1 #include "mainwindow.h"
7 #include <q3filedialog.h>
9 #include <QColorDialog>
11 #include <QInputDialog>
15 #include <QCloseEvent>
18 #include <Q3PopupMenu>
19 #include <QActionGroup>
21 //#include <qdatetime.h> // for random seed
27 #include "aboutdialog.h"
28 #include "exportoofiledialog.h"
30 #include "exportxhtmldialog.h"
32 #include "flagrowobj.h"
34 #include "mapeditor.h"
39 #include "showtextdialog.h"
40 #include "texteditor.h"
43 extern TextEditor *textEditor;
44 extern Main *mainWindow;
45 extern QString tmpVymDir;
46 extern QString clipboardDir;
47 extern bool clipboardEmpty;
48 extern int statusbarTime;
49 extern FlagRowObj* standardFlagsDefault;
50 extern FlagRowObj* systemFlagsDefault;
52 extern Q3PtrList <QAction> actionListBranches;
54 extern QAction* actionFileSave;
55 extern QAction* actionFilePrint;
56 extern QAction* actionEditUndo;
57 extern QAction* actionEditRedo;
58 extern QAction *actionEditCopy;
59 extern QAction *actionEditCut;
60 extern QAction *actionEditPaste;
61 extern QAction *actionEditMoveUp;
62 extern QAction *actionEditMoveDown;
63 extern QAction *actionEditToggleScroll;
64 extern QAction* actionEditOpenURL;
65 extern QAction* actionEditOpenURLTab;
66 extern QAction* actionEditURL;
67 extern QAction* actionEditHeading2URL;
68 extern QAction* actionEditBugzilla2URL;
69 extern QAction* actionEditFATE2URL;
70 extern QAction *actionEditOpenVymLink;
71 extern QAction *actionEditVymLink;
72 extern QAction *actionEditDeleteVymLink;
73 extern QAction *actionEditToggleHideExport;
74 extern QAction *actionEditMapInfo;
75 extern QAction *actionEditHeading;
76 extern QAction *actionEditDelete;
77 extern QAction *actionEditAddBranch;
78 extern QAction *actionEditAddBranchHere;
79 extern QAction *actionEditAddBranchAbove;
80 extern QAction *actionEditAddBranchBelow;
81 extern QAction *actionEditRemoveBranchKeepChilds;
82 extern QAction *actionEditRemoveChilds;
83 extern QAction *actionEditImportAdd;
84 extern QAction *actionEditImportReplace;
85 extern QAction *actionEditSaveBranch;
86 extern QAction *actionEditSelectFirst;
87 extern QAction *actionEditSelectLast;
88 extern QAction *actionEditLoadImage;
90 extern QAction* actionFormatColor;
91 extern QAction* actionFormatPickColor;
92 extern QAction* actionFormatColorBranch;
93 extern QAction* actionFormatColorSubtree;
94 extern QAction* actionFormatLinkColorHint;
95 extern QAction* actionFormatBackColor;
96 extern QAction* actionFormatLinkColor;
97 extern QAction *actionFormatIncludeImagesVer;
98 extern QAction *actionFormatIncludeImagesHor;
100 extern QActionGroup* actionGroupModModes;
101 extern QAction* actionModModeColor;
102 extern QAction* actionModModeLink;
103 extern QAction* actionModModeCopy;
105 extern QActionGroup *actionGroupFormatFrameTypes;
106 extern QAction *actionFormatFrameNone;
107 extern QAction *actionFormatFrameRectangle;
109 extern QActionGroup *actionGroupFormatLinkStyles;
110 extern QAction *actionFormatLinkStyleLine;
111 extern QAction *actionFormatLinkStyleParabel;
112 extern QAction *actionFormatLinkStylePolyLine;
113 extern QAction *actionFormatLinkStylePolyParabel;
114 extern QAction *actionFormatHideLinkUnselected;
116 extern QAction *actionViewToggleNoteEditor;
117 extern QAction *actionViewToggleHistoryWindow;
119 extern QAction* actionSettingsAutoedit;
120 extern QAction* actionSettingsAutoselectHeading;
121 extern QAction* actionSettingsAutoselectHeading;
122 extern QAction* actionSettingsAutoselectText;
123 extern QAction* actionSettingsPasteNewHeading;
124 extern QAction* actionSettingsUseDelKey;
125 extern QAction* actionSettingsUseFlagGroups;
126 extern QAction* actionSettingsUseHideExport;
128 extern QMenu* branchContextMenu;
129 extern QMenu* branchAddContextMenu;
130 extern QMenu* branchRemoveContextMenu;
131 extern QMenu* branchLinksContextMenuEdit;
132 extern QMenu* branchLinksContextMenuFollow;
133 extern QMenu* floatimageContextMenu;
134 extern QMenu* canvasContextMenu;
135 extern QMenu* fileLastMapsMenu;
136 extern QMenu* fileImportMenu;
137 extern QMenu* fileExportMenu;
140 extern Settings settings;
141 extern Options options;
142 extern ImageIO imageIO;
144 extern QDir vymBaseDir;
145 extern QDir lastImageDir;
146 extern QDir lastFileDir;
147 extern QString iconPath;
148 extern QString flagsPath;
150 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
151 QMainWindow(parent,name,f)
155 setCaption ("VYM - View Your Mind");
157 // Load window settings
158 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
159 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
162 // Create unique temporary directory
163 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
165 // Create direcctory for clipboard
166 clipboardDir=tmpVymDir+"/clipboard";
167 QDir d(clipboardDir);
168 d.mkdir (clipboardDir,true);
169 makeSubDirs (clipboardDir);
174 // FIXME not used currently
175 // Set random seed (random used for object IDs)
176 // QTime t = QTime::currentTime(); // set random seed
177 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
180 // Initialize some settings, which are platform dependant
183 // application to open URLs
184 p="/mainwindow/readerURL";
185 #if defined(Q_OS_LINUX)
186 s=settings.value (p,"konqueror").toString();
188 #if defined(Q_OS_MACX)
189 s=settings.value (p,"/usr/bin/open").toString();
191 s=settings.value (p,"mozilla");
194 settings.setValue( p,s);
196 // application to open PDFs
197 p="/mainwindow/readerPDF";
198 #if defined(Q_OS_LINUX)
199 s=settings.value (p,"acroread").toString();
201 #if defined(Q_OS_MACX)
202 s=settings.value (p,"/usr/bin/open").toString();
204 s=settings.value (p,"acroread").toString();
207 settings.setValue( p,s);
212 // Create tab widget which holds the maps
213 tabWidget= new QTabWidget (this);
214 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
215 this, SLOT( editorChanged( QWidget * ) ) );
217 setCentralWidget(tabWidget);
221 setupFormatActions();
225 setupSettingsActions();
227 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
232 restoreState (settings.value("/mainwindow/state",0).toByteArray());
234 // Initialize Find window
235 findWindow=new FindWindow(NULL,"findwindow");
236 connect (findWindow, SIGNAL( findButton(QString) ),
237 this, SLOT(editFind(QString) ) );
238 connect (findWindow, SIGNAL( somethingChanged() ),
239 this, SLOT(editFindChanged() ) );
241 // Connect TextEditor, so that we can update flags if text changes
242 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
250 settings.setValue ( "/mainwindow/geometry/size", size() );
251 settings.setValue ( "/mainwindow/geometry/pos", pos() );
253 settings.setValue ("/mainwindow/state",saveState(0));
255 settings.setValue( "/version/version", __VYM_VERSION );
256 settings.setValue( "/version/builddate", __BUILD_DATE );
258 settings.setValue( "/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
259 settings.setValue( "/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
260 settings.setValue( "/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
261 settings.setValue( "/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
262 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
263 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
264 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
267 int maps=lastMaps.count();
268 settings.setValue( "/lastMaps/number",maps );
269 for (int i=1;i<=maps;i++)
271 s=QString("/lastMaps/map-%1").arg(i);
272 if (!s.isEmpty() && i<=maxLastMaps)
273 settings.setValue (s, lastMaps.at(i-1));
277 // To make the texteditor save its settings, call the destructor
280 // Remove temporary directory
281 removeDir (QDir(tmpVymDir));
284 void Main::loadCmdLine()
286 /* TODO draw some kind of splashscreen while loading...
292 QStringList flist=options.getFileList();
293 QStringList::Iterator it=flist.begin();
295 while (it !=flist.end() )
297 fileLoad (*it, NewMap);
303 void Main::statusMessage(const QString &s)
305 statusBar()->message (s);
308 void Main::closeEvent (QCloseEvent* )
314 void Main::setupFileActions()
316 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
317 QToolBar *tb = addToolBar( tr ("&Map") );
320 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
321 a->setStatusTip ( tr( "New map","File menu" ) );
322 a->setShortcut ( Qt::CTRL + Qt::Key_N );
324 fileMenu->addAction (a);
325 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
327 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
328 a->setStatusTip (tr( "Open","File menu" ) );
329 a->setShortcut ( Qt::CTRL + Qt::Key_O );
331 fileMenu->addAction (a);
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
334 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
335 fileMenu->addSeparator();
337 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
338 a->setStatusTip ( tr( "Save" ));
339 a->setShortcut (Qt::CTRL + Qt::Key_S );
341 fileMenu->addAction (a);
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
345 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
346 a->setStatusTip (tr( "Save &As" ) );
347 fileMenu->addAction (a);
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
350 fileMenu->addSeparator();
352 fileImportMenu = fileMenu->addMenu (tr("Import"));
354 a = new QAction(tr("KDE Bookmarks"), this);
355 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
356 a->addTo (fileImportMenu);
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
359 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
361 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
362 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
363 a->addTo (fileImportMenu);
364 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
367 a = new QAction("Mind Manager...",this);
368 a->setStatusTip ( tr( "Import")+" Mind Manager" );
369 fileImportMenu->addAction (a);
370 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
372 a = new QAction( tr( "Import Dir"+QString("...") ), this);
373 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
374 fileImportMenu->addAction (a);
375 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
377 fileExportMenu = fileMenu->addMenu (tr("Export"));
379 a = new QAction( tr("Image")+QString("..."), this);
380 a->setStatusTip( tr( "Export map as image" ));
381 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
382 fileExportMenu->addAction (a);
384 a = new QAction( "Open Office"+QString("..."), this);
385 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
386 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
387 fileExportMenu->addAction (a);
389 a = new QAction( "Webpage (XHTML)...",this );
390 a->setShortcut (Qt::ALT + Qt::Key_X);
391 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
393 fileExportMenu->addAction (a);
395 a = new QAction( "Text (ASCII)...", this);
396 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
397 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
398 fileExportMenu->addAction (a);
400 a = new QAction( tr("KDE Bookmarks"), this);
401 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
402 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
403 fileExportMenu->addAction (a);
405 a = new QAction( "Taskjuggler...", this );
406 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
407 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
408 fileExportMenu->addAction (a);
410 a = new QAction( "LaTeX...", this);
411 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
412 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
413 fileExportMenu->addAction (a);
415 a = new QAction( "XML..." , this );
416 a->setStatusTip (tr( "Export as")+" XML");
417 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
418 fileExportMenu->addAction (a);
420 fileMenu->addSeparator();
422 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
423 a->setStatusTip ( tr( "Print" ) );
424 a->setShortcut (Qt::CTRL + Qt::Key_P );
426 fileMenu->addAction (a);
427 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
430 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
431 a->setStatusTip (tr( "Close Map" ) );
432 a->setShortcut (Qt::ALT + Qt::Key_C );
433 fileMenu->addAction (a);
434 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
436 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
437 a->setStatusTip ( tr( "Exit")+" "+__VYM );
438 a->setShortcut (Qt::CTRL + Qt::Key_Q );
439 fileMenu->addAction (a);
440 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
445 void Main::setupEditActions()
447 QToolBar *tb = addToolBar( tr ("&Actions") );
448 tb->setLabel( "Edit Actions" );
449 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
453 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
454 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
455 a->setStatusTip (tr( "Undo" ) );
456 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
457 a->setEnabled (false);
459 editMenu->addAction (a);
462 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
464 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
465 a->setStatusTip (tr( "Redo" ));
466 a->setShortcut (Qt::CTRL + Qt::Key_Y );
467 editMenu->addAction (a);
468 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
471 editMenu->addSeparator();
472 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
473 a->setStatusTip ( tr( "Copy" ) );
474 a->setShortcut (Qt::CTRL + Qt::Key_C );
475 a->setEnabled (false);
477 editMenu->addAction (a);
478 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
481 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
482 a->setStatusTip ( tr( "Cut" ) );
483 a->setShortcut (Qt::CTRL + Qt::Key_X );
484 a->setEnabled (false);
486 editMenu->addAction (a);
488 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
490 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
491 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
492 a->setStatusTip ( tr( "Paste" ) );
493 a->setShortcut ( Qt::CTRL + Qt::Key_V );
494 a->setEnabled (false);
496 editMenu->addAction (a);
499 // Shortcuts to modify heading:
500 a = new QAction(tr( "Edit heading" ),this);
501 a->setStatusTip ( tr( "edit Heading" ));
502 a->setShortcut ( Qt::Key_Enter);
503 a->setShortcutContext (Qt::WindowShortcut);
505 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
506 actionListBranches.append(a);
507 a = new QAction( tr( "Edit heading" ), this);
508 a->setStatusTip (tr( "edit Heading" ));
509 a->setShortcut (Qt::Key_Return );
510 a->setShortcutContext (Qt::WindowShortcut);
512 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
513 actionListBranches.append(a);
514 editMenu->addAction (a);
516 a = new QAction( tr( "Edit heading" ), this);
517 a->setStatusTip (tr( "edit Heading" ));
518 a->setShortcut ( Qt::Key_F2 );
519 a->setShortcutContext (Qt::WindowShortcut);
521 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
522 actionListBranches.append(a);
524 // Shortcut to delete selection
525 a = new QAction( tr( "Delete Selection" ),this);
526 a->setStatusTip (tr( "Delete Selection" ));
527 a->setShortcut ( Qt::Key_Delete);
528 a->setShortcutContext (Qt::WindowShortcut);
530 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
533 // Shortcut to add branch
534 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
535 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
536 alt->setShortcut (Qt::Key_A);
537 alt->setShortcutContext (Qt::WindowShortcut);
539 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
540 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
541 a->setStatusTip ( tr( "Add a branch as child of selection" ));
542 a->setShortcut (Qt::Key_Insert);
543 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
544 actionListBranches.append(a);
545 #if defined (Q_OS_MACX)
546 // In OSX show different shortcut in menues, the keys work indepently always
547 actionEditAddBranch=alt;
549 actionEditAddBranch=a;
551 editMenu->addAction (actionEditAddBranch);
552 tb->addAction (actionEditAddBranch);
555 // Add branch by inserting it at selection
556 a = new QAction(tr( "Add branch (insert)" ), this);
557 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
558 a->setShortcut (Qt::ALT + Qt::Key_Insert );
559 a->setShortcutContext (Qt::WindowShortcut);
561 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
562 a->setEnabled (false);
563 actionListBranches.append(a);
564 actionEditAddBranchHere=a;
565 a = new QAction(tr( "Add branch (insert)" ),this);
566 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
567 a->setShortcut ( Qt::ALT + Qt::Key_A );
568 a->setShortcutContext (Qt::WindowShortcut);
570 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchHere() ) );
571 actionListBranches.append(a);
574 a = new QAction(tr( "Add branch above" ), this);
575 a->setStatusTip ( tr( "Add a branch above selection" ));
576 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
577 a->setShortcutContext (Qt::WindowShortcut);
579 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
580 a->setEnabled (false);
581 actionListBranches.append(a);
582 actionEditAddBranchAbove=a;
583 a = new QAction(tr( "Add branch above" ), this);
584 a->setStatusTip ( tr( "Add a branch above selection" ));
585 a->setShortcut (Qt::SHIFT+Qt::Key_A );
586 a->setShortcutContext (Qt::WindowShortcut);
588 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
589 actionListBranches.append(a);
592 a = new QAction(tr( "Add branch below" ), this);
593 a->setStatusTip ( tr( "Add a branch below selection" ));
594 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
595 a->setShortcutContext (Qt::WindowShortcut);
597 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
598 a->setEnabled (false);
599 actionListBranches.append(a);
600 actionEditAddBranchBelow=a;
601 a = new QAction(tr( "Add branch below" ), this);
602 a->setStatusTip ( tr( "Add a branch below selection" ));
603 a->setShortcut (Qt::CTRL +Qt::Key_A );
604 a->setShortcutContext (Qt::WindowShortcut);
606 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
607 actionListBranches.append(a);
609 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
610 a->setStatusTip ( tr( "Move branch up" ) );
611 a->setShortcut (Qt::Key_PageUp );
612 a->setEnabled (false);
614 editMenu->addAction (a);
615 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
618 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
619 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
620 a->setStatusTip (tr( "Move branch down" ) );
621 a->setShortcut ( Qt::Key_PageDown );
622 a->setEnabled (false);
624 editMenu->addAction (a);
625 actionEditMoveDown=a;
628 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
629 a->setShortcut ( Qt::Key_ScrollLock );
630 a->setStatusTip (tr( "Scroll branch" ) );
631 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
632 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
633 alt->setShortcut ( Qt::Key_S );
634 alt->setStatusTip (tr( "Scroll branch" ));
635 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
636 #if defined(Q_OS_MACX)
637 actionEditToggleScroll=alt;
639 actionEditToggleScroll=a;
641 actionEditToggleScroll->setEnabled (false);
642 actionEditToggleScroll->setToggleAction(true);
643 tb->addAction (actionEditToggleScroll);
644 editMenu->addAction ( actionEditToggleScroll);
645 editMenu->addAction (actionEditToggleScroll);
646 actionListBranches.append(actionEditToggleScroll);
648 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
649 a->setStatusTip (tr( "Unscroll all" ));
650 editMenu->addAction (a);
651 connect( a, SIGNAL( triggered() ), this, SLOT( editUnScrollAll() ) );
653 editMenu->addSeparator();
655 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
656 a->setStatusTip (tr( "Find" ) );
657 a->setShortcut (Qt::CTRL + Qt::Key_F );
658 editMenu->addAction (a);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
661 editMenu->addSeparator();
663 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
664 a->setShortcut (Qt::CTRL + Qt::Key_U );
665 a->setShortcut (tr( "Open URL" ));
668 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
671 a = new QAction( tr( "Open URL in new tab" ), this);
672 a->setStatusTip (tr( "Open URL in new tab" ));
673 a->setShortcut (Qt::CTRL+Qt::Key_U );
675 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
676 actionEditOpenURLTab=a;
678 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
679 a->setStatusTip ( tr( "Edit URL" ) );
680 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
681 //a->setShortcut ( Qt::Key_U );
682 a->setShortcutContext (Qt::WindowShortcut);
683 actionListBranches.append(a);
685 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
688 a = new QAction( tr( "Use heading for URL" ), this);
689 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
690 a->setEnabled (false);
691 actionListBranches.append(a);
692 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
693 actionEditHeading2URL=a;
695 a = new QAction(tr( "Create URL to Bugzilla" ), this);
696 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
697 a->setEnabled (false);
698 actionListBranches.append(a);
699 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
700 actionEditBugzilla2URL=a;
702 a = new QAction(tr( "Create URL to FATE" ), this);
703 a->setStatusTip ( tr( "Create URL to FATE" ));
704 a->setEnabled (false);
705 actionListBranches.append(a);
706 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
707 actionEditFATE2URL=a;
709 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
710 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
712 a->setEnabled (false);
713 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
714 actionEditOpenVymLink=a;
716 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
717 a->setEnabled (false);
718 a->setStatusTip ( tr( "Edit link to another vym map" ));
719 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
720 actionListBranches.append(a);
723 a = new QAction(tr( "Delete vym link" ),this);
724 a->setStatusTip ( tr( "Delete link to another vym map" ));
725 a->setEnabled (false);
726 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
727 actionEditDeleteVymLink=a;
729 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
730 a->setStatusTip ( tr( "Hide object in exports" ) );
731 a->setShortcut (Qt::Key_H );
732 a->setToggleAction(true);
734 a->setEnabled (false);
735 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
736 actionEditToggleHideExport=a;
738 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
739 a->setStatusTip ( tr( "Edit Map Info" ));
740 a->setEnabled (true);
741 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
744 editMenu->addSeparator();
746 // Import at selection (adding to selection)
747 a = new QAction( tr( "Add map (insert)" ),this);
748 a->setStatusTip (tr( "Add map at selection" ));
749 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
750 a->setEnabled (false);
751 actionListBranches.append(a);
752 actionEditImportAdd=a;
754 // Import at selection (replacing selection)
755 a = new QAction( tr( "Add map (replace)" ), this);
756 a->setStatusTip (tr( "Replace selection with map" ));
757 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
758 a->setEnabled (false);
759 actionListBranches.append(a);
760 actionEditImportReplace=a;
763 a = new QAction( tr( "Save selection" ), this);
764 a->setStatusTip (tr( "Save selection" ));
765 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
766 a->setEnabled (false);
767 actionListBranches.append(a);
768 actionEditSaveBranch=a;
770 // Only remove branch, not its childs
771 a = new QAction(tr( "Remove only branch " ), this);
772 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
773 a->setShortcut (Qt::ALT + Qt::Key_Delete );
774 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveBranchKeepChilds() ) );
775 a->setEnabled (false);
776 actionListBranches.append(a);
777 actionEditRemoveBranchKeepChilds=a;
779 // Only remove childs of a branch
780 a = new QAction( tr( "Remove childs" ), this);
781 a->setStatusTip (tr( "Remove childs of branch" ));
782 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
783 connect( a, SIGNAL( triggered() ), this, SLOT( editRemoveChilds() ) );
784 a->setEnabled (false);
785 actionListBranches.append(a);
786 actionEditRemoveChilds=a;
788 // Shortcuts for navigating with cursor:
789 a = new QAction(tr( "Select upper branch" ), this);
790 a->setStatusTip ( tr( "Select upper branch" ));
791 a->setShortcut (Qt::Key_Up );
792 a->setShortcutContext (Qt::WindowShortcut);
794 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
795 a = new QAction( tr( "Select lower branch" ),this);
796 a->setStatusTip (tr( "Select lower branch" ));
797 a->setShortcut ( Qt::Key_Down );
798 a->setShortcutContext (Qt::WindowShortcut);
800 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
801 a = new QAction(tr( "Select left branch" ), this);
802 a->setStatusTip ( tr( "Select left branch" ));
803 a->setShortcut (Qt::Key_Left );
804 a->setShortcutContext (Qt::WindowShortcut);
806 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
807 a = new QAction( tr( "Select child branch" ), this);
808 a->setStatusTip (tr( "Select right branch" ));
809 a->setShortcut (Qt::Key_Right);
810 a->setShortcutContext (Qt::WindowShortcut);
812 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
813 a = new QAction( tr( "Select first branch" ), this);
814 a->setStatusTip (tr( "Select first branch" ));
815 a->setShortcut (Qt::Key_Home );
816 a->setShortcutContext (Qt::WindowShortcut);
818 a->setEnabled (false);
819 editMenu->addAction (a);
820 actionListBranches.append(a);
821 actionEditSelectFirst=a;
822 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
823 a = new QAction( tr( "Select last branch" ),this);
824 a->setStatusTip (tr( "Select last branch" ));
825 a->setShortcut ( Qt::Key_End );
826 a->setShortcutContext (Qt::WindowShortcut);
828 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
829 a->setEnabled (false);
830 editMenu->addAction (a);
831 actionListBranches.append(a);
832 actionEditSelectLast=a;
834 a = new QAction( tr( "Add Image" )+QString("..."), this);
835 a->setStatusTip (tr( "Add Image" ));
836 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
837 actionEditLoadImage=a;
842 void Main::setupFormatActions()
844 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
846 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
849 pix.fill (Qt::black);
850 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
851 a->setStatusTip ( tr( "Set Color" ));
852 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
854 formatMenu->addAction (a);
856 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
857 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
858 a->setShortcut (Qt::CTRL + Qt::Key_K );
859 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
860 a->setEnabled (false);
862 formatMenu->addAction (a);
863 actionListBranches.append(a);
864 actionFormatPickColor=a;
866 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
867 a->setStatusTip ( tr( "Color branch" ) );
868 a->setShortcut (Qt::CTRL + Qt::Key_I);
869 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorItem() ) );
870 a->setEnabled (false);
872 formatMenu->addAction (a);
873 actionListBranches.append(a);
874 actionFormatColorBranch=a;
876 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
877 a->setStatusTip ( tr( "Color Subtree" ));
878 a->setShortcut (Qt::CTRL + Qt::Key_T);
879 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
880 a->setEnabled (false);
881 formatMenu->addAction (a);
883 actionListBranches.append(a);
884 actionFormatColorSubtree=a;
886 formatMenu->addSeparator();
887 actionGroupFormatLinkStyles=new QActionGroup ( this);
888 actionGroupFormatLinkStyles->setExclusive (true);
889 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
890 a->setStatusTip (tr( "Line" ));
891 a->setToggleAction(true);
892 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
893 formatMenu->addAction (a);
894 actionFormatLinkStyleLine=a;
895 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
896 a->setStatusTip (tr( "Line" ));
897 a->setToggleAction(true);
898 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
899 formatMenu->addAction (a);
900 actionFormatLinkStyleParabel=a;
901 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
902 a->setStatusTip (tr( "PolyLine" ));
903 a->setToggleAction(true);
904 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
905 formatMenu->addAction (a);
906 actionFormatLinkStylePolyLine=a;
907 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
908 a->setStatusTip (tr( "PolyParabel" ) );
909 a->setToggleAction(true);
910 a->setChecked (true);
911 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
912 formatMenu->addAction (a);
913 actionFormatLinkStylePolyParabel=a;
915 actionGroupFormatFrameTypes=new QActionGroup ( this);
916 actionGroupFormatFrameTypes->setExclusive (true);
917 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
918 a->setStatusTip (tr("No Frame"));
919 a->setToggleAction(true);
920 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameNone() ) );
921 actionFormatFrameNone=a;
922 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
923 a->setStatusTip (tr( "Rectangle" ));
924 a->setToggleAction(true);
925 connect( a, SIGNAL( triggered() ), this, SLOT( formatFrameRectangle() ) );
926 actionFormatFrameRectangle=a;
928 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
929 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
930 a->setToggleAction(true);
931 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesVer() ) );
932 actionFormatIncludeImagesVer=a;
934 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
935 a->setStatusTip ( tr ("Include left and right position of images into branch"));
936 a->setToggleAction(true);
937 connect( a, SIGNAL( triggered() ), this, SLOT( formatIncludeImagesHor() ) );
938 actionFormatIncludeImagesHor=a;
940 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
941 a->setStatusTip (tr( "Hide link" ));
942 a->setToggleAction(true);
943 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
944 actionFormatHideLinkUnselected=a;
946 formatMenu->addSeparator();
947 a= new QAction( tr( "&Use color of heading for link" ), this);
948 a->setStatusTip (tr( "Use same color for links and headings" ));
949 a->setToggleAction(true);
950 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
951 formatMenu->addAction (a);
952 actionFormatLinkColorHint=a;
954 pix.fill (Qt::white);
955 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
956 a->setStatusTip (tr( "Set Link Color" ));
957 formatMenu->addAction (a);
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
959 actionFormatLinkColor=a;
961 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
962 a->setStatusTip (tr( "Set Background Color" ));
963 formatMenu->addAction (a);
964 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
965 actionFormatBackColor=a;
969 void Main::setupViewActions()
971 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
972 tb->setLabel( "View Actions" );
973 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
976 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
977 a->setStatusTip ( tr( "Zoom reset" ) );
978 a->setShortcut (Qt::CTRL + Qt::Key_0 );
980 viewMenu->addAction (a);
981 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
983 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
984 a->setStatusTip (tr( "Zoom in" ));
985 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
987 viewMenu->addAction (a);
988 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
990 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
991 a->setStatusTip (tr( "Zoom out" ));
992 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
994 viewMenu->addAction (a);
995 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
998 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
999 a->setStatusTip ( tr( "Show Note Editor" ));
1000 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1001 a->setToggleAction(true);
1002 if (textEditor->showWithMain())
1007 viewMenu->addAction (a);
1008 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1009 actionViewToggleNoteEditor=a;
1011 a = new QAction( tr( "Show history window" ),this );
1012 a->setStatusTip ( tr( "Show history window" ));
1013 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1014 a->setToggleAction(false);
1015 viewMenu->addAction (a);
1016 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1017 actionViewToggleHistoryWindow=a;
1019 a = new QAction(tr( "Next Window" ), this);
1020 a->setStatusTip ( tr( "&Next Window" ) );
1021 a->setShortcut (Qt::ALT + Qt::Key_N );
1022 viewMenu->addAction (a);
1023 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1025 a = new QAction (tr( "Previous Window" ), this );
1026 a->setStatusTip (tr( "&Previous Window" ));
1027 a->setShortcut (Qt::ALT + Qt::Key_P );
1028 viewMenu->addAction (a);
1029 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1033 void Main::setupModeActions()
1035 //QPopupMenu *menu = new QPopupMenu( this );
1036 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1038 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1040 actionGroupModModes=new QActionGroup ( this);
1041 actionGroupModModes->setExclusive (true);
1042 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1043 a->setShortcut (Qt::Key_J);
1044 a->setStatusTip ( tr( "Use modifier to color branches" ));
1045 a->setToggleAction(true);
1048 actionModModeColor=a;
1050 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1051 a->setShortcut( Qt::Key_K);
1052 a->setStatusTip( tr( "Use modifier to copy" ));
1053 a->setToggleAction(true);
1055 actionModModeCopy=a;
1057 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1058 a->setShortcut (Qt::Key_L);
1059 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1060 a->setToggleAction(true);
1062 actionModModeLink=a;
1066 void Main::setupFlagActions()
1068 // Create System Flags
1069 systemFlagsDefault = new FlagRowObj ();
1070 systemFlagsDefault->setVisibility (false);
1071 systemFlagsDefault->setName ("systemFlagsDef");
1073 FlagObj *fo = new FlagObj ();
1074 fo->load(QPixmap(flagsPath+"flag-note.png"));
1075 fo->setName("note");
1076 fo->setToolTip(tr("Note","Systemflag"));
1077 systemFlagsDefault->addFlag (fo); // makes deep copy
1079 fo->load(QPixmap(flagsPath+"flag-url.png"));
1081 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1082 systemFlagsDefault->addFlag (fo);
1084 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1085 fo->setName("vymLink");
1086 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1087 systemFlagsDefault->addFlag (fo);
1089 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1090 fo->setName("scrolledright");
1091 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1092 systemFlagsDefault->addFlag (fo);
1094 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1095 fo->setName("tmpUnscrolledright");
1096 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1097 systemFlagsDefault->addFlag (fo);
1099 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1100 fo->setName("hideInExport");
1101 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1102 systemFlagsDefault->addFlag (fo);
1104 // Create Standard Flags
1105 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1106 //FIXMEtoolbars.add (tb);
1108 standardFlagsDefault = new FlagRowObj ();
1109 standardFlagsDefault->setVisibility (false);
1110 standardFlagsDefault->setName ("standardFlagsDef");
1111 standardFlagsDefault->setToolBar (tb);
1112 tb->setObjectName ("standardFlagTB");
1114 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1115 fo->setName ("exclamationmark");
1116 fo->setGroup("standard-mark");
1117 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1120 a->setCheckable(true);
1121 a->setObjectName(fo->getName());
1122 a->setToolTip(tr("Take care!","Standardflag"));
1123 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1124 standardFlagsDefault->addFlag (fo); // makes deep copy
1126 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1127 fo->setName("questionmark");
1128 fo->setGroup("standard-mark");
1129 a=new QAction (fo->getPixmap(),fo->getName(),this);
1132 a->setCheckable(true);
1133 a->setObjectName(fo->getName());
1134 a->setToolTip(tr("Really?","Standardflag"));
1135 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1136 standardFlagsDefault->addFlag (fo);
1138 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1139 fo->setName("hook-green");
1140 fo->setGroup("standard-hook");
1141 a=new QAction (fo->getPixmap(),fo->getName(),this);
1144 a->setCheckable(true);
1145 a->setObjectName(fo->getName());
1146 a->setToolTip(tr("ok!","Standardflag"));
1147 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1148 standardFlagsDefault->addFlag (fo);
1150 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1151 fo->setName("cross-red");
1152 fo->setGroup("standard-hook");
1153 a=new QAction (fo->getPixmap(),fo->getName(),this);
1156 a->setCheckable(true);
1157 a->setObjectName(fo->getName());
1158 a->setToolTip(tr("Not ok!","Standardflag"));
1159 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1160 standardFlagsDefault->addFlag (fo);
1162 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1163 fo->setName("stopsign");
1164 a=new QAction (fo->getPixmap(),fo->getName(),this);
1167 a->setCheckable(true);
1168 a->setObjectName(fo->getName());
1169 a->setToolTip(tr("This won't work!","Standardflag"));
1170 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1171 standardFlagsDefault->addFlag (fo);
1173 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1174 fo->setName("smiley-good");
1175 fo->setGroup("standard-smiley");
1176 a=new QAction (fo->getPixmap(),fo->getName(),this);
1179 a->setCheckable(true);
1180 a->setObjectName(fo->getName());
1181 a->setToolTip(tr("Good","Standardflag"));
1182 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1183 standardFlagsDefault->addFlag (fo);
1185 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1186 fo->setName("smiley-sad");
1187 fo->setGroup("standard-smiley");
1188 a=new QAction (fo->getPixmap(),fo->getName(),this);
1191 a->setCheckable(true);
1192 a->setObjectName(fo->getName());
1193 a->setToolTip(tr("Bad","Standardflag"));
1194 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1195 standardFlagsDefault->addFlag (fo);
1197 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1198 // Original omg.png (in KDE emoticons)
1199 fo->setName("smiley-omg");
1200 fo->setGroup("standard-smiley");
1201 a=new QAction (fo->getPixmap(),fo->getName(),this);
1204 a->setCheckable(true);
1205 a->setObjectName(fo->getName());
1206 a->setToolTip(tr("Oh no!","Standardflag"));
1207 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1208 standardFlagsDefault->addFlag (fo);
1210 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1211 fo->setName("clock");
1212 a=new QAction (fo->getPixmap(),fo->getName(),this);
1215 a->setCheckable(true);
1216 a->setObjectName(fo->getName());
1217 a->setToolTip(tr("Time critical","Standardflag"));
1218 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1219 standardFlagsDefault->addFlag (fo);
1221 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1222 fo->setName("phone");
1223 a=new QAction (fo->getPixmap(),fo->getName(),this);
1226 a->setCheckable(true);
1227 a->setObjectName(fo->getName());
1228 a->setToolTip(tr("Call...","Standardflag"));
1229 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1230 standardFlagsDefault->addFlag (fo);
1232 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1233 fo->setName("lamp");
1234 a=new QAction (fo->getPixmap(),fo->getName(),this);
1237 a->setCheckable(true);
1238 a->setObjectName(fo->getName());
1239 a->setToolTip(tr("Idea!","Standardflag"));
1240 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1241 standardFlagsDefault->addFlag (fo);
1243 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1244 fo->setName("arrow-up");
1245 fo->setGroup("standard-arrow");
1246 a=new QAction (fo->getPixmap(),fo->getName(),this);
1249 a->setCheckable(true);
1250 a->setObjectName(fo->getName());
1251 a->setToolTip(tr("Important","Standardflag"));
1252 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1253 standardFlagsDefault->addFlag (fo);
1255 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1256 fo->setName("arrow-down");
1257 fo->setGroup("standard-arrow");
1258 a=new QAction (fo->getPixmap(),fo->getName(),this);
1261 a->setCheckable(true);
1262 a->setObjectName(fo->getName());
1263 a->setToolTip(tr("Unimportant","Standardflag"));
1264 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1265 standardFlagsDefault->addFlag (fo);
1267 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1268 fo->setName("2arrow-up");
1269 fo->setGroup("standard-arrow");
1270 a=new QAction (fo->getPixmap(),fo->getName(),this);
1273 a->setCheckable(true);
1274 a->setObjectName(fo->getName());
1275 a->setToolTip(tr("Very important!","Standardflag"));
1276 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1277 standardFlagsDefault->addFlag (fo);
1279 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1280 fo->setName("2arrow-down");
1281 fo->setGroup("standard-arrow");
1282 a=new QAction (fo->getPixmap(),fo->getName(),this);
1285 a->setCheckable(true);
1286 a->setObjectName(fo->getName());
1287 a->setToolTip(tr("Very unimportant!","Standardflag"));
1288 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1289 standardFlagsDefault->addFlag (fo);
1291 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1292 fo->setName("thumb-up");
1293 fo->setGroup("standard-thumb");
1294 a=new QAction (fo->getPixmap(),fo->getName(),this);
1297 a->setCheckable(true);
1298 a->setObjectName(fo->getName());
1299 a->setToolTip(tr("I like this","Standardflag"));
1300 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1301 standardFlagsDefault->addFlag (fo);
1303 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1304 fo->setName("thumb-down");
1305 fo->setGroup("standard-thumb");
1306 a=new QAction (fo->getPixmap(),fo->getName(),this);
1309 a->setCheckable(true);
1310 a->setObjectName(fo->getName());
1311 a->setToolTip(tr("I do not like this","Standardflag"));
1312 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1313 standardFlagsDefault->addFlag (fo);
1315 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1316 fo->setName("rose");
1317 a=new QAction (fo->getPixmap(),fo->getName(),this);
1320 a->setCheckable(true);
1321 a->setObjectName(fo->getName());
1322 a->setToolTip(tr("Rose","Standardflag"));
1323 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1324 standardFlagsDefault->addFlag (fo);
1326 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1327 fo->setName("heart");
1328 a=new QAction (fo->getPixmap(),fo->getName(),this);
1330 a->setCheckable(true);
1331 a->setObjectName(fo->getName());
1332 a->setToolTip(tr("I just love... ","Standardflag"));
1333 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1334 standardFlagsDefault->addFlag (fo);
1336 fo->load(QPixmap(flagsPath+"flag-present.png"));
1337 fo->setName("present");
1338 a=new QAction (fo->getPixmap(),fo->getName(),this);
1341 a->setCheckable(true);
1342 a->setObjectName(fo->getName());
1343 a->setToolTip(tr("Surprise!","Standardflag"));
1344 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1345 standardFlagsDefault->addFlag (fo);
1347 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1348 fo->setName("flash");
1349 a=new QAction (fo->getPixmap(),fo->getName(),this);
1352 a->setCheckable(true);
1353 a->setObjectName(fo->getName());
1354 a->setToolTip(tr("Dangerous","Standardflag"));
1355 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1356 standardFlagsDefault->addFlag (fo);
1358 fo->load(QPixmap(flagsPath+"flag-info.png"));
1359 // Original: xsldbg_output.png
1360 fo->setName("info");
1361 a=new QAction (fo->getPixmap(),fo->getName(),this);
1364 a->setCheckable(true);
1365 a->setObjectName(fo->getName());
1366 a->setToolTip(tr("Info","Standardflag"));
1367 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1368 standardFlagsDefault->addFlag (fo);
1370 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1371 // Original khelpcenter.png
1372 fo->setName("lifebelt");
1373 a=new QAction (fo->getPixmap(),fo->getName(),this);
1376 a->setCheckable(true);
1377 a->setObjectName(fo->getName());
1378 a->setToolTip(tr("This will help","Standardflag"));
1379 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1380 standardFlagsDefault->addFlag (fo);
1386 void Main::setupSettingsActions()
1388 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1392 a = new QAction( tr( "Set application to open pdf files"), this);
1393 a->setStatusTip ( tr( "Set application to open pdf files"));
1394 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1395 settingsMenu->addAction (a);
1397 a = new QAction( tr( "Set application to open external links"), this);
1398 a->setStatusTip( tr( "Set application to open external links"));
1399 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1400 settingsMenu->addAction (a);
1402 settingsMenu->addSeparator();
1403 a = new QAction( tr( "Edit branch after adding it" ), this );
1404 a->setStatusTip( tr( "Edit branch after adding it" ));
1405 a->setToggleAction(true);
1406 a->setOn ( settings.value ("/mapeditor/editmode/autoedit",true).toBool());
1407 settingsMenu->addAction (a);
1408 actionSettingsAutoedit=a;
1410 a= new QAction( tr( "Select branch after adding it" ), this );
1411 a->setStatusTip( tr( "Select branch after adding it" ));
1412 a->setToggleAction(true);
1413 a->setOn ( settings.value ("/mapeditor/editmode/autoselect",false).toBool() );
1414 settingsMenu->addAction (a);
1415 actionSettingsAutoselectHeading=a;
1417 a= new QAction(tr( "Select existing heading" ), this);
1418 a->setStatusTip( tr( "Select heading before editing" ));
1419 a->setToggleAction(true);
1420 a->setOn ( settings.value ("/mapeditor/editmode/autoselectexistingtext",true).toBool() );
1421 settingsMenu->addAction (a);
1422 actionSettingsAutoselectText=a;
1424 a= new QAction(tr( "pasting into new branch" ), this );
1425 a->setStatusTip( tr( "Pasting into new branch" ));
1426 a->setToggleAction(true);
1427 a->setOn ( settings.value ("/mapeditor/editmode/newheadingisempty",true).toBool() );
1428 settingsMenu->addAction (a);
1429 actionSettingsPasteNewHeading=a;
1431 a= new QAction( tr( "Delete key" ), this);
1432 a->setStatusTip( tr( "Delete key for deleting branches" ));
1433 a->setToggleAction(true);
1434 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1435 settingsMenu->addAction (a);
1436 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1437 actionSettingsUseDelKey=a;
1439 a= new QAction( tr( "Exclusive flags" ), this);
1440 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1441 a->setToggleAction(true);
1442 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1443 settingsMenu->addAction (a);
1444 actionSettingsUseFlagGroups=a;
1446 a= new QAction( tr( "Use hide flags" ), this);
1447 a->setStatusTip( tr( "Use hide flag during exports " ));
1448 a->setToggleAction(true);
1449 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1450 settingsMenu->addAction (a);
1451 actionSettingsUseHideExport=a;
1455 void Main::setupTestActions()
1457 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1460 a = new QAction( tr( "test flag" ), this);
1461 a->setStatusTip( tr( "Call test function" ));
1462 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1463 testMenu->addAction (a);
1467 void Main::setupHelpActions()
1469 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1472 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1473 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1474 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1475 helpMenu->addAction (a);
1477 a = new QAction( tr( "About VYM" ), this);
1478 a->setStatusTip( tr( "About VYM")+" "__VYM);
1479 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1480 helpMenu->addAction (a);
1482 a = new QAction( tr( "About QT" ), this);
1483 a->setStatusTip( tr( "Information about QT toolkit" ));
1484 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1485 helpMenu->addAction (a);
1489 void Main::setupContextMenus()
1493 // Context Menu for branch or mapcenter
1494 branchContextMenu =new QMenu (this);
1497 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1498 branchAddContextMenu->addAction (actionEditPaste );
1499 branchAddContextMenu->addAction ( actionEditAddBranch );
1500 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1501 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1502 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1503 branchAddContextMenu->addSeparator();
1504 branchAddContextMenu->addAction ( actionEditLoadImage);
1505 branchAddContextMenu->addSeparator();
1506 branchAddContextMenu->addAction ( actionEditLoadImage);
1507 branchAddContextMenu->addAction ( actionEditImportAdd );
1508 branchAddContextMenu->addAction ( actionEditImportReplace );
1511 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1512 branchRemoveContextMenu->addAction (actionEditCut);
1513 branchRemoveContextMenu->addAction ( actionEditDelete );
1514 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1515 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1518 actionEditSaveBranch->addTo( branchContextMenu );
1520 branchContextMenu->addSeparator();
1521 branchContextMenu->addAction ( actionEditOpenURL );
1522 branchContextMenu->addAction ( actionEditOpenURLTab );
1523 branchContextMenu->addAction ( actionEditURL );
1524 branchContextMenu->addAction ( actionEditHeading2URL );
1525 branchContextMenu->addAction ( actionEditBugzilla2URL );
1526 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1528 branchContextMenu->addAction ( actionEditFATE2URL );
1530 branchContextMenu->addSeparator();
1531 branchContextMenu->addAction ( actionEditOpenVymLink );
1532 branchContextMenu->addAction ( actionEditVymLink );
1533 branchContextMenu->addAction ( actionEditDeleteVymLink );
1535 branchContextMenu->addSeparator();
1536 branchContextMenu->addAction ( actionFormatFrameNone );
1537 branchContextMenu->addAction ( actionFormatFrameRectangle);
1539 branchContextMenu->addSeparator();
1540 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1541 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1542 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1544 // Context Menu for links in a branch menu
1545 // This will be populated "on demand" in MapEditor::updateActions
1546 branchContextMenu->addSeparator();
1547 branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1548 branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1549 connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1550 connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1552 // Context menu for floatimage
1553 floatimageContextMenu =new QMenu (this);
1554 a= new QAction (tr ("Save image"),this);
1555 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1556 floatimageContextMenu->addAction (a);
1558 floatimageContextMenu->addSeparator();
1559 actionEditCopy->addTo( floatimageContextMenu );
1560 actionEditCut->addTo( floatimageContextMenu );
1562 floatimageContextMenu->addSeparator();
1563 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1566 // Context menu for canvas
1567 canvasContextMenu =new QMenu (this);
1568 actionEditMapInfo->addTo( canvasContextMenu );
1569 canvasContextMenu->insertSeparator();
1570 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1571 canvasContextMenu->insertSeparator();
1572 actionFormatLinkColorHint->addTo( canvasContextMenu );
1573 actionFormatLinkColor->addTo( canvasContextMenu );
1574 actionFormatBackColor->addTo( canvasContextMenu );
1576 // Menu for last opened files
1577 // Read settings initially
1579 int j=settings.readNumEntry( "/lastMaps/number",0);
1580 for (int i=1;i<=j;i++)
1582 s=settings.value(QString("/lastMaps/map-%1").arg(i),"").toString();
1583 if (!s.isEmpty() && j<=maxLastMaps)
1586 setupLastMapsMenu();
1587 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1590 void Main::setupLastMapsMenu()
1592 // Remove double entries
1593 QStringList::Iterator it=lastMaps.begin();
1594 QStringList::Iterator jt;
1595 while (it!=lastMaps.end() )
1599 while (jt!=lastMaps.end() )
1602 jt=lastMaps.remove(jt);
1609 // Limit length of list to maxLastMaps
1610 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1612 // build Menu from lastMaps string list
1613 fileLastMapsMenu->clear();
1614 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1615 fileLastMapsMenu->addAction (*it );
1618 void Main::hideEvent (QHideEvent * )
1620 if (!textEditor->isMinimized() ) textEditor->hide();
1623 void Main::showEvent (QShowEvent * )
1625 if (textEditor->showWithMain()) textEditor->showNormal();
1628 bool Main::reallyWriteDirectory(const QString &dir)
1630 QStringList eList = QDir(dir).entryList();
1631 if (eList.first() ==".") eList.pop_front(); // remove "."
1632 if (eList.first() =="..") eList.pop_front(); // remove "."
1633 if (!eList.isEmpty())
1635 QMessageBox mb( __VYM,
1636 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1637 QMessageBox::Warning,
1639 QMessageBox::Cancel | QMessageBox::Default,
1640 QMessageBox::QMessageBox::NoButton );
1642 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1643 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1646 case QMessageBox::Yes:
1649 case QMessageBox::Cancel:
1657 QString Main::browseDirectory (const QString &caption)
1659 Q3FileDialog fd(this,caption);
1660 fd.setMode (Q3FileDialog::DirectoryOnly);
1661 fd.setCaption(__VYM " - "+caption);
1664 if ( fd.exec() == QDialog::Accepted )
1665 return fd.selectedFile();
1670 MapEditor* Main::currentMapEditor() const
1672 if ( tabWidget->currentPage() &&
1673 tabWidget->currentPage()->inherits( "MapEditor" ) )
1674 return (MapEditor*)tabWidget->currentPage();
1678 //TODO not used now, maybe use this for overview window later
1679 void Main::newView()
1681 // Open a new view... have it delete when closed.
1682 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1683 qApp->setMainWidget(m);
1685 qApp->setMainWidget(0);
1688 void Main::editorChanged(QWidget *)
1690 // Unselect all possibly selected objects
1691 // (Important to update note editor)
1694 for (i=0;i<=tabWidget->count() -1;i++)
1697 me=(MapEditor*)tabWidget->page(i);
1700 currentMapEditor()->reselect();
1702 // Update actions to in menus and toolbars according to editor
1703 currentMapEditor()->updateActions();
1706 void Main::fileNew()
1708 QString fn="unnamed";
1709 MapEditor* medit = new MapEditor ( NULL,true);
1710 tabWidget->addTab (medit,fn);
1711 tabWidget->showPage(medit);
1712 medit->viewport()->setFocus();
1713 // For the very first map we do not have flagrows yet...
1714 medit->select("mc:");
1717 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1719 ErrorCode err=success;
1721 // fn is usually the archive, mapfile the file after uncompressing
1724 // Make fn absolute (needed for unzip)
1725 fn=QDir (fn).absPath();
1731 // Check, if map is already loaded
1733 while (i<=tabWidget->count() -1)
1735 me=(MapEditor*)tabWidget->page(i);
1736 if (me->getFilePath() == fn)
1738 // Already there, ask for confirmation
1739 QMessageBox mb( __VYM,
1740 tr("The map %1\nis already opened."
1741 "Opening the same map in multiple editors may lead \n"
1742 "to confusion when finishing working with vym."
1743 "Do you want to").arg(fn),
1744 QMessageBox::Warning,
1745 QMessageBox::Yes | QMessageBox::Default,
1746 QMessageBox::Cancel | QMessageBox::Escape,
1747 QMessageBox::NoButton);
1748 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1749 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1752 case QMessageBox::Yes:
1754 i=tabWidget->count();
1756 case QMessageBox::Cancel:
1768 if ( !fn.isEmpty() )
1770 me = currentMapEditor();
1771 int tabIndex=tabWidget->currentPageIndex();
1772 // Check first, if mapeditor exists
1773 // If it is not default AND we want a new map,
1774 // create a new mapeditor in a new tab
1775 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1777 me= new MapEditor ( NULL,true);
1778 tabWidget->addTab (me,fn);
1779 tabIndex=tabWidget->indexOf (me);
1780 tabWidget->setCurrentPage (tabIndex);
1783 // Check, if file exists (important for creating new files
1784 // from command line
1785 if (!QFile(fn).exists() )
1787 QMessageBox mb( __VYM,
1788 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1789 QMessageBox::Question,
1791 QMessageBox::Cancel | QMessageBox::Default,
1792 QMessageBox::NoButton );
1794 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1795 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1798 case QMessageBox::Yes:
1800 currentMapEditor()->setFilePath(fn);
1801 tabWidget->setTabLabel (currentMapEditor(),
1802 currentMapEditor()->getFileName() );
1803 statusBar()->message( "Created " + fn , statusbarTime );
1806 case QMessageBox::Cancel:
1807 // don't create new map
1808 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1815 //tabWidget->currentPage() won't be NULL here, because of above...
1816 tabWidget->showPage(me);
1817 me->viewport()->setFocus();
1819 // Create temporary directory for packing
1820 char tmpdir1[]="/tmp/vym-XXXXXX";
1821 QString tmpMapDir=mkdtemp(tmpdir1);
1823 // Try to unzip file
1824 err=unzipDir (tmpMapDir,fn);
1828 me->setZipped(false);
1831 me->setZipped(true);
1833 // Look for mapname.xml
1834 mapfile= fn.left(fn.findRev(".",-1,true));
1835 mapfile=mapfile.section( '/', -1 );
1836 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1837 if (!file.exists() )
1839 // mapname.xml does not exist, well,
1840 // maybe some renamed the mapname.vym file...
1841 // Try to find any .xml in the toplevel
1842 // directory of the .vym file
1843 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1844 if (flist.count()==1)
1846 // Only one entry, take this one
1847 mapfile=tmpMapDir + "/"+flist.first();
1850 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1851 *it=tmpMapDir + "/" + *it;
1852 // TODO Multiple entries, load all (but only the first one into this ME)
1853 //mainWindow->fileLoadFromTmp (flist);
1854 //returnCode=1; // Silently forget this attempt to load
1855 qWarning ("MainWindow::load (fn) multimap found...");
1858 if (flist.isEmpty() )
1860 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1861 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1864 } //file doesn't exist
1866 mapfile=file.name();
1871 // Save existing filename in case we import
1872 QString fn_org=me->getFilePath();
1874 // Finally load map into mapEditor
1875 me->setFilePath (mapfile,fn);
1876 err=me->load(mapfile,lmode);
1878 // Restore old (maybe empty) filepath, if this is an import
1880 me->setFilePath (fn_org);
1883 // Finally check for errors and go home
1886 if (lmode==NewMap) fileCloseMap();
1887 statusBar()->message( "Could not load " + fn, statusbarTime );
1892 me->setFilePath (fn);
1893 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1894 if (fn.left(9)!="/tmp/vym-")
1896 // Only append to lastMaps if not loaded from a tmpDir
1897 // e.g. imported bookmarks are in a tmpDir
1898 lastMaps.prepend(me->getFilePath() );
1899 setupLastMapsMenu();
1901 actionFilePrint->setEnabled (true);
1903 statusBar()->message( "Loaded " + fn, statusbarTime );
1907 removeDir (QDir(tmpMapDir));
1913 void Main::fileLoad(const LoadMode &lmode)
1915 Q3FileDialog *fd=new Q3FileDialog( this);
1916 fd->setDir (lastFileDir);
1917 fd->setMode (Q3FileDialog::ExistingFiles);
1918 fd->addFilter ("XML (*.xml)");
1919 fd->addFilter ("VYM map (*.vym *.vyp)");
1923 fd->setCaption(tr("Load vym map"));
1926 fd->setCaption(tr("Import: Add vym map to selection"));
1929 fd->setCaption(tr("Import: Replace selection with vym map"));
1935 if ( fd->exec() == QDialog::Accepted )
1937 lastFileDir=fd->dirPath();
1938 QStringList flist = fd->selectedFiles();
1939 QStringList::Iterator it = flist.begin();
1940 while( it != flist.end() )
1943 fileLoad(*it, lmode);
1950 void Main::fileLoad()
1955 void Main::fileLoadLast(QAction *a)
1957 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1960 void Main::fileSave(const SaveMode &savemode)
1962 // tmp dir for zipping
1966 ErrorCode err=success;
1968 QString safeFilePath;
1970 bool saveZipped=currentMapEditor()->saveZipped();
1972 MapEditor * me=currentMapEditor();
1975 QString fn=me->getFilePath();
1976 // filename=unnamed, filepath="" in constructor...
1977 if ( !fn.isEmpty() )
1979 // We have a filepath, go on saving
1980 // First remove existing file, we
1981 // don't want to add to old zip archives
1985 QMessageBox::warning( 0, tr( "Save Error" ),
1986 fn+ tr("\ncould not be removed before saving"));
1988 // Look, if we should zip the data:
1991 QMessageBox mb( __VYM,
1992 tr("The map %1\ndid not use the compressed "
1993 "vym file format.\nWriting it uncompressed will also write images \n"
1994 "and flags and thus may overwrite files in the "
1995 "given directory\n\nDo you want to write the map").arg(fn),
1996 QMessageBox::Warning,
1997 QMessageBox::Yes | QMessageBox::Default,
1999 QMessageBox::Cancel | QMessageBox::Escape);
2000 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2001 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2002 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2005 case QMessageBox::Yes:
2006 // save compressed (default file format)
2009 case QMessageBox::No:
2010 // save uncompressed
2013 case QMessageBox::Cancel:
2022 char tmpdir1[]="/tmp/vym-XXXXXX";
2023 tmpMapDir=mkdtemp(tmpdir1);
2025 safeFilePath=me->getFilePath();
2026 me->setFilePath (tmpMapDir+"/"+
2027 me->getMapName()+ ".xml",
2029 me->save (savemode);
2030 me->setFilePath (safeFilePath);
2032 zipDir (tmpMapDir,fn);
2037 safeFilePath=me->getFilePath();
2038 me->setFilePath (fn, safeFilePath);
2039 me->save (savemode);
2040 me->setFilePath (safeFilePath);
2042 } // filepath available
2045 // We have no filepath yet,
2046 // call fileSaveAs() now, this will call fileSave()
2048 fileSaveAs(savemode);
2052 if (saveZipped && !tmpMapDir.isEmpty())
2054 removeDir (QDir(tmpMapDir));
2058 statusBar()->message(
2059 tr("Saved %1").arg(me->getFilePath()),
2061 lastMaps.prepend(me->getFilePath() );
2062 setupLastMapsMenu();
2064 statusBar()->message(
2065 tr("Couldn't save ").arg(me->getFilePath()),
2069 void Main::fileSave()
2071 fileSave (CompleteMap);
2074 void Main::fileSaveAs(const SaveMode& savemode)
2078 if (currentMapEditor())
2080 if (savemode==CompleteMap)
2081 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2083 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2084 if ( !fn.isEmpty() )
2086 // Check for existing file
2087 if (QFile (fn).exists())
2089 QMessageBox mb( __VYM,
2090 tr("The file %1\nexists already. Do you want to").arg(fn),
2091 QMessageBox::Warning,
2092 QMessageBox::Yes | QMessageBox::Default,
2093 QMessageBox::Cancel | QMessageBox::Escape,
2094 QMessageBox::NoButton);
2095 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2096 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2099 case QMessageBox::Yes:
2102 case QMessageBox::Cancel:
2109 // New file, add extension to filename, if missing
2110 // This is always .vym or .vyp, depending on savemode
2111 if (savemode==CompleteMap)
2113 if (!fn.contains (".vym") && !fn.contains (".xml"))
2117 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2126 currentMapEditor()->setFilePath(fn);
2130 if (savemode==CompleteMap)
2131 tabWidget->setTabLabel (currentMapEditor(),
2132 currentMapEditor()->getFileName() );
2138 void Main::fileSaveAs()
2140 fileSaveAs (CompleteMap);
2143 void Main::fileImportKDEBookmarks()
2145 ImportKDEBookmarks im;
2147 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2148 currentMapEditor()->setFilePath ("");
2151 void Main::fileImportFirefoxBookmarks()
2153 Q3FileDialog *fd=new Q3FileDialog( this);
2154 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2155 fd->setMode (Q3FileDialog::ExistingFiles);
2156 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2157 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2160 if ( fd->exec() == QDialog::Accepted )
2162 ImportFirefoxBookmarks im;
2163 QStringList flist = fd->selectedFiles();
2164 QStringList::Iterator it = flist.begin();
2165 while( it != flist.end() )
2168 if (im.transform() &&
2169 success==fileLoad (im.getTransformedFile(),NewMap) &&
2170 currentMapEditor() )
2171 currentMapEditor()->setFilePath ("");
2178 void Main::fileImportMM()
2182 Q3FileDialog *fd=new Q3FileDialog( this);
2183 fd->setDir (lastFileDir);
2184 fd->setMode (Q3FileDialog::ExistingFiles);
2185 fd->addFilter ("Mind Manager (*.mmap)");
2186 fd->setCaption(tr("Import")+" "+"Mind Manager");
2189 if ( fd->exec() == QDialog::Accepted )
2191 lastFileDir=fd->dirPath();
2192 QStringList flist = fd->selectedFiles();
2193 QStringList::Iterator it = flist.begin();
2194 while( it != flist.end() )
2197 if (im.transform() &&
2198 success==fileLoad (im.getTransformedFile(),NewMap) &&
2199 currentMapEditor() )
2200 currentMapEditor()->setFilePath ("");
2209 void Main::fileImportDir()
2211 if (currentMapEditor())
2212 currentMapEditor()->importDir();
2215 void Main::fileExportXML()
2217 if (currentMapEditor())
2219 QString dir=browseDirectory(tr("Export XML to directory"));
2220 if (dir !="" && reallyWriteDirectory(dir) )
2221 currentMapEditor()->exportXML(dir);
2226 void Main::fileExportXHTML()
2228 MapEditor *me=currentMapEditor();
2232 ExportXHTMLDialog dia(this);
2233 dia.setFilePath (me->getFilePath() );
2234 dia.setMapName (me->getMapName() );
2237 if (dia.exec()==QDialog::Accepted)
2239 QString dir=dia.getDir();
2240 // Check, if warnings should be used before overwriting
2241 // the output directory
2244 ok=reallyWriteDirectory(dir);
2250 me->exportXML (dia.getDir() );
2251 dia.doExport(me->getMapName() );
2252 if (dia.hasChanged())
2259 void Main::fileExportImage()
2261 MapEditor *me=currentMapEditor();
2265 QFileDialog *fd=new QFileDialog (this);
2266 fd->setCaption (tr("Export map as image"));
2267 fd->setFileMode(QFileDialog::AnyFile);
2268 fd->setFilters (imageIO.getFilters() );
2269 fd->setDirectory (lastImageDir);
2272 fl=fd->selectedFiles();
2273 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2274 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2279 void Main::fileExportASCII()
2281 MapEditor *me=currentMapEditor();
2285 ex.setMapCenter(me->getMapCenter());
2286 ex.addFilter ("TXT (*.txt)");
2287 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2288 if (ex.execDialog() )
2290 me->setExportMode(true);
2292 me->setExportMode(false);
2297 void Main::fileExportLaTeX()
2299 MapEditor *me=currentMapEditor();
2303 ex.setMapCenter(me->getMapCenter());
2304 ex.addFilter ("Tex (*.tex)");
2305 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2306 if (ex.execDialog() )
2308 me->setExportMode(true);
2310 me->setExportMode(false);
2315 void Main::fileExportKDEBookmarks()
2317 ExportKDEBookmarks ex;
2318 MapEditor *me=currentMapEditor();
2321 ex.setMapCenter (me->getMapCenter() );
2326 void Main::fileExportTaskjuggler()
2328 ExportTaskjuggler ex;
2329 MapEditor *me=currentMapEditor();
2332 ex.setMapCenter (me->getMapCenter() );
2333 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2334 ex.addFilter ("Taskjuggler (*.tjp)");
2335 if (ex.execDialog() )
2337 me->setExportMode(true);
2339 me->setExportMode(false);
2344 void Main::fileExportOOPresentation()
2346 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2347 // TODO add preview in dialog
2348 //ImagePreview *p =new ImagePreview (fd);
2349 //fd->setContentsPreviewEnabled( TRUE );
2350 //fd->setContentsPreview( p, p );
2351 //fd->setPreviewMode( QFileDialog::Contents );
2352 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2353 fd->setDir (QDir().current());
2354 if (fd->foundConfig())
2358 if ( fd->exec() == QDialog::Accepted )
2360 QString fn=fd->selectedFile();
2361 //lastImageDir=fn.left(fn.findRev ("/"));
2362 if (currentMapEditor())
2363 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2367 QMessageBox::warning(0,
2369 tr("Couldn't find configuration for export to Open Office\n"));
2373 void Main::fileCloseMap()
2375 if (currentMapEditor())
2377 if (currentMapEditor()->hasChanged())
2379 QMessageBox mb( __VYM,
2380 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2381 QMessageBox::Warning,
2382 QMessageBox::Yes | QMessageBox::Default,
2384 QMessageBox::Cancel | QMessageBox::Escape );
2385 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2386 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2389 case QMessageBox::Yes:
2391 fileSave(CompleteMap);
2393 case QMessageBox::No:
2394 // close without saving
2396 case QMessageBox::Cancel:
2401 currentMapEditor()->closeMap();
2402 tabWidget->removePage(currentMapEditor());
2403 if (tabWidget->count()==0)
2404 actionFilePrint->setEnabled (false);
2408 void Main::filePrint()
2410 if (currentMapEditor())
2411 currentMapEditor()->print();
2414 void Main::fileExitVYM()
2416 // Check if one or more editors have changed
2419 for (i=0;i<=tabWidget->count() -1;i++)
2422 me=(MapEditor*)tabWidget->page(i);
2424 // If something changed, ask what to do
2425 if (me->isUnsaved())
2427 tabWidget->setCurrentPage(i);
2428 QMessageBox mb( __VYM,
2429 tr("This map is not saved yet. Do you want to"),
2430 QMessageBox::Warning,
2431 QMessageBox::Yes | QMessageBox::Default,
2433 QMessageBox::Cancel | QMessageBox::Escape );
2434 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2435 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2437 mb.setActiveWindow();
2438 switch( mb.exec() ) {
2439 case QMessageBox::Yes:
2440 // save (the changed editors) and exit
2441 fileSave(CompleteMap);
2443 case QMessageBox::No:
2444 // exit without saving
2446 case QMessageBox::Cancel:
2447 // don't save and don't exit
2451 } // loop over all MEs
2455 void Main::editUndo()
2457 if (currentMapEditor())
2458 currentMapEditor()->undo();
2461 void Main::editRedo()
2463 if (currentMapEditor())
2464 currentMapEditor()->redo();
2467 void Main::editCopy()
2469 if (currentMapEditor())
2470 currentMapEditor()->copy();
2473 void Main::editPaste()
2475 if (currentMapEditor())
2476 currentMapEditor()->paste();
2479 void Main::editCut()
2481 if (currentMapEditor())
2482 currentMapEditor()->cut();
2485 void Main::editOpenFindWindow()
2487 findWindow->popup();
2488 findWindow->raise();
2489 findWindow->setActiveWindow();
2492 void Main::editFind(QString s)
2495 BranchObj *bo=currentMapEditor()->findText(s, cs);
2498 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2501 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2502 tr("No matches found for \"%1\"").arg(s));
2506 void Main::editFindChanged()
2507 { // Notify editor, to abort the current find process
2508 currentMapEditor()->findReset();
2511 void Main::editOpenURL()
2514 if (currentMapEditor())
2516 QString url=currentMapEditor()->getURL();
2517 if (url=="") return;
2518 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2519 procBrowser = new Q3Process( this );
2521 procBrowser->addArgument( browser);
2522 procBrowser->addArgument( url);
2524 if ( !procBrowser->start() )
2526 // try to set path to browser
2527 QMessageBox::warning(0,
2529 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2530 tr("Please use Settings->")+tr("Set application to open an URL"));
2535 void Main::editOpenURLTab()
2537 if (currentMapEditor())
2539 QString url=currentMapEditor()->getURL();
2540 if (url=="") return;
2541 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2542 if (procBrowser && procBrowser->isRunning())
2544 if (browser.contains("konqueror"))
2546 // Try to open new tab in existing konqueror started previously by vym
2547 Q3Process *p=new Q3Process (this);
2548 p->addArgument ("dcop");
2549 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2550 p->addArgument ("konqueror-mainwindow#1");
2551 p->addArgument ("newTab");
2552 p->addArgument (url);
2554 // try to set browser
2555 QMessageBox::warning(0,
2557 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2559 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2561 // Try to open new tab in firefox
2562 Q3Process *p=new Q3Process (this);
2563 p->addArgument (browser);
2564 p->addArgument ("-remote");
2565 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2567 // try to set browser
2568 QMessageBox::warning(0,
2570 tr("Couldn't start %1 to open a new tab").arg(browser));
2579 void Main::editURL()
2581 if (currentMapEditor())
2582 currentMapEditor()->editURL();
2585 void Main::editHeading2URL()
2587 if (currentMapEditor())
2588 currentMapEditor()->editHeading2URL();
2591 void Main::editBugzilla2URL()
2593 if (currentMapEditor())
2594 currentMapEditor()->editBugzilla2URL();
2597 void Main::editFATE2URL()
2599 if (currentMapEditor())
2600 currentMapEditor()->editFATE2URL();
2603 void Main::editOpenVymLink()
2605 // Get current path to map
2606 QString currentVymLink;
2607 if (currentMapEditor())
2609 currentVymLink=currentMapEditor()->getVymLink();
2610 // compare path with already loaded maps
2614 for (i=0;i<=tabWidget->count() -1;i++)
2616 me=(MapEditor*)tabWidget->page(i);
2617 if (currentVymLink==me->getFilePath() )
2626 if (!QFile(currentVymLink).exists() )
2627 QMessageBox::critical( 0, tr( "Critical Error" ),
2628 tr("Couldn't open map %1").arg(currentVymLink));
2631 fileLoad (currentVymLink, NewMap);
2632 tabWidget->setCurrentPage (tabWidget->count()-1);
2635 // Go to tab containing the map
2636 tabWidget->setCurrentPage (index);
2640 void Main::editVymLink()
2642 if (currentMapEditor())
2643 currentMapEditor()->editVymLink();
2646 void Main::editDeleteVymLink()
2648 if (currentMapEditor())
2649 currentMapEditor()->deleteVymLink();
2652 void Main::editToggleHideExport()
2654 if (currentMapEditor())
2655 currentMapEditor()->toggleHideExport();
2658 void Main::editMapInfo()
2660 if (currentMapEditor())
2661 currentMapEditor()->editMapInfo();
2664 void Main::editMoveUp()
2666 if (currentMapEditor())
2667 currentMapEditor()->moveBranchUp();
2670 void Main::editMoveDown()
2672 if (currentMapEditor())
2673 currentMapEditor()->moveBranchDown();
2676 void Main::editToggleScroll()
2678 if (currentMapEditor())
2680 currentMapEditor()->toggleScroll();
2684 void Main::editUnScrollAll()
2686 if (currentMapEditor())
2688 currentMapEditor()->unScrollAll();
2692 void Main::editHeading()
2694 if (currentMapEditor())
2695 currentMapEditor()->editHeading();
2698 void Main::editNewBranch()
2700 if (currentMapEditor())
2701 currentMapEditor()->addNewBranch(0);
2704 void Main::editNewBranchHere()
2706 if (currentMapEditor())
2707 currentMapEditor()->addNewBranchHere();
2710 void Main::editNewBranchAbove()
2712 if (currentMapEditor())
2713 currentMapEditor()->addNewBranch(-1);
2716 void Main::editNewBranchBelow()
2718 if (currentMapEditor())
2719 currentMapEditor()->addNewBranch(1);
2722 void Main::editImportAdd()
2724 fileLoad (ImportAdd);
2727 void Main::editImportReplace()
2729 fileLoad (ImportReplace);
2732 void Main::editSaveBranch()
2734 fileSaveAs (PartOfMap);
2737 void Main::editRemoveBranchKeepChilds()
2739 if (currentMapEditor())
2740 currentMapEditor()->removeBranchKeepChilds();
2743 void Main::editRemoveChilds()
2745 if (currentMapEditor())
2746 currentMapEditor()->removeChilds();
2749 void Main::editDeleteSelection()
2751 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2752 currentMapEditor()->deleteSelection();
2755 void Main::editUpperBranch()
2757 if (currentMapEditor())
2758 currentMapEditor()->selectUpperBranch();
2761 void Main::editLowerBranch()
2763 if (currentMapEditor())
2764 currentMapEditor()->selectLowerBranch();
2767 void Main::editLeftBranch()
2769 if (currentMapEditor())
2770 currentMapEditor()->selectLeftBranch();
2773 void Main::editRightBranch()
2775 if (currentMapEditor())
2776 currentMapEditor()->selectRightBranch();
2779 void Main::editFirstBranch()
2781 if (currentMapEditor())
2782 currentMapEditor()->selectFirstBranch();
2785 void Main::editLastBranch()
2787 if (currentMapEditor())
2788 currentMapEditor()->selectLastBranch();
2791 void Main::editLoadImage()
2793 if (currentMapEditor())
2794 currentMapEditor()->loadFloatImage();
2797 void Main::editSaveImage()
2799 if (currentMapEditor())
2800 currentMapEditor()->saveFloatImage();
2803 void Main::editFollowXLink(QAction *a)
2806 if (currentMapEditor())
2807 currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
2810 void Main::editEditXLink(QAction *a)
2812 if (currentMapEditor())
2813 currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
2816 void Main::formatSelectColor()
2818 if (currentMapEditor())
2820 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2821 if ( !col.isValid() ) return;
2822 currentMapEditor()->setColor( col );
2823 colorChanged( col );
2827 void Main::formatPickColor()
2829 if (currentMapEditor())
2830 colorChanged( currentMapEditor()->pickColor() );
2833 void Main::colorChanged(QColor c)
2835 QPixmap pix( 16, 16 );
2837 actionFormatColor->setIconSet( pix );
2840 void Main::formatColorItem()
2842 if (currentMapEditor())
2843 currentMapEditor()->colorItem();
2846 void Main::formatColorBranch()
2848 if (currentMapEditor())
2849 currentMapEditor()->colorBranch();
2852 void Main::formatLinkStyleLine()
2854 if (currentMapEditor())
2855 currentMapEditor()->setLinkStyle(StyleLine);
2858 void Main::formatLinkStyleParabel()
2860 if (currentMapEditor())
2861 currentMapEditor()->setLinkStyle(StyleParabel);
2864 void Main::formatLinkStylePolyLine()
2866 if (currentMapEditor())
2867 currentMapEditor()->setLinkStyle(StylePolyLine);
2870 void Main::formatLinkStylePolyParabel()
2872 if (currentMapEditor())
2873 currentMapEditor()->setLinkStyle(StylePolyParabel);
2876 void Main::formatSelectBackColor()
2878 if (currentMapEditor())
2879 currentMapEditor()->selectBackgroundColor();
2882 void Main::formatSelectLinkColor()
2884 if (currentMapEditor())
2885 currentMapEditor()->selectLinkColor();
2888 void Main::formatToggleLinkColorHint()
2890 currentMapEditor()->toggleLinkColorHint();
2893 void Main::formatFrameNone()
2895 if (currentMapEditor())
2896 currentMapEditor()->setFrame(NoFrame);
2899 void Main::formatFrameRectangle()
2901 if (currentMapEditor())
2902 currentMapEditor()->setFrame(Rectangle);
2905 void Main::formatIncludeImagesVer()
2907 if (currentMapEditor())
2908 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2911 void Main::formatIncludeImagesHor()
2913 if (currentMapEditor())
2914 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2917 void Main::formatHideLinkUnselected()
2919 if (currentMapEditor())
2920 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2923 void Main::viewZoomReset()
2925 if (currentMapEditor())
2929 currentMapEditor()->setWorldMatrix( m );
2930 currentMapEditor()->setViewCenter();
2931 currentMapEditor()->adjustCanvasSize();
2935 void Main::viewZoomIn()
2937 if (currentMapEditor())
2939 QMatrix m = currentMapEditor()->worldMatrix();
2940 m.scale( 1.25, 1.25 );
2941 currentMapEditor()->setWorldMatrix( m );
2942 currentMapEditor()->setViewCenter();
2943 currentMapEditor()->adjustCanvasSize();
2947 void Main::viewZoomOut()
2949 if (currentMapEditor())
2951 QMatrix m = currentMapEditor()->worldMatrix();
2952 m.scale( 0.8, 0.8 );
2953 currentMapEditor()->setWorldMatrix( m );
2954 currentMapEditor()->setViewCenter();
2955 currentMapEditor()->adjustCanvasSize();
2959 void Main::modModeColor()
2963 void Main::modModeLink()
2967 bool Main::settingsPDF()
2969 // Default browser is set in constructor
2971 QString text = QInputDialog::getText(
2972 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2973 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
2975 settings.setValue ("/mainwindow/readerPDF",text);
2980 bool Main::settingsURL()
2982 // Default browser is set in constructor
2984 QString text = QInputDialog::getText(
2985 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2986 settings.value("/mainwindow/readerURL").toString()
2989 settings.setValue ("/mainwindow/readerURL",text);
2993 void Main::settingsToggleDelKey()
2995 if (actionSettingsUseDelKey->isOn())
2997 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3000 actionEditDelete->setAccel (QKeySequence (""));
3004 void Main::windowToggleNoteEditor()
3006 if (textEditor->showWithMain() )
3007 windowHideNoteEditor();
3009 windowShowNoteEditor();
3012 void Main::windowToggleHistory()
3014 if (currentMapEditor())
3015 currentMapEditor()->toggleHistoryWindow();
3018 void Main::updateNoteFlag()
3020 if (currentMapEditor())
3021 currentMapEditor()->updateNoteFlag();
3024 void Main::windowShowNoteEditor()
3026 textEditor->setShowWithMain(true);
3028 actionViewToggleNoteEditor->setOn (true);
3031 void Main::windowHideNoteEditor()
3033 textEditor->setShowWithMain(false);
3035 actionViewToggleNoteEditor->setOn (false);
3038 void Main::windowNextEditor()
3040 if (tabWidget->currentPageIndex() < tabWidget->count())
3041 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3044 void Main::windowPreviousEditor()
3046 if (tabWidget->currentPageIndex() >0)
3047 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3050 void Main::standardFlagChanged()
3052 currentMapEditor()->toggleStandardFlag(sender()->name());
3055 void Main::testFunction()
3057 currentMapEditor()->testFunction();
3060 void Main::helpDoc()
3063 #if defined(Q_OS_MACX)
3064 docpath="./vym.app/Contents/vym.pdf";
3066 // default path in SUSE LINUX
3067 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3070 if (!QFile (docpath).exists() )
3072 // relative path for easy testing in tarball
3073 docpath="doc/vym.pdf";
3074 if (!QFile (docpath).exists() )
3076 // relative path for testing while still writing vym.tex
3077 docpath="doc/tex/vym.pdf";
3078 if (!QFile (docpath).exists() )
3080 // Try yet another one for Knoppix
3081 docpath="/usr/share/doc/packages/vym/vym.pdf";
3082 if (!QFile (docpath).exists() )
3084 QMessageBox::critical(0,
3085 tr("Critcal error"),
3086 tr("Couldn't find the documentation\n"
3087 "vym.pdf in various places."));
3094 Process *pdfProc = new Process();
3095 pdfProc->clearArguments();
3096 pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
3097 pdfProc->addArgument( docpath);
3099 if ( !pdfProc->start() )
3102 QMessageBox::warning(0,
3104 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3105 tr("Please use Settings->")+tr("Set application to open PDF files"));
3112 void Main::helpAbout()
3115 ad.setName ("aboutwindow");
3116 ad.setMinimumSize(500,500);
3117 ad.resize (QSize (500,500));
3121 void Main::helpAboutQT()
3123 QMessageBox::aboutQt( this, "Qt Application Example" );