mapeditor.h
author insilmaril
Wed Apr 25 16:02:54 2007 +0000 (2007-04-25)
changeset 463 694f5e35e87c
parent 442 dfbc371b7280
child 473 8b9cfc26638c
permissions -rw-r--r--
started doxygen documentation
insilmaril@0
     1
#ifndef MAPEDITOR_H
insilmaril@0
     2
#define MAPEDITOR_H
insilmaril@0
     3
insilmaril@442
     4
//#include <QBuffer>
insilmaril@408
     5
#include <QGraphicsView>
insilmaril@0
     6
insilmaril@0
     7
#include "mapcenterobj.h"
insilmaril@175
     8
#include "file.h"
insilmaril@0
     9
#include "misc.h"
insilmaril@432
    10
#include "parser.h"
insilmaril@366
    11
#include "selection.h"
insilmaril@366
    12
#include "settings.h"
insilmaril@0
    13
insilmaril@119
    14
insilmaril@408
    15
class MapEditor : public QGraphicsView, public xmlObj {
insilmaril@0
    16
    Q_OBJECT
insilmaril@0
    17
insilmaril@0
    18
public:
insilmaril@408
    19
    MapEditor(QWidget* parent=0);
insilmaril@0
    20
	~MapEditor();
insilmaril@0
    21
    MapCenterObj* getMapCenter();
insilmaril@408
    22
	QGraphicsScene * getScene();
insilmaril@139
    23
	bool isRepositionBlocked(); // block while load or undo
insilmaril@0
    24
	
insilmaril@0
    25
private:
insilmaril@420
    26
	QString getName(const LinkableMapObj*);	// Get e.g. heading or filename
insilmaril@0
    27
	void makeTmpDirs();		// create temporary directories
insilmaril@408
    28
    QString saveToDir(const QString&,const QString &,bool, const QPointF &,LinkableMapObj*);
insilmaril@395
    29
    void saveStateChangingPart (LinkableMapObj *, LinkableMapObj *, const QString &, const QString &);
insilmaril@393
    30
    void saveStateRemovingPart (LinkableMapObj *, const QString &);
insilmaril@366
    31
    void saveState(LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &);
insilmaril@366
    32
    void saveState(const QString &, const QString &, const QString &, const QString &, const QString &);
insilmaril@366
    33
    void saveState(const SaveMode&, const QString &, const QString &, const QString &, const QString &, const QString &, LinkableMapObj *);
insilmaril@393
    34
public:	
insilmaril@432
    35
    void parseAtom (const QString &);	
insilmaril@432
    36
	void runScript (QString);
insilmaril@393
    37
private:
insilmaril@395
    38
    void addFloatImageInt(const QPixmap &img);
insilmaril@119
    39
insilmaril@0
    40
public:
insilmaril@0
    41
	bool isDefault();		// false, if map was changed once
insilmaril@0
    42
    bool isUnsaved();		// save necessary
insilmaril@0
    43
    bool hasChanged();		// undo possible
insilmaril@0
    44
	void setChanged();		// called from NoteEditor via LMO
insilmaril@0
    45
	void closeMap();
insilmaril@0
    46
	void setFilePath (QString);	
insilmaril@0
    47
	void setFilePath (QString,QString);	
insilmaril@0
    48
	QString getFilePath ();	// Full path e.g. "/home/tux/map.xml"
insilmaril@0
    49
	QString getFileName ();	// e.g. "map.xml"
insilmaril@0
    50
	QString getMapName ();	// e.g. "map"
insilmaril@0
    51
	QString getDestPath (); // e.g. "/home/tux/map.vym"
insilmaril@205
    52
    ErrorCode load (QString, LoadMode );	// newmap, import/replace selection
insilmaril@163
    53
public:
insilmaril@0
    54
    int save(const SaveMode &);	// Save map 
insilmaril@0
    55
	void setZipped(bool);		// save map zipped
insilmaril@0
    56
	bool saveZipped();			// 1 if file will be saved zipped
insilmaril@0
    57
    void print();				// print canvas
insilmaril@408
    58
	void setAntiAlias (bool);
insilmaril@408
    59
	void setSmoothPixmap(bool);
insilmaril@0
    60
private:
insilmaril@0
    61
    QPixmap getPixmap();
insilmaril@260
    62
	void setHideTmpMode (HideTmpMode);	// temporary hide stuff
insilmaril@260
    63
	HideTmpMode getHideTmpMode();		// temporary hide stuff
insilmaril@0
    64
public:
insilmaril@260
    65
	void setExportMode (bool);			// temporary hide stuff during export
insilmaril@366
    66
    void exportImage (QString fn);			// export as PNG	
insilmaril@366
    67
    void exportImage (QString fn, QString);	// export in given format
insilmaril@185
    68
    void exportOOPresentation(const QString &,const QString &);
insilmaril@0
    69
    void exportXML(const QString&);		// export to directory
insilmaril@0
    70
    void clear();		// clear map
insilmaril@106
    71
    void copy();		// copy branch to clipboard
insilmaril@163
    72
    void redo();		// redo last action
insilmaril@390
    73
	bool isRedoAvailable();
insilmaril@0
    74
    void undo();		// undo last action
insilmaril@390
    75
	bool isUndoAvailable();
insilmaril@404
    76
	void gotoHistoryStep (int);// goto a step in history
insilmaril@0
    77
private:	
insilmaril@394
    78
    void addMapReplaceInt(const QString & undoSel, const QString & path);
insilmaril@394
    79
    void addMapInsertInt (const QString & path, int pos);
insilmaril@166
    80
    void pasteNoSave();		// paste clipboard to branch
insilmaril@0
    81
    void cutNoSave();	// cut to clipboard
insilmaril@0
    82
public:	
insilmaril@0
    83
    void paste();		// paste clipboard to branch and backup
insilmaril@0
    84
    void cut();			// cut to clipboard and backup
insilmaril@393
    85
    void move    (const int &x, const int &y);
insilmaril@393
    86
    void moveRel (const int &x, const int &y);
insilmaril@0
    87
    void moveBranchUp();
insilmaril@0
    88
    void moveBranchDown();
insilmaril@420
    89
private:	
insilmaril@420
    90
	void linkTo(const QString &);
insilmaril@420
    91
public:	
insilmaril@393
    92
	QString getHeading (bool &ok,QPoint &p); // Get heading, ok if selection is branch
insilmaril@366
    93
	void setHeading(const QString &);
insilmaril@106
    94
private:
insilmaril@366
    95
	void setHeadingInt(const QString &);
insilmaril@366
    96
	void setURLInt(const QString &);		// Just set the URL for selection
insilmaril@366
    97
	void setVymLinkInt(const QString &);	// Set vymLink for selection
insilmaril@366
    98
    BranchObj* addNewBranchInt(int);		// pos allows to add above/below selection
insilmaril@106
    99
public:	
insilmaril@394
   100
    BranchObj* addNewBranch(int);			// pos allows to add above/below selection
insilmaril@394
   101
    BranchObj* addNewBranchBefore();		// insert and make selection its
insilmaril@0
   102
    void deleteSelection();
insilmaril@442
   103
	LinkableMapObj* getSelection();			// returns selection
insilmaril@442
   104
	BranchObj* getSelectedBranch();			// returns selected branch or NULL
insilmaril@442
   105
	FloatImageObj* getSelectedFloatImage();	// returns selected branch or NULL
insilmaril@442
   106
	void unselect();						// before changing current noteedit
insilmaril@442
   107
	void reselect();						// after  changing current noteedit
insilmaril@442
   108
	bool select(const QString &);			// Select by string
insilmaril@366
   109
	QString getSelectString();
insilmaril@0
   110
private:	
insilmaril@366
   111
	void selectInt(LinkableMapObj*);	
insilmaril@366
   112
	void selectNextBranchInt();		// Increment number of branch
insilmaril@366
   113
	void selectPrevBranchInt();		// Decrement number of branch
insilmaril@0
   114
public:	
insilmaril@0
   115
    void selectUpperBranch();
insilmaril@0
   116
    void selectLowerBranch();
insilmaril@0
   117
    void selectLeftBranch();
insilmaril@0
   118
    void selectRightBranch();
insilmaril@0
   119
    void selectFirstBranch();
insilmaril@0
   120
    void selectLastBranch();
insilmaril@408
   121
    void selectMapBackgroundImage();
insilmaril@408
   122
    void setMapBackgroundImage(const QString &);
insilmaril@398
   123
    void selectMapBackgroundColor();
insilmaril@398
   124
    void setMapBackgroundColor(QColor);
insilmaril@398
   125
    QColor getMapBackgroundColor();
insilmaril@395
   126
    QColor getCurrentHeadingColor();
insilmaril@395
   127
    void colorBranch(QColor);
insilmaril@417
   128
    void colorSubtree(QColor);
insilmaril@0
   129
	void toggleStandardFlag(QString);
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@442
   148
	void ensureSelectionVisible();		
insilmaril@442
   149
	void updateSelection();					// update geometry of selection
insilmaril@0
   150
	void updateActions();					// update e.g. format buttons
insilmaril@160
   151
	void updateNoteFlag();					// when TextEditor changes
insilmaril@398
   152
	void setMapAuthor (const QString &);
insilmaril@398
   153
	void setMapComment(const QString &);
insilmaril@398
   154
	void setMapLinkStyle (const QString &);	// Set style of link
insilmaril@398
   155
	LinkStyle getMapLinkStyle ();			// requested in LMO
insilmaril@398
   156
	void setMapDefLinkColor(QColor);		// default color of links
insilmaril@398
   157
	void setMapLinkColorHintInt();			// color of links
insilmaril@398
   158
	void setMapLinkColorHint(LinkColorHint);// color of links
insilmaril@398
   159
	LinkColorHint getMapLinkColorHint();
insilmaril@398
   160
	QColor getMapDefLinkColor();
insilmaril@398
   161
	void setMapDefXLinkColor(QColor);
insilmaril@398
   162
	QColor getMapDefXLinkColor();
insilmaril@398
   163
	void setMapDefXLinkWidth (int);
insilmaril@398
   164
	int getMapDefXLinkWidth();
insilmaril@398
   165
	void toggleMapLinkColorHint();			// after changing linkStyles
insilmaril@398
   166
    void selectMapLinkColor();
insilmaril@442
   167
    void selectMapSelectionColor();
insilmaril@442
   168
private:	
insilmaril@442
   169
    void setSelectionColorInt(QColor);
insilmaril@442
   170
public:	
insilmaril@442
   171
    void setSelectionColor(QColor);
insilmaril@442
   172
    QColor getSelectionColor();
insilmaril@427
   173
	bool scrollBranch();
insilmaril@427
   174
	bool unscrollBranch();
insilmaril@0
   175
    void toggleScroll();
insilmaril@428
   176
    void unscrollChilds();
insilmaril@432
   177
private:	
insilmaril@432
   178
	FloatImageObj* loadFloatImageInt (QString);
insilmaril@432
   179
public:	
insilmaril@0
   180
	void loadFloatImage ();
insilmaril@434
   181
private:	
insilmaril@434
   182
	void saveFloatImageInt (FloatImageObj*, const QString &, const QString &);
insilmaril@434
   183
public:	
insilmaril@366
   184
	void saveFloatImage ();
insilmaril@442
   185
	void setFrameType(const FrameType &);
insilmaril@445
   186
	void setFrameType(const QString &);
insilmaril@442
   187
	void setFramePenColor (const QColor &);
insilmaril@442
   188
	void setFrameBrushColor (const QColor &);
insilmaril@175
   189
	void setIncludeImagesVer(bool);
insilmaril@175
   190
	void setIncludeImagesHor(bool);
insilmaril@160
   191
	void setHideLinkUnselected (bool);
insilmaril@160
   192
	bool getHideLinkUnselected ();
insilmaril@0
   193
private:	
insilmaril@366
   194
    void importDirInt(BranchObj *,QDir);
insilmaril@0
   195
public:	
insilmaril@0
   196
    void importDir();
insilmaril@95
   197
	void followXLink (int);
insilmaril@95
   198
	void editXLink (int);
insilmaril@366
   199
    void testFunction();					// just testing new stuff
insilmaril@366
   200
											// set /mainwindo/showTestMenu=true...
insilmaril@0
   201
insilmaril@0
   202
protected:
insilmaril@408
   203
	virtual void contextMenuEvent ( QContextMenuEvent *e );
insilmaril@398
   204
    virtual void keyPressEvent(QKeyEvent*);
insilmaril@398
   205
    virtual void keyReleaseEvent(QKeyEvent*);
insilmaril@408
   206
    virtual void mousePressEvent(QMouseEvent*);
insilmaril@408
   207
    virtual void mouseReleaseEvent(QMouseEvent*);
insilmaril@408
   208
    virtual void mouseDoubleClickEvent(QMouseEvent*);
insilmaril@408
   209
    virtual void mouseMoveEvent(QMouseEvent*);
insilmaril@0
   210
insilmaril@417
   211
	void dragEnterEvent (QDragEnterEvent *);
insilmaril@417
   212
	void dragMoveEvent (QDragMoveEvent *);
insilmaril@417
   213
	void dragLeaveEvent (QDragLeaveEvent *);
insilmaril@417
   214
	void dropEvent (QDropEvent *);
insilmaril@412
   215
insilmaril@0
   216
private:
insilmaril@408
   217
	QGraphicsScene *mapScene;
insilmaril@0
   218
    MapCenterObj* mapCenter;
insilmaril@0
   219
insilmaril@0
   220
	bool adjustCanvasRequested;	// collect requests until end of user event
insilmaril@0
   221
	BranchObj *editingBO;		// entering Text into BO
insilmaril@0
   222
insilmaril@97
   223
	QColor defLinkColor;		// default color for links
insilmaril@97
   224
	QColor defXLinkColor;		// default color for xlinks
insilmaril@97
   225
	int defXLinkWidth;			// default width for xlinks
insilmaril@0
   226
	LinkColorHint linkcolorhint;// use heading color or own color
insilmaril@0
   227
	LinkStyle linkstyle;		// default style for links
insilmaril@0
   228
insilmaril@398
   229
    QCursor HandOpenCursor;		// cursor while moving canvas view
insilmaril@398
   230
	QCursor PickColorCursor;	// cursor while picking color 
insilmaril@398
   231
	QCursor CopyCursor;			// cursor while picking color 
insilmaril@398
   232
	QCursor XLinkCursor;		// cursor while picking color 
insilmaril@83
   233
	bool pickingColor;
insilmaril@83
   234
	bool drawingLink;			// true while creating a link
insilmaril@93
   235
	bool copyingObj;			// true while creating a link
insilmaril@95
   236
	XLinkObj* tmpXLink;
insilmaril@366
   237
insilmaril@424
   238
	Selection xelection;	
insilmaril@0
   239
    MapObj* movingObj;				// moving a MapObj
insilmaril@83
   240
	MapObj* linkingObj_src;			// part of a link
insilmaril@408
   241
    QPointF movingObj_orgPos;		// org. pos of mouse before move
insilmaril@408
   242
    QPointF movingObj_orgRelPos;	// org. relative pos of mouse before move
insilmaril@408
   243
    QPointF movingObj_start;		// rel. pos of mouse to absPos 
insilmaril@408
   244
    QPointF movingCont_start;		// inital pos of moving Content or
insilmaril@408
   245
    QPointF movingVec;				// how far has Content moved
insilmaril@0
   246
    QPrinter* printer;				// Printing
insilmaril@0
   247
insilmaril@0
   248
    bool mapDefault;				// Flag if map is untouched
insilmaril@0
   249
    bool mapChanged;				// Flag if undo is possible
insilmaril@0
   250
	bool mapUnsaved;				// Flag if map should be saved
insilmaril@0
   251
insilmaril@432
   252
	Parser parser;				// Parser stuff for scripting
insilmaril@432
   253
insilmaril@0
   254
	bool printFrame;			// Print frame around map
insilmaril@0
   255
	bool printFooter;			// Print footer below map
insilmaril@0
   256
insilmaril@0
   257
	bool zipped;				// should map be zipped
insilmaril@393
   258
	static	int mapNum;			// unique number for Editor
insilmaril@0
   259
	QString fileName;			// short name of file (for tab)
insilmaril@0
   260
	QString filePath;			// path to file which will be saved
insilmaril@0
   261
	QString fileDir;			// dir where file is saved
insilmaril@0
   262
	QString destPath;			// path to .vym file (needed for vymlinks)
insilmaril@0
   263
	QString mapName;			// fileName without ".vym"
insilmaril@0
   264
insilmaril@377
   265
	QString tmpMapDir;			// tmp directory with undo history
insilmaril@366
   266
	QString histPath;			// Path to history file
insilmaril@381
   267
	int stepsTotal;				// total number of steps (undos+redos) 
insilmaril@366
   268
	SimpleSettings undoSet;		// undo/redo commands
insilmaril@139
   269
	bool blockReposition;		// block while load or undo
insilmaril@139
   270
	bool blockSaveState;		// block while load or undo
insilmaril@0
   271
insilmaril@0
   272
	BranchObj* itFind;			// next object in find process
insilmaril@0
   273
	bool EOFind;				// true, if search failed
insilmaril@0
   274
insilmaril@0
   275
	QPoint exportOffset;		// set before export, used in save
insilmaril@260
   276
	HideTmpMode hidemode;			// true while exporting to hide some stuff
insilmaril@260
   277
	
insilmaril@0
   278
    void resizeEvent( QResizeEvent * );
insilmaril@0
   279
};
insilmaril@0
   280
#endif
insilmaril@0
   281