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->setEnabled (false);
687 actionListBranches.append(a);
688 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
691 a = new QAction( tr( "Use heading for URL" ), this);
692 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
693 a->setEnabled (false);
694 actionListBranches.append(a);
695 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
696 actionEditHeading2URL=a;
698 a = new QAction(tr( "Create URL to Bugzilla" ), this);
699 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
700 a->setEnabled (false);
701 actionListBranches.append(a);
702 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
703 actionEditBugzilla2URL=a;
705 a = new QAction(tr( "Create URL to FATE" ), this);
706 a->setStatusTip ( tr( "Create URL to FATE" ));
707 a->setEnabled (false);
708 actionListBranches.append(a);
709 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
710 actionEditFATE2URL=a;
712 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
713 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
715 a->setEnabled (false);
716 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
717 actionEditOpenVymLink=a;
719 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
720 a->setEnabled (false);
721 a->setStatusTip ( tr( "Edit link to another vym map" ));
722 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
723 actionListBranches.append(a);
726 a = new QAction(tr( "Delete vym link" ),this);
727 a->setStatusTip ( tr( "Delete link to another vym map" ));
728 a->setEnabled (false);
729 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
730 actionEditDeleteVymLink=a;
732 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
733 a->setStatusTip ( tr( "Hide object in exports" ) );
734 a->setShortcut (Qt::Key_H );
735 a->setToggleAction(true);
737 a->setEnabled (false);
738 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
739 actionEditToggleHideExport=a;
741 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
742 a->setStatusTip ( tr( "Edit Map Info" ));
743 a->setEnabled (true);
744 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
747 editMenu->addSeparator();
749 // Import at selection (adding to selection)
750 a = new QAction( tr( "Add map (insert)" ),this);
751 a->setStatusTip (tr( "Add map at selection" ));
752 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
753 a->setEnabled (false);
754 actionListBranches.append(a);
755 actionEditImportAdd=a;
757 // Import at selection (replacing selection)
758 a = new QAction( tr( "Add map (replace)" ), this);
759 a->setStatusTip (tr( "Replace selection with map" ));
760 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
761 a->setEnabled (false);
762 actionListBranches.append(a);
763 actionEditImportReplace=a;
766 a = new QAction( tr( "Save selection" ), this);
767 a->setStatusTip (tr( "Save selection" ));
768 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
769 a->setEnabled (false);
770 actionListBranches.append(a);
771 actionEditSaveBranch=a;
773 // Only remove branch, not its childs
774 a = new QAction(tr( "Remove only branch " ), this);
775 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
776 a->setShortcut (Qt::ALT + Qt::Key_Delete );
777 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
778 a->setEnabled (false);
779 actionListBranches.append(a);
780 actionEditRemoveBranchKeepChilds=a;
782 // Only remove childs of a branch
783 a = new QAction( tr( "Remove childs" ), this);
784 a->setStatusTip (tr( "Remove childs of branch" ));
785 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
786 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
787 a->setEnabled (false);
788 actionListBranches.append(a);
789 actionEditRemoveChilds=a;
791 // Shortcuts for navigating with cursor:
792 a = new QAction(tr( "Select upper branch" ), this);
793 a->setStatusTip ( tr( "Select upper branch" ));
794 a->setShortcut (Qt::Key_Up );
795 a->setShortcutContext (Qt::WindowShortcut);
797 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
798 a = new QAction( tr( "Select lower branch" ),this);
799 a->setStatusTip (tr( "Select lower branch" ));
800 a->setShortcut ( Qt::Key_Down );
801 a->setShortcutContext (Qt::WindowShortcut);
803 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
804 a = new QAction(tr( "Select left branch" ), this);
805 a->setStatusTip ( tr( "Select left branch" ));
806 a->setShortcut (Qt::Key_Left );
807 a->setShortcutContext (Qt::WindowShortcut);
809 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
810 a = new QAction( tr( "Select child branch" ), this);
811 a->setStatusTip (tr( "Select right branch" ));
812 a->setShortcut (Qt::Key_Right);
813 a->setShortcutContext (Qt::WindowShortcut);
815 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
816 a = new QAction( tr( "Select first branch" ), this);
817 a->setStatusTip (tr( "Select first branch" ));
818 a->setShortcut (Qt::Key_Home );
819 a->setShortcutContext (Qt::WindowShortcut);
821 a->setEnabled (false);
822 editMenu->addAction (a);
823 actionListBranches.append(a);
824 actionEditSelectFirst=a;
825 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
826 a = new QAction( tr( "Select last branch" ),this);
827 a->setStatusTip (tr( "Select last branch" ));
828 a->setShortcut ( Qt::Key_End );
829 a->setShortcutContext (Qt::WindowShortcut);
831 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
832 a->setEnabled (false);
833 editMenu->addAction (a);
834 actionListBranches.append(a);
835 actionEditSelectLast=a;
837 a = new QAction( tr( "Add Image" )+QString("..."), this);
838 a->setStatusTip (tr( "Add Image" ));
839 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
840 actionEditLoadImage=a;
845 void Main::setupFormatActions()
847 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
849 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
852 pix.fill (Qt::black);
853 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
854 a->setStatusTip ( tr( "Set Color" ));
855 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
857 formatMenu->addAction (a);
859 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
860 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
861 a->setShortcut (Qt::CTRL + Qt::Key_K );
862 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
863 a->setEnabled (false);
865 formatMenu->addAction (a);
866 actionListBranches.append(a);
867 actionFormatPickColor=a;
869 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
870 a->setStatusTip ( tr( "Color branch" ) );
871 a->setShortcut (Qt::CTRL + Qt::Key_I);
872 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
873 a->setEnabled (false);
875 formatMenu->addAction (a);
876 actionListBranches.append(a);
877 actionFormatColorBranch=a;
879 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
880 a->setStatusTip ( tr( "Color Subtree" ));
881 a->setShortcut (Qt::CTRL + Qt::Key_T);
882 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
883 a->setEnabled (false);
884 formatMenu->addAction (a);
886 actionListBranches.append(a);
887 actionFormatColorSubtree=a;
889 formatMenu->addSeparator();
890 actionGroupFormatLinkStyles=new QActionGroup ( this);
891 actionGroupFormatLinkStyles->setExclusive (true);
892 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
893 a->setStatusTip (tr( "Line" ));
894 a->setToggleAction(true);
895 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
896 formatMenu->addAction (a);
897 actionFormatLinkStyleLine=a;
898 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
899 a->setStatusTip (tr( "Line" ));
900 a->setToggleAction(true);
901 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
902 formatMenu->addAction (a);
903 actionFormatLinkStyleParabel=a;
904 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
905 a->setStatusTip (tr( "PolyLine" ));
906 a->setToggleAction(true);
907 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
908 formatMenu->addAction (a);
909 actionFormatLinkStylePolyLine=a;
910 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
911 a->setStatusTip (tr( "PolyParabel" ) );
912 a->setToggleAction(true);
913 a->setChecked (true);
914 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
915 formatMenu->addAction (a);
916 actionFormatLinkStylePolyParabel=a;
918 actionGroupFormatFrameTypes=new QActionGroup ( this);
919 actionGroupFormatFrameTypes->setExclusive (true);
920 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
921 a->setStatusTip (tr("No Frame"));
922 a->setToggleAction(true);
923 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
924 actionFormatFrameNone=a;
925 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
926 a->setStatusTip (tr( "Rectangle" ));
927 a->setToggleAction(true);
928 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
929 actionFormatFrameRectangle=a;
931 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
932 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
933 a->setToggleAction(true);
934 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
935 actionFormatIncludeImagesVer=a;
937 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
938 a->setStatusTip ( tr ("Include left and right position of images into branch"));
939 a->setToggleAction(true);
940 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
941 actionFormatIncludeImagesHor=a;
943 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
944 a->setStatusTip (tr( "Hide link" ));
945 a->setToggleAction(true);
946 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
947 actionFormatHideLinkUnselected=a;
949 formatMenu->addSeparator();
950 a= new QAction( tr( "&Use color of heading for link" ), this);
951 a->setStatusTip (tr( "Use same color for links and headings" ));
952 a->setToggleAction(true);
953 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
954 formatMenu->addAction (a);
955 actionFormatLinkColorHint=a;
957 pix.fill (Qt::white);
958 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
959 a->setStatusTip (tr( "Set Link Color" ));
960 formatMenu->addAction (a);
961 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
962 actionFormatLinkColor=a;
964 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
965 a->setStatusTip (tr( "Set Background Color" ));
966 formatMenu->addAction (a);
967 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
968 actionFormatBackColor=a;
972 void Main::setupViewActions()
974 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
975 tb->setLabel( "View Actions" );
976 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
979 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
980 a->setStatusTip ( tr( "Zoom reset" ) );
981 a->setShortcut (Qt::CTRL + Qt::Key_0 );
983 viewMenu->addAction (a);
984 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
986 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
987 a->setStatusTip (tr( "Zoom in" ));
988 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
990 viewMenu->addAction (a);
991 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
993 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
994 a->setStatusTip (tr( "Zoom out" ));
995 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
997 viewMenu->addAction (a);
998 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
1001 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1002 a->setStatusTip ( tr( "Show Note Editor" ));
1003 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1004 a->setToggleAction(true);
1005 if (textEditor->showWithMain())
1010 viewMenu->addAction (a);
1011 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
1012 actionViewToggleNoteEditor=a;
1014 a = new QAction( tr( "Show history window" ),this );
1015 a->setStatusTip ( tr( "Show history window" ));
1016 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1017 a->setToggleAction(false);
1018 viewMenu->addAction (a);
1019 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
1020 actionViewToggleHistoryWindow=a;
1022 a = new QAction(tr( "Next Window" ), this);
1023 a->setStatusTip ( tr( "&Next Window" ) );
1024 a->setShortcut (Qt::ALT + Qt::Key_N );
1025 viewMenu->addAction (a);
1026 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
1028 a = new QAction (tr( "Previous Window" ), this );
1029 a->setStatusTip (tr( "&Previous Window" ));
1030 a->setShortcut (Qt::ALT + Qt::Key_P );
1031 viewMenu->addAction (a);
1032 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
1036 void Main::setupModeActions()
1038 //QPopupMenu *menu = new QPopupMenu( this );
1039 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1041 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1043 actionGroupModModes=new QActionGroup ( this);
1044 actionGroupModModes->setExclusive (true);
1045 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1046 a->setShortcut (Qt::Key_J);
1047 a->setStatusTip ( tr( "Use modifier to color branches" ));
1048 a->setToggleAction(true);
1051 actionModModeColor=a;
1053 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1054 a->setShortcut( Qt::Key_K);
1055 a->setStatusTip( tr( "Use modifier to copy" ));
1056 a->setToggleAction(true);
1058 actionModModeCopy=a;
1060 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1061 a->setShortcut (Qt::Key_L);
1062 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1063 a->setToggleAction(true);
1065 actionModModeLink=a;
1069 void Main::setupFlagActions()
1071 // Create System Flags
1072 systemFlagsDefault = new FlagRowObj ();
1073 systemFlagsDefault->setVisibility (false);
1074 systemFlagsDefault->setName ("systemFlagsDef");
1076 FlagObj *fo = new FlagObj ();
1077 fo->load(QPixmap(flagsPath+"flag-note.png"));
1078 fo->setName("note");
1079 fo->setToolTip(tr("Note","Systemflag"));
1080 systemFlagsDefault->addFlag (fo); // makes deep copy
1082 fo->load(QPixmap(flagsPath+"flag-url.png"));
1084 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1085 systemFlagsDefault->addFlag (fo);
1087 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1088 fo->setName("vymLink");
1089 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1090 systemFlagsDefault->addFlag (fo);
1092 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1093 fo->setName("scrolledright");
1094 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1095 systemFlagsDefault->addFlag (fo);
1097 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1098 fo->setName("tmpUnscrolledright");
1099 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1100 systemFlagsDefault->addFlag (fo);
1102 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1103 fo->setName("hideInExport");
1104 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1105 systemFlagsDefault->addFlag (fo);
1107 // Create Standard Flags
1108 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1110 standardFlagsDefault = new FlagRowObj ();
1111 standardFlagsDefault->setVisibility (false);
1112 standardFlagsDefault->setName ("standardFlagsDef");
1113 standardFlagsDefault->setToolBar (tb);
1115 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1116 fo->setName ("exclamationmark");
1117 fo->setGroup("standard-mark");
1118 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1121 a->setCheckable(true);
1122 a->setObjectName(fo->getName());
1123 a->setToolTip(tr("Take care!","Standardflag"));
1124 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1125 standardFlagsDefault->addFlag (fo); // makes deep copy
1127 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1128 fo->setName("questionmark");
1129 fo->setGroup("standard-mark");
1130 a=new QAction (fo->getPixmap(),fo->getName(),this);
1133 a->setCheckable(true);
1134 a->setObjectName(fo->getName());
1135 a->setToolTip(tr("Really?","Standardflag"));
1136 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1137 standardFlagsDefault->addFlag (fo);
1139 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1140 fo->setName("hook-green");
1141 fo->setGroup("standard-hook");
1142 a=new QAction (fo->getPixmap(),fo->getName(),this);
1145 a->setCheckable(true);
1146 a->setObjectName(fo->getName());
1147 a->setToolTip(tr("ok!","Standardflag"));
1148 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1149 standardFlagsDefault->addFlag (fo);
1151 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1152 fo->setName("cross-red");
1153 fo->setGroup("standard-hook");
1154 a=new QAction (fo->getPixmap(),fo->getName(),this);
1157 a->setCheckable(true);
1158 a->setObjectName(fo->getName());
1159 a->setToolTip(tr("Not ok!","Standardflag"));
1160 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1161 standardFlagsDefault->addFlag (fo);
1163 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1164 fo->setName("stopsign");
1165 a=new QAction (fo->getPixmap(),fo->getName(),this);
1168 a->setCheckable(true);
1169 a->setObjectName(fo->getName());
1170 a->setToolTip(tr("This won't work!","Standardflag"));
1171 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1172 standardFlagsDefault->addFlag (fo);
1174 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1175 fo->setName("smiley-good");
1176 fo->setGroup("standard-smiley");
1177 a=new QAction (fo->getPixmap(),fo->getName(),this);
1180 a->setCheckable(true);
1181 a->setObjectName(fo->getName());
1182 a->setToolTip(tr("Good","Standardflag"));
1183 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1184 standardFlagsDefault->addFlag (fo);
1186 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1187 fo->setName("smiley-sad");
1188 fo->setGroup("standard-smiley");
1189 a=new QAction (fo->getPixmap(),fo->getName(),this);
1192 a->setCheckable(true);
1193 a->setObjectName(fo->getName());
1194 a->setToolTip(tr("Bad","Standardflag"));
1195 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1196 standardFlagsDefault->addFlag (fo);
1198 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1199 // Original omg.png (in KDE emoticons)
1200 fo->setName("smiley-omg");
1201 fo->setGroup("standard-smiley");
1202 a=new QAction (fo->getPixmap(),fo->getName(),this);
1205 a->setCheckable(true);
1206 a->setObjectName(fo->getName());
1207 a->setToolTip(tr("Oh no!","Standardflag"));
1208 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1209 standardFlagsDefault->addFlag (fo);
1211 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1212 fo->setName("clock");
1213 a=new QAction (fo->getPixmap(),fo->getName(),this);
1216 a->setCheckable(true);
1217 a->setObjectName(fo->getName());
1218 a->setToolTip(tr("Time critical","Standardflag"));
1219 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1220 standardFlagsDefault->addFlag (fo);
1222 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1223 fo->setName("phone");
1224 a=new QAction (fo->getPixmap(),fo->getName(),this);
1227 a->setCheckable(true);
1228 a->setObjectName(fo->getName());
1229 a->setToolTip(tr("Call...","Standardflag"));
1230 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1231 standardFlagsDefault->addFlag (fo);
1233 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1234 fo->setName("lamp");
1235 a=new QAction (fo->getPixmap(),fo->getName(),this);
1238 a->setCheckable(true);
1239 a->setObjectName(fo->getName());
1240 a->setToolTip(tr("Idea!","Standardflag"));
1241 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1242 standardFlagsDefault->addFlag (fo);
1244 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1245 fo->setName("arrow-up");
1246 fo->setGroup("standard-arrow");
1247 a=new QAction (fo->getPixmap(),fo->getName(),this);
1250 a->setCheckable(true);
1251 a->setObjectName(fo->getName());
1252 a->setToolTip(tr("Important","Standardflag"));
1253 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1254 standardFlagsDefault->addFlag (fo);
1256 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1257 fo->setName("arrow-down");
1258 fo->setGroup("standard-arrow");
1259 a=new QAction (fo->getPixmap(),fo->getName(),this);
1262 a->setCheckable(true);
1263 a->setObjectName(fo->getName());
1264 a->setToolTip(tr("Unimportant","Standardflag"));
1265 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1266 standardFlagsDefault->addFlag (fo);
1268 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1269 fo->setName("2arrow-up");
1270 fo->setGroup("standard-arrow");
1271 a=new QAction (fo->getPixmap(),fo->getName(),this);
1274 a->setCheckable(true);
1275 a->setObjectName(fo->getName());
1276 a->setToolTip(tr("Very important!","Standardflag"));
1277 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1278 standardFlagsDefault->addFlag (fo);
1280 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1281 fo->setName("2arrow-down");
1282 fo->setGroup("standard-arrow");
1283 a=new QAction (fo->getPixmap(),fo->getName(),this);
1286 a->setCheckable(true);
1287 a->setObjectName(fo->getName());
1288 a->setToolTip(tr("Very unimportant!","Standardflag"));
1289 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1290 standardFlagsDefault->addFlag (fo);
1292 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1293 fo->setName("thumb-up");
1294 fo->setGroup("standard-thumb");
1295 a=new QAction (fo->getPixmap(),fo->getName(),this);
1298 a->setCheckable(true);
1299 a->setObjectName(fo->getName());
1300 a->setToolTip(tr("I like this","Standardflag"));
1301 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1302 standardFlagsDefault->addFlag (fo);
1304 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1305 fo->setName("thumb-down");
1306 fo->setGroup("standard-thumb");
1307 a=new QAction (fo->getPixmap(),fo->getName(),this);
1310 a->setCheckable(true);
1311 a->setObjectName(fo->getName());
1312 a->setToolTip(tr("I do not like this","Standardflag"));
1313 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1314 standardFlagsDefault->addFlag (fo);
1316 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1317 fo->setName("rose");
1318 a=new QAction (fo->getPixmap(),fo->getName(),this);
1321 a->setCheckable(true);
1322 a->setObjectName(fo->getName());
1323 a->setToolTip(tr("Rose","Standardflag"));
1324 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1325 standardFlagsDefault->addFlag (fo);
1327 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1328 fo->setName("heart");
1329 a=new QAction (fo->getPixmap(),fo->getName(),this);
1331 a->setCheckable(true);
1332 a->setObjectName(fo->getName());
1333 a->setToolTip(tr("I just love... ","Standardflag"));
1334 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1335 standardFlagsDefault->addFlag (fo);
1337 fo->load(QPixmap(flagsPath+"flag-present.png"));
1338 fo->setName("present");
1339 a=new QAction (fo->getPixmap(),fo->getName(),this);
1342 a->setCheckable(true);
1343 a->setObjectName(fo->getName());
1344 a->setToolTip(tr("Surprise!","Standardflag"));
1345 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1346 standardFlagsDefault->addFlag (fo);
1348 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1349 fo->setName("flash");
1350 a=new QAction (fo->getPixmap(),fo->getName(),this);
1353 a->setCheckable(true);
1354 a->setObjectName(fo->getName());
1355 a->setToolTip(tr("Dangerous","Standardflag"));
1356 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1357 standardFlagsDefault->addFlag (fo);
1359 fo->load(QPixmap(flagsPath+"flag-info.png"));
1360 // Original: xsldbg_output.png
1361 fo->setName("info");
1362 a=new QAction (fo->getPixmap(),fo->getName(),this);
1365 a->setCheckable(true);
1366 a->setObjectName(fo->getName());
1367 a->setToolTip(tr("Info","Standardflag"));
1368 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1369 standardFlagsDefault->addFlag (fo);
1371 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1372 // Original khelpcenter.png
1373 fo->setName("lifebelt");
1374 a=new QAction (fo->getPixmap(),fo->getName(),this);
1377 a->setCheckable(true);
1378 a->setObjectName(fo->getName());
1379 a->setToolTip(tr("This will help","Standardflag"));
1380 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1381 standardFlagsDefault->addFlag (fo);
1387 void Main::setupSettingsActions()
1389 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1393 a = new QAction( tr( "Set application to open pdf files"), this);
1394 a->setStatusTip ( tr( "Set application to open pdf files"));
1395 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1396 settingsMenu->addAction (a);
1398 a = new QAction( tr( "Set application to open external links"), this);
1399 a->setStatusTip( tr( "Set application to open external links"));
1400 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1401 settingsMenu->addAction (a);
1403 settingsMenu->addSeparator();
1404 a = new QAction( tr( "Edit branch after adding it" ), this );
1405 a->setStatusTip( tr( "Edit branch after adding it" ));
1406 a->setToggleAction(true);
1407 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1408 settingsMenu->addAction (a);
1409 actionSettingsAutoedit=a;
1411 a= new QAction( tr( "Select branch after adding it" ), this );
1412 a->setStatusTip( tr( "Select branch after adding it" ));
1413 a->setToggleAction(true);
1414 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1415 settingsMenu->addAction (a);
1416 actionSettingsAutoselectHeading=a;
1418 a= new QAction(tr( "Select existing heading" ), this);
1419 a->setStatusTip( tr( "Select heading before editing" ));
1420 a->setToggleAction(true);
1421 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1422 settingsMenu->addAction (a);
1423 actionSettingsAutoselectText=a;
1425 a= new QAction(tr( "pasting into new branch" ), this );
1426 a->setStatusTip( tr( "Pasting into new branch" ));
1427 a->setToggleAction(true);
1428 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1429 settingsMenu->addAction (a);
1430 actionSettingsPasteNewHeading=a;
1432 a= new QAction( tr( "Delete key" ), this);
1433 a->setStatusTip( tr( "Delete key for deleting branches" ));
1434 a->setToggleAction(true);
1435 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1436 settingsMenu->addAction (a);
1437 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1438 actionSettingsUseDelKey=a;
1440 a= new QAction( tr( "Exclusive flags" ), this);
1441 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1442 a->setToggleAction(true);
1443 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1444 settingsMenu->addAction (a);
1445 actionSettingsUseFlagGroups=a;
1447 a= new QAction( tr( "Use hide flags" ), this);
1448 a->setStatusTip( tr( "Use hide flag during exports " ));
1449 a->setToggleAction(true);
1450 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1451 settingsMenu->addAction (a);
1452 actionSettingsUseHideExport=a;
1456 void Main::setupTestActions()
1458 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1461 a = new QAction( tr( "test flag" ), this);
1462 a->setStatusTip( tr( "Call test function" ));
1463 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1464 testMenu->addAction (a);
1468 void Main::setupHelpActions()
1470 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1473 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1474 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1475 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1476 helpMenu->addAction (a);
1478 a = new QAction( tr( "About VYM" ), this);
1479 a->setStatusTip( tr( "About VYM")+" "__VYM);
1480 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1481 helpMenu->addAction (a);
1483 a = new QAction( tr( "About QT" ), this);
1484 a->setStatusTip( tr( "Information about QT toolkit" ));
1485 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1486 helpMenu->addAction (a);
1490 void Main::setupContextMenus()
1494 // Context Menu for branch or mapcenter
1495 branchContextMenu =new QMenu (this);
1498 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1499 branchAddContextMenu->addAction (actionEditPaste );
1500 branchAddContextMenu->addAction ( actionEditAddBranch );
1501 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1502 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1503 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1504 branchAddContextMenu->addSeparator();
1505 branchAddContextMenu->addAction ( actionEditLoadImage);
1506 branchAddContextMenu->addSeparator();
1507 branchAddContextMenu->addAction ( actionEditLoadImage);
1508 branchAddContextMenu->addAction ( actionEditImportAdd );
1509 branchAddContextMenu->addAction ( actionEditImportReplace );
1512 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1513 branchRemoveContextMenu->addAction (actionEditCut);
1514 branchRemoveContextMenu->addAction ( actionEditDelete );
1515 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1516 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1519 actionEditSaveBranch->addTo( branchContextMenu );
1521 branchContextMenu->addSeparator();
1522 branchContextMenu->addAction ( actionEditOpenURL );
1523 branchContextMenu->addAction ( actionEditOpenURLTab );
1524 branchContextMenu->addAction ( actionEditURL );
1525 branchContextMenu->addAction ( actionEditHeading2URL );
1526 branchContextMenu->addAction ( actionEditBugzilla2URL );
1527 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1529 branchContextMenu->addAction ( actionEditFATE2URL );
1531 branchContextMenu->addSeparator();
1532 branchContextMenu->addAction ( actionEditOpenVymLink );
1533 branchContextMenu->addAction ( actionEditVymLink );
1534 branchContextMenu->addAction ( actionEditDeleteVymLink );
1536 branchContextMenu->addSeparator();
1537 branchContextMenu->addAction ( actionFormatFrameNone );
1538 branchContextMenu->addAction ( actionFormatFrameRectangle);
1540 branchContextMenu->addSeparator();
1541 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1542 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1543 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1545 // Context Menu for links in a branch menu
1546 // This will be populated "on demand" in MapEditor::updateActions
1547 branchContextMenu->addSeparator();
1548 branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1549 branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1550 connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1551 connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1553 // Context menu for floatimage
1554 floatimageContextMenu =new QMenu (this);
1555 saveImageFormatMenu=floatimageContextMenu->addMenu (tr("Save image"));
1557 foreach (QByteArray format, QImageWriter::supportedImageFormats())
1559 QString text = tr("%1...").arg(QString(format).toUpper());
1560 a= new QAction (text,this);
1561 saveImageFormatMenu->addAction ( a );
1564 /* FIXME not needed any longer
1565 Q3StrList fmt = QImageWriter::supportedImageFormats();
1566 for (const char* f = fmt.first(); f; f = fmt.next())
1568 saveImageFormatMenu->insertItem( f );
1569 exportImageFormatMenu->insertItem( f );
1572 // connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1573 // connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1575 floatimageContextMenu->addSeparator();
1576 actionEditCopy->addTo( floatimageContextMenu );
1577 actionEditCut->addTo( floatimageContextMenu );
1579 floatimageContextMenu->addSeparator();
1580 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1583 // Context menu for canvas
1584 canvasContextMenu =new QMenu (this);
1585 actionEditMapInfo->addTo( canvasContextMenu );
1586 canvasContextMenu->insertSeparator();
1587 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1588 canvasContextMenu->insertSeparator();
1589 actionFormatLinkColorHint->addTo( canvasContextMenu );
1590 actionFormatLinkColor->addTo( canvasContextMenu );
1591 actionFormatBackColor->addTo( canvasContextMenu );
1593 // Menu for last opened files
1594 // Read settings initially
1596 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1597 for (int i=1;i<=j;i++)
1599 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1600 if (!s.isEmpty() && j<=maxLastMaps)
1603 setupLastMapsMenu();
1604 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1607 void Main::setupLastMapsMenu()
1609 // Remove double entries
1610 QStringList::Iterator it=lastMaps.begin();
1611 QStringList::Iterator jt;
1612 while (it!=lastMaps.end() )
1616 while (jt!=lastMaps.end() )
1619 jt=lastMaps.remove(jt);
1626 // Limit length of list to maxLastMaps
1627 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1629 // build Menu from lastMaps string list
1630 fileLastMapsMenu->clear();
1631 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1632 fileLastMapsMenu->addAction (*it );
1635 void Main::hideEvent (QHideEvent * )
1637 if (!textEditor->isMinimized() ) textEditor->hide();
1640 void Main::showEvent (QShowEvent * )
1642 if (textEditor->showWithMain()) textEditor->showNormal();
1645 bool Main::reallyWriteDirectory(const QString &dir)
1647 QStringList eList = QDir(dir).entryList();
1648 if (eList.first() ==".") eList.pop_front(); // remove "."
1649 if (eList.first() =="..") eList.pop_front(); // remove "."
1650 if (!eList.isEmpty())
1652 QMessageBox mb( __VYM,
1653 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1654 QMessageBox::Warning,
1656 QMessageBox::Cancel | QMessageBox::Default,
1657 QMessageBox::QMessageBox::NoButton );
1659 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1660 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1663 case QMessageBox::Yes:
1666 case QMessageBox::Cancel:
1674 QString Main::browseDirectory (const QString &caption)
1676 Q3FileDialog fd(this,caption);
1677 fd.setMode (Q3FileDialog::DirectoryOnly);
1678 fd.setCaption(__VYM " - "+caption);
1681 if ( fd.exec() == QDialog::Accepted )
1682 return fd.selectedFile();
1687 MapEditor* Main::currentMapEditor() const
1689 if ( tabWidget->currentPage() &&
1690 tabWidget->currentPage()->inherits( "MapEditor" ) )
1691 return (MapEditor*)tabWidget->currentPage();
1695 //TODO not used now, maybe use this for overview window later
1696 void Main::newView()
1698 // Open a new view... have it delete when closed.
1699 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1700 qApp->setMainWidget(m);
1702 qApp->setMainWidget(0);
1705 void Main::editorChanged(QWidget *)
1707 // Unselect all possibly selected objects
1708 // (Important to update note editor)
1711 for (i=0;i<=tabWidget->count() -1;i++)
1714 me=(MapEditor*)tabWidget->page(i);
1717 currentMapEditor()->reselect();
1719 // Update actions to in menus and toolbars according to editor
1720 currentMapEditor()->updateActions();
1723 void Main::fileNew()
1725 QString fn="unnamed";
1726 MapEditor* medit = new MapEditor ( NULL,true);
1727 tabWidget->addTab (medit,fn);
1728 tabWidget->showPage(medit);
1729 medit->viewport()->setFocus();
1730 // For the very first map we do not have flagrows yet...
1731 medit->select("mc:");
1734 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1736 ErrorCode err=success;
1738 // fn is usually the archive, mapfile the file after uncompressing
1741 // Make fn absolute (needed for unzip)
1742 fn=QDir (fn).absPath();
1748 // Check, if map is already loaded
1750 while (i<=tabWidget->count() -1)
1752 me=(MapEditor*)tabWidget->page(i);
1753 if (me->getFilePath() == fn)
1755 // Already there, ask for confirmation
1756 QMessageBox mb( __VYM,
1757 tr("The map %1\nis already opened."
1758 "Opening the same map in multiple editors may lead \n"
1759 "to confusion when finishing working with vym."
1760 "Do you want to").arg(fn),
1761 QMessageBox::Warning,
1762 QMessageBox::Yes | QMessageBox::Default,
1763 QMessageBox::Cancel | QMessageBox::Escape,
1764 QMessageBox::NoButton);
1765 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1766 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1769 case QMessageBox::Yes:
1771 i=tabWidget->count();
1773 case QMessageBox::Cancel:
1785 if ( !fn.isEmpty() )
1787 me = currentMapEditor();
1788 int tabIndex=tabWidget->currentPageIndex();
1789 // Check first, if mapeditor exists
1790 // If it is not default AND we want a new map,
1791 // create a new mapeditor in a new tab
1792 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1794 me= new MapEditor ( NULL,true);
1795 tabWidget->addTab (me,fn);
1796 tabIndex=tabWidget->indexOf (me);
1797 tabWidget->setCurrentPage (tabIndex);
1800 // Check, if file exists (important for creating new files
1801 // from command line
1802 if (!QFile(fn).exists() )
1804 QMessageBox mb( __VYM,
1805 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1806 QMessageBox::Question,
1808 QMessageBox::Cancel | QMessageBox::Default,
1809 QMessageBox::NoButton );
1811 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1812 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1815 case QMessageBox::Yes:
1817 currentMapEditor()->setFilePath(fn);
1818 tabWidget->setTabLabel (currentMapEditor(),
1819 currentMapEditor()->getFileName() );
1820 statusBar()->message( "Created " + fn , statusbarTime );
1823 case QMessageBox::Cancel:
1824 // don't create new map
1825 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1832 //tabWidget->currentPage() won't be NULL here, because of above...
1833 tabWidget->showPage(me);
1834 me->viewport()->setFocus();
1836 // Create temporary directory for packing
1837 char tmpdir1[]="/tmp/vym-XXXXXX";
1838 QString tmpMapDir=mkdtemp(tmpdir1);
1840 // Try to unzip file
1841 err=unzipDir (tmpMapDir,fn);
1845 me->setZipped(false);
1848 me->setZipped(true);
1850 // Look for mapname.xml
1851 mapfile= fn.left(fn.findRev(".",-1,true));
1852 mapfile=mapfile.section( '/', -1 );
1853 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1854 if (!file.exists() )
1856 // mapname.xml does not exist, well,
1857 // maybe some renamed the mapname.vym file...
1858 // Try to find any .xml in the toplevel
1859 // directory of the .vym file
1860 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1861 if (flist.count()==1)
1863 // Only one entry, take this one
1864 mapfile=tmpMapDir + "/"+flist.first();
1867 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1868 *it=tmpMapDir + "/" + *it;
1869 // TODO Multiple entries, load all (but only the first one into this ME)
1870 //mainWindow->fileLoadFromTmp (flist);
1871 //returnCode=1; // Silently forget this attempt to load
1872 qWarning ("MainWindow::load (fn) multimap found...");
1875 if (flist.isEmpty() )
1877 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1878 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1881 } //file doesn't exist
1883 mapfile=file.name();
1888 // Save existing filename in case we import
1889 QString fn_org=me->getFilePath();
1891 // Finally load map into mapEditor
1892 me->setFilePath (mapfile,fn);
1893 err=me->load(mapfile,lmode);
1895 // Restore old (maybe empty) filepath, if this is an import
1897 me->setFilePath (fn_org);
1900 // Finally check for errors and go home
1903 if (lmode==NewMap) fileCloseMap();
1904 statusBar()->message( "Could not load " + fn, statusbarTime );
1909 me->setFilePath (fn);
1910 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1911 if (fn.left(9)!="/tmp/vym-")
1913 // Only append to lastMaps if not loaded from a tmpDir
1914 // e.g. imported bookmarks are in a tmpDir
1915 lastMaps.prepend(me->getFilePath() );
1916 setupLastMapsMenu();
1918 actionFilePrint->setEnabled (true);
1920 statusBar()->message( "Loaded " + fn, statusbarTime );
1924 removeDir (QDir(tmpMapDir));
1930 void Main::fileLoad(const LoadMode &lmode)
1932 Q3FileDialog *fd=new Q3FileDialog( this);
1933 if (!lastFileDir.isEmpty())
1934 fd->setDir (lastFileDir);
1935 fd->setMode (Q3FileDialog::ExistingFiles);
1936 fd->addFilter ("XML (*.xml)");
1937 fd->addFilter ("VYM map (*.vym *.vyp)");
1941 fd->setCaption(tr("Load vym map"));
1944 fd->setCaption(tr("Import: Add vym map to selection"));
1947 fd->setCaption(tr("Import: Replace selection with vym map"));
1953 if ( fd->exec() == QDialog::Accepted )
1955 lastFileDir=fd->dirPath();
1956 QStringList flist = fd->selectedFiles();
1957 QStringList::Iterator it = flist.begin();
1958 while( it != flist.end() )
1961 fileLoad(*it, lmode);
1968 void Main::fileLoad()
1973 void Main::fileLoadLast(QAction *a)
1975 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1978 void Main::fileSave(const SaveMode &savemode)
1980 // tmp dir for zipping
1984 ErrorCode err=success;
1986 QString safeFilePath;
1988 bool saveZipped=currentMapEditor()->saveZipped();
1990 MapEditor * me=currentMapEditor();
1993 QString fn=me->getFilePath();
1994 // filename=unnamed, filepath="" in constructor...
1995 if ( !fn.isEmpty() )
1997 // We have a filepath, go on saving
1998 // First remove existing file, we
1999 // don't want to add to old zip archives
2003 QMessageBox::warning( 0, tr( "Save Error" ),
2004 fn+ tr("\ncould not be removed before saving"));
2006 // Look, if we should zip the data:
2009 QMessageBox mb( __VYM,
2010 tr("The map %1\ndid not use the compressed "
2011 "vym file format.\nWriting it uncompressed will also write images \n"
2012 "and flags and thus may overwrite files in the "
2013 "given directory\n\nDo you want to write the map").arg(fn),
2014 QMessageBox::Warning,
2015 QMessageBox::Yes | QMessageBox::Default,
2017 QMessageBox::Cancel | QMessageBox::Escape);
2018 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2019 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2020 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2023 case QMessageBox::Yes:
2024 // save compressed (default file format)
2027 case QMessageBox::No:
2028 // save uncompressed
2031 case QMessageBox::Cancel:
2040 char tmpdir1[]="/tmp/vym-XXXXXX";
2041 tmpMapDir=mkdtemp(tmpdir1);
2043 safeFilePath=me->getFilePath();
2044 me->setFilePath (tmpMapDir+"/"+
2045 me->getMapName()+ ".xml",
2047 me->save (savemode);
2048 me->setFilePath (safeFilePath);
2050 zipDir (tmpMapDir,fn);
2055 safeFilePath=me->getFilePath();
2056 me->setFilePath (fn, safeFilePath);
2057 me->save (savemode);
2058 me->setFilePath (safeFilePath);
2060 } // filepath available
2063 // We have no filepath yet,
2064 // call fileSaveAs() now, this will call fileSave()
2066 fileSaveAs(savemode);
2070 if (saveZipped && !tmpMapDir.isEmpty())
2072 removeDir (QDir(tmpMapDir));
2076 statusBar()->message(
2077 tr("Saved %1").arg(me->getFilePath()),
2079 lastMaps.prepend(me->getFilePath() );
2080 setupLastMapsMenu();
2082 statusBar()->message(
2083 tr("Couldn't save ").arg(me->getFilePath()),
2087 void Main::fileSave()
2089 fileSave (CompleteMap);
2092 void Main::fileSaveAs(const SaveMode& savemode)
2096 if (currentMapEditor())
2098 if (savemode==CompleteMap)
2099 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2101 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2102 if ( !fn.isEmpty() )
2104 // Check for existing file
2105 if (QFile (fn).exists())
2107 QMessageBox mb( __VYM,
2108 tr("The file %1\nexists already. Do you want to").arg(fn),
2109 QMessageBox::Warning,
2110 QMessageBox::Yes | QMessageBox::Default,
2111 QMessageBox::Cancel | QMessageBox::Escape,
2112 QMessageBox::NoButton);
2113 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2114 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2117 case QMessageBox::Yes:
2120 case QMessageBox::Cancel:
2127 // New file, add extension to filename, if missing
2128 // This is always .vym or .vyp, depending on savemode
2129 if (savemode==CompleteMap)
2131 if (!fn.contains (".vym") && !fn.contains (".xml"))
2135 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2144 currentMapEditor()->setFilePath(fn);
2148 if (savemode==CompleteMap)
2149 tabWidget->setTabLabel (currentMapEditor(),
2150 currentMapEditor()->getFileName() );
2156 void Main::fileSaveAs()
2158 fileSaveAs (CompleteMap);
2161 void Main::fileImportKDEBookmarks()
2163 ImportKDEBookmarks im;
2165 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2166 currentMapEditor()->setFilePath ("");
2169 void Main::fileImportFirefoxBookmarks()
2171 Q3FileDialog *fd=new Q3FileDialog( this);
2172 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2173 fd->setMode (Q3FileDialog::ExistingFiles);
2174 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2175 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2178 if ( fd->exec() == QDialog::Accepted )
2180 ImportFirefoxBookmarks im;
2181 QStringList flist = fd->selectedFiles();
2182 QStringList::Iterator it = flist.begin();
2183 while( it != flist.end() )
2186 if (im.transform() &&
2187 success==fileLoad (im.getTransformedFile(),NewMap) &&
2188 currentMapEditor() )
2189 currentMapEditor()->setFilePath ("");
2196 void Main::fileImportMM()
2200 Q3FileDialog *fd=new Q3FileDialog( this);
2201 if (!lastFileDir.isEmpty())
2202 fd->setDir (lastFileDir);
2203 fd->setMode (Q3FileDialog::ExistingFiles);
2204 fd->addFilter ("Mind Manager (*.mmap)");
2205 fd->setCaption(tr("Import")+" "+"Mind Manager");
2208 if ( fd->exec() == QDialog::Accepted )
2210 lastFileDir=fd->dirPath();
2211 QStringList flist = fd->selectedFiles();
2212 QStringList::Iterator it = flist.begin();
2213 while( it != flist.end() )
2216 if (im.transform() &&
2217 success==fileLoad (im.getTransformedFile(),NewMap) &&
2218 currentMapEditor() )
2219 currentMapEditor()->setFilePath ("");
2228 void Main::fileImportDir()
2230 if (currentMapEditor())
2231 currentMapEditor()->importDir();
2234 void Main::fileExportXML()
2236 if (currentMapEditor())
2238 QString dir=browseDirectory(tr("Export XML to directory"));
2239 if (dir !="" && reallyWriteDirectory(dir) )
2240 currentMapEditor()->exportXML(dir);
2245 void Main::fileExportXHTML()
2247 MapEditor *me=currentMapEditor();
2251 ExportXHTMLDialog dia(this);
2252 dia.setFilePath (me->getFilePath() );
2253 dia.setMapName (me->getMapName() );
2256 if (dia.exec()==QDialog::Accepted)
2258 QString dir=dia.getDir();
2259 // Check, if warnings should be used before overwriting
2260 // the output directory
2263 ok=reallyWriteDirectory(dir);
2269 me->exportXML (dia.getDir() );
2270 dia.doExport(me->getMapName() );
2271 if (dia.hasChanged())
2278 void Main::fileExportImage()
2280 MapEditor *me=currentMapEditor();
2284 QFileDialog *fd=new QFileDialog (this);
2285 fd->setCaption (tr("Export map as image"));
2286 fd->setFileMode(QFileDialog::AnyFile);
2287 fd->setFilters (imageIO.getFilters() );
2288 fd->setDirectory (lastImageDir);
2291 fl=fd->selectedFiles();
2292 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2293 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2298 void Main::fileExportASCII()
2300 MapEditor *me=currentMapEditor();
2304 ex.setMapCenter(me->getMapCenter());
2305 ex.addFilter ("TXT (*.txt)");
2306 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2307 if (ex.execDialog() )
2309 me->setExportMode(true);
2311 me->setExportMode(false);
2316 void Main::fileExportLaTeX()
2318 MapEditor *me=currentMapEditor();
2322 ex.setMapCenter(me->getMapCenter());
2323 ex.addFilter ("Tex (*.tex)");
2324 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2325 if (ex.execDialog() )
2327 me->setExportMode(true);
2329 me->setExportMode(false);
2334 void Main::fileExportKDEBookmarks()
2336 ExportKDEBookmarks ex;
2337 MapEditor *me=currentMapEditor();
2340 ex.setMapCenter (me->getMapCenter() );
2345 void Main::fileExportTaskjuggler()
2347 ExportTaskjuggler ex;
2348 MapEditor *me=currentMapEditor();
2351 ex.setMapCenter (me->getMapCenter() );
2352 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2353 ex.addFilter ("Taskjuggler (*.tjp)");
2354 if (ex.execDialog() )
2356 me->setExportMode(true);
2358 me->setExportMode(false);
2363 void Main::fileExportOOPresentation()
2365 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2366 // FIXME add extra info in dialog
2367 //ImagePreview *p =new ImagePreview (fd);
2368 //fd->setContentsPreviewEnabled( TRUE );
2369 //fd->setContentsPreview( p, p );
2370 //fd->setPreviewMode( QFileDialog::Contents );
2371 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2372 //fd->setDir (lastImageDir);
2375 if ( fd->exec() == QDialog::Accepted )
2377 QString fn=fd->selectedFile();
2378 //lastImageDir=fn.left(fn.findRev ("/"));
2379 if (currentMapEditor())
2380 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2384 void Main::fileCloseMap()
2386 if (currentMapEditor())
2388 if (currentMapEditor()->hasChanged())
2390 QMessageBox mb( __VYM,
2391 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2392 QMessageBox::Warning,
2393 QMessageBox::Yes | QMessageBox::Default,
2395 QMessageBox::Cancel | QMessageBox::Escape );
2396 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2397 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2400 case QMessageBox::Yes:
2402 fileSave(CompleteMap);
2404 case QMessageBox::No:
2405 // close without saving
2407 case QMessageBox::Cancel:
2412 currentMapEditor()->closeMap();
2413 tabWidget->removePage(currentMapEditor());
2414 if (tabWidget->count()==0)
2415 actionFilePrint->setEnabled (false);
2419 void Main::filePrint()
2421 if (currentMapEditor())
2422 currentMapEditor()->print();
2425 void Main::fileExitVYM()
2427 // Check if one or more editors have changed
2430 for (i=0;i<=tabWidget->count() -1;i++)
2433 me=(MapEditor*)tabWidget->page(i);
2435 // If something changed, ask what to do
2436 if (me->isUnsaved())
2438 tabWidget->setCurrentPage(i);
2439 QMessageBox mb( __VYM,
2440 tr("This map is not saved yet. Do you want to"),
2441 QMessageBox::Warning,
2442 QMessageBox::Yes | QMessageBox::Default,
2444 QMessageBox::Cancel | QMessageBox::Escape );
2445 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2446 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2448 mb.setActiveWindow();
2449 switch( mb.exec() ) {
2450 case QMessageBox::Yes:
2451 // save (the changed editors) and exit
2452 fileSave(CompleteMap);
2454 case QMessageBox::No:
2455 // exit without saving
2457 case QMessageBox::Cancel:
2458 // don't save and don't exit
2462 } // loop over all MEs
2466 void Main::editUndo()
2468 if (currentMapEditor())
2469 currentMapEditor()->undo();
2472 void Main::editRedo()
2474 if (currentMapEditor())
2475 currentMapEditor()->redo();
2478 void Main::editCopy()
2480 if (currentMapEditor())
2481 currentMapEditor()->copy();
2484 void Main::editPaste()
2486 if (currentMapEditor())
2487 currentMapEditor()->paste();
2490 void Main::editCut()
2492 if (currentMapEditor())
2493 currentMapEditor()->cut();
2496 void Main::editOpenFindWindow()
2498 findWindow->popup();
2499 findWindow->raise();
2500 findWindow->setActiveWindow();
2503 void Main::editFind(QString s)
2506 BranchObj *bo=currentMapEditor()->findText(s, cs);
2509 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2512 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2513 tr("No matches found for \"%1\"").arg(s));
2517 void Main::editFindChanged()
2518 { // Notify editor, to abort the current find process
2519 currentMapEditor()->findReset();
2522 void Main::editOpenURL()
2525 if (currentMapEditor())
2527 QString url=currentMapEditor()->getURL();
2528 if (url=="") return;
2529 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2530 procBrowser = new Q3Process( this );
2532 procBrowser->addArgument( browser);
2533 procBrowser->addArgument( url);
2535 if ( !procBrowser->start() )
2537 // try to set path to browser
2538 QMessageBox::warning(0,
2540 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2541 tr("Please use Settings->")+tr("Set application to open an URL"));
2546 void Main::editOpenURLTab()
2548 if (currentMapEditor())
2550 QString url=currentMapEditor()->getURL();
2551 if (url=="") return;
2552 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2553 if (procBrowser && procBrowser->isRunning())
2555 if (browser.contains("konqueror"))
2557 // Try to open new tab in existing konqueror started previously by vym
2558 Q3Process *p=new Q3Process (this);
2559 p->addArgument ("dcop");
2560 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2561 p->addArgument ("konqueror-mainwindow#1");
2562 p->addArgument ("newTab");
2563 p->addArgument (url);
2565 // try to set browser
2566 QMessageBox::warning(0,
2568 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2570 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2572 // Try to open new tab in firefox
2573 Q3Process *p=new Q3Process (this);
2574 p->addArgument (browser);
2575 p->addArgument ("-remote");
2576 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2578 // try to set browser
2579 QMessageBox::warning(0,
2581 tr("Couldn't start %1 to open a new tab").arg(browser));
2590 void Main::editURL()
2592 if (currentMapEditor())
2593 currentMapEditor()->editURL();
2596 void Main::editHeading2URL()
2598 if (currentMapEditor())
2599 currentMapEditor()->editHeading2URL();
2602 void Main::editBugzilla2URL()
2604 if (currentMapEditor())
2605 currentMapEditor()->editBugzilla2URL();
2608 void Main::editFATE2URL()
2610 if (currentMapEditor())
2611 currentMapEditor()->editFATE2URL();
2614 void Main::editOpenVymLink()
2616 // Get current path to map
2617 QString currentVymLink;
2618 if (currentMapEditor())
2620 currentVymLink=currentMapEditor()->getVymLink();
2621 // compare path with already loaded maps
2625 for (i=0;i<=tabWidget->count() -1;i++)
2627 me=(MapEditor*)tabWidget->page(i);
2628 if (currentVymLink==me->getFilePath() )
2637 if (!QFile(currentVymLink).exists() )
2638 QMessageBox::critical( 0, tr( "Critical Error" ),
2639 tr("Couldn't open map %1").arg(currentVymLink));
2642 fileLoad (currentVymLink, NewMap);
2643 tabWidget->setCurrentPage (tabWidget->count()-1);
2646 // Go to tab containing the map
2647 tabWidget->setCurrentPage (index);
2651 void Main::editVymLink()
2653 if (currentMapEditor())
2654 currentMapEditor()->editVymLink();
2657 void Main::editDeleteVymLink()
2659 if (currentMapEditor())
2660 currentMapEditor()->deleteVymLink();
2663 void Main::editToggleHideExport()
2665 if (currentMapEditor())
2666 currentMapEditor()->toggleHideExport();
2669 void Main::editMapInfo()
2671 if (currentMapEditor())
2672 currentMapEditor()->editMapInfo();
2675 void Main::editMoveUp()
2677 if (currentMapEditor())
2678 currentMapEditor()->moveBranchUp();
2681 void Main::editMoveDown()
2683 if (currentMapEditor())
2684 currentMapEditor()->moveBranchDown();
2687 void Main::editToggleScroll()
2689 if (currentMapEditor())
2691 currentMapEditor()->toggleScroll();
2695 void Main::editUnScrollAll()
2697 if (currentMapEditor())
2699 currentMapEditor()->unScrollAll();
2703 void Main::editHeading()
2705 if (currentMapEditor())
2706 currentMapEditor()->editHeading();
2709 void Main::editNewBranch()
2711 if (currentMapEditor())
2712 currentMapEditor()->addNewBranch(0);
2715 void Main::editNewBranchHere()
2717 if (currentMapEditor())
2718 currentMapEditor()->addNewBranchHere();
2721 void Main::editNewBranchAbove()
2723 if (currentMapEditor())
2724 currentMapEditor()->addNewBranch(-1);
2727 void Main::editNewBranchBelow()
2729 if (currentMapEditor())
2730 currentMapEditor()->addNewBranch(1);
2733 void Main::editImportAdd()
2735 fileLoad (ImportAdd);
2738 void Main::editImportReplace()
2740 fileLoad (ImportReplace);
2743 void Main::editSaveBranch()
2745 fileSaveAs (PartOfMap);
2748 void Main::editRemoveBranchKeepChilds()
2750 if (currentMapEditor())
2751 currentMapEditor()->removeBranchKeepChilds();
2754 void Main::editRemoveChilds()
2756 if (currentMapEditor())
2757 currentMapEditor()->removeChilds();
2760 void Main::editDeleteSelection()
2762 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2763 currentMapEditor()->deleteSelection();
2766 void Main::editUpperBranch()
2768 if (currentMapEditor())
2769 currentMapEditor()->selectUpperBranch();
2772 void Main::editLowerBranch()
2774 if (currentMapEditor())
2775 currentMapEditor()->selectLowerBranch();
2778 void Main::editLeftBranch()
2780 if (currentMapEditor())
2781 currentMapEditor()->selectLeftBranch();
2784 void Main::editRightBranch()
2786 if (currentMapEditor())
2787 currentMapEditor()->selectRightBranch();
2790 void Main::editFirstBranch()
2792 if (currentMapEditor())
2793 currentMapEditor()->selectFirstBranch();
2796 void Main::editLastBranch()
2798 if (currentMapEditor())
2799 currentMapEditor()->selectLastBranch();
2802 void Main::editLoadImage()
2804 if (currentMapEditor())
2805 currentMapEditor()->loadFloatImage();
2808 void Main::editSaveImage(int item)
2810 if (currentMapEditor())
2811 currentMapEditor()->saveFloatImage(item);
2814 void Main::editFollowXLink(QAction *a)
2817 if (currentMapEditor())
2818 currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
2821 void Main::editEditXLink(QAction *a)
2823 if (currentMapEditor())
2824 currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
2827 void Main::formatSelectColor()
2829 if (currentMapEditor())
2831 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2832 if ( !col.isValid() ) return;
2833 currentMapEditor()->setColor( col );
2834 colorChanged( col );
2838 void Main::formatPickColor()
2840 if (currentMapEditor())
2841 colorChanged( currentMapEditor()->pickColor() );
2844 void Main::colorChanged(QColor c)
2846 QPixmap pix( 16, 16 );
2848 actionFormatColor->setIconSet( pix );
2851 void Main::formatColorItem()
2853 if (currentMapEditor())
2854 currentMapEditor()->colorItem();
2857 void Main::formatColorBranch()
2859 if (currentMapEditor())
2860 currentMapEditor()->colorBranch();
2863 void Main::formatLinkStyleLine()
2865 if (currentMapEditor())
2866 currentMapEditor()->setLinkStyle(StyleLine);
2869 void Main::formatLinkStyleParabel()
2871 if (currentMapEditor())
2872 currentMapEditor()->setLinkStyle(StyleParabel);
2875 void Main::formatLinkStylePolyLine()
2877 if (currentMapEditor())
2878 currentMapEditor()->setLinkStyle(StylePolyLine);
2881 void Main::formatLinkStylePolyParabel()
2883 if (currentMapEditor())
2884 currentMapEditor()->setLinkStyle(StylePolyParabel);
2887 void Main::formatSelectBackColor()
2889 if (currentMapEditor())
2890 currentMapEditor()->selectBackgroundColor();
2893 void Main::formatSelectLinkColor()
2895 if (currentMapEditor())
2896 currentMapEditor()->selectLinkColor();
2899 void Main::formatToggleLinkColorHint()
2901 currentMapEditor()->toggleLinkColorHint();
2904 void Main::formatFrameNone()
2906 if (currentMapEditor())
2907 currentMapEditor()->setFrame(NoFrame);
2910 void Main::formatFrameRectangle()
2912 if (currentMapEditor())
2913 currentMapEditor()->setFrame(Rectangle);
2916 void Main::formatIncludeImagesVer()
2918 if (currentMapEditor())
2919 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2922 void Main::formatIncludeImagesHor()
2924 if (currentMapEditor())
2925 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2928 void Main::formatHideLinkUnselected()
2930 if (currentMapEditor())
2931 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2934 void Main::viewZoomReset()
2936 if (currentMapEditor())
2940 currentMapEditor()->setWorldMatrix( m );
2941 currentMapEditor()->setViewCenter();
2942 currentMapEditor()->adjustCanvasSize();
2946 void Main::viewZoomIn()
2948 if (currentMapEditor())
2950 QMatrix m = currentMapEditor()->worldMatrix();
2951 m.scale( 1.25, 1.25 );
2952 currentMapEditor()->setWorldMatrix( m );
2953 currentMapEditor()->setViewCenter();
2954 currentMapEditor()->adjustCanvasSize();
2958 void Main::viewZoomOut()
2960 if (currentMapEditor())
2962 QMatrix m = currentMapEditor()->worldMatrix();
2963 m.scale( 0.8, 0.8 );
2964 currentMapEditor()->setWorldMatrix( m );
2965 currentMapEditor()->setViewCenter();
2966 currentMapEditor()->adjustCanvasSize();
2970 void Main::modModeColor()
2974 void Main::modModeLink()
2978 bool Main::settingsPDF()
2980 // Default browser is set in constructor
2982 QString text = QInputDialog::getText(
2983 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2984 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2986 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2991 bool Main::settingsURL()
2993 // Default browser is set in constructor
2995 QString text = QInputDialog::getText(
2996 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2997 settings.readEntry("/vym/mainwindow/readerURL")
3000 settings.writeEntry ("/vym/mainwindow/readerURL",text);
3004 void Main::settingsToggleDelKey()
3006 if (actionSettingsUseDelKey->isOn())
3008 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3011 actionEditDelete->setAccel (QKeySequence (""));
3015 void Main::windowToggleNoteEditor()
3017 if (textEditor->showWithMain() )
3018 windowHideNoteEditor();
3020 windowShowNoteEditor();
3023 void Main::windowToggleHistory()
3025 if (currentMapEditor())
3026 currentMapEditor()->toggleHistoryWindow();
3029 void Main::updateNoteFlag()
3031 if (currentMapEditor())
3032 currentMapEditor()->updateNoteFlag();
3035 void Main::windowShowNoteEditor()
3037 textEditor->setShowWithMain(true);
3039 actionViewToggleNoteEditor->setOn (true);
3042 void Main::windowHideNoteEditor()
3044 textEditor->setShowWithMain(false);
3046 actionViewToggleNoteEditor->setOn (false);
3049 void Main::windowNextEditor()
3051 if (tabWidget->currentPageIndex() < tabWidget->count())
3052 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3055 void Main::windowPreviousEditor()
3057 if (tabWidget->currentPageIndex() >0)
3058 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3061 void Main::standardFlagChanged()
3063 currentMapEditor()->toggleStandardFlag(sender()->name());
3066 void Main::testFunction()
3068 currentMapEditor()->testFunction();
3071 void Main::helpDoc()
3074 #if defined(Q_OS_MACX)
3075 docpath="./vym.app/Contents/vym.pdf";
3077 // default path in SUSE LINUX
3078 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3081 if (!QFile (docpath).exists() )
3083 // relative path for easy testing in tarball
3084 docpath="doc/vym.pdf";
3085 if (!QFile (docpath).exists() )
3087 // relative path for testing while still writing vym.tex
3088 docpath="doc/tex/vym.pdf";
3089 if (!QFile (docpath).exists() )
3091 // Try yet another one for Knoppix
3092 docpath="/usr/share/doc/packages/vym/vym.pdf";
3093 if (!QFile (docpath).exists() )
3095 QMessageBox::critical(0,
3096 tr("Critcal error"),
3097 tr("Couldn't find the documentation\n"
3098 "vym.pdf in various places."));
3105 Process *pdfProc = new Process();
3106 pdfProc->clearArguments();
3107 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
3108 pdfProc->addArgument( docpath);
3110 if ( !pdfProc->start() )
3113 QMessageBox::warning(0,
3115 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3116 tr("Please use Settings->")+tr("Set application to open PDF files"));
3123 void Main::helpAbout()
3126 ad.setName ("aboutwindow");
3127 ad.setMinimumSize(500,500);
3128 ad.resize (QSize (500,500));
3132 void Main::helpAboutQT()
3134 QMessageBox::aboutQt( this, "Qt Application Example" );