1 #include "mainwindow.h"
7 #include <q3filedialog.h>
9 #include <QColorDialog>
11 #include <QInputDialog>
15 #include <QCloseEvent>
18 #include <Q3PopupMenu>
19 #include <QActionGroup>
21 //#include <qdatetime.h> // for random seed
27 #include "aboutdialog.h"
28 #include "exportoofiledialog.h"
30 #include "exportxhtmldialog.h"
32 #include "flagrowobj.h"
34 #include "mapeditor.h"
39 #include "showtextdialog.h"
40 #include "texteditor.h"
43 extern TextEditor *textEditor;
44 extern Main *mainWindow;
45 extern QString tmpVymDir;
46 extern QString clipboardDir;
47 extern bool clipboardEmpty;
48 extern int statusbarTime;
49 extern FlagRowObj* standardFlagsDefault;
50 extern FlagRowObj* systemFlagsDefault;
52 extern Q3PtrList <QAction> actionListBranches;
54 extern QAction* actionFileSave;
55 extern QAction* actionFilePrint;
56 extern QAction* actionEditUndo;
57 extern QAction* actionEditRedo;
58 extern QAction *actionEditCopy;
59 extern QAction *actionEditCut;
60 extern QAction *actionEditPaste;
61 extern QAction *actionEditMoveUp;
62 extern QAction *actionEditMoveDown;
63 extern QAction *actionEditToggleScroll;
64 extern QAction* actionEditOpenURL;
65 extern QAction* actionEditOpenURLTab;
66 extern QAction* actionEditURL;
67 extern QAction* actionEditHeading2URL;
68 extern QAction* actionEditBugzilla2URL;
69 extern QAction* actionEditFATE2URL;
70 extern QAction *actionEditOpenVymLink;
71 extern QAction *actionEditVymLink;
72 extern QAction *actionEditDeleteVymLink;
73 extern QAction *actionEditToggleHideExport;
74 extern QAction *actionEditMapInfo;
75 extern QAction *actionEditHeading;
76 extern QAction *actionEditDelete;
77 extern QAction *actionEditAddBranch;
78 extern QAction *actionEditAddBranchHere;
79 extern QAction *actionEditAddBranchAbove;
80 extern QAction *actionEditAddBranchBelow;
81 extern QAction *actionEditRemoveBranchKeepChilds;
82 extern QAction *actionEditRemoveChilds;
83 extern QAction *actionEditImportAdd;
84 extern QAction *actionEditImportReplace;
85 extern QAction *actionEditSaveBranch;
86 extern QAction *actionEditSelectFirst;
87 extern QAction *actionEditSelectLast;
88 extern QAction *actionEditLoadImage;
90 extern QAction* actionFormatColor;
91 extern QAction* actionFormatPickColor;
92 extern QAction* actionFormatColorBranch;
93 extern QAction* actionFormatColorSubtree;
94 extern QAction* actionFormatLinkColorHint;
95 extern QAction* actionFormatBackColor;
96 extern QAction* actionFormatLinkColor;
97 extern QAction *actionFormatIncludeImagesVer;
98 extern QAction *actionFormatIncludeImagesHor;
100 extern QActionGroup* actionGroupModModes;
101 extern QAction* actionModModeColor;
102 extern QAction* actionModModeLink;
103 extern QAction* actionModModeCopy;
105 extern QActionGroup *actionGroupFormatFrameTypes;
106 extern QAction *actionFormatFrameNone;
107 extern QAction *actionFormatFrameRectangle;
109 extern QActionGroup *actionGroupFormatLinkStyles;
110 extern QAction *actionFormatLinkStyleLine;
111 extern QAction *actionFormatLinkStyleParabel;
112 extern QAction *actionFormatLinkStylePolyLine;
113 extern QAction *actionFormatLinkStylePolyParabel;
114 extern QAction *actionFormatHideLinkUnselected;
116 extern QAction *actionViewToggleNoteEditor;
117 extern QAction *actionViewToggleHistoryWindow;
119 extern QAction* actionSettingsAutoedit;
120 extern QAction* actionSettingsAutoselectHeading;
121 extern QAction* actionSettingsAutoselectHeading;
122 extern QAction* actionSettingsAutoselectText;
123 extern QAction* actionSettingsPasteNewHeading;
124 extern QAction* actionSettingsUseDelKey;
125 extern QAction* actionSettingsUseFlagGroups;
126 extern QAction* actionSettingsUseHideExport;
128 extern QMenu* branchContextMenu;
129 extern QMenu* branchAddContextMenu;
130 extern QMenu* branchRemoveContextMenu;
131 extern QMenu* branchLinksContextMenuEdit;
132 extern QMenu* branchLinksContextMenuFollow;
133 extern QMenu* floatimageContextMenu;
134 extern QMenu* canvasContextMenu;
135 extern QMenu* fileLastMapsMenu;
136 extern QMenu* fileImportMenu;
137 extern QMenu* fileExportMenu;
140 extern Settings settings;
141 extern Options options;
142 extern ImageIO imageIO;
144 extern QDir vymBaseDir;
145 extern QDir lastImageDir;
146 extern QDir lastFileDir;
147 extern QString iconPath;
148 extern QString flagsPath;
150 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
151 QMainWindow(parent,name,f)
155 setCaption ("VYM - View Your Mind");
157 // Load window settings
158 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
159 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
162 // Create unique temporary directory
163 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
165 // Create direcctory for clipboard
166 clipboardDir=tmpVymDir+"/clipboard";
167 QDir d(clipboardDir);
168 d.mkdir (clipboardDir,true);
169 makeSubDirs (clipboardDir);
174 // FIXME not used currently
175 // Set random seed (random used for object IDs)
176 // QTime t = QTime::currentTime(); // set random seed
177 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
180 // Initialize some settings, which are platform dependant
183 // application to open URLs
184 p="/mainwindow/readerURL";
185 #if defined(Q_OS_LINUX)
186 s=settings.value (p,"konqueror").toString();
188 #if defined(Q_OS_MACX)
189 s=settings.value (p,"/usr/bin/open").toString();
191 s=settings.value (p,"mozilla");
194 settings.setValue( p,s);
196 // application to open PDFs
197 p="/mainwindow/readerPDF";
198 #if defined(Q_OS_LINUX)
199 s=settings.value (p,"acroread").toString();
201 #if defined(Q_OS_MACX)
202 s=settings.value (p,"/usr/bin/open").toString();
204 s=settings.value (p,"acroread").toString();
207 settings.setValue( p,s);
212 // Create tab widget which holds the maps
213 tabWidget= new QTabWidget (this);
214 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
215 this, SLOT( editorChanged( QWidget * ) ) );
217 setCentralWidget(tabWidget);
221 setupFormatActions();
225 setupSettingsActions();
227 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
232 restoreState (settings.value("/mainwindow/state",0).toByteArray());
234 // Initialize Find window
235 findWindow=new FindWindow(NULL,"findwindow");
236 connect (findWindow, SIGNAL( findButton(QString) ),
237 this, SLOT(editFind(QString) ) );
238 connect (findWindow, SIGNAL( somethingChanged() ),
239 this, SLOT(editFindChanged() ) );
241 // Connect TextEditor, so that we can update flags if text changes
242 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
250 settings.setValue ( "/mainwindow/geometry/size", size() );
251 settings.setValue ( "/mainwindow/geometry/pos", pos() );
253 settings.setValue ("/mainwindow/state",saveState(0));
255 settings.setValue( "/version/version", __VYM_VERSION );
256 settings.setValue( "/version/builddate", __BUILD_DATE );
258 settings.setValue( "/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
259 settings.setValue( "/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
260 settings.setValue( "/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
261 settings.setValue( "/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
262 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
263 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
264 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
267 int maps=lastMaps.count();
268 settings.setValue( "/lastMaps/number",maps );
269 for (int i=1;i<=maps;i++)
271 s=QString("/lastMaps/map-%1").arg(i);
272 if (!s.isEmpty() && i<=maxLastMaps)
273 settings.setValue (s, lastMaps.at(i-1));
277 // To make the texteditor save its settings, call the destructor
280 // Remove temporary directory
281 removeDir (QDir(tmpVymDir));
284 void Main::loadCmdLine()
286 /* TODO draw some kind of splashscreen while loading...
292 QStringList flist=options.getFileList();
293 QStringList::Iterator it=flist.begin();
295 while (it !=flist.end() )
297 fileLoad (*it, NewMap);
303 void Main::statusMessage(const QString &s)
305 statusBar()->message (s);
308 void Main::closeEvent (QCloseEvent* )
314 void Main::setupFileActions()
316 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
317 QToolBar *tb = addToolBar( tr ("&Map") );
320 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
321 a->setStatusTip ( tr( "New map","File menu" ) );
322 a->setShortcut ( Qt::CTRL + Qt::Key_N );
324 fileMenu->addAction (a);
325 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
327 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
328 a->setStatusTip (tr( "Open","File menu" ) );
329 a->setShortcut ( Qt::CTRL + Qt::Key_O );
331 fileMenu->addAction (a);
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
334 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
335 fileMenu->addSeparator();
337 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
338 a->setStatusTip ( tr( "Save" ));
339 a->setShortcut (Qt::CTRL + Qt::Key_S );
341 fileMenu->addAction (a);
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
345 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
346 a->setStatusTip (tr( "Save &As" ) );
347 fileMenu->addAction (a);
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
350 fileMenu->addSeparator();
352 fileImportMenu = fileMenu->addMenu (tr("Import"));
354 a = new QAction(tr("KDE Bookmarks"), this);
355 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
356 a->addTo (fileImportMenu);
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
359 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
361 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
362 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
363 a->addTo (fileImportMenu);
364 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
367 a = new QAction("Mind Manager...",this);
368 a->setStatusTip ( tr( "Import")+" Mind Manager" );
369 fileImportMenu->addAction (a);
370 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
372 a = new QAction( tr( "Import Dir"+QString("...") ), this);
373 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
374 fileImportMenu->addAction (a);
375 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
377 fileExportMenu = fileMenu->addMenu (tr("Export"));
379 a = new QAction( tr("Image")+QString("..."), this);
380 a->setStatusTip( tr( "Export map as image" ));
381 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
382 fileExportMenu->addAction (a);
384 a = new QAction( "Open Office"+QString("..."), this);
385 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
386 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
387 fileExportMenu->addAction (a);
389 a = new QAction( "Webpage (XHTML)...",this );
390 a->setShortcut (Qt::ALT + Qt::Key_X);
391 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
393 fileExportMenu->addAction (a);
395 a = new QAction( "Text (ASCII)...", this);
396 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
397 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
398 fileExportMenu->addAction (a);
400 a = new QAction( tr("KDE Bookmarks"), this);
401 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
402 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
403 fileExportMenu->addAction (a);
405 a = new QAction( "Taskjuggler...", this );
406 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
407 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
408 fileExportMenu->addAction (a);
410 a = new QAction( "LaTeX...", this);
411 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
412 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
413 fileExportMenu->addAction (a);
415 a = new QAction( "XML..." , this );
416 a->setStatusTip (tr( "Export as")+" XML");
417 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
418 fileExportMenu->addAction (a);
420 fileMenu->addSeparator();
422 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
423 a->setStatusTip ( tr( "Print" ) );
424 a->setShortcut (Qt::CTRL + Qt::Key_P );
426 fileMenu->addAction (a);
427 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
430 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
431 a->setStatusTip (tr( "Close Map" ) );
432 a->setShortcut (Qt::ALT + Qt::Key_C );
433 fileMenu->addAction (a);
434 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
436 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
437 a->setStatusTip ( tr( "Exit")+" "+__VYM );
438 a->setShortcut (Qt::CTRL + Qt::Key_Q );
439 fileMenu->addAction (a);
440 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
445 void Main::setupEditActions()
447 QToolBar *tb = addToolBar( tr ("&Actions") );
448 tb->setLabel( "Edit Actions" );
449 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
453 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
454 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
455 a->setStatusTip (tr( "Undo" ) );
456 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
457 a->setEnabled (false);
459 editMenu->addAction (a);
462 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
464 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
465 a->setStatusTip (tr( "Redo" ));
466 a->setShortcut (Qt::CTRL + Qt::Key_Y );
467 editMenu->addAction (a);
468 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
471 editMenu->addSeparator();
472 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
473 a->setStatusTip ( tr( "Copy" ) );
474 a->setShortcut (Qt::CTRL + Qt::Key_C );
475 a->setEnabled (false);
477 editMenu->addAction (a);
478 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
481 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
482 a->setStatusTip ( tr( "Cut" ) );
483 a->setShortcut (Qt::CTRL + Qt::Key_X );
484 a->setEnabled (false);
486 editMenu->addAction (a);
488 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
490 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
491 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
492 a->setStatusTip ( tr( "Paste" ) );
493 a->setShortcut ( Qt::CTRL + Qt::Key_V );
494 a->setEnabled (false);
496 editMenu->addAction (a);
499 // Shortcuts to modify heading:
500 a = new QAction(tr( "Edit heading" ),this);
501 a->setStatusTip ( tr( "edit Heading" ));
502 a->setShortcut ( Qt::Key_Enter);
503 a->setShortcutContext (Qt::WindowShortcut);
505 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
506 actionListBranches.append(a);
507 a = new QAction( tr( "Edit heading" ), this);
508 a->setStatusTip (tr( "edit Heading" ));
509 a->setShortcut (Qt::Key_Return );
510 a->setShortcutContext (Qt::WindowShortcut);
512 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
513 actionListBranches.append(a);
514 editMenu->addAction (a);
516 a = new QAction( tr( "Edit heading" ), this);
517 a->setStatusTip (tr( "edit Heading" ));
518 a->setShortcut ( Qt::Key_F2 );
519 a->setShortcutContext (Qt::WindowShortcut);
521 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
522 actionListBranches.append(a);
524 // Shortcut to delete selection
525 a = new QAction( tr( "Delete Selection" ),this);
526 a->setStatusTip (tr( "Delete Selection" ));
527 a->setShortcut ( Qt::Key_Delete);
528 a->setShortcutContext (Qt::WindowShortcut);
530 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
533 // Shortcut to add branch
534 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
535 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
536 alt->setShortcut (Qt::Key_A);
537 alt->setShortcutContext (Qt::WindowShortcut);
539 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
540 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
541 a->setStatusTip ( tr( "Add a branch as child of selection" ));
542 a->setShortcut (Qt::Key_Insert);
543 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
544 actionListBranches.append(a);
545 #if defined (Q_OS_MACX)
546 // In OSX show different shortcut in menues, the keys work indepently always
547 actionEditAddBranch=alt;
549 actionEditAddBranch=a;
551 editMenu->addAction (actionEditAddBranch);
552 tb->addAction (actionEditAddBranch);
555 // Add branch by inserting it at selection
556 a = new QAction(tr( "Add branch (insert)" ), this);
557 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
558 a->setShortcut (Qt::ALT + Qt::Key_Insert );
559 a->setShortcutContext (Qt::WindowShortcut);
561 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
562 a->setEnabled (false);
563 actionListBranches.append(a);
564 actionEditAddBranchHere=a;
565 a = new QAction(tr( "Add branch (insert)" ),this);
566 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
567 a->setShortcut ( Qt::ALT + Qt::Key_A );
568 a->setShortcutContext (Qt::WindowShortcut);
570 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
571 actionListBranches.append(a);
574 a = new QAction(tr( "Add branch above" ), this);
575 a->setStatusTip ( tr( "Add a branch above selection" ));
576 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
577 a->setShortcutContext (Qt::WindowShortcut);
579 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
580 a->setEnabled (false);
581 actionListBranches.append(a);
582 actionEditAddBranchAbove=a;
583 a = new QAction(tr( "Add branch above" ), this);
584 a->setStatusTip ( tr( "Add a branch above selection" ));
585 a->setShortcut (Qt::SHIFT+Qt::Key_A );
586 a->setShortcutContext (Qt::WindowShortcut);
588 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
589 actionListBranches.append(a);
592 a = new QAction(tr( "Add branch below" ), this);
593 a->setStatusTip ( tr( "Add a branch below selection" ));
594 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
595 a->setShortcutContext (Qt::WindowShortcut);
597 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
598 a->setEnabled (false);
599 actionListBranches.append(a);
600 actionEditAddBranchBelow=a;
601 a = new QAction(tr( "Add branch below" ), this);
602 a->setStatusTip ( tr( "Add a branch below selection" ));
603 a->setShortcut (Qt::CTRL +Qt::Key_A );
604 a->setShortcutContext (Qt::WindowShortcut);
606 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
607 actionListBranches.append(a);
609 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
610 a->setStatusTip ( tr( "Move branch up" ) );
611 a->setShortcut (Qt::Key_PageUp );
612 a->setEnabled (false);
614 editMenu->addAction (a);
615 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
618 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
619 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
620 a->setStatusTip (tr( "Move branch down" ) );
621 a->setShortcut ( Qt::Key_PageDown );
622 a->setEnabled (false);
624 editMenu->addAction (a);
625 actionEditMoveDown=a;
628 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
629 a->setShortcut ( Qt::Key_ScrollLock );
630 a->setStatusTip (tr( "Scroll branch" ) );
631 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
632 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
633 alt->setShortcut ( Qt::Key_S );
634 alt->setStatusTip (tr( "Scroll branch" ));
635 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
636 #if defined(Q_OS_MACX)
637 actionEditToggleScroll=alt;
639 actionEditToggleScroll=a;
641 actionEditToggleScroll->setEnabled (false);
642 actionEditToggleScroll->setToggleAction(true);
643 tb->addAction (actionEditToggleScroll);
644 editMenu->addAction ( actionEditToggleScroll);
645 editMenu->addAction (actionEditToggleScroll);
646 actionListBranches.append(actionEditToggleScroll);
648 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
649 a->setStatusTip (tr( "Unscroll all" ));
650 editMenu->addAction (a);
651 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
653 editMenu->addSeparator();
655 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
656 a->setStatusTip (tr( "Find" ) );
657 a->setShortcut (Qt::CTRL + Qt::Key_F );
658 editMenu->addAction (a);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
661 editMenu->addSeparator();
663 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
664 a->setShortcut (Qt::CTRL + Qt::Key_U );
665 a->setShortcut (tr( "Open URL" ));
668 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
671 a = new QAction( tr( "Open URL in new tab" ), this);
672 a->setStatusTip (tr( "Open URL in new tab" ));
673 a->setShortcut (Qt::CTRL+Qt::Key_U );
675 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
676 actionEditOpenURLTab=a;
678 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
679 a->setStatusTip ( tr( "Edit URL" ) );
680 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
681 //a->setShortcut ( Qt::Key_U );
682 a->setShortcutContext (Qt::WindowShortcut);
683 actionListBranches.append(a);
685 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
688 a = new QAction( tr( "Use heading for URL" ), this);
689 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
690 a->setEnabled (false);
691 actionListBranches.append(a);
692 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
693 actionEditHeading2URL=a;
695 a = new QAction(tr( "Create URL to Bugzilla" ), this);
696 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
697 a->setEnabled (false);
698 actionListBranches.append(a);
699 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
700 actionEditBugzilla2URL=a;
702 a = new QAction(tr( "Create URL to FATE" ), this);
703 a->setStatusTip ( tr( "Create URL to FATE" ));
704 a->setEnabled (false);
705 actionListBranches.append(a);
706 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
707 actionEditFATE2URL=a;
709 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
710 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
712 a->setEnabled (false);
713 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
714 actionEditOpenVymLink=a;
716 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
717 a->setEnabled (false);
718 a->setStatusTip ( tr( "Edit link to another vym map" ));
719 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
720 actionListBranches.append(a);
723 a = new QAction(tr( "Delete vym link" ),this);
724 a->setStatusTip ( tr( "Delete link to another vym map" ));
725 a->setEnabled (false);
726 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
727 actionEditDeleteVymLink=a;
729 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
730 a->setStatusTip ( tr( "Hide object in exports" ) );
731 a->setShortcut (Qt::Key_H );
732 a->setToggleAction(true);
734 a->setEnabled (false);
735 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
736 actionEditToggleHideExport=a;
738 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
739 a->setStatusTip ( tr( "Edit Map Info" ));
740 a->setEnabled (true);
741 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
744 editMenu->addSeparator();
746 // Import at selection (adding to selection)
747 a = new QAction( tr( "Add map (insert)" ),this);
748 a->setStatusTip (tr( "Add map at selection" ));
749 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
750 a->setEnabled (false);
751 actionListBranches.append(a);
752 actionEditImportAdd=a;
754 // Import at selection (replacing selection)
755 a = new QAction( tr( "Add map (replace)" ), this);
756 a->setStatusTip (tr( "Replace selection with map" ));
757 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
758 a->setEnabled (false);
759 actionListBranches.append(a);
760 actionEditImportReplace=a;
763 a = new QAction( tr( "Save selection" ), this);
764 a->setStatusTip (tr( "Save selection" ));
765 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
766 a->setEnabled (false);
767 actionListBranches.append(a);
768 actionEditSaveBranch=a;
770 // Only remove branch, not its childs
771 a = new QAction(tr( "Remove only branch " ), this);
772 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
773 a->setShortcut (Qt::ALT + Qt::Key_Delete );
774 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
775 a->setEnabled (false);
776 actionListBranches.append(a);
777 actionEditRemoveBranchKeepChilds=a;
779 // Only remove childs of a branch
780 a = new QAction( tr( "Remove childs" ), this);
781 a->setStatusTip (tr( "Remove childs of branch" ));
782 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
783 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
784 a->setEnabled (false);
785 actionListBranches.append(a);
786 actionEditRemoveChilds=a;
788 // Shortcuts for navigating with cursor:
789 a = new QAction(tr( "Select upper branch" ), this);
790 a->setStatusTip ( tr( "Select upper branch" ));
791 a->setShortcut (Qt::Key_Up );
792 a->setShortcutContext (Qt::WindowShortcut);
794 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
795 a = new QAction( tr( "Select lower branch" ),this);
796 a->setStatusTip (tr( "Select lower branch" ));
797 a->setShortcut ( Qt::Key_Down );
798 a->setShortcutContext (Qt::WindowShortcut);
800 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
801 a = new QAction(tr( "Select left branch" ), this);
802 a->setStatusTip ( tr( "Select left branch" ));
803 a->setShortcut (Qt::Key_Left );
804 a->setShortcutContext (Qt::WindowShortcut);
806 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
807 a = new QAction( tr( "Select child branch" ), this);
808 a->setStatusTip (tr( "Select right branch" ));
809 a->setShortcut (Qt::Key_Right);
810 a->setShortcutContext (Qt::WindowShortcut);
812 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
813 a = new QAction( tr( "Select first branch" ), this);
814 a->setStatusTip (tr( "Select first branch" ));
815 a->setShortcut (Qt::Key_Home );
816 a->setShortcutContext (Qt::WindowShortcut);
818 a->setEnabled (false);
819 editMenu->addAction (a);
820 actionListBranches.append(a);
821 actionEditSelectFirst=a;
822 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
823 a = new QAction( tr( "Select last branch" ),this);
824 a->setStatusTip (tr( "Select last branch" ));
825 a->setShortcut ( Qt::Key_End );
826 a->setShortcutContext (Qt::WindowShortcut);
828 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
829 a->setEnabled (false);
830 editMenu->addAction (a);
831 actionListBranches.append(a);
832 actionEditSelectLast=a;
834 a = new QAction( tr( "Add Image" )+QString("..."), this);
835 a->setStatusTip (tr( "Add Image" ));
836 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
837 actionEditLoadImage=a;
842 void Main::setupFormatActions()
844 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
846 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
849 pix.fill (Qt::black);
850 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
851 a->setStatusTip ( tr( "Set Color" ));
852 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
854 formatMenu->addAction (a);
856 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
857 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
858 a->setShortcut (Qt::CTRL + Qt::Key_K );
859 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
860 a->setEnabled (false);
862 formatMenu->addAction (a);
863 actionListBranches.append(a);
864 actionFormatPickColor=a;
866 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
867 a->setStatusTip ( tr( "Color branch" ) );
868 a->setShortcut (Qt::CTRL + Qt::Key_I);
869 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
870 a->setEnabled (false);
872 formatMenu->addAction (a);
873 actionListBranches.append(a);
874 actionFormatColorBranch=a;
876 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
877 a->setStatusTip ( tr( "Color Subtree" ));
878 a->setShortcut (Qt::CTRL + Qt::Key_T);
879 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
880 a->setEnabled (false);
881 formatMenu->addAction (a);
883 actionListBranches.append(a);
884 actionFormatColorSubtree=a;
886 formatMenu->addSeparator();
887 actionGroupFormatLinkStyles=new QActionGroup ( this);
888 actionGroupFormatLinkStyles->setExclusive (true);
889 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
890 a->setStatusTip (tr( "Line" ));
891 a->setToggleAction(true);
892 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
893 formatMenu->addAction (a);
894 actionFormatLinkStyleLine=a;
895 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
896 a->setStatusTip (tr( "Line" ));
897 a->setToggleAction(true);
898 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
899 formatMenu->addAction (a);
900 actionFormatLinkStyleParabel=a;
901 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
902 a->setStatusTip (tr( "PolyLine" ));
903 a->setToggleAction(true);
904 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
905 formatMenu->addAction (a);
906 actionFormatLinkStylePolyLine=a;
907 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
908 a->setStatusTip (tr( "PolyParabel" ) );
909 a->setToggleAction(true);
910 a->setChecked (true);
911 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
912 formatMenu->addAction (a);
913 actionFormatLinkStylePolyParabel=a;
915 actionGroupFormatFrameTypes=new QActionGroup ( this);
916 actionGroupFormatFrameTypes->setExclusive (true);
917 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
918 a->setStatusTip (tr("No Frame"));
919 a->setToggleAction(true);
920 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
921 actionFormatFrameNone=a;
922 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
923 a->setStatusTip (tr( "Rectangle" ));
924 a->setToggleAction(true);
925 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
926 actionFormatFrameRectangle=a;
928 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
929 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
930 a->setToggleAction(true);
931 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
932 actionFormatIncludeImagesVer=a;
934 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
935 a->setStatusTip ( tr ("Include left and right position of images into branch"));
936 a->setToggleAction(true);
937 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
938 actionFormatIncludeImagesHor=a;
940 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
941 a->setStatusTip (tr( "Hide link" ));
942 a->setToggleAction(true);
943 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
944 actionFormatHideLinkUnselected=a;
946 formatMenu->addSeparator();
947 a= new QAction( tr( "&Use color of heading for link" ), this);
948 a->setStatusTip (tr( "Use same color for links and headings" ));
949 a->setToggleAction(true);
950 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
951 formatMenu->addAction (a);
952 actionFormatLinkColorHint=a;
954 pix.fill (Qt::white);
955 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
956 a->setStatusTip (tr( "Set Link Color" ));
957 formatMenu->addAction (a);
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
959 actionFormatLinkColor=a;
961 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
962 a->setStatusTip (tr( "Set Background Color" ));
963 formatMenu->addAction (a);
964 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
965 actionFormatBackColor=a;
969 void Main::setupViewActions()
971 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
972 tb->setLabel( "View Actions" );
973 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
976 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
977 a->setStatusTip ( tr( "Zoom reset" ) );
978 a->setShortcut (Qt::CTRL + Qt::Key_0 );
980 viewMenu->addAction (a);
981 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
983 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
984 a->setStatusTip (tr( "Zoom in" ));
985 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
987 viewMenu->addAction (a);
988 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
990 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
991 a->setStatusTip (tr( "Zoom out" ));
992 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
994 viewMenu->addAction (a);
995 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
998 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
999 a->setStatusTip ( tr( "Show Note Editor" ));
1000 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1001 a->setToggleAction(true);
1002 if (textEditor->showWithMain())
1007 viewMenu->addAction (a);
1008 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1009 actionViewToggleNoteEditor=a;
1011 a = new QAction( tr( "Show history window" ),this );
1012 a->setStatusTip ( tr( "Show history window" ));
1013 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1014 a->setToggleAction(false);
1015 viewMenu->addAction (a);
1016 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1017 actionViewToggleHistoryWindow=a;
1019 a = new QAction(tr( "Next Window" ), this);
1020 a->setStatusTip ( tr( "&Next Window" ) );
1021 a->setShortcut (Qt::ALT + Qt::Key_N );
1022 viewMenu->addAction (a);
1023 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1025 a = new QAction (tr( "Previous Window" ), this );
1026 a->setStatusTip (tr( "&Previous Window" ));
1027 a->setShortcut (Qt::ALT + Qt::Key_P );
1028 viewMenu->addAction (a);
1029 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1033 void Main::setupModeActions()
1035 //QPopupMenu *menu = new QPopupMenu( this );
1036 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1038 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1040 actionGroupModModes=new QActionGroup ( this);
1041 actionGroupModModes->setExclusive (true);
1042 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1043 a->setShortcut (Qt::Key_J);
1044 a->setStatusTip ( tr( "Use modifier to color branches" ));
1045 a->setToggleAction(true);
1048 actionModModeColor=a;
1050 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1051 a->setShortcut( Qt::Key_K);
1052 a->setStatusTip( tr( "Use modifier to copy" ));
1053 a->setToggleAction(true);
1055 actionModModeCopy=a;
1057 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1058 a->setShortcut (Qt::Key_L);
1059 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1060 a->setToggleAction(true);
1062 actionModModeLink=a;
1066 void Main::setupFlagActions()
1068 // Create System Flags
1069 systemFlagsDefault = new FlagRowObj ();
1070 systemFlagsDefault->setVisibility (false);
1071 systemFlagsDefault->setName ("systemFlagsDef");
1073 FlagObj *fo = new FlagObj ();
1074 fo->load(QPixmap(flagsPath+"flag-note.png"));
1075 fo->setName("note");
1076 fo->setToolTip(tr("Note","Systemflag"));
1077 systemFlagsDefault->addFlag (fo); // makes deep copy
1079 fo->load(QPixmap(flagsPath+"flag-url.png"));
1081 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1082 systemFlagsDefault->addFlag (fo);
1084 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1085 fo->setName("vymLink");
1086 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1087 systemFlagsDefault->addFlag (fo);
1089 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1090 fo->setName("scrolledright");
1091 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1092 systemFlagsDefault->addFlag (fo);
1094 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1095 fo->setName("tmpUnscrolledright");
1096 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1097 systemFlagsDefault->addFlag (fo);
1099 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1100 fo->setName("hideInExport");
1101 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1102 systemFlagsDefault->addFlag (fo);
1104 // Create Standard Flags
1105 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1106 //FIXMEtoolbars.add (tb);
1108 standardFlagsDefault = new FlagRowObj ();
1109 standardFlagsDefault->setVisibility (false);
1110 standardFlagsDefault->setName ("standardFlagsDef");
1111 standardFlagsDefault->setToolBar (tb);
1112 TB_standardFlags=tb;
1113 tb->setObjectName ("standardFlagTB");
1115 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1116 fo->setName ("exclamationmark");
1117 fo->setGroup("standard-mark");
1118 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1121 a->setCheckable(true);
1122 a->setObjectName(fo->getName());
1123 a->setToolTip(tr("Take care!","Standardflag"));
1124 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1125 standardFlagsDefault->addFlag (fo); // makes deep copy
1127 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1128 fo->setName("questionmark");
1129 fo->setGroup("standard-mark");
1130 a=new QAction (fo->getPixmap(),fo->getName(),this);
1133 a->setCheckable(true);
1134 a->setObjectName(fo->getName());
1135 a->setToolTip(tr("Really?","Standardflag"));
1136 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1137 standardFlagsDefault->addFlag (fo);
1139 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1140 fo->setName("hook-green");
1141 fo->setGroup("standard-hook");
1142 a=new QAction (fo->getPixmap(),fo->getName(),this);
1145 a->setCheckable(true);
1146 a->setObjectName(fo->getName());
1147 a->setToolTip(tr("ok!","Standardflag"));
1148 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1149 standardFlagsDefault->addFlag (fo);
1151 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1152 fo->setName("cross-red");
1153 fo->setGroup("standard-hook");
1154 a=new QAction (fo->getPixmap(),fo->getName(),this);
1157 a->setCheckable(true);
1158 a->setObjectName(fo->getName());
1159 a->setToolTip(tr("Not ok!","Standardflag"));
1160 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1161 standardFlagsDefault->addFlag (fo);
1163 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1164 fo->setName("stopsign");
1165 a=new QAction (fo->getPixmap(),fo->getName(),this);
1168 a->setCheckable(true);
1169 a->setObjectName(fo->getName());
1170 a->setToolTip(tr("This won't work!","Standardflag"));
1171 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1172 standardFlagsDefault->addFlag (fo);
1174 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1175 fo->setName("smiley-good");
1176 fo->setGroup("standard-smiley");
1177 a=new QAction (fo->getPixmap(),fo->getName(),this);
1180 a->setCheckable(true);
1181 a->setObjectName(fo->getName());
1182 a->setToolTip(tr("Good","Standardflag"));
1183 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1184 standardFlagsDefault->addFlag (fo);
1186 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1187 fo->setName("smiley-sad");
1188 fo->setGroup("standard-smiley");
1189 a=new QAction (fo->getPixmap(),fo->getName(),this);
1192 a->setCheckable(true);
1193 a->setObjectName(fo->getName());
1194 a->setToolTip(tr("Bad","Standardflag"));
1195 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1196 standardFlagsDefault->addFlag (fo);
1198 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1199 // Original omg.png (in KDE emoticons)
1200 fo->setName("smiley-omg");
1201 fo->setGroup("standard-smiley");
1202 a=new QAction (fo->getPixmap(),fo->getName(),this);
1205 a->setCheckable(true);
1206 a->setObjectName(fo->getName());
1207 a->setToolTip(tr("Oh no!","Standardflag"));
1208 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1209 standardFlagsDefault->addFlag (fo);
1211 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1212 fo->setName("clock");
1213 a=new QAction (fo->getPixmap(),fo->getName(),this);
1216 a->setCheckable(true);
1217 a->setObjectName(fo->getName());
1218 a->setToolTip(tr("Time critical","Standardflag"));
1219 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1220 standardFlagsDefault->addFlag (fo);
1222 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1223 fo->setName("phone");
1224 a=new QAction (fo->getPixmap(),fo->getName(),this);
1227 a->setCheckable(true);
1228 a->setObjectName(fo->getName());
1229 a->setToolTip(tr("Call...","Standardflag"));
1230 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1231 standardFlagsDefault->addFlag (fo);
1233 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1234 fo->setName("lamp");
1235 a=new QAction (fo->getPixmap(),fo->getName(),this);
1238 a->setCheckable(true);
1239 a->setObjectName(fo->getName());
1240 a->setToolTip(tr("Idea!","Standardflag"));
1241 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1242 standardFlagsDefault->addFlag (fo);
1244 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1245 fo->setName("arrow-up");
1246 fo->setGroup("standard-arrow");
1247 a=new QAction (fo->getPixmap(),fo->getName(),this);
1250 a->setCheckable(true);
1251 a->setObjectName(fo->getName());
1252 a->setToolTip(tr("Important","Standardflag"));
1253 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1254 standardFlagsDefault->addFlag (fo);
1256 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1257 fo->setName("arrow-down");
1258 fo->setGroup("standard-arrow");
1259 a=new QAction (fo->getPixmap(),fo->getName(),this);
1262 a->setCheckable(true);
1263 a->setObjectName(fo->getName());
1264 a->setToolTip(tr("Unimportant","Standardflag"));
1265 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1266 standardFlagsDefault->addFlag (fo);
1268 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1269 fo->setName("2arrow-up");
1270 fo->setGroup("standard-arrow");
1271 a=new QAction (fo->getPixmap(),fo->getName(),this);
1274 a->setCheckable(true);
1275 a->setObjectName(fo->getName());
1276 a->setToolTip(tr("Very important!","Standardflag"));
1277 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1278 standardFlagsDefault->addFlag (fo);
1280 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1281 fo->setName("2arrow-down");
1282 fo->setGroup("standard-arrow");
1283 a=new QAction (fo->getPixmap(),fo->getName(),this);
1286 a->setCheckable(true);
1287 a->setObjectName(fo->getName());
1288 a->setToolTip(tr("Very unimportant!","Standardflag"));
1289 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1290 standardFlagsDefault->addFlag (fo);
1292 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1293 fo->setName("thumb-up");
1294 fo->setGroup("standard-thumb");
1295 a=new QAction (fo->getPixmap(),fo->getName(),this);
1298 a->setCheckable(true);
1299 a->setObjectName(fo->getName());
1300 a->setToolTip(tr("I like this","Standardflag"));
1301 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1302 standardFlagsDefault->addFlag (fo);
1304 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1305 fo->setName("thumb-down");
1306 fo->setGroup("standard-thumb");
1307 a=new QAction (fo->getPixmap(),fo->getName(),this);
1310 a->setCheckable(true);
1311 a->setObjectName(fo->getName());
1312 a->setToolTip(tr("I do not like this","Standardflag"));
1313 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1314 standardFlagsDefault->addFlag (fo);
1316 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1317 fo->setName("rose");
1318 a=new QAction (fo->getPixmap(),fo->getName(),this);
1321 a->setCheckable(true);
1322 a->setObjectName(fo->getName());
1323 a->setToolTip(tr("Rose","Standardflag"));
1324 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1325 standardFlagsDefault->addFlag (fo);
1327 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1328 fo->setName("heart");
1329 a=new QAction (fo->getPixmap(),fo->getName(),this);
1331 a->setCheckable(true);
1332 a->setObjectName(fo->getName());
1333 a->setToolTip(tr("I just love... ","Standardflag"));
1334 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1335 standardFlagsDefault->addFlag (fo);
1337 fo->load(QPixmap(flagsPath+"flag-present.png"));
1338 fo->setName("present");
1339 a=new QAction (fo->getPixmap(),fo->getName(),this);
1342 a->setCheckable(true);
1343 a->setObjectName(fo->getName());
1344 a->setToolTip(tr("Surprise!","Standardflag"));
1345 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1346 standardFlagsDefault->addFlag (fo);
1348 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1349 fo->setName("flash");
1350 a=new QAction (fo->getPixmap(),fo->getName(),this);
1353 a->setCheckable(true);
1354 a->setObjectName(fo->getName());
1355 a->setToolTip(tr("Dangerous","Standardflag"));
1356 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1357 standardFlagsDefault->addFlag (fo);
1359 fo->load(QPixmap(flagsPath+"flag-info.png"));
1360 // Original: xsldbg_output.png
1361 fo->setName("info");
1362 a=new QAction (fo->getPixmap(),fo->getName(),this);
1365 a->setCheckable(true);
1366 a->setObjectName(fo->getName());
1367 a->setToolTip(tr("Info","Standardflag"));
1368 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1369 standardFlagsDefault->addFlag (fo);
1371 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1372 // Original khelpcenter.png
1373 fo->setName("lifebelt");
1374 a=new QAction (fo->getPixmap(),fo->getName(),this);
1377 a->setCheckable(true);
1378 a->setObjectName(fo->getName());
1379 a->setToolTip(tr("This will help","Standardflag"));
1380 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1381 standardFlagsDefault->addFlag (fo);
1387 void Main::setupSettingsActions()
1389 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1393 a = new QAction( tr( "Set application to open pdf files"), this);
1394 a->setStatusTip ( tr( "Set application to open pdf files"));
1395 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1396 settingsMenu->addAction (a);
1398 a = new QAction( tr( "Set application to open external links"), this);
1399 a->setStatusTip( tr( "Set application to open external links"));
1400 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1401 settingsMenu->addAction (a);
1403 settingsMenu->addSeparator();
1404 a = new QAction( tr( "Edit branch after adding it" ), this );
1405 a->setStatusTip( tr( "Edit branch after adding it" ));
1406 a->setToggleAction(true);
1407 a->setOn ( settings.value ("/mapeditor/editmode/autoedit",true).toBool());
1408 settingsMenu->addAction (a);
1409 actionSettingsAutoedit=a;
1411 a= new QAction( tr( "Select branch after adding it" ), this );
1412 a->setStatusTip( tr( "Select branch after adding it" ));
1413 a->setToggleAction(true);
1414 a->setOn ( settings.value ("/mapeditor/editmode/autoselect",false).toBool() );
1415 settingsMenu->addAction (a);
1416 actionSettingsAutoselectHeading=a;
1418 a= new QAction(tr( "Select existing heading" ), this);
1419 a->setStatusTip( tr( "Select heading before editing" ));
1420 a->setToggleAction(true);
1421 a->setOn ( settings.value ("/mapeditor/editmode/autoselectexistingtext",true).toBool() );
1422 settingsMenu->addAction (a);
1423 actionSettingsAutoselectText=a;
1425 a= new QAction(tr( "pasting into new branch" ), this );
1426 a->setStatusTip( tr( "Pasting into new branch" ));
1427 a->setToggleAction(true);
1428 a->setOn ( settings.value ("/mapeditor/editmode/newheadingisempty",true).toBool() );
1429 settingsMenu->addAction (a);
1430 actionSettingsPasteNewHeading=a;
1432 a= new QAction( tr( "Delete key" ), this);
1433 a->setStatusTip( tr( "Delete key for deleting branches" ));
1434 a->setToggleAction(true);
1435 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1436 settingsMenu->addAction (a);
1437 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1438 actionSettingsUseDelKey=a;
1440 a= new QAction( tr( "Exclusive flags" ), this);
1441 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1442 a->setToggleAction(true);
1443 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1444 settingsMenu->addAction (a);
1445 actionSettingsUseFlagGroups=a;
1447 a= new QAction( tr( "Use hide flags" ), this);
1448 a->setStatusTip( tr( "Use hide flag during exports " ));
1449 a->setToggleAction(true);
1450 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1451 settingsMenu->addAction (a);
1452 actionSettingsUseHideExport=a;
1456 void Main::setupTestActions()
1458 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1461 a = new QAction( tr( "test flag" ), this);
1462 a->setStatusTip( tr( "Call test function" ));
1463 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1464 testMenu->addAction (a);
1468 void Main::setupHelpActions()
1470 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1473 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1474 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1475 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1476 helpMenu->addAction (a);
1478 a = new QAction( tr( "About VYM" ), this);
1479 a->setStatusTip( tr( "About VYM")+" "__VYM);
1480 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1481 helpMenu->addAction (a);
1483 a = new QAction( tr( "About QT" ), this);
1484 a->setStatusTip( tr( "Information about QT toolkit" ));
1485 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1486 helpMenu->addAction (a);
1490 void Main::setupContextMenus()
1494 // Context Menu for branch or mapcenter
1495 branchContextMenu =new QMenu (this);
1498 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1499 branchAddContextMenu->addAction (actionEditPaste );
1500 branchAddContextMenu->addAction ( actionEditAddBranch );
1501 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1502 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1503 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1504 branchAddContextMenu->addSeparator();
1505 branchAddContextMenu->addAction ( actionEditLoadImage);
1506 branchAddContextMenu->addSeparator();
1507 branchAddContextMenu->addAction ( actionEditLoadImage);
1508 branchAddContextMenu->addAction ( actionEditImportAdd );
1509 branchAddContextMenu->addAction ( actionEditImportReplace );
1512 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1513 branchRemoveContextMenu->addAction (actionEditCut);
1514 branchRemoveContextMenu->addAction ( actionEditDelete );
1515 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1516 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1519 actionEditSaveBranch->addTo( branchContextMenu );
1521 branchContextMenu->addSeparator();
1522 branchContextMenu->addAction ( actionEditOpenURL );
1523 branchContextMenu->addAction ( actionEditOpenURLTab );
1524 branchContextMenu->addAction ( actionEditURL );
1525 branchContextMenu->addAction ( actionEditHeading2URL );
1526 branchContextMenu->addAction ( actionEditBugzilla2URL );
1527 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1529 branchContextMenu->addAction ( actionEditFATE2URL );
1531 branchContextMenu->addSeparator();
1532 branchContextMenu->addAction ( actionEditOpenVymLink );
1533 branchContextMenu->addAction ( actionEditVymLink );
1534 branchContextMenu->addAction ( actionEditDeleteVymLink );
1536 branchContextMenu->addSeparator();
1537 branchContextMenu->addAction ( actionFormatFrameNone );
1538 branchContextMenu->addAction ( actionFormatFrameRectangle);
1540 branchContextMenu->addSeparator();
1541 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1542 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1543 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1545 // Context Menu for links in a branch menu
1546 // This will be populated "on demand" in MapEditor::updateActions
1547 branchContextMenu->addSeparator();
1548 branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1549 branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1550 connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1551 connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1553 // Context menu for floatimage
1554 floatimageContextMenu =new QMenu (this);
1555 a= new QAction (tr ("Save image"),this);
1556 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1557 floatimageContextMenu->addAction (a);
1559 floatimageContextMenu->addSeparator();
1560 actionEditCopy->addTo( floatimageContextMenu );
1561 actionEditCut->addTo( floatimageContextMenu );
1563 floatimageContextMenu->addSeparator();
1564 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1567 // Context menu for canvas
1568 canvasContextMenu =new QMenu (this);
1569 actionEditMapInfo->addTo( canvasContextMenu );
1570 canvasContextMenu->insertSeparator();
1571 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1572 canvasContextMenu->insertSeparator();
1573 actionFormatLinkColorHint->addTo( canvasContextMenu );
1574 actionFormatLinkColor->addTo( canvasContextMenu );
1575 actionFormatBackColor->addTo( canvasContextMenu );
1577 // Menu for last opened files
1578 // Read settings initially
1580 int j=settings.readNumEntry( "/lastMaps/number",0);
1581 for (int i=1;i<=j;i++)
1583 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1584 if (!s.isEmpty() && j<=maxLastMaps)
1587 setupLastMapsMenu();
1588 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1591 void Main::setupLastMapsMenu()
1593 // Remove double entries
1594 QStringList::Iterator it=lastMaps.begin();
1595 QStringList::Iterator jt;
1596 while (it!=lastMaps.end() )
1600 while (jt!=lastMaps.end() )
1603 jt=lastMaps.remove(jt);
1610 // Limit length of list to maxLastMaps
1611 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1613 // build Menu from lastMaps string list
1614 fileLastMapsMenu->clear();
1615 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1616 fileLastMapsMenu->addAction (*it );
1619 void Main::hideEvent (QHideEvent * )
1621 if (!textEditor->isMinimized() ) textEditor->hide();
1624 void Main::showEvent (QShowEvent * )
1626 if (textEditor->showWithMain()) textEditor->showNormal();
1629 bool Main::reallyWriteDirectory(const QString &dir)
1631 QStringList eList = QDir(dir).entryList();
1632 if (eList.first() ==".") eList.pop_front(); // remove "."
1633 if (eList.first() =="..") eList.pop_front(); // remove "."
1634 if (!eList.isEmpty())
1636 QMessageBox mb( __VYM,
1637 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1638 QMessageBox::Warning,
1640 QMessageBox::Cancel | QMessageBox::Default,
1641 QMessageBox::QMessageBox::NoButton );
1643 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1644 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1647 case QMessageBox::Yes:
1650 case QMessageBox::Cancel:
1658 QString Main::browseDirectory (const QString &caption)
1660 Q3FileDialog fd(this,caption);
1661 fd.setMode (Q3FileDialog::DirectoryOnly);
1662 fd.setCaption(__VYM " - "+caption);
1665 if ( fd.exec() == QDialog::Accepted )
1666 return fd.selectedFile();
1671 MapEditor* Main::currentMapEditor() const
1673 if ( tabWidget->currentPage() &&
1674 tabWidget->currentPage()->inherits( "MapEditor" ) )
1675 return (MapEditor*)tabWidget->currentPage();
1679 //TODO not used now, maybe use this for overview window later
1680 void Main::newView()
1682 // Open a new view... have it delete when closed.
1683 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1684 qApp->setMainWidget(m);
1686 qApp->setMainWidget(0);
1689 void Main::editorChanged(QWidget *)
1691 // Unselect all possibly selected objects
1692 // (Important to update note editor)
1695 for (i=0;i<=tabWidget->count() -1;i++)
1698 me=(MapEditor*)tabWidget->page(i);
1701 currentMapEditor()->reselect();
1703 // Update actions to in menus and toolbars according to editor
1704 currentMapEditor()->updateActions();
1707 void Main::fileNew()
1709 QString fn="unnamed";
1710 MapEditor* medit = new MapEditor ( NULL,true);
1711 tabWidget->addTab (medit,fn);
1712 tabWidget->showPage(medit);
1713 medit->viewport()->setFocus();
1714 // For the very first map we do not have flagrows yet...
1715 medit->select("mc:");
1718 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1720 ErrorCode err=success;
1722 // fn is usually the archive, mapfile the file after uncompressing
1725 // Make fn absolute (needed for unzip)
1726 fn=QDir (fn).absPath();
1732 // Check, if map is already loaded
1734 while (i<=tabWidget->count() -1)
1736 me=(MapEditor*)tabWidget->page(i);
1737 if (me->getFilePath() == fn)
1739 // Already there, ask for confirmation
1740 QMessageBox mb( __VYM,
1741 tr("The map %1\nis already opened."
1742 "Opening the same map in multiple editors may lead \n"
1743 "to confusion when finishing working with vym."
1744 "Do you want to").arg(fn),
1745 QMessageBox::Warning,
1746 QMessageBox::Yes | QMessageBox::Default,
1747 QMessageBox::Cancel | QMessageBox::Escape,
1748 QMessageBox::NoButton);
1749 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1750 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1753 case QMessageBox::Yes:
1755 i=tabWidget->count();
1757 case QMessageBox::Cancel:
1769 if ( !fn.isEmpty() )
1771 me = currentMapEditor();
1772 int tabIndex=tabWidget->currentPageIndex();
1773 // Check first, if mapeditor exists
1774 // If it is not default AND we want a new map,
1775 // create a new mapeditor in a new tab
1776 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1778 me= new MapEditor ( NULL,true);
1779 tabWidget->addTab (me,fn);
1780 tabIndex=tabWidget->indexOf (me);
1781 tabWidget->setCurrentPage (tabIndex);
1784 // Check, if file exists (important for creating new files
1785 // from command line
1786 if (!QFile(fn).exists() )
1788 QMessageBox mb( __VYM,
1789 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1790 QMessageBox::Question,
1792 QMessageBox::Cancel | QMessageBox::Default,
1793 QMessageBox::NoButton );
1795 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1796 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1799 case QMessageBox::Yes:
1801 currentMapEditor()->setFilePath(fn);
1802 tabWidget->setTabLabel (currentMapEditor(),
1803 currentMapEditor()->getFileName() );
1804 statusBar()->message( "Created " + fn , statusbarTime );
1807 case QMessageBox::Cancel:
1808 // don't create new map
1809 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1816 //tabWidget->currentPage() won't be NULL here, because of above...
1817 tabWidget->showPage(me);
1818 me->viewport()->setFocus();
1820 // Create temporary directory for packing
1821 char tmpdir1[]="/tmp/vym-XXXXXX";
1822 QString tmpMapDir=mkdtemp(tmpdir1);
1824 // Try to unzip file
1825 err=unzipDir (tmpMapDir,fn);
1829 me->setZipped(false);
1832 me->setZipped(true);
1834 // Look for mapname.xml
1835 mapfile= fn.left(fn.findRev(".",-1,true));
1836 mapfile=mapfile.section( '/', -1 );
1837 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1838 if (!file.exists() )
1840 // mapname.xml does not exist, well,
1841 // maybe some renamed the mapname.vym file...
1842 // Try to find any .xml in the toplevel
1843 // directory of the .vym file
1844 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1845 if (flist.count()==1)
1847 // Only one entry, take this one
1848 mapfile=tmpMapDir + "/"+flist.first();
1851 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1852 *it=tmpMapDir + "/" + *it;
1853 // TODO Multiple entries, load all (but only the first one into this ME)
1854 //mainWindow->fileLoadFromTmp (flist);
1855 //returnCode=1; // Silently forget this attempt to load
1856 qWarning ("MainWindow::load (fn) multimap found...");
1859 if (flist.isEmpty() )
1861 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1862 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1865 } //file doesn't exist
1867 mapfile=file.name();
1872 // Save existing filename in case we import
1873 QString fn_org=me->getFilePath();
1875 // Finally load map into mapEditor
1876 me->setFilePath (mapfile,fn);
1877 err=me->load(mapfile,lmode);
1879 // Restore old (maybe empty) filepath, if this is an import
1881 me->setFilePath (fn_org);
1884 // Finally check for errors and go home
1887 if (lmode==NewMap) fileCloseMap();
1888 statusBar()->message( "Could not load " + fn, statusbarTime );
1893 me->setFilePath (fn);
1894 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1895 if (fn.left(9)!="/tmp/vym-")
1897 // Only append to lastMaps if not loaded from a tmpDir
1898 // e.g. imported bookmarks are in a tmpDir
1899 lastMaps.prepend(me->getFilePath() );
1900 setupLastMapsMenu();
1902 actionFilePrint->setEnabled (true);
1904 statusBar()->message( "Loaded " + fn, statusbarTime );
1908 removeDir (QDir(tmpMapDir));
1914 void Main::fileLoad(const LoadMode &lmode)
1916 Q3FileDialog *fd=new Q3FileDialog( this);
1917 fd->setDir (lastFileDir);
1918 fd->setMode (Q3FileDialog::ExistingFiles);
1919 fd->addFilter ("XML (*.xml)");
1920 fd->addFilter ("VYM map (*.vym *.vyp)");
1924 fd->setCaption(tr("Load vym map"));
1927 fd->setCaption(tr("Import: Add vym map to selection"));
1930 fd->setCaption(tr("Import: Replace selection with vym map"));
1936 if ( fd->exec() == QDialog::Accepted )
1938 lastFileDir=fd->dirPath();
1939 QStringList flist = fd->selectedFiles();
1940 QStringList::Iterator it = flist.begin();
1941 while( it != flist.end() )
1944 fileLoad(*it, lmode);
1951 void Main::fileLoad()
1956 void Main::fileLoadLast(QAction *a)
1958 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1961 void Main::fileSave(const SaveMode &savemode)
1963 // tmp dir for zipping
1967 ErrorCode err=success;
1969 QString safeFilePath;
1971 bool saveZipped=currentMapEditor()->saveZipped();
1973 MapEditor * me=currentMapEditor();
1976 QString fn=me->getFilePath();
1977 // filename=unnamed, filepath="" in constructor...
1978 if ( !fn.isEmpty() )
1980 // We have a filepath, go on saving
1981 // First remove existing file, we
1982 // don't want to add to old zip archives
1986 QMessageBox::warning( 0, tr( "Save Error" ),
1987 fn+ tr("\ncould not be removed before saving"));
1989 // Look, if we should zip the data:
1992 QMessageBox mb( __VYM,
1993 tr("The map %1\ndid not use the compressed "
1994 "vym file format.\nWriting it uncompressed will also write images \n"
1995 "and flags and thus may overwrite files in the "
1996 "given directory\n\nDo you want to write the map").arg(fn),
1997 QMessageBox::Warning,
1998 QMessageBox::Yes | QMessageBox::Default,
2000 QMessageBox::Cancel | QMessageBox::Escape);
2001 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2002 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2003 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2006 case QMessageBox::Yes:
2007 // save compressed (default file format)
2010 case QMessageBox::No:
2011 // save uncompressed
2014 case QMessageBox::Cancel:
2023 char tmpdir1[]="/tmp/vym-XXXXXX";
2024 tmpMapDir=mkdtemp(tmpdir1);
2026 safeFilePath=me->getFilePath();
2027 me->setFilePath (tmpMapDir+"/"+
2028 me->getMapName()+ ".xml",
2030 me->save (savemode);
2031 me->setFilePath (safeFilePath);
2033 zipDir (tmpMapDir,fn);
2038 safeFilePath=me->getFilePath();
2039 me->setFilePath (fn, safeFilePath);
2040 me->save (savemode);
2041 me->setFilePath (safeFilePath);
2043 } // filepath available
2046 // We have no filepath yet,
2047 // call fileSaveAs() now, this will call fileSave()
2049 fileSaveAs(savemode);
2053 if (saveZipped && !tmpMapDir.isEmpty())
2055 removeDir (QDir(tmpMapDir));
2059 statusBar()->message(
2060 tr("Saved %1").arg(me->getFilePath()),
2062 lastMaps.prepend(me->getFilePath() );
2063 setupLastMapsMenu();
2065 statusBar()->message(
2066 tr("Couldn't save ").arg(me->getFilePath()),
2070 void Main::fileSave()
2072 fileSave (CompleteMap);
2075 void Main::fileSaveAs(const SaveMode& savemode)
2079 if (currentMapEditor())
2081 if (savemode==CompleteMap)
2082 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2084 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2085 if ( !fn.isEmpty() )
2087 // Check for existing file
2088 if (QFile (fn).exists())
2090 QMessageBox mb( __VYM,
2091 tr("The file %1\nexists already. Do you want to").arg(fn),
2092 QMessageBox::Warning,
2093 QMessageBox::Yes | QMessageBox::Default,
2094 QMessageBox::Cancel | QMessageBox::Escape,
2095 QMessageBox::NoButton);
2096 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2097 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2100 case QMessageBox::Yes:
2103 case QMessageBox::Cancel:
2110 // New file, add extension to filename, if missing
2111 // This is always .vym or .vyp, depending on savemode
2112 if (savemode==CompleteMap)
2114 if (!fn.contains (".vym") && !fn.contains (".xml"))
2118 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2127 currentMapEditor()->setFilePath(fn);
2131 if (savemode==CompleteMap)
2132 tabWidget->setTabLabel (currentMapEditor(),
2133 currentMapEditor()->getFileName() );
2139 void Main::fileSaveAs()
2141 fileSaveAs (CompleteMap);
2144 void Main::fileImportKDEBookmarks()
2146 ImportKDEBookmarks im;
2148 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2149 currentMapEditor()->setFilePath ("");
2152 void Main::fileImportFirefoxBookmarks()
2154 Q3FileDialog *fd=new Q3FileDialog( this);
2155 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2156 fd->setMode (Q3FileDialog::ExistingFiles);
2157 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2158 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2161 if ( fd->exec() == QDialog::Accepted )
2163 ImportFirefoxBookmarks im;
2164 QStringList flist = fd->selectedFiles();
2165 QStringList::Iterator it = flist.begin();
2166 while( it != flist.end() )
2169 if (im.transform() &&
2170 success==fileLoad (im.getTransformedFile(),NewMap) &&
2171 currentMapEditor() )
2172 currentMapEditor()->setFilePath ("");
2179 void Main::fileImportMM()
2183 Q3FileDialog *fd=new Q3FileDialog( this);
2184 fd->setDir (lastFileDir);
2185 fd->setMode (Q3FileDialog::ExistingFiles);
2186 fd->addFilter ("Mind Manager (*.mmap)");
2187 fd->setCaption(tr("Import")+" "+"Mind Manager");
2190 if ( fd->exec() == QDialog::Accepted )
2192 lastFileDir=fd->dirPath();
2193 QStringList flist = fd->selectedFiles();
2194 QStringList::Iterator it = flist.begin();
2195 while( it != flist.end() )
2198 if (im.transform() &&
2199 success==fileLoad (im.getTransformedFile(),NewMap) &&
2200 currentMapEditor() )
2201 currentMapEditor()->setFilePath ("");
2210 void Main::fileImportDir()
2212 if (currentMapEditor())
2213 currentMapEditor()->importDir();
2216 void Main::fileExportXML()
2218 if (currentMapEditor())
2220 QString dir=browseDirectory(tr("Export XML to directory"));
2221 if (dir !="" && reallyWriteDirectory(dir) )
2222 currentMapEditor()->exportXML(dir);
2227 void Main::fileExportXHTML()
2229 MapEditor *me=currentMapEditor();
2233 ExportXHTMLDialog dia(this);
2234 dia.setFilePath (me->getFilePath() );
2235 dia.setMapName (me->getMapName() );
2238 if (dia.exec()==QDialog::Accepted)
2240 QString dir=dia.getDir();
2241 // Check, if warnings should be used before overwriting
2242 // the output directory
2245 ok=reallyWriteDirectory(dir);
2251 me->exportXML (dia.getDir() );
2252 dia.doExport(me->getMapName() );
2253 if (dia.hasChanged())
2260 void Main::fileExportImage()
2262 MapEditor *me=currentMapEditor();
2266 QFileDialog *fd=new QFileDialog (this);
2267 fd->setCaption (tr("Export map as image"));
2268 fd->setFileMode(QFileDialog::AnyFile);
2269 fd->setFilters (imageIO.getFilters() );
2270 fd->setDirectory (lastImageDir);
2273 fl=fd->selectedFiles();
2274 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2275 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2280 void Main::fileExportASCII()
2282 MapEditor *me=currentMapEditor();
2286 ex.setMapCenter(me->getMapCenter());
2287 ex.addFilter ("TXT (*.txt)");
2288 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2289 if (ex.execDialog() )
2291 me->setExportMode(true);
2293 me->setExportMode(false);
2298 void Main::fileExportLaTeX()
2300 MapEditor *me=currentMapEditor();
2304 ex.setMapCenter(me->getMapCenter());
2305 ex.addFilter ("Tex (*.tex)");
2306 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2307 if (ex.execDialog() )
2309 me->setExportMode(true);
2311 me->setExportMode(false);
2316 void Main::fileExportKDEBookmarks()
2318 ExportKDEBookmarks ex;
2319 MapEditor *me=currentMapEditor();
2322 ex.setMapCenter (me->getMapCenter() );
2327 void Main::fileExportTaskjuggler()
2329 ExportTaskjuggler ex;
2330 MapEditor *me=currentMapEditor();
2333 ex.setMapCenter (me->getMapCenter() );
2334 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2335 ex.addFilter ("Taskjuggler (*.tjp)");
2336 if (ex.execDialog() )
2338 me->setExportMode(true);
2340 me->setExportMode(false);
2345 void Main::fileExportOOPresentation()
2347 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2348 // TODO add preview in dialog
2349 //ImagePreview *p =new ImagePreview (fd);
2350 //fd->setContentsPreviewEnabled( TRUE );
2351 //fd->setContentsPreview( p, p );
2352 //fd->setPreviewMode( QFileDialog::Contents );
2353 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2354 fd->setDir (QDir().current());
2355 if (fd->foundConfig())
2359 if ( fd->exec() == QDialog::Accepted )
2361 QString fn=fd->selectedFile();
2362 //lastImageDir=fn.left(fn.findRev ("/"));
2363 if (currentMapEditor())
2364 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2368 QMessageBox::warning(0,
2370 tr("Couldn't find configuration for export to Open Office\n"));
2374 void Main::fileCloseMap()
2376 if (currentMapEditor())
2378 if (currentMapEditor()->hasChanged())
2380 QMessageBox mb( __VYM,
2381 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2382 QMessageBox::Warning,
2383 QMessageBox::Yes | QMessageBox::Default,
2385 QMessageBox::Cancel | QMessageBox::Escape );
2386 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2387 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2390 case QMessageBox::Yes:
2392 fileSave(CompleteMap);
2394 case QMessageBox::No:
2395 // close without saving
2397 case QMessageBox::Cancel:
2402 currentMapEditor()->closeMap();
2403 tabWidget->removePage(currentMapEditor());
2404 if (tabWidget->count()==0)
2405 actionFilePrint->setEnabled (false);
2409 void Main::filePrint()
2411 if (currentMapEditor())
2412 currentMapEditor()->print();
2415 void Main::fileExitVYM()
2417 // Check if one or more editors have changed
2420 for (i=0;i<=tabWidget->count() -1;i++)
2423 me=(MapEditor*)tabWidget->page(i);
2425 // If something changed, ask what to do
2426 if (me->isUnsaved())
2428 tabWidget->setCurrentPage(i);
2429 QMessageBox mb( __VYM,
2430 tr("This map is not saved yet. Do you want to"),
2431 QMessageBox::Warning,
2432 QMessageBox::Yes | QMessageBox::Default,
2434 QMessageBox::Cancel | QMessageBox::Escape );
2435 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2436 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2438 mb.setActiveWindow();
2439 switch( mb.exec() ) {
2440 case QMessageBox::Yes:
2441 // save (the changed editors) and exit
2442 fileSave(CompleteMap);
2444 case QMessageBox::No:
2445 // exit without saving
2447 case QMessageBox::Cancel:
2448 // don't save and don't exit
2452 } // loop over all MEs
2456 void Main::editUndo()
2458 if (currentMapEditor())
2459 currentMapEditor()->undo();
2462 void Main::editRedo()
2464 if (currentMapEditor())
2465 currentMapEditor()->redo();
2468 void Main::editCopy()
2470 if (currentMapEditor())
2471 currentMapEditor()->copy();
2474 void Main::editPaste()
2476 if (currentMapEditor())
2477 currentMapEditor()->paste();
2480 void Main::editCut()
2482 if (currentMapEditor())
2483 currentMapEditor()->cut();
2486 void Main::editOpenFindWindow()
2488 findWindow->popup();
2489 findWindow->raise();
2490 findWindow->setActiveWindow();
2493 void Main::editFind(QString s)
2496 BranchObj *bo=currentMapEditor()->findText(s, cs);
2499 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2502 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2503 tr("No matches found for \"%1\"").arg(s));
2507 void Main::editFindChanged()
2508 { // Notify editor, to abort the current find process
2509 currentMapEditor()->findReset();
2512 void Main::editOpenURL()
2515 if (currentMapEditor())
2517 QString url=currentMapEditor()->getURL();
2518 if (url=="") return;
2519 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2520 procBrowser = new Q3Process( this );
2522 procBrowser->addArgument( browser);
2523 procBrowser->addArgument( url);
2525 if ( !procBrowser->start() )
2527 // try to set path to browser
2528 QMessageBox::warning(0,
2530 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2531 tr("Please use Settings->")+tr("Set application to open an URL"));
2536 void Main::editOpenURLTab()
2538 if (currentMapEditor())
2540 QString url=currentMapEditor()->getURL();
2541 if (url=="") return;
2542 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2543 if (procBrowser && procBrowser->isRunning())
2545 if (browser.contains("konqueror"))
2547 // Try to open new tab in existing konqueror started previously by vym
2548 Q3Process *p=new Q3Process (this);
2549 p->addArgument ("dcop");
2550 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2551 p->addArgument ("konqueror-mainwindow#1");
2552 p->addArgument ("newTab");
2553 p->addArgument (url);
2555 // try to set browser
2556 QMessageBox::warning(0,
2558 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2560 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2562 // Try to open new tab in firefox
2563 Q3Process *p=new Q3Process (this);
2564 p->addArgument (browser);
2565 p->addArgument ("-remote");
2566 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2568 // try to set browser
2569 QMessageBox::warning(0,
2571 tr("Couldn't start %1 to open a new tab").arg(browser));
2580 void Main::editURL()
2582 if (currentMapEditor())
2583 currentMapEditor()->editURL();
2586 void Main::editHeading2URL()
2588 if (currentMapEditor())
2589 currentMapEditor()->editHeading2URL();
2592 void Main::editBugzilla2URL()
2594 if (currentMapEditor())
2595 currentMapEditor()->editBugzilla2URL();
2598 void Main::editFATE2URL()
2600 if (currentMapEditor())
2601 currentMapEditor()->editFATE2URL();
2604 void Main::editOpenVymLink()
2606 // Get current path to map
2607 QString currentVymLink;
2608 if (currentMapEditor())
2610 currentVymLink=currentMapEditor()->getVymLink();
2611 // compare path with already loaded maps
2615 for (i=0;i<=tabWidget->count() -1;i++)
2617 me=(MapEditor*)tabWidget->page(i);
2618 if (currentVymLink==me->getFilePath() )
2627 if (!QFile(currentVymLink).exists() )
2628 QMessageBox::critical( 0, tr( "Critical Error" ),
2629 tr("Couldn't open map %1").arg(currentVymLink));
2632 fileLoad (currentVymLink, NewMap);
2633 tabWidget->setCurrentPage (tabWidget->count()-1);
2636 // Go to tab containing the map
2637 tabWidget->setCurrentPage (index);
2641 void Main::editVymLink()
2643 if (currentMapEditor())
2644 currentMapEditor()->editVymLink();
2647 void Main::editDeleteVymLink()
2649 if (currentMapEditor())
2650 currentMapEditor()->deleteVymLink();
2653 void Main::editToggleHideExport()
2655 if (currentMapEditor())
2656 currentMapEditor()->toggleHideExport();
2659 void Main::editMapInfo()
2661 if (currentMapEditor())
2662 currentMapEditor()->editMapInfo();
2665 void Main::editMoveUp()
2667 if (currentMapEditor())
2668 currentMapEditor()->moveBranchUp();
2671 void Main::editMoveDown()
2673 if (currentMapEditor())
2674 currentMapEditor()->moveBranchDown();
2677 void Main::editToggleScroll()
2679 if (currentMapEditor())
2681 currentMapEditor()->toggleScroll();
2685 void Main::editUnScrollAll()
2687 if (currentMapEditor())
2689 currentMapEditor()->unScrollAll();
2693 void Main::editHeading()
2695 if (currentMapEditor())
2696 currentMapEditor()->editHeading();
2699 void Main::editNewBranch()
2701 if (currentMapEditor())
2702 currentMapEditor()->addNewBranch(0);
2705 void Main::editNewBranchHere()
2707 if (currentMapEditor())
2708 currentMapEditor()->addNewBranchHere();
2711 void Main::editNewBranchAbove()
2713 if (currentMapEditor())
2714 currentMapEditor()->addNewBranch(-1);
2717 void Main::editNewBranchBelow()
2719 if (currentMapEditor())
2720 currentMapEditor()->addNewBranch(1);
2723 void Main::editImportAdd()
2725 fileLoad (ImportAdd);
2728 void Main::editImportReplace()
2730 fileLoad (ImportReplace);
2733 void Main::editSaveBranch()
2735 fileSaveAs (PartOfMap);
2738 void Main::editRemoveBranchKeepChilds()
2740 if (currentMapEditor())
2741 currentMapEditor()->removeBranchKeepChilds();
2744 void Main::editRemoveChilds()
2746 if (currentMapEditor())
2747 currentMapEditor()->removeChilds();
2750 void Main::editDeleteSelection()
2752 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2753 currentMapEditor()->deleteSelection();
2756 void Main::editUpperBranch()
2758 if (currentMapEditor())
2759 currentMapEditor()->selectUpperBranch();
2762 void Main::editLowerBranch()
2764 if (currentMapEditor())
2765 currentMapEditor()->selectLowerBranch();
2768 void Main::editLeftBranch()
2770 if (currentMapEditor())
2771 currentMapEditor()->selectLeftBranch();
2774 void Main::editRightBranch()
2776 if (currentMapEditor())
2777 currentMapEditor()->selectRightBranch();
2780 void Main::editFirstBranch()
2782 if (currentMapEditor())
2783 currentMapEditor()->selectFirstBranch();
2786 void Main::editLastBranch()
2788 if (currentMapEditor())
2789 currentMapEditor()->selectLastBranch();
2792 void Main::editLoadImage()
2794 if (currentMapEditor())
2795 currentMapEditor()->loadFloatImage();
2798 void Main::editSaveImage()
2800 if (currentMapEditor())
2801 currentMapEditor()->saveFloatImage();
2804 void Main::editFollowXLink(QAction *a)
2807 if (currentMapEditor())
2808 currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
2811 void Main::editEditXLink(QAction *a)
2813 if (currentMapEditor())
2814 currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
2817 void Main::formatSelectColor()
2819 if (currentMapEditor())
2821 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2822 if ( !col.isValid() ) return;
2823 currentMapEditor()->setColor( col );
2824 colorChanged( col );
2828 void Main::formatPickColor()
2830 if (currentMapEditor())
2831 colorChanged( currentMapEditor()->pickColor() );
2834 void Main::colorChanged(QColor c)
2836 QPixmap pix( 16, 16 );
2838 actionFormatColor->setIconSet( pix );
2841 void Main::formatColorItem()
2843 if (currentMapEditor())
2844 currentMapEditor()->colorItem();
2847 void Main::formatColorBranch()
2849 if (currentMapEditor())
2850 currentMapEditor()->colorBranch();
2853 void Main::formatLinkStyleLine()
2855 if (currentMapEditor())
2856 currentMapEditor()->setLinkStyle(StyleLine);
2859 void Main::formatLinkStyleParabel()
2861 if (currentMapEditor())
2862 currentMapEditor()->setLinkStyle(StyleParabel);
2865 void Main::formatLinkStylePolyLine()
2867 if (currentMapEditor())
2868 currentMapEditor()->setLinkStyle(StylePolyLine);
2871 void Main::formatLinkStylePolyParabel()
2873 if (currentMapEditor())
2874 currentMapEditor()->setLinkStyle(StylePolyParabel);
2877 void Main::formatSelectBackColor()
2879 if (currentMapEditor())
2880 currentMapEditor()->selectBackgroundColor();
2883 void Main::formatSelectLinkColor()
2885 if (currentMapEditor())
2886 currentMapEditor()->selectLinkColor();
2889 void Main::formatToggleLinkColorHint()
2891 currentMapEditor()->toggleLinkColorHint();
2894 void Main::formatFrameNone()
2896 if (currentMapEditor())
2897 currentMapEditor()->setFrame(NoFrame);
2900 void Main::formatFrameRectangle()
2902 if (currentMapEditor())
2903 currentMapEditor()->setFrame(Rectangle);
2906 void Main::formatIncludeImagesVer()
2908 if (currentMapEditor())
2909 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2912 void Main::formatIncludeImagesHor()
2914 if (currentMapEditor())
2915 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2918 void Main::formatHideLinkUnselected()
2920 if (currentMapEditor())
2921 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2924 void Main::viewZoomReset()
2926 if (currentMapEditor())
2930 currentMapEditor()->setWorldMatrix( m );
2931 currentMapEditor()->setViewCenter();
2932 currentMapEditor()->adjustCanvasSize();
2936 void Main::viewZoomIn()
2938 if (currentMapEditor())
2940 QMatrix m = currentMapEditor()->worldMatrix();
2941 m.scale( 1.25, 1.25 );
2942 currentMapEditor()->setWorldMatrix( m );
2943 currentMapEditor()->setViewCenter();
2944 currentMapEditor()->adjustCanvasSize();
2948 void Main::viewZoomOut()
2950 if (currentMapEditor())
2952 QMatrix m = currentMapEditor()->worldMatrix();
2953 m.scale( 0.8, 0.8 );
2954 currentMapEditor()->setWorldMatrix( m );
2955 currentMapEditor()->setViewCenter();
2956 currentMapEditor()->adjustCanvasSize();
2960 void Main::modModeColor()
2964 void Main::modModeLink()
2968 bool Main::settingsPDF()
2970 // Default browser is set in constructor
2972 QString text = QInputDialog::getText(
2973 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2974 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
2976 settings.setValue ("/mainwindow/readerPDF",text);
2981 bool Main::settingsURL()
2983 // Default browser is set in constructor
2985 QString text = QInputDialog::getText(
2986 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2987 settings.value("/mainwindow/readerURL").toString()
2990 settings.setValue ("/mainwindow/readerURL",text);
2994 void Main::settingsToggleDelKey()
2996 if (actionSettingsUseDelKey->isOn())
2998 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3001 actionEditDelete->setAccel (QKeySequence (""));
3005 void Main::windowToggleNoteEditor()
3007 if (textEditor->showWithMain() )
3008 windowHideNoteEditor();
3010 windowShowNoteEditor();
3013 void Main::windowToggleHistory()
3015 if (currentMapEditor())
3016 currentMapEditor()->toggleHistoryWindow();
3019 void Main::updateNoteFlag()
3021 if (currentMapEditor())
3022 currentMapEditor()->updateNoteFlag();
3025 void Main::windowShowNoteEditor()
3027 textEditor->setShowWithMain(true);
3029 actionViewToggleNoteEditor->setOn (true);
3032 void Main::windowHideNoteEditor()
3034 textEditor->setShowWithMain(false);
3036 actionViewToggleNoteEditor->setOn (false);
3039 void Main::windowNextEditor()
3041 if (tabWidget->currentPageIndex() < tabWidget->count())
3042 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3045 void Main::windowPreviousEditor()
3047 if (tabWidget->currentPageIndex() >0)
3048 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3051 void Main::standardFlagChanged()
3053 currentMapEditor()->toggleStandardFlag(sender()->name());
3056 void Main::testFunction()
3058 cout <<TB_standardFlags->isMovable()<<endl;
3059 cout <<TB_standardFlags->pos()<<endl;
3060 TB_standardFlags->move(QPoint (0,66));
3061 //currentMapEditor()->testFunction();
3064 void Main::helpDoc()
3067 #if defined(Q_OS_MACX)
3068 docpath="./vym.app/Contents/vym.pdf";
3070 // default path in SUSE LINUX
3071 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3074 if (!QFile (docpath).exists() )
3076 // relative path for easy testing in tarball
3077 docpath="doc/vym.pdf";
3078 if (!QFile (docpath).exists() )
3080 // relative path for testing while still writing vym.tex
3081 docpath="doc/tex/vym.pdf";
3082 if (!QFile (docpath).exists() )
3084 // Try yet another one for Knoppix
3085 docpath="/usr/share/doc/packages/vym/vym.pdf";
3086 if (!QFile (docpath).exists() )
3088 QMessageBox::critical(0,
3089 tr("Critcal error"),
3090 tr("Couldn't find the documentation\n"
3091 "vym.pdf in various places."));
3098 Process *pdfProc = new Process();
3099 pdfProc->clearArguments();
3100 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3101 pdfProc->addArgument( docpath);
3103 if ( !pdfProc->start() )
3106 QMessageBox::warning(0,
3108 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3109 tr("Please use Settings->")+tr("Set application to open PDF files"));
3116 void Main::helpAbout()
3119 ad.setName ("aboutwindow");
3120 ad.setMinimumSize(500,500);
3121 ad.resize (QSize (500,500));
3125 void Main::helpAboutQT()
3127 QMessageBox::aboutQt( this, "Qt Application Example" );