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"
67 #include "exportxhtmldialog.h"
69 #include "flagrowobj.h"
71 #include "mapeditor.h"
76 #include "showtextdialog.h"
77 #include "texteditor.h"
80 extern TextEditor *textEditor;
81 extern Main *mainWindow;
82 extern QString tmpVymDir;
83 extern QString clipboardDir;
84 extern bool clipboardEmpty;
85 extern int statusbarTime;
86 extern FlagRowObj* standardFlagsDefault;
87 extern FlagRowObj* systemFlagsDefault;
89 extern QPtrList <QAction> actionListBranches;
91 extern QAction* actionFileSave;
92 extern QAction* actionFilePrint;
93 extern QAction* actionEditUndo;
94 extern QAction* actionEditRedo;
95 extern QAction *actionEditCopy;
96 extern QAction *actionEditCut;
97 extern QAction *actionEditPaste;
98 extern QAction *actionEditMoveUp;
99 extern QAction *actionEditMoveDown;
100 extern QAction *actionEditToggleScroll;
101 extern QAction* actionEditOpenURL;
102 extern QAction* actionEditURL;
103 extern QAction* actionEditHeading2URL;
104 extern QAction* actionEditBugzilla2URL;
105 extern QAction* actionEditFATE2URL;
106 extern QAction *actionEditOpenVymLink;
107 extern QAction *actionEditVymLink;
108 extern QAction *actionEditDeleteVymLink;
109 extern QAction *actionEditMapInfo;
110 extern QAction *actionEditHeading;
111 extern QAction *actionEditDelete;
112 extern QAction *actionEditAddBranch;
113 extern QAction *actionEditAddBranchHere;
114 extern QAction *actionEditAddBranchAbove;
115 extern QAction *actionEditAddBranchBelow;
116 extern QAction *actionEditRemoveBranchHere;
117 extern QAction *actionEditRemoveChilds;
118 extern QAction *actionEditImportAdd;
119 extern QAction *actionEditImportReplace;
120 extern QAction *actionEditSaveBranch;
121 extern QAction *actionEditSelectFirst;
122 extern QAction *actionEditSelectLast;
123 extern QAction *actionEditLoadImage;
124 extern QAction *actionEditToggleFloatExport;
126 extern QAction* actionFormatColor;
127 extern QAction* actionFormatPickColor;
128 extern QAction* actionFormatColorBranch;
129 extern QAction* actionFormatColorSubtree;
130 extern QAction* actionFormatLinkColorHint;
131 extern QAction* actionFormatBackColor;
132 extern QAction* actionFormatLinkColor;
133 extern QAction *actionFormatIncludeImagesVer;
134 extern QAction *actionFormatIncludeImagesHor;
136 extern QActionGroup* actionGroupModModes;
137 extern QAction* actionModModeColor;
138 extern QAction* actionModModeLink;
139 extern QAction* actionModModeCopy;
141 extern QActionGroup *actionGroupFormatFrameTypes;
142 extern QAction *actionFormatFrameNone;
143 extern QAction *actionFormatFrameRectangle;
145 extern QActionGroup *actionGroupFormatLinkStyles;
146 extern QAction *actionFormatLinkStyleLine;
147 extern QAction *actionFormatLinkStyleParabel;
148 extern QAction *actionFormatLinkStylePolyLine;
149 extern QAction *actionFormatLinkStylePolyParabel;
150 extern QAction *actionFormatHideLinkUnselected;
152 extern QAction *actionViewToggleNoteEditor;
154 extern QAction* actionSettingsAutoedit;
155 extern QAction* actionSettingsAutoselectHeading;
156 extern QAction* actionSettingsAutoselectHeading;
157 extern QAction* actionSettingsAutoselectText;
158 extern QAction* actionSettingsPasteNewHeading;
159 extern QAction* actionSettingsUseDelKey;
160 extern QAction* actionSettingsUseFlagGroups;
162 extern QPopupMenu* branchContextMenu;
163 extern QPopupMenu* branchAddContextMenu;
164 extern QPopupMenu* branchRemoveContextMenu;
165 extern QPopupMenu* branchLinksContextMenu;
166 extern QPopupMenu* branchLinksContextMenuDup;
167 extern QPopupMenu* floatimageContextMenu;
168 extern QPopupMenu* saveImageFormatMenu;
169 extern QPopupMenu* canvasContextMenu;
170 extern QPopupMenu* lastMapsMenu;
171 extern QPopupMenu* importMenu;
172 extern QPopupMenu* exportMenu;
173 extern QPopupMenu* exportImageFormatMenu;
176 extern Settings settings;
177 extern Options options;
179 #if defined(Q_OS_LINUX)
180 extern void qt_wait_for_window_manager( QWidget* w );
183 Main::Main(QWidget* parent, const char* name, WFlags f) :
184 QMainWindow(parent,name,f)
188 setCaption ("VYM - View Your Mind");
190 // Load window settings
191 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
192 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
193 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
194 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
197 // Create unique temporary directory
198 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
200 // Create direcctory for clipboard
201 clipboardDir=tmpVymDir+"/clipboard";
202 QDir d(clipboardDir);
203 d.mkdir (clipboardDir,true);
204 makeSubDirs (clipboardDir);
207 // FIXME not used currently
208 // Set random seed (random used for object IDs)
209 // QTime t = QTime::currentTime(); // set random seed
210 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
213 // Initialize some settings, which are platform dependant
216 // application to open URLs
217 p="/vym/mainwindow/readerURL";
218 #if defined(Q_OS_LINUX)
219 s=settings.readEntry (p,"konqueror");
221 #if defined(Q_OS_MACX)
222 s=settings.readEntry (p,"/usr/bin/open");
224 s=settings.readEntry (p,"mozilla");
227 settings.writeEntry( p,s);
229 // application to open PDFs
230 p="/vym/mainwindow/readerPDF";
231 #if defined(Q_OS_LINUX)
232 s=settings.readEntry (p,"acroread");
234 #if defined(Q_OS_MACX)
235 s=settings.readEntry (p,"/usr/bin/open");
237 s=settings.readEntry (p,"acroread");
240 settings.writeEntry( p,s);
245 // Create tab widget which holds the maps
246 tabWidget= new QTabWidget (this);
247 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
248 this, SLOT( editorChanged( QWidget * ) ) );
250 setCentralWidget(tabWidget);
254 setupFormatActions();
258 setupSettingsActions();
260 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
263 // After menu is created, we can enable some actions
264 actionFilePrint->setEnabled (true);
269 // Initialize Find window
270 findWindow=new FindWindow(NULL,"findwindow");
271 connect (findWindow, SIGNAL( findButton(QString) ),
272 this, SLOT(editFind(QString) ) );
273 connect (findWindow, SIGNAL( somethingChanged() ),
274 this, SLOT(editFindChanged() ) );
276 // Connect TextEditor, so that we can update flags if text changes
277 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
285 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
286 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
287 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
288 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
290 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
291 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
293 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
294 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
295 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
296 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
297 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
298 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
301 int maps=lastMaps.count();
302 settings.writeEntry( "/vym/lastMaps/number",maps );
303 for (int i=1;i<=maps;i++)
305 QStringList::Iterator it = lastMaps.at(i-1);
306 s=QString("/vym/lastMaps/map-%1").arg(i);
307 if (!s.isEmpty() && i<=maxLastMaps)
308 settings.writeEntry (s, *it);
312 // To make the texteditor save its settings, call the destructor
315 // Remove temporary directory
316 removeDir (QDir(tmpVymDir));
319 void Main::loadCmdLine()
321 /* TODO draw some kind of splashscreen while loading...
327 QStringList flist=options.getFileList();
328 QStringList::Iterator it=flist.begin();
330 while (it !=flist.end() )
332 fileLoad (*it, NewMap);
338 void Main::statusMessage(const QString &s)
340 statusBar()->message (s);
343 void Main::closeEvent (QCloseEvent* )
349 void Main::setupFileActions()
351 QToolBar *tb = new QToolBar( this );
352 tb->setLabel( "File Actions" );
353 QPopupMenu *menu = new QPopupMenu( this );
354 menuBar()->insertItem( tr( "&File" ), menu );
356 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
359 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
360 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
364 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
365 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
369 lastMapsMenu = new QPopupMenu (this);
371 menu->insertItem (tr("Open Recent"),lastMapsMenu );
372 menu->insertSeparator();
374 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
375 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
380 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
381 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
384 menu->insertSeparator();
386 importMenu = new QPopupMenu (this);
387 menu->insertItem (tr("Import"),importMenu );
389 a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
390 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
391 a->addTo (importMenu);
393 a = new QAction( tr( "Import")+" "+tr("Mind Manager" ), QPixmap(), tr("Mind Manager")+QString("..."), 0, this, "importMM" );
394 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
395 a->addTo (importMenu);
397 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
398 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
399 a->addTo( importMenu);
401 exportMenu = new QPopupMenu (this);
402 menu->insertItem (tr("Export"),exportMenu );
404 menu->insertSeparator();
407 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" );
408 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
413 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
414 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
417 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
418 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
424 void Main::setupEditActions()
426 QToolBar *tb = new QToolBar( this );
427 tb->setLabel( "Edit Actions" );
428 QPopupMenu *menu = new QPopupMenu( this );
429 menuBar()->insertItem( tr( "&Edit" ), menu );
433 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
434 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
435 a->setEnabled (false);
440 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
442 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
443 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
448 menu->insertSeparator();
449 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
450 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
451 a->setEnabled (false);
455 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
456 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
457 a->setEnabled (false);
461 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
462 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
463 a->setEnabled (false);
468 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
469 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
470 a->setEnabled (false);
473 actionListBranches.append(a);
476 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
477 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
478 a->setEnabled (false);
481 actionListBranches.append(a);
482 actionEditMoveDown=a;
485 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
486 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
487 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
488 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
489 #if defined(Q_OS_MACX)
490 actionEditToggleScroll=alt;
492 actionEditToggleScroll=a;
494 actionEditToggleScroll->setEnabled (false);
495 actionEditToggleScroll->addTo( tb );
496 actionEditToggleScroll->addTo( menu );
497 actionListBranches.append(actionEditToggleScroll);
499 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
500 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
503 menu->insertSeparator();
505 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
506 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
509 menu->insertSeparator();
511 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
512 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
514 a->setEnabled (false);
517 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
518 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
519 a->setEnabled (false);
520 actionListBranches.append(a);
523 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
524 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
525 a->setEnabled (false);
526 actionListBranches.append(a);
527 actionEditHeading2URL=a;
529 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
530 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
531 a->setEnabled (false);
532 actionListBranches.append(a);
533 actionEditBugzilla2URL=a;
535 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
536 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
537 a->setEnabled (false);
538 actionListBranches.append(a);
539 actionEditFATE2URL=a;
541 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" );
542 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
544 a->setEnabled (false);
545 actionEditOpenVymLink=a;
547 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
548 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
549 a->setEnabled (false);
550 actionListBranches.append(a);
553 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
554 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
555 a->setEnabled (false);
556 actionEditDeleteVymLink=a;
558 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
559 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
560 a->setEnabled (true);
563 menu->insertSeparator();
565 // Shortcuts to modify heading:
566 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
567 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
568 actionListBranches.append(a);
569 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
570 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
571 actionListBranches.append(a);
573 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
574 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
575 a->setEnabled (false);
577 actionListBranches.append(a);
579 // Shortcut to delete selection
580 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
581 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
582 a->setEnabled (false);
585 // Shortcut to add branch
586 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
587 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
588 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
589 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
590 a->setEnabled (false);
591 actionListBranches.append(a);
592 #if defined (Q_OS_MACX)
593 // In OSX show different shortcut in menues, the keys work independtly always
594 actionEditAddBranch=alt;
596 actionEditAddBranch=a;
599 // Add branch by inserting it at selection
600 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
601 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
602 a->setEnabled (false);
603 actionListBranches.append(a);
604 actionEditAddBranchHere=a;
605 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
606 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
607 actionListBranches.append(a);
610 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
611 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
612 a->setEnabled (false);
613 actionListBranches.append(a);
614 actionEditAddBranchAbove=a;
615 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
616 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
617 actionListBranches.append(a);
620 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
621 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
622 a->setEnabled (false);
623 actionListBranches.append(a);
624 actionEditAddBranchBelow=a;
625 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
626 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
627 actionListBranches.append(a);
629 // Import at selection (adding to selection)
630 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
631 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 actionEditImportAdd=a;
636 // Import at selection (replacing selection)
637 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
638 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
639 a->setEnabled (false);
640 actionListBranches.append(a);
641 actionEditImportReplace=a;
644 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
645 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
646 a->setEnabled (false);
647 actionListBranches.append(a);
648 actionEditSaveBranch=a;
650 // Only remove branch, not its childs
651 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
652 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
653 a->setEnabled (false);
654 actionListBranches.append(a);
655 actionEditRemoveBranchHere=a;
657 // Only remove childs of a branch
658 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
659 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
660 a->setEnabled (false);
661 actionListBranches.append(a);
662 actionEditRemoveChilds=a;
664 // Shortcuts for navigating with cursor:
665 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
666 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
667 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
668 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
669 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
670 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
671 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
672 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
673 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
674 a->setEnabled (false);
676 actionListBranches.append(a);
677 actionEditSelectFirst=a;
678 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
679 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
680 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
681 a->setEnabled (false);
683 actionListBranches.append(a);
684 actionEditSelectLast=a;
686 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
687 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
688 actionEditLoadImage=a;
693 void Main::setupFormatActions()
695 QPopupMenu *menu = new QPopupMenu( this );
696 menuBar()->insertItem( tr( "&Format" ), menu );
698 QToolBar *tb = new QToolBar( this );
702 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
703 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
704 actionFormatColor->addTo( tb );
705 actionFormatColor->addTo( menu );
706 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" );
707 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
708 a->setEnabled (false);
711 actionListBranches.append(a);
712 actionFormatPickColor=a;
713 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
714 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
715 a->setEnabled (false);
718 actionListBranches.append(a);
719 actionFormatColorBranch=a;
720 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
721 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
722 a->setEnabled (false);
725 actionListBranches.append(a);
726 actionFormatColorSubtree=a;
728 menu->insertSeparator();
729 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
730 actionGroupFormatLinkStyles->setExclusive (true);
731 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
732 a->setToggleAction(true);
733 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
734 actionFormatLinkStyleLine=a;
735 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
736 a->setToggleAction(true);
737 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
738 actionFormatLinkStyleParabel=a;
739 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
740 a->setToggleAction(true);
741 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
742 actionFormatLinkStylePolyLine=a;
743 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
744 a->setToggleAction(true);
745 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
746 actionFormatLinkStylePolyParabel=a;
747 actionGroupFormatLinkStyles->addTo (menu);
749 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
750 actionGroupFormatFrameTypes->setExclusive (true);
751 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
752 a->setToggleAction(true);
753 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
754 actionFormatFrameNone=a;
755 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
756 a->setToggleAction(true);
757 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
758 actionFormatFrameRectangle=a;
760 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
761 a->setToggleAction(true);
762 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
763 actionFormatIncludeImagesVer=a;
765 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
766 a->setToggleAction(true);
767 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
768 actionFormatIncludeImagesHor=a;
770 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
771 a->setToggleAction(true);
772 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
773 actionFormatHideLinkUnselected=a;
775 menu->insertSeparator();
776 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
777 a->setToggleAction(true);
778 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
780 actionFormatLinkColorHint=a;
782 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
783 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
784 actionFormatLinkColor->addTo( menu );
785 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
786 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
787 actionFormatBackColor->addTo( menu );
791 void Main::setupViewActions()
793 QToolBar *tb = new QToolBar( this );
794 tb->setLabel( "View Actions" );
795 QPopupMenu *menu = new QPopupMenu( this );
796 menuBar()->insertItem( tr( "&View" ), menu );
799 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
800 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
803 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
804 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
807 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
808 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
811 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
812 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
813 a->setToggleAction(true);
814 if (textEditor->showWithMain())
820 actionViewToggleNoteEditor=a;
821 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
822 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
824 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
825 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
830 void Main::setupModeActions()
832 //QPopupMenu *menu = new QPopupMenu( this );
833 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
835 QToolBar *tb = new QToolBar( this );
836 tb->setLabel( tr ("Modes when using modifiers") );
838 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
839 actionGroupModModes->setExclusive (true);
840 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
841 a->setToggleAction(true);
844 actionModModeColor=a;
846 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
847 a->setToggleAction(true);
851 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
852 a->setToggleAction(true);
858 void Main::setupFlagActions()
860 // Create System Flags
861 systemFlagsDefault = new FlagRowObj ();
862 systemFlagsDefault->setVisibility (false);
863 systemFlagsDefault->setName ("systemFlagsDef");
865 FlagObj *fo = new FlagObj ();
866 fo->load(QPixmap(flag_note_xpm));
868 fo->setToolTip(tr("Note","Systemflag"));
869 systemFlagsDefault->addFlag (fo); // makes deep copy
871 fo->load(QPixmap(flag_url_xpm));
873 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
874 systemFlagsDefault->addFlag (fo);
876 fo->load(QPixmap(flag_vymlink_xpm));
877 fo->setName("vymLink");
878 fo->setToolTip(tr("Link to another vym map","Systemflag"));
879 systemFlagsDefault->addFlag (fo);
881 fo->load(QPixmap(flag_scrolled_right_xpm));
882 fo->setName("scrolledright");
883 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
884 systemFlagsDefault->addFlag (fo);
886 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
887 fo->setName("tmpUnscrolledright");
888 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
889 systemFlagsDefault->addFlag (fo);
891 // Create Standard Flags
892 standardFlagsDefault = new FlagRowObj ();
893 standardFlagsDefault->setVisibility (false);
894 standardFlagsDefault->setName ("standardFlagsDef");
896 fo->load(QPixmap(flag_exclamationmark_xpm));
897 fo->setName ("exclamationmark");
898 fo->setGroup("standard-mark");
899 fo->setToolTip(tr("Take care!","Standardflag"));
900 standardFlagsDefault->addFlag (fo); // makes deep copy
902 fo->load(QPixmap(flag_questionmark_xpm));
903 fo->setName("questionmark");
904 fo->setGroup("standard-mark");
905 fo->setToolTip(tr("Really?","Standardflag"));
906 standardFlagsDefault->addFlag (fo);
908 fo->load(QPixmap(flag_hook_green_xpm));
909 fo->setName("hook-green");
910 fo->setGroup("standard-hook");
911 fo->setToolTip(tr("ok!","Standardflag"));
912 standardFlagsDefault->addFlag (fo);
914 fo->load(QPixmap(flag_cross_red_xpm));
915 fo->setName("cross-red");
916 fo->setGroup("standard-hook");
917 fo->setToolTip(tr("Not ok!","Standardflag"));
918 standardFlagsDefault->addFlag (fo);
920 fo->load(QPixmap(flag_stopsign_xpm));
921 fo->setName("stopsign");
922 fo->setToolTip(tr("This won't work!","Standardflag"));
923 standardFlagsDefault->addFlag (fo);
925 fo->load(QPixmap(flag_smiley_good_xpm));
926 fo->setName("smiley-good");
927 fo->setGroup("standard-smiley");
928 fo->setToolTip(tr("Good","Standardflag"));
929 standardFlagsDefault->addFlag (fo);
931 fo->load(QPixmap(flag_smiley_sad_xpm));
932 fo->setName("smiley-sad");
933 fo->setGroup("standard-smiley");
934 fo->setToolTip(tr("Bad","Standardflag"));
935 standardFlagsDefault->addFlag (fo);
937 fo->load(QPixmap(flag_clock_xpm));
938 fo->setName("clock");
939 fo->setToolTip(tr("Time critical","Standardflag"));
940 standardFlagsDefault->addFlag (fo);
942 fo->load(QPixmap(flag_lamp_xpm));
944 fo->setToolTip(tr("Idea!","Standardflag"));
945 standardFlagsDefault->addFlag (fo);
947 fo->load(QPixmap(flag_arrow_up_xpm));
948 fo->setName("arrow-up");
949 fo->setGroup("standard-arrow");
950 fo->setToolTip(tr("Important","Standardflag"));
951 standardFlagsDefault->addFlag (fo);
953 fo->load(QPixmap(flag_arrow_down_xpm));
954 fo->setName("arrow-down");
955 fo->setGroup("standard-arrow");
956 fo->setToolTip(tr("Unimportant","Standardflag"));
957 standardFlagsDefault->addFlag (fo);
959 fo->load(QPixmap(flag_thumb_up_xpm));
960 fo->setName("thumb-up");
961 fo->setGroup("standard-thumb");
962 fo->setToolTip(tr("I like this","Standardflag"));
963 standardFlagsDefault->addFlag (fo);
965 fo->load(QPixmap(flag_thumb_down_xpm));
966 fo->setName("thumb-down");
967 fo->setGroup("standard-thumb");
968 fo->setToolTip(tr("I like this","Standardflag"));
969 fo->setToolTip(tr("I do not like this","Standardflag"));
970 standardFlagsDefault->addFlag (fo);
972 fo->load(QPixmap(flag_heart_xpm));
973 fo->setName("heart");
974 fo->setToolTip(tr("I just love... ","Standardflag"));
975 standardFlagsDefault->addFlag (fo);
977 fo->load(QPixmap(flag_flash_xpm));
978 fo->setName("flash");
979 fo->setToolTip(tr("Dangerous","Standardflag"));
980 standardFlagsDefault->addFlag (fo);
982 fo->load(QPixmap(flag_lifebelt_xpm));
983 fo->setName("lifebelt");
984 fo->setToolTip(tr("This will help","Standardflag"));
985 standardFlagsDefault->addFlag (fo);
988 standardFlagsDefault->makeToolbar(this, "Standard Flags");
992 void Main::setupSettingsActions()
994 QPopupMenu *menu = new QPopupMenu( this );
995 menuBar()->insertItem( tr( "&Settings" ), menu );
1000 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1001 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1004 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1005 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1008 menu->insertSeparator();
1009 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1010 a->setToggleAction(true);
1011 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1013 actionSettingsAutoedit=a;
1015 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1016 a->setToggleAction(true);
1017 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1019 actionSettingsAutoselectHeading=a;
1021 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1022 a->setToggleAction(true);
1023 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1025 actionSettingsAutoselectText=a;
1027 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1028 a->setToggleAction(true);
1029 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1031 actionSettingsPasteNewHeading=a;
1033 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1034 a->setToggleAction(true);
1035 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1037 actionSettingsUseDelKey=a;
1039 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1040 a->setToggleAction(true);
1041 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1043 actionSettingsUseFlagGroups=a;
1047 void Main::setupTestActions()
1049 QPopupMenu *menu = new QPopupMenu( this );
1050 menuBar()->insertItem( tr( "&Test" ), menu );
1053 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1054 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1059 void Main::setupHelpActions()
1061 QPopupMenu *menu = new QPopupMenu( this );
1062 menuBar()->insertItem( tr( "&Help" ), menu );
1065 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1066 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1069 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1070 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1073 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1074 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1079 void Main::setupContextMenus()
1083 // Context Menu for branch or mapcenter
1084 branchContextMenu =new QPopupMenu (this);
1087 branchAddContextMenu =new QPopupMenu (this);
1088 actionEditPaste->addTo ( branchAddContextMenu );
1089 actionEditAddBranch->addTo ( branchAddContextMenu );
1090 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1091 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1092 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1093 branchAddContextMenu->insertSeparator();
1094 actionEditLoadImage->addTo( branchAddContextMenu );
1095 branchAddContextMenu->insertSeparator();
1096 actionEditImportAdd->addTo ( branchAddContextMenu );
1097 actionEditImportReplace->addTo ( branchAddContextMenu );
1100 branchRemoveContextMenu =new QPopupMenu (this);
1101 actionEditCut->addTo ( branchRemoveContextMenu );
1102 actionEditDelete->addTo ( branchRemoveContextMenu );
1103 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
1104 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1106 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1107 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1109 actionEditSaveBranch->addTo( branchContextMenu );
1111 branchContextMenu->insertSeparator();
1112 actionEditOpenURL->addTo ( branchContextMenu );
1113 actionEditURL->addTo ( branchContextMenu );
1114 actionEditHeading2URL->addTo ( branchContextMenu );
1115 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1117 actionEditBugzilla2URL->addTo( branchContextMenu );
1118 actionEditFATE2URL->addTo( branchContextMenu );
1120 branchContextMenu->insertSeparator();
1121 actionEditOpenVymLink->addTo ( branchContextMenu );
1122 actionEditVymLink->addTo ( branchContextMenu );
1123 actionEditDeleteVymLink->addTo ( branchContextMenu );
1125 branchContextMenu->insertSeparator();
1126 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1128 branchContextMenu->insertSeparator();
1129 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1130 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1131 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1133 // Context Menu for links in a branch menu
1134 // This will be populated "on demand" in MapEditor::updateActions
1135 branchContextMenu->insertSeparator();
1136 branchLinksContextMenu =new QPopupMenu (this);
1137 branchLinksContextMenuDup =new QPopupMenu (this);
1138 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1139 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1141 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1142 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1144 // Context menu for floatimage
1145 floatimageContextMenu =new QPopupMenu (this);
1146 saveImageFormatMenu=new QPopupMenu (this);
1147 exportImageFormatMenu=new QPopupMenu (this);
1149 QStrList fmt = QImage::outputFormats();
1150 for (const char* f = fmt.first(); f; f = fmt.next())
1152 saveImageFormatMenu->insertItem( f );
1153 exportImageFormatMenu->insertItem( f );
1155 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1156 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1157 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1159 floatimageContextMenu->insertSeparator();
1160 actionEditCopy->addTo( floatimageContextMenu );
1161 actionEditCut->addTo( floatimageContextMenu );
1163 floatimageContextMenu->insertSeparator();
1164 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1165 a->setToggleAction(true);
1166 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1167 a->addTo( floatimageContextMenu);
1168 actionEditToggleFloatExport=a;
1170 floatimageContextMenu->insertSeparator();
1171 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1173 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1174 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1175 a->addTo (exportMenu);
1177 exportMenu->insertItem ( tr("Export as Image"),exportImageFormatMenu);
1179 a = new QAction( tr( "Export as ASCII")+" "+tr("(still experimental)" ), QPixmap(), "ASCII...", 0, this, "exportASCII" );
1180 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1181 a->addTo( exportMenu );
1183 a = new QAction( tr( "Export as LaTeX")+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1184 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1185 a->addTo( exportMenu );
1187 a = new QAction( tr( "Export as XML" ), QPixmap(), "XML...", 0, this, "exportXML" );
1188 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1189 a->addTo( exportMenu );
1191 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1193 a = new QAction( tr( "Export as HTML" ), QPixmap(), "HTML...", 0, this, "exportHTML");
1194 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1195 a->addTo( exportMenu );
1198 a = new QAction( tr( "Export as XHTML" ), QPixmap(), "XHTML...", ALT + Key_X, this, "exportXHTML" );
1199 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1200 a->addTo( exportMenu );
1203 // Context menu for canvas
1204 canvasContextMenu =new QPopupMenu (this);
1205 actionEditMapInfo->addTo( canvasContextMenu );
1206 canvasContextMenu->insertSeparator();
1207 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1208 canvasContextMenu->insertSeparator();
1209 actionFormatLinkColorHint->addTo( canvasContextMenu );
1210 actionFormatLinkColor->addTo( canvasContextMenu );
1211 actionFormatBackColor->addTo( canvasContextMenu );
1213 // Menu for last opened files
1214 // Read settings initially
1216 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1217 for (int i=1;i<=j;i++)
1219 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1220 if (!s.isEmpty() && j<=maxLastMaps)
1223 setupLastMapsMenu();
1224 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1227 void Main::setupLastMapsMenu()
1229 // Remove double entries
1230 QStringList::Iterator it=lastMaps.begin();
1231 QStringList::Iterator jt;
1232 while (it!=lastMaps.end() )
1236 while (jt!=lastMaps.end() )
1239 jt=lastMaps.remove(jt);
1246 // Limit length of list to maxLastMaps
1247 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1249 // build Menu from lastMaps string list
1250 lastMapsMenu->clear();
1251 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1252 lastMapsMenu->insertItem (*it );
1256 void Main::hideEvent (QHideEvent * )
1258 if (!textEditor->isMinimized() ) textEditor->hide();
1261 void Main::showEvent (QShowEvent * )
1263 if (textEditor->showWithMain()) textEditor->showNormal();
1266 bool Main::reallyWriteDirectory(const QString &dir)
1268 QStringList eList = QDir(dir).entryList();
1269 if (eList.first() ==".") eList.pop_front(); // remove "."
1270 if (eList.first() =="..") eList.pop_front(); // remove "."
1271 if (!eList.isEmpty())
1273 QMessageBox mb( __VYM,
1274 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1275 QMessageBox::Warning,
1277 QMessageBox::Cancel | QMessageBox::Default,
1278 QMessageBox::QMessageBox::NoButton );
1280 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1281 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1284 case QMessageBox::Yes:
1287 case QMessageBox::Cancel:
1295 QString Main::browseDirectory (const QString &caption)
1297 QFileDialog fd(this,caption);
1298 fd.setMode (QFileDialog::DirectoryOnly);
1299 fd.setCaption(__VYM " - "+caption);
1302 if ( fd.exec() == QDialog::Accepted )
1303 return fd.selectedFile();
1308 MapEditor* Main::currentMapEditor() const
1310 if ( tabWidget->currentPage() &&
1311 tabWidget->currentPage()->inherits( "MapEditor" ) )
1312 return (MapEditor*)tabWidget->currentPage();
1316 //TODO not used now, maybe use this for overview window later
1317 void Main::newView()
1319 // Open a new view... have it delete when closed.
1320 Main *m = new Main(0, 0, WDestructiveClose);
1321 qApp->setMainWidget(m);
1323 qApp->setMainWidget(0);
1326 void Main::editorChanged(QWidget *)
1328 // Unselect all possibly selected objects
1329 // (Important to update note editor)
1332 for (i=0;i<=tabWidget->count() -1;i++)
1335 me=(MapEditor*)tabWidget->page(i);
1338 currentMapEditor()->reselect();
1340 // Update actions to in menus and toolbars according to editor
1341 currentMapEditor()->updateActions();
1344 void Main::fileNew()
1346 QString fn="unnamed";
1347 MapEditor* medit = new MapEditor (tabWidget, true);
1348 tabWidget->addTab (medit,fn);
1349 tabWidget->showPage(medit);
1350 medit->viewport()->setFocus();
1351 // For the very first map we do not have flagrows yet...
1352 medit->select("mc:");
1355 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1357 ErrorCode err=success;
1359 // fn is usually the archive, mapfile the file after uncompressing
1362 // Make fn absolute (needed for unzip)
1363 fn=QDir (fn).absPath();
1369 // Check, if map is already loaded
1371 while (i<=tabWidget->count() -1)
1373 me=(MapEditor*)tabWidget->page(i);
1374 if (me->getFilePath() == fn)
1376 // Already there, ask for confirmation
1377 QMessageBox mb( __VYM,
1378 tr("The map %1\nis already opened."
1379 "Opening the same map in multiple editors may lead \n"
1380 "to confusion when finishing working with vym."
1381 "Do you want to").arg(fn),
1382 QMessageBox::Warning,
1383 QMessageBox::Yes | QMessageBox::Default,
1384 QMessageBox::Cancel | QMessageBox::Escape,
1385 QMessageBox::QMessageBox::NoButton);
1386 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1387 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1390 case QMessageBox::Yes:
1392 i=tabWidget->count();
1394 case QMessageBox::Cancel:
1406 if ( !fn.isEmpty() )
1408 me = currentMapEditor();
1409 int tabIndex=tabWidget->currentPageIndex();
1410 // Check first, if mapeditor exists
1411 // If it is not default AND we want a new map,
1412 // create a new mapeditor in a new tab
1413 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1415 me = new MapEditor (tabWidget,true);
1416 tabWidget->addTab (me,fn);
1417 tabIndex=tabWidget->indexOf (me);
1418 tabWidget->setCurrentPage (tabIndex);
1421 // Check, if file exists (important for creating new files
1422 // from command line
1423 if (!QFile(fn).exists() )
1425 QMessageBox mb( __VYM,
1426 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1427 QMessageBox::Question,
1429 QMessageBox::Cancel | QMessageBox::Default,
1430 QMessageBox::QMessageBox::NoButton );
1432 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1433 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1436 case QMessageBox::Yes:
1438 currentMapEditor()->setFilePath(fn);
1439 tabWidget->setTabLabel (currentMapEditor(),
1440 currentMapEditor()->getFileName() );
1441 statusBar()->message( "Created " + fn , statusbarTime );
1444 case QMessageBox::Cancel:
1445 // don't create new map
1446 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1453 //tabWidget->currentPage() won't be NULL here, because of above...
1454 tabWidget->showPage(me);
1455 me->viewport()->setFocus();
1457 // Create temporary directory for packing
1458 char tmpdir1[]="/tmp/vym-XXXXXX";
1459 QString tmpMapDir=mkdtemp(tmpdir1);
1461 // Try to unzip file
1462 err=unzipDir (tmpMapDir,fn);
1466 me->setZipped(false);
1469 me->setZipped(true);
1471 // Look for mapname.xml
1472 mapfile= fn.left(fn.findRev(".",-1,true));
1473 mapfile=mapfile.section( '/', -1 );
1474 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1475 if (!file.exists() )
1477 // mapname.xml does not exist, well,
1478 // maybe some renamed the mapname.vym file...
1479 // Try to find any .xml in the toplevel
1480 // directory of the .vym file
1481 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1482 if (flist.count()==1)
1484 // Only one entry, take this one
1485 mapfile=tmpMapDir + "/"+flist.first();
1488 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1489 *it=tmpMapDir + "/" + *it;
1490 // TODO Multiple entries, load all (but only the first one into this ME)
1491 //mainWindow->fileLoadFromTmp (flist);
1492 //returnCode=1; // Silently forget this attempt to load
1493 qWarning ("MainWindow::load (fn) multimap found...");
1496 if (flist.isEmpty() )
1498 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1499 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1502 } //file doesn't exist
1504 mapfile=file.name();
1509 // Save existing filename in case we import
1510 QString fn_org=me->getFilePath();
1512 // Finally load map into mapEditor
1513 me->setFilePath (mapfile,fn);
1514 err=me->load(mapfile,lmode);
1516 // Restore old (maybe empty) filepath, if this is an import
1518 me->setFilePath (fn_org);
1521 // Finally check for errors and go home
1524 if (lmode==NewMap) fileCloseMap();
1525 statusBar()->message( "Could not load " + fn, statusbarTime );
1530 me->setFilePath (fn);
1531 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1532 if (fn.left(9)!="/tmp/vym-")
1534 // Only append to lastMaps if not loaded from a tmpDir
1535 // e.g. imported bookmarks are in a tmpDir
1536 lastMaps.prepend(me->getFilePath() );
1537 setupLastMapsMenu();
1539 actionFilePrint->setEnabled (true);
1541 statusBar()->message( "Loaded " + fn, statusbarTime );
1545 removeDir (QDir(tmpMapDir));
1551 void Main::fileLoad(const LoadMode &lmode)
1553 QFileDialog *fd=new QFileDialog( this);
1554 if (!lastFileDir.isEmpty())
1555 fd->setDir (lastFileDir);
1556 fd->setMode (QFileDialog::ExistingFiles);
1557 fd->addFilter ("XML (*.xml)");
1558 fd->addFilter ("VYM map (*.vym *.vyp)");
1562 fd->setCaption(tr("Load vym map"));
1565 fd->setCaption(tr("Import: Add vym map to selection"));
1568 fd->setCaption(tr("Import: Replace selection with vym map"));
1574 if ( fd->exec() == QDialog::Accepted )
1576 lastFileDir=fd->dirPath();
1577 QStringList flist = fd->selectedFiles();
1578 QStringList::Iterator it = flist.begin();
1579 while( it != flist.end() )
1582 fileLoad(*it, lmode);
1589 void Main::fileLoad()
1594 void Main::fileLoadLast(int i)
1596 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1599 void Main::fileSave(const SaveMode &savemode)
1601 // tmp dir for zipping
1605 ErrorCode err=success;
1607 QString safeFilePath;
1609 bool saveZipped=currentMapEditor()->saveZipped();
1611 MapEditor * me=currentMapEditor();
1614 QString fn=me->getFilePath();
1615 // filename=unnamed, filepath="" in constructor...
1616 if ( !fn.isEmpty() )
1618 // We have a filepath, go on saving
1619 // First remove existing file, we
1620 // don't want to add to old zip archives
1624 QMessageBox::warning( 0, tr( "Save Error" ),
1625 fn+ tr("\ncould not be removed before saving"));
1627 // Look, if we should zip the data:
1630 QMessageBox mb( __VYM,
1631 tr("The map %1\ndid not use the compressed "
1632 "vym file format.\nWriting it uncompressed will also write images \n"
1633 "and flags and thus may overwrite files in the "
1634 "given directory\n\nDo you want to write the map").arg(fn),
1635 QMessageBox::Warning,
1636 QMessageBox::Yes | QMessageBox::Default,
1638 QMessageBox::Cancel | QMessageBox::Escape);
1639 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1640 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1641 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1644 case QMessageBox::Yes:
1645 // save compressed (default file format)
1648 case QMessageBox::No:
1649 // save uncompressed
1652 case QMessageBox::Cancel:
1661 char tmpdir1[]="/tmp/vym-XXXXXX";
1662 tmpMapDir=mkdtemp(tmpdir1);
1664 safeFilePath=me->getFilePath();
1665 me->setFilePath (tmpMapDir+"/"+
1666 me->getMapName()+ ".xml",
1668 me->save (savemode);
1669 me->setFilePath (safeFilePath);
1671 zipDir (tmpMapDir,fn);
1676 safeFilePath=me->getFilePath();
1677 me->setFilePath (fn, safeFilePath);
1678 me->save (savemode);
1679 me->setFilePath (safeFilePath);
1681 } // filepath available
1684 // We have no filepath yet,
1685 // call fileSaveAs() now, this will call fileSave()
1687 fileSaveAs(savemode);
1691 if (me->saveZipped())
1694 removeDir (QDir(tmpMapDir));
1699 statusBar()->message(
1700 tr("Saved %1").arg(me->getFilePath()),
1702 lastMaps.prepend(me->getFilePath() );
1703 setupLastMapsMenu();
1705 statusBar()->message(
1706 tr("Couldn't save ").arg(me->getFilePath()),
1710 void Main::fileSave()
1712 fileSave (CompleteMap);
1715 void Main::fileSaveAs(const SaveMode& savemode)
1720 if (currentMapEditor())
1722 if (savemode==CompleteMap)
1723 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1725 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1726 if ( !fn.isEmpty() )
1728 // Check for existing file
1729 if (QFile (fn).exists())
1731 QMessageBox mb( __VYM,
1732 tr("The file %1\nexists already. Do you want to").arg(fn),
1733 QMessageBox::Warning,
1734 QMessageBox::Yes | QMessageBox::Default,
1735 QMessageBox::Cancel | QMessageBox::Escape,
1736 QMessageBox::QMessageBox::NoButton);
1737 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1738 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1741 case QMessageBox::Yes:
1744 case QMessageBox::Cancel:
1751 // New file, add extension to filename, if missing
1752 // This is always .vym or .vyp, depending on savemode
1753 if (savemode==CompleteMap)
1755 if (!fn.contains (".vym") && !fn.contains (".xml"))
1759 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1768 currentMapEditor()->setFilePath(fn);
1772 if (savemode==CompleteMap)
1773 tabWidget->setTabLabel (currentMapEditor(),
1774 currentMapEditor()->getFileName() );
1780 void Main::fileSaveAs()
1782 fileSaveAs (CompleteMap);
1785 void Main::fileImportKDEBookmarks()
1787 ImportKDEBookmarks im;
1789 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1790 currentMapEditor()->setFilePath ("");
1793 void Main::fileImportMM()
1797 QFileDialog *fd=new QFileDialog( this);
1798 if (!lastFileDir.isEmpty())
1799 fd->setDir (lastFileDir);
1800 fd->setMode (QFileDialog::ExistingFiles);
1801 fd->addFilter ("Mind Manager (*.mmap)");
1802 fd->setCaption(tr("Import")+" "+"Mind Manager");
1805 if ( fd->exec() == QDialog::Accepted )
1807 lastFileDir=fd->dirPath();
1808 QStringList flist = fd->selectedFiles();
1809 QStringList::Iterator it = flist.begin();
1810 while( it != flist.end() )
1813 if (im.transform() &&
1814 success==fileLoad (im.getTransformedFile(),NewMap) &&
1815 currentMapEditor() )
1816 currentMapEditor()->setFilePath ("");
1825 void Main::fileImportDir()
1827 if (currentMapEditor())
1828 currentMapEditor()->importDir();
1831 void Main::fileExportXML()
1833 if (currentMapEditor())
1835 QString dir=browseDirectory(tr("Export XML to directory"));
1836 if (dir !="" && reallyWriteDirectory(dir) )
1837 currentMapEditor()->exportXML(dir);
1841 void Main::fileExportHTML()
1843 if (currentMapEditor())
1845 ExportHTMLDialog dia(this);
1847 if (dia.exec()==QDialog::Accepted)
1849 QString dir=dia.getDir();
1850 if (reallyWriteDirectory(dir) )
1852 currentMapEditor()->exportXML (dia.getDir() );
1853 dia.doExport(currentMapEditor()->getMapName() );
1859 void Main::fileExportXHTML()
1862 if (currentMapEditor())
1864 ExportXHTMLDialog dia(this);
1865 dia.setFilePath (currentMapEditor()->getFilePath() );
1866 dia.setMapName (currentMapEditor()->getMapName() );
1869 if (dia.exec()==QDialog::Accepted)
1871 QString dir=dia.getDir();
1872 // Check, if warnings should be used before overwriting
1873 // the output directory
1876 ok=reallyWriteDirectory(dir);
1882 currentMapEditor()->exportXML (dia.getDir() );
1883 dia.doExport(currentMapEditor()->getMapName() );
1884 if (dia.hasChanged())
1885 currentMapEditor()->setChanged();
1891 void Main::fileExportImage(int item)
1893 if (currentMapEditor())
1895 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1897 if ( !fn.isEmpty() )
1898 currentMapEditor()->exportImage(fn,item);
1900 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1905 void Main::fileExportASCII()
1907 if (currentMapEditor())
1908 currentMapEditor()->exportASCII();
1911 void Main::fileExportLaTeX()
1913 if (currentMapEditor())
1914 currentMapEditor()->exportLaTeX();
1917 void Main::fileExportOOPresentation()
1919 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to Open Office"));
1920 // FIXME add extra info in dialog
1921 //ImagePreview *p =new ImagePreview (fd);
1922 //fd->setContentsPreviewEnabled( TRUE );
1923 //fd->setContentsPreview( p, p );
1924 //fd->setPreviewMode( QFileDialog::Contents );
1925 fd->setCaption(__VYM " - " +tr("Export to Open Office"));
1926 //fd->setDir (lastImageDir);
1929 if ( fd->exec() == QDialog::Accepted )
1931 QString fn=fd->selectedFile();
1932 //lastImageDir=fn.left(fn.findRev ("/"));
1933 if (currentMapEditor())
1934 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
1938 void Main::fileCloseMap()
1940 if (currentMapEditor())
1942 if (currentMapEditor()->hasChanged())
1944 QMessageBox mb( __VYM,
1945 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1946 QMessageBox::Warning,
1947 QMessageBox::Yes | QMessageBox::Default,
1949 QMessageBox::Cancel | QMessageBox::Escape );
1950 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1951 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1954 case QMessageBox::Yes:
1956 fileSave(CompleteMap);
1958 case QMessageBox::No:
1959 // close without saving
1961 case QMessageBox::Cancel:
1966 currentMapEditor()->closeMap();
1967 tabWidget->removePage(currentMapEditor());
1968 if (tabWidget->count()==0)
1969 actionFilePrint->setEnabled (false);
1973 void Main::filePrint()
1975 if (currentMapEditor())
1976 currentMapEditor()->print();
1979 void Main::fileExitVYM()
1981 // Check if one or more editors have changed
1984 for (i=0;i<=tabWidget->count() -1;i++)
1987 me=(MapEditor*)tabWidget->page(i);
1989 // If something changed, ask what to do
1990 if (me->isUnsaved())
1992 tabWidget->setCurrentPage(i);
1993 QMessageBox mb( __VYM,
1994 tr("This map is not saved yet. Do you want to"),
1995 QMessageBox::Warning,
1996 QMessageBox::Yes | QMessageBox::Default,
1998 QMessageBox::Cancel | QMessageBox::Escape );
1999 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2000 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2002 // Call undocumented function: setActiveWindow is only
2003 // possible, if widget is visible. This depends on
2005 #if defined(Q_OS_LINUX)
2006 qt_wait_for_window_manager( this);
2008 mb.setActiveWindow();
2009 switch( mb.exec() ) {
2010 case QMessageBox::Yes:
2011 // save (the changed editors) and exit
2012 fileSave(CompleteMap);
2014 case QMessageBox::No:
2015 // exit without saving
2017 case QMessageBox::Cancel:
2018 // don't save and don't exit
2022 } // loop over all MEs
2026 void Main::editUndo()
2028 if (currentMapEditor())
2029 currentMapEditor()->undo();
2032 void Main::editRedo()
2034 if (currentMapEditor())
2035 currentMapEditor()->redo();
2038 void Main::editCopy()
2040 if (currentMapEditor())
2041 currentMapEditor()->copy();
2044 void Main::editPaste()
2046 if (currentMapEditor())
2047 currentMapEditor()->paste();
2050 void Main::editCut()
2052 if (currentMapEditor())
2053 currentMapEditor()->cut();
2056 void Main::editOpenFindWindow()
2058 findWindow->popup();
2059 findWindow->raise();
2061 // Call undocumented function: setActiveWindow is only
2062 // possible, if widget is visible. This depends on
2064 #if defined(Q_OS_LINUX)
2065 qt_wait_for_window_manager( this);
2067 findWindow->setActiveWindow();
2070 void Main::editFind(QString s)
2073 BranchObj *bo=currentMapEditor()->findText(s, cs);
2076 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2079 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2080 tr("No matches found for <b>%1</b>").arg(s));
2084 void Main::editFindChanged()
2085 { // Notify editor, to abort the current find process
2086 currentMapEditor()->findReset();
2089 void Main::editOpenURL()
2091 if (currentMapEditor())
2092 currentMapEditor()->openURL();
2095 void Main::editURL()
2097 if (currentMapEditor())
2098 currentMapEditor()->editURL();
2101 void Main::editHeading2URL()
2103 if (currentMapEditor())
2104 currentMapEditor()->editHeading2URL();
2107 void Main::editBugzilla2URL()
2109 if (currentMapEditor())
2110 currentMapEditor()->editBugzilla2URL();
2113 void Main::editFATE2URL()
2115 if (currentMapEditor())
2116 currentMapEditor()->editFATE2URL();
2119 void Main::editOpenVymLink()
2121 // Get current path to map
2122 QString currentVymLink;
2123 if (currentMapEditor())
2125 currentVymLink=currentMapEditor()->getVymLink();
2126 // compare path with already loaded maps
2130 for (i=0;i<=tabWidget->count() -1;i++)
2132 me=(MapEditor*)tabWidget->page(i);
2133 if (currentVymLink==me->getFilePath() )
2142 if (!QFile(currentVymLink).exists() )
2143 QMessageBox::critical( 0, tr( "Critical Error" ),
2144 tr("Couldn't open map %1").arg(currentVymLink));
2147 fileLoad (currentVymLink, NewMap);
2148 tabWidget->setCurrentPage (tabWidget->count()-1);
2151 // Go to tab containing the map
2152 tabWidget->setCurrentPage (index);
2156 void Main::editVymLink()
2158 if (currentMapEditor())
2159 currentMapEditor()->editVymLink();
2162 void Main::editDeleteVymLink()
2164 if (currentMapEditor())
2165 currentMapEditor()->deleteVymLink();
2168 void Main::editMapInfo()
2170 if (currentMapEditor())
2171 currentMapEditor()->editMapInfo();
2174 void Main::editMoveUp()
2176 if (currentMapEditor())
2177 currentMapEditor()->moveBranchUp();
2180 void Main::editMoveDown()
2182 if (currentMapEditor())
2183 currentMapEditor()->moveBranchDown();
2186 void Main::editToggleScroll()
2188 if (currentMapEditor())
2190 currentMapEditor()->toggleScroll();
2194 void Main::editUnScrollAll()
2196 if (currentMapEditor())
2198 currentMapEditor()->unScrollAll();
2202 void Main::editHeading()
2204 if (currentMapEditor())
2205 currentMapEditor()->editHeading();
2208 void Main::editNewBranch()
2210 if (currentMapEditor())
2211 currentMapEditor()->addNewBranch(0);
2214 void Main::editNewBranchHere()
2216 if (currentMapEditor())
2217 currentMapEditor()->addNewBranchHere();
2220 void Main::editNewBranchAbove()
2222 if (currentMapEditor())
2223 currentMapEditor()->addNewBranch(-1);
2226 void Main::editNewBranchBelow()
2228 if (currentMapEditor())
2229 currentMapEditor()->addNewBranch(1);
2232 void Main::editImportAdd()
2234 fileLoad (ImportAdd);
2237 void Main::editImportReplace()
2239 fileLoad (ImportReplace);
2242 void Main::editSaveBranch()
2244 fileSaveAs (PartOfMap);
2247 void Main::editRemoveBranchHere()
2249 if (currentMapEditor())
2250 currentMapEditor()->removeBranchHere();
2253 void Main::editRemoveChilds()
2255 if (currentMapEditor())
2256 currentMapEditor()->removeChilds();
2259 void Main::editDeleteSelection()
2261 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2262 currentMapEditor()->deleteSelection();
2265 void Main::editUpperBranch()
2267 if (currentMapEditor())
2268 currentMapEditor()->selectUpperBranch();
2271 void Main::editLowerBranch()
2273 if (currentMapEditor())
2274 currentMapEditor()->selectLowerBranch();
2277 void Main::editLeftBranch()
2279 if (currentMapEditor())
2280 currentMapEditor()->selectLeftBranch();
2283 void Main::editRightBranch()
2285 if (currentMapEditor())
2286 currentMapEditor()->selectRightBranch();
2289 void Main::editFirstBranch()
2291 if (currentMapEditor())
2292 currentMapEditor()->selectFirstBranch();
2295 void Main::editLastBranch()
2297 if (currentMapEditor())
2298 currentMapEditor()->selectLastBranch();
2301 void Main::editLoadImage()
2303 if (currentMapEditor())
2304 currentMapEditor()->loadFloatImage();
2307 void Main::editSaveImage(int item)
2309 if (currentMapEditor())
2310 currentMapEditor()->saveFloatImage(item);
2313 void Main::editToggleFloatExport()
2315 if (currentMapEditor())
2316 currentMapEditor()->toggleFloatExport();
2319 void Main::editFollowXLink(int item)
2321 if (currentMapEditor())
2322 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2325 void Main::editEditXLink(int item)
2327 if (currentMapEditor())
2328 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2331 void Main::formatSelectColor()
2333 if (currentMapEditor())
2335 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2336 if ( !col.isValid() ) return;
2337 currentMapEditor()->setColor( col );
2338 colorChanged( col );
2342 void Main::formatPickColor()
2344 if (currentMapEditor())
2345 colorChanged( currentMapEditor()->pickColor() );
2348 void Main::colorChanged(QColor c)
2350 QPixmap pix( 16, 16 );
2352 actionFormatColor->setIconSet( pix );
2355 void Main::formatColorItem()
2357 if (currentMapEditor())
2358 currentMapEditor()->colorItem();
2361 void Main::formatColorBranch()
2363 if (currentMapEditor())
2364 currentMapEditor()->colorBranch();
2367 void Main::formatLinkStyleLine()
2369 if (currentMapEditor())
2370 currentMapEditor()->setLinkStyle(StyleLine);
2373 void Main::formatLinkStyleParabel()
2375 if (currentMapEditor())
2376 currentMapEditor()->setLinkStyle(StyleParabel);
2379 void Main::formatLinkStylePolyLine()
2381 if (currentMapEditor())
2382 currentMapEditor()->setLinkStyle(StylePolyLine);
2385 void Main::formatLinkStylePolyParabel()
2387 if (currentMapEditor())
2388 currentMapEditor()->setLinkStyle(StylePolyParabel);
2391 void Main::formatSelectBackColor()
2393 if (currentMapEditor())
2394 currentMapEditor()->selectBackgroundColor();
2397 void Main::formatSelectLinkColor()
2399 if (currentMapEditor())
2400 currentMapEditor()->selectLinkColor();
2403 void Main::formatToggleLinkColorHint()
2405 currentMapEditor()->toggleLinkColorHint();
2408 void Main::formatFrameNone()
2410 if (currentMapEditor())
2411 currentMapEditor()->setFrame(NoFrame);
2414 void Main::formatFrameRectangle()
2416 if (currentMapEditor())
2417 currentMapEditor()->setFrame(Rectangle);
2420 void Main::formatIncludeImagesVer()
2422 if (currentMapEditor())
2423 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2426 void Main::formatIncludeImagesHor()
2428 if (currentMapEditor())
2429 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2432 void Main::formatHideLinkUnselected()
2434 if (currentMapEditor())
2435 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2438 void Main::viewZoomReset()
2440 if (currentMapEditor())
2444 currentMapEditor()->setWorldMatrix( m );
2445 currentMapEditor()->setViewCenter();
2446 currentMapEditor()->adjustCanvasSize();
2450 void Main::viewZoomIn()
2452 if (currentMapEditor())
2454 QWMatrix m = currentMapEditor()->worldMatrix();
2455 m.scale( 1.25, 1.25 );
2456 currentMapEditor()->setWorldMatrix( m );
2457 currentMapEditor()->setViewCenter();
2458 currentMapEditor()->adjustCanvasSize();
2462 void Main::viewZoomOut()
2464 if (currentMapEditor())
2466 QWMatrix m = currentMapEditor()->worldMatrix();
2467 m.scale( 0.8, 0.8 );
2468 currentMapEditor()->setWorldMatrix( m );
2469 currentMapEditor()->setViewCenter();
2470 currentMapEditor()->adjustCanvasSize();
2474 void Main::modModeColor()
2478 void Main::modModeLink()
2482 bool Main::settingsPDF()
2484 // Default browser is set in constructor
2486 QString text = QInputDialog::getText(
2487 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2488 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2490 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2495 bool Main::settingsURL()
2497 // Default browser is set in constructor
2499 QString text = QInputDialog::getText(
2500 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2501 settings.readEntry("/vym/mainwindow/readerURL")
2504 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2508 void Main::windowToggleNoteEditor()
2510 if (textEditor->showWithMain() )
2511 windowHideNoteEditor();
2513 windowShowNoteEditor();
2516 void Main::updateNoteFlag()
2518 if (currentMapEditor())
2519 currentMapEditor()->updateNoteFlag();
2522 void Main::windowShowNoteEditor()
2524 textEditor->setShowWithMain(true);
2526 actionViewToggleNoteEditor->setOn (true);
2529 void Main::windowHideNoteEditor()
2531 textEditor->setShowWithMain(false);
2533 actionViewToggleNoteEditor->setOn (false);
2536 void Main::windowNextEditor()
2538 if (tabWidget->currentPageIndex() < tabWidget->count())
2539 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2542 void Main::windowPreviousEditor()
2544 if (tabWidget->currentPageIndex() >0)
2545 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2548 void Main::standardFlagChanged()
2550 currentMapEditor()->toggleStandardFlag(sender()->name());
2553 void Main::testFunction()
2555 currentMapEditor()->testFunction();
2558 void Main::helpDoc()
2561 #if defined(Q_OS_MACX)
2562 docpath="./vym.app/Contents/vym.pdf";
2564 // default path in SUSE LINUX
2565 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2568 if (!QFile (docpath).exists() )
2570 // relative path for easy testing in tarball
2571 docpath="doc/vym.pdf";
2572 if (!QFile (docpath).exists() )
2574 // relative path for testing while still writing vym.tex
2575 docpath="doc/tex/vym.pdf";
2576 if (!QFile (docpath).exists() )
2578 // Try yet another one for Knoppix
2579 docpath="/usr/share/doc/packages/vym/vym.pdf";
2580 if (!QFile (docpath).exists() )
2582 QMessageBox::critical(0,
2583 tr("Critcal error"),
2584 tr("Couldn't find the documentation\n"
2585 "vym.pdf in various places."));
2592 Process *pdfProc = new Process();
2593 pdfProc->clearArguments();
2594 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2595 pdfProc->addArgument( docpath);
2597 if ( !pdfProc->start() )
2600 QMessageBox::critical(0,
2601 tr("Critcal error"),
2602 tr("Couldn't find a viewer to read vym.pdf.\n"
2603 "Please use Settings->")+tr("Set application to open pdf files"));
2609 void Main::helpAbout()
2612 ad.setName ("aboutwindow");
2613 ad.setMinimumSize(500,500);
2614 ad.resize (QSize (500,500));
2618 void Main::helpAboutQT()
2620 QMessageBox::aboutQt( this, "Qt Application Example" );