undo/redo for delete BranchObj. Added calling commands in testmenu
1 #include "mainwindow.h"
5 #include <q3filedialog.h>
13 #include "aboutdialog.h"
14 #include "exportoofiledialog.h"
16 #include "exportxhtmldialog.h"
18 #include "flagrowobj.h"
19 #include "historywindow.h"
21 #include "mapeditor.h"
26 #include "texteditor.h"
29 extern TextEditor *textEditor;
30 extern Main *mainWindow;
31 extern QString tmpVymDir;
32 extern QString clipboardDir;
33 extern bool clipboardEmpty;
34 extern int statusbarTime;
35 extern FlagRowObj* standardFlagsDefault;
36 extern FlagRowObj* systemFlagsDefault;
38 QMenu* branchContextMenu;
39 QMenu* branchAddContextMenu;
40 QMenu* branchRemoveContextMenu;
41 QMenu* branchLinksContextMenu;
42 QMenu* branchXLinksContextMenuEdit;
43 QMenu* branchXLinksContextMenuFollow;
44 QMenu* floatimageContextMenu;
45 QMenu* canvasContextMenu;
46 QMenu* fileLastMapsMenu;
47 QMenu* fileImportMenu;
48 QMenu* fileExportMenu;
51 extern Settings settings;
52 extern Options options;
53 extern ImageIO imageIO;
55 extern QDir vymBaseDir;
56 extern QDir lastImageDir;
57 extern QDir lastFileDir;
58 extern QString iconPath;
59 extern QString flagsPath;
61 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
62 QMainWindow(parent,name,f)
66 setCaption ("VYM - View Your Mind");
68 // Load window settings
69 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
70 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
73 // Create unique temporary directory
75 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
78 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
82 // Create direcctory for clipboard
83 clipboardDir=tmpVymDir+"/clipboard";
85 d.mkdir (clipboardDir,true);
86 makeSubDirs (clipboardDir);
91 // FIXME not used currently
92 // Set random seed (random used for object IDs)
93 // QTime t = QTime::currentTime(); // set random seed
94 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
97 // Initialize some settings, which are platform dependant
100 // application to open URLs
101 p="/mainwindow/readerURL";
102 #if defined(Q_OS_LINUX)
103 s=settings.value (p,"konqueror").toString();
105 #if defined(Q_OS_MACX)
106 s=settings.value (p,"/usr/bin/open").toString();
108 s=settings.value (p,"mozilla");
111 settings.setValue( p,s);
113 // application to open PDFs
114 p="/mainwindow/readerPDF";
115 #if defined(Q_OS_LINUX)
116 s=settings.value (p,"acroread").toString();
118 #if defined(Q_OS_MACX)
119 s=settings.value (p,"/usr/bin/open").toString();
121 s=settings.value (p,"acroread").toString();
124 settings.setValue( p,s);
129 // Create tab widget which holds the maps
130 tabWidget= new QTabWidget (this);
131 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
132 this, SLOT( editorChanged( QWidget * ) ) );
134 lineedit=new QLineEdit (this);
137 setCentralWidget(tabWidget);
141 setupFormatActions();
145 setupSettingsActions();
147 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
152 restoreState (settings.value("/mainwindow/state",0).toByteArray());
154 // Initialize Find window
155 findWindow=new FindWindow(NULL);
156 findWindow->move (x(),y()+70);
157 connect (findWindow, SIGNAL( findButton(QString) ),
158 this, SLOT(editFind(QString) ) );
159 connect (findWindow, SIGNAL( somethingChanged() ),
160 this, SLOT(editFindChanged() ) );
162 // Connect TextEditor, so that we can update flags if text changes
163 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
164 connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions()));
172 settings.setValue ( "/mainwindow/geometry/size", size() );
173 settings.setValue ( "/mainwindow/geometry/pos", pos() );
175 settings.setValue ("/mainwindow/state",saveState(0));
177 settings.setValue( "/version/version", __VYM_VERSION );
178 settings.setValue( "/version/builddate", __BUILD_DATE );
180 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
181 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
182 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
183 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
184 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
185 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
188 int maps=lastMaps.count();
189 settings.setValue( "/lastMaps/number",maps );
190 for (int i=1;i<=maps;i++)
192 s=QString("/lastMaps/map-%1").arg(i);
193 if (!s.isEmpty() && i<=maxLastMaps)
194 settings.setValue (s, lastMaps.at(i-1));
198 // To make the texteditor save its settings, call the destructor
201 // Remove temporary directory
202 removeDir (QDir(tmpVymDir));
205 void Main::loadCmdLine()
207 /* TODO draw some kind of splashscreen while loading...
213 QStringList flist=options.getFileList();
214 QStringList::Iterator it=flist.begin();
216 while (it !=flist.end() )
218 fileLoad (*it, NewMap);
224 void Main::statusMessage(const QString &s)
226 statusBar()->message (s);
229 void Main::closeEvent (QCloseEvent* )
235 void Main::setupFileActions()
237 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
238 QToolBar *tb = addToolBar( tr ("&Map") );
239 tb->setObjectName ("mapTB");
242 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
243 a->setStatusTip ( tr( "New map","File menu" ) );
244 a->setShortcut ( Qt::CTRL + Qt::Key_N );
246 fileMenu->addAction (a);
247 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
249 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
250 a->setStatusTip (tr( "Open","File menu" ) );
251 a->setShortcut ( Qt::CTRL + Qt::Key_O );
253 fileMenu->addAction (a);
254 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
256 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
257 fileMenu->addSeparator();
259 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
260 a->setStatusTip ( tr( "Save" ));
261 a->setShortcut (Qt::CTRL + Qt::Key_S );
263 fileMenu->addAction (a);
264 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
267 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
268 a->setStatusTip (tr( "Save &As" ) );
269 fileMenu->addAction (a);
270 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
272 fileMenu->addSeparator();
274 fileImportMenu = fileMenu->addMenu (tr("Import"));
276 a = new QAction(tr("KDE Bookmarks"), this);
277 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
278 a->addTo (fileImportMenu);
279 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
281 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
283 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
284 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
285 a->addTo (fileImportMenu);
286 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
289 a = new QAction("Mind Manager...",this);
290 a->setStatusTip ( tr( "Import")+" Mind Manager" );
291 fileImportMenu->addAction (a);
292 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
294 a = new QAction( tr( "Import Dir"+QString("...") ), this);
295 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
296 fileImportMenu->addAction (a);
297 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
299 fileExportMenu = fileMenu->addMenu (tr("Export"));
301 a = new QAction( tr("Image")+QString("..."), this);
302 a->setStatusTip( tr( "Export map as image" ));
303 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
304 fileExportMenu->addAction (a);
306 a = new QAction( "Open Office"+QString("..."), this);
307 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
308 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
309 fileExportMenu->addAction (a);
311 a = new QAction( "Webpage (XHTML)...",this );
312 a->setShortcut (Qt::ALT + Qt::Key_X);
313 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
314 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
315 fileExportMenu->addAction (a);
317 a = new QAction( "Text (ASCII)...", this);
318 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
319 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
320 fileExportMenu->addAction (a);
322 a = new QAction( tr("KDE Bookmarks"), this);
323 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
324 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
325 fileExportMenu->addAction (a);
327 a = new QAction( "Taskjuggler...", this );
328 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
329 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
330 fileExportMenu->addAction (a);
332 a = new QAction( "LaTeX...", this);
333 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
334 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
335 fileExportMenu->addAction (a);
337 a = new QAction( "XML..." , this );
338 a->setStatusTip (tr( "Export as")+" XML");
339 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
340 fileExportMenu->addAction (a);
342 fileMenu->addSeparator();
344 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
345 a->setStatusTip ( tr( "Print" ) );
346 a->setShortcut (Qt::CTRL + Qt::Key_P );
348 fileMenu->addAction (a);
349 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
352 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
353 a->setStatusTip (tr( "Close Map" ) );
354 a->setShortcut (Qt::ALT + Qt::Key_C );
355 fileMenu->addAction (a);
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
358 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
359 a->setStatusTip ( tr( "Exit")+" "+__VYM );
360 a->setShortcut (Qt::CTRL + Qt::Key_Q );
361 fileMenu->addAction (a);
362 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
367 void Main::setupEditActions()
369 QToolBar *tb = addToolBar( tr ("&Actions") );
370 tb->setLabel( "Edit Actions" );
371 tb->setObjectName ("actionsTB");
372 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
376 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
377 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
378 a->setStatusTip (tr( "Undo" ) );
379 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
380 a->setEnabled (false);
382 editMenu->addAction (a);
385 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
386 a->setStatusTip (tr( "Redo" ));
387 a->setShortcut (Qt::CTRL + Qt::Key_Y );
389 editMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
393 editMenu->addSeparator();
394 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
395 a->setStatusTip ( tr( "Copy" ) );
396 a->setShortcut (Qt::CTRL + Qt::Key_C );
397 a->setEnabled (false);
399 editMenu->addAction (a);
400 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
403 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
404 a->setStatusTip ( tr( "Cut" ) );
405 a->setShortcut (Qt::CTRL + Qt::Key_X );
406 a->setEnabled (false);
408 editMenu->addAction (a);
410 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
412 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
413 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
414 a->setStatusTip ( tr( "Paste" ) );
415 a->setShortcut ( Qt::CTRL + Qt::Key_V );
416 a->setEnabled (false);
418 editMenu->addAction (a);
421 // Shortcuts to modify heading:
422 a = new QAction(tr( "Edit heading" ),this);
423 a->setStatusTip ( tr( "edit Heading" ));
424 a->setShortcut ( Qt::Key_Enter);
425 // a->setShortcutContext (Qt::WindowShortcut);
427 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
428 actionListBranches.append(a);
429 a = new QAction( tr( "Edit heading" ), this);
430 a->setStatusTip (tr( "edit Heading" ));
431 a->setShortcut (Qt::Key_Return );
432 //a->setShortcutContext (Qt::WindowShortcut);
434 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
435 actionListBranches.append(a);
436 editMenu->addAction (a);
438 a = new QAction( tr( "Edit heading" ), this);
439 a->setStatusTip (tr( "edit Heading" ));
440 a->setShortcut ( Qt::Key_F2 );
441 a->setShortcutContext (Qt::WindowShortcut);
443 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
444 actionListBranches.append(a);
446 // Shortcut to delete selection
447 a = new QAction( tr( "Delete Selection" ),this);
448 a->setStatusTip (tr( "Delete Selection" ));
449 a->setShortcut ( Qt::Key_Delete);
450 a->setShortcutContext (Qt::WindowShortcut);
452 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
455 // Shortcut to add branch
456 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
457 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
458 alt->setShortcut (Qt::Key_A);
459 alt->setShortcutContext (Qt::WindowShortcut);
461 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
462 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
463 a->setStatusTip ( tr( "Add a branch as child of selection" ));
464 a->setShortcut (Qt::Key_Insert);
465 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
466 actionListBranches.append(a);
467 #if defined (Q_OS_MACX)
468 // In OSX show different shortcut in menues, the keys work indepently always
469 actionEditAddBranch=alt;
471 actionEditAddBranch=a;
473 editMenu->addAction (actionEditAddBranch);
474 tb->addAction (actionEditAddBranch);
477 // Add branch by inserting it at selection
478 a = new QAction(tr( "Add branch (insert)" ), this);
479 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
480 a->setShortcut (Qt::ALT + Qt::Key_Insert );
481 a->setShortcutContext (Qt::WindowShortcut);
483 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
484 a->setEnabled (false);
485 actionListBranches.append(a);
486 actionEditAddBranchHere=a;
487 a = new QAction(tr( "Add branch (insert)" ),this);
488 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
489 a->setShortcut ( Qt::ALT + Qt::Key_A );
490 a->setShortcutContext (Qt::WindowShortcut);
492 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
493 actionListBranches.append(a);
496 a = new QAction(tr( "Add branch above" ), this);
497 a->setStatusTip ( tr( "Add a branch above selection" ));
498 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
499 a->setShortcutContext (Qt::WindowShortcut);
501 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
502 a->setEnabled (false);
503 actionListBranches.append(a);
504 actionEditAddBranchAbove=a;
505 a = new QAction(tr( "Add branch above" ), this);
506 a->setStatusTip ( tr( "Add a branch above selection" ));
507 a->setShortcut (Qt::SHIFT+Qt::Key_A );
508 a->setShortcutContext (Qt::WindowShortcut);
510 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
511 actionListBranches.append(a);
514 a = new QAction(tr( "Add branch below" ), this);
515 a->setStatusTip ( tr( "Add a branch below selection" ));
516 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
517 a->setShortcutContext (Qt::WindowShortcut);
519 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
520 a->setEnabled (false);
521 actionListBranches.append(a);
522 actionEditAddBranchBelow=a;
523 a = new QAction(tr( "Add branch below" ), this);
524 a->setStatusTip ( tr( "Add a branch below selection" ));
525 a->setShortcut (Qt::CTRL +Qt::Key_A );
526 a->setShortcutContext (Qt::WindowShortcut);
528 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
529 actionListBranches.append(a);
531 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
532 a->setStatusTip ( tr( "Move branch up" ) );
533 a->setShortcut (Qt::Key_PageUp );
534 a->setEnabled (false);
536 editMenu->addAction (a);
537 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
540 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
542 a->setStatusTip (tr( "Move branch down" ) );
543 a->setShortcut ( Qt::Key_PageDown );
544 a->setEnabled (false);
546 editMenu->addAction (a);
547 actionEditMoveDown=a;
550 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
551 a->setShortcut ( Qt::Key_ScrollLock );
552 a->setStatusTip (tr( "Scroll branch" ) );
553 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
555 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
556 alt->setShortcut ( Qt::Key_S );
557 alt->setStatusTip (tr( "Scroll branch" ));
558 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
559 #if defined(Q_OS_MACX)
560 actionEditToggleScroll=alt;
562 actionEditToggleScroll=a;
564 actionEditToggleScroll->setEnabled (false);
565 actionEditToggleScroll->setToggleAction(true);
566 tb->addAction (actionEditToggleScroll);
567 editMenu->addAction ( actionEditToggleScroll);
568 editMenu->addAction (actionEditToggleScroll);
571 actionListBranches.append(actionEditToggleScroll);
573 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
574 a->setStatusTip (tr( "Unscroll all" ));
575 editMenu->addAction (a);
576 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
578 editMenu->addSeparator();
580 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
581 a->setStatusTip (tr( "Find" ) );
582 a->setShortcut (Qt::CTRL + Qt::Key_F );
583 editMenu->addAction (a);
584 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
586 editMenu->addSeparator();
588 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
589 a->setShortcut (Qt::CTRL + Qt::Key_U );
590 a->setShortcut (tr( "Open URL" ));
593 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
596 a = new QAction( tr( "Open URL in new tab" ), this);
597 a->setStatusTip (tr( "Open URL in new tab" ));
598 a->setShortcut (Qt::CTRL+Qt::Key_U );
600 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
601 actionEditOpenURLTab=a;
603 a = new QAction( tr( "Open all URLs in subtree" ), this);
604 a->setStatusTip (tr( "Open all URLs in subtree" ));
606 actionListBranches.append(a);
607 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
608 actionEditOpenMultipleURLTabs=a;
610 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
611 a->setStatusTip ( tr( "Edit URL" ) );
612 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
613 //a->setShortcut ( Qt::Key_U );
614 a->setShortcutContext (Qt::WindowShortcut);
615 actionListBranches.append(a);
617 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
620 a = new QAction( tr( "Use heading for URL" ), this);
621 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
622 a->setEnabled (false);
623 actionListBranches.append(a);
624 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
625 actionEditHeading2URL=a;
627 a = new QAction(tr( "Create URL to Bugzilla" ), this);
628 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
629 a->setEnabled (false);
630 actionListBranches.append(a);
631 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
632 actionEditBugzilla2URL=a;
634 a = new QAction(tr( "Create URL to FATE" ), this);
635 a->setStatusTip ( tr( "Create URL to FATE" ));
636 a->setEnabled (false);
637 actionListBranches.append(a);
638 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
639 actionEditFATE2URL=a;
641 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this);
642 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
644 a->setEnabled (false);
645 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
646 actionEditOpenVymLink=a;
648 a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this);
649 a->setStatusTip ( tr( "Open all vym links in subtree" ));
650 a->setEnabled (false);
651 actionListBranches.append(a);
652 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
653 actionEditOpenMultipleVymLinks=a;
656 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
657 a->setEnabled (false);
658 a->setStatusTip ( tr( "Edit link to another vym map" ));
659 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
660 actionListBranches.append(a);
663 a = new QAction(tr( "Delete vym link" ),this);
664 a->setStatusTip ( tr( "Delete link to another vym map" ));
665 a->setEnabled (false);
666 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
667 actionEditDeleteVymLink=a;
669 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
670 a->setStatusTip ( tr( "Hide object in exports" ) );
671 a->setShortcut (Qt::Key_H );
672 a->setToggleAction(true);
674 a->setEnabled (false);
675 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
676 actionEditToggleHideExport=a;
678 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
679 a->setStatusTip ( tr( "Edit Map Info" ));
680 a->setEnabled (true);
681 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
684 // Import at selection (adding to selection)
685 a = new QAction( tr( "Add map (insert)" ),this);
686 a->setStatusTip (tr( "Add map at selection" ));
687 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
688 a->setEnabled (false);
689 actionListBranches.append(a);
690 actionEditImportAdd=a;
692 // Import at selection (replacing selection)
693 a = new QAction( tr( "Add map (replace)" ), this);
694 a->setStatusTip (tr( "Replace selection with map" ));
695 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
696 a->setEnabled (false);
697 actionListBranches.append(a);
698 actionEditImportReplace=a;
701 a = new QAction( tr( "Save selection" ), this);
702 a->setStatusTip (tr( "Save selection" ));
703 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
704 a->setEnabled (false);
705 actionListBranches.append(a);
706 actionEditSaveBranch=a;
708 // Only remove branch, not its childs
709 a = new QAction(tr( "Remove only branch " ), this);
710 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
711 a->setShortcut (Qt::ALT + Qt::Key_Delete );
712 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
713 a->setEnabled (false);
715 actionListBranches.append(a);
716 actionEditRemoveBranchKeepChilds=a;
718 // Only remove childs of a branch
719 a = new QAction( tr( "Remove childs" ), this);
720 a->setStatusTip (tr( "Remove childs of branch" ));
721 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
722 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
723 a->setEnabled (false);
724 actionListBranches.append(a);
725 actionEditRemoveChilds=a;
727 // Shortcuts for navigating with cursor:
728 a = new QAction(tr( "Select upper branch" ), this);
729 a->setStatusTip ( tr( "Select upper branch" ));
730 a->setShortcut (Qt::Key_Up );
731 a->setShortcutContext (Qt::WindowShortcut);
733 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
734 a = new QAction( tr( "Select lower branch" ),this);
735 a->setStatusTip (tr( "Select lower branch" ));
736 a->setShortcut ( Qt::Key_Down );
737 a->setShortcutContext (Qt::WindowShortcut);
739 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
740 a = new QAction(tr( "Select left branch" ), this);
741 a->setStatusTip ( tr( "Select left branch" ));
742 a->setShortcut (Qt::Key_Left );
743 a->setShortcutContext (Qt::WindowShortcut);
745 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
746 a = new QAction( tr( "Select child branch" ), this);
747 a->setStatusTip (tr( "Select right branch" ));
748 a->setShortcut (Qt::Key_Right);
749 a->setShortcutContext (Qt::WindowShortcut);
751 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
752 a = new QAction( tr( "Select first branch" ), this);
753 a->setStatusTip (tr( "Select first branch" ));
754 a->setShortcut (Qt::Key_Home );
755 a->setShortcutContext (Qt::WindowShortcut);
757 a->setEnabled (false);
758 editMenu->addAction (a);
759 actionListBranches.append(a);
760 actionEditSelectFirst=a;
761 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
762 a = new QAction( tr( "Select last branch" ),this);
763 a->setStatusTip (tr( "Select last branch" ));
764 a->setShortcut ( Qt::Key_End );
765 a->setShortcutContext (Qt::WindowShortcut);
767 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
768 a->setEnabled (false);
769 editMenu->addAction (a);
770 actionListBranches.append(a);
771 actionEditSelectLast=a;
773 a = new QAction( tr( "Add Image" )+QString("..."), this);
774 a->setStatusTip (tr( "Add Image" ));
775 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
776 actionEditLoadImage=a;
781 void Main::setupFormatActions()
783 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
785 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
786 tb->setObjectName ("formatTB");
789 pix.fill (Qt::black);
790 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
791 a->setStatusTip ( tr( "Set Color" ));
792 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
794 formatMenu->addAction (a);
796 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
797 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
798 a->setShortcut (Qt::CTRL + Qt::Key_K );
799 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
800 a->setEnabled (false);
802 formatMenu->addAction (a);
803 actionListBranches.append(a);
804 actionFormatPickColor=a;
806 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
807 a->setStatusTip ( tr( "Color branch" ) );
808 a->setShortcut (Qt::CTRL + Qt::Key_I);
809 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
810 a->setEnabled (false);
812 formatMenu->addAction (a);
813 actionListBranches.append(a);
814 actionFormatColorBranch=a;
816 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
817 a->setStatusTip ( tr( "Color Subtree" ));
818 a->setShortcut (Qt::CTRL + Qt::Key_T);
819 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
820 a->setEnabled (false);
821 formatMenu->addAction (a);
823 actionListBranches.append(a);
824 actionFormatColorSubtree=a;
826 formatMenu->addSeparator();
827 actionGroupFormatLinkStyles=new QActionGroup ( this);
828 actionGroupFormatLinkStyles->setExclusive (true);
829 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
830 a->setStatusTip (tr( "Line" ));
831 a->setToggleAction(true);
832 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
833 formatMenu->addAction (a);
834 actionFormatLinkStyleLine=a;
835 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
836 a->setStatusTip (tr( "Line" ));
837 a->setToggleAction(true);
838 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
839 formatMenu->addAction (a);
840 actionFormatLinkStyleParabel=a;
841 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
842 a->setStatusTip (tr( "PolyLine" ));
843 a->setToggleAction(true);
844 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
845 formatMenu->addAction (a);
846 actionFormatLinkStylePolyLine=a;
847 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
848 a->setStatusTip (tr( "PolyParabel" ) );
849 a->setToggleAction(true);
850 a->setChecked (true);
851 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
852 formatMenu->addAction (a);
853 actionFormatLinkStylePolyParabel=a;
855 actionGroupFormatFrameTypes=new QActionGroup ( this);
856 actionGroupFormatFrameTypes->setExclusive (true);
857 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
858 a->setStatusTip (tr("No Frame"));
859 a->setToggleAction(true);
860 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
861 actionFormatFrameNone=a;
862 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
863 a->setStatusTip (tr( "Rectangle" ));
864 a->setToggleAction(true);
865 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
866 actionFormatFrameRectangle=a;
868 a = new QAction( tr( "Include images vertically" ), this);
869 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
870 a->setToggleAction(true);
871 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
872 actionFormatIncludeImagesVer=a;
874 a = new QAction( tr( "Include images horizontally" ), this);
875 a->setStatusTip ( tr ("Include left and right position of images into branch"));
876 a->setToggleAction(true);
877 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
878 actionFormatIncludeImagesHor=a;
880 a = new QAction( tr( "Hide link if object is not selected" ), this);
881 a->setStatusTip (tr( "Hide link" ));
882 a->setToggleAction(true);
883 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
884 actionFormatHideLinkUnselected=a;
886 formatMenu->addSeparator();
887 a= new QAction( tr( "&Use color of heading for link" ), this);
888 a->setStatusTip (tr( "Use same color for links and headings" ));
889 a->setToggleAction(true);
890 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
891 formatMenu->addAction (a);
892 actionFormatLinkColorHint=a;
894 pix.fill (Qt::white);
895 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
896 a->setStatusTip (tr( "Set Link Color" ));
897 formatMenu->addAction (a);
898 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
899 actionFormatLinkColor=a;
901 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
902 a->setStatusTip (tr( "Set Background Color" ));
903 formatMenu->addAction (a);
904 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
905 actionFormatBackColor=a;
909 void Main::setupViewActions()
911 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
912 tb->setLabel( "View Actions" );
913 tb->setObjectName ("viewTB");
914 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
917 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
918 a->setStatusTip ( tr( "Zoom reset" ) );
919 a->setShortcut (Qt::CTRL + Qt::Key_0 );
921 viewMenu->addAction (a);
922 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
924 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
925 a->setStatusTip (tr( "Zoom in" ));
926 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
928 viewMenu->addAction (a);
929 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
931 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
932 a->setStatusTip (tr( "Zoom out" ));
933 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
935 viewMenu->addAction (a);
936 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
939 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
940 a->setStatusTip ( tr( "Show Note Editor" ));
941 a->setShortcut ( Qt::CTRL + Qt::Key_E );
942 a->setToggleAction(true);
943 if (textEditor->showWithMain())
948 viewMenu->addAction (a);
949 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
950 actionViewToggleNoteEditor=a;
952 a = new QAction( tr( "Show history window" ),this );
953 a->setStatusTip ( tr( "Show history window" ));
954 a->setShortcut ( Qt::CTRL + Qt::Key_H );
955 a->setToggleAction(false);
956 viewMenu->addAction (a);
957 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
958 actionViewToggleHistoryWindow=a;
960 a = new QAction(tr( "Next Window" ), this);
961 a->setStatusTip ( tr( "&Next Window" ) );
962 a->setShortcut (Qt::ALT + Qt::Key_N );
963 viewMenu->addAction (a);
964 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
966 a = new QAction (tr( "Previous Window" ), this );
967 a->setStatusTip (tr( "&Previous Window" ));
968 a->setShortcut (Qt::ALT + Qt::Key_P );
969 viewMenu->addAction (a);
970 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
974 void Main::setupModeActions()
976 //QPopupMenu *menu = new QPopupMenu( this );
977 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
979 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
980 tb->setObjectName ("modesTB");
982 actionGroupModModes=new QActionGroup ( this);
983 actionGroupModModes->setExclusive (true);
984 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
985 a->setShortcut (Qt::Key_J);
986 a->setStatusTip ( tr( "Use modifier to color branches" ));
987 a->setToggleAction(true);
990 actionModModeColor=a;
992 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
993 a->setShortcut( Qt::Key_K);
994 a->setStatusTip( tr( "Use modifier to copy" ));
995 a->setToggleAction(true);
999 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1000 a->setShortcut (Qt::Key_L);
1001 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1002 a->setToggleAction(true);
1004 actionModModeXLink=a;
1008 void Main::setupFlagActions()
1010 // Create System Flags
1011 systemFlagsDefault = new FlagRowObj ();
1012 systemFlagsDefault->setVisibility (false);
1013 systemFlagsDefault->setName ("systemFlagsDef");
1015 FlagObj *fo = new FlagObj ();
1016 fo->load(QPixmap(flagsPath+"flag-note.png"));
1017 fo->setName("note");
1018 fo->setToolTip(tr("Note","Systemflag"));
1019 systemFlagsDefault->addFlag (fo); // makes deep copy
1021 fo->load(QPixmap(flagsPath+"flag-url.png"));
1023 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1024 systemFlagsDefault->addFlag (fo);
1026 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1027 fo->setName("vymLink");
1028 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1029 systemFlagsDefault->addFlag (fo);
1031 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1032 fo->setName("scrolledright");
1033 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1034 systemFlagsDefault->addFlag (fo);
1036 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1037 fo->setName("tmpUnscrolledright");
1038 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1039 systemFlagsDefault->addFlag (fo);
1041 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1042 fo->setName("hideInExport");
1043 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1044 systemFlagsDefault->addFlag (fo);
1046 // Create Standard Flags
1047 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1048 tb->setObjectName ("standardFlagTB");
1050 standardFlagsDefault = new FlagRowObj ();
1051 standardFlagsDefault->setVisibility (false);
1052 standardFlagsDefault->setName ("standardFlagsDef");
1053 standardFlagsDefault->setToolBar (tb);
1055 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1056 fo->setName ("exclamationmark");
1057 fo->setGroup("standard-mark");
1058 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1061 a->setCheckable(true);
1062 a->setObjectName(fo->getName());
1063 a->setToolTip(tr("Take care!","Standardflag"));
1064 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1065 standardFlagsDefault->addFlag (fo); // makes deep copy
1067 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1068 fo->setName("questionmark");
1069 fo->setGroup("standard-mark");
1070 a=new QAction (fo->getPixmap(),fo->getName(),this);
1073 a->setCheckable(true);
1074 a->setObjectName(fo->getName());
1075 a->setToolTip(tr("Really?","Standardflag"));
1076 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1077 standardFlagsDefault->addFlag (fo);
1079 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1080 fo->setName("hook-green");
1081 fo->setGroup("standard-hook");
1082 a=new QAction (fo->getPixmap(),fo->getName(),this);
1085 a->setCheckable(true);
1086 a->setObjectName(fo->getName());
1087 a->setToolTip(tr("ok!","Standardflag"));
1088 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1089 standardFlagsDefault->addFlag (fo);
1091 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1092 fo->setName("cross-red");
1093 fo->setGroup("standard-hook");
1094 a=new QAction (fo->getPixmap(),fo->getName(),this);
1097 a->setCheckable(true);
1098 a->setObjectName(fo->getName());
1099 a->setToolTip(tr("Not ok!","Standardflag"));
1100 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1101 standardFlagsDefault->addFlag (fo);
1103 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1104 fo->setName("stopsign");
1105 a=new QAction (fo->getPixmap(),fo->getName(),this);
1108 a->setCheckable(true);
1109 a->setObjectName(fo->getName());
1110 a->setToolTip(tr("This won't work!","Standardflag"));
1111 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1112 standardFlagsDefault->addFlag (fo);
1114 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1115 fo->setName("smiley-good");
1116 fo->setGroup("standard-smiley");
1117 a=new QAction (fo->getPixmap(),fo->getName(),this);
1120 a->setCheckable(true);
1121 a->setObjectName(fo->getName());
1122 a->setToolTip(tr("Good","Standardflag"));
1123 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1124 standardFlagsDefault->addFlag (fo);
1126 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1127 fo->setName("smiley-sad");
1128 fo->setGroup("standard-smiley");
1129 a=new QAction (fo->getPixmap(),fo->getName(),this);
1132 a->setCheckable(true);
1133 a->setObjectName(fo->getName());
1134 a->setToolTip(tr("Bad","Standardflag"));
1135 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1136 standardFlagsDefault->addFlag (fo);
1138 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1139 // Original omg.png (in KDE emoticons)
1140 fo->setName("smiley-omg");
1141 fo->setGroup("standard-smiley");
1142 a=new QAction (fo->getPixmap(),fo->getName(),this);
1145 a->setCheckable(true);
1146 a->setObjectName(fo->getName());
1147 a->setToolTip(tr("Oh no!","Standardflag"));
1148 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1149 standardFlagsDefault->addFlag (fo);
1151 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1152 fo->setName("clock");
1153 a=new QAction (fo->getPixmap(),fo->getName(),this);
1156 a->setCheckable(true);
1157 a->setObjectName(fo->getName());
1158 a->setToolTip(tr("Time critical","Standardflag"));
1159 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1160 standardFlagsDefault->addFlag (fo);
1162 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1163 fo->setName("phone");
1164 a=new QAction (fo->getPixmap(),fo->getName(),this);
1167 a->setCheckable(true);
1168 a->setObjectName(fo->getName());
1169 a->setToolTip(tr("Call...","Standardflag"));
1170 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1171 standardFlagsDefault->addFlag (fo);
1173 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1174 fo->setName("lamp");
1175 a=new QAction (fo->getPixmap(),fo->getName(),this);
1178 a->setCheckable(true);
1179 a->setObjectName(fo->getName());
1180 a->setToolTip(tr("Idea!","Standardflag"));
1181 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1182 standardFlagsDefault->addFlag (fo);
1184 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1185 fo->setName("arrow-up");
1186 fo->setGroup("standard-arrow");
1187 a=new QAction (fo->getPixmap(),fo->getName(),this);
1190 a->setCheckable(true);
1191 a->setObjectName(fo->getName());
1192 a->setToolTip(tr("Important","Standardflag"));
1193 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1194 standardFlagsDefault->addFlag (fo);
1196 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1197 fo->setName("arrow-down");
1198 fo->setGroup("standard-arrow");
1199 a=new QAction (fo->getPixmap(),fo->getName(),this);
1202 a->setCheckable(true);
1203 a->setObjectName(fo->getName());
1204 a->setToolTip(tr("Unimportant","Standardflag"));
1205 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1206 standardFlagsDefault->addFlag (fo);
1208 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1209 fo->setName("2arrow-up");
1210 fo->setGroup("standard-arrow");
1211 a=new QAction (fo->getPixmap(),fo->getName(),this);
1214 a->setCheckable(true);
1215 a->setObjectName(fo->getName());
1216 a->setToolTip(tr("Very important!","Standardflag"));
1217 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1218 standardFlagsDefault->addFlag (fo);
1220 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1221 fo->setName("2arrow-down");
1222 fo->setGroup("standard-arrow");
1223 a=new QAction (fo->getPixmap(),fo->getName(),this);
1226 a->setCheckable(true);
1227 a->setObjectName(fo->getName());
1228 a->setToolTip(tr("Very unimportant!","Standardflag"));
1229 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1230 standardFlagsDefault->addFlag (fo);
1232 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1233 fo->setName("thumb-up");
1234 fo->setGroup("standard-thumb");
1235 a=new QAction (fo->getPixmap(),fo->getName(),this);
1238 a->setCheckable(true);
1239 a->setObjectName(fo->getName());
1240 a->setToolTip(tr("I like this","Standardflag"));
1241 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1242 standardFlagsDefault->addFlag (fo);
1244 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1245 fo->setName("thumb-down");
1246 fo->setGroup("standard-thumb");
1247 a=new QAction (fo->getPixmap(),fo->getName(),this);
1250 a->setCheckable(true);
1251 a->setObjectName(fo->getName());
1252 a->setToolTip(tr("I do not like this","Standardflag"));
1253 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1254 standardFlagsDefault->addFlag (fo);
1256 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1257 fo->setName("rose");
1258 a=new QAction (fo->getPixmap(),fo->getName(),this);
1261 a->setCheckable(true);
1262 a->setObjectName(fo->getName());
1263 a->setToolTip(tr("Rose","Standardflag"));
1264 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1265 standardFlagsDefault->addFlag (fo);
1267 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1268 fo->setName("heart");
1269 a=new QAction (fo->getPixmap(),fo->getName(),this);
1271 a->setCheckable(true);
1272 a->setObjectName(fo->getName());
1273 a->setToolTip(tr("I just love... ","Standardflag"));
1274 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1275 standardFlagsDefault->addFlag (fo);
1277 fo->load(QPixmap(flagsPath+"flag-present.png"));
1278 fo->setName("present");
1279 a=new QAction (fo->getPixmap(),fo->getName(),this);
1282 a->setCheckable(true);
1283 a->setObjectName(fo->getName());
1284 a->setToolTip(tr("Surprise!","Standardflag"));
1285 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1286 standardFlagsDefault->addFlag (fo);
1288 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1289 fo->setName("flash");
1290 a=new QAction (fo->getPixmap(),fo->getName(),this);
1293 a->setCheckable(true);
1294 a->setObjectName(fo->getName());
1295 a->setToolTip(tr("Dangerous","Standardflag"));
1296 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1297 standardFlagsDefault->addFlag (fo);
1299 fo->load(QPixmap(flagsPath+"flag-info.png"));
1300 // Original: xsldbg_output.png
1301 fo->setName("info");
1302 a=new QAction (fo->getPixmap(),fo->getName(),this);
1305 a->setCheckable(true);
1306 a->setObjectName(fo->getName());
1307 a->setToolTip(tr("Info","Standardflag"));
1308 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1309 standardFlagsDefault->addFlag (fo);
1311 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1312 // Original khelpcenter.png
1313 fo->setName("lifebelt");
1314 a=new QAction (fo->getPixmap(),fo->getName(),this);
1317 a->setCheckable(true);
1318 a->setObjectName(fo->getName());
1319 a->setToolTip(tr("This will help","Standardflag"));
1320 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1321 standardFlagsDefault->addFlag (fo);
1327 void Main::setupSettingsActions()
1329 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1333 a = new QAction( tr( "Set application to open pdf files"), this);
1334 a->setStatusTip ( tr( "Set application to open pdf files"));
1335 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1336 settingsMenu->addAction (a);
1338 a = new QAction( tr( "Set application to open external links"), this);
1339 a->setStatusTip( tr( "Set application to open external links"));
1340 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1341 settingsMenu->addAction (a);
1343 settingsMenu->addSeparator();
1344 a = new QAction( tr( "Edit branch after adding it" ), this );
1345 a->setStatusTip( tr( "Edit branch after adding it" ));
1346 a->setToggleAction(true);
1347 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1348 settingsMenu->addAction (a);
1349 actionSettingsAutoEdit=a;
1351 a= new QAction( tr( "Select branch after adding it" ), this );
1352 a->setStatusTip( tr( "Select branch after adding it" ));
1353 a->setToggleAction(true);
1354 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1355 settingsMenu->addAction (a);
1356 actionSettingsAutoSelectHeading=a;
1358 a= new QAction(tr( "Select existing heading" ), this);
1359 a->setStatusTip( tr( "Select heading before editing" ));
1360 a->setToggleAction(true);
1361 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1362 settingsMenu->addAction (a);
1363 actionSettingsAutoSelectText=a;
1365 a= new QAction( tr( "Delete key" ), this);
1366 a->setStatusTip( tr( "Delete key for deleting branches" ));
1367 a->setToggleAction(true);
1368 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1369 settingsMenu->addAction (a);
1370 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1371 actionSettingsUseDelKey=a;
1373 a= new QAction( tr( "Exclusive flags" ), this);
1374 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1375 a->setToggleAction(true);
1376 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1377 settingsMenu->addAction (a);
1378 actionSettingsUseFlagGroups=a;
1380 a= new QAction( tr( "Use hide flags" ), this);
1381 a->setStatusTip( tr( "Use hide flag during exports " ));
1382 a->setToggleAction(true);
1383 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1384 settingsMenu->addAction (a);
1385 actionSettingsUseHideExport=a;
1389 void Main::setupTestActions()
1391 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1394 a = new QAction( tr( "Test function" ), this);
1395 a->setStatusTip( tr( "Call test function" ));
1396 a->setShortcut (Qt::Key_F4 );
1397 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1398 testMenu->addAction (a);
1399 a = new QAction( tr( "Command" ), this);
1400 a->setStatusTip( tr( "Enter command to call in editor" ));
1401 a->setShortcut (Qt::Key_F5 );
1402 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1403 testMenu->addAction (a);
1407 void Main::setupHelpActions()
1409 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1412 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1413 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1414 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1415 helpMenu->addAction (a);
1417 a = new QAction( tr( "About VYM" ), this);
1418 a->setStatusTip( tr( "About VYM")+" "__VYM);
1419 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1420 helpMenu->addAction (a);
1422 a = new QAction( tr( "About QT" ), this);
1423 a->setStatusTip( tr( "Information about QT toolkit" ));
1424 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1425 helpMenu->addAction (a);
1429 void Main::setupContextMenus()
1433 // Context Menu for branch or mapcenter
1434 branchContextMenu =new QMenu (this);
1437 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1438 branchAddContextMenu->addAction (actionEditPaste );
1439 branchAddContextMenu->addAction ( actionEditAddBranch );
1440 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1441 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1442 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1443 branchAddContextMenu->addSeparator();
1444 branchAddContextMenu->addAction ( actionEditLoadImage);
1445 branchAddContextMenu->addSeparator();
1446 branchAddContextMenu->addAction ( actionEditImportAdd );
1447 branchAddContextMenu->addAction ( actionEditImportReplace );
1450 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1451 branchRemoveContextMenu->addAction (actionEditCut);
1452 branchRemoveContextMenu->addAction ( actionEditDelete );
1453 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1454 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1457 actionEditSaveBranch->addTo( branchContextMenu );
1459 branchContextMenu->addSeparator();
1460 branchContextMenu->addAction ( actionFormatFrameNone );
1461 branchContextMenu->addAction ( actionFormatFrameRectangle);
1463 branchContextMenu->addSeparator();
1464 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1465 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1466 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1468 // Submenu for Links (URLs, vymLinks)
1469 branchLinksContextMenu =new QMenu (this);
1471 branchContextMenu->addSeparator();
1472 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));
1473 branchLinksContextMenu->addAction ( actionEditOpenURL );
1474 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1475 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1476 branchLinksContextMenu->addAction ( actionEditURL );
1477 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1478 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1479 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1481 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1483 branchLinksContextMenu->addSeparator();
1484 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1485 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1486 branchLinksContextMenu->addAction ( actionEditVymLink );
1487 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1490 // Context Menu for XLinks in a branch menu
1491 // This will be populated "on demand" in MapEditor::updateActions
1492 branchContextMenu->addSeparator();
1493 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1494 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1495 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1496 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1499 // Context menu for floatimage
1500 floatimageContextMenu =new QMenu (this);
1501 a= new QAction (tr ("Save image"),this);
1502 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1503 floatimageContextMenu->addAction (a);
1505 floatimageContextMenu->addSeparator();
1506 actionEditCopy->addTo( floatimageContextMenu );
1507 actionEditCut->addTo( floatimageContextMenu );
1509 floatimageContextMenu->addSeparator();
1510 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1513 // Context menu for canvas
1514 canvasContextMenu =new QMenu (this);
1515 actionEditMapInfo->addTo( canvasContextMenu );
1516 canvasContextMenu->insertSeparator();
1517 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1518 canvasContextMenu->insertSeparator();
1519 actionFormatLinkColorHint->addTo( canvasContextMenu );
1520 actionFormatLinkColor->addTo( canvasContextMenu );
1521 actionFormatBackColor->addTo( canvasContextMenu );
1523 // Menu for last opened files
1524 // Read settings initially
1526 int j=settings.readNumEntry( "/lastMaps/number",0);
1527 for (int i=1;i<=j;i++)
1529 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1530 if (!s.isEmpty() && j<=maxLastMaps)
1533 setupLastMapsMenu();
1534 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1537 void Main::setupLastMapsMenu()
1539 // Remove double entries
1540 QStringList::Iterator it=lastMaps.begin();
1541 QStringList::Iterator jt;
1542 while (it!=lastMaps.end() )
1546 while (jt!=lastMaps.end() )
1549 jt=lastMaps.remove(jt);
1556 // Limit length of list to maxLastMaps
1557 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1559 // build Menu from lastMaps string list
1560 fileLastMapsMenu->clear();
1561 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1562 fileLastMapsMenu->addAction (*it );
1565 void Main::hideEvent (QHideEvent * )
1567 if (!textEditor->isMinimized() ) textEditor->hide();
1570 void Main::showEvent (QShowEvent * )
1572 if (textEditor->showWithMain()) textEditor->showNormal();
1575 bool Main::reallyWriteDirectory(const QString &dir)
1577 QStringList eList = QDir(dir).entryList();
1578 if (eList.first() ==".") eList.pop_front(); // remove "."
1579 if (eList.first() =="..") eList.pop_front(); // remove "."
1580 if (!eList.isEmpty())
1582 QMessageBox mb( __VYM,
1583 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1584 QMessageBox::Warning,
1586 QMessageBox::Cancel | QMessageBox::Default,
1587 QMessageBox::QMessageBox::NoButton );
1589 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1590 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1593 case QMessageBox::Yes:
1596 case QMessageBox::Cancel:
1604 QString Main::browseDirectory (const QString &caption)
1606 Q3FileDialog fd(this,caption);
1607 fd.setMode (Q3FileDialog::DirectoryOnly);
1608 fd.setCaption(__VYM " - "+caption);
1611 if ( fd.exec() == QDialog::Accepted )
1612 return fd.selectedFile();
1617 MapEditor* Main::currentMapEditor() const
1619 if ( tabWidget->currentPage() &&
1620 tabWidget->currentPage()->inherits( "MapEditor" ) )
1621 return (MapEditor*)tabWidget->currentPage();
1625 //TODO not used now, maybe use this for overview window later
1626 void Main::newView()
1628 // Open a new view... have it delete when closed.
1629 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1630 qApp->setMainWidget(m);
1632 qApp->setMainWidget(0);
1635 void Main::editorChanged(QWidget *)
1637 // Unselect all possibly selected objects
1638 // (Important to update note editor)
1641 for (i=0;i<=tabWidget->count() -1;i++)
1644 me=(MapEditor*)tabWidget->page(i);
1647 currentMapEditor()->reselect();
1649 // Update actions to in menus and toolbars according to editor
1650 currentMapEditor()->updateActions();
1653 void Main::fileNew()
1655 QString fn="unnamed";
1656 MapEditor* medit = new MapEditor ( NULL);
1657 tabWidget->addTab (medit,fn);
1658 tabWidget->showPage(medit);
1659 medit->viewport()->setFocus();
1660 // For the very first map we do not have flagrows yet...
1661 medit->select("mc:");
1664 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1666 ErrorCode err=success;
1668 // fn is usually the archive, mapfile the file after uncompressing
1671 // Make fn absolute (needed for unzip)
1672 fn=QDir (fn).absPath();
1678 // Check, if map is already loaded
1680 while (i<=tabWidget->count() -1)
1682 me=(MapEditor*)tabWidget->page(i);
1683 if (me->getFilePath() == fn)
1685 // Already there, ask for confirmation
1686 QMessageBox mb( __VYM,
1687 tr("The map %1\nis already opened."
1688 "Opening the same map in multiple editors may lead \n"
1689 "to confusion when finishing working with vym."
1690 "Do you want to").arg(fn),
1691 QMessageBox::Warning,
1692 QMessageBox::Yes | QMessageBox::Default,
1693 QMessageBox::Cancel | QMessageBox::Escape,
1694 QMessageBox::NoButton);
1695 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1696 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1699 case QMessageBox::Yes:
1701 i=tabWidget->count();
1703 case QMessageBox::Cancel:
1715 if ( !fn.isEmpty() )
1717 me = currentMapEditor();
1718 int tabIndex=tabWidget->currentPageIndex();
1719 // Check first, if mapeditor exists
1720 // If it is not default AND we want a new map,
1721 // create a new mapeditor in a new tab
1722 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1724 me= new MapEditor ( NULL);
1725 tabWidget->addTab (me,fn);
1726 tabIndex=tabWidget->indexOf (me);
1727 tabWidget->setCurrentPage (tabIndex);
1730 // Check, if file exists (important for creating new files
1731 // from command line
1732 if (!QFile(fn).exists() )
1734 QMessageBox mb( __VYM,
1735 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1736 QMessageBox::Question,
1738 QMessageBox::Cancel | QMessageBox::Default,
1739 QMessageBox::NoButton );
1741 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1742 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1745 case QMessageBox::Yes:
1747 currentMapEditor()->setFilePath(fn);
1748 tabWidget->setTabLabel (currentMapEditor(),
1749 currentMapEditor()->getFileName() );
1750 statusBar()->message( "Created " + fn , statusbarTime );
1753 case QMessageBox::Cancel:
1754 // don't create new map
1755 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1762 //tabWidget->currentPage() won't be NULL here, because of above...
1763 tabWidget->showPage(me);
1764 me->viewport()->setFocus();
1766 // Create temporary directory for packing
1768 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1771 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1772 tr("Couldn't create temporary directory before load\n"));
1776 // Try to unzip file
1777 err=unzipDir (tmpMapDir,fn);
1781 me->setZipped(false);
1784 me->setZipped(true);
1786 // Look for mapname.xml
1787 mapfile= fn.left(fn.findRev(".",-1,true));
1788 mapfile=mapfile.section( '/', -1 );
1789 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1790 if (!file.exists() )
1792 // mapname.xml does not exist, well,
1793 // maybe some renamed the mapname.vym file...
1794 // Try to find any .xml in the toplevel
1795 // directory of the .vym file
1796 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1797 if (flist.count()==1)
1799 // Only one entry, take this one
1800 mapfile=tmpMapDir + "/"+flist.first();
1803 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1804 *it=tmpMapDir + "/" + *it;
1805 // TODO Multiple entries, load all (but only the first one into this ME)
1806 //mainWindow->fileLoadFromTmp (flist);
1807 //returnCode=1; // Silently forget this attempt to load
1808 qWarning ("MainWindow::load (fn) multimap found...");
1811 if (flist.isEmpty() )
1813 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1814 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1817 } //file doesn't exist
1819 mapfile=file.name();
1824 // Save existing filename in case we import
1825 QString fn_org=me->getFilePath();
1827 // Finally load map into mapEditor
1828 me->setFilePath (mapfile,fn);
1829 err=me->load(mapfile,lmode);
1831 // Restore old (maybe empty) filepath, if this is an import
1833 me->setFilePath (fn_org);
1836 // Finally check for errors and go home
1839 if (lmode==NewMap) fileCloseMap();
1840 statusBar()->message( "Could not load " + fn, statusbarTime );
1845 me->setFilePath (fn);
1846 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1847 if (fn.left(9)!="/tmp/vym-")
1849 // Only append to lastMaps if not loaded from a tmpDir
1850 // e.g. imported bookmarks are in a tmpDir
1851 lastMaps.prepend(me->getFilePath() );
1852 setupLastMapsMenu();
1854 actionFilePrint->setEnabled (true);
1856 statusBar()->message( "Loaded " + fn, statusbarTime );
1860 removeDir (QDir(tmpMapDir));
1866 void Main::fileLoad(const LoadMode &lmode)
1868 QStringList filters;
1869 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1870 QFileDialog *fd=new QFileDialog( this);
1871 fd->setDir (lastFileDir);
1872 fd->setFileMode (QFileDialog::ExistingFiles);
1873 fd->setFilters (filters);
1877 fd->setCaption(__VYM " - " +tr("Load vym map"));
1880 fd->setCaption(__VYM " - " +tr("Import: Add vym map to selection"));
1883 fd->setCaption(__VYM " - " +tr("Import: Replace selection with vym map"));
1889 if ( fd->exec() == QDialog::Accepted )
1891 lastFileDir=fd->directory().path();
1892 QStringList flist = fd->selectedFiles();
1893 QStringList::Iterator it = flist.begin();
1894 while( it != flist.end() )
1897 fileLoad(*it, lmode);
1904 void Main::fileLoad()
1909 void Main::fileLoadLast(QAction *a)
1911 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1914 void Main::fileSave(const SaveMode &savemode)
1916 // tmp dir for zipping
1920 ErrorCode err=success;
1922 QString safeFilePath;
1924 bool saveZipped=currentMapEditor()->saveZipped();
1926 MapEditor * me=currentMapEditor();
1929 QString fn=me->getFilePath();
1930 // filename=unnamed, filepath="" in constructor...
1931 if ( !fn.isEmpty() )
1933 // We have a filepath, go on saving
1934 // First remove existing file, we
1935 // don't want to add to old zip archives
1939 QMessageBox::warning( 0, tr( "Save Error" ),
1940 fn+ tr("\ncould not be removed before saving"));
1942 // Look, if we should zip the data:
1945 QMessageBox mb( __VYM,
1946 tr("The map %1\ndid not use the compressed "
1947 "vym file format.\nWriting it uncompressed will also write images \n"
1948 "and flags and thus may overwrite files in the "
1949 "given directory\n\nDo you want to write the map").arg(fn),
1950 QMessageBox::Warning,
1951 QMessageBox::Yes | QMessageBox::Default,
1953 QMessageBox::Cancel | QMessageBox::Escape);
1954 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1955 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1956 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1959 case QMessageBox::Yes:
1960 // save compressed (default file format)
1963 case QMessageBox::No:
1964 // save uncompressed
1967 case QMessageBox::Cancel:
1976 // Create temporary directory for packing
1978 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1981 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1982 tr("Couldn't create temporary directory before save\n"));
1986 safeFilePath=me->getFilePath();
1987 me->setFilePath (tmpMapDir+"/"+
1988 me->getMapName()+ ".xml",
1990 me->save (savemode);
1991 me->setFilePath (safeFilePath);
1993 zipDir (tmpMapDir,fn);
1998 safeFilePath=me->getFilePath();
1999 me->setFilePath (fn, safeFilePath);
2000 me->save (savemode);
2001 me->setFilePath (safeFilePath);
2003 } // filepath available
2006 // We have no filepath yet,
2007 // call fileSaveAs() now, this will call fileSave()
2009 fileSaveAs(savemode);
2013 if (saveZipped && !tmpMapDir.isEmpty())
2015 removeDir (QDir(tmpMapDir));
2019 statusBar()->message(
2020 tr("Saved %1").arg(me->getFilePath()),
2022 lastMaps.prepend(me->getFilePath() );
2023 setupLastMapsMenu();
2025 statusBar()->message(
2026 tr("Couldn't save ").arg(me->getFilePath()),
2030 void Main::fileSave()
2032 fileSave (CompleteMap);
2035 void Main::fileSaveAs(const SaveMode& savemode)
2039 if (currentMapEditor())
2041 if (savemode==CompleteMap)
2042 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2044 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2045 if ( !fn.isEmpty() )
2047 // Check for existing file
2048 if (QFile (fn).exists())
2050 QMessageBox mb( __VYM,
2051 tr("The file %1\nexists already. Do you want to").arg(fn),
2052 QMessageBox::Warning,
2053 QMessageBox::Yes | QMessageBox::Default,
2054 QMessageBox::Cancel | QMessageBox::Escape,
2055 QMessageBox::NoButton);
2056 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2057 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2060 case QMessageBox::Yes:
2063 case QMessageBox::Cancel:
2070 // New file, add extension to filename, if missing
2071 // This is always .vym or .vyp, depending on savemode
2072 if (savemode==CompleteMap)
2074 if (!fn.contains (".vym") && !fn.contains (".xml"))
2078 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2087 currentMapEditor()->setFilePath(fn);
2091 if (savemode==CompleteMap)
2092 tabWidget->setTabLabel (currentMapEditor(),
2093 currentMapEditor()->getFileName() );
2099 void Main::fileSaveAs()
2101 fileSaveAs (CompleteMap);
2104 void Main::fileImportKDEBookmarks()
2106 ImportKDEBookmarks im;
2108 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2109 currentMapEditor()->setFilePath ("");
2112 void Main::fileImportFirefoxBookmarks()
2114 Q3FileDialog *fd=new Q3FileDialog( this);
2115 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2116 fd->setMode (Q3FileDialog::ExistingFiles);
2117 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2118 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2121 if ( fd->exec() == QDialog::Accepted )
2123 ImportFirefoxBookmarks im;
2124 QStringList flist = fd->selectedFiles();
2125 QStringList::Iterator it = flist.begin();
2126 while( it != flist.end() )
2129 if (im.transform() &&
2130 success==fileLoad (im.getTransformedFile(),NewMap) &&
2131 currentMapEditor() )
2132 currentMapEditor()->setFilePath ("");
2139 void Main::fileImportMM()
2143 Q3FileDialog *fd=new Q3FileDialog( this);
2144 fd->setDir (lastFileDir);
2145 fd->setMode (Q3FileDialog::ExistingFiles);
2146 fd->addFilter ("Mind Manager (*.mmap)");
2147 fd->setCaption(tr("Import")+" "+"Mind Manager");
2150 if ( fd->exec() == QDialog::Accepted )
2152 lastFileDir=fd->dirPath();
2153 QStringList flist = fd->selectedFiles();
2154 QStringList::Iterator it = flist.begin();
2155 while( it != flist.end() )
2158 if (im.transform() &&
2159 success==fileLoad (im.getTransformedFile(),NewMap) &&
2160 currentMapEditor() )
2161 currentMapEditor()->setFilePath ("");
2170 void Main::fileImportDir()
2172 if (currentMapEditor())
2173 currentMapEditor()->importDir();
2176 void Main::fileExportXML()
2178 if (currentMapEditor())
2180 QString dir=browseDirectory(tr("Export XML to directory"));
2181 if (dir !="" && reallyWriteDirectory(dir) )
2182 currentMapEditor()->exportXML(dir);
2187 void Main::fileExportXHTML()
2189 MapEditor *me=currentMapEditor();
2193 ExportXHTMLDialog dia(this);
2194 dia.setFilePath (me->getFilePath() );
2195 dia.setMapName (me->getMapName() );
2198 if (dia.exec()==QDialog::Accepted)
2200 QString dir=dia.getDir();
2201 // Check, if warnings should be used before overwriting
2202 // the output directory
2205 ok=reallyWriteDirectory(dir);
2211 me->exportXML (dia.getDir() );
2212 dia.doExport(me->getMapName() );
2213 if (dia.hasChanged())
2220 void Main::fileExportImage()
2222 MapEditor *me=currentMapEditor();
2226 QFileDialog *fd=new QFileDialog (this);
2227 fd->setCaption (tr("Export map as image"));
2228 fd->setFileMode(QFileDialog::AnyFile);
2229 fd->setFilters (imageIO.getFilters() );
2230 fd->setDirectory (lastImageDir);
2233 fl=fd->selectedFiles();
2234 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2235 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2240 void Main::fileExportASCII()
2242 MapEditor *me=currentMapEditor();
2246 ex.setMapCenter(me->getMapCenter());
2247 ex.addFilter ("TXT (*.txt)");
2248 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2249 if (ex.execDialog() )
2251 me->setExportMode(true);
2253 me->setExportMode(false);
2258 void Main::fileExportLaTeX()
2260 MapEditor *me=currentMapEditor();
2264 ex.setMapCenter(me->getMapCenter());
2265 ex.addFilter ("Tex (*.tex)");
2266 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2267 if (ex.execDialog() )
2269 me->setExportMode(true);
2271 me->setExportMode(false);
2276 void Main::fileExportKDEBookmarks()
2278 ExportKDEBookmarks ex;
2279 MapEditor *me=currentMapEditor();
2282 ex.setMapCenter (me->getMapCenter() );
2287 void Main::fileExportTaskjuggler()
2289 ExportTaskjuggler ex;
2290 MapEditor *me=currentMapEditor();
2293 ex.setMapCenter (me->getMapCenter() );
2294 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2295 ex.addFilter ("Taskjuggler (*.tjp)");
2296 if (ex.execDialog() )
2298 me->setExportMode(true);
2300 me->setExportMode(false);
2305 void Main::fileExportOOPresentation()
2307 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2308 // TODO add preview in dialog
2309 //ImagePreview *p =new ImagePreview (fd);
2310 //fd->setContentsPreviewEnabled( TRUE );
2311 //fd->setContentsPreview( p, p );
2312 //fd->setPreviewMode( QFileDialog::Contents );
2313 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2314 fd->setDir (QDir().current());
2315 if (fd->foundConfig())
2319 if ( fd->exec() == QDialog::Accepted )
2321 QString fn=fd->selectedFile();
2322 if (!fn.contains (".odp"))
2325 //lastImageDir=fn.left(fn.findRev ("/"));
2326 if (currentMapEditor())
2327 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2331 QMessageBox::warning(0,
2333 tr("Couldn't find configuration for export to Open Office\n"));
2337 void Main::fileCloseMap()
2339 if (currentMapEditor())
2341 if (currentMapEditor()->hasChanged())
2343 QMessageBox mb( __VYM,
2344 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2345 QMessageBox::Warning,
2346 QMessageBox::Yes | QMessageBox::Default,
2348 QMessageBox::Cancel | QMessageBox::Escape );
2349 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2350 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2353 case QMessageBox::Yes:
2355 fileSave(CompleteMap);
2357 case QMessageBox::No:
2358 // close without saving
2360 case QMessageBox::Cancel:
2365 currentMapEditor()->closeMap();
2366 tabWidget->removePage(currentMapEditor());
2367 if (tabWidget->count()==0)
2368 actionFilePrint->setEnabled (false);
2372 void Main::filePrint()
2374 if (currentMapEditor())
2375 currentMapEditor()->print();
2378 void Main::fileExitVYM()
2380 // Check if one or more editors have changed
2383 for (i=0;i<=tabWidget->count() -1;i++)
2386 me=(MapEditor*)tabWidget->page(i);
2388 // If something changed, ask what to do
2389 if (me->isUnsaved())
2391 tabWidget->setCurrentPage(i);
2392 QMessageBox mb( __VYM,
2393 tr("This map is not saved yet. Do you want to"),
2394 QMessageBox::Warning,
2395 QMessageBox::Yes | QMessageBox::Default,
2397 QMessageBox::Cancel | QMessageBox::Escape );
2398 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2399 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2402 mb.setActiveWindow();
2403 switch( mb.exec() ) {
2404 case QMessageBox::Yes:
2405 // save (the changed editors) and exit
2406 fileSave(CompleteMap);
2408 case QMessageBox::No:
2409 // exit without saving
2411 case QMessageBox::Cancel:
2412 // don't save and don't exit
2416 } // loop over all MEs
2420 void Main::editUndo()
2422 if (currentMapEditor())
2423 currentMapEditor()->undo();
2426 void Main::editRedo()
2428 if (currentMapEditor())
2429 currentMapEditor()->redo();
2432 void Main::editCopy()
2434 if (currentMapEditor())
2435 currentMapEditor()->copy();
2438 void Main::editPaste()
2440 if (currentMapEditor())
2441 currentMapEditor()->paste();
2444 void Main::editCut()
2446 if (currentMapEditor())
2447 currentMapEditor()->cut();
2450 void Main::editOpenFindWindow()
2452 findWindow->popup();
2453 findWindow->raise();
2454 findWindow->setActiveWindow();
2457 void Main::editFind(QString s)
2460 BranchObj *bo=currentMapEditor()->findText(s, cs);
2463 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2466 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2467 tr("No matches found for \"%1\"").arg(s));
2471 void Main::editFindChanged()
2472 { // Notify editor, to abort the current find process
2473 currentMapEditor()->findReset();
2476 void Main::openTabs(QStringList urls)
2478 if (!urls.isEmpty())
2482 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2484 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2486 QString u=urls.takeFirst();
2487 procBrowser = new QProcess( this );
2489 procBrowser->start(browser,args);
2490 if ( !procBrowser->waitForStarted())
2492 // try to set path to browser
2493 QMessageBox::warning(0,
2495 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2496 tr("Please use Settings->")+tr("Set application to open an URL"));
2501 if (browser.contains("konqueror"))
2503 for (int i=0; i<urls.size(); i++)
2506 // Try to open new tab in existing konqueror started previously by vym
2507 p=new QProcess (this);
2509 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2510 "konqueror-mainwindow#1"<<
2513 p->start ("dcop",args);
2514 if ( !p->waitForStarted() ) success=false;
2517 QMessageBox::warning(0,
2519 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2521 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2523 for (int i=0; i<urls.size(); i++)
2525 // Try to open new tab in firefox
2526 p=new QProcess (this);
2527 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2528 p->start (browser,args);
2529 if ( !p->waitForStarted() ) success=false;
2532 QMessageBox::warning(0,
2534 tr("Couldn't start %1 to open a new tab").arg(browser));
2537 QMessageBox::warning(0,
2539 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2543 void Main::editOpenURL()
2546 if (currentMapEditor())
2548 QString url=currentMapEditor()->getURL();
2550 if (url=="") return;
2551 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2552 procBrowser = new QProcess( this );
2554 procBrowser->start(browser,args);
2555 if ( !procBrowser->waitForStarted())
2557 // try to set path to browser
2558 QMessageBox::warning(0,
2560 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2561 tr("Please use Settings->")+tr("Set application to open an URL"));
2566 void Main::editOpenURLTab()
2568 if (currentMapEditor())
2571 urls.append(currentMapEditor()->getURL());
2575 void Main::editOpenMultipleURLTabs()
2577 if (currentMapEditor())
2580 urls=currentMapEditor()->getURLs();
2586 void Main::editURL()
2588 if (currentMapEditor())
2589 currentMapEditor()->editURL();
2592 void Main::editHeading2URL()
2594 if (currentMapEditor())
2595 currentMapEditor()->editHeading2URL();
2598 void Main::editBugzilla2URL()
2600 if (currentMapEditor())
2601 currentMapEditor()->editBugzilla2URL();
2604 void Main::editFATE2URL()
2606 if (currentMapEditor())
2607 currentMapEditor()->editFATE2URL();
2610 void Main::editHeading()
2612 if (lineedit->isVisible())
2614 if (currentMapEditor())
2616 MapEditor *me=currentMapEditor();
2617 QString oldSel=me->getSelectString();
2618 if (me->select (editSel))
2619 me->setHeading(lineedit->text());
2620 me->select (oldSel);
2622 lineedit->releaseKeyboard();
2627 if (currentMapEditor())
2631 QString s=currentMapEditor()->getHeading(ok,p);
2635 #if defined(Q_OS_MACX)
2636 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2637 QDialog *d =new QDialog(NULL);
2638 QLineEdit *le=new QLineEdit (d);
2639 d->setWindowFlags (Qt::FramelessWindowHint);
2640 d->setGeometry(p.x(),p.y(),200,25);
2641 le->resize (d->size());
2644 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2645 d->activateWindow();
2647 currentMapEditor()->setHeading (le->text());
2649 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2650 lineedit->setGeometry(p.x(),p.y(),200,25);
2651 lineedit->setText(s);
2652 lineedit->setCursorPosition(1);
2653 lineedit->selectAll();
2655 lineedit->grabKeyboard();
2656 lineedit->setFocus();
2658 editSel=currentMapEditor()->getSelectString();
2666 void Main::openVymLinks(const QStringList &vl)
2668 for (int j=0; j<vl.size(); j++)
2670 // compare path with already loaded maps
2674 for (i=0;i<=tabWidget->count() -1;i++)
2676 me=(MapEditor*)tabWidget->page(i);
2677 if (vl.at(j)==me->getFilePath() )
2686 if (!QFile(vl.at(j)).exists() )
2687 QMessageBox::critical( 0, tr( "Critical Error" ),
2688 tr("Couldn't open map %1").arg(vl.at(j)));
2691 fileLoad (vl.at(j), NewMap);
2692 tabWidget->setCurrentPage (tabWidget->count()-1);
2695 // Go to tab containing the map
2696 tabWidget->setCurrentPage (index);
2700 void Main::editOpenVymLink()
2702 if (currentMapEditor())
2705 vl.append(currentMapEditor()->getVymLink());
2710 void Main::editOpenMultipleVymLinks()
2712 QString currentVymLink;
2713 if (currentMapEditor())
2715 QStringList vl=currentMapEditor()->getVymLinks();
2720 void Main::editVymLink()
2722 if (currentMapEditor())
2723 currentMapEditor()->editVymLink();
2726 void Main::editDeleteVymLink()
2728 if (currentMapEditor())
2729 currentMapEditor()->deleteVymLink();
2732 void Main::editToggleHideExport()
2734 if (currentMapEditor())
2735 currentMapEditor()->toggleHideExport();
2738 void Main::editMapInfo()
2740 if (currentMapEditor())
2741 currentMapEditor()->editMapInfo();
2744 void Main::editMoveUp()
2746 if (currentMapEditor())
2747 currentMapEditor()->moveBranchUp();
2750 void Main::editMoveDown()
2752 if (currentMapEditor())
2753 currentMapEditor()->moveBranchDown();
2756 void Main::editToggleScroll()
2758 if (currentMapEditor())
2760 currentMapEditor()->toggleScroll();
2764 void Main::editUnScrollAll()
2766 if (currentMapEditor())
2768 currentMapEditor()->unScrollAll();
2772 void Main::editNewBranch()
2775 if (!lineedit->isVisible() && currentMapEditor())
2776 currentMapEditor()->addNewBranch(0);
2779 void Main::editNewBranchHere()
2781 if (currentMapEditor())
2782 currentMapEditor()->addNewBranchHere();
2785 void Main::editNewBranchAbove()
2787 if (currentMapEditor())
2788 currentMapEditor()->addNewBranch(-1);
2791 void Main::editNewBranchBelow()
2793 if (currentMapEditor())
2794 currentMapEditor()->addNewBranch(1);
2797 void Main::editImportAdd()
2799 fileLoad (ImportAdd);
2802 void Main::editImportReplace()
2804 fileLoad (ImportReplace);
2807 void Main::editSaveBranch()
2809 fileSaveAs (PartOfMap);
2812 void Main::editRemoveBranchKeepChilds()
2814 if (currentMapEditor())
2815 currentMapEditor()->removeBranchKeepChilds();
2818 void Main::editRemoveChilds()
2820 if (currentMapEditor())
2821 currentMapEditor()->removeChilds();
2824 void Main::editDeleteSelection()
2826 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2827 currentMapEditor()->deleteSelection();
2830 void Main::editUpperBranch()
2832 if (currentMapEditor())
2833 currentMapEditor()->selectUpperBranch();
2836 void Main::editLowerBranch()
2838 if (currentMapEditor())
2839 currentMapEditor()->selectLowerBranch();
2842 void Main::editLeftBranch()
2844 if (currentMapEditor())
2845 currentMapEditor()->selectLeftBranch();
2848 void Main::editRightBranch()
2850 if (currentMapEditor())
2851 currentMapEditor()->selectRightBranch();
2854 void Main::editFirstBranch()
2856 if (currentMapEditor())
2857 currentMapEditor()->selectFirstBranch();
2860 void Main::editLastBranch()
2862 if (currentMapEditor())
2863 currentMapEditor()->selectLastBranch();
2866 void Main::editLoadImage()
2868 if (currentMapEditor())
2869 currentMapEditor()->loadFloatImage();
2872 void Main::editSaveImage()
2874 if (currentMapEditor())
2875 currentMapEditor()->saveFloatImage();
2878 void Main::editFollowXLink(QAction *a)
2881 if (currentMapEditor())
2882 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2885 void Main::editEditXLink(QAction *a)
2887 if (currentMapEditor())
2888 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2891 void Main::formatSelectColor()
2893 if (currentMapEditor())
2895 QColor col = QColorDialog::getColor( currentMapEditor()->getColor(), this );
2896 if ( !col.isValid() ) return;
2897 currentMapEditor()->setColor( col );
2898 colorChanged( col );
2902 void Main::formatPickColor()
2904 if (currentMapEditor())
2905 colorChanged( currentMapEditor()->pickColor() );
2908 void Main::colorChanged(QColor c)
2910 QPixmap pix( 16, 16 );
2912 actionFormatColor->setIconSet( pix );
2915 void Main::formatColorItem()
2917 if (currentMapEditor())
2918 currentMapEditor()->colorItem();
2921 void Main::formatColorBranch()
2923 if (currentMapEditor())
2924 currentMapEditor()->colorBranch();
2927 void Main::formatLinkStyleLine()
2929 if (currentMapEditor())
2930 currentMapEditor()->setLinkStyle(StyleLine);
2933 void Main::formatLinkStyleParabel()
2935 if (currentMapEditor())
2936 currentMapEditor()->setLinkStyle(StyleParabel);
2939 void Main::formatLinkStylePolyLine()
2941 if (currentMapEditor())
2942 currentMapEditor()->setLinkStyle(StylePolyLine);
2945 void Main::formatLinkStylePolyParabel()
2947 if (currentMapEditor())
2948 currentMapEditor()->setLinkStyle(StylePolyParabel);
2951 void Main::formatSelectBackColor()
2953 if (currentMapEditor())
2954 currentMapEditor()->selectBackgroundColor();
2957 void Main::formatSelectLinkColor()
2959 if (currentMapEditor())
2960 currentMapEditor()->selectLinkColor();
2963 void Main::formatToggleLinkColorHint()
2965 currentMapEditor()->toggleLinkColorHint();
2968 void Main::formatFrameNone()
2970 if (currentMapEditor())
2971 currentMapEditor()->setFrame(NoFrame);
2974 void Main::formatFrameRectangle()
2976 if (currentMapEditor())
2977 currentMapEditor()->setFrame(Rectangle);
2980 void Main::formatIncludeImagesVer()
2982 if (currentMapEditor())
2983 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2986 void Main::formatIncludeImagesHor()
2988 if (currentMapEditor())
2989 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2992 void Main::formatHideLinkUnselected()
2994 if (currentMapEditor())
2995 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2998 void Main::viewZoomReset()
3000 if (currentMapEditor())
3004 currentMapEditor()->setWorldMatrix( m );
3005 currentMapEditor()->setViewCenter();
3006 currentMapEditor()->adjustCanvasSize();
3010 void Main::viewZoomIn()
3012 if (currentMapEditor())
3014 QMatrix m = currentMapEditor()->worldMatrix();
3015 m.scale( 1.25, 1.25 );
3016 currentMapEditor()->setWorldMatrix( m );
3017 currentMapEditor()->setViewCenter();
3018 currentMapEditor()->adjustCanvasSize();
3022 void Main::viewZoomOut()
3024 if (currentMapEditor())
3026 QMatrix m = currentMapEditor()->worldMatrix();
3027 m.scale( 0.8, 0.8 );
3028 currentMapEditor()->setWorldMatrix( m );
3029 currentMapEditor()->setViewCenter();
3030 currentMapEditor()->adjustCanvasSize();
3034 bool Main::settingsPDF()
3036 // Default browser is set in constructor
3038 QString text = QInputDialog::getText(
3039 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3040 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3042 settings.setValue ("/mainwindow/readerPDF",text);
3047 bool Main::settingsURL()
3049 // Default browser is set in constructor
3051 QString text = QInputDialog::getText(
3052 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3053 settings.value("/mainwindow/readerURL").toString()
3056 settings.setValue ("/mainwindow/readerURL",text);
3060 void Main::settingsToggleDelKey()
3062 if (actionSettingsUseDelKey->isOn())
3064 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3067 actionEditDelete->setAccel (QKeySequence (""));
3071 void Main::windowToggleNoteEditor()
3073 if (textEditor->showWithMain() )
3074 windowHideNoteEditor();
3076 windowShowNoteEditor();
3079 void Main::windowToggleHistory()
3081 if (currentMapEditor())
3082 currentMapEditor()->toggleHistoryWindow();
3085 void Main::updateNoteFlag()
3087 if (currentMapEditor())
3088 currentMapEditor()->updateNoteFlag();
3091 void Main::updateActions()
3093 MapEditor *me=currentMapEditor();
3096 // updateActions is also called when NoteEditor is closed
3097 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3100 if (me->getLinkColorHint()==HeadingColor)
3101 actionFormatLinkColorHint->setOn(true);
3103 actionFormatLinkColorHint->setOn(false);
3105 switch (me->getLinkStyle())
3108 actionFormatLinkStyleLine->setOn(true);
3111 actionFormatLinkStyleParabel->setOn(true);
3114 actionFormatLinkStylePolyLine->setOn(true);
3116 case StylePolyParabel:
3117 actionFormatLinkStylePolyParabel->setOn(true);
3123 QPixmap pix( 16, 16 );
3124 pix.fill( me->getBackgroundColor() );
3125 actionFormatBackColor->setIconSet( pix );
3126 pix.fill( me->getDefLinkColor() );
3127 actionFormatLinkColor->setIconSet( pix );
3129 actionFileSave->setEnabled( me->isUnsaved() );
3130 if (me->isUndoAvailable())
3131 actionEditUndo->setEnabled( true);
3133 actionEditUndo->setEnabled( false);
3135 if (me->isRedoAvailable())
3136 actionEditRedo->setEnabled( true);
3138 actionEditRedo->setEnabled( false);
3140 LinkableMapObj *selection=me->getSelection();
3143 if ( (typeid(*selection) == typeid(BranchObj)) ||
3144 (typeid(*selection) == typeid(MapCenterObj)) )
3146 BranchObj *bo=(BranchObj*)selection;
3147 // Take care of links
3148 if (bo->countXLinks()==0)
3150 branchXLinksContextMenuEdit->clear();
3151 branchXLinksContextMenuFollow->clear();
3156 branchXLinksContextMenuEdit->clear();
3157 branchXLinksContextMenuFollow->clear();
3158 for (int i=0; i<=bo->countXLinks();i++)
3160 bot=bo->XLinkTargetAt(i);
3163 s=bot->getHeading();
3166 branchXLinksContextMenuFollow->addAction (s);
3167 branchXLinksContextMenuEdit->addAction (s);
3172 standardFlagsDefault->setEnabled (true);
3174 actionEditToggleScroll->setEnabled (true);
3175 if ( bo->isScrolled() )
3176 actionEditToggleScroll->setOn(true);
3178 actionEditToggleScroll->setOn(false);
3180 if ( bo->getURL().isEmpty() )
3182 actionEditOpenURL->setEnabled (false);
3183 actionEditOpenURLTab->setEnabled (false);
3187 actionEditOpenURL->setEnabled (true);
3188 actionEditOpenURLTab->setEnabled (true);
3190 if ( bo->getVymLink().isEmpty() )
3192 actionEditOpenVymLink->setEnabled (false);
3193 actionEditDeleteVymLink->setEnabled (false);
3196 actionEditOpenVymLink->setEnabled (true);
3197 actionEditDeleteVymLink->setEnabled (true);
3200 if (bo->canMoveBranchUp())
3201 actionEditMoveUp->setEnabled (true);
3203 actionEditMoveUp->setEnabled (false);
3204 if (bo->canMoveBranchDown())
3205 actionEditMoveDown->setEnabled (true);
3207 actionEditMoveDown->setEnabled (false);
3210 actionEditToggleHideExport->setEnabled (true);
3211 actionEditToggleHideExport->setOn (bo->hideInExport() );
3213 actionEditCopy->setEnabled (true);
3214 actionEditCut->setEnabled (true);
3215 if (!clipboardEmpty)
3216 actionEditPaste->setEnabled (true);
3218 actionEditPaste->setEnabled (false);
3219 for (a=actionListBranches.first();a;a=actionListBranches.next())
3220 a->setEnabled(true);
3221 actionEditDelete->setEnabled (true);
3222 switch (selection->getFrameType())
3225 actionFormatFrameNone->setOn(true);
3228 actionFormatFrameRectangle->setOn(true);
3233 actionFormatIncludeImagesVer->setOn
3234 ( ((BranchObj*)selection)->getIncludeImagesVer());
3235 actionFormatIncludeImagesHor->setOn
3236 ( ((BranchObj*)selection)->getIncludeImagesHor());
3237 actionFormatHideLinkUnselected->setOn
3238 (selection->getHideLinkUnselected());
3240 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3242 FloatObj *fo=(FloatImageObj*)selection;
3243 //FIXME do this in mainwindow standardFlagsDefault->setEnabled (false);
3245 actionEditOpenURL->setEnabled (false);
3246 actionEditOpenVymLink->setEnabled (false);
3247 actionEditDeleteVymLink->setEnabled (false);
3248 actionEditToggleHideExport->setEnabled (true);
3249 actionEditToggleHideExport->setOn (fo->hideInExport() );
3252 actionEditCopy->setEnabled (true);
3253 actionEditCut->setEnabled (true);
3254 actionEditPaste->setEnabled (false);
3255 for (a=actionListBranches.first();a;a=actionListBranches.next())
3256 a->setEnabled(false);
3257 actionEditDelete->setEnabled (true);
3258 actionFormatHideLinkUnselected->setOn
3259 ( selection->getHideLinkUnselected());
3260 actionEditMoveUp->setEnabled (false);
3261 actionEditMoveDown->setEnabled (false);
3266 actionEditCopy->setEnabled (false);
3267 actionEditCut->setEnabled (false);
3268 actionEditPaste->setEnabled (false);
3269 for (a=actionListBranches.first();a;a=actionListBranches.next())
3270 a->setEnabled(false);
3272 actionEditToggleScroll->setEnabled (false);
3273 actionEditOpenURL->setEnabled (false);
3274 actionEditOpenVymLink->setEnabled (false);
3275 actionEditDeleteVymLink->setEnabled (false);
3276 actionEditHeading2URL->setEnabled (false);
3277 actionEditDelete->setEnabled (false);
3278 actionEditMoveUp->setEnabled (false);
3279 actionEditMoveDown->setEnabled (false);
3280 actionEditToggleHideExport->setEnabled (false);
3284 ModMode Main::getModMode()
3286 if (actionModModeColor->isOn()) return ModModeColor;
3287 if (actionModModeCopy->isOn()) return ModModeCopy;
3288 if (actionModModeXLink->isOn()) return ModModeXLink;
3292 bool Main::autoEdit()
3294 return actionSettingsAutoEdit->isOn();
3297 bool Main::autoSelectHeading()
3299 return actionSettingsAutoSelectHeading->isOn();
3302 bool Main::useFlagGroups()
3304 return actionSettingsUseFlagGroups->isOn();
3307 void Main::windowShowNoteEditor()
3309 textEditor->setShowWithMain(true);
3311 actionViewToggleNoteEditor->setOn (true);
3314 void Main::windowHideNoteEditor()
3316 textEditor->setShowWithMain(false);
3318 actionViewToggleNoteEditor->setOn (false);
3321 void Main::windowNextEditor()
3323 if (tabWidget->currentPageIndex() < tabWidget->count())
3324 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3327 void Main::windowPreviousEditor()
3329 if (tabWidget->currentPageIndex() >0)
3330 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3333 void Main::standardFlagChanged()
3335 currentMapEditor()->toggleStandardFlag(sender()->name());
3338 void Main::testFunction()
3340 if (!currentMapEditor()) return;
3341 currentMapEditor()->testFunction();
3344 void Main::testCommand()
3346 if (!currentMapEditor()) return;
3348 QString com = QInputDialog::getText(
3349 __VYM, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3350 if (ok) currentMapEditor()->parseAtom(com);
3353 void Main::helpDoc()
3356 #if defined(Q_OS_MACX)
3357 docpath="./vym.app/Contents/vym.pdf";
3359 // default path in SUSE LINUX
3360 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3363 if (!QFile (docpath).exists() )
3365 // relative path for easy testing in tarball
3366 docpath="doc/vym.pdf";
3367 if (!QFile (docpath).exists() )
3369 // relative path for testing while still writing vym.tex
3370 docpath="doc/tex/vym.pdf";
3371 if (!QFile (docpath).exists() )
3373 // Try yet another one for Knoppix
3374 docpath="/usr/share/doc/packages/vym/vym.pdf";
3375 if (!QFile (docpath).exists() )
3377 QMessageBox::critical(0,
3378 tr("Critcal error"),
3379 tr("Couldn't find the documentation\n"
3380 "vym.pdf in various places."));
3387 Process *pdfProc = new Process();
3388 pdfProc->clearArguments();
3389 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3390 pdfProc->addArgument( docpath);
3392 if ( !pdfProc->start() )
3395 QMessageBox::warning(0,
3397 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3398 tr("Please use Settings->")+tr("Set application to open PDF files"));
3405 void Main::helpAbout()
3408 ad.setName ("aboutwindow");
3409 ad.setMinimumSize(500,500);
3410 ad.resize (QSize (500,500));
3414 void Main::helpAboutQT()
3416 QMessageBox::aboutQt( this, "Qt Application Example" );