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 // Sometimes we may need to remember old selections
76 // Create unique temporary directory
78 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
81 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
85 // Create direcctory for clipboard
86 clipboardDir=tmpVymDir+"/clipboard";
88 d.mkdir (clipboardDir,true);
89 makeSubDirs (clipboardDir);
94 // FIXME not used currently
95 // Set random seed (random used for object IDs)
96 // QTime t = QTime::currentTime(); // set random seed
97 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
100 // Initialize some settings, which are platform dependant
103 // application to open URLs
104 p="/mainwindow/readerURL";
105 #if defined(Q_OS_LINUX)
106 s=settings.value (p,"konqueror").toString();
108 #if defined(Q_OS_MACX)
109 s=settings.value (p,"/usr/bin/open").toString();
111 s=settings.value (p,"mozilla");
114 settings.setValue( p,s);
116 // application to open PDFs
117 p="/mainwindow/readerPDF";
118 #if defined(Q_OS_LINUX)
119 s=settings.value (p,"acroread").toString();
121 #if defined(Q_OS_MACX)
122 s=settings.value (p,"/usr/bin/open").toString();
124 s=settings.value (p,"acroread").toString();
127 settings.setValue( p,s);
132 // Create tab widget which holds the maps
133 tabWidget= new QTabWidget (this);
134 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
135 this, SLOT( editorChanged( QWidget * ) ) );
137 lineedit=new QLineEdit (this);
140 setCentralWidget(tabWidget);
144 setupFormatActions();
148 setupSettingsActions();
150 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
155 restoreState (settings.value("/mainwindow/state",0).toByteArray());
157 // Initialize Find window
158 findWindow=new FindWindow(NULL);
159 findWindow->move (x(),y()+70);
160 connect (findWindow, SIGNAL( findButton(QString) ),
161 this, SLOT(editFind(QString) ) );
162 connect (findWindow, SIGNAL( somethingChanged() ),
163 this, SLOT(editFindChanged() ) );
165 // Connect TextEditor, so that we can update flags if text changes
166 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
167 connect (textEditor, SIGNAL (textEditorClosed() ), this, SLOT (updateActions()));
175 settings.setValue ( "/mainwindow/geometry/size", size() );
176 settings.setValue ( "/mainwindow/geometry/pos", pos() );
178 settings.setValue ("/mainwindow/state",saveState(0));
180 settings.setValue( "/version/version", __VYM_VERSION );
181 settings.setValue( "/version/builddate", __BUILD_DATE );
183 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
184 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
185 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
186 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
187 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
188 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
191 int maps=lastMaps.count();
192 settings.setValue( "/lastMaps/number",maps );
193 for (int i=1;i<=maps;i++)
195 s=QString("/lastMaps/map-%1").arg(i);
196 if (!s.isEmpty() && i<=maxLastMaps)
197 settings.setValue (s, lastMaps.at(i-1));
201 // To make the texteditor save its settings, call the destructor
204 // Remove temporary directory
205 removeDir (QDir(tmpVymDir));
208 void Main::loadCmdLine()
210 /* TODO draw some kind of splashscreen while loading...
216 QStringList flist=options.getFileList();
217 QStringList::Iterator it=flist.begin();
219 while (it !=flist.end() )
221 fileLoad (*it, NewMap);
227 void Main::statusMessage(const QString &s)
229 statusBar()->message (s);
232 void Main::closeEvent (QCloseEvent* )
238 void Main::setupFileActions()
240 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
241 QToolBar *tb = addToolBar( tr ("&Map") );
242 tb->setObjectName ("mapTB");
245 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
246 a->setStatusTip ( tr( "New map","File menu" ) );
247 a->setShortcut ( Qt::CTRL + Qt::Key_N );
249 fileMenu->addAction (a);
250 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
252 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
253 a->setStatusTip (tr( "Open","File menu" ) );
254 a->setShortcut ( Qt::CTRL + Qt::Key_O );
256 fileMenu->addAction (a);
257 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
259 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
260 fileMenu->addSeparator();
262 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
263 a->setStatusTip ( tr( "Save" ));
264 a->setShortcut (Qt::CTRL + Qt::Key_S );
266 fileMenu->addAction (a);
267 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
270 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
271 a->setStatusTip (tr( "Save &As" ) );
272 fileMenu->addAction (a);
273 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
275 fileMenu->addSeparator();
277 fileImportMenu = fileMenu->addMenu (tr("Import"));
279 a = new QAction(tr("KDE Bookmarks"), this);
280 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
281 a->addTo (fileImportMenu);
282 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
284 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
286 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
287 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
288 a->addTo (fileImportMenu);
289 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
292 a = new QAction("Mind Manager...",this);
293 a->setStatusTip ( tr( "Import")+" Mind Manager" );
294 fileImportMenu->addAction (a);
295 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
297 a = new QAction( tr( "Import Dir"+QString("...") ), this);
298 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
299 fileImportMenu->addAction (a);
300 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
302 fileExportMenu = fileMenu->addMenu (tr("Export"));
304 a = new QAction( tr("Image")+QString("..."), this);
305 a->setStatusTip( tr( "Export map as image" ));
306 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
307 fileExportMenu->addAction (a);
309 a = new QAction( "Open Office"+QString("..."), this);
310 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
311 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
312 fileExportMenu->addAction (a);
314 a = new QAction( "Webpage (XHTML)...",this );
315 a->setShortcut (Qt::ALT + Qt::Key_X);
316 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
317 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
318 fileExportMenu->addAction (a);
320 a = new QAction( "Text (ASCII)...", this);
321 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
322 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
323 fileExportMenu->addAction (a);
325 a = new QAction( tr("KDE Bookmarks"), this);
326 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
327 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
328 fileExportMenu->addAction (a);
330 a = new QAction( "Taskjuggler...", this );
331 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
333 fileExportMenu->addAction (a);
335 a = new QAction( "LaTeX...", this);
336 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
338 fileExportMenu->addAction (a);
340 a = new QAction( "XML..." , this );
341 a->setStatusTip (tr( "Export as")+" XML");
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
343 fileExportMenu->addAction (a);
345 fileMenu->addSeparator();
347 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
348 a->setStatusTip ( tr( "Print" ) );
349 a->setShortcut (Qt::CTRL + Qt::Key_P );
351 fileMenu->addAction (a);
352 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
355 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
356 a->setStatusTip (tr( "Close Map" ) );
357 a->setShortcut (Qt::ALT + Qt::Key_C );
358 fileMenu->addAction (a);
359 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
361 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
362 a->setStatusTip ( tr( "Exit")+" "+__VYM );
363 a->setShortcut (Qt::CTRL + Qt::Key_Q );
364 fileMenu->addAction (a);
365 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
370 void Main::setupEditActions()
372 QToolBar *tb = addToolBar( tr ("&Actions") );
373 tb->setLabel( "Edit Actions" );
374 tb->setObjectName ("actionsTB");
375 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
379 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
380 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
381 a->setStatusTip (tr( "Undo" ) );
382 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
383 a->setEnabled (false);
385 editMenu->addAction (a);
388 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
389 a->setStatusTip (tr( "Redo" ));
390 a->setShortcut (Qt::CTRL + Qt::Key_Y );
392 editMenu->addAction (a);
393 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
396 editMenu->addSeparator();
397 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
398 a->setStatusTip ( tr( "Copy" ) );
399 a->setShortcut (Qt::CTRL + Qt::Key_C );
400 a->setEnabled (false);
402 editMenu->addAction (a);
403 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
406 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
407 a->setStatusTip ( tr( "Cut" ) );
408 a->setShortcut (Qt::CTRL + Qt::Key_X );
409 a->setEnabled (false);
411 editMenu->addAction (a);
413 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
415 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
416 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
417 a->setStatusTip ( tr( "Paste" ) );
418 a->setShortcut ( Qt::CTRL + Qt::Key_V );
419 a->setEnabled (false);
421 editMenu->addAction (a);
424 // Shortcuts to modify heading:
425 a = new QAction(tr( "Edit heading" ),this);
426 a->setStatusTip ( tr( "edit Heading" ));
427 a->setShortcut ( Qt::Key_Enter);
428 // a->setShortcutContext (Qt::WindowShortcut);
430 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
431 actionListBranches.append(a);
432 a = new QAction( tr( "Edit heading" ), this);
433 a->setStatusTip (tr( "edit Heading" ));
434 a->setShortcut (Qt::Key_Return );
435 //a->setShortcutContext (Qt::WindowShortcut);
437 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
438 actionListBranches.append(a);
439 editMenu->addAction (a);
441 a = new QAction( tr( "Edit heading" ), this);
442 a->setStatusTip (tr( "edit Heading" ));
443 a->setShortcut ( Qt::Key_F2 );
444 a->setShortcutContext (Qt::WindowShortcut);
446 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
447 actionListBranches.append(a);
449 // Shortcut to delete selection
450 a = new QAction( tr( "Delete Selection" ),this);
451 a->setStatusTip (tr( "Delete Selection" ));
452 a->setShortcut ( Qt::Key_Delete);
453 a->setShortcutContext (Qt::WindowShortcut);
455 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
458 // Shortcut to add branch
459 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
460 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
461 alt->setShortcut (Qt::Key_A);
462 alt->setShortcutContext (Qt::WindowShortcut);
464 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
465 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
466 a->setStatusTip ( tr( "Add a branch as child of selection" ));
467 a->setShortcut (Qt::Key_Insert);
468 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
469 actionListBranches.append(a);
470 #if defined (Q_OS_MACX)
471 // In OSX show different shortcut in menues, the keys work indepently always
472 actionEditAddBranch=alt;
474 actionEditAddBranch=a;
476 editMenu->addAction (actionEditAddBranch);
477 tb->addAction (actionEditAddBranch);
480 // Add branch by inserting it at selection
481 a = new QAction(tr( "Add branch (insert)" ), this);
482 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
483 a->setShortcut (Qt::ALT + Qt::Key_Insert );
484 a->setShortcutContext (Qt::WindowShortcut);
486 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
487 a->setEnabled (false);
488 actionListBranches.append(a);
489 actionEditAddBranchBefore=a;
490 a = new QAction(tr( "Add branch (insert)" ),this);
491 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
492 a->setShortcut ( Qt::ALT + Qt::Key_A );
493 a->setShortcutContext (Qt::WindowShortcut);
495 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
496 actionListBranches.append(a);
499 a = new QAction(tr( "Add branch above" ), this);
500 a->setStatusTip ( tr( "Add a branch above selection" ));
501 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
502 a->setShortcutContext (Qt::WindowShortcut);
504 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
505 a->setEnabled (false);
506 actionListBranches.append(a);
507 actionEditAddBranchAbove=a;
508 a = new QAction(tr( "Add branch above" ), this);
509 a->setStatusTip ( tr( "Add a branch above selection" ));
510 a->setShortcut (Qt::SHIFT+Qt::Key_A );
511 a->setShortcutContext (Qt::WindowShortcut);
513 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
514 actionListBranches.append(a);
517 a = new QAction(tr( "Add branch below" ), this);
518 a->setStatusTip ( tr( "Add a branch below selection" ));
519 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
520 a->setShortcutContext (Qt::WindowShortcut);
522 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
523 a->setEnabled (false);
524 actionListBranches.append(a);
525 actionEditAddBranchBelow=a;
526 a = new QAction(tr( "Add branch below" ), this);
527 a->setStatusTip ( tr( "Add a branch below selection" ));
528 a->setShortcut (Qt::CTRL +Qt::Key_A );
529 a->setShortcutContext (Qt::WindowShortcut);
531 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
532 actionListBranches.append(a);
534 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
535 a->setStatusTip ( tr( "Move branch up" ) );
536 a->setShortcut (Qt::Key_PageUp );
537 a->setEnabled (false);
539 editMenu->addAction (a);
540 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
543 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
544 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
545 a->setStatusTip (tr( "Move branch down" ) );
546 a->setShortcut ( Qt::Key_PageDown );
547 a->setEnabled (false);
549 editMenu->addAction (a);
550 actionEditMoveDown=a;
553 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
554 a->setShortcut ( Qt::Key_ScrollLock );
555 a->setStatusTip (tr( "Scroll branch" ) );
556 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
558 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
559 alt->setShortcut ( Qt::Key_S );
560 alt->setStatusTip (tr( "Scroll branch" ));
561 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
562 #if defined(Q_OS_MACX)
563 actionEditToggleScroll=alt;
565 actionEditToggleScroll=a;
567 actionEditToggleScroll->setEnabled (false);
568 actionEditToggleScroll->setToggleAction(true);
569 tb->addAction (actionEditToggleScroll);
570 editMenu->addAction ( actionEditToggleScroll);
571 editMenu->addAction (actionEditToggleScroll);
574 actionListBranches.append(actionEditToggleScroll);
576 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
577 a->setStatusTip (tr( "Unscroll all" ));
578 editMenu->addAction (a);
579 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
581 editMenu->addSeparator();
583 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
584 a->setStatusTip (tr( "Find" ) );
585 a->setShortcut (Qt::CTRL + Qt::Key_F );
586 editMenu->addAction (a);
587 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
589 editMenu->addSeparator();
591 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
592 a->setShortcut (Qt::CTRL + Qt::Key_U );
593 a->setShortcut (tr( "Open URL" ));
596 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
599 a = new QAction( tr( "Open URL in new tab" ), this);
600 a->setStatusTip (tr( "Open URL in new tab" ));
601 a->setShortcut (Qt::CTRL+Qt::Key_U );
603 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
604 actionEditOpenURLTab=a;
606 a = new QAction( tr( "Open all URLs in subtree" ), this);
607 a->setStatusTip (tr( "Open all URLs in subtree" ));
609 actionListBranches.append(a);
610 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
611 actionEditOpenMultipleURLTabs=a;
613 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
614 a->setStatusTip ( tr( "Edit URL" ) );
615 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
616 //a->setShortcut ( Qt::Key_U );
617 a->setShortcutContext (Qt::WindowShortcut);
618 actionListBranches.append(a);
620 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
623 a = new QAction( tr( "Use heading for URL" ), this);
624 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
625 a->setEnabled (false);
626 actionListBranches.append(a);
627 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
628 actionEditHeading2URL=a;
630 a = new QAction(tr( "Create URL to Bugzilla" ), this);
631 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
635 actionEditBugzilla2URL=a;
637 a = new QAction(tr( "Create URL to FATE" ), this);
638 a->setStatusTip ( tr( "Create URL to FATE" ));
639 a->setEnabled (false);
640 actionListBranches.append(a);
641 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
642 actionEditFATE2URL=a;
644 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open xlinked map" ), this);
645 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
647 a->setEnabled (false);
648 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
649 actionEditOpenVymLink=a;
651 a = new QAction(QPixmap(), tr( "Open all vym links in subtree" ), this);
652 a->setStatusTip ( tr( "Open all vym links in subtree" ));
653 a->setEnabled (false);
654 actionListBranches.append(a);
655 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
656 actionEditOpenMultipleVymLinks=a;
659 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
660 a->setEnabled (false);
661 a->setStatusTip ( tr( "Edit link to another vym map" ));
662 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
663 actionListBranches.append(a);
666 a = new QAction(tr( "Delete vym link" ),this);
667 a->setStatusTip ( tr( "Delete link to another vym map" ));
668 a->setEnabled (false);
669 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
670 actionEditDeleteVymLink=a;
672 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
673 a->setStatusTip ( tr( "Hide object in exports" ) );
674 a->setShortcut (Qt::Key_H );
675 a->setToggleAction(true);
677 a->setEnabled (false);
678 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
679 actionEditToggleHideExport=a;
681 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
682 a->setStatusTip ( tr( "Edit Map Info" ));
683 a->setEnabled (true);
684 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
687 // Import at selection (adding to selection)
688 a = new QAction( tr( "Add map (insert)" ),this);
689 a->setStatusTip (tr( "Add map at selection" ));
690 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
691 a->setEnabled (false);
692 actionListBranches.append(a);
693 actionEditImportAdd=a;
695 // Import at selection (replacing selection)
696 a = new QAction( tr( "Add map (replace)" ), this);
697 a->setStatusTip (tr( "Replace selection with map" ));
698 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
699 a->setEnabled (false);
700 actionListBranches.append(a);
701 actionEditImportReplace=a;
704 a = new QAction( tr( "Save selection" ), this);
705 a->setStatusTip (tr( "Save selection" ));
706 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
707 a->setEnabled (false);
708 actionListBranches.append(a);
709 actionEditSaveBranch=a;
711 // Only remove branch, not its childs
712 a = new QAction(tr( "Remove only branch " ), this);
713 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
714 a->setShortcut (Qt::ALT + Qt::Key_Delete );
715 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
716 a->setEnabled (false);
718 actionListBranches.append(a);
719 actionEditRemoveBranchKeepChilds=a;
721 // Only remove childs of a branch
722 a = new QAction( tr( "Remove childs" ), this);
723 a->setStatusTip (tr( "Remove childs of branch" ));
724 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
725 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
726 a->setEnabled (false);
727 actionListBranches.append(a);
728 actionEditRemoveChilds=a;
730 // Shortcuts for navigating with cursor:
731 a = new QAction(tr( "Select upper branch" ), this);
732 a->setStatusTip ( tr( "Select upper branch" ));
733 a->setShortcut (Qt::Key_Up );
734 a->setShortcutContext (Qt::WindowShortcut);
736 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
737 a = new QAction( tr( "Select lower branch" ),this);
738 a->setStatusTip (tr( "Select lower branch" ));
739 a->setShortcut ( Qt::Key_Down );
740 a->setShortcutContext (Qt::WindowShortcut);
742 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
743 a = new QAction(tr( "Select left branch" ), this);
744 a->setStatusTip ( tr( "Select left branch" ));
745 a->setShortcut (Qt::Key_Left );
746 a->setShortcutContext (Qt::WindowShortcut);
748 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
749 a = new QAction( tr( "Select child branch" ), this);
750 a->setStatusTip (tr( "Select right branch" ));
751 a->setShortcut (Qt::Key_Right);
752 a->setShortcutContext (Qt::WindowShortcut);
754 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
755 a = new QAction( tr( "Select first branch" ), this);
756 a->setStatusTip (tr( "Select first branch" ));
757 a->setShortcut (Qt::Key_Home );
758 a->setShortcutContext (Qt::WindowShortcut);
760 a->setEnabled (false);
761 editMenu->addAction (a);
762 actionListBranches.append(a);
763 actionEditSelectFirst=a;
764 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
765 a = new QAction( tr( "Select last branch" ),this);
766 a->setStatusTip (tr( "Select last branch" ));
767 a->setShortcut ( Qt::Key_End );
768 a->setShortcutContext (Qt::WindowShortcut);
770 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
771 a->setEnabled (false);
772 editMenu->addAction (a);
773 actionListBranches.append(a);
774 actionEditSelectLast=a;
776 a = new QAction( tr( "Add Image" )+QString("..."), this);
777 a->setStatusTip (tr( "Add Image" ));
778 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
779 actionEditLoadImage=a;
784 void Main::setupFormatActions()
786 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
788 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
789 tb->setObjectName ("formatTB");
792 pix.fill (Qt::black);
793 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
794 a->setStatusTip ( tr( "Set Color" ));
795 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
797 formatMenu->addAction (a);
799 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
800 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
801 a->setShortcut (Qt::CTRL + Qt::Key_K );
802 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
803 a->setEnabled (false);
805 formatMenu->addAction (a);
806 actionListBranches.append(a);
807 actionFormatPickColor=a;
809 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
810 a->setStatusTip ( tr( "Color branch" ) );
811 a->setShortcut (Qt::CTRL + Qt::Key_I);
812 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
813 a->setEnabled (false);
815 formatMenu->addAction (a);
816 actionListBranches.append(a);
817 actionFormatColorBranch=a;
819 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
820 a->setStatusTip ( tr( "Color Subtree" ));
821 a->setShortcut (Qt::CTRL + Qt::Key_T);
822 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
823 a->setEnabled (false);
824 formatMenu->addAction (a);
826 actionListBranches.append(a);
827 actionFormatColorSubtree=a;
829 formatMenu->addSeparator();
830 actionGroupFormatLinkStyles=new QActionGroup ( this);
831 actionGroupFormatLinkStyles->setExclusive (true);
832 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
833 a->setStatusTip (tr( "Line" ));
834 a->setToggleAction(true);
835 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
836 formatMenu->addAction (a);
837 actionFormatLinkStyleLine=a;
838 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
839 a->setStatusTip (tr( "Line" ));
840 a->setToggleAction(true);
841 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
842 formatMenu->addAction (a);
843 actionFormatLinkStyleParabel=a;
844 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
845 a->setStatusTip (tr( "PolyLine" ));
846 a->setToggleAction(true);
847 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
848 formatMenu->addAction (a);
849 actionFormatLinkStylePolyLine=a;
850 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
851 a->setStatusTip (tr( "PolyParabel" ) );
852 a->setToggleAction(true);
853 a->setChecked (true);
854 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
855 formatMenu->addAction (a);
856 actionFormatLinkStylePolyParabel=a;
858 actionGroupFormatFrameTypes=new QActionGroup ( this);
859 actionGroupFormatFrameTypes->setExclusive (true);
860 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
861 a->setStatusTip (tr("No Frame"));
862 a->setToggleAction(true);
863 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
864 actionFormatFrameNone=a;
865 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
866 a->setStatusTip (tr( "Rectangle" ));
867 a->setToggleAction(true);
868 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
869 actionFormatFrameRectangle=a;
871 a = new QAction( tr( "Include images vertically" ), this);
872 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
873 a->setToggleAction(true);
874 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
875 actionFormatIncludeImagesVer=a;
877 a = new QAction( tr( "Include images horizontally" ), this);
878 a->setStatusTip ( tr ("Include left and right position of images into branch"));
879 a->setToggleAction(true);
880 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
881 actionFormatIncludeImagesHor=a;
883 a = new QAction( tr( "Hide link if object is not selected" ), this);
884 a->setStatusTip (tr( "Hide link" ));
885 a->setToggleAction(true);
886 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
887 actionFormatHideLinkUnselected=a;
889 formatMenu->addSeparator();
890 a= new QAction( tr( "&Use color of heading for link" ), this);
891 a->setStatusTip (tr( "Use same color for links and headings" ));
892 a->setToggleAction(true);
893 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
894 formatMenu->addAction (a);
895 actionFormatLinkColorHint=a;
897 pix.fill (Qt::white);
898 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
899 a->setStatusTip (tr( "Set Link Color" ));
900 formatMenu->addAction (a);
901 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
902 actionFormatLinkColor=a;
904 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
905 a->setStatusTip (tr( "Set Background Color" ));
906 formatMenu->addAction (a);
907 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
908 actionFormatBackColor=a;
912 void Main::setupViewActions()
914 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
915 tb->setLabel( "View Actions" );
916 tb->setObjectName ("viewTB");
917 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
920 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
921 a->setStatusTip ( tr( "Zoom reset" ) );
922 a->setShortcut (Qt::CTRL + Qt::Key_0 );
924 viewMenu->addAction (a);
925 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
927 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
928 a->setStatusTip (tr( "Zoom in" ));
929 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
931 viewMenu->addAction (a);
932 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
934 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
935 a->setStatusTip (tr( "Zoom out" ));
936 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
938 viewMenu->addAction (a);
939 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
942 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
943 a->setStatusTip ( tr( "Show Note Editor" ));
944 a->setShortcut ( Qt::CTRL + Qt::Key_E );
945 a->setToggleAction(true);
946 if (textEditor->showWithMain())
951 viewMenu->addAction (a);
952 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
953 actionViewToggleNoteEditor=a;
955 a = new QAction( tr( "Show history window" ),this );
956 a->setStatusTip ( tr( "Show history window" ));
957 a->setShortcut ( Qt::CTRL + Qt::Key_H );
958 a->setToggleAction(false);
959 viewMenu->addAction (a);
960 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
961 actionViewToggleHistoryWindow=a;
963 a = new QAction(tr( "Next Window" ), this);
964 a->setStatusTip ( tr( "&Next Window" ) );
965 a->setShortcut (Qt::ALT + Qt::Key_N );
966 viewMenu->addAction (a);
967 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
969 a = new QAction (tr( "Previous Window" ), this );
970 a->setStatusTip (tr( "&Previous Window" ));
971 a->setShortcut (Qt::ALT + Qt::Key_P );
972 viewMenu->addAction (a);
973 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
977 void Main::setupModeActions()
979 //QPopupMenu *menu = new QPopupMenu( this );
980 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
982 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
983 tb->setObjectName ("modesTB");
985 actionGroupModModes=new QActionGroup ( this);
986 actionGroupModModes->setExclusive (true);
987 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
988 a->setShortcut (Qt::Key_J);
989 a->setStatusTip ( tr( "Use modifier to color branches" ));
990 a->setToggleAction(true);
993 actionModModeColor=a;
995 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
996 a->setShortcut( Qt::Key_K);
997 a->setStatusTip( tr( "Use modifier to copy" ));
998 a->setToggleAction(true);
1000 actionModModeCopy=a;
1002 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1003 a->setShortcut (Qt::Key_L);
1004 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1005 a->setToggleAction(true);
1007 actionModModeXLink=a;
1011 void Main::setupFlagActions()
1013 // Create System Flags
1014 systemFlagsDefault = new FlagRowObj ();
1015 systemFlagsDefault->setVisibility (false);
1016 systemFlagsDefault->setName ("systemFlagsDef");
1018 FlagObj *fo = new FlagObj ();
1019 fo->load(QPixmap(flagsPath+"flag-note.png"));
1020 fo->setName("note");
1021 fo->setToolTip(tr("Note","Systemflag"));
1022 systemFlagsDefault->addFlag (fo); // makes deep copy
1024 fo->load(QPixmap(flagsPath+"flag-url.png"));
1026 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1027 systemFlagsDefault->addFlag (fo);
1029 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1030 fo->setName("vymLink");
1031 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1032 systemFlagsDefault->addFlag (fo);
1034 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1035 fo->setName("scrolledright");
1036 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1037 systemFlagsDefault->addFlag (fo);
1039 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1040 fo->setName("tmpUnscrolledright");
1041 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1042 systemFlagsDefault->addFlag (fo);
1044 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1045 fo->setName("hideInExport");
1046 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1047 systemFlagsDefault->addFlag (fo);
1049 // Create Standard Flags
1050 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1051 tb->setObjectName ("standardFlagTB");
1053 standardFlagsDefault = new FlagRowObj ();
1054 standardFlagsDefault->setVisibility (false);
1055 standardFlagsDefault->setName ("standardFlagsDef");
1056 standardFlagsDefault->setToolBar (tb);
1058 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1059 fo->setName ("exclamationmark");
1060 fo->setGroup("standard-mark");
1061 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1064 a->setCheckable(true);
1065 a->setObjectName(fo->getName());
1066 a->setToolTip(tr("Take care!","Standardflag"));
1067 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1068 standardFlagsDefault->addFlag (fo); // makes deep copy
1070 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1071 fo->setName("questionmark");
1072 fo->setGroup("standard-mark");
1073 a=new QAction (fo->getPixmap(),fo->getName(),this);
1076 a->setCheckable(true);
1077 a->setObjectName(fo->getName());
1078 a->setToolTip(tr("Really?","Standardflag"));
1079 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1080 standardFlagsDefault->addFlag (fo);
1082 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1083 fo->setName("hook-green");
1084 fo->setGroup("standard-hook");
1085 a=new QAction (fo->getPixmap(),fo->getName(),this);
1088 a->setCheckable(true);
1089 a->setObjectName(fo->getName());
1090 a->setToolTip(tr("ok!","Standardflag"));
1091 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1092 standardFlagsDefault->addFlag (fo);
1094 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1095 fo->setName("cross-red");
1096 fo->setGroup("standard-hook");
1097 a=new QAction (fo->getPixmap(),fo->getName(),this);
1100 a->setCheckable(true);
1101 a->setObjectName(fo->getName());
1102 a->setToolTip(tr("Not ok!","Standardflag"));
1103 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1104 standardFlagsDefault->addFlag (fo);
1106 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1107 fo->setName("stopsign");
1108 a=new QAction (fo->getPixmap(),fo->getName(),this);
1111 a->setCheckable(true);
1112 a->setObjectName(fo->getName());
1113 a->setToolTip(tr("This won't work!","Standardflag"));
1114 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1115 standardFlagsDefault->addFlag (fo);
1117 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1118 fo->setName("smiley-good");
1119 fo->setGroup("standard-smiley");
1120 a=new QAction (fo->getPixmap(),fo->getName(),this);
1123 a->setCheckable(true);
1124 a->setObjectName(fo->getName());
1125 a->setToolTip(tr("Good","Standardflag"));
1126 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1127 standardFlagsDefault->addFlag (fo);
1129 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1130 fo->setName("smiley-sad");
1131 fo->setGroup("standard-smiley");
1132 a=new QAction (fo->getPixmap(),fo->getName(),this);
1135 a->setCheckable(true);
1136 a->setObjectName(fo->getName());
1137 a->setToolTip(tr("Bad","Standardflag"));
1138 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1139 standardFlagsDefault->addFlag (fo);
1141 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1142 // Original omg.png (in KDE emoticons)
1143 fo->setName("smiley-omg");
1144 fo->setGroup("standard-smiley");
1145 a=new QAction (fo->getPixmap(),fo->getName(),this);
1148 a->setCheckable(true);
1149 a->setObjectName(fo->getName());
1150 a->setToolTip(tr("Oh no!","Standardflag"));
1151 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1152 standardFlagsDefault->addFlag (fo);
1154 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1155 fo->setName("clock");
1156 a=new QAction (fo->getPixmap(),fo->getName(),this);
1159 a->setCheckable(true);
1160 a->setObjectName(fo->getName());
1161 a->setToolTip(tr("Time critical","Standardflag"));
1162 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1163 standardFlagsDefault->addFlag (fo);
1165 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1166 fo->setName("phone");
1167 a=new QAction (fo->getPixmap(),fo->getName(),this);
1170 a->setCheckable(true);
1171 a->setObjectName(fo->getName());
1172 a->setToolTip(tr("Call...","Standardflag"));
1173 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1174 standardFlagsDefault->addFlag (fo);
1176 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1177 fo->setName("lamp");
1178 a=new QAction (fo->getPixmap(),fo->getName(),this);
1181 a->setCheckable(true);
1182 a->setObjectName(fo->getName());
1183 a->setToolTip(tr("Idea!","Standardflag"));
1184 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1185 standardFlagsDefault->addFlag (fo);
1187 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1188 fo->setName("arrow-up");
1189 fo->setGroup("standard-arrow");
1190 a=new QAction (fo->getPixmap(),fo->getName(),this);
1193 a->setCheckable(true);
1194 a->setObjectName(fo->getName());
1195 a->setToolTip(tr("Important","Standardflag"));
1196 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1197 standardFlagsDefault->addFlag (fo);
1199 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1200 fo->setName("arrow-down");
1201 fo->setGroup("standard-arrow");
1202 a=new QAction (fo->getPixmap(),fo->getName(),this);
1205 a->setCheckable(true);
1206 a->setObjectName(fo->getName());
1207 a->setToolTip(tr("Unimportant","Standardflag"));
1208 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1209 standardFlagsDefault->addFlag (fo);
1211 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1212 fo->setName("2arrow-up");
1213 fo->setGroup("standard-arrow");
1214 a=new QAction (fo->getPixmap(),fo->getName(),this);
1217 a->setCheckable(true);
1218 a->setObjectName(fo->getName());
1219 a->setToolTip(tr("Very important!","Standardflag"));
1220 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1221 standardFlagsDefault->addFlag (fo);
1223 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1224 fo->setName("2arrow-down");
1225 fo->setGroup("standard-arrow");
1226 a=new QAction (fo->getPixmap(),fo->getName(),this);
1229 a->setCheckable(true);
1230 a->setObjectName(fo->getName());
1231 a->setToolTip(tr("Very unimportant!","Standardflag"));
1232 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1233 standardFlagsDefault->addFlag (fo);
1235 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1236 fo->setName("thumb-up");
1237 fo->setGroup("standard-thumb");
1238 a=new QAction (fo->getPixmap(),fo->getName(),this);
1241 a->setCheckable(true);
1242 a->setObjectName(fo->getName());
1243 a->setToolTip(tr("I like this","Standardflag"));
1244 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1245 standardFlagsDefault->addFlag (fo);
1247 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1248 fo->setName("thumb-down");
1249 fo->setGroup("standard-thumb");
1250 a=new QAction (fo->getPixmap(),fo->getName(),this);
1253 a->setCheckable(true);
1254 a->setObjectName(fo->getName());
1255 a->setToolTip(tr("I do not like this","Standardflag"));
1256 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1257 standardFlagsDefault->addFlag (fo);
1259 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1260 fo->setName("rose");
1261 a=new QAction (fo->getPixmap(),fo->getName(),this);
1264 a->setCheckable(true);
1265 a->setObjectName(fo->getName());
1266 a->setToolTip(tr("Rose","Standardflag"));
1267 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1268 standardFlagsDefault->addFlag (fo);
1270 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1271 fo->setName("heart");
1272 a=new QAction (fo->getPixmap(),fo->getName(),this);
1274 a->setCheckable(true);
1275 a->setObjectName(fo->getName());
1276 a->setToolTip(tr("I just love... ","Standardflag"));
1277 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1278 standardFlagsDefault->addFlag (fo);
1280 fo->load(QPixmap(flagsPath+"flag-present.png"));
1281 fo->setName("present");
1282 a=new QAction (fo->getPixmap(),fo->getName(),this);
1285 a->setCheckable(true);
1286 a->setObjectName(fo->getName());
1287 a->setToolTip(tr("Surprise!","Standardflag"));
1288 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1289 standardFlagsDefault->addFlag (fo);
1291 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1292 fo->setName("flash");
1293 a=new QAction (fo->getPixmap(),fo->getName(),this);
1296 a->setCheckable(true);
1297 a->setObjectName(fo->getName());
1298 a->setToolTip(tr("Dangerous","Standardflag"));
1299 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1300 standardFlagsDefault->addFlag (fo);
1302 fo->load(QPixmap(flagsPath+"flag-info.png"));
1303 // Original: xsldbg_output.png
1304 fo->setName("info");
1305 a=new QAction (fo->getPixmap(),fo->getName(),this);
1308 a->setCheckable(true);
1309 a->setObjectName(fo->getName());
1310 a->setToolTip(tr("Info","Standardflag"));
1311 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1312 standardFlagsDefault->addFlag (fo);
1314 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1315 // Original khelpcenter.png
1316 fo->setName("lifebelt");
1317 a=new QAction (fo->getPixmap(),fo->getName(),this);
1320 a->setCheckable(true);
1321 a->setObjectName(fo->getName());
1322 a->setToolTip(tr("This will help","Standardflag"));
1323 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1324 standardFlagsDefault->addFlag (fo);
1330 void Main::setupSettingsActions()
1332 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1336 a = new QAction( tr( "Set application to open pdf files"), this);
1337 a->setStatusTip ( tr( "Set application to open pdf files"));
1338 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1339 settingsMenu->addAction (a);
1341 a = new QAction( tr( "Set application to open external links"), this);
1342 a->setStatusTip( tr( "Set application to open external links"));
1343 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1344 settingsMenu->addAction (a);
1346 settingsMenu->addSeparator();
1347 a = new QAction( tr( "Edit branch after adding it" ), this );
1348 a->setStatusTip( tr( "Edit branch after adding it" ));
1349 a->setToggleAction(true);
1350 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1351 settingsMenu->addAction (a);
1352 actionSettingsAutoEdit=a;
1354 a= new QAction( tr( "Select branch after adding it" ), this );
1355 a->setStatusTip( tr( "Select branch after adding it" ));
1356 a->setToggleAction(true);
1357 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1358 settingsMenu->addAction (a);
1359 actionSettingsAutoSelectHeading=a;
1361 a= new QAction(tr( "Select existing heading" ), this);
1362 a->setStatusTip( tr( "Select heading before editing" ));
1363 a->setToggleAction(true);
1364 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1365 settingsMenu->addAction (a);
1366 actionSettingsAutoSelectText=a;
1368 a= new QAction( tr( "Delete key" ), this);
1369 a->setStatusTip( tr( "Delete key for deleting branches" ));
1370 a->setToggleAction(true);
1371 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1372 settingsMenu->addAction (a);
1373 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1374 actionSettingsUseDelKey=a;
1376 a= new QAction( tr( "Exclusive flags" ), this);
1377 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1378 a->setToggleAction(true);
1379 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1380 settingsMenu->addAction (a);
1381 actionSettingsUseFlagGroups=a;
1383 a= new QAction( tr( "Use hide flags" ), this);
1384 a->setStatusTip( tr( "Use hide flag during exports " ));
1385 a->setToggleAction(true);
1386 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1387 settingsMenu->addAction (a);
1388 actionSettingsUseHideExport=a;
1392 void Main::setupTestActions()
1394 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1397 a = new QAction( tr( "Test function" ), this);
1398 a->setStatusTip( tr( "Call test function" ));
1399 a->setShortcut (Qt::Key_F4 );
1400 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1401 testMenu->addAction (a);
1402 a = new QAction( tr( "Command" ), this);
1403 a->setStatusTip( tr( "Enter command to call in editor" ));
1404 a->setShortcut (Qt::Key_F5 );
1405 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1406 testMenu->addAction (a);
1410 void Main::setupHelpActions()
1412 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1415 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1416 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1417 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1418 helpMenu->addAction (a);
1420 a = new QAction( tr( "About VYM" ), this);
1421 a->setStatusTip( tr( "About VYM")+" "__VYM);
1422 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1423 helpMenu->addAction (a);
1425 a = new QAction( tr( "About QT" ), this);
1426 a->setStatusTip( tr( "Information about QT toolkit" ));
1427 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1428 helpMenu->addAction (a);
1432 void Main::setupContextMenus()
1436 // Context Menu for branch or mapcenter
1437 branchContextMenu =new QMenu (this);
1440 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1441 branchAddContextMenu->addAction (actionEditPaste );
1442 branchAddContextMenu->addAction ( actionEditAddBranch );
1443 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1444 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1445 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1446 branchAddContextMenu->addSeparator();
1447 branchAddContextMenu->addAction ( actionEditLoadImage);
1448 branchAddContextMenu->addSeparator();
1449 branchAddContextMenu->addAction ( actionEditImportAdd );
1450 branchAddContextMenu->addAction ( actionEditImportReplace );
1453 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1454 branchRemoveContextMenu->addAction (actionEditCut);
1455 branchRemoveContextMenu->addAction ( actionEditDelete );
1456 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1457 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1460 actionEditSaveBranch->addTo( branchContextMenu );
1462 branchContextMenu->addSeparator();
1463 branchContextMenu->addAction ( actionFormatFrameNone );
1464 branchContextMenu->addAction ( actionFormatFrameRectangle);
1466 branchContextMenu->addSeparator();
1467 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1468 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1469 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1471 // Submenu for Links (URLs, vymLinks)
1472 branchLinksContextMenu =new QMenu (this);
1474 branchContextMenu->addSeparator();
1475 branchLinksContextMenu=branchContextMenu->addMenu(tr("URLs and vymLinks"));
1476 branchLinksContextMenu->addAction ( actionEditOpenURL );
1477 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1478 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1479 branchLinksContextMenu->addAction ( actionEditURL );
1480 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1481 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1482 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1484 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1486 branchLinksContextMenu->addSeparator();
1487 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1488 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1489 branchLinksContextMenu->addAction ( actionEditVymLink );
1490 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1493 // Context Menu for XLinks in a branch menu
1494 // This will be populated "on demand" in MapEditor::updateActions
1495 branchContextMenu->addSeparator();
1496 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1497 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1498 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1499 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1502 // Context menu for floatimage
1503 floatimageContextMenu =new QMenu (this);
1504 a= new QAction (tr ("Save image"),this);
1505 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1506 floatimageContextMenu->addAction (a);
1508 floatimageContextMenu->addSeparator();
1509 actionEditCopy->addTo( floatimageContextMenu );
1510 actionEditCut->addTo( floatimageContextMenu );
1512 floatimageContextMenu->addSeparator();
1513 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1516 // Context menu for canvas
1517 canvasContextMenu =new QMenu (this);
1518 actionEditMapInfo->addTo( canvasContextMenu );
1519 canvasContextMenu->insertSeparator();
1520 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1521 canvasContextMenu->insertSeparator();
1522 actionFormatLinkColorHint->addTo( canvasContextMenu );
1523 actionFormatLinkColor->addTo( canvasContextMenu );
1524 actionFormatBackColor->addTo( canvasContextMenu );
1526 // Menu for last opened files
1527 // Read settings initially
1529 int j=settings.readNumEntry( "/lastMaps/number",0);
1530 for (int i=1;i<=j;i++)
1532 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1533 if (!s.isEmpty() && j<=maxLastMaps)
1536 setupLastMapsMenu();
1537 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1540 void Main::setupLastMapsMenu()
1542 // Remove double entries
1543 QStringList::Iterator it=lastMaps.begin();
1544 QStringList::Iterator jt;
1545 while (it!=lastMaps.end() )
1549 while (jt!=lastMaps.end() )
1552 jt=lastMaps.remove(jt);
1559 // Limit length of list to maxLastMaps
1560 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1562 // build Menu from lastMaps string list
1563 fileLastMapsMenu->clear();
1564 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1565 fileLastMapsMenu->addAction (*it );
1568 void Main::hideEvent (QHideEvent * )
1570 if (!textEditor->isMinimized() ) textEditor->hide();
1573 void Main::showEvent (QShowEvent * )
1575 if (textEditor->showWithMain()) textEditor->showNormal();
1578 bool Main::reallyWriteDirectory(const QString &dir)
1580 QStringList eList = QDir(dir).entryList();
1581 if (eList.first() ==".") eList.pop_front(); // remove "."
1582 if (eList.first() =="..") eList.pop_front(); // remove "."
1583 if (!eList.isEmpty())
1585 QMessageBox mb( __VYM,
1586 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1587 QMessageBox::Warning,
1589 QMessageBox::Cancel | QMessageBox::Default,
1590 QMessageBox::QMessageBox::NoButton );
1592 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1593 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1596 case QMessageBox::Yes:
1599 case QMessageBox::Cancel:
1607 QString Main::browseDirectory (const QString &caption)
1609 Q3FileDialog fd(this,caption);
1610 fd.setMode (Q3FileDialog::DirectoryOnly);
1611 fd.setCaption(__VYM " - "+caption);
1614 if ( fd.exec() == QDialog::Accepted )
1615 return fd.selectedFile();
1620 MapEditor* Main::currentMapEditor() const
1622 if ( tabWidget->currentPage() &&
1623 tabWidget->currentPage()->inherits( "MapEditor" ) )
1624 return (MapEditor*)tabWidget->currentPage();
1628 //TODO not used now, maybe use this for overview window later
1629 void Main::newView()
1631 // Open a new view... have it delete when closed.
1632 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1633 qApp->setMainWidget(m);
1635 qApp->setMainWidget(0);
1638 void Main::editorChanged(QWidget *)
1640 // Unselect all possibly selected objects
1641 // (Important to update note editor)
1644 for (i=0;i<=tabWidget->count() -1;i++)
1647 me=(MapEditor*)tabWidget->page(i);
1650 currentMapEditor()->reselect();
1652 // Update actions to in menus and toolbars according to editor
1653 currentMapEditor()->updateActions();
1656 void Main::fileNew()
1658 QString fn="unnamed";
1659 MapEditor* medit = new MapEditor ( NULL);
1660 tabWidget->addTab (medit,fn);
1661 tabWidget->showPage(medit);
1662 medit->viewport()->setFocus();
1663 // For the very first map we do not have flagrows yet...
1664 medit->select("mc:");
1667 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1669 ErrorCode err=success;
1671 // fn is usually the archive, mapfile the file after uncompressing
1674 // Make fn absolute (needed for unzip)
1675 fn=QDir (fn).absPath();
1681 // Check, if map is already loaded
1683 while (i<=tabWidget->count() -1)
1685 me=(MapEditor*)tabWidget->page(i);
1686 if (me->getFilePath() == fn)
1688 // Already there, ask for confirmation
1689 QMessageBox mb( __VYM,
1690 tr("The map %1\nis already opened."
1691 "Opening the same map in multiple editors may lead \n"
1692 "to confusion when finishing working with vym."
1693 "Do you want to").arg(fn),
1694 QMessageBox::Warning,
1695 QMessageBox::Yes | QMessageBox::Default,
1696 QMessageBox::Cancel | QMessageBox::Escape,
1697 QMessageBox::NoButton);
1698 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1699 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1702 case QMessageBox::Yes:
1704 i=tabWidget->count();
1706 case QMessageBox::Cancel:
1718 if ( !fn.isEmpty() )
1720 me = currentMapEditor();
1721 int tabIndex=tabWidget->currentPageIndex();
1722 // Check first, if mapeditor exists
1723 // If it is not default AND we want a new map,
1724 // create a new mapeditor in a new tab
1725 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1727 me= new MapEditor ( NULL);
1728 tabWidget->addTab (me,fn);
1729 tabIndex=tabWidget->indexOf (me);
1730 tabWidget->setCurrentPage (tabIndex);
1733 // Check, if file exists (important for creating new files
1734 // from command line
1735 if (!QFile(fn).exists() )
1737 QMessageBox mb( __VYM,
1738 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1739 QMessageBox::Question,
1741 QMessageBox::Cancel | QMessageBox::Default,
1742 QMessageBox::NoButton );
1744 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1745 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1748 case QMessageBox::Yes:
1750 currentMapEditor()->setFilePath(fn);
1751 tabWidget->setTabLabel (currentMapEditor(),
1752 currentMapEditor()->getFileName() );
1753 statusBar()->message( "Created " + fn , statusbarTime );
1756 case QMessageBox::Cancel:
1757 // don't create new map
1758 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1765 //tabWidget->currentPage() won't be NULL here, because of above...
1766 tabWidget->showPage(me);
1767 me->viewport()->setFocus();
1769 // Create temporary directory for packing
1771 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1774 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1775 tr("Couldn't create temporary directory before load\n"));
1779 // Try to unzip file
1780 err=unzipDir (tmpMapDir,fn);
1784 me->setZipped(false);
1787 me->setZipped(true);
1789 // Look for mapname.xml
1790 mapfile= fn.left(fn.findRev(".",-1,true));
1791 mapfile=mapfile.section( '/', -1 );
1792 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1793 if (!file.exists() )
1795 // mapname.xml does not exist, well,
1796 // maybe some renamed the mapname.vym file...
1797 // Try to find any .xml in the toplevel
1798 // directory of the .vym file
1799 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1800 if (flist.count()==1)
1802 // Only one entry, take this one
1803 mapfile=tmpMapDir + "/"+flist.first();
1806 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1807 *it=tmpMapDir + "/" + *it;
1808 // TODO Multiple entries, load all (but only the first one into this ME)
1809 //mainWindow->fileLoadFromTmp (flist);
1810 //returnCode=1; // Silently forget this attempt to load
1811 qWarning ("MainWindow::load (fn) multimap found...");
1814 if (flist.isEmpty() )
1816 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1817 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1820 } //file doesn't exist
1822 mapfile=file.name();
1827 // Save existing filename in case we import
1828 QString fn_org=me->getFilePath();
1830 // Finally load map into mapEditor
1831 me->setFilePath (mapfile,fn);
1832 err=me->load(mapfile,lmode);
1834 // Restore old (maybe empty) filepath, if this is an import
1836 me->setFilePath (fn_org);
1839 // Finally check for errors and go home
1842 if (lmode==NewMap) fileCloseMap();
1843 statusBar()->message( "Could not load " + fn, statusbarTime );
1848 me->setFilePath (fn);
1849 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1850 if (fn.left(9)!="/tmp/vym-")
1852 // Only append to lastMaps if not loaded from a tmpDir
1853 // e.g. imported bookmarks are in a tmpDir
1854 lastMaps.prepend(me->getFilePath() );
1855 setupLastMapsMenu();
1857 actionFilePrint->setEnabled (true);
1859 statusBar()->message( "Loaded " + fn, statusbarTime );
1863 removeDir (QDir(tmpMapDir));
1869 void Main::fileLoad(const LoadMode &lmode)
1871 QStringList filters;
1872 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1873 QFileDialog *fd=new QFileDialog( this);
1874 fd->setDir (lastFileDir);
1875 fd->setFileMode (QFileDialog::ExistingFiles);
1876 fd->setFilters (filters);
1880 fd->setCaption(__VYM " - " +tr("Load vym map"));
1883 fd->setCaption(__VYM " - " +tr("Import: Add vym map to selection"));
1886 fd->setCaption(__VYM " - " +tr("Import: Replace selection with vym map"));
1892 if ( fd->exec() == QDialog::Accepted )
1894 lastFileDir=fd->directory().path();
1895 QStringList flist = fd->selectedFiles();
1896 QStringList::Iterator it = flist.begin();
1897 while( it != flist.end() )
1900 fileLoad(*it, lmode);
1907 void Main::fileLoad()
1912 void Main::fileLoadLast(QAction *a)
1914 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1917 void Main::fileSave(const SaveMode &savemode)
1919 // tmp dir for zipping
1923 ErrorCode err=success;
1925 QString safeFilePath;
1927 bool saveZipped=currentMapEditor()->saveZipped();
1929 MapEditor * me=currentMapEditor();
1932 QString fn=me->getFilePath();
1933 // filename=unnamed, filepath="" in constructor...
1934 if ( !fn.isEmpty() )
1936 // We have a filepath, go on saving
1937 // First remove existing file, we
1938 // don't want to add to old zip archives
1942 QMessageBox::warning( 0, tr( "Save Error" ),
1943 fn+ tr("\ncould not be removed before saving"));
1945 // Look, if we should zip the data:
1948 QMessageBox mb( __VYM,
1949 tr("The map %1\ndid not use the compressed "
1950 "vym file format.\nWriting it uncompressed will also write images \n"
1951 "and flags and thus may overwrite files in the "
1952 "given directory\n\nDo you want to write the map").arg(fn),
1953 QMessageBox::Warning,
1954 QMessageBox::Yes | QMessageBox::Default,
1956 QMessageBox::Cancel | QMessageBox::Escape);
1957 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1958 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1959 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1962 case QMessageBox::Yes:
1963 // save compressed (default file format)
1966 case QMessageBox::No:
1967 // save uncompressed
1970 case QMessageBox::Cancel:
1979 // Create temporary directory for packing
1981 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1984 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1985 tr("Couldn't create temporary directory before save\n"));
1989 safeFilePath=me->getFilePath();
1990 me->setFilePath (tmpMapDir+"/"+
1991 me->getMapName()+ ".xml",
1993 me->save (savemode);
1994 me->setFilePath (safeFilePath);
1996 zipDir (tmpMapDir,fn);
2001 safeFilePath=me->getFilePath();
2002 me->setFilePath (fn, safeFilePath);
2003 me->save (savemode);
2004 me->setFilePath (safeFilePath);
2006 } // filepath available
2009 // We have no filepath yet,
2010 // call fileSaveAs() now, this will call fileSave()
2012 fileSaveAs(savemode);
2016 if (saveZipped && !tmpMapDir.isEmpty())
2018 removeDir (QDir(tmpMapDir));
2022 statusBar()->message(
2023 tr("Saved %1").arg(me->getFilePath()),
2025 lastMaps.prepend(me->getFilePath() );
2026 setupLastMapsMenu();
2028 statusBar()->message(
2029 tr("Couldn't save ").arg(me->getFilePath()),
2033 void Main::fileSave()
2035 fileSave (CompleteMap);
2038 void Main::fileSaveAs(const SaveMode& savemode)
2042 if (currentMapEditor())
2044 if (savemode==CompleteMap)
2045 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2047 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2048 if ( !fn.isEmpty() )
2050 // Check for existing file
2051 if (QFile (fn).exists())
2053 QMessageBox mb( __VYM,
2054 tr("The file %1\nexists already. Do you want to").arg(fn),
2055 QMessageBox::Warning,
2056 QMessageBox::Yes | QMessageBox::Default,
2057 QMessageBox::Cancel | QMessageBox::Escape,
2058 QMessageBox::NoButton);
2059 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2060 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2063 case QMessageBox::Yes:
2066 case QMessageBox::Cancel:
2073 // New file, add extension to filename, if missing
2074 // This is always .vym or .vyp, depending on savemode
2075 if (savemode==CompleteMap)
2077 if (!fn.contains (".vym") && !fn.contains (".xml"))
2081 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2090 currentMapEditor()->setFilePath(fn);
2094 if (savemode==CompleteMap)
2095 tabWidget->setTabLabel (currentMapEditor(),
2096 currentMapEditor()->getFileName() );
2102 void Main::fileSaveAs()
2104 fileSaveAs (CompleteMap);
2107 void Main::fileImportKDEBookmarks()
2109 ImportKDEBookmarks im;
2111 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2112 currentMapEditor()->setFilePath ("");
2115 void Main::fileImportFirefoxBookmarks()
2117 Q3FileDialog *fd=new Q3FileDialog( this);
2118 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2119 fd->setMode (Q3FileDialog::ExistingFiles);
2120 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2121 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2124 if ( fd->exec() == QDialog::Accepted )
2126 ImportFirefoxBookmarks im;
2127 QStringList flist = fd->selectedFiles();
2128 QStringList::Iterator it = flist.begin();
2129 while( it != flist.end() )
2132 if (im.transform() &&
2133 success==fileLoad (im.getTransformedFile(),NewMap) &&
2134 currentMapEditor() )
2135 currentMapEditor()->setFilePath ("");
2142 void Main::fileImportMM()
2146 Q3FileDialog *fd=new Q3FileDialog( this);
2147 fd->setDir (lastFileDir);
2148 fd->setMode (Q3FileDialog::ExistingFiles);
2149 fd->addFilter ("Mind Manager (*.mmap)");
2150 fd->setCaption(tr("Import")+" "+"Mind Manager");
2153 if ( fd->exec() == QDialog::Accepted )
2155 lastFileDir=fd->dirPath();
2156 QStringList flist = fd->selectedFiles();
2157 QStringList::Iterator it = flist.begin();
2158 while( it != flist.end() )
2161 if (im.transform() &&
2162 success==fileLoad (im.getTransformedFile(),NewMap) &&
2163 currentMapEditor() )
2164 currentMapEditor()->setFilePath ("");
2173 void Main::fileImportDir()
2175 if (currentMapEditor())
2176 currentMapEditor()->importDir();
2179 void Main::fileExportXML()
2181 if (currentMapEditor())
2183 QString dir=browseDirectory(tr("Export XML to directory"));
2184 if (dir !="" && reallyWriteDirectory(dir) )
2185 currentMapEditor()->exportXML(dir);
2190 void Main::fileExportXHTML()
2192 MapEditor *me=currentMapEditor();
2196 ExportXHTMLDialog dia(this);
2197 dia.setFilePath (me->getFilePath() );
2198 dia.setMapName (me->getMapName() );
2201 if (dia.exec()==QDialog::Accepted)
2203 QString dir=dia.getDir();
2204 // Check, if warnings should be used before overwriting
2205 // the output directory
2208 ok=reallyWriteDirectory(dir);
2214 me->exportXML (dia.getDir() );
2215 dia.doExport(me->getMapName() );
2216 if (dia.hasChanged())
2223 void Main::fileExportImage()
2225 MapEditor *me=currentMapEditor();
2229 QFileDialog *fd=new QFileDialog (this);
2230 fd->setCaption (tr("Export map as image"));
2231 fd->setFileMode(QFileDialog::AnyFile);
2232 fd->setFilters (imageIO.getFilters() );
2233 fd->setDirectory (lastImageDir);
2236 fl=fd->selectedFiles();
2237 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2238 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2243 void Main::fileExportASCII()
2245 MapEditor *me=currentMapEditor();
2249 ex.setMapCenter(me->getMapCenter());
2250 ex.addFilter ("TXT (*.txt)");
2251 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2252 if (ex.execDialog() )
2254 me->setExportMode(true);
2256 me->setExportMode(false);
2261 void Main::fileExportLaTeX()
2263 MapEditor *me=currentMapEditor();
2267 ex.setMapCenter(me->getMapCenter());
2268 ex.addFilter ("Tex (*.tex)");
2269 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2270 if (ex.execDialog() )
2272 me->setExportMode(true);
2274 me->setExportMode(false);
2279 void Main::fileExportKDEBookmarks()
2281 ExportKDEBookmarks ex;
2282 MapEditor *me=currentMapEditor();
2285 ex.setMapCenter (me->getMapCenter() );
2290 void Main::fileExportTaskjuggler()
2292 ExportTaskjuggler ex;
2293 MapEditor *me=currentMapEditor();
2296 ex.setMapCenter (me->getMapCenter() );
2297 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2298 ex.addFilter ("Taskjuggler (*.tjp)");
2299 if (ex.execDialog() )
2301 me->setExportMode(true);
2303 me->setExportMode(false);
2308 void Main::fileExportOOPresentation()
2310 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2311 // TODO add preview in dialog
2312 //ImagePreview *p =new ImagePreview (fd);
2313 //fd->setContentsPreviewEnabled( TRUE );
2314 //fd->setContentsPreview( p, p );
2315 //fd->setPreviewMode( QFileDialog::Contents );
2316 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2317 fd->setDir (QDir().current());
2318 if (fd->foundConfig())
2322 if ( fd->exec() == QDialog::Accepted )
2324 QString fn=fd->selectedFile();
2325 if (!fn.contains (".odp"))
2328 //lastImageDir=fn.left(fn.findRev ("/"));
2329 if (currentMapEditor())
2330 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2334 QMessageBox::warning(0,
2336 tr("Couldn't find configuration for export to Open Office\n"));
2340 void Main::fileCloseMap()
2342 if (currentMapEditor())
2344 if (currentMapEditor()->hasChanged())
2346 QMessageBox mb( __VYM,
2347 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2348 QMessageBox::Warning,
2349 QMessageBox::Yes | QMessageBox::Default,
2351 QMessageBox::Cancel | QMessageBox::Escape );
2352 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2353 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2356 case QMessageBox::Yes:
2358 fileSave(CompleteMap);
2360 case QMessageBox::No:
2361 // close without saving
2363 case QMessageBox::Cancel:
2368 currentMapEditor()->closeMap();
2369 tabWidget->removePage(currentMapEditor());
2370 if (tabWidget->count()==0)
2371 actionFilePrint->setEnabled (false);
2375 void Main::filePrint()
2377 if (currentMapEditor())
2378 currentMapEditor()->print();
2381 void Main::fileExitVYM()
2383 // Check if one or more editors have changed
2386 for (i=0;i<=tabWidget->count() -1;i++)
2389 me=(MapEditor*)tabWidget->page(i);
2391 // If something changed, ask what to do
2392 if (me->isUnsaved())
2394 tabWidget->setCurrentPage(i);
2395 QMessageBox mb( __VYM,
2396 tr("This map is not saved yet. Do you want to"),
2397 QMessageBox::Warning,
2398 QMessageBox::Yes | QMessageBox::Default,
2400 QMessageBox::Cancel | QMessageBox::Escape );
2401 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2402 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2405 mb.setActiveWindow();
2406 switch( mb.exec() ) {
2407 case QMessageBox::Yes:
2408 // save (the changed editors) and exit
2409 fileSave(CompleteMap);
2411 case QMessageBox::No:
2412 // exit without saving
2414 case QMessageBox::Cancel:
2415 // don't save and don't exit
2419 } // loop over all MEs
2423 void Main::editUndo()
2425 if (currentMapEditor())
2426 currentMapEditor()->undo();
2429 void Main::editRedo()
2431 if (currentMapEditor())
2432 currentMapEditor()->redo();
2435 void Main::editCopy()
2437 if (currentMapEditor())
2438 currentMapEditor()->copy();
2441 void Main::editPaste()
2443 if (currentMapEditor())
2444 currentMapEditor()->paste();
2447 void Main::editCut()
2449 if (currentMapEditor())
2450 currentMapEditor()->cut();
2453 void Main::editOpenFindWindow()
2455 findWindow->popup();
2456 findWindow->raise();
2457 findWindow->setActiveWindow();
2460 void Main::editFind(QString s)
2463 BranchObj *bo=currentMapEditor()->findText(s, cs);
2466 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2469 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2470 tr("No matches found for \"%1\"").arg(s));
2474 void Main::editFindChanged()
2475 { // Notify editor, to abort the current find process
2476 currentMapEditor()->findReset();
2479 void Main::openTabs(QStringList urls)
2481 if (!urls.isEmpty())
2485 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2487 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2489 QString u=urls.takeFirst();
2490 procBrowser = new QProcess( this );
2492 procBrowser->start(browser,args);
2493 if ( !procBrowser->waitForStarted())
2495 // try to set path to browser
2496 QMessageBox::warning(0,
2498 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2499 tr("Please use Settings->")+tr("Set application to open an URL"));
2504 if (browser.contains("konqueror"))
2506 for (int i=0; i<urls.size(); i++)
2509 // Try to open new tab in existing konqueror started previously by vym
2510 p=new QProcess (this);
2512 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2513 "konqueror-mainwindow#1"<<
2516 p->start ("dcop",args);
2517 if ( !p->waitForStarted() ) success=false;
2520 QMessageBox::warning(0,
2522 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2524 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2526 for (int i=0; i<urls.size(); i++)
2528 // Try to open new tab in firefox
2529 p=new QProcess (this);
2530 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2531 p->start (browser,args);
2532 if ( !p->waitForStarted() ) success=false;
2535 QMessageBox::warning(0,
2537 tr("Couldn't start %1 to open a new tab").arg(browser));
2540 QMessageBox::warning(0,
2542 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2546 void Main::editOpenURL()
2549 if (currentMapEditor())
2551 QString url=currentMapEditor()->getURL();
2553 if (url=="") return;
2554 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2555 procBrowser = new QProcess( this );
2557 procBrowser->start(browser,args);
2558 if ( !procBrowser->waitForStarted())
2560 // try to set path to browser
2561 QMessageBox::warning(0,
2563 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2564 tr("Please use Settings->")+tr("Set application to open an URL"));
2569 void Main::editOpenURLTab()
2571 if (currentMapEditor())
2574 urls.append(currentMapEditor()->getURL());
2578 void Main::editOpenMultipleURLTabs()
2580 if (currentMapEditor())
2583 urls=currentMapEditor()->getURLs();
2589 void Main::editURL()
2591 if (currentMapEditor())
2592 currentMapEditor()->editURL();
2595 void Main::editHeading2URL()
2597 if (currentMapEditor())
2598 currentMapEditor()->editHeading2URL();
2601 void Main::editBugzilla2URL()
2603 if (currentMapEditor())
2604 currentMapEditor()->editBugzilla2URL();
2607 void Main::editFATE2URL()
2609 if (currentMapEditor())
2610 currentMapEditor()->editFATE2URL();
2613 void Main::editHeadingFinished()
2615 // only called from editHeading(), so there is a currentME
2616 MapEditor *me=currentMapEditor();
2618 #if defined(Q_OS_MACX)
2620 me->setHeading(lineedit->text());
2622 lineedit->releaseKeyboard();
2626 if (!prevSelection.isEmpty()) me->select(prevSelection);
2630 void Main::editHeading()
2632 if (currentMapEditor())
2634 MapEditor *me=currentMapEditor();
2635 QString oldSel=me->getSelectString();
2637 if (lineedit->isVisible())
2638 editHeadingFinished();
2643 QString s=currentMapEditor()->getHeading(ok,p);
2647 #if defined(Q_OS_MACX)
2648 p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
2649 QDialog *d =new QDialog(NULL);
2650 QLineEdit *le=new QLineEdit (d);
2651 d->setWindowFlags (Qt::FramelessWindowHint);
2652 d->setGeometry(p.x(),p.y(),230,25);
2653 le->resize (d->width()-10,d->height());
2656 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2657 d->activateWindow();
2659 currentMapEditor()->setHeading (le->text());
2662 editHeadingFinished();
2664 p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
2665 lineedit->setGeometry(p.x(),p.y(),230,25);
2666 lineedit->setText(s);
2667 lineedit->setCursorPosition(1);
2668 lineedit->selectAll();
2670 lineedit->grabKeyboard();
2671 lineedit->setFocus();
2675 } // currentMapEditor()
2678 void Main::openVymLinks(const QStringList &vl)
2680 for (int j=0; j<vl.size(); j++)
2682 // compare path with already loaded maps
2686 for (i=0;i<=tabWidget->count() -1;i++)
2688 me=(MapEditor*)tabWidget->page(i);
2689 if (vl.at(j)==me->getFilePath() )
2698 if (!QFile(vl.at(j)).exists() )
2699 QMessageBox::critical( 0, tr( "Critical Error" ),
2700 tr("Couldn't open map %1").arg(vl.at(j)));
2703 fileLoad (vl.at(j), NewMap);
2704 tabWidget->setCurrentPage (tabWidget->count()-1);
2707 // Go to tab containing the map
2708 tabWidget->setCurrentPage (index);
2712 void Main::editOpenVymLink()
2714 if (currentMapEditor())
2717 vl.append(currentMapEditor()->getVymLink());
2722 void Main::editOpenMultipleVymLinks()
2724 QString currentVymLink;
2725 if (currentMapEditor())
2727 QStringList vl=currentMapEditor()->getVymLinks();
2732 void Main::editVymLink()
2734 if (currentMapEditor())
2735 currentMapEditor()->editVymLink();
2738 void Main::editDeleteVymLink()
2740 if (currentMapEditor())
2741 currentMapEditor()->deleteVymLink();
2744 void Main::editToggleHideExport()
2746 if (currentMapEditor())
2747 currentMapEditor()->toggleHideExport();
2750 void Main::editMapInfo()
2752 if (currentMapEditor())
2753 currentMapEditor()->editMapInfo();
2756 void Main::editMoveUp()
2758 if (currentMapEditor())
2759 currentMapEditor()->moveBranchUp();
2762 void Main::editMoveDown()
2764 if (currentMapEditor())
2765 currentMapEditor()->moveBranchDown();
2768 void Main::editToggleScroll()
2770 if (currentMapEditor())
2772 currentMapEditor()->toggleScroll();
2776 void Main::editUnScrollAll()
2778 if (currentMapEditor())
2779 currentMapEditor()->unScrollAll();
2782 void Main::editNewBranch()
2784 MapEditor *me=currentMapEditor();
2785 if (!lineedit->isVisible() && me)
2787 BranchObj *bo=(BranchObj*)me->getSelection();
2788 BranchObj *newbo=me->addNewBranch(0);
2791 me->select (newbo->getSelectString());
2795 if (actionSettingsAutoEdit->isOn())
2797 if (!actionSettingsAutoSelectHeading->isOn())
2798 prevSelection=bo->getSelectString();
2804 void Main::editNewBranchBefore()
2806 MapEditor *me=currentMapEditor();
2807 if (!lineedit->isVisible() && me)
2809 BranchObj *bo=(BranchObj*)me->getSelection();
2810 BranchObj *newbo=me->addNewBranchBefore();
2813 me->select (newbo->getSelectString());
2817 if (actionSettingsAutoEdit->isOn())
2819 if (!actionSettingsAutoSelectHeading->isOn())
2820 prevSelection=bo->getSelectString();
2826 void Main::editNewBranchAbove()
2828 MapEditor *me=currentMapEditor();
2829 if (!lineedit->isVisible() && me)
2831 BranchObj *bo=(BranchObj*)me->getSelection();
2832 BranchObj *newbo=me->addNewBranch (-1);
2835 me->select (newbo->getSelectString());
2839 if (actionSettingsAutoEdit->isOn())
2841 if (!actionSettingsAutoSelectHeading->isOn())
2842 prevSelection=bo->getSelectString();
2848 void Main::editNewBranchBelow()
2850 MapEditor *me=currentMapEditor();
2851 if (!lineedit->isVisible() && me)
2853 BranchObj *bo=(BranchObj*)me->getSelection();
2854 BranchObj *newbo=me->addNewBranch (1);
2857 me->select (newbo->getSelectString());
2861 if (actionSettingsAutoEdit->isOn())
2863 if (!actionSettingsAutoSelectHeading->isOn())
2864 prevSelection=bo->getSelectString();
2870 void Main::editImportAdd()
2872 fileLoad (ImportAdd);
2875 void Main::editImportReplace()
2877 fileLoad (ImportReplace);
2880 void Main::editSaveBranch()
2882 fileSaveAs (PartOfMap);
2885 void Main::editRemoveBranchKeepChilds()
2887 if (currentMapEditor())
2888 currentMapEditor()->removeBranchKeepChilds();
2891 void Main::editRemoveChilds()
2893 if (currentMapEditor())
2894 currentMapEditor()->removeChilds();
2897 void Main::editDeleteSelection()
2899 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2900 currentMapEditor()->deleteSelection();
2903 void Main::editUpperBranch()
2905 if (currentMapEditor())
2906 currentMapEditor()->selectUpperBranch();
2909 void Main::editLowerBranch()
2911 if (currentMapEditor())
2912 currentMapEditor()->selectLowerBranch();
2915 void Main::editLeftBranch()
2917 if (currentMapEditor())
2918 currentMapEditor()->selectLeftBranch();
2921 void Main::editRightBranch()
2923 if (currentMapEditor())
2924 currentMapEditor()->selectRightBranch();
2927 void Main::editFirstBranch()
2929 if (currentMapEditor())
2930 currentMapEditor()->selectFirstBranch();
2933 void Main::editLastBranch()
2935 if (currentMapEditor())
2936 currentMapEditor()->selectLastBranch();
2939 void Main::editLoadImage()
2941 if (currentMapEditor())
2942 currentMapEditor()->loadFloatImage();
2945 void Main::editSaveImage()
2947 if (currentMapEditor())
2948 currentMapEditor()->saveFloatImage();
2951 void Main::editFollowXLink(QAction *a)
2954 if (currentMapEditor())
2955 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2958 void Main::editEditXLink(QAction *a)
2960 if (currentMapEditor())
2961 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2964 void Main::formatSelectColor()
2966 if (currentMapEditor())
2968 QColor col = QColorDialog::getColor( currentMapEditor()->getColor(), this );
2969 if ( !col.isValid() ) return;
2970 currentMapEditor()->setColor( col );
2971 colorChanged( col );
2975 void Main::formatPickColor()
2977 if (currentMapEditor())
2978 colorChanged( currentMapEditor()->pickColor() );
2981 void Main::colorChanged(QColor c)
2983 QPixmap pix( 16, 16 );
2985 actionFormatColor->setIconSet( pix );
2988 void Main::formatColorItem()
2990 if (currentMapEditor())
2991 currentMapEditor()->colorItem();
2994 void Main::formatColorBranch()
2996 if (currentMapEditor())
2997 currentMapEditor()->colorBranch();
3000 void Main::formatLinkStyleLine()
3002 if (currentMapEditor())
3003 currentMapEditor()->setLinkStyle(StyleLine);
3006 void Main::formatLinkStyleParabel()
3008 if (currentMapEditor())
3009 currentMapEditor()->setLinkStyle(StyleParabel);
3012 void Main::formatLinkStylePolyLine()
3014 if (currentMapEditor())
3015 currentMapEditor()->setLinkStyle(StylePolyLine);
3018 void Main::formatLinkStylePolyParabel()
3020 if (currentMapEditor())
3021 currentMapEditor()->setLinkStyle(StylePolyParabel);
3024 void Main::formatSelectBackColor()
3026 if (currentMapEditor())
3027 currentMapEditor()->selectBackgroundColor();
3030 void Main::formatSelectLinkColor()
3032 if (currentMapEditor())
3033 currentMapEditor()->selectLinkColor();
3036 void Main::formatToggleLinkColorHint()
3038 currentMapEditor()->toggleLinkColorHint();
3041 void Main::formatFrameNone()
3043 if (currentMapEditor())
3044 currentMapEditor()->setFrame(NoFrame);
3047 void Main::formatFrameRectangle()
3049 if (currentMapEditor())
3050 currentMapEditor()->setFrame(Rectangle);
3053 void Main::formatIncludeImagesVer()
3055 if (currentMapEditor())
3056 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
3059 void Main::formatIncludeImagesHor()
3061 if (currentMapEditor())
3062 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
3065 void Main::formatHideLinkUnselected()
3067 if (currentMapEditor())
3068 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3071 void Main::viewZoomReset()
3073 if (currentMapEditor())
3077 currentMapEditor()->setWorldMatrix( m );
3078 currentMapEditor()->setViewCenter();
3079 currentMapEditor()->adjustCanvasSize();
3083 void Main::viewZoomIn()
3085 if (currentMapEditor())
3087 QMatrix m = currentMapEditor()->worldMatrix();
3088 m.scale( 1.25, 1.25 );
3089 currentMapEditor()->setWorldMatrix( m );
3090 currentMapEditor()->setViewCenter();
3091 currentMapEditor()->adjustCanvasSize();
3095 void Main::viewZoomOut()
3097 if (currentMapEditor())
3099 QMatrix m = currentMapEditor()->worldMatrix();
3100 m.scale( 0.8, 0.8 );
3101 currentMapEditor()->setWorldMatrix( m );
3102 currentMapEditor()->setViewCenter();
3103 currentMapEditor()->adjustCanvasSize();
3107 bool Main::settingsPDF()
3109 // Default browser is set in constructor
3111 QString text = QInputDialog::getText(
3112 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3113 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3115 settings.setValue ("/mainwindow/readerPDF",text);
3120 bool Main::settingsURL()
3122 // Default browser is set in constructor
3124 QString text = QInputDialog::getText(
3125 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3126 settings.value("/mainwindow/readerURL").toString()
3129 settings.setValue ("/mainwindow/readerURL",text);
3133 void Main::settingsToggleDelKey()
3135 if (actionSettingsUseDelKey->isOn())
3137 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3140 actionEditDelete->setAccel (QKeySequence (""));
3144 void Main::windowToggleNoteEditor()
3146 if (textEditor->showWithMain() )
3147 windowHideNoteEditor();
3149 windowShowNoteEditor();
3152 void Main::windowToggleHistory()
3154 if (currentMapEditor())
3155 currentMapEditor()->toggleHistoryWindow();
3158 void Main::updateNoteFlag()
3160 if (currentMapEditor())
3161 currentMapEditor()->updateNoteFlag();
3164 void Main::updateActions()
3166 MapEditor *me=currentMapEditor();
3169 // updateActions is also called when NoteEditor is closed
3170 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3173 if (me->getLinkColorHint()==HeadingColor)
3174 actionFormatLinkColorHint->setOn(true);
3176 actionFormatLinkColorHint->setOn(false);
3178 switch (me->getLinkStyle())
3181 actionFormatLinkStyleLine->setOn(true);
3184 actionFormatLinkStyleParabel->setOn(true);
3187 actionFormatLinkStylePolyLine->setOn(true);
3189 case StylePolyParabel:
3190 actionFormatLinkStylePolyParabel->setOn(true);
3196 QPixmap pix( 16, 16 );
3197 pix.fill( me->getBackgroundColor() );
3198 actionFormatBackColor->setIconSet( pix );
3199 pix.fill( me->getDefLinkColor() );
3200 actionFormatLinkColor->setIconSet( pix );
3202 actionFileSave->setEnabled( me->isUnsaved() );
3203 if (me->isUndoAvailable())
3204 actionEditUndo->setEnabled( true);
3206 actionEditUndo->setEnabled( false);
3208 if (me->isRedoAvailable())
3209 actionEditRedo->setEnabled( true);
3211 actionEditRedo->setEnabled( false);
3213 LinkableMapObj *selection=me->getSelection();
3216 if ( (typeid(*selection) == typeid(BranchObj)) ||
3217 (typeid(*selection) == typeid(MapCenterObj)) )
3219 BranchObj *bo=(BranchObj*)selection;
3220 // Take care of links
3221 if (bo->countXLinks()==0)
3223 branchXLinksContextMenuEdit->clear();
3224 branchXLinksContextMenuFollow->clear();
3229 branchXLinksContextMenuEdit->clear();
3230 branchXLinksContextMenuFollow->clear();
3231 for (int i=0; i<=bo->countXLinks();i++)
3233 bot=bo->XLinkTargetAt(i);
3236 s=bot->getHeading();
3239 branchXLinksContextMenuFollow->addAction (s);
3240 branchXLinksContextMenuEdit->addAction (s);
3245 standardFlagsDefault->setEnabled (true);
3247 actionEditToggleScroll->setEnabled (true);
3248 if ( bo->isScrolled() )
3249 actionEditToggleScroll->setOn(true);
3251 actionEditToggleScroll->setOn(false);
3253 if ( bo->getURL().isEmpty() )
3255 actionEditOpenURL->setEnabled (false);
3256 actionEditOpenURLTab->setEnabled (false);
3260 actionEditOpenURL->setEnabled (true);
3261 actionEditOpenURLTab->setEnabled (true);
3263 if ( bo->getVymLink().isEmpty() )
3265 actionEditOpenVymLink->setEnabled (false);
3266 actionEditDeleteVymLink->setEnabled (false);
3269 actionEditOpenVymLink->setEnabled (true);
3270 actionEditDeleteVymLink->setEnabled (true);
3273 if (bo->canMoveBranchUp())
3274 actionEditMoveUp->setEnabled (true);
3276 actionEditMoveUp->setEnabled (false);
3277 if (bo->canMoveBranchDown())
3278 actionEditMoveDown->setEnabled (true);
3280 actionEditMoveDown->setEnabled (false);
3283 actionEditToggleHideExport->setEnabled (true);
3284 actionEditToggleHideExport->setOn (bo->hideInExport() );
3286 actionEditCopy->setEnabled (true);
3287 actionEditCut->setEnabled (true);
3288 if (!clipboardEmpty)
3289 actionEditPaste->setEnabled (true);
3291 actionEditPaste->setEnabled (false);
3292 for (a=actionListBranches.first();a;a=actionListBranches.next())
3293 a->setEnabled(true);
3294 actionEditDelete->setEnabled (true);
3295 switch (selection->getFrameType())
3298 actionFormatFrameNone->setOn(true);
3301 actionFormatFrameRectangle->setOn(true);
3306 actionFormatIncludeImagesVer->setOn
3307 ( ((BranchObj*)selection)->getIncludeImagesVer());
3308 actionFormatIncludeImagesHor->setOn
3309 ( ((BranchObj*)selection)->getIncludeImagesHor());
3310 actionFormatHideLinkUnselected->setOn
3311 (selection->getHideLinkUnselected());
3313 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3315 FloatObj *fo=(FloatImageObj*)selection;
3316 //FIXME do this in mainwindow standardFlagsDefault->setEnabled (false);
3318 actionEditOpenURL->setEnabled (false);
3319 actionEditOpenVymLink->setEnabled (false);
3320 actionEditDeleteVymLink->setEnabled (false);
3321 actionEditToggleHideExport->setEnabled (true);
3322 actionEditToggleHideExport->setOn (fo->hideInExport() );
3325 actionEditCopy->setEnabled (true);
3326 actionEditCut->setEnabled (true);
3327 actionEditPaste->setEnabled (false);
3328 for (a=actionListBranches.first();a;a=actionListBranches.next())
3329 a->setEnabled(false);
3330 actionEditDelete->setEnabled (true);
3331 actionFormatHideLinkUnselected->setOn
3332 ( selection->getHideLinkUnselected());
3333 actionEditMoveUp->setEnabled (false);
3334 actionEditMoveDown->setEnabled (false);
3339 actionEditCopy->setEnabled (false);
3340 actionEditCut->setEnabled (false);
3341 actionEditPaste->setEnabled (false);
3342 for (a=actionListBranches.first();a;a=actionListBranches.next())
3343 a->setEnabled(false);
3345 actionEditToggleScroll->setEnabled (false);
3346 actionEditOpenURL->setEnabled (false);
3347 actionEditOpenVymLink->setEnabled (false);
3348 actionEditDeleteVymLink->setEnabled (false);
3349 actionEditHeading2URL->setEnabled (false);
3350 actionEditDelete->setEnabled (false);
3351 actionEditMoveUp->setEnabled (false);
3352 actionEditMoveDown->setEnabled (false);
3353 actionEditToggleHideExport->setEnabled (false);
3357 ModMode Main::getModMode()
3359 if (actionModModeColor->isOn()) return ModModeColor;
3360 if (actionModModeCopy->isOn()) return ModModeCopy;
3361 if (actionModModeXLink->isOn()) return ModModeXLink;
3365 bool Main::autoEdit()
3367 return actionSettingsAutoEdit->isOn();
3370 bool Main::autoSelectHeading()
3372 return actionSettingsAutoSelectHeading->isOn();
3375 bool Main::useFlagGroups()
3377 return actionSettingsUseFlagGroups->isOn();
3380 void Main::windowShowNoteEditor()
3382 textEditor->setShowWithMain(true);
3384 actionViewToggleNoteEditor->setOn (true);
3387 void Main::windowHideNoteEditor()
3389 textEditor->setShowWithMain(false);
3391 actionViewToggleNoteEditor->setOn (false);
3394 void Main::windowNextEditor()
3396 if (tabWidget->currentPageIndex() < tabWidget->count())
3397 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3400 void Main::windowPreviousEditor()
3402 if (tabWidget->currentPageIndex() >0)
3403 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3406 void Main::standardFlagChanged()
3408 currentMapEditor()->toggleStandardFlag(sender()->name());
3411 void Main::testFunction()
3413 if (!currentMapEditor()) return;
3414 currentMapEditor()->testFunction();
3417 void Main::testCommand()
3419 if (!currentMapEditor()) return;
3421 QString com = QInputDialog::getText(
3422 __VYM, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3423 if (ok) currentMapEditor()->parseAtom(com);
3426 void Main::helpDoc()
3429 #if defined(Q_OS_MACX)
3430 docpath="./vym.app/Contents/vym.pdf";
3432 // default path in SUSE LINUX
3433 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3436 if (!QFile (docpath).exists() )
3438 // relative path for easy testing in tarball
3439 docpath="doc/vym.pdf";
3440 if (!QFile (docpath).exists() )
3442 // relative path for testing while still writing vym.tex
3443 docpath="doc/tex/vym.pdf";
3444 if (!QFile (docpath).exists() )
3446 // Try yet another one for Knoppix
3447 docpath="/usr/share/doc/packages/vym/vym.pdf";
3448 if (!QFile (docpath).exists() )
3450 QMessageBox::critical(0,
3451 tr("Critcal error"),
3452 tr("Couldn't find the documentation\n"
3453 "vym.pdf in various places."));
3460 Process *pdfProc = new Process();
3461 pdfProc->clearArguments();
3462 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3463 pdfProc->addArgument( docpath);
3465 if ( !pdfProc->start() )
3468 QMessageBox::warning(0,
3470 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3471 tr("Please use Settings->")+tr("Set application to open PDF files"));
3478 void Main::helpAbout()
3481 ad.setName ("aboutwindow");
3482 ad.setMinimumSize(500,500);
3483 ad.resize (QSize (500,500));
3487 void Main::helpAboutQT()
3489 QMessageBox::aboutQt( this, "Qt Application Example" );