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 some 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.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2253 if (ex.execDialog() )
2255 me->setExportMode(true);
2257 me->setExportMode(false);
2262 void Main::fileExportLaTeX()
2264 MapEditor *me=currentMapEditor();
2268 ex.setMapCenter(me->getMapCenter());
2269 ex.addFilter ("Tex (*.tex)");
2270 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2271 if (ex.execDialog() )
2273 me->setExportMode(true);
2275 me->setExportMode(false);
2280 void Main::fileExportKDEBookmarks()
2282 ExportKDEBookmarks ex;
2283 MapEditor *me=currentMapEditor();
2286 ex.setMapCenter (me->getMapCenter() );
2291 void Main::fileExportTaskjuggler()
2293 ExportTaskjuggler ex;
2294 MapEditor *me=currentMapEditor();
2297 ex.setMapCenter (me->getMapCenter() );
2298 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2299 ex.addFilter ("Taskjuggler (*.tjp)");
2300 if (ex.execDialog() )
2302 me->setExportMode(true);
2304 me->setExportMode(false);
2309 void Main::fileExportOOPresentation()
2311 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2312 // TODO add preview in dialog
2313 //ImagePreview *p =new ImagePreview (fd);
2314 //fd->setContentsPreviewEnabled( TRUE );
2315 //fd->setContentsPreview( p, p );
2316 //fd->setPreviewMode( QFileDialog::Contents );
2317 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2318 fd->setDir (QDir().current());
2319 if (fd->foundConfig())
2323 if ( fd->exec() == QDialog::Accepted )
2325 QString fn=fd->selectedFile();
2326 if (!fn.contains (".odp"))
2329 //lastImageDir=fn.left(fn.findRev ("/"));
2330 if (currentMapEditor())
2331 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2335 QMessageBox::warning(0,
2337 tr("Couldn't find configuration for export to Open Office\n"));
2341 void Main::fileCloseMap()
2343 if (currentMapEditor())
2345 if (currentMapEditor()->hasChanged())
2347 QMessageBox mb( vymName,
2348 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2349 QMessageBox::Warning,
2350 QMessageBox::Yes | QMessageBox::Default,
2352 QMessageBox::Cancel | QMessageBox::Escape );
2353 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2354 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2357 case QMessageBox::Yes:
2359 fileSave(CompleteMap);
2361 case QMessageBox::No:
2362 // close without saving
2364 case QMessageBox::Cancel:
2369 currentMapEditor()->closeMap();
2370 tabWidget->removePage(currentMapEditor());
2371 if (tabWidget->count()==0)
2372 actionFilePrint->setEnabled (false);
2376 void Main::filePrint()
2378 if (currentMapEditor())
2379 currentMapEditor()->print();
2382 void Main::fileExitVYM()
2384 // Check if one or more editors have changed
2387 for (i=0;i<=tabWidget->count() -1;i++)
2390 me=(MapEditor*)tabWidget->page(i);
2392 // If something changed, ask what to do
2393 if (me->isUnsaved())
2395 tabWidget->setCurrentPage(i);
2396 QMessageBox mb( vymName,
2397 tr("This map is not saved yet. Do you want to"),
2398 QMessageBox::Warning,
2399 QMessageBox::Yes | QMessageBox::Default,
2401 QMessageBox::Cancel | QMessageBox::Escape );
2402 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2403 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2406 mb.setActiveWindow();
2407 switch( mb.exec() ) {
2408 case QMessageBox::Yes:
2409 // save (the changed editors) and exit
2410 fileSave(CompleteMap);
2412 case QMessageBox::No:
2413 // exit without saving
2415 case QMessageBox::Cancel:
2416 // don't save and don't exit
2420 } // loop over all MEs
2424 void Main::editUndo()
2426 if (currentMapEditor())
2427 currentMapEditor()->undo();
2430 void Main::editRedo()
2432 if (currentMapEditor())
2433 currentMapEditor()->redo();
2436 void Main::gotoHistoryStep (int i)
2438 if (currentMapEditor())
2439 currentMapEditor()->gotoHistoryStep (i);
2442 void Main::editCopy()
2444 if (currentMapEditor())
2445 currentMapEditor()->copy();
2448 void Main::editPaste()
2450 if (currentMapEditor())
2451 currentMapEditor()->paste();
2454 void Main::editCut()
2456 if (currentMapEditor())
2457 currentMapEditor()->cut();
2460 void Main::editOpenFindWindow()
2462 findWindow->popup();
2463 findWindow->raise();
2464 findWindow->setActiveWindow();
2467 void Main::editFind(QString s)
2470 BranchObj *bo=currentMapEditor()->findText(s, cs);
2473 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2476 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2477 tr("No matches found for \"%1\"").arg(s));
2481 void Main::editFindChanged()
2482 { // Notify editor, to abort the current find process
2483 currentMapEditor()->findReset();
2486 void Main::openTabs(QStringList urls)
2488 if (!urls.isEmpty())
2492 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2494 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2496 QString u=urls.takeFirst();
2497 procBrowser = new QProcess( this );
2499 procBrowser->start(browser,args);
2500 if ( !procBrowser->waitForStarted())
2502 // try to set path to browser
2503 QMessageBox::warning(0,
2505 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2506 tr("Please use Settings->")+tr("Set application to open an URL"));
2511 if (browser.contains("konqueror"))
2513 for (int i=0; i<urls.size(); i++)
2516 // Try to open new tab in existing konqueror started previously by vym
2517 p=new QProcess (this);
2519 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2520 "konqueror-mainwindow#1"<<
2523 p->start ("dcop",args);
2524 if ( !p->waitForStarted() ) success=false;
2527 QMessageBox::warning(0,
2529 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2531 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2533 for (int i=0; i<urls.size(); i++)
2535 // Try to open new tab in firefox
2536 p=new QProcess (this);
2537 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2538 p->start (browser,args);
2539 if ( !p->waitForStarted() ) success=false;
2542 QMessageBox::warning(0,
2544 tr("Couldn't start %1 to open a new tab").arg(browser));
2547 QMessageBox::warning(0,
2549 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2553 void Main::editOpenURL()
2556 if (currentMapEditor())
2558 QString url=currentMapEditor()->getURL();
2560 if (url=="") return;
2561 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2562 procBrowser = new QProcess( this );
2564 procBrowser->start(browser,args);
2565 if ( !procBrowser->waitForStarted())
2567 // try to set path to browser
2568 QMessageBox::warning(0,
2570 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2571 tr("Please use Settings->")+tr("Set application to open an URL"));
2576 void Main::editOpenURLTab()
2578 if (currentMapEditor())
2581 urls.append(currentMapEditor()->getURL());
2585 void Main::editOpenMultipleURLTabs()
2587 if (currentMapEditor())
2590 urls=currentMapEditor()->getURLs();
2596 void Main::editURL()
2598 if (currentMapEditor())
2599 currentMapEditor()->editURL();
2602 void Main::editHeading2URL()
2604 if (currentMapEditor())
2605 currentMapEditor()->editHeading2URL();
2608 void Main::editBugzilla2URL()
2610 if (currentMapEditor())
2611 currentMapEditor()->editBugzilla2URL();
2614 void Main::editFATE2URL()
2616 if (currentMapEditor())
2617 currentMapEditor()->editFATE2URL();
2620 void Main::editHeadingFinished()
2622 // only called from editHeading(), so there is a currentME
2623 MapEditor *me=currentMapEditor();
2626 QPoint p; //Not used here, only to find out pos of branch
2628 QString s=me->getHeading(ok,p);
2630 #if defined(Q_OS_MACX)
2632 if (ok && s!=lineedit->text())
2633 me->setHeading(lineedit->text());
2635 lineedit->releaseKeyboard();
2639 if (!prevSelection.isEmpty()) me->select(prevSelection);
2644 void Main::editHeading()
2646 if (currentMapEditor())
2648 MapEditor *me=currentMapEditor();
2649 QString oldSel=me->getSelectString();
2651 if (lineedit->isVisible())
2652 editHeadingFinished();
2657 QString s=currentMapEditor()->getHeading(ok,p);
2661 #if defined(Q_OS_MACX)
2662 p=currentMapEditor()->mapTo (this,p);
2663 QDialog *d =new QDialog(NULL);
2664 QLineEdit *le=new QLineEdit (d);
2665 d->setWindowFlags (Qt::FramelessWindowHint);
2666 d->setGeometry(p.x(),p.y(),230,25);
2667 le->resize (d->width()-10,d->height());
2670 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2671 d->activateWindow();
2673 currentMapEditor()->setHeading (le->text());
2676 editHeadingFinished();
2678 p=currentMapEditor()->mapTo (this,p);
2679 lineedit->setGeometry(p.x(),p.y(),230,25);
2680 lineedit->setText(s);
2681 lineedit->setCursorPosition(1);
2682 lineedit->selectAll();
2684 lineedit->grabKeyboard();
2685 lineedit->setFocus();
2689 } // currentMapEditor()
2692 void Main::openVymLinks(const QStringList &vl)
2694 for (int j=0; j<vl.size(); j++)
2696 // compare path with already loaded maps
2700 for (i=0;i<=tabWidget->count() -1;i++)
2702 me=(MapEditor*)tabWidget->page(i);
2703 if (vl.at(j)==me->getFilePath() )
2712 if (!QFile(vl.at(j)).exists() )
2713 QMessageBox::critical( 0, tr( "Critical Error" ),
2714 tr("Couldn't open map %1").arg(vl.at(j)));
2717 fileLoad (vl.at(j), NewMap);
2718 tabWidget->setCurrentPage (tabWidget->count()-1);
2721 // Go to tab containing the map
2722 tabWidget->setCurrentPage (index);
2726 void Main::editOpenVymLink()
2728 if (currentMapEditor())
2731 vl.append(currentMapEditor()->getVymLink());
2736 void Main::editOpenMultipleVymLinks()
2738 QString currentVymLink;
2739 if (currentMapEditor())
2741 QStringList vl=currentMapEditor()->getVymLinks();
2746 void Main::editVymLink()
2748 if (currentMapEditor())
2749 currentMapEditor()->editVymLink();
2752 void Main::editDeleteVymLink()
2754 if (currentMapEditor())
2755 currentMapEditor()->deleteVymLink();
2758 void Main::editToggleHideExport()
2760 if (currentMapEditor())
2761 currentMapEditor()->toggleHideExport();
2764 void Main::editMapInfo()
2766 if (currentMapEditor())
2767 currentMapEditor()->editMapInfo();
2770 void Main::editMoveUp()
2772 if (currentMapEditor())
2773 currentMapEditor()->moveBranchUp();
2776 void Main::editMoveDown()
2778 if (currentMapEditor())
2779 currentMapEditor()->moveBranchDown();
2782 void Main::editToggleScroll()
2784 if (currentMapEditor())
2786 currentMapEditor()->toggleScroll();
2790 void Main::editUnScrollAll()
2792 if (currentMapEditor())
2793 currentMapEditor()->unScrollAll();
2796 void Main::editNewBranch()
2798 MapEditor *me=currentMapEditor();
2799 if (!lineedit->isVisible() && me)
2801 BranchObj *bo=(BranchObj*)me->getSelection();
2802 BranchObj *newbo=me->addNewBranch(0);
2805 me->select (newbo->getSelectString());
2809 if (actionSettingsAutoEdit->isOn())
2811 if (!actionSettingsAutoSelectHeading->isOn())
2812 prevSelection=bo->getSelectString();
2818 void Main::editNewBranchBefore()
2820 MapEditor *me=currentMapEditor();
2821 if (!lineedit->isVisible() && me)
2823 BranchObj *bo=(BranchObj*)me->getSelection();
2824 BranchObj *newbo=me->addNewBranchBefore();
2827 me->select (newbo->getSelectString());
2831 if (actionSettingsAutoEdit->isOn())
2833 if (!actionSettingsAutoSelectHeading->isOn())
2834 prevSelection=bo->getSelectString();
2840 void Main::editNewBranchAbove()
2842 MapEditor *me=currentMapEditor();
2843 if (!lineedit->isVisible() && me)
2845 BranchObj *bo=(BranchObj*)me->getSelection();
2846 BranchObj *newbo=me->addNewBranch (-1);
2849 me->select (newbo->getSelectString());
2853 if (actionSettingsAutoEdit->isOn())
2855 if (!actionSettingsAutoSelectHeading->isOn())
2856 prevSelection=bo->getSelectString();
2862 void Main::editNewBranchBelow()
2864 MapEditor *me=currentMapEditor();
2865 if (!lineedit->isVisible() && me)
2867 BranchObj *bo=(BranchObj*)me->getSelection();
2868 BranchObj *newbo=me->addNewBranch (1);
2871 me->select (newbo->getSelectString());
2875 if (actionSettingsAutoEdit->isOn())
2877 if (!actionSettingsAutoSelectHeading->isOn())
2878 prevSelection=bo->getSelectString();
2884 void Main::editImportAdd()
2886 fileLoad (ImportAdd);
2889 void Main::editImportReplace()
2891 fileLoad (ImportReplace);
2894 void Main::editSaveBranch()
2896 fileSaveAs (PartOfMap);
2899 void Main::editDeleteKeepChilds()
2901 if (currentMapEditor())
2902 currentMapEditor()->deleteKeepChilds();
2905 void Main::editDeleteChilds()
2907 if (currentMapEditor())
2908 currentMapEditor()->deleteChilds();
2911 void Main::editDeleteSelection()
2913 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2914 currentMapEditor()->deleteSelection();
2917 void Main::editUpperBranch()
2919 if (currentMapEditor())
2920 currentMapEditor()->selectUpperBranch();
2923 void Main::editLowerBranch()
2925 if (currentMapEditor())
2926 currentMapEditor()->selectLowerBranch();
2929 void Main::editLeftBranch()
2931 if (currentMapEditor())
2932 currentMapEditor()->selectLeftBranch();
2935 void Main::editRightBranch()
2937 if (currentMapEditor())
2938 currentMapEditor()->selectRightBranch();
2941 void Main::editFirstBranch()
2943 if (currentMapEditor())
2944 currentMapEditor()->selectFirstBranch();
2947 void Main::editLastBranch()
2949 if (currentMapEditor())
2950 currentMapEditor()->selectLastBranch();
2953 void Main::editLoadImage()
2955 if (currentMapEditor())
2956 currentMapEditor()->loadFloatImage();
2959 void Main::editSaveImage()
2961 if (currentMapEditor())
2962 currentMapEditor()->saveFloatImage();
2965 void Main::editFollowXLink(QAction *a)
2968 if (currentMapEditor())
2969 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2972 void Main::editEditXLink(QAction *a)
2974 if (currentMapEditor())
2975 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2978 void Main::formatSelectColor()
2980 if (currentMapEditor())
2982 QColor col = QColorDialog::getColor((currentColor ), this );
2983 if ( !col.isValid() ) return;
2984 colorChanged( col );
2988 void Main::formatPickColor()
2990 if (currentMapEditor())
2991 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
2994 void Main::colorChanged(QColor c)
2996 QPixmap pix( 16, 16 );
2998 actionFormatColor->setIconSet( pix );
3002 void Main::formatColorBranch()
3004 if (currentMapEditor())
3005 currentMapEditor()->colorBranch(currentColor);
3008 void Main::formatColorSubtree()
3010 if (currentMapEditor())
3011 currentMapEditor()->colorSubtree (currentColor);
3014 void Main::formatLinkStyleLine()
3016 if (currentMapEditor())
3017 currentMapEditor()->setMapLinkStyle("StyleLine");
3020 void Main::formatLinkStyleParabel()
3022 if (currentMapEditor())
3023 currentMapEditor()->setMapLinkStyle("StyleParabel");
3026 void Main::formatLinkStylePolyLine()
3028 if (currentMapEditor())
3029 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3032 void Main::formatLinkStylePolyParabel()
3034 if (currentMapEditor())
3035 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3038 void Main::formatSelectBackColor()
3040 if (currentMapEditor())
3041 currentMapEditor()->selectMapBackgroundColor();
3044 void Main::formatSelectBackImage()
3046 if (currentMapEditor())
3047 currentMapEditor()->selectMapBackgroundImage();
3050 void Main::formatSelectLinkColor()
3052 if (currentMapEditor())
3053 currentMapEditor()->selectMapLinkColor();
3056 void Main::formatToggleLinkColorHint()
3058 currentMapEditor()->toggleMapLinkColorHint();
3062 void Main::formatIncludeImagesVer()
3064 if (currentMapEditor())
3065 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3068 void Main::formatIncludeImagesHor()
3070 if (currentMapEditor())
3071 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3074 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3076 if (currentMapEditor())
3077 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3080 void Main::viewZoomReset()
3082 if (currentMapEditor())
3086 currentMapEditor()->setMatrix( m );
3090 void Main::viewZoomIn()
3092 if (currentMapEditor())
3094 QMatrix m = currentMapEditor()->matrix();
3095 m.scale( 1.25, 1.25 );
3096 currentMapEditor()->setMatrix( m );
3100 void Main::viewZoomOut()
3102 if (currentMapEditor())
3104 QMatrix m = currentMapEditor()->matrix();
3105 m.scale( 0.8, 0.8 );
3106 currentMapEditor()->setMatrix( m );
3110 bool Main::settingsPDF()
3112 // Default browser is set in constructor
3114 QString text = QInputDialog::getText(
3115 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3116 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3118 settings.setValue ("/mainwindow/readerPDF",text);
3123 bool Main::settingsURL()
3125 // Default browser is set in constructor
3127 QString text = QInputDialog::getText(
3128 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3129 settings.value("/mainwindow/readerURL").toString()
3132 settings.setValue ("/mainwindow/readerURL",text);
3136 void Main::settingsToggleDelKey()
3138 if (actionSettingsUseDelKey->isOn())
3140 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3143 actionEditDelete->setAccel (QKeySequence (""));
3147 void Main::windowToggleNoteEditor()
3149 if (textEditor->showWithMain() )
3150 windowHideNoteEditor();
3152 windowShowNoteEditor();
3155 void Main::windowToggleHistory()
3157 if (historyWindow->isVisible())
3158 historyWindow->hide();
3160 historyWindow->show();
3164 void Main::windowToggleAntiAlias()
3166 bool b=actionViewToggleAntiAlias->isOn();
3168 for (int i=0;i<tabWidget->count();i++)
3171 me=(MapEditor*)tabWidget->page(i);
3172 me->setAntiAlias(b);
3177 void Main::windowToggleSmoothPixmap()
3179 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3181 for (int i=0;i<tabWidget->count();i++)
3184 me=(MapEditor*)tabWidget->page(i);
3185 me->setSmoothPixmap(b);
3189 void Main::updateHistory(SimpleSettings &undoSet)
3191 historyWindow->update (undoSet);
3194 void Main::updateNoteFlag()
3196 if (currentMapEditor())
3197 currentMapEditor()->updateNoteFlag();
3200 void Main::updateActions()
3202 MapEditor *me=currentMapEditor();
3205 historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
3207 // updateActions is also called when NoteEditor is closed
3208 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3210 if (me->getMapLinkColorHint()==HeadingColor)
3211 actionFormatLinkColorHint->setOn(true);
3213 actionFormatLinkColorHint->setOn(false);
3215 switch (me->getMapLinkStyle())
3218 actionFormatLinkStyleLine->setOn(true);
3221 actionFormatLinkStyleParabel->setOn(true);
3224 actionFormatLinkStylePolyLine->setOn(true);
3226 case StylePolyParabel:
3227 actionFormatLinkStylePolyParabel->setOn(true);
3233 QPixmap pix( 16, 16 );
3234 pix.fill( me->getMapBackgroundColor() );
3235 actionFormatBackColor->setIconSet( pix );
3236 pix.fill( me->getMapDefLinkColor() );
3237 actionFormatLinkColor->setIconSet( pix );
3239 actionFileSave->setEnabled( me->isUnsaved() );
3240 if (me->isUndoAvailable())
3241 actionEditUndo->setEnabled( true);
3243 actionEditUndo->setEnabled( false);
3245 if (me->isRedoAvailable())
3246 actionEditRedo->setEnabled( true);
3248 actionEditRedo->setEnabled( false);
3250 LinkableMapObj *selection=me->getSelection();
3253 if ( (typeid(*selection) == typeid(BranchObj)) ||
3254 (typeid(*selection) == typeid(MapCenterObj)) )
3256 BranchObj *bo=(BranchObj*)selection;
3257 // Take care of links
3258 if (bo->countXLinks()==0)
3260 branchXLinksContextMenuEdit->clear();
3261 branchXLinksContextMenuFollow->clear();
3266 branchXLinksContextMenuEdit->clear();
3267 branchXLinksContextMenuFollow->clear();
3268 for (int i=0; i<=bo->countXLinks();i++)
3270 bot=bo->XLinkTargetAt(i);
3273 s=bot->getHeading();
3276 branchXLinksContextMenuFollow->addAction (s);
3277 branchXLinksContextMenuEdit->addAction (s);
3282 standardFlagsDefault->setEnabled (true);
3284 actionEditToggleScroll->setEnabled (true);
3285 if ( bo->isScrolled() )
3286 actionEditToggleScroll->setOn(true);
3288 actionEditToggleScroll->setOn(false);
3290 if ( bo->getURL().isEmpty() )
3292 actionEditOpenURL->setEnabled (false);
3293 actionEditOpenURLTab->setEnabled (false);
3297 actionEditOpenURL->setEnabled (true);
3298 actionEditOpenURLTab->setEnabled (true);
3300 if ( bo->getVymLink().isEmpty() )
3302 actionEditOpenVymLink->setEnabled (false);
3303 actionEditDeleteVymLink->setEnabled (false);
3306 actionEditOpenVymLink->setEnabled (true);
3307 actionEditDeleteVymLink->setEnabled (true);
3310 if (bo->canMoveBranchUp())
3311 actionEditMoveUp->setEnabled (true);
3313 actionEditMoveUp->setEnabled (false);
3314 if (bo->canMoveBranchDown())
3315 actionEditMoveDown->setEnabled (true);
3317 actionEditMoveDown->setEnabled (false);
3320 actionEditToggleHideExport->setEnabled (true);
3321 actionEditToggleHideExport->setOn (bo->hideInExport() );
3323 actionEditCopy->setEnabled (true);
3324 actionEditCut->setEnabled (true);
3325 if (!clipboardEmpty)
3326 actionEditPaste->setEnabled (true);
3328 actionEditPaste->setEnabled (false);
3329 for (int i=0; i<actionListBranches.size(); ++i)
3330 actionListBranches.at(i)->setEnabled(true);
3331 actionEditDelete->setEnabled (true);
3332 actionFormatIncludeImagesVer->setOn
3333 ( ((BranchObj*)selection)->getIncludeImagesVer());
3334 actionFormatIncludeImagesHor->setOn
3335 ( ((BranchObj*)selection)->getIncludeImagesHor());
3336 actionFormatHideLinkUnselected->setOn
3337 (selection->getHideLinkUnselected());
3339 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3341 FloatObj *fo=(FloatImageObj*)selection;
3343 actionEditOpenURL->setEnabled (false);
3344 actionEditOpenVymLink->setEnabled (false);
3345 actionEditDeleteVymLink->setEnabled (false);
3346 actionEditToggleHideExport->setEnabled (true);
3347 actionEditToggleHideExport->setOn (fo->hideInExport() );
3350 actionEditCopy->setEnabled (true);
3351 actionEditCut->setEnabled (true);
3352 actionEditPaste->setEnabled (false);
3353 for (int i=0; i<actionListBranches.size(); ++i)
3354 actionListBranches.at(i)->setEnabled(false);
3355 actionEditDelete->setEnabled (true);
3356 actionFormatHideLinkUnselected->setOn
3357 ( selection->getHideLinkUnselected());
3358 actionEditMoveUp->setEnabled (false);
3359 actionEditMoveDown->setEnabled (false);
3364 actionEditCopy->setEnabled (false);
3365 actionEditCut->setEnabled (false);
3366 actionEditPaste->setEnabled (false);
3367 for (int i=0; i<actionListBranches.size(); ++i)
3368 actionListBranches.at(i)->setEnabled(false);
3370 actionEditToggleScroll->setEnabled (false);
3371 actionEditOpenURL->setEnabled (false);
3372 actionEditOpenVymLink->setEnabled (false);
3373 actionEditDeleteVymLink->setEnabled (false);
3374 actionEditHeading2URL->setEnabled (false);
3375 actionEditDelete->setEnabled (false);
3376 actionEditMoveUp->setEnabled (false);
3377 actionEditMoveDown->setEnabled (false);
3378 actionEditToggleHideExport->setEnabled (false);
3382 ModMode Main::getModMode()
3384 if (actionModModeColor->isOn()) return ModModeColor;
3385 if (actionModModeCopy->isOn()) return ModModeCopy;
3386 if (actionModModeXLink->isOn()) return ModModeXLink;
3390 bool Main::autoEdit()
3392 return actionSettingsAutoEdit->isOn();
3395 bool Main::autoSelectHeading()
3397 return actionSettingsAutoSelectHeading->isOn();
3400 bool Main::useFlagGroups()
3402 return actionSettingsUseFlagGroups->isOn();
3405 void Main::windowShowNoteEditor()
3407 textEditor->setShowWithMain(true);
3409 actionViewToggleNoteEditor->setOn (true);
3412 void Main::windowHideNoteEditor()
3414 textEditor->setShowWithMain(false);
3416 actionViewToggleNoteEditor->setOn (false);
3419 void Main::showPropertyDialog()
3421 if(currentMapEditor())
3423 LinkableMapObj *sel=currentMapEditor()->getSelection();
3424 if (sel && typeid(*sel) == typeid(BranchObj))
3426 branchPropertyWindow->show();
3427 branchPropertyWindow->setMapEditor(currentMapEditor());
3428 branchPropertyWindow->setBranch((BranchObj*)sel);
3433 branchPropertyWindow->setBranch(NULL);
3436 void Main::windowNextEditor()
3438 if (tabWidget->currentPageIndex() < tabWidget->count())
3439 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3442 void Main::windowPreviousEditor()
3444 if (tabWidget->currentPageIndex() >0)
3445 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3448 void Main::standardFlagChanged()
3450 if (currentMapEditor())
3451 currentMapEditor()->toggleStandardFlag(sender()->name());
3454 void Main::testFunction()
3456 if (!currentMapEditor()) return;
3457 currentMapEditor()->testFunction();
3460 void Main::testCommand()
3462 if (!currentMapEditor()) return;
3464 QString com = QInputDialog::getText(
3465 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3466 if (ok) currentMapEditor()->parseAtom(com);
3469 void Main::helpDoc()
3471 QString locale = QLocale::system().name();
3473 if (locale.left(2)=="es")
3474 docname="vym_es.pdf";
3478 QStringList searchList;
3480 #if defined(Q_OS_MACX)
3481 searchList << "./vym.app/Contents";
3483 // default path in SUSE LINUX
3484 searchList <<"/usr/share/doc/packages/vym/doc";
3487 searchList << "doc"; // relative path for easy testing in tarball
3488 searchList << "doc/tex"; // Easy testing working on vym.tex
3489 searchList << "/usr/share/doc/vym"; // Debian
3490 searchList << "/usr/share/doc/packages";// Knoppix
3494 for (int i=0; i<searchList.count(); ++i)
3496 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3497 if (docfile.exists() )
3506 QMessageBox::critical(0,
3507 tr("Critcal error"),
3508 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3513 Process *pdfProc = new Process();
3514 args <<docfile.fileName();
3516 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3517 if ( !pdfProc->waitForStarted() )
3520 QMessageBox::warning(0,
3522 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3523 tr("Please use Settings->")+tr("Set application to open PDF files"));
3530 void Main::helpAbout()
3533 ad.setName ("aboutwindow");
3534 ad.setMinimumSize(500,500);
3535 ad.resize (QSize (500,500));
3539 void Main::helpAboutQT()
3541 QMessageBox::aboutQt( this, "Qt Application Example" );