1 #include "mainwindow.h"
3 #include <qstatusbar.h>
4 #include <qmessagebox.h>
6 #include <qapplication.h>
10 #include <qfiledialog.h>
12 #include <qcolordialog.h>
14 #include <qinputdialog.h>
15 //#include <qdatetime.h> // for random seed
22 #include "icons/filenew.xpm"
23 #include "icons/fileopen.xpm"
24 #include "icons/filesave.xpm"
25 #include "icons/fileprint.xpm"
26 #include "icons/editundo.xpm"
27 #include "icons/editredo.xpm"
28 #include "icons/editcopy.xpm"
29 #include "icons/editcut.xpm"
30 #include "icons/editpaste.xpm"
31 #include "icons/editmoveup.xpm"
32 #include "icons/editmovedown.xpm"
33 #include "icons/formatcoloritem.xpm"
34 #include "icons/formatcolorbranch.xpm"
35 #include "icons/formatcolorpicker.xpm"
36 #include "icons/viewzoomreset.xpm"
37 #include "icons/viewzoomin.xpm"
38 #include "icons/viewzoomout.xpm"
39 #include "icons/modecolor.xpm"
40 #include "icons/modelink.xpm"
41 #include "icons/modecopy.xpm"
42 #include "icons/flag-questionmark.xpm"
43 #include "icons/flag-exclamationmark.xpm"
44 #include "icons/flag-hook-green.xpm"
45 #include "icons/flag-cross-red.xpm"
46 #include "icons/flag-stopsign.xpm"
47 #include "icons/flag-smiley-good.xpm"
48 #include "icons/flag-smiley-sad.xpm"
49 #include "icons/flag-clock.xpm"
50 #include "icons/flag-lamp.xpm"
51 #include "icons/flag-arrow-up.xpm"
52 #include "icons/flag-arrow-down.xpm"
53 #include "icons/flag-thumb-up.xpm"
54 #include "icons/flag-thumb-down.xpm"
55 #include "icons/flag-heart.xpm"
56 #include "icons/flag-flash.xpm"
57 #include "icons/flag-lifebelt.xpm"
58 #include "icons/flag-note.xpm"
59 #include "icons/flag-url.xpm"
60 #include "icons/flag-vymlink.xpm"
61 #include "icons/flag-scrolled-right.xpm"
62 #include "icons/flag-tmpUnscrolled-right.xpm"
64 #include "aboutdialog.h"
65 #include "exporthtmldialog.h"
66 #include "exportoofiledialog.h"
67 #include "exportxhtmldialog.h"
69 #include "flagrowobj.h"
71 #include "mapeditor.h"
76 #include "showtextdialog.h"
77 #include "texteditor.h"
80 extern TextEditor *textEditor;
81 extern Main *mainWindow;
82 extern QString tmpVymDir;
83 extern QString clipboardDir;
84 extern bool clipboardEmpty;
85 extern int statusbarTime;
86 extern FlagRowObj* standardFlagsDefault;
87 extern FlagRowObj* systemFlagsDefault;
89 extern QPtrList <QAction> actionListBranches;
91 extern QAction* actionFileSave;
92 extern QAction* actionFilePrint;
93 extern QAction* actionEditUndo;
94 extern QAction* actionEditRedo;
95 extern QAction *actionEditCopy;
96 extern QAction *actionEditCut;
97 extern QAction *actionEditPaste;
98 extern QAction *actionEditMoveUp;
99 extern QAction *actionEditMoveDown;
100 extern QAction *actionEditToggleScroll;
101 extern QAction* actionEditOpenURL;
102 extern QAction* actionEditURL;
103 extern QAction* actionEditHeading2URL;
104 extern QAction* actionEditBugzilla2URL;
105 extern QAction* actionEditFATE2URL;
106 extern QAction *actionEditOpenVymLink;
107 extern QAction *actionEditVymLink;
108 extern QAction *actionEditDeleteVymLink;
109 extern QAction *actionEditMapInfo;
110 extern QAction *actionEditHeading;
111 extern QAction *actionEditDelete;
112 extern QAction *actionEditAddBranch;
113 extern QAction *actionEditAddBranchHere;
114 extern QAction *actionEditAddBranchAbove;
115 extern QAction *actionEditAddBranchBelow;
116 extern QAction *actionEditRemoveBranchHere;
117 extern QAction *actionEditRemoveChilds;
118 extern QAction *actionEditImportAdd;
119 extern QAction *actionEditImportReplace;
120 extern QAction *actionEditSaveBranch;
121 extern QAction *actionEditSelectFirst;
122 extern QAction *actionEditSelectLast;
123 extern QAction *actionEditLoadImage;
124 extern QAction *actionEditToggleFloatExport;
126 extern QAction* actionFormatColor;
127 extern QAction* actionFormatPickColor;
128 extern QAction* actionFormatColorBranch;
129 extern QAction* actionFormatColorSubtree;
130 extern QAction* actionFormatLinkColorHint;
131 extern QAction* actionFormatBackColor;
132 extern QAction* actionFormatLinkColor;
133 extern QAction *actionFormatIncludeImagesVer;
134 extern QAction *actionFormatIncludeImagesHor;
136 extern QActionGroup* actionGroupModModes;
137 extern QAction* actionModModeColor;
138 extern QAction* actionModModeLink;
139 extern QAction* actionModModeCopy;
141 extern QActionGroup *actionGroupFormatFrameTypes;
142 extern QAction *actionFormatFrameNone;
143 extern QAction *actionFormatFrameRectangle;
145 extern QActionGroup *actionGroupFormatLinkStyles;
146 extern QAction *actionFormatLinkStyleLine;
147 extern QAction *actionFormatLinkStyleParabel;
148 extern QAction *actionFormatLinkStylePolyLine;
149 extern QAction *actionFormatLinkStylePolyParabel;
150 extern QAction *actionFormatHideLinkUnselected;
152 extern QAction *actionViewToggleNoteEditor;
154 extern QAction* actionSettingsAutoedit;
155 extern QAction* actionSettingsAutoselectHeading;
156 extern QAction* actionSettingsAutoselectHeading;
157 extern QAction* actionSettingsAutoselectText;
158 extern QAction* actionSettingsPasteNewHeading;
159 extern QAction* actionSettingsUseDelKey;
160 extern QAction* actionSettingsUseFlagGroups;
162 extern QPopupMenu* branchContextMenu;
163 extern QPopupMenu* branchAddContextMenu;
164 extern QPopupMenu* branchRemoveContextMenu;
165 extern QPopupMenu* branchLinksContextMenu;
166 extern QPopupMenu* branchLinksContextMenuDup;
167 extern QPopupMenu* floatimageContextMenu;
168 extern QPopupMenu* saveImageFormatMenu;
169 extern QPopupMenu* canvasContextMenu;
170 extern QPopupMenu* lastMapsMenu;
171 extern QPopupMenu* importMenu;
172 extern QPopupMenu* exportMenu;
173 extern QPopupMenu* exportImageFormatMenu;
176 extern Settings settings;
177 extern Options options;
179 #if defined(Q_OS_LINUX)
180 extern void qt_wait_for_window_manager( QWidget* w );
183 Main::Main(QWidget* parent, const char* name, WFlags f) :
184 QMainWindow(parent,name,f)
188 setCaption ("VYM - View Your Mind");
190 // Load window settings
191 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
192 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
193 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
194 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
197 // Create unique temporary directory
198 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
200 // Create direcctory for clipboard
201 clipboardDir=tmpVymDir+"/clipboard";
202 QDir d(clipboardDir);
203 d.mkdir (clipboardDir,true);
204 makeSubDirs (clipboardDir);
207 // FIXME not used currently
208 // Set random seed (random used for object IDs)
209 // QTime t = QTime::currentTime(); // set random seed
210 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
213 // Initialize some settings, which are platform dependant
216 // application to open URLs
217 p="/vym/mainwindow/readerURL";
218 #if defined(Q_OS_LINUX)
219 s=settings.readEntry (p,"konqueror");
221 #if defined(Q_OS_MACX)
222 s=settings.readEntry (p,"/usr/bin/open");
224 s=settings.readEntry (p,"mozilla");
227 settings.writeEntry( p,s);
229 // application to open PDFs
230 p="/vym/mainwindow/readerPDF";
231 #if defined(Q_OS_LINUX)
232 s=settings.readEntry (p,"acroread");
234 #if defined(Q_OS_MACX)
235 s=settings.readEntry (p,"/usr/bin/open");
237 s=settings.readEntry (p,"acroread");
240 settings.writeEntry( p,s);
245 // Create tab widget which holds the maps
246 tabWidget= new QTabWidget (this);
247 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
248 this, SLOT( editorChanged( QWidget * ) ) );
250 setCentralWidget(tabWidget);
254 setupFormatActions();
258 setupSettingsActions();
260 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
263 // After menu is created, we can enable some actions
264 actionFilePrint->setEnabled (true);
269 // Initialize Find window
270 findWindow=new FindWindow(NULL,"findwindow");
271 connect (findWindow, SIGNAL( findButton(QString) ),
272 this, SLOT(editFind(QString) ) );
273 connect (findWindow, SIGNAL( somethingChanged() ),
274 this, SLOT(editFindChanged() ) );
276 // Connect TextEditor, so that we can update flags if text changes
277 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
285 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
286 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
287 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
288 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
290 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
291 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
293 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
294 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
295 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
296 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
297 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
298 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
301 int maps=lastMaps.count();
302 settings.writeEntry( "/vym/lastMaps/number",maps );
303 for (int i=1;i<=maps;i++)
305 QStringList::Iterator it = lastMaps.at(i-1);
306 s=QString("/vym/lastMaps/map-%1").arg(i);
307 if (!s.isEmpty() && i<=maxLastMaps)
308 settings.writeEntry (s, *it);
312 // To make the texteditor save its settings, call the destructor
315 // Remove temporary directory
316 removeDir (QDir(tmpVymDir));
319 void Main::loadCmdLine()
321 /* TODO draw some kind of splashscreen while loading...
327 QStringList flist=options.getFileList();
328 QStringList::Iterator it=flist.begin();
330 while (it !=flist.end() )
332 fileLoad (*it, NewMap);
338 void Main::statusMessage(const QString &s)
340 statusBar()->message (s);
343 void Main::closeEvent (QCloseEvent* )
349 void Main::setupFileActions()
351 QToolBar *tb = new QToolBar( this );
352 tb->setLabel( "File Actions" );
353 QPopupMenu *menu = new QPopupMenu( this );
354 menuBar()->insertItem( tr( "&File" ), menu );
356 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
359 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
360 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
364 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
365 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
369 lastMapsMenu = new QPopupMenu (this);
371 menu->insertItem (tr("Open Recent"),lastMapsMenu );
372 menu->insertSeparator();
374 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
375 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
380 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
381 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
384 menu->insertSeparator();
386 importMenu = new QPopupMenu (this);
387 menu->insertItem (tr("Import"),importMenu );
389 a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
390 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
391 a->addTo (importMenu);
393 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
394 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
395 a->addTo( importMenu);
397 exportMenu = new QPopupMenu (this);
398 menu->insertItem (tr("Export"),exportMenu );
400 menu->insertSeparator();
403 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
404 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
409 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
410 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
413 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
414 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
420 void Main::setupEditActions()
422 QToolBar *tb = new QToolBar( this );
423 tb->setLabel( "Edit Actions" );
424 QPopupMenu *menu = new QPopupMenu( this );
425 menuBar()->insertItem( tr( "&Edit" ), menu );
429 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
430 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
431 a->setEnabled (false);
436 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
438 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
439 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
444 menu->insertSeparator();
445 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
446 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
447 a->setEnabled (false);
451 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
452 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
453 a->setEnabled (false);
457 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
458 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
459 a->setEnabled (false);
464 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
465 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
466 a->setEnabled (false);
469 actionListBranches.append(a);
472 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
473 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
474 a->setEnabled (false);
477 actionListBranches.append(a);
478 actionEditMoveDown=a;
481 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
482 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
483 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
484 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
485 #if defined(Q_OS_MACX)
486 actionEditToggleScroll=alt;
488 actionEditToggleScroll=a;
490 actionEditToggleScroll->setEnabled (false);
491 actionEditToggleScroll->addTo( tb );
492 actionEditToggleScroll->addTo( menu );
493 actionListBranches.append(actionEditToggleScroll);
495 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
496 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
499 menu->insertSeparator();
501 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
502 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
505 menu->insertSeparator();
507 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
508 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
510 a->setEnabled (false);
513 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
514 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
515 a->setEnabled (false);
516 actionListBranches.append(a);
519 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
520 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
521 a->setEnabled (false);
522 actionListBranches.append(a);
523 actionEditHeading2URL=a;
525 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
526 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
527 a->setEnabled (false);
528 actionListBranches.append(a);
529 actionEditBugzilla2URL=a;
531 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
532 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
533 a->setEnabled (false);
534 actionListBranches.append(a);
535 actionEditFATE2URL=a;
537 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" );
538 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
540 a->setEnabled (false);
541 actionEditOpenVymLink=a;
543 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
544 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
545 a->setEnabled (false);
546 actionListBranches.append(a);
549 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
550 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
551 a->setEnabled (false);
552 actionEditDeleteVymLink=a;
554 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
555 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
556 a->setEnabled (true);
559 menu->insertSeparator();
561 // Shortcuts to modify heading:
562 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
563 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
564 actionListBranches.append(a);
565 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
566 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
567 actionListBranches.append(a);
569 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
570 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
571 a->setEnabled (false);
573 actionListBranches.append(a);
575 // Shortcut to delete selection
576 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
577 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
578 a->setEnabled (false);
581 // Shortcut to add branch
582 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
583 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
584 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
585 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
586 a->setEnabled (false);
587 actionListBranches.append(a);
588 #if defined (Q_OS_MACX)
589 // In OSX show different shortcut in menues, the keys work independtly always
590 actionEditAddBranch=alt;
592 actionEditAddBranch=a;
595 // Add branch by inserting it at selection
596 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
597 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
598 a->setEnabled (false);
599 actionListBranches.append(a);
600 actionEditAddBranchHere=a;
601 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
602 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
603 actionListBranches.append(a);
606 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
607 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
608 a->setEnabled (false);
609 actionListBranches.append(a);
610 actionEditAddBranchAbove=a;
611 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
612 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
613 actionListBranches.append(a);
616 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
617 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
618 a->setEnabled (false);
619 actionListBranches.append(a);
620 actionEditAddBranchBelow=a;
621 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
622 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
623 actionListBranches.append(a);
625 // Import at selection (adding to selection)
626 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
627 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
628 a->setEnabled (false);
629 actionListBranches.append(a);
630 actionEditImportAdd=a;
632 // Import at selection (replacing selection)
633 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
634 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
635 a->setEnabled (false);
636 actionListBranches.append(a);
637 actionEditImportReplace=a;
640 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
641 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
642 a->setEnabled (false);
643 actionListBranches.append(a);
644 actionEditSaveBranch=a;
646 // Only remove branch, not its childs
647 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
648 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
649 a->setEnabled (false);
650 actionListBranches.append(a);
651 actionEditRemoveBranchHere=a;
653 // Only remove childs of a branch
654 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
655 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
656 a->setEnabled (false);
657 actionListBranches.append(a);
658 actionEditRemoveChilds=a;
660 // Shortcuts for navigating with cursor:
661 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
662 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
663 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
664 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
665 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
666 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
667 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
668 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
669 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
670 a->setEnabled (false);
672 actionListBranches.append(a);
673 actionEditSelectFirst=a;
674 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
675 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
676 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
677 a->setEnabled (false);
679 actionListBranches.append(a);
680 actionEditSelectLast=a;
682 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
683 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
684 actionEditLoadImage=a;
689 void Main::setupFormatActions()
691 QPopupMenu *menu = new QPopupMenu( this );
692 menuBar()->insertItem( tr( "&Format" ), menu );
694 QToolBar *tb = new QToolBar( this );
698 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
699 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
700 actionFormatColor->addTo( tb );
701 actionFormatColor->addTo( menu );
702 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" );
703 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
704 a->setEnabled (false);
707 actionListBranches.append(a);
708 actionFormatPickColor=a;
709 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
710 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
711 a->setEnabled (false);
714 actionListBranches.append(a);
715 actionFormatColorBranch=a;
716 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
717 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
718 a->setEnabled (false);
721 actionListBranches.append(a);
722 actionFormatColorSubtree=a;
724 menu->insertSeparator();
725 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
726 actionGroupFormatLinkStyles->setExclusive (true);
727 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
728 a->setToggleAction(true);
729 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
730 actionFormatLinkStyleLine=a;
731 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
732 a->setToggleAction(true);
733 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
734 actionFormatLinkStyleParabel=a;
735 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
736 a->setToggleAction(true);
737 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
738 actionFormatLinkStylePolyLine=a;
739 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
740 a->setToggleAction(true);
741 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
742 actionFormatLinkStylePolyParabel=a;
743 actionGroupFormatLinkStyles->addTo (menu);
745 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
746 actionGroupFormatFrameTypes->setExclusive (true);
747 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
748 a->setToggleAction(true);
749 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
750 actionFormatFrameNone=a;
751 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
752 a->setToggleAction(true);
753 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
754 actionFormatFrameRectangle=a;
756 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
757 a->setToggleAction(true);
758 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
759 actionFormatIncludeImagesVer=a;
761 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
762 a->setToggleAction(true);
763 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
764 actionFormatIncludeImagesHor=a;
766 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
767 a->setToggleAction(true);
768 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
769 actionFormatHideLinkUnselected=a;
771 menu->insertSeparator();
772 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
773 a->setToggleAction(true);
774 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
776 actionFormatLinkColorHint=a;
778 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
779 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
780 actionFormatLinkColor->addTo( menu );
781 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
782 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
783 actionFormatBackColor->addTo( menu );
787 void Main::setupViewActions()
789 QToolBar *tb = new QToolBar( this );
790 tb->setLabel( "View Actions" );
791 QPopupMenu *menu = new QPopupMenu( this );
792 menuBar()->insertItem( tr( "&View" ), menu );
795 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
796 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
799 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
800 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
803 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
804 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
807 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
808 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
809 a->setToggleAction(true);
810 if (textEditor->showWithMain())
816 actionViewToggleNoteEditor=a;
817 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
818 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
820 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
821 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
826 void Main::setupModeActions()
828 //QPopupMenu *menu = new QPopupMenu( this );
829 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
831 QToolBar *tb = new QToolBar( this );
832 tb->setLabel( tr ("Modes when using modifiers") );
834 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
835 actionGroupModModes->setExclusive (true);
836 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
837 a->setToggleAction(true);
840 actionModModeColor=a;
842 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
843 a->setToggleAction(true);
847 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
848 a->setToggleAction(true);
854 void Main::setupFlagActions()
856 // Create System Flags
857 systemFlagsDefault = new FlagRowObj ();
858 systemFlagsDefault->setVisibility (false);
859 systemFlagsDefault->setName ("systemFlagsDef");
861 FlagObj *fo = new FlagObj ();
862 fo->load(QPixmap(flag_note_xpm));
864 fo->setToolTip(tr("Note","Systemflag"));
865 systemFlagsDefault->addFlag (fo); // makes deep copy
867 fo->load(QPixmap(flag_url_xpm));
869 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
870 systemFlagsDefault->addFlag (fo);
872 fo->load(QPixmap(flag_vymlink_xpm));
873 fo->setName("vymLink");
874 fo->setToolTip(tr("Link to another vym map","Systemflag"));
875 systemFlagsDefault->addFlag (fo);
877 fo->load(QPixmap(flag_scrolled_right_xpm));
878 fo->setName("scrolledright");
879 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
880 systemFlagsDefault->addFlag (fo);
882 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
883 fo->setName("tmpUnscrolledright");
884 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
885 systemFlagsDefault->addFlag (fo);
887 // Create Standard Flags
888 standardFlagsDefault = new FlagRowObj ();
889 standardFlagsDefault->setVisibility (false);
890 standardFlagsDefault->setName ("standardFlagsDef");
892 fo->load(QPixmap(flag_exclamationmark_xpm));
893 fo->setName ("exclamationmark");
894 fo->setGroup("standard-mark");
895 fo->setToolTip(tr("Take care!","Standardflag"));
896 standardFlagsDefault->addFlag (fo); // makes deep copy
898 fo->load(QPixmap(flag_questionmark_xpm));
899 fo->setName("questionmark");
900 fo->setGroup("standard-mark");
901 fo->setToolTip(tr("Really?","Standardflag"));
902 standardFlagsDefault->addFlag (fo);
904 fo->load(QPixmap(flag_hook_green_xpm));
905 fo->setName("hook-green");
906 fo->setGroup("standard-hook");
907 fo->setToolTip(tr("ok!","Standardflag"));
908 standardFlagsDefault->addFlag (fo);
910 fo->load(QPixmap(flag_cross_red_xpm));
911 fo->setName("cross-red");
912 fo->setGroup("standard-hook");
913 fo->setToolTip(tr("Not ok!","Standardflag"));
914 standardFlagsDefault->addFlag (fo);
916 fo->load(QPixmap(flag_stopsign_xpm));
917 fo->setName("stopsign");
918 fo->setToolTip(tr("This won't work!","Standardflag"));
919 standardFlagsDefault->addFlag (fo);
921 fo->load(QPixmap(flag_smiley_good_xpm));
922 fo->setName("smiley-good");
923 fo->setGroup("standard-smiley");
924 fo->setToolTip(tr("Good","Standardflag"));
925 standardFlagsDefault->addFlag (fo);
927 fo->load(QPixmap(flag_smiley_sad_xpm));
928 fo->setName("smiley-sad");
929 fo->setGroup("standard-smiley");
930 fo->setToolTip(tr("Bad","Standardflag"));
931 standardFlagsDefault->addFlag (fo);
933 fo->load(QPixmap(flag_clock_xpm));
934 fo->setName("clock");
935 fo->setToolTip(tr("Time critical","Standardflag"));
936 standardFlagsDefault->addFlag (fo);
938 fo->load(QPixmap(flag_lamp_xpm));
940 fo->setToolTip(tr("Idea!","Standardflag"));
941 standardFlagsDefault->addFlag (fo);
943 fo->load(QPixmap(flag_arrow_up_xpm));
944 fo->setName("arrow-up");
945 fo->setGroup("standard-arrow");
946 fo->setToolTip(tr("Important","Standardflag"));
947 standardFlagsDefault->addFlag (fo);
949 fo->load(QPixmap(flag_arrow_down_xpm));
950 fo->setName("arrow-down");
951 fo->setGroup("standard-arrow");
952 fo->setToolTip(tr("Unimportant","Standardflag"));
953 standardFlagsDefault->addFlag (fo);
955 fo->load(QPixmap(flag_thumb_up_xpm));
956 fo->setName("thumb-up");
957 fo->setGroup("standard-thumb");
958 fo->setToolTip(tr("I like this","Standardflag"));
959 standardFlagsDefault->addFlag (fo);
961 fo->load(QPixmap(flag_thumb_down_xpm));
962 fo->setName("thumb-down");
963 fo->setGroup("standard-thumb");
964 fo->setToolTip(tr("I like this","Standardflag"));
965 fo->setToolTip(tr("I do not like this","Standardflag"));
966 standardFlagsDefault->addFlag (fo);
968 fo->load(QPixmap(flag_heart_xpm));
969 fo->setName("heart");
970 fo->setToolTip(tr("I just love... ","Standardflag"));
971 standardFlagsDefault->addFlag (fo);
973 fo->load(QPixmap(flag_flash_xpm));
974 fo->setName("flash");
975 fo->setToolTip(tr("Dangerous","Standardflag"));
976 standardFlagsDefault->addFlag (fo);
978 fo->load(QPixmap(flag_lifebelt_xpm));
979 fo->setName("lifebelt");
980 fo->setToolTip(tr("This will help","Standardflag"));
981 standardFlagsDefault->addFlag (fo);
984 standardFlagsDefault->makeToolbar(this, "Standard Flags");
988 void Main::setupSettingsActions()
990 QPopupMenu *menu = new QPopupMenu( this );
991 menuBar()->insertItem( tr( "&Settings" ), menu );
996 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
997 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1000 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1001 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1004 menu->insertSeparator();
1005 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1006 a->setToggleAction(true);
1007 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1009 actionSettingsAutoedit=a;
1011 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1012 a->setToggleAction(true);
1013 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1015 actionSettingsAutoselectHeading=a;
1017 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1018 a->setToggleAction(true);
1019 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1021 actionSettingsAutoselectText=a;
1023 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1024 a->setToggleAction(true);
1025 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1027 actionSettingsPasteNewHeading=a;
1029 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1030 a->setToggleAction(true);
1031 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1033 actionSettingsUseDelKey=a;
1035 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1036 a->setToggleAction(true);
1037 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1039 actionSettingsUseFlagGroups=a;
1043 void Main::setupTestActions()
1045 QPopupMenu *menu = new QPopupMenu( this );
1046 menuBar()->insertItem( tr( "&Test" ), menu );
1049 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1050 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1055 void Main::setupHelpActions()
1057 QPopupMenu *menu = new QPopupMenu( this );
1058 menuBar()->insertItem( tr( "&Help" ), menu );
1061 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1062 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1065 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1066 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1069 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1070 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1075 void Main::setupContextMenus()
1079 // Context Menu for branch or mapcenter
1080 branchContextMenu =new QPopupMenu (this);
1083 branchAddContextMenu =new QPopupMenu (this);
1084 actionEditPaste->addTo ( branchAddContextMenu );
1085 actionEditAddBranch->addTo ( branchAddContextMenu );
1086 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1087 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1088 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1089 branchAddContextMenu->insertSeparator();
1090 actionEditLoadImage->addTo( branchAddContextMenu );
1091 branchAddContextMenu->insertSeparator();
1092 actionEditImportAdd->addTo ( branchAddContextMenu );
1093 actionEditImportReplace->addTo ( branchAddContextMenu );
1096 branchRemoveContextMenu =new QPopupMenu (this);
1097 actionEditCut->addTo ( branchRemoveContextMenu );
1098 actionEditDelete->addTo ( branchRemoveContextMenu );
1099 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
1100 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1102 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1103 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1105 actionEditSaveBranch->addTo( branchContextMenu );
1107 branchContextMenu->insertSeparator();
1108 actionEditOpenURL->addTo ( branchContextMenu );
1109 actionEditURL->addTo ( branchContextMenu );
1110 actionEditHeading2URL->addTo ( branchContextMenu );
1111 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1113 actionEditBugzilla2URL->addTo( branchContextMenu );
1114 actionEditFATE2URL->addTo( branchContextMenu );
1116 branchContextMenu->insertSeparator();
1117 actionEditOpenVymLink->addTo ( branchContextMenu );
1118 actionEditVymLink->addTo ( branchContextMenu );
1119 actionEditDeleteVymLink->addTo ( branchContextMenu );
1121 branchContextMenu->insertSeparator();
1122 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1124 branchContextMenu->insertSeparator();
1125 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1126 // FIXME not implemented yet actionFormatIncludeImagesHor->addTo( branchContextMenu );
1127 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1129 // Context Menu for links in a branch menu
1130 // This will be populated "on demand" in MapEditor::updateActions
1131 branchContextMenu->insertSeparator();
1132 branchLinksContextMenu =new QPopupMenu (this);
1133 branchLinksContextMenuDup =new QPopupMenu (this);
1134 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1135 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1137 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1138 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1140 // Context menu for floatimage
1141 floatimageContextMenu =new QPopupMenu (this);
1142 saveImageFormatMenu=new QPopupMenu (this);
1143 exportImageFormatMenu=new QPopupMenu (this);
1145 QStrList fmt = QImage::outputFormats();
1146 for (const char* f = fmt.first(); f; f = fmt.next())
1148 saveImageFormatMenu->insertItem( f );
1149 exportImageFormatMenu->insertItem( f );
1151 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1152 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1153 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1155 floatimageContextMenu->insertSeparator();
1156 actionEditCopy->addTo( floatimageContextMenu );
1157 actionEditCut->addTo( floatimageContextMenu );
1159 floatimageContextMenu->insertSeparator();
1160 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1161 a->setToggleAction(true);
1162 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1163 a->addTo( floatimageContextMenu);
1164 actionEditToggleFloatExport=a;
1166 floatimageContextMenu->insertSeparator();
1167 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1169 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1170 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1171 a->addTo (exportMenu);
1173 exportMenu->insertItem ( tr("Export as Image"),exportImageFormatMenu);
1175 a = new QAction( tr( "Export as ASCII")+" "+tr("(still experimental)" ), QPixmap(), "ASCII...", 0, this, "exportASCII" );
1176 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1177 a->addTo( exportMenu );
1179 a = new QAction( tr( "Export as LaTeX")+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1180 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1181 a->addTo( exportMenu );
1183 a = new QAction( tr( "Export as XML" ), QPixmap(), "XML...", 0, this, "exportXML" );
1184 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1185 a->addTo( exportMenu );
1187 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1189 a = new QAction( tr( "Export as HTML" ), QPixmap(), "HTML...", 0, this, "exportHTML");
1190 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1191 a->addTo( exportMenu );
1194 a = new QAction( tr( "Export as XHTML" ), QPixmap(), "XHTML...", ALT + Key_X, this, "exportXHTML" );
1195 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1196 a->addTo( exportMenu );
1199 // Context menu for canvas
1200 canvasContextMenu =new QPopupMenu (this);
1201 actionEditMapInfo->addTo( canvasContextMenu );
1202 canvasContextMenu->insertSeparator();
1203 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1204 canvasContextMenu->insertSeparator();
1205 actionFormatLinkColorHint->addTo( canvasContextMenu );
1206 actionFormatLinkColor->addTo( canvasContextMenu );
1207 actionFormatBackColor->addTo( canvasContextMenu );
1209 // Menu for last opened files
1210 // Read settings initially
1212 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1213 for (int i=1;i<=j;i++)
1215 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1216 if (!s.isEmpty() && j<=maxLastMaps)
1219 setupLastMapsMenu();
1220 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1223 void Main::setupLastMapsMenu()
1225 // Remove double entries
1226 QStringList::Iterator it=lastMaps.begin();
1227 QStringList::Iterator jt;
1228 while (it!=lastMaps.end() )
1232 while (jt!=lastMaps.end() )
1235 jt=lastMaps.remove(jt);
1242 // Limit length of list to maxLastMaps
1243 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1245 // build Menu from lastMaps string list
1246 lastMapsMenu->clear();
1247 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1248 lastMapsMenu->insertItem (*it );
1252 void Main::hideEvent (QHideEvent * )
1254 if (!textEditor->isMinimized() ) textEditor->hide();
1257 void Main::showEvent (QShowEvent * )
1259 if (textEditor->showWithMain()) textEditor->showNormal();
1262 bool Main::reallyWriteDirectory(const QString &dir)
1264 QStringList eList = QDir(dir).entryList();
1265 if (eList.first() ==".") eList.pop_front(); // remove "."
1266 if (eList.first() =="..") eList.pop_front(); // remove "."
1267 if (!eList.isEmpty())
1269 QMessageBox mb( __VYM,
1270 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1271 QMessageBox::Warning,
1273 QMessageBox::Cancel | QMessageBox::Default,
1274 QMessageBox::QMessageBox::NoButton );
1276 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1277 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1280 case QMessageBox::Yes:
1283 case QMessageBox::Cancel:
1291 QString Main::browseDirectory (const QString &caption)
1293 QFileDialog fd(this,caption);
1294 fd.setMode (QFileDialog::DirectoryOnly);
1295 fd.setCaption(__VYM " - "+caption);
1298 if ( fd.exec() == QDialog::Accepted )
1299 return fd.selectedFile();
1304 MapEditor* Main::currentMapEditor() const
1306 if ( tabWidget->currentPage() &&
1307 tabWidget->currentPage()->inherits( "MapEditor" ) )
1308 return (MapEditor*)tabWidget->currentPage();
1312 //TODO not used now, maybe use this for overview window later
1313 void Main::newView()
1315 // Open a new view... have it delete when closed.
1316 Main *m = new Main(0, 0, WDestructiveClose);
1317 qApp->setMainWidget(m);
1319 qApp->setMainWidget(0);
1322 void Main::editorChanged(QWidget *)
1324 // Unselect all possibly selected objects
1325 // (Important to update note editor)
1328 for (i=0;i<=tabWidget->count() -1;i++)
1331 me=(MapEditor*)tabWidget->page(i);
1334 currentMapEditor()->reselect();
1336 // Update actions to in menus and toolbars according to editor
1337 currentMapEditor()->updateActions();
1340 void Main::fileNew()
1342 QString fn="unnamed";
1343 MapEditor* medit = new MapEditor (tabWidget, true);
1344 tabWidget->addTab (medit,fn);
1345 tabWidget->showPage(medit);
1346 medit->viewport()->setFocus();
1347 // For the very first map we do not have flagrows yet...
1348 medit->select("mc:");
1351 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1353 ErrorCode err=success;
1355 // fn is usually the archive, mapfile the file after uncompressing
1358 // Make fn absolute (needed for unzip)
1359 fn=QDir (fn).absPath();
1365 // Check, if map is already loaded
1367 while (i<=tabWidget->count() -1)
1369 me=(MapEditor*)tabWidget->page(i);
1370 if (me->getFilePath() == fn)
1372 // Already there, ask for confirmation
1373 QMessageBox mb( __VYM,
1374 tr("The map %1\nis already opened."
1375 "Opening the same map in multiple editors may lead \n"
1376 "to confusion when finishing working with vym."
1377 "Do you want to").arg(fn),
1378 QMessageBox::Warning,
1379 QMessageBox::Yes | QMessageBox::Default,
1380 QMessageBox::Cancel | QMessageBox::Escape,
1381 QMessageBox::QMessageBox::NoButton);
1382 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1383 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1386 case QMessageBox::Yes:
1388 i=tabWidget->count();
1390 case QMessageBox::Cancel:
1402 if ( !fn.isEmpty() )
1404 me = currentMapEditor();
1405 int tabIndex=tabWidget->currentPageIndex();
1406 // Check first, if mapeditor exists
1407 // If it is not default AND we want a new map,
1408 // create a new mapeditor in a new tab
1409 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1411 me = new MapEditor (tabWidget,true);
1412 tabWidget->addTab (me,fn);
1413 tabIndex=tabWidget->indexOf (me);
1414 tabWidget->setCurrentPage (tabIndex);
1417 // Check, if file exists (important for creating new files
1418 // from command line
1419 if (!QFile(fn).exists() )
1421 QMessageBox mb( __VYM,
1422 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1423 QMessageBox::Question,
1425 QMessageBox::Cancel | QMessageBox::Default,
1426 QMessageBox::QMessageBox::NoButton );
1428 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1429 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1432 case QMessageBox::Yes:
1434 currentMapEditor()->setFilePath(fn);
1435 tabWidget->setTabLabel (currentMapEditor(),
1436 currentMapEditor()->getFileName() );
1437 statusBar()->message( "Created " + fn , statusbarTime );
1440 case QMessageBox::Cancel:
1441 // don't create new map
1442 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1449 //tabWidget->currentPage() won't be NULL here, because of above...
1450 tabWidget->showPage(me);
1451 me->viewport()->setFocus();
1453 // Create temporary directory for packing
1454 char tmpdir1[]="/tmp/vym-XXXXXX";
1455 QString tmpMapDir=mkdtemp(tmpdir1);
1457 // Try to unzip file
1458 err=unzipDir (tmpMapDir,fn);
1462 me->setZipped(false);
1465 me->setZipped(true);
1467 // Look for mapname.xml
1468 mapfile= fn.left(fn.findRev(".",-1,true));
1469 mapfile=mapfile.section( '/', -1 );
1470 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1471 if (!file.exists() )
1473 // mapname.xml does not exist, well,
1474 // maybe some renamed the mapname.vym file...
1475 // Try to find any .xml in the toplevel
1476 // directory of the .vym file
1477 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1478 if (flist.count()==1)
1480 // Only one entry, take this one
1481 mapfile=tmpMapDir + "/"+flist.first();
1484 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1485 *it=tmpMapDir + "/" + *it;
1486 // TODO Multiple entries, load all (but only the first one into this ME)
1487 //mainWindow->fileLoadFromTmp (flist);
1488 //returnCode=1; // Silently forget this attempt to load
1489 qWarning ("MainWindow::load (fn) multimap found...");
1492 if (flist.isEmpty() )
1494 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1495 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1498 } //file doesn't exist
1500 mapfile=file.name();
1505 // Save existing filename in case we import
1506 QString fn_org=me->getFilePath();
1508 // Finally load map into mapEditor
1509 me->setFilePath (mapfile,fn);
1510 err=me->load(mapfile,lmode);
1512 // Restore old (maybe empty) filepath, if this is an import
1514 me->setFilePath (fn_org);
1517 // Finally check for errors and go home
1520 if (lmode==NewMap) fileCloseMap();
1521 statusBar()->message( "Could not load " + fn, statusbarTime );
1526 me->setFilePath (fn);
1527 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1528 if (fn.left(9)!="/tmp/vym-")
1530 // Only append to lastMaps if not loaded from a tmpDir
1531 // e.g. imported bookmarks are in a tmpDir
1532 lastMaps.prepend(me->getFilePath() );
1533 setupLastMapsMenu();
1535 actionFilePrint->setEnabled (true);
1537 statusBar()->message( "Loaded " + fn, statusbarTime );
1541 removeDir (QDir(tmpMapDir));
1547 void Main::fileLoad(const LoadMode &lmode)
1549 QFileDialog *fd=new QFileDialog( this);
1550 if (!lastFileDir.isEmpty())
1551 fd->setDir (lastFileDir);
1552 fd->setMode (QFileDialog::ExistingFiles);
1553 fd->addFilter ("XML (*.xml)");
1554 fd->addFilter ("VYM map (*.vym *.vyp)");
1558 fd->setCaption(tr("Load vym map"));
1561 fd->setCaption(tr("Import: Add vym map to selection"));
1564 fd->setCaption(tr("Import: Replace selection with vym map"));
1570 if ( fd->exec() == QDialog::Accepted )
1572 lastFileDir=fd->dirPath();
1573 QStringList flist = fd->selectedFiles();
1574 QStringList::Iterator it = flist.begin();
1575 while( it != flist.end() )
1578 fileLoad(*it, lmode);
1585 void Main::fileLoad()
1590 void Main::fileLoadLast(int i)
1592 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1595 void Main::fileSave(const SaveMode &savemode)
1597 // tmp dir for zipping
1601 ErrorCode err=success;
1603 QString safeFilePath;
1605 bool saveZipped=currentMapEditor()->saveZipped();
1607 MapEditor * me=currentMapEditor();
1610 QString fn=me->getFilePath();
1611 // filename=unnamed, filepath="" in constructor...
1612 if ( !fn.isEmpty() )
1614 // We have a filepath, go on saving
1615 // First remove existing file, we
1616 // don't want to add to old zip archives
1620 QMessageBox::warning( 0, tr( "Save Error" ),
1621 fn+ tr("\ncould not be removed before saving"));
1623 // Look, if we should zip the data:
1626 QMessageBox mb( __VYM,
1627 tr("The map %1\ndid not use the compressed "
1628 "vym file format.\nWriting it uncompressed will also write images \n"
1629 "and flags and thus may overwrite files in the "
1630 "given directory\n\nDo you want to write the map").arg(fn),
1631 QMessageBox::Warning,
1632 QMessageBox::Yes | QMessageBox::Default,
1634 QMessageBox::Cancel | QMessageBox::Escape);
1635 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1636 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1637 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1640 case QMessageBox::Yes:
1641 // save compressed (default file format)
1644 case QMessageBox::No:
1645 // save uncompressed
1648 case QMessageBox::Cancel:
1657 char tmpdir1[]="/tmp/vym-XXXXXX";
1658 tmpMapDir=mkdtemp(tmpdir1);
1660 safeFilePath=me->getFilePath();
1661 me->setFilePath (tmpMapDir+"/"+
1662 me->getMapName()+ ".xml",
1664 me->save (savemode);
1665 me->setFilePath (safeFilePath);
1667 zipDir (tmpMapDir,fn);
1672 safeFilePath=me->getFilePath();
1673 me->setFilePath (fn, safeFilePath);
1674 me->save (savemode);
1675 me->setFilePath (safeFilePath);
1677 } // filepath available
1680 // We have no filepath yet,
1681 // call fileSaveAs() now, this will call fileSave()
1683 fileSaveAs(savemode);
1687 if (me->saveZipped())
1690 removeDir (QDir(tmpMapDir));
1695 statusBar()->message(
1696 tr("Saved %1").arg(me->getFilePath()),
1698 lastMaps.prepend(me->getFilePath() );
1699 setupLastMapsMenu();
1701 statusBar()->message(
1702 tr("Couldn't save ").arg(me->getFilePath()),
1706 void Main::fileSave()
1708 fileSave (CompleteMap);
1711 void Main::fileSaveAs(const SaveMode& savemode)
1716 if (currentMapEditor())
1718 if (savemode==CompleteMap)
1719 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1721 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1722 if ( !fn.isEmpty() )
1724 // Check for existing file
1725 if (QFile (fn).exists())
1727 QMessageBox mb( __VYM,
1728 tr("The file %1\nexists already. Do you want to").arg(fn),
1729 QMessageBox::Warning,
1730 QMessageBox::Yes | QMessageBox::Default,
1731 QMessageBox::Cancel | QMessageBox::Escape,
1732 QMessageBox::QMessageBox::NoButton);
1733 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1734 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1737 case QMessageBox::Yes:
1740 case QMessageBox::Cancel:
1747 // New file, add extension to filename, if missing
1748 // This is always .vym or .vyp, depending on savemode
1749 if (savemode==CompleteMap)
1751 if (!fn.contains (".vym") && !fn.contains (".xml"))
1755 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1764 currentMapEditor()->setFilePath(fn);
1768 if (savemode==CompleteMap)
1769 tabWidget->setTabLabel (currentMapEditor(),
1770 currentMapEditor()->getFileName() );
1776 void Main::fileSaveAs()
1778 fileSaveAs (CompleteMap);
1781 void Main::fileImportDir()
1783 if (currentMapEditor())
1784 currentMapEditor()->importDir();
1787 void Main::fileImportKDEBookmarks()
1789 ImportKDEBookmarks im;
1791 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1792 currentMapEditor()->setFilePath ("");
1795 void Main::fileExportXML()
1797 if (currentMapEditor())
1799 QString dir=browseDirectory(tr("Export XML to directory"));
1800 if (dir !="" && reallyWriteDirectory(dir) )
1801 currentMapEditor()->exportXML(dir);
1805 void Main::fileExportHTML()
1807 if (currentMapEditor())
1809 ExportHTMLDialog dia(this);
1811 if (dia.exec()==QDialog::Accepted)
1813 QString dir=dia.getDir();
1814 if (reallyWriteDirectory(dir) )
1816 currentMapEditor()->exportXML (dia.getDir() );
1817 dia.doExport(currentMapEditor()->getMapName() );
1823 void Main::fileExportXHTML()
1826 if (currentMapEditor())
1828 ExportXHTMLDialog dia(this);
1829 dia.setFilePath (currentMapEditor()->getFilePath() );
1830 dia.setMapName (currentMapEditor()->getMapName() );
1833 if (dia.exec()==QDialog::Accepted)
1835 QString dir=dia.getDir();
1836 // Check, if warnings should be used before overwriting
1837 // the output directory
1840 ok=reallyWriteDirectory(dir);
1846 currentMapEditor()->exportXML (dia.getDir() );
1847 dia.doExport(currentMapEditor()->getMapName() );
1848 if (dia.hasChanged())
1849 currentMapEditor()->setChanged();
1855 void Main::fileExportImage(int item)
1857 if (currentMapEditor())
1859 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1861 if ( !fn.isEmpty() )
1862 currentMapEditor()->exportImage(fn,item);
1864 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1869 void Main::fileExportASCII()
1871 if (currentMapEditor())
1872 currentMapEditor()->exportASCII();
1875 void Main::fileExportLaTeX()
1877 if (currentMapEditor())
1878 currentMapEditor()->exportLaTeX();
1881 void Main::fileExportOOPresentation()
1883 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to Open Office"));
1884 // FIXME add extra info in dialog
1885 //ImagePreview *p =new ImagePreview (fd);
1886 //fd->setContentsPreviewEnabled( TRUE );
1887 //fd->setContentsPreview( p, p );
1888 //fd->setPreviewMode( QFileDialog::Contents );
1889 fd->setCaption(__VYM " - " +tr("Export to Open Office"));
1890 //fd->setDir (lastImageDir);
1893 if ( fd->exec() == QDialog::Accepted )
1895 QString fn=fd->selectedFile();
1896 //lastImageDir=fn.left(fn.findRev ("/"));
1897 if (currentMapEditor())
1898 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
1902 void Main::fileCloseMap()
1904 if (currentMapEditor())
1906 if (currentMapEditor()->hasChanged())
1908 QMessageBox mb( __VYM,
1909 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1910 QMessageBox::Warning,
1911 QMessageBox::Yes | QMessageBox::Default,
1913 QMessageBox::Cancel | QMessageBox::Escape );
1914 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1915 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1918 case QMessageBox::Yes:
1920 fileSave(CompleteMap);
1922 case QMessageBox::No:
1923 // close without saving
1925 case QMessageBox::Cancel:
1930 currentMapEditor()->closeMap();
1931 tabWidget->removePage(currentMapEditor());
1932 if (tabWidget->count()==0)
1933 actionFilePrint->setEnabled (false);
1937 void Main::filePrint()
1939 if (currentMapEditor())
1940 currentMapEditor()->print();
1943 void Main::fileExitVYM()
1945 // Check if one or more editors have changed
1948 for (i=0;i<=tabWidget->count() -1;i++)
1951 me=(MapEditor*)tabWidget->page(i);
1953 // If something changed, ask what to do
1954 if (me->isUnsaved())
1956 tabWidget->setCurrentPage(i);
1957 QMessageBox mb( __VYM,
1958 tr("This map is not saved yet. Do you want to"),
1959 QMessageBox::Warning,
1960 QMessageBox::Yes | QMessageBox::Default,
1962 QMessageBox::Cancel | QMessageBox::Escape );
1963 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1964 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1966 // Call undocumented function: setActiveWindow is only
1967 // possible, if widget is visible. This depends on
1969 #if defined(Q_OS_LINUX)
1970 qt_wait_for_window_manager( this);
1972 mb.setActiveWindow();
1973 switch( mb.exec() ) {
1974 case QMessageBox::Yes:
1975 // save (the changed editors) and exit
1976 fileSave(CompleteMap);
1978 case QMessageBox::No:
1979 // exit without saving
1981 case QMessageBox::Cancel:
1982 // don't save and don't exit
1986 } // loop over all MEs
1990 void Main::editUndo()
1992 if (currentMapEditor())
1993 currentMapEditor()->undo();
1996 void Main::editRedo()
1998 if (currentMapEditor())
1999 currentMapEditor()->redo();
2002 void Main::editCopy()
2004 if (currentMapEditor())
2005 currentMapEditor()->copy();
2008 void Main::editPaste()
2010 if (currentMapEditor())
2011 currentMapEditor()->paste();
2014 void Main::editCut()
2016 if (currentMapEditor())
2017 currentMapEditor()->cut();
2020 void Main::editOpenFindWindow()
2022 findWindow->popup();
2023 findWindow->raise();
2025 // Call undocumented function: setActiveWindow is only
2026 // possible, if widget is visible. This depends on
2028 #if defined(Q_OS_LINUX)
2029 qt_wait_for_window_manager( this);
2031 findWindow->setActiveWindow();
2034 void Main::editFind(QString s)
2037 BranchObj *bo=currentMapEditor()->findText(s, cs);
2040 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2043 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2044 tr("No matches found for <b>%1</b>").arg(s));
2048 void Main::editFindChanged()
2049 { // Notify editor, to abort the current find process
2050 currentMapEditor()->findReset();
2053 void Main::editOpenURL()
2055 if (currentMapEditor())
2056 currentMapEditor()->openURL();
2059 void Main::editURL()
2061 if (currentMapEditor())
2062 currentMapEditor()->editURL();
2065 void Main::editHeading2URL()
2067 if (currentMapEditor())
2068 currentMapEditor()->editHeading2URL();
2071 void Main::editBugzilla2URL()
2073 if (currentMapEditor())
2074 currentMapEditor()->editBugzilla2URL();
2077 void Main::editFATE2URL()
2079 if (currentMapEditor())
2080 currentMapEditor()->editFATE2URL();
2083 void Main::editOpenVymLink()
2085 // Get current path to map
2086 QString currentVymLink;
2087 if (currentMapEditor())
2089 currentVymLink=currentMapEditor()->getVymLink();
2090 // compare path with already loaded maps
2094 for (i=0;i<=tabWidget->count() -1;i++)
2096 me=(MapEditor*)tabWidget->page(i);
2097 if (currentVymLink==me->getFilePath() )
2106 if (!QFile(currentVymLink).exists() )
2107 QMessageBox::critical( 0, tr( "Critical Error" ),
2108 tr("Couldn't open map %1").arg(currentVymLink));
2111 fileLoad (currentVymLink, NewMap);
2112 tabWidget->setCurrentPage (tabWidget->count()-1);
2115 // Go to tab containing the map
2116 tabWidget->setCurrentPage (index);
2120 void Main::editVymLink()
2122 if (currentMapEditor())
2123 currentMapEditor()->editVymLink();
2126 void Main::editDeleteVymLink()
2128 if (currentMapEditor())
2129 currentMapEditor()->deleteVymLink();
2132 void Main::editMapInfo()
2134 if (currentMapEditor())
2135 currentMapEditor()->editMapInfo();
2138 void Main::editMoveUp()
2140 if (currentMapEditor())
2141 currentMapEditor()->moveBranchUp();
2144 void Main::editMoveDown()
2146 if (currentMapEditor())
2147 currentMapEditor()->moveBranchDown();
2150 void Main::editToggleScroll()
2152 if (currentMapEditor())
2154 currentMapEditor()->toggleScroll();
2158 void Main::editUnScrollAll()
2160 if (currentMapEditor())
2162 currentMapEditor()->unScrollAll();
2166 void Main::editHeading()
2168 if (currentMapEditor())
2169 currentMapEditor()->editHeading();
2172 void Main::editNewBranch()
2174 if (currentMapEditor())
2175 currentMapEditor()->addNewBranch(0);
2178 void Main::editNewBranchHere()
2180 if (currentMapEditor())
2181 currentMapEditor()->addNewBranchHere();
2184 void Main::editNewBranchAbove()
2186 if (currentMapEditor())
2187 currentMapEditor()->addNewBranch(-1);
2190 void Main::editNewBranchBelow()
2192 if (currentMapEditor())
2193 currentMapEditor()->addNewBranch(1);
2196 void Main::editImportAdd()
2198 fileLoad (ImportAdd);
2201 void Main::editImportReplace()
2203 fileLoad (ImportReplace);
2206 void Main::editSaveBranch()
2208 fileSaveAs (PartOfMap);
2211 void Main::editRemoveBranchHere()
2213 if (currentMapEditor())
2214 currentMapEditor()->removeBranchHere();
2217 void Main::editRemoveChilds()
2219 if (currentMapEditor())
2220 currentMapEditor()->removeChilds();
2223 void Main::editDeleteSelection()
2225 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2226 currentMapEditor()->deleteSelection();
2229 void Main::editUpperBranch()
2231 if (currentMapEditor())
2232 currentMapEditor()->selectUpperBranch();
2235 void Main::editLowerBranch()
2237 if (currentMapEditor())
2238 currentMapEditor()->selectLowerBranch();
2241 void Main::editLeftBranch()
2243 if (currentMapEditor())
2244 currentMapEditor()->selectLeftBranch();
2247 void Main::editRightBranch()
2249 if (currentMapEditor())
2250 currentMapEditor()->selectRightBranch();
2253 void Main::editFirstBranch()
2255 if (currentMapEditor())
2256 currentMapEditor()->selectFirstBranch();
2259 void Main::editLastBranch()
2261 if (currentMapEditor())
2262 currentMapEditor()->selectLastBranch();
2265 void Main::editLoadImage()
2267 if (currentMapEditor())
2268 currentMapEditor()->loadFloatImage();
2271 void Main::editSaveImage(int item)
2273 if (currentMapEditor())
2274 currentMapEditor()->saveFloatImage(item);
2277 void Main::editToggleFloatExport()
2279 if (currentMapEditor())
2280 currentMapEditor()->toggleFloatExport();
2283 void Main::editFollowXLink(int item)
2285 if (currentMapEditor())
2286 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2289 void Main::editEditXLink(int item)
2291 if (currentMapEditor())
2292 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2295 void Main::formatSelectColor()
2297 if (currentMapEditor())
2299 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2300 if ( !col.isValid() ) return;
2301 currentMapEditor()->setColor( col );
2302 colorChanged( col );
2306 void Main::formatPickColor()
2308 if (currentMapEditor())
2309 colorChanged( currentMapEditor()->pickColor() );
2312 void Main::colorChanged(QColor c)
2314 QPixmap pix( 16, 16 );
2316 actionFormatColor->setIconSet( pix );
2319 void Main::formatColorItem()
2321 if (currentMapEditor())
2322 currentMapEditor()->colorItem();
2325 void Main::formatColorBranch()
2327 if (currentMapEditor())
2328 currentMapEditor()->colorBranch();
2331 void Main::formatLinkStyleLine()
2333 if (currentMapEditor())
2334 currentMapEditor()->setLinkStyle(StyleLine);
2337 void Main::formatLinkStyleParabel()
2339 if (currentMapEditor())
2340 currentMapEditor()->setLinkStyle(StyleParabel);
2343 void Main::formatLinkStylePolyLine()
2345 if (currentMapEditor())
2346 currentMapEditor()->setLinkStyle(StylePolyLine);
2349 void Main::formatLinkStylePolyParabel()
2351 if (currentMapEditor())
2352 currentMapEditor()->setLinkStyle(StylePolyParabel);
2355 void Main::formatSelectBackColor()
2357 if (currentMapEditor())
2358 currentMapEditor()->selectBackgroundColor();
2361 void Main::formatSelectLinkColor()
2363 if (currentMapEditor())
2364 currentMapEditor()->selectLinkColor();
2367 void Main::formatToggleLinkColorHint()
2369 currentMapEditor()->toggleLinkColorHint();
2372 void Main::formatFrameNone()
2374 if (currentMapEditor())
2375 currentMapEditor()->setFrame(NoFrame);
2378 void Main::formatFrameRectangle()
2380 if (currentMapEditor())
2381 currentMapEditor()->setFrame(Rectangle);
2384 void Main::formatIncludeImagesVer()
2386 if (currentMapEditor())
2387 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2390 void Main::formatIncludeImagesHor()
2392 if (currentMapEditor())
2393 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2396 void Main::formatHideLinkUnselected()
2398 if (currentMapEditor())
2399 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2402 void Main::viewZoomReset()
2404 if (currentMapEditor())
2408 currentMapEditor()->setWorldMatrix( m );
2409 currentMapEditor()->setViewCenter();
2410 currentMapEditor()->adjustCanvasSize();
2414 void Main::viewZoomIn()
2416 if (currentMapEditor())
2418 QWMatrix m = currentMapEditor()->worldMatrix();
2419 m.scale( 1.25, 1.25 );
2420 currentMapEditor()->setWorldMatrix( m );
2421 currentMapEditor()->setViewCenter();
2422 currentMapEditor()->adjustCanvasSize();
2426 void Main::viewZoomOut()
2428 if (currentMapEditor())
2430 QWMatrix m = currentMapEditor()->worldMatrix();
2431 m.scale( 0.8, 0.8 );
2432 currentMapEditor()->setWorldMatrix( m );
2433 currentMapEditor()->setViewCenter();
2434 currentMapEditor()->adjustCanvasSize();
2438 void Main::modModeColor()
2442 void Main::modModeLink()
2446 bool Main::settingsPDF()
2448 // Default browser is set in constructor
2450 QString text = QInputDialog::getText(
2451 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2452 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2454 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2459 bool Main::settingsURL()
2461 // Default browser is set in constructor
2463 QString text = QInputDialog::getText(
2464 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2465 settings.readEntry("/vym/mainwindow/readerURL")
2468 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2472 void Main::windowToggleNoteEditor()
2474 if (textEditor->showWithMain() )
2475 windowHideNoteEditor();
2477 windowShowNoteEditor();
2480 void Main::updateNoteFlag()
2482 if (currentMapEditor())
2483 currentMapEditor()->updateNoteFlag();
2486 void Main::windowShowNoteEditor()
2488 textEditor->setShowWithMain(true);
2490 actionViewToggleNoteEditor->setOn (true);
2493 void Main::windowHideNoteEditor()
2495 textEditor->setShowWithMain(false);
2497 actionViewToggleNoteEditor->setOn (false);
2500 void Main::windowNextEditor()
2502 if (tabWidget->currentPageIndex() < tabWidget->count())
2503 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2506 void Main::windowPreviousEditor()
2508 if (tabWidget->currentPageIndex() >0)
2509 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2512 void Main::standardFlagChanged()
2514 currentMapEditor()->toggleStandardFlag(sender()->name());
2517 void Main::testFunction()
2519 currentMapEditor()->testFunction();
2522 void Main::helpDoc()
2525 #if defined(Q_OS_MACX)
2526 docpath="./vym.app/Contents/vym.pdf";
2528 // default path in SUSE LINUX
2529 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2532 if (!QFile (docpath).exists() )
2534 // relative path for easy testing in tarball
2535 docpath="doc/vym.pdf";
2536 if (!QFile (docpath).exists() )
2538 // relative path for testing while still writing vym.tex
2539 docpath="doc/tex/vym.pdf";
2540 if (!QFile (docpath).exists() )
2542 // Try yet another one for Knoppix
2543 docpath="/usr/share/doc/packages/vym/vym.pdf";
2544 if (!QFile (docpath).exists() )
2546 QMessageBox::critical(0,
2547 tr("Critcal error"),
2548 tr("Couldn't find the documentation\n"
2549 "vym.pdf in various places."));
2556 Process *pdfProc = new Process();
2557 pdfProc->clearArguments();
2558 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2559 pdfProc->addArgument( docpath);
2561 if ( !pdfProc->start() )
2564 QMessageBox::critical(0,
2565 tr("Critcal error"),
2566 tr("Couldn't find a viewer to read vym.pdf.\n"
2567 "Please use Settings->")+tr("Set application to open pdf files"));
2573 void Main::helpAbout()
2576 ad.setName ("aboutwindow");
2577 ad.setMinimumSize(500,500);
2578 ad.resize (QSize (500,500));
2582 void Main::helpAboutQT()
2584 QMessageBox::aboutQt( this, "Qt Application Example" );