minor fixes in mmap2vym.xsl and repaired todo.vym (every includeImagesHor was set)
1 #include "mainwindow.h"
3 #include <qstatusbar.h>
4 #include <qmessagebox.h>
6 #include <qapplication.h>
10 #include <qfiledialog.h>
12 #include <qcolordialog.h>
14 #include <qinputdialog.h>
15 //#include <qdatetime.h> // for random seed
22 #include "icons/filenew.xpm"
23 #include "icons/fileopen.xpm"
24 #include "icons/filesave.xpm"
25 #include "icons/fileprint.xpm"
26 #include "icons/editundo.xpm"
27 #include "icons/editredo.xpm"
28 #include "icons/editcopy.xpm"
29 #include "icons/editcut.xpm"
30 #include "icons/editpaste.xpm"
31 #include "icons/editmoveup.xpm"
32 #include "icons/editmovedown.xpm"
33 #include "icons/formatcoloritem.xpm"
34 #include "icons/formatcolorbranch.xpm"
35 #include "icons/formatcolorpicker.xpm"
36 #include "icons/viewzoomreset.xpm"
37 #include "icons/viewzoomin.xpm"
38 #include "icons/viewzoomout.xpm"
39 #include "icons/modecolor.xpm"
40 #include "icons/modelink.xpm"
41 #include "icons/modecopy.xpm"
42 #include "icons/flag-questionmark.xpm"
43 #include "icons/flag-exclamationmark.xpm"
44 #include "icons/flag-hook-green.xpm"
45 #include "icons/flag-cross-red.xpm"
46 #include "icons/flag-stopsign.xpm"
47 #include "icons/flag-smiley-good.xpm"
48 #include "icons/flag-smiley-sad.xpm"
49 #include "icons/flag-clock.xpm"
50 #include "icons/flag-lamp.xpm"
51 #include "icons/flag-arrow-up.xpm"
52 #include "icons/flag-arrow-down.xpm"
53 #include "icons/flag-thumb-up.xpm"
54 #include "icons/flag-thumb-down.xpm"
55 #include "icons/flag-heart.xpm"
56 #include "icons/flag-flash.xpm"
57 #include "icons/flag-lifebelt.xpm"
58 #include "icons/flag-note.xpm"
59 #include "icons/flag-url.xpm"
60 #include "icons/flag-vymlink.xpm"
61 #include "icons/flag-scrolled-right.xpm"
62 #include "icons/flag-tmpUnscrolled-right.xpm"
64 #include "aboutdialog.h"
65 #include "exporthtmldialog.h"
66 #include "exportoofiledialog.h"
67 #include "exportxhtmldialog.h"
69 #include "flagrowobj.h"
71 #include "mapeditor.h"
76 #include "showtextdialog.h"
77 #include "texteditor.h"
80 extern TextEditor *textEditor;
81 extern Main *mainWindow;
82 extern QString tmpVymDir;
83 extern QString clipboardDir;
84 extern bool clipboardEmpty;
85 extern int statusbarTime;
86 extern FlagRowObj* standardFlagsDefault;
87 extern FlagRowObj* systemFlagsDefault;
89 extern QPtrList <QAction> actionListBranches;
91 extern QAction* actionFileSave;
92 extern QAction* actionFilePrint;
93 extern QAction* actionEditUndo;
94 extern QAction* actionEditRedo;
95 extern QAction *actionEditCopy;
96 extern QAction *actionEditCut;
97 extern QAction *actionEditPaste;
98 extern QAction *actionEditMoveUp;
99 extern QAction *actionEditMoveDown;
100 extern QAction *actionEditToggleScroll;
101 extern QAction* actionEditOpenURL;
102 extern QAction* actionEditURL;
103 extern QAction* actionEditHeading2URL;
104 extern QAction* actionEditBugzilla2URL;
105 extern QAction* actionEditFATE2URL;
106 extern QAction *actionEditOpenVymLink;
107 extern QAction *actionEditVymLink;
108 extern QAction *actionEditDeleteVymLink;
109 extern QAction *actionEditMapInfo;
110 extern QAction *actionEditHeading;
111 extern QAction *actionEditDelete;
112 extern QAction *actionEditAddBranch;
113 extern QAction *actionEditAddBranchHere;
114 extern QAction *actionEditAddBranchAbove;
115 extern QAction *actionEditAddBranchBelow;
116 extern QAction *actionEditRemoveBranchHere;
117 extern QAction *actionEditRemoveChilds;
118 extern QAction *actionEditImportAdd;
119 extern QAction *actionEditImportReplace;
120 extern QAction *actionEditSaveBranch;
121 extern QAction *actionEditSelectFirst;
122 extern QAction *actionEditSelectLast;
123 extern QAction *actionEditLoadImage;
124 extern QAction *actionEditToggleFloatExport;
126 extern QAction* actionFormatColor;
127 extern QAction* actionFormatPickColor;
128 extern QAction* actionFormatColorBranch;
129 extern QAction* actionFormatColorSubtree;
130 extern QAction* actionFormatLinkColorHint;
131 extern QAction* actionFormatBackColor;
132 extern QAction* actionFormatLinkColor;
133 extern QAction *actionFormatIncludeImagesVer;
134 extern QAction *actionFormatIncludeImagesHor;
136 extern QActionGroup* actionGroupModModes;
137 extern QAction* actionModModeColor;
138 extern QAction* actionModModeLink;
139 extern QAction* actionModModeCopy;
141 extern QActionGroup *actionGroupFormatFrameTypes;
142 extern QAction *actionFormatFrameNone;
143 extern QAction *actionFormatFrameRectangle;
145 extern QActionGroup *actionGroupFormatLinkStyles;
146 extern QAction *actionFormatLinkStyleLine;
147 extern QAction *actionFormatLinkStyleParabel;
148 extern QAction *actionFormatLinkStylePolyLine;
149 extern QAction *actionFormatLinkStylePolyParabel;
150 extern QAction *actionFormatHideLinkUnselected;
152 extern QAction *actionViewToggleNoteEditor;
154 extern QAction* actionSettingsAutoedit;
155 extern QAction* actionSettingsAutoselectHeading;
156 extern QAction* actionSettingsAutoselectHeading;
157 extern QAction* actionSettingsAutoselectText;
158 extern QAction* actionSettingsPasteNewHeading;
159 extern QAction* actionSettingsUseDelKey;
160 extern QAction* actionSettingsUseFlagGroups;
162 extern QPopupMenu* branchContextMenu;
163 extern QPopupMenu* branchAddContextMenu;
164 extern QPopupMenu* branchRemoveContextMenu;
165 extern QPopupMenu* branchLinksContextMenu;
166 extern QPopupMenu* branchLinksContextMenuDup;
167 extern QPopupMenu* floatimageContextMenu;
168 extern QPopupMenu* saveImageFormatMenu;
169 extern QPopupMenu* canvasContextMenu;
170 extern QPopupMenu* lastMapsMenu;
171 extern QPopupMenu* importMenu;
172 extern QPopupMenu* exportMenu;
173 extern QPopupMenu* exportImageFormatMenu;
176 extern Settings settings;
177 extern Options options;
179 #if defined(Q_OS_LINUX)
180 extern void qt_wait_for_window_manager( QWidget* w );
183 Main::Main(QWidget* parent, const char* name, WFlags f) :
184 QMainWindow(parent,name,f)
188 setCaption ("VYM - View Your Mind");
190 // Load window settings
191 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
192 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
193 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
194 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
197 // Create unique temporary directory
198 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
200 // Create direcctory for clipboard
201 clipboardDir=tmpVymDir+"/clipboard";
202 QDir d(clipboardDir);
203 d.mkdir (clipboardDir,true);
204 makeSubDirs (clipboardDir);
207 // FIXME not used currently
208 // Set random seed (random used for object IDs)
209 // QTime t = QTime::currentTime(); // set random seed
210 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
213 // Initialize some settings, which are platform dependant
216 // application to open URLs
217 p="/vym/mainwindow/readerURL";
218 #if defined(Q_OS_LINUX)
219 s=settings.readEntry (p,"konqueror");
221 #if defined(Q_OS_MACX)
222 s=settings.readEntry (p,"/usr/bin/open");
224 s=settings.readEntry (p,"mozilla");
227 settings.writeEntry( p,s);
229 // application to open PDFs
230 p="/vym/mainwindow/readerPDF";
231 #if defined(Q_OS_LINUX)
232 s=settings.readEntry (p,"acroread");
234 #if defined(Q_OS_MACX)
235 s=settings.readEntry (p,"/usr/bin/open");
237 s=settings.readEntry (p,"acroread");
240 settings.writeEntry( p,s);
245 // Create tab widget which holds the maps
246 tabWidget= new QTabWidget (this);
247 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
248 this, SLOT( editorChanged( QWidget * ) ) );
250 setCentralWidget(tabWidget);
254 setupFormatActions();
258 setupSettingsActions();
260 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
263 // After menu is created, we can enable some actions
264 actionFilePrint->setEnabled (true);
269 // Initialize Find window
270 findWindow=new FindWindow(NULL,"findwindow");
271 connect (findWindow, SIGNAL( findButton(QString) ),
272 this, SLOT(editFind(QString) ) );
273 connect (findWindow, SIGNAL( somethingChanged() ),
274 this, SLOT(editFindChanged() ) );
276 // Connect TextEditor, so that we can update flags if text changes
277 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
285 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
286 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
287 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
288 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
290 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
291 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
293 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
294 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
295 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
296 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
297 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
298 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
301 int maps=lastMaps.count();
302 settings.writeEntry( "/vym/lastMaps/number",maps );
303 for (int i=1;i<=maps;i++)
305 QStringList::Iterator it = lastMaps.at(i-1);
306 s=QString("/vym/lastMaps/map-%1").arg(i);
307 if (!s.isEmpty() && i<=maxLastMaps)
308 settings.writeEntry (s, *it);
312 // To make the texteditor save its settings, call the destructor
315 // Remove temporary directory
316 removeDir (QDir(tmpVymDir));
319 void Main::loadCmdLine()
321 /* TODO draw some kind of splashscreen while loading...
327 QStringList flist=options.getFileList();
328 QStringList::Iterator it=flist.begin();
330 while (it !=flist.end() )
332 fileLoad (*it, NewMap);
338 void Main::statusMessage(const QString &s)
340 statusBar()->message (s);
343 void Main::closeEvent (QCloseEvent* )
349 void Main::setupFileActions()
351 QToolBar *tb = new QToolBar( this );
352 tb->setLabel( "File Actions" );
353 QPopupMenu *menu = new QPopupMenu( this );
354 menuBar()->insertItem( tr( "&File" ), menu );
356 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
359 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
360 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
364 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
365 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
369 lastMapsMenu = new QPopupMenu (this);
371 menu->insertItem (tr("Open Recent"),lastMapsMenu );
372 menu->insertSeparator();
374 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
375 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
380 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
381 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
384 menu->insertSeparator();
386 importMenu = new QPopupMenu (this);
387 menu->insertItem (tr("Import"),importMenu );
389 a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
390 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
391 a->addTo (importMenu);
393 a = new QAction( tr( "Import")+" "+tr("Mind Manager" ), QPixmap(), tr("Mind Manager"), 0, this, "importMM" );
394 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
395 a->addTo (importMenu);
397 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
398 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
399 a->addTo( importMenu);
401 exportMenu = new QPopupMenu (this);
402 menu->insertItem (tr("Export"),exportMenu );
404 menu->insertSeparator();
407 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
408 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
413 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
414 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
417 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
418 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
424 void Main::setupEditActions()
426 QToolBar *tb = new QToolBar( this );
427 tb->setLabel( "Edit Actions" );
428 QPopupMenu *menu = new QPopupMenu( this );
429 menuBar()->insertItem( tr( "&Edit" ), menu );
433 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
434 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
435 a->setEnabled (false);
440 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
442 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
443 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
448 menu->insertSeparator();
449 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
450 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
451 a->setEnabled (false);
455 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
456 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
457 a->setEnabled (false);
461 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
462 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
463 a->setEnabled (false);
468 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
469 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
470 a->setEnabled (false);
473 actionListBranches.append(a);
476 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
477 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
478 a->setEnabled (false);
481 actionListBranches.append(a);
482 actionEditMoveDown=a;
485 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
486 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
487 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
488 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
489 #if defined(Q_OS_MACX)
490 actionEditToggleScroll=alt;
492 actionEditToggleScroll=a;
494 actionEditToggleScroll->setEnabled (false);
495 actionEditToggleScroll->addTo( tb );
496 actionEditToggleScroll->addTo( menu );
497 actionListBranches.append(actionEditToggleScroll);
499 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
500 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
503 menu->insertSeparator();
505 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
506 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
509 menu->insertSeparator();
511 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
512 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
514 a->setEnabled (false);
517 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
518 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
519 a->setEnabled (false);
520 actionListBranches.append(a);
523 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
524 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
525 a->setEnabled (false);
526 actionListBranches.append(a);
527 actionEditHeading2URL=a;
529 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
530 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
531 a->setEnabled (false);
532 actionListBranches.append(a);
533 actionEditBugzilla2URL=a;
535 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
536 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
537 a->setEnabled (false);
538 actionListBranches.append(a);
539 actionEditFATE2URL=a;
541 a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flag_vymlink_xpm), tr( "Jump to map" ), 0, this, "jumpMap" );
542 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
544 a->setEnabled (false);
545 actionEditOpenVymLink=a;
547 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
548 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
549 a->setEnabled (false);
550 actionListBranches.append(a);
553 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
554 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
555 a->setEnabled (false);
556 actionEditDeleteVymLink=a;
558 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
559 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
560 a->setEnabled (true);
563 menu->insertSeparator();
565 // Shortcuts to modify heading:
566 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
567 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
568 actionListBranches.append(a);
569 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
570 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
571 actionListBranches.append(a);
573 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
574 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
575 a->setEnabled (false);
577 actionListBranches.append(a);
579 // Shortcut to delete selection
580 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
581 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
582 a->setEnabled (false);
585 // Shortcut to add branch
586 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
587 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
588 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
589 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
590 a->setEnabled (false);
591 actionListBranches.append(a);
592 #if defined (Q_OS_MACX)
593 // In OSX show different shortcut in menues, the keys work independtly always
594 actionEditAddBranch=alt;
596 actionEditAddBranch=a;
599 // Add branch by inserting it at selection
600 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
601 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
602 a->setEnabled (false);
603 actionListBranches.append(a);
604 actionEditAddBranchHere=a;
605 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
606 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
607 actionListBranches.append(a);
610 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
611 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
612 a->setEnabled (false);
613 actionListBranches.append(a);
614 actionEditAddBranchAbove=a;
615 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
616 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
617 actionListBranches.append(a);
620 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
621 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
622 a->setEnabled (false);
623 actionListBranches.append(a);
624 actionEditAddBranchBelow=a;
625 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
626 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
627 actionListBranches.append(a);
629 // Import at selection (adding to selection)
630 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
631 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 actionEditImportAdd=a;
636 // Import at selection (replacing selection)
637 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
638 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
639 a->setEnabled (false);
640 actionListBranches.append(a);
641 actionEditImportReplace=a;
644 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
645 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
646 a->setEnabled (false);
647 actionListBranches.append(a);
648 actionEditSaveBranch=a;
650 // Only remove branch, not its childs
651 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
652 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
653 a->setEnabled (false);
654 actionListBranches.append(a);
655 actionEditRemoveBranchHere=a;
657 // Only remove childs of a branch
658 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
659 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
660 a->setEnabled (false);
661 actionListBranches.append(a);
662 actionEditRemoveChilds=a;
664 // Shortcuts for navigating with cursor:
665 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
666 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
667 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
668 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
669 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
670 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
671 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
672 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
673 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
674 a->setEnabled (false);
676 actionListBranches.append(a);
677 actionEditSelectFirst=a;
678 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
679 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
680 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
681 a->setEnabled (false);
683 actionListBranches.append(a);
684 actionEditSelectLast=a;
686 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
687 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
688 actionEditLoadImage=a;
693 void Main::setupFormatActions()
695 QPopupMenu *menu = new QPopupMenu( this );
696 menuBar()->insertItem( tr( "&Format" ), menu );
698 QToolBar *tb = new QToolBar( this );
702 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
703 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
704 actionFormatColor->addTo( tb );
705 actionFormatColor->addTo( menu );
706 a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(formatcolorpicker_xpm), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" );
707 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
708 a->setEnabled (false);
711 actionListBranches.append(a);
712 actionFormatPickColor=a;
713 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
714 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
715 a->setEnabled (false);
718 actionListBranches.append(a);
719 actionFormatColorBranch=a;
720 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
721 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
722 a->setEnabled (false);
725 actionListBranches.append(a);
726 actionFormatColorSubtree=a;
728 menu->insertSeparator();
729 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
730 actionGroupFormatLinkStyles->setExclusive (true);
731 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
732 a->setToggleAction(true);
733 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
734 actionFormatLinkStyleLine=a;
735 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
736 a->setToggleAction(true);
737 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
738 actionFormatLinkStyleParabel=a;
739 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
740 a->setToggleAction(true);
741 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
742 actionFormatLinkStylePolyLine=a;
743 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
744 a->setToggleAction(true);
745 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
746 actionFormatLinkStylePolyParabel=a;
747 actionGroupFormatLinkStyles->addTo (menu);
749 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
750 actionGroupFormatFrameTypes->setExclusive (true);
751 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
752 a->setToggleAction(true);
753 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
754 actionFormatFrameNone=a;
755 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
756 a->setToggleAction(true);
757 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
758 actionFormatFrameRectangle=a;
760 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
761 a->setToggleAction(true);
762 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
763 actionFormatIncludeImagesVer=a;
765 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
766 a->setToggleAction(true);
767 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
768 actionFormatIncludeImagesHor=a;
770 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
771 a->setToggleAction(true);
772 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
773 actionFormatHideLinkUnselected=a;
775 menu->insertSeparator();
776 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
777 a->setToggleAction(true);
778 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
780 actionFormatLinkColorHint=a;
782 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
783 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
784 actionFormatLinkColor->addTo( menu );
785 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
786 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
787 actionFormatBackColor->addTo( menu );
791 void Main::setupViewActions()
793 QToolBar *tb = new QToolBar( this );
794 tb->setLabel( "View Actions" );
795 QPopupMenu *menu = new QPopupMenu( this );
796 menuBar()->insertItem( tr( "&View" ), menu );
799 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
800 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
803 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
804 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
807 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
808 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
811 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
812 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
813 a->setToggleAction(true);
814 if (textEditor->showWithMain())
820 actionViewToggleNoteEditor=a;
821 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
822 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
824 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
825 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
830 void Main::setupModeActions()
832 //QPopupMenu *menu = new QPopupMenu( this );
833 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
835 QToolBar *tb = new QToolBar( this );
836 tb->setLabel( tr ("Modes when using modifiers") );
838 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
839 actionGroupModModes->setExclusive (true);
840 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
841 a->setToggleAction(true);
844 actionModModeColor=a;
846 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
847 a->setToggleAction(true);
851 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
852 a->setToggleAction(true);
858 void Main::setupFlagActions()
860 // Create System Flags
861 systemFlagsDefault = new FlagRowObj ();
862 systemFlagsDefault->setVisibility (false);
863 systemFlagsDefault->setName ("systemFlagsDef");
865 FlagObj *fo = new FlagObj ();
866 fo->load(QPixmap(flag_note_xpm));
868 fo->setToolTip(tr("Note","Systemflag"));
869 systemFlagsDefault->addFlag (fo); // makes deep copy
871 fo->load(QPixmap(flag_url_xpm));
873 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
874 systemFlagsDefault->addFlag (fo);
876 fo->load(QPixmap(flag_vymlink_xpm));
877 fo->setName("vymLink");
878 fo->setToolTip(tr("Link to another vym map","Systemflag"));
879 systemFlagsDefault->addFlag (fo);
881 fo->load(QPixmap(flag_scrolled_right_xpm));
882 fo->setName("scrolledright");
883 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
884 systemFlagsDefault->addFlag (fo);
886 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
887 fo->setName("tmpUnscrolledright");
888 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
889 systemFlagsDefault->addFlag (fo);
891 // Create Standard Flags
892 standardFlagsDefault = new FlagRowObj ();
893 standardFlagsDefault->setVisibility (false);
894 standardFlagsDefault->setName ("standardFlagsDef");
896 fo->load(QPixmap(flag_exclamationmark_xpm));
897 fo->setName ("exclamationmark");
898 fo->setGroup("standard-mark");
899 fo->setToolTip(tr("Take care!","Standardflag"));
900 standardFlagsDefault->addFlag (fo); // makes deep copy
902 fo->load(QPixmap(flag_questionmark_xpm));
903 fo->setName("questionmark");
904 fo->setGroup("standard-mark");
905 fo->setToolTip(tr("Really?","Standardflag"));
906 standardFlagsDefault->addFlag (fo);
908 fo->load(QPixmap(flag_hook_green_xpm));
909 fo->setName("hook-green");
910 fo->setGroup("standard-hook");
911 fo->setToolTip(tr("ok!","Standardflag"));
912 standardFlagsDefault->addFlag (fo);
914 fo->load(QPixmap(flag_cross_red_xpm));
915 fo->setName("cross-red");
916 fo->setGroup("standard-hook");
917 fo->setToolTip(tr("Not ok!","Standardflag"));
918 standardFlagsDefault->addFlag (fo);
920 fo->load(QPixmap(flag_stopsign_xpm));
921 fo->setName("stopsign");
922 fo->setToolTip(tr("This won't work!","Standardflag"));
923 standardFlagsDefault->addFlag (fo);
925 fo->load(QPixmap(flag_smiley_good_xpm));
926 fo->setName("smiley-good");
927 fo->setGroup("standard-smiley");
928 fo->setToolTip(tr("Good","Standardflag"));
929 standardFlagsDefault->addFlag (fo);
931 fo->load(QPixmap(flag_smiley_sad_xpm));
932 fo->setName("smiley-sad");
933 fo->setGroup("standard-smiley");
934 fo->setToolTip(tr("Bad","Standardflag"));
935 standardFlagsDefault->addFlag (fo);
937 fo->load(QPixmap(flag_clock_xpm));
938 fo->setName("clock");
939 fo->setToolTip(tr("Time critical","Standardflag"));
940 standardFlagsDefault->addFlag (fo);
942 fo->load(QPixmap(flag_lamp_xpm));
944 fo->setToolTip(tr("Idea!","Standardflag"));
945 standardFlagsDefault->addFlag (fo);
947 fo->load(QPixmap(flag_arrow_up_xpm));
948 fo->setName("arrow-up");
949 fo->setGroup("standard-arrow");
950 fo->setToolTip(tr("Important","Standardflag"));
951 standardFlagsDefault->addFlag (fo);
953 fo->load(QPixmap(flag_arrow_down_xpm));
954 fo->setName("arrow-down");
955 fo->setGroup("standard-arrow");
956 fo->setToolTip(tr("Unimportant","Standardflag"));
957 standardFlagsDefault->addFlag (fo);
959 fo->load(QPixmap(flag_thumb_up_xpm));
960 fo->setName("thumb-up");
961 fo->setGroup("standard-thumb");
962 fo->setToolTip(tr("I like this","Standardflag"));
963 standardFlagsDefault->addFlag (fo);
965 fo->load(QPixmap(flag_thumb_down_xpm));
966 fo->setName("thumb-down");
967 fo->setGroup("standard-thumb");
968 fo->setToolTip(tr("I like this","Standardflag"));
969 fo->setToolTip(tr("I do not like this","Standardflag"));
970 standardFlagsDefault->addFlag (fo);
972 fo->load(QPixmap(flag_heart_xpm));
973 fo->setName("heart");
974 fo->setToolTip(tr("I just love... ","Standardflag"));
975 standardFlagsDefault->addFlag (fo);
977 fo->load(QPixmap(flag_flash_xpm));
978 fo->setName("flash");
979 fo->setToolTip(tr("Dangerous","Standardflag"));
980 standardFlagsDefault->addFlag (fo);
982 fo->load(QPixmap(flag_lifebelt_xpm));
983 fo->setName("lifebelt");
984 fo->setToolTip(tr("This will help","Standardflag"));
985 standardFlagsDefault->addFlag (fo);
988 standardFlagsDefault->makeToolbar(this, "Standard Flags");
992 void Main::setupSettingsActions()
994 QPopupMenu *menu = new QPopupMenu( this );
995 menuBar()->insertItem( tr( "&Settings" ), menu );
1000 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1001 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1004 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1005 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1008 menu->insertSeparator();
1009 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1010 a->setToggleAction(true);
1011 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1013 actionSettingsAutoedit=a;
1015 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1016 a->setToggleAction(true);
1017 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1019 actionSettingsAutoselectHeading=a;
1021 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1022 a->setToggleAction(true);
1023 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1025 actionSettingsAutoselectText=a;
1027 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1028 a->setToggleAction(true);
1029 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1031 actionSettingsPasteNewHeading=a;
1033 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1034 a->setToggleAction(true);
1035 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1037 actionSettingsUseDelKey=a;
1039 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1040 a->setToggleAction(true);
1041 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1043 actionSettingsUseFlagGroups=a;
1047 void Main::setupTestActions()
1049 QPopupMenu *menu = new QPopupMenu( this );
1050 menuBar()->insertItem( tr( "&Test" ), menu );
1053 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1054 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1059 void Main::setupHelpActions()
1061 QPopupMenu *menu = new QPopupMenu( this );
1062 menuBar()->insertItem( tr( "&Help" ), menu );
1065 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1066 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1069 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1070 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1073 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1074 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1079 void Main::setupContextMenus()
1083 // Context Menu for branch or mapcenter
1084 branchContextMenu =new QPopupMenu (this);
1087 branchAddContextMenu =new QPopupMenu (this);
1088 actionEditPaste->addTo ( branchAddContextMenu );
1089 actionEditAddBranch->addTo ( branchAddContextMenu );
1090 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1091 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1092 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1093 branchAddContextMenu->insertSeparator();
1094 actionEditLoadImage->addTo( branchAddContextMenu );
1095 branchAddContextMenu->insertSeparator();
1096 actionEditImportAdd->addTo ( branchAddContextMenu );
1097 actionEditImportReplace->addTo ( branchAddContextMenu );
1100 branchRemoveContextMenu =new QPopupMenu (this);
1101 actionEditCut->addTo ( branchRemoveContextMenu );
1102 actionEditDelete->addTo ( branchRemoveContextMenu );
1103 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
1104 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1106 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1107 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1109 actionEditSaveBranch->addTo( branchContextMenu );
1111 branchContextMenu->insertSeparator();
1112 actionEditOpenURL->addTo ( branchContextMenu );
1113 actionEditURL->addTo ( branchContextMenu );
1114 actionEditHeading2URL->addTo ( branchContextMenu );
1115 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1117 actionEditBugzilla2URL->addTo( branchContextMenu );
1118 actionEditFATE2URL->addTo( branchContextMenu );
1120 branchContextMenu->insertSeparator();
1121 actionEditOpenVymLink->addTo ( branchContextMenu );
1122 actionEditVymLink->addTo ( branchContextMenu );
1123 actionEditDeleteVymLink->addTo ( branchContextMenu );
1125 branchContextMenu->insertSeparator();
1126 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1128 branchContextMenu->insertSeparator();
1129 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1130 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1131 // FIXME not implemented yet
1132 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1133 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1135 // Context Menu for links in a branch menu
1136 // This will be populated "on demand" in MapEditor::updateActions
1137 branchContextMenu->insertSeparator();
1138 branchLinksContextMenu =new QPopupMenu (this);
1139 branchLinksContextMenuDup =new QPopupMenu (this);
1140 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1141 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1143 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1144 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1146 // Context menu for floatimage
1147 floatimageContextMenu =new QPopupMenu (this);
1148 saveImageFormatMenu=new QPopupMenu (this);
1149 exportImageFormatMenu=new QPopupMenu (this);
1151 QStrList fmt = QImage::outputFormats();
1152 for (const char* f = fmt.first(); f; f = fmt.next())
1154 saveImageFormatMenu->insertItem( f );
1155 exportImageFormatMenu->insertItem( f );
1157 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1158 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1159 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1161 floatimageContextMenu->insertSeparator();
1162 actionEditCopy->addTo( floatimageContextMenu );
1163 actionEditCut->addTo( floatimageContextMenu );
1165 floatimageContextMenu->insertSeparator();
1166 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1167 a->setToggleAction(true);
1168 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1169 a->addTo( floatimageContextMenu);
1170 actionEditToggleFloatExport=a;
1172 floatimageContextMenu->insertSeparator();
1173 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1175 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1176 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1177 a->addTo (exportMenu);
1179 exportMenu->insertItem ( tr("Export as Image"),exportImageFormatMenu);
1181 a = new QAction( tr( "Export as ASCII")+" "+tr("(still experimental)" ), QPixmap(), "ASCII...", 0, this, "exportASCII" );
1182 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1183 a->addTo( exportMenu );
1185 a = new QAction( tr( "Export as LaTeX")+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1186 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1187 a->addTo( exportMenu );
1189 a = new QAction( tr( "Export as XML" ), QPixmap(), "XML...", 0, this, "exportXML" );
1190 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1191 a->addTo( exportMenu );
1193 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1195 a = new QAction( tr( "Export as HTML" ), QPixmap(), "HTML...", 0, this, "exportHTML");
1196 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1197 a->addTo( exportMenu );
1200 a = new QAction( tr( "Export as XHTML" ), QPixmap(), "XHTML...", ALT + Key_X, this, "exportXHTML" );
1201 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1202 a->addTo( exportMenu );
1205 // Context menu for canvas
1206 canvasContextMenu =new QPopupMenu (this);
1207 actionEditMapInfo->addTo( canvasContextMenu );
1208 canvasContextMenu->insertSeparator();
1209 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1210 canvasContextMenu->insertSeparator();
1211 actionFormatLinkColorHint->addTo( canvasContextMenu );
1212 actionFormatLinkColor->addTo( canvasContextMenu );
1213 actionFormatBackColor->addTo( canvasContextMenu );
1215 // Menu for last opened files
1216 // Read settings initially
1218 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1219 for (int i=1;i<=j;i++)
1221 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1222 if (!s.isEmpty() && j<=maxLastMaps)
1225 setupLastMapsMenu();
1226 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1229 void Main::setupLastMapsMenu()
1231 // Remove double entries
1232 QStringList::Iterator it=lastMaps.begin();
1233 QStringList::Iterator jt;
1234 while (it!=lastMaps.end() )
1238 while (jt!=lastMaps.end() )
1241 jt=lastMaps.remove(jt);
1248 // Limit length of list to maxLastMaps
1249 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1251 // build Menu from lastMaps string list
1252 lastMapsMenu->clear();
1253 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1254 lastMapsMenu->insertItem (*it );
1258 void Main::hideEvent (QHideEvent * )
1260 if (!textEditor->isMinimized() ) textEditor->hide();
1263 void Main::showEvent (QShowEvent * )
1265 if (textEditor->showWithMain()) textEditor->showNormal();
1268 bool Main::reallyWriteDirectory(const QString &dir)
1270 QStringList eList = QDir(dir).entryList();
1271 if (eList.first() ==".") eList.pop_front(); // remove "."
1272 if (eList.first() =="..") eList.pop_front(); // remove "."
1273 if (!eList.isEmpty())
1275 QMessageBox mb( __VYM,
1276 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1277 QMessageBox::Warning,
1279 QMessageBox::Cancel | QMessageBox::Default,
1280 QMessageBox::QMessageBox::NoButton );
1282 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1283 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1286 case QMessageBox::Yes:
1289 case QMessageBox::Cancel:
1297 QString Main::browseDirectory (const QString &caption)
1299 QFileDialog fd(this,caption);
1300 fd.setMode (QFileDialog::DirectoryOnly);
1301 fd.setCaption(__VYM " - "+caption);
1304 if ( fd.exec() == QDialog::Accepted )
1305 return fd.selectedFile();
1310 MapEditor* Main::currentMapEditor() const
1312 if ( tabWidget->currentPage() &&
1313 tabWidget->currentPage()->inherits( "MapEditor" ) )
1314 return (MapEditor*)tabWidget->currentPage();
1318 //TODO not used now, maybe use this for overview window later
1319 void Main::newView()
1321 // Open a new view... have it delete when closed.
1322 Main *m = new Main(0, 0, WDestructiveClose);
1323 qApp->setMainWidget(m);
1325 qApp->setMainWidget(0);
1328 void Main::editorChanged(QWidget *)
1330 // Unselect all possibly selected objects
1331 // (Important to update note editor)
1334 for (i=0;i<=tabWidget->count() -1;i++)
1337 me=(MapEditor*)tabWidget->page(i);
1340 currentMapEditor()->reselect();
1342 // Update actions to in menus and toolbars according to editor
1343 currentMapEditor()->updateActions();
1346 void Main::fileNew()
1348 QString fn="unnamed";
1349 MapEditor* medit = new MapEditor (tabWidget, true);
1350 tabWidget->addTab (medit,fn);
1351 tabWidget->showPage(medit);
1352 medit->viewport()->setFocus();
1353 // For the very first map we do not have flagrows yet...
1354 medit->select("mc:");
1357 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1359 ErrorCode err=success;
1361 // fn is usually the archive, mapfile the file after uncompressing
1364 // Make fn absolute (needed for unzip)
1365 fn=QDir (fn).absPath();
1371 // Check, if map is already loaded
1373 while (i<=tabWidget->count() -1)
1375 me=(MapEditor*)tabWidget->page(i);
1376 if (me->getFilePath() == fn)
1378 // Already there, ask for confirmation
1379 QMessageBox mb( __VYM,
1380 tr("The map %1\nis already opened."
1381 "Opening the same map in multiple editors may lead \n"
1382 "to confusion when finishing working with vym."
1383 "Do you want to").arg(fn),
1384 QMessageBox::Warning,
1385 QMessageBox::Yes | QMessageBox::Default,
1386 QMessageBox::Cancel | QMessageBox::Escape,
1387 QMessageBox::QMessageBox::NoButton);
1388 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1389 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1392 case QMessageBox::Yes:
1394 i=tabWidget->count();
1396 case QMessageBox::Cancel:
1408 if ( !fn.isEmpty() )
1410 me = currentMapEditor();
1411 int tabIndex=tabWidget->currentPageIndex();
1412 // Check first, if mapeditor exists
1413 // If it is not default AND we want a new map,
1414 // create a new mapeditor in a new tab
1415 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1417 me = new MapEditor (tabWidget,true);
1418 tabWidget->addTab (me,fn);
1419 tabIndex=tabWidget->indexOf (me);
1420 tabWidget->setCurrentPage (tabIndex);
1423 // Check, if file exists (important for creating new files
1424 // from command line
1425 if (!QFile(fn).exists() )
1427 QMessageBox mb( __VYM,
1428 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1429 QMessageBox::Question,
1431 QMessageBox::Cancel | QMessageBox::Default,
1432 QMessageBox::QMessageBox::NoButton );
1434 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1435 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1438 case QMessageBox::Yes:
1440 currentMapEditor()->setFilePath(fn);
1441 tabWidget->setTabLabel (currentMapEditor(),
1442 currentMapEditor()->getFileName() );
1443 statusBar()->message( "Created " + fn , statusbarTime );
1446 case QMessageBox::Cancel:
1447 // don't create new map
1448 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1455 //tabWidget->currentPage() won't be NULL here, because of above...
1456 tabWidget->showPage(me);
1457 me->viewport()->setFocus();
1459 // Create temporary directory for packing
1460 char tmpdir1[]="/tmp/vym-XXXXXX";
1461 QString tmpMapDir=mkdtemp(tmpdir1);
1463 // Try to unzip file
1464 err=unzipDir (tmpMapDir,fn);
1468 me->setZipped(false);
1471 me->setZipped(true);
1473 // Look for mapname.xml
1474 mapfile= fn.left(fn.findRev(".",-1,true));
1475 mapfile=mapfile.section( '/', -1 );
1476 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1477 if (!file.exists() )
1479 // mapname.xml does not exist, well,
1480 // maybe some renamed the mapname.vym file...
1481 // Try to find any .xml in the toplevel
1482 // directory of the .vym file
1483 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1484 if (flist.count()==1)
1486 // Only one entry, take this one
1487 mapfile=tmpMapDir + "/"+flist.first();
1490 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1491 *it=tmpMapDir + "/" + *it;
1492 // TODO Multiple entries, load all (but only the first one into this ME)
1493 //mainWindow->fileLoadFromTmp (flist);
1494 //returnCode=1; // Silently forget this attempt to load
1495 qWarning ("MainWindow::load (fn) multimap found...");
1498 if (flist.isEmpty() )
1500 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1501 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1504 } //file doesn't exist
1506 mapfile=file.name();
1511 // Save existing filename in case we import
1512 QString fn_org=me->getFilePath();
1514 // Finally load map into mapEditor
1515 me->setFilePath (mapfile,fn);
1516 err=me->load(mapfile,lmode);
1518 // Restore old (maybe empty) filepath, if this is an import
1520 me->setFilePath (fn_org);
1523 // Finally check for errors and go home
1526 if (lmode==NewMap) fileCloseMap();
1527 statusBar()->message( "Could not load " + fn, statusbarTime );
1532 me->setFilePath (fn);
1533 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1534 if (fn.left(9)!="/tmp/vym-")
1536 // Only append to lastMaps if not loaded from a tmpDir
1537 // e.g. imported bookmarks are in a tmpDir
1538 lastMaps.prepend(me->getFilePath() );
1539 setupLastMapsMenu();
1541 actionFilePrint->setEnabled (true);
1543 statusBar()->message( "Loaded " + fn, statusbarTime );
1547 removeDir (QDir(tmpMapDir));
1553 void Main::fileLoad(const LoadMode &lmode)
1555 QFileDialog *fd=new QFileDialog( this);
1556 if (!lastFileDir.isEmpty())
1557 fd->setDir (lastFileDir);
1558 fd->setMode (QFileDialog::ExistingFiles);
1559 fd->addFilter ("XML (*.xml)");
1560 fd->addFilter ("VYM map (*.vym *.vyp)");
1564 fd->setCaption(tr("Load vym map"));
1567 fd->setCaption(tr("Import: Add vym map to selection"));
1570 fd->setCaption(tr("Import: Replace selection with vym map"));
1576 if ( fd->exec() == QDialog::Accepted )
1578 lastFileDir=fd->dirPath();
1579 QStringList flist = fd->selectedFiles();
1580 QStringList::Iterator it = flist.begin();
1581 while( it != flist.end() )
1584 fileLoad(*it, lmode);
1591 void Main::fileLoad()
1596 void Main::fileLoadLast(int i)
1598 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1601 void Main::fileSave(const SaveMode &savemode)
1603 // tmp dir for zipping
1607 ErrorCode err=success;
1609 QString safeFilePath;
1611 bool saveZipped=currentMapEditor()->saveZipped();
1613 MapEditor * me=currentMapEditor();
1616 QString fn=me->getFilePath();
1617 // filename=unnamed, filepath="" in constructor...
1618 if ( !fn.isEmpty() )
1620 // We have a filepath, go on saving
1621 // First remove existing file, we
1622 // don't want to add to old zip archives
1626 QMessageBox::warning( 0, tr( "Save Error" ),
1627 fn+ tr("\ncould not be removed before saving"));
1629 // Look, if we should zip the data:
1632 QMessageBox mb( __VYM,
1633 tr("The map %1\ndid not use the compressed "
1634 "vym file format.\nWriting it uncompressed will also write images \n"
1635 "and flags and thus may overwrite files in the "
1636 "given directory\n\nDo you want to write the map").arg(fn),
1637 QMessageBox::Warning,
1638 QMessageBox::Yes | QMessageBox::Default,
1640 QMessageBox::Cancel | QMessageBox::Escape);
1641 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1642 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1643 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1646 case QMessageBox::Yes:
1647 // save compressed (default file format)
1650 case QMessageBox::No:
1651 // save uncompressed
1654 case QMessageBox::Cancel:
1663 char tmpdir1[]="/tmp/vym-XXXXXX";
1664 tmpMapDir=mkdtemp(tmpdir1);
1666 safeFilePath=me->getFilePath();
1667 me->setFilePath (tmpMapDir+"/"+
1668 me->getMapName()+ ".xml",
1670 me->save (savemode);
1671 me->setFilePath (safeFilePath);
1673 zipDir (tmpMapDir,fn);
1678 safeFilePath=me->getFilePath();
1679 me->setFilePath (fn, safeFilePath);
1680 me->save (savemode);
1681 me->setFilePath (safeFilePath);
1683 } // filepath available
1686 // We have no filepath yet,
1687 // call fileSaveAs() now, this will call fileSave()
1689 fileSaveAs(savemode);
1693 if (me->saveZipped())
1696 removeDir (QDir(tmpMapDir));
1701 statusBar()->message(
1702 tr("Saved %1").arg(me->getFilePath()),
1704 lastMaps.prepend(me->getFilePath() );
1705 setupLastMapsMenu();
1707 statusBar()->message(
1708 tr("Couldn't save ").arg(me->getFilePath()),
1712 void Main::fileSave()
1714 fileSave (CompleteMap);
1717 void Main::fileSaveAs(const SaveMode& savemode)
1722 if (currentMapEditor())
1724 if (savemode==CompleteMap)
1725 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1727 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1728 if ( !fn.isEmpty() )
1730 // Check for existing file
1731 if (QFile (fn).exists())
1733 QMessageBox mb( __VYM,
1734 tr("The file %1\nexists already. Do you want to").arg(fn),
1735 QMessageBox::Warning,
1736 QMessageBox::Yes | QMessageBox::Default,
1737 QMessageBox::Cancel | QMessageBox::Escape,
1738 QMessageBox::QMessageBox::NoButton);
1739 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1740 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1743 case QMessageBox::Yes:
1746 case QMessageBox::Cancel:
1753 // New file, add extension to filename, if missing
1754 // This is always .vym or .vyp, depending on savemode
1755 if (savemode==CompleteMap)
1757 if (!fn.contains (".vym") && !fn.contains (".xml"))
1761 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1770 currentMapEditor()->setFilePath(fn);
1774 if (savemode==CompleteMap)
1775 tabWidget->setTabLabel (currentMapEditor(),
1776 currentMapEditor()->getFileName() );
1782 void Main::fileSaveAs()
1784 fileSaveAs (CompleteMap);
1787 void Main::fileImportKDEBookmarks()
1789 ImportKDEBookmarks im;
1791 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1792 currentMapEditor()->setFilePath ("");
1795 void Main::fileImportMM()
1799 QFileDialog *fd=new QFileDialog( this);
1800 if (!lastFileDir.isEmpty())
1801 fd->setDir (lastFileDir);
1802 fd->setMode (QFileDialog::ExistingFiles);
1803 fd->addFilter ("Mind Manager (*.mmap)");
1804 fd->setCaption(tr("Import")+" "+"Mind Manager");
1807 if ( fd->exec() == QDialog::Accepted )
1809 lastFileDir=fd->dirPath();
1810 QStringList flist = fd->selectedFiles();
1811 QStringList::Iterator it = flist.begin();
1812 while( it != flist.end() )
1815 if (im.transform() &&
1816 success==fileLoad (im.getTransformedFile(),NewMap) &&
1817 currentMapEditor() )
1818 currentMapEditor()->setFilePath ("");
1827 void Main::fileImportDir()
1829 if (currentMapEditor())
1830 currentMapEditor()->importDir();
1833 void Main::fileExportXML()
1835 if (currentMapEditor())
1837 QString dir=browseDirectory(tr("Export XML to directory"));
1838 if (dir !="" && reallyWriteDirectory(dir) )
1839 currentMapEditor()->exportXML(dir);
1843 void Main::fileExportHTML()
1845 if (currentMapEditor())
1847 ExportHTMLDialog dia(this);
1849 if (dia.exec()==QDialog::Accepted)
1851 QString dir=dia.getDir();
1852 if (reallyWriteDirectory(dir) )
1854 currentMapEditor()->exportXML (dia.getDir() );
1855 dia.doExport(currentMapEditor()->getMapName() );
1861 void Main::fileExportXHTML()
1864 if (currentMapEditor())
1866 ExportXHTMLDialog dia(this);
1867 dia.setFilePath (currentMapEditor()->getFilePath() );
1868 dia.setMapName (currentMapEditor()->getMapName() );
1871 if (dia.exec()==QDialog::Accepted)
1873 QString dir=dia.getDir();
1874 // Check, if warnings should be used before overwriting
1875 // the output directory
1878 ok=reallyWriteDirectory(dir);
1884 currentMapEditor()->exportXML (dia.getDir() );
1885 dia.doExport(currentMapEditor()->getMapName() );
1886 if (dia.hasChanged())
1887 currentMapEditor()->setChanged();
1893 void Main::fileExportImage(int item)
1895 if (currentMapEditor())
1897 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1899 if ( !fn.isEmpty() )
1900 currentMapEditor()->exportImage(fn,item);
1902 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1907 void Main::fileExportASCII()
1909 if (currentMapEditor())
1910 currentMapEditor()->exportASCII();
1913 void Main::fileExportLaTeX()
1915 if (currentMapEditor())
1916 currentMapEditor()->exportLaTeX();
1919 void Main::fileExportOOPresentation()
1921 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to Open Office"));
1922 // FIXME add extra info in dialog
1923 //ImagePreview *p =new ImagePreview (fd);
1924 //fd->setContentsPreviewEnabled( TRUE );
1925 //fd->setContentsPreview( p, p );
1926 //fd->setPreviewMode( QFileDialog::Contents );
1927 fd->setCaption(__VYM " - " +tr("Export to Open Office"));
1928 //fd->setDir (lastImageDir);
1931 if ( fd->exec() == QDialog::Accepted )
1933 QString fn=fd->selectedFile();
1934 //lastImageDir=fn.left(fn.findRev ("/"));
1935 if (currentMapEditor())
1936 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
1940 void Main::fileCloseMap()
1942 if (currentMapEditor())
1944 if (currentMapEditor()->hasChanged())
1946 QMessageBox mb( __VYM,
1947 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1948 QMessageBox::Warning,
1949 QMessageBox::Yes | QMessageBox::Default,
1951 QMessageBox::Cancel | QMessageBox::Escape );
1952 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1953 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1956 case QMessageBox::Yes:
1958 fileSave(CompleteMap);
1960 case QMessageBox::No:
1961 // close without saving
1963 case QMessageBox::Cancel:
1968 currentMapEditor()->closeMap();
1969 tabWidget->removePage(currentMapEditor());
1970 if (tabWidget->count()==0)
1971 actionFilePrint->setEnabled (false);
1975 void Main::filePrint()
1977 if (currentMapEditor())
1978 currentMapEditor()->print();
1981 void Main::fileExitVYM()
1983 // Check if one or more editors have changed
1986 for (i=0;i<=tabWidget->count() -1;i++)
1989 me=(MapEditor*)tabWidget->page(i);
1991 // If something changed, ask what to do
1992 if (me->isUnsaved())
1994 tabWidget->setCurrentPage(i);
1995 QMessageBox mb( __VYM,
1996 tr("This map is not saved yet. Do you want to"),
1997 QMessageBox::Warning,
1998 QMessageBox::Yes | QMessageBox::Default,
2000 QMessageBox::Cancel | QMessageBox::Escape );
2001 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2002 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2004 // Call undocumented function: setActiveWindow is only
2005 // possible, if widget is visible. This depends on
2007 #if defined(Q_OS_LINUX)
2008 qt_wait_for_window_manager( this);
2010 mb.setActiveWindow();
2011 switch( mb.exec() ) {
2012 case QMessageBox::Yes:
2013 // save (the changed editors) and exit
2014 fileSave(CompleteMap);
2016 case QMessageBox::No:
2017 // exit without saving
2019 case QMessageBox::Cancel:
2020 // don't save and don't exit
2024 } // loop over all MEs
2028 void Main::editUndo()
2030 if (currentMapEditor())
2031 currentMapEditor()->undo();
2034 void Main::editRedo()
2036 if (currentMapEditor())
2037 currentMapEditor()->redo();
2040 void Main::editCopy()
2042 if (currentMapEditor())
2043 currentMapEditor()->copy();
2046 void Main::editPaste()
2048 if (currentMapEditor())
2049 currentMapEditor()->paste();
2052 void Main::editCut()
2054 if (currentMapEditor())
2055 currentMapEditor()->cut();
2058 void Main::editOpenFindWindow()
2060 findWindow->popup();
2061 findWindow->raise();
2063 // Call undocumented function: setActiveWindow is only
2064 // possible, if widget is visible. This depends on
2066 #if defined(Q_OS_LINUX)
2067 qt_wait_for_window_manager( this);
2069 findWindow->setActiveWindow();
2072 void Main::editFind(QString s)
2075 BranchObj *bo=currentMapEditor()->findText(s, cs);
2078 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2081 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2082 tr("No matches found for <b>%1</b>").arg(s));
2086 void Main::editFindChanged()
2087 { // Notify editor, to abort the current find process
2088 currentMapEditor()->findReset();
2091 void Main::editOpenURL()
2093 if (currentMapEditor())
2094 currentMapEditor()->openURL();
2097 void Main::editURL()
2099 if (currentMapEditor())
2100 currentMapEditor()->editURL();
2103 void Main::editHeading2URL()
2105 if (currentMapEditor())
2106 currentMapEditor()->editHeading2URL();
2109 void Main::editBugzilla2URL()
2111 if (currentMapEditor())
2112 currentMapEditor()->editBugzilla2URL();
2115 void Main::editFATE2URL()
2117 if (currentMapEditor())
2118 currentMapEditor()->editFATE2URL();
2121 void Main::editOpenVymLink()
2123 // Get current path to map
2124 QString currentVymLink;
2125 if (currentMapEditor())
2127 currentVymLink=currentMapEditor()->getVymLink();
2128 // compare path with already loaded maps
2132 for (i=0;i<=tabWidget->count() -1;i++)
2134 me=(MapEditor*)tabWidget->page(i);
2135 if (currentVymLink==me->getFilePath() )
2144 if (!QFile(currentVymLink).exists() )
2145 QMessageBox::critical( 0, tr( "Critical Error" ),
2146 tr("Couldn't open map %1").arg(currentVymLink));
2149 fileLoad (currentVymLink, NewMap);
2150 tabWidget->setCurrentPage (tabWidget->count()-1);
2153 // Go to tab containing the map
2154 tabWidget->setCurrentPage (index);
2158 void Main::editVymLink()
2160 if (currentMapEditor())
2161 currentMapEditor()->editVymLink();
2164 void Main::editDeleteVymLink()
2166 if (currentMapEditor())
2167 currentMapEditor()->deleteVymLink();
2170 void Main::editMapInfo()
2172 if (currentMapEditor())
2173 currentMapEditor()->editMapInfo();
2176 void Main::editMoveUp()
2178 if (currentMapEditor())
2179 currentMapEditor()->moveBranchUp();
2182 void Main::editMoveDown()
2184 if (currentMapEditor())
2185 currentMapEditor()->moveBranchDown();
2188 void Main::editToggleScroll()
2190 if (currentMapEditor())
2192 currentMapEditor()->toggleScroll();
2196 void Main::editUnScrollAll()
2198 if (currentMapEditor())
2200 currentMapEditor()->unScrollAll();
2204 void Main::editHeading()
2206 if (currentMapEditor())
2207 currentMapEditor()->editHeading();
2210 void Main::editNewBranch()
2212 if (currentMapEditor())
2213 currentMapEditor()->addNewBranch(0);
2216 void Main::editNewBranchHere()
2218 if (currentMapEditor())
2219 currentMapEditor()->addNewBranchHere();
2222 void Main::editNewBranchAbove()
2224 if (currentMapEditor())
2225 currentMapEditor()->addNewBranch(-1);
2228 void Main::editNewBranchBelow()
2230 if (currentMapEditor())
2231 currentMapEditor()->addNewBranch(1);
2234 void Main::editImportAdd()
2236 fileLoad (ImportAdd);
2239 void Main::editImportReplace()
2241 fileLoad (ImportReplace);
2244 void Main::editSaveBranch()
2246 fileSaveAs (PartOfMap);
2249 void Main::editRemoveBranchHere()
2251 if (currentMapEditor())
2252 currentMapEditor()->removeBranchHere();
2255 void Main::editRemoveChilds()
2257 if (currentMapEditor())
2258 currentMapEditor()->removeChilds();
2261 void Main::editDeleteSelection()
2263 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2264 currentMapEditor()->deleteSelection();
2267 void Main::editUpperBranch()
2269 if (currentMapEditor())
2270 currentMapEditor()->selectUpperBranch();
2273 void Main::editLowerBranch()
2275 if (currentMapEditor())
2276 currentMapEditor()->selectLowerBranch();
2279 void Main::editLeftBranch()
2281 if (currentMapEditor())
2282 currentMapEditor()->selectLeftBranch();
2285 void Main::editRightBranch()
2287 if (currentMapEditor())
2288 currentMapEditor()->selectRightBranch();
2291 void Main::editFirstBranch()
2293 if (currentMapEditor())
2294 currentMapEditor()->selectFirstBranch();
2297 void Main::editLastBranch()
2299 if (currentMapEditor())
2300 currentMapEditor()->selectLastBranch();
2303 void Main::editLoadImage()
2305 if (currentMapEditor())
2306 currentMapEditor()->loadFloatImage();
2309 void Main::editSaveImage(int item)
2311 if (currentMapEditor())
2312 currentMapEditor()->saveFloatImage(item);
2315 void Main::editToggleFloatExport()
2317 if (currentMapEditor())
2318 currentMapEditor()->toggleFloatExport();
2321 void Main::editFollowXLink(int item)
2323 if (currentMapEditor())
2324 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2327 void Main::editEditXLink(int item)
2329 if (currentMapEditor())
2330 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2333 void Main::formatSelectColor()
2335 if (currentMapEditor())
2337 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2338 if ( !col.isValid() ) return;
2339 currentMapEditor()->setColor( col );
2340 colorChanged( col );
2344 void Main::formatPickColor()
2346 if (currentMapEditor())
2347 colorChanged( currentMapEditor()->pickColor() );
2350 void Main::colorChanged(QColor c)
2352 QPixmap pix( 16, 16 );
2354 actionFormatColor->setIconSet( pix );
2357 void Main::formatColorItem()
2359 if (currentMapEditor())
2360 currentMapEditor()->colorItem();
2363 void Main::formatColorBranch()
2365 if (currentMapEditor())
2366 currentMapEditor()->colorBranch();
2369 void Main::formatLinkStyleLine()
2371 if (currentMapEditor())
2372 currentMapEditor()->setLinkStyle(StyleLine);
2375 void Main::formatLinkStyleParabel()
2377 if (currentMapEditor())
2378 currentMapEditor()->setLinkStyle(StyleParabel);
2381 void Main::formatLinkStylePolyLine()
2383 if (currentMapEditor())
2384 currentMapEditor()->setLinkStyle(StylePolyLine);
2387 void Main::formatLinkStylePolyParabel()
2389 if (currentMapEditor())
2390 currentMapEditor()->setLinkStyle(StylePolyParabel);
2393 void Main::formatSelectBackColor()
2395 if (currentMapEditor())
2396 currentMapEditor()->selectBackgroundColor();
2399 void Main::formatSelectLinkColor()
2401 if (currentMapEditor())
2402 currentMapEditor()->selectLinkColor();
2405 void Main::formatToggleLinkColorHint()
2407 currentMapEditor()->toggleLinkColorHint();
2410 void Main::formatFrameNone()
2412 if (currentMapEditor())
2413 currentMapEditor()->setFrame(NoFrame);
2416 void Main::formatFrameRectangle()
2418 if (currentMapEditor())
2419 currentMapEditor()->setFrame(Rectangle);
2422 void Main::formatIncludeImagesVer()
2424 if (currentMapEditor())
2425 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2428 void Main::formatIncludeImagesHor()
2430 if (currentMapEditor())
2431 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2434 void Main::formatHideLinkUnselected()
2436 if (currentMapEditor())
2437 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2440 void Main::viewZoomReset()
2442 if (currentMapEditor())
2446 currentMapEditor()->setWorldMatrix( m );
2447 currentMapEditor()->setViewCenter();
2448 currentMapEditor()->adjustCanvasSize();
2452 void Main::viewZoomIn()
2454 if (currentMapEditor())
2456 QWMatrix m = currentMapEditor()->worldMatrix();
2457 m.scale( 1.25, 1.25 );
2458 currentMapEditor()->setWorldMatrix( m );
2459 currentMapEditor()->setViewCenter();
2460 currentMapEditor()->adjustCanvasSize();
2464 void Main::viewZoomOut()
2466 if (currentMapEditor())
2468 QWMatrix m = currentMapEditor()->worldMatrix();
2469 m.scale( 0.8, 0.8 );
2470 currentMapEditor()->setWorldMatrix( m );
2471 currentMapEditor()->setViewCenter();
2472 currentMapEditor()->adjustCanvasSize();
2476 void Main::modModeColor()
2480 void Main::modModeLink()
2484 bool Main::settingsPDF()
2486 // Default browser is set in constructor
2488 QString text = QInputDialog::getText(
2489 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2490 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2492 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2497 bool Main::settingsURL()
2499 // Default browser is set in constructor
2501 QString text = QInputDialog::getText(
2502 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2503 settings.readEntry("/vym/mainwindow/readerURL")
2506 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2510 void Main::windowToggleNoteEditor()
2512 if (textEditor->showWithMain() )
2513 windowHideNoteEditor();
2515 windowShowNoteEditor();
2518 void Main::updateNoteFlag()
2520 if (currentMapEditor())
2521 currentMapEditor()->updateNoteFlag();
2524 void Main::windowShowNoteEditor()
2526 textEditor->setShowWithMain(true);
2528 actionViewToggleNoteEditor->setOn (true);
2531 void Main::windowHideNoteEditor()
2533 textEditor->setShowWithMain(false);
2535 actionViewToggleNoteEditor->setOn (false);
2538 void Main::windowNextEditor()
2540 if (tabWidget->currentPageIndex() < tabWidget->count())
2541 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2544 void Main::windowPreviousEditor()
2546 if (tabWidget->currentPageIndex() >0)
2547 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2550 void Main::standardFlagChanged()
2552 currentMapEditor()->toggleStandardFlag(sender()->name());
2555 void Main::testFunction()
2557 currentMapEditor()->testFunction();
2560 void Main::helpDoc()
2563 #if defined(Q_OS_MACX)
2564 docpath="./vym.app/Contents/vym.pdf";
2566 // default path in SUSE LINUX
2567 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2570 if (!QFile (docpath).exists() )
2572 // relative path for easy testing in tarball
2573 docpath="doc/vym.pdf";
2574 if (!QFile (docpath).exists() )
2576 // relative path for testing while still writing vym.tex
2577 docpath="doc/tex/vym.pdf";
2578 if (!QFile (docpath).exists() )
2580 // Try yet another one for Knoppix
2581 docpath="/usr/share/doc/packages/vym/vym.pdf";
2582 if (!QFile (docpath).exists() )
2584 QMessageBox::critical(0,
2585 tr("Critcal error"),
2586 tr("Couldn't find the documentation\n"
2587 "vym.pdf in various places."));
2594 Process *pdfProc = new Process();
2595 pdfProc->clearArguments();
2596 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2597 pdfProc->addArgument( docpath);
2599 if ( !pdfProc->start() )
2602 QMessageBox::critical(0,
2603 tr("Critcal error"),
2604 tr("Couldn't find a viewer to read vym.pdf.\n"
2605 "Please use Settings->")+tr("Set application to open pdf files"));
2611 void Main::helpAbout()
2614 ad.setName ("aboutwindow");
2615 ad.setMinimumSize(500,500);
2616 ad.resize (QSize (500,500));
2620 void Main::helpAboutQT()
2622 QMessageBox::aboutQt( this, "Qt Application Example" );