mapeditor.h
author insilmaril
Thu Nov 16 13:43:06 2006 +0000 (2006-11-16)
changeset 401 f364b13047ba
parent 395 7ced3733ba60
child 404 53efc2562a7d
permissions -rw-r--r--
Fixed OS X crash when trying to load recent map
insilmaril@0
     1
#ifndef MAPEDITOR_H
insilmaril@0
     2
#define MAPEDITOR_H
insilmaril@0
     3
insilmaril@366
     4
#include <q3canvas.h>
insilmaril@366
     5
#include <QBuffer>
insilmaril@0
     6
insilmaril@0
     7
#include "mapcenterobj.h"
insilmaril@175
     8
#include "file.h"
insilmaril@377
     9
#include "historywindow.h"
insilmaril@0
    10
#include "misc.h"
insilmaril@366
    11
#include "selection.h"
insilmaril@366
    12
#include "settings.h"
insilmaril@0
    13
insilmaril@366
    14
class Q3NetworkOperation;
insilmaril@366
    15
class Q3UrlOperator;
insilmaril@119
    16
insilmaril@366
    17
class MapEditor : public Q3CanvasView , public xmlObj {
insilmaril@0
    18
    Q_OBJECT
insilmaril@0
    19
insilmaril@0
    20
public:
insilmaril@390
    21
    MapEditor(QWidget* parent=0,  const char* name=0, Qt::WFlags f=0);
insilmaril@0
    22
	~MapEditor();
insilmaril@0
    23
    MapCenterObj* getMapCenter();
insilmaril@366
    24
	Q3Canvas* getCanvas();
insilmaril@0
    25
	void adjustCanvasSize();// adjust canvas size to map and scrollview
insilmaril@139
    26
	bool isRepositionBlocked(); // block while load or undo
insilmaril@0
    27
	
insilmaril@0
    28
private:
insilmaril@295
    29
	QString getName(LinkableMapObj*);	// Get e.g. heading or filename
insilmaril@0
    30
	void makeTmpDirs();		// create temporary directories
insilmaril@106
    31
    QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*);
insilmaril@395
    32
    void saveStateChangingPart (LinkableMapObj *, LinkableMapObj *, const QString &, const QString &);
insilmaril@393
    33
    void saveStateRemovingPart (LinkableMapObj *, const QString &);
insilmaril@366
    34
    void saveState(LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &);
insilmaril@366
    35
    void saveState(const QString &, const QString &, const QString &, const QString &, const QString &);
insilmaril@366
    36
    void saveState(const SaveMode&, const QString &, const QString &, const QString &, const QString &, const QString &, LinkableMapObj *);
insilmaril@393
    37
public:	
insilmaril@106
    38
    void parseAtom(const QString &);	
insilmaril@393
    39
private:
insilmaril@395
    40
    void addFloatImageInt(const QPixmap &img);
insilmaril@119
    41
insilmaril@119
    42
  private slots:
insilmaril@119
    43
    void fetchImage(const QString &img);
insilmaril@366
    44
    void imageDataFetched(const QByteArray &, Q3NetworkOperation *);
insilmaril@366
    45
    void imageDataFinished(Q3NetworkOperation *);
insilmaril@0
    46
insilmaril@0
    47
public:
insilmaril@295
    48
	void toggleHistoryWindow();
insilmaril@0
    49
	bool isDefault();		// false, if map was changed once
insilmaril@0
    50
    bool isUnsaved();		// save necessary
insilmaril@0
    51
    bool hasChanged();		// undo possible
insilmaril@0
    52
	void setChanged();		// called from NoteEditor via LMO
insilmaril@0
    53
	void closeMap();
insilmaril@0
    54
	void setFilePath (QString);	
insilmaril@0
    55
	void setFilePath (QString,QString);	
insilmaril@0
    56
	QString getFilePath ();	// Full path e.g. "/home/tux/map.xml"
insilmaril@0
    57
	QString getFileName ();	// e.g. "map.xml"
insilmaril@0
    58
	QString getMapName ();	// e.g. "map"
insilmaril@0
    59
	QString getDestPath (); // e.g. "/home/tux/map.vym"
insilmaril@205
    60
    ErrorCode load (QString, LoadMode );	// newmap, import/replace selection
insilmaril@163
    61
public:
insilmaril@0
    62
    int save(const SaveMode &);	// Save map 
insilmaril@0
    63
	void setZipped(bool);		// save map zipped
insilmaril@0
    64
	bool saveZipped();			// 1 if file will be saved zipped
insilmaril@0
    65
    void print();				// print canvas
insilmaril@0
    66
private:
insilmaril@0
    67
    QPixmap getPixmap();
insilmaril@260
    68
	void setHideTmpMode (HideTmpMode);	// temporary hide stuff
insilmaril@260
    69
	HideTmpMode getHideTmpMode();		// temporary hide stuff
insilmaril@0
    70
public:
insilmaril@260
    71
	void setExportMode (bool);			// temporary hide stuff during export
insilmaril@366
    72
    void exportImage (QString fn);			// export as PNG	
insilmaril@366
    73
    void exportImage (QString fn, QString);	// export in given format
insilmaril@185
    74
    void exportOOPresentation(const QString &,const QString &);
insilmaril@0
    75
    void exportXML(const QString&);		// export to directory
insilmaril@0
    76
    void clear();		// clear map
insilmaril@106
    77
    void copy();		// copy branch to clipboard
insilmaril@163
    78
    void redo();		// redo last action
insilmaril@390
    79
	bool isRedoAvailable();
insilmaril@0
    80
    void undo();		// undo last action
insilmaril@390
    81
	bool isUndoAvailable();
insilmaril@381
    82
	void gotoStep (int);// goto a step in history
insilmaril@0
    83
private:	
insilmaril@394
    84
    void addMapReplaceInt(const QString & undoSel, const QString & path);
insilmaril@394
    85
    void addMapInsertInt (const QString & path, int pos);
insilmaril@166
    86
    void pasteNoSave();		// paste clipboard to branch
insilmaril@0
    87
    void cutNoSave();	// cut to clipboard
insilmaril@0
    88
public:	
insilmaril@0
    89
    void paste();		// paste clipboard to branch and backup
insilmaril@0
    90
    void cut();			// cut to clipboard and backup
insilmaril@393
    91
    void move    (const int &x, const int &y);
insilmaril@393
    92
    void moveRel (const int &x, const int &y);
insilmaril@0
    93
    void moveBranchUp();
insilmaril@0
    94
    void moveBranchDown();
insilmaril@393
    95
	QString getHeading (bool &ok,QPoint &p); // Get heading, ok if selection is branch
insilmaril@366
    96
	void setHeading(const QString &);
insilmaril@106
    97
private:
insilmaril@366
    98
	void setHeadingInt(const QString &);
insilmaril@366
    99
	void setURLInt(const QString &);		// Just set the URL for selection
insilmaril@366
   100
	void setVymLinkInt(const QString &);	// Set vymLink for selection
insilmaril@366
   101
    BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
insilmaril@106
   102
public:	
insilmaril@394
   103
    BranchObj* addNewBranch(int);			// pos allows to add above/below selection
insilmaril@394
   104
    BranchObj* addNewBranchBefore();		// insert and make selection its
insilmaril@0
   105
    void deleteSelection();
insilmaril@0
   106
	LinkableMapObj* getSelection();	// returns selection
insilmaril@0
   107
	void unselect();				// before changing current noteedit
insilmaril@0
   108
	void reselect();				// after  changing current noteedit
insilmaril@366
   109
	bool select(const QString &);	// Select by string
insilmaril@366
   110
	QString getSelectString();
insilmaril@0
   111
private:	
insilmaril@366
   112
	void selectInt(LinkableMapObj*);	
insilmaril@366
   113
	void selectNextBranchInt();		// Increment number of branch
insilmaril@366
   114
	void selectPrevBranchInt();		// Decrement number of branch
insilmaril@0
   115
public:	
insilmaril@0
   116
    void selectUpperBranch();
insilmaril@0
   117
    void selectLowerBranch();
insilmaril@0
   118
    void selectLeftBranch();
insilmaril@0
   119
    void selectRightBranch();
insilmaril@0
   120
    void selectFirstBranch();
insilmaril@0
   121
    void selectLastBranch();
insilmaril@398
   122
    void selectMapBackgroundColor();
insilmaril@398
   123
    void setMapBackgroundColor(QColor);
insilmaril@398
   124
    QColor getMapBackgroundColor();
insilmaril@395
   125
    QColor getCurrentHeadingColor();
insilmaril@395
   126
    void colorItem(QColor);
insilmaril@395
   127
    void colorBranch(QColor);
insilmaril@0
   128
	void toggleStandardFlag(QString);
insilmaril@0
   129
	virtual void setViewCenter();			// needed for zooming
insilmaril@0
   130
    BranchObj* findText(QString,bool);		// Find object
insilmaril@0
   131
    void findReset();						// Reset Find 
insilmaril@395
   132
	void setURL(const QString &);			// set the URL
insilmaril@0
   133
	void editURL();							// edit the URL
insilmaril@266
   134
	QString getURL();						// returns URL of selection or ""
insilmaril@366
   135
	QStringList getURLs();					// returns URLs of subtree
insilmaril@0
   136
	void editHeading2URL();					// copy heading to URL
insilmaril@0
   137
	void editBugzilla2URL();				// create URL to Bugzilla
insilmaril@175
   138
	void editFATE2URL();					// create URL to FATE
insilmaril@0
   139
	void editVymLink();						// edit link to another map
insilmaril@0
   140
	void deleteVymLink();					// delete link to another map
insilmaril@0
   141
	QString getVymLink();					// return path to map
insilmaril@366
   142
	QStringList getVymLinks();				// return paths in subtree
insilmaril@395
   143
	void setHideExport(bool);				// toggle the export flag
insilmaril@243
   144
	void toggleHideExport();				// toggle the export flag
insilmaril@395
   145
	void deleteKeepChilds();				// remove but keep childs
insilmaril@395
   146
	void deleteChilds();					// remove childs
insilmaril@0
   147
	void editMapInfo();						// dialog to enter author, ...
insilmaril@0
   148
	void updateActions();					// update e.g. format buttons
insilmaril@160
   149
	void updateNoteFlag();					// when TextEditor changes
insilmaril@398
   150
	void setMapAuthor (const QString &);
insilmaril@398
   151
	void setMapComment(const QString &);
insilmaril@398
   152
	void setMapLinkStyle (const QString &);	// Set style of link
insilmaril@398
   153
	LinkStyle getMapLinkStyle ();			// requested in LMO
insilmaril@398
   154
	void setMapDefLinkColor(QColor);		// default color of links
insilmaril@398
   155
	void setMapLinkColorHintInt();			// color of links
insilmaril@398
   156
	void setMapLinkColorHint(LinkColorHint);// color of links
insilmaril@398
   157
	LinkColorHint getMapLinkColorHint();
insilmaril@398
   158
	QColor getMapDefLinkColor();
insilmaril@398
   159
	void setMapDefXLinkColor(QColor);
insilmaril@398
   160
	QColor getMapDefXLinkColor();
insilmaril@398
   161
	void setMapDefXLinkWidth (int);
insilmaril@398
   162
	int getMapDefXLinkWidth();
insilmaril@398
   163
	void toggleMapLinkColorHint();			// after changing linkStyles
insilmaril@398
   164
    void selectMapLinkColor();
insilmaril@0
   165
    void toggleScroll();
insilmaril@0
   166
    void unScrollAll();
insilmaril@0
   167
	void loadFloatImage ();
insilmaril@366
   168
	void saveFloatImage ();
insilmaril@0
   169
	void setFrame(const FrameType &);
insilmaril@175
   170
	void setIncludeImagesVer(bool);
insilmaril@175
   171
	void setIncludeImagesHor(bool);
insilmaril@160
   172
	void setHideLinkUnselected (bool);
insilmaril@160
   173
	bool getHideLinkUnselected ();
insilmaril@0
   174
private:	
insilmaril@366
   175
    void importDirInt(BranchObj *,QDir);
insilmaril@0
   176
public:	
insilmaril@0
   177
    void importDir();
insilmaril@95
   178
	void followXLink (int);
insilmaril@95
   179
	void editXLink (int);
insilmaril@366
   180
    void testFunction();					// just testing new stuff
insilmaril@366
   181
											// set /mainwindo/showTestMenu=true...
insilmaril@0
   182
insilmaril@0
   183
protected:
insilmaril@0
   184
	void ensureSelectionVisible();		
insilmaril@0
   185
	virtual void updateViewCenter();	// needed for zooming
insilmaril@0
   186
	virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
insilmaril@398
   187
    virtual void keyPressEvent(QKeyEvent*);
insilmaril@398
   188
    virtual void keyReleaseEvent(QKeyEvent*);
insilmaril@0
   189
    virtual void contentsMousePressEvent(QMouseEvent*);
insilmaril@0
   190
    virtual void contentsMouseReleaseEvent(QMouseEvent*);
insilmaril@0
   191
    virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
insilmaril@0
   192
    virtual void contentsMouseMoveEvent(QMouseEvent*);
insilmaril@0
   193
insilmaril@119
   194
    virtual void contentsDragEnterEvent(QDragEnterEvent *event);
insilmaril@119
   195
    virtual void contentsDropEvent(QDropEvent *event);
insilmaril@0
   196
private:
insilmaril@366
   197
    Q3Canvas* mapCanvas;
insilmaril@0
   198
    MapCenterObj* mapCenter;
insilmaril@0
   199
insilmaril@0
   200
	bool adjustCanvasRequested;	// collect requests until end of user event
insilmaril@0
   201
	BranchObj *editingBO;		// entering Text into BO
insilmaril@0
   202
insilmaril@97
   203
	QColor defLinkColor;		// default color for links
insilmaril@97
   204
	QColor defXLinkColor;		// default color for xlinks
insilmaril@97
   205
	int defXLinkWidth;			// default width for xlinks
insilmaril@0
   206
	LinkColorHint linkcolorhint;// use heading color or own color
insilmaril@0
   207
	LinkStyle linkstyle;		// default style for links
insilmaril@0
   208
insilmaril@398
   209
    QCursor HandOpenCursor;		// cursor while moving canvas view
insilmaril@398
   210
	QCursor PickColorCursor;	// cursor while picking color 
insilmaril@398
   211
	QCursor CopyCursor;			// cursor while picking color 
insilmaril@398
   212
	QCursor XLinkCursor;		// cursor while picking color 
insilmaril@83
   213
	bool pickingColor;
insilmaril@83
   214
	bool drawingLink;			// true while creating a link
insilmaril@93
   215
	bool copyingObj;			// true while creating a link
insilmaril@95
   216
	XLinkObj* tmpXLink;
insilmaril@366
   217
insilmaril@366
   218
	Selection xelection;
insilmaril@0
   219
    LinkableMapObj* selection;		// select a LinkableMapObj
insilmaril@0
   220
    LinkableMapObj* selectionLast;	// last selection 
insilmaril@0
   221
    MapObj* movingObj;				// moving a MapObj
insilmaril@83
   222
	MapObj* linkingObj_src;			// part of a link
insilmaril@129
   223
    QPoint movingObj_orgPos;		// org. pos of mouse before move
insilmaril@366
   224
    QPoint movingObj_orgRelPos;		// org. relative pos of mouse before move
insilmaril@0
   225
    QPoint movingObj_start;			// rel. pos of mouse to absPos 
insilmaril@0
   226
    QPoint movingCont_start;		// inital pos of moving Content or
insilmaril@0
   227
    QPoint movingVec;				// how far has Content moved
insilmaril@0
   228
	QPoint movingCenter;			// used when zooming
insilmaril@0
   229
    QPrinter* printer;				// Printing
insilmaril@0
   230
insilmaril@0
   231
    bool mapDefault;				// Flag if map is untouched
insilmaril@0
   232
    bool mapChanged;				// Flag if undo is possible
insilmaril@0
   233
	bool mapUnsaved;				// Flag if map should be saved
insilmaril@0
   234
insilmaril@0
   235
	bool printFrame;			// Print frame around map
insilmaril@0
   236
	bool printFooter;			// Print footer below map
insilmaril@0
   237
insilmaril@0
   238
	bool zipped;				// should map be zipped
insilmaril@393
   239
	static	int mapNum;			// unique number for Editor
insilmaril@0
   240
	QString fileName;			// short name of file (for tab)
insilmaril@0
   241
	QString filePath;			// path to file which will be saved
insilmaril@0
   242
	QString fileDir;			// dir where file is saved
insilmaril@0
   243
	QString destPath;			// path to .vym file (needed for vymlinks)
insilmaril@0
   244
	QString mapName;			// fileName without ".vym"
insilmaril@0
   245
insilmaril@377
   246
	QString tmpMapDir;			// tmp directory with undo history
insilmaril@366
   247
	QString histPath;			// Path to history file
insilmaril@381
   248
	int stepsTotal;				// total number of steps (undos+redos) 
insilmaril@366
   249
	SimpleSettings undoSet;		// undo/redo commands
insilmaril@139
   250
	bool blockReposition;		// block while load or undo
insilmaril@139
   251
	bool blockSaveState;		// block while load or undo
insilmaril@0
   252
insilmaril@0
   253
	BranchObj* itFind;			// next object in find process
insilmaril@0
   254
	bool EOFind;				// true, if search failed
insilmaril@0
   255
insilmaril@0
   256
	QPoint exportOffset;		// set before export, used in save
insilmaril@260
   257
	HideTmpMode hidemode;			// true while exporting to hide some stuff
insilmaril@260
   258
	
insilmaril@0
   259
    void resizeEvent( QResizeEvent * );
insilmaril@119
   260
insilmaril@381
   261
	Q3UrlOperator *urlOperator;
insilmaril@381
   262
	QDataStream *imageData;
insilmaril@381
   263
	QBuffer *imageBuffer;
insilmaril@119
   264
insilmaril@377
   265
	HistoryWindow historyWindow;
insilmaril@295
   266
insilmaril@0
   267
};
insilmaril@0
   268
#endif
insilmaril@0
   269