mainwindow.h
author insilmaril
Tue, 18 Aug 2009 12:39:07 +0000
changeset 788 78ba80b54bc4
parent 786 6269016c9905
child 790 133e2ed6b9c5
permissions -rw-r--r--
Fix for segfault when deleting MCO (invalid QModelIndex needs to be returned in index(TreeItem*) )
     1 #ifndef MAINWINDOW_H 
     2 #define MAINWINDOW_H
     3 
     4 #include <QMainWindow>
     5 #include <QtDBus>
     6 
     7 
     8 #include "branchpropwindow.h"
     9 #include "extrainfodialog.h"
    10 #include "flag.h"
    11 #include "file.h"
    12 #include "findwindow.h"
    13 #include "historywindow.h"
    14 #include "mapeditor.h"
    15 #include "simplescripteditor.h"
    16 #include "texteditor.h"
    17 #include "vymview.h"
    18 
    19 class Main : public QMainWindow 
    20 {
    21     Q_OBJECT
    22 
    23 public:
    24 	/*! Modifier modes are used when CTRL together with a mouse button is pressed */
    25 	enum ModMode {
    26 		ModModeNone,	//!< Unused
    27 		ModModeColor,	//!< Pick color from object
    28 		ModModeCopy,	//!< Copy object
    29 		ModModeXLink	//!< Create a XLink (XLinkObj) from selected object
    30 		};
    31 
    32     Main(QWidget* parent=0, const char* name=0, Qt::WFlags f=0);
    33     ~Main();
    34 	void loadCmdLine();
    35 
    36 private:
    37 	QProgressBar *progressBar;
    38 	int progressMax;
    39 	int progressMin;
    40 public:	
    41 	void statusMessage (const QString &);
    42 	void setProgressMinimum (int min);
    43 	void setProgressMaximum (int max);
    44 	void setProgressValue (int v);
    45 	void removeProgressBar();
    46 
    47 public slots:
    48     void fileNew();
    49     void fileNewCopy();
    50 
    51 protected:
    52 	void closeEvent( QCloseEvent* );
    53 
    54 private:
    55     void setupFileActions();
    56     void setupEditActions();
    57     void setupFormatActions();
    58     void setupViewActions();
    59     void setupModeActions();
    60     void setupWindowActions();
    61     void setupFlag(Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip);
    62     void setupFlagActions();
    63     void setupNetworkActions();
    64     void setupSettingsActions();
    65     void setupTestActions();
    66     void setupHelpActions();
    67     void setupContextMenus();
    68 	void setupRecentMapsMenu();
    69     void setupMacros();
    70 	void hideEvent (QHideEvent * );
    71 	void showEvent (QShowEvent * );
    72 	MapEditor* currentMapEditor() const;
    73 	VymModel* currentModel() const;
    74     
    75 private slots:
    76 	void editorChanged(QWidget*);
    77 
    78     ErrorCode fileLoad(QString ,const LoadMode &, const FileType & ftype=VymMap);
    79     void fileLoad(const LoadMode &);
    80     void fileLoad();
    81 	void fileLoadRecent();
    82 	void addRecentMap (const QString &);
    83     void fileSave(VymModel*, const SaveMode & );
    84     void fileSave();
    85 public slots:	
    86     void fileSave(VymModel*);	// autosave from MapEditor
    87 private slots:	
    88     void fileSaveAs(const SaveMode &);
    89     void fileSaveAs();
    90     void fileImportKDE3Bookmarks();
    91     void fileImportKDE4Bookmarks();
    92     void fileImportFirefoxBookmarks();
    93     void fileImportFreemind();
    94     void fileImportMM();
    95     void fileImportDir();
    96     void fileExportXML();
    97     void fileExportXHTML();
    98     void fileExportImage();
    99     void fileExportASCII();
   100     void fileExportCSV();
   101     void fileExportLaTeX();
   102     void fileExportKDE3Bookmarks();
   103     void fileExportKDE4Bookmarks();
   104     void fileExportTaskjuggler();
   105     void fileExportOOPresentation();
   106     void fileCloseMap();
   107     void filePrint();
   108     void fileExitVYM();
   109 
   110 public slots:
   111     void editUndo();	
   112     void editRedo();	
   113 	void gotoHistoryStep (int);
   114 private slots:	
   115     void editCopy();	
   116     void editPaste();	
   117     void editCut();	
   118     void editOpenFindWindow();
   119 	void editFind(QString);
   120 	void editFindChanged();
   121 private:
   122 	void openTabs(QStringList);
   123 public slots:
   124 	void editOpenURL();
   125 	void editOpenURLTab();
   126 private slots:
   127 	void editOpenMultipleURLTabs();
   128 	void editURL();
   129 	void editLocalURL();
   130 	void editHeading2URL();
   131 	void editBugzilla2URL();
   132 	void editFATE2URL();
   133 	void openVymLinks(const QStringList &);
   134 	void editVymLink();
   135 	void editOpenMultipleVymLinks();
   136 public slots:
   137     void editHeadingFinished(VymModel *m);
   138 //    void editHeading();
   139 	void editOpenVymLink();
   140 private slots:
   141 	void editDeleteVymLink();
   142 	void editToggleHideExport();
   143 	void editMapInfo();
   144     void editMoveUp();	
   145     void editMoveDown();	
   146 	void editSortChildren();
   147     void editToggleScroll();
   148     void editExpandAll();
   149     void editUnscrollChildren();
   150     void editAddAttribute();
   151     void editAddMapCenter();
   152     void editNewBranch();
   153     void editNewBranchBefore();
   154     void editNewBranchAbove();
   155     void editNewBranchBelow();
   156     void editImportAdd();
   157     void editImportReplace();
   158     void editSaveBranch();
   159     void editDeleteKeepChildren();
   160     void editDeleteChildren();
   161     void editDeleteSelection();
   162     void editLoadImage();
   163     void editSaveImage();
   164     void editFollowXLink (QAction *);
   165     void editEditXLink (QAction *);
   166 
   167     void formatSelectColor();
   168     void formatPickColor();
   169     void colorChanged(QColor);
   170     void formatColorBranch();
   171     void formatColorSubtree();
   172 	void formatLinkStyleLine();
   173 	void formatLinkStyleParabel();
   174 	void formatLinkStylePolyLine();
   175 	void formatLinkStylePolyParabel();
   176     void formatSelectBackColor();
   177     void formatSelectBackImage();
   178     void formatSelectLinkColor();
   179     void formatSelectSelectionColor();
   180     void formatToggleLinkColorHint();
   181 	void formatHideLinkUnselected();
   182 
   183     void viewZoomReset();
   184     void viewZoomIn();
   185     void viewZoomOut();
   186     void viewCenter();
   187 
   188 public slots:
   189 	void networkStartServer();
   190 	void networkConnect();
   191 	bool settingsPDF();
   192 	bool settingsURL();
   193 	void settingsMacroDir();
   194 	void settingsToggleDelKey();
   195 	void settingsUndoLevels();
   196 	void settingsAutosaveToggle();
   197 	void settingsAutosaveTime();
   198 	void settingsWriteBackupFileToggle();
   199 	void settingsToggleAnimation();
   200 
   201 	void windowToggleNoteEditor();
   202 	void windowToggleHistory();
   203 	void windowToggleProperty();
   204 	void updateHistory(SimpleSettings &);
   205 	void windowToggleAntiAlias();
   206 public:
   207 	bool isAliased();
   208 	bool hasSmoothPixmapTransform();
   209 public slots:
   210 	void windowToggleSmoothPixmap();
   211 	void updateNoteFlag();
   212 	void updateNoteEditor (QModelIndex index);
   213 	void changeSelection (VymModel *model,const QItemSelection &newSel, const QItemSelection &delSel);
   214 
   215 	void updateActions();
   216 	ModMode getModMode();
   217 	bool autoEditNewBranch();
   218 	bool autoSelectNewBranch();
   219 	void setScript(const QString &);
   220 	void runScript(const QString &);
   221 	void runScriptEverywhere (const QString &);
   222 
   223 private slots:
   224 	void windowNextEditor();
   225 	void windowPreviousEditor();
   226 	void windowShowNoteEditor();
   227 	void windowHideNoteEditor();
   228 
   229 	void standardFlagChanged();
   230 
   231     void testFunction1();
   232     void testFunction2();
   233     void testCommand();
   234 
   235     void helpDoc();
   236     void helpDemo();
   237     void helpAbout();
   238     void helpAboutQT();
   239 
   240 	void callMacro ();
   241 
   242 private:
   243 	QTabWidget *tabWidget;
   244 	FindWindow *findWindow;
   245 	QProcess *procBrowser;
   246 
   247 	QStringList imageTypes;
   248 
   249 	QList <VymView*> vymViews;		//! Keeps track of models and views related to a tab 
   250 	QString prevSelection;
   251 
   252 	HistoryWindow *historyWindow;
   253 
   254 	BranchPropertyWindow *branchPropertyWindow;
   255 	SimpleScriptEditor *scriptEditor;
   256 
   257 	QList <QAction*> actionListBranches;
   258 
   259 	QColor currentColor;
   260 
   261 	int xLinkMenuWidth;
   262 
   263 	QMenu *recentFilesMenu;
   264 	enum { MaxRecentFiles = 9 };
   265     QAction *recentFileActions[MaxRecentFiles];
   266 
   267     QAction *macroActions[12];
   268 	QStringList macro;
   269 
   270 	QAction* actionFileNewCopy;
   271 	QAction* actionFileSave;
   272 	QAction* actionFilePrint;
   273 	QAction* actionUndo;
   274 	QAction* actionRedo;
   275 	QAction *actionCopy;
   276 	QAction *actionCut;
   277 	QAction *actionPaste;
   278 	QAction *actionMoveUp;
   279 	QAction *actionMoveDown;
   280 	QAction *actionSortChildren;
   281 	QAction *actionToggleScroll;
   282 	QAction *actionExpandAll;
   283 	QAction* actionOpenURL;
   284 	QAction* actionOpenURLTab;
   285 	QAction* actionOpenMultipleURLTabs;
   286 	QAction* actionURL;
   287 	QAction* actionLocalURL;
   288 	QAction* actionHeading2URL;
   289 	QAction* actionBugzilla2URL;
   290 	QAction* actionFATE2URL;
   291 	QAction *actionOpenVymLink;
   292 	QAction *actionOpenMultipleVymLinks;
   293 	QAction *actionVymLink;
   294 	QAction *actionDeleteVymLink;
   295 	QAction *actionToggleHideExport;
   296 	QAction *actionMapInfo;
   297 	QAction *actionHeading;
   298 	QAction *actionDelete;
   299 	QAction *actionAddAttribute;
   300 public:
   301 	QAction *actionAddMapCenter;
   302 
   303 private:	
   304 	QAction *actionAddBranch;
   305 	QAction *actionAddBranchBefore;
   306 	QAction *actionAddBranchAbove;
   307 	QAction *actionAddBranchBelow;
   308 	QAction *actionDeleteKeepChildren;
   309 	QAction *actionDeleteChildren;
   310 	QAction *actionImportAdd;
   311 	QAction *actionImportReplace;
   312 	QAction *actionSaveBranch;
   313 	QAction *actionLoadImage;
   314 
   315 	QAction* actionFormatColor;
   316 	QAction* actionFormatPickColor;
   317 	QAction* actionFormatColorBranch;
   318 	QAction* actionFormatColorSubtree;
   319 	QAction* actionFormatLinkColorHint;
   320 	QAction* actionFormatBackColor;
   321 	QAction* actionFormatBackImage;
   322 	QAction* actionFormatLinkColor;
   323 	QAction* actionFormatSelectionColor;
   324 
   325 	QActionGroup* actionGroupModModes;
   326 	QAction* actionModModeColor;
   327 	QAction* actionModModeXLink;
   328 	QAction* actionModModeCopy;
   329 
   330 	QActionGroup *actionGroupFormatFrameTypes;
   331 
   332 
   333 	QActionGroup *actionGroupFormatLinkStyles;
   334 	QAction *actionFormatLinkStyleLine;
   335 	QAction *actionFormatLinkStyleParabel;
   336 	QAction *actionFormatLinkStylePolyLine;
   337 	QAction *actionFormatLinkStylePolyParabel;
   338 	QAction *actionFormatHideLinkUnselected;
   339 
   340 	QAction *actionViewToggleNoteEditor;
   341 	QAction *actionViewToggleHistoryWindow;
   342 	QAction *actionViewTogglePropertyWindow;
   343 	QAction *actionViewToggleAntiAlias;
   344 	QAction *actionViewToggleSmoothPixmapTransform;
   345 	QAction* actionViewCenter;
   346 
   347 	QAction* actionSettingsAutoEditNewBranch;
   348 	QAction* actionSettingsAutoSelectNewBranch;
   349 	QAction* actionSettingsAutoSelectText;
   350 	QAction* actionSettingsUseDelKey;
   351 	QAction* actionSettingsUseFlagGroups;
   352 	QAction* actionSettingsUseHideExport;
   353 	QAction* actionSettingsAutosaveToggle;
   354 	QAction* actionSettingsAutosaveTime;
   355 	QAction* actionSettingsWriteBackupFile;
   356 	QAction* actionSettingsUseAnimation;
   357 };
   358 
   359 
   360 #endif
   361