Version 1.55. Fixed (recently) broken saveToDir
1 #include "mainwindow.h"
7 #include <q3filedialog.h>
9 #include <QColorDialog>
11 #include <QInputDialog>
15 #include <QCloseEvent>
18 #include <Q3PopupMenu>
19 #include <QActionGroup>
21 //#include <qdatetime.h> // for random seed
27 #include "aboutdialog.h"
28 #include "exportoofiledialog.h"
30 #include "exportxhtmldialog.h"
32 #include "flagrowobj.h"
34 #include "mapeditor.h"
39 #include "showtextdialog.h"
40 #include "texteditor.h"
43 extern TextEditor *textEditor;
44 extern Main *mainWindow;
45 extern QString tmpVymDir;
46 extern QString clipboardDir;
47 extern bool clipboardEmpty;
48 extern int statusbarTime;
49 extern FlagRowObj* standardFlagsDefault;
50 extern FlagRowObj* systemFlagsDefault;
52 extern Q3PtrList <QAction> actionListBranches;
54 extern QAction* actionFileSave;
55 extern QAction* actionFilePrint;
56 extern QAction* actionEditUndo;
57 extern QAction* actionEditRedo;
58 extern QAction *actionEditCopy;
59 extern QAction *actionEditCut;
60 extern QAction *actionEditPaste;
61 extern QAction *actionEditMoveUp;
62 extern QAction *actionEditMoveDown;
63 extern QAction *actionEditToggleScroll;
64 extern QAction* actionEditOpenURL;
65 extern QAction* actionEditOpenURLTab;
66 extern QAction* actionEditOpenMultipleURLTabs;
67 extern QAction* actionEditURL;
68 extern QAction* actionEditHeading2URL;
69 extern QAction* actionEditBugzilla2URL;
70 extern QAction* actionEditFATE2URL;
71 extern QAction *actionEditOpenVymLink;
72 extern QAction *actionEditOpenMultipleVymLinks;
73 extern QAction *actionEditVymLink;
74 extern QAction *actionEditDeleteVymLink;
75 extern QAction *actionEditToggleHideExport;
76 extern QAction *actionEditMapInfo;
77 extern QAction *actionEditHeading;
78 extern QAction *actionEditDelete;
79 extern QAction *actionEditAddBranch;
80 extern QAction *actionEditAddBranchHere;
81 extern QAction *actionEditAddBranchAbove;
82 extern QAction *actionEditAddBranchBelow;
83 extern QAction *actionEditRemoveBranchKeepChilds;
84 extern QAction *actionEditRemoveChilds;
85 extern QAction *actionEditImportAdd;
86 extern QAction *actionEditImportReplace;
87 extern QAction *actionEditSaveBranch;
88 extern QAction *actionEditSelectFirst;
89 extern QAction *actionEditSelectLast;
90 extern QAction *actionEditLoadImage;
92 extern QAction* actionFormatColor;
93 extern QAction* actionFormatPickColor;
94 extern QAction* actionFormatColorBranch;
95 extern QAction* actionFormatColorSubtree;
96 extern QAction* actionFormatLinkColorHint;
97 extern QAction* actionFormatBackColor;
98 extern QAction* actionFormatLinkColor;
99 extern QAction *actionFormatIncludeImagesVer;
100 extern QAction *actionFormatIncludeImagesHor;
102 extern QActionGroup* actionGroupModModes;
103 extern QAction* actionModModeColor;
104 extern QAction* actionModModeLink;
105 extern QAction* actionModModeCopy;
107 extern QActionGroup *actionGroupFormatFrameTypes;
108 extern QAction *actionFormatFrameNone;
109 extern QAction *actionFormatFrameRectangle;
111 extern QActionGroup *actionGroupFormatLinkStyles;
112 extern QAction *actionFormatLinkStyleLine;
113 extern QAction *actionFormatLinkStyleParabel;
114 extern QAction *actionFormatLinkStylePolyLine;
115 extern QAction *actionFormatLinkStylePolyParabel;
116 extern QAction *actionFormatHideLinkUnselected;
118 extern QAction *actionViewToggleNoteEditor;
119 extern QAction *actionViewToggleHistoryWindow;
121 extern QAction* actionSettingsAutoedit;
122 extern QAction* actionSettingsAutoselectHeading;
123 extern QAction* actionSettingsAutoselectHeading;
124 extern QAction* actionSettingsAutoselectText;
125 extern QAction* actionSettingsUseDelKey;
126 extern QAction* actionSettingsUseFlagGroups;
127 extern QAction* actionSettingsUseHideExport;
129 extern QMenu* branchContextMenu;
130 extern QMenu* branchAddContextMenu;
131 extern QMenu* branchRemoveContextMenu;
132 extern QMenu* branchLinksContextMenu;
133 extern QMenu* branchXLinksContextMenuEdit;
134 extern QMenu* branchXLinksContextMenuFollow;
135 extern QMenu* floatimageContextMenu;
136 extern QMenu* canvasContextMenu;
137 extern QMenu* fileLastMapsMenu;
138 extern QMenu* fileImportMenu;
139 extern QMenu* fileExportMenu;
142 extern Settings settings;
143 extern Options options;
144 extern ImageIO imageIO;
146 extern QDir vymBaseDir;
147 extern QDir lastImageDir;
148 extern QDir lastFileDir;
149 extern QString iconPath;
150 extern QString flagsPath;
152 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
153 QMainWindow(parent,name,f)
157 setCaption ("VYM - View Your Mind");
159 // Load window settings
160 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
161 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
164 // Create unique temporary directory
166 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
169 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
173 // Create direcctory for clipboard
174 clipboardDir=tmpVymDir+"/clipboard";
175 QDir d(clipboardDir);
176 d.mkdir (clipboardDir,true);
177 makeSubDirs (clipboardDir);
182 // FIXME not used currently
183 // Set random seed (random used for object IDs)
184 // QTime t = QTime::currentTime(); // set random seed
185 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
188 // Initialize some settings, which are platform dependant
191 // application to open URLs
192 p="/mainwindow/readerURL";
193 #if defined(Q_OS_LINUX)
194 s=settings.value (p,"konqueror").toString();
196 #if defined(Q_OS_MACX)
197 s=settings.value (p,"/usr/bin/open").toString();
199 s=settings.value (p,"mozilla");
202 settings.setValue( p,s);
204 // application to open PDFs
205 p="/mainwindow/readerPDF";
206 #if defined(Q_OS_LINUX)
207 s=settings.value (p,"acroread").toString();
209 #if defined(Q_OS_MACX)
210 s=settings.value (p,"/usr/bin/open").toString();
212 s=settings.value (p,"acroread").toString();
215 settings.setValue( p,s);
220 // Create tab widget which holds the maps
221 tabWidget= new QTabWidget (this);
222 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
223 this, SLOT( editorChanged( QWidget * ) ) );
225 lineedit=new QLineEdit (this);
228 setCentralWidget(tabWidget);
232 setupFormatActions();
236 setupSettingsActions();
238 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
243 restoreState (settings.value("/mainwindow/state",0).toByteArray());
245 // Initialize Find window
246 findWindow=new FindWindow(NULL);
247 findWindow->move (x(),y()+70);
248 connect (findWindow, SIGNAL( findButton(QString) ),
249 this, SLOT(editFind(QString) ) );
250 connect (findWindow, SIGNAL( somethingChanged() ),
251 this, SLOT(editFindChanged() ) );
253 // Connect TextEditor, so that we can update flags if text changes
254 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
262 settings.setValue ( "/mainwindow/geometry/size", size() );
263 settings.setValue ( "/mainwindow/geometry/pos", pos() );
265 settings.setValue ("/mainwindow/state",saveState(0));
267 settings.setValue( "/version/version", __VYM_VERSION );
268 settings.setValue( "/version/builddate", __BUILD_DATE );
270 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoselectHeading->isOn() );
271 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoselectText->isOn() );
272 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoedit->isOn() );
273 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
274 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
275 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
278 int maps=lastMaps.count();
279 settings.setValue( "/lastMaps/number",maps );
280 for (int i=1;i<=maps;i++)
282 s=QString("/lastMaps/map-%1").arg(i);
283 if (!s.isEmpty() && i<=maxLastMaps)
284 settings.setValue (s, lastMaps.at(i-1));
288 // To make the texteditor save its settings, call the destructor
291 // Remove temporary directory
292 removeDir (QDir(tmpVymDir));
295 void Main::loadCmdLine()
297 /* TODO draw some kind of splashscreen while loading...
303 QStringList flist=options.getFileList();
304 QStringList::Iterator it=flist.begin();
306 while (it !=flist.end() )
308 fileLoad (*it, NewMap);
314 void Main::statusMessage(const QString &s)
316 statusBar()->message (s);
319 void Main::closeEvent (QCloseEvent* )
325 void Main::setupFileActions()
327 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
328 QToolBar *tb = addToolBar( tr ("&Map") );
329 tb->setObjectName ("mapTB");
332 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
333 a->setStatusTip ( tr( "New map","File menu" ) );
334 a->setShortcut ( Qt::CTRL + Qt::Key_N );
336 fileMenu->addAction (a);
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
339 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
340 a->setStatusTip (tr( "Open","File menu" ) );
341 a->setShortcut ( Qt::CTRL + Qt::Key_O );
343 fileMenu->addAction (a);
344 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
346 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
347 fileMenu->addSeparator();
349 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
350 a->setStatusTip ( tr( "Save" ));
351 a->setShortcut (Qt::CTRL + Qt::Key_S );
353 fileMenu->addAction (a);
354 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
357 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
358 a->setStatusTip (tr( "Save &As" ) );
359 fileMenu->addAction (a);
360 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
362 fileMenu->addSeparator();
364 fileImportMenu = fileMenu->addMenu (tr("Import"));
366 a = new QAction(tr("KDE Bookmarks"), this);
367 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
368 a->addTo (fileImportMenu);
369 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
371 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
373 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
374 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
375 a->addTo (fileImportMenu);
376 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
379 a = new QAction("Mind Manager...",this);
380 a->setStatusTip ( tr( "Import")+" Mind Manager" );
381 fileImportMenu->addAction (a);
382 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
384 a = new QAction( tr( "Import Dir"+QString("...") ), this);
385 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
386 fileImportMenu->addAction (a);
387 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
389 fileExportMenu = fileMenu->addMenu (tr("Export"));
391 a = new QAction( tr("Image")+QString("..."), this);
392 a->setStatusTip( tr( "Export map as image" ));
393 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
394 fileExportMenu->addAction (a);
396 a = new QAction( "Open Office"+QString("..."), this);
397 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
398 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
399 fileExportMenu->addAction (a);
401 a = new QAction( "Webpage (XHTML)...",this );
402 a->setShortcut (Qt::ALT + Qt::Key_X);
403 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
404 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
405 fileExportMenu->addAction (a);
407 a = new QAction( "Text (ASCII)...", this);
408 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
409 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
410 fileExportMenu->addAction (a);
412 a = new QAction( tr("KDE Bookmarks"), this);
413 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
414 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
415 fileExportMenu->addAction (a);
417 a = new QAction( "Taskjuggler...", this );
418 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
419 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
420 fileExportMenu->addAction (a);
422 a = new QAction( "LaTeX...", this);
423 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
424 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
425 fileExportMenu->addAction (a);
427 a = new QAction( "XML..." , this );
428 a->setStatusTip (tr( "Export as")+" XML");
429 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
430 fileExportMenu->addAction (a);
432 fileMenu->addSeparator();
434 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
435 a->setStatusTip ( tr( "Print" ) );
436 a->setShortcut (Qt::CTRL + Qt::Key_P );
438 fileMenu->addAction (a);
439 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
442 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
443 a->setStatusTip (tr( "Close Map" ) );
444 a->setShortcut (Qt::ALT + Qt::Key_C );
445 fileMenu->addAction (a);
446 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
448 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
449 a->setStatusTip ( tr( "Exit")+" "+__VYM );
450 a->setShortcut (Qt::CTRL + Qt::Key_Q );
451 fileMenu->addAction (a);
452 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
457 void Main::setupEditActions()
459 QToolBar *tb = addToolBar( tr ("&Actions") );
460 tb->setLabel( "Edit Actions" );
461 tb->setObjectName ("actionsTB");
462 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
466 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
467 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
468 a->setStatusTip (tr( "Undo" ) );
469 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
470 a->setEnabled (false);
472 editMenu->addAction (a);
475 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
476 a->setStatusTip (tr( "Redo" ));
477 a->setShortcut (Qt::CTRL + Qt::Key_Y );
479 editMenu->addAction (a);
480 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
483 editMenu->addSeparator();
484 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
485 a->setStatusTip ( tr( "Copy" ) );
486 a->setShortcut (Qt::CTRL + Qt::Key_C );
487 a->setEnabled (false);
489 editMenu->addAction (a);
490 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
493 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
494 a->setStatusTip ( tr( "Cut" ) );
495 a->setShortcut (Qt::CTRL + Qt::Key_X );
496 a->setEnabled (false);
498 editMenu->addAction (a);
500 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
502 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
503 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
504 a->setStatusTip ( tr( "Paste" ) );
505 a->setShortcut ( Qt::CTRL + Qt::Key_V );
506 a->setEnabled (false);
508 editMenu->addAction (a);
511 // Shortcuts to modify heading:
512 a = new QAction(tr( "Edit heading" ),this);
513 a->setStatusTip ( tr( "edit Heading" ));
514 a->setShortcut ( Qt::Key_Enter);
515 // a->setShortcutContext (Qt::WindowShortcut);
517 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
518 actionListBranches.append(a);
519 a = new QAction( tr( "Edit heading" ), this);
520 a->setStatusTip (tr( "edit Heading" ));
521 a->setShortcut (Qt::Key_Return );
522 //a->setShortcutContext (Qt::WindowShortcut);
524 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
525 actionListBranches.append(a);
526 editMenu->addAction (a);
528 a = new QAction( tr( "Edit heading" ), this);
529 a->setStatusTip (tr( "edit Heading" ));
530 a->setShortcut ( Qt::Key_F2 );
531 a->setShortcutContext (Qt::WindowShortcut);
533 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
534 actionListBranches.append(a);
536 // Shortcut to delete selection
537 a = new QAction( tr( "Delete Selection" ),this);
538 a->setStatusTip (tr( "Delete Selection" ));
539 a->setShortcut ( Qt::Key_Delete);
540 a->setShortcutContext (Qt::WindowShortcut);
542 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
545 // Shortcut to add branch
546 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
547 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
548 alt->setShortcut (Qt::Key_A);
549 alt->setShortcutContext (Qt::WindowShortcut);
551 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
552 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
553 a->setStatusTip ( tr( "Add a branch as child of selection" ));
554 a->setShortcut (Qt::Key_Insert);
555 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
556 actionListBranches.append(a);
557 #if defined (Q_OS_MACX)
558 // In OSX show different shortcut in menues, the keys work indepently always
559 actionEditAddBranch=alt;
561 actionEditAddBranch=a;
563 editMenu->addAction (actionEditAddBranch);
564 tb->addAction (actionEditAddBranch);
567 // Add branch by inserting it at selection
568 a = new QAction(tr( "Add branch (insert)" ), this);
569 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
570 a->setShortcut (Qt::ALT + Qt::Key_Insert );
571 a->setShortcutContext (Qt::WindowShortcut);
573 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
574 a->setEnabled (false);
575 actionListBranches.append(a);
576 actionEditAddBranchHere=a;
577 a = new QAction(tr( "Add branch (insert)" ),this);
578 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
579 a->setShortcut ( Qt::ALT + Qt::Key_A );
580 a->setShortcutContext (Qt::WindowShortcut);
582 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
583 actionListBranches.append(a);
586 a = new QAction(tr( "Add branch above" ), this);
587 a->setStatusTip ( tr( "Add a branch above selection" ));
588 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
589 a->setShortcutContext (Qt::WindowShortcut);
591 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
592 a->setEnabled (false);
593 actionListBranches.append(a);
594 actionEditAddBranchAbove=a;
595 a = new QAction(tr( "Add branch above" ), this);
596 a->setStatusTip ( tr( "Add a branch above selection" ));
597 a->setShortcut (Qt::SHIFT+Qt::Key_A );
598 a->setShortcutContext (Qt::WindowShortcut);
600 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
601 actionListBranches.append(a);
604 a = new QAction(tr( "Add branch below" ), this);
605 a->setStatusTip ( tr( "Add a branch below selection" ));
606 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
607 a->setShortcutContext (Qt::WindowShortcut);
609 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
610 a->setEnabled (false);
611 actionListBranches.append(a);
612 actionEditAddBranchBelow=a;
613 a = new QAction(tr( "Add branch below" ), this);
614 a->setStatusTip ( tr( "Add a branch below selection" ));
615 a->setShortcut (Qt::CTRL +Qt::Key_A );
616 a->setShortcutContext (Qt::WindowShortcut);
618 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
619 actionListBranches.append(a);
621 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
622 a->setStatusTip ( tr( "Move branch up" ) );
623 a->setShortcut (Qt::Key_PageUp );
624 a->setEnabled (false);
626 editMenu->addAction (a);
627 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
630 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
631 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
632 a->setStatusTip (tr( "Move branch down" ) );
633 a->setShortcut ( Qt::Key_PageDown );
634 a->setEnabled (false);
636 editMenu->addAction (a);
637 actionEditMoveDown=a;
640 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
641 a->setShortcut ( Qt::Key_ScrollLock );
642 a->setStatusTip (tr( "Scroll branch" ) );
643 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
645 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
646 alt->setShortcut ( Qt::Key_S );
647 alt->setStatusTip (tr( "Scroll branch" ));
648 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
649 #if defined(Q_OS_MACX)
650 actionEditToggleScroll=alt;
652 actionEditToggleScroll=a;
654 actionEditToggleScroll->setEnabled (false);
655 actionEditToggleScroll->setToggleAction(true);
656 tb->addAction (actionEditToggleScroll);
657 editMenu->addAction ( actionEditToggleScroll);
658 editMenu->addAction (actionEditToggleScroll);
661 actionListBranches.append(actionEditToggleScroll);
663 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
664 a->setStatusTip (tr( "Unscroll all" ));
665 editMenu->addAction (a);
666 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
668 editMenu->addSeparator();
670 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
671 a->setStatusTip (tr( "Find" ) );
672 a->setShortcut (Qt::CTRL + Qt::Key_F );
673 editMenu->addAction (a);
674 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
676 editMenu->addSeparator();
678 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
679 a->setShortcut (Qt::CTRL + Qt::Key_U );
680 a->setShortcut (tr( "Open URL" ));
683 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
686 a = new QAction( tr( "Open URL in new tab" ), this);
687 a->setStatusTip (tr( "Open URL in new tab" ));
688 a->setShortcut (Qt::CTRL+Qt::Key_U );
690 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
691 actionEditOpenURLTab=a;
693 a = new QAction( tr( "Open all URLs in subtree" ), this);
694 a->setStatusTip (tr( "Open all URLs in subtree" ));
696 actionListBranches.append(a);
697 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
698 actionEditOpenMultipleURLTabs=a;
700 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
701 a->setStatusTip ( tr( "Edit URL" ) );
702 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
703 //a->setShortcut ( Qt::Key_U );
704 a->setShortcutContext (Qt::WindowShortcut);
705 actionListBranches.append(a);
707 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
710 a = new QAction( tr( "Use heading for URL" ), this);
711 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
712 a->setEnabled (false);
713 actionListBranches.append(a);
714 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
715 actionEditHeading2URL=a;
717 a = new QAction(tr( "Create URL to Bugzilla" ), this);
718 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
719 a->setEnabled (false);
720 actionListBranches.append(a);
721 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
722 actionEditBugzilla2URL=a;
724 a = new QAction(tr( "Create URL to FATE" ), this);
725 a->setStatusTip ( tr( "Create URL to FATE" ));
726 a->setEnabled (false);
727 actionListBranches.append(a);
728 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
729 actionEditFATE2URL=a;
731 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this);
732 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
734 a->setEnabled (false);
735 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
736 actionEditOpenVymLink=a;
738 a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this);
739 a->setStatusTip ( tr( "Open all vym links in subtree" ));
740 a->setEnabled (false);
741 actionListBranches.append(a);
742 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
743 actionEditOpenMultipleVymLinks=a;
746 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
747 a->setEnabled (false);
748 a->setStatusTip ( tr( "Edit link to another vym map" ));
749 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
750 actionListBranches.append(a);
753 a = new QAction(tr( "Delete vym link" ),this);
754 a->setStatusTip ( tr( "Delete link to another vym map" ));
755 a->setEnabled (false);
756 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
757 actionEditDeleteVymLink=a;
759 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
760 a->setStatusTip ( tr( "Hide object in exports" ) );
761 a->setShortcut (Qt::Key_H );
762 a->setToggleAction(true);
764 a->setEnabled (false);
765 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
766 actionEditToggleHideExport=a;
768 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
769 a->setStatusTip ( tr( "Edit Map Info" ));
770 a->setEnabled (true);
771 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
774 editMenu->addSeparator();
776 // Import at selection (adding to selection)
777 a = new QAction( tr( "Add map (insert)" ),this);
778 a->setStatusTip (tr( "Add map at selection" ));
779 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
780 a->setEnabled (false);
781 actionListBranches.append(a);
782 actionEditImportAdd=a;
784 // Import at selection (replacing selection)
785 a = new QAction( tr( "Add map (replace)" ), this);
786 a->setStatusTip (tr( "Replace selection with map" ));
787 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
788 a->setEnabled (false);
789 actionListBranches.append(a);
790 actionEditImportReplace=a;
793 a = new QAction( tr( "Save selection" ), this);
794 a->setStatusTip (tr( "Save selection" ));
795 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
796 a->setEnabled (false);
797 actionListBranches.append(a);
798 actionEditSaveBranch=a;
800 // Only remove branch, not its childs
801 a = new QAction(tr( "Remove only branch " ), this);
802 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
803 a->setShortcut (Qt::ALT + Qt::Key_Delete );
804 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
805 a->setEnabled (false);
807 actionListBranches.append(a);
808 actionEditRemoveBranchKeepChilds=a;
810 // Only remove childs of a branch
811 a = new QAction( tr( "Remove childs" ), this);
812 a->setStatusTip (tr( "Remove childs of branch" ));
813 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
814 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
815 a->setEnabled (false);
816 actionListBranches.append(a);
817 actionEditRemoveChilds=a;
819 // Shortcuts for navigating with cursor:
820 a = new QAction(tr( "Select upper branch" ), this);
821 a->setStatusTip ( tr( "Select upper branch" ));
822 a->setShortcut (Qt::Key_Up );
823 a->setShortcutContext (Qt::WindowShortcut);
825 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
826 a = new QAction( tr( "Select lower branch" ),this);
827 a->setStatusTip (tr( "Select lower branch" ));
828 a->setShortcut ( Qt::Key_Down );
829 a->setShortcutContext (Qt::WindowShortcut);
831 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
832 a = new QAction(tr( "Select left branch" ), this);
833 a->setStatusTip ( tr( "Select left branch" ));
834 a->setShortcut (Qt::Key_Left );
835 a->setShortcutContext (Qt::WindowShortcut);
837 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
838 a = new QAction( tr( "Select child branch" ), this);
839 a->setStatusTip (tr( "Select right branch" ));
840 a->setShortcut (Qt::Key_Right);
841 a->setShortcutContext (Qt::WindowShortcut);
843 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
844 a = new QAction( tr( "Select first branch" ), this);
845 a->setStatusTip (tr( "Select first branch" ));
846 a->setShortcut (Qt::Key_Home );
847 a->setShortcutContext (Qt::WindowShortcut);
849 a->setEnabled (false);
850 editMenu->addAction (a);
851 actionListBranches.append(a);
852 actionEditSelectFirst=a;
853 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
854 a = new QAction( tr( "Select last branch" ),this);
855 a->setStatusTip (tr( "Select last branch" ));
856 a->setShortcut ( Qt::Key_End );
857 a->setShortcutContext (Qt::WindowShortcut);
859 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
860 a->setEnabled (false);
861 editMenu->addAction (a);
862 actionListBranches.append(a);
863 actionEditSelectLast=a;
865 a = new QAction( tr( "Add Image" )+QString("..."), this);
866 a->setStatusTip (tr( "Add Image" ));
867 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
868 actionEditLoadImage=a;
873 void Main::setupFormatActions()
875 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
877 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
878 tb->setObjectName ("formatTB");
881 pix.fill (Qt::black);
882 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
883 a->setStatusTip ( tr( "Set Color" ));
884 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
886 formatMenu->addAction (a);
888 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
889 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
890 a->setShortcut (Qt::CTRL + Qt::Key_K );
891 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
892 a->setEnabled (false);
894 formatMenu->addAction (a);
895 actionListBranches.append(a);
896 actionFormatPickColor=a;
898 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
899 a->setStatusTip ( tr( "Color branch" ) );
900 a->setShortcut (Qt::CTRL + Qt::Key_I);
901 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
902 a->setEnabled (false);
904 formatMenu->addAction (a);
905 actionListBranches.append(a);
906 actionFormatColorBranch=a;
908 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
909 a->setStatusTip ( tr( "Color Subtree" ));
910 a->setShortcut (Qt::CTRL + Qt::Key_T);
911 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
912 a->setEnabled (false);
913 formatMenu->addAction (a);
915 actionListBranches.append(a);
916 actionFormatColorSubtree=a;
918 formatMenu->addSeparator();
919 actionGroupFormatLinkStyles=new QActionGroup ( this);
920 actionGroupFormatLinkStyles->setExclusive (true);
921 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
922 a->setStatusTip (tr( "Line" ));
923 a->setToggleAction(true);
924 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
925 formatMenu->addAction (a);
926 actionFormatLinkStyleLine=a;
927 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
928 a->setStatusTip (tr( "Line" ));
929 a->setToggleAction(true);
930 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
931 formatMenu->addAction (a);
932 actionFormatLinkStyleParabel=a;
933 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
934 a->setStatusTip (tr( "PolyLine" ));
935 a->setToggleAction(true);
936 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
937 formatMenu->addAction (a);
938 actionFormatLinkStylePolyLine=a;
939 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
940 a->setStatusTip (tr( "PolyParabel" ) );
941 a->setToggleAction(true);
942 a->setChecked (true);
943 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
944 formatMenu->addAction (a);
945 actionFormatLinkStylePolyParabel=a;
947 actionGroupFormatFrameTypes=new QActionGroup ( this);
948 actionGroupFormatFrameTypes->setExclusive (true);
949 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
950 a->setStatusTip (tr("No Frame"));
951 a->setToggleAction(true);
952 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
953 actionFormatFrameNone=a;
954 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
955 a->setStatusTip (tr( "Rectangle" ));
956 a->setToggleAction(true);
957 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
958 actionFormatFrameRectangle=a;
960 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
961 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
962 a->setToggleAction(true);
963 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
964 actionFormatIncludeImagesVer=a;
966 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
967 a->setStatusTip ( tr ("Include left and right position of images into branch"));
968 a->setToggleAction(true);
969 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
970 actionFormatIncludeImagesHor=a;
972 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
973 a->setStatusTip (tr( "Hide link" ));
974 a->setToggleAction(true);
975 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
976 actionFormatHideLinkUnselected=a;
978 formatMenu->addSeparator();
979 a= new QAction( tr( "&Use color of heading for link" ), this);
980 a->setStatusTip (tr( "Use same color for links and headings" ));
981 a->setToggleAction(true);
982 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
983 formatMenu->addAction (a);
984 actionFormatLinkColorHint=a;
986 pix.fill (Qt::white);
987 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
988 a->setStatusTip (tr( "Set Link Color" ));
989 formatMenu->addAction (a);
990 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
991 actionFormatLinkColor=a;
993 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
994 a->setStatusTip (tr( "Set Background Color" ));
995 formatMenu->addAction (a);
996 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
997 actionFormatBackColor=a;
1001 void Main::setupViewActions()
1003 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
1004 tb->setLabel( "View Actions" );
1005 tb->setObjectName ("viewTB");
1006 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1009 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
1010 a->setStatusTip ( tr( "Zoom reset" ) );
1011 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1013 viewMenu->addAction (a);
1014 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1016 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
1017 a->setStatusTip (tr( "Zoom in" ));
1018 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1020 viewMenu->addAction (a);
1021 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1023 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
1024 a->setStatusTip (tr( "Zoom out" ));
1025 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1027 viewMenu->addAction (a);
1028 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1031 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1032 a->setStatusTip ( tr( "Show Note Editor" ));
1033 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1034 a->setToggleAction(true);
1035 if (textEditor->showWithMain())
1040 viewMenu->addAction (a);
1041 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1042 actionViewToggleNoteEditor=a;
1044 a = new QAction( tr( "Show history window" ),this );
1045 a->setStatusTip ( tr( "Show history window" ));
1046 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1047 a->setToggleAction(false);
1048 viewMenu->addAction (a);
1049 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1050 actionViewToggleHistoryWindow=a;
1052 a = new QAction(tr( "Next Window" ), this);
1053 a->setStatusTip ( tr( "&Next Window" ) );
1054 a->setShortcut (Qt::ALT + Qt::Key_N );
1055 viewMenu->addAction (a);
1056 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1058 a = new QAction (tr( "Previous Window" ), this );
1059 a->setStatusTip (tr( "&Previous Window" ));
1060 a->setShortcut (Qt::ALT + Qt::Key_P );
1061 viewMenu->addAction (a);
1062 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1066 void Main::setupModeActions()
1068 //QPopupMenu *menu = new QPopupMenu( this );
1069 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1071 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1072 tb->setObjectName ("modesTB");
1074 actionGroupModModes=new QActionGroup ( this);
1075 actionGroupModModes->setExclusive (true);
1076 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1077 a->setShortcut (Qt::Key_J);
1078 a->setStatusTip ( tr( "Use modifier to color branches" ));
1079 a->setToggleAction(true);
1082 actionModModeColor=a;
1084 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1085 a->setShortcut( Qt::Key_K);
1086 a->setStatusTip( tr( "Use modifier to copy" ));
1087 a->setToggleAction(true);
1089 actionModModeCopy=a;
1091 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1092 a->setShortcut (Qt::Key_L);
1093 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1094 a->setToggleAction(true);
1096 actionModModeLink=a;
1100 void Main::setupFlagActions()
1102 // Create System Flags
1103 systemFlagsDefault = new FlagRowObj ();
1104 systemFlagsDefault->setVisibility (false);
1105 systemFlagsDefault->setName ("systemFlagsDef");
1107 FlagObj *fo = new FlagObj ();
1108 fo->load(QPixmap(flagsPath+"flag-note.png"));
1109 fo->setName("note");
1110 fo->setToolTip(tr("Note","Systemflag"));
1111 systemFlagsDefault->addFlag (fo); // makes deep copy
1113 fo->load(QPixmap(flagsPath+"flag-url.png"));
1115 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1116 systemFlagsDefault->addFlag (fo);
1118 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1119 fo->setName("vymLink");
1120 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1121 systemFlagsDefault->addFlag (fo);
1123 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1124 fo->setName("scrolledright");
1125 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1126 systemFlagsDefault->addFlag (fo);
1128 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1129 fo->setName("tmpUnscrolledright");
1130 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1131 systemFlagsDefault->addFlag (fo);
1133 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1134 fo->setName("hideInExport");
1135 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1136 systemFlagsDefault->addFlag (fo);
1138 // Create Standard Flags
1139 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1140 tb->setObjectName ("standardFlagTB");
1142 standardFlagsDefault = new FlagRowObj ();
1143 standardFlagsDefault->setVisibility (false);
1144 standardFlagsDefault->setName ("standardFlagsDef");
1145 standardFlagsDefault->setToolBar (tb);
1147 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1148 fo->setName ("exclamationmark");
1149 fo->setGroup("standard-mark");
1150 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1153 a->setCheckable(true);
1154 a->setObjectName(fo->getName());
1155 a->setToolTip(tr("Take care!","Standardflag"));
1156 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1157 standardFlagsDefault->addFlag (fo); // makes deep copy
1159 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1160 fo->setName("questionmark");
1161 fo->setGroup("standard-mark");
1162 a=new QAction (fo->getPixmap(),fo->getName(),this);
1165 a->setCheckable(true);
1166 a->setObjectName(fo->getName());
1167 a->setToolTip(tr("Really?","Standardflag"));
1168 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1169 standardFlagsDefault->addFlag (fo);
1171 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1172 fo->setName("hook-green");
1173 fo->setGroup("standard-hook");
1174 a=new QAction (fo->getPixmap(),fo->getName(),this);
1177 a->setCheckable(true);
1178 a->setObjectName(fo->getName());
1179 a->setToolTip(tr("ok!","Standardflag"));
1180 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1181 standardFlagsDefault->addFlag (fo);
1183 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1184 fo->setName("cross-red");
1185 fo->setGroup("standard-hook");
1186 a=new QAction (fo->getPixmap(),fo->getName(),this);
1189 a->setCheckable(true);
1190 a->setObjectName(fo->getName());
1191 a->setToolTip(tr("Not ok!","Standardflag"));
1192 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1193 standardFlagsDefault->addFlag (fo);
1195 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1196 fo->setName("stopsign");
1197 a=new QAction (fo->getPixmap(),fo->getName(),this);
1200 a->setCheckable(true);
1201 a->setObjectName(fo->getName());
1202 a->setToolTip(tr("This won't work!","Standardflag"));
1203 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1204 standardFlagsDefault->addFlag (fo);
1206 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1207 fo->setName("smiley-good");
1208 fo->setGroup("standard-smiley");
1209 a=new QAction (fo->getPixmap(),fo->getName(),this);
1212 a->setCheckable(true);
1213 a->setObjectName(fo->getName());
1214 a->setToolTip(tr("Good","Standardflag"));
1215 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1216 standardFlagsDefault->addFlag (fo);
1218 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1219 fo->setName("smiley-sad");
1220 fo->setGroup("standard-smiley");
1221 a=new QAction (fo->getPixmap(),fo->getName(),this);
1224 a->setCheckable(true);
1225 a->setObjectName(fo->getName());
1226 a->setToolTip(tr("Bad","Standardflag"));
1227 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1228 standardFlagsDefault->addFlag (fo);
1230 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1231 // Original omg.png (in KDE emoticons)
1232 fo->setName("smiley-omg");
1233 fo->setGroup("standard-smiley");
1234 a=new QAction (fo->getPixmap(),fo->getName(),this);
1237 a->setCheckable(true);
1238 a->setObjectName(fo->getName());
1239 a->setToolTip(tr("Oh no!","Standardflag"));
1240 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1241 standardFlagsDefault->addFlag (fo);
1243 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1244 fo->setName("clock");
1245 a=new QAction (fo->getPixmap(),fo->getName(),this);
1248 a->setCheckable(true);
1249 a->setObjectName(fo->getName());
1250 a->setToolTip(tr("Time critical","Standardflag"));
1251 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1252 standardFlagsDefault->addFlag (fo);
1254 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1255 fo->setName("phone");
1256 a=new QAction (fo->getPixmap(),fo->getName(),this);
1259 a->setCheckable(true);
1260 a->setObjectName(fo->getName());
1261 a->setToolTip(tr("Call...","Standardflag"));
1262 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1263 standardFlagsDefault->addFlag (fo);
1265 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1266 fo->setName("lamp");
1267 a=new QAction (fo->getPixmap(),fo->getName(),this);
1270 a->setCheckable(true);
1271 a->setObjectName(fo->getName());
1272 a->setToolTip(tr("Idea!","Standardflag"));
1273 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1274 standardFlagsDefault->addFlag (fo);
1276 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1277 fo->setName("arrow-up");
1278 fo->setGroup("standard-arrow");
1279 a=new QAction (fo->getPixmap(),fo->getName(),this);
1282 a->setCheckable(true);
1283 a->setObjectName(fo->getName());
1284 a->setToolTip(tr("Important","Standardflag"));
1285 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1286 standardFlagsDefault->addFlag (fo);
1288 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1289 fo->setName("arrow-down");
1290 fo->setGroup("standard-arrow");
1291 a=new QAction (fo->getPixmap(),fo->getName(),this);
1294 a->setCheckable(true);
1295 a->setObjectName(fo->getName());
1296 a->setToolTip(tr("Unimportant","Standardflag"));
1297 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1298 standardFlagsDefault->addFlag (fo);
1300 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1301 fo->setName("2arrow-up");
1302 fo->setGroup("standard-arrow");
1303 a=new QAction (fo->getPixmap(),fo->getName(),this);
1306 a->setCheckable(true);
1307 a->setObjectName(fo->getName());
1308 a->setToolTip(tr("Very important!","Standardflag"));
1309 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1310 standardFlagsDefault->addFlag (fo);
1312 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1313 fo->setName("2arrow-down");
1314 fo->setGroup("standard-arrow");
1315 a=new QAction (fo->getPixmap(),fo->getName(),this);
1318 a->setCheckable(true);
1319 a->setObjectName(fo->getName());
1320 a->setToolTip(tr("Very unimportant!","Standardflag"));
1321 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1322 standardFlagsDefault->addFlag (fo);
1324 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1325 fo->setName("thumb-up");
1326 fo->setGroup("standard-thumb");
1327 a=new QAction (fo->getPixmap(),fo->getName(),this);
1330 a->setCheckable(true);
1331 a->setObjectName(fo->getName());
1332 a->setToolTip(tr("I like this","Standardflag"));
1333 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1334 standardFlagsDefault->addFlag (fo);
1336 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1337 fo->setName("thumb-down");
1338 fo->setGroup("standard-thumb");
1339 a=new QAction (fo->getPixmap(),fo->getName(),this);
1342 a->setCheckable(true);
1343 a->setObjectName(fo->getName());
1344 a->setToolTip(tr("I do not like this","Standardflag"));
1345 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1346 standardFlagsDefault->addFlag (fo);
1348 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1349 fo->setName("rose");
1350 a=new QAction (fo->getPixmap(),fo->getName(),this);
1353 a->setCheckable(true);
1354 a->setObjectName(fo->getName());
1355 a->setToolTip(tr("Rose","Standardflag"));
1356 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1357 standardFlagsDefault->addFlag (fo);
1359 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1360 fo->setName("heart");
1361 a=new QAction (fo->getPixmap(),fo->getName(),this);
1363 a->setCheckable(true);
1364 a->setObjectName(fo->getName());
1365 a->setToolTip(tr("I just love... ","Standardflag"));
1366 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1367 standardFlagsDefault->addFlag (fo);
1369 fo->load(QPixmap(flagsPath+"flag-present.png"));
1370 fo->setName("present");
1371 a=new QAction (fo->getPixmap(),fo->getName(),this);
1374 a->setCheckable(true);
1375 a->setObjectName(fo->getName());
1376 a->setToolTip(tr("Surprise!","Standardflag"));
1377 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1378 standardFlagsDefault->addFlag (fo);
1380 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1381 fo->setName("flash");
1382 a=new QAction (fo->getPixmap(),fo->getName(),this);
1385 a->setCheckable(true);
1386 a->setObjectName(fo->getName());
1387 a->setToolTip(tr("Dangerous","Standardflag"));
1388 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1389 standardFlagsDefault->addFlag (fo);
1391 fo->load(QPixmap(flagsPath+"flag-info.png"));
1392 // Original: xsldbg_output.png
1393 fo->setName("info");
1394 a=new QAction (fo->getPixmap(),fo->getName(),this);
1397 a->setCheckable(true);
1398 a->setObjectName(fo->getName());
1399 a->setToolTip(tr("Info","Standardflag"));
1400 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1401 standardFlagsDefault->addFlag (fo);
1403 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1404 // Original khelpcenter.png
1405 fo->setName("lifebelt");
1406 a=new QAction (fo->getPixmap(),fo->getName(),this);
1409 a->setCheckable(true);
1410 a->setObjectName(fo->getName());
1411 a->setToolTip(tr("This will help","Standardflag"));
1412 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1413 standardFlagsDefault->addFlag (fo);
1419 void Main::setupSettingsActions()
1421 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1425 a = new QAction( tr( "Set application to open pdf files"), this);
1426 a->setStatusTip ( tr( "Set application to open pdf files"));
1427 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1428 settingsMenu->addAction (a);
1430 a = new QAction( tr( "Set application to open external links"), this);
1431 a->setStatusTip( tr( "Set application to open external links"));
1432 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1433 settingsMenu->addAction (a);
1435 settingsMenu->addSeparator();
1436 a = new QAction( tr( "Edit branch after adding it" ), this );
1437 a->setStatusTip( tr( "Edit branch after adding it" ));
1438 a->setToggleAction(true);
1439 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1440 settingsMenu->addAction (a);
1441 actionSettingsAutoedit=a;
1443 a= new QAction( tr( "Select branch after adding it" ), this );
1444 a->setStatusTip( tr( "Select branch after adding it" ));
1445 a->setToggleAction(true);
1446 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1447 settingsMenu->addAction (a);
1448 actionSettingsAutoselectHeading=a;
1450 a= new QAction(tr( "Select existing heading" ), this);
1451 a->setStatusTip( tr( "Select heading before editing" ));
1452 a->setToggleAction(true);
1453 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1454 settingsMenu->addAction (a);
1455 actionSettingsAutoselectText=a;
1457 a= new QAction( tr( "Delete key" ), this);
1458 a->setStatusTip( tr( "Delete key for deleting branches" ));
1459 a->setToggleAction(true);
1460 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1461 settingsMenu->addAction (a);
1462 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1463 actionSettingsUseDelKey=a;
1465 a= new QAction( tr( "Exclusive flags" ), this);
1466 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1467 a->setToggleAction(true);
1468 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1469 settingsMenu->addAction (a);
1470 actionSettingsUseFlagGroups=a;
1472 a= new QAction( tr( "Use hide flags" ), this);
1473 a->setStatusTip( tr( "Use hide flag during exports " ));
1474 a->setToggleAction(true);
1475 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1476 settingsMenu->addAction (a);
1477 actionSettingsUseHideExport=a;
1481 void Main::setupTestActions()
1483 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1486 a = new QAction( tr( "test flag" ), this);
1487 a->setStatusTip( tr( "Call test function" ));
1488 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1489 testMenu->addAction (a);
1493 void Main::setupHelpActions()
1495 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1498 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1499 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1500 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1501 helpMenu->addAction (a);
1503 a = new QAction( tr( "About VYM" ), this);
1504 a->setStatusTip( tr( "About VYM")+" "__VYM);
1505 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1506 helpMenu->addAction (a);
1508 a = new QAction( tr( "About QT" ), this);
1509 a->setStatusTip( tr( "Information about QT toolkit" ));
1510 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1511 helpMenu->addAction (a);
1515 void Main::setupContextMenus()
1519 // Context Menu for branch or mapcenter
1520 branchContextMenu =new QMenu (this);
1523 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1524 branchAddContextMenu->addAction (actionEditPaste );
1525 branchAddContextMenu->addAction ( actionEditAddBranch );
1526 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1527 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1528 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1529 branchAddContextMenu->addSeparator();
1530 branchAddContextMenu->addAction ( actionEditLoadImage);
1531 branchAddContextMenu->addSeparator();
1532 branchAddContextMenu->addAction ( actionEditImportAdd );
1533 branchAddContextMenu->addAction ( actionEditImportReplace );
1536 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1537 branchRemoveContextMenu->addAction (actionEditCut);
1538 branchRemoveContextMenu->addAction ( actionEditDelete );
1539 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1540 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1543 actionEditSaveBranch->addTo( branchContextMenu );
1545 branchContextMenu->addSeparator();
1546 branchContextMenu->addAction ( actionFormatFrameNone );
1547 branchContextMenu->addAction ( actionFormatFrameRectangle);
1549 branchContextMenu->addSeparator();
1550 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1551 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1552 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1554 // Submenu for Links (URLs, vymLinks)
1555 branchLinksContextMenu =new QMenu (this);
1557 branchContextMenu->addSeparator();
1558 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));
1559 branchLinksContextMenu->addAction ( actionEditOpenURL );
1560 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1561 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1562 branchLinksContextMenu->addAction ( actionEditURL );
1563 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1564 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1565 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1567 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1569 branchLinksContextMenu->addSeparator();
1570 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1571 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1572 branchLinksContextMenu->addAction ( actionEditVymLink );
1573 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1576 // Context Menu for XLinks in a branch menu
1577 // This will be populated "on demand" in MapEditor::updateActions
1578 branchContextMenu->addSeparator();
1579 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1580 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1581 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1582 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1585 // Context menu for floatimage
1586 floatimageContextMenu =new QMenu (this);
1587 a= new QAction (tr ("Save image"),this);
1588 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1589 floatimageContextMenu->addAction (a);
1591 floatimageContextMenu->addSeparator();
1592 actionEditCopy->addTo( floatimageContextMenu );
1593 actionEditCut->addTo( floatimageContextMenu );
1595 floatimageContextMenu->addSeparator();
1596 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1599 // Context menu for canvas
1600 canvasContextMenu =new QMenu (this);
1601 actionEditMapInfo->addTo( canvasContextMenu );
1602 canvasContextMenu->insertSeparator();
1603 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1604 canvasContextMenu->insertSeparator();
1605 actionFormatLinkColorHint->addTo( canvasContextMenu );
1606 actionFormatLinkColor->addTo( canvasContextMenu );
1607 actionFormatBackColor->addTo( canvasContextMenu );
1609 // Menu for last opened files
1610 // Read settings initially
1612 int j=settings.readNumEntry( "/lastMaps/number",0);
1613 for (int i=1;i<=j;i++)
1615 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1616 if (!s.isEmpty() && j<=maxLastMaps)
1619 setupLastMapsMenu();
1620 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1623 void Main::setupLastMapsMenu()
1625 // Remove double entries
1626 QStringList::Iterator it=lastMaps.begin();
1627 QStringList::Iterator jt;
1628 while (it!=lastMaps.end() )
1632 while (jt!=lastMaps.end() )
1635 jt=lastMaps.remove(jt);
1642 // Limit length of list to maxLastMaps
1643 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1645 // build Menu from lastMaps string list
1646 fileLastMapsMenu->clear();
1647 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1648 fileLastMapsMenu->addAction (*it );
1651 void Main::hideEvent (QHideEvent * )
1653 if (!textEditor->isMinimized() ) textEditor->hide();
1656 void Main::showEvent (QShowEvent * )
1658 if (textEditor->showWithMain()) textEditor->showNormal();
1661 bool Main::reallyWriteDirectory(const QString &dir)
1663 QStringList eList = QDir(dir).entryList();
1664 if (eList.first() ==".") eList.pop_front(); // remove "."
1665 if (eList.first() =="..") eList.pop_front(); // remove "."
1666 if (!eList.isEmpty())
1668 QMessageBox mb( __VYM,
1669 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1670 QMessageBox::Warning,
1672 QMessageBox::Cancel | QMessageBox::Default,
1673 QMessageBox::QMessageBox::NoButton );
1675 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1676 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1679 case QMessageBox::Yes:
1682 case QMessageBox::Cancel:
1690 QString Main::browseDirectory (const QString &caption)
1692 Q3FileDialog fd(this,caption);
1693 fd.setMode (Q3FileDialog::DirectoryOnly);
1694 fd.setCaption(__VYM " - "+caption);
1697 if ( fd.exec() == QDialog::Accepted )
1698 return fd.selectedFile();
1703 MapEditor* Main::currentMapEditor() const
1705 if ( tabWidget->currentPage() &&
1706 tabWidget->currentPage()->inherits( "MapEditor" ) )
1707 return (MapEditor*)tabWidget->currentPage();
1711 //TODO not used now, maybe use this for overview window later
1712 void Main::newView()
1714 // Open a new view... have it delete when closed.
1715 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1716 qApp->setMainWidget(m);
1718 qApp->setMainWidget(0);
1721 void Main::editorChanged(QWidget *)
1723 // Unselect all possibly selected objects
1724 // (Important to update note editor)
1727 for (i=0;i<=tabWidget->count() -1;i++)
1730 me=(MapEditor*)tabWidget->page(i);
1733 currentMapEditor()->reselect();
1735 // Update actions to in menus and toolbars according to editor
1736 currentMapEditor()->updateActions();
1739 void Main::fileNew()
1741 QString fn="unnamed";
1742 MapEditor* medit = new MapEditor ( NULL,true);
1743 tabWidget->addTab (medit,fn);
1744 tabWidget->showPage(medit);
1745 medit->viewport()->setFocus();
1746 // For the very first map we do not have flagrows yet...
1747 medit->select("mc:");
1750 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1752 ErrorCode err=success;
1754 // fn is usually the archive, mapfile the file after uncompressing
1757 // Make fn absolute (needed for unzip)
1758 fn=QDir (fn).absPath();
1764 // Check, if map is already loaded
1766 while (i<=tabWidget->count() -1)
1768 me=(MapEditor*)tabWidget->page(i);
1769 if (me->getFilePath() == fn)
1771 // Already there, ask for confirmation
1772 QMessageBox mb( __VYM,
1773 tr("The map %1\nis already opened."
1774 "Opening the same map in multiple editors may lead \n"
1775 "to confusion when finishing working with vym."
1776 "Do you want to").arg(fn),
1777 QMessageBox::Warning,
1778 QMessageBox::Yes | QMessageBox::Default,
1779 QMessageBox::Cancel | QMessageBox::Escape,
1780 QMessageBox::NoButton);
1781 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1782 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1785 case QMessageBox::Yes:
1787 i=tabWidget->count();
1789 case QMessageBox::Cancel:
1801 if ( !fn.isEmpty() )
1803 me = currentMapEditor();
1804 int tabIndex=tabWidget->currentPageIndex();
1805 // Check first, if mapeditor exists
1806 // If it is not default AND we want a new map,
1807 // create a new mapeditor in a new tab
1808 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1810 me= new MapEditor ( NULL,true);
1811 tabWidget->addTab (me,fn);
1812 tabIndex=tabWidget->indexOf (me);
1813 tabWidget->setCurrentPage (tabIndex);
1816 // Check, if file exists (important for creating new files
1817 // from command line
1818 if (!QFile(fn).exists() )
1820 QMessageBox mb( __VYM,
1821 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1822 QMessageBox::Question,
1824 QMessageBox::Cancel | QMessageBox::Default,
1825 QMessageBox::NoButton );
1827 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1828 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1831 case QMessageBox::Yes:
1833 currentMapEditor()->setFilePath(fn);
1834 tabWidget->setTabLabel (currentMapEditor(),
1835 currentMapEditor()->getFileName() );
1836 statusBar()->message( "Created " + fn , statusbarTime );
1839 case QMessageBox::Cancel:
1840 // don't create new map
1841 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1848 //tabWidget->currentPage() won't be NULL here, because of above...
1849 tabWidget->showPage(me);
1850 me->viewport()->setFocus();
1852 // Create temporary directory for packing
1853 char tmpdir1[]="/tmp/vym-XXXXXX";
1854 QString tmpMapDir=mkdtemp(tmpdir1);
1856 // Try to unzip file
1857 err=unzipDir (tmpMapDir,fn);
1861 me->setZipped(false);
1864 me->setZipped(true);
1866 // Look for mapname.xml
1867 mapfile= fn.left(fn.findRev(".",-1,true));
1868 mapfile=mapfile.section( '/', -1 );
1869 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1870 if (!file.exists() )
1872 // mapname.xml does not exist, well,
1873 // maybe some renamed the mapname.vym file...
1874 // Try to find any .xml in the toplevel
1875 // directory of the .vym file
1876 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1877 if (flist.count()==1)
1879 // Only one entry, take this one
1880 mapfile=tmpMapDir + "/"+flist.first();
1883 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1884 *it=tmpMapDir + "/" + *it;
1885 // TODO Multiple entries, load all (but only the first one into this ME)
1886 //mainWindow->fileLoadFromTmp (flist);
1887 //returnCode=1; // Silently forget this attempt to load
1888 qWarning ("MainWindow::load (fn) multimap found...");
1891 if (flist.isEmpty() )
1893 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1894 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1897 } //file doesn't exist
1899 mapfile=file.name();
1904 // Save existing filename in case we import
1905 QString fn_org=me->getFilePath();
1907 // Finally load map into mapEditor
1908 me->setFilePath (mapfile,fn);
1909 err=me->load(mapfile,lmode);
1911 // Restore old (maybe empty) filepath, if this is an import
1913 me->setFilePath (fn_org);
1916 // Finally check for errors and go home
1919 if (lmode==NewMap) fileCloseMap();
1920 statusBar()->message( "Could not load " + fn, statusbarTime );
1925 me->setFilePath (fn);
1926 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1927 if (fn.left(9)!="/tmp/vym-")
1929 // Only append to lastMaps if not loaded from a tmpDir
1930 // e.g. imported bookmarks are in a tmpDir
1931 lastMaps.prepend(me->getFilePath() );
1932 setupLastMapsMenu();
1934 actionFilePrint->setEnabled (true);
1936 statusBar()->message( "Loaded " + fn, statusbarTime );
1940 removeDir (QDir(tmpMapDir));
1946 void Main::fileLoad(const LoadMode &lmode)
1948 Q3FileDialog *fd=new Q3FileDialog( this);
1949 fd->setDir (lastFileDir);
1950 fd->setMode (Q3FileDialog::ExistingFiles);
1951 fd->addFilter ("XML (*.xml)");
1952 fd->addFilter ("VYM map (*.vym *.vyp)");
1956 fd->setCaption(tr("Load vym map"));
1959 fd->setCaption(tr("Import: Add vym map to selection"));
1962 fd->setCaption(tr("Import: Replace selection with vym map"));
1968 if ( fd->exec() == QDialog::Accepted )
1970 lastFileDir=fd->dirPath();
1971 QStringList flist = fd->selectedFiles();
1972 QStringList::Iterator it = flist.begin();
1973 while( it != flist.end() )
1976 fileLoad(*it, lmode);
1983 void Main::fileLoad()
1988 void Main::fileLoadLast(QAction *a)
1990 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1993 void Main::fileSave(const SaveMode &savemode)
1995 // tmp dir for zipping
1999 ErrorCode err=success;
2001 QString safeFilePath;
2003 bool saveZipped=currentMapEditor()->saveZipped();
2005 MapEditor * me=currentMapEditor();
2008 QString fn=me->getFilePath();
2009 // filename=unnamed, filepath="" in constructor...
2010 if ( !fn.isEmpty() )
2012 // We have a filepath, go on saving
2013 // First remove existing file, we
2014 // don't want to add to old zip archives
2018 QMessageBox::warning( 0, tr( "Save Error" ),
2019 fn+ tr("\ncould not be removed before saving"));
2021 // Look, if we should zip the data:
2024 QMessageBox mb( __VYM,
2025 tr("The map %1\ndid not use the compressed "
2026 "vym file format.\nWriting it uncompressed will also write images \n"
2027 "and flags and thus may overwrite files in the "
2028 "given directory\n\nDo you want to write the map").arg(fn),
2029 QMessageBox::Warning,
2030 QMessageBox::Yes | QMessageBox::Default,
2032 QMessageBox::Cancel | QMessageBox::Escape);
2033 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2034 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2035 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2038 case QMessageBox::Yes:
2039 // save compressed (default file format)
2042 case QMessageBox::No:
2043 // save uncompressed
2046 case QMessageBox::Cancel:
2055 char tmpdir1[]="/tmp/vym-XXXXXX";
2056 tmpMapDir=mkdtemp(tmpdir1);
2058 safeFilePath=me->getFilePath();
2059 me->setFilePath (tmpMapDir+"/"+
2060 me->getMapName()+ ".xml",
2062 me->save (savemode);
2063 me->setFilePath (safeFilePath);
2065 zipDir (tmpMapDir,fn);
2070 safeFilePath=me->getFilePath();
2071 me->setFilePath (fn, safeFilePath);
2072 me->save (savemode);
2073 me->setFilePath (safeFilePath);
2075 } // filepath available
2078 // We have no filepath yet,
2079 // call fileSaveAs() now, this will call fileSave()
2081 fileSaveAs(savemode);
2085 if (saveZipped && !tmpMapDir.isEmpty())
2087 removeDir (QDir(tmpMapDir));
2091 statusBar()->message(
2092 tr("Saved %1").arg(me->getFilePath()),
2094 lastMaps.prepend(me->getFilePath() );
2095 setupLastMapsMenu();
2097 statusBar()->message(
2098 tr("Couldn't save ").arg(me->getFilePath()),
2102 void Main::fileSave()
2104 fileSave (CompleteMap);
2107 void Main::fileSaveAs(const SaveMode& savemode)
2111 if (currentMapEditor())
2113 if (savemode==CompleteMap)
2114 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2116 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2117 if ( !fn.isEmpty() )
2119 // Check for existing file
2120 if (QFile (fn).exists())
2122 QMessageBox mb( __VYM,
2123 tr("The file %1\nexists already. Do you want to").arg(fn),
2124 QMessageBox::Warning,
2125 QMessageBox::Yes | QMessageBox::Default,
2126 QMessageBox::Cancel | QMessageBox::Escape,
2127 QMessageBox::NoButton);
2128 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2129 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2132 case QMessageBox::Yes:
2135 case QMessageBox::Cancel:
2142 // New file, add extension to filename, if missing
2143 // This is always .vym or .vyp, depending on savemode
2144 if (savemode==CompleteMap)
2146 if (!fn.contains (".vym") && !fn.contains (".xml"))
2150 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2159 currentMapEditor()->setFilePath(fn);
2163 if (savemode==CompleteMap)
2164 tabWidget->setTabLabel (currentMapEditor(),
2165 currentMapEditor()->getFileName() );
2171 void Main::fileSaveAs()
2173 fileSaveAs (CompleteMap);
2176 void Main::fileImportKDEBookmarks()
2178 ImportKDEBookmarks im;
2180 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2181 currentMapEditor()->setFilePath ("");
2184 void Main::fileImportFirefoxBookmarks()
2186 Q3FileDialog *fd=new Q3FileDialog( this);
2187 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2188 fd->setMode (Q3FileDialog::ExistingFiles);
2189 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2190 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2193 if ( fd->exec() == QDialog::Accepted )
2195 ImportFirefoxBookmarks im;
2196 QStringList flist = fd->selectedFiles();
2197 QStringList::Iterator it = flist.begin();
2198 while( it != flist.end() )
2201 if (im.transform() &&
2202 success==fileLoad (im.getTransformedFile(),NewMap) &&
2203 currentMapEditor() )
2204 currentMapEditor()->setFilePath ("");
2211 void Main::fileImportMM()
2215 Q3FileDialog *fd=new Q3FileDialog( this);
2216 fd->setDir (lastFileDir);
2217 fd->setMode (Q3FileDialog::ExistingFiles);
2218 fd->addFilter ("Mind Manager (*.mmap)");
2219 fd->setCaption(tr("Import")+" "+"Mind Manager");
2222 if ( fd->exec() == QDialog::Accepted )
2224 lastFileDir=fd->dirPath();
2225 QStringList flist = fd->selectedFiles();
2226 QStringList::Iterator it = flist.begin();
2227 while( it != flist.end() )
2230 if (im.transform() &&
2231 success==fileLoad (im.getTransformedFile(),NewMap) &&
2232 currentMapEditor() )
2233 currentMapEditor()->setFilePath ("");
2242 void Main::fileImportDir()
2244 if (currentMapEditor())
2245 currentMapEditor()->importDir();
2248 void Main::fileExportXML()
2250 if (currentMapEditor())
2252 QString dir=browseDirectory(tr("Export XML to directory"));
2253 if (dir !="" && reallyWriteDirectory(dir) )
2254 currentMapEditor()->exportXML(dir);
2259 void Main::fileExportXHTML()
2261 MapEditor *me=currentMapEditor();
2265 ExportXHTMLDialog dia(this);
2266 dia.setFilePath (me->getFilePath() );
2267 dia.setMapName (me->getMapName() );
2270 if (dia.exec()==QDialog::Accepted)
2272 QString dir=dia.getDir();
2273 // Check, if warnings should be used before overwriting
2274 // the output directory
2277 ok=reallyWriteDirectory(dir);
2283 me->exportXML (dia.getDir() );
2284 dia.doExport(me->getMapName() );
2285 if (dia.hasChanged())
2292 void Main::fileExportImage()
2294 MapEditor *me=currentMapEditor();
2298 QFileDialog *fd=new QFileDialog (this);
2299 fd->setCaption (tr("Export map as image"));
2300 fd->setFileMode(QFileDialog::AnyFile);
2301 fd->setFilters (imageIO.getFilters() );
2302 fd->setDirectory (lastImageDir);
2305 fl=fd->selectedFiles();
2306 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2307 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2312 void Main::fileExportASCII()
2314 MapEditor *me=currentMapEditor();
2318 ex.setMapCenter(me->getMapCenter());
2319 ex.addFilter ("TXT (*.txt)");
2320 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2321 if (ex.execDialog() )
2323 me->setExportMode(true);
2325 me->setExportMode(false);
2330 void Main::fileExportLaTeX()
2332 MapEditor *me=currentMapEditor();
2336 ex.setMapCenter(me->getMapCenter());
2337 ex.addFilter ("Tex (*.tex)");
2338 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2339 if (ex.execDialog() )
2341 me->setExportMode(true);
2343 me->setExportMode(false);
2348 void Main::fileExportKDEBookmarks()
2350 ExportKDEBookmarks ex;
2351 MapEditor *me=currentMapEditor();
2354 ex.setMapCenter (me->getMapCenter() );
2359 void Main::fileExportTaskjuggler()
2361 ExportTaskjuggler ex;
2362 MapEditor *me=currentMapEditor();
2365 ex.setMapCenter (me->getMapCenter() );
2366 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2367 ex.addFilter ("Taskjuggler (*.tjp)");
2368 if (ex.execDialog() )
2370 me->setExportMode(true);
2372 me->setExportMode(false);
2377 void Main::fileExportOOPresentation()
2379 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2380 // TODO add preview in dialog
2381 //ImagePreview *p =new ImagePreview (fd);
2382 //fd->setContentsPreviewEnabled( TRUE );
2383 //fd->setContentsPreview( p, p );
2384 //fd->setPreviewMode( QFileDialog::Contents );
2385 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2386 fd->setDir (QDir().current());
2387 if (fd->foundConfig())
2391 if ( fd->exec() == QDialog::Accepted )
2393 QString fn=fd->selectedFile();
2394 if (!fn.contains (".odp"))
2397 //lastImageDir=fn.left(fn.findRev ("/"));
2398 if (currentMapEditor())
2399 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2403 QMessageBox::warning(0,
2405 tr("Couldn't find configuration for export to Open Office\n"));
2409 void Main::fileCloseMap()
2411 if (currentMapEditor())
2413 if (currentMapEditor()->hasChanged())
2415 QMessageBox mb( __VYM,
2416 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2417 QMessageBox::Warning,
2418 QMessageBox::Yes | QMessageBox::Default,
2420 QMessageBox::Cancel | QMessageBox::Escape );
2421 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2422 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2425 case QMessageBox::Yes:
2427 fileSave(CompleteMap);
2429 case QMessageBox::No:
2430 // close without saving
2432 case QMessageBox::Cancel:
2437 currentMapEditor()->closeMap();
2438 tabWidget->removePage(currentMapEditor());
2439 if (tabWidget->count()==0)
2440 actionFilePrint->setEnabled (false);
2444 void Main::filePrint()
2446 if (currentMapEditor())
2447 currentMapEditor()->print();
2450 void Main::fileExitVYM()
2452 // Check if one or more editors have changed
2455 for (i=0;i<=tabWidget->count() -1;i++)
2458 me=(MapEditor*)tabWidget->page(i);
2460 // If something changed, ask what to do
2461 if (me->isUnsaved())
2463 tabWidget->setCurrentPage(i);
2464 QMessageBox mb( __VYM,
2465 tr("This map is not saved yet. Do you want to"),
2466 QMessageBox::Warning,
2467 QMessageBox::Yes | QMessageBox::Default,
2469 QMessageBox::Cancel | QMessageBox::Escape );
2470 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2471 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2474 mb.setActiveWindow();
2475 switch( mb.exec() ) {
2476 case QMessageBox::Yes:
2477 // save (the changed editors) and exit
2478 fileSave(CompleteMap);
2480 case QMessageBox::No:
2481 // exit without saving
2483 case QMessageBox::Cancel:
2484 // don't save and don't exit
2488 } // loop over all MEs
2492 void Main::editUndo()
2494 if (currentMapEditor())
2495 currentMapEditor()->undo();
2498 void Main::editRedo()
2500 if (currentMapEditor())
2501 currentMapEditor()->redo();
2504 void Main::editCopy()
2506 if (currentMapEditor())
2507 currentMapEditor()->copy();
2510 void Main::editPaste()
2512 if (currentMapEditor())
2513 currentMapEditor()->paste();
2516 void Main::editCut()
2518 if (currentMapEditor())
2519 currentMapEditor()->cut();
2522 void Main::editOpenFindWindow()
2524 findWindow->popup();
2525 findWindow->raise();
2526 findWindow->setActiveWindow();
2529 void Main::editFind(QString s)
2532 BranchObj *bo=currentMapEditor()->findText(s, cs);
2535 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2538 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2539 tr("No matches found for \"%1\"").arg(s));
2543 void Main::editFindChanged()
2544 { // Notify editor, to abort the current find process
2545 currentMapEditor()->findReset();
2548 void Main::openTabs(QStringList urls)
2550 if (!urls.isEmpty())
2554 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2556 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2558 QString u=urls.takeFirst();
2559 procBrowser = new QProcess( this );
2561 procBrowser->start(browser,args);
2562 if ( !procBrowser->waitForStarted())
2564 // try to set path to browser
2565 QMessageBox::warning(0,
2567 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2568 tr("Please use Settings->")+tr("Set application to open an URL"));
2573 if (browser.contains("konqueror"))
2575 for (int i=0; i<urls.size(); i++)
2578 // Try to open new tab in existing konqueror started previously by vym
2579 p=new QProcess (this);
2581 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2582 "konqueror-mainwindow#1"<<
2585 p->start ("dcop",args);
2586 if ( !p->waitForStarted() ) success=false;
2589 QMessageBox::warning(0,
2591 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2593 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2595 for (int i=0; i<urls.size(); i++)
2597 // Try to open new tab in firefox
2598 p=new QProcess (this);
2599 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2600 p->start (browser,args);
2601 if ( !p->waitForStarted() ) success=false;
2604 QMessageBox::warning(0,
2606 tr("Couldn't start %1 to open a new tab").arg(browser));
2609 QMessageBox::warning(0,
2611 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2615 void Main::editOpenURL()
2618 if (currentMapEditor())
2620 QString url=currentMapEditor()->getURL();
2622 if (url=="") return;
2623 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2624 procBrowser = new QProcess( this );
2626 procBrowser->start(browser,args);
2627 if ( !procBrowser->waitForStarted())
2629 // try to set path to browser
2630 QMessageBox::warning(0,
2632 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2633 tr("Please use Settings->")+tr("Set application to open an URL"));
2638 void Main::editOpenURLTab()
2640 if (currentMapEditor())
2643 urls.append(currentMapEditor()->getURL());
2647 void Main::editOpenMultipleURLTabs()
2649 if (currentMapEditor())
2652 urls=currentMapEditor()->getURLs();
2658 void Main::editURL()
2660 if (currentMapEditor())
2661 currentMapEditor()->editURL();
2664 void Main::editHeading2URL()
2666 if (currentMapEditor())
2667 currentMapEditor()->editHeading2URL();
2670 void Main::editBugzilla2URL()
2672 if (currentMapEditor())
2673 currentMapEditor()->editBugzilla2URL();
2676 void Main::editFATE2URL()
2678 if (currentMapEditor())
2679 currentMapEditor()->editFATE2URL();
2682 void Main::editHeading()
2684 if (lineedit->isVisible())
2686 if (currentMapEditor())
2688 MapEditor *me=currentMapEditor();
2689 QString oldSel=me->getSelectString();
2690 if (me->select (editSel))
2691 me->setHeading(lineedit->text());
2692 me->select (oldSel);
2694 lineedit->releaseKeyboard();
2699 if (currentMapEditor())
2703 QString s=currentMapEditor()->getHeading(ok,p);
2707 #if defined(Q_OS_MACX)
2708 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2709 QDialog *d =new QDialog(NULL);
2710 QLineEdit *le=new QLineEdit (d);
2711 d->setWindowFlags (Qt::FramelessWindowHint);
2712 d->setGeometry(p.x(),p.y(),200,25);
2713 le->resize (d->size());
2716 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2717 d->activateWindow();
2719 currentMapEditor()->setHeading (le->text());
2721 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2722 lineedit->setGeometry(p.x(),p.y(),200,25);
2723 lineedit->setText(s);
2724 lineedit->setCursorPosition(1);
2725 lineedit->selectAll();
2727 lineedit->grabKeyboard();
2728 lineedit->setFocus();
2730 editSel=currentMapEditor()->getSelectString();
2738 void Main::openVymLinks(const QStringList &vl)
2740 for (int j=0; j<vl.size(); j++)
2742 // compare path with already loaded maps
2746 for (i=0;i<=tabWidget->count() -1;i++)
2748 me=(MapEditor*)tabWidget->page(i);
2749 if (vl.at(j)==me->getFilePath() )
2758 if (!QFile(vl.at(j)).exists() )
2759 QMessageBox::critical( 0, tr( "Critical Error" ),
2760 tr("Couldn't open map %1").arg(vl.at(j)));
2763 fileLoad (vl.at(j), NewMap);
2764 tabWidget->setCurrentPage (tabWidget->count()-1);
2767 // Go to tab containing the map
2768 tabWidget->setCurrentPage (index);
2772 void Main::editOpenVymLink()
2774 if (currentMapEditor())
2777 vl.append(currentMapEditor()->getVymLink());
2782 void Main::editOpenMultipleVymLinks()
2784 QString currentVymLink;
2785 if (currentMapEditor())
2787 QStringList vl=currentMapEditor()->getVymLinks();
2792 void Main::editVymLink()
2794 if (currentMapEditor())
2795 currentMapEditor()->editVymLink();
2798 void Main::editDeleteVymLink()
2800 if (currentMapEditor())
2801 currentMapEditor()->deleteVymLink();
2804 void Main::editToggleHideExport()
2806 if (currentMapEditor())
2807 currentMapEditor()->toggleHideExport();
2810 void Main::editMapInfo()
2812 if (currentMapEditor())
2813 currentMapEditor()->editMapInfo();
2816 void Main::editMoveUp()
2818 if (currentMapEditor())
2819 currentMapEditor()->moveBranchUp();
2822 void Main::editMoveDown()
2824 if (currentMapEditor())
2825 currentMapEditor()->moveBranchDown();
2828 void Main::editToggleScroll()
2830 if (currentMapEditor())
2832 currentMapEditor()->toggleScroll();
2836 void Main::editUnScrollAll()
2838 if (currentMapEditor())
2840 currentMapEditor()->unScrollAll();
2844 void Main::editNewBranch()
2847 if (!lineedit->isVisible() && currentMapEditor())
2848 currentMapEditor()->addNewBranch(0);
2851 void Main::editNewBranchHere()
2853 if (currentMapEditor())
2854 currentMapEditor()->addNewBranchHere();
2857 void Main::editNewBranchAbove()
2859 if (currentMapEditor())
2860 currentMapEditor()->addNewBranch(-1);
2863 void Main::editNewBranchBelow()
2865 if (currentMapEditor())
2866 currentMapEditor()->addNewBranch(1);
2869 void Main::editImportAdd()
2871 fileLoad (ImportAdd);
2874 void Main::editImportReplace()
2876 fileLoad (ImportReplace);
2879 void Main::editSaveBranch()
2881 fileSaveAs (PartOfMap);
2884 void Main::editRemoveBranchKeepChilds()
2886 if (currentMapEditor())
2887 currentMapEditor()->removeBranchKeepChilds();
2890 void Main::editRemoveChilds()
2892 if (currentMapEditor())
2893 currentMapEditor()->removeChilds();
2896 void Main::editDeleteSelection()
2898 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2899 currentMapEditor()->deleteSelection();
2902 void Main::editUpperBranch()
2904 if (currentMapEditor())
2905 currentMapEditor()->selectUpperBranch();
2908 void Main::editLowerBranch()
2910 if (currentMapEditor())
2911 currentMapEditor()->selectLowerBranch();
2914 void Main::editLeftBranch()
2916 if (currentMapEditor())
2917 currentMapEditor()->selectLeftBranch();
2920 void Main::editRightBranch()
2922 if (currentMapEditor())
2923 currentMapEditor()->selectRightBranch();
2926 void Main::editFirstBranch()
2928 if (currentMapEditor())
2929 currentMapEditor()->selectFirstBranch();
2932 void Main::editLastBranch()
2934 if (currentMapEditor())
2935 currentMapEditor()->selectLastBranch();
2938 void Main::editLoadImage()
2940 if (currentMapEditor())
2941 currentMapEditor()->loadFloatImage();
2944 void Main::editSaveImage()
2946 if (currentMapEditor())
2947 currentMapEditor()->saveFloatImage();
2950 void Main::editFollowXLink(QAction *a)
2953 if (currentMapEditor())
2954 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2957 void Main::editEditXLink(QAction *a)
2959 if (currentMapEditor())
2960 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2963 void Main::formatSelectColor()
2965 if (currentMapEditor())
2967 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2968 if ( !col.isValid() ) return;
2969 currentMapEditor()->setColor( col );
2970 colorChanged( col );
2974 void Main::formatPickColor()
2976 if (currentMapEditor())
2977 colorChanged( currentMapEditor()->pickColor() );
2980 void Main::colorChanged(QColor c)
2982 QPixmap pix( 16, 16 );
2984 actionFormatColor->setIconSet( pix );
2987 void Main::formatColorItem()
2989 if (currentMapEditor())
2990 currentMapEditor()->colorItem();
2993 void Main::formatColorBranch()
2995 if (currentMapEditor())
2996 currentMapEditor()->colorBranch();
2999 void Main::formatLinkStyleLine()
3001 if (currentMapEditor())
3002 currentMapEditor()->setLinkStyle(StyleLine);
3005 void Main::formatLinkStyleParabel()
3007 if (currentMapEditor())
3008 currentMapEditor()->setLinkStyle(StyleParabel);
3011 void Main::formatLinkStylePolyLine()
3013 if (currentMapEditor())
3014 currentMapEditor()->setLinkStyle(StylePolyLine);
3017 void Main::formatLinkStylePolyParabel()
3019 if (currentMapEditor())
3020 currentMapEditor()->setLinkStyle(StylePolyParabel);
3023 void Main::formatSelectBackColor()
3025 if (currentMapEditor())
3026 currentMapEditor()->selectBackgroundColor();
3029 void Main::formatSelectLinkColor()
3031 if (currentMapEditor())
3032 currentMapEditor()->selectLinkColor();
3035 void Main::formatToggleLinkColorHint()
3037 currentMapEditor()->toggleLinkColorHint();
3040 void Main::formatFrameNone()
3042 if (currentMapEditor())
3043 currentMapEditor()->setFrame(NoFrame);
3046 void Main::formatFrameRectangle()
3048 if (currentMapEditor())
3049 currentMapEditor()->setFrame(Rectangle);
3052 void Main::formatIncludeImagesVer()
3054 if (currentMapEditor())
3055 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3058 void Main::formatIncludeImagesHor()
3060 if (currentMapEditor())
3061 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3064 void Main::formatHideLinkUnselected()
3066 if (currentMapEditor())
3067 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3070 void Main::viewZoomReset()
3072 if (currentMapEditor())
3076 currentMapEditor()->setWorldMatrix( m );
3077 currentMapEditor()->setViewCenter();
3078 currentMapEditor()->adjustCanvasSize();
3082 void Main::viewZoomIn()
3084 if (currentMapEditor())
3086 QMatrix m = currentMapEditor()->worldMatrix();
3087 m.scale( 1.25, 1.25 );
3088 currentMapEditor()->setWorldMatrix( m );
3089 currentMapEditor()->setViewCenter();
3090 currentMapEditor()->adjustCanvasSize();
3094 void Main::viewZoomOut()
3096 if (currentMapEditor())
3098 QMatrix m = currentMapEditor()->worldMatrix();
3099 m.scale( 0.8, 0.8 );
3100 currentMapEditor()->setWorldMatrix( m );
3101 currentMapEditor()->setViewCenter();
3102 currentMapEditor()->adjustCanvasSize();
3106 void Main::modModeColor()
3110 void Main::modModeLink()
3114 bool Main::settingsPDF()
3116 // Default browser is set in constructor
3118 QString text = QInputDialog::getText(
3119 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3120 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3122 settings.setValue ("/mainwindow/readerPDF",text);
3127 bool Main::settingsURL()
3129 // Default browser is set in constructor
3131 QString text = QInputDialog::getText(
3132 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3133 settings.value("/mainwindow/readerURL").toString()
3136 settings.setValue ("/mainwindow/readerURL",text);
3140 void Main::settingsToggleDelKey()
3142 if (actionSettingsUseDelKey->isOn())
3144 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3147 actionEditDelete->setAccel (QKeySequence (""));
3151 void Main::windowToggleNoteEditor()
3153 if (textEditor->showWithMain() )
3154 windowHideNoteEditor();
3156 windowShowNoteEditor();
3159 void Main::windowToggleHistory()
3161 if (currentMapEditor())
3162 currentMapEditor()->toggleHistoryWindow();
3165 void Main::updateNoteFlag()
3167 if (currentMapEditor())
3168 currentMapEditor()->updateNoteFlag();
3171 void Main::windowShowNoteEditor()
3173 textEditor->setShowWithMain(true);
3175 actionViewToggleNoteEditor->setOn (true);
3178 void Main::windowHideNoteEditor()
3180 textEditor->setShowWithMain(false);
3182 actionViewToggleNoteEditor->setOn (false);
3185 void Main::windowNextEditor()
3187 if (tabWidget->currentPageIndex() < tabWidget->count())
3188 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3191 void Main::windowPreviousEditor()
3193 if (tabWidget->currentPageIndex() >0)
3194 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3197 void Main::standardFlagChanged()
3199 currentMapEditor()->toggleStandardFlag(sender()->name());
3202 void Main::testFunction()
3204 currentMapEditor()->testFunction();
3207 void Main::helpDoc()
3210 #if defined(Q_OS_MACX)
3211 docpath="./vym.app/Contents/vym.pdf";
3213 // default path in SUSE LINUX
3214 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3217 if (!QFile (docpath).exists() )
3219 // relative path for easy testing in tarball
3220 docpath="doc/vym.pdf";
3221 if (!QFile (docpath).exists() )
3223 // relative path for testing while still writing vym.tex
3224 docpath="doc/tex/vym.pdf";
3225 if (!QFile (docpath).exists() )
3227 // Try yet another one for Knoppix
3228 docpath="/usr/share/doc/packages/vym/vym.pdf";
3229 if (!QFile (docpath).exists() )
3231 QMessageBox::critical(0,
3232 tr("Critcal error"),
3233 tr("Couldn't find the documentation\n"
3234 "vym.pdf in various places."));
3241 Process *pdfProc = new Process();
3242 pdfProc->clearArguments();
3243 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3244 pdfProc->addArgument( docpath);
3246 if ( !pdfProc->start() )
3249 QMessageBox::warning(0,
3251 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3252 tr("Please use Settings->")+tr("Set application to open PDF files"));
3259 void Main::helpAbout()
3262 ad.setName ("aboutwindow");
3263 ad.setMinimumSize(500,500);
3264 ad.resize (QSize (500,500));
3268 void Main::helpAboutQT()
3270 QMessageBox::aboutQt( this, "Qt Application Example" );