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