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