7 #include <qfiledialog.h>
12 #include "mapcenterobj.h"
15 class QNetworkOperation;
18 class MapEditor : public QCanvasView , public xmlObj {
22 MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, WFlags f=0);
25 QColor backgroundColor();
26 MapCenterObj* getMapCenter();
28 void adjustCanvasSize();// adjust canvas size to map and scrollview
29 bool isRepositionBlocked(); // block while load or undo
32 void makeTmpDirs(); // create temporary directories
33 void delTmpDirs(); // delete temporary directories
34 void makeSubDirs(const QString&);
35 // create subdirs in dir
36 QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*);
37 void saveState(); // save actual state to backup
38 void saveState(LinkableMapObj *);
39 void saveState(const QString &, const QString &);
40 void saveState(const QString &, LinkableMapObj *);
41 void saveState(const SaveMode&, const QString &, LinkableMapObj *, const QString &, LinkableMapObj *);
42 void parseAtom(const QString &);
44 void addFloatImage(const QPixmap &img);
47 void finishedLineEditNoSave();
48 void fetchImage(const QString &img);
49 void imageDataFetched(const QByteArray &, QNetworkOperation *);
50 void imageDataFinished(QNetworkOperation *);
53 bool isDefault(); // false, if map was changed once
54 bool isUnsaved(); // save necessary
55 bool hasChanged(); // undo possible
56 void setChanged(); // called from NoteEditor via LMO
58 void setFilePath (QString);
59 void setFilePath (QString,QString);
60 QString getFilePath (); // Full path e.g. "/home/tux/map.xml"
61 QString getFileName (); // e.g. "map.xml"
62 QString getMapName (); // e.g. "map"
63 QString getDestPath (); // e.g. "/home/tux/map.vym"
64 int load (QString&, const LoadMode &); // newmap, import/replace selection
66 int save(const SaveMode &); // Save map
67 void setZipped(bool); // save map zipped
68 bool saveZipped(); // 1 if file will be saved zipped
69 void print(); // print canvas
73 void exportImage (QString fn); // export as PNG
74 void exportImage (QString fn, int); // export in given format
77 void exportOOPresentation();
78 void exportXML(const QString&); // export to directory
79 void clear(); // clear map
80 void copy(); // copy branch to clipboard
81 void redo(); // redo last action
82 void undo(); // undo last action
84 void undoXML(const QString &, const QString &);
85 LinkableMapObj* 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 &,const int&);
92 void moveBranchDown();
93 void editHeading(); // Start editing heading
95 void setHeading(const QString &); // Just set the heading for selection
96 void setURL(const QString &); // Just set the URL for selection
97 void setVymLink(const QString &); // Set vymLink for selection
99 void addNewBranch(int); // pos allows to add above/below selection
100 void addNewBranchHere(); // insert and make selection its
101 void deleteSelection();
102 LinkableMapObj* getSelection(); // returns selection
103 bool select(const QString &); // Select
104 void unselect(); // before changing current noteedit
105 void reselect(); // after changing current noteedit
107 void selectNextBranch(); // Increment number of branch
108 void selectPrevBranch(); // Decrement number of branch
110 void selectUpperBranch();
111 void selectLowerBranch();
112 void selectLeftBranch();
113 void selectRightBranch();
114 void selectFirstBranch();
115 void selectLastBranch();
116 void setColor(QColor);
117 void selectBackgroundColor();
118 void setBackgroundColor(QColor);
122 void toggleStandardFlag(QString);
123 virtual void setViewCenter(); // needed for zooming
124 BranchObj* findText(QString,bool); // Find object
125 void findReset(); // Reset Find
126 void openURL(); // open URL in external browser
127 void editURL(); // edit the URL
128 void editHeading2URL(); // copy heading to URL
129 void editBugzilla2URL(); // create URL to Bugzilla
130 void editVymLink(); // edit link to another map
131 void deleteVymLink(); // delete link to another map
132 QString getVymLink(); // return path to map
133 void removeBranchHere(); // remove but keep childs
134 void removeChilds(); // remove childs
135 void editMapInfo(); // dialog to enter author, ...
136 void updateActions(); // update e.g. format buttons
137 void updateNoteFlag(); // when TextEditor changes
138 void setLinkStyle (LinkStyle); // Set style of link
139 LinkStyle getLinkStyle (); // requested in LMO
140 void setLinkColor(QColor); // default color of links
141 void setLinkColorHint(); // color of links
142 void setLinkColorHint(LinkColorHint); // color of links
143 LinkColorHint getLinkColorHint();
144 QColor getDefLinkColor();
145 void setDefXLinkColor(QColor);
146 QColor getDefXLinkColor();
147 void setDefXLinkWidth (int);
148 int getDefXLinkWidth();
149 void toggleLinkColorHint(); // after changing linkStyles
150 void selectLinkColor();
153 void loadFloatImage ();
154 void saveFloatImage (int);
155 void toggleFloatExport();
156 void setFrame(const FrameType &);
157 void setHideLinkUnselected (bool);
158 bool getHideLinkUnselected ();
160 void importDir(BranchObj *,QDir);
163 void followXLink (int);
164 void editXLink (int);
165 void testFunction(); // FIXME just testing
168 void ensureSelectionVisible();
169 virtual void updateViewCenter(); // needed for zooming
170 virtual void contentsContextMenuEvent ( QContextMenuEvent *e );
171 virtual void contentsMousePressEvent(QMouseEvent*);
172 virtual void contentsMouseReleaseEvent(QMouseEvent*);
173 virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
174 virtual void contentsMouseMoveEvent(QMouseEvent*);
176 virtual void contentsDragEnterEvent(QDragEnterEvent *event);
177 virtual void contentsDropEvent(QDropEvent *event);
180 MapCenterObj* mapCenter;
182 bool adjustCanvasRequested; // collect requests until end of user event
183 BranchObj *editingBO; // entering Text into BO
186 QColor actColor; // actual color
187 QColor defLinkColor; // default color for links
188 QColor defXLinkColor; // default color for xlinks
189 int defXLinkWidth; // default width for xlinks
190 LinkColorHint linkcolorhint;// use heading color or own color
191 LinkStyle linkstyle; // default style for links
193 QCursor handOpenCursor; // cursor while moving canvas view
194 QCursor pickColorCursor; // cursor while picking color
196 bool drawingLink; // true while creating a link
197 bool copyingObj; // true while creating a link
200 LinkableMapObj* selection; // select a LinkableMapObj
201 LinkableMapObj* selectionLast; // last selection
202 MapObj* movingObj; // moving a MapObj
203 MapObj* linkingObj_src; // part of a link
204 QPoint movingObj_orgPos; // org. pos of mouse before move
205 QPoint movingObj_start; // rel. pos of mouse to absPos
206 QPoint movingCont_start; // inital pos of moving Content or
207 QPoint movingVec; // how far has Content moved
208 QPoint movingCenter; // used when zooming
209 QPrinter* printer; // Printing
211 bool mapDefault; // Flag if map is untouched
212 bool mapChanged; // Flag if undo is possible
213 bool mapUnsaved; // Flag if map should be saved
215 bool printFrame; // Print frame around map
216 bool printFooter; // Print footer below map
218 bool zipped; // should map be zipped
219 static int mapNum; // unique number for Editor
220 QString fileName; // short name of file (for tab)
221 QString filePath; // path to file which will be saved
222 QString fileDir; // dir where file is saved
223 QString destPath; // path to .vym file (needed for vymlinks)
224 QString mapName; // fileName without ".vym"
225 QString lastImageDir; // save dir for adding images
227 bool isInteractive; // non interactive don't need tmpdirs
228 QString tmpMapDir; // tmp directory with data for undo/redo
229 int undosTotal; // total number of undos
230 int undoNum; // current number of bakMapDir to be used
231 int undosAvail; // how many actions can currently be undone
232 bool blockReposition; // block while load or undo
233 bool blockSaveState; // block while load or undo
235 BranchObj* itFind; // next object in find process
236 bool EOFind; // true, if search failed
238 QPoint exportOffset; // set before export, used in save
239 void resizeEvent( QResizeEvent * );
241 QUrlOperator *urlOperator;
242 QDataStream *imageData;
243 QBuffer *imageBuffer;