More undo/redo commands. 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* 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
165 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
167 // Create direcctory for clipboard
168 clipboardDir=tmpVymDir+"/clipboard";
169 QDir d(clipboardDir);
170 d.mkdir (clipboardDir,true);
171 makeSubDirs (clipboardDir);
176 // FIXME not used currently
177 // Set random seed (random used for object IDs)
178 // QTime t = QTime::currentTime(); // set random seed
179 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
182 // Initialize some settings, which are platform dependant
185 // application to open URLs
186 p="/mainwindow/readerURL";
187 #if defined(Q_OS_LINUX)
188 s=settings.value (p,"konqueror").toString();
190 #if defined(Q_OS_MACX)
191 s=settings.value (p,"/usr/bin/open").toString();
193 s=settings.value (p,"mozilla");
196 settings.setValue( p,s);
198 // application to open PDFs
199 p="/mainwindow/readerPDF";
200 #if defined(Q_OS_LINUX)
201 s=settings.value (p,"acroread").toString();
203 #if defined(Q_OS_MACX)
204 s=settings.value (p,"/usr/bin/open").toString();
206 s=settings.value (p,"acroread").toString();
209 settings.setValue( p,s);
214 // Create tab widget which holds the maps
215 tabWidget= new QTabWidget (this);
216 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
217 this, SLOT( editorChanged( QWidget * ) ) );
219 lineedit=new QLineEdit (this);
222 setCentralWidget(tabWidget);
226 setupFormatActions();
230 setupSettingsActions();
232 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
237 restoreState (settings.value("/mainwindow/state",0).toByteArray());
239 // Initialize Find window
240 findWindow=new FindWindow(NULL,"findwindow");
241 connect (findWindow, SIGNAL( findButton(QString) ),
242 this, SLOT(editFind(QString) ) );
243 connect (findWindow, SIGNAL( somethingChanged() ),
244 this, SLOT(editFindChanged() ) );
246 // Connect TextEditor, so that we can update flags if text changes
247 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
255 settings.setValue ( "/mainwindow/geometry/size", size() );
256 settings.setValue ( "/mainwindow/geometry/pos", pos() );
258 settings.setValue ("/mainwindow/state",saveState(0));
260 settings.setValue( "/version/version", __VYM_VERSION );
261 settings.setValue( "/version/builddate", __BUILD_DATE );
263 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoselectHeading->isOn() );
264 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoselectText->isOn() );
265 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoedit->isOn() );
266 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
267 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
268 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
271 int maps=lastMaps.count();
272 settings.setValue( "/lastMaps/number",maps );
273 for (int i=1;i<=maps;i++)
275 s=QString("/lastMaps/map-%1").arg(i);
276 if (!s.isEmpty() && i<=maxLastMaps)
277 settings.setValue (s, lastMaps.at(i-1));
281 // To make the texteditor save its settings, call the destructor
284 // Remove temporary directory
285 removeDir (QDir(tmpVymDir));
288 void Main::loadCmdLine()
290 /* TODO draw some kind of splashscreen while loading...
296 QStringList flist=options.getFileList();
297 QStringList::Iterator it=flist.begin();
299 while (it !=flist.end() )
301 fileLoad (*it, NewMap);
307 void Main::statusMessage(const QString &s)
309 statusBar()->message (s);
312 void Main::closeEvent (QCloseEvent* )
318 void Main::setupFileActions()
320 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
321 QToolBar *tb = addToolBar( tr ("&Map") );
322 tb->setObjectName ("mapTB");
325 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
326 a->setStatusTip ( tr( "New map","File menu" ) );
327 a->setShortcut ( Qt::CTRL + Qt::Key_N );
329 fileMenu->addAction (a);
330 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
332 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
333 a->setStatusTip (tr( "Open","File menu" ) );
334 a->setShortcut ( Qt::CTRL + Qt::Key_O );
336 fileMenu->addAction (a);
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
339 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
340 fileMenu->addSeparator();
342 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
343 a->setStatusTip ( tr( "Save" ));
344 a->setShortcut (Qt::CTRL + Qt::Key_S );
346 fileMenu->addAction (a);
347 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
350 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
351 a->setStatusTip (tr( "Save &As" ) );
352 fileMenu->addAction (a);
353 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
355 fileMenu->addSeparator();
357 fileImportMenu = fileMenu->addMenu (tr("Import"));
359 a = new QAction(tr("KDE Bookmarks"), this);
360 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
361 a->addTo (fileImportMenu);
362 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
364 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
366 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
367 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
368 a->addTo (fileImportMenu);
369 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
372 a = new QAction("Mind Manager...",this);
373 a->setStatusTip ( tr( "Import")+" Mind Manager" );
374 fileImportMenu->addAction (a);
375 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
377 a = new QAction( tr( "Import Dir"+QString("...") ), this);
378 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
379 fileImportMenu->addAction (a);
380 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
382 fileExportMenu = fileMenu->addMenu (tr("Export"));
384 a = new QAction( tr("Image")+QString("..."), this);
385 a->setStatusTip( tr( "Export map as image" ));
386 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
387 fileExportMenu->addAction (a);
389 a = new QAction( "Open Office"+QString("..."), this);
390 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
391 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
392 fileExportMenu->addAction (a);
394 a = new QAction( "Webpage (XHTML)...",this );
395 a->setShortcut (Qt::ALT + Qt::Key_X);
396 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
397 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
398 fileExportMenu->addAction (a);
400 a = new QAction( "Text (ASCII)...", this);
401 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
402 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
403 fileExportMenu->addAction (a);
405 a = new QAction( tr("KDE Bookmarks"), this);
406 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
407 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
408 fileExportMenu->addAction (a);
410 a = new QAction( "Taskjuggler...", this );
411 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
412 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
413 fileExportMenu->addAction (a);
415 a = new QAction( "LaTeX...", this);
416 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
417 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
418 fileExportMenu->addAction (a);
420 a = new QAction( "XML..." , this );
421 a->setStatusTip (tr( "Export as")+" XML");
422 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
423 fileExportMenu->addAction (a);
425 fileMenu->addSeparator();
427 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
428 a->setStatusTip ( tr( "Print" ) );
429 a->setShortcut (Qt::CTRL + Qt::Key_P );
431 fileMenu->addAction (a);
432 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
435 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
436 a->setStatusTip (tr( "Close Map" ) );
437 a->setShortcut (Qt::ALT + Qt::Key_C );
438 fileMenu->addAction (a);
439 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
441 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
442 a->setStatusTip ( tr( "Exit")+" "+__VYM );
443 a->setShortcut (Qt::CTRL + Qt::Key_Q );
444 fileMenu->addAction (a);
445 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
450 void Main::setupEditActions()
452 QToolBar *tb = addToolBar( tr ("&Actions") );
453 tb->setLabel( "Edit Actions" );
454 tb->setObjectName ("actionsTB");
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"));
867 tb->setObjectName ("formatTB");
870 pix.fill (Qt::black);
871 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
872 a->setStatusTip ( tr( "Set Color" ));
873 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
875 formatMenu->addAction (a);
877 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
878 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
879 a->setShortcut (Qt::CTRL + Qt::Key_K );
880 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
881 a->setEnabled (false);
883 formatMenu->addAction (a);
884 actionListBranches.append(a);
885 actionFormatPickColor=a;
887 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
888 a->setStatusTip ( tr( "Color branch" ) );
889 a->setShortcut (Qt::CTRL + Qt::Key_I);
890 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
891 a->setEnabled (false);
893 formatMenu->addAction (a);
894 actionListBranches.append(a);
895 actionFormatColorBranch=a;
897 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
898 a->setStatusTip ( tr( "Color Subtree" ));
899 a->setShortcut (Qt::CTRL + Qt::Key_T);
900 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
901 a->setEnabled (false);
902 formatMenu->addAction (a);
904 actionListBranches.append(a);
905 actionFormatColorSubtree=a;
907 formatMenu->addSeparator();
908 actionGroupFormatLinkStyles=new QActionGroup ( this);
909 actionGroupFormatLinkStyles->setExclusive (true);
910 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
911 a->setStatusTip (tr( "Line" ));
912 a->setToggleAction(true);
913 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
914 formatMenu->addAction (a);
915 actionFormatLinkStyleLine=a;
916 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
917 a->setStatusTip (tr( "Line" ));
918 a->setToggleAction(true);
919 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
920 formatMenu->addAction (a);
921 actionFormatLinkStyleParabel=a;
922 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
923 a->setStatusTip (tr( "PolyLine" ));
924 a->setToggleAction(true);
925 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
926 formatMenu->addAction (a);
927 actionFormatLinkStylePolyLine=a;
928 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
929 a->setStatusTip (tr( "PolyParabel" ) );
930 a->setToggleAction(true);
931 a->setChecked (true);
932 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
933 formatMenu->addAction (a);
934 actionFormatLinkStylePolyParabel=a;
936 actionGroupFormatFrameTypes=new QActionGroup ( this);
937 actionGroupFormatFrameTypes->setExclusive (true);
938 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
939 a->setStatusTip (tr("No Frame"));
940 a->setToggleAction(true);
941 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
942 actionFormatFrameNone=a;
943 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
944 a->setStatusTip (tr( "Rectangle" ));
945 a->setToggleAction(true);
946 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
947 actionFormatFrameRectangle=a;
949 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
950 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
951 a->setToggleAction(true);
952 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
953 actionFormatIncludeImagesVer=a;
955 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
956 a->setStatusTip ( tr ("Include left and right position of images into branch"));
957 a->setToggleAction(true);
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
959 actionFormatIncludeImagesHor=a;
961 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
962 a->setStatusTip (tr( "Hide link" ));
963 a->setToggleAction(true);
964 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
965 actionFormatHideLinkUnselected=a;
967 formatMenu->addSeparator();
968 a= new QAction( tr( "&Use color of heading for link" ), this);
969 a->setStatusTip (tr( "Use same color for links and headings" ));
970 a->setToggleAction(true);
971 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
972 formatMenu->addAction (a);
973 actionFormatLinkColorHint=a;
975 pix.fill (Qt::white);
976 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
977 a->setStatusTip (tr( "Set Link Color" ));
978 formatMenu->addAction (a);
979 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
980 actionFormatLinkColor=a;
982 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
983 a->setStatusTip (tr( "Set Background Color" ));
984 formatMenu->addAction (a);
985 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
986 actionFormatBackColor=a;
990 void Main::setupViewActions()
992 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
993 tb->setLabel( "View Actions" );
994 tb->setObjectName ("viewTB");
995 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
998 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
999 a->setStatusTip ( tr( "Zoom reset" ) );
1000 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1002 viewMenu->addAction (a);
1003 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1005 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
1006 a->setStatusTip (tr( "Zoom in" ));
1007 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1009 viewMenu->addAction (a);
1010 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1012 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
1013 a->setStatusTip (tr( "Zoom out" ));
1014 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1016 viewMenu->addAction (a);
1017 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1020 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1021 a->setStatusTip ( tr( "Show Note Editor" ));
1022 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1023 a->setToggleAction(true);
1024 if (textEditor->showWithMain())
1029 viewMenu->addAction (a);
1030 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1031 actionViewToggleNoteEditor=a;
1033 a = new QAction( tr( "Show history window" ),this );
1034 a->setStatusTip ( tr( "Show history window" ));
1035 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1036 a->setToggleAction(false);
1037 viewMenu->addAction (a);
1038 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1039 actionViewToggleHistoryWindow=a;
1041 a = new QAction(tr( "Next Window" ), this);
1042 a->setStatusTip ( tr( "&Next Window" ) );
1043 a->setShortcut (Qt::ALT + Qt::Key_N );
1044 viewMenu->addAction (a);
1045 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1047 a = new QAction (tr( "Previous Window" ), this );
1048 a->setStatusTip (tr( "&Previous Window" ));
1049 a->setShortcut (Qt::ALT + Qt::Key_P );
1050 viewMenu->addAction (a);
1051 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1055 void Main::setupModeActions()
1057 //QPopupMenu *menu = new QPopupMenu( this );
1058 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1060 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1061 tb->setObjectName ("modesTB");
1063 actionGroupModModes=new QActionGroup ( this);
1064 actionGroupModModes->setExclusive (true);
1065 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1066 a->setShortcut (Qt::Key_J);
1067 a->setStatusTip ( tr( "Use modifier to color branches" ));
1068 a->setToggleAction(true);
1071 actionModModeColor=a;
1073 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1074 a->setShortcut( Qt::Key_K);
1075 a->setStatusTip( tr( "Use modifier to copy" ));
1076 a->setToggleAction(true);
1078 actionModModeCopy=a;
1080 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1081 a->setShortcut (Qt::Key_L);
1082 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1083 a->setToggleAction(true);
1085 actionModModeLink=a;
1089 void Main::setupFlagActions()
1091 // Create System Flags
1092 systemFlagsDefault = new FlagRowObj ();
1093 systemFlagsDefault->setVisibility (false);
1094 systemFlagsDefault->setName ("systemFlagsDef");
1096 FlagObj *fo = new FlagObj ();
1097 fo->load(QPixmap(flagsPath+"flag-note.png"));
1098 fo->setName("note");
1099 fo->setToolTip(tr("Note","Systemflag"));
1100 systemFlagsDefault->addFlag (fo); // makes deep copy
1102 fo->load(QPixmap(flagsPath+"flag-url.png"));
1104 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1105 systemFlagsDefault->addFlag (fo);
1107 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1108 fo->setName("vymLink");
1109 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1110 systemFlagsDefault->addFlag (fo);
1112 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1113 fo->setName("scrolledright");
1114 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1115 systemFlagsDefault->addFlag (fo);
1117 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1118 fo->setName("tmpUnscrolledright");
1119 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1120 systemFlagsDefault->addFlag (fo);
1122 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1123 fo->setName("hideInExport");
1124 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1125 systemFlagsDefault->addFlag (fo);
1127 // Create Standard Flags
1128 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1129 tb->setObjectName ("standardFlagTB");
1131 standardFlagsDefault = new FlagRowObj ();
1132 standardFlagsDefault->setVisibility (false);
1133 standardFlagsDefault->setName ("standardFlagsDef");
1134 standardFlagsDefault->setToolBar (tb);
1136 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1137 fo->setName ("exclamationmark");
1138 fo->setGroup("standard-mark");
1139 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1142 a->setCheckable(true);
1143 a->setObjectName(fo->getName());
1144 a->setToolTip(tr("Take care!","Standardflag"));
1145 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1146 standardFlagsDefault->addFlag (fo); // makes deep copy
1148 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1149 fo->setName("questionmark");
1150 fo->setGroup("standard-mark");
1151 a=new QAction (fo->getPixmap(),fo->getName(),this);
1154 a->setCheckable(true);
1155 a->setObjectName(fo->getName());
1156 a->setToolTip(tr("Really?","Standardflag"));
1157 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1158 standardFlagsDefault->addFlag (fo);
1160 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1161 fo->setName("hook-green");
1162 fo->setGroup("standard-hook");
1163 a=new QAction (fo->getPixmap(),fo->getName(),this);
1166 a->setCheckable(true);
1167 a->setObjectName(fo->getName());
1168 a->setToolTip(tr("ok!","Standardflag"));
1169 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1170 standardFlagsDefault->addFlag (fo);
1172 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1173 fo->setName("cross-red");
1174 fo->setGroup("standard-hook");
1175 a=new QAction (fo->getPixmap(),fo->getName(),this);
1178 a->setCheckable(true);
1179 a->setObjectName(fo->getName());
1180 a->setToolTip(tr("Not ok!","Standardflag"));
1181 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1182 standardFlagsDefault->addFlag (fo);
1184 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1185 fo->setName("stopsign");
1186 a=new QAction (fo->getPixmap(),fo->getName(),this);
1189 a->setCheckable(true);
1190 a->setObjectName(fo->getName());
1191 a->setToolTip(tr("This won't work!","Standardflag"));
1192 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1193 standardFlagsDefault->addFlag (fo);
1195 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1196 fo->setName("smiley-good");
1197 fo->setGroup("standard-smiley");
1198 a=new QAction (fo->getPixmap(),fo->getName(),this);
1201 a->setCheckable(true);
1202 a->setObjectName(fo->getName());
1203 a->setToolTip(tr("Good","Standardflag"));
1204 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1205 standardFlagsDefault->addFlag (fo);
1207 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1208 fo->setName("smiley-sad");
1209 fo->setGroup("standard-smiley");
1210 a=new QAction (fo->getPixmap(),fo->getName(),this);
1213 a->setCheckable(true);
1214 a->setObjectName(fo->getName());
1215 a->setToolTip(tr("Bad","Standardflag"));
1216 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1217 standardFlagsDefault->addFlag (fo);
1219 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1220 // Original omg.png (in KDE emoticons)
1221 fo->setName("smiley-omg");
1222 fo->setGroup("standard-smiley");
1223 a=new QAction (fo->getPixmap(),fo->getName(),this);
1226 a->setCheckable(true);
1227 a->setObjectName(fo->getName());
1228 a->setToolTip(tr("Oh no!","Standardflag"));
1229 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1230 standardFlagsDefault->addFlag (fo);
1232 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1233 fo->setName("clock");
1234 a=new QAction (fo->getPixmap(),fo->getName(),this);
1237 a->setCheckable(true);
1238 a->setObjectName(fo->getName());
1239 a->setToolTip(tr("Time critical","Standardflag"));
1240 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1241 standardFlagsDefault->addFlag (fo);
1243 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1244 fo->setName("phone");
1245 a=new QAction (fo->getPixmap(),fo->getName(),this);
1248 a->setCheckable(true);
1249 a->setObjectName(fo->getName());
1250 a->setToolTip(tr("Call...","Standardflag"));
1251 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1252 standardFlagsDefault->addFlag (fo);
1254 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1255 fo->setName("lamp");
1256 a=new QAction (fo->getPixmap(),fo->getName(),this);
1259 a->setCheckable(true);
1260 a->setObjectName(fo->getName());
1261 a->setToolTip(tr("Idea!","Standardflag"));
1262 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1263 standardFlagsDefault->addFlag (fo);
1265 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1266 fo->setName("arrow-up");
1267 fo->setGroup("standard-arrow");
1268 a=new QAction (fo->getPixmap(),fo->getName(),this);
1271 a->setCheckable(true);
1272 a->setObjectName(fo->getName());
1273 a->setToolTip(tr("Important","Standardflag"));
1274 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1275 standardFlagsDefault->addFlag (fo);
1277 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1278 fo->setName("arrow-down");
1279 fo->setGroup("standard-arrow");
1280 a=new QAction (fo->getPixmap(),fo->getName(),this);
1283 a->setCheckable(true);
1284 a->setObjectName(fo->getName());
1285 a->setToolTip(tr("Unimportant","Standardflag"));
1286 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1287 standardFlagsDefault->addFlag (fo);
1289 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1290 fo->setName("2arrow-up");
1291 fo->setGroup("standard-arrow");
1292 a=new QAction (fo->getPixmap(),fo->getName(),this);
1295 a->setCheckable(true);
1296 a->setObjectName(fo->getName());
1297 a->setToolTip(tr("Very important!","Standardflag"));
1298 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1299 standardFlagsDefault->addFlag (fo);
1301 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1302 fo->setName("2arrow-down");
1303 fo->setGroup("standard-arrow");
1304 a=new QAction (fo->getPixmap(),fo->getName(),this);
1307 a->setCheckable(true);
1308 a->setObjectName(fo->getName());
1309 a->setToolTip(tr("Very unimportant!","Standardflag"));
1310 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1311 standardFlagsDefault->addFlag (fo);
1313 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1314 fo->setName("thumb-up");
1315 fo->setGroup("standard-thumb");
1316 a=new QAction (fo->getPixmap(),fo->getName(),this);
1319 a->setCheckable(true);
1320 a->setObjectName(fo->getName());
1321 a->setToolTip(tr("I like this","Standardflag"));
1322 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1323 standardFlagsDefault->addFlag (fo);
1325 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1326 fo->setName("thumb-down");
1327 fo->setGroup("standard-thumb");
1328 a=new QAction (fo->getPixmap(),fo->getName(),this);
1331 a->setCheckable(true);
1332 a->setObjectName(fo->getName());
1333 a->setToolTip(tr("I do not like this","Standardflag"));
1334 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1335 standardFlagsDefault->addFlag (fo);
1337 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1338 fo->setName("rose");
1339 a=new QAction (fo->getPixmap(),fo->getName(),this);
1342 a->setCheckable(true);
1343 a->setObjectName(fo->getName());
1344 a->setToolTip(tr("Rose","Standardflag"));
1345 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1346 standardFlagsDefault->addFlag (fo);
1348 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1349 fo->setName("heart");
1350 a=new QAction (fo->getPixmap(),fo->getName(),this);
1352 a->setCheckable(true);
1353 a->setObjectName(fo->getName());
1354 a->setToolTip(tr("I just love... ","Standardflag"));
1355 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1356 standardFlagsDefault->addFlag (fo);
1358 fo->load(QPixmap(flagsPath+"flag-present.png"));
1359 fo->setName("present");
1360 a=new QAction (fo->getPixmap(),fo->getName(),this);
1363 a->setCheckable(true);
1364 a->setObjectName(fo->getName());
1365 a->setToolTip(tr("Surprise!","Standardflag"));
1366 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1367 standardFlagsDefault->addFlag (fo);
1369 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1370 fo->setName("flash");
1371 a=new QAction (fo->getPixmap(),fo->getName(),this);
1374 a->setCheckable(true);
1375 a->setObjectName(fo->getName());
1376 a->setToolTip(tr("Dangerous","Standardflag"));
1377 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1378 standardFlagsDefault->addFlag (fo);
1380 fo->load(QPixmap(flagsPath+"flag-info.png"));
1381 // Original: xsldbg_output.png
1382 fo->setName("info");
1383 a=new QAction (fo->getPixmap(),fo->getName(),this);
1386 a->setCheckable(true);
1387 a->setObjectName(fo->getName());
1388 a->setToolTip(tr("Info","Standardflag"));
1389 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1390 standardFlagsDefault->addFlag (fo);
1392 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1393 // Original khelpcenter.png
1394 fo->setName("lifebelt");
1395 a=new QAction (fo->getPixmap(),fo->getName(),this);
1398 a->setCheckable(true);
1399 a->setObjectName(fo->getName());
1400 a->setToolTip(tr("This will help","Standardflag"));
1401 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1402 standardFlagsDefault->addFlag (fo);
1408 void Main::setupSettingsActions()
1410 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1414 a = new QAction( tr( "Set application to open pdf files"), this);
1415 a->setStatusTip ( tr( "Set application to open pdf files"));
1416 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1417 settingsMenu->addAction (a);
1419 a = new QAction( tr( "Set application to open external links"), this);
1420 a->setStatusTip( tr( "Set application to open external links"));
1421 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1422 settingsMenu->addAction (a);
1424 settingsMenu->addSeparator();
1425 a = new QAction( tr( "Edit branch after adding it" ), this );
1426 a->setStatusTip( tr( "Edit branch after adding it" ));
1427 a->setToggleAction(true);
1428 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1429 settingsMenu->addAction (a);
1430 actionSettingsAutoedit=a;
1432 a= new QAction( tr( "Select branch after adding it" ), this );
1433 a->setStatusTip( tr( "Select branch after adding it" ));
1434 a->setToggleAction(true);
1435 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1436 settingsMenu->addAction (a);
1437 actionSettingsAutoselectHeading=a;
1439 a= new QAction(tr( "Select existing heading" ), this);
1440 a->setStatusTip( tr( "Select heading before editing" ));
1441 a->setToggleAction(true);
1442 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1443 settingsMenu->addAction (a);
1444 actionSettingsAutoselectText=a;
1446 a= new QAction( tr( "Delete key" ), this);
1447 a->setStatusTip( tr( "Delete key for deleting branches" ));
1448 a->setToggleAction(true);
1449 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1450 settingsMenu->addAction (a);
1451 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1452 actionSettingsUseDelKey=a;
1454 a= new QAction( tr( "Exclusive flags" ), this);
1455 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1456 a->setToggleAction(true);
1457 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1458 settingsMenu->addAction (a);
1459 actionSettingsUseFlagGroups=a;
1461 a= new QAction( tr( "Use hide flags" ), this);
1462 a->setStatusTip( tr( "Use hide flag during exports " ));
1463 a->setToggleAction(true);
1464 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1465 settingsMenu->addAction (a);
1466 actionSettingsUseHideExport=a;
1470 void Main::setupTestActions()
1472 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1475 a = new QAction( tr( "test flag" ), this);
1476 a->setStatusTip( tr( "Call test function" ));
1477 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1478 testMenu->addAction (a);
1482 void Main::setupHelpActions()
1484 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1487 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1488 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1489 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1490 helpMenu->addAction (a);
1492 a = new QAction( tr( "About VYM" ), this);
1493 a->setStatusTip( tr( "About VYM")+" "__VYM);
1494 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1495 helpMenu->addAction (a);
1497 a = new QAction( tr( "About QT" ), this);
1498 a->setStatusTip( tr( "Information about QT toolkit" ));
1499 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1500 helpMenu->addAction (a);
1504 void Main::setupContextMenus()
1508 // Context Menu for branch or mapcenter
1509 branchContextMenu =new QMenu (this);
1512 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1513 branchAddContextMenu->addAction (actionEditPaste );
1514 branchAddContextMenu->addAction ( actionEditAddBranch );
1515 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1516 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1517 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1518 branchAddContextMenu->addSeparator();
1519 branchAddContextMenu->addAction ( actionEditLoadImage);
1520 branchAddContextMenu->addSeparator();
1521 branchAddContextMenu->addAction ( actionEditImportAdd );
1522 branchAddContextMenu->addAction ( actionEditImportReplace );
1525 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1526 branchRemoveContextMenu->addAction (actionEditCut);
1527 branchRemoveContextMenu->addAction ( actionEditDelete );
1528 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1529 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1532 actionEditSaveBranch->addTo( branchContextMenu );
1534 branchContextMenu->addSeparator();
1535 branchContextMenu->addAction ( actionFormatFrameNone );
1536 branchContextMenu->addAction ( actionFormatFrameRectangle);
1538 branchContextMenu->addSeparator();
1539 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1540 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1541 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1543 // Submenu for Links (URLs, vymLinks)
1544 branchLinksContextMenu =new QMenu (this);
1546 branchContextMenu->addSeparator();
1547 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));
1548 branchLinksContextMenu->addAction ( actionEditOpenURL );
1549 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1550 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1551 branchLinksContextMenu->addAction ( actionEditURL );
1552 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1553 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1554 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1556 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1558 branchLinksContextMenu->addSeparator();
1559 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1560 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1561 branchLinksContextMenu->addAction ( actionEditVymLink );
1562 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1565 // Context Menu for XLinks in a branch menu
1566 // This will be populated "on demand" in MapEditor::updateActions
1567 branchContextMenu->addSeparator();
1568 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1569 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1570 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1571 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1574 // Context menu for floatimage
1575 floatimageContextMenu =new QMenu (this);
1576 a= new QAction (tr ("Save image"),this);
1577 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1578 floatimageContextMenu->addAction (a);
1580 floatimageContextMenu->addSeparator();
1581 actionEditCopy->addTo( floatimageContextMenu );
1582 actionEditCut->addTo( floatimageContextMenu );
1584 floatimageContextMenu->addSeparator();
1585 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1588 // Context menu for canvas
1589 canvasContextMenu =new QMenu (this);
1590 actionEditMapInfo->addTo( canvasContextMenu );
1591 canvasContextMenu->insertSeparator();
1592 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1593 canvasContextMenu->insertSeparator();
1594 actionFormatLinkColorHint->addTo( canvasContextMenu );
1595 actionFormatLinkColor->addTo( canvasContextMenu );
1596 actionFormatBackColor->addTo( canvasContextMenu );
1598 // Menu for last opened files
1599 // Read settings initially
1601 int j=settings.readNumEntry( "/lastMaps/number",0);
1602 for (int i=1;i<=j;i++)
1604 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1605 if (!s.isEmpty() && j<=maxLastMaps)
1608 setupLastMapsMenu();
1609 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1612 void Main::setupLastMapsMenu()
1614 // Remove double entries
1615 QStringList::Iterator it=lastMaps.begin();
1616 QStringList::Iterator jt;
1617 while (it!=lastMaps.end() )
1621 while (jt!=lastMaps.end() )
1624 jt=lastMaps.remove(jt);
1631 // Limit length of list to maxLastMaps
1632 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1634 // build Menu from lastMaps string list
1635 fileLastMapsMenu->clear();
1636 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1637 fileLastMapsMenu->addAction (*it );
1640 void Main::hideEvent (QHideEvent * )
1642 if (!textEditor->isMinimized() ) textEditor->hide();
1645 void Main::showEvent (QShowEvent * )
1647 if (textEditor->showWithMain()) textEditor->showNormal();
1650 bool Main::reallyWriteDirectory(const QString &dir)
1652 QStringList eList = QDir(dir).entryList();
1653 if (eList.first() ==".") eList.pop_front(); // remove "."
1654 if (eList.first() =="..") eList.pop_front(); // remove "."
1655 if (!eList.isEmpty())
1657 QMessageBox mb( __VYM,
1658 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1659 QMessageBox::Warning,
1661 QMessageBox::Cancel | QMessageBox::Default,
1662 QMessageBox::QMessageBox::NoButton );
1664 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1665 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1668 case QMessageBox::Yes:
1671 case QMessageBox::Cancel:
1679 QString Main::browseDirectory (const QString &caption)
1681 Q3FileDialog fd(this,caption);
1682 fd.setMode (Q3FileDialog::DirectoryOnly);
1683 fd.setCaption(__VYM " - "+caption);
1686 if ( fd.exec() == QDialog::Accepted )
1687 return fd.selectedFile();
1692 MapEditor* Main::currentMapEditor() const
1694 if ( tabWidget->currentPage() &&
1695 tabWidget->currentPage()->inherits( "MapEditor" ) )
1696 return (MapEditor*)tabWidget->currentPage();
1700 //TODO not used now, maybe use this for overview window later
1701 void Main::newView()
1703 // Open a new view... have it delete when closed.
1704 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1705 qApp->setMainWidget(m);
1707 qApp->setMainWidget(0);
1710 void Main::editorChanged(QWidget *)
1712 // Unselect all possibly selected objects
1713 // (Important to update note editor)
1716 for (i=0;i<=tabWidget->count() -1;i++)
1719 me=(MapEditor*)tabWidget->page(i);
1722 currentMapEditor()->reselect();
1724 // Update actions to in menus and toolbars according to editor
1725 currentMapEditor()->updateActions();
1728 void Main::fileNew()
1730 QString fn="unnamed";
1731 MapEditor* medit = new MapEditor ( NULL,true);
1732 tabWidget->addTab (medit,fn);
1733 tabWidget->showPage(medit);
1734 medit->viewport()->setFocus();
1735 // For the very first map we do not have flagrows yet...
1736 medit->select("mc:");
1739 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1741 ErrorCode err=success;
1743 // fn is usually the archive, mapfile the file after uncompressing
1746 // Make fn absolute (needed for unzip)
1747 fn=QDir (fn).absPath();
1753 // Check, if map is already loaded
1755 while (i<=tabWidget->count() -1)
1757 me=(MapEditor*)tabWidget->page(i);
1758 if (me->getFilePath() == fn)
1760 // Already there, ask for confirmation
1761 QMessageBox mb( __VYM,
1762 tr("The map %1\nis already opened."
1763 "Opening the same map in multiple editors may lead \n"
1764 "to confusion when finishing working with vym."
1765 "Do you want to").arg(fn),
1766 QMessageBox::Warning,
1767 QMessageBox::Yes | QMessageBox::Default,
1768 QMessageBox::Cancel | QMessageBox::Escape,
1769 QMessageBox::NoButton);
1770 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1771 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1774 case QMessageBox::Yes:
1776 i=tabWidget->count();
1778 case QMessageBox::Cancel:
1790 if ( !fn.isEmpty() )
1792 me = currentMapEditor();
1793 int tabIndex=tabWidget->currentPageIndex();
1794 // Check first, if mapeditor exists
1795 // If it is not default AND we want a new map,
1796 // create a new mapeditor in a new tab
1797 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1799 me= new MapEditor ( NULL,true);
1800 tabWidget->addTab (me,fn);
1801 tabIndex=tabWidget->indexOf (me);
1802 tabWidget->setCurrentPage (tabIndex);
1805 // Check, if file exists (important for creating new files
1806 // from command line
1807 if (!QFile(fn).exists() )
1809 QMessageBox mb( __VYM,
1810 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1811 QMessageBox::Question,
1813 QMessageBox::Cancel | QMessageBox::Default,
1814 QMessageBox::NoButton );
1816 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1817 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1820 case QMessageBox::Yes:
1822 currentMapEditor()->setFilePath(fn);
1823 tabWidget->setTabLabel (currentMapEditor(),
1824 currentMapEditor()->getFileName() );
1825 statusBar()->message( "Created " + fn , statusbarTime );
1828 case QMessageBox::Cancel:
1829 // don't create new map
1830 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1837 //tabWidget->currentPage() won't be NULL here, because of above...
1838 tabWidget->showPage(me);
1839 me->viewport()->setFocus();
1841 // Create temporary directory for packing
1842 char tmpdir1[]="/tmp/vym-XXXXXX";
1843 QString tmpMapDir=mkdtemp(tmpdir1);
1845 // Try to unzip file
1846 err=unzipDir (tmpMapDir,fn);
1850 me->setZipped(false);
1853 me->setZipped(true);
1855 // Look for mapname.xml
1856 mapfile= fn.left(fn.findRev(".",-1,true));
1857 mapfile=mapfile.section( '/', -1 );
1858 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1859 if (!file.exists() )
1861 // mapname.xml does not exist, well,
1862 // maybe some renamed the mapname.vym file...
1863 // Try to find any .xml in the toplevel
1864 // directory of the .vym file
1865 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1866 if (flist.count()==1)
1868 // Only one entry, take this one
1869 mapfile=tmpMapDir + "/"+flist.first();
1872 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1873 *it=tmpMapDir + "/" + *it;
1874 // TODO Multiple entries, load all (but only the first one into this ME)
1875 //mainWindow->fileLoadFromTmp (flist);
1876 //returnCode=1; // Silently forget this attempt to load
1877 qWarning ("MainWindow::load (fn) multimap found...");
1880 if (flist.isEmpty() )
1882 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1883 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1886 } //file doesn't exist
1888 mapfile=file.name();
1893 // Save existing filename in case we import
1894 QString fn_org=me->getFilePath();
1896 // Finally load map into mapEditor
1897 me->setFilePath (mapfile,fn);
1898 err=me->load(mapfile,lmode);
1900 // Restore old (maybe empty) filepath, if this is an import
1902 me->setFilePath (fn_org);
1905 // Finally check for errors and go home
1908 if (lmode==NewMap) fileCloseMap();
1909 statusBar()->message( "Could not load " + fn, statusbarTime );
1914 me->setFilePath (fn);
1915 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1916 if (fn.left(9)!="/tmp/vym-")
1918 // Only append to lastMaps if not loaded from a tmpDir
1919 // e.g. imported bookmarks are in a tmpDir
1920 lastMaps.prepend(me->getFilePath() );
1921 setupLastMapsMenu();
1923 actionFilePrint->setEnabled (true);
1925 statusBar()->message( "Loaded " + fn, statusbarTime );
1929 removeDir (QDir(tmpMapDir));
1935 void Main::fileLoad(const LoadMode &lmode)
1937 Q3FileDialog *fd=new Q3FileDialog( this);
1938 fd->setDir (lastFileDir);
1939 fd->setMode (Q3FileDialog::ExistingFiles);
1940 fd->addFilter ("XML (*.xml)");
1941 fd->addFilter ("VYM map (*.vym *.vyp)");
1945 fd->setCaption(tr("Load vym map"));
1948 fd->setCaption(tr("Import: Add vym map to selection"));
1951 fd->setCaption(tr("Import: Replace selection with vym map"));
1957 if ( fd->exec() == QDialog::Accepted )
1959 lastFileDir=fd->dirPath();
1960 QStringList flist = fd->selectedFiles();
1961 QStringList::Iterator it = flist.begin();
1962 while( it != flist.end() )
1965 fileLoad(*it, lmode);
1972 void Main::fileLoad()
1977 void Main::fileLoadLast(QAction *a)
1979 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1982 void Main::fileSave(const SaveMode &savemode)
1984 // tmp dir for zipping
1988 ErrorCode err=success;
1990 QString safeFilePath;
1992 bool saveZipped=currentMapEditor()->saveZipped();
1994 MapEditor * me=currentMapEditor();
1997 QString fn=me->getFilePath();
1998 // filename=unnamed, filepath="" in constructor...
1999 if ( !fn.isEmpty() )
2001 // We have a filepath, go on saving
2002 // First remove existing file, we
2003 // don't want to add to old zip archives
2007 QMessageBox::warning( 0, tr( "Save Error" ),
2008 fn+ tr("\ncould not be removed before saving"));
2010 // Look, if we should zip the data:
2013 QMessageBox mb( __VYM,
2014 tr("The map %1\ndid not use the compressed "
2015 "vym file format.\nWriting it uncompressed will also write images \n"
2016 "and flags and thus may overwrite files in the "
2017 "given directory\n\nDo you want to write the map").arg(fn),
2018 QMessageBox::Warning,
2019 QMessageBox::Yes | QMessageBox::Default,
2021 QMessageBox::Cancel | QMessageBox::Escape);
2022 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2023 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2024 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2027 case QMessageBox::Yes:
2028 // save compressed (default file format)
2031 case QMessageBox::No:
2032 // save uncompressed
2035 case QMessageBox::Cancel:
2044 char tmpdir1[]="/tmp/vym-XXXXXX";
2045 tmpMapDir=mkdtemp(tmpdir1);
2047 safeFilePath=me->getFilePath();
2048 me->setFilePath (tmpMapDir+"/"+
2049 me->getMapName()+ ".xml",
2051 me->save (savemode);
2052 me->setFilePath (safeFilePath);
2054 zipDir (tmpMapDir,fn);
2059 safeFilePath=me->getFilePath();
2060 me->setFilePath (fn, safeFilePath);
2061 me->save (savemode);
2062 me->setFilePath (safeFilePath);
2064 } // filepath available
2067 // We have no filepath yet,
2068 // call fileSaveAs() now, this will call fileSave()
2070 fileSaveAs(savemode);
2074 if (saveZipped && !tmpMapDir.isEmpty())
2076 removeDir (QDir(tmpMapDir));
2080 statusBar()->message(
2081 tr("Saved %1").arg(me->getFilePath()),
2083 lastMaps.prepend(me->getFilePath() );
2084 setupLastMapsMenu();
2086 statusBar()->message(
2087 tr("Couldn't save ").arg(me->getFilePath()),
2091 void Main::fileSave()
2093 fileSave (CompleteMap);
2096 void Main::fileSaveAs(const SaveMode& savemode)
2100 if (currentMapEditor())
2102 if (savemode==CompleteMap)
2103 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2105 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2106 if ( !fn.isEmpty() )
2108 // Check for existing file
2109 if (QFile (fn).exists())
2111 QMessageBox mb( __VYM,
2112 tr("The file %1\nexists already. Do you want to").arg(fn),
2113 QMessageBox::Warning,
2114 QMessageBox::Yes | QMessageBox::Default,
2115 QMessageBox::Cancel | QMessageBox::Escape,
2116 QMessageBox::NoButton);
2117 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2118 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2121 case QMessageBox::Yes:
2124 case QMessageBox::Cancel:
2131 // New file, add extension to filename, if missing
2132 // This is always .vym or .vyp, depending on savemode
2133 if (savemode==CompleteMap)
2135 if (!fn.contains (".vym") && !fn.contains (".xml"))
2139 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2148 currentMapEditor()->setFilePath(fn);
2152 if (savemode==CompleteMap)
2153 tabWidget->setTabLabel (currentMapEditor(),
2154 currentMapEditor()->getFileName() );
2160 void Main::fileSaveAs()
2162 fileSaveAs (CompleteMap);
2165 void Main::fileImportKDEBookmarks()
2167 ImportKDEBookmarks im;
2169 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2170 currentMapEditor()->setFilePath ("");
2173 void Main::fileImportFirefoxBookmarks()
2175 Q3FileDialog *fd=new Q3FileDialog( this);
2176 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2177 fd->setMode (Q3FileDialog::ExistingFiles);
2178 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2179 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2182 if ( fd->exec() == QDialog::Accepted )
2184 ImportFirefoxBookmarks im;
2185 QStringList flist = fd->selectedFiles();
2186 QStringList::Iterator it = flist.begin();
2187 while( it != flist.end() )
2190 if (im.transform() &&
2191 success==fileLoad (im.getTransformedFile(),NewMap) &&
2192 currentMapEditor() )
2193 currentMapEditor()->setFilePath ("");
2200 void Main::fileImportMM()
2204 Q3FileDialog *fd=new Q3FileDialog( this);
2205 fd->setDir (lastFileDir);
2206 fd->setMode (Q3FileDialog::ExistingFiles);
2207 fd->addFilter ("Mind Manager (*.mmap)");
2208 fd->setCaption(tr("Import")+" "+"Mind Manager");
2211 if ( fd->exec() == QDialog::Accepted )
2213 lastFileDir=fd->dirPath();
2214 QStringList flist = fd->selectedFiles();
2215 QStringList::Iterator it = flist.begin();
2216 while( it != flist.end() )
2219 if (im.transform() &&
2220 success==fileLoad (im.getTransformedFile(),NewMap) &&
2221 currentMapEditor() )
2222 currentMapEditor()->setFilePath ("");
2231 void Main::fileImportDir()
2233 if (currentMapEditor())
2234 currentMapEditor()->importDir();
2237 void Main::fileExportXML()
2239 if (currentMapEditor())
2241 QString dir=browseDirectory(tr("Export XML to directory"));
2242 if (dir !="" && reallyWriteDirectory(dir) )
2243 currentMapEditor()->exportXML(dir);
2248 void Main::fileExportXHTML()
2250 MapEditor *me=currentMapEditor();
2254 ExportXHTMLDialog dia(this);
2255 dia.setFilePath (me->getFilePath() );
2256 dia.setMapName (me->getMapName() );
2259 if (dia.exec()==QDialog::Accepted)
2261 QString dir=dia.getDir();
2262 // Check, if warnings should be used before overwriting
2263 // the output directory
2266 ok=reallyWriteDirectory(dir);
2272 me->exportXML (dia.getDir() );
2273 dia.doExport(me->getMapName() );
2274 if (dia.hasChanged())
2281 void Main::fileExportImage()
2283 MapEditor *me=currentMapEditor();
2287 QFileDialog *fd=new QFileDialog (this);
2288 fd->setCaption (tr("Export map as image"));
2289 fd->setFileMode(QFileDialog::AnyFile);
2290 fd->setFilters (imageIO.getFilters() );
2291 fd->setDirectory (lastImageDir);
2294 fl=fd->selectedFiles();
2295 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2296 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2301 void Main::fileExportASCII()
2303 MapEditor *me=currentMapEditor();
2307 ex.setMapCenter(me->getMapCenter());
2308 ex.addFilter ("TXT (*.txt)");
2309 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2310 if (ex.execDialog() )
2312 me->setExportMode(true);
2314 me->setExportMode(false);
2319 void Main::fileExportLaTeX()
2321 MapEditor *me=currentMapEditor();
2325 ex.setMapCenter(me->getMapCenter());
2326 ex.addFilter ("Tex (*.tex)");
2327 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2328 if (ex.execDialog() )
2330 me->setExportMode(true);
2332 me->setExportMode(false);
2337 void Main::fileExportKDEBookmarks()
2339 ExportKDEBookmarks ex;
2340 MapEditor *me=currentMapEditor();
2343 ex.setMapCenter (me->getMapCenter() );
2348 void Main::fileExportTaskjuggler()
2350 ExportTaskjuggler ex;
2351 MapEditor *me=currentMapEditor();
2354 ex.setMapCenter (me->getMapCenter() );
2355 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2356 ex.addFilter ("Taskjuggler (*.tjp)");
2357 if (ex.execDialog() )
2359 me->setExportMode(true);
2361 me->setExportMode(false);
2366 void Main::fileExportOOPresentation()
2368 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2369 // TODO add preview in dialog
2370 //ImagePreview *p =new ImagePreview (fd);
2371 //fd->setContentsPreviewEnabled( TRUE );
2372 //fd->setContentsPreview( p, p );
2373 //fd->setPreviewMode( QFileDialog::Contents );
2374 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2375 fd->setDir (QDir().current());
2376 if (fd->foundConfig())
2380 if ( fd->exec() == QDialog::Accepted )
2382 QString fn=fd->selectedFile();
2383 if (!fn.contains (".odp"))
2386 //lastImageDir=fn.left(fn.findRev ("/"));
2387 if (currentMapEditor())
2388 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2392 QMessageBox::warning(0,
2394 tr("Couldn't find configuration for export to Open Office\n"));
2398 void Main::fileCloseMap()
2400 if (currentMapEditor())
2402 if (currentMapEditor()->hasChanged())
2404 QMessageBox mb( __VYM,
2405 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2406 QMessageBox::Warning,
2407 QMessageBox::Yes | QMessageBox::Default,
2409 QMessageBox::Cancel | QMessageBox::Escape );
2410 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2411 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2414 case QMessageBox::Yes:
2416 fileSave(CompleteMap);
2418 case QMessageBox::No:
2419 // close without saving
2421 case QMessageBox::Cancel:
2426 currentMapEditor()->closeMap();
2427 tabWidget->removePage(currentMapEditor());
2428 if (tabWidget->count()==0)
2429 actionFilePrint->setEnabled (false);
2433 void Main::filePrint()
2435 if (currentMapEditor())
2436 currentMapEditor()->print();
2439 void Main::fileExitVYM()
2441 // Check if one or more editors have changed
2444 for (i=0;i<=tabWidget->count() -1;i++)
2447 me=(MapEditor*)tabWidget->page(i);
2449 // If something changed, ask what to do
2450 if (me->isUnsaved())
2452 tabWidget->setCurrentPage(i);
2453 QMessageBox mb( __VYM,
2454 tr("This map is not saved yet. Do you want to"),
2455 QMessageBox::Warning,
2456 QMessageBox::Yes | QMessageBox::Default,
2458 QMessageBox::Cancel | QMessageBox::Escape );
2459 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2460 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2463 mb.setActiveWindow();
2464 switch( mb.exec() ) {
2465 case QMessageBox::Yes:
2466 // save (the changed editors) and exit
2467 fileSave(CompleteMap);
2469 case QMessageBox::No:
2470 // exit without saving
2472 case QMessageBox::Cancel:
2473 // don't save and don't exit
2477 } // loop over all MEs
2481 void Main::editUndo()
2483 if (currentMapEditor())
2484 currentMapEditor()->undo();
2487 void Main::editRedo()
2489 if (currentMapEditor())
2490 currentMapEditor()->redo();
2493 void Main::editCopy()
2495 if (currentMapEditor())
2496 currentMapEditor()->copy();
2499 void Main::editPaste()
2501 if (currentMapEditor())
2502 currentMapEditor()->paste();
2505 void Main::editCut()
2507 if (currentMapEditor())
2508 currentMapEditor()->cut();
2511 void Main::editOpenFindWindow()
2513 findWindow->popup();
2514 findWindow->raise();
2515 findWindow->setActiveWindow();
2518 void Main::editFind(QString s)
2521 BranchObj *bo=currentMapEditor()->findText(s, cs);
2524 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2527 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2528 tr("No matches found for \"%1\"").arg(s));
2532 void Main::editFindChanged()
2533 { // Notify editor, to abort the current find process
2534 currentMapEditor()->findReset();
2537 void Main::openTabs(QStringList urls)
2539 if (!urls.isEmpty())
2543 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2545 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2547 QString u=urls.takeFirst();
2548 procBrowser = new QProcess( this );
2550 procBrowser->start(browser,args);
2551 if ( !procBrowser->waitForStarted())
2553 // try to set path to browser
2554 QMessageBox::warning(0,
2556 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2557 tr("Please use Settings->")+tr("Set application to open an URL"));
2562 if (browser.contains("konqueror"))
2564 for (int i=0; i<urls.size(); i++)
2567 // Try to open new tab in existing konqueror started previously by vym
2568 p=new QProcess (this);
2570 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2571 "konqueror-mainwindow#1"<<
2574 p->start ("dcop",args);
2575 if ( !p->waitForStarted() ) success=false;
2578 QMessageBox::warning(0,
2580 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2582 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2584 for (int i=0; i<urls.size(); i++)
2586 // Try to open new tab in firefox
2587 p=new QProcess (this);
2588 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2589 p->start (browser,args);
2590 if ( !p->waitForStarted() ) success=false;
2593 QMessageBox::warning(0,
2595 tr("Couldn't start %1 to open a new tab").arg(browser));
2598 QMessageBox::warning(0,
2600 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2604 void Main::editOpenURL()
2607 if (currentMapEditor())
2609 QString url=currentMapEditor()->getURL();
2611 if (url=="") return;
2612 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2613 procBrowser = new QProcess( this );
2615 procBrowser->start(browser,args);
2616 if ( !procBrowser->waitForStarted())
2618 // try to set path to browser
2619 QMessageBox::warning(0,
2621 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2622 tr("Please use Settings->")+tr("Set application to open an URL"));
2627 void Main::editOpenURLTab()
2629 if (currentMapEditor())
2632 urls.append(currentMapEditor()->getURL());
2636 void Main::editOpenMultipleURLTabs()
2638 if (currentMapEditor())
2641 urls=currentMapEditor()->getURLs();
2647 void Main::editURL()
2649 if (currentMapEditor())
2650 currentMapEditor()->editURL();
2653 void Main::editHeading2URL()
2655 if (currentMapEditor())
2656 currentMapEditor()->editHeading2URL();
2659 void Main::editBugzilla2URL()
2661 if (currentMapEditor())
2662 currentMapEditor()->editBugzilla2URL();
2665 void Main::editFATE2URL()
2667 if (currentMapEditor())
2668 currentMapEditor()->editFATE2URL();
2671 void Main::editHeading()
2673 if (lineedit->isVisible())
2675 if (currentMapEditor())
2677 MapEditor *me=currentMapEditor();
2678 QString oldSel=me->getSelectString();
2679 if (me->select (editSel))
2680 me->setHeading(lineedit->text());
2681 me->select (oldSel);
2683 lineedit->releaseKeyboard();
2688 if (currentMapEditor())
2692 QString s=currentMapEditor()->getHeading(ok,p);
2696 #if defined(Q_OS_MACX)
2697 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2698 QDialog *d =new QDialog(NULL);
2699 QLineEdit *le=new QLineEdit (d);
2700 d->setWindowFlags (Qt::FramelessWindowHint);
2701 d->setGeometry(p.x(),p.y(),200,25);
2702 le->resize (d->size());
2705 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2706 d->activateWindow();
2708 currentMapEditor()->setHeading (le->text());
2710 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2711 lineedit->setGeometry(p.x(),p.y(),200,25);
2712 lineedit->setText(s);
2713 lineedit->setCursorPosition(1);
2714 lineedit->selectAll();
2716 lineedit->grabKeyboard();
2717 lineedit->setFocus();
2719 editSel=currentMapEditor()->getSelectString();
2727 void Main::openVymLinks(const QStringList &vl)
2729 for (int j=0; j<vl.size(); j++)
2731 // compare path with already loaded maps
2735 for (i=0;i<=tabWidget->count() -1;i++)
2737 me=(MapEditor*)tabWidget->page(i);
2738 if (vl.at(j)==me->getFilePath() )
2747 if (!QFile(vl.at(j)).exists() )
2748 QMessageBox::critical( 0, tr( "Critical Error" ),
2749 tr("Couldn't open map %1").arg(vl.at(j)));
2752 fileLoad (vl.at(j), NewMap);
2753 tabWidget->setCurrentPage (tabWidget->count()-1);
2756 // Go to tab containing the map
2757 tabWidget->setCurrentPage (index);
2761 void Main::editOpenVymLink()
2763 if (currentMapEditor())
2766 vl.append(currentMapEditor()->getVymLink());
2771 void Main::editOpenMultipleVymLinks()
2773 QString currentVymLink;
2774 if (currentMapEditor())
2776 QStringList vl=currentMapEditor()->getVymLinks();
2781 void Main::editVymLink()
2783 if (currentMapEditor())
2784 currentMapEditor()->editVymLink();
2787 void Main::editDeleteVymLink()
2789 if (currentMapEditor())
2790 currentMapEditor()->deleteVymLink();
2793 void Main::editToggleHideExport()
2795 if (currentMapEditor())
2796 currentMapEditor()->toggleHideExport();
2799 void Main::editMapInfo()
2801 if (currentMapEditor())
2802 currentMapEditor()->editMapInfo();
2805 void Main::editMoveUp()
2807 if (currentMapEditor())
2808 currentMapEditor()->moveBranchUp();
2811 void Main::editMoveDown()
2813 if (currentMapEditor())
2814 currentMapEditor()->moveBranchDown();
2817 void Main::editToggleScroll()
2819 if (currentMapEditor())
2821 currentMapEditor()->toggleScroll();
2825 void Main::editUnScrollAll()
2827 if (currentMapEditor())
2829 currentMapEditor()->unScrollAll();
2833 void Main::editNewBranch()
2836 if (!lineedit->isVisible() && currentMapEditor())
2837 currentMapEditor()->addNewBranch(0);
2840 void Main::editNewBranchHere()
2842 if (currentMapEditor())
2843 currentMapEditor()->addNewBranchHere();
2846 void Main::editNewBranchAbove()
2848 if (currentMapEditor())
2849 currentMapEditor()->addNewBranch(-1);
2852 void Main::editNewBranchBelow()
2854 if (currentMapEditor())
2855 currentMapEditor()->addNewBranch(1);
2858 void Main::editImportAdd()
2860 fileLoad (ImportAdd);
2863 void Main::editImportReplace()
2865 fileLoad (ImportReplace);
2868 void Main::editSaveBranch()
2870 fileSaveAs (PartOfMap);
2873 void Main::editRemoveBranchKeepChilds()
2875 if (currentMapEditor())
2876 currentMapEditor()->removeBranchKeepChilds();
2879 void Main::editRemoveChilds()
2881 if (currentMapEditor())
2882 currentMapEditor()->removeChilds();
2885 void Main::editDeleteSelection()
2887 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2888 currentMapEditor()->deleteSelection();
2891 void Main::editUpperBranch()
2893 if (currentMapEditor())
2894 currentMapEditor()->selectUpperBranch();
2897 void Main::editLowerBranch()
2899 if (currentMapEditor())
2900 currentMapEditor()->selectLowerBranch();
2903 void Main::editLeftBranch()
2905 if (currentMapEditor())
2906 currentMapEditor()->selectLeftBranch();
2909 void Main::editRightBranch()
2911 if (currentMapEditor())
2912 currentMapEditor()->selectRightBranch();
2915 void Main::editFirstBranch()
2917 if (currentMapEditor())
2918 currentMapEditor()->selectFirstBranch();
2921 void Main::editLastBranch()
2923 if (currentMapEditor())
2924 currentMapEditor()->selectLastBranch();
2927 void Main::editLoadImage()
2929 if (currentMapEditor())
2930 currentMapEditor()->loadFloatImage();
2933 void Main::editSaveImage()
2935 if (currentMapEditor())
2936 currentMapEditor()->saveFloatImage();
2939 void Main::editFollowXLink(QAction *a)
2942 if (currentMapEditor())
2943 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2946 void Main::editEditXLink(QAction *a)
2948 if (currentMapEditor())
2949 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2952 void Main::formatSelectColor()
2954 if (currentMapEditor())
2956 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2957 if ( !col.isValid() ) return;
2958 currentMapEditor()->setColor( col );
2959 colorChanged( col );
2963 void Main::formatPickColor()
2965 if (currentMapEditor())
2966 colorChanged( currentMapEditor()->pickColor() );
2969 void Main::colorChanged(QColor c)
2971 QPixmap pix( 16, 16 );
2973 actionFormatColor->setIconSet( pix );
2976 void Main::formatColorItem()
2978 if (currentMapEditor())
2979 currentMapEditor()->colorItem();
2982 void Main::formatColorBranch()
2984 if (currentMapEditor())
2985 currentMapEditor()->colorBranch();
2988 void Main::formatLinkStyleLine()
2990 if (currentMapEditor())
2991 currentMapEditor()->setLinkStyle(StyleLine);
2994 void Main::formatLinkStyleParabel()
2996 if (currentMapEditor())
2997 currentMapEditor()->setLinkStyle(StyleParabel);
3000 void Main::formatLinkStylePolyLine()
3002 if (currentMapEditor())
3003 currentMapEditor()->setLinkStyle(StylePolyLine);
3006 void Main::formatLinkStylePolyParabel()
3008 if (currentMapEditor())
3009 currentMapEditor()->setLinkStyle(StylePolyParabel);
3012 void Main::formatSelectBackColor()
3014 if (currentMapEditor())
3015 currentMapEditor()->selectBackgroundColor();
3018 void Main::formatSelectLinkColor()
3020 if (currentMapEditor())
3021 currentMapEditor()->selectLinkColor();
3024 void Main::formatToggleLinkColorHint()
3026 currentMapEditor()->toggleLinkColorHint();
3029 void Main::formatFrameNone()
3031 if (currentMapEditor())
3032 currentMapEditor()->setFrame(NoFrame);
3035 void Main::formatFrameRectangle()
3037 if (currentMapEditor())
3038 currentMapEditor()->setFrame(Rectangle);
3041 void Main::formatIncludeImagesVer()
3043 if (currentMapEditor())
3044 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3047 void Main::formatIncludeImagesHor()
3049 if (currentMapEditor())
3050 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3053 void Main::formatHideLinkUnselected()
3055 if (currentMapEditor())
3056 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3059 void Main::viewZoomReset()
3061 if (currentMapEditor())
3065 currentMapEditor()->setWorldMatrix( m );
3066 currentMapEditor()->setViewCenter();
3067 currentMapEditor()->adjustCanvasSize();
3071 void Main::viewZoomIn()
3073 if (currentMapEditor())
3075 QMatrix m = currentMapEditor()->worldMatrix();
3076 m.scale( 1.25, 1.25 );
3077 currentMapEditor()->setWorldMatrix( m );
3078 currentMapEditor()->setViewCenter();
3079 currentMapEditor()->adjustCanvasSize();
3083 void Main::viewZoomOut()
3085 if (currentMapEditor())
3087 QMatrix m = currentMapEditor()->worldMatrix();
3088 m.scale( 0.8, 0.8 );
3089 currentMapEditor()->setWorldMatrix( m );
3090 currentMapEditor()->setViewCenter();
3091 currentMapEditor()->adjustCanvasSize();
3095 void Main::modModeColor()
3099 void Main::modModeLink()
3103 bool Main::settingsPDF()
3105 // Default browser is set in constructor
3107 QString text = QInputDialog::getText(
3108 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3109 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3111 settings.setValue ("/mainwindow/readerPDF",text);
3116 bool Main::settingsURL()
3118 // Default browser is set in constructor
3120 QString text = QInputDialog::getText(
3121 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3122 settings.value("/mainwindow/readerURL").toString()
3125 settings.setValue ("/mainwindow/readerURL",text);
3129 void Main::settingsToggleDelKey()
3131 if (actionSettingsUseDelKey->isOn())
3133 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3136 actionEditDelete->setAccel (QKeySequence (""));
3140 void Main::windowToggleNoteEditor()
3142 if (textEditor->showWithMain() )
3143 windowHideNoteEditor();
3145 windowShowNoteEditor();
3148 void Main::windowToggleHistory()
3150 if (currentMapEditor())
3151 currentMapEditor()->toggleHistoryWindow();
3154 void Main::updateNoteFlag()
3156 if (currentMapEditor())
3157 currentMapEditor()->updateNoteFlag();
3160 void Main::windowShowNoteEditor()
3162 textEditor->setShowWithMain(true);
3164 actionViewToggleNoteEditor->setOn (true);
3167 void Main::windowHideNoteEditor()
3169 textEditor->setShowWithMain(false);
3171 actionViewToggleNoteEditor->setOn (false);
3174 void Main::windowNextEditor()
3176 if (tabWidget->currentPageIndex() < tabWidget->count())
3177 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3180 void Main::windowPreviousEditor()
3182 if (tabWidget->currentPageIndex() >0)
3183 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3186 void Main::standardFlagChanged()
3188 currentMapEditor()->toggleStandardFlag(sender()->name());
3191 void Main::testFunction()
3193 currentMapEditor()->testFunction();
3196 void Main::helpDoc()
3199 #if defined(Q_OS_MACX)
3200 docpath="./vym.app/Contents/vym.pdf";
3202 // default path in SUSE LINUX
3203 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3206 if (!QFile (docpath).exists() )
3208 // relative path for easy testing in tarball
3209 docpath="doc/vym.pdf";
3210 if (!QFile (docpath).exists() )
3212 // relative path for testing while still writing vym.tex
3213 docpath="doc/tex/vym.pdf";
3214 if (!QFile (docpath).exists() )
3216 // Try yet another one for Knoppix
3217 docpath="/usr/share/doc/packages/vym/vym.pdf";
3218 if (!QFile (docpath).exists() )
3220 QMessageBox::critical(0,
3221 tr("Critcal error"),
3222 tr("Couldn't find the documentation\n"
3223 "vym.pdf in various places."));
3230 Process *pdfProc = new Process();
3231 pdfProc->clearArguments();
3232 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3233 pdfProc->addArgument( docpath);
3235 if ( !pdfProc->start() )
3238 QMessageBox::warning(0,
3240 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3241 tr("Please use Settings->")+tr("Set application to open PDF files"));
3248 void Main::helpAbout()
3251 ad.setName ("aboutwindow");
3252 ad.setMinimumSize(500,500);
3253 ad.resize (QSize (500,500));
3257 void Main::helpAboutQT()
3259 QMessageBox::aboutQt( this, "Qt Application Example" );