1 #include "mainwindow.h"
5 #include <q3filedialog.h>
13 #include "aboutdialog.h"
14 #include "exportoofiledialog.h"
16 #include "exportxhtmldialog.h"
18 #include "flagrowobj.h"
19 #include "historywindow.h"
21 #include "mapeditor.h"
26 #include "texteditor.h"
29 extern TextEditor *textEditor;
30 extern Main *mainWindow;
31 extern QString tmpVymDir;
32 extern QString clipboardDir;
33 extern bool clipboardEmpty;
34 extern int statusbarTime;
35 extern FlagRowObj* standardFlagsDefault;
36 extern FlagRowObj* systemFlagsDefault;
38 QMenu* branchContextMenu;
39 QMenu* branchAddContextMenu;
40 QMenu* branchRemoveContextMenu;
41 QMenu* branchLinksContextMenu;
42 QMenu* branchXLinksContextMenuEdit;
43 QMenu* branchXLinksContextMenuFollow;
44 QMenu* floatimageContextMenu;
45 QMenu* canvasContextMenu;
46 QMenu* fileLastMapsMenu;
47 QMenu* fileImportMenu;
48 QMenu* fileExportMenu;
51 extern Settings settings;
52 extern Options options;
53 extern ImageIO imageIO;
55 extern QDir vymBaseDir;
56 extern QDir lastImageDir;
57 extern QDir lastFileDir;
58 extern QString iconPath;
59 extern QString flagsPath;
61 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
62 QMainWindow(parent,name,f)
66 setCaption ("VYM - View Your Mind");
68 // Load window settings
69 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
70 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
73 // Create unique temporary directory
75 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
78 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
82 // Create direcctory for clipboard
83 clipboardDir=tmpVymDir+"/clipboard";
85 d.mkdir (clipboardDir,true);
86 makeSubDirs (clipboardDir);
91 // FIXME not used currently
92 // Set random seed (random used for object IDs)
93 // QTime t = QTime::currentTime(); // set random seed
94 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
97 // Initialize some settings, which are platform dependant
100 // application to open URLs
101 p="/mainwindow/readerURL";
102 #if defined(Q_OS_LINUX)
103 s=settings.value (p,"konqueror").toString();
105 #if defined(Q_OS_MACX)
106 s=settings.value (p,"/usr/bin/open").toString();
108 s=settings.value (p,"mozilla");
111 settings.setValue( p,s);
113 // application to open PDFs
114 p="/mainwindow/readerPDF";
115 #if defined(Q_OS_LINUX)
116 s=settings.value (p,"acroread").toString();
118 #if defined(Q_OS_MACX)
119 s=settings.value (p,"/usr/bin/open").toString();
121 s=settings.value (p,"acroread").toString();
124 settings.setValue( p,s);
129 // Create tab widget which holds the maps
130 tabWidget= new QTabWidget (this);
131 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
132 this, SLOT( editorChanged( QWidget * ) ) );
134 lineedit=new QLineEdit (this);
137 setCentralWidget(tabWidget);
141 setupFormatActions();
145 setupSettingsActions();
147 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
152 restoreState (settings.value("/mainwindow/state",0).toByteArray());
154 // Initialize Find window
155 findWindow=new FindWindow(NULL);
156 findWindow->move (x(),y()+70);
157 connect (findWindow, SIGNAL( findButton(QString) ),
158 this, SLOT(editFind(QString) ) );
159 connect (findWindow, SIGNAL( somethingChanged() ),
160 this, SLOT(editFindChanged() ) );
162 // Connect TextEditor, so that we can update flags if text changes
163 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
164 connect (textEditor, SIGNAL (textClosed() ), this, SLOT (updateActions()));
172 settings.setValue ( "/mainwindow/geometry/size", size() );
173 settings.setValue ( "/mainwindow/geometry/pos", pos() );
175 settings.setValue ("/mainwindow/state",saveState(0));
177 settings.setValue( "/version/version", __VYM_VERSION );
178 settings.setValue( "/version/builddate", __BUILD_DATE );
180 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
181 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
182 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
183 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
184 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
185 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
188 int maps=lastMaps.count();
189 settings.setValue( "/lastMaps/number",maps );
190 for (int i=1;i<=maps;i++)
192 s=QString("/lastMaps/map-%1").arg(i);
193 if (!s.isEmpty() && i<=maxLastMaps)
194 settings.setValue (s, lastMaps.at(i-1));
198 // To make the texteditor save its settings, call the destructor
201 // Remove temporary directory
202 removeDir (QDir(tmpVymDir));
205 void Main::loadCmdLine()
207 /* TODO draw some kind of splashscreen while loading...
213 QStringList flist=options.getFileList();
214 QStringList::Iterator it=flist.begin();
216 while (it !=flist.end() )
218 fileLoad (*it, NewMap);
224 void Main::statusMessage(const QString &s)
226 statusBar()->message (s);
229 void Main::closeEvent (QCloseEvent* )
235 void Main::setupFileActions()
237 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
238 QToolBar *tb = addToolBar( tr ("&Map") );
239 tb->setObjectName ("mapTB");
242 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
243 a->setStatusTip ( tr( "New map","File menu" ) );
244 a->setShortcut ( Qt::CTRL + Qt::Key_N );
246 fileMenu->addAction (a);
247 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
249 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
250 a->setStatusTip (tr( "Open","File menu" ) );
251 a->setShortcut ( Qt::CTRL + Qt::Key_O );
253 fileMenu->addAction (a);
254 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
256 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
257 fileMenu->addSeparator();
259 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
260 a->setStatusTip ( tr( "Save" ));
261 a->setShortcut (Qt::CTRL + Qt::Key_S );
263 fileMenu->addAction (a);
264 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
267 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
268 a->setStatusTip (tr( "Save &As" ) );
269 fileMenu->addAction (a);
270 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
272 fileMenu->addSeparator();
274 fileImportMenu = fileMenu->addMenu (tr("Import"));
276 a = new QAction(tr("KDE Bookmarks"), this);
277 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
278 a->addTo (fileImportMenu);
279 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
281 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
283 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
284 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
285 a->addTo (fileImportMenu);
286 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
289 a = new QAction("Mind Manager...",this);
290 a->setStatusTip ( tr( "Import")+" Mind Manager" );
291 fileImportMenu->addAction (a);
292 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
294 a = new QAction( tr( "Import Dir"+QString("...") ), this);
295 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
296 fileImportMenu->addAction (a);
297 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
299 fileExportMenu = fileMenu->addMenu (tr("Export"));
301 a = new QAction( tr("Image")+QString("..."), this);
302 a->setStatusTip( tr( "Export map as image" ));
303 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
304 fileExportMenu->addAction (a);
306 a = new QAction( "Open Office"+QString("..."), this);
307 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
308 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
309 fileExportMenu->addAction (a);
311 a = new QAction( "Webpage (XHTML)...",this );
312 a->setShortcut (Qt::ALT + Qt::Key_X);
313 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
314 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
315 fileExportMenu->addAction (a);
317 a = new QAction( "Text (ASCII)...", this);
318 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
319 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
320 fileExportMenu->addAction (a);
322 a = new QAction( tr("KDE Bookmarks"), this);
323 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
324 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
325 fileExportMenu->addAction (a);
327 a = new QAction( "Taskjuggler...", this );
328 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
329 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
330 fileExportMenu->addAction (a);
332 a = new QAction( "LaTeX...", this);
333 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
334 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
335 fileExportMenu->addAction (a);
337 a = new QAction( "XML..." , this );
338 a->setStatusTip (tr( "Export as")+" XML");
339 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
340 fileExportMenu->addAction (a);
342 fileMenu->addSeparator();
344 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
345 a->setStatusTip ( tr( "Print" ) );
346 a->setShortcut (Qt::CTRL + Qt::Key_P );
348 fileMenu->addAction (a);
349 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
352 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
353 a->setStatusTip (tr( "Close Map" ) );
354 a->setShortcut (Qt::ALT + Qt::Key_C );
355 fileMenu->addAction (a);
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
358 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
359 a->setStatusTip ( tr( "Exit")+" "+__VYM );
360 a->setShortcut (Qt::CTRL + Qt::Key_Q );
361 fileMenu->addAction (a);
362 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
367 void Main::setupEditActions()
369 QToolBar *tb = addToolBar( tr ("&Actions") );
370 tb->setLabel( "Edit Actions" );
371 tb->setObjectName ("actionsTB");
372 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
376 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
377 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
378 a->setStatusTip (tr( "Undo" ) );
379 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
380 a->setEnabled (false);
382 editMenu->addAction (a);
385 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
386 a->setStatusTip (tr( "Redo" ));
387 a->setShortcut (Qt::CTRL + Qt::Key_Y );
389 editMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
393 editMenu->addSeparator();
394 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
395 a->setStatusTip ( tr( "Copy" ) );
396 a->setShortcut (Qt::CTRL + Qt::Key_C );
397 a->setEnabled (false);
399 editMenu->addAction (a);
400 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
403 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
404 a->setStatusTip ( tr( "Cut" ) );
405 a->setShortcut (Qt::CTRL + Qt::Key_X );
406 a->setEnabled (false);
408 editMenu->addAction (a);
410 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
412 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
413 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
414 a->setStatusTip ( tr( "Paste" ) );
415 a->setShortcut ( Qt::CTRL + Qt::Key_V );
416 a->setEnabled (false);
418 editMenu->addAction (a);
421 // Shortcuts to modify heading:
422 a = new QAction(tr( "Edit heading" ),this);
423 a->setStatusTip ( tr( "edit Heading" ));
424 a->setShortcut ( Qt::Key_Enter);
425 // a->setShortcutContext (Qt::WindowShortcut);
427 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
428 actionListBranches.append(a);
429 a = new QAction( tr( "Edit heading" ), this);
430 a->setStatusTip (tr( "edit Heading" ));
431 a->setShortcut (Qt::Key_Return );
432 //a->setShortcutContext (Qt::WindowShortcut);
434 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
435 actionListBranches.append(a);
436 editMenu->addAction (a);
438 a = new QAction( tr( "Edit heading" ), this);
439 a->setStatusTip (tr( "edit Heading" ));
440 a->setShortcut ( Qt::Key_F2 );
441 a->setShortcutContext (Qt::WindowShortcut);
443 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
444 actionListBranches.append(a);
446 // Shortcut to delete selection
447 a = new QAction( tr( "Delete Selection" ),this);
448 a->setStatusTip (tr( "Delete Selection" ));
449 a->setShortcut ( Qt::Key_Delete);
450 a->setShortcutContext (Qt::WindowShortcut);
452 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
455 // Shortcut to add branch
456 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
457 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
458 alt->setShortcut (Qt::Key_A);
459 alt->setShortcutContext (Qt::WindowShortcut);
461 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
462 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
463 a->setStatusTip ( tr( "Add a branch as child of selection" ));
464 a->setShortcut (Qt::Key_Insert);
465 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
466 actionListBranches.append(a);
467 #if defined (Q_OS_MACX)
468 // In OSX show different shortcut in menues, the keys work indepently always
469 actionEditAddBranch=alt;
471 actionEditAddBranch=a;
473 editMenu->addAction (actionEditAddBranch);
474 tb->addAction (actionEditAddBranch);
477 // Add branch by inserting it at selection
478 a = new QAction(tr( "Add branch (insert)" ), this);
479 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
480 a->setShortcut (Qt::ALT + Qt::Key_Insert );
481 a->setShortcutContext (Qt::WindowShortcut);
483 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
484 a->setEnabled (false);
485 actionListBranches.append(a);
486 actionEditAddBranchHere=a;
487 a = new QAction(tr( "Add branch (insert)" ),this);
488 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
489 a->setShortcut ( Qt::ALT + Qt::Key_A );
490 a->setShortcutContext (Qt::WindowShortcut);
492 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
493 actionListBranches.append(a);
496 a = new QAction(tr( "Add branch above" ), this);
497 a->setStatusTip ( tr( "Add a branch above selection" ));
498 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
499 a->setShortcutContext (Qt::WindowShortcut);
501 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
502 a->setEnabled (false);
503 actionListBranches.append(a);
504 actionEditAddBranchAbove=a;
505 a = new QAction(tr( "Add branch above" ), this);
506 a->setStatusTip ( tr( "Add a branch above selection" ));
507 a->setShortcut (Qt::SHIFT+Qt::Key_A );
508 a->setShortcutContext (Qt::WindowShortcut);
510 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
511 actionListBranches.append(a);
514 a = new QAction(tr( "Add branch below" ), this);
515 a->setStatusTip ( tr( "Add a branch below selection" ));
516 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
517 a->setShortcutContext (Qt::WindowShortcut);
519 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
520 a->setEnabled (false);
521 actionListBranches.append(a);
522 actionEditAddBranchBelow=a;
523 a = new QAction(tr( "Add branch below" ), this);
524 a->setStatusTip ( tr( "Add a branch below selection" ));
525 a->setShortcut (Qt::CTRL +Qt::Key_A );
526 a->setShortcutContext (Qt::WindowShortcut);
528 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
529 actionListBranches.append(a);
531 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
532 a->setStatusTip ( tr( "Move branch up" ) );
533 a->setShortcut (Qt::Key_PageUp );
534 a->setEnabled (false);
536 editMenu->addAction (a);
537 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
540 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
542 a->setStatusTip (tr( "Move branch down" ) );
543 a->setShortcut ( Qt::Key_PageDown );
544 a->setEnabled (false);
546 editMenu->addAction (a);
547 actionEditMoveDown=a;
550 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
551 a->setShortcut ( Qt::Key_ScrollLock );
552 a->setStatusTip (tr( "Scroll branch" ) );
553 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
555 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
556 alt->setShortcut ( Qt::Key_S );
557 alt->setStatusTip (tr( "Scroll branch" ));
558 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
559 #if defined(Q_OS_MACX)
560 actionEditToggleScroll=alt;
562 actionEditToggleScroll=a;
564 actionEditToggleScroll->setEnabled (false);
565 actionEditToggleScroll->setToggleAction(true);
566 tb->addAction (actionEditToggleScroll);
567 editMenu->addAction ( actionEditToggleScroll);
568 editMenu->addAction (actionEditToggleScroll);
571 actionListBranches.append(actionEditToggleScroll);
573 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
574 a->setStatusTip (tr( "Unscroll all" ));
575 editMenu->addAction (a);
576 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
578 editMenu->addSeparator();
580 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
581 a->setStatusTip (tr( "Find" ) );
582 a->setShortcut (Qt::CTRL + Qt::Key_F );
583 editMenu->addAction (a);
584 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
586 editMenu->addSeparator();
588 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
589 a->setShortcut (Qt::CTRL + Qt::Key_U );
590 a->setShortcut (tr( "Open URL" ));
593 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
596 a = new QAction( tr( "Open URL in new tab" ), this);
597 a->setStatusTip (tr( "Open URL in new tab" ));
598 a->setShortcut (Qt::CTRL+Qt::Key_U );
600 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
601 actionEditOpenURLTab=a;
603 a = new QAction( tr( "Open all URLs in subtree" ), this);
604 a->setStatusTip (tr( "Open all URLs in subtree" ));
606 actionListBranches.append(a);
607 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
608 actionEditOpenMultipleURLTabs=a;
610 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
611 a->setStatusTip ( tr( "Edit URL" ) );
612 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
613 //a->setShortcut ( Qt::Key_U );
614 a->setShortcutContext (Qt::WindowShortcut);
615 actionListBranches.append(a);
617 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
620 a = new QAction( tr( "Use heading for URL" ), this);
621 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
622 a->setEnabled (false);
623 actionListBranches.append(a);
624 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
625 actionEditHeading2URL=a;
627 a = new QAction(tr( "Create URL to Bugzilla" ), this);
628 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
629 a->setEnabled (false);
630 actionListBranches.append(a);
631 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
632 actionEditBugzilla2URL=a;
634 a = new QAction(tr( "Create URL to FATE" ), this);
635 a->setStatusTip ( tr( "Create URL to FATE" ));
636 a->setEnabled (false);
637 actionListBranches.append(a);
638 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
639 actionEditFATE2URL=a;
641 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this);
642 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
644 a->setEnabled (false);
645 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
646 actionEditOpenVymLink=a;
648 a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this);
649 a->setStatusTip ( tr( "Open all vym links in subtree" ));
650 a->setEnabled (false);
651 actionListBranches.append(a);
652 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
653 actionEditOpenMultipleVymLinks=a;
656 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
657 a->setEnabled (false);
658 a->setStatusTip ( tr( "Edit link to another vym map" ));
659 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
660 actionListBranches.append(a);
663 a = new QAction(tr( "Delete vym link" ),this);
664 a->setStatusTip ( tr( "Delete link to another vym map" ));
665 a->setEnabled (false);
666 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
667 actionEditDeleteVymLink=a;
669 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
670 a->setStatusTip ( tr( "Hide object in exports" ) );
671 a->setShortcut (Qt::Key_H );
672 a->setToggleAction(true);
674 a->setEnabled (false);
675 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
676 actionEditToggleHideExport=a;
678 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
679 a->setStatusTip ( tr( "Edit Map Info" ));
680 a->setEnabled (true);
681 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
684 editMenu->addSeparator();
686 // Import at selection (adding to selection)
687 a = new QAction( tr( "Add map (insert)" ),this);
688 a->setStatusTip (tr( "Add map at selection" ));
689 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
690 a->setEnabled (false);
691 actionListBranches.append(a);
692 actionEditImportAdd=a;
694 // Import at selection (replacing selection)
695 a = new QAction( tr( "Add map (replace)" ), this);
696 a->setStatusTip (tr( "Replace selection with map" ));
697 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
698 a->setEnabled (false);
699 actionListBranches.append(a);
700 actionEditImportReplace=a;
703 a = new QAction( tr( "Save selection" ), this);
704 a->setStatusTip (tr( "Save selection" ));
705 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
706 a->setEnabled (false);
707 actionListBranches.append(a);
708 actionEditSaveBranch=a;
710 // Only remove branch, not its childs
711 a = new QAction(tr( "Remove only branch " ), this);
712 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
713 a->setShortcut (Qt::ALT + Qt::Key_Delete );
714 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
715 a->setEnabled (false);
717 actionListBranches.append(a);
718 actionEditRemoveBranchKeepChilds=a;
720 // Only remove childs of a branch
721 a = new QAction( tr( "Remove childs" ), this);
722 a->setStatusTip (tr( "Remove childs of branch" ));
723 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
724 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
725 a->setEnabled (false);
726 actionListBranches.append(a);
727 actionEditRemoveChilds=a;
729 // Shortcuts for navigating with cursor:
730 a = new QAction(tr( "Select upper branch" ), this);
731 a->setStatusTip ( tr( "Select upper branch" ));
732 a->setShortcut (Qt::Key_Up );
733 a->setShortcutContext (Qt::WindowShortcut);
735 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
736 a = new QAction( tr( "Select lower branch" ),this);
737 a->setStatusTip (tr( "Select lower branch" ));
738 a->setShortcut ( Qt::Key_Down );
739 a->setShortcutContext (Qt::WindowShortcut);
741 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
742 a = new QAction(tr( "Select left branch" ), this);
743 a->setStatusTip ( tr( "Select left branch" ));
744 a->setShortcut (Qt::Key_Left );
745 a->setShortcutContext (Qt::WindowShortcut);
747 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
748 a = new QAction( tr( "Select child branch" ), this);
749 a->setStatusTip (tr( "Select right branch" ));
750 a->setShortcut (Qt::Key_Right);
751 a->setShortcutContext (Qt::WindowShortcut);
753 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
754 a = new QAction( tr( "Select first branch" ), this);
755 a->setStatusTip (tr( "Select first branch" ));
756 a->setShortcut (Qt::Key_Home );
757 a->setShortcutContext (Qt::WindowShortcut);
759 a->setEnabled (false);
760 editMenu->addAction (a);
761 actionListBranches.append(a);
762 actionEditSelectFirst=a;
763 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
764 a = new QAction( tr( "Select last branch" ),this);
765 a->setStatusTip (tr( "Select last branch" ));
766 a->setShortcut ( Qt::Key_End );
767 a->setShortcutContext (Qt::WindowShortcut);
769 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
770 a->setEnabled (false);
771 editMenu->addAction (a);
772 actionListBranches.append(a);
773 actionEditSelectLast=a;
775 a = new QAction( tr( "Add Image" )+QString("..."), this);
776 a->setStatusTip (tr( "Add Image" ));
777 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
778 actionEditLoadImage=a;
783 void Main::setupFormatActions()
785 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
787 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
788 tb->setObjectName ("formatTB");
791 pix.fill (Qt::black);
792 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
793 a->setStatusTip ( tr( "Set Color" ));
794 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
796 formatMenu->addAction (a);
798 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
799 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
800 a->setShortcut (Qt::CTRL + Qt::Key_K );
801 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
802 a->setEnabled (false);
804 formatMenu->addAction (a);
805 actionListBranches.append(a);
806 actionFormatPickColor=a;
808 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
809 a->setStatusTip ( tr( "Color branch" ) );
810 a->setShortcut (Qt::CTRL + Qt::Key_I);
811 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
812 a->setEnabled (false);
814 formatMenu->addAction (a);
815 actionListBranches.append(a);
816 actionFormatColorBranch=a;
818 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
819 a->setStatusTip ( tr( "Color Subtree" ));
820 a->setShortcut (Qt::CTRL + Qt::Key_T);
821 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
822 a->setEnabled (false);
823 formatMenu->addAction (a);
825 actionListBranches.append(a);
826 actionFormatColorSubtree=a;
828 formatMenu->addSeparator();
829 actionGroupFormatLinkStyles=new QActionGroup ( this);
830 actionGroupFormatLinkStyles->setExclusive (true);
831 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
832 a->setStatusTip (tr( "Line" ));
833 a->setToggleAction(true);
834 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
835 formatMenu->addAction (a);
836 actionFormatLinkStyleLine=a;
837 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
838 a->setStatusTip (tr( "Line" ));
839 a->setToggleAction(true);
840 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
841 formatMenu->addAction (a);
842 actionFormatLinkStyleParabel=a;
843 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
844 a->setStatusTip (tr( "PolyLine" ));
845 a->setToggleAction(true);
846 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
847 formatMenu->addAction (a);
848 actionFormatLinkStylePolyLine=a;
849 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
850 a->setStatusTip (tr( "PolyParabel" ) );
851 a->setToggleAction(true);
852 a->setChecked (true);
853 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
854 formatMenu->addAction (a);
855 actionFormatLinkStylePolyParabel=a;
857 actionGroupFormatFrameTypes=new QActionGroup ( this);
858 actionGroupFormatFrameTypes->setExclusive (true);
859 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
860 a->setStatusTip (tr("No Frame"));
861 a->setToggleAction(true);
862 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
863 actionFormatFrameNone=a;
864 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
865 a->setStatusTip (tr( "Rectangle" ));
866 a->setToggleAction(true);
867 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
868 actionFormatFrameRectangle=a;
870 a = new QAction( tr( "Include images vertically" ), this);
871 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
872 a->setToggleAction(true);
873 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
874 actionFormatIncludeImagesVer=a;
876 a = new QAction( tr( "Include images horizontally" ), this);
877 a->setStatusTip ( tr ("Include left and right position of images into branch"));
878 a->setToggleAction(true);
879 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
880 actionFormatIncludeImagesHor=a;
882 a = new QAction( tr( "Hide link if object is not selected" ), this);
883 a->setStatusTip (tr( "Hide link" ));
884 a->setToggleAction(true);
885 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
886 actionFormatHideLinkUnselected=a;
888 formatMenu->addSeparator();
889 a= new QAction( tr( "&Use color of heading for link" ), this);
890 a->setStatusTip (tr( "Use same color for links and headings" ));
891 a->setToggleAction(true);
892 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
893 formatMenu->addAction (a);
894 actionFormatLinkColorHint=a;
896 pix.fill (Qt::white);
897 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
898 a->setStatusTip (tr( "Set Link Color" ));
899 formatMenu->addAction (a);
900 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
901 actionFormatLinkColor=a;
903 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
904 a->setStatusTip (tr( "Set Background Color" ));
905 formatMenu->addAction (a);
906 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
907 actionFormatBackColor=a;
911 void Main::setupViewActions()
913 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
914 tb->setLabel( "View Actions" );
915 tb->setObjectName ("viewTB");
916 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
919 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
920 a->setStatusTip ( tr( "Zoom reset" ) );
921 a->setShortcut (Qt::CTRL + Qt::Key_0 );
923 viewMenu->addAction (a);
924 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
926 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
927 a->setStatusTip (tr( "Zoom in" ));
928 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
930 viewMenu->addAction (a);
931 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
933 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
934 a->setStatusTip (tr( "Zoom out" ));
935 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
937 viewMenu->addAction (a);
938 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
941 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
942 a->setStatusTip ( tr( "Show Note Editor" ));
943 a->setShortcut ( Qt::CTRL + Qt::Key_E );
944 a->setToggleAction(true);
945 if (textEditor->showWithMain())
950 viewMenu->addAction (a);
951 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
952 actionViewToggleNoteEditor=a;
954 a = new QAction( tr( "Show history window" ),this );
955 a->setStatusTip ( tr( "Show history window" ));
956 a->setShortcut ( Qt::CTRL + Qt::Key_H );
957 a->setToggleAction(false);
958 viewMenu->addAction (a);
959 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
960 actionViewToggleHistoryWindow=a;
962 a = new QAction(tr( "Next Window" ), this);
963 a->setStatusTip ( tr( "&Next Window" ) );
964 a->setShortcut (Qt::ALT + Qt::Key_N );
965 viewMenu->addAction (a);
966 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
968 a = new QAction (tr( "Previous Window" ), this );
969 a->setStatusTip (tr( "&Previous Window" ));
970 a->setShortcut (Qt::ALT + Qt::Key_P );
971 viewMenu->addAction (a);
972 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
976 void Main::setupModeActions()
978 //QPopupMenu *menu = new QPopupMenu( this );
979 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
981 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
982 tb->setObjectName ("modesTB");
984 actionGroupModModes=new QActionGroup ( this);
985 actionGroupModModes->setExclusive (true);
986 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
987 a->setShortcut (Qt::Key_J);
988 a->setStatusTip ( tr( "Use modifier to color branches" ));
989 a->setToggleAction(true);
992 actionModModeColor=a;
994 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
995 a->setShortcut( Qt::Key_K);
996 a->setStatusTip( tr( "Use modifier to copy" ));
997 a->setToggleAction(true);
1001 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1002 a->setShortcut (Qt::Key_L);
1003 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1004 a->setToggleAction(true);
1006 actionModModeXLink=a;
1010 void Main::setupFlagActions()
1012 // Create System Flags
1013 systemFlagsDefault = new FlagRowObj ();
1014 systemFlagsDefault->setVisibility (false);
1015 systemFlagsDefault->setName ("systemFlagsDef");
1017 FlagObj *fo = new FlagObj ();
1018 fo->load(QPixmap(flagsPath+"flag-note.png"));
1019 fo->setName("note");
1020 fo->setToolTip(tr("Note","Systemflag"));
1021 systemFlagsDefault->addFlag (fo); // makes deep copy
1023 fo->load(QPixmap(flagsPath+"flag-url.png"));
1025 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1026 systemFlagsDefault->addFlag (fo);
1028 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1029 fo->setName("vymLink");
1030 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1031 systemFlagsDefault->addFlag (fo);
1033 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1034 fo->setName("scrolledright");
1035 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1036 systemFlagsDefault->addFlag (fo);
1038 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1039 fo->setName("tmpUnscrolledright");
1040 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1041 systemFlagsDefault->addFlag (fo);
1043 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1044 fo->setName("hideInExport");
1045 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1046 systemFlagsDefault->addFlag (fo);
1048 // Create Standard Flags
1049 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1050 tb->setObjectName ("standardFlagTB");
1052 standardFlagsDefault = new FlagRowObj ();
1053 standardFlagsDefault->setVisibility (false);
1054 standardFlagsDefault->setName ("standardFlagsDef");
1055 standardFlagsDefault->setToolBar (tb);
1057 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1058 fo->setName ("exclamationmark");
1059 fo->setGroup("standard-mark");
1060 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1063 a->setCheckable(true);
1064 a->setObjectName(fo->getName());
1065 a->setToolTip(tr("Take care!","Standardflag"));
1066 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1067 standardFlagsDefault->addFlag (fo); // makes deep copy
1069 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1070 fo->setName("questionmark");
1071 fo->setGroup("standard-mark");
1072 a=new QAction (fo->getPixmap(),fo->getName(),this);
1075 a->setCheckable(true);
1076 a->setObjectName(fo->getName());
1077 a->setToolTip(tr("Really?","Standardflag"));
1078 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1079 standardFlagsDefault->addFlag (fo);
1081 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1082 fo->setName("hook-green");
1083 fo->setGroup("standard-hook");
1084 a=new QAction (fo->getPixmap(),fo->getName(),this);
1087 a->setCheckable(true);
1088 a->setObjectName(fo->getName());
1089 a->setToolTip(tr("ok!","Standardflag"));
1090 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1091 standardFlagsDefault->addFlag (fo);
1093 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1094 fo->setName("cross-red");
1095 fo->setGroup("standard-hook");
1096 a=new QAction (fo->getPixmap(),fo->getName(),this);
1099 a->setCheckable(true);
1100 a->setObjectName(fo->getName());
1101 a->setToolTip(tr("Not ok!","Standardflag"));
1102 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1103 standardFlagsDefault->addFlag (fo);
1105 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1106 fo->setName("stopsign");
1107 a=new QAction (fo->getPixmap(),fo->getName(),this);
1110 a->setCheckable(true);
1111 a->setObjectName(fo->getName());
1112 a->setToolTip(tr("This won't work!","Standardflag"));
1113 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1114 standardFlagsDefault->addFlag (fo);
1116 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1117 fo->setName("smiley-good");
1118 fo->setGroup("standard-smiley");
1119 a=new QAction (fo->getPixmap(),fo->getName(),this);
1122 a->setCheckable(true);
1123 a->setObjectName(fo->getName());
1124 a->setToolTip(tr("Good","Standardflag"));
1125 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1126 standardFlagsDefault->addFlag (fo);
1128 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1129 fo->setName("smiley-sad");
1130 fo->setGroup("standard-smiley");
1131 a=new QAction (fo->getPixmap(),fo->getName(),this);
1134 a->setCheckable(true);
1135 a->setObjectName(fo->getName());
1136 a->setToolTip(tr("Bad","Standardflag"));
1137 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1138 standardFlagsDefault->addFlag (fo);
1140 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1141 // Original omg.png (in KDE emoticons)
1142 fo->setName("smiley-omg");
1143 fo->setGroup("standard-smiley");
1144 a=new QAction (fo->getPixmap(),fo->getName(),this);
1147 a->setCheckable(true);
1148 a->setObjectName(fo->getName());
1149 a->setToolTip(tr("Oh no!","Standardflag"));
1150 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1151 standardFlagsDefault->addFlag (fo);
1153 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1154 fo->setName("clock");
1155 a=new QAction (fo->getPixmap(),fo->getName(),this);
1158 a->setCheckable(true);
1159 a->setObjectName(fo->getName());
1160 a->setToolTip(tr("Time critical","Standardflag"));
1161 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1162 standardFlagsDefault->addFlag (fo);
1164 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1165 fo->setName("phone");
1166 a=new QAction (fo->getPixmap(),fo->getName(),this);
1169 a->setCheckable(true);
1170 a->setObjectName(fo->getName());
1171 a->setToolTip(tr("Call...","Standardflag"));
1172 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1173 standardFlagsDefault->addFlag (fo);
1175 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1176 fo->setName("lamp");
1177 a=new QAction (fo->getPixmap(),fo->getName(),this);
1180 a->setCheckable(true);
1181 a->setObjectName(fo->getName());
1182 a->setToolTip(tr("Idea!","Standardflag"));
1183 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1184 standardFlagsDefault->addFlag (fo);
1186 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1187 fo->setName("arrow-up");
1188 fo->setGroup("standard-arrow");
1189 a=new QAction (fo->getPixmap(),fo->getName(),this);
1192 a->setCheckable(true);
1193 a->setObjectName(fo->getName());
1194 a->setToolTip(tr("Important","Standardflag"));
1195 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1196 standardFlagsDefault->addFlag (fo);
1198 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1199 fo->setName("arrow-down");
1200 fo->setGroup("standard-arrow");
1201 a=new QAction (fo->getPixmap(),fo->getName(),this);
1204 a->setCheckable(true);
1205 a->setObjectName(fo->getName());
1206 a->setToolTip(tr("Unimportant","Standardflag"));
1207 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1208 standardFlagsDefault->addFlag (fo);
1210 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1211 fo->setName("2arrow-up");
1212 fo->setGroup("standard-arrow");
1213 a=new QAction (fo->getPixmap(),fo->getName(),this);
1216 a->setCheckable(true);
1217 a->setObjectName(fo->getName());
1218 a->setToolTip(tr("Very important!","Standardflag"));
1219 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1220 standardFlagsDefault->addFlag (fo);
1222 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1223 fo->setName("2arrow-down");
1224 fo->setGroup("standard-arrow");
1225 a=new QAction (fo->getPixmap(),fo->getName(),this);
1228 a->setCheckable(true);
1229 a->setObjectName(fo->getName());
1230 a->setToolTip(tr("Very unimportant!","Standardflag"));
1231 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1232 standardFlagsDefault->addFlag (fo);
1234 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1235 fo->setName("thumb-up");
1236 fo->setGroup("standard-thumb");
1237 a=new QAction (fo->getPixmap(),fo->getName(),this);
1240 a->setCheckable(true);
1241 a->setObjectName(fo->getName());
1242 a->setToolTip(tr("I like this","Standardflag"));
1243 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1244 standardFlagsDefault->addFlag (fo);
1246 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1247 fo->setName("thumb-down");
1248 fo->setGroup("standard-thumb");
1249 a=new QAction (fo->getPixmap(),fo->getName(),this);
1252 a->setCheckable(true);
1253 a->setObjectName(fo->getName());
1254 a->setToolTip(tr("I do not like this","Standardflag"));
1255 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1256 standardFlagsDefault->addFlag (fo);
1258 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1259 fo->setName("rose");
1260 a=new QAction (fo->getPixmap(),fo->getName(),this);
1263 a->setCheckable(true);
1264 a->setObjectName(fo->getName());
1265 a->setToolTip(tr("Rose","Standardflag"));
1266 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1267 standardFlagsDefault->addFlag (fo);
1269 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1270 fo->setName("heart");
1271 a=new QAction (fo->getPixmap(),fo->getName(),this);
1273 a->setCheckable(true);
1274 a->setObjectName(fo->getName());
1275 a->setToolTip(tr("I just love... ","Standardflag"));
1276 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1277 standardFlagsDefault->addFlag (fo);
1279 fo->load(QPixmap(flagsPath+"flag-present.png"));
1280 fo->setName("present");
1281 a=new QAction (fo->getPixmap(),fo->getName(),this);
1284 a->setCheckable(true);
1285 a->setObjectName(fo->getName());
1286 a->setToolTip(tr("Surprise!","Standardflag"));
1287 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1288 standardFlagsDefault->addFlag (fo);
1290 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1291 fo->setName("flash");
1292 a=new QAction (fo->getPixmap(),fo->getName(),this);
1295 a->setCheckable(true);
1296 a->setObjectName(fo->getName());
1297 a->setToolTip(tr("Dangerous","Standardflag"));
1298 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1299 standardFlagsDefault->addFlag (fo);
1301 fo->load(QPixmap(flagsPath+"flag-info.png"));
1302 // Original: xsldbg_output.png
1303 fo->setName("info");
1304 a=new QAction (fo->getPixmap(),fo->getName(),this);
1307 a->setCheckable(true);
1308 a->setObjectName(fo->getName());
1309 a->setToolTip(tr("Info","Standardflag"));
1310 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1311 standardFlagsDefault->addFlag (fo);
1313 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1314 // Original khelpcenter.png
1315 fo->setName("lifebelt");
1316 a=new QAction (fo->getPixmap(),fo->getName(),this);
1319 a->setCheckable(true);
1320 a->setObjectName(fo->getName());
1321 a->setToolTip(tr("This will help","Standardflag"));
1322 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1323 standardFlagsDefault->addFlag (fo);
1329 void Main::setupSettingsActions()
1331 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1335 a = new QAction( tr( "Set application to open pdf files"), this);
1336 a->setStatusTip ( tr( "Set application to open pdf files"));
1337 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1338 settingsMenu->addAction (a);
1340 a = new QAction( tr( "Set application to open external links"), this);
1341 a->setStatusTip( tr( "Set application to open external links"));
1342 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1343 settingsMenu->addAction (a);
1345 settingsMenu->addSeparator();
1346 a = new QAction( tr( "Edit branch after adding it" ), this );
1347 a->setStatusTip( tr( "Edit branch after adding it" ));
1348 a->setToggleAction(true);
1349 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1350 settingsMenu->addAction (a);
1351 actionSettingsAutoEdit=a;
1353 a= new QAction( tr( "Select branch after adding it" ), this );
1354 a->setStatusTip( tr( "Select branch after adding it" ));
1355 a->setToggleAction(true);
1356 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1357 settingsMenu->addAction (a);
1358 actionSettingsAutoSelectHeading=a;
1360 a= new QAction(tr( "Select existing heading" ), this);
1361 a->setStatusTip( tr( "Select heading before editing" ));
1362 a->setToggleAction(true);
1363 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1364 settingsMenu->addAction (a);
1365 actionSettingsAutoSelectText=a;
1367 a= new QAction( tr( "Delete key" ), this);
1368 a->setStatusTip( tr( "Delete key for deleting branches" ));
1369 a->setToggleAction(true);
1370 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1371 settingsMenu->addAction (a);
1372 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1373 actionSettingsUseDelKey=a;
1375 a= new QAction( tr( "Exclusive flags" ), this);
1376 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1377 a->setToggleAction(true);
1378 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1379 settingsMenu->addAction (a);
1380 actionSettingsUseFlagGroups=a;
1382 a= new QAction( tr( "Use hide flags" ), this);
1383 a->setStatusTip( tr( "Use hide flag during exports " ));
1384 a->setToggleAction(true);
1385 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1386 settingsMenu->addAction (a);
1387 actionSettingsUseHideExport=a;
1391 void Main::setupTestActions()
1393 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1396 a = new QAction( tr( "test flag" ), this);
1397 a->setStatusTip( tr( "Call test function" ));
1398 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1399 testMenu->addAction (a);
1403 void Main::setupHelpActions()
1405 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1408 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1409 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1410 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1411 helpMenu->addAction (a);
1413 a = new QAction( tr( "About VYM" ), this);
1414 a->setStatusTip( tr( "About VYM")+" "__VYM);
1415 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1416 helpMenu->addAction (a);
1418 a = new QAction( tr( "About QT" ), this);
1419 a->setStatusTip( tr( "Information about QT toolkit" ));
1420 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1421 helpMenu->addAction (a);
1425 void Main::setupContextMenus()
1429 // Context Menu for branch or mapcenter
1430 branchContextMenu =new QMenu (this);
1433 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1434 branchAddContextMenu->addAction (actionEditPaste );
1435 branchAddContextMenu->addAction ( actionEditAddBranch );
1436 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1437 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1438 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1439 branchAddContextMenu->addSeparator();
1440 branchAddContextMenu->addAction ( actionEditLoadImage);
1441 branchAddContextMenu->addSeparator();
1442 branchAddContextMenu->addAction ( actionEditImportAdd );
1443 branchAddContextMenu->addAction ( actionEditImportReplace );
1446 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1447 branchRemoveContextMenu->addAction (actionEditCut);
1448 branchRemoveContextMenu->addAction ( actionEditDelete );
1449 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1450 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1453 actionEditSaveBranch->addTo( branchContextMenu );
1455 branchContextMenu->addSeparator();
1456 branchContextMenu->addAction ( actionFormatFrameNone );
1457 branchContextMenu->addAction ( actionFormatFrameRectangle);
1459 branchContextMenu->addSeparator();
1460 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1461 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1462 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1464 // Submenu for Links (URLs, vymLinks)
1465 branchLinksContextMenu =new QMenu (this);
1467 branchContextMenu->addSeparator();
1468 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));
1469 branchLinksContextMenu->addAction ( actionEditOpenURL );
1470 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1471 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1472 branchLinksContextMenu->addAction ( actionEditURL );
1473 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1474 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1475 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1477 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1479 branchLinksContextMenu->addSeparator();
1480 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1481 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1482 branchLinksContextMenu->addAction ( actionEditVymLink );
1483 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1486 // Context Menu for XLinks in a branch menu
1487 // This will be populated "on demand" in MapEditor::updateActions
1488 branchContextMenu->addSeparator();
1489 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1490 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1491 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1492 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1495 // Context menu for floatimage
1496 floatimageContextMenu =new QMenu (this);
1497 a= new QAction (tr ("Save image"),this);
1498 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1499 floatimageContextMenu->addAction (a);
1501 floatimageContextMenu->addSeparator();
1502 actionEditCopy->addTo( floatimageContextMenu );
1503 actionEditCut->addTo( floatimageContextMenu );
1505 floatimageContextMenu->addSeparator();
1506 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1509 // Context menu for canvas
1510 canvasContextMenu =new QMenu (this);
1511 actionEditMapInfo->addTo( canvasContextMenu );
1512 canvasContextMenu->insertSeparator();
1513 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1514 canvasContextMenu->insertSeparator();
1515 actionFormatLinkColorHint->addTo( canvasContextMenu );
1516 actionFormatLinkColor->addTo( canvasContextMenu );
1517 actionFormatBackColor->addTo( canvasContextMenu );
1519 // Menu for last opened files
1520 // Read settings initially
1522 int j=settings.readNumEntry( "/lastMaps/number",0);
1523 for (int i=1;i<=j;i++)
1525 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1526 if (!s.isEmpty() && j<=maxLastMaps)
1529 setupLastMapsMenu();
1530 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1533 void Main::setupLastMapsMenu()
1535 // Remove double entries
1536 QStringList::Iterator it=lastMaps.begin();
1537 QStringList::Iterator jt;
1538 while (it!=lastMaps.end() )
1542 while (jt!=lastMaps.end() )
1545 jt=lastMaps.remove(jt);
1552 // Limit length of list to maxLastMaps
1553 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1555 // build Menu from lastMaps string list
1556 fileLastMapsMenu->clear();
1557 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1558 fileLastMapsMenu->addAction (*it );
1561 void Main::hideEvent (QHideEvent * )
1563 if (!textEditor->isMinimized() ) textEditor->hide();
1566 void Main::showEvent (QShowEvent * )
1568 if (textEditor->showWithMain()) textEditor->showNormal();
1571 bool Main::reallyWriteDirectory(const QString &dir)
1573 QStringList eList = QDir(dir).entryList();
1574 if (eList.first() ==".") eList.pop_front(); // remove "."
1575 if (eList.first() =="..") eList.pop_front(); // remove "."
1576 if (!eList.isEmpty())
1578 QMessageBox mb( __VYM,
1579 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1580 QMessageBox::Warning,
1582 QMessageBox::Cancel | QMessageBox::Default,
1583 QMessageBox::QMessageBox::NoButton );
1585 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1586 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1589 case QMessageBox::Yes:
1592 case QMessageBox::Cancel:
1600 QString Main::browseDirectory (const QString &caption)
1602 Q3FileDialog fd(this,caption);
1603 fd.setMode (Q3FileDialog::DirectoryOnly);
1604 fd.setCaption(__VYM " - "+caption);
1607 if ( fd.exec() == QDialog::Accepted )
1608 return fd.selectedFile();
1613 MapEditor* Main::currentMapEditor() const
1615 if ( tabWidget->currentPage() &&
1616 tabWidget->currentPage()->inherits( "MapEditor" ) )
1617 return (MapEditor*)tabWidget->currentPage();
1621 //TODO not used now, maybe use this for overview window later
1622 void Main::newView()
1624 // Open a new view... have it delete when closed.
1625 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1626 qApp->setMainWidget(m);
1628 qApp->setMainWidget(0);
1631 void Main::editorChanged(QWidget *)
1633 // Unselect all possibly selected objects
1634 // (Important to update note editor)
1637 for (i=0;i<=tabWidget->count() -1;i++)
1640 me=(MapEditor*)tabWidget->page(i);
1643 currentMapEditor()->reselect();
1645 // Update actions to in menus and toolbars according to editor
1646 currentMapEditor()->updateActions();
1649 void Main::fileNew()
1651 QString fn="unnamed";
1652 MapEditor* medit = new MapEditor ( NULL);
1653 tabWidget->addTab (medit,fn);
1654 tabWidget->showPage(medit);
1655 medit->viewport()->setFocus();
1656 // For the very first map we do not have flagrows yet...
1657 medit->select("mc:");
1660 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1662 ErrorCode err=success;
1664 // fn is usually the archive, mapfile the file after uncompressing
1667 // Make fn absolute (needed for unzip)
1668 fn=QDir (fn).absPath();
1674 // Check, if map is already loaded
1676 while (i<=tabWidget->count() -1)
1678 me=(MapEditor*)tabWidget->page(i);
1679 if (me->getFilePath() == fn)
1681 // Already there, ask for confirmation
1682 QMessageBox mb( __VYM,
1683 tr("The map %1\nis already opened."
1684 "Opening the same map in multiple editors may lead \n"
1685 "to confusion when finishing working with vym."
1686 "Do you want to").arg(fn),
1687 QMessageBox::Warning,
1688 QMessageBox::Yes | QMessageBox::Default,
1689 QMessageBox::Cancel | QMessageBox::Escape,
1690 QMessageBox::NoButton);
1691 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1692 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1695 case QMessageBox::Yes:
1697 i=tabWidget->count();
1699 case QMessageBox::Cancel:
1711 if ( !fn.isEmpty() )
1713 me = currentMapEditor();
1714 int tabIndex=tabWidget->currentPageIndex();
1715 // Check first, if mapeditor exists
1716 // If it is not default AND we want a new map,
1717 // create a new mapeditor in a new tab
1718 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1720 me= new MapEditor ( NULL);
1721 tabWidget->addTab (me,fn);
1722 tabIndex=tabWidget->indexOf (me);
1723 tabWidget->setCurrentPage (tabIndex);
1726 // Check, if file exists (important for creating new files
1727 // from command line
1728 if (!QFile(fn).exists() )
1730 QMessageBox mb( __VYM,
1731 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1732 QMessageBox::Question,
1734 QMessageBox::Cancel | QMessageBox::Default,
1735 QMessageBox::NoButton );
1737 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1738 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1741 case QMessageBox::Yes:
1743 currentMapEditor()->setFilePath(fn);
1744 tabWidget->setTabLabel (currentMapEditor(),
1745 currentMapEditor()->getFileName() );
1746 statusBar()->message( "Created " + fn , statusbarTime );
1749 case QMessageBox::Cancel:
1750 // don't create new map
1751 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1758 //tabWidget->currentPage() won't be NULL here, because of above...
1759 tabWidget->showPage(me);
1760 me->viewport()->setFocus();
1762 // Create temporary directory for packing
1764 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1767 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1768 tr("Couldn't create temporary directory before load\n"));
1772 // Try to unzip file
1773 err=unzipDir (tmpMapDir,fn);
1777 me->setZipped(false);
1780 me->setZipped(true);
1782 // Look for mapname.xml
1783 mapfile= fn.left(fn.findRev(".",-1,true));
1784 mapfile=mapfile.section( '/', -1 );
1785 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1786 if (!file.exists() )
1788 // mapname.xml does not exist, well,
1789 // maybe some renamed the mapname.vym file...
1790 // Try to find any .xml in the toplevel
1791 // directory of the .vym file
1792 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1793 if (flist.count()==1)
1795 // Only one entry, take this one
1796 mapfile=tmpMapDir + "/"+flist.first();
1799 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1800 *it=tmpMapDir + "/" + *it;
1801 // TODO Multiple entries, load all (but only the first one into this ME)
1802 //mainWindow->fileLoadFromTmp (flist);
1803 //returnCode=1; // Silently forget this attempt to load
1804 qWarning ("MainWindow::load (fn) multimap found...");
1807 if (flist.isEmpty() )
1809 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1810 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1813 } //file doesn't exist
1815 mapfile=file.name();
1820 // Save existing filename in case we import
1821 QString fn_org=me->getFilePath();
1823 // Finally load map into mapEditor
1824 me->setFilePath (mapfile,fn);
1825 err=me->load(mapfile,lmode);
1827 // Restore old (maybe empty) filepath, if this is an import
1829 me->setFilePath (fn_org);
1832 // Finally check for errors and go home
1835 if (lmode==NewMap) fileCloseMap();
1836 statusBar()->message( "Could not load " + fn, statusbarTime );
1841 me->setFilePath (fn);
1842 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1843 if (fn.left(9)!="/tmp/vym-")
1845 // Only append to lastMaps if not loaded from a tmpDir
1846 // e.g. imported bookmarks are in a tmpDir
1847 lastMaps.prepend(me->getFilePath() );
1848 setupLastMapsMenu();
1850 actionFilePrint->setEnabled (true);
1852 statusBar()->message( "Loaded " + fn, statusbarTime );
1856 removeDir (QDir(tmpMapDir));
1862 void Main::fileLoad(const LoadMode &lmode)
1864 QStringList filters;
1865 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1866 QFileDialog *fd=new QFileDialog( this);
1867 fd->setDir (lastFileDir);
1868 fd->setFileMode (QFileDialog::ExistingFiles);
1869 fd->setFilters (filters);
1873 fd->setCaption(__VYM " - " +tr("Load vym map"));
1876 fd->setCaption(__VYM " - " +tr("Import: Add vym map to selection"));
1879 fd->setCaption(__VYM " - " +tr("Import: Replace selection with vym map"));
1885 if ( fd->exec() == QDialog::Accepted )
1887 lastFileDir=fd->directory().path();
1888 QStringList flist = fd->selectedFiles();
1889 QStringList::Iterator it = flist.begin();
1890 while( it != flist.end() )
1893 fileLoad(*it, lmode);
1900 void Main::fileLoad()
1905 void Main::fileLoadLast(QAction *a)
1907 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1910 void Main::fileSave(const SaveMode &savemode)
1912 // tmp dir for zipping
1916 ErrorCode err=success;
1918 QString safeFilePath;
1920 bool saveZipped=currentMapEditor()->saveZipped();
1922 MapEditor * me=currentMapEditor();
1925 QString fn=me->getFilePath();
1926 // filename=unnamed, filepath="" in constructor...
1927 if ( !fn.isEmpty() )
1929 // We have a filepath, go on saving
1930 // First remove existing file, we
1931 // don't want to add to old zip archives
1935 QMessageBox::warning( 0, tr( "Save Error" ),
1936 fn+ tr("\ncould not be removed before saving"));
1938 // Look, if we should zip the data:
1941 QMessageBox mb( __VYM,
1942 tr("The map %1\ndid not use the compressed "
1943 "vym file format.\nWriting it uncompressed will also write images \n"
1944 "and flags and thus may overwrite files in the "
1945 "given directory\n\nDo you want to write the map").arg(fn),
1946 QMessageBox::Warning,
1947 QMessageBox::Yes | QMessageBox::Default,
1949 QMessageBox::Cancel | QMessageBox::Escape);
1950 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1951 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1952 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1955 case QMessageBox::Yes:
1956 // save compressed (default file format)
1959 case QMessageBox::No:
1960 // save uncompressed
1963 case QMessageBox::Cancel:
1972 // Create temporary directory for packing
1974 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1977 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1978 tr("Couldn't create temporary directory before save\n"));
1982 safeFilePath=me->getFilePath();
1983 me->setFilePath (tmpMapDir+"/"+
1984 me->getMapName()+ ".xml",
1986 me->save (savemode);
1987 me->setFilePath (safeFilePath);
1989 zipDir (tmpMapDir,fn);
1994 safeFilePath=me->getFilePath();
1995 me->setFilePath (fn, safeFilePath);
1996 me->save (savemode);
1997 me->setFilePath (safeFilePath);
1999 } // filepath available
2002 // We have no filepath yet,
2003 // call fileSaveAs() now, this will call fileSave()
2005 fileSaveAs(savemode);
2009 if (saveZipped && !tmpMapDir.isEmpty())
2011 removeDir (QDir(tmpMapDir));
2015 statusBar()->message(
2016 tr("Saved %1").arg(me->getFilePath()),
2018 lastMaps.prepend(me->getFilePath() );
2019 setupLastMapsMenu();
2021 statusBar()->message(
2022 tr("Couldn't save ").arg(me->getFilePath()),
2026 void Main::fileSave()
2028 fileSave (CompleteMap);
2031 void Main::fileSaveAs(const SaveMode& savemode)
2035 if (currentMapEditor())
2037 if (savemode==CompleteMap)
2038 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2040 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2041 if ( !fn.isEmpty() )
2043 // Check for existing file
2044 if (QFile (fn).exists())
2046 QMessageBox mb( __VYM,
2047 tr("The file %1\nexists already. Do you want to").arg(fn),
2048 QMessageBox::Warning,
2049 QMessageBox::Yes | QMessageBox::Default,
2050 QMessageBox::Cancel | QMessageBox::Escape,
2051 QMessageBox::NoButton);
2052 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2053 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2056 case QMessageBox::Yes:
2059 case QMessageBox::Cancel:
2066 // New file, add extension to filename, if missing
2067 // This is always .vym or .vyp, depending on savemode
2068 if (savemode==CompleteMap)
2070 if (!fn.contains (".vym") && !fn.contains (".xml"))
2074 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2083 currentMapEditor()->setFilePath(fn);
2087 if (savemode==CompleteMap)
2088 tabWidget->setTabLabel (currentMapEditor(),
2089 currentMapEditor()->getFileName() );
2095 void Main::fileSaveAs()
2097 fileSaveAs (CompleteMap);
2100 void Main::fileImportKDEBookmarks()
2102 ImportKDEBookmarks im;
2104 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2105 currentMapEditor()->setFilePath ("");
2108 void Main::fileImportFirefoxBookmarks()
2110 Q3FileDialog *fd=new Q3FileDialog( this);
2111 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2112 fd->setMode (Q3FileDialog::ExistingFiles);
2113 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2114 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2117 if ( fd->exec() == QDialog::Accepted )
2119 ImportFirefoxBookmarks im;
2120 QStringList flist = fd->selectedFiles();
2121 QStringList::Iterator it = flist.begin();
2122 while( it != flist.end() )
2125 if (im.transform() &&
2126 success==fileLoad (im.getTransformedFile(),NewMap) &&
2127 currentMapEditor() )
2128 currentMapEditor()->setFilePath ("");
2135 void Main::fileImportMM()
2139 Q3FileDialog *fd=new Q3FileDialog( this);
2140 fd->setDir (lastFileDir);
2141 fd->setMode (Q3FileDialog::ExistingFiles);
2142 fd->addFilter ("Mind Manager (*.mmap)");
2143 fd->setCaption(tr("Import")+" "+"Mind Manager");
2146 if ( fd->exec() == QDialog::Accepted )
2148 lastFileDir=fd->dirPath();
2149 QStringList flist = fd->selectedFiles();
2150 QStringList::Iterator it = flist.begin();
2151 while( it != flist.end() )
2154 if (im.transform() &&
2155 success==fileLoad (im.getTransformedFile(),NewMap) &&
2156 currentMapEditor() )
2157 currentMapEditor()->setFilePath ("");
2166 void Main::fileImportDir()
2168 if (currentMapEditor())
2169 currentMapEditor()->importDir();
2172 void Main::fileExportXML()
2174 if (currentMapEditor())
2176 QString dir=browseDirectory(tr("Export XML to directory"));
2177 if (dir !="" && reallyWriteDirectory(dir) )
2178 currentMapEditor()->exportXML(dir);
2183 void Main::fileExportXHTML()
2185 MapEditor *me=currentMapEditor();
2189 ExportXHTMLDialog dia(this);
2190 dia.setFilePath (me->getFilePath() );
2191 dia.setMapName (me->getMapName() );
2194 if (dia.exec()==QDialog::Accepted)
2196 QString dir=dia.getDir();
2197 // Check, if warnings should be used before overwriting
2198 // the output directory
2201 ok=reallyWriteDirectory(dir);
2207 me->exportXML (dia.getDir() );
2208 dia.doExport(me->getMapName() );
2209 if (dia.hasChanged())
2216 void Main::fileExportImage()
2218 MapEditor *me=currentMapEditor();
2222 QFileDialog *fd=new QFileDialog (this);
2223 fd->setCaption (tr("Export map as image"));
2224 fd->setFileMode(QFileDialog::AnyFile);
2225 fd->setFilters (imageIO.getFilters() );
2226 fd->setDirectory (lastImageDir);
2229 fl=fd->selectedFiles();
2230 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2231 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2236 void Main::fileExportASCII()
2238 MapEditor *me=currentMapEditor();
2242 ex.setMapCenter(me->getMapCenter());
2243 ex.addFilter ("TXT (*.txt)");
2244 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2245 if (ex.execDialog() )
2247 me->setExportMode(true);
2249 me->setExportMode(false);
2254 void Main::fileExportLaTeX()
2256 MapEditor *me=currentMapEditor();
2260 ex.setMapCenter(me->getMapCenter());
2261 ex.addFilter ("Tex (*.tex)");
2262 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2263 if (ex.execDialog() )
2265 me->setExportMode(true);
2267 me->setExportMode(false);
2272 void Main::fileExportKDEBookmarks()
2274 ExportKDEBookmarks ex;
2275 MapEditor *me=currentMapEditor();
2278 ex.setMapCenter (me->getMapCenter() );
2283 void Main::fileExportTaskjuggler()
2285 ExportTaskjuggler ex;
2286 MapEditor *me=currentMapEditor();
2289 ex.setMapCenter (me->getMapCenter() );
2290 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2291 ex.addFilter ("Taskjuggler (*.tjp)");
2292 if (ex.execDialog() )
2294 me->setExportMode(true);
2296 me->setExportMode(false);
2301 void Main::fileExportOOPresentation()
2303 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2304 // TODO add preview in dialog
2305 //ImagePreview *p =new ImagePreview (fd);
2306 //fd->setContentsPreviewEnabled( TRUE );
2307 //fd->setContentsPreview( p, p );
2308 //fd->setPreviewMode( QFileDialog::Contents );
2309 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2310 fd->setDir (QDir().current());
2311 if (fd->foundConfig())
2315 if ( fd->exec() == QDialog::Accepted )
2317 QString fn=fd->selectedFile();
2318 if (!fn.contains (".odp"))
2321 //lastImageDir=fn.left(fn.findRev ("/"));
2322 if (currentMapEditor())
2323 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2327 QMessageBox::warning(0,
2329 tr("Couldn't find configuration for export to Open Office\n"));
2333 void Main::fileCloseMap()
2335 if (currentMapEditor())
2337 if (currentMapEditor()->hasChanged())
2339 QMessageBox mb( __VYM,
2340 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2341 QMessageBox::Warning,
2342 QMessageBox::Yes | QMessageBox::Default,
2344 QMessageBox::Cancel | QMessageBox::Escape );
2345 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2346 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2349 case QMessageBox::Yes:
2351 fileSave(CompleteMap);
2353 case QMessageBox::No:
2354 // close without saving
2356 case QMessageBox::Cancel:
2361 currentMapEditor()->closeMap();
2362 tabWidget->removePage(currentMapEditor());
2363 if (tabWidget->count()==0)
2364 actionFilePrint->setEnabled (false);
2368 void Main::filePrint()
2370 if (currentMapEditor())
2371 currentMapEditor()->print();
2374 void Main::fileExitVYM()
2376 // Check if one or more editors have changed
2379 for (i=0;i<=tabWidget->count() -1;i++)
2382 me=(MapEditor*)tabWidget->page(i);
2384 // If something changed, ask what to do
2385 if (me->isUnsaved())
2387 tabWidget->setCurrentPage(i);
2388 QMessageBox mb( __VYM,
2389 tr("This map is not saved yet. Do you want to"),
2390 QMessageBox::Warning,
2391 QMessageBox::Yes | QMessageBox::Default,
2393 QMessageBox::Cancel | QMessageBox::Escape );
2394 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2395 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2398 mb.setActiveWindow();
2399 switch( mb.exec() ) {
2400 case QMessageBox::Yes:
2401 // save (the changed editors) and exit
2402 fileSave(CompleteMap);
2404 case QMessageBox::No:
2405 // exit without saving
2407 case QMessageBox::Cancel:
2408 // don't save and don't exit
2412 } // loop over all MEs
2416 void Main::editUndo()
2418 if (currentMapEditor())
2419 currentMapEditor()->undo();
2422 void Main::editRedo()
2424 if (currentMapEditor())
2425 currentMapEditor()->redo();
2428 void Main::editCopy()
2430 if (currentMapEditor())
2431 currentMapEditor()->copy();
2434 void Main::editPaste()
2436 if (currentMapEditor())
2437 currentMapEditor()->paste();
2440 void Main::editCut()
2442 if (currentMapEditor())
2443 currentMapEditor()->cut();
2446 void Main::editOpenFindWindow()
2448 findWindow->popup();
2449 findWindow->raise();
2450 findWindow->setActiveWindow();
2453 void Main::editFind(QString s)
2456 BranchObj *bo=currentMapEditor()->findText(s, cs);
2459 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2462 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2463 tr("No matches found for \"%1\"").arg(s));
2467 void Main::editFindChanged()
2468 { // Notify editor, to abort the current find process
2469 currentMapEditor()->findReset();
2472 void Main::openTabs(QStringList urls)
2474 if (!urls.isEmpty())
2478 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2480 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2482 QString u=urls.takeFirst();
2483 procBrowser = new QProcess( this );
2485 procBrowser->start(browser,args);
2486 if ( !procBrowser->waitForStarted())
2488 // try to set path to browser
2489 QMessageBox::warning(0,
2491 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2492 tr("Please use Settings->")+tr("Set application to open an URL"));
2497 if (browser.contains("konqueror"))
2499 for (int i=0; i<urls.size(); i++)
2502 // Try to open new tab in existing konqueror started previously by vym
2503 p=new QProcess (this);
2505 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2506 "konqueror-mainwindow#1"<<
2509 p->start ("dcop",args);
2510 if ( !p->waitForStarted() ) success=false;
2513 QMessageBox::warning(0,
2515 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2517 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2519 for (int i=0; i<urls.size(); i++)
2521 // Try to open new tab in firefox
2522 p=new QProcess (this);
2523 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2524 p->start (browser,args);
2525 if ( !p->waitForStarted() ) success=false;
2528 QMessageBox::warning(0,
2530 tr("Couldn't start %1 to open a new tab").arg(browser));
2533 QMessageBox::warning(0,
2535 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2539 void Main::editOpenURL()
2542 if (currentMapEditor())
2544 QString url=currentMapEditor()->getURL();
2546 if (url=="") return;
2547 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2548 procBrowser = new QProcess( this );
2550 procBrowser->start(browser,args);
2551 if ( !procBrowser->waitForStarted())
2553 // try to set path to browser
2554 QMessageBox::warning(0,
2556 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2557 tr("Please use Settings->")+tr("Set application to open an URL"));
2562 void Main::editOpenURLTab()
2564 if (currentMapEditor())
2567 urls.append(currentMapEditor()->getURL());
2571 void Main::editOpenMultipleURLTabs()
2573 if (currentMapEditor())
2576 urls=currentMapEditor()->getURLs();
2582 void Main::editURL()
2584 if (currentMapEditor())
2585 currentMapEditor()->editURL();
2588 void Main::editHeading2URL()
2590 if (currentMapEditor())
2591 currentMapEditor()->editHeading2URL();
2594 void Main::editBugzilla2URL()
2596 if (currentMapEditor())
2597 currentMapEditor()->editBugzilla2URL();
2600 void Main::editFATE2URL()
2602 if (currentMapEditor())
2603 currentMapEditor()->editFATE2URL();
2606 void Main::editHeading()
2608 if (lineedit->isVisible())
2610 if (currentMapEditor())
2612 MapEditor *me=currentMapEditor();
2613 QString oldSel=me->getSelectString();
2614 if (me->select (editSel))
2615 me->setHeading(lineedit->text());
2616 me->select (oldSel);
2618 lineedit->releaseKeyboard();
2623 if (currentMapEditor())
2627 QString s=currentMapEditor()->getHeading(ok,p);
2631 #if defined(Q_OS_MACX)
2632 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2633 QDialog *d =new QDialog(NULL);
2634 QLineEdit *le=new QLineEdit (d);
2635 d->setWindowFlags (Qt::FramelessWindowHint);
2636 d->setGeometry(p.x(),p.y(),200,25);
2637 le->resize (d->size());
2640 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2641 d->activateWindow();
2643 currentMapEditor()->setHeading (le->text());
2645 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2646 lineedit->setGeometry(p.x(),p.y(),200,25);
2647 lineedit->setText(s);
2648 lineedit->setCursorPosition(1);
2649 lineedit->selectAll();
2651 lineedit->grabKeyboard();
2652 lineedit->setFocus();
2654 editSel=currentMapEditor()->getSelectString();
2662 void Main::openVymLinks(const QStringList &vl)
2664 for (int j=0; j<vl.size(); j++)
2666 // compare path with already loaded maps
2670 for (i=0;i<=tabWidget->count() -1;i++)
2672 me=(MapEditor*)tabWidget->page(i);
2673 if (vl.at(j)==me->getFilePath() )
2682 if (!QFile(vl.at(j)).exists() )
2683 QMessageBox::critical( 0, tr( "Critical Error" ),
2684 tr("Couldn't open map %1").arg(vl.at(j)));
2687 fileLoad (vl.at(j), NewMap);
2688 tabWidget->setCurrentPage (tabWidget->count()-1);
2691 // Go to tab containing the map
2692 tabWidget->setCurrentPage (index);
2696 void Main::editOpenVymLink()
2698 if (currentMapEditor())
2701 vl.append(currentMapEditor()->getVymLink());
2706 void Main::editOpenMultipleVymLinks()
2708 QString currentVymLink;
2709 if (currentMapEditor())
2711 QStringList vl=currentMapEditor()->getVymLinks();
2716 void Main::editVymLink()
2718 if (currentMapEditor())
2719 currentMapEditor()->editVymLink();
2722 void Main::editDeleteVymLink()
2724 if (currentMapEditor())
2725 currentMapEditor()->deleteVymLink();
2728 void Main::editToggleHideExport()
2730 if (currentMapEditor())
2731 currentMapEditor()->toggleHideExport();
2734 void Main::editMapInfo()
2736 if (currentMapEditor())
2737 currentMapEditor()->editMapInfo();
2740 void Main::editMoveUp()
2742 if (currentMapEditor())
2743 currentMapEditor()->moveBranchUp();
2746 void Main::editMoveDown()
2748 if (currentMapEditor())
2749 currentMapEditor()->moveBranchDown();
2752 void Main::editToggleScroll()
2754 if (currentMapEditor())
2756 currentMapEditor()->toggleScroll();
2760 void Main::editUnScrollAll()
2762 if (currentMapEditor())
2764 currentMapEditor()->unScrollAll();
2768 void Main::editNewBranch()
2771 if (!lineedit->isVisible() && currentMapEditor())
2772 currentMapEditor()->addNewBranch(0);
2775 void Main::editNewBranchHere()
2777 if (currentMapEditor())
2778 currentMapEditor()->addNewBranchHere();
2781 void Main::editNewBranchAbove()
2783 if (currentMapEditor())
2784 currentMapEditor()->addNewBranch(-1);
2787 void Main::editNewBranchBelow()
2789 if (currentMapEditor())
2790 currentMapEditor()->addNewBranch(1);
2793 void Main::editImportAdd()
2795 fileLoad (ImportAdd);
2798 void Main::editImportReplace()
2800 fileLoad (ImportReplace);
2803 void Main::editSaveBranch()
2805 fileSaveAs (PartOfMap);
2808 void Main::editRemoveBranchKeepChilds()
2810 if (currentMapEditor())
2811 currentMapEditor()->removeBranchKeepChilds();
2814 void Main::editRemoveChilds()
2816 if (currentMapEditor())
2817 currentMapEditor()->removeChilds();
2820 void Main::editDeleteSelection()
2822 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2823 currentMapEditor()->deleteSelection();
2826 void Main::editUpperBranch()
2828 if (currentMapEditor())
2829 currentMapEditor()->selectUpperBranch();
2832 void Main::editLowerBranch()
2834 if (currentMapEditor())
2835 currentMapEditor()->selectLowerBranch();
2838 void Main::editLeftBranch()
2840 if (currentMapEditor())
2841 currentMapEditor()->selectLeftBranch();
2844 void Main::editRightBranch()
2846 if (currentMapEditor())
2847 currentMapEditor()->selectRightBranch();
2850 void Main::editFirstBranch()
2852 if (currentMapEditor())
2853 currentMapEditor()->selectFirstBranch();
2856 void Main::editLastBranch()
2858 if (currentMapEditor())
2859 currentMapEditor()->selectLastBranch();
2862 void Main::editLoadImage()
2864 if (currentMapEditor())
2865 currentMapEditor()->loadFloatImage();
2868 void Main::editSaveImage()
2870 if (currentMapEditor())
2871 currentMapEditor()->saveFloatImage();
2874 void Main::editFollowXLink(QAction *a)
2877 if (currentMapEditor())
2878 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2881 void Main::editEditXLink(QAction *a)
2883 if (currentMapEditor())
2884 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2887 void Main::formatSelectColor()
2889 if (currentMapEditor())
2891 QColor col = QColorDialog::getColor( currentMapEditor()->getColor(), this );
2892 if ( !col.isValid() ) return;
2893 currentMapEditor()->setColor( col );
2894 colorChanged( col );
2898 void Main::formatPickColor()
2900 if (currentMapEditor())
2901 colorChanged( currentMapEditor()->pickColor() );
2904 void Main::colorChanged(QColor c)
2906 QPixmap pix( 16, 16 );
2908 actionFormatColor->setIconSet( pix );
2911 void Main::formatColorItem()
2913 if (currentMapEditor())
2914 currentMapEditor()->colorItem();
2917 void Main::formatColorBranch()
2919 if (currentMapEditor())
2920 currentMapEditor()->colorBranch();
2923 void Main::formatLinkStyleLine()
2925 if (currentMapEditor())
2926 currentMapEditor()->setLinkStyle(StyleLine);
2929 void Main::formatLinkStyleParabel()
2931 if (currentMapEditor())
2932 currentMapEditor()->setLinkStyle(StyleParabel);
2935 void Main::formatLinkStylePolyLine()
2937 if (currentMapEditor())
2938 currentMapEditor()->setLinkStyle(StylePolyLine);
2941 void Main::formatLinkStylePolyParabel()
2943 if (currentMapEditor())
2944 currentMapEditor()->setLinkStyle(StylePolyParabel);
2947 void Main::formatSelectBackColor()
2949 if (currentMapEditor())
2950 currentMapEditor()->selectBackgroundColor();
2953 void Main::formatSelectLinkColor()
2955 if (currentMapEditor())
2956 currentMapEditor()->selectLinkColor();
2959 void Main::formatToggleLinkColorHint()
2961 currentMapEditor()->toggleLinkColorHint();
2964 void Main::formatFrameNone()
2966 if (currentMapEditor())
2967 currentMapEditor()->setFrame(NoFrame);
2970 void Main::formatFrameRectangle()
2972 if (currentMapEditor())
2973 currentMapEditor()->setFrame(Rectangle);
2976 void Main::formatIncludeImagesVer()
2978 if (currentMapEditor())
2979 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2982 void Main::formatIncludeImagesHor()
2984 if (currentMapEditor())
2985 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2988 void Main::formatHideLinkUnselected()
2990 if (currentMapEditor())
2991 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2994 void Main::viewZoomReset()
2996 if (currentMapEditor())
3000 currentMapEditor()->setWorldMatrix( m );
3001 currentMapEditor()->setViewCenter();
3002 currentMapEditor()->adjustCanvasSize();
3006 void Main::viewZoomIn()
3008 if (currentMapEditor())
3010 QMatrix m = currentMapEditor()->worldMatrix();
3011 m.scale( 1.25, 1.25 );
3012 currentMapEditor()->setWorldMatrix( m );
3013 currentMapEditor()->setViewCenter();
3014 currentMapEditor()->adjustCanvasSize();
3018 void Main::viewZoomOut()
3020 if (currentMapEditor())
3022 QMatrix m = currentMapEditor()->worldMatrix();
3023 m.scale( 0.8, 0.8 );
3024 currentMapEditor()->setWorldMatrix( m );
3025 currentMapEditor()->setViewCenter();
3026 currentMapEditor()->adjustCanvasSize();
3030 bool Main::settingsPDF()
3032 // Default browser is set in constructor
3034 QString text = QInputDialog::getText(
3035 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3036 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3038 settings.setValue ("/mainwindow/readerPDF",text);
3043 bool Main::settingsURL()
3045 // Default browser is set in constructor
3047 QString text = QInputDialog::getText(
3048 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3049 settings.value("/mainwindow/readerURL").toString()
3052 settings.setValue ("/mainwindow/readerURL",text);
3056 void Main::settingsToggleDelKey()
3058 if (actionSettingsUseDelKey->isOn())
3060 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3063 actionEditDelete->setAccel (QKeySequence (""));
3067 void Main::windowToggleNoteEditor()
3069 if (textEditor->showWithMain() )
3070 windowHideNoteEditor();
3072 windowShowNoteEditor();
3075 void Main::windowToggleHistory()
3077 if (currentMapEditor())
3078 currentMapEditor()->toggleHistoryWindow();
3081 void Main::updateNoteFlag()
3083 if (currentMapEditor())
3084 currentMapEditor()->updateNoteFlag();
3087 void Main::updateActions()
3089 MapEditor *me=currentMapEditor();
3092 // updateActions is also called when NoteEditor is closed
3093 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3096 if (me->getLinkColorHint()==HeadingColor)
3097 actionFormatLinkColorHint->setOn(true);
3099 actionFormatLinkColorHint->setOn(false);
3101 switch (me->getLinkStyle())
3104 actionFormatLinkStyleLine->setOn(true);
3107 actionFormatLinkStyleParabel->setOn(true);
3110 actionFormatLinkStylePolyLine->setOn(true);
3112 case StylePolyParabel:
3113 actionFormatLinkStylePolyParabel->setOn(true);
3119 QPixmap pix( 16, 16 );
3120 pix.fill( me->getBackgroundColor() );
3121 actionFormatBackColor->setIconSet( pix );
3122 pix.fill( me->getDefLinkColor() );
3123 actionFormatLinkColor->setIconSet( pix );
3125 actionFileSave->setEnabled( me->isUnsaved() );
3126 if (me->isUndoAvailable())
3127 actionEditUndo->setEnabled( true);
3129 actionEditUndo->setEnabled( false);
3131 if (me->isRedoAvailable())
3132 actionEditRedo->setEnabled( true);
3134 actionEditRedo->setEnabled( false);
3136 LinkableMapObj *selection=me->getSelection();
3139 if ( (typeid(*selection) == typeid(BranchObj)) ||
3140 (typeid(*selection) == typeid(MapCenterObj)) )
3142 BranchObj *bo=(BranchObj*)selection;
3143 // Take care of links
3144 if (bo->countXLinks()==0)
3146 branchXLinksContextMenuEdit->clear();
3147 branchXLinksContextMenuFollow->clear();
3152 branchXLinksContextMenuEdit->clear();
3153 branchXLinksContextMenuFollow->clear();
3154 for (int i=0; i<=bo->countXLinks();i++)
3156 bot=bo->XLinkTargetAt(i);
3159 s=bot->getHeading();
3162 branchXLinksContextMenuFollow->addAction (s);
3163 branchXLinksContextMenuEdit->addAction (s);
3168 standardFlagsDefault->setEnabled (true);
3170 actionEditToggleScroll->setEnabled (true);
3171 if ( bo->isScrolled() )
3172 actionEditToggleScroll->setOn(true);
3174 actionEditToggleScroll->setOn(false);
3176 if ( bo->getURL().isEmpty() )
3178 actionEditOpenURL->setEnabled (false);
3179 actionEditOpenURLTab->setEnabled (false);
3183 actionEditOpenURL->setEnabled (true);
3184 actionEditOpenURLTab->setEnabled (true);
3186 if ( bo->getVymLink().isEmpty() )
3188 actionEditOpenVymLink->setEnabled (false);
3189 actionEditDeleteVymLink->setEnabled (false);
3192 actionEditOpenVymLink->setEnabled (true);
3193 actionEditDeleteVymLink->setEnabled (true);
3196 if (bo->canMoveBranchUp())
3197 actionEditMoveUp->setEnabled (true);
3199 actionEditMoveUp->setEnabled (false);
3200 if (bo->canMoveBranchDown())
3201 actionEditMoveDown->setEnabled (true);
3203 actionEditMoveDown->setEnabled (false);
3206 actionEditToggleHideExport->setEnabled (true);
3207 actionEditToggleHideExport->setOn (bo->hideInExport() );
3209 actionEditCopy->setEnabled (true);
3210 actionEditCut->setEnabled (true);
3211 if (!clipboardEmpty)
3212 actionEditPaste->setEnabled (true);
3214 actionEditPaste->setEnabled (false);
3215 for (a=actionListBranches.first();a;a=actionListBranches.next())
3216 a->setEnabled(true);
3217 actionEditDelete->setEnabled (true);
3218 switch (selection->getFrameType())
3221 actionFormatFrameNone->setOn(true);
3224 actionFormatFrameRectangle->setOn(true);
3229 actionFormatIncludeImagesVer->setOn
3230 ( ((BranchObj*)selection)->getIncludeImagesVer());
3231 actionFormatIncludeImagesHor->setOn
3232 ( ((BranchObj*)selection)->getIncludeImagesHor());
3233 actionFormatHideLinkUnselected->setOn
3234 (selection->getHideLinkUnselected());
3236 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3238 FloatObj *fo=(FloatImageObj*)selection;
3239 //FIXME do this in mainwindow standardFlagsDefault->setEnabled (false);
3241 actionEditOpenURL->setEnabled (false);
3242 actionEditOpenVymLink->setEnabled (false);
3243 actionEditDeleteVymLink->setEnabled (false);
3244 actionEditToggleHideExport->setEnabled (true);
3245 actionEditToggleHideExport->setOn (fo->hideInExport() );
3248 actionEditCopy->setEnabled (true);
3249 actionEditCut->setEnabled (true);
3250 actionEditPaste->setEnabled (false);
3251 for (a=actionListBranches.first();a;a=actionListBranches.next())
3252 a->setEnabled(false);
3253 actionEditDelete->setEnabled (true);
3254 actionFormatHideLinkUnselected->setOn
3255 ( selection->getHideLinkUnselected());
3256 actionEditMoveUp->setEnabled (false);
3257 actionEditMoveDown->setEnabled (false);
3262 actionEditCopy->setEnabled (false);
3263 actionEditCut->setEnabled (false);
3264 actionEditPaste->setEnabled (false);
3265 for (a=actionListBranches.first();a;a=actionListBranches.next())
3266 a->setEnabled(false);
3268 actionEditToggleScroll->setEnabled (false);
3269 actionEditOpenURL->setEnabled (false);
3270 actionEditOpenVymLink->setEnabled (false);
3271 actionEditDeleteVymLink->setEnabled (false);
3272 actionEditHeading2URL->setEnabled (false);
3273 actionEditDelete->setEnabled (false);
3274 actionEditMoveUp->setEnabled (false);
3275 actionEditMoveDown->setEnabled (false);
3276 actionEditToggleHideExport->setEnabled (false);
3280 ModMode Main::getModMode()
3282 if (actionModModeColor->isOn()) return ModModeColor;
3283 if (actionModModeCopy->isOn()) return ModModeCopy;
3284 if (actionModModeXLink->isOn()) return ModModeXLink;
3288 bool Main::autoEdit()
3290 return actionSettingsAutoEdit->isOn();
3293 bool Main::autoSelectHeading()
3295 return actionSettingsAutoSelectHeading->isOn();
3298 bool Main::useFlagGroups()
3300 return actionSettingsUseFlagGroups->isOn();
3303 void Main::windowShowNoteEditor()
3305 textEditor->setShowWithMain(true);
3307 actionViewToggleNoteEditor->setOn (true);
3310 void Main::windowHideNoteEditor()
3312 textEditor->setShowWithMain(false);
3314 actionViewToggleNoteEditor->setOn (false);
3317 void Main::windowNextEditor()
3319 if (tabWidget->currentPageIndex() < tabWidget->count())
3320 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3323 void Main::windowPreviousEditor()
3325 if (tabWidget->currentPageIndex() >0)
3326 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3329 void Main::standardFlagChanged()
3331 currentMapEditor()->toggleStandardFlag(sender()->name());
3334 void Main::testFunction()
3336 currentMapEditor()->testFunction();
3339 void Main::helpDoc()
3342 #if defined(Q_OS_MACX)
3343 docpath="./vym.app/Contents/vym.pdf";
3345 // default path in SUSE LINUX
3346 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3349 if (!QFile (docpath).exists() )
3351 // relative path for easy testing in tarball
3352 docpath="doc/vym.pdf";
3353 if (!QFile (docpath).exists() )
3355 // relative path for testing while still writing vym.tex
3356 docpath="doc/tex/vym.pdf";
3357 if (!QFile (docpath).exists() )
3359 // Try yet another one for Knoppix
3360 docpath="/usr/share/doc/packages/vym/vym.pdf";
3361 if (!QFile (docpath).exists() )
3363 QMessageBox::critical(0,
3364 tr("Critcal error"),
3365 tr("Couldn't find the documentation\n"
3366 "vym.pdf in various places."));
3373 Process *pdfProc = new Process();
3374 pdfProc->clearArguments();
3375 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3376 pdfProc->addArgument( docpath);
3378 if ( !pdfProc->start() )
3381 QMessageBox::warning(0,
3383 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3384 tr("Please use Settings->")+tr("Set application to open PDF files"));
3391 void Main::helpAbout()
3394 ad.setName ("aboutwindow");
3395 ad.setMinimumSize(500,500);
3396 ad.resize (QSize (500,500));
3400 void Main::helpAboutQT()
3402 QMessageBox::aboutQt( this, "Qt Application Example" );