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