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 settingsMenu->addSeparator();
1379 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1380 a->setStatusTip( tr( "Edit branch after adding it" ));
1381 a->setToggleAction(true);
1382 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1383 settingsMenu->addAction (a);
1384 actionSettingsAutoEdit=a;
1386 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1387 a->setStatusTip( tr( "Select branch after adding it" ));
1388 a->setToggleAction(true);
1389 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1390 settingsMenu->addAction (a);
1391 actionSettingsAutoSelectHeading=a;
1393 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1394 a->setStatusTip( tr( "Select heading before editing" ));
1395 a->setToggleAction(true);
1396 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1397 settingsMenu->addAction (a);
1398 actionSettingsAutoSelectText=a;
1400 a= new QAction( tr( "Delete key","Settings action" ), this);
1401 a->setStatusTip( tr( "Delete key for deleting branches" ));
1402 a->setToggleAction(true);
1403 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1404 settingsMenu->addAction (a);
1405 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1406 actionSettingsUseDelKey=a;
1408 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1409 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1410 a->setToggleAction(true);
1411 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1412 settingsMenu->addAction (a);
1413 actionSettingsUseFlagGroups=a;
1415 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1416 a->setStatusTip( tr( "Use hide flag during exports " ));
1417 a->setToggleAction(true);
1418 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1419 settingsMenu->addAction (a);
1420 actionSettingsUseHideExport=a;
1424 void Main::setupTestActions()
1426 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1429 a = new QAction( "Test function" , this);
1430 a->setStatusTip( "Call test function" );
1431 //a->setShortcut (Qt::Key_F4 );
1432 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1433 testMenu->addAction (a);
1434 a = new QAction( "Command" , this);
1435 a->setStatusTip( "Enter command to call in editor" );
1436 //a->setShortcut (Qt::Key_F5 );
1437 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1438 testMenu->addAction (a);
1442 void Main::setupHelpActions()
1444 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1447 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1448 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1449 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1450 helpMenu->addAction (a);
1452 a = new QAction( tr( "About VYM","Help action" ), this);
1453 a->setStatusTip( tr( "About VYM")+vymName);
1454 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1455 helpMenu->addAction (a);
1457 a = new QAction( tr( "About QT","Help action" ), this);
1458 a->setStatusTip( tr( "Information about QT toolkit" ));
1459 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1460 helpMenu->addAction (a);
1464 void Main::setupContextMenus()
1468 // Context Menu for branch or mapcenter
1469 branchContextMenu =new QMenu (this);
1470 branchContextMenu->addAction (actionTogglePropertyDialog);
1471 branchContextMenu->addSeparator();
1474 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1475 branchAddContextMenu->addAction (actionEditPaste );
1476 branchAddContextMenu->addAction ( actionEditAddBranch );
1477 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1478 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1479 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1480 branchAddContextMenu->addSeparator();
1481 branchAddContextMenu->addAction ( actionEditImportAdd );
1482 branchAddContextMenu->addAction ( actionEditImportReplace );
1485 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1486 branchRemoveContextMenu->addAction (actionEditCut);
1487 branchRemoveContextMenu->addAction ( actionEditDelete );
1488 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1489 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1492 actionEditSaveBranch->addTo( branchContextMenu );
1494 branchContextMenu->addSeparator();
1495 branchContextMenu->addAction ( actionEditLoadImage);
1496 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1497 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1499 // Submenu for Links (URLs, vymLinks)
1500 branchLinksContextMenu =new QMenu (this);
1502 branchContextMenu->addSeparator();
1503 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1504 branchLinksContextMenu->addAction ( actionEditOpenURL );
1505 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1506 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1507 branchLinksContextMenu->addAction ( actionEditURL );
1508 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1509 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1510 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1512 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1514 branchLinksContextMenu->addSeparator();
1515 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1516 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1517 branchLinksContextMenu->addAction ( actionEditVymLink );
1518 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1521 // Context Menu for XLinks in a branch menu
1522 // This will be populated "on demand" in MapEditor::updateActions
1523 branchContextMenu->addSeparator();
1524 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1525 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1526 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1527 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1530 // Context menu for floatimage
1531 floatimageContextMenu =new QMenu (this);
1532 a= new QAction (tr ("Save image","Context action"),this);
1533 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1534 floatimageContextMenu->addAction (a);
1536 floatimageContextMenu->addSeparator();
1537 actionEditCopy->addTo( floatimageContextMenu );
1538 actionEditCut->addTo( floatimageContextMenu );
1540 floatimageContextMenu->addSeparator();
1541 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1544 // Context menu for canvas
1545 canvasContextMenu =new QMenu (this);
1546 actionEditMapInfo->addTo( canvasContextMenu );
1547 canvasContextMenu->insertSeparator();
1548 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1549 canvasContextMenu->insertSeparator();
1550 actionFormatLinkColorHint->addTo( canvasContextMenu );
1551 actionFormatLinkColor->addTo( canvasContextMenu );
1552 actionFormatSelectionColor->addTo( canvasContextMenu );
1553 actionFormatBackColor->addTo( canvasContextMenu );
1554 actionFormatBackImage->addTo( canvasContextMenu );
1556 // Menu for last opened files
1558 for (int i = 0; i < MaxRecentFiles; ++i)
1560 recentFileActions[i] = new QAction(this);
1561 recentFileActions[i]->setVisible(false);
1562 fileLastMapsMenu->addAction(recentFileActions[i]);
1563 connect(recentFileActions[i], SIGNAL(triggered()),
1564 this, SLOT(fileLoadRecent()));
1566 setupRecentMapsMenu();
1569 void Main::setupRecentMapsMenu()
1571 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1573 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1575 for (int i = 0; i < numRecentFiles; ++i) {
1576 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1577 recentFileActions[i]->setText(text);
1578 recentFileActions[i]->setData(files[i]);
1579 recentFileActions[i]->setVisible(true);
1581 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1582 recentFileActions[j]->setVisible(false);
1585 void Main::setupMacros()
1587 for (int i = 0; i <= 11; i++)
1589 macroActions[i] = new QAction(this);
1590 macroActions[i]->setData(i);
1591 addAction (macroActions[i]);
1592 connect(macroActions[i], SIGNAL(triggered()),
1593 this, SLOT(callMacro()));
1595 macroActions[0]->setShortcut ( Qt::Key_F1 );
1596 macroActions[1]->setShortcut ( Qt::Key_F2 );
1597 macroActions[2]->setShortcut ( Qt::Key_F3 );
1598 macroActions[3]->setShortcut ( Qt::Key_F4 );
1599 macroActions[4]->setShortcut ( Qt::Key_F5 );
1600 macroActions[5]->setShortcut ( Qt::Key_F6 );
1601 macroActions[6]->setShortcut ( Qt::Key_F7 );
1602 macroActions[7]->setShortcut ( Qt::Key_F8 );
1603 macroActions[8]->setShortcut ( Qt::Key_F9 );
1604 macroActions[9]->setShortcut ( Qt::Key_F10 );
1605 macroActions[10]->setShortcut ( Qt::Key_F11 );
1606 macroActions[11]->setShortcut ( Qt::Key_F12 );
1609 void Main::hideEvent (QHideEvent * )
1611 if (!textEditor->isMinimized() ) textEditor->hide();
1614 void Main::showEvent (QShowEvent * )
1616 if (textEditor->showWithMain()) textEditor->showNormal();
1619 bool Main::reallyWriteDirectory(const QString &dir)
1621 QStringList eList = QDir(dir).entryList();
1622 if (eList.first() ==".") eList.pop_front(); // remove "."
1623 if (eList.first() =="..") eList.pop_front(); // remove "."
1624 if (!eList.isEmpty())
1626 QMessageBox mb( vymName,
1627 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1628 QMessageBox::Warning,
1630 QMessageBox::Cancel | QMessageBox::Default,
1631 QMessageBox::QMessageBox::NoButton );
1633 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1634 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1637 case QMessageBox::Yes:
1640 case QMessageBox::Cancel:
1648 QString Main::browseDirectory (const QString &caption)
1650 QFileDialog fd(this,caption);
1651 fd.setMode (QFileDialog::DirectoryOnly);
1652 fd.setCaption(vymName+ " - "+caption);
1653 fd.setDir (lastFileDir);
1656 if ( fd.exec() == QDialog::Accepted )
1657 return fd.selectedFile();
1662 MapEditor* Main::currentMapEditor() const
1664 if ( tabWidget->currentPage() &&
1665 tabWidget->currentPage()->inherits( "MapEditor" ) )
1666 return (MapEditor*)tabWidget->currentPage();
1671 void Main::editorChanged(QWidget *)
1673 // Unselect all possibly selected objects
1674 // (Important to update note editor)
1677 for (i=0;i<=tabWidget->count() -1;i++)
1680 me=(MapEditor*)tabWidget->page(i);
1683 currentMapEditor()->reselect();
1685 // Update actions to in menus and toolbars according to editor
1689 void Main::fileNew()
1691 QString fn="unnamed";
1692 MapEditor* me = new MapEditor ( NULL);
1693 tabWidget->addTab (me,fn);
1694 tabWidget->showPage(me);
1695 me->viewport()->setFocus();
1696 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1697 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1699 // For the very first map we do not have flagrows yet...
1703 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1705 ErrorCode err=success;
1707 // fn is usually the archive, mapfile the file after uncompressing
1710 // Make fn absolute (needed for unzip)
1711 fn=QDir (fn).absPath();
1717 // Check, if map is already loaded
1719 while (i<=tabWidget->count() -1)
1721 me=(MapEditor*)tabWidget->page(i);
1722 if (me->getFilePath() == fn)
1724 // Already there, ask for confirmation
1725 QMessageBox mb( vymName,
1726 tr("The map %1\nis already opened."
1727 "Opening the same map in multiple editors may lead \n"
1728 "to confusion when finishing working with vym."
1729 "Do you want to").arg(fn),
1730 QMessageBox::Warning,
1731 QMessageBox::Yes | QMessageBox::Default,
1732 QMessageBox::Cancel | QMessageBox::Escape,
1733 QMessageBox::NoButton);
1734 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1735 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1738 case QMessageBox::Yes:
1740 i=tabWidget->count();
1742 case QMessageBox::Cancel:
1754 if ( !fn.isEmpty() )
1756 me = currentMapEditor();
1757 int tabIndex=tabWidget->currentPageIndex();
1758 // Check first, if mapeditor exists
1759 // If it is not default AND we want a new map,
1760 // create a new mapeditor in a new tab
1761 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1763 me= new MapEditor ( NULL);
1764 tabWidget->addTab (me,fn);
1765 tabIndex=tabWidget->indexOf (me);
1766 tabWidget->setCurrentPage (tabIndex);
1767 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1768 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1771 // Check, if file exists (important for creating new files
1772 // from command line
1773 if (!QFile(fn).exists() )
1775 QMessageBox mb( vymName,
1776 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1777 QMessageBox::Question,
1779 QMessageBox::Cancel | QMessageBox::Default,
1780 QMessageBox::NoButton );
1782 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1783 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1786 case QMessageBox::Yes:
1788 currentMapEditor()->setFilePath(fn);
1789 tabWidget->setTabLabel (currentMapEditor(),
1790 currentMapEditor()->getFileName() );
1791 statusBar()->message( "Created " + fn , statusbarTime );
1794 case QMessageBox::Cancel:
1795 // don't create new map
1796 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1803 //tabWidget->currentPage() won't be NULL here, because of above...
1804 tabWidget->showPage(me);
1805 me->viewport()->setFocus();
1807 // Create temporary directory for packing
1809 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1812 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1813 tr("Couldn't create temporary directory before load\n"));
1817 // Try to unzip file
1818 err=unzipDir (tmpMapDir,fn);
1822 me->setZipped(false);
1825 me->setZipped(true);
1827 // Look for mapname.xml
1828 mapfile= fn.left(fn.findRev(".",-1,true));
1829 mapfile=mapfile.section( '/', -1 );
1830 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1831 if (!file.exists() )
1833 // mapname.xml does not exist, well,
1834 // maybe someone renamed the mapname.vym file...
1835 // Try to find any .xml in the toplevel
1836 // directory of the .vym file
1837 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1838 if (flist.count()==1)
1840 // Only one entry, take this one
1841 mapfile=tmpMapDir + "/"+flist.first();
1844 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1845 *it=tmpMapDir + "/" + *it;
1846 // TODO Multiple entries, load all (but only the first one into this ME)
1847 //mainWindow->fileLoadFromTmp (flist);
1848 //returnCode=1; // Silently forget this attempt to load
1849 qWarning ("MainWindow::load (fn) multimap found...");
1852 if (flist.isEmpty() )
1854 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1855 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1858 } //file doesn't exist
1860 mapfile=file.name();
1865 // Save existing filename in case we import
1866 QString fn_org=me->getFilePath();
1868 // Finally load map into mapEditor
1869 me->setFilePath (mapfile,fn);
1870 err=me->load(mapfile,lmode);
1872 // Restore old (maybe empty) filepath, if this is an import
1874 me->setFilePath (fn_org);
1877 // Finally check for errors and go home
1880 if (lmode==NewMap) fileCloseMap();
1881 statusBar()->message( "Could not load " + fn, statusbarTime );
1886 me->setFilePath (fn);
1887 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1888 if (fn.left(9)!="/tmp/vym-")
1890 // Only append to lastMaps if not loaded from a tmpDir
1891 // e.g. imported bookmarks are in a tmpDir
1892 addRecentMap(me->getFilePath() );
1894 actionFilePrint->setEnabled (true);
1896 statusBar()->message( "Loaded " + fn, statusbarTime );
1900 removeDir (QDir(tmpMapDir));
1906 void Main::fileLoad(const LoadMode &lmode)
1908 QStringList filters;
1909 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1910 QFileDialog *fd=new QFileDialog( this);
1911 fd->setDir (lastFileDir);
1912 fd->setFileMode (QFileDialog::ExistingFiles);
1913 fd->setFilters (filters);
1917 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1920 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1923 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1929 if ( fd->exec() == QDialog::Accepted )
1931 lastFileDir=fd->directory().path();
1932 QStringList flist = fd->selectedFiles();
1933 QStringList::Iterator it = flist.begin();
1934 while( it != flist.end() )
1937 fileLoad(*it, lmode);
1944 void Main::fileLoad()
1949 void Main::fileLoadRecent()
1951 QAction *action = qobject_cast<QAction *>(sender());
1953 fileLoad (action->data().toString(), NewMap);
1956 void Main::addRecentMap (const QString &fileName)
1959 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1960 files.removeAll(fileName);
1961 files.prepend(fileName);
1962 while (files.size() > MaxRecentFiles)
1965 settings.setValue("/mainwindow/recentFileList", files);
1967 setupRecentMapsMenu();
1970 void Main::fileSave(const SaveMode &savemode)
1972 // tmp dir for zipping
1976 ErrorCode err=success;
1978 QString safeFilePath;
1980 bool saveZipped=currentMapEditor()->saveZipped();
1982 MapEditor * me=currentMapEditor();
1985 QString fn=me->getFilePath();
1986 // filename=unnamed, filepath="" in constructor...
1987 if ( !fn.isEmpty() )
1989 // We have a filepath, go on saving
1990 // First remove existing file, we
1991 // don't want to add to old zip archives
1995 QMessageBox::warning( 0, tr( "Save Error" ),
1996 fn+ tr("\ncould not be removed before saving"));
1998 // Look, if we should zip the data:
2001 QMessageBox mb( vymName,
2002 tr("The map %1\ndid not use the compressed "
2003 "vym file format.\nWriting it uncompressed will also write images \n"
2004 "and flags and thus may overwrite files in the "
2005 "given directory\n\nDo you want to write the map").arg(fn),
2006 QMessageBox::Warning,
2007 QMessageBox::Yes | QMessageBox::Default,
2009 QMessageBox::Cancel | QMessageBox::Escape);
2010 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2011 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2012 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2015 case QMessageBox::Yes:
2016 // save compressed (default file format)
2019 case QMessageBox::No:
2020 // save uncompressed
2023 case QMessageBox::Cancel:
2032 // Create temporary directory for packing
2034 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2037 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2038 tr("Couldn't create temporary directory before save\n"));
2042 safeFilePath=me->getFilePath();
2043 me->setFilePath (tmpMapDir+"/"+
2044 me->getMapName()+ ".xml",
2046 me->save (savemode);
2047 me->setFilePath (safeFilePath);
2049 zipDir (tmpMapDir,fn);
2054 safeFilePath=me->getFilePath();
2055 me->setFilePath (fn, safeFilePath);
2056 me->save (savemode);
2057 me->setFilePath (safeFilePath);
2059 } // filepath available
2062 // We have no filepath yet,
2063 // call fileSaveAs() now, this will call fileSave()
2065 fileSaveAs(savemode);
2069 if (saveZipped && !tmpMapDir.isEmpty())
2071 removeDir (QDir(tmpMapDir));
2075 statusBar()->message(
2076 tr("Saved %1").arg(me->getFilePath()),
2078 addRecentMap (me->getFilePath() );
2080 statusBar()->message(
2081 tr("Couldn't save ").arg(me->getFilePath()),
2085 void Main::fileSave()
2087 fileSave (CompleteMap);
2090 void Main::fileSaveAs(const SaveMode& savemode)
2094 if (currentMapEditor())
2096 if (savemode==CompleteMap)
2097 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2099 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2100 if ( !fn.isEmpty() )
2102 // Check for existing file
2103 if (QFile (fn).exists())
2105 QMessageBox mb( vymName,
2106 tr("The file %1\nexists already. Do you want to").arg(fn),
2107 QMessageBox::Warning,
2108 QMessageBox::Yes | QMessageBox::Default,
2109 QMessageBox::Cancel | QMessageBox::Escape,
2110 QMessageBox::NoButton);
2111 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2112 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2115 case QMessageBox::Yes:
2118 case QMessageBox::Cancel:
2125 // New file, add extension to filename, if missing
2126 // This is always .vym or .vyp, depending on savemode
2127 if (savemode==CompleteMap)
2129 if (!fn.contains (".vym") && !fn.contains (".xml"))
2133 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2142 currentMapEditor()->setFilePath(fn);
2146 if (savemode==CompleteMap)
2147 tabWidget->setTabLabel (currentMapEditor(),
2148 currentMapEditor()->getFileName() );
2154 void Main::fileSaveAs()
2156 fileSaveAs (CompleteMap);
2159 void Main::fileImportKDEBookmarks()
2161 ImportKDEBookmarks im;
2163 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2164 currentMapEditor()->setFilePath ("");
2167 void Main::fileImportFirefoxBookmarks()
2169 Q3FileDialog *fd=new Q3FileDialog( this);
2170 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2171 fd->setMode (Q3FileDialog::ExistingFiles);
2172 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2173 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2176 if ( fd->exec() == QDialog::Accepted )
2178 ImportFirefoxBookmarks im;
2179 QStringList flist = fd->selectedFiles();
2180 QStringList::Iterator it = flist.begin();
2181 while( it != flist.end() )
2184 if (im.transform() &&
2185 success==fileLoad (im.getTransformedFile(),NewMap) &&
2186 currentMapEditor() )
2187 currentMapEditor()->setFilePath ("");
2194 void Main::fileImportMM()
2198 Q3FileDialog *fd=new Q3FileDialog( this);
2199 fd->setDir (lastFileDir);
2200 fd->setMode (Q3FileDialog::ExistingFiles);
2201 fd->addFilter ("Mind Manager (*.mmap)");
2202 fd->setCaption(tr("Import")+" "+"Mind Manager");
2205 if ( fd->exec() == QDialog::Accepted )
2207 lastFileDir=fd->dirPath();
2208 QStringList flist = fd->selectedFiles();
2209 QStringList::Iterator it = flist.begin();
2210 while( it != flist.end() )
2213 if (im.transform() &&
2214 success==fileLoad (im.getTransformedFile(),NewMap) &&
2215 currentMapEditor() )
2216 currentMapEditor()->setFilePath ("");
2225 void Main::fileImportDir()
2227 if (currentMapEditor())
2228 currentMapEditor()->importDir();
2231 void Main::fileExportXML()
2233 if (currentMapEditor())
2235 QString dir=browseDirectory(tr("Export XML to directory"));
2236 if (dir !="" && reallyWriteDirectory(dir) )
2237 currentMapEditor()->exportXML(dir);
2242 void Main::fileExportXHTML()
2244 MapEditor *me=currentMapEditor();
2248 ExportXHTMLDialog dia(this);
2249 dia.setFilePath (me->getFilePath() );
2250 dia.setMapName (me->getMapName() );
2253 if (dia.exec()==QDialog::Accepted)
2255 QString dir=dia.getDir();
2256 // Check, if warnings should be used before overwriting
2257 // the output directory
2259 warn.showCancelButton (true);
2260 warn.setText(QString(
2261 "The directory %1 is not empty.\n"
2262 "Do you risk to overwrite some of its contents?").arg(dir));
2263 warn.setCaption("Warning: Directory not empty");
2264 warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
2265 if (warn.exec()==QDialog::Accepted)
2267 me->exportXML (dia.getDir() );
2268 dia.doExport(me->getMapName() );
2269 if (dia.hasChanged())
2276 void Main::fileExportImage()
2278 MapEditor *me=currentMapEditor();
2282 QFileDialog *fd=new QFileDialog (this);
2283 fd->setCaption (tr("Export map as image"));
2284 fd->setDirectory (lastImageDir);
2285 fd->setFileMode(QFileDialog::AnyFile);
2286 fd->setFilters (imageIO.getFilters() );
2289 fl=fd->selectedFiles();
2290 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2291 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2296 void Main::fileExportASCII()
2298 MapEditor *me=currentMapEditor();
2302 ex.setMapCenter(me->getMapCenter());
2303 ex.addFilter ("TXT (*.txt)");
2304 ex.setDir(lastImageDir);
2305 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2306 if (ex.execDialog() )
2308 me->setExportMode(true);
2310 me->setExportMode(false);
2315 void Main::fileExportLaTeX()
2317 MapEditor *me=currentMapEditor();
2321 ex.setMapCenter(me->getMapCenter());
2322 ex.addFilter ("Tex (*.tex)");
2323 ex.setDir(lastImageDir);
2324 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2325 if (ex.execDialog() )
2327 me->setExportMode(true);
2329 me->setExportMode(false);
2334 void Main::fileExportKDEBookmarks()
2336 ExportKDEBookmarks ex;
2337 MapEditor *me=currentMapEditor();
2340 ex.setMapCenter (me->getMapCenter() );
2345 void Main::fileExportTaskjuggler()
2347 ExportTaskjuggler ex;
2348 MapEditor *me=currentMapEditor();
2351 ex.setMapCenter (me->getMapCenter() );
2352 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2353 ex.setDir(lastImageDir);
2354 ex.addFilter ("Taskjuggler (*.tjp)");
2355 if (ex.execDialog() )
2357 me->setExportMode(true);
2359 me->setExportMode(false);
2364 void Main::fileExportOOPresentation()
2366 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2367 // TODO add preview in dialog
2368 //ImagePreview *p =new ImagePreview (fd);
2369 //fd->setContentsPreviewEnabled( TRUE );
2370 //fd->setContentsPreview( p, p );
2371 //fd->setPreviewMode( QFileDialog::Contents );
2372 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2373 fd->setDir (QDir().current());
2374 if (fd->foundConfig())
2378 if ( fd->exec() == QDialog::Accepted )
2380 QString fn=fd->selectedFile();
2381 if (!fn.contains (".odp"))
2384 //lastImageDir=fn.left(fn.findRev ("/"));
2385 if (currentMapEditor())
2386 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2390 QMessageBox::warning(0,
2392 tr("Couldn't find configuration for export to Open Office\n"));
2396 void Main::fileCloseMap()
2398 if (currentMapEditor())
2400 if (currentMapEditor()->hasChanged())
2402 QMessageBox mb( vymName,
2403 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2404 QMessageBox::Warning,
2405 QMessageBox::Yes | QMessageBox::Default,
2407 QMessageBox::Cancel | QMessageBox::Escape );
2408 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2409 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2412 case QMessageBox::Yes:
2414 fileSave(CompleteMap);
2416 case QMessageBox::No:
2417 // close without saving
2419 case QMessageBox::Cancel:
2424 currentMapEditor()->closeMap();
2425 tabWidget->removePage(currentMapEditor());
2426 if (tabWidget->count()==0)
2427 actionFilePrint->setEnabled (false);
2431 void Main::filePrint()
2433 if (currentMapEditor())
2434 currentMapEditor()->print();
2437 void Main::fileExitVYM()
2439 // Check if one or more editors have changed
2442 for (i=0;i<=tabWidget->count() -1;i++)
2445 me=(MapEditor*)tabWidget->page(i);
2447 // If something changed, ask what to do
2448 if (me->isUnsaved())
2450 tabWidget->setCurrentPage(i);
2451 QMessageBox mb( vymName,
2452 tr("This map is not saved yet. Do you want to"),
2453 QMessageBox::Warning,
2454 QMessageBox::Yes | QMessageBox::Default,
2456 QMessageBox::Cancel | QMessageBox::Escape );
2457 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2458 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2461 mb.setActiveWindow();
2462 switch( mb.exec() ) {
2463 case QMessageBox::Yes:
2464 // save (the changed editors) and exit
2465 fileSave(CompleteMap);
2467 case QMessageBox::No:
2468 // exit without saving
2470 case QMessageBox::Cancel:
2471 // don't save and don't exit
2475 } // loop over all MEs
2479 void Main::editUndo()
2481 if (currentMapEditor())
2482 currentMapEditor()->undo();
2485 void Main::editRedo()
2487 if (currentMapEditor())
2488 currentMapEditor()->redo();
2491 void Main::gotoHistoryStep (int i)
2493 if (currentMapEditor())
2494 currentMapEditor()->gotoHistoryStep (i);
2497 void Main::editCopy()
2499 if (currentMapEditor())
2500 currentMapEditor()->copy();
2503 void Main::editPaste()
2505 if (currentMapEditor())
2506 currentMapEditor()->paste();
2509 void Main::editCut()
2511 if (currentMapEditor())
2512 currentMapEditor()->cut();
2515 void Main::editOpenFindWindow()
2517 findWindow->popup();
2518 findWindow->raise();
2519 findWindow->setActiveWindow();
2522 void Main::editFind(QString s)
2525 BranchObj *bo=currentMapEditor()->findText(s, cs);
2528 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2531 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2532 tr("No matches found for \"%1\"").arg(s));
2536 void Main::editFindChanged()
2537 { // Notify editor, to abort the current find process
2538 currentMapEditor()->findReset();
2541 void Main::openTabs(QStringList urls)
2543 if (!urls.isEmpty())
2547 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2549 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2551 QString u=urls.takeFirst();
2552 procBrowser = new QProcess( this );
2554 procBrowser->start(browser,args);
2555 if ( !procBrowser->waitForStarted())
2557 // try to set path to browser
2558 QMessageBox::warning(0,
2560 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2561 tr("Please use Settings->")+tr("Set application to open an URL"));
2566 if (browser.contains("konqueror"))
2568 for (int i=0; i<urls.size(); i++)
2571 // Try to open new tab in existing konqueror started previously by vym
2572 p=new QProcess (this);
2574 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2575 "konqueror-mainwindow#1"<<
2578 p->start ("dcop",args);
2579 if ( !p->waitForStarted() ) success=false;
2582 QMessageBox::warning(0,
2584 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2586 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2588 for (int i=0; i<urls.size(); i++)
2590 // Try to open new tab in firefox
2591 p=new QProcess (this);
2592 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2593 p->start (browser,args);
2594 if ( !p->waitForStarted() ) success=false;
2597 QMessageBox::warning(0,
2599 tr("Couldn't start %1 to open a new tab").arg(browser));
2602 QMessageBox::warning(0,
2604 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2608 void Main::editOpenURL()
2611 if (currentMapEditor())
2613 QString url=currentMapEditor()->getURL();
2615 if (url=="") return;
2616 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2617 procBrowser = new QProcess( this );
2619 procBrowser->start(browser,args);
2620 if ( !procBrowser->waitForStarted())
2622 // try to set path to browser
2623 QMessageBox::warning(0,
2625 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2626 tr("Please use Settings->")+tr("Set application to open an URL"));
2631 void Main::editOpenURLTab()
2633 if (currentMapEditor())
2636 urls.append(currentMapEditor()->getURL());
2640 void Main::editOpenMultipleURLTabs()
2642 if (currentMapEditor())
2645 urls=currentMapEditor()->getURLs();
2651 void Main::editURL()
2653 if (currentMapEditor())
2654 currentMapEditor()->editURL();
2657 void Main::editHeading2URL()
2659 if (currentMapEditor())
2660 currentMapEditor()->editHeading2URL();
2663 void Main::editBugzilla2URL()
2665 if (currentMapEditor())
2666 currentMapEditor()->editBugzilla2URL();
2669 void Main::editFATE2URL()
2671 if (currentMapEditor())
2672 currentMapEditor()->editFATE2URL();
2675 void Main::editHeadingFinished()
2677 // only called from editHeading(), so there is a currentME
2678 MapEditor *me=currentMapEditor();
2681 QPoint p; //Not used here, only to find out pos of branch
2683 QString s=me->getHeading(ok,p);
2685 #if defined(Q_OS_MACX)
2687 if (ok && s!=lineedit->text())
2688 me->setHeading(lineedit->text());
2690 lineedit->releaseKeyboard();
2694 if (!prevSelection.isEmpty()) me->select(prevSelection);
2699 void Main::editHeading()
2701 if (currentMapEditor())
2703 MapEditor *me=currentMapEditor();
2704 QString oldSel=me->getSelectString();
2706 if (lineedit->isVisible())
2707 editHeadingFinished();
2712 QString s=currentMapEditor()->getHeading(ok,p);
2716 #if defined(Q_OS_MACX)
2717 p=currentMapEditor()->mapTo (this,p);
2718 QDialog *d =new QDialog(NULL);
2719 QLineEdit *le=new QLineEdit (d);
2720 d->setWindowFlags (Qt::FramelessWindowHint);
2721 d->setGeometry(p.x(),p.y(),230,25);
2722 le->resize (d->width()-10,d->height());
2725 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2726 d->activateWindow();
2728 currentMapEditor()->setHeading (le->text());
2731 editHeadingFinished();
2733 p=currentMapEditor()->mapTo (this,p);
2734 lineedit->setGeometry(p.x(),p.y(),230,25);
2735 lineedit->setText(s);
2736 lineedit->setCursorPosition(1);
2737 lineedit->selectAll();
2739 lineedit->grabKeyboard();
2740 lineedit->setFocus();
2744 } // currentMapEditor()
2747 void Main::openVymLinks(const QStringList &vl)
2749 for (int j=0; j<vl.size(); j++)
2751 // compare path with already loaded maps
2755 for (i=0;i<=tabWidget->count() -1;i++)
2757 me=(MapEditor*)tabWidget->page(i);
2758 if (vl.at(j)==me->getFilePath() )
2767 if (!QFile(vl.at(j)).exists() )
2768 QMessageBox::critical( 0, tr( "Critical Error" ),
2769 tr("Couldn't open map %1").arg(vl.at(j)));
2772 fileLoad (vl.at(j), NewMap);
2773 tabWidget->setCurrentPage (tabWidget->count()-1);
2776 // Go to tab containing the map
2777 tabWidget->setCurrentPage (index);
2781 void Main::editOpenVymLink()
2783 if (currentMapEditor())
2786 vl.append(currentMapEditor()->getVymLink());
2791 void Main::editOpenMultipleVymLinks()
2793 QString currentVymLink;
2794 if (currentMapEditor())
2796 QStringList vl=currentMapEditor()->getVymLinks();
2801 void Main::editVymLink()
2803 if (currentMapEditor())
2804 currentMapEditor()->editVymLink();
2807 void Main::editDeleteVymLink()
2809 if (currentMapEditor())
2810 currentMapEditor()->deleteVymLink();
2813 void Main::editToggleHideExport()
2815 if (currentMapEditor())
2816 currentMapEditor()->toggleHideExport();
2819 void Main::editMapInfo()
2821 if (currentMapEditor())
2822 currentMapEditor()->editMapInfo();
2825 void Main::editMoveUp()
2827 if (currentMapEditor())
2828 currentMapEditor()->moveBranchUp();
2831 void Main::editMoveDown()
2833 if (currentMapEditor())
2834 currentMapEditor()->moveBranchDown();
2837 void Main::editToggleScroll()
2839 if (currentMapEditor())
2841 currentMapEditor()->toggleScroll();
2845 void Main::editUnScrollAll()
2847 if (currentMapEditor())
2848 currentMapEditor()->unscrollChilds();
2851 void Main::editNewBranch()
2853 MapEditor *me=currentMapEditor();
2854 if (!lineedit->isVisible() && me)
2856 BranchObj *bo=(BranchObj*)me->getSelection();
2857 BranchObj *newbo=me->addNewBranch(0);
2860 me->select (newbo->getSelectString());
2864 if (actionSettingsAutoEdit->isOn())
2866 if (!actionSettingsAutoSelectHeading->isOn())
2867 prevSelection=bo->getSelectString();
2873 void Main::editNewBranchBefore()
2875 MapEditor *me=currentMapEditor();
2876 if (!lineedit->isVisible() && me)
2878 BranchObj *bo=(BranchObj*)me->getSelection();
2879 BranchObj *newbo=me->addNewBranchBefore();
2882 me->select (newbo->getSelectString());
2886 if (actionSettingsAutoEdit->isOn())
2888 if (!actionSettingsAutoSelectHeading->isOn())
2889 prevSelection=bo->getSelectString();
2895 void Main::editNewBranchAbove()
2897 MapEditor *me=currentMapEditor();
2898 if (!lineedit->isVisible() && me)
2900 BranchObj *bo=(BranchObj*)me->getSelection();
2901 BranchObj *newbo=me->addNewBranch (-1);
2904 me->select (newbo->getSelectString());
2908 if (actionSettingsAutoEdit->isOn())
2910 if (!actionSettingsAutoSelectHeading->isOn())
2911 prevSelection=bo->getSelectString();
2917 void Main::editNewBranchBelow()
2919 MapEditor *me=currentMapEditor();
2920 if (!lineedit->isVisible() && me)
2922 BranchObj *bo=(BranchObj*)me->getSelection();
2923 BranchObj *newbo=me->addNewBranch (1);
2926 me->select (newbo->getSelectString());
2930 if (actionSettingsAutoEdit->isOn())
2932 if (!actionSettingsAutoSelectHeading->isOn())
2933 prevSelection=bo->getSelectString();
2939 void Main::editImportAdd()
2941 fileLoad (ImportAdd);
2944 void Main::editImportReplace()
2946 fileLoad (ImportReplace);
2949 void Main::editSaveBranch()
2951 fileSaveAs (PartOfMap);
2954 void Main::editDeleteKeepChilds()
2956 if (currentMapEditor())
2957 currentMapEditor()->deleteKeepChilds();
2960 void Main::editDeleteChilds()
2962 if (currentMapEditor())
2963 currentMapEditor()->deleteChilds();
2966 void Main::editDeleteSelection()
2968 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2969 currentMapEditor()->deleteSelection();
2972 void Main::editUpperBranch()
2974 if (currentMapEditor())
2975 currentMapEditor()->selectUpperBranch();
2978 void Main::editLowerBranch()
2980 if (currentMapEditor())
2981 currentMapEditor()->selectLowerBranch();
2984 void Main::editLeftBranch()
2986 if (currentMapEditor())
2987 currentMapEditor()->selectLeftBranch();
2990 void Main::editRightBranch()
2992 if (currentMapEditor())
2993 currentMapEditor()->selectRightBranch();
2996 void Main::editFirstBranch()
2998 if (currentMapEditor())
2999 currentMapEditor()->selectFirstBranch();
3002 void Main::editLastBranch()
3004 if (currentMapEditor())
3005 currentMapEditor()->selectLastBranch();
3008 void Main::editLoadImage()
3010 if (currentMapEditor())
3011 currentMapEditor()->loadFloatImage();
3014 void Main::editSaveImage()
3016 if (currentMapEditor())
3017 currentMapEditor()->saveFloatImage();
3020 void Main::editFollowXLink(QAction *a)
3023 if (currentMapEditor())
3024 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3027 void Main::editEditXLink(QAction *a)
3029 if (currentMapEditor())
3030 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3033 void Main::formatSelectColor()
3035 if (currentMapEditor())
3037 QColor col = QColorDialog::getColor((currentColor ), this );
3038 if ( !col.isValid() ) return;
3039 colorChanged( col );
3043 void Main::formatPickColor()
3045 if (currentMapEditor())
3046 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3049 void Main::colorChanged(QColor c)
3051 QPixmap pix( 16, 16 );
3053 actionFormatColor->setIconSet( pix );
3057 void Main::formatColorBranch()
3059 if (currentMapEditor())
3060 currentMapEditor()->colorBranch(currentColor);
3063 void Main::formatColorSubtree()
3065 if (currentMapEditor())
3066 currentMapEditor()->colorSubtree (currentColor);
3069 void Main::formatLinkStyleLine()
3071 if (currentMapEditor())
3072 currentMapEditor()->setMapLinkStyle("StyleLine");
3075 void Main::formatLinkStyleParabel()
3077 if (currentMapEditor())
3078 currentMapEditor()->setMapLinkStyle("StyleParabel");
3081 void Main::formatLinkStylePolyLine()
3083 if (currentMapEditor())
3084 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3087 void Main::formatLinkStylePolyParabel()
3089 if (currentMapEditor())
3090 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3093 void Main::formatSelectBackColor()
3095 if (currentMapEditor())
3096 currentMapEditor()->selectMapBackgroundColor();
3099 void Main::formatSelectBackImage()
3101 if (currentMapEditor())
3102 currentMapEditor()->selectMapBackgroundImage();
3105 void Main::formatSelectLinkColor()
3107 if (currentMapEditor())
3108 currentMapEditor()->selectMapLinkColor();
3111 void Main::formatSelectSelectionColor()
3113 if (currentMapEditor())
3114 currentMapEditor()->selectMapSelectionColor();
3117 void Main::formatToggleLinkColorHint()
3119 currentMapEditor()->toggleMapLinkColorHint();
3123 void Main::formatIncludeImagesVer()
3125 if (currentMapEditor())
3126 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3129 void Main::formatIncludeImagesHor()
3131 if (currentMapEditor())
3132 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3135 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3137 if (currentMapEditor())
3138 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3141 void Main::viewZoomReset()
3143 if (currentMapEditor())
3147 currentMapEditor()->setMatrix( m );
3151 void Main::viewZoomIn()
3153 if (currentMapEditor())
3155 QMatrix m = currentMapEditor()->matrix();
3156 m.scale( 1.25, 1.25 );
3157 currentMapEditor()->setMatrix( m );
3161 void Main::viewZoomOut()
3163 if (currentMapEditor())
3165 QMatrix m = currentMapEditor()->matrix();
3166 m.scale( 0.8, 0.8 );
3167 currentMapEditor()->setMatrix( m );
3171 bool Main::settingsPDF()
3173 // Default browser is set in constructor
3175 QString text = QInputDialog::getText(
3176 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3177 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3179 settings.setValue ("/mainwindow/readerPDF",text);
3184 bool Main::settingsURL()
3186 // Default browser is set in constructor
3188 QString text = QInputDialog::getText(
3189 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3190 settings.value("/mainwindow/readerURL").toString()
3193 settings.setValue ("/mainwindow/readerURL",text);
3197 void Main::settingsToggleDelKey()
3199 if (actionSettingsUseDelKey->isOn())
3201 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3204 actionEditDelete->setAccel (QKeySequence (""));
3208 void Main::windowToggleNoteEditor()
3210 if (textEditor->showWithMain() )
3211 windowHideNoteEditor();
3213 windowShowNoteEditor();
3216 void Main::windowToggleHistory()
3218 if (historyWindow->isVisible())
3219 historyWindow->hide();
3221 historyWindow->show();
3225 void Main::windowToggleAntiAlias()
3227 bool b=actionViewToggleAntiAlias->isOn();
3229 for (int i=0;i<tabWidget->count();i++)
3232 me=(MapEditor*)tabWidget->page(i);
3233 me->setAntiAlias(b);
3238 void Main::windowToggleSmoothPixmap()
3240 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3242 for (int i=0;i<tabWidget->count();i++)
3245 me=(MapEditor*)tabWidget->page(i);
3246 me->setSmoothPixmap(b);
3250 void Main::updateHistory(SimpleSettings &undoSet)
3252 historyWindow->update (undoSet);
3255 void Main::updateNoteFlag()
3257 if (currentMapEditor())
3258 currentMapEditor()->updateNoteFlag();
3261 void Main::updateSatellites(MapEditor *me)
3263 branchPropertyWindow->setMapEditor (me);
3266 void Main::updateActions()
3268 MapEditor *me=currentMapEditor();
3271 historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
3273 // updateActions is also called when NoteEditor is closed
3274 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3275 actionViewToggleHistoryWindow->setOn (historyWindow->showWithMain());
3277 if (me->getMapLinkColorHint()==HeadingColor)
3278 actionFormatLinkColorHint->setOn(true);
3280 actionFormatLinkColorHint->setOn(false);
3282 switch (me->getMapLinkStyle())
3285 actionFormatLinkStyleLine->setOn(true);
3288 actionFormatLinkStyleParabel->setOn(true);
3291 actionFormatLinkStylePolyLine->setOn(true);
3293 case StylePolyParabel:
3294 actionFormatLinkStylePolyParabel->setOn(true);
3301 QPixmap pix( 16, 16 );
3302 pix.fill( me->getMapBackgroundColor() );
3303 actionFormatBackColor->setIconSet( pix );
3304 pix.fill( me->getSelectionColor() );
3305 actionFormatSelectionColor->setIconSet( pix );
3306 pix.fill( me->getMapDefLinkColor() );
3307 actionFormatLinkColor->setIconSet( pix );
3310 actionFileSave->setEnabled( me->isUnsaved() );
3311 if (me->isUndoAvailable())
3312 actionEditUndo->setEnabled( true);
3314 actionEditUndo->setEnabled( false);
3316 if (me->isRedoAvailable())
3317 actionEditRedo->setEnabled( true);
3319 actionEditRedo->setEnabled( false);
3321 LinkableMapObj *selection=me->getSelection();
3324 if ( (typeid(*selection) == typeid(BranchObj)) ||
3325 (typeid(*selection) == typeid(MapCenterObj)) )
3327 BranchObj *bo=(BranchObj*)selection;
3328 // Take care of links
3329 if (bo->countXLinks()==0)
3331 branchXLinksContextMenuEdit->clear();
3332 branchXLinksContextMenuFollow->clear();
3337 branchXLinksContextMenuEdit->clear();
3338 branchXLinksContextMenuFollow->clear();
3339 for (int i=0; i<=bo->countXLinks();i++)
3341 bot=bo->XLinkTargetAt(i);
3344 s=bot->getHeading();
3347 branchXLinksContextMenuFollow->addAction (s);
3348 branchXLinksContextMenuEdit->addAction (s);
3353 standardFlagsDefault->setEnabled (true);
3355 actionEditToggleScroll->setEnabled (true);
3356 if ( bo->isScrolled() )
3357 actionEditToggleScroll->setOn(true);
3359 actionEditToggleScroll->setOn(false);
3361 if ( bo->getURL().isEmpty() )
3363 actionEditOpenURL->setEnabled (false);
3364 actionEditOpenURLTab->setEnabled (false);
3368 actionEditOpenURL->setEnabled (true);
3369 actionEditOpenURLTab->setEnabled (true);
3371 if ( bo->getVymLink().isEmpty() )
3373 actionEditOpenVymLink->setEnabled (false);
3374 actionEditDeleteVymLink->setEnabled (false);
3377 actionEditOpenVymLink->setEnabled (true);
3378 actionEditDeleteVymLink->setEnabled (true);
3381 if (bo->canMoveBranchUp())
3382 actionEditMoveUp->setEnabled (true);
3384 actionEditMoveUp->setEnabled (false);
3385 if (bo->canMoveBranchDown())
3386 actionEditMoveDown->setEnabled (true);
3388 actionEditMoveDown->setEnabled (false);
3391 actionEditToggleHideExport->setEnabled (true);
3392 actionEditToggleHideExport->setOn (bo->hideInExport() );
3394 actionEditCopy->setEnabled (true);
3395 actionEditCut->setEnabled (true);
3396 if (!clipboardEmpty)
3397 actionEditPaste->setEnabled (true);
3399 actionEditPaste->setEnabled (false);
3400 for (int i=0; i<actionListBranches.size(); ++i)
3401 actionListBranches.at(i)->setEnabled(true);
3402 actionEditDelete->setEnabled (true);
3403 actionFormatIncludeImagesVer->setOn
3404 ( ((BranchObj*)selection)->getIncludeImagesVer());
3405 actionFormatIncludeImagesHor->setOn
3406 ( ((BranchObj*)selection)->getIncludeImagesHor());
3407 actionFormatHideLinkUnselected->setOn
3408 (selection->getHideLinkUnselected());
3410 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3412 FloatObj *fo=(FloatImageObj*)selection;
3414 actionEditOpenURL->setEnabled (false);
3415 actionEditOpenVymLink->setEnabled (false);
3416 actionEditDeleteVymLink->setEnabled (false);
3417 actionEditToggleHideExport->setEnabled (true);
3418 actionEditToggleHideExport->setOn (fo->hideInExport() );
3421 actionEditCopy->setEnabled (true);
3422 actionEditCut->setEnabled (true);
3423 actionEditPaste->setEnabled (false);
3424 for (int i=0; i<actionListBranches.size(); ++i)
3425 actionListBranches.at(i)->setEnabled(false);
3426 actionEditDelete->setEnabled (true);
3427 actionFormatHideLinkUnselected->setOn
3428 ( selection->getHideLinkUnselected());
3429 actionEditMoveUp->setEnabled (false);
3430 actionEditMoveDown->setEnabled (false);
3435 actionEditCopy->setEnabled (false);
3436 actionEditCut->setEnabled (false);
3437 actionEditPaste->setEnabled (false);
3438 for (int i=0; i<actionListBranches.size(); ++i)
3439 actionListBranches.at(i)->setEnabled(false);
3441 actionEditToggleScroll->setEnabled (false);
3442 actionEditOpenURL->setEnabled (false);
3443 actionEditOpenVymLink->setEnabled (false);
3444 actionEditDeleteVymLink->setEnabled (false);
3445 actionEditHeading2URL->setEnabled (false);
3446 actionEditDelete->setEnabled (false);
3447 actionEditMoveUp->setEnabled (false);
3448 actionEditMoveDown->setEnabled (false);
3449 actionEditToggleHideExport->setEnabled (false);
3453 ModMode Main::getModMode()
3455 if (actionModModeColor->isOn()) return ModModeColor;
3456 if (actionModModeCopy->isOn()) return ModModeCopy;
3457 if (actionModModeXLink->isOn()) return ModModeXLink;
3461 bool Main::autoEdit()
3463 return actionSettingsAutoEdit->isOn();
3466 bool Main::autoSelectHeading()
3468 return actionSettingsAutoSelectHeading->isOn();
3471 bool Main::useFlagGroups()
3473 return actionSettingsUseFlagGroups->isOn();
3476 void Main::windowShowNoteEditor()
3478 textEditor->setShowWithMain(true);
3480 actionViewToggleNoteEditor->setOn (true);
3483 void Main::windowHideNoteEditor()
3485 textEditor->setShowWithMain(false);
3487 actionViewToggleNoteEditor->setOn (false);
3490 void Main::setScript (const QString &script)
3492 scriptEditor->setScript (script);
3495 void Main::runScript (const QString &script)
3497 if (currentMapEditor())
3498 currentMapEditor()->runScript (script);
3501 void Main::showPropertyDialog()
3503 if(currentMapEditor())
3505 LinkableMapObj *sel=currentMapEditor()->getSelection();
3506 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3507 typeid(*sel) == typeid(MapCenterObj)))
3509 branchPropertyWindow->show();
3510 branchPropertyWindow->setMapEditor(currentMapEditor());
3511 branchPropertyWindow->setBranch((BranchObj*)sel);
3516 branchPropertyWindow->setBranch(NULL);
3519 void Main::windowNextEditor()
3521 if (tabWidget->currentPageIndex() < tabWidget->count())
3522 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3525 void Main::windowPreviousEditor()
3527 if (tabWidget->currentPageIndex() >0)
3528 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3531 void Main::standardFlagChanged()
3533 if (currentMapEditor())
3534 currentMapEditor()->toggleStandardFlag(sender()->name());
3537 void Main::testFunction()
3539 if (!currentMapEditor()) return;
3540 currentMapEditor()->testFunction();
3543 void Main::testCommand()
3545 if (!currentMapEditor()) return;
3546 scriptEditor->show();
3549 QString com = QInputDialog::getText(
3550 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3551 if (ok) currentMapEditor()->parseAtom(com);
3555 void Main::helpDoc()
3557 QString locale = QLocale::system().name();
3559 if (locale.left(2)=="es")
3560 docname="vym_es.pdf";
3564 QStringList searchList;
3566 #if defined(Q_OS_MACX)
3567 searchList << "./vym.app/Contents";
3569 // default path in SUSE LINUX
3570 searchList <<"/usr/share/doc/packages/vym/doc";
3573 searchList << "doc"; // relative path for easy testing in tarball
3574 searchList << "doc/tex"; // Easy testing working on vym.tex
3575 searchList << "/usr/share/doc/vym"; // Debian
3576 searchList << "/usr/share/doc/packages";// Knoppix
3580 for (int i=0; i<searchList.count(); ++i)
3582 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3583 if (docfile.exists() )
3592 QMessageBox::critical(0,
3593 tr("Critcal error"),
3594 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3599 Process *pdfProc = new Process();
3600 args <<docfile.fileName();
3602 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3603 if ( !pdfProc->waitForStarted() )
3606 QMessageBox::warning(0,
3608 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3609 tr("Please use Settings->")+tr("Set application to open PDF files"));
3616 void Main::helpAbout()
3619 ad.setName ("aboutwindow");
3620 ad.setMinimumSize(500,500);
3621 ad.resize (QSize (500,500));
3625 void Main::helpAboutQT()
3627 QMessageBox::aboutQt( this, "Qt Application Example" );
3630 void Main::callMacro ()
3632 QAction *action = qobject_cast<QAction *>(sender());
3636 i=action->data().toInt();
3637 QString mDir (settings.value ("macros/macroDir").toString() );
3639 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3641 if ( !f.open( QIODevice::ReadOnly ) )
3643 QMessageBox::warning(0,
3645 tr("Couldn't find a macro at %1.\n").arg(fn)+
3646 tr("Please use Settings->")+tr("Set directory for vym macros"));
3650 QTextStream ts( &f );
3651 QString m= ts.read();
3655 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3656 currentMapEditor()->runScript (m);