Runs basically on Mac now. Undo debug output still enabled
1 #include "mainwindow.h"
7 #include <q3filedialog.h>
9 #include <QColorDialog>
11 #include <QInputDialog>
15 #include <QCloseEvent>
18 #include <Q3PopupMenu>
19 #include <QActionGroup>
21 //#include <qdatetime.h> // for random seed
27 #include "aboutdialog.h"
28 #include "exportoofiledialog.h"
30 #include "exportxhtmldialog.h"
32 #include "flagrowobj.h"
34 #include "mapeditor.h"
39 #include "showtextdialog.h"
40 #include "texteditor.h"
43 extern TextEditor *textEditor;
44 extern Main *mainWindow;
45 extern QString tmpVymDir;
46 extern QString clipboardDir;
47 extern bool clipboardEmpty;
48 extern int statusbarTime;
49 extern FlagRowObj* standardFlagsDefault;
50 extern FlagRowObj* systemFlagsDefault;
52 extern Q3PtrList <QAction> actionListBranches;
54 extern QAction* actionFileSave;
55 extern QAction* actionFilePrint;
56 extern QAction* actionEditUndo;
57 extern QAction* actionEditRedo;
58 extern QAction *actionEditCopy;
59 extern QAction *actionEditCut;
60 extern QAction *actionEditPaste;
61 extern QAction *actionEditMoveUp;
62 extern QAction *actionEditMoveDown;
63 extern QAction *actionEditToggleScroll;
64 extern QAction* actionEditOpenURL;
65 extern QAction* actionEditOpenURLTab;
66 extern QAction* actionEditOpenMultipleURLTabs;
67 extern QAction* actionEditURL;
68 extern QAction* actionEditHeading2URL;
69 extern QAction* actionEditBugzilla2URL;
70 extern QAction* actionEditFATE2URL;
71 extern QAction *actionEditOpenVymLink;
72 extern QAction *actionEditVymLink;
73 extern QAction *actionEditDeleteVymLink;
74 extern QAction *actionEditToggleHideExport;
75 extern QAction *actionEditMapInfo;
76 extern QAction *actionEditHeading;
77 extern QAction *actionEditDelete;
78 extern QAction *actionEditAddBranch;
79 extern QAction *actionEditAddBranchHere;
80 extern QAction *actionEditAddBranchAbove;
81 extern QAction *actionEditAddBranchBelow;
82 extern QAction *actionEditRemoveBranchKeepChilds;
83 extern QAction *actionEditRemoveChilds;
84 extern QAction *actionEditImportAdd;
85 extern QAction *actionEditImportReplace;
86 extern QAction *actionEditSaveBranch;
87 extern QAction *actionEditSelectFirst;
88 extern QAction *actionEditSelectLast;
89 extern QAction *actionEditLoadImage;
91 extern QAction* actionFormatColor;
92 extern QAction* actionFormatPickColor;
93 extern QAction* actionFormatColorBranch;
94 extern QAction* actionFormatColorSubtree;
95 extern QAction* actionFormatLinkColorHint;
96 extern QAction* actionFormatBackColor;
97 extern QAction* actionFormatLinkColor;
98 extern QAction *actionFormatIncludeImagesVer;
99 extern QAction *actionFormatIncludeImagesHor;
101 extern QActionGroup* actionGroupModModes;
102 extern QAction* actionModModeColor;
103 extern QAction* actionModModeLink;
104 extern QAction* actionModModeCopy;
106 extern QActionGroup *actionGroupFormatFrameTypes;
107 extern QAction *actionFormatFrameNone;
108 extern QAction *actionFormatFrameRectangle;
110 extern QActionGroup *actionGroupFormatLinkStyles;
111 extern QAction *actionFormatLinkStyleLine;
112 extern QAction *actionFormatLinkStyleParabel;
113 extern QAction *actionFormatLinkStylePolyLine;
114 extern QAction *actionFormatLinkStylePolyParabel;
115 extern QAction *actionFormatHideLinkUnselected;
117 extern QAction *actionViewToggleNoteEditor;
118 extern QAction *actionViewToggleHistoryWindow;
120 extern QAction* actionSettingsAutoedit;
121 extern QAction* actionSettingsAutoselectHeading;
122 extern QAction* actionSettingsAutoselectHeading;
123 extern QAction* actionSettingsAutoselectText;
124 extern QAction* actionSettingsPasteNewHeading;
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* branchLinksContextMenuEdit;
133 extern QMenu* branchLinksContextMenuFollow;
134 extern QMenu* floatimageContextMenu;
135 extern QMenu* canvasContextMenu;
136 extern QMenu* fileLastMapsMenu;
137 extern QMenu* fileImportMenu;
138 extern QMenu* fileExportMenu;
141 extern Settings settings;
142 extern Options options;
143 extern ImageIO imageIO;
145 extern QDir vymBaseDir;
146 extern QDir lastImageDir;
147 extern QDir lastFileDir;
148 extern QString iconPath;
149 extern QString flagsPath;
151 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
152 QMainWindow(parent,name,f)
156 setCaption ("VYM - View Your Mind");
158 // Load window settings
159 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
160 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
163 // Create unique temporary directory
164 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
166 // Create direcctory for clipboard
167 clipboardDir=tmpVymDir+"/clipboard";
168 QDir d(clipboardDir);
169 d.mkdir (clipboardDir,true);
170 makeSubDirs (clipboardDir);
175 // FIXME not used currently
176 // Set random seed (random used for object IDs)
177 // QTime t = QTime::currentTime(); // set random seed
178 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
181 // Initialize some settings, which are platform dependant
184 // application to open URLs
185 p="/mainwindow/readerURL";
186 #if defined(Q_OS_LINUX)
187 s=settings.value (p,"konqueror").toString();
189 #if defined(Q_OS_MACX)
190 s=settings.value (p,"/usr/bin/open").toString();
192 s=settings.value (p,"mozilla");
195 settings.setValue( p,s);
197 // application to open PDFs
198 p="/mainwindow/readerPDF";
199 #if defined(Q_OS_LINUX)
200 s=settings.value (p,"acroread").toString();
202 #if defined(Q_OS_MACX)
203 s=settings.value (p,"/usr/bin/open").toString();
205 s=settings.value (p,"acroread").toString();
208 settings.setValue( p,s);
213 // Create tab widget which holds the maps
214 tabWidget= new QTabWidget (this);
215 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
216 this, SLOT( editorChanged( QWidget * ) ) );
218 lineedit=new QLineEdit (this);
221 setCentralWidget(tabWidget);
225 setupFormatActions();
229 setupSettingsActions();
231 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
236 restoreState (settings.value("/mainwindow/state",0).toByteArray());
238 // Initialize Find window
239 findWindow=new FindWindow(NULL,"findwindow");
240 connect (findWindow, SIGNAL( findButton(QString) ),
241 this, SLOT(editFind(QString) ) );
242 connect (findWindow, SIGNAL( somethingChanged() ),
243 this, SLOT(editFindChanged() ) );
245 // Connect TextEditor, so that we can update flags if text changes
246 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
254 settings.setValue ( "/mainwindow/geometry/size", size() );
255 settings.setValue ( "/mainwindow/geometry/pos", pos() );
257 settings.setValue ("/mainwindow/state",saveState(0));
259 settings.setValue( "/version/version", __VYM_VERSION );
260 settings.setValue( "/version/builddate", __BUILD_DATE );
262 settings.setValue( "/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
263 settings.setValue( "/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
264 settings.setValue( "/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
265 settings.setValue( "/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
266 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
267 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
268 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
271 int maps=lastMaps.count();
272 settings.setValue( "/lastMaps/number",maps );
273 for (int i=1;i<=maps;i++)
275 s=QString("/lastMaps/map-%1").arg(i);
276 if (!s.isEmpty() && i<=maxLastMaps)
277 settings.setValue (s, lastMaps.at(i-1));
281 // To make the texteditor save its settings, call the destructor
284 // Remove temporary directory
285 removeDir (QDir(tmpVymDir));
288 void Main::loadCmdLine()
290 /* TODO draw some kind of splashscreen while loading...
296 QStringList flist=options.getFileList();
297 QStringList::Iterator it=flist.begin();
299 while (it !=flist.end() )
301 fileLoad (*it, NewMap);
307 void Main::statusMessage(const QString &s)
309 statusBar()->message (s);
312 void Main::closeEvent (QCloseEvent* )
318 void Main::setupFileActions()
320 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
321 QToolBar *tb = addToolBar( tr ("&Map") );
324 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
325 a->setStatusTip ( tr( "New map","File menu" ) );
326 a->setShortcut ( Qt::CTRL + Qt::Key_N );
328 fileMenu->addAction (a);
329 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
331 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
332 a->setStatusTip (tr( "Open","File menu" ) );
333 a->setShortcut ( Qt::CTRL + Qt::Key_O );
335 fileMenu->addAction (a);
336 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
338 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
339 fileMenu->addSeparator();
341 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
342 a->setStatusTip ( tr( "Save" ));
343 a->setShortcut (Qt::CTRL + Qt::Key_S );
345 fileMenu->addAction (a);
346 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
349 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
350 a->setStatusTip (tr( "Save &As" ) );
351 fileMenu->addAction (a);
352 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
354 fileMenu->addSeparator();
356 fileImportMenu = fileMenu->addMenu (tr("Import"));
358 a = new QAction(tr("KDE Bookmarks"), this);
359 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
360 a->addTo (fileImportMenu);
361 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
363 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
365 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
366 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
367 a->addTo (fileImportMenu);
368 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
371 a = new QAction("Mind Manager...",this);
372 a->setStatusTip ( tr( "Import")+" Mind Manager" );
373 fileImportMenu->addAction (a);
374 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
376 a = new QAction( tr( "Import Dir"+QString("...") ), this);
377 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
378 fileImportMenu->addAction (a);
379 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
381 fileExportMenu = fileMenu->addMenu (tr("Export"));
383 a = new QAction( tr("Image")+QString("..."), this);
384 a->setStatusTip( tr( "Export map as image" ));
385 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
386 fileExportMenu->addAction (a);
388 a = new QAction( "Open Office"+QString("..."), this);
389 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
391 fileExportMenu->addAction (a);
393 a = new QAction( "Webpage (XHTML)...",this );
394 a->setShortcut (Qt::ALT + Qt::Key_X);
395 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
396 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
397 fileExportMenu->addAction (a);
399 a = new QAction( "Text (ASCII)...", this);
400 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
401 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
402 fileExportMenu->addAction (a);
404 a = new QAction( tr("KDE Bookmarks"), this);
405 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
406 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
407 fileExportMenu->addAction (a);
409 a = new QAction( "Taskjuggler...", this );
410 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
411 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
412 fileExportMenu->addAction (a);
414 a = new QAction( "LaTeX...", this);
415 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
416 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
417 fileExportMenu->addAction (a);
419 a = new QAction( "XML..." , this );
420 a->setStatusTip (tr( "Export as")+" XML");
421 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
422 fileExportMenu->addAction (a);
424 fileMenu->addSeparator();
426 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
427 a->setStatusTip ( tr( "Print" ) );
428 a->setShortcut (Qt::CTRL + Qt::Key_P );
430 fileMenu->addAction (a);
431 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
434 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
435 a->setStatusTip (tr( "Close Map" ) );
436 a->setShortcut (Qt::ALT + Qt::Key_C );
437 fileMenu->addAction (a);
438 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
440 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
441 a->setStatusTip ( tr( "Exit")+" "+__VYM );
442 a->setShortcut (Qt::CTRL + Qt::Key_Q );
443 fileMenu->addAction (a);
444 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
449 void Main::setupEditActions()
451 QToolBar *tb = addToolBar( tr ("&Actions") );
452 tb->setLabel( "Edit Actions" );
453 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
457 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
458 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
459 a->setStatusTip (tr( "Undo" ) );
460 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
461 a->setEnabled (false);
463 editMenu->addAction (a);
466 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
467 a->setStatusTip (tr( "Redo" ));
468 a->setShortcut (Qt::CTRL + Qt::Key_Y );
470 editMenu->addAction (a);
471 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
474 editMenu->addSeparator();
475 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
476 a->setStatusTip ( tr( "Copy" ) );
477 a->setShortcut (Qt::CTRL + Qt::Key_C );
478 a->setEnabled (false);
480 editMenu->addAction (a);
481 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
484 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
485 a->setStatusTip ( tr( "Cut" ) );
486 a->setShortcut (Qt::CTRL + Qt::Key_X );
487 a->setEnabled (false);
489 editMenu->addAction (a);
491 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
493 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
494 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
495 a->setStatusTip ( tr( "Paste" ) );
496 a->setShortcut ( Qt::CTRL + Qt::Key_V );
497 a->setEnabled (false);
499 editMenu->addAction (a);
502 // Shortcuts to modify heading:
503 a = new QAction(tr( "Edit heading" ),this);
504 a->setStatusTip ( tr( "edit Heading" ));
505 a->setShortcut ( Qt::Key_Enter);
506 // a->setShortcutContext (Qt::WindowShortcut);
508 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
509 actionListBranches.append(a);
510 a = new QAction( tr( "Edit heading" ), this);
511 a->setStatusTip (tr( "edit Heading" ));
512 a->setShortcut (Qt::Key_Return );
513 //a->setShortcutContext (Qt::WindowShortcut);
515 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
516 actionListBranches.append(a);
517 editMenu->addAction (a);
519 a = new QAction( tr( "Edit heading" ), this);
520 a->setStatusTip (tr( "edit Heading" ));
521 a->setShortcut ( Qt::Key_F2 );
522 a->setShortcutContext (Qt::WindowShortcut);
524 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
525 actionListBranches.append(a);
527 // Shortcut to delete selection
528 a = new QAction( tr( "Delete Selection" ),this);
529 a->setStatusTip (tr( "Delete Selection" ));
530 a->setShortcut ( Qt::Key_Delete);
531 a->setShortcutContext (Qt::WindowShortcut);
533 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
536 // Shortcut to add branch
537 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
538 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
539 alt->setShortcut (Qt::Key_A);
540 alt->setShortcutContext (Qt::WindowShortcut);
542 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
543 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
544 a->setStatusTip ( tr( "Add a branch as child of selection" ));
545 a->setShortcut (Qt::Key_Insert);
546 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
547 actionListBranches.append(a);
548 #if defined (Q_OS_MACX)
549 // In OSX show different shortcut in menues, the keys work indepently always
550 actionEditAddBranch=alt;
552 actionEditAddBranch=a;
554 editMenu->addAction (actionEditAddBranch);
555 tb->addAction (actionEditAddBranch);
558 // Add branch by inserting it at selection
559 a = new QAction(tr( "Add branch (insert)" ), this);
560 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
561 a->setShortcut (Qt::ALT + Qt::Key_Insert );
562 a->setShortcutContext (Qt::WindowShortcut);
564 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
565 a->setEnabled (false);
566 actionListBranches.append(a);
567 actionEditAddBranchHere=a;
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_A );
571 a->setShortcutContext (Qt::WindowShortcut);
573 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
574 actionListBranches.append(a);
577 a = new QAction(tr( "Add branch above" ), this);
578 a->setStatusTip ( tr( "Add a branch above selection" ));
579 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
580 a->setShortcutContext (Qt::WindowShortcut);
582 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
583 a->setEnabled (false);
584 actionListBranches.append(a);
585 actionEditAddBranchAbove=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_A );
589 a->setShortcutContext (Qt::WindowShortcut);
591 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
592 actionListBranches.append(a);
595 a = new QAction(tr( "Add branch below" ), this);
596 a->setStatusTip ( tr( "Add a branch below selection" ));
597 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
598 a->setShortcutContext (Qt::WindowShortcut);
600 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
601 a->setEnabled (false);
602 actionListBranches.append(a);
603 actionEditAddBranchBelow=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_A );
607 a->setShortcutContext (Qt::WindowShortcut);
609 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
610 actionListBranches.append(a);
612 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
613 a->setStatusTip ( tr( "Move branch up" ) );
614 a->setShortcut (Qt::Key_PageUp );
615 a->setEnabled (false);
617 editMenu->addAction (a);
618 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
621 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
622 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
623 a->setStatusTip (tr( "Move branch down" ) );
624 a->setShortcut ( Qt::Key_PageDown );
625 a->setEnabled (false);
627 editMenu->addAction (a);
628 actionEditMoveDown=a;
631 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
632 a->setShortcut ( Qt::Key_ScrollLock );
633 a->setStatusTip (tr( "Scroll branch" ) );
634 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
635 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
636 alt->setShortcut ( Qt::Key_S );
637 alt->setStatusTip (tr( "Scroll branch" ));
638 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
639 #if defined(Q_OS_MACX)
640 actionEditToggleScroll=alt;
642 actionEditToggleScroll=a;
644 actionEditToggleScroll->setEnabled (false);
645 actionEditToggleScroll->setToggleAction(true);
646 tb->addAction (actionEditToggleScroll);
647 editMenu->addAction ( actionEditToggleScroll);
648 editMenu->addAction (actionEditToggleScroll);
649 actionListBranches.append(actionEditToggleScroll);
651 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
652 a->setStatusTip (tr( "Unscroll all" ));
653 editMenu->addAction (a);
654 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
656 editMenu->addSeparator();
658 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
659 a->setStatusTip (tr( "Find" ) );
660 a->setShortcut (Qt::CTRL + Qt::Key_F );
661 editMenu->addAction (a);
662 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
664 editMenu->addSeparator();
666 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
667 a->setShortcut (Qt::CTRL + Qt::Key_U );
668 a->setShortcut (tr( "Open URL" ));
671 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
674 a = new QAction( tr( "Open URL in new tab" ), this);
675 a->setStatusTip (tr( "Open URL in new tab" ));
676 a->setShortcut (Qt::CTRL+Qt::Key_U );
678 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
679 actionEditOpenURLTab=a;
681 a = new QAction( tr( "Open all URLs in subtree" ), this);
682 a->setStatusTip (tr( "Open all URLs in subtree" ));
683 a->setShortcut (Qt::CTRL+Qt::Key_U );
685 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
686 actionEditOpenMultipleURLTabs=a;
688 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
689 a->setStatusTip ( tr( "Edit URL" ) );
690 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
691 //a->setShortcut ( Qt::Key_U );
692 a->setShortcutContext (Qt::WindowShortcut);
693 actionListBranches.append(a);
695 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
698 a = new QAction( tr( "Use heading for URL" ), this);
699 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
700 a->setEnabled (false);
701 actionListBranches.append(a);
702 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
703 actionEditHeading2URL=a;
705 a = new QAction(tr( "Create URL to Bugzilla" ), this);
706 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
707 a->setEnabled (false);
708 actionListBranches.append(a);
709 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
710 actionEditBugzilla2URL=a;
712 a = new QAction(tr( "Create URL to FATE" ), this);
713 a->setStatusTip ( tr( "Create URL to FATE" ));
714 a->setEnabled (false);
715 actionListBranches.append(a);
716 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
717 actionEditFATE2URL=a;
719 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
720 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
722 a->setEnabled (false);
723 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
724 actionEditOpenVymLink=a;
726 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
727 a->setEnabled (false);
728 a->setStatusTip ( tr( "Edit link to another vym map" ));
729 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
730 actionListBranches.append(a);
733 a = new QAction(tr( "Delete vym link" ),this);
734 a->setStatusTip ( tr( "Delete link to another vym map" ));
735 a->setEnabled (false);
736 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
737 actionEditDeleteVymLink=a;
739 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
740 a->setStatusTip ( tr( "Hide object in exports" ) );
741 a->setShortcut (Qt::Key_H );
742 a->setToggleAction(true);
744 a->setEnabled (false);
745 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
746 actionEditToggleHideExport=a;
748 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
749 a->setStatusTip ( tr( "Edit Map Info" ));
750 a->setEnabled (true);
751 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
754 editMenu->addSeparator();
756 // Import at selection (adding to selection)
757 a = new QAction( tr( "Add map (insert)" ),this);
758 a->setStatusTip (tr( "Add map at selection" ));
759 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
760 a->setEnabled (false);
761 actionListBranches.append(a);
762 actionEditImportAdd=a;
764 // Import at selection (replacing selection)
765 a = new QAction( tr( "Add map (replace)" ), this);
766 a->setStatusTip (tr( "Replace selection with map" ));
767 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
768 a->setEnabled (false);
769 actionListBranches.append(a);
770 actionEditImportReplace=a;
773 a = new QAction( tr( "Save selection" ), this);
774 a->setStatusTip (tr( "Save selection" ));
775 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
776 a->setEnabled (false);
777 actionListBranches.append(a);
778 actionEditSaveBranch=a;
780 // Only remove branch, not its childs
781 a = new QAction(tr( "Remove only branch " ), this);
782 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
783 a->setShortcut (Qt::ALT + Qt::Key_Delete );
784 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
785 a->setEnabled (false);
786 actionListBranches.append(a);
787 actionEditRemoveBranchKeepChilds=a;
789 // Only remove childs of a branch
790 a = new QAction( tr( "Remove childs" ), this);
791 a->setStatusTip (tr( "Remove childs of branch" ));
792 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
793 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
794 a->setEnabled (false);
795 actionListBranches.append(a);
796 actionEditRemoveChilds=a;
798 // Shortcuts for navigating with cursor:
799 a = new QAction(tr( "Select upper branch" ), this);
800 a->setStatusTip ( tr( "Select upper branch" ));
801 a->setShortcut (Qt::Key_Up );
802 a->setShortcutContext (Qt::WindowShortcut);
804 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
805 a = new QAction( tr( "Select lower branch" ),this);
806 a->setStatusTip (tr( "Select lower branch" ));
807 a->setShortcut ( Qt::Key_Down );
808 a->setShortcutContext (Qt::WindowShortcut);
810 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
811 a = new QAction(tr( "Select left branch" ), this);
812 a->setStatusTip ( tr( "Select left branch" ));
813 a->setShortcut (Qt::Key_Left );
814 a->setShortcutContext (Qt::WindowShortcut);
816 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
817 a = new QAction( tr( "Select child branch" ), this);
818 a->setStatusTip (tr( "Select right branch" ));
819 a->setShortcut (Qt::Key_Right);
820 a->setShortcutContext (Qt::WindowShortcut);
822 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
823 a = new QAction( tr( "Select first branch" ), this);
824 a->setStatusTip (tr( "Select first branch" ));
825 a->setShortcut (Qt::Key_Home );
826 a->setShortcutContext (Qt::WindowShortcut);
828 a->setEnabled (false);
829 editMenu->addAction (a);
830 actionListBranches.append(a);
831 actionEditSelectFirst=a;
832 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
833 a = new QAction( tr( "Select last branch" ),this);
834 a->setStatusTip (tr( "Select last branch" ));
835 a->setShortcut ( Qt::Key_End );
836 a->setShortcutContext (Qt::WindowShortcut);
838 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
839 a->setEnabled (false);
840 editMenu->addAction (a);
841 actionListBranches.append(a);
842 actionEditSelectLast=a;
844 a = new QAction( tr( "Add Image" )+QString("..."), this);
845 a->setStatusTip (tr( "Add Image" ));
846 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
847 actionEditLoadImage=a;
852 void Main::setupFormatActions()
854 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
856 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
859 pix.fill (Qt::black);
860 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
861 a->setStatusTip ( tr( "Set Color" ));
862 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
864 formatMenu->addAction (a);
866 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
867 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
868 a->setShortcut (Qt::CTRL + Qt::Key_K );
869 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
870 a->setEnabled (false);
872 formatMenu->addAction (a);
873 actionListBranches.append(a);
874 actionFormatPickColor=a;
876 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
877 a->setStatusTip ( tr( "Color branch" ) );
878 a->setShortcut (Qt::CTRL + Qt::Key_I);
879 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
880 a->setEnabled (false);
882 formatMenu->addAction (a);
883 actionListBranches.append(a);
884 actionFormatColorBranch=a;
886 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
887 a->setStatusTip ( tr( "Color Subtree" ));
888 a->setShortcut (Qt::CTRL + Qt::Key_T);
889 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
890 a->setEnabled (false);
891 formatMenu->addAction (a);
893 actionListBranches.append(a);
894 actionFormatColorSubtree=a;
896 formatMenu->addSeparator();
897 actionGroupFormatLinkStyles=new QActionGroup ( this);
898 actionGroupFormatLinkStyles->setExclusive (true);
899 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
900 a->setStatusTip (tr( "Line" ));
901 a->setToggleAction(true);
902 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
903 formatMenu->addAction (a);
904 actionFormatLinkStyleLine=a;
905 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
906 a->setStatusTip (tr( "Line" ));
907 a->setToggleAction(true);
908 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
909 formatMenu->addAction (a);
910 actionFormatLinkStyleParabel=a;
911 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
912 a->setStatusTip (tr( "PolyLine" ));
913 a->setToggleAction(true);
914 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
915 formatMenu->addAction (a);
916 actionFormatLinkStylePolyLine=a;
917 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
918 a->setStatusTip (tr( "PolyParabel" ) );
919 a->setToggleAction(true);
920 a->setChecked (true);
921 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
922 formatMenu->addAction (a);
923 actionFormatLinkStylePolyParabel=a;
925 actionGroupFormatFrameTypes=new QActionGroup ( this);
926 actionGroupFormatFrameTypes->setExclusive (true);
927 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
928 a->setStatusTip (tr("No Frame"));
929 a->setToggleAction(true);
930 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
931 actionFormatFrameNone=a;
932 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
933 a->setStatusTip (tr( "Rectangle" ));
934 a->setToggleAction(true);
935 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
936 actionFormatFrameRectangle=a;
938 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
939 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
940 a->setToggleAction(true);
941 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
942 actionFormatIncludeImagesVer=a;
944 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
945 a->setStatusTip ( tr ("Include left and right position of images into branch"));
946 a->setToggleAction(true);
947 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
948 actionFormatIncludeImagesHor=a;
950 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
951 a->setStatusTip (tr( "Hide link" ));
952 a->setToggleAction(true);
953 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
954 actionFormatHideLinkUnselected=a;
956 formatMenu->addSeparator();
957 a= new QAction( tr( "&Use color of heading for link" ), this);
958 a->setStatusTip (tr( "Use same color for links and headings" ));
959 a->setToggleAction(true);
960 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
961 formatMenu->addAction (a);
962 actionFormatLinkColorHint=a;
964 pix.fill (Qt::white);
965 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
966 a->setStatusTip (tr( "Set Link Color" ));
967 formatMenu->addAction (a);
968 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
969 actionFormatLinkColor=a;
971 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
972 a->setStatusTip (tr( "Set Background Color" ));
973 formatMenu->addAction (a);
974 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
975 actionFormatBackColor=a;
979 void Main::setupViewActions()
981 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
982 tb->setLabel( "View Actions" );
983 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
986 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
987 a->setStatusTip ( tr( "Zoom reset" ) );
988 a->setShortcut (Qt::CTRL + Qt::Key_0 );
990 viewMenu->addAction (a);
991 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
993 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
994 a->setStatusTip (tr( "Zoom in" ));
995 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
997 viewMenu->addAction (a);
998 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1000 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
1001 a->setStatusTip (tr( "Zoom out" ));
1002 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1004 viewMenu->addAction (a);
1005 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1008 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1009 a->setStatusTip ( tr( "Show Note Editor" ));
1010 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1011 a->setToggleAction(true);
1012 if (textEditor->showWithMain())
1017 viewMenu->addAction (a);
1018 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1019 actionViewToggleNoteEditor=a;
1021 a = new QAction( tr( "Show history window" ),this );
1022 a->setStatusTip ( tr( "Show history window" ));
1023 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1024 a->setToggleAction(false);
1025 viewMenu->addAction (a);
1026 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1027 actionViewToggleHistoryWindow=a;
1029 a = new QAction(tr( "Next Window" ), this);
1030 a->setStatusTip ( tr( "&Next Window" ) );
1031 a->setShortcut (Qt::ALT + Qt::Key_N );
1032 viewMenu->addAction (a);
1033 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1035 a = new QAction (tr( "Previous Window" ), this );
1036 a->setStatusTip (tr( "&Previous Window" ));
1037 a->setShortcut (Qt::ALT + Qt::Key_P );
1038 viewMenu->addAction (a);
1039 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1043 void Main::setupModeActions()
1045 //QPopupMenu *menu = new QPopupMenu( this );
1046 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1048 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1050 actionGroupModModes=new QActionGroup ( this);
1051 actionGroupModModes->setExclusive (true);
1052 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1053 a->setShortcut (Qt::Key_J);
1054 a->setStatusTip ( tr( "Use modifier to color branches" ));
1055 a->setToggleAction(true);
1058 actionModModeColor=a;
1060 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1061 a->setShortcut( Qt::Key_K);
1062 a->setStatusTip( tr( "Use modifier to copy" ));
1063 a->setToggleAction(true);
1065 actionModModeCopy=a;
1067 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1068 a->setShortcut (Qt::Key_L);
1069 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1070 a->setToggleAction(true);
1072 actionModModeLink=a;
1076 void Main::setupFlagActions()
1078 // Create System Flags
1079 systemFlagsDefault = new FlagRowObj ();
1080 systemFlagsDefault->setVisibility (false);
1081 systemFlagsDefault->setName ("systemFlagsDef");
1083 FlagObj *fo = new FlagObj ();
1084 fo->load(QPixmap(flagsPath+"flag-note.png"));
1085 fo->setName("note");
1086 fo->setToolTip(tr("Note","Systemflag"));
1087 systemFlagsDefault->addFlag (fo); // makes deep copy
1089 fo->load(QPixmap(flagsPath+"flag-url.png"));
1091 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1092 systemFlagsDefault->addFlag (fo);
1094 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1095 fo->setName("vymLink");
1096 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1097 systemFlagsDefault->addFlag (fo);
1099 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1100 fo->setName("scrolledright");
1101 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1102 systemFlagsDefault->addFlag (fo);
1104 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1105 fo->setName("tmpUnscrolledright");
1106 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1107 systemFlagsDefault->addFlag (fo);
1109 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1110 fo->setName("hideInExport");
1111 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1112 systemFlagsDefault->addFlag (fo);
1114 // Create Standard Flags
1115 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1116 //FIXMEtoolbars.add (tb);
1118 standardFlagsDefault = new FlagRowObj ();
1119 standardFlagsDefault->setVisibility (false);
1120 standardFlagsDefault->setName ("standardFlagsDef");
1121 standardFlagsDefault->setToolBar (tb);
1122 tb->setObjectName ("standardFlagTB");
1124 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1125 fo->setName ("exclamationmark");
1126 fo->setGroup("standard-mark");
1127 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1130 a->setCheckable(true);
1131 a->setObjectName(fo->getName());
1132 a->setToolTip(tr("Take care!","Standardflag"));
1133 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1134 standardFlagsDefault->addFlag (fo); // makes deep copy
1136 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1137 fo->setName("questionmark");
1138 fo->setGroup("standard-mark");
1139 a=new QAction (fo->getPixmap(),fo->getName(),this);
1142 a->setCheckable(true);
1143 a->setObjectName(fo->getName());
1144 a->setToolTip(tr("Really?","Standardflag"));
1145 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1146 standardFlagsDefault->addFlag (fo);
1148 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1149 fo->setName("hook-green");
1150 fo->setGroup("standard-hook");
1151 a=new QAction (fo->getPixmap(),fo->getName(),this);
1154 a->setCheckable(true);
1155 a->setObjectName(fo->getName());
1156 a->setToolTip(tr("ok!","Standardflag"));
1157 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1158 standardFlagsDefault->addFlag (fo);
1160 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1161 fo->setName("cross-red");
1162 fo->setGroup("standard-hook");
1163 a=new QAction (fo->getPixmap(),fo->getName(),this);
1166 a->setCheckable(true);
1167 a->setObjectName(fo->getName());
1168 a->setToolTip(tr("Not ok!","Standardflag"));
1169 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1170 standardFlagsDefault->addFlag (fo);
1172 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1173 fo->setName("stopsign");
1174 a=new QAction (fo->getPixmap(),fo->getName(),this);
1177 a->setCheckable(true);
1178 a->setObjectName(fo->getName());
1179 a->setToolTip(tr("This won't work!","Standardflag"));
1180 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1181 standardFlagsDefault->addFlag (fo);
1183 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1184 fo->setName("smiley-good");
1185 fo->setGroup("standard-smiley");
1186 a=new QAction (fo->getPixmap(),fo->getName(),this);
1189 a->setCheckable(true);
1190 a->setObjectName(fo->getName());
1191 a->setToolTip(tr("Good","Standardflag"));
1192 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1193 standardFlagsDefault->addFlag (fo);
1195 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1196 fo->setName("smiley-sad");
1197 fo->setGroup("standard-smiley");
1198 a=new QAction (fo->getPixmap(),fo->getName(),this);
1201 a->setCheckable(true);
1202 a->setObjectName(fo->getName());
1203 a->setToolTip(tr("Bad","Standardflag"));
1204 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1205 standardFlagsDefault->addFlag (fo);
1207 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1208 // Original omg.png (in KDE emoticons)
1209 fo->setName("smiley-omg");
1210 fo->setGroup("standard-smiley");
1211 a=new QAction (fo->getPixmap(),fo->getName(),this);
1214 a->setCheckable(true);
1215 a->setObjectName(fo->getName());
1216 a->setToolTip(tr("Oh no!","Standardflag"));
1217 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1218 standardFlagsDefault->addFlag (fo);
1220 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1221 fo->setName("clock");
1222 a=new QAction (fo->getPixmap(),fo->getName(),this);
1225 a->setCheckable(true);
1226 a->setObjectName(fo->getName());
1227 a->setToolTip(tr("Time critical","Standardflag"));
1228 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1229 standardFlagsDefault->addFlag (fo);
1231 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1232 fo->setName("phone");
1233 a=new QAction (fo->getPixmap(),fo->getName(),this);
1236 a->setCheckable(true);
1237 a->setObjectName(fo->getName());
1238 a->setToolTip(tr("Call...","Standardflag"));
1239 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1240 standardFlagsDefault->addFlag (fo);
1242 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1243 fo->setName("lamp");
1244 a=new QAction (fo->getPixmap(),fo->getName(),this);
1247 a->setCheckable(true);
1248 a->setObjectName(fo->getName());
1249 a->setToolTip(tr("Idea!","Standardflag"));
1250 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1251 standardFlagsDefault->addFlag (fo);
1253 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1254 fo->setName("arrow-up");
1255 fo->setGroup("standard-arrow");
1256 a=new QAction (fo->getPixmap(),fo->getName(),this);
1259 a->setCheckable(true);
1260 a->setObjectName(fo->getName());
1261 a->setToolTip(tr("Important","Standardflag"));
1262 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1263 standardFlagsDefault->addFlag (fo);
1265 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1266 fo->setName("arrow-down");
1267 fo->setGroup("standard-arrow");
1268 a=new QAction (fo->getPixmap(),fo->getName(),this);
1271 a->setCheckable(true);
1272 a->setObjectName(fo->getName());
1273 a->setToolTip(tr("Unimportant","Standardflag"));
1274 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1275 standardFlagsDefault->addFlag (fo);
1277 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1278 fo->setName("2arrow-up");
1279 fo->setGroup("standard-arrow");
1280 a=new QAction (fo->getPixmap(),fo->getName(),this);
1283 a->setCheckable(true);
1284 a->setObjectName(fo->getName());
1285 a->setToolTip(tr("Very important!","Standardflag"));
1286 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1287 standardFlagsDefault->addFlag (fo);
1289 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1290 fo->setName("2arrow-down");
1291 fo->setGroup("standard-arrow");
1292 a=new QAction (fo->getPixmap(),fo->getName(),this);
1295 a->setCheckable(true);
1296 a->setObjectName(fo->getName());
1297 a->setToolTip(tr("Very unimportant!","Standardflag"));
1298 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1299 standardFlagsDefault->addFlag (fo);
1301 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1302 fo->setName("thumb-up");
1303 fo->setGroup("standard-thumb");
1304 a=new QAction (fo->getPixmap(),fo->getName(),this);
1307 a->setCheckable(true);
1308 a->setObjectName(fo->getName());
1309 a->setToolTip(tr("I like this","Standardflag"));
1310 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1311 standardFlagsDefault->addFlag (fo);
1313 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1314 fo->setName("thumb-down");
1315 fo->setGroup("standard-thumb");
1316 a=new QAction (fo->getPixmap(),fo->getName(),this);
1319 a->setCheckable(true);
1320 a->setObjectName(fo->getName());
1321 a->setToolTip(tr("I do not like this","Standardflag"));
1322 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1323 standardFlagsDefault->addFlag (fo);
1325 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1326 fo->setName("rose");
1327 a=new QAction (fo->getPixmap(),fo->getName(),this);
1330 a->setCheckable(true);
1331 a->setObjectName(fo->getName());
1332 a->setToolTip(tr("Rose","Standardflag"));
1333 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1334 standardFlagsDefault->addFlag (fo);
1336 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1337 fo->setName("heart");
1338 a=new QAction (fo->getPixmap(),fo->getName(),this);
1340 a->setCheckable(true);
1341 a->setObjectName(fo->getName());
1342 a->setToolTip(tr("I just love... ","Standardflag"));
1343 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1344 standardFlagsDefault->addFlag (fo);
1346 fo->load(QPixmap(flagsPath+"flag-present.png"));
1347 fo->setName("present");
1348 a=new QAction (fo->getPixmap(),fo->getName(),this);
1351 a->setCheckable(true);
1352 a->setObjectName(fo->getName());
1353 a->setToolTip(tr("Surprise!","Standardflag"));
1354 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1355 standardFlagsDefault->addFlag (fo);
1357 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1358 fo->setName("flash");
1359 a=new QAction (fo->getPixmap(),fo->getName(),this);
1362 a->setCheckable(true);
1363 a->setObjectName(fo->getName());
1364 a->setToolTip(tr("Dangerous","Standardflag"));
1365 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1366 standardFlagsDefault->addFlag (fo);
1368 fo->load(QPixmap(flagsPath+"flag-info.png"));
1369 // Original: xsldbg_output.png
1370 fo->setName("info");
1371 a=new QAction (fo->getPixmap(),fo->getName(),this);
1374 a->setCheckable(true);
1375 a->setObjectName(fo->getName());
1376 a->setToolTip(tr("Info","Standardflag"));
1377 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1378 standardFlagsDefault->addFlag (fo);
1380 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1381 // Original khelpcenter.png
1382 fo->setName("lifebelt");
1383 a=new QAction (fo->getPixmap(),fo->getName(),this);
1386 a->setCheckable(true);
1387 a->setObjectName(fo->getName());
1388 a->setToolTip(tr("This will help","Standardflag"));
1389 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1390 standardFlagsDefault->addFlag (fo);
1396 void Main::setupSettingsActions()
1398 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1402 a = new QAction( tr( "Set application to open pdf files"), this);
1403 a->setStatusTip ( tr( "Set application to open pdf files"));
1404 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1405 settingsMenu->addAction (a);
1407 a = new QAction( tr( "Set application to open external links"), this);
1408 a->setStatusTip( tr( "Set application to open external links"));
1409 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1410 settingsMenu->addAction (a);
1412 settingsMenu->addSeparator();
1413 a = new QAction( tr( "Edit branch after adding it" ), this );
1414 a->setStatusTip( tr( "Edit branch after adding it" ));
1415 a->setToggleAction(true);
1416 a->setOn ( settings.value ("/mapeditor/editmode/autoedit",true).toBool());
1417 settingsMenu->addAction (a);
1418 actionSettingsAutoedit=a;
1420 a= new QAction( tr( "Select branch after adding it" ), this );
1421 a->setStatusTip( tr( "Select branch after adding it" ));
1422 a->setToggleAction(true);
1423 a->setOn ( settings.value ("/mapeditor/editmode/autoselect",false).toBool() );
1424 settingsMenu->addAction (a);
1425 actionSettingsAutoselectHeading=a;
1427 a= new QAction(tr( "Select existing heading" ), this);
1428 a->setStatusTip( tr( "Select heading before editing" ));
1429 a->setToggleAction(true);
1430 a->setOn ( settings.value ("/mapeditor/editmode/autoselectexistingtext",true).toBool() );
1431 settingsMenu->addAction (a);
1432 actionSettingsAutoselectText=a;
1434 a= new QAction(tr( "pasting into new branch" ), this );
1435 a->setStatusTip( tr( "Pasting into new branch" ));
1436 a->setToggleAction(true);
1437 a->setOn ( settings.value ("/mapeditor/editmode/newheadingisempty",true).toBool() );
1438 settingsMenu->addAction (a);
1439 actionSettingsPasteNewHeading=a;
1441 a= new QAction( tr( "Delete key" ), this);
1442 a->setStatusTip( tr( "Delete key for deleting branches" ));
1443 a->setToggleAction(true);
1444 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1445 settingsMenu->addAction (a);
1446 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1447 actionSettingsUseDelKey=a;
1449 a= new QAction( tr( "Exclusive flags" ), this);
1450 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1451 a->setToggleAction(true);
1452 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1453 settingsMenu->addAction (a);
1454 actionSettingsUseFlagGroups=a;
1456 a= new QAction( tr( "Use hide flags" ), this);
1457 a->setStatusTip( tr( "Use hide flag during exports " ));
1458 a->setToggleAction(true);
1459 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1460 settingsMenu->addAction (a);
1461 actionSettingsUseHideExport=a;
1465 void Main::setupTestActions()
1467 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1470 a = new QAction( tr( "test flag" ), this);
1471 a->setStatusTip( tr( "Call test function" ));
1472 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1473 testMenu->addAction (a);
1477 void Main::setupHelpActions()
1479 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1482 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1483 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1484 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1485 helpMenu->addAction (a);
1487 a = new QAction( tr( "About VYM" ), this);
1488 a->setStatusTip( tr( "About VYM")+" "__VYM);
1489 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1490 helpMenu->addAction (a);
1492 a = new QAction( tr( "About QT" ), this);
1493 a->setStatusTip( tr( "Information about QT toolkit" ));
1494 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1495 helpMenu->addAction (a);
1499 void Main::setupContextMenus()
1503 // Context Menu for branch or mapcenter
1504 branchContextMenu =new QMenu (this);
1507 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1508 branchAddContextMenu->addAction (actionEditPaste );
1509 branchAddContextMenu->addAction ( actionEditAddBranch );
1510 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1511 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1512 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1513 branchAddContextMenu->addSeparator();
1514 branchAddContextMenu->addAction ( actionEditLoadImage);
1515 branchAddContextMenu->addSeparator();
1516 branchAddContextMenu->addAction ( actionEditImportAdd );
1517 branchAddContextMenu->addAction ( actionEditImportReplace );
1520 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1521 branchRemoveContextMenu->addAction (actionEditCut);
1522 branchRemoveContextMenu->addAction ( actionEditDelete );
1523 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1524 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1527 actionEditSaveBranch->addTo( branchContextMenu );
1529 branchContextMenu->addSeparator();
1530 branchContextMenu->addAction ( actionEditOpenURL );
1531 branchContextMenu->addAction ( actionEditOpenURLTab );
1532 branchContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1533 branchContextMenu->addAction ( actionEditURL );
1534 branchContextMenu->addAction ( actionEditHeading2URL );
1535 branchContextMenu->addAction ( actionEditBugzilla2URL );
1536 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1538 branchContextMenu->addAction ( actionEditFATE2URL );
1540 branchContextMenu->addSeparator();
1541 branchContextMenu->addAction ( actionEditOpenVymLink );
1542 branchContextMenu->addAction ( actionEditVymLink );
1543 branchContextMenu->addAction ( actionEditDeleteVymLink );
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 // Context Menu for links in a branch menu
1555 // This will be populated "on demand" in MapEditor::updateActions
1556 branchContextMenu->addSeparator();
1557 branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1558 branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1559 connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1560 connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1562 // Context menu for floatimage
1563 floatimageContextMenu =new QMenu (this);
1564 a= new QAction (tr ("Save image"),this);
1565 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1566 floatimageContextMenu->addAction (a);
1568 floatimageContextMenu->addSeparator();
1569 actionEditCopy->addTo( floatimageContextMenu );
1570 actionEditCut->addTo( floatimageContextMenu );
1572 floatimageContextMenu->addSeparator();
1573 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1576 // Context menu for canvas
1577 canvasContextMenu =new QMenu (this);
1578 actionEditMapInfo->addTo( canvasContextMenu );
1579 canvasContextMenu->insertSeparator();
1580 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1581 canvasContextMenu->insertSeparator();
1582 actionFormatLinkColorHint->addTo( canvasContextMenu );
1583 actionFormatLinkColor->addTo( canvasContextMenu );
1584 actionFormatBackColor->addTo( canvasContextMenu );
1586 // Menu for last opened files
1587 // Read settings initially
1589 int j=settings.readNumEntry( "/lastMaps/number",0);
1590 for (int i=1;i<=j;i++)
1592 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1593 if (!s.isEmpty() && j<=maxLastMaps)
1596 setupLastMapsMenu();
1597 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1600 void Main::setupLastMapsMenu()
1602 // Remove double entries
1603 QStringList::Iterator it=lastMaps.begin();
1604 QStringList::Iterator jt;
1605 while (it!=lastMaps.end() )
1609 while (jt!=lastMaps.end() )
1612 jt=lastMaps.remove(jt);
1619 // Limit length of list to maxLastMaps
1620 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1622 // build Menu from lastMaps string list
1623 fileLastMapsMenu->clear();
1624 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1625 fileLastMapsMenu->addAction (*it );
1628 void Main::hideEvent (QHideEvent * )
1630 if (!textEditor->isMinimized() ) textEditor->hide();
1633 void Main::showEvent (QShowEvent * )
1635 if (textEditor->showWithMain()) textEditor->showNormal();
1638 bool Main::reallyWriteDirectory(const QString &dir)
1640 QStringList eList = QDir(dir).entryList();
1641 if (eList.first() ==".") eList.pop_front(); // remove "."
1642 if (eList.first() =="..") eList.pop_front(); // remove "."
1643 if (!eList.isEmpty())
1645 QMessageBox mb( __VYM,
1646 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1647 QMessageBox::Warning,
1649 QMessageBox::Cancel | QMessageBox::Default,
1650 QMessageBox::QMessageBox::NoButton );
1652 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1653 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1656 case QMessageBox::Yes:
1659 case QMessageBox::Cancel:
1667 QString Main::browseDirectory (const QString &caption)
1669 Q3FileDialog fd(this,caption);
1670 fd.setMode (Q3FileDialog::DirectoryOnly);
1671 fd.setCaption(__VYM " - "+caption);
1674 if ( fd.exec() == QDialog::Accepted )
1675 return fd.selectedFile();
1680 MapEditor* Main::currentMapEditor() const
1682 if ( tabWidget->currentPage() &&
1683 tabWidget->currentPage()->inherits( "MapEditor" ) )
1684 return (MapEditor*)tabWidget->currentPage();
1688 //TODO not used now, maybe use this for overview window later
1689 void Main::newView()
1691 // Open a new view... have it delete when closed.
1692 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1693 qApp->setMainWidget(m);
1695 qApp->setMainWidget(0);
1698 void Main::editorChanged(QWidget *)
1700 // Unselect all possibly selected objects
1701 // (Important to update note editor)
1704 for (i=0;i<=tabWidget->count() -1;i++)
1707 me=(MapEditor*)tabWidget->page(i);
1710 currentMapEditor()->reselect();
1712 // Update actions to in menus and toolbars according to editor
1713 currentMapEditor()->updateActions();
1716 void Main::fileNew()
1718 QString fn="unnamed";
1719 MapEditor* medit = new MapEditor ( NULL,true);
1720 tabWidget->addTab (medit,fn);
1721 tabWidget->showPage(medit);
1722 medit->viewport()->setFocus();
1723 // For the very first map we do not have flagrows yet...
1724 medit->select("mc:");
1727 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1729 ErrorCode err=success;
1731 // fn is usually the archive, mapfile the file after uncompressing
1734 // Make fn absolute (needed for unzip)
1735 fn=QDir (fn).absPath();
1741 // Check, if map is already loaded
1743 while (i<=tabWidget->count() -1)
1745 me=(MapEditor*)tabWidget->page(i);
1746 if (me->getFilePath() == fn)
1748 // Already there, ask for confirmation
1749 QMessageBox mb( __VYM,
1750 tr("The map %1\nis already opened."
1751 "Opening the same map in multiple editors may lead \n"
1752 "to confusion when finishing working with vym."
1753 "Do you want to").arg(fn),
1754 QMessageBox::Warning,
1755 QMessageBox::Yes | QMessageBox::Default,
1756 QMessageBox::Cancel | QMessageBox::Escape,
1757 QMessageBox::NoButton);
1758 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1759 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1762 case QMessageBox::Yes:
1764 i=tabWidget->count();
1766 case QMessageBox::Cancel:
1778 if ( !fn.isEmpty() )
1780 me = currentMapEditor();
1781 int tabIndex=tabWidget->currentPageIndex();
1782 // Check first, if mapeditor exists
1783 // If it is not default AND we want a new map,
1784 // create a new mapeditor in a new tab
1785 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1787 me= new MapEditor ( NULL,true);
1788 tabWidget->addTab (me,fn);
1789 tabIndex=tabWidget->indexOf (me);
1790 tabWidget->setCurrentPage (tabIndex);
1793 // Check, if file exists (important for creating new files
1794 // from command line
1795 if (!QFile(fn).exists() )
1797 QMessageBox mb( __VYM,
1798 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1799 QMessageBox::Question,
1801 QMessageBox::Cancel | QMessageBox::Default,
1802 QMessageBox::NoButton );
1804 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1805 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1808 case QMessageBox::Yes:
1810 currentMapEditor()->setFilePath(fn);
1811 tabWidget->setTabLabel (currentMapEditor(),
1812 currentMapEditor()->getFileName() );
1813 statusBar()->message( "Created " + fn , statusbarTime );
1816 case QMessageBox::Cancel:
1817 // don't create new map
1818 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1825 //tabWidget->currentPage() won't be NULL here, because of above...
1826 tabWidget->showPage(me);
1827 me->viewport()->setFocus();
1829 // Create temporary directory for packing
1830 char tmpdir1[]="/tmp/vym-XXXXXX";
1831 QString tmpMapDir=mkdtemp(tmpdir1);
1833 // Try to unzip file
1834 err=unzipDir (tmpMapDir,fn);
1838 me->setZipped(false);
1841 me->setZipped(true);
1843 // Look for mapname.xml
1844 mapfile= fn.left(fn.findRev(".",-1,true));
1845 mapfile=mapfile.section( '/', -1 );
1846 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1847 if (!file.exists() )
1849 // mapname.xml does not exist, well,
1850 // maybe some renamed the mapname.vym file...
1851 // Try to find any .xml in the toplevel
1852 // directory of the .vym file
1853 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1854 if (flist.count()==1)
1856 // Only one entry, take this one
1857 mapfile=tmpMapDir + "/"+flist.first();
1860 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1861 *it=tmpMapDir + "/" + *it;
1862 // TODO Multiple entries, load all (but only the first one into this ME)
1863 //mainWindow->fileLoadFromTmp (flist);
1864 //returnCode=1; // Silently forget this attempt to load
1865 qWarning ("MainWindow::load (fn) multimap found...");
1868 if (flist.isEmpty() )
1870 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1871 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1874 } //file doesn't exist
1876 mapfile=file.name();
1881 // Save existing filename in case we import
1882 QString fn_org=me->getFilePath();
1884 // Finally load map into mapEditor
1885 me->setFilePath (mapfile,fn);
1886 err=me->load(mapfile,lmode);
1888 // Restore old (maybe empty) filepath, if this is an import
1890 me->setFilePath (fn_org);
1893 // Finally check for errors and go home
1896 if (lmode==NewMap) fileCloseMap();
1897 statusBar()->message( "Could not load " + fn, statusbarTime );
1902 me->setFilePath (fn);
1903 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1904 if (fn.left(9)!="/tmp/vym-")
1906 // Only append to lastMaps if not loaded from a tmpDir
1907 // e.g. imported bookmarks are in a tmpDir
1908 lastMaps.prepend(me->getFilePath() );
1909 setupLastMapsMenu();
1911 actionFilePrint->setEnabled (true);
1913 statusBar()->message( "Loaded " + fn, statusbarTime );
1917 removeDir (QDir(tmpMapDir));
1923 void Main::fileLoad(const LoadMode &lmode)
1925 Q3FileDialog *fd=new Q3FileDialog( this);
1926 fd->setDir (lastFileDir);
1927 fd->setMode (Q3FileDialog::ExistingFiles);
1928 fd->addFilter ("XML (*.xml)");
1929 fd->addFilter ("VYM map (*.vym *.vyp)");
1933 fd->setCaption(tr("Load vym map"));
1936 fd->setCaption(tr("Import: Add vym map to selection"));
1939 fd->setCaption(tr("Import: Replace selection with vym map"));
1945 if ( fd->exec() == QDialog::Accepted )
1947 lastFileDir=fd->dirPath();
1948 QStringList flist = fd->selectedFiles();
1949 QStringList::Iterator it = flist.begin();
1950 while( it != flist.end() )
1953 fileLoad(*it, lmode);
1960 void Main::fileLoad()
1965 void Main::fileLoadLast(QAction *a)
1967 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1970 void Main::fileSave(const SaveMode &savemode)
1972 // tmp dir for zipping
1976 ErrorCode err=success;
1978 QString safeFilePath;
1980 bool saveZipped=currentMapEditor()->saveZipped();
1982 MapEditor * me=currentMapEditor();
1985 QString fn=me->getFilePath();
1986 // filename=unnamed, filepath="" in constructor...
1987 if ( !fn.isEmpty() )
1989 // We have a filepath, go on saving
1990 // First remove existing file, we
1991 // don't want to add to old zip archives
1995 QMessageBox::warning( 0, tr( "Save Error" ),
1996 fn+ tr("\ncould not be removed before saving"));
1998 // Look, if we should zip the data:
2001 QMessageBox mb( __VYM,
2002 tr("The map %1\ndid not use the compressed "
2003 "vym file format.\nWriting it uncompressed will also write images \n"
2004 "and flags and thus may overwrite files in the "
2005 "given directory\n\nDo you want to write the map").arg(fn),
2006 QMessageBox::Warning,
2007 QMessageBox::Yes | QMessageBox::Default,
2009 QMessageBox::Cancel | QMessageBox::Escape);
2010 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2011 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2012 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2015 case QMessageBox::Yes:
2016 // save compressed (default file format)
2019 case QMessageBox::No:
2020 // save uncompressed
2023 case QMessageBox::Cancel:
2032 char tmpdir1[]="/tmp/vym-XXXXXX";
2033 tmpMapDir=mkdtemp(tmpdir1);
2035 safeFilePath=me->getFilePath();
2036 me->setFilePath (tmpMapDir+"/"+
2037 me->getMapName()+ ".xml",
2039 me->save (savemode);
2040 me->setFilePath (safeFilePath);
2042 zipDir (tmpMapDir,fn);
2047 safeFilePath=me->getFilePath();
2048 me->setFilePath (fn, safeFilePath);
2049 me->save (savemode);
2050 me->setFilePath (safeFilePath);
2052 } // filepath available
2055 // We have no filepath yet,
2056 // call fileSaveAs() now, this will call fileSave()
2058 fileSaveAs(savemode);
2062 if (saveZipped && !tmpMapDir.isEmpty())
2064 removeDir (QDir(tmpMapDir));
2068 statusBar()->message(
2069 tr("Saved %1").arg(me->getFilePath()),
2071 lastMaps.prepend(me->getFilePath() );
2072 setupLastMapsMenu();
2074 statusBar()->message(
2075 tr("Couldn't save ").arg(me->getFilePath()),
2079 void Main::fileSave()
2081 fileSave (CompleteMap);
2084 void Main::fileSaveAs(const SaveMode& savemode)
2088 if (currentMapEditor())
2090 if (savemode==CompleteMap)
2091 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2093 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2094 if ( !fn.isEmpty() )
2096 // Check for existing file
2097 if (QFile (fn).exists())
2099 QMessageBox mb( __VYM,
2100 tr("The file %1\nexists already. Do you want to").arg(fn),
2101 QMessageBox::Warning,
2102 QMessageBox::Yes | QMessageBox::Default,
2103 QMessageBox::Cancel | QMessageBox::Escape,
2104 QMessageBox::NoButton);
2105 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2106 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2109 case QMessageBox::Yes:
2112 case QMessageBox::Cancel:
2119 // New file, add extension to filename, if missing
2120 // This is always .vym or .vyp, depending on savemode
2121 if (savemode==CompleteMap)
2123 if (!fn.contains (".vym") && !fn.contains (".xml"))
2127 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2136 currentMapEditor()->setFilePath(fn);
2140 if (savemode==CompleteMap)
2141 tabWidget->setTabLabel (currentMapEditor(),
2142 currentMapEditor()->getFileName() );
2148 void Main::fileSaveAs()
2150 fileSaveAs (CompleteMap);
2153 void Main::fileImportKDEBookmarks()
2155 ImportKDEBookmarks im;
2157 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2158 currentMapEditor()->setFilePath ("");
2161 void Main::fileImportFirefoxBookmarks()
2163 Q3FileDialog *fd=new Q3FileDialog( this);
2164 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2165 fd->setMode (Q3FileDialog::ExistingFiles);
2166 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2167 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2170 if ( fd->exec() == QDialog::Accepted )
2172 ImportFirefoxBookmarks im;
2173 QStringList flist = fd->selectedFiles();
2174 QStringList::Iterator it = flist.begin();
2175 while( it != flist.end() )
2178 if (im.transform() &&
2179 success==fileLoad (im.getTransformedFile(),NewMap) &&
2180 currentMapEditor() )
2181 currentMapEditor()->setFilePath ("");
2188 void Main::fileImportMM()
2192 Q3FileDialog *fd=new Q3FileDialog( this);
2193 fd->setDir (lastFileDir);
2194 fd->setMode (Q3FileDialog::ExistingFiles);
2195 fd->addFilter ("Mind Manager (*.mmap)");
2196 fd->setCaption(tr("Import")+" "+"Mind Manager");
2199 if ( fd->exec() == QDialog::Accepted )
2201 lastFileDir=fd->dirPath();
2202 QStringList flist = fd->selectedFiles();
2203 QStringList::Iterator it = flist.begin();
2204 while( it != flist.end() )
2207 if (im.transform() &&
2208 success==fileLoad (im.getTransformedFile(),NewMap) &&
2209 currentMapEditor() )
2210 currentMapEditor()->setFilePath ("");
2219 void Main::fileImportDir()
2221 if (currentMapEditor())
2222 currentMapEditor()->importDir();
2225 void Main::fileExportXML()
2227 if (currentMapEditor())
2229 QString dir=browseDirectory(tr("Export XML to directory"));
2230 if (dir !="" && reallyWriteDirectory(dir) )
2231 currentMapEditor()->exportXML(dir);
2236 void Main::fileExportXHTML()
2238 MapEditor *me=currentMapEditor();
2242 ExportXHTMLDialog dia(this);
2243 dia.setFilePath (me->getFilePath() );
2244 dia.setMapName (me->getMapName() );
2247 if (dia.exec()==QDialog::Accepted)
2249 QString dir=dia.getDir();
2250 // Check, if warnings should be used before overwriting
2251 // the output directory
2254 ok=reallyWriteDirectory(dir);
2260 me->exportXML (dia.getDir() );
2261 dia.doExport(me->getMapName() );
2262 if (dia.hasChanged())
2269 void Main::fileExportImage()
2271 MapEditor *me=currentMapEditor();
2275 QFileDialog *fd=new QFileDialog (this);
2276 fd->setCaption (tr("Export map as image"));
2277 fd->setFileMode(QFileDialog::AnyFile);
2278 fd->setFilters (imageIO.getFilters() );
2279 fd->setDirectory (lastImageDir);
2282 fl=fd->selectedFiles();
2283 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2284 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2289 void Main::fileExportASCII()
2291 MapEditor *me=currentMapEditor();
2295 ex.setMapCenter(me->getMapCenter());
2296 ex.addFilter ("TXT (*.txt)");
2297 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2298 if (ex.execDialog() )
2300 me->setExportMode(true);
2302 me->setExportMode(false);
2307 void Main::fileExportLaTeX()
2309 MapEditor *me=currentMapEditor();
2313 ex.setMapCenter(me->getMapCenter());
2314 ex.addFilter ("Tex (*.tex)");
2315 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2316 if (ex.execDialog() )
2318 me->setExportMode(true);
2320 me->setExportMode(false);
2325 void Main::fileExportKDEBookmarks()
2327 ExportKDEBookmarks ex;
2328 MapEditor *me=currentMapEditor();
2331 ex.setMapCenter (me->getMapCenter() );
2336 void Main::fileExportTaskjuggler()
2338 ExportTaskjuggler ex;
2339 MapEditor *me=currentMapEditor();
2342 ex.setMapCenter (me->getMapCenter() );
2343 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2344 ex.addFilter ("Taskjuggler (*.tjp)");
2345 if (ex.execDialog() )
2347 me->setExportMode(true);
2349 me->setExportMode(false);
2354 void Main::fileExportOOPresentation()
2356 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2357 // TODO add preview in dialog
2358 //ImagePreview *p =new ImagePreview (fd);
2359 //fd->setContentsPreviewEnabled( TRUE );
2360 //fd->setContentsPreview( p, p );
2361 //fd->setPreviewMode( QFileDialog::Contents );
2362 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2363 fd->setDir (QDir().current());
2364 if (fd->foundConfig())
2368 if ( fd->exec() == QDialog::Accepted )
2370 QString fn=fd->selectedFile();
2371 //lastImageDir=fn.left(fn.findRev ("/"));
2372 if (currentMapEditor())
2373 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2377 QMessageBox::warning(0,
2379 tr("Couldn't find configuration for export to Open Office\n"));
2383 void Main::fileCloseMap()
2385 if (currentMapEditor())
2387 if (currentMapEditor()->hasChanged())
2389 QMessageBox mb( __VYM,
2390 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2391 QMessageBox::Warning,
2392 QMessageBox::Yes | QMessageBox::Default,
2394 QMessageBox::Cancel | QMessageBox::Escape );
2395 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2396 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2399 case QMessageBox::Yes:
2401 fileSave(CompleteMap);
2403 case QMessageBox::No:
2404 // close without saving
2406 case QMessageBox::Cancel:
2411 currentMapEditor()->closeMap();
2412 tabWidget->removePage(currentMapEditor());
2413 if (tabWidget->count()==0)
2414 actionFilePrint->setEnabled (false);
2418 void Main::filePrint()
2420 if (currentMapEditor())
2421 currentMapEditor()->print();
2424 void Main::fileExitVYM()
2426 // Check if one or more editors have changed
2429 for (i=0;i<=tabWidget->count() -1;i++)
2432 me=(MapEditor*)tabWidget->page(i);
2434 // If something changed, ask what to do
2435 if (me->isUnsaved())
2437 tabWidget->setCurrentPage(i);
2438 QMessageBox mb( __VYM,
2439 tr("This map is not saved yet. Do you want to"),
2440 QMessageBox::Warning,
2441 QMessageBox::Yes | QMessageBox::Default,
2443 QMessageBox::Cancel | QMessageBox::Escape );
2444 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2445 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2448 mb.setActiveWindow();
2449 switch( mb.exec() ) {
2450 case QMessageBox::Yes:
2451 // save (the changed editors) and exit
2452 fileSave(CompleteMap);
2454 case QMessageBox::No:
2455 // exit without saving
2457 case QMessageBox::Cancel:
2458 // don't save and don't exit
2462 } // loop over all MEs
2466 void Main::editUndo()
2468 if (currentMapEditor())
2469 currentMapEditor()->undo();
2472 void Main::editRedo()
2474 if (currentMapEditor())
2475 currentMapEditor()->redo();
2478 void Main::editCopy()
2480 if (currentMapEditor())
2481 currentMapEditor()->copy();
2484 void Main::editPaste()
2486 if (currentMapEditor())
2487 currentMapEditor()->paste();
2490 void Main::editCut()
2492 if (currentMapEditor())
2493 currentMapEditor()->cut();
2496 void Main::editOpenFindWindow()
2498 findWindow->popup();
2499 findWindow->raise();
2500 findWindow->setActiveWindow();
2503 void Main::editFind(QString s)
2506 BranchObj *bo=currentMapEditor()->findText(s, cs);
2509 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2512 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2513 tr("No matches found for \"%1\"").arg(s));
2517 void Main::editFindChanged()
2518 { // Notify editor, to abort the current find process
2519 currentMapEditor()->findReset();
2522 void Main::openTabs(QStringList urls)
2524 if (!urls.isEmpty())
2528 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2530 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2532 QString u=urls.takeFirst();
2533 procBrowser = new QProcess( this );
2535 procBrowser->start(browser,args);
2536 if ( !procBrowser->waitForStarted())
2538 // try to set path to browser
2539 QMessageBox::warning(0,
2541 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2542 tr("Please use Settings->")+tr("Set application to open an URL"));
2547 if (browser.contains("konqueror"))
2549 for (int i=0; i<urls.size(); i++)
2552 // Try to open new tab in existing konqueror started previously by vym
2553 p=new QProcess (this);
2555 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2556 "konqueror-mainwindow#1"<<
2559 p->start ("dcop",args);
2560 if ( !p->waitForStarted() ) success=false;
2563 QMessageBox::warning(0,
2565 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2567 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2569 for (int i=0; i<urls.size(); i++)
2571 // Try to open new tab in firefox
2572 p=new QProcess (this);
2573 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2574 p->start (browser,args);
2575 if ( !p->waitForStarted() ) success=false;
2578 QMessageBox::warning(0,
2580 tr("Couldn't start %1 to open a new tab").arg(browser));
2583 QMessageBox::warning(0,
2585 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2589 void Main::editOpenURL()
2592 if (currentMapEditor())
2594 QString url=currentMapEditor()->getURL();
2596 if (url=="") return;
2597 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2598 procBrowser = new QProcess( this );
2600 procBrowser->start(browser,args);
2601 if ( !procBrowser->waitForStarted())
2603 // try to set path to browser
2604 QMessageBox::warning(0,
2606 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2607 tr("Please use Settings->")+tr("Set application to open an URL"));
2612 void Main::editOpenURLTab()
2614 if (currentMapEditor())
2617 urls.append(currentMapEditor()->getURL());
2621 void Main::editOpenMultipleURLTabs()
2623 if (currentMapEditor())
2626 urls.append ("www.suse.de");
2627 urls.append ("www.google.de");
2628 urls.append ("www.heise.de");
2629 urls.append ("www.insilmaril.de");
2635 void Main::editURL()
2637 if (currentMapEditor())
2638 currentMapEditor()->editURL();
2641 void Main::editHeading2URL()
2643 if (currentMapEditor())
2644 currentMapEditor()->editHeading2URL();
2647 void Main::editBugzilla2URL()
2649 if (currentMapEditor())
2650 currentMapEditor()->editBugzilla2URL();
2653 void Main::editFATE2URL()
2655 if (currentMapEditor())
2656 currentMapEditor()->editFATE2URL();
2659 void Main::editHeading()
2661 if (lineedit->isVisible())
2663 if (currentMapEditor())
2664 currentMapEditor()->setHeading(lineedit->text());
2665 lineedit->releaseKeyboard();
2670 if (currentMapEditor())
2674 QString s=currentMapEditor()->getHeading(ok,p);
2678 #if defined(Q_OS_MACX)
2679 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2680 QDialog *d =new QDialog(NULL);
2681 QLineEdit *le=new QLineEdit (d);
2682 d->setWindowFlags (Qt::FramelessWindowHint);
2683 d->setGeometry(p.x(),p.y(),200,25);
2684 le->resize (d->size());
2687 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2688 d->activateWindow();
2690 currentMapEditor()->setHeading (le->text());
2692 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2693 lineedit->setGeometry(p.x(),p.y(),200,25);
2694 lineedit->setText(s);
2695 lineedit->setCursorPosition(1);
2696 lineedit->selectAll();
2698 lineedit->grabKeyboard();
2699 lineedit->setFocus();
2707 void Main::editOpenVymLink()
2709 // Get current path to map
2710 QString currentVymLink;
2711 if (currentMapEditor())
2713 currentVymLink=currentMapEditor()->getVymLink();
2714 // compare path with already loaded maps
2718 for (i=0;i<=tabWidget->count() -1;i++)
2720 me=(MapEditor*)tabWidget->page(i);
2721 if (currentVymLink==me->getFilePath() )
2730 if (!QFile(currentVymLink).exists() )
2731 QMessageBox::critical( 0, tr( "Critical Error" ),
2732 tr("Couldn't open map %1").arg(currentVymLink));
2735 fileLoad (currentVymLink, NewMap);
2736 tabWidget->setCurrentPage (tabWidget->count()-1);
2739 // Go to tab containing the map
2740 tabWidget->setCurrentPage (index);
2744 void Main::editVymLink()
2746 if (currentMapEditor())
2747 currentMapEditor()->editVymLink();
2750 void Main::editDeleteVymLink()
2752 if (currentMapEditor())
2753 currentMapEditor()->deleteVymLink();
2756 void Main::editToggleHideExport()
2758 if (currentMapEditor())
2759 currentMapEditor()->toggleHideExport();
2762 void Main::editMapInfo()
2764 if (currentMapEditor())
2765 currentMapEditor()->editMapInfo();
2768 void Main::editMoveUp()
2770 if (currentMapEditor())
2771 currentMapEditor()->moveBranchUp();
2774 void Main::editMoveDown()
2776 if (currentMapEditor())
2777 currentMapEditor()->moveBranchDown();
2780 void Main::editToggleScroll()
2782 if (currentMapEditor())
2784 currentMapEditor()->toggleScroll();
2788 void Main::editUnScrollAll()
2790 if (currentMapEditor())
2792 currentMapEditor()->unScrollAll();
2796 void Main::editNewBranch()
2799 if (!lineedit->isVisible() && currentMapEditor())
2800 currentMapEditor()->addNewBranch(0);
2803 void Main::editNewBranchHere()
2805 if (currentMapEditor())
2806 currentMapEditor()->addNewBranchHere();
2809 void Main::editNewBranchAbove()
2811 if (currentMapEditor())
2812 currentMapEditor()->addNewBranch(-1);
2815 void Main::editNewBranchBelow()
2817 if (currentMapEditor())
2818 currentMapEditor()->addNewBranch(1);
2821 void Main::editImportAdd()
2823 fileLoad (ImportAdd);
2826 void Main::editImportReplace()
2828 fileLoad (ImportReplace);
2831 void Main::editSaveBranch()
2833 fileSaveAs (PartOfMap);
2836 void Main::editRemoveBranchKeepChilds()
2838 if (currentMapEditor())
2839 currentMapEditor()->removeBranchKeepChilds();
2842 void Main::editRemoveChilds()
2844 if (currentMapEditor())
2845 currentMapEditor()->removeChilds();
2848 void Main::editDeleteSelection()
2850 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2851 currentMapEditor()->deleteSelection();
2854 void Main::editUpperBranch()
2856 if (currentMapEditor())
2857 currentMapEditor()->selectUpperBranch();
2860 void Main::editLowerBranch()
2862 if (currentMapEditor())
2863 currentMapEditor()->selectLowerBranch();
2866 void Main::editLeftBranch()
2868 if (currentMapEditor())
2869 currentMapEditor()->selectLeftBranch();
2872 void Main::editRightBranch()
2874 if (currentMapEditor())
2875 currentMapEditor()->selectRightBranch();
2878 void Main::editFirstBranch()
2880 if (currentMapEditor())
2881 currentMapEditor()->selectFirstBranch();
2884 void Main::editLastBranch()
2886 if (currentMapEditor())
2887 currentMapEditor()->selectLastBranch();
2890 void Main::editLoadImage()
2892 if (currentMapEditor())
2893 currentMapEditor()->loadFloatImage();
2896 void Main::editSaveImage()
2898 if (currentMapEditor())
2899 currentMapEditor()->saveFloatImage();
2902 void Main::editFollowXLink(QAction *a)
2905 if (currentMapEditor())
2906 currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
2909 void Main::editEditXLink(QAction *a)
2911 if (currentMapEditor())
2912 currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
2915 void Main::formatSelectColor()
2917 if (currentMapEditor())
2919 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2920 if ( !col.isValid() ) return;
2921 currentMapEditor()->setColor( col );
2922 colorChanged( col );
2926 void Main::formatPickColor()
2928 if (currentMapEditor())
2929 colorChanged( currentMapEditor()->pickColor() );
2932 void Main::colorChanged(QColor c)
2934 QPixmap pix( 16, 16 );
2936 actionFormatColor->setIconSet( pix );
2939 void Main::formatColorItem()
2941 if (currentMapEditor())
2942 currentMapEditor()->colorItem();
2945 void Main::formatColorBranch()
2947 if (currentMapEditor())
2948 currentMapEditor()->colorBranch();
2951 void Main::formatLinkStyleLine()
2953 if (currentMapEditor())
2954 currentMapEditor()->setLinkStyle(StyleLine);
2957 void Main::formatLinkStyleParabel()
2959 if (currentMapEditor())
2960 currentMapEditor()->setLinkStyle(StyleParabel);
2963 void Main::formatLinkStylePolyLine()
2965 if (currentMapEditor())
2966 currentMapEditor()->setLinkStyle(StylePolyLine);
2969 void Main::formatLinkStylePolyParabel()
2971 if (currentMapEditor())
2972 currentMapEditor()->setLinkStyle(StylePolyParabel);
2975 void Main::formatSelectBackColor()
2977 if (currentMapEditor())
2978 currentMapEditor()->selectBackgroundColor();
2981 void Main::formatSelectLinkColor()
2983 if (currentMapEditor())
2984 currentMapEditor()->selectLinkColor();
2987 void Main::formatToggleLinkColorHint()
2989 currentMapEditor()->toggleLinkColorHint();
2992 void Main::formatFrameNone()
2994 if (currentMapEditor())
2995 currentMapEditor()->setFrame(NoFrame);
2998 void Main::formatFrameRectangle()
3000 if (currentMapEditor())
3001 currentMapEditor()->setFrame(Rectangle);
3004 void Main::formatIncludeImagesVer()
3006 if (currentMapEditor())
3007 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3010 void Main::formatIncludeImagesHor()
3012 if (currentMapEditor())
3013 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3016 void Main::formatHideLinkUnselected()
3018 if (currentMapEditor())
3019 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3022 void Main::viewZoomReset()
3024 if (currentMapEditor())
3028 currentMapEditor()->setWorldMatrix( m );
3029 currentMapEditor()->setViewCenter();
3030 currentMapEditor()->adjustCanvasSize();
3034 void Main::viewZoomIn()
3036 if (currentMapEditor())
3038 QMatrix m = currentMapEditor()->worldMatrix();
3039 m.scale( 1.25, 1.25 );
3040 currentMapEditor()->setWorldMatrix( m );
3041 currentMapEditor()->setViewCenter();
3042 currentMapEditor()->adjustCanvasSize();
3046 void Main::viewZoomOut()
3048 if (currentMapEditor())
3050 QMatrix m = currentMapEditor()->worldMatrix();
3051 m.scale( 0.8, 0.8 );
3052 currentMapEditor()->setWorldMatrix( m );
3053 currentMapEditor()->setViewCenter();
3054 currentMapEditor()->adjustCanvasSize();
3058 void Main::modModeColor()
3062 void Main::modModeLink()
3066 bool Main::settingsPDF()
3068 // Default browser is set in constructor
3070 QString text = QInputDialog::getText(
3071 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3072 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3074 settings.setValue ("/mainwindow/readerPDF",text);
3079 bool Main::settingsURL()
3081 // Default browser is set in constructor
3083 QString text = QInputDialog::getText(
3084 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3085 settings.value("/mainwindow/readerURL").toString()
3088 settings.setValue ("/mainwindow/readerURL",text);
3092 void Main::settingsToggleDelKey()
3094 if (actionSettingsUseDelKey->isOn())
3096 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3099 actionEditDelete->setAccel (QKeySequence (""));
3103 void Main::windowToggleNoteEditor()
3105 if (textEditor->showWithMain() )
3106 windowHideNoteEditor();
3108 windowShowNoteEditor();
3111 void Main::windowToggleHistory()
3113 if (currentMapEditor())
3114 currentMapEditor()->toggleHistoryWindow();
3117 void Main::updateNoteFlag()
3119 if (currentMapEditor())
3120 currentMapEditor()->updateNoteFlag();
3123 void Main::windowShowNoteEditor()
3125 textEditor->setShowWithMain(true);
3127 actionViewToggleNoteEditor->setOn (true);
3130 void Main::windowHideNoteEditor()
3132 textEditor->setShowWithMain(false);
3134 actionViewToggleNoteEditor->setOn (false);
3137 void Main::windowNextEditor()
3139 if (tabWidget->currentPageIndex() < tabWidget->count())
3140 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3143 void Main::windowPreviousEditor()
3145 if (tabWidget->currentPageIndex() >0)
3146 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3149 void Main::standardFlagChanged()
3151 currentMapEditor()->toggleStandardFlag(sender()->name());
3154 void Main::testFunction()
3156 currentMapEditor()->testFunction();
3159 void Main::helpDoc()
3162 #if defined(Q_OS_MACX)
3163 docpath="./vym.app/Contents/vym.pdf";
3165 // default path in SUSE LINUX
3166 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3169 if (!QFile (docpath).exists() )
3171 // relative path for easy testing in tarball
3172 docpath="doc/vym.pdf";
3173 if (!QFile (docpath).exists() )
3175 // relative path for testing while still writing vym.tex
3176 docpath="doc/tex/vym.pdf";
3177 if (!QFile (docpath).exists() )
3179 // Try yet another one for Knoppix
3180 docpath="/usr/share/doc/packages/vym/vym.pdf";
3181 if (!QFile (docpath).exists() )
3183 QMessageBox::critical(0,
3184 tr("Critcal error"),
3185 tr("Couldn't find the documentation\n"
3186 "vym.pdf in various places."));
3193 Process *pdfProc = new Process();
3194 pdfProc->clearArguments();
3195 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3196 pdfProc->addArgument( docpath);
3198 if ( !pdfProc->start() )
3201 QMessageBox::warning(0,
3203 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3204 tr("Please use Settings->")+tr("Set application to open PDF files"));
3211 void Main::helpAbout()
3214 ad.setName ("aboutwindow");
3215 ad.setMinimumSize(500,500);
3216 ad.resize (QSize (500,500));
3220 void Main::helpAboutQT()
3222 QMessageBox::aboutQt( this, "Qt Application Example" );