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:
505 a = new QAction(tr( "Edit heading" ),this);
506 a->setStatusTip ( tr( "edit Heading" ));
507 a->setShortcut ( Qt::Key_Enter);
508 a->setShortcutContext (Qt::ApplicationShortcut);
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 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
516 actionListBranches.append(a);
517 editMenu->addAction (a);
518 a->setShortcutContext (Qt::ApplicationShortcut);
521 a = new QAction( tr( "Edit heading" ), this);
522 a->setStatusTip (tr( "edit Heading" ));
523 a->setShortcut ( Qt::Key_F2 );
524 a->setShortcutContext (Qt::ApplicationShortcut);
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 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
534 a->setEnabled (false);
537 // Shortcut to add branch
538 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
539 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
540 alt->setShortcut (Qt::Key_A);
541 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
542 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
543 a->setStatusTip ( tr( "Add a branch as child of selection" ));
544 a->setShortcut (Qt::Key_Insert);
545 // a->setEnabled (false);
546 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
547 actionListBranches.append(a);
548 #if defined (Q_OS_MACX)
549 // In OSX show different shortcut in menues, the keys work indepently always
550 actionEditAddBranch=alt;
552 actionEditAddBranch=a;
554 editMenu->addAction (actionEditAddBranch);
555 tb->addAction (actionEditAddBranch);
558 // Add branch by inserting it at selection
559 a = new QAction(tr( "Add branch (insert)" ), this);
560 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
561 a->setShortcut (Qt::ALT + Qt::Key_Insert );
562 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
563 a->setEnabled (false);
564 actionListBranches.append(a);
565 actionEditAddBranchHere=a;
566 a = new QAction(tr( "Add branch (insert)" ),this);
567 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
568 a->setShortcut ( Qt::ALT + Qt::Key_A );
569 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
570 actionListBranches.append(a);
573 a = new QAction(tr( "Add branch above" ), this);
574 a->setStatusTip ( tr( "Add a branch above selection" ));
575 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
576 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
577 a->setEnabled (false);
578 actionListBranches.append(a);
579 actionEditAddBranchAbove=a;
580 a = new QAction(tr( "Add branch above" ), this);
581 a->setStatusTip ( tr( "Add a branch above selection" ));
582 a->setShortcut (Qt::SHIFT+Qt::Key_A );
583 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
584 actionListBranches.append(a);
587 a = new QAction(tr( "Add branch below" ), this);
588 a->setStatusTip ( tr( "Add a branch below selection" ));
589 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
590 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
591 a->setEnabled (false);
592 actionListBranches.append(a);
593 actionEditAddBranchBelow=a;
594 a = new QAction(tr( "Add branch below" ), this);
595 a->setStatusTip ( tr( "Add a branch below selection" ));
596 a->setShortcut (Qt::CTRL +Qt::Key_A );
597 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
598 actionListBranches.append(a);
600 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
601 a->setStatusTip ( tr( "Move branch up" ) );
602 a->setShortcut (Qt::Key_PageUp );
603 a->setEnabled (false);
605 editMenu->addAction (a);
606 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
609 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
610 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
611 a->setStatusTip (tr( "Move branch down" ) );
612 a->setShortcut ( Qt::Key_PageDown );
613 a->setEnabled (false);
615 editMenu->addAction (a);
616 actionEditMoveDown=a;
619 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
620 a->setShortcut ( Qt::Key_ScrollLock );
621 a->setStatusTip (tr( "Scroll branch" ) );
622 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
623 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
624 alt->setShortcut ( Qt::Key_S );
625 alt->setStatusTip (tr( "Scroll branch" ));
626 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
627 #if defined(Q_OS_MACX)
628 actionEditToggleScroll=alt;
630 actionEditToggleScroll=a;
632 actionEditToggleScroll->setEnabled (false);
633 actionEditToggleScroll->setToggleAction(true);
634 tb->addAction (actionEditToggleScroll);
635 editMenu->addAction ( actionEditToggleScroll);
636 editMenu->addAction (actionEditToggleScroll);
637 actionListBranches.append(actionEditToggleScroll);
639 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
640 a->setStatusTip (tr( "Unscroll all" ));
641 editMenu->addAction (a);
642 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
644 editMenu->addSeparator();
646 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
647 a->setStatusTip (tr( "Find" ) );
648 a->setShortcut (Qt::CTRL + Qt::Key_F );
649 editMenu->addAction (a);
650 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
652 editMenu->addSeparator();
654 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
655 a->setShortcut (Qt::CTRL + Qt::Key_U );
656 a->setShortcut (tr( "Open URL" ));
658 a->setEnabled (false);
659 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
662 a = new QAction( tr( "Open URL in new tab" ), this);
663 a->setStatusTip (tr( "Open URL in new tab" ));
664 a->setShortcut (Qt::CTRL+Qt::Key_U );
665 a->setEnabled (false);
666 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
667 actionEditOpenURLTab=a;
669 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
670 a->setStatusTip ( tr( "Edit URL" ) );
671 a->setShortcut (Qt::SHIFT + Qt::CTRL+Qt::Key_U );
672 a->setEnabled (false);
673 actionListBranches.append(a);
674 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
677 a = new QAction( tr( "Use heading for URL" ), this);
678 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
679 a->setEnabled (false);
680 actionListBranches.append(a);
681 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
682 actionEditHeading2URL=a;
684 a = new QAction(tr( "Create URL to Bugzilla" ), this);
685 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
686 a->setEnabled (false);
687 actionListBranches.append(a);
688 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
689 actionEditBugzilla2URL=a;
691 a = new QAction(tr( "Create URL to FATE" ), this);
692 a->setStatusTip ( tr( "Create URL to FATE" ));
693 a->setEnabled (false);
694 actionListBranches.append(a);
695 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
696 actionEditFATE2URL=a;
698 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
699 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
701 a->setEnabled (false);
702 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
703 actionEditOpenVymLink=a;
705 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
706 a->setEnabled (false);
707 a->setStatusTip ( tr( "Edit link to another vym map" ));
708 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
709 actionListBranches.append(a);
712 a = new QAction(tr( "Delete vym link" ),this);
713 a->setStatusTip ( tr( "Delete link to another vym map" ));
714 a->setEnabled (false);
715 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
716 actionEditDeleteVymLink=a;
718 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
719 a->setStatusTip ( tr( "Hide object in exports" ) );
720 a->setShortcut (Qt::Key_H );
721 a->setToggleAction(true);
723 a->setEnabled (false);
724 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
725 actionEditToggleHideExport=a;
727 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
728 a->setStatusTip ( tr( "Edit Map Info" ));
729 a->setEnabled (true);
730 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
733 editMenu->addSeparator();
735 // Import at selection (adding to selection)
736 a = new QAction( tr( "Add map (insert)" ),this);
737 a->setStatusTip (tr( "Add map at selection" ));
738 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
739 a->setEnabled (false);
740 actionListBranches.append(a);
741 actionEditImportAdd=a;
743 // Import at selection (replacing selection)
744 a = new QAction( tr( "Add map (replace)" ), this);
745 a->setStatusTip (tr( "Replace selection with map" ));
746 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
747 a->setEnabled (false);
748 actionListBranches.append(a);
749 actionEditImportReplace=a;
752 a = new QAction( tr( "Save selection" ), this);
753 a->setStatusTip (tr( "Save selection" ));
754 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
755 a->setEnabled (false);
756 actionListBranches.append(a);
757 actionEditSaveBranch=a;
759 // Only remove branch, not its childs
760 a = new QAction(tr( "Remove only branch " ), this);
761 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
762 a->setShortcut (Qt::ALT + Qt::Key_Delete );
763 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
764 a->setEnabled (false);
765 actionListBranches.append(a);
766 actionEditRemoveBranchKeepChilds=a;
768 // Only remove childs of a branch
769 a = new QAction( tr( "Remove childs" ), this);
770 a->setStatusTip (tr( "Remove childs of branch" ));
771 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
772 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
773 a->setEnabled (false);
774 actionListBranches.append(a);
775 actionEditRemoveChilds=a;
777 // Shortcuts for navigating with cursor:
778 a = new QAction(tr( "Select upper branch" ), this);
779 a->setStatusTip ( tr( "Select upper branch" ));
780 a->setShortcut (Qt::Key_Up );
781 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
782 a = new QAction( tr( "Select lower branch" ),this);
783 a->setStatusTip (tr( "Select lower branch" ));
784 a->setShortcut ( Qt::Key_Down );
785 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
786 a = new QAction(tr( "Select left branch" ), this);
787 a->setStatusTip ( tr( "Select left branch" ));
788 a->setShortcut (Qt::Key_Left );
789 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
790 a = new QAction( tr( "Select child branch" ), this);
791 a->setStatusTip (tr( "Select right branch" ));
792 a->setShortcut (Qt::Key_Right);
793 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
794 a = new QAction( tr( "Select first branch" ), this);
795 a->setStatusTip (tr( "Select first branch" ));
796 a->setShortcut (Qt::Key_Home );
797 a->setEnabled (false);
798 editMenu->addAction (a);
799 actionListBranches.append(a);
800 actionEditSelectFirst=a;
801 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
802 a = new QAction( tr( "Select last branch" ),this);
803 a->setStatusTip (tr( "Select last branch" ));
804 a->setShortcut ( Qt::Key_End );
805 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
806 a->setEnabled (false);
807 editMenu->addAction (a);
808 actionListBranches.append(a);
809 actionEditSelectLast=a;
811 a = new QAction( tr( "Add Image" )+QString("..."), this);
812 a->setStatusTip (tr( "Add Image" ));
813 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
814 actionEditLoadImage=a;
819 void Main::setupFormatActions()
821 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
823 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
826 pix.fill (Qt::black);
827 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
828 a->setStatusTip ( tr( "Set Color" ));
829 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
831 formatMenu->addAction (a);
833 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
834 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
835 a->setShortcut (Qt::CTRL + Qt::Key_K );
836 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
837 a->setEnabled (false);
839 formatMenu->addAction (a);
840 actionListBranches.append(a);
841 actionFormatPickColor=a;
843 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
844 a->setStatusTip ( tr( "Color branch" ) );
845 a->setShortcut (Qt::CTRL + Qt::Key_I);
846 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
847 a->setEnabled (false);
849 formatMenu->addAction (a);
850 actionListBranches.append(a);
851 actionFormatColorBranch=a;
853 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
854 a->setStatusTip ( tr( "Color Subtree" ));
855 a->setShortcut (Qt::CTRL + Qt::Key_T);
856 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
857 a->setEnabled (false);
858 formatMenu->addAction (a);
860 actionListBranches.append(a);
861 actionFormatColorSubtree=a;
863 formatMenu->addSeparator();
864 actionGroupFormatLinkStyles=new QActionGroup ( this);
865 actionGroupFormatLinkStyles->setExclusive (true);
866 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
867 a->setStatusTip (tr( "Line" ));
868 a->setToggleAction(true);
869 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
870 formatMenu->addAction (a);
871 actionFormatLinkStyleLine=a;
872 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
873 a->setStatusTip (tr( "Line" ));
874 a->setToggleAction(true);
875 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
876 formatMenu->addAction (a);
877 actionFormatLinkStyleParabel=a;
878 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
879 a->setStatusTip (tr( "PolyLine" ));
880 a->setToggleAction(true);
881 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
882 formatMenu->addAction (a);
883 actionFormatLinkStylePolyLine=a;
884 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
885 a->setStatusTip (tr( "PolyParabel" ) );
886 a->setToggleAction(true);
887 a->setChecked (true);
888 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
889 formatMenu->addAction (a);
890 actionFormatLinkStylePolyParabel=a;
892 actionGroupFormatFrameTypes=new QActionGroup ( this);
893 actionGroupFormatFrameTypes->setExclusive (true);
894 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
895 a->setStatusTip (tr("No Frame"));
896 a->setToggleAction(true);
897 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
898 actionFormatFrameNone=a;
899 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
900 a->setStatusTip (tr( "Rectangle" ));
901 a->setToggleAction(true);
902 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
903 actionFormatFrameRectangle=a;
905 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
906 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
907 a->setToggleAction(true);
908 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
909 actionFormatIncludeImagesVer=a;
911 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
912 a->setStatusTip ( tr ("Include left and right position of images into branch"));
913 a->setToggleAction(true);
914 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
915 actionFormatIncludeImagesHor=a;
917 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
918 a->setStatusTip (tr( "Hide link" ));
919 a->setToggleAction(true);
920 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
921 actionFormatHideLinkUnselected=a;
923 formatMenu->addSeparator();
924 a= new QAction( tr( "&Use color of heading for link" ), this);
925 a->setStatusTip (tr( "Use same color for links and headings" ));
926 a->setToggleAction(true);
927 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
928 formatMenu->addAction (a);
929 actionFormatLinkColorHint=a;
931 pix.fill (Qt::white);
932 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
933 a->setStatusTip (tr( "Set Link Color" ));
934 formatMenu->addAction (a);
935 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
936 actionFormatLinkColor=a;
938 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
939 a->setStatusTip (tr( "Set Background Color" ));
940 formatMenu->addAction (a);
941 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
942 actionFormatBackColor=a;
946 void Main::setupViewActions()
948 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
949 tb->setLabel( "View Actions" );
950 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
953 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
954 a->setStatusTip ( tr( "Zoom reset" ) );
955 a->setShortcut (Qt::CTRL + Qt::Key_0 );
957 viewMenu->addAction (a);
958 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
960 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
961 a->setStatusTip (tr( "Zoom in" ));
962 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
964 viewMenu->addAction (a);
965 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
967 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
968 a->setStatusTip (tr( "Zoom out" ));
969 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
971 viewMenu->addAction (a);
972 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
975 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
976 a->setStatusTip ( tr( "Show Note Editor" ));
977 a->setShortcut ( Qt::CTRL + Qt::Key_E );
978 a->setToggleAction(true);
979 if (textEditor->showWithMain())
984 viewMenu->addAction (a);
985 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
986 actionViewToggleNoteEditor=a;
988 a = new QAction( tr( "Show history window" ),this );
989 a->setStatusTip ( tr( "Show history window" ));
990 a->setShortcut ( Qt::CTRL + Qt::Key_H );
991 a->setToggleAction(false);
992 viewMenu->addAction (a);
993 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
994 actionViewToggleHistoryWindow=a;
996 a = new QAction(tr( "Next Window" ), this);
997 a->setStatusTip ( tr( "&Next Window" ) );
998 a->setShortcut (Qt::ALT + Qt::Key_N );
999 viewMenu->addAction (a);
1000 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
1002 a = new QAction (tr( "Previous Window" ), this );
1003 a->setStatusTip (tr( "&Previous Window" ));
1004 a->setShortcut (Qt::ALT + Qt::Key_P );
1005 viewMenu->addAction (a);
1006 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
1010 void Main::setupModeActions()
1012 //QPopupMenu *menu = new QPopupMenu( this );
1013 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1015 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1017 actionGroupModModes=new QActionGroup ( this);
1018 actionGroupModModes->setExclusive (true);
1019 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1020 a->setShortcut (Qt::Key_J);
1021 a->setStatusTip ( tr( "Use modifier to color branches" ));
1022 a->setToggleAction(true);
1025 actionModModeColor=a;
1027 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1028 a->setShortcut( Qt::Key_K);
1029 a->setStatusTip( tr( "Use modifier to copy" ));
1030 a->setToggleAction(true);
1032 actionModModeCopy=a;
1034 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1035 a->setShortcut (Qt::Key_L);
1036 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1037 a->setToggleAction(true);
1039 actionModModeLink=a;
1043 void Main::setupFlagActions()
1045 // Create System Flags
1046 systemFlagsDefault = new FlagRowObj ();
1047 systemFlagsDefault->setVisibility (false);
1048 systemFlagsDefault->setName ("systemFlagsDef");
1050 FlagObj *fo = new FlagObj ();
1051 fo->load(QPixmap(flagsPath+"flag-note.png"));
1052 fo->setName("note");
1053 fo->setToolTip(tr("Note","Systemflag"));
1054 systemFlagsDefault->addFlag (fo); // makes deep copy
1056 fo->load(QPixmap(flagsPath+"flag-url.png"));
1058 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1059 systemFlagsDefault->addFlag (fo);
1061 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1062 fo->setName("vymLink");
1063 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1064 systemFlagsDefault->addFlag (fo);
1066 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1067 fo->setName("scrolledright");
1068 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1069 systemFlagsDefault->addFlag (fo);
1071 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1072 fo->setName("tmpUnscrolledright");
1073 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1074 systemFlagsDefault->addFlag (fo);
1076 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1077 fo->setName("hideInExport");
1078 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1079 systemFlagsDefault->addFlag (fo);
1081 // Create Standard Flags
1082 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1084 standardFlagsDefault = new FlagRowObj ();
1085 standardFlagsDefault->setVisibility (false);
1086 standardFlagsDefault->setName ("standardFlagsDef");
1087 standardFlagsDefault->setToolBar (tb);
1089 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1090 fo->setName ("exclamationmark");
1091 fo->setGroup("standard-mark");
1092 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1095 a->setCheckable(true);
1096 a->setObjectName(fo->getName());
1097 a->setToolTip(tr("Take care!","Standardflag"));
1098 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1099 standardFlagsDefault->addFlag (fo); // makes deep copy
1101 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1102 fo->setName("questionmark");
1103 fo->setGroup("standard-mark");
1104 a=new QAction (fo->getPixmap(),fo->getName(),this);
1107 a->setCheckable(true);
1108 a->setObjectName(fo->getName());
1109 a->setToolTip(tr("Really?","Standardflag"));
1110 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1111 standardFlagsDefault->addFlag (fo);
1113 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1114 fo->setName("hook-green");
1115 fo->setGroup("standard-hook");
1116 a=new QAction (fo->getPixmap(),fo->getName(),this);
1119 a->setCheckable(true);
1120 a->setObjectName(fo->getName());
1121 a->setToolTip(tr("ok!","Standardflag"));
1122 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1123 standardFlagsDefault->addFlag (fo);
1125 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1126 fo->setName("cross-red");
1127 fo->setGroup("standard-hook");
1128 a=new QAction (fo->getPixmap(),fo->getName(),this);
1131 a->setCheckable(true);
1132 a->setObjectName(fo->getName());
1133 a->setToolTip(tr("Not ok!","Standardflag"));
1134 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1135 standardFlagsDefault->addFlag (fo);
1137 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1138 fo->setName("stopsign");
1139 a=new QAction (fo->getPixmap(),fo->getName(),this);
1142 a->setCheckable(true);
1143 a->setObjectName(fo->getName());
1144 a->setToolTip(tr("This won't work!","Standardflag"));
1145 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1146 standardFlagsDefault->addFlag (fo);
1148 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1149 fo->setName("smiley-good");
1150 fo->setGroup("standard-smiley");
1151 a=new QAction (fo->getPixmap(),fo->getName(),this);
1154 a->setCheckable(true);
1155 a->setObjectName(fo->getName());
1156 a->setToolTip(tr("Good","Standardflag"));
1157 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1158 standardFlagsDefault->addFlag (fo);
1160 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1161 fo->setName("smiley-sad");
1162 fo->setGroup("standard-smiley");
1163 a=new QAction (fo->getPixmap(),fo->getName(),this);
1166 a->setCheckable(true);
1167 a->setObjectName(fo->getName());
1168 a->setToolTip(tr("Bad","Standardflag"));
1169 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1170 standardFlagsDefault->addFlag (fo);
1172 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1173 // Original omg.png (in KDE emoticons)
1174 fo->setName("smiley-omg");
1175 fo->setGroup("standard-smiley");
1176 a=new QAction (fo->getPixmap(),fo->getName(),this);
1179 a->setCheckable(true);
1180 a->setObjectName(fo->getName());
1181 a->setToolTip(tr("Oh no!","Standardflag"));
1182 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1183 standardFlagsDefault->addFlag (fo);
1185 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1186 fo->setName("clock");
1187 a=new QAction (fo->getPixmap(),fo->getName(),this);
1190 a->setCheckable(true);
1191 a->setObjectName(fo->getName());
1192 a->setToolTip(tr("Time critical","Standardflag"));
1193 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1194 standardFlagsDefault->addFlag (fo);
1196 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1197 fo->setName("phone");
1198 a=new QAction (fo->getPixmap(),fo->getName(),this);
1201 a->setCheckable(true);
1202 a->setObjectName(fo->getName());
1203 a->setToolTip(tr("Call...","Standardflag"));
1204 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1205 standardFlagsDefault->addFlag (fo);
1207 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1208 fo->setName("lamp");
1209 a=new QAction (fo->getPixmap(),fo->getName(),this);
1212 a->setCheckable(true);
1213 a->setObjectName(fo->getName());
1214 a->setToolTip(tr("Idea!","Standardflag"));
1215 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1216 standardFlagsDefault->addFlag (fo);
1218 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1219 fo->setName("arrow-up");
1220 fo->setGroup("standard-arrow");
1221 a=new QAction (fo->getPixmap(),fo->getName(),this);
1224 a->setCheckable(true);
1225 a->setObjectName(fo->getName());
1226 a->setToolTip(tr("Important","Standardflag"));
1227 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1228 standardFlagsDefault->addFlag (fo);
1230 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1231 fo->setName("arrow-down");
1232 fo->setGroup("standard-arrow");
1233 a=new QAction (fo->getPixmap(),fo->getName(),this);
1236 a->setCheckable(true);
1237 a->setObjectName(fo->getName());
1238 a->setToolTip(tr("Unimportant","Standardflag"));
1239 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1240 standardFlagsDefault->addFlag (fo);
1242 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1243 fo->setName("2arrow-up");
1244 fo->setGroup("standard-arrow");
1245 a=new QAction (fo->getPixmap(),fo->getName(),this);
1248 a->setCheckable(true);
1249 a->setObjectName(fo->getName());
1250 a->setToolTip(tr("Very important!","Standardflag"));
1251 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1252 standardFlagsDefault->addFlag (fo);
1254 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1255 fo->setName("2arrow-down");
1256 fo->setGroup("standard-arrow");
1257 a=new QAction (fo->getPixmap(),fo->getName(),this);
1260 a->setCheckable(true);
1261 a->setObjectName(fo->getName());
1262 a->setToolTip(tr("Very unimportant!","Standardflag"));
1263 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1264 standardFlagsDefault->addFlag (fo);
1266 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1267 fo->setName("thumb-up");
1268 fo->setGroup("standard-thumb");
1269 a=new QAction (fo->getPixmap(),fo->getName(),this);
1272 a->setCheckable(true);
1273 a->setObjectName(fo->getName());
1274 a->setToolTip(tr("I like this","Standardflag"));
1275 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1276 standardFlagsDefault->addFlag (fo);
1278 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1279 fo->setName("thumb-down");
1280 fo->setGroup("standard-thumb");
1281 a=new QAction (fo->getPixmap(),fo->getName(),this);
1284 a->setCheckable(true);
1285 a->setObjectName(fo->getName());
1286 a->setToolTip(tr("I do not like this","Standardflag"));
1287 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1288 standardFlagsDefault->addFlag (fo);
1290 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1291 fo->setName("rose");
1292 a=new QAction (fo->getPixmap(),fo->getName(),this);
1295 a->setCheckable(true);
1296 a->setObjectName(fo->getName());
1297 a->setToolTip(tr("Rose","Standardflag"));
1298 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1299 standardFlagsDefault->addFlag (fo);
1301 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1302 fo->setName("heart");
1303 a=new QAction (fo->getPixmap(),fo->getName(),this);
1305 a->setCheckable(true);
1306 a->setObjectName(fo->getName());
1307 a->setToolTip(tr("I just love... ","Standardflag"));
1308 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1309 standardFlagsDefault->addFlag (fo);
1311 fo->load(QPixmap(flagsPath+"flag-present.png"));
1312 fo->setName("present");
1313 a=new QAction (fo->getPixmap(),fo->getName(),this);
1316 a->setCheckable(true);
1317 a->setObjectName(fo->getName());
1318 a->setToolTip(tr("Surprise!","Standardflag"));
1319 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1320 standardFlagsDefault->addFlag (fo);
1322 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1323 fo->setName("flash");
1324 a=new QAction (fo->getPixmap(),fo->getName(),this);
1327 a->setCheckable(true);
1328 a->setObjectName(fo->getName());
1329 a->setToolTip(tr("Dangerous","Standardflag"));
1330 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1331 standardFlagsDefault->addFlag (fo);
1333 fo->load(QPixmap(flagsPath+"flag-info.png"));
1334 // Original: xsldbg_output.png
1335 fo->setName("info");
1336 a=new QAction (fo->getPixmap(),fo->getName(),this);
1339 a->setCheckable(true);
1340 a->setObjectName(fo->getName());
1341 a->setToolTip(tr("Info","Standardflag"));
1342 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1343 standardFlagsDefault->addFlag (fo);
1345 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1346 // Original khelpcenter.png
1347 fo->setName("lifebelt");
1348 a=new QAction (fo->getPixmap(),fo->getName(),this);
1351 a->setCheckable(true);
1352 a->setObjectName(fo->getName());
1353 a->setToolTip(tr("This will help","Standardflag"));
1354 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1355 standardFlagsDefault->addFlag (fo);
1361 void Main::setupSettingsActions()
1363 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1367 a = new QAction( tr( "Set application to open pdf files"), this);
1368 a->setStatusTip ( tr( "Set application to open pdf files"));
1369 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1370 settingsMenu->addAction (a);
1372 a = new QAction( tr( "Set application to open external links"), this);
1373 a->setStatusTip( tr( "Set application to open external links"));
1374 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1375 settingsMenu->addAction (a);
1377 settingsMenu->addSeparator();
1378 a = new QAction( tr( "Edit branch after adding it" ), this );
1379 a->setStatusTip( tr( "Edit branch after adding it" ));
1380 a->setToggleAction(true);
1381 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1382 settingsMenu->addAction (a);
1383 actionSettingsAutoedit=a;
1385 a= new QAction( tr( "Select branch after adding it" ), this );
1386 a->setStatusTip( tr( "Select branch after adding it" ));
1387 a->setToggleAction(true);
1388 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1389 settingsMenu->addAction (a);
1390 actionSettingsAutoselectHeading=a;
1392 a= new QAction(tr( "Select existing heading" ), this);
1393 a->setStatusTip( tr( "Select heading before editing" ));
1394 a->setToggleAction(true);
1395 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1396 settingsMenu->addAction (a);
1397 actionSettingsAutoselectText=a;
1399 a= new QAction(tr( "pasting into new branch" ), this );
1400 a->setStatusTip( tr( "Pasting into new branch" ));
1401 a->setToggleAction(true);
1402 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1403 settingsMenu->addAction (a);
1404 actionSettingsPasteNewHeading=a;
1406 a= new QAction( tr( "Delete key" ), this);
1407 a->setStatusTip( tr( "Delete key for deleting branches" ));
1408 a->setToggleAction(true);
1409 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1410 settingsMenu->addAction (a);
1411 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1412 actionSettingsUseDelKey=a;
1414 a= new QAction( tr( "Exclusive flags" ), this);
1415 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1416 a->setToggleAction(true);
1417 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1418 settingsMenu->addAction (a);
1419 actionSettingsUseFlagGroups=a;
1421 a= new QAction( tr( "Use hide flags" ), this);
1422 a->setStatusTip( tr( "Use hide flag during exports " ));
1423 a->setToggleAction(true);
1424 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1425 settingsMenu->addAction (a);
1426 actionSettingsUseHideExport=a;
1430 void Main::setupTestActions()
1432 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1435 a = new QAction( tr( "test flag" ), this);
1436 a->setStatusTip( tr( "Call test function" ));
1437 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1438 testMenu->addAction (a);
1442 void Main::setupHelpActions()
1444 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1447 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1448 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1449 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1450 helpMenu->addAction (a);
1452 a = new QAction( tr( "About VYM" ), this);
1453 a->setStatusTip( tr( "About VYM")+" "__VYM);
1454 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1455 helpMenu->addAction (a);
1457 a = new QAction( tr( "About QT" ), this);
1458 a->setStatusTip( tr( "Information about QT toolkit" ));
1459 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1460 helpMenu->addAction (a);
1464 void Main::setupContextMenus()
1468 // Context Menu for branch or mapcenter
1469 branchContextMenu =new QMenu (this);
1472 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1473 branchAddContextMenu->addAction (actionEditPaste );
1474 branchAddContextMenu->addAction ( actionEditAddBranch );
1475 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1476 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1477 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1478 branchAddContextMenu->addSeparator();
1479 branchAddContextMenu->addAction ( actionEditLoadImage);
1480 branchAddContextMenu->addSeparator();
1481 branchAddContextMenu->addAction ( actionEditLoadImage);
1482 branchAddContextMenu->addAction ( actionEditImportAdd );
1483 branchAddContextMenu->addAction ( actionEditImportReplace );
1486 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1487 branchRemoveContextMenu->addAction (actionEditCut);
1488 branchRemoveContextMenu->addAction ( actionEditDelete );
1489 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1490 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1493 actionEditSaveBranch->addTo( branchContextMenu );
1495 branchContextMenu->addSeparator();
1496 branchContextMenu->addAction ( actionEditOpenURL );
1497 branchContextMenu->addAction ( actionEditOpenURLTab );
1498 branchContextMenu->addAction ( actionEditURL );
1499 branchContextMenu->addAction ( actionEditHeading2URL );
1500 branchContextMenu->addAction ( actionEditBugzilla2URL );
1501 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1503 branchContextMenu->addAction ( actionEditFATE2URL );
1505 branchContextMenu->addSeparator();
1506 branchContextMenu->addAction ( actionEditOpenVymLink );
1507 branchContextMenu->addAction ( actionEditVymLink );
1508 branchContextMenu->addAction ( actionEditDeleteVymLink );
1510 branchContextMenu->addSeparator();
1511 branchContextMenu->addAction ( actionFormatFrameNone );
1512 branchContextMenu->addAction ( actionFormatFrameRectangle);
1514 branchContextMenu->addSeparator();
1515 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1516 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1517 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1519 // Context Menu for links in a branch menu
1520 // This will be populated "on demand" in MapEditor::updateActions
1521 branchContextMenu->addSeparator();
1522 /* FIXME not yet ported from QT3
1523 branchLinksContextMenu =new Q3PopupMenu (this);
1524 branchLinksContextMenuDup =new Q3PopupMenu (this);
1525 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1526 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1528 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1529 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1532 // Context menu for floatimage
1533 floatimageContextMenu =new QMenu (this);
1534 saveImageFormatMenu=floatimageContextMenu->addMenu (tr("Save image"));
1536 foreach (QByteArray format, QImageWriter::supportedImageFormats())
1538 QString text = tr("%1...").arg(QString(format).toUpper());
1539 a= new QAction (text,this);
1540 saveImageFormatMenu->addAction ( a );
1543 /* FIXME not needed any longer
1544 Q3StrList fmt = QImageWriter::supportedImageFormats();
1545 for (const char* f = fmt.first(); f; f = fmt.next())
1547 saveImageFormatMenu->insertItem( f );
1548 exportImageFormatMenu->insertItem( f );
1551 // connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1552 // connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1554 floatimageContextMenu->addSeparator();
1555 actionEditCopy->addTo( floatimageContextMenu );
1556 actionEditCut->addTo( floatimageContextMenu );
1558 floatimageContextMenu->addSeparator();
1559 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1562 // Context menu for canvas
1563 canvasContextMenu =new QMenu (this);
1564 actionEditMapInfo->addTo( canvasContextMenu );
1565 canvasContextMenu->insertSeparator();
1566 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1567 canvasContextMenu->insertSeparator();
1568 actionFormatLinkColorHint->addTo( canvasContextMenu );
1569 actionFormatLinkColor->addTo( canvasContextMenu );
1570 actionFormatBackColor->addTo( canvasContextMenu );
1572 // Menu for last opened files
1573 // Read settings initially
1575 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1576 for (int i=1;i<=j;i++)
1578 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1579 if (!s.isEmpty() && j<=maxLastMaps)
1582 setupLastMapsMenu();
1583 // connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1586 void Main::setupLastMapsMenu()
1588 // Remove double entries
1589 QStringList::Iterator it=lastMaps.begin();
1590 QStringList::Iterator jt;
1591 while (it!=lastMaps.end() )
1595 while (jt!=lastMaps.end() )
1598 jt=lastMaps.remove(jt);
1605 // Limit length of list to maxLastMaps
1606 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1608 // build Menu from lastMaps string list
1609 fileLastMapsMenu->clear();
1610 /* FIXME add actions instead of strings in QT4
1611 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1612 fileLastMapsMenu->addAction (*it );
1617 void Main::hideEvent (QHideEvent * )
1619 if (!textEditor->isMinimized() ) textEditor->hide();
1622 void Main::showEvent (QShowEvent * )
1624 if (textEditor->showWithMain()) textEditor->showNormal();
1627 bool Main::reallyWriteDirectory(const QString &dir)
1629 QStringList eList = QDir(dir).entryList();
1630 if (eList.first() ==".") eList.pop_front(); // remove "."
1631 if (eList.first() =="..") eList.pop_front(); // remove "."
1632 if (!eList.isEmpty())
1634 QMessageBox mb( __VYM,
1635 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1636 QMessageBox::Warning,
1638 QMessageBox::Cancel | QMessageBox::Default,
1639 QMessageBox::QMessageBox::NoButton );
1641 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1642 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1645 case QMessageBox::Yes:
1648 case QMessageBox::Cancel:
1656 QString Main::browseDirectory (const QString &caption)
1658 Q3FileDialog fd(this,caption);
1659 fd.setMode (Q3FileDialog::DirectoryOnly);
1660 fd.setCaption(__VYM " - "+caption);
1663 if ( fd.exec() == QDialog::Accepted )
1664 return fd.selectedFile();
1669 MapEditor* Main::currentMapEditor() const
1671 if ( tabWidget->currentPage() &&
1672 tabWidget->currentPage()->inherits( "MapEditor" ) )
1673 return (MapEditor*)tabWidget->currentPage();
1677 //TODO not used now, maybe use this for overview window later
1678 void Main::newView()
1680 // Open a new view... have it delete when closed.
1681 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1682 qApp->setMainWidget(m);
1684 qApp->setMainWidget(0);
1687 void Main::editorChanged(QWidget *)
1689 // Unselect all possibly selected objects
1690 // (Important to update note editor)
1693 for (i=0;i<=tabWidget->count() -1;i++)
1696 me=(MapEditor*)tabWidget->page(i);
1699 currentMapEditor()->reselect();
1701 // Update actions to in menus and toolbars according to editor
1702 currentMapEditor()->updateActions();
1705 void Main::fileNew()
1707 QString fn="unnamed";
1708 MapEditor* medit = new MapEditor ( NULL,true);
1709 tabWidget->addTab (medit,fn);
1710 tabWidget->showPage(medit);
1711 medit->viewport()->setFocus();
1712 // For the very first map we do not have flagrows yet...
1713 medit->select("mc:");
1716 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1718 ErrorCode err=success;
1720 // fn is usually the archive, mapfile the file after uncompressing
1723 // Make fn absolute (needed for unzip)
1724 fn=QDir (fn).absPath();
1730 // Check, if map is already loaded
1732 while (i<=tabWidget->count() -1)
1734 me=(MapEditor*)tabWidget->page(i);
1735 if (me->getFilePath() == fn)
1737 // Already there, ask for confirmation
1738 QMessageBox mb( __VYM,
1739 tr("The map %1\nis already opened."
1740 "Opening the same map in multiple editors may lead \n"
1741 "to confusion when finishing working with vym."
1742 "Do you want to").arg(fn),
1743 QMessageBox::Warning,
1744 QMessageBox::Yes | QMessageBox::Default,
1745 QMessageBox::Cancel | QMessageBox::Escape,
1746 QMessageBox::NoButton);
1747 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1748 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1751 case QMessageBox::Yes:
1753 i=tabWidget->count();
1755 case QMessageBox::Cancel:
1767 if ( !fn.isEmpty() )
1769 me = currentMapEditor();
1770 int tabIndex=tabWidget->currentPageIndex();
1771 // Check first, if mapeditor exists
1772 // If it is not default AND we want a new map,
1773 // create a new mapeditor in a new tab
1774 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1776 me= new MapEditor ( NULL,true);
1777 tabWidget->addTab (me,fn);
1778 tabIndex=tabWidget->indexOf (me);
1779 tabWidget->setCurrentPage (tabIndex);
1782 // Check, if file exists (important for creating new files
1783 // from command line
1784 if (!QFile(fn).exists() )
1786 QMessageBox mb( __VYM,
1787 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1788 QMessageBox::Question,
1790 QMessageBox::Cancel | QMessageBox::Default,
1791 QMessageBox::NoButton );
1793 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1794 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1797 case QMessageBox::Yes:
1799 currentMapEditor()->setFilePath(fn);
1800 tabWidget->setTabLabel (currentMapEditor(),
1801 currentMapEditor()->getFileName() );
1802 statusBar()->message( "Created " + fn , statusbarTime );
1805 case QMessageBox::Cancel:
1806 // don't create new map
1807 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1814 //tabWidget->currentPage() won't be NULL here, because of above...
1815 tabWidget->showPage(me);
1816 me->viewport()->setFocus();
1818 // Create temporary directory for packing
1819 char tmpdir1[]="/tmp/vym-XXXXXX";
1820 QString tmpMapDir=mkdtemp(tmpdir1);
1822 // Try to unzip file
1823 err=unzipDir (tmpMapDir,fn);
1827 me->setZipped(false);
1830 me->setZipped(true);
1832 // Look for mapname.xml
1833 mapfile= fn.left(fn.findRev(".",-1,true));
1834 mapfile=mapfile.section( '/', -1 );
1835 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1836 if (!file.exists() )
1838 // mapname.xml does not exist, well,
1839 // maybe some renamed the mapname.vym file...
1840 // Try to find any .xml in the toplevel
1841 // directory of the .vym file
1842 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1843 if (flist.count()==1)
1845 // Only one entry, take this one
1846 mapfile=tmpMapDir + "/"+flist.first();
1849 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1850 *it=tmpMapDir + "/" + *it;
1851 // TODO Multiple entries, load all (but only the first one into this ME)
1852 //mainWindow->fileLoadFromTmp (flist);
1853 //returnCode=1; // Silently forget this attempt to load
1854 qWarning ("MainWindow::load (fn) multimap found...");
1857 if (flist.isEmpty() )
1859 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1860 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1863 } //file doesn't exist
1865 mapfile=file.name();
1870 // Save existing filename in case we import
1871 QString fn_org=me->getFilePath();
1873 // Finally load map into mapEditor
1874 me->setFilePath (mapfile,fn);
1875 err=me->load(mapfile,lmode);
1877 // Restore old (maybe empty) filepath, if this is an import
1879 me->setFilePath (fn_org);
1882 // Finally check for errors and go home
1885 if (lmode==NewMap) fileCloseMap();
1886 statusBar()->message( "Could not load " + fn, statusbarTime );
1891 me->setFilePath (fn);
1892 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1893 if (fn.left(9)!="/tmp/vym-")
1895 // Only append to lastMaps if not loaded from a tmpDir
1896 // e.g. imported bookmarks are in a tmpDir
1897 lastMaps.prepend(me->getFilePath() );
1898 setupLastMapsMenu();
1900 actionFilePrint->setEnabled (true);
1902 statusBar()->message( "Loaded " + fn, statusbarTime );
1906 removeDir (QDir(tmpMapDir));
1912 void Main::fileLoad(const LoadMode &lmode)
1914 Q3FileDialog *fd=new Q3FileDialog( this);
1915 if (!lastFileDir.isEmpty())
1916 fd->setDir (lastFileDir);
1917 fd->setMode (Q3FileDialog::ExistingFiles);
1918 fd->addFilter ("XML (*.xml)");
1919 fd->addFilter ("VYM map (*.vym *.vyp)");
1923 fd->setCaption(tr("Load vym map"));
1926 fd->setCaption(tr("Import: Add vym map to selection"));
1929 fd->setCaption(tr("Import: Replace selection with vym map"));
1935 if ( fd->exec() == QDialog::Accepted )
1937 lastFileDir=fd->dirPath();
1938 QStringList flist = fd->selectedFiles();
1939 QStringList::Iterator it = flist.begin();
1940 while( it != flist.end() )
1943 fileLoad(*it, lmode);
1950 void Main::fileLoad()
1955 void Main::fileLoadLast(int i)
1957 fileLoad(QString(*lastMaps.at(fileLastMapsMenu->indexOf (i)) ),NewMap);
1960 void Main::fileSave(const SaveMode &savemode)
1962 // tmp dir for zipping
1966 ErrorCode err=success;
1968 QString safeFilePath;
1970 bool saveZipped=currentMapEditor()->saveZipped();
1972 MapEditor * me=currentMapEditor();
1975 QString fn=me->getFilePath();
1976 // filename=unnamed, filepath="" in constructor...
1977 if ( !fn.isEmpty() )
1979 // We have a filepath, go on saving
1980 // First remove existing file, we
1981 // don't want to add to old zip archives
1985 QMessageBox::warning( 0, tr( "Save Error" ),
1986 fn+ tr("\ncould not be removed before saving"));
1988 // Look, if we should zip the data:
1991 QMessageBox mb( __VYM,
1992 tr("The map %1\ndid not use the compressed "
1993 "vym file format.\nWriting it uncompressed will also write images \n"
1994 "and flags and thus may overwrite files in the "
1995 "given directory\n\nDo you want to write the map").arg(fn),
1996 QMessageBox::Warning,
1997 QMessageBox::Yes | QMessageBox::Default,
1999 QMessageBox::Cancel | QMessageBox::Escape);
2000 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2001 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2002 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2005 case QMessageBox::Yes:
2006 // save compressed (default file format)
2009 case QMessageBox::No:
2010 // save uncompressed
2013 case QMessageBox::Cancel:
2022 char tmpdir1[]="/tmp/vym-XXXXXX";
2023 tmpMapDir=mkdtemp(tmpdir1);
2025 safeFilePath=me->getFilePath();
2026 me->setFilePath (tmpMapDir+"/"+
2027 me->getMapName()+ ".xml",
2029 me->save (savemode);
2030 me->setFilePath (safeFilePath);
2032 zipDir (tmpMapDir,fn);
2037 safeFilePath=me->getFilePath();
2038 me->setFilePath (fn, safeFilePath);
2039 me->save (savemode);
2040 me->setFilePath (safeFilePath);
2042 } // filepath available
2045 // We have no filepath yet,
2046 // call fileSaveAs() now, this will call fileSave()
2048 fileSaveAs(savemode);
2052 if (saveZipped && !tmpMapDir.isEmpty())
2054 removeDir (QDir(tmpMapDir));
2058 statusBar()->message(
2059 tr("Saved %1").arg(me->getFilePath()),
2061 lastMaps.prepend(me->getFilePath() );
2062 setupLastMapsMenu();
2064 statusBar()->message(
2065 tr("Couldn't save ").arg(me->getFilePath()),
2069 void Main::fileSave()
2071 fileSave (CompleteMap);
2074 void Main::fileSaveAs(const SaveMode& savemode)
2078 if (currentMapEditor())
2080 if (savemode==CompleteMap)
2081 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2083 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2084 if ( !fn.isEmpty() )
2086 // Check for existing file
2087 if (QFile (fn).exists())
2089 QMessageBox mb( __VYM,
2090 tr("The file %1\nexists already. Do you want to").arg(fn),
2091 QMessageBox::Warning,
2092 QMessageBox::Yes | QMessageBox::Default,
2093 QMessageBox::Cancel | QMessageBox::Escape,
2094 QMessageBox::NoButton);
2095 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2096 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2099 case QMessageBox::Yes:
2102 case QMessageBox::Cancel:
2109 // New file, add extension to filename, if missing
2110 // This is always .vym or .vyp, depending on savemode
2111 if (savemode==CompleteMap)
2113 if (!fn.contains (".vym") && !fn.contains (".xml"))
2117 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2126 currentMapEditor()->setFilePath(fn);
2130 if (savemode==CompleteMap)
2131 tabWidget->setTabLabel (currentMapEditor(),
2132 currentMapEditor()->getFileName() );
2138 void Main::fileSaveAs()
2140 fileSaveAs (CompleteMap);
2143 void Main::fileImportKDEBookmarks()
2145 ImportKDEBookmarks im;
2147 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2148 currentMapEditor()->setFilePath ("");
2151 void Main::fileImportFirefoxBookmarks()
2153 Q3FileDialog *fd=new Q3FileDialog( this);
2154 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2155 fd->setMode (Q3FileDialog::ExistingFiles);
2156 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2157 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2160 if ( fd->exec() == QDialog::Accepted )
2162 ImportFirefoxBookmarks im;
2163 QStringList flist = fd->selectedFiles();
2164 QStringList::Iterator it = flist.begin();
2165 while( it != flist.end() )
2168 if (im.transform() &&
2169 success==fileLoad (im.getTransformedFile(),NewMap) &&
2170 currentMapEditor() )
2171 currentMapEditor()->setFilePath ("");
2178 void Main::fileImportMM()
2182 Q3FileDialog *fd=new Q3FileDialog( this);
2183 if (!lastFileDir.isEmpty())
2184 fd->setDir (lastFileDir);
2185 fd->setMode (Q3FileDialog::ExistingFiles);
2186 fd->addFilter ("Mind Manager (*.mmap)");
2187 fd->setCaption(tr("Import")+" "+"Mind Manager");
2190 if ( fd->exec() == QDialog::Accepted )
2192 lastFileDir=fd->dirPath();
2193 QStringList flist = fd->selectedFiles();
2194 QStringList::Iterator it = flist.begin();
2195 while( it != flist.end() )
2198 if (im.transform() &&
2199 success==fileLoad (im.getTransformedFile(),NewMap) &&
2200 currentMapEditor() )
2201 currentMapEditor()->setFilePath ("");
2210 void Main::fileImportDir()
2212 if (currentMapEditor())
2213 currentMapEditor()->importDir();
2216 void Main::fileExportXML()
2218 if (currentMapEditor())
2220 QString dir=browseDirectory(tr("Export XML to directory"));
2221 if (dir !="" && reallyWriteDirectory(dir) )
2222 currentMapEditor()->exportXML(dir);
2227 void Main::fileExportXHTML()
2229 MapEditor *me=currentMapEditor();
2233 ExportXHTMLDialog dia(this);
2234 dia.setFilePath (me->getFilePath() );
2235 dia.setMapName (me->getMapName() );
2238 if (dia.exec()==QDialog::Accepted)
2240 QString dir=dia.getDir();
2241 // Check, if warnings should be used before overwriting
2242 // the output directory
2245 ok=reallyWriteDirectory(dir);
2251 me->exportXML (dia.getDir() );
2252 dia.doExport(me->getMapName() );
2253 if (dia.hasChanged())
2260 void Main::fileExportImage()
2262 MapEditor *me=currentMapEditor();
2266 QFileDialog *fd=new QFileDialog (this);
2267 fd->setCaption (tr("Export map as image"));
2268 fd->setFileMode(QFileDialog::AnyFile);
2269 fd->setFilters (imageIO.getFilters() );
2270 fd->setDirectory (lastImageDir);
2273 fl=fd->selectedFiles();
2274 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2275 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2280 void Main::fileExportASCII()
2282 MapEditor *me=currentMapEditor();
2286 ex.setMapCenter(me->getMapCenter());
2287 ex.addFilter ("TXT (*.txt)");
2288 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2289 if (ex.execDialog() )
2291 me->setExportMode(true);
2293 me->setExportMode(false);
2298 void Main::fileExportLaTeX()
2300 MapEditor *me=currentMapEditor();
2304 ex.setMapCenter(me->getMapCenter());
2305 ex.addFilter ("Tex (*.tex)");
2306 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2307 if (ex.execDialog() )
2309 me->setExportMode(true);
2311 me->setExportMode(false);
2316 void Main::fileExportKDEBookmarks()
2318 ExportKDEBookmarks ex;
2319 MapEditor *me=currentMapEditor();
2322 ex.setMapCenter (me->getMapCenter() );
2327 void Main::fileExportTaskjuggler()
2329 ExportTaskjuggler ex;
2330 MapEditor *me=currentMapEditor();
2333 ex.setMapCenter (me->getMapCenter() );
2334 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2335 ex.addFilter ("Taskjuggler (*.tjp)");
2336 if (ex.execDialog() )
2338 me->setExportMode(true);
2340 me->setExportMode(false);
2345 void Main::fileExportOOPresentation()
2347 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2348 // FIXME add extra info in dialog
2349 //ImagePreview *p =new ImagePreview (fd);
2350 //fd->setContentsPreviewEnabled( TRUE );
2351 //fd->setContentsPreview( p, p );
2352 //fd->setPreviewMode( QFileDialog::Contents );
2353 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2354 //fd->setDir (lastImageDir);
2357 if ( fd->exec() == QDialog::Accepted )
2359 QString fn=fd->selectedFile();
2360 //lastImageDir=fn.left(fn.findRev ("/"));
2361 if (currentMapEditor())
2362 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2366 void Main::fileCloseMap()
2368 if (currentMapEditor())
2370 if (currentMapEditor()->hasChanged())
2372 QMessageBox mb( __VYM,
2373 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2374 QMessageBox::Warning,
2375 QMessageBox::Yes | QMessageBox::Default,
2377 QMessageBox::Cancel | QMessageBox::Escape );
2378 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2379 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2382 case QMessageBox::Yes:
2384 fileSave(CompleteMap);
2386 case QMessageBox::No:
2387 // close without saving
2389 case QMessageBox::Cancel:
2394 currentMapEditor()->closeMap();
2395 tabWidget->removePage(currentMapEditor());
2396 if (tabWidget->count()==0)
2397 actionFilePrint->setEnabled (false);
2401 void Main::filePrint()
2403 if (currentMapEditor())
2404 currentMapEditor()->print();
2407 void Main::fileExitVYM()
2409 // Check if one or more editors have changed
2412 for (i=0;i<=tabWidget->count() -1;i++)
2415 me=(MapEditor*)tabWidget->page(i);
2417 // If something changed, ask what to do
2418 if (me->isUnsaved())
2420 tabWidget->setCurrentPage(i);
2421 QMessageBox mb( __VYM,
2422 tr("This map is not saved yet. Do you want to"),
2423 QMessageBox::Warning,
2424 QMessageBox::Yes | QMessageBox::Default,
2426 QMessageBox::Cancel | QMessageBox::Escape );
2427 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2428 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2430 mb.setActiveWindow();
2431 switch( mb.exec() ) {
2432 case QMessageBox::Yes:
2433 // save (the changed editors) and exit
2434 fileSave(CompleteMap);
2436 case QMessageBox::No:
2437 // exit without saving
2439 case QMessageBox::Cancel:
2440 // don't save and don't exit
2444 } // loop over all MEs
2448 void Main::editUndo()
2450 if (currentMapEditor())
2451 currentMapEditor()->undo();
2454 void Main::editRedo()
2456 if (currentMapEditor())
2457 currentMapEditor()->redo();
2460 void Main::editCopy()
2462 if (currentMapEditor())
2463 currentMapEditor()->copy();
2466 void Main::editPaste()
2468 if (currentMapEditor())
2469 currentMapEditor()->paste();
2472 void Main::editCut()
2474 if (currentMapEditor())
2475 currentMapEditor()->cut();
2478 void Main::editOpenFindWindow()
2480 findWindow->popup();
2481 findWindow->raise();
2482 findWindow->setActiveWindow();
2485 void Main::editFind(QString s)
2488 BranchObj *bo=currentMapEditor()->findText(s, cs);
2491 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2494 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2495 tr("No matches found for \"%1\"").arg(s));
2499 void Main::editFindChanged()
2500 { // Notify editor, to abort the current find process
2501 currentMapEditor()->findReset();
2504 void Main::editOpenURL()
2507 if (currentMapEditor())
2509 QString url=currentMapEditor()->getURL();
2510 if (url=="") return;
2511 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2512 procBrowser = new Q3Process( this );
2514 procBrowser->addArgument( browser);
2515 procBrowser->addArgument( url);
2517 if ( !procBrowser->start() )
2519 // try to set path to browser
2520 QMessageBox::warning(0,
2522 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2523 tr("Please use Settings->")+tr("Set application to open an URL"));
2528 void Main::editOpenURLTab()
2530 if (currentMapEditor())
2532 QString url=currentMapEditor()->getURL();
2533 if (url=="") return;
2534 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2535 if (procBrowser && procBrowser->isRunning())
2537 if (browser.contains("konqueror"))
2539 // Try to open new tab in existing konqueror started previously by vym
2540 Q3Process *p=new Q3Process (this);
2541 p->addArgument ("dcop");
2542 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2543 p->addArgument ("konqueror-mainwindow#1");
2544 p->addArgument ("newTab");
2545 p->addArgument (url);
2547 // try to set browser
2548 QMessageBox::warning(0,
2550 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2552 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2554 // Try to open new tab in firefox
2555 Q3Process *p=new Q3Process (this);
2556 p->addArgument (browser);
2557 p->addArgument ("-remote");
2558 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2560 // try to set browser
2561 QMessageBox::warning(0,
2563 tr("Couldn't start %1 to open a new tab").arg(browser));
2572 void Main::editURL()
2574 if (currentMapEditor())
2575 currentMapEditor()->editURL();
2578 void Main::editHeading2URL()
2580 if (currentMapEditor())
2581 currentMapEditor()->editHeading2URL();
2584 void Main::editBugzilla2URL()
2586 if (currentMapEditor())
2587 currentMapEditor()->editBugzilla2URL();
2590 void Main::editFATE2URL()
2592 if (currentMapEditor())
2593 currentMapEditor()->editFATE2URL();
2596 void Main::editOpenVymLink()
2598 // Get current path to map
2599 QString currentVymLink;
2600 if (currentMapEditor())
2602 currentVymLink=currentMapEditor()->getVymLink();
2603 // compare path with already loaded maps
2607 for (i=0;i<=tabWidget->count() -1;i++)
2609 me=(MapEditor*)tabWidget->page(i);
2610 if (currentVymLink==me->getFilePath() )
2619 if (!QFile(currentVymLink).exists() )
2620 QMessageBox::critical( 0, tr( "Critical Error" ),
2621 tr("Couldn't open map %1").arg(currentVymLink));
2624 fileLoad (currentVymLink, NewMap);
2625 tabWidget->setCurrentPage (tabWidget->count()-1);
2628 // Go to tab containing the map
2629 tabWidget->setCurrentPage (index);
2633 void Main::editVymLink()
2635 if (currentMapEditor())
2636 currentMapEditor()->editVymLink();
2639 void Main::editDeleteVymLink()
2641 if (currentMapEditor())
2642 currentMapEditor()->deleteVymLink();
2645 void Main::editToggleHideExport()
2647 if (currentMapEditor())
2648 currentMapEditor()->toggleHideExport();
2651 void Main::editMapInfo()
2653 if (currentMapEditor())
2654 currentMapEditor()->editMapInfo();
2657 void Main::editMoveUp()
2659 if (currentMapEditor())
2660 currentMapEditor()->moveBranchUp();
2663 void Main::editMoveDown()
2665 if (currentMapEditor())
2666 currentMapEditor()->moveBranchDown();
2669 void Main::editToggleScroll()
2671 if (currentMapEditor())
2673 currentMapEditor()->toggleScroll();
2677 void Main::editUnScrollAll()
2679 if (currentMapEditor())
2681 currentMapEditor()->unScrollAll();
2685 void Main::editHeading()
2687 if (currentMapEditor())
2688 currentMapEditor()->editHeading();
2691 void Main::editNewBranch()
2693 if (currentMapEditor())
2694 currentMapEditor()->addNewBranch(0);
2697 void Main::editNewBranchHere()
2699 if (currentMapEditor())
2700 currentMapEditor()->addNewBranchHere();
2703 void Main::editNewBranchAbove()
2705 if (currentMapEditor())
2706 currentMapEditor()->addNewBranch(-1);
2709 void Main::editNewBranchBelow()
2711 if (currentMapEditor())
2712 currentMapEditor()->addNewBranch(1);
2715 void Main::editImportAdd()
2717 fileLoad (ImportAdd);
2720 void Main::editImportReplace()
2722 fileLoad (ImportReplace);
2725 void Main::editSaveBranch()
2727 fileSaveAs (PartOfMap);
2730 void Main::editRemoveBranchKeepChilds()
2732 if (currentMapEditor())
2733 currentMapEditor()->removeBranchKeepChilds();
2736 void Main::editRemoveChilds()
2738 if (currentMapEditor())
2739 currentMapEditor()->removeChilds();
2742 void Main::editDeleteSelection()
2744 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2745 currentMapEditor()->deleteSelection();
2748 void Main::editUpperBranch()
2750 if (currentMapEditor())
2751 currentMapEditor()->selectUpperBranch();
2754 void Main::editLowerBranch()
2756 if (currentMapEditor())
2757 currentMapEditor()->selectLowerBranch();
2760 void Main::editLeftBranch()
2762 if (currentMapEditor())
2763 currentMapEditor()->selectLeftBranch();
2766 void Main::editRightBranch()
2768 if (currentMapEditor())
2769 currentMapEditor()->selectRightBranch();
2772 void Main::editFirstBranch()
2774 if (currentMapEditor())
2775 currentMapEditor()->selectFirstBranch();
2778 void Main::editLastBranch()
2780 if (currentMapEditor())
2781 currentMapEditor()->selectLastBranch();
2784 void Main::editLoadImage()
2786 if (currentMapEditor())
2787 currentMapEditor()->loadFloatImage();
2790 void Main::editSaveImage(int item)
2792 if (currentMapEditor())
2793 currentMapEditor()->saveFloatImage(item);
2796 void Main::editFollowXLink(int item)
2798 if (currentMapEditor())
2799 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2802 void Main::editEditXLink(int item)
2804 if (currentMapEditor())
2805 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2808 void Main::formatSelectColor()
2810 if (currentMapEditor())
2812 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2813 if ( !col.isValid() ) return;
2814 currentMapEditor()->setColor( col );
2815 colorChanged( col );
2819 void Main::formatPickColor()
2821 if (currentMapEditor())
2822 colorChanged( currentMapEditor()->pickColor() );
2825 void Main::colorChanged(QColor c)
2827 QPixmap pix( 16, 16 );
2829 actionFormatColor->setIconSet( pix );
2832 void Main::formatColorItem()
2834 if (currentMapEditor())
2835 currentMapEditor()->colorItem();
2838 void Main::formatColorBranch()
2840 if (currentMapEditor())
2841 currentMapEditor()->colorBranch();
2844 void Main::formatLinkStyleLine()
2846 if (currentMapEditor())
2847 currentMapEditor()->setLinkStyle(StyleLine);
2850 void Main::formatLinkStyleParabel()
2852 if (currentMapEditor())
2853 currentMapEditor()->setLinkStyle(StyleParabel);
2856 void Main::formatLinkStylePolyLine()
2858 if (currentMapEditor())
2859 currentMapEditor()->setLinkStyle(StylePolyLine);
2862 void Main::formatLinkStylePolyParabel()
2864 if (currentMapEditor())
2865 currentMapEditor()->setLinkStyle(StylePolyParabel);
2868 void Main::formatSelectBackColor()
2870 if (currentMapEditor())
2871 currentMapEditor()->selectBackgroundColor();
2874 void Main::formatSelectLinkColor()
2876 if (currentMapEditor())
2877 currentMapEditor()->selectLinkColor();
2880 void Main::formatToggleLinkColorHint()
2882 currentMapEditor()->toggleLinkColorHint();
2885 void Main::formatFrameNone()
2887 if (currentMapEditor())
2888 currentMapEditor()->setFrame(NoFrame);
2891 void Main::formatFrameRectangle()
2893 if (currentMapEditor())
2894 currentMapEditor()->setFrame(Rectangle);
2897 void Main::formatIncludeImagesVer()
2899 if (currentMapEditor())
2900 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2903 void Main::formatIncludeImagesHor()
2905 if (currentMapEditor())
2906 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2909 void Main::formatHideLinkUnselected()
2911 if (currentMapEditor())
2912 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2915 void Main::viewZoomReset()
2917 if (currentMapEditor())
2921 currentMapEditor()->setWorldMatrix( m );
2922 currentMapEditor()->setViewCenter();
2923 currentMapEditor()->adjustCanvasSize();
2927 void Main::viewZoomIn()
2929 if (currentMapEditor())
2931 QMatrix m = currentMapEditor()->worldMatrix();
2932 m.scale( 1.25, 1.25 );
2933 currentMapEditor()->setWorldMatrix( m );
2934 currentMapEditor()->setViewCenter();
2935 currentMapEditor()->adjustCanvasSize();
2939 void Main::viewZoomOut()
2941 if (currentMapEditor())
2943 QMatrix m = currentMapEditor()->worldMatrix();
2944 m.scale( 0.8, 0.8 );
2945 currentMapEditor()->setWorldMatrix( m );
2946 currentMapEditor()->setViewCenter();
2947 currentMapEditor()->adjustCanvasSize();
2951 void Main::modModeColor()
2955 void Main::modModeLink()
2959 bool Main::settingsPDF()
2961 // Default browser is set in constructor
2963 QString text = QInputDialog::getText(
2964 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2965 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2967 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2972 bool Main::settingsURL()
2974 // Default browser is set in constructor
2976 QString text = QInputDialog::getText(
2977 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2978 settings.readEntry("/vym/mainwindow/readerURL")
2981 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2985 void Main::settingsToggleDelKey()
2987 if (actionSettingsUseDelKey->isOn())
2989 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
2992 actionEditDelete->setAccel (QKeySequence (""));
2996 void Main::windowToggleNoteEditor()
2998 if (textEditor->showWithMain() )
2999 windowHideNoteEditor();
3001 windowShowNoteEditor();
3004 void Main::windowToggleHistory()
3006 if (currentMapEditor())
3007 currentMapEditor()->toggleHistoryWindow();
3010 void Main::updateNoteFlag()
3012 if (currentMapEditor())
3013 currentMapEditor()->updateNoteFlag();
3016 void Main::windowShowNoteEditor()
3018 textEditor->setShowWithMain(true);
3020 actionViewToggleNoteEditor->setOn (true);
3023 void Main::windowHideNoteEditor()
3025 textEditor->setShowWithMain(false);
3027 actionViewToggleNoteEditor->setOn (false);
3030 void Main::windowNextEditor()
3032 if (tabWidget->currentPageIndex() < tabWidget->count())
3033 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3036 void Main::windowPreviousEditor()
3038 if (tabWidget->currentPageIndex() >0)
3039 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3042 void Main::standardFlagChanged()
3044 currentMapEditor()->toggleStandardFlag(sender()->name());
3047 void Main::testFunction()
3049 currentMapEditor()->testFunction();
3052 void Main::helpDoc()
3055 #if defined(Q_OS_MACX)
3056 docpath="./vym.app/Contents/vym.pdf";
3058 // default path in SUSE LINUX
3059 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3062 if (!QFile (docpath).exists() )
3064 // relative path for easy testing in tarball
3065 docpath="doc/vym.pdf";
3066 if (!QFile (docpath).exists() )
3068 // relative path for testing while still writing vym.tex
3069 docpath="doc/tex/vym.pdf";
3070 if (!QFile (docpath).exists() )
3072 // Try yet another one for Knoppix
3073 docpath="/usr/share/doc/packages/vym/vym.pdf";
3074 if (!QFile (docpath).exists() )
3076 QMessageBox::critical(0,
3077 tr("Critcal error"),
3078 tr("Couldn't find the documentation\n"
3079 "vym.pdf in various places."));
3086 Process *pdfProc = new Process();
3087 pdfProc->clearArguments();
3088 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
3089 pdfProc->addArgument( docpath);
3091 if ( !pdfProc->start() )
3094 QMessageBox::warning(0,
3096 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3097 tr("Please use Settings->")+tr("Set application to open PDF files"));
3104 void Main::helpAbout()
3107 ad.setName ("aboutwindow");
3108 ad.setMinimumSize(500,500);
3109 ad.resize (QSize (500,500));
3113 void Main::helpAboutQT()
3115 QMessageBox::aboutQt( this, "Qt Application Example" );