More documentation, fixed small bug where links of unselected objects where visible again
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-hideexport.xpm"
62 #include "icons/flag-scrolled-right.xpm"
63 #include "icons/flag-tmpUnscrolled-right.xpm"
65 #include "aboutdialog.h"
66 #include "exporthtmldialog.h"
67 #include "exportoofiledialog.h"
69 #include "exportxhtmldialog.h"
71 #include "flagrowobj.h"
73 #include "mapeditor.h"
78 #include "showtextdialog.h"
79 #include "texteditor.h"
82 extern TextEditor *textEditor;
83 extern Main *mainWindow;
84 extern QString tmpVymDir;
85 extern QString clipboardDir;
86 extern bool clipboardEmpty;
87 extern int statusbarTime;
88 extern FlagRowObj* standardFlagsDefault;
89 extern FlagRowObj* systemFlagsDefault;
91 extern QPtrList <QAction> actionListBranches;
93 extern QAction* actionFileSave;
94 extern QAction* actionFilePrint;
95 extern QAction* actionEditUndo;
96 extern QAction* actionEditRedo;
97 extern QAction *actionEditCopy;
98 extern QAction *actionEditCut;
99 extern QAction *actionEditPaste;
100 extern QAction *actionEditMoveUp;
101 extern QAction *actionEditMoveDown;
102 extern QAction *actionEditToggleScroll;
103 extern QAction* actionEditOpenURL;
104 extern QAction* actionEditURL;
105 extern QAction* actionEditHeading2URL;
106 extern QAction* actionEditBugzilla2URL;
107 extern QAction* actionEditFATE2URL;
108 extern QAction *actionEditOpenVymLink;
109 extern QAction *actionEditVymLink;
110 extern QAction *actionEditDeleteVymLink;
111 extern QAction *actionEditToggleHideExport;
112 extern QAction *actionEditMapInfo;
113 extern QAction *actionEditHeading;
114 extern QAction *actionEditDelete;
115 extern QAction *actionEditAddBranch;
116 extern QAction *actionEditAddBranchHere;
117 extern QAction *actionEditAddBranchAbove;
118 extern QAction *actionEditAddBranchBelow;
119 extern QAction *actionEditRemoveBranchHere;
120 extern QAction *actionEditRemoveChilds;
121 extern QAction *actionEditImportAdd;
122 extern QAction *actionEditImportReplace;
123 extern QAction *actionEditSaveBranch;
124 extern QAction *actionEditSelectFirst;
125 extern QAction *actionEditSelectLast;
126 extern QAction *actionEditLoadImage;
128 extern QAction* actionFormatColor;
129 extern QAction* actionFormatPickColor;
130 extern QAction* actionFormatColorBranch;
131 extern QAction* actionFormatColorSubtree;
132 extern QAction* actionFormatLinkColorHint;
133 extern QAction* actionFormatBackColor;
134 extern QAction* actionFormatLinkColor;
135 extern QAction *actionFormatIncludeImagesVer;
136 extern QAction *actionFormatIncludeImagesHor;
138 extern QActionGroup* actionGroupModModes;
139 extern QAction* actionModModeColor;
140 extern QAction* actionModModeLink;
141 extern QAction* actionModModeCopy;
143 extern QActionGroup *actionGroupFormatFrameTypes;
144 extern QAction *actionFormatFrameNone;
145 extern QAction *actionFormatFrameRectangle;
147 extern QActionGroup *actionGroupFormatLinkStyles;
148 extern QAction *actionFormatLinkStyleLine;
149 extern QAction *actionFormatLinkStyleParabel;
150 extern QAction *actionFormatLinkStylePolyLine;
151 extern QAction *actionFormatLinkStylePolyParabel;
152 extern QAction *actionFormatHideLinkUnselected;
154 extern QAction *actionViewToggleNoteEditor;
156 extern QAction* actionSettingsAutoedit;
157 extern QAction* actionSettingsAutoselectHeading;
158 extern QAction* actionSettingsAutoselectHeading;
159 extern QAction* actionSettingsAutoselectText;
160 extern QAction* actionSettingsPasteNewHeading;
161 extern QAction* actionSettingsUseDelKey;
162 extern QAction* actionSettingsUseFlagGroups;
163 extern QAction* actionSettingsUseHideExport;
165 extern QPopupMenu* branchContextMenu;
166 extern QPopupMenu* branchAddContextMenu;
167 extern QPopupMenu* branchRemoveContextMenu;
168 extern QPopupMenu* branchLinksContextMenu;
169 extern QPopupMenu* branchLinksContextMenuDup;
170 extern QPopupMenu* floatimageContextMenu;
171 extern QPopupMenu* saveImageFormatMenu;
172 extern QPopupMenu* canvasContextMenu;
173 extern QPopupMenu* lastMapsMenu;
174 extern QPopupMenu* importMenu;
175 extern QPopupMenu* exportMenu;
176 extern QPopupMenu* exportImageFormatMenu;
179 extern Settings settings;
180 extern Options options;
182 #if defined(Q_OS_LINUX)
183 extern void qt_wait_for_window_manager( QWidget* w );
186 Main::Main(QWidget* parent, const char* name, WFlags f) :
187 QMainWindow(parent,name,f)
191 setCaption ("VYM - View Your Mind");
193 // Load window settings
194 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
195 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
196 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
197 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
200 // Create unique temporary directory
201 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
203 // Create direcctory for clipboard
204 clipboardDir=tmpVymDir+"/clipboard";
205 QDir d(clipboardDir);
206 d.mkdir (clipboardDir,true);
207 makeSubDirs (clipboardDir);
210 // FIXME not used currently
211 // Set random seed (random used for object IDs)
212 // QTime t = QTime::currentTime(); // set random seed
213 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
216 // Initialize some settings, which are platform dependant
219 // application to open URLs
220 p="/vym/mainwindow/readerURL";
221 #if defined(Q_OS_LINUX)
222 s=settings.readEntry (p,"konqueror");
224 #if defined(Q_OS_MACX)
225 s=settings.readEntry (p,"/usr/bin/open");
227 s=settings.readEntry (p,"mozilla");
230 settings.writeEntry( p,s);
232 // application to open PDFs
233 p="/vym/mainwindow/readerPDF";
234 #if defined(Q_OS_LINUX)
235 s=settings.readEntry (p,"acroread");
237 #if defined(Q_OS_MACX)
238 s=settings.readEntry (p,"/usr/bin/open");
240 s=settings.readEntry (p,"acroread");
243 settings.writeEntry( p,s);
248 // Create tab widget which holds the maps
249 tabWidget= new QTabWidget (this);
250 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
251 this, SLOT( editorChanged( QWidget * ) ) );
253 setCentralWidget(tabWidget);
257 setupFormatActions();
261 setupSettingsActions();
263 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
266 // After menu is created, we can enable some actions
267 actionFilePrint->setEnabled (true);
272 // Initialize Find window
273 findWindow=new FindWindow(NULL,"findwindow");
274 connect (findWindow, SIGNAL( findButton(QString) ),
275 this, SLOT(editFind(QString) ) );
276 connect (findWindow, SIGNAL( somethingChanged() ),
277 this, SLOT(editFindChanged() ) );
279 // Connect TextEditor, so that we can update flags if text changes
280 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
288 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
289 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
290 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
291 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
293 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
294 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
296 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
297 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
298 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
299 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
300 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
301 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
302 settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
305 int maps=lastMaps.count();
306 settings.writeEntry( "/vym/lastMaps/number",maps );
307 for (int i=1;i<=maps;i++)
309 QStringList::Iterator it = lastMaps.at(i-1);
310 s=QString("/vym/lastMaps/map-%1").arg(i);
311 if (!s.isEmpty() && i<=maxLastMaps)
312 settings.writeEntry (s, *it);
316 // To make the texteditor save its settings, call the destructor
319 // Remove temporary directory
320 removeDir (QDir(tmpVymDir));
323 void Main::loadCmdLine()
325 /* TODO draw some kind of splashscreen while loading...
331 QStringList flist=options.getFileList();
332 QStringList::Iterator it=flist.begin();
334 while (it !=flist.end() )
336 fileLoad (*it, NewMap);
342 void Main::statusMessage(const QString &s)
344 statusBar()->message (s);
347 void Main::closeEvent (QCloseEvent* )
353 void Main::setupFileActions()
355 QToolBar *tb = new QToolBar( this );
356 tb->setLabel( "File Actions" );
357 QPopupMenu *menu = new QPopupMenu( this );
358 menuBar()->insertItem( tr( "&File" ), menu );
360 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
363 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
364 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
368 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
369 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
373 lastMapsMenu = new QPopupMenu (this);
375 menu->insertItem (tr("Open Recent"),lastMapsMenu );
376 menu->insertSeparator();
378 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
379 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
384 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
385 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
388 menu->insertSeparator();
390 importMenu = new QPopupMenu (this);
391 menu->insertItem (tr("Import"),importMenu );
393 a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
394 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
395 a->addTo (importMenu);
397 a = new QAction( tr( "Import")+" Mind Manager" , QPixmap(), "Mind Manager...", 0, this, "importMM" );
398 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
399 a->addTo (importMenu);
401 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
402 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
403 a->addTo( importMenu);
405 exportMenu = new QPopupMenu (this);
406 menu->insertItem (tr("Export"),exportMenu );
408 menu->insertSeparator();
411 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" );
412 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
417 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
418 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
421 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
422 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
428 void Main::setupEditActions()
430 QToolBar *tb = new QToolBar( this );
431 tb->setLabel( "Edit Actions" );
432 QPopupMenu *menu = new QPopupMenu( this );
433 menuBar()->insertItem( tr( "&Edit" ), menu );
437 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
438 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
439 a->setEnabled (false);
444 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
446 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
447 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
452 menu->insertSeparator();
453 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
454 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
455 a->setEnabled (false);
459 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
460 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
461 a->setEnabled (false);
465 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
466 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
467 a->setEnabled (false);
472 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
473 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
474 a->setEnabled (false);
477 actionListBranches.append(a);
480 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
481 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
482 a->setEnabled (false);
485 actionListBranches.append(a);
486 actionEditMoveDown=a;
489 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
490 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
491 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
492 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
493 #if defined(Q_OS_MACX)
494 actionEditToggleScroll=alt;
496 actionEditToggleScroll=a;
498 actionEditToggleScroll->setEnabled (false);
499 actionEditToggleScroll->setToggleAction(true);
500 actionEditToggleScroll->addTo( tb );
501 actionEditToggleScroll->addTo( menu );
502 actionListBranches.append(actionEditToggleScroll);
504 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
505 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
508 menu->insertSeparator();
510 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
511 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
514 menu->insertSeparator();
516 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
517 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
519 a->setEnabled (false);
522 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
523 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
524 a->setEnabled (false);
525 actionListBranches.append(a);
528 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
529 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
530 a->setEnabled (false);
531 actionListBranches.append(a);
532 actionEditHeading2URL=a;
534 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
535 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
536 a->setEnabled (false);
537 actionListBranches.append(a);
538 actionEditBugzilla2URL=a;
540 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
541 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
542 a->setEnabled (false);
543 actionListBranches.append(a);
544 actionEditFATE2URL=a;
546 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" );
547 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
549 a->setEnabled (false);
550 actionEditOpenVymLink=a;
552 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
553 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
554 a->setEnabled (false);
555 actionListBranches.append(a);
558 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
559 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
560 a->setEnabled (false);
561 actionEditDeleteVymLink=a;
563 a = new QAction( tr( "Hide object in exports" ), QPixmap(flag_hideexport_xpm), tr( "Hide in exports" ), 0, this, "hideExport" );
564 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
565 a->setToggleAction(true);
567 a->setEnabled (false);
568 actionEditToggleHideExport=a;
570 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
571 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
572 a->setEnabled (true);
575 menu->insertSeparator();
577 // Shortcuts to modify heading:
578 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
579 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
580 actionListBranches.append(a);
581 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
582 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
583 actionListBranches.append(a);
585 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
586 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
587 a->setEnabled (false);
589 actionListBranches.append(a);
591 // Shortcut to delete selection
592 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
593 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
594 a->setEnabled (false);
597 // Shortcut to add branch
598 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
599 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
600 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
601 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
602 a->setEnabled (false);
603 actionListBranches.append(a);
604 #if defined (Q_OS_MACX)
605 // In OSX show different shortcut in menues, the keys work independtly always
606 actionEditAddBranch=alt;
608 actionEditAddBranch=a;
611 // Add branch by inserting it at selection
612 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
613 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
614 a->setEnabled (false);
615 actionListBranches.append(a);
616 actionEditAddBranchHere=a;
617 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
618 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
619 actionListBranches.append(a);
622 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
623 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
624 a->setEnabled (false);
625 actionListBranches.append(a);
626 actionEditAddBranchAbove=a;
627 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
628 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
629 actionListBranches.append(a);
632 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
633 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
634 a->setEnabled (false);
635 actionListBranches.append(a);
636 actionEditAddBranchBelow=a;
637 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
638 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
639 actionListBranches.append(a);
641 // Import at selection (adding to selection)
642 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
643 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
644 a->setEnabled (false);
645 actionListBranches.append(a);
646 actionEditImportAdd=a;
648 // Import at selection (replacing selection)
649 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
650 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
651 a->setEnabled (false);
652 actionListBranches.append(a);
653 actionEditImportReplace=a;
656 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
657 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
658 a->setEnabled (false);
659 actionListBranches.append(a);
660 actionEditSaveBranch=a;
662 // Only remove branch, not its childs
663 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
664 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
665 a->setEnabled (false);
666 actionListBranches.append(a);
667 actionEditRemoveBranchHere=a;
669 // Only remove childs of a branch
670 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
671 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
672 a->setEnabled (false);
673 actionListBranches.append(a);
674 actionEditRemoveChilds=a;
676 // Shortcuts for navigating with cursor:
677 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
678 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
679 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
680 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
681 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
682 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
683 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
684 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
685 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
686 a->setEnabled (false);
688 actionListBranches.append(a);
689 actionEditSelectFirst=a;
690 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
691 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
692 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
693 a->setEnabled (false);
695 actionListBranches.append(a);
696 actionEditSelectLast=a;
698 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
699 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
700 actionEditLoadImage=a;
705 void Main::setupFormatActions()
707 QPopupMenu *menu = new QPopupMenu( this );
708 menuBar()->insertItem( tr( "&Format" ), menu );
710 QToolBar *tb = new QToolBar( this );
714 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
715 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
716 actionFormatColor->addTo( tb );
717 actionFormatColor->addTo( menu );
718 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" );
719 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
720 a->setEnabled (false);
723 actionListBranches.append(a);
724 actionFormatPickColor=a;
725 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
726 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
727 a->setEnabled (false);
730 actionListBranches.append(a);
731 actionFormatColorBranch=a;
732 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
733 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
734 a->setEnabled (false);
737 actionListBranches.append(a);
738 actionFormatColorSubtree=a;
740 menu->insertSeparator();
741 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
742 actionGroupFormatLinkStyles->setExclusive (true);
743 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
744 a->setToggleAction(true);
745 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
746 actionFormatLinkStyleLine=a;
747 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
748 a->setToggleAction(true);
749 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
750 actionFormatLinkStyleParabel=a;
751 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
752 a->setToggleAction(true);
753 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
754 actionFormatLinkStylePolyLine=a;
755 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
756 a->setToggleAction(true);
757 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
758 actionFormatLinkStylePolyParabel=a;
759 actionGroupFormatLinkStyles->addTo (menu);
761 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
762 actionGroupFormatFrameTypes->setExclusive (true);
763 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
764 a->setToggleAction(true);
765 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
766 actionFormatFrameNone=a;
767 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
768 a->setToggleAction(true);
769 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
770 actionFormatFrameRectangle=a;
772 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
773 a->setToggleAction(true);
774 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
775 actionFormatIncludeImagesVer=a;
777 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
778 a->setToggleAction(true);
779 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
780 actionFormatIncludeImagesHor=a;
782 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
783 a->setToggleAction(true);
784 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
785 actionFormatHideLinkUnselected=a;
787 menu->insertSeparator();
788 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
789 a->setToggleAction(true);
790 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
792 actionFormatLinkColorHint=a;
794 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
795 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
796 actionFormatLinkColor->addTo( menu );
797 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
798 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
799 actionFormatBackColor->addTo( menu );
803 void Main::setupViewActions()
805 QToolBar *tb = new QToolBar( this );
806 tb->setLabel( "View Actions" );
807 QPopupMenu *menu = new QPopupMenu( this );
808 menuBar()->insertItem( tr( "&View" ), menu );
811 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
812 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
815 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
816 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
819 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
820 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
823 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
824 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
825 a->setToggleAction(true);
826 if (textEditor->showWithMain())
832 actionViewToggleNoteEditor=a;
833 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
834 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
836 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
837 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
842 void Main::setupModeActions()
844 //QPopupMenu *menu = new QPopupMenu( this );
845 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
847 QToolBar *tb = new QToolBar( this );
848 tb->setLabel( tr ("Modes when using modifiers") );
850 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
851 actionGroupModModes->setExclusive (true);
852 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
853 a->setToggleAction(true);
856 actionModModeColor=a;
858 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
859 a->setToggleAction(true);
863 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
864 a->setToggleAction(true);
870 void Main::setupFlagActions()
872 // Create System Flags
873 systemFlagsDefault = new FlagRowObj ();
874 systemFlagsDefault->setVisibility (false);
875 systemFlagsDefault->setName ("systemFlagsDef");
877 FlagObj *fo = new FlagObj ();
878 fo->load(QPixmap(flag_note_xpm));
880 fo->setToolTip(tr("Note","Systemflag"));
881 systemFlagsDefault->addFlag (fo); // makes deep copy
883 fo->load(QPixmap(flag_url_xpm));
885 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
886 systemFlagsDefault->addFlag (fo);
888 fo->load(QPixmap(flag_vymlink_xpm));
889 fo->setName("vymLink");
890 fo->setToolTip(tr("Link to another vym map","Systemflag"));
891 systemFlagsDefault->addFlag (fo);
893 fo->load(QPixmap(flag_scrolled_right_xpm));
894 fo->setName("scrolledright");
895 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
896 systemFlagsDefault->addFlag (fo);
898 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
899 fo->setName("tmpUnscrolledright");
900 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
901 systemFlagsDefault->addFlag (fo);
903 fo->load(QPixmap("icons/flag-hideexport.png"));
904 fo->setName("hideInExport");
905 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
906 systemFlagsDefault->addFlag (fo);
908 // Create Standard Flags
909 standardFlagsDefault = new FlagRowObj ();
910 standardFlagsDefault->setVisibility (false);
911 standardFlagsDefault->setName ("standardFlagsDef");
913 fo->load(QPixmap(flag_exclamationmark_xpm));
914 fo->setName ("exclamationmark");
915 fo->setGroup("standard-mark");
916 fo->setToolTip(tr("Take care!","Standardflag"));
917 standardFlagsDefault->addFlag (fo); // makes deep copy
919 fo->load(QPixmap(flag_questionmark_xpm));
920 fo->setName("questionmark");
921 fo->setGroup("standard-mark");
922 fo->setToolTip(tr("Really?","Standardflag"));
923 standardFlagsDefault->addFlag (fo);
925 fo->load(QPixmap(flag_hook_green_xpm));
926 fo->setName("hook-green");
927 fo->setGroup("standard-hook");
928 fo->setToolTip(tr("ok!","Standardflag"));
929 standardFlagsDefault->addFlag (fo);
931 fo->load(QPixmap(flag_cross_red_xpm));
932 fo->setName("cross-red");
933 fo->setGroup("standard-hook");
934 fo->setToolTip(tr("Not ok!","Standardflag"));
935 standardFlagsDefault->addFlag (fo);
937 fo->load(QPixmap(flag_stopsign_xpm));
938 fo->setName("stopsign");
939 fo->setToolTip(tr("This won't work!","Standardflag"));
940 standardFlagsDefault->addFlag (fo);
942 fo->load(QPixmap(flag_smiley_good_xpm));
943 fo->setName("smiley-good");
944 fo->setGroup("standard-smiley");
945 fo->setToolTip(tr("Good","Standardflag"));
946 standardFlagsDefault->addFlag (fo);
948 fo->load(QPixmap(flag_smiley_sad_xpm));
949 fo->setName("smiley-sad");
950 fo->setGroup("standard-smiley");
951 fo->setToolTip(tr("Bad","Standardflag"));
952 standardFlagsDefault->addFlag (fo);
954 fo->load(QPixmap(flag_clock_xpm));
955 fo->setName("clock");
956 fo->setToolTip(tr("Time critical","Standardflag"));
957 standardFlagsDefault->addFlag (fo);
959 fo->load(QPixmap(flag_lamp_xpm));
961 fo->setToolTip(tr("Idea!","Standardflag"));
962 standardFlagsDefault->addFlag (fo);
964 fo->load(QPixmap(flag_arrow_up_xpm));
965 fo->setName("arrow-up");
966 fo->setGroup("standard-arrow");
967 fo->setToolTip(tr("Important","Standardflag"));
968 standardFlagsDefault->addFlag (fo);
970 fo->load(QPixmap(flag_arrow_down_xpm));
971 fo->setName("arrow-down");
972 fo->setGroup("standard-arrow");
973 fo->setToolTip(tr("Unimportant","Standardflag"));
974 standardFlagsDefault->addFlag (fo);
976 fo->load(QPixmap(flag_thumb_up_xpm));
977 fo->setName("thumb-up");
978 fo->setGroup("standard-thumb");
979 fo->setToolTip(tr("I like this","Standardflag"));
980 standardFlagsDefault->addFlag (fo);
982 fo->load(QPixmap(flag_thumb_down_xpm));
983 fo->setName("thumb-down");
984 fo->setGroup("standard-thumb");
985 fo->setToolTip(tr("I like this","Standardflag"));
986 fo->setToolTip(tr("I do not like this","Standardflag"));
987 standardFlagsDefault->addFlag (fo);
989 fo->load(QPixmap(flag_heart_xpm));
990 fo->setName("heart");
991 fo->setToolTip(tr("I just love... ","Standardflag"));
992 standardFlagsDefault->addFlag (fo);
994 fo->load(QPixmap(flag_flash_xpm));
995 fo->setName("flash");
996 fo->setToolTip(tr("Dangerous","Standardflag"));
997 standardFlagsDefault->addFlag (fo);
999 fo->load(QPixmap(flag_lifebelt_xpm));
1000 fo->setName("lifebelt");
1001 fo->setToolTip(tr("This will help","Standardflag"));
1002 standardFlagsDefault->addFlag (fo);
1006 standardFlagsDefault->makeToolbar(this, "Standard Flags");
1010 void Main::setupSettingsActions()
1012 QPopupMenu *menu = new QPopupMenu( this );
1013 menuBar()->insertItem( tr( "&Settings" ), menu );
1018 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1019 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1022 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1023 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1026 menu->insertSeparator();
1027 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1028 a->setToggleAction(true);
1029 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1031 actionSettingsAutoedit=a;
1033 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1034 a->setToggleAction(true);
1035 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1037 actionSettingsAutoselectHeading=a;
1039 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1040 a->setToggleAction(true);
1041 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1043 actionSettingsAutoselectText=a;
1045 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1046 a->setToggleAction(true);
1047 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1049 actionSettingsPasteNewHeading=a;
1051 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1052 a->setToggleAction(true);
1053 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1055 actionSettingsUseDelKey=a;
1057 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1058 a->setToggleAction(true);
1059 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1061 actionSettingsUseFlagGroups=a;
1063 a= new QAction( tr( "Use hide flag during exports " ), QPixmap(), tr( "Use hide flags" ), 0, this, "hideexport" );
1064 a->setToggleAction(true);
1065 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1067 actionSettingsUseHideExport=a;
1071 void Main::setupTestActions()
1073 QPopupMenu *menu = new QPopupMenu( this );
1074 menuBar()->insertItem( tr( "&Test" ), menu );
1077 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1078 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1083 void Main::setupHelpActions()
1085 QPopupMenu *menu = new QPopupMenu( this );
1086 menuBar()->insertItem( tr( "&Help" ), menu );
1089 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1090 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1093 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1094 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1097 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1098 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1103 void Main::setupContextMenus()
1107 // Context Menu for branch or mapcenter
1108 branchContextMenu =new QPopupMenu (this);
1111 branchAddContextMenu =new QPopupMenu (this);
1112 actionEditPaste->addTo ( branchAddContextMenu );
1113 actionEditAddBranch->addTo ( branchAddContextMenu );
1114 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1115 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1116 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1117 branchAddContextMenu->insertSeparator();
1118 actionEditLoadImage->addTo( branchAddContextMenu );
1119 branchAddContextMenu->insertSeparator();
1120 actionEditImportAdd->addTo ( branchAddContextMenu );
1121 actionEditImportReplace->addTo ( branchAddContextMenu );
1124 branchRemoveContextMenu =new QPopupMenu (this);
1125 actionEditCut->addTo ( branchRemoveContextMenu );
1126 actionEditDelete->addTo ( branchRemoveContextMenu );
1127 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
1128 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1130 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1131 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1133 actionEditSaveBranch->addTo( branchContextMenu );
1135 branchContextMenu->insertSeparator();
1136 actionEditOpenURL->addTo ( branchContextMenu );
1137 actionEditURL->addTo ( branchContextMenu );
1138 actionEditHeading2URL->addTo ( branchContextMenu );
1139 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1141 actionEditBugzilla2URL->addTo( branchContextMenu );
1142 actionEditFATE2URL->addTo( branchContextMenu );
1144 branchContextMenu->insertSeparator();
1145 actionEditOpenVymLink->addTo ( branchContextMenu );
1146 actionEditVymLink->addTo ( branchContextMenu );
1147 actionEditDeleteVymLink->addTo ( branchContextMenu );
1149 branchContextMenu->insertSeparator();
1150 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1152 branchContextMenu->insertSeparator();
1153 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1154 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1155 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1157 // Context Menu for links in a branch menu
1158 // This will be populated "on demand" in MapEditor::updateActions
1159 branchContextMenu->insertSeparator();
1160 branchLinksContextMenu =new QPopupMenu (this);
1161 branchLinksContextMenuDup =new QPopupMenu (this);
1162 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1163 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1165 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1166 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1168 // Context menu for floatimage
1169 floatimageContextMenu =new QPopupMenu (this);
1170 saveImageFormatMenu=new QPopupMenu (this);
1171 exportImageFormatMenu=new QPopupMenu (this);
1173 QStrList fmt = QImage::outputFormats();
1174 for (const char* f = fmt.first(); f; f = fmt.next())
1176 saveImageFormatMenu->insertItem( f );
1177 exportImageFormatMenu->insertItem( f );
1179 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1180 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1181 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1183 floatimageContextMenu->insertSeparator();
1184 actionEditCopy->addTo( floatimageContextMenu );
1185 actionEditCut->addTo( floatimageContextMenu );
1187 /* FIXME not needed any longer
1188 floatimageContextMenu->insertSeparator();
1189 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1190 a->setToggleAction(true);
1191 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1192 a->addTo( floatimageContextMenu);
1193 actionEditToggleFloatExport=a;
1196 floatimageContextMenu->insertSeparator();
1197 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1199 exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1201 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1202 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1203 a->addTo (exportMenu);
1205 a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" );
1206 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1207 a->addTo( exportMenu );
1209 a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" );
1210 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1211 a->addTo( exportMenu );
1213 a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
1214 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1215 a->addTo (exportMenu);
1217 a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
1218 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1219 a->addTo( exportMenu );
1221 a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1222 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1223 a->addTo( exportMenu );
1225 a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" );
1226 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1227 a->addTo( exportMenu );
1229 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1231 a = new QAction( tr( "Export as")+" HTML" , QPixmap(), "HTML...", 0, this, "exportHTML");
1232 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1233 a->addTo( exportMenu );
1237 // Context menu for canvas
1238 canvasContextMenu =new QPopupMenu (this);
1239 actionEditMapInfo->addTo( canvasContextMenu );
1240 canvasContextMenu->insertSeparator();
1241 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1242 canvasContextMenu->insertSeparator();
1243 actionFormatLinkColorHint->addTo( canvasContextMenu );
1244 actionFormatLinkColor->addTo( canvasContextMenu );
1245 actionFormatBackColor->addTo( canvasContextMenu );
1247 // Menu for last opened files
1248 // Read settings initially
1250 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1251 for (int i=1;i<=j;i++)
1253 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1254 if (!s.isEmpty() && j<=maxLastMaps)
1257 setupLastMapsMenu();
1258 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1261 void Main::setupLastMapsMenu()
1263 // Remove double entries
1264 QStringList::Iterator it=lastMaps.begin();
1265 QStringList::Iterator jt;
1266 while (it!=lastMaps.end() )
1270 while (jt!=lastMaps.end() )
1273 jt=lastMaps.remove(jt);
1280 // Limit length of list to maxLastMaps
1281 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1283 // build Menu from lastMaps string list
1284 lastMapsMenu->clear();
1285 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1286 lastMapsMenu->insertItem (*it );
1290 void Main::hideEvent (QHideEvent * )
1292 if (!textEditor->isMinimized() ) textEditor->hide();
1295 void Main::showEvent (QShowEvent * )
1297 if (textEditor->showWithMain()) textEditor->showNormal();
1300 bool Main::reallyWriteDirectory(const QString &dir)
1302 QStringList eList = QDir(dir).entryList();
1303 if (eList.first() ==".") eList.pop_front(); // remove "."
1304 if (eList.first() =="..") eList.pop_front(); // remove "."
1305 if (!eList.isEmpty())
1307 QMessageBox mb( __VYM,
1308 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1309 QMessageBox::Warning,
1311 QMessageBox::Cancel | QMessageBox::Default,
1312 QMessageBox::QMessageBox::NoButton );
1314 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1315 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1318 case QMessageBox::Yes:
1321 case QMessageBox::Cancel:
1329 QString Main::browseDirectory (const QString &caption)
1331 QFileDialog fd(this,caption);
1332 fd.setMode (QFileDialog::DirectoryOnly);
1333 fd.setCaption(__VYM " - "+caption);
1336 if ( fd.exec() == QDialog::Accepted )
1337 return fd.selectedFile();
1342 MapEditor* Main::currentMapEditor() const
1344 if ( tabWidget->currentPage() &&
1345 tabWidget->currentPage()->inherits( "MapEditor" ) )
1346 return (MapEditor*)tabWidget->currentPage();
1350 //TODO not used now, maybe use this for overview window later
1351 void Main::newView()
1353 // Open a new view... have it delete when closed.
1354 Main *m = new Main(0, 0, WDestructiveClose);
1355 qApp->setMainWidget(m);
1357 qApp->setMainWidget(0);
1360 void Main::editorChanged(QWidget *)
1362 // Unselect all possibly selected objects
1363 // (Important to update note editor)
1366 for (i=0;i<=tabWidget->count() -1;i++)
1369 me=(MapEditor*)tabWidget->page(i);
1372 currentMapEditor()->reselect();
1374 // Update actions to in menus and toolbars according to editor
1375 currentMapEditor()->updateActions();
1378 void Main::fileNew()
1380 QString fn="unnamed";
1381 MapEditor* medit = new MapEditor (tabWidget, true);
1382 tabWidget->addTab (medit,fn);
1383 tabWidget->showPage(medit);
1384 medit->viewport()->setFocus();
1385 // For the very first map we do not have flagrows yet...
1386 medit->select("mc:");
1389 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1391 ErrorCode err=success;
1393 // fn is usually the archive, mapfile the file after uncompressing
1396 // Make fn absolute (needed for unzip)
1397 fn=QDir (fn).absPath();
1403 // Check, if map is already loaded
1405 while (i<=tabWidget->count() -1)
1407 me=(MapEditor*)tabWidget->page(i);
1408 if (me->getFilePath() == fn)
1410 // Already there, ask for confirmation
1411 QMessageBox mb( __VYM,
1412 tr("The map %1\nis already opened."
1413 "Opening the same map in multiple editors may lead \n"
1414 "to confusion when finishing working with vym."
1415 "Do you want to").arg(fn),
1416 QMessageBox::Warning,
1417 QMessageBox::Yes | QMessageBox::Default,
1418 QMessageBox::Cancel | QMessageBox::Escape,
1419 QMessageBox::QMessageBox::NoButton);
1420 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1421 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1424 case QMessageBox::Yes:
1426 i=tabWidget->count();
1428 case QMessageBox::Cancel:
1440 if ( !fn.isEmpty() )
1442 me = currentMapEditor();
1443 int tabIndex=tabWidget->currentPageIndex();
1444 // Check first, if mapeditor exists
1445 // If it is not default AND we want a new map,
1446 // create a new mapeditor in a new tab
1447 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1449 me = new MapEditor (tabWidget,true);
1450 tabWidget->addTab (me,fn);
1451 tabIndex=tabWidget->indexOf (me);
1452 tabWidget->setCurrentPage (tabIndex);
1455 // Check, if file exists (important for creating new files
1456 // from command line
1457 if (!QFile(fn).exists() )
1459 QMessageBox mb( __VYM,
1460 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1461 QMessageBox::Question,
1463 QMessageBox::Cancel | QMessageBox::Default,
1464 QMessageBox::QMessageBox::NoButton );
1466 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1467 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1470 case QMessageBox::Yes:
1472 currentMapEditor()->setFilePath(fn);
1473 tabWidget->setTabLabel (currentMapEditor(),
1474 currentMapEditor()->getFileName() );
1475 statusBar()->message( "Created " + fn , statusbarTime );
1478 case QMessageBox::Cancel:
1479 // don't create new map
1480 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1487 //tabWidget->currentPage() won't be NULL here, because of above...
1488 tabWidget->showPage(me);
1489 me->viewport()->setFocus();
1491 // Create temporary directory for packing
1492 char tmpdir1[]="/tmp/vym-XXXXXX";
1493 QString tmpMapDir=mkdtemp(tmpdir1);
1495 // Try to unzip file
1496 err=unzipDir (tmpMapDir,fn);
1500 me->setZipped(false);
1503 me->setZipped(true);
1505 // Look for mapname.xml
1506 mapfile= fn.left(fn.findRev(".",-1,true));
1507 mapfile=mapfile.section( '/', -1 );
1508 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1509 if (!file.exists() )
1511 // mapname.xml does not exist, well,
1512 // maybe some renamed the mapname.vym file...
1513 // Try to find any .xml in the toplevel
1514 // directory of the .vym file
1515 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1516 if (flist.count()==1)
1518 // Only one entry, take this one
1519 mapfile=tmpMapDir + "/"+flist.first();
1522 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1523 *it=tmpMapDir + "/" + *it;
1524 // TODO Multiple entries, load all (but only the first one into this ME)
1525 //mainWindow->fileLoadFromTmp (flist);
1526 //returnCode=1; // Silently forget this attempt to load
1527 qWarning ("MainWindow::load (fn) multimap found...");
1530 if (flist.isEmpty() )
1532 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1533 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1536 } //file doesn't exist
1538 mapfile=file.name();
1543 // Save existing filename in case we import
1544 QString fn_org=me->getFilePath();
1546 // Finally load map into mapEditor
1547 me->setFilePath (mapfile,fn);
1548 err=me->load(mapfile,lmode);
1550 // Restore old (maybe empty) filepath, if this is an import
1552 me->setFilePath (fn_org);
1555 // Finally check for errors and go home
1558 if (lmode==NewMap) fileCloseMap();
1559 statusBar()->message( "Could not load " + fn, statusbarTime );
1564 me->setFilePath (fn);
1565 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1566 if (fn.left(9)!="/tmp/vym-")
1568 // Only append to lastMaps if not loaded from a tmpDir
1569 // e.g. imported bookmarks are in a tmpDir
1570 lastMaps.prepend(me->getFilePath() );
1571 setupLastMapsMenu();
1573 actionFilePrint->setEnabled (true);
1575 statusBar()->message( "Loaded " + fn, statusbarTime );
1579 removeDir (QDir(tmpMapDir));
1585 void Main::fileLoad(const LoadMode &lmode)
1587 QFileDialog *fd=new QFileDialog( this);
1588 if (!lastFileDir.isEmpty())
1589 fd->setDir (lastFileDir);
1590 fd->setMode (QFileDialog::ExistingFiles);
1591 fd->addFilter ("XML (*.xml)");
1592 fd->addFilter ("VYM map (*.vym *.vyp)");
1596 fd->setCaption(tr("Load vym map"));
1599 fd->setCaption(tr("Import: Add vym map to selection"));
1602 fd->setCaption(tr("Import: Replace selection with vym map"));
1608 if ( fd->exec() == QDialog::Accepted )
1610 lastFileDir=fd->dirPath();
1611 QStringList flist = fd->selectedFiles();
1612 QStringList::Iterator it = flist.begin();
1613 while( it != flist.end() )
1616 fileLoad(*it, lmode);
1623 void Main::fileLoad()
1628 void Main::fileLoadLast(int i)
1630 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1633 void Main::fileSave(const SaveMode &savemode)
1635 // tmp dir for zipping
1639 ErrorCode err=success;
1641 QString safeFilePath;
1643 bool saveZipped=currentMapEditor()->saveZipped();
1645 MapEditor * me=currentMapEditor();
1648 QString fn=me->getFilePath();
1649 // filename=unnamed, filepath="" in constructor...
1650 if ( !fn.isEmpty() )
1652 // We have a filepath, go on saving
1653 // First remove existing file, we
1654 // don't want to add to old zip archives
1658 QMessageBox::warning( 0, tr( "Save Error" ),
1659 fn+ tr("\ncould not be removed before saving"));
1661 // Look, if we should zip the data:
1664 QMessageBox mb( __VYM,
1665 tr("The map %1\ndid not use the compressed "
1666 "vym file format.\nWriting it uncompressed will also write images \n"
1667 "and flags and thus may overwrite files in the "
1668 "given directory\n\nDo you want to write the map").arg(fn),
1669 QMessageBox::Warning,
1670 QMessageBox::Yes | QMessageBox::Default,
1672 QMessageBox::Cancel | QMessageBox::Escape);
1673 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1674 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1675 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1678 case QMessageBox::Yes:
1679 // save compressed (default file format)
1682 case QMessageBox::No:
1683 // save uncompressed
1686 case QMessageBox::Cancel:
1695 char tmpdir1[]="/tmp/vym-XXXXXX";
1696 tmpMapDir=mkdtemp(tmpdir1);
1698 safeFilePath=me->getFilePath();
1699 me->setFilePath (tmpMapDir+"/"+
1700 me->getMapName()+ ".xml",
1702 me->save (savemode);
1703 me->setFilePath (safeFilePath);
1705 zipDir (tmpMapDir,fn);
1710 safeFilePath=me->getFilePath();
1711 me->setFilePath (fn, safeFilePath);
1712 me->save (savemode);
1713 me->setFilePath (safeFilePath);
1715 } // filepath available
1718 // We have no filepath yet,
1719 // call fileSaveAs() now, this will call fileSave()
1721 fileSaveAs(savemode);
1725 if (saveZipped && !tmpMapDir.isEmpty())
1727 removeDir (QDir(tmpMapDir));
1731 statusBar()->message(
1732 tr("Saved %1").arg(me->getFilePath()),
1734 lastMaps.prepend(me->getFilePath() );
1735 setupLastMapsMenu();
1737 statusBar()->message(
1738 tr("Couldn't save ").arg(me->getFilePath()),
1742 void Main::fileSave()
1744 fileSave (CompleteMap);
1747 void Main::fileSaveAs(const SaveMode& savemode)
1751 if (currentMapEditor())
1753 if (savemode==CompleteMap)
1754 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1756 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1757 if ( !fn.isEmpty() )
1759 // Check for existing file
1760 if (QFile (fn).exists())
1762 QMessageBox mb( __VYM,
1763 tr("The file %1\nexists already. Do you want to").arg(fn),
1764 QMessageBox::Warning,
1765 QMessageBox::Yes | QMessageBox::Default,
1766 QMessageBox::Cancel | QMessageBox::Escape,
1767 QMessageBox::QMessageBox::NoButton);
1768 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1769 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1772 case QMessageBox::Yes:
1775 case QMessageBox::Cancel:
1782 // New file, add extension to filename, if missing
1783 // This is always .vym or .vyp, depending on savemode
1784 if (savemode==CompleteMap)
1786 if (!fn.contains (".vym") && !fn.contains (".xml"))
1790 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1799 currentMapEditor()->setFilePath(fn);
1803 if (savemode==CompleteMap)
1804 tabWidget->setTabLabel (currentMapEditor(),
1805 currentMapEditor()->getFileName() );
1811 void Main::fileSaveAs()
1813 fileSaveAs (CompleteMap);
1816 void Main::fileImportKDEBookmarks()
1818 ImportKDEBookmarks im;
1820 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1821 currentMapEditor()->setFilePath ("");
1824 void Main::fileImportMM()
1828 QFileDialog *fd=new QFileDialog( this);
1829 if (!lastFileDir.isEmpty())
1830 fd->setDir (lastFileDir);
1831 fd->setMode (QFileDialog::ExistingFiles);
1832 fd->addFilter ("Mind Manager (*.mmap)");
1833 fd->setCaption(tr("Import")+" "+"Mind Manager");
1836 if ( fd->exec() == QDialog::Accepted )
1838 lastFileDir=fd->dirPath();
1839 QStringList flist = fd->selectedFiles();
1840 QStringList::Iterator it = flist.begin();
1841 while( it != flist.end() )
1844 if (im.transform() &&
1845 success==fileLoad (im.getTransformedFile(),NewMap) &&
1846 currentMapEditor() )
1847 currentMapEditor()->setFilePath ("");
1856 void Main::fileImportDir()
1858 if (currentMapEditor())
1859 currentMapEditor()->importDir();
1862 void Main::fileExportXML()
1864 if (currentMapEditor())
1866 QString dir=browseDirectory(tr("Export XML to directory"));
1867 if (dir !="" && reallyWriteDirectory(dir) )
1868 currentMapEditor()->exportXML(dir);
1872 void Main::fileExportHTML()
1874 MapEditor *me=currentMapEditor();
1877 ExportHTMLDialog dia(this);
1879 if (dia.exec()==QDialog::Accepted)
1881 QString dir=dia.getDir();
1882 if (reallyWriteDirectory(dir) )
1884 me->setExportMode (true);
1885 me->exportXML (dia.getDir() );
1886 dia.doExport(me->getMapName() );
1887 me->setExportMode (false);
1893 void Main::fileExportXHTML()
1895 MapEditor *me=currentMapEditor();
1899 ExportXHTMLDialog dia(this);
1900 dia.setFilePath (me->getFilePath() );
1901 dia.setMapName (me->getMapName() );
1904 if (dia.exec()==QDialog::Accepted)
1906 QString dir=dia.getDir();
1907 // Check, if warnings should be used before overwriting
1908 // the output directory
1911 ok=reallyWriteDirectory(dir);
1917 me->exportXML (dia.getDir() );
1918 dia.doExport(me->getMapName() );
1919 if (dia.hasChanged())
1926 void Main::fileExportImage(int item)
1928 MapEditor *me=currentMapEditor();
1931 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1933 if ( !fn.isEmpty() )
1934 me->exportImage(fn,item);
1936 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1941 void Main::fileExportASCII()
1943 MapEditor *me=currentMapEditor();
1947 ex.setMapCenter(me->getMapCenter());
1948 ex.addFilter ("TXT (*.txt)");
1949 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1950 if (ex.execDialog() )
1952 me->setExportMode(true);
1954 me->setExportMode(false);
1959 void Main::fileExportLaTeX()
1961 MapEditor *me=currentMapEditor();
1965 ex.setMapCenter(me->getMapCenter());
1966 ex.addFilter ("Tex (*.tex)");
1967 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1968 if (ex.execDialog() )
1970 me->setExportMode(true);
1972 me->setExportMode(false);
1977 void Main::fileExportKDEBookmarks()
1979 ExportKDEBookmarks ex;
1980 MapEditor *me=currentMapEditor();
1983 ex.setMapCenter (me->getMapCenter() );
1988 void Main::fileExportTaskjuggler()
1990 ExportTaskjuggler ex;
1991 MapEditor *me=currentMapEditor();
1994 ex.setMapCenter (me->getMapCenter() );
1995 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
1996 ex.addFilter ("Taskjuggler (*.tjp)");
1997 if (ex.execDialog() )
1999 me->setExportMode(true);
2001 me->setExportMode(false);
2006 void Main::fileExportOOPresentation()
2008 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2009 // FIXME add extra info in dialog
2010 //ImagePreview *p =new ImagePreview (fd);
2011 //fd->setContentsPreviewEnabled( TRUE );
2012 //fd->setContentsPreview( p, p );
2013 //fd->setPreviewMode( QFileDialog::Contents );
2014 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2015 //fd->setDir (lastImageDir);
2018 if ( fd->exec() == QDialog::Accepted )
2020 QString fn=fd->selectedFile();
2021 //lastImageDir=fn.left(fn.findRev ("/"));
2022 if (currentMapEditor())
2023 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2027 void Main::fileCloseMap()
2029 if (currentMapEditor())
2031 if (currentMapEditor()->hasChanged())
2033 QMessageBox mb( __VYM,
2034 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2035 QMessageBox::Warning,
2036 QMessageBox::Yes | QMessageBox::Default,
2038 QMessageBox::Cancel | QMessageBox::Escape );
2039 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2040 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2043 case QMessageBox::Yes:
2045 fileSave(CompleteMap);
2047 case QMessageBox::No:
2048 // close without saving
2050 case QMessageBox::Cancel:
2055 currentMapEditor()->closeMap();
2056 tabWidget->removePage(currentMapEditor());
2057 if (tabWidget->count()==0)
2058 actionFilePrint->setEnabled (false);
2062 void Main::filePrint()
2064 if (currentMapEditor())
2065 currentMapEditor()->print();
2068 void Main::fileExitVYM()
2070 // Check if one or more editors have changed
2073 for (i=0;i<=tabWidget->count() -1;i++)
2076 me=(MapEditor*)tabWidget->page(i);
2078 // If something changed, ask what to do
2079 if (me->isUnsaved())
2081 tabWidget->setCurrentPage(i);
2082 QMessageBox mb( __VYM,
2083 tr("This map is not saved yet. Do you want to"),
2084 QMessageBox::Warning,
2085 QMessageBox::Yes | QMessageBox::Default,
2087 QMessageBox::Cancel | QMessageBox::Escape );
2088 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2089 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2091 // Call undocumented function: setActiveWindow is only
2092 // possible, if widget is visible. This depends on
2094 #if defined(Q_OS_LINUX)
2095 qt_wait_for_window_manager( this);
2097 mb.setActiveWindow();
2098 switch( mb.exec() ) {
2099 case QMessageBox::Yes:
2100 // save (the changed editors) and exit
2101 fileSave(CompleteMap);
2103 case QMessageBox::No:
2104 // exit without saving
2106 case QMessageBox::Cancel:
2107 // don't save and don't exit
2111 } // loop over all MEs
2115 void Main::editUndo()
2117 if (currentMapEditor())
2118 currentMapEditor()->undo();
2121 void Main::editRedo()
2123 if (currentMapEditor())
2124 currentMapEditor()->redo();
2127 void Main::editCopy()
2129 if (currentMapEditor())
2130 currentMapEditor()->copy();
2133 void Main::editPaste()
2135 if (currentMapEditor())
2136 currentMapEditor()->paste();
2139 void Main::editCut()
2141 if (currentMapEditor())
2142 currentMapEditor()->cut();
2145 void Main::editOpenFindWindow()
2147 findWindow->popup();
2148 findWindow->raise();
2150 // Call undocumented function: setActiveWindow is only
2151 // possible, if widget is visible. This depends on
2153 #if defined(Q_OS_LINUX)
2154 qt_wait_for_window_manager( this);
2156 findWindow->setActiveWindow();
2159 void Main::editFind(QString s)
2162 BranchObj *bo=currentMapEditor()->findText(s, cs);
2165 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2168 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2169 tr("No matches found for <b>%1</b>").arg(s));
2173 void Main::editFindChanged()
2174 { // Notify editor, to abort the current find process
2175 currentMapEditor()->findReset();
2178 void Main::editOpenURL()
2180 if (currentMapEditor())
2181 currentMapEditor()->openURL();
2184 void Main::editURL()
2186 if (currentMapEditor())
2187 currentMapEditor()->editURL();
2190 void Main::editHeading2URL()
2192 if (currentMapEditor())
2193 currentMapEditor()->editHeading2URL();
2196 void Main::editBugzilla2URL()
2198 if (currentMapEditor())
2199 currentMapEditor()->editBugzilla2URL();
2202 void Main::editFATE2URL()
2204 if (currentMapEditor())
2205 currentMapEditor()->editFATE2URL();
2208 void Main::editOpenVymLink()
2210 // Get current path to map
2211 QString currentVymLink;
2212 if (currentMapEditor())
2214 currentVymLink=currentMapEditor()->getVymLink();
2215 // compare path with already loaded maps
2219 for (i=0;i<=tabWidget->count() -1;i++)
2221 me=(MapEditor*)tabWidget->page(i);
2222 if (currentVymLink==me->getFilePath() )
2231 if (!QFile(currentVymLink).exists() )
2232 QMessageBox::critical( 0, tr( "Critical Error" ),
2233 tr("Couldn't open map %1").arg(currentVymLink));
2236 fileLoad (currentVymLink, NewMap);
2237 tabWidget->setCurrentPage (tabWidget->count()-1);
2240 // Go to tab containing the map
2241 tabWidget->setCurrentPage (index);
2245 void Main::editVymLink()
2247 if (currentMapEditor())
2248 currentMapEditor()->editVymLink();
2251 void Main::editDeleteVymLink()
2253 if (currentMapEditor())
2254 currentMapEditor()->deleteVymLink();
2257 void Main::editToggleHideExport()
2259 if (currentMapEditor())
2260 currentMapEditor()->setHideExport();
2263 void Main::editMapInfo()
2265 if (currentMapEditor())
2266 currentMapEditor()->editMapInfo();
2269 void Main::editMoveUp()
2271 if (currentMapEditor())
2272 currentMapEditor()->moveBranchUp();
2275 void Main::editMoveDown()
2277 if (currentMapEditor())
2278 currentMapEditor()->moveBranchDown();
2281 void Main::editToggleScroll()
2283 if (currentMapEditor())
2285 currentMapEditor()->toggleScroll();
2289 void Main::editUnScrollAll()
2291 if (currentMapEditor())
2293 currentMapEditor()->unScrollAll();
2297 void Main::editHeading()
2299 if (currentMapEditor())
2300 currentMapEditor()->editHeading();
2303 void Main::editNewBranch()
2305 if (currentMapEditor())
2306 currentMapEditor()->addNewBranch(0);
2309 void Main::editNewBranchHere()
2311 if (currentMapEditor())
2312 currentMapEditor()->addNewBranchHere();
2315 void Main::editNewBranchAbove()
2317 if (currentMapEditor())
2318 currentMapEditor()->addNewBranch(-1);
2321 void Main::editNewBranchBelow()
2323 if (currentMapEditor())
2324 currentMapEditor()->addNewBranch(1);
2327 void Main::editImportAdd()
2329 fileLoad (ImportAdd);
2332 void Main::editImportReplace()
2334 fileLoad (ImportReplace);
2337 void Main::editSaveBranch()
2339 fileSaveAs (PartOfMap);
2342 void Main::editRemoveBranchHere()
2344 if (currentMapEditor())
2345 currentMapEditor()->removeBranchHere();
2348 void Main::editRemoveChilds()
2350 if (currentMapEditor())
2351 currentMapEditor()->removeChilds();
2354 void Main::editDeleteSelection()
2356 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2357 currentMapEditor()->deleteSelection();
2360 void Main::editUpperBranch()
2362 if (currentMapEditor())
2363 currentMapEditor()->selectUpperBranch();
2366 void Main::editLowerBranch()
2368 if (currentMapEditor())
2369 currentMapEditor()->selectLowerBranch();
2372 void Main::editLeftBranch()
2374 if (currentMapEditor())
2375 currentMapEditor()->selectLeftBranch();
2378 void Main::editRightBranch()
2380 if (currentMapEditor())
2381 currentMapEditor()->selectRightBranch();
2384 void Main::editFirstBranch()
2386 if (currentMapEditor())
2387 currentMapEditor()->selectFirstBranch();
2390 void Main::editLastBranch()
2392 if (currentMapEditor())
2393 currentMapEditor()->selectLastBranch();
2396 void Main::editLoadImage()
2398 if (currentMapEditor())
2399 currentMapEditor()->loadFloatImage();
2402 void Main::editSaveImage(int item)
2404 if (currentMapEditor())
2405 currentMapEditor()->saveFloatImage(item);
2408 void Main::editFollowXLink(int item)
2410 if (currentMapEditor())
2411 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2414 void Main::editEditXLink(int item)
2416 if (currentMapEditor())
2417 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2420 void Main::formatSelectColor()
2422 if (currentMapEditor())
2424 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2425 if ( !col.isValid() ) return;
2426 currentMapEditor()->setColor( col );
2427 colorChanged( col );
2431 void Main::formatPickColor()
2433 if (currentMapEditor())
2434 colorChanged( currentMapEditor()->pickColor() );
2437 void Main::colorChanged(QColor c)
2439 QPixmap pix( 16, 16 );
2441 actionFormatColor->setIconSet( pix );
2444 void Main::formatColorItem()
2446 if (currentMapEditor())
2447 currentMapEditor()->colorItem();
2450 void Main::formatColorBranch()
2452 if (currentMapEditor())
2453 currentMapEditor()->colorBranch();
2456 void Main::formatLinkStyleLine()
2458 if (currentMapEditor())
2459 currentMapEditor()->setLinkStyle(StyleLine);
2462 void Main::formatLinkStyleParabel()
2464 if (currentMapEditor())
2465 currentMapEditor()->setLinkStyle(StyleParabel);
2468 void Main::formatLinkStylePolyLine()
2470 if (currentMapEditor())
2471 currentMapEditor()->setLinkStyle(StylePolyLine);
2474 void Main::formatLinkStylePolyParabel()
2476 if (currentMapEditor())
2477 currentMapEditor()->setLinkStyle(StylePolyParabel);
2480 void Main::formatSelectBackColor()
2482 if (currentMapEditor())
2483 currentMapEditor()->selectBackgroundColor();
2486 void Main::formatSelectLinkColor()
2488 if (currentMapEditor())
2489 currentMapEditor()->selectLinkColor();
2492 void Main::formatToggleLinkColorHint()
2494 currentMapEditor()->toggleLinkColorHint();
2497 void Main::formatFrameNone()
2499 if (currentMapEditor())
2500 currentMapEditor()->setFrame(NoFrame);
2503 void Main::formatFrameRectangle()
2505 if (currentMapEditor())
2506 currentMapEditor()->setFrame(Rectangle);
2509 void Main::formatIncludeImagesVer()
2511 if (currentMapEditor())
2512 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2515 void Main::formatIncludeImagesHor()
2517 if (currentMapEditor())
2518 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2521 void Main::formatHideLinkUnselected()
2523 if (currentMapEditor())
2524 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2527 void Main::viewZoomReset()
2529 if (currentMapEditor())
2533 currentMapEditor()->setWorldMatrix( m );
2534 currentMapEditor()->setViewCenter();
2535 currentMapEditor()->adjustCanvasSize();
2539 void Main::viewZoomIn()
2541 if (currentMapEditor())
2543 QWMatrix m = currentMapEditor()->worldMatrix();
2544 m.scale( 1.25, 1.25 );
2545 currentMapEditor()->setWorldMatrix( m );
2546 currentMapEditor()->setViewCenter();
2547 currentMapEditor()->adjustCanvasSize();
2551 void Main::viewZoomOut()
2553 if (currentMapEditor())
2555 QWMatrix m = currentMapEditor()->worldMatrix();
2556 m.scale( 0.8, 0.8 );
2557 currentMapEditor()->setWorldMatrix( m );
2558 currentMapEditor()->setViewCenter();
2559 currentMapEditor()->adjustCanvasSize();
2563 void Main::modModeColor()
2567 void Main::modModeLink()
2571 bool Main::settingsPDF()
2573 // Default browser is set in constructor
2575 QString text = QInputDialog::getText(
2576 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2577 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2579 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2584 bool Main::settingsURL()
2586 // Default browser is set in constructor
2588 QString text = QInputDialog::getText(
2589 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2590 settings.readEntry("/vym/mainwindow/readerURL")
2593 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2597 void Main::windowToggleNoteEditor()
2599 if (textEditor->showWithMain() )
2600 windowHideNoteEditor();
2602 windowShowNoteEditor();
2605 void Main::updateNoteFlag()
2607 if (currentMapEditor())
2608 currentMapEditor()->updateNoteFlag();
2611 void Main::windowShowNoteEditor()
2613 textEditor->setShowWithMain(true);
2615 actionViewToggleNoteEditor->setOn (true);
2618 void Main::windowHideNoteEditor()
2620 textEditor->setShowWithMain(false);
2622 actionViewToggleNoteEditor->setOn (false);
2625 void Main::windowNextEditor()
2627 if (tabWidget->currentPageIndex() < tabWidget->count())
2628 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2631 void Main::windowPreviousEditor()
2633 if (tabWidget->currentPageIndex() >0)
2634 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2637 void Main::standardFlagChanged()
2639 currentMapEditor()->toggleStandardFlag(sender()->name());
2642 void Main::testFunction()
2644 currentMapEditor()->testFunction();
2647 void Main::helpDoc()
2650 #if defined(Q_OS_MACX)
2651 docpath="./vym.app/Contents/vym.pdf";
2653 // default path in SUSE LINUX
2654 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2657 if (!QFile (docpath).exists() )
2659 // relative path for easy testing in tarball
2660 docpath="doc/vym.pdf";
2661 if (!QFile (docpath).exists() )
2663 // relative path for testing while still writing vym.tex
2664 docpath="doc/tex/vym.pdf";
2665 if (!QFile (docpath).exists() )
2667 // Try yet another one for Knoppix
2668 docpath="/usr/share/doc/packages/vym/vym.pdf";
2669 if (!QFile (docpath).exists() )
2671 QMessageBox::critical(0,
2672 tr("Critcal error"),
2673 tr("Couldn't find the documentation\n"
2674 "vym.pdf in various places."));
2681 Process *pdfProc = new Process();
2682 pdfProc->clearArguments();
2683 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2684 pdfProc->addArgument( docpath);
2686 if ( !pdfProc->start() )
2689 QMessageBox::critical(0,
2690 tr("Critcal error"),
2691 tr("Couldn't find a viewer to read vym.pdf.\n"
2692 "Please use Settings->")+tr("Set application to open pdf files"));
2698 void Main::helpAbout()
2701 ad.setName ("aboutwindow");
2702 ad.setMinimumSize(500,500);
2703 ad.resize (QSize (500,500));
2707 void Main::helpAboutQT()
2709 QMessageBox::aboutQt( this, "Qt Application Example" );