hide export for floatimages.
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"
68 #include "exportxhtmldialog.h"
70 #include "flagrowobj.h"
72 #include "mapeditor.h"
77 #include "showtextdialog.h"
78 #include "texteditor.h"
81 extern TextEditor *textEditor;
82 extern Main *mainWindow;
83 extern QString tmpVymDir;
84 extern QString clipboardDir;
85 extern bool clipboardEmpty;
86 extern int statusbarTime;
87 extern FlagRowObj* standardFlagsDefault;
88 extern FlagRowObj* systemFlagsDefault;
90 extern QPtrList <QAction> actionListBranches;
92 extern QAction* actionFileSave;
93 extern QAction* actionFilePrint;
94 extern QAction* actionEditUndo;
95 extern QAction* actionEditRedo;
96 extern QAction *actionEditCopy;
97 extern QAction *actionEditCut;
98 extern QAction *actionEditPaste;
99 extern QAction *actionEditMoveUp;
100 extern QAction *actionEditMoveDown;
101 extern QAction *actionEditToggleScroll;
102 extern QAction* actionEditOpenURL;
103 extern QAction* actionEditURL;
104 extern QAction* actionEditHeading2URL;
105 extern QAction* actionEditBugzilla2URL;
106 extern QAction* actionEditFATE2URL;
107 extern QAction *actionEditOpenVymLink;
108 extern QAction *actionEditVymLink;
109 extern QAction *actionEditDeleteVymLink;
110 extern QAction *actionEditToggleHideExport;
111 extern QAction *actionEditMapInfo;
112 extern QAction *actionEditHeading;
113 extern QAction *actionEditDelete;
114 extern QAction *actionEditAddBranch;
115 extern QAction *actionEditAddBranchHere;
116 extern QAction *actionEditAddBranchAbove;
117 extern QAction *actionEditAddBranchBelow;
118 extern QAction *actionEditRemoveBranchHere;
119 extern QAction *actionEditRemoveChilds;
120 extern QAction *actionEditImportAdd;
121 extern QAction *actionEditImportReplace;
122 extern QAction *actionEditSaveBranch;
123 extern QAction *actionEditSelectFirst;
124 extern QAction *actionEditSelectLast;
125 extern QAction *actionEditLoadImage;
126 extern QAction *actionEditToggleFloatExport;
128 extern QAction* actionFormatColor;
129 extern QAction* actionFormatPickColor;
130 extern QAction* actionFormatColorBranch;
131 extern QAction* actionFormatColorSubtree;
132 extern QAction* actionFormatLinkColorHint;
133 extern QAction* actionFormatBackColor;
134 extern QAction* actionFormatLinkColor;
135 extern QAction *actionFormatIncludeImagesVer;
136 extern QAction *actionFormatIncludeImagesHor;
138 extern QActionGroup* actionGroupModModes;
139 extern QAction* actionModModeColor;
140 extern QAction* actionModModeLink;
141 extern QAction* actionModModeCopy;
143 extern QActionGroup *actionGroupFormatFrameTypes;
144 extern QAction *actionFormatFrameNone;
145 extern QAction *actionFormatFrameRectangle;
147 extern QActionGroup *actionGroupFormatLinkStyles;
148 extern QAction *actionFormatLinkStyleLine;
149 extern QAction *actionFormatLinkStyleParabel;
150 extern QAction *actionFormatLinkStylePolyLine;
151 extern QAction *actionFormatLinkStylePolyParabel;
152 extern QAction *actionFormatHideLinkUnselected;
154 extern QAction *actionViewToggleNoteEditor;
156 extern QAction* actionSettingsAutoedit;
157 extern QAction* actionSettingsAutoselectHeading;
158 extern QAction* actionSettingsAutoselectHeading;
159 extern QAction* actionSettingsAutoselectText;
160 extern QAction* actionSettingsPasteNewHeading;
161 extern QAction* actionSettingsUseDelKey;
162 extern QAction* actionSettingsUseFlagGroups;
164 extern QPopupMenu* branchContextMenu;
165 extern QPopupMenu* branchAddContextMenu;
166 extern QPopupMenu* branchRemoveContextMenu;
167 extern QPopupMenu* branchLinksContextMenu;
168 extern QPopupMenu* branchLinksContextMenuDup;
169 extern QPopupMenu* floatimageContextMenu;
170 extern QPopupMenu* saveImageFormatMenu;
171 extern QPopupMenu* canvasContextMenu;
172 extern QPopupMenu* lastMapsMenu;
173 extern QPopupMenu* importMenu;
174 extern QPopupMenu* exportMenu;
175 extern QPopupMenu* exportImageFormatMenu;
178 extern Settings settings;
179 extern Options options;
181 #if defined(Q_OS_LINUX)
182 extern void qt_wait_for_window_manager( QWidget* w );
185 Main::Main(QWidget* parent, const char* name, WFlags f) :
186 QMainWindow(parent,name,f)
190 setCaption ("VYM - View Your Mind");
192 // Load window settings
193 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
194 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
195 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
196 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
199 // Create unique temporary directory
200 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
202 // Create direcctory for clipboard
203 clipboardDir=tmpVymDir+"/clipboard";
204 QDir d(clipboardDir);
205 d.mkdir (clipboardDir,true);
206 makeSubDirs (clipboardDir);
209 // FIXME not used currently
210 // Set random seed (random used for object IDs)
211 // QTime t = QTime::currentTime(); // set random seed
212 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
215 // Initialize some settings, which are platform dependant
218 // application to open URLs
219 p="/vym/mainwindow/readerURL";
220 #if defined(Q_OS_LINUX)
221 s=settings.readEntry (p,"konqueror");
223 #if defined(Q_OS_MACX)
224 s=settings.readEntry (p,"/usr/bin/open");
226 s=settings.readEntry (p,"mozilla");
229 settings.writeEntry( p,s);
231 // application to open PDFs
232 p="/vym/mainwindow/readerPDF";
233 #if defined(Q_OS_LINUX)
234 s=settings.readEntry (p,"acroread");
236 #if defined(Q_OS_MACX)
237 s=settings.readEntry (p,"/usr/bin/open");
239 s=settings.readEntry (p,"acroread");
242 settings.writeEntry( p,s);
247 // Create tab widget which holds the maps
248 tabWidget= new QTabWidget (this);
249 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
250 this, SLOT( editorChanged( QWidget * ) ) );
252 setCentralWidget(tabWidget);
256 setupFormatActions();
260 setupSettingsActions();
262 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
265 // After menu is created, we can enable some actions
266 actionFilePrint->setEnabled (true);
271 // Initialize Find window
272 findWindow=new FindWindow(NULL,"findwindow");
273 connect (findWindow, SIGNAL( findButton(QString) ),
274 this, SLOT(editFind(QString) ) );
275 connect (findWindow, SIGNAL( somethingChanged() ),
276 this, SLOT(editFindChanged() ) );
278 // Connect TextEditor, so that we can update flags if text changes
279 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
287 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
288 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
289 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
290 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
292 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
293 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
295 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
296 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
297 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
298 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
299 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
300 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
303 int maps=lastMaps.count();
304 settings.writeEntry( "/vym/lastMaps/number",maps );
305 for (int i=1;i<=maps;i++)
307 QStringList::Iterator it = lastMaps.at(i-1);
308 s=QString("/vym/lastMaps/map-%1").arg(i);
309 if (!s.isEmpty() && i<=maxLastMaps)
310 settings.writeEntry (s, *it);
314 // To make the texteditor save its settings, call the destructor
317 // Remove temporary directory
318 removeDir (QDir(tmpVymDir));
321 void Main::loadCmdLine()
323 /* TODO draw some kind of splashscreen while loading...
329 QStringList flist=options.getFileList();
330 QStringList::Iterator it=flist.begin();
332 while (it !=flist.end() )
334 fileLoad (*it, NewMap);
340 void Main::statusMessage(const QString &s)
342 statusBar()->message (s);
345 void Main::closeEvent (QCloseEvent* )
351 void Main::setupFileActions()
353 QToolBar *tb = new QToolBar( this );
354 tb->setLabel( "File Actions" );
355 QPopupMenu *menu = new QPopupMenu( this );
356 menuBar()->insertItem( tr( "&File" ), menu );
358 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
361 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
362 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
366 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
367 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
371 lastMapsMenu = new QPopupMenu (this);
373 menu->insertItem (tr("Open Recent"),lastMapsMenu );
374 menu->insertSeparator();
376 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
377 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
382 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
383 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
386 menu->insertSeparator();
388 importMenu = new QPopupMenu (this);
389 menu->insertItem (tr("Import"),importMenu );
391 a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
392 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
393 a->addTo (importMenu);
395 a = new QAction( tr( "Import")+" Mind Manager" , QPixmap(), "Mind Manager...", 0, this, "importMM" );
396 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
397 a->addTo (importMenu);
399 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
400 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
401 a->addTo( importMenu);
403 exportMenu = new QPopupMenu (this);
404 menu->insertItem (tr("Export"),exportMenu );
406 menu->insertSeparator();
409 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" );
410 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
415 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
416 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
419 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
420 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
426 void Main::setupEditActions()
428 QToolBar *tb = new QToolBar( this );
429 tb->setLabel( "Edit Actions" );
430 QPopupMenu *menu = new QPopupMenu( this );
431 menuBar()->insertItem( tr( "&Edit" ), menu );
435 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
436 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
437 a->setEnabled (false);
442 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
444 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
445 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
450 menu->insertSeparator();
451 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
452 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
453 a->setEnabled (false);
457 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
458 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
459 a->setEnabled (false);
463 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
464 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
465 a->setEnabled (false);
470 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
471 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
472 a->setEnabled (false);
475 actionListBranches.append(a);
478 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
479 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
480 a->setEnabled (false);
483 actionListBranches.append(a);
484 actionEditMoveDown=a;
487 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
488 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
489 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
490 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
491 #if defined(Q_OS_MACX)
492 actionEditToggleScroll=alt;
494 actionEditToggleScroll=a;
496 actionEditToggleScroll->setEnabled (false);
497 actionEditToggleScroll->addTo( tb );
498 actionEditToggleScroll->addTo( menu );
499 actionListBranches.append(actionEditToggleScroll);
501 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
502 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
505 menu->insertSeparator();
507 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
508 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
511 menu->insertSeparator();
513 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
514 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
516 a->setEnabled (false);
519 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
520 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
521 a->setEnabled (false);
522 actionListBranches.append(a);
525 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
526 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
527 a->setEnabled (false);
528 actionListBranches.append(a);
529 actionEditHeading2URL=a;
531 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
532 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
533 a->setEnabled (false);
534 actionListBranches.append(a);
535 actionEditBugzilla2URL=a;
537 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
538 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
539 a->setEnabled (false);
540 actionListBranches.append(a);
541 actionEditFATE2URL=a;
543 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" );
544 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
546 a->setEnabled (false);
547 actionEditOpenVymLink=a;
549 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
550 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
551 a->setEnabled (false);
552 actionListBranches.append(a);
555 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
556 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
557 a->setEnabled (false);
558 actionEditDeleteVymLink=a;
560 a = new QAction( tr( "Hide object in exports" ), QPixmap("icons/flag-hideexport.png"), tr( "Hide in exports" ), 0, this, "hideExport" );
561 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
562 a->setToggleAction(true);
564 a->setEnabled (false);
565 actionEditToggleHideExport=a;
567 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
568 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
569 a->setEnabled (true);
572 menu->insertSeparator();
574 // Shortcuts to modify heading:
575 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
576 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
577 actionListBranches.append(a);
578 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
579 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
580 actionListBranches.append(a);
582 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
583 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
584 a->setEnabled (false);
586 actionListBranches.append(a);
588 // Shortcut to delete selection
589 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
590 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
591 a->setEnabled (false);
594 // Shortcut to add branch
595 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
596 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
597 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
598 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
599 a->setEnabled (false);
600 actionListBranches.append(a);
601 #if defined (Q_OS_MACX)
602 // In OSX show different shortcut in menues, the keys work independtly always
603 actionEditAddBranch=alt;
605 actionEditAddBranch=a;
608 // Add branch by inserting it at selection
609 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
610 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
611 a->setEnabled (false);
612 actionListBranches.append(a);
613 actionEditAddBranchHere=a;
614 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
615 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
616 actionListBranches.append(a);
619 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
620 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
621 a->setEnabled (false);
622 actionListBranches.append(a);
623 actionEditAddBranchAbove=a;
624 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
625 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
626 actionListBranches.append(a);
629 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
630 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
631 a->setEnabled (false);
632 actionListBranches.append(a);
633 actionEditAddBranchBelow=a;
634 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
635 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
636 actionListBranches.append(a);
638 // Import at selection (adding to selection)
639 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
640 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
641 a->setEnabled (false);
642 actionListBranches.append(a);
643 actionEditImportAdd=a;
645 // Import at selection (replacing selection)
646 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
647 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
648 a->setEnabled (false);
649 actionListBranches.append(a);
650 actionEditImportReplace=a;
653 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
654 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
655 a->setEnabled (false);
656 actionListBranches.append(a);
657 actionEditSaveBranch=a;
659 // Only remove branch, not its childs
660 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
661 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
662 a->setEnabled (false);
663 actionListBranches.append(a);
664 actionEditRemoveBranchHere=a;
666 // Only remove childs of a branch
667 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
668 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
669 a->setEnabled (false);
670 actionListBranches.append(a);
671 actionEditRemoveChilds=a;
673 // Shortcuts for navigating with cursor:
674 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
675 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
676 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
677 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
678 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
679 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
680 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
681 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
682 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
683 a->setEnabled (false);
685 actionListBranches.append(a);
686 actionEditSelectFirst=a;
687 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
688 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
689 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
690 a->setEnabled (false);
692 actionListBranches.append(a);
693 actionEditSelectLast=a;
695 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
696 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
697 actionEditLoadImage=a;
702 void Main::setupFormatActions()
704 QPopupMenu *menu = new QPopupMenu( this );
705 menuBar()->insertItem( tr( "&Format" ), menu );
707 QToolBar *tb = new QToolBar( this );
711 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
712 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
713 actionFormatColor->addTo( tb );
714 actionFormatColor->addTo( menu );
715 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" );
716 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
717 a->setEnabled (false);
720 actionListBranches.append(a);
721 actionFormatPickColor=a;
722 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
723 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
724 a->setEnabled (false);
727 actionListBranches.append(a);
728 actionFormatColorBranch=a;
729 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
730 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
731 a->setEnabled (false);
734 actionListBranches.append(a);
735 actionFormatColorSubtree=a;
737 menu->insertSeparator();
738 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
739 actionGroupFormatLinkStyles->setExclusive (true);
740 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
741 a->setToggleAction(true);
742 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
743 actionFormatLinkStyleLine=a;
744 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
745 a->setToggleAction(true);
746 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
747 actionFormatLinkStyleParabel=a;
748 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
749 a->setToggleAction(true);
750 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
751 actionFormatLinkStylePolyLine=a;
752 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
753 a->setToggleAction(true);
754 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
755 actionFormatLinkStylePolyParabel=a;
756 actionGroupFormatLinkStyles->addTo (menu);
758 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
759 actionGroupFormatFrameTypes->setExclusive (true);
760 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
761 a->setToggleAction(true);
762 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
763 actionFormatFrameNone=a;
764 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
765 a->setToggleAction(true);
766 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
767 actionFormatFrameRectangle=a;
769 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
770 a->setToggleAction(true);
771 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
772 actionFormatIncludeImagesVer=a;
774 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
775 a->setToggleAction(true);
776 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
777 actionFormatIncludeImagesHor=a;
779 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
780 a->setToggleAction(true);
781 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
782 actionFormatHideLinkUnselected=a;
784 menu->insertSeparator();
785 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
786 a->setToggleAction(true);
787 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
789 actionFormatLinkColorHint=a;
791 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
792 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
793 actionFormatLinkColor->addTo( menu );
794 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
795 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
796 actionFormatBackColor->addTo( menu );
800 void Main::setupViewActions()
802 QToolBar *tb = new QToolBar( this );
803 tb->setLabel( "View Actions" );
804 QPopupMenu *menu = new QPopupMenu( this );
805 menuBar()->insertItem( tr( "&View" ), menu );
808 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
809 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
812 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
813 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
816 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
817 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
820 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
821 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
822 a->setToggleAction(true);
823 if (textEditor->showWithMain())
829 actionViewToggleNoteEditor=a;
830 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
831 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
833 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
834 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
839 void Main::setupModeActions()
841 //QPopupMenu *menu = new QPopupMenu( this );
842 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
844 QToolBar *tb = new QToolBar( this );
845 tb->setLabel( tr ("Modes when using modifiers") );
847 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
848 actionGroupModModes->setExclusive (true);
849 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
850 a->setToggleAction(true);
853 actionModModeColor=a;
855 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
856 a->setToggleAction(true);
860 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
861 a->setToggleAction(true);
867 void Main::setupFlagActions()
869 // Create System Flags
870 systemFlagsDefault = new FlagRowObj ();
871 systemFlagsDefault->setVisibility (false);
872 systemFlagsDefault->setName ("systemFlagsDef");
874 FlagObj *fo = new FlagObj ();
875 fo->load(QPixmap(flag_note_xpm));
877 fo->setToolTip(tr("Note","Systemflag"));
878 systemFlagsDefault->addFlag (fo); // makes deep copy
880 fo->load(QPixmap(flag_url_xpm));
882 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
883 systemFlagsDefault->addFlag (fo);
885 fo->load(QPixmap(flag_vymlink_xpm));
886 fo->setName("vymLink");
887 fo->setToolTip(tr("Link to another vym map","Systemflag"));
888 systemFlagsDefault->addFlag (fo);
890 fo->load(QPixmap(flag_scrolled_right_xpm));
891 fo->setName("scrolledright");
892 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
893 systemFlagsDefault->addFlag (fo);
895 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
896 fo->setName("tmpUnscrolledright");
897 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
898 systemFlagsDefault->addFlag (fo);
900 fo->load(QPixmap("icons/flag-hideexport.png"));
901 fo->setName("hideInExport");
902 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
903 systemFlagsDefault->addFlag (fo);
905 // Create Standard Flags
906 standardFlagsDefault = new FlagRowObj ();
907 standardFlagsDefault->setVisibility (false);
908 standardFlagsDefault->setName ("standardFlagsDef");
910 fo->load(QPixmap(flag_exclamationmark_xpm));
911 fo->setName ("exclamationmark");
912 fo->setGroup("standard-mark");
913 fo->setToolTip(tr("Take care!","Standardflag"));
914 standardFlagsDefault->addFlag (fo); // makes deep copy
916 fo->load(QPixmap(flag_questionmark_xpm));
917 fo->setName("questionmark");
918 fo->setGroup("standard-mark");
919 fo->setToolTip(tr("Really?","Standardflag"));
920 standardFlagsDefault->addFlag (fo);
922 fo->load(QPixmap(flag_hook_green_xpm));
923 fo->setName("hook-green");
924 fo->setGroup("standard-hook");
925 fo->setToolTip(tr("ok!","Standardflag"));
926 standardFlagsDefault->addFlag (fo);
928 fo->load(QPixmap(flag_cross_red_xpm));
929 fo->setName("cross-red");
930 fo->setGroup("standard-hook");
931 fo->setToolTip(tr("Not ok!","Standardflag"));
932 standardFlagsDefault->addFlag (fo);
934 fo->load(QPixmap(flag_stopsign_xpm));
935 fo->setName("stopsign");
936 fo->setToolTip(tr("This won't work!","Standardflag"));
937 standardFlagsDefault->addFlag (fo);
939 fo->load(QPixmap(flag_smiley_good_xpm));
940 fo->setName("smiley-good");
941 fo->setGroup("standard-smiley");
942 fo->setToolTip(tr("Good","Standardflag"));
943 standardFlagsDefault->addFlag (fo);
945 fo->load(QPixmap(flag_smiley_sad_xpm));
946 fo->setName("smiley-sad");
947 fo->setGroup("standard-smiley");
948 fo->setToolTip(tr("Bad","Standardflag"));
949 standardFlagsDefault->addFlag (fo);
951 fo->load(QPixmap(flag_clock_xpm));
952 fo->setName("clock");
953 fo->setToolTip(tr("Time critical","Standardflag"));
954 standardFlagsDefault->addFlag (fo);
956 fo->load(QPixmap(flag_lamp_xpm));
958 fo->setToolTip(tr("Idea!","Standardflag"));
959 standardFlagsDefault->addFlag (fo);
961 fo->load(QPixmap(flag_arrow_up_xpm));
962 fo->setName("arrow-up");
963 fo->setGroup("standard-arrow");
964 fo->setToolTip(tr("Important","Standardflag"));
965 standardFlagsDefault->addFlag (fo);
967 fo->load(QPixmap(flag_arrow_down_xpm));
968 fo->setName("arrow-down");
969 fo->setGroup("standard-arrow");
970 fo->setToolTip(tr("Unimportant","Standardflag"));
971 standardFlagsDefault->addFlag (fo);
973 fo->load(QPixmap(flag_thumb_up_xpm));
974 fo->setName("thumb-up");
975 fo->setGroup("standard-thumb");
976 fo->setToolTip(tr("I like this","Standardflag"));
977 standardFlagsDefault->addFlag (fo);
979 fo->load(QPixmap(flag_thumb_down_xpm));
980 fo->setName("thumb-down");
981 fo->setGroup("standard-thumb");
982 fo->setToolTip(tr("I like this","Standardflag"));
983 fo->setToolTip(tr("I do not like this","Standardflag"));
984 standardFlagsDefault->addFlag (fo);
986 fo->load(QPixmap(flag_heart_xpm));
987 fo->setName("heart");
988 fo->setToolTip(tr("I just love... ","Standardflag"));
989 standardFlagsDefault->addFlag (fo);
991 fo->load(QPixmap(flag_flash_xpm));
992 fo->setName("flash");
993 fo->setToolTip(tr("Dangerous","Standardflag"));
994 standardFlagsDefault->addFlag (fo);
996 fo->load(QPixmap(flag_lifebelt_xpm));
997 fo->setName("lifebelt");
998 fo->setToolTip(tr("This will help","Standardflag"));
999 standardFlagsDefault->addFlag (fo);
1003 standardFlagsDefault->makeToolbar(this, "Standard Flags");
1007 void Main::setupSettingsActions()
1009 QPopupMenu *menu = new QPopupMenu( this );
1010 menuBar()->insertItem( tr( "&Settings" ), menu );
1015 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1016 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1019 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1020 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1023 menu->insertSeparator();
1024 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1025 a->setToggleAction(true);
1026 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1028 actionSettingsAutoedit=a;
1030 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1031 a->setToggleAction(true);
1032 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1034 actionSettingsAutoselectHeading=a;
1036 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1037 a->setToggleAction(true);
1038 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1040 actionSettingsAutoselectText=a;
1042 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1043 a->setToggleAction(true);
1044 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1046 actionSettingsPasteNewHeading=a;
1048 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1049 a->setToggleAction(true);
1050 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1052 actionSettingsUseDelKey=a;
1054 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1055 a->setToggleAction(true);
1056 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1058 actionSettingsUseFlagGroups=a;
1062 void Main::setupTestActions()
1064 QPopupMenu *menu = new QPopupMenu( this );
1065 menuBar()->insertItem( tr( "&Test" ), menu );
1068 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1069 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1074 void Main::setupHelpActions()
1076 QPopupMenu *menu = new QPopupMenu( this );
1077 menuBar()->insertItem( tr( "&Help" ), menu );
1080 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1081 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1084 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1085 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1088 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1089 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1094 void Main::setupContextMenus()
1098 // Context Menu for branch or mapcenter
1099 branchContextMenu =new QPopupMenu (this);
1102 branchAddContextMenu =new QPopupMenu (this);
1103 actionEditPaste->addTo ( branchAddContextMenu );
1104 actionEditAddBranch->addTo ( branchAddContextMenu );
1105 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1106 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1107 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1108 branchAddContextMenu->insertSeparator();
1109 actionEditLoadImage->addTo( branchAddContextMenu );
1110 branchAddContextMenu->insertSeparator();
1111 actionEditImportAdd->addTo ( branchAddContextMenu );
1112 actionEditImportReplace->addTo ( branchAddContextMenu );
1115 branchRemoveContextMenu =new QPopupMenu (this);
1116 actionEditCut->addTo ( branchRemoveContextMenu );
1117 actionEditDelete->addTo ( branchRemoveContextMenu );
1118 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
1119 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1121 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1122 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1124 actionEditSaveBranch->addTo( branchContextMenu );
1126 branchContextMenu->insertSeparator();
1127 actionEditOpenURL->addTo ( branchContextMenu );
1128 actionEditURL->addTo ( branchContextMenu );
1129 actionEditHeading2URL->addTo ( branchContextMenu );
1130 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1132 actionEditBugzilla2URL->addTo( branchContextMenu );
1133 actionEditFATE2URL->addTo( branchContextMenu );
1135 branchContextMenu->insertSeparator();
1136 actionEditOpenVymLink->addTo ( branchContextMenu );
1137 actionEditVymLink->addTo ( branchContextMenu );
1138 actionEditDeleteVymLink->addTo ( branchContextMenu );
1140 branchContextMenu->insertSeparator();
1141 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1143 branchContextMenu->insertSeparator();
1144 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1145 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1146 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1148 // Context Menu for links in a branch menu
1149 // This will be populated "on demand" in MapEditor::updateActions
1150 branchContextMenu->insertSeparator();
1151 branchLinksContextMenu =new QPopupMenu (this);
1152 branchLinksContextMenuDup =new QPopupMenu (this);
1153 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1154 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1156 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1157 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1159 // Context menu for floatimage
1160 floatimageContextMenu =new QPopupMenu (this);
1161 saveImageFormatMenu=new QPopupMenu (this);
1162 exportImageFormatMenu=new QPopupMenu (this);
1164 QStrList fmt = QImage::outputFormats();
1165 for (const char* f = fmt.first(); f; f = fmt.next())
1167 saveImageFormatMenu->insertItem( f );
1168 exportImageFormatMenu->insertItem( f );
1170 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1171 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1172 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1174 floatimageContextMenu->insertSeparator();
1175 actionEditCopy->addTo( floatimageContextMenu );
1176 actionEditCut->addTo( floatimageContextMenu );
1178 floatimageContextMenu->insertSeparator();
1179 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1180 a->setToggleAction(true);
1181 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1182 a->addTo( floatimageContextMenu);
1183 actionEditToggleFloatExport=a;
1185 floatimageContextMenu->insertSeparator();
1186 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1188 exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1190 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1191 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1192 a->addTo (exportMenu);
1194 a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" );
1195 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1196 a->addTo( exportMenu );
1198 a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" );
1199 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1200 a->addTo( exportMenu );
1202 a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
1203 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1204 a->addTo (exportMenu);
1206 a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
1207 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1208 a->addTo( exportMenu );
1210 a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1211 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1212 a->addTo( exportMenu );
1214 a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" );
1215 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1216 a->addTo( exportMenu );
1218 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1220 a = new QAction( tr( "Export as")+" HTML" , QPixmap(), "HTML...", 0, this, "exportHTML");
1221 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1222 a->addTo( exportMenu );
1226 // Context menu for canvas
1227 canvasContextMenu =new QPopupMenu (this);
1228 actionEditMapInfo->addTo( canvasContextMenu );
1229 canvasContextMenu->insertSeparator();
1230 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1231 canvasContextMenu->insertSeparator();
1232 actionFormatLinkColorHint->addTo( canvasContextMenu );
1233 actionFormatLinkColor->addTo( canvasContextMenu );
1234 actionFormatBackColor->addTo( canvasContextMenu );
1236 // Menu for last opened files
1237 // Read settings initially
1239 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1240 for (int i=1;i<=j;i++)
1242 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1243 if (!s.isEmpty() && j<=maxLastMaps)
1246 setupLastMapsMenu();
1247 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1250 void Main::setupLastMapsMenu()
1252 // Remove double entries
1253 QStringList::Iterator it=lastMaps.begin();
1254 QStringList::Iterator jt;
1255 while (it!=lastMaps.end() )
1259 while (jt!=lastMaps.end() )
1262 jt=lastMaps.remove(jt);
1269 // Limit length of list to maxLastMaps
1270 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1272 // build Menu from lastMaps string list
1273 lastMapsMenu->clear();
1274 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1275 lastMapsMenu->insertItem (*it );
1279 void Main::hideEvent (QHideEvent * )
1281 if (!textEditor->isMinimized() ) textEditor->hide();
1284 void Main::showEvent (QShowEvent * )
1286 if (textEditor->showWithMain()) textEditor->showNormal();
1289 bool Main::reallyWriteDirectory(const QString &dir)
1291 QStringList eList = QDir(dir).entryList();
1292 if (eList.first() ==".") eList.pop_front(); // remove "."
1293 if (eList.first() =="..") eList.pop_front(); // remove "."
1294 if (!eList.isEmpty())
1296 QMessageBox mb( __VYM,
1297 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1298 QMessageBox::Warning,
1300 QMessageBox::Cancel | QMessageBox::Default,
1301 QMessageBox::QMessageBox::NoButton );
1303 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1304 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1307 case QMessageBox::Yes:
1310 case QMessageBox::Cancel:
1318 QString Main::browseDirectory (const QString &caption)
1320 QFileDialog fd(this,caption);
1321 fd.setMode (QFileDialog::DirectoryOnly);
1322 fd.setCaption(__VYM " - "+caption);
1325 if ( fd.exec() == QDialog::Accepted )
1326 return fd.selectedFile();
1331 MapEditor* Main::currentMapEditor() const
1333 if ( tabWidget->currentPage() &&
1334 tabWidget->currentPage()->inherits( "MapEditor" ) )
1335 return (MapEditor*)tabWidget->currentPage();
1339 //TODO not used now, maybe use this for overview window later
1340 void Main::newView()
1342 // Open a new view... have it delete when closed.
1343 Main *m = new Main(0, 0, WDestructiveClose);
1344 qApp->setMainWidget(m);
1346 qApp->setMainWidget(0);
1349 void Main::editorChanged(QWidget *)
1351 // Unselect all possibly selected objects
1352 // (Important to update note editor)
1355 for (i=0;i<=tabWidget->count() -1;i++)
1358 me=(MapEditor*)tabWidget->page(i);
1361 currentMapEditor()->reselect();
1363 // Update actions to in menus and toolbars according to editor
1364 currentMapEditor()->updateActions();
1367 void Main::fileNew()
1369 QString fn="unnamed";
1370 MapEditor* medit = new MapEditor (tabWidget, true);
1371 tabWidget->addTab (medit,fn);
1372 tabWidget->showPage(medit);
1373 medit->viewport()->setFocus();
1374 // For the very first map we do not have flagrows yet...
1375 medit->select("mc:");
1378 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1380 ErrorCode err=success;
1382 // fn is usually the archive, mapfile the file after uncompressing
1385 // Make fn absolute (needed for unzip)
1386 fn=QDir (fn).absPath();
1392 // Check, if map is already loaded
1394 while (i<=tabWidget->count() -1)
1396 me=(MapEditor*)tabWidget->page(i);
1397 if (me->getFilePath() == fn)
1399 // Already there, ask for confirmation
1400 QMessageBox mb( __VYM,
1401 tr("The map %1\nis already opened."
1402 "Opening the same map in multiple editors may lead \n"
1403 "to confusion when finishing working with vym."
1404 "Do you want to").arg(fn),
1405 QMessageBox::Warning,
1406 QMessageBox::Yes | QMessageBox::Default,
1407 QMessageBox::Cancel | QMessageBox::Escape,
1408 QMessageBox::QMessageBox::NoButton);
1409 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1410 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1413 case QMessageBox::Yes:
1415 i=tabWidget->count();
1417 case QMessageBox::Cancel:
1429 if ( !fn.isEmpty() )
1431 me = currentMapEditor();
1432 int tabIndex=tabWidget->currentPageIndex();
1433 // Check first, if mapeditor exists
1434 // If it is not default AND we want a new map,
1435 // create a new mapeditor in a new tab
1436 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1438 me = new MapEditor (tabWidget,true);
1439 tabWidget->addTab (me,fn);
1440 tabIndex=tabWidget->indexOf (me);
1441 tabWidget->setCurrentPage (tabIndex);
1444 // Check, if file exists (important for creating new files
1445 // from command line
1446 if (!QFile(fn).exists() )
1448 QMessageBox mb( __VYM,
1449 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1450 QMessageBox::Question,
1452 QMessageBox::Cancel | QMessageBox::Default,
1453 QMessageBox::QMessageBox::NoButton );
1455 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1456 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1459 case QMessageBox::Yes:
1461 currentMapEditor()->setFilePath(fn);
1462 tabWidget->setTabLabel (currentMapEditor(),
1463 currentMapEditor()->getFileName() );
1464 statusBar()->message( "Created " + fn , statusbarTime );
1467 case QMessageBox::Cancel:
1468 // don't create new map
1469 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1476 //tabWidget->currentPage() won't be NULL here, because of above...
1477 tabWidget->showPage(me);
1478 me->viewport()->setFocus();
1480 // Create temporary directory for packing
1481 char tmpdir1[]="/tmp/vym-XXXXXX";
1482 QString tmpMapDir=mkdtemp(tmpdir1);
1484 // Try to unzip file
1485 err=unzipDir (tmpMapDir,fn);
1489 me->setZipped(false);
1492 me->setZipped(true);
1494 // Look for mapname.xml
1495 mapfile= fn.left(fn.findRev(".",-1,true));
1496 mapfile=mapfile.section( '/', -1 );
1497 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1498 if (!file.exists() )
1500 // mapname.xml does not exist, well,
1501 // maybe some renamed the mapname.vym file...
1502 // Try to find any .xml in the toplevel
1503 // directory of the .vym file
1504 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1505 if (flist.count()==1)
1507 // Only one entry, take this one
1508 mapfile=tmpMapDir + "/"+flist.first();
1511 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1512 *it=tmpMapDir + "/" + *it;
1513 // TODO Multiple entries, load all (but only the first one into this ME)
1514 //mainWindow->fileLoadFromTmp (flist);
1515 //returnCode=1; // Silently forget this attempt to load
1516 qWarning ("MainWindow::load (fn) multimap found...");
1519 if (flist.isEmpty() )
1521 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1522 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1525 } //file doesn't exist
1527 mapfile=file.name();
1532 // Save existing filename in case we import
1533 QString fn_org=me->getFilePath();
1535 // Finally load map into mapEditor
1536 me->setFilePath (mapfile,fn);
1537 err=me->load(mapfile,lmode);
1539 // Restore old (maybe empty) filepath, if this is an import
1541 me->setFilePath (fn_org);
1544 // Finally check for errors and go home
1547 if (lmode==NewMap) fileCloseMap();
1548 statusBar()->message( "Could not load " + fn, statusbarTime );
1553 me->setFilePath (fn);
1554 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1555 if (fn.left(9)!="/tmp/vym-")
1557 // Only append to lastMaps if not loaded from a tmpDir
1558 // e.g. imported bookmarks are in a tmpDir
1559 lastMaps.prepend(me->getFilePath() );
1560 setupLastMapsMenu();
1562 actionFilePrint->setEnabled (true);
1564 statusBar()->message( "Loaded " + fn, statusbarTime );
1568 removeDir (QDir(tmpMapDir));
1574 void Main::fileLoad(const LoadMode &lmode)
1576 QFileDialog *fd=new QFileDialog( this);
1577 if (!lastFileDir.isEmpty())
1578 fd->setDir (lastFileDir);
1579 fd->setMode (QFileDialog::ExistingFiles);
1580 fd->addFilter ("XML (*.xml)");
1581 fd->addFilter ("VYM map (*.vym *.vyp)");
1585 fd->setCaption(tr("Load vym map"));
1588 fd->setCaption(tr("Import: Add vym map to selection"));
1591 fd->setCaption(tr("Import: Replace selection with vym map"));
1597 if ( fd->exec() == QDialog::Accepted )
1599 lastFileDir=fd->dirPath();
1600 QStringList flist = fd->selectedFiles();
1601 QStringList::Iterator it = flist.begin();
1602 while( it != flist.end() )
1605 fileLoad(*it, lmode);
1612 void Main::fileLoad()
1617 void Main::fileLoadLast(int i)
1619 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1622 void Main::fileSave(const SaveMode &savemode)
1624 // tmp dir for zipping
1628 ErrorCode err=success;
1630 QString safeFilePath;
1632 bool saveZipped=currentMapEditor()->saveZipped();
1634 MapEditor * me=currentMapEditor();
1637 QString fn=me->getFilePath();
1638 // filename=unnamed, filepath="" in constructor...
1639 if ( !fn.isEmpty() )
1641 // We have a filepath, go on saving
1642 // First remove existing file, we
1643 // don't want to add to old zip archives
1647 QMessageBox::warning( 0, tr( "Save Error" ),
1648 fn+ tr("\ncould not be removed before saving"));
1650 // Look, if we should zip the data:
1653 QMessageBox mb( __VYM,
1654 tr("The map %1\ndid not use the compressed "
1655 "vym file format.\nWriting it uncompressed will also write images \n"
1656 "and flags and thus may overwrite files in the "
1657 "given directory\n\nDo you want to write the map").arg(fn),
1658 QMessageBox::Warning,
1659 QMessageBox::Yes | QMessageBox::Default,
1661 QMessageBox::Cancel | QMessageBox::Escape);
1662 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1663 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1664 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1667 case QMessageBox::Yes:
1668 // save compressed (default file format)
1671 case QMessageBox::No:
1672 // save uncompressed
1675 case QMessageBox::Cancel:
1684 char tmpdir1[]="/tmp/vym-XXXXXX";
1685 tmpMapDir=mkdtemp(tmpdir1);
1687 safeFilePath=me->getFilePath();
1688 me->setFilePath (tmpMapDir+"/"+
1689 me->getMapName()+ ".xml",
1691 me->save (savemode);
1692 me->setFilePath (safeFilePath);
1694 zipDir (tmpMapDir,fn);
1699 safeFilePath=me->getFilePath();
1700 me->setFilePath (fn, safeFilePath);
1701 me->save (savemode);
1702 me->setFilePath (safeFilePath);
1704 } // filepath available
1707 // We have no filepath yet,
1708 // call fileSaveAs() now, this will call fileSave()
1710 fileSaveAs(savemode);
1714 if (me->saveZipped())
1717 removeDir (QDir(tmpMapDir));
1722 statusBar()->message(
1723 tr("Saved %1").arg(me->getFilePath()),
1725 lastMaps.prepend(me->getFilePath() );
1726 setupLastMapsMenu();
1728 statusBar()->message(
1729 tr("Couldn't save ").arg(me->getFilePath()),
1733 void Main::fileSave()
1735 fileSave (CompleteMap);
1738 void Main::fileSaveAs(const SaveMode& savemode)
1743 if (currentMapEditor())
1745 if (savemode==CompleteMap)
1746 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1748 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1749 if ( !fn.isEmpty() )
1751 // Check for existing file
1752 if (QFile (fn).exists())
1754 QMessageBox mb( __VYM,
1755 tr("The file %1\nexists already. Do you want to").arg(fn),
1756 QMessageBox::Warning,
1757 QMessageBox::Yes | QMessageBox::Default,
1758 QMessageBox::Cancel | QMessageBox::Escape,
1759 QMessageBox::QMessageBox::NoButton);
1760 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1761 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1764 case QMessageBox::Yes:
1767 case QMessageBox::Cancel:
1774 // New file, add extension to filename, if missing
1775 // This is always .vym or .vyp, depending on savemode
1776 if (savemode==CompleteMap)
1778 if (!fn.contains (".vym") && !fn.contains (".xml"))
1782 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1791 currentMapEditor()->setFilePath(fn);
1795 if (savemode==CompleteMap)
1796 tabWidget->setTabLabel (currentMapEditor(),
1797 currentMapEditor()->getFileName() );
1803 void Main::fileSaveAs()
1805 fileSaveAs (CompleteMap);
1808 void Main::fileImportKDEBookmarks()
1810 ImportKDEBookmarks im;
1812 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1813 currentMapEditor()->setFilePath ("");
1816 void Main::fileImportMM()
1820 QFileDialog *fd=new QFileDialog( this);
1821 if (!lastFileDir.isEmpty())
1822 fd->setDir (lastFileDir);
1823 fd->setMode (QFileDialog::ExistingFiles);
1824 fd->addFilter ("Mind Manager (*.mmap)");
1825 fd->setCaption(tr("Import")+" "+"Mind Manager");
1828 if ( fd->exec() == QDialog::Accepted )
1830 lastFileDir=fd->dirPath();
1831 QStringList flist = fd->selectedFiles();
1832 QStringList::Iterator it = flist.begin();
1833 while( it != flist.end() )
1836 if (im.transform() &&
1837 success==fileLoad (im.getTransformedFile(),NewMap) &&
1838 currentMapEditor() )
1839 currentMapEditor()->setFilePath ("");
1848 void Main::fileImportDir()
1850 if (currentMapEditor())
1851 currentMapEditor()->importDir();
1854 void Main::fileExportXML()
1856 if (currentMapEditor())
1858 QString dir=browseDirectory(tr("Export XML to directory"));
1859 if (dir !="" && reallyWriteDirectory(dir) )
1860 currentMapEditor()->exportXML(dir);
1864 void Main::fileExportHTML()
1866 if (currentMapEditor())
1868 ExportHTMLDialog dia(this);
1870 if (dia.exec()==QDialog::Accepted)
1872 QString dir=dia.getDir();
1873 if (reallyWriteDirectory(dir) )
1875 currentMapEditor()->exportXML (dia.getDir() );
1876 dia.doExport(currentMapEditor()->getMapName() );
1882 void Main::fileExportXHTML()
1885 if (currentMapEditor())
1887 ExportXHTMLDialog dia(this);
1888 dia.setFilePath (currentMapEditor()->getFilePath() );
1889 dia.setMapName (currentMapEditor()->getMapName() );
1892 if (dia.exec()==QDialog::Accepted)
1894 QString dir=dia.getDir();
1895 // Check, if warnings should be used before overwriting
1896 // the output directory
1899 ok=reallyWriteDirectory(dir);
1905 currentMapEditor()->exportXML (dia.getDir() );
1906 dia.doExport(currentMapEditor()->getMapName() );
1907 if (dia.hasChanged())
1908 currentMapEditor()->setChanged();
1914 void Main::fileExportImage(int item)
1916 if (currentMapEditor())
1918 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1920 if ( !fn.isEmpty() )
1921 currentMapEditor()->exportImage(fn,item);
1923 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1928 void Main::fileExportASCII()
1930 if (currentMapEditor())
1933 ex.setMapCenter(currentMapEditor()->getMapCenter());
1934 ex.addFilter ("TXT (*.txt)");
1935 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1936 if (ex.execDialog() ) ex.doExport();
1940 void Main::fileExportLaTeX()
1942 if (currentMapEditor())
1945 ex.setMapCenter(currentMapEditor()->getMapCenter());
1946 ex.addFilter ("Tex (*.tex)");
1947 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1948 if (ex.execDialog() ) ex.doExport();
1952 void Main::fileExportKDEBookmarks()
1954 ExportKDEBookmarks ex;
1955 if (currentMapEditor())
1957 ex.setMapCenter (currentMapEditor()->getMapCenter() );
1962 void Main::fileExportTaskjuggler()
1964 ExportTaskjuggler ex;
1965 if (currentMapEditor())
1967 ex.setMapCenter (currentMapEditor()->getMapCenter() );
1968 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
1969 ex.addFilter ("Taskjuggler (*.tjp)");
1970 if (ex.execDialog()) ex.doExport();
1974 void Main::fileExportOOPresentation()
1976 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
1977 // FIXME add extra info in dialog
1978 //ImagePreview *p =new ImagePreview (fd);
1979 //fd->setContentsPreviewEnabled( TRUE );
1980 //fd->setContentsPreview( p, p );
1981 //fd->setPreviewMode( QFileDialog::Contents );
1982 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
1983 //fd->setDir (lastImageDir);
1986 if ( fd->exec() == QDialog::Accepted )
1988 QString fn=fd->selectedFile();
1989 //lastImageDir=fn.left(fn.findRev ("/"));
1990 if (currentMapEditor())
1991 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
1995 void Main::fileCloseMap()
1997 if (currentMapEditor())
1999 if (currentMapEditor()->hasChanged())
2001 QMessageBox mb( __VYM,
2002 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2003 QMessageBox::Warning,
2004 QMessageBox::Yes | QMessageBox::Default,
2006 QMessageBox::Cancel | QMessageBox::Escape );
2007 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2008 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2011 case QMessageBox::Yes:
2013 fileSave(CompleteMap);
2015 case QMessageBox::No:
2016 // close without saving
2018 case QMessageBox::Cancel:
2023 currentMapEditor()->closeMap();
2024 tabWidget->removePage(currentMapEditor());
2025 if (tabWidget->count()==0)
2026 actionFilePrint->setEnabled (false);
2030 void Main::filePrint()
2032 if (currentMapEditor())
2033 currentMapEditor()->print();
2036 void Main::fileExitVYM()
2038 // Check if one or more editors have changed
2041 for (i=0;i<=tabWidget->count() -1;i++)
2044 me=(MapEditor*)tabWidget->page(i);
2046 // If something changed, ask what to do
2047 if (me->isUnsaved())
2049 tabWidget->setCurrentPage(i);
2050 QMessageBox mb( __VYM,
2051 tr("This map is not saved yet. Do you want to"),
2052 QMessageBox::Warning,
2053 QMessageBox::Yes | QMessageBox::Default,
2055 QMessageBox::Cancel | QMessageBox::Escape );
2056 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2057 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2059 // Call undocumented function: setActiveWindow is only
2060 // possible, if widget is visible. This depends on
2062 #if defined(Q_OS_LINUX)
2063 qt_wait_for_window_manager( this);
2065 mb.setActiveWindow();
2066 switch( mb.exec() ) {
2067 case QMessageBox::Yes:
2068 // save (the changed editors) and exit
2069 fileSave(CompleteMap);
2071 case QMessageBox::No:
2072 // exit without saving
2074 case QMessageBox::Cancel:
2075 // don't save and don't exit
2079 } // loop over all MEs
2083 void Main::editUndo()
2085 if (currentMapEditor())
2086 currentMapEditor()->undo();
2089 void Main::editRedo()
2091 if (currentMapEditor())
2092 currentMapEditor()->redo();
2095 void Main::editCopy()
2097 if (currentMapEditor())
2098 currentMapEditor()->copy();
2101 void Main::editPaste()
2103 if (currentMapEditor())
2104 currentMapEditor()->paste();
2107 void Main::editCut()
2109 if (currentMapEditor())
2110 currentMapEditor()->cut();
2113 void Main::editOpenFindWindow()
2115 findWindow->popup();
2116 findWindow->raise();
2118 // Call undocumented function: setActiveWindow is only
2119 // possible, if widget is visible. This depends on
2121 #if defined(Q_OS_LINUX)
2122 qt_wait_for_window_manager( this);
2124 findWindow->setActiveWindow();
2127 void Main::editFind(QString s)
2130 BranchObj *bo=currentMapEditor()->findText(s, cs);
2133 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2136 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2137 tr("No matches found for <b>%1</b>").arg(s));
2141 void Main::editFindChanged()
2142 { // Notify editor, to abort the current find process
2143 currentMapEditor()->findReset();
2146 void Main::editOpenURL()
2148 if (currentMapEditor())
2149 currentMapEditor()->openURL();
2152 void Main::editURL()
2154 if (currentMapEditor())
2155 currentMapEditor()->editURL();
2158 void Main::editHeading2URL()
2160 if (currentMapEditor())
2161 currentMapEditor()->editHeading2URL();
2164 void Main::editBugzilla2URL()
2166 if (currentMapEditor())
2167 currentMapEditor()->editBugzilla2URL();
2170 void Main::editFATE2URL()
2172 if (currentMapEditor())
2173 currentMapEditor()->editFATE2URL();
2176 void Main::editOpenVymLink()
2178 // Get current path to map
2179 QString currentVymLink;
2180 if (currentMapEditor())
2182 currentVymLink=currentMapEditor()->getVymLink();
2183 // compare path with already loaded maps
2187 for (i=0;i<=tabWidget->count() -1;i++)
2189 me=(MapEditor*)tabWidget->page(i);
2190 if (currentVymLink==me->getFilePath() )
2199 if (!QFile(currentVymLink).exists() )
2200 QMessageBox::critical( 0, tr( "Critical Error" ),
2201 tr("Couldn't open map %1").arg(currentVymLink));
2204 fileLoad (currentVymLink, NewMap);
2205 tabWidget->setCurrentPage (tabWidget->count()-1);
2208 // Go to tab containing the map
2209 tabWidget->setCurrentPage (index);
2213 void Main::editVymLink()
2215 if (currentMapEditor())
2216 currentMapEditor()->editVymLink();
2219 void Main::editDeleteVymLink()
2221 if (currentMapEditor())
2222 currentMapEditor()->deleteVymLink();
2225 void Main::editToggleHideExport()
2227 if (currentMapEditor())
2228 currentMapEditor()->toggleHideExport();
2231 void Main::editMapInfo()
2233 if (currentMapEditor())
2234 currentMapEditor()->editMapInfo();
2237 void Main::editMoveUp()
2239 if (currentMapEditor())
2240 currentMapEditor()->moveBranchUp();
2243 void Main::editMoveDown()
2245 if (currentMapEditor())
2246 currentMapEditor()->moveBranchDown();
2249 void Main::editToggleScroll()
2251 if (currentMapEditor())
2253 currentMapEditor()->toggleScroll();
2257 void Main::editUnScrollAll()
2259 if (currentMapEditor())
2261 currentMapEditor()->unScrollAll();
2265 void Main::editHeading()
2267 if (currentMapEditor())
2268 currentMapEditor()->editHeading();
2271 void Main::editNewBranch()
2273 if (currentMapEditor())
2274 currentMapEditor()->addNewBranch(0);
2277 void Main::editNewBranchHere()
2279 if (currentMapEditor())
2280 currentMapEditor()->addNewBranchHere();
2283 void Main::editNewBranchAbove()
2285 if (currentMapEditor())
2286 currentMapEditor()->addNewBranch(-1);
2289 void Main::editNewBranchBelow()
2291 if (currentMapEditor())
2292 currentMapEditor()->addNewBranch(1);
2295 void Main::editImportAdd()
2297 fileLoad (ImportAdd);
2300 void Main::editImportReplace()
2302 fileLoad (ImportReplace);
2305 void Main::editSaveBranch()
2307 fileSaveAs (PartOfMap);
2310 void Main::editRemoveBranchHere()
2312 if (currentMapEditor())
2313 currentMapEditor()->removeBranchHere();
2316 void Main::editRemoveChilds()
2318 if (currentMapEditor())
2319 currentMapEditor()->removeChilds();
2322 void Main::editDeleteSelection()
2324 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2325 currentMapEditor()->deleteSelection();
2328 void Main::editUpperBranch()
2330 if (currentMapEditor())
2331 currentMapEditor()->selectUpperBranch();
2334 void Main::editLowerBranch()
2336 if (currentMapEditor())
2337 currentMapEditor()->selectLowerBranch();
2340 void Main::editLeftBranch()
2342 if (currentMapEditor())
2343 currentMapEditor()->selectLeftBranch();
2346 void Main::editRightBranch()
2348 if (currentMapEditor())
2349 currentMapEditor()->selectRightBranch();
2352 void Main::editFirstBranch()
2354 if (currentMapEditor())
2355 currentMapEditor()->selectFirstBranch();
2358 void Main::editLastBranch()
2360 if (currentMapEditor())
2361 currentMapEditor()->selectLastBranch();
2364 void Main::editLoadImage()
2366 if (currentMapEditor())
2367 currentMapEditor()->loadFloatImage();
2370 void Main::editSaveImage(int item)
2372 if (currentMapEditor())
2373 currentMapEditor()->saveFloatImage(item);
2376 void Main::editToggleFloatExport()
2378 if (currentMapEditor())
2379 currentMapEditor()->toggleFloatExport();
2382 void Main::editFollowXLink(int item)
2384 if (currentMapEditor())
2385 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2388 void Main::editEditXLink(int item)
2390 if (currentMapEditor())
2391 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2394 void Main::formatSelectColor()
2396 if (currentMapEditor())
2398 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2399 if ( !col.isValid() ) return;
2400 currentMapEditor()->setColor( col );
2401 colorChanged( col );
2405 void Main::formatPickColor()
2407 if (currentMapEditor())
2408 colorChanged( currentMapEditor()->pickColor() );
2411 void Main::colorChanged(QColor c)
2413 QPixmap pix( 16, 16 );
2415 actionFormatColor->setIconSet( pix );
2418 void Main::formatColorItem()
2420 if (currentMapEditor())
2421 currentMapEditor()->colorItem();
2424 void Main::formatColorBranch()
2426 if (currentMapEditor())
2427 currentMapEditor()->colorBranch();
2430 void Main::formatLinkStyleLine()
2432 if (currentMapEditor())
2433 currentMapEditor()->setLinkStyle(StyleLine);
2436 void Main::formatLinkStyleParabel()
2438 if (currentMapEditor())
2439 currentMapEditor()->setLinkStyle(StyleParabel);
2442 void Main::formatLinkStylePolyLine()
2444 if (currentMapEditor())
2445 currentMapEditor()->setLinkStyle(StylePolyLine);
2448 void Main::formatLinkStylePolyParabel()
2450 if (currentMapEditor())
2451 currentMapEditor()->setLinkStyle(StylePolyParabel);
2454 void Main::formatSelectBackColor()
2456 if (currentMapEditor())
2457 currentMapEditor()->selectBackgroundColor();
2460 void Main::formatSelectLinkColor()
2462 if (currentMapEditor())
2463 currentMapEditor()->selectLinkColor();
2466 void Main::formatToggleLinkColorHint()
2468 currentMapEditor()->toggleLinkColorHint();
2471 void Main::formatFrameNone()
2473 if (currentMapEditor())
2474 currentMapEditor()->setFrame(NoFrame);
2477 void Main::formatFrameRectangle()
2479 if (currentMapEditor())
2480 currentMapEditor()->setFrame(Rectangle);
2483 void Main::formatIncludeImagesVer()
2485 if (currentMapEditor())
2486 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2489 void Main::formatIncludeImagesHor()
2491 if (currentMapEditor())
2492 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2495 void Main::formatHideLinkUnselected()
2497 if (currentMapEditor())
2498 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2501 void Main::viewZoomReset()
2503 if (currentMapEditor())
2507 currentMapEditor()->setWorldMatrix( m );
2508 currentMapEditor()->setViewCenter();
2509 currentMapEditor()->adjustCanvasSize();
2513 void Main::viewZoomIn()
2515 if (currentMapEditor())
2517 QWMatrix m = currentMapEditor()->worldMatrix();
2518 m.scale( 1.25, 1.25 );
2519 currentMapEditor()->setWorldMatrix( m );
2520 currentMapEditor()->setViewCenter();
2521 currentMapEditor()->adjustCanvasSize();
2525 void Main::viewZoomOut()
2527 if (currentMapEditor())
2529 QWMatrix m = currentMapEditor()->worldMatrix();
2530 m.scale( 0.8, 0.8 );
2531 currentMapEditor()->setWorldMatrix( m );
2532 currentMapEditor()->setViewCenter();
2533 currentMapEditor()->adjustCanvasSize();
2537 void Main::modModeColor()
2541 void Main::modModeLink()
2545 bool Main::settingsPDF()
2547 // Default browser is set in constructor
2549 QString text = QInputDialog::getText(
2550 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2551 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2553 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2558 bool Main::settingsURL()
2560 // Default browser is set in constructor
2562 QString text = QInputDialog::getText(
2563 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2564 settings.readEntry("/vym/mainwindow/readerURL")
2567 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2571 void Main::windowToggleNoteEditor()
2573 if (textEditor->showWithMain() )
2574 windowHideNoteEditor();
2576 windowShowNoteEditor();
2579 void Main::updateNoteFlag()
2581 if (currentMapEditor())
2582 currentMapEditor()->updateNoteFlag();
2585 void Main::windowShowNoteEditor()
2587 textEditor->setShowWithMain(true);
2589 actionViewToggleNoteEditor->setOn (true);
2592 void Main::windowHideNoteEditor()
2594 textEditor->setShowWithMain(false);
2596 actionViewToggleNoteEditor->setOn (false);
2599 void Main::windowNextEditor()
2601 if (tabWidget->currentPageIndex() < tabWidget->count())
2602 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2605 void Main::windowPreviousEditor()
2607 if (tabWidget->currentPageIndex() >0)
2608 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2611 void Main::standardFlagChanged()
2613 currentMapEditor()->toggleStandardFlag(sender()->name());
2616 void Main::testFunction()
2618 currentMapEditor()->testFunction();
2621 void Main::helpDoc()
2624 #if defined(Q_OS_MACX)
2625 docpath="./vym.app/Contents/vym.pdf";
2627 // default path in SUSE LINUX
2628 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2631 if (!QFile (docpath).exists() )
2633 // relative path for easy testing in tarball
2634 docpath="doc/vym.pdf";
2635 if (!QFile (docpath).exists() )
2637 // relative path for testing while still writing vym.tex
2638 docpath="doc/tex/vym.pdf";
2639 if (!QFile (docpath).exists() )
2641 // Try yet another one for Knoppix
2642 docpath="/usr/share/doc/packages/vym/vym.pdf";
2643 if (!QFile (docpath).exists() )
2645 QMessageBox::critical(0,
2646 tr("Critcal error"),
2647 tr("Couldn't find the documentation\n"
2648 "vym.pdf in various places."));
2655 Process *pdfProc = new Process();
2656 pdfProc->clearArguments();
2657 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2658 pdfProc->addArgument( docpath);
2660 if ( !pdfProc->start() )
2663 QMessageBox::critical(0,
2664 tr("Critcal error"),
2665 tr("Couldn't find a viewer to read vym.pdf.\n"
2666 "Please use Settings->")+tr("Set application to open pdf files"));
2672 void Main::helpAbout()
2675 ad.setName ("aboutwindow");
2676 ad.setMinimumSize(500,500);
2677 ad.resize (QSize (500,500));
2681 void Main::helpAboutQT()
2683 QMessageBox::aboutQt( this, "Qt Application Example" );