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.readNumEntry( "/vym/mainwindow/geometry/width", 800),
159 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
160 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
161 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
164 // Create unique temporary directory
165 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
167 // Create direcctory for clipboard
168 clipboardDir=tmpVymDir+"/clipboard";
169 QDir d(clipboardDir);
170 d.mkdir (clipboardDir,true);
171 makeSubDirs (clipboardDir);
176 // FIXME not used currently
177 // Set random seed (random used for object IDs)
178 // QTime t = QTime::currentTime(); // set random seed
179 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
182 // Initialize some settings, which are platform dependant
185 // application to open URLs
186 p="/vym/mainwindow/readerURL";
187 #if defined(Q_OS_LINUX)
188 s=settings.readEntry (p,"konqueror");
190 #if defined(Q_OS_MACX)
191 s=settings.readEntry (p,"/usr/bin/open");
193 s=settings.readEntry (p,"mozilla");
196 settings.writeEntry( p,s);
198 // application to open PDFs
199 p="/vym/mainwindow/readerPDF";
200 #if defined(Q_OS_LINUX)
201 s=settings.readEntry (p,"acroread");
203 #if defined(Q_OS_MACX)
204 s=settings.readEntry (p,"/usr/bin/open");
206 s=settings.readEntry (p,"acroread");
209 settings.writeEntry( p,s);
214 // Create tab widget which holds the maps
215 tabWidget= new QTabWidget (this);
216 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
217 this, SLOT( editorChanged( QWidget * ) ) );
219 setCentralWidget(tabWidget);
223 setupFormatActions();
227 setupSettingsActions();
229 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
232 // After menu is created, we can enable some actions
233 //FIXME QT3 testing actionFilePrint->setEnabled (true);
238 settings.beginGroup("/vym/mainwindow/toolbars/standardFlags");
239 TB_standardFlags->move(settings.value("pos").toPoint());
240 cout << "moving TB to pos="<<settings.value("pos").toPoint()<<endl;
241 // FIXME proceed here...
242 // TB_standardFlags->setOrientation(settings.value("orientation").toInt());
243 // TB_standardFlags->setVisible(settings.value<QVariant::Bool>("visible",true));
247 // Initialize Find window
248 findWindow=new FindWindow(NULL,"findwindow");
249 connect (findWindow, SIGNAL( findButton(QString) ),
250 this, SLOT(editFind(QString) ) );
251 connect (findWindow, SIGNAL( somethingChanged() ),
252 this, SLOT(editFindChanged() ) );
254 // Connect TextEditor, so that we can update flags if text changes
255 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
263 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
264 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
265 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
266 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
268 settings.beginGroup ("/vym/mainwindow/toolbar/standardFlags");
269 settings.setValue ("pos",TB_standardFlags->pos());
270 settings.setValue ("visible",TB_standardFlags->isVisible());
271 settings.setValue ("orientation",TB_standardFlags->orientation());
274 settings.writeEntry( "/vym/mainwindow/toobar/posY", pos().y() );
276 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
277 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
279 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
280 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
281 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
282 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
283 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
284 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
285 settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
288 int maps=lastMaps.count();
289 settings.writeEntry( "/vym/lastMaps/number",maps );
290 for (int i=1;i<=maps;i++)
292 s=QString("/vym/lastMaps/map-%1").arg(i);
293 if (!s.isEmpty() && i<=maxLastMaps)
294 settings.writeEntry (s, lastMaps.at(i-1));
298 // To make the texteditor save its settings, call the destructor
301 // Remove temporary directory
302 removeDir (QDir(tmpVymDir));
305 void Main::loadCmdLine()
307 /* TODO draw some kind of splashscreen while loading...
313 QStringList flist=options.getFileList();
314 QStringList::Iterator it=flist.begin();
316 while (it !=flist.end() )
318 fileLoad (*it, NewMap);
324 void Main::statusMessage(const QString &s)
326 statusBar()->message (s);
329 void Main::closeEvent (QCloseEvent* )
335 void Main::setupFileActions()
337 QMenu *fileMenu = menuBar()->addMenu ( tr ("&File") );
338 QToolBar *tb = addToolBar( tr ("&File") );
341 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
342 a->setStatusTip ( tr( "New map","File menu" ) );
343 a->setShortcut ( Qt::CTRL + Qt::Key_N );
345 fileMenu->addAction (a);
346 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
348 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
349 a->setStatusTip (tr( "Open","File menu" ) );
350 a->setShortcut ( Qt::CTRL + Qt::Key_O );
352 fileMenu->addAction (a);
353 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
355 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
356 fileMenu->addSeparator();
358 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
359 a->setStatusTip ( tr( "Save" ));
360 a->setShortcut (Qt::CTRL + Qt::Key_S );
362 fileMenu->addAction (a);
363 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
366 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
367 a->setStatusTip (tr( "Save &As" ) );
368 fileMenu->addAction (a);
369 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
371 fileMenu->addSeparator();
373 fileImportMenu = fileMenu->addMenu (tr("Import"));
375 a = new QAction(tr("KDE Bookmarks"), this);
376 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
377 a->addTo (fileImportMenu);
378 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
380 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
382 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
383 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
384 a->addTo (fileImportMenu);
385 connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
388 a = new QAction("Mind Manager...",this);
389 a->setStatusTip ( tr( "Import")+" Mind Manager" );
390 fileImportMenu->addAction (a);
391 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
393 a = new QAction( tr( "Import Dir"+QString("...") ), this);
394 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
395 fileImportMenu->addAction (a);
396 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
398 fileExportMenu = fileMenu->addMenu (tr("Export"));
400 a = new QAction( tr("Image")+QString("..."), this);
401 a->setStatusTip( tr( "Export map as image" ));
402 connect( a, SIGNAL( activated() ), this, SLOT( fileExportImage() ) );
403 fileExportMenu->addAction (a);
405 a = new QAction( "Open Office"+QString("..."), this);
406 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
407 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
408 fileExportMenu->addAction (a);
410 a = new QAction( "Webpage (XHTML)...",this );
411 a->setShortcut (Qt::ALT + Qt::Key_X);
412 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
413 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
414 fileExportMenu->addAction (a);
416 a = new QAction( "Text (ASCII)...", this);
417 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
418 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
419 fileExportMenu->addAction (a);
421 a = new QAction( tr("KDE Bookmarks"), this);
422 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
423 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
424 fileExportMenu->addAction (a);
426 a = new QAction( "Taskjuggler...", this );
427 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
428 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
429 fileExportMenu->addAction (a);
431 a = new QAction( "LaTeX...", this);
432 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
433 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
434 fileExportMenu->addAction (a);
436 a = new QAction( "XML..." , this );
437 a->setStatusTip (tr( "Export as")+" XML");
438 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
439 fileExportMenu->addAction (a);
441 fileMenu->addSeparator();
443 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
444 a->setStatusTip ( tr( "Print" ) );
445 a->setShortcut (Qt::CTRL + Qt::Key_P );
447 fileMenu->addAction (a);
448 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
451 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
452 a->setStatusTip (tr( "Close Map" ) );
453 a->setShortcut (Qt::ALT + Qt::Key_C );
454 fileMenu->addAction (a);
455 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
457 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
458 a->setStatusTip ( tr( "Exit")+" "+__VYM );
459 a->setShortcut (Qt::CTRL + Qt::Key_Q );
460 fileMenu->addAction (a);
461 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
466 void Main::setupEditActions()
468 QToolBar *tb = addToolBar( tr ("&Edit") );
469 tb->setLabel( "Edit Actions" );
470 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
474 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
475 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
476 a->setStatusTip (tr( "Undo" ) );
477 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
478 a->setEnabled (false);
480 editMenu->addAction (a);
483 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
485 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
486 a->setStatusTip (tr( "Redo" ));
487 a->setShortcut (Qt::CTRL + Qt::Key_Y );
488 editMenu->addAction (a);
489 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
492 editMenu->addSeparator();
493 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
494 a->setStatusTip ( tr( "Copy" ) );
495 a->setShortcut (Qt::CTRL + Qt::Key_C );
496 a->setEnabled (false);
498 editMenu->addAction (a);
499 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
502 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
503 a->setStatusTip ( tr( "Cut" ) );
504 a->setShortcut (Qt::CTRL + Qt::Key_X );
505 a->setEnabled (false);
507 editMenu->addAction (a);
509 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
511 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
512 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
513 a->setStatusTip ( tr( "Paste" ) );
514 a->setShortcut ( Qt::CTRL + Qt::Key_V );
515 a->setEnabled (false);
517 editMenu->addAction (a);
520 // Shortcuts to modify heading:
521 a = new QAction(tr( "Edit heading" ),this);
522 a->setStatusTip ( tr( "edit Heading" ));
523 a->setShortcut ( Qt::Key_Enter);
524 a->setShortcutContext (Qt::WindowShortcut);
526 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
527 actionListBranches.append(a);
528 a = new QAction( tr( "Edit heading" ), this);
529 a->setStatusTip (tr( "edit Heading" ));
530 a->setShortcut (Qt::Key_Return );
531 a->setShortcutContext (Qt::WindowShortcut);
533 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
534 actionListBranches.append(a);
535 editMenu->addAction (a);
537 a = new QAction( tr( "Edit heading" ), this);
538 a->setStatusTip (tr( "edit Heading" ));
539 a->setShortcut ( Qt::Key_F2 );
540 a->setShortcutContext (Qt::WindowShortcut);
542 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
543 actionListBranches.append(a);
545 // Shortcut to delete selection
546 a = new QAction( tr( "Delete Selection" ),this);
547 a->setStatusTip (tr( "Delete Selection" ));
548 a->setShortcut ( Qt::Key_Delete);
549 a->setShortcutContext (Qt::WindowShortcut);
551 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
554 // Shortcut to add branch
555 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
556 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
557 alt->setShortcut (Qt::Key_A);
558 alt->setShortcutContext (Qt::WindowShortcut);
560 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
561 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
562 a->setStatusTip ( tr( "Add a branch as child of selection" ));
563 a->setShortcut (Qt::Key_Insert);
564 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
565 actionListBranches.append(a);
566 #if defined (Q_OS_MACX)
567 // In OSX show different shortcut in menues, the keys work indepently always
568 actionEditAddBranch=alt;
570 actionEditAddBranch=a;
572 editMenu->addAction (actionEditAddBranch);
573 tb->addAction (actionEditAddBranch);
576 // Add branch by inserting it at selection
577 a = new QAction(tr( "Add branch (insert)" ), this);
578 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
579 a->setShortcut (Qt::ALT + Qt::Key_Insert );
580 a->setShortcutContext (Qt::WindowShortcut);
582 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
583 a->setEnabled (false);
584 actionListBranches.append(a);
585 actionEditAddBranchHere=a;
586 a = new QAction(tr( "Add branch (insert)" ),this);
587 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
588 a->setShortcut ( Qt::ALT + Qt::Key_A );
589 a->setShortcutContext (Qt::WindowShortcut);
591 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
592 actionListBranches.append(a);
595 a = new QAction(tr( "Add branch above" ), this);
596 a->setStatusTip ( tr( "Add a branch above selection" ));
597 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
598 a->setShortcutContext (Qt::WindowShortcut);
600 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
601 a->setEnabled (false);
602 actionListBranches.append(a);
603 actionEditAddBranchAbove=a;
604 a = new QAction(tr( "Add branch above" ), this);
605 a->setStatusTip ( tr( "Add a branch above selection" ));
606 a->setShortcut (Qt::SHIFT+Qt::Key_A );
607 a->setShortcutContext (Qt::WindowShortcut);
609 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
610 actionListBranches.append(a);
613 a = new QAction(tr( "Add branch below" ), this);
614 a->setStatusTip ( tr( "Add a branch below selection" ));
615 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
616 a->setShortcutContext (Qt::WindowShortcut);
618 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
619 a->setEnabled (false);
620 actionListBranches.append(a);
621 actionEditAddBranchBelow=a;
622 a = new QAction(tr( "Add branch below" ), this);
623 a->setStatusTip ( tr( "Add a branch below selection" ));
624 a->setShortcut (Qt::CTRL +Qt::Key_A );
625 a->setShortcutContext (Qt::WindowShortcut);
627 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
628 actionListBranches.append(a);
630 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
631 a->setStatusTip ( tr( "Move branch up" ) );
632 a->setShortcut (Qt::Key_PageUp );
633 a->setEnabled (false);
635 editMenu->addAction (a);
636 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
639 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
640 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
641 a->setStatusTip (tr( "Move branch down" ) );
642 a->setShortcut ( Qt::Key_PageDown );
643 a->setEnabled (false);
645 editMenu->addAction (a);
646 actionEditMoveDown=a;
649 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
650 a->setShortcut ( Qt::Key_ScrollLock );
651 a->setStatusTip (tr( "Scroll branch" ) );
652 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
653 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
654 alt->setShortcut ( Qt::Key_S );
655 alt->setStatusTip (tr( "Scroll branch" ));
656 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
657 #if defined(Q_OS_MACX)
658 actionEditToggleScroll=alt;
660 actionEditToggleScroll=a;
662 actionEditToggleScroll->setEnabled (false);
663 actionEditToggleScroll->setToggleAction(true);
664 tb->addAction (actionEditToggleScroll);
665 editMenu->addAction ( actionEditToggleScroll);
666 editMenu->addAction (actionEditToggleScroll);
667 actionListBranches.append(actionEditToggleScroll);
669 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
670 a->setStatusTip (tr( "Unscroll all" ));
671 editMenu->addAction (a);
672 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
674 editMenu->addSeparator();
676 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
677 a->setStatusTip (tr( "Find" ) );
678 a->setShortcut (Qt::CTRL + Qt::Key_F );
679 editMenu->addAction (a);
680 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
682 editMenu->addSeparator();
684 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
685 a->setShortcut (Qt::CTRL + Qt::Key_U );
686 a->setShortcut (tr( "Open URL" ));
689 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
692 a = new QAction( tr( "Open URL in new tab" ), this);
693 a->setStatusTip (tr( "Open URL in new tab" ));
694 a->setShortcut (Qt::CTRL+Qt::Key_U );
696 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
697 actionEditOpenURLTab=a;
699 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
700 a->setStatusTip ( tr( "Edit URL" ) );
701 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
702 //a->setShortcut ( Qt::Key_U );
703 a->setShortcutContext (Qt::WindowShortcut);
704 actionListBranches.append(a);
706 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
709 a = new QAction( tr( "Use heading for URL" ), this);
710 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
711 a->setEnabled (false);
712 actionListBranches.append(a);
713 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
714 actionEditHeading2URL=a;
716 a = new QAction(tr( "Create URL to Bugzilla" ), this);
717 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
718 a->setEnabled (false);
719 actionListBranches.append(a);
720 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
721 actionEditBugzilla2URL=a;
723 a = new QAction(tr( "Create URL to FATE" ), this);
724 a->setStatusTip ( tr( "Create URL to FATE" ));
725 a->setEnabled (false);
726 actionListBranches.append(a);
727 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
728 actionEditFATE2URL=a;
730 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
731 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
733 a->setEnabled (false);
734 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
735 actionEditOpenVymLink=a;
737 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
738 a->setEnabled (false);
739 a->setStatusTip ( tr( "Edit link to another vym map" ));
740 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
741 actionListBranches.append(a);
744 a = new QAction(tr( "Delete vym link" ),this);
745 a->setStatusTip ( tr( "Delete link to another vym map" ));
746 a->setEnabled (false);
747 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
748 actionEditDeleteVymLink=a;
750 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
751 a->setStatusTip ( tr( "Hide object in exports" ) );
752 a->setShortcut (Qt::Key_H );
753 a->setToggleAction(true);
755 a->setEnabled (false);
756 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
757 actionEditToggleHideExport=a;
759 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
760 a->setStatusTip ( tr( "Edit Map Info" ));
761 a->setEnabled (true);
762 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
765 editMenu->addSeparator();
767 // Import at selection (adding to selection)
768 a = new QAction( tr( "Add map (insert)" ),this);
769 a->setStatusTip (tr( "Add map at selection" ));
770 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
771 a->setEnabled (false);
772 actionListBranches.append(a);
773 actionEditImportAdd=a;
775 // Import at selection (replacing selection)
776 a = new QAction( tr( "Add map (replace)" ), this);
777 a->setStatusTip (tr( "Replace selection with map" ));
778 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
779 a->setEnabled (false);
780 actionListBranches.append(a);
781 actionEditImportReplace=a;
784 a = new QAction( tr( "Save selection" ), this);
785 a->setStatusTip (tr( "Save selection" ));
786 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
787 a->setEnabled (false);
788 actionListBranches.append(a);
789 actionEditSaveBranch=a;
791 // Only remove branch, not its childs
792 a = new QAction(tr( "Remove only branch " ), this);
793 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
794 a->setShortcut (Qt::ALT + Qt::Key_Delete );
795 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
796 a->setEnabled (false);
797 actionListBranches.append(a);
798 actionEditRemoveBranchKeepChilds=a;
800 // Only remove childs of a branch
801 a = new QAction( tr( "Remove childs" ), this);
802 a->setStatusTip (tr( "Remove childs of branch" ));
803 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
804 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
805 a->setEnabled (false);
806 actionListBranches.append(a);
807 actionEditRemoveChilds=a;
809 // Shortcuts for navigating with cursor:
810 a = new QAction(tr( "Select upper branch" ), this);
811 a->setStatusTip ( tr( "Select upper branch" ));
812 a->setShortcut (Qt::Key_Up );
813 a->setShortcutContext (Qt::WindowShortcut);
815 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
816 a = new QAction( tr( "Select lower branch" ),this);
817 a->setStatusTip (tr( "Select lower branch" ));
818 a->setShortcut ( Qt::Key_Down );
819 a->setShortcutContext (Qt::WindowShortcut);
821 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
822 a = new QAction(tr( "Select left branch" ), this);
823 a->setStatusTip ( tr( "Select left branch" ));
824 a->setShortcut (Qt::Key_Left );
825 a->setShortcutContext (Qt::WindowShortcut);
827 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
828 a = new QAction( tr( "Select child branch" ), this);
829 a->setStatusTip (tr( "Select right branch" ));
830 a->setShortcut (Qt::Key_Right);
831 a->setShortcutContext (Qt::WindowShortcut);
833 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
834 a = new QAction( tr( "Select first branch" ), this);
835 a->setStatusTip (tr( "Select first branch" ));
836 a->setShortcut (Qt::Key_Home );
837 a->setShortcutContext (Qt::WindowShortcut);
839 a->setEnabled (false);
840 editMenu->addAction (a);
841 actionListBranches.append(a);
842 actionEditSelectFirst=a;
843 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
844 a = new QAction( tr( "Select last branch" ),this);
845 a->setStatusTip (tr( "Select last branch" ));
846 a->setShortcut ( Qt::Key_End );
847 a->setShortcutContext (Qt::WindowShortcut);
849 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
850 a->setEnabled (false);
851 editMenu->addAction (a);
852 actionListBranches.append(a);
853 actionEditSelectLast=a;
855 a = new QAction( tr( "Add Image" )+QString("..."), this);
856 a->setStatusTip (tr( "Add Image" ));
857 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
858 actionEditLoadImage=a;
863 void Main::setupFormatActions()
865 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
867 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
870 pix.fill (Qt::black);
871 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
872 a->setStatusTip ( tr( "Set Color" ));
873 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
875 formatMenu->addAction (a);
877 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
878 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
879 a->setShortcut (Qt::CTRL + Qt::Key_K );
880 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
881 a->setEnabled (false);
883 formatMenu->addAction (a);
884 actionListBranches.append(a);
885 actionFormatPickColor=a;
887 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
888 a->setStatusTip ( tr( "Color branch" ) );
889 a->setShortcut (Qt::CTRL + Qt::Key_I);
890 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
891 a->setEnabled (false);
893 formatMenu->addAction (a);
894 actionListBranches.append(a);
895 actionFormatColorBranch=a;
897 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
898 a->setStatusTip ( tr( "Color Subtree" ));
899 a->setShortcut (Qt::CTRL + Qt::Key_T);
900 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
901 a->setEnabled (false);
902 formatMenu->addAction (a);
904 actionListBranches.append(a);
905 actionFormatColorSubtree=a;
907 formatMenu->addSeparator();
908 actionGroupFormatLinkStyles=new QActionGroup ( this);
909 actionGroupFormatLinkStyles->setExclusive (true);
910 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
911 a->setStatusTip (tr( "Line" ));
912 a->setToggleAction(true);
913 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
914 formatMenu->addAction (a);
915 actionFormatLinkStyleLine=a;
916 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
917 a->setStatusTip (tr( "Line" ));
918 a->setToggleAction(true);
919 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
920 formatMenu->addAction (a);
921 actionFormatLinkStyleParabel=a;
922 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
923 a->setStatusTip (tr( "PolyLine" ));
924 a->setToggleAction(true);
925 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
926 formatMenu->addAction (a);
927 actionFormatLinkStylePolyLine=a;
928 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
929 a->setStatusTip (tr( "PolyParabel" ) );
930 a->setToggleAction(true);
931 a->setChecked (true);
932 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
933 formatMenu->addAction (a);
934 actionFormatLinkStylePolyParabel=a;
936 actionGroupFormatFrameTypes=new QActionGroup ( this);
937 actionGroupFormatFrameTypes->setExclusive (true);
938 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
939 a->setStatusTip (tr("No Frame"));
940 a->setToggleAction(true);
941 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
942 actionFormatFrameNone=a;
943 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
944 a->setStatusTip (tr( "Rectangle" ));
945 a->setToggleAction(true);
946 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
947 actionFormatFrameRectangle=a;
949 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
950 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
951 a->setToggleAction(true);
952 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
953 actionFormatIncludeImagesVer=a;
955 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
956 a->setStatusTip ( tr ("Include left and right position of images into branch"));
957 a->setToggleAction(true);
958 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
959 actionFormatIncludeImagesHor=a;
961 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
962 a->setStatusTip (tr( "Hide link" ));
963 a->setToggleAction(true);
964 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
965 actionFormatHideLinkUnselected=a;
967 formatMenu->addSeparator();
968 a= new QAction( tr( "&Use color of heading for link" ), this);
969 a->setStatusTip (tr( "Use same color for links and headings" ));
970 a->setToggleAction(true);
971 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
972 formatMenu->addAction (a);
973 actionFormatLinkColorHint=a;
975 pix.fill (Qt::white);
976 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
977 a->setStatusTip (tr( "Set Link Color" ));
978 formatMenu->addAction (a);
979 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
980 actionFormatLinkColor=a;
982 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
983 a->setStatusTip (tr( "Set Background Color" ));
984 formatMenu->addAction (a);
985 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
986 actionFormatBackColor=a;
990 void Main::setupViewActions()
992 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
993 tb->setLabel( "View Actions" );
994 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
997 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
998 a->setStatusTip ( tr( "Zoom reset" ) );
999 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1001 viewMenu->addAction (a);
1002 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
1004 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
1005 a->setStatusTip (tr( "Zoom in" ));
1006 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1008 viewMenu->addAction (a);
1009 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
1011 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
1012 a->setStatusTip (tr( "Zoom out" ));
1013 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1015 viewMenu->addAction (a);
1016 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
1019 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1020 a->setStatusTip ( tr( "Show Note Editor" ));
1021 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1022 a->setToggleAction(true);
1023 if (textEditor->showWithMain())
1028 viewMenu->addAction (a);
1029 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
1030 actionViewToggleNoteEditor=a;
1032 a = new QAction( tr( "Show history window" ),this );
1033 a->setStatusTip ( tr( "Show history window" ));
1034 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1035 a->setToggleAction(false);
1036 viewMenu->addAction (a);
1037 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
1038 actionViewToggleHistoryWindow=a;
1040 a = new QAction(tr( "Next Window" ), this);
1041 a->setStatusTip ( tr( "&Next Window" ) );
1042 a->setShortcut (Qt::ALT + Qt::Key_N );
1043 viewMenu->addAction (a);
1044 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
1046 a = new QAction (tr( "Previous Window" ), this );
1047 a->setStatusTip (tr( "&Previous Window" ));
1048 a->setShortcut (Qt::ALT + Qt::Key_P );
1049 viewMenu->addAction (a);
1050 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
1054 void Main::setupModeActions()
1056 //QPopupMenu *menu = new QPopupMenu( this );
1057 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1059 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1061 actionGroupModModes=new QActionGroup ( this);
1062 actionGroupModModes->setExclusive (true);
1063 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1064 a->setShortcut (Qt::Key_J);
1065 a->setStatusTip ( tr( "Use modifier to color branches" ));
1066 a->setToggleAction(true);
1069 actionModModeColor=a;
1071 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1072 a->setShortcut( Qt::Key_K);
1073 a->setStatusTip( tr( "Use modifier to copy" ));
1074 a->setToggleAction(true);
1076 actionModModeCopy=a;
1078 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1079 a->setShortcut (Qt::Key_L);
1080 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1081 a->setToggleAction(true);
1083 actionModModeLink=a;
1087 void Main::setupFlagActions()
1089 // Create System Flags
1090 systemFlagsDefault = new FlagRowObj ();
1091 systemFlagsDefault->setVisibility (false);
1092 systemFlagsDefault->setName ("systemFlagsDef");
1094 FlagObj *fo = new FlagObj ();
1095 fo->load(QPixmap(flagsPath+"flag-note.png"));
1096 fo->setName("note");
1097 fo->setToolTip(tr("Note","Systemflag"));
1098 systemFlagsDefault->addFlag (fo); // makes deep copy
1100 fo->load(QPixmap(flagsPath+"flag-url.png"));
1102 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1103 systemFlagsDefault->addFlag (fo);
1105 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1106 fo->setName("vymLink");
1107 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1108 systemFlagsDefault->addFlag (fo);
1110 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1111 fo->setName("scrolledright");
1112 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1113 systemFlagsDefault->addFlag (fo);
1115 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1116 fo->setName("tmpUnscrolledright");
1117 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1118 systemFlagsDefault->addFlag (fo);
1120 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1121 fo->setName("hideInExport");
1122 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1123 systemFlagsDefault->addFlag (fo);
1125 // Create Standard Flags
1126 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1127 TB_standardFlags=tb;
1129 standardFlagsDefault = new FlagRowObj ();
1130 standardFlagsDefault->setVisibility (false);
1131 standardFlagsDefault->setName ("standardFlagsDef");
1132 standardFlagsDefault->setToolBar (tb);
1134 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1135 fo->setName ("exclamationmark");
1136 fo->setGroup("standard-mark");
1137 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1140 a->setCheckable(true);
1141 a->setObjectName(fo->getName());
1142 a->setToolTip(tr("Take care!","Standardflag"));
1143 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1144 standardFlagsDefault->addFlag (fo); // makes deep copy
1146 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1147 fo->setName("questionmark");
1148 fo->setGroup("standard-mark");
1149 a=new QAction (fo->getPixmap(),fo->getName(),this);
1152 a->setCheckable(true);
1153 a->setObjectName(fo->getName());
1154 a->setToolTip(tr("Really?","Standardflag"));
1155 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1156 standardFlagsDefault->addFlag (fo);
1158 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1159 fo->setName("hook-green");
1160 fo->setGroup("standard-hook");
1161 a=new QAction (fo->getPixmap(),fo->getName(),this);
1164 a->setCheckable(true);
1165 a->setObjectName(fo->getName());
1166 a->setToolTip(tr("ok!","Standardflag"));
1167 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1168 standardFlagsDefault->addFlag (fo);
1170 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1171 fo->setName("cross-red");
1172 fo->setGroup("standard-hook");
1173 a=new QAction (fo->getPixmap(),fo->getName(),this);
1176 a->setCheckable(true);
1177 a->setObjectName(fo->getName());
1178 a->setToolTip(tr("Not ok!","Standardflag"));
1179 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1180 standardFlagsDefault->addFlag (fo);
1182 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1183 fo->setName("stopsign");
1184 a=new QAction (fo->getPixmap(),fo->getName(),this);
1187 a->setCheckable(true);
1188 a->setObjectName(fo->getName());
1189 a->setToolTip(tr("This won't work!","Standardflag"));
1190 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1191 standardFlagsDefault->addFlag (fo);
1193 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1194 fo->setName("smiley-good");
1195 fo->setGroup("standard-smiley");
1196 a=new QAction (fo->getPixmap(),fo->getName(),this);
1199 a->setCheckable(true);
1200 a->setObjectName(fo->getName());
1201 a->setToolTip(tr("Good","Standardflag"));
1202 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1203 standardFlagsDefault->addFlag (fo);
1205 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1206 fo->setName("smiley-sad");
1207 fo->setGroup("standard-smiley");
1208 a=new QAction (fo->getPixmap(),fo->getName(),this);
1211 a->setCheckable(true);
1212 a->setObjectName(fo->getName());
1213 a->setToolTip(tr("Bad","Standardflag"));
1214 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1215 standardFlagsDefault->addFlag (fo);
1217 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1218 // Original omg.png (in KDE emoticons)
1219 fo->setName("smiley-omg");
1220 fo->setGroup("standard-smiley");
1221 a=new QAction (fo->getPixmap(),fo->getName(),this);
1224 a->setCheckable(true);
1225 a->setObjectName(fo->getName());
1226 a->setToolTip(tr("Oh no!","Standardflag"));
1227 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1228 standardFlagsDefault->addFlag (fo);
1230 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1231 fo->setName("clock");
1232 a=new QAction (fo->getPixmap(),fo->getName(),this);
1235 a->setCheckable(true);
1236 a->setObjectName(fo->getName());
1237 a->setToolTip(tr("Time critical","Standardflag"));
1238 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1239 standardFlagsDefault->addFlag (fo);
1241 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1242 fo->setName("phone");
1243 a=new QAction (fo->getPixmap(),fo->getName(),this);
1246 a->setCheckable(true);
1247 a->setObjectName(fo->getName());
1248 a->setToolTip(tr("Call...","Standardflag"));
1249 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1250 standardFlagsDefault->addFlag (fo);
1252 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1253 fo->setName("lamp");
1254 a=new QAction (fo->getPixmap(),fo->getName(),this);
1257 a->setCheckable(true);
1258 a->setObjectName(fo->getName());
1259 a->setToolTip(tr("Idea!","Standardflag"));
1260 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1261 standardFlagsDefault->addFlag (fo);
1263 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1264 fo->setName("arrow-up");
1265 fo->setGroup("standard-arrow");
1266 a=new QAction (fo->getPixmap(),fo->getName(),this);
1269 a->setCheckable(true);
1270 a->setObjectName(fo->getName());
1271 a->setToolTip(tr("Important","Standardflag"));
1272 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1273 standardFlagsDefault->addFlag (fo);
1275 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1276 fo->setName("arrow-down");
1277 fo->setGroup("standard-arrow");
1278 a=new QAction (fo->getPixmap(),fo->getName(),this);
1281 a->setCheckable(true);
1282 a->setObjectName(fo->getName());
1283 a->setToolTip(tr("Unimportant","Standardflag"));
1284 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1285 standardFlagsDefault->addFlag (fo);
1287 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1288 fo->setName("2arrow-up");
1289 fo->setGroup("standard-arrow");
1290 a=new QAction (fo->getPixmap(),fo->getName(),this);
1293 a->setCheckable(true);
1294 a->setObjectName(fo->getName());
1295 a->setToolTip(tr("Very important!","Standardflag"));
1296 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1297 standardFlagsDefault->addFlag (fo);
1299 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1300 fo->setName("2arrow-down");
1301 fo->setGroup("standard-arrow");
1302 a=new QAction (fo->getPixmap(),fo->getName(),this);
1305 a->setCheckable(true);
1306 a->setObjectName(fo->getName());
1307 a->setToolTip(tr("Very unimportant!","Standardflag"));
1308 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1309 standardFlagsDefault->addFlag (fo);
1311 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1312 fo->setName("thumb-up");
1313 fo->setGroup("standard-thumb");
1314 a=new QAction (fo->getPixmap(),fo->getName(),this);
1317 a->setCheckable(true);
1318 a->setObjectName(fo->getName());
1319 a->setToolTip(tr("I like this","Standardflag"));
1320 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1321 standardFlagsDefault->addFlag (fo);
1323 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1324 fo->setName("thumb-down");
1325 fo->setGroup("standard-thumb");
1326 a=new QAction (fo->getPixmap(),fo->getName(),this);
1329 a->setCheckable(true);
1330 a->setObjectName(fo->getName());
1331 a->setToolTip(tr("I do not like this","Standardflag"));
1332 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1333 standardFlagsDefault->addFlag (fo);
1335 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1336 fo->setName("rose");
1337 a=new QAction (fo->getPixmap(),fo->getName(),this);
1340 a->setCheckable(true);
1341 a->setObjectName(fo->getName());
1342 a->setToolTip(tr("Rose","Standardflag"));
1343 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1344 standardFlagsDefault->addFlag (fo);
1346 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1347 fo->setName("heart");
1348 a=new QAction (fo->getPixmap(),fo->getName(),this);
1350 a->setCheckable(true);
1351 a->setObjectName(fo->getName());
1352 a->setToolTip(tr("I just love... ","Standardflag"));
1353 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1354 standardFlagsDefault->addFlag (fo);
1356 fo->load(QPixmap(flagsPath+"flag-present.png"));
1357 fo->setName("present");
1358 a=new QAction (fo->getPixmap(),fo->getName(),this);
1361 a->setCheckable(true);
1362 a->setObjectName(fo->getName());
1363 a->setToolTip(tr("Surprise!","Standardflag"));
1364 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1365 standardFlagsDefault->addFlag (fo);
1367 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1368 fo->setName("flash");
1369 a=new QAction (fo->getPixmap(),fo->getName(),this);
1372 a->setCheckable(true);
1373 a->setObjectName(fo->getName());
1374 a->setToolTip(tr("Dangerous","Standardflag"));
1375 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1376 standardFlagsDefault->addFlag (fo);
1378 fo->load(QPixmap(flagsPath+"flag-info.png"));
1379 // Original: xsldbg_output.png
1380 fo->setName("info");
1381 a=new QAction (fo->getPixmap(),fo->getName(),this);
1384 a->setCheckable(true);
1385 a->setObjectName(fo->getName());
1386 a->setToolTip(tr("Info","Standardflag"));
1387 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1388 standardFlagsDefault->addFlag (fo);
1390 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1391 // Original khelpcenter.png
1392 fo->setName("lifebelt");
1393 a=new QAction (fo->getPixmap(),fo->getName(),this);
1396 a->setCheckable(true);
1397 a->setObjectName(fo->getName());
1398 a->setToolTip(tr("This will help","Standardflag"));
1399 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1400 standardFlagsDefault->addFlag (fo);
1406 void Main::setupSettingsActions()
1408 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1412 a = new QAction( tr( "Set application to open pdf files"), this);
1413 a->setStatusTip ( tr( "Set application to open pdf files"));
1414 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1415 settingsMenu->addAction (a);
1417 a = new QAction( tr( "Set application to open external links"), this);
1418 a->setStatusTip( tr( "Set application to open external links"));
1419 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1420 settingsMenu->addAction (a);
1422 settingsMenu->addSeparator();
1423 a = new QAction( tr( "Edit branch after adding it" ), this );
1424 a->setStatusTip( tr( "Edit branch after adding it" ));
1425 a->setToggleAction(true);
1426 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1427 settingsMenu->addAction (a);
1428 actionSettingsAutoedit=a;
1430 a= new QAction( tr( "Select branch after adding it" ), this );
1431 a->setStatusTip( tr( "Select branch after adding it" ));
1432 a->setToggleAction(true);
1433 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1434 settingsMenu->addAction (a);
1435 actionSettingsAutoselectHeading=a;
1437 a= new QAction(tr( "Select existing heading" ), this);
1438 a->setStatusTip( tr( "Select heading before editing" ));
1439 a->setToggleAction(true);
1440 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1441 settingsMenu->addAction (a);
1442 actionSettingsAutoselectText=a;
1444 a= new QAction(tr( "pasting into new branch" ), this );
1445 a->setStatusTip( tr( "Pasting into new branch" ));
1446 a->setToggleAction(true);
1447 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1448 settingsMenu->addAction (a);
1449 actionSettingsPasteNewHeading=a;
1451 a= new QAction( tr( "Delete key" ), this);
1452 a->setStatusTip( tr( "Delete key for deleting branches" ));
1453 a->setToggleAction(true);
1454 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1455 settingsMenu->addAction (a);
1456 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1457 actionSettingsUseDelKey=a;
1459 a= new QAction( tr( "Exclusive flags" ), this);
1460 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1461 a->setToggleAction(true);
1462 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1463 settingsMenu->addAction (a);
1464 actionSettingsUseFlagGroups=a;
1466 a= new QAction( tr( "Use hide flags" ), this);
1467 a->setStatusTip( tr( "Use hide flag during exports " ));
1468 a->setToggleAction(true);
1469 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1470 settingsMenu->addAction (a);
1471 actionSettingsUseHideExport=a;
1475 void Main::setupTestActions()
1477 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1480 a = new QAction( tr( "test flag" ), this);
1481 a->setStatusTip( tr( "Call test function" ));
1482 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1483 testMenu->addAction (a);
1487 void Main::setupHelpActions()
1489 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1492 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1493 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1494 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1495 helpMenu->addAction (a);
1497 a = new QAction( tr( "About VYM" ), this);
1498 a->setStatusTip( tr( "About VYM")+" "__VYM);
1499 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1500 helpMenu->addAction (a);
1502 a = new QAction( tr( "About QT" ), this);
1503 a->setStatusTip( tr( "Information about QT toolkit" ));
1504 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1505 helpMenu->addAction (a);
1509 void Main::setupContextMenus()
1513 // Context Menu for branch or mapcenter
1514 branchContextMenu =new QMenu (this);
1517 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1518 branchAddContextMenu->addAction (actionEditPaste );
1519 branchAddContextMenu->addAction ( actionEditAddBranch );
1520 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1521 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1522 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1523 branchAddContextMenu->addSeparator();
1524 branchAddContextMenu->addAction ( actionEditLoadImage);
1525 branchAddContextMenu->addSeparator();
1526 branchAddContextMenu->addAction ( actionEditLoadImage);
1527 branchAddContextMenu->addAction ( actionEditImportAdd );
1528 branchAddContextMenu->addAction ( actionEditImportReplace );
1531 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1532 branchRemoveContextMenu->addAction (actionEditCut);
1533 branchRemoveContextMenu->addAction ( actionEditDelete );
1534 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1535 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1538 actionEditSaveBranch->addTo( branchContextMenu );
1540 branchContextMenu->addSeparator();
1541 branchContextMenu->addAction ( actionEditOpenURL );
1542 branchContextMenu->addAction ( actionEditOpenURLTab );
1543 branchContextMenu->addAction ( actionEditURL );
1544 branchContextMenu->addAction ( actionEditHeading2URL );
1545 branchContextMenu->addAction ( actionEditBugzilla2URL );
1546 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1548 branchContextMenu->addAction ( actionEditFATE2URL );
1550 branchContextMenu->addSeparator();
1551 branchContextMenu->addAction ( actionEditOpenVymLink );
1552 branchContextMenu->addAction ( actionEditVymLink );
1553 branchContextMenu->addAction ( actionEditDeleteVymLink );
1555 branchContextMenu->addSeparator();
1556 branchContextMenu->addAction ( actionFormatFrameNone );
1557 branchContextMenu->addAction ( actionFormatFrameRectangle);
1559 branchContextMenu->addSeparator();
1560 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1561 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1562 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1564 // Context Menu for links in a branch menu
1565 // This will be populated "on demand" in MapEditor::updateActions
1566 branchContextMenu->addSeparator();
1567 branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1568 branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1569 connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1570 connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1572 // Context menu for floatimage
1573 floatimageContextMenu =new QMenu (this);
1574 a= new QAction (tr ("Save image"),this);
1575 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1576 floatimageContextMenu->addAction (a);
1578 floatimageContextMenu->addSeparator();
1579 actionEditCopy->addTo( floatimageContextMenu );
1580 actionEditCut->addTo( floatimageContextMenu );
1582 floatimageContextMenu->addSeparator();
1583 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1586 // Context menu for canvas
1587 canvasContextMenu =new QMenu (this);
1588 actionEditMapInfo->addTo( canvasContextMenu );
1589 canvasContextMenu->insertSeparator();
1590 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1591 canvasContextMenu->insertSeparator();
1592 actionFormatLinkColorHint->addTo( canvasContextMenu );
1593 actionFormatLinkColor->addTo( canvasContextMenu );
1594 actionFormatBackColor->addTo( canvasContextMenu );
1596 // Menu for last opened files
1597 // Read settings initially
1599 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1600 for (int i=1;i<=j;i++)
1602 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1603 if (!s.isEmpty() && j<=maxLastMaps)
1606 setupLastMapsMenu();
1607 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1610 void Main::setupLastMapsMenu()
1612 // Remove double entries
1613 QStringList::Iterator it=lastMaps.begin();
1614 QStringList::Iterator jt;
1615 while (it!=lastMaps.end() )
1619 while (jt!=lastMaps.end() )
1622 jt=lastMaps.remove(jt);
1629 // Limit length of list to maxLastMaps
1630 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1632 // build Menu from lastMaps string list
1633 fileLastMapsMenu->clear();
1634 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1635 fileLastMapsMenu->addAction (*it );
1638 void Main::hideEvent (QHideEvent * )
1640 if (!textEditor->isMinimized() ) textEditor->hide();
1643 void Main::showEvent (QShowEvent * )
1645 if (textEditor->showWithMain()) textEditor->showNormal();
1648 bool Main::reallyWriteDirectory(const QString &dir)
1650 QStringList eList = QDir(dir).entryList();
1651 if (eList.first() ==".") eList.pop_front(); // remove "."
1652 if (eList.first() =="..") eList.pop_front(); // remove "."
1653 if (!eList.isEmpty())
1655 QMessageBox mb( __VYM,
1656 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1657 QMessageBox::Warning,
1659 QMessageBox::Cancel | QMessageBox::Default,
1660 QMessageBox::QMessageBox::NoButton );
1662 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1663 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1666 case QMessageBox::Yes:
1669 case QMessageBox::Cancel:
1677 QString Main::browseDirectory (const QString &caption)
1679 Q3FileDialog fd(this,caption);
1680 fd.setMode (Q3FileDialog::DirectoryOnly);
1681 fd.setCaption(__VYM " - "+caption);
1684 if ( fd.exec() == QDialog::Accepted )
1685 return fd.selectedFile();
1690 MapEditor* Main::currentMapEditor() const
1692 if ( tabWidget->currentPage() &&
1693 tabWidget->currentPage()->inherits( "MapEditor" ) )
1694 return (MapEditor*)tabWidget->currentPage();
1698 //TODO not used now, maybe use this for overview window later
1699 void Main::newView()
1701 // Open a new view... have it delete when closed.
1702 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1703 qApp->setMainWidget(m);
1705 qApp->setMainWidget(0);
1708 void Main::editorChanged(QWidget *)
1710 // Unselect all possibly selected objects
1711 // (Important to update note editor)
1714 for (i=0;i<=tabWidget->count() -1;i++)
1717 me=(MapEditor*)tabWidget->page(i);
1720 currentMapEditor()->reselect();
1722 // Update actions to in menus and toolbars according to editor
1723 currentMapEditor()->updateActions();
1726 void Main::fileNew()
1728 QString fn="unnamed";
1729 MapEditor* medit = new MapEditor ( NULL,true);
1730 tabWidget->addTab (medit,fn);
1731 tabWidget->showPage(medit);
1732 medit->viewport()->setFocus();
1733 // For the very first map we do not have flagrows yet...
1734 medit->select("mc:");
1737 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1739 ErrorCode err=success;
1741 // fn is usually the archive, mapfile the file after uncompressing
1744 // Make fn absolute (needed for unzip)
1745 fn=QDir (fn).absPath();
1751 // Check, if map is already loaded
1753 while (i<=tabWidget->count() -1)
1755 me=(MapEditor*)tabWidget->page(i);
1756 if (me->getFilePath() == fn)
1758 // Already there, ask for confirmation
1759 QMessageBox mb( __VYM,
1760 tr("The map %1\nis already opened."
1761 "Opening the same map in multiple editors may lead \n"
1762 "to confusion when finishing working with vym."
1763 "Do you want to").arg(fn),
1764 QMessageBox::Warning,
1765 QMessageBox::Yes | QMessageBox::Default,
1766 QMessageBox::Cancel | QMessageBox::Escape,
1767 QMessageBox::NoButton);
1768 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1769 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1772 case QMessageBox::Yes:
1774 i=tabWidget->count();
1776 case QMessageBox::Cancel:
1788 if ( !fn.isEmpty() )
1790 me = currentMapEditor();
1791 int tabIndex=tabWidget->currentPageIndex();
1792 // Check first, if mapeditor exists
1793 // If it is not default AND we want a new map,
1794 // create a new mapeditor in a new tab
1795 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1797 me= new MapEditor ( NULL,true);
1798 tabWidget->addTab (me,fn);
1799 tabIndex=tabWidget->indexOf (me);
1800 tabWidget->setCurrentPage (tabIndex);
1803 // Check, if file exists (important for creating new files
1804 // from command line
1805 if (!QFile(fn).exists() )
1807 QMessageBox mb( __VYM,
1808 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1809 QMessageBox::Question,
1811 QMessageBox::Cancel | QMessageBox::Default,
1812 QMessageBox::NoButton );
1814 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1815 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1818 case QMessageBox::Yes:
1820 currentMapEditor()->setFilePath(fn);
1821 tabWidget->setTabLabel (currentMapEditor(),
1822 currentMapEditor()->getFileName() );
1823 statusBar()->message( "Created " + fn , statusbarTime );
1826 case QMessageBox::Cancel:
1827 // don't create new map
1828 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1835 //tabWidget->currentPage() won't be NULL here, because of above...
1836 tabWidget->showPage(me);
1837 me->viewport()->setFocus();
1839 // Create temporary directory for packing
1840 char tmpdir1[]="/tmp/vym-XXXXXX";
1841 QString tmpMapDir=mkdtemp(tmpdir1);
1843 // Try to unzip file
1844 err=unzipDir (tmpMapDir,fn);
1848 me->setZipped(false);
1851 me->setZipped(true);
1853 // Look for mapname.xml
1854 mapfile= fn.left(fn.findRev(".",-1,true));
1855 mapfile=mapfile.section( '/', -1 );
1856 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1857 if (!file.exists() )
1859 // mapname.xml does not exist, well,
1860 // maybe some renamed the mapname.vym file...
1861 // Try to find any .xml in the toplevel
1862 // directory of the .vym file
1863 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1864 if (flist.count()==1)
1866 // Only one entry, take this one
1867 mapfile=tmpMapDir + "/"+flist.first();
1870 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1871 *it=tmpMapDir + "/" + *it;
1872 // TODO Multiple entries, load all (but only the first one into this ME)
1873 //mainWindow->fileLoadFromTmp (flist);
1874 //returnCode=1; // Silently forget this attempt to load
1875 qWarning ("MainWindow::load (fn) multimap found...");
1878 if (flist.isEmpty() )
1880 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1881 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1884 } //file doesn't exist
1886 mapfile=file.name();
1891 // Save existing filename in case we import
1892 QString fn_org=me->getFilePath();
1894 // Finally load map into mapEditor
1895 me->setFilePath (mapfile,fn);
1896 err=me->load(mapfile,lmode);
1898 // Restore old (maybe empty) filepath, if this is an import
1900 me->setFilePath (fn_org);
1903 // Finally check for errors and go home
1906 if (lmode==NewMap) fileCloseMap();
1907 statusBar()->message( "Could not load " + fn, statusbarTime );
1912 me->setFilePath (fn);
1913 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1914 if (fn.left(9)!="/tmp/vym-")
1916 // Only append to lastMaps if not loaded from a tmpDir
1917 // e.g. imported bookmarks are in a tmpDir
1918 lastMaps.prepend(me->getFilePath() );
1919 setupLastMapsMenu();
1921 actionFilePrint->setEnabled (true);
1923 statusBar()->message( "Loaded " + fn, statusbarTime );
1927 removeDir (QDir(tmpMapDir));
1933 void Main::fileLoad(const LoadMode &lmode)
1935 Q3FileDialog *fd=new Q3FileDialog( this);
1936 fd->setDir (lastFileDir);
1937 fd->setMode (Q3FileDialog::ExistingFiles);
1938 fd->addFilter ("XML (*.xml)");
1939 fd->addFilter ("VYM map (*.vym *.vyp)");
1943 fd->setCaption(tr("Load vym map"));
1946 fd->setCaption(tr("Import: Add vym map to selection"));
1949 fd->setCaption(tr("Import: Replace selection with vym map"));
1955 if ( fd->exec() == QDialog::Accepted )
1957 lastFileDir=fd->dirPath();
1958 QStringList flist = fd->selectedFiles();
1959 QStringList::Iterator it = flist.begin();
1960 while( it != flist.end() )
1963 fileLoad(*it, lmode);
1970 void Main::fileLoad()
1975 void Main::fileLoadLast(QAction *a)
1977 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1980 void Main::fileSave(const SaveMode &savemode)
1982 // tmp dir for zipping
1986 ErrorCode err=success;
1988 QString safeFilePath;
1990 bool saveZipped=currentMapEditor()->saveZipped();
1992 MapEditor * me=currentMapEditor();
1995 QString fn=me->getFilePath();
1996 // filename=unnamed, filepath="" in constructor...
1997 if ( !fn.isEmpty() )
1999 // We have a filepath, go on saving
2000 // First remove existing file, we
2001 // don't want to add to old zip archives
2005 QMessageBox::warning( 0, tr( "Save Error" ),
2006 fn+ tr("\ncould not be removed before saving"));
2008 // Look, if we should zip the data:
2011 QMessageBox mb( __VYM,
2012 tr("The map %1\ndid not use the compressed "
2013 "vym file format.\nWriting it uncompressed will also write images \n"
2014 "and flags and thus may overwrite files in the "
2015 "given directory\n\nDo you want to write the map").arg(fn),
2016 QMessageBox::Warning,
2017 QMessageBox::Yes | QMessageBox::Default,
2019 QMessageBox::Cancel | QMessageBox::Escape);
2020 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2021 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2022 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2025 case QMessageBox::Yes:
2026 // save compressed (default file format)
2029 case QMessageBox::No:
2030 // save uncompressed
2033 case QMessageBox::Cancel:
2042 char tmpdir1[]="/tmp/vym-XXXXXX";
2043 tmpMapDir=mkdtemp(tmpdir1);
2045 safeFilePath=me->getFilePath();
2046 me->setFilePath (tmpMapDir+"/"+
2047 me->getMapName()+ ".xml",
2049 me->save (savemode);
2050 me->setFilePath (safeFilePath);
2052 zipDir (tmpMapDir,fn);
2057 safeFilePath=me->getFilePath();
2058 me->setFilePath (fn, safeFilePath);
2059 me->save (savemode);
2060 me->setFilePath (safeFilePath);
2062 } // filepath available
2065 // We have no filepath yet,
2066 // call fileSaveAs() now, this will call fileSave()
2068 fileSaveAs(savemode);
2072 if (saveZipped && !tmpMapDir.isEmpty())
2074 removeDir (QDir(tmpMapDir));
2078 statusBar()->message(
2079 tr("Saved %1").arg(me->getFilePath()),
2081 lastMaps.prepend(me->getFilePath() );
2082 setupLastMapsMenu();
2084 statusBar()->message(
2085 tr("Couldn't save ").arg(me->getFilePath()),
2089 void Main::fileSave()
2091 fileSave (CompleteMap);
2094 void Main::fileSaveAs(const SaveMode& savemode)
2098 if (currentMapEditor())
2100 if (savemode==CompleteMap)
2101 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2103 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2104 if ( !fn.isEmpty() )
2106 // Check for existing file
2107 if (QFile (fn).exists())
2109 QMessageBox mb( __VYM,
2110 tr("The file %1\nexists already. Do you want to").arg(fn),
2111 QMessageBox::Warning,
2112 QMessageBox::Yes | QMessageBox::Default,
2113 QMessageBox::Cancel | QMessageBox::Escape,
2114 QMessageBox::NoButton);
2115 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2116 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2119 case QMessageBox::Yes:
2122 case QMessageBox::Cancel:
2129 // New file, add extension to filename, if missing
2130 // This is always .vym or .vyp, depending on savemode
2131 if (savemode==CompleteMap)
2133 if (!fn.contains (".vym") && !fn.contains (".xml"))
2137 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2146 currentMapEditor()->setFilePath(fn);
2150 if (savemode==CompleteMap)
2151 tabWidget->setTabLabel (currentMapEditor(),
2152 currentMapEditor()->getFileName() );
2158 void Main::fileSaveAs()
2160 fileSaveAs (CompleteMap);
2163 void Main::fileImportKDEBookmarks()
2165 ImportKDEBookmarks im;
2167 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2168 currentMapEditor()->setFilePath ("");
2171 void Main::fileImportFirefoxBookmarks()
2173 Q3FileDialog *fd=new Q3FileDialog( this);
2174 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2175 fd->setMode (Q3FileDialog::ExistingFiles);
2176 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2177 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2180 if ( fd->exec() == QDialog::Accepted )
2182 ImportFirefoxBookmarks im;
2183 QStringList flist = fd->selectedFiles();
2184 QStringList::Iterator it = flist.begin();
2185 while( it != flist.end() )
2188 if (im.transform() &&
2189 success==fileLoad (im.getTransformedFile(),NewMap) &&
2190 currentMapEditor() )
2191 currentMapEditor()->setFilePath ("");
2198 void Main::fileImportMM()
2202 Q3FileDialog *fd=new Q3FileDialog( this);
2203 fd->setDir (lastFileDir);
2204 fd->setMode (Q3FileDialog::ExistingFiles);
2205 fd->addFilter ("Mind Manager (*.mmap)");
2206 fd->setCaption(tr("Import")+" "+"Mind Manager");
2209 if ( fd->exec() == QDialog::Accepted )
2211 lastFileDir=fd->dirPath();
2212 QStringList flist = fd->selectedFiles();
2213 QStringList::Iterator it = flist.begin();
2214 while( it != flist.end() )
2217 if (im.transform() &&
2218 success==fileLoad (im.getTransformedFile(),NewMap) &&
2219 currentMapEditor() )
2220 currentMapEditor()->setFilePath ("");
2229 void Main::fileImportDir()
2231 if (currentMapEditor())
2232 currentMapEditor()->importDir();
2235 void Main::fileExportXML()
2237 if (currentMapEditor())
2239 QString dir=browseDirectory(tr("Export XML to directory"));
2240 if (dir !="" && reallyWriteDirectory(dir) )
2241 currentMapEditor()->exportXML(dir);
2246 void Main::fileExportXHTML()
2248 MapEditor *me=currentMapEditor();
2252 ExportXHTMLDialog dia(this);
2253 dia.setFilePath (me->getFilePath() );
2254 dia.setMapName (me->getMapName() );
2257 if (dia.exec()==QDialog::Accepted)
2259 QString dir=dia.getDir();
2260 // Check, if warnings should be used before overwriting
2261 // the output directory
2264 ok=reallyWriteDirectory(dir);
2270 me->exportXML (dia.getDir() );
2271 dia.doExport(me->getMapName() );
2272 if (dia.hasChanged())
2279 void Main::fileExportImage()
2281 MapEditor *me=currentMapEditor();
2285 QFileDialog *fd=new QFileDialog (this);
2286 fd->setCaption (tr("Export map as image"));
2287 fd->setFileMode(QFileDialog::AnyFile);
2288 fd->setFilters (imageIO.getFilters() );
2289 fd->setDirectory (lastImageDir);
2292 fl=fd->selectedFiles();
2293 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2294 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2299 void Main::fileExportASCII()
2301 MapEditor *me=currentMapEditor();
2305 ex.setMapCenter(me->getMapCenter());
2306 ex.addFilter ("TXT (*.txt)");
2307 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2308 if (ex.execDialog() )
2310 me->setExportMode(true);
2312 me->setExportMode(false);
2317 void Main::fileExportLaTeX()
2319 MapEditor *me=currentMapEditor();
2323 ex.setMapCenter(me->getMapCenter());
2324 ex.addFilter ("Tex (*.tex)");
2325 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2326 if (ex.execDialog() )
2328 me->setExportMode(true);
2330 me->setExportMode(false);
2335 void Main::fileExportKDEBookmarks()
2337 ExportKDEBookmarks ex;
2338 MapEditor *me=currentMapEditor();
2341 ex.setMapCenter (me->getMapCenter() );
2346 void Main::fileExportTaskjuggler()
2348 ExportTaskjuggler ex;
2349 MapEditor *me=currentMapEditor();
2352 ex.setMapCenter (me->getMapCenter() );
2353 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2354 ex.addFilter ("Taskjuggler (*.tjp)");
2355 if (ex.execDialog() )
2357 me->setExportMode(true);
2359 me->setExportMode(false);
2364 void Main::fileExportOOPresentation()
2366 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2367 // TODO add preview in dialog
2368 //ImagePreview *p =new ImagePreview (fd);
2369 //fd->setContentsPreviewEnabled( TRUE );
2370 //fd->setContentsPreview( p, p );
2371 //fd->setPreviewMode( QFileDialog::Contents );
2372 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2373 fd->setDir (QDir().current());
2374 if (fd->foundConfig())
2378 if ( fd->exec() == QDialog::Accepted )
2380 QString fn=fd->selectedFile();
2381 //lastImageDir=fn.left(fn.findRev ("/"));
2382 if (currentMapEditor())
2383 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2387 QMessageBox::warning(0,
2389 tr("Couldn't find configuration for export to Open Office\n"));
2393 void Main::fileCloseMap()
2395 if (currentMapEditor())
2397 if (currentMapEditor()->hasChanged())
2399 QMessageBox mb( __VYM,
2400 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2401 QMessageBox::Warning,
2402 QMessageBox::Yes | QMessageBox::Default,
2404 QMessageBox::Cancel | QMessageBox::Escape );
2405 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2406 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2409 case QMessageBox::Yes:
2411 fileSave(CompleteMap);
2413 case QMessageBox::No:
2414 // close without saving
2416 case QMessageBox::Cancel:
2421 currentMapEditor()->closeMap();
2422 tabWidget->removePage(currentMapEditor());
2423 if (tabWidget->count()==0)
2424 actionFilePrint->setEnabled (false);
2428 void Main::filePrint()
2430 if (currentMapEditor())
2431 currentMapEditor()->print();
2434 void Main::fileExitVYM()
2436 // Check if one or more editors have changed
2439 for (i=0;i<=tabWidget->count() -1;i++)
2442 me=(MapEditor*)tabWidget->page(i);
2444 // If something changed, ask what to do
2445 if (me->isUnsaved())
2447 tabWidget->setCurrentPage(i);
2448 QMessageBox mb( __VYM,
2449 tr("This map is not saved yet. Do you want to"),
2450 QMessageBox::Warning,
2451 QMessageBox::Yes | QMessageBox::Default,
2453 QMessageBox::Cancel | QMessageBox::Escape );
2454 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2455 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2457 mb.setActiveWindow();
2458 switch( mb.exec() ) {
2459 case QMessageBox::Yes:
2460 // save (the changed editors) and exit
2461 fileSave(CompleteMap);
2463 case QMessageBox::No:
2464 // exit without saving
2466 case QMessageBox::Cancel:
2467 // don't save and don't exit
2471 } // loop over all MEs
2475 void Main::editUndo()
2477 if (currentMapEditor())
2478 currentMapEditor()->undo();
2481 void Main::editRedo()
2483 if (currentMapEditor())
2484 currentMapEditor()->redo();
2487 void Main::editCopy()
2489 if (currentMapEditor())
2490 currentMapEditor()->copy();
2493 void Main::editPaste()
2495 if (currentMapEditor())
2496 currentMapEditor()->paste();
2499 void Main::editCut()
2501 if (currentMapEditor())
2502 currentMapEditor()->cut();
2505 void Main::editOpenFindWindow()
2507 findWindow->popup();
2508 findWindow->raise();
2509 findWindow->setActiveWindow();
2512 void Main::editFind(QString s)
2515 BranchObj *bo=currentMapEditor()->findText(s, cs);
2518 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2521 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2522 tr("No matches found for \"%1\"").arg(s));
2526 void Main::editFindChanged()
2527 { // Notify editor, to abort the current find process
2528 currentMapEditor()->findReset();
2531 void Main::editOpenURL()
2534 if (currentMapEditor())
2536 QString url=currentMapEditor()->getURL();
2537 if (url=="") return;
2538 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2539 procBrowser = new Q3Process( this );
2541 procBrowser->addArgument( browser);
2542 procBrowser->addArgument( url);
2544 if ( !procBrowser->start() )
2546 // try to set path to browser
2547 QMessageBox::warning(0,
2549 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2550 tr("Please use Settings->")+tr("Set application to open an URL"));
2555 void Main::editOpenURLTab()
2557 if (currentMapEditor())
2559 QString url=currentMapEditor()->getURL();
2560 if (url=="") return;
2561 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2562 if (procBrowser && procBrowser->isRunning())
2564 if (browser.contains("konqueror"))
2566 // Try to open new tab in existing konqueror started previously by vym
2567 Q3Process *p=new Q3Process (this);
2568 p->addArgument ("dcop");
2569 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2570 p->addArgument ("konqueror-mainwindow#1");
2571 p->addArgument ("newTab");
2572 p->addArgument (url);
2574 // try to set browser
2575 QMessageBox::warning(0,
2577 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2579 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2581 // Try to open new tab in firefox
2582 Q3Process *p=new Q3Process (this);
2583 p->addArgument (browser);
2584 p->addArgument ("-remote");
2585 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2587 // try to set browser
2588 QMessageBox::warning(0,
2590 tr("Couldn't start %1 to open a new tab").arg(browser));
2599 void Main::editURL()
2601 if (currentMapEditor())
2602 currentMapEditor()->editURL();
2605 void Main::editHeading2URL()
2607 if (currentMapEditor())
2608 currentMapEditor()->editHeading2URL();
2611 void Main::editBugzilla2URL()
2613 if (currentMapEditor())
2614 currentMapEditor()->editBugzilla2URL();
2617 void Main::editFATE2URL()
2619 if (currentMapEditor())
2620 currentMapEditor()->editFATE2URL();
2623 void Main::editOpenVymLink()
2625 // Get current path to map
2626 QString currentVymLink;
2627 if (currentMapEditor())
2629 currentVymLink=currentMapEditor()->getVymLink();
2630 // compare path with already loaded maps
2634 for (i=0;i<=tabWidget->count() -1;i++)
2636 me=(MapEditor*)tabWidget->page(i);
2637 if (currentVymLink==me->getFilePath() )
2646 if (!QFile(currentVymLink).exists() )
2647 QMessageBox::critical( 0, tr( "Critical Error" ),
2648 tr("Couldn't open map %1").arg(currentVymLink));
2651 fileLoad (currentVymLink, NewMap);
2652 tabWidget->setCurrentPage (tabWidget->count()-1);
2655 // Go to tab containing the map
2656 tabWidget->setCurrentPage (index);
2660 void Main::editVymLink()
2662 if (currentMapEditor())
2663 currentMapEditor()->editVymLink();
2666 void Main::editDeleteVymLink()
2668 if (currentMapEditor())
2669 currentMapEditor()->deleteVymLink();
2672 void Main::editToggleHideExport()
2674 if (currentMapEditor())
2675 currentMapEditor()->toggleHideExport();
2678 void Main::editMapInfo()
2680 if (currentMapEditor())
2681 currentMapEditor()->editMapInfo();
2684 void Main::editMoveUp()
2686 if (currentMapEditor())
2687 currentMapEditor()->moveBranchUp();
2690 void Main::editMoveDown()
2692 if (currentMapEditor())
2693 currentMapEditor()->moveBranchDown();
2696 void Main::editToggleScroll()
2698 if (currentMapEditor())
2700 currentMapEditor()->toggleScroll();
2704 void Main::editUnScrollAll()
2706 if (currentMapEditor())
2708 currentMapEditor()->unScrollAll();
2712 void Main::editHeading()
2714 if (currentMapEditor())
2715 currentMapEditor()->editHeading();
2718 void Main::editNewBranch()
2720 if (currentMapEditor())
2721 currentMapEditor()->addNewBranch(0);
2724 void Main::editNewBranchHere()
2726 if (currentMapEditor())
2727 currentMapEditor()->addNewBranchHere();
2730 void Main::editNewBranchAbove()
2732 if (currentMapEditor())
2733 currentMapEditor()->addNewBranch(-1);
2736 void Main::editNewBranchBelow()
2738 if (currentMapEditor())
2739 currentMapEditor()->addNewBranch(1);
2742 void Main::editImportAdd()
2744 fileLoad (ImportAdd);
2747 void Main::editImportReplace()
2749 fileLoad (ImportReplace);
2752 void Main::editSaveBranch()
2754 fileSaveAs (PartOfMap);
2757 void Main::editRemoveBranchKeepChilds()
2759 if (currentMapEditor())
2760 currentMapEditor()->removeBranchKeepChilds();
2763 void Main::editRemoveChilds()
2765 if (currentMapEditor())
2766 currentMapEditor()->removeChilds();
2769 void Main::editDeleteSelection()
2771 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2772 currentMapEditor()->deleteSelection();
2775 void Main::editUpperBranch()
2777 if (currentMapEditor())
2778 currentMapEditor()->selectUpperBranch();
2781 void Main::editLowerBranch()
2783 if (currentMapEditor())
2784 currentMapEditor()->selectLowerBranch();
2787 void Main::editLeftBranch()
2789 if (currentMapEditor())
2790 currentMapEditor()->selectLeftBranch();
2793 void Main::editRightBranch()
2795 if (currentMapEditor())
2796 currentMapEditor()->selectRightBranch();
2799 void Main::editFirstBranch()
2801 if (currentMapEditor())
2802 currentMapEditor()->selectFirstBranch();
2805 void Main::editLastBranch()
2807 if (currentMapEditor())
2808 currentMapEditor()->selectLastBranch();
2811 void Main::editLoadImage()
2813 if (currentMapEditor())
2814 currentMapEditor()->loadFloatImage();
2817 void Main::editSaveImage()
2819 if (currentMapEditor())
2820 currentMapEditor()->saveFloatImage();
2823 void Main::editFollowXLink(QAction *a)
2826 if (currentMapEditor())
2827 currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
2830 void Main::editEditXLink(QAction *a)
2832 if (currentMapEditor())
2833 currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
2836 void Main::formatSelectColor()
2838 if (currentMapEditor())
2840 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2841 if ( !col.isValid() ) return;
2842 currentMapEditor()->setColor( col );
2843 colorChanged( col );
2847 void Main::formatPickColor()
2849 if (currentMapEditor())
2850 colorChanged( currentMapEditor()->pickColor() );
2853 void Main::colorChanged(QColor c)
2855 QPixmap pix( 16, 16 );
2857 actionFormatColor->setIconSet( pix );
2860 void Main::formatColorItem()
2862 if (currentMapEditor())
2863 currentMapEditor()->colorItem();
2866 void Main::formatColorBranch()
2868 if (currentMapEditor())
2869 currentMapEditor()->colorBranch();
2872 void Main::formatLinkStyleLine()
2874 if (currentMapEditor())
2875 currentMapEditor()->setLinkStyle(StyleLine);
2878 void Main::formatLinkStyleParabel()
2880 if (currentMapEditor())
2881 currentMapEditor()->setLinkStyle(StyleParabel);
2884 void Main::formatLinkStylePolyLine()
2886 if (currentMapEditor())
2887 currentMapEditor()->setLinkStyle(StylePolyLine);
2890 void Main::formatLinkStylePolyParabel()
2892 if (currentMapEditor())
2893 currentMapEditor()->setLinkStyle(StylePolyParabel);
2896 void Main::formatSelectBackColor()
2898 if (currentMapEditor())
2899 currentMapEditor()->selectBackgroundColor();
2902 void Main::formatSelectLinkColor()
2904 if (currentMapEditor())
2905 currentMapEditor()->selectLinkColor();
2908 void Main::formatToggleLinkColorHint()
2910 currentMapEditor()->toggleLinkColorHint();
2913 void Main::formatFrameNone()
2915 if (currentMapEditor())
2916 currentMapEditor()->setFrame(NoFrame);
2919 void Main::formatFrameRectangle()
2921 if (currentMapEditor())
2922 currentMapEditor()->setFrame(Rectangle);
2925 void Main::formatIncludeImagesVer()
2927 if (currentMapEditor())
2928 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2931 void Main::formatIncludeImagesHor()
2933 if (currentMapEditor())
2934 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2937 void Main::formatHideLinkUnselected()
2939 if (currentMapEditor())
2940 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2943 void Main::viewZoomReset()
2945 if (currentMapEditor())
2949 currentMapEditor()->setWorldMatrix( m );
2950 currentMapEditor()->setViewCenter();
2951 currentMapEditor()->adjustCanvasSize();
2955 void Main::viewZoomIn()
2957 if (currentMapEditor())
2959 QMatrix m = currentMapEditor()->worldMatrix();
2960 m.scale( 1.25, 1.25 );
2961 currentMapEditor()->setWorldMatrix( m );
2962 currentMapEditor()->setViewCenter();
2963 currentMapEditor()->adjustCanvasSize();
2967 void Main::viewZoomOut()
2969 if (currentMapEditor())
2971 QMatrix m = currentMapEditor()->worldMatrix();
2972 m.scale( 0.8, 0.8 );
2973 currentMapEditor()->setWorldMatrix( m );
2974 currentMapEditor()->setViewCenter();
2975 currentMapEditor()->adjustCanvasSize();
2979 void Main::modModeColor()
2983 void Main::modModeLink()
2987 bool Main::settingsPDF()
2989 // Default browser is set in constructor
2991 QString text = QInputDialog::getText(
2992 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2993 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2995 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
3000 bool Main::settingsURL()
3002 // Default browser is set in constructor
3004 QString text = QInputDialog::getText(
3005 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3006 settings.readEntry("/vym/mainwindow/readerURL")
3009 settings.writeEntry ("/vym/mainwindow/readerURL",text);
3013 void Main::settingsToggleDelKey()
3015 if (actionSettingsUseDelKey->isOn())
3017 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3020 actionEditDelete->setAccel (QKeySequence (""));
3024 void Main::windowToggleNoteEditor()
3026 if (textEditor->showWithMain() )
3027 windowHideNoteEditor();
3029 windowShowNoteEditor();
3032 void Main::windowToggleHistory()
3034 if (currentMapEditor())
3035 currentMapEditor()->toggleHistoryWindow();
3038 void Main::updateNoteFlag()
3040 if (currentMapEditor())
3041 currentMapEditor()->updateNoteFlag();
3044 void Main::windowShowNoteEditor()
3046 textEditor->setShowWithMain(true);
3048 actionViewToggleNoteEditor->setOn (true);
3051 void Main::windowHideNoteEditor()
3053 textEditor->setShowWithMain(false);
3055 actionViewToggleNoteEditor->setOn (false);
3058 void Main::windowNextEditor()
3060 if (tabWidget->currentPageIndex() < tabWidget->count())
3061 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3064 void Main::windowPreviousEditor()
3066 if (tabWidget->currentPageIndex() >0)
3067 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3070 void Main::standardFlagChanged()
3072 currentMapEditor()->toggleStandardFlag(sender()->name());
3075 void Main::testFunction()
3077 cout <<TB_standardFlags->pos()<<endl;
3078 //currentMapEditor()->testFunction();
3081 void Main::helpDoc()
3084 #if defined(Q_OS_MACX)
3085 docpath="./vym.app/Contents/vym.pdf";
3087 // default path in SUSE LINUX
3088 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3091 if (!QFile (docpath).exists() )
3093 // relative path for easy testing in tarball
3094 docpath="doc/vym.pdf";
3095 if (!QFile (docpath).exists() )
3097 // relative path for testing while still writing vym.tex
3098 docpath="doc/tex/vym.pdf";
3099 if (!QFile (docpath).exists() )
3101 // Try yet another one for Knoppix
3102 docpath="/usr/share/doc/packages/vym/vym.pdf";
3103 if (!QFile (docpath).exists() )
3105 QMessageBox::critical(0,
3106 tr("Critcal error"),
3107 tr("Couldn't find the documentation\n"
3108 "vym.pdf in various places."));
3115 Process *pdfProc = new Process();
3116 pdfProc->clearArguments();
3117 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
3118 pdfProc->addArgument( docpath);
3120 if ( !pdfProc->start() )
3123 QMessageBox::warning(0,
3125 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3126 tr("Please use Settings->")+tr("Set application to open PDF files"));
3133 void Main::helpAbout()
3136 ad.setName ("aboutwindow");
3137 ad.setMinimumSize(500,500);
3138 ad.resize (QSize (500,500));
3142 void Main::helpAboutQT()
3144 QMessageBox::aboutQt( this, "Qt Application Example" );