Fixed editing of headings. Undo debug output still enabled
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* actionSettingsPasteNewHeading;
126 extern QAction* actionSettingsUseDelKey;
127 extern QAction* actionSettingsUseFlagGroups;
128 extern QAction* actionSettingsUseHideExport;
130 extern QMenu* branchContextMenu;
131 extern QMenu* branchAddContextMenu;
132 extern QMenu* branchRemoveContextMenu;
133 extern QMenu* branchLinksContextMenu;
134 extern QMenu* branchXLinksContextMenuEdit;
135 extern QMenu* branchXLinksContextMenuFollow;
136 extern QMenu* floatimageContextMenu;
137 extern QMenu* canvasContextMenu;
138 extern QMenu* fileLastMapsMenu;
139 extern QMenu* fileImportMenu;
140 extern QMenu* fileExportMenu;
143 extern Settings settings;
144 extern Options options;
145 extern ImageIO imageIO;
147 extern QDir vymBaseDir;
148 extern QDir lastImageDir;
149 extern QDir lastFileDir;
150 extern QString iconPath;
151 extern QString flagsPath;
153 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
154 QMainWindow(parent,name,f)
158 setCaption ("VYM - View Your Mind");
160 // Load window settings
161 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
162 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
165 // Create unique temporary directory
166 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
168 // Create direcctory for clipboard
169 clipboardDir=tmpVymDir+"/clipboard";
170 QDir d(clipboardDir);
171 d.mkdir (clipboardDir,true);
172 makeSubDirs (clipboardDir);
177 // FIXME not used currently
178 // Set random seed (random used for object IDs)
179 // QTime t = QTime::currentTime(); // set random seed
180 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
183 // Initialize some settings, which are platform dependant
186 // application to open URLs
187 p="/mainwindow/readerURL";
188 #if defined(Q_OS_LINUX)
189 s=settings.value (p,"konqueror").toString();
191 #if defined(Q_OS_MACX)
192 s=settings.value (p,"/usr/bin/open").toString();
194 s=settings.value (p,"mozilla");
197 settings.setValue( p,s);
199 // application to open PDFs
200 p="/mainwindow/readerPDF";
201 #if defined(Q_OS_LINUX)
202 s=settings.value (p,"acroread").toString();
204 #if defined(Q_OS_MACX)
205 s=settings.value (p,"/usr/bin/open").toString();
207 s=settings.value (p,"acroread").toString();
210 settings.setValue( p,s);
215 // Create tab widget which holds the maps
216 tabWidget= new QTabWidget (this);
217 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
218 this, SLOT( editorChanged( QWidget * ) ) );
220 lineedit=new QLineEdit (this);
223 setCentralWidget(tabWidget);
227 setupFormatActions();
231 setupSettingsActions();
233 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
238 restoreState (settings.value("/mainwindow/state",0).toByteArray());
240 // Initialize Find window
241 findWindow=new FindWindow(NULL,"findwindow");
242 connect (findWindow, SIGNAL( findButton(QString) ),
243 this, SLOT(editFind(QString) ) );
244 connect (findWindow, SIGNAL( somethingChanged() ),
245 this, SLOT(editFindChanged() ) );
247 // Connect TextEditor, so that we can update flags if text changes
248 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
256 settings.setValue ( "/mainwindow/geometry/size", size() );
257 settings.setValue ( "/mainwindow/geometry/pos", pos() );
259 settings.setValue ("/mainwindow/state",saveState(0));
261 settings.setValue( "/version/version", __VYM_VERSION );
262 settings.setValue( "/version/builddate", __BUILD_DATE );
264 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoselectHeading->isOn() );
265 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoselectText->isOn() );
266 settings.setValue( "/mapeditor/editmode/pasteNewHeading",actionSettingsPasteNewHeading->isOn() );
267 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoedit->isOn() );
268 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
269 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
270 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
273 int maps=lastMaps.count();
274 settings.setValue( "/lastMaps/number",maps );
275 for (int i=1;i<=maps;i++)
277 s=QString("/lastMaps/map-%1").arg(i);
278 if (!s.isEmpty() && i<=maxLastMaps)
279 settings.setValue (s, lastMaps.at(i-1));
283 // To make the texteditor save its settings, call the destructor
286 // Remove temporary directory
287 removeDir (QDir(tmpVymDir));
290 void Main::loadCmdLine()
292 /* TODO draw some kind of splashscreen while loading...
298 QStringList flist=options.getFileList();
299 QStringList::Iterator it=flist.begin();
301 while (it !=flist.end() )
303 fileLoad (*it, NewMap);
309 void Main::statusMessage(const QString &s)
311 statusBar()->message (s);
314 void Main::closeEvent (QCloseEvent* )
320 void Main::setupFileActions()
322 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
323 QToolBar *tb = addToolBar( tr ("&Map") );
326 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
327 a->setStatusTip ( tr( "New map","File menu" ) );
328 a->setShortcut ( Qt::CTRL + Qt::Key_N );
330 fileMenu->addAction (a);
331 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
333 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
334 a->setStatusTip (tr( "Open","File menu" ) );
335 a->setShortcut ( Qt::CTRL + Qt::Key_O );
337 fileMenu->addAction (a);
338 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
340 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
341 fileMenu->addSeparator();
343 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
344 a->setStatusTip ( tr( "Save" ));
345 a->setShortcut (Qt::CTRL + Qt::Key_S );
347 fileMenu->addAction (a);
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
351 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
352 a->setStatusTip (tr( "Save &As" ) );
353 fileMenu->addAction (a);
354 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
356 fileMenu->addSeparator();
358 fileImportMenu = fileMenu->addMenu (tr("Import"));
360 a = new QAction(tr("KDE Bookmarks"), this);
361 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
362 a->addTo (fileImportMenu);
363 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
365 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
367 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
368 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
369 a->addTo (fileImportMenu);
370 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
373 a = new QAction("Mind Manager...",this);
374 a->setStatusTip ( tr( "Import")+" Mind Manager" );
375 fileImportMenu->addAction (a);
376 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
378 a = new QAction( tr( "Import Dir"+QString("...") ), this);
379 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
380 fileImportMenu->addAction (a);
381 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
383 fileExportMenu = fileMenu->addMenu (tr("Export"));
385 a = new QAction( tr("Image")+QString("..."), this);
386 a->setStatusTip( tr( "Export map as image" ));
387 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
388 fileExportMenu->addAction (a);
390 a = new QAction( "Open Office"+QString("..."), this);
391 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
393 fileExportMenu->addAction (a);
395 a = new QAction( "Webpage (XHTML)...",this );
396 a->setShortcut (Qt::ALT + Qt::Key_X);
397 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
398 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
399 fileExportMenu->addAction (a);
401 a = new QAction( "Text (ASCII)...", this);
402 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
403 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
404 fileExportMenu->addAction (a);
406 a = new QAction( tr("KDE Bookmarks"), this);
407 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
408 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
409 fileExportMenu->addAction (a);
411 a = new QAction( "Taskjuggler...", this );
412 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
413 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
414 fileExportMenu->addAction (a);
416 a = new QAction( "LaTeX...", this);
417 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
418 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
419 fileExportMenu->addAction (a);
421 a = new QAction( "XML..." , this );
422 a->setStatusTip (tr( "Export as")+" XML");
423 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
424 fileExportMenu->addAction (a);
426 fileMenu->addSeparator();
428 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
429 a->setStatusTip ( tr( "Print" ) );
430 a->setShortcut (Qt::CTRL + Qt::Key_P );
432 fileMenu->addAction (a);
433 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
436 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
437 a->setStatusTip (tr( "Close Map" ) );
438 a->setShortcut (Qt::ALT + Qt::Key_C );
439 fileMenu->addAction (a);
440 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
442 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
443 a->setStatusTip ( tr( "Exit")+" "+__VYM );
444 a->setShortcut (Qt::CTRL + Qt::Key_Q );
445 fileMenu->addAction (a);
446 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
451 void Main::setupEditActions()
453 QToolBar *tb = addToolBar( tr ("&Actions") );
454 tb->setLabel( "Edit Actions" );
455 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
459 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
460 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
461 a->setStatusTip (tr( "Undo" ) );
462 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
463 a->setEnabled (false);
465 editMenu->addAction (a);
468 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
469 a->setStatusTip (tr( "Redo" ));
470 a->setShortcut (Qt::CTRL + Qt::Key_Y );
472 editMenu->addAction (a);
473 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
476 editMenu->addSeparator();
477 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
478 a->setStatusTip ( tr( "Copy" ) );
479 a->setShortcut (Qt::CTRL + Qt::Key_C );
480 a->setEnabled (false);
482 editMenu->addAction (a);
483 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
486 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
487 a->setStatusTip ( tr( "Cut" ) );
488 a->setShortcut (Qt::CTRL + Qt::Key_X );
489 a->setEnabled (false);
491 editMenu->addAction (a);
493 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
495 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
496 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
497 a->setStatusTip ( tr( "Paste" ) );
498 a->setShortcut ( Qt::CTRL + Qt::Key_V );
499 a->setEnabled (false);
501 editMenu->addAction (a);
504 // Shortcuts to modify heading:
505 a = new QAction(tr( "Edit heading" ),this);
506 a->setStatusTip ( tr( "edit Heading" ));
507 a->setShortcut ( Qt::Key_Enter);
508 // a->setShortcutContext (Qt::WindowShortcut);
510 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
511 actionListBranches.append(a);
512 a = new QAction( tr( "Edit heading" ), this);
513 a->setStatusTip (tr( "edit Heading" ));
514 a->setShortcut (Qt::Key_Return );
515 //a->setShortcutContext (Qt::WindowShortcut);
517 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
518 actionListBranches.append(a);
519 editMenu->addAction (a);
521 a = new QAction( tr( "Edit heading" ), this);
522 a->setStatusTip (tr( "edit Heading" ));
523 a->setShortcut ( Qt::Key_F2 );
524 a->setShortcutContext (Qt::WindowShortcut);
526 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
527 actionListBranches.append(a);
529 // Shortcut to delete selection
530 a = new QAction( tr( "Delete Selection" ),this);
531 a->setStatusTip (tr( "Delete Selection" ));
532 a->setShortcut ( Qt::Key_Delete);
533 a->setShortcutContext (Qt::WindowShortcut);
535 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
538 // Shortcut to add branch
539 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
540 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
541 alt->setShortcut (Qt::Key_A);
542 alt->setShortcutContext (Qt::WindowShortcut);
544 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
545 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
546 a->setStatusTip ( tr( "Add a branch as child of selection" ));
547 a->setShortcut (Qt::Key_Insert);
548 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
549 actionListBranches.append(a);
550 #if defined (Q_OS_MACX)
551 // In OSX show different shortcut in menues, the keys work indepently always
552 actionEditAddBranch=alt;
554 actionEditAddBranch=a;
556 editMenu->addAction (actionEditAddBranch);
557 tb->addAction (actionEditAddBranch);
560 // Add branch by inserting it at selection
561 a = new QAction(tr( "Add branch (insert)" ), this);
562 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
563 a->setShortcut (Qt::ALT + Qt::Key_Insert );
564 a->setShortcutContext (Qt::WindowShortcut);
566 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
567 a->setEnabled (false);
568 actionListBranches.append(a);
569 actionEditAddBranchHere=a;
570 a = new QAction(tr( "Add branch (insert)" ),this);
571 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
572 a->setShortcut ( Qt::ALT + Qt::Key_A );
573 a->setShortcutContext (Qt::WindowShortcut);
575 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
576 actionListBranches.append(a);
579 a = new QAction(tr( "Add branch above" ), this);
580 a->setStatusTip ( tr( "Add a branch above selection" ));
581 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
582 a->setShortcutContext (Qt::WindowShortcut);
584 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
585 a->setEnabled (false);
586 actionListBranches.append(a);
587 actionEditAddBranchAbove=a;
588 a = new QAction(tr( "Add branch above" ), this);
589 a->setStatusTip ( tr( "Add a branch above selection" ));
590 a->setShortcut (Qt::SHIFT+Qt::Key_A );
591 a->setShortcutContext (Qt::WindowShortcut);
593 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
594 actionListBranches.append(a);
597 a = new QAction(tr( "Add branch below" ), this);
598 a->setStatusTip ( tr( "Add a branch below selection" ));
599 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
600 a->setShortcutContext (Qt::WindowShortcut);
602 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
603 a->setEnabled (false);
604 actionListBranches.append(a);
605 actionEditAddBranchBelow=a;
606 a = new QAction(tr( "Add branch below" ), this);
607 a->setStatusTip ( tr( "Add a branch below selection" ));
608 a->setShortcut (Qt::CTRL +Qt::Key_A );
609 a->setShortcutContext (Qt::WindowShortcut);
611 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
612 actionListBranches.append(a);
614 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
615 a->setStatusTip ( tr( "Move branch up" ) );
616 a->setShortcut (Qt::Key_PageUp );
617 a->setEnabled (false);
619 editMenu->addAction (a);
620 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
623 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
624 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
625 a->setStatusTip (tr( "Move branch down" ) );
626 a->setShortcut ( Qt::Key_PageDown );
627 a->setEnabled (false);
629 editMenu->addAction (a);
630 actionEditMoveDown=a;
633 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
634 a->setShortcut ( Qt::Key_ScrollLock );
635 a->setStatusTip (tr( "Scroll branch" ) );
636 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
637 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
638 alt->setShortcut ( Qt::Key_S );
639 alt->setStatusTip (tr( "Scroll branch" ));
640 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
641 #if defined(Q_OS_MACX)
642 actionEditToggleScroll=alt;
644 actionEditToggleScroll=a;
646 actionEditToggleScroll->setEnabled (false);
647 actionEditToggleScroll->setToggleAction(true);
648 tb->addAction (actionEditToggleScroll);
649 editMenu->addAction ( actionEditToggleScroll);
650 editMenu->addAction (actionEditToggleScroll);
651 actionListBranches.append(actionEditToggleScroll);
653 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
654 a->setStatusTip (tr( "Unscroll all" ));
655 editMenu->addAction (a);
656 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
658 editMenu->addSeparator();
660 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
661 a->setStatusTip (tr( "Find" ) );
662 a->setShortcut (Qt::CTRL + Qt::Key_F );
663 editMenu->addAction (a);
664 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
666 editMenu->addSeparator();
668 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
669 a->setShortcut (Qt::CTRL + Qt::Key_U );
670 a->setShortcut (tr( "Open URL" ));
673 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
676 a = new QAction( tr( "Open URL in new tab" ), this);
677 a->setStatusTip (tr( "Open URL in new tab" ));
678 a->setShortcut (Qt::CTRL+Qt::Key_U );
680 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
681 actionEditOpenURLTab=a;
683 a = new QAction( tr( "Open all URLs in subtree" ), this);
684 a->setStatusTip (tr( "Open all URLs in subtree" ));
686 actionListBranches.append(a);
687 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
688 actionEditOpenMultipleURLTabs=a;
690 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
691 a->setStatusTip ( tr( "Edit URL" ) );
692 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
693 //a->setShortcut ( Qt::Key_U );
694 a->setShortcutContext (Qt::WindowShortcut);
695 actionListBranches.append(a);
697 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
700 a = new QAction( tr( "Use heading for URL" ), this);
701 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
702 a->setEnabled (false);
703 actionListBranches.append(a);
704 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
705 actionEditHeading2URL=a;
707 a = new QAction(tr( "Create URL to Bugzilla" ), this);
708 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
709 a->setEnabled (false);
710 actionListBranches.append(a);
711 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
712 actionEditBugzilla2URL=a;
714 a = new QAction(tr( "Create URL to FATE" ), this);
715 a->setStatusTip ( tr( "Create URL to FATE" ));
716 a->setEnabled (false);
717 actionListBranches.append(a);
718 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
719 actionEditFATE2URL=a;
721 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this);
722 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
724 a->setEnabled (false);
725 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
726 actionEditOpenVymLink=a;
728 a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this);
729 a->setStatusTip ( tr( "Open all vym links in subtree" ));
730 a->setEnabled (false);
731 actionListBranches.append(a);
732 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
733 actionEditOpenMultipleVymLinks=a;
736 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
737 a->setEnabled (false);
738 a->setStatusTip ( tr( "Edit link to another vym map" ));
739 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
740 actionListBranches.append(a);
743 a = new QAction(tr( "Delete vym link" ),this);
744 a->setStatusTip ( tr( "Delete link to another vym map" ));
745 a->setEnabled (false);
746 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
747 actionEditDeleteVymLink=a;
749 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
750 a->setStatusTip ( tr( "Hide object in exports" ) );
751 a->setShortcut (Qt::Key_H );
752 a->setToggleAction(true);
754 a->setEnabled (false);
755 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
756 actionEditToggleHideExport=a;
758 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
759 a->setStatusTip ( tr( "Edit Map Info" ));
760 a->setEnabled (true);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
764 editMenu->addSeparator();
766 // Import at selection (adding to selection)
767 a = new QAction( tr( "Add map (insert)" ),this);
768 a->setStatusTip (tr( "Add map at selection" ));
769 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
770 a->setEnabled (false);
771 actionListBranches.append(a);
772 actionEditImportAdd=a;
774 // Import at selection (replacing selection)
775 a = new QAction( tr( "Add map (replace)" ), this);
776 a->setStatusTip (tr( "Replace selection with map" ));
777 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
778 a->setEnabled (false);
779 actionListBranches.append(a);
780 actionEditImportReplace=a;
783 a = new QAction( tr( "Save selection" ), this);
784 a->setStatusTip (tr( "Save selection" ));
785 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
786 a->setEnabled (false);
787 actionListBranches.append(a);
788 actionEditSaveBranch=a;
790 // Only remove branch, not its childs
791 a = new QAction(tr( "Remove only branch " ), this);
792 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
793 a->setShortcut (Qt::ALT + Qt::Key_Delete );
794 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
795 a->setEnabled (false);
796 actionListBranches.append(a);
797 actionEditRemoveBranchKeepChilds=a;
799 // Only remove childs of a branch
800 a = new QAction( tr( "Remove childs" ), this);
801 a->setStatusTip (tr( "Remove childs of branch" ));
802 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
803 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
804 a->setEnabled (false);
805 actionListBranches.append(a);
806 actionEditRemoveChilds=a;
808 // Shortcuts for navigating with cursor:
809 a = new QAction(tr( "Select upper branch" ), this);
810 a->setStatusTip ( tr( "Select upper branch" ));
811 a->setShortcut (Qt::Key_Up );
812 a->setShortcutContext (Qt::WindowShortcut);
814 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
815 a = new QAction( tr( "Select lower branch" ),this);
816 a->setStatusTip (tr( "Select lower branch" ));
817 a->setShortcut ( Qt::Key_Down );
818 a->setShortcutContext (Qt::WindowShortcut);
820 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
821 a = new QAction(tr( "Select left branch" ), this);
822 a->setStatusTip ( tr( "Select left branch" ));
823 a->setShortcut (Qt::Key_Left );
824 a->setShortcutContext (Qt::WindowShortcut);
826 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
827 a = new QAction( tr( "Select child branch" ), this);
828 a->setStatusTip (tr( "Select right branch" ));
829 a->setShortcut (Qt::Key_Right);
830 a->setShortcutContext (Qt::WindowShortcut);
832 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
833 a = new QAction( tr( "Select first branch" ), this);
834 a->setStatusTip (tr( "Select first branch" ));
835 a->setShortcut (Qt::Key_Home );
836 a->setShortcutContext (Qt::WindowShortcut);
838 a->setEnabled (false);
839 editMenu->addAction (a);
840 actionListBranches.append(a);
841 actionEditSelectFirst=a;
842 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
843 a = new QAction( tr( "Select last branch" ),this);
844 a->setStatusTip (tr( "Select last branch" ));
845 a->setShortcut ( Qt::Key_End );
846 a->setShortcutContext (Qt::WindowShortcut);
848 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
849 a->setEnabled (false);
850 editMenu->addAction (a);
851 actionListBranches.append(a);
852 actionEditSelectLast=a;
854 a = new QAction( tr( "Add Image" )+QString("..."), this);
855 a->setStatusTip (tr( "Add Image" ));
856 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
857 actionEditLoadImage=a;
862 void Main::setupFormatActions()
864 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
866 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
869 pix.fill (Qt::black);
870 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
871 a->setStatusTip ( tr( "Set Color" ));
872 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
874 formatMenu->addAction (a);
876 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
877 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
878 a->setShortcut (Qt::CTRL + Qt::Key_K );
879 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
880 a->setEnabled (false);
882 formatMenu->addAction (a);
883 actionListBranches.append(a);
884 actionFormatPickColor=a;
886 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
887 a->setStatusTip ( tr( "Color branch" ) );
888 a->setShortcut (Qt::CTRL + Qt::Key_I);
889 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
890 a->setEnabled (false);
892 formatMenu->addAction (a);
893 actionListBranches.append(a);
894 actionFormatColorBranch=a;
896 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
897 a->setStatusTip ( tr( "Color Subtree" ));
898 a->setShortcut (Qt::CTRL + Qt::Key_T);
899 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
900 a->setEnabled (false);
901 formatMenu->addAction (a);
903 actionListBranches.append(a);
904 actionFormatColorSubtree=a;
906 formatMenu->addSeparator();
907 actionGroupFormatLinkStyles=new QActionGroup ( this);
908 actionGroupFormatLinkStyles->setExclusive (true);
909 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
910 a->setStatusTip (tr( "Line" ));
911 a->setToggleAction(true);
912 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
913 formatMenu->addAction (a);
914 actionFormatLinkStyleLine=a;
915 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
916 a->setStatusTip (tr( "Line" ));
917 a->setToggleAction(true);
918 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
919 formatMenu->addAction (a);
920 actionFormatLinkStyleParabel=a;
921 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
922 a->setStatusTip (tr( "PolyLine" ));
923 a->setToggleAction(true);
924 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
925 formatMenu->addAction (a);
926 actionFormatLinkStylePolyLine=a;
927 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
928 a->setStatusTip (tr( "PolyParabel" ) );
929 a->setToggleAction(true);
930 a->setChecked (true);
931 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
932 formatMenu->addAction (a);
933 actionFormatLinkStylePolyParabel=a;
935 actionGroupFormatFrameTypes=new QActionGroup ( this);
936 actionGroupFormatFrameTypes->setExclusive (true);
937 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
938 a->setStatusTip (tr("No Frame"));
939 a->setToggleAction(true);
940 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
941 actionFormatFrameNone=a;
942 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
943 a->setStatusTip (tr( "Rectangle" ));
944 a->setToggleAction(true);
945 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
946 actionFormatFrameRectangle=a;
948 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
949 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
950 a->setToggleAction(true);
951 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
952 actionFormatIncludeImagesVer=a;
954 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
955 a->setStatusTip ( tr ("Include left and right position of images into branch"));
956 a->setToggleAction(true);
957 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
958 actionFormatIncludeImagesHor=a;
960 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
961 a->setStatusTip (tr( "Hide link" ));
962 a->setToggleAction(true);
963 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
964 actionFormatHideLinkUnselected=a;
966 formatMenu->addSeparator();
967 a= new QAction( tr( "&Use color of heading for link" ), this);
968 a->setStatusTip (tr( "Use same color for links and headings" ));
969 a->setToggleAction(true);
970 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
971 formatMenu->addAction (a);
972 actionFormatLinkColorHint=a;
974 pix.fill (Qt::white);
975 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
976 a->setStatusTip (tr( "Set Link Color" ));
977 formatMenu->addAction (a);
978 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
979 actionFormatLinkColor=a;
981 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
982 a->setStatusTip (tr( "Set Background Color" ));
983 formatMenu->addAction (a);
984 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
985 actionFormatBackColor=a;
989 void Main::setupViewActions()
991 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
992 tb->setLabel( "View Actions" );
993 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
996 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
997 a->setStatusTip ( tr( "Zoom reset" ) );
998 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1000 viewMenu->addAction (a);
1001 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1003 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
1004 a->setStatusTip (tr( "Zoom in" ));
1005 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1007 viewMenu->addAction (a);
1008 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1010 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
1011 a->setStatusTip (tr( "Zoom out" ));
1012 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1014 viewMenu->addAction (a);
1015 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1018 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1019 a->setStatusTip ( tr( "Show Note Editor" ));
1020 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1021 a->setToggleAction(true);
1022 if (textEditor->showWithMain())
1027 viewMenu->addAction (a);
1028 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1029 actionViewToggleNoteEditor=a;
1031 a = new QAction( tr( "Show history window" ),this );
1032 a->setStatusTip ( tr( "Show history window" ));
1033 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1034 a->setToggleAction(false);
1035 viewMenu->addAction (a);
1036 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1037 actionViewToggleHistoryWindow=a;
1039 a = new QAction(tr( "Next Window" ), this);
1040 a->setStatusTip ( tr( "&Next Window" ) );
1041 a->setShortcut (Qt::ALT + Qt::Key_N );
1042 viewMenu->addAction (a);
1043 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1045 a = new QAction (tr( "Previous Window" ), this );
1046 a->setStatusTip (tr( "&Previous Window" ));
1047 a->setShortcut (Qt::ALT + Qt::Key_P );
1048 viewMenu->addAction (a);
1049 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1053 void Main::setupModeActions()
1055 //QPopupMenu *menu = new QPopupMenu( this );
1056 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1058 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1060 actionGroupModModes=new QActionGroup ( this);
1061 actionGroupModModes->setExclusive (true);
1062 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1063 a->setShortcut (Qt::Key_J);
1064 a->setStatusTip ( tr( "Use modifier to color branches" ));
1065 a->setToggleAction(true);
1068 actionModModeColor=a;
1070 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1071 a->setShortcut( Qt::Key_K);
1072 a->setStatusTip( tr( "Use modifier to copy" ));
1073 a->setToggleAction(true);
1075 actionModModeCopy=a;
1077 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1078 a->setShortcut (Qt::Key_L);
1079 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1080 a->setToggleAction(true);
1082 actionModModeLink=a;
1086 void Main::setupFlagActions()
1088 // Create System Flags
1089 systemFlagsDefault = new FlagRowObj ();
1090 systemFlagsDefault->setVisibility (false);
1091 systemFlagsDefault->setName ("systemFlagsDef");
1093 FlagObj *fo = new FlagObj ();
1094 fo->load(QPixmap(flagsPath+"flag-note.png"));
1095 fo->setName("note");
1096 fo->setToolTip(tr("Note","Systemflag"));
1097 systemFlagsDefault->addFlag (fo); // makes deep copy
1099 fo->load(QPixmap(flagsPath+"flag-url.png"));
1101 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1102 systemFlagsDefault->addFlag (fo);
1104 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1105 fo->setName("vymLink");
1106 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1107 systemFlagsDefault->addFlag (fo);
1109 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1110 fo->setName("scrolledright");
1111 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1112 systemFlagsDefault->addFlag (fo);
1114 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1115 fo->setName("tmpUnscrolledright");
1116 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1117 systemFlagsDefault->addFlag (fo);
1119 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1120 fo->setName("hideInExport");
1121 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1122 systemFlagsDefault->addFlag (fo);
1124 // Create Standard Flags
1125 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1126 //FIXMEtoolbars.add (tb);
1128 standardFlagsDefault = new FlagRowObj ();
1129 standardFlagsDefault->setVisibility (false);
1130 standardFlagsDefault->setName ("standardFlagsDef");
1131 standardFlagsDefault->setToolBar (tb);
1132 tb->setObjectName ("standardFlagTB");
1134 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1135 fo->setName ("exclamationmark");
1136 fo->setGroup("standard-mark");
1137 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1140 a->setCheckable(true);
1141 a->setObjectName(fo->getName());
1142 a->setToolTip(tr("Take care!","Standardflag"));
1143 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1144 standardFlagsDefault->addFlag (fo); // makes deep copy
1146 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1147 fo->setName("questionmark");
1148 fo->setGroup("standard-mark");
1149 a=new QAction (fo->getPixmap(),fo->getName(),this);
1152 a->setCheckable(true);
1153 a->setObjectName(fo->getName());
1154 a->setToolTip(tr("Really?","Standardflag"));
1155 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1156 standardFlagsDefault->addFlag (fo);
1158 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1159 fo->setName("hook-green");
1160 fo->setGroup("standard-hook");
1161 a=new QAction (fo->getPixmap(),fo->getName(),this);
1164 a->setCheckable(true);
1165 a->setObjectName(fo->getName());
1166 a->setToolTip(tr("ok!","Standardflag"));
1167 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1168 standardFlagsDefault->addFlag (fo);
1170 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1171 fo->setName("cross-red");
1172 fo->setGroup("standard-hook");
1173 a=new QAction (fo->getPixmap(),fo->getName(),this);
1176 a->setCheckable(true);
1177 a->setObjectName(fo->getName());
1178 a->setToolTip(tr("Not ok!","Standardflag"));
1179 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1180 standardFlagsDefault->addFlag (fo);
1182 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1183 fo->setName("stopsign");
1184 a=new QAction (fo->getPixmap(),fo->getName(),this);
1187 a->setCheckable(true);
1188 a->setObjectName(fo->getName());
1189 a->setToolTip(tr("This won't work!","Standardflag"));
1190 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1191 standardFlagsDefault->addFlag (fo);
1193 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1194 fo->setName("smiley-good");
1195 fo->setGroup("standard-smiley");
1196 a=new QAction (fo->getPixmap(),fo->getName(),this);
1199 a->setCheckable(true);
1200 a->setObjectName(fo->getName());
1201 a->setToolTip(tr("Good","Standardflag"));
1202 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1203 standardFlagsDefault->addFlag (fo);
1205 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1206 fo->setName("smiley-sad");
1207 fo->setGroup("standard-smiley");
1208 a=new QAction (fo->getPixmap(),fo->getName(),this);
1211 a->setCheckable(true);
1212 a->setObjectName(fo->getName());
1213 a->setToolTip(tr("Bad","Standardflag"));
1214 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1215 standardFlagsDefault->addFlag (fo);
1217 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1218 // Original omg.png (in KDE emoticons)
1219 fo->setName("smiley-omg");
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("Oh no!","Standardflag"));
1227 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1228 standardFlagsDefault->addFlag (fo);
1230 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1231 fo->setName("clock");
1232 a=new QAction (fo->getPixmap(),fo->getName(),this);
1235 a->setCheckable(true);
1236 a->setObjectName(fo->getName());
1237 a->setToolTip(tr("Time critical","Standardflag"));
1238 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1239 standardFlagsDefault->addFlag (fo);
1241 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1242 fo->setName("phone");
1243 a=new QAction (fo->getPixmap(),fo->getName(),this);
1246 a->setCheckable(true);
1247 a->setObjectName(fo->getName());
1248 a->setToolTip(tr("Call...","Standardflag"));
1249 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1250 standardFlagsDefault->addFlag (fo);
1252 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1253 fo->setName("lamp");
1254 a=new QAction (fo->getPixmap(),fo->getName(),this);
1257 a->setCheckable(true);
1258 a->setObjectName(fo->getName());
1259 a->setToolTip(tr("Idea!","Standardflag"));
1260 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1261 standardFlagsDefault->addFlag (fo);
1263 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1264 fo->setName("arrow-up");
1265 fo->setGroup("standard-arrow");
1266 a=new QAction (fo->getPixmap(),fo->getName(),this);
1269 a->setCheckable(true);
1270 a->setObjectName(fo->getName());
1271 a->setToolTip(tr("Important","Standardflag"));
1272 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1273 standardFlagsDefault->addFlag (fo);
1275 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1276 fo->setName("arrow-down");
1277 fo->setGroup("standard-arrow");
1278 a=new QAction (fo->getPixmap(),fo->getName(),this);
1281 a->setCheckable(true);
1282 a->setObjectName(fo->getName());
1283 a->setToolTip(tr("Unimportant","Standardflag"));
1284 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1285 standardFlagsDefault->addFlag (fo);
1287 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1288 fo->setName("2arrow-up");
1289 fo->setGroup("standard-arrow");
1290 a=new QAction (fo->getPixmap(),fo->getName(),this);
1293 a->setCheckable(true);
1294 a->setObjectName(fo->getName());
1295 a->setToolTip(tr("Very important!","Standardflag"));
1296 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1297 standardFlagsDefault->addFlag (fo);
1299 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1300 fo->setName("2arrow-down");
1301 fo->setGroup("standard-arrow");
1302 a=new QAction (fo->getPixmap(),fo->getName(),this);
1305 a->setCheckable(true);
1306 a->setObjectName(fo->getName());
1307 a->setToolTip(tr("Very unimportant!","Standardflag"));
1308 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1309 standardFlagsDefault->addFlag (fo);
1311 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1312 fo->setName("thumb-up");
1313 fo->setGroup("standard-thumb");
1314 a=new QAction (fo->getPixmap(),fo->getName(),this);
1317 a->setCheckable(true);
1318 a->setObjectName(fo->getName());
1319 a->setToolTip(tr("I like this","Standardflag"));
1320 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1321 standardFlagsDefault->addFlag (fo);
1323 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1324 fo->setName("thumb-down");
1325 fo->setGroup("standard-thumb");
1326 a=new QAction (fo->getPixmap(),fo->getName(),this);
1329 a->setCheckable(true);
1330 a->setObjectName(fo->getName());
1331 a->setToolTip(tr("I do not like this","Standardflag"));
1332 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1333 standardFlagsDefault->addFlag (fo);
1335 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1336 fo->setName("rose");
1337 a=new QAction (fo->getPixmap(),fo->getName(),this);
1340 a->setCheckable(true);
1341 a->setObjectName(fo->getName());
1342 a->setToolTip(tr("Rose","Standardflag"));
1343 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1344 standardFlagsDefault->addFlag (fo);
1346 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1347 fo->setName("heart");
1348 a=new QAction (fo->getPixmap(),fo->getName(),this);
1350 a->setCheckable(true);
1351 a->setObjectName(fo->getName());
1352 a->setToolTip(tr("I just love... ","Standardflag"));
1353 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1354 standardFlagsDefault->addFlag (fo);
1356 fo->load(QPixmap(flagsPath+"flag-present.png"));
1357 fo->setName("present");
1358 a=new QAction (fo->getPixmap(),fo->getName(),this);
1361 a->setCheckable(true);
1362 a->setObjectName(fo->getName());
1363 a->setToolTip(tr("Surprise!","Standardflag"));
1364 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1365 standardFlagsDefault->addFlag (fo);
1367 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1368 fo->setName("flash");
1369 a=new QAction (fo->getPixmap(),fo->getName(),this);
1372 a->setCheckable(true);
1373 a->setObjectName(fo->getName());
1374 a->setToolTip(tr("Dangerous","Standardflag"));
1375 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1376 standardFlagsDefault->addFlag (fo);
1378 fo->load(QPixmap(flagsPath+"flag-info.png"));
1379 // Original: xsldbg_output.png
1380 fo->setName("info");
1381 a=new QAction (fo->getPixmap(),fo->getName(),this);
1384 a->setCheckable(true);
1385 a->setObjectName(fo->getName());
1386 a->setToolTip(tr("Info","Standardflag"));
1387 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1388 standardFlagsDefault->addFlag (fo);
1390 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1391 // Original khelpcenter.png
1392 fo->setName("lifebelt");
1393 a=new QAction (fo->getPixmap(),fo->getName(),this);
1396 a->setCheckable(true);
1397 a->setObjectName(fo->getName());
1398 a->setToolTip(tr("This will help","Standardflag"));
1399 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1400 standardFlagsDefault->addFlag (fo);
1406 void Main::setupSettingsActions()
1408 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1412 a = new QAction( tr( "Set application to open pdf files"), this);
1413 a->setStatusTip ( tr( "Set application to open pdf files"));
1414 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1415 settingsMenu->addAction (a);
1417 a = new QAction( tr( "Set application to open external links"), this);
1418 a->setStatusTip( tr( "Set application to open external links"));
1419 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1420 settingsMenu->addAction (a);
1422 settingsMenu->addSeparator();
1423 a = new QAction( tr( "Edit branch after adding it" ), this );
1424 a->setStatusTip( tr( "Edit branch after adding it" ));
1425 a->setToggleAction(true);
1426 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1427 settingsMenu->addAction (a);
1428 actionSettingsAutoedit=a;
1430 a= new QAction( tr( "Select branch after adding it" ), this );
1431 a->setStatusTip( tr( "Select branch after adding it" ));
1432 a->setToggleAction(true);
1433 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1434 settingsMenu->addAction (a);
1435 actionSettingsAutoselectHeading=a;
1437 a= new QAction(tr( "Select existing heading" ), this);
1438 a->setStatusTip( tr( "Select heading before editing" ));
1439 a->setToggleAction(true);
1440 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1441 settingsMenu->addAction (a);
1442 actionSettingsAutoselectText=a;
1444 a= new QAction(tr( "pasting into new branch" ), this );
1445 a->setStatusTip( tr( "Pasting into new branch" ));
1446 a->setToggleAction(true);
1447 a->setOn ( settings.value ("/mapeditor/editmode/newHeadingIsEmpty",true).toBool() );
1448 settingsMenu->addAction (a);
1449 actionSettingsPasteNewHeading=a;
1451 a= new QAction( tr( "Delete key" ), this);
1452 a->setStatusTip( tr( "Delete key for deleting branches" ));
1453 a->setToggleAction(true);
1454 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1455 settingsMenu->addAction (a);
1456 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1457 actionSettingsUseDelKey=a;
1459 a= new QAction( tr( "Exclusive flags" ), this);
1460 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1461 a->setToggleAction(true);
1462 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1463 settingsMenu->addAction (a);
1464 actionSettingsUseFlagGroups=a;
1466 a= new QAction( tr( "Use hide flags" ), this);
1467 a->setStatusTip( tr( "Use hide flag during exports " ));
1468 a->setToggleAction(true);
1469 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1470 settingsMenu->addAction (a);
1471 actionSettingsUseHideExport=a;
1475 void Main::setupTestActions()
1477 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1480 a = new QAction( tr( "test flag" ), this);
1481 a->setStatusTip( tr( "Call test function" ));
1482 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1483 testMenu->addAction (a);
1487 void Main::setupHelpActions()
1489 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1492 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1493 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1494 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1495 helpMenu->addAction (a);
1497 a = new QAction( tr( "About VYM" ), this);
1498 a->setStatusTip( tr( "About VYM")+" "__VYM);
1499 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1500 helpMenu->addAction (a);
1502 a = new QAction( tr( "About QT" ), this);
1503 a->setStatusTip( tr( "Information about QT toolkit" ));
1504 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1505 helpMenu->addAction (a);
1509 void Main::setupContextMenus()
1513 // Context Menu for branch or mapcenter
1514 branchContextMenu =new QMenu (this);
1517 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1518 branchAddContextMenu->addAction (actionEditPaste );
1519 branchAddContextMenu->addAction ( actionEditAddBranch );
1520 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1521 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1522 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1523 branchAddContextMenu->addSeparator();
1524 branchAddContextMenu->addAction ( actionEditLoadImage);
1525 branchAddContextMenu->addSeparator();
1526 branchAddContextMenu->addAction ( actionEditImportAdd );
1527 branchAddContextMenu->addAction ( actionEditImportReplace );
1530 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1531 branchRemoveContextMenu->addAction (actionEditCut);
1532 branchRemoveContextMenu->addAction ( actionEditDelete );
1533 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1534 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1537 actionEditSaveBranch->addTo( branchContextMenu );
1539 branchContextMenu->addSeparator();
1540 branchContextMenu->addAction ( actionFormatFrameNone );
1541 branchContextMenu->addAction ( actionFormatFrameRectangle);
1543 branchContextMenu->addSeparator();
1544 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1545 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1546 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1548 // Submenu for Links (URLs, vymLinks)
1549 branchLinksContextMenu =new QMenu (this);
1551 branchContextMenu->addSeparator();
1552 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));
1553 branchLinksContextMenu->addAction ( actionEditOpenURL );
1554 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1555 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1556 branchLinksContextMenu->addAction ( actionEditURL );
1557 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1558 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1559 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1561 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1563 branchLinksContextMenu->addSeparator();
1564 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1565 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1566 branchLinksContextMenu->addAction ( actionEditVymLink );
1567 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1570 // Context Menu for XLinks in a branch menu
1571 // This will be populated "on demand" in MapEditor::updateActions
1572 branchContextMenu->addSeparator();
1573 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1574 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1575 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1576 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1579 // Context menu for floatimage
1580 floatimageContextMenu =new QMenu (this);
1581 a= new QAction (tr ("Save image"),this);
1582 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1583 floatimageContextMenu->addAction (a);
1585 floatimageContextMenu->addSeparator();
1586 actionEditCopy->addTo( floatimageContextMenu );
1587 actionEditCut->addTo( floatimageContextMenu );
1589 floatimageContextMenu->addSeparator();
1590 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1593 // Context menu for canvas
1594 canvasContextMenu =new QMenu (this);
1595 actionEditMapInfo->addTo( canvasContextMenu );
1596 canvasContextMenu->insertSeparator();
1597 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1598 canvasContextMenu->insertSeparator();
1599 actionFormatLinkColorHint->addTo( canvasContextMenu );
1600 actionFormatLinkColor->addTo( canvasContextMenu );
1601 actionFormatBackColor->addTo( canvasContextMenu );
1603 // Menu for last opened files
1604 // Read settings initially
1606 int j=settings.readNumEntry( "/lastMaps/number",0);
1607 for (int i=1;i<=j;i++)
1609 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1610 if (!s.isEmpty() && j<=maxLastMaps)
1613 setupLastMapsMenu();
1614 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1617 void Main::setupLastMapsMenu()
1619 // Remove double entries
1620 QStringList::Iterator it=lastMaps.begin();
1621 QStringList::Iterator jt;
1622 while (it!=lastMaps.end() )
1626 while (jt!=lastMaps.end() )
1629 jt=lastMaps.remove(jt);
1636 // Limit length of list to maxLastMaps
1637 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1639 // build Menu from lastMaps string list
1640 fileLastMapsMenu->clear();
1641 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1642 fileLastMapsMenu->addAction (*it );
1645 void Main::hideEvent (QHideEvent * )
1647 if (!textEditor->isMinimized() ) textEditor->hide();
1650 void Main::showEvent (QShowEvent * )
1652 if (textEditor->showWithMain()) textEditor->showNormal();
1655 bool Main::reallyWriteDirectory(const QString &dir)
1657 QStringList eList = QDir(dir).entryList();
1658 if (eList.first() ==".") eList.pop_front(); // remove "."
1659 if (eList.first() =="..") eList.pop_front(); // remove "."
1660 if (!eList.isEmpty())
1662 QMessageBox mb( __VYM,
1663 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1664 QMessageBox::Warning,
1666 QMessageBox::Cancel | QMessageBox::Default,
1667 QMessageBox::QMessageBox::NoButton );
1669 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1670 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1673 case QMessageBox::Yes:
1676 case QMessageBox::Cancel:
1684 QString Main::browseDirectory (const QString &caption)
1686 Q3FileDialog fd(this,caption);
1687 fd.setMode (Q3FileDialog::DirectoryOnly);
1688 fd.setCaption(__VYM " - "+caption);
1691 if ( fd.exec() == QDialog::Accepted )
1692 return fd.selectedFile();
1697 MapEditor* Main::currentMapEditor() const
1699 if ( tabWidget->currentPage() &&
1700 tabWidget->currentPage()->inherits( "MapEditor" ) )
1701 return (MapEditor*)tabWidget->currentPage();
1705 //TODO not used now, maybe use this for overview window later
1706 void Main::newView()
1708 // Open a new view... have it delete when closed.
1709 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1710 qApp->setMainWidget(m);
1712 qApp->setMainWidget(0);
1715 void Main::editorChanged(QWidget *)
1717 // Unselect all possibly selected objects
1718 // (Important to update note editor)
1721 for (i=0;i<=tabWidget->count() -1;i++)
1724 me=(MapEditor*)tabWidget->page(i);
1727 currentMapEditor()->reselect();
1729 // Update actions to in menus and toolbars according to editor
1730 currentMapEditor()->updateActions();
1733 void Main::fileNew()
1735 QString fn="unnamed";
1736 MapEditor* medit = new MapEditor ( NULL,true);
1737 tabWidget->addTab (medit,fn);
1738 tabWidget->showPage(medit);
1739 medit->viewport()->setFocus();
1740 // For the very first map we do not have flagrows yet...
1741 medit->select("mc:");
1744 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1746 ErrorCode err=success;
1748 // fn is usually the archive, mapfile the file after uncompressing
1751 // Make fn absolute (needed for unzip)
1752 fn=QDir (fn).absPath();
1758 // Check, if map is already loaded
1760 while (i<=tabWidget->count() -1)
1762 me=(MapEditor*)tabWidget->page(i);
1763 if (me->getFilePath() == fn)
1765 // Already there, ask for confirmation
1766 QMessageBox mb( __VYM,
1767 tr("The map %1\nis already opened."
1768 "Opening the same map in multiple editors may lead \n"
1769 "to confusion when finishing working with vym."
1770 "Do you want to").arg(fn),
1771 QMessageBox::Warning,
1772 QMessageBox::Yes | QMessageBox::Default,
1773 QMessageBox::Cancel | QMessageBox::Escape,
1774 QMessageBox::NoButton);
1775 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1776 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1779 case QMessageBox::Yes:
1781 i=tabWidget->count();
1783 case QMessageBox::Cancel:
1795 if ( !fn.isEmpty() )
1797 me = currentMapEditor();
1798 int tabIndex=tabWidget->currentPageIndex();
1799 // Check first, if mapeditor exists
1800 // If it is not default AND we want a new map,
1801 // create a new mapeditor in a new tab
1802 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1804 me= new MapEditor ( NULL,true);
1805 tabWidget->addTab (me,fn);
1806 tabIndex=tabWidget->indexOf (me);
1807 tabWidget->setCurrentPage (tabIndex);
1810 // Check, if file exists (important for creating new files
1811 // from command line
1812 if (!QFile(fn).exists() )
1814 QMessageBox mb( __VYM,
1815 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1816 QMessageBox::Question,
1818 QMessageBox::Cancel | QMessageBox::Default,
1819 QMessageBox::NoButton );
1821 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1822 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1825 case QMessageBox::Yes:
1827 currentMapEditor()->setFilePath(fn);
1828 tabWidget->setTabLabel (currentMapEditor(),
1829 currentMapEditor()->getFileName() );
1830 statusBar()->message( "Created " + fn , statusbarTime );
1833 case QMessageBox::Cancel:
1834 // don't create new map
1835 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1842 //tabWidget->currentPage() won't be NULL here, because of above...
1843 tabWidget->showPage(me);
1844 me->viewport()->setFocus();
1846 // Create temporary directory for packing
1847 char tmpdir1[]="/tmp/vym-XXXXXX";
1848 QString tmpMapDir=mkdtemp(tmpdir1);
1850 // Try to unzip file
1851 err=unzipDir (tmpMapDir,fn);
1855 me->setZipped(false);
1858 me->setZipped(true);
1860 // Look for mapname.xml
1861 mapfile= fn.left(fn.findRev(".",-1,true));
1862 mapfile=mapfile.section( '/', -1 );
1863 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1864 if (!file.exists() )
1866 // mapname.xml does not exist, well,
1867 // maybe some renamed the mapname.vym file...
1868 // Try to find any .xml in the toplevel
1869 // directory of the .vym file
1870 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1871 if (flist.count()==1)
1873 // Only one entry, take this one
1874 mapfile=tmpMapDir + "/"+flist.first();
1877 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1878 *it=tmpMapDir + "/" + *it;
1879 // TODO Multiple entries, load all (but only the first one into this ME)
1880 //mainWindow->fileLoadFromTmp (flist);
1881 //returnCode=1; // Silently forget this attempt to load
1882 qWarning ("MainWindow::load (fn) multimap found...");
1885 if (flist.isEmpty() )
1887 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1888 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1891 } //file doesn't exist
1893 mapfile=file.name();
1898 // Save existing filename in case we import
1899 QString fn_org=me->getFilePath();
1901 // Finally load map into mapEditor
1902 me->setFilePath (mapfile,fn);
1903 err=me->load(mapfile,lmode);
1905 // Restore old (maybe empty) filepath, if this is an import
1907 me->setFilePath (fn_org);
1910 // Finally check for errors and go home
1913 if (lmode==NewMap) fileCloseMap();
1914 statusBar()->message( "Could not load " + fn, statusbarTime );
1919 me->setFilePath (fn);
1920 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1921 if (fn.left(9)!="/tmp/vym-")
1923 // Only append to lastMaps if not loaded from a tmpDir
1924 // e.g. imported bookmarks are in a tmpDir
1925 lastMaps.prepend(me->getFilePath() );
1926 setupLastMapsMenu();
1928 actionFilePrint->setEnabled (true);
1930 statusBar()->message( "Loaded " + fn, statusbarTime );
1934 removeDir (QDir(tmpMapDir));
1940 void Main::fileLoad(const LoadMode &lmode)
1942 Q3FileDialog *fd=new Q3FileDialog( this);
1943 fd->setDir (lastFileDir);
1944 fd->setMode (Q3FileDialog::ExistingFiles);
1945 fd->addFilter ("XML (*.xml)");
1946 fd->addFilter ("VYM map (*.vym *.vyp)");
1950 fd->setCaption(tr("Load vym map"));
1953 fd->setCaption(tr("Import: Add vym map to selection"));
1956 fd->setCaption(tr("Import: Replace selection with vym map"));
1962 if ( fd->exec() == QDialog::Accepted )
1964 lastFileDir=fd->dirPath();
1965 QStringList flist = fd->selectedFiles();
1966 QStringList::Iterator it = flist.begin();
1967 while( it != flist.end() )
1970 fileLoad(*it, lmode);
1977 void Main::fileLoad()
1982 void Main::fileLoadLast(QAction *a)
1984 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1987 void Main::fileSave(const SaveMode &savemode)
1989 // tmp dir for zipping
1993 ErrorCode err=success;
1995 QString safeFilePath;
1997 bool saveZipped=currentMapEditor()->saveZipped();
1999 MapEditor * me=currentMapEditor();
2002 QString fn=me->getFilePath();
2003 // filename=unnamed, filepath="" in constructor...
2004 if ( !fn.isEmpty() )
2006 // We have a filepath, go on saving
2007 // First remove existing file, we
2008 // don't want to add to old zip archives
2012 QMessageBox::warning( 0, tr( "Save Error" ),
2013 fn+ tr("\ncould not be removed before saving"));
2015 // Look, if we should zip the data:
2018 QMessageBox mb( __VYM,
2019 tr("The map %1\ndid not use the compressed "
2020 "vym file format.\nWriting it uncompressed will also write images \n"
2021 "and flags and thus may overwrite files in the "
2022 "given directory\n\nDo you want to write the map").arg(fn),
2023 QMessageBox::Warning,
2024 QMessageBox::Yes | QMessageBox::Default,
2026 QMessageBox::Cancel | QMessageBox::Escape);
2027 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2028 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2029 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2032 case QMessageBox::Yes:
2033 // save compressed (default file format)
2036 case QMessageBox::No:
2037 // save uncompressed
2040 case QMessageBox::Cancel:
2049 char tmpdir1[]="/tmp/vym-XXXXXX";
2050 tmpMapDir=mkdtemp(tmpdir1);
2052 safeFilePath=me->getFilePath();
2053 me->setFilePath (tmpMapDir+"/"+
2054 me->getMapName()+ ".xml",
2056 me->save (savemode);
2057 me->setFilePath (safeFilePath);
2059 zipDir (tmpMapDir,fn);
2064 safeFilePath=me->getFilePath();
2065 me->setFilePath (fn, safeFilePath);
2066 me->save (savemode);
2067 me->setFilePath (safeFilePath);
2069 } // filepath available
2072 // We have no filepath yet,
2073 // call fileSaveAs() now, this will call fileSave()
2075 fileSaveAs(savemode);
2079 if (saveZipped && !tmpMapDir.isEmpty())
2081 removeDir (QDir(tmpMapDir));
2085 statusBar()->message(
2086 tr("Saved %1").arg(me->getFilePath()),
2088 lastMaps.prepend(me->getFilePath() );
2089 setupLastMapsMenu();
2091 statusBar()->message(
2092 tr("Couldn't save ").arg(me->getFilePath()),
2096 void Main::fileSave()
2098 fileSave (CompleteMap);
2101 void Main::fileSaveAs(const SaveMode& savemode)
2105 if (currentMapEditor())
2107 if (savemode==CompleteMap)
2108 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2110 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2111 if ( !fn.isEmpty() )
2113 // Check for existing file
2114 if (QFile (fn).exists())
2116 QMessageBox mb( __VYM,
2117 tr("The file %1\nexists already. Do you want to").arg(fn),
2118 QMessageBox::Warning,
2119 QMessageBox::Yes | QMessageBox::Default,
2120 QMessageBox::Cancel | QMessageBox::Escape,
2121 QMessageBox::NoButton);
2122 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2123 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2126 case QMessageBox::Yes:
2129 case QMessageBox::Cancel:
2136 // New file, add extension to filename, if missing
2137 // This is always .vym or .vyp, depending on savemode
2138 if (savemode==CompleteMap)
2140 if (!fn.contains (".vym") && !fn.contains (".xml"))
2144 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2153 currentMapEditor()->setFilePath(fn);
2157 if (savemode==CompleteMap)
2158 tabWidget->setTabLabel (currentMapEditor(),
2159 currentMapEditor()->getFileName() );
2165 void Main::fileSaveAs()
2167 fileSaveAs (CompleteMap);
2170 void Main::fileImportKDEBookmarks()
2172 ImportKDEBookmarks im;
2174 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2175 currentMapEditor()->setFilePath ("");
2178 void Main::fileImportFirefoxBookmarks()
2180 Q3FileDialog *fd=new Q3FileDialog( this);
2181 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2182 fd->setMode (Q3FileDialog::ExistingFiles);
2183 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2184 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2187 if ( fd->exec() == QDialog::Accepted )
2189 ImportFirefoxBookmarks im;
2190 QStringList flist = fd->selectedFiles();
2191 QStringList::Iterator it = flist.begin();
2192 while( it != flist.end() )
2195 if (im.transform() &&
2196 success==fileLoad (im.getTransformedFile(),NewMap) &&
2197 currentMapEditor() )
2198 currentMapEditor()->setFilePath ("");
2205 void Main::fileImportMM()
2209 Q3FileDialog *fd=new Q3FileDialog( this);
2210 fd->setDir (lastFileDir);
2211 fd->setMode (Q3FileDialog::ExistingFiles);
2212 fd->addFilter ("Mind Manager (*.mmap)");
2213 fd->setCaption(tr("Import")+" "+"Mind Manager");
2216 if ( fd->exec() == QDialog::Accepted )
2218 lastFileDir=fd->dirPath();
2219 QStringList flist = fd->selectedFiles();
2220 QStringList::Iterator it = flist.begin();
2221 while( it != flist.end() )
2224 if (im.transform() &&
2225 success==fileLoad (im.getTransformedFile(),NewMap) &&
2226 currentMapEditor() )
2227 currentMapEditor()->setFilePath ("");
2236 void Main::fileImportDir()
2238 if (currentMapEditor())
2239 currentMapEditor()->importDir();
2242 void Main::fileExportXML()
2244 if (currentMapEditor())
2246 QString dir=browseDirectory(tr("Export XML to directory"));
2247 if (dir !="" && reallyWriteDirectory(dir) )
2248 currentMapEditor()->exportXML(dir);
2253 void Main::fileExportXHTML()
2255 MapEditor *me=currentMapEditor();
2259 ExportXHTMLDialog dia(this);
2260 dia.setFilePath (me->getFilePath() );
2261 dia.setMapName (me->getMapName() );
2264 if (dia.exec()==QDialog::Accepted)
2266 QString dir=dia.getDir();
2267 // Check, if warnings should be used before overwriting
2268 // the output directory
2271 ok=reallyWriteDirectory(dir);
2277 me->exportXML (dia.getDir() );
2278 dia.doExport(me->getMapName() );
2279 if (dia.hasChanged())
2286 void Main::fileExportImage()
2288 MapEditor *me=currentMapEditor();
2292 QFileDialog *fd=new QFileDialog (this);
2293 fd->setCaption (tr("Export map as image"));
2294 fd->setFileMode(QFileDialog::AnyFile);
2295 fd->setFilters (imageIO.getFilters() );
2296 fd->setDirectory (lastImageDir);
2299 fl=fd->selectedFiles();
2300 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2301 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2306 void Main::fileExportASCII()
2308 MapEditor *me=currentMapEditor();
2312 ex.setMapCenter(me->getMapCenter());
2313 ex.addFilter ("TXT (*.txt)");
2314 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2315 if (ex.execDialog() )
2317 me->setExportMode(true);
2319 me->setExportMode(false);
2324 void Main::fileExportLaTeX()
2326 MapEditor *me=currentMapEditor();
2330 ex.setMapCenter(me->getMapCenter());
2331 ex.addFilter ("Tex (*.tex)");
2332 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2333 if (ex.execDialog() )
2335 me->setExportMode(true);
2337 me->setExportMode(false);
2342 void Main::fileExportKDEBookmarks()
2344 ExportKDEBookmarks ex;
2345 MapEditor *me=currentMapEditor();
2348 ex.setMapCenter (me->getMapCenter() );
2353 void Main::fileExportTaskjuggler()
2355 ExportTaskjuggler ex;
2356 MapEditor *me=currentMapEditor();
2359 ex.setMapCenter (me->getMapCenter() );
2360 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2361 ex.addFilter ("Taskjuggler (*.tjp)");
2362 if (ex.execDialog() )
2364 me->setExportMode(true);
2366 me->setExportMode(false);
2371 void Main::fileExportOOPresentation()
2373 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2374 // TODO add preview in dialog
2375 //ImagePreview *p =new ImagePreview (fd);
2376 //fd->setContentsPreviewEnabled( TRUE );
2377 //fd->setContentsPreview( p, p );
2378 //fd->setPreviewMode( QFileDialog::Contents );
2379 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2380 fd->setDir (QDir().current());
2381 if (fd->foundConfig())
2385 if ( fd->exec() == QDialog::Accepted )
2387 QString fn=fd->selectedFile();
2388 if (!fn.contains (".odp"))
2391 //lastImageDir=fn.left(fn.findRev ("/"));
2392 if (currentMapEditor())
2393 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2397 QMessageBox::warning(0,
2399 tr("Couldn't find configuration for export to Open Office\n"));
2403 void Main::fileCloseMap()
2405 if (currentMapEditor())
2407 if (currentMapEditor()->hasChanged())
2409 QMessageBox mb( __VYM,
2410 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2411 QMessageBox::Warning,
2412 QMessageBox::Yes | QMessageBox::Default,
2414 QMessageBox::Cancel | QMessageBox::Escape );
2415 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2416 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2419 case QMessageBox::Yes:
2421 fileSave(CompleteMap);
2423 case QMessageBox::No:
2424 // close without saving
2426 case QMessageBox::Cancel:
2431 currentMapEditor()->closeMap();
2432 tabWidget->removePage(currentMapEditor());
2433 if (tabWidget->count()==0)
2434 actionFilePrint->setEnabled (false);
2438 void Main::filePrint()
2440 if (currentMapEditor())
2441 currentMapEditor()->print();
2444 void Main::fileExitVYM()
2446 // Check if one or more editors have changed
2449 for (i=0;i<=tabWidget->count() -1;i++)
2452 me=(MapEditor*)tabWidget->page(i);
2454 // If something changed, ask what to do
2455 if (me->isUnsaved())
2457 tabWidget->setCurrentPage(i);
2458 QMessageBox mb( __VYM,
2459 tr("This map is not saved yet. Do you want to"),
2460 QMessageBox::Warning,
2461 QMessageBox::Yes | QMessageBox::Default,
2463 QMessageBox::Cancel | QMessageBox::Escape );
2464 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2465 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2468 mb.setActiveWindow();
2469 switch( mb.exec() ) {
2470 case QMessageBox::Yes:
2471 // save (the changed editors) and exit
2472 fileSave(CompleteMap);
2474 case QMessageBox::No:
2475 // exit without saving
2477 case QMessageBox::Cancel:
2478 // don't save and don't exit
2482 } // loop over all MEs
2486 void Main::editUndo()
2488 if (currentMapEditor())
2489 currentMapEditor()->undo();
2492 void Main::editRedo()
2494 if (currentMapEditor())
2495 currentMapEditor()->redo();
2498 void Main::editCopy()
2500 if (currentMapEditor())
2501 currentMapEditor()->copy();
2504 void Main::editPaste()
2506 if (currentMapEditor())
2507 currentMapEditor()->paste();
2510 void Main::editCut()
2512 if (currentMapEditor())
2513 currentMapEditor()->cut();
2516 void Main::editOpenFindWindow()
2518 findWindow->popup();
2519 findWindow->raise();
2520 findWindow->setActiveWindow();
2523 void Main::editFind(QString s)
2526 BranchObj *bo=currentMapEditor()->findText(s, cs);
2529 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2532 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2533 tr("No matches found for \"%1\"").arg(s));
2537 void Main::editFindChanged()
2538 { // Notify editor, to abort the current find process
2539 currentMapEditor()->findReset();
2542 void Main::openTabs(QStringList urls)
2544 if (!urls.isEmpty())
2548 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2550 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2552 QString u=urls.takeFirst();
2553 procBrowser = new QProcess( this );
2555 procBrowser->start(browser,args);
2556 if ( !procBrowser->waitForStarted())
2558 // try to set path to browser
2559 QMessageBox::warning(0,
2561 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2562 tr("Please use Settings->")+tr("Set application to open an URL"));
2567 if (browser.contains("konqueror"))
2569 for (int i=0; i<urls.size(); i++)
2572 // Try to open new tab in existing konqueror started previously by vym
2573 p=new QProcess (this);
2575 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2576 "konqueror-mainwindow#1"<<
2579 p->start ("dcop",args);
2580 if ( !p->waitForStarted() ) success=false;
2583 QMessageBox::warning(0,
2585 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2587 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2589 for (int i=0; i<urls.size(); i++)
2591 // Try to open new tab in firefox
2592 p=new QProcess (this);
2593 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2594 p->start (browser,args);
2595 if ( !p->waitForStarted() ) success=false;
2598 QMessageBox::warning(0,
2600 tr("Couldn't start %1 to open a new tab").arg(browser));
2603 QMessageBox::warning(0,
2605 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2609 void Main::editOpenURL()
2612 if (currentMapEditor())
2614 QString url=currentMapEditor()->getURL();
2616 if (url=="") return;
2617 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2618 procBrowser = new QProcess( this );
2620 procBrowser->start(browser,args);
2621 if ( !procBrowser->waitForStarted())
2623 // try to set path to browser
2624 QMessageBox::warning(0,
2626 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2627 tr("Please use Settings->")+tr("Set application to open an URL"));
2632 void Main::editOpenURLTab()
2634 if (currentMapEditor())
2637 urls.append(currentMapEditor()->getURL());
2641 void Main::editOpenMultipleURLTabs()
2643 if (currentMapEditor())
2646 urls=currentMapEditor()->getURLs();
2652 void Main::editURL()
2654 if (currentMapEditor())
2655 currentMapEditor()->editURL();
2658 void Main::editHeading2URL()
2660 if (currentMapEditor())
2661 currentMapEditor()->editHeading2URL();
2664 void Main::editBugzilla2URL()
2666 if (currentMapEditor())
2667 currentMapEditor()->editBugzilla2URL();
2670 void Main::editFATE2URL()
2672 if (currentMapEditor())
2673 currentMapEditor()->editFATE2URL();
2676 void Main::editHeading()
2678 if (lineedit->isVisible())
2680 if (currentMapEditor())
2682 MapEditor *me=currentMapEditor();
2683 QString oldSel=me->getSelectString();
2684 if (me->select (editSel))
2685 me->setHeading(lineedit->text());
2686 me->select (oldSel);
2688 lineedit->releaseKeyboard();
2693 if (currentMapEditor())
2697 QString s=currentMapEditor()->getHeading(ok,p);
2701 #if defined(Q_OS_MACX)
2702 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2703 QDialog *d =new QDialog(NULL);
2704 QLineEdit *le=new QLineEdit (d);
2705 d->setWindowFlags (Qt::FramelessWindowHint);
2706 d->setGeometry(p.x(),p.y(),200,25);
2707 le->resize (d->size());
2710 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2711 d->activateWindow();
2713 currentMapEditor()->setHeading (le->text());
2715 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2716 lineedit->setGeometry(p.x(),p.y(),200,25);
2717 lineedit->setText(s);
2718 lineedit->setCursorPosition(1);
2719 lineedit->selectAll();
2721 lineedit->grabKeyboard();
2722 lineedit->setFocus();
2724 editSel=currentMapEditor()->getSelectString();
2732 void Main::openVymLinks(const QStringList &vl)
2734 for (int j=0; j<vl.size(); j++)
2736 // compare path with already loaded maps
2740 for (i=0;i<=tabWidget->count() -1;i++)
2742 me=(MapEditor*)tabWidget->page(i);
2743 if (vl.at(j)==me->getFilePath() )
2752 if (!QFile(vl.at(j)).exists() )
2753 QMessageBox::critical( 0, tr( "Critical Error" ),
2754 tr("Couldn't open map %1").arg(vl.at(j)));
2757 fileLoad (vl.at(j), NewMap);
2758 tabWidget->setCurrentPage (tabWidget->count()-1);
2761 // Go to tab containing the map
2762 tabWidget->setCurrentPage (index);
2766 void Main::editOpenVymLink()
2768 if (currentMapEditor())
2771 vl.append(currentMapEditor()->getVymLink());
2776 void Main::editOpenMultipleVymLinks()
2778 QString currentVymLink;
2779 if (currentMapEditor())
2781 QStringList vl=currentMapEditor()->getVymLinks();
2786 void Main::editVymLink()
2788 if (currentMapEditor())
2789 currentMapEditor()->editVymLink();
2792 void Main::editDeleteVymLink()
2794 if (currentMapEditor())
2795 currentMapEditor()->deleteVymLink();
2798 void Main::editToggleHideExport()
2800 if (currentMapEditor())
2801 currentMapEditor()->toggleHideExport();
2804 void Main::editMapInfo()
2806 if (currentMapEditor())
2807 currentMapEditor()->editMapInfo();
2810 void Main::editMoveUp()
2812 if (currentMapEditor())
2813 currentMapEditor()->moveBranchUp();
2816 void Main::editMoveDown()
2818 if (currentMapEditor())
2819 currentMapEditor()->moveBranchDown();
2822 void Main::editToggleScroll()
2824 if (currentMapEditor())
2826 currentMapEditor()->toggleScroll();
2830 void Main::editUnScrollAll()
2832 if (currentMapEditor())
2834 currentMapEditor()->unScrollAll();
2838 void Main::editNewBranch()
2841 if (!lineedit->isVisible() && currentMapEditor())
2842 currentMapEditor()->addNewBranch(0);
2845 void Main::editNewBranchHere()
2847 if (currentMapEditor())
2848 currentMapEditor()->addNewBranchHere();
2851 void Main::editNewBranchAbove()
2853 if (currentMapEditor())
2854 currentMapEditor()->addNewBranch(-1);
2857 void Main::editNewBranchBelow()
2859 if (currentMapEditor())
2860 currentMapEditor()->addNewBranch(1);
2863 void Main::editImportAdd()
2865 fileLoad (ImportAdd);
2868 void Main::editImportReplace()
2870 fileLoad (ImportReplace);
2873 void Main::editSaveBranch()
2875 fileSaveAs (PartOfMap);
2878 void Main::editRemoveBranchKeepChilds()
2880 if (currentMapEditor())
2881 currentMapEditor()->removeBranchKeepChilds();
2884 void Main::editRemoveChilds()
2886 if (currentMapEditor())
2887 currentMapEditor()->removeChilds();
2890 void Main::editDeleteSelection()
2892 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2893 currentMapEditor()->deleteSelection();
2896 void Main::editUpperBranch()
2898 if (currentMapEditor())
2899 currentMapEditor()->selectUpperBranch();
2902 void Main::editLowerBranch()
2904 if (currentMapEditor())
2905 currentMapEditor()->selectLowerBranch();
2908 void Main::editLeftBranch()
2910 if (currentMapEditor())
2911 currentMapEditor()->selectLeftBranch();
2914 void Main::editRightBranch()
2916 if (currentMapEditor())
2917 currentMapEditor()->selectRightBranch();
2920 void Main::editFirstBranch()
2922 if (currentMapEditor())
2923 currentMapEditor()->selectFirstBranch();
2926 void Main::editLastBranch()
2928 if (currentMapEditor())
2929 currentMapEditor()->selectLastBranch();
2932 void Main::editLoadImage()
2934 if (currentMapEditor())
2935 currentMapEditor()->loadFloatImage();
2938 void Main::editSaveImage()
2940 if (currentMapEditor())
2941 currentMapEditor()->saveFloatImage();
2944 void Main::editFollowXLink(QAction *a)
2947 if (currentMapEditor())
2948 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2951 void Main::editEditXLink(QAction *a)
2953 if (currentMapEditor())
2954 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2957 void Main::formatSelectColor()
2959 if (currentMapEditor())
2961 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2962 if ( !col.isValid() ) return;
2963 currentMapEditor()->setColor( col );
2964 colorChanged( col );
2968 void Main::formatPickColor()
2970 if (currentMapEditor())
2971 colorChanged( currentMapEditor()->pickColor() );
2974 void Main::colorChanged(QColor c)
2976 QPixmap pix( 16, 16 );
2978 actionFormatColor->setIconSet( pix );
2981 void Main::formatColorItem()
2983 if (currentMapEditor())
2984 currentMapEditor()->colorItem();
2987 void Main::formatColorBranch()
2989 if (currentMapEditor())
2990 currentMapEditor()->colorBranch();
2993 void Main::formatLinkStyleLine()
2995 if (currentMapEditor())
2996 currentMapEditor()->setLinkStyle(StyleLine);
2999 void Main::formatLinkStyleParabel()
3001 if (currentMapEditor())
3002 currentMapEditor()->setLinkStyle(StyleParabel);
3005 void Main::formatLinkStylePolyLine()
3007 if (currentMapEditor())
3008 currentMapEditor()->setLinkStyle(StylePolyLine);
3011 void Main::formatLinkStylePolyParabel()
3013 if (currentMapEditor())
3014 currentMapEditor()->setLinkStyle(StylePolyParabel);
3017 void Main::formatSelectBackColor()
3019 if (currentMapEditor())
3020 currentMapEditor()->selectBackgroundColor();
3023 void Main::formatSelectLinkColor()
3025 if (currentMapEditor())
3026 currentMapEditor()->selectLinkColor();
3029 void Main::formatToggleLinkColorHint()
3031 currentMapEditor()->toggleLinkColorHint();
3034 void Main::formatFrameNone()
3036 if (currentMapEditor())
3037 currentMapEditor()->setFrame(NoFrame);
3040 void Main::formatFrameRectangle()
3042 if (currentMapEditor())
3043 currentMapEditor()->setFrame(Rectangle);
3046 void Main::formatIncludeImagesVer()
3048 if (currentMapEditor())
3049 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3052 void Main::formatIncludeImagesHor()
3054 if (currentMapEditor())
3055 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3058 void Main::formatHideLinkUnselected()
3060 if (currentMapEditor())
3061 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3064 void Main::viewZoomReset()
3066 if (currentMapEditor())
3070 currentMapEditor()->setWorldMatrix( m );
3071 currentMapEditor()->setViewCenter();
3072 currentMapEditor()->adjustCanvasSize();
3076 void Main::viewZoomIn()
3078 if (currentMapEditor())
3080 QMatrix m = currentMapEditor()->worldMatrix();
3081 m.scale( 1.25, 1.25 );
3082 currentMapEditor()->setWorldMatrix( m );
3083 currentMapEditor()->setViewCenter();
3084 currentMapEditor()->adjustCanvasSize();
3088 void Main::viewZoomOut()
3090 if (currentMapEditor())
3092 QMatrix m = currentMapEditor()->worldMatrix();
3093 m.scale( 0.8, 0.8 );
3094 currentMapEditor()->setWorldMatrix( m );
3095 currentMapEditor()->setViewCenter();
3096 currentMapEditor()->adjustCanvasSize();
3100 void Main::modModeColor()
3104 void Main::modModeLink()
3108 bool Main::settingsPDF()
3110 // Default browser is set in constructor
3112 QString text = QInputDialog::getText(
3113 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3114 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3116 settings.setValue ("/mainwindow/readerPDF",text);
3121 bool Main::settingsURL()
3123 // Default browser is set in constructor
3125 QString text = QInputDialog::getText(
3126 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3127 settings.value("/mainwindow/readerURL").toString()
3130 settings.setValue ("/mainwindow/readerURL",text);
3134 void Main::settingsToggleDelKey()
3136 if (actionSettingsUseDelKey->isOn())
3138 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3141 actionEditDelete->setAccel (QKeySequence (""));
3145 void Main::windowToggleNoteEditor()
3147 if (textEditor->showWithMain() )
3148 windowHideNoteEditor();
3150 windowShowNoteEditor();
3153 void Main::windowToggleHistory()
3155 if (currentMapEditor())
3156 currentMapEditor()->toggleHistoryWindow();
3159 void Main::updateNoteFlag()
3161 if (currentMapEditor())
3162 currentMapEditor()->updateNoteFlag();
3165 void Main::windowShowNoteEditor()
3167 textEditor->setShowWithMain(true);
3169 actionViewToggleNoteEditor->setOn (true);
3172 void Main::windowHideNoteEditor()
3174 textEditor->setShowWithMain(false);
3176 actionViewToggleNoteEditor->setOn (false);
3179 void Main::windowNextEditor()
3181 if (tabWidget->currentPageIndex() < tabWidget->count())
3182 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3185 void Main::windowPreviousEditor()
3187 if (tabWidget->currentPageIndex() >0)
3188 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3191 void Main::standardFlagChanged()
3193 currentMapEditor()->toggleStandardFlag(sender()->name());
3196 void Main::testFunction()
3198 currentMapEditor()->testFunction();
3201 void Main::helpDoc()
3204 #if defined(Q_OS_MACX)
3205 docpath="./vym.app/Contents/vym.pdf";
3207 // default path in SUSE LINUX
3208 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3211 if (!QFile (docpath).exists() )
3213 // relative path for easy testing in tarball
3214 docpath="doc/vym.pdf";
3215 if (!QFile (docpath).exists() )
3217 // relative path for testing while still writing vym.tex
3218 docpath="doc/tex/vym.pdf";
3219 if (!QFile (docpath).exists() )
3221 // Try yet another one for Knoppix
3222 docpath="/usr/share/doc/packages/vym/vym.pdf";
3223 if (!QFile (docpath).exists() )
3225 QMessageBox::critical(0,
3226 tr("Critcal error"),
3227 tr("Couldn't find the documentation\n"
3228 "vym.pdf in various places."));
3235 Process *pdfProc = new Process();
3236 pdfProc->clearArguments();
3237 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3238 pdfProc->addArgument( docpath);
3240 if ( !pdfProc->start() )
3243 QMessageBox::warning(0,
3245 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3246 tr("Please use Settings->")+tr("Set application to open PDF files"));
3253 void Main::helpAbout()
3256 ad.setName ("aboutwindow");
3257 ad.setMinimumSize(500,500);
3258 ad.resize (QSize (500,500));
3262 void Main::helpAboutQT()
3264 QMessageBox::aboutQt( this, "Qt Application Example" );