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 "aboutdialog.h"
23 #include "exportoofiledialog.h"
25 #include "exportxhtmldialog.h"
27 #include "flagrowobj.h"
29 #include "mapeditor.h"
34 #include "showtextdialog.h"
35 #include "texteditor.h"
38 extern TextEditor *textEditor;
39 extern Main *mainWindow;
40 extern QString tmpVymDir;
41 extern QString clipboardDir;
42 extern bool clipboardEmpty;
43 extern int statusbarTime;
44 extern FlagRowObj* standardFlagsDefault;
45 extern FlagRowObj* systemFlagsDefault;
47 extern QPtrList <QAction> actionListBranches;
49 extern QAction* actionFileSave;
50 extern QAction* actionFilePrint;
51 extern QAction* actionEditUndo;
52 extern QAction* actionEditRedo;
53 extern QAction *actionEditCopy;
54 extern QAction *actionEditCut;
55 extern QAction *actionEditPaste;
56 extern QAction *actionEditMoveUp;
57 extern QAction *actionEditMoveDown;
58 extern QAction *actionEditToggleScroll;
59 extern QAction* actionEditOpenURL;
60 extern QAction* actionEditOpenURLTab;
61 extern QAction* actionEditURL;
62 extern QAction* actionEditHeading2URL;
63 extern QAction* actionEditBugzilla2URL;
64 extern QAction* actionEditFATE2URL;
65 extern QAction *actionEditOpenVymLink;
66 extern QAction *actionEditVymLink;
67 extern QAction *actionEditDeleteVymLink;
68 extern QAction *actionEditToggleHideExport;
69 extern QAction *actionEditMapInfo;
70 extern QAction *actionEditHeading;
71 extern QAction *actionEditDelete;
72 extern QAction *actionEditAddBranch;
73 extern QAction *actionEditAddBranchHere;
74 extern QAction *actionEditAddBranchAbove;
75 extern QAction *actionEditAddBranchBelow;
76 extern QAction *actionEditRemoveBranchKeepChilds;
77 extern QAction *actionEditRemoveChilds;
78 extern QAction *actionEditImportAdd;
79 extern QAction *actionEditImportReplace;
80 extern QAction *actionEditSaveBranch;
81 extern QAction *actionEditSelectFirst;
82 extern QAction *actionEditSelectLast;
83 extern QAction *actionEditLoadImage;
85 extern QAction* actionFormatColor;
86 extern QAction* actionFormatPickColor;
87 extern QAction* actionFormatColorBranch;
88 extern QAction* actionFormatColorSubtree;
89 extern QAction* actionFormatLinkColorHint;
90 extern QAction* actionFormatBackColor;
91 extern QAction* actionFormatLinkColor;
92 extern QAction *actionFormatIncludeImagesVer;
93 extern QAction *actionFormatIncludeImagesHor;
95 extern QActionGroup* actionGroupModModes;
96 extern QAction* actionModModeColor;
97 extern QAction* actionModModeLink;
98 extern QAction* actionModModeCopy;
100 extern QActionGroup *actionGroupFormatFrameTypes;
101 extern QAction *actionFormatFrameNone;
102 extern QAction *actionFormatFrameRectangle;
104 extern QActionGroup *actionGroupFormatLinkStyles;
105 extern QAction *actionFormatLinkStyleLine;
106 extern QAction *actionFormatLinkStyleParabel;
107 extern QAction *actionFormatLinkStylePolyLine;
108 extern QAction *actionFormatLinkStylePolyParabel;
109 extern QAction *actionFormatHideLinkUnselected;
111 extern QAction *actionViewToggleNoteEditor;
112 extern QAction *actionViewToggleHistoryWindow;
114 extern QAction* actionSettingsAutoedit;
115 extern QAction* actionSettingsAutoselectHeading;
116 extern QAction* actionSettingsAutoselectHeading;
117 extern QAction* actionSettingsAutoselectText;
118 extern QAction* actionSettingsPasteNewHeading;
119 extern QAction* actionSettingsUseDelKey;
120 extern QAction* actionSettingsUseFlagGroups;
121 extern QAction* actionSettingsUseHideExport;
123 extern QPopupMenu* branchContextMenu;
124 extern QPopupMenu* branchAddContextMenu;
125 extern QPopupMenu* branchRemoveContextMenu;
126 extern QPopupMenu* branchLinksContextMenu;
127 extern QPopupMenu* branchLinksContextMenuDup;
128 extern QPopupMenu* floatimageContextMenu;
129 extern QPopupMenu* saveImageFormatMenu;
130 extern QPopupMenu* canvasContextMenu;
131 extern QPopupMenu* lastMapsMenu;
132 extern QPopupMenu* importMenu;
133 extern QPopupMenu* exportMenu;
134 extern QPopupMenu* exportImageFormatMenu;
137 extern Settings settings;
138 extern Options options;
139 extern QDir vymBaseDir;
140 extern QString iconPath;
141 extern QString flagsPath;
143 #if defined(Q_OS_LINUX)
144 extern void qt_wait_for_window_manager( QWidget* w );
147 Main::Main(QWidget* parent, const char* name, WFlags f) :
148 QMainWindow(parent,name,f)
152 setCaption ("VYM - View Your Mind");
154 // Load window settings
155 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
156 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
157 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
158 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
161 // Create unique temporary directory
162 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
164 // Create direcctory for clipboard
165 clipboardDir=tmpVymDir+"/clipboard";
166 QDir d(clipboardDir);
167 d.mkdir (clipboardDir,true);
168 makeSubDirs (clipboardDir);
173 // FIXME not used currently
174 // Set random seed (random used for object IDs)
175 // QTime t = QTime::currentTime(); // set random seed
176 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
179 // Initialize some settings, which are platform dependant
182 // application to open URLs
183 p="/vym/mainwindow/readerURL";
184 #if defined(Q_OS_LINUX)
185 s=settings.readEntry (p,"konqueror");
187 #if defined(Q_OS_MACX)
188 s=settings.readEntry (p,"/usr/bin/open");
190 s=settings.readEntry (p,"mozilla");
193 settings.writeEntry( p,s);
195 // application to open PDFs
196 p="/vym/mainwindow/readerPDF";
197 #if defined(Q_OS_LINUX)
198 s=settings.readEntry (p,"acroread");
200 #if defined(Q_OS_MACX)
201 s=settings.readEntry (p,"/usr/bin/open");
203 s=settings.readEntry (p,"acroread");
206 settings.writeEntry( p,s);
211 // Create tab widget which holds the maps
212 tabWidget= new QTabWidget (this);
213 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
214 this, SLOT( editorChanged( QWidget * ) ) );
216 setCentralWidget(tabWidget);
220 setupFormatActions();
224 setupSettingsActions();
226 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
229 // After menu is created, we can enable some actions
230 actionFilePrint->setEnabled (true);
235 // Initialize Find window
236 findWindow=new FindWindow(NULL,"findwindow");
237 connect (findWindow, SIGNAL( findButton(QString) ),
238 this, SLOT(editFind(QString) ) );
239 connect (findWindow, SIGNAL( somethingChanged() ),
240 this, SLOT(editFindChanged() ) );
242 // Connect TextEditor, so that we can update flags if text changes
243 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
251 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
252 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
253 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
254 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
256 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
257 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
259 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
260 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
261 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
262 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
263 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
264 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
265 settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
268 int maps=lastMaps.count();
269 settings.writeEntry( "/vym/lastMaps/number",maps );
270 for (int i=1;i<=maps;i++)
272 QStringList::Iterator it = lastMaps.at(i-1);
273 s=QString("/vym/lastMaps/map-%1").arg(i);
274 if (!s.isEmpty() && i<=maxLastMaps)
275 settings.writeEntry (s, *it);
279 // To make the texteditor save its settings, call the destructor
282 // Remove temporary directory
283 removeDir (QDir(tmpVymDir));
286 void Main::loadCmdLine()
288 /* TODO draw some kind of splashscreen while loading...
294 QStringList flist=options.getFileList();
295 QStringList::Iterator it=flist.begin();
297 while (it !=flist.end() )
299 fileLoad (*it, NewMap);
305 void Main::statusMessage(const QString &s)
307 statusBar()->message (s);
310 void Main::closeEvent (QCloseEvent* )
316 void Main::setupFileActions()
318 QToolBar *tb = new QToolBar( this );
319 tb->setLabel( "File Actions" );
320 QPopupMenu *menu = new QPopupMenu( this );
321 menuBar()->insertItem( tr( "&File" ), menu );
323 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
326 a = new QAction( tr( "New map","File menu" ), QPixmap( iconPath+"filenew.png"), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
327 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
331 a = new QAction( tr( "Open","File menu" ), QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
332 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
336 lastMapsMenu = new QPopupMenu (this);
338 menu->insertItem (tr("Open Recent"),lastMapsMenu );
339 menu->insertSeparator();
341 a = new QAction( tr( "Save" ), QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
342 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
347 a = new QAction( tr( "Save &As" ), QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), 0, this, "fileSaveAs" );
348 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
351 menu->insertSeparator();
353 importMenu = new QPopupMenu (this);
354 menu->insertItem (tr("Import"),importMenu );
356 a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
357 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
358 a->addTo (importMenu);
360 a = new QAction( tr( "Import")+" Mind Manager" , QPixmap(), "Mind Manager...", 0, this, "importMM" );
361 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
362 a->addTo (importMenu);
364 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
365 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
366 a->addTo( importMenu);
368 exportMenu = new QPopupMenu (this);
369 menu->insertItem (tr("Export"),exportMenu );
371 menu->insertSeparator();
374 a = new QAction( tr( "Print" ), QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" );
375 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
380 a = new QAction( tr( "Close Map" ), QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
381 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
384 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
385 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
391 void Main::setupEditActions()
393 QToolBar *tb = new QToolBar( this );
394 tb->setLabel( "Edit Actions" );
395 QPopupMenu *menu = new QPopupMenu( this );
396 menuBar()->insertItem( tr( "&Edit" ), menu );
400 a = new QAction( tr( "Undo" ), QPixmap( iconPath+"undo.png"), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
401 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
402 a->setEnabled (false);
407 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
409 a = new QAction( tr( "Redo" ), QPixmap( iconPath+"redo.png"), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
410 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
415 menu->insertSeparator();
416 a = new QAction( tr( "Copy" ), QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
417 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
418 a->setEnabled (false);
422 a = new QAction( tr( "Cut" ), QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
423 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
424 a->setEnabled (false);
428 a = new QAction( tr( "Paste" ), QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
429 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
430 a->setEnabled (false);
435 a = new QAction( tr( "Move branch up" ), QPixmap(iconPath+"up.png" ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
436 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
437 a->setEnabled (false);
440 actionListBranches.append(a);
443 a = new QAction( tr( "Move branch down" ), QPixmap( iconPath+"down.png"), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
444 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
445 a->setEnabled (false);
448 actionListBranches.append(a);
449 actionEditMoveDown=a;
452 a = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
453 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
454 alt = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_S, this, "scroll" );
455 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
456 #if defined(Q_OS_MACX)
457 actionEditToggleScroll=alt;
459 actionEditToggleScroll=a;
461 actionEditToggleScroll->setEnabled (false);
462 actionEditToggleScroll->setToggleAction(true);
463 actionEditToggleScroll->addTo( tb );
464 actionEditToggleScroll->addTo( menu );
465 actionListBranches.append(actionEditToggleScroll);
467 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
468 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
471 menu->insertSeparator();
473 a = new QAction( tr( "Find" ), QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
474 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
477 menu->insertSeparator();
479 a = new QAction( tr( "Open URL" ), QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), CTRL + Key_U, this, "url" );
480 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
482 a->setEnabled (false);
485 a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), CTRL + Key_U, this, "urltab" );
486 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
487 a->setEnabled (false);
488 actionEditOpenURLTab=a;
490 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
491 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
492 a->setEnabled (false);
493 actionListBranches.append(a);
496 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
497 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
498 a->setEnabled (false);
499 actionListBranches.append(a);
500 actionEditHeading2URL=a;
502 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
503 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
504 a->setEnabled (false);
505 actionListBranches.append(a);
506 actionEditBugzilla2URL=a;
508 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
509 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
510 a->setEnabled (false);
511 actionListBranches.append(a);
512 actionEditFATE2URL=a;
514 a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), 0, this, "jumpMap" );
515 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
517 a->setEnabled (false);
518 actionEditOpenVymLink=a;
520 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
521 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
522 a->setEnabled (false);
523 actionListBranches.append(a);
526 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
527 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
528 a->setEnabled (false);
529 actionEditDeleteVymLink=a;
531 a = new QAction( tr( "Hide object in exports" ), QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), Key_H, this, "hideExport" );
532 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
533 a->setToggleAction(true);
535 a->setEnabled (false);
536 actionEditToggleHideExport=a;
538 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
539 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
540 a->setEnabled (true);
543 menu->insertSeparator();
545 // Shortcuts to modify heading:
546 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
547 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
548 actionListBranches.append(a);
549 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
550 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
551 actionListBranches.append(a);
553 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
554 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
555 a->setEnabled (false);
557 actionListBranches.append(a);
559 // Shortcut to delete selection
560 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
561 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
562 a->setEnabled (false);
565 // Shortcut to add branch
566 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
567 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
568 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
569 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
570 a->setEnabled (false);
571 actionListBranches.append(a);
572 #if defined (Q_OS_MACX)
573 // In OSX show different shortcut in menues, the keys work independtly always
574 actionEditAddBranch=alt;
576 actionEditAddBranch=a;
579 // Add branch by inserting it at selection
580 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
581 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
582 a->setEnabled (false);
583 actionListBranches.append(a);
584 actionEditAddBranchHere=a;
585 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
586 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
587 actionListBranches.append(a);
590 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
591 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
592 a->setEnabled (false);
593 actionListBranches.append(a);
594 actionEditAddBranchAbove=a;
595 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
596 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
597 actionListBranches.append(a);
600 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
601 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
602 a->setEnabled (false);
603 actionListBranches.append(a);
604 actionEditAddBranchBelow=a;
605 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
606 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
607 actionListBranches.append(a);
609 // Import at selection (adding to selection)
610 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
611 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
612 a->setEnabled (false);
613 actionListBranches.append(a);
614 actionEditImportAdd=a;
616 // Import at selection (replacing selection)
617 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
618 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
619 a->setEnabled (false);
620 actionListBranches.append(a);
621 actionEditImportReplace=a;
624 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
625 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
626 a->setEnabled (false);
627 actionListBranches.append(a);
628 actionEditSaveBranch=a;
630 // Only remove branch, not its childs
631 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
632 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
633 a->setEnabled (false);
634 actionListBranches.append(a);
635 actionEditRemoveBranchKeepChilds=a;
637 // Only remove childs of a branch
638 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
639 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
640 a->setEnabled (false);
641 actionListBranches.append(a);
642 actionEditRemoveChilds=a;
644 // Shortcuts for navigating with cursor:
645 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
646 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
647 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
648 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
649 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
650 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
651 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
652 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
653 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
654 a->setEnabled (false);
656 actionListBranches.append(a);
657 actionEditSelectFirst=a;
658 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
659 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
660 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
661 a->setEnabled (false);
663 actionListBranches.append(a);
664 actionEditSelectLast=a;
666 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
667 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
668 actionEditLoadImage=a;
673 void Main::setupFormatActions()
675 QPopupMenu *menu = new QPopupMenu( this );
676 menuBar()->insertItem( tr( "&Format" ), menu );
678 QToolBar *tb = new QToolBar( this );
682 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
683 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
684 actionFormatColor->addTo( tb );
685 actionFormatColor->addTo( menu );
686 a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" );
687 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
688 a->setEnabled (false);
691 actionListBranches.append(a);
692 actionFormatPickColor=a;
693 a= new QAction( tr( "Color branch" ), QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
694 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
695 a->setEnabled (false);
698 actionListBranches.append(a);
699 actionFormatColorBranch=a;
700 a= new QAction( tr( "Color Subtree" ), QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
701 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
702 a->setEnabled (false);
705 actionListBranches.append(a);
706 actionFormatColorSubtree=a;
708 menu->insertSeparator();
709 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
710 actionGroupFormatLinkStyles->setExclusive (true);
711 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
712 a->setToggleAction(true);
713 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
714 actionFormatLinkStyleLine=a;
715 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
716 a->setToggleAction(true);
717 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
718 actionFormatLinkStyleParabel=a;
719 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
720 a->setToggleAction(true);
721 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
722 actionFormatLinkStylePolyLine=a;
723 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
724 a->setToggleAction(true);
725 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
726 actionFormatLinkStylePolyParabel=a;
727 actionGroupFormatLinkStyles->addTo (menu);
729 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
730 actionGroupFormatFrameTypes->setExclusive (true);
731 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
732 a->setToggleAction(true);
733 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
734 actionFormatFrameNone=a;
735 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
736 a->setToggleAction(true);
737 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
738 actionFormatFrameRectangle=a;
740 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
741 a->setToggleAction(true);
742 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
743 actionFormatIncludeImagesVer=a;
745 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
746 a->setToggleAction(true);
747 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
748 actionFormatIncludeImagesHor=a;
750 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
751 a->setToggleAction(true);
752 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
753 actionFormatHideLinkUnselected=a;
755 menu->insertSeparator();
756 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
757 a->setToggleAction(true);
758 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
760 actionFormatLinkColorHint=a;
762 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
763 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
764 actionFormatLinkColor->addTo( menu );
765 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
766 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
767 actionFormatBackColor->addTo( menu );
771 void Main::setupViewActions()
773 QToolBar *tb = new QToolBar( this );
774 tb->setLabel( "View Actions" );
775 QPopupMenu *menu = new QPopupMenu( this );
776 menuBar()->insertItem( tr( "&View" ), menu );
779 a = new QAction( tr( "Zoom reset" ), QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
780 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
783 a = new QAction( tr( "Zoom in" ), QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
784 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
787 a = new QAction( tr( "Zoom out" ), QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
788 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
793 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flagsPath+"flag-note.png"), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
794 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
795 a->setToggleAction(true);
796 if (textEditor->showWithMain())
802 actionViewToggleNoteEditor=a;
804 a = new QAction( tr( "Toggle history window" ), QPixmap(), tr( "Toggle history window" ), CTRL + Key_H , this, "historyWindow" );
805 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
806 a->setToggleAction(false);
808 actionViewToggleHistoryWindow=a;
810 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
811 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
813 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
814 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
819 void Main::setupModeActions()
821 //QPopupMenu *menu = new QPopupMenu( this );
822 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
824 QToolBar *tb = new QToolBar( this );
825 tb->setLabel( tr ("Modes when using modifiers") );
827 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
828 actionGroupModModes->setExclusive (true);
829 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(iconPath+"modecolor.png"), 0, Key_J, actionGroupModModes, "modModeColor" );
830 a->setToggleAction(true);
833 actionModModeColor=a;
835 a= new QAction( tr( "Use modifier to copy" ), QPixmap(iconPath+"modecopy.png"), 0, Key_K, actionGroupModModes, "modModeCopy" );
836 a->setToggleAction(true);
840 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(iconPath+"modelink.png"), 0, Key_L, actionGroupModModes, "modModeLink" );
841 a->setToggleAction(true);
847 void Main::setupFlagActions()
849 // Create System Flags
850 systemFlagsDefault = new FlagRowObj ();
851 systemFlagsDefault->setVisibility (false);
852 systemFlagsDefault->setName ("systemFlagsDef");
854 FlagObj *fo = new FlagObj ();
855 fo->load(QPixmap(flagsPath+"flag-note.png"));
857 fo->setToolTip(tr("Note","Systemflag"));
858 systemFlagsDefault->addFlag (fo); // makes deep copy
860 fo->load(QPixmap(flagsPath+"flag-url.png"));
862 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
863 systemFlagsDefault->addFlag (fo);
865 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
866 fo->setName("vymLink");
867 fo->setToolTip(tr("Link to another vym map","Systemflag"));
868 systemFlagsDefault->addFlag (fo);
870 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
871 fo->setName("scrolledright");
872 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
873 systemFlagsDefault->addFlag (fo);
875 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
876 fo->setName("tmpUnscrolledright");
877 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
878 systemFlagsDefault->addFlag (fo);
880 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
881 fo->setName("hideInExport");
882 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
883 systemFlagsDefault->addFlag (fo);
885 // Create Standard Flags
886 standardFlagsDefault = new FlagRowObj ();
887 standardFlagsDefault->setVisibility (false);
888 standardFlagsDefault->setName ("standardFlagsDef");
890 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
891 fo->setName ("exclamationmark");
892 fo->setGroup("standard-mark");
893 fo->setToolTip(tr("Take care!","Standardflag"));
894 standardFlagsDefault->addFlag (fo); // makes deep copy
896 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
897 fo->setName("questionmark");
898 fo->setGroup("standard-mark");
899 fo->setToolTip(tr("Really?","Standardflag"));
900 standardFlagsDefault->addFlag (fo);
902 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
903 fo->setName("hook-green");
904 fo->setGroup("standard-hook");
905 fo->setToolTip(tr("ok!","Standardflag"));
906 standardFlagsDefault->addFlag (fo);
908 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
909 fo->setName("cross-red");
910 fo->setGroup("standard-hook");
911 fo->setToolTip(tr("Not ok!","Standardflag"));
912 standardFlagsDefault->addFlag (fo);
914 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
915 fo->setName("stopsign");
916 fo->setToolTip(tr("This won't work!","Standardflag"));
917 standardFlagsDefault->addFlag (fo);
919 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
920 fo->setName("smiley-good");
921 fo->setGroup("standard-smiley");
922 fo->setToolTip(tr("Good","Standardflag"));
923 standardFlagsDefault->addFlag (fo);
925 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
926 fo->setName("smiley-sad");
927 fo->setGroup("standard-smiley");
928 fo->setToolTip(tr("Bad","Standardflag"));
929 standardFlagsDefault->addFlag (fo);
931 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
932 // Original omg.png (in KDE emoticons)
933 fo->setName("smiley-omg");
934 fo->setGroup("standard-smiley");
935 fo->setToolTip(tr("Oh no!","Standardflag"));
936 standardFlagsDefault->addFlag (fo);
938 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
939 fo->setName("clock");
940 fo->setToolTip(tr("Time critical","Standardflag"));
941 standardFlagsDefault->addFlag (fo);
943 fo->load(QPixmap(flagsPath+"flag-phone.png"));
944 fo->setName("phone");
945 fo->setToolTip(tr("Call...","Standardflag"));
946 standardFlagsDefault->addFlag (fo);
948 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
950 fo->setToolTip(tr("Idea!","Standardflag"));
951 standardFlagsDefault->addFlag (fo);
953 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
954 fo->setName("arrow-up");
955 fo->setGroup("standard-arrow");
956 fo->setToolTip(tr("Important","Standardflag"));
957 standardFlagsDefault->addFlag (fo);
959 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
960 fo->setName("arrow-down");
961 fo->setGroup("standard-arrow");
962 fo->setToolTip(tr("Unimportant","Standardflag"));
963 standardFlagsDefault->addFlag (fo);
965 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
966 fo->setName("2arrow-up");
967 fo->setGroup("standard-arrow");
968 fo->setToolTip(tr("Very important!","Standardflag"));
969 standardFlagsDefault->addFlag (fo);
971 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
972 fo->setName("2arrow-down");
973 fo->setGroup("standard-arrow");
974 fo->setToolTip(tr("Very unimportant!","Standardflag"));
975 standardFlagsDefault->addFlag (fo);
977 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
978 fo->setName("thumb-up");
979 fo->setGroup("standard-thumb");
980 fo->setToolTip(tr("I like this","Standardflag"));
981 standardFlagsDefault->addFlag (fo);
983 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
984 fo->setName("thumb-down");
985 fo->setGroup("standard-thumb");
986 fo->setToolTip(tr("I like this","Standardflag"));
987 fo->setToolTip(tr("I do not like this","Standardflag"));
988 standardFlagsDefault->addFlag (fo);
990 fo->load(QPixmap(flagsPath+"flag-rose.png"));
992 fo->setToolTip(tr("Rose","Standardflag"));
993 standardFlagsDefault->addFlag (fo);
995 fo->load(QPixmap(flagsPath+"flag-heart.png"));
996 fo->setName("heart");
997 fo->setToolTip(tr("I just love... ","Standardflag"));
998 standardFlagsDefault->addFlag (fo);
1000 fo->load(QPixmap(flagsPath+"flag-present.png"));
1001 fo->setName("present");
1002 fo->setToolTip(tr("Surprise!","Standardflag"));
1003 standardFlagsDefault->addFlag (fo);
1005 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1006 fo->setName("flash");
1007 fo->setToolTip(tr("Dangerous","Standardflag"));
1008 standardFlagsDefault->addFlag (fo);
1010 fo->load(QPixmap(flagsPath+"flag-info.png"));
1011 // Original: xsldbg_output.png
1012 fo->setName("info");
1013 fo->setToolTip(tr("Info","Standardflag"));
1014 standardFlagsDefault->addFlag (fo);
1016 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1017 // Original khelpcenter.png
1018 fo->setName("lifebelt");
1019 fo->setToolTip(tr("This will help","Standardflag"));
1020 standardFlagsDefault->addFlag (fo);
1024 standardFlagsDefault->makeToolbar(this, "Standard Flags");
1028 void Main::setupSettingsActions()
1030 QPopupMenu *menu = new QPopupMenu( this );
1031 menuBar()->insertItem( tr( "&Settings" ), menu );
1036 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1037 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1040 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1041 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1044 menu->insertSeparator();
1045 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1046 a->setToggleAction(true);
1047 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1049 actionSettingsAutoedit=a;
1051 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1052 a->setToggleAction(true);
1053 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1055 actionSettingsAutoselectHeading=a;
1057 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1058 a->setToggleAction(true);
1059 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1061 actionSettingsAutoselectText=a;
1063 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1064 a->setToggleAction(true);
1065 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1067 actionSettingsPasteNewHeading=a;
1069 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1070 a->setToggleAction(true);
1071 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1073 actionSettingsUseDelKey=a;
1075 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1076 a->setToggleAction(true);
1077 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1079 actionSettingsUseFlagGroups=a;
1081 a= new QAction( tr( "Use hide flag during exports " ), QPixmap(), tr( "Use hide flags" ), 0, this, "hideexport" );
1082 a->setToggleAction(true);
1083 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1085 actionSettingsUseHideExport=a;
1089 void Main::setupTestActions()
1091 QPopupMenu *menu = new QPopupMenu( this );
1092 menuBar()->insertItem( tr( "&Test" ), menu );
1095 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1096 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1101 void Main::setupHelpActions()
1103 QPopupMenu *menu = new QPopupMenu( this );
1104 menuBar()->insertItem( tr( "&Help" ), menu );
1107 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1108 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1111 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1112 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1115 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1116 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1121 void Main::setupContextMenus()
1125 // Context Menu for branch or mapcenter
1126 branchContextMenu =new QPopupMenu (this);
1129 branchAddContextMenu =new QPopupMenu (this);
1130 actionEditPaste->addTo ( branchAddContextMenu );
1131 actionEditAddBranch->addTo ( branchAddContextMenu );
1132 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1133 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1134 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1135 branchAddContextMenu->insertSeparator();
1136 actionEditLoadImage->addTo( branchAddContextMenu );
1137 branchAddContextMenu->insertSeparator();
1138 actionEditImportAdd->addTo ( branchAddContextMenu );
1139 actionEditImportReplace->addTo ( branchAddContextMenu );
1142 branchRemoveContextMenu =new QPopupMenu (this);
1143 actionEditCut->addTo ( branchRemoveContextMenu );
1144 actionEditDelete->addTo ( branchRemoveContextMenu );
1145 actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu );
1146 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1148 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1149 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1151 actionEditSaveBranch->addTo( branchContextMenu );
1153 branchContextMenu->insertSeparator();
1154 actionEditOpenURL->addTo ( branchContextMenu );
1155 actionEditOpenURLTab->addTo ( branchContextMenu );
1156 actionEditURL->addTo ( branchContextMenu );
1157 actionEditHeading2URL->addTo ( branchContextMenu );
1158 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1160 actionEditBugzilla2URL->addTo( branchContextMenu );
1161 actionEditFATE2URL->addTo( branchContextMenu );
1163 branchContextMenu->insertSeparator();
1164 actionEditOpenVymLink->addTo ( branchContextMenu );
1165 actionEditVymLink->addTo ( branchContextMenu );
1166 actionEditDeleteVymLink->addTo ( branchContextMenu );
1168 branchContextMenu->insertSeparator();
1169 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1171 branchContextMenu->insertSeparator();
1172 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1173 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1174 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1176 // Context Menu for links in a branch menu
1177 // This will be populated "on demand" in MapEditor::updateActions
1178 branchContextMenu->insertSeparator();
1179 branchLinksContextMenu =new QPopupMenu (this);
1180 branchLinksContextMenuDup =new QPopupMenu (this);
1181 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1182 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1184 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1185 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1187 // Context menu for floatimage
1188 floatimageContextMenu =new QPopupMenu (this);
1189 saveImageFormatMenu=new QPopupMenu (this);
1190 exportImageFormatMenu=new QPopupMenu (this);
1192 QStrList fmt = QImage::outputFormats();
1193 for (const char* f = fmt.first(); f; f = fmt.next())
1195 saveImageFormatMenu->insertItem( f );
1196 exportImageFormatMenu->insertItem( f );
1198 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1199 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1200 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1202 floatimageContextMenu->insertSeparator();
1203 actionEditCopy->addTo( floatimageContextMenu );
1204 actionEditCut->addTo( floatimageContextMenu );
1206 /* FIXME not needed any longer
1207 floatimageContextMenu->insertSeparator();
1208 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1209 a->setToggleAction(true);
1210 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1211 a->addTo( floatimageContextMenu);
1212 actionEditToggleFloatExport=a;
1215 floatimageContextMenu->insertSeparator();
1216 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1218 exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1220 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1221 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1222 a->addTo (exportMenu);
1224 a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" );
1225 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1226 a->addTo( exportMenu );
1228 a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" );
1229 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1230 a->addTo( exportMenu );
1232 a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
1233 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1235 // a->addTo (exportMenu);
1237 a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
1238 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1239 a->addTo( exportMenu );
1241 a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1242 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1243 a->addTo( exportMenu );
1245 a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" );
1246 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1247 a->addTo( exportMenu );
1249 // Context menu for canvas
1250 canvasContextMenu =new QPopupMenu (this);
1251 actionEditMapInfo->addTo( canvasContextMenu );
1252 canvasContextMenu->insertSeparator();
1253 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1254 canvasContextMenu->insertSeparator();
1255 actionFormatLinkColorHint->addTo( canvasContextMenu );
1256 actionFormatLinkColor->addTo( canvasContextMenu );
1257 actionFormatBackColor->addTo( canvasContextMenu );
1259 // Menu for last opened files
1260 // Read settings initially
1262 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1263 for (int i=1;i<=j;i++)
1265 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1266 if (!s.isEmpty() && j<=maxLastMaps)
1269 setupLastMapsMenu();
1270 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1273 void Main::setupLastMapsMenu()
1275 // Remove double entries
1276 QStringList::Iterator it=lastMaps.begin();
1277 QStringList::Iterator jt;
1278 while (it!=lastMaps.end() )
1282 while (jt!=lastMaps.end() )
1285 jt=lastMaps.remove(jt);
1292 // Limit length of list to maxLastMaps
1293 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1295 // build Menu from lastMaps string list
1296 lastMapsMenu->clear();
1297 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1298 lastMapsMenu->insertItem (*it );
1302 void Main::hideEvent (QHideEvent * )
1304 if (!textEditor->isMinimized() ) textEditor->hide();
1307 void Main::showEvent (QShowEvent * )
1309 if (textEditor->showWithMain()) textEditor->showNormal();
1312 bool Main::reallyWriteDirectory(const QString &dir)
1314 QStringList eList = QDir(dir).entryList();
1315 if (eList.first() ==".") eList.pop_front(); // remove "."
1316 if (eList.first() =="..") eList.pop_front(); // remove "."
1317 if (!eList.isEmpty())
1319 QMessageBox mb( __VYM,
1320 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1321 QMessageBox::Warning,
1323 QMessageBox::Cancel | QMessageBox::Default,
1324 QMessageBox::QMessageBox::NoButton );
1326 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1327 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1330 case QMessageBox::Yes:
1333 case QMessageBox::Cancel:
1341 QString Main::browseDirectory (const QString &caption)
1343 QFileDialog fd(this,caption);
1344 fd.setMode (QFileDialog::DirectoryOnly);
1345 fd.setCaption(__VYM " - "+caption);
1348 if ( fd.exec() == QDialog::Accepted )
1349 return fd.selectedFile();
1354 MapEditor* Main::currentMapEditor() const
1356 if ( tabWidget->currentPage() &&
1357 tabWidget->currentPage()->inherits( "MapEditor" ) )
1358 return (MapEditor*)tabWidget->currentPage();
1362 //TODO not used now, maybe use this for overview window later
1363 void Main::newView()
1365 // Open a new view... have it delete when closed.
1366 Main *m = new Main(0, 0, WDestructiveClose);
1367 qApp->setMainWidget(m);
1369 qApp->setMainWidget(0);
1372 void Main::editorChanged(QWidget *)
1374 // Unselect all possibly selected objects
1375 // (Important to update note editor)
1378 for (i=0;i<=tabWidget->count() -1;i++)
1381 me=(MapEditor*)tabWidget->page(i);
1384 currentMapEditor()->reselect();
1386 // Update actions to in menus and toolbars according to editor
1387 currentMapEditor()->updateActions();
1390 void Main::fileNew()
1392 QString fn="unnamed";
1393 MapEditor* medit = new MapEditor (tabWidget, true);
1394 tabWidget->addTab (medit,fn);
1395 tabWidget->showPage(medit);
1396 medit->viewport()->setFocus();
1397 // For the very first map we do not have flagrows yet...
1398 medit->select("mc:");
1401 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1403 ErrorCode err=success;
1405 // fn is usually the archive, mapfile the file after uncompressing
1408 // Make fn absolute (needed for unzip)
1409 fn=QDir (fn).absPath();
1415 // Check, if map is already loaded
1417 while (i<=tabWidget->count() -1)
1419 me=(MapEditor*)tabWidget->page(i);
1420 if (me->getFilePath() == fn)
1422 // Already there, ask for confirmation
1423 QMessageBox mb( __VYM,
1424 tr("The map %1\nis already opened."
1425 "Opening the same map in multiple editors may lead \n"
1426 "to confusion when finishing working with vym."
1427 "Do you want to").arg(fn),
1428 QMessageBox::Warning,
1429 QMessageBox::Yes | QMessageBox::Default,
1430 QMessageBox::Cancel | QMessageBox::Escape,
1431 QMessageBox::QMessageBox::NoButton);
1432 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1433 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1436 case QMessageBox::Yes:
1438 i=tabWidget->count();
1440 case QMessageBox::Cancel:
1452 if ( !fn.isEmpty() )
1454 me = currentMapEditor();
1455 int tabIndex=tabWidget->currentPageIndex();
1456 // Check first, if mapeditor exists
1457 // If it is not default AND we want a new map,
1458 // create a new mapeditor in a new tab
1459 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1461 me = new MapEditor (tabWidget,true);
1462 tabWidget->addTab (me,fn);
1463 tabIndex=tabWidget->indexOf (me);
1464 tabWidget->setCurrentPage (tabIndex);
1467 // Check, if file exists (important for creating new files
1468 // from command line
1469 if (!QFile(fn).exists() )
1471 QMessageBox mb( __VYM,
1472 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1473 QMessageBox::Question,
1475 QMessageBox::Cancel | QMessageBox::Default,
1476 QMessageBox::QMessageBox::NoButton );
1478 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1479 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1482 case QMessageBox::Yes:
1484 currentMapEditor()->setFilePath(fn);
1485 tabWidget->setTabLabel (currentMapEditor(),
1486 currentMapEditor()->getFileName() );
1487 statusBar()->message( "Created " + fn , statusbarTime );
1490 case QMessageBox::Cancel:
1491 // don't create new map
1492 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1499 //tabWidget->currentPage() won't be NULL here, because of above...
1500 tabWidget->showPage(me);
1501 me->viewport()->setFocus();
1503 // Create temporary directory for packing
1504 char tmpdir1[]="/tmp/vym-XXXXXX";
1505 QString tmpMapDir=mkdtemp(tmpdir1);
1507 // Try to unzip file
1508 err=unzipDir (tmpMapDir,fn);
1512 me->setZipped(false);
1515 me->setZipped(true);
1517 // Look for mapname.xml
1518 mapfile= fn.left(fn.findRev(".",-1,true));
1519 mapfile=mapfile.section( '/', -1 );
1520 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1521 if (!file.exists() )
1523 // mapname.xml does not exist, well,
1524 // maybe some renamed the mapname.vym file...
1525 // Try to find any .xml in the toplevel
1526 // directory of the .vym file
1527 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1528 if (flist.count()==1)
1530 // Only one entry, take this one
1531 mapfile=tmpMapDir + "/"+flist.first();
1534 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1535 *it=tmpMapDir + "/" + *it;
1536 // TODO Multiple entries, load all (but only the first one into this ME)
1537 //mainWindow->fileLoadFromTmp (flist);
1538 //returnCode=1; // Silently forget this attempt to load
1539 qWarning ("MainWindow::load (fn) multimap found...");
1542 if (flist.isEmpty() )
1544 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1545 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1548 } //file doesn't exist
1550 mapfile=file.name();
1555 // Save existing filename in case we import
1556 QString fn_org=me->getFilePath();
1558 // Finally load map into mapEditor
1559 me->setFilePath (mapfile,fn);
1560 err=me->load(mapfile,lmode);
1562 // Restore old (maybe empty) filepath, if this is an import
1564 me->setFilePath (fn_org);
1567 // Finally check for errors and go home
1570 if (lmode==NewMap) fileCloseMap();
1571 statusBar()->message( "Could not load " + fn, statusbarTime );
1576 me->setFilePath (fn);
1577 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1578 if (fn.left(9)!="/tmp/vym-")
1580 // Only append to lastMaps if not loaded from a tmpDir
1581 // e.g. imported bookmarks are in a tmpDir
1582 lastMaps.prepend(me->getFilePath() );
1583 setupLastMapsMenu();
1585 actionFilePrint->setEnabled (true);
1587 statusBar()->message( "Loaded " + fn, statusbarTime );
1591 removeDir (QDir(tmpMapDir));
1597 void Main::fileLoad(const LoadMode &lmode)
1599 QFileDialog *fd=new QFileDialog( this);
1600 if (!lastFileDir.isEmpty())
1601 fd->setDir (lastFileDir);
1602 fd->setMode (QFileDialog::ExistingFiles);
1603 fd->addFilter ("XML (*.xml)");
1604 fd->addFilter ("VYM map (*.vym *.vyp)");
1608 fd->setCaption(tr("Load vym map"));
1611 fd->setCaption(tr("Import: Add vym map to selection"));
1614 fd->setCaption(tr("Import: Replace selection with vym map"));
1620 if ( fd->exec() == QDialog::Accepted )
1622 lastFileDir=fd->dirPath();
1623 QStringList flist = fd->selectedFiles();
1624 QStringList::Iterator it = flist.begin();
1625 while( it != flist.end() )
1628 fileLoad(*it, lmode);
1635 void Main::fileLoad()
1640 void Main::fileLoadLast(int i)
1642 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1645 void Main::fileSave(const SaveMode &savemode)
1647 // tmp dir for zipping
1651 ErrorCode err=success;
1653 QString safeFilePath;
1655 bool saveZipped=currentMapEditor()->saveZipped();
1657 MapEditor * me=currentMapEditor();
1660 QString fn=me->getFilePath();
1661 // filename=unnamed, filepath="" in constructor...
1662 if ( !fn.isEmpty() )
1664 // We have a filepath, go on saving
1665 // First remove existing file, we
1666 // don't want to add to old zip archives
1670 QMessageBox::warning( 0, tr( "Save Error" ),
1671 fn+ tr("\ncould not be removed before saving"));
1673 // Look, if we should zip the data:
1676 QMessageBox mb( __VYM,
1677 tr("The map %1\ndid not use the compressed "
1678 "vym file format.\nWriting it uncompressed will also write images \n"
1679 "and flags and thus may overwrite files in the "
1680 "given directory\n\nDo you want to write the map").arg(fn),
1681 QMessageBox::Warning,
1682 QMessageBox::Yes | QMessageBox::Default,
1684 QMessageBox::Cancel | QMessageBox::Escape);
1685 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1686 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1687 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1690 case QMessageBox::Yes:
1691 // save compressed (default file format)
1694 case QMessageBox::No:
1695 // save uncompressed
1698 case QMessageBox::Cancel:
1707 char tmpdir1[]="/tmp/vym-XXXXXX";
1708 tmpMapDir=mkdtemp(tmpdir1);
1710 safeFilePath=me->getFilePath();
1711 me->setFilePath (tmpMapDir+"/"+
1712 me->getMapName()+ ".xml",
1714 me->save (savemode);
1715 me->setFilePath (safeFilePath);
1717 zipDir (tmpMapDir,fn);
1722 safeFilePath=me->getFilePath();
1723 me->setFilePath (fn, safeFilePath);
1724 me->save (savemode);
1725 me->setFilePath (safeFilePath);
1727 } // filepath available
1730 // We have no filepath yet,
1731 // call fileSaveAs() now, this will call fileSave()
1733 fileSaveAs(savemode);
1737 if (saveZipped && !tmpMapDir.isEmpty())
1739 removeDir (QDir(tmpMapDir));
1743 statusBar()->message(
1744 tr("Saved %1").arg(me->getFilePath()),
1746 lastMaps.prepend(me->getFilePath() );
1747 setupLastMapsMenu();
1749 statusBar()->message(
1750 tr("Couldn't save ").arg(me->getFilePath()),
1754 void Main::fileSave()
1756 fileSave (CompleteMap);
1759 void Main::fileSaveAs(const SaveMode& savemode)
1763 if (currentMapEditor())
1765 if (savemode==CompleteMap)
1766 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1768 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1769 if ( !fn.isEmpty() )
1771 // Check for existing file
1772 if (QFile (fn).exists())
1774 QMessageBox mb( __VYM,
1775 tr("The file %1\nexists already. Do you want to").arg(fn),
1776 QMessageBox::Warning,
1777 QMessageBox::Yes | QMessageBox::Default,
1778 QMessageBox::Cancel | QMessageBox::Escape,
1779 QMessageBox::QMessageBox::NoButton);
1780 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1781 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1784 case QMessageBox::Yes:
1787 case QMessageBox::Cancel:
1794 // New file, add extension to filename, if missing
1795 // This is always .vym or .vyp, depending on savemode
1796 if (savemode==CompleteMap)
1798 if (!fn.contains (".vym") && !fn.contains (".xml"))
1802 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1811 currentMapEditor()->setFilePath(fn);
1815 if (savemode==CompleteMap)
1816 tabWidget->setTabLabel (currentMapEditor(),
1817 currentMapEditor()->getFileName() );
1823 void Main::fileSaveAs()
1825 fileSaveAs (CompleteMap);
1828 void Main::fileImportKDEBookmarks()
1830 ImportKDEBookmarks im;
1832 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1833 currentMapEditor()->setFilePath ("");
1836 void Main::fileImportMM()
1840 QFileDialog *fd=new QFileDialog( this);
1841 if (!lastFileDir.isEmpty())
1842 fd->setDir (lastFileDir);
1843 fd->setMode (QFileDialog::ExistingFiles);
1844 fd->addFilter ("Mind Manager (*.mmap)");
1845 fd->setCaption(tr("Import")+" "+"Mind Manager");
1848 if ( fd->exec() == QDialog::Accepted )
1850 lastFileDir=fd->dirPath();
1851 QStringList flist = fd->selectedFiles();
1852 QStringList::Iterator it = flist.begin();
1853 while( it != flist.end() )
1856 if (im.transform() &&
1857 success==fileLoad (im.getTransformedFile(),NewMap) &&
1858 currentMapEditor() )
1859 currentMapEditor()->setFilePath ("");
1868 void Main::fileImportDir()
1870 if (currentMapEditor())
1871 currentMapEditor()->importDir();
1874 void Main::fileExportXML()
1876 if (currentMapEditor())
1878 QString dir=browseDirectory(tr("Export XML to directory"));
1879 if (dir !="" && reallyWriteDirectory(dir) )
1880 currentMapEditor()->exportXML(dir);
1885 void Main::fileExportXHTML()
1887 MapEditor *me=currentMapEditor();
1891 ExportXHTMLDialog dia(this);
1892 dia.setFilePath (me->getFilePath() );
1893 dia.setMapName (me->getMapName() );
1896 if (dia.exec()==QDialog::Accepted)
1898 QString dir=dia.getDir();
1899 // Check, if warnings should be used before overwriting
1900 // the output directory
1903 ok=reallyWriteDirectory(dir);
1909 me->exportXML (dia.getDir() );
1910 dia.doExport(me->getMapName() );
1911 if (dia.hasChanged())
1918 void Main::fileExportImage(int item)
1920 MapEditor *me=currentMapEditor();
1923 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1925 if ( !fn.isEmpty() )
1926 me->exportImage(fn,item);
1928 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1933 void Main::fileExportASCII()
1935 MapEditor *me=currentMapEditor();
1939 ex.setMapCenter(me->getMapCenter());
1940 ex.addFilter ("TXT (*.txt)");
1941 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1942 if (ex.execDialog() )
1944 me->setExportMode(true);
1946 me->setExportMode(false);
1951 void Main::fileExportLaTeX()
1953 MapEditor *me=currentMapEditor();
1957 ex.setMapCenter(me->getMapCenter());
1958 ex.addFilter ("Tex (*.tex)");
1959 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1960 if (ex.execDialog() )
1962 me->setExportMode(true);
1964 me->setExportMode(false);
1969 void Main::fileExportKDEBookmarks()
1971 ExportKDEBookmarks ex;
1972 MapEditor *me=currentMapEditor();
1975 ex.setMapCenter (me->getMapCenter() );
1980 void Main::fileExportTaskjuggler()
1982 ExportTaskjuggler ex;
1983 MapEditor *me=currentMapEditor();
1986 ex.setMapCenter (me->getMapCenter() );
1987 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
1988 ex.addFilter ("Taskjuggler (*.tjp)");
1989 if (ex.execDialog() )
1991 me->setExportMode(true);
1993 me->setExportMode(false);
1998 void Main::fileExportOOPresentation()
2000 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2001 // FIXME add extra info in dialog
2002 //ImagePreview *p =new ImagePreview (fd);
2003 //fd->setContentsPreviewEnabled( TRUE );
2004 //fd->setContentsPreview( p, p );
2005 //fd->setPreviewMode( QFileDialog::Contents );
2006 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2007 //fd->setDir (lastImageDir);
2010 if ( fd->exec() == QDialog::Accepted )
2012 QString fn=fd->selectedFile();
2013 //lastImageDir=fn.left(fn.findRev ("/"));
2014 if (currentMapEditor())
2015 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2019 void Main::fileCloseMap()
2021 if (currentMapEditor())
2023 if (currentMapEditor()->hasChanged())
2025 QMessageBox mb( __VYM,
2026 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2027 QMessageBox::Warning,
2028 QMessageBox::Yes | QMessageBox::Default,
2030 QMessageBox::Cancel | QMessageBox::Escape );
2031 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2032 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2035 case QMessageBox::Yes:
2037 fileSave(CompleteMap);
2039 case QMessageBox::No:
2040 // close without saving
2042 case QMessageBox::Cancel:
2047 currentMapEditor()->closeMap();
2048 tabWidget->removePage(currentMapEditor());
2049 if (tabWidget->count()==0)
2050 actionFilePrint->setEnabled (false);
2054 void Main::filePrint()
2056 if (currentMapEditor())
2057 currentMapEditor()->print();
2060 void Main::fileExitVYM()
2062 // Check if one or more editors have changed
2065 for (i=0;i<=tabWidget->count() -1;i++)
2068 me=(MapEditor*)tabWidget->page(i);
2070 // If something changed, ask what to do
2071 if (me->isUnsaved())
2073 tabWidget->setCurrentPage(i);
2074 QMessageBox mb( __VYM,
2075 tr("This map is not saved yet. Do you want to"),
2076 QMessageBox::Warning,
2077 QMessageBox::Yes | QMessageBox::Default,
2079 QMessageBox::Cancel | QMessageBox::Escape );
2080 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2081 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2083 // Call undocumented function: setActiveWindow is only
2084 // possible, if widget is visible. This depends on
2086 #if defined(Q_OS_LINUX)
2087 qt_wait_for_window_manager( this);
2089 mb.setActiveWindow();
2090 switch( mb.exec() ) {
2091 case QMessageBox::Yes:
2092 // save (the changed editors) and exit
2093 fileSave(CompleteMap);
2095 case QMessageBox::No:
2096 // exit without saving
2098 case QMessageBox::Cancel:
2099 // don't save and don't exit
2103 } // loop over all MEs
2107 void Main::editUndo()
2109 if (currentMapEditor())
2110 currentMapEditor()->undo();
2113 void Main::editRedo()
2115 if (currentMapEditor())
2116 currentMapEditor()->redo();
2119 void Main::editCopy()
2121 if (currentMapEditor())
2122 currentMapEditor()->copy();
2125 void Main::editPaste()
2127 if (currentMapEditor())
2128 currentMapEditor()->paste();
2131 void Main::editCut()
2133 if (currentMapEditor())
2134 currentMapEditor()->cut();
2137 void Main::editOpenFindWindow()
2139 findWindow->popup();
2140 findWindow->raise();
2142 // Call undocumented function: setActiveWindow is only
2143 // possible, if widget is visible. This depends on
2145 #if defined(Q_OS_LINUX)
2146 qt_wait_for_window_manager( this);
2148 findWindow->setActiveWindow();
2151 void Main::editFind(QString s)
2154 BranchObj *bo=currentMapEditor()->findText(s, cs);
2157 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2160 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2161 tr("No matches found for <b>%1</b>").arg(s));
2165 void Main::editFindChanged()
2166 { // Notify editor, to abort the current find process
2167 currentMapEditor()->findReset();
2170 void Main::editOpenURL()
2173 if (currentMapEditor())
2175 QString url=currentMapEditor()->getURL();
2176 if (url=="") return;
2177 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2178 procBrowser = new QProcess( this );
2180 procBrowser->addArgument( browser);
2181 procBrowser->addArgument( url);
2183 if ( !procBrowser->start() )
2185 // try to set path to browser
2186 QMessageBox::warning(0,
2188 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2189 tr("Please use Settings->")+tr("Set application to open an URL"));
2194 void Main::editOpenURLTab()
2196 if (currentMapEditor())
2198 QString url=currentMapEditor()->getURL();
2199 if (url=="") return;
2200 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2201 if (browser.contains("konqueror") && procBrowser && procBrowser->isRunning())
2203 // Try to open new tab in existing browser
2204 QProcess *p=new QProcess (this);
2205 p->addArgument ("dcop");
2206 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2207 p->addArgument ("konqueror-mainwindow#1");
2208 p->addArgument ("newTab");
2209 p->addArgument (url);
2211 // try to set browser
2212 QMessageBox::warning(0,
2214 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2221 void Main::editURL()
2223 if (currentMapEditor())
2224 currentMapEditor()->editURL();
2227 void Main::editHeading2URL()
2229 if (currentMapEditor())
2230 currentMapEditor()->editHeading2URL();
2233 void Main::editBugzilla2URL()
2235 if (currentMapEditor())
2236 currentMapEditor()->editBugzilla2URL();
2239 void Main::editFATE2URL()
2241 if (currentMapEditor())
2242 currentMapEditor()->editFATE2URL();
2245 void Main::editOpenVymLink()
2247 // Get current path to map
2248 QString currentVymLink;
2249 if (currentMapEditor())
2251 currentVymLink=currentMapEditor()->getVymLink();
2252 // compare path with already loaded maps
2256 for (i=0;i<=tabWidget->count() -1;i++)
2258 me=(MapEditor*)tabWidget->page(i);
2259 if (currentVymLink==me->getFilePath() )
2268 if (!QFile(currentVymLink).exists() )
2269 QMessageBox::critical( 0, tr( "Critical Error" ),
2270 tr("Couldn't open map %1").arg(currentVymLink));
2273 fileLoad (currentVymLink, NewMap);
2274 tabWidget->setCurrentPage (tabWidget->count()-1);
2277 // Go to tab containing the map
2278 tabWidget->setCurrentPage (index);
2282 void Main::editVymLink()
2284 if (currentMapEditor())
2285 currentMapEditor()->editVymLink();
2288 void Main::editDeleteVymLink()
2290 if (currentMapEditor())
2291 currentMapEditor()->deleteVymLink();
2294 void Main::editToggleHideExport()
2296 if (currentMapEditor())
2297 currentMapEditor()->toggleHideExport();
2300 void Main::editMapInfo()
2302 if (currentMapEditor())
2303 currentMapEditor()->editMapInfo();
2306 void Main::editMoveUp()
2308 if (currentMapEditor())
2309 currentMapEditor()->moveBranchUp();
2312 void Main::editMoveDown()
2314 if (currentMapEditor())
2315 currentMapEditor()->moveBranchDown();
2318 void Main::editToggleScroll()
2320 if (currentMapEditor())
2322 currentMapEditor()->toggleScroll();
2326 void Main::editUnScrollAll()
2328 if (currentMapEditor())
2330 currentMapEditor()->unScrollAll();
2334 void Main::editHeading()
2336 if (currentMapEditor())
2337 currentMapEditor()->editHeading();
2340 void Main::editNewBranch()
2342 if (currentMapEditor())
2343 currentMapEditor()->addNewBranch(0);
2346 void Main::editNewBranchHere()
2348 if (currentMapEditor())
2349 currentMapEditor()->addNewBranchHere();
2352 void Main::editNewBranchAbove()
2354 if (currentMapEditor())
2355 currentMapEditor()->addNewBranch(-1);
2358 void Main::editNewBranchBelow()
2360 if (currentMapEditor())
2361 currentMapEditor()->addNewBranch(1);
2364 void Main::editImportAdd()
2366 fileLoad (ImportAdd);
2369 void Main::editImportReplace()
2371 fileLoad (ImportReplace);
2374 void Main::editSaveBranch()
2376 fileSaveAs (PartOfMap);
2379 void Main::editRemoveBranchKeepChilds()
2381 if (currentMapEditor())
2382 currentMapEditor()->removeBranchKeepChilds();
2385 void Main::editRemoveChilds()
2387 if (currentMapEditor())
2388 currentMapEditor()->removeChilds();
2391 void Main::editDeleteSelection()
2393 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2394 currentMapEditor()->deleteSelection();
2397 void Main::editUpperBranch()
2399 if (currentMapEditor())
2400 currentMapEditor()->selectUpperBranch();
2403 void Main::editLowerBranch()
2405 if (currentMapEditor())
2406 currentMapEditor()->selectLowerBranch();
2409 void Main::editLeftBranch()
2411 if (currentMapEditor())
2412 currentMapEditor()->selectLeftBranch();
2415 void Main::editRightBranch()
2417 if (currentMapEditor())
2418 currentMapEditor()->selectRightBranch();
2421 void Main::editFirstBranch()
2423 if (currentMapEditor())
2424 currentMapEditor()->selectFirstBranch();
2427 void Main::editLastBranch()
2429 if (currentMapEditor())
2430 currentMapEditor()->selectLastBranch();
2433 void Main::editLoadImage()
2435 if (currentMapEditor())
2436 currentMapEditor()->loadFloatImage();
2439 void Main::editSaveImage(int item)
2441 if (currentMapEditor())
2442 currentMapEditor()->saveFloatImage(item);
2445 void Main::editFollowXLink(int item)
2447 if (currentMapEditor())
2448 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2451 void Main::editEditXLink(int item)
2453 if (currentMapEditor())
2454 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2457 void Main::formatSelectColor()
2459 if (currentMapEditor())
2461 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2462 if ( !col.isValid() ) return;
2463 currentMapEditor()->setColor( col );
2464 colorChanged( col );
2468 void Main::formatPickColor()
2470 if (currentMapEditor())
2471 colorChanged( currentMapEditor()->pickColor() );
2474 void Main::colorChanged(QColor c)
2476 QPixmap pix( 16, 16 );
2478 actionFormatColor->setIconSet( pix );
2481 void Main::formatColorItem()
2483 if (currentMapEditor())
2484 currentMapEditor()->colorItem();
2487 void Main::formatColorBranch()
2489 if (currentMapEditor())
2490 currentMapEditor()->colorBranch();
2493 void Main::formatLinkStyleLine()
2495 if (currentMapEditor())
2496 currentMapEditor()->setLinkStyle(StyleLine);
2499 void Main::formatLinkStyleParabel()
2501 if (currentMapEditor())
2502 currentMapEditor()->setLinkStyle(StyleParabel);
2505 void Main::formatLinkStylePolyLine()
2507 if (currentMapEditor())
2508 currentMapEditor()->setLinkStyle(StylePolyLine);
2511 void Main::formatLinkStylePolyParabel()
2513 if (currentMapEditor())
2514 currentMapEditor()->setLinkStyle(StylePolyParabel);
2517 void Main::formatSelectBackColor()
2519 if (currentMapEditor())
2520 currentMapEditor()->selectBackgroundColor();
2523 void Main::formatSelectLinkColor()
2525 if (currentMapEditor())
2526 currentMapEditor()->selectLinkColor();
2529 void Main::formatToggleLinkColorHint()
2531 currentMapEditor()->toggleLinkColorHint();
2534 void Main::formatFrameNone()
2536 if (currentMapEditor())
2537 currentMapEditor()->setFrame(NoFrame);
2540 void Main::formatFrameRectangle()
2542 if (currentMapEditor())
2543 currentMapEditor()->setFrame(Rectangle);
2546 void Main::formatIncludeImagesVer()
2548 if (currentMapEditor())
2549 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2552 void Main::formatIncludeImagesHor()
2554 if (currentMapEditor())
2555 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2558 void Main::formatHideLinkUnselected()
2560 if (currentMapEditor())
2561 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2564 void Main::viewZoomReset()
2566 if (currentMapEditor())
2570 currentMapEditor()->setWorldMatrix( m );
2571 currentMapEditor()->setViewCenter();
2572 currentMapEditor()->adjustCanvasSize();
2576 void Main::viewZoomIn()
2578 if (currentMapEditor())
2580 QWMatrix m = currentMapEditor()->worldMatrix();
2581 m.scale( 1.25, 1.25 );
2582 currentMapEditor()->setWorldMatrix( m );
2583 currentMapEditor()->setViewCenter();
2584 currentMapEditor()->adjustCanvasSize();
2588 void Main::viewZoomOut()
2590 if (currentMapEditor())
2592 QWMatrix m = currentMapEditor()->worldMatrix();
2593 m.scale( 0.8, 0.8 );
2594 currentMapEditor()->setWorldMatrix( m );
2595 currentMapEditor()->setViewCenter();
2596 currentMapEditor()->adjustCanvasSize();
2600 void Main::modModeColor()
2604 void Main::modModeLink()
2608 bool Main::settingsPDF()
2610 // Default browser is set in constructor
2612 QString text = QInputDialog::getText(
2613 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2614 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2616 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2621 bool Main::settingsURL()
2623 // Default browser is set in constructor
2625 QString text = QInputDialog::getText(
2626 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2627 settings.readEntry("/vym/mainwindow/readerURL")
2630 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2634 void Main::windowToggleNoteEditor()
2636 if (textEditor->showWithMain() )
2637 windowHideNoteEditor();
2639 windowShowNoteEditor();
2642 void Main::windowToggleHistory()
2644 if (currentMapEditor())
2645 currentMapEditor()->toggleHistoryWindow();
2648 void Main::updateNoteFlag()
2650 if (currentMapEditor())
2651 currentMapEditor()->updateNoteFlag();
2654 void Main::windowShowNoteEditor()
2656 textEditor->setShowWithMain(true);
2658 actionViewToggleNoteEditor->setOn (true);
2661 void Main::windowHideNoteEditor()
2663 textEditor->setShowWithMain(false);
2665 actionViewToggleNoteEditor->setOn (false);
2668 void Main::windowNextEditor()
2670 if (tabWidget->currentPageIndex() < tabWidget->count())
2671 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2674 void Main::windowPreviousEditor()
2676 if (tabWidget->currentPageIndex() >0)
2677 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2680 void Main::standardFlagChanged()
2682 currentMapEditor()->toggleStandardFlag(sender()->name());
2685 void Main::testFunction()
2687 currentMapEditor()->testFunction();
2690 void Main::helpDoc()
2693 #if defined(Q_OS_MACX)
2694 docpath="./vym.app/Contents/vym.pdf";
2696 // default path in SUSE LINUX
2697 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2700 if (!QFile (docpath).exists() )
2702 // relative path for easy testing in tarball
2703 docpath="doc/vym.pdf";
2704 if (!QFile (docpath).exists() )
2706 // relative path for testing while still writing vym.tex
2707 docpath="doc/tex/vym.pdf";
2708 if (!QFile (docpath).exists() )
2710 // Try yet another one for Knoppix
2711 docpath="/usr/share/doc/packages/vym/vym.pdf";
2712 if (!QFile (docpath).exists() )
2714 QMessageBox::critical(0,
2715 tr("Critcal error"),
2716 tr("Couldn't find the documentation\n"
2717 "vym.pdf in various places."));
2724 Process *pdfProc = new Process();
2725 pdfProc->clearArguments();
2726 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2727 pdfProc->addArgument( docpath);
2729 if ( !pdfProc->start() )
2732 QMessageBox::warning(0,
2734 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
2735 tr("Please use Settings->")+tr("Set application to open PDF files"));
2742 void Main::helpAbout()
2745 ad.setName ("aboutwindow");
2746 ad.setMinimumSize(500,500);
2747 ad.resize (QSize (500,500));
2751 void Main::helpAboutQT()
2753 QMessageBox::aboutQt( this, "Qt Application Example" );