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* 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() ) );
644 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
645 alt->setShortcut ( Qt::Key_S );
646 alt->setStatusTip (tr( "Scroll branch" ));
647 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
648 #if defined(Q_OS_MACX)
649 actionEditToggleScroll=alt;
651 actionEditToggleScroll=a;
653 actionEditToggleScroll->setEnabled (false);
654 actionEditToggleScroll->setToggleAction(true);
655 tb->addAction (actionEditToggleScroll);
656 editMenu->addAction ( actionEditToggleScroll);
657 editMenu->addAction (actionEditToggleScroll);
658 actionListBranches.append(actionEditToggleScroll);
660 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
661 a->setStatusTip (tr( "Unscroll all" ));
662 editMenu->addAction (a);
663 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
665 editMenu->addSeparator();
667 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
668 a->setStatusTip (tr( "Find" ) );
669 a->setShortcut (Qt::CTRL + Qt::Key_F );
670 editMenu->addAction (a);
671 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
673 editMenu->addSeparator();
675 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
676 a->setShortcut (Qt::CTRL + Qt::Key_U );
677 a->setShortcut (tr( "Open URL" ));
680 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
683 a = new QAction( tr( "Open URL in new tab" ), this);
684 a->setStatusTip (tr( "Open URL in new tab" ));
685 a->setShortcut (Qt::CTRL+Qt::Key_U );
687 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
688 actionEditOpenURLTab=a;
690 a = new QAction( tr( "Open all URLs in subtree" ), this);
691 a->setStatusTip (tr( "Open all URLs in subtree" ));
693 actionListBranches.append(a);
694 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
695 actionEditOpenMultipleURLTabs=a;
697 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
698 a->setStatusTip ( tr( "Edit URL" ) );
699 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
700 //a->setShortcut ( Qt::Key_U );
701 a->setShortcutContext (Qt::WindowShortcut);
702 actionListBranches.append(a);
704 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
707 a = new QAction( tr( "Use heading for URL" ), this);
708 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
709 a->setEnabled (false);
710 actionListBranches.append(a);
711 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
712 actionEditHeading2URL=a;
714 a = new QAction(tr( "Create URL to Bugzilla" ), this);
715 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
716 a->setEnabled (false);
717 actionListBranches.append(a);
718 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
719 actionEditBugzilla2URL=a;
721 a = new QAction(tr( "Create URL to FATE" ), this);
722 a->setStatusTip ( tr( "Create URL to FATE" ));
723 a->setEnabled (false);
724 actionListBranches.append(a);
725 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
726 actionEditFATE2URL=a;
728 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this);
729 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
731 a->setEnabled (false);
732 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
733 actionEditOpenVymLink=a;
735 a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this);
736 a->setStatusTip ( tr( "Open all vym links in subtree" ));
737 a->setEnabled (false);
738 actionListBranches.append(a);
739 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
740 actionEditOpenMultipleVymLinks=a;
743 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
744 a->setEnabled (false);
745 a->setStatusTip ( tr( "Edit link to another vym map" ));
746 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
747 actionListBranches.append(a);
750 a = new QAction(tr( "Delete vym link" ),this);
751 a->setStatusTip ( tr( "Delete link to another vym map" ));
752 a->setEnabled (false);
753 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
754 actionEditDeleteVymLink=a;
756 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
757 a->setStatusTip ( tr( "Hide object in exports" ) );
758 a->setShortcut (Qt::Key_H );
759 a->setToggleAction(true);
761 a->setEnabled (false);
762 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
763 actionEditToggleHideExport=a;
765 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
766 a->setStatusTip ( tr( "Edit Map Info" ));
767 a->setEnabled (true);
768 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
771 editMenu->addSeparator();
773 // Import at selection (adding to selection)
774 a = new QAction( tr( "Add map (insert)" ),this);
775 a->setStatusTip (tr( "Add map at selection" ));
776 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
777 a->setEnabled (false);
778 actionListBranches.append(a);
779 actionEditImportAdd=a;
781 // Import at selection (replacing selection)
782 a = new QAction( tr( "Add map (replace)" ), this);
783 a->setStatusTip (tr( "Replace selection with map" ));
784 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
785 a->setEnabled (false);
786 actionListBranches.append(a);
787 actionEditImportReplace=a;
790 a = new QAction( tr( "Save selection" ), this);
791 a->setStatusTip (tr( "Save selection" ));
792 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
793 a->setEnabled (false);
794 actionListBranches.append(a);
795 actionEditSaveBranch=a;
797 // Only remove branch, not its childs
798 a = new QAction(tr( "Remove only branch " ), this);
799 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
800 a->setShortcut (Qt::ALT + Qt::Key_Delete );
801 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
802 a->setEnabled (false);
803 actionListBranches.append(a);
804 actionEditRemoveBranchKeepChilds=a;
806 // Only remove childs of a branch
807 a = new QAction( tr( "Remove childs" ), this);
808 a->setStatusTip (tr( "Remove childs of branch" ));
809 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
810 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
811 a->setEnabled (false);
812 actionListBranches.append(a);
813 actionEditRemoveChilds=a;
815 // Shortcuts for navigating with cursor:
816 a = new QAction(tr( "Select upper branch" ), this);
817 a->setStatusTip ( tr( "Select upper branch" ));
818 a->setShortcut (Qt::Key_Up );
819 a->setShortcutContext (Qt::WindowShortcut);
821 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
822 a = new QAction( tr( "Select lower branch" ),this);
823 a->setStatusTip (tr( "Select lower branch" ));
824 a->setShortcut ( Qt::Key_Down );
825 a->setShortcutContext (Qt::WindowShortcut);
827 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
828 a = new QAction(tr( "Select left branch" ), this);
829 a->setStatusTip ( tr( "Select left branch" ));
830 a->setShortcut (Qt::Key_Left );
831 a->setShortcutContext (Qt::WindowShortcut);
833 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
834 a = new QAction( tr( "Select child branch" ), this);
835 a->setStatusTip (tr( "Select right branch" ));
836 a->setShortcut (Qt::Key_Right);
837 a->setShortcutContext (Qt::WindowShortcut);
839 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
840 a = new QAction( tr( "Select first branch" ), this);
841 a->setStatusTip (tr( "Select first branch" ));
842 a->setShortcut (Qt::Key_Home );
843 a->setShortcutContext (Qt::WindowShortcut);
845 a->setEnabled (false);
846 editMenu->addAction (a);
847 actionListBranches.append(a);
848 actionEditSelectFirst=a;
849 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
850 a = new QAction( tr( "Select last branch" ),this);
851 a->setStatusTip (tr( "Select last branch" ));
852 a->setShortcut ( Qt::Key_End );
853 a->setShortcutContext (Qt::WindowShortcut);
855 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
856 a->setEnabled (false);
857 editMenu->addAction (a);
858 actionListBranches.append(a);
859 actionEditSelectLast=a;
861 a = new QAction( tr( "Add Image" )+QString("..."), this);
862 a->setStatusTip (tr( "Add Image" ));
863 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
864 actionEditLoadImage=a;
869 void Main::setupFormatActions()
871 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
873 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
874 tb->setObjectName ("formatTB");
877 pix.fill (Qt::black);
878 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
879 a->setStatusTip ( tr( "Set Color" ));
880 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
882 formatMenu->addAction (a);
884 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
885 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
886 a->setShortcut (Qt::CTRL + Qt::Key_K );
887 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
888 a->setEnabled (false);
890 formatMenu->addAction (a);
891 actionListBranches.append(a);
892 actionFormatPickColor=a;
894 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
895 a->setStatusTip ( tr( "Color branch" ) );
896 a->setShortcut (Qt::CTRL + Qt::Key_I);
897 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
898 a->setEnabled (false);
900 formatMenu->addAction (a);
901 actionListBranches.append(a);
902 actionFormatColorBranch=a;
904 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
905 a->setStatusTip ( tr( "Color Subtree" ));
906 a->setShortcut (Qt::CTRL + Qt::Key_T);
907 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
908 a->setEnabled (false);
909 formatMenu->addAction (a);
911 actionListBranches.append(a);
912 actionFormatColorSubtree=a;
914 formatMenu->addSeparator();
915 actionGroupFormatLinkStyles=new QActionGroup ( this);
916 actionGroupFormatLinkStyles->setExclusive (true);
917 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
918 a->setStatusTip (tr( "Line" ));
919 a->setToggleAction(true);
920 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
921 formatMenu->addAction (a);
922 actionFormatLinkStyleLine=a;
923 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
924 a->setStatusTip (tr( "Line" ));
925 a->setToggleAction(true);
926 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
927 formatMenu->addAction (a);
928 actionFormatLinkStyleParabel=a;
929 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
930 a->setStatusTip (tr( "PolyLine" ));
931 a->setToggleAction(true);
932 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
933 formatMenu->addAction (a);
934 actionFormatLinkStylePolyLine=a;
935 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
936 a->setStatusTip (tr( "PolyParabel" ) );
937 a->setToggleAction(true);
938 a->setChecked (true);
939 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
940 formatMenu->addAction (a);
941 actionFormatLinkStylePolyParabel=a;
943 actionGroupFormatFrameTypes=new QActionGroup ( this);
944 actionGroupFormatFrameTypes->setExclusive (true);
945 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
946 a->setStatusTip (tr("No Frame"));
947 a->setToggleAction(true);
948 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
949 actionFormatFrameNone=a;
950 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
951 a->setStatusTip (tr( "Rectangle" ));
952 a->setToggleAction(true);
953 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
954 actionFormatFrameRectangle=a;
956 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
957 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
958 a->setToggleAction(true);
959 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
960 actionFormatIncludeImagesVer=a;
962 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
963 a->setStatusTip ( tr ("Include left and right position of images into branch"));
964 a->setToggleAction(true);
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
966 actionFormatIncludeImagesHor=a;
968 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
969 a->setStatusTip (tr( "Hide link" ));
970 a->setToggleAction(true);
971 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
972 actionFormatHideLinkUnselected=a;
974 formatMenu->addSeparator();
975 a= new QAction( tr( "&Use color of heading for link" ), this);
976 a->setStatusTip (tr( "Use same color for links and headings" ));
977 a->setToggleAction(true);
978 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
979 formatMenu->addAction (a);
980 actionFormatLinkColorHint=a;
982 pix.fill (Qt::white);
983 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
984 a->setStatusTip (tr( "Set Link Color" ));
985 formatMenu->addAction (a);
986 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
987 actionFormatLinkColor=a;
989 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
990 a->setStatusTip (tr( "Set Background Color" ));
991 formatMenu->addAction (a);
992 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
993 actionFormatBackColor=a;
997 void Main::setupViewActions()
999 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
1000 tb->setLabel( "View Actions" );
1001 tb->setObjectName ("viewTB");
1002 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1005 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
1006 a->setStatusTip ( tr( "Zoom reset" ) );
1007 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1009 viewMenu->addAction (a);
1010 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1012 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
1013 a->setStatusTip (tr( "Zoom in" ));
1014 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1016 viewMenu->addAction (a);
1017 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1019 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
1020 a->setStatusTip (tr( "Zoom out" ));
1021 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1023 viewMenu->addAction (a);
1024 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1027 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1028 a->setStatusTip ( tr( "Show Note Editor" ));
1029 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1030 a->setToggleAction(true);
1031 if (textEditor->showWithMain())
1036 viewMenu->addAction (a);
1037 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1038 actionViewToggleNoteEditor=a;
1040 a = new QAction( tr( "Show history window" ),this );
1041 a->setStatusTip ( tr( "Show history window" ));
1042 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1043 a->setToggleAction(false);
1044 viewMenu->addAction (a);
1045 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1046 actionViewToggleHistoryWindow=a;
1048 a = new QAction(tr( "Next Window" ), this);
1049 a->setStatusTip ( tr( "&Next Window" ) );
1050 a->setShortcut (Qt::ALT + Qt::Key_N );
1051 viewMenu->addAction (a);
1052 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1054 a = new QAction (tr( "Previous Window" ), this );
1055 a->setStatusTip (tr( "&Previous Window" ));
1056 a->setShortcut (Qt::ALT + Qt::Key_P );
1057 viewMenu->addAction (a);
1058 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1062 void Main::setupModeActions()
1064 //QPopupMenu *menu = new QPopupMenu( this );
1065 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1067 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1068 tb->setObjectName ("modesTB");
1070 actionGroupModModes=new QActionGroup ( this);
1071 actionGroupModModes->setExclusive (true);
1072 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1073 a->setShortcut (Qt::Key_J);
1074 a->setStatusTip ( tr( "Use modifier to color branches" ));
1075 a->setToggleAction(true);
1078 actionModModeColor=a;
1080 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1081 a->setShortcut( Qt::Key_K);
1082 a->setStatusTip( tr( "Use modifier to copy" ));
1083 a->setToggleAction(true);
1085 actionModModeCopy=a;
1087 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1088 a->setShortcut (Qt::Key_L);
1089 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1090 a->setToggleAction(true);
1092 actionModModeLink=a;
1096 void Main::setupFlagActions()
1098 // Create System Flags
1099 systemFlagsDefault = new FlagRowObj ();
1100 systemFlagsDefault->setVisibility (false);
1101 systemFlagsDefault->setName ("systemFlagsDef");
1103 FlagObj *fo = new FlagObj ();
1104 fo->load(QPixmap(flagsPath+"flag-note.png"));
1105 fo->setName("note");
1106 fo->setToolTip(tr("Note","Systemflag"));
1107 systemFlagsDefault->addFlag (fo); // makes deep copy
1109 fo->load(QPixmap(flagsPath+"flag-url.png"));
1111 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1112 systemFlagsDefault->addFlag (fo);
1114 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1115 fo->setName("vymLink");
1116 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1117 systemFlagsDefault->addFlag (fo);
1119 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1120 fo->setName("scrolledright");
1121 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1122 systemFlagsDefault->addFlag (fo);
1124 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1125 fo->setName("tmpUnscrolledright");
1126 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1127 systemFlagsDefault->addFlag (fo);
1129 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1130 fo->setName("hideInExport");
1131 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1132 systemFlagsDefault->addFlag (fo);
1134 // Create Standard Flags
1135 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1136 tb->setObjectName ("standardFlagTB");
1138 standardFlagsDefault = new FlagRowObj ();
1139 standardFlagsDefault->setVisibility (false);
1140 standardFlagsDefault->setName ("standardFlagsDef");
1141 standardFlagsDefault->setToolBar (tb);
1143 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1144 fo->setName ("exclamationmark");
1145 fo->setGroup("standard-mark");
1146 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1149 a->setCheckable(true);
1150 a->setObjectName(fo->getName());
1151 a->setToolTip(tr("Take care!","Standardflag"));
1152 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1153 standardFlagsDefault->addFlag (fo); // makes deep copy
1155 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1156 fo->setName("questionmark");
1157 fo->setGroup("standard-mark");
1158 a=new QAction (fo->getPixmap(),fo->getName(),this);
1161 a->setCheckable(true);
1162 a->setObjectName(fo->getName());
1163 a->setToolTip(tr("Really?","Standardflag"));
1164 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1165 standardFlagsDefault->addFlag (fo);
1167 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1168 fo->setName("hook-green");
1169 fo->setGroup("standard-hook");
1170 a=new QAction (fo->getPixmap(),fo->getName(),this);
1173 a->setCheckable(true);
1174 a->setObjectName(fo->getName());
1175 a->setToolTip(tr("ok!","Standardflag"));
1176 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1177 standardFlagsDefault->addFlag (fo);
1179 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1180 fo->setName("cross-red");
1181 fo->setGroup("standard-hook");
1182 a=new QAction (fo->getPixmap(),fo->getName(),this);
1185 a->setCheckable(true);
1186 a->setObjectName(fo->getName());
1187 a->setToolTip(tr("Not ok!","Standardflag"));
1188 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1189 standardFlagsDefault->addFlag (fo);
1191 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1192 fo->setName("stopsign");
1193 a=new QAction (fo->getPixmap(),fo->getName(),this);
1196 a->setCheckable(true);
1197 a->setObjectName(fo->getName());
1198 a->setToolTip(tr("This won't work!","Standardflag"));
1199 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1200 standardFlagsDefault->addFlag (fo);
1202 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1203 fo->setName("smiley-good");
1204 fo->setGroup("standard-smiley");
1205 a=new QAction (fo->getPixmap(),fo->getName(),this);
1208 a->setCheckable(true);
1209 a->setObjectName(fo->getName());
1210 a->setToolTip(tr("Good","Standardflag"));
1211 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1212 standardFlagsDefault->addFlag (fo);
1214 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1215 fo->setName("smiley-sad");
1216 fo->setGroup("standard-smiley");
1217 a=new QAction (fo->getPixmap(),fo->getName(),this);
1220 a->setCheckable(true);
1221 a->setObjectName(fo->getName());
1222 a->setToolTip(tr("Bad","Standardflag"));
1223 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1224 standardFlagsDefault->addFlag (fo);
1226 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1227 // Original omg.png (in KDE emoticons)
1228 fo->setName("smiley-omg");
1229 fo->setGroup("standard-smiley");
1230 a=new QAction (fo->getPixmap(),fo->getName(),this);
1233 a->setCheckable(true);
1234 a->setObjectName(fo->getName());
1235 a->setToolTip(tr("Oh no!","Standardflag"));
1236 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1237 standardFlagsDefault->addFlag (fo);
1239 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1240 fo->setName("clock");
1241 a=new QAction (fo->getPixmap(),fo->getName(),this);
1244 a->setCheckable(true);
1245 a->setObjectName(fo->getName());
1246 a->setToolTip(tr("Time critical","Standardflag"));
1247 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1248 standardFlagsDefault->addFlag (fo);
1250 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1251 fo->setName("phone");
1252 a=new QAction (fo->getPixmap(),fo->getName(),this);
1255 a->setCheckable(true);
1256 a->setObjectName(fo->getName());
1257 a->setToolTip(tr("Call...","Standardflag"));
1258 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1259 standardFlagsDefault->addFlag (fo);
1261 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1262 fo->setName("lamp");
1263 a=new QAction (fo->getPixmap(),fo->getName(),this);
1266 a->setCheckable(true);
1267 a->setObjectName(fo->getName());
1268 a->setToolTip(tr("Idea!","Standardflag"));
1269 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1270 standardFlagsDefault->addFlag (fo);
1272 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1273 fo->setName("arrow-up");
1274 fo->setGroup("standard-arrow");
1275 a=new QAction (fo->getPixmap(),fo->getName(),this);
1278 a->setCheckable(true);
1279 a->setObjectName(fo->getName());
1280 a->setToolTip(tr("Important","Standardflag"));
1281 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1282 standardFlagsDefault->addFlag (fo);
1284 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1285 fo->setName("arrow-down");
1286 fo->setGroup("standard-arrow");
1287 a=new QAction (fo->getPixmap(),fo->getName(),this);
1290 a->setCheckable(true);
1291 a->setObjectName(fo->getName());
1292 a->setToolTip(tr("Unimportant","Standardflag"));
1293 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1294 standardFlagsDefault->addFlag (fo);
1296 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1297 fo->setName("2arrow-up");
1298 fo->setGroup("standard-arrow");
1299 a=new QAction (fo->getPixmap(),fo->getName(),this);
1302 a->setCheckable(true);
1303 a->setObjectName(fo->getName());
1304 a->setToolTip(tr("Very important!","Standardflag"));
1305 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1306 standardFlagsDefault->addFlag (fo);
1308 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1309 fo->setName("2arrow-down");
1310 fo->setGroup("standard-arrow");
1311 a=new QAction (fo->getPixmap(),fo->getName(),this);
1314 a->setCheckable(true);
1315 a->setObjectName(fo->getName());
1316 a->setToolTip(tr("Very unimportant!","Standardflag"));
1317 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1318 standardFlagsDefault->addFlag (fo);
1320 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1321 fo->setName("thumb-up");
1322 fo->setGroup("standard-thumb");
1323 a=new QAction (fo->getPixmap(),fo->getName(),this);
1326 a->setCheckable(true);
1327 a->setObjectName(fo->getName());
1328 a->setToolTip(tr("I like this","Standardflag"));
1329 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1330 standardFlagsDefault->addFlag (fo);
1332 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1333 fo->setName("thumb-down");
1334 fo->setGroup("standard-thumb");
1335 a=new QAction (fo->getPixmap(),fo->getName(),this);
1338 a->setCheckable(true);
1339 a->setObjectName(fo->getName());
1340 a->setToolTip(tr("I do not like this","Standardflag"));
1341 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1342 standardFlagsDefault->addFlag (fo);
1344 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1345 fo->setName("rose");
1346 a=new QAction (fo->getPixmap(),fo->getName(),this);
1349 a->setCheckable(true);
1350 a->setObjectName(fo->getName());
1351 a->setToolTip(tr("Rose","Standardflag"));
1352 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1353 standardFlagsDefault->addFlag (fo);
1355 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1356 fo->setName("heart");
1357 a=new QAction (fo->getPixmap(),fo->getName(),this);
1359 a->setCheckable(true);
1360 a->setObjectName(fo->getName());
1361 a->setToolTip(tr("I just love... ","Standardflag"));
1362 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1363 standardFlagsDefault->addFlag (fo);
1365 fo->load(QPixmap(flagsPath+"flag-present.png"));
1366 fo->setName("present");
1367 a=new QAction (fo->getPixmap(),fo->getName(),this);
1370 a->setCheckable(true);
1371 a->setObjectName(fo->getName());
1372 a->setToolTip(tr("Surprise!","Standardflag"));
1373 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1374 standardFlagsDefault->addFlag (fo);
1376 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1377 fo->setName("flash");
1378 a=new QAction (fo->getPixmap(),fo->getName(),this);
1381 a->setCheckable(true);
1382 a->setObjectName(fo->getName());
1383 a->setToolTip(tr("Dangerous","Standardflag"));
1384 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1385 standardFlagsDefault->addFlag (fo);
1387 fo->load(QPixmap(flagsPath+"flag-info.png"));
1388 // Original: xsldbg_output.png
1389 fo->setName("info");
1390 a=new QAction (fo->getPixmap(),fo->getName(),this);
1393 a->setCheckable(true);
1394 a->setObjectName(fo->getName());
1395 a->setToolTip(tr("Info","Standardflag"));
1396 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1397 standardFlagsDefault->addFlag (fo);
1399 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1400 // Original khelpcenter.png
1401 fo->setName("lifebelt");
1402 a=new QAction (fo->getPixmap(),fo->getName(),this);
1405 a->setCheckable(true);
1406 a->setObjectName(fo->getName());
1407 a->setToolTip(tr("This will help","Standardflag"));
1408 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1409 standardFlagsDefault->addFlag (fo);
1415 void Main::setupSettingsActions()
1417 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1421 a = new QAction( tr( "Set application to open pdf files"), this);
1422 a->setStatusTip ( tr( "Set application to open pdf files"));
1423 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1424 settingsMenu->addAction (a);
1426 a = new QAction( tr( "Set application to open external links"), this);
1427 a->setStatusTip( tr( "Set application to open external links"));
1428 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1429 settingsMenu->addAction (a);
1431 settingsMenu->addSeparator();
1432 a = new QAction( tr( "Edit branch after adding it" ), this );
1433 a->setStatusTip( tr( "Edit branch after adding it" ));
1434 a->setToggleAction(true);
1435 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1436 settingsMenu->addAction (a);
1437 actionSettingsAutoedit=a;
1439 a= new QAction( tr( "Select branch after adding it" ), this );
1440 a->setStatusTip( tr( "Select branch after adding it" ));
1441 a->setToggleAction(true);
1442 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1443 settingsMenu->addAction (a);
1444 actionSettingsAutoselectHeading=a;
1446 a= new QAction(tr( "Select existing heading" ), this);
1447 a->setStatusTip( tr( "Select heading before editing" ));
1448 a->setToggleAction(true);
1449 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1450 settingsMenu->addAction (a);
1451 actionSettingsAutoselectText=a;
1453 a= new QAction( tr( "Delete key" ), this);
1454 a->setStatusTip( tr( "Delete key for deleting branches" ));
1455 a->setToggleAction(true);
1456 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1457 settingsMenu->addAction (a);
1458 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1459 actionSettingsUseDelKey=a;
1461 a= new QAction( tr( "Exclusive flags" ), this);
1462 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1463 a->setToggleAction(true);
1464 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1465 settingsMenu->addAction (a);
1466 actionSettingsUseFlagGroups=a;
1468 a= new QAction( tr( "Use hide flags" ), this);
1469 a->setStatusTip( tr( "Use hide flag during exports " ));
1470 a->setToggleAction(true);
1471 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1472 settingsMenu->addAction (a);
1473 actionSettingsUseHideExport=a;
1477 void Main::setupTestActions()
1479 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1482 a = new QAction( tr( "test flag" ), this);
1483 a->setStatusTip( tr( "Call test function" ));
1484 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1485 testMenu->addAction (a);
1489 void Main::setupHelpActions()
1491 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1494 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1495 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1496 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1497 helpMenu->addAction (a);
1499 a = new QAction( tr( "About VYM" ), this);
1500 a->setStatusTip( tr( "About VYM")+" "__VYM);
1501 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1502 helpMenu->addAction (a);
1504 a = new QAction( tr( "About QT" ), this);
1505 a->setStatusTip( tr( "Information about QT toolkit" ));
1506 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1507 helpMenu->addAction (a);
1511 void Main::setupContextMenus()
1515 // Context Menu for branch or mapcenter
1516 branchContextMenu =new QMenu (this);
1519 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1520 branchAddContextMenu->addAction (actionEditPaste );
1521 branchAddContextMenu->addAction ( actionEditAddBranch );
1522 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1523 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1524 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1525 branchAddContextMenu->addSeparator();
1526 branchAddContextMenu->addAction ( actionEditLoadImage);
1527 branchAddContextMenu->addSeparator();
1528 branchAddContextMenu->addAction ( actionEditImportAdd );
1529 branchAddContextMenu->addAction ( actionEditImportReplace );
1532 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1533 branchRemoveContextMenu->addAction (actionEditCut);
1534 branchRemoveContextMenu->addAction ( actionEditDelete );
1535 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1536 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1539 actionEditSaveBranch->addTo( branchContextMenu );
1541 branchContextMenu->addSeparator();
1542 branchContextMenu->addAction ( actionFormatFrameNone );
1543 branchContextMenu->addAction ( actionFormatFrameRectangle);
1545 branchContextMenu->addSeparator();
1546 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1547 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1548 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1550 // Submenu for Links (URLs, vymLinks)
1551 branchLinksContextMenu =new QMenu (this);
1553 branchContextMenu->addSeparator();
1554 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));
1555 branchLinksContextMenu->addAction ( actionEditOpenURL );
1556 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1557 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1558 branchLinksContextMenu->addAction ( actionEditURL );
1559 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1560 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1561 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1563 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1565 branchLinksContextMenu->addSeparator();
1566 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1567 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1568 branchLinksContextMenu->addAction ( actionEditVymLink );
1569 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1572 // Context Menu for XLinks in a branch menu
1573 // This will be populated "on demand" in MapEditor::updateActions
1574 branchContextMenu->addSeparator();
1575 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1576 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1577 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1578 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1581 // Context menu for floatimage
1582 floatimageContextMenu =new QMenu (this);
1583 a= new QAction (tr ("Save image"),this);
1584 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1585 floatimageContextMenu->addAction (a);
1587 floatimageContextMenu->addSeparator();
1588 actionEditCopy->addTo( floatimageContextMenu );
1589 actionEditCut->addTo( floatimageContextMenu );
1591 floatimageContextMenu->addSeparator();
1592 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1595 // Context menu for canvas
1596 canvasContextMenu =new QMenu (this);
1597 actionEditMapInfo->addTo( canvasContextMenu );
1598 canvasContextMenu->insertSeparator();
1599 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1600 canvasContextMenu->insertSeparator();
1601 actionFormatLinkColorHint->addTo( canvasContextMenu );
1602 actionFormatLinkColor->addTo( canvasContextMenu );
1603 actionFormatBackColor->addTo( canvasContextMenu );
1605 // Menu for last opened files
1606 // Read settings initially
1608 int j=settings.readNumEntry( "/lastMaps/number",0);
1609 for (int i=1;i<=j;i++)
1611 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1612 if (!s.isEmpty() && j<=maxLastMaps)
1615 setupLastMapsMenu();
1616 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1619 void Main::setupLastMapsMenu()
1621 // Remove double entries
1622 QStringList::Iterator it=lastMaps.begin();
1623 QStringList::Iterator jt;
1624 while (it!=lastMaps.end() )
1628 while (jt!=lastMaps.end() )
1631 jt=lastMaps.remove(jt);
1638 // Limit length of list to maxLastMaps
1639 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1641 // build Menu from lastMaps string list
1642 fileLastMapsMenu->clear();
1643 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1644 fileLastMapsMenu->addAction (*it );
1647 void Main::hideEvent (QHideEvent * )
1649 if (!textEditor->isMinimized() ) textEditor->hide();
1652 void Main::showEvent (QShowEvent * )
1654 if (textEditor->showWithMain()) textEditor->showNormal();
1657 bool Main::reallyWriteDirectory(const QString &dir)
1659 QStringList eList = QDir(dir).entryList();
1660 if (eList.first() ==".") eList.pop_front(); // remove "."
1661 if (eList.first() =="..") eList.pop_front(); // remove "."
1662 if (!eList.isEmpty())
1664 QMessageBox mb( __VYM,
1665 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1666 QMessageBox::Warning,
1668 QMessageBox::Cancel | QMessageBox::Default,
1669 QMessageBox::QMessageBox::NoButton );
1671 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1672 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1675 case QMessageBox::Yes:
1678 case QMessageBox::Cancel:
1686 QString Main::browseDirectory (const QString &caption)
1688 Q3FileDialog fd(this,caption);
1689 fd.setMode (Q3FileDialog::DirectoryOnly);
1690 fd.setCaption(__VYM " - "+caption);
1693 if ( fd.exec() == QDialog::Accepted )
1694 return fd.selectedFile();
1699 MapEditor* Main::currentMapEditor() const
1701 if ( tabWidget->currentPage() &&
1702 tabWidget->currentPage()->inherits( "MapEditor" ) )
1703 return (MapEditor*)tabWidget->currentPage();
1707 //TODO not used now, maybe use this for overview window later
1708 void Main::newView()
1710 // Open a new view... have it delete when closed.
1711 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1712 qApp->setMainWidget(m);
1714 qApp->setMainWidget(0);
1717 void Main::editorChanged(QWidget *)
1719 // Unselect all possibly selected objects
1720 // (Important to update note editor)
1723 for (i=0;i<=tabWidget->count() -1;i++)
1726 me=(MapEditor*)tabWidget->page(i);
1729 currentMapEditor()->reselect();
1731 // Update actions to in menus and toolbars according to editor
1732 currentMapEditor()->updateActions();
1735 void Main::fileNew()
1737 QString fn="unnamed";
1738 MapEditor* medit = new MapEditor ( NULL,true);
1739 tabWidget->addTab (medit,fn);
1740 tabWidget->showPage(medit);
1741 medit->viewport()->setFocus();
1742 // For the very first map we do not have flagrows yet...
1743 medit->select("mc:");
1746 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1748 ErrorCode err=success;
1750 // fn is usually the archive, mapfile the file after uncompressing
1753 // Make fn absolute (needed for unzip)
1754 fn=QDir (fn).absPath();
1760 // Check, if map is already loaded
1762 while (i<=tabWidget->count() -1)
1764 me=(MapEditor*)tabWidget->page(i);
1765 if (me->getFilePath() == fn)
1767 // Already there, ask for confirmation
1768 QMessageBox mb( __VYM,
1769 tr("The map %1\nis already opened."
1770 "Opening the same map in multiple editors may lead \n"
1771 "to confusion when finishing working with vym."
1772 "Do you want to").arg(fn),
1773 QMessageBox::Warning,
1774 QMessageBox::Yes | QMessageBox::Default,
1775 QMessageBox::Cancel | QMessageBox::Escape,
1776 QMessageBox::NoButton);
1777 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1778 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1781 case QMessageBox::Yes:
1783 i=tabWidget->count();
1785 case QMessageBox::Cancel:
1797 if ( !fn.isEmpty() )
1799 me = currentMapEditor();
1800 int tabIndex=tabWidget->currentPageIndex();
1801 // Check first, if mapeditor exists
1802 // If it is not default AND we want a new map,
1803 // create a new mapeditor in a new tab
1804 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1806 me= new MapEditor ( NULL,true);
1807 tabWidget->addTab (me,fn);
1808 tabIndex=tabWidget->indexOf (me);
1809 tabWidget->setCurrentPage (tabIndex);
1812 // Check, if file exists (important for creating new files
1813 // from command line
1814 if (!QFile(fn).exists() )
1816 QMessageBox mb( __VYM,
1817 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1818 QMessageBox::Question,
1820 QMessageBox::Cancel | QMessageBox::Default,
1821 QMessageBox::NoButton );
1823 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1824 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1827 case QMessageBox::Yes:
1829 currentMapEditor()->setFilePath(fn);
1830 tabWidget->setTabLabel (currentMapEditor(),
1831 currentMapEditor()->getFileName() );
1832 statusBar()->message( "Created " + fn , statusbarTime );
1835 case QMessageBox::Cancel:
1836 // don't create new map
1837 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1844 //tabWidget->currentPage() won't be NULL here, because of above...
1845 tabWidget->showPage(me);
1846 me->viewport()->setFocus();
1848 // Create temporary directory for packing
1849 char tmpdir1[]="/tmp/vym-XXXXXX";
1850 QString tmpMapDir=mkdtemp(tmpdir1);
1852 // Try to unzip file
1853 err=unzipDir (tmpMapDir,fn);
1857 me->setZipped(false);
1860 me->setZipped(true);
1862 // Look for mapname.xml
1863 mapfile= fn.left(fn.findRev(".",-1,true));
1864 mapfile=mapfile.section( '/', -1 );
1865 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1866 if (!file.exists() )
1868 // mapname.xml does not exist, well,
1869 // maybe some renamed the mapname.vym file...
1870 // Try to find any .xml in the toplevel
1871 // directory of the .vym file
1872 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1873 if (flist.count()==1)
1875 // Only one entry, take this one
1876 mapfile=tmpMapDir + "/"+flist.first();
1879 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1880 *it=tmpMapDir + "/" + *it;
1881 // TODO Multiple entries, load all (but only the first one into this ME)
1882 //mainWindow->fileLoadFromTmp (flist);
1883 //returnCode=1; // Silently forget this attempt to load
1884 qWarning ("MainWindow::load (fn) multimap found...");
1887 if (flist.isEmpty() )
1889 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1890 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1893 } //file doesn't exist
1895 mapfile=file.name();
1900 // Save existing filename in case we import
1901 QString fn_org=me->getFilePath();
1903 // Finally load map into mapEditor
1904 me->setFilePath (mapfile,fn);
1905 err=me->load(mapfile,lmode);
1907 // Restore old (maybe empty) filepath, if this is an import
1909 me->setFilePath (fn_org);
1912 // Finally check for errors and go home
1915 if (lmode==NewMap) fileCloseMap();
1916 statusBar()->message( "Could not load " + fn, statusbarTime );
1921 me->setFilePath (fn);
1922 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1923 if (fn.left(9)!="/tmp/vym-")
1925 // Only append to lastMaps if not loaded from a tmpDir
1926 // e.g. imported bookmarks are in a tmpDir
1927 lastMaps.prepend(me->getFilePath() );
1928 setupLastMapsMenu();
1930 actionFilePrint->setEnabled (true);
1932 statusBar()->message( "Loaded " + fn, statusbarTime );
1936 removeDir (QDir(tmpMapDir));
1942 void Main::fileLoad(const LoadMode &lmode)
1944 Q3FileDialog *fd=new Q3FileDialog( this);
1945 fd->setDir (lastFileDir);
1946 fd->setMode (Q3FileDialog::ExistingFiles);
1947 fd->addFilter ("XML (*.xml)");
1948 fd->addFilter ("VYM map (*.vym *.vyp)");
1952 fd->setCaption(tr("Load vym map"));
1955 fd->setCaption(tr("Import: Add vym map to selection"));
1958 fd->setCaption(tr("Import: Replace selection with vym map"));
1964 if ( fd->exec() == QDialog::Accepted )
1966 lastFileDir=fd->dirPath();
1967 QStringList flist = fd->selectedFiles();
1968 QStringList::Iterator it = flist.begin();
1969 while( it != flist.end() )
1972 fileLoad(*it, lmode);
1979 void Main::fileLoad()
1984 void Main::fileLoadLast(QAction *a)
1986 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1989 void Main::fileSave(const SaveMode &savemode)
1991 // tmp dir for zipping
1995 ErrorCode err=success;
1997 QString safeFilePath;
1999 bool saveZipped=currentMapEditor()->saveZipped();
2001 MapEditor * me=currentMapEditor();
2004 QString fn=me->getFilePath();
2005 // filename=unnamed, filepath="" in constructor...
2006 if ( !fn.isEmpty() )
2008 // We have a filepath, go on saving
2009 // First remove existing file, we
2010 // don't want to add to old zip archives
2014 QMessageBox::warning( 0, tr( "Save Error" ),
2015 fn+ tr("\ncould not be removed before saving"));
2017 // Look, if we should zip the data:
2020 QMessageBox mb( __VYM,
2021 tr("The map %1\ndid not use the compressed "
2022 "vym file format.\nWriting it uncompressed will also write images \n"
2023 "and flags and thus may overwrite files in the "
2024 "given directory\n\nDo you want to write the map").arg(fn),
2025 QMessageBox::Warning,
2026 QMessageBox::Yes | QMessageBox::Default,
2028 QMessageBox::Cancel | QMessageBox::Escape);
2029 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2030 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2031 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2034 case QMessageBox::Yes:
2035 // save compressed (default file format)
2038 case QMessageBox::No:
2039 // save uncompressed
2042 case QMessageBox::Cancel:
2051 char tmpdir1[]="/tmp/vym-XXXXXX";
2052 tmpMapDir=mkdtemp(tmpdir1);
2054 safeFilePath=me->getFilePath();
2055 me->setFilePath (tmpMapDir+"/"+
2056 me->getMapName()+ ".xml",
2058 me->save (savemode);
2059 me->setFilePath (safeFilePath);
2061 zipDir (tmpMapDir,fn);
2066 safeFilePath=me->getFilePath();
2067 me->setFilePath (fn, safeFilePath);
2068 me->save (savemode);
2069 me->setFilePath (safeFilePath);
2071 } // filepath available
2074 // We have no filepath yet,
2075 // call fileSaveAs() now, this will call fileSave()
2077 fileSaveAs(savemode);
2081 if (saveZipped && !tmpMapDir.isEmpty())
2083 removeDir (QDir(tmpMapDir));
2087 statusBar()->message(
2088 tr("Saved %1").arg(me->getFilePath()),
2090 lastMaps.prepend(me->getFilePath() );
2091 setupLastMapsMenu();
2093 statusBar()->message(
2094 tr("Couldn't save ").arg(me->getFilePath()),
2098 void Main::fileSave()
2100 fileSave (CompleteMap);
2103 void Main::fileSaveAs(const SaveMode& savemode)
2107 if (currentMapEditor())
2109 if (savemode==CompleteMap)
2110 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2112 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2113 if ( !fn.isEmpty() )
2115 // Check for existing file
2116 if (QFile (fn).exists())
2118 QMessageBox mb( __VYM,
2119 tr("The file %1\nexists already. Do you want to").arg(fn),
2120 QMessageBox::Warning,
2121 QMessageBox::Yes | QMessageBox::Default,
2122 QMessageBox::Cancel | QMessageBox::Escape,
2123 QMessageBox::NoButton);
2124 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2125 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2128 case QMessageBox::Yes:
2131 case QMessageBox::Cancel:
2138 // New file, add extension to filename, if missing
2139 // This is always .vym or .vyp, depending on savemode
2140 if (savemode==CompleteMap)
2142 if (!fn.contains (".vym") && !fn.contains (".xml"))
2146 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2155 currentMapEditor()->setFilePath(fn);
2159 if (savemode==CompleteMap)
2160 tabWidget->setTabLabel (currentMapEditor(),
2161 currentMapEditor()->getFileName() );
2167 void Main::fileSaveAs()
2169 fileSaveAs (CompleteMap);
2172 void Main::fileImportKDEBookmarks()
2174 ImportKDEBookmarks im;
2176 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2177 currentMapEditor()->setFilePath ("");
2180 void Main::fileImportFirefoxBookmarks()
2182 Q3FileDialog *fd=new Q3FileDialog( this);
2183 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2184 fd->setMode (Q3FileDialog::ExistingFiles);
2185 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2186 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2189 if ( fd->exec() == QDialog::Accepted )
2191 ImportFirefoxBookmarks im;
2192 QStringList flist = fd->selectedFiles();
2193 QStringList::Iterator it = flist.begin();
2194 while( it != flist.end() )
2197 if (im.transform() &&
2198 success==fileLoad (im.getTransformedFile(),NewMap) &&
2199 currentMapEditor() )
2200 currentMapEditor()->setFilePath ("");
2207 void Main::fileImportMM()
2211 Q3FileDialog *fd=new Q3FileDialog( this);
2212 fd->setDir (lastFileDir);
2213 fd->setMode (Q3FileDialog::ExistingFiles);
2214 fd->addFilter ("Mind Manager (*.mmap)");
2215 fd->setCaption(tr("Import")+" "+"Mind Manager");
2218 if ( fd->exec() == QDialog::Accepted )
2220 lastFileDir=fd->dirPath();
2221 QStringList flist = fd->selectedFiles();
2222 QStringList::Iterator it = flist.begin();
2223 while( it != flist.end() )
2226 if (im.transform() &&
2227 success==fileLoad (im.getTransformedFile(),NewMap) &&
2228 currentMapEditor() )
2229 currentMapEditor()->setFilePath ("");
2238 void Main::fileImportDir()
2240 if (currentMapEditor())
2241 currentMapEditor()->importDir();
2244 void Main::fileExportXML()
2246 if (currentMapEditor())
2248 QString dir=browseDirectory(tr("Export XML to directory"));
2249 if (dir !="" && reallyWriteDirectory(dir) )
2250 currentMapEditor()->exportXML(dir);
2255 void Main::fileExportXHTML()
2257 MapEditor *me=currentMapEditor();
2261 ExportXHTMLDialog dia(this);
2262 dia.setFilePath (me->getFilePath() );
2263 dia.setMapName (me->getMapName() );
2266 if (dia.exec()==QDialog::Accepted)
2268 QString dir=dia.getDir();
2269 // Check, if warnings should be used before overwriting
2270 // the output directory
2273 ok=reallyWriteDirectory(dir);
2279 me->exportXML (dia.getDir() );
2280 dia.doExport(me->getMapName() );
2281 if (dia.hasChanged())
2288 void Main::fileExportImage()
2290 MapEditor *me=currentMapEditor();
2294 QFileDialog *fd=new QFileDialog (this);
2295 fd->setCaption (tr("Export map as image"));
2296 fd->setFileMode(QFileDialog::AnyFile);
2297 fd->setFilters (imageIO.getFilters() );
2298 fd->setDirectory (lastImageDir);
2301 fl=fd->selectedFiles();
2302 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2303 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2308 void Main::fileExportASCII()
2310 MapEditor *me=currentMapEditor();
2314 ex.setMapCenter(me->getMapCenter());
2315 ex.addFilter ("TXT (*.txt)");
2316 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2317 if (ex.execDialog() )
2319 me->setExportMode(true);
2321 me->setExportMode(false);
2326 void Main::fileExportLaTeX()
2328 MapEditor *me=currentMapEditor();
2332 ex.setMapCenter(me->getMapCenter());
2333 ex.addFilter ("Tex (*.tex)");
2334 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2335 if (ex.execDialog() )
2337 me->setExportMode(true);
2339 me->setExportMode(false);
2344 void Main::fileExportKDEBookmarks()
2346 ExportKDEBookmarks ex;
2347 MapEditor *me=currentMapEditor();
2350 ex.setMapCenter (me->getMapCenter() );
2355 void Main::fileExportTaskjuggler()
2357 ExportTaskjuggler ex;
2358 MapEditor *me=currentMapEditor();
2361 ex.setMapCenter (me->getMapCenter() );
2362 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2363 ex.addFilter ("Taskjuggler (*.tjp)");
2364 if (ex.execDialog() )
2366 me->setExportMode(true);
2368 me->setExportMode(false);
2373 void Main::fileExportOOPresentation()
2375 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2376 // TODO add preview in dialog
2377 //ImagePreview *p =new ImagePreview (fd);
2378 //fd->setContentsPreviewEnabled( TRUE );
2379 //fd->setContentsPreview( p, p );
2380 //fd->setPreviewMode( QFileDialog::Contents );
2381 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2382 fd->setDir (QDir().current());
2383 if (fd->foundConfig())
2387 if ( fd->exec() == QDialog::Accepted )
2389 QString fn=fd->selectedFile();
2390 if (!fn.contains (".odp"))
2393 //lastImageDir=fn.left(fn.findRev ("/"));
2394 if (currentMapEditor())
2395 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2399 QMessageBox::warning(0,
2401 tr("Couldn't find configuration for export to Open Office\n"));
2405 void Main::fileCloseMap()
2407 if (currentMapEditor())
2409 if (currentMapEditor()->hasChanged())
2411 QMessageBox mb( __VYM,
2412 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2413 QMessageBox::Warning,
2414 QMessageBox::Yes | QMessageBox::Default,
2416 QMessageBox::Cancel | QMessageBox::Escape );
2417 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2418 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2421 case QMessageBox::Yes:
2423 fileSave(CompleteMap);
2425 case QMessageBox::No:
2426 // close without saving
2428 case QMessageBox::Cancel:
2433 currentMapEditor()->closeMap();
2434 tabWidget->removePage(currentMapEditor());
2435 if (tabWidget->count()==0)
2436 actionFilePrint->setEnabled (false);
2440 void Main::filePrint()
2442 if (currentMapEditor())
2443 currentMapEditor()->print();
2446 void Main::fileExitVYM()
2448 // Check if one or more editors have changed
2451 for (i=0;i<=tabWidget->count() -1;i++)
2454 me=(MapEditor*)tabWidget->page(i);
2456 // If something changed, ask what to do
2457 if (me->isUnsaved())
2459 tabWidget->setCurrentPage(i);
2460 QMessageBox mb( __VYM,
2461 tr("This map is not saved yet. Do you want to"),
2462 QMessageBox::Warning,
2463 QMessageBox::Yes | QMessageBox::Default,
2465 QMessageBox::Cancel | QMessageBox::Escape );
2466 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2467 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2470 mb.setActiveWindow();
2471 switch( mb.exec() ) {
2472 case QMessageBox::Yes:
2473 // save (the changed editors) and exit
2474 fileSave(CompleteMap);
2476 case QMessageBox::No:
2477 // exit without saving
2479 case QMessageBox::Cancel:
2480 // don't save and don't exit
2484 } // loop over all MEs
2488 void Main::editUndo()
2490 if (currentMapEditor())
2491 currentMapEditor()->undo();
2494 void Main::editRedo()
2496 if (currentMapEditor())
2497 currentMapEditor()->redo();
2500 void Main::editCopy()
2502 if (currentMapEditor())
2503 currentMapEditor()->copy();
2506 void Main::editPaste()
2508 if (currentMapEditor())
2509 currentMapEditor()->paste();
2512 void Main::editCut()
2514 if (currentMapEditor())
2515 currentMapEditor()->cut();
2518 void Main::editOpenFindWindow()
2520 findWindow->popup();
2521 findWindow->raise();
2522 findWindow->setActiveWindow();
2525 void Main::editFind(QString s)
2528 BranchObj *bo=currentMapEditor()->findText(s, cs);
2531 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2534 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2535 tr("No matches found for \"%1\"").arg(s));
2539 void Main::editFindChanged()
2540 { // Notify editor, to abort the current find process
2541 currentMapEditor()->findReset();
2544 void Main::openTabs(QStringList urls)
2546 if (!urls.isEmpty())
2550 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2552 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2554 QString u=urls.takeFirst();
2555 procBrowser = new QProcess( this );
2557 procBrowser->start(browser,args);
2558 if ( !procBrowser->waitForStarted())
2560 // try to set path to browser
2561 QMessageBox::warning(0,
2563 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2564 tr("Please use Settings->")+tr("Set application to open an URL"));
2569 if (browser.contains("konqueror"))
2571 for (int i=0; i<urls.size(); i++)
2574 // Try to open new tab in existing konqueror started previously by vym
2575 p=new QProcess (this);
2577 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2578 "konqueror-mainwindow#1"<<
2581 p->start ("dcop",args);
2582 if ( !p->waitForStarted() ) success=false;
2585 QMessageBox::warning(0,
2587 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2589 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2591 for (int i=0; i<urls.size(); i++)
2593 // Try to open new tab in firefox
2594 p=new QProcess (this);
2595 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2596 p->start (browser,args);
2597 if ( !p->waitForStarted() ) success=false;
2600 QMessageBox::warning(0,
2602 tr("Couldn't start %1 to open a new tab").arg(browser));
2605 QMessageBox::warning(0,
2607 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2611 void Main::editOpenURL()
2614 if (currentMapEditor())
2616 QString url=currentMapEditor()->getURL();
2618 if (url=="") return;
2619 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2620 procBrowser = new QProcess( this );
2622 procBrowser->start(browser,args);
2623 if ( !procBrowser->waitForStarted())
2625 // try to set path to browser
2626 QMessageBox::warning(0,
2628 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2629 tr("Please use Settings->")+tr("Set application to open an URL"));
2634 void Main::editOpenURLTab()
2636 if (currentMapEditor())
2639 urls.append(currentMapEditor()->getURL());
2643 void Main::editOpenMultipleURLTabs()
2645 if (currentMapEditor())
2648 urls=currentMapEditor()->getURLs();
2654 void Main::editURL()
2656 if (currentMapEditor())
2657 currentMapEditor()->editURL();
2660 void Main::editHeading2URL()
2662 if (currentMapEditor())
2663 currentMapEditor()->editHeading2URL();
2666 void Main::editBugzilla2URL()
2668 if (currentMapEditor())
2669 currentMapEditor()->editBugzilla2URL();
2672 void Main::editFATE2URL()
2674 if (currentMapEditor())
2675 currentMapEditor()->editFATE2URL();
2678 void Main::editHeading()
2680 if (lineedit->isVisible())
2682 if (currentMapEditor())
2684 MapEditor *me=currentMapEditor();
2685 QString oldSel=me->getSelectString();
2686 if (me->select (editSel))
2687 me->setHeading(lineedit->text());
2688 me->select (oldSel);
2690 lineedit->releaseKeyboard();
2695 if (currentMapEditor())
2699 QString s=currentMapEditor()->getHeading(ok,p);
2703 #if defined(Q_OS_MACX)
2704 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2705 QDialog *d =new QDialog(NULL);
2706 QLineEdit *le=new QLineEdit (d);
2707 d->setWindowFlags (Qt::FramelessWindowHint);
2708 d->setGeometry(p.x(),p.y(),200,25);
2709 le->resize (d->size());
2712 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2713 d->activateWindow();
2715 currentMapEditor()->setHeading (le->text());
2717 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2718 lineedit->setGeometry(p.x(),p.y(),200,25);
2719 lineedit->setText(s);
2720 lineedit->setCursorPosition(1);
2721 lineedit->selectAll();
2723 lineedit->grabKeyboard();
2724 lineedit->setFocus();
2726 editSel=currentMapEditor()->getSelectString();
2734 void Main::openVymLinks(const QStringList &vl)
2736 for (int j=0; j<vl.size(); j++)
2738 // compare path with already loaded maps
2742 for (i=0;i<=tabWidget->count() -1;i++)
2744 me=(MapEditor*)tabWidget->page(i);
2745 if (vl.at(j)==me->getFilePath() )
2754 if (!QFile(vl.at(j)).exists() )
2755 QMessageBox::critical( 0, tr( "Critical Error" ),
2756 tr("Couldn't open map %1").arg(vl.at(j)));
2759 fileLoad (vl.at(j), NewMap);
2760 tabWidget->setCurrentPage (tabWidget->count()-1);
2763 // Go to tab containing the map
2764 tabWidget->setCurrentPage (index);
2768 void Main::editOpenVymLink()
2770 if (currentMapEditor())
2773 vl.append(currentMapEditor()->getVymLink());
2778 void Main::editOpenMultipleVymLinks()
2780 QString currentVymLink;
2781 if (currentMapEditor())
2783 QStringList vl=currentMapEditor()->getVymLinks();
2788 void Main::editVymLink()
2790 if (currentMapEditor())
2791 currentMapEditor()->editVymLink();
2794 void Main::editDeleteVymLink()
2796 if (currentMapEditor())
2797 currentMapEditor()->deleteVymLink();
2800 void Main::editToggleHideExport()
2802 if (currentMapEditor())
2803 currentMapEditor()->toggleHideExport();
2806 void Main::editMapInfo()
2808 if (currentMapEditor())
2809 currentMapEditor()->editMapInfo();
2812 void Main::editMoveUp()
2814 if (currentMapEditor())
2815 currentMapEditor()->moveBranchUp();
2818 void Main::editMoveDown()
2820 if (currentMapEditor())
2821 currentMapEditor()->moveBranchDown();
2824 void Main::editToggleScroll()
2826 if (currentMapEditor())
2828 currentMapEditor()->toggleScroll();
2832 void Main::editUnScrollAll()
2834 if (currentMapEditor())
2836 currentMapEditor()->unScrollAll();
2840 void Main::editNewBranch()
2843 if (!lineedit->isVisible() && currentMapEditor())
2844 currentMapEditor()->addNewBranch(0);
2847 void Main::editNewBranchHere()
2849 if (currentMapEditor())
2850 currentMapEditor()->addNewBranchHere();
2853 void Main::editNewBranchAbove()
2855 if (currentMapEditor())
2856 currentMapEditor()->addNewBranch(-1);
2859 void Main::editNewBranchBelow()
2861 if (currentMapEditor())
2862 currentMapEditor()->addNewBranch(1);
2865 void Main::editImportAdd()
2867 fileLoad (ImportAdd);
2870 void Main::editImportReplace()
2872 fileLoad (ImportReplace);
2875 void Main::editSaveBranch()
2877 fileSaveAs (PartOfMap);
2880 void Main::editRemoveBranchKeepChilds()
2882 if (currentMapEditor())
2883 currentMapEditor()->removeBranchKeepChilds();
2886 void Main::editRemoveChilds()
2888 if (currentMapEditor())
2889 currentMapEditor()->removeChilds();
2892 void Main::editDeleteSelection()
2894 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2895 currentMapEditor()->deleteSelection();
2898 void Main::editUpperBranch()
2900 if (currentMapEditor())
2901 currentMapEditor()->selectUpperBranch();
2904 void Main::editLowerBranch()
2906 if (currentMapEditor())
2907 currentMapEditor()->selectLowerBranch();
2910 void Main::editLeftBranch()
2912 if (currentMapEditor())
2913 currentMapEditor()->selectLeftBranch();
2916 void Main::editRightBranch()
2918 if (currentMapEditor())
2919 currentMapEditor()->selectRightBranch();
2922 void Main::editFirstBranch()
2924 if (currentMapEditor())
2925 currentMapEditor()->selectFirstBranch();
2928 void Main::editLastBranch()
2930 if (currentMapEditor())
2931 currentMapEditor()->selectLastBranch();
2934 void Main::editLoadImage()
2936 if (currentMapEditor())
2937 currentMapEditor()->loadFloatImage();
2940 void Main::editSaveImage()
2942 if (currentMapEditor())
2943 currentMapEditor()->saveFloatImage();
2946 void Main::editFollowXLink(QAction *a)
2949 if (currentMapEditor())
2950 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2953 void Main::editEditXLink(QAction *a)
2955 if (currentMapEditor())
2956 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2959 void Main::formatSelectColor()
2961 if (currentMapEditor())
2963 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2964 if ( !col.isValid() ) return;
2965 currentMapEditor()->setColor( col );
2966 colorChanged( col );
2970 void Main::formatPickColor()
2972 if (currentMapEditor())
2973 colorChanged( currentMapEditor()->pickColor() );
2976 void Main::colorChanged(QColor c)
2978 QPixmap pix( 16, 16 );
2980 actionFormatColor->setIconSet( pix );
2983 void Main::formatColorItem()
2985 if (currentMapEditor())
2986 currentMapEditor()->colorItem();
2989 void Main::formatColorBranch()
2991 if (currentMapEditor())
2992 currentMapEditor()->colorBranch();
2995 void Main::formatLinkStyleLine()
2997 if (currentMapEditor())
2998 currentMapEditor()->setLinkStyle(StyleLine);
3001 void Main::formatLinkStyleParabel()
3003 if (currentMapEditor())
3004 currentMapEditor()->setLinkStyle(StyleParabel);
3007 void Main::formatLinkStylePolyLine()
3009 if (currentMapEditor())
3010 currentMapEditor()->setLinkStyle(StylePolyLine);
3013 void Main::formatLinkStylePolyParabel()
3015 if (currentMapEditor())
3016 currentMapEditor()->setLinkStyle(StylePolyParabel);
3019 void Main::formatSelectBackColor()
3021 if (currentMapEditor())
3022 currentMapEditor()->selectBackgroundColor();
3025 void Main::formatSelectLinkColor()
3027 if (currentMapEditor())
3028 currentMapEditor()->selectLinkColor();
3031 void Main::formatToggleLinkColorHint()
3033 currentMapEditor()->toggleLinkColorHint();
3036 void Main::formatFrameNone()
3038 if (currentMapEditor())
3039 currentMapEditor()->setFrame(NoFrame);
3042 void Main::formatFrameRectangle()
3044 if (currentMapEditor())
3045 currentMapEditor()->setFrame(Rectangle);
3048 void Main::formatIncludeImagesVer()
3050 if (currentMapEditor())
3051 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3054 void Main::formatIncludeImagesHor()
3056 if (currentMapEditor())
3057 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3060 void Main::formatHideLinkUnselected()
3062 if (currentMapEditor())
3063 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3066 void Main::viewZoomReset()
3068 if (currentMapEditor())
3072 currentMapEditor()->setWorldMatrix( m );
3073 currentMapEditor()->setViewCenter();
3074 currentMapEditor()->adjustCanvasSize();
3078 void Main::viewZoomIn()
3080 if (currentMapEditor())
3082 QMatrix m = currentMapEditor()->worldMatrix();
3083 m.scale( 1.25, 1.25 );
3084 currentMapEditor()->setWorldMatrix( m );
3085 currentMapEditor()->setViewCenter();
3086 currentMapEditor()->adjustCanvasSize();
3090 void Main::viewZoomOut()
3092 if (currentMapEditor())
3094 QMatrix m = currentMapEditor()->worldMatrix();
3095 m.scale( 0.8, 0.8 );
3096 currentMapEditor()->setWorldMatrix( m );
3097 currentMapEditor()->setViewCenter();
3098 currentMapEditor()->adjustCanvasSize();
3102 void Main::modModeColor()
3106 void Main::modModeLink()
3110 bool Main::settingsPDF()
3112 // Default browser is set in constructor
3114 QString text = QInputDialog::getText(
3115 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3116 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3118 settings.setValue ("/mainwindow/readerPDF",text);
3123 bool Main::settingsURL()
3125 // Default browser is set in constructor
3127 QString text = QInputDialog::getText(
3128 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3129 settings.value("/mainwindow/readerURL").toString()
3132 settings.setValue ("/mainwindow/readerURL",text);
3136 void Main::settingsToggleDelKey()
3138 if (actionSettingsUseDelKey->isOn())
3140 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3143 actionEditDelete->setAccel (QKeySequence (""));
3147 void Main::windowToggleNoteEditor()
3149 if (textEditor->showWithMain() )
3150 windowHideNoteEditor();
3152 windowShowNoteEditor();
3155 void Main::windowToggleHistory()
3157 if (currentMapEditor())
3158 currentMapEditor()->toggleHistoryWindow();
3161 void Main::updateNoteFlag()
3163 if (currentMapEditor())
3164 currentMapEditor()->updateNoteFlag();
3167 void Main::windowShowNoteEditor()
3169 textEditor->setShowWithMain(true);
3171 actionViewToggleNoteEditor->setOn (true);
3174 void Main::windowHideNoteEditor()
3176 textEditor->setShowWithMain(false);
3178 actionViewToggleNoteEditor->setOn (false);
3181 void Main::windowNextEditor()
3183 if (tabWidget->currentPageIndex() < tabWidget->count())
3184 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3187 void Main::windowPreviousEditor()
3189 if (tabWidget->currentPageIndex() >0)
3190 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3193 void Main::standardFlagChanged()
3195 currentMapEditor()->toggleStandardFlag(sender()->name());
3198 void Main::testFunction()
3200 currentMapEditor()->testFunction();
3203 void Main::helpDoc()
3206 #if defined(Q_OS_MACX)
3207 docpath="./vym.app/Contents/vym.pdf";
3209 // default path in SUSE LINUX
3210 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3213 if (!QFile (docpath).exists() )
3215 // relative path for easy testing in tarball
3216 docpath="doc/vym.pdf";
3217 if (!QFile (docpath).exists() )
3219 // relative path for testing while still writing vym.tex
3220 docpath="doc/tex/vym.pdf";
3221 if (!QFile (docpath).exists() )
3223 // Try yet another one for Knoppix
3224 docpath="/usr/share/doc/packages/vym/vym.pdf";
3225 if (!QFile (docpath).exists() )
3227 QMessageBox::critical(0,
3228 tr("Critcal error"),
3229 tr("Couldn't find the documentation\n"
3230 "vym.pdf in various places."));
3237 Process *pdfProc = new Process();
3238 pdfProc->clearArguments();
3239 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3240 pdfProc->addArgument( docpath);
3242 if ( !pdfProc->start() )
3245 QMessageBox::warning(0,
3247 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3248 tr("Please use Settings->")+tr("Set application to open PDF files"));
3255 void Main::helpAbout()
3258 ad.setName ("aboutwindow");
3259 ad.setMinimumSize(500,500);
3260 ad.resize (QSize (500,500));
3264 void Main::helpAboutQT()
3266 QMessageBox::aboutQt( this, "Qt Application Example" );