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 fileMenu->addSeparator();
262 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
263 a->setStatusTip ( tr( "Save","Status tip file menu" ));
264 a->setShortcut (Qt::CTRL + Qt::Key_S );
266 fileMenu->addAction (a);
267 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
270 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
271 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
272 fileMenu->addAction (a);
273 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
275 fileMenu->addSeparator();
277 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
279 a = new QAction(tr("KDE Bookmarks"), this);
280 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
281 a->addTo (fileImportMenu);
282 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
284 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
286 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
287 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
288 a->addTo (fileImportMenu);
289 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
292 a = new QAction("Mind Manager...",this);
293 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
294 fileImportMenu->addAction (a);
295 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
297 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
298 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
299 fileImportMenu->addAction (a);
300 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
302 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
304 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
305 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
306 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
307 fileExportMenu->addAction (a);
309 a = new QAction( "Open Office...", this);
310 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
311 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
312 fileExportMenu->addAction (a);
314 a = new QAction( "Webpage (XHTML)...",this );
315 a->setShortcut (Qt::ALT + Qt::Key_X);
316 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
317 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
318 fileExportMenu->addAction (a);
320 a = new QAction( "Text (ASCII)...", this);
321 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
322 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
323 fileExportMenu->addAction (a);
325 a = new QAction( tr("KDE Bookmarks","File menu"), this);
326 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
327 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
328 fileExportMenu->addAction (a);
330 a = new QAction( "Taskjuggler...", this );
331 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
333 fileExportMenu->addAction (a);
335 a = new QAction( "LaTeX...", this);
336 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
338 fileExportMenu->addAction (a);
340 a = new QAction( "XML..." , this );
341 a->setStatusTip (tr( "Export as %1").arg("XML"));
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
343 fileExportMenu->addAction (a);
345 fileMenu->addSeparator();
347 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
348 a->setStatusTip ( tr( "Print" ,"File menu") );
349 a->setShortcut (Qt::CTRL + Qt::Key_P );
351 fileMenu->addAction (a);
352 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
355 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
356 a->setStatusTip (tr( "Close Map" ) );
357 a->setShortcut (Qt::ALT + Qt::Key_C );
358 fileMenu->addAction (a);
359 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
361 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
362 a->setStatusTip ( tr( "Exit")+" "+vymName );
363 a->setShortcut (Qt::CTRL + Qt::Key_Q );
364 fileMenu->addAction (a);
365 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
370 void Main::setupEditActions()
372 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
373 tb->setLabel( "Edit Actions" );
374 tb->setObjectName ("actionsTB");
375 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
379 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
380 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
381 a->setStatusTip (tr( "Undo" ) );
382 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
383 a->setEnabled (false);
385 editMenu->addAction (a);
388 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
389 a->setStatusTip (tr( "Redo" ));
390 a->setShortcut (Qt::CTRL + Qt::Key_Y );
392 editMenu->addAction (a);
393 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
396 editMenu->addSeparator();
397 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
398 a->setStatusTip ( tr( "Copy" ) );
399 a->setShortcut (Qt::CTRL + Qt::Key_C );
400 a->setEnabled (false);
402 editMenu->addAction (a);
403 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
406 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
407 a->setStatusTip ( tr( "Cut" ) );
408 a->setShortcut (Qt::CTRL + Qt::Key_X );
409 a->setEnabled (false);
411 editMenu->addAction (a);
413 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
415 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
416 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
417 a->setStatusTip ( tr( "Paste" ) );
418 a->setShortcut ( Qt::CTRL + Qt::Key_V );
419 a->setEnabled (false);
421 editMenu->addAction (a);
424 // Shortcuts to modify heading:
425 a = new QAction(tr( "Edit heading","Edit menu" ),this);
426 a->setStatusTip ( tr( "edit Heading" ));
427 a->setShortcut ( Qt::Key_Enter);
428 // a->setShortcutContext (Qt::WindowShortcut);
430 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
431 actionListBranches.append(a);
432 a = new QAction( tr( "Edit heading","Edit menu" ), this);
433 a->setStatusTip (tr( "edit Heading" ));
434 a->setShortcut (Qt::Key_Return );
435 //a->setShortcutContext (Qt::WindowShortcut);
437 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
438 actionListBranches.append(a);
439 editMenu->addAction (a);
441 a = new QAction( tr( "Edit heading","Edit menu" ), this);
442 a->setStatusTip (tr( "edit Heading" ));
443 a->setShortcut ( Qt::Key_F2 );
444 a->setShortcutContext (Qt::WindowShortcut);
446 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
447 actionListBranches.append(a);
449 // Shortcut to delete selection
450 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
451 a->setStatusTip (tr( "Delete Selection" ));
452 a->setShortcut ( Qt::Key_Delete);
453 a->setShortcutContext (Qt::WindowShortcut);
455 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
458 // Shortcut to add branch
459 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
460 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
461 alt->setShortcut (Qt::Key_A);
462 alt->setShortcutContext (Qt::WindowShortcut);
464 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
465 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
466 a->setStatusTip ( tr( "Add a branch as child of selection" ));
467 a->setShortcut (Qt::Key_Insert);
468 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
469 actionListBranches.append(a);
470 #if defined (Q_OS_MACX)
471 // In OSX show different shortcut in menues, the keys work indepently always
472 actionEditAddBranch=alt;
474 actionEditAddBranch=a;
476 editMenu->addAction (actionEditAddBranch);
477 tb->addAction (actionEditAddBranch);
480 // Add branch by inserting it at selection
481 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
482 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
483 a->setShortcut (Qt::ALT + Qt::Key_Insert );
484 a->setShortcutContext (Qt::WindowShortcut);
486 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
487 a->setEnabled (false);
488 actionListBranches.append(a);
489 actionEditAddBranchBefore=a;
490 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
491 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
492 a->setShortcut ( Qt::ALT + Qt::Key_A );
493 a->setShortcutContext (Qt::WindowShortcut);
495 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
496 actionListBranches.append(a);
499 a = new QAction(tr( "Add branch above","Edit menu" ), this);
500 a->setStatusTip ( tr( "Add a branch above selection" ));
501 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
502 a->setShortcutContext (Qt::WindowShortcut);
504 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
505 a->setEnabled (false);
506 actionListBranches.append(a);
507 actionEditAddBranchAbove=a;
508 a = new QAction(tr( "Add branch above","Edit menu" ), this);
509 a->setStatusTip ( tr( "Add a branch above selection" ));
510 a->setShortcut (Qt::SHIFT+Qt::Key_A );
511 a->setShortcutContext (Qt::WindowShortcut);
513 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
514 actionListBranches.append(a);
517 a = new QAction(tr( "Add branch below","Edit menu" ), this);
518 a->setStatusTip ( tr( "Add a branch below selection" ));
519 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
520 a->setShortcutContext (Qt::WindowShortcut);
522 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
523 a->setEnabled (false);
524 actionListBranches.append(a);
525 actionEditAddBranchBelow=a;
526 a = new QAction(tr( "Add branch below","Edit menu" ), this);
527 a->setStatusTip ( tr( "Add a branch below selection" ));
528 a->setShortcut (Qt::CTRL +Qt::Key_A );
529 a->setShortcutContext (Qt::WindowShortcut);
531 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
532 actionListBranches.append(a);
534 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
535 a->setStatusTip ( tr( "Move branch up" ) );
536 a->setShortcut (Qt::Key_PageUp );
537 a->setEnabled (false);
539 editMenu->addAction (a);
540 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
543 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
544 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
545 a->setStatusTip (tr( "Move branch down" ) );
546 a->setShortcut ( Qt::Key_PageDown );
547 a->setEnabled (false);
549 editMenu->addAction (a);
550 actionEditMoveDown=a;
553 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
554 a->setShortcut ( Qt::Key_ScrollLock );
555 a->setStatusTip (tr( "Scroll branch" ) );
556 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
558 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
559 alt->setShortcut ( Qt::Key_S );
560 alt->setStatusTip (tr( "Scroll branch" ));
561 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
562 #if defined(Q_OS_MACX)
563 actionEditToggleScroll=alt;
565 actionEditToggleScroll=a;
567 actionEditToggleScroll->setEnabled (false);
568 actionEditToggleScroll->setToggleAction(true);
569 tb->addAction (actionEditToggleScroll);
570 editMenu->addAction ( actionEditToggleScroll);
571 editMenu->addAction (actionEditToggleScroll);
574 actionListBranches.append(actionEditToggleScroll);
576 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
577 a->setStatusTip (tr( "Unscroll all" ));
578 editMenu->addAction (a);
579 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
581 editMenu->addSeparator();
583 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
584 a->setStatusTip (tr( "Find" ) );
585 a->setShortcut (Qt::CTRL + Qt::Key_F );
586 editMenu->addAction (a);
587 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
589 editMenu->addSeparator();
591 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
592 a->setShortcut (Qt::CTRL + Qt::Key_U );
593 a->setShortcut (tr( "Open URL" ));
596 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
599 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
600 a->setStatusTip (tr( "Open URL in new tab" ));
601 a->setShortcut (Qt::CTRL+Qt::Key_U );
603 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
604 actionEditOpenURLTab=a;
606 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
607 a->setStatusTip (tr( "Open all URLs in subtree" ));
609 actionListBranches.append(a);
610 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
611 actionEditOpenMultipleURLTabs=a;
613 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
614 a->setStatusTip ( tr( "Edit URL" ) );
615 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
616 //a->setShortcut ( Qt::Key_U );
617 a->setShortcutContext (Qt::WindowShortcut);
618 actionListBranches.append(a);
620 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
623 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
624 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
625 a->setEnabled (false);
626 actionListBranches.append(a);
627 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
628 actionEditHeading2URL=a;
630 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
631 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
635 actionEditBugzilla2URL=a;
637 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
638 a->setStatusTip ( tr( "Create URL to FATE" ));
639 a->setEnabled (false);
640 actionListBranches.append(a);
641 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
642 actionEditFATE2URL=a;
644 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
645 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
647 a->setEnabled (false);
648 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
649 actionEditOpenVymLink=a;
651 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
652 a->setStatusTip ( tr( "Open all vym links in subtree" ));
653 a->setEnabled (false);
654 actionListBranches.append(a);
655 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
656 actionEditOpenMultipleVymLinks=a;
659 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
660 a->setEnabled (false);
661 a->setStatusTip ( tr( "Edit link to another vym map" ));
662 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
663 actionListBranches.append(a);
666 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
667 a->setStatusTip ( tr( "Delete link to another vym map" ));
668 a->setEnabled (false);
669 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
670 actionEditDeleteVymLink=a;
672 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
673 a->setStatusTip ( tr( "Hide object in exports" ) );
674 a->setShortcut (Qt::Key_H );
675 a->setToggleAction(true);
677 a->setEnabled (false);
678 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
679 actionEditToggleHideExport=a;
681 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
682 a->setStatusTip ( tr( "Edit Map Info" ));
683 a->setEnabled (true);
684 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
687 // Import at selection (adding to selection)
688 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
689 a->setStatusTip (tr( "Add map at selection" ));
690 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
691 a->setEnabled (false);
692 actionListBranches.append(a);
693 actionEditImportAdd=a;
695 // Import at selection (replacing selection)
696 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
697 a->setStatusTip (tr( "Replace selection with map" ));
698 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
699 a->setEnabled (false);
700 actionListBranches.append(a);
701 actionEditImportReplace=a;
704 a = new QAction( tr( "Save selection","Edit menu" ), this);
705 a->setStatusTip (tr( "Save selection" ));
706 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
707 a->setEnabled (false);
708 actionListBranches.append(a);
709 actionEditSaveBranch=a;
711 // Only remove branch, not its childs
712 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
713 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
714 a->setShortcut (Qt::ALT + Qt::Key_Delete );
715 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
716 a->setEnabled (false);
718 actionListBranches.append(a);
719 actionEditDeleteKeepChilds=a;
721 // Only remove childs of a branch
722 a = new QAction( tr( "Remove childs","Edit menu" ), this);
723 a->setStatusTip (tr( "Remove childs of branch" ));
724 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
725 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
726 a->setEnabled (false);
727 actionListBranches.append(a);
728 actionEditDeleteChilds=a;
730 // Shortcuts for navigating with cursor:
731 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
732 a->setStatusTip ( tr( "Select upper branch" ));
733 a->setShortcut (Qt::Key_Up );
734 a->setShortcutContext (Qt::WindowShortcut);
736 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
737 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
738 a->setStatusTip (tr( "Select lower branch" ));
739 a->setShortcut ( Qt::Key_Down );
740 a->setShortcutContext (Qt::WindowShortcut);
742 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
743 a = new QAction(tr( "Select left branch","Edit menu" ), this);
744 a->setStatusTip ( tr( "Select left branch" ));
745 a->setShortcut (Qt::Key_Left );
746 a->setShortcutContext (Qt::WindowShortcut);
748 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
749 a = new QAction( tr( "Select child branch","Edit menu" ), this);
750 a->setStatusTip (tr( "Select right branch" ));
751 a->setShortcut (Qt::Key_Right);
752 a->setShortcutContext (Qt::WindowShortcut);
754 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
755 a = new QAction( tr( "Select first branch","Edit menu" ), this);
756 a->setStatusTip (tr( "Select first branch" ));
757 a->setShortcut (Qt::Key_Home );
758 a->setShortcutContext (Qt::WindowShortcut);
760 a->setEnabled (false);
761 editMenu->addAction (a);
762 actionListBranches.append(a);
763 actionEditSelectFirst=a;
764 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
765 a = new QAction( tr( "Select last branch","Edit menu" ),this);
766 a->setStatusTip (tr( "Select last branch" ));
767 a->setShortcut ( Qt::Key_End );
768 a->setShortcutContext (Qt::WindowShortcut);
770 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
771 a->setEnabled (false);
772 editMenu->addAction (a);
773 actionListBranches.append(a);
774 actionEditSelectLast=a;
776 a = new QAction( tr( "Add Image...","Edit menu" ), this);
777 a->setStatusTip (tr( "Add Image" ));
778 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
779 actionEditLoadImage=a;
781 a = new QAction( tr( "Properties","Context menu for images and branches" )+QString ("..."), this);
782 a->setStatusTip (tr( "Set properties for object" ));
783 connect( a, SIGNAL( triggered() ), this, SLOT( showPropertyDialog() ) );
784 actionOpenPropertyDialog=a;
788 void Main::setupFormatActions()
790 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
792 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
793 tb->setObjectName ("formatTB");
796 pix.fill (Qt::black);
797 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
798 a->setStatusTip ( tr( "Set Color" ));
799 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
801 formatMenu->addAction (a);
803 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
804 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
805 a->setShortcut (Qt::CTRL + Qt::Key_K );
806 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
807 a->setEnabled (false);
809 formatMenu->addAction (a);
810 actionListBranches.append(a);
811 actionFormatPickColor=a;
813 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
814 a->setStatusTip ( tr( "Color branch" ) );
815 a->setShortcut (Qt::CTRL + Qt::Key_I);
816 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
817 a->setEnabled (false);
819 formatMenu->addAction (a);
820 actionListBranches.append(a);
821 actionFormatColorSubtree=a;
823 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
824 a->setStatusTip ( tr( "Color Subtree" ));
825 a->setShortcut (Qt::CTRL + Qt::Key_T);
826 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
827 a->setEnabled (false);
828 formatMenu->addAction (a);
830 actionListBranches.append(a);
831 actionFormatColorSubtree=a;
833 formatMenu->addSeparator();
834 actionGroupFormatLinkStyles=new QActionGroup ( this);
835 actionGroupFormatLinkStyles->setExclusive (true);
836 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
837 a->setStatusTip (tr( "Line" ));
838 a->setToggleAction(true);
839 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
840 formatMenu->addAction (a);
841 actionFormatLinkStyleLine=a;
842 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
843 a->setStatusTip (tr( "Line" ));
844 a->setToggleAction(true);
845 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
846 formatMenu->addAction (a);
847 actionFormatLinkStyleParabel=a;
848 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
849 a->setStatusTip (tr( "PolyLine" ));
850 a->setToggleAction(true);
851 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
852 formatMenu->addAction (a);
853 actionFormatLinkStylePolyLine=a;
854 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
855 a->setStatusTip (tr( "PolyParabel" ) );
856 a->setToggleAction(true);
857 a->setChecked (true);
858 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
859 formatMenu->addAction (a);
860 actionFormatLinkStylePolyParabel=a;
862 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
863 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
864 a->setToggleAction(true);
865 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
866 actionFormatIncludeImagesVer=a;
868 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
869 a->setStatusTip ( tr ("Include left and right position of images into branch"));
870 a->setToggleAction(true);
871 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
872 actionFormatIncludeImagesHor=a;
874 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
875 a->setStatusTip (tr( "Hide link" ));
876 a->setToggleAction(true);
877 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
878 actionFormatHideLinkUnselected=a;
880 formatMenu->addSeparator();
881 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
882 a->setStatusTip (tr( "Use same color for links and headings" ));
883 a->setToggleAction(true);
884 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
885 formatMenu->addAction (a);
886 actionFormatLinkColorHint=a;
888 pix.fill (Qt::white);
889 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
890 a->setStatusTip (tr( "Set Link Color" ));
891 formatMenu->addAction (a);
892 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
893 actionFormatLinkColor=a;
895 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
896 a->setStatusTip (tr( "Set Background Color" ));
897 formatMenu->addAction (a);
898 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
899 actionFormatBackColor=a;
901 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
902 a->setStatusTip (tr( "Set Background image" ));
903 formatMenu->addAction (a);
904 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
905 actionFormatBackImage=a;
909 void Main::setupViewActions()
911 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
912 tb->setLabel( "View Actions" );
913 tb->setObjectName ("viewTB");
914 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
917 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
918 a->setStatusTip ( tr( "Zoom reset" ) );
919 a->setShortcut (Qt::CTRL + Qt::Key_0 );
921 viewMenu->addAction (a);
922 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
924 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
925 a->setStatusTip (tr( "Zoom in" ));
926 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
928 viewMenu->addAction (a);
929 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
931 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
932 a->setStatusTip (tr( "Zoom out" ));
933 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
935 viewMenu->addAction (a);
936 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
939 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
940 a->setStatusTip ( tr( "Show Note Editor" ));
941 a->setShortcut ( Qt::CTRL + Qt::Key_E );
942 a->setToggleAction(true);
943 if (textEditor->showWithMain())
948 viewMenu->addAction (a);
949 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
950 actionViewToggleNoteEditor=a;
952 a = new QAction(QPixmap(iconPath+"history.png"), tr( "Show history window","View action" ),this );
953 a->setStatusTip ( tr( "Show history window" ));
954 a->setShortcut ( Qt::CTRL + Qt::Key_H );
955 a->setToggleAction(true);
957 viewMenu->addAction (a);
958 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
959 actionViewToggleHistoryWindow=a;
961 a = new QAction(tr( "Antialiasing","View action" ),this );
962 a->setStatusTip ( tr( "Antialiasing" ));
963 a->setToggleAction(true);
964 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
965 viewMenu->addAction (a);
966 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
967 actionViewToggleAntiAlias=a;
969 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
970 a->setStatusTip (a->text());
971 a->setToggleAction(true);
972 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
973 viewMenu->addAction (a);
974 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
975 actionViewToggleSmoothPixmapTransform=a;
977 a = new QAction(tr( "Next Window","View action" ), this);
978 a->setStatusTip (a->text());
979 a->setShortcut (Qt::ALT + Qt::Key_N );
980 viewMenu->addAction (a);
981 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
983 a = new QAction (tr( "Previous Window","View action" ), this );
984 a->setStatusTip (a->text());
985 a->setShortcut (Qt::ALT + Qt::Key_P );
986 viewMenu->addAction (a);
987 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
991 void Main::setupModeActions()
993 //QPopupMenu *menu = new QPopupMenu( this );
994 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
996 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
997 tb->setObjectName ("modesTB");
999 actionGroupModModes=new QActionGroup ( this);
1000 actionGroupModModes->setExclusive (true);
1001 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1002 a->setShortcut (Qt::Key_J);
1003 a->setStatusTip ( tr( "Use modifier to color branches" ));
1004 a->setToggleAction(true);
1007 actionModModeColor=a;
1009 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1010 a->setShortcut( Qt::Key_K);
1011 a->setStatusTip( tr( "Use modifier to copy" ));
1012 a->setToggleAction(true);
1014 actionModModeCopy=a;
1016 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1017 a->setShortcut (Qt::Key_L);
1018 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1019 a->setToggleAction(true);
1021 actionModModeXLink=a;
1025 void Main::setupFlagActions()
1027 // Create System Flags
1028 systemFlagsDefault = new FlagRowObj ();
1029 systemFlagsDefault->setVisibility (false);
1030 systemFlagsDefault->setName ("systemFlagsDef");
1032 FlagObj *fo = new FlagObj ();
1033 fo->load(QPixmap(flagsPath+"flag-note.png"));
1034 fo->setName("note");
1035 fo->setToolTip(tr("Note","Systemflag"));
1036 systemFlagsDefault->addFlag (fo); // makes deep copy
1038 fo->load(QPixmap(flagsPath+"flag-url.png"));
1040 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1041 systemFlagsDefault->addFlag (fo);
1043 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1044 fo->setName("vymLink");
1045 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1046 systemFlagsDefault->addFlag (fo);
1048 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1049 fo->setName("scrolledright");
1050 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1051 systemFlagsDefault->addFlag (fo);
1053 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1054 fo->setName("tmpUnscrolledright");
1055 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1056 systemFlagsDefault->addFlag (fo);
1058 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1059 fo->setName("hideInExport");
1060 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1061 systemFlagsDefault->addFlag (fo);
1063 // Create Standard Flags
1064 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1065 tb->setObjectName ("standardFlagTB");
1067 standardFlagsDefault = new FlagRowObj ();
1068 standardFlagsDefault->setVisibility (false);
1069 standardFlagsDefault->setName ("standardFlagsDef");
1070 standardFlagsDefault->setToolBar (tb);
1072 fo->load(flagsPath+"flag-exclamationmark.png");
1073 fo->setName ("exclamationmark");
1074 fo->setGroup("standard-mark");
1075 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1078 a->setCheckable(true);
1079 a->setObjectName(fo->getName());
1080 a->setToolTip(tr("Take care!","Standardflag"));
1081 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1082 standardFlagsDefault->addFlag (fo); // makes deep copy
1084 fo->load(flagsPath+"flag-questionmark.png");
1085 fo->setName("questionmark");
1086 fo->setGroup("standard-mark");
1087 a=new QAction (fo->getPixmap(),fo->getName(),this);
1090 a->setCheckable(true);
1091 a->setObjectName(fo->getName());
1092 a->setToolTip(tr("Really?","Standardflag"));
1093 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1094 standardFlagsDefault->addFlag (fo);
1096 fo->load(flagsPath+"flag-hook-green.png");
1097 fo->setName("hook-green");
1098 fo->setGroup("standard-hook");
1099 a=new QAction (fo->getPixmap(),fo->getName(),this);
1102 a->setCheckable(true);
1103 a->setObjectName(fo->getName());
1104 a->setToolTip(tr("ok!","Standardflag"));
1105 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1106 standardFlagsDefault->addFlag (fo);
1108 fo->load(flagsPath+"flag-cross-red.png");
1109 fo->setName("cross-red");
1110 fo->setGroup("standard-hook");
1111 a=new QAction (fo->getPixmap(),fo->getName(),this);
1114 a->setCheckable(true);
1115 a->setObjectName(fo->getName());
1116 a->setToolTip(tr("Not ok!","Standardflag"));
1117 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1118 standardFlagsDefault->addFlag (fo);
1120 fo->load(flagsPath+"flag-stopsign.png");
1121 fo->setName("stopsign");
1122 a=new QAction (fo->getPixmap(),fo->getName(),this);
1125 a->setCheckable(true);
1126 a->setObjectName(fo->getName());
1127 a->setToolTip(tr("This won't work!","Standardflag"));
1128 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1129 standardFlagsDefault->addFlag (fo);
1131 fo->load(flagsPath+"flag-smiley-good.png");
1132 fo->setName("smiley-good");
1133 fo->setGroup("standard-smiley");
1134 a=new QAction (fo->getPixmap(),fo->getName(),this);
1137 a->setCheckable(true);
1138 a->setObjectName(fo->getName());
1139 a->setToolTip(tr("Good","Standardflag"));
1140 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1141 standardFlagsDefault->addFlag (fo);
1143 fo->load(flagsPath+"flag-smiley-sad.png");
1144 fo->setName("smiley-sad");
1145 fo->setGroup("standard-smiley");
1146 a=new QAction (fo->getPixmap(),fo->getName(),this);
1149 a->setCheckable(true);
1150 a->setObjectName(fo->getName());
1151 a->setToolTip(tr("Bad","Standardflag"));
1152 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1153 standardFlagsDefault->addFlag (fo);
1155 fo->load(flagsPath+"flag-smiley-omg.png");
1156 // Original omg.png (in KDE emoticons)
1157 fo->setName("smiley-omg");
1158 fo->setGroup("standard-smiley");
1159 a=new QAction (fo->getPixmap(),fo->getName(),this);
1162 a->setCheckable(true);
1163 a->setObjectName(fo->getName());
1164 a->setToolTip(tr("Oh no!","Standardflag"));
1165 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1166 standardFlagsDefault->addFlag (fo);
1168 fo->load(flagsPath+"flag-kalarm.png");
1169 fo->setName("clock");
1170 a=new QAction (fo->getPixmap(),fo->getName(),this);
1173 a->setCheckable(true);
1174 a->setObjectName(fo->getName());
1175 a->setToolTip(tr("Time critical","Standardflag"));
1176 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1177 standardFlagsDefault->addFlag (fo);
1179 fo->load(flagsPath+"flag-phone.png");
1180 fo->setName("phone");
1181 a=new QAction (fo->getPixmap(),fo->getName(),this);
1184 a->setCheckable(true);
1185 a->setObjectName(fo->getName());
1186 a->setToolTip(tr("Call...","Standardflag"));
1187 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1188 standardFlagsDefault->addFlag (fo);
1190 fo->load(flagsPath+"flag-lamp.png");
1191 fo->setName("lamp");
1192 a=new QAction (fo->getPixmap(),fo->getName(),this);
1195 a->setCheckable(true);
1196 a->setObjectName(fo->getName());
1197 a->setToolTip(tr("Idea!","Standardflag"));
1198 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1199 standardFlagsDefault->addFlag (fo);
1201 fo->load(flagsPath+"flag-arrow-up.png");
1202 fo->setName("arrow-up");
1203 fo->setGroup("standard-arrow");
1204 a=new QAction (fo->getPixmap(),fo->getName(),this);
1207 a->setCheckable(true);
1208 a->setObjectName(fo->getName());
1209 a->setToolTip(tr("Important","Standardflag"));
1210 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1211 standardFlagsDefault->addFlag (fo);
1213 fo->load(flagsPath+"flag-arrow-down.png");
1214 fo->setName("arrow-down");
1215 fo->setGroup("standard-arrow");
1216 a=new QAction (fo->getPixmap(),fo->getName(),this);
1219 a->setCheckable(true);
1220 a->setObjectName(fo->getName());
1221 a->setToolTip(tr("Unimportant","Standardflag"));
1222 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1223 standardFlagsDefault->addFlag (fo);
1225 fo->load(flagsPath+"flag-arrow-2up.png");
1226 fo->setName("2arrow-up");
1227 fo->setGroup("standard-arrow");
1228 a=new QAction (fo->getPixmap(),fo->getName(),this);
1231 a->setCheckable(true);
1232 a->setObjectName(fo->getName());
1233 a->setToolTip(tr("Very important!","Standardflag"));
1234 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1235 standardFlagsDefault->addFlag (fo);
1237 fo->load(flagsPath+"flag-arrow-2down.png");
1238 fo->setName("2arrow-down");
1239 fo->setGroup("standard-arrow");
1240 a=new QAction (fo->getPixmap(),fo->getName(),this);
1243 a->setCheckable(true);
1244 a->setObjectName(fo->getName());
1245 a->setToolTip(tr("Very unimportant!","Standardflag"));
1246 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1247 standardFlagsDefault->addFlag (fo);
1249 fo->load(flagsPath+"flag-thumb-up.png");
1250 fo->setName("thumb-up");
1251 fo->setGroup("standard-thumb");
1252 a=new QAction (fo->getPixmap(),fo->getName(),this);
1255 a->setCheckable(true);
1256 a->setObjectName(fo->getName());
1257 a->setToolTip(tr("I like this","Standardflag"));
1258 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1259 standardFlagsDefault->addFlag (fo);
1261 fo->load(flagsPath+"flag-thumb-down.png");
1262 fo->setName("thumb-down");
1263 fo->setGroup("standard-thumb");
1264 a=new QAction (fo->getPixmap(),fo->getName(),this);
1267 a->setCheckable(true);
1268 a->setObjectName(fo->getName());
1269 a->setToolTip(tr("I do not like this","Standardflag"));
1270 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1271 standardFlagsDefault->addFlag (fo);
1273 fo->load(flagsPath+"flag-rose.png");
1274 fo->setName("rose");
1275 a=new QAction (fo->getPixmap(),fo->getName(),this);
1278 a->setCheckable(true);
1279 a->setObjectName(fo->getName());
1280 a->setToolTip(tr("Rose","Standardflag"));
1281 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1282 standardFlagsDefault->addFlag (fo);
1284 fo->load(flagsPath+"flag-heart.png");
1285 fo->setName("heart");
1286 a=new QAction (fo->getPixmap(),fo->getName(),this);
1288 a->setCheckable(true);
1289 a->setObjectName(fo->getName());
1290 a->setToolTip(tr("I just love... ","Standardflag"));
1291 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1292 standardFlagsDefault->addFlag (fo);
1294 fo->load(flagsPath+"flag-present.png");
1295 fo->setName("present");
1296 a=new QAction (fo->getPixmap(),fo->getName(),this);
1299 a->setCheckable(true);
1300 a->setObjectName(fo->getName());
1301 a->setToolTip(tr("Surprise!","Standardflag"));
1302 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1303 standardFlagsDefault->addFlag (fo);
1305 fo->load(flagsPath+"flag-flash.png");
1306 fo->setName("flash");
1307 a=new QAction (fo->getPixmap(),fo->getName(),this);
1310 a->setCheckable(true);
1311 a->setObjectName(fo->getName());
1312 a->setToolTip(tr("Dangerous","Standardflag"));
1313 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1314 standardFlagsDefault->addFlag (fo);
1316 fo->load(flagsPath+"flag-info.png");
1317 // Original: xsldbg_output.png
1318 fo->setName("info");
1319 a=new QAction (fo->getPixmap(),fo->getName(),this);
1322 a->setCheckable(true);
1323 a->setObjectName(fo->getName());
1324 a->setToolTip(tr("Info","Standardflag"));
1325 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1326 standardFlagsDefault->addFlag (fo);
1328 fo->load(flagsPath+"flag-lifebelt.png");
1329 // Original khelpcenter.png
1330 fo->setName("lifebelt");
1331 a=new QAction (fo->getPixmap(),fo->getName(),this);
1334 a->setCheckable(true);
1335 a->setObjectName(fo->getName());
1336 a->setToolTip(tr("This will help","Standardflag"));
1337 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1338 standardFlagsDefault->addFlag (fo);
1344 void Main::setupSettingsActions()
1346 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1350 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1351 a->setStatusTip ( tr( "Set application to open pdf files"));
1352 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1353 settingsMenu->addAction (a);
1355 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1356 a->setStatusTip( tr( "Set application to open external links"));
1357 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1358 settingsMenu->addAction (a);
1360 settingsMenu->addSeparator();
1361 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1362 a->setStatusTip( tr( "Edit branch after adding it" ));
1363 a->setToggleAction(true);
1364 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1365 settingsMenu->addAction (a);
1366 actionSettingsAutoEdit=a;
1368 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1369 a->setStatusTip( tr( "Select branch after adding it" ));
1370 a->setToggleAction(true);
1371 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1372 settingsMenu->addAction (a);
1373 actionSettingsAutoSelectHeading=a;
1375 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1376 a->setStatusTip( tr( "Select heading before editing" ));
1377 a->setToggleAction(true);
1378 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1379 settingsMenu->addAction (a);
1380 actionSettingsAutoSelectText=a;
1382 a= new QAction( tr( "Delete key","Settings action" ), this);
1383 a->setStatusTip( tr( "Delete key for deleting branches" ));
1384 a->setToggleAction(true);
1385 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1386 settingsMenu->addAction (a);
1387 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1388 actionSettingsUseDelKey=a;
1390 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1391 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1392 a->setToggleAction(true);
1393 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1394 settingsMenu->addAction (a);
1395 actionSettingsUseFlagGroups=a;
1397 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1398 a->setStatusTip( tr( "Use hide flag during exports " ));
1399 a->setToggleAction(true);
1400 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1401 settingsMenu->addAction (a);
1402 actionSettingsUseHideExport=a;
1406 void Main::setupTestActions()
1408 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1411 a = new QAction( "Test function" , this);
1412 a->setStatusTip( "Call test function" );
1413 a->setShortcut (Qt::Key_F4 );
1414 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1415 testMenu->addAction (a);
1416 a = new QAction( "Command" , this);
1417 a->setStatusTip( "Enter command to call in editor" );
1418 a->setShortcut (Qt::Key_F5 );
1419 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1420 testMenu->addAction (a);
1424 void Main::setupHelpActions()
1426 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1429 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1430 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1431 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1432 helpMenu->addAction (a);
1434 a = new QAction( tr( "About VYM","Help action" ), this);
1435 a->setStatusTip( tr( "About VYM")+vymName);
1436 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1437 helpMenu->addAction (a);
1439 a = new QAction( tr( "About QT","Help action" ), this);
1440 a->setStatusTip( tr( "Information about QT toolkit" ));
1441 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1442 helpMenu->addAction (a);
1446 void Main::setupContextMenus()
1450 // Context Menu for branch or mapcenter
1451 branchContextMenu =new QMenu (this);
1453 actionOpenPropertyDialog->addTo (branchContextMenu);
1454 branchContextMenu->addSeparator();
1457 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1458 branchAddContextMenu->addAction (actionEditPaste );
1459 branchAddContextMenu->addAction ( actionEditAddBranch );
1460 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1461 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1462 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1463 branchAddContextMenu->addSeparator();
1464 branchAddContextMenu->addAction ( actionEditImportAdd );
1465 branchAddContextMenu->addAction ( actionEditImportReplace );
1468 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1469 branchRemoveContextMenu->addAction (actionEditCut);
1470 branchRemoveContextMenu->addAction ( actionEditDelete );
1471 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1472 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1475 actionEditSaveBranch->addTo( branchContextMenu );
1477 branchContextMenu->addSeparator();
1478 branchContextMenu->addAction ( actionEditLoadImage);
1479 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1480 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1482 // Submenu for Links (URLs, vymLinks)
1483 branchLinksContextMenu =new QMenu (this);
1485 branchContextMenu->addSeparator();
1486 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1487 branchLinksContextMenu->addAction ( actionEditOpenURL );
1488 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1489 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1490 branchLinksContextMenu->addAction ( actionEditURL );
1491 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1492 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1493 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1495 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1497 branchLinksContextMenu->addSeparator();
1498 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1499 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1500 branchLinksContextMenu->addAction ( actionEditVymLink );
1501 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1504 // Context Menu for XLinks in a branch menu
1505 // This will be populated "on demand" in MapEditor::updateActions
1506 branchContextMenu->addSeparator();
1507 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1508 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1509 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1510 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1513 // Context menu for floatimage
1514 floatimageContextMenu =new QMenu (this);
1515 a= new QAction (tr ("Save image","Context action"),this);
1516 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1517 floatimageContextMenu->addAction (a);
1519 floatimageContextMenu->addSeparator();
1520 actionEditCopy->addTo( floatimageContextMenu );
1521 actionEditCut->addTo( floatimageContextMenu );
1523 floatimageContextMenu->addSeparator();
1524 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1527 // Context menu for canvas
1528 canvasContextMenu =new QMenu (this);
1529 actionEditMapInfo->addTo( canvasContextMenu );
1530 canvasContextMenu->insertSeparator();
1531 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1532 canvasContextMenu->insertSeparator();
1533 actionFormatLinkColorHint->addTo( canvasContextMenu );
1534 actionFormatLinkColor->addTo( canvasContextMenu );
1535 actionFormatBackColor->addTo( canvasContextMenu );
1536 actionFormatBackImage->addTo( canvasContextMenu );
1538 // Menu for last opened files
1540 for (int i = 0; i < MaxRecentFiles; ++i)
1542 recentFileActs[i] = new QAction(this);
1543 recentFileActs[i]->setVisible(false);
1544 fileLastMapsMenu->addAction(recentFileActs[i]);
1545 connect(recentFileActs[i], SIGNAL(triggered()),
1546 this, SLOT(fileLoadRecent()));
1548 setupRecentMapsMenu();
1551 void Main::setupRecentMapsMenu()
1553 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1555 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1557 for (int i = 0; i < numRecentFiles; ++i) {
1558 //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
1559 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1560 recentFileActs[i]->setText(text);
1561 recentFileActs[i]->setData(files[i]);
1562 recentFileActs[i]->setVisible(true);
1564 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1565 recentFileActs[j]->setVisible(false);
1568 void Main::hideEvent (QHideEvent * )
1570 if (!textEditor->isMinimized() ) textEditor->hide();
1573 void Main::showEvent (QShowEvent * )
1575 if (textEditor->showWithMain()) textEditor->showNormal();
1578 bool Main::reallyWriteDirectory(const QString &dir)
1580 QStringList eList = QDir(dir).entryList();
1581 if (eList.first() ==".") eList.pop_front(); // remove "."
1582 if (eList.first() =="..") eList.pop_front(); // remove "."
1583 if (!eList.isEmpty())
1585 QMessageBox mb( vymName,
1586 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1587 QMessageBox::Warning,
1589 QMessageBox::Cancel | QMessageBox::Default,
1590 QMessageBox::QMessageBox::NoButton );
1592 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1593 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1596 case QMessageBox::Yes:
1599 case QMessageBox::Cancel:
1607 QString Main::browseDirectory (const QString &caption)
1609 QFileDialog fd(this,caption);
1610 fd.setMode (QFileDialog::DirectoryOnly);
1611 fd.setCaption(vymName+ " - "+caption);
1612 fd.setDir (lastFileDir);
1615 if ( fd.exec() == QDialog::Accepted )
1616 return fd.selectedFile();
1621 MapEditor* Main::currentMapEditor() const
1623 if ( tabWidget->currentPage() &&
1624 tabWidget->currentPage()->inherits( "MapEditor" ) )
1625 return (MapEditor*)tabWidget->currentPage();
1630 void Main::editorChanged(QWidget *)
1632 // Unselect all possibly selected objects
1633 // (Important to update note editor)
1636 for (i=0;i<=tabWidget->count() -1;i++)
1639 me=(MapEditor*)tabWidget->page(i);
1642 currentMapEditor()->reselect();
1644 // Update actions to in menus and toolbars according to editor
1648 void Main::fileNew()
1650 QString fn="unnamed";
1651 MapEditor* me = new MapEditor ( NULL);
1652 tabWidget->addTab (me,fn);
1653 tabWidget->showPage(me);
1654 me->viewport()->setFocus();
1655 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1656 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1658 // For the very first map we do not have flagrows yet...
1662 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1664 ErrorCode err=success;
1666 // fn is usually the archive, mapfile the file after uncompressing
1669 // Make fn absolute (needed for unzip)
1670 fn=QDir (fn).absPath();
1676 // Check, if map is already loaded
1678 while (i<=tabWidget->count() -1)
1680 me=(MapEditor*)tabWidget->page(i);
1681 if (me->getFilePath() == fn)
1683 // Already there, ask for confirmation
1684 QMessageBox mb( vymName,
1685 tr("The map %1\nis already opened."
1686 "Opening the same map in multiple editors may lead \n"
1687 "to confusion when finishing working with vym."
1688 "Do you want to").arg(fn),
1689 QMessageBox::Warning,
1690 QMessageBox::Yes | QMessageBox::Default,
1691 QMessageBox::Cancel | QMessageBox::Escape,
1692 QMessageBox::NoButton);
1693 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1694 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1697 case QMessageBox::Yes:
1699 i=tabWidget->count();
1701 case QMessageBox::Cancel:
1713 if ( !fn.isEmpty() )
1715 me = currentMapEditor();
1716 int tabIndex=tabWidget->currentPageIndex();
1717 // Check first, if mapeditor exists
1718 // If it is not default AND we want a new map,
1719 // create a new mapeditor in a new tab
1720 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1722 me= new MapEditor ( NULL);
1723 tabWidget->addTab (me,fn);
1724 tabIndex=tabWidget->indexOf (me);
1725 tabWidget->setCurrentPage (tabIndex);
1726 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1727 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1730 // Check, if file exists (important for creating new files
1731 // from command line
1732 if (!QFile(fn).exists() )
1734 QMessageBox mb( vymName,
1735 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1736 QMessageBox::Question,
1738 QMessageBox::Cancel | QMessageBox::Default,
1739 QMessageBox::NoButton );
1741 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1742 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1745 case QMessageBox::Yes:
1747 currentMapEditor()->setFilePath(fn);
1748 tabWidget->setTabLabel (currentMapEditor(),
1749 currentMapEditor()->getFileName() );
1750 statusBar()->message( "Created " + fn , statusbarTime );
1753 case QMessageBox::Cancel:
1754 // don't create new map
1755 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1762 //tabWidget->currentPage() won't be NULL here, because of above...
1763 tabWidget->showPage(me);
1764 me->viewport()->setFocus();
1766 // Create temporary directory for packing
1768 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1771 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1772 tr("Couldn't create temporary directory before load\n"));
1776 // Try to unzip file
1777 err=unzipDir (tmpMapDir,fn);
1781 me->setZipped(false);
1784 me->setZipped(true);
1786 // Look for mapname.xml
1787 mapfile= fn.left(fn.findRev(".",-1,true));
1788 mapfile=mapfile.section( '/', -1 );
1789 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1790 if (!file.exists() )
1792 // mapname.xml does not exist, well,
1793 // maybe someone renamed the mapname.vym file...
1794 // Try to find any .xml in the toplevel
1795 // directory of the .vym file
1796 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1797 if (flist.count()==1)
1799 // Only one entry, take this one
1800 mapfile=tmpMapDir + "/"+flist.first();
1803 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1804 *it=tmpMapDir + "/" + *it;
1805 // TODO Multiple entries, load all (but only the first one into this ME)
1806 //mainWindow->fileLoadFromTmp (flist);
1807 //returnCode=1; // Silently forget this attempt to load
1808 qWarning ("MainWindow::load (fn) multimap found...");
1811 if (flist.isEmpty() )
1813 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1814 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1817 } //file doesn't exist
1819 mapfile=file.name();
1824 // Save existing filename in case we import
1825 QString fn_org=me->getFilePath();
1827 // Finally load map into mapEditor
1828 me->setFilePath (mapfile,fn);
1829 err=me->load(mapfile,lmode);
1831 // Restore old (maybe empty) filepath, if this is an import
1833 me->setFilePath (fn_org);
1836 // Finally check for errors and go home
1839 if (lmode==NewMap) fileCloseMap();
1840 statusBar()->message( "Could not load " + fn, statusbarTime );
1845 me->setFilePath (fn);
1846 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1847 if (fn.left(9)!="/tmp/vym-")
1849 // Only append to lastMaps if not loaded from a tmpDir
1850 // e.g. imported bookmarks are in a tmpDir
1851 addRecentMap(me->getFilePath() );
1853 actionFilePrint->setEnabled (true);
1855 statusBar()->message( "Loaded " + fn, statusbarTime );
1859 removeDir (QDir(tmpMapDir));
1865 void Main::fileLoad(const LoadMode &lmode)
1867 QStringList filters;
1868 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1869 QFileDialog *fd=new QFileDialog( this);
1870 fd->setDir (lastFileDir);
1871 fd->setFileMode (QFileDialog::ExistingFiles);
1872 fd->setFilters (filters);
1876 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1879 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1882 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1888 if ( fd->exec() == QDialog::Accepted )
1890 lastFileDir=fd->directory().path();
1891 QStringList flist = fd->selectedFiles();
1892 QStringList::Iterator it = flist.begin();
1893 while( it != flist.end() )
1896 fileLoad(*it, lmode);
1903 void Main::fileLoad()
1908 void Main::fileLoadRecent()
1910 QAction *action = qobject_cast<QAction *>(sender());
1912 fileLoad (action->data().toString(), NewMap);
1915 void Main::addRecentMap (const QString &fileName)
1918 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1919 files.removeAll(fileName);
1920 files.prepend(fileName);
1921 while (files.size() > MaxRecentFiles)
1924 settings.setValue("/mainwindow/recentFileList", files);
1926 setupRecentMapsMenu();
1929 void Main::fileSave(const SaveMode &savemode)
1931 // tmp dir for zipping
1935 ErrorCode err=success;
1937 QString safeFilePath;
1939 bool saveZipped=currentMapEditor()->saveZipped();
1941 MapEditor * me=currentMapEditor();
1944 QString fn=me->getFilePath();
1945 // filename=unnamed, filepath="" in constructor...
1946 if ( !fn.isEmpty() )
1948 // We have a filepath, go on saving
1949 // First remove existing file, we
1950 // don't want to add to old zip archives
1954 QMessageBox::warning( 0, tr( "Save Error" ),
1955 fn+ tr("\ncould not be removed before saving"));
1957 // Look, if we should zip the data:
1960 QMessageBox mb( vymName,
1961 tr("The map %1\ndid not use the compressed "
1962 "vym file format.\nWriting it uncompressed will also write images \n"
1963 "and flags and thus may overwrite files in the "
1964 "given directory\n\nDo you want to write the map").arg(fn),
1965 QMessageBox::Warning,
1966 QMessageBox::Yes | QMessageBox::Default,
1968 QMessageBox::Cancel | QMessageBox::Escape);
1969 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1970 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1971 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1974 case QMessageBox::Yes:
1975 // save compressed (default file format)
1978 case QMessageBox::No:
1979 // save uncompressed
1982 case QMessageBox::Cancel:
1991 // Create temporary directory for packing
1993 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1996 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1997 tr("Couldn't create temporary directory before save\n"));
2001 safeFilePath=me->getFilePath();
2002 me->setFilePath (tmpMapDir+"/"+
2003 me->getMapName()+ ".xml",
2005 me->save (savemode);
2006 me->setFilePath (safeFilePath);
2008 zipDir (tmpMapDir,fn);
2013 safeFilePath=me->getFilePath();
2014 me->setFilePath (fn, safeFilePath);
2015 me->save (savemode);
2016 me->setFilePath (safeFilePath);
2018 } // filepath available
2021 // We have no filepath yet,
2022 // call fileSaveAs() now, this will call fileSave()
2024 fileSaveAs(savemode);
2028 if (saveZipped && !tmpMapDir.isEmpty())
2030 removeDir (QDir(tmpMapDir));
2034 statusBar()->message(
2035 tr("Saved %1").arg(me->getFilePath()),
2037 addRecentMap (me->getFilePath() );
2039 statusBar()->message(
2040 tr("Couldn't save ").arg(me->getFilePath()),
2044 void Main::fileSave()
2046 fileSave (CompleteMap);
2049 void Main::fileSaveAs(const SaveMode& savemode)
2053 if (currentMapEditor())
2055 if (savemode==CompleteMap)
2056 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2058 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2059 if ( !fn.isEmpty() )
2061 // Check for existing file
2062 if (QFile (fn).exists())
2064 QMessageBox mb( vymName,
2065 tr("The file %1\nexists already. Do you want to").arg(fn),
2066 QMessageBox::Warning,
2067 QMessageBox::Yes | QMessageBox::Default,
2068 QMessageBox::Cancel | QMessageBox::Escape,
2069 QMessageBox::NoButton);
2070 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2071 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2074 case QMessageBox::Yes:
2077 case QMessageBox::Cancel:
2084 // New file, add extension to filename, if missing
2085 // This is always .vym or .vyp, depending on savemode
2086 if (savemode==CompleteMap)
2088 if (!fn.contains (".vym") && !fn.contains (".xml"))
2092 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2101 currentMapEditor()->setFilePath(fn);
2105 if (savemode==CompleteMap)
2106 tabWidget->setTabLabel (currentMapEditor(),
2107 currentMapEditor()->getFileName() );
2113 void Main::fileSaveAs()
2115 fileSaveAs (CompleteMap);
2118 void Main::fileImportKDEBookmarks()
2120 ImportKDEBookmarks im;
2122 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2123 currentMapEditor()->setFilePath ("");
2126 void Main::fileImportFirefoxBookmarks()
2128 Q3FileDialog *fd=new Q3FileDialog( this);
2129 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2130 fd->setMode (Q3FileDialog::ExistingFiles);
2131 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2132 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2135 if ( fd->exec() == QDialog::Accepted )
2137 ImportFirefoxBookmarks im;
2138 QStringList flist = fd->selectedFiles();
2139 QStringList::Iterator it = flist.begin();
2140 while( it != flist.end() )
2143 if (im.transform() &&
2144 success==fileLoad (im.getTransformedFile(),NewMap) &&
2145 currentMapEditor() )
2146 currentMapEditor()->setFilePath ("");
2153 void Main::fileImportMM()
2157 Q3FileDialog *fd=new Q3FileDialog( this);
2158 fd->setDir (lastFileDir);
2159 fd->setMode (Q3FileDialog::ExistingFiles);
2160 fd->addFilter ("Mind Manager (*.mmap)");
2161 fd->setCaption(tr("Import")+" "+"Mind Manager");
2164 if ( fd->exec() == QDialog::Accepted )
2166 lastFileDir=fd->dirPath();
2167 QStringList flist = fd->selectedFiles();
2168 QStringList::Iterator it = flist.begin();
2169 while( it != flist.end() )
2172 if (im.transform() &&
2173 success==fileLoad (im.getTransformedFile(),NewMap) &&
2174 currentMapEditor() )
2175 currentMapEditor()->setFilePath ("");
2184 void Main::fileImportDir()
2186 if (currentMapEditor())
2187 currentMapEditor()->importDir();
2190 void Main::fileExportXML()
2192 if (currentMapEditor())
2194 QString dir=browseDirectory(tr("Export XML to directory"));
2195 if (dir !="" && reallyWriteDirectory(dir) )
2196 currentMapEditor()->exportXML(dir);
2201 void Main::fileExportXHTML()
2203 MapEditor *me=currentMapEditor();
2207 ExportXHTMLDialog dia(this);
2208 dia.setFilePath (me->getFilePath() );
2209 dia.setMapName (me->getMapName() );
2212 if (dia.exec()==QDialog::Accepted)
2214 QString dir=dia.getDir();
2215 // Check, if warnings should be used before overwriting
2216 // the output directory
2219 ok=reallyWriteDirectory(dir);
2225 me->exportXML (dia.getDir() );
2226 dia.doExport(me->getMapName() );
2227 if (dia.hasChanged())
2234 void Main::fileExportImage()
2236 MapEditor *me=currentMapEditor();
2240 QFileDialog *fd=new QFileDialog (this);
2241 fd->setCaption (tr("Export map as image"));
2242 fd->setFileMode(QFileDialog::AnyFile);
2243 fd->setFilters (imageIO.getFilters() );
2244 fd->setDirectory (lastImageDir);
2247 fl=fd->selectedFiles();
2248 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2249 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2254 void Main::fileExportASCII()
2256 MapEditor *me=currentMapEditor();
2260 ex.setMapCenter(me->getMapCenter());
2261 ex.addFilter ("TXT (*.txt)");
2262 ex.setDir(lastImageDir);
2263 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2264 if (ex.execDialog() )
2266 me->setExportMode(true);
2268 me->setExportMode(false);
2273 void Main::fileExportLaTeX()
2275 MapEditor *me=currentMapEditor();
2279 ex.setMapCenter(me->getMapCenter());
2280 ex.addFilter ("Tex (*.tex)");
2281 ex.setDir(lastImageDir);
2282 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2283 if (ex.execDialog() )
2285 me->setExportMode(true);
2287 me->setExportMode(false);
2292 void Main::fileExportKDEBookmarks()
2294 ExportKDEBookmarks ex;
2295 MapEditor *me=currentMapEditor();
2298 ex.setMapCenter (me->getMapCenter() );
2303 void Main::fileExportTaskjuggler()
2305 ExportTaskjuggler ex;
2306 MapEditor *me=currentMapEditor();
2309 ex.setMapCenter (me->getMapCenter() );
2310 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2311 ex.setDir(lastImageDir);
2312 ex.addFilter ("Taskjuggler (*.tjp)");
2313 if (ex.execDialog() )
2315 me->setExportMode(true);
2317 me->setExportMode(false);
2322 void Main::fileExportOOPresentation()
2324 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2325 // TODO add preview in dialog
2326 //ImagePreview *p =new ImagePreview (fd);
2327 //fd->setContentsPreviewEnabled( TRUE );
2328 //fd->setContentsPreview( p, p );
2329 //fd->setPreviewMode( QFileDialog::Contents );
2330 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2331 fd->setDir (QDir().current());
2332 if (fd->foundConfig())
2336 if ( fd->exec() == QDialog::Accepted )
2338 QString fn=fd->selectedFile();
2339 if (!fn.contains (".odp"))
2342 //lastImageDir=fn.left(fn.findRev ("/"));
2343 if (currentMapEditor())
2344 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2348 QMessageBox::warning(0,
2350 tr("Couldn't find configuration for export to Open Office\n"));
2354 void Main::fileCloseMap()
2356 if (currentMapEditor())
2358 if (currentMapEditor()->hasChanged())
2360 QMessageBox mb( vymName,
2361 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2362 QMessageBox::Warning,
2363 QMessageBox::Yes | QMessageBox::Default,
2365 QMessageBox::Cancel | QMessageBox::Escape );
2366 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2367 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2370 case QMessageBox::Yes:
2372 fileSave(CompleteMap);
2374 case QMessageBox::No:
2375 // close without saving
2377 case QMessageBox::Cancel:
2382 currentMapEditor()->closeMap();
2383 tabWidget->removePage(currentMapEditor());
2384 if (tabWidget->count()==0)
2385 actionFilePrint->setEnabled (false);
2389 void Main::filePrint()
2391 if (currentMapEditor())
2392 currentMapEditor()->print();
2395 void Main::fileExitVYM()
2397 // Check if one or more editors have changed
2400 for (i=0;i<=tabWidget->count() -1;i++)
2403 me=(MapEditor*)tabWidget->page(i);
2405 // If something changed, ask what to do
2406 if (me->isUnsaved())
2408 tabWidget->setCurrentPage(i);
2409 QMessageBox mb( vymName,
2410 tr("This map is not saved yet. Do you want to"),
2411 QMessageBox::Warning,
2412 QMessageBox::Yes | QMessageBox::Default,
2414 QMessageBox::Cancel | QMessageBox::Escape );
2415 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2416 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2419 mb.setActiveWindow();
2420 switch( mb.exec() ) {
2421 case QMessageBox::Yes:
2422 // save (the changed editors) and exit
2423 fileSave(CompleteMap);
2425 case QMessageBox::No:
2426 // exit without saving
2428 case QMessageBox::Cancel:
2429 // don't save and don't exit
2433 } // loop over all MEs
2437 void Main::editUndo()
2439 if (currentMapEditor())
2440 currentMapEditor()->undo();
2443 void Main::editRedo()
2445 if (currentMapEditor())
2446 currentMapEditor()->redo();
2449 void Main::gotoHistoryStep (int i)
2451 if (currentMapEditor())
2452 currentMapEditor()->gotoHistoryStep (i);
2455 void Main::editCopy()
2457 if (currentMapEditor())
2458 currentMapEditor()->copy();
2461 void Main::editPaste()
2463 if (currentMapEditor())
2464 currentMapEditor()->paste();
2467 void Main::editCut()
2469 if (currentMapEditor())
2470 currentMapEditor()->cut();
2473 void Main::editOpenFindWindow()
2475 findWindow->popup();
2476 findWindow->raise();
2477 findWindow->setActiveWindow();
2480 void Main::editFind(QString s)
2483 BranchObj *bo=currentMapEditor()->findText(s, cs);
2486 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2489 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2490 tr("No matches found for \"%1\"").arg(s));
2494 void Main::editFindChanged()
2495 { // Notify editor, to abort the current find process
2496 currentMapEditor()->findReset();
2499 void Main::openTabs(QStringList urls)
2501 if (!urls.isEmpty())
2505 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2507 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2509 QString u=urls.takeFirst();
2510 procBrowser = new QProcess( this );
2512 procBrowser->start(browser,args);
2513 if ( !procBrowser->waitForStarted())
2515 // try to set path to browser
2516 QMessageBox::warning(0,
2518 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2519 tr("Please use Settings->")+tr("Set application to open an URL"));
2524 if (browser.contains("konqueror"))
2526 for (int i=0; i<urls.size(); i++)
2529 // Try to open new tab in existing konqueror started previously by vym
2530 p=new QProcess (this);
2532 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2533 "konqueror-mainwindow#1"<<
2536 p->start ("dcop",args);
2537 if ( !p->waitForStarted() ) success=false;
2540 QMessageBox::warning(0,
2542 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2544 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2546 for (int i=0; i<urls.size(); i++)
2548 // Try to open new tab in firefox
2549 p=new QProcess (this);
2550 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2551 p->start (browser,args);
2552 if ( !p->waitForStarted() ) success=false;
2555 QMessageBox::warning(0,
2557 tr("Couldn't start %1 to open a new tab").arg(browser));
2560 QMessageBox::warning(0,
2562 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2566 void Main::editOpenURL()
2569 if (currentMapEditor())
2571 QString url=currentMapEditor()->getURL();
2573 if (url=="") return;
2574 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2575 procBrowser = new QProcess( this );
2577 procBrowser->start(browser,args);
2578 if ( !procBrowser->waitForStarted())
2580 // try to set path to browser
2581 QMessageBox::warning(0,
2583 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2584 tr("Please use Settings->")+tr("Set application to open an URL"));
2589 void Main::editOpenURLTab()
2591 if (currentMapEditor())
2594 urls.append(currentMapEditor()->getURL());
2598 void Main::editOpenMultipleURLTabs()
2600 if (currentMapEditor())
2603 urls=currentMapEditor()->getURLs();
2609 void Main::editURL()
2611 if (currentMapEditor())
2612 currentMapEditor()->editURL();
2615 void Main::editHeading2URL()
2617 if (currentMapEditor())
2618 currentMapEditor()->editHeading2URL();
2621 void Main::editBugzilla2URL()
2623 if (currentMapEditor())
2624 currentMapEditor()->editBugzilla2URL();
2627 void Main::editFATE2URL()
2629 if (currentMapEditor())
2630 currentMapEditor()->editFATE2URL();
2633 void Main::editHeadingFinished()
2635 // only called from editHeading(), so there is a currentME
2636 MapEditor *me=currentMapEditor();
2639 QPoint p; //Not used here, only to find out pos of branch
2641 QString s=me->getHeading(ok,p);
2643 #if defined(Q_OS_MACX)
2645 if (ok && s!=lineedit->text())
2646 me->setHeading(lineedit->text());
2648 lineedit->releaseKeyboard();
2652 if (!prevSelection.isEmpty()) me->select(prevSelection);
2657 void Main::editHeading()
2659 if (currentMapEditor())
2661 MapEditor *me=currentMapEditor();
2662 QString oldSel=me->getSelectString();
2664 if (lineedit->isVisible())
2665 editHeadingFinished();
2670 QString s=currentMapEditor()->getHeading(ok,p);
2674 #if defined(Q_OS_MACX)
2675 p=currentMapEditor()->mapTo (this,p);
2676 QDialog *d =new QDialog(NULL);
2677 QLineEdit *le=new QLineEdit (d);
2678 d->setWindowFlags (Qt::FramelessWindowHint);
2679 d->setGeometry(p.x(),p.y(),230,25);
2680 le->resize (d->width()-10,d->height());
2683 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2684 d->activateWindow();
2686 currentMapEditor()->setHeading (le->text());
2689 editHeadingFinished();
2691 p=currentMapEditor()->mapTo (this,p);
2692 lineedit->setGeometry(p.x(),p.y(),230,25);
2693 lineedit->setText(s);
2694 lineedit->setCursorPosition(1);
2695 lineedit->selectAll();
2697 lineedit->grabKeyboard();
2698 lineedit->setFocus();
2702 } // currentMapEditor()
2705 void Main::openVymLinks(const QStringList &vl)
2707 for (int j=0; j<vl.size(); j++)
2709 // compare path with already loaded maps
2713 for (i=0;i<=tabWidget->count() -1;i++)
2715 me=(MapEditor*)tabWidget->page(i);
2716 if (vl.at(j)==me->getFilePath() )
2725 if (!QFile(vl.at(j)).exists() )
2726 QMessageBox::critical( 0, tr( "Critical Error" ),
2727 tr("Couldn't open map %1").arg(vl.at(j)));
2730 fileLoad (vl.at(j), NewMap);
2731 tabWidget->setCurrentPage (tabWidget->count()-1);
2734 // Go to tab containing the map
2735 tabWidget->setCurrentPage (index);
2739 void Main::editOpenVymLink()
2741 if (currentMapEditor())
2744 vl.append(currentMapEditor()->getVymLink());
2749 void Main::editOpenMultipleVymLinks()
2751 QString currentVymLink;
2752 if (currentMapEditor())
2754 QStringList vl=currentMapEditor()->getVymLinks();
2759 void Main::editVymLink()
2761 if (currentMapEditor())
2762 currentMapEditor()->editVymLink();
2765 void Main::editDeleteVymLink()
2767 if (currentMapEditor())
2768 currentMapEditor()->deleteVymLink();
2771 void Main::editToggleHideExport()
2773 if (currentMapEditor())
2774 currentMapEditor()->toggleHideExport();
2777 void Main::editMapInfo()
2779 if (currentMapEditor())
2780 currentMapEditor()->editMapInfo();
2783 void Main::editMoveUp()
2785 if (currentMapEditor())
2786 currentMapEditor()->moveBranchUp();
2789 void Main::editMoveDown()
2791 if (currentMapEditor())
2792 currentMapEditor()->moveBranchDown();
2795 void Main::editToggleScroll()
2797 if (currentMapEditor())
2799 currentMapEditor()->toggleScroll();
2803 void Main::editUnScrollAll()
2805 if (currentMapEditor())
2806 currentMapEditor()->unscrollChilds();
2809 void Main::editNewBranch()
2811 MapEditor *me=currentMapEditor();
2812 if (!lineedit->isVisible() && me)
2814 BranchObj *bo=(BranchObj*)me->getSelection();
2815 BranchObj *newbo=me->addNewBranch(0);
2818 me->select (newbo->getSelectString());
2822 if (actionSettingsAutoEdit->isOn())
2824 if (!actionSettingsAutoSelectHeading->isOn())
2825 prevSelection=bo->getSelectString();
2831 void Main::editNewBranchBefore()
2833 MapEditor *me=currentMapEditor();
2834 if (!lineedit->isVisible() && me)
2836 BranchObj *bo=(BranchObj*)me->getSelection();
2837 BranchObj *newbo=me->addNewBranchBefore();
2840 me->select (newbo->getSelectString());
2844 if (actionSettingsAutoEdit->isOn())
2846 if (!actionSettingsAutoSelectHeading->isOn())
2847 prevSelection=bo->getSelectString();
2853 void Main::editNewBranchAbove()
2855 MapEditor *me=currentMapEditor();
2856 if (!lineedit->isVisible() && me)
2858 BranchObj *bo=(BranchObj*)me->getSelection();
2859 BranchObj *newbo=me->addNewBranch (-1);
2862 me->select (newbo->getSelectString());
2866 if (actionSettingsAutoEdit->isOn())
2868 if (!actionSettingsAutoSelectHeading->isOn())
2869 prevSelection=bo->getSelectString();
2875 void Main::editNewBranchBelow()
2877 MapEditor *me=currentMapEditor();
2878 if (!lineedit->isVisible() && me)
2880 BranchObj *bo=(BranchObj*)me->getSelection();
2881 BranchObj *newbo=me->addNewBranch (1);
2884 me->select (newbo->getSelectString());
2888 if (actionSettingsAutoEdit->isOn())
2890 if (!actionSettingsAutoSelectHeading->isOn())
2891 prevSelection=bo->getSelectString();
2897 void Main::editImportAdd()
2899 fileLoad (ImportAdd);
2902 void Main::editImportReplace()
2904 fileLoad (ImportReplace);
2907 void Main::editSaveBranch()
2909 fileSaveAs (PartOfMap);
2912 void Main::editDeleteKeepChilds()
2914 if (currentMapEditor())
2915 currentMapEditor()->deleteKeepChilds();
2918 void Main::editDeleteChilds()
2920 if (currentMapEditor())
2921 currentMapEditor()->deleteChilds();
2924 void Main::editDeleteSelection()
2926 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2927 currentMapEditor()->deleteSelection();
2930 void Main::editUpperBranch()
2932 if (currentMapEditor())
2933 currentMapEditor()->selectUpperBranch();
2936 void Main::editLowerBranch()
2938 if (currentMapEditor())
2939 currentMapEditor()->selectLowerBranch();
2942 void Main::editLeftBranch()
2944 if (currentMapEditor())
2945 currentMapEditor()->selectLeftBranch();
2948 void Main::editRightBranch()
2950 if (currentMapEditor())
2951 currentMapEditor()->selectRightBranch();
2954 void Main::editFirstBranch()
2956 if (currentMapEditor())
2957 currentMapEditor()->selectFirstBranch();
2960 void Main::editLastBranch()
2962 if (currentMapEditor())
2963 currentMapEditor()->selectLastBranch();
2966 void Main::editLoadImage()
2968 if (currentMapEditor())
2969 currentMapEditor()->loadFloatImage();
2972 void Main::editSaveImage()
2974 if (currentMapEditor())
2975 currentMapEditor()->saveFloatImage();
2978 void Main::editFollowXLink(QAction *a)
2981 if (currentMapEditor())
2982 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2985 void Main::editEditXLink(QAction *a)
2987 if (currentMapEditor())
2988 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2991 void Main::formatSelectColor()
2993 if (currentMapEditor())
2995 QColor col = QColorDialog::getColor((currentColor ), this );
2996 if ( !col.isValid() ) return;
2997 colorChanged( col );
3001 void Main::formatPickColor()
3003 if (currentMapEditor())
3004 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3007 void Main::colorChanged(QColor c)
3009 QPixmap pix( 16, 16 );
3011 actionFormatColor->setIconSet( pix );
3015 void Main::formatColorBranch()
3017 if (currentMapEditor())
3018 currentMapEditor()->colorBranch(currentColor);
3021 void Main::formatColorSubtree()
3023 if (currentMapEditor())
3024 currentMapEditor()->colorSubtree (currentColor);
3027 void Main::formatLinkStyleLine()
3029 if (currentMapEditor())
3030 currentMapEditor()->setMapLinkStyle("StyleLine");
3033 void Main::formatLinkStyleParabel()
3035 if (currentMapEditor())
3036 currentMapEditor()->setMapLinkStyle("StyleParabel");
3039 void Main::formatLinkStylePolyLine()
3041 if (currentMapEditor())
3042 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3045 void Main::formatLinkStylePolyParabel()
3047 if (currentMapEditor())
3048 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3051 void Main::formatSelectBackColor()
3053 if (currentMapEditor())
3054 currentMapEditor()->selectMapBackgroundColor();
3057 void Main::formatSelectBackImage()
3059 if (currentMapEditor())
3060 currentMapEditor()->selectMapBackgroundImage();
3063 void Main::formatSelectLinkColor()
3065 if (currentMapEditor())
3066 currentMapEditor()->selectMapLinkColor();
3069 void Main::formatToggleLinkColorHint()
3071 currentMapEditor()->toggleMapLinkColorHint();
3075 void Main::formatIncludeImagesVer()
3077 if (currentMapEditor())
3078 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3081 void Main::formatIncludeImagesHor()
3083 if (currentMapEditor())
3084 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3087 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3089 if (currentMapEditor())
3090 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3093 void Main::viewZoomReset()
3095 if (currentMapEditor())
3099 currentMapEditor()->setMatrix( m );
3103 void Main::viewZoomIn()
3105 if (currentMapEditor())
3107 QMatrix m = currentMapEditor()->matrix();
3108 m.scale( 1.25, 1.25 );
3109 currentMapEditor()->setMatrix( m );
3113 void Main::viewZoomOut()
3115 if (currentMapEditor())
3117 QMatrix m = currentMapEditor()->matrix();
3118 m.scale( 0.8, 0.8 );
3119 currentMapEditor()->setMatrix( m );
3123 bool Main::settingsPDF()
3125 // Default browser is set in constructor
3127 QString text = QInputDialog::getText(
3128 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3129 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3131 settings.setValue ("/mainwindow/readerPDF",text);
3136 bool Main::settingsURL()
3138 // Default browser is set in constructor
3140 QString text = QInputDialog::getText(
3141 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3142 settings.value("/mainwindow/readerURL").toString()
3145 settings.setValue ("/mainwindow/readerURL",text);
3149 void Main::settingsToggleDelKey()
3151 if (actionSettingsUseDelKey->isOn())
3153 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3156 actionEditDelete->setAccel (QKeySequence (""));
3160 void Main::windowToggleNoteEditor()
3162 if (textEditor->showWithMain() )
3163 windowHideNoteEditor();
3165 windowShowNoteEditor();
3168 void Main::windowToggleHistory()
3170 if (historyWindow->isVisible())
3171 historyWindow->hide();
3173 historyWindow->show();
3177 void Main::windowToggleAntiAlias()
3179 bool b=actionViewToggleAntiAlias->isOn();
3181 for (int i=0;i<tabWidget->count();i++)
3184 me=(MapEditor*)tabWidget->page(i);
3185 me->setAntiAlias(b);
3190 void Main::windowToggleSmoothPixmap()
3192 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3194 for (int i=0;i<tabWidget->count();i++)
3197 me=(MapEditor*)tabWidget->page(i);
3198 me->setSmoothPixmap(b);
3202 void Main::updateHistory(SimpleSettings &undoSet)
3204 historyWindow->update (undoSet);
3207 void Main::updateNoteFlag()
3209 if (currentMapEditor())
3210 currentMapEditor()->updateNoteFlag();
3213 void Main::updateActions()
3215 MapEditor *me=currentMapEditor();
3218 historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
3220 // updateActions is also called when NoteEditor is closed
3221 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3223 if (me->getMapLinkColorHint()==HeadingColor)
3224 actionFormatLinkColorHint->setOn(true);
3226 actionFormatLinkColorHint->setOn(false);
3228 switch (me->getMapLinkStyle())
3231 actionFormatLinkStyleLine->setOn(true);
3234 actionFormatLinkStyleParabel->setOn(true);
3237 actionFormatLinkStylePolyLine->setOn(true);
3239 case StylePolyParabel:
3240 actionFormatLinkStylePolyParabel->setOn(true);
3246 QPixmap pix( 16, 16 );
3247 pix.fill( me->getMapBackgroundColor() );
3248 actionFormatBackColor->setIconSet( pix );
3249 pix.fill( me->getMapDefLinkColor() );
3250 actionFormatLinkColor->setIconSet( pix );
3252 actionFileSave->setEnabled( me->isUnsaved() );
3253 if (me->isUndoAvailable())
3254 actionEditUndo->setEnabled( true);
3256 actionEditUndo->setEnabled( false);
3258 if (me->isRedoAvailable())
3259 actionEditRedo->setEnabled( true);
3261 actionEditRedo->setEnabled( false);
3263 LinkableMapObj *selection=me->getSelection();
3266 if ( (typeid(*selection) == typeid(BranchObj)) ||
3267 (typeid(*selection) == typeid(MapCenterObj)) )
3269 BranchObj *bo=(BranchObj*)selection;
3270 // Take care of links
3271 if (bo->countXLinks()==0)
3273 branchXLinksContextMenuEdit->clear();
3274 branchXLinksContextMenuFollow->clear();
3279 branchXLinksContextMenuEdit->clear();
3280 branchXLinksContextMenuFollow->clear();
3281 for (int i=0; i<=bo->countXLinks();i++)
3283 bot=bo->XLinkTargetAt(i);
3286 s=bot->getHeading();
3289 branchXLinksContextMenuFollow->addAction (s);
3290 branchXLinksContextMenuEdit->addAction (s);
3295 standardFlagsDefault->setEnabled (true);
3297 actionEditToggleScroll->setEnabled (true);
3298 if ( bo->isScrolled() )
3299 actionEditToggleScroll->setOn(true);
3301 actionEditToggleScroll->setOn(false);
3303 if ( bo->getURL().isEmpty() )
3305 actionEditOpenURL->setEnabled (false);
3306 actionEditOpenURLTab->setEnabled (false);
3310 actionEditOpenURL->setEnabled (true);
3311 actionEditOpenURLTab->setEnabled (true);
3313 if ( bo->getVymLink().isEmpty() )
3315 actionEditOpenVymLink->setEnabled (false);
3316 actionEditDeleteVymLink->setEnabled (false);
3319 actionEditOpenVymLink->setEnabled (true);
3320 actionEditDeleteVymLink->setEnabled (true);
3323 if (bo->canMoveBranchUp())
3324 actionEditMoveUp->setEnabled (true);
3326 actionEditMoveUp->setEnabled (false);
3327 if (bo->canMoveBranchDown())
3328 actionEditMoveDown->setEnabled (true);
3330 actionEditMoveDown->setEnabled (false);
3333 actionEditToggleHideExport->setEnabled (true);
3334 actionEditToggleHideExport->setOn (bo->hideInExport() );
3336 actionEditCopy->setEnabled (true);
3337 actionEditCut->setEnabled (true);
3338 if (!clipboardEmpty)
3339 actionEditPaste->setEnabled (true);
3341 actionEditPaste->setEnabled (false);
3342 for (int i=0; i<actionListBranches.size(); ++i)
3343 actionListBranches.at(i)->setEnabled(true);
3344 actionEditDelete->setEnabled (true);
3345 actionFormatIncludeImagesVer->setOn
3346 ( ((BranchObj*)selection)->getIncludeImagesVer());
3347 actionFormatIncludeImagesHor->setOn
3348 ( ((BranchObj*)selection)->getIncludeImagesHor());
3349 actionFormatHideLinkUnselected->setOn
3350 (selection->getHideLinkUnselected());
3352 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3354 FloatObj *fo=(FloatImageObj*)selection;
3356 actionEditOpenURL->setEnabled (false);
3357 actionEditOpenVymLink->setEnabled (false);
3358 actionEditDeleteVymLink->setEnabled (false);
3359 actionEditToggleHideExport->setEnabled (true);
3360 actionEditToggleHideExport->setOn (fo->hideInExport() );
3363 actionEditCopy->setEnabled (true);
3364 actionEditCut->setEnabled (true);
3365 actionEditPaste->setEnabled (false);
3366 for (int i=0; i<actionListBranches.size(); ++i)
3367 actionListBranches.at(i)->setEnabled(false);
3368 actionEditDelete->setEnabled (true);
3369 actionFormatHideLinkUnselected->setOn
3370 ( selection->getHideLinkUnselected());
3371 actionEditMoveUp->setEnabled (false);
3372 actionEditMoveDown->setEnabled (false);
3377 actionEditCopy->setEnabled (false);
3378 actionEditCut->setEnabled (false);
3379 actionEditPaste->setEnabled (false);
3380 for (int i=0; i<actionListBranches.size(); ++i)
3381 actionListBranches.at(i)->setEnabled(false);
3383 actionEditToggleScroll->setEnabled (false);
3384 actionEditOpenURL->setEnabled (false);
3385 actionEditOpenVymLink->setEnabled (false);
3386 actionEditDeleteVymLink->setEnabled (false);
3387 actionEditHeading2URL->setEnabled (false);
3388 actionEditDelete->setEnabled (false);
3389 actionEditMoveUp->setEnabled (false);
3390 actionEditMoveDown->setEnabled (false);
3391 actionEditToggleHideExport->setEnabled (false);
3395 ModMode Main::getModMode()
3397 if (actionModModeColor->isOn()) return ModModeColor;
3398 if (actionModModeCopy->isOn()) return ModModeCopy;
3399 if (actionModModeXLink->isOn()) return ModModeXLink;
3403 bool Main::autoEdit()
3405 return actionSettingsAutoEdit->isOn();
3408 bool Main::autoSelectHeading()
3410 return actionSettingsAutoSelectHeading->isOn();
3413 bool Main::useFlagGroups()
3415 return actionSettingsUseFlagGroups->isOn();
3418 void Main::windowShowNoteEditor()
3420 textEditor->setShowWithMain(true);
3422 actionViewToggleNoteEditor->setOn (true);
3425 void Main::windowHideNoteEditor()
3427 textEditor->setShowWithMain(false);
3429 actionViewToggleNoteEditor->setOn (false);
3432 void Main::setScript (const QString &script)
3434 scriptEditor->setScript (script);
3437 void Main::runScript (const QString &script)
3439 if (currentMapEditor())
3440 currentMapEditor()->runScript (script);
3443 void Main::showPropertyDialog()
3445 if(currentMapEditor())
3447 LinkableMapObj *sel=currentMapEditor()->getSelection();
3448 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3449 typeid(*sel) == typeid(MapCenterObj)))
3451 branchPropertyWindow->show();
3452 branchPropertyWindow->setMapEditor(currentMapEditor());
3453 branchPropertyWindow->setBranch((BranchObj*)sel);
3458 branchPropertyWindow->setBranch(NULL);
3461 void Main::windowNextEditor()
3463 if (tabWidget->currentPageIndex() < tabWidget->count())
3464 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3467 void Main::windowPreviousEditor()
3469 if (tabWidget->currentPageIndex() >0)
3470 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3473 void Main::standardFlagChanged()
3475 if (currentMapEditor())
3476 currentMapEditor()->toggleStandardFlag(sender()->name());
3479 void Main::testFunction()
3481 if (!currentMapEditor()) return;
3482 currentMapEditor()->testFunction();
3485 void Main::testCommand()
3487 if (!currentMapEditor()) return;
3488 scriptEditor->show();
3491 QString com = QInputDialog::getText(
3492 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3493 if (ok) currentMapEditor()->parseAtom(com);
3497 void Main::helpDoc()
3499 QString locale = QLocale::system().name();
3501 if (locale.left(2)=="es")
3502 docname="vym_es.pdf";
3506 QStringList searchList;
3508 #if defined(Q_OS_MACX)
3509 searchList << "./vym.app/Contents";
3511 // default path in SUSE LINUX
3512 searchList <<"/usr/share/doc/packages/vym/doc";
3515 searchList << "doc"; // relative path for easy testing in tarball
3516 searchList << "doc/tex"; // Easy testing working on vym.tex
3517 searchList << "/usr/share/doc/vym"; // Debian
3518 searchList << "/usr/share/doc/packages";// Knoppix
3522 for (int i=0; i<searchList.count(); ++i)
3524 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3525 if (docfile.exists() )
3534 QMessageBox::critical(0,
3535 tr("Critcal error"),
3536 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3541 Process *pdfProc = new Process();
3542 args <<docfile.fileName();
3544 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3545 if ( !pdfProc->waitForStarted() )
3548 QMessageBox::warning(0,
3550 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3551 tr("Please use Settings->")+tr("Set application to open PDF files"));
3558 void Main::helpAbout()
3561 ad.setName ("aboutwindow");
3562 ad.setMinimumSize(500,500);
3563 ad.resize (QSize (500,500));
3567 void Main::helpAboutQT()
3569 QMessageBox::aboutQt( this, "Qt Application Example" );