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"
27 #include "icons/filenew.xpm"
28 #include "icons/fileopen.xpm"
29 #include "icons/filesave.xpm"
30 #include "icons/fileprint.xpm"
31 #include "icons/editundo.xpm"
32 #include "icons/editredo.xpm"
33 #include "icons/editcopy.xpm"
34 #include "icons/editcut.xpm"
35 #include "icons/editpaste.xpm"
36 #include "icons/editmoveup.xpm"
37 #include "icons/editmovedown.xpm"
38 #include "icons/formatcoloritem.xpm"
39 #include "icons/formatcolorbranch.xpm"
40 #include "icons/formatcolorpicker.xpm"
41 #include "icons/viewzoomreset.xpm"
42 #include "icons/viewzoomin.xpm"
43 #include "icons/viewzoomout.xpm"
44 #include "icons/modecolor.xpm"
45 #include "icons/modelink.xpm"
46 #include "icons/modecopy.xpm"
47 //#include "icons/vym-48x48.xpm"
49 #include "icons/flag-questionmark.xpm"
50 #include "icons/flag-exclamationmark.xpm"
51 #include "icons/flag-hook-green.xpm"
52 #include "icons/flag-cross-red.xpm"
53 #include "icons/flag-stopsign.xpm"
54 #include "icons/flag-smiley-good.xpm"
55 #include "icons/flag-smiley-sad.xpm"
56 #include "icons/flag-clock.xpm"
57 #include "icons/flag-lamp.xpm"
58 #include "icons/flag-arrow-up.xpm"
59 #include "icons/flag-arrow-down.xpm"
60 #include "icons/flag-thumb-up.xpm"
61 #include "icons/flag-thumb-down.xpm"
62 #include "icons/flag-heart.xpm"
63 #include "icons/flag-flash.xpm"
64 #include "icons/flag-lifebelt.xpm"
66 #include "icons/flag-note.xpm"
67 #include "icons/flag-url.xpm"
68 #include "icons/flag-vymlink.xpm"
69 #include "icons/flag-scrolled-right.xpm"
70 #include "icons/flag-tmpUnscrolled-right.xpm"
72 #include "flagrowobj.h"
73 #include "texteditor.h"
74 #include "mapeditor.h"
75 #include "exporthtmldialog.h"
76 #include "exportxhtmldialog.h"
77 #include "showtextdialog.h"
82 extern TextEditor *textEditor;
83 extern Main *mainWindow;
84 extern QString tmpVymDir;
85 extern QString clipboardDir;
86 extern bool clipboardEmpty;
87 extern int statusbarTime;
88 extern MapEditor *clipboardME;
89 extern FlagRowObj* standardFlagsDefault;
90 extern FlagRowObj* systemFlagsDefault;
92 extern QPtrList <QAction> actionListBranches;
94 extern QAction* actionFileSave;
95 extern QAction* actionFilePrint;
96 extern QAction* actionEditUndo;
97 extern QAction* actionEditRedo;
98 extern QAction *actionEditCopy;
99 extern QAction *actionEditCut;
100 extern QAction *actionEditPaste;
101 extern QAction *actionEditMoveUp;
102 extern QAction *actionEditMoveDown;
103 extern QAction *actionEditToggleScroll;
104 extern QAction* actionEditOpenURL;
105 extern QAction* actionEditURL;
106 extern QAction* actionEditHeading2URL;
107 extern QAction* actionEditBugzilla2URL;
108 extern QAction* actionEditFATE2URL;
109 extern QAction *actionEditOpenVymLink;
110 extern QAction *actionEditVymLink;
111 extern QAction *actionEditDeleteVymLink;
112 extern QAction *actionEditMapInfo;
113 extern QAction *actionEditHeading;
114 extern QAction *actionEditDelete;
115 extern QAction *actionEditAddBranch;
116 extern QAction *actionEditAddBranchHere;
117 extern QAction *actionEditAddBranchAbove;
118 extern QAction *actionEditAddBranchBelow;
119 extern QAction *actionEditRemoveBranchHere;
120 extern QAction *actionEditRemoveChilds;
121 extern QAction *actionEditImportAdd;
122 extern QAction *actionEditImportReplace;
123 extern QAction *actionEditSaveBranch;
124 extern QAction *actionEditSelectFirst;
125 extern QAction *actionEditSelectLast;
126 extern QAction *actionEditLoadImage;
127 extern QAction *actionEditToggleFloatExport;
129 extern QAction* actionFormatColor;
130 extern QAction* actionFormatPickColor;
131 extern QAction* actionFormatColorBranch;
132 extern QAction* actionFormatColorSubtree;
133 extern QAction* actionFormatLinkColorHint;
134 extern QAction* actionFormatBackColor;
135 extern QAction* actionFormatLinkColor;
136 extern QAction *actionFormatIncludeImagesVer;
137 extern QAction *actionFormatIncludeImagesHor;
139 extern QActionGroup* actionGroupModModes;
140 extern QAction* actionModModeColor;
141 extern QAction* actionModModeLink;
142 extern QAction* actionModModeCopy;
144 extern QActionGroup *actionGroupFormatFrameTypes;
145 extern QAction *actionFormatFrameNone;
146 extern QAction *actionFormatFrameRectangle;
148 extern QActionGroup *actionGroupFormatLinkStyles;
149 extern QAction *actionFormatLinkStyleLine;
150 extern QAction *actionFormatLinkStyleParabel;
151 extern QAction *actionFormatLinkStylePolyLine;
152 extern QAction *actionFormatLinkStylePolyParabel;
153 extern QAction *actionFormatHideLinkUnselected;
155 extern QAction *actionViewToggleNoteEditor;
157 extern QAction* actionSettingsAutoedit;
158 extern QAction* actionSettingsAutoselectHeading;
159 extern QAction* actionSettingsAutoselectHeading;
160 extern QAction* actionSettingsAutoselectText;
161 extern QAction* actionSettingsPasteNewHeading;
162 extern QAction* actionSettingsUseDelKey;
163 extern QAction* actionSettingsUseFlagGroups;
165 extern QPopupMenu* branchContextMenu;
166 extern QPopupMenu* branchAddContextMenu;
167 extern QPopupMenu* branchRemoveContextMenu;
168 extern QPopupMenu* branchLinksContextMenu;
169 extern QPopupMenu* branchLinksContextMenuDup;
170 extern QPopupMenu* floatimageContextMenu;
171 extern QPopupMenu* saveImageFormatMenu;
172 extern QPopupMenu* canvasContextMenu;
173 extern QPopupMenu* lastMapsMenu;
174 extern QPopupMenu* exportMenu;
175 extern QPopupMenu* exportImageFormatMenu;
178 extern Settings settings;
179 extern Options options;
181 #if defined(Q_OS_LINUX)
182 extern void qt_wait_for_window_manager( QWidget* w );
185 Main::Main(QWidget* parent, const char* name, WFlags f) :
186 QMainWindow(parent,name,f)
190 setCaption ("VYM - View Your Mind");
192 // Load window settings
193 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
194 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
195 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
196 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
199 // Create unique temporary directory
200 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
202 // Create direcctory for clipboard
203 clipboardDir=tmpVymDir+"/clipboard";
204 QDir d(clipboardDir);
205 d.mkdir (clipboardDir,true);
206 makeSubDirs (clipboardDir);
209 // FIXME not used currently
210 // Set random seed (random used for object IDs)
211 // QTime t = QTime::currentTime(); // set random seed
212 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
215 // Initialize some settings, which are platform dependant
218 // application to open URLs
219 p="/vym/mainwindow/readerURL";
220 #if defined(Q_OS_LINUX)
221 s=settings.readEntry (p,"konqueror");
223 #if defined(Q_OS_MACX)
224 s=settings.readEntry (p,"/usr/bin/open");
226 s=settings.readEntry (p,"mozilla");
229 settings.writeEntry( p,s);
231 // application to open PDFs
232 p="/vym/mainwindow/readerPDF";
233 #if defined(Q_OS_LINUX)
234 s=settings.readEntry (p,"acroread");
236 #if defined(Q_OS_MACX)
237 s=settings.readEntry (p,"/usr/bin/open");
239 s=settings.readEntry (p,"acroread");
242 settings.writeEntry( p,s);
247 // Create tab widget which holds the maps
248 tabWidget= new QTabWidget (this);
249 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
250 this, SLOT( editorChanged( QWidget * ) ) );
252 setCentralWidget(tabWidget);
256 setupFormatActions();
260 setupSettingsActions();
262 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
265 // After menu is created, we can enable some actions
266 actionFilePrint->setEnabled (true);
271 // Initialize Find window
272 findWindow=new FindWindow(NULL,"findwindow");
273 connect (findWindow, SIGNAL( findButton(QString) ),
274 this, SLOT(editFind(QString) ) );
275 connect (findWindow, SIGNAL( somethingChanged() ),
276 this, SLOT(editFindChanged() ) );
278 // Connect TextEditor, so that we can update flags if text changes
279 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
287 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
288 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
289 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
290 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
292 settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
293 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
295 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
296 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
297 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
298 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
299 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
300 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
303 int maps=lastMaps.count();
304 settings.writeEntry( "/vym/lastMaps/number",maps );
305 for (int i=1;i<=maps;i++)
307 QStringList::Iterator it = lastMaps.at(i-1);
308 s=QString("/vym/lastMaps/map-%1").arg(i);
309 if (!s.isEmpty() && i<=maxLastMaps)
310 settings.writeEntry (s, *it);
314 // To make the texteditor save its settings, call the destructor
317 // Remove temporary directory
318 removeDir (QDir(tmpVymDir));
321 void Main::loadCmdLine()
323 /* TODO draw some kind of splashscreen while loading...
329 QStringList flist=options.getFileList();
330 QStringList::Iterator it=flist.begin();
332 while (it !=flist.end() )
334 fileLoad (*it, NewMap);
340 void Main::statusMessage(const QString &s)
342 statusBar()->message (s);
345 void Main::closeEvent (QCloseEvent* )
351 void Main::setupFileActions()
353 QToolBar *tb = new QToolBar( this );
354 tb->setLabel( "File Actions" );
355 QPopupMenu *menu = new QPopupMenu( this );
356 menuBar()->insertItem( tr( "&File" ), menu );
358 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
361 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
362 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
366 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
367 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
371 lastMapsMenu = new QPopupMenu (this);
373 menu->insertItem (tr("Open Recent"),lastMapsMenu );
374 menu->insertSeparator();
376 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
377 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
382 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
383 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
386 menu->insertSeparator();
388 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
389 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
392 exportMenu = new QPopupMenu (this);
393 menu->insertItem (tr("Export"),exportMenu );
395 menu->insertSeparator();
398 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
399 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
404 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
405 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
408 a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
409 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
415 void Main::setupEditActions()
417 QToolBar *tb = new QToolBar( this );
418 tb->setLabel( "Edit Actions" );
419 QPopupMenu *menu = new QPopupMenu( this );
420 menuBar()->insertItem( tr( "&Edit" ), menu );
424 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
425 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
426 a->setEnabled (false);
431 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
433 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
434 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
439 menu->insertSeparator();
440 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
441 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
442 a->setEnabled (false);
446 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
447 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
448 a->setEnabled (false);
452 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
453 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
454 a->setEnabled (false);
459 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
460 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
461 a->setEnabled (false);
464 actionListBranches.append(a);
467 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
468 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
469 a->setEnabled (false);
472 actionListBranches.append(a);
473 actionEditMoveDown=a;
476 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
477 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
478 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
479 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
480 #if defined(Q_OS_MACX)
481 actionEditToggleScroll=alt;
483 actionEditToggleScroll=a;
485 actionEditToggleScroll->setEnabled (false);
486 actionEditToggleScroll->addTo( tb );
487 actionEditToggleScroll->addTo( menu );
488 actionListBranches.append(actionEditToggleScroll);
490 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
491 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
494 menu->insertSeparator();
496 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
497 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
500 menu->insertSeparator();
502 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
503 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
505 a->setEnabled (false);
508 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
509 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
510 a->setEnabled (false);
511 actionListBranches.append(a);
514 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
515 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
516 a->setEnabled (false);
517 actionListBranches.append(a);
518 actionEditHeading2URL=a;
520 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
521 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
522 a->setEnabled (false);
523 actionListBranches.append(a);
524 actionEditBugzilla2URL=a;
526 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
527 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
528 a->setEnabled (false);
529 actionListBranches.append(a);
530 actionEditFATE2URL=a;
532 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" );
533 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
535 a->setEnabled (false);
536 actionEditOpenVymLink=a;
538 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
539 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
540 a->setEnabled (false);
541 actionListBranches.append(a);
544 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
545 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
546 a->setEnabled (false);
547 actionEditDeleteVymLink=a;
549 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
550 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
551 a->setEnabled (true);
554 menu->insertSeparator();
556 // Shortcuts to modify heading:
557 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
558 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
559 actionListBranches.append(a);
560 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
561 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
562 actionListBranches.append(a);
564 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
565 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
566 a->setEnabled (false);
568 actionListBranches.append(a);
570 // Shortcut to delete selection
571 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
572 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
573 a->setEnabled (false);
576 // Shortcut to add branch
577 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
578 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
579 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
580 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
581 a->setEnabled (false);
582 actionListBranches.append(a);
583 #if defined (Q_OS_MACX)
584 // In OSX show different shortcut in menues, the keys work independtly always
585 actionEditAddBranch=alt;
587 actionEditAddBranch=a;
590 // Add branch by inserting it at selection
591 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
592 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
593 a->setEnabled (false);
594 actionListBranches.append(a);
595 actionEditAddBranchHere=a;
596 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
597 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
598 actionListBranches.append(a);
601 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
602 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
603 a->setEnabled (false);
604 actionListBranches.append(a);
605 actionEditAddBranchAbove=a;
606 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
607 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
608 actionListBranches.append(a);
611 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
612 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
613 a->setEnabled (false);
614 actionListBranches.append(a);
615 actionEditAddBranchBelow=a;
616 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
617 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
618 actionListBranches.append(a);
620 // Import at selection (adding to selection)
621 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
622 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
623 a->setEnabled (false);
624 actionListBranches.append(a);
625 actionEditImportAdd=a;
627 // Import at selection (replacing selection)
628 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
629 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
630 a->setEnabled (false);
631 actionListBranches.append(a);
632 actionEditImportReplace=a;
635 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
636 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
637 a->setEnabled (false);
638 actionListBranches.append(a);
639 actionEditSaveBranch=a;
641 // Only remove branch, not its childs
642 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
643 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
644 a->setEnabled (false);
645 actionListBranches.append(a);
646 actionEditRemoveBranchHere=a;
648 // Only remove childs of a branch
649 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
650 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
651 a->setEnabled (false);
652 actionListBranches.append(a);
653 actionEditRemoveChilds=a;
655 // Shortcuts for navigating with cursor:
656 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
657 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
658 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
659 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
660 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
661 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
662 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
663 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
664 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
665 a->setEnabled (false);
667 actionListBranches.append(a);
668 actionEditSelectFirst=a;
669 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
670 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
671 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
672 a->setEnabled (false);
674 actionListBranches.append(a);
675 actionEditSelectLast=a;
677 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
678 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
679 actionEditLoadImage=a;
684 void Main::setupFormatActions()
686 QPopupMenu *menu = new QPopupMenu( this );
687 menuBar()->insertItem( tr( "&Format" ), menu );
689 QToolBar *tb = new QToolBar( this );
693 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
694 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
695 actionFormatColor->addTo( tb );
696 actionFormatColor->addTo( menu );
697 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" );
698 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
699 a->setEnabled (false);
702 actionListBranches.append(a);
703 actionFormatPickColor=a;
704 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
705 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
706 a->setEnabled (false);
709 actionListBranches.append(a);
710 actionFormatColorBranch=a;
711 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
712 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
713 a->setEnabled (false);
716 actionListBranches.append(a);
717 actionFormatColorSubtree=a;
719 menu->insertSeparator();
720 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
721 actionGroupFormatLinkStyles->setExclusive (true);
722 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
723 a->setToggleAction(true);
724 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
725 actionFormatLinkStyleLine=a;
726 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
727 a->setToggleAction(true);
728 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
729 actionFormatLinkStyleParabel=a;
730 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
731 a->setToggleAction(true);
732 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
733 actionFormatLinkStylePolyLine=a;
734 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
735 a->setToggleAction(true);
736 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
737 actionFormatLinkStylePolyParabel=a;
738 actionGroupFormatLinkStyles->addTo (menu);
740 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
741 actionGroupFormatFrameTypes->setExclusive (true);
742 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
743 a->setToggleAction(true);
744 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
745 actionFormatFrameNone=a;
746 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
747 a->setToggleAction(true);
748 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
749 actionFormatFrameRectangle=a;
751 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
752 a->setToggleAction(true);
753 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
754 actionFormatIncludeImagesVer=a;
756 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
757 a->setToggleAction(true);
758 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
759 actionFormatIncludeImagesHor=a;
761 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
762 a->setToggleAction(true);
763 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
764 actionFormatHideLinkUnselected=a;
766 menu->insertSeparator();
767 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
768 a->setToggleAction(true);
769 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
771 actionFormatLinkColorHint=a;
773 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
774 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
775 actionFormatLinkColor->addTo( menu );
776 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
777 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
778 actionFormatBackColor->addTo( menu );
782 void Main::setupViewActions()
784 QToolBar *tb = new QToolBar( this );
785 tb->setLabel( "View Actions" );
786 QPopupMenu *menu = new QPopupMenu( this );
787 menuBar()->insertItem( tr( "&View" ), menu );
790 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
791 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
794 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
795 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
798 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
799 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
802 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
803 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
804 a->setToggleAction(true);
805 if (textEditor->showWithMain())
811 actionViewToggleNoteEditor=a;
812 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
813 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
815 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
816 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
821 void Main::setupModeActions()
823 //QPopupMenu *menu = new QPopupMenu( this );
824 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
826 QToolBar *tb = new QToolBar( this );
827 tb->setLabel( tr ("Modes when using modifiers") );
829 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
830 actionGroupModModes->setExclusive (true);
831 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
832 a->setToggleAction(true);
835 actionModModeColor=a;
837 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
838 a->setToggleAction(true);
842 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
843 a->setToggleAction(true);
849 void Main::setupFlagActions()
851 // Create System Flags
852 systemFlagsDefault = new FlagRowObj ();
853 systemFlagsDefault->setVisibility (false);
854 systemFlagsDefault->setName ("systemFlagsDef");
856 FlagObj *fo = new FlagObj ();
857 fo->load(QPixmap(flag_note_xpm));
859 fo->setToolTip(tr("Note","Systemflag"));
860 systemFlagsDefault->addFlag (fo); // makes deep copy
862 fo->load(QPixmap(flag_url_xpm));
864 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
865 systemFlagsDefault->addFlag (fo);
867 fo->load(QPixmap(flag_vymlink_xpm));
868 fo->setName("vymLink");
869 fo->setToolTip(tr("Link to another vym map","Systemflag"));
870 systemFlagsDefault->addFlag (fo);
872 fo->load(QPixmap(flag_scrolled_right_xpm));
873 fo->setName("scrolledright");
874 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
875 systemFlagsDefault->addFlag (fo);
877 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
878 fo->setName("tmpUnscrolledright");
879 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
880 systemFlagsDefault->addFlag (fo);
882 // Create Standard Flags
883 standardFlagsDefault = new FlagRowObj ();
884 standardFlagsDefault->setVisibility (false);
885 standardFlagsDefault->setName ("standardFlagsDef");
887 fo->load(QPixmap(flag_exclamationmark_xpm));
888 fo->setName ("exclamationmark");
889 fo->setGroup("standard-mark");
890 fo->setToolTip(tr("Take care!","Standardflag"));
891 standardFlagsDefault->addFlag (fo); // makes deep copy
893 fo->load(QPixmap(flag_questionmark_xpm));
894 fo->setName("questionmark");
895 fo->setGroup("standard-mark");
896 fo->setToolTip(tr("Really?","Standardflag"));
897 standardFlagsDefault->addFlag (fo);
899 fo->load(QPixmap(flag_hook_green_xpm));
900 fo->setName("hook-green");
901 fo->setGroup("standard-hook");
902 fo->setToolTip(tr("ok!","Standardflag"));
903 standardFlagsDefault->addFlag (fo);
905 fo->load(QPixmap(flag_cross_red_xpm));
906 fo->setName("cross-red");
907 fo->setGroup("standard-hook");
908 fo->setToolTip(tr("Not ok!","Standardflag"));
909 standardFlagsDefault->addFlag (fo);
911 fo->load(QPixmap(flag_stopsign_xpm));
912 fo->setName("stopsign");
913 fo->setToolTip(tr("This won't work!","Standardflag"));
914 standardFlagsDefault->addFlag (fo);
916 fo->load(QPixmap(flag_smiley_good_xpm));
917 fo->setName("smiley-good");
918 fo->setGroup("standard-smiley");
919 fo->setToolTip(tr("Good","Standardflag"));
920 standardFlagsDefault->addFlag (fo);
922 fo->load(QPixmap(flag_smiley_sad_xpm));
923 fo->setName("smiley-sad");
924 fo->setGroup("standard-smiley");
925 fo->setToolTip(tr("Bad","Standardflag"));
926 standardFlagsDefault->addFlag (fo);
928 fo->load(QPixmap(flag_clock_xpm));
929 fo->setName("clock");
930 fo->setToolTip(tr("Time critical","Standardflag"));
931 standardFlagsDefault->addFlag (fo);
933 fo->load(QPixmap(flag_lamp_xpm));
935 fo->setToolTip(tr("Idea!","Standardflag"));
936 standardFlagsDefault->addFlag (fo);
938 fo->load(QPixmap(flag_arrow_up_xpm));
939 fo->setName("arrow-up");
940 fo->setGroup("standard-arrow");
941 fo->setToolTip(tr("Important","Standardflag"));
942 standardFlagsDefault->addFlag (fo);
944 fo->load(QPixmap(flag_arrow_down_xpm));
945 fo->setName("arrow-down");
946 fo->setGroup("standard-arrow");
947 fo->setToolTip(tr("Unimportant","Standardflag"));
948 standardFlagsDefault->addFlag (fo);
950 fo->load(QPixmap(flag_thumb_up_xpm));
951 fo->setName("thumb-up");
952 fo->setGroup("standard-thumb");
953 fo->setToolTip(tr("I like this","Standardflag"));
954 standardFlagsDefault->addFlag (fo);
956 fo->load(QPixmap(flag_thumb_down_xpm));
957 fo->setName("thumb-down");
958 fo->setGroup("standard-thumb");
959 fo->setToolTip(tr("I like this","Standardflag"));
960 fo->setToolTip(tr("I do not like this","Standardflag"));
961 standardFlagsDefault->addFlag (fo);
963 fo->load(QPixmap(flag_heart_xpm));
964 fo->setName("heart");
965 fo->setToolTip(tr("I just love... ","Standardflag"));
966 standardFlagsDefault->addFlag (fo);
968 fo->load(QPixmap(flag_flash_xpm));
969 fo->setName("flash");
970 fo->setToolTip(tr("Dangerous","Standardflag"));
971 standardFlagsDefault->addFlag (fo);
973 fo->load(QPixmap(flag_lifebelt_xpm));
974 fo->setName("lifebelt");
975 fo->setToolTip(tr("This will help","Standardflag"));
976 standardFlagsDefault->addFlag (fo);
979 standardFlagsDefault->makeToolbar(this, "Standard Flags");
983 void Main::setupSettingsActions()
985 QPopupMenu *menu = new QPopupMenu( this );
986 menuBar()->insertItem( tr( "&Settings" ), menu );
991 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
992 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
995 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
996 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
999 menu->insertSeparator();
1000 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1001 a->setToggleAction(true);
1002 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1004 actionSettingsAutoedit=a;
1006 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1007 a->setToggleAction(true);
1008 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1010 actionSettingsAutoselectHeading=a;
1012 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1013 a->setToggleAction(true);
1014 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1016 actionSettingsAutoselectText=a;
1018 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1019 a->setToggleAction(true);
1020 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1022 actionSettingsPasteNewHeading=a;
1024 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1025 a->setToggleAction(true);
1026 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1028 actionSettingsUseDelKey=a;
1030 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1031 a->setToggleAction(true);
1032 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1034 actionSettingsUseFlagGroups=a;
1038 void Main::setupTestActions()
1040 QPopupMenu *menu = new QPopupMenu( this );
1041 menuBar()->insertItem( tr( "&Test" ), menu );
1044 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1045 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1050 void Main::setupHelpActions()
1052 QPopupMenu *menu = new QPopupMenu( this );
1053 menuBar()->insertItem( tr( "&Help" ), menu );
1056 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1057 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1060 a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
1061 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1064 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1065 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1070 void Main::setupContextMenus()
1074 // Context Menu for branch or mapcenter
1075 branchContextMenu =new QPopupMenu (this);
1078 branchAddContextMenu =new QPopupMenu (this);
1079 actionEditPaste->addTo ( branchAddContextMenu );
1080 actionEditAddBranch->addTo ( branchAddContextMenu );
1081 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1082 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1083 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1084 branchAddContextMenu->insertSeparator();
1085 actionEditLoadImage->addTo( branchAddContextMenu );
1086 branchAddContextMenu->insertSeparator();
1087 actionEditImportAdd->addTo ( branchAddContextMenu );
1088 actionEditImportReplace->addTo ( branchAddContextMenu );
1091 branchRemoveContextMenu =new QPopupMenu (this);
1092 actionEditCut->addTo ( branchRemoveContextMenu );
1093 actionEditDelete->addTo ( branchRemoveContextMenu );
1094 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
1095 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1097 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1098 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1100 actionEditSaveBranch->addTo( branchContextMenu );
1102 branchContextMenu->insertSeparator();
1103 actionEditOpenURL->addTo ( branchContextMenu );
1104 actionEditURL->addTo ( branchContextMenu );
1105 actionEditHeading2URL->addTo ( branchContextMenu );
1106 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1108 actionEditBugzilla2URL->addTo( branchContextMenu );
1109 actionEditFATE2URL->addTo( branchContextMenu );
1111 branchContextMenu->insertSeparator();
1112 actionEditOpenVymLink->addTo ( branchContextMenu );
1113 actionEditVymLink->addTo ( branchContextMenu );
1114 actionEditDeleteVymLink->addTo ( branchContextMenu );
1116 branchContextMenu->insertSeparator();
1117 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1119 branchContextMenu->insertSeparator();
1120 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1121 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1122 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1124 // Context Menu for links in a branch menu
1125 // This will be populated "on demand" in MapEditor::updateActions
1126 branchContextMenu->insertSeparator();
1127 branchLinksContextMenu =new QPopupMenu (this);
1128 branchLinksContextMenuDup =new QPopupMenu (this);
1129 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1130 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1132 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1133 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1135 // Context menu for floatimage
1136 floatimageContextMenu =new QPopupMenu (this);
1137 saveImageFormatMenu=new QPopupMenu (this);
1138 exportImageFormatMenu=new QPopupMenu (this);
1140 QStrList fmt = QImage::outputFormats();
1141 for (const char* f = fmt.first(); f; f = fmt.next())
1143 saveImageFormatMenu->insertItem( f );
1144 exportImageFormatMenu->insertItem( f );
1146 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1147 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1148 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1150 floatimageContextMenu->insertSeparator();
1151 actionEditCopy->addTo( floatimageContextMenu );
1152 actionEditCut->addTo( floatimageContextMenu );
1154 floatimageContextMenu->insertSeparator();
1155 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1156 a->setToggleAction(true);
1157 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1158 a->addTo( floatimageContextMenu);
1159 actionEditToggleFloatExport=a;
1161 floatimageContextMenu->insertSeparator();
1162 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1164 // Context menu for exports
1165 exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
1167 a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" +QString("...")), 0, this, "exportASCII" );
1168 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1169 a->addTo( exportMenu );
1171 a = new QAction( tr( "Export as LaTeX (still experimental)" ), QPixmap(), tr( "Export (LaTeX)" +QString("...")), 0, this, "exportLaTeX" );
1172 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1173 a->addTo( exportMenu );
1175 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1177 a = new QAction( tr( "Export as Open Office 1.3.x Presentation (still experimental)" ), QPixmap(), tr( "Export (OO Presentation)" +QString("...")), 0, this, "exportOOPresentation" );
1178 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1179 a->addTo( exportMenu );
1182 a = new QAction( tr( "Export (XML)" ), QPixmap(), tr( "Export (XML)" )+QString("..."), 0, this, "exportXML" );
1183 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1184 a->addTo( exportMenu );
1186 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1188 a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export (HTML)" )+QString("..."), 0, this, "exportHTML");
1189 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1190 a->addTo( exportMenu );
1193 a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" )+QString("..."), ALT + Key_X, this, "exportXHTML" );
1194 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1195 a->addTo( exportMenu );
1198 // Context menu for canvas
1199 canvasContextMenu =new QPopupMenu (this);
1200 actionEditMapInfo->addTo( canvasContextMenu );
1201 canvasContextMenu->insertSeparator();
1202 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1203 canvasContextMenu->insertSeparator();
1204 actionFormatLinkColorHint->addTo( canvasContextMenu );
1205 actionFormatLinkColor->addTo( canvasContextMenu );
1206 actionFormatBackColor->addTo( canvasContextMenu );
1208 // Menu for last opened files
1209 // Read settings initially
1211 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1212 for (int i=1;i<=j;i++)
1214 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1215 if (!s.isEmpty() && j<=maxLastMaps)
1218 setupLastMapsMenu();
1219 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1222 void Main::setupLastMapsMenu()
1224 // Remove double entries
1225 QStringList::Iterator it=lastMaps.begin();
1226 QStringList::Iterator jt;
1227 while (it!=lastMaps.end() )
1231 while (jt!=lastMaps.end() )
1234 jt=lastMaps.remove(jt);
1241 // Limit length of list to maxLastMaps
1242 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1244 // build Menu from lastMaps string list
1245 lastMapsMenu->clear();
1246 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1247 lastMapsMenu->insertItem (*it );
1251 void Main::hideEvent (QHideEvent * )
1253 if (!textEditor->isMinimized() ) textEditor->hide();
1256 void Main::showEvent (QShowEvent * )
1258 if (textEditor->showWithMain()) textEditor->showNormal();
1261 bool Main::reallyWriteDirectory(const QString &dir)
1263 QStringList eList = QDir(dir).entryList();
1264 if (eList.first() ==".") eList.pop_front(); // remove "."
1265 if (eList.first() =="..") eList.pop_front(); // remove "."
1266 if (!eList.isEmpty())
1268 QMessageBox mb( "VYM",
1269 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1270 QMessageBox::Warning,
1272 QMessageBox::Cancel | QMessageBox::Default,
1273 QMessageBox::QMessageBox::NoButton );
1275 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1276 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1279 case QMessageBox::Yes:
1282 case QMessageBox::Cancel:
1290 QString Main::browseDirectory (const QString &caption)
1292 QFileDialog fd(this,caption);
1293 fd.setMode (QFileDialog::DirectoryOnly);
1294 fd.setCaption("VYM - "+caption);
1297 if ( fd.exec() == QDialog::Accepted )
1298 return fd.selectedFile();
1303 MapEditor* Main::currentMapEditor() const
1305 if ( tabWidget->currentPage() &&
1306 tabWidget->currentPage()->inherits( "MapEditor" ) )
1307 return (MapEditor*)tabWidget->currentPage();
1311 //TODO not used now, maybe use this for overview window later
1312 void Main::newView()
1314 // Open a new view... have it delete when closed.
1315 Main *m = new Main(0, 0, WDestructiveClose);
1316 qApp->setMainWidget(m);
1318 qApp->setMainWidget(0);
1321 void Main::editorChanged(QWidget *)
1323 // Unselect all possibly selected objects
1324 // (Important to update note editor)
1327 for (i=0;i<=tabWidget->count() -1;i++)
1330 me=(MapEditor*)tabWidget->page(i);
1333 currentMapEditor()->reselect();
1335 // Update actions to in menus and toolbars according to editor
1336 currentMapEditor()->updateActions();
1339 void Main::fileNew()
1341 QString fn="unnamed";
1342 MapEditor* medit = new MapEditor (tabWidget, true);
1343 tabWidget->addTab (medit,fn);
1344 tabWidget->showPage(medit);
1345 medit->viewport()->setFocus();
1346 // For the very first map we do not have flagrows yet...
1347 medit->select("mc:");
1350 void Main::fileLoad(QString fn, const LoadMode &lmode)
1353 enum errorCode {success,aborted};
1354 errorCode err=success;
1356 // fn is usually the archive, mapfile the file after uncompressing
1359 // Make fn absolute (needed for unzip)
1360 fn=QDir (fn).absPath();
1366 // Check, if map is already loaded
1368 while (i<=tabWidget->count() -1)
1370 me=(MapEditor*)tabWidget->page(i);
1371 if (me->getFilePath() == fn)
1373 // Already there, ask for confirmation
1374 QMessageBox mb( "VYM",
1375 tr("The map %1\nis already opened."
1376 "Opening the same map in multiple editors may lead \n"
1377 "to confusion when finishing working with vym."
1378 "Do you want to").arg(fn),
1379 QMessageBox::Warning,
1380 QMessageBox::Yes | QMessageBox::Default,
1381 QMessageBox::Cancel | QMessageBox::Escape,
1382 QMessageBox::QMessageBox::NoButton);
1383 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1384 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1387 case QMessageBox::Yes:
1389 i=tabWidget->count();
1391 case QMessageBox::Cancel:
1403 if ( !fn.isEmpty() )
1405 me = currentMapEditor();
1406 int tabIndex=tabWidget->currentPageIndex();
1407 // Check first, if mapeditor exists
1408 // If it is not default AND we want a new map,
1409 // create a new mapeditor in a new tab
1410 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1412 me = new MapEditor (tabWidget,true);
1413 tabWidget->addTab (me,fn);
1414 tabIndex=tabWidget->indexOf (me);
1415 tabWidget->setCurrentPage (tabIndex);
1418 // Check, if file exists (important for creating new files
1419 // from command line
1420 if (!QFile(fn).exists() )
1422 QMessageBox mb( "VYM",
1423 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1424 QMessageBox::Question,
1426 QMessageBox::Cancel | QMessageBox::Default,
1427 QMessageBox::QMessageBox::NoButton );
1429 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1430 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1433 case QMessageBox::Yes:
1435 currentMapEditor()->setFilePath(fn);
1436 tabWidget->setTabLabel (currentMapEditor(),
1437 currentMapEditor()->getFileName() );
1438 statusBar()->message( "Created " + fn , statusbarTime );
1441 case QMessageBox::Cancel:
1442 // don't create new map
1443 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1450 //tabWidget->currentPage() won't be NULL here, because of above...
1451 tabWidget->showPage(me);
1452 me->viewport()->setFocus();
1454 // Create temporary directory for packing
1455 char tmpdir1[]="/tmp/vym-XXXXXX";
1456 QString tmpMapDir=mkdtemp(tmpdir1);
1458 // Try to unzip file
1459 Process *zipProc=new Process ();
1460 zipProc->clearArguments();
1461 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1462 zipProc->addArgument ("unzip");
1463 zipProc->addArgument (fn );
1464 zipProc->addArgument ("-d");
1465 zipProc->addArgument (tmpMapDir);
1467 if (!zipProc->start() )
1469 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1470 tr("Couldn't start unzip to decompress data."));
1475 zipProc->waitFinished();
1476 if (!zipProc->normalExit() )
1478 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1479 tr("unzip didn't exit normally") +
1480 zipProc->getErrout() );
1484 if (zipProc->exitStatus()>0)
1486 if (zipProc->exitStatus()==9)
1488 // no zipped file, but maybe .xml or old version? Try again.
1490 me->setZipped(false);
1494 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1495 QString("unzip exit code: %1").arg(zipProc->exitStatus() ) +
1496 zipProc->getErrout() );
1500 { // Uncompressing was successfull,
1501 // load from uncompressed temporary directory
1503 me->setZipped(true);
1506 // Look for mapname.xml
1507 mapfile= fn.left(fn.findRev(".",-1,true));
1508 mapfile=mapfile.section( '/', -1 );
1509 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1510 if (!file.exists() )
1512 // mapname.xml does not exist, well,
1513 // maybe some renamed the mapname.vym file...
1514 // Try to find any .xml in the toplevel
1515 // directory of the .vym file
1516 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1517 if (flist.count()==1)
1519 // Only one entry, take this one
1520 mapfile=tmpMapDir + "/"+flist.first();
1523 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1524 *it=tmpMapDir + "/" + *it;
1525 // TODO Multiple entries, load all (but only the first one into this ME)
1526 //mainWindow->fileLoadFromTmp (flist);
1527 //returnCode=1; // Silently forget this attempt to load
1528 qWarning ("MainWindow::load (fn) multimap found...");
1531 if (flist.isEmpty() )
1533 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1534 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1537 } //file doesn't exist
1539 mapfile=file.name();
1540 } // Uncompressing successfull
1545 // Save existing filename
1546 QString fn_org=me->getFilePath();
1548 // Finally load map into mapEditor
1549 me->setFilePath (mapfile,fn);
1550 if (me->load(mapfile,lmode))
1553 // Restore old (maybe empty) filepath, if this is an import
1555 me->setFilePath (fn_org);
1558 removeDir (QDir(tmpMapDir));
1565 me->setFilePath (fn);
1566 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1567 lastMaps.prepend(me->getFilePath() );
1568 setupLastMapsMenu();
1569 actionFilePrint->setEnabled (true);
1571 statusBar()->message( "Loaded " + fn, statusbarTime );
1581 statusBar()->message( "Could not load " + fn, statusbarTime );
1585 void Main::fileLoad(const LoadMode &lmode)
1587 QFileDialog *fd=new QFileDialog( this);
1588 if (!lastFileDir.isEmpty())
1589 fd->setDir (lastFileDir);
1590 fd->addFilter ("XML (*.xml)");
1591 fd->addFilter ("VYM map (*.vym *.vyp)");
1595 fd->setCaption(tr("Load vym map"));
1598 fd->setCaption(tr("Import: Add vym map to selection"));
1601 fd->setCaption(tr("Import: Replace selection with vym map"));
1607 if ( fd->exec() == QDialog::Accepted )
1609 lastFileDir=fd->dirPath();
1610 fn = fd->selectedFile();
1611 fileLoad(fn, lmode);
1615 void Main::fileLoad()
1620 void Main::fileLoadLast(int i)
1622 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1625 void Main::fileSave(const SaveMode &savemode)
1627 // tmp dir for zipping
1631 enum errorCode {success,aborted};
1632 errorCode err=success;
1634 QString safeFilePath;
1636 bool saveZipped=currentMapEditor()->saveZipped();
1638 MapEditor * me=currentMapEditor();
1641 QString fn=me->getFilePath();
1642 // filename=unnamed, filepath="" in constructor...
1643 if ( !fn.isEmpty() )
1645 // We have a filepath, go on saving
1646 // First remove existing file, we
1647 // don't want to add to old zip archives
1651 QMessageBox::warning( 0, tr( "Save Error" ),
1652 fn+ tr("\ncould not be removed before saving"));
1654 // Look, if we should zip the data:
1657 QMessageBox mb( "VYM",
1658 tr("The map %1\ndid not use the compressed "
1659 "vym file format.\nWriting it uncompressed will also write images \n"
1660 "and flags and thus may overwrite files in the "
1661 "given directory\n\nDo you want to write the map").arg(fn),
1662 QMessageBox::Warning,
1663 QMessageBox::Yes | QMessageBox::Default,
1665 QMessageBox::Cancel | QMessageBox::Escape);
1666 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1667 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1668 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1671 case QMessageBox::Yes:
1672 // save compressed (default file format)
1675 case QMessageBox::No:
1676 // save uncompressed
1679 case QMessageBox::Cancel:
1688 char tmpdir1[]="/tmp/vym-XXXXXX";
1689 tmpMapDir=mkdtemp(tmpdir1);
1691 safeFilePath=me->getFilePath();
1692 me->setFilePath (tmpMapDir+"/"+
1693 me->getMapName()+ ".xml",
1695 me->save (savemode);
1696 me->setFilePath (safeFilePath);
1698 zipDir (tmpMapDir,fn);
1703 safeFilePath=me->getFilePath();
1704 me->setFilePath (fn, safeFilePath);
1705 me->save (savemode);
1706 me->setFilePath (safeFilePath);
1708 } // filepath available
1711 // We have no filepath yet,
1712 // call fileSaveAs() now, this will call fileSave()
1714 fileSaveAs(savemode);
1718 if (me->saveZipped())
1721 removeDir (QDir(tmpMapDir));
1726 statusBar()->message(
1727 tr("Saved %1").arg(me->getFilePath()),
1729 lastMaps.prepend(me->getFilePath() );
1730 setupLastMapsMenu();
1732 statusBar()->message(
1733 tr("Couldn't save ").arg(me->getFilePath()),
1737 void Main::fileSave()
1739 fileSave (CompleteMap);
1742 void Main::fileSaveAs(const SaveMode& savemode)
1747 if (currentMapEditor())
1749 if (savemode==CompleteMap)
1750 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1752 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1753 if ( !fn.isEmpty() )
1755 // Check for existing file
1756 if (QFile (fn).exists())
1758 QMessageBox mb( "VYM",
1759 tr("The file %1\nexists already. Do you want to").arg(fn),
1760 QMessageBox::Warning,
1761 QMessageBox::Yes | QMessageBox::Default,
1762 QMessageBox::Cancel | QMessageBox::Escape,
1763 QMessageBox::QMessageBox::NoButton);
1764 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1765 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1768 case QMessageBox::Yes:
1771 case QMessageBox::Cancel:
1778 // New file, add extension to filename, if missing
1779 // This is always .vym or .vyp, depending on savemode
1780 if (savemode==CompleteMap)
1782 if (!fn.contains (".vym") && !fn.contains (".xml"))
1786 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1795 currentMapEditor()->setFilePath(fn);
1799 if (savemode==CompleteMap)
1800 tabWidget->setTabLabel (currentMapEditor(),
1801 currentMapEditor()->getFileName() );
1807 void Main::fileSaveAs()
1809 fileSaveAs (CompleteMap);
1812 void Main::fileImportDir()
1814 if (currentMapEditor())
1815 currentMapEditor()->importDir();
1818 void Main::fileExportXML()
1820 if (currentMapEditor())
1822 QString dir=browseDirectory(tr("Export XML to directory"));
1823 if (dir !="" && reallyWriteDirectory(dir) )
1824 currentMapEditor()->exportXML(dir);
1828 void Main::fileExportHTML()
1830 if (currentMapEditor())
1832 ExportHTMLDialog dia(this);
1834 if (dia.exec()==QDialog::Accepted)
1836 QString dir=dia.getDir();
1837 if (reallyWriteDirectory(dir) )
1839 currentMapEditor()->exportXML (dia.getDir() );
1840 dia.doExport(currentMapEditor()->getMapName() );
1846 void Main::fileExportXHTML()
1849 if (currentMapEditor())
1851 ExportXHTMLDialog dia(this);
1852 dia.setFilePath (currentMapEditor()->getFilePath() );
1853 dia.setMapName (currentMapEditor()->getMapName() );
1856 if (dia.exec()==QDialog::Accepted)
1858 QString dir=dia.getDir();
1859 // Check, if warnings should be used before overwriting
1860 // the output directory
1863 ok=reallyWriteDirectory(dir);
1869 currentMapEditor()->exportXML (dia.getDir() );
1870 dia.doExport(currentMapEditor()->getMapName() );
1871 if (dia.hasChanged())
1872 currentMapEditor()->setChanged();
1878 void Main::fileExportImage(int item)
1880 if (currentMapEditor())
1882 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1884 if ( !fn.isEmpty() )
1886 currentMapEditor()->exportImage(fn,item);
1888 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1893 void Main::fileExportASCII()
1895 if (currentMapEditor())
1896 currentMapEditor()->exportASCII();
1899 void Main::fileExportLaTeX()
1901 if (currentMapEditor())
1902 currentMapEditor()->exportLaTeX();
1905 void Main::fileExportOOPresentation()
1907 if (currentMapEditor())
1908 currentMapEditor()->exportOOPresentation();
1911 void Main::fileCloseMap()
1913 if (currentMapEditor())
1915 if (currentMapEditor()->hasChanged())
1917 QMessageBox mb( "VYM",
1918 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1919 QMessageBox::Warning,
1920 QMessageBox::Yes | QMessageBox::Default,
1922 QMessageBox::Cancel | QMessageBox::Escape );
1923 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1924 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1927 case QMessageBox::Yes:
1929 fileSave(CompleteMap);
1931 case QMessageBox::No:
1932 // close without saving
1934 case QMessageBox::Cancel:
1939 currentMapEditor()->closeMap();
1940 tabWidget->removePage(currentMapEditor());
1941 if (tabWidget->count()==0)
1942 actionFilePrint->setEnabled (false);
1946 void Main::filePrint()
1948 if (currentMapEditor())
1949 currentMapEditor()->print();
1952 void Main::fileExitVYM()
1954 // Check if one or more editors have changed
1957 for (i=0;i<=tabWidget->count() -1;i++)
1960 me=(MapEditor*)tabWidget->page(i);
1962 // If something changed, ask what to do
1963 if (me->isUnsaved())
1965 tabWidget->setCurrentPage(i);
1966 QMessageBox mb( "VYM",
1967 tr("This map is not saved yet. Do you want to"),
1968 QMessageBox::Warning,
1969 QMessageBox::Yes | QMessageBox::Default,
1971 QMessageBox::Cancel | QMessageBox::Escape );
1972 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1973 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1975 // Call undocumented function: setActiveWindow is only
1976 // possible, if widget is visible. This depends on
1978 #if defined(Q_OS_LINUX)
1979 qt_wait_for_window_manager( this);
1981 mb.setActiveWindow();
1982 switch( mb.exec() ) {
1983 case QMessageBox::Yes:
1984 // save (the changed editors) and exit
1985 fileSave(CompleteMap);
1987 case QMessageBox::No:
1988 // exit without saving
1990 case QMessageBox::Cancel:
1991 // don't save and don't exit
1995 } // loop over all MEs
1999 void Main::editUndo()
2001 if (currentMapEditor())
2002 currentMapEditor()->undo();
2005 void Main::editRedo()
2007 if (currentMapEditor())
2008 currentMapEditor()->redo();
2011 void Main::editCopy()
2013 if (currentMapEditor())
2014 currentMapEditor()->copy();
2017 void Main::editPaste()
2019 if (currentMapEditor())
2020 currentMapEditor()->paste();
2023 void Main::editCut()
2025 if (currentMapEditor())
2026 currentMapEditor()->cut();
2029 void Main::editOpenFindWindow()
2031 findWindow->popup();
2032 findWindow->raise();
2034 // Call undocumented function: setActiveWindow is only
2035 // possible, if widget is visible. This depends on
2037 #if defined(Q_OS_LINUX)
2038 qt_wait_for_window_manager( this);
2040 findWindow->setActiveWindow();
2043 void Main::editFind(QString s)
2046 BranchObj *bo=currentMapEditor()->findText(s, cs);
2049 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2052 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2053 tr("No matches found for <b>%1</b>").arg(s));
2057 void Main::editFindChanged()
2058 { // Notify editor, to abort the current find process
2059 currentMapEditor()->findReset();
2062 void Main::editOpenURL()
2064 if (currentMapEditor())
2065 currentMapEditor()->openURL();
2068 void Main::editURL()
2070 if (currentMapEditor())
2071 currentMapEditor()->editURL();
2074 void Main::editHeading2URL()
2076 if (currentMapEditor())
2077 currentMapEditor()->editHeading2URL();
2080 void Main::editBugzilla2URL()
2082 if (currentMapEditor())
2083 currentMapEditor()->editBugzilla2URL();
2086 void Main::editFATE2URL()
2088 if (currentMapEditor())
2089 currentMapEditor()->editFATE2URL();
2092 void Main::editOpenVymLink()
2094 // Get current path to map
2095 QString currentVymLink;
2096 if (currentMapEditor())
2098 currentVymLink=currentMapEditor()->getVymLink();
2099 // compare path with already loaded maps
2103 for (i=0;i<=tabWidget->count() -1;i++)
2105 me=(MapEditor*)tabWidget->page(i);
2106 if (currentVymLink==me->getFilePath() )
2115 if (!QFile(currentVymLink).exists() )
2116 QMessageBox::critical( 0, tr( "Critical Error" ),
2117 tr("Couldn't open map %1").arg(currentVymLink));
2120 fileLoad (currentVymLink, NewMap);
2121 tabWidget->setCurrentPage (tabWidget->count()-1);
2124 // Go to tab containing the map
2125 tabWidget->setCurrentPage (index);
2129 void Main::editVymLink()
2131 if (currentMapEditor())
2132 currentMapEditor()->editVymLink();
2135 void Main::editDeleteVymLink()
2137 if (currentMapEditor())
2138 currentMapEditor()->deleteVymLink();
2141 void Main::editMapInfo()
2143 if (currentMapEditor())
2144 currentMapEditor()->editMapInfo();
2147 void Main::editMoveUp()
2149 if (currentMapEditor())
2150 currentMapEditor()->moveBranchUp();
2153 void Main::editMoveDown()
2155 if (currentMapEditor())
2156 currentMapEditor()->moveBranchDown();
2159 void Main::editToggleScroll()
2161 if (currentMapEditor())
2163 currentMapEditor()->toggleScroll();
2167 void Main::editUnScrollAll()
2169 if (currentMapEditor())
2171 currentMapEditor()->unScrollAll();
2175 void Main::editHeading()
2177 if (currentMapEditor())
2178 currentMapEditor()->editHeading();
2181 void Main::editNewBranch()
2183 if (currentMapEditor())
2184 currentMapEditor()->addNewBranch(0);
2187 void Main::editNewBranchHere()
2189 if (currentMapEditor())
2190 currentMapEditor()->addNewBranchHere();
2193 void Main::editNewBranchAbove()
2195 if (currentMapEditor())
2196 currentMapEditor()->addNewBranch(-1);
2199 void Main::editNewBranchBelow()
2201 if (currentMapEditor())
2202 currentMapEditor()->addNewBranch(1);
2205 void Main::editImportAdd()
2207 fileLoad (ImportAdd);
2210 void Main::editImportReplace()
2212 fileLoad (ImportReplace);
2215 void Main::editSaveBranch()
2217 fileSaveAs (PartOfMap);
2220 void Main::editRemoveBranchHere()
2222 if (currentMapEditor())
2223 currentMapEditor()->removeBranchHere();
2226 void Main::editRemoveChilds()
2228 if (currentMapEditor())
2229 currentMapEditor()->removeChilds();
2232 void Main::editDeleteSelection()
2234 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2235 currentMapEditor()->deleteSelection();
2238 void Main::editUpperBranch()
2240 if (currentMapEditor())
2241 currentMapEditor()->selectUpperBranch();
2244 void Main::editLowerBranch()
2246 if (currentMapEditor())
2247 currentMapEditor()->selectLowerBranch();
2250 void Main::editLeftBranch()
2252 if (currentMapEditor())
2253 currentMapEditor()->selectLeftBranch();
2256 void Main::editRightBranch()
2258 if (currentMapEditor())
2259 currentMapEditor()->selectRightBranch();
2262 void Main::editFirstBranch()
2264 if (currentMapEditor())
2265 currentMapEditor()->selectFirstBranch();
2268 void Main::editLastBranch()
2270 if (currentMapEditor())
2271 currentMapEditor()->selectLastBranch();
2274 void Main::editLoadImage()
2276 if (currentMapEditor())
2277 currentMapEditor()->loadFloatImage();
2280 void Main::editSaveImage(int item)
2282 if (currentMapEditor())
2283 currentMapEditor()->saveFloatImage(item);
2286 void Main::editToggleFloatExport()
2288 if (currentMapEditor())
2289 currentMapEditor()->toggleFloatExport();
2292 void Main::editFollowXLink(int item)
2294 if (currentMapEditor())
2295 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2298 void Main::editEditXLink(int item)
2300 if (currentMapEditor())
2301 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2304 void Main::formatSelectColor()
2306 if (currentMapEditor())
2308 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2309 if ( !col.isValid() ) return;
2310 currentMapEditor()->setColor( col );
2311 colorChanged( col );
2315 void Main::formatPickColor()
2317 if (currentMapEditor())
2318 colorChanged( currentMapEditor()->pickColor() );
2321 void Main::colorChanged(QColor c)
2323 QPixmap pix( 16, 16 );
2325 actionFormatColor->setIconSet( pix );
2328 void Main::formatColorItem()
2330 if (currentMapEditor())
2331 currentMapEditor()->colorItem();
2334 void Main::formatColorBranch()
2336 if (currentMapEditor())
2337 currentMapEditor()->colorBranch();
2340 void Main::formatLinkStyleLine()
2342 if (currentMapEditor())
2343 currentMapEditor()->setLinkStyle(StyleLine);
2346 void Main::formatLinkStyleParabel()
2348 if (currentMapEditor())
2349 currentMapEditor()->setLinkStyle(StyleParabel);
2352 void Main::formatLinkStylePolyLine()
2354 if (currentMapEditor())
2355 currentMapEditor()->setLinkStyle(StylePolyLine);
2358 void Main::formatLinkStylePolyParabel()
2360 if (currentMapEditor())
2361 currentMapEditor()->setLinkStyle(StylePolyParabel);
2364 void Main::formatSelectBackColor()
2366 if (currentMapEditor())
2367 currentMapEditor()->selectBackgroundColor();
2370 void Main::formatSelectLinkColor()
2372 if (currentMapEditor())
2373 currentMapEditor()->selectLinkColor();
2376 void Main::formatToggleLinkColorHint()
2378 currentMapEditor()->toggleLinkColorHint();
2381 void Main::formatFrameNone()
2383 if (currentMapEditor())
2384 currentMapEditor()->setFrame(NoFrame);
2387 void Main::formatFrameRectangle()
2389 if (currentMapEditor())
2390 currentMapEditor()->setFrame(Rectangle);
2393 void Main::formatIncludeImagesVer()
2395 if (currentMapEditor())
2396 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2399 void Main::formatIncludeImagesHor()
2401 if (currentMapEditor())
2402 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2405 void Main::formatHideLinkUnselected()
2407 if (currentMapEditor())
2408 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2411 void Main::viewZoomReset()
2413 if (currentMapEditor())
2417 currentMapEditor()->setWorldMatrix( m );
2418 currentMapEditor()->setViewCenter();
2419 currentMapEditor()->adjustCanvasSize();
2423 void Main::viewZoomIn()
2425 if (currentMapEditor())
2427 QWMatrix m = currentMapEditor()->worldMatrix();
2428 m.scale( 1.25, 1.25 );
2429 currentMapEditor()->setWorldMatrix( m );
2430 currentMapEditor()->setViewCenter();
2431 currentMapEditor()->adjustCanvasSize();
2435 void Main::viewZoomOut()
2437 if (currentMapEditor())
2439 QWMatrix m = currentMapEditor()->worldMatrix();
2440 m.scale( 0.8, 0.8 );
2441 currentMapEditor()->setWorldMatrix( m );
2442 currentMapEditor()->setViewCenter();
2443 currentMapEditor()->adjustCanvasSize();
2447 void Main::modModeColor()
2451 void Main::modModeLink()
2455 bool Main::settingsPDF()
2457 // Default browser is set in constructor
2459 QString text = QInputDialog::getText(
2460 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2461 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2463 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2468 bool Main::settingsURL()
2470 // Default browser is set in constructor
2472 QString text = QInputDialog::getText(
2473 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2474 settings.readEntry("/vym/mainwindow/readerURL")
2477 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2481 void Main::windowToggleNoteEditor()
2483 if (textEditor->showWithMain() )
2484 windowHideNoteEditor();
2486 windowShowNoteEditor();
2489 void Main::updateNoteFlag()
2491 if (currentMapEditor())
2492 currentMapEditor()->updateNoteFlag();
2495 void Main::windowShowNoteEditor()
2497 textEditor->setShowWithMain(true);
2499 actionViewToggleNoteEditor->setOn (true);
2502 void Main::windowHideNoteEditor()
2504 textEditor->setShowWithMain(false);
2506 actionViewToggleNoteEditor->setOn (false);
2509 void Main::windowNextEditor()
2511 if (tabWidget->currentPageIndex() < tabWidget->count())
2512 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2515 void Main::windowPreviousEditor()
2517 if (tabWidget->currentPageIndex() >0)
2518 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2521 void Main::standardFlagChanged()
2523 currentMapEditor()->toggleStandardFlag(sender()->name());
2526 void Main::testFunction()
2528 //textEditor->stackUnder(this);
2529 currentMapEditor()->testFunction();
2532 void Main::helpDoc()
2535 #if defined(Q_OS_MACX)
2536 docpath="./vym.app/Contents/vym.pdf";
2538 // default path in SUSE LINUX
2539 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2542 if (!QFile (docpath).exists() )
2544 // relative path for easy testing in tarball
2545 docpath="doc/vym.pdf";
2546 if (!QFile (docpath).exists() )
2548 // relative path for testing while still writing vym.tex
2549 docpath="doc/tex/vym.pdf";
2550 if (!QFile (docpath).exists() )
2552 // Try yet another one for Knoppix
2553 docpath="/usr/share/doc/packages/vym/vym.pdf";
2554 if (!QFile (docpath).exists() )
2556 QMessageBox::critical(0,
2557 tr("Critcal error"),
2558 tr("Couldn't find the documentation\n"
2559 "vym.pdf in various places."));
2566 Process *pdfProc = new Process();
2567 pdfProc->clearArguments();
2568 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2569 pdfProc->addArgument( docpath);
2571 if ( !pdfProc->start() )
2574 QMessageBox::critical(0,
2575 tr("Critcal error"),
2576 tr("Couldn't find a viewer to read vym.pdf.\n"
2577 "Please use Settings->")+tr("Set application to open pdf files"));
2583 void Main::helpAbout()
2586 ad.setName ("aboutwindow");
2587 ad.setMinimumSize(500,500);
2588 ad.resize (QSize (500,500));
2592 void Main::helpAboutQT()
2594 QMessageBox::aboutQt( this, "Qt Application Example" );