6 #include <QProgressDialog>
7 #include <QScriptContext>
8 #include <QScriptEngine>
9 #include <QScriptValue>
10 #include <QTextStream>
12 #include "branchpropeditor.h"
13 #include "extrainfodialog.h"
16 #include "historywindow.h"
17 #include "mapeditor.h"
18 #include "scripting.h"
19 #include "texteditor.h"
22 class Main : public QMainWindow {
26 /*! Modifier modes are used when SHIFT together with a mouse button is
29 ModModeUndefined, //!< Unused
30 ModModePoint, //!< Regular mode: Point and relink items
31 ModModeColor, //!< Pick color from object
32 ModModeXLink, //!< Create a XLink (XLinkObj) from selected object
33 ModModeMoveObject, //!< Move object without linking
34 ModModeMoveView //!< Move view without changing
37 Main(QWidget *parent = 0);
42 QProgressDialog progressDialog;
45 int progressCounterTotal;
48 void statusMessage(const QString &);
49 void setProgressMaximum(int max);
50 void addProgressValue(float v);
51 void initProgressCounter(uint n = 1);
52 void removeProgressCounter();
59 void closeEvent(QCloseEvent *);
62 QPrinter *setupPrinter();
67 /*! Helper method to clone actions later in MapEditor */
68 void cloneActionMapEditor(QAction *a, QKeySequence ks);
70 void setupFileActions();
71 void setupEditActions();
72 void setupSelectActions();
73 void setupFormatActions();
74 void setupViewActions();
75 void setupConnectActions();
76 void setupModeActions();
77 void setupWindowActions();
78 void setupFlagActions();
84 Flag *setupFlag(const QString &path, Flag::FlagType type,
85 const QString &name, const QString &tooltip,
86 const QUuid &uid = QUuid(), const QKeySequence &ks = 0);
89 void setupNetworkActions();
90 void setupSettingsActions();
91 void setupTestActions();
92 void setupHelpActions();
93 void setupContextMenus();
94 void setupRecentMapsMenu();
97 VymView *currentView() const;
98 VymView *view(const int i);
101 MapEditor *currentMapEditor() const;
102 VymModel *currentModel() const;
103 uint currentMapID() const;
104 int currentMapIndex() const;
105 VymModel *getModel(uint);
106 void gotoModel(VymModel *m);
107 void gotoModelWithID(uint id);
108 bool closeModelWithID(uint id);
110 void updateTabName(VymModel *vm);
113 void editorChanged();
116 File::ErrorCode fileLoad(QString, const LoadMode &, const FileType &ftype);
117 void fileLoad(const LoadMode &);
120 void fileSaveSession();
122 void fileRestoreSession();
124 void fileLoadRecent();
125 void addRecentMap(const QString &);
126 void fileSave(VymModel *, const SaveMode &);
129 void fileSave(VymModel *); // autosave from MapEditor
132 void fileSaveAs(const SaveMode &);
133 void fileSaveAsDefault();
134 void fileImportFirefoxBookmarks();
135 void fileImportFreemind();
137 void fileImportDir();
139 void fileExportASCII();
140 void fileExportASCIITasks();
141 void fileExportCSV();
142 void fileExportConfluence();
143 void fileExportFirefoxBookmarks();
144 void fileExportHTML();
145 void fileExportImage();
146 void fileExportImpress();
147 void fileExportLaTeX();
148 void fileExportMarkdown();
149 void fileExportOrgMode();
150 void fileExportPDF();
151 void fileExportSVG();
152 void fileExportTaskjuggler();
153 void fileExportXML();
154 void fileExportLast();
155 bool fileCloseMap(int i = -1); // Optionally pass number of tab
162 void gotoHistoryStep(int);
169 void updateQueries(VymModel *);
170 bool openURL(const QString &url);
171 void openTabs(QStringList);
173 void editOpenURLTab();
176 void editOpenMultipleVisURLTabs(bool ignoreScrolled = true);
177 void editOpenMultipleURLTabs();
178 void editNote2URLs();
181 void editHeading2URL();
182 void getJiraDataSubtree();
183 void setHeadingConfluencePageName();
184 void getConfluenceUser();
185 void openVymLinks(const QStringList &, bool background = false);
187 void editOpenMultipleVymLinks();
190 void editHeadingFinished(VymModel *m);
191 void editOpenVymLink(bool background = false);
192 void editOpenVymLinkBackground();
194 void editDeleteVymLink();
195 void editToggleHideExport();
196 void editToggleTask();
197 void editCycleTaskStatus();
198 void editTaskResetDeltaPrio();
199 void editTaskSleepN();
200 void editAddTimestamp();
201 void editMapProperties();
204 void editMoveUpDiagonally();
205 void editMoveDownDiagonally();
207 void editSortChildren();
208 void editSortBackChildren();
209 void editToggleScroll();
210 void editExpandAll();
211 void editExpandOneLevel();
212 void editCollapseOneLevel();
213 void editCollapseUnselected();
214 void editUnscrollChildren();
215 void editGrowSelectionSize();
216 void editShrinkSelectionSize();
217 void editResetSelectionSize();
218 void editAddAttribute();
219 void editAddMapCenter();
220 void editNewBranch();
221 void editNewBranchBefore();
222 void editNewBranchAbove();
223 void editNewBranchBelow();
224 void editImportAdd();
225 void editImportReplace();
226 void editSaveBranch();
227 void editDeleteKeepChildren();
228 void editDeleteChildren();
229 void editDeleteSelection();
230 void editLoadImage();
231 void editSaveImage();
232 void popupFollowXLink();
233 void editFollowXLink(QAction *);
234 void editEditXLink(QAction *);
237 bool initLinkedMapsMenu(VymModel *model, QMenu *menu);
240 void editGoToLinkedMap();
243 void editToggleTarget();
244 bool initTargetsMenu(VymModel *model, QMenu *menu);
245 void editGoToTarget();
246 void editMoveToTarget();
247 void editSelectPrevious();
248 void editSelectNext();
249 void editSelectNothing();
250 void editOpenFindResultWidget();
251 void editFindNext(QString s, bool searchNotesFlag);
252 void editFindDuplicateURLs();
255 void selectQuickColor(int n);
256 void setQuickColor(QColor col);
257 void quickColorPressed();
258 void formatPickColor();
259 QColor getCurrentColor();
260 int getCurrentColorIndex();
261 void setCurrentColor(QColor);
264 void formatColorBranch();
265 void formatColorSubtree();
266 void formatLinkStyleLine();
267 void formatLinkStyleParabel();
268 void formatLinkStylePolyLine();
269 void formatLinkStylePolyParabel();
270 void formatSelectBackColor();
271 void formatSelectBackImage();
272 void formatSelectLinkColor();
273 void formatSelectSelectionColor();
274 void formatSelectFont();
275 void formatToggleLinkColorHint();
276 void formatHideLinkUnselected();
279 void viewZoomReset();
282 void viewRotateCounterClockwise();
283 void viewRotateClockwise();
285 void viewCenterScaled();
288 void networkStartServer();
289 void networkConnect();
290 void downloadFinished();
293 void settingsZipTool();
294 void settingsMacroPath();
295 void settingsUndoLevels();
296 void settingsDefaultMapPath();
299 QString defaultMapPath(); // Default path, used with "auto" to define newMapPath
300 QString newMapPath(); // Depends on settings and dark theme
302 void setAutosave(bool b);
305 void settingsAutosaveTime();
306 void settingsDefaultMapAuthor();
307 void settingsDarkTheme();
308 void settingsShowParentsLevelTasks();
309 void settingsShowParentsLevelFindResults();
310 void settingsToggleAutoLayout();
311 void settingsToggleWriteBackupFile();
312 void settingsToggleAnimation();
313 void settingsToggleDownloads();
314 bool settingsConfluence();
317 void windowToggleNoteEditor();
318 void windowToggleTreeEditor();
319 void windowToggleTaskEditor();
320 void windowToggleSlideEditor();
321 void windowToggleScriptEditor();
322 void windowToggleScriptOutput();
323 void windowToggleHistory();
324 void windowToggleProperty();
325 void windowShowHeadingEditor();
326 void windowToggleHeadingEditor();
327 void updateHistory(SimpleSettings &);
328 void windowToggleAntiAlias();
330 bool hasSmoothPixmapTransform();
331 void windowToggleSmoothPixmap();
332 void clearScriptOutput();
333 void updateHeading(const VymText &vt);
334 void updateNoteText(const VymText &vt);
335 void updateNoteEditor(TreeItem *ti);
336 void updateHeadingEditor(BranchItem *bi = nullptr);
337 void selectInNoteEditor(QString s, int i);
338 void setFocusMapEditor();
339 void changeSelection(VymModel *model, const QItemSelection &newSel,
340 const QItemSelection &delSel);
341 void updateDockWidgetTitles(VymModel *model);
343 void updateActions();
344 ModMode getModMode();
345 bool autoSelectNewBranch();
346 QVariant runScript(const QString &);
347 QObject *getCurrentModelWrapper();
348 bool gotoWindow(const int &n);
351 void windowNextEditor();
352 void windowPreviousEditor();
354 void previousSlide();
358 void testFunction1();
359 void testFunction2();
361 void toggleHideExport();
366 void helpShortcuts();
368 void helpScriptingCommands();
369 void helpDebugInfo();
374 void downloadReleaseNotesFinished();
377 QUrl serverUrl(const QString &scriptName);
378 bool checkUpdatesAfterReleaseNotes;
381 void checkReleaseNotesAndUpdates();
384 void checkReleaseNotes();
385 bool downloadsEnabled(bool userTriggered = false);
386 void downloadUpdatesFinished(bool userTriggered = false);
387 void downloadUpdatesFinishedInt();
388 void downloadUpdates(bool userTriggered);
390 void escapePressed();
391 void togglePresentationMode();
394 QString shortcutScope; //! For listing shortcuts
395 QTabWidget *tabWidget;
398 QStringList imageTypes;
400 QScriptEngine scriptEngine;
402 QString prevSelection;
404 HistoryWindow *historyWindow;
406 QDockWidget *headingEditorDW;
407 QDockWidget *noteEditorDW;
408 QDockWidget *scriptEditorDW;
409 QDockWidget *branchPropertyEditorDW;
413 mapEditorActions; //! allows mapEditor to clone actions and shortcuts
415 taskEditorActions; //! allows taskEditor to clone actions and shortcuts
418 restrictedMapActions; //! Actions reqire map and write access
420 unrestrictedMapActions; //! Actions require map, but work also in
421 //! readonly, e.g. print, copy
422 QList<QAction *> actionListFiles; //! File related actions, e.g. load, save,
424 QList<QAction *> actionListBranches;
425 QList<QAction *> actionListItems;
429 QMenu *recentFilesMenu;
430 enum { MaxRecentFiles = 20 };
431 QAction *recentFileActions[MaxRecentFiles];
433 QAction *macroActions[24];
436 QList <QColor> quickColors;
439 QToolBar *fileToolbar;
440 QToolBar *clipboardToolbar;
441 QToolBar *editActionsToolbar;
442 QToolBar *selectionToolbar;
443 QToolBar *editorsToolbar;
444 QToolBar *colorsToolbar;
445 QToolBar *zoomToolbar;
446 QToolBar *modModesToolbar;
447 QToolBar *referencesToolbar;
448 QToolBar *standardFlagsToolbar;
449 QToolBar *userFlagsToolbar;
451 bool presentationMode;
452 QMap<QToolBar *, bool>
453 toolbarStates; // Save visibilty of toolbars during presentation mode
455 QAction *actionFileNew;
456 QAction *actionFileNewCopy;
457 QAction *actionFileOpen;
458 QAction *actionFileRestoreSession;
459 QAction *actionFileSave;
460 QAction *actionFilePrint;
461 QAction *actionMapProperties;
462 QAction *actionFileExportLast;
463 QAction *actionFileExportConfluence;
468 QAction *actionPaste;
469 QAction *actionMoveUp;
470 QAction *actionMoveDown;
471 QAction *actionMoveDownDiagonally;
472 QAction *actionMoveUpDiagonally;
473 QAction *actionDetach;
474 QAction *actionSortChildren;
475 QAction *actionSortBackChildren;
476 QAction *actionToggleScroll;
477 QAction *actionExpandAll;
478 QAction *actionExpandOneLevel;
479 QAction *actionCollapseOneLevel;
480 QAction *actionCollapseUnselected;
481 QAction *actionOpenURL;
482 QAction *actionOpenURLTab;
483 QAction *actionOpenMultipleVisURLTabs;
484 QAction *actionOpenMultipleURLTabs;
485 QAction *actionGetURLsFromNote;
486 QAction *actionURLNew;
487 QAction *actionLocalURL;
488 QAction *actionHeading2URL;
489 QAction *actionGetJiraDataSubtree;
490 QAction *actionGetConfluencePageName;
491 QAction *actionOpenVymLink;
492 QAction *actionOpenVymLinkBackground;
493 QAction *actionOpenMultipleVymLinks;
494 QAction *actionEditVymLink;
495 QAction *actionDeleteVymLink;
496 QAction *actionAddTimestamp;
497 QAction *actionToggleTask;
498 QAction *actionTogglePresentationMode;
499 QAction *actionCycleTaskStatus;
500 QAction *actionTaskResetDeltaPrio;
501 QAction *actionTaskSleep0;
502 QAction *actionTaskSleepN;
503 QAction *actionTaskSleep1;
504 QAction *actionTaskSleep2;
505 QAction *actionTaskSleep3;
506 QAction *actionTaskSleep4;
507 QAction *actionTaskSleep5;
508 QAction *actionTaskSleep7;
509 QAction *actionTaskSleep14;
510 QAction *actionTaskSleep28;
511 QAction *actionToggleHideExport;
512 QAction *actionMapInfo;
513 QAction *actionHeading;
514 QAction *actionDelete;
515 QAction *actionDeleteAlt;
516 QAction *actionAddAttribute;
519 QAction *actionAddMapCenter;
522 QAction *actionAddBranch;
523 QAction *actionAddBranchBefore;
524 QAction *actionAddBranchAbove;
525 QAction *actionAddBranchBelow;
526 QAction *actionDeleteKeepChildren;
527 QAction *actionDeleteChildren;
528 QAction *actionImportAdd;
529 QAction *actionImportReplace;
530 QAction *actionSaveBranch;
531 QAction *actionLoadImage;
533 QAction *actionGrowSelectionSize;
534 QAction *actionShrinkSelectionSize;
535 QAction *actionResetSelectionSize;
537 QAction *actionToggleTarget;
538 QAction *actionGoToTargetLinkedMap;
539 QAction *actionGoToTarget;
540 QAction *actionMoveToTarget;
541 QAction *actionSelectPrevious;
542 QAction *actionSelectNext;
543 QAction *actionSelectNothing;
546 QActionGroup *actionGroupQuickColors;
547 QAction *actionFormatQuickColor;
548 QAction *actionFormatPickColor;
549 QAction *actionFormatColorBranch;
550 QAction *actionFormatColorSubtree;
551 QAction *actionFormatLinkColorHint;
552 QAction *actionFormatBackColor;
553 QAction *actionFormatBackImage;
554 QAction *actionFormatLinkColor;
555 QAction *actionFormatSelectionColor;
556 QAction *actionFormatFont;
558 QAction *actionZoomIn;
559 QAction *actionZoomOut;
560 QAction *actionZoomReset;
561 QAction *actionRotateCounterClockwise;
562 QAction *actionRotateClockwise;
563 QAction *actionCenterOn;
564 QAction *actionFitToSelection;
566 QActionGroup *actionGroupModModes;
567 QAction *actionModModePoint;
568 QAction *actionModModeColor;
569 QAction *actionModModeCopy;
570 QAction *actionModModeXLink;
571 QAction *actionModModeMoveObject;
572 QAction *actionModModeMoveView;
574 QAction *actionToggleHideMode;
576 QAction *actionToggleWinter;
578 QActionGroup *actionGroupFormatFrameTypes;
580 QActionGroup *actionGroupFormatLinkStyles;
581 QAction *actionFormatLinkStyleLine;
582 QAction *actionFormatLinkStyleParabel;
583 QAction *actionFormatLinkStylePolyLine;
584 QAction *actionFormatLinkStylePolyParabel;
585 QAction *actionFormatHideLinkUnselected;
587 QAction *actionViewToggleNoteEditor;
588 QAction *actionViewToggleHeadingEditor;
589 QAction *actionViewToggleTreeEditor;
590 QAction *actionViewToggleTaskEditor;
591 QAction *actionViewToggleSlideEditor;
592 QAction *actionViewToggleScriptEditor;
593 QAction *actionViewToggleScriptOutput;
594 QAction *actionViewToggleHistoryWindow;
595 QAction *actionViewTogglePropertyEditor;
596 QAction *actionViewToggleAntiAlias;
597 QAction *actionViewToggleSmoothPixmapTransform;
598 QAction *actionViewCenter;
600 QAction *actionConnectGetConfluenceUser;
601 QAction *actionSettingsAutoSelectNewBranch;
602 QAction *actionSettingsAutoSelectText;
603 QAction *actionSettingsUseFlagGroups;
604 QAction *actionSettingsUseHideExport;
605 QAction *actionSettingsToggleAutosave;
606 QAction *actionSettingsAutosaveTime;
607 QAction *actionSettingsDarkTheme;
608 QAction *actionSettingsShowParentsLevelTasks;
609 QAction *actionSettingsShowParentsLevelFindResults;
610 QAction *actionSettingsToggleAutoLayout;
611 QAction *actionSettingsWriteBackupFile;
612 QAction *actionSettingsToggleDownloads;
613 QAction *actionSettingsUseAnimation;
614 QAction *actionSettingsJIRA;
615 QAction *actionSettingsConfluence;