1 #include "mainwindow.h"
7 #include <q3filedialog.h>
9 #include <QColorDialog>
11 #include <QInputDialog>
15 #include <QCloseEvent>
18 #include <Q3PopupMenu>
19 #include <QActionGroup>
21 //#include <qdatetime.h> // for random seed
27 #include "aboutdialog.h"
28 #include "exportoofiledialog.h"
30 #include "exportxhtmldialog.h"
32 #include "flagrowobj.h"
34 #include "mapeditor.h"
39 #include "showtextdialog.h"
40 #include "texteditor.h"
43 extern TextEditor *textEditor;
44 extern Main *mainWindow;
45 extern QString tmpVymDir;
46 extern QString clipboardDir;
47 extern bool clipboardEmpty;
48 extern int statusbarTime;
49 extern FlagRowObj* standardFlagsDefault;
50 extern FlagRowObj* systemFlagsDefault;
52 extern Q3PtrList <QAction> actionListBranches;
54 extern QAction* actionFileSave;
55 extern QAction* actionFilePrint;
56 extern QAction* actionEditUndo;
57 extern QAction* actionEditRedo;
58 extern QAction *actionEditCopy;
59 extern QAction *actionEditCut;
60 extern QAction *actionEditPaste;
61 extern QAction *actionEditMoveUp;
62 extern QAction *actionEditMoveDown;
63 extern QAction *actionEditToggleScroll;
64 extern QAction* actionEditOpenURL;
65 extern QAction* actionEditOpenURLTab;
66 extern QAction* actionEditURL;
67 extern QAction* actionEditHeading2URL;
68 extern QAction* actionEditBugzilla2URL;
69 extern QAction* actionEditFATE2URL;
70 extern QAction *actionEditOpenVymLink;
71 extern QAction *actionEditVymLink;
72 extern QAction *actionEditDeleteVymLink;
73 extern QAction *actionEditToggleHideExport;
74 extern QAction *actionEditMapInfo;
75 extern QAction *actionEditHeading;
76 extern QAction *actionEditDelete;
77 extern QAction *actionEditAddBranch;
78 extern QAction *actionEditAddBranchHere;
79 extern QAction *actionEditAddBranchAbove;
80 extern QAction *actionEditAddBranchBelow;
81 extern QAction *actionEditRemoveBranchKeepChilds;
82 extern QAction *actionEditRemoveChilds;
83 extern QAction *actionEditImportAdd;
84 extern QAction *actionEditImportReplace;
85 extern QAction *actionEditSaveBranch;
86 extern QAction *actionEditSelectFirst;
87 extern QAction *actionEditSelectLast;
88 extern QAction *actionEditLoadImage;
90 extern QAction* actionFormatColor;
91 extern QAction* actionFormatPickColor;
92 extern QAction* actionFormatColorBranch;
93 extern QAction* actionFormatColorSubtree;
94 extern QAction* actionFormatLinkColorHint;
95 extern QAction* actionFormatBackColor;
96 extern QAction* actionFormatLinkColor;
97 extern QAction *actionFormatIncludeImagesVer;
98 extern QAction *actionFormatIncludeImagesHor;
100 extern QActionGroup* actionGroupModModes;
101 extern QAction* actionModModeColor;
102 extern QAction* actionModModeLink;
103 extern QAction* actionModModeCopy;
105 extern QActionGroup *actionGroupFormatFrameTypes;
106 extern QAction *actionFormatFrameNone;
107 extern QAction *actionFormatFrameRectangle;
109 extern QActionGroup *actionGroupFormatLinkStyles;
110 extern QAction *actionFormatLinkStyleLine;
111 extern QAction *actionFormatLinkStyleParabel;
112 extern QAction *actionFormatLinkStylePolyLine;
113 extern QAction *actionFormatLinkStylePolyParabel;
114 extern QAction *actionFormatHideLinkUnselected;
116 extern QAction *actionViewToggleNoteEditor;
117 extern QAction *actionViewToggleHistoryWindow;
119 extern QAction* actionSettingsAutoedit;
120 extern QAction* actionSettingsAutoselectHeading;
121 extern QAction* actionSettingsAutoselectHeading;
122 extern QAction* actionSettingsAutoselectText;
123 extern QAction* actionSettingsPasteNewHeading;
124 extern QAction* actionSettingsUseDelKey;
125 extern QAction* actionSettingsUseFlagGroups;
126 extern QAction* actionSettingsUseHideExport;
128 extern QMenu* branchContextMenu;
129 extern QMenu* branchAddContextMenu;
130 extern QMenu* branchRemoveContextMenu;
131 extern QMenu* branchLinksContextMenuEdit;
132 extern QMenu* branchLinksContextMenuFollow;
133 extern QMenu* floatimageContextMenu;
134 extern QMenu* canvasContextMenu;
135 extern QMenu* fileLastMapsMenu;
136 extern QMenu* fileImportMenu;
137 extern QMenu* fileExportMenu;
140 extern Settings settings;
141 extern Options options;
142 extern ImageIO imageIO;
144 extern QDir vymBaseDir;
145 extern QDir lastImageDir;
146 extern QDir lastFileDir;
147 extern QString iconPath;
148 extern QString flagsPath;
150 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
151 QMainWindow(parent,name,f)
155 setCaption ("VYM - View Your Mind");
157 // Load window settings
158 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
159 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
160 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
161 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
164 // Create unique temporary directory
165 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
167 // Create direcctory for clipboard
168 clipboardDir=tmpVymDir+"/clipboard";
169 QDir d(clipboardDir);
170 d.mkdir (clipboardDir,true);
171 makeSubDirs (clipboardDir);
176 // FIXME not used currently
177 // Set random seed (random used for object IDs)
178 // QTime t = QTime::currentTime(); // set random seed
179 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
182 // Initialize some settings, which are platform dependant
185 // application to open URLs
186 p="/vym/mainwindow/readerURL";
187 #if defined(Q_OS_LINUX)
188 s=settings.readEntry (p,"konqueror");
190 #if defined(Q_OS_MACX)
191 s=settings.readEntry (p,"/usr/bin/open");
193 s=settings.readEntry (p,"mozilla");
196 settings.writeEntry( p,s);
198 // application to open PDFs
199 p="/vym/mainwindow/readerPDF";
200 #if defined(Q_OS_LINUX)
201 s=settings.readEntry (p,"acroread");
203 #if defined(Q_OS_MACX)
204 s=settings.readEntry (p,"/usr/bin/open");
206 s=settings.readEntry (p,"acroread");
209 settings.writeEntry( p,s);
214 // Create tab widget which holds the maps
215 tabWidget= new QTabWidget (this);
216 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
217 this, SLOT( editorChanged( QWidget * ) ) );
219 setCentralWidget(tabWidget);
223 setupFormatActions();
227 setupSettingsActions();
229 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
232 // After menu is created, we can enable some actions
233 //FIXME QT3 testing actionFilePrint->setEnabled (true);
238 // Initialize Find window
239 findWindow=new FindWindow(NULL,"findwindow");
240 connect (findWindow, SIGNAL( findButton(QString) ),
241 this, SLOT(editFind(QString) ) );
242 connect (findWindow, SIGNAL( somethingChanged() ),
243 this, SLOT(editFindChanged() ) );
245 // Connect TextEditor, so that we can update flags if text changes
246 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
254 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
255 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
256 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
257 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
259 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
260 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
262 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
263 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
264 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
265 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
266 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
267 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
268 settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
271 int maps=lastMaps.count();
272 settings.writeEntry( "/vym/lastMaps/number",maps );
273 for (int i=1;i<=maps;i++)
275 s=QString("/vym/lastMaps/map-%1").arg(i);
276 if (!s.isEmpty() && i<=maxLastMaps)
277 settings.writeEntry (s, lastMaps.at(i-1));
281 // To make the texteditor save its settings, call the destructor
284 // Remove temporary directory
285 removeDir (QDir(tmpVymDir));
288 void Main::loadCmdLine()
290 /* TODO draw some kind of splashscreen while loading...
296 QStringList flist=options.getFileList();
297 QStringList::Iterator it=flist.begin();
299 while (it !=flist.end() )
301 fileLoad (*it, NewMap);
307 void Main::statusMessage(const QString &s)
309 statusBar()->message (s);
312 void Main::closeEvent (QCloseEvent* )
318 void Main::setupFileActions()
320 QMenu *fileMenu = menuBar()->addMenu ( tr ("&File") );
321 QToolBar *tb = addToolBar( tr ("&File") );
324 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
325 a->setStatusTip ( tr( "New map","File menu" ) );
326 a->setShortcut ( Qt::CTRL + Qt::Key_N );
328 fileMenu->addAction (a);
329 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
331 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
332 a->setStatusTip (tr( "Open","File menu" ) );
333 a->setShortcut ( Qt::CTRL + Qt::Key_O );
335 fileMenu->addAction (a);
336 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
338 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
339 fileMenu->addSeparator();
341 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
342 a->setStatusTip ( tr( "Save" ));
343 a->setShortcut (Qt::CTRL + Qt::Key_S );
345 fileMenu->addAction (a);
346 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
349 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
350 a->setStatusTip (tr( "Save &As" ) );
351 fileMenu->addAction (a);
352 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
354 fileMenu->addSeparator();
356 fileImportMenu = fileMenu->addMenu (tr("Import"));
358 a = new QAction(tr("KDE Bookmarks"), this);
359 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
360 a->addTo (fileImportMenu);
361 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
363 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
365 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
366 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
367 a->addTo (fileImportMenu);
368 connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
371 a = new QAction("Mind Manager...",this);
372 a->setStatusTip ( tr( "Import")+" Mind Manager" );
373 fileImportMenu->addAction (a);
374 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
376 a = new QAction( tr( "Import Dir"+QString("...") ), this);
377 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
378 fileImportMenu->addAction (a);
379 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
381 fileExportMenu = fileMenu->addMenu (tr("Export"));
383 a = new QAction( tr("Image")+QString("..."), this);
384 a->setStatusTip( tr( "Export map as image" ));
385 connect( a, SIGNAL( activated() ), this, SLOT( fileExportImage() ) );
386 fileExportMenu->addAction (a);
388 a = new QAction( "Open Office"+QString("..."), this);
389 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
390 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
391 fileExportMenu->addAction (a);
393 a = new QAction( "Webpage (XHTML)...",this );
394 a->setShortcut (Qt::ALT + Qt::Key_X);
395 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
396 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
397 fileExportMenu->addAction (a);
399 a = new QAction( "Text (ASCII)...", this);
400 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
401 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
402 fileExportMenu->addAction (a);
404 a = new QAction( tr("KDE Bookmarks"), this);
405 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
406 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
407 fileExportMenu->addAction (a);
409 a = new QAction( "Taskjuggler...", this );
410 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
411 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
412 fileExportMenu->addAction (a);
414 a = new QAction( "LaTeX...", this);
415 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
416 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
417 fileExportMenu->addAction (a);
419 a = new QAction( "XML..." , this );
420 a->setStatusTip (tr( "Export as")+" XML");
421 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
422 fileExportMenu->addAction (a);
424 fileMenu->addSeparator();
426 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
427 a->setStatusTip ( tr( "Print" ) );
428 a->setShortcut (Qt::CTRL + Qt::Key_P );
430 fileMenu->addAction (a);
431 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
434 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
435 a->setStatusTip (tr( "Close Map" ) );
436 a->setShortcut (Qt::ALT + Qt::Key_C );
437 fileMenu->addAction (a);
438 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
440 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
441 a->setStatusTip ( tr( "Exit")+" "+__VYM );
442 a->setShortcut (Qt::CTRL + Qt::Key_Q );
443 fileMenu->addAction (a);
444 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
449 void Main::setupEditActions()
451 QToolBar *tb = addToolBar( tr ("&Edit") );
452 tb->setLabel( "Edit Actions" );
453 QMenu *editMenu = menuBar()->addMenu( tr("&Edit") );
457 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
458 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
459 a->setStatusTip (tr( "Undo" ) );
460 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
461 a->setEnabled (false);
463 editMenu->addAction (a);
466 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
468 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
469 a->setStatusTip (tr( "Redo" ));
470 a->setShortcut (Qt::CTRL + Qt::Key_Y );
471 editMenu->addAction (a);
472 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
475 editMenu->addSeparator();
476 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
477 a->setStatusTip ( tr( "Copy" ) );
478 a->setShortcut (Qt::CTRL + Qt::Key_C );
479 a->setEnabled (false);
481 editMenu->addAction (a);
482 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
485 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
486 a->setStatusTip ( tr( "Cut" ) );
487 a->setShortcut (Qt::CTRL + Qt::Key_X );
488 a->setEnabled (false);
490 editMenu->addAction (a);
492 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
494 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
495 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
496 a->setStatusTip ( tr( "Paste" ) );
497 a->setShortcut ( Qt::CTRL + Qt::Key_V );
498 a->setEnabled (false);
500 editMenu->addAction (a);
503 // Shortcuts to modify heading:
504 a = new QAction(tr( "Edit heading" ),this);
505 a->setStatusTip ( tr( "edit Heading" ));
506 a->setShortcut ( Qt::Key_Enter);
507 a->setShortcutContext (Qt::WindowShortcut);
509 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
510 actionListBranches.append(a);
511 a = new QAction( tr( "Edit heading" ), this);
512 a->setStatusTip (tr( "edit Heading" ));
513 a->setShortcut (Qt::Key_Return );
514 a->setShortcutContext (Qt::WindowShortcut);
516 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
517 actionListBranches.append(a);
518 editMenu->addAction (a);
520 a = new QAction( tr( "Edit heading" ), this);
521 a->setStatusTip (tr( "edit Heading" ));
522 a->setShortcut ( Qt::Key_F2 );
523 a->setShortcutContext (Qt::WindowShortcut);
525 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
526 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 a->setShortcutContext (Qt::WindowShortcut);
534 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
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 alt->setShortcutContext (Qt::WindowShortcut);
543 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
544 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child" ), this);
545 a->setStatusTip ( tr( "Add a branch as child of selection" ));
546 a->setShortcut (Qt::Key_Insert);
547 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
548 actionListBranches.append(a);
549 #if defined (Q_OS_MACX)
550 // In OSX show different shortcut in menues, the keys work indepently always
551 actionEditAddBranch=alt;
553 actionEditAddBranch=a;
555 editMenu->addAction (actionEditAddBranch);
556 tb->addAction (actionEditAddBranch);
559 // Add branch by inserting it at selection
560 a = new QAction(tr( "Add branch (insert)" ), this);
561 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
562 a->setShortcut (Qt::ALT + Qt::Key_Insert );
563 a->setShortcutContext (Qt::WindowShortcut);
565 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
566 a->setEnabled (false);
567 actionListBranches.append(a);
568 actionEditAddBranchHere=a;
569 a = new QAction(tr( "Add branch (insert)" ),this);
570 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
571 a->setShortcut ( Qt::ALT + Qt::Key_A );
572 a->setShortcutContext (Qt::WindowShortcut);
574 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
575 actionListBranches.append(a);
578 a = new QAction(tr( "Add branch above" ), this);
579 a->setStatusTip ( tr( "Add a branch above selection" ));
580 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
581 a->setShortcutContext (Qt::WindowShortcut);
583 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
584 a->setEnabled (false);
585 actionListBranches.append(a);
586 actionEditAddBranchAbove=a;
587 a = new QAction(tr( "Add branch above" ), this);
588 a->setStatusTip ( tr( "Add a branch above selection" ));
589 a->setShortcut (Qt::SHIFT+Qt::Key_A );
590 a->setShortcutContext (Qt::WindowShortcut);
592 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
593 actionListBranches.append(a);
596 a = new QAction(tr( "Add branch below" ), this);
597 a->setStatusTip ( tr( "Add a branch below selection" ));
598 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
599 a->setShortcutContext (Qt::WindowShortcut);
601 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
602 a->setEnabled (false);
603 actionListBranches.append(a);
604 actionEditAddBranchBelow=a;
605 a = new QAction(tr( "Add branch below" ), this);
606 a->setStatusTip ( tr( "Add a branch below selection" ));
607 a->setShortcut (Qt::CTRL +Qt::Key_A );
608 a->setShortcutContext (Qt::WindowShortcut);
610 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
611 actionListBranches.append(a);
613 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
614 a->setStatusTip ( tr( "Move branch up" ) );
615 a->setShortcut (Qt::Key_PageUp );
616 a->setEnabled (false);
618 editMenu->addAction (a);
619 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
622 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
623 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
624 a->setStatusTip (tr( "Move branch down" ) );
625 a->setShortcut ( Qt::Key_PageDown );
626 a->setEnabled (false);
628 editMenu->addAction (a);
629 actionEditMoveDown=a;
632 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
633 a->setShortcut ( Qt::Key_ScrollLock );
634 a->setStatusTip (tr( "Scroll branch" ) );
635 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
636 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
637 alt->setShortcut ( Qt::Key_S );
638 alt->setStatusTip (tr( "Scroll branch" ));
639 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
640 #if defined(Q_OS_MACX)
641 actionEditToggleScroll=alt;
643 actionEditToggleScroll=a;
645 actionEditToggleScroll->setEnabled (false);
646 actionEditToggleScroll->setToggleAction(true);
647 tb->addAction (actionEditToggleScroll);
648 editMenu->addAction ( actionEditToggleScroll);
649 editMenu->addAction (actionEditToggleScroll);
650 actionListBranches.append(actionEditToggleScroll);
652 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
653 a->setStatusTip (tr( "Unscroll all" ));
654 editMenu->addAction (a);
655 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
657 editMenu->addSeparator();
659 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
660 a->setStatusTip (tr( "Find" ) );
661 a->setShortcut (Qt::CTRL + Qt::Key_F );
662 editMenu->addAction (a);
663 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
665 editMenu->addSeparator();
667 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
668 a->setShortcut (Qt::CTRL + Qt::Key_U );
669 a->setShortcut (tr( "Open URL" ));
672 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
675 a = new QAction( tr( "Open URL in new tab" ), this);
676 a->setStatusTip (tr( "Open URL in new tab" ));
677 a->setShortcut (Qt::CTRL+Qt::Key_U );
679 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
680 actionEditOpenURLTab=a;
682 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
683 a->setStatusTip ( tr( "Edit URL" ) );
684 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
685 //a->setShortcut ( Qt::Key_U );
686 a->setShortcutContext (Qt::WindowShortcut);
687 actionListBranches.append(a);
689 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
692 a = new QAction( tr( "Use heading for URL" ), this);
693 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
694 a->setEnabled (false);
695 actionListBranches.append(a);
696 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
697 actionEditHeading2URL=a;
699 a = new QAction(tr( "Create URL to Bugzilla" ), this);
700 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
701 a->setEnabled (false);
702 actionListBranches.append(a);
703 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
704 actionEditBugzilla2URL=a;
706 a = new QAction(tr( "Create URL to FATE" ), this);
707 a->setStatusTip ( tr( "Create URL to FATE" ));
708 a->setEnabled (false);
709 actionListBranches.append(a);
710 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
711 actionEditFATE2URL=a;
713 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
714 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
716 a->setEnabled (false);
717 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
718 actionEditOpenVymLink=a;
720 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
721 a->setEnabled (false);
722 a->setStatusTip ( tr( "Edit link to another vym map" ));
723 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
724 actionListBranches.append(a);
727 a = new QAction(tr( "Delete vym link" ),this);
728 a->setStatusTip ( tr( "Delete link to another vym map" ));
729 a->setEnabled (false);
730 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
731 actionEditDeleteVymLink=a;
733 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
734 a->setStatusTip ( tr( "Hide object in exports" ) );
735 a->setShortcut (Qt::Key_H );
736 a->setToggleAction(true);
738 a->setEnabled (false);
739 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
740 actionEditToggleHideExport=a;
742 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
743 a->setStatusTip ( tr( "Edit Map Info" ));
744 a->setEnabled (true);
745 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
748 editMenu->addSeparator();
750 // Import at selection (adding to selection)
751 a = new QAction( tr( "Add map (insert)" ),this);
752 a->setStatusTip (tr( "Add map at selection" ));
753 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
754 a->setEnabled (false);
755 actionListBranches.append(a);
756 actionEditImportAdd=a;
758 // Import at selection (replacing selection)
759 a = new QAction( tr( "Add map (replace)" ), this);
760 a->setStatusTip (tr( "Replace selection with map" ));
761 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
762 a->setEnabled (false);
763 actionListBranches.append(a);
764 actionEditImportReplace=a;
767 a = new QAction( tr( "Save selection" ), this);
768 a->setStatusTip (tr( "Save selection" ));
769 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
770 a->setEnabled (false);
771 actionListBranches.append(a);
772 actionEditSaveBranch=a;
774 // Only remove branch, not its childs
775 a = new QAction(tr( "Remove only branch " ), this);
776 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
777 a->setShortcut (Qt::ALT + Qt::Key_Delete );
778 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
779 a->setEnabled (false);
780 actionListBranches.append(a);
781 actionEditRemoveBranchKeepChilds=a;
783 // Only remove childs of a branch
784 a = new QAction( tr( "Remove childs" ), this);
785 a->setStatusTip (tr( "Remove childs of branch" ));
786 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
787 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
788 a->setEnabled (false);
789 actionListBranches.append(a);
790 actionEditRemoveChilds=a;
792 // Shortcuts for navigating with cursor:
793 a = new QAction(tr( "Select upper branch" ), this);
794 a->setStatusTip ( tr( "Select upper branch" ));
795 a->setShortcut (Qt::Key_Up );
796 a->setShortcutContext (Qt::WindowShortcut);
798 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
799 a = new QAction( tr( "Select lower branch" ),this);
800 a->setStatusTip (tr( "Select lower branch" ));
801 a->setShortcut ( Qt::Key_Down );
802 a->setShortcutContext (Qt::WindowShortcut);
804 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
805 a = new QAction(tr( "Select left branch" ), this);
806 a->setStatusTip ( tr( "Select left branch" ));
807 a->setShortcut (Qt::Key_Left );
808 a->setShortcutContext (Qt::WindowShortcut);
810 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
811 a = new QAction( tr( "Select child branch" ), this);
812 a->setStatusTip (tr( "Select right branch" ));
813 a->setShortcut (Qt::Key_Right);
814 a->setShortcutContext (Qt::WindowShortcut);
816 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
817 a = new QAction( tr( "Select first branch" ), this);
818 a->setStatusTip (tr( "Select first branch" ));
819 a->setShortcut (Qt::Key_Home );
820 a->setShortcutContext (Qt::WindowShortcut);
822 a->setEnabled (false);
823 editMenu->addAction (a);
824 actionListBranches.append(a);
825 actionEditSelectFirst=a;
826 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
827 a = new QAction( tr( "Select last branch" ),this);
828 a->setStatusTip (tr( "Select last branch" ));
829 a->setShortcut ( Qt::Key_End );
830 a->setShortcutContext (Qt::WindowShortcut);
832 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
833 a->setEnabled (false);
834 editMenu->addAction (a);
835 actionListBranches.append(a);
836 actionEditSelectLast=a;
838 a = new QAction( tr( "Add Image" )+QString("..."), this);
839 a->setStatusTip (tr( "Add Image" ));
840 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
841 actionEditLoadImage=a;
846 void Main::setupFormatActions()
848 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
850 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
853 pix.fill (Qt::black);
854 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
855 a->setStatusTip ( tr( "Set Color" ));
856 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
858 formatMenu->addAction (a);
860 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
861 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
862 a->setShortcut (Qt::CTRL + Qt::Key_K );
863 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
864 a->setEnabled (false);
866 formatMenu->addAction (a);
867 actionListBranches.append(a);
868 actionFormatPickColor=a;
870 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
871 a->setStatusTip ( tr( "Color branch" ) );
872 a->setShortcut (Qt::CTRL + Qt::Key_I);
873 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
874 a->setEnabled (false);
876 formatMenu->addAction (a);
877 actionListBranches.append(a);
878 actionFormatColorBranch=a;
880 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
881 a->setStatusTip ( tr( "Color Subtree" ));
882 a->setShortcut (Qt::CTRL + Qt::Key_T);
883 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
884 a->setEnabled (false);
885 formatMenu->addAction (a);
887 actionListBranches.append(a);
888 actionFormatColorSubtree=a;
890 formatMenu->addSeparator();
891 actionGroupFormatLinkStyles=new QActionGroup ( this);
892 actionGroupFormatLinkStyles->setExclusive (true);
893 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
894 a->setStatusTip (tr( "Line" ));
895 a->setToggleAction(true);
896 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
897 formatMenu->addAction (a);
898 actionFormatLinkStyleLine=a;
899 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
900 a->setStatusTip (tr( "Line" ));
901 a->setToggleAction(true);
902 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
903 formatMenu->addAction (a);
904 actionFormatLinkStyleParabel=a;
905 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
906 a->setStatusTip (tr( "PolyLine" ));
907 a->setToggleAction(true);
908 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
909 formatMenu->addAction (a);
910 actionFormatLinkStylePolyLine=a;
911 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
912 a->setStatusTip (tr( "PolyParabel" ) );
913 a->setToggleAction(true);
914 a->setChecked (true);
915 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
916 formatMenu->addAction (a);
917 actionFormatLinkStylePolyParabel=a;
919 actionGroupFormatFrameTypes=new QActionGroup ( this);
920 actionGroupFormatFrameTypes->setExclusive (true);
921 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
922 a->setStatusTip (tr("No Frame"));
923 a->setToggleAction(true);
924 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
925 actionFormatFrameNone=a;
926 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
927 a->setStatusTip (tr( "Rectangle" ));
928 a->setToggleAction(true);
929 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
930 actionFormatFrameRectangle=a;
932 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
933 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
934 a->setToggleAction(true);
935 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
936 actionFormatIncludeImagesVer=a;
938 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
939 a->setStatusTip ( tr ("Include left and right position of images into branch"));
940 a->setToggleAction(true);
941 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
942 actionFormatIncludeImagesHor=a;
944 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
945 a->setStatusTip (tr( "Hide link" ));
946 a->setToggleAction(true);
947 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
948 actionFormatHideLinkUnselected=a;
950 formatMenu->addSeparator();
951 a= new QAction( tr( "&Use color of heading for link" ), this);
952 a->setStatusTip (tr( "Use same color for links and headings" ));
953 a->setToggleAction(true);
954 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
955 formatMenu->addAction (a);
956 actionFormatLinkColorHint=a;
958 pix.fill (Qt::white);
959 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
960 a->setStatusTip (tr( "Set Link Color" ));
961 formatMenu->addAction (a);
962 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
963 actionFormatLinkColor=a;
965 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
966 a->setStatusTip (tr( "Set Background Color" ));
967 formatMenu->addAction (a);
968 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
969 actionFormatBackColor=a;
973 void Main::setupViewActions()
975 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
976 tb->setLabel( "View Actions" );
977 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
980 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
981 a->setStatusTip ( tr( "Zoom reset" ) );
982 a->setShortcut (Qt::CTRL + Qt::Key_0 );
984 viewMenu->addAction (a);
985 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
987 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
988 a->setStatusTip (tr( "Zoom in" ));
989 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
991 viewMenu->addAction (a);
992 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
994 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
995 a->setStatusTip (tr( "Zoom out" ));
996 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
998 viewMenu->addAction (a);
999 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
1002 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1003 a->setStatusTip ( tr( "Show Note Editor" ));
1004 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1005 a->setToggleAction(true);
1006 if (textEditor->showWithMain())
1011 viewMenu->addAction (a);
1012 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
1013 actionViewToggleNoteEditor=a;
1015 a = new QAction( tr( "Show history window" ),this );
1016 a->setStatusTip ( tr( "Show history window" ));
1017 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1018 a->setToggleAction(false);
1019 viewMenu->addAction (a);
1020 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
1021 actionViewToggleHistoryWindow=a;
1023 a = new QAction(tr( "Next Window" ), this);
1024 a->setStatusTip ( tr( "&Next Window" ) );
1025 a->setShortcut (Qt::ALT + Qt::Key_N );
1026 viewMenu->addAction (a);
1027 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
1029 a = new QAction (tr( "Previous Window" ), this );
1030 a->setStatusTip (tr( "&Previous Window" ));
1031 a->setShortcut (Qt::ALT + Qt::Key_P );
1032 viewMenu->addAction (a);
1033 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
1037 void Main::setupModeActions()
1039 //QPopupMenu *menu = new QPopupMenu( this );
1040 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1042 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1044 actionGroupModModes=new QActionGroup ( this);
1045 actionGroupModModes->setExclusive (true);
1046 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1047 a->setShortcut (Qt::Key_J);
1048 a->setStatusTip ( tr( "Use modifier to color branches" ));
1049 a->setToggleAction(true);
1052 actionModModeColor=a;
1054 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1055 a->setShortcut( Qt::Key_K);
1056 a->setStatusTip( tr( "Use modifier to copy" ));
1057 a->setToggleAction(true);
1059 actionModModeCopy=a;
1061 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1062 a->setShortcut (Qt::Key_L);
1063 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1064 a->setToggleAction(true);
1066 actionModModeLink=a;
1070 void Main::setupFlagActions()
1072 // Create System Flags
1073 systemFlagsDefault = new FlagRowObj ();
1074 systemFlagsDefault->setVisibility (false);
1075 systemFlagsDefault->setName ("systemFlagsDef");
1077 FlagObj *fo = new FlagObj ();
1078 fo->load(QPixmap(flagsPath+"flag-note.png"));
1079 fo->setName("note");
1080 fo->setToolTip(tr("Note","Systemflag"));
1081 systemFlagsDefault->addFlag (fo); // makes deep copy
1083 fo->load(QPixmap(flagsPath+"flag-url.png"));
1085 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1086 systemFlagsDefault->addFlag (fo);
1088 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1089 fo->setName("vymLink");
1090 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1091 systemFlagsDefault->addFlag (fo);
1093 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1094 fo->setName("scrolledright");
1095 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1096 systemFlagsDefault->addFlag (fo);
1098 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1099 fo->setName("tmpUnscrolledright");
1100 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1101 systemFlagsDefault->addFlag (fo);
1103 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1104 fo->setName("hideInExport");
1105 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1106 systemFlagsDefault->addFlag (fo);
1108 // Create Standard Flags
1109 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1111 standardFlagsDefault = new FlagRowObj ();
1112 standardFlagsDefault->setVisibility (false);
1113 standardFlagsDefault->setName ("standardFlagsDef");
1114 standardFlagsDefault->setToolBar (tb);
1116 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1117 fo->setName ("exclamationmark");
1118 fo->setGroup("standard-mark");
1119 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1122 a->setCheckable(true);
1123 a->setObjectName(fo->getName());
1124 a->setToolTip(tr("Take care!","Standardflag"));
1125 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1126 standardFlagsDefault->addFlag (fo); // makes deep copy
1128 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1129 fo->setName("questionmark");
1130 fo->setGroup("standard-mark");
1131 a=new QAction (fo->getPixmap(),fo->getName(),this);
1134 a->setCheckable(true);
1135 a->setObjectName(fo->getName());
1136 a->setToolTip(tr("Really?","Standardflag"));
1137 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1138 standardFlagsDefault->addFlag (fo);
1140 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1141 fo->setName("hook-green");
1142 fo->setGroup("standard-hook");
1143 a=new QAction (fo->getPixmap(),fo->getName(),this);
1146 a->setCheckable(true);
1147 a->setObjectName(fo->getName());
1148 a->setToolTip(tr("ok!","Standardflag"));
1149 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1150 standardFlagsDefault->addFlag (fo);
1152 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1153 fo->setName("cross-red");
1154 fo->setGroup("standard-hook");
1155 a=new QAction (fo->getPixmap(),fo->getName(),this);
1158 a->setCheckable(true);
1159 a->setObjectName(fo->getName());
1160 a->setToolTip(tr("Not ok!","Standardflag"));
1161 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1162 standardFlagsDefault->addFlag (fo);
1164 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1165 fo->setName("stopsign");
1166 a=new QAction (fo->getPixmap(),fo->getName(),this);
1169 a->setCheckable(true);
1170 a->setObjectName(fo->getName());
1171 a->setToolTip(tr("This won't work!","Standardflag"));
1172 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1173 standardFlagsDefault->addFlag (fo);
1175 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1176 fo->setName("smiley-good");
1177 fo->setGroup("standard-smiley");
1178 a=new QAction (fo->getPixmap(),fo->getName(),this);
1181 a->setCheckable(true);
1182 a->setObjectName(fo->getName());
1183 a->setToolTip(tr("Good","Standardflag"));
1184 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1185 standardFlagsDefault->addFlag (fo);
1187 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1188 fo->setName("smiley-sad");
1189 fo->setGroup("standard-smiley");
1190 a=new QAction (fo->getPixmap(),fo->getName(),this);
1193 a->setCheckable(true);
1194 a->setObjectName(fo->getName());
1195 a->setToolTip(tr("Bad","Standardflag"));
1196 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1197 standardFlagsDefault->addFlag (fo);
1199 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1200 // Original omg.png (in KDE emoticons)
1201 fo->setName("smiley-omg");
1202 fo->setGroup("standard-smiley");
1203 a=new QAction (fo->getPixmap(),fo->getName(),this);
1206 a->setCheckable(true);
1207 a->setObjectName(fo->getName());
1208 a->setToolTip(tr("Oh no!","Standardflag"));
1209 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1210 standardFlagsDefault->addFlag (fo);
1212 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1213 fo->setName("clock");
1214 a=new QAction (fo->getPixmap(),fo->getName(),this);
1217 a->setCheckable(true);
1218 a->setObjectName(fo->getName());
1219 a->setToolTip(tr("Time critical","Standardflag"));
1220 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1221 standardFlagsDefault->addFlag (fo);
1223 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1224 fo->setName("phone");
1225 a=new QAction (fo->getPixmap(),fo->getName(),this);
1228 a->setCheckable(true);
1229 a->setObjectName(fo->getName());
1230 a->setToolTip(tr("Call...","Standardflag"));
1231 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1232 standardFlagsDefault->addFlag (fo);
1234 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1235 fo->setName("lamp");
1236 a=new QAction (fo->getPixmap(),fo->getName(),this);
1239 a->setCheckable(true);
1240 a->setObjectName(fo->getName());
1241 a->setToolTip(tr("Idea!","Standardflag"));
1242 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1243 standardFlagsDefault->addFlag (fo);
1245 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1246 fo->setName("arrow-up");
1247 fo->setGroup("standard-arrow");
1248 a=new QAction (fo->getPixmap(),fo->getName(),this);
1251 a->setCheckable(true);
1252 a->setObjectName(fo->getName());
1253 a->setToolTip(tr("Important","Standardflag"));
1254 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1255 standardFlagsDefault->addFlag (fo);
1257 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1258 fo->setName("arrow-down");
1259 fo->setGroup("standard-arrow");
1260 a=new QAction (fo->getPixmap(),fo->getName(),this);
1263 a->setCheckable(true);
1264 a->setObjectName(fo->getName());
1265 a->setToolTip(tr("Unimportant","Standardflag"));
1266 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1267 standardFlagsDefault->addFlag (fo);
1269 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1270 fo->setName("2arrow-up");
1271 fo->setGroup("standard-arrow");
1272 a=new QAction (fo->getPixmap(),fo->getName(),this);
1275 a->setCheckable(true);
1276 a->setObjectName(fo->getName());
1277 a->setToolTip(tr("Very important!","Standardflag"));
1278 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1279 standardFlagsDefault->addFlag (fo);
1281 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1282 fo->setName("2arrow-down");
1283 fo->setGroup("standard-arrow");
1284 a=new QAction (fo->getPixmap(),fo->getName(),this);
1287 a->setCheckable(true);
1288 a->setObjectName(fo->getName());
1289 a->setToolTip(tr("Very unimportant!","Standardflag"));
1290 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1291 standardFlagsDefault->addFlag (fo);
1293 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1294 fo->setName("thumb-up");
1295 fo->setGroup("standard-thumb");
1296 a=new QAction (fo->getPixmap(),fo->getName(),this);
1299 a->setCheckable(true);
1300 a->setObjectName(fo->getName());
1301 a->setToolTip(tr("I like this","Standardflag"));
1302 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1303 standardFlagsDefault->addFlag (fo);
1305 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1306 fo->setName("thumb-down");
1307 fo->setGroup("standard-thumb");
1308 a=new QAction (fo->getPixmap(),fo->getName(),this);
1311 a->setCheckable(true);
1312 a->setObjectName(fo->getName());
1313 a->setToolTip(tr("I do not like this","Standardflag"));
1314 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1315 standardFlagsDefault->addFlag (fo);
1317 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1318 fo->setName("rose");
1319 a=new QAction (fo->getPixmap(),fo->getName(),this);
1322 a->setCheckable(true);
1323 a->setObjectName(fo->getName());
1324 a->setToolTip(tr("Rose","Standardflag"));
1325 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1326 standardFlagsDefault->addFlag (fo);
1328 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1329 fo->setName("heart");
1330 a=new QAction (fo->getPixmap(),fo->getName(),this);
1332 a->setCheckable(true);
1333 a->setObjectName(fo->getName());
1334 a->setToolTip(tr("I just love... ","Standardflag"));
1335 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1336 standardFlagsDefault->addFlag (fo);
1338 fo->load(QPixmap(flagsPath+"flag-present.png"));
1339 fo->setName("present");
1340 a=new QAction (fo->getPixmap(),fo->getName(),this);
1343 a->setCheckable(true);
1344 a->setObjectName(fo->getName());
1345 a->setToolTip(tr("Surprise!","Standardflag"));
1346 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1347 standardFlagsDefault->addFlag (fo);
1349 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1350 fo->setName("flash");
1351 a=new QAction (fo->getPixmap(),fo->getName(),this);
1354 a->setCheckable(true);
1355 a->setObjectName(fo->getName());
1356 a->setToolTip(tr("Dangerous","Standardflag"));
1357 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1358 standardFlagsDefault->addFlag (fo);
1360 fo->load(QPixmap(flagsPath+"flag-info.png"));
1361 // Original: xsldbg_output.png
1362 fo->setName("info");
1363 a=new QAction (fo->getPixmap(),fo->getName(),this);
1366 a->setCheckable(true);
1367 a->setObjectName(fo->getName());
1368 a->setToolTip(tr("Info","Standardflag"));
1369 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1370 standardFlagsDefault->addFlag (fo);
1372 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1373 // Original khelpcenter.png
1374 fo->setName("lifebelt");
1375 a=new QAction (fo->getPixmap(),fo->getName(),this);
1378 a->setCheckable(true);
1379 a->setObjectName(fo->getName());
1380 a->setToolTip(tr("This will help","Standardflag"));
1381 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1382 standardFlagsDefault->addFlag (fo);
1388 void Main::setupSettingsActions()
1390 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1394 a = new QAction( tr( "Set application to open pdf files"), this);
1395 a->setStatusTip ( tr( "Set application to open pdf files"));
1396 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1397 settingsMenu->addAction (a);
1399 a = new QAction( tr( "Set application to open external links"), this);
1400 a->setStatusTip( tr( "Set application to open external links"));
1401 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1402 settingsMenu->addAction (a);
1404 settingsMenu->addSeparator();
1405 a = new QAction( tr( "Edit branch after adding it" ), this );
1406 a->setStatusTip( tr( "Edit branch after adding it" ));
1407 a->setToggleAction(true);
1408 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1409 settingsMenu->addAction (a);
1410 actionSettingsAutoedit=a;
1412 a= new QAction( tr( "Select branch after adding it" ), this );
1413 a->setStatusTip( tr( "Select branch after adding it" ));
1414 a->setToggleAction(true);
1415 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1416 settingsMenu->addAction (a);
1417 actionSettingsAutoselectHeading=a;
1419 a= new QAction(tr( "Select existing heading" ), this);
1420 a->setStatusTip( tr( "Select heading before editing" ));
1421 a->setToggleAction(true);
1422 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1423 settingsMenu->addAction (a);
1424 actionSettingsAutoselectText=a;
1426 a= new QAction(tr( "pasting into new branch" ), this );
1427 a->setStatusTip( tr( "Pasting into new branch" ));
1428 a->setToggleAction(true);
1429 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1430 settingsMenu->addAction (a);
1431 actionSettingsPasteNewHeading=a;
1433 a= new QAction( tr( "Delete key" ), this);
1434 a->setStatusTip( tr( "Delete key for deleting branches" ));
1435 a->setToggleAction(true);
1436 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1437 settingsMenu->addAction (a);
1438 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1439 actionSettingsUseDelKey=a;
1441 a= new QAction( tr( "Exclusive flags" ), this);
1442 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1443 a->setToggleAction(true);
1444 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1445 settingsMenu->addAction (a);
1446 actionSettingsUseFlagGroups=a;
1448 a= new QAction( tr( "Use hide flags" ), this);
1449 a->setStatusTip( tr( "Use hide flag during exports " ));
1450 a->setToggleAction(true);
1451 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1452 settingsMenu->addAction (a);
1453 actionSettingsUseHideExport=a;
1457 void Main::setupTestActions()
1459 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1462 a = new QAction( tr( "test flag" ), this);
1463 a->setStatusTip( tr( "Call test function" ));
1464 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1465 testMenu->addAction (a);
1469 void Main::setupHelpActions()
1471 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1474 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1475 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1476 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1477 helpMenu->addAction (a);
1479 a = new QAction( tr( "About VYM" ), this);
1480 a->setStatusTip( tr( "About VYM")+" "__VYM);
1481 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1482 helpMenu->addAction (a);
1484 a = new QAction( tr( "About QT" ), this);
1485 a->setStatusTip( tr( "Information about QT toolkit" ));
1486 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1487 helpMenu->addAction (a);
1491 void Main::setupContextMenus()
1495 // Context Menu for branch or mapcenter
1496 branchContextMenu =new QMenu (this);
1499 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1500 branchAddContextMenu->addAction (actionEditPaste );
1501 branchAddContextMenu->addAction ( actionEditAddBranch );
1502 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1503 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1504 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1505 branchAddContextMenu->addSeparator();
1506 branchAddContextMenu->addAction ( actionEditLoadImage);
1507 branchAddContextMenu->addSeparator();
1508 branchAddContextMenu->addAction ( actionEditLoadImage);
1509 branchAddContextMenu->addAction ( actionEditImportAdd );
1510 branchAddContextMenu->addAction ( actionEditImportReplace );
1513 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1514 branchRemoveContextMenu->addAction (actionEditCut);
1515 branchRemoveContextMenu->addAction ( actionEditDelete );
1516 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1517 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1520 actionEditSaveBranch->addTo( branchContextMenu );
1522 branchContextMenu->addSeparator();
1523 branchContextMenu->addAction ( actionEditOpenURL );
1524 branchContextMenu->addAction ( actionEditOpenURLTab );
1525 branchContextMenu->addAction ( actionEditURL );
1526 branchContextMenu->addAction ( actionEditHeading2URL );
1527 branchContextMenu->addAction ( actionEditBugzilla2URL );
1528 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1530 branchContextMenu->addAction ( actionEditFATE2URL );
1532 branchContextMenu->addSeparator();
1533 branchContextMenu->addAction ( actionEditOpenVymLink );
1534 branchContextMenu->addAction ( actionEditVymLink );
1535 branchContextMenu->addAction ( actionEditDeleteVymLink );
1537 branchContextMenu->addSeparator();
1538 branchContextMenu->addAction ( actionFormatFrameNone );
1539 branchContextMenu->addAction ( actionFormatFrameRectangle);
1541 branchContextMenu->addSeparator();
1542 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1543 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1544 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1546 // Context Menu for links in a branch menu
1547 // This will be populated "on demand" in MapEditor::updateActions
1548 branchContextMenu->addSeparator();
1549 branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1550 branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1551 connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1552 connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1554 // Context menu for floatimage
1555 floatimageContextMenu =new QMenu (this);
1556 a= new QAction (tr ("Save image"),this);
1557 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1558 floatimageContextMenu->addAction (a);
1560 floatimageContextMenu->addSeparator();
1561 actionEditCopy->addTo( floatimageContextMenu );
1562 actionEditCut->addTo( floatimageContextMenu );
1564 floatimageContextMenu->addSeparator();
1565 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1568 // Context menu for canvas
1569 canvasContextMenu =new QMenu (this);
1570 actionEditMapInfo->addTo( canvasContextMenu );
1571 canvasContextMenu->insertSeparator();
1572 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1573 canvasContextMenu->insertSeparator();
1574 actionFormatLinkColorHint->addTo( canvasContextMenu );
1575 actionFormatLinkColor->addTo( canvasContextMenu );
1576 actionFormatBackColor->addTo( canvasContextMenu );
1578 // Menu for last opened files
1579 // Read settings initially
1581 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1582 for (int i=1;i<=j;i++)
1584 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1585 if (!s.isEmpty() && j<=maxLastMaps)
1588 setupLastMapsMenu();
1589 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1592 void Main::setupLastMapsMenu()
1594 // Remove double entries
1595 QStringList::Iterator it=lastMaps.begin();
1596 QStringList::Iterator jt;
1597 while (it!=lastMaps.end() )
1601 while (jt!=lastMaps.end() )
1604 jt=lastMaps.remove(jt);
1611 // Limit length of list to maxLastMaps
1612 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1614 // build Menu from lastMaps string list
1615 fileLastMapsMenu->clear();
1616 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1617 fileLastMapsMenu->addAction (*it );
1620 void Main::hideEvent (QHideEvent * )
1622 if (!textEditor->isMinimized() ) textEditor->hide();
1625 void Main::showEvent (QShowEvent * )
1627 if (textEditor->showWithMain()) textEditor->showNormal();
1630 bool Main::reallyWriteDirectory(const QString &dir)
1632 QStringList eList = QDir(dir).entryList();
1633 if (eList.first() ==".") eList.pop_front(); // remove "."
1634 if (eList.first() =="..") eList.pop_front(); // remove "."
1635 if (!eList.isEmpty())
1637 QMessageBox mb( __VYM,
1638 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1639 QMessageBox::Warning,
1641 QMessageBox::Cancel | QMessageBox::Default,
1642 QMessageBox::QMessageBox::NoButton );
1644 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1645 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1648 case QMessageBox::Yes:
1651 case QMessageBox::Cancel:
1659 QString Main::browseDirectory (const QString &caption)
1661 Q3FileDialog fd(this,caption);
1662 fd.setMode (Q3FileDialog::DirectoryOnly);
1663 fd.setCaption(__VYM " - "+caption);
1666 if ( fd.exec() == QDialog::Accepted )
1667 return fd.selectedFile();
1672 MapEditor* Main::currentMapEditor() const
1674 if ( tabWidget->currentPage() &&
1675 tabWidget->currentPage()->inherits( "MapEditor" ) )
1676 return (MapEditor*)tabWidget->currentPage();
1680 //TODO not used now, maybe use this for overview window later
1681 void Main::newView()
1683 // Open a new view... have it delete when closed.
1684 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1685 qApp->setMainWidget(m);
1687 qApp->setMainWidget(0);
1690 void Main::editorChanged(QWidget *)
1692 // Unselect all possibly selected objects
1693 // (Important to update note editor)
1696 for (i=0;i<=tabWidget->count() -1;i++)
1699 me=(MapEditor*)tabWidget->page(i);
1702 currentMapEditor()->reselect();
1704 // Update actions to in menus and toolbars according to editor
1705 currentMapEditor()->updateActions();
1708 void Main::fileNew()
1710 QString fn="unnamed";
1711 MapEditor* medit = new MapEditor ( NULL,true);
1712 tabWidget->addTab (medit,fn);
1713 tabWidget->showPage(medit);
1714 medit->viewport()->setFocus();
1715 // For the very first map we do not have flagrows yet...
1716 medit->select("mc:");
1719 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1721 ErrorCode err=success;
1723 // fn is usually the archive, mapfile the file after uncompressing
1726 // Make fn absolute (needed for unzip)
1727 fn=QDir (fn).absPath();
1733 // Check, if map is already loaded
1735 while (i<=tabWidget->count() -1)
1737 me=(MapEditor*)tabWidget->page(i);
1738 if (me->getFilePath() == fn)
1740 // Already there, ask for confirmation
1741 QMessageBox mb( __VYM,
1742 tr("The map %1\nis already opened."
1743 "Opening the same map in multiple editors may lead \n"
1744 "to confusion when finishing working with vym."
1745 "Do you want to").arg(fn),
1746 QMessageBox::Warning,
1747 QMessageBox::Yes | QMessageBox::Default,
1748 QMessageBox::Cancel | QMessageBox::Escape,
1749 QMessageBox::NoButton);
1750 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1751 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1754 case QMessageBox::Yes:
1756 i=tabWidget->count();
1758 case QMessageBox::Cancel:
1770 if ( !fn.isEmpty() )
1772 me = currentMapEditor();
1773 int tabIndex=tabWidget->currentPageIndex();
1774 // Check first, if mapeditor exists
1775 // If it is not default AND we want a new map,
1776 // create a new mapeditor in a new tab
1777 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1779 me= new MapEditor ( NULL,true);
1780 tabWidget->addTab (me,fn);
1781 tabIndex=tabWidget->indexOf (me);
1782 tabWidget->setCurrentPage (tabIndex);
1785 // Check, if file exists (important for creating new files
1786 // from command line
1787 if (!QFile(fn).exists() )
1789 QMessageBox mb( __VYM,
1790 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1791 QMessageBox::Question,
1793 QMessageBox::Cancel | QMessageBox::Default,
1794 QMessageBox::NoButton );
1796 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1797 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1800 case QMessageBox::Yes:
1802 currentMapEditor()->setFilePath(fn);
1803 tabWidget->setTabLabel (currentMapEditor(),
1804 currentMapEditor()->getFileName() );
1805 statusBar()->message( "Created " + fn , statusbarTime );
1808 case QMessageBox::Cancel:
1809 // don't create new map
1810 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1817 //tabWidget->currentPage() won't be NULL here, because of above...
1818 tabWidget->showPage(me);
1819 me->viewport()->setFocus();
1821 // Create temporary directory for packing
1822 char tmpdir1[]="/tmp/vym-XXXXXX";
1823 QString tmpMapDir=mkdtemp(tmpdir1);
1825 // Try to unzip file
1826 err=unzipDir (tmpMapDir,fn);
1830 me->setZipped(false);
1833 me->setZipped(true);
1835 // Look for mapname.xml
1836 mapfile= fn.left(fn.findRev(".",-1,true));
1837 mapfile=mapfile.section( '/', -1 );
1838 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1839 if (!file.exists() )
1841 // mapname.xml does not exist, well,
1842 // maybe some renamed the mapname.vym file...
1843 // Try to find any .xml in the toplevel
1844 // directory of the .vym file
1845 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1846 if (flist.count()==1)
1848 // Only one entry, take this one
1849 mapfile=tmpMapDir + "/"+flist.first();
1852 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1853 *it=tmpMapDir + "/" + *it;
1854 // TODO Multiple entries, load all (but only the first one into this ME)
1855 //mainWindow->fileLoadFromTmp (flist);
1856 //returnCode=1; // Silently forget this attempt to load
1857 qWarning ("MainWindow::load (fn) multimap found...");
1860 if (flist.isEmpty() )
1862 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1863 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1866 } //file doesn't exist
1868 mapfile=file.name();
1873 // Save existing filename in case we import
1874 QString fn_org=me->getFilePath();
1876 // Finally load map into mapEditor
1877 me->setFilePath (mapfile,fn);
1878 err=me->load(mapfile,lmode);
1880 // Restore old (maybe empty) filepath, if this is an import
1882 me->setFilePath (fn_org);
1885 // Finally check for errors and go home
1888 if (lmode==NewMap) fileCloseMap();
1889 statusBar()->message( "Could not load " + fn, statusbarTime );
1894 me->setFilePath (fn);
1895 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1896 if (fn.left(9)!="/tmp/vym-")
1898 // Only append to lastMaps if not loaded from a tmpDir
1899 // e.g. imported bookmarks are in a tmpDir
1900 lastMaps.prepend(me->getFilePath() );
1901 setupLastMapsMenu();
1903 actionFilePrint->setEnabled (true);
1905 statusBar()->message( "Loaded " + fn, statusbarTime );
1909 removeDir (QDir(tmpMapDir));
1915 void Main::fileLoad(const LoadMode &lmode)
1917 Q3FileDialog *fd=new Q3FileDialog( this);
1918 fd->setDir (lastFileDir);
1919 fd->setMode (Q3FileDialog::ExistingFiles);
1920 fd->addFilter ("XML (*.xml)");
1921 fd->addFilter ("VYM map (*.vym *.vyp)");
1925 fd->setCaption(tr("Load vym map"));
1928 fd->setCaption(tr("Import: Add vym map to selection"));
1931 fd->setCaption(tr("Import: Replace selection with vym map"));
1937 if ( fd->exec() == QDialog::Accepted )
1939 lastFileDir=fd->dirPath();
1940 QStringList flist = fd->selectedFiles();
1941 QStringList::Iterator it = flist.begin();
1942 while( it != flist.end() )
1945 fileLoad(*it, lmode);
1952 void Main::fileLoad()
1957 void Main::fileLoadLast(QAction *a)
1959 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1962 void Main::fileSave(const SaveMode &savemode)
1964 // tmp dir for zipping
1968 ErrorCode err=success;
1970 QString safeFilePath;
1972 bool saveZipped=currentMapEditor()->saveZipped();
1974 MapEditor * me=currentMapEditor();
1977 QString fn=me->getFilePath();
1978 // filename=unnamed, filepath="" in constructor...
1979 if ( !fn.isEmpty() )
1981 // We have a filepath, go on saving
1982 // First remove existing file, we
1983 // don't want to add to old zip archives
1987 QMessageBox::warning( 0, tr( "Save Error" ),
1988 fn+ tr("\ncould not be removed before saving"));
1990 // Look, if we should zip the data:
1993 QMessageBox mb( __VYM,
1994 tr("The map %1\ndid not use the compressed "
1995 "vym file format.\nWriting it uncompressed will also write images \n"
1996 "and flags and thus may overwrite files in the "
1997 "given directory\n\nDo you want to write the map").arg(fn),
1998 QMessageBox::Warning,
1999 QMessageBox::Yes | QMessageBox::Default,
2001 QMessageBox::Cancel | QMessageBox::Escape);
2002 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2003 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2004 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2007 case QMessageBox::Yes:
2008 // save compressed (default file format)
2011 case QMessageBox::No:
2012 // save uncompressed
2015 case QMessageBox::Cancel:
2024 char tmpdir1[]="/tmp/vym-XXXXXX";
2025 tmpMapDir=mkdtemp(tmpdir1);
2027 safeFilePath=me->getFilePath();
2028 me->setFilePath (tmpMapDir+"/"+
2029 me->getMapName()+ ".xml",
2031 me->save (savemode);
2032 me->setFilePath (safeFilePath);
2034 zipDir (tmpMapDir,fn);
2039 safeFilePath=me->getFilePath();
2040 me->setFilePath (fn, safeFilePath);
2041 me->save (savemode);
2042 me->setFilePath (safeFilePath);
2044 } // filepath available
2047 // We have no filepath yet,
2048 // call fileSaveAs() now, this will call fileSave()
2050 fileSaveAs(savemode);
2054 if (saveZipped && !tmpMapDir.isEmpty())
2056 removeDir (QDir(tmpMapDir));
2060 statusBar()->message(
2061 tr("Saved %1").arg(me->getFilePath()),
2063 lastMaps.prepend(me->getFilePath() );
2064 setupLastMapsMenu();
2066 statusBar()->message(
2067 tr("Couldn't save ").arg(me->getFilePath()),
2071 void Main::fileSave()
2073 fileSave (CompleteMap);
2076 void Main::fileSaveAs(const SaveMode& savemode)
2080 if (currentMapEditor())
2082 if (savemode==CompleteMap)
2083 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2085 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2086 if ( !fn.isEmpty() )
2088 // Check for existing file
2089 if (QFile (fn).exists())
2091 QMessageBox mb( __VYM,
2092 tr("The file %1\nexists already. Do you want to").arg(fn),
2093 QMessageBox::Warning,
2094 QMessageBox::Yes | QMessageBox::Default,
2095 QMessageBox::Cancel | QMessageBox::Escape,
2096 QMessageBox::NoButton);
2097 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2098 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2101 case QMessageBox::Yes:
2104 case QMessageBox::Cancel:
2111 // New file, add extension to filename, if missing
2112 // This is always .vym or .vyp, depending on savemode
2113 if (savemode==CompleteMap)
2115 if (!fn.contains (".vym") && !fn.contains (".xml"))
2119 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2128 currentMapEditor()->setFilePath(fn);
2132 if (savemode==CompleteMap)
2133 tabWidget->setTabLabel (currentMapEditor(),
2134 currentMapEditor()->getFileName() );
2140 void Main::fileSaveAs()
2142 fileSaveAs (CompleteMap);
2145 void Main::fileImportKDEBookmarks()
2147 ImportKDEBookmarks im;
2149 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2150 currentMapEditor()->setFilePath ("");
2153 void Main::fileImportFirefoxBookmarks()
2155 Q3FileDialog *fd=new Q3FileDialog( this);
2156 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2157 fd->setMode (Q3FileDialog::ExistingFiles);
2158 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2159 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2162 if ( fd->exec() == QDialog::Accepted )
2164 ImportFirefoxBookmarks im;
2165 QStringList flist = fd->selectedFiles();
2166 QStringList::Iterator it = flist.begin();
2167 while( it != flist.end() )
2170 if (im.transform() &&
2171 success==fileLoad (im.getTransformedFile(),NewMap) &&
2172 currentMapEditor() )
2173 currentMapEditor()->setFilePath ("");
2180 void Main::fileImportMM()
2184 Q3FileDialog *fd=new Q3FileDialog( this);
2185 fd->setDir (lastFileDir);
2186 fd->setMode (Q3FileDialog::ExistingFiles);
2187 fd->addFilter ("Mind Manager (*.mmap)");
2188 fd->setCaption(tr("Import")+" "+"Mind Manager");
2191 if ( fd->exec() == QDialog::Accepted )
2193 lastFileDir=fd->dirPath();
2194 QStringList flist = fd->selectedFiles();
2195 QStringList::Iterator it = flist.begin();
2196 while( it != flist.end() )
2199 if (im.transform() &&
2200 success==fileLoad (im.getTransformedFile(),NewMap) &&
2201 currentMapEditor() )
2202 currentMapEditor()->setFilePath ("");
2211 void Main::fileImportDir()
2213 if (currentMapEditor())
2214 currentMapEditor()->importDir();
2217 void Main::fileExportXML()
2219 if (currentMapEditor())
2221 QString dir=browseDirectory(tr("Export XML to directory"));
2222 if (dir !="" && reallyWriteDirectory(dir) )
2223 currentMapEditor()->exportXML(dir);
2228 void Main::fileExportXHTML()
2230 MapEditor *me=currentMapEditor();
2234 ExportXHTMLDialog dia(this);
2235 dia.setFilePath (me->getFilePath() );
2236 dia.setMapName (me->getMapName() );
2239 if (dia.exec()==QDialog::Accepted)
2241 QString dir=dia.getDir();
2242 // Check, if warnings should be used before overwriting
2243 // the output directory
2246 ok=reallyWriteDirectory(dir);
2252 me->exportXML (dia.getDir() );
2253 dia.doExport(me->getMapName() );
2254 if (dia.hasChanged())
2261 void Main::fileExportImage()
2263 MapEditor *me=currentMapEditor();
2267 QFileDialog *fd=new QFileDialog (this);
2268 fd->setCaption (tr("Export map as image"));
2269 fd->setFileMode(QFileDialog::AnyFile);
2270 fd->setFilters (imageIO.getFilters() );
2271 fd->setDirectory (lastImageDir);
2274 fl=fd->selectedFiles();
2275 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2276 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2281 void Main::fileExportASCII()
2283 MapEditor *me=currentMapEditor();
2287 ex.setMapCenter(me->getMapCenter());
2288 ex.addFilter ("TXT (*.txt)");
2289 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2290 if (ex.execDialog() )
2292 me->setExportMode(true);
2294 me->setExportMode(false);
2299 void Main::fileExportLaTeX()
2301 MapEditor *me=currentMapEditor();
2305 ex.setMapCenter(me->getMapCenter());
2306 ex.addFilter ("Tex (*.tex)");
2307 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2308 if (ex.execDialog() )
2310 me->setExportMode(true);
2312 me->setExportMode(false);
2317 void Main::fileExportKDEBookmarks()
2319 ExportKDEBookmarks ex;
2320 MapEditor *me=currentMapEditor();
2323 ex.setMapCenter (me->getMapCenter() );
2328 void Main::fileExportTaskjuggler()
2330 ExportTaskjuggler ex;
2331 MapEditor *me=currentMapEditor();
2334 ex.setMapCenter (me->getMapCenter() );
2335 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2336 ex.addFilter ("Taskjuggler (*.tjp)");
2337 if (ex.execDialog() )
2339 me->setExportMode(true);
2341 me->setExportMode(false);
2346 void Main::fileExportOOPresentation()
2348 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2349 // TODO add preview in dialog
2350 //ImagePreview *p =new ImagePreview (fd);
2351 //fd->setContentsPreviewEnabled( TRUE );
2352 //fd->setContentsPreview( p, p );
2353 //fd->setPreviewMode( QFileDialog::Contents );
2354 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2355 fd->setDir (QDir().current());
2356 if (fd->foundConfig())
2360 if ( fd->exec() == QDialog::Accepted )
2362 QString fn=fd->selectedFile();
2363 //lastImageDir=fn.left(fn.findRev ("/"));
2364 if (currentMapEditor())
2365 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2369 QMessageBox::warning(0,
2371 tr("Couldn't find configuration for export to Open Office\n"));
2375 void Main::fileCloseMap()
2377 if (currentMapEditor())
2379 if (currentMapEditor()->hasChanged())
2381 QMessageBox mb( __VYM,
2382 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2383 QMessageBox::Warning,
2384 QMessageBox::Yes | QMessageBox::Default,
2386 QMessageBox::Cancel | QMessageBox::Escape );
2387 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2388 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2391 case QMessageBox::Yes:
2393 fileSave(CompleteMap);
2395 case QMessageBox::No:
2396 // close without saving
2398 case QMessageBox::Cancel:
2403 currentMapEditor()->closeMap();
2404 tabWidget->removePage(currentMapEditor());
2405 if (tabWidget->count()==0)
2406 actionFilePrint->setEnabled (false);
2410 void Main::filePrint()
2412 if (currentMapEditor())
2413 currentMapEditor()->print();
2416 void Main::fileExitVYM()
2418 // Check if one or more editors have changed
2421 for (i=0;i<=tabWidget->count() -1;i++)
2424 me=(MapEditor*)tabWidget->page(i);
2426 // If something changed, ask what to do
2427 if (me->isUnsaved())
2429 tabWidget->setCurrentPage(i);
2430 QMessageBox mb( __VYM,
2431 tr("This map is not saved yet. Do you want to"),
2432 QMessageBox::Warning,
2433 QMessageBox::Yes | QMessageBox::Default,
2435 QMessageBox::Cancel | QMessageBox::Escape );
2436 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2437 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2439 mb.setActiveWindow();
2440 switch( mb.exec() ) {
2441 case QMessageBox::Yes:
2442 // save (the changed editors) and exit
2443 fileSave(CompleteMap);
2445 case QMessageBox::No:
2446 // exit without saving
2448 case QMessageBox::Cancel:
2449 // don't save and don't exit
2453 } // loop over all MEs
2457 void Main::editUndo()
2459 if (currentMapEditor())
2460 currentMapEditor()->undo();
2463 void Main::editRedo()
2465 if (currentMapEditor())
2466 currentMapEditor()->redo();
2469 void Main::editCopy()
2471 if (currentMapEditor())
2472 currentMapEditor()->copy();
2475 void Main::editPaste()
2477 if (currentMapEditor())
2478 currentMapEditor()->paste();
2481 void Main::editCut()
2483 if (currentMapEditor())
2484 currentMapEditor()->cut();
2487 void Main::editOpenFindWindow()
2489 findWindow->popup();
2490 findWindow->raise();
2491 findWindow->setActiveWindow();
2494 void Main::editFind(QString s)
2497 BranchObj *bo=currentMapEditor()->findText(s, cs);
2500 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2503 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2504 tr("No matches found for \"%1\"").arg(s));
2508 void Main::editFindChanged()
2509 { // Notify editor, to abort the current find process
2510 currentMapEditor()->findReset();
2513 void Main::editOpenURL()
2516 if (currentMapEditor())
2518 QString url=currentMapEditor()->getURL();
2519 if (url=="") return;
2520 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2521 procBrowser = new Q3Process( this );
2523 procBrowser->addArgument( browser);
2524 procBrowser->addArgument( url);
2526 if ( !procBrowser->start() )
2528 // try to set path to browser
2529 QMessageBox::warning(0,
2531 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2532 tr("Please use Settings->")+tr("Set application to open an URL"));
2537 void Main::editOpenURLTab()
2539 if (currentMapEditor())
2541 QString url=currentMapEditor()->getURL();
2542 if (url=="") return;
2543 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2544 if (procBrowser && procBrowser->isRunning())
2546 if (browser.contains("konqueror"))
2548 // Try to open new tab in existing konqueror started previously by vym
2549 Q3Process *p=new Q3Process (this);
2550 p->addArgument ("dcop");
2551 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2552 p->addArgument ("konqueror-mainwindow#1");
2553 p->addArgument ("newTab");
2554 p->addArgument (url);
2556 // try to set browser
2557 QMessageBox::warning(0,
2559 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2561 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2563 // Try to open new tab in firefox
2564 Q3Process *p=new Q3Process (this);
2565 p->addArgument (browser);
2566 p->addArgument ("-remote");
2567 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2569 // try to set browser
2570 QMessageBox::warning(0,
2572 tr("Couldn't start %1 to open a new tab").arg(browser));
2581 void Main::editURL()
2583 if (currentMapEditor())
2584 currentMapEditor()->editURL();
2587 void Main::editHeading2URL()
2589 if (currentMapEditor())
2590 currentMapEditor()->editHeading2URL();
2593 void Main::editBugzilla2URL()
2595 if (currentMapEditor())
2596 currentMapEditor()->editBugzilla2URL();
2599 void Main::editFATE2URL()
2601 if (currentMapEditor())
2602 currentMapEditor()->editFATE2URL();
2605 void Main::editOpenVymLink()
2607 // Get current path to map
2608 QString currentVymLink;
2609 if (currentMapEditor())
2611 currentVymLink=currentMapEditor()->getVymLink();
2612 // compare path with already loaded maps
2616 for (i=0;i<=tabWidget->count() -1;i++)
2618 me=(MapEditor*)tabWidget->page(i);
2619 if (currentVymLink==me->getFilePath() )
2628 if (!QFile(currentVymLink).exists() )
2629 QMessageBox::critical( 0, tr( "Critical Error" ),
2630 tr("Couldn't open map %1").arg(currentVymLink));
2633 fileLoad (currentVymLink, NewMap);
2634 tabWidget->setCurrentPage (tabWidget->count()-1);
2637 // Go to tab containing the map
2638 tabWidget->setCurrentPage (index);
2642 void Main::editVymLink()
2644 if (currentMapEditor())
2645 currentMapEditor()->editVymLink();
2648 void Main::editDeleteVymLink()
2650 if (currentMapEditor())
2651 currentMapEditor()->deleteVymLink();
2654 void Main::editToggleHideExport()
2656 if (currentMapEditor())
2657 currentMapEditor()->toggleHideExport();
2660 void Main::editMapInfo()
2662 if (currentMapEditor())
2663 currentMapEditor()->editMapInfo();
2666 void Main::editMoveUp()
2668 if (currentMapEditor())
2669 currentMapEditor()->moveBranchUp();
2672 void Main::editMoveDown()
2674 if (currentMapEditor())
2675 currentMapEditor()->moveBranchDown();
2678 void Main::editToggleScroll()
2680 if (currentMapEditor())
2682 currentMapEditor()->toggleScroll();
2686 void Main::editUnScrollAll()
2688 if (currentMapEditor())
2690 currentMapEditor()->unScrollAll();
2694 void Main::editHeading()
2696 if (currentMapEditor())
2697 currentMapEditor()->editHeading();
2700 void Main::editNewBranch()
2702 if (currentMapEditor())
2703 currentMapEditor()->addNewBranch(0);
2706 void Main::editNewBranchHere()
2708 if (currentMapEditor())
2709 currentMapEditor()->addNewBranchHere();
2712 void Main::editNewBranchAbove()
2714 if (currentMapEditor())
2715 currentMapEditor()->addNewBranch(-1);
2718 void Main::editNewBranchBelow()
2720 if (currentMapEditor())
2721 currentMapEditor()->addNewBranch(1);
2724 void Main::editImportAdd()
2726 fileLoad (ImportAdd);
2729 void Main::editImportReplace()
2731 fileLoad (ImportReplace);
2734 void Main::editSaveBranch()
2736 fileSaveAs (PartOfMap);
2739 void Main::editRemoveBranchKeepChilds()
2741 if (currentMapEditor())
2742 currentMapEditor()->removeBranchKeepChilds();
2745 void Main::editRemoveChilds()
2747 if (currentMapEditor())
2748 currentMapEditor()->removeChilds();
2751 void Main::editDeleteSelection()
2753 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2754 currentMapEditor()->deleteSelection();
2757 void Main::editUpperBranch()
2759 if (currentMapEditor())
2760 currentMapEditor()->selectUpperBranch();
2763 void Main::editLowerBranch()
2765 if (currentMapEditor())
2766 currentMapEditor()->selectLowerBranch();
2769 void Main::editLeftBranch()
2771 if (currentMapEditor())
2772 currentMapEditor()->selectLeftBranch();
2775 void Main::editRightBranch()
2777 if (currentMapEditor())
2778 currentMapEditor()->selectRightBranch();
2781 void Main::editFirstBranch()
2783 if (currentMapEditor())
2784 currentMapEditor()->selectFirstBranch();
2787 void Main::editLastBranch()
2789 if (currentMapEditor())
2790 currentMapEditor()->selectLastBranch();
2793 void Main::editLoadImage()
2795 if (currentMapEditor())
2796 currentMapEditor()->loadFloatImage();
2799 void Main::editSaveImage()
2801 if (currentMapEditor())
2802 currentMapEditor()->saveFloatImage();
2805 void Main::editFollowXLink(QAction *a)
2808 if (currentMapEditor())
2809 currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
2812 void Main::editEditXLink(QAction *a)
2814 if (currentMapEditor())
2815 currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
2818 void Main::formatSelectColor()
2820 if (currentMapEditor())
2822 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2823 if ( !col.isValid() ) return;
2824 currentMapEditor()->setColor( col );
2825 colorChanged( col );
2829 void Main::formatPickColor()
2831 if (currentMapEditor())
2832 colorChanged( currentMapEditor()->pickColor() );
2835 void Main::colorChanged(QColor c)
2837 QPixmap pix( 16, 16 );
2839 actionFormatColor->setIconSet( pix );
2842 void Main::formatColorItem()
2844 if (currentMapEditor())
2845 currentMapEditor()->colorItem();
2848 void Main::formatColorBranch()
2850 if (currentMapEditor())
2851 currentMapEditor()->colorBranch();
2854 void Main::formatLinkStyleLine()
2856 if (currentMapEditor())
2857 currentMapEditor()->setLinkStyle(StyleLine);
2860 void Main::formatLinkStyleParabel()
2862 if (currentMapEditor())
2863 currentMapEditor()->setLinkStyle(StyleParabel);
2866 void Main::formatLinkStylePolyLine()
2868 if (currentMapEditor())
2869 currentMapEditor()->setLinkStyle(StylePolyLine);
2872 void Main::formatLinkStylePolyParabel()
2874 if (currentMapEditor())
2875 currentMapEditor()->setLinkStyle(StylePolyParabel);
2878 void Main::formatSelectBackColor()
2880 if (currentMapEditor())
2881 currentMapEditor()->selectBackgroundColor();
2884 void Main::formatSelectLinkColor()
2886 if (currentMapEditor())
2887 currentMapEditor()->selectLinkColor();
2890 void Main::formatToggleLinkColorHint()
2892 currentMapEditor()->toggleLinkColorHint();
2895 void Main::formatFrameNone()
2897 if (currentMapEditor())
2898 currentMapEditor()->setFrame(NoFrame);
2901 void Main::formatFrameRectangle()
2903 if (currentMapEditor())
2904 currentMapEditor()->setFrame(Rectangle);
2907 void Main::formatIncludeImagesVer()
2909 if (currentMapEditor())
2910 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2913 void Main::formatIncludeImagesHor()
2915 if (currentMapEditor())
2916 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2919 void Main::formatHideLinkUnselected()
2921 if (currentMapEditor())
2922 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2925 void Main::viewZoomReset()
2927 if (currentMapEditor())
2931 currentMapEditor()->setWorldMatrix( m );
2932 currentMapEditor()->setViewCenter();
2933 currentMapEditor()->adjustCanvasSize();
2937 void Main::viewZoomIn()
2939 if (currentMapEditor())
2941 QMatrix m = currentMapEditor()->worldMatrix();
2942 m.scale( 1.25, 1.25 );
2943 currentMapEditor()->setWorldMatrix( m );
2944 currentMapEditor()->setViewCenter();
2945 currentMapEditor()->adjustCanvasSize();
2949 void Main::viewZoomOut()
2951 if (currentMapEditor())
2953 QMatrix m = currentMapEditor()->worldMatrix();
2954 m.scale( 0.8, 0.8 );
2955 currentMapEditor()->setWorldMatrix( m );
2956 currentMapEditor()->setViewCenter();
2957 currentMapEditor()->adjustCanvasSize();
2961 void Main::modModeColor()
2965 void Main::modModeLink()
2969 bool Main::settingsPDF()
2971 // Default browser is set in constructor
2973 QString text = QInputDialog::getText(
2974 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2975 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2977 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2982 bool Main::settingsURL()
2984 // Default browser is set in constructor
2986 QString text = QInputDialog::getText(
2987 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2988 settings.readEntry("/vym/mainwindow/readerURL")
2991 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2995 void Main::settingsToggleDelKey()
2997 if (actionSettingsUseDelKey->isOn())
2999 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3002 actionEditDelete->setAccel (QKeySequence (""));
3006 void Main::windowToggleNoteEditor()
3008 if (textEditor->showWithMain() )
3009 windowHideNoteEditor();
3011 windowShowNoteEditor();
3014 void Main::windowToggleHistory()
3016 if (currentMapEditor())
3017 currentMapEditor()->toggleHistoryWindow();
3020 void Main::updateNoteFlag()
3022 if (currentMapEditor())
3023 currentMapEditor()->updateNoteFlag();
3026 void Main::windowShowNoteEditor()
3028 textEditor->setShowWithMain(true);
3030 actionViewToggleNoteEditor->setOn (true);
3033 void Main::windowHideNoteEditor()
3035 textEditor->setShowWithMain(false);
3037 actionViewToggleNoteEditor->setOn (false);
3040 void Main::windowNextEditor()
3042 if (tabWidget->currentPageIndex() < tabWidget->count())
3043 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3046 void Main::windowPreviousEditor()
3048 if (tabWidget->currentPageIndex() >0)
3049 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3052 void Main::standardFlagChanged()
3054 currentMapEditor()->toggleStandardFlag(sender()->name());
3057 void Main::testFunction()
3059 currentMapEditor()->testFunction();
3062 void Main::helpDoc()
3065 #if defined(Q_OS_MACX)
3066 docpath="./vym.app/Contents/vym.pdf";
3068 // default path in SUSE LINUX
3069 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3072 if (!QFile (docpath).exists() )
3074 // relative path for easy testing in tarball
3075 docpath="doc/vym.pdf";
3076 if (!QFile (docpath).exists() )
3078 // relative path for testing while still writing vym.tex
3079 docpath="doc/tex/vym.pdf";
3080 if (!QFile (docpath).exists() )
3082 // Try yet another one for Knoppix
3083 docpath="/usr/share/doc/packages/vym/vym.pdf";
3084 if (!QFile (docpath).exists() )
3086 QMessageBox::critical(0,
3087 tr("Critcal error"),
3088 tr("Couldn't find the documentation\n"
3089 "vym.pdf in various places."));
3096 Process *pdfProc = new Process();
3097 pdfProc->clearArguments();
3098 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
3099 pdfProc->addArgument( docpath);
3101 if ( !pdfProc->start() )
3104 QMessageBox::warning(0,
3106 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3107 tr("Please use Settings->")+tr("Set application to open PDF files"));
3114 void Main::helpAbout()
3117 ad.setName ("aboutwindow");
3118 ad.setMinimumSize(500,500);
3119 ad.resize (QSize (500,500));
3123 void Main::helpAboutQT()
3125 QMessageBox::aboutQt( this, "Qt Application Example" );