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"
23 extern TextEditor *textEditor;
24 extern Main *mainWindow;
25 extern QString tmpVymDir;
26 extern QString clipboardDir;
27 extern bool clipboardEmpty;
28 extern int statusbarTime;
29 extern FlagRowObj* standardFlagsDefault;
30 extern FlagRowObj* systemFlagsDefault;
31 extern QString vymName;
32 extern QString vymVersion;
33 extern QString vymBuildDate;
35 QMenu* branchContextMenu;
36 QMenu* branchAddContextMenu;
37 QMenu* branchRemoveContextMenu;
38 QMenu* branchLinksContextMenu;
39 QMenu* branchXLinksContextMenuEdit;
40 QMenu* branchXLinksContextMenuFollow;
41 QMenu* floatimageContextMenu;
42 QMenu* canvasContextMenu;
43 QMenu* fileLastMapsMenu;
44 QMenu* fileImportMenu;
45 QMenu* fileExportMenu;
48 extern Settings settings;
49 extern Options options;
50 extern ImageIO imageIO;
52 extern QDir vymBaseDir;
53 extern QDir lastImageDir;
54 extern QDir lastFileDir;
55 extern QString iconPath;
56 extern QString flagsPath;
58 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
59 QMainWindow(parent,name,f)
63 setCaption ("VYM - View Your Mind");
65 // Load window settings
66 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
67 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
70 // Sometimes we may need to remember old selections
74 currentColor=Qt::black;
76 // Create unique temporary directory
78 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
81 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
85 // Create direcctory for clipboard
86 clipboardDir=tmpVymDir+"/clipboard";
88 d.mkdir (clipboardDir,true);
89 makeSubDirs (clipboardDir);
94 // Initialize history window;
95 historyWindow=new HistoryWindow();
97 // Initialize properties window
98 branchPropertyWindow = new BranchPropertyWindow();
99 branchPropertyWindow->move (20,20);
101 // Initialize script editor
102 scriptEditor = new SimpleScriptEditor();
103 scriptEditor->move (50,50);
105 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
106 this, SLOT( runScript( QString ) ) );
108 // Initialize some settings, which are platform dependant
111 // application to open URLs
112 p="/mainwindow/readerURL";
113 #if defined(Q_OS_LINUX)
114 s=settings.value (p,"konqueror").toString();
116 #if defined(Q_OS_MACX)
117 s=settings.value (p,"/usr/bin/open").toString();
119 s=settings.value (p,"mozilla");
122 settings.setValue( p,s);
124 // application to open PDFs
125 p="/mainwindow/readerPDF";
126 #if defined(Q_OS_LINUX)
127 s=settings.value (p,"acroread").toString();
129 #if defined(Q_OS_MACX)
130 s=settings.value (p,"/usr/bin/open").toString();
132 s=settings.value (p,"acroread").toString();
135 settings.setValue( p,s);
138 // Create tab widget which holds the maps
139 tabWidget= new QTabWidget (this);
140 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
141 this, SLOT( editorChanged( QWidget * ) ) );
143 lineedit=new QLineEdit (this);
146 setCentralWidget(tabWidget);
150 setupFormatActions();
154 setupSettingsActions();
156 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
161 restoreState (settings.value("/mainwindow/state",0).toByteArray());
163 // Initialize Find window
164 findWindow=new FindWindow(NULL);
165 findWindow->move (x(),y()+70);
166 connect (findWindow, SIGNAL( findButton(QString) ),
167 this, SLOT(editFind(QString) ) );
168 connect (findWindow, SIGNAL( somethingChanged() ),
169 this, SLOT(editFindChanged() ) );
171 // Connect TextEditor, so that we can update flags if text changes
172 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
173 connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions()));
181 settings.setValue ( "/mainwindow/geometry/size", size() );
182 settings.setValue ( "/mainwindow/geometry/pos", pos() );
183 settings.setValue ("/mainwindow/state",saveState(0));
185 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
186 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
187 settings.setValue( "/version/version", vymVersion );
188 settings.setValue( "/version/builddate", vymBuildDate );
190 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
191 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
192 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
193 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
194 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
195 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
197 //FIXME save branchPropWindow settings
198 //FIXME save scriptEditor settings
200 // call the destructors
202 delete historyWindow;
204 // Remove temporary directory
205 removeDir (QDir(tmpVymDir));
208 void Main::loadCmdLine()
210 /* TODO draw some kind of splashscreen while loading...
216 QStringList flist=options.getFileList();
217 QStringList::Iterator it=flist.begin();
219 while (it !=flist.end() )
221 fileLoad (*it, NewMap);
227 void Main::statusMessage(const QString &s)
229 statusBar()->message (s);
232 void Main::closeEvent (QCloseEvent* )
238 void Main::setupFileActions()
240 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
241 QToolBar *tb = addToolBar( tr ("&Map") );
242 tb->setObjectName ("mapTB");
245 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
246 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
247 a->setShortcut ( Qt::CTRL + Qt::Key_N );
249 fileMenu->addAction (a);
250 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
252 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
253 a->setStatusTip (tr( "Open","Status tip File menu" ) );
254 a->setShortcut ( Qt::CTRL + Qt::Key_O );
256 fileMenu->addAction (a);
257 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
259 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
260 fileLastMapsMenu->menuAction()->setShortcut ( Qt::CTRL + +Qt::SHIFT + Qt::Key_O );
261 fileMenu->addSeparator();
263 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
264 a->setStatusTip ( tr( "Save","Status tip file menu" ));
265 a->setShortcut (Qt::CTRL + Qt::Key_S );
267 fileMenu->addAction (a);
268 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
271 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
272 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
273 fileMenu->addAction (a);
274 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
276 fileMenu->addSeparator();
278 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
280 a = new QAction(tr("KDE Bookmarks"), this);
281 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
282 a->addTo (fileImportMenu);
283 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
285 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
287 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
288 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
289 a->addTo (fileImportMenu);
290 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
293 a = new QAction("Mind Manager...",this);
294 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
295 fileImportMenu->addAction (a);
296 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
298 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
299 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
300 fileImportMenu->addAction (a);
301 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
303 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
305 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
306 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
307 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
308 fileExportMenu->addAction (a);
310 a = new QAction( "Open Office...", this);
311 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
313 fileExportMenu->addAction (a);
315 a = new QAction( "Webpage (XHTML)...",this );
316 a->setShortcut (Qt::ALT + Qt::Key_X);
317 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
318 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
319 fileExportMenu->addAction (a);
321 a = new QAction( "Text (ASCII)...", this);
322 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
323 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
324 fileExportMenu->addAction (a);
326 a = new QAction( tr("KDE Bookmarks","File menu"), this);
327 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
328 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
329 fileExportMenu->addAction (a);
331 a = new QAction( "Taskjuggler...", this );
332 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
333 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
334 fileExportMenu->addAction (a);
336 a = new QAction( "LaTeX...", this);
337 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
338 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
339 fileExportMenu->addAction (a);
341 a = new QAction( "XML..." , this );
342 a->setStatusTip (tr( "Export as %1").arg("XML"));
343 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
344 fileExportMenu->addAction (a);
346 fileMenu->addSeparator();
348 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
349 a->setStatusTip ( tr( "Print" ,"File menu") );
350 a->setShortcut (Qt::CTRL + Qt::Key_P );
352 fileMenu->addAction (a);
353 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
356 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
357 a->setStatusTip (tr( "Close Map" ) );
358 a->setShortcut (Qt::ALT + Qt::Key_C );
359 fileMenu->addAction (a);
360 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
362 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
363 a->setStatusTip ( tr( "Exit")+" "+vymName );
364 a->setShortcut (Qt::CTRL + Qt::Key_Q );
365 fileMenu->addAction (a);
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
371 void Main::setupEditActions()
373 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
374 tb->setLabel( "Edit Actions" );
375 tb->setObjectName ("actionsTB");
376 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
380 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
381 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
382 a->setStatusTip (tr( "Undo" ) );
383 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
384 a->setEnabled (false);
386 editMenu->addAction (a);
389 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
390 a->setStatusTip (tr( "Redo" ));
391 a->setShortcut (Qt::CTRL + Qt::Key_Y );
393 editMenu->addAction (a);
394 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
397 editMenu->addSeparator();
398 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
399 a->setStatusTip ( tr( "Copy" ) );
400 a->setShortcut (Qt::CTRL + Qt::Key_C );
401 a->setEnabled (false);
403 editMenu->addAction (a);
404 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
407 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
408 a->setStatusTip ( tr( "Cut" ) );
409 a->setShortcut (Qt::CTRL + Qt::Key_X );
410 a->setEnabled (false);
412 editMenu->addAction (a);
414 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
416 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
417 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
418 a->setStatusTip ( tr( "Paste" ) );
419 a->setShortcut ( Qt::CTRL + Qt::Key_V );
420 a->setEnabled (false);
422 editMenu->addAction (a);
425 // Shortcuts to modify heading:
426 a = new QAction(tr( "Edit heading","Edit menu" ),this);
427 a->setStatusTip ( tr( "edit Heading" ));
428 a->setShortcut ( Qt::Key_Enter);
429 // a->setShortcutContext (Qt::WindowShortcut);
431 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
432 actionListBranches.append(a);
433 a = new QAction( tr( "Edit heading","Edit menu" ), this);
434 a->setStatusTip (tr( "edit Heading" ));
435 a->setShortcut (Qt::Key_Return );
436 //a->setShortcutContext (Qt::WindowShortcut);
438 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
439 actionListBranches.append(a);
440 editMenu->addAction (a);
442 a = new QAction( tr( "Edit heading","Edit menu" ), this);
443 a->setStatusTip (tr( "edit Heading" ));
444 a->setShortcut ( Qt::Key_F2 );
445 a->setShortcutContext (Qt::WindowShortcut);
447 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
448 actionListBranches.append(a);
450 // Shortcut to delete selection
451 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
452 a->setStatusTip (tr( "Delete Selection" ));
453 a->setShortcut ( Qt::Key_Delete);
454 a->setShortcutContext (Qt::WindowShortcut);
456 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
459 // Shortcut to add branch
460 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
461 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
462 alt->setShortcut (Qt::Key_A);
463 alt->setShortcutContext (Qt::WindowShortcut);
465 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
466 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
467 a->setStatusTip ( tr( "Add a branch as child of selection" ));
468 a->setShortcut (Qt::Key_Insert);
469 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
470 actionListBranches.append(a);
471 #if defined (Q_OS_MACX)
472 // In OSX show different shortcut in menues, the keys work indepently always
473 actionEditAddBranch=alt;
475 actionEditAddBranch=a;
477 editMenu->addAction (actionEditAddBranch);
478 tb->addAction (actionEditAddBranch);
481 // Add branch by inserting it at selection
482 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
483 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
484 a->setShortcut (Qt::ALT + Qt::Key_Insert );
485 a->setShortcutContext (Qt::WindowShortcut);
487 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
488 a->setEnabled (false);
489 actionListBranches.append(a);
490 actionEditAddBranchBefore=a;
491 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
492 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
493 a->setShortcut ( Qt::ALT + Qt::Key_A );
494 a->setShortcutContext (Qt::WindowShortcut);
496 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
497 actionListBranches.append(a);
500 a = new QAction(tr( "Add branch above","Edit menu" ), this);
501 a->setStatusTip ( tr( "Add a branch above selection" ));
502 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
503 a->setShortcutContext (Qt::WindowShortcut);
505 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
506 a->setEnabled (false);
507 actionListBranches.append(a);
508 actionEditAddBranchAbove=a;
509 a = new QAction(tr( "Add branch above","Edit menu" ), this);
510 a->setStatusTip ( tr( "Add a branch above selection" ));
511 a->setShortcut (Qt::SHIFT+Qt::Key_A );
512 a->setShortcutContext (Qt::WindowShortcut);
514 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
515 actionListBranches.append(a);
518 a = new QAction(tr( "Add branch below","Edit menu" ), this);
519 a->setStatusTip ( tr( "Add a branch below selection" ));
520 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
521 a->setShortcutContext (Qt::WindowShortcut);
523 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
524 a->setEnabled (false);
525 actionListBranches.append(a);
526 actionEditAddBranchBelow=a;
527 a = new QAction(tr( "Add branch below","Edit menu" ), this);
528 a->setStatusTip ( tr( "Add a branch below selection" ));
529 a->setShortcut (Qt::CTRL +Qt::Key_A );
530 a->setShortcutContext (Qt::WindowShortcut);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
533 actionListBranches.append(a);
535 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
536 a->setStatusTip ( tr( "Move branch up" ) );
537 a->setShortcut (Qt::Key_PageUp );
538 a->setEnabled (false);
540 editMenu->addAction (a);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
544 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
545 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
546 a->setStatusTip (tr( "Move branch down" ) );
547 a->setShortcut ( Qt::Key_PageDown );
548 a->setEnabled (false);
550 editMenu->addAction (a);
551 actionEditMoveDown=a;
554 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
555 a->setShortcut ( Qt::Key_ScrollLock );
556 a->setStatusTip (tr( "Scroll branch" ) );
557 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
559 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
560 alt->setShortcut ( Qt::Key_S );
561 alt->setStatusTip (tr( "Scroll branch" ));
562 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
563 #if defined(Q_OS_MACX)
564 actionEditToggleScroll=alt;
566 actionEditToggleScroll=a;
568 actionEditToggleScroll->setEnabled (false);
569 actionEditToggleScroll->setToggleAction(true);
570 tb->addAction (actionEditToggleScroll);
571 editMenu->addAction ( actionEditToggleScroll);
572 editMenu->addAction (actionEditToggleScroll);
575 actionListBranches.append(actionEditToggleScroll);
577 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
578 a->setStatusTip (tr( "Unscroll all" ));
579 editMenu->addAction (a);
580 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
582 editMenu->addSeparator();
584 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
585 a->setStatusTip (tr( "Find" ) );
586 a->setShortcut (Qt::CTRL + Qt::Key_F );
587 editMenu->addAction (a);
588 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
590 editMenu->addSeparator();
592 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
593 a->setShortcut (Qt::CTRL + Qt::Key_U );
594 a->setShortcut (tr( "Open URL" ));
597 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
600 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
601 a->setStatusTip (tr( "Open URL in new tab" ));
602 a->setShortcut (Qt::CTRL+Qt::Key_U );
604 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
605 actionEditOpenURLTab=a;
607 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
608 a->setStatusTip (tr( "Open all URLs in subtree" ));
610 actionListBranches.append(a);
611 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
612 actionEditOpenMultipleURLTabs=a;
614 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
615 a->setStatusTip ( tr( "Edit URL" ) );
616 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
617 //a->setShortcut ( Qt::Key_U );
618 a->setShortcutContext (Qt::WindowShortcut);
619 actionListBranches.append(a);
621 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
624 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
625 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
626 a->setEnabled (false);
627 actionListBranches.append(a);
628 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
629 actionEditHeading2URL=a;
631 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
632 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
633 a->setEnabled (false);
634 actionListBranches.append(a);
635 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
636 actionEditBugzilla2URL=a;
638 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
639 a->setStatusTip ( tr( "Create URL to FATE" ));
640 a->setEnabled (false);
641 actionListBranches.append(a);
642 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
643 actionEditFATE2URL=a;
645 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
646 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
648 a->setEnabled (false);
649 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
650 actionEditOpenVymLink=a;
652 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
653 a->setStatusTip ( tr( "Open all vym links in subtree" ));
654 a->setEnabled (false);
655 actionListBranches.append(a);
656 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
657 actionEditOpenMultipleVymLinks=a;
660 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
661 a->setEnabled (false);
662 a->setStatusTip ( tr( "Edit link to another vym map" ));
663 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
664 actionListBranches.append(a);
667 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
668 a->setStatusTip ( tr( "Delete link to another vym map" ));
669 a->setEnabled (false);
670 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
671 actionEditDeleteVymLink=a;
673 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
674 a->setStatusTip ( tr( "Hide object in exports" ) );
675 a->setShortcut (Qt::Key_H );
676 a->setToggleAction(true);
678 a->setEnabled (false);
679 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
680 actionEditToggleHideExport=a;
682 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
683 a->setStatusTip ( tr( "Edit Map Info" ));
684 a->setEnabled (true);
685 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
688 // Import at selection (adding to selection)
689 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
690 a->setStatusTip (tr( "Add map at selection" ));
691 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
692 a->setEnabled (false);
693 actionListBranches.append(a);
694 actionEditImportAdd=a;
696 // Import at selection (replacing selection)
697 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
698 a->setStatusTip (tr( "Replace selection with map" ));
699 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
700 a->setEnabled (false);
701 actionListBranches.append(a);
702 actionEditImportReplace=a;
705 a = new QAction( tr( "Save selection","Edit menu" ), this);
706 a->setStatusTip (tr( "Save selection" ));
707 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
708 a->setEnabled (false);
709 actionListBranches.append(a);
710 actionEditSaveBranch=a;
712 // Only remove branch, not its childs
713 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
714 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
715 a->setShortcut (Qt::ALT + Qt::Key_Delete );
716 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
717 a->setEnabled (false);
719 actionListBranches.append(a);
720 actionEditDeleteKeepChilds=a;
722 // Only remove childs of a branch
723 a = new QAction( tr( "Remove childs","Edit menu" ), this);
724 a->setStatusTip (tr( "Remove childs of branch" ));
725 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
726 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
727 a->setEnabled (false);
728 actionListBranches.append(a);
729 actionEditDeleteChilds=a;
731 // Shortcuts for navigating with cursor:
732 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
733 a->setStatusTip ( tr( "Select upper branch" ));
734 a->setShortcut (Qt::Key_Up );
735 a->setShortcutContext (Qt::WindowShortcut);
737 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
738 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
739 a->setStatusTip (tr( "Select lower branch" ));
740 a->setShortcut ( Qt::Key_Down );
741 a->setShortcutContext (Qt::WindowShortcut);
743 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
744 a = new QAction(tr( "Select left branch","Edit menu" ), this);
745 a->setStatusTip ( tr( "Select left branch" ));
746 a->setShortcut (Qt::Key_Left );
747 a->setShortcutContext (Qt::WindowShortcut);
749 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
750 a = new QAction( tr( "Select child branch","Edit menu" ), this);
751 a->setStatusTip (tr( "Select right branch" ));
752 a->setShortcut (Qt::Key_Right);
753 a->setShortcutContext (Qt::WindowShortcut);
755 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
756 a = new QAction( tr( "Select first branch","Edit menu" ), this);
757 a->setStatusTip (tr( "Select first branch" ));
758 a->setShortcut (Qt::Key_Home );
759 a->setShortcutContext (Qt::WindowShortcut);
761 a->setEnabled (false);
762 editMenu->addAction (a);
763 actionListBranches.append(a);
764 actionEditSelectFirst=a;
765 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
766 a = new QAction( tr( "Select last branch","Edit menu" ),this);
767 a->setStatusTip (tr( "Select last branch" ));
768 a->setShortcut ( Qt::Key_End );
769 a->setShortcutContext (Qt::WindowShortcut);
771 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
772 a->setEnabled (false);
773 editMenu->addAction (a);
774 actionListBranches.append(a);
775 actionEditSelectLast=a;
777 a = new QAction( tr( "Add Image...","Edit menu" ), this);
778 a->setStatusTip (tr( "Add Image" ));
779 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
780 actionEditLoadImage=a;
782 a = new QAction( tr( "Properties","Context menu for images and branches" )+QString ("..."), this);
783 a->setStatusTip (tr( "Set properties for object" ));
784 connect( a, SIGNAL( triggered() ), this, SLOT( showPropertyDialog() ) );
785 actionOpenPropertyDialog=a;
789 void Main::setupFormatActions()
791 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
793 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
794 tb->setObjectName ("formatTB");
797 pix.fill (Qt::black);
798 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
799 a->setStatusTip ( tr( "Set Color" ));
800 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
802 formatMenu->addAction (a);
804 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
805 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
806 a->setShortcut (Qt::CTRL + Qt::Key_K );
807 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
808 a->setEnabled (false);
810 formatMenu->addAction (a);
811 actionListBranches.append(a);
812 actionFormatPickColor=a;
814 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
815 a->setStatusTip ( tr( "Color branch" ) );
816 a->setShortcut (Qt::CTRL + Qt::Key_I);
817 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
818 a->setEnabled (false);
820 formatMenu->addAction (a);
821 actionListBranches.append(a);
822 actionFormatColorSubtree=a;
824 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
825 a->setStatusTip ( tr( "Color Subtree" ));
826 a->setShortcut (Qt::CTRL + Qt::Key_T);
827 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
828 a->setEnabled (false);
829 formatMenu->addAction (a);
831 actionListBranches.append(a);
832 actionFormatColorSubtree=a;
834 formatMenu->addSeparator();
835 actionGroupFormatLinkStyles=new QActionGroup ( this);
836 actionGroupFormatLinkStyles->setExclusive (true);
837 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
838 a->setStatusTip (tr( "Line" ));
839 a->setToggleAction(true);
840 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
841 formatMenu->addAction (a);
842 actionFormatLinkStyleLine=a;
843 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
844 a->setStatusTip (tr( "Line" ));
845 a->setToggleAction(true);
846 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
847 formatMenu->addAction (a);
848 actionFormatLinkStyleParabel=a;
849 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
850 a->setStatusTip (tr( "PolyLine" ));
851 a->setToggleAction(true);
852 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
853 formatMenu->addAction (a);
854 actionFormatLinkStylePolyLine=a;
855 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
856 a->setStatusTip (tr( "PolyParabel" ) );
857 a->setToggleAction(true);
858 a->setChecked (true);
859 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
860 formatMenu->addAction (a);
861 actionFormatLinkStylePolyParabel=a;
863 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
864 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
865 a->setToggleAction(true);
866 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
867 actionFormatIncludeImagesVer=a;
869 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
870 a->setStatusTip ( tr ("Include left and right position of images into branch"));
871 a->setToggleAction(true);
872 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
873 actionFormatIncludeImagesHor=a;
875 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
876 a->setStatusTip (tr( "Hide link" ));
877 a->setToggleAction(true);
878 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
879 actionFormatHideLinkUnselected=a;
881 formatMenu->addSeparator();
882 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
883 a->setStatusTip (tr( "Use same color for links and headings" ));
884 a->setToggleAction(true);
885 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
886 formatMenu->addAction (a);
887 actionFormatLinkColorHint=a;
889 pix.fill (Qt::white);
890 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
891 a->setStatusTip (tr( "Set Link Color" ));
892 formatMenu->addAction (a);
893 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
894 actionFormatLinkColor=a;
896 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
897 a->setStatusTip (tr( "Set Background Color" ));
898 formatMenu->addAction (a);
899 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
900 actionFormatBackColor=a;
902 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
903 a->setStatusTip (tr( "Set Background image" ));
904 formatMenu->addAction (a);
905 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
906 actionFormatBackImage=a;
910 void Main::setupViewActions()
912 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
913 tb->setLabel( "View Actions" );
914 tb->setObjectName ("viewTB");
915 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
918 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
919 a->setStatusTip ( tr( "Zoom reset" ) );
920 a->setShortcut (Qt::CTRL + Qt::Key_0 );
922 viewMenu->addAction (a);
923 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
925 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
926 a->setStatusTip (tr( "Zoom in" ));
927 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
929 viewMenu->addAction (a);
930 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
932 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
933 a->setStatusTip (tr( "Zoom out" ));
934 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
936 viewMenu->addAction (a);
937 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
940 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
941 a->setStatusTip ( tr( "Show Note Editor" ));
942 a->setShortcut ( Qt::CTRL + Qt::Key_E );
943 a->setToggleAction(true);
944 if (textEditor->showWithMain())
949 viewMenu->addAction (a);
950 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
951 actionViewToggleNoteEditor=a;
953 a = new QAction(QPixmap(iconPath+"history.png"), tr( "Show history window","View action" ),this );
954 a->setStatusTip ( tr( "Show history window" ));
955 a->setShortcut ( Qt::CTRL + Qt::Key_H );
956 a->setToggleAction(true);
958 viewMenu->addAction (a);
959 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
960 actionViewToggleHistoryWindow=a;
962 a = new QAction(tr( "Antialiasing","View action" ),this );
963 a->setStatusTip ( tr( "Antialiasing" ));
964 a->setToggleAction(true);
965 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
966 viewMenu->addAction (a);
967 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
968 actionViewToggleAntiAlias=a;
970 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
971 a->setStatusTip (a->text());
972 a->setToggleAction(true);
973 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
974 viewMenu->addAction (a);
975 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
976 actionViewToggleSmoothPixmapTransform=a;
978 a = new QAction(tr( "Next Window","View action" ), this);
979 a->setStatusTip (a->text());
980 a->setShortcut (Qt::ALT + Qt::Key_N );
981 viewMenu->addAction (a);
982 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
984 a = new QAction (tr( "Previous Window","View action" ), this );
985 a->setStatusTip (a->text());
986 a->setShortcut (Qt::ALT + Qt::Key_P );
987 viewMenu->addAction (a);
988 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
992 void Main::setupModeActions()
994 //QPopupMenu *menu = new QPopupMenu( this );
995 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
997 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
998 tb->setObjectName ("modesTB");
1000 actionGroupModModes=new QActionGroup ( this);
1001 actionGroupModModes->setExclusive (true);
1002 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1003 a->setShortcut (Qt::Key_J);
1004 a->setStatusTip ( tr( "Use modifier to color branches" ));
1005 a->setToggleAction(true);
1008 actionModModeColor=a;
1010 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1011 a->setShortcut( Qt::Key_K);
1012 a->setStatusTip( tr( "Use modifier to copy" ));
1013 a->setToggleAction(true);
1015 actionModModeCopy=a;
1017 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1018 a->setShortcut (Qt::Key_L);
1019 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1020 a->setToggleAction(true);
1022 actionModModeXLink=a;
1026 void Main::setupFlagActions()
1028 // Create System Flags
1029 systemFlagsDefault = new FlagRowObj ();
1030 systemFlagsDefault->setVisibility (false);
1031 systemFlagsDefault->setName ("systemFlagsDef");
1033 FlagObj *fo = new FlagObj ();
1034 fo->load(QPixmap(flagsPath+"flag-note.png"));
1035 fo->setName("note");
1036 fo->setToolTip(tr("Note","Systemflag"));
1037 systemFlagsDefault->addFlag (fo); // makes deep copy
1039 fo->load(QPixmap(flagsPath+"flag-url.png"));
1041 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1042 systemFlagsDefault->addFlag (fo);
1044 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1045 fo->setName("vymLink");
1046 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1047 systemFlagsDefault->addFlag (fo);
1049 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1050 fo->setName("scrolledright");
1051 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1052 systemFlagsDefault->addFlag (fo);
1054 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1055 fo->setName("tmpUnscrolledright");
1056 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1057 systemFlagsDefault->addFlag (fo);
1059 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1060 fo->setName("hideInExport");
1061 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1062 systemFlagsDefault->addFlag (fo);
1064 // Create Standard Flags
1065 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1066 tb->setObjectName ("standardFlagTB");
1068 standardFlagsDefault = new FlagRowObj ();
1069 standardFlagsDefault->setVisibility (false);
1070 standardFlagsDefault->setName ("standardFlagsDef");
1071 standardFlagsDefault->setToolBar (tb);
1073 fo->load(flagsPath+"flag-exclamationmark.png");
1074 fo->setName ("exclamationmark");
1075 fo->setGroup("standard-mark");
1076 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1079 a->setCheckable(true);
1080 a->setObjectName(fo->getName());
1081 a->setToolTip(tr("Take care!","Standardflag"));
1082 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1083 standardFlagsDefault->addFlag (fo); // makes deep copy
1085 fo->load(flagsPath+"flag-questionmark.png");
1086 fo->setName("questionmark");
1087 fo->setGroup("standard-mark");
1088 a=new QAction (fo->getPixmap(),fo->getName(),this);
1091 a->setCheckable(true);
1092 a->setObjectName(fo->getName());
1093 a->setToolTip(tr("Really?","Standardflag"));
1094 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1095 standardFlagsDefault->addFlag (fo);
1097 fo->load(flagsPath+"flag-hook-green.png");
1098 fo->setName("hook-green");
1099 fo->setGroup("standard-hook");
1100 a=new QAction (fo->getPixmap(),fo->getName(),this);
1103 a->setCheckable(true);
1104 a->setObjectName(fo->getName());
1105 a->setToolTip(tr("ok!","Standardflag"));
1106 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1107 standardFlagsDefault->addFlag (fo);
1109 fo->load(flagsPath+"flag-cross-red.png");
1110 fo->setName("cross-red");
1111 fo->setGroup("standard-hook");
1112 a=new QAction (fo->getPixmap(),fo->getName(),this);
1115 a->setCheckable(true);
1116 a->setObjectName(fo->getName());
1117 a->setToolTip(tr("Not ok!","Standardflag"));
1118 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1119 standardFlagsDefault->addFlag (fo);
1121 fo->load(flagsPath+"flag-stopsign.png");
1122 fo->setName("stopsign");
1123 a=new QAction (fo->getPixmap(),fo->getName(),this);
1126 a->setCheckable(true);
1127 a->setObjectName(fo->getName());
1128 a->setToolTip(tr("This won't work!","Standardflag"));
1129 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1130 standardFlagsDefault->addFlag (fo);
1132 fo->load(flagsPath+"flag-smiley-good.png");
1133 fo->setName("smiley-good");
1134 fo->setGroup("standard-smiley");
1135 a=new QAction (fo->getPixmap(),fo->getName(),this);
1138 a->setCheckable(true);
1139 a->setObjectName(fo->getName());
1140 a->setToolTip(tr("Good","Standardflag"));
1141 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1142 standardFlagsDefault->addFlag (fo);
1144 fo->load(flagsPath+"flag-smiley-sad.png");
1145 fo->setName("smiley-sad");
1146 fo->setGroup("standard-smiley");
1147 a=new QAction (fo->getPixmap(),fo->getName(),this);
1150 a->setCheckable(true);
1151 a->setObjectName(fo->getName());
1152 a->setToolTip(tr("Bad","Standardflag"));
1153 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1154 standardFlagsDefault->addFlag (fo);
1156 fo->load(flagsPath+"flag-smiley-omg.png");
1157 // Original omg.png (in KDE emoticons)
1158 fo->setName("smiley-omg");
1159 fo->setGroup("standard-smiley");
1160 a=new QAction (fo->getPixmap(),fo->getName(),this);
1163 a->setCheckable(true);
1164 a->setObjectName(fo->getName());
1165 a->setToolTip(tr("Oh no!","Standardflag"));
1166 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1167 standardFlagsDefault->addFlag (fo);
1169 fo->load(flagsPath+"flag-kalarm.png");
1170 fo->setName("clock");
1171 a=new QAction (fo->getPixmap(),fo->getName(),this);
1174 a->setCheckable(true);
1175 a->setObjectName(fo->getName());
1176 a->setToolTip(tr("Time critical","Standardflag"));
1177 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1178 standardFlagsDefault->addFlag (fo);
1180 fo->load(flagsPath+"flag-phone.png");
1181 fo->setName("phone");
1182 a=new QAction (fo->getPixmap(),fo->getName(),this);
1185 a->setCheckable(true);
1186 a->setObjectName(fo->getName());
1187 a->setToolTip(tr("Call...","Standardflag"));
1188 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1189 standardFlagsDefault->addFlag (fo);
1191 fo->load(flagsPath+"flag-lamp.png");
1192 fo->setName("lamp");
1193 a=new QAction (fo->getPixmap(),fo->getName(),this);
1196 a->setCheckable(true);
1197 a->setObjectName(fo->getName());
1198 a->setToolTip(tr("Idea!","Standardflag"));
1199 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1200 standardFlagsDefault->addFlag (fo);
1202 fo->load(flagsPath+"flag-arrow-up.png");
1203 fo->setName("arrow-up");
1204 fo->setGroup("standard-arrow");
1205 a=new QAction (fo->getPixmap(),fo->getName(),this);
1208 a->setCheckable(true);
1209 a->setObjectName(fo->getName());
1210 a->setToolTip(tr("Important","Standardflag"));
1211 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1212 standardFlagsDefault->addFlag (fo);
1214 fo->load(flagsPath+"flag-arrow-down.png");
1215 fo->setName("arrow-down");
1216 fo->setGroup("standard-arrow");
1217 a=new QAction (fo->getPixmap(),fo->getName(),this);
1220 a->setCheckable(true);
1221 a->setObjectName(fo->getName());
1222 a->setToolTip(tr("Unimportant","Standardflag"));
1223 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1224 standardFlagsDefault->addFlag (fo);
1226 fo->load(flagsPath+"flag-arrow-2up.png");
1227 fo->setName("2arrow-up");
1228 fo->setGroup("standard-arrow");
1229 a=new QAction (fo->getPixmap(),fo->getName(),this);
1232 a->setCheckable(true);
1233 a->setObjectName(fo->getName());
1234 a->setToolTip(tr("Very important!","Standardflag"));
1235 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1236 standardFlagsDefault->addFlag (fo);
1238 fo->load(flagsPath+"flag-arrow-2down.png");
1239 fo->setName("2arrow-down");
1240 fo->setGroup("standard-arrow");
1241 a=new QAction (fo->getPixmap(),fo->getName(),this);
1244 a->setCheckable(true);
1245 a->setObjectName(fo->getName());
1246 a->setToolTip(tr("Very unimportant!","Standardflag"));
1247 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1248 standardFlagsDefault->addFlag (fo);
1250 fo->load(flagsPath+"flag-thumb-up.png");
1251 fo->setName("thumb-up");
1252 fo->setGroup("standard-thumb");
1253 a=new QAction (fo->getPixmap(),fo->getName(),this);
1256 a->setCheckable(true);
1257 a->setObjectName(fo->getName());
1258 a->setToolTip(tr("I like this","Standardflag"));
1259 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1260 standardFlagsDefault->addFlag (fo);
1262 fo->load(flagsPath+"flag-thumb-down.png");
1263 fo->setName("thumb-down");
1264 fo->setGroup("standard-thumb");
1265 a=new QAction (fo->getPixmap(),fo->getName(),this);
1268 a->setCheckable(true);
1269 a->setObjectName(fo->getName());
1270 a->setToolTip(tr("I do not like this","Standardflag"));
1271 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1272 standardFlagsDefault->addFlag (fo);
1274 fo->load(flagsPath+"flag-rose.png");
1275 fo->setName("rose");
1276 a=new QAction (fo->getPixmap(),fo->getName(),this);
1279 a->setCheckable(true);
1280 a->setObjectName(fo->getName());
1281 a->setToolTip(tr("Rose","Standardflag"));
1282 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1283 standardFlagsDefault->addFlag (fo);
1285 fo->load(flagsPath+"flag-heart.png");
1286 fo->setName("heart");
1287 a=new QAction (fo->getPixmap(),fo->getName(),this);
1289 a->setCheckable(true);
1290 a->setObjectName(fo->getName());
1291 a->setToolTip(tr("I just love... ","Standardflag"));
1292 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1293 standardFlagsDefault->addFlag (fo);
1295 fo->load(flagsPath+"flag-present.png");
1296 fo->setName("present");
1297 a=new QAction (fo->getPixmap(),fo->getName(),this);
1300 a->setCheckable(true);
1301 a->setObjectName(fo->getName());
1302 a->setToolTip(tr("Surprise!","Standardflag"));
1303 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1304 standardFlagsDefault->addFlag (fo);
1306 fo->load(flagsPath+"flag-flash.png");
1307 fo->setName("flash");
1308 a=new QAction (fo->getPixmap(),fo->getName(),this);
1311 a->setCheckable(true);
1312 a->setObjectName(fo->getName());
1313 a->setToolTip(tr("Dangerous","Standardflag"));
1314 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1315 standardFlagsDefault->addFlag (fo);
1317 fo->load(flagsPath+"flag-info.png");
1318 // Original: xsldbg_output.png
1319 fo->setName("info");
1320 a=new QAction (fo->getPixmap(),fo->getName(),this);
1323 a->setCheckable(true);
1324 a->setObjectName(fo->getName());
1325 a->setToolTip(tr("Info","Standardflag"));
1326 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1327 standardFlagsDefault->addFlag (fo);
1329 fo->load(flagsPath+"flag-lifebelt.png");
1330 // Original khelpcenter.png
1331 fo->setName("lifebelt");
1332 a=new QAction (fo->getPixmap(),fo->getName(),this);
1335 a->setCheckable(true);
1336 a->setObjectName(fo->getName());
1337 a->setToolTip(tr("This will help","Standardflag"));
1338 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1339 standardFlagsDefault->addFlag (fo);
1345 void Main::setupSettingsActions()
1347 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1351 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1352 a->setStatusTip ( tr( "Set application to open pdf files"));
1353 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1354 settingsMenu->addAction (a);
1356 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1357 a->setStatusTip( tr( "Set application to open external links"));
1358 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1359 settingsMenu->addAction (a);
1361 settingsMenu->addSeparator();
1362 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1363 a->setStatusTip( tr( "Edit branch after adding it" ));
1364 a->setToggleAction(true);
1365 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1366 settingsMenu->addAction (a);
1367 actionSettingsAutoEdit=a;
1369 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1370 a->setStatusTip( tr( "Select branch after adding it" ));
1371 a->setToggleAction(true);
1372 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1373 settingsMenu->addAction (a);
1374 actionSettingsAutoSelectHeading=a;
1376 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1377 a->setStatusTip( tr( "Select heading before editing" ));
1378 a->setToggleAction(true);
1379 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1380 settingsMenu->addAction (a);
1381 actionSettingsAutoSelectText=a;
1383 a= new QAction( tr( "Delete key","Settings action" ), this);
1384 a->setStatusTip( tr( "Delete key for deleting branches" ));
1385 a->setToggleAction(true);
1386 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1387 settingsMenu->addAction (a);
1388 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1389 actionSettingsUseDelKey=a;
1391 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1392 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1393 a->setToggleAction(true);
1394 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1395 settingsMenu->addAction (a);
1396 actionSettingsUseFlagGroups=a;
1398 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1399 a->setStatusTip( tr( "Use hide flag during exports " ));
1400 a->setToggleAction(true);
1401 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1402 settingsMenu->addAction (a);
1403 actionSettingsUseHideExport=a;
1407 void Main::setupTestActions()
1409 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1412 a = new QAction( "Test function" , this);
1413 a->setStatusTip( "Call test function" );
1414 a->setShortcut (Qt::Key_F4 );
1415 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1416 testMenu->addAction (a);
1417 a = new QAction( "Command" , this);
1418 a->setStatusTip( "Enter command to call in editor" );
1419 a->setShortcut (Qt::Key_F5 );
1420 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1421 testMenu->addAction (a);
1425 void Main::setupHelpActions()
1427 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1430 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1431 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1432 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1433 helpMenu->addAction (a);
1435 a = new QAction( tr( "About VYM","Help action" ), this);
1436 a->setStatusTip( tr( "About VYM")+vymName);
1437 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1438 helpMenu->addAction (a);
1440 a = new QAction( tr( "About QT","Help action" ), this);
1441 a->setStatusTip( tr( "Information about QT toolkit" ));
1442 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1443 helpMenu->addAction (a);
1447 void Main::setupContextMenus()
1451 // Context Menu for branch or mapcenter
1452 branchContextMenu =new QMenu (this);
1454 actionOpenPropertyDialog->addTo (branchContextMenu);
1455 branchContextMenu->addSeparator();
1458 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1459 branchAddContextMenu->addAction (actionEditPaste );
1460 branchAddContextMenu->addAction ( actionEditAddBranch );
1461 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1462 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1463 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1464 branchAddContextMenu->addSeparator();
1465 branchAddContextMenu->addAction ( actionEditImportAdd );
1466 branchAddContextMenu->addAction ( actionEditImportReplace );
1469 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1470 branchRemoveContextMenu->addAction (actionEditCut);
1471 branchRemoveContextMenu->addAction ( actionEditDelete );
1472 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1473 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1476 actionEditSaveBranch->addTo( branchContextMenu );
1478 branchContextMenu->addSeparator();
1479 branchContextMenu->addAction ( actionEditLoadImage);
1480 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1481 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1483 // Submenu for Links (URLs, vymLinks)
1484 branchLinksContextMenu =new QMenu (this);
1486 branchContextMenu->addSeparator();
1487 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1488 branchLinksContextMenu->addAction ( actionEditOpenURL );
1489 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1490 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1491 branchLinksContextMenu->addAction ( actionEditURL );
1492 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1493 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1494 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1496 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1498 branchLinksContextMenu->addSeparator();
1499 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1500 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1501 branchLinksContextMenu->addAction ( actionEditVymLink );
1502 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1505 // Context Menu for XLinks in a branch menu
1506 // This will be populated "on demand" in MapEditor::updateActions
1507 branchContextMenu->addSeparator();
1508 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1509 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1510 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1511 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1514 // Context menu for floatimage
1515 floatimageContextMenu =new QMenu (this);
1516 a= new QAction (tr ("Save image","Context action"),this);
1517 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1518 floatimageContextMenu->addAction (a);
1520 floatimageContextMenu->addSeparator();
1521 actionEditCopy->addTo( floatimageContextMenu );
1522 actionEditCut->addTo( floatimageContextMenu );
1524 floatimageContextMenu->addSeparator();
1525 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1528 // Context menu for canvas
1529 canvasContextMenu =new QMenu (this);
1530 actionEditMapInfo->addTo( canvasContextMenu );
1531 canvasContextMenu->insertSeparator();
1532 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1533 canvasContextMenu->insertSeparator();
1534 actionFormatLinkColorHint->addTo( canvasContextMenu );
1535 actionFormatLinkColor->addTo( canvasContextMenu );
1536 actionFormatBackColor->addTo( canvasContextMenu );
1537 actionFormatBackImage->addTo( canvasContextMenu );
1539 // Menu for last opened files
1541 for (int i = 0; i < MaxRecentFiles; ++i)
1543 recentFileActs[i] = new QAction(this);
1544 recentFileActs[i]->setVisible(false);
1545 fileLastMapsMenu->addAction(recentFileActs[i]);
1546 connect(recentFileActs[i], SIGNAL(triggered()),
1547 this, SLOT(fileLoadRecent()));
1549 setupRecentMapsMenu();
1552 void Main::setupRecentMapsMenu()
1554 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1556 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1558 for (int i = 0; i < numRecentFiles; ++i) {
1559 //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
1560 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1561 recentFileActs[i]->setText(text);
1562 recentFileActs[i]->setData(files[i]);
1563 recentFileActs[i]->setVisible(true);
1565 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1566 recentFileActs[j]->setVisible(false);
1569 void Main::hideEvent (QHideEvent * )
1571 if (!textEditor->isMinimized() ) textEditor->hide();
1574 void Main::showEvent (QShowEvent * )
1576 if (textEditor->showWithMain()) textEditor->showNormal();
1579 bool Main::reallyWriteDirectory(const QString &dir)
1581 QStringList eList = QDir(dir).entryList();
1582 if (eList.first() ==".") eList.pop_front(); // remove "."
1583 if (eList.first() =="..") eList.pop_front(); // remove "."
1584 if (!eList.isEmpty())
1586 QMessageBox mb( vymName,
1587 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1588 QMessageBox::Warning,
1590 QMessageBox::Cancel | QMessageBox::Default,
1591 QMessageBox::QMessageBox::NoButton );
1593 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1594 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1597 case QMessageBox::Yes:
1600 case QMessageBox::Cancel:
1608 QString Main::browseDirectory (const QString &caption)
1610 QFileDialog fd(this,caption);
1611 fd.setMode (QFileDialog::DirectoryOnly);
1612 fd.setCaption(vymName+ " - "+caption);
1613 fd.setDir (lastFileDir);
1616 if ( fd.exec() == QDialog::Accepted )
1617 return fd.selectedFile();
1622 MapEditor* Main::currentMapEditor() const
1624 if ( tabWidget->currentPage() &&
1625 tabWidget->currentPage()->inherits( "MapEditor" ) )
1626 return (MapEditor*)tabWidget->currentPage();
1631 void Main::editorChanged(QWidget *)
1633 // Unselect all possibly selected objects
1634 // (Important to update note editor)
1637 for (i=0;i<=tabWidget->count() -1;i++)
1640 me=(MapEditor*)tabWidget->page(i);
1643 currentMapEditor()->reselect();
1645 // Update actions to in menus and toolbars according to editor
1649 void Main::fileNew()
1651 QString fn="unnamed";
1652 MapEditor* me = new MapEditor ( NULL);
1653 tabWidget->addTab (me,fn);
1654 tabWidget->showPage(me);
1655 me->viewport()->setFocus();
1656 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1657 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1659 // For the very first map we do not have flagrows yet...
1663 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1665 ErrorCode err=success;
1667 // fn is usually the archive, mapfile the file after uncompressing
1670 // Make fn absolute (needed for unzip)
1671 fn=QDir (fn).absPath();
1677 // Check, if map is already loaded
1679 while (i<=tabWidget->count() -1)
1681 me=(MapEditor*)tabWidget->page(i);
1682 if (me->getFilePath() == fn)
1684 // Already there, ask for confirmation
1685 QMessageBox mb( vymName,
1686 tr("The map %1\nis already opened."
1687 "Opening the same map in multiple editors may lead \n"
1688 "to confusion when finishing working with vym."
1689 "Do you want to").arg(fn),
1690 QMessageBox::Warning,
1691 QMessageBox::Yes | QMessageBox::Default,
1692 QMessageBox::Cancel | QMessageBox::Escape,
1693 QMessageBox::NoButton);
1694 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1695 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1698 case QMessageBox::Yes:
1700 i=tabWidget->count();
1702 case QMessageBox::Cancel:
1714 if ( !fn.isEmpty() )
1716 me = currentMapEditor();
1717 int tabIndex=tabWidget->currentPageIndex();
1718 // Check first, if mapeditor exists
1719 // If it is not default AND we want a new map,
1720 // create a new mapeditor in a new tab
1721 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1723 me= new MapEditor ( NULL);
1724 tabWidget->addTab (me,fn);
1725 tabIndex=tabWidget->indexOf (me);
1726 tabWidget->setCurrentPage (tabIndex);
1727 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1728 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1731 // Check, if file exists (important for creating new files
1732 // from command line
1733 if (!QFile(fn).exists() )
1735 QMessageBox mb( vymName,
1736 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1737 QMessageBox::Question,
1739 QMessageBox::Cancel | QMessageBox::Default,
1740 QMessageBox::NoButton );
1742 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1743 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1746 case QMessageBox::Yes:
1748 currentMapEditor()->setFilePath(fn);
1749 tabWidget->setTabLabel (currentMapEditor(),
1750 currentMapEditor()->getFileName() );
1751 statusBar()->message( "Created " + fn , statusbarTime );
1754 case QMessageBox::Cancel:
1755 // don't create new map
1756 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1763 //tabWidget->currentPage() won't be NULL here, because of above...
1764 tabWidget->showPage(me);
1765 me->viewport()->setFocus();
1767 // Create temporary directory for packing
1769 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1772 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1773 tr("Couldn't create temporary directory before load\n"));
1777 // Try to unzip file
1778 err=unzipDir (tmpMapDir,fn);
1782 me->setZipped(false);
1785 me->setZipped(true);
1787 // Look for mapname.xml
1788 mapfile= fn.left(fn.findRev(".",-1,true));
1789 mapfile=mapfile.section( '/', -1 );
1790 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1791 if (!file.exists() )
1793 // mapname.xml does not exist, well,
1794 // maybe someone renamed the mapname.vym file...
1795 // Try to find any .xml in the toplevel
1796 // directory of the .vym file
1797 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1798 if (flist.count()==1)
1800 // Only one entry, take this one
1801 mapfile=tmpMapDir + "/"+flist.first();
1804 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1805 *it=tmpMapDir + "/" + *it;
1806 // TODO Multiple entries, load all (but only the first one into this ME)
1807 //mainWindow->fileLoadFromTmp (flist);
1808 //returnCode=1; // Silently forget this attempt to load
1809 qWarning ("MainWindow::load (fn) multimap found...");
1812 if (flist.isEmpty() )
1814 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1815 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1818 } //file doesn't exist
1820 mapfile=file.name();
1825 // Save existing filename in case we import
1826 QString fn_org=me->getFilePath();
1828 // Finally load map into mapEditor
1829 me->setFilePath (mapfile,fn);
1830 err=me->load(mapfile,lmode);
1832 // Restore old (maybe empty) filepath, if this is an import
1834 me->setFilePath (fn_org);
1837 // Finally check for errors and go home
1840 if (lmode==NewMap) fileCloseMap();
1841 statusBar()->message( "Could not load " + fn, statusbarTime );
1846 me->setFilePath (fn);
1847 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1848 if (fn.left(9)!="/tmp/vym-")
1850 // Only append to lastMaps if not loaded from a tmpDir
1851 // e.g. imported bookmarks are in a tmpDir
1852 addRecentMap(me->getFilePath() );
1854 actionFilePrint->setEnabled (true);
1856 statusBar()->message( "Loaded " + fn, statusbarTime );
1860 removeDir (QDir(tmpMapDir));
1866 void Main::fileLoad(const LoadMode &lmode)
1868 QStringList filters;
1869 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1870 QFileDialog *fd=new QFileDialog( this);
1871 fd->setDir (lastFileDir);
1872 fd->setFileMode (QFileDialog::ExistingFiles);
1873 fd->setFilters (filters);
1877 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1880 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1883 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1889 if ( fd->exec() == QDialog::Accepted )
1891 lastFileDir=fd->directory().path();
1892 QStringList flist = fd->selectedFiles();
1893 QStringList::Iterator it = flist.begin();
1894 while( it != flist.end() )
1897 fileLoad(*it, lmode);
1904 void Main::fileLoad()
1909 void Main::fileLoadRecent()
1911 QAction *action = qobject_cast<QAction *>(sender());
1913 fileLoad (action->data().toString(), NewMap);
1916 void Main::addRecentMap (const QString &fileName)
1919 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1920 files.removeAll(fileName);
1921 files.prepend(fileName);
1922 while (files.size() > MaxRecentFiles)
1925 settings.setValue("/mainwindow/recentFileList", files);
1927 setupRecentMapsMenu();
1930 void Main::fileSave(const SaveMode &savemode)
1932 // tmp dir for zipping
1936 ErrorCode err=success;
1938 QString safeFilePath;
1940 bool saveZipped=currentMapEditor()->saveZipped();
1942 MapEditor * me=currentMapEditor();
1945 QString fn=me->getFilePath();
1946 // filename=unnamed, filepath="" in constructor...
1947 if ( !fn.isEmpty() )
1949 // We have a filepath, go on saving
1950 // First remove existing file, we
1951 // don't want to add to old zip archives
1955 QMessageBox::warning( 0, tr( "Save Error" ),
1956 fn+ tr("\ncould not be removed before saving"));
1958 // Look, if we should zip the data:
1961 QMessageBox mb( vymName,
1962 tr("The map %1\ndid not use the compressed "
1963 "vym file format.\nWriting it uncompressed will also write images \n"
1964 "and flags and thus may overwrite files in the "
1965 "given directory\n\nDo you want to write the map").arg(fn),
1966 QMessageBox::Warning,
1967 QMessageBox::Yes | QMessageBox::Default,
1969 QMessageBox::Cancel | QMessageBox::Escape);
1970 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1971 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1972 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1975 case QMessageBox::Yes:
1976 // save compressed (default file format)
1979 case QMessageBox::No:
1980 // save uncompressed
1983 case QMessageBox::Cancel:
1992 // Create temporary directory for packing
1994 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1997 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1998 tr("Couldn't create temporary directory before save\n"));
2002 safeFilePath=me->getFilePath();
2003 me->setFilePath (tmpMapDir+"/"+
2004 me->getMapName()+ ".xml",
2006 me->save (savemode);
2007 me->setFilePath (safeFilePath);
2009 zipDir (tmpMapDir,fn);
2014 safeFilePath=me->getFilePath();
2015 me->setFilePath (fn, safeFilePath);
2016 me->save (savemode);
2017 me->setFilePath (safeFilePath);
2019 } // filepath available
2022 // We have no filepath yet,
2023 // call fileSaveAs() now, this will call fileSave()
2025 fileSaveAs(savemode);
2029 if (saveZipped && !tmpMapDir.isEmpty())
2031 removeDir (QDir(tmpMapDir));
2035 statusBar()->message(
2036 tr("Saved %1").arg(me->getFilePath()),
2038 addRecentMap (me->getFilePath() );
2040 statusBar()->message(
2041 tr("Couldn't save ").arg(me->getFilePath()),
2045 void Main::fileSave()
2047 fileSave (CompleteMap);
2050 void Main::fileSaveAs(const SaveMode& savemode)
2054 if (currentMapEditor())
2056 if (savemode==CompleteMap)
2057 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2059 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2060 if ( !fn.isEmpty() )
2062 // Check for existing file
2063 if (QFile (fn).exists())
2065 QMessageBox mb( vymName,
2066 tr("The file %1\nexists already. Do you want to").arg(fn),
2067 QMessageBox::Warning,
2068 QMessageBox::Yes | QMessageBox::Default,
2069 QMessageBox::Cancel | QMessageBox::Escape,
2070 QMessageBox::NoButton);
2071 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2072 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2075 case QMessageBox::Yes:
2078 case QMessageBox::Cancel:
2085 // New file, add extension to filename, if missing
2086 // This is always .vym or .vyp, depending on savemode
2087 if (savemode==CompleteMap)
2089 if (!fn.contains (".vym") && !fn.contains (".xml"))
2093 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2102 currentMapEditor()->setFilePath(fn);
2106 if (savemode==CompleteMap)
2107 tabWidget->setTabLabel (currentMapEditor(),
2108 currentMapEditor()->getFileName() );
2114 void Main::fileSaveAs()
2116 fileSaveAs (CompleteMap);
2119 void Main::fileImportKDEBookmarks()
2121 ImportKDEBookmarks im;
2123 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2124 currentMapEditor()->setFilePath ("");
2127 void Main::fileImportFirefoxBookmarks()
2129 Q3FileDialog *fd=new Q3FileDialog( this);
2130 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2131 fd->setMode (Q3FileDialog::ExistingFiles);
2132 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2133 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2136 if ( fd->exec() == QDialog::Accepted )
2138 ImportFirefoxBookmarks im;
2139 QStringList flist = fd->selectedFiles();
2140 QStringList::Iterator it = flist.begin();
2141 while( it != flist.end() )
2144 if (im.transform() &&
2145 success==fileLoad (im.getTransformedFile(),NewMap) &&
2146 currentMapEditor() )
2147 currentMapEditor()->setFilePath ("");
2154 void Main::fileImportMM()
2158 Q3FileDialog *fd=new Q3FileDialog( this);
2159 fd->setDir (lastFileDir);
2160 fd->setMode (Q3FileDialog::ExistingFiles);
2161 fd->addFilter ("Mind Manager (*.mmap)");
2162 fd->setCaption(tr("Import")+" "+"Mind Manager");
2165 if ( fd->exec() == QDialog::Accepted )
2167 lastFileDir=fd->dirPath();
2168 QStringList flist = fd->selectedFiles();
2169 QStringList::Iterator it = flist.begin();
2170 while( it != flist.end() )
2173 if (im.transform() &&
2174 success==fileLoad (im.getTransformedFile(),NewMap) &&
2175 currentMapEditor() )
2176 currentMapEditor()->setFilePath ("");
2185 void Main::fileImportDir()
2187 if (currentMapEditor())
2188 currentMapEditor()->importDir();
2191 void Main::fileExportXML()
2193 if (currentMapEditor())
2195 QString dir=browseDirectory(tr("Export XML to directory"));
2196 if (dir !="" && reallyWriteDirectory(dir) )
2197 currentMapEditor()->exportXML(dir);
2202 void Main::fileExportXHTML()
2204 MapEditor *me=currentMapEditor();
2208 ExportXHTMLDialog dia(this);
2209 dia.setFilePath (me->getFilePath() );
2210 dia.setMapName (me->getMapName() );
2213 if (dia.exec()==QDialog::Accepted)
2215 QString dir=dia.getDir();
2216 // Check, if warnings should be used before overwriting
2217 // the output directory
2220 ok=reallyWriteDirectory(dir);
2226 me->exportXML (dia.getDir() );
2227 dia.doExport(me->getMapName() );
2228 if (dia.hasChanged())
2235 void Main::fileExportImage()
2237 MapEditor *me=currentMapEditor();
2241 QFileDialog *fd=new QFileDialog (this);
2242 fd->setCaption (tr("Export map as image"));
2243 fd->setFileMode(QFileDialog::AnyFile);
2244 fd->setFilters (imageIO.getFilters() );
2245 fd->setDirectory (lastImageDir);
2248 fl=fd->selectedFiles();
2249 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2250 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2255 void Main::fileExportASCII()
2257 MapEditor *me=currentMapEditor();
2261 ex.setMapCenter(me->getMapCenter());
2262 ex.addFilter ("TXT (*.txt)");
2263 ex.setDir(lastImageDir);
2264 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2265 if (ex.execDialog() )
2267 me->setExportMode(true);
2269 me->setExportMode(false);
2274 void Main::fileExportLaTeX()
2276 MapEditor *me=currentMapEditor();
2280 ex.setMapCenter(me->getMapCenter());
2281 ex.addFilter ("Tex (*.tex)");
2282 ex.setDir(lastImageDir);
2283 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2284 if (ex.execDialog() )
2286 me->setExportMode(true);
2288 me->setExportMode(false);
2293 void Main::fileExportKDEBookmarks()
2295 ExportKDEBookmarks ex;
2296 MapEditor *me=currentMapEditor();
2299 ex.setMapCenter (me->getMapCenter() );
2304 void Main::fileExportTaskjuggler()
2306 ExportTaskjuggler ex;
2307 MapEditor *me=currentMapEditor();
2310 ex.setMapCenter (me->getMapCenter() );
2311 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2312 ex.setDir(lastImageDir);
2313 ex.addFilter ("Taskjuggler (*.tjp)");
2314 if (ex.execDialog() )
2316 me->setExportMode(true);
2318 me->setExportMode(false);
2323 void Main::fileExportOOPresentation()
2325 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2326 // TODO add preview in dialog
2327 //ImagePreview *p =new ImagePreview (fd);
2328 //fd->setContentsPreviewEnabled( TRUE );
2329 //fd->setContentsPreview( p, p );
2330 //fd->setPreviewMode( QFileDialog::Contents );
2331 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2332 fd->setDir (QDir().current());
2333 if (fd->foundConfig())
2337 if ( fd->exec() == QDialog::Accepted )
2339 QString fn=fd->selectedFile();
2340 if (!fn.contains (".odp"))
2343 //lastImageDir=fn.left(fn.findRev ("/"));
2344 if (currentMapEditor())
2345 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2349 QMessageBox::warning(0,
2351 tr("Couldn't find configuration for export to Open Office\n"));
2355 void Main::fileCloseMap()
2357 if (currentMapEditor())
2359 if (currentMapEditor()->hasChanged())
2361 QMessageBox mb( vymName,
2362 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2363 QMessageBox::Warning,
2364 QMessageBox::Yes | QMessageBox::Default,
2366 QMessageBox::Cancel | QMessageBox::Escape );
2367 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2368 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2371 case QMessageBox::Yes:
2373 fileSave(CompleteMap);
2375 case QMessageBox::No:
2376 // close without saving
2378 case QMessageBox::Cancel:
2383 currentMapEditor()->closeMap();
2384 tabWidget->removePage(currentMapEditor());
2385 if (tabWidget->count()==0)
2386 actionFilePrint->setEnabled (false);
2390 void Main::filePrint()
2392 if (currentMapEditor())
2393 currentMapEditor()->print();
2396 void Main::fileExitVYM()
2398 // Check if one or more editors have changed
2401 for (i=0;i<=tabWidget->count() -1;i++)
2404 me=(MapEditor*)tabWidget->page(i);
2406 // If something changed, ask what to do
2407 if (me->isUnsaved())
2409 tabWidget->setCurrentPage(i);
2410 QMessageBox mb( vymName,
2411 tr("This map is not saved yet. Do you want to"),
2412 QMessageBox::Warning,
2413 QMessageBox::Yes | QMessageBox::Default,
2415 QMessageBox::Cancel | QMessageBox::Escape );
2416 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2417 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2420 mb.setActiveWindow();
2421 switch( mb.exec() ) {
2422 case QMessageBox::Yes:
2423 // save (the changed editors) and exit
2424 fileSave(CompleteMap);
2426 case QMessageBox::No:
2427 // exit without saving
2429 case QMessageBox::Cancel:
2430 // don't save and don't exit
2434 } // loop over all MEs
2438 void Main::editUndo()
2440 if (currentMapEditor())
2441 currentMapEditor()->undo();
2444 void Main::editRedo()
2446 if (currentMapEditor())
2447 currentMapEditor()->redo();
2450 void Main::gotoHistoryStep (int i)
2452 if (currentMapEditor())
2453 currentMapEditor()->gotoHistoryStep (i);
2456 void Main::editCopy()
2458 if (currentMapEditor())
2459 currentMapEditor()->copy();
2462 void Main::editPaste()
2464 if (currentMapEditor())
2465 currentMapEditor()->paste();
2468 void Main::editCut()
2470 if (currentMapEditor())
2471 currentMapEditor()->cut();
2474 void Main::editOpenFindWindow()
2476 findWindow->popup();
2477 findWindow->raise();
2478 findWindow->setActiveWindow();
2481 void Main::editFind(QString s)
2484 BranchObj *bo=currentMapEditor()->findText(s, cs);
2487 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2490 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2491 tr("No matches found for \"%1\"").arg(s));
2495 void Main::editFindChanged()
2496 { // Notify editor, to abort the current find process
2497 currentMapEditor()->findReset();
2500 void Main::openTabs(QStringList urls)
2502 if (!urls.isEmpty())
2506 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2508 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2510 QString u=urls.takeFirst();
2511 procBrowser = new QProcess( this );
2513 procBrowser->start(browser,args);
2514 if ( !procBrowser->waitForStarted())
2516 // try to set path to browser
2517 QMessageBox::warning(0,
2519 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2520 tr("Please use Settings->")+tr("Set application to open an URL"));
2525 if (browser.contains("konqueror"))
2527 for (int i=0; i<urls.size(); i++)
2530 // Try to open new tab in existing konqueror started previously by vym
2531 p=new QProcess (this);
2533 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2534 "konqueror-mainwindow#1"<<
2537 p->start ("dcop",args);
2538 if ( !p->waitForStarted() ) success=false;
2541 QMessageBox::warning(0,
2543 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2545 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2547 for (int i=0; i<urls.size(); i++)
2549 // Try to open new tab in firefox
2550 p=new QProcess (this);
2551 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2552 p->start (browser,args);
2553 if ( !p->waitForStarted() ) success=false;
2556 QMessageBox::warning(0,
2558 tr("Couldn't start %1 to open a new tab").arg(browser));
2561 QMessageBox::warning(0,
2563 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2567 void Main::editOpenURL()
2570 if (currentMapEditor())
2572 QString url=currentMapEditor()->getURL();
2574 if (url=="") return;
2575 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2576 procBrowser = new QProcess( this );
2578 procBrowser->start(browser,args);
2579 if ( !procBrowser->waitForStarted())
2581 // try to set path to browser
2582 QMessageBox::warning(0,
2584 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2585 tr("Please use Settings->")+tr("Set application to open an URL"));
2590 void Main::editOpenURLTab()
2592 if (currentMapEditor())
2595 urls.append(currentMapEditor()->getURL());
2599 void Main::editOpenMultipleURLTabs()
2601 if (currentMapEditor())
2604 urls=currentMapEditor()->getURLs();
2610 void Main::editURL()
2612 if (currentMapEditor())
2613 currentMapEditor()->editURL();
2616 void Main::editHeading2URL()
2618 if (currentMapEditor())
2619 currentMapEditor()->editHeading2URL();
2622 void Main::editBugzilla2URL()
2624 if (currentMapEditor())
2625 currentMapEditor()->editBugzilla2URL();
2628 void Main::editFATE2URL()
2630 if (currentMapEditor())
2631 currentMapEditor()->editFATE2URL();
2634 void Main::editHeadingFinished()
2636 // only called from editHeading(), so there is a currentME
2637 MapEditor *me=currentMapEditor();
2640 QPoint p; //Not used here, only to find out pos of branch
2642 QString s=me->getHeading(ok,p);
2644 #if defined(Q_OS_MACX)
2646 if (ok && s!=lineedit->text())
2647 me->setHeading(lineedit->text());
2649 lineedit->releaseKeyboard();
2653 if (!prevSelection.isEmpty()) me->select(prevSelection);
2658 void Main::editHeading()
2660 if (currentMapEditor())
2662 MapEditor *me=currentMapEditor();
2663 QString oldSel=me->getSelectString();
2665 if (lineedit->isVisible())
2666 editHeadingFinished();
2671 QString s=currentMapEditor()->getHeading(ok,p);
2675 #if defined(Q_OS_MACX)
2676 p=currentMapEditor()->mapTo (this,p);
2677 QDialog *d =new QDialog(NULL);
2678 QLineEdit *le=new QLineEdit (d);
2679 d->setWindowFlags (Qt::FramelessWindowHint);
2680 d->setGeometry(p.x(),p.y(),230,25);
2681 le->resize (d->width()-10,d->height());
2684 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2685 d->activateWindow();
2687 currentMapEditor()->setHeading (le->text());
2690 editHeadingFinished();
2692 p=currentMapEditor()->mapTo (this,p);
2693 lineedit->setGeometry(p.x(),p.y(),230,25);
2694 lineedit->setText(s);
2695 lineedit->setCursorPosition(1);
2696 lineedit->selectAll();
2698 lineedit->grabKeyboard();
2699 lineedit->setFocus();
2703 } // currentMapEditor()
2706 void Main::openVymLinks(const QStringList &vl)
2708 for (int j=0; j<vl.size(); j++)
2710 // compare path with already loaded maps
2714 for (i=0;i<=tabWidget->count() -1;i++)
2716 me=(MapEditor*)tabWidget->page(i);
2717 if (vl.at(j)==me->getFilePath() )
2726 if (!QFile(vl.at(j)).exists() )
2727 QMessageBox::critical( 0, tr( "Critical Error" ),
2728 tr("Couldn't open map %1").arg(vl.at(j)));
2731 fileLoad (vl.at(j), NewMap);
2732 tabWidget->setCurrentPage (tabWidget->count()-1);
2735 // Go to tab containing the map
2736 tabWidget->setCurrentPage (index);
2740 void Main::editOpenVymLink()
2742 if (currentMapEditor())
2745 vl.append(currentMapEditor()->getVymLink());
2750 void Main::editOpenMultipleVymLinks()
2752 QString currentVymLink;
2753 if (currentMapEditor())
2755 QStringList vl=currentMapEditor()->getVymLinks();
2760 void Main::editVymLink()
2762 if (currentMapEditor())
2763 currentMapEditor()->editVymLink();
2766 void Main::editDeleteVymLink()
2768 if (currentMapEditor())
2769 currentMapEditor()->deleteVymLink();
2772 void Main::editToggleHideExport()
2774 if (currentMapEditor())
2775 currentMapEditor()->toggleHideExport();
2778 void Main::editMapInfo()
2780 if (currentMapEditor())
2781 currentMapEditor()->editMapInfo();
2784 void Main::editMoveUp()
2786 if (currentMapEditor())
2787 currentMapEditor()->moveBranchUp();
2790 void Main::editMoveDown()
2792 if (currentMapEditor())
2793 currentMapEditor()->moveBranchDown();
2796 void Main::editToggleScroll()
2798 if (currentMapEditor())
2800 currentMapEditor()->toggleScroll();
2804 void Main::editUnScrollAll()
2806 if (currentMapEditor())
2807 currentMapEditor()->unscrollChilds();
2810 void Main::editNewBranch()
2812 MapEditor *me=currentMapEditor();
2813 if (!lineedit->isVisible() && me)
2815 BranchObj *bo=(BranchObj*)me->getSelection();
2816 BranchObj *newbo=me->addNewBranch(0);
2819 me->select (newbo->getSelectString());
2823 if (actionSettingsAutoEdit->isOn())
2825 if (!actionSettingsAutoSelectHeading->isOn())
2826 prevSelection=bo->getSelectString();
2832 void Main::editNewBranchBefore()
2834 MapEditor *me=currentMapEditor();
2835 if (!lineedit->isVisible() && me)
2837 BranchObj *bo=(BranchObj*)me->getSelection();
2838 BranchObj *newbo=me->addNewBranchBefore();
2841 me->select (newbo->getSelectString());
2845 if (actionSettingsAutoEdit->isOn())
2847 if (!actionSettingsAutoSelectHeading->isOn())
2848 prevSelection=bo->getSelectString();
2854 void Main::editNewBranchAbove()
2856 MapEditor *me=currentMapEditor();
2857 if (!lineedit->isVisible() && me)
2859 BranchObj *bo=(BranchObj*)me->getSelection();
2860 BranchObj *newbo=me->addNewBranch (-1);
2863 me->select (newbo->getSelectString());
2867 if (actionSettingsAutoEdit->isOn())
2869 if (!actionSettingsAutoSelectHeading->isOn())
2870 prevSelection=bo->getSelectString();
2876 void Main::editNewBranchBelow()
2878 MapEditor *me=currentMapEditor();
2879 if (!lineedit->isVisible() && me)
2881 BranchObj *bo=(BranchObj*)me->getSelection();
2882 BranchObj *newbo=me->addNewBranch (1);
2885 me->select (newbo->getSelectString());
2889 if (actionSettingsAutoEdit->isOn())
2891 if (!actionSettingsAutoSelectHeading->isOn())
2892 prevSelection=bo->getSelectString();
2898 void Main::editImportAdd()
2900 fileLoad (ImportAdd);
2903 void Main::editImportReplace()
2905 fileLoad (ImportReplace);
2908 void Main::editSaveBranch()
2910 fileSaveAs (PartOfMap);
2913 void Main::editDeleteKeepChilds()
2915 if (currentMapEditor())
2916 currentMapEditor()->deleteKeepChilds();
2919 void Main::editDeleteChilds()
2921 if (currentMapEditor())
2922 currentMapEditor()->deleteChilds();
2925 void Main::editDeleteSelection()
2927 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2928 currentMapEditor()->deleteSelection();
2931 void Main::editUpperBranch()
2933 if (currentMapEditor())
2934 currentMapEditor()->selectUpperBranch();
2937 void Main::editLowerBranch()
2939 if (currentMapEditor())
2940 currentMapEditor()->selectLowerBranch();
2943 void Main::editLeftBranch()
2945 if (currentMapEditor())
2946 currentMapEditor()->selectLeftBranch();
2949 void Main::editRightBranch()
2951 if (currentMapEditor())
2952 currentMapEditor()->selectRightBranch();
2955 void Main::editFirstBranch()
2957 if (currentMapEditor())
2958 currentMapEditor()->selectFirstBranch();
2961 void Main::editLastBranch()
2963 if (currentMapEditor())
2964 currentMapEditor()->selectLastBranch();
2967 void Main::editLoadImage()
2969 if (currentMapEditor())
2970 currentMapEditor()->loadFloatImage();
2973 void Main::editSaveImage()
2975 if (currentMapEditor())
2976 currentMapEditor()->saveFloatImage();
2979 void Main::editFollowXLink(QAction *a)
2982 if (currentMapEditor())
2983 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2986 void Main::editEditXLink(QAction *a)
2988 if (currentMapEditor())
2989 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2992 void Main::formatSelectColor()
2994 if (currentMapEditor())
2996 QColor col = QColorDialog::getColor((currentColor ), this );
2997 if ( !col.isValid() ) return;
2998 colorChanged( col );
3002 void Main::formatPickColor()
3004 if (currentMapEditor())
3005 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3008 void Main::colorChanged(QColor c)
3010 QPixmap pix( 16, 16 );
3012 actionFormatColor->setIconSet( pix );
3016 void Main::formatColorBranch()
3018 if (currentMapEditor())
3019 currentMapEditor()->colorBranch(currentColor);
3022 void Main::formatColorSubtree()
3024 if (currentMapEditor())
3025 currentMapEditor()->colorSubtree (currentColor);
3028 void Main::formatLinkStyleLine()
3030 if (currentMapEditor())
3031 currentMapEditor()->setMapLinkStyle("StyleLine");
3034 void Main::formatLinkStyleParabel()
3036 if (currentMapEditor())
3037 currentMapEditor()->setMapLinkStyle("StyleParabel");
3040 void Main::formatLinkStylePolyLine()
3042 if (currentMapEditor())
3043 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3046 void Main::formatLinkStylePolyParabel()
3048 if (currentMapEditor())
3049 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3052 void Main::formatSelectBackColor()
3054 if (currentMapEditor())
3055 currentMapEditor()->selectMapBackgroundColor();
3058 void Main::formatSelectBackImage()
3060 if (currentMapEditor())
3061 currentMapEditor()->selectMapBackgroundImage();
3064 void Main::formatSelectLinkColor()
3066 if (currentMapEditor())
3067 currentMapEditor()->selectMapLinkColor();
3070 void Main::formatToggleLinkColorHint()
3072 currentMapEditor()->toggleMapLinkColorHint();
3076 void Main::formatIncludeImagesVer()
3078 if (currentMapEditor())
3079 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3082 void Main::formatIncludeImagesHor()
3084 if (currentMapEditor())
3085 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3088 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3090 if (currentMapEditor())
3091 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3094 void Main::viewZoomReset()
3096 if (currentMapEditor())
3100 currentMapEditor()->setMatrix( m );
3104 void Main::viewZoomIn()
3106 if (currentMapEditor())
3108 QMatrix m = currentMapEditor()->matrix();
3109 m.scale( 1.25, 1.25 );
3110 currentMapEditor()->setMatrix( m );
3114 void Main::viewZoomOut()
3116 if (currentMapEditor())
3118 QMatrix m = currentMapEditor()->matrix();
3119 m.scale( 0.8, 0.8 );
3120 currentMapEditor()->setMatrix( m );
3124 bool Main::settingsPDF()
3126 // Default browser is set in constructor
3128 QString text = QInputDialog::getText(
3129 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3130 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3132 settings.setValue ("/mainwindow/readerPDF",text);
3137 bool Main::settingsURL()
3139 // Default browser is set in constructor
3141 QString text = QInputDialog::getText(
3142 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3143 settings.value("/mainwindow/readerURL").toString()
3146 settings.setValue ("/mainwindow/readerURL",text);
3150 void Main::settingsToggleDelKey()
3152 if (actionSettingsUseDelKey->isOn())
3154 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3157 actionEditDelete->setAccel (QKeySequence (""));
3161 void Main::windowToggleNoteEditor()
3163 if (textEditor->showWithMain() )
3164 windowHideNoteEditor();
3166 windowShowNoteEditor();
3169 void Main::windowToggleHistory()
3171 if (historyWindow->isVisible())
3172 historyWindow->hide();
3174 historyWindow->show();
3178 void Main::windowToggleAntiAlias()
3180 bool b=actionViewToggleAntiAlias->isOn();
3182 for (int i=0;i<tabWidget->count();i++)
3185 me=(MapEditor*)tabWidget->page(i);
3186 me->setAntiAlias(b);
3191 void Main::windowToggleSmoothPixmap()
3193 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3195 for (int i=0;i<tabWidget->count();i++)
3198 me=(MapEditor*)tabWidget->page(i);
3199 me->setSmoothPixmap(b);
3203 void Main::updateHistory(SimpleSettings &undoSet)
3205 historyWindow->update (undoSet);
3208 void Main::updateNoteFlag()
3210 if (currentMapEditor())
3211 currentMapEditor()->updateNoteFlag();
3214 void Main::updateActions()
3216 MapEditor *me=currentMapEditor();
3219 historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
3221 // updateActions is also called when NoteEditor is closed
3222 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3224 if (me->getMapLinkColorHint()==HeadingColor)
3225 actionFormatLinkColorHint->setOn(true);
3227 actionFormatLinkColorHint->setOn(false);
3229 switch (me->getMapLinkStyle())
3232 actionFormatLinkStyleLine->setOn(true);
3235 actionFormatLinkStyleParabel->setOn(true);
3238 actionFormatLinkStylePolyLine->setOn(true);
3240 case StylePolyParabel:
3241 actionFormatLinkStylePolyParabel->setOn(true);
3247 QPixmap pix( 16, 16 );
3248 pix.fill( me->getMapBackgroundColor() );
3249 actionFormatBackColor->setIconSet( pix );
3250 pix.fill( me->getMapDefLinkColor() );
3251 actionFormatLinkColor->setIconSet( pix );
3253 actionFileSave->setEnabled( me->isUnsaved() );
3254 if (me->isUndoAvailable())
3255 actionEditUndo->setEnabled( true);
3257 actionEditUndo->setEnabled( false);
3259 if (me->isRedoAvailable())
3260 actionEditRedo->setEnabled( true);
3262 actionEditRedo->setEnabled( false);
3264 LinkableMapObj *selection=me->getSelection();
3267 if ( (typeid(*selection) == typeid(BranchObj)) ||
3268 (typeid(*selection) == typeid(MapCenterObj)) )
3270 BranchObj *bo=(BranchObj*)selection;
3271 // Take care of links
3272 if (bo->countXLinks()==0)
3274 branchXLinksContextMenuEdit->clear();
3275 branchXLinksContextMenuFollow->clear();
3280 branchXLinksContextMenuEdit->clear();
3281 branchXLinksContextMenuFollow->clear();
3282 for (int i=0; i<=bo->countXLinks();i++)
3284 bot=bo->XLinkTargetAt(i);
3287 s=bot->getHeading();
3290 branchXLinksContextMenuFollow->addAction (s);
3291 branchXLinksContextMenuEdit->addAction (s);
3296 standardFlagsDefault->setEnabled (true);
3298 actionEditToggleScroll->setEnabled (true);
3299 if ( bo->isScrolled() )
3300 actionEditToggleScroll->setOn(true);
3302 actionEditToggleScroll->setOn(false);
3304 if ( bo->getURL().isEmpty() )
3306 actionEditOpenURL->setEnabled (false);
3307 actionEditOpenURLTab->setEnabled (false);
3311 actionEditOpenURL->setEnabled (true);
3312 actionEditOpenURLTab->setEnabled (true);
3314 if ( bo->getVymLink().isEmpty() )
3316 actionEditOpenVymLink->setEnabled (false);
3317 actionEditDeleteVymLink->setEnabled (false);
3320 actionEditOpenVymLink->setEnabled (true);
3321 actionEditDeleteVymLink->setEnabled (true);
3324 if (bo->canMoveBranchUp())
3325 actionEditMoveUp->setEnabled (true);
3327 actionEditMoveUp->setEnabled (false);
3328 if (bo->canMoveBranchDown())
3329 actionEditMoveDown->setEnabled (true);
3331 actionEditMoveDown->setEnabled (false);
3334 actionEditToggleHideExport->setEnabled (true);
3335 actionEditToggleHideExport->setOn (bo->hideInExport() );
3337 actionEditCopy->setEnabled (true);
3338 actionEditCut->setEnabled (true);
3339 if (!clipboardEmpty)
3340 actionEditPaste->setEnabled (true);
3342 actionEditPaste->setEnabled (false);
3343 for (int i=0; i<actionListBranches.size(); ++i)
3344 actionListBranches.at(i)->setEnabled(true);
3345 actionEditDelete->setEnabled (true);
3346 actionFormatIncludeImagesVer->setOn
3347 ( ((BranchObj*)selection)->getIncludeImagesVer());
3348 actionFormatIncludeImagesHor->setOn
3349 ( ((BranchObj*)selection)->getIncludeImagesHor());
3350 actionFormatHideLinkUnselected->setOn
3351 (selection->getHideLinkUnselected());
3353 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3355 FloatObj *fo=(FloatImageObj*)selection;
3357 actionEditOpenURL->setEnabled (false);
3358 actionEditOpenVymLink->setEnabled (false);
3359 actionEditDeleteVymLink->setEnabled (false);
3360 actionEditToggleHideExport->setEnabled (true);
3361 actionEditToggleHideExport->setOn (fo->hideInExport() );
3364 actionEditCopy->setEnabled (true);
3365 actionEditCut->setEnabled (true);
3366 actionEditPaste->setEnabled (false);
3367 for (int i=0; i<actionListBranches.size(); ++i)
3368 actionListBranches.at(i)->setEnabled(false);
3369 actionEditDelete->setEnabled (true);
3370 actionFormatHideLinkUnselected->setOn
3371 ( selection->getHideLinkUnselected());
3372 actionEditMoveUp->setEnabled (false);
3373 actionEditMoveDown->setEnabled (false);
3378 actionEditCopy->setEnabled (false);
3379 actionEditCut->setEnabled (false);
3380 actionEditPaste->setEnabled (false);
3381 for (int i=0; i<actionListBranches.size(); ++i)
3382 actionListBranches.at(i)->setEnabled(false);
3384 actionEditToggleScroll->setEnabled (false);
3385 actionEditOpenURL->setEnabled (false);
3386 actionEditOpenVymLink->setEnabled (false);
3387 actionEditDeleteVymLink->setEnabled (false);
3388 actionEditHeading2URL->setEnabled (false);
3389 actionEditDelete->setEnabled (false);
3390 actionEditMoveUp->setEnabled (false);
3391 actionEditMoveDown->setEnabled (false);
3392 actionEditToggleHideExport->setEnabled (false);
3396 ModMode Main::getModMode()
3398 if (actionModModeColor->isOn()) return ModModeColor;
3399 if (actionModModeCopy->isOn()) return ModModeCopy;
3400 if (actionModModeXLink->isOn()) return ModModeXLink;
3404 bool Main::autoEdit()
3406 return actionSettingsAutoEdit->isOn();
3409 bool Main::autoSelectHeading()
3411 return actionSettingsAutoSelectHeading->isOn();
3414 bool Main::useFlagGroups()
3416 return actionSettingsUseFlagGroups->isOn();
3419 void Main::windowShowNoteEditor()
3421 textEditor->setShowWithMain(true);
3423 actionViewToggleNoteEditor->setOn (true);
3426 void Main::windowHideNoteEditor()
3428 textEditor->setShowWithMain(false);
3430 actionViewToggleNoteEditor->setOn (false);
3433 void Main::setScript (const QString &script)
3435 scriptEditor->setScript (script);
3438 void Main::runScript (const QString &script)
3440 if (currentMapEditor())
3441 currentMapEditor()->runScript (script);
3444 void Main::showPropertyDialog()
3446 if(currentMapEditor())
3448 LinkableMapObj *sel=currentMapEditor()->getSelection();
3449 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3450 typeid(*sel) == typeid(MapCenterObj)))
3452 branchPropertyWindow->show();
3453 branchPropertyWindow->setMapEditor(currentMapEditor());
3454 branchPropertyWindow->setBranch((BranchObj*)sel);
3459 branchPropertyWindow->setBranch(NULL);
3462 void Main::windowNextEditor()
3464 if (tabWidget->currentPageIndex() < tabWidget->count())
3465 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3468 void Main::windowPreviousEditor()
3470 if (tabWidget->currentPageIndex() >0)
3471 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3474 void Main::standardFlagChanged()
3476 if (currentMapEditor())
3477 currentMapEditor()->toggleStandardFlag(sender()->name());
3480 void Main::testFunction()
3482 if (!currentMapEditor()) return;
3483 currentMapEditor()->testFunction();
3486 void Main::testCommand()
3488 if (!currentMapEditor()) return;
3489 scriptEditor->show();
3492 QString com = QInputDialog::getText(
3493 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3494 if (ok) currentMapEditor()->parseAtom(com);
3498 void Main::helpDoc()
3500 QString locale = QLocale::system().name();
3502 if (locale.left(2)=="es")
3503 docname="vym_es.pdf";
3507 QStringList searchList;
3509 #if defined(Q_OS_MACX)
3510 searchList << "./vym.app/Contents";
3512 // default path in SUSE LINUX
3513 searchList <<"/usr/share/doc/packages/vym/doc";
3516 searchList << "doc"; // relative path for easy testing in tarball
3517 searchList << "doc/tex"; // Easy testing working on vym.tex
3518 searchList << "/usr/share/doc/vym"; // Debian
3519 searchList << "/usr/share/doc/packages";// Knoppix
3523 for (int i=0; i<searchList.count(); ++i)
3525 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3526 if (docfile.exists() )
3535 QMessageBox::critical(0,
3536 tr("Critcal error"),
3537 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3542 Process *pdfProc = new Process();
3543 args <<docfile.fileName();
3545 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3546 if ( !pdfProc->waitForStarted() )
3549 QMessageBox::warning(0,
3551 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3552 tr("Please use Settings->")+tr("Set application to open PDF files"));
3559 void Main::helpAbout()
3562 ad.setName ("aboutwindow");
3563 ad.setMinimumSize(500,500);
3564 ad.resize (QSize (500,500));
3568 void Main::helpAboutQT()
3570 QMessageBox::aboutQt( this, "Qt Application Example" );