5 #include <QGraphicsView>
7 #include "mapcenterobj.h"
10 #include "selection.h"
13 class Q3NetworkOperation;
16 class MapEditor : public QGraphicsView, public xmlObj {
20 MapEditor(QWidget* parent=0);
22 MapCenterObj* getMapCenter();
23 QGraphicsScene * getScene();
24 void adjustCanvasSize();// adjust canvas size to map and scrollview
25 bool isRepositionBlocked(); // block while load or undo
28 QString getName(LinkableMapObj*); // Get e.g. heading or filename
29 void makeTmpDirs(); // create temporary directories
30 QString saveToDir(const QString&,const QString &,bool, const QPointF &,LinkableMapObj*);
31 void saveStateChangingPart (LinkableMapObj *, LinkableMapObj *, const QString &, const QString &);
32 void saveStateRemovingPart (LinkableMapObj *, const QString &);
33 void saveState(LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &);
34 void saveState(const QString &, const QString &, const QString &, const QString &, const QString &);
35 void saveState(const SaveMode&, const QString &, const QString &, const QString &, const QString &, const QString &, LinkableMapObj *);
37 void parseAtom(const QString &);
39 void addFloatImageInt(const QPixmap &img);
42 void fetchImage(const QString &img);
43 void imageDataFetched(const QByteArray &, Q3NetworkOperation *);
44 void imageDataFinished(Q3NetworkOperation *);
47 bool isDefault(); // false, if map was changed once
48 bool isUnsaved(); // save necessary
49 bool hasChanged(); // undo possible
50 void setChanged(); // called from NoteEditor via LMO
52 void setFilePath (QString);
53 void setFilePath (QString,QString);
54 QString getFilePath (); // Full path e.g. "/home/tux/map.xml"
55 QString getFileName (); // e.g. "map.xml"
56 QString getMapName (); // e.g. "map"
57 QString getDestPath (); // e.g. "/home/tux/map.vym"
58 ErrorCode load (QString, LoadMode ); // newmap, import/replace selection
60 int save(const SaveMode &); // Save map
61 void setZipped(bool); // save map zipped
62 bool saveZipped(); // 1 if file will be saved zipped
63 void print(); // print canvas
64 void setAntiAlias (bool);
65 void setSmoothPixmap(bool);
68 void setHideTmpMode (HideTmpMode); // temporary hide stuff
69 HideTmpMode getHideTmpMode(); // temporary hide stuff
71 void setExportMode (bool); // temporary hide stuff during export
72 void exportImage (QString fn); // export as PNG
73 void exportImage (QString fn, QString); // export in given format
74 void exportOOPresentation(const QString &,const QString &);
75 void exportXML(const QString&); // export to directory
76 void clear(); // clear map
77 void copy(); // copy branch to clipboard
78 void redo(); // redo last action
79 bool isRedoAvailable();
80 void undo(); // undo last action
81 bool isUndoAvailable();
82 void gotoHistoryStep (int);// goto a step in history
84 void addMapReplaceInt(const QString & undoSel, const QString & path);
85 void addMapInsertInt (const QString & path, int pos);
86 void pasteNoSave(); // paste clipboard to branch
87 void cutNoSave(); // cut to clipboard
89 void paste(); // paste clipboard to branch and backup
90 void cut(); // cut to clipboard and backup
91 void move (const int &x, const int &y);
92 void moveRel (const int &x, const int &y);
94 void moveBranchDown();
95 QString getHeading (bool &ok,QPoint &p); // Get heading, ok if selection is branch
96 void setHeading(const QString &);
98 void setHeadingInt(const QString &);
99 void setURLInt(const QString &); // Just set the URL for selection
100 void setVymLinkInt(const QString &); // Set vymLink for selection
101 BranchObj* addNewBranchInt(int); // pos allows to add above/below selection
103 BranchObj* addNewBranch(int); // pos allows to add above/below selection
104 BranchObj* addNewBranchBefore(); // insert and make selection its
105 void deleteSelection();
106 LinkableMapObj* getSelection(); // returns selection
107 void unselect(); // before changing current noteedit
108 void reselect(); // after changing current noteedit
109 bool select(const QString &); // Select by string
110 QString getSelectString();
112 void selectInt(LinkableMapObj*);
113 void selectNextBranchInt(); // Increment number of branch
114 void selectPrevBranchInt(); // Decrement number of branch
116 void selectUpperBranch();
117 void selectLowerBranch();
118 void selectLeftBranch();
119 void selectRightBranch();
120 void selectFirstBranch();
121 void selectLastBranch();
122 void selectMapBackgroundImage();
123 void setMapBackgroundImage(const QString &);
124 void selectMapBackgroundColor();
125 void setMapBackgroundColor(QColor);
126 QColor getMapBackgroundColor();
127 QColor getCurrentHeadingColor();
128 void colorItem(QColor);
129 void colorBranch(QColor);
130 void toggleStandardFlag(QString);
131 virtual void setViewCenter(); // needed for zooming
132 BranchObj* findText(QString,bool); // Find object
133 void findReset(); // Reset Find
134 void setURL(const QString &); // set the URL
135 void editURL(); // edit the URL
136 QString getURL(); // returns URL of selection or ""
137 QStringList getURLs(); // returns URLs of subtree
138 void editHeading2URL(); // copy heading to URL
139 void editBugzilla2URL(); // create URL to Bugzilla
140 void editFATE2URL(); // create URL to FATE
141 void editVymLink(); // edit link to another map
142 void deleteVymLink(); // delete link to another map
143 QString getVymLink(); // return path to map
144 QStringList getVymLinks(); // return paths in subtree
145 void setHideExport(bool); // toggle the export flag
146 void toggleHideExport(); // toggle the export flag
147 void deleteKeepChilds(); // remove but keep childs
148 void deleteChilds(); // remove childs
149 void editMapInfo(); // dialog to enter author, ...
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();
169 void loadFloatImage ();
170 void saveFloatImage ();
171 void setFrame(const FrameType &);
172 void setIncludeImagesVer(bool);
173 void setIncludeImagesHor(bool);
174 void setHideLinkUnselected (bool);
175 bool getHideLinkUnselected ();
177 void importDirInt(BranchObj *,QDir);
180 void followXLink (int);
181 void editXLink (int);
182 void testFunction(); // just testing new stuff
183 // set /mainwindo/showTestMenu=true...
186 void ensureSelectionVisible();
187 virtual void updateViewCenter(); // needed for zooming
188 virtual void contextMenuEvent ( QContextMenuEvent *e );
189 virtual void keyPressEvent(QKeyEvent*);
190 virtual void keyReleaseEvent(QKeyEvent*);
191 virtual void mousePressEvent(QMouseEvent*);
192 virtual void mouseReleaseEvent(QMouseEvent*);
193 virtual void mouseDoubleClickEvent(QMouseEvent*);
194 virtual void mouseMoveEvent(QMouseEvent*);
196 virtual void contentsDragEnterEvent(QDragEnterEvent *event);
197 virtual void contentsDropEvent(QDropEvent *event);
199 QGraphicsScene *mapScene;
200 MapCenterObj* mapCenter;
202 bool adjustCanvasRequested; // collect requests until end of user event
203 BranchObj *editingBO; // entering Text into BO
205 QColor defLinkColor; // default color for links
206 QColor defXLinkColor; // default color for xlinks
207 int defXLinkWidth; // default width for xlinks
208 LinkColorHint linkcolorhint;// use heading color or own color
209 LinkStyle linkstyle; // default style for links
211 QCursor HandOpenCursor; // cursor while moving canvas view
212 QCursor PickColorCursor; // cursor while picking color
213 QCursor CopyCursor; // cursor while picking color
214 QCursor XLinkCursor; // cursor while picking color
216 bool drawingLink; // true while creating a link
217 bool copyingObj; // true while creating a link
221 LinkableMapObj* selection; // select a LinkableMapObj
222 LinkableMapObj* selectionLast; // last selection
223 MapObj* movingObj; // moving a MapObj
224 MapObj* linkingObj_src; // part of a link
225 QPointF movingObj_orgPos; // org. pos of mouse before move
226 QPointF movingObj_orgRelPos; // org. relative pos of mouse before move
227 QPointF movingObj_start; // rel. pos of mouse to absPos
228 QPointF movingCont_start; // inital pos of moving Content or
229 QPointF movingVec; // how far has Content moved
230 QPointF movingCenter; // used when zooming
231 QPrinter* printer; // Printing
233 bool mapDefault; // Flag if map is untouched
234 bool mapChanged; // Flag if undo is possible
235 bool mapUnsaved; // Flag if map should be saved
237 bool printFrame; // Print frame around map
238 bool printFooter; // Print footer below map
240 bool zipped; // should map be zipped
241 static int mapNum; // unique number for Editor
242 QString fileName; // short name of file (for tab)
243 QString filePath; // path to file which will be saved
244 QString fileDir; // dir where file is saved
245 QString destPath; // path to .vym file (needed for vymlinks)
246 QString mapName; // fileName without ".vym"
248 QString tmpMapDir; // tmp directory with undo history
249 QString histPath; // Path to history file
250 int stepsTotal; // total number of steps (undos+redos)
251 SimpleSettings undoSet; // undo/redo commands
252 bool blockReposition; // block while load or undo
253 bool blockSaveState; // block while load or undo
255 BranchObj* itFind; // next object in find process
256 bool EOFind; // true, if search failed
258 QPoint exportOffset; // set before export, used in save
259 HideTmpMode hidemode; // true while exporting to hide some stuff
261 void resizeEvent( QResizeEvent * );
263 Q3UrlOperator *urlOperator;
264 QDataStream *imageData;
265 QBuffer *imageBuffer;