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