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* saveImageFormatMenu;
135 extern QMenu* canvasContextMenu;
136 extern QMenu* fileLastMapsMenu;
137 extern QMenu* fileImportMenu;
138 extern QMenu* fileExportMenu;
141 extern Settings settings;
142 extern Options options;
143 extern ImageIO imageIO;
145 extern QDir vymBaseDir;
146 extern QDir lastImageDir;
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" ));
671 a->setEnabled (false);
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 );
678 a->setEnabled (false);
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->setShortcutContext (Qt::WindowShortcut);
686 a->setEnabled (false);
687 actionListBranches.append(a);
688 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
691 a = new QAction( tr( "Use heading for URL" ), this);
692 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
693 a->setEnabled (false);
694 actionListBranches.append(a);
695 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
696 actionEditHeading2URL=a;
698 a = new QAction(tr( "Create URL to Bugzilla" ), this);
699 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
700 a->setEnabled (false);
701 actionListBranches.append(a);
702 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
703 actionEditBugzilla2URL=a;
705 a = new QAction(tr( "Create URL to FATE" ), this);
706 a->setStatusTip ( tr( "Create URL to FATE" ));
707 a->setEnabled (false);
708 actionListBranches.append(a);
709 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
710 actionEditFATE2URL=a;
712 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
713 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
715 a->setEnabled (false);
716 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
717 actionEditOpenVymLink=a;
719 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
720 a->setEnabled (false);
721 a->setStatusTip ( tr( "Edit link to another vym map" ));
722 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
723 actionListBranches.append(a);
726 a = new QAction(tr( "Delete vym link" ),this);
727 a->setStatusTip ( tr( "Delete link to another vym map" ));
728 a->setEnabled (false);
729 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
730 actionEditDeleteVymLink=a;
732 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
733 a->setStatusTip ( tr( "Hide object in exports" ) );
734 a->setShortcut (Qt::Key_H );
735 a->setToggleAction(true);
737 a->setEnabled (false);
738 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
739 actionEditToggleHideExport=a;
741 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
742 a->setStatusTip ( tr( "Edit Map Info" ));
743 a->setEnabled (true);
744 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
747 editMenu->addSeparator();
749 // Import at selection (adding to selection)
750 a = new QAction( tr( "Add map (insert)" ),this);
751 a->setStatusTip (tr( "Add map at selection" ));
752 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
753 a->setEnabled (false);
754 actionListBranches.append(a);
755 actionEditImportAdd=a;
757 // Import at selection (replacing selection)
758 a = new QAction( tr( "Add map (replace)" ), this);
759 a->setStatusTip (tr( "Replace selection with map" ));
760 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
761 a->setEnabled (false);
762 actionListBranches.append(a);
763 actionEditImportReplace=a;
766 a = new QAction( tr( "Save selection" ), this);
767 a->setStatusTip (tr( "Save selection" ));
768 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
769 a->setEnabled (false);
770 actionListBranches.append(a);
771 actionEditSaveBranch=a;
773 // Only remove branch, not its childs
774 a = new QAction(tr( "Remove only branch " ), this);
775 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
776 a->setShortcut (Qt::ALT + Qt::Key_Delete );
777 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
778 a->setEnabled (false);
779 actionListBranches.append(a);
780 actionEditRemoveBranchKeepChilds=a;
782 // Only remove childs of a branch
783 a = new QAction( tr( "Remove childs" ), this);
784 a->setStatusTip (tr( "Remove childs of branch" ));
785 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
786 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
787 a->setEnabled (false);
788 actionListBranches.append(a);
789 actionEditRemoveChilds=a;
791 // Shortcuts for navigating with cursor:
792 a = new QAction(tr( "Select upper branch" ), this);
793 a->setStatusTip ( tr( "Select upper branch" ));
794 a->setShortcut (Qt::Key_Up );
795 a->setShortcutContext (Qt::WindowShortcut);
797 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
798 a = new QAction( tr( "Select lower branch" ),this);
799 a->setStatusTip (tr( "Select lower branch" ));
800 a->setShortcut ( Qt::Key_Down );
801 a->setShortcutContext (Qt::WindowShortcut);
803 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
804 a = new QAction(tr( "Select left branch" ), this);
805 a->setStatusTip ( tr( "Select left branch" ));
806 a->setShortcut (Qt::Key_Left );
807 a->setShortcutContext (Qt::WindowShortcut);
809 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
810 a = new QAction( tr( "Select child branch" ), this);
811 a->setStatusTip (tr( "Select right branch" ));
812 a->setShortcut (Qt::Key_Right);
813 a->setShortcutContext (Qt::WindowShortcut);
815 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
816 a = new QAction( tr( "Select first branch" ), this);
817 a->setStatusTip (tr( "Select first branch" ));
818 a->setShortcut (Qt::Key_Home );
819 a->setShortcutContext (Qt::WindowShortcut);
821 a->setEnabled (false);
822 editMenu->addAction (a);
823 actionListBranches.append(a);
824 actionEditSelectFirst=a;
825 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
826 a = new QAction( tr( "Select last branch" ),this);
827 a->setStatusTip (tr( "Select last branch" ));
828 a->setShortcut ( Qt::Key_End );
829 a->setShortcutContext (Qt::WindowShortcut);
831 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
832 a->setEnabled (false);
833 editMenu->addAction (a);
834 actionListBranches.append(a);
835 actionEditSelectLast=a;
837 a = new QAction( tr( "Add Image" )+QString("..."), this);
838 a->setStatusTip (tr( "Add Image" ));
839 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
840 actionEditLoadImage=a;
845 void Main::setupFormatActions()
847 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat"));
849 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
852 pix.fill (Qt::black);
853 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
854 a->setStatusTip ( tr( "Set Color" ));
855 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
857 formatMenu->addAction (a);
859 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
860 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
861 a->setShortcut (Qt::CTRL + Qt::Key_K );
862 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
863 a->setEnabled (false);
865 formatMenu->addAction (a);
866 actionListBranches.append(a);
867 actionFormatPickColor=a;
869 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
870 a->setStatusTip ( tr( "Color branch" ) );
871 a->setShortcut (Qt::CTRL + Qt::Key_I);
872 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
873 a->setEnabled (false);
875 formatMenu->addAction (a);
876 actionListBranches.append(a);
877 actionFormatColorBranch=a;
879 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
880 a->setStatusTip ( tr( "Color Subtree" ));
881 a->setShortcut (Qt::CTRL + Qt::Key_T);
882 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
883 a->setEnabled (false);
884 formatMenu->addAction (a);
886 actionListBranches.append(a);
887 actionFormatColorSubtree=a;
889 formatMenu->addSeparator();
890 actionGroupFormatLinkStyles=new QActionGroup ( this);
891 actionGroupFormatLinkStyles->setExclusive (true);
892 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
893 a->setStatusTip (tr( "Line" ));
894 a->setToggleAction(true);
895 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
896 formatMenu->addAction (a);
897 actionFormatLinkStyleLine=a;
898 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
899 a->setStatusTip (tr( "Line" ));
900 a->setToggleAction(true);
901 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
902 formatMenu->addAction (a);
903 actionFormatLinkStyleParabel=a;
904 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
905 a->setStatusTip (tr( "PolyLine" ));
906 a->setToggleAction(true);
907 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
908 formatMenu->addAction (a);
909 actionFormatLinkStylePolyLine=a;
910 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
911 a->setStatusTip (tr( "PolyParabel" ) );
912 a->setToggleAction(true);
913 a->setChecked (true);
914 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
915 formatMenu->addAction (a);
916 actionFormatLinkStylePolyParabel=a;
918 actionGroupFormatFrameTypes=new QActionGroup ( this);
919 actionGroupFormatFrameTypes->setExclusive (true);
920 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
921 a->setStatusTip (tr("No Frame"));
922 a->setToggleAction(true);
923 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
924 actionFormatFrameNone=a;
925 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
926 a->setStatusTip (tr( "Rectangle" ));
927 a->setToggleAction(true);
928 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
929 actionFormatFrameRectangle=a;
931 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
932 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
933 a->setToggleAction(true);
934 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
935 actionFormatIncludeImagesVer=a;
937 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
938 a->setStatusTip ( tr ("Include left and right position of images into branch"));
939 a->setToggleAction(true);
940 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
941 actionFormatIncludeImagesHor=a;
943 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
944 a->setStatusTip (tr( "Hide link" ));
945 a->setToggleAction(true);
946 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
947 actionFormatHideLinkUnselected=a;
949 formatMenu->addSeparator();
950 a= new QAction( tr( "&Use color of heading for link" ), this);
951 a->setStatusTip (tr( "Use same color for links and headings" ));
952 a->setToggleAction(true);
953 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
954 formatMenu->addAction (a);
955 actionFormatLinkColorHint=a;
957 pix.fill (Qt::white);
958 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
959 a->setStatusTip (tr( "Set Link Color" ));
960 formatMenu->addAction (a);
961 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
962 actionFormatLinkColor=a;
964 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
965 a->setStatusTip (tr( "Set Background Color" ));
966 formatMenu->addAction (a);
967 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
968 actionFormatBackColor=a;
972 void Main::setupViewActions()
974 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
975 tb->setLabel( "View Actions" );
976 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
979 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
980 a->setStatusTip ( tr( "Zoom reset" ) );
981 a->setShortcut (Qt::CTRL + Qt::Key_0 );
983 viewMenu->addAction (a);
984 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
986 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
987 a->setStatusTip (tr( "Zoom in" ));
988 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
990 viewMenu->addAction (a);
991 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
993 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
994 a->setStatusTip (tr( "Zoom out" ));
995 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
997 viewMenu->addAction (a);
998 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
1001 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
1002 a->setStatusTip ( tr( "Show Note Editor" ));
1003 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1004 a->setToggleAction(true);
1005 if (textEditor->showWithMain())
1010 viewMenu->addAction (a);
1011 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
1012 actionViewToggleNoteEditor=a;
1014 a = new QAction( tr( "Show history window" ),this );
1015 a->setStatusTip ( tr( "Show history window" ));
1016 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1017 a->setToggleAction(false);
1018 viewMenu->addAction (a);
1019 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
1020 actionViewToggleHistoryWindow=a;
1022 a = new QAction(tr( "Next Window" ), this);
1023 a->setStatusTip ( tr( "&Next Window" ) );
1024 a->setShortcut (Qt::ALT + Qt::Key_N );
1025 viewMenu->addAction (a);
1026 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
1028 a = new QAction (tr( "Previous Window" ), this );
1029 a->setStatusTip (tr( "&Previous Window" ));
1030 a->setShortcut (Qt::ALT + Qt::Key_P );
1031 viewMenu->addAction (a);
1032 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
1036 void Main::setupModeActions()
1038 //QPopupMenu *menu = new QPopupMenu( this );
1039 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1041 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1043 actionGroupModModes=new QActionGroup ( this);
1044 actionGroupModModes->setExclusive (true);
1045 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1046 a->setShortcut (Qt::Key_J);
1047 a->setStatusTip ( tr( "Use modifier to color branches" ));
1048 a->setToggleAction(true);
1051 actionModModeColor=a;
1053 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1054 a->setShortcut( Qt::Key_K);
1055 a->setStatusTip( tr( "Use modifier to copy" ));
1056 a->setToggleAction(true);
1058 actionModModeCopy=a;
1060 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1061 a->setShortcut (Qt::Key_L);
1062 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1063 a->setToggleAction(true);
1065 actionModModeLink=a;
1069 void Main::setupFlagActions()
1071 // Create System Flags
1072 systemFlagsDefault = new FlagRowObj ();
1073 systemFlagsDefault->setVisibility (false);
1074 systemFlagsDefault->setName ("systemFlagsDef");
1076 FlagObj *fo = new FlagObj ();
1077 fo->load(QPixmap(flagsPath+"flag-note.png"));
1078 fo->setName("note");
1079 fo->setToolTip(tr("Note","Systemflag"));
1080 systemFlagsDefault->addFlag (fo); // makes deep copy
1082 fo->load(QPixmap(flagsPath+"flag-url.png"));
1084 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1085 systemFlagsDefault->addFlag (fo);
1087 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1088 fo->setName("vymLink");
1089 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1090 systemFlagsDefault->addFlag (fo);
1092 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1093 fo->setName("scrolledright");
1094 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1095 systemFlagsDefault->addFlag (fo);
1097 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1098 fo->setName("tmpUnscrolledright");
1099 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1100 systemFlagsDefault->addFlag (fo);
1102 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1103 fo->setName("hideInExport");
1104 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1105 systemFlagsDefault->addFlag (fo);
1107 // Create Standard Flags
1108 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1110 standardFlagsDefault = new FlagRowObj ();
1111 standardFlagsDefault->setVisibility (false);
1112 standardFlagsDefault->setName ("standardFlagsDef");
1113 standardFlagsDefault->setToolBar (tb);
1115 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1116 fo->setName ("exclamationmark");
1117 fo->setGroup("standard-mark");
1118 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1121 a->setCheckable(true);
1122 a->setObjectName(fo->getName());
1123 a->setToolTip(tr("Take care!","Standardflag"));
1124 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1125 standardFlagsDefault->addFlag (fo); // makes deep copy
1127 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1128 fo->setName("questionmark");
1129 fo->setGroup("standard-mark");
1130 a=new QAction (fo->getPixmap(),fo->getName(),this);
1133 a->setCheckable(true);
1134 a->setObjectName(fo->getName());
1135 a->setToolTip(tr("Really?","Standardflag"));
1136 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1137 standardFlagsDefault->addFlag (fo);
1139 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1140 fo->setName("hook-green");
1141 fo->setGroup("standard-hook");
1142 a=new QAction (fo->getPixmap(),fo->getName(),this);
1145 a->setCheckable(true);
1146 a->setObjectName(fo->getName());
1147 a->setToolTip(tr("ok!","Standardflag"));
1148 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1149 standardFlagsDefault->addFlag (fo);
1151 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1152 fo->setName("cross-red");
1153 fo->setGroup("standard-hook");
1154 a=new QAction (fo->getPixmap(),fo->getName(),this);
1157 a->setCheckable(true);
1158 a->setObjectName(fo->getName());
1159 a->setToolTip(tr("Not ok!","Standardflag"));
1160 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1161 standardFlagsDefault->addFlag (fo);
1163 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1164 fo->setName("stopsign");
1165 a=new QAction (fo->getPixmap(),fo->getName(),this);
1168 a->setCheckable(true);
1169 a->setObjectName(fo->getName());
1170 a->setToolTip(tr("This won't work!","Standardflag"));
1171 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1172 standardFlagsDefault->addFlag (fo);
1174 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1175 fo->setName("smiley-good");
1176 fo->setGroup("standard-smiley");
1177 a=new QAction (fo->getPixmap(),fo->getName(),this);
1180 a->setCheckable(true);
1181 a->setObjectName(fo->getName());
1182 a->setToolTip(tr("Good","Standardflag"));
1183 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1184 standardFlagsDefault->addFlag (fo);
1186 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1187 fo->setName("smiley-sad");
1188 fo->setGroup("standard-smiley");
1189 a=new QAction (fo->getPixmap(),fo->getName(),this);
1192 a->setCheckable(true);
1193 a->setObjectName(fo->getName());
1194 a->setToolTip(tr("Bad","Standardflag"));
1195 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1196 standardFlagsDefault->addFlag (fo);
1198 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1199 // Original omg.png (in KDE emoticons)
1200 fo->setName("smiley-omg");
1201 fo->setGroup("standard-smiley");
1202 a=new QAction (fo->getPixmap(),fo->getName(),this);
1205 a->setCheckable(true);
1206 a->setObjectName(fo->getName());
1207 a->setToolTip(tr("Oh no!","Standardflag"));
1208 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1209 standardFlagsDefault->addFlag (fo);
1211 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1212 fo->setName("clock");
1213 a=new QAction (fo->getPixmap(),fo->getName(),this);
1216 a->setCheckable(true);
1217 a->setObjectName(fo->getName());
1218 a->setToolTip(tr("Time critical","Standardflag"));
1219 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1220 standardFlagsDefault->addFlag (fo);
1222 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1223 fo->setName("phone");
1224 a=new QAction (fo->getPixmap(),fo->getName(),this);
1227 a->setCheckable(true);
1228 a->setObjectName(fo->getName());
1229 a->setToolTip(tr("Call...","Standardflag"));
1230 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1231 standardFlagsDefault->addFlag (fo);
1233 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1234 fo->setName("lamp");
1235 a=new QAction (fo->getPixmap(),fo->getName(),this);
1238 a->setCheckable(true);
1239 a->setObjectName(fo->getName());
1240 a->setToolTip(tr("Idea!","Standardflag"));
1241 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1242 standardFlagsDefault->addFlag (fo);
1244 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1245 fo->setName("arrow-up");
1246 fo->setGroup("standard-arrow");
1247 a=new QAction (fo->getPixmap(),fo->getName(),this);
1250 a->setCheckable(true);
1251 a->setObjectName(fo->getName());
1252 a->setToolTip(tr("Important","Standardflag"));
1253 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1254 standardFlagsDefault->addFlag (fo);
1256 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1257 fo->setName("arrow-down");
1258 fo->setGroup("standard-arrow");
1259 a=new QAction (fo->getPixmap(),fo->getName(),this);
1262 a->setCheckable(true);
1263 a->setObjectName(fo->getName());
1264 a->setToolTip(tr("Unimportant","Standardflag"));
1265 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1266 standardFlagsDefault->addFlag (fo);
1268 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1269 fo->setName("2arrow-up");
1270 fo->setGroup("standard-arrow");
1271 a=new QAction (fo->getPixmap(),fo->getName(),this);
1274 a->setCheckable(true);
1275 a->setObjectName(fo->getName());
1276 a->setToolTip(tr("Very important!","Standardflag"));
1277 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1278 standardFlagsDefault->addFlag (fo);
1280 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1281 fo->setName("2arrow-down");
1282 fo->setGroup("standard-arrow");
1283 a=new QAction (fo->getPixmap(),fo->getName(),this);
1286 a->setCheckable(true);
1287 a->setObjectName(fo->getName());
1288 a->setToolTip(tr("Very unimportant!","Standardflag"));
1289 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1290 standardFlagsDefault->addFlag (fo);
1292 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1293 fo->setName("thumb-up");
1294 fo->setGroup("standard-thumb");
1295 a=new QAction (fo->getPixmap(),fo->getName(),this);
1298 a->setCheckable(true);
1299 a->setObjectName(fo->getName());
1300 a->setToolTip(tr("I like this","Standardflag"));
1301 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1302 standardFlagsDefault->addFlag (fo);
1304 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1305 fo->setName("thumb-down");
1306 fo->setGroup("standard-thumb");
1307 a=new QAction (fo->getPixmap(),fo->getName(),this);
1310 a->setCheckable(true);
1311 a->setObjectName(fo->getName());
1312 a->setToolTip(tr("I do not like this","Standardflag"));
1313 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1314 standardFlagsDefault->addFlag (fo);
1316 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1317 fo->setName("rose");
1318 a=new QAction (fo->getPixmap(),fo->getName(),this);
1321 a->setCheckable(true);
1322 a->setObjectName(fo->getName());
1323 a->setToolTip(tr("Rose","Standardflag"));
1324 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1325 standardFlagsDefault->addFlag (fo);
1327 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1328 fo->setName("heart");
1329 a=new QAction (fo->getPixmap(),fo->getName(),this);
1331 a->setCheckable(true);
1332 a->setObjectName(fo->getName());
1333 a->setToolTip(tr("I just love... ","Standardflag"));
1334 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1335 standardFlagsDefault->addFlag (fo);
1337 fo->load(QPixmap(flagsPath+"flag-present.png"));
1338 fo->setName("present");
1339 a=new QAction (fo->getPixmap(),fo->getName(),this);
1342 a->setCheckable(true);
1343 a->setObjectName(fo->getName());
1344 a->setToolTip(tr("Surprise!","Standardflag"));
1345 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1346 standardFlagsDefault->addFlag (fo);
1348 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1349 fo->setName("flash");
1350 a=new QAction (fo->getPixmap(),fo->getName(),this);
1353 a->setCheckable(true);
1354 a->setObjectName(fo->getName());
1355 a->setToolTip(tr("Dangerous","Standardflag"));
1356 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1357 standardFlagsDefault->addFlag (fo);
1359 fo->load(QPixmap(flagsPath+"flag-info.png"));
1360 // Original: xsldbg_output.png
1361 fo->setName("info");
1362 a=new QAction (fo->getPixmap(),fo->getName(),this);
1365 a->setCheckable(true);
1366 a->setObjectName(fo->getName());
1367 a->setToolTip(tr("Info","Standardflag"));
1368 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1369 standardFlagsDefault->addFlag (fo);
1371 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1372 // Original khelpcenter.png
1373 fo->setName("lifebelt");
1374 a=new QAction (fo->getPixmap(),fo->getName(),this);
1377 a->setCheckable(true);
1378 a->setObjectName(fo->getName());
1379 a->setToolTip(tr("This will help","Standardflag"));
1380 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1381 standardFlagsDefault->addFlag (fo);
1387 void Main::setupSettingsActions()
1389 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1393 a = new QAction( tr( "Set application to open pdf files"), this);
1394 a->setStatusTip ( tr( "Set application to open pdf files"));
1395 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1396 settingsMenu->addAction (a);
1398 a = new QAction( tr( "Set application to open external links"), this);
1399 a->setStatusTip( tr( "Set application to open external links"));
1400 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1401 settingsMenu->addAction (a);
1403 settingsMenu->addSeparator();
1404 a = new QAction( tr( "Edit branch after adding it" ), this );
1405 a->setStatusTip( tr( "Edit branch after adding it" ));
1406 a->setToggleAction(true);
1407 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1408 settingsMenu->addAction (a);
1409 actionSettingsAutoedit=a;
1411 a= new QAction( tr( "Select branch after adding it" ), this );
1412 a->setStatusTip( tr( "Select branch after adding it" ));
1413 a->setToggleAction(true);
1414 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1415 settingsMenu->addAction (a);
1416 actionSettingsAutoselectHeading=a;
1418 a= new QAction(tr( "Select existing heading" ), this);
1419 a->setStatusTip( tr( "Select heading before editing" ));
1420 a->setToggleAction(true);
1421 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1422 settingsMenu->addAction (a);
1423 actionSettingsAutoselectText=a;
1425 a= new QAction(tr( "pasting into new branch" ), this );
1426 a->setStatusTip( tr( "Pasting into new branch" ));
1427 a->setToggleAction(true);
1428 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1429 settingsMenu->addAction (a);
1430 actionSettingsPasteNewHeading=a;
1432 a= new QAction( tr( "Delete key" ), this);
1433 a->setStatusTip( tr( "Delete key for deleting branches" ));
1434 a->setToggleAction(true);
1435 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1436 settingsMenu->addAction (a);
1437 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1438 actionSettingsUseDelKey=a;
1440 a= new QAction( tr( "Exclusive flags" ), this);
1441 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1442 a->setToggleAction(true);
1443 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1444 settingsMenu->addAction (a);
1445 actionSettingsUseFlagGroups=a;
1447 a= new QAction( tr( "Use hide flags" ), this);
1448 a->setStatusTip( tr( "Use hide flag during exports " ));
1449 a->setToggleAction(true);
1450 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1451 settingsMenu->addAction (a);
1452 actionSettingsUseHideExport=a;
1456 void Main::setupTestActions()
1458 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1461 a = new QAction( tr( "test flag" ), this);
1462 a->setStatusTip( tr( "Call test function" ));
1463 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1464 testMenu->addAction (a);
1468 void Main::setupHelpActions()
1470 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help" ));
1473 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1474 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1475 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1476 helpMenu->addAction (a);
1478 a = new QAction( tr( "About VYM" ), this);
1479 a->setStatusTip( tr( "About VYM")+" "__VYM);
1480 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1481 helpMenu->addAction (a);
1483 a = new QAction( tr( "About QT" ), this);
1484 a->setStatusTip( tr( "Information about QT toolkit" ));
1485 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1486 helpMenu->addAction (a);
1490 void Main::setupContextMenus()
1494 // Context Menu for branch or mapcenter
1495 branchContextMenu =new QMenu (this);
1498 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1499 branchAddContextMenu->addAction (actionEditPaste );
1500 branchAddContextMenu->addAction ( actionEditAddBranch );
1501 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1502 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1503 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1504 branchAddContextMenu->addSeparator();
1505 branchAddContextMenu->addAction ( actionEditLoadImage);
1506 branchAddContextMenu->addSeparator();
1507 branchAddContextMenu->addAction ( actionEditLoadImage);
1508 branchAddContextMenu->addAction ( actionEditImportAdd );
1509 branchAddContextMenu->addAction ( actionEditImportReplace );
1512 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1513 branchRemoveContextMenu->addAction (actionEditCut);
1514 branchRemoveContextMenu->addAction ( actionEditDelete );
1515 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1516 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1519 actionEditSaveBranch->addTo( branchContextMenu );
1521 branchContextMenu->addSeparator();
1522 branchContextMenu->addAction ( actionEditOpenURL );
1523 branchContextMenu->addAction ( actionEditOpenURLTab );
1524 branchContextMenu->addAction ( actionEditURL );
1525 branchContextMenu->addAction ( actionEditHeading2URL );
1526 branchContextMenu->addAction ( actionEditBugzilla2URL );
1527 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1529 branchContextMenu->addAction ( actionEditFATE2URL );
1531 branchContextMenu->addSeparator();
1532 branchContextMenu->addAction ( actionEditOpenVymLink );
1533 branchContextMenu->addAction ( actionEditVymLink );
1534 branchContextMenu->addAction ( actionEditDeleteVymLink );
1536 branchContextMenu->addSeparator();
1537 branchContextMenu->addAction ( actionFormatFrameNone );
1538 branchContextMenu->addAction ( actionFormatFrameRectangle);
1540 branchContextMenu->addSeparator();
1541 branchContextMenu->addAction ( actionFormatIncludeImagesVer );
1542 branchContextMenu->addAction ( actionFormatIncludeImagesHor );
1543 branchContextMenu->addAction ( actionFormatHideLinkUnselected );
1545 // Context Menu for links in a branch menu
1546 // This will be populated "on demand" in MapEditor::updateActions
1547 branchContextMenu->addSeparator();
1548 branchLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink"));
1549 branchLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink"));
1550 connect( branchLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1551 connect( branchLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1553 // Context menu for floatimage
1554 floatimageContextMenu =new QMenu (this);
1555 saveImageFormatMenu=floatimageContextMenu->addMenu (tr("Save image"));
1557 foreach (QByteArray format, QImageWriter::supportedImageFormats())
1559 QString text = tr("%1...").arg(QString(format).toUpper());
1560 a= new QAction (text,this);
1561 saveImageFormatMenu->addAction ( a );
1564 floatimageContextMenu->addSeparator();
1565 actionEditCopy->addTo( floatimageContextMenu );
1566 actionEditCut->addTo( floatimageContextMenu );
1568 floatimageContextMenu->addSeparator();
1569 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1572 // Context menu for canvas
1573 canvasContextMenu =new QMenu (this);
1574 actionEditMapInfo->addTo( canvasContextMenu );
1575 canvasContextMenu->insertSeparator();
1576 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1577 canvasContextMenu->insertSeparator();
1578 actionFormatLinkColorHint->addTo( canvasContextMenu );
1579 actionFormatLinkColor->addTo( canvasContextMenu );
1580 actionFormatBackColor->addTo( canvasContextMenu );
1582 // Menu for last opened files
1583 // Read settings initially
1585 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1586 for (int i=1;i<=j;i++)
1588 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1589 if (!s.isEmpty() && j<=maxLastMaps)
1592 setupLastMapsMenu();
1593 connect( fileLastMapsMenu, SIGNAL( triggered(QAction *) ), this, SLOT( fileLoadLast(QAction*) ) );
1596 void Main::setupLastMapsMenu()
1598 // Remove double entries
1599 QStringList::Iterator it=lastMaps.begin();
1600 QStringList::Iterator jt;
1601 while (it!=lastMaps.end() )
1605 while (jt!=lastMaps.end() )
1608 jt=lastMaps.remove(jt);
1615 // Limit length of list to maxLastMaps
1616 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1618 // build Menu from lastMaps string list
1619 fileLastMapsMenu->clear();
1620 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1621 fileLastMapsMenu->addAction (*it );
1624 void Main::hideEvent (QHideEvent * )
1626 if (!textEditor->isMinimized() ) textEditor->hide();
1629 void Main::showEvent (QShowEvent * )
1631 if (textEditor->showWithMain()) textEditor->showNormal();
1634 bool Main::reallyWriteDirectory(const QString &dir)
1636 QStringList eList = QDir(dir).entryList();
1637 if (eList.first() ==".") eList.pop_front(); // remove "."
1638 if (eList.first() =="..") eList.pop_front(); // remove "."
1639 if (!eList.isEmpty())
1641 QMessageBox mb( __VYM,
1642 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1643 QMessageBox::Warning,
1645 QMessageBox::Cancel | QMessageBox::Default,
1646 QMessageBox::QMessageBox::NoButton );
1648 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1649 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1652 case QMessageBox::Yes:
1655 case QMessageBox::Cancel:
1663 QString Main::browseDirectory (const QString &caption)
1665 Q3FileDialog fd(this,caption);
1666 fd.setMode (Q3FileDialog::DirectoryOnly);
1667 fd.setCaption(__VYM " - "+caption);
1670 if ( fd.exec() == QDialog::Accepted )
1671 return fd.selectedFile();
1676 MapEditor* Main::currentMapEditor() const
1678 if ( tabWidget->currentPage() &&
1679 tabWidget->currentPage()->inherits( "MapEditor" ) )
1680 return (MapEditor*)tabWidget->currentPage();
1684 //TODO not used now, maybe use this for overview window later
1685 void Main::newView()
1687 // Open a new view... have it delete when closed.
1688 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1689 qApp->setMainWidget(m);
1691 qApp->setMainWidget(0);
1694 void Main::editorChanged(QWidget *)
1696 // Unselect all possibly selected objects
1697 // (Important to update note editor)
1700 for (i=0;i<=tabWidget->count() -1;i++)
1703 me=(MapEditor*)tabWidget->page(i);
1706 currentMapEditor()->reselect();
1708 // Update actions to in menus and toolbars according to editor
1709 currentMapEditor()->updateActions();
1712 void Main::fileNew()
1714 QString fn="unnamed";
1715 MapEditor* medit = new MapEditor ( NULL,true);
1716 tabWidget->addTab (medit,fn);
1717 tabWidget->showPage(medit);
1718 medit->viewport()->setFocus();
1719 // For the very first map we do not have flagrows yet...
1720 medit->select("mc:");
1723 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1725 ErrorCode err=success;
1727 // fn is usually the archive, mapfile the file after uncompressing
1730 // Make fn absolute (needed for unzip)
1731 fn=QDir (fn).absPath();
1737 // Check, if map is already loaded
1739 while (i<=tabWidget->count() -1)
1741 me=(MapEditor*)tabWidget->page(i);
1742 if (me->getFilePath() == fn)
1744 // Already there, ask for confirmation
1745 QMessageBox mb( __VYM,
1746 tr("The map %1\nis already opened."
1747 "Opening the same map in multiple editors may lead \n"
1748 "to confusion when finishing working with vym."
1749 "Do you want to").arg(fn),
1750 QMessageBox::Warning,
1751 QMessageBox::Yes | QMessageBox::Default,
1752 QMessageBox::Cancel | QMessageBox::Escape,
1753 QMessageBox::NoButton);
1754 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1755 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1758 case QMessageBox::Yes:
1760 i=tabWidget->count();
1762 case QMessageBox::Cancel:
1774 if ( !fn.isEmpty() )
1776 me = currentMapEditor();
1777 int tabIndex=tabWidget->currentPageIndex();
1778 // Check first, if mapeditor exists
1779 // If it is not default AND we want a new map,
1780 // create a new mapeditor in a new tab
1781 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1783 me= new MapEditor ( NULL,true);
1784 tabWidget->addTab (me,fn);
1785 tabIndex=tabWidget->indexOf (me);
1786 tabWidget->setCurrentPage (tabIndex);
1789 // Check, if file exists (important for creating new files
1790 // from command line
1791 if (!QFile(fn).exists() )
1793 QMessageBox mb( __VYM,
1794 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1795 QMessageBox::Question,
1797 QMessageBox::Cancel | QMessageBox::Default,
1798 QMessageBox::NoButton );
1800 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1801 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1804 case QMessageBox::Yes:
1806 currentMapEditor()->setFilePath(fn);
1807 tabWidget->setTabLabel (currentMapEditor(),
1808 currentMapEditor()->getFileName() );
1809 statusBar()->message( "Created " + fn , statusbarTime );
1812 case QMessageBox::Cancel:
1813 // don't create new map
1814 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1821 //tabWidget->currentPage() won't be NULL here, because of above...
1822 tabWidget->showPage(me);
1823 me->viewport()->setFocus();
1825 // Create temporary directory for packing
1826 char tmpdir1[]="/tmp/vym-XXXXXX";
1827 QString tmpMapDir=mkdtemp(tmpdir1);
1829 // Try to unzip file
1830 err=unzipDir (tmpMapDir,fn);
1834 me->setZipped(false);
1837 me->setZipped(true);
1839 // Look for mapname.xml
1840 mapfile= fn.left(fn.findRev(".",-1,true));
1841 mapfile=mapfile.section( '/', -1 );
1842 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1843 if (!file.exists() )
1845 // mapname.xml does not exist, well,
1846 // maybe some renamed the mapname.vym file...
1847 // Try to find any .xml in the toplevel
1848 // directory of the .vym file
1849 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1850 if (flist.count()==1)
1852 // Only one entry, take this one
1853 mapfile=tmpMapDir + "/"+flist.first();
1856 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1857 *it=tmpMapDir + "/" + *it;
1858 // TODO Multiple entries, load all (but only the first one into this ME)
1859 //mainWindow->fileLoadFromTmp (flist);
1860 //returnCode=1; // Silently forget this attempt to load
1861 qWarning ("MainWindow::load (fn) multimap found...");
1864 if (flist.isEmpty() )
1866 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1867 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1870 } //file doesn't exist
1872 mapfile=file.name();
1877 // Save existing filename in case we import
1878 QString fn_org=me->getFilePath();
1880 // Finally load map into mapEditor
1881 me->setFilePath (mapfile,fn);
1882 err=me->load(mapfile,lmode);
1884 // Restore old (maybe empty) filepath, if this is an import
1886 me->setFilePath (fn_org);
1889 // Finally check for errors and go home
1892 if (lmode==NewMap) fileCloseMap();
1893 statusBar()->message( "Could not load " + fn, statusbarTime );
1898 me->setFilePath (fn);
1899 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1900 if (fn.left(9)!="/tmp/vym-")
1902 // Only append to lastMaps if not loaded from a tmpDir
1903 // e.g. imported bookmarks are in a tmpDir
1904 lastMaps.prepend(me->getFilePath() );
1905 setupLastMapsMenu();
1907 actionFilePrint->setEnabled (true);
1909 statusBar()->message( "Loaded " + fn, statusbarTime );
1913 removeDir (QDir(tmpMapDir));
1919 void Main::fileLoad(const LoadMode &lmode)
1921 Q3FileDialog *fd=new Q3FileDialog( this);
1922 if (!lastFileDir.isEmpty())
1923 fd->setDir (lastFileDir);
1924 fd->setMode (Q3FileDialog::ExistingFiles);
1925 fd->addFilter ("XML (*.xml)");
1926 fd->addFilter ("VYM map (*.vym *.vyp)");
1930 fd->setCaption(tr("Load vym map"));
1933 fd->setCaption(tr("Import: Add vym map to selection"));
1936 fd->setCaption(tr("Import: Replace selection with vym map"));
1942 if ( fd->exec() == QDialog::Accepted )
1944 lastFileDir=fd->dirPath();
1945 QStringList flist = fd->selectedFiles();
1946 QStringList::Iterator it = flist.begin();
1947 while( it != flist.end() )
1950 fileLoad(*it, lmode);
1957 void Main::fileLoad()
1962 void Main::fileLoadLast(QAction *a)
1964 fileLoad(lastMaps.at(fileLastMapsMenu->actions().indexOf(a)) ,NewMap);
1967 void Main::fileSave(const SaveMode &savemode)
1969 // tmp dir for zipping
1973 ErrorCode err=success;
1975 QString safeFilePath;
1977 bool saveZipped=currentMapEditor()->saveZipped();
1979 MapEditor * me=currentMapEditor();
1982 QString fn=me->getFilePath();
1983 // filename=unnamed, filepath="" in constructor...
1984 if ( !fn.isEmpty() )
1986 // We have a filepath, go on saving
1987 // First remove existing file, we
1988 // don't want to add to old zip archives
1992 QMessageBox::warning( 0, tr( "Save Error" ),
1993 fn+ tr("\ncould not be removed before saving"));
1995 // Look, if we should zip the data:
1998 QMessageBox mb( __VYM,
1999 tr("The map %1\ndid not use the compressed "
2000 "vym file format.\nWriting it uncompressed will also write images \n"
2001 "and flags and thus may overwrite files in the "
2002 "given directory\n\nDo you want to write the map").arg(fn),
2003 QMessageBox::Warning,
2004 QMessageBox::Yes | QMessageBox::Default,
2006 QMessageBox::Cancel | QMessageBox::Escape);
2007 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2008 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2009 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2012 case QMessageBox::Yes:
2013 // save compressed (default file format)
2016 case QMessageBox::No:
2017 // save uncompressed
2020 case QMessageBox::Cancel:
2029 char tmpdir1[]="/tmp/vym-XXXXXX";
2030 tmpMapDir=mkdtemp(tmpdir1);
2032 safeFilePath=me->getFilePath();
2033 me->setFilePath (tmpMapDir+"/"+
2034 me->getMapName()+ ".xml",
2036 me->save (savemode);
2037 me->setFilePath (safeFilePath);
2039 zipDir (tmpMapDir,fn);
2044 safeFilePath=me->getFilePath();
2045 me->setFilePath (fn, safeFilePath);
2046 me->save (savemode);
2047 me->setFilePath (safeFilePath);
2049 } // filepath available
2052 // We have no filepath yet,
2053 // call fileSaveAs() now, this will call fileSave()
2055 fileSaveAs(savemode);
2059 if (saveZipped && !tmpMapDir.isEmpty())
2061 removeDir (QDir(tmpMapDir));
2065 statusBar()->message(
2066 tr("Saved %1").arg(me->getFilePath()),
2068 lastMaps.prepend(me->getFilePath() );
2069 setupLastMapsMenu();
2071 statusBar()->message(
2072 tr("Couldn't save ").arg(me->getFilePath()),
2076 void Main::fileSave()
2078 fileSave (CompleteMap);
2081 void Main::fileSaveAs(const SaveMode& savemode)
2085 if (currentMapEditor())
2087 if (savemode==CompleteMap)
2088 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2090 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2091 if ( !fn.isEmpty() )
2093 // Check for existing file
2094 if (QFile (fn).exists())
2096 QMessageBox mb( __VYM,
2097 tr("The file %1\nexists already. Do you want to").arg(fn),
2098 QMessageBox::Warning,
2099 QMessageBox::Yes | QMessageBox::Default,
2100 QMessageBox::Cancel | QMessageBox::Escape,
2101 QMessageBox::NoButton);
2102 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2103 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2106 case QMessageBox::Yes:
2109 case QMessageBox::Cancel:
2116 // New file, add extension to filename, if missing
2117 // This is always .vym or .vyp, depending on savemode
2118 if (savemode==CompleteMap)
2120 if (!fn.contains (".vym") && !fn.contains (".xml"))
2124 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2133 currentMapEditor()->setFilePath(fn);
2137 if (savemode==CompleteMap)
2138 tabWidget->setTabLabel (currentMapEditor(),
2139 currentMapEditor()->getFileName() );
2145 void Main::fileSaveAs()
2147 fileSaveAs (CompleteMap);
2150 void Main::fileImportKDEBookmarks()
2152 ImportKDEBookmarks im;
2154 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2155 currentMapEditor()->setFilePath ("");
2158 void Main::fileImportFirefoxBookmarks()
2160 Q3FileDialog *fd=new Q3FileDialog( this);
2161 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2162 fd->setMode (Q3FileDialog::ExistingFiles);
2163 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2164 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2167 if ( fd->exec() == QDialog::Accepted )
2169 ImportFirefoxBookmarks im;
2170 QStringList flist = fd->selectedFiles();
2171 QStringList::Iterator it = flist.begin();
2172 while( it != flist.end() )
2175 if (im.transform() &&
2176 success==fileLoad (im.getTransformedFile(),NewMap) &&
2177 currentMapEditor() )
2178 currentMapEditor()->setFilePath ("");
2185 void Main::fileImportMM()
2189 Q3FileDialog *fd=new Q3FileDialog( this);
2190 if (!lastFileDir.isEmpty())
2191 fd->setDir (lastFileDir);
2192 fd->setMode (Q3FileDialog::ExistingFiles);
2193 fd->addFilter ("Mind Manager (*.mmap)");
2194 fd->setCaption(tr("Import")+" "+"Mind Manager");
2197 if ( fd->exec() == QDialog::Accepted )
2199 lastFileDir=fd->dirPath();
2200 QStringList flist = fd->selectedFiles();
2201 QStringList::Iterator it = flist.begin();
2202 while( it != flist.end() )
2205 if (im.transform() &&
2206 success==fileLoad (im.getTransformedFile(),NewMap) &&
2207 currentMapEditor() )
2208 currentMapEditor()->setFilePath ("");
2217 void Main::fileImportDir()
2219 if (currentMapEditor())
2220 currentMapEditor()->importDir();
2223 void Main::fileExportXML()
2225 if (currentMapEditor())
2227 QString dir=browseDirectory(tr("Export XML to directory"));
2228 if (dir !="" && reallyWriteDirectory(dir) )
2229 currentMapEditor()->exportXML(dir);
2234 void Main::fileExportXHTML()
2236 MapEditor *me=currentMapEditor();
2240 ExportXHTMLDialog dia(this);
2241 dia.setFilePath (me->getFilePath() );
2242 dia.setMapName (me->getMapName() );
2245 if (dia.exec()==QDialog::Accepted)
2247 QString dir=dia.getDir();
2248 // Check, if warnings should be used before overwriting
2249 // the output directory
2252 ok=reallyWriteDirectory(dir);
2258 me->exportXML (dia.getDir() );
2259 dia.doExport(me->getMapName() );
2260 if (dia.hasChanged())
2267 void Main::fileExportImage()
2269 MapEditor *me=currentMapEditor();
2273 QFileDialog *fd=new QFileDialog (this);
2274 fd->setCaption (tr("Export map as image"));
2275 fd->setFileMode(QFileDialog::AnyFile);
2276 fd->setFilters (imageIO.getFilters() );
2277 fd->setDirectory (lastImageDir);
2280 fl=fd->selectedFiles();
2281 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2282 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2287 void Main::fileExportASCII()
2289 MapEditor *me=currentMapEditor();
2293 ex.setMapCenter(me->getMapCenter());
2294 ex.addFilter ("TXT (*.txt)");
2295 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2296 if (ex.execDialog() )
2298 me->setExportMode(true);
2300 me->setExportMode(false);
2305 void Main::fileExportLaTeX()
2307 MapEditor *me=currentMapEditor();
2311 ex.setMapCenter(me->getMapCenter());
2312 ex.addFilter ("Tex (*.tex)");
2313 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2314 if (ex.execDialog() )
2316 me->setExportMode(true);
2318 me->setExportMode(false);
2323 void Main::fileExportKDEBookmarks()
2325 ExportKDEBookmarks ex;
2326 MapEditor *me=currentMapEditor();
2329 ex.setMapCenter (me->getMapCenter() );
2334 void Main::fileExportTaskjuggler()
2336 ExportTaskjuggler ex;
2337 MapEditor *me=currentMapEditor();
2340 ex.setMapCenter (me->getMapCenter() );
2341 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2342 ex.addFilter ("Taskjuggler (*.tjp)");
2343 if (ex.execDialog() )
2345 me->setExportMode(true);
2347 me->setExportMode(false);
2352 void Main::fileExportOOPresentation()
2354 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2355 // TODO add preview in dialog
2356 //ImagePreview *p =new ImagePreview (fd);
2357 //fd->setContentsPreviewEnabled( TRUE );
2358 //fd->setContentsPreview( p, p );
2359 //fd->setPreviewMode( QFileDialog::Contents );
2360 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2361 fd->setDir (QDir().current());
2364 if ( fd->exec() == QDialog::Accepted )
2366 QString fn=fd->selectedFile();
2367 //lastImageDir=fn.left(fn.findRev ("/"));
2368 if (currentMapEditor())
2369 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2373 void Main::fileCloseMap()
2375 if (currentMapEditor())
2377 if (currentMapEditor()->hasChanged())
2379 QMessageBox mb( __VYM,
2380 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2381 QMessageBox::Warning,
2382 QMessageBox::Yes | QMessageBox::Default,
2384 QMessageBox::Cancel | QMessageBox::Escape );
2385 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2386 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2389 case QMessageBox::Yes:
2391 fileSave(CompleteMap);
2393 case QMessageBox::No:
2394 // close without saving
2396 case QMessageBox::Cancel:
2401 currentMapEditor()->closeMap();
2402 tabWidget->removePage(currentMapEditor());
2403 if (tabWidget->count()==0)
2404 actionFilePrint->setEnabled (false);
2408 void Main::filePrint()
2410 if (currentMapEditor())
2411 currentMapEditor()->print();
2414 void Main::fileExitVYM()
2416 // Check if one or more editors have changed
2419 for (i=0;i<=tabWidget->count() -1;i++)
2422 me=(MapEditor*)tabWidget->page(i);
2424 // If something changed, ask what to do
2425 if (me->isUnsaved())
2427 tabWidget->setCurrentPage(i);
2428 QMessageBox mb( __VYM,
2429 tr("This map is not saved yet. Do you want to"),
2430 QMessageBox::Warning,
2431 QMessageBox::Yes | QMessageBox::Default,
2433 QMessageBox::Cancel | QMessageBox::Escape );
2434 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2435 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2437 mb.setActiveWindow();
2438 switch( mb.exec() ) {
2439 case QMessageBox::Yes:
2440 // save (the changed editors) and exit
2441 fileSave(CompleteMap);
2443 case QMessageBox::No:
2444 // exit without saving
2446 case QMessageBox::Cancel:
2447 // don't save and don't exit
2451 } // loop over all MEs
2455 void Main::editUndo()
2457 if (currentMapEditor())
2458 currentMapEditor()->undo();
2461 void Main::editRedo()
2463 if (currentMapEditor())
2464 currentMapEditor()->redo();
2467 void Main::editCopy()
2469 if (currentMapEditor())
2470 currentMapEditor()->copy();
2473 void Main::editPaste()
2475 if (currentMapEditor())
2476 currentMapEditor()->paste();
2479 void Main::editCut()
2481 if (currentMapEditor())
2482 currentMapEditor()->cut();
2485 void Main::editOpenFindWindow()
2487 findWindow->popup();
2488 findWindow->raise();
2489 findWindow->setActiveWindow();
2492 void Main::editFind(QString s)
2495 BranchObj *bo=currentMapEditor()->findText(s, cs);
2498 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2501 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2502 tr("No matches found for \"%1\"").arg(s));
2506 void Main::editFindChanged()
2507 { // Notify editor, to abort the current find process
2508 currentMapEditor()->findReset();
2511 void Main::editOpenURL()
2514 if (currentMapEditor())
2516 QString url=currentMapEditor()->getURL();
2517 if (url=="") return;
2518 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2519 procBrowser = new Q3Process( this );
2521 procBrowser->addArgument( browser);
2522 procBrowser->addArgument( url);
2524 if ( !procBrowser->start() )
2526 // try to set path to browser
2527 QMessageBox::warning(0,
2529 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2530 tr("Please use Settings->")+tr("Set application to open an URL"));
2535 void Main::editOpenURLTab()
2537 if (currentMapEditor())
2539 QString url=currentMapEditor()->getURL();
2540 if (url=="") return;
2541 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2542 if (procBrowser && procBrowser->isRunning())
2544 if (browser.contains("konqueror"))
2546 // Try to open new tab in existing konqueror started previously by vym
2547 Q3Process *p=new Q3Process (this);
2548 p->addArgument ("dcop");
2549 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2550 p->addArgument ("konqueror-mainwindow#1");
2551 p->addArgument ("newTab");
2552 p->addArgument (url);
2554 // try to set browser
2555 QMessageBox::warning(0,
2557 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2559 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2561 // Try to open new tab in firefox
2562 Q3Process *p=new Q3Process (this);
2563 p->addArgument (browser);
2564 p->addArgument ("-remote");
2565 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2567 // try to set browser
2568 QMessageBox::warning(0,
2570 tr("Couldn't start %1 to open a new tab").arg(browser));
2579 void Main::editURL()
2581 if (currentMapEditor())
2582 currentMapEditor()->editURL();
2585 void Main::editHeading2URL()
2587 if (currentMapEditor())
2588 currentMapEditor()->editHeading2URL();
2591 void Main::editBugzilla2URL()
2593 if (currentMapEditor())
2594 currentMapEditor()->editBugzilla2URL();
2597 void Main::editFATE2URL()
2599 if (currentMapEditor())
2600 currentMapEditor()->editFATE2URL();
2603 void Main::editOpenVymLink()
2605 // Get current path to map
2606 QString currentVymLink;
2607 if (currentMapEditor())
2609 currentVymLink=currentMapEditor()->getVymLink();
2610 // compare path with already loaded maps
2614 for (i=0;i<=tabWidget->count() -1;i++)
2616 me=(MapEditor*)tabWidget->page(i);
2617 if (currentVymLink==me->getFilePath() )
2626 if (!QFile(currentVymLink).exists() )
2627 QMessageBox::critical( 0, tr( "Critical Error" ),
2628 tr("Couldn't open map %1").arg(currentVymLink));
2631 fileLoad (currentVymLink, NewMap);
2632 tabWidget->setCurrentPage (tabWidget->count()-1);
2635 // Go to tab containing the map
2636 tabWidget->setCurrentPage (index);
2640 void Main::editVymLink()
2642 if (currentMapEditor())
2643 currentMapEditor()->editVymLink();
2646 void Main::editDeleteVymLink()
2648 if (currentMapEditor())
2649 currentMapEditor()->deleteVymLink();
2652 void Main::editToggleHideExport()
2654 if (currentMapEditor())
2655 currentMapEditor()->toggleHideExport();
2658 void Main::editMapInfo()
2660 if (currentMapEditor())
2661 currentMapEditor()->editMapInfo();
2664 void Main::editMoveUp()
2666 if (currentMapEditor())
2667 currentMapEditor()->moveBranchUp();
2670 void Main::editMoveDown()
2672 if (currentMapEditor())
2673 currentMapEditor()->moveBranchDown();
2676 void Main::editToggleScroll()
2678 if (currentMapEditor())
2680 currentMapEditor()->toggleScroll();
2684 void Main::editUnScrollAll()
2686 if (currentMapEditor())
2688 currentMapEditor()->unScrollAll();
2692 void Main::editHeading()
2694 if (currentMapEditor())
2695 currentMapEditor()->editHeading();
2698 void Main::editNewBranch()
2700 if (currentMapEditor())
2701 currentMapEditor()->addNewBranch(0);
2704 void Main::editNewBranchHere()
2706 if (currentMapEditor())
2707 currentMapEditor()->addNewBranchHere();
2710 void Main::editNewBranchAbove()
2712 if (currentMapEditor())
2713 currentMapEditor()->addNewBranch(-1);
2716 void Main::editNewBranchBelow()
2718 if (currentMapEditor())
2719 currentMapEditor()->addNewBranch(1);
2722 void Main::editImportAdd()
2724 fileLoad (ImportAdd);
2727 void Main::editImportReplace()
2729 fileLoad (ImportReplace);
2732 void Main::editSaveBranch()
2734 fileSaveAs (PartOfMap);
2737 void Main::editRemoveBranchKeepChilds()
2739 if (currentMapEditor())
2740 currentMapEditor()->removeBranchKeepChilds();
2743 void Main::editRemoveChilds()
2745 if (currentMapEditor())
2746 currentMapEditor()->removeChilds();
2749 void Main::editDeleteSelection()
2751 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2752 currentMapEditor()->deleteSelection();
2755 void Main::editUpperBranch()
2757 if (currentMapEditor())
2758 currentMapEditor()->selectUpperBranch();
2761 void Main::editLowerBranch()
2763 if (currentMapEditor())
2764 currentMapEditor()->selectLowerBranch();
2767 void Main::editLeftBranch()
2769 if (currentMapEditor())
2770 currentMapEditor()->selectLeftBranch();
2773 void Main::editRightBranch()
2775 if (currentMapEditor())
2776 currentMapEditor()->selectRightBranch();
2779 void Main::editFirstBranch()
2781 if (currentMapEditor())
2782 currentMapEditor()->selectFirstBranch();
2785 void Main::editLastBranch()
2787 if (currentMapEditor())
2788 currentMapEditor()->selectLastBranch();
2791 void Main::editLoadImage()
2793 if (currentMapEditor())
2794 currentMapEditor()->loadFloatImage();
2797 void Main::editSaveImage(int item)
2799 if (currentMapEditor())
2800 currentMapEditor()->saveFloatImage(item);
2803 void Main::editFollowXLink(QAction *a)
2806 if (currentMapEditor())
2807 currentMapEditor()->followXLink(branchLinksContextMenuFollow->actions().indexOf(a));
2810 void Main::editEditXLink(QAction *a)
2812 if (currentMapEditor())
2813 currentMapEditor()->editXLink(branchLinksContextMenuEdit->actions().indexOf(a));
2816 void Main::formatSelectColor()
2818 if (currentMapEditor())
2820 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2821 if ( !col.isValid() ) return;
2822 currentMapEditor()->setColor( col );
2823 colorChanged( col );
2827 void Main::formatPickColor()
2829 if (currentMapEditor())
2830 colorChanged( currentMapEditor()->pickColor() );
2833 void Main::colorChanged(QColor c)
2835 QPixmap pix( 16, 16 );
2837 actionFormatColor->setIconSet( pix );
2840 void Main::formatColorItem()
2842 if (currentMapEditor())
2843 currentMapEditor()->colorItem();
2846 void Main::formatColorBranch()
2848 if (currentMapEditor())
2849 currentMapEditor()->colorBranch();
2852 void Main::formatLinkStyleLine()
2854 if (currentMapEditor())
2855 currentMapEditor()->setLinkStyle(StyleLine);
2858 void Main::formatLinkStyleParabel()
2860 if (currentMapEditor())
2861 currentMapEditor()->setLinkStyle(StyleParabel);
2864 void Main::formatLinkStylePolyLine()
2866 if (currentMapEditor())
2867 currentMapEditor()->setLinkStyle(StylePolyLine);
2870 void Main::formatLinkStylePolyParabel()
2872 if (currentMapEditor())
2873 currentMapEditor()->setLinkStyle(StylePolyParabel);
2876 void Main::formatSelectBackColor()
2878 if (currentMapEditor())
2879 currentMapEditor()->selectBackgroundColor();
2882 void Main::formatSelectLinkColor()
2884 if (currentMapEditor())
2885 currentMapEditor()->selectLinkColor();
2888 void Main::formatToggleLinkColorHint()
2890 currentMapEditor()->toggleLinkColorHint();
2893 void Main::formatFrameNone()
2895 if (currentMapEditor())
2896 currentMapEditor()->setFrame(NoFrame);
2899 void Main::formatFrameRectangle()
2901 if (currentMapEditor())
2902 currentMapEditor()->setFrame(Rectangle);
2905 void Main::formatIncludeImagesVer()
2907 if (currentMapEditor())
2908 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2911 void Main::formatIncludeImagesHor()
2913 if (currentMapEditor())
2914 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2917 void Main::formatHideLinkUnselected()
2919 if (currentMapEditor())
2920 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2923 void Main::viewZoomReset()
2925 if (currentMapEditor())
2929 currentMapEditor()->setWorldMatrix( m );
2930 currentMapEditor()->setViewCenter();
2931 currentMapEditor()->adjustCanvasSize();
2935 void Main::viewZoomIn()
2937 if (currentMapEditor())
2939 QMatrix m = currentMapEditor()->worldMatrix();
2940 m.scale( 1.25, 1.25 );
2941 currentMapEditor()->setWorldMatrix( m );
2942 currentMapEditor()->setViewCenter();
2943 currentMapEditor()->adjustCanvasSize();
2947 void Main::viewZoomOut()
2949 if (currentMapEditor())
2951 QMatrix m = currentMapEditor()->worldMatrix();
2952 m.scale( 0.8, 0.8 );
2953 currentMapEditor()->setWorldMatrix( m );
2954 currentMapEditor()->setViewCenter();
2955 currentMapEditor()->adjustCanvasSize();
2959 void Main::modModeColor()
2963 void Main::modModeLink()
2967 bool Main::settingsPDF()
2969 // Default browser is set in constructor
2971 QString text = QInputDialog::getText(
2972 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2973 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2975 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2980 bool Main::settingsURL()
2982 // Default browser is set in constructor
2984 QString text = QInputDialog::getText(
2985 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2986 settings.readEntry("/vym/mainwindow/readerURL")
2989 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2993 void Main::settingsToggleDelKey()
2995 if (actionSettingsUseDelKey->isOn())
2997 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3000 actionEditDelete->setAccel (QKeySequence (""));
3004 void Main::windowToggleNoteEditor()
3006 if (textEditor->showWithMain() )
3007 windowHideNoteEditor();
3009 windowShowNoteEditor();
3012 void Main::windowToggleHistory()
3014 if (currentMapEditor())
3015 currentMapEditor()->toggleHistoryWindow();
3018 void Main::updateNoteFlag()
3020 if (currentMapEditor())
3021 currentMapEditor()->updateNoteFlag();
3024 void Main::windowShowNoteEditor()
3026 textEditor->setShowWithMain(true);
3028 actionViewToggleNoteEditor->setOn (true);
3031 void Main::windowHideNoteEditor()
3033 textEditor->setShowWithMain(false);
3035 actionViewToggleNoteEditor->setOn (false);
3038 void Main::windowNextEditor()
3040 if (tabWidget->currentPageIndex() < tabWidget->count())
3041 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3044 void Main::windowPreviousEditor()
3046 if (tabWidget->currentPageIndex() >0)
3047 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3050 void Main::standardFlagChanged()
3052 currentMapEditor()->toggleStandardFlag(sender()->name());
3055 void Main::testFunction()
3057 currentMapEditor()->testFunction();
3060 void Main::helpDoc()
3063 #if defined(Q_OS_MACX)
3064 docpath="./vym.app/Contents/vym.pdf";
3066 // default path in SUSE LINUX
3067 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3070 if (!QFile (docpath).exists() )
3072 // relative path for easy testing in tarball
3073 docpath="doc/vym.pdf";
3074 if (!QFile (docpath).exists() )
3076 // relative path for testing while still writing vym.tex
3077 docpath="doc/tex/vym.pdf";
3078 if (!QFile (docpath).exists() )
3080 // Try yet another one for Knoppix
3081 docpath="/usr/share/doc/packages/vym/vym.pdf";
3082 if (!QFile (docpath).exists() )
3084 QMessageBox::critical(0,
3085 tr("Critcal error"),
3086 tr("Couldn't find the documentation\n"
3087 "vym.pdf in various places."));
3094 Process *pdfProc = new Process();
3095 pdfProc->clearArguments();
3096 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
3097 pdfProc->addArgument( docpath);
3099 if ( !pdfProc->start() )
3102 QMessageBox::warning(0,
3104 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3105 tr("Please use Settings->")+tr("Set application to open PDF files"));
3112 void Main::helpAbout()
3115 ad.setName ("aboutwindow");
3116 ad.setMinimumSize(500,500);
3117 ad.resize (QSize (500,500));
3121 void Main::helpAboutQT()
3123 QMessageBox::aboutQt( this, "Qt Application Example" );