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 BranchObj* getSelectedBranch(); // returns selected branch or NULL
105 FloatImageObj* getSelectedFloatImage(); // returns selected branch or NULL
106 void unselect(); // before changing current noteedit
107 void reselect(); // after changing current noteedit
108 bool select(const QString &); // Select by string
109 QString getSelectString();
111 void selectInt(LinkableMapObj*);
112 void selectNextBranchInt(); // Increment number of branch
113 void selectPrevBranchInt(); // Decrement number of branch
115 void selectUpperBranch();
116 void selectLowerBranch();
117 void selectLeftBranch();
118 void selectRightBranch();
119 void selectFirstBranch();
120 void selectLastBranch();
121 void selectMapBackgroundImage();
122 void setMapBackgroundImage(const QString &);
123 void selectMapBackgroundColor();
124 void setMapBackgroundColor(QColor);
125 QColor getMapBackgroundColor();
126 QColor getCurrentHeadingColor();
127 void colorBranch(QColor);
128 void colorSubtree(QColor);
129 void toggleStandardFlag(QString);
130 BranchObj* findText(QString,bool); // Find object
131 void findReset(); // Reset Find
132 void setURL(const QString &); // set the URL
133 void editURL(); // edit the URL
134 QString getURL(); // returns URL of selection or ""
135 QStringList getURLs(); // returns URLs of subtree
136 void editHeading2URL(); // copy heading to URL
137 void editBugzilla2URL(); // create URL to Bugzilla
138 void editFATE2URL(); // create URL to FATE
139 void editVymLink(); // edit link to another map
140 void deleteVymLink(); // delete link to another map
141 QString getVymLink(); // return path to map
142 QStringList getVymLinks(); // return paths in subtree
143 void setHideExport(bool); // toggle the export flag
144 void toggleHideExport(); // toggle the export flag
145 void deleteKeepChilds(); // remove but keep childs
146 void deleteChilds(); // remove childs
147 void editMapInfo(); // dialog to enter author, ...
148 void ensureSelectionVisible();
149 void updateSelection(); // update geometry of selection
150 void updateActions(); // update e.g. format buttons
151 void updateNoteFlag(); // when TextEditor changes
152 void setMapAuthor (const QString &);
153 void setMapComment(const QString &);
154 void setMapLinkStyle (const QString &); // Set style of link
155 LinkStyle getMapLinkStyle (); // requested in LMO
156 void setMapDefLinkColor(QColor); // default color of links
157 void setMapLinkColorHintInt(); // color of links
158 void setMapLinkColorHint(LinkColorHint);// color of links
159 LinkColorHint getMapLinkColorHint();
160 QColor getMapDefLinkColor();
161 void setMapDefXLinkColor(QColor);
162 QColor getMapDefXLinkColor();
163 void setMapDefXLinkWidth (int);
164 int getMapDefXLinkWidth();
165 void toggleMapLinkColorHint(); // after changing linkStyles
166 void selectMapLinkColor();
167 void selectMapSelectionColor();
169 void setSelectionColorInt(QColor);
171 void setSelectionColor(QColor);
172 QColor getSelectionColor();
174 bool unscrollBranch();
176 void unscrollChilds();
178 FloatImageObj* loadFloatImageInt (QString);
180 void loadFloatImage ();
182 void saveFloatImageInt (FloatImageObj*, const QString &, const QString &);
184 void saveFloatImage ();
185 void setFrameType(const FrameType &);
186 void setFramePenColor (const QColor &);
187 void setFrameBrushColor (const QColor &);
188 void setIncludeImagesVer(bool);
189 void setIncludeImagesHor(bool);
190 void setHideLinkUnselected (bool);
191 bool getHideLinkUnselected ();
193 void importDirInt(BranchObj *,QDir);
196 void followXLink (int);
197 void editXLink (int);
198 void testFunction(); // just testing new stuff
199 // set /mainwindo/showTestMenu=true...
202 virtual void contextMenuEvent ( QContextMenuEvent *e );
203 virtual void keyPressEvent(QKeyEvent*);
204 virtual void keyReleaseEvent(QKeyEvent*);
205 virtual void mousePressEvent(QMouseEvent*);
206 virtual void mouseReleaseEvent(QMouseEvent*);
207 virtual void mouseDoubleClickEvent(QMouseEvent*);
208 virtual void mouseMoveEvent(QMouseEvent*);
210 void dragEnterEvent (QDragEnterEvent *);
211 void dragMoveEvent (QDragMoveEvent *);
212 void dragLeaveEvent (QDragLeaveEvent *);
213 void dropEvent (QDropEvent *);
216 QGraphicsScene *mapScene;
217 MapCenterObj* mapCenter;
219 bool adjustCanvasRequested; // collect requests until end of user event
220 BranchObj *editingBO; // entering Text into BO
222 QColor defLinkColor; // default color for links
223 QColor defXLinkColor; // default color for xlinks
224 int defXLinkWidth; // default width for xlinks
225 LinkColorHint linkcolorhint;// use heading color or own color
226 LinkStyle linkstyle; // default style for links
228 QCursor HandOpenCursor; // cursor while moving canvas view
229 QCursor PickColorCursor; // cursor while picking color
230 QCursor CopyCursor; // cursor while picking color
231 QCursor XLinkCursor; // cursor while picking color
233 bool drawingLink; // true while creating a link
234 bool copyingObj; // true while creating a link
238 MapObj* movingObj; // moving a MapObj
239 MapObj* linkingObj_src; // part of a link
240 QPointF movingObj_orgPos; // org. pos of mouse before move
241 QPointF movingObj_orgRelPos; // org. relative pos of mouse before move
242 QPointF movingObj_start; // rel. pos of mouse to absPos
243 QPointF movingCont_start; // inital pos of moving Content or
244 QPointF movingVec; // how far has Content moved
245 QPrinter* printer; // Printing
247 bool mapDefault; // Flag if map is untouched
248 bool mapChanged; // Flag if undo is possible
249 bool mapUnsaved; // Flag if map should be saved
251 Parser parser; // Parser stuff for scripting
253 bool printFrame; // Print frame around map
254 bool printFooter; // Print footer below map
256 bool zipped; // should map be zipped
257 static int mapNum; // unique number for Editor
258 QString fileName; // short name of file (for tab)
259 QString filePath; // path to file which will be saved
260 QString fileDir; // dir where file is saved
261 QString destPath; // path to .vym file (needed for vymlinks)
262 QString mapName; // fileName without ".vym"
264 QString tmpMapDir; // tmp directory with undo history
265 QString histPath; // Path to history file
266 int stepsTotal; // total number of steps (undos+redos)
267 SimpleSettings undoSet; // undo/redo commands
268 bool blockReposition; // block while load or undo
269 bool blockSaveState; // block while load or undo
271 BranchObj* itFind; // next object in find process
272 bool EOFind; // true, if search failed
274 QPoint exportOffset; // set before export, used in save
275 HideTmpMode hidemode; // true while exporting to hide some stuff
277 void resizeEvent( QResizeEvent * );