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-hideexport.xpm"
62 #include "icons/flag-scrolled-right.xpm"
63 #include "icons/flag-tmpUnscrolled-right.xpm"
65 #include "aboutdialog.h"
66 #include "exporthtmldialog.h"
67 #include "exportoofiledialog.h"
69 #include "exportxhtmldialog.h"
71 #include "flagrowobj.h"
73 #include "mapeditor.h"
78 #include "showtextdialog.h"
79 #include "texteditor.h"
82 extern TextEditor *textEditor;
83 extern Main *mainWindow;
84 extern QString tmpVymDir;
85 extern QString clipboardDir;
86 extern bool clipboardEmpty;
87 extern int statusbarTime;
88 extern FlagRowObj* standardFlagsDefault;
89 extern FlagRowObj* systemFlagsDefault;
91 extern QPtrList <QAction> actionListBranches;
93 extern QAction* actionFileSave;
94 extern QAction* actionFilePrint;
95 extern QAction* actionEditUndo;
96 extern QAction* actionEditRedo;
97 extern QAction *actionEditCopy;
98 extern QAction *actionEditCut;
99 extern QAction *actionEditPaste;
100 extern QAction *actionEditMoveUp;
101 extern QAction *actionEditMoveDown;
102 extern QAction *actionEditToggleScroll;
103 extern QAction* actionEditOpenURL;
104 extern QAction* actionEditOpenURLTab;
105 extern QAction* actionEditURL;
106 extern QAction* actionEditHeading2URL;
107 extern QAction* actionEditBugzilla2URL;
108 extern QAction* actionEditFATE2URL;
109 extern QAction *actionEditOpenVymLink;
110 extern QAction *actionEditVymLink;
111 extern QAction *actionEditDeleteVymLink;
112 extern QAction *actionEditToggleHideExport;
113 extern QAction *actionEditMapInfo;
114 extern QAction *actionEditHeading;
115 extern QAction *actionEditDelete;
116 extern QAction *actionEditAddBranch;
117 extern QAction *actionEditAddBranchHere;
118 extern QAction *actionEditAddBranchAbove;
119 extern QAction *actionEditAddBranchBelow;
120 extern QAction *actionEditRemoveBranchHere;
121 extern QAction *actionEditRemoveChilds;
122 extern QAction *actionEditImportAdd;
123 extern QAction *actionEditImportReplace;
124 extern QAction *actionEditSaveBranch;
125 extern QAction *actionEditSelectFirst;
126 extern QAction *actionEditSelectLast;
127 extern QAction *actionEditLoadImage;
129 extern QAction* actionFormatColor;
130 extern QAction* actionFormatPickColor;
131 extern QAction* actionFormatColorBranch;
132 extern QAction* actionFormatColorSubtree;
133 extern QAction* actionFormatLinkColorHint;
134 extern QAction* actionFormatBackColor;
135 extern QAction* actionFormatLinkColor;
136 extern QAction *actionFormatIncludeImagesVer;
137 extern QAction *actionFormatIncludeImagesHor;
139 extern QActionGroup* actionGroupModModes;
140 extern QAction* actionModModeColor;
141 extern QAction* actionModModeLink;
142 extern QAction* actionModModeCopy;
144 extern QActionGroup *actionGroupFormatFrameTypes;
145 extern QAction *actionFormatFrameNone;
146 extern QAction *actionFormatFrameRectangle;
148 extern QActionGroup *actionGroupFormatLinkStyles;
149 extern QAction *actionFormatLinkStyleLine;
150 extern QAction *actionFormatLinkStyleParabel;
151 extern QAction *actionFormatLinkStylePolyLine;
152 extern QAction *actionFormatLinkStylePolyParabel;
153 extern QAction *actionFormatHideLinkUnselected;
155 extern QAction *actionViewToggleNoteEditor;
157 extern QAction* actionSettingsAutoedit;
158 extern QAction* actionSettingsAutoselectHeading;
159 extern QAction* actionSettingsAutoselectHeading;
160 extern QAction* actionSettingsAutoselectText;
161 extern QAction* actionSettingsPasteNewHeading;
162 extern QAction* actionSettingsUseDelKey;
163 extern QAction* actionSettingsUseFlagGroups;
164 extern QAction* actionSettingsUseHideExport;
166 extern QPopupMenu* branchContextMenu;
167 extern QPopupMenu* branchAddContextMenu;
168 extern QPopupMenu* branchRemoveContextMenu;
169 extern QPopupMenu* branchLinksContextMenu;
170 extern QPopupMenu* branchLinksContextMenuDup;
171 extern QPopupMenu* floatimageContextMenu;
172 extern QPopupMenu* saveImageFormatMenu;
173 extern QPopupMenu* canvasContextMenu;
174 extern QPopupMenu* lastMapsMenu;
175 extern QPopupMenu* importMenu;
176 extern QPopupMenu* exportMenu;
177 extern QPopupMenu* exportImageFormatMenu;
180 extern Settings settings;
181 extern Options options;
183 #if defined(Q_OS_LINUX)
184 extern void qt_wait_for_window_manager( QWidget* w );
187 Main::Main(QWidget* parent, const char* name, WFlags f) :
188 QMainWindow(parent,name,f)
192 setCaption ("VYM - View Your Mind");
194 // Load window settings
195 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
196 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
197 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
198 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
201 // Create unique temporary directory
202 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
204 // Create direcctory for clipboard
205 clipboardDir=tmpVymDir+"/clipboard";
206 QDir d(clipboardDir);
207 d.mkdir (clipboardDir,true);
208 makeSubDirs (clipboardDir);
213 // FIXME not used currently
214 // Set random seed (random used for object IDs)
215 // QTime t = QTime::currentTime(); // set random seed
216 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
219 // Initialize some settings, which are platform dependant
222 // application to open URLs
223 p="/vym/mainwindow/readerURL";
224 #if defined(Q_OS_LINUX)
225 s=settings.readEntry (p,"konqueror");
227 #if defined(Q_OS_MACX)
228 s=settings.readEntry (p,"/usr/bin/open");
230 s=settings.readEntry (p,"mozilla");
233 settings.writeEntry( p,s);
235 // application to open PDFs
236 p="/vym/mainwindow/readerPDF";
237 #if defined(Q_OS_LINUX)
238 s=settings.readEntry (p,"acroread");
240 #if defined(Q_OS_MACX)
241 s=settings.readEntry (p,"/usr/bin/open");
243 s=settings.readEntry (p,"acroread");
246 settings.writeEntry( p,s);
251 // Create tab widget which holds the maps
252 tabWidget= new QTabWidget (this);
253 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
254 this, SLOT( editorChanged( QWidget * ) ) );
256 setCentralWidget(tabWidget);
260 setupFormatActions();
264 setupSettingsActions();
266 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
269 // After menu is created, we can enable some actions
270 actionFilePrint->setEnabled (true);
275 // Initialize Find window
276 findWindow=new FindWindow(NULL,"findwindow");
277 connect (findWindow, SIGNAL( findButton(QString) ),
278 this, SLOT(editFind(QString) ) );
279 connect (findWindow, SIGNAL( somethingChanged() ),
280 this, SLOT(editFindChanged() ) );
282 // Connect TextEditor, so that we can update flags if text changes
283 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
291 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
292 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
293 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
294 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
296 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
297 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
299 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
300 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
301 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
302 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
303 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
304 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
305 settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
308 int maps=lastMaps.count();
309 settings.writeEntry( "/vym/lastMaps/number",maps );
310 for (int i=1;i<=maps;i++)
312 QStringList::Iterator it = lastMaps.at(i-1);
313 s=QString("/vym/lastMaps/map-%1").arg(i);
314 if (!s.isEmpty() && i<=maxLastMaps)
315 settings.writeEntry (s, *it);
319 // To make the texteditor save its settings, call the destructor
322 // Remove temporary directory
323 removeDir (QDir(tmpVymDir));
326 void Main::loadCmdLine()
328 /* TODO draw some kind of splashscreen while loading...
334 QStringList flist=options.getFileList();
335 QStringList::Iterator it=flist.begin();
337 while (it !=flist.end() )
339 fileLoad (*it, NewMap);
345 void Main::statusMessage(const QString &s)
347 statusBar()->message (s);
350 void Main::closeEvent (QCloseEvent* )
356 void Main::setupFileActions()
358 QToolBar *tb = new QToolBar( this );
359 tb->setLabel( "File Actions" );
360 QPopupMenu *menu = new QPopupMenu( this );
361 menuBar()->insertItem( tr( "&File" ), menu );
363 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
366 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
367 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
371 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
372 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
376 lastMapsMenu = new QPopupMenu (this);
378 menu->insertItem (tr("Open Recent"),lastMapsMenu );
379 menu->insertSeparator();
381 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
382 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
387 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
388 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
391 menu->insertSeparator();
393 importMenu = new QPopupMenu (this);
394 menu->insertItem (tr("Import"),importMenu );
396 a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
397 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
398 a->addTo (importMenu);
400 a = new QAction( tr( "Import")+" Mind Manager" , QPixmap(), "Mind Manager...", 0, this, "importMM" );
401 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
402 a->addTo (importMenu);
404 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
405 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
406 a->addTo( importMenu);
408 exportMenu = new QPopupMenu (this);
409 menu->insertItem (tr("Export"),exportMenu );
411 menu->insertSeparator();
414 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" );
415 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
420 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
421 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
424 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
425 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
431 void Main::setupEditActions()
433 QToolBar *tb = new QToolBar( this );
434 tb->setLabel( "Edit Actions" );
435 QPopupMenu *menu = new QPopupMenu( this );
436 menuBar()->insertItem( tr( "&Edit" ), menu );
440 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
441 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
442 a->setEnabled (false);
447 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
449 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
450 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
455 menu->insertSeparator();
456 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
457 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
458 a->setEnabled (false);
462 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
463 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
464 a->setEnabled (false);
468 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
469 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
470 a->setEnabled (false);
475 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
476 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
477 a->setEnabled (false);
480 actionListBranches.append(a);
483 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
484 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
485 a->setEnabled (false);
488 actionListBranches.append(a);
489 actionEditMoveDown=a;
492 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
493 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
494 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
495 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
496 #if defined(Q_OS_MACX)
497 actionEditToggleScroll=alt;
499 actionEditToggleScroll=a;
501 actionEditToggleScroll->setEnabled (false);
502 actionEditToggleScroll->setToggleAction(true);
503 actionEditToggleScroll->addTo( tb );
504 actionEditToggleScroll->addTo( menu );
505 actionListBranches.append(actionEditToggleScroll);
507 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
508 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
511 menu->insertSeparator();
513 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
514 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
517 menu->insertSeparator();
519 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
520 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
522 a->setEnabled (false);
525 a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), CTRL + Key_U, this, "urltab" );
526 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
527 a->setEnabled (false);
528 actionEditOpenURLTab=a;
530 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
531 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
532 a->setEnabled (false);
533 actionListBranches.append(a);
536 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
537 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
538 a->setEnabled (false);
539 actionListBranches.append(a);
540 actionEditHeading2URL=a;
542 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
543 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
544 a->setEnabled (false);
545 actionListBranches.append(a);
546 actionEditBugzilla2URL=a;
548 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
549 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
550 a->setEnabled (false);
551 actionListBranches.append(a);
552 actionEditFATE2URL=a;
554 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" );
555 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
557 a->setEnabled (false);
558 actionEditOpenVymLink=a;
560 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
561 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
562 a->setEnabled (false);
563 actionListBranches.append(a);
566 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
567 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
568 a->setEnabled (false);
569 actionEditDeleteVymLink=a;
571 a = new QAction( tr( "Hide object in exports" ), QPixmap(flag_hideexport_xpm), tr( "Hide in exports" ), 0, this, "hideExport" );
572 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
573 a->setToggleAction(true);
575 a->setEnabled (false);
576 actionEditToggleHideExport=a;
578 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
579 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
580 a->setEnabled (true);
583 menu->insertSeparator();
585 // Shortcuts to modify heading:
586 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
587 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
588 actionListBranches.append(a);
589 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
590 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
591 actionListBranches.append(a);
593 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
594 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
595 a->setEnabled (false);
597 actionListBranches.append(a);
599 // Shortcut to delete selection
600 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
601 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
602 a->setEnabled (false);
605 // Shortcut to add branch
606 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
607 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
608 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
609 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
610 a->setEnabled (false);
611 actionListBranches.append(a);
612 #if defined (Q_OS_MACX)
613 // In OSX show different shortcut in menues, the keys work independtly always
614 actionEditAddBranch=alt;
616 actionEditAddBranch=a;
619 // Add branch by inserting it at selection
620 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
621 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
622 a->setEnabled (false);
623 actionListBranches.append(a);
624 actionEditAddBranchHere=a;
625 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
626 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
627 actionListBranches.append(a);
630 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
631 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 actionEditAddBranchAbove=a;
635 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
636 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
637 actionListBranches.append(a);
640 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
641 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
642 a->setEnabled (false);
643 actionListBranches.append(a);
644 actionEditAddBranchBelow=a;
645 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
646 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
647 actionListBranches.append(a);
649 // Import at selection (adding to selection)
650 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
651 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
652 a->setEnabled (false);
653 actionListBranches.append(a);
654 actionEditImportAdd=a;
656 // Import at selection (replacing selection)
657 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
658 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
659 a->setEnabled (false);
660 actionListBranches.append(a);
661 actionEditImportReplace=a;
664 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
665 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
666 a->setEnabled (false);
667 actionListBranches.append(a);
668 actionEditSaveBranch=a;
670 // Only remove branch, not its childs
671 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
672 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
673 a->setEnabled (false);
674 actionListBranches.append(a);
675 actionEditRemoveBranchHere=a;
677 // Only remove childs of a branch
678 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
679 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
680 a->setEnabled (false);
681 actionListBranches.append(a);
682 actionEditRemoveChilds=a;
684 // Shortcuts for navigating with cursor:
685 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
686 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
687 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
688 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
689 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
690 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
691 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
692 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
693 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
694 a->setEnabled (false);
696 actionListBranches.append(a);
697 actionEditSelectFirst=a;
698 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
699 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
700 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
701 a->setEnabled (false);
703 actionListBranches.append(a);
704 actionEditSelectLast=a;
706 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
707 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
708 actionEditLoadImage=a;
713 void Main::setupFormatActions()
715 QPopupMenu *menu = new QPopupMenu( this );
716 menuBar()->insertItem( tr( "&Format" ), menu );
718 QToolBar *tb = new QToolBar( this );
722 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
723 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
724 actionFormatColor->addTo( tb );
725 actionFormatColor->addTo( menu );
726 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" );
727 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
728 a->setEnabled (false);
731 actionListBranches.append(a);
732 actionFormatPickColor=a;
733 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
734 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
735 a->setEnabled (false);
738 actionListBranches.append(a);
739 actionFormatColorBranch=a;
740 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
741 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
742 a->setEnabled (false);
745 actionListBranches.append(a);
746 actionFormatColorSubtree=a;
748 menu->insertSeparator();
749 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
750 actionGroupFormatLinkStyles->setExclusive (true);
751 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
752 a->setToggleAction(true);
753 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
754 actionFormatLinkStyleLine=a;
755 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
756 a->setToggleAction(true);
757 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
758 actionFormatLinkStyleParabel=a;
759 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
760 a->setToggleAction(true);
761 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
762 actionFormatLinkStylePolyLine=a;
763 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
764 a->setToggleAction(true);
765 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
766 actionFormatLinkStylePolyParabel=a;
767 actionGroupFormatLinkStyles->addTo (menu);
769 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
770 actionGroupFormatFrameTypes->setExclusive (true);
771 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
772 a->setToggleAction(true);
773 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
774 actionFormatFrameNone=a;
775 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
776 a->setToggleAction(true);
777 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
778 actionFormatFrameRectangle=a;
780 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
781 a->setToggleAction(true);
782 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
783 actionFormatIncludeImagesVer=a;
785 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
786 a->setToggleAction(true);
787 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
788 actionFormatIncludeImagesHor=a;
790 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
791 a->setToggleAction(true);
792 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
793 actionFormatHideLinkUnselected=a;
795 menu->insertSeparator();
796 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
797 a->setToggleAction(true);
798 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
800 actionFormatLinkColorHint=a;
802 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
803 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
804 actionFormatLinkColor->addTo( menu );
805 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
806 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
807 actionFormatBackColor->addTo( menu );
811 void Main::setupViewActions()
813 QToolBar *tb = new QToolBar( this );
814 tb->setLabel( "View Actions" );
815 QPopupMenu *menu = new QPopupMenu( this );
816 menuBar()->insertItem( tr( "&View" ), menu );
819 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
820 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
823 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
824 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
827 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
828 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
831 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
832 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
833 a->setToggleAction(true);
834 if (textEditor->showWithMain())
840 actionViewToggleNoteEditor=a;
841 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
842 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
844 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
845 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
850 void Main::setupModeActions()
852 //QPopupMenu *menu = new QPopupMenu( this );
853 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
855 QToolBar *tb = new QToolBar( this );
856 tb->setLabel( tr ("Modes when using modifiers") );
858 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
859 actionGroupModModes->setExclusive (true);
860 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
861 a->setToggleAction(true);
864 actionModModeColor=a;
866 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
867 a->setToggleAction(true);
871 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
872 a->setToggleAction(true);
878 void Main::setupFlagActions()
880 // Create System Flags
881 systemFlagsDefault = new FlagRowObj ();
882 systemFlagsDefault->setVisibility (false);
883 systemFlagsDefault->setName ("systemFlagsDef");
885 FlagObj *fo = new FlagObj ();
886 fo->load(QPixmap(flag_note_xpm));
888 fo->setToolTip(tr("Note","Systemflag"));
889 systemFlagsDefault->addFlag (fo); // makes deep copy
891 fo->load(QPixmap(flag_url_xpm));
893 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
894 systemFlagsDefault->addFlag (fo);
896 fo->load(QPixmap(flag_vymlink_xpm));
897 fo->setName("vymLink");
898 fo->setToolTip(tr("Link to another vym map","Systemflag"));
899 systemFlagsDefault->addFlag (fo);
901 fo->load(QPixmap(flag_scrolled_right_xpm));
902 fo->setName("scrolledright");
903 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
904 systemFlagsDefault->addFlag (fo);
906 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
907 fo->setName("tmpUnscrolledright");
908 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
909 systemFlagsDefault->addFlag (fo);
911 fo->load(QPixmap("icons/flag-hideexport.png"));
912 fo->setName("hideInExport");
913 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
914 systemFlagsDefault->addFlag (fo);
916 // Create Standard Flags
917 standardFlagsDefault = new FlagRowObj ();
918 standardFlagsDefault->setVisibility (false);
919 standardFlagsDefault->setName ("standardFlagsDef");
921 fo->load(QPixmap(flag_exclamationmark_xpm));
922 fo->setName ("exclamationmark");
923 fo->setGroup("standard-mark");
924 fo->setToolTip(tr("Take care!","Standardflag"));
925 standardFlagsDefault->addFlag (fo); // makes deep copy
927 fo->load(QPixmap(flag_questionmark_xpm));
928 fo->setName("questionmark");
929 fo->setGroup("standard-mark");
930 fo->setToolTip(tr("Really?","Standardflag"));
931 standardFlagsDefault->addFlag (fo);
933 fo->load(QPixmap(flag_hook_green_xpm));
934 fo->setName("hook-green");
935 fo->setGroup("standard-hook");
936 fo->setToolTip(tr("ok!","Standardflag"));
937 standardFlagsDefault->addFlag (fo);
939 fo->load(QPixmap(flag_cross_red_xpm));
940 fo->setName("cross-red");
941 fo->setGroup("standard-hook");
942 fo->setToolTip(tr("Not ok!","Standardflag"));
943 standardFlagsDefault->addFlag (fo);
945 fo->load(QPixmap(flag_stopsign_xpm));
946 fo->setName("stopsign");
947 fo->setToolTip(tr("This won't work!","Standardflag"));
948 standardFlagsDefault->addFlag (fo);
950 fo->load(QPixmap(flag_smiley_good_xpm));
951 fo->setName("smiley-good");
952 fo->setGroup("standard-smiley");
953 fo->setToolTip(tr("Good","Standardflag"));
954 standardFlagsDefault->addFlag (fo);
956 fo->load(QPixmap(flag_smiley_sad_xpm));
957 fo->setName("smiley-sad");
958 fo->setGroup("standard-smiley");
959 fo->setToolTip(tr("Bad","Standardflag"));
960 standardFlagsDefault->addFlag (fo);
962 fo->load(QPixmap(flag_clock_xpm));
963 fo->setName("clock");
964 fo->setToolTip(tr("Time critical","Standardflag"));
965 standardFlagsDefault->addFlag (fo);
967 fo->load(QPixmap(flag_lamp_xpm));
969 fo->setToolTip(tr("Idea!","Standardflag"));
970 standardFlagsDefault->addFlag (fo);
972 fo->load(QPixmap(flag_arrow_up_xpm));
973 fo->setName("arrow-up");
974 fo->setGroup("standard-arrow");
975 fo->setToolTip(tr("Important","Standardflag"));
976 standardFlagsDefault->addFlag (fo);
978 fo->load(QPixmap(flag_arrow_down_xpm));
979 fo->setName("arrow-down");
980 fo->setGroup("standard-arrow");
981 fo->setToolTip(tr("Unimportant","Standardflag"));
982 standardFlagsDefault->addFlag (fo);
984 fo->load(QPixmap(flag_thumb_up_xpm));
985 fo->setName("thumb-up");
986 fo->setGroup("standard-thumb");
987 fo->setToolTip(tr("I like this","Standardflag"));
988 standardFlagsDefault->addFlag (fo);
990 fo->load(QPixmap(flag_thumb_down_xpm));
991 fo->setName("thumb-down");
992 fo->setGroup("standard-thumb");
993 fo->setToolTip(tr("I like this","Standardflag"));
994 fo->setToolTip(tr("I do not like this","Standardflag"));
995 standardFlagsDefault->addFlag (fo);
997 fo->load(QPixmap(flag_heart_xpm));
998 fo->setName("heart");
999 fo->setToolTip(tr("I just love... ","Standardflag"));
1000 standardFlagsDefault->addFlag (fo);
1002 fo->load(QPixmap(flag_flash_xpm));
1003 fo->setName("flash");
1004 fo->setToolTip(tr("Dangerous","Standardflag"));
1005 standardFlagsDefault->addFlag (fo);
1007 fo->load(QPixmap(flag_lifebelt_xpm));
1008 fo->setName("lifebelt");
1009 fo->setToolTip(tr("This will help","Standardflag"));
1010 standardFlagsDefault->addFlag (fo);
1014 standardFlagsDefault->makeToolbar(this, "Standard Flags");
1018 void Main::setupSettingsActions()
1020 QPopupMenu *menu = new QPopupMenu( this );
1021 menuBar()->insertItem( tr( "&Settings" ), menu );
1026 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1027 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1030 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1031 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1034 menu->insertSeparator();
1035 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1036 a->setToggleAction(true);
1037 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1039 actionSettingsAutoedit=a;
1041 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1042 a->setToggleAction(true);
1043 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1045 actionSettingsAutoselectHeading=a;
1047 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1048 a->setToggleAction(true);
1049 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1051 actionSettingsAutoselectText=a;
1053 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1054 a->setToggleAction(true);
1055 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1057 actionSettingsPasteNewHeading=a;
1059 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1060 a->setToggleAction(true);
1061 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1063 actionSettingsUseDelKey=a;
1065 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1066 a->setToggleAction(true);
1067 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1069 actionSettingsUseFlagGroups=a;
1071 a= new QAction( tr( "Use hide flag during exports " ), QPixmap(), tr( "Use hide flags" ), 0, this, "hideexport" );
1072 a->setToggleAction(true);
1073 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1075 actionSettingsUseHideExport=a;
1079 void Main::setupTestActions()
1081 QPopupMenu *menu = new QPopupMenu( this );
1082 menuBar()->insertItem( tr( "&Test" ), menu );
1085 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1086 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1091 void Main::setupHelpActions()
1093 QPopupMenu *menu = new QPopupMenu( this );
1094 menuBar()->insertItem( tr( "&Help" ), menu );
1097 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1098 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1101 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1102 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1105 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1106 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1111 void Main::setupContextMenus()
1115 // Context Menu for branch or mapcenter
1116 branchContextMenu =new QPopupMenu (this);
1119 branchAddContextMenu =new QPopupMenu (this);
1120 actionEditPaste->addTo ( branchAddContextMenu );
1121 actionEditAddBranch->addTo ( branchAddContextMenu );
1122 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1123 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1124 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1125 branchAddContextMenu->insertSeparator();
1126 actionEditLoadImage->addTo( branchAddContextMenu );
1127 branchAddContextMenu->insertSeparator();
1128 actionEditImportAdd->addTo ( branchAddContextMenu );
1129 actionEditImportReplace->addTo ( branchAddContextMenu );
1132 branchRemoveContextMenu =new QPopupMenu (this);
1133 actionEditCut->addTo ( branchRemoveContextMenu );
1134 actionEditDelete->addTo ( branchRemoveContextMenu );
1135 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
1136 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1138 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1139 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1141 actionEditSaveBranch->addTo( branchContextMenu );
1143 branchContextMenu->insertSeparator();
1144 actionEditOpenURL->addTo ( branchContextMenu );
1145 actionEditOpenURLTab->addTo ( branchContextMenu );
1146 actionEditURL->addTo ( branchContextMenu );
1147 actionEditHeading2URL->addTo ( branchContextMenu );
1148 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1150 actionEditBugzilla2URL->addTo( branchContextMenu );
1151 actionEditFATE2URL->addTo( branchContextMenu );
1153 branchContextMenu->insertSeparator();
1154 actionEditOpenVymLink->addTo ( branchContextMenu );
1155 actionEditVymLink->addTo ( branchContextMenu );
1156 actionEditDeleteVymLink->addTo ( branchContextMenu );
1158 branchContextMenu->insertSeparator();
1159 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1161 branchContextMenu->insertSeparator();
1162 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1163 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1164 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1166 // Context Menu for links in a branch menu
1167 // This will be populated "on demand" in MapEditor::updateActions
1168 branchContextMenu->insertSeparator();
1169 branchLinksContextMenu =new QPopupMenu (this);
1170 branchLinksContextMenuDup =new QPopupMenu (this);
1171 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1172 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1174 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1175 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1177 // Context menu for floatimage
1178 floatimageContextMenu =new QPopupMenu (this);
1179 saveImageFormatMenu=new QPopupMenu (this);
1180 exportImageFormatMenu=new QPopupMenu (this);
1182 QStrList fmt = QImage::outputFormats();
1183 for (const char* f = fmt.first(); f; f = fmt.next())
1185 saveImageFormatMenu->insertItem( f );
1186 exportImageFormatMenu->insertItem( f );
1188 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1189 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1190 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1192 floatimageContextMenu->insertSeparator();
1193 actionEditCopy->addTo( floatimageContextMenu );
1194 actionEditCut->addTo( floatimageContextMenu );
1196 /* FIXME not needed any longer
1197 floatimageContextMenu->insertSeparator();
1198 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1199 a->setToggleAction(true);
1200 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1201 a->addTo( floatimageContextMenu);
1202 actionEditToggleFloatExport=a;
1205 floatimageContextMenu->insertSeparator();
1206 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1208 exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1210 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1211 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1212 a->addTo (exportMenu);
1214 a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" );
1215 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1216 a->addTo( exportMenu );
1218 a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" );
1219 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1220 a->addTo( exportMenu );
1222 a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
1223 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1224 a->addTo (exportMenu);
1226 a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
1227 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1228 a->addTo( exportMenu );
1230 a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1231 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1232 a->addTo( exportMenu );
1234 a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" );
1235 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1236 a->addTo( exportMenu );
1238 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1240 a = new QAction( tr( "Export as")+" HTML" , QPixmap(), "HTML...", 0, this, "exportHTML");
1241 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1242 a->addTo( exportMenu );
1246 // Context menu for canvas
1247 canvasContextMenu =new QPopupMenu (this);
1248 actionEditMapInfo->addTo( canvasContextMenu );
1249 canvasContextMenu->insertSeparator();
1250 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1251 canvasContextMenu->insertSeparator();
1252 actionFormatLinkColorHint->addTo( canvasContextMenu );
1253 actionFormatLinkColor->addTo( canvasContextMenu );
1254 actionFormatBackColor->addTo( canvasContextMenu );
1256 // Menu for last opened files
1257 // Read settings initially
1259 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1260 for (int i=1;i<=j;i++)
1262 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1263 if (!s.isEmpty() && j<=maxLastMaps)
1266 setupLastMapsMenu();
1267 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1270 void Main::setupLastMapsMenu()
1272 // Remove double entries
1273 QStringList::Iterator it=lastMaps.begin();
1274 QStringList::Iterator jt;
1275 while (it!=lastMaps.end() )
1279 while (jt!=lastMaps.end() )
1282 jt=lastMaps.remove(jt);
1289 // Limit length of list to maxLastMaps
1290 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1292 // build Menu from lastMaps string list
1293 lastMapsMenu->clear();
1294 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1295 lastMapsMenu->insertItem (*it );
1299 void Main::hideEvent (QHideEvent * )
1301 if (!textEditor->isMinimized() ) textEditor->hide();
1304 void Main::showEvent (QShowEvent * )
1306 if (textEditor->showWithMain()) textEditor->showNormal();
1309 bool Main::reallyWriteDirectory(const QString &dir)
1311 QStringList eList = QDir(dir).entryList();
1312 if (eList.first() ==".") eList.pop_front(); // remove "."
1313 if (eList.first() =="..") eList.pop_front(); // remove "."
1314 if (!eList.isEmpty())
1316 QMessageBox mb( __VYM,
1317 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1318 QMessageBox::Warning,
1320 QMessageBox::Cancel | QMessageBox::Default,
1321 QMessageBox::QMessageBox::NoButton );
1323 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1324 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1327 case QMessageBox::Yes:
1330 case QMessageBox::Cancel:
1338 QString Main::browseDirectory (const QString &caption)
1340 QFileDialog fd(this,caption);
1341 fd.setMode (QFileDialog::DirectoryOnly);
1342 fd.setCaption(__VYM " - "+caption);
1345 if ( fd.exec() == QDialog::Accepted )
1346 return fd.selectedFile();
1351 MapEditor* Main::currentMapEditor() const
1353 if ( tabWidget->currentPage() &&
1354 tabWidget->currentPage()->inherits( "MapEditor" ) )
1355 return (MapEditor*)tabWidget->currentPage();
1359 //TODO not used now, maybe use this for overview window later
1360 void Main::newView()
1362 // Open a new view... have it delete when closed.
1363 Main *m = new Main(0, 0, WDestructiveClose);
1364 qApp->setMainWidget(m);
1366 qApp->setMainWidget(0);
1369 void Main::editorChanged(QWidget *)
1371 // Unselect all possibly selected objects
1372 // (Important to update note editor)
1375 for (i=0;i<=tabWidget->count() -1;i++)
1378 me=(MapEditor*)tabWidget->page(i);
1381 currentMapEditor()->reselect();
1383 // Update actions to in menus and toolbars according to editor
1384 currentMapEditor()->updateActions();
1387 void Main::fileNew()
1389 QString fn="unnamed";
1390 MapEditor* medit = new MapEditor (tabWidget, true);
1391 tabWidget->addTab (medit,fn);
1392 tabWidget->showPage(medit);
1393 medit->viewport()->setFocus();
1394 // For the very first map we do not have flagrows yet...
1395 medit->select("mc:");
1398 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1400 ErrorCode err=success;
1402 // fn is usually the archive, mapfile the file after uncompressing
1405 // Make fn absolute (needed for unzip)
1406 fn=QDir (fn).absPath();
1412 // Check, if map is already loaded
1414 while (i<=tabWidget->count() -1)
1416 me=(MapEditor*)tabWidget->page(i);
1417 if (me->getFilePath() == fn)
1419 // Already there, ask for confirmation
1420 QMessageBox mb( __VYM,
1421 tr("The map %1\nis already opened."
1422 "Opening the same map in multiple editors may lead \n"
1423 "to confusion when finishing working with vym."
1424 "Do you want to").arg(fn),
1425 QMessageBox::Warning,
1426 QMessageBox::Yes | QMessageBox::Default,
1427 QMessageBox::Cancel | QMessageBox::Escape,
1428 QMessageBox::QMessageBox::NoButton);
1429 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1430 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1433 case QMessageBox::Yes:
1435 i=tabWidget->count();
1437 case QMessageBox::Cancel:
1449 if ( !fn.isEmpty() )
1451 me = currentMapEditor();
1452 int tabIndex=tabWidget->currentPageIndex();
1453 // Check first, if mapeditor exists
1454 // If it is not default AND we want a new map,
1455 // create a new mapeditor in a new tab
1456 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1458 me = new MapEditor (tabWidget,true);
1459 tabWidget->addTab (me,fn);
1460 tabIndex=tabWidget->indexOf (me);
1461 tabWidget->setCurrentPage (tabIndex);
1464 // Check, if file exists (important for creating new files
1465 // from command line
1466 if (!QFile(fn).exists() )
1468 QMessageBox mb( __VYM,
1469 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1470 QMessageBox::Question,
1472 QMessageBox::Cancel | QMessageBox::Default,
1473 QMessageBox::QMessageBox::NoButton );
1475 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1476 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1479 case QMessageBox::Yes:
1481 currentMapEditor()->setFilePath(fn);
1482 tabWidget->setTabLabel (currentMapEditor(),
1483 currentMapEditor()->getFileName() );
1484 statusBar()->message( "Created " + fn , statusbarTime );
1487 case QMessageBox::Cancel:
1488 // don't create new map
1489 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1496 //tabWidget->currentPage() won't be NULL here, because of above...
1497 tabWidget->showPage(me);
1498 me->viewport()->setFocus();
1500 // Create temporary directory for packing
1501 char tmpdir1[]="/tmp/vym-XXXXXX";
1502 QString tmpMapDir=mkdtemp(tmpdir1);
1504 // Try to unzip file
1505 err=unzipDir (tmpMapDir,fn);
1509 me->setZipped(false);
1512 me->setZipped(true);
1514 // Look for mapname.xml
1515 mapfile= fn.left(fn.findRev(".",-1,true));
1516 mapfile=mapfile.section( '/', -1 );
1517 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1518 if (!file.exists() )
1520 // mapname.xml does not exist, well,
1521 // maybe some renamed the mapname.vym file...
1522 // Try to find any .xml in the toplevel
1523 // directory of the .vym file
1524 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1525 if (flist.count()==1)
1527 // Only one entry, take this one
1528 mapfile=tmpMapDir + "/"+flist.first();
1531 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1532 *it=tmpMapDir + "/" + *it;
1533 // TODO Multiple entries, load all (but only the first one into this ME)
1534 //mainWindow->fileLoadFromTmp (flist);
1535 //returnCode=1; // Silently forget this attempt to load
1536 qWarning ("MainWindow::load (fn) multimap found...");
1539 if (flist.isEmpty() )
1541 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1542 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1545 } //file doesn't exist
1547 mapfile=file.name();
1552 // Save existing filename in case we import
1553 QString fn_org=me->getFilePath();
1555 // Finally load map into mapEditor
1556 me->setFilePath (mapfile,fn);
1557 err=me->load(mapfile,lmode);
1559 // Restore old (maybe empty) filepath, if this is an import
1561 me->setFilePath (fn_org);
1564 // Finally check for errors and go home
1567 if (lmode==NewMap) fileCloseMap();
1568 statusBar()->message( "Could not load " + fn, statusbarTime );
1573 me->setFilePath (fn);
1574 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1575 if (fn.left(9)!="/tmp/vym-")
1577 // Only append to lastMaps if not loaded from a tmpDir
1578 // e.g. imported bookmarks are in a tmpDir
1579 lastMaps.prepend(me->getFilePath() );
1580 setupLastMapsMenu();
1582 actionFilePrint->setEnabled (true);
1584 statusBar()->message( "Loaded " + fn, statusbarTime );
1588 removeDir (QDir(tmpMapDir));
1594 void Main::fileLoad(const LoadMode &lmode)
1596 QFileDialog *fd=new QFileDialog( this);
1597 if (!lastFileDir.isEmpty())
1598 fd->setDir (lastFileDir);
1599 fd->setMode (QFileDialog::ExistingFiles);
1600 fd->addFilter ("XML (*.xml)");
1601 fd->addFilter ("VYM map (*.vym *.vyp)");
1605 fd->setCaption(tr("Load vym map"));
1608 fd->setCaption(tr("Import: Add vym map to selection"));
1611 fd->setCaption(tr("Import: Replace selection with vym map"));
1617 if ( fd->exec() == QDialog::Accepted )
1619 lastFileDir=fd->dirPath();
1620 QStringList flist = fd->selectedFiles();
1621 QStringList::Iterator it = flist.begin();
1622 while( it != flist.end() )
1625 fileLoad(*it, lmode);
1632 void Main::fileLoad()
1637 void Main::fileLoadLast(int i)
1639 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1642 void Main::fileSave(const SaveMode &savemode)
1644 // tmp dir for zipping
1648 ErrorCode err=success;
1650 QString safeFilePath;
1652 bool saveZipped=currentMapEditor()->saveZipped();
1654 MapEditor * me=currentMapEditor();
1657 QString fn=me->getFilePath();
1658 // filename=unnamed, filepath="" in constructor...
1659 if ( !fn.isEmpty() )
1661 // We have a filepath, go on saving
1662 // First remove existing file, we
1663 // don't want to add to old zip archives
1667 QMessageBox::warning( 0, tr( "Save Error" ),
1668 fn+ tr("\ncould not be removed before saving"));
1670 // Look, if we should zip the data:
1673 QMessageBox mb( __VYM,
1674 tr("The map %1\ndid not use the compressed "
1675 "vym file format.\nWriting it uncompressed will also write images \n"
1676 "and flags and thus may overwrite files in the "
1677 "given directory\n\nDo you want to write the map").arg(fn),
1678 QMessageBox::Warning,
1679 QMessageBox::Yes | QMessageBox::Default,
1681 QMessageBox::Cancel | QMessageBox::Escape);
1682 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1683 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1684 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1687 case QMessageBox::Yes:
1688 // save compressed (default file format)
1691 case QMessageBox::No:
1692 // save uncompressed
1695 case QMessageBox::Cancel:
1704 char tmpdir1[]="/tmp/vym-XXXXXX";
1705 tmpMapDir=mkdtemp(tmpdir1);
1707 safeFilePath=me->getFilePath();
1708 me->setFilePath (tmpMapDir+"/"+
1709 me->getMapName()+ ".xml",
1711 me->save (savemode);
1712 me->setFilePath (safeFilePath);
1714 zipDir (tmpMapDir,fn);
1719 safeFilePath=me->getFilePath();
1720 me->setFilePath (fn, safeFilePath);
1721 me->save (savemode);
1722 me->setFilePath (safeFilePath);
1724 } // filepath available
1727 // We have no filepath yet,
1728 // call fileSaveAs() now, this will call fileSave()
1730 fileSaveAs(savemode);
1734 if (saveZipped && !tmpMapDir.isEmpty())
1736 removeDir (QDir(tmpMapDir));
1740 statusBar()->message(
1741 tr("Saved %1").arg(me->getFilePath()),
1743 lastMaps.prepend(me->getFilePath() );
1744 setupLastMapsMenu();
1746 statusBar()->message(
1747 tr("Couldn't save ").arg(me->getFilePath()),
1751 void Main::fileSave()
1753 fileSave (CompleteMap);
1756 void Main::fileSaveAs(const SaveMode& savemode)
1760 if (currentMapEditor())
1762 if (savemode==CompleteMap)
1763 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1765 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1766 if ( !fn.isEmpty() )
1768 // Check for existing file
1769 if (QFile (fn).exists())
1771 QMessageBox mb( __VYM,
1772 tr("The file %1\nexists already. Do you want to").arg(fn),
1773 QMessageBox::Warning,
1774 QMessageBox::Yes | QMessageBox::Default,
1775 QMessageBox::Cancel | QMessageBox::Escape,
1776 QMessageBox::QMessageBox::NoButton);
1777 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1778 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1781 case QMessageBox::Yes:
1784 case QMessageBox::Cancel:
1791 // New file, add extension to filename, if missing
1792 // This is always .vym or .vyp, depending on savemode
1793 if (savemode==CompleteMap)
1795 if (!fn.contains (".vym") && !fn.contains (".xml"))
1799 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1808 currentMapEditor()->setFilePath(fn);
1812 if (savemode==CompleteMap)
1813 tabWidget->setTabLabel (currentMapEditor(),
1814 currentMapEditor()->getFileName() );
1820 void Main::fileSaveAs()
1822 fileSaveAs (CompleteMap);
1825 void Main::fileImportKDEBookmarks()
1827 ImportKDEBookmarks im;
1829 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1830 currentMapEditor()->setFilePath ("");
1833 void Main::fileImportMM()
1837 QFileDialog *fd=new QFileDialog( this);
1838 if (!lastFileDir.isEmpty())
1839 fd->setDir (lastFileDir);
1840 fd->setMode (QFileDialog::ExistingFiles);
1841 fd->addFilter ("Mind Manager (*.mmap)");
1842 fd->setCaption(tr("Import")+" "+"Mind Manager");
1845 if ( fd->exec() == QDialog::Accepted )
1847 lastFileDir=fd->dirPath();
1848 QStringList flist = fd->selectedFiles();
1849 QStringList::Iterator it = flist.begin();
1850 while( it != flist.end() )
1853 if (im.transform() &&
1854 success==fileLoad (im.getTransformedFile(),NewMap) &&
1855 currentMapEditor() )
1856 currentMapEditor()->setFilePath ("");
1865 void Main::fileImportDir()
1867 if (currentMapEditor())
1868 currentMapEditor()->importDir();
1871 void Main::fileExportXML()
1873 if (currentMapEditor())
1875 QString dir=browseDirectory(tr("Export XML to directory"));
1876 if (dir !="" && reallyWriteDirectory(dir) )
1877 currentMapEditor()->exportXML(dir);
1881 void Main::fileExportHTML()
1883 MapEditor *me=currentMapEditor();
1886 ExportHTMLDialog dia(this);
1888 if (dia.exec()==QDialog::Accepted)
1890 QString dir=dia.getDir();
1891 if (reallyWriteDirectory(dir) )
1893 me->setExportMode (true);
1894 me->exportXML (dia.getDir() );
1895 dia.doExport(me->getMapName() );
1896 me->setExportMode (false);
1902 void Main::fileExportXHTML()
1904 MapEditor *me=currentMapEditor();
1908 ExportXHTMLDialog dia(this);
1909 dia.setFilePath (me->getFilePath() );
1910 dia.setMapName (me->getMapName() );
1913 if (dia.exec()==QDialog::Accepted)
1915 QString dir=dia.getDir();
1916 // Check, if warnings should be used before overwriting
1917 // the output directory
1920 ok=reallyWriteDirectory(dir);
1926 me->exportXML (dia.getDir() );
1927 dia.doExport(me->getMapName() );
1928 if (dia.hasChanged())
1935 void Main::fileExportImage(int item)
1937 MapEditor *me=currentMapEditor();
1940 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1942 if ( !fn.isEmpty() )
1943 me->exportImage(fn,item);
1945 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1950 void Main::fileExportASCII()
1952 MapEditor *me=currentMapEditor();
1956 ex.setMapCenter(me->getMapCenter());
1957 ex.addFilter ("TXT (*.txt)");
1958 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1959 if (ex.execDialog() )
1961 me->setExportMode(true);
1963 me->setExportMode(false);
1968 void Main::fileExportLaTeX()
1970 MapEditor *me=currentMapEditor();
1974 ex.setMapCenter(me->getMapCenter());
1975 ex.addFilter ("Tex (*.tex)");
1976 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1977 if (ex.execDialog() )
1979 me->setExportMode(true);
1981 me->setExportMode(false);
1986 void Main::fileExportKDEBookmarks()
1988 ExportKDEBookmarks ex;
1989 MapEditor *me=currentMapEditor();
1992 ex.setMapCenter (me->getMapCenter() );
1997 void Main::fileExportTaskjuggler()
1999 ExportTaskjuggler ex;
2000 MapEditor *me=currentMapEditor();
2003 ex.setMapCenter (me->getMapCenter() );
2004 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2005 ex.addFilter ("Taskjuggler (*.tjp)");
2006 if (ex.execDialog() )
2008 me->setExportMode(true);
2010 me->setExportMode(false);
2015 void Main::fileExportOOPresentation()
2017 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2018 // FIXME add extra info in dialog
2019 //ImagePreview *p =new ImagePreview (fd);
2020 //fd->setContentsPreviewEnabled( TRUE );
2021 //fd->setContentsPreview( p, p );
2022 //fd->setPreviewMode( QFileDialog::Contents );
2023 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2024 //fd->setDir (lastImageDir);
2027 if ( fd->exec() == QDialog::Accepted )
2029 QString fn=fd->selectedFile();
2030 //lastImageDir=fn.left(fn.findRev ("/"));
2031 if (currentMapEditor())
2032 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2036 void Main::fileCloseMap()
2038 if (currentMapEditor())
2040 if (currentMapEditor()->hasChanged())
2042 QMessageBox mb( __VYM,
2043 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2044 QMessageBox::Warning,
2045 QMessageBox::Yes | QMessageBox::Default,
2047 QMessageBox::Cancel | QMessageBox::Escape );
2048 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2049 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2052 case QMessageBox::Yes:
2054 fileSave(CompleteMap);
2056 case QMessageBox::No:
2057 // close without saving
2059 case QMessageBox::Cancel:
2064 currentMapEditor()->closeMap();
2065 tabWidget->removePage(currentMapEditor());
2066 if (tabWidget->count()==0)
2067 actionFilePrint->setEnabled (false);
2071 void Main::filePrint()
2073 if (currentMapEditor())
2074 currentMapEditor()->print();
2077 void Main::fileExitVYM()
2079 // Check if one or more editors have changed
2082 for (i=0;i<=tabWidget->count() -1;i++)
2085 me=(MapEditor*)tabWidget->page(i);
2087 // If something changed, ask what to do
2088 if (me->isUnsaved())
2090 tabWidget->setCurrentPage(i);
2091 QMessageBox mb( __VYM,
2092 tr("This map is not saved yet. Do you want to"),
2093 QMessageBox::Warning,
2094 QMessageBox::Yes | QMessageBox::Default,
2096 QMessageBox::Cancel | QMessageBox::Escape );
2097 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2098 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2100 // Call undocumented function: setActiveWindow is only
2101 // possible, if widget is visible. This depends on
2103 #if defined(Q_OS_LINUX)
2104 qt_wait_for_window_manager( this);
2106 mb.setActiveWindow();
2107 switch( mb.exec() ) {
2108 case QMessageBox::Yes:
2109 // save (the changed editors) and exit
2110 fileSave(CompleteMap);
2112 case QMessageBox::No:
2113 // exit without saving
2115 case QMessageBox::Cancel:
2116 // don't save and don't exit
2120 } // loop over all MEs
2124 void Main::editUndo()
2126 if (currentMapEditor())
2127 currentMapEditor()->undo();
2130 void Main::editRedo()
2132 if (currentMapEditor())
2133 currentMapEditor()->redo();
2136 void Main::editCopy()
2138 if (currentMapEditor())
2139 currentMapEditor()->copy();
2142 void Main::editPaste()
2144 if (currentMapEditor())
2145 currentMapEditor()->paste();
2148 void Main::editCut()
2150 if (currentMapEditor())
2151 currentMapEditor()->cut();
2154 void Main::editOpenFindWindow()
2156 findWindow->popup();
2157 findWindow->raise();
2159 // Call undocumented function: setActiveWindow is only
2160 // possible, if widget is visible. This depends on
2162 #if defined(Q_OS_LINUX)
2163 qt_wait_for_window_manager( this);
2165 findWindow->setActiveWindow();
2168 void Main::editFind(QString s)
2171 BranchObj *bo=currentMapEditor()->findText(s, cs);
2174 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2177 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2178 tr("No matches found for <b>%1</b>").arg(s));
2182 void Main::editFindChanged()
2183 { // Notify editor, to abort the current find process
2184 currentMapEditor()->findReset();
2187 void Main::editOpenURL()
2190 if (currentMapEditor())
2192 QString url=currentMapEditor()->getURL();
2193 if (url=="") return;
2194 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2195 procBrowser = new QProcess( this );
2197 procBrowser->addArgument( browser);
2198 procBrowser->addArgument( url);
2200 if ( !procBrowser->start() )
2202 // try to set path to browser
2203 QMessageBox::warning(0,
2205 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2206 tr("Please use Settings->")+tr("Set application to open an URL"));
2211 void Main::editOpenURLTab()
2213 if (currentMapEditor())
2215 QString url=currentMapEditor()->getURL();
2216 if (url=="") return;
2217 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2218 if (browser.contains("konqueror") && procBrowser && procBrowser->isRunning())
2220 // Try to open new tab in existing browser
2221 QProcess *p=new QProcess (this);
2222 p->addArgument ("dcop");
2223 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2224 p->addArgument ("konqueror-mainwindow#1");
2225 p->addArgument ("newTab");
2226 p->addArgument (url);
2228 // try to set browser
2229 QMessageBox::warning(0,
2231 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2238 void Main::editURL()
2240 if (currentMapEditor())
2241 currentMapEditor()->editURL();
2244 void Main::editHeading2URL()
2246 if (currentMapEditor())
2247 currentMapEditor()->editHeading2URL();
2250 void Main::editBugzilla2URL()
2252 if (currentMapEditor())
2253 currentMapEditor()->editBugzilla2URL();
2256 void Main::editFATE2URL()
2258 if (currentMapEditor())
2259 currentMapEditor()->editFATE2URL();
2262 void Main::editOpenVymLink()
2264 // Get current path to map
2265 QString currentVymLink;
2266 if (currentMapEditor())
2268 currentVymLink=currentMapEditor()->getVymLink();
2269 // compare path with already loaded maps
2273 for (i=0;i<=tabWidget->count() -1;i++)
2275 me=(MapEditor*)tabWidget->page(i);
2276 if (currentVymLink==me->getFilePath() )
2285 if (!QFile(currentVymLink).exists() )
2286 QMessageBox::critical( 0, tr( "Critical Error" ),
2287 tr("Couldn't open map %1").arg(currentVymLink));
2290 fileLoad (currentVymLink, NewMap);
2291 tabWidget->setCurrentPage (tabWidget->count()-1);
2294 // Go to tab containing the map
2295 tabWidget->setCurrentPage (index);
2299 void Main::editVymLink()
2301 if (currentMapEditor())
2302 currentMapEditor()->editVymLink();
2305 void Main::editDeleteVymLink()
2307 if (currentMapEditor())
2308 currentMapEditor()->deleteVymLink();
2311 void Main::editToggleHideExport()
2313 if (currentMapEditor())
2314 currentMapEditor()->setHideExport();
2317 void Main::editMapInfo()
2319 if (currentMapEditor())
2320 currentMapEditor()->editMapInfo();
2323 void Main::editMoveUp()
2325 if (currentMapEditor())
2326 currentMapEditor()->moveBranchUp();
2329 void Main::editMoveDown()
2331 if (currentMapEditor())
2332 currentMapEditor()->moveBranchDown();
2335 void Main::editToggleScroll()
2337 if (currentMapEditor())
2339 currentMapEditor()->toggleScroll();
2343 void Main::editUnScrollAll()
2345 if (currentMapEditor())
2347 currentMapEditor()->unScrollAll();
2351 void Main::editHeading()
2353 if (currentMapEditor())
2354 currentMapEditor()->editHeading();
2357 void Main::editNewBranch()
2359 if (currentMapEditor())
2360 currentMapEditor()->addNewBranch(0);
2363 void Main::editNewBranchHere()
2365 if (currentMapEditor())
2366 currentMapEditor()->addNewBranchHere();
2369 void Main::editNewBranchAbove()
2371 if (currentMapEditor())
2372 currentMapEditor()->addNewBranch(-1);
2375 void Main::editNewBranchBelow()
2377 if (currentMapEditor())
2378 currentMapEditor()->addNewBranch(1);
2381 void Main::editImportAdd()
2383 fileLoad (ImportAdd);
2386 void Main::editImportReplace()
2388 fileLoad (ImportReplace);
2391 void Main::editSaveBranch()
2393 fileSaveAs (PartOfMap);
2396 void Main::editRemoveBranchHere()
2398 if (currentMapEditor())
2399 currentMapEditor()->removeBranchHere();
2402 void Main::editRemoveChilds()
2404 if (currentMapEditor())
2405 currentMapEditor()->removeChilds();
2408 void Main::editDeleteSelection()
2410 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2411 currentMapEditor()->deleteSelection();
2414 void Main::editUpperBranch()
2416 if (currentMapEditor())
2417 currentMapEditor()->selectUpperBranch();
2420 void Main::editLowerBranch()
2422 if (currentMapEditor())
2423 currentMapEditor()->selectLowerBranch();
2426 void Main::editLeftBranch()
2428 if (currentMapEditor())
2429 currentMapEditor()->selectLeftBranch();
2432 void Main::editRightBranch()
2434 if (currentMapEditor())
2435 currentMapEditor()->selectRightBranch();
2438 void Main::editFirstBranch()
2440 if (currentMapEditor())
2441 currentMapEditor()->selectFirstBranch();
2444 void Main::editLastBranch()
2446 if (currentMapEditor())
2447 currentMapEditor()->selectLastBranch();
2450 void Main::editLoadImage()
2452 if (currentMapEditor())
2453 currentMapEditor()->loadFloatImage();
2456 void Main::editSaveImage(int item)
2458 if (currentMapEditor())
2459 currentMapEditor()->saveFloatImage(item);
2462 void Main::editFollowXLink(int item)
2464 if (currentMapEditor())
2465 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2468 void Main::editEditXLink(int item)
2470 if (currentMapEditor())
2471 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2474 void Main::formatSelectColor()
2476 if (currentMapEditor())
2478 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2479 if ( !col.isValid() ) return;
2480 currentMapEditor()->setColor( col );
2481 colorChanged( col );
2485 void Main::formatPickColor()
2487 if (currentMapEditor())
2488 colorChanged( currentMapEditor()->pickColor() );
2491 void Main::colorChanged(QColor c)
2493 QPixmap pix( 16, 16 );
2495 actionFormatColor->setIconSet( pix );
2498 void Main::formatColorItem()
2500 if (currentMapEditor())
2501 currentMapEditor()->colorItem();
2504 void Main::formatColorBranch()
2506 if (currentMapEditor())
2507 currentMapEditor()->colorBranch();
2510 void Main::formatLinkStyleLine()
2512 if (currentMapEditor())
2513 currentMapEditor()->setLinkStyle(StyleLine);
2516 void Main::formatLinkStyleParabel()
2518 if (currentMapEditor())
2519 currentMapEditor()->setLinkStyle(StyleParabel);
2522 void Main::formatLinkStylePolyLine()
2524 if (currentMapEditor())
2525 currentMapEditor()->setLinkStyle(StylePolyLine);
2528 void Main::formatLinkStylePolyParabel()
2530 if (currentMapEditor())
2531 currentMapEditor()->setLinkStyle(StylePolyParabel);
2534 void Main::formatSelectBackColor()
2536 if (currentMapEditor())
2537 currentMapEditor()->selectBackgroundColor();
2540 void Main::formatSelectLinkColor()
2542 if (currentMapEditor())
2543 currentMapEditor()->selectLinkColor();
2546 void Main::formatToggleLinkColorHint()
2548 currentMapEditor()->toggleLinkColorHint();
2551 void Main::formatFrameNone()
2553 if (currentMapEditor())
2554 currentMapEditor()->setFrame(NoFrame);
2557 void Main::formatFrameRectangle()
2559 if (currentMapEditor())
2560 currentMapEditor()->setFrame(Rectangle);
2563 void Main::formatIncludeImagesVer()
2565 if (currentMapEditor())
2566 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2569 void Main::formatIncludeImagesHor()
2571 if (currentMapEditor())
2572 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2575 void Main::formatHideLinkUnselected()
2577 if (currentMapEditor())
2578 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2581 void Main::viewZoomReset()
2583 if (currentMapEditor())
2587 currentMapEditor()->setWorldMatrix( m );
2588 currentMapEditor()->setViewCenter();
2589 currentMapEditor()->adjustCanvasSize();
2593 void Main::viewZoomIn()
2595 if (currentMapEditor())
2597 QWMatrix m = currentMapEditor()->worldMatrix();
2598 m.scale( 1.25, 1.25 );
2599 currentMapEditor()->setWorldMatrix( m );
2600 currentMapEditor()->setViewCenter();
2601 currentMapEditor()->adjustCanvasSize();
2605 void Main::viewZoomOut()
2607 if (currentMapEditor())
2609 QWMatrix m = currentMapEditor()->worldMatrix();
2610 m.scale( 0.8, 0.8 );
2611 currentMapEditor()->setWorldMatrix( m );
2612 currentMapEditor()->setViewCenter();
2613 currentMapEditor()->adjustCanvasSize();
2617 void Main::modModeColor()
2621 void Main::modModeLink()
2625 bool Main::settingsPDF()
2627 // Default browser is set in constructor
2629 QString text = QInputDialog::getText(
2630 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2631 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2633 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2638 bool Main::settingsURL()
2640 // Default browser is set in constructor
2642 QString text = QInputDialog::getText(
2643 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2644 settings.readEntry("/vym/mainwindow/readerURL")
2647 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2651 void Main::windowToggleNoteEditor()
2653 if (textEditor->showWithMain() )
2654 windowHideNoteEditor();
2656 windowShowNoteEditor();
2659 void Main::updateNoteFlag()
2661 if (currentMapEditor())
2662 currentMapEditor()->updateNoteFlag();
2665 void Main::windowShowNoteEditor()
2667 textEditor->setShowWithMain(true);
2669 actionViewToggleNoteEditor->setOn (true);
2672 void Main::windowHideNoteEditor()
2674 textEditor->setShowWithMain(false);
2676 actionViewToggleNoteEditor->setOn (false);
2679 void Main::windowNextEditor()
2681 if (tabWidget->currentPageIndex() < tabWidget->count())
2682 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2685 void Main::windowPreviousEditor()
2687 if (tabWidget->currentPageIndex() >0)
2688 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2691 void Main::standardFlagChanged()
2693 currentMapEditor()->toggleStandardFlag(sender()->name());
2696 void Main::testFunction()
2698 currentMapEditor()->testFunction();
2701 void Main::helpDoc()
2704 #if defined(Q_OS_MACX)
2705 docpath="./vym.app/Contents/vym.pdf";
2707 // default path in SUSE LINUX
2708 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2711 if (!QFile (docpath).exists() )
2713 // relative path for easy testing in tarball
2714 docpath="doc/vym.pdf";
2715 if (!QFile (docpath).exists() )
2717 // relative path for testing while still writing vym.tex
2718 docpath="doc/tex/vym.pdf";
2719 if (!QFile (docpath).exists() )
2721 // Try yet another one for Knoppix
2722 docpath="/usr/share/doc/packages/vym/vym.pdf";
2723 if (!QFile (docpath).exists() )
2725 QMessageBox::critical(0,
2726 tr("Critcal error"),
2727 tr("Couldn't find the documentation\n"
2728 "vym.pdf in various places."));
2735 Process *pdfProc = new Process();
2736 pdfProc->clearArguments();
2737 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2738 pdfProc->addArgument( docpath);
2740 if ( !pdfProc->start() )
2743 QMessageBox::warning(0,
2745 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
2746 tr("Please use Settings->")+tr("Set application to open PDF files"));
2753 void Main::helpAbout()
2756 ad.setName ("aboutwindow");
2757 ad.setMinimumSize(500,500);
2758 ad.resize (QSize (500,500));
2762 void Main::helpAboutQT()
2764 QMessageBox::aboutQt( this, "Qt Application Example" );