3 #include "mainwindow.h"
8 #include <q3filedialog.h>
10 #include <qcolordialog.h>
12 #include <qinputdialog.h>
16 #include <QCloseEvent>
19 #include <Q3PopupMenu>
20 #include <QActionGroup>
22 //#include <qdatetime.h> // for random seed
28 #include "aboutdialog.h"
29 #include "exportoofiledialog.h"
31 #include "exportxhtmldialog.h"
33 #include "flagrowobj.h"
35 #include "mapeditor.h"
40 #include "showtextdialog.h"
41 #include "texteditor.h"
44 extern TextEditor *textEditor;
45 extern Main *mainWindow;
46 extern QString tmpVymDir;
47 extern QString clipboardDir;
48 extern bool clipboardEmpty;
49 extern int statusbarTime;
50 extern FlagRowObj* standardFlagsDefault;
51 extern FlagRowObj* systemFlagsDefault;
53 extern Q3PtrList <QAction> actionListBranches;
55 extern QAction* actionFileSave;
56 extern QAction* actionFilePrint;
57 extern QAction* actionEditUndo;
58 extern QAction* actionEditRedo;
59 extern QAction *actionEditCopy;
60 extern QAction *actionEditCut;
61 extern QAction *actionEditPaste;
62 extern QAction *actionEditMoveUp;
63 extern QAction *actionEditMoveDown;
64 extern QAction *actionEditToggleScroll;
65 extern QAction* actionEditOpenURL;
66 extern QAction* actionEditOpenURLTab;
67 extern QAction* actionEditURL;
68 extern QAction* actionEditHeading2URL;
69 extern QAction* actionEditBugzilla2URL;
70 extern QAction* actionEditFATE2URL;
71 extern QAction *actionEditOpenVymLink;
72 extern QAction *actionEditVymLink;
73 extern QAction *actionEditDeleteVymLink;
74 extern QAction *actionEditToggleHideExport;
75 extern QAction *actionEditMapInfo;
76 extern QAction *actionEditHeading;
77 extern QAction *actionEditDelete;
78 extern QAction *actionEditAddBranch;
79 extern QAction *actionEditAddBranchHere;
80 extern QAction *actionEditAddBranchAbove;
81 extern QAction *actionEditAddBranchBelow;
82 extern QAction *actionEditRemoveBranchKeepChilds;
83 extern QAction *actionEditRemoveChilds;
84 extern QAction *actionEditImportAdd;
85 extern QAction *actionEditImportReplace;
86 extern QAction *actionEditSaveBranch;
87 extern QAction *actionEditSelectFirst;
88 extern QAction *actionEditSelectLast;
89 extern QAction *actionEditLoadImage;
91 extern QAction* actionFormatColor;
92 extern QAction* actionFormatPickColor;
93 extern QAction* actionFormatColorBranch;
94 extern QAction* actionFormatColorSubtree;
95 extern QAction* actionFormatLinkColorHint;
96 extern QAction* actionFormatBackColor;
97 extern QAction* actionFormatLinkColor;
98 extern QAction *actionFormatIncludeImagesVer;
99 extern QAction *actionFormatIncludeImagesHor;
101 extern QActionGroup* actionGroupModModes;
102 extern QAction* actionModModeColor;
103 extern QAction* actionModModeLink;
104 extern QAction* actionModModeCopy;
106 extern QActionGroup *actionGroupFormatFrameTypes;
107 extern QAction *actionFormatFrameNone;
108 extern QAction *actionFormatFrameRectangle;
110 extern QActionGroup *actionGroupFormatLinkStyles;
111 extern QAction *actionFormatLinkStyleLine;
112 extern QAction *actionFormatLinkStyleParabel;
113 extern QAction *actionFormatLinkStylePolyLine;
114 extern QAction *actionFormatLinkStylePolyParabel;
115 extern QAction *actionFormatHideLinkUnselected;
117 extern QAction *actionViewToggleNoteEditor;
118 extern QAction *actionViewToggleHistoryWindow;
120 extern QAction* actionSettingsAutoedit;
121 extern QAction* actionSettingsAutoselectHeading;
122 extern QAction* actionSettingsAutoselectHeading;
123 extern QAction* actionSettingsAutoselectText;
124 extern QAction* actionSettingsPasteNewHeading;
125 extern QAction* actionSettingsUseDelKey;
126 extern QAction* actionSettingsUseFlagGroups;
127 extern QAction* actionSettingsUseHideExport;
129 extern QMenu* branchContextMenu;
130 extern QMenu* branchAddContextMenu;
131 extern QMenu* branchRemoveContextMenu;
132 extern QMenu* branchLinksContextMenuEdit;
133 extern QMenu* branchLinksContextMenuFollow;
134 extern QMenu* floatimageContextMenu;
135 extern QMenu* saveImageFormatMenu;
136 extern QMenu* canvasContextMenu;
137 extern QMenu* fileLastMapsMenu;
138 extern QMenu* fileImportMenu;
139 extern QMenu* fileExportMenu;
142 extern Settings settings;
143 extern Options options;
144 extern ImageIO imageIO;
146 extern QDir vymBaseDir;
147 extern QDir lastImageDir;
148 extern QString iconPath;
149 extern QString flagsPath;
151 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
152 QMainWindow(parent,name,f)
156 setCaption ("VYM - View Your Mind");
158 // Load window settings
159 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
160 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
161 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
162 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
165 // Create unique temporary directory
166 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
168 // Create direcctory for clipboard
169 clipboardDir=tmpVymDir+"/clipboard";
170 QDir d(clipboardDir);
171 d.mkdir (clipboardDir,true);
172 makeSubDirs (clipboardDir);
177 // FIXME not used currently
178 // Set random seed (random used for object IDs)
179 // QTime t = QTime::currentTime(); // set random seed
180 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
183 // Initialize some settings, which are platform dependant
186 // application to open URLs
187 p="/vym/mainwindow/readerURL";
188 #if defined(Q_OS_LINUX)
189 s=settings.readEntry (p,"konqueror");
191 #if defined(Q_OS_MACX)
192 s=settings.readEntry (p,"/usr/bin/open");
194 s=settings.readEntry (p,"mozilla");
197 settings.writeEntry( p,s);
199 // application to open PDFs
200 p="/vym/mainwindow/readerPDF";
201 #if defined(Q_OS_LINUX)
202 s=settings.readEntry (p,"acroread");
204 #if defined(Q_OS_MACX)
205 s=settings.readEntry (p,"/usr/bin/open");
207 s=settings.readEntry (p,"acroread");
210 settings.writeEntry( p,s);
215 // Create tab widget which holds the maps
216 tabWidget= new QTabWidget (this);
217 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
218 this, SLOT( editorChanged( QWidget * ) ) );
220 setCentralWidget(tabWidget);
224 setupFormatActions();
228 setupSettingsActions();
230 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
233 // After menu is created, we can enable some actions
234 //FIXME QT3 testing actionFilePrint->setEnabled (true);
239 // Initialize Find window
240 findWindow=new FindWindow(NULL,"findwindow");
241 connect (findWindow, SIGNAL( findButton(QString) ),
242 this, SLOT(editFind(QString) ) );
243 connect (findWindow, SIGNAL( somethingChanged() ),
244 this, SLOT(editFindChanged() ) );
246 // Connect TextEditor, so that we can update flags if text changes
247 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
255 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
256 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
257 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
258 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
260 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
261 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
263 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
264 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
265 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
266 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
267 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
268 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
269 settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
272 int maps=lastMaps.count();
273 settings.writeEntry( "/vym/lastMaps/number",maps );
274 for (int i=1;i<=maps;i++)
276 s=QString("/vym/lastMaps/map-%1").arg(i);
277 if (!s.isEmpty() && i<=maxLastMaps)
278 settings.writeEntry (s, lastMaps.at(i-1));
282 // To make the texteditor save its settings, call the destructor
285 // Remove temporary directory
286 removeDir (QDir(tmpVymDir));
289 void Main::loadCmdLine()
291 /* TODO draw some kind of splashscreen while loading...
297 QStringList flist=options.getFileList();
298 QStringList::Iterator it=flist.begin();
300 while (it !=flist.end() )
302 fileLoad (*it, NewMap);
308 void Main::statusMessage(const QString &s)
310 statusBar()->message (s);
313 void Main::closeEvent (QCloseEvent* )
319 void Main::setupFileActions()
321 QMenu *fileMenu = menuBar()->addMenu ( tr ("&File") );
322 QToolBar *tb = addToolBar( tr ("&File") );
325 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
326 a->setStatusTip ( tr( "New map","File menu" ) );
327 a->setShortcut ( Qt::CTRL + Qt::Key_N );
329 fileMenu->addAction (a);
330 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
332 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
333 a->setStatusTip (tr( "Open","File menu" ) );
334 a->setShortcut ( Qt::CTRL + Qt::Key_O );
336 fileMenu->addAction (a);
337 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
339 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
340 fileMenu->addSeparator();
342 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
343 a->setStatusTip ( tr( "Save" ));
344 a->setShortcut (Qt::CTRL + Qt::Key_S );
346 fileMenu->addAction (a);
347 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
350 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
351 a->setStatusTip (tr( "Save &As" ) );
352 fileMenu->addAction (a);
353 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
355 fileMenu->addSeparator();
357 fileImportMenu = fileMenu->addMenu (tr("Import"));
359 a = new QAction(tr("KDE Bookmarks"), this);
360 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
361 a->addTo (fileImportMenu);
362 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
364 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
366 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
367 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
368 a->addTo (fileImportMenu);
369 connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
372 a = new QAction("Mind Manager...",this);
373 a->setStatusTip ( tr( "Import")+" Mind Manager" );
374 fileImportMenu->addAction (a);
375 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
377 a = new QAction( tr( "Import Dir"+QString("...") ), this);
378 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
379 fileImportMenu->addAction (a);
380 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
382 fileExportMenu = fileMenu->addMenu (tr("Export"));
384 a = new QAction( tr("Image")+QString("..."), this);
385 a->setStatusTip( tr( "Export map as image" ));
386 connect( a, SIGNAL( activated() ), this, SLOT( fileExportImage() ) );
387 fileExportMenu->addAction (a);
389 a = new QAction( "Open Office"+QString("..."), this);
390 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
391 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
392 fileExportMenu->addAction (a);
394 a = new QAction( "Webpage (XHTML)...",this );
395 a->setShortcut (Qt::ALT + Qt::Key_X);
396 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
397 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
398 fileExportMenu->addAction (a);
400 a = new QAction( "Text (ASCII)...", this);
401 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
402 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
403 fileExportMenu->addAction (a);
405 a = new QAction( tr("KDE Bookmarks"), this);
406 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
407 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
408 fileExportMenu->addAction (a);
410 a = new QAction( "Taskjuggler...", this );
411 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
412 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
413 fileExportMenu->addAction (a);
415 a = new QAction( "LaTeX...", this);
416 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
417 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
418 fileExportMenu->addAction (a);
420 a = new QAction( "XML..." , this );
421 a->setStatusTip (tr( "Export as")+" XML");
422 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
423 fileExportMenu->addAction (a);
425 fileMenu->addSeparator();
427 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
428 a->setStatusTip ( tr( "Print" ) );
429 a->setShortcut (Qt::CTRL + Qt::Key_P );
431 fileMenu->addAction (a);
432 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
435 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
436 a->setStatusTip (tr( "Close Map" ) );
437 a->setShortcut (Qt::ALT + Qt::Key_C );
438 fileMenu->addAction (a);
439 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
441 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
442 a->setStatusTip ( tr( "Exit")+" "+__VYM );
443 a->setShortcut (Qt::CTRL + Qt::Key_Q );
444 fileMenu->addAction (a);
445 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
450 void Main::setupEditActions()
452 QToolBar *tb = addToolBar( tr ("&Edit") );
453 tb->setLabel( "Edit Actions" );
454 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
458 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
459 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
460 a->setStatusTip (tr( "Undo" ) );
461 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
462 a->setEnabled (false);
464 editMenu->addAction (a);
467 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
469 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
470 a->setStatusTip (tr( "Redo" ));
471 a->setShortcut (Qt::CTRL + Qt::Key_Y );
472 editMenu->addAction (a);
473 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
476 editMenu->addSeparator();
477 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
478 a->setStatusTip ( tr( "Copy" ) );
479 a->setShortcut (Qt::CTRL + Qt::Key_C );
480 a->setEnabled (false);
482 editMenu->addAction (a);
483 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
486 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
487 a->setStatusTip ( tr( "Cut" ) );
488 a->setShortcut (Qt::CTRL + Qt::Key_X );
489 a->setEnabled (false);
491 editMenu->addAction (a);
493 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
495 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
496 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
497 a->setStatusTip ( tr( "Paste" ) );
498 a->setShortcut ( Qt::CTRL + Qt::Key_V );
499 a->setEnabled (false);
501 editMenu->addAction (a);
504 // Shortcuts to modify heading:
505 a = new QAction(tr( "Edit heading" ),this);
506 a->setStatusTip ( tr( "edit Heading" ));
507 a->setShortcut ( Qt::Key_Enter);
508 a->setShortcutContext (Qt::WindowShortcut);
510 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
511 actionListBranches.append(a);
512 a = new QAction( tr( "Edit heading" ), this);
513 a->setStatusTip (tr( "edit Heading" ));
514 a->setShortcut (Qt::Key_Return );
515 a->setShortcutContext (Qt::WindowShortcut);
517 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
518 actionListBranches.append(a);
519 editMenu->addAction (a);
521 a = new QAction( tr( "Edit heading" ), this);
522 a->setStatusTip (tr( "edit Heading" ));
523 a->setShortcut ( Qt::Key_F2 );
524 a->setShortcutContext (Qt::WindowShortcut);
526 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
527 actionListBranches.append(a);
529 // Shortcut to delete selection
530 a = new QAction( tr( "Delete Selection" ),this);
531 a->setStatusTip (tr( "Delete Selection" ));
532 a->setShortcut ( Qt::Key_Delete);
533 a->setShortcutContext (Qt::WindowShortcut);
535 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
538 // Shortcut to add branch
539 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
540 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
541 alt->setShortcut (Qt::Key_A);
542 alt->setShortcutContext (Qt::WindowShortcut);
544 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
545 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
546 a->setStatusTip ( tr( "Add a branch as child of selection" ));
547 a->setShortcut (Qt::Key_Insert);
548 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
549 actionListBranches.append(a);
550 #if defined (Q_OS_MACX)
551 // In OSX show different shortcut in menues, the keys work indepently always
552 actionEditAddBranch=alt;
554 actionEditAddBranch=a;
556 editMenu->addAction (actionEditAddBranch);
557 tb->addAction (actionEditAddBranch);
560 // Add branch by inserting it at selection
561 a = new QAction(tr( "Add branch (insert)" ), this);
562 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
563 a->setShortcut (Qt::ALT + Qt::Key_Insert );
564 a->setShortcutContext (Qt::WindowShortcut);
566 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
567 a->setEnabled (false);
568 actionListBranches.append(a);
569 actionEditAddBranchHere=a;
570 a = new QAction(tr( "Add branch (insert)" ),this);
571 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
572 a->setShortcut ( Qt::ALT + Qt::Key_A );
573 a->setShortcutContext (Qt::WindowShortcut);
575 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
576 actionListBranches.append(a);
579 a = new QAction(tr( "Add branch above" ), this);
580 a->setStatusTip ( tr( "Add a branch above selection" ));
581 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
582 a->setShortcutContext (Qt::WindowShortcut);
584 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
585 a->setEnabled (false);
586 actionListBranches.append(a);
587 actionEditAddBranchAbove=a;
588 a = new QAction(tr( "Add branch above" ), this);
589 a->setStatusTip ( tr( "Add a branch above selection" ));
590 a->setShortcut (Qt::SHIFT+Qt::Key_A );
591 a->setShortcutContext (Qt::WindowShortcut);
593 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
594 actionListBranches.append(a);
597 a = new QAction(tr( "Add branch below" ), this);
598 a->setStatusTip ( tr( "Add a branch below selection" ));
599 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
600 a->setShortcutContext (Qt::WindowShortcut);
602 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
603 a->setEnabled (false);
604 actionListBranches.append(a);
605 actionEditAddBranchBelow=a;
606 a = new QAction(tr( "Add branch below" ), this);
607 a->setStatusTip ( tr( "Add a branch below selection" ));
608 a->setShortcut (Qt::CTRL +Qt::Key_A );
609 a->setShortcutContext (Qt::WindowShortcut);
611 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
612 actionListBranches.append(a);
614 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
615 a->setStatusTip ( tr( "Move branch up" ) );
616 a->setShortcut (Qt::Key_PageUp );
617 a->setEnabled (false);
619 editMenu->addAction (a);
620 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
623 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
624 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
625 a->setStatusTip (tr( "Move branch down" ) );
626 a->setShortcut ( Qt::Key_PageDown );
627 a->setEnabled (false);
629 editMenu->addAction (a);
630 actionEditMoveDown=a;
633 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
634 a->setShortcut ( Qt::Key_ScrollLock );
635 a->setStatusTip (tr( "Scroll branch" ) );
636 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
637 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
638 alt->setShortcut ( Qt::Key_S );
639 alt->setStatusTip (tr( "Scroll branch" ));
640 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
641 #if defined(Q_OS_MACX)
642 actionEditToggleScroll=alt;
644 actionEditToggleScroll=a;
646 actionEditToggleScroll->setEnabled (false);
647 actionEditToggleScroll->setToggleAction(true);
648 tb->addAction (actionEditToggleScroll);
649 editMenu->addAction ( actionEditToggleScroll);
650 editMenu->addAction (actionEditToggleScroll);
651 actionListBranches.append(actionEditToggleScroll);
653 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
654 a->setStatusTip (tr( "Unscroll all" ));
655 editMenu->addAction (a);
656 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
658 editMenu->addSeparator();
660 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
661 a->setStatusTip (tr( "Find" ) );
662 a->setShortcut (Qt::CTRL + Qt::Key_F );
663 editMenu->addAction (a);
664 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
666 editMenu->addSeparator();
668 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
669 a->setShortcut (Qt::CTRL + Qt::Key_U );
670 a->setShortcut (tr( "Open URL" ));
672 a->setEnabled (false);
673 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
676 a = new QAction( tr( "Open URL in new tab" ), this);
677 a->setStatusTip (tr( "Open URL in new tab" ));
678 a->setShortcut (Qt::CTRL+Qt::Key_U );
679 a->setEnabled (false);
680 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
681 actionEditOpenURLTab=a;
683 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
684 a->setStatusTip ( tr( "Edit URL" ) );
685 a->setShortcut (Qt::SHIFT + Qt::CTRL+Qt::Key_U );
686 a->setShortcutContext (Qt::WindowShortcut);
687 a->setEnabled (false);
688 actionListBranches.append(a);
689 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
692 a = new QAction( tr( "Use heading for URL" ), this);
693 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
694 a->setEnabled (false);
695 actionListBranches.append(a);
696 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
697 actionEditHeading2URL=a;
699 a = new QAction(tr( "Create URL to Bugzilla" ), this);
700 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
701 a->setEnabled (false);
702 actionListBranches.append(a);
703 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
704 actionEditBugzilla2URL=a;
706 a = new QAction(tr( "Create URL to FATE" ), this);
707 a->setStatusTip ( tr( "Create URL to FATE" ));
708 a->setEnabled (false);
709 actionListBranches.append(a);
710 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
711 actionEditFATE2URL=a;
713 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
714 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
716 a->setEnabled (false);
717 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
718 actionEditOpenVymLink=a;
720 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
721 a->setEnabled (false);
722 a->setStatusTip ( tr( "Edit link to another vym map" ));
723 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
724 actionListBranches.append(a);
727 a = new QAction(tr( "Delete vym link" ),this);
728 a->setStatusTip ( tr( "Delete link to another vym map" ));
729 a->setEnabled (false);
730 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
731 actionEditDeleteVymLink=a;
733 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
734 a->setStatusTip ( tr( "Hide object in exports" ) );
735 a->setShortcut (Qt::Key_H );
736 a->setToggleAction(true);
738 a->setEnabled (false);
739 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
740 actionEditToggleHideExport=a;
742 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
743 a->setStatusTip ( tr( "Edit Map Info" ));
744 a->setEnabled (true);
745 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
748 editMenu->addSeparator();
750 // Import at selection (adding to selection)
751 a = new QAction( tr( "Add map (insert)" ),this);
752 a->setStatusTip (tr( "Add map at selection" ));
753 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
754 a->setEnabled (false);
755 actionListBranches.append(a);
756 actionEditImportAdd=a;
758 // Import at selection (replacing selection)
759 a = new QAction( tr( "Add map (replace)" ), this);
760 a->setStatusTip (tr( "Replace selection with map" ));
761 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
762 a->setEnabled (false);
763 actionListBranches.append(a);
764 actionEditImportReplace=a;
767 a = new QAction( tr( "Save selection" ), this);
768 a->setStatusTip (tr( "Save selection" ));
769 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
770 a->setEnabled (false);
771 actionListBranches.append(a);
772 actionEditSaveBranch=a;
774 // Only remove branch, not its childs
775 a = new QAction(tr( "Remove only branch " ), this);
776 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
777 a->setShortcut (Qt::ALT + Qt::Key_Delete );
778 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
779 a->setEnabled (false);
780 actionListBranches.append(a);
781 actionEditRemoveBranchKeepChilds=a;
783 // Only remove childs of a branch
784 a = new QAction( tr( "Remove childs" ), this);
785 a->setStatusTip (tr( "Remove childs of branch" ));
786 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
787 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
788 a->setEnabled (false);
789 actionListBranches.append(a);
790 actionEditRemoveChilds=a;
792 // Shortcuts for navigating with cursor:
793 a = new QAction(tr( "Select upper branch" ), this);
794 a->setStatusTip ( tr( "Select upper branch" ));
795 a->setShortcut (Qt::Key_Up );
796 a->setShortcutContext (Qt::WindowShortcut);
798 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
799 a = new QAction( tr( "Select lower branch" ),this);
800 a->setStatusTip (tr( "Select lower branch" ));
801 a->setShortcut ( Qt::Key_Down );
802 a->setShortcutContext (Qt::WindowShortcut);
804 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
805 a = new QAction(tr( "Select left branch" ), this);
806 a->setStatusTip ( tr( "Select left branch" ));
807 a->setShortcut (Qt::Key_Left );
808 a->setShortcutContext (Qt::WindowShortcut);
810 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
811 a = new QAction( tr( "Select child branch" ), this);
812 a->setStatusTip (tr( "Select right branch" ));
813 a->setShortcut (Qt::Key_Right);
814 a->setShortcutContext (Qt::WindowShortcut);
816 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
817 a = new QAction( tr( "Select first branch" ), this);
818 a->setStatusTip (tr( "Select first branch" ));
819 a->setShortcut (Qt::Key_Home );
820 a->setShortcutContext (Qt::WindowShortcut);
822 a->setEnabled (false);
823 editMenu->addAction (a);
824 actionListBranches.append(a);
825 actionEditSelectFirst=a;
826 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
827 a = new QAction( tr( "Select last branch" ),this);
828 a->setStatusTip (tr( "Select last branch" ));
829 a->setShortcut ( Qt::Key_End );
830 a->setShortcutContext (Qt::WindowShortcut);
832 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
833 a->setEnabled (false);
834 editMenu->addAction (a);
835 actionListBranches.append(a);
836 actionEditSelectLast=a;
838 a = new QAction( tr( "Add Image" )+QString("..."), this);
839 a->setStatusTip (tr( "Add Image" ));
840 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
841 actionEditLoadImage=a;
846 void Main::setupFormatActions()
848 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
850 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
853 pix.fill (Qt::black);
854 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
855 a->setStatusTip ( tr( "Set Color" ));
856 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
858 formatMenu->addAction (a);
860 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
861 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
862 a->setShortcut (Qt::CTRL + Qt::Key_K );
863 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
864 a->setEnabled (false);
866 formatMenu->addAction (a);
867 actionListBranches.append(a);
868 actionFormatPickColor=a;
870 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
871 a->setStatusTip ( tr( "Color branch" ) );
872 a->setShortcut (Qt::CTRL + Qt::Key_I);
873 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
874 a->setEnabled (false);
876 formatMenu->addAction (a);
877 actionListBranches.append(a);
878 actionFormatColorBranch=a;
880 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
881 a->setStatusTip ( tr( "Color Subtree" ));
882 a->setShortcut (Qt::CTRL + Qt::Key_T);
883 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
884 a->setEnabled (false);
885 formatMenu->addAction (a);
887 actionListBranches.append(a);
888 actionFormatColorSubtree=a;
890 formatMenu->addSeparator();
891 actionGroupFormatLinkStyles=new QActionGroup ( this);
892 actionGroupFormatLinkStyles->setExclusive (true);
893 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
894 a->setStatusTip (tr( "Line" ));
895 a->setToggleAction(true);
896 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
897 formatMenu->addAction (a);
898 actionFormatLinkStyleLine=a;
899 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
900 a->setStatusTip (tr( "Line" ));
901 a->setToggleAction(true);
902 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
903 formatMenu->addAction (a);
904 actionFormatLinkStyleParabel=a;
905 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
906 a->setStatusTip (tr( "PolyLine" ));
907 a->setToggleAction(true);
908 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
909 formatMenu->addAction (a);
910 actionFormatLinkStylePolyLine=a;
911 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
912 a->setStatusTip (tr( "PolyParabel" ) );
913 a->setToggleAction(true);
914 a->setChecked (true);
915 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
916 formatMenu->addAction (a);
917 actionFormatLinkStylePolyParabel=a;
919 actionGroupFormatFrameTypes=new QActionGroup ( this);
920 actionGroupFormatFrameTypes->setExclusive (true);
921 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
922 a->setStatusTip (tr("No Frame"));
923 a->setToggleAction(true);
924 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
925 actionFormatFrameNone=a;
926 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
927 a->setStatusTip (tr( "Rectangle" ));
928 a->setToggleAction(true);
929 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
930 actionFormatFrameRectangle=a;
932 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
933 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
934 a->setToggleAction(true);
935 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
936 actionFormatIncludeImagesVer=a;
938 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
939 a->setStatusTip ( tr ("Include left and right position of images into branch"));
940 a->setToggleAction(true);
941 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
942 actionFormatIncludeImagesHor=a;
944 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
945 a->setStatusTip (tr( "Hide link" ));
946 a->setToggleAction(true);
947 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
948 actionFormatHideLinkUnselected=a;
950 formatMenu->addSeparator();
951 a= new QAction( tr( "&Use color of heading for link" ), this);
952 a->setStatusTip (tr( "Use same color for links and headings" ));
953 a->setToggleAction(true);
954 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
955 formatMenu->addAction (a);
956 actionFormatLinkColorHint=a;
958 pix.fill (Qt::white);
959 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
960 a->setStatusTip (tr( "Set Link Color" ));
961 formatMenu->addAction (a);
962 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
963 actionFormatLinkColor=a;
965 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
966 a->setStatusTip (tr( "Set Background Color" ));
967 formatMenu->addAction (a);
968 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
969 actionFormatBackColor=a;
973 void Main::setupViewActions()
975 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
976 tb->setLabel( "View Actions" );
977 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
980 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
981 a->setStatusTip ( tr( "Zoom reset" ) );
982 a->setShortcut (Qt::CTRL + Qt::Key_0 );
984 viewMenu->addAction (a);
985 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
987 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
988 a->setStatusTip (tr( "Zoom in" ));
989 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
991 viewMenu->addAction (a);
992 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
994 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
995 a->setStatusTip (tr( "Zoom out" ));
996 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
998 viewMenu->addAction (a);
999 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
1002 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1003 a->setStatusTip ( tr( "Show Note Editor" ));
1004 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1005 a->setToggleAction(true);
1006 if (textEditor->showWithMain())
1011 viewMenu->addAction (a);
1012 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
1013 actionViewToggleNoteEditor=a;
1015 a = new QAction( tr( "Show history window" ),this );
1016 a->setStatusTip ( tr( "Show history window" ));
1017 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1018 a->setToggleAction(false);
1019 viewMenu->addAction (a);
1020 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
1021 actionViewToggleHistoryWindow=a;
1023 a = new QAction(tr( "Next Window" ), this);
1024 a->setStatusTip ( tr( "&Next Window" ) );
1025 a->setShortcut (Qt::ALT + Qt::Key_N );
1026 viewMenu->addAction (a);
1027 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
1029 a = new QAction (tr( "Previous Window" ), this );
1030 a->setStatusTip (tr( "&Previous Window" ));
1031 a->setShortcut (Qt::ALT + Qt::Key_P );
1032 viewMenu->addAction (a);
1033 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
1037 void Main::setupModeActions()
1039 //QPopupMenu *menu = new QPopupMenu( this );
1040 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1042 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1044 actionGroupModModes=new QActionGroup ( this);
1045 actionGroupModModes->setExclusive (true);
1046 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1047 a->setShortcut (Qt::Key_J);
1048 a->setStatusTip ( tr( "Use modifier to color branches" ));
1049 a->setToggleAction(true);
1052 actionModModeColor=a;
1054 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1055 a->setShortcut( Qt::Key_K);
1056 a->setStatusTip( tr( "Use modifier to copy" ));
1057 a->setToggleAction(true);
1059 actionModModeCopy=a;
1061 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1062 a->setShortcut (Qt::Key_L);
1063 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1064 a->setToggleAction(true);
1066 actionModModeLink=a;
1070 void Main::setupFlagActions()
1072 // Create System Flags
1073 systemFlagsDefault = new FlagRowObj ();
1074 systemFlagsDefault->setVisibility (false);
1075 systemFlagsDefault->setName ("systemFlagsDef");
1077 FlagObj *fo = new FlagObj ();
1078 fo->load(QPixmap(flagsPath+"flag-note.png"));
1079 fo->setName("note");
1080 fo->setToolTip(tr("Note","Systemflag"));
1081 systemFlagsDefault->addFlag (fo); // makes deep copy
1083 fo->load(QPixmap(flagsPath+"flag-url.png"));
1085 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1086 systemFlagsDefault->addFlag (fo);
1088 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1089 fo->setName("vymLink");
1090 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1091 systemFlagsDefault->addFlag (fo);
1093 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1094 fo->setName("scrolledright");
1095 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1096 systemFlagsDefault->addFlag (fo);
1098 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1099 fo->setName("tmpUnscrolledright");
1100 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1101 systemFlagsDefault->addFlag (fo);
1103 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1104 fo->setName("hideInExport");
1105 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1106 systemFlagsDefault->addFlag (fo);
1108 // Create Standard Flags
1109 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1111 standardFlagsDefault = new FlagRowObj ();
1112 standardFlagsDefault->setVisibility (false);
1113 standardFlagsDefault->setName ("standardFlagsDef");
1114 standardFlagsDefault->setToolBar (tb);
1116 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1117 fo->setName ("exclamationmark");
1118 fo->setGroup("standard-mark");
1119 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1122 a->setCheckable(true);
1123 a->setObjectName(fo->getName());
1124 a->setToolTip(tr("Take care!","Standardflag"));
1125 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1126 standardFlagsDefault->addFlag (fo); // makes deep copy
1128 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1129 fo->setName("questionmark");
1130 fo->setGroup("standard-mark");
1131 a=new QAction (fo->getPixmap(),fo->getName(),this);
1134 a->setCheckable(true);
1135 a->setObjectName(fo->getName());
1136 a->setToolTip(tr("Really?","Standardflag"));
1137 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1138 standardFlagsDefault->addFlag (fo);
1140 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1141 fo->setName("hook-green");
1142 fo->setGroup("standard-hook");
1143 a=new QAction (fo->getPixmap(),fo->getName(),this);
1146 a->setCheckable(true);
1147 a->setObjectName(fo->getName());
1148 a->setToolTip(tr("ok!","Standardflag"));
1149 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1150 standardFlagsDefault->addFlag (fo);
1152 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1153 fo->setName("cross-red");
1154 fo->setGroup("standard-hook");
1155 a=new QAction (fo->getPixmap(),fo->getName(),this);
1158 a->setCheckable(true);
1159 a->setObjectName(fo->getName());
1160 a->setToolTip(tr("Not ok!","Standardflag"));
1161 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1162 standardFlagsDefault->addFlag (fo);
1164 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1165 fo->setName("stopsign");
1166 a=new QAction (fo->getPixmap(),fo->getName(),this);
1169 a->setCheckable(true);
1170 a->setObjectName(fo->getName());
1171 a->setToolTip(tr("This won't work!","Standardflag"));
1172 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1173 standardFlagsDefault->addFlag (fo);
1175 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1176 fo->setName("smiley-good");
1177 fo->setGroup("standard-smiley");
1178 a=new QAction (fo->getPixmap(),fo->getName(),this);
1181 a->setCheckable(true);
1182 a->setObjectName(fo->getName());
1183 a->setToolTip(tr("Good","Standardflag"));
1184 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1185 standardFlagsDefault->addFlag (fo);
1187 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1188 fo->setName("smiley-sad");
1189 fo->setGroup("standard-smiley");
1190 a=new QAction (fo->getPixmap(),fo->getName(),this);
1193 a->setCheckable(true);
1194 a->setObjectName(fo->getName());
1195 a->setToolTip(tr("Bad","Standardflag"));
1196 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1197 standardFlagsDefault->addFlag (fo);
1199 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1200 // Original omg.png (in KDE emoticons)
1201 fo->setName("smiley-omg");
1202 fo->setGroup("standard-smiley");
1203 a=new QAction (fo->getPixmap(),fo->getName(),this);
1206 a->setCheckable(true);
1207 a->setObjectName(fo->getName());
1208 a->setToolTip(tr("Oh no!","Standardflag"));
1209 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1210 standardFlagsDefault->addFlag (fo);
1212 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1213 fo->setName("clock");
1214 a=new QAction (fo->getPixmap(),fo->getName(),this);
1217 a->setCheckable(true);
1218 a->setObjectName(fo->getName());
1219 a->setToolTip(tr("Time critical","Standardflag"));
1220 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1221 standardFlagsDefault->addFlag (fo);
1223 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1224 fo->setName("phone");
1225 a=new QAction (fo->getPixmap(),fo->getName(),this);
1228 a->setCheckable(true);
1229 a->setObjectName(fo->getName());
1230 a->setToolTip(tr("Call...","Standardflag"));
1231 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1232 standardFlagsDefault->addFlag (fo);
1234 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1235 fo->setName("lamp");
1236 a=new QAction (fo->getPixmap(),fo->getName(),this);
1239 a->setCheckable(true);
1240 a->setObjectName(fo->getName());
1241 a->setToolTip(tr("Idea!","Standardflag"));
1242 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1243 standardFlagsDefault->addFlag (fo);
1245 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1246 fo->setName("arrow-up");
1247 fo->setGroup("standard-arrow");
1248 a=new QAction (fo->getPixmap(),fo->getName(),this);
1251 a->setCheckable(true);
1252 a->setObjectName(fo->getName());
1253 a->setToolTip(tr("Important","Standardflag"));
1254 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1255 standardFlagsDefault->addFlag (fo);
1257 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1258 fo->setName("arrow-down");
1259 fo->setGroup("standard-arrow");
1260 a=new QAction (fo->getPixmap(),fo->getName(),this);
1263 a->setCheckable(true);
1264 a->setObjectName(fo->getName());
1265 a->setToolTip(tr("Unimportant","Standardflag"));
1266 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1267 standardFlagsDefault->addFlag (fo);
1269 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1270 fo->setName("2arrow-up");
1271 fo->setGroup("standard-arrow");
1272 a=new QAction (fo->getPixmap(),fo->getName(),this);
1275 a->setCheckable(true);
1276 a->setObjectName(fo->getName());
1277 a->setToolTip(tr("Very important!","Standardflag"));
1278 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1279 standardFlagsDefault->addFlag (fo);
1281 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1282 fo->setName("2arrow-down");
1283 fo->setGroup("standard-arrow");
1284 a=new QAction (fo->getPixmap(),fo->getName(),this);
1287 a->setCheckable(true);
1288 a->setObjectName(fo->getName());
1289 a->setToolTip(tr("Very unimportant!","Standardflag"));
1290 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1291 standardFlagsDefault->addFlag (fo);
1293 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1294 fo->setName("thumb-up");
1295 fo->setGroup("standard-thumb");
1296 a=new QAction (fo->getPixmap(),fo->getName(),this);
1299 a->setCheckable(true);
1300 a->setObjectName(fo->getName());
1301 a->setToolTip(tr("I like this","Standardflag"));
1302 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1303 standardFlagsDefault->addFlag (fo);
1305 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1306 fo->setName("thumb-down");
1307 fo->setGroup("standard-thumb");
1308 a=new QAction (fo->getPixmap(),fo->getName(),this);
1311 a->setCheckable(true);
1312 a->setObjectName(fo->getName());
1313 a->setToolTip(tr("I do not like this","Standardflag"));
1314 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1315 standardFlagsDefault->addFlag (fo);
1317 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1318 fo->setName("rose");
1319 a=new QAction (fo->getPixmap(),fo->getName(),this);
1322 a->setCheckable(true);
1323 a->setObjectName(fo->getName());
1324 a->setToolTip(tr("Rose","Standardflag"));
1325 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1326 standardFlagsDefault->addFlag (fo);
1328 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1329 fo->setName("heart");
1330 a=new QAction (fo->getPixmap(),fo->getName(),this);
1332 a->setCheckable(true);
1333 a->setObjectName(fo->getName());
1334 a->setToolTip(tr("I just love... ","Standardflag"));
1335 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1336 standardFlagsDefault->addFlag (fo);
1338 fo->load(QPixmap(flagsPath+"flag-present.png"));
1339 fo->setName("present");
1340 a=new QAction (fo->getPixmap(),fo->getName(),this);
1343 a->setCheckable(true);
1344 a->setObjectName(fo->getName());
1345 a->setToolTip(tr("Surprise!","Standardflag"));
1346 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1347 standardFlagsDefault->addFlag (fo);
1349 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1350 fo->setName("flash");
1351 a=new QAction (fo->getPixmap(),fo->getName(),this);
1354 a->setCheckable(true);
1355 a->setObjectName(fo->getName());
1356 a->setToolTip(tr("Dangerous","Standardflag"));
1357 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1358 standardFlagsDefault->addFlag (fo);
1360 fo->load(QPixmap(flagsPath+"flag-info.png"));
1361 // Original: xsldbg_output.png
1362 fo->setName("info");
1363 a=new QAction (fo->getPixmap(),fo->getName(),this);
1366 a->setCheckable(true);
1367 a->setObjectName(fo->getName());
1368 a->setToolTip(tr("Info","Standardflag"));
1369 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1370 standardFlagsDefault->addFlag (fo);
1372 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1373 // Original khelpcenter.png
1374 fo->setName("lifebelt");
1375 a=new QAction (fo->getPixmap(),fo->getName(),this);
1378 a->setCheckable(true);
1379 a->setObjectName(fo->getName());
1380 a->setToolTip(tr("This will help","Standardflag"));
1381 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1382 standardFlagsDefault->addFlag (fo);
1388 void Main::setupSettingsActions()
1390 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1394 a = new QAction( tr( "Set application to open pdf files"), this);
1395 a->setStatusTip ( tr( "Set application to open pdf files"));
1396 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1397 settingsMenu->addAction (a);
1399 a = new QAction( tr( "Set application to open external links"), this);
1400 a->setStatusTip( tr( "Set application to open external links"));
1401 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1402 settingsMenu->addAction (a);
1404 settingsMenu->addSeparator();
1405 a = new QAction( tr( "Edit branch after adding it" ), this );
1406 a->setStatusTip( tr( "Edit branch after adding it" ));
1407 a->setToggleAction(true);
1408 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1409 settingsMenu->addAction (a);
1410 actionSettingsAutoedit=a;
1412 a= new QAction( tr( "Select branch after adding it" ), this );
1413 a->setStatusTip( tr( "Select branch after adding it" ));
1414 a->setToggleAction(true);
1415 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1416 settingsMenu->addAction (a);
1417 actionSettingsAutoselectHeading=a;
1419 a= new QAction(tr( "Select existing heading" ), this);
1420 a->setStatusTip( tr( "Select heading before editing" ));
1421 a->setToggleAction(true);
1422 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1423 settingsMenu->addAction (a);
1424 actionSettingsAutoselectText=a;
1426 a= new QAction(tr( "pasting into new branch" ), this );
1427 a->setStatusTip( tr( "Pasting into new branch" ));
1428 a->setToggleAction(true);
1429 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1430 settingsMenu->addAction (a);
1431 actionSettingsPasteNewHeading=a;
1433 a= new QAction( tr( "Delete key" ), this);
1434 a->setStatusTip( tr( "Delete key for deleting branches" ));
1435 a->setToggleAction(true);
1436 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1437 settingsMenu->addAction (a);
1438 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1439 actionSettingsUseDelKey=a;
1441 a= new QAction( tr( "Exclusive flags" ), this);
1442 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1443 a->setToggleAction(true);
1444 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1445 settingsMenu->addAction (a);
1446 actionSettingsUseFlagGroups=a;
1448 a= new QAction( tr( "Use hide flags" ), this);
1449 a->setStatusTip( tr( "Use hide flag during exports " ));
1450 a->setToggleAction(true);
1451 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1452 settingsMenu->addAction (a);
1453 actionSettingsUseHideExport=a;
1457 void Main::setupTestActions()
1459 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1462 a = new QAction( tr( "test flag" ), this);
1463 a->setStatusTip( tr( "Call test function" ));
1464 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1465 testMenu->addAction (a);
1469 void Main::setupHelpActions()
1471 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1474 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1475 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1476 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1477 helpMenu->addAction (a);
1479 a = new QAction( tr( "About VYM" ), this);
1480 a->setStatusTip( tr( "About VYM")+" "__VYM);
1481 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1482 helpMenu->addAction (a);
1484 a = new QAction( tr( "About QT" ), this);
1485 a->setStatusTip( tr( "Information about QT toolkit" ));
1486 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1487 helpMenu->addAction (a);
1491 void Main::setupContextMenus()
1495 // Context Menu for branch or mapcenter
1496 branchContextMenu =new QMenu (this);
1499 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1500 branchAddContextMenu->addAction (actionEditPaste );
1501 branchAddContextMenu->addAction ( actionEditAddBranch );
1502 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1503 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1504 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1505 branchAddContextMenu->addSeparator();
1506 branchAddContextMenu->addAction ( actionEditLoadImage);
1507 branchAddContextMenu->addSeparator();
1508 branchAddContextMenu->addAction ( actionEditLoadImage);
1509 branchAddContextMenu->addAction ( actionEditImportAdd );
1510 branchAddContextMenu->addAction ( actionEditImportReplace );
1513 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1514 branchRemoveContextMenu->addAction (actionEditCut);
1515 branchRemoveContextMenu->addAction ( actionEditDelete );
1516 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1517 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1520 actionEditSaveBranch->addTo( branchContextMenu );
1522 branchContextMenu->addSeparator();
1523 branchContextMenu->addAction ( actionEditOpenURL );
1524 branchContextMenu->addAction ( actionEditOpenURLTab );
1525 branchContextMenu->addAction ( actionEditURL );
1526 branchContextMenu->addAction ( actionEditHeading2URL );
1527 branchContextMenu->addAction ( actionEditBugzilla2URL );
1528 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1530 branchContextMenu->addAction ( actionEditFATE2URL );
1532 branchContextMenu->addSeparator();
1533 branchContextMenu->addAction ( actionEditOpenVymLink );
1534 branchContextMenu->addAction ( actionEditVymLink );
1535 branchContextMenu->addAction ( actionEditDeleteVymLink );
1537 branchContextMenu->addSeparator();
1538 branchContextMenu->addAction ( actionFormatFrameNone );
1539 branchContextMenu->addAction ( actionFormatFrameRectangle);
1541 branchContextMenu->addSeparator();
1542 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1543 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1544 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1546 // Context Menu for links in a branch menu
1547 // This will be populated "on demand" in MapEditor::updateActions
1548 branchContextMenu->addSeparator();
1549 branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1550 branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1551 connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1552 connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1554 // Context menu for floatimage
1555 floatimageContextMenu =new QMenu (this);
1556 saveImageFormatMenu=floatimageContextMenu->addMenu (tr("Save image"));
1558 foreach (QByteArray format, QImageWriter::supportedImageFormats())
1560 QString text = tr("%1...").arg(QString(format).toUpper());
1561 a= new QAction (text,this);
1562 saveImageFormatMenu->addAction ( a );
1565 floatimageContextMenu->addSeparator();
1566 actionEditCopy->addTo( floatimageContextMenu );
1567 actionEditCut->addTo( floatimageContextMenu );
1569 floatimageContextMenu->addSeparator();
1570 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1573 // Context menu for canvas
1574 canvasContextMenu =new QMenu (this);
1575 actionEditMapInfo->addTo( canvasContextMenu );
1576 canvasContextMenu->insertSeparator();
1577 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1578 canvasContextMenu->insertSeparator();
1579 actionFormatLinkColorHint->addTo( canvasContextMenu );
1580 actionFormatLinkColor->addTo( canvasContextMenu );
1581 actionFormatBackColor->addTo( canvasContextMenu );
1583 // Menu for last opened files
1584 // Read settings initially
1586 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1587 for (int i=1;i<=j;i++)
1589 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1590 if (!s.isEmpty() && j<=maxLastMaps)
1593 setupLastMapsMenu();
1594 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1597 void Main::setupLastMapsMenu()
1599 // Remove double entries
1600 QStringList::Iterator it=lastMaps.begin();
1601 QStringList::Iterator jt;
1602 while (it!=lastMaps.end() )
1606 while (jt!=lastMaps.end() )
1609 jt=lastMaps.remove(jt);
1616 // Limit length of list to maxLastMaps
1617 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1619 // build Menu from lastMaps string list
1620 fileLastMapsMenu->clear();
1621 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1622 fileLastMapsMenu->addAction (*it );
1625 void Main::hideEvent (QHideEvent * )
1627 if (!textEditor->isMinimized() ) textEditor->hide();
1630 void Main::showEvent (QShowEvent * )
1632 if (textEditor->showWithMain()) textEditor->showNormal();
1635 bool Main::reallyWriteDirectory(const QString &dir)
1637 QStringList eList = QDir(dir).entryList();
1638 if (eList.first() ==".") eList.pop_front(); // remove "."
1639 if (eList.first() =="..") eList.pop_front(); // remove "."
1640 if (!eList.isEmpty())
1642 QMessageBox mb( __VYM,
1643 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1644 QMessageBox::Warning,
1646 QMessageBox::Cancel | QMessageBox::Default,
1647 QMessageBox::QMessageBox::NoButton );
1649 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1650 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1653 case QMessageBox::Yes:
1656 case QMessageBox::Cancel:
1664 QString Main::browseDirectory (const QString &caption)
1666 Q3FileDialog fd(this,caption);
1667 fd.setMode (Q3FileDialog::DirectoryOnly);
1668 fd.setCaption(__VYM " - "+caption);
1671 if ( fd.exec() == QDialog::Accepted )
1672 return fd.selectedFile();
1677 MapEditor* Main::currentMapEditor() const
1679 if ( tabWidget->currentPage() &&
1680 tabWidget->currentPage()->inherits( "MapEditor" ) )
1681 return (MapEditor*)tabWidget->currentPage();
1685 //TODO not used now, maybe use this for overview window later
1686 void Main::newView()
1688 // Open a new view... have it delete when closed.
1689 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1690 qApp->setMainWidget(m);
1692 qApp->setMainWidget(0);
1695 void Main::editorChanged(QWidget *)
1697 // Unselect all possibly selected objects
1698 // (Important to update note editor)
1701 for (i=0;i<=tabWidget->count() -1;i++)
1704 me=(MapEditor*)tabWidget->page(i);
1707 currentMapEditor()->reselect();
1709 // Update actions to in menus and toolbars according to editor
1710 currentMapEditor()->updateActions();
1713 void Main::fileNew()
1715 QString fn="unnamed";
1716 MapEditor* medit = new MapEditor ( NULL,true);
1717 tabWidget->addTab (medit,fn);
1718 tabWidget->showPage(medit);
1719 medit->viewport()->setFocus();
1720 // For the very first map we do not have flagrows yet...
1721 medit->select("mc:");
1724 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1726 ErrorCode err=success;
1728 // fn is usually the archive, mapfile the file after uncompressing
1731 // Make fn absolute (needed for unzip)
1732 fn=QDir (fn).absPath();
1738 // Check, if map is already loaded
1740 while (i<=tabWidget->count() -1)
1742 me=(MapEditor*)tabWidget->page(i);
1743 if (me->getFilePath() == fn)
1745 // Already there, ask for confirmation
1746 QMessageBox mb( __VYM,
1747 tr("The map %1\nis already opened."
1748 "Opening the same map in multiple editors may lead \n"
1749 "to confusion when finishing working with vym."
1750 "Do you want to").arg(fn),
1751 QMessageBox::Warning,
1752 QMessageBox::Yes | QMessageBox::Default,
1753 QMessageBox::Cancel | QMessageBox::Escape,
1754 QMessageBox::NoButton);
1755 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1756 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1759 case QMessageBox::Yes:
1761 i=tabWidget->count();
1763 case QMessageBox::Cancel:
1775 if ( !fn.isEmpty() )
1777 me = currentMapEditor();
1778 int tabIndex=tabWidget->currentPageIndex();
1779 // Check first, if mapeditor exists
1780 // If it is not default AND we want a new map,
1781 // create a new mapeditor in a new tab
1782 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1784 me= new MapEditor ( NULL,true);
1785 tabWidget->addTab (me,fn);
1786 tabIndex=tabWidget->indexOf (me);
1787 tabWidget->setCurrentPage (tabIndex);
1790 // Check, if file exists (important for creating new files
1791 // from command line
1792 if (!QFile(fn).exists() )
1794 QMessageBox mb( __VYM,
1795 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1796 QMessageBox::Question,
1798 QMessageBox::Cancel | QMessageBox::Default,
1799 QMessageBox::NoButton );
1801 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1802 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1805 case QMessageBox::Yes:
1807 currentMapEditor()->setFilePath(fn);
1808 tabWidget->setTabLabel (currentMapEditor(),
1809 currentMapEditor()->getFileName() );
1810 statusBar()->message( "Created " + fn , statusbarTime );
1813 case QMessageBox::Cancel:
1814 // don't create new map
1815 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1822 //tabWidget->currentPage() won't be NULL here, because of above...
1823 tabWidget->showPage(me);
1824 me->viewport()->setFocus();
1826 // Create temporary directory for packing
1827 char tmpdir1[]="/tmp/vym-XXXXXX";
1828 QString tmpMapDir=mkdtemp(tmpdir1);
1830 // Try to unzip file
1831 err=unzipDir (tmpMapDir,fn);
1835 me->setZipped(false);
1838 me->setZipped(true);
1840 // Look for mapname.xml
1841 mapfile= fn.left(fn.findRev(".",-1,true));
1842 mapfile=mapfile.section( '/', -1 );
1843 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1844 if (!file.exists() )
1846 // mapname.xml does not exist, well,
1847 // maybe some renamed the mapname.vym file...
1848 // Try to find any .xml in the toplevel
1849 // directory of the .vym file
1850 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1851 if (flist.count()==1)
1853 // Only one entry, take this one
1854 mapfile=tmpMapDir + "/"+flist.first();
1857 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1858 *it=tmpMapDir + "/" + *it;
1859 // TODO Multiple entries, load all (but only the first one into this ME)
1860 //mainWindow->fileLoadFromTmp (flist);
1861 //returnCode=1; // Silently forget this attempt to load
1862 qWarning ("MainWindow::load (fn) multimap found...");
1865 if (flist.isEmpty() )
1867 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1868 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1871 } //file doesn't exist
1873 mapfile=file.name();
1878 // Save existing filename in case we import
1879 QString fn_org=me->getFilePath();
1881 // Finally load map into mapEditor
1882 me->setFilePath (mapfile,fn);
1883 err=me->load(mapfile,lmode);
1885 // Restore old (maybe empty) filepath, if this is an import
1887 me->setFilePath (fn_org);
1890 // Finally check for errors and go home
1893 if (lmode==NewMap) fileCloseMap();
1894 statusBar()->message( "Could not load " + fn, statusbarTime );
1899 me->setFilePath (fn);
1900 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1901 if (fn.left(9)!="/tmp/vym-")
1903 // Only append to lastMaps if not loaded from a tmpDir
1904 // e.g. imported bookmarks are in a tmpDir
1905 lastMaps.prepend(me->getFilePath() );
1906 setupLastMapsMenu();
1908 actionFilePrint->setEnabled (true);
1910 statusBar()->message( "Loaded " + fn, statusbarTime );
1914 removeDir (QDir(tmpMapDir));
1920 void Main::fileLoad(const LoadMode &lmode)
1922 Q3FileDialog *fd=new Q3FileDialog( this);
1923 if (!lastFileDir.isEmpty())
1924 fd->setDir (lastFileDir);
1925 fd->setMode (Q3FileDialog::ExistingFiles);
1926 fd->addFilter ("XML (*.xml)");
1927 fd->addFilter ("VYM map (*.vym *.vyp)");
1931 fd->setCaption(tr("Load vym map"));
1934 fd->setCaption(tr("Import: Add vym map to selection"));
1937 fd->setCaption(tr("Import: Replace selection with vym map"));
1943 if ( fd->exec() == QDialog::Accepted )
1945 lastFileDir=fd->dirPath();
1946 QStringList flist = fd->selectedFiles();
1947 QStringList::Iterator it = flist.begin();
1948 while( it != flist.end() )
1951 fileLoad(*it, lmode);
1958 void Main::fileLoad()
1963 void Main::fileLoadLast(QAction *a)
1965 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1968 void Main::fileSave(const SaveMode &savemode)
1970 // tmp dir for zipping
1974 ErrorCode err=success;
1976 QString safeFilePath;
1978 bool saveZipped=currentMapEditor()->saveZipped();
1980 MapEditor * me=currentMapEditor();
1983 QString fn=me->getFilePath();
1984 // filename=unnamed, filepath="" in constructor...
1985 if ( !fn.isEmpty() )
1987 // We have a filepath, go on saving
1988 // First remove existing file, we
1989 // don't want to add to old zip archives
1993 QMessageBox::warning( 0, tr( "Save Error" ),
1994 fn+ tr("\ncould not be removed before saving"));
1996 // Look, if we should zip the data:
1999 QMessageBox mb( __VYM,
2000 tr("The map %1\ndid not use the compressed "
2001 "vym file format.\nWriting it uncompressed will also write images \n"
2002 "and flags and thus may overwrite files in the "
2003 "given directory\n\nDo you want to write the map").arg(fn),
2004 QMessageBox::Warning,
2005 QMessageBox::Yes | QMessageBox::Default,
2007 QMessageBox::Cancel | QMessageBox::Escape);
2008 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2009 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2010 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2013 case QMessageBox::Yes:
2014 // save compressed (default file format)
2017 case QMessageBox::No:
2018 // save uncompressed
2021 case QMessageBox::Cancel:
2030 char tmpdir1[]="/tmp/vym-XXXXXX";
2031 tmpMapDir=mkdtemp(tmpdir1);
2033 safeFilePath=me->getFilePath();
2034 me->setFilePath (tmpMapDir+"/"+
2035 me->getMapName()+ ".xml",
2037 me->save (savemode);
2038 me->setFilePath (safeFilePath);
2040 zipDir (tmpMapDir,fn);
2045 safeFilePath=me->getFilePath();
2046 me->setFilePath (fn, safeFilePath);
2047 me->save (savemode);
2048 me->setFilePath (safeFilePath);
2050 } // filepath available
2053 // We have no filepath yet,
2054 // call fileSaveAs() now, this will call fileSave()
2056 fileSaveAs(savemode);
2060 if (saveZipped && !tmpMapDir.isEmpty())
2062 removeDir (QDir(tmpMapDir));
2066 statusBar()->message(
2067 tr("Saved %1").arg(me->getFilePath()),
2069 lastMaps.prepend(me->getFilePath() );
2070 setupLastMapsMenu();
2072 statusBar()->message(
2073 tr("Couldn't save ").arg(me->getFilePath()),
2077 void Main::fileSave()
2079 fileSave (CompleteMap);
2082 void Main::fileSaveAs(const SaveMode& savemode)
2086 if (currentMapEditor())
2088 if (savemode==CompleteMap)
2089 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2091 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2092 if ( !fn.isEmpty() )
2094 // Check for existing file
2095 if (QFile (fn).exists())
2097 QMessageBox mb( __VYM,
2098 tr("The file %1\nexists already. Do you want to").arg(fn),
2099 QMessageBox::Warning,
2100 QMessageBox::Yes | QMessageBox::Default,
2101 QMessageBox::Cancel | QMessageBox::Escape,
2102 QMessageBox::NoButton);
2103 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2104 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2107 case QMessageBox::Yes:
2110 case QMessageBox::Cancel:
2117 // New file, add extension to filename, if missing
2118 // This is always .vym or .vyp, depending on savemode
2119 if (savemode==CompleteMap)
2121 if (!fn.contains (".vym") && !fn.contains (".xml"))
2125 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2134 currentMapEditor()->setFilePath(fn);
2138 if (savemode==CompleteMap)
2139 tabWidget->setTabLabel (currentMapEditor(),
2140 currentMapEditor()->getFileName() );
2146 void Main::fileSaveAs()
2148 fileSaveAs (CompleteMap);
2151 void Main::fileImportKDEBookmarks()
2153 ImportKDEBookmarks im;
2155 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2156 currentMapEditor()->setFilePath ("");
2159 void Main::fileImportFirefoxBookmarks()
2161 Q3FileDialog *fd=new Q3FileDialog( this);
2162 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2163 fd->setMode (Q3FileDialog::ExistingFiles);
2164 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2165 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2168 if ( fd->exec() == QDialog::Accepted )
2170 ImportFirefoxBookmarks im;
2171 QStringList flist = fd->selectedFiles();
2172 QStringList::Iterator it = flist.begin();
2173 while( it != flist.end() )
2176 if (im.transform() &&
2177 success==fileLoad (im.getTransformedFile(),NewMap) &&
2178 currentMapEditor() )
2179 currentMapEditor()->setFilePath ("");
2186 void Main::fileImportMM()
2190 Q3FileDialog *fd=new Q3FileDialog( this);
2191 if (!lastFileDir.isEmpty())
2192 fd->setDir (lastFileDir);
2193 fd->setMode (Q3FileDialog::ExistingFiles);
2194 fd->addFilter ("Mind Manager (*.mmap)");
2195 fd->setCaption(tr("Import")+" "+"Mind Manager");
2198 if ( fd->exec() == QDialog::Accepted )
2200 lastFileDir=fd->dirPath();
2201 QStringList flist = fd->selectedFiles();
2202 QStringList::Iterator it = flist.begin();
2203 while( it != flist.end() )
2206 if (im.transform() &&
2207 success==fileLoad (im.getTransformedFile(),NewMap) &&
2208 currentMapEditor() )
2209 currentMapEditor()->setFilePath ("");
2218 void Main::fileImportDir()
2220 if (currentMapEditor())
2221 currentMapEditor()->importDir();
2224 void Main::fileExportXML()
2226 if (currentMapEditor())
2228 QString dir=browseDirectory(tr("Export XML to directory"));
2229 if (dir !="" && reallyWriteDirectory(dir) )
2230 currentMapEditor()->exportXML(dir);
2235 void Main::fileExportXHTML()
2237 MapEditor *me=currentMapEditor();
2241 ExportXHTMLDialog dia(this);
2242 dia.setFilePath (me->getFilePath() );
2243 dia.setMapName (me->getMapName() );
2246 if (dia.exec()==QDialog::Accepted)
2248 QString dir=dia.getDir();
2249 // Check, if warnings should be used before overwriting
2250 // the output directory
2253 ok=reallyWriteDirectory(dir);
2259 me->exportXML (dia.getDir() );
2260 dia.doExport(me->getMapName() );
2261 if (dia.hasChanged())
2268 void Main::fileExportImage()
2270 MapEditor *me=currentMapEditor();
2274 QFileDialog *fd=new QFileDialog (this);
2275 fd->setCaption (tr("Export map as image"));
2276 fd->setFileMode(QFileDialog::AnyFile);
2277 fd->setFilters (imageIO.getFilters() );
2278 fd->setDirectory (lastImageDir);
2281 fl=fd->selectedFiles();
2282 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2283 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2288 void Main::fileExportASCII()
2290 MapEditor *me=currentMapEditor();
2294 ex.setMapCenter(me->getMapCenter());
2295 ex.addFilter ("TXT (*.txt)");
2296 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2297 if (ex.execDialog() )
2299 me->setExportMode(true);
2301 me->setExportMode(false);
2306 void Main::fileExportLaTeX()
2308 MapEditor *me=currentMapEditor();
2312 ex.setMapCenter(me->getMapCenter());
2313 ex.addFilter ("Tex (*.tex)");
2314 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2315 if (ex.execDialog() )
2317 me->setExportMode(true);
2319 me->setExportMode(false);
2324 void Main::fileExportKDEBookmarks()
2326 ExportKDEBookmarks ex;
2327 MapEditor *me=currentMapEditor();
2330 ex.setMapCenter (me->getMapCenter() );
2335 void Main::fileExportTaskjuggler()
2337 ExportTaskjuggler ex;
2338 MapEditor *me=currentMapEditor();
2341 ex.setMapCenter (me->getMapCenter() );
2342 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2343 ex.addFilter ("Taskjuggler (*.tjp)");
2344 if (ex.execDialog() )
2346 me->setExportMode(true);
2348 me->setExportMode(false);
2353 void Main::fileExportOOPresentation()
2355 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2356 // FIXME add extra info in dialog
2357 //ImagePreview *p =new ImagePreview (fd);
2358 //fd->setContentsPreviewEnabled( TRUE );
2359 //fd->setContentsPreview( p, p );
2360 //fd->setPreviewMode( QFileDialog::Contents );
2361 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2362 //fd->setDir (lastImageDir);
2365 if ( fd->exec() == QDialog::Accepted )
2367 QString fn=fd->selectedFile();
2368 //lastImageDir=fn.left(fn.findRev ("/"));
2369 if (currentMapEditor())
2370 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2374 void Main::fileCloseMap()
2376 if (currentMapEditor())
2378 if (currentMapEditor()->hasChanged())
2380 QMessageBox mb( __VYM,
2381 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2382 QMessageBox::Warning,
2383 QMessageBox::Yes | QMessageBox::Default,
2385 QMessageBox::Cancel | QMessageBox::Escape );
2386 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2387 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2390 case QMessageBox::Yes:
2392 fileSave(CompleteMap);
2394 case QMessageBox::No:
2395 // close without saving
2397 case QMessageBox::Cancel:
2402 currentMapEditor()->closeMap();
2403 tabWidget->removePage(currentMapEditor());
2404 if (tabWidget->count()==0)
2405 actionFilePrint->setEnabled (false);
2409 void Main::filePrint()
2411 if (currentMapEditor())
2412 currentMapEditor()->print();
2415 void Main::fileExitVYM()
2417 // Check if one or more editors have changed
2420 for (i=0;i<=tabWidget->count() -1;i++)
2423 me=(MapEditor*)tabWidget->page(i);
2425 // If something changed, ask what to do
2426 if (me->isUnsaved())
2428 tabWidget->setCurrentPage(i);
2429 QMessageBox mb( __VYM,
2430 tr("This map is not saved yet. Do you want to"),
2431 QMessageBox::Warning,
2432 QMessageBox::Yes | QMessageBox::Default,
2434 QMessageBox::Cancel | QMessageBox::Escape );
2435 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2436 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2438 mb.setActiveWindow();
2439 switch( mb.exec() ) {
2440 case QMessageBox::Yes:
2441 // save (the changed editors) and exit
2442 fileSave(CompleteMap);
2444 case QMessageBox::No:
2445 // exit without saving
2447 case QMessageBox::Cancel:
2448 // don't save and don't exit
2452 } // loop over all MEs
2456 void Main::editUndo()
2458 if (currentMapEditor())
2459 currentMapEditor()->undo();
2462 void Main::editRedo()
2464 if (currentMapEditor())
2465 currentMapEditor()->redo();
2468 void Main::editCopy()
2470 if (currentMapEditor())
2471 currentMapEditor()->copy();
2474 void Main::editPaste()
2476 if (currentMapEditor())
2477 currentMapEditor()->paste();
2480 void Main::editCut()
2482 if (currentMapEditor())
2483 currentMapEditor()->cut();
2486 void Main::editOpenFindWindow()
2488 findWindow->popup();
2489 findWindow->raise();
2490 findWindow->setActiveWindow();
2493 void Main::editFind(QString s)
2496 BranchObj *bo=currentMapEditor()->findText(s, cs);
2499 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2502 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2503 tr("No matches found for \"%1\"").arg(s));
2507 void Main::editFindChanged()
2508 { // Notify editor, to abort the current find process
2509 currentMapEditor()->findReset();
2512 void Main::editOpenURL()
2515 if (currentMapEditor())
2517 QString url=currentMapEditor()->getURL();
2518 if (url=="") return;
2519 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2520 procBrowser = new Q3Process( this );
2522 procBrowser->addArgument( browser);
2523 procBrowser->addArgument( url);
2525 if ( !procBrowser->start() )
2527 // try to set path to browser
2528 QMessageBox::warning(0,
2530 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2531 tr("Please use Settings->")+tr("Set application to open an URL"));
2536 void Main::editOpenURLTab()
2538 if (currentMapEditor())
2540 QString url=currentMapEditor()->getURL();
2541 if (url=="") return;
2542 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2543 if (procBrowser && procBrowser->isRunning())
2545 if (browser.contains("konqueror"))
2547 // Try to open new tab in existing konqueror started previously by vym
2548 Q3Process *p=new Q3Process (this);
2549 p->addArgument ("dcop");
2550 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2551 p->addArgument ("konqueror-mainwindow#1");
2552 p->addArgument ("newTab");
2553 p->addArgument (url);
2555 // try to set browser
2556 QMessageBox::warning(0,
2558 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2560 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2562 // Try to open new tab in firefox
2563 Q3Process *p=new Q3Process (this);
2564 p->addArgument (browser);
2565 p->addArgument ("-remote");
2566 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2568 // try to set browser
2569 QMessageBox::warning(0,
2571 tr("Couldn't start %1 to open a new tab").arg(browser));
2580 void Main::editURL()
2582 if (currentMapEditor())
2583 currentMapEditor()->editURL();
2586 void Main::editHeading2URL()
2588 if (currentMapEditor())
2589 currentMapEditor()->editHeading2URL();
2592 void Main::editBugzilla2URL()
2594 if (currentMapEditor())
2595 currentMapEditor()->editBugzilla2URL();
2598 void Main::editFATE2URL()
2600 if (currentMapEditor())
2601 currentMapEditor()->editFATE2URL();
2604 void Main::editOpenVymLink()
2606 // Get current path to map
2607 QString currentVymLink;
2608 if (currentMapEditor())
2610 currentVymLink=currentMapEditor()->getVymLink();
2611 // compare path with already loaded maps
2615 for (i=0;i<=tabWidget->count() -1;i++)
2617 me=(MapEditor*)tabWidget->page(i);
2618 if (currentVymLink==me->getFilePath() )
2627 if (!QFile(currentVymLink).exists() )
2628 QMessageBox::critical( 0, tr( "Critical Error" ),
2629 tr("Couldn't open map %1").arg(currentVymLink));
2632 fileLoad (currentVymLink, NewMap);
2633 tabWidget->setCurrentPage (tabWidget->count()-1);
2636 // Go to tab containing the map
2637 tabWidget->setCurrentPage (index);
2641 void Main::editVymLink()
2643 if (currentMapEditor())
2644 currentMapEditor()->editVymLink();
2647 void Main::editDeleteVymLink()
2649 if (currentMapEditor())
2650 currentMapEditor()->deleteVymLink();
2653 void Main::editToggleHideExport()
2655 if (currentMapEditor())
2656 currentMapEditor()->toggleHideExport();
2659 void Main::editMapInfo()
2661 if (currentMapEditor())
2662 currentMapEditor()->editMapInfo();
2665 void Main::editMoveUp()
2667 if (currentMapEditor())
2668 currentMapEditor()->moveBranchUp();
2671 void Main::editMoveDown()
2673 if (currentMapEditor())
2674 currentMapEditor()->moveBranchDown();
2677 void Main::editToggleScroll()
2679 if (currentMapEditor())
2681 currentMapEditor()->toggleScroll();
2685 void Main::editUnScrollAll()
2687 if (currentMapEditor())
2689 currentMapEditor()->unScrollAll();
2693 void Main::editHeading()
2695 if (currentMapEditor())
2696 currentMapEditor()->editHeading();
2699 void Main::editNewBranch()
2701 if (currentMapEditor())
2702 currentMapEditor()->addNewBranch(0);
2705 void Main::editNewBranchHere()
2707 if (currentMapEditor())
2708 currentMapEditor()->addNewBranchHere();
2711 void Main::editNewBranchAbove()
2713 if (currentMapEditor())
2714 currentMapEditor()->addNewBranch(-1);
2717 void Main::editNewBranchBelow()
2719 if (currentMapEditor())
2720 currentMapEditor()->addNewBranch(1);
2723 void Main::editImportAdd()
2725 fileLoad (ImportAdd);
2728 void Main::editImportReplace()
2730 fileLoad (ImportReplace);
2733 void Main::editSaveBranch()
2735 fileSaveAs (PartOfMap);
2738 void Main::editRemoveBranchKeepChilds()
2740 if (currentMapEditor())
2741 currentMapEditor()->removeBranchKeepChilds();
2744 void Main::editRemoveChilds()
2746 if (currentMapEditor())
2747 currentMapEditor()->removeChilds();
2750 void Main::editDeleteSelection()
2752 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2753 currentMapEditor()->deleteSelection();
2756 void Main::editUpperBranch()
2758 if (currentMapEditor())
2759 currentMapEditor()->selectUpperBranch();
2762 void Main::editLowerBranch()
2764 if (currentMapEditor())
2765 currentMapEditor()->selectLowerBranch();
2768 void Main::editLeftBranch()
2770 if (currentMapEditor())
2771 currentMapEditor()->selectLeftBranch();
2774 void Main::editRightBranch()
2776 if (currentMapEditor())
2777 currentMapEditor()->selectRightBranch();
2780 void Main::editFirstBranch()
2782 if (currentMapEditor())
2783 currentMapEditor()->selectFirstBranch();
2786 void Main::editLastBranch()
2788 if (currentMapEditor())
2789 currentMapEditor()->selectLastBranch();
2792 void Main::editLoadImage()
2794 if (currentMapEditor())
2795 currentMapEditor()->loadFloatImage();
2798 void Main::editSaveImage(int item)
2800 if (currentMapEditor())
2801 currentMapEditor()->saveFloatImage(item);
2804 void Main::editFollowXLink(QAction *a)
2807 if (currentMapEditor())
2808 currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
2811 void Main::editEditXLink(QAction *a)
2813 if (currentMapEditor())
2814 currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
2817 void Main::formatSelectColor()
2819 if (currentMapEditor())
2821 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2822 if ( !col.isValid() ) return;
2823 currentMapEditor()->setColor( col );
2824 colorChanged( col );
2828 void Main::formatPickColor()
2830 if (currentMapEditor())
2831 colorChanged( currentMapEditor()->pickColor() );
2834 void Main::colorChanged(QColor c)
2836 QPixmap pix( 16, 16 );
2838 actionFormatColor->setIconSet( pix );
2841 void Main::formatColorItem()
2843 if (currentMapEditor())
2844 currentMapEditor()->colorItem();
2847 void Main::formatColorBranch()
2849 if (currentMapEditor())
2850 currentMapEditor()->colorBranch();
2853 void Main::formatLinkStyleLine()
2855 if (currentMapEditor())
2856 currentMapEditor()->setLinkStyle(StyleLine);
2859 void Main::formatLinkStyleParabel()
2861 if (currentMapEditor())
2862 currentMapEditor()->setLinkStyle(StyleParabel);
2865 void Main::formatLinkStylePolyLine()
2867 if (currentMapEditor())
2868 currentMapEditor()->setLinkStyle(StylePolyLine);
2871 void Main::formatLinkStylePolyParabel()
2873 if (currentMapEditor())
2874 currentMapEditor()->setLinkStyle(StylePolyParabel);
2877 void Main::formatSelectBackColor()
2879 if (currentMapEditor())
2880 currentMapEditor()->selectBackgroundColor();
2883 void Main::formatSelectLinkColor()
2885 if (currentMapEditor())
2886 currentMapEditor()->selectLinkColor();
2889 void Main::formatToggleLinkColorHint()
2891 currentMapEditor()->toggleLinkColorHint();
2894 void Main::formatFrameNone()
2896 if (currentMapEditor())
2897 currentMapEditor()->setFrame(NoFrame);
2900 void Main::formatFrameRectangle()
2902 if (currentMapEditor())
2903 currentMapEditor()->setFrame(Rectangle);
2906 void Main::formatIncludeImagesVer()
2908 if (currentMapEditor())
2909 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2912 void Main::formatIncludeImagesHor()
2914 if (currentMapEditor())
2915 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2918 void Main::formatHideLinkUnselected()
2920 if (currentMapEditor())
2921 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2924 void Main::viewZoomReset()
2926 if (currentMapEditor())
2930 currentMapEditor()->setWorldMatrix( m );
2931 currentMapEditor()->setViewCenter();
2932 currentMapEditor()->adjustCanvasSize();
2936 void Main::viewZoomIn()
2938 if (currentMapEditor())
2940 QMatrix m = currentMapEditor()->worldMatrix();
2941 m.scale( 1.25, 1.25 );
2942 currentMapEditor()->setWorldMatrix( m );
2943 currentMapEditor()->setViewCenter();
2944 currentMapEditor()->adjustCanvasSize();
2948 void Main::viewZoomOut()
2950 if (currentMapEditor())
2952 QMatrix m = currentMapEditor()->worldMatrix();
2953 m.scale( 0.8, 0.8 );
2954 currentMapEditor()->setWorldMatrix( m );
2955 currentMapEditor()->setViewCenter();
2956 currentMapEditor()->adjustCanvasSize();
2960 void Main::modModeColor()
2964 void Main::modModeLink()
2968 bool Main::settingsPDF()
2970 // Default browser is set in constructor
2972 QString text = QInputDialog::getText(
2973 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2974 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2976 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2981 bool Main::settingsURL()
2983 // Default browser is set in constructor
2985 QString text = QInputDialog::getText(
2986 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2987 settings.readEntry("/vym/mainwindow/readerURL")
2990 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2994 void Main::settingsToggleDelKey()
2996 if (actionSettingsUseDelKey->isOn())
2998 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3001 actionEditDelete->setAccel (QKeySequence (""));
3005 void Main::windowToggleNoteEditor()
3007 if (textEditor->showWithMain() )
3008 windowHideNoteEditor();
3010 windowShowNoteEditor();
3013 void Main::windowToggleHistory()
3015 if (currentMapEditor())
3016 currentMapEditor()->toggleHistoryWindow();
3019 void Main::updateNoteFlag()
3021 if (currentMapEditor())
3022 currentMapEditor()->updateNoteFlag();
3025 void Main::windowShowNoteEditor()
3027 textEditor->setShowWithMain(true);
3029 actionViewToggleNoteEditor->setOn (true);
3032 void Main::windowHideNoteEditor()
3034 textEditor->setShowWithMain(false);
3036 actionViewToggleNoteEditor->setOn (false);
3039 void Main::windowNextEditor()
3041 if (tabWidget->currentPageIndex() < tabWidget->count())
3042 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3045 void Main::windowPreviousEditor()
3047 if (tabWidget->currentPageIndex() >0)
3048 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3051 void Main::standardFlagChanged()
3053 currentMapEditor()->toggleStandardFlag(sender()->name());
3056 void Main::testFunction()
3058 currentMapEditor()->testFunction();
3061 void Main::helpDoc()
3064 #if defined(Q_OS_MACX)
3065 docpath="./vym.app/Contents/vym.pdf";
3067 // default path in SUSE LINUX
3068 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3071 if (!QFile (docpath).exists() )
3073 // relative path for easy testing in tarball
3074 docpath="doc/vym.pdf";
3075 if (!QFile (docpath).exists() )
3077 // relative path for testing while still writing vym.tex
3078 docpath="doc/tex/vym.pdf";
3079 if (!QFile (docpath).exists() )
3081 // Try yet another one for Knoppix
3082 docpath="/usr/share/doc/packages/vym/vym.pdf";
3083 if (!QFile (docpath).exists() )
3085 QMessageBox::critical(0,
3086 tr("Critcal error"),
3087 tr("Couldn't find the documentation\n"
3088 "vym.pdf in various places."));
3095 Process *pdfProc = new Process();
3096 pdfProc->clearArguments();
3097 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
3098 pdfProc->addArgument( docpath);
3100 if ( !pdfProc->start() )
3103 QMessageBox::warning(0,
3105 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3106 tr("Please use Settings->")+tr("Set application to open PDF files"));
3113 void Main::helpAbout()
3116 ad.setName ("aboutwindow");
3117 ad.setMinimumSize(500,500);
3118 ad.resize (QSize (500,500));
3122 void Main::helpAboutQT()
3124 QMessageBox::aboutQt( this, "Qt Application Example" );