1 #include "mainwindow.h"
7 #include <q3filedialog.h>
9 #include <QColorDialog>
11 #include <QInputDialog>
15 #include <QCloseEvent>
18 #include <Q3PopupMenu>
19 #include <QActionGroup>
21 //#include <qdatetime.h> // for random seed
27 #include "aboutdialog.h"
28 #include "exportoofiledialog.h"
30 #include "exportxhtmldialog.h"
32 #include "flagrowobj.h"
34 #include "mapeditor.h"
39 #include "showtextdialog.h"
40 #include "texteditor.h"
43 extern TextEditor *textEditor;
44 extern Main *mainWindow;
45 extern QString tmpVymDir;
46 extern QString clipboardDir;
47 extern bool clipboardEmpty;
48 extern int statusbarTime;
49 extern FlagRowObj* standardFlagsDefault;
50 extern FlagRowObj* systemFlagsDefault;
52 extern Q3PtrList <QAction> actionListBranches;
54 extern QAction* actionFileSave;
55 extern QAction* actionFilePrint;
56 extern QAction* actionEditUndo;
57 extern QAction* actionEditRedo;
58 extern QAction *actionEditCopy;
59 extern QAction *actionEditCut;
60 extern QAction *actionEditPaste;
61 extern QAction *actionEditMoveUp;
62 extern QAction *actionEditMoveDown;
63 extern QAction *actionEditToggleScroll;
64 extern QAction* actionEditOpenURL;
65 extern QAction* actionEditOpenURLTab;
66 extern QAction* actionEditOpenMultipleURLTabs;
67 extern QAction* actionEditURL;
68 extern QAction* actionEditHeading2URL;
69 extern QAction* actionEditBugzilla2URL;
70 extern QAction* actionEditFATE2URL;
71 extern QAction *actionEditOpenVymLink;
72 extern QAction *actionEditOpenMultipleVymLinks;
73 extern QAction *actionEditVymLink;
74 extern QAction *actionEditDeleteVymLink;
75 extern QAction *actionEditToggleHideExport;
76 extern QAction *actionEditMapInfo;
77 extern QAction *actionEditHeading;
78 extern QAction *actionEditDelete;
79 extern QAction *actionEditAddBranch;
80 extern QAction *actionEditAddBranchHere;
81 extern QAction *actionEditAddBranchAbove;
82 extern QAction *actionEditAddBranchBelow;
83 extern QAction *actionEditRemoveBranchKeepChilds;
84 extern QAction *actionEditRemoveChilds;
85 extern QAction *actionEditImportAdd;
86 extern QAction *actionEditImportReplace;
87 extern QAction *actionEditSaveBranch;
88 extern QAction *actionEditSelectFirst;
89 extern QAction *actionEditSelectLast;
90 extern QAction *actionEditLoadImage;
92 extern QAction* actionFormatColor;
93 extern QAction* actionFormatPickColor;
94 extern QAction* actionFormatColorBranch;
95 extern QAction* actionFormatColorSubtree;
96 extern QAction* actionFormatLinkColorHint;
97 extern QAction* actionFormatBackColor;
98 extern QAction* actionFormatLinkColor;
99 extern QAction *actionFormatIncludeImagesVer;
100 extern QAction *actionFormatIncludeImagesHor;
102 extern QActionGroup* actionGroupModModes;
103 extern QAction* actionModModeColor;
104 extern QAction* actionModModeLink;
105 extern QAction* actionModModeCopy;
107 extern QActionGroup *actionGroupFormatFrameTypes;
108 extern QAction *actionFormatFrameNone;
109 extern QAction *actionFormatFrameRectangle;
111 extern QActionGroup *actionGroupFormatLinkStyles;
112 extern QAction *actionFormatLinkStyleLine;
113 extern QAction *actionFormatLinkStyleParabel;
114 extern QAction *actionFormatLinkStylePolyLine;
115 extern QAction *actionFormatLinkStylePolyParabel;
116 extern QAction *actionFormatHideLinkUnselected;
118 extern QAction *actionViewToggleNoteEditor;
119 extern QAction *actionViewToggleHistoryWindow;
121 extern QAction* actionSettingsAutoedit;
122 extern QAction* actionSettingsAutoselectHeading;
123 extern QAction* actionSettingsAutoselectHeading;
124 extern QAction* actionSettingsAutoselectText;
125 extern QAction* actionSettingsUseDelKey;
126 extern QAction* actionSettingsUseFlagGroups;
127 extern QAction* actionSettingsUseHideExport;
129 extern QMenu* branchContextMenu;
130 extern QMenu* branchAddContextMenu;
131 extern QMenu* branchRemoveContextMenu;
132 extern QMenu* branchLinksContextMenu;
133 extern QMenu* branchXLinksContextMenuEdit;
134 extern QMenu* branchXLinksContextMenuFollow;
135 extern QMenu* floatimageContextMenu;
136 extern QMenu* canvasContextMenu;
137 extern QMenu* fileLastMapsMenu;
138 extern QMenu* fileImportMenu;
139 extern QMenu* fileExportMenu;
142 extern Settings settings;
143 extern Options options;
144 extern ImageIO imageIO;
146 extern QDir vymBaseDir;
147 extern QDir lastImageDir;
148 extern QDir lastFileDir;
149 extern QString iconPath;
150 extern QString flagsPath;
152 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
153 QMainWindow(parent,name,f)
157 setCaption ("VYM - View Your Mind");
159 // Load window settings
160 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
161 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
164 // Create unique temporary directory
166 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
169 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
173 // Create direcctory for clipboard
174 clipboardDir=tmpVymDir+"/clipboard";
175 QDir d(clipboardDir);
176 d.mkdir (clipboardDir,true);
177 makeSubDirs (clipboardDir);
182 // FIXME not used currently
183 // Set random seed (random used for object IDs)
184 // QTime t = QTime::currentTime(); // set random seed
185 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
188 // Initialize some settings, which are platform dependant
191 // application to open URLs
192 p="/mainwindow/readerURL";
193 #if defined(Q_OS_LINUX)
194 s=settings.value (p,"konqueror").toString();
196 #if defined(Q_OS_MACX)
197 s=settings.value (p,"/usr/bin/open").toString();
199 s=settings.value (p,"mozilla");
202 settings.setValue( p,s);
204 // application to open PDFs
205 p="/mainwindow/readerPDF";
206 #if defined(Q_OS_LINUX)
207 s=settings.value (p,"acroread").toString();
209 #if defined(Q_OS_MACX)
210 s=settings.value (p,"/usr/bin/open").toString();
212 s=settings.value (p,"acroread").toString();
215 settings.setValue( p,s);
220 // Create tab widget which holds the maps
221 tabWidget= new QTabWidget (this);
222 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
223 this, SLOT( editorChanged( QWidget * ) ) );
225 lineedit=new QLineEdit (this);
228 setCentralWidget(tabWidget);
232 setupFormatActions();
236 setupSettingsActions();
238 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
243 restoreState (settings.value("/mainwindow/state",0).toByteArray());
245 // Initialize Find window
246 findWindow=new FindWindow(NULL,"findwindow");
247 connect (findWindow, SIGNAL( findButton(QString) ),
248 this, SLOT(editFind(QString) ) );
249 connect (findWindow, SIGNAL( somethingChanged() ),
250 this, SLOT(editFindChanged() ) );
252 // Connect TextEditor, so that we can update flags if text changes
253 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
261 settings.setValue ( "/mainwindow/geometry/size", size() );
262 settings.setValue ( "/mainwindow/geometry/pos", pos() );
264 settings.setValue ("/mainwindow/state",saveState(0));
266 settings.setValue( "/version/version", __VYM_VERSION );
267 settings.setValue( "/version/builddate", __BUILD_DATE );
269 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoselectHeading->isOn() );
270 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoselectText->isOn() );
271 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoedit->isOn() );
272 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
273 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
274 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
277 int maps=lastMaps.count();
278 settings.setValue( "/lastMaps/number",maps );
279 for (int i=1;i<=maps;i++)
281 s=QString("/lastMaps/map-%1").arg(i);
282 if (!s.isEmpty() && i<=maxLastMaps)
283 settings.setValue (s, lastMaps.at(i-1));
287 // To make the texteditor save its settings, call the destructor
290 // Remove temporary directory
291 removeDir (QDir(tmpVymDir));
294 void Main::loadCmdLine()
296 /* TODO draw some kind of splashscreen while loading...
302 QStringList flist=options.getFileList();
303 QStringList::Iterator it=flist.begin();
305 while (it !=flist.end() )
307 fileLoad (*it, NewMap);
313 void Main::statusMessage(const QString &s)
315 statusBar()->message (s);
318 void Main::closeEvent (QCloseEvent* )
324 void Main::setupFileActions()
326 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
327 QToolBar *tb = addToolBar( tr ("&Map") );
328 tb->setObjectName ("mapTB");
331 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
332 a->setStatusTip ( tr( "New map","File menu" ) );
333 a->setShortcut ( Qt::CTRL + Qt::Key_N );
335 fileMenu->addAction (a);
336 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
338 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
339 a->setStatusTip (tr( "Open","File menu" ) );
340 a->setShortcut ( Qt::CTRL + Qt::Key_O );
342 fileMenu->addAction (a);
343 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
345 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
346 fileMenu->addSeparator();
348 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
349 a->setStatusTip ( tr( "Save" ));
350 a->setShortcut (Qt::CTRL + Qt::Key_S );
352 fileMenu->addAction (a);
353 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
356 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
357 a->setStatusTip (tr( "Save &As" ) );
358 fileMenu->addAction (a);
359 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
361 fileMenu->addSeparator();
363 fileImportMenu = fileMenu->addMenu (tr("Import"));
365 a = new QAction(tr("KDE Bookmarks"), this);
366 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
367 a->addTo (fileImportMenu);
368 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
370 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
372 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
373 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
374 a->addTo (fileImportMenu);
375 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
378 a = new QAction("Mind Manager...",this);
379 a->setStatusTip ( tr( "Import")+" Mind Manager" );
380 fileImportMenu->addAction (a);
381 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
383 a = new QAction( tr( "Import Dir"+QString("...") ), this);
384 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
385 fileImportMenu->addAction (a);
386 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
388 fileExportMenu = fileMenu->addMenu (tr("Export"));
390 a = new QAction( tr("Image")+QString("..."), this);
391 a->setStatusTip( tr( "Export map as image" ));
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
393 fileExportMenu->addAction (a);
395 a = new QAction( "Open Office"+QString("..."), this);
396 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
397 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
398 fileExportMenu->addAction (a);
400 a = new QAction( "Webpage (XHTML)...",this );
401 a->setShortcut (Qt::ALT + Qt::Key_X);
402 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
403 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
404 fileExportMenu->addAction (a);
406 a = new QAction( "Text (ASCII)...", this);
407 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
408 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
409 fileExportMenu->addAction (a);
411 a = new QAction( tr("KDE Bookmarks"), this);
412 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
413 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
414 fileExportMenu->addAction (a);
416 a = new QAction( "Taskjuggler...", this );
417 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
418 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
419 fileExportMenu->addAction (a);
421 a = new QAction( "LaTeX...", this);
422 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
423 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
424 fileExportMenu->addAction (a);
426 a = new QAction( "XML..." , this );
427 a->setStatusTip (tr( "Export as")+" XML");
428 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
429 fileExportMenu->addAction (a);
431 fileMenu->addSeparator();
433 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
434 a->setStatusTip ( tr( "Print" ) );
435 a->setShortcut (Qt::CTRL + Qt::Key_P );
437 fileMenu->addAction (a);
438 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
441 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
442 a->setStatusTip (tr( "Close Map" ) );
443 a->setShortcut (Qt::ALT + Qt::Key_C );
444 fileMenu->addAction (a);
445 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
447 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
448 a->setStatusTip ( tr( "Exit")+" "+__VYM );
449 a->setShortcut (Qt::CTRL + Qt::Key_Q );
450 fileMenu->addAction (a);
451 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
456 void Main::setupEditActions()
458 QToolBar *tb = addToolBar( tr ("&Actions") );
459 tb->setLabel( "Edit Actions" );
460 tb->setObjectName ("actionsTB");
461 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
465 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
466 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
467 a->setStatusTip (tr( "Undo" ) );
468 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
469 a->setEnabled (false);
471 editMenu->addAction (a);
474 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
475 a->setStatusTip (tr( "Redo" ));
476 a->setShortcut (Qt::CTRL + Qt::Key_Y );
478 editMenu->addAction (a);
479 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
482 editMenu->addSeparator();
483 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
484 a->setStatusTip ( tr( "Copy" ) );
485 a->setShortcut (Qt::CTRL + Qt::Key_C );
486 a->setEnabled (false);
488 editMenu->addAction (a);
489 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
492 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
493 a->setStatusTip ( tr( "Cut" ) );
494 a->setShortcut (Qt::CTRL + Qt::Key_X );
495 a->setEnabled (false);
497 editMenu->addAction (a);
499 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
501 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
502 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
503 a->setStatusTip ( tr( "Paste" ) );
504 a->setShortcut ( Qt::CTRL + Qt::Key_V );
505 a->setEnabled (false);
507 editMenu->addAction (a);
510 // Shortcuts to modify heading:
511 a = new QAction(tr( "Edit heading" ),this);
512 a->setStatusTip ( tr( "edit Heading" ));
513 a->setShortcut ( Qt::Key_Enter);
514 // a->setShortcutContext (Qt::WindowShortcut);
516 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
517 actionListBranches.append(a);
518 a = new QAction( tr( "Edit heading" ), this);
519 a->setStatusTip (tr( "edit Heading" ));
520 a->setShortcut (Qt::Key_Return );
521 //a->setShortcutContext (Qt::WindowShortcut);
523 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
524 actionListBranches.append(a);
525 editMenu->addAction (a);
527 a = new QAction( tr( "Edit heading" ), this);
528 a->setStatusTip (tr( "edit Heading" ));
529 a->setShortcut ( Qt::Key_F2 );
530 a->setShortcutContext (Qt::WindowShortcut);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
533 actionListBranches.append(a);
535 // Shortcut to delete selection
536 a = new QAction( tr( "Delete Selection" ),this);
537 a->setStatusTip (tr( "Delete Selection" ));
538 a->setShortcut ( Qt::Key_Delete);
539 a->setShortcutContext (Qt::WindowShortcut);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
544 // Shortcut to add branch
545 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
546 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
547 alt->setShortcut (Qt::Key_A);
548 alt->setShortcutContext (Qt::WindowShortcut);
550 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
551 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
552 a->setStatusTip ( tr( "Add a branch as child of selection" ));
553 a->setShortcut (Qt::Key_Insert);
554 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
555 actionListBranches.append(a);
556 #if defined (Q_OS_MACX)
557 // In OSX show different shortcut in menues, the keys work indepently always
558 actionEditAddBranch=alt;
560 actionEditAddBranch=a;
562 editMenu->addAction (actionEditAddBranch);
563 tb->addAction (actionEditAddBranch);
566 // Add branch by inserting it at selection
567 a = new QAction(tr( "Add branch (insert)" ), this);
568 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
569 a->setShortcut (Qt::ALT + Qt::Key_Insert );
570 a->setShortcutContext (Qt::WindowShortcut);
572 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
573 a->setEnabled (false);
574 actionListBranches.append(a);
575 actionEditAddBranchHere=a;
576 a = new QAction(tr( "Add branch (insert)" ),this);
577 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
578 a->setShortcut ( Qt::ALT + Qt::Key_A );
579 a->setShortcutContext (Qt::WindowShortcut);
581 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
582 actionListBranches.append(a);
585 a = new QAction(tr( "Add branch above" ), this);
586 a->setStatusTip ( tr( "Add a branch above selection" ));
587 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
588 a->setShortcutContext (Qt::WindowShortcut);
590 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
591 a->setEnabled (false);
592 actionListBranches.append(a);
593 actionEditAddBranchAbove=a;
594 a = new QAction(tr( "Add branch above" ), this);
595 a->setStatusTip ( tr( "Add a branch above selection" ));
596 a->setShortcut (Qt::SHIFT+Qt::Key_A );
597 a->setShortcutContext (Qt::WindowShortcut);
599 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
600 actionListBranches.append(a);
603 a = new QAction(tr( "Add branch below" ), this);
604 a->setStatusTip ( tr( "Add a branch below selection" ));
605 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
606 a->setShortcutContext (Qt::WindowShortcut);
608 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
609 a->setEnabled (false);
610 actionListBranches.append(a);
611 actionEditAddBranchBelow=a;
612 a = new QAction(tr( "Add branch below" ), this);
613 a->setStatusTip ( tr( "Add a branch below selection" ));
614 a->setShortcut (Qt::CTRL +Qt::Key_A );
615 a->setShortcutContext (Qt::WindowShortcut);
617 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
618 actionListBranches.append(a);
620 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
621 a->setStatusTip ( tr( "Move branch up" ) );
622 a->setShortcut (Qt::Key_PageUp );
623 a->setEnabled (false);
625 editMenu->addAction (a);
626 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
629 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
630 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
631 a->setStatusTip (tr( "Move branch down" ) );
632 a->setShortcut ( Qt::Key_PageDown );
633 a->setEnabled (false);
635 editMenu->addAction (a);
636 actionEditMoveDown=a;
639 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
640 a->setShortcut ( Qt::Key_ScrollLock );
641 a->setStatusTip (tr( "Scroll branch" ) );
642 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
643 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
644 alt->setShortcut ( Qt::Key_S );
645 alt->setStatusTip (tr( "Scroll branch" ));
646 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
647 #if defined(Q_OS_MACX)
648 actionEditToggleScroll=alt;
650 actionEditToggleScroll=a;
652 actionEditToggleScroll->setEnabled (false);
653 actionEditToggleScroll->setToggleAction(true);
654 tb->addAction (actionEditToggleScroll);
655 editMenu->addAction ( actionEditToggleScroll);
656 editMenu->addAction (actionEditToggleScroll);
657 actionListBranches.append(actionEditToggleScroll);
659 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
660 a->setStatusTip (tr( "Unscroll all" ));
661 editMenu->addAction (a);
662 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
664 editMenu->addSeparator();
666 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
667 a->setStatusTip (tr( "Find" ) );
668 a->setShortcut (Qt::CTRL + Qt::Key_F );
669 editMenu->addAction (a);
670 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
672 editMenu->addSeparator();
674 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
675 a->setShortcut (Qt::CTRL + Qt::Key_U );
676 a->setShortcut (tr( "Open URL" ));
679 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
682 a = new QAction( tr( "Open URL in new tab" ), this);
683 a->setStatusTip (tr( "Open URL in new tab" ));
684 a->setShortcut (Qt::CTRL+Qt::Key_U );
686 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
687 actionEditOpenURLTab=a;
689 a = new QAction( tr( "Open all URLs in subtree" ), this);
690 a->setStatusTip (tr( "Open all URLs in subtree" ));
692 actionListBranches.append(a);
693 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
694 actionEditOpenMultipleURLTabs=a;
696 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
697 a->setStatusTip ( tr( "Edit URL" ) );
698 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
699 //a->setShortcut ( Qt::Key_U );
700 a->setShortcutContext (Qt::WindowShortcut);
701 actionListBranches.append(a);
703 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
706 a = new QAction( tr( "Use heading for URL" ), this);
707 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
708 a->setEnabled (false);
709 actionListBranches.append(a);
710 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
711 actionEditHeading2URL=a;
713 a = new QAction(tr( "Create URL to Bugzilla" ), this);
714 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
715 a->setEnabled (false);
716 actionListBranches.append(a);
717 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
718 actionEditBugzilla2URL=a;
720 a = new QAction(tr( "Create URL to FATE" ), this);
721 a->setStatusTip ( tr( "Create URL to FATE" ));
722 a->setEnabled (false);
723 actionListBranches.append(a);
724 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
725 actionEditFATE2URL=a;
727 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this);
728 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
730 a->setEnabled (false);
731 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
732 actionEditOpenVymLink=a;
734 a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this);
735 a->setStatusTip ( tr( "Open all vym links in subtree" ));
736 a->setEnabled (false);
737 actionListBranches.append(a);
738 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
739 actionEditOpenMultipleVymLinks=a;
742 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
743 a->setEnabled (false);
744 a->setStatusTip ( tr( "Edit link to another vym map" ));
745 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
746 actionListBranches.append(a);
749 a = new QAction(tr( "Delete vym link" ),this);
750 a->setStatusTip ( tr( "Delete link to another vym map" ));
751 a->setEnabled (false);
752 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
753 actionEditDeleteVymLink=a;
755 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
756 a->setStatusTip ( tr( "Hide object in exports" ) );
757 a->setShortcut (Qt::Key_H );
758 a->setToggleAction(true);
760 a->setEnabled (false);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
762 actionEditToggleHideExport=a;
764 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
765 a->setStatusTip ( tr( "Edit Map Info" ));
766 a->setEnabled (true);
767 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
770 editMenu->addSeparator();
772 // Import at selection (adding to selection)
773 a = new QAction( tr( "Add map (insert)" ),this);
774 a->setStatusTip (tr( "Add map at selection" ));
775 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
776 a->setEnabled (false);
777 actionListBranches.append(a);
778 actionEditImportAdd=a;
780 // Import at selection (replacing selection)
781 a = new QAction( tr( "Add map (replace)" ), this);
782 a->setStatusTip (tr( "Replace selection with map" ));
783 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
784 a->setEnabled (false);
785 actionListBranches.append(a);
786 actionEditImportReplace=a;
789 a = new QAction( tr( "Save selection" ), this);
790 a->setStatusTip (tr( "Save selection" ));
791 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
792 a->setEnabled (false);
793 actionListBranches.append(a);
794 actionEditSaveBranch=a;
796 // Only remove branch, not its childs
797 a = new QAction(tr( "Remove only branch " ), this);
798 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
799 a->setShortcut (Qt::ALT + Qt::Key_Delete );
800 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
801 a->setEnabled (false);
802 actionListBranches.append(a);
803 actionEditRemoveBranchKeepChilds=a;
805 // Only remove childs of a branch
806 a = new QAction( tr( "Remove childs" ), this);
807 a->setStatusTip (tr( "Remove childs of branch" ));
808 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
809 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
810 a->setEnabled (false);
811 actionListBranches.append(a);
812 actionEditRemoveChilds=a;
814 // Shortcuts for navigating with cursor:
815 a = new QAction(tr( "Select upper branch" ), this);
816 a->setStatusTip ( tr( "Select upper branch" ));
817 a->setShortcut (Qt::Key_Up );
818 a->setShortcutContext (Qt::WindowShortcut);
820 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
821 a = new QAction( tr( "Select lower branch" ),this);
822 a->setStatusTip (tr( "Select lower branch" ));
823 a->setShortcut ( Qt::Key_Down );
824 a->setShortcutContext (Qt::WindowShortcut);
826 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
827 a = new QAction(tr( "Select left branch" ), this);
828 a->setStatusTip ( tr( "Select left branch" ));
829 a->setShortcut (Qt::Key_Left );
830 a->setShortcutContext (Qt::WindowShortcut);
832 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
833 a = new QAction( tr( "Select child branch" ), this);
834 a->setStatusTip (tr( "Select right branch" ));
835 a->setShortcut (Qt::Key_Right);
836 a->setShortcutContext (Qt::WindowShortcut);
838 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
839 a = new QAction( tr( "Select first branch" ), this);
840 a->setStatusTip (tr( "Select first branch" ));
841 a->setShortcut (Qt::Key_Home );
842 a->setShortcutContext (Qt::WindowShortcut);
844 a->setEnabled (false);
845 editMenu->addAction (a);
846 actionListBranches.append(a);
847 actionEditSelectFirst=a;
848 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
849 a = new QAction( tr( "Select last branch" ),this);
850 a->setStatusTip (tr( "Select last branch" ));
851 a->setShortcut ( Qt::Key_End );
852 a->setShortcutContext (Qt::WindowShortcut);
854 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
855 a->setEnabled (false);
856 editMenu->addAction (a);
857 actionListBranches.append(a);
858 actionEditSelectLast=a;
860 a = new QAction( tr( "Add Image" )+QString("..."), this);
861 a->setStatusTip (tr( "Add Image" ));
862 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
863 actionEditLoadImage=a;
868 void Main::setupFormatActions()
870 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
872 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
873 tb->setObjectName ("formatTB");
876 pix.fill (Qt::black);
877 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
878 a->setStatusTip ( tr( "Set Color" ));
879 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
881 formatMenu->addAction (a);
883 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
884 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
885 a->setShortcut (Qt::CTRL + Qt::Key_K );
886 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
887 a->setEnabled (false);
889 formatMenu->addAction (a);
890 actionListBranches.append(a);
891 actionFormatPickColor=a;
893 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
894 a->setStatusTip ( tr( "Color branch" ) );
895 a->setShortcut (Qt::CTRL + Qt::Key_I);
896 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
897 a->setEnabled (false);
899 formatMenu->addAction (a);
900 actionListBranches.append(a);
901 actionFormatColorBranch=a;
903 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
904 a->setStatusTip ( tr( "Color Subtree" ));
905 a->setShortcut (Qt::CTRL + Qt::Key_T);
906 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
907 a->setEnabled (false);
908 formatMenu->addAction (a);
910 actionListBranches.append(a);
911 actionFormatColorSubtree=a;
913 formatMenu->addSeparator();
914 actionGroupFormatLinkStyles=new QActionGroup ( this);
915 actionGroupFormatLinkStyles->setExclusive (true);
916 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
917 a->setStatusTip (tr( "Line" ));
918 a->setToggleAction(true);
919 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
920 formatMenu->addAction (a);
921 actionFormatLinkStyleLine=a;
922 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
923 a->setStatusTip (tr( "Line" ));
924 a->setToggleAction(true);
925 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
926 formatMenu->addAction (a);
927 actionFormatLinkStyleParabel=a;
928 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
929 a->setStatusTip (tr( "PolyLine" ));
930 a->setToggleAction(true);
931 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
932 formatMenu->addAction (a);
933 actionFormatLinkStylePolyLine=a;
934 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
935 a->setStatusTip (tr( "PolyParabel" ) );
936 a->setToggleAction(true);
937 a->setChecked (true);
938 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
939 formatMenu->addAction (a);
940 actionFormatLinkStylePolyParabel=a;
942 actionGroupFormatFrameTypes=new QActionGroup ( this);
943 actionGroupFormatFrameTypes->setExclusive (true);
944 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
945 a->setStatusTip (tr("No Frame"));
946 a->setToggleAction(true);
947 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
948 actionFormatFrameNone=a;
949 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
950 a->setStatusTip (tr( "Rectangle" ));
951 a->setToggleAction(true);
952 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
953 actionFormatFrameRectangle=a;
955 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
956 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
957 a->setToggleAction(true);
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
959 actionFormatIncludeImagesVer=a;
961 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
962 a->setStatusTip ( tr ("Include left and right position of images into branch"));
963 a->setToggleAction(true);
964 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
965 actionFormatIncludeImagesHor=a;
967 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
968 a->setStatusTip (tr( "Hide link" ));
969 a->setToggleAction(true);
970 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
971 actionFormatHideLinkUnselected=a;
973 formatMenu->addSeparator();
974 a= new QAction( tr( "&Use color of heading for link" ), this);
975 a->setStatusTip (tr( "Use same color for links and headings" ));
976 a->setToggleAction(true);
977 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
978 formatMenu->addAction (a);
979 actionFormatLinkColorHint=a;
981 pix.fill (Qt::white);
982 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
983 a->setStatusTip (tr( "Set Link Color" ));
984 formatMenu->addAction (a);
985 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
986 actionFormatLinkColor=a;
988 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
989 a->setStatusTip (tr( "Set Background Color" ));
990 formatMenu->addAction (a);
991 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
992 actionFormatBackColor=a;
996 void Main::setupViewActions()
998 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
999 tb->setLabel( "View Actions" );
1000 tb->setObjectName ("viewTB");
1001 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1004 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
1005 a->setStatusTip ( tr( "Zoom reset" ) );
1006 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1008 viewMenu->addAction (a);
1009 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1011 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
1012 a->setStatusTip (tr( "Zoom in" ));
1013 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1015 viewMenu->addAction (a);
1016 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1018 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
1019 a->setStatusTip (tr( "Zoom out" ));
1020 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1022 viewMenu->addAction (a);
1023 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1026 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1027 a->setStatusTip ( tr( "Show Note Editor" ));
1028 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1029 a->setToggleAction(true);
1030 if (textEditor->showWithMain())
1035 viewMenu->addAction (a);
1036 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1037 actionViewToggleNoteEditor=a;
1039 a = new QAction( tr( "Show history window" ),this );
1040 a->setStatusTip ( tr( "Show history window" ));
1041 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1042 a->setToggleAction(false);
1043 viewMenu->addAction (a);
1044 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1045 actionViewToggleHistoryWindow=a;
1047 a = new QAction(tr( "Next Window" ), this);
1048 a->setStatusTip ( tr( "&Next Window" ) );
1049 a->setShortcut (Qt::ALT + Qt::Key_N );
1050 viewMenu->addAction (a);
1051 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1053 a = new QAction (tr( "Previous Window" ), this );
1054 a->setStatusTip (tr( "&Previous Window" ));
1055 a->setShortcut (Qt::ALT + Qt::Key_P );
1056 viewMenu->addAction (a);
1057 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1061 void Main::setupModeActions()
1063 //QPopupMenu *menu = new QPopupMenu( this );
1064 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1066 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1067 tb->setObjectName ("modesTB");
1069 actionGroupModModes=new QActionGroup ( this);
1070 actionGroupModModes->setExclusive (true);
1071 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1072 a->setShortcut (Qt::Key_J);
1073 a->setStatusTip ( tr( "Use modifier to color branches" ));
1074 a->setToggleAction(true);
1077 actionModModeColor=a;
1079 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1080 a->setShortcut( Qt::Key_K);
1081 a->setStatusTip( tr( "Use modifier to copy" ));
1082 a->setToggleAction(true);
1084 actionModModeCopy=a;
1086 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1087 a->setShortcut (Qt::Key_L);
1088 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1089 a->setToggleAction(true);
1091 actionModModeLink=a;
1095 void Main::setupFlagActions()
1097 // Create System Flags
1098 systemFlagsDefault = new FlagRowObj ();
1099 systemFlagsDefault->setVisibility (false);
1100 systemFlagsDefault->setName ("systemFlagsDef");
1102 FlagObj *fo = new FlagObj ();
1103 fo->load(QPixmap(flagsPath+"flag-note.png"));
1104 fo->setName("note");
1105 fo->setToolTip(tr("Note","Systemflag"));
1106 systemFlagsDefault->addFlag (fo); // makes deep copy
1108 fo->load(QPixmap(flagsPath+"flag-url.png"));
1110 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1111 systemFlagsDefault->addFlag (fo);
1113 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1114 fo->setName("vymLink");
1115 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1116 systemFlagsDefault->addFlag (fo);
1118 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1119 fo->setName("scrolledright");
1120 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1121 systemFlagsDefault->addFlag (fo);
1123 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1124 fo->setName("tmpUnscrolledright");
1125 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1126 systemFlagsDefault->addFlag (fo);
1128 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1129 fo->setName("hideInExport");
1130 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1131 systemFlagsDefault->addFlag (fo);
1133 // Create Standard Flags
1134 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1135 tb->setObjectName ("standardFlagTB");
1137 standardFlagsDefault = new FlagRowObj ();
1138 standardFlagsDefault->setVisibility (false);
1139 standardFlagsDefault->setName ("standardFlagsDef");
1140 standardFlagsDefault->setToolBar (tb);
1142 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1143 fo->setName ("exclamationmark");
1144 fo->setGroup("standard-mark");
1145 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1148 a->setCheckable(true);
1149 a->setObjectName(fo->getName());
1150 a->setToolTip(tr("Take care!","Standardflag"));
1151 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1152 standardFlagsDefault->addFlag (fo); // makes deep copy
1154 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1155 fo->setName("questionmark");
1156 fo->setGroup("standard-mark");
1157 a=new QAction (fo->getPixmap(),fo->getName(),this);
1160 a->setCheckable(true);
1161 a->setObjectName(fo->getName());
1162 a->setToolTip(tr("Really?","Standardflag"));
1163 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1164 standardFlagsDefault->addFlag (fo);
1166 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1167 fo->setName("hook-green");
1168 fo->setGroup("standard-hook");
1169 a=new QAction (fo->getPixmap(),fo->getName(),this);
1172 a->setCheckable(true);
1173 a->setObjectName(fo->getName());
1174 a->setToolTip(tr("ok!","Standardflag"));
1175 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1176 standardFlagsDefault->addFlag (fo);
1178 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1179 fo->setName("cross-red");
1180 fo->setGroup("standard-hook");
1181 a=new QAction (fo->getPixmap(),fo->getName(),this);
1184 a->setCheckable(true);
1185 a->setObjectName(fo->getName());
1186 a->setToolTip(tr("Not ok!","Standardflag"));
1187 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1188 standardFlagsDefault->addFlag (fo);
1190 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1191 fo->setName("stopsign");
1192 a=new QAction (fo->getPixmap(),fo->getName(),this);
1195 a->setCheckable(true);
1196 a->setObjectName(fo->getName());
1197 a->setToolTip(tr("This won't work!","Standardflag"));
1198 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1199 standardFlagsDefault->addFlag (fo);
1201 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1202 fo->setName("smiley-good");
1203 fo->setGroup("standard-smiley");
1204 a=new QAction (fo->getPixmap(),fo->getName(),this);
1207 a->setCheckable(true);
1208 a->setObjectName(fo->getName());
1209 a->setToolTip(tr("Good","Standardflag"));
1210 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1211 standardFlagsDefault->addFlag (fo);
1213 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1214 fo->setName("smiley-sad");
1215 fo->setGroup("standard-smiley");
1216 a=new QAction (fo->getPixmap(),fo->getName(),this);
1219 a->setCheckable(true);
1220 a->setObjectName(fo->getName());
1221 a->setToolTip(tr("Bad","Standardflag"));
1222 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1223 standardFlagsDefault->addFlag (fo);
1225 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1226 // Original omg.png (in KDE emoticons)
1227 fo->setName("smiley-omg");
1228 fo->setGroup("standard-smiley");
1229 a=new QAction (fo->getPixmap(),fo->getName(),this);
1232 a->setCheckable(true);
1233 a->setObjectName(fo->getName());
1234 a->setToolTip(tr("Oh no!","Standardflag"));
1235 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1236 standardFlagsDefault->addFlag (fo);
1238 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1239 fo->setName("clock");
1240 a=new QAction (fo->getPixmap(),fo->getName(),this);
1243 a->setCheckable(true);
1244 a->setObjectName(fo->getName());
1245 a->setToolTip(tr("Time critical","Standardflag"));
1246 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1247 standardFlagsDefault->addFlag (fo);
1249 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1250 fo->setName("phone");
1251 a=new QAction (fo->getPixmap(),fo->getName(),this);
1254 a->setCheckable(true);
1255 a->setObjectName(fo->getName());
1256 a->setToolTip(tr("Call...","Standardflag"));
1257 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1258 standardFlagsDefault->addFlag (fo);
1260 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1261 fo->setName("lamp");
1262 a=new QAction (fo->getPixmap(),fo->getName(),this);
1265 a->setCheckable(true);
1266 a->setObjectName(fo->getName());
1267 a->setToolTip(tr("Idea!","Standardflag"));
1268 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1269 standardFlagsDefault->addFlag (fo);
1271 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1272 fo->setName("arrow-up");
1273 fo->setGroup("standard-arrow");
1274 a=new QAction (fo->getPixmap(),fo->getName(),this);
1277 a->setCheckable(true);
1278 a->setObjectName(fo->getName());
1279 a->setToolTip(tr("Important","Standardflag"));
1280 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1281 standardFlagsDefault->addFlag (fo);
1283 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1284 fo->setName("arrow-down");
1285 fo->setGroup("standard-arrow");
1286 a=new QAction (fo->getPixmap(),fo->getName(),this);
1289 a->setCheckable(true);
1290 a->setObjectName(fo->getName());
1291 a->setToolTip(tr("Unimportant","Standardflag"));
1292 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1293 standardFlagsDefault->addFlag (fo);
1295 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1296 fo->setName("2arrow-up");
1297 fo->setGroup("standard-arrow");
1298 a=new QAction (fo->getPixmap(),fo->getName(),this);
1301 a->setCheckable(true);
1302 a->setObjectName(fo->getName());
1303 a->setToolTip(tr("Very important!","Standardflag"));
1304 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1305 standardFlagsDefault->addFlag (fo);
1307 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1308 fo->setName("2arrow-down");
1309 fo->setGroup("standard-arrow");
1310 a=new QAction (fo->getPixmap(),fo->getName(),this);
1313 a->setCheckable(true);
1314 a->setObjectName(fo->getName());
1315 a->setToolTip(tr("Very unimportant!","Standardflag"));
1316 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1317 standardFlagsDefault->addFlag (fo);
1319 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1320 fo->setName("thumb-up");
1321 fo->setGroup("standard-thumb");
1322 a=new QAction (fo->getPixmap(),fo->getName(),this);
1325 a->setCheckable(true);
1326 a->setObjectName(fo->getName());
1327 a->setToolTip(tr("I like this","Standardflag"));
1328 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1329 standardFlagsDefault->addFlag (fo);
1331 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1332 fo->setName("thumb-down");
1333 fo->setGroup("standard-thumb");
1334 a=new QAction (fo->getPixmap(),fo->getName(),this);
1337 a->setCheckable(true);
1338 a->setObjectName(fo->getName());
1339 a->setToolTip(tr("I do not like this","Standardflag"));
1340 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1341 standardFlagsDefault->addFlag (fo);
1343 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1344 fo->setName("rose");
1345 a=new QAction (fo->getPixmap(),fo->getName(),this);
1348 a->setCheckable(true);
1349 a->setObjectName(fo->getName());
1350 a->setToolTip(tr("Rose","Standardflag"));
1351 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1352 standardFlagsDefault->addFlag (fo);
1354 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1355 fo->setName("heart");
1356 a=new QAction (fo->getPixmap(),fo->getName(),this);
1358 a->setCheckable(true);
1359 a->setObjectName(fo->getName());
1360 a->setToolTip(tr("I just love... ","Standardflag"));
1361 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1362 standardFlagsDefault->addFlag (fo);
1364 fo->load(QPixmap(flagsPath+"flag-present.png"));
1365 fo->setName("present");
1366 a=new QAction (fo->getPixmap(),fo->getName(),this);
1369 a->setCheckable(true);
1370 a->setObjectName(fo->getName());
1371 a->setToolTip(tr("Surprise!","Standardflag"));
1372 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1373 standardFlagsDefault->addFlag (fo);
1375 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1376 fo->setName("flash");
1377 a=new QAction (fo->getPixmap(),fo->getName(),this);
1380 a->setCheckable(true);
1381 a->setObjectName(fo->getName());
1382 a->setToolTip(tr("Dangerous","Standardflag"));
1383 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1384 standardFlagsDefault->addFlag (fo);
1386 fo->load(QPixmap(flagsPath+"flag-info.png"));
1387 // Original: xsldbg_output.png
1388 fo->setName("info");
1389 a=new QAction (fo->getPixmap(),fo->getName(),this);
1392 a->setCheckable(true);
1393 a->setObjectName(fo->getName());
1394 a->setToolTip(tr("Info","Standardflag"));
1395 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1396 standardFlagsDefault->addFlag (fo);
1398 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1399 // Original khelpcenter.png
1400 fo->setName("lifebelt");
1401 a=new QAction (fo->getPixmap(),fo->getName(),this);
1404 a->setCheckable(true);
1405 a->setObjectName(fo->getName());
1406 a->setToolTip(tr("This will help","Standardflag"));
1407 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1408 standardFlagsDefault->addFlag (fo);
1414 void Main::setupSettingsActions()
1416 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1420 a = new QAction( tr( "Set application to open pdf files"), this);
1421 a->setStatusTip ( tr( "Set application to open pdf files"));
1422 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1423 settingsMenu->addAction (a);
1425 a = new QAction( tr( "Set application to open external links"), this);
1426 a->setStatusTip( tr( "Set application to open external links"));
1427 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1428 settingsMenu->addAction (a);
1430 settingsMenu->addSeparator();
1431 a = new QAction( tr( "Edit branch after adding it" ), this );
1432 a->setStatusTip( tr( "Edit branch after adding it" ));
1433 a->setToggleAction(true);
1434 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1435 settingsMenu->addAction (a);
1436 actionSettingsAutoedit=a;
1438 a= new QAction( tr( "Select branch after adding it" ), this );
1439 a->setStatusTip( tr( "Select branch after adding it" ));
1440 a->setToggleAction(true);
1441 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1442 settingsMenu->addAction (a);
1443 actionSettingsAutoselectHeading=a;
1445 a= new QAction(tr( "Select existing heading" ), this);
1446 a->setStatusTip( tr( "Select heading before editing" ));
1447 a->setToggleAction(true);
1448 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1449 settingsMenu->addAction (a);
1450 actionSettingsAutoselectText=a;
1452 a= new QAction( tr( "Delete key" ), this);
1453 a->setStatusTip( tr( "Delete key for deleting branches" ));
1454 a->setToggleAction(true);
1455 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1456 settingsMenu->addAction (a);
1457 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1458 actionSettingsUseDelKey=a;
1460 a= new QAction( tr( "Exclusive flags" ), this);
1461 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1462 a->setToggleAction(true);
1463 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1464 settingsMenu->addAction (a);
1465 actionSettingsUseFlagGroups=a;
1467 a= new QAction( tr( "Use hide flags" ), this);
1468 a->setStatusTip( tr( "Use hide flag during exports " ));
1469 a->setToggleAction(true);
1470 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1471 settingsMenu->addAction (a);
1472 actionSettingsUseHideExport=a;
1476 void Main::setupTestActions()
1478 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1481 a = new QAction( tr( "test flag" ), this);
1482 a->setStatusTip( tr( "Call test function" ));
1483 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1484 testMenu->addAction (a);
1488 void Main::setupHelpActions()
1490 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1493 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1494 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1495 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1496 helpMenu->addAction (a);
1498 a = new QAction( tr( "About VYM" ), this);
1499 a->setStatusTip( tr( "About VYM")+" "__VYM);
1500 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1501 helpMenu->addAction (a);
1503 a = new QAction( tr( "About QT" ), this);
1504 a->setStatusTip( tr( "Information about QT toolkit" ));
1505 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1506 helpMenu->addAction (a);
1510 void Main::setupContextMenus()
1514 // Context Menu for branch or mapcenter
1515 branchContextMenu =new QMenu (this);
1518 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1519 branchAddContextMenu->addAction (actionEditPaste );
1520 branchAddContextMenu->addAction ( actionEditAddBranch );
1521 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1522 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1523 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1524 branchAddContextMenu->addSeparator();
1525 branchAddContextMenu->addAction ( actionEditLoadImage);
1526 branchAddContextMenu->addSeparator();
1527 branchAddContextMenu->addAction ( actionEditImportAdd );
1528 branchAddContextMenu->addAction ( actionEditImportReplace );
1531 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1532 branchRemoveContextMenu->addAction (actionEditCut);
1533 branchRemoveContextMenu->addAction ( actionEditDelete );
1534 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1535 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1538 actionEditSaveBranch->addTo( branchContextMenu );
1540 branchContextMenu->addSeparator();
1541 branchContextMenu->addAction ( actionFormatFrameNone );
1542 branchContextMenu->addAction ( actionFormatFrameRectangle);
1544 branchContextMenu->addSeparator();
1545 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1546 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1547 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1549 // Submenu for Links (URLs, vymLinks)
1550 branchLinksContextMenu =new QMenu (this);
1552 branchContextMenu->addSeparator();
1553 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));
1554 branchLinksContextMenu->addAction ( actionEditOpenURL );
1555 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1556 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1557 branchLinksContextMenu->addAction ( actionEditURL );
1558 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1559 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1560 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1562 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1564 branchLinksContextMenu->addSeparator();
1565 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1566 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1567 branchLinksContextMenu->addAction ( actionEditVymLink );
1568 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1571 // Context Menu for XLinks in a branch menu
1572 // This will be populated "on demand" in MapEditor::updateActions
1573 branchContextMenu->addSeparator();
1574 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1575 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1576 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1577 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1580 // Context menu for floatimage
1581 floatimageContextMenu =new QMenu (this);
1582 a= new QAction (tr ("Save image"),this);
1583 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1584 floatimageContextMenu->addAction (a);
1586 floatimageContextMenu->addSeparator();
1587 actionEditCopy->addTo( floatimageContextMenu );
1588 actionEditCut->addTo( floatimageContextMenu );
1590 floatimageContextMenu->addSeparator();
1591 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1594 // Context menu for canvas
1595 canvasContextMenu =new QMenu (this);
1596 actionEditMapInfo->addTo( canvasContextMenu );
1597 canvasContextMenu->insertSeparator();
1598 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1599 canvasContextMenu->insertSeparator();
1600 actionFormatLinkColorHint->addTo( canvasContextMenu );
1601 actionFormatLinkColor->addTo( canvasContextMenu );
1602 actionFormatBackColor->addTo( canvasContextMenu );
1604 // Menu for last opened files
1605 // Read settings initially
1607 int j=settings.readNumEntry( "/lastMaps/number",0);
1608 for (int i=1;i<=j;i++)
1610 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1611 if (!s.isEmpty() && j<=maxLastMaps)
1614 setupLastMapsMenu();
1615 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1618 void Main::setupLastMapsMenu()
1620 // Remove double entries
1621 QStringList::Iterator it=lastMaps.begin();
1622 QStringList::Iterator jt;
1623 while (it!=lastMaps.end() )
1627 while (jt!=lastMaps.end() )
1630 jt=lastMaps.remove(jt);
1637 // Limit length of list to maxLastMaps
1638 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1640 // build Menu from lastMaps string list
1641 fileLastMapsMenu->clear();
1642 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1643 fileLastMapsMenu->addAction (*it );
1646 void Main::hideEvent (QHideEvent * )
1648 if (!textEditor->isMinimized() ) textEditor->hide();
1651 void Main::showEvent (QShowEvent * )
1653 if (textEditor->showWithMain()) textEditor->showNormal();
1656 bool Main::reallyWriteDirectory(const QString &dir)
1658 QStringList eList = QDir(dir).entryList();
1659 if (eList.first() ==".") eList.pop_front(); // remove "."
1660 if (eList.first() =="..") eList.pop_front(); // remove "."
1661 if (!eList.isEmpty())
1663 QMessageBox mb( __VYM,
1664 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1665 QMessageBox::Warning,
1667 QMessageBox::Cancel | QMessageBox::Default,
1668 QMessageBox::QMessageBox::NoButton );
1670 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1671 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1674 case QMessageBox::Yes:
1677 case QMessageBox::Cancel:
1685 QString Main::browseDirectory (const QString &caption)
1687 Q3FileDialog fd(this,caption);
1688 fd.setMode (Q3FileDialog::DirectoryOnly);
1689 fd.setCaption(__VYM " - "+caption);
1692 if ( fd.exec() == QDialog::Accepted )
1693 return fd.selectedFile();
1698 MapEditor* Main::currentMapEditor() const
1700 if ( tabWidget->currentPage() &&
1701 tabWidget->currentPage()->inherits( "MapEditor" ) )
1702 return (MapEditor*)tabWidget->currentPage();
1706 //TODO not used now, maybe use this for overview window later
1707 void Main::newView()
1709 // Open a new view... have it delete when closed.
1710 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1711 qApp->setMainWidget(m);
1713 qApp->setMainWidget(0);
1716 void Main::editorChanged(QWidget *)
1718 // Unselect all possibly selected objects
1719 // (Important to update note editor)
1722 for (i=0;i<=tabWidget->count() -1;i++)
1725 me=(MapEditor*)tabWidget->page(i);
1728 currentMapEditor()->reselect();
1730 // Update actions to in menus and toolbars according to editor
1731 currentMapEditor()->updateActions();
1734 void Main::fileNew()
1736 QString fn="unnamed";
1737 MapEditor* medit = new MapEditor ( NULL,true);
1738 tabWidget->addTab (medit,fn);
1739 tabWidget->showPage(medit);
1740 medit->viewport()->setFocus();
1741 // For the very first map we do not have flagrows yet...
1742 medit->select("mc:");
1745 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1747 ErrorCode err=success;
1749 // fn is usually the archive, mapfile the file after uncompressing
1752 // Make fn absolute (needed for unzip)
1753 fn=QDir (fn).absPath();
1759 // Check, if map is already loaded
1761 while (i<=tabWidget->count() -1)
1763 me=(MapEditor*)tabWidget->page(i);
1764 if (me->getFilePath() == fn)
1766 // Already there, ask for confirmation
1767 QMessageBox mb( __VYM,
1768 tr("The map %1\nis already opened."
1769 "Opening the same map in multiple editors may lead \n"
1770 "to confusion when finishing working with vym."
1771 "Do you want to").arg(fn),
1772 QMessageBox::Warning,
1773 QMessageBox::Yes | QMessageBox::Default,
1774 QMessageBox::Cancel | QMessageBox::Escape,
1775 QMessageBox::NoButton);
1776 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1777 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1780 case QMessageBox::Yes:
1782 i=tabWidget->count();
1784 case QMessageBox::Cancel:
1796 if ( !fn.isEmpty() )
1798 me = currentMapEditor();
1799 int tabIndex=tabWidget->currentPageIndex();
1800 // Check first, if mapeditor exists
1801 // If it is not default AND we want a new map,
1802 // create a new mapeditor in a new tab
1803 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1805 me= new MapEditor ( NULL,true);
1806 tabWidget->addTab (me,fn);
1807 tabIndex=tabWidget->indexOf (me);
1808 tabWidget->setCurrentPage (tabIndex);
1811 // Check, if file exists (important for creating new files
1812 // from command line
1813 if (!QFile(fn).exists() )
1815 QMessageBox mb( __VYM,
1816 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1817 QMessageBox::Question,
1819 QMessageBox::Cancel | QMessageBox::Default,
1820 QMessageBox::NoButton );
1822 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1823 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1826 case QMessageBox::Yes:
1828 currentMapEditor()->setFilePath(fn);
1829 tabWidget->setTabLabel (currentMapEditor(),
1830 currentMapEditor()->getFileName() );
1831 statusBar()->message( "Created " + fn , statusbarTime );
1834 case QMessageBox::Cancel:
1835 // don't create new map
1836 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1843 //tabWidget->currentPage() won't be NULL here, because of above...
1844 tabWidget->showPage(me);
1845 me->viewport()->setFocus();
1847 // Create temporary directory for packing
1848 char tmpdir1[]="/tmp/vym-XXXXXX";
1849 QString tmpMapDir=mkdtemp(tmpdir1);
1851 // Try to unzip file
1852 err=unzipDir (tmpMapDir,fn);
1856 me->setZipped(false);
1859 me->setZipped(true);
1861 // Look for mapname.xml
1862 mapfile= fn.left(fn.findRev(".",-1,true));
1863 mapfile=mapfile.section( '/', -1 );
1864 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1865 if (!file.exists() )
1867 // mapname.xml does not exist, well,
1868 // maybe some renamed the mapname.vym file...
1869 // Try to find any .xml in the toplevel
1870 // directory of the .vym file
1871 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1872 if (flist.count()==1)
1874 // Only one entry, take this one
1875 mapfile=tmpMapDir + "/"+flist.first();
1878 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1879 *it=tmpMapDir + "/" + *it;
1880 // TODO Multiple entries, load all (but only the first one into this ME)
1881 //mainWindow->fileLoadFromTmp (flist);
1882 //returnCode=1; // Silently forget this attempt to load
1883 qWarning ("MainWindow::load (fn) multimap found...");
1886 if (flist.isEmpty() )
1888 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1889 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1892 } //file doesn't exist
1894 mapfile=file.name();
1899 // Save existing filename in case we import
1900 QString fn_org=me->getFilePath();
1902 // Finally load map into mapEditor
1903 me->setFilePath (mapfile,fn);
1904 err=me->load(mapfile,lmode);
1906 // Restore old (maybe empty) filepath, if this is an import
1908 me->setFilePath (fn_org);
1911 // Finally check for errors and go home
1914 if (lmode==NewMap) fileCloseMap();
1915 statusBar()->message( "Could not load " + fn, statusbarTime );
1920 me->setFilePath (fn);
1921 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1922 if (fn.left(9)!="/tmp/vym-")
1924 // Only append to lastMaps if not loaded from a tmpDir
1925 // e.g. imported bookmarks are in a tmpDir
1926 lastMaps.prepend(me->getFilePath() );
1927 setupLastMapsMenu();
1929 actionFilePrint->setEnabled (true);
1931 statusBar()->message( "Loaded " + fn, statusbarTime );
1935 removeDir (QDir(tmpMapDir));
1941 void Main::fileLoad(const LoadMode &lmode)
1943 Q3FileDialog *fd=new Q3FileDialog( this);
1944 fd->setDir (lastFileDir);
1945 fd->setMode (Q3FileDialog::ExistingFiles);
1946 fd->addFilter ("XML (*.xml)");
1947 fd->addFilter ("VYM map (*.vym *.vyp)");
1951 fd->setCaption(tr("Load vym map"));
1954 fd->setCaption(tr("Import: Add vym map to selection"));
1957 fd->setCaption(tr("Import: Replace selection with vym map"));
1963 if ( fd->exec() == QDialog::Accepted )
1965 lastFileDir=fd->dirPath();
1966 QStringList flist = fd->selectedFiles();
1967 QStringList::Iterator it = flist.begin();
1968 while( it != flist.end() )
1971 fileLoad(*it, lmode);
1978 void Main::fileLoad()
1983 void Main::fileLoadLast(QAction *a)
1985 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1988 void Main::fileSave(const SaveMode &savemode)
1990 // tmp dir for zipping
1994 ErrorCode err=success;
1996 QString safeFilePath;
1998 bool saveZipped=currentMapEditor()->saveZipped();
2000 MapEditor * me=currentMapEditor();
2003 QString fn=me->getFilePath();
2004 // filename=unnamed, filepath="" in constructor...
2005 if ( !fn.isEmpty() )
2007 // We have a filepath, go on saving
2008 // First remove existing file, we
2009 // don't want to add to old zip archives
2013 QMessageBox::warning( 0, tr( "Save Error" ),
2014 fn+ tr("\ncould not be removed before saving"));
2016 // Look, if we should zip the data:
2019 QMessageBox mb( __VYM,
2020 tr("The map %1\ndid not use the compressed "
2021 "vym file format.\nWriting it uncompressed will also write images \n"
2022 "and flags and thus may overwrite files in the "
2023 "given directory\n\nDo you want to write the map").arg(fn),
2024 QMessageBox::Warning,
2025 QMessageBox::Yes | QMessageBox::Default,
2027 QMessageBox::Cancel | QMessageBox::Escape);
2028 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2029 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2030 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2033 case QMessageBox::Yes:
2034 // save compressed (default file format)
2037 case QMessageBox::No:
2038 // save uncompressed
2041 case QMessageBox::Cancel:
2050 char tmpdir1[]="/tmp/vym-XXXXXX";
2051 tmpMapDir=mkdtemp(tmpdir1);
2053 safeFilePath=me->getFilePath();
2054 me->setFilePath (tmpMapDir+"/"+
2055 me->getMapName()+ ".xml",
2057 me->save (savemode);
2058 me->setFilePath (safeFilePath);
2060 zipDir (tmpMapDir,fn);
2065 safeFilePath=me->getFilePath();
2066 me->setFilePath (fn, safeFilePath);
2067 me->save (savemode);
2068 me->setFilePath (safeFilePath);
2070 } // filepath available
2073 // We have no filepath yet,
2074 // call fileSaveAs() now, this will call fileSave()
2076 fileSaveAs(savemode);
2080 if (saveZipped && !tmpMapDir.isEmpty())
2082 removeDir (QDir(tmpMapDir));
2086 statusBar()->message(
2087 tr("Saved %1").arg(me->getFilePath()),
2089 lastMaps.prepend(me->getFilePath() );
2090 setupLastMapsMenu();
2092 statusBar()->message(
2093 tr("Couldn't save ").arg(me->getFilePath()),
2097 void Main::fileSave()
2099 fileSave (CompleteMap);
2102 void Main::fileSaveAs(const SaveMode& savemode)
2106 if (currentMapEditor())
2108 if (savemode==CompleteMap)
2109 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2111 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2112 if ( !fn.isEmpty() )
2114 // Check for existing file
2115 if (QFile (fn).exists())
2117 QMessageBox mb( __VYM,
2118 tr("The file %1\nexists already. Do you want to").arg(fn),
2119 QMessageBox::Warning,
2120 QMessageBox::Yes | QMessageBox::Default,
2121 QMessageBox::Cancel | QMessageBox::Escape,
2122 QMessageBox::NoButton);
2123 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2124 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2127 case QMessageBox::Yes:
2130 case QMessageBox::Cancel:
2137 // New file, add extension to filename, if missing
2138 // This is always .vym or .vyp, depending on savemode
2139 if (savemode==CompleteMap)
2141 if (!fn.contains (".vym") && !fn.contains (".xml"))
2145 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2154 currentMapEditor()->setFilePath(fn);
2158 if (savemode==CompleteMap)
2159 tabWidget->setTabLabel (currentMapEditor(),
2160 currentMapEditor()->getFileName() );
2166 void Main::fileSaveAs()
2168 fileSaveAs (CompleteMap);
2171 void Main::fileImportKDEBookmarks()
2173 ImportKDEBookmarks im;
2175 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2176 currentMapEditor()->setFilePath ("");
2179 void Main::fileImportFirefoxBookmarks()
2181 Q3FileDialog *fd=new Q3FileDialog( this);
2182 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2183 fd->setMode (Q3FileDialog::ExistingFiles);
2184 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2185 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2188 if ( fd->exec() == QDialog::Accepted )
2190 ImportFirefoxBookmarks im;
2191 QStringList flist = fd->selectedFiles();
2192 QStringList::Iterator it = flist.begin();
2193 while( it != flist.end() )
2196 if (im.transform() &&
2197 success==fileLoad (im.getTransformedFile(),NewMap) &&
2198 currentMapEditor() )
2199 currentMapEditor()->setFilePath ("");
2206 void Main::fileImportMM()
2210 Q3FileDialog *fd=new Q3FileDialog( this);
2211 fd->setDir (lastFileDir);
2212 fd->setMode (Q3FileDialog::ExistingFiles);
2213 fd->addFilter ("Mind Manager (*.mmap)");
2214 fd->setCaption(tr("Import")+" "+"Mind Manager");
2217 if ( fd->exec() == QDialog::Accepted )
2219 lastFileDir=fd->dirPath();
2220 QStringList flist = fd->selectedFiles();
2221 QStringList::Iterator it = flist.begin();
2222 while( it != flist.end() )
2225 if (im.transform() &&
2226 success==fileLoad (im.getTransformedFile(),NewMap) &&
2227 currentMapEditor() )
2228 currentMapEditor()->setFilePath ("");
2237 void Main::fileImportDir()
2239 if (currentMapEditor())
2240 currentMapEditor()->importDir();
2243 void Main::fileExportXML()
2245 if (currentMapEditor())
2247 QString dir=browseDirectory(tr("Export XML to directory"));
2248 if (dir !="" && reallyWriteDirectory(dir) )
2249 currentMapEditor()->exportXML(dir);
2254 void Main::fileExportXHTML()
2256 MapEditor *me=currentMapEditor();
2260 ExportXHTMLDialog dia(this);
2261 dia.setFilePath (me->getFilePath() );
2262 dia.setMapName (me->getMapName() );
2265 if (dia.exec()==QDialog::Accepted)
2267 QString dir=dia.getDir();
2268 // Check, if warnings should be used before overwriting
2269 // the output directory
2272 ok=reallyWriteDirectory(dir);
2278 me->exportXML (dia.getDir() );
2279 dia.doExport(me->getMapName() );
2280 if (dia.hasChanged())
2287 void Main::fileExportImage()
2289 MapEditor *me=currentMapEditor();
2293 QFileDialog *fd=new QFileDialog (this);
2294 fd->setCaption (tr("Export map as image"));
2295 fd->setFileMode(QFileDialog::AnyFile);
2296 fd->setFilters (imageIO.getFilters() );
2297 fd->setDirectory (lastImageDir);
2300 fl=fd->selectedFiles();
2301 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2302 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2307 void Main::fileExportASCII()
2309 MapEditor *me=currentMapEditor();
2313 ex.setMapCenter(me->getMapCenter());
2314 ex.addFilter ("TXT (*.txt)");
2315 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2316 if (ex.execDialog() )
2318 me->setExportMode(true);
2320 me->setExportMode(false);
2325 void Main::fileExportLaTeX()
2327 MapEditor *me=currentMapEditor();
2331 ex.setMapCenter(me->getMapCenter());
2332 ex.addFilter ("Tex (*.tex)");
2333 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2334 if (ex.execDialog() )
2336 me->setExportMode(true);
2338 me->setExportMode(false);
2343 void Main::fileExportKDEBookmarks()
2345 ExportKDEBookmarks ex;
2346 MapEditor *me=currentMapEditor();
2349 ex.setMapCenter (me->getMapCenter() );
2354 void Main::fileExportTaskjuggler()
2356 ExportTaskjuggler ex;
2357 MapEditor *me=currentMapEditor();
2360 ex.setMapCenter (me->getMapCenter() );
2361 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2362 ex.addFilter ("Taskjuggler (*.tjp)");
2363 if (ex.execDialog() )
2365 me->setExportMode(true);
2367 me->setExportMode(false);
2372 void Main::fileExportOOPresentation()
2374 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2375 // TODO add preview in dialog
2376 //ImagePreview *p =new ImagePreview (fd);
2377 //fd->setContentsPreviewEnabled( TRUE );
2378 //fd->setContentsPreview( p, p );
2379 //fd->setPreviewMode( QFileDialog::Contents );
2380 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2381 fd->setDir (QDir().current());
2382 if (fd->foundConfig())
2386 if ( fd->exec() == QDialog::Accepted )
2388 QString fn=fd->selectedFile();
2389 if (!fn.contains (".odp"))
2392 //lastImageDir=fn.left(fn.findRev ("/"));
2393 if (currentMapEditor())
2394 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2398 QMessageBox::warning(0,
2400 tr("Couldn't find configuration for export to Open Office\n"));
2404 void Main::fileCloseMap()
2406 if (currentMapEditor())
2408 if (currentMapEditor()->hasChanged())
2410 QMessageBox mb( __VYM,
2411 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2412 QMessageBox::Warning,
2413 QMessageBox::Yes | QMessageBox::Default,
2415 QMessageBox::Cancel | QMessageBox::Escape );
2416 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2417 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2420 case QMessageBox::Yes:
2422 fileSave(CompleteMap);
2424 case QMessageBox::No:
2425 // close without saving
2427 case QMessageBox::Cancel:
2432 currentMapEditor()->closeMap();
2433 tabWidget->removePage(currentMapEditor());
2434 if (tabWidget->count()==0)
2435 actionFilePrint->setEnabled (false);
2439 void Main::filePrint()
2441 if (currentMapEditor())
2442 currentMapEditor()->print();
2445 void Main::fileExitVYM()
2447 // Check if one or more editors have changed
2450 for (i=0;i<=tabWidget->count() -1;i++)
2453 me=(MapEditor*)tabWidget->page(i);
2455 // If something changed, ask what to do
2456 if (me->isUnsaved())
2458 tabWidget->setCurrentPage(i);
2459 QMessageBox mb( __VYM,
2460 tr("This map is not saved yet. Do you want to"),
2461 QMessageBox::Warning,
2462 QMessageBox::Yes | QMessageBox::Default,
2464 QMessageBox::Cancel | QMessageBox::Escape );
2465 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2466 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2469 mb.setActiveWindow();
2470 switch( mb.exec() ) {
2471 case QMessageBox::Yes:
2472 // save (the changed editors) and exit
2473 fileSave(CompleteMap);
2475 case QMessageBox::No:
2476 // exit without saving
2478 case QMessageBox::Cancel:
2479 // don't save and don't exit
2483 } // loop over all MEs
2487 void Main::editUndo()
2489 if (currentMapEditor())
2490 currentMapEditor()->undo();
2493 void Main::editRedo()
2495 if (currentMapEditor())
2496 currentMapEditor()->redo();
2499 void Main::editCopy()
2501 if (currentMapEditor())
2502 currentMapEditor()->copy();
2505 void Main::editPaste()
2507 if (currentMapEditor())
2508 currentMapEditor()->paste();
2511 void Main::editCut()
2513 if (currentMapEditor())
2514 currentMapEditor()->cut();
2517 void Main::editOpenFindWindow()
2519 findWindow->popup();
2520 findWindow->raise();
2521 findWindow->setActiveWindow();
2524 void Main::editFind(QString s)
2527 BranchObj *bo=currentMapEditor()->findText(s, cs);
2530 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2533 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2534 tr("No matches found for \"%1\"").arg(s));
2538 void Main::editFindChanged()
2539 { // Notify editor, to abort the current find process
2540 currentMapEditor()->findReset();
2543 void Main::openTabs(QStringList urls)
2545 if (!urls.isEmpty())
2549 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2551 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2553 QString u=urls.takeFirst();
2554 procBrowser = new QProcess( this );
2556 procBrowser->start(browser,args);
2557 if ( !procBrowser->waitForStarted())
2559 // try to set path to browser
2560 QMessageBox::warning(0,
2562 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2563 tr("Please use Settings->")+tr("Set application to open an URL"));
2568 if (browser.contains("konqueror"))
2570 for (int i=0; i<urls.size(); i++)
2573 // Try to open new tab in existing konqueror started previously by vym
2574 p=new QProcess (this);
2576 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2577 "konqueror-mainwindow#1"<<
2580 p->start ("dcop",args);
2581 if ( !p->waitForStarted() ) success=false;
2584 QMessageBox::warning(0,
2586 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2588 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2590 for (int i=0; i<urls.size(); i++)
2592 // Try to open new tab in firefox
2593 p=new QProcess (this);
2594 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2595 p->start (browser,args);
2596 if ( !p->waitForStarted() ) success=false;
2599 QMessageBox::warning(0,
2601 tr("Couldn't start %1 to open a new tab").arg(browser));
2604 QMessageBox::warning(0,
2606 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2610 void Main::editOpenURL()
2613 if (currentMapEditor())
2615 QString url=currentMapEditor()->getURL();
2617 if (url=="") return;
2618 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2619 procBrowser = new QProcess( this );
2621 procBrowser->start(browser,args);
2622 if ( !procBrowser->waitForStarted())
2624 // try to set path to browser
2625 QMessageBox::warning(0,
2627 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2628 tr("Please use Settings->")+tr("Set application to open an URL"));
2633 void Main::editOpenURLTab()
2635 if (currentMapEditor())
2638 urls.append(currentMapEditor()->getURL());
2642 void Main::editOpenMultipleURLTabs()
2644 if (currentMapEditor())
2647 urls=currentMapEditor()->getURLs();
2653 void Main::editURL()
2655 if (currentMapEditor())
2656 currentMapEditor()->editURL();
2659 void Main::editHeading2URL()
2661 if (currentMapEditor())
2662 currentMapEditor()->editHeading2URL();
2665 void Main::editBugzilla2URL()
2667 if (currentMapEditor())
2668 currentMapEditor()->editBugzilla2URL();
2671 void Main::editFATE2URL()
2673 if (currentMapEditor())
2674 currentMapEditor()->editFATE2URL();
2677 void Main::editHeading()
2679 if (lineedit->isVisible())
2681 if (currentMapEditor())
2683 MapEditor *me=currentMapEditor();
2684 QString oldSel=me->getSelectString();
2685 if (me->select (editSel))
2686 me->setHeading(lineedit->text());
2687 me->select (oldSel);
2689 lineedit->releaseKeyboard();
2694 if (currentMapEditor())
2698 QString s=currentMapEditor()->getHeading(ok,p);
2702 #if defined(Q_OS_MACX)
2703 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2704 QDialog *d =new QDialog(NULL);
2705 QLineEdit *le=new QLineEdit (d);
2706 d->setWindowFlags (Qt::FramelessWindowHint);
2707 d->setGeometry(p.x(),p.y(),200,25);
2708 le->resize (d->size());
2711 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2712 d->activateWindow();
2714 currentMapEditor()->setHeading (le->text());
2716 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2717 lineedit->setGeometry(p.x(),p.y(),200,25);
2718 lineedit->setText(s);
2719 lineedit->setCursorPosition(1);
2720 lineedit->selectAll();
2722 lineedit->grabKeyboard();
2723 lineedit->setFocus();
2725 editSel=currentMapEditor()->getSelectString();
2733 void Main::openVymLinks(const QStringList &vl)
2735 for (int j=0; j<vl.size(); j++)
2737 // compare path with already loaded maps
2741 for (i=0;i<=tabWidget->count() -1;i++)
2743 me=(MapEditor*)tabWidget->page(i);
2744 if (vl.at(j)==me->getFilePath() )
2753 if (!QFile(vl.at(j)).exists() )
2754 QMessageBox::critical( 0, tr( "Critical Error" ),
2755 tr("Couldn't open map %1").arg(vl.at(j)));
2758 fileLoad (vl.at(j), NewMap);
2759 tabWidget->setCurrentPage (tabWidget->count()-1);
2762 // Go to tab containing the map
2763 tabWidget->setCurrentPage (index);
2767 void Main::editOpenVymLink()
2769 if (currentMapEditor())
2772 vl.append(currentMapEditor()->getVymLink());
2777 void Main::editOpenMultipleVymLinks()
2779 QString currentVymLink;
2780 if (currentMapEditor())
2782 QStringList vl=currentMapEditor()->getVymLinks();
2787 void Main::editVymLink()
2789 if (currentMapEditor())
2790 currentMapEditor()->editVymLink();
2793 void Main::editDeleteVymLink()
2795 if (currentMapEditor())
2796 currentMapEditor()->deleteVymLink();
2799 void Main::editToggleHideExport()
2801 if (currentMapEditor())
2802 currentMapEditor()->toggleHideExport();
2805 void Main::editMapInfo()
2807 if (currentMapEditor())
2808 currentMapEditor()->editMapInfo();
2811 void Main::editMoveUp()
2813 if (currentMapEditor())
2814 currentMapEditor()->moveBranchUp();
2817 void Main::editMoveDown()
2819 if (currentMapEditor())
2820 currentMapEditor()->moveBranchDown();
2823 void Main::editToggleScroll()
2825 if (currentMapEditor())
2827 currentMapEditor()->toggleScroll();
2831 void Main::editUnScrollAll()
2833 if (currentMapEditor())
2835 currentMapEditor()->unScrollAll();
2839 void Main::editNewBranch()
2842 if (!lineedit->isVisible() && currentMapEditor())
2843 currentMapEditor()->addNewBranch(0);
2846 void Main::editNewBranchHere()
2848 if (currentMapEditor())
2849 currentMapEditor()->addNewBranchHere();
2852 void Main::editNewBranchAbove()
2854 if (currentMapEditor())
2855 currentMapEditor()->addNewBranch(-1);
2858 void Main::editNewBranchBelow()
2860 if (currentMapEditor())
2861 currentMapEditor()->addNewBranch(1);
2864 void Main::editImportAdd()
2866 fileLoad (ImportAdd);
2869 void Main::editImportReplace()
2871 fileLoad (ImportReplace);
2874 void Main::editSaveBranch()
2876 fileSaveAs (PartOfMap);
2879 void Main::editRemoveBranchKeepChilds()
2881 if (currentMapEditor())
2882 currentMapEditor()->removeBranchKeepChilds();
2885 void Main::editRemoveChilds()
2887 if (currentMapEditor())
2888 currentMapEditor()->removeChilds();
2891 void Main::editDeleteSelection()
2893 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2894 currentMapEditor()->deleteSelection();
2897 void Main::editUpperBranch()
2899 if (currentMapEditor())
2900 currentMapEditor()->selectUpperBranch();
2903 void Main::editLowerBranch()
2905 if (currentMapEditor())
2906 currentMapEditor()->selectLowerBranch();
2909 void Main::editLeftBranch()
2911 if (currentMapEditor())
2912 currentMapEditor()->selectLeftBranch();
2915 void Main::editRightBranch()
2917 if (currentMapEditor())
2918 currentMapEditor()->selectRightBranch();
2921 void Main::editFirstBranch()
2923 if (currentMapEditor())
2924 currentMapEditor()->selectFirstBranch();
2927 void Main::editLastBranch()
2929 if (currentMapEditor())
2930 currentMapEditor()->selectLastBranch();
2933 void Main::editLoadImage()
2935 if (currentMapEditor())
2936 currentMapEditor()->loadFloatImage();
2939 void Main::editSaveImage()
2941 if (currentMapEditor())
2942 currentMapEditor()->saveFloatImage();
2945 void Main::editFollowXLink(QAction *a)
2948 if (currentMapEditor())
2949 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2952 void Main::editEditXLink(QAction *a)
2954 if (currentMapEditor())
2955 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2958 void Main::formatSelectColor()
2960 if (currentMapEditor())
2962 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2963 if ( !col.isValid() ) return;
2964 currentMapEditor()->setColor( col );
2965 colorChanged( col );
2969 void Main::formatPickColor()
2971 if (currentMapEditor())
2972 colorChanged( currentMapEditor()->pickColor() );
2975 void Main::colorChanged(QColor c)
2977 QPixmap pix( 16, 16 );
2979 actionFormatColor->setIconSet( pix );
2982 void Main::formatColorItem()
2984 if (currentMapEditor())
2985 currentMapEditor()->colorItem();
2988 void Main::formatColorBranch()
2990 if (currentMapEditor())
2991 currentMapEditor()->colorBranch();
2994 void Main::formatLinkStyleLine()
2996 if (currentMapEditor())
2997 currentMapEditor()->setLinkStyle(StyleLine);
3000 void Main::formatLinkStyleParabel()
3002 if (currentMapEditor())
3003 currentMapEditor()->setLinkStyle(StyleParabel);
3006 void Main::formatLinkStylePolyLine()
3008 if (currentMapEditor())
3009 currentMapEditor()->setLinkStyle(StylePolyLine);
3012 void Main::formatLinkStylePolyParabel()
3014 if (currentMapEditor())
3015 currentMapEditor()->setLinkStyle(StylePolyParabel);
3018 void Main::formatSelectBackColor()
3020 if (currentMapEditor())
3021 currentMapEditor()->selectBackgroundColor();
3024 void Main::formatSelectLinkColor()
3026 if (currentMapEditor())
3027 currentMapEditor()->selectLinkColor();
3030 void Main::formatToggleLinkColorHint()
3032 currentMapEditor()->toggleLinkColorHint();
3035 void Main::formatFrameNone()
3037 if (currentMapEditor())
3038 currentMapEditor()->setFrame(NoFrame);
3041 void Main::formatFrameRectangle()
3043 if (currentMapEditor())
3044 currentMapEditor()->setFrame(Rectangle);
3047 void Main::formatIncludeImagesVer()
3049 if (currentMapEditor())
3050 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3053 void Main::formatIncludeImagesHor()
3055 if (currentMapEditor())
3056 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3059 void Main::formatHideLinkUnselected()
3061 if (currentMapEditor())
3062 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3065 void Main::viewZoomReset()
3067 if (currentMapEditor())
3071 currentMapEditor()->setWorldMatrix( m );
3072 currentMapEditor()->setViewCenter();
3073 currentMapEditor()->adjustCanvasSize();
3077 void Main::viewZoomIn()
3079 if (currentMapEditor())
3081 QMatrix m = currentMapEditor()->worldMatrix();
3082 m.scale( 1.25, 1.25 );
3083 currentMapEditor()->setWorldMatrix( m );
3084 currentMapEditor()->setViewCenter();
3085 currentMapEditor()->adjustCanvasSize();
3089 void Main::viewZoomOut()
3091 if (currentMapEditor())
3093 QMatrix m = currentMapEditor()->worldMatrix();
3094 m.scale( 0.8, 0.8 );
3095 currentMapEditor()->setWorldMatrix( m );
3096 currentMapEditor()->setViewCenter();
3097 currentMapEditor()->adjustCanvasSize();
3101 void Main::modModeColor()
3105 void Main::modModeLink()
3109 bool Main::settingsPDF()
3111 // Default browser is set in constructor
3113 QString text = QInputDialog::getText(
3114 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3115 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3117 settings.setValue ("/mainwindow/readerPDF",text);
3122 bool Main::settingsURL()
3124 // Default browser is set in constructor
3126 QString text = QInputDialog::getText(
3127 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3128 settings.value("/mainwindow/readerURL").toString()
3131 settings.setValue ("/mainwindow/readerURL",text);
3135 void Main::settingsToggleDelKey()
3137 if (actionSettingsUseDelKey->isOn())
3139 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3142 actionEditDelete->setAccel (QKeySequence (""));
3146 void Main::windowToggleNoteEditor()
3148 if (textEditor->showWithMain() )
3149 windowHideNoteEditor();
3151 windowShowNoteEditor();
3154 void Main::windowToggleHistory()
3156 if (currentMapEditor())
3157 currentMapEditor()->toggleHistoryWindow();
3160 void Main::updateNoteFlag()
3162 if (currentMapEditor())
3163 currentMapEditor()->updateNoteFlag();
3166 void Main::windowShowNoteEditor()
3168 textEditor->setShowWithMain(true);
3170 actionViewToggleNoteEditor->setOn (true);
3173 void Main::windowHideNoteEditor()
3175 textEditor->setShowWithMain(false);
3177 actionViewToggleNoteEditor->setOn (false);
3180 void Main::windowNextEditor()
3182 if (tabWidget->currentPageIndex() < tabWidget->count())
3183 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3186 void Main::windowPreviousEditor()
3188 if (tabWidget->currentPageIndex() >0)
3189 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3192 void Main::standardFlagChanged()
3194 currentMapEditor()->toggleStandardFlag(sender()->name());
3197 void Main::testFunction()
3199 currentMapEditor()->testFunction();
3202 void Main::helpDoc()
3205 #if defined(Q_OS_MACX)
3206 docpath="./vym.app/Contents/vym.pdf";
3208 // default path in SUSE LINUX
3209 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3212 if (!QFile (docpath).exists() )
3214 // relative path for easy testing in tarball
3215 docpath="doc/vym.pdf";
3216 if (!QFile (docpath).exists() )
3218 // relative path for testing while still writing vym.tex
3219 docpath="doc/tex/vym.pdf";
3220 if (!QFile (docpath).exists() )
3222 // Try yet another one for Knoppix
3223 docpath="/usr/share/doc/packages/vym/vym.pdf";
3224 if (!QFile (docpath).exists() )
3226 QMessageBox::critical(0,
3227 tr("Critcal error"),
3228 tr("Couldn't find the documentation\n"
3229 "vym.pdf in various places."));
3236 Process *pdfProc = new Process();
3237 pdfProc->clearArguments();
3238 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3239 pdfProc->addArgument( docpath);
3241 if ( !pdfProc->start() )
3244 QMessageBox::warning(0,
3246 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3247 tr("Please use Settings->")+tr("Set application to open PDF files"));
3254 void Main::helpAbout()
3257 ad.setName ("aboutwindow");
3258 ad.setMinimumSize(500,500);
3259 ad.resize (QSize (500,500));
3263 void Main::helpAboutQT()
3265 QMessageBox::aboutQt( this, "Qt Application Example" );