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"
33 #include "historywindow.h"
35 #include "mapeditor.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* actionEditOpenMultipleURLTabs;
67 extern QAction* actionEditURL;
68 extern QAction* actionEditHeading2URL;
69 extern QAction* actionEditBugzilla2URL;
70 extern QAction* actionEditFATE2URL;
71 extern QAction *actionEditOpenVymLink;
72 extern QAction *actionEditOpenMultipleVymLinks;
73 extern QAction *actionEditVymLink;
74 extern QAction *actionEditDeleteVymLink;
75 extern QAction *actionEditToggleHideExport;
76 extern QAction *actionEditMapInfo;
77 extern QAction *actionEditHeading;
78 extern QAction *actionEditDelete;
79 extern QAction *actionEditAddBranch;
80 extern QAction *actionEditAddBranchHere;
81 extern QAction *actionEditAddBranchAbove;
82 extern QAction *actionEditAddBranchBelow;
83 extern QAction *actionEditRemoveBranchKeepChilds;
84 extern QAction *actionEditRemoveChilds;
85 extern QAction *actionEditImportAdd;
86 extern QAction *actionEditImportReplace;
87 extern QAction *actionEditSaveBranch;
88 extern QAction *actionEditSelectFirst;
89 extern QAction *actionEditSelectLast;
90 extern QAction *actionEditLoadImage;
92 extern QAction* actionFormatColor;
93 extern QAction* actionFormatPickColor;
94 extern QAction* actionFormatColorBranch;
95 extern QAction* actionFormatColorSubtree;
96 extern QAction* actionFormatLinkColorHint;
97 extern QAction* actionFormatBackColor;
98 extern QAction* actionFormatLinkColor;
99 extern QAction *actionFormatIncludeImagesVer;
100 extern QAction *actionFormatIncludeImagesHor;
102 extern QActionGroup* actionGroupModModes;
103 extern QAction* actionModModeColor;
104 extern QAction* actionModModeLink;
105 extern QAction* actionModModeCopy;
107 extern QActionGroup *actionGroupFormatFrameTypes;
108 extern QAction *actionFormatFrameNone;
109 extern QAction *actionFormatFrameRectangle;
111 extern QActionGroup *actionGroupFormatLinkStyles;
112 extern QAction *actionFormatLinkStyleLine;
113 extern QAction *actionFormatLinkStyleParabel;
114 extern QAction *actionFormatLinkStylePolyLine;
115 extern QAction *actionFormatLinkStylePolyParabel;
116 extern QAction *actionFormatHideLinkUnselected;
118 extern QAction *actionViewToggleNoteEditor;
119 extern QAction *actionViewToggleHistoryWindow;
121 extern QAction* actionSettingsAutoedit;
122 extern QAction* actionSettingsAutoselectHeading;
123 extern QAction* actionSettingsAutoselectHeading;
124 extern QAction* actionSettingsAutoselectText;
125 extern QAction* actionSettingsUseDelKey;
126 extern QAction* actionSettingsUseFlagGroups;
127 extern QAction* actionSettingsUseHideExport;
129 extern QMenu* branchContextMenu;
130 extern QMenu* branchAddContextMenu;
131 extern QMenu* branchRemoveContextMenu;
132 extern QMenu* branchLinksContextMenu;
133 extern QMenu* branchXLinksContextMenuEdit;
134 extern QMenu* branchXLinksContextMenuFollow;
135 extern QMenu* floatimageContextMenu;
136 extern QMenu* canvasContextMenu;
137 extern QMenu* fileLastMapsMenu;
138 extern QMenu* fileImportMenu;
139 extern QMenu* fileExportMenu;
142 extern Settings settings;
143 extern Options options;
144 extern ImageIO imageIO;
146 extern QDir vymBaseDir;
147 extern QDir lastImageDir;
148 extern QDir lastFileDir;
149 extern QString iconPath;
150 extern QString flagsPath;
152 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
153 QMainWindow(parent,name,f)
157 setCaption ("VYM - View Your Mind");
159 // Load window settings
160 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
161 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
164 // Create unique temporary directory
166 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
169 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
173 // Create direcctory for clipboard
174 clipboardDir=tmpVymDir+"/clipboard";
175 QDir d(clipboardDir);
176 d.mkdir (clipboardDir,true);
177 makeSubDirs (clipboardDir);
182 // FIXME not used currently
183 // Set random seed (random used for object IDs)
184 // QTime t = QTime::currentTime(); // set random seed
185 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
188 // Initialize some settings, which are platform dependant
191 // application to open URLs
192 p="/mainwindow/readerURL";
193 #if defined(Q_OS_LINUX)
194 s=settings.value (p,"konqueror").toString();
196 #if defined(Q_OS_MACX)
197 s=settings.value (p,"/usr/bin/open").toString();
199 s=settings.value (p,"mozilla");
202 settings.setValue( p,s);
204 // application to open PDFs
205 p="/mainwindow/readerPDF";
206 #if defined(Q_OS_LINUX)
207 s=settings.value (p,"acroread").toString();
209 #if defined(Q_OS_MACX)
210 s=settings.value (p,"/usr/bin/open").toString();
212 s=settings.value (p,"acroread").toString();
215 settings.setValue( p,s);
220 // Create tab widget which holds the maps
221 tabWidget= new QTabWidget (this);
222 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
223 this, SLOT( editorChanged( QWidget * ) ) );
225 lineedit=new QLineEdit (this);
228 setCentralWidget(tabWidget);
232 setupFormatActions();
236 setupSettingsActions();
238 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
243 restoreState (settings.value("/mainwindow/state",0).toByteArray());
245 // Initialize Find window
246 findWindow=new FindWindow(NULL);
247 findWindow->move (x(),y()+70);
248 connect (findWindow, SIGNAL( findButton(QString) ),
249 this, SLOT(editFind(QString) ) );
250 connect (findWindow, SIGNAL( somethingChanged() ),
251 this, SLOT(editFindChanged() ) );
253 // Connect TextEditor, so that we can update flags if text changes
254 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
262 settings.setValue ( "/mainwindow/geometry/size", size() );
263 settings.setValue ( "/mainwindow/geometry/pos", pos() );
265 settings.setValue ("/mainwindow/state",saveState(0));
267 settings.setValue( "/version/version", __VYM_VERSION );
268 settings.setValue( "/version/builddate", __BUILD_DATE );
270 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoselectHeading->isOn() );
271 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoselectText->isOn() );
272 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoedit->isOn() );
273 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
274 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
275 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
278 int maps=lastMaps.count();
279 settings.setValue( "/lastMaps/number",maps );
280 for (int i=1;i<=maps;i++)
282 s=QString("/lastMaps/map-%1").arg(i);
283 if (!s.isEmpty() && i<=maxLastMaps)
284 settings.setValue (s, lastMaps.at(i-1));
288 // To make the texteditor save its settings, call the destructor
291 // Remove temporary directory
292 removeDir (QDir(tmpVymDir));
295 void Main::loadCmdLine()
297 /* TODO draw some kind of splashscreen while loading...
303 QStringList flist=options.getFileList();
304 QStringList::Iterator it=flist.begin();
306 while (it !=flist.end() )
308 fileLoad (*it, NewMap);
314 void Main::statusMessage(const QString &s)
316 statusBar()->message (s);
319 void Main::closeEvent (QCloseEvent* )
325 void Main::setupFileActions()
327 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
328 QToolBar *tb = addToolBar( tr ("&Map") );
329 tb->setObjectName ("mapTB");
332 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
333 a->setStatusTip ( tr( "New map","File menu" ) );
334 a->setShortcut ( Qt::CTRL + Qt::Key_N );
336 fileMenu->addAction (a);
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
339 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
340 a->setStatusTip (tr( "Open","File menu" ) );
341 a->setShortcut ( Qt::CTRL + Qt::Key_O );
343 fileMenu->addAction (a);
344 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
346 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
347 fileMenu->addSeparator();
349 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
350 a->setStatusTip ( tr( "Save" ));
351 a->setShortcut (Qt::CTRL + Qt::Key_S );
353 fileMenu->addAction (a);
354 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
357 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
358 a->setStatusTip (tr( "Save &As" ) );
359 fileMenu->addAction (a);
360 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
362 fileMenu->addSeparator();
364 fileImportMenu = fileMenu->addMenu (tr("Import"));
366 a = new QAction(tr("KDE Bookmarks"), this);
367 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
368 a->addTo (fileImportMenu);
369 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
371 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
373 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
374 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
375 a->addTo (fileImportMenu);
376 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
379 a = new QAction("Mind Manager...",this);
380 a->setStatusTip ( tr( "Import")+" Mind Manager" );
381 fileImportMenu->addAction (a);
382 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
384 a = new QAction( tr( "Import Dir"+QString("...") ), this);
385 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
386 fileImportMenu->addAction (a);
387 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
389 fileExportMenu = fileMenu->addMenu (tr("Export"));
391 a = new QAction( tr("Image")+QString("..."), this);
392 a->setStatusTip( tr( "Export map as image" ));
393 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
394 fileExportMenu->addAction (a);
396 a = new QAction( "Open Office"+QString("..."), this);
397 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
398 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
399 fileExportMenu->addAction (a);
401 a = new QAction( "Webpage (XHTML)...",this );
402 a->setShortcut (Qt::ALT + Qt::Key_X);
403 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
404 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
405 fileExportMenu->addAction (a);
407 a = new QAction( "Text (ASCII)...", this);
408 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
409 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
410 fileExportMenu->addAction (a);
412 a = new QAction( tr("KDE Bookmarks"), this);
413 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
414 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
415 fileExportMenu->addAction (a);
417 a = new QAction( "Taskjuggler...", this );
418 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
419 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
420 fileExportMenu->addAction (a);
422 a = new QAction( "LaTeX...", this);
423 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
424 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
425 fileExportMenu->addAction (a);
427 a = new QAction( "XML..." , this );
428 a->setStatusTip (tr( "Export as")+" XML");
429 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
430 fileExportMenu->addAction (a);
432 fileMenu->addSeparator();
434 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
435 a->setStatusTip ( tr( "Print" ) );
436 a->setShortcut (Qt::CTRL + Qt::Key_P );
438 fileMenu->addAction (a);
439 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
442 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
443 a->setStatusTip (tr( "Close Map" ) );
444 a->setShortcut (Qt::ALT + Qt::Key_C );
445 fileMenu->addAction (a);
446 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
448 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
449 a->setStatusTip ( tr( "Exit")+" "+__VYM );
450 a->setShortcut (Qt::CTRL + Qt::Key_Q );
451 fileMenu->addAction (a);
452 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
457 void Main::setupEditActions()
459 QToolBar *tb = addToolBar( tr ("&Actions") );
460 tb->setLabel( "Edit Actions" );
461 tb->setObjectName ("actionsTB");
462 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
466 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
467 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
468 a->setStatusTip (tr( "Undo" ) );
469 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
470 a->setEnabled (false);
472 editMenu->addAction (a);
475 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
476 a->setStatusTip (tr( "Redo" ));
477 a->setShortcut (Qt::CTRL + Qt::Key_Y );
479 editMenu->addAction (a);
480 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
483 editMenu->addSeparator();
484 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
485 a->setStatusTip ( tr( "Copy" ) );
486 a->setShortcut (Qt::CTRL + Qt::Key_C );
487 a->setEnabled (false);
489 editMenu->addAction (a);
490 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
493 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
494 a->setStatusTip ( tr( "Cut" ) );
495 a->setShortcut (Qt::CTRL + Qt::Key_X );
496 a->setEnabled (false);
498 editMenu->addAction (a);
500 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
502 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
503 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
504 a->setStatusTip ( tr( "Paste" ) );
505 a->setShortcut ( Qt::CTRL + Qt::Key_V );
506 a->setEnabled (false);
508 editMenu->addAction (a);
511 // Shortcuts to modify heading:
512 a = new QAction(tr( "Edit heading" ),this);
513 a->setStatusTip ( tr( "edit Heading" ));
514 a->setShortcut ( Qt::Key_Enter);
515 // a->setShortcutContext (Qt::WindowShortcut);
517 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
518 actionListBranches.append(a);
519 a = new QAction( tr( "Edit heading" ), this);
520 a->setStatusTip (tr( "edit Heading" ));
521 a->setShortcut (Qt::Key_Return );
522 //a->setShortcutContext (Qt::WindowShortcut);
524 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
525 actionListBranches.append(a);
526 editMenu->addAction (a);
528 a = new QAction( tr( "Edit heading" ), this);
529 a->setStatusTip (tr( "edit Heading" ));
530 a->setShortcut ( Qt::Key_F2 );
531 a->setShortcutContext (Qt::WindowShortcut);
533 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
534 actionListBranches.append(a);
536 // Shortcut to delete selection
537 a = new QAction( tr( "Delete Selection" ),this);
538 a->setStatusTip (tr( "Delete Selection" ));
539 a->setShortcut ( Qt::Key_Delete);
540 a->setShortcutContext (Qt::WindowShortcut);
542 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
545 // Shortcut to add branch
546 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
547 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
548 alt->setShortcut (Qt::Key_A);
549 alt->setShortcutContext (Qt::WindowShortcut);
551 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
552 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
553 a->setStatusTip ( tr( "Add a branch as child of selection" ));
554 a->setShortcut (Qt::Key_Insert);
555 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
556 actionListBranches.append(a);
557 #if defined (Q_OS_MACX)
558 // In OSX show different shortcut in menues, the keys work indepently always
559 actionEditAddBranch=alt;
561 actionEditAddBranch=a;
563 editMenu->addAction (actionEditAddBranch);
564 tb->addAction (actionEditAddBranch);
567 // Add branch by inserting it at selection
568 a = new QAction(tr( "Add branch (insert)" ), this);
569 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
570 a->setShortcut (Qt::ALT + Qt::Key_Insert );
571 a->setShortcutContext (Qt::WindowShortcut);
573 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
574 a->setEnabled (false);
575 actionListBranches.append(a);
576 actionEditAddBranchHere=a;
577 a = new QAction(tr( "Add branch (insert)" ),this);
578 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
579 a->setShortcut ( Qt::ALT + Qt::Key_A );
580 a->setShortcutContext (Qt::WindowShortcut);
582 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
583 actionListBranches.append(a);
586 a = new QAction(tr( "Add branch above" ), this);
587 a->setStatusTip ( tr( "Add a branch above selection" ));
588 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
589 a->setShortcutContext (Qt::WindowShortcut);
591 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
592 a->setEnabled (false);
593 actionListBranches.append(a);
594 actionEditAddBranchAbove=a;
595 a = new QAction(tr( "Add branch above" ), this);
596 a->setStatusTip ( tr( "Add a branch above selection" ));
597 a->setShortcut (Qt::SHIFT+Qt::Key_A );
598 a->setShortcutContext (Qt::WindowShortcut);
600 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
601 actionListBranches.append(a);
604 a = new QAction(tr( "Add branch below" ), this);
605 a->setStatusTip ( tr( "Add a branch below selection" ));
606 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
607 a->setShortcutContext (Qt::WindowShortcut);
609 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
610 a->setEnabled (false);
611 actionListBranches.append(a);
612 actionEditAddBranchBelow=a;
613 a = new QAction(tr( "Add branch below" ), this);
614 a->setStatusTip ( tr( "Add a branch below selection" ));
615 a->setShortcut (Qt::CTRL +Qt::Key_A );
616 a->setShortcutContext (Qt::WindowShortcut);
618 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
619 actionListBranches.append(a);
621 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
622 a->setStatusTip ( tr( "Move branch up" ) );
623 a->setShortcut (Qt::Key_PageUp );
624 a->setEnabled (false);
626 editMenu->addAction (a);
627 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
630 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
631 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
632 a->setStatusTip (tr( "Move branch down" ) );
633 a->setShortcut ( Qt::Key_PageDown );
634 a->setEnabled (false);
636 editMenu->addAction (a);
637 actionEditMoveDown=a;
640 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
641 a->setShortcut ( Qt::Key_ScrollLock );
642 a->setStatusTip (tr( "Scroll branch" ) );
643 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
645 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
646 alt->setShortcut ( Qt::Key_S );
647 alt->setStatusTip (tr( "Scroll branch" ));
648 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
649 #if defined(Q_OS_MACX)
650 actionEditToggleScroll=alt;
652 actionEditToggleScroll=a;
654 actionEditToggleScroll->setEnabled (false);
655 actionEditToggleScroll->setToggleAction(true);
656 tb->addAction (actionEditToggleScroll);
657 editMenu->addAction ( actionEditToggleScroll);
658 editMenu->addAction (actionEditToggleScroll);
661 actionListBranches.append(actionEditToggleScroll);
663 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
664 a->setStatusTip (tr( "Unscroll all" ));
665 editMenu->addAction (a);
666 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
668 editMenu->addSeparator();
670 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
671 a->setStatusTip (tr( "Find" ) );
672 a->setShortcut (Qt::CTRL + Qt::Key_F );
673 editMenu->addAction (a);
674 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
676 editMenu->addSeparator();
678 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
679 a->setShortcut (Qt::CTRL + Qt::Key_U );
680 a->setShortcut (tr( "Open URL" ));
683 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
686 a = new QAction( tr( "Open URL in new tab" ), this);
687 a->setStatusTip (tr( "Open URL in new tab" ));
688 a->setShortcut (Qt::CTRL+Qt::Key_U );
690 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
691 actionEditOpenURLTab=a;
693 a = new QAction( tr( "Open all URLs in subtree" ), this);
694 a->setStatusTip (tr( "Open all URLs in subtree" ));
696 actionListBranches.append(a);
697 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
698 actionEditOpenMultipleURLTabs=a;
700 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
701 a->setStatusTip ( tr( "Edit URL" ) );
702 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
703 //a->setShortcut ( Qt::Key_U );
704 a->setShortcutContext (Qt::WindowShortcut);
705 actionListBranches.append(a);
707 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
710 a = new QAction( tr( "Use heading for URL" ), this);
711 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
712 a->setEnabled (false);
713 actionListBranches.append(a);
714 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
715 actionEditHeading2URL=a;
717 a = new QAction(tr( "Create URL to Bugzilla" ), this);
718 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
719 a->setEnabled (false);
720 actionListBranches.append(a);
721 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
722 actionEditBugzilla2URL=a;
724 a = new QAction(tr( "Create URL to FATE" ), this);
725 a->setStatusTip ( tr( "Create URL to FATE" ));
726 a->setEnabled (false);
727 actionListBranches.append(a);
728 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
729 actionEditFATE2URL=a;
731 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this);
732 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
734 a->setEnabled (false);
735 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
736 actionEditOpenVymLink=a;
738 a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this);
739 a->setStatusTip ( tr( "Open all vym links in subtree" ));
740 a->setEnabled (false);
741 actionListBranches.append(a);
742 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
743 actionEditOpenMultipleVymLinks=a;
746 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
747 a->setEnabled (false);
748 a->setStatusTip ( tr( "Edit link to another vym map" ));
749 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
750 actionListBranches.append(a);
753 a = new QAction(tr( "Delete vym link" ),this);
754 a->setStatusTip ( tr( "Delete link to another vym map" ));
755 a->setEnabled (false);
756 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
757 actionEditDeleteVymLink=a;
759 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
760 a->setStatusTip ( tr( "Hide object in exports" ) );
761 a->setShortcut (Qt::Key_H );
762 a->setToggleAction(true);
764 a->setEnabled (false);
765 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
766 actionEditToggleHideExport=a;
768 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
769 a->setStatusTip ( tr( "Edit Map Info" ));
770 a->setEnabled (true);
771 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
774 editMenu->addSeparator();
776 // Import at selection (adding to selection)
777 a = new QAction( tr( "Add map (insert)" ),this);
778 a->setStatusTip (tr( "Add map at selection" ));
779 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
780 a->setEnabled (false);
781 actionListBranches.append(a);
782 actionEditImportAdd=a;
784 // Import at selection (replacing selection)
785 a = new QAction( tr( "Add map (replace)" ), this);
786 a->setStatusTip (tr( "Replace selection with map" ));
787 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
788 a->setEnabled (false);
789 actionListBranches.append(a);
790 actionEditImportReplace=a;
793 a = new QAction( tr( "Save selection" ), this);
794 a->setStatusTip (tr( "Save selection" ));
795 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
796 a->setEnabled (false);
797 actionListBranches.append(a);
798 actionEditSaveBranch=a;
800 // Only remove branch, not its childs
801 a = new QAction(tr( "Remove only branch " ), this);
802 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
803 a->setShortcut (Qt::ALT + Qt::Key_Delete );
804 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
805 a->setEnabled (false);
807 actionListBranches.append(a);
808 actionEditRemoveBranchKeepChilds=a;
810 // Only remove childs of a branch
811 a = new QAction( tr( "Remove childs" ), this);
812 a->setStatusTip (tr( "Remove childs of branch" ));
813 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
814 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
815 a->setEnabled (false);
816 actionListBranches.append(a);
817 actionEditRemoveChilds=a;
819 // Shortcuts for navigating with cursor:
820 a = new QAction(tr( "Select upper branch" ), this);
821 a->setStatusTip ( tr( "Select upper branch" ));
822 a->setShortcut (Qt::Key_Up );
823 a->setShortcutContext (Qt::WindowShortcut);
825 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
826 a = new QAction( tr( "Select lower branch" ),this);
827 a->setStatusTip (tr( "Select lower branch" ));
828 a->setShortcut ( Qt::Key_Down );
829 a->setShortcutContext (Qt::WindowShortcut);
831 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
832 a = new QAction(tr( "Select left branch" ), this);
833 a->setStatusTip ( tr( "Select left branch" ));
834 a->setShortcut (Qt::Key_Left );
835 a->setShortcutContext (Qt::WindowShortcut);
837 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
838 a = new QAction( tr( "Select child branch" ), this);
839 a->setStatusTip (tr( "Select right branch" ));
840 a->setShortcut (Qt::Key_Right);
841 a->setShortcutContext (Qt::WindowShortcut);
843 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
844 a = new QAction( tr( "Select first branch" ), this);
845 a->setStatusTip (tr( "Select first branch" ));
846 a->setShortcut (Qt::Key_Home );
847 a->setShortcutContext (Qt::WindowShortcut);
849 a->setEnabled (false);
850 editMenu->addAction (a);
851 actionListBranches.append(a);
852 actionEditSelectFirst=a;
853 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
854 a = new QAction( tr( "Select last branch" ),this);
855 a->setStatusTip (tr( "Select last branch" ));
856 a->setShortcut ( Qt::Key_End );
857 a->setShortcutContext (Qt::WindowShortcut);
859 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
860 a->setEnabled (false);
861 editMenu->addAction (a);
862 actionListBranches.append(a);
863 actionEditSelectLast=a;
865 a = new QAction( tr( "Add Image" )+QString("..."), this);
866 a->setStatusTip (tr( "Add Image" ));
867 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
868 actionEditLoadImage=a;
873 void Main::setupFormatActions()
875 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
877 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
878 tb->setObjectName ("formatTB");
881 pix.fill (Qt::black);
882 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
883 a->setStatusTip ( tr( "Set Color" ));
884 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
886 formatMenu->addAction (a);
888 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
889 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
890 a->setShortcut (Qt::CTRL + Qt::Key_K );
891 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
892 a->setEnabled (false);
894 formatMenu->addAction (a);
895 actionListBranches.append(a);
896 actionFormatPickColor=a;
898 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
899 a->setStatusTip ( tr( "Color branch" ) );
900 a->setShortcut (Qt::CTRL + Qt::Key_I);
901 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
902 a->setEnabled (false);
904 formatMenu->addAction (a);
905 actionListBranches.append(a);
906 actionFormatColorBranch=a;
908 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
909 a->setStatusTip ( tr( "Color Subtree" ));
910 a->setShortcut (Qt::CTRL + Qt::Key_T);
911 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
912 a->setEnabled (false);
913 formatMenu->addAction (a);
915 actionListBranches.append(a);
916 actionFormatColorSubtree=a;
918 formatMenu->addSeparator();
919 actionGroupFormatLinkStyles=new QActionGroup ( this);
920 actionGroupFormatLinkStyles->setExclusive (true);
921 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
922 a->setStatusTip (tr( "Line" ));
923 a->setToggleAction(true);
924 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
925 formatMenu->addAction (a);
926 actionFormatLinkStyleLine=a;
927 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
928 a->setStatusTip (tr( "Line" ));
929 a->setToggleAction(true);
930 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
931 formatMenu->addAction (a);
932 actionFormatLinkStyleParabel=a;
933 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
934 a->setStatusTip (tr( "PolyLine" ));
935 a->setToggleAction(true);
936 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
937 formatMenu->addAction (a);
938 actionFormatLinkStylePolyLine=a;
939 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
940 a->setStatusTip (tr( "PolyParabel" ) );
941 a->setToggleAction(true);
942 a->setChecked (true);
943 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
944 formatMenu->addAction (a);
945 actionFormatLinkStylePolyParabel=a;
947 actionGroupFormatFrameTypes=new QActionGroup ( this);
948 actionGroupFormatFrameTypes->setExclusive (true);
949 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
950 a->setStatusTip (tr("No Frame"));
951 a->setToggleAction(true);
952 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
953 actionFormatFrameNone=a;
954 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
955 a->setStatusTip (tr( "Rectangle" ));
956 a->setToggleAction(true);
957 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
958 actionFormatFrameRectangle=a;
960 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
961 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
962 a->setToggleAction(true);
963 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
964 actionFormatIncludeImagesVer=a;
966 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
967 a->setStatusTip ( tr ("Include left and right position of images into branch"));
968 a->setToggleAction(true);
969 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
970 actionFormatIncludeImagesHor=a;
972 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
973 a->setStatusTip (tr( "Hide link" ));
974 a->setToggleAction(true);
975 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
976 actionFormatHideLinkUnselected=a;
978 formatMenu->addSeparator();
979 a= new QAction( tr( "&Use color of heading for link" ), this);
980 a->setStatusTip (tr( "Use same color for links and headings" ));
981 a->setToggleAction(true);
982 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
983 formatMenu->addAction (a);
984 actionFormatLinkColorHint=a;
986 pix.fill (Qt::white);
987 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
988 a->setStatusTip (tr( "Set Link Color" ));
989 formatMenu->addAction (a);
990 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
991 actionFormatLinkColor=a;
993 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
994 a->setStatusTip (tr( "Set Background Color" ));
995 formatMenu->addAction (a);
996 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
997 actionFormatBackColor=a;
1001 void Main::setupViewActions()
1003 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
1004 tb->setLabel( "View Actions" );
1005 tb->setObjectName ("viewTB");
1006 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1009 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
1010 a->setStatusTip ( tr( "Zoom reset" ) );
1011 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1013 viewMenu->addAction (a);
1014 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1016 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
1017 a->setStatusTip (tr( "Zoom in" ));
1018 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1020 viewMenu->addAction (a);
1021 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1023 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
1024 a->setStatusTip (tr( "Zoom out" ));
1025 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1027 viewMenu->addAction (a);
1028 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1031 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1032 a->setStatusTip ( tr( "Show Note Editor" ));
1033 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1034 a->setToggleAction(true);
1035 if (textEditor->showWithMain())
1040 viewMenu->addAction (a);
1041 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1042 actionViewToggleNoteEditor=a;
1044 a = new QAction( tr( "Show history window" ),this );
1045 a->setStatusTip ( tr( "Show history window" ));
1046 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1047 a->setToggleAction(false);
1048 viewMenu->addAction (a);
1049 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1050 actionViewToggleHistoryWindow=a;
1052 a = new QAction(tr( "Next Window" ), this);
1053 a->setStatusTip ( tr( "&Next Window" ) );
1054 a->setShortcut (Qt::ALT + Qt::Key_N );
1055 viewMenu->addAction (a);
1056 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1058 a = new QAction (tr( "Previous Window" ), this );
1059 a->setStatusTip (tr( "&Previous Window" ));
1060 a->setShortcut (Qt::ALT + Qt::Key_P );
1061 viewMenu->addAction (a);
1062 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1066 void Main::setupModeActions()
1068 //QPopupMenu *menu = new QPopupMenu( this );
1069 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1071 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1072 tb->setObjectName ("modesTB");
1074 actionGroupModModes=new QActionGroup ( this);
1075 actionGroupModModes->setExclusive (true);
1076 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1077 a->setShortcut (Qt::Key_J);
1078 a->setStatusTip ( tr( "Use modifier to color branches" ));
1079 a->setToggleAction(true);
1082 actionModModeColor=a;
1084 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1085 a->setShortcut( Qt::Key_K);
1086 a->setStatusTip( tr( "Use modifier to copy" ));
1087 a->setToggleAction(true);
1089 actionModModeCopy=a;
1091 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1092 a->setShortcut (Qt::Key_L);
1093 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1094 a->setToggleAction(true);
1096 actionModModeLink=a;
1100 void Main::setupFlagActions()
1102 // Create System Flags
1103 systemFlagsDefault = new FlagRowObj ();
1104 systemFlagsDefault->setVisibility (false);
1105 systemFlagsDefault->setName ("systemFlagsDef");
1107 FlagObj *fo = new FlagObj ();
1108 fo->load(QPixmap(flagsPath+"flag-note.png"));
1109 fo->setName("note");
1110 fo->setToolTip(tr("Note","Systemflag"));
1111 systemFlagsDefault->addFlag (fo); // makes deep copy
1113 fo->load(QPixmap(flagsPath+"flag-url.png"));
1115 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1116 systemFlagsDefault->addFlag (fo);
1118 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1119 fo->setName("vymLink");
1120 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1121 systemFlagsDefault->addFlag (fo);
1123 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1124 fo->setName("scrolledright");
1125 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1126 systemFlagsDefault->addFlag (fo);
1128 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1129 fo->setName("tmpUnscrolledright");
1130 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1131 systemFlagsDefault->addFlag (fo);
1133 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1134 fo->setName("hideInExport");
1135 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1136 systemFlagsDefault->addFlag (fo);
1138 // Create Standard Flags
1139 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1140 tb->setObjectName ("standardFlagTB");
1142 standardFlagsDefault = new FlagRowObj ();
1143 standardFlagsDefault->setVisibility (false);
1144 standardFlagsDefault->setName ("standardFlagsDef");
1145 standardFlagsDefault->setToolBar (tb);
1147 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1148 fo->setName ("exclamationmark");
1149 fo->setGroup("standard-mark");
1150 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1153 a->setCheckable(true);
1154 a->setObjectName(fo->getName());
1155 a->setToolTip(tr("Take care!","Standardflag"));
1156 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1157 standardFlagsDefault->addFlag (fo); // makes deep copy
1159 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1160 fo->setName("questionmark");
1161 fo->setGroup("standard-mark");
1162 a=new QAction (fo->getPixmap(),fo->getName(),this);
1165 a->setCheckable(true);
1166 a->setObjectName(fo->getName());
1167 a->setToolTip(tr("Really?","Standardflag"));
1168 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1169 standardFlagsDefault->addFlag (fo);
1171 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1172 fo->setName("hook-green");
1173 fo->setGroup("standard-hook");
1174 a=new QAction (fo->getPixmap(),fo->getName(),this);
1177 a->setCheckable(true);
1178 a->setObjectName(fo->getName());
1179 a->setToolTip(tr("ok!","Standardflag"));
1180 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1181 standardFlagsDefault->addFlag (fo);
1183 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1184 fo->setName("cross-red");
1185 fo->setGroup("standard-hook");
1186 a=new QAction (fo->getPixmap(),fo->getName(),this);
1189 a->setCheckable(true);
1190 a->setObjectName(fo->getName());
1191 a->setToolTip(tr("Not ok!","Standardflag"));
1192 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1193 standardFlagsDefault->addFlag (fo);
1195 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1196 fo->setName("stopsign");
1197 a=new QAction (fo->getPixmap(),fo->getName(),this);
1200 a->setCheckable(true);
1201 a->setObjectName(fo->getName());
1202 a->setToolTip(tr("This won't work!","Standardflag"));
1203 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1204 standardFlagsDefault->addFlag (fo);
1206 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1207 fo->setName("smiley-good");
1208 fo->setGroup("standard-smiley");
1209 a=new QAction (fo->getPixmap(),fo->getName(),this);
1212 a->setCheckable(true);
1213 a->setObjectName(fo->getName());
1214 a->setToolTip(tr("Good","Standardflag"));
1215 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1216 standardFlagsDefault->addFlag (fo);
1218 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1219 fo->setName("smiley-sad");
1220 fo->setGroup("standard-smiley");
1221 a=new QAction (fo->getPixmap(),fo->getName(),this);
1224 a->setCheckable(true);
1225 a->setObjectName(fo->getName());
1226 a->setToolTip(tr("Bad","Standardflag"));
1227 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1228 standardFlagsDefault->addFlag (fo);
1230 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1231 // Original omg.png (in KDE emoticons)
1232 fo->setName("smiley-omg");
1233 fo->setGroup("standard-smiley");
1234 a=new QAction (fo->getPixmap(),fo->getName(),this);
1237 a->setCheckable(true);
1238 a->setObjectName(fo->getName());
1239 a->setToolTip(tr("Oh no!","Standardflag"));
1240 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1241 standardFlagsDefault->addFlag (fo);
1243 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1244 fo->setName("clock");
1245 a=new QAction (fo->getPixmap(),fo->getName(),this);
1248 a->setCheckable(true);
1249 a->setObjectName(fo->getName());
1250 a->setToolTip(tr("Time critical","Standardflag"));
1251 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1252 standardFlagsDefault->addFlag (fo);
1254 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1255 fo->setName("phone");
1256 a=new QAction (fo->getPixmap(),fo->getName(),this);
1259 a->setCheckable(true);
1260 a->setObjectName(fo->getName());
1261 a->setToolTip(tr("Call...","Standardflag"));
1262 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1263 standardFlagsDefault->addFlag (fo);
1265 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1266 fo->setName("lamp");
1267 a=new QAction (fo->getPixmap(),fo->getName(),this);
1270 a->setCheckable(true);
1271 a->setObjectName(fo->getName());
1272 a->setToolTip(tr("Idea!","Standardflag"));
1273 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1274 standardFlagsDefault->addFlag (fo);
1276 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1277 fo->setName("arrow-up");
1278 fo->setGroup("standard-arrow");
1279 a=new QAction (fo->getPixmap(),fo->getName(),this);
1282 a->setCheckable(true);
1283 a->setObjectName(fo->getName());
1284 a->setToolTip(tr("Important","Standardflag"));
1285 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1286 standardFlagsDefault->addFlag (fo);
1288 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1289 fo->setName("arrow-down");
1290 fo->setGroup("standard-arrow");
1291 a=new QAction (fo->getPixmap(),fo->getName(),this);
1294 a->setCheckable(true);
1295 a->setObjectName(fo->getName());
1296 a->setToolTip(tr("Unimportant","Standardflag"));
1297 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1298 standardFlagsDefault->addFlag (fo);
1300 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1301 fo->setName("2arrow-up");
1302 fo->setGroup("standard-arrow");
1303 a=new QAction (fo->getPixmap(),fo->getName(),this);
1306 a->setCheckable(true);
1307 a->setObjectName(fo->getName());
1308 a->setToolTip(tr("Very important!","Standardflag"));
1309 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1310 standardFlagsDefault->addFlag (fo);
1312 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1313 fo->setName("2arrow-down");
1314 fo->setGroup("standard-arrow");
1315 a=new QAction (fo->getPixmap(),fo->getName(),this);
1318 a->setCheckable(true);
1319 a->setObjectName(fo->getName());
1320 a->setToolTip(tr("Very unimportant!","Standardflag"));
1321 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1322 standardFlagsDefault->addFlag (fo);
1324 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1325 fo->setName("thumb-up");
1326 fo->setGroup("standard-thumb");
1327 a=new QAction (fo->getPixmap(),fo->getName(),this);
1330 a->setCheckable(true);
1331 a->setObjectName(fo->getName());
1332 a->setToolTip(tr("I like this","Standardflag"));
1333 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1334 standardFlagsDefault->addFlag (fo);
1336 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1337 fo->setName("thumb-down");
1338 fo->setGroup("standard-thumb");
1339 a=new QAction (fo->getPixmap(),fo->getName(),this);
1342 a->setCheckable(true);
1343 a->setObjectName(fo->getName());
1344 a->setToolTip(tr("I do not like this","Standardflag"));
1345 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1346 standardFlagsDefault->addFlag (fo);
1348 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1349 fo->setName("rose");
1350 a=new QAction (fo->getPixmap(),fo->getName(),this);
1353 a->setCheckable(true);
1354 a->setObjectName(fo->getName());
1355 a->setToolTip(tr("Rose","Standardflag"));
1356 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1357 standardFlagsDefault->addFlag (fo);
1359 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1360 fo->setName("heart");
1361 a=new QAction (fo->getPixmap(),fo->getName(),this);
1363 a->setCheckable(true);
1364 a->setObjectName(fo->getName());
1365 a->setToolTip(tr("I just love... ","Standardflag"));
1366 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1367 standardFlagsDefault->addFlag (fo);
1369 fo->load(QPixmap(flagsPath+"flag-present.png"));
1370 fo->setName("present");
1371 a=new QAction (fo->getPixmap(),fo->getName(),this);
1374 a->setCheckable(true);
1375 a->setObjectName(fo->getName());
1376 a->setToolTip(tr("Surprise!","Standardflag"));
1377 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1378 standardFlagsDefault->addFlag (fo);
1380 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1381 fo->setName("flash");
1382 a=new QAction (fo->getPixmap(),fo->getName(),this);
1385 a->setCheckable(true);
1386 a->setObjectName(fo->getName());
1387 a->setToolTip(tr("Dangerous","Standardflag"));
1388 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1389 standardFlagsDefault->addFlag (fo);
1391 fo->load(QPixmap(flagsPath+"flag-info.png"));
1392 // Original: xsldbg_output.png
1393 fo->setName("info");
1394 a=new QAction (fo->getPixmap(),fo->getName(),this);
1397 a->setCheckable(true);
1398 a->setObjectName(fo->getName());
1399 a->setToolTip(tr("Info","Standardflag"));
1400 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1401 standardFlagsDefault->addFlag (fo);
1403 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1404 // Original khelpcenter.png
1405 fo->setName("lifebelt");
1406 a=new QAction (fo->getPixmap(),fo->getName(),this);
1409 a->setCheckable(true);
1410 a->setObjectName(fo->getName());
1411 a->setToolTip(tr("This will help","Standardflag"));
1412 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1413 standardFlagsDefault->addFlag (fo);
1419 void Main::setupSettingsActions()
1421 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1425 a = new QAction( tr( "Set application to open pdf files"), this);
1426 a->setStatusTip ( tr( "Set application to open pdf files"));
1427 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1428 settingsMenu->addAction (a);
1430 a = new QAction( tr( "Set application to open external links"), this);
1431 a->setStatusTip( tr( "Set application to open external links"));
1432 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1433 settingsMenu->addAction (a);
1435 settingsMenu->addSeparator();
1436 a = new QAction( tr( "Edit branch after adding it" ), this );
1437 a->setStatusTip( tr( "Edit branch after adding it" ));
1438 a->setToggleAction(true);
1439 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1440 settingsMenu->addAction (a);
1441 actionSettingsAutoedit=a;
1443 a= new QAction( tr( "Select branch after adding it" ), this );
1444 a->setStatusTip( tr( "Select branch after adding it" ));
1445 a->setToggleAction(true);
1446 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1447 settingsMenu->addAction (a);
1448 actionSettingsAutoselectHeading=a;
1450 a= new QAction(tr( "Select existing heading" ), this);
1451 a->setStatusTip( tr( "Select heading before editing" ));
1452 a->setToggleAction(true);
1453 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1454 settingsMenu->addAction (a);
1455 actionSettingsAutoselectText=a;
1457 a= new QAction( tr( "Delete key" ), this);
1458 a->setStatusTip( tr( "Delete key for deleting branches" ));
1459 a->setToggleAction(true);
1460 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1461 settingsMenu->addAction (a);
1462 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1463 actionSettingsUseDelKey=a;
1465 a= new QAction( tr( "Exclusive flags" ), this);
1466 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1467 a->setToggleAction(true);
1468 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1469 settingsMenu->addAction (a);
1470 actionSettingsUseFlagGroups=a;
1472 a= new QAction( tr( "Use hide flags" ), this);
1473 a->setStatusTip( tr( "Use hide flag during exports " ));
1474 a->setToggleAction(true);
1475 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1476 settingsMenu->addAction (a);
1477 actionSettingsUseHideExport=a;
1481 void Main::setupTestActions()
1483 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1486 a = new QAction( tr( "test flag" ), this);
1487 a->setStatusTip( tr( "Call test function" ));
1488 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1489 testMenu->addAction (a);
1493 void Main::setupHelpActions()
1495 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1498 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1499 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1500 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1501 helpMenu->addAction (a);
1503 a = new QAction( tr( "About VYM" ), this);
1504 a->setStatusTip( tr( "About VYM")+" "__VYM);
1505 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1506 helpMenu->addAction (a);
1508 a = new QAction( tr( "About QT" ), this);
1509 a->setStatusTip( tr( "Information about QT toolkit" ));
1510 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1511 helpMenu->addAction (a);
1515 void Main::setupContextMenus()
1519 // Context Menu for branch or mapcenter
1520 branchContextMenu =new QMenu (this);
1523 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1524 branchAddContextMenu->addAction (actionEditPaste );
1525 branchAddContextMenu->addAction ( actionEditAddBranch );
1526 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1527 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1528 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1529 branchAddContextMenu->addSeparator();
1530 branchAddContextMenu->addAction ( actionEditLoadImage);
1531 branchAddContextMenu->addSeparator();
1532 branchAddContextMenu->addAction ( actionEditImportAdd );
1533 branchAddContextMenu->addAction ( actionEditImportReplace );
1536 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1537 branchRemoveContextMenu->addAction (actionEditCut);
1538 branchRemoveContextMenu->addAction ( actionEditDelete );
1539 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1540 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1543 actionEditSaveBranch->addTo( branchContextMenu );
1545 branchContextMenu->addSeparator();
1546 branchContextMenu->addAction ( actionFormatFrameNone );
1547 branchContextMenu->addAction ( actionFormatFrameRectangle);
1549 branchContextMenu->addSeparator();
1550 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1551 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1552 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1554 // Submenu for Links (URLs, vymLinks)
1555 branchLinksContextMenu =new QMenu (this);
1557 branchContextMenu->addSeparator();
1558 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));
1559 branchLinksContextMenu->addAction ( actionEditOpenURL );
1560 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1561 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1562 branchLinksContextMenu->addAction ( actionEditURL );
1563 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1564 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1565 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1567 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1569 branchLinksContextMenu->addSeparator();
1570 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1571 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1572 branchLinksContextMenu->addAction ( actionEditVymLink );
1573 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1576 // Context Menu for XLinks in a branch menu
1577 // This will be populated "on demand" in MapEditor::updateActions
1578 branchContextMenu->addSeparator();
1579 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1580 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1581 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1582 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1585 // Context menu for floatimage
1586 floatimageContextMenu =new QMenu (this);
1587 a= new QAction (tr ("Save image"),this);
1588 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1589 floatimageContextMenu->addAction (a);
1591 floatimageContextMenu->addSeparator();
1592 actionEditCopy->addTo( floatimageContextMenu );
1593 actionEditCut->addTo( floatimageContextMenu );
1595 floatimageContextMenu->addSeparator();
1596 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1599 // Context menu for canvas
1600 canvasContextMenu =new QMenu (this);
1601 actionEditMapInfo->addTo( canvasContextMenu );
1602 canvasContextMenu->insertSeparator();
1603 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1604 canvasContextMenu->insertSeparator();
1605 actionFormatLinkColorHint->addTo( canvasContextMenu );
1606 actionFormatLinkColor->addTo( canvasContextMenu );
1607 actionFormatBackColor->addTo( canvasContextMenu );
1609 // Menu for last opened files
1610 // Read settings initially
1612 int j=settings.readNumEntry( "/lastMaps/number",0);
1613 for (int i=1;i<=j;i++)
1615 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1616 if (!s.isEmpty() && j<=maxLastMaps)
1619 setupLastMapsMenu();
1620 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1623 void Main::setupLastMapsMenu()
1625 // Remove double entries
1626 QStringList::Iterator it=lastMaps.begin();
1627 QStringList::Iterator jt;
1628 while (it!=lastMaps.end() )
1632 while (jt!=lastMaps.end() )
1635 jt=lastMaps.remove(jt);
1642 // Limit length of list to maxLastMaps
1643 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1645 // build Menu from lastMaps string list
1646 fileLastMapsMenu->clear();
1647 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1648 fileLastMapsMenu->addAction (*it );
1651 void Main::hideEvent (QHideEvent * )
1653 if (!textEditor->isMinimized() ) textEditor->hide();
1656 void Main::showEvent (QShowEvent * )
1658 if (textEditor->showWithMain()) textEditor->showNormal();
1661 bool Main::reallyWriteDirectory(const QString &dir)
1663 QStringList eList = QDir(dir).entryList();
1664 if (eList.first() ==".") eList.pop_front(); // remove "."
1665 if (eList.first() =="..") eList.pop_front(); // remove "."
1666 if (!eList.isEmpty())
1668 QMessageBox mb( __VYM,
1669 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1670 QMessageBox::Warning,
1672 QMessageBox::Cancel | QMessageBox::Default,
1673 QMessageBox::QMessageBox::NoButton );
1675 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1676 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1679 case QMessageBox::Yes:
1682 case QMessageBox::Cancel:
1690 QString Main::browseDirectory (const QString &caption)
1692 Q3FileDialog fd(this,caption);
1693 fd.setMode (Q3FileDialog::DirectoryOnly);
1694 fd.setCaption(__VYM " - "+caption);
1697 if ( fd.exec() == QDialog::Accepted )
1698 return fd.selectedFile();
1703 MapEditor* Main::currentMapEditor() const
1705 if ( tabWidget->currentPage() &&
1706 tabWidget->currentPage()->inherits( "MapEditor" ) )
1707 return (MapEditor*)tabWidget->currentPage();
1711 //TODO not used now, maybe use this for overview window later
1712 void Main::newView()
1714 // Open a new view... have it delete when closed.
1715 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1716 qApp->setMainWidget(m);
1718 qApp->setMainWidget(0);
1721 void Main::editorChanged(QWidget *)
1723 // Unselect all possibly selected objects
1724 // (Important to update note editor)
1727 for (i=0;i<=tabWidget->count() -1;i++)
1730 me=(MapEditor*)tabWidget->page(i);
1733 currentMapEditor()->reselect();
1735 // Update actions to in menus and toolbars according to editor
1736 currentMapEditor()->updateActions();
1739 void Main::fileNew()
1741 QString fn="unnamed";
1742 MapEditor* medit = new MapEditor ( NULL,true);
1743 tabWidget->addTab (medit,fn);
1744 tabWidget->showPage(medit);
1745 medit->viewport()->setFocus();
1746 // For the very first map we do not have flagrows yet...
1747 medit->select("mc:");
1750 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1752 ErrorCode err=success;
1754 // fn is usually the archive, mapfile the file after uncompressing
1757 // Make fn absolute (needed for unzip)
1758 fn=QDir (fn).absPath();
1764 // Check, if map is already loaded
1766 while (i<=tabWidget->count() -1)
1768 me=(MapEditor*)tabWidget->page(i);
1769 if (me->getFilePath() == fn)
1771 // Already there, ask for confirmation
1772 QMessageBox mb( __VYM,
1773 tr("The map %1\nis already opened."
1774 "Opening the same map in multiple editors may lead \n"
1775 "to confusion when finishing working with vym."
1776 "Do you want to").arg(fn),
1777 QMessageBox::Warning,
1778 QMessageBox::Yes | QMessageBox::Default,
1779 QMessageBox::Cancel | QMessageBox::Escape,
1780 QMessageBox::NoButton);
1781 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1782 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1785 case QMessageBox::Yes:
1787 i=tabWidget->count();
1789 case QMessageBox::Cancel:
1801 if ( !fn.isEmpty() )
1803 me = currentMapEditor();
1804 int tabIndex=tabWidget->currentPageIndex();
1805 // Check first, if mapeditor exists
1806 // If it is not default AND we want a new map,
1807 // create a new mapeditor in a new tab
1808 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1810 me= new MapEditor ( NULL,true);
1811 tabWidget->addTab (me,fn);
1812 tabIndex=tabWidget->indexOf (me);
1813 tabWidget->setCurrentPage (tabIndex);
1816 // Check, if file exists (important for creating new files
1817 // from command line
1818 if (!QFile(fn).exists() )
1820 QMessageBox mb( __VYM,
1821 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1822 QMessageBox::Question,
1824 QMessageBox::Cancel | QMessageBox::Default,
1825 QMessageBox::NoButton );
1827 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1828 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1831 case QMessageBox::Yes:
1833 currentMapEditor()->setFilePath(fn);
1834 tabWidget->setTabLabel (currentMapEditor(),
1835 currentMapEditor()->getFileName() );
1836 statusBar()->message( "Created " + fn , statusbarTime );
1839 case QMessageBox::Cancel:
1840 // don't create new map
1841 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1848 //tabWidget->currentPage() won't be NULL here, because of above...
1849 tabWidget->showPage(me);
1850 me->viewport()->setFocus();
1852 // Create temporary directory for packing
1854 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1857 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1858 tr("Couldn't create temporary directory before load\n"));
1862 // Try to unzip file
1863 err=unzipDir (tmpMapDir,fn);
1867 me->setZipped(false);
1870 me->setZipped(true);
1872 // Look for mapname.xml
1873 mapfile= fn.left(fn.findRev(".",-1,true));
1874 mapfile=mapfile.section( '/', -1 );
1875 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1876 if (!file.exists() )
1878 // mapname.xml does not exist, well,
1879 // maybe some renamed the mapname.vym file...
1880 // Try to find any .xml in the toplevel
1881 // directory of the .vym file
1882 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1883 if (flist.count()==1)
1885 // Only one entry, take this one
1886 mapfile=tmpMapDir + "/"+flist.first();
1889 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1890 *it=tmpMapDir + "/" + *it;
1891 // TODO Multiple entries, load all (but only the first one into this ME)
1892 //mainWindow->fileLoadFromTmp (flist);
1893 //returnCode=1; // Silently forget this attempt to load
1894 qWarning ("MainWindow::load (fn) multimap found...");
1897 if (flist.isEmpty() )
1899 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1900 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1903 } //file doesn't exist
1905 mapfile=file.name();
1910 // Save existing filename in case we import
1911 QString fn_org=me->getFilePath();
1913 // Finally load map into mapEditor
1914 me->setFilePath (mapfile,fn);
1915 err=me->load(mapfile,lmode);
1917 // Restore old (maybe empty) filepath, if this is an import
1919 me->setFilePath (fn_org);
1922 // Finally check for errors and go home
1925 if (lmode==NewMap) fileCloseMap();
1926 statusBar()->message( "Could not load " + fn, statusbarTime );
1931 me->setFilePath (fn);
1932 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1933 if (fn.left(9)!="/tmp/vym-")
1935 // Only append to lastMaps if not loaded from a tmpDir
1936 // e.g. imported bookmarks are in a tmpDir
1937 lastMaps.prepend(me->getFilePath() );
1938 setupLastMapsMenu();
1940 actionFilePrint->setEnabled (true);
1942 statusBar()->message( "Loaded " + fn, statusbarTime );
1946 removeDir (QDir(tmpMapDir));
1952 void Main::fileLoad(const LoadMode &lmode)
1954 QStringList filters;
1955 filters <<"XML (*.xml)"<<"VYM map (*.vym *.vyp)";
1956 QFileDialog *fd=new QFileDialog( this);
1957 fd->setDir (lastFileDir);
1958 fd->setFileMode (QFileDialog::ExistingFiles);
1959 fd->setFilters (filters);
1963 fd->setCaption(__VYM " - " +tr("Load vym map"));
1966 fd->setCaption(__VYM " - " +tr("Import: Add vym map to selection"));
1969 fd->setCaption(__VYM " - " +tr("Import: Replace selection with vym map"));
1975 if ( fd->exec() == QDialog::Accepted )
1977 lastFileDir=fd->directory().path();
1978 QStringList flist = fd->selectedFiles();
1979 QStringList::Iterator it = flist.begin();
1980 while( it != flist.end() )
1983 fileLoad(*it, lmode);
1990 void Main::fileLoad()
1995 void Main::fileLoadLast(QAction *a)
1997 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
2000 void Main::fileSave(const SaveMode &savemode)
2002 // tmp dir for zipping
2006 ErrorCode err=success;
2008 QString safeFilePath;
2010 bool saveZipped=currentMapEditor()->saveZipped();
2012 MapEditor * me=currentMapEditor();
2015 QString fn=me->getFilePath();
2016 // filename=unnamed, filepath="" in constructor...
2017 if ( !fn.isEmpty() )
2019 // We have a filepath, go on saving
2020 // First remove existing file, we
2021 // don't want to add to old zip archives
2025 QMessageBox::warning( 0, tr( "Save Error" ),
2026 fn+ tr("\ncould not be removed before saving"));
2028 // Look, if we should zip the data:
2031 QMessageBox mb( __VYM,
2032 tr("The map %1\ndid not use the compressed "
2033 "vym file format.\nWriting it uncompressed will also write images \n"
2034 "and flags and thus may overwrite files in the "
2035 "given directory\n\nDo you want to write the map").arg(fn),
2036 QMessageBox::Warning,
2037 QMessageBox::Yes | QMessageBox::Default,
2039 QMessageBox::Cancel | QMessageBox::Escape);
2040 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2041 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2042 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2045 case QMessageBox::Yes:
2046 // save compressed (default file format)
2049 case QMessageBox::No:
2050 // save uncompressed
2053 case QMessageBox::Cancel:
2062 // Create temporary directory for packing
2064 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2067 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2068 tr("Couldn't create temporary directory before save\n"));
2072 safeFilePath=me->getFilePath();
2073 me->setFilePath (tmpMapDir+"/"+
2074 me->getMapName()+ ".xml",
2076 me->save (savemode);
2077 me->setFilePath (safeFilePath);
2079 zipDir (tmpMapDir,fn);
2084 safeFilePath=me->getFilePath();
2085 me->setFilePath (fn, safeFilePath);
2086 me->save (savemode);
2087 me->setFilePath (safeFilePath);
2089 } // filepath available
2092 // We have no filepath yet,
2093 // call fileSaveAs() now, this will call fileSave()
2095 fileSaveAs(savemode);
2099 if (saveZipped && !tmpMapDir.isEmpty())
2101 removeDir (QDir(tmpMapDir));
2105 statusBar()->message(
2106 tr("Saved %1").arg(me->getFilePath()),
2108 lastMaps.prepend(me->getFilePath() );
2109 setupLastMapsMenu();
2111 statusBar()->message(
2112 tr("Couldn't save ").arg(me->getFilePath()),
2116 void Main::fileSave()
2118 fileSave (CompleteMap);
2121 void Main::fileSaveAs(const SaveMode& savemode)
2125 if (currentMapEditor())
2127 if (savemode==CompleteMap)
2128 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2130 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2131 if ( !fn.isEmpty() )
2133 // Check for existing file
2134 if (QFile (fn).exists())
2136 QMessageBox mb( __VYM,
2137 tr("The file %1\nexists already. Do you want to").arg(fn),
2138 QMessageBox::Warning,
2139 QMessageBox::Yes | QMessageBox::Default,
2140 QMessageBox::Cancel | QMessageBox::Escape,
2141 QMessageBox::NoButton);
2142 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2143 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2146 case QMessageBox::Yes:
2149 case QMessageBox::Cancel:
2156 // New file, add extension to filename, if missing
2157 // This is always .vym or .vyp, depending on savemode
2158 if (savemode==CompleteMap)
2160 if (!fn.contains (".vym") && !fn.contains (".xml"))
2164 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2173 currentMapEditor()->setFilePath(fn);
2177 if (savemode==CompleteMap)
2178 tabWidget->setTabLabel (currentMapEditor(),
2179 currentMapEditor()->getFileName() );
2185 void Main::fileSaveAs()
2187 fileSaveAs (CompleteMap);
2190 void Main::fileImportKDEBookmarks()
2192 ImportKDEBookmarks im;
2194 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2195 currentMapEditor()->setFilePath ("");
2198 void Main::fileImportFirefoxBookmarks()
2200 Q3FileDialog *fd=new Q3FileDialog( this);
2201 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2202 fd->setMode (Q3FileDialog::ExistingFiles);
2203 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2204 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2207 if ( fd->exec() == QDialog::Accepted )
2209 ImportFirefoxBookmarks im;
2210 QStringList flist = fd->selectedFiles();
2211 QStringList::Iterator it = flist.begin();
2212 while( it != flist.end() )
2215 if (im.transform() &&
2216 success==fileLoad (im.getTransformedFile(),NewMap) &&
2217 currentMapEditor() )
2218 currentMapEditor()->setFilePath ("");
2225 void Main::fileImportMM()
2229 Q3FileDialog *fd=new Q3FileDialog( this);
2230 fd->setDir (lastFileDir);
2231 fd->setMode (Q3FileDialog::ExistingFiles);
2232 fd->addFilter ("Mind Manager (*.mmap)");
2233 fd->setCaption(tr("Import")+" "+"Mind Manager");
2236 if ( fd->exec() == QDialog::Accepted )
2238 lastFileDir=fd->dirPath();
2239 QStringList flist = fd->selectedFiles();
2240 QStringList::Iterator it = flist.begin();
2241 while( it != flist.end() )
2244 if (im.transform() &&
2245 success==fileLoad (im.getTransformedFile(),NewMap) &&
2246 currentMapEditor() )
2247 currentMapEditor()->setFilePath ("");
2256 void Main::fileImportDir()
2258 if (currentMapEditor())
2259 currentMapEditor()->importDir();
2262 void Main::fileExportXML()
2264 if (currentMapEditor())
2266 QString dir=browseDirectory(tr("Export XML to directory"));
2267 if (dir !="" && reallyWriteDirectory(dir) )
2268 currentMapEditor()->exportXML(dir);
2273 void Main::fileExportXHTML()
2275 MapEditor *me=currentMapEditor();
2279 ExportXHTMLDialog dia(this);
2280 dia.setFilePath (me->getFilePath() );
2281 dia.setMapName (me->getMapName() );
2284 if (dia.exec()==QDialog::Accepted)
2286 QString dir=dia.getDir();
2287 // Check, if warnings should be used before overwriting
2288 // the output directory
2291 ok=reallyWriteDirectory(dir);
2297 me->exportXML (dia.getDir() );
2298 dia.doExport(me->getMapName() );
2299 if (dia.hasChanged())
2306 void Main::fileExportImage()
2308 MapEditor *me=currentMapEditor();
2312 QFileDialog *fd=new QFileDialog (this);
2313 fd->setCaption (tr("Export map as image"));
2314 fd->setFileMode(QFileDialog::AnyFile);
2315 fd->setFilters (imageIO.getFilters() );
2316 fd->setDirectory (lastImageDir);
2319 fl=fd->selectedFiles();
2320 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2321 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2326 void Main::fileExportASCII()
2328 MapEditor *me=currentMapEditor();
2332 ex.setMapCenter(me->getMapCenter());
2333 ex.addFilter ("TXT (*.txt)");
2334 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2335 if (ex.execDialog() )
2337 me->setExportMode(true);
2339 me->setExportMode(false);
2344 void Main::fileExportLaTeX()
2346 MapEditor *me=currentMapEditor();
2350 ex.setMapCenter(me->getMapCenter());
2351 ex.addFilter ("Tex (*.tex)");
2352 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2353 if (ex.execDialog() )
2355 me->setExportMode(true);
2357 me->setExportMode(false);
2362 void Main::fileExportKDEBookmarks()
2364 ExportKDEBookmarks ex;
2365 MapEditor *me=currentMapEditor();
2368 ex.setMapCenter (me->getMapCenter() );
2373 void Main::fileExportTaskjuggler()
2375 ExportTaskjuggler ex;
2376 MapEditor *me=currentMapEditor();
2379 ex.setMapCenter (me->getMapCenter() );
2380 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2381 ex.addFilter ("Taskjuggler (*.tjp)");
2382 if (ex.execDialog() )
2384 me->setExportMode(true);
2386 me->setExportMode(false);
2391 void Main::fileExportOOPresentation()
2393 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2394 // TODO add preview in dialog
2395 //ImagePreview *p =new ImagePreview (fd);
2396 //fd->setContentsPreviewEnabled( TRUE );
2397 //fd->setContentsPreview( p, p );
2398 //fd->setPreviewMode( QFileDialog::Contents );
2399 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2400 fd->setDir (QDir().current());
2401 if (fd->foundConfig())
2405 if ( fd->exec() == QDialog::Accepted )
2407 QString fn=fd->selectedFile();
2408 if (!fn.contains (".odp"))
2411 //lastImageDir=fn.left(fn.findRev ("/"));
2412 if (currentMapEditor())
2413 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2417 QMessageBox::warning(0,
2419 tr("Couldn't find configuration for export to Open Office\n"));
2423 void Main::fileCloseMap()
2425 if (currentMapEditor())
2427 if (currentMapEditor()->hasChanged())
2429 QMessageBox mb( __VYM,
2430 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2431 QMessageBox::Warning,
2432 QMessageBox::Yes | QMessageBox::Default,
2434 QMessageBox::Cancel | QMessageBox::Escape );
2435 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2436 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2439 case QMessageBox::Yes:
2441 fileSave(CompleteMap);
2443 case QMessageBox::No:
2444 // close without saving
2446 case QMessageBox::Cancel:
2451 currentMapEditor()->closeMap();
2452 tabWidget->removePage(currentMapEditor());
2453 if (tabWidget->count()==0)
2454 actionFilePrint->setEnabled (false);
2458 void Main::filePrint()
2460 if (currentMapEditor())
2461 currentMapEditor()->print();
2464 void Main::fileExitVYM()
2466 // Check if one or more editors have changed
2469 for (i=0;i<=tabWidget->count() -1;i++)
2472 me=(MapEditor*)tabWidget->page(i);
2474 // If something changed, ask what to do
2475 if (me->isUnsaved())
2477 tabWidget->setCurrentPage(i);
2478 QMessageBox mb( __VYM,
2479 tr("This map is not saved yet. Do you want to"),
2480 QMessageBox::Warning,
2481 QMessageBox::Yes | QMessageBox::Default,
2483 QMessageBox::Cancel | QMessageBox::Escape );
2484 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2485 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2488 mb.setActiveWindow();
2489 switch( mb.exec() ) {
2490 case QMessageBox::Yes:
2491 // save (the changed editors) and exit
2492 fileSave(CompleteMap);
2494 case QMessageBox::No:
2495 // exit without saving
2497 case QMessageBox::Cancel:
2498 // don't save and don't exit
2502 } // loop over all MEs
2506 void Main::editUndo()
2508 if (currentMapEditor())
2509 currentMapEditor()->undo();
2512 void Main::editRedo()
2514 if (currentMapEditor())
2515 currentMapEditor()->redo();
2518 void Main::editCopy()
2520 if (currentMapEditor())
2521 currentMapEditor()->copy();
2524 void Main::editPaste()
2526 if (currentMapEditor())
2527 currentMapEditor()->paste();
2530 void Main::editCut()
2532 if (currentMapEditor())
2533 currentMapEditor()->cut();
2536 void Main::editOpenFindWindow()
2538 findWindow->popup();
2539 findWindow->raise();
2540 findWindow->setActiveWindow();
2543 void Main::editFind(QString s)
2546 BranchObj *bo=currentMapEditor()->findText(s, cs);
2549 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2552 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2553 tr("No matches found for \"%1\"").arg(s));
2557 void Main::editFindChanged()
2558 { // Notify editor, to abort the current find process
2559 currentMapEditor()->findReset();
2562 void Main::openTabs(QStringList urls)
2564 if (!urls.isEmpty())
2568 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2570 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2572 QString u=urls.takeFirst();
2573 procBrowser = new QProcess( this );
2575 procBrowser->start(browser,args);
2576 if ( !procBrowser->waitForStarted())
2578 // try to set path to browser
2579 QMessageBox::warning(0,
2581 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2582 tr("Please use Settings->")+tr("Set application to open an URL"));
2587 if (browser.contains("konqueror"))
2589 for (int i=0; i<urls.size(); i++)
2592 // Try to open new tab in existing konqueror started previously by vym
2593 p=new QProcess (this);
2595 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2596 "konqueror-mainwindow#1"<<
2599 p->start ("dcop",args);
2600 if ( !p->waitForStarted() ) success=false;
2603 QMessageBox::warning(0,
2605 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2607 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2609 for (int i=0; i<urls.size(); i++)
2611 // Try to open new tab in firefox
2612 p=new QProcess (this);
2613 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2614 p->start (browser,args);
2615 if ( !p->waitForStarted() ) success=false;
2618 QMessageBox::warning(0,
2620 tr("Couldn't start %1 to open a new tab").arg(browser));
2623 QMessageBox::warning(0,
2625 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2629 void Main::editOpenURL()
2632 if (currentMapEditor())
2634 QString url=currentMapEditor()->getURL();
2636 if (url=="") return;
2637 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2638 procBrowser = new QProcess( this );
2640 procBrowser->start(browser,args);
2641 if ( !procBrowser->waitForStarted())
2643 // try to set path to browser
2644 QMessageBox::warning(0,
2646 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2647 tr("Please use Settings->")+tr("Set application to open an URL"));
2652 void Main::editOpenURLTab()
2654 if (currentMapEditor())
2657 urls.append(currentMapEditor()->getURL());
2661 void Main::editOpenMultipleURLTabs()
2663 if (currentMapEditor())
2666 urls=currentMapEditor()->getURLs();
2672 void Main::editURL()
2674 if (currentMapEditor())
2675 currentMapEditor()->editURL();
2678 void Main::editHeading2URL()
2680 if (currentMapEditor())
2681 currentMapEditor()->editHeading2URL();
2684 void Main::editBugzilla2URL()
2686 if (currentMapEditor())
2687 currentMapEditor()->editBugzilla2URL();
2690 void Main::editFATE2URL()
2692 if (currentMapEditor())
2693 currentMapEditor()->editFATE2URL();
2696 void Main::editHeading()
2698 if (lineedit->isVisible())
2700 if (currentMapEditor())
2702 MapEditor *me=currentMapEditor();
2703 QString oldSel=me->getSelectString();
2704 if (me->select (editSel))
2705 me->setHeading(lineedit->text());
2706 me->select (oldSel);
2708 lineedit->releaseKeyboard();
2713 if (currentMapEditor())
2717 QString s=currentMapEditor()->getHeading(ok,p);
2721 #if defined(Q_OS_MACX)
2722 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2723 QDialog *d =new QDialog(NULL);
2724 QLineEdit *le=new QLineEdit (d);
2725 d->setWindowFlags (Qt::FramelessWindowHint);
2726 d->setGeometry(p.x(),p.y(),200,25);
2727 le->resize (d->size());
2730 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2731 d->activateWindow();
2733 currentMapEditor()->setHeading (le->text());
2735 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2736 lineedit->setGeometry(p.x(),p.y(),200,25);
2737 lineedit->setText(s);
2738 lineedit->setCursorPosition(1);
2739 lineedit->selectAll();
2741 lineedit->grabKeyboard();
2742 lineedit->setFocus();
2744 editSel=currentMapEditor()->getSelectString();
2752 void Main::openVymLinks(const QStringList &vl)
2754 for (int j=0; j<vl.size(); j++)
2756 // compare path with already loaded maps
2760 for (i=0;i<=tabWidget->count() -1;i++)
2762 me=(MapEditor*)tabWidget->page(i);
2763 if (vl.at(j)==me->getFilePath() )
2772 if (!QFile(vl.at(j)).exists() )
2773 QMessageBox::critical( 0, tr( "Critical Error" ),
2774 tr("Couldn't open map %1").arg(vl.at(j)));
2777 fileLoad (vl.at(j), NewMap);
2778 tabWidget->setCurrentPage (tabWidget->count()-1);
2781 // Go to tab containing the map
2782 tabWidget->setCurrentPage (index);
2786 void Main::editOpenVymLink()
2788 if (currentMapEditor())
2791 vl.append(currentMapEditor()->getVymLink());
2796 void Main::editOpenMultipleVymLinks()
2798 QString currentVymLink;
2799 if (currentMapEditor())
2801 QStringList vl=currentMapEditor()->getVymLinks();
2806 void Main::editVymLink()
2808 if (currentMapEditor())
2809 currentMapEditor()->editVymLink();
2812 void Main::editDeleteVymLink()
2814 if (currentMapEditor())
2815 currentMapEditor()->deleteVymLink();
2818 void Main::editToggleHideExport()
2820 if (currentMapEditor())
2821 currentMapEditor()->toggleHideExport();
2824 void Main::editMapInfo()
2826 if (currentMapEditor())
2827 currentMapEditor()->editMapInfo();
2830 void Main::editMoveUp()
2832 if (currentMapEditor())
2833 currentMapEditor()->moveBranchUp();
2836 void Main::editMoveDown()
2838 if (currentMapEditor())
2839 currentMapEditor()->moveBranchDown();
2842 void Main::editToggleScroll()
2844 if (currentMapEditor())
2846 currentMapEditor()->toggleScroll();
2850 void Main::editUnScrollAll()
2852 if (currentMapEditor())
2854 currentMapEditor()->unScrollAll();
2858 void Main::editNewBranch()
2861 if (!lineedit->isVisible() && currentMapEditor())
2862 currentMapEditor()->addNewBranch(0);
2865 void Main::editNewBranchHere()
2867 if (currentMapEditor())
2868 currentMapEditor()->addNewBranchHere();
2871 void Main::editNewBranchAbove()
2873 if (currentMapEditor())
2874 currentMapEditor()->addNewBranch(-1);
2877 void Main::editNewBranchBelow()
2879 if (currentMapEditor())
2880 currentMapEditor()->addNewBranch(1);
2883 void Main::editImportAdd()
2885 fileLoad (ImportAdd);
2888 void Main::editImportReplace()
2890 fileLoad (ImportReplace);
2893 void Main::editSaveBranch()
2895 fileSaveAs (PartOfMap);
2898 void Main::editRemoveBranchKeepChilds()
2900 if (currentMapEditor())
2901 currentMapEditor()->removeBranchKeepChilds();
2904 void Main::editRemoveChilds()
2906 if (currentMapEditor())
2907 currentMapEditor()->removeChilds();
2910 void Main::editDeleteSelection()
2912 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2913 currentMapEditor()->deleteSelection();
2916 void Main::editUpperBranch()
2918 if (currentMapEditor())
2919 currentMapEditor()->selectUpperBranch();
2922 void Main::editLowerBranch()
2924 if (currentMapEditor())
2925 currentMapEditor()->selectLowerBranch();
2928 void Main::editLeftBranch()
2930 if (currentMapEditor())
2931 currentMapEditor()->selectLeftBranch();
2934 void Main::editRightBranch()
2936 if (currentMapEditor())
2937 currentMapEditor()->selectRightBranch();
2940 void Main::editFirstBranch()
2942 if (currentMapEditor())
2943 currentMapEditor()->selectFirstBranch();
2946 void Main::editLastBranch()
2948 if (currentMapEditor())
2949 currentMapEditor()->selectLastBranch();
2952 void Main::editLoadImage()
2954 if (currentMapEditor())
2955 currentMapEditor()->loadFloatImage();
2958 void Main::editSaveImage()
2960 if (currentMapEditor())
2961 currentMapEditor()->saveFloatImage();
2964 void Main::editFollowXLink(QAction *a)
2967 if (currentMapEditor())
2968 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2971 void Main::editEditXLink(QAction *a)
2973 if (currentMapEditor())
2974 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2977 void Main::formatSelectColor()
2979 if (currentMapEditor())
2981 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2982 if ( !col.isValid() ) return;
2983 currentMapEditor()->setColor( col );
2984 colorChanged( col );
2988 void Main::formatPickColor()
2990 if (currentMapEditor())
2991 colorChanged( currentMapEditor()->pickColor() );
2994 void Main::colorChanged(QColor c)
2996 QPixmap pix( 16, 16 );
2998 actionFormatColor->setIconSet( pix );
3001 void Main::formatColorItem()
3003 if (currentMapEditor())
3004 currentMapEditor()->colorItem();
3007 void Main::formatColorBranch()
3009 if (currentMapEditor())
3010 currentMapEditor()->colorBranch();
3013 void Main::formatLinkStyleLine()
3015 if (currentMapEditor())
3016 currentMapEditor()->setLinkStyle(StyleLine);
3019 void Main::formatLinkStyleParabel()
3021 if (currentMapEditor())
3022 currentMapEditor()->setLinkStyle(StyleParabel);
3025 void Main::formatLinkStylePolyLine()
3027 if (currentMapEditor())
3028 currentMapEditor()->setLinkStyle(StylePolyLine);
3031 void Main::formatLinkStylePolyParabel()
3033 if (currentMapEditor())
3034 currentMapEditor()->setLinkStyle(StylePolyParabel);
3037 void Main::formatSelectBackColor()
3039 if (currentMapEditor())
3040 currentMapEditor()->selectBackgroundColor();
3043 void Main::formatSelectLinkColor()
3045 if (currentMapEditor())
3046 currentMapEditor()->selectLinkColor();
3049 void Main::formatToggleLinkColorHint()
3051 currentMapEditor()->toggleLinkColorHint();
3054 void Main::formatFrameNone()
3056 if (currentMapEditor())
3057 currentMapEditor()->setFrame(NoFrame);
3060 void Main::formatFrameRectangle()
3062 if (currentMapEditor())
3063 currentMapEditor()->setFrame(Rectangle);
3066 void Main::formatIncludeImagesVer()
3068 if (currentMapEditor())
3069 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3072 void Main::formatIncludeImagesHor()
3074 if (currentMapEditor())
3075 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3078 void Main::formatHideLinkUnselected()
3080 if (currentMapEditor())
3081 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3084 void Main::viewZoomReset()
3086 if (currentMapEditor())
3090 currentMapEditor()->setWorldMatrix( m );
3091 currentMapEditor()->setViewCenter();
3092 currentMapEditor()->adjustCanvasSize();
3096 void Main::viewZoomIn()
3098 if (currentMapEditor())
3100 QMatrix m = currentMapEditor()->worldMatrix();
3101 m.scale( 1.25, 1.25 );
3102 currentMapEditor()->setWorldMatrix( m );
3103 currentMapEditor()->setViewCenter();
3104 currentMapEditor()->adjustCanvasSize();
3108 void Main::viewZoomOut()
3110 if (currentMapEditor())
3112 QMatrix m = currentMapEditor()->worldMatrix();
3113 m.scale( 0.8, 0.8 );
3114 currentMapEditor()->setWorldMatrix( m );
3115 currentMapEditor()->setViewCenter();
3116 currentMapEditor()->adjustCanvasSize();
3120 void Main::modModeColor()
3124 void Main::modModeLink()
3128 bool Main::settingsPDF()
3130 // Default browser is set in constructor
3132 QString text = QInputDialog::getText(
3133 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3134 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3136 settings.setValue ("/mainwindow/readerPDF",text);
3141 bool Main::settingsURL()
3143 // Default browser is set in constructor
3145 QString text = QInputDialog::getText(
3146 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3147 settings.value("/mainwindow/readerURL").toString()
3150 settings.setValue ("/mainwindow/readerURL",text);
3154 void Main::settingsToggleDelKey()
3156 if (actionSettingsUseDelKey->isOn())
3158 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3161 actionEditDelete->setAccel (QKeySequence (""));
3165 void Main::windowToggleNoteEditor()
3167 if (textEditor->showWithMain() )
3168 windowHideNoteEditor();
3170 windowShowNoteEditor();
3173 void Main::windowToggleHistory()
3175 if (currentMapEditor())
3176 currentMapEditor()->toggleHistoryWindow();
3179 void Main::updateNoteFlag()
3181 if (currentMapEditor())
3182 currentMapEditor()->updateNoteFlag();
3185 void Main::windowShowNoteEditor()
3187 textEditor->setShowWithMain(true);
3189 actionViewToggleNoteEditor->setOn (true);
3192 void Main::windowHideNoteEditor()
3194 textEditor->setShowWithMain(false);
3196 actionViewToggleNoteEditor->setOn (false);
3199 void Main::windowNextEditor()
3201 if (tabWidget->currentPageIndex() < tabWidget->count())
3202 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3205 void Main::windowPreviousEditor()
3207 if (tabWidget->currentPageIndex() >0)
3208 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3211 void Main::standardFlagChanged()
3213 currentMapEditor()->toggleStandardFlag(sender()->name());
3216 void Main::testFunction()
3220 //currentMapEditor()->testFunction();
3223 void Main::helpDoc()
3226 #if defined(Q_OS_MACX)
3227 docpath="./vym.app/Contents/vym.pdf";
3229 // default path in SUSE LINUX
3230 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3233 if (!QFile (docpath).exists() )
3235 // relative path for easy testing in tarball
3236 docpath="doc/vym.pdf";
3237 if (!QFile (docpath).exists() )
3239 // relative path for testing while still writing vym.tex
3240 docpath="doc/tex/vym.pdf";
3241 if (!QFile (docpath).exists() )
3243 // Try yet another one for Knoppix
3244 docpath="/usr/share/doc/packages/vym/vym.pdf";
3245 if (!QFile (docpath).exists() )
3247 QMessageBox::critical(0,
3248 tr("Critcal error"),
3249 tr("Couldn't find the documentation\n"
3250 "vym.pdf in various places."));
3257 Process *pdfProc = new Process();
3258 pdfProc->clearArguments();
3259 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3260 pdfProc->addArgument( docpath);
3262 if ( !pdfProc->start() )
3265 QMessageBox::warning(0,
3267 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3268 tr("Please use Settings->")+tr("Set application to open PDF files"));
3275 void Main::helpAbout()
3278 ad.setName ("aboutwindow");
3279 ad.setMinimumSize(500,500);
3280 ad.resize (QSize (500,500));
3284 void Main::helpAboutQT()
3286 QMessageBox::aboutQt( this, "Qt Application Example" );