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* branchLinksContextMenu;
133 extern QMenu* branchLinksContextMenuDup;
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:
506 a = new QAction(tr( "Edit heading" ),this);
507 a->setStatusTip ( tr( "edit Heading" ));
508 a->setShortcut ( Qt::Key_Enter);
509 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
510 actionListBranches.append(a);
512 a = new QAction( tr( "Edit heading" ), this);
513 a->setStatusTip (tr( "edit Heading" ));
514 a->setShortcut (Qt::Key_Return );
515 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
516 //actionListBranches.append(a);
517 editMenu->addAction (a);
520 a = new QAction( tr( "Edit heading" ),this);
521 a->setStatusTip (tr( "edit Heading" ));
522 a->setShortcut ( Qt::Key_F2 );
523 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
524 a->setEnabled (false);
525 actionListBranches.append(a);
528 // Shortcut to delete selection
529 a = new QAction( tr( "Delete Selection" ),this);
530 a->setStatusTip (tr( "Delete Selection" ));
531 a->setShortcut ( Qt::Key_Delete);
532 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
533 a->setEnabled (false);
536 // Shortcut to add branch
537 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
538 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
539 alt->setShortcut (Qt::Key_A);
540 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
541 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
542 a->setStatusTip ( tr( "Add a branch as child of selection" ));
543 a->setShortcut (Qt::Key_Insert);
544 // a->setEnabled (false);
545 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
546 actionListBranches.append(a);
547 #if defined (Q_OS_MACX)
548 // In OSX show different shortcut in menues, the keys work indepently always
549 actionEditAddBranch=alt;
551 actionEditAddBranch=a;
553 editMenu->addAction (actionEditAddBranch);
554 tb->addAction (actionEditAddBranch);
557 // Add branch by inserting it at selection
558 a = new QAction(tr( "Add branch (insert)" ), this);
559 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
560 a->setShortcut (Qt::ALT + Qt::Key_Insert );
561 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
562 a->setEnabled (false);
563 actionListBranches.append(a);
564 actionEditAddBranchHere=a;
565 a = new QAction(tr( "Add branch (insert)" ),this);
566 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
567 a->setShortcut ( Qt::ALT + Qt::Key_A );
568 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
569 actionListBranches.append(a);
572 a = new QAction(tr( "Add branch above" ), this);
573 a->setStatusTip ( tr( "Add a branch above selection" ));
574 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
575 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
576 a->setEnabled (false);
577 actionListBranches.append(a);
578 actionEditAddBranchAbove=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_A );
582 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
583 actionListBranches.append(a);
586 a = new QAction(tr( "Add branch below" ), this);
587 a->setStatusTip ( tr( "Add a branch below selection" ));
588 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
589 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
590 a->setEnabled (false);
591 actionListBranches.append(a);
592 actionEditAddBranchBelow=a;
593 a = new QAction(tr( "Add branch below" ), this);
594 a->setStatusTip ( tr( "Add a branch below selection" ));
595 a->setShortcut (Qt::CTRL +Qt::Key_A );
596 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
597 actionListBranches.append(a);
599 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
600 a->setStatusTip ( tr( "Move branch up" ) );
601 a->setShortcut (Qt::Key_PageUp );
602 a->setEnabled (false);
604 editMenu->addAction (a);
605 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
608 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
609 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
610 a->setStatusTip (tr( "Move branch down" ) );
611 a->setShortcut ( Qt::Key_PageDown );
612 a->setEnabled (false);
614 editMenu->addAction (a);
615 actionEditMoveDown=a;
618 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
619 a->setShortcut ( Qt::Key_ScrollLock );
620 a->setStatusTip (tr( "Scroll branch" ) );
621 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
622 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
623 alt->setShortcut ( Qt::Key_S );
624 alt->setStatusTip (tr( "Scroll branch" ));
625 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
626 #if defined(Q_OS_MACX)
627 actionEditToggleScroll=alt;
629 actionEditToggleScroll=a;
631 actionEditToggleScroll->setEnabled (false);
632 actionEditToggleScroll->setToggleAction(true);
633 tb->addAction (actionEditToggleScroll);
634 editMenu->addAction ( actionEditToggleScroll);
635 editMenu->addAction (actionEditToggleScroll);
636 actionListBranches.append(actionEditToggleScroll);
638 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
639 a->setStatusTip (tr( "Unscroll all" ));
640 editMenu->addAction (a);
641 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
643 editMenu->addSeparator();
645 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
646 a->setStatusTip (tr( "Find" ) );
647 a->setShortcut (Qt::CTRL + Qt::Key_F );
648 editMenu->addAction (a);
649 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
651 editMenu->addSeparator();
653 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
654 a->setShortcut (Qt::CTRL + Qt::Key_U );
655 a->setShortcut (tr( "Open URL" ));
657 a->setEnabled (false);
658 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
661 a = new QAction( tr( "Open URL in new tab" ), this);
662 a->setStatusTip (tr( "Open URL in new tab" ));
663 a->setShortcut (Qt::CTRL+Qt::Key_U );
664 a->setEnabled (false);
665 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
666 actionEditOpenURLTab=a;
668 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
669 a->setStatusTip ( tr( "Edit URL" ) );
670 a->setShortcut (Qt::SHIFT + Qt::CTRL+Qt::Key_U );
671 a->setEnabled (false);
672 actionListBranches.append(a);
673 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
676 a = new QAction( tr( "Use heading for URL" ), this);
677 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
678 a->setEnabled (false);
679 actionListBranches.append(a);
680 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
681 actionEditHeading2URL=a;
683 a = new QAction(tr( "Create URL to Bugzilla" ), this);
684 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
685 a->setEnabled (false);
686 actionListBranches.append(a);
687 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
688 actionEditBugzilla2URL=a;
690 a = new QAction(tr( "Create URL to FATE" ), this);
691 a->setStatusTip ( tr( "Create URL to FATE" ));
692 a->setEnabled (false);
693 actionListBranches.append(a);
694 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
695 actionEditFATE2URL=a;
697 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
698 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
700 a->setEnabled (false);
701 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
702 actionEditOpenVymLink=a;
704 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
705 a->setEnabled (false);
706 a->setStatusTip ( tr( "Edit link to another vym map" ));
707 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
708 actionListBranches.append(a);
711 a = new QAction(tr( "Delete vym link" ),this);
712 a->setStatusTip ( tr( "Delete link to another vym map" ));
713 a->setEnabled (false);
714 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
715 actionEditDeleteVymLink=a;
717 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
718 a->setStatusTip ( tr( "Hide object in exports" ) );
719 a->setShortcut (Qt::Key_H );
720 a->setToggleAction(true);
722 a->setEnabled (false);
723 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
724 actionEditToggleHideExport=a;
726 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
727 a->setStatusTip ( tr( "Edit Map Info" ));
728 a->setEnabled (true);
729 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
732 editMenu->addSeparator();
734 // Import at selection (adding to selection)
735 a = new QAction( tr( "Add map (insert)" ),this);
736 a->setStatusTip (tr( "Add map at selection" ));
737 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
738 a->setEnabled (false);
739 actionListBranches.append(a);
740 actionEditImportAdd=a;
742 // Import at selection (replacing selection)
743 a = new QAction( tr( "Add map (replace)" ), this);
744 a->setStatusTip (tr( "Replace selection with map" ));
745 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
746 a->setEnabled (false);
747 actionListBranches.append(a);
748 actionEditImportReplace=a;
751 a = new QAction( tr( "Save selection" ), this);
752 a->setStatusTip (tr( "Save selection" ));
753 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
754 a->setEnabled (false);
755 actionListBranches.append(a);
756 actionEditSaveBranch=a;
758 // Only remove branch, not its childs
759 a = new QAction(tr( "Remove only branch " ), this);
760 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
761 a->setShortcut (Qt::ALT + Qt::Key_Delete );
762 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
763 a->setEnabled (false);
764 actionListBranches.append(a);
765 actionEditRemoveBranchKeepChilds=a;
767 // Only remove childs of a branch
768 a = new QAction( tr( "Remove childs" ), this);
769 a->setStatusTip (tr( "Remove childs of branch" ));
770 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
771 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
772 a->setEnabled (false);
773 actionListBranches.append(a);
774 actionEditRemoveChilds=a;
776 // Shortcuts for navigating with cursor:
777 a = new QAction(tr( "Select upper branch" ), this);
778 a->setStatusTip ( tr( "Select upper branch" ));
779 a->setShortcut (Qt::Key_Up );
780 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
781 a = new QAction( tr( "Select lower branch" ),this);
782 a->setStatusTip (tr( "Select lower branch" ));
783 a->setShortcut ( Qt::Key_Down );
784 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
785 a = new QAction(tr( "Select left branch" ), this);
786 a->setStatusTip ( tr( "Select left branch" ));
787 a->setShortcut (Qt::Key_Left );
788 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
789 a = new QAction( tr( "Select child branch" ), this);
790 a->setStatusTip (tr( "Select right branch" ));
791 a->setShortcut (Qt::Key_Right);
792 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
793 a = new QAction( tr( "Select first branch" ), this);
794 a->setStatusTip (tr( "Select first branch" ));
795 a->setShortcut (Qt::Key_Home );
796 a->setEnabled (false);
797 editMenu->addAction (a);
798 actionListBranches.append(a);
799 actionEditSelectFirst=a;
800 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
801 a = new QAction( tr( "Select last branch" ),this);
802 a->setStatusTip (tr( "Select last branch" ));
803 a->setShortcut ( Qt::Key_End );
804 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
805 a->setEnabled (false);
806 editMenu->addAction (a);
807 actionListBranches.append(a);
808 actionEditSelectLast=a;
810 a = new QAction( tr( "Add Image" )+QString("..."), this);
811 a->setStatusTip (tr( "Add Image" ));
812 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
813 actionEditLoadImage=a;
818 void Main::setupFormatActions()
820 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
822 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
825 pix.fill (Qt::black);
826 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
827 a->setStatusTip ( tr( "Set Color" ));
828 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
830 formatMenu->addAction (a);
832 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
833 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
834 a->setShortcut (Qt::CTRL + Qt::Key_K );
835 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
836 a->setEnabled (false);
838 formatMenu->addAction (a);
839 actionListBranches.append(a);
840 actionFormatPickColor=a;
842 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
843 a->setStatusTip ( tr( "Color branch" ) );
844 a->setShortcut (Qt::CTRL + Qt::Key_I);
845 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
846 a->setEnabled (false);
848 formatMenu->addAction (a);
849 actionListBranches.append(a);
850 actionFormatColorBranch=a;
852 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
853 a->setStatusTip ( tr( "Color Subtree" ));
854 a->setShortcut (Qt::CTRL + Qt::Key_T);
855 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
856 a->setEnabled (false);
857 formatMenu->addAction (a);
859 actionListBranches.append(a);
860 actionFormatColorSubtree=a;
862 formatMenu->addSeparator();
863 actionGroupFormatLinkStyles=new QActionGroup ( this);
864 actionGroupFormatLinkStyles->setExclusive (true);
865 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
866 a->setStatusTip (tr( "Line" ));
867 a->setToggleAction(true);
868 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
869 formatMenu->addAction (a);
870 actionFormatLinkStyleLine=a;
871 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
872 a->setStatusTip (tr( "Line" ));
873 a->setToggleAction(true);
874 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
875 formatMenu->addAction (a);
876 actionFormatLinkStyleParabel=a;
877 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
878 a->setStatusTip (tr( "PolyLine" ));
879 a->setToggleAction(true);
880 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
881 formatMenu->addAction (a);
882 actionFormatLinkStylePolyLine=a;
883 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
884 a->setStatusTip (tr( "PolyParabel" ) );
885 a->setToggleAction(true);
886 a->setChecked (true);
887 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
888 formatMenu->addAction (a);
889 actionFormatLinkStylePolyParabel=a;
891 actionGroupFormatFrameTypes=new QActionGroup ( this);
892 actionGroupFormatFrameTypes->setExclusive (true);
893 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
894 a->setStatusTip (tr("No Frame"));
895 a->setToggleAction(true);
896 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
897 actionFormatFrameNone=a;
898 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
899 a->setStatusTip (tr( "Rectangle" ));
900 a->setToggleAction(true);
901 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
902 actionFormatFrameRectangle=a;
904 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
905 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
906 a->setToggleAction(true);
907 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
908 actionFormatIncludeImagesVer=a;
910 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
911 a->setStatusTip ( tr ("Include left and right position of images into branch"));
912 a->setToggleAction(true);
913 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
914 actionFormatIncludeImagesHor=a;
916 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
917 a->setStatusTip (tr( "Hide link" ));
918 a->setToggleAction(true);
919 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
920 actionFormatHideLinkUnselected=a;
922 formatMenu->addSeparator();
923 a= new QAction( tr( "&Use color of heading for link" ), this);
924 a->setStatusTip (tr( "Use same color for links and headings" ));
925 a->setToggleAction(true);
926 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
927 formatMenu->addAction (a);
928 actionFormatLinkColorHint=a;
930 pix.fill (Qt::white);
931 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
932 a->setStatusTip (tr( "Set Link Color" ));
933 formatMenu->addAction (a);
934 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
935 actionFormatLinkColor=a;
937 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
938 a->setStatusTip (tr( "Set Background Color" ));
939 formatMenu->addAction (a);
940 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
941 actionFormatBackColor=a;
945 void Main::setupViewActions()
947 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
948 tb->setLabel( "View Actions" );
949 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
952 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
953 a->setStatusTip ( tr( "Zoom reset" ) );
954 a->setShortcut (Qt::CTRL + Qt::Key_0 );
956 viewMenu->addAction (a);
957 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
959 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
960 a->setStatusTip (tr( "Zoom in" ));
961 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
963 viewMenu->addAction (a);
964 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
966 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
967 a->setStatusTip (tr( "Zoom out" ));
968 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
970 viewMenu->addAction (a);
971 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
974 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
975 a->setStatusTip ( tr( "Show Note Editor" ));
976 a->setShortcut ( Qt::CTRL + Qt::Key_E );
977 a->setToggleAction(true);
978 if (textEditor->showWithMain())
983 viewMenu->addAction (a);
984 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
985 actionViewToggleNoteEditor=a;
987 a = new QAction( tr( "Show history window" ),this );
988 a->setStatusTip ( tr( "Show history window" ));
989 a->setShortcut ( Qt::CTRL + Qt::Key_H );
990 a->setToggleAction(false);
991 viewMenu->addAction (a);
992 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
993 actionViewToggleHistoryWindow=a;
995 a = new QAction(tr( "Next Window" ), this);
996 a->setStatusTip ( tr( "&Next Window" ) );
997 a->setShortcut (Qt::ALT + Qt::Key_N );
998 viewMenu->addAction (a);
999 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
1001 a = new QAction (tr( "Previous Window" ), this );
1002 a->setStatusTip (tr( "&Previous Window" ));
1003 a->setShortcut (Qt::ALT + Qt::Key_P );
1004 viewMenu->addAction (a);
1005 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
1009 void Main::setupModeActions()
1011 //QPopupMenu *menu = new QPopupMenu( this );
1012 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1014 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1016 actionGroupModModes=new QActionGroup ( this);
1017 actionGroupModModes->setExclusive (true);
1018 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1019 a->setShortcut (Qt::Key_J);
1020 a->setStatusTip ( tr( "Use modifier to color branches" ));
1021 a->setToggleAction(true);
1024 actionModModeColor=a;
1026 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1027 a->setShortcut( Qt::Key_K);
1028 a->setStatusTip( tr( "Use modifier to copy" ));
1029 a->setToggleAction(true);
1031 actionModModeCopy=a;
1033 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1034 a->setShortcut (Qt::Key_L);
1035 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1036 a->setToggleAction(true);
1038 actionModModeLink=a;
1042 void Main::setupFlagActions()
1044 // Create System Flags
1045 systemFlagsDefault = new FlagRowObj ();
1046 systemFlagsDefault->setVisibility (false);
1047 systemFlagsDefault->setName ("systemFlagsDef");
1049 FlagObj *fo = new FlagObj ();
1050 fo->load(QPixmap(flagsPath+"flag-note.png"));
1051 fo->setName("note");
1052 fo->setToolTip(tr("Note","Systemflag"));
1053 systemFlagsDefault->addFlag (fo); // makes deep copy
1055 fo->load(QPixmap(flagsPath+"flag-url.png"));
1057 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1058 systemFlagsDefault->addFlag (fo);
1060 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1061 fo->setName("vymLink");
1062 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1063 systemFlagsDefault->addFlag (fo);
1065 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1066 fo->setName("scrolledright");
1067 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1068 systemFlagsDefault->addFlag (fo);
1070 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1071 fo->setName("tmpUnscrolledright");
1072 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1073 systemFlagsDefault->addFlag (fo);
1075 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1076 fo->setName("hideInExport");
1077 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1078 systemFlagsDefault->addFlag (fo);
1080 // Create Standard Flags
1081 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1083 standardFlagsDefault = new FlagRowObj ();
1084 standardFlagsDefault->setVisibility (false);
1085 standardFlagsDefault->setName ("standardFlagsDef");
1086 standardFlagsDefault->setToolBar (tb);
1088 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1089 fo->setName ("exclamationmark");
1090 fo->setGroup("standard-mark");
1091 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1094 a->setCheckable(true);
1095 a->setObjectName(fo->getName());
1096 a->setToolTip(tr("Take care!","Standardflag"));
1097 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1098 standardFlagsDefault->addFlag (fo); // makes deep copy
1100 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1101 fo->setName("questionmark");
1102 fo->setGroup("standard-mark");
1103 a=new QAction (fo->getPixmap(),fo->getName(),this);
1106 a->setCheckable(true);
1107 a->setObjectName(fo->getName());
1108 a->setToolTip(tr("Really?","Standardflag"));
1109 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1110 standardFlagsDefault->addFlag (fo);
1112 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1113 fo->setName("hook-green");
1114 fo->setGroup("standard-hook");
1115 a=new QAction (fo->getPixmap(),fo->getName(),this);
1118 a->setCheckable(true);
1119 a->setObjectName(fo->getName());
1120 a->setToolTip(tr("ok!","Standardflag"));
1121 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1122 standardFlagsDefault->addFlag (fo);
1124 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1125 fo->setName("cross-red");
1126 fo->setGroup("standard-hook");
1127 a=new QAction (fo->getPixmap(),fo->getName(),this);
1130 a->setCheckable(true);
1131 a->setObjectName(fo->getName());
1132 a->setToolTip(tr("Not ok!","Standardflag"));
1133 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1134 standardFlagsDefault->addFlag (fo);
1136 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1137 fo->setName("stopsign");
1138 a=new QAction (fo->getPixmap(),fo->getName(),this);
1141 a->setCheckable(true);
1142 a->setObjectName(fo->getName());
1143 a->setToolTip(tr("This won't work!","Standardflag"));
1144 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1145 standardFlagsDefault->addFlag (fo);
1147 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1148 fo->setName("smiley-good");
1149 fo->setGroup("standard-smiley");
1150 a=new QAction (fo->getPixmap(),fo->getName(),this);
1153 a->setCheckable(true);
1154 a->setObjectName(fo->getName());
1155 a->setToolTip(tr("Good","Standardflag"));
1156 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1157 standardFlagsDefault->addFlag (fo);
1159 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1160 fo->setName("smiley-sad");
1161 fo->setGroup("standard-smiley");
1162 a=new QAction (fo->getPixmap(),fo->getName(),this);
1165 a->setCheckable(true);
1166 a->setObjectName(fo->getName());
1167 a->setToolTip(tr("Bad","Standardflag"));
1168 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1169 standardFlagsDefault->addFlag (fo);
1171 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1172 // Original omg.png (in KDE emoticons)
1173 fo->setName("smiley-omg");
1174 fo->setGroup("standard-smiley");
1175 a=new QAction (fo->getPixmap(),fo->getName(),this);
1178 a->setCheckable(true);
1179 a->setObjectName(fo->getName());
1180 a->setToolTip(tr("Oh no!","Standardflag"));
1181 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1182 standardFlagsDefault->addFlag (fo);
1184 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1185 fo->setName("clock");
1186 a=new QAction (fo->getPixmap(),fo->getName(),this);
1189 a->setCheckable(true);
1190 a->setObjectName(fo->getName());
1191 a->setToolTip(tr("Time critical","Standardflag"));
1192 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1193 standardFlagsDefault->addFlag (fo);
1195 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1196 fo->setName("phone");
1197 a=new QAction (fo->getPixmap(),fo->getName(),this);
1200 a->setCheckable(true);
1201 a->setObjectName(fo->getName());
1202 a->setToolTip(tr("Call...","Standardflag"));
1203 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1204 standardFlagsDefault->addFlag (fo);
1206 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1207 fo->setName("lamp");
1208 a=new QAction (fo->getPixmap(),fo->getName(),this);
1211 a->setCheckable(true);
1212 a->setObjectName(fo->getName());
1213 a->setToolTip(tr("Idea!","Standardflag"));
1214 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1215 standardFlagsDefault->addFlag (fo);
1217 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1218 fo->setName("arrow-up");
1219 fo->setGroup("standard-arrow");
1220 a=new QAction (fo->getPixmap(),fo->getName(),this);
1223 a->setCheckable(true);
1224 a->setObjectName(fo->getName());
1225 a->setToolTip(tr("Important","Standardflag"));
1226 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1227 standardFlagsDefault->addFlag (fo);
1229 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1230 fo->setName("arrow-down");
1231 fo->setGroup("standard-arrow");
1232 a=new QAction (fo->getPixmap(),fo->getName(),this);
1235 a->setCheckable(true);
1236 a->setObjectName(fo->getName());
1237 a->setToolTip(tr("Unimportant","Standardflag"));
1238 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1239 standardFlagsDefault->addFlag (fo);
1241 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1242 fo->setName("2arrow-up");
1243 fo->setGroup("standard-arrow");
1244 a=new QAction (fo->getPixmap(),fo->getName(),this);
1247 a->setCheckable(true);
1248 a->setObjectName(fo->getName());
1249 a->setToolTip(tr("Very important!","Standardflag"));
1250 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1251 standardFlagsDefault->addFlag (fo);
1253 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1254 fo->setName("2arrow-down");
1255 fo->setGroup("standard-arrow");
1256 a=new QAction (fo->getPixmap(),fo->getName(),this);
1259 a->setCheckable(true);
1260 a->setObjectName(fo->getName());
1261 a->setToolTip(tr("Very unimportant!","Standardflag"));
1262 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1263 standardFlagsDefault->addFlag (fo);
1265 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1266 fo->setName("thumb-up");
1267 fo->setGroup("standard-thumb");
1268 a=new QAction (fo->getPixmap(),fo->getName(),this);
1271 a->setCheckable(true);
1272 a->setObjectName(fo->getName());
1273 a->setToolTip(tr("I like this","Standardflag"));
1274 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1275 standardFlagsDefault->addFlag (fo);
1277 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1278 fo->setName("thumb-down");
1279 fo->setGroup("standard-thumb");
1280 a=new QAction (fo->getPixmap(),fo->getName(),this);
1283 a->setCheckable(true);
1284 a->setObjectName(fo->getName());
1285 a->setToolTip(tr("I do not like this","Standardflag"));
1286 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1287 standardFlagsDefault->addFlag (fo);
1289 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1290 fo->setName("rose");
1291 a=new QAction (fo->getPixmap(),fo->getName(),this);
1294 a->setCheckable(true);
1295 a->setObjectName(fo->getName());
1296 a->setToolTip(tr("Rose","Standardflag"));
1297 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1298 standardFlagsDefault->addFlag (fo);
1300 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1301 fo->setName("heart");
1302 a=new QAction (fo->getPixmap(),fo->getName(),this);
1304 a->setCheckable(true);
1305 a->setObjectName(fo->getName());
1306 a->setToolTip(tr("I just love... ","Standardflag"));
1307 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1308 standardFlagsDefault->addFlag (fo);
1310 fo->load(QPixmap(flagsPath+"flag-present.png"));
1311 fo->setName("present");
1312 a=new QAction (fo->getPixmap(),fo->getName(),this);
1315 a->setCheckable(true);
1316 a->setObjectName(fo->getName());
1317 a->setToolTip(tr("Surprise!","Standardflag"));
1318 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1319 standardFlagsDefault->addFlag (fo);
1321 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1322 fo->setName("flash");
1323 a=new QAction (fo->getPixmap(),fo->getName(),this);
1326 a->setCheckable(true);
1327 a->setObjectName(fo->getName());
1328 a->setToolTip(tr("Dangerous","Standardflag"));
1329 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1330 standardFlagsDefault->addFlag (fo);
1332 fo->load(QPixmap(flagsPath+"flag-info.png"));
1333 // Original: xsldbg_output.png
1334 fo->setName("info");
1335 a=new QAction (fo->getPixmap(),fo->getName(),this);
1338 a->setCheckable(true);
1339 a->setObjectName(fo->getName());
1340 a->setToolTip(tr("Info","Standardflag"));
1341 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1342 standardFlagsDefault->addFlag (fo);
1344 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1345 // Original khelpcenter.png
1346 fo->setName("lifebelt");
1347 a=new QAction (fo->getPixmap(),fo->getName(),this);
1350 a->setCheckable(true);
1351 a->setObjectName(fo->getName());
1352 a->setToolTip(tr("This will help","Standardflag"));
1353 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1354 standardFlagsDefault->addFlag (fo);
1360 void Main::setupSettingsActions()
1362 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1366 a = new QAction( tr( "Set application to open pdf files"), this);
1367 a->setStatusTip ( tr( "Set application to open pdf files"));
1368 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1369 settingsMenu->addAction (a);
1371 a = new QAction( tr( "Set application to open external links"), this);
1372 a->setStatusTip( tr( "Set application to open external links"));
1373 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1374 settingsMenu->addAction (a);
1376 settingsMenu->addSeparator();
1377 a = new QAction( tr( "Edit branch after adding it" ), this );
1378 a->setStatusTip( tr( "Edit branch after adding it" ));
1379 a->setToggleAction(true);
1380 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1381 settingsMenu->addAction (a);
1382 actionSettingsAutoedit=a;
1384 a= new QAction( tr( "Select branch after adding it" ), this );
1385 a->setStatusTip( tr( "Select branch after adding it" ));
1386 a->setToggleAction(true);
1387 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1388 settingsMenu->addAction (a);
1389 actionSettingsAutoselectHeading=a;
1391 a= new QAction(tr( "Select existing heading" ), this);
1392 a->setStatusTip( tr( "Select heading before editing" ));
1393 a->setToggleAction(true);
1394 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1395 settingsMenu->addAction (a);
1396 actionSettingsAutoselectText=a;
1398 a= new QAction(tr( "pasting into new branch" ), this );
1399 a->setStatusTip( tr( "Pasting into new branch" ));
1400 a->setToggleAction(true);
1401 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1402 settingsMenu->addAction (a);
1403 actionSettingsPasteNewHeading=a;
1405 a= new QAction( tr( "Delete key" ), this);
1406 a->setStatusTip( tr( "Delete key for deleting branches" ));
1407 a->setToggleAction(true);
1408 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1409 settingsMenu->addAction (a);
1410 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1411 actionSettingsUseDelKey=a;
1413 a= new QAction( tr( "Exclusive flags" ), this);
1414 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1415 a->setToggleAction(true);
1416 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1417 settingsMenu->addAction (a);
1418 actionSettingsUseFlagGroups=a;
1420 a= new QAction( tr( "Use hide flags" ), this);
1421 a->setStatusTip( tr( "Use hide flag during exports " ));
1422 a->setToggleAction(true);
1423 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1424 settingsMenu->addAction (a);
1425 actionSettingsUseHideExport=a;
1429 void Main::setupTestActions()
1431 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1434 a = new QAction( tr( "test flag" ), this);
1435 a->setStatusTip( tr( "Call test function" ));
1436 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1437 testMenu->addAction (a);
1441 void Main::setupHelpActions()
1443 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1446 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1447 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1448 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1449 helpMenu->addAction (a);
1451 a = new QAction( tr( "About VYM" ), this);
1452 a->setStatusTip( tr( "About VYM")+" "__VYM);
1453 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1454 helpMenu->addAction (a);
1456 a = new QAction( tr( "About QT" ), this);
1457 a->setStatusTip( tr( "Information about QT toolkit" ));
1458 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1459 helpMenu->addAction (a);
1463 void Main::setupContextMenus()
1467 // Context Menu for branch or mapcenter
1468 branchContextMenu =new QMenu (this);
1471 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1472 branchAddContextMenu->addAction (actionEditPaste );
1473 branchAddContextMenu->addAction ( actionEditAddBranch );
1474 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1475 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1476 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1477 branchAddContextMenu->addSeparator();
1478 branchAddContextMenu->addAction ( actionEditLoadImage);
1479 branchAddContextMenu->addSeparator();
1480 branchAddContextMenu->addAction ( actionEditLoadImage);
1481 branchAddContextMenu->addAction ( actionEditImportAdd );
1482 branchAddContextMenu->addAction ( actionEditImportReplace );
1485 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1486 branchRemoveContextMenu->addAction (actionEditCut);
1487 branchRemoveContextMenu->addAction ( actionEditDelete );
1488 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1489 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1492 actionEditSaveBranch->addTo( branchContextMenu );
1494 branchContextMenu->addSeparator();
1495 branchContextMenu->addAction ( actionEditOpenURL );
1496 branchContextMenu->addAction ( actionEditOpenURLTab );
1497 branchContextMenu->addAction ( actionEditURL );
1498 branchContextMenu->addAction ( actionEditHeading2URL );
1499 branchContextMenu->addAction ( actionEditBugzilla2URL );
1500 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1502 branchContextMenu->addAction ( actionEditFATE2URL );
1504 branchContextMenu->addSeparator();
1505 branchContextMenu->addAction ( actionEditOpenVymLink );
1506 branchContextMenu->addAction ( actionEditVymLink );
1507 branchContextMenu->addAction ( actionEditDeleteVymLink );
1509 branchContextMenu->addSeparator();
1510 branchContextMenu->addAction ( actionFormatFrameNone );
1511 branchContextMenu->addAction ( actionFormatFrameRectangle);
1513 branchContextMenu->addSeparator();
1514 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1515 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1516 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1518 // Context Menu for links in a branch menu
1519 // This will be populated "on demand" in MapEditor::updateActions
1520 branchContextMenu->addSeparator();
1521 /* FIXME not yet ported from QT3
1522 branchLinksContextMenu =new Q3PopupMenu (this);
1523 branchLinksContextMenuDup =new Q3PopupMenu (this);
1524 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1525 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1527 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1528 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1531 // Context menu for floatimage
1532 floatimageContextMenu =new QMenu (this);
1533 saveImageFormatMenu=floatimageContextMenu->addMenu (tr("Save image"));
1535 foreach (QByteArray format, QImageWriter::supportedImageFormats())
1537 QString text = tr("%1...").arg(QString(format).toUpper());
1538 a= new QAction (text,this);
1539 saveImageFormatMenu->addAction ( a );
1542 /* FIXME not needed any longer
1543 Q3StrList fmt = QImageWriter::supportedImageFormats();
1544 for (const char* f = fmt.first(); f; f = fmt.next())
1546 saveImageFormatMenu->insertItem( f );
1547 exportImageFormatMenu->insertItem( f );
1550 // connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1551 // connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1553 floatimageContextMenu->addSeparator();
1554 actionEditCopy->addTo( floatimageContextMenu );
1555 actionEditCut->addTo( floatimageContextMenu );
1557 floatimageContextMenu->addSeparator();
1558 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1561 // Context menu for canvas
1562 canvasContextMenu =new QMenu (this);
1563 actionEditMapInfo->addTo( canvasContextMenu );
1564 canvasContextMenu->insertSeparator();
1565 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1566 canvasContextMenu->insertSeparator();
1567 actionFormatLinkColorHint->addTo( canvasContextMenu );
1568 actionFormatLinkColor->addTo( canvasContextMenu );
1569 actionFormatBackColor->addTo( canvasContextMenu );
1571 // Menu for last opened files
1572 // Read settings initially
1574 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1575 for (int i=1;i<=j;i++)
1577 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1578 if (!s.isEmpty() && j<=maxLastMaps)
1581 setupLastMapsMenu();
1582 // connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1585 void Main::setupLastMapsMenu()
1587 // Remove double entries
1588 QStringList::Iterator it=lastMaps.begin();
1589 QStringList::Iterator jt;
1590 while (it!=lastMaps.end() )
1594 while (jt!=lastMaps.end() )
1597 jt=lastMaps.remove(jt);
1604 // Limit length of list to maxLastMaps
1605 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1607 // build Menu from lastMaps string list
1608 fileLastMapsMenu->clear();
1609 /* FIXME add actions instead of strings in QT4
1610 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1611 fileLastMapsMenu->addAction (*it );
1616 void Main::hideEvent (QHideEvent * )
1618 if (!textEditor->isMinimized() ) textEditor->hide();
1621 void Main::showEvent (QShowEvent * )
1623 if (textEditor->showWithMain()) textEditor->showNormal();
1626 bool Main::reallyWriteDirectory(const QString &dir)
1628 QStringList eList = QDir(dir).entryList();
1629 if (eList.first() ==".") eList.pop_front(); // remove "."
1630 if (eList.first() =="..") eList.pop_front(); // remove "."
1631 if (!eList.isEmpty())
1633 QMessageBox mb( __VYM,
1634 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1635 QMessageBox::Warning,
1637 QMessageBox::Cancel | QMessageBox::Default,
1638 QMessageBox::QMessageBox::NoButton );
1640 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1641 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1644 case QMessageBox::Yes:
1647 case QMessageBox::Cancel:
1655 QString Main::browseDirectory (const QString &caption)
1657 Q3FileDialog fd(this,caption);
1658 fd.setMode (Q3FileDialog::DirectoryOnly);
1659 fd.setCaption(__VYM " - "+caption);
1662 if ( fd.exec() == QDialog::Accepted )
1663 return fd.selectedFile();
1668 MapEditor* Main::currentMapEditor() const
1670 if ( tabWidget->currentPage() &&
1671 tabWidget->currentPage()->inherits( "MapEditor" ) )
1672 return (MapEditor*)tabWidget->currentPage();
1676 //TODO not used now, maybe use this for overview window later
1677 void Main::newView()
1679 // Open a new view... have it delete when closed.
1680 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1681 qApp->setMainWidget(m);
1683 qApp->setMainWidget(0);
1686 void Main::editorChanged(QWidget *)
1688 // Unselect all possibly selected objects
1689 // (Important to update note editor)
1692 for (i=0;i<=tabWidget->count() -1;i++)
1695 me=(MapEditor*)tabWidget->page(i);
1698 currentMapEditor()->reselect();
1700 // Update actions to in menus and toolbars according to editor
1701 currentMapEditor()->updateActions();
1704 void Main::fileNew()
1706 QString fn="unnamed";
1707 MapEditor* medit = new MapEditor ( NULL,true);
1708 tabWidget->addTab (medit,fn);
1709 tabWidget->showPage(medit);
1710 medit->viewport()->setFocus();
1711 // For the very first map we do not have flagrows yet...
1712 medit->select("mc:");
1715 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1717 ErrorCode err=success;
1719 // fn is usually the archive, mapfile the file after uncompressing
1722 // Make fn absolute (needed for unzip)
1723 fn=QDir (fn).absPath();
1729 // Check, if map is already loaded
1731 while (i<=tabWidget->count() -1)
1733 me=(MapEditor*)tabWidget->page(i);
1734 if (me->getFilePath() == fn)
1736 // Already there, ask for confirmation
1737 QMessageBox mb( __VYM,
1738 tr("The map %1\nis already opened."
1739 "Opening the same map in multiple editors may lead \n"
1740 "to confusion when finishing working with vym."
1741 "Do you want to").arg(fn),
1742 QMessageBox::Warning,
1743 QMessageBox::Yes | QMessageBox::Default,
1744 QMessageBox::Cancel | QMessageBox::Escape,
1745 QMessageBox::NoButton);
1746 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1747 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1750 case QMessageBox::Yes:
1752 i=tabWidget->count();
1754 case QMessageBox::Cancel:
1766 if ( !fn.isEmpty() )
1768 me = currentMapEditor();
1769 int tabIndex=tabWidget->currentPageIndex();
1770 // Check first, if mapeditor exists
1771 // If it is not default AND we want a new map,
1772 // create a new mapeditor in a new tab
1773 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1775 me= new MapEditor ( NULL,true);
1776 tabWidget->addTab (me,fn);
1777 tabIndex=tabWidget->indexOf (me);
1778 tabWidget->setCurrentPage (tabIndex);
1781 // Check, if file exists (important for creating new files
1782 // from command line
1783 if (!QFile(fn).exists() )
1785 QMessageBox mb( __VYM,
1786 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1787 QMessageBox::Question,
1789 QMessageBox::Cancel | QMessageBox::Default,
1790 QMessageBox::NoButton );
1792 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1793 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1796 case QMessageBox::Yes:
1798 currentMapEditor()->setFilePath(fn);
1799 tabWidget->setTabLabel (currentMapEditor(),
1800 currentMapEditor()->getFileName() );
1801 statusBar()->message( "Created " + fn , statusbarTime );
1804 case QMessageBox::Cancel:
1805 // don't create new map
1806 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1813 //tabWidget->currentPage() won't be NULL here, because of above...
1814 tabWidget->showPage(me);
1815 me->viewport()->setFocus();
1817 // Create temporary directory for packing
1818 char tmpdir1[]="/tmp/vym-XXXXXX";
1819 QString tmpMapDir=mkdtemp(tmpdir1);
1821 // Try to unzip file
1822 err=unzipDir (tmpMapDir,fn);
1826 me->setZipped(false);
1829 me->setZipped(true);
1831 // Look for mapname.xml
1832 mapfile= fn.left(fn.findRev(".",-1,true));
1833 mapfile=mapfile.section( '/', -1 );
1834 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1835 if (!file.exists() )
1837 // mapname.xml does not exist, well,
1838 // maybe some renamed the mapname.vym file...
1839 // Try to find any .xml in the toplevel
1840 // directory of the .vym file
1841 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1842 if (flist.count()==1)
1844 // Only one entry, take this one
1845 mapfile=tmpMapDir + "/"+flist.first();
1848 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1849 *it=tmpMapDir + "/" + *it;
1850 // TODO Multiple entries, load all (but only the first one into this ME)
1851 //mainWindow->fileLoadFromTmp (flist);
1852 //returnCode=1; // Silently forget this attempt to load
1853 qWarning ("MainWindow::load (fn) multimap found...");
1856 if (flist.isEmpty() )
1858 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1859 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1862 } //file doesn't exist
1864 mapfile=file.name();
1869 // Save existing filename in case we import
1870 QString fn_org=me->getFilePath();
1872 // Finally load map into mapEditor
1873 me->setFilePath (mapfile,fn);
1874 err=me->load(mapfile,lmode);
1876 // Restore old (maybe empty) filepath, if this is an import
1878 me->setFilePath (fn_org);
1881 // Finally check for errors and go home
1884 if (lmode==NewMap) fileCloseMap();
1885 statusBar()->message( "Could not load " + fn, statusbarTime );
1890 me->setFilePath (fn);
1891 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1892 if (fn.left(9)!="/tmp/vym-")
1894 // Only append to lastMaps if not loaded from a tmpDir
1895 // e.g. imported bookmarks are in a tmpDir
1896 lastMaps.prepend(me->getFilePath() );
1897 setupLastMapsMenu();
1899 actionFilePrint->setEnabled (true);
1901 statusBar()->message( "Loaded " + fn, statusbarTime );
1905 removeDir (QDir(tmpMapDir));
1911 void Main::fileLoad(const LoadMode &lmode)
1913 Q3FileDialog *fd=new Q3FileDialog( this);
1914 if (!lastFileDir.isEmpty())
1915 fd->setDir (lastFileDir);
1916 fd->setMode (Q3FileDialog::ExistingFiles);
1917 fd->addFilter ("XML (*.xml)");
1918 fd->addFilter ("VYM map (*.vym *.vyp)");
1922 fd->setCaption(tr("Load vym map"));
1925 fd->setCaption(tr("Import: Add vym map to selection"));
1928 fd->setCaption(tr("Import: Replace selection with vym map"));
1934 if ( fd->exec() == QDialog::Accepted )
1936 lastFileDir=fd->dirPath();
1937 QStringList flist = fd->selectedFiles();
1938 QStringList::Iterator it = flist.begin();
1939 while( it != flist.end() )
1942 fileLoad(*it, lmode);
1949 void Main::fileLoad()
1954 void Main::fileLoadLast(int i)
1956 fileLoad(QString(*lastMaps.at(fileLastMapsMenu->indexOf (i)) ),NewMap);
1959 void Main::fileSave(const SaveMode &savemode)
1961 // tmp dir for zipping
1965 ErrorCode err=success;
1967 QString safeFilePath;
1969 bool saveZipped=currentMapEditor()->saveZipped();
1971 MapEditor * me=currentMapEditor();
1974 QString fn=me->getFilePath();
1975 // filename=unnamed, filepath="" in constructor...
1976 if ( !fn.isEmpty() )
1978 // We have a filepath, go on saving
1979 // First remove existing file, we
1980 // don't want to add to old zip archives
1984 QMessageBox::warning( 0, tr( "Save Error" ),
1985 fn+ tr("\ncould not be removed before saving"));
1987 // Look, if we should zip the data:
1990 QMessageBox mb( __VYM,
1991 tr("The map %1\ndid not use the compressed "
1992 "vym file format.\nWriting it uncompressed will also write images \n"
1993 "and flags and thus may overwrite files in the "
1994 "given directory\n\nDo you want to write the map").arg(fn),
1995 QMessageBox::Warning,
1996 QMessageBox::Yes | QMessageBox::Default,
1998 QMessageBox::Cancel | QMessageBox::Escape);
1999 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2000 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2001 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2004 case QMessageBox::Yes:
2005 // save compressed (default file format)
2008 case QMessageBox::No:
2009 // save uncompressed
2012 case QMessageBox::Cancel:
2021 char tmpdir1[]="/tmp/vym-XXXXXX";
2022 tmpMapDir=mkdtemp(tmpdir1);
2024 safeFilePath=me->getFilePath();
2025 me->setFilePath (tmpMapDir+"/"+
2026 me->getMapName()+ ".xml",
2028 me->save (savemode);
2029 me->setFilePath (safeFilePath);
2031 zipDir (tmpMapDir,fn);
2036 safeFilePath=me->getFilePath();
2037 me->setFilePath (fn, safeFilePath);
2038 me->save (savemode);
2039 me->setFilePath (safeFilePath);
2041 } // filepath available
2044 // We have no filepath yet,
2045 // call fileSaveAs() now, this will call fileSave()
2047 fileSaveAs(savemode);
2051 if (saveZipped && !tmpMapDir.isEmpty())
2053 removeDir (QDir(tmpMapDir));
2057 statusBar()->message(
2058 tr("Saved %1").arg(me->getFilePath()),
2060 lastMaps.prepend(me->getFilePath() );
2061 setupLastMapsMenu();
2063 statusBar()->message(
2064 tr("Couldn't save ").arg(me->getFilePath()),
2068 void Main::fileSave()
2070 fileSave (CompleteMap);
2073 void Main::fileSaveAs(const SaveMode& savemode)
2077 if (currentMapEditor())
2079 if (savemode==CompleteMap)
2080 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2082 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2083 if ( !fn.isEmpty() )
2085 // Check for existing file
2086 if (QFile (fn).exists())
2088 QMessageBox mb( __VYM,
2089 tr("The file %1\nexists already. Do you want to").arg(fn),
2090 QMessageBox::Warning,
2091 QMessageBox::Yes | QMessageBox::Default,
2092 QMessageBox::Cancel | QMessageBox::Escape,
2093 QMessageBox::NoButton);
2094 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2095 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2098 case QMessageBox::Yes:
2101 case QMessageBox::Cancel:
2108 // New file, add extension to filename, if missing
2109 // This is always .vym or .vyp, depending on savemode
2110 if (savemode==CompleteMap)
2112 if (!fn.contains (".vym") && !fn.contains (".xml"))
2116 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2125 currentMapEditor()->setFilePath(fn);
2129 if (savemode==CompleteMap)
2130 tabWidget->setTabLabel (currentMapEditor(),
2131 currentMapEditor()->getFileName() );
2137 void Main::fileSaveAs()
2139 fileSaveAs (CompleteMap);
2142 void Main::fileImportKDEBookmarks()
2144 ImportKDEBookmarks im;
2146 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2147 currentMapEditor()->setFilePath ("");
2150 void Main::fileImportFirefoxBookmarks()
2152 Q3FileDialog *fd=new Q3FileDialog( this);
2153 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2154 fd->setMode (Q3FileDialog::ExistingFiles);
2155 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2156 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2159 if ( fd->exec() == QDialog::Accepted )
2161 ImportFirefoxBookmarks im;
2162 QStringList flist = fd->selectedFiles();
2163 QStringList::Iterator it = flist.begin();
2164 while( it != flist.end() )
2167 if (im.transform() &&
2168 success==fileLoad (im.getTransformedFile(),NewMap) &&
2169 currentMapEditor() )
2170 currentMapEditor()->setFilePath ("");
2177 void Main::fileImportMM()
2181 Q3FileDialog *fd=new Q3FileDialog( this);
2182 if (!lastFileDir.isEmpty())
2183 fd->setDir (lastFileDir);
2184 fd->setMode (Q3FileDialog::ExistingFiles);
2185 fd->addFilter ("Mind Manager (*.mmap)");
2186 fd->setCaption(tr("Import")+" "+"Mind Manager");
2189 if ( fd->exec() == QDialog::Accepted )
2191 lastFileDir=fd->dirPath();
2192 QStringList flist = fd->selectedFiles();
2193 QStringList::Iterator it = flist.begin();
2194 while( it != flist.end() )
2197 if (im.transform() &&
2198 success==fileLoad (im.getTransformedFile(),NewMap) &&
2199 currentMapEditor() )
2200 currentMapEditor()->setFilePath ("");
2209 void Main::fileImportDir()
2211 if (currentMapEditor())
2212 currentMapEditor()->importDir();
2215 void Main::fileExportXML()
2217 if (currentMapEditor())
2219 QString dir=browseDirectory(tr("Export XML to directory"));
2220 if (dir !="" && reallyWriteDirectory(dir) )
2221 currentMapEditor()->exportXML(dir);
2226 void Main::fileExportXHTML()
2228 MapEditor *me=currentMapEditor();
2232 ExportXHTMLDialog dia(this);
2233 dia.setFilePath (me->getFilePath() );
2234 dia.setMapName (me->getMapName() );
2237 if (dia.exec()==QDialog::Accepted)
2239 QString dir=dia.getDir();
2240 // Check, if warnings should be used before overwriting
2241 // the output directory
2244 ok=reallyWriteDirectory(dir);
2250 me->exportXML (dia.getDir() );
2251 dia.doExport(me->getMapName() );
2252 if (dia.hasChanged())
2259 void Main::fileExportImage()
2261 MapEditor *me=currentMapEditor();
2265 QFileDialog *fd=new QFileDialog (this);
2266 fd->setCaption (tr("Export map as image"));
2267 fd->setFileMode(QFileDialog::AnyFile);
2268 fd->setFilters (imageIO.getFilters() );
2269 fd->setDirectory (lastImageDir);
2272 fl=fd->selectedFiles();
2273 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2274 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2279 void Main::fileExportASCII()
2281 MapEditor *me=currentMapEditor();
2285 ex.setMapCenter(me->getMapCenter());
2286 ex.addFilter ("TXT (*.txt)");
2287 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2288 if (ex.execDialog() )
2290 me->setExportMode(true);
2292 me->setExportMode(false);
2297 void Main::fileExportLaTeX()
2299 MapEditor *me=currentMapEditor();
2303 ex.setMapCenter(me->getMapCenter());
2304 ex.addFilter ("Tex (*.tex)");
2305 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2306 if (ex.execDialog() )
2308 me->setExportMode(true);
2310 me->setExportMode(false);
2315 void Main::fileExportKDEBookmarks()
2317 ExportKDEBookmarks ex;
2318 MapEditor *me=currentMapEditor();
2321 ex.setMapCenter (me->getMapCenter() );
2326 void Main::fileExportTaskjuggler()
2328 ExportTaskjuggler ex;
2329 MapEditor *me=currentMapEditor();
2332 ex.setMapCenter (me->getMapCenter() );
2333 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2334 ex.addFilter ("Taskjuggler (*.tjp)");
2335 if (ex.execDialog() )
2337 me->setExportMode(true);
2339 me->setExportMode(false);
2344 void Main::fileExportOOPresentation()
2346 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2347 // FIXME add extra info in dialog
2348 //ImagePreview *p =new ImagePreview (fd);
2349 //fd->setContentsPreviewEnabled( TRUE );
2350 //fd->setContentsPreview( p, p );
2351 //fd->setPreviewMode( QFileDialog::Contents );
2352 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2353 //fd->setDir (lastImageDir);
2356 if ( fd->exec() == QDialog::Accepted )
2358 QString fn=fd->selectedFile();
2359 //lastImageDir=fn.left(fn.findRev ("/"));
2360 if (currentMapEditor())
2361 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2365 void Main::fileCloseMap()
2367 if (currentMapEditor())
2369 if (currentMapEditor()->hasChanged())
2371 QMessageBox mb( __VYM,
2372 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2373 QMessageBox::Warning,
2374 QMessageBox::Yes | QMessageBox::Default,
2376 QMessageBox::Cancel | QMessageBox::Escape );
2377 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2378 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2381 case QMessageBox::Yes:
2383 fileSave(CompleteMap);
2385 case QMessageBox::No:
2386 // close without saving
2388 case QMessageBox::Cancel:
2393 currentMapEditor()->closeMap();
2394 tabWidget->removePage(currentMapEditor());
2395 if (tabWidget->count()==0)
2396 actionFilePrint->setEnabled (false);
2400 void Main::filePrint()
2402 if (currentMapEditor())
2403 currentMapEditor()->print();
2406 void Main::fileExitVYM()
2408 // Check if one or more editors have changed
2411 for (i=0;i<=tabWidget->count() -1;i++)
2414 me=(MapEditor*)tabWidget->page(i);
2416 // If something changed, ask what to do
2417 if (me->isUnsaved())
2419 tabWidget->setCurrentPage(i);
2420 QMessageBox mb( __VYM,
2421 tr("This map is not saved yet. Do you want to"),
2422 QMessageBox::Warning,
2423 QMessageBox::Yes | QMessageBox::Default,
2425 QMessageBox::Cancel | QMessageBox::Escape );
2426 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2427 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2429 mb.setActiveWindow();
2430 switch( mb.exec() ) {
2431 case QMessageBox::Yes:
2432 // save (the changed editors) and exit
2433 fileSave(CompleteMap);
2435 case QMessageBox::No:
2436 // exit without saving
2438 case QMessageBox::Cancel:
2439 // don't save and don't exit
2443 } // loop over all MEs
2447 void Main::editUndo()
2449 if (currentMapEditor())
2450 currentMapEditor()->undo();
2453 void Main::editRedo()
2455 if (currentMapEditor())
2456 currentMapEditor()->redo();
2459 void Main::editCopy()
2461 if (currentMapEditor())
2462 currentMapEditor()->copy();
2465 void Main::editPaste()
2467 if (currentMapEditor())
2468 currentMapEditor()->paste();
2471 void Main::editCut()
2473 if (currentMapEditor())
2474 currentMapEditor()->cut();
2477 void Main::editOpenFindWindow()
2479 findWindow->popup();
2480 findWindow->raise();
2481 findWindow->setActiveWindow();
2484 void Main::editFind(QString s)
2487 BranchObj *bo=currentMapEditor()->findText(s, cs);
2490 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2493 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2494 tr("No matches found for \"%1\"").arg(s));
2498 void Main::editFindChanged()
2499 { // Notify editor, to abort the current find process
2500 currentMapEditor()->findReset();
2503 void Main::editOpenURL()
2506 if (currentMapEditor())
2508 QString url=currentMapEditor()->getURL();
2509 if (url=="") return;
2510 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2511 procBrowser = new Q3Process( this );
2513 procBrowser->addArgument( browser);
2514 procBrowser->addArgument( url);
2516 if ( !procBrowser->start() )
2518 // try to set path to browser
2519 QMessageBox::warning(0,
2521 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2522 tr("Please use Settings->")+tr("Set application to open an URL"));
2527 void Main::editOpenURLTab()
2529 if (currentMapEditor())
2531 QString url=currentMapEditor()->getURL();
2532 if (url=="") return;
2533 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2534 if (procBrowser && procBrowser->isRunning())
2536 if (browser.contains("konqueror"))
2538 // Try to open new tab in existing konqueror started previously by vym
2539 Q3Process *p=new Q3Process (this);
2540 p->addArgument ("dcop");
2541 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2542 p->addArgument ("konqueror-mainwindow#1");
2543 p->addArgument ("newTab");
2544 p->addArgument (url);
2546 // try to set browser
2547 QMessageBox::warning(0,
2549 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2551 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2553 // Try to open new tab in firefox
2554 Q3Process *p=new Q3Process (this);
2555 p->addArgument (browser);
2556 p->addArgument ("-remote");
2557 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2559 // try to set browser
2560 QMessageBox::warning(0,
2562 tr("Couldn't start %1 to open a new tab").arg(browser));
2571 void Main::editURL()
2573 if (currentMapEditor())
2574 currentMapEditor()->editURL();
2577 void Main::editHeading2URL()
2579 if (currentMapEditor())
2580 currentMapEditor()->editHeading2URL();
2583 void Main::editBugzilla2URL()
2585 if (currentMapEditor())
2586 currentMapEditor()->editBugzilla2URL();
2589 void Main::editFATE2URL()
2591 if (currentMapEditor())
2592 currentMapEditor()->editFATE2URL();
2595 void Main::editOpenVymLink()
2597 // Get current path to map
2598 QString currentVymLink;
2599 if (currentMapEditor())
2601 currentVymLink=currentMapEditor()->getVymLink();
2602 // compare path with already loaded maps
2606 for (i=0;i<=tabWidget->count() -1;i++)
2608 me=(MapEditor*)tabWidget->page(i);
2609 if (currentVymLink==me->getFilePath() )
2618 if (!QFile(currentVymLink).exists() )
2619 QMessageBox::critical( 0, tr( "Critical Error" ),
2620 tr("Couldn't open map %1").arg(currentVymLink));
2623 fileLoad (currentVymLink, NewMap);
2624 tabWidget->setCurrentPage (tabWidget->count()-1);
2627 // Go to tab containing the map
2628 tabWidget->setCurrentPage (index);
2632 void Main::editVymLink()
2634 if (currentMapEditor())
2635 currentMapEditor()->editVymLink();
2638 void Main::editDeleteVymLink()
2640 if (currentMapEditor())
2641 currentMapEditor()->deleteVymLink();
2644 void Main::editToggleHideExport()
2646 if (currentMapEditor())
2647 currentMapEditor()->toggleHideExport();
2650 void Main::editMapInfo()
2652 if (currentMapEditor())
2653 currentMapEditor()->editMapInfo();
2656 void Main::editMoveUp()
2658 if (currentMapEditor())
2659 currentMapEditor()->moveBranchUp();
2662 void Main::editMoveDown()
2664 if (currentMapEditor())
2665 currentMapEditor()->moveBranchDown();
2668 void Main::editToggleScroll()
2670 if (currentMapEditor())
2672 currentMapEditor()->toggleScroll();
2676 void Main::editUnScrollAll()
2678 if (currentMapEditor())
2680 currentMapEditor()->unScrollAll();
2684 void Main::editHeading()
2686 qWarning ("Main::editHeading called");
2687 if (currentMapEditor())
2688 currentMapEditor()->editHeading();
2691 void Main::editNewBranch()
2694 // tried to see if maybe currentMapEditor is not set, but
2695 // ME does not seem to send a key event anyway...:q
2696 //here i was last time...
2698 cout << "Main::editNewBranch\n";
2699 if (currentMapEditor())
2700 currentMapEditor()->addNewBranch(0);
2703 void Main::editNewBranchHere()
2705 if (currentMapEditor())
2706 currentMapEditor()->addNewBranchHere();
2709 void Main::editNewBranchAbove()
2711 if (currentMapEditor())
2712 currentMapEditor()->addNewBranch(-1);
2715 void Main::editNewBranchBelow()
2717 if (currentMapEditor())
2718 currentMapEditor()->addNewBranch(1);
2721 void Main::editImportAdd()
2723 fileLoad (ImportAdd);
2726 void Main::editImportReplace()
2728 fileLoad (ImportReplace);
2731 void Main::editSaveBranch()
2733 fileSaveAs (PartOfMap);
2736 void Main::editRemoveBranchKeepChilds()
2738 if (currentMapEditor())
2739 currentMapEditor()->removeBranchKeepChilds();
2742 void Main::editRemoveChilds()
2744 if (currentMapEditor())
2745 currentMapEditor()->removeChilds();
2748 void Main::editDeleteSelection()
2750 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2751 currentMapEditor()->deleteSelection();
2754 void Main::editUpperBranch()
2756 if (currentMapEditor())
2757 currentMapEditor()->selectUpperBranch();
2760 void Main::editLowerBranch()
2762 if (currentMapEditor())
2763 currentMapEditor()->selectLowerBranch();
2766 void Main::editLeftBranch()
2768 if (currentMapEditor())
2769 currentMapEditor()->selectLeftBranch();
2772 void Main::editRightBranch()
2774 if (currentMapEditor())
2775 currentMapEditor()->selectRightBranch();
2778 void Main::editFirstBranch()
2780 if (currentMapEditor())
2781 currentMapEditor()->selectFirstBranch();
2784 void Main::editLastBranch()
2786 if (currentMapEditor())
2787 currentMapEditor()->selectLastBranch();
2790 void Main::editLoadImage()
2792 if (currentMapEditor())
2793 currentMapEditor()->loadFloatImage();
2796 void Main::editSaveImage(int item)
2798 if (currentMapEditor())
2799 currentMapEditor()->saveFloatImage(item);
2802 void Main::editFollowXLink(int item)
2804 if (currentMapEditor())
2805 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2808 void Main::editEditXLink(int item)
2810 if (currentMapEditor())
2811 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2814 void Main::formatSelectColor()
2816 if (currentMapEditor())
2818 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2819 if ( !col.isValid() ) return;
2820 currentMapEditor()->setColor( col );
2821 colorChanged( col );
2825 void Main::formatPickColor()
2827 if (currentMapEditor())
2828 colorChanged( currentMapEditor()->pickColor() );
2831 void Main::colorChanged(QColor c)
2833 QPixmap pix( 16, 16 );
2835 actionFormatColor->setIconSet( pix );
2838 void Main::formatColorItem()
2840 if (currentMapEditor())
2841 currentMapEditor()->colorItem();
2844 void Main::formatColorBranch()
2846 if (currentMapEditor())
2847 currentMapEditor()->colorBranch();
2850 void Main::formatLinkStyleLine()
2852 if (currentMapEditor())
2853 currentMapEditor()->setLinkStyle(StyleLine);
2856 void Main::formatLinkStyleParabel()
2858 if (currentMapEditor())
2859 currentMapEditor()->setLinkStyle(StyleParabel);
2862 void Main::formatLinkStylePolyLine()
2864 if (currentMapEditor())
2865 currentMapEditor()->setLinkStyle(StylePolyLine);
2868 void Main::formatLinkStylePolyParabel()
2870 if (currentMapEditor())
2871 currentMapEditor()->setLinkStyle(StylePolyParabel);
2874 void Main::formatSelectBackColor()
2876 if (currentMapEditor())
2877 currentMapEditor()->selectBackgroundColor();
2880 void Main::formatSelectLinkColor()
2882 if (currentMapEditor())
2883 currentMapEditor()->selectLinkColor();
2886 void Main::formatToggleLinkColorHint()
2888 currentMapEditor()->toggleLinkColorHint();
2891 void Main::formatFrameNone()
2893 if (currentMapEditor())
2894 currentMapEditor()->setFrame(NoFrame);
2897 void Main::formatFrameRectangle()
2899 if (currentMapEditor())
2900 currentMapEditor()->setFrame(Rectangle);
2903 void Main::formatIncludeImagesVer()
2905 if (currentMapEditor())
2906 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2909 void Main::formatIncludeImagesHor()
2911 if (currentMapEditor())
2912 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2915 void Main::formatHideLinkUnselected()
2917 if (currentMapEditor())
2918 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2921 void Main::viewZoomReset()
2923 if (currentMapEditor())
2927 currentMapEditor()->setWorldMatrix( m );
2928 currentMapEditor()->setViewCenter();
2929 currentMapEditor()->adjustCanvasSize();
2933 void Main::viewZoomIn()
2935 if (currentMapEditor())
2937 QMatrix m = currentMapEditor()->worldMatrix();
2938 m.scale( 1.25, 1.25 );
2939 currentMapEditor()->setWorldMatrix( m );
2940 currentMapEditor()->setViewCenter();
2941 currentMapEditor()->adjustCanvasSize();
2945 void Main::viewZoomOut()
2947 if (currentMapEditor())
2949 QMatrix m = currentMapEditor()->worldMatrix();
2950 m.scale( 0.8, 0.8 );
2951 currentMapEditor()->setWorldMatrix( m );
2952 currentMapEditor()->setViewCenter();
2953 currentMapEditor()->adjustCanvasSize();
2957 void Main::modModeColor()
2961 void Main::modModeLink()
2965 bool Main::settingsPDF()
2967 // Default browser is set in constructor
2969 QString text = QInputDialog::getText(
2970 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2971 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2973 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2978 bool Main::settingsURL()
2980 // Default browser is set in constructor
2982 QString text = QInputDialog::getText(
2983 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2984 settings.readEntry("/vym/mainwindow/readerURL")
2987 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2991 void Main::settingsToggleDelKey()
2993 if (actionSettingsUseDelKey->isOn())
2995 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
2998 actionEditDelete->setAccel (QKeySequence (""));
3002 void Main::windowToggleNoteEditor()
3004 if (textEditor->showWithMain() )
3005 windowHideNoteEditor();
3007 windowShowNoteEditor();
3010 void Main::windowToggleHistory()
3012 if (currentMapEditor())
3013 currentMapEditor()->toggleHistoryWindow();
3016 void Main::updateNoteFlag()
3018 if (currentMapEditor())
3019 currentMapEditor()->updateNoteFlag();
3022 void Main::windowShowNoteEditor()
3024 textEditor->setShowWithMain(true);
3026 actionViewToggleNoteEditor->setOn (true);
3029 void Main::windowHideNoteEditor()
3031 textEditor->setShowWithMain(false);
3033 actionViewToggleNoteEditor->setOn (false);
3036 void Main::windowNextEditor()
3038 if (tabWidget->currentPageIndex() < tabWidget->count())
3039 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3042 void Main::windowPreviousEditor()
3044 if (tabWidget->currentPageIndex() >0)
3045 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3048 void Main::standardFlagChanged()
3050 currentMapEditor()->toggleStandardFlag(sender()->name());
3053 void Main::testFunction()
3055 currentMapEditor()->testFunction();
3058 void Main::helpDoc()
3061 #if defined(Q_OS_MACX)
3062 docpath="./vym.app/Contents/vym.pdf";
3064 // default path in SUSE LINUX
3065 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3068 if (!QFile (docpath).exists() )
3070 // relative path for easy testing in tarball
3071 docpath="doc/vym.pdf";
3072 if (!QFile (docpath).exists() )
3074 // relative path for testing while still writing vym.tex
3075 docpath="doc/tex/vym.pdf";
3076 if (!QFile (docpath).exists() )
3078 // Try yet another one for Knoppix
3079 docpath="/usr/share/doc/packages/vym/vym.pdf";
3080 if (!QFile (docpath).exists() )
3082 QMessageBox::critical(0,
3083 tr("Critcal error"),
3084 tr("Couldn't find the documentation\n"
3085 "vym.pdf in various places."));
3092 Process *pdfProc = new Process();
3093 pdfProc->clearArguments();
3094 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
3095 pdfProc->addArgument( docpath);
3097 if ( !pdfProc->start() )
3100 QMessageBox::warning(0,
3102 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3103 tr("Please use Settings->")+tr("Set application to open PDF files"));
3110 void Main::helpAbout()
3113 ad.setName ("aboutwindow");
3114 ad.setMinimumSize(500,500);
3115 ad.resize (QSize (500,500));
3119 void Main::helpAboutQT()
3121 QMessageBox::aboutQt( this, "Qt Application Example" );