]> git.sven.stormbind.net Git - sven/vym.git/blob - mainwindow.h
39df41ae6e23d0843ae3127ea60002180aecc2e5
[sven/vym.git] / mainwindow.h
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3
4 #include <QMainWindow>
5 #include <QProgressDialog>
6
7 #include "branchpropeditor.h"
8 #include "extrainfodialog.h"
9 #include "flag.h"
10 #include "file.h"
11 #include "historywindow.h"
12 #include "mapeditor.h"
13 #include "texteditor.h"
14 #include "vymview.h"
15
16 class Main : public QMainWindow 
17 {
18     Q_OBJECT
19
20 public:
21     /*! Modifier modes are used when CTRL together with a mouse button is pressed */
22     enum ModMode {
23         ModModeNone,    //!< Unused
24         ModModeColor,   //!< Pick color from object
25         ModModeCopy,    //!< Copy object
26         ModModeXLink    //!< Create a XLink (XLinkObj) from selected object
27         };
28
29     Main(QWidget* parent=0, Qt::WindowFlags f=0);
30     ~Main();
31     void loadCmdLine();
32
33 private:
34     QProgressDialog progressDialog;
35     int progressMax;
36     int progressCounter;
37     int progressCounterTotal;
38 public: 
39     void statusMessage (const QString &);
40     void setProgressMaximum (int max);
41     void addProgressValue (float v);
42     void initProgressCounter(uint n=1);
43     void removeProgressCounter();
44
45 public slots:
46     void fileNew();
47     void fileNewCopy();
48
49 protected:
50     void closeEvent( QCloseEvent* );
51
52 private:
53     void setupAPI();
54
55     /*! Helper method to clone actions later in MapEditor */
56     void cloneActionMapEditor( QAction *a, QKeySequence ks);
57
58     void setupFileActions();
59     void setupEditActions();
60     void setupSelectActions();
61     void setupFormatActions();
62     void setupViewActions();
63     void setupModeActions();
64     void setupWindowActions();
65     void setupFlag(
66         Flag *flag, 
67         QToolBar *tb, 
68         const QString &name, 
69         const QString &tooltip,
70         const QKeySequence &ks=0
71         );
72     void setupFlagActions();
73     void setupNetworkActions();
74     void setupSettingsActions();
75     void setupTestActions();
76     void setupHelpActions();
77     void setupContextMenus();
78     void setupRecentMapsMenu();
79     void setupMacros();
80     void setupToolbars();
81     VymView* currentView() const;
82 public: 
83     MapEditor* currentMapEditor() const;
84     VymModel* currentModel() const;
85     uint currentModelID() const;
86     VymModel* getModel(uint) const;
87     void gotoModel (VymModel *m);
88     int modelCount();
89     void updateTabName(VymModel *vm);
90     
91 private slots:
92     void editorChanged();
93
94     File::ErrorCode fileLoad(QString ,const LoadMode &, const FileType &ftype);
95     void fileLoad(const LoadMode &);
96     void fileLoad();
97     void fileSaveSession();
98 public slots:    
99     void fileRestoreSession();
100 private slots:    
101     void fileLoadRecent();
102     void addRecentMap (const QString &);
103     void fileSave(VymModel*, const SaveMode & );
104     void fileSave();
105 public slots:   
106     void fileSave(VymModel*);   // autosave from MapEditor
107 private slots:  
108     void fileSaveAs();
109     void fileSaveAs(const SaveMode &);
110     void fileImportFirefoxBookmarks();
111     void fileImportFreemind();
112     void fileImportMM();
113     void fileImportDir();
114     void fileExportXML();
115     void fileExportHTML();
116     void fileExportImage();
117     void fileExportPDF();
118     void fileExportSVG();
119     void fileExportAO();
120     void fileExportASCII();
121     void fileExportASCIITasks();
122     void fileExportCSV();
123     void fileExportOrgMode();
124     void fileExportLaTeX();
125     void fileExportTaskjuggler();
126     void fileExportImpress();
127     void fileExportLast();
128     bool fileCloseMap(int i = -1);  // Optionally pass number of tab
129     void filePrint();
130     bool fileExitVYM();
131
132 public slots:
133     void editUndo();    
134     void editRedo();    
135     void gotoHistoryStep (int);
136 private slots:  
137     void editCopy();    
138     void editPaste();   
139     void editCut(); 
140
141 public slots:    
142     void updateQueries (VymModel*);
143 private:
144     bool openURL(const QString &url);
145     void openTabs(QStringList);
146 public slots:
147     void editOpenURL();
148     void editOpenURLTab();
149 private slots:
150     void editOpenMultipleVisURLTabs(bool ignoreScrolled=true);
151     void editOpenMultipleURLTabs();
152     void editNote2URLs();
153     void editURL();
154     void editLocalURL();
155     void editHeading2URL();
156     void editBugzilla2URL();
157     void getBugzillaData();
158     void getBugzillaDataSubtree();
159     void editFATE2URL();
160     void openVymLinks(const QStringList &, bool background=false);
161     void editVymLink();
162     void editOpenMultipleVymLinks();
163 public slots:
164     void editHeading();
165     void editHeadingFinished(VymModel *m);
166     void editOpenVymLink(bool background=false);
167     void editOpenVymLinkBackground();
168 private slots:
169     void editDeleteVymLink();
170     void editToggleHideExport();
171     void editToggleTask();
172     void editCycleTaskStatus();
173     void editTaskSleepN();
174     void editAddTimestamp();
175     void editMapProperties();
176     void editMoveUp();  
177     void editMoveDown();    
178     void editDetach();  
179     void editSortChildren();
180     void editSortBackChildren();
181     void editToggleScroll();
182     void editExpandAll();
183     void editExpandOneLevel();
184     void editCollapseOneLevel();
185     void editCollapseUnselected();
186     void editUnscrollChildren();
187     void editGrowSelectionSize();
188     void editShrinkSelectionSize();
189     void editResetSelectionSize();
190     void editAddAttribute();
191     void editAddMapCenter();
192     void editNewBranch();
193     void editNewBranchBefore();
194     void editNewBranchAbove();
195     void editNewBranchBelow();
196     void editImportAdd();
197     void editImportReplace();
198     void editSaveBranch();
199     void editDeleteKeepChildren();
200     void editDeleteChildren();
201     void editDeleteSelection();
202     void editLoadImage();
203     void editSaveImage();
204     void popupFollowXLink ();
205     void editFollowXLink (QAction *);
206     void editEditXLink (QAction *);
207
208 private slots:    
209     void editToggleTarget();
210     bool initTargetsMenu( VymModel *model, QMenu *menu);
211     void editGoToTarget();
212     void editMoveToTarget();
213     void editSelectPrevious();
214     void editSelectNext();
215     void editSelectNothing();
216     void editOpenFindResultWidget();
217     void editFindNext(QString s);
218     void editFindDuplicateURLs();
219
220 public slots:
221     void formatPickColor();
222     QColor getCurrentColor();
223     void setCurrentColor(QColor);
224
225 private slots:    
226     void formatSelectColor();
227     void formatColorBranch();
228     void formatColorSubtree();
229     void formatLinkStyleLine();
230     void formatLinkStyleParabel();
231     void formatLinkStylePolyLine();
232     void formatLinkStylePolyParabel();
233     void formatSelectBackColor();
234     void formatSelectBackImage();
235     void formatSelectLinkColor();
236     void formatSelectSelectionColor();
237     void formatSelectFont();
238     void formatToggleLinkColorHint();
239     void formatHideLinkUnselected();
240
241 public slots:
242     void viewZoomReset();
243     void viewZoomIn();
244     void viewZoomOut();
245     void viewRotateCounterClockwise();
246     void viewRotateClockwise();
247     void viewCenter();
248
249 public slots:
250     void networkStartServer();
251     void networkConnect();
252     void downloadFinished();
253     bool settingsPDF();
254     bool settingsURL();
255     void settingsZipTool();
256     void settingsMacroDir();
257     void settingsUndoLevels();
258
259 public:
260     bool useAutosave();
261     void setAutosave( bool b);
262
263 public slots:
264     void settingsAutosaveTime();
265     void settingsDefaultMapAuthor();
266     void settingsShowParentsLevelTasks();
267     void settingsShowParentsLevelFindResults();
268     void settingsToggleAutoLayout();
269     void settingsToggleWriteBackupFile();
270     void settingsToggleAnimation();
271     void settingsToggleDownloads();
272
273     void windowToggleNoteEditor();
274     void windowToggleTreeEditor();
275     void windowToggleTaskEditor();
276     void windowToggleSlideEditor();
277     void windowToggleScriptEditor();
278     void windowToggleHistory();
279     void windowToggleProperty();
280     void windowShowHeadingEditor();
281     void windowToggleHeadingEditor();
282     void updateHistory(SimpleSettings &);
283     void windowToggleAntiAlias();
284 public:
285     bool isAliased();
286     bool hasSmoothPixmapTransform();
287 public slots:
288     void windowToggleSmoothPixmap();
289     void updateHeading();
290     void updateNoteFlag();
291     void updateNoteEditor (QModelIndex index);
292     void selectInNoteEditor (QString s, int i);
293     void setFocusMapEditor();
294     void changeSelection (VymModel *model,const QItemSelection &newSel, const QItemSelection &delSel);
295     void updateDockWidgetTitles(VymModel *model);
296
297     void updateActions();
298     ModMode getModMode();
299     bool autoEditNewBranch();
300     bool autoSelectNewBranch();
301     void setScriptFile(const QString &fn);
302     QVariant execute(const QString &);
303     void executeEverywhere (const QString &);
304     void gotoWindow (const int &n);
305
306 private slots:
307     void windowNextEditor();
308     void windowPreviousEditor();
309     void nextSlide();
310     void previousSlide();
311
312     void standardFlagChanged();
313
314     void testFunction1();
315     void testFunction2();
316     void toggleWinter();
317     void toggleHideExport();
318     void testCommand();
319
320     void helpDoc();
321     void helpDemo();
322     void helpShortcuts();
323     void debugInfo();
324     void helpAbout();
325     void helpAboutQT();
326
327     void callMacro ();
328     void downloadReleaseNotesFinished();
329
330 public slots:
331     void checkReleaseNotes();
332     bool downloadsEnabled(bool userTriggered = false);
333     void downloadUpdatesFinished(bool userTriggered = false);
334     void downloadUpdatesFinishedInt();
335     void downloadUpdates(bool userTriggered);
336     void checkUpdates();
337
338 private:
339     QString shortcutScope;          //! For listing shortcuts
340     QTabWidget *tabWidget;
341     qint64 *browserPID;
342
343     QStringList imageTypes;
344
345     QList <VymView*> vymViews;      //! Keeps track of models and views related to a tab 
346     QString prevSelection;
347
348     HistoryWindow *historyWindow;
349
350     QDockWidget *headingEditorDW;
351     QDockWidget *noteEditorDW;
352     QDockWidget *scriptEditorDW;
353
354     BranchPropertyEditor *branchPropertyEditor;
355
356 public:
357     QList <QAction*> mapEditorActions;      //! allows mapEditor to clone actions and shortcuts
358     QList <QAction*> taskEditorActions;     //! allows taskEditor to clone actions and shortcuts
359 private:
360     QList <QAction*> restrictedMapActions;  //! Actions reqire map and write access
361     QList <QAction*> unrestrictedMapActions;//! Actions require map, but work also in readonly, e.g. print, copy
362     QList <QAction*> actionListFiles;       //! File related actions, e.g. load, save, restore session
363     QList <QAction*> actionListBranches;
364     QList <QAction*> actionListItems;
365
366     QColor currentColor;
367
368     int xLinkMenuWidth;
369
370     QMenu *recentFilesMenu;
371     enum { MaxRecentFiles = 9 };
372     QAction *recentFileActions[MaxRecentFiles];
373
374     QAction *macroActions[13];
375     QStringList macro;
376
377     QMenu *toolbarsMenu;
378     QToolBar *fileToolbar;
379     QToolBar *clipboardToolbar;
380     QToolBar *editActionsToolbar;
381     QToolBar *selectionToolbar;
382     QToolBar *editorsToolbar;
383     QToolBar *colorsToolbar;
384     QToolBar *zoomToolbar;
385     QToolBar *modModesToolbar;
386     QToolBar *referencesToolbar;
387     QToolBar *standardFlagsToolbar;
388
389     QAction* actionFileNew;
390     QAction* actionFileNewCopy;
391     QAction* actionFileOpen;
392     QAction* actionFileRestoreSession;
393     QAction* actionFileSave;
394     QAction* actionFilePrint;
395     QAction* actionMapProperties;
396     QAction* actionFileExportLast;
397     QAction* actionUndo;
398     QAction* actionRedo;
399     QAction *actionCopy;
400     QAction *actionCut;
401     QAction *actionPaste;
402     QAction *actionMoveUp;
403     QAction *actionMoveDown;
404     QAction *actionDetach;
405     QAction *actionSortChildren;
406     QAction *actionSortBackChildren;
407     QAction *actionToggleScroll;
408     QAction *actionExpandAll;
409     QAction *actionExpandOneLevel;
410     QAction *actionCollapseOneLevel;
411     QAction *actionCollapseUnselected;
412     QAction* actionOpenURL;
413     QAction* actionOpenURLTab;
414     QAction* actionOpenMultipleVisURLTabs;
415     QAction* actionOpenMultipleURLTabs;
416     QAction* actionGetURLsFromNote;
417     QAction* actionURLNew;
418     QAction* actionLocalURL;
419     QAction* actionHeading2URL;
420     QAction* actionBugzilla2URL;
421     QAction* actionGetBugzillaData;
422     QAction* actionGetBugzillaDataSubtree;
423     QAction* actionFATE2URL;
424     QAction *actionOpenVymLink;
425     QAction *actionOpenVymLinkBackground;
426     QAction *actionOpenMultipleVymLinks;
427     QAction *actionEditVymLink;
428     QAction *actionDeleteVymLink;
429     QAction *actionAddTimestamp;
430     QAction *actionToggleTask;
431     QAction *actionCycleTaskStatus;
432     QAction *actionTaskSleep0;
433     QAction *actionTaskSleepN;
434     QAction *actionTaskSleep1;
435     QAction *actionTaskSleep2;
436     QAction *actionTaskSleep3;
437     QAction *actionTaskSleep5;
438     QAction *actionTaskSleep7;
439     QAction *actionTaskSleep14;
440     QAction *actionTaskSleep28;
441     QAction *actionToggleHideExport;
442     QAction *actionMapInfo;
443     QAction *actionHeading;
444     QAction *actionDelete;
445     QAction *actionAddAttribute;
446 public:
447     QAction *actionAddMapCenter;
448
449 private:    
450     QAction *actionAddBranch;
451     QAction *actionAddBranchBefore;
452     QAction *actionAddBranchAbove;
453     QAction *actionAddBranchBelow;
454     QAction *actionDeleteKeepChildren;
455     QAction *actionDeleteChildren;
456     QAction *actionImportAdd;
457     QAction *actionImportReplace;
458     QAction *actionSaveBranch;
459     QAction *actionLoadImage;
460
461     QAction *actionGrowSelectionSize;
462     QAction *actionShrinkSelectionSize;
463     QAction *actionResetSelectionSize;
464
465     QAction *actionToggleTarget;
466     QAction *actionGoToTarget;
467     QAction *actionMoveToTarget;
468     QAction *actionSelectPrevious;
469     QAction *actionSelectNext;
470     QAction *actionSelectNothing;
471     QAction *actionFind;
472
473     QAction *actionFormatColor;
474     QAction *actionFormatPickColor;
475     QAction *actionFormatColorBranch;
476     QAction *actionFormatColorSubtree;
477     QAction *actionFormatLinkColorHint;
478     QAction *actionFormatBackColor;
479     QAction *actionFormatBackImage;
480     QAction *actionFormatLinkColor;
481     QAction *actionFormatSelectionColor;
482     QAction *actionFormatFont;
483
484     QAction *actionZoomIn;
485     QAction *actionZoomOut;
486     QAction *actionZoomReset;
487     QAction *actionRotateCounterClockwise;
488     QAction *actionRotateClockwise;
489     QAction *actionCenterOn;
490
491     QActionGroup *actionGroupModModes;
492     QAction *actionModModeColor;
493     QAction *actionModModeXLink;
494     QAction *actionModModeCopy;
495
496     QAction *actionToggleHideMode;
497
498     QAction *actionToggleWinter;
499
500     QActionGroup *actionGroupFormatFrameTypes;
501
502     QActionGroup *actionGroupFormatLinkStyles;
503     QAction *actionFormatLinkStyleLine;
504     QAction *actionFormatLinkStyleParabel;
505     QAction *actionFormatLinkStylePolyLine;
506     QAction *actionFormatLinkStylePolyParabel;
507     QAction *actionFormatHideLinkUnselected;
508
509     QAction *actionViewToggleNoteEditor;
510     QAction *actionViewToggleHeadingEditor;
511     QAction *actionViewToggleTreeEditor;
512     QAction *actionViewToggleTaskEditor;
513     QAction *actionViewToggleSlideEditor;
514     QAction *actionViewToggleScriptEditor;
515     QAction *actionViewToggleHistoryWindow;
516     QAction *actionViewTogglePropertyEditor;
517     QAction *actionViewToggleAntiAlias;
518     QAction *actionViewToggleSmoothPixmapTransform;
519     QAction* actionViewCenter;
520
521     QAction* actionSettingsAutoEditNewBranch;
522     QAction* actionSettingsAutoSelectNewBranch;
523     QAction* actionSettingsAutoSelectText;
524     QAction* actionSettingsUseFlagGroups;
525     QAction* actionSettingsUseHideExport;
526     QAction* actionSettingsToggleAutosave;
527     QAction* actionSettingsAutosaveTime;
528     QAction* actionSettingsShowParentsLevelTasks;
529     QAction* actionSettingsShowParentsLevelFindResults;
530     QAction* actionSettingsToggleAutoLayout;
531     QAction* actionSettingsWriteBackupFile;
532     QAction* actionSettingsToggleDownloads;
533     QAction* actionSettingsUseAnimation;
534 };
535
536
537 #endif
538