1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "branchpropwindow.h"
9 #include "exportoofiledialog.h"
11 #include "exportxhtmldialog.h"
13 #include "flagrowobj.h"
14 #include "historywindow.h"
16 #include "mapeditor.h"
21 #include "texteditor.h"
22 #include "warningdialog.h"
24 extern TextEditor *textEditor;
25 extern Main *mainWindow;
26 extern QString tmpVymDir;
27 extern QString clipboardDir;
28 extern bool clipboardEmpty;
29 extern int statusbarTime;
30 extern FlagRowObj* standardFlagsDefault;
31 extern FlagRowObj* systemFlagsDefault;
32 extern QString vymName;
33 extern QString vymVersion;
34 extern QString vymBuildDate;
36 QMenu* branchContextMenu;
37 QMenu* branchAddContextMenu;
38 QMenu* branchRemoveContextMenu;
39 QMenu* branchLinksContextMenu;
40 QMenu* branchXLinksContextMenuEdit;
41 QMenu* branchXLinksContextMenuFollow;
42 QMenu* floatimageContextMenu;
43 QMenu* canvasContextMenu;
44 QMenu* fileLastMapsMenu;
45 QMenu* fileImportMenu;
46 QMenu* fileExportMenu;
49 extern Settings settings;
50 extern Options options;
51 extern ImageIO imageIO;
53 extern QDir vymBaseDir;
54 extern QDir lastImageDir;
55 extern QDir lastFileDir;
56 extern QString iconPath;
57 extern QString flagsPath;
59 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
60 QMainWindow(parent,name,f)
64 setCaption ("VYM - View Your Mind");
66 // Load window settings
67 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
68 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
71 // Sometimes we may need to remember old selections
75 currentColor=Qt::black;
77 // Create unique temporary directory
79 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
82 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
86 // Create direcctory for clipboard
87 clipboardDir=tmpVymDir+"/clipboard";
89 d.mkdir (clipboardDir,true);
90 makeSubDirs (clipboardDir);
95 // Initialize history window;
96 historyWindow=new HistoryWindow();
98 // Initialize properties window
99 branchPropertyWindow = new BranchPropertyWindow();
100 branchPropertyWindow->move (20,20);
102 // Initialize script editor
103 scriptEditor = new SimpleScriptEditor();
104 scriptEditor->move (50,50);
106 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
107 this, SLOT( runScript( QString ) ) );
109 // Initialize some settings, which are platform dependant
112 // application to open URLs
113 p="/mainwindow/readerURL";
114 #if defined(Q_OS_LINUX)
115 s=settings.value (p,"konqueror").toString();
117 #if defined(Q_OS_MACX)
118 s=settings.value (p,"/usr/bin/open").toString();
120 s=settings.value (p,"mozilla");
123 settings.setValue( p,s);
125 // application to open PDFs
126 p="/mainwindow/readerPDF";
127 #if defined(Q_OS_LINUX)
128 s=settings.value (p,"acroread").toString();
130 #if defined(Q_OS_MACX)
131 s=settings.value (p,"/usr/bin/open").toString();
133 s=settings.value (p,"acroread").toString();
136 settings.setValue( p,s);
139 // Create tab widget which holds the maps
140 tabWidget= new QTabWidget (this);
141 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
142 this, SLOT( editorChanged( QWidget * ) ) );
144 lineedit=new QLineEdit (this);
147 setCentralWidget(tabWidget);
151 setupFormatActions();
155 setupSettingsActions();
158 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
163 restoreState (settings.value("/mainwindow/state",0).toByteArray());
165 // Satellite windows //////////////////////////////////////////
167 // Initialize Find window
168 findWindow=new FindWindow(NULL);
169 findWindow->move (x(),y()+70);
170 connect (findWindow, SIGNAL( findButton(QString) ),
171 this, SLOT(editFind(QString) ) );
172 connect (findWindow, SIGNAL( somethingChanged() ),
173 this, SLOT(editFindChanged() ) );
175 // Connect TextEditor, so that we can update flags if text changes
176 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
177 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
179 // Connect HistoryWindow, so that we can update flags
180 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
188 settings.setValue ( "/mainwindow/geometry/size", size() );
189 settings.setValue ( "/mainwindow/geometry/pos", pos() );
190 settings.setValue ("/mainwindow/state",saveState(0));
192 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
193 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
194 settings.setValue( "/version/version", vymVersion );
195 settings.setValue( "/version/builddate", vymBuildDate );
197 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
198 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
199 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
200 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
201 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
202 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
204 //FIXME save branchPropWindow settings
205 //FIXME save scriptEditor settings
207 // call the destructors
209 delete historyWindow;
211 // Remove temporary directory
212 removeDir (QDir(tmpVymDir));
215 void Main::loadCmdLine()
217 /* TODO draw some kind of splashscreen while loading...
223 QStringList flist=options.getFileList();
224 QStringList::Iterator it=flist.begin();
226 while (it !=flist.end() )
228 fileLoad (*it, NewMap);
234 void Main::statusMessage(const QString &s)
236 statusBar()->message (s);
239 void Main::closeEvent (QCloseEvent* )
245 void Main::setupFileActions()
247 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
248 QToolBar *tb = addToolBar( tr ("&Map") );
249 tb->setObjectName ("mapTB");
252 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
253 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
254 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
256 fileMenu->addAction (a);
257 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
259 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
260 a->setStatusTip (tr( "Open","Status tip File menu" ) );
261 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
263 fileMenu->addAction (a);
264 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
266 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
267 fileMenu->addSeparator();
269 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
270 a->setStatusTip ( tr( "Save","Status tip file menu" ));
271 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
273 fileMenu->addAction (a);
274 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
277 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
278 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
279 fileMenu->addAction (a);
280 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
282 fileMenu->addSeparator();
284 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
286 a = new QAction(tr("KDE Bookmarks"), this);
287 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
288 a->addTo (fileImportMenu);
289 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
291 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
293 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
294 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
295 a->addTo (fileImportMenu);
296 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
299 a = new QAction("Mind Manager...",this);
300 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
301 fileImportMenu->addAction (a);
302 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
304 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
305 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
306 fileImportMenu->addAction (a);
307 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
309 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
311 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
312 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
313 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
314 fileExportMenu->addAction (a);
316 a = new QAction( "Open Office...", this);
317 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
318 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
319 fileExportMenu->addAction (a);
321 a = new QAction( "Webpage (XHTML)...",this );
322 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
323 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
324 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
325 fileExportMenu->addAction (a);
327 a = new QAction( "Text (ASCII)...", this);
328 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
329 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
330 fileExportMenu->addAction (a);
332 a = new QAction( tr("KDE Bookmarks","File menu"), this);
333 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
334 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
335 fileExportMenu->addAction (a);
337 a = new QAction( "Taskjuggler...", this );
338 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
339 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
340 fileExportMenu->addAction (a);
342 a = new QAction( "LaTeX...", this);
343 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
344 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
345 fileExportMenu->addAction (a);
347 a = new QAction( "XML..." , this );
348 a->setStatusTip (tr( "Export as %1").arg("XML"));
349 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
350 fileExportMenu->addAction (a);
352 fileMenu->addSeparator();
354 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
355 a->setStatusTip ( tr( "Print" ,"File menu") );
356 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
358 fileMenu->addAction (a);
359 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
362 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
363 a->setStatusTip (tr( "Close Map" ) );
364 a->setShortcut (Qt::ALT + Qt::Key_C ); //Close map
365 fileMenu->addAction (a);
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
368 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
369 a->setStatusTip ( tr( "Exit")+" "+vymName );
370 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
371 fileMenu->addAction (a);
372 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
377 void Main::setupEditActions()
379 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
380 tb->setLabel( "Edit Actions" );
381 tb->setObjectName ("actionsTB");
382 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
386 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
387 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
388 a->setStatusTip (tr( "Undo" ) );
389 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
390 a->setEnabled (false);
392 editMenu->addAction (a);
395 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
396 a->setStatusTip (tr( "Redo" ));
397 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
399 editMenu->addAction (a);
400 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
403 editMenu->addSeparator();
404 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
405 a->setStatusTip ( tr( "Copy" ) );
406 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
407 a->setEnabled (false);
409 editMenu->addAction (a);
410 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
413 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
414 a->setStatusTip ( tr( "Cut" ) );
415 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
416 a->setEnabled (false);
418 editMenu->addAction (a);
420 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
422 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
423 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
424 a->setStatusTip ( tr( "Paste" ) );
425 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
426 a->setEnabled (false);
428 editMenu->addAction (a);
431 // Shortcuts to modify heading:
432 a = new QAction(tr( "Edit heading","Edit menu" ),this);
433 a->setStatusTip ( tr( "edit Heading" ));
434 a->setShortcut ( Qt::Key_Enter); //Edit heading
435 // a->setShortcutContext (Qt::WindowShortcut);
437 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
438 actionListBranches.append(a);
439 a = new QAction( tr( "Edit heading","Edit menu" ), this);
440 a->setStatusTip (tr( "edit Heading" ));
441 a->setShortcut (Qt::Key_Return ); //Edit heading
442 //a->setShortcutContext (Qt::WindowShortcut);
444 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
445 actionListBranches.append(a);
446 editMenu->addAction (a);
448 a = new QAction( tr( "Edit heading","Edit menu" ), this);
449 a->setStatusTip (tr( "edit Heading" ));
450 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
451 a->setShortcutContext (Qt::WindowShortcut);
453 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
454 actionListBranches.append(a);
456 // Shortcut to delete selection
457 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
458 a->setStatusTip (tr( "Delete Selection" ));
459 a->setShortcut ( Qt::Key_Delete); //Delete selection
460 a->setShortcutContext (Qt::WindowShortcut);
462 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
465 // Shortcut to add branch
466 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
467 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
468 alt->setShortcut (Qt::Key_A); //Add branch
469 alt->setShortcutContext (Qt::WindowShortcut);
471 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
472 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
473 a->setStatusTip ( tr( "Add a branch as child of selection" ));
474 a->setShortcut (Qt::Key_Insert); //Add branch
475 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
476 actionListBranches.append(a);
477 #if defined (Q_OS_MACX)
478 // In OSX show different shortcut in menues, the keys work indepently always
479 actionEditAddBranch=alt;
481 actionEditAddBranch=a;
483 editMenu->addAction (actionEditAddBranch);
484 tb->addAction (actionEditAddBranch);
487 // Add branch by inserting it at selection
488 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
489 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
490 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
491 a->setShortcutContext (Qt::WindowShortcut);
493 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
494 a->setEnabled (false);
495 actionListBranches.append(a);
496 actionEditAddBranchBefore=a;
497 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
498 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
499 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
500 a->setShortcutContext (Qt::WindowShortcut);
502 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
503 actionListBranches.append(a);
506 a = new QAction(tr( "Add branch above","Edit menu" ), this);
507 a->setStatusTip ( tr( "Add a branch above selection" ));
508 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
509 a->setShortcutContext (Qt::WindowShortcut);
511 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
512 a->setEnabled (false);
513 actionListBranches.append(a);
514 actionEditAddBranchAbove=a;
515 a = new QAction(tr( "Add branch above","Edit menu" ), this);
516 a->setStatusTip ( tr( "Add a branch above selection" ));
517 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
518 a->setShortcutContext (Qt::WindowShortcut);
520 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
521 actionListBranches.append(a);
524 a = new QAction(tr( "Add branch below","Edit menu" ), this);
525 a->setStatusTip ( tr( "Add a branch below selection" ));
526 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
527 a->setShortcutContext (Qt::WindowShortcut);
529 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
530 a->setEnabled (false);
531 actionListBranches.append(a);
532 actionEditAddBranchBelow=a;
533 a = new QAction(tr( "Add branch below","Edit menu" ), this);
534 a->setStatusTip ( tr( "Add a branch below selection" ));
535 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
536 a->setShortcutContext (Qt::WindowShortcut);
538 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
539 actionListBranches.append(a);
541 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
542 a->setStatusTip ( tr( "Move branch up" ) );
543 a->setShortcut (Qt::Key_PageUp ); // Move branch up
544 a->setEnabled (false);
546 editMenu->addAction (a);
547 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
550 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
551 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
552 a->setStatusTip (tr( "Move branch down" ) );
553 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
554 a->setEnabled (false);
556 editMenu->addAction (a);
557 actionEditMoveDown=a;
560 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
561 a->setShortcut ( Qt::Key_ScrollLock );
562 a->setStatusTip (tr( "Scroll branch" ) );
563 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
565 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
566 alt->setShortcut ( Qt::Key_S ); // Scroll branch
567 alt->setStatusTip (tr( "Scroll branch" ));
568 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
569 #if defined(Q_OS_MACX)
570 actionEditToggleScroll=alt;
572 actionEditToggleScroll=a;
574 actionEditToggleScroll->setEnabled (false);
575 actionEditToggleScroll->setToggleAction(true);
576 tb->addAction (actionEditToggleScroll);
577 editMenu->addAction ( actionEditToggleScroll);
578 editMenu->addAction (actionEditToggleScroll);
581 actionListBranches.append(actionEditToggleScroll);
583 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
584 a->setStatusTip (tr( "Unscroll all" ));
585 editMenu->addAction (a);
586 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
588 editMenu->addSeparator();
590 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
591 a->setStatusTip (tr( "Find" ) );
592 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
593 editMenu->addAction (a);
594 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
596 editMenu->addSeparator();
598 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
599 a->setShortcut (Qt::CTRL + Qt::Key_U );
600 a->setShortcut (tr( "Open URL" ));
603 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
606 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
607 a->setStatusTip (tr( "Open URL in new tab" ));
608 a->setShortcut (Qt::CTRL+Qt::Key_U );
610 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
611 actionEditOpenURLTab=a;
613 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
614 a->setStatusTip (tr( "Open all URLs in subtree" ));
616 actionListBranches.append(a);
617 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
618 actionEditOpenMultipleURLTabs=a;
620 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
621 a->setStatusTip ( tr( "Edit URL" ) );
622 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
623 //a->setShortcut ( Qt::Key_U );
624 a->setShortcutContext (Qt::WindowShortcut);
625 actionListBranches.append(a);
627 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
630 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
631 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
635 actionEditHeading2URL=a;
637 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
638 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
639 a->setEnabled (false);
640 actionListBranches.append(a);
641 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
642 actionEditBugzilla2URL=a;
644 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
645 a->setStatusTip ( tr( "Create URL to FATE" ));
646 a->setEnabled (false);
647 actionListBranches.append(a);
648 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
649 actionEditFATE2URL=a;
651 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
652 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
654 a->setEnabled (false);
655 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
656 actionEditOpenVymLink=a;
658 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
659 a->setStatusTip ( tr( "Open all vym links in subtree" ));
660 a->setEnabled (false);
661 actionListBranches.append(a);
662 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
663 actionEditOpenMultipleVymLinks=a;
666 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
667 a->setEnabled (false);
668 a->setStatusTip ( tr( "Edit link to another vym map" ));
669 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
670 actionListBranches.append(a);
673 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
674 a->setStatusTip ( tr( "Delete link to another vym map" ));
675 a->setEnabled (false);
676 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
677 actionEditDeleteVymLink=a;
679 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
680 a->setStatusTip ( tr( "Hide object in exports" ) );
681 a->setShortcut (Qt::Key_H );
682 a->setToggleAction(true);
684 a->setEnabled (false);
685 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
686 actionEditToggleHideExport=a;
688 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
689 a->setStatusTip ( tr( "Edit Map Info" ));
690 a->setEnabled (true);
691 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
694 // Import at selection (adding to selection)
695 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
696 a->setStatusTip (tr( "Add map at selection" ));
697 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
698 a->setEnabled (false);
699 actionListBranches.append(a);
700 actionEditImportAdd=a;
702 // Import at selection (replacing selection)
703 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
704 a->setStatusTip (tr( "Replace selection with map" ));
705 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
706 a->setEnabled (false);
707 actionListBranches.append(a);
708 actionEditImportReplace=a;
711 a = new QAction( tr( "Save selection","Edit menu" ), this);
712 a->setStatusTip (tr( "Save selection" ));
713 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
714 a->setEnabled (false);
715 actionListBranches.append(a);
716 actionEditSaveBranch=a;
718 // Only remove branch, not its childs
719 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
720 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
721 a->setShortcut (Qt::ALT + Qt::Key_Delete );
722 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
723 a->setEnabled (false);
725 actionListBranches.append(a);
726 actionEditDeleteKeepChilds=a;
728 // Only remove childs of a branch
729 a = new QAction( tr( "Remove childs","Edit menu" ), this);
730 a->setStatusTip (tr( "Remove childs of branch" ));
731 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
732 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
733 a->setEnabled (false);
734 actionListBranches.append(a);
735 actionEditDeleteChilds=a;
737 // Shortcuts for navigating with cursor:
738 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
739 a->setStatusTip ( tr( "Select upper branch" ));
740 a->setShortcut (Qt::Key_Up );
741 a->setShortcutContext (Qt::WindowShortcut);
743 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
744 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
745 a->setStatusTip (tr( "Select lower branch" ));
746 a->setShortcut ( Qt::Key_Down );
747 a->setShortcutContext (Qt::WindowShortcut);
749 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
750 a = new QAction(tr( "Select left branch","Edit menu" ), this);
751 a->setStatusTip ( tr( "Select left branch" ));
752 a->setShortcut (Qt::Key_Left );
753 a->setShortcutContext (Qt::WindowShortcut);
755 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
756 a = new QAction( tr( "Select child branch","Edit menu" ), this);
757 a->setStatusTip (tr( "Select right branch" ));
758 a->setShortcut (Qt::Key_Right);
759 a->setShortcutContext (Qt::WindowShortcut);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
762 a = new QAction( tr( "Select first branch","Edit menu" ), this);
763 a->setStatusTip (tr( "Select first branch" ));
764 a->setShortcut (Qt::Key_Home );
765 a->setShortcutContext (Qt::WindowShortcut);
767 a->setEnabled (false);
768 editMenu->addAction (a);
769 actionListBranches.append(a);
770 actionEditSelectFirst=a;
771 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
772 a = new QAction( tr( "Select last branch","Edit menu" ),this);
773 a->setStatusTip (tr( "Select last branch" ));
774 a->setShortcut ( Qt::Key_End );
775 a->setShortcutContext (Qt::WindowShortcut);
777 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
778 a->setEnabled (false);
779 editMenu->addAction (a);
780 actionListBranches.append(a);
781 actionEditSelectLast=a;
783 a = new QAction( tr( "Add Image...","Edit menu" ), this);
784 a->setStatusTip (tr( "Add Image" ));
785 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
786 actionEditLoadImage=a;
788 a = new QAction( tr( "Property Dialog","Dialog to edit properties of selection" )+QString ("..."), this);
789 a->setStatusTip (tr( "Set properties for selection" ));
790 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
791 a->setShortcutContext (Qt::WindowShortcut);
793 connect( a, SIGNAL( triggered() ), this, SLOT( showPropertyDialog() ) );
794 actionTogglePropertyDialog=a;
798 void Main::setupFormatActions()
800 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
802 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
803 tb->setObjectName ("formatTB");
806 pix.fill (Qt::black);
807 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
808 a->setStatusTip ( tr( "Set Color" ));
809 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
811 formatMenu->addAction (a);
813 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
814 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
815 a->setShortcut (Qt::CTRL + Qt::Key_K );
816 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
817 a->setEnabled (false);
819 formatMenu->addAction (a);
820 actionListBranches.append(a);
821 actionFormatPickColor=a;
823 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
824 a->setStatusTip ( tr( "Color branch" ) );
825 a->setShortcut (Qt::CTRL + Qt::Key_B);
826 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
827 a->setEnabled (false);
829 formatMenu->addAction (a);
830 actionListBranches.append(a);
831 actionFormatColorSubtree=a;
833 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
834 a->setStatusTip ( tr( "Color Subtree" ));
835 a->setShortcut (Qt::CTRL + Qt::Key_T);
836 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
837 a->setEnabled (false);
838 formatMenu->addAction (a);
840 actionListBranches.append(a);
841 actionFormatColorSubtree=a;
843 formatMenu->addSeparator();
844 actionGroupFormatLinkStyles=new QActionGroup ( this);
845 actionGroupFormatLinkStyles->setExclusive (true);
846 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
847 a->setStatusTip (tr( "Line" ));
848 a->setToggleAction(true);
849 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
850 formatMenu->addAction (a);
851 actionFormatLinkStyleLine=a;
852 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
853 a->setStatusTip (tr( "Line" ));
854 a->setToggleAction(true);
855 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
856 formatMenu->addAction (a);
857 actionFormatLinkStyleParabel=a;
858 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
859 a->setStatusTip (tr( "PolyLine" ));
860 a->setToggleAction(true);
861 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
862 formatMenu->addAction (a);
863 actionFormatLinkStylePolyLine=a;
864 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
865 a->setStatusTip (tr( "PolyParabel" ) );
866 a->setToggleAction(true);
867 a->setChecked (true);
868 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
869 formatMenu->addAction (a);
870 actionFormatLinkStylePolyParabel=a;
872 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
873 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
874 a->setToggleAction(true);
875 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
876 actionFormatIncludeImagesVer=a;
878 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
879 a->setStatusTip ( tr ("Include left and right position of images into branch"));
880 a->setToggleAction(true);
881 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
882 actionFormatIncludeImagesHor=a;
884 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
885 a->setStatusTip (tr( "Hide link" ));
886 a->setToggleAction(true);
887 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
888 actionFormatHideLinkUnselected=a;
890 formatMenu->addSeparator();
891 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
892 a->setStatusTip (tr( "Use same color for links and headings" ));
893 a->setToggleAction(true);
894 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
895 formatMenu->addAction (a);
896 actionFormatLinkColorHint=a;
898 pix.fill (Qt::white);
899 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
900 a->setStatusTip (tr( "Set Link Color" ));
901 formatMenu->addAction (a);
902 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
903 actionFormatLinkColor=a;
905 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
906 a->setStatusTip (tr( "Set Selection Color" ));
907 formatMenu->addAction (a);
908 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
909 actionFormatSelectionColor=a;
911 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
912 a->setStatusTip (tr( "Set Background Color" ));
913 formatMenu->addAction (a);
914 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
915 actionFormatBackColor=a;
917 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
918 a->setStatusTip (tr( "Set Background image" ));
919 formatMenu->addAction (a);
920 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
921 actionFormatBackImage=a;
925 void Main::setupViewActions()
927 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
928 tb->setLabel( "View Actions" );
929 tb->setObjectName ("viewTB");
930 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
933 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
934 a->setStatusTip ( tr( "Zoom reset" ) );
935 a->setShortcut (Qt::CTRL + Qt::Key_0 );
937 viewMenu->addAction (a);
938 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
940 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
941 a->setStatusTip (tr( "Zoom in" ));
942 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
944 viewMenu->addAction (a);
945 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
947 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
948 a->setStatusTip (tr( "Zoom out" ));
949 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
951 viewMenu->addAction (a);
952 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
955 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
956 a->setStatusTip ( tr( "Show Note Editor" ));
957 a->setShortcut ( Qt::CTRL + Qt::Key_E );
958 a->setToggleAction(true);
959 if (textEditor->showWithMain())
964 viewMenu->addAction (a);
965 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
966 actionViewToggleNoteEditor=a;
968 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
969 a->setStatusTip ( tr( "Show History Window" ));
970 a->setShortcut ( Qt::CTRL + Qt::Key_H );
971 a->setToggleAction(true);
973 viewMenu->addAction (a);
974 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
975 actionViewToggleHistoryWindow=a;
977 viewMenu->addAction (actionTogglePropertyDialog );
979 a = new QAction(tr( "Antialiasing","View action" ),this );
980 a->setStatusTip ( tr( "Antialiasing" ));
981 a->setToggleAction(true);
982 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
983 viewMenu->addAction (a);
984 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
985 actionViewToggleAntiAlias=a;
987 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
988 a->setStatusTip (a->text());
989 a->setToggleAction(true);
990 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
991 viewMenu->addAction (a);
992 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
993 actionViewToggleSmoothPixmapTransform=a;
995 a = new QAction(tr( "Next Window","View action" ), this);
996 a->setStatusTip (a->text());
997 a->setShortcut (Qt::ALT + Qt::Key_N );
998 viewMenu->addAction (a);
999 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1001 a = new QAction (tr( "Previous Window","View action" ), this );
1002 a->setStatusTip (a->text());
1003 a->setShortcut (Qt::ALT + Qt::Key_P );
1004 viewMenu->addAction (a);
1005 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1009 void Main::setupModeActions()
1011 //QPopupMenu *menu = new QPopupMenu( this );
1012 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1014 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1015 tb->setObjectName ("modesTB");
1017 actionGroupModModes=new QActionGroup ( this);
1018 actionGroupModModes->setExclusive (true);
1019 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1020 a->setShortcut (Qt::Key_J);
1021 a->setStatusTip ( tr( "Use modifier to color branches" ));
1022 a->setToggleAction(true);
1025 actionModModeColor=a;
1027 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1028 a->setShortcut( Qt::Key_K);
1029 a->setStatusTip( tr( "Use modifier to copy" ));
1030 a->setToggleAction(true);
1032 actionModModeCopy=a;
1034 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1035 a->setShortcut (Qt::Key_L);
1036 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1037 a->setToggleAction(true);
1039 actionModModeXLink=a;
1043 void Main::setupFlagActions()
1045 // Create System Flags
1046 systemFlagsDefault = new FlagRowObj ();
1047 systemFlagsDefault->setVisibility (false);
1048 systemFlagsDefault->setName ("systemFlagsDef");
1050 FlagObj *fo = new FlagObj ();
1051 fo->load(QPixmap(flagsPath+"flag-note.png"));
1052 fo->setName("note");
1053 fo->setToolTip(tr("Note","Systemflag"));
1054 systemFlagsDefault->addFlag (fo); // makes deep copy
1056 fo->load(QPixmap(flagsPath+"flag-url.png"));
1058 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1059 systemFlagsDefault->addFlag (fo);
1061 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1062 fo->setName("vymLink");
1063 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1064 systemFlagsDefault->addFlag (fo);
1066 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1067 fo->setName("scrolledright");
1068 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1069 systemFlagsDefault->addFlag (fo);
1071 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1072 fo->setName("tmpUnscrolledright");
1073 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1074 systemFlagsDefault->addFlag (fo);
1076 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1077 fo->setName("hideInExport");
1078 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1079 systemFlagsDefault->addFlag (fo);
1081 // Create Standard Flags
1082 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1083 tb->setObjectName ("standardFlagTB");
1085 standardFlagsDefault = new FlagRowObj ();
1086 standardFlagsDefault->setVisibility (false);
1087 standardFlagsDefault->setName ("standardFlagsDef");
1088 standardFlagsDefault->setToolBar (tb);
1090 fo->load(flagsPath+"flag-exclamationmark.png");
1091 fo->setName ("exclamationmark");
1092 fo->setGroup("standard-mark");
1093 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1096 a->setCheckable(true);
1097 a->setObjectName(fo->getName());
1098 a->setToolTip(tr("Take care!","Standardflag"));
1099 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1100 standardFlagsDefault->addFlag (fo); // makes deep copy
1102 fo->load(flagsPath+"flag-questionmark.png");
1103 fo->setName("questionmark");
1104 fo->setGroup("standard-mark");
1105 a=new QAction (fo->getPixmap(),fo->getName(),this);
1108 a->setCheckable(true);
1109 a->setObjectName(fo->getName());
1110 a->setToolTip(tr("Really?","Standardflag"));
1111 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1112 standardFlagsDefault->addFlag (fo);
1114 fo->load(flagsPath+"flag-hook-green.png");
1115 fo->setName("hook-green");
1116 fo->setGroup("standard-hook");
1117 a=new QAction (fo->getPixmap(),fo->getName(),this);
1120 a->setCheckable(true);
1121 a->setObjectName(fo->getName());
1122 a->setToolTip(tr("ok!","Standardflag"));
1123 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1124 standardFlagsDefault->addFlag (fo);
1126 fo->load(flagsPath+"flag-cross-red.png");
1127 fo->setName("cross-red");
1128 fo->setGroup("standard-hook");
1129 a=new QAction (fo->getPixmap(),fo->getName(),this);
1132 a->setCheckable(true);
1133 a->setObjectName(fo->getName());
1134 a->setToolTip(tr("Not ok!","Standardflag"));
1135 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1136 standardFlagsDefault->addFlag (fo);
1138 fo->load(flagsPath+"flag-stopsign.png");
1139 fo->setName("stopsign");
1140 a=new QAction (fo->getPixmap(),fo->getName(),this);
1143 a->setCheckable(true);
1144 a->setObjectName(fo->getName());
1145 a->setToolTip(tr("This won't work!","Standardflag"));
1146 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1147 standardFlagsDefault->addFlag (fo);
1149 fo->load(flagsPath+"flag-smiley-good.png");
1150 fo->setName("smiley-good");
1151 fo->setGroup("standard-smiley");
1152 a=new QAction (fo->getPixmap(),fo->getName(),this);
1155 a->setCheckable(true);
1156 a->setObjectName(fo->getName());
1157 a->setToolTip(tr("Good","Standardflag"));
1158 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1159 standardFlagsDefault->addFlag (fo);
1161 fo->load(flagsPath+"flag-smiley-sad.png");
1162 fo->setName("smiley-sad");
1163 fo->setGroup("standard-smiley");
1164 a=new QAction (fo->getPixmap(),fo->getName(),this);
1167 a->setCheckable(true);
1168 a->setObjectName(fo->getName());
1169 a->setToolTip(tr("Bad","Standardflag"));
1170 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1171 standardFlagsDefault->addFlag (fo);
1173 fo->load(flagsPath+"flag-smiley-omg.png");
1174 // Original omg.png (in KDE emoticons)
1175 fo->setName("smiley-omg");
1176 fo->setGroup("standard-smiley");
1177 a=new QAction (fo->getPixmap(),fo->getName(),this);
1180 a->setCheckable(true);
1181 a->setObjectName(fo->getName());
1182 a->setToolTip(tr("Oh no!","Standardflag"));
1183 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1184 standardFlagsDefault->addFlag (fo);
1186 fo->load(flagsPath+"flag-kalarm.png");
1187 fo->setName("clock");
1188 a=new QAction (fo->getPixmap(),fo->getName(),this);
1191 a->setCheckable(true);
1192 a->setObjectName(fo->getName());
1193 a->setToolTip(tr("Time critical","Standardflag"));
1194 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1195 standardFlagsDefault->addFlag (fo);
1197 fo->load(flagsPath+"flag-phone.png");
1198 fo->setName("phone");
1199 a=new QAction (fo->getPixmap(),fo->getName(),this);
1202 a->setCheckable(true);
1203 a->setObjectName(fo->getName());
1204 a->setToolTip(tr("Call...","Standardflag"));
1205 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1206 standardFlagsDefault->addFlag (fo);
1208 fo->load(flagsPath+"flag-lamp.png");
1209 fo->setName("lamp");
1210 a=new QAction (fo->getPixmap(),fo->getName(),this);
1213 a->setCheckable(true);
1214 a->setObjectName(fo->getName());
1215 a->setToolTip(tr("Idea!","Standardflag"));
1216 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1217 standardFlagsDefault->addFlag (fo);
1219 fo->load(flagsPath+"flag-arrow-up.png");
1220 fo->setName("arrow-up");
1221 fo->setGroup("standard-arrow");
1222 a=new QAction (fo->getPixmap(),fo->getName(),this);
1225 a->setCheckable(true);
1226 a->setObjectName(fo->getName());
1227 a->setToolTip(tr("Important","Standardflag"));
1228 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1229 standardFlagsDefault->addFlag (fo);
1231 fo->load(flagsPath+"flag-arrow-down.png");
1232 fo->setName("arrow-down");
1233 fo->setGroup("standard-arrow");
1234 a=new QAction (fo->getPixmap(),fo->getName(),this);
1237 a->setCheckable(true);
1238 a->setObjectName(fo->getName());
1239 a->setToolTip(tr("Unimportant","Standardflag"));
1240 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1241 standardFlagsDefault->addFlag (fo);
1243 fo->load(flagsPath+"flag-arrow-2up.png");
1244 fo->setName("2arrow-up");
1245 fo->setGroup("standard-arrow");
1246 a=new QAction (fo->getPixmap(),fo->getName(),this);
1249 a->setCheckable(true);
1250 a->setObjectName(fo->getName());
1251 a->setToolTip(tr("Very important!","Standardflag"));
1252 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1253 standardFlagsDefault->addFlag (fo);
1255 fo->load(flagsPath+"flag-arrow-2down.png");
1256 fo->setName("2arrow-down");
1257 fo->setGroup("standard-arrow");
1258 a=new QAction (fo->getPixmap(),fo->getName(),this);
1261 a->setCheckable(true);
1262 a->setObjectName(fo->getName());
1263 a->setToolTip(tr("Very unimportant!","Standardflag"));
1264 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1265 standardFlagsDefault->addFlag (fo);
1267 fo->load(flagsPath+"flag-thumb-up.png");
1268 fo->setName("thumb-up");
1269 fo->setGroup("standard-thumb");
1270 a=new QAction (fo->getPixmap(),fo->getName(),this);
1273 a->setCheckable(true);
1274 a->setObjectName(fo->getName());
1275 a->setToolTip(tr("I like this","Standardflag"));
1276 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1277 standardFlagsDefault->addFlag (fo);
1279 fo->load(flagsPath+"flag-thumb-down.png");
1280 fo->setName("thumb-down");
1281 fo->setGroup("standard-thumb");
1282 a=new QAction (fo->getPixmap(),fo->getName(),this);
1285 a->setCheckable(true);
1286 a->setObjectName(fo->getName());
1287 a->setToolTip(tr("I do not like this","Standardflag"));
1288 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1289 standardFlagsDefault->addFlag (fo);
1291 fo->load(flagsPath+"flag-rose.png");
1292 fo->setName("rose");
1293 a=new QAction (fo->getPixmap(),fo->getName(),this);
1296 a->setCheckable(true);
1297 a->setObjectName(fo->getName());
1298 a->setToolTip(tr("Rose","Standardflag"));
1299 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1300 standardFlagsDefault->addFlag (fo);
1302 fo->load(flagsPath+"flag-heart.png");
1303 fo->setName("heart");
1304 a=new QAction (fo->getPixmap(),fo->getName(),this);
1306 a->setCheckable(true);
1307 a->setObjectName(fo->getName());
1308 a->setToolTip(tr("I just love... ","Standardflag"));
1309 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1310 standardFlagsDefault->addFlag (fo);
1312 fo->load(flagsPath+"flag-present.png");
1313 fo->setName("present");
1314 a=new QAction (fo->getPixmap(),fo->getName(),this);
1317 a->setCheckable(true);
1318 a->setObjectName(fo->getName());
1319 a->setToolTip(tr("Surprise!","Standardflag"));
1320 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1321 standardFlagsDefault->addFlag (fo);
1323 fo->load(flagsPath+"flag-flash.png");
1324 fo->setName("flash");
1325 a=new QAction (fo->getPixmap(),fo->getName(),this);
1328 a->setCheckable(true);
1329 a->setObjectName(fo->getName());
1330 a->setToolTip(tr("Dangerous","Standardflag"));
1331 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1332 standardFlagsDefault->addFlag (fo);
1334 fo->load(flagsPath+"flag-info.png");
1335 // Original: xsldbg_output.png
1336 fo->setName("info");
1337 a=new QAction (fo->getPixmap(),fo->getName(),this);
1340 a->setCheckable(true);
1341 a->setObjectName(fo->getName());
1342 a->setToolTip(tr("Info","Standardflag"));
1343 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1344 standardFlagsDefault->addFlag (fo);
1346 fo->load(flagsPath+"flag-lifebelt.png");
1347 // Original khelpcenter.png
1348 fo->setName("lifebelt");
1349 a=new QAction (fo->getPixmap(),fo->getName(),this);
1352 a->setCheckable(true);
1353 a->setObjectName(fo->getName());
1354 a->setToolTip(tr("This will help","Standardflag"));
1355 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1356 standardFlagsDefault->addFlag (fo);
1362 void Main::setupSettingsActions()
1364 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1368 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1369 a->setStatusTip ( tr( "Set application to open pdf files"));
1370 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1371 settingsMenu->addAction (a);
1373 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1374 a->setStatusTip( tr( "Set application to open external links"));
1375 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1376 settingsMenu->addAction (a);
1378 a = new QAction( tr( "Set path for macros","Settings action"), this);
1379 a->setStatusTip( tr( "Set path for macros"));
1380 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1381 settingsMenu->addAction (a);
1383 settingsMenu->addSeparator();
1384 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1385 a->setStatusTip( tr( "Edit branch after adding it" ));
1386 a->setToggleAction(true);
1387 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1388 settingsMenu->addAction (a);
1389 actionSettingsAutoEdit=a;
1391 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1392 a->setStatusTip( tr( "Select branch after adding it" ));
1393 a->setToggleAction(true);
1394 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1395 settingsMenu->addAction (a);
1396 actionSettingsAutoSelectHeading=a;
1398 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1399 a->setStatusTip( tr( "Select heading before editing" ));
1400 a->setToggleAction(true);
1401 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1402 settingsMenu->addAction (a);
1403 actionSettingsAutoSelectText=a;
1405 a= new QAction( tr( "Delete key","Settings action" ), this);
1406 a->setStatusTip( tr( "Delete key for deleting branches" ));
1407 a->setToggleAction(true);
1408 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1409 settingsMenu->addAction (a);
1410 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1411 actionSettingsUseDelKey=a;
1413 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1414 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1415 a->setToggleAction(true);
1416 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1417 settingsMenu->addAction (a);
1418 actionSettingsUseFlagGroups=a;
1420 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1421 a->setStatusTip( tr( "Use hide flag during exports " ));
1422 a->setToggleAction(true);
1423 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1424 settingsMenu->addAction (a);
1425 actionSettingsUseHideExport=a;
1429 void Main::setupTestActions()
1431 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1434 a = new QAction( "Test function" , this);
1435 a->setStatusTip( "Call test function" );
1436 //a->setShortcut (Qt::Key_F4 );
1437 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1438 testMenu->addAction (a);
1439 a = new QAction( "Command" , this);
1440 a->setStatusTip( "Enter command to call in editor" );
1441 //a->setShortcut (Qt::Key_F5 );
1442 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1443 testMenu->addAction (a);
1447 void Main::setupHelpActions()
1449 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1452 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1453 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1454 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1455 helpMenu->addAction (a);
1457 a = new QAction( tr( "About VYM","Help action" ), this);
1458 a->setStatusTip( tr( "About VYM")+vymName);
1459 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1460 helpMenu->addAction (a);
1462 a = new QAction( tr( "About QT","Help action" ), this);
1463 a->setStatusTip( tr( "Information about QT toolkit" ));
1464 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1465 helpMenu->addAction (a);
1469 void Main::setupContextMenus()
1473 // Context Menu for branch or mapcenter
1474 branchContextMenu =new QMenu (this);
1475 branchContextMenu->addAction (actionTogglePropertyDialog);
1476 branchContextMenu->addSeparator();
1479 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1480 branchAddContextMenu->addAction (actionEditPaste );
1481 branchAddContextMenu->addAction ( actionEditAddBranch );
1482 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1483 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1484 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1485 branchAddContextMenu->addSeparator();
1486 branchAddContextMenu->addAction ( actionEditImportAdd );
1487 branchAddContextMenu->addAction ( actionEditImportReplace );
1490 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1491 branchRemoveContextMenu->addAction (actionEditCut);
1492 branchRemoveContextMenu->addAction ( actionEditDelete );
1493 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1494 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1497 actionEditSaveBranch->addTo( branchContextMenu );
1499 branchContextMenu->addSeparator();
1500 branchContextMenu->addAction ( actionEditLoadImage);
1501 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1502 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1504 // Submenu for Links (URLs, vymLinks)
1505 branchLinksContextMenu =new QMenu (this);
1507 branchContextMenu->addSeparator();
1508 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1509 branchLinksContextMenu->addAction ( actionEditOpenURL );
1510 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1511 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1512 branchLinksContextMenu->addAction ( actionEditURL );
1513 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1514 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1515 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1517 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1519 branchLinksContextMenu->addSeparator();
1520 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1521 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1522 branchLinksContextMenu->addAction ( actionEditVymLink );
1523 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1526 // Context Menu for XLinks in a branch menu
1527 // This will be populated "on demand" in MapEditor::updateActions
1528 branchContextMenu->addSeparator();
1529 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1530 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1531 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1532 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1535 // Context menu for floatimage
1536 floatimageContextMenu =new QMenu (this);
1537 a= new QAction (tr ("Save image","Context action"),this);
1538 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1539 floatimageContextMenu->addAction (a);
1541 floatimageContextMenu->addSeparator();
1542 actionEditCopy->addTo( floatimageContextMenu );
1543 actionEditCut->addTo( floatimageContextMenu );
1545 floatimageContextMenu->addSeparator();
1546 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1549 // Context menu for canvas
1550 canvasContextMenu =new QMenu (this);
1551 actionEditMapInfo->addTo( canvasContextMenu );
1552 canvasContextMenu->insertSeparator();
1553 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1554 canvasContextMenu->insertSeparator();
1555 actionFormatLinkColorHint->addTo( canvasContextMenu );
1556 actionFormatLinkColor->addTo( canvasContextMenu );
1557 actionFormatSelectionColor->addTo( canvasContextMenu );
1558 actionFormatBackColor->addTo( canvasContextMenu );
1559 actionFormatBackImage->addTo( canvasContextMenu );
1561 // Menu for last opened files
1563 for (int i = 0; i < MaxRecentFiles; ++i)
1565 recentFileActions[i] = new QAction(this);
1566 recentFileActions[i]->setVisible(false);
1567 fileLastMapsMenu->addAction(recentFileActions[i]);
1568 connect(recentFileActions[i], SIGNAL(triggered()),
1569 this, SLOT(fileLoadRecent()));
1571 setupRecentMapsMenu();
1574 void Main::setupRecentMapsMenu()
1576 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1578 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1580 for (int i = 0; i < numRecentFiles; ++i) {
1581 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1582 recentFileActions[i]->setText(text);
1583 recentFileActions[i]->setData(files[i]);
1584 recentFileActions[i]->setVisible(true);
1586 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1587 recentFileActions[j]->setVisible(false);
1590 void Main::setupMacros()
1592 for (int i = 0; i <= 11; i++)
1594 macroActions[i] = new QAction(this);
1595 macroActions[i]->setData(i);
1596 addAction (macroActions[i]);
1597 connect(macroActions[i], SIGNAL(triggered()),
1598 this, SLOT(callMacro()));
1600 macroActions[0]->setShortcut ( Qt::Key_F1 );
1601 macroActions[1]->setShortcut ( Qt::Key_F2 );
1602 macroActions[2]->setShortcut ( Qt::Key_F3 );
1603 macroActions[3]->setShortcut ( Qt::Key_F4 );
1604 macroActions[4]->setShortcut ( Qt::Key_F5 );
1605 macroActions[5]->setShortcut ( Qt::Key_F6 );
1606 macroActions[6]->setShortcut ( Qt::Key_F7 );
1607 macroActions[7]->setShortcut ( Qt::Key_F8 );
1608 macroActions[8]->setShortcut ( Qt::Key_F9 );
1609 macroActions[9]->setShortcut ( Qt::Key_F10 );
1610 macroActions[10]->setShortcut ( Qt::Key_F11 );
1611 macroActions[11]->setShortcut ( Qt::Key_F12 );
1614 void Main::hideEvent (QHideEvent * )
1616 if (!textEditor->isMinimized() ) textEditor->hide();
1619 void Main::showEvent (QShowEvent * )
1621 if (textEditor->showWithMain()) textEditor->showNormal();
1624 bool Main::reallyWriteDirectory(const QString &dir)
1626 QStringList eList = QDir(dir).entryList();
1627 if (eList.first() ==".") eList.pop_front(); // remove "."
1628 if (eList.first() =="..") eList.pop_front(); // remove "."
1629 if (!eList.isEmpty())
1631 QMessageBox mb( vymName,
1632 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1633 QMessageBox::Warning,
1635 QMessageBox::Cancel | QMessageBox::Default,
1636 QMessageBox::QMessageBox::NoButton );
1638 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1639 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1642 case QMessageBox::Yes:
1645 case QMessageBox::Cancel:
1653 QString Main::browseDirectory (const QString &caption)
1655 QFileDialog fd(this,caption);
1656 fd.setMode (QFileDialog::DirectoryOnly);
1657 fd.setCaption(vymName+ " - "+caption);
1658 fd.setDir (lastFileDir);
1661 if ( fd.exec() == QDialog::Accepted )
1662 return fd.selectedFile();
1667 MapEditor* Main::currentMapEditor() const
1669 if ( tabWidget->currentPage() &&
1670 tabWidget->currentPage()->inherits( "MapEditor" ) )
1671 return (MapEditor*)tabWidget->currentPage();
1676 void Main::editorChanged(QWidget *)
1678 // Unselect all possibly selected objects
1679 // (Important to update note editor)
1682 for (i=0;i<=tabWidget->count() -1;i++)
1685 me=(MapEditor*)tabWidget->page(i);
1688 currentMapEditor()->reselect();
1690 // Update actions to in menus and toolbars according to editor
1694 void Main::fileNew()
1696 QString fn="unnamed";
1697 MapEditor* me = new MapEditor ( NULL);
1698 tabWidget->addTab (me,fn);
1699 tabWidget->showPage(me);
1700 me->viewport()->setFocus();
1701 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1702 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1704 // For the very first map we do not have flagrows yet...
1708 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1710 ErrorCode err=success;
1712 // fn is usually the archive, mapfile the file after uncompressing
1715 // Make fn absolute (needed for unzip)
1716 fn=QDir (fn).absPath();
1722 // Check, if map is already loaded
1724 while (i<=tabWidget->count() -1)
1726 me=(MapEditor*)tabWidget->page(i);
1727 if (me->getFilePath() == fn)
1729 // Already there, ask for confirmation
1730 QMessageBox mb( vymName,
1731 tr("The map %1\nis already opened."
1732 "Opening the same map in multiple editors may lead \n"
1733 "to confusion when finishing working with vym."
1734 "Do you want to").arg(fn),
1735 QMessageBox::Warning,
1736 QMessageBox::Yes | QMessageBox::Default,
1737 QMessageBox::Cancel | QMessageBox::Escape,
1738 QMessageBox::NoButton);
1739 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1740 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1743 case QMessageBox::Yes:
1745 i=tabWidget->count();
1747 case QMessageBox::Cancel:
1759 if ( !fn.isEmpty() )
1761 me = currentMapEditor();
1762 int tabIndex=tabWidget->currentPageIndex();
1763 // Check first, if mapeditor exists
1764 // If it is not default AND we want a new map,
1765 // create a new mapeditor in a new tab
1766 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1768 me= new MapEditor ( NULL);
1769 tabWidget->addTab (me,fn);
1770 tabIndex=tabWidget->indexOf (me);
1771 tabWidget->setCurrentPage (tabIndex);
1772 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1773 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1776 // Check, if file exists (important for creating new files
1777 // from command line
1778 if (!QFile(fn).exists() )
1780 QMessageBox mb( vymName,
1781 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1782 QMessageBox::Question,
1784 QMessageBox::Cancel | QMessageBox::Default,
1785 QMessageBox::NoButton );
1787 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1788 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1791 case QMessageBox::Yes:
1793 currentMapEditor()->setFilePath(fn);
1794 tabWidget->setTabLabel (currentMapEditor(),
1795 currentMapEditor()->getFileName() );
1796 statusBar()->message( "Created " + fn , statusbarTime );
1799 case QMessageBox::Cancel:
1800 // don't create new map
1801 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1808 //tabWidget->currentPage() won't be NULL here, because of above...
1809 tabWidget->showPage(me);
1810 me->viewport()->setFocus();
1812 // Create temporary directory for packing
1814 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1817 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1818 tr("Couldn't create temporary directory before load\n"));
1822 // Try to unzip file
1823 err=unzipDir (tmpMapDir,fn);
1827 me->setZipped(false);
1830 me->setZipped(true);
1832 // Look for mapname.xml
1833 mapfile= fn.left(fn.findRev(".",-1,true));
1834 mapfile=mapfile.section( '/', -1 );
1835 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1836 if (!file.exists() )
1838 // mapname.xml does not exist, well,
1839 // maybe someone renamed the mapname.vym file...
1840 // Try to find any .xml in the toplevel
1841 // directory of the .vym file
1842 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1843 if (flist.count()==1)
1845 // Only one entry, take this one
1846 mapfile=tmpMapDir + "/"+flist.first();
1849 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1850 *it=tmpMapDir + "/" + *it;
1851 // TODO Multiple entries, load all (but only the first one into this ME)
1852 //mainWindow->fileLoadFromTmp (flist);
1853 //returnCode=1; // Silently forget this attempt to load
1854 qWarning ("MainWindow::load (fn) multimap found...");
1857 if (flist.isEmpty() )
1859 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1860 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1863 } //file doesn't exist
1865 mapfile=file.name();
1870 // Save existing filename in case we import
1871 QString fn_org=me->getFilePath();
1873 // Finally load map into mapEditor
1874 me->setFilePath (mapfile,fn);
1875 err=me->load(mapfile,lmode);
1877 // Restore old (maybe empty) filepath, if this is an import
1879 me->setFilePath (fn_org);
1882 // Finally check for errors and go home
1885 if (lmode==NewMap) fileCloseMap();
1886 statusBar()->message( "Could not load " + fn, statusbarTime );
1891 me->setFilePath (fn);
1892 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1893 if (fn.left(9)!="/tmp/vym-")
1895 // Only append to lastMaps if not loaded from a tmpDir
1896 // e.g. imported bookmarks are in a tmpDir
1897 addRecentMap(me->getFilePath() );
1899 actionFilePrint->setEnabled (true);
1901 statusBar()->message( "Loaded " + fn, statusbarTime );
1905 removeDir (QDir(tmpMapDir));
1911 void Main::fileLoad(const LoadMode &lmode)
1913 QStringList filters;
1914 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1915 QFileDialog *fd=new QFileDialog( this);
1916 fd->setDir (lastFileDir);
1917 fd->setFileMode (QFileDialog::ExistingFiles);
1918 fd->setFilters (filters);
1922 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1925 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1928 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1934 if ( fd->exec() == QDialog::Accepted )
1936 lastFileDir=fd->directory().path();
1937 QStringList flist = fd->selectedFiles();
1938 QStringList::Iterator it = flist.begin();
1939 while( it != flist.end() )
1942 fileLoad(*it, lmode);
1949 void Main::fileLoad()
1954 void Main::fileLoadRecent()
1956 QAction *action = qobject_cast<QAction *>(sender());
1958 fileLoad (action->data().toString(), NewMap);
1961 void Main::addRecentMap (const QString &fileName)
1964 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1965 files.removeAll(fileName);
1966 files.prepend(fileName);
1967 while (files.size() > MaxRecentFiles)
1970 settings.setValue("/mainwindow/recentFileList", files);
1972 setupRecentMapsMenu();
1975 void Main::fileSave(const SaveMode &savemode)
1977 // tmp dir for zipping
1981 ErrorCode err=success;
1983 QString safeFilePath;
1985 bool saveZipped=currentMapEditor()->saveZipped();
1987 MapEditor * me=currentMapEditor();
1990 QString fn=me->getFilePath();
1991 // filename=unnamed, filepath="" in constructor...
1992 if ( !fn.isEmpty() )
1994 // We have a filepath, go on saving
1995 // First remove existing file, we
1996 // don't want to add to old zip archives
2000 QMessageBox::warning( 0, tr( "Save Error" ),
2001 fn+ tr("\ncould not be removed before saving"));
2003 // Look, if we should zip the data:
2006 QMessageBox mb( vymName,
2007 tr("The map %1\ndid not use the compressed "
2008 "vym file format.\nWriting it uncompressed will also write images \n"
2009 "and flags and thus may overwrite files in the "
2010 "given directory\n\nDo you want to write the map").arg(fn),
2011 QMessageBox::Warning,
2012 QMessageBox::Yes | QMessageBox::Default,
2014 QMessageBox::Cancel | QMessageBox::Escape);
2015 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2016 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2017 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2020 case QMessageBox::Yes:
2021 // save compressed (default file format)
2024 case QMessageBox::No:
2025 // save uncompressed
2028 case QMessageBox::Cancel:
2037 // Create temporary directory for packing
2039 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2042 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2043 tr("Couldn't create temporary directory before save\n"));
2047 safeFilePath=me->getFilePath();
2048 me->setFilePath (tmpMapDir+"/"+
2049 me->getMapName()+ ".xml",
2051 me->save (savemode);
2052 me->setFilePath (safeFilePath);
2054 zipDir (tmpMapDir,fn);
2059 safeFilePath=me->getFilePath();
2060 me->setFilePath (fn, safeFilePath);
2061 me->save (savemode);
2062 me->setFilePath (safeFilePath);
2064 } // filepath available
2067 // We have no filepath yet,
2068 // call fileSaveAs() now, this will call fileSave()
2070 fileSaveAs(savemode);
2074 if (saveZipped && !tmpMapDir.isEmpty())
2076 removeDir (QDir(tmpMapDir));
2080 statusBar()->message(
2081 tr("Saved %1").arg(me->getFilePath()),
2083 addRecentMap (me->getFilePath() );
2085 statusBar()->message(
2086 tr("Couldn't save ").arg(me->getFilePath()),
2090 void Main::fileSave()
2092 fileSave (CompleteMap);
2095 void Main::fileSaveAs(const SaveMode& savemode)
2099 if (currentMapEditor())
2101 if (savemode==CompleteMap)
2102 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2104 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2105 if ( !fn.isEmpty() )
2107 // Check for existing file
2108 if (QFile (fn).exists())
2110 QMessageBox mb( vymName,
2111 tr("The file %1\nexists already. Do you want to").arg(fn),
2112 QMessageBox::Warning,
2113 QMessageBox::Yes | QMessageBox::Default,
2114 QMessageBox::Cancel | QMessageBox::Escape,
2115 QMessageBox::NoButton);
2116 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2117 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2120 case QMessageBox::Yes:
2123 case QMessageBox::Cancel:
2130 // New file, add extension to filename, if missing
2131 // This is always .vym or .vyp, depending on savemode
2132 if (savemode==CompleteMap)
2134 if (!fn.contains (".vym") && !fn.contains (".xml"))
2138 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2147 currentMapEditor()->setFilePath(fn);
2151 if (savemode==CompleteMap)
2152 tabWidget->setTabLabel (currentMapEditor(),
2153 currentMapEditor()->getFileName() );
2159 void Main::fileSaveAs()
2161 fileSaveAs (CompleteMap);
2164 void Main::fileImportKDEBookmarks()
2166 ImportKDEBookmarks im;
2168 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2169 currentMapEditor()->setFilePath ("");
2172 void Main::fileImportFirefoxBookmarks()
2174 Q3FileDialog *fd=new Q3FileDialog( this);
2175 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2176 fd->setMode (Q3FileDialog::ExistingFiles);
2177 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2178 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2181 if ( fd->exec() == QDialog::Accepted )
2183 ImportFirefoxBookmarks im;
2184 QStringList flist = fd->selectedFiles();
2185 QStringList::Iterator it = flist.begin();
2186 while( it != flist.end() )
2189 if (im.transform() &&
2190 success==fileLoad (im.getTransformedFile(),NewMap) &&
2191 currentMapEditor() )
2192 currentMapEditor()->setFilePath ("");
2199 void Main::fileImportMM()
2203 Q3FileDialog *fd=new Q3FileDialog( this);
2204 fd->setDir (lastFileDir);
2205 fd->setMode (Q3FileDialog::ExistingFiles);
2206 fd->addFilter ("Mind Manager (*.mmap)");
2207 fd->setCaption(tr("Import")+" "+"Mind Manager");
2210 if ( fd->exec() == QDialog::Accepted )
2212 lastFileDir=fd->dirPath();
2213 QStringList flist = fd->selectedFiles();
2214 QStringList::Iterator it = flist.begin();
2215 while( it != flist.end() )
2218 if (im.transform() &&
2219 success==fileLoad (im.getTransformedFile(),NewMap) &&
2220 currentMapEditor() )
2221 currentMapEditor()->setFilePath ("");
2230 void Main::fileImportDir()
2232 if (currentMapEditor())
2233 currentMapEditor()->importDir();
2236 void Main::fileExportXML()
2238 if (currentMapEditor())
2240 QString dir=browseDirectory(tr("Export XML to directory"));
2241 if (dir !="" && reallyWriteDirectory(dir) )
2242 currentMapEditor()->exportXML(dir);
2247 void Main::fileExportXHTML()
2249 MapEditor *me=currentMapEditor();
2253 ExportXHTMLDialog dia(this);
2254 dia.setFilePath (me->getFilePath() );
2255 dia.setMapName (me->getMapName() );
2258 if (dia.exec()==QDialog::Accepted)
2260 QString dir=dia.getDir();
2261 // Check, if warnings should be used before overwriting
2262 // the output directory
2264 warn.showCancelButton (true);
2265 warn.setText(QString(
2266 "The directory %1 is not empty.\n"
2267 "Do you risk to overwrite some of its contents?").arg(dir));
2268 warn.setCaption("Warning: Directory not empty");
2269 warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
2270 if (warn.exec()==QDialog::Accepted)
2272 me->exportXML (dia.getDir() );
2273 dia.doExport(me->getMapName() );
2274 if (dia.hasChanged())
2281 void Main::fileExportImage()
2283 MapEditor *me=currentMapEditor();
2287 QFileDialog *fd=new QFileDialog (this);
2288 fd->setCaption (tr("Export map as image"));
2289 fd->setDirectory (lastImageDir);
2290 fd->setFileMode(QFileDialog::AnyFile);
2291 fd->setFilters (imageIO.getFilters() );
2294 fl=fd->selectedFiles();
2295 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2300 void Main::fileExportASCII()
2302 MapEditor *me=currentMapEditor();
2306 ex.setMapCenter(me->getMapCenter());
2307 ex.addFilter ("TXT (*.txt)");
2308 ex.setDir(lastImageDir);
2309 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2310 if (ex.execDialog() )
2312 me->setExportMode(true);
2314 me->setExportMode(false);
2319 void Main::fileExportLaTeX()
2321 MapEditor *me=currentMapEditor();
2325 ex.setMapCenter(me->getMapCenter());
2326 ex.addFilter ("Tex (*.tex)");
2327 ex.setDir(lastImageDir);
2328 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2329 if (ex.execDialog() )
2331 me->setExportMode(true);
2333 me->setExportMode(false);
2338 void Main::fileExportKDEBookmarks()
2340 ExportKDEBookmarks ex;
2341 MapEditor *me=currentMapEditor();
2344 ex.setMapCenter (me->getMapCenter() );
2349 void Main::fileExportTaskjuggler()
2351 ExportTaskjuggler ex;
2352 MapEditor *me=currentMapEditor();
2355 ex.setMapCenter (me->getMapCenter() );
2356 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2357 ex.setDir(lastImageDir);
2358 ex.addFilter ("Taskjuggler (*.tjp)");
2359 if (ex.execDialog() )
2361 me->setExportMode(true);
2363 me->setExportMode(false);
2368 void Main::fileExportOOPresentation()
2370 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2371 // TODO add preview in dialog
2372 //ImagePreview *p =new ImagePreview (fd);
2373 //fd->setContentsPreviewEnabled( TRUE );
2374 //fd->setContentsPreview( p, p );
2375 //fd->setPreviewMode( QFileDialog::Contents );
2376 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2377 fd->setDir (QDir().current());
2378 if (fd->foundConfig())
2382 if ( fd->exec() == QDialog::Accepted )
2384 QString fn=fd->selectedFile();
2385 if (!fn.contains (".odp"))
2388 //lastImageDir=fn.left(fn.findRev ("/"));
2389 if (currentMapEditor())
2390 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2394 QMessageBox::warning(0,
2396 tr("Couldn't find configuration for export to Open Office\n"));
2400 void Main::fileCloseMap()
2402 if (currentMapEditor())
2404 if (currentMapEditor()->hasChanged())
2406 QMessageBox mb( vymName,
2407 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2408 QMessageBox::Warning,
2409 QMessageBox::Yes | QMessageBox::Default,
2411 QMessageBox::Cancel | QMessageBox::Escape );
2412 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2413 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2416 case QMessageBox::Yes:
2418 fileSave(CompleteMap);
2420 case QMessageBox::No:
2421 // close without saving
2423 case QMessageBox::Cancel:
2428 currentMapEditor()->closeMap();
2429 tabWidget->removePage(currentMapEditor());
2430 if (tabWidget->count()==0)
2431 actionFilePrint->setEnabled (false);
2435 void Main::filePrint()
2437 if (currentMapEditor())
2438 currentMapEditor()->print();
2441 void Main::fileExitVYM()
2443 // Check if one or more editors have changed
2446 for (i=0;i<=tabWidget->count() -1;i++)
2449 me=(MapEditor*)tabWidget->page(i);
2451 // If something changed, ask what to do
2452 if (me->isUnsaved())
2454 tabWidget->setCurrentPage(i);
2455 QMessageBox mb( vymName,
2456 tr("This map is not saved yet. Do you want to"),
2457 QMessageBox::Warning,
2458 QMessageBox::Yes | QMessageBox::Default,
2460 QMessageBox::Cancel | QMessageBox::Escape );
2461 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2462 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2465 mb.setActiveWindow();
2466 switch( mb.exec() ) {
2467 case QMessageBox::Yes:
2468 // save (the changed editors) and exit
2469 fileSave(CompleteMap);
2471 case QMessageBox::No:
2472 // exit without saving
2474 case QMessageBox::Cancel:
2475 // don't save and don't exit
2479 } // loop over all MEs
2483 void Main::editUndo()
2485 if (currentMapEditor())
2486 currentMapEditor()->undo();
2489 void Main::editRedo()
2491 if (currentMapEditor())
2492 currentMapEditor()->redo();
2495 void Main::gotoHistoryStep (int i)
2497 if (currentMapEditor())
2498 currentMapEditor()->gotoHistoryStep (i);
2501 void Main::editCopy()
2503 if (currentMapEditor())
2504 currentMapEditor()->copy();
2507 void Main::editPaste()
2509 if (currentMapEditor())
2510 currentMapEditor()->paste();
2513 void Main::editCut()
2515 if (currentMapEditor())
2516 currentMapEditor()->cut();
2519 void Main::editOpenFindWindow()
2521 findWindow->popup();
2522 findWindow->raise();
2523 findWindow->setActiveWindow();
2526 void Main::editFind(QString s)
2529 BranchObj *bo=currentMapEditor()->findText(s, cs);
2532 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2535 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2536 tr("No matches found for \"%1\"").arg(s));
2540 void Main::editFindChanged()
2541 { // Notify editor, to abort the current find process
2542 currentMapEditor()->findReset();
2545 void Main::openTabs(QStringList urls)
2547 if (!urls.isEmpty())
2551 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2553 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2555 QString u=urls.takeFirst();
2556 procBrowser = new QProcess( this );
2558 procBrowser->start(browser,args);
2559 if ( !procBrowser->waitForStarted())
2561 // try to set path to browser
2562 QMessageBox::warning(0,
2564 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2565 tr("Please use Settings->")+tr("Set application to open an URL"));
2570 if (browser.contains("konqueror"))
2572 for (int i=0; i<urls.size(); i++)
2575 // Try to open new tab in existing konqueror started previously by vym
2576 p=new QProcess (this);
2578 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2579 "konqueror-mainwindow#1"<<
2582 p->start ("dcop",args);
2583 if ( !p->waitForStarted() ) success=false;
2586 QMessageBox::warning(0,
2588 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2590 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2592 for (int i=0; i<urls.size(); i++)
2594 // Try to open new tab in firefox
2595 p=new QProcess (this);
2596 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2597 p->start (browser,args);
2598 if ( !p->waitForStarted() ) success=false;
2601 QMessageBox::warning(0,
2603 tr("Couldn't start %1 to open a new tab").arg(browser));
2606 QMessageBox::warning(0,
2608 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2612 void Main::editOpenURL()
2615 if (currentMapEditor())
2617 QString url=currentMapEditor()->getURL();
2619 if (url=="") return;
2620 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2621 procBrowser = new QProcess( this );
2623 procBrowser->start(browser,args);
2624 if ( !procBrowser->waitForStarted())
2626 // try to set path to browser
2627 QMessageBox::warning(0,
2629 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2630 tr("Please use Settings->")+tr("Set application to open an URL"));
2635 void Main::editOpenURLTab()
2637 if (currentMapEditor())
2640 urls.append(currentMapEditor()->getURL());
2644 void Main::editOpenMultipleURLTabs()
2646 if (currentMapEditor())
2649 urls=currentMapEditor()->getURLs();
2655 void Main::editURL()
2657 if (currentMapEditor())
2658 currentMapEditor()->editURL();
2661 void Main::editHeading2URL()
2663 if (currentMapEditor())
2664 currentMapEditor()->editHeading2URL();
2667 void Main::editBugzilla2URL()
2669 if (currentMapEditor())
2670 currentMapEditor()->editBugzilla2URL();
2673 void Main::editFATE2URL()
2675 if (currentMapEditor())
2676 currentMapEditor()->editFATE2URL();
2679 void Main::editHeadingFinished()
2681 // only called from editHeading(), so there is a currentME
2682 MapEditor *me=currentMapEditor();
2685 QPoint p; //Not used here, only to find out pos of branch
2687 QString s=me->getHeading(ok,p);
2689 #if defined(Q_OS_MACX)
2691 if (ok && s!=lineedit->text())
2692 me->setHeading(lineedit->text());
2694 lineedit->releaseKeyboard();
2698 if (!prevSelection.isEmpty()) me->select(prevSelection);
2703 void Main::editHeading()
2705 if (currentMapEditor())
2707 MapEditor *me=currentMapEditor();
2708 QString oldSel=me->getSelectString();
2710 if (lineedit->isVisible())
2711 editHeadingFinished();
2716 QString s=currentMapEditor()->getHeading(ok,p);
2720 #if defined(Q_OS_MACX)
2721 p=currentMapEditor()->mapTo (this,p);
2722 QDialog *d =new QDialog(NULL);
2723 QLineEdit *le=new QLineEdit (d);
2724 d->setWindowFlags (Qt::FramelessWindowHint);
2725 d->setGeometry(p.x(),p.y(),230,25);
2726 le->resize (d->width()-10,d->height());
2729 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2730 d->activateWindow();
2732 currentMapEditor()->setHeading (le->text());
2735 editHeadingFinished();
2737 p=currentMapEditor()->mapTo (this,p);
2738 lineedit->setGeometry(p.x(),p.y(),230,25);
2739 lineedit->setText(s);
2740 lineedit->setCursorPosition(1);
2741 lineedit->selectAll();
2743 lineedit->grabKeyboard();
2744 lineedit->setFocus();
2748 } // currentMapEditor()
2751 void Main::openVymLinks(const QStringList &vl)
2753 for (int j=0; j<vl.size(); j++)
2755 // compare path with already loaded maps
2759 for (i=0;i<=tabWidget->count() -1;i++)
2761 me=(MapEditor*)tabWidget->page(i);
2762 if (vl.at(j)==me->getFilePath() )
2771 if (!QFile(vl.at(j)).exists() )
2772 QMessageBox::critical( 0, tr( "Critical Error" ),
2773 tr("Couldn't open map %1").arg(vl.at(j)));
2776 fileLoad (vl.at(j), NewMap);
2777 tabWidget->setCurrentPage (tabWidget->count()-1);
2780 // Go to tab containing the map
2781 tabWidget->setCurrentPage (index);
2785 void Main::editOpenVymLink()
2787 if (currentMapEditor())
2790 vl.append(currentMapEditor()->getVymLink());
2795 void Main::editOpenMultipleVymLinks()
2797 QString currentVymLink;
2798 if (currentMapEditor())
2800 QStringList vl=currentMapEditor()->getVymLinks();
2805 void Main::editVymLink()
2807 if (currentMapEditor())
2808 currentMapEditor()->editVymLink();
2811 void Main::editDeleteVymLink()
2813 if (currentMapEditor())
2814 currentMapEditor()->deleteVymLink();
2817 void Main::editToggleHideExport()
2819 if (currentMapEditor())
2820 currentMapEditor()->toggleHideExport();
2823 void Main::editMapInfo()
2825 if (currentMapEditor())
2826 currentMapEditor()->editMapInfo();
2829 void Main::editMoveUp()
2831 if (currentMapEditor())
2832 currentMapEditor()->moveBranchUp();
2835 void Main::editMoveDown()
2837 if (currentMapEditor())
2838 currentMapEditor()->moveBranchDown();
2841 void Main::editToggleScroll()
2843 if (currentMapEditor())
2845 currentMapEditor()->toggleScroll();
2849 void Main::editUnScrollAll()
2851 if (currentMapEditor())
2852 currentMapEditor()->unscrollChilds();
2855 void Main::editNewBranch()
2857 MapEditor *me=currentMapEditor();
2858 if (!lineedit->isVisible() && me)
2860 BranchObj *bo=(BranchObj*)me->getSelection();
2861 BranchObj *newbo=me->addNewBranch(0);
2864 me->select (newbo->getSelectString());
2868 if (actionSettingsAutoEdit->isOn())
2870 if (!actionSettingsAutoSelectHeading->isOn())
2871 prevSelection=bo->getSelectString();
2877 void Main::editNewBranchBefore()
2879 MapEditor *me=currentMapEditor();
2880 if (!lineedit->isVisible() && me)
2882 BranchObj *bo=(BranchObj*)me->getSelection();
2883 BranchObj *newbo=me->addNewBranchBefore();
2886 me->select (newbo->getSelectString());
2890 if (actionSettingsAutoEdit->isOn())
2892 if (!actionSettingsAutoSelectHeading->isOn())
2893 prevSelection=bo->getSelectString();
2899 void Main::editNewBranchAbove()
2901 MapEditor *me=currentMapEditor();
2902 if (!lineedit->isVisible() && me)
2904 BranchObj *bo=(BranchObj*)me->getSelection();
2905 BranchObj *newbo=me->addNewBranch (-1);
2908 me->select (newbo->getSelectString());
2912 if (actionSettingsAutoEdit->isOn())
2914 if (!actionSettingsAutoSelectHeading->isOn())
2915 prevSelection=bo->getSelectString();
2921 void Main::editNewBranchBelow()
2923 MapEditor *me=currentMapEditor();
2924 if (!lineedit->isVisible() && me)
2926 BranchObj *bo=(BranchObj*)me->getSelection();
2927 BranchObj *newbo=me->addNewBranch (1);
2930 me->select (newbo->getSelectString());
2934 if (actionSettingsAutoEdit->isOn())
2936 if (!actionSettingsAutoSelectHeading->isOn())
2937 prevSelection=bo->getSelectString();
2943 void Main::editImportAdd()
2945 fileLoad (ImportAdd);
2948 void Main::editImportReplace()
2950 fileLoad (ImportReplace);
2953 void Main::editSaveBranch()
2955 fileSaveAs (PartOfMap);
2958 void Main::editDeleteKeepChilds()
2960 if (currentMapEditor())
2961 currentMapEditor()->deleteKeepChilds();
2964 void Main::editDeleteChilds()
2966 if (currentMapEditor())
2967 currentMapEditor()->deleteChilds();
2970 void Main::editDeleteSelection()
2972 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2973 currentMapEditor()->deleteSelection();
2976 void Main::editUpperBranch()
2978 if (currentMapEditor())
2979 currentMapEditor()->selectUpperBranch();
2982 void Main::editLowerBranch()
2984 if (currentMapEditor())
2985 currentMapEditor()->selectLowerBranch();
2988 void Main::editLeftBranch()
2990 if (currentMapEditor())
2991 currentMapEditor()->selectLeftBranch();
2994 void Main::editRightBranch()
2996 if (currentMapEditor())
2997 currentMapEditor()->selectRightBranch();
3000 void Main::editFirstBranch()
3002 if (currentMapEditor())
3003 currentMapEditor()->selectFirstBranch();
3006 void Main::editLastBranch()
3008 if (currentMapEditor())
3009 currentMapEditor()->selectLastBranch();
3012 void Main::editLoadImage()
3014 if (currentMapEditor())
3015 currentMapEditor()->loadFloatImage();
3018 void Main::editSaveImage()
3020 if (currentMapEditor())
3021 currentMapEditor()->saveFloatImage();
3024 void Main::editFollowXLink(QAction *a)
3027 if (currentMapEditor())
3028 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3031 void Main::editEditXLink(QAction *a)
3033 if (currentMapEditor())
3034 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3037 void Main::formatSelectColor()
3039 if (currentMapEditor())
3041 QColor col = QColorDialog::getColor((currentColor ), this );
3042 if ( !col.isValid() ) return;
3043 colorChanged( col );
3047 void Main::formatPickColor()
3049 if (currentMapEditor())
3050 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3053 void Main::colorChanged(QColor c)
3055 QPixmap pix( 16, 16 );
3057 actionFormatColor->setIconSet( pix );
3061 void Main::formatColorBranch()
3063 if (currentMapEditor())
3064 currentMapEditor()->colorBranch(currentColor);
3067 void Main::formatColorSubtree()
3069 if (currentMapEditor())
3070 currentMapEditor()->colorSubtree (currentColor);
3073 void Main::formatLinkStyleLine()
3075 if (currentMapEditor())
3076 currentMapEditor()->setMapLinkStyle("StyleLine");
3079 void Main::formatLinkStyleParabel()
3081 if (currentMapEditor())
3082 currentMapEditor()->setMapLinkStyle("StyleParabel");
3085 void Main::formatLinkStylePolyLine()
3087 if (currentMapEditor())
3088 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3091 void Main::formatLinkStylePolyParabel()
3093 if (currentMapEditor())
3094 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3097 void Main::formatSelectBackColor()
3099 if (currentMapEditor())
3100 currentMapEditor()->selectMapBackgroundColor();
3103 void Main::formatSelectBackImage()
3105 if (currentMapEditor())
3106 currentMapEditor()->selectMapBackgroundImage();
3109 void Main::formatSelectLinkColor()
3111 if (currentMapEditor())
3112 currentMapEditor()->selectMapLinkColor();
3115 void Main::formatSelectSelectionColor()
3117 if (currentMapEditor())
3118 currentMapEditor()->selectMapSelectionColor();
3121 void Main::formatToggleLinkColorHint()
3123 currentMapEditor()->toggleMapLinkColorHint();
3127 void Main::formatIncludeImagesVer()
3129 if (currentMapEditor())
3130 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3133 void Main::formatIncludeImagesHor()
3135 if (currentMapEditor())
3136 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3139 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3141 if (currentMapEditor())
3142 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3145 void Main::viewZoomReset()
3147 if (currentMapEditor())
3151 currentMapEditor()->setMatrix( m );
3155 void Main::viewZoomIn()
3157 if (currentMapEditor())
3159 QMatrix m = currentMapEditor()->matrix();
3160 m.scale( 1.25, 1.25 );
3161 currentMapEditor()->setMatrix( m );
3165 void Main::viewZoomOut()
3167 if (currentMapEditor())
3169 QMatrix m = currentMapEditor()->matrix();
3170 m.scale( 0.8, 0.8 );
3171 currentMapEditor()->setMatrix( m );
3175 bool Main::settingsPDF()
3177 // Default browser is set in constructor
3179 QString text = QInputDialog::getText(
3180 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3181 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3183 settings.setValue ("/mainwindow/readerPDF",text);
3188 bool Main::settingsURL()
3190 // Default browser is set in constructor
3192 QString text = QInputDialog::getText(
3193 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3194 settings.value("/mainwindow/readerURL").toString()
3197 settings.setValue ("/mainwindow/readerURL",text);
3201 void Main::settingsMacroDir()
3203 QDir defdir=vymBaseDir;
3204 defdir.cd("macros");
3205 if (!defdir.exists())
3207 QDir dir=QFileDialog::getExistingDirectory (
3209 tr ("Directory with vym macros:"),
3210 settings.value ("/macros/macroDir",defdir.path()).toString()
3213 settings.setValue ("/macros/macroDir",dir.path());
3216 void Main::settingsToggleDelKey()
3218 if (actionSettingsUseDelKey->isOn())
3220 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3223 actionEditDelete->setAccel (QKeySequence (""));
3227 void Main::windowToggleNoteEditor()
3229 if (textEditor->showWithMain() )
3230 windowHideNoteEditor();
3232 windowShowNoteEditor();
3235 void Main::windowToggleHistory()
3237 if (historyWindow->isVisible())
3238 historyWindow->hide();
3240 historyWindow->show();
3244 void Main::windowToggleAntiAlias()
3246 bool b=actionViewToggleAntiAlias->isOn();
3248 for (int i=0;i<tabWidget->count();i++)
3251 me=(MapEditor*)tabWidget->page(i);
3252 me->setAntiAlias(b);
3257 void Main::windowToggleSmoothPixmap()
3259 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3261 for (int i=0;i<tabWidget->count();i++)
3264 me=(MapEditor*)tabWidget->page(i);
3265 me->setSmoothPixmap(b);
3269 void Main::updateHistory(SimpleSettings &undoSet)
3271 historyWindow->update (undoSet);
3274 void Main::updateNoteFlag()
3276 if (currentMapEditor())
3277 currentMapEditor()->updateNoteFlag();
3280 void Main::updateSatellites(MapEditor *me)
3282 branchPropertyWindow->setMapEditor (me);
3285 void Main::updateActions()
3287 MapEditor *me=currentMapEditor();
3290 historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
3292 // updateActions is also called when NoteEditor is closed
3293 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3294 actionViewToggleHistoryWindow->setOn (historyWindow->showWithMain());
3296 if (me->getMapLinkColorHint()==HeadingColor)
3297 actionFormatLinkColorHint->setOn(true);
3299 actionFormatLinkColorHint->setOn(false);
3301 switch (me->getMapLinkStyle())
3304 actionFormatLinkStyleLine->setOn(true);
3307 actionFormatLinkStyleParabel->setOn(true);
3310 actionFormatLinkStylePolyLine->setOn(true);
3312 case StylePolyParabel:
3313 actionFormatLinkStylePolyParabel->setOn(true);
3320 QPixmap pix( 16, 16 );
3321 pix.fill( me->getMapBackgroundColor() );
3322 actionFormatBackColor->setIconSet( pix );
3323 pix.fill( me->getSelectionColor() );
3324 actionFormatSelectionColor->setIconSet( pix );
3325 pix.fill( me->getMapDefLinkColor() );
3326 actionFormatLinkColor->setIconSet( pix );
3329 actionFileSave->setEnabled( me->isUnsaved() );
3330 if (me->isUndoAvailable())
3331 actionEditUndo->setEnabled( true);
3333 actionEditUndo->setEnabled( false);
3335 if (me->isRedoAvailable())
3336 actionEditRedo->setEnabled( true);
3338 actionEditRedo->setEnabled( false);
3340 LinkableMapObj *selection=me->getSelection();
3343 if ( (typeid(*selection) == typeid(BranchObj)) ||
3344 (typeid(*selection) == typeid(MapCenterObj)) )
3346 BranchObj *bo=(BranchObj*)selection;
3347 // Take care of links
3348 if (bo->countXLinks()==0)
3350 branchXLinksContextMenuEdit->clear();
3351 branchXLinksContextMenuFollow->clear();
3356 branchXLinksContextMenuEdit->clear();
3357 branchXLinksContextMenuFollow->clear();
3358 for (int i=0; i<=bo->countXLinks();i++)
3360 bot=bo->XLinkTargetAt(i);
3363 s=bot->getHeading();
3366 branchXLinksContextMenuFollow->addAction (s);
3367 branchXLinksContextMenuEdit->addAction (s);
3372 standardFlagsDefault->setEnabled (true);
3374 actionEditToggleScroll->setEnabled (true);
3375 if ( bo->isScrolled() )
3376 actionEditToggleScroll->setOn(true);
3378 actionEditToggleScroll->setOn(false);
3380 if ( bo->getURL().isEmpty() )
3382 actionEditOpenURL->setEnabled (false);
3383 actionEditOpenURLTab->setEnabled (false);
3387 actionEditOpenURL->setEnabled (true);
3388 actionEditOpenURLTab->setEnabled (true);
3390 if ( bo->getVymLink().isEmpty() )
3392 actionEditOpenVymLink->setEnabled (false);
3393 actionEditDeleteVymLink->setEnabled (false);
3396 actionEditOpenVymLink->setEnabled (true);
3397 actionEditDeleteVymLink->setEnabled (true);
3400 if (bo->canMoveBranchUp())
3401 actionEditMoveUp->setEnabled (true);
3403 actionEditMoveUp->setEnabled (false);
3404 if (bo->canMoveBranchDown())
3405 actionEditMoveDown->setEnabled (true);
3407 actionEditMoveDown->setEnabled (false);
3410 actionEditToggleHideExport->setEnabled (true);
3411 actionEditToggleHideExport->setOn (bo->hideInExport() );
3413 actionEditCopy->setEnabled (true);
3414 actionEditCut->setEnabled (true);
3415 if (!clipboardEmpty)
3416 actionEditPaste->setEnabled (true);
3418 actionEditPaste->setEnabled (false);
3419 for (int i=0; i<actionListBranches.size(); ++i)
3420 actionListBranches.at(i)->setEnabled(true);
3421 actionEditDelete->setEnabled (true);
3422 actionFormatIncludeImagesVer->setOn
3423 ( ((BranchObj*)selection)->getIncludeImagesVer());
3424 actionFormatIncludeImagesHor->setOn
3425 ( ((BranchObj*)selection)->getIncludeImagesHor());
3426 actionFormatHideLinkUnselected->setOn
3427 (selection->getHideLinkUnselected());
3429 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3431 FloatObj *fo=(FloatImageObj*)selection;
3433 actionEditOpenURL->setEnabled (false);
3434 actionEditOpenVymLink->setEnabled (false);
3435 actionEditDeleteVymLink->setEnabled (false);
3436 actionEditToggleHideExport->setEnabled (true);
3437 actionEditToggleHideExport->setOn (fo->hideInExport() );
3440 actionEditCopy->setEnabled (true);
3441 actionEditCut->setEnabled (true);
3442 actionEditPaste->setEnabled (false);
3443 for (int i=0; i<actionListBranches.size(); ++i)
3444 actionListBranches.at(i)->setEnabled(false);
3445 actionEditDelete->setEnabled (true);
3446 actionFormatHideLinkUnselected->setOn
3447 ( selection->getHideLinkUnselected());
3448 actionEditMoveUp->setEnabled (false);
3449 actionEditMoveDown->setEnabled (false);
3454 actionEditCopy->setEnabled (false);
3455 actionEditCut->setEnabled (false);
3456 actionEditPaste->setEnabled (false);
3457 for (int i=0; i<actionListBranches.size(); ++i)
3458 actionListBranches.at(i)->setEnabled(false);
3460 actionEditToggleScroll->setEnabled (false);
3461 actionEditOpenURL->setEnabled (false);
3462 actionEditOpenVymLink->setEnabled (false);
3463 actionEditDeleteVymLink->setEnabled (false);
3464 actionEditHeading2URL->setEnabled (false);
3465 actionEditDelete->setEnabled (false);
3466 actionEditMoveUp->setEnabled (false);
3467 actionEditMoveDown->setEnabled (false);
3468 actionEditToggleHideExport->setEnabled (false);
3472 ModMode Main::getModMode()
3474 if (actionModModeColor->isOn()) return ModModeColor;
3475 if (actionModModeCopy->isOn()) return ModModeCopy;
3476 if (actionModModeXLink->isOn()) return ModModeXLink;
3480 bool Main::autoEdit()
3482 return actionSettingsAutoEdit->isOn();
3485 bool Main::autoSelectHeading()
3487 return actionSettingsAutoSelectHeading->isOn();
3490 bool Main::useFlagGroups()
3492 return actionSettingsUseFlagGroups->isOn();
3495 void Main::windowShowNoteEditor()
3497 textEditor->setShowWithMain(true);
3499 actionViewToggleNoteEditor->setOn (true);
3502 void Main::windowHideNoteEditor()
3504 textEditor->setShowWithMain(false);
3506 actionViewToggleNoteEditor->setOn (false);
3509 void Main::setScript (const QString &script)
3511 scriptEditor->setScript (script);
3514 void Main::runScript (const QString &script)
3516 if (currentMapEditor())
3517 currentMapEditor()->runScript (script);
3520 void Main::showPropertyDialog()
3522 if(currentMapEditor())
3524 LinkableMapObj *sel=currentMapEditor()->getSelection();
3525 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3526 typeid(*sel) == typeid(MapCenterObj)))
3528 branchPropertyWindow->show();
3529 branchPropertyWindow->setMapEditor(currentMapEditor());
3530 branchPropertyWindow->setBranch((BranchObj*)sel);
3535 branchPropertyWindow->setBranch(NULL);
3538 void Main::windowNextEditor()
3540 if (tabWidget->currentPageIndex() < tabWidget->count())
3541 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3544 void Main::windowPreviousEditor()
3546 if (tabWidget->currentPageIndex() >0)
3547 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3550 void Main::standardFlagChanged()
3552 if (currentMapEditor())
3553 currentMapEditor()->toggleStandardFlag(sender()->name());
3556 void Main::testFunction()
3558 if (!currentMapEditor()) return;
3559 currentMapEditor()->testFunction();
3562 void Main::testCommand()
3564 if (!currentMapEditor()) return;
3565 scriptEditor->show();
3568 QString com = QInputDialog::getText(
3569 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3570 if (ok) currentMapEditor()->parseAtom(com);
3574 void Main::helpDoc()
3576 QString locale = QLocale::system().name();
3578 if (locale.left(2)=="es")
3579 docname="vym_es.pdf";
3583 QStringList searchList;
3585 #if defined(Q_OS_MACX)
3586 searchList << "./vym.app/Contents";
3588 // default path in SUSE LINUX
3589 searchList <<"/usr/share/doc/packages/vym/doc";
3592 searchList << "doc"; // relative path for easy testing in tarball
3593 searchList << "doc/tex"; // Easy testing working on vym.tex
3594 searchList << "/usr/share/doc/vym"; // Debian
3595 searchList << "/usr/share/doc/packages";// Knoppix
3599 for (int i=0; i<searchList.count(); ++i)
3601 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3602 if (docfile.exists() )
3611 QMessageBox::critical(0,
3612 tr("Critcal error"),
3613 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3618 Process *pdfProc = new Process();
3619 args <<docfile.fileName();
3621 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3622 if ( !pdfProc->waitForStarted() )
3625 QMessageBox::warning(0,
3627 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3628 tr("Please use Settings->")+tr("Set application to open PDF files"));
3635 void Main::helpAbout()
3638 ad.setName ("aboutwindow");
3639 ad.setMinimumSize(500,500);
3640 ad.resize (QSize (500,500));
3644 void Main::helpAboutQT()
3646 QMessageBox::aboutQt( this, "Qt Application Example" );
3649 void Main::callMacro ()
3651 QAction *action = qobject_cast<QAction *>(sender());
3655 i=action->data().toInt();
3656 QString mDir (settings.value ("macros/macroDir").toString() );
3658 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3660 if ( !f.open( QIODevice::ReadOnly ) )
3662 QMessageBox::warning(0,
3664 tr("Couldn't find a macro at %1.\n").arg(fn)+
3665 tr("Please use Settings->")+tr("Set directory for vym macros"));
3669 QTextStream ts( &f );
3670 QString m= ts.read();
3674 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3675 currentMapEditor()->runScript (m);