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