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
25 #include "aboutdialog.h"
26 #include "exportoofiledialog.h"
28 #include "icons/filenew.xpm"
29 #include "icons/fileopen.xpm"
30 #include "icons/filesave.xpm"
31 #include "icons/fileprint.xpm"
32 #include "icons/editundo.xpm"
33 #include "icons/editredo.xpm"
34 #include "icons/editcopy.xpm"
35 #include "icons/editcut.xpm"
36 #include "icons/editpaste.xpm"
37 #include "icons/editmoveup.xpm"
38 #include "icons/editmovedown.xpm"
39 #include "icons/formatcoloritem.xpm"
40 #include "icons/formatcolorbranch.xpm"
41 #include "icons/formatcolorpicker.xpm"
42 #include "icons/viewzoomreset.xpm"
43 #include "icons/viewzoomin.xpm"
44 #include "icons/viewzoomout.xpm"
45 #include "icons/modecolor.xpm"
46 #include "icons/modelink.xpm"
47 #include "icons/modecopy.xpm"
48 //#include "icons/vym-48x48.xpm"
50 #include "icons/flag-questionmark.xpm"
51 #include "icons/flag-exclamationmark.xpm"
52 #include "icons/flag-hook-green.xpm"
53 #include "icons/flag-cross-red.xpm"
54 #include "icons/flag-stopsign.xpm"
55 #include "icons/flag-smiley-good.xpm"
56 #include "icons/flag-smiley-sad.xpm"
57 #include "icons/flag-clock.xpm"
58 #include "icons/flag-lamp.xpm"
59 #include "icons/flag-arrow-up.xpm"
60 #include "icons/flag-arrow-down.xpm"
61 #include "icons/flag-thumb-up.xpm"
62 #include "icons/flag-thumb-down.xpm"
63 #include "icons/flag-heart.xpm"
64 #include "icons/flag-flash.xpm"
65 #include "icons/flag-lifebelt.xpm"
67 #include "icons/flag-note.xpm"
68 #include "icons/flag-url.xpm"
69 #include "icons/flag-vymlink.xpm"
70 #include "icons/flag-scrolled-right.xpm"
71 #include "icons/flag-tmpUnscrolled-right.xpm"
73 #include "flagrowobj.h"
74 #include "texteditor.h"
75 #include "mapeditor.h"
76 #include "exporthtmldialog.h"
77 #include "exportxhtmldialog.h"
78 #include "showtextdialog.h"
83 extern TextEditor *textEditor;
84 extern Main *mainWindow;
85 extern QString tmpVymDir;
86 extern QString clipboardDir;
87 extern bool clipboardEmpty;
88 extern int statusbarTime;
89 extern MapEditor *clipboardME;
90 extern FlagRowObj* standardFlagsDefault;
91 extern FlagRowObj* systemFlagsDefault;
93 extern QPtrList <QAction> actionListBranches;
95 extern QAction* actionFileSave;
96 extern QAction* actionFilePrint;
97 extern QAction* actionEditUndo;
98 extern QAction* actionEditRedo;
99 extern QAction *actionEditCopy;
100 extern QAction *actionEditCut;
101 extern QAction *actionEditPaste;
102 extern QAction *actionEditMoveUp;
103 extern QAction *actionEditMoveDown;
104 extern QAction *actionEditToggleScroll;
105 extern QAction* actionEditOpenURL;
106 extern QAction* actionEditURL;
107 extern QAction* actionEditHeading2URL;
108 extern QAction* actionEditBugzilla2URL;
109 extern QAction* actionEditFATE2URL;
110 extern QAction *actionEditOpenVymLink;
111 extern QAction *actionEditVymLink;
112 extern QAction *actionEditDeleteVymLink;
113 extern QAction *actionEditMapInfo;
114 extern QAction *actionEditHeading;
115 extern QAction *actionEditDelete;
116 extern QAction *actionEditAddBranch;
117 extern QAction *actionEditAddBranchHere;
118 extern QAction *actionEditAddBranchAbove;
119 extern QAction *actionEditAddBranchBelow;
120 extern QAction *actionEditRemoveBranchHere;
121 extern QAction *actionEditRemoveChilds;
122 extern QAction *actionEditImportAdd;
123 extern QAction *actionEditImportReplace;
124 extern QAction *actionEditSaveBranch;
125 extern QAction *actionEditSelectFirst;
126 extern QAction *actionEditSelectLast;
127 extern QAction *actionEditLoadImage;
128 extern QAction *actionEditToggleFloatExport;
130 extern QAction* actionFormatColor;
131 extern QAction* actionFormatPickColor;
132 extern QAction* actionFormatColorBranch;
133 extern QAction* actionFormatColorSubtree;
134 extern QAction* actionFormatLinkColorHint;
135 extern QAction* actionFormatBackColor;
136 extern QAction* actionFormatLinkColor;
137 extern QAction *actionFormatIncludeImagesVer;
138 extern QAction *actionFormatIncludeImagesHor;
140 extern QActionGroup* actionGroupModModes;
141 extern QAction* actionModModeColor;
142 extern QAction* actionModModeLink;
143 extern QAction* actionModModeCopy;
145 extern QActionGroup *actionGroupFormatFrameTypes;
146 extern QAction *actionFormatFrameNone;
147 extern QAction *actionFormatFrameRectangle;
149 extern QActionGroup *actionGroupFormatLinkStyles;
150 extern QAction *actionFormatLinkStyleLine;
151 extern QAction *actionFormatLinkStyleParabel;
152 extern QAction *actionFormatLinkStylePolyLine;
153 extern QAction *actionFormatLinkStylePolyParabel;
154 extern QAction *actionFormatHideLinkUnselected;
156 extern QAction *actionViewToggleNoteEditor;
158 extern QAction* actionSettingsAutoedit;
159 extern QAction* actionSettingsAutoselectHeading;
160 extern QAction* actionSettingsAutoselectHeading;
161 extern QAction* actionSettingsAutoselectText;
162 extern QAction* actionSettingsPasteNewHeading;
163 extern QAction* actionSettingsUseDelKey;
164 extern QAction* actionSettingsUseFlagGroups;
166 extern QPopupMenu* branchContextMenu;
167 extern QPopupMenu* branchAddContextMenu;
168 extern QPopupMenu* branchRemoveContextMenu;
169 extern QPopupMenu* branchLinksContextMenu;
170 extern QPopupMenu* branchLinksContextMenuDup;
171 extern QPopupMenu* floatimageContextMenu;
172 extern QPopupMenu* saveImageFormatMenu;
173 extern QPopupMenu* canvasContextMenu;
174 extern QPopupMenu* lastMapsMenu;
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() );
304 int maps=lastMaps.count();
305 settings.writeEntry( "/vym/lastMaps/number",maps );
306 for (int i=1;i<=maps;i++)
308 QStringList::Iterator it = lastMaps.at(i-1);
309 s=QString("/vym/lastMaps/map-%1").arg(i);
310 if (!s.isEmpty() && i<=maxLastMaps)
311 settings.writeEntry (s, *it);
315 // To make the texteditor save its settings, call the destructor
318 // Remove temporary directory
319 removeDir (QDir(tmpVymDir));
322 void Main::loadCmdLine()
324 /* TODO draw some kind of splashscreen while loading...
330 QStringList flist=options.getFileList();
331 QStringList::Iterator it=flist.begin();
333 while (it !=flist.end() )
335 fileLoad (*it, NewMap);
341 void Main::statusMessage(const QString &s)
343 statusBar()->message (s);
346 void Main::closeEvent (QCloseEvent* )
352 void Main::setupFileActions()
354 QToolBar *tb = new QToolBar( this );
355 tb->setLabel( "File Actions" );
356 QPopupMenu *menu = new QPopupMenu( this );
357 menuBar()->insertItem( tr( "&File" ), menu );
359 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
362 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
363 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
367 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
368 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
372 lastMapsMenu = new QPopupMenu (this);
374 menu->insertItem (tr("Open Recent"),lastMapsMenu );
375 menu->insertSeparator();
377 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
378 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
383 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
384 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
387 menu->insertSeparator();
389 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
390 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
393 exportMenu = new QPopupMenu (this);
394 menu->insertItem (tr("Export"),exportMenu );
396 menu->insertSeparator();
399 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
400 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
405 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
406 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
409 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
410 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
416 void Main::setupEditActions()
418 QToolBar *tb = new QToolBar( this );
419 tb->setLabel( "Edit Actions" );
420 QPopupMenu *menu = new QPopupMenu( this );
421 menuBar()->insertItem( tr( "&Edit" ), menu );
425 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
426 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
427 a->setEnabled (false);
432 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
434 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
435 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
440 menu->insertSeparator();
441 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
442 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
443 a->setEnabled (false);
447 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
448 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
449 a->setEnabled (false);
453 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
454 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
455 a->setEnabled (false);
460 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
461 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
462 a->setEnabled (false);
465 actionListBranches.append(a);
468 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
469 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
470 a->setEnabled (false);
473 actionListBranches.append(a);
474 actionEditMoveDown=a;
477 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
478 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
479 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
480 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
481 #if defined(Q_OS_MACX)
482 actionEditToggleScroll=alt;
484 actionEditToggleScroll=a;
486 actionEditToggleScroll->setEnabled (false);
487 actionEditToggleScroll->addTo( tb );
488 actionEditToggleScroll->addTo( menu );
489 actionListBranches.append(actionEditToggleScroll);
491 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
492 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
495 menu->insertSeparator();
497 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
498 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
501 menu->insertSeparator();
503 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
504 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
506 a->setEnabled (false);
509 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
510 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
511 a->setEnabled (false);
512 actionListBranches.append(a);
515 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
516 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
517 a->setEnabled (false);
518 actionListBranches.append(a);
519 actionEditHeading2URL=a;
521 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
522 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
523 a->setEnabled (false);
524 actionListBranches.append(a);
525 actionEditBugzilla2URL=a;
527 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
528 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
529 a->setEnabled (false);
530 actionListBranches.append(a);
531 actionEditFATE2URL=a;
533 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" );
534 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
536 a->setEnabled (false);
537 actionEditOpenVymLink=a;
539 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
540 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
541 a->setEnabled (false);
542 actionListBranches.append(a);
545 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
546 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
547 a->setEnabled (false);
548 actionEditDeleteVymLink=a;
550 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
551 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
552 a->setEnabled (true);
555 menu->insertSeparator();
557 // Shortcuts to modify heading:
558 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
559 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
560 actionListBranches.append(a);
561 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
562 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
563 actionListBranches.append(a);
565 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
566 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
567 a->setEnabled (false);
569 actionListBranches.append(a);
571 // Shortcut to delete selection
572 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
573 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
574 a->setEnabled (false);
577 // Shortcut to add branch
578 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
579 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
580 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
581 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
582 a->setEnabled (false);
583 actionListBranches.append(a);
584 #if defined (Q_OS_MACX)
585 // In OSX show different shortcut in menues, the keys work independtly always
586 actionEditAddBranch=alt;
588 actionEditAddBranch=a;
591 // Add branch by inserting it at selection
592 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
593 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
594 a->setEnabled (false);
595 actionListBranches.append(a);
596 actionEditAddBranchHere=a;
597 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
598 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
599 actionListBranches.append(a);
602 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
603 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
604 a->setEnabled (false);
605 actionListBranches.append(a);
606 actionEditAddBranchAbove=a;
607 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
608 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
609 actionListBranches.append(a);
612 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
613 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
614 a->setEnabled (false);
615 actionListBranches.append(a);
616 actionEditAddBranchBelow=a;
617 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
618 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
619 actionListBranches.append(a);
621 // Import at selection (adding to selection)
622 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
623 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
624 a->setEnabled (false);
625 actionListBranches.append(a);
626 actionEditImportAdd=a;
628 // Import at selection (replacing selection)
629 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
630 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
631 a->setEnabled (false);
632 actionListBranches.append(a);
633 actionEditImportReplace=a;
636 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
637 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
638 a->setEnabled (false);
639 actionListBranches.append(a);
640 actionEditSaveBranch=a;
642 // Only remove branch, not its childs
643 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
644 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
645 a->setEnabled (false);
646 actionListBranches.append(a);
647 actionEditRemoveBranchHere=a;
649 // Only remove childs of a branch
650 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
651 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
652 a->setEnabled (false);
653 actionListBranches.append(a);
654 actionEditRemoveChilds=a;
656 // Shortcuts for navigating with cursor:
657 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
658 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
659 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
660 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
661 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
662 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
663 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
664 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
665 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
666 a->setEnabled (false);
668 actionListBranches.append(a);
669 actionEditSelectFirst=a;
670 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
671 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
672 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
673 a->setEnabled (false);
675 actionListBranches.append(a);
676 actionEditSelectLast=a;
678 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
679 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
680 actionEditLoadImage=a;
685 void Main::setupFormatActions()
687 QPopupMenu *menu = new QPopupMenu( this );
688 menuBar()->insertItem( tr( "&Format" ), menu );
690 QToolBar *tb = new QToolBar( this );
694 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
695 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
696 actionFormatColor->addTo( tb );
697 actionFormatColor->addTo( menu );
698 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" );
699 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
700 a->setEnabled (false);
703 actionListBranches.append(a);
704 actionFormatPickColor=a;
705 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
706 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
707 a->setEnabled (false);
710 actionListBranches.append(a);
711 actionFormatColorBranch=a;
712 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
713 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
714 a->setEnabled (false);
717 actionListBranches.append(a);
718 actionFormatColorSubtree=a;
720 menu->insertSeparator();
721 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
722 actionGroupFormatLinkStyles->setExclusive (true);
723 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
724 a->setToggleAction(true);
725 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
726 actionFormatLinkStyleLine=a;
727 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
728 a->setToggleAction(true);
729 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
730 actionFormatLinkStyleParabel=a;
731 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
732 a->setToggleAction(true);
733 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
734 actionFormatLinkStylePolyLine=a;
735 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
736 a->setToggleAction(true);
737 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
738 actionFormatLinkStylePolyParabel=a;
739 actionGroupFormatLinkStyles->addTo (menu);
741 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
742 actionGroupFormatFrameTypes->setExclusive (true);
743 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
744 a->setToggleAction(true);
745 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
746 actionFormatFrameNone=a;
747 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
748 a->setToggleAction(true);
749 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
750 actionFormatFrameRectangle=a;
752 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
753 a->setToggleAction(true);
754 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
755 actionFormatIncludeImagesVer=a;
757 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
758 a->setToggleAction(true);
759 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
760 actionFormatIncludeImagesHor=a;
762 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
763 a->setToggleAction(true);
764 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
765 actionFormatHideLinkUnselected=a;
767 menu->insertSeparator();
768 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
769 a->setToggleAction(true);
770 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
772 actionFormatLinkColorHint=a;
774 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
775 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
776 actionFormatLinkColor->addTo( menu );
777 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
778 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
779 actionFormatBackColor->addTo( menu );
783 void Main::setupViewActions()
785 QToolBar *tb = new QToolBar( this );
786 tb->setLabel( "View Actions" );
787 QPopupMenu *menu = new QPopupMenu( this );
788 menuBar()->insertItem( tr( "&View" ), menu );
791 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
792 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
795 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
796 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
799 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
800 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
803 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
804 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
805 a->setToggleAction(true);
806 if (textEditor->showWithMain())
812 actionViewToggleNoteEditor=a;
813 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
814 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
816 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
817 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
822 void Main::setupModeActions()
824 //QPopupMenu *menu = new QPopupMenu( this );
825 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
827 QToolBar *tb = new QToolBar( this );
828 tb->setLabel( tr ("Modes when using modifiers") );
830 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
831 actionGroupModModes->setExclusive (true);
832 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
833 a->setToggleAction(true);
836 actionModModeColor=a;
838 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
839 a->setToggleAction(true);
843 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
844 a->setToggleAction(true);
850 void Main::setupFlagActions()
852 // Create System Flags
853 systemFlagsDefault = new FlagRowObj ();
854 systemFlagsDefault->setVisibility (false);
855 systemFlagsDefault->setName ("systemFlagsDef");
857 FlagObj *fo = new FlagObj ();
858 fo->load(QPixmap(flag_note_xpm));
860 fo->setToolTip(tr("Note","Systemflag"));
861 systemFlagsDefault->addFlag (fo); // makes deep copy
863 fo->load(QPixmap(flag_url_xpm));
865 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
866 systemFlagsDefault->addFlag (fo);
868 fo->load(QPixmap(flag_vymlink_xpm));
869 fo->setName("vymLink");
870 fo->setToolTip(tr("Link to another vym map","Systemflag"));
871 systemFlagsDefault->addFlag (fo);
873 fo->load(QPixmap(flag_scrolled_right_xpm));
874 fo->setName("scrolledright");
875 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
876 systemFlagsDefault->addFlag (fo);
878 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
879 fo->setName("tmpUnscrolledright");
880 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
881 systemFlagsDefault->addFlag (fo);
883 // Create Standard Flags
884 standardFlagsDefault = new FlagRowObj ();
885 standardFlagsDefault->setVisibility (false);
886 standardFlagsDefault->setName ("standardFlagsDef");
888 fo->load(QPixmap(flag_exclamationmark_xpm));
889 fo->setName ("exclamationmark");
890 fo->setGroup("standard-mark");
891 fo->setToolTip(tr("Take care!","Standardflag"));
892 standardFlagsDefault->addFlag (fo); // makes deep copy
894 fo->load(QPixmap(flag_questionmark_xpm));
895 fo->setName("questionmark");
896 fo->setGroup("standard-mark");
897 fo->setToolTip(tr("Really?","Standardflag"));
898 standardFlagsDefault->addFlag (fo);
900 fo->load(QPixmap(flag_hook_green_xpm));
901 fo->setName("hook-green");
902 fo->setGroup("standard-hook");
903 fo->setToolTip(tr("ok!","Standardflag"));
904 standardFlagsDefault->addFlag (fo);
906 fo->load(QPixmap(flag_cross_red_xpm));
907 fo->setName("cross-red");
908 fo->setGroup("standard-hook");
909 fo->setToolTip(tr("Not ok!","Standardflag"));
910 standardFlagsDefault->addFlag (fo);
912 fo->load(QPixmap(flag_stopsign_xpm));
913 fo->setName("stopsign");
914 fo->setToolTip(tr("This won't work!","Standardflag"));
915 standardFlagsDefault->addFlag (fo);
917 fo->load(QPixmap(flag_smiley_good_xpm));
918 fo->setName("smiley-good");
919 fo->setGroup("standard-smiley");
920 fo->setToolTip(tr("Good","Standardflag"));
921 standardFlagsDefault->addFlag (fo);
923 fo->load(QPixmap(flag_smiley_sad_xpm));
924 fo->setName("smiley-sad");
925 fo->setGroup("standard-smiley");
926 fo->setToolTip(tr("Bad","Standardflag"));
927 standardFlagsDefault->addFlag (fo);
929 fo->load(QPixmap(flag_clock_xpm));
930 fo->setName("clock");
931 fo->setToolTip(tr("Time critical","Standardflag"));
932 standardFlagsDefault->addFlag (fo);
934 fo->load(QPixmap(flag_lamp_xpm));
936 fo->setToolTip(tr("Idea!","Standardflag"));
937 standardFlagsDefault->addFlag (fo);
939 fo->load(QPixmap(flag_arrow_up_xpm));
940 fo->setName("arrow-up");
941 fo->setGroup("standard-arrow");
942 fo->setToolTip(tr("Important","Standardflag"));
943 standardFlagsDefault->addFlag (fo);
945 fo->load(QPixmap(flag_arrow_down_xpm));
946 fo->setName("arrow-down");
947 fo->setGroup("standard-arrow");
948 fo->setToolTip(tr("Unimportant","Standardflag"));
949 standardFlagsDefault->addFlag (fo);
951 fo->load(QPixmap(flag_thumb_up_xpm));
952 fo->setName("thumb-up");
953 fo->setGroup("standard-thumb");
954 fo->setToolTip(tr("I like this","Standardflag"));
955 standardFlagsDefault->addFlag (fo);
957 fo->load(QPixmap(flag_thumb_down_xpm));
958 fo->setName("thumb-down");
959 fo->setGroup("standard-thumb");
960 fo->setToolTip(tr("I like this","Standardflag"));
961 fo->setToolTip(tr("I do not like this","Standardflag"));
962 standardFlagsDefault->addFlag (fo);
964 fo->load(QPixmap(flag_heart_xpm));
965 fo->setName("heart");
966 fo->setToolTip(tr("I just love... ","Standardflag"));
967 standardFlagsDefault->addFlag (fo);
969 fo->load(QPixmap(flag_flash_xpm));
970 fo->setName("flash");
971 fo->setToolTip(tr("Dangerous","Standardflag"));
972 standardFlagsDefault->addFlag (fo);
974 fo->load(QPixmap(flag_lifebelt_xpm));
975 fo->setName("lifebelt");
976 fo->setToolTip(tr("This will help","Standardflag"));
977 standardFlagsDefault->addFlag (fo);
980 standardFlagsDefault->makeToolbar(this, "Standard Flags");
984 void Main::setupSettingsActions()
986 QPopupMenu *menu = new QPopupMenu( this );
987 menuBar()->insertItem( tr( "&Settings" ), menu );
992 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
993 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
996 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
997 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1000 menu->insertSeparator();
1001 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1002 a->setToggleAction(true);
1003 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1005 actionSettingsAutoedit=a;
1007 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1008 a->setToggleAction(true);
1009 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1011 actionSettingsAutoselectHeading=a;
1013 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1014 a->setToggleAction(true);
1015 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1017 actionSettingsAutoselectText=a;
1019 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1020 a->setToggleAction(true);
1021 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1023 actionSettingsPasteNewHeading=a;
1025 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1026 a->setToggleAction(true);
1027 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1029 actionSettingsUseDelKey=a;
1031 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1032 a->setToggleAction(true);
1033 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1035 actionSettingsUseFlagGroups=a;
1039 void Main::setupTestActions()
1041 QPopupMenu *menu = new QPopupMenu( this );
1042 menuBar()->insertItem( tr( "&Test" ), menu );
1045 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1046 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1051 void Main::setupHelpActions()
1053 QPopupMenu *menu = new QPopupMenu( this );
1054 menuBar()->insertItem( tr( "&Help" ), menu );
1057 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1058 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1061 a = new QAction( tr( "Information about")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1062 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1065 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1066 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1071 void Main::setupContextMenus()
1075 // Context Menu for branch or mapcenter
1076 branchContextMenu =new QPopupMenu (this);
1079 branchAddContextMenu =new QPopupMenu (this);
1080 actionEditPaste->addTo ( branchAddContextMenu );
1081 actionEditAddBranch->addTo ( branchAddContextMenu );
1082 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1083 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1084 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1085 branchAddContextMenu->insertSeparator();
1086 actionEditLoadImage->addTo( branchAddContextMenu );
1087 branchAddContextMenu->insertSeparator();
1088 actionEditImportAdd->addTo ( branchAddContextMenu );
1089 actionEditImportReplace->addTo ( branchAddContextMenu );
1092 branchRemoveContextMenu =new QPopupMenu (this);
1093 actionEditCut->addTo ( branchRemoveContextMenu );
1094 actionEditDelete->addTo ( branchRemoveContextMenu );
1095 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
1096 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1098 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1099 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1101 actionEditSaveBranch->addTo( branchContextMenu );
1103 branchContextMenu->insertSeparator();
1104 actionEditOpenURL->addTo ( branchContextMenu );
1105 actionEditURL->addTo ( branchContextMenu );
1106 actionEditHeading2URL->addTo ( branchContextMenu );
1107 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1109 actionEditBugzilla2URL->addTo( branchContextMenu );
1110 actionEditFATE2URL->addTo( branchContextMenu );
1112 branchContextMenu->insertSeparator();
1113 actionEditOpenVymLink->addTo ( branchContextMenu );
1114 actionEditVymLink->addTo ( branchContextMenu );
1115 actionEditDeleteVymLink->addTo ( branchContextMenu );
1117 branchContextMenu->insertSeparator();
1118 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1120 branchContextMenu->insertSeparator();
1121 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1122 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1123 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1125 // Context Menu for links in a branch menu
1126 // This will be populated "on demand" in MapEditor::updateActions
1127 branchContextMenu->insertSeparator();
1128 branchLinksContextMenu =new QPopupMenu (this);
1129 branchLinksContextMenuDup =new QPopupMenu (this);
1130 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1131 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1133 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1134 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1136 // Context menu for floatimage
1137 floatimageContextMenu =new QPopupMenu (this);
1138 saveImageFormatMenu=new QPopupMenu (this);
1139 exportImageFormatMenu=new QPopupMenu (this);
1141 QStrList fmt = QImage::outputFormats();
1142 for (const char* f = fmt.first(); f; f = fmt.next())
1144 saveImageFormatMenu->insertItem( f );
1145 exportImageFormatMenu->insertItem( f );
1147 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1148 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1149 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1151 floatimageContextMenu->insertSeparator();
1152 actionEditCopy->addTo( floatimageContextMenu );
1153 actionEditCut->addTo( floatimageContextMenu );
1155 floatimageContextMenu->insertSeparator();
1156 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1157 a->setToggleAction(true);
1158 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1159 a->addTo( floatimageContextMenu);
1160 actionEditToggleFloatExport=a;
1162 floatimageContextMenu->insertSeparator();
1163 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1165 a = new QAction( tr( "Export as Open Office 2.0 (Open Document) " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1166 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1167 a->addTo (exportMenu);
1169 exportMenu->insertItem ( tr("Image"),exportImageFormatMenu);
1171 a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), "ASCII...", 0, this, "exportASCII" );
1172 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1173 a->addTo( exportMenu );
1175 a = new QAction( tr( "Export as LaTeX (still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1176 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1177 a->addTo( exportMenu );
1179 a = new QAction( tr( "Export (XML)" ), QPixmap(), "XML...", 0, this, "exportXML" );
1180 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1181 a->addTo( exportMenu );
1183 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1185 a = new QAction( tr( "Export HTML" ), QPixmap(), "HTML...", 0, this, "exportHTML");
1186 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1187 a->addTo( exportMenu );
1190 a = new QAction( tr( "Export XHTML" ), QPixmap(), "XHTML...", ALT + Key_X, this, "exportXHTML" );
1191 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1192 a->addTo( exportMenu );
1195 // Context menu for canvas
1196 canvasContextMenu =new QPopupMenu (this);
1197 actionEditMapInfo->addTo( canvasContextMenu );
1198 canvasContextMenu->insertSeparator();
1199 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1200 canvasContextMenu->insertSeparator();
1201 actionFormatLinkColorHint->addTo( canvasContextMenu );
1202 actionFormatLinkColor->addTo( canvasContextMenu );
1203 actionFormatBackColor->addTo( canvasContextMenu );
1205 // Menu for last opened files
1206 // Read settings initially
1208 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1209 for (int i=1;i<=j;i++)
1211 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1212 if (!s.isEmpty() && j<=maxLastMaps)
1215 setupLastMapsMenu();
1216 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1219 void Main::setupLastMapsMenu()
1221 // Remove double entries
1222 QStringList::Iterator it=lastMaps.begin();
1223 QStringList::Iterator jt;
1224 while (it!=lastMaps.end() )
1228 while (jt!=lastMaps.end() )
1231 jt=lastMaps.remove(jt);
1238 // Limit length of list to maxLastMaps
1239 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1241 // build Menu from lastMaps string list
1242 lastMapsMenu->clear();
1243 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1244 lastMapsMenu->insertItem (*it );
1248 void Main::hideEvent (QHideEvent * )
1250 if (!textEditor->isMinimized() ) textEditor->hide();
1253 void Main::showEvent (QShowEvent * )
1255 if (textEditor->showWithMain()) textEditor->showNormal();
1258 bool Main::reallyWriteDirectory(const QString &dir)
1260 QStringList eList = QDir(dir).entryList();
1261 if (eList.first() ==".") eList.pop_front(); // remove "."
1262 if (eList.first() =="..") eList.pop_front(); // remove "."
1263 if (!eList.isEmpty())
1265 QMessageBox mb( __VYM,
1266 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1267 QMessageBox::Warning,
1269 QMessageBox::Cancel | QMessageBox::Default,
1270 QMessageBox::QMessageBox::NoButton );
1272 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1273 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1276 case QMessageBox::Yes:
1279 case QMessageBox::Cancel:
1287 QString Main::browseDirectory (const QString &caption)
1289 QFileDialog fd(this,caption);
1290 fd.setMode (QFileDialog::DirectoryOnly);
1291 fd.setCaption(__VYM " - "+caption);
1294 if ( fd.exec() == QDialog::Accepted )
1295 return fd.selectedFile();
1300 MapEditor* Main::currentMapEditor() const
1302 if ( tabWidget->currentPage() &&
1303 tabWidget->currentPage()->inherits( "MapEditor" ) )
1304 return (MapEditor*)tabWidget->currentPage();
1308 //TODO not used now, maybe use this for overview window later
1309 void Main::newView()
1311 // Open a new view... have it delete when closed.
1312 Main *m = new Main(0, 0, WDestructiveClose);
1313 qApp->setMainWidget(m);
1315 qApp->setMainWidget(0);
1318 void Main::editorChanged(QWidget *)
1320 // Unselect all possibly selected objects
1321 // (Important to update note editor)
1324 for (i=0;i<=tabWidget->count() -1;i++)
1327 me=(MapEditor*)tabWidget->page(i);
1330 currentMapEditor()->reselect();
1332 // Update actions to in menus and toolbars according to editor
1333 currentMapEditor()->updateActions();
1336 void Main::fileNew()
1338 QString fn="unnamed";
1339 MapEditor* medit = new MapEditor (tabWidget, true);
1340 tabWidget->addTab (medit,fn);
1341 tabWidget->showPage(medit);
1342 medit->viewport()->setFocus();
1343 // For the very first map we do not have flagrows yet...
1344 medit->select("mc:");
1347 void Main::fileLoad(QString fn, const LoadMode &lmode)
1349 errorCode err=success;
1351 // fn is usually the archive, mapfile the file after uncompressing
1354 // Make fn absolute (needed for unzip)
1355 fn=QDir (fn).absPath();
1361 // Check, if map is already loaded
1363 while (i<=tabWidget->count() -1)
1365 me=(MapEditor*)tabWidget->page(i);
1366 if (me->getFilePath() == fn)
1368 // Already there, ask for confirmation
1369 QMessageBox mb( __VYM,
1370 tr("The map %1\nis already opened."
1371 "Opening the same map in multiple editors may lead \n"
1372 "to confusion when finishing working with vym."
1373 "Do you want to").arg(fn),
1374 QMessageBox::Warning,
1375 QMessageBox::Yes | QMessageBox::Default,
1376 QMessageBox::Cancel | QMessageBox::Escape,
1377 QMessageBox::QMessageBox::NoButton);
1378 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1379 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1382 case QMessageBox::Yes:
1384 i=tabWidget->count();
1386 case QMessageBox::Cancel:
1398 if ( !fn.isEmpty() )
1400 me = currentMapEditor();
1401 int tabIndex=tabWidget->currentPageIndex();
1402 // Check first, if mapeditor exists
1403 // If it is not default AND we want a new map,
1404 // create a new mapeditor in a new tab
1405 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1407 me = new MapEditor (tabWidget,true);
1408 tabWidget->addTab (me,fn);
1409 tabIndex=tabWidget->indexOf (me);
1410 tabWidget->setCurrentPage (tabIndex);
1413 // Check, if file exists (important for creating new files
1414 // from command line
1415 if (!QFile(fn).exists() )
1417 QMessageBox mb( __VYM,
1418 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1419 QMessageBox::Question,
1421 QMessageBox::Cancel | QMessageBox::Default,
1422 QMessageBox::QMessageBox::NoButton );
1424 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1425 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1428 case QMessageBox::Yes:
1430 currentMapEditor()->setFilePath(fn);
1431 tabWidget->setTabLabel (currentMapEditor(),
1432 currentMapEditor()->getFileName() );
1433 statusBar()->message( "Created " + fn , statusbarTime );
1436 case QMessageBox::Cancel:
1437 // don't create new map
1438 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1445 //tabWidget->currentPage() won't be NULL here, because of above...
1446 tabWidget->showPage(me);
1447 me->viewport()->setFocus();
1449 // Create temporary directory for packing
1450 char tmpdir1[]="/tmp/vym-XXXXXX";
1451 QString tmpMapDir=mkdtemp(tmpdir1);
1453 // Try to unzip file
1454 err=unzipDir (tmpMapDir,fn);
1458 me->setZipped(false);
1461 me->setZipped(true);
1463 // Look for mapname.xml
1464 mapfile= fn.left(fn.findRev(".",-1,true));
1465 mapfile=mapfile.section( '/', -1 );
1466 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1467 if (!file.exists() )
1469 // mapname.xml does not exist, well,
1470 // maybe some renamed the mapname.vym file...
1471 // Try to find any .xml in the toplevel
1472 // directory of the .vym file
1473 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1474 if (flist.count()==1)
1476 // Only one entry, take this one
1477 mapfile=tmpMapDir + "/"+flist.first();
1480 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1481 *it=tmpMapDir + "/" + *it;
1482 // TODO Multiple entries, load all (but only the first one into this ME)
1483 //mainWindow->fileLoadFromTmp (flist);
1484 //returnCode=1; // Silently forget this attempt to load
1485 qWarning ("MainWindow::load (fn) multimap found...");
1488 if (flist.isEmpty() )
1490 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1491 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1494 } //file doesn't exist
1496 mapfile=file.name();
1501 // Save existing filename in case we import
1502 QString fn_org=me->getFilePath();
1504 // Finally load map into mapEditor
1505 me->setFilePath (mapfile,fn);
1506 if (me->load(mapfile,lmode))
1509 // Restore old (maybe empty) filepath, if this is an import
1511 me->setFilePath (fn_org);
1514 // Finally check for errors and go home
1517 if (lmode==NewMap) fileCloseMap();
1518 statusBar()->message( "Could not load " + fn, statusbarTime );
1523 me->setFilePath (fn);
1524 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1525 lastMaps.prepend(me->getFilePath() );
1526 setupLastMapsMenu();
1527 actionFilePrint->setEnabled (true);
1529 statusBar()->message( "Loaded " + fn, statusbarTime );
1533 removeDir (QDir(tmpMapDir));
1538 void Main::fileLoad(const LoadMode &lmode)
1540 QFileDialog *fd=new QFileDialog( this);
1541 if (!lastFileDir.isEmpty())
1542 fd->setDir (lastFileDir);
1543 fd->setMode (QFileDialog::ExistingFiles);
1544 fd->addFilter ("XML (*.xml)");
1545 fd->addFilter ("VYM map (*.vym *.vyp)");
1549 fd->setCaption(tr("Load vym map"));
1552 fd->setCaption(tr("Import: Add vym map to selection"));
1555 fd->setCaption(tr("Import: Replace selection with vym map"));
1561 if ( fd->exec() == QDialog::Accepted )
1563 lastFileDir=fd->dirPath();
1564 QStringList flist = fd->selectedFiles();
1565 QStringList::Iterator it = flist.begin();
1566 while( it != flist.end() )
1569 fileLoad(*it, lmode);
1576 void Main::fileLoad()
1581 void Main::fileLoadLast(int i)
1583 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1586 void Main::fileSave(const SaveMode &savemode)
1588 // tmp dir for zipping
1592 enum errorCode {success,aborted};
1593 errorCode err=success;
1595 QString safeFilePath;
1597 bool saveZipped=currentMapEditor()->saveZipped();
1599 MapEditor * me=currentMapEditor();
1602 QString fn=me->getFilePath();
1603 // filename=unnamed, filepath="" in constructor...
1604 if ( !fn.isEmpty() )
1606 // We have a filepath, go on saving
1607 // First remove existing file, we
1608 // don't want to add to old zip archives
1612 QMessageBox::warning( 0, tr( "Save Error" ),
1613 fn+ tr("\ncould not be removed before saving"));
1615 // Look, if we should zip the data:
1618 QMessageBox mb( __VYM,
1619 tr("The map %1\ndid not use the compressed "
1620 "vym file format.\nWriting it uncompressed will also write images \n"
1621 "and flags and thus may overwrite files in the "
1622 "given directory\n\nDo you want to write the map").arg(fn),
1623 QMessageBox::Warning,
1624 QMessageBox::Yes | QMessageBox::Default,
1626 QMessageBox::Cancel | QMessageBox::Escape);
1627 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1628 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1629 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1632 case QMessageBox::Yes:
1633 // save compressed (default file format)
1636 case QMessageBox::No:
1637 // save uncompressed
1640 case QMessageBox::Cancel:
1649 char tmpdir1[]="/tmp/vym-XXXXXX";
1650 tmpMapDir=mkdtemp(tmpdir1);
1652 safeFilePath=me->getFilePath();
1653 me->setFilePath (tmpMapDir+"/"+
1654 me->getMapName()+ ".xml",
1656 me->save (savemode);
1657 me->setFilePath (safeFilePath);
1659 zipDir (tmpMapDir,fn);
1664 safeFilePath=me->getFilePath();
1665 me->setFilePath (fn, safeFilePath);
1666 me->save (savemode);
1667 me->setFilePath (safeFilePath);
1669 } // filepath available
1672 // We have no filepath yet,
1673 // call fileSaveAs() now, this will call fileSave()
1675 fileSaveAs(savemode);
1679 if (me->saveZipped())
1682 removeDir (QDir(tmpMapDir));
1687 statusBar()->message(
1688 tr("Saved %1").arg(me->getFilePath()),
1690 lastMaps.prepend(me->getFilePath() );
1691 setupLastMapsMenu();
1693 statusBar()->message(
1694 tr("Couldn't save ").arg(me->getFilePath()),
1698 void Main::fileSave()
1700 fileSave (CompleteMap);
1703 void Main::fileSaveAs(const SaveMode& savemode)
1708 if (currentMapEditor())
1710 if (savemode==CompleteMap)
1711 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1713 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1714 if ( !fn.isEmpty() )
1716 // Check for existing file
1717 if (QFile (fn).exists())
1719 QMessageBox mb( __VYM,
1720 tr("The file %1\nexists already. Do you want to").arg(fn),
1721 QMessageBox::Warning,
1722 QMessageBox::Yes | QMessageBox::Default,
1723 QMessageBox::Cancel | QMessageBox::Escape,
1724 QMessageBox::QMessageBox::NoButton);
1725 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1726 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1729 case QMessageBox::Yes:
1732 case QMessageBox::Cancel:
1739 // New file, add extension to filename, if missing
1740 // This is always .vym or .vyp, depending on savemode
1741 if (savemode==CompleteMap)
1743 if (!fn.contains (".vym") && !fn.contains (".xml"))
1747 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1756 currentMapEditor()->setFilePath(fn);
1760 if (savemode==CompleteMap)
1761 tabWidget->setTabLabel (currentMapEditor(),
1762 currentMapEditor()->getFileName() );
1768 void Main::fileSaveAs()
1770 fileSaveAs (CompleteMap);
1773 void Main::fileImportDir()
1775 if (currentMapEditor())
1776 currentMapEditor()->importDir();
1779 void Main::fileExportXML()
1781 if (currentMapEditor())
1783 QString dir=browseDirectory(tr("Export XML to directory"));
1784 if (dir !="" && reallyWriteDirectory(dir) )
1785 currentMapEditor()->exportXML(dir);
1789 void Main::fileExportHTML()
1791 if (currentMapEditor())
1793 ExportHTMLDialog dia(this);
1795 if (dia.exec()==QDialog::Accepted)
1797 QString dir=dia.getDir();
1798 if (reallyWriteDirectory(dir) )
1800 currentMapEditor()->exportXML (dia.getDir() );
1801 dia.doExport(currentMapEditor()->getMapName() );
1807 void Main::fileExportXHTML()
1810 if (currentMapEditor())
1812 ExportXHTMLDialog dia(this);
1813 dia.setFilePath (currentMapEditor()->getFilePath() );
1814 dia.setMapName (currentMapEditor()->getMapName() );
1817 if (dia.exec()==QDialog::Accepted)
1819 QString dir=dia.getDir();
1820 // Check, if warnings should be used before overwriting
1821 // the output directory
1824 ok=reallyWriteDirectory(dir);
1830 currentMapEditor()->exportXML (dia.getDir() );
1831 dia.doExport(currentMapEditor()->getMapName() );
1832 if (dia.hasChanged())
1833 currentMapEditor()->setChanged();
1839 void Main::fileExportImage(int item)
1841 if (currentMapEditor())
1843 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1845 if ( !fn.isEmpty() )
1847 currentMapEditor()->exportImage(fn,item);
1849 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1854 void Main::fileExportASCII()
1856 if (currentMapEditor())
1857 currentMapEditor()->exportASCII();
1860 void Main::fileExportLaTeX()
1862 if (currentMapEditor())
1863 currentMapEditor()->exportLaTeX();
1866 void Main::fileExportOOPresentation()
1868 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to Open Office"));
1869 // FIXME add extra info in dialog
1870 //ImagePreview *p =new ImagePreview (fd);
1871 //fd->setContentsPreviewEnabled( TRUE );
1872 //fd->setContentsPreview( p, p );
1873 //fd->setPreviewMode( QFileDialog::Contents );
1874 fd->setCaption(__VYM " - " +tr("Export to Open Office"));
1875 //fd->setDir (lastImageDir);
1878 if ( fd->exec() == QDialog::Accepted )
1880 QString fn=fd->selectedFile();
1881 //lastImageDir=fn.left(fn.findRev ("/"));
1882 if (currentMapEditor())
1883 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
1887 void Main::fileCloseMap()
1889 if (currentMapEditor())
1891 if (currentMapEditor()->hasChanged())
1893 QMessageBox mb( __VYM,
1894 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1895 QMessageBox::Warning,
1896 QMessageBox::Yes | QMessageBox::Default,
1898 QMessageBox::Cancel | QMessageBox::Escape );
1899 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1900 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1903 case QMessageBox::Yes:
1905 fileSave(CompleteMap);
1907 case QMessageBox::No:
1908 // close without saving
1910 case QMessageBox::Cancel:
1915 currentMapEditor()->closeMap();
1916 tabWidget->removePage(currentMapEditor());
1917 if (tabWidget->count()==0)
1918 actionFilePrint->setEnabled (false);
1922 void Main::filePrint()
1924 if (currentMapEditor())
1925 currentMapEditor()->print();
1928 void Main::fileExitVYM()
1930 // Check if one or more editors have changed
1933 for (i=0;i<=tabWidget->count() -1;i++)
1936 me=(MapEditor*)tabWidget->page(i);
1938 // If something changed, ask what to do
1939 if (me->isUnsaved())
1941 tabWidget->setCurrentPage(i);
1942 QMessageBox mb( __VYM,
1943 tr("This map is not saved yet. Do you want to"),
1944 QMessageBox::Warning,
1945 QMessageBox::Yes | QMessageBox::Default,
1947 QMessageBox::Cancel | QMessageBox::Escape );
1948 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1949 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1951 // Call undocumented function: setActiveWindow is only
1952 // possible, if widget is visible. This depends on
1954 #if defined(Q_OS_LINUX)
1955 qt_wait_for_window_manager( this);
1957 mb.setActiveWindow();
1958 switch( mb.exec() ) {
1959 case QMessageBox::Yes:
1960 // save (the changed editors) and exit
1961 fileSave(CompleteMap);
1963 case QMessageBox::No:
1964 // exit without saving
1966 case QMessageBox::Cancel:
1967 // don't save and don't exit
1971 } // loop over all MEs
1975 void Main::editUndo()
1977 if (currentMapEditor())
1978 currentMapEditor()->undo();
1981 void Main::editRedo()
1983 if (currentMapEditor())
1984 currentMapEditor()->redo();
1987 void Main::editCopy()
1989 if (currentMapEditor())
1990 currentMapEditor()->copy();
1993 void Main::editPaste()
1995 if (currentMapEditor())
1996 currentMapEditor()->paste();
1999 void Main::editCut()
2001 if (currentMapEditor())
2002 currentMapEditor()->cut();
2005 void Main::editOpenFindWindow()
2007 findWindow->popup();
2008 findWindow->raise();
2010 // Call undocumented function: setActiveWindow is only
2011 // possible, if widget is visible. This depends on
2013 #if defined(Q_OS_LINUX)
2014 qt_wait_for_window_manager( this);
2016 findWindow->setActiveWindow();
2019 void Main::editFind(QString s)
2022 BranchObj *bo=currentMapEditor()->findText(s, cs);
2025 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2028 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2029 tr("No matches found for <b>%1</b>").arg(s));
2033 void Main::editFindChanged()
2034 { // Notify editor, to abort the current find process
2035 currentMapEditor()->findReset();
2038 void Main::editOpenURL()
2040 if (currentMapEditor())
2041 currentMapEditor()->openURL();
2044 void Main::editURL()
2046 if (currentMapEditor())
2047 currentMapEditor()->editURL();
2050 void Main::editHeading2URL()
2052 if (currentMapEditor())
2053 currentMapEditor()->editHeading2URL();
2056 void Main::editBugzilla2URL()
2058 if (currentMapEditor())
2059 currentMapEditor()->editBugzilla2URL();
2062 void Main::editFATE2URL()
2064 if (currentMapEditor())
2065 currentMapEditor()->editFATE2URL();
2068 void Main::editOpenVymLink()
2070 // Get current path to map
2071 QString currentVymLink;
2072 if (currentMapEditor())
2074 currentVymLink=currentMapEditor()->getVymLink();
2075 // compare path with already loaded maps
2079 for (i=0;i<=tabWidget->count() -1;i++)
2081 me=(MapEditor*)tabWidget->page(i);
2082 if (currentVymLink==me->getFilePath() )
2091 if (!QFile(currentVymLink).exists() )
2092 QMessageBox::critical( 0, tr( "Critical Error" ),
2093 tr("Couldn't open map %1").arg(currentVymLink));
2096 fileLoad (currentVymLink, NewMap);
2097 tabWidget->setCurrentPage (tabWidget->count()-1);
2100 // Go to tab containing the map
2101 tabWidget->setCurrentPage (index);
2105 void Main::editVymLink()
2107 if (currentMapEditor())
2108 currentMapEditor()->editVymLink();
2111 void Main::editDeleteVymLink()
2113 if (currentMapEditor())
2114 currentMapEditor()->deleteVymLink();
2117 void Main::editMapInfo()
2119 if (currentMapEditor())
2120 currentMapEditor()->editMapInfo();
2123 void Main::editMoveUp()
2125 if (currentMapEditor())
2126 currentMapEditor()->moveBranchUp();
2129 void Main::editMoveDown()
2131 if (currentMapEditor())
2132 currentMapEditor()->moveBranchDown();
2135 void Main::editToggleScroll()
2137 if (currentMapEditor())
2139 currentMapEditor()->toggleScroll();
2143 void Main::editUnScrollAll()
2145 if (currentMapEditor())
2147 currentMapEditor()->unScrollAll();
2151 void Main::editHeading()
2153 if (currentMapEditor())
2154 currentMapEditor()->editHeading();
2157 void Main::editNewBranch()
2159 if (currentMapEditor())
2160 currentMapEditor()->addNewBranch(0);
2163 void Main::editNewBranchHere()
2165 if (currentMapEditor())
2166 currentMapEditor()->addNewBranchHere();
2169 void Main::editNewBranchAbove()
2171 if (currentMapEditor())
2172 currentMapEditor()->addNewBranch(-1);
2175 void Main::editNewBranchBelow()
2177 if (currentMapEditor())
2178 currentMapEditor()->addNewBranch(1);
2181 void Main::editImportAdd()
2183 fileLoad (ImportAdd);
2186 void Main::editImportReplace()
2188 fileLoad (ImportReplace);
2191 void Main::editSaveBranch()
2193 fileSaveAs (PartOfMap);
2196 void Main::editRemoveBranchHere()
2198 if (currentMapEditor())
2199 currentMapEditor()->removeBranchHere();
2202 void Main::editRemoveChilds()
2204 if (currentMapEditor())
2205 currentMapEditor()->removeChilds();
2208 void Main::editDeleteSelection()
2210 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2211 currentMapEditor()->deleteSelection();
2214 void Main::editUpperBranch()
2216 if (currentMapEditor())
2217 currentMapEditor()->selectUpperBranch();
2220 void Main::editLowerBranch()
2222 if (currentMapEditor())
2223 currentMapEditor()->selectLowerBranch();
2226 void Main::editLeftBranch()
2228 if (currentMapEditor())
2229 currentMapEditor()->selectLeftBranch();
2232 void Main::editRightBranch()
2234 if (currentMapEditor())
2235 currentMapEditor()->selectRightBranch();
2238 void Main::editFirstBranch()
2240 if (currentMapEditor())
2241 currentMapEditor()->selectFirstBranch();
2244 void Main::editLastBranch()
2246 if (currentMapEditor())
2247 currentMapEditor()->selectLastBranch();
2250 void Main::editLoadImage()
2252 if (currentMapEditor())
2253 currentMapEditor()->loadFloatImage();
2256 void Main::editSaveImage(int item)
2258 if (currentMapEditor())
2259 currentMapEditor()->saveFloatImage(item);
2262 void Main::editToggleFloatExport()
2264 if (currentMapEditor())
2265 currentMapEditor()->toggleFloatExport();
2268 void Main::editFollowXLink(int item)
2270 if (currentMapEditor())
2271 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2274 void Main::editEditXLink(int item)
2276 if (currentMapEditor())
2277 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2280 void Main::formatSelectColor()
2282 if (currentMapEditor())
2284 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2285 if ( !col.isValid() ) return;
2286 currentMapEditor()->setColor( col );
2287 colorChanged( col );
2291 void Main::formatPickColor()
2293 if (currentMapEditor())
2294 colorChanged( currentMapEditor()->pickColor() );
2297 void Main::colorChanged(QColor c)
2299 QPixmap pix( 16, 16 );
2301 actionFormatColor->setIconSet( pix );
2304 void Main::formatColorItem()
2306 if (currentMapEditor())
2307 currentMapEditor()->colorItem();
2310 void Main::formatColorBranch()
2312 if (currentMapEditor())
2313 currentMapEditor()->colorBranch();
2316 void Main::formatLinkStyleLine()
2318 if (currentMapEditor())
2319 currentMapEditor()->setLinkStyle(StyleLine);
2322 void Main::formatLinkStyleParabel()
2324 if (currentMapEditor())
2325 currentMapEditor()->setLinkStyle(StyleParabel);
2328 void Main::formatLinkStylePolyLine()
2330 if (currentMapEditor())
2331 currentMapEditor()->setLinkStyle(StylePolyLine);
2334 void Main::formatLinkStylePolyParabel()
2336 if (currentMapEditor())
2337 currentMapEditor()->setLinkStyle(StylePolyParabel);
2340 void Main::formatSelectBackColor()
2342 if (currentMapEditor())
2343 currentMapEditor()->selectBackgroundColor();
2346 void Main::formatSelectLinkColor()
2348 if (currentMapEditor())
2349 currentMapEditor()->selectLinkColor();
2352 void Main::formatToggleLinkColorHint()
2354 currentMapEditor()->toggleLinkColorHint();
2357 void Main::formatFrameNone()
2359 if (currentMapEditor())
2360 currentMapEditor()->setFrame(NoFrame);
2363 void Main::formatFrameRectangle()
2365 if (currentMapEditor())
2366 currentMapEditor()->setFrame(Rectangle);
2369 void Main::formatIncludeImagesVer()
2371 if (currentMapEditor())
2372 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2375 void Main::formatIncludeImagesHor()
2377 if (currentMapEditor())
2378 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2381 void Main::formatHideLinkUnselected()
2383 if (currentMapEditor())
2384 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2387 void Main::viewZoomReset()
2389 if (currentMapEditor())
2393 currentMapEditor()->setWorldMatrix( m );
2394 currentMapEditor()->setViewCenter();
2395 currentMapEditor()->adjustCanvasSize();
2399 void Main::viewZoomIn()
2401 if (currentMapEditor())
2403 QWMatrix m = currentMapEditor()->worldMatrix();
2404 m.scale( 1.25, 1.25 );
2405 currentMapEditor()->setWorldMatrix( m );
2406 currentMapEditor()->setViewCenter();
2407 currentMapEditor()->adjustCanvasSize();
2411 void Main::viewZoomOut()
2413 if (currentMapEditor())
2415 QWMatrix m = currentMapEditor()->worldMatrix();
2416 m.scale( 0.8, 0.8 );
2417 currentMapEditor()->setWorldMatrix( m );
2418 currentMapEditor()->setViewCenter();
2419 currentMapEditor()->adjustCanvasSize();
2423 void Main::modModeColor()
2427 void Main::modModeLink()
2431 bool Main::settingsPDF()
2433 // Default browser is set in constructor
2435 QString text = QInputDialog::getText(
2436 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2437 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2439 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2444 bool Main::settingsURL()
2446 // Default browser is set in constructor
2448 QString text = QInputDialog::getText(
2449 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2450 settings.readEntry("/vym/mainwindow/readerURL")
2453 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2457 void Main::windowToggleNoteEditor()
2459 if (textEditor->showWithMain() )
2460 windowHideNoteEditor();
2462 windowShowNoteEditor();
2465 void Main::updateNoteFlag()
2467 if (currentMapEditor())
2468 currentMapEditor()->updateNoteFlag();
2471 void Main::windowShowNoteEditor()
2473 textEditor->setShowWithMain(true);
2475 actionViewToggleNoteEditor->setOn (true);
2478 void Main::windowHideNoteEditor()
2480 textEditor->setShowWithMain(false);
2482 actionViewToggleNoteEditor->setOn (false);
2485 void Main::windowNextEditor()
2487 if (tabWidget->currentPageIndex() < tabWidget->count())
2488 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2491 void Main::windowPreviousEditor()
2493 if (tabWidget->currentPageIndex() >0)
2494 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2497 void Main::standardFlagChanged()
2499 currentMapEditor()->toggleStandardFlag(sender()->name());
2502 void Main::testFunction()
2504 fileExportOOPresentation();
2505 // currentMapEditor()->testFunction();
2508 void Main::helpDoc()
2511 #if defined(Q_OS_MACX)
2512 docpath="./vym.app/Contents/vym.pdf";
2514 // default path in SUSE LINUX
2515 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2518 if (!QFile (docpath).exists() )
2520 // relative path for easy testing in tarball
2521 docpath="doc/vym.pdf";
2522 if (!QFile (docpath).exists() )
2524 // relative path for testing while still writing vym.tex
2525 docpath="doc/tex/vym.pdf";
2526 if (!QFile (docpath).exists() )
2528 // Try yet another one for Knoppix
2529 docpath="/usr/share/doc/packages/vym/vym.pdf";
2530 if (!QFile (docpath).exists() )
2532 QMessageBox::critical(0,
2533 tr("Critcal error"),
2534 tr("Couldn't find the documentation\n"
2535 "vym.pdf in various places."));
2542 Process *pdfProc = new Process();
2543 pdfProc->clearArguments();
2544 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2545 pdfProc->addArgument( docpath);
2547 if ( !pdfProc->start() )
2550 QMessageBox::critical(0,
2551 tr("Critcal error"),
2552 tr("Couldn't find a viewer to read vym.pdf.\n"
2553 "Please use Settings->")+tr("Set application to open pdf files"));
2559 void Main::helpAbout()
2562 ad.setName ("aboutwindow");
2563 ad.setMinimumSize(500,500);
2564 ad.resize (QSize (500,500));
2568 void Main::helpAboutQT()
2570 QMessageBox::aboutQt( this, "Qt Application Example" );