1 #include "mainwindow.h"
3 #include <qstatusbar.h>
4 #include <qmessagebox.h>
6 #include <qapplication.h>
10 #include <qfiledialog.h>
12 #include <qcolordialog.h>
14 #include <qinputdialog.h>
15 //#include <qdatetime.h> // for random seed
22 #include "icons/filenew.xpm"
23 #include "icons/fileopen.xpm"
24 #include "icons/filesave.xpm"
25 #include "icons/fileprint.xpm"
26 #include "icons/editundo.xpm"
27 #include "icons/editredo.xpm"
28 #include "icons/editcopy.xpm"
29 #include "icons/editcut.xpm"
30 #include "icons/editpaste.xpm"
31 #include "icons/editmoveup.xpm"
32 #include "icons/editmovedown.xpm"
33 #include "icons/formatcoloritem.xpm"
34 #include "icons/formatcolorbranch.xpm"
35 #include "icons/formatcolorpicker.xpm"
36 #include "icons/viewzoomreset.xpm"
37 #include "icons/viewzoomin.xpm"
38 #include "icons/viewzoomout.xpm"
39 #include "icons/modecolor.xpm"
40 #include "icons/modelink.xpm"
41 #include "icons/modecopy.xpm"
42 #include "icons/flag-questionmark.xpm"
43 #include "icons/flag-exclamationmark.xpm"
44 #include "icons/flag-hook-green.xpm"
45 #include "icons/flag-cross-red.xpm"
46 #include "icons/flag-stopsign.xpm"
47 #include "icons/flag-smiley-good.xpm"
48 #include "icons/flag-smiley-sad.xpm"
49 #include "icons/flag-clock.xpm"
50 #include "icons/flag-lamp.xpm"
51 #include "icons/flag-arrow-up.xpm"
52 #include "icons/flag-arrow-down.xpm"
53 #include "icons/flag-thumb-up.xpm"
54 #include "icons/flag-thumb-down.xpm"
55 #include "icons/flag-heart.xpm"
56 #include "icons/flag-flash.xpm"
57 #include "icons/flag-lifebelt.xpm"
58 #include "icons/flag-note.xpm"
59 #include "icons/flag-url.xpm"
60 #include "icons/flag-vymlink.xpm"
61 #include "icons/flag-scrolled-right.xpm"
62 #include "icons/flag-tmpUnscrolled-right.xpm"
64 #include "aboutdialog.h"
65 #include "exporthtmldialog.h"
66 #include "exportoofiledialog.h"
68 #include "exportxhtmldialog.h"
70 #include "flagrowobj.h"
72 #include "mapeditor.h"
77 #include "showtextdialog.h"
78 #include "texteditor.h"
81 extern TextEditor *textEditor;
82 extern Main *mainWindow;
83 extern QString tmpVymDir;
84 extern QString clipboardDir;
85 extern bool clipboardEmpty;
86 extern int statusbarTime;
87 extern FlagRowObj* standardFlagsDefault;
88 extern FlagRowObj* systemFlagsDefault;
90 extern QPtrList <QAction> actionListBranches;
92 extern QAction* actionFileSave;
93 extern QAction* actionFilePrint;
94 extern QAction* actionEditUndo;
95 extern QAction* actionEditRedo;
96 extern QAction *actionEditCopy;
97 extern QAction *actionEditCut;
98 extern QAction *actionEditPaste;
99 extern QAction *actionEditMoveUp;
100 extern QAction *actionEditMoveDown;
101 extern QAction *actionEditToggleScroll;
102 extern QAction* actionEditOpenURL;
103 extern QAction* actionEditURL;
104 extern QAction* actionEditHeading2URL;
105 extern QAction* actionEditBugzilla2URL;
106 extern QAction* actionEditFATE2URL;
107 extern QAction *actionEditOpenVymLink;
108 extern QAction *actionEditVymLink;
109 extern QAction *actionEditDeleteVymLink;
110 extern QAction *actionEditMapInfo;
111 extern QAction *actionEditHeading;
112 extern QAction *actionEditDelete;
113 extern QAction *actionEditAddBranch;
114 extern QAction *actionEditAddBranchHere;
115 extern QAction *actionEditAddBranchAbove;
116 extern QAction *actionEditAddBranchBelow;
117 extern QAction *actionEditRemoveBranchHere;
118 extern QAction *actionEditRemoveChilds;
119 extern QAction *actionEditImportAdd;
120 extern QAction *actionEditImportReplace;
121 extern QAction *actionEditSaveBranch;
122 extern QAction *actionEditSelectFirst;
123 extern QAction *actionEditSelectLast;
124 extern QAction *actionEditLoadImage;
125 extern QAction *actionEditToggleFloatExport;
127 extern QAction* actionFormatColor;
128 extern QAction* actionFormatPickColor;
129 extern QAction* actionFormatColorBranch;
130 extern QAction* actionFormatColorSubtree;
131 extern QAction* actionFormatLinkColorHint;
132 extern QAction* actionFormatBackColor;
133 extern QAction* actionFormatLinkColor;
134 extern QAction *actionFormatIncludeImagesVer;
135 extern QAction *actionFormatIncludeImagesHor;
137 extern QActionGroup* actionGroupModModes;
138 extern QAction* actionModModeColor;
139 extern QAction* actionModModeLink;
140 extern QAction* actionModModeCopy;
142 extern QActionGroup *actionGroupFormatFrameTypes;
143 extern QAction *actionFormatFrameNone;
144 extern QAction *actionFormatFrameRectangle;
146 extern QActionGroup *actionGroupFormatLinkStyles;
147 extern QAction *actionFormatLinkStyleLine;
148 extern QAction *actionFormatLinkStyleParabel;
149 extern QAction *actionFormatLinkStylePolyLine;
150 extern QAction *actionFormatLinkStylePolyParabel;
151 extern QAction *actionFormatHideLinkUnselected;
153 extern QAction *actionViewToggleNoteEditor;
155 extern QAction* actionSettingsAutoedit;
156 extern QAction* actionSettingsAutoselectHeading;
157 extern QAction* actionSettingsAutoselectHeading;
158 extern QAction* actionSettingsAutoselectText;
159 extern QAction* actionSettingsPasteNewHeading;
160 extern QAction* actionSettingsUseDelKey;
161 extern QAction* actionSettingsUseFlagGroups;
163 extern QPopupMenu* branchContextMenu;
164 extern QPopupMenu* branchAddContextMenu;
165 extern QPopupMenu* branchRemoveContextMenu;
166 extern QPopupMenu* branchLinksContextMenu;
167 extern QPopupMenu* branchLinksContextMenuDup;
168 extern QPopupMenu* floatimageContextMenu;
169 extern QPopupMenu* saveImageFormatMenu;
170 extern QPopupMenu* canvasContextMenu;
171 extern QPopupMenu* lastMapsMenu;
172 extern QPopupMenu* importMenu;
173 extern QPopupMenu* exportMenu;
174 extern QPopupMenu* exportImageFormatMenu;
177 extern Settings settings;
178 extern Options options;
180 #if defined(Q_OS_LINUX)
181 extern void qt_wait_for_window_manager( QWidget* w );
184 Main::Main(QWidget* parent, const char* name, WFlags f) :
185 QMainWindow(parent,name,f)
189 setCaption ("VYM - View Your Mind");
191 // Load window settings
192 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
193 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
194 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
195 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
198 // Create unique temporary directory
199 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
201 // Create direcctory for clipboard
202 clipboardDir=tmpVymDir+"/clipboard";
203 QDir d(clipboardDir);
204 d.mkdir (clipboardDir,true);
205 makeSubDirs (clipboardDir);
208 // FIXME not used currently
209 // Set random seed (random used for object IDs)
210 // QTime t = QTime::currentTime(); // set random seed
211 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
214 // Initialize some settings, which are platform dependant
217 // application to open URLs
218 p="/vym/mainwindow/readerURL";
219 #if defined(Q_OS_LINUX)
220 s=settings.readEntry (p,"konqueror");
222 #if defined(Q_OS_MACX)
223 s=settings.readEntry (p,"/usr/bin/open");
225 s=settings.readEntry (p,"mozilla");
228 settings.writeEntry( p,s);
230 // application to open PDFs
231 p="/vym/mainwindow/readerPDF";
232 #if defined(Q_OS_LINUX)
233 s=settings.readEntry (p,"acroread");
235 #if defined(Q_OS_MACX)
236 s=settings.readEntry (p,"/usr/bin/open");
238 s=settings.readEntry (p,"acroread");
241 settings.writeEntry( p,s);
246 // Create tab widget which holds the maps
247 tabWidget= new QTabWidget (this);
248 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
249 this, SLOT( editorChanged( QWidget * ) ) );
251 setCentralWidget(tabWidget);
255 setupFormatActions();
259 setupSettingsActions();
261 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
264 // After menu is created, we can enable some actions
265 actionFilePrint->setEnabled (true);
270 // Initialize Find window
271 findWindow=new FindWindow(NULL,"findwindow");
272 connect (findWindow, SIGNAL( findButton(QString) ),
273 this, SLOT(editFind(QString) ) );
274 connect (findWindow, SIGNAL( somethingChanged() ),
275 this, SLOT(editFindChanged() ) );
277 // Connect TextEditor, so that we can update flags if text changes
278 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
286 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
287 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
288 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
289 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
291 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
292 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
294 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
295 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
296 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
297 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
298 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
299 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
302 int maps=lastMaps.count();
303 settings.writeEntry( "/vym/lastMaps/number",maps );
304 for (int i=1;i<=maps;i++)
306 QStringList::Iterator it = lastMaps.at(i-1);
307 s=QString("/vym/lastMaps/map-%1").arg(i);
308 if (!s.isEmpty() && i<=maxLastMaps)
309 settings.writeEntry (s, *it);
313 // To make the texteditor save its settings, call the destructor
316 // Remove temporary directory
317 removeDir (QDir(tmpVymDir));
320 void Main::loadCmdLine()
322 /* TODO draw some kind of splashscreen while loading...
328 QStringList flist=options.getFileList();
329 QStringList::Iterator it=flist.begin();
331 while (it !=flist.end() )
333 fileLoad (*it, NewMap);
339 void Main::statusMessage(const QString &s)
341 statusBar()->message (s);
344 void Main::closeEvent (QCloseEvent* )
350 void Main::setupFileActions()
352 QToolBar *tb = new QToolBar( this );
353 tb->setLabel( "File Actions" );
354 QPopupMenu *menu = new QPopupMenu( this );
355 menuBar()->insertItem( tr( "&File" ), menu );
357 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
360 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
361 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
365 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
366 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
370 lastMapsMenu = new QPopupMenu (this);
372 menu->insertItem (tr("Open Recent"),lastMapsMenu );
373 menu->insertSeparator();
375 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
376 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
381 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
382 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
385 menu->insertSeparator();
387 importMenu = new QPopupMenu (this);
388 menu->insertItem (tr("Import"),importMenu );
390 a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
391 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
392 a->addTo (importMenu);
394 a = new QAction( tr( "Import")+" "+tr("Mind Manager" ), QPixmap(), tr("Mind Manager")+QString("..."), 0, this, "importMM" );
395 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
396 a->addTo (importMenu);
398 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
399 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
400 a->addTo( importMenu);
402 exportMenu = new QPopupMenu (this);
403 menu->insertItem (tr("Export"),exportMenu );
405 menu->insertSeparator();
408 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" );
409 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
414 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
415 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
418 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
419 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
425 void Main::setupEditActions()
427 QToolBar *tb = new QToolBar( this );
428 tb->setLabel( "Edit Actions" );
429 QPopupMenu *menu = new QPopupMenu( this );
430 menuBar()->insertItem( tr( "&Edit" ), menu );
434 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
435 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
436 a->setEnabled (false);
441 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
443 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
444 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
449 menu->insertSeparator();
450 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
451 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
452 a->setEnabled (false);
456 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
457 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
458 a->setEnabled (false);
462 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
463 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
464 a->setEnabled (false);
469 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
470 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
471 a->setEnabled (false);
474 actionListBranches.append(a);
477 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
478 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
479 a->setEnabled (false);
482 actionListBranches.append(a);
483 actionEditMoveDown=a;
486 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
487 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
488 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
489 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
490 #if defined(Q_OS_MACX)
491 actionEditToggleScroll=alt;
493 actionEditToggleScroll=a;
495 actionEditToggleScroll->setEnabled (false);
496 actionEditToggleScroll->addTo( tb );
497 actionEditToggleScroll->addTo( menu );
498 actionListBranches.append(actionEditToggleScroll);
500 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
501 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
504 menu->insertSeparator();
506 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
507 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
510 menu->insertSeparator();
512 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
513 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
515 a->setEnabled (false);
518 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
519 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
520 a->setEnabled (false);
521 actionListBranches.append(a);
524 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
525 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
526 a->setEnabled (false);
527 actionListBranches.append(a);
528 actionEditHeading2URL=a;
530 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
531 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
532 a->setEnabled (false);
533 actionListBranches.append(a);
534 actionEditBugzilla2URL=a;
536 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
537 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
538 a->setEnabled (false);
539 actionListBranches.append(a);
540 actionEditFATE2URL=a;
542 a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flag_vymlink_xpm), tr( "Jump to map" ), 0, this, "jumpMap" );
543 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
545 a->setEnabled (false);
546 actionEditOpenVymLink=a;
548 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
549 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
550 a->setEnabled (false);
551 actionListBranches.append(a);
554 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
555 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
556 a->setEnabled (false);
557 actionEditDeleteVymLink=a;
559 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
560 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
561 a->setEnabled (true);
564 menu->insertSeparator();
566 // Shortcuts to modify heading:
567 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
568 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
569 actionListBranches.append(a);
570 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
571 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
572 actionListBranches.append(a);
574 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
575 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
576 a->setEnabled (false);
578 actionListBranches.append(a);
580 // Shortcut to delete selection
581 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
582 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
583 a->setEnabled (false);
586 // Shortcut to add branch
587 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
588 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
589 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
590 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
591 a->setEnabled (false);
592 actionListBranches.append(a);
593 #if defined (Q_OS_MACX)
594 // In OSX show different shortcut in menues, the keys work independtly always
595 actionEditAddBranch=alt;
597 actionEditAddBranch=a;
600 // Add branch by inserting it at selection
601 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
602 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
603 a->setEnabled (false);
604 actionListBranches.append(a);
605 actionEditAddBranchHere=a;
606 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
607 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
608 actionListBranches.append(a);
611 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
612 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
613 a->setEnabled (false);
614 actionListBranches.append(a);
615 actionEditAddBranchAbove=a;
616 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
617 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
618 actionListBranches.append(a);
621 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
622 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
623 a->setEnabled (false);
624 actionListBranches.append(a);
625 actionEditAddBranchBelow=a;
626 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
627 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
628 actionListBranches.append(a);
630 // Import at selection (adding to selection)
631 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
632 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
633 a->setEnabled (false);
634 actionListBranches.append(a);
635 actionEditImportAdd=a;
637 // Import at selection (replacing selection)
638 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
639 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
640 a->setEnabled (false);
641 actionListBranches.append(a);
642 actionEditImportReplace=a;
645 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
646 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
647 a->setEnabled (false);
648 actionListBranches.append(a);
649 actionEditSaveBranch=a;
651 // Only remove branch, not its childs
652 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
653 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
654 a->setEnabled (false);
655 actionListBranches.append(a);
656 actionEditRemoveBranchHere=a;
658 // Only remove childs of a branch
659 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
660 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
661 a->setEnabled (false);
662 actionListBranches.append(a);
663 actionEditRemoveChilds=a;
665 // Shortcuts for navigating with cursor:
666 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
667 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
668 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
669 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
670 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
671 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
672 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
673 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
674 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
675 a->setEnabled (false);
677 actionListBranches.append(a);
678 actionEditSelectFirst=a;
679 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
680 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
681 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
682 a->setEnabled (false);
684 actionListBranches.append(a);
685 actionEditSelectLast=a;
687 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
688 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
689 actionEditLoadImage=a;
694 void Main::setupFormatActions()
696 QPopupMenu *menu = new QPopupMenu( this );
697 menuBar()->insertItem( tr( "&Format" ), menu );
699 QToolBar *tb = new QToolBar( this );
703 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
704 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
705 actionFormatColor->addTo( tb );
706 actionFormatColor->addTo( menu );
707 a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(formatcolorpicker_xpm), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" );
708 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
709 a->setEnabled (false);
712 actionListBranches.append(a);
713 actionFormatPickColor=a;
714 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
715 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
716 a->setEnabled (false);
719 actionListBranches.append(a);
720 actionFormatColorBranch=a;
721 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
722 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
723 a->setEnabled (false);
726 actionListBranches.append(a);
727 actionFormatColorSubtree=a;
729 menu->insertSeparator();
730 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
731 actionGroupFormatLinkStyles->setExclusive (true);
732 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
733 a->setToggleAction(true);
734 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
735 actionFormatLinkStyleLine=a;
736 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
737 a->setToggleAction(true);
738 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
739 actionFormatLinkStyleParabel=a;
740 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
741 a->setToggleAction(true);
742 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
743 actionFormatLinkStylePolyLine=a;
744 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
745 a->setToggleAction(true);
746 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
747 actionFormatLinkStylePolyParabel=a;
748 actionGroupFormatLinkStyles->addTo (menu);
750 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
751 actionGroupFormatFrameTypes->setExclusive (true);
752 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
753 a->setToggleAction(true);
754 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
755 actionFormatFrameNone=a;
756 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
757 a->setToggleAction(true);
758 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
759 actionFormatFrameRectangle=a;
761 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
762 a->setToggleAction(true);
763 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
764 actionFormatIncludeImagesVer=a;
766 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
767 a->setToggleAction(true);
768 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
769 actionFormatIncludeImagesHor=a;
771 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
772 a->setToggleAction(true);
773 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
774 actionFormatHideLinkUnselected=a;
776 menu->insertSeparator();
777 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
778 a->setToggleAction(true);
779 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
781 actionFormatLinkColorHint=a;
783 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
784 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
785 actionFormatLinkColor->addTo( menu );
786 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
787 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
788 actionFormatBackColor->addTo( menu );
792 void Main::setupViewActions()
794 QToolBar *tb = new QToolBar( this );
795 tb->setLabel( "View Actions" );
796 QPopupMenu *menu = new QPopupMenu( this );
797 menuBar()->insertItem( tr( "&View" ), menu );
800 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
801 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
804 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
805 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
808 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
809 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
812 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
813 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
814 a->setToggleAction(true);
815 if (textEditor->showWithMain())
821 actionViewToggleNoteEditor=a;
822 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
823 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
825 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
826 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
831 void Main::setupModeActions()
833 //QPopupMenu *menu = new QPopupMenu( this );
834 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
836 QToolBar *tb = new QToolBar( this );
837 tb->setLabel( tr ("Modes when using modifiers") );
839 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
840 actionGroupModModes->setExclusive (true);
841 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
842 a->setToggleAction(true);
845 actionModModeColor=a;
847 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
848 a->setToggleAction(true);
852 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
853 a->setToggleAction(true);
859 void Main::setupFlagActions()
861 // Create System Flags
862 systemFlagsDefault = new FlagRowObj ();
863 systemFlagsDefault->setVisibility (false);
864 systemFlagsDefault->setName ("systemFlagsDef");
866 FlagObj *fo = new FlagObj ();
867 fo->load(QPixmap(flag_note_xpm));
869 fo->setToolTip(tr("Note","Systemflag"));
870 systemFlagsDefault->addFlag (fo); // makes deep copy
872 fo->load(QPixmap(flag_url_xpm));
874 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
875 systemFlagsDefault->addFlag (fo);
877 fo->load(QPixmap(flag_vymlink_xpm));
878 fo->setName("vymLink");
879 fo->setToolTip(tr("Link to another vym map","Systemflag"));
880 systemFlagsDefault->addFlag (fo);
882 fo->load(QPixmap(flag_scrolled_right_xpm));
883 fo->setName("scrolledright");
884 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
885 systemFlagsDefault->addFlag (fo);
887 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
888 fo->setName("tmpUnscrolledright");
889 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
890 systemFlagsDefault->addFlag (fo);
892 // Create Standard Flags
893 standardFlagsDefault = new FlagRowObj ();
894 standardFlagsDefault->setVisibility (false);
895 standardFlagsDefault->setName ("standardFlagsDef");
897 fo->load(QPixmap(flag_exclamationmark_xpm));
898 fo->setName ("exclamationmark");
899 fo->setGroup("standard-mark");
900 fo->setToolTip(tr("Take care!","Standardflag"));
901 standardFlagsDefault->addFlag (fo); // makes deep copy
903 fo->load(QPixmap(flag_questionmark_xpm));
904 fo->setName("questionmark");
905 fo->setGroup("standard-mark");
906 fo->setToolTip(tr("Really?","Standardflag"));
907 standardFlagsDefault->addFlag (fo);
909 fo->load(QPixmap(flag_hook_green_xpm));
910 fo->setName("hook-green");
911 fo->setGroup("standard-hook");
912 fo->setToolTip(tr("ok!","Standardflag"));
913 standardFlagsDefault->addFlag (fo);
915 fo->load(QPixmap(flag_cross_red_xpm));
916 fo->setName("cross-red");
917 fo->setGroup("standard-hook");
918 fo->setToolTip(tr("Not ok!","Standardflag"));
919 standardFlagsDefault->addFlag (fo);
921 fo->load(QPixmap(flag_stopsign_xpm));
922 fo->setName("stopsign");
923 fo->setToolTip(tr("This won't work!","Standardflag"));
924 standardFlagsDefault->addFlag (fo);
926 fo->load(QPixmap(flag_smiley_good_xpm));
927 fo->setName("smiley-good");
928 fo->setGroup("standard-smiley");
929 fo->setToolTip(tr("Good","Standardflag"));
930 standardFlagsDefault->addFlag (fo);
932 fo->load(QPixmap(flag_smiley_sad_xpm));
933 fo->setName("smiley-sad");
934 fo->setGroup("standard-smiley");
935 fo->setToolTip(tr("Bad","Standardflag"));
936 standardFlagsDefault->addFlag (fo);
938 fo->load(QPixmap(flag_clock_xpm));
939 fo->setName("clock");
940 fo->setToolTip(tr("Time critical","Standardflag"));
941 standardFlagsDefault->addFlag (fo);
943 fo->load(QPixmap(flag_lamp_xpm));
945 fo->setToolTip(tr("Idea!","Standardflag"));
946 standardFlagsDefault->addFlag (fo);
948 fo->load(QPixmap(flag_arrow_up_xpm));
949 fo->setName("arrow-up");
950 fo->setGroup("standard-arrow");
951 fo->setToolTip(tr("Important","Standardflag"));
952 standardFlagsDefault->addFlag (fo);
954 fo->load(QPixmap(flag_arrow_down_xpm));
955 fo->setName("arrow-down");
956 fo->setGroup("standard-arrow");
957 fo->setToolTip(tr("Unimportant","Standardflag"));
958 standardFlagsDefault->addFlag (fo);
960 fo->load(QPixmap(flag_thumb_up_xpm));
961 fo->setName("thumb-up");
962 fo->setGroup("standard-thumb");
963 fo->setToolTip(tr("I like this","Standardflag"));
964 standardFlagsDefault->addFlag (fo);
966 fo->load(QPixmap(flag_thumb_down_xpm));
967 fo->setName("thumb-down");
968 fo->setGroup("standard-thumb");
969 fo->setToolTip(tr("I like this","Standardflag"));
970 fo->setToolTip(tr("I do not like this","Standardflag"));
971 standardFlagsDefault->addFlag (fo);
973 fo->load(QPixmap(flag_heart_xpm));
974 fo->setName("heart");
975 fo->setToolTip(tr("I just love... ","Standardflag"));
976 standardFlagsDefault->addFlag (fo);
978 fo->load(QPixmap(flag_flash_xpm));
979 fo->setName("flash");
980 fo->setToolTip(tr("Dangerous","Standardflag"));
981 standardFlagsDefault->addFlag (fo);
983 fo->load(QPixmap(flag_lifebelt_xpm));
984 fo->setName("lifebelt");
985 fo->setToolTip(tr("This will help","Standardflag"));
986 standardFlagsDefault->addFlag (fo);
989 standardFlagsDefault->makeToolbar(this, "Standard Flags");
993 void Main::setupSettingsActions()
995 QPopupMenu *menu = new QPopupMenu( this );
996 menuBar()->insertItem( tr( "&Settings" ), menu );
1001 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1002 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1005 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1006 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1009 menu->insertSeparator();
1010 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1011 a->setToggleAction(true);
1012 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1014 actionSettingsAutoedit=a;
1016 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1017 a->setToggleAction(true);
1018 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1020 actionSettingsAutoselectHeading=a;
1022 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1023 a->setToggleAction(true);
1024 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1026 actionSettingsAutoselectText=a;
1028 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1029 a->setToggleAction(true);
1030 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1032 actionSettingsPasteNewHeading=a;
1034 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1035 a->setToggleAction(true);
1036 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1038 actionSettingsUseDelKey=a;
1040 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1041 a->setToggleAction(true);
1042 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1044 actionSettingsUseFlagGroups=a;
1048 void Main::setupTestActions()
1050 QPopupMenu *menu = new QPopupMenu( this );
1051 menuBar()->insertItem( tr( "&Test" ), menu );
1054 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1055 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1060 void Main::setupHelpActions()
1062 QPopupMenu *menu = new QPopupMenu( this );
1063 menuBar()->insertItem( tr( "&Help" ), menu );
1066 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1067 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1070 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1071 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1074 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1075 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1080 void Main::setupContextMenus()
1084 // Context Menu for branch or mapcenter
1085 branchContextMenu =new QPopupMenu (this);
1088 branchAddContextMenu =new QPopupMenu (this);
1089 actionEditPaste->addTo ( branchAddContextMenu );
1090 actionEditAddBranch->addTo ( branchAddContextMenu );
1091 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1092 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1093 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1094 branchAddContextMenu->insertSeparator();
1095 actionEditLoadImage->addTo( branchAddContextMenu );
1096 branchAddContextMenu->insertSeparator();
1097 actionEditImportAdd->addTo ( branchAddContextMenu );
1098 actionEditImportReplace->addTo ( branchAddContextMenu );
1101 branchRemoveContextMenu =new QPopupMenu (this);
1102 actionEditCut->addTo ( branchRemoveContextMenu );
1103 actionEditDelete->addTo ( branchRemoveContextMenu );
1104 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
1105 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1107 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1108 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1110 actionEditSaveBranch->addTo( branchContextMenu );
1112 branchContextMenu->insertSeparator();
1113 actionEditOpenURL->addTo ( branchContextMenu );
1114 actionEditURL->addTo ( branchContextMenu );
1115 actionEditHeading2URL->addTo ( branchContextMenu );
1116 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1118 actionEditBugzilla2URL->addTo( branchContextMenu );
1119 actionEditFATE2URL->addTo( branchContextMenu );
1121 branchContextMenu->insertSeparator();
1122 actionEditOpenVymLink->addTo ( branchContextMenu );
1123 actionEditVymLink->addTo ( branchContextMenu );
1124 actionEditDeleteVymLink->addTo ( branchContextMenu );
1126 branchContextMenu->insertSeparator();
1127 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1129 branchContextMenu->insertSeparator();
1130 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1131 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1132 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1134 // Context Menu for links in a branch menu
1135 // This will be populated "on demand" in MapEditor::updateActions
1136 branchContextMenu->insertSeparator();
1137 branchLinksContextMenu =new QPopupMenu (this);
1138 branchLinksContextMenuDup =new QPopupMenu (this);
1139 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1140 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1142 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1143 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1145 // Context menu for floatimage
1146 floatimageContextMenu =new QPopupMenu (this);
1147 saveImageFormatMenu=new QPopupMenu (this);
1148 exportImageFormatMenu=new QPopupMenu (this);
1150 QStrList fmt = QImage::outputFormats();
1151 for (const char* f = fmt.first(); f; f = fmt.next())
1153 saveImageFormatMenu->insertItem( f );
1154 exportImageFormatMenu->insertItem( f );
1156 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1157 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1158 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1160 floatimageContextMenu->insertSeparator();
1161 actionEditCopy->addTo( floatimageContextMenu );
1162 actionEditCut->addTo( floatimageContextMenu );
1164 floatimageContextMenu->insertSeparator();
1165 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1166 a->setToggleAction(true);
1167 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1168 a->addTo( floatimageContextMenu);
1169 actionEditToggleFloatExport=a;
1171 floatimageContextMenu->insertSeparator();
1172 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1174 exportMenu->insertItem ( tr("Export as Image"),exportImageFormatMenu);
1176 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1177 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1178 a->addTo (exportMenu);
1180 a = new QAction( tr( "Export as webpage (XHTML)" ), QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" );
1181 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1182 a->addTo( exportMenu );
1184 a = new QAction( tr( "Export as ASCII")+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" );
1185 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1186 a->addTo( exportMenu );
1188 a = new QAction( tr( "Export as Taskjuggler")+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
1189 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1190 a->addTo( exportMenu );
1192 a = new QAction( tr( "Export as LaTeX")+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1193 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1194 a->addTo( exportMenu );
1196 a = new QAction( tr( "Export as XML" ), QPixmap(), "XML...", 0, this, "exportXML" );
1197 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1198 a->addTo( exportMenu );
1200 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1202 a = new QAction( tr( "Export as HTML" ), QPixmap(), "HTML...", 0, this, "exportHTML");
1203 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1204 a->addTo( exportMenu );
1208 // Context menu for canvas
1209 canvasContextMenu =new QPopupMenu (this);
1210 actionEditMapInfo->addTo( canvasContextMenu );
1211 canvasContextMenu->insertSeparator();
1212 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1213 canvasContextMenu->insertSeparator();
1214 actionFormatLinkColorHint->addTo( canvasContextMenu );
1215 actionFormatLinkColor->addTo( canvasContextMenu );
1216 actionFormatBackColor->addTo( canvasContextMenu );
1218 // Menu for last opened files
1219 // Read settings initially
1221 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1222 for (int i=1;i<=j;i++)
1224 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1225 if (!s.isEmpty() && j<=maxLastMaps)
1228 setupLastMapsMenu();
1229 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1232 void Main::setupLastMapsMenu()
1234 // Remove double entries
1235 QStringList::Iterator it=lastMaps.begin();
1236 QStringList::Iterator jt;
1237 while (it!=lastMaps.end() )
1241 while (jt!=lastMaps.end() )
1244 jt=lastMaps.remove(jt);
1251 // Limit length of list to maxLastMaps
1252 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1254 // build Menu from lastMaps string list
1255 lastMapsMenu->clear();
1256 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1257 lastMapsMenu->insertItem (*it );
1261 void Main::hideEvent (QHideEvent * )
1263 if (!textEditor->isMinimized() ) textEditor->hide();
1266 void Main::showEvent (QShowEvent * )
1268 if (textEditor->showWithMain()) textEditor->showNormal();
1271 bool Main::reallyWriteDirectory(const QString &dir)
1273 QStringList eList = QDir(dir).entryList();
1274 if (eList.first() ==".") eList.pop_front(); // remove "."
1275 if (eList.first() =="..") eList.pop_front(); // remove "."
1276 if (!eList.isEmpty())
1278 QMessageBox mb( __VYM,
1279 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1280 QMessageBox::Warning,
1282 QMessageBox::Cancel | QMessageBox::Default,
1283 QMessageBox::QMessageBox::NoButton );
1285 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1286 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1289 case QMessageBox::Yes:
1292 case QMessageBox::Cancel:
1300 QString Main::browseDirectory (const QString &caption)
1302 QFileDialog fd(this,caption);
1303 fd.setMode (QFileDialog::DirectoryOnly);
1304 fd.setCaption(__VYM " - "+caption);
1307 if ( fd.exec() == QDialog::Accepted )
1308 return fd.selectedFile();
1313 MapEditor* Main::currentMapEditor() const
1315 if ( tabWidget->currentPage() &&
1316 tabWidget->currentPage()->inherits( "MapEditor" ) )
1317 return (MapEditor*)tabWidget->currentPage();
1321 //TODO not used now, maybe use this for overview window later
1322 void Main::newView()
1324 // Open a new view... have it delete when closed.
1325 Main *m = new Main(0, 0, WDestructiveClose);
1326 qApp->setMainWidget(m);
1328 qApp->setMainWidget(0);
1331 void Main::editorChanged(QWidget *)
1333 // Unselect all possibly selected objects
1334 // (Important to update note editor)
1337 for (i=0;i<=tabWidget->count() -1;i++)
1340 me=(MapEditor*)tabWidget->page(i);
1343 currentMapEditor()->reselect();
1345 // Update actions to in menus and toolbars according to editor
1346 currentMapEditor()->updateActions();
1349 void Main::fileNew()
1351 QString fn="unnamed";
1352 MapEditor* medit = new MapEditor (tabWidget, true);
1353 tabWidget->addTab (medit,fn);
1354 tabWidget->showPage(medit);
1355 medit->viewport()->setFocus();
1356 // For the very first map we do not have flagrows yet...
1357 medit->select("mc:");
1360 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1362 ErrorCode err=success;
1364 // fn is usually the archive, mapfile the file after uncompressing
1367 // Make fn absolute (needed for unzip)
1368 fn=QDir (fn).absPath();
1374 // Check, if map is already loaded
1376 while (i<=tabWidget->count() -1)
1378 me=(MapEditor*)tabWidget->page(i);
1379 if (me->getFilePath() == fn)
1381 // Already there, ask for confirmation
1382 QMessageBox mb( __VYM,
1383 tr("The map %1\nis already opened."
1384 "Opening the same map in multiple editors may lead \n"
1385 "to confusion when finishing working with vym."
1386 "Do you want to").arg(fn),
1387 QMessageBox::Warning,
1388 QMessageBox::Yes | QMessageBox::Default,
1389 QMessageBox::Cancel | QMessageBox::Escape,
1390 QMessageBox::QMessageBox::NoButton);
1391 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1392 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1395 case QMessageBox::Yes:
1397 i=tabWidget->count();
1399 case QMessageBox::Cancel:
1411 if ( !fn.isEmpty() )
1413 me = currentMapEditor();
1414 int tabIndex=tabWidget->currentPageIndex();
1415 // Check first, if mapeditor exists
1416 // If it is not default AND we want a new map,
1417 // create a new mapeditor in a new tab
1418 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1420 me = new MapEditor (tabWidget,true);
1421 tabWidget->addTab (me,fn);
1422 tabIndex=tabWidget->indexOf (me);
1423 tabWidget->setCurrentPage (tabIndex);
1426 // Check, if file exists (important for creating new files
1427 // from command line
1428 if (!QFile(fn).exists() )
1430 QMessageBox mb( __VYM,
1431 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1432 QMessageBox::Question,
1434 QMessageBox::Cancel | QMessageBox::Default,
1435 QMessageBox::QMessageBox::NoButton );
1437 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1438 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1441 case QMessageBox::Yes:
1443 currentMapEditor()->setFilePath(fn);
1444 tabWidget->setTabLabel (currentMapEditor(),
1445 currentMapEditor()->getFileName() );
1446 statusBar()->message( "Created " + fn , statusbarTime );
1449 case QMessageBox::Cancel:
1450 // don't create new map
1451 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1458 //tabWidget->currentPage() won't be NULL here, because of above...
1459 tabWidget->showPage(me);
1460 me->viewport()->setFocus();
1462 // Create temporary directory for packing
1463 char tmpdir1[]="/tmp/vym-XXXXXX";
1464 QString tmpMapDir=mkdtemp(tmpdir1);
1466 // Try to unzip file
1467 err=unzipDir (tmpMapDir,fn);
1471 me->setZipped(false);
1474 me->setZipped(true);
1476 // Look for mapname.xml
1477 mapfile= fn.left(fn.findRev(".",-1,true));
1478 mapfile=mapfile.section( '/', -1 );
1479 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1480 if (!file.exists() )
1482 // mapname.xml does not exist, well,
1483 // maybe some renamed the mapname.vym file...
1484 // Try to find any .xml in the toplevel
1485 // directory of the .vym file
1486 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1487 if (flist.count()==1)
1489 // Only one entry, take this one
1490 mapfile=tmpMapDir + "/"+flist.first();
1493 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1494 *it=tmpMapDir + "/" + *it;
1495 // TODO Multiple entries, load all (but only the first one into this ME)
1496 //mainWindow->fileLoadFromTmp (flist);
1497 //returnCode=1; // Silently forget this attempt to load
1498 qWarning ("MainWindow::load (fn) multimap found...");
1501 if (flist.isEmpty() )
1503 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1504 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1507 } //file doesn't exist
1509 mapfile=file.name();
1514 // Save existing filename in case we import
1515 QString fn_org=me->getFilePath();
1517 // Finally load map into mapEditor
1518 me->setFilePath (mapfile,fn);
1519 err=me->load(mapfile,lmode);
1521 // Restore old (maybe empty) filepath, if this is an import
1523 me->setFilePath (fn_org);
1526 // Finally check for errors and go home
1529 if (lmode==NewMap) fileCloseMap();
1530 statusBar()->message( "Could not load " + fn, statusbarTime );
1535 me->setFilePath (fn);
1536 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1537 if (fn.left(9)!="/tmp/vym-")
1539 // Only append to lastMaps if not loaded from a tmpDir
1540 // e.g. imported bookmarks are in a tmpDir
1541 lastMaps.prepend(me->getFilePath() );
1542 setupLastMapsMenu();
1544 actionFilePrint->setEnabled (true);
1546 statusBar()->message( "Loaded " + fn, statusbarTime );
1550 removeDir (QDir(tmpMapDir));
1556 void Main::fileLoad(const LoadMode &lmode)
1558 QFileDialog *fd=new QFileDialog( this);
1559 if (!lastFileDir.isEmpty())
1560 fd->setDir (lastFileDir);
1561 fd->setMode (QFileDialog::ExistingFiles);
1562 fd->addFilter ("XML (*.xml)");
1563 fd->addFilter ("VYM map (*.vym *.vyp)");
1567 fd->setCaption(tr("Load vym map"));
1570 fd->setCaption(tr("Import: Add vym map to selection"));
1573 fd->setCaption(tr("Import: Replace selection with vym map"));
1579 if ( fd->exec() == QDialog::Accepted )
1581 lastFileDir=fd->dirPath();
1582 QStringList flist = fd->selectedFiles();
1583 QStringList::Iterator it = flist.begin();
1584 while( it != flist.end() )
1587 fileLoad(*it, lmode);
1594 void Main::fileLoad()
1599 void Main::fileLoadLast(int i)
1601 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1604 void Main::fileSave(const SaveMode &savemode)
1606 // tmp dir for zipping
1610 ErrorCode err=success;
1612 QString safeFilePath;
1614 bool saveZipped=currentMapEditor()->saveZipped();
1616 MapEditor * me=currentMapEditor();
1619 QString fn=me->getFilePath();
1620 // filename=unnamed, filepath="" in constructor...
1621 if ( !fn.isEmpty() )
1623 // We have a filepath, go on saving
1624 // First remove existing file, we
1625 // don't want to add to old zip archives
1629 QMessageBox::warning( 0, tr( "Save Error" ),
1630 fn+ tr("\ncould not be removed before saving"));
1632 // Look, if we should zip the data:
1635 QMessageBox mb( __VYM,
1636 tr("The map %1\ndid not use the compressed "
1637 "vym file format.\nWriting it uncompressed will also write images \n"
1638 "and flags and thus may overwrite files in the "
1639 "given directory\n\nDo you want to write the map").arg(fn),
1640 QMessageBox::Warning,
1641 QMessageBox::Yes | QMessageBox::Default,
1643 QMessageBox::Cancel | QMessageBox::Escape);
1644 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1645 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1646 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1649 case QMessageBox::Yes:
1650 // save compressed (default file format)
1653 case QMessageBox::No:
1654 // save uncompressed
1657 case QMessageBox::Cancel:
1666 char tmpdir1[]="/tmp/vym-XXXXXX";
1667 tmpMapDir=mkdtemp(tmpdir1);
1669 safeFilePath=me->getFilePath();
1670 me->setFilePath (tmpMapDir+"/"+
1671 me->getMapName()+ ".xml",
1673 me->save (savemode);
1674 me->setFilePath (safeFilePath);
1676 zipDir (tmpMapDir,fn);
1681 safeFilePath=me->getFilePath();
1682 me->setFilePath (fn, safeFilePath);
1683 me->save (savemode);
1684 me->setFilePath (safeFilePath);
1686 } // filepath available
1689 // We have no filepath yet,
1690 // call fileSaveAs() now, this will call fileSave()
1692 fileSaveAs(savemode);
1696 if (me->saveZipped())
1699 removeDir (QDir(tmpMapDir));
1704 statusBar()->message(
1705 tr("Saved %1").arg(me->getFilePath()),
1707 lastMaps.prepend(me->getFilePath() );
1708 setupLastMapsMenu();
1710 statusBar()->message(
1711 tr("Couldn't save ").arg(me->getFilePath()),
1715 void Main::fileSave()
1717 fileSave (CompleteMap);
1720 void Main::fileSaveAs(const SaveMode& savemode)
1725 if (currentMapEditor())
1727 if (savemode==CompleteMap)
1728 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1730 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1731 if ( !fn.isEmpty() )
1733 // Check for existing file
1734 if (QFile (fn).exists())
1736 QMessageBox mb( __VYM,
1737 tr("The file %1\nexists already. Do you want to").arg(fn),
1738 QMessageBox::Warning,
1739 QMessageBox::Yes | QMessageBox::Default,
1740 QMessageBox::Cancel | QMessageBox::Escape,
1741 QMessageBox::QMessageBox::NoButton);
1742 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1743 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1746 case QMessageBox::Yes:
1749 case QMessageBox::Cancel:
1756 // New file, add extension to filename, if missing
1757 // This is always .vym or .vyp, depending on savemode
1758 if (savemode==CompleteMap)
1760 if (!fn.contains (".vym") && !fn.contains (".xml"))
1764 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1773 currentMapEditor()->setFilePath(fn);
1777 if (savemode==CompleteMap)
1778 tabWidget->setTabLabel (currentMapEditor(),
1779 currentMapEditor()->getFileName() );
1785 void Main::fileSaveAs()
1787 fileSaveAs (CompleteMap);
1790 void Main::fileImportKDEBookmarks()
1792 ImportKDEBookmarks im;
1794 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1795 currentMapEditor()->setFilePath ("");
1798 void Main::fileImportMM()
1802 QFileDialog *fd=new QFileDialog( this);
1803 if (!lastFileDir.isEmpty())
1804 fd->setDir (lastFileDir);
1805 fd->setMode (QFileDialog::ExistingFiles);
1806 fd->addFilter ("Mind Manager (*.mmap)");
1807 fd->setCaption(tr("Import")+" "+"Mind Manager");
1810 if ( fd->exec() == QDialog::Accepted )
1812 lastFileDir=fd->dirPath();
1813 QStringList flist = fd->selectedFiles();
1814 QStringList::Iterator it = flist.begin();
1815 while( it != flist.end() )
1818 if (im.transform() &&
1819 success==fileLoad (im.getTransformedFile(),NewMap) &&
1820 currentMapEditor() )
1821 currentMapEditor()->setFilePath ("");
1830 void Main::fileImportDir()
1832 if (currentMapEditor())
1833 currentMapEditor()->importDir();
1836 void Main::fileExportXML()
1838 if (currentMapEditor())
1840 QString dir=browseDirectory(tr("Export XML to directory"));
1841 if (dir !="" && reallyWriteDirectory(dir) )
1842 currentMapEditor()->exportXML(dir);
1846 void Main::fileExportHTML()
1848 if (currentMapEditor())
1850 ExportHTMLDialog dia(this);
1852 if (dia.exec()==QDialog::Accepted)
1854 QString dir=dia.getDir();
1855 if (reallyWriteDirectory(dir) )
1857 currentMapEditor()->exportXML (dia.getDir() );
1858 dia.doExport(currentMapEditor()->getMapName() );
1864 void Main::fileExportXHTML()
1867 if (currentMapEditor())
1869 ExportXHTMLDialog dia(this);
1870 dia.setFilePath (currentMapEditor()->getFilePath() );
1871 dia.setMapName (currentMapEditor()->getMapName() );
1874 if (dia.exec()==QDialog::Accepted)
1876 QString dir=dia.getDir();
1877 // Check, if warnings should be used before overwriting
1878 // the output directory
1881 ok=reallyWriteDirectory(dir);
1887 currentMapEditor()->exportXML (dia.getDir() );
1888 dia.doExport(currentMapEditor()->getMapName() );
1889 if (dia.hasChanged())
1890 currentMapEditor()->setChanged();
1896 void Main::fileExportImage(int item)
1898 if (currentMapEditor())
1900 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1902 if ( !fn.isEmpty() )
1903 currentMapEditor()->exportImage(fn,item);
1905 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1910 void Main::fileExportASCII()
1912 if (currentMapEditor())
1915 ex.setMapCenter(currentMapEditor()->getMapCenter());
1916 ex.addFilter ("TXT (*.txt)");
1917 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1918 if (ex.execDialog() ) ex.doExport();
1922 void Main::fileExportLaTeX()
1924 if (currentMapEditor())
1927 ex.setMapCenter(currentMapEditor()->getMapCenter());
1928 ex.addFilter ("Tex (*.tex)");
1929 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1930 if (ex.execDialog() ) ex.doExport();
1934 void Main::fileExportTaskjuggler()
1936 ExportTaskjuggler ex;
1937 if (currentMapEditor())
1939 ex.setMapCenter (currentMapEditor()->getMapCenter() );
1940 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
1941 ex.addFilter ("Taskjuggler (*.tj)");
1942 if (ex.execDialog()) ex.doExport();
1946 void Main::fileExportOOPresentation()
1948 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
1949 // FIXME add extra info in dialog
1950 //ImagePreview *p =new ImagePreview (fd);
1951 //fd->setContentsPreviewEnabled( TRUE );
1952 //fd->setContentsPreview( p, p );
1953 //fd->setPreviewMode( QFileDialog::Contents );
1954 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
1955 //fd->setDir (lastImageDir);
1958 if ( fd->exec() == QDialog::Accepted )
1960 QString fn=fd->selectedFile();
1961 //lastImageDir=fn.left(fn.findRev ("/"));
1962 if (currentMapEditor())
1963 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
1967 void Main::fileCloseMap()
1969 if (currentMapEditor())
1971 if (currentMapEditor()->hasChanged())
1973 QMessageBox mb( __VYM,
1974 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1975 QMessageBox::Warning,
1976 QMessageBox::Yes | QMessageBox::Default,
1978 QMessageBox::Cancel | QMessageBox::Escape );
1979 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1980 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1983 case QMessageBox::Yes:
1985 fileSave(CompleteMap);
1987 case QMessageBox::No:
1988 // close without saving
1990 case QMessageBox::Cancel:
1995 currentMapEditor()->closeMap();
1996 tabWidget->removePage(currentMapEditor());
1997 if (tabWidget->count()==0)
1998 actionFilePrint->setEnabled (false);
2002 void Main::filePrint()
2004 if (currentMapEditor())
2005 currentMapEditor()->print();
2008 void Main::fileExitVYM()
2010 // Check if one or more editors have changed
2013 for (i=0;i<=tabWidget->count() -1;i++)
2016 me=(MapEditor*)tabWidget->page(i);
2018 // If something changed, ask what to do
2019 if (me->isUnsaved())
2021 tabWidget->setCurrentPage(i);
2022 QMessageBox mb( __VYM,
2023 tr("This map is not saved yet. Do you want to"),
2024 QMessageBox::Warning,
2025 QMessageBox::Yes | QMessageBox::Default,
2027 QMessageBox::Cancel | QMessageBox::Escape );
2028 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2029 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2031 // Call undocumented function: setActiveWindow is only
2032 // possible, if widget is visible. This depends on
2034 #if defined(Q_OS_LINUX)
2035 qt_wait_for_window_manager( this);
2037 mb.setActiveWindow();
2038 switch( mb.exec() ) {
2039 case QMessageBox::Yes:
2040 // save (the changed editors) and exit
2041 fileSave(CompleteMap);
2043 case QMessageBox::No:
2044 // exit without saving
2046 case QMessageBox::Cancel:
2047 // don't save and don't exit
2051 } // loop over all MEs
2055 void Main::editUndo()
2057 if (currentMapEditor())
2058 currentMapEditor()->undo();
2061 void Main::editRedo()
2063 if (currentMapEditor())
2064 currentMapEditor()->redo();
2067 void Main::editCopy()
2069 if (currentMapEditor())
2070 currentMapEditor()->copy();
2073 void Main::editPaste()
2075 if (currentMapEditor())
2076 currentMapEditor()->paste();
2079 void Main::editCut()
2081 if (currentMapEditor())
2082 currentMapEditor()->cut();
2085 void Main::editOpenFindWindow()
2087 findWindow->popup();
2088 findWindow->raise();
2090 // Call undocumented function: setActiveWindow is only
2091 // possible, if widget is visible. This depends on
2093 #if defined(Q_OS_LINUX)
2094 qt_wait_for_window_manager( this);
2096 findWindow->setActiveWindow();
2099 void Main::editFind(QString s)
2102 BranchObj *bo=currentMapEditor()->findText(s, cs);
2105 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2108 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2109 tr("No matches found for <b>%1</b>").arg(s));
2113 void Main::editFindChanged()
2114 { // Notify editor, to abort the current find process
2115 currentMapEditor()->findReset();
2118 void Main::editOpenURL()
2120 if (currentMapEditor())
2121 currentMapEditor()->openURL();
2124 void Main::editURL()
2126 if (currentMapEditor())
2127 currentMapEditor()->editURL();
2130 void Main::editHeading2URL()
2132 if (currentMapEditor())
2133 currentMapEditor()->editHeading2URL();
2136 void Main::editBugzilla2URL()
2138 if (currentMapEditor())
2139 currentMapEditor()->editBugzilla2URL();
2142 void Main::editFATE2URL()
2144 if (currentMapEditor())
2145 currentMapEditor()->editFATE2URL();
2148 void Main::editOpenVymLink()
2150 // Get current path to map
2151 QString currentVymLink;
2152 if (currentMapEditor())
2154 currentVymLink=currentMapEditor()->getVymLink();
2155 // compare path with already loaded maps
2159 for (i=0;i<=tabWidget->count() -1;i++)
2161 me=(MapEditor*)tabWidget->page(i);
2162 if (currentVymLink==me->getFilePath() )
2171 if (!QFile(currentVymLink).exists() )
2172 QMessageBox::critical( 0, tr( "Critical Error" ),
2173 tr("Couldn't open map %1").arg(currentVymLink));
2176 fileLoad (currentVymLink, NewMap);
2177 tabWidget->setCurrentPage (tabWidget->count()-1);
2180 // Go to tab containing the map
2181 tabWidget->setCurrentPage (index);
2185 void Main::editVymLink()
2187 if (currentMapEditor())
2188 currentMapEditor()->editVymLink();
2191 void Main::editDeleteVymLink()
2193 if (currentMapEditor())
2194 currentMapEditor()->deleteVymLink();
2197 void Main::editMapInfo()
2199 if (currentMapEditor())
2200 currentMapEditor()->editMapInfo();
2203 void Main::editMoveUp()
2205 if (currentMapEditor())
2206 currentMapEditor()->moveBranchUp();
2209 void Main::editMoveDown()
2211 if (currentMapEditor())
2212 currentMapEditor()->moveBranchDown();
2215 void Main::editToggleScroll()
2217 if (currentMapEditor())
2219 currentMapEditor()->toggleScroll();
2223 void Main::editUnScrollAll()
2225 if (currentMapEditor())
2227 currentMapEditor()->unScrollAll();
2231 void Main::editHeading()
2233 if (currentMapEditor())
2234 currentMapEditor()->editHeading();
2237 void Main::editNewBranch()
2239 if (currentMapEditor())
2240 currentMapEditor()->addNewBranch(0);
2243 void Main::editNewBranchHere()
2245 if (currentMapEditor())
2246 currentMapEditor()->addNewBranchHere();
2249 void Main::editNewBranchAbove()
2251 if (currentMapEditor())
2252 currentMapEditor()->addNewBranch(-1);
2255 void Main::editNewBranchBelow()
2257 if (currentMapEditor())
2258 currentMapEditor()->addNewBranch(1);
2261 void Main::editImportAdd()
2263 fileLoad (ImportAdd);
2266 void Main::editImportReplace()
2268 fileLoad (ImportReplace);
2271 void Main::editSaveBranch()
2273 fileSaveAs (PartOfMap);
2276 void Main::editRemoveBranchHere()
2278 if (currentMapEditor())
2279 currentMapEditor()->removeBranchHere();
2282 void Main::editRemoveChilds()
2284 if (currentMapEditor())
2285 currentMapEditor()->removeChilds();
2288 void Main::editDeleteSelection()
2290 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2291 currentMapEditor()->deleteSelection();
2294 void Main::editUpperBranch()
2296 if (currentMapEditor())
2297 currentMapEditor()->selectUpperBranch();
2300 void Main::editLowerBranch()
2302 if (currentMapEditor())
2303 currentMapEditor()->selectLowerBranch();
2306 void Main::editLeftBranch()
2308 if (currentMapEditor())
2309 currentMapEditor()->selectLeftBranch();
2312 void Main::editRightBranch()
2314 if (currentMapEditor())
2315 currentMapEditor()->selectRightBranch();
2318 void Main::editFirstBranch()
2320 if (currentMapEditor())
2321 currentMapEditor()->selectFirstBranch();
2324 void Main::editLastBranch()
2326 if (currentMapEditor())
2327 currentMapEditor()->selectLastBranch();
2330 void Main::editLoadImage()
2332 if (currentMapEditor())
2333 currentMapEditor()->loadFloatImage();
2336 void Main::editSaveImage(int item)
2338 if (currentMapEditor())
2339 currentMapEditor()->saveFloatImage(item);
2342 void Main::editToggleFloatExport()
2344 if (currentMapEditor())
2345 currentMapEditor()->toggleFloatExport();
2348 void Main::editFollowXLink(int item)
2350 if (currentMapEditor())
2351 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2354 void Main::editEditXLink(int item)
2356 if (currentMapEditor())
2357 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2360 void Main::formatSelectColor()
2362 if (currentMapEditor())
2364 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2365 if ( !col.isValid() ) return;
2366 currentMapEditor()->setColor( col );
2367 colorChanged( col );
2371 void Main::formatPickColor()
2373 if (currentMapEditor())
2374 colorChanged( currentMapEditor()->pickColor() );
2377 void Main::colorChanged(QColor c)
2379 QPixmap pix( 16, 16 );
2381 actionFormatColor->setIconSet( pix );
2384 void Main::formatColorItem()
2386 if (currentMapEditor())
2387 currentMapEditor()->colorItem();
2390 void Main::formatColorBranch()
2392 if (currentMapEditor())
2393 currentMapEditor()->colorBranch();
2396 void Main::formatLinkStyleLine()
2398 if (currentMapEditor())
2399 currentMapEditor()->setLinkStyle(StyleLine);
2402 void Main::formatLinkStyleParabel()
2404 if (currentMapEditor())
2405 currentMapEditor()->setLinkStyle(StyleParabel);
2408 void Main::formatLinkStylePolyLine()
2410 if (currentMapEditor())
2411 currentMapEditor()->setLinkStyle(StylePolyLine);
2414 void Main::formatLinkStylePolyParabel()
2416 if (currentMapEditor())
2417 currentMapEditor()->setLinkStyle(StylePolyParabel);
2420 void Main::formatSelectBackColor()
2422 if (currentMapEditor())
2423 currentMapEditor()->selectBackgroundColor();
2426 void Main::formatSelectLinkColor()
2428 if (currentMapEditor())
2429 currentMapEditor()->selectLinkColor();
2432 void Main::formatToggleLinkColorHint()
2434 currentMapEditor()->toggleLinkColorHint();
2437 void Main::formatFrameNone()
2439 if (currentMapEditor())
2440 currentMapEditor()->setFrame(NoFrame);
2443 void Main::formatFrameRectangle()
2445 if (currentMapEditor())
2446 currentMapEditor()->setFrame(Rectangle);
2449 void Main::formatIncludeImagesVer()
2451 if (currentMapEditor())
2452 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2455 void Main::formatIncludeImagesHor()
2457 if (currentMapEditor())
2458 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2461 void Main::formatHideLinkUnselected()
2463 if (currentMapEditor())
2464 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2467 void Main::viewZoomReset()
2469 if (currentMapEditor())
2473 currentMapEditor()->setWorldMatrix( m );
2474 currentMapEditor()->setViewCenter();
2475 currentMapEditor()->adjustCanvasSize();
2479 void Main::viewZoomIn()
2481 if (currentMapEditor())
2483 QWMatrix m = currentMapEditor()->worldMatrix();
2484 m.scale( 1.25, 1.25 );
2485 currentMapEditor()->setWorldMatrix( m );
2486 currentMapEditor()->setViewCenter();
2487 currentMapEditor()->adjustCanvasSize();
2491 void Main::viewZoomOut()
2493 if (currentMapEditor())
2495 QWMatrix m = currentMapEditor()->worldMatrix();
2496 m.scale( 0.8, 0.8 );
2497 currentMapEditor()->setWorldMatrix( m );
2498 currentMapEditor()->setViewCenter();
2499 currentMapEditor()->adjustCanvasSize();
2503 void Main::modModeColor()
2507 void Main::modModeLink()
2511 bool Main::settingsPDF()
2513 // Default browser is set in constructor
2515 QString text = QInputDialog::getText(
2516 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2517 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2519 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2524 bool Main::settingsURL()
2526 // Default browser is set in constructor
2528 QString text = QInputDialog::getText(
2529 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2530 settings.readEntry("/vym/mainwindow/readerURL")
2533 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2537 void Main::windowToggleNoteEditor()
2539 if (textEditor->showWithMain() )
2540 windowHideNoteEditor();
2542 windowShowNoteEditor();
2545 void Main::updateNoteFlag()
2547 if (currentMapEditor())
2548 currentMapEditor()->updateNoteFlag();
2551 void Main::windowShowNoteEditor()
2553 textEditor->setShowWithMain(true);
2555 actionViewToggleNoteEditor->setOn (true);
2558 void Main::windowHideNoteEditor()
2560 textEditor->setShowWithMain(false);
2562 actionViewToggleNoteEditor->setOn (false);
2565 void Main::windowNextEditor()
2567 if (tabWidget->currentPageIndex() < tabWidget->count())
2568 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2571 void Main::windowPreviousEditor()
2573 if (tabWidget->currentPageIndex() >0)
2574 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2577 void Main::standardFlagChanged()
2579 currentMapEditor()->toggleStandardFlag(sender()->name());
2582 void Main::testFunction()
2584 currentMapEditor()->testFunction();
2587 void Main::helpDoc()
2590 #if defined(Q_OS_MACX)
2591 docpath="./vym.app/Contents/vym.pdf";
2593 // default path in SUSE LINUX
2594 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2597 if (!QFile (docpath).exists() )
2599 // relative path for easy testing in tarball
2600 docpath="doc/vym.pdf";
2601 if (!QFile (docpath).exists() )
2603 // relative path for testing while still writing vym.tex
2604 docpath="doc/tex/vym.pdf";
2605 if (!QFile (docpath).exists() )
2607 // Try yet another one for Knoppix
2608 docpath="/usr/share/doc/packages/vym/vym.pdf";
2609 if (!QFile (docpath).exists() )
2611 QMessageBox::critical(0,
2612 tr("Critcal error"),
2613 tr("Couldn't find the documentation\n"
2614 "vym.pdf in various places."));
2621 Process *pdfProc = new Process();
2622 pdfProc->clearArguments();
2623 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2624 pdfProc->addArgument( docpath);
2626 if ( !pdfProc->start() )
2629 QMessageBox::critical(0,
2630 tr("Critcal error"),
2631 tr("Couldn't find a viewer to read vym.pdf.\n"
2632 "Please use Settings->")+tr("Set application to open pdf files"));
2638 void Main::helpAbout()
2641 ad.setName ("aboutwindow");
2642 ad.setMinimumSize(500,500);
2643 ad.resize (QSize (500,500));
2647 void Main::helpAboutQT()
2649 QMessageBox::aboutQt( this, "Qt Application Example" );