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 some settings, which are platform dependant
104 // application to open URLs
105 p="/mainwindow/readerURL";
106 #if defined(Q_OS_LINUX)
107 s=settings.value (p,"konqueror").toString();
109 #if defined(Q_OS_MACX)
110 s=settings.value (p,"/usr/bin/open").toString();
112 s=settings.value (p,"mozilla");
115 settings.setValue( p,s);
117 // application to open PDFs
118 p="/mainwindow/readerPDF";
119 #if defined(Q_OS_LINUX)
120 s=settings.value (p,"acroread").toString();
122 #if defined(Q_OS_MACX)
123 s=settings.value (p,"/usr/bin/open").toString();
125 s=settings.value (p,"acroread").toString();
128 settings.setValue( p,s);
131 // Create tab widget which holds the maps
132 tabWidget= new QTabWidget (this);
133 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
134 this, SLOT( editorChanged( QWidget * ) ) );
136 lineedit=new QLineEdit (this);
139 setCentralWidget(tabWidget);
143 setupFormatActions();
147 setupSettingsActions();
149 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
154 restoreState (settings.value("/mainwindow/state",0).toByteArray());
156 // Initialize Find window
157 findWindow=new FindWindow(NULL);
158 findWindow->move (x(),y()+70);
159 connect (findWindow, SIGNAL( findButton(QString) ),
160 this, SLOT(editFind(QString) ) );
161 connect (findWindow, SIGNAL( somethingChanged() ),
162 this, SLOT(editFindChanged() ) );
164 // Connect TextEditor, so that we can update flags if text changes
165 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
166 connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions()));
174 settings.setValue ( "/mainwindow/geometry/size", size() );
175 settings.setValue ( "/mainwindow/geometry/pos", pos() );
176 settings.setValue ("/mainwindow/state",saveState(0));
178 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
179 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
180 settings.setValue( "/version/version", vymVersion );
181 settings.setValue( "/version/builddate", vymBuildDate );
183 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
184 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
185 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
186 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
187 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
188 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
190 // call the destructors
192 delete historyWindow;
194 // Remove temporary directory
195 removeDir (QDir(tmpVymDir));
198 void Main::loadCmdLine()
200 /* TODO draw some kind of splashscreen while loading...
206 QStringList flist=options.getFileList();
207 QStringList::Iterator it=flist.begin();
209 while (it !=flist.end() )
211 fileLoad (*it, NewMap);
217 void Main::statusMessage(const QString &s)
219 statusBar()->message (s);
222 void Main::closeEvent (QCloseEvent* )
228 void Main::setupFileActions()
230 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
231 QToolBar *tb = addToolBar( tr ("&Map") );
232 tb->setObjectName ("mapTB");
235 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
236 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
237 a->setShortcut ( Qt::CTRL + Qt::Key_N );
239 fileMenu->addAction (a);
240 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
242 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
243 a->setStatusTip (tr( "Open","Status tip File menu" ) );
244 a->setShortcut ( Qt::CTRL + Qt::Key_O );
246 fileMenu->addAction (a);
247 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
249 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
250 fileMenu->addSeparator();
252 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
253 a->setStatusTip ( tr( "Save","Status tip file menu" ));
254 a->setShortcut (Qt::CTRL + Qt::Key_S );
256 fileMenu->addAction (a);
257 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
260 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
261 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
262 fileMenu->addAction (a);
263 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
265 fileMenu->addSeparator();
267 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
269 a = new QAction(tr("KDE Bookmarks"), this);
270 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
271 a->addTo (fileImportMenu);
272 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
274 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
276 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
277 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
278 a->addTo (fileImportMenu);
279 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
282 a = new QAction("Mind Manager...",this);
283 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
284 fileImportMenu->addAction (a);
285 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
287 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
288 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
289 fileImportMenu->addAction (a);
290 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
292 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
294 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
295 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
296 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
297 fileExportMenu->addAction (a);
299 a = new QAction( "Open Office...", this);
300 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
301 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
302 fileExportMenu->addAction (a);
304 a = new QAction( "Webpage (XHTML)...",this );
305 a->setShortcut (Qt::ALT + Qt::Key_X);
306 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
307 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
308 fileExportMenu->addAction (a);
310 a = new QAction( "Text (ASCII)...", this);
311 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
313 fileExportMenu->addAction (a);
315 a = new QAction( tr("KDE Bookmarks","File menu"), this);
316 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
317 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
318 fileExportMenu->addAction (a);
320 a = new QAction( "Taskjuggler...", this );
321 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
322 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
323 fileExportMenu->addAction (a);
325 a = new QAction( "LaTeX...", this);
326 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
327 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
328 fileExportMenu->addAction (a);
330 a = new QAction( "XML..." , this );
331 a->setStatusTip (tr( "Export as %1").arg("XML"));
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
333 fileExportMenu->addAction (a);
335 fileMenu->addSeparator();
337 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
338 a->setStatusTip ( tr( "Print" ,"File menu") );
339 a->setShortcut (Qt::CTRL + Qt::Key_P );
341 fileMenu->addAction (a);
342 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
345 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
346 a->setStatusTip (tr( "Close Map" ) );
347 a->setShortcut (Qt::ALT + Qt::Key_C );
348 fileMenu->addAction (a);
349 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
351 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
352 a->setStatusTip ( tr( "Exit")+" "+vymName );
353 a->setShortcut (Qt::CTRL + Qt::Key_Q );
354 fileMenu->addAction (a);
355 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
360 void Main::setupEditActions()
362 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
363 tb->setLabel( "Edit Actions" );
364 tb->setObjectName ("actionsTB");
365 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
369 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
370 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
371 a->setStatusTip (tr( "Undo" ) );
372 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
373 a->setEnabled (false);
375 editMenu->addAction (a);
378 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
379 a->setStatusTip (tr( "Redo" ));
380 a->setShortcut (Qt::CTRL + Qt::Key_Y );
382 editMenu->addAction (a);
383 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
386 editMenu->addSeparator();
387 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
388 a->setStatusTip ( tr( "Copy" ) );
389 a->setShortcut (Qt::CTRL + Qt::Key_C );
390 a->setEnabled (false);
392 editMenu->addAction (a);
393 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
396 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
397 a->setStatusTip ( tr( "Cut" ) );
398 a->setShortcut (Qt::CTRL + Qt::Key_X );
399 a->setEnabled (false);
401 editMenu->addAction (a);
403 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
405 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
406 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
407 a->setStatusTip ( tr( "Paste" ) );
408 a->setShortcut ( Qt::CTRL + Qt::Key_V );
409 a->setEnabled (false);
411 editMenu->addAction (a);
414 // Shortcuts to modify heading:
415 a = new QAction(tr( "Edit heading","Edit menu" ),this);
416 a->setStatusTip ( tr( "edit Heading" ));
417 a->setShortcut ( Qt::Key_Enter);
418 // a->setShortcutContext (Qt::WindowShortcut);
420 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
421 actionListBranches.append(a);
422 a = new QAction( tr( "Edit heading","Edit menu" ), this);
423 a->setStatusTip (tr( "edit Heading" ));
424 a->setShortcut (Qt::Key_Return );
425 //a->setShortcutContext (Qt::WindowShortcut);
427 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
428 actionListBranches.append(a);
429 editMenu->addAction (a);
431 a = new QAction( tr( "Edit heading","Edit menu" ), this);
432 a->setStatusTip (tr( "edit Heading" ));
433 a->setShortcut ( Qt::Key_F2 );
434 a->setShortcutContext (Qt::WindowShortcut);
436 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
437 actionListBranches.append(a);
439 // Shortcut to delete selection
440 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
441 a->setStatusTip (tr( "Delete Selection" ));
442 a->setShortcut ( Qt::Key_Delete);
443 a->setShortcutContext (Qt::WindowShortcut);
445 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
448 // Shortcut to add branch
449 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
450 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
451 alt->setShortcut (Qt::Key_A);
452 alt->setShortcutContext (Qt::WindowShortcut);
454 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
455 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
456 a->setStatusTip ( tr( "Add a branch as child of selection" ));
457 a->setShortcut (Qt::Key_Insert);
458 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
459 actionListBranches.append(a);
460 #if defined (Q_OS_MACX)
461 // In OSX show different shortcut in menues, the keys work indepently always
462 actionEditAddBranch=alt;
464 actionEditAddBranch=a;
466 editMenu->addAction (actionEditAddBranch);
467 tb->addAction (actionEditAddBranch);
470 // Add branch by inserting it at selection
471 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
472 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
473 a->setShortcut (Qt::ALT + Qt::Key_Insert );
474 a->setShortcutContext (Qt::WindowShortcut);
476 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
477 a->setEnabled (false);
478 actionListBranches.append(a);
479 actionEditAddBranchBefore=a;
480 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
481 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
482 a->setShortcut ( Qt::ALT + Qt::Key_A );
483 a->setShortcutContext (Qt::WindowShortcut);
485 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
486 actionListBranches.append(a);
489 a = new QAction(tr( "Add branch above","Edit menu" ), this);
490 a->setStatusTip ( tr( "Add a branch above selection" ));
491 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
492 a->setShortcutContext (Qt::WindowShortcut);
494 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
495 a->setEnabled (false);
496 actionListBranches.append(a);
497 actionEditAddBranchAbove=a;
498 a = new QAction(tr( "Add branch above","Edit menu" ), this);
499 a->setStatusTip ( tr( "Add a branch above selection" ));
500 a->setShortcut (Qt::SHIFT+Qt::Key_A );
501 a->setShortcutContext (Qt::WindowShortcut);
503 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
504 actionListBranches.append(a);
507 a = new QAction(tr( "Add branch below","Edit menu" ), this);
508 a->setStatusTip ( tr( "Add a branch below selection" ));
509 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
510 a->setShortcutContext (Qt::WindowShortcut);
512 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
513 a->setEnabled (false);
514 actionListBranches.append(a);
515 actionEditAddBranchBelow=a;
516 a = new QAction(tr( "Add branch below","Edit menu" ), this);
517 a->setStatusTip ( tr( "Add a branch below selection" ));
518 a->setShortcut (Qt::CTRL +Qt::Key_A );
519 a->setShortcutContext (Qt::WindowShortcut);
521 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
522 actionListBranches.append(a);
524 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
525 a->setStatusTip ( tr( "Move branch up" ) );
526 a->setShortcut (Qt::Key_PageUp );
527 a->setEnabled (false);
529 editMenu->addAction (a);
530 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
533 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
534 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
535 a->setStatusTip (tr( "Move branch down" ) );
536 a->setShortcut ( Qt::Key_PageDown );
537 a->setEnabled (false);
539 editMenu->addAction (a);
540 actionEditMoveDown=a;
543 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
544 a->setShortcut ( Qt::Key_ScrollLock );
545 a->setStatusTip (tr( "Scroll branch" ) );
546 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
548 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
549 alt->setShortcut ( Qt::Key_S );
550 alt->setStatusTip (tr( "Scroll branch" ));
551 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
552 #if defined(Q_OS_MACX)
553 actionEditToggleScroll=alt;
555 actionEditToggleScroll=a;
557 actionEditToggleScroll->setEnabled (false);
558 actionEditToggleScroll->setToggleAction(true);
559 tb->addAction (actionEditToggleScroll);
560 editMenu->addAction ( actionEditToggleScroll);
561 editMenu->addAction (actionEditToggleScroll);
564 actionListBranches.append(actionEditToggleScroll);
566 a = new QAction( tr( "Unscroll all scrolled branches","Edit menu" ), this);
567 a->setStatusTip (tr( "Unscroll all" ));
568 editMenu->addAction (a);
569 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
571 editMenu->addSeparator();
573 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
574 a->setStatusTip (tr( "Find" ) );
575 a->setShortcut (Qt::CTRL + Qt::Key_F );
576 editMenu->addAction (a);
577 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
579 editMenu->addSeparator();
581 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
582 a->setShortcut (Qt::CTRL + Qt::Key_U );
583 a->setShortcut (tr( "Open URL" ));
586 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
589 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
590 a->setStatusTip (tr( "Open URL in new tab" ));
591 a->setShortcut (Qt::CTRL+Qt::Key_U );
593 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
594 actionEditOpenURLTab=a;
596 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
597 a->setStatusTip (tr( "Open all URLs in subtree" ));
599 actionListBranches.append(a);
600 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
601 actionEditOpenMultipleURLTabs=a;
603 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
604 a->setStatusTip ( tr( "Edit URL" ) );
605 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
606 //a->setShortcut ( Qt::Key_U );
607 a->setShortcutContext (Qt::WindowShortcut);
608 actionListBranches.append(a);
610 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
613 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
614 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
615 a->setEnabled (false);
616 actionListBranches.append(a);
617 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
618 actionEditHeading2URL=a;
620 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
621 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
622 a->setEnabled (false);
623 actionListBranches.append(a);
624 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
625 actionEditBugzilla2URL=a;
627 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
628 a->setStatusTip ( tr( "Create URL to FATE" ));
629 a->setEnabled (false);
630 actionListBranches.append(a);
631 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
632 actionEditFATE2URL=a;
634 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
635 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
637 a->setEnabled (false);
638 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
639 actionEditOpenVymLink=a;
641 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
642 a->setStatusTip ( tr( "Open all vym links in subtree" ));
643 a->setEnabled (false);
644 actionListBranches.append(a);
645 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
646 actionEditOpenMultipleVymLinks=a;
649 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
650 a->setEnabled (false);
651 a->setStatusTip ( tr( "Edit link to another vym map" ));
652 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
653 actionListBranches.append(a);
656 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
657 a->setStatusTip ( tr( "Delete link to another vym map" ));
658 a->setEnabled (false);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
660 actionEditDeleteVymLink=a;
662 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
663 a->setStatusTip ( tr( "Hide object in exports" ) );
664 a->setShortcut (Qt::Key_H );
665 a->setToggleAction(true);
667 a->setEnabled (false);
668 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
669 actionEditToggleHideExport=a;
671 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
672 a->setStatusTip ( tr( "Edit Map Info" ));
673 a->setEnabled (true);
674 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
677 // Import at selection (adding to selection)
678 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
679 a->setStatusTip (tr( "Add map at selection" ));
680 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
681 a->setEnabled (false);
682 actionListBranches.append(a);
683 actionEditImportAdd=a;
685 // Import at selection (replacing selection)
686 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
687 a->setStatusTip (tr( "Replace selection with map" ));
688 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
689 a->setEnabled (false);
690 actionListBranches.append(a);
691 actionEditImportReplace=a;
694 a = new QAction( tr( "Save selection","Edit menu" ), this);
695 a->setStatusTip (tr( "Save selection" ));
696 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
697 a->setEnabled (false);
698 actionListBranches.append(a);
699 actionEditSaveBranch=a;
701 // Only remove branch, not its childs
702 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
703 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
704 a->setShortcut (Qt::ALT + Qt::Key_Delete );
705 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
706 a->setEnabled (false);
708 actionListBranches.append(a);
709 actionEditDeleteKeepChilds=a;
711 // Only remove childs of a branch
712 a = new QAction( tr( "Remove childs","Edit menu" ), this);
713 a->setStatusTip (tr( "Remove childs of branch" ));
714 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
715 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
716 a->setEnabled (false);
717 actionListBranches.append(a);
718 actionEditDeleteChilds=a;
720 // Shortcuts for navigating with cursor:
721 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
722 a->setStatusTip ( tr( "Select upper branch" ));
723 a->setShortcut (Qt::Key_Up );
724 a->setShortcutContext (Qt::WindowShortcut);
726 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
727 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
728 a->setStatusTip (tr( "Select lower branch" ));
729 a->setShortcut ( Qt::Key_Down );
730 a->setShortcutContext (Qt::WindowShortcut);
732 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
733 a = new QAction(tr( "Select left branch","Edit menu" ), this);
734 a->setStatusTip ( tr( "Select left branch" ));
735 a->setShortcut (Qt::Key_Left );
736 a->setShortcutContext (Qt::WindowShortcut);
738 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
739 a = new QAction( tr( "Select child branch","Edit menu" ), this);
740 a->setStatusTip (tr( "Select right branch" ));
741 a->setShortcut (Qt::Key_Right);
742 a->setShortcutContext (Qt::WindowShortcut);
744 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
745 a = new QAction( tr( "Select first branch","Edit menu" ), this);
746 a->setStatusTip (tr( "Select first branch" ));
747 a->setShortcut (Qt::Key_Home );
748 a->setShortcutContext (Qt::WindowShortcut);
750 a->setEnabled (false);
751 editMenu->addAction (a);
752 actionListBranches.append(a);
753 actionEditSelectFirst=a;
754 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
755 a = new QAction( tr( "Select last branch","Edit menu" ),this);
756 a->setStatusTip (tr( "Select last branch" ));
757 a->setShortcut ( Qt::Key_End );
758 a->setShortcutContext (Qt::WindowShortcut);
760 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
761 a->setEnabled (false);
762 editMenu->addAction (a);
763 actionListBranches.append(a);
764 actionEditSelectLast=a;
766 a = new QAction( tr( "Add Image...","Edit menu" ), this);
767 a->setStatusTip (tr( "Add Image" ));
768 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
769 actionEditLoadImage=a;
771 a = new QAction( tr( "Properties","Context menu for images and branches" )+QString ("..."), this);
772 a->setStatusTip (tr( "Set properties for object" ));
773 connect( a, SIGNAL( triggered() ), this, SLOT( showPropertyDialog() ) );
774 actionOpenPropertyDialog=a;
778 void Main::setupFormatActions()
780 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
782 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
783 tb->setObjectName ("formatTB");
786 pix.fill (Qt::black);
787 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
788 a->setStatusTip ( tr( "Set Color" ));
789 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
791 formatMenu->addAction (a);
793 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
794 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
795 a->setShortcut (Qt::CTRL + Qt::Key_K );
796 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
797 a->setEnabled (false);
799 formatMenu->addAction (a);
800 actionListBranches.append(a);
801 actionFormatPickColor=a;
803 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
804 a->setStatusTip ( tr( "Color branch" ) );
805 a->setShortcut (Qt::CTRL + Qt::Key_I);
806 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
807 a->setEnabled (false);
809 formatMenu->addAction (a);
810 actionListBranches.append(a);
811 actionFormatColorSubtree=a;
813 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
814 a->setStatusTip ( tr( "Color Subtree" ));
815 a->setShortcut (Qt::CTRL + Qt::Key_T);
816 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
817 a->setEnabled (false);
818 formatMenu->addAction (a);
820 actionListBranches.append(a);
821 actionFormatColorSubtree=a;
823 formatMenu->addSeparator();
824 actionGroupFormatLinkStyles=new QActionGroup ( this);
825 actionGroupFormatLinkStyles->setExclusive (true);
826 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
827 a->setStatusTip (tr( "Line" ));
828 a->setToggleAction(true);
829 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
830 formatMenu->addAction (a);
831 actionFormatLinkStyleLine=a;
832 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
833 a->setStatusTip (tr( "Line" ));
834 a->setToggleAction(true);
835 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
836 formatMenu->addAction (a);
837 actionFormatLinkStyleParabel=a;
838 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
839 a->setStatusTip (tr( "PolyLine" ));
840 a->setToggleAction(true);
841 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
842 formatMenu->addAction (a);
843 actionFormatLinkStylePolyLine=a;
844 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
845 a->setStatusTip (tr( "PolyParabel" ) );
846 a->setToggleAction(true);
847 a->setChecked (true);
848 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
849 formatMenu->addAction (a);
850 actionFormatLinkStylePolyParabel=a;
852 a = new QAction( tr( "Include images vertically","Branch attribute" ), this);
853 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
854 a->setToggleAction(true);
855 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
856 actionFormatIncludeImagesVer=a;
858 a = new QAction( tr( "Include images horizontally","Branch attribute" ), this);
859 a->setStatusTip ( tr ("Include left and right position of images into branch"));
860 a->setToggleAction(true);
861 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
862 actionFormatIncludeImagesHor=a;
864 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
865 a->setStatusTip (tr( "Hide link" ));
866 a->setToggleAction(true);
867 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
868 actionFormatHideLinkUnselected=a;
870 formatMenu->addSeparator();
871 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
872 a->setStatusTip (tr( "Use same color for links and headings" ));
873 a->setToggleAction(true);
874 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
875 formatMenu->addAction (a);
876 actionFormatLinkColorHint=a;
878 pix.fill (Qt::white);
879 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
880 a->setStatusTip (tr( "Set Link Color" ));
881 formatMenu->addAction (a);
882 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
883 actionFormatLinkColor=a;
885 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
886 a->setStatusTip (tr( "Set Background Color" ));
887 formatMenu->addAction (a);
888 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
889 actionFormatBackColor=a;
891 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
892 a->setStatusTip (tr( "Set Background image" ));
893 formatMenu->addAction (a);
894 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
895 actionFormatBackImage=a;
899 void Main::setupViewActions()
901 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
902 tb->setLabel( "View Actions" );
903 tb->setObjectName ("viewTB");
904 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
907 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
908 a->setStatusTip ( tr( "Zoom reset" ) );
909 a->setShortcut (Qt::CTRL + Qt::Key_0 );
911 viewMenu->addAction (a);
912 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
914 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
915 a->setStatusTip (tr( "Zoom in" ));
916 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
918 viewMenu->addAction (a);
919 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
921 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
922 a->setStatusTip (tr( "Zoom out" ));
923 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
925 viewMenu->addAction (a);
926 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
929 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
930 a->setStatusTip ( tr( "Show Note Editor" ));
931 a->setShortcut ( Qt::CTRL + Qt::Key_E );
932 a->setToggleAction(true);
933 if (textEditor->showWithMain())
938 viewMenu->addAction (a);
939 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
940 actionViewToggleNoteEditor=a;
942 a = new QAction(QPixmap(iconPath+"history.png"), tr( "Show history window","View action" ),this );
943 a->setStatusTip ( tr( "Show history window" ));
944 a->setShortcut ( Qt::CTRL + Qt::Key_H );
945 a->setToggleAction(true);
947 viewMenu->addAction (a);
948 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
949 actionViewToggleHistoryWindow=a;
951 a = new QAction(tr( "Antialiasing","View action" ),this );
952 a->setStatusTip ( tr( "Antialiasing" ));
953 a->setToggleAction(true);
954 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
955 viewMenu->addAction (a);
956 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
957 actionViewToggleAntiAlias=a;
959 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
960 a->setStatusTip (a->text());
961 a->setToggleAction(true);
962 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
963 viewMenu->addAction (a);
964 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
965 actionViewToggleSmoothPixmapTransform=a;
967 a = new QAction(tr( "Next Window","View action" ), this);
968 a->setStatusTip (a->text());
969 a->setShortcut (Qt::ALT + Qt::Key_N );
970 viewMenu->addAction (a);
971 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
973 a = new QAction (tr( "Previous Window","View action" ), this );
974 a->setStatusTip (a->text());
975 a->setShortcut (Qt::ALT + Qt::Key_P );
976 viewMenu->addAction (a);
977 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
981 void Main::setupModeActions()
983 //QPopupMenu *menu = new QPopupMenu( this );
984 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
986 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
987 tb->setObjectName ("modesTB");
989 actionGroupModModes=new QActionGroup ( this);
990 actionGroupModModes->setExclusive (true);
991 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
992 a->setShortcut (Qt::Key_J);
993 a->setStatusTip ( tr( "Use modifier to color branches" ));
994 a->setToggleAction(true);
997 actionModModeColor=a;
999 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1000 a->setShortcut( Qt::Key_K);
1001 a->setStatusTip( tr( "Use modifier to copy" ));
1002 a->setToggleAction(true);
1004 actionModModeCopy=a;
1006 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1007 a->setShortcut (Qt::Key_L);
1008 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1009 a->setToggleAction(true);
1011 actionModModeXLink=a;
1015 void Main::setupFlagActions()
1017 // Create System Flags
1018 systemFlagsDefault = new FlagRowObj ();
1019 systemFlagsDefault->setVisibility (false);
1020 systemFlagsDefault->setName ("systemFlagsDef");
1022 FlagObj *fo = new FlagObj ();
1023 fo->load(QPixmap(flagsPath+"flag-note.png"));
1024 fo->setName("note");
1025 fo->setToolTip(tr("Note","Systemflag"));
1026 systemFlagsDefault->addFlag (fo); // makes deep copy
1028 fo->load(QPixmap(flagsPath+"flag-url.png"));
1030 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1031 systemFlagsDefault->addFlag (fo);
1033 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1034 fo->setName("vymLink");
1035 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1036 systemFlagsDefault->addFlag (fo);
1038 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1039 fo->setName("scrolledright");
1040 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1041 systemFlagsDefault->addFlag (fo);
1043 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1044 fo->setName("tmpUnscrolledright");
1045 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1046 systemFlagsDefault->addFlag (fo);
1048 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1049 fo->setName("hideInExport");
1050 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1051 systemFlagsDefault->addFlag (fo);
1053 // Create Standard Flags
1054 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1055 tb->setObjectName ("standardFlagTB");
1057 standardFlagsDefault = new FlagRowObj ();
1058 standardFlagsDefault->setVisibility (false);
1059 standardFlagsDefault->setName ("standardFlagsDef");
1060 standardFlagsDefault->setToolBar (tb);
1062 fo->load(flagsPath+"flag-exclamationmark.png");
1063 fo->setName ("exclamationmark");
1064 fo->setGroup("standard-mark");
1065 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1068 a->setCheckable(true);
1069 a->setObjectName(fo->getName());
1070 a->setToolTip(tr("Take care!","Standardflag"));
1071 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1072 standardFlagsDefault->addFlag (fo); // makes deep copy
1074 fo->load(flagsPath+"flag-questionmark.png");
1075 fo->setName("questionmark");
1076 fo->setGroup("standard-mark");
1077 a=new QAction (fo->getPixmap(),fo->getName(),this);
1080 a->setCheckable(true);
1081 a->setObjectName(fo->getName());
1082 a->setToolTip(tr("Really?","Standardflag"));
1083 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1084 standardFlagsDefault->addFlag (fo);
1086 fo->load(flagsPath+"flag-hook-green.png");
1087 fo->setName("hook-green");
1088 fo->setGroup("standard-hook");
1089 a=new QAction (fo->getPixmap(),fo->getName(),this);
1092 a->setCheckable(true);
1093 a->setObjectName(fo->getName());
1094 a->setToolTip(tr("ok!","Standardflag"));
1095 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1096 standardFlagsDefault->addFlag (fo);
1098 fo->load(flagsPath+"flag-cross-red.png");
1099 fo->setName("cross-red");
1100 fo->setGroup("standard-hook");
1101 a=new QAction (fo->getPixmap(),fo->getName(),this);
1104 a->setCheckable(true);
1105 a->setObjectName(fo->getName());
1106 a->setToolTip(tr("Not ok!","Standardflag"));
1107 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1108 standardFlagsDefault->addFlag (fo);
1110 fo->load(flagsPath+"flag-stopsign.png");
1111 fo->setName("stopsign");
1112 a=new QAction (fo->getPixmap(),fo->getName(),this);
1115 a->setCheckable(true);
1116 a->setObjectName(fo->getName());
1117 a->setToolTip(tr("This won't work!","Standardflag"));
1118 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1119 standardFlagsDefault->addFlag (fo);
1121 fo->load(flagsPath+"flag-smiley-good.png");
1122 fo->setName("smiley-good");
1123 fo->setGroup("standard-smiley");
1124 a=new QAction (fo->getPixmap(),fo->getName(),this);
1127 a->setCheckable(true);
1128 a->setObjectName(fo->getName());
1129 a->setToolTip(tr("Good","Standardflag"));
1130 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1131 standardFlagsDefault->addFlag (fo);
1133 fo->load(flagsPath+"flag-smiley-sad.png");
1134 fo->setName("smiley-sad");
1135 fo->setGroup("standard-smiley");
1136 a=new QAction (fo->getPixmap(),fo->getName(),this);
1139 a->setCheckable(true);
1140 a->setObjectName(fo->getName());
1141 a->setToolTip(tr("Bad","Standardflag"));
1142 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1143 standardFlagsDefault->addFlag (fo);
1145 fo->load(flagsPath+"flag-smiley-omg.png");
1146 // Original omg.png (in KDE emoticons)
1147 fo->setName("smiley-omg");
1148 fo->setGroup("standard-smiley");
1149 a=new QAction (fo->getPixmap(),fo->getName(),this);
1152 a->setCheckable(true);
1153 a->setObjectName(fo->getName());
1154 a->setToolTip(tr("Oh no!","Standardflag"));
1155 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1156 standardFlagsDefault->addFlag (fo);
1158 fo->load(flagsPath+"flag-kalarm.png");
1159 fo->setName("clock");
1160 a=new QAction (fo->getPixmap(),fo->getName(),this);
1163 a->setCheckable(true);
1164 a->setObjectName(fo->getName());
1165 a->setToolTip(tr("Time critical","Standardflag"));
1166 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1167 standardFlagsDefault->addFlag (fo);
1169 fo->load(flagsPath+"flag-phone.png");
1170 fo->setName("phone");
1171 a=new QAction (fo->getPixmap(),fo->getName(),this);
1174 a->setCheckable(true);
1175 a->setObjectName(fo->getName());
1176 a->setToolTip(tr("Call...","Standardflag"));
1177 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1178 standardFlagsDefault->addFlag (fo);
1180 fo->load(flagsPath+"flag-lamp.png");
1181 fo->setName("lamp");
1182 a=new QAction (fo->getPixmap(),fo->getName(),this);
1185 a->setCheckable(true);
1186 a->setObjectName(fo->getName());
1187 a->setToolTip(tr("Idea!","Standardflag"));
1188 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1189 standardFlagsDefault->addFlag (fo);
1191 fo->load(flagsPath+"flag-arrow-up.png");
1192 fo->setName("arrow-up");
1193 fo->setGroup("standard-arrow");
1194 a=new QAction (fo->getPixmap(),fo->getName(),this);
1197 a->setCheckable(true);
1198 a->setObjectName(fo->getName());
1199 a->setToolTip(tr("Important","Standardflag"));
1200 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1201 standardFlagsDefault->addFlag (fo);
1203 fo->load(flagsPath+"flag-arrow-down.png");
1204 fo->setName("arrow-down");
1205 fo->setGroup("standard-arrow");
1206 a=new QAction (fo->getPixmap(),fo->getName(),this);
1209 a->setCheckable(true);
1210 a->setObjectName(fo->getName());
1211 a->setToolTip(tr("Unimportant","Standardflag"));
1212 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1213 standardFlagsDefault->addFlag (fo);
1215 fo->load(flagsPath+"flag-arrow-2up.png");
1216 fo->setName("2arrow-up");
1217 fo->setGroup("standard-arrow");
1218 a=new QAction (fo->getPixmap(),fo->getName(),this);
1221 a->setCheckable(true);
1222 a->setObjectName(fo->getName());
1223 a->setToolTip(tr("Very important!","Standardflag"));
1224 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1225 standardFlagsDefault->addFlag (fo);
1227 fo->load(flagsPath+"flag-arrow-2down.png");
1228 fo->setName("2arrow-down");
1229 fo->setGroup("standard-arrow");
1230 a=new QAction (fo->getPixmap(),fo->getName(),this);
1233 a->setCheckable(true);
1234 a->setObjectName(fo->getName());
1235 a->setToolTip(tr("Very unimportant!","Standardflag"));
1236 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1237 standardFlagsDefault->addFlag (fo);
1239 fo->load(flagsPath+"flag-thumb-up.png");
1240 fo->setName("thumb-up");
1241 fo->setGroup("standard-thumb");
1242 a=new QAction (fo->getPixmap(),fo->getName(),this);
1245 a->setCheckable(true);
1246 a->setObjectName(fo->getName());
1247 a->setToolTip(tr("I like this","Standardflag"));
1248 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1249 standardFlagsDefault->addFlag (fo);
1251 fo->load(flagsPath+"flag-thumb-down.png");
1252 fo->setName("thumb-down");
1253 fo->setGroup("standard-thumb");
1254 a=new QAction (fo->getPixmap(),fo->getName(),this);
1257 a->setCheckable(true);
1258 a->setObjectName(fo->getName());
1259 a->setToolTip(tr("I do not like this","Standardflag"));
1260 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1261 standardFlagsDefault->addFlag (fo);
1263 fo->load(flagsPath+"flag-rose.png");
1264 fo->setName("rose");
1265 a=new QAction (fo->getPixmap(),fo->getName(),this);
1268 a->setCheckable(true);
1269 a->setObjectName(fo->getName());
1270 a->setToolTip(tr("Rose","Standardflag"));
1271 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1272 standardFlagsDefault->addFlag (fo);
1274 fo->load(flagsPath+"flag-heart.png");
1275 fo->setName("heart");
1276 a=new QAction (fo->getPixmap(),fo->getName(),this);
1278 a->setCheckable(true);
1279 a->setObjectName(fo->getName());
1280 a->setToolTip(tr("I just love... ","Standardflag"));
1281 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1282 standardFlagsDefault->addFlag (fo);
1284 fo->load(flagsPath+"flag-present.png");
1285 fo->setName("present");
1286 a=new QAction (fo->getPixmap(),fo->getName(),this);
1289 a->setCheckable(true);
1290 a->setObjectName(fo->getName());
1291 a->setToolTip(tr("Surprise!","Standardflag"));
1292 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1293 standardFlagsDefault->addFlag (fo);
1295 fo->load(flagsPath+"flag-flash.png");
1296 fo->setName("flash");
1297 a=new QAction (fo->getPixmap(),fo->getName(),this);
1300 a->setCheckable(true);
1301 a->setObjectName(fo->getName());
1302 a->setToolTip(tr("Dangerous","Standardflag"));
1303 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1304 standardFlagsDefault->addFlag (fo);
1306 fo->load(flagsPath+"flag-info.png");
1307 // Original: xsldbg_output.png
1308 fo->setName("info");
1309 a=new QAction (fo->getPixmap(),fo->getName(),this);
1312 a->setCheckable(true);
1313 a->setObjectName(fo->getName());
1314 a->setToolTip(tr("Info","Standardflag"));
1315 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1316 standardFlagsDefault->addFlag (fo);
1318 fo->load(flagsPath+"flag-lifebelt.png");
1319 // Original khelpcenter.png
1320 fo->setName("lifebelt");
1321 a=new QAction (fo->getPixmap(),fo->getName(),this);
1324 a->setCheckable(true);
1325 a->setObjectName(fo->getName());
1326 a->setToolTip(tr("This will help","Standardflag"));
1327 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1328 standardFlagsDefault->addFlag (fo);
1334 void Main::setupSettingsActions()
1336 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1340 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1341 a->setStatusTip ( tr( "Set application to open pdf files"));
1342 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1343 settingsMenu->addAction (a);
1345 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1346 a->setStatusTip( tr( "Set application to open external links"));
1347 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1348 settingsMenu->addAction (a);
1350 settingsMenu->addSeparator();
1351 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1352 a->setStatusTip( tr( "Edit branch after adding it" ));
1353 a->setToggleAction(true);
1354 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1355 settingsMenu->addAction (a);
1356 actionSettingsAutoEdit=a;
1358 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1359 a->setStatusTip( tr( "Select branch after adding it" ));
1360 a->setToggleAction(true);
1361 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1362 settingsMenu->addAction (a);
1363 actionSettingsAutoSelectHeading=a;
1365 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1366 a->setStatusTip( tr( "Select heading before editing" ));
1367 a->setToggleAction(true);
1368 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1369 settingsMenu->addAction (a);
1370 actionSettingsAutoSelectText=a;
1372 a= new QAction( tr( "Delete key","Settings action" ), this);
1373 a->setStatusTip( tr( "Delete key for deleting branches" ));
1374 a->setToggleAction(true);
1375 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1376 settingsMenu->addAction (a);
1377 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1378 actionSettingsUseDelKey=a;
1380 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1381 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1382 a->setToggleAction(true);
1383 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1384 settingsMenu->addAction (a);
1385 actionSettingsUseFlagGroups=a;
1387 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1388 a->setStatusTip( tr( "Use hide flag during exports " ));
1389 a->setToggleAction(true);
1390 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1391 settingsMenu->addAction (a);
1392 actionSettingsUseHideExport=a;
1396 void Main::setupTestActions()
1398 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1401 a = new QAction( "Test function" , this);
1402 a->setStatusTip( "Call test function" );
1403 a->setShortcut (Qt::Key_F4 );
1404 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1405 testMenu->addAction (a);
1406 a = new QAction( "Command" , this);
1407 a->setStatusTip( "Enter command to call in editor" );
1408 a->setShortcut (Qt::Key_F5 );
1409 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1410 testMenu->addAction (a);
1414 void Main::setupHelpActions()
1416 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1419 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1420 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1421 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1422 helpMenu->addAction (a);
1424 a = new QAction( tr( "About VYM","Help action" ), this);
1425 a->setStatusTip( tr( "About VYM")+vymName);
1426 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1427 helpMenu->addAction (a);
1429 a = new QAction( tr( "About QT","Help action" ), this);
1430 a->setStatusTip( tr( "Information about QT toolkit" ));
1431 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1432 helpMenu->addAction (a);
1436 void Main::setupContextMenus()
1440 // Context Menu for branch or mapcenter
1441 branchContextMenu =new QMenu (this);
1443 actionOpenPropertyDialog->addTo (branchContextMenu);
1444 branchContextMenu->addSeparator();
1447 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1448 branchAddContextMenu->addAction (actionEditPaste );
1449 branchAddContextMenu->addAction ( actionEditAddBranch );
1450 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1451 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1452 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1453 branchAddContextMenu->addSeparator();
1454 branchAddContextMenu->addAction ( actionEditImportAdd );
1455 branchAddContextMenu->addAction ( actionEditImportReplace );
1458 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1459 branchRemoveContextMenu->addAction (actionEditCut);
1460 branchRemoveContextMenu->addAction ( actionEditDelete );
1461 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1462 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1465 actionEditSaveBranch->addTo( branchContextMenu );
1467 branchContextMenu->addSeparator();
1468 branchContextMenu->addAction ( actionEditLoadImage);
1469 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1470 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1472 // Submenu for Links (URLs, vymLinks)
1473 branchLinksContextMenu =new QMenu (this);
1475 branchContextMenu->addSeparator();
1476 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks","Context menu name"));
1477 branchLinksContextMenu->addAction ( actionEditOpenURL );
1478 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1479 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1480 branchLinksContextMenu->addAction ( actionEditURL );
1481 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1482 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1483 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1485 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1487 branchLinksContextMenu->addSeparator();
1488 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1489 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1490 branchLinksContextMenu->addAction ( actionEditVymLink );
1491 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1494 // Context Menu for XLinks in a branch menu
1495 // This will be populated "on demand" in MapEditor::updateActions
1496 branchContextMenu->addSeparator();
1497 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1498 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1499 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1500 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1503 // Context menu for floatimage
1504 floatimageContextMenu =new QMenu (this);
1505 a= new QAction (tr ("Save image","Context action"),this);
1506 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1507 floatimageContextMenu->addAction (a);
1509 floatimageContextMenu->addSeparator();
1510 actionEditCopy->addTo( floatimageContextMenu );
1511 actionEditCut->addTo( floatimageContextMenu );
1513 floatimageContextMenu->addSeparator();
1514 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1517 // Context menu for canvas
1518 canvasContextMenu =new QMenu (this);
1519 actionEditMapInfo->addTo( canvasContextMenu );
1520 canvasContextMenu->insertSeparator();
1521 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1522 canvasContextMenu->insertSeparator();
1523 actionFormatLinkColorHint->addTo( canvasContextMenu );
1524 actionFormatLinkColor->addTo( canvasContextMenu );
1525 actionFormatBackColor->addTo( canvasContextMenu );
1526 actionFormatBackImage->addTo( canvasContextMenu );
1528 // Menu for last opened files
1530 for (int i = 0; i < MaxRecentFiles; ++i)
1532 recentFileActs[i] = new QAction(this);
1533 recentFileActs[i]->setVisible(false);
1534 fileLastMapsMenu->addAction(recentFileActs[i]);
1535 connect(recentFileActs[i], SIGNAL(triggered()),
1536 this, SLOT(fileLoadRecent()));
1538 setupRecentMapsMenu();
1541 void Main::setupRecentMapsMenu()
1543 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1545 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1547 for (int i = 0; i < numRecentFiles; ++i) {
1548 //QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
1549 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1550 recentFileActs[i]->setText(text);
1551 recentFileActs[i]->setData(files[i]);
1552 recentFileActs[i]->setVisible(true);
1554 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1555 recentFileActs[j]->setVisible(false);
1558 void Main::hideEvent (QHideEvent * )
1560 if (!textEditor->isMinimized() ) textEditor->hide();
1563 void Main::showEvent (QShowEvent * )
1565 if (textEditor->showWithMain()) textEditor->showNormal();
1568 bool Main::reallyWriteDirectory(const QString &dir)
1570 QStringList eList = QDir(dir).entryList();
1571 if (eList.first() ==".") eList.pop_front(); // remove "."
1572 if (eList.first() =="..") eList.pop_front(); // remove "."
1573 if (!eList.isEmpty())
1575 QMessageBox mb( vymName,
1576 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1577 QMessageBox::Warning,
1579 QMessageBox::Cancel | QMessageBox::Default,
1580 QMessageBox::QMessageBox::NoButton );
1582 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1583 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1586 case QMessageBox::Yes:
1589 case QMessageBox::Cancel:
1597 QString Main::browseDirectory (const QString &caption)
1599 QFileDialog fd(this,caption);
1600 fd.setMode (QFileDialog::DirectoryOnly);
1601 fd.setCaption(vymName+ " - "+caption);
1602 fd.setDir (lastFileDir);
1605 if ( fd.exec() == QDialog::Accepted )
1606 return fd.selectedFile();
1611 MapEditor* Main::currentMapEditor() const
1613 if ( tabWidget->currentPage() &&
1614 tabWidget->currentPage()->inherits( "MapEditor" ) )
1615 return (MapEditor*)tabWidget->currentPage();
1620 void Main::editorChanged(QWidget *)
1622 // Unselect all possibly selected objects
1623 // (Important to update note editor)
1626 for (i=0;i<=tabWidget->count() -1;i++)
1629 me=(MapEditor*)tabWidget->page(i);
1632 currentMapEditor()->reselect();
1634 // Update actions to in menus and toolbars according to editor
1638 void Main::fileNew()
1640 QString fn="unnamed";
1641 MapEditor* me = new MapEditor ( NULL);
1642 tabWidget->addTab (me,fn);
1643 tabWidget->showPage(me);
1644 me->viewport()->setFocus();
1645 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1646 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1648 // For the very first map we do not have flagrows yet...
1652 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1654 ErrorCode err=success;
1656 // fn is usually the archive, mapfile the file after uncompressing
1659 // Make fn absolute (needed for unzip)
1660 fn=QDir (fn).absPath();
1666 // Check, if map is already loaded
1668 while (i<=tabWidget->count() -1)
1670 me=(MapEditor*)tabWidget->page(i);
1671 if (me->getFilePath() == fn)
1673 // Already there, ask for confirmation
1674 QMessageBox mb( vymName,
1675 tr("The map %1\nis already opened."
1676 "Opening the same map in multiple editors may lead \n"
1677 "to confusion when finishing working with vym."
1678 "Do you want to").arg(fn),
1679 QMessageBox::Warning,
1680 QMessageBox::Yes | QMessageBox::Default,
1681 QMessageBox::Cancel | QMessageBox::Escape,
1682 QMessageBox::NoButton);
1683 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1684 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1687 case QMessageBox::Yes:
1689 i=tabWidget->count();
1691 case QMessageBox::Cancel:
1703 if ( !fn.isEmpty() )
1705 me = currentMapEditor();
1706 int tabIndex=tabWidget->currentPageIndex();
1707 // Check first, if mapeditor exists
1708 // If it is not default AND we want a new map,
1709 // create a new mapeditor in a new tab
1710 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1712 me= new MapEditor ( NULL);
1713 tabWidget->addTab (me,fn);
1714 tabIndex=tabWidget->indexOf (me);
1715 tabWidget->setCurrentPage (tabIndex);
1716 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1717 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1720 // Check, if file exists (important for creating new files
1721 // from command line
1722 if (!QFile(fn).exists() )
1724 QMessageBox mb( vymName,
1725 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1726 QMessageBox::Question,
1728 QMessageBox::Cancel | QMessageBox::Default,
1729 QMessageBox::NoButton );
1731 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1732 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1735 case QMessageBox::Yes:
1737 currentMapEditor()->setFilePath(fn);
1738 tabWidget->setTabLabel (currentMapEditor(),
1739 currentMapEditor()->getFileName() );
1740 statusBar()->message( "Created " + fn , statusbarTime );
1743 case QMessageBox::Cancel:
1744 // don't create new map
1745 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1752 //tabWidget->currentPage() won't be NULL here, because of above...
1753 tabWidget->showPage(me);
1754 me->viewport()->setFocus();
1756 // Create temporary directory for packing
1758 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1761 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1762 tr("Couldn't create temporary directory before load\n"));
1766 // Try to unzip file
1767 err=unzipDir (tmpMapDir,fn);
1771 me->setZipped(false);
1774 me->setZipped(true);
1776 // Look for mapname.xml
1777 mapfile= fn.left(fn.findRev(".",-1,true));
1778 mapfile=mapfile.section( '/', -1 );
1779 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1780 if (!file.exists() )
1782 // mapname.xml does not exist, well,
1783 // maybe someone renamed the mapname.vym file...
1784 // Try to find any .xml in the toplevel
1785 // directory of the .vym file
1786 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1787 if (flist.count()==1)
1789 // Only one entry, take this one
1790 mapfile=tmpMapDir + "/"+flist.first();
1793 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1794 *it=tmpMapDir + "/" + *it;
1795 // TODO Multiple entries, load all (but only the first one into this ME)
1796 //mainWindow->fileLoadFromTmp (flist);
1797 //returnCode=1; // Silently forget this attempt to load
1798 qWarning ("MainWindow::load (fn) multimap found...");
1801 if (flist.isEmpty() )
1803 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1804 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1807 } //file doesn't exist
1809 mapfile=file.name();
1814 // Save existing filename in case we import
1815 QString fn_org=me->getFilePath();
1817 // Finally load map into mapEditor
1818 me->setFilePath (mapfile,fn);
1819 err=me->load(mapfile,lmode);
1821 // Restore old (maybe empty) filepath, if this is an import
1823 me->setFilePath (fn_org);
1826 // Finally check for errors and go home
1829 if (lmode==NewMap) fileCloseMap();
1830 statusBar()->message( "Could not load " + fn, statusbarTime );
1835 me->setFilePath (fn);
1836 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1837 if (fn.left(9)!="/tmp/vym-")
1839 // Only append to lastMaps if not loaded from a tmpDir
1840 // e.g. imported bookmarks are in a tmpDir
1841 addRecentMap(me->getFilePath() );
1843 actionFilePrint->setEnabled (true);
1845 statusBar()->message( "Loaded " + fn, statusbarTime );
1849 removeDir (QDir(tmpMapDir));
1855 void Main::fileLoad(const LoadMode &lmode)
1857 QStringList filters;
1858 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1859 QFileDialog *fd=new QFileDialog( this);
1860 fd->setDir (lastFileDir);
1861 fd->setFileMode (QFileDialog::ExistingFiles);
1862 fd->setFilters (filters);
1866 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1869 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1872 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1878 if ( fd->exec() == QDialog::Accepted )
1880 lastFileDir=fd->directory().path();
1881 QStringList flist = fd->selectedFiles();
1882 QStringList::Iterator it = flist.begin();
1883 while( it != flist.end() )
1886 fileLoad(*it, lmode);
1893 void Main::fileLoad()
1898 void Main::fileLoadRecent()
1900 QAction *action = qobject_cast<QAction *>(sender());
1902 fileLoad (action->data().toString(), NewMap);
1905 void Main::addRecentMap (const QString &fileName)
1908 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1909 files.removeAll(fileName);
1910 files.prepend(fileName);
1911 while (files.size() > MaxRecentFiles)
1914 settings.setValue("/mainwindow/recentFileList", files);
1916 setupRecentMapsMenu();
1919 void Main::fileSave(const SaveMode &savemode)
1921 // tmp dir for zipping
1925 ErrorCode err=success;
1927 QString safeFilePath;
1929 bool saveZipped=currentMapEditor()->saveZipped();
1931 MapEditor * me=currentMapEditor();
1934 QString fn=me->getFilePath();
1935 // filename=unnamed, filepath="" in constructor...
1936 if ( !fn.isEmpty() )
1938 // We have a filepath, go on saving
1939 // First remove existing file, we
1940 // don't want to add to old zip archives
1944 QMessageBox::warning( 0, tr( "Save Error" ),
1945 fn+ tr("\ncould not be removed before saving"));
1947 // Look, if we should zip the data:
1950 QMessageBox mb( vymName,
1951 tr("The map %1\ndid not use the compressed "
1952 "vym file format.\nWriting it uncompressed will also write images \n"
1953 "and flags and thus may overwrite files in the "
1954 "given directory\n\nDo you want to write the map").arg(fn),
1955 QMessageBox::Warning,
1956 QMessageBox::Yes | QMessageBox::Default,
1958 QMessageBox::Cancel | QMessageBox::Escape);
1959 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1960 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1961 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1964 case QMessageBox::Yes:
1965 // save compressed (default file format)
1968 case QMessageBox::No:
1969 // save uncompressed
1972 case QMessageBox::Cancel:
1981 // Create temporary directory for packing
1983 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1986 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1987 tr("Couldn't create temporary directory before save\n"));
1991 safeFilePath=me->getFilePath();
1992 me->setFilePath (tmpMapDir+"/"+
1993 me->getMapName()+ ".xml",
1995 me->save (savemode);
1996 me->setFilePath (safeFilePath);
1998 zipDir (tmpMapDir,fn);
2003 safeFilePath=me->getFilePath();
2004 me->setFilePath (fn, safeFilePath);
2005 me->save (savemode);
2006 me->setFilePath (safeFilePath);
2008 } // filepath available
2011 // We have no filepath yet,
2012 // call fileSaveAs() now, this will call fileSave()
2014 fileSaveAs(savemode);
2018 if (saveZipped && !tmpMapDir.isEmpty())
2020 removeDir (QDir(tmpMapDir));
2024 statusBar()->message(
2025 tr("Saved %1").arg(me->getFilePath()),
2027 addRecentMap (me->getFilePath() );
2029 statusBar()->message(
2030 tr("Couldn't save ").arg(me->getFilePath()),
2034 void Main::fileSave()
2036 fileSave (CompleteMap);
2039 void Main::fileSaveAs(const SaveMode& savemode)
2043 if (currentMapEditor())
2045 if (savemode==CompleteMap)
2046 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2048 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2049 if ( !fn.isEmpty() )
2051 // Check for existing file
2052 if (QFile (fn).exists())
2054 QMessageBox mb( vymName,
2055 tr("The file %1\nexists already. Do you want to").arg(fn),
2056 QMessageBox::Warning,
2057 QMessageBox::Yes | QMessageBox::Default,
2058 QMessageBox::Cancel | QMessageBox::Escape,
2059 QMessageBox::NoButton);
2060 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2061 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2064 case QMessageBox::Yes:
2067 case QMessageBox::Cancel:
2074 // New file, add extension to filename, if missing
2075 // This is always .vym or .vyp, depending on savemode
2076 if (savemode==CompleteMap)
2078 if (!fn.contains (".vym") && !fn.contains (".xml"))
2082 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2091 currentMapEditor()->setFilePath(fn);
2095 if (savemode==CompleteMap)
2096 tabWidget->setTabLabel (currentMapEditor(),
2097 currentMapEditor()->getFileName() );
2103 void Main::fileSaveAs()
2105 fileSaveAs (CompleteMap);
2108 void Main::fileImportKDEBookmarks()
2110 ImportKDEBookmarks im;
2112 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2113 currentMapEditor()->setFilePath ("");
2116 void Main::fileImportFirefoxBookmarks()
2118 Q3FileDialog *fd=new Q3FileDialog( this);
2119 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2120 fd->setMode (Q3FileDialog::ExistingFiles);
2121 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2122 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2125 if ( fd->exec() == QDialog::Accepted )
2127 ImportFirefoxBookmarks im;
2128 QStringList flist = fd->selectedFiles();
2129 QStringList::Iterator it = flist.begin();
2130 while( it != flist.end() )
2133 if (im.transform() &&
2134 success==fileLoad (im.getTransformedFile(),NewMap) &&
2135 currentMapEditor() )
2136 currentMapEditor()->setFilePath ("");
2143 void Main::fileImportMM()
2147 Q3FileDialog *fd=new Q3FileDialog( this);
2148 fd->setDir (lastFileDir);
2149 fd->setMode (Q3FileDialog::ExistingFiles);
2150 fd->addFilter ("Mind Manager (*.mmap)");
2151 fd->setCaption(tr("Import")+" "+"Mind Manager");
2154 if ( fd->exec() == QDialog::Accepted )
2156 lastFileDir=fd->dirPath();
2157 QStringList flist = fd->selectedFiles();
2158 QStringList::Iterator it = flist.begin();
2159 while( it != flist.end() )
2162 if (im.transform() &&
2163 success==fileLoad (im.getTransformedFile(),NewMap) &&
2164 currentMapEditor() )
2165 currentMapEditor()->setFilePath ("");
2174 void Main::fileImportDir()
2176 if (currentMapEditor())
2177 currentMapEditor()->importDir();
2180 void Main::fileExportXML()
2182 if (currentMapEditor())
2184 QString dir=browseDirectory(tr("Export XML to directory"));
2185 if (dir !="" && reallyWriteDirectory(dir) )
2186 currentMapEditor()->exportXML(dir);
2191 void Main::fileExportXHTML()
2193 MapEditor *me=currentMapEditor();
2197 ExportXHTMLDialog dia(this);
2198 dia.setFilePath (me->getFilePath() );
2199 dia.setMapName (me->getMapName() );
2202 if (dia.exec()==QDialog::Accepted)
2204 QString dir=dia.getDir();
2205 // Check, if warnings should be used before overwriting
2206 // the output directory
2209 ok=reallyWriteDirectory(dir);
2215 me->exportXML (dia.getDir() );
2216 dia.doExport(me->getMapName() );
2217 if (dia.hasChanged())
2224 void Main::fileExportImage()
2226 MapEditor *me=currentMapEditor();
2230 QFileDialog *fd=new QFileDialog (this);
2231 fd->setCaption (tr("Export map as image"));
2232 fd->setFileMode(QFileDialog::AnyFile);
2233 fd->setFilters (imageIO.getFilters() );
2234 fd->setDirectory (lastImageDir);
2237 fl=fd->selectedFiles();
2238 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2239 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2244 void Main::fileExportASCII()
2246 MapEditor *me=currentMapEditor();
2250 ex.setMapCenter(me->getMapCenter());
2251 ex.addFilter ("TXT (*.txt)");
2252 ex.setDir(lastImageDir);
2253 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2254 if (ex.execDialog() )
2256 me->setExportMode(true);
2258 me->setExportMode(false);
2263 void Main::fileExportLaTeX()
2265 MapEditor *me=currentMapEditor();
2269 ex.setMapCenter(me->getMapCenter());
2270 ex.addFilter ("Tex (*.tex)");
2271 ex.setDir(lastImageDir);
2272 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2273 if (ex.execDialog() )
2275 me->setExportMode(true);
2277 me->setExportMode(false);
2282 void Main::fileExportKDEBookmarks()
2284 ExportKDEBookmarks ex;
2285 MapEditor *me=currentMapEditor();
2288 ex.setMapCenter (me->getMapCenter() );
2293 void Main::fileExportTaskjuggler()
2295 ExportTaskjuggler ex;
2296 MapEditor *me=currentMapEditor();
2299 ex.setMapCenter (me->getMapCenter() );
2300 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2301 ex.setDir(lastImageDir);
2302 ex.addFilter ("Taskjuggler (*.tjp)");
2303 if (ex.execDialog() )
2305 me->setExportMode(true);
2307 me->setExportMode(false);
2312 void Main::fileExportOOPresentation()
2314 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2315 // TODO add preview in dialog
2316 //ImagePreview *p =new ImagePreview (fd);
2317 //fd->setContentsPreviewEnabled( TRUE );
2318 //fd->setContentsPreview( p, p );
2319 //fd->setPreviewMode( QFileDialog::Contents );
2320 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2321 fd->setDir (QDir().current());
2322 if (fd->foundConfig())
2326 if ( fd->exec() == QDialog::Accepted )
2328 QString fn=fd->selectedFile();
2329 if (!fn.contains (".odp"))
2332 //lastImageDir=fn.left(fn.findRev ("/"));
2333 if (currentMapEditor())
2334 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2338 QMessageBox::warning(0,
2340 tr("Couldn't find configuration for export to Open Office\n"));
2344 void Main::fileCloseMap()
2346 if (currentMapEditor())
2348 if (currentMapEditor()->hasChanged())
2350 QMessageBox mb( vymName,
2351 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2352 QMessageBox::Warning,
2353 QMessageBox::Yes | QMessageBox::Default,
2355 QMessageBox::Cancel | QMessageBox::Escape );
2356 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2357 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2360 case QMessageBox::Yes:
2362 fileSave(CompleteMap);
2364 case QMessageBox::No:
2365 // close without saving
2367 case QMessageBox::Cancel:
2372 currentMapEditor()->closeMap();
2373 tabWidget->removePage(currentMapEditor());
2374 if (tabWidget->count()==0)
2375 actionFilePrint->setEnabled (false);
2379 void Main::filePrint()
2381 if (currentMapEditor())
2382 currentMapEditor()->print();
2385 void Main::fileExitVYM()
2387 // Check if one or more editors have changed
2390 for (i=0;i<=tabWidget->count() -1;i++)
2393 me=(MapEditor*)tabWidget->page(i);
2395 // If something changed, ask what to do
2396 if (me->isUnsaved())
2398 tabWidget->setCurrentPage(i);
2399 QMessageBox mb( vymName,
2400 tr("This map is not saved yet. Do you want to"),
2401 QMessageBox::Warning,
2402 QMessageBox::Yes | QMessageBox::Default,
2404 QMessageBox::Cancel | QMessageBox::Escape );
2405 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2406 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2409 mb.setActiveWindow();
2410 switch( mb.exec() ) {
2411 case QMessageBox::Yes:
2412 // save (the changed editors) and exit
2413 fileSave(CompleteMap);
2415 case QMessageBox::No:
2416 // exit without saving
2418 case QMessageBox::Cancel:
2419 // don't save and don't exit
2423 } // loop over all MEs
2427 void Main::editUndo()
2429 if (currentMapEditor())
2430 currentMapEditor()->undo();
2433 void Main::editRedo()
2435 if (currentMapEditor())
2436 currentMapEditor()->redo();
2439 void Main::gotoHistoryStep (int i)
2441 if (currentMapEditor())
2442 currentMapEditor()->gotoHistoryStep (i);
2445 void Main::editCopy()
2447 if (currentMapEditor())
2448 currentMapEditor()->copy();
2451 void Main::editPaste()
2453 if (currentMapEditor())
2454 currentMapEditor()->paste();
2457 void Main::editCut()
2459 if (currentMapEditor())
2460 currentMapEditor()->cut();
2463 void Main::editOpenFindWindow()
2465 findWindow->popup();
2466 findWindow->raise();
2467 findWindow->setActiveWindow();
2470 void Main::editFind(QString s)
2473 BranchObj *bo=currentMapEditor()->findText(s, cs);
2476 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2479 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2480 tr("No matches found for \"%1\"").arg(s));
2484 void Main::editFindChanged()
2485 { // Notify editor, to abort the current find process
2486 currentMapEditor()->findReset();
2489 void Main::openTabs(QStringList urls)
2491 if (!urls.isEmpty())
2495 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2497 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2499 QString u=urls.takeFirst();
2500 procBrowser = new QProcess( this );
2502 procBrowser->start(browser,args);
2503 if ( !procBrowser->waitForStarted())
2505 // try to set path to browser
2506 QMessageBox::warning(0,
2508 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2509 tr("Please use Settings->")+tr("Set application to open an URL"));
2514 if (browser.contains("konqueror"))
2516 for (int i=0; i<urls.size(); i++)
2519 // Try to open new tab in existing konqueror started previously by vym
2520 p=new QProcess (this);
2522 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2523 "konqueror-mainwindow#1"<<
2526 p->start ("dcop",args);
2527 if ( !p->waitForStarted() ) success=false;
2530 QMessageBox::warning(0,
2532 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2534 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2536 for (int i=0; i<urls.size(); i++)
2538 // Try to open new tab in firefox
2539 p=new QProcess (this);
2540 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2541 p->start (browser,args);
2542 if ( !p->waitForStarted() ) success=false;
2545 QMessageBox::warning(0,
2547 tr("Couldn't start %1 to open a new tab").arg(browser));
2550 QMessageBox::warning(0,
2552 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2556 void Main::editOpenURL()
2559 if (currentMapEditor())
2561 QString url=currentMapEditor()->getURL();
2563 if (url=="") return;
2564 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2565 procBrowser = new QProcess( this );
2567 procBrowser->start(browser,args);
2568 if ( !procBrowser->waitForStarted())
2570 // try to set path to browser
2571 QMessageBox::warning(0,
2573 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2574 tr("Please use Settings->")+tr("Set application to open an URL"));
2579 void Main::editOpenURLTab()
2581 if (currentMapEditor())
2584 urls.append(currentMapEditor()->getURL());
2588 void Main::editOpenMultipleURLTabs()
2590 if (currentMapEditor())
2593 urls=currentMapEditor()->getURLs();
2599 void Main::editURL()
2601 if (currentMapEditor())
2602 currentMapEditor()->editURL();
2605 void Main::editHeading2URL()
2607 if (currentMapEditor())
2608 currentMapEditor()->editHeading2URL();
2611 void Main::editBugzilla2URL()
2613 if (currentMapEditor())
2614 currentMapEditor()->editBugzilla2URL();
2617 void Main::editFATE2URL()
2619 if (currentMapEditor())
2620 currentMapEditor()->editFATE2URL();
2623 void Main::editHeadingFinished()
2625 // only called from editHeading(), so there is a currentME
2626 MapEditor *me=currentMapEditor();
2629 QPoint p; //Not used here, only to find out pos of branch
2631 QString s=me->getHeading(ok,p);
2633 #if defined(Q_OS_MACX)
2635 if (ok && s!=lineedit->text())
2636 me->setHeading(lineedit->text());
2638 lineedit->releaseKeyboard();
2642 if (!prevSelection.isEmpty()) me->select(prevSelection);
2647 void Main::editHeading()
2649 if (currentMapEditor())
2651 MapEditor *me=currentMapEditor();
2652 QString oldSel=me->getSelectString();
2654 if (lineedit->isVisible())
2655 editHeadingFinished();
2660 QString s=currentMapEditor()->getHeading(ok,p);
2664 #if defined(Q_OS_MACX)
2665 p=currentMapEditor()->mapTo (this,p);
2666 QDialog *d =new QDialog(NULL);
2667 QLineEdit *le=new QLineEdit (d);
2668 d->setWindowFlags (Qt::FramelessWindowHint);
2669 d->setGeometry(p.x(),p.y(),230,25);
2670 le->resize (d->width()-10,d->height());
2673 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2674 d->activateWindow();
2676 currentMapEditor()->setHeading (le->text());
2679 editHeadingFinished();
2681 p=currentMapEditor()->mapTo (this,p);
2682 lineedit->setGeometry(p.x(),p.y(),230,25);
2683 lineedit->setText(s);
2684 lineedit->setCursorPosition(1);
2685 lineedit->selectAll();
2687 lineedit->grabKeyboard();
2688 lineedit->setFocus();
2692 } // currentMapEditor()
2695 void Main::openVymLinks(const QStringList &vl)
2697 for (int j=0; j<vl.size(); j++)
2699 // compare path with already loaded maps
2703 for (i=0;i<=tabWidget->count() -1;i++)
2705 me=(MapEditor*)tabWidget->page(i);
2706 if (vl.at(j)==me->getFilePath() )
2715 if (!QFile(vl.at(j)).exists() )
2716 QMessageBox::critical( 0, tr( "Critical Error" ),
2717 tr("Couldn't open map %1").arg(vl.at(j)));
2720 fileLoad (vl.at(j), NewMap);
2721 tabWidget->setCurrentPage (tabWidget->count()-1);
2724 // Go to tab containing the map
2725 tabWidget->setCurrentPage (index);
2729 void Main::editOpenVymLink()
2731 if (currentMapEditor())
2734 vl.append(currentMapEditor()->getVymLink());
2739 void Main::editOpenMultipleVymLinks()
2741 QString currentVymLink;
2742 if (currentMapEditor())
2744 QStringList vl=currentMapEditor()->getVymLinks();
2749 void Main::editVymLink()
2751 if (currentMapEditor())
2752 currentMapEditor()->editVymLink();
2755 void Main::editDeleteVymLink()
2757 if (currentMapEditor())
2758 currentMapEditor()->deleteVymLink();
2761 void Main::editToggleHideExport()
2763 if (currentMapEditor())
2764 currentMapEditor()->toggleHideExport();
2767 void Main::editMapInfo()
2769 if (currentMapEditor())
2770 currentMapEditor()->editMapInfo();
2773 void Main::editMoveUp()
2775 if (currentMapEditor())
2776 currentMapEditor()->moveBranchUp();
2779 void Main::editMoveDown()
2781 if (currentMapEditor())
2782 currentMapEditor()->moveBranchDown();
2785 void Main::editToggleScroll()
2787 if (currentMapEditor())
2789 currentMapEditor()->toggleScroll();
2793 void Main::editUnScrollAll()
2795 if (currentMapEditor())
2796 currentMapEditor()->unscrollChilds();
2799 void Main::editNewBranch()
2801 MapEditor *me=currentMapEditor();
2802 if (!lineedit->isVisible() && me)
2804 BranchObj *bo=(BranchObj*)me->getSelection();
2805 BranchObj *newbo=me->addNewBranch(0);
2808 me->select (newbo->getSelectString());
2812 if (actionSettingsAutoEdit->isOn())
2814 if (!actionSettingsAutoSelectHeading->isOn())
2815 prevSelection=bo->getSelectString();
2821 void Main::editNewBranchBefore()
2823 MapEditor *me=currentMapEditor();
2824 if (!lineedit->isVisible() && me)
2826 BranchObj *bo=(BranchObj*)me->getSelection();
2827 BranchObj *newbo=me->addNewBranchBefore();
2830 me->select (newbo->getSelectString());
2834 if (actionSettingsAutoEdit->isOn())
2836 if (!actionSettingsAutoSelectHeading->isOn())
2837 prevSelection=bo->getSelectString();
2843 void Main::editNewBranchAbove()
2845 MapEditor *me=currentMapEditor();
2846 if (!lineedit->isVisible() && me)
2848 BranchObj *bo=(BranchObj*)me->getSelection();
2849 BranchObj *newbo=me->addNewBranch (-1);
2852 me->select (newbo->getSelectString());
2856 if (actionSettingsAutoEdit->isOn())
2858 if (!actionSettingsAutoSelectHeading->isOn())
2859 prevSelection=bo->getSelectString();
2865 void Main::editNewBranchBelow()
2867 MapEditor *me=currentMapEditor();
2868 if (!lineedit->isVisible() && me)
2870 BranchObj *bo=(BranchObj*)me->getSelection();
2871 BranchObj *newbo=me->addNewBranch (1);
2874 me->select (newbo->getSelectString());
2878 if (actionSettingsAutoEdit->isOn())
2880 if (!actionSettingsAutoSelectHeading->isOn())
2881 prevSelection=bo->getSelectString();
2887 void Main::editImportAdd()
2889 fileLoad (ImportAdd);
2892 void Main::editImportReplace()
2894 fileLoad (ImportReplace);
2897 void Main::editSaveBranch()
2899 fileSaveAs (PartOfMap);
2902 void Main::editDeleteKeepChilds()
2904 if (currentMapEditor())
2905 currentMapEditor()->deleteKeepChilds();
2908 void Main::editDeleteChilds()
2910 if (currentMapEditor())
2911 currentMapEditor()->deleteChilds();
2914 void Main::editDeleteSelection()
2916 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2917 currentMapEditor()->deleteSelection();
2920 void Main::editUpperBranch()
2922 if (currentMapEditor())
2923 currentMapEditor()->selectUpperBranch();
2926 void Main::editLowerBranch()
2928 if (currentMapEditor())
2929 currentMapEditor()->selectLowerBranch();
2932 void Main::editLeftBranch()
2934 if (currentMapEditor())
2935 currentMapEditor()->selectLeftBranch();
2938 void Main::editRightBranch()
2940 if (currentMapEditor())
2941 currentMapEditor()->selectRightBranch();
2944 void Main::editFirstBranch()
2946 if (currentMapEditor())
2947 currentMapEditor()->selectFirstBranch();
2950 void Main::editLastBranch()
2952 if (currentMapEditor())
2953 currentMapEditor()->selectLastBranch();
2956 void Main::editLoadImage()
2958 if (currentMapEditor())
2959 currentMapEditor()->loadFloatImage();
2962 void Main::editSaveImage()
2964 if (currentMapEditor())
2965 currentMapEditor()->saveFloatImage();
2968 void Main::editFollowXLink(QAction *a)
2971 if (currentMapEditor())
2972 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2975 void Main::editEditXLink(QAction *a)
2977 if (currentMapEditor())
2978 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2981 void Main::formatSelectColor()
2983 if (currentMapEditor())
2985 QColor col = QColorDialog::getColor((currentColor ), this );
2986 if ( !col.isValid() ) return;
2987 colorChanged( col );
2991 void Main::formatPickColor()
2993 if (currentMapEditor())
2994 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
2997 void Main::colorChanged(QColor c)
2999 QPixmap pix( 16, 16 );
3001 actionFormatColor->setIconSet( pix );
3005 void Main::formatColorBranch()
3007 if (currentMapEditor())
3008 currentMapEditor()->colorBranch(currentColor);
3011 void Main::formatColorSubtree()
3013 if (currentMapEditor())
3014 currentMapEditor()->colorSubtree (currentColor);
3017 void Main::formatLinkStyleLine()
3019 if (currentMapEditor())
3020 currentMapEditor()->setMapLinkStyle("StyleLine");
3023 void Main::formatLinkStyleParabel()
3025 if (currentMapEditor())
3026 currentMapEditor()->setMapLinkStyle("StyleParabel");
3029 void Main::formatLinkStylePolyLine()
3031 if (currentMapEditor())
3032 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3035 void Main::formatLinkStylePolyParabel()
3037 if (currentMapEditor())
3038 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3041 void Main::formatSelectBackColor()
3043 if (currentMapEditor())
3044 currentMapEditor()->selectMapBackgroundColor();
3047 void Main::formatSelectBackImage()
3049 if (currentMapEditor())
3050 currentMapEditor()->selectMapBackgroundImage();
3053 void Main::formatSelectLinkColor()
3055 if (currentMapEditor())
3056 currentMapEditor()->selectMapLinkColor();
3059 void Main::formatToggleLinkColorHint()
3061 currentMapEditor()->toggleMapLinkColorHint();
3065 void Main::formatIncludeImagesVer()
3067 if (currentMapEditor())
3068 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3071 void Main::formatIncludeImagesHor()
3073 if (currentMapEditor())
3074 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3077 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3079 if (currentMapEditor())
3080 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3083 void Main::viewZoomReset()
3085 if (currentMapEditor())
3089 currentMapEditor()->setMatrix( m );
3093 void Main::viewZoomIn()
3095 if (currentMapEditor())
3097 QMatrix m = currentMapEditor()->matrix();
3098 m.scale( 1.25, 1.25 );
3099 currentMapEditor()->setMatrix( m );
3103 void Main::viewZoomOut()
3105 if (currentMapEditor())
3107 QMatrix m = currentMapEditor()->matrix();
3108 m.scale( 0.8, 0.8 );
3109 currentMapEditor()->setMatrix( m );
3113 bool Main::settingsPDF()
3115 // Default browser is set in constructor
3117 QString text = QInputDialog::getText(
3118 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3119 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3121 settings.setValue ("/mainwindow/readerPDF",text);
3126 bool Main::settingsURL()
3128 // Default browser is set in constructor
3130 QString text = QInputDialog::getText(
3131 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3132 settings.value("/mainwindow/readerURL").toString()
3135 settings.setValue ("/mainwindow/readerURL",text);
3139 void Main::settingsToggleDelKey()
3141 if (actionSettingsUseDelKey->isOn())
3143 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3146 actionEditDelete->setAccel (QKeySequence (""));
3150 void Main::windowToggleNoteEditor()
3152 if (textEditor->showWithMain() )
3153 windowHideNoteEditor();
3155 windowShowNoteEditor();
3158 void Main::windowToggleHistory()
3160 if (historyWindow->isVisible())
3161 historyWindow->hide();
3163 historyWindow->show();
3167 void Main::windowToggleAntiAlias()
3169 bool b=actionViewToggleAntiAlias->isOn();
3171 for (int i=0;i<tabWidget->count();i++)
3174 me=(MapEditor*)tabWidget->page(i);
3175 me->setAntiAlias(b);
3180 void Main::windowToggleSmoothPixmap()
3182 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3184 for (int i=0;i<tabWidget->count();i++)
3187 me=(MapEditor*)tabWidget->page(i);
3188 me->setSmoothPixmap(b);
3192 void Main::updateHistory(SimpleSettings &undoSet)
3194 historyWindow->update (undoSet);
3197 void Main::updateNoteFlag()
3199 if (currentMapEditor())
3200 currentMapEditor()->updateNoteFlag();
3203 void Main::updateActions()
3205 MapEditor *me=currentMapEditor();
3208 historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
3210 // updateActions is also called when NoteEditor is closed
3211 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3213 if (me->getMapLinkColorHint()==HeadingColor)
3214 actionFormatLinkColorHint->setOn(true);
3216 actionFormatLinkColorHint->setOn(false);
3218 switch (me->getMapLinkStyle())
3221 actionFormatLinkStyleLine->setOn(true);
3224 actionFormatLinkStyleParabel->setOn(true);
3227 actionFormatLinkStylePolyLine->setOn(true);
3229 case StylePolyParabel:
3230 actionFormatLinkStylePolyParabel->setOn(true);
3236 QPixmap pix( 16, 16 );
3237 pix.fill( me->getMapBackgroundColor() );
3238 actionFormatBackColor->setIconSet( pix );
3239 pix.fill( me->getMapDefLinkColor() );
3240 actionFormatLinkColor->setIconSet( pix );
3242 actionFileSave->setEnabled( me->isUnsaved() );
3243 if (me->isUndoAvailable())
3244 actionEditUndo->setEnabled( true);
3246 actionEditUndo->setEnabled( false);
3248 if (me->isRedoAvailable())
3249 actionEditRedo->setEnabled( true);
3251 actionEditRedo->setEnabled( false);
3253 LinkableMapObj *selection=me->getSelection();
3256 if ( (typeid(*selection) == typeid(BranchObj)) ||
3257 (typeid(*selection) == typeid(MapCenterObj)) )
3259 BranchObj *bo=(BranchObj*)selection;
3260 // Take care of links
3261 if (bo->countXLinks()==0)
3263 branchXLinksContextMenuEdit->clear();
3264 branchXLinksContextMenuFollow->clear();
3269 branchXLinksContextMenuEdit->clear();
3270 branchXLinksContextMenuFollow->clear();
3271 for (int i=0; i<=bo->countXLinks();i++)
3273 bot=bo->XLinkTargetAt(i);
3276 s=bot->getHeading();
3279 branchXLinksContextMenuFollow->addAction (s);
3280 branchXLinksContextMenuEdit->addAction (s);
3285 standardFlagsDefault->setEnabled (true);
3287 actionEditToggleScroll->setEnabled (true);
3288 if ( bo->isScrolled() )
3289 actionEditToggleScroll->setOn(true);
3291 actionEditToggleScroll->setOn(false);
3293 if ( bo->getURL().isEmpty() )
3295 actionEditOpenURL->setEnabled (false);
3296 actionEditOpenURLTab->setEnabled (false);
3300 actionEditOpenURL->setEnabled (true);
3301 actionEditOpenURLTab->setEnabled (true);
3303 if ( bo->getVymLink().isEmpty() )
3305 actionEditOpenVymLink->setEnabled (false);
3306 actionEditDeleteVymLink->setEnabled (false);
3309 actionEditOpenVymLink->setEnabled (true);
3310 actionEditDeleteVymLink->setEnabled (true);
3313 if (bo->canMoveBranchUp())
3314 actionEditMoveUp->setEnabled (true);
3316 actionEditMoveUp->setEnabled (false);
3317 if (bo->canMoveBranchDown())
3318 actionEditMoveDown->setEnabled (true);
3320 actionEditMoveDown->setEnabled (false);
3323 actionEditToggleHideExport->setEnabled (true);
3324 actionEditToggleHideExport->setOn (bo->hideInExport() );
3326 actionEditCopy->setEnabled (true);
3327 actionEditCut->setEnabled (true);
3328 if (!clipboardEmpty)
3329 actionEditPaste->setEnabled (true);
3331 actionEditPaste->setEnabled (false);
3332 for (int i=0; i<actionListBranches.size(); ++i)
3333 actionListBranches.at(i)->setEnabled(true);
3334 actionEditDelete->setEnabled (true);
3335 actionFormatIncludeImagesVer->setOn
3336 ( ((BranchObj*)selection)->getIncludeImagesVer());
3337 actionFormatIncludeImagesHor->setOn
3338 ( ((BranchObj*)selection)->getIncludeImagesHor());
3339 actionFormatHideLinkUnselected->setOn
3340 (selection->getHideLinkUnselected());
3342 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3344 FloatObj *fo=(FloatImageObj*)selection;
3346 actionEditOpenURL->setEnabled (false);
3347 actionEditOpenVymLink->setEnabled (false);
3348 actionEditDeleteVymLink->setEnabled (false);
3349 actionEditToggleHideExport->setEnabled (true);
3350 actionEditToggleHideExport->setOn (fo->hideInExport() );
3353 actionEditCopy->setEnabled (true);
3354 actionEditCut->setEnabled (true);
3355 actionEditPaste->setEnabled (false);
3356 for (int i=0; i<actionListBranches.size(); ++i)
3357 actionListBranches.at(i)->setEnabled(false);
3358 actionEditDelete->setEnabled (true);
3359 actionFormatHideLinkUnselected->setOn
3360 ( selection->getHideLinkUnselected());
3361 actionEditMoveUp->setEnabled (false);
3362 actionEditMoveDown->setEnabled (false);
3367 actionEditCopy->setEnabled (false);
3368 actionEditCut->setEnabled (false);
3369 actionEditPaste->setEnabled (false);
3370 for (int i=0; i<actionListBranches.size(); ++i)
3371 actionListBranches.at(i)->setEnabled(false);
3373 actionEditToggleScroll->setEnabled (false);
3374 actionEditOpenURL->setEnabled (false);
3375 actionEditOpenVymLink->setEnabled (false);
3376 actionEditDeleteVymLink->setEnabled (false);
3377 actionEditHeading2URL->setEnabled (false);
3378 actionEditDelete->setEnabled (false);
3379 actionEditMoveUp->setEnabled (false);
3380 actionEditMoveDown->setEnabled (false);
3381 actionEditToggleHideExport->setEnabled (false);
3385 ModMode Main::getModMode()
3387 if (actionModModeColor->isOn()) return ModModeColor;
3388 if (actionModModeCopy->isOn()) return ModModeCopy;
3389 if (actionModModeXLink->isOn()) return ModModeXLink;
3393 bool Main::autoEdit()
3395 return actionSettingsAutoEdit->isOn();
3398 bool Main::autoSelectHeading()
3400 return actionSettingsAutoSelectHeading->isOn();
3403 bool Main::useFlagGroups()
3405 return actionSettingsUseFlagGroups->isOn();
3408 void Main::windowShowNoteEditor()
3410 textEditor->setShowWithMain(true);
3412 actionViewToggleNoteEditor->setOn (true);
3415 void Main::windowHideNoteEditor()
3417 textEditor->setShowWithMain(false);
3419 actionViewToggleNoteEditor->setOn (false);
3422 void Main::showPropertyDialog()
3424 if(currentMapEditor())
3426 LinkableMapObj *sel=currentMapEditor()->getSelection();
3427 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3428 typeid(*sel) == typeid(MapCenterObj)))
3430 branchPropertyWindow->show();
3431 branchPropertyWindow->setMapEditor(currentMapEditor());
3432 branchPropertyWindow->setBranch((BranchObj*)sel);
3437 branchPropertyWindow->setBranch(NULL);
3440 void Main::windowNextEditor()
3442 if (tabWidget->currentPageIndex() < tabWidget->count())
3443 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3446 void Main::windowPreviousEditor()
3448 if (tabWidget->currentPageIndex() >0)
3449 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3452 void Main::standardFlagChanged()
3454 if (currentMapEditor())
3455 currentMapEditor()->toggleStandardFlag(sender()->name());
3458 void Main::testFunction()
3460 if (!currentMapEditor()) return;
3461 currentMapEditor()->testFunction();
3464 void Main::testCommand()
3466 if (!currentMapEditor()) return;
3468 QString com = QInputDialog::getText(
3469 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3470 if (ok) currentMapEditor()->parseAtom(com);
3473 void Main::helpDoc()
3475 QString locale = QLocale::system().name();
3477 if (locale.left(2)=="es")
3478 docname="vym_es.pdf";
3482 QStringList searchList;
3484 #if defined(Q_OS_MACX)
3485 searchList << "./vym.app/Contents";
3487 // default path in SUSE LINUX
3488 searchList <<"/usr/share/doc/packages/vym/doc";
3491 searchList << "doc"; // relative path for easy testing in tarball
3492 searchList << "doc/tex"; // Easy testing working on vym.tex
3493 searchList << "/usr/share/doc/vym"; // Debian
3494 searchList << "/usr/share/doc/packages";// Knoppix
3498 for (int i=0; i<searchList.count(); ++i)
3500 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3501 if (docfile.exists() )
3510 QMessageBox::critical(0,
3511 tr("Critcal error"),
3512 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3517 Process *pdfProc = new Process();
3518 args <<docfile.fileName();
3520 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3521 if ( !pdfProc->waitForStarted() )
3524 QMessageBox::warning(0,
3526 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3527 tr("Please use Settings->")+tr("Set application to open PDF files"));
3534 void Main::helpAbout()
3537 ad.setName ("aboutwindow");
3538 ad.setMinimumSize(500,500);
3539 ad.resize (QSize (500,500));
3543 void Main::helpAboutQT()
3545 QMessageBox::aboutQt( this, "Qt Application Example" );