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 *actionEditRemoveBranchHere;
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;
113 extern QAction* actionSettingsAutoedit;
114 extern QAction* actionSettingsAutoselectHeading;
115 extern QAction* actionSettingsAutoselectHeading;
116 extern QAction* actionSettingsAutoselectText;
117 extern QAction* actionSettingsPasteNewHeading;
118 extern QAction* actionSettingsUseDelKey;
119 extern QAction* actionSettingsUseFlagGroups;
120 extern QAction* actionSettingsUseHideExport;
122 extern QPopupMenu* branchContextMenu;
123 extern QPopupMenu* branchAddContextMenu;
124 extern QPopupMenu* branchRemoveContextMenu;
125 extern QPopupMenu* branchLinksContextMenu;
126 extern QPopupMenu* branchLinksContextMenuDup;
127 extern QPopupMenu* floatimageContextMenu;
128 extern QPopupMenu* saveImageFormatMenu;
129 extern QPopupMenu* canvasContextMenu;
130 extern QPopupMenu* lastMapsMenu;
131 extern QPopupMenu* importMenu;
132 extern QPopupMenu* exportMenu;
133 extern QPopupMenu* exportImageFormatMenu;
136 extern Settings settings;
137 extern Options options;
138 extern QDir vymBaseDir;
139 extern QString iconPath;
140 extern QString flagsPath;
142 #if defined(Q_OS_LINUX)
143 extern void qt_wait_for_window_manager( QWidget* w );
146 Main::Main(QWidget* parent, const char* name, WFlags f) :
147 QMainWindow(parent,name,f)
151 setCaption ("VYM - View Your Mind");
153 // Load window settings
154 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
155 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
156 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
157 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
160 // Create unique temporary directory
161 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
163 // Create direcctory for clipboard
164 clipboardDir=tmpVymDir+"/clipboard";
165 QDir d(clipboardDir);
166 d.mkdir (clipboardDir,true);
167 makeSubDirs (clipboardDir);
172 // FIXME not used currently
173 // Set random seed (random used for object IDs)
174 // QTime t = QTime::currentTime(); // set random seed
175 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
178 // Initialize some settings, which are platform dependant
181 // application to open URLs
182 p="/vym/mainwindow/readerURL";
183 #if defined(Q_OS_LINUX)
184 s=settings.readEntry (p,"konqueror");
186 #if defined(Q_OS_MACX)
187 s=settings.readEntry (p,"/usr/bin/open");
189 s=settings.readEntry (p,"mozilla");
192 settings.writeEntry( p,s);
194 // application to open PDFs
195 p="/vym/mainwindow/readerPDF";
196 #if defined(Q_OS_LINUX)
197 s=settings.readEntry (p,"acroread");
199 #if defined(Q_OS_MACX)
200 s=settings.readEntry (p,"/usr/bin/open");
202 s=settings.readEntry (p,"acroread");
205 settings.writeEntry( p,s);
210 // Create tab widget which holds the maps
211 tabWidget= new QTabWidget (this);
212 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
213 this, SLOT( editorChanged( QWidget * ) ) );
215 setCentralWidget(tabWidget);
219 setupFormatActions();
223 setupSettingsActions();
225 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
228 // After menu is created, we can enable some actions
229 actionFilePrint->setEnabled (true);
234 // Initialize Find window
235 findWindow=new FindWindow(NULL,"findwindow");
236 connect (findWindow, SIGNAL( findButton(QString) ),
237 this, SLOT(editFind(QString) ) );
238 connect (findWindow, SIGNAL( somethingChanged() ),
239 this, SLOT(editFindChanged() ) );
241 // Connect TextEditor, so that we can update flags if text changes
242 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
250 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
251 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
252 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
253 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
255 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
256 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
258 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
259 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
260 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
261 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
262 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
263 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
264 settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
267 int maps=lastMaps.count();
268 settings.writeEntry( "/vym/lastMaps/number",maps );
269 for (int i=1;i<=maps;i++)
271 QStringList::Iterator it = lastMaps.at(i-1);
272 s=QString("/vym/lastMaps/map-%1").arg(i);
273 if (!s.isEmpty() && i<=maxLastMaps)
274 settings.writeEntry (s, *it);
278 // To make the texteditor save its settings, call the destructor
281 // Remove temporary directory
282 removeDir (QDir(tmpVymDir));
285 void Main::loadCmdLine()
287 /* TODO draw some kind of splashscreen while loading...
293 QStringList flist=options.getFileList();
294 QStringList::Iterator it=flist.begin();
296 while (it !=flist.end() )
298 fileLoad (*it, NewMap);
304 void Main::statusMessage(const QString &s)
306 statusBar()->message (s);
309 void Main::closeEvent (QCloseEvent* )
315 void Main::setupFileActions()
317 QToolBar *tb = new QToolBar( this );
318 tb->setLabel( "File Actions" );
319 QPopupMenu *menu = new QPopupMenu( this );
320 menuBar()->insertItem( tr( "&File" ), menu );
322 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
325 a = new QAction( tr( "New map","File menu" ), QPixmap( iconPath+"filenew.png"), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
326 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
330 a = new QAction( tr( "Open","File menu" ), QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
331 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
335 lastMapsMenu = new QPopupMenu (this);
337 menu->insertItem (tr("Open Recent"),lastMapsMenu );
338 menu->insertSeparator();
340 a = new QAction( tr( "Save" ), QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
341 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
346 a = new QAction( tr( "Save &As" ), QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), 0, this, "fileSaveAs" );
347 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
350 menu->insertSeparator();
352 importMenu = new QPopupMenu (this);
353 menu->insertItem (tr("Import"),importMenu );
355 a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
356 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
357 a->addTo (importMenu);
359 a = new QAction( tr( "Import")+" Mind Manager" , QPixmap(), "Mind Manager...", 0, this, "importMM" );
360 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
361 a->addTo (importMenu);
363 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
364 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
365 a->addTo( importMenu);
367 exportMenu = new QPopupMenu (this);
368 menu->insertItem (tr("Export"),exportMenu );
370 menu->insertSeparator();
373 a = new QAction( tr( "Print" ), QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" );
374 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
379 a = new QAction( tr( "Close Map" ), QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
380 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
383 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
384 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
390 void Main::setupEditActions()
392 QToolBar *tb = new QToolBar( this );
393 tb->setLabel( "Edit Actions" );
394 QPopupMenu *menu = new QPopupMenu( this );
395 menuBar()->insertItem( tr( "&Edit" ), menu );
399 a = new QAction( tr( "Undo" ), QPixmap( iconPath+"undo.png"), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
400 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
401 a->setEnabled (false);
406 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
408 a = new QAction( tr( "Redo" ), QPixmap( iconPath+"redo.png"), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
409 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
414 menu->insertSeparator();
415 a = new QAction( tr( "Copy" ), QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
416 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
417 a->setEnabled (false);
421 a = new QAction( tr( "Cut" ), QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
422 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
423 a->setEnabled (false);
427 a = new QAction( tr( "Paste" ), QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
428 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
429 a->setEnabled (false);
434 a = new QAction( tr( "Move branch up" ), QPixmap(iconPath+"up.png" ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
435 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
436 a->setEnabled (false);
439 actionListBranches.append(a);
442 a = new QAction( tr( "Move branch down" ), QPixmap( iconPath+"down.png"), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
443 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
444 a->setEnabled (false);
447 actionListBranches.append(a);
448 actionEditMoveDown=a;
451 a = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
452 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
453 alt = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_S, this, "scroll" );
454 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
455 #if defined(Q_OS_MACX)
456 actionEditToggleScroll=alt;
458 actionEditToggleScroll=a;
460 actionEditToggleScroll->setEnabled (false);
461 actionEditToggleScroll->setToggleAction(true);
462 actionEditToggleScroll->addTo( tb );
463 actionEditToggleScroll->addTo( menu );
464 actionListBranches.append(actionEditToggleScroll);
466 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
467 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
470 menu->insertSeparator();
472 a = new QAction( tr( "Find" ), QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
473 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
476 menu->insertSeparator();
478 a = new QAction( tr( "Open URL" ), QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), CTRL + Key_U, this, "url" );
479 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
481 a->setEnabled (false);
484 a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), CTRL + Key_U, this, "urltab" );
485 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
486 a->setEnabled (false);
487 actionEditOpenURLTab=a;
489 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
490 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
491 a->setEnabled (false);
492 actionListBranches.append(a);
495 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
496 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
497 a->setEnabled (false);
498 actionListBranches.append(a);
499 actionEditHeading2URL=a;
501 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
502 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
503 a->setEnabled (false);
504 actionListBranches.append(a);
505 actionEditBugzilla2URL=a;
507 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
508 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
509 a->setEnabled (false);
510 actionListBranches.append(a);
511 actionEditFATE2URL=a;
513 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" );
514 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
516 a->setEnabled (false);
517 actionEditOpenVymLink=a;
519 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
520 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
521 a->setEnabled (false);
522 actionListBranches.append(a);
525 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
526 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
527 a->setEnabled (false);
528 actionEditDeleteVymLink=a;
530 a = new QAction( tr( "Hide object in exports" ), QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), Key_H, this, "hideExport" );
531 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
532 a->setToggleAction(true);
534 a->setEnabled (false);
535 actionEditToggleHideExport=a;
537 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
538 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
539 a->setEnabled (true);
542 menu->insertSeparator();
544 // Shortcuts to modify heading:
545 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
546 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
547 actionListBranches.append(a);
548 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
549 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
550 actionListBranches.append(a);
552 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
553 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
554 a->setEnabled (false);
556 actionListBranches.append(a);
558 // Shortcut to delete selection
559 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
560 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
561 a->setEnabled (false);
564 // Shortcut to add branch
565 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
566 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
567 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
568 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
569 a->setEnabled (false);
570 actionListBranches.append(a);
571 #if defined (Q_OS_MACX)
572 // In OSX show different shortcut in menues, the keys work independtly always
573 actionEditAddBranch=alt;
575 actionEditAddBranch=a;
578 // Add branch by inserting it at selection
579 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
580 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
581 a->setEnabled (false);
582 actionListBranches.append(a);
583 actionEditAddBranchHere=a;
584 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
585 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
586 actionListBranches.append(a);
589 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
590 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
591 a->setEnabled (false);
592 actionListBranches.append(a);
593 actionEditAddBranchAbove=a;
594 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
595 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
596 actionListBranches.append(a);
599 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
600 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
601 a->setEnabled (false);
602 actionListBranches.append(a);
603 actionEditAddBranchBelow=a;
604 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
605 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
606 actionListBranches.append(a);
608 // Import at selection (adding to selection)
609 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
610 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
611 a->setEnabled (false);
612 actionListBranches.append(a);
613 actionEditImportAdd=a;
615 // Import at selection (replacing selection)
616 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
617 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
618 a->setEnabled (false);
619 actionListBranches.append(a);
620 actionEditImportReplace=a;
623 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
624 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
625 a->setEnabled (false);
626 actionListBranches.append(a);
627 actionEditSaveBranch=a;
629 // Only remove branch, not its childs
630 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
631 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 actionEditRemoveBranchHere=a;
636 // Only remove childs of a branch
637 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
638 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
639 a->setEnabled (false);
640 actionListBranches.append(a);
641 actionEditRemoveChilds=a;
643 // Shortcuts for navigating with cursor:
644 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
645 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
646 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
647 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
648 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
649 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
650 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
651 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
652 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
653 a->setEnabled (false);
655 actionListBranches.append(a);
656 actionEditSelectFirst=a;
657 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
658 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
659 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
660 a->setEnabled (false);
662 actionListBranches.append(a);
663 actionEditSelectLast=a;
665 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
666 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
667 actionEditLoadImage=a;
672 void Main::setupFormatActions()
674 QPopupMenu *menu = new QPopupMenu( this );
675 menuBar()->insertItem( tr( "&Format" ), menu );
677 QToolBar *tb = new QToolBar( this );
681 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
682 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
683 actionFormatColor->addTo( tb );
684 actionFormatColor->addTo( menu );
685 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" );
686 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
687 a->setEnabled (false);
690 actionListBranches.append(a);
691 actionFormatPickColor=a;
692 a= new QAction( tr( "Color branch" ), QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
693 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
694 a->setEnabled (false);
697 actionListBranches.append(a);
698 actionFormatColorBranch=a;
699 a= new QAction( tr( "Color Subtree" ), QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
700 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
701 a->setEnabled (false);
704 actionListBranches.append(a);
705 actionFormatColorSubtree=a;
707 menu->insertSeparator();
708 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
709 actionGroupFormatLinkStyles->setExclusive (true);
710 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
711 a->setToggleAction(true);
712 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
713 actionFormatLinkStyleLine=a;
714 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
715 a->setToggleAction(true);
716 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
717 actionFormatLinkStyleParabel=a;
718 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
719 a->setToggleAction(true);
720 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
721 actionFormatLinkStylePolyLine=a;
722 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
723 a->setToggleAction(true);
724 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
725 actionFormatLinkStylePolyParabel=a;
726 actionGroupFormatLinkStyles->addTo (menu);
728 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
729 actionGroupFormatFrameTypes->setExclusive (true);
730 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
731 a->setToggleAction(true);
732 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
733 actionFormatFrameNone=a;
734 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
735 a->setToggleAction(true);
736 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
737 actionFormatFrameRectangle=a;
739 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
740 a->setToggleAction(true);
741 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
742 actionFormatIncludeImagesVer=a;
744 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
745 a->setToggleAction(true);
746 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
747 actionFormatIncludeImagesHor=a;
749 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
750 a->setToggleAction(true);
751 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
752 actionFormatHideLinkUnselected=a;
754 menu->insertSeparator();
755 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
756 a->setToggleAction(true);
757 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
759 actionFormatLinkColorHint=a;
761 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
762 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
763 actionFormatLinkColor->addTo( menu );
764 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
765 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
766 actionFormatBackColor->addTo( menu );
770 void Main::setupViewActions()
772 QToolBar *tb = new QToolBar( this );
773 tb->setLabel( "View Actions" );
774 QPopupMenu *menu = new QPopupMenu( this );
775 menuBar()->insertItem( tr( "&View" ), menu );
778 a = new QAction( tr( "Zoom reset" ), QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
779 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
782 a = new QAction( tr( "Zoom in" ), QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
783 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
786 a = new QAction( tr( "Zoom out" ), QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
787 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
790 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flagsPath+"flag-note.png"), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
791 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
792 a->setToggleAction(true);
793 if (textEditor->showWithMain())
799 actionViewToggleNoteEditor=a;
800 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
801 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
803 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
804 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
809 void Main::setupModeActions()
811 //QPopupMenu *menu = new QPopupMenu( this );
812 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
814 QToolBar *tb = new QToolBar( this );
815 tb->setLabel( tr ("Modes when using modifiers") );
817 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
818 actionGroupModModes->setExclusive (true);
819 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(iconPath+"modecolor.png"), 0, Key_J, actionGroupModModes, "modModeColor" );
820 a->setToggleAction(true);
823 actionModModeColor=a;
825 a= new QAction( tr( "Use modifier to copy" ), QPixmap(iconPath+"modecopy.png"), 0, Key_K, actionGroupModModes, "modModeCopy" );
826 a->setToggleAction(true);
830 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(iconPath+"modelink.png"), 0, Key_L, actionGroupModModes, "modModeLink" );
831 a->setToggleAction(true);
837 void Main::setupFlagActions()
839 // Create System Flags
840 systemFlagsDefault = new FlagRowObj ();
841 systemFlagsDefault->setVisibility (false);
842 systemFlagsDefault->setName ("systemFlagsDef");
844 FlagObj *fo = new FlagObj ();
845 fo->load(QPixmap(flagsPath+"flag-note.png"));
847 fo->setToolTip(tr("Note","Systemflag"));
848 systemFlagsDefault->addFlag (fo); // makes deep copy
850 fo->load(QPixmap(flagsPath+"flag-url.png"));
852 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
853 systemFlagsDefault->addFlag (fo);
855 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
856 fo->setName("vymLink");
857 fo->setToolTip(tr("Link to another vym map","Systemflag"));
858 systemFlagsDefault->addFlag (fo);
860 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
861 fo->setName("scrolledright");
862 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
863 systemFlagsDefault->addFlag (fo);
865 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
866 fo->setName("tmpUnscrolledright");
867 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
868 systemFlagsDefault->addFlag (fo);
870 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
871 fo->setName("hideInExport");
872 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
873 systemFlagsDefault->addFlag (fo);
875 // Create Standard Flags
876 standardFlagsDefault = new FlagRowObj ();
877 standardFlagsDefault->setVisibility (false);
878 standardFlagsDefault->setName ("standardFlagsDef");
880 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
881 fo->setName ("exclamationmark");
882 fo->setGroup("standard-mark");
883 fo->setToolTip(tr("Take care!","Standardflag"));
884 standardFlagsDefault->addFlag (fo); // makes deep copy
886 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
887 fo->setName("questionmark");
888 fo->setGroup("standard-mark");
889 fo->setToolTip(tr("Really?","Standardflag"));
890 standardFlagsDefault->addFlag (fo);
892 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
893 fo->setName("hook-green");
894 fo->setGroup("standard-hook");
895 fo->setToolTip(tr("ok!","Standardflag"));
896 standardFlagsDefault->addFlag (fo);
898 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
899 fo->setName("cross-red");
900 fo->setGroup("standard-hook");
901 fo->setToolTip(tr("Not ok!","Standardflag"));
902 standardFlagsDefault->addFlag (fo);
904 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
905 fo->setName("stopsign");
906 fo->setToolTip(tr("This won't work!","Standardflag"));
907 standardFlagsDefault->addFlag (fo);
909 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
910 fo->setName("smiley-good");
911 fo->setGroup("standard-smiley");
912 fo->setToolTip(tr("Good","Standardflag"));
913 standardFlagsDefault->addFlag (fo);
915 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
916 fo->setName("smiley-sad");
917 fo->setGroup("standard-smiley");
918 fo->setToolTip(tr("Bad","Standardflag"));
919 standardFlagsDefault->addFlag (fo);
921 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
922 // Original omg.png (in KDE emoticons)
923 fo->setName("smiley-omg");
924 fo->setGroup("standard-smiley");
925 fo->setToolTip(tr("Oh no!","Standardflag"));
926 standardFlagsDefault->addFlag (fo);
928 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
929 fo->setName("clock");
930 fo->setToolTip(tr("Time critical","Standardflag"));
931 standardFlagsDefault->addFlag (fo);
933 fo->load(QPixmap(flagsPath+"flag-phone.png"));
934 fo->setName("phone");
935 fo->setToolTip(tr("Call...","Standardflag"));
936 standardFlagsDefault->addFlag (fo);
938 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
940 fo->setToolTip(tr("Idea!","Standardflag"));
941 standardFlagsDefault->addFlag (fo);
943 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
944 fo->setName("arrow-up");
945 fo->setGroup("standard-arrow");
946 fo->setToolTip(tr("Important","Standardflag"));
947 standardFlagsDefault->addFlag (fo);
949 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
950 fo->setName("arrow-down");
951 fo->setGroup("standard-arrow");
952 fo->setToolTip(tr("Unimportant","Standardflag"));
953 standardFlagsDefault->addFlag (fo);
955 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
956 fo->setName("2arrow-up");
957 fo->setGroup("standard-arrow");
958 fo->setToolTip(tr("Very important!","Standardflag"));
959 standardFlagsDefault->addFlag (fo);
961 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
962 fo->setName("2arrow-down");
963 fo->setGroup("standard-arrow");
964 fo->setToolTip(tr("Very unimportant!","Standardflag"));
965 standardFlagsDefault->addFlag (fo);
967 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
968 fo->setName("thumb-up");
969 fo->setGroup("standard-thumb");
970 fo->setToolTip(tr("I like this","Standardflag"));
971 standardFlagsDefault->addFlag (fo);
973 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
974 fo->setName("thumb-down");
975 fo->setGroup("standard-thumb");
976 fo->setToolTip(tr("I like this","Standardflag"));
977 fo->setToolTip(tr("I do not like this","Standardflag"));
978 standardFlagsDefault->addFlag (fo);
980 fo->load(QPixmap(flagsPath+"flag-rose.png"));
982 fo->setToolTip(tr("Rose","Standardflag"));
983 standardFlagsDefault->addFlag (fo);
985 fo->load(QPixmap(flagsPath+"flag-heart.png"));
986 fo->setName("heart");
987 fo->setToolTip(tr("I just love... ","Standardflag"));
988 standardFlagsDefault->addFlag (fo);
990 fo->load(QPixmap(flagsPath+"flag-present.png"));
991 fo->setName("present");
992 fo->setToolTip(tr("Surprise!","Standardflag"));
993 standardFlagsDefault->addFlag (fo);
995 fo->load(QPixmap(flagsPath+"flag-flash.png"));
996 fo->setName("flash");
997 fo->setToolTip(tr("Dangerous","Standardflag"));
998 standardFlagsDefault->addFlag (fo);
1000 fo->load(QPixmap(flagsPath+"flag-info.png"));
1001 // Original: xsldbg_output.png
1002 fo->setName("info");
1003 fo->setToolTip(tr("Info","Standardflag"));
1004 standardFlagsDefault->addFlag (fo);
1006 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1007 // Original khelpcenter.png
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 // Context menu for canvas
1239 canvasContextMenu =new QPopupMenu (this);
1240 actionEditMapInfo->addTo( canvasContextMenu );
1241 canvasContextMenu->insertSeparator();
1242 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1243 canvasContextMenu->insertSeparator();
1244 actionFormatLinkColorHint->addTo( canvasContextMenu );
1245 actionFormatLinkColor->addTo( canvasContextMenu );
1246 actionFormatBackColor->addTo( canvasContextMenu );
1248 // Menu for last opened files
1249 // Read settings initially
1251 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1252 for (int i=1;i<=j;i++)
1254 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1255 if (!s.isEmpty() && j<=maxLastMaps)
1258 setupLastMapsMenu();
1259 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1262 void Main::setupLastMapsMenu()
1264 // Remove double entries
1265 QStringList::Iterator it=lastMaps.begin();
1266 QStringList::Iterator jt;
1267 while (it!=lastMaps.end() )
1271 while (jt!=lastMaps.end() )
1274 jt=lastMaps.remove(jt);
1281 // Limit length of list to maxLastMaps
1282 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1284 // build Menu from lastMaps string list
1285 lastMapsMenu->clear();
1286 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1287 lastMapsMenu->insertItem (*it );
1291 void Main::hideEvent (QHideEvent * )
1293 if (!textEditor->isMinimized() ) textEditor->hide();
1296 void Main::showEvent (QShowEvent * )
1298 if (textEditor->showWithMain()) textEditor->showNormal();
1301 bool Main::reallyWriteDirectory(const QString &dir)
1303 QStringList eList = QDir(dir).entryList();
1304 if (eList.first() ==".") eList.pop_front(); // remove "."
1305 if (eList.first() =="..") eList.pop_front(); // remove "."
1306 if (!eList.isEmpty())
1308 QMessageBox mb( __VYM,
1309 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1310 QMessageBox::Warning,
1312 QMessageBox::Cancel | QMessageBox::Default,
1313 QMessageBox::QMessageBox::NoButton );
1315 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1316 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1319 case QMessageBox::Yes:
1322 case QMessageBox::Cancel:
1330 QString Main::browseDirectory (const QString &caption)
1332 QFileDialog fd(this,caption);
1333 fd.setMode (QFileDialog::DirectoryOnly);
1334 fd.setCaption(__VYM " - "+caption);
1337 if ( fd.exec() == QDialog::Accepted )
1338 return fd.selectedFile();
1343 MapEditor* Main::currentMapEditor() const
1345 if ( tabWidget->currentPage() &&
1346 tabWidget->currentPage()->inherits( "MapEditor" ) )
1347 return (MapEditor*)tabWidget->currentPage();
1351 //TODO not used now, maybe use this for overview window later
1352 void Main::newView()
1354 // Open a new view... have it delete when closed.
1355 Main *m = new Main(0, 0, WDestructiveClose);
1356 qApp->setMainWidget(m);
1358 qApp->setMainWidget(0);
1361 void Main::editorChanged(QWidget *)
1363 // Unselect all possibly selected objects
1364 // (Important to update note editor)
1367 for (i=0;i<=tabWidget->count() -1;i++)
1370 me=(MapEditor*)tabWidget->page(i);
1373 currentMapEditor()->reselect();
1375 // Update actions to in menus and toolbars according to editor
1376 currentMapEditor()->updateActions();
1379 void Main::fileNew()
1381 QString fn="unnamed";
1382 MapEditor* medit = new MapEditor (tabWidget, true);
1383 tabWidget->addTab (medit,fn);
1384 tabWidget->showPage(medit);
1385 medit->viewport()->setFocus();
1386 // For the very first map we do not have flagrows yet...
1387 medit->select("mc:");
1390 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1392 ErrorCode err=success;
1394 // fn is usually the archive, mapfile the file after uncompressing
1397 // Make fn absolute (needed for unzip)
1398 fn=QDir (fn).absPath();
1404 // Check, if map is already loaded
1406 while (i<=tabWidget->count() -1)
1408 me=(MapEditor*)tabWidget->page(i);
1409 if (me->getFilePath() == fn)
1411 // Already there, ask for confirmation
1412 QMessageBox mb( __VYM,
1413 tr("The map %1\nis already opened."
1414 "Opening the same map in multiple editors may lead \n"
1415 "to confusion when finishing working with vym."
1416 "Do you want to").arg(fn),
1417 QMessageBox::Warning,
1418 QMessageBox::Yes | QMessageBox::Default,
1419 QMessageBox::Cancel | QMessageBox::Escape,
1420 QMessageBox::QMessageBox::NoButton);
1421 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1422 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1425 case QMessageBox::Yes:
1427 i=tabWidget->count();
1429 case QMessageBox::Cancel:
1441 if ( !fn.isEmpty() )
1443 me = currentMapEditor();
1444 int tabIndex=tabWidget->currentPageIndex();
1445 // Check first, if mapeditor exists
1446 // If it is not default AND we want a new map,
1447 // create a new mapeditor in a new tab
1448 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1450 me = new MapEditor (tabWidget,true);
1451 tabWidget->addTab (me,fn);
1452 tabIndex=tabWidget->indexOf (me);
1453 tabWidget->setCurrentPage (tabIndex);
1456 // Check, if file exists (important for creating new files
1457 // from command line
1458 if (!QFile(fn).exists() )
1460 QMessageBox mb( __VYM,
1461 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1462 QMessageBox::Question,
1464 QMessageBox::Cancel | QMessageBox::Default,
1465 QMessageBox::QMessageBox::NoButton );
1467 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1468 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1471 case QMessageBox::Yes:
1473 currentMapEditor()->setFilePath(fn);
1474 tabWidget->setTabLabel (currentMapEditor(),
1475 currentMapEditor()->getFileName() );
1476 statusBar()->message( "Created " + fn , statusbarTime );
1479 case QMessageBox::Cancel:
1480 // don't create new map
1481 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1488 //tabWidget->currentPage() won't be NULL here, because of above...
1489 tabWidget->showPage(me);
1490 me->viewport()->setFocus();
1492 // Create temporary directory for packing
1493 char tmpdir1[]="/tmp/vym-XXXXXX";
1494 QString tmpMapDir=mkdtemp(tmpdir1);
1496 // Try to unzip file
1497 err=unzipDir (tmpMapDir,fn);
1501 me->setZipped(false);
1504 me->setZipped(true);
1506 // Look for mapname.xml
1507 mapfile= fn.left(fn.findRev(".",-1,true));
1508 mapfile=mapfile.section( '/', -1 );
1509 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1510 if (!file.exists() )
1512 // mapname.xml does not exist, well,
1513 // maybe some renamed the mapname.vym file...
1514 // Try to find any .xml in the toplevel
1515 // directory of the .vym file
1516 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1517 if (flist.count()==1)
1519 // Only one entry, take this one
1520 mapfile=tmpMapDir + "/"+flist.first();
1523 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1524 *it=tmpMapDir + "/" + *it;
1525 // TODO Multiple entries, load all (but only the first one into this ME)
1526 //mainWindow->fileLoadFromTmp (flist);
1527 //returnCode=1; // Silently forget this attempt to load
1528 qWarning ("MainWindow::load (fn) multimap found...");
1531 if (flist.isEmpty() )
1533 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1534 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1537 } //file doesn't exist
1539 mapfile=file.name();
1544 // Save existing filename in case we import
1545 QString fn_org=me->getFilePath();
1547 // Finally load map into mapEditor
1548 me->setFilePath (mapfile,fn);
1549 err=me->load(mapfile,lmode);
1551 // Restore old (maybe empty) filepath, if this is an import
1553 me->setFilePath (fn_org);
1556 // Finally check for errors and go home
1559 if (lmode==NewMap) fileCloseMap();
1560 statusBar()->message( "Could not load " + fn, statusbarTime );
1565 me->setFilePath (fn);
1566 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1567 if (fn.left(9)!="/tmp/vym-")
1569 // Only append to lastMaps if not loaded from a tmpDir
1570 // e.g. imported bookmarks are in a tmpDir
1571 lastMaps.prepend(me->getFilePath() );
1572 setupLastMapsMenu();
1574 actionFilePrint->setEnabled (true);
1576 statusBar()->message( "Loaded " + fn, statusbarTime );
1580 removeDir (QDir(tmpMapDir));
1586 void Main::fileLoad(const LoadMode &lmode)
1588 QFileDialog *fd=new QFileDialog( this);
1589 if (!lastFileDir.isEmpty())
1590 fd->setDir (lastFileDir);
1591 fd->setMode (QFileDialog::ExistingFiles);
1592 fd->addFilter ("XML (*.xml)");
1593 fd->addFilter ("VYM map (*.vym *.vyp)");
1597 fd->setCaption(tr("Load vym map"));
1600 fd->setCaption(tr("Import: Add vym map to selection"));
1603 fd->setCaption(tr("Import: Replace selection with vym map"));
1609 if ( fd->exec() == QDialog::Accepted )
1611 lastFileDir=fd->dirPath();
1612 QStringList flist = fd->selectedFiles();
1613 QStringList::Iterator it = flist.begin();
1614 while( it != flist.end() )
1617 fileLoad(*it, lmode);
1624 void Main::fileLoad()
1629 void Main::fileLoadLast(int i)
1631 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1634 void Main::fileSave(const SaveMode &savemode)
1636 // tmp dir for zipping
1640 ErrorCode err=success;
1642 QString safeFilePath;
1644 bool saveZipped=currentMapEditor()->saveZipped();
1646 MapEditor * me=currentMapEditor();
1649 QString fn=me->getFilePath();
1650 // filename=unnamed, filepath="" in constructor...
1651 if ( !fn.isEmpty() )
1653 // We have a filepath, go on saving
1654 // First remove existing file, we
1655 // don't want to add to old zip archives
1659 QMessageBox::warning( 0, tr( "Save Error" ),
1660 fn+ tr("\ncould not be removed before saving"));
1662 // Look, if we should zip the data:
1665 QMessageBox mb( __VYM,
1666 tr("The map %1\ndid not use the compressed "
1667 "vym file format.\nWriting it uncompressed will also write images \n"
1668 "and flags and thus may overwrite files in the "
1669 "given directory\n\nDo you want to write the map").arg(fn),
1670 QMessageBox::Warning,
1671 QMessageBox::Yes | QMessageBox::Default,
1673 QMessageBox::Cancel | QMessageBox::Escape);
1674 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1675 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1676 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1679 case QMessageBox::Yes:
1680 // save compressed (default file format)
1683 case QMessageBox::No:
1684 // save uncompressed
1687 case QMessageBox::Cancel:
1696 char tmpdir1[]="/tmp/vym-XXXXXX";
1697 tmpMapDir=mkdtemp(tmpdir1);
1699 safeFilePath=me->getFilePath();
1700 me->setFilePath (tmpMapDir+"/"+
1701 me->getMapName()+ ".xml",
1703 me->save (savemode);
1704 me->setFilePath (safeFilePath);
1706 zipDir (tmpMapDir,fn);
1711 safeFilePath=me->getFilePath();
1712 me->setFilePath (fn, safeFilePath);
1713 me->save (savemode);
1714 me->setFilePath (safeFilePath);
1716 } // filepath available
1719 // We have no filepath yet,
1720 // call fileSaveAs() now, this will call fileSave()
1722 fileSaveAs(savemode);
1726 if (saveZipped && !tmpMapDir.isEmpty())
1728 removeDir (QDir(tmpMapDir));
1732 statusBar()->message(
1733 tr("Saved %1").arg(me->getFilePath()),
1735 lastMaps.prepend(me->getFilePath() );
1736 setupLastMapsMenu();
1738 statusBar()->message(
1739 tr("Couldn't save ").arg(me->getFilePath()),
1743 void Main::fileSave()
1745 fileSave (CompleteMap);
1748 void Main::fileSaveAs(const SaveMode& savemode)
1752 if (currentMapEditor())
1754 if (savemode==CompleteMap)
1755 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1757 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1758 if ( !fn.isEmpty() )
1760 // Check for existing file
1761 if (QFile (fn).exists())
1763 QMessageBox mb( __VYM,
1764 tr("The file %1\nexists already. Do you want to").arg(fn),
1765 QMessageBox::Warning,
1766 QMessageBox::Yes | QMessageBox::Default,
1767 QMessageBox::Cancel | QMessageBox::Escape,
1768 QMessageBox::QMessageBox::NoButton);
1769 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1770 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1773 case QMessageBox::Yes:
1776 case QMessageBox::Cancel:
1783 // New file, add extension to filename, if missing
1784 // This is always .vym or .vyp, depending on savemode
1785 if (savemode==CompleteMap)
1787 if (!fn.contains (".vym") && !fn.contains (".xml"))
1791 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1800 currentMapEditor()->setFilePath(fn);
1804 if (savemode==CompleteMap)
1805 tabWidget->setTabLabel (currentMapEditor(),
1806 currentMapEditor()->getFileName() );
1812 void Main::fileSaveAs()
1814 fileSaveAs (CompleteMap);
1817 void Main::fileImportKDEBookmarks()
1819 ImportKDEBookmarks im;
1821 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1822 currentMapEditor()->setFilePath ("");
1825 void Main::fileImportMM()
1829 QFileDialog *fd=new QFileDialog( this);
1830 if (!lastFileDir.isEmpty())
1831 fd->setDir (lastFileDir);
1832 fd->setMode (QFileDialog::ExistingFiles);
1833 fd->addFilter ("Mind Manager (*.mmap)");
1834 fd->setCaption(tr("Import")+" "+"Mind Manager");
1837 if ( fd->exec() == QDialog::Accepted )
1839 lastFileDir=fd->dirPath();
1840 QStringList flist = fd->selectedFiles();
1841 QStringList::Iterator it = flist.begin();
1842 while( it != flist.end() )
1845 if (im.transform() &&
1846 success==fileLoad (im.getTransformedFile(),NewMap) &&
1847 currentMapEditor() )
1848 currentMapEditor()->setFilePath ("");
1857 void Main::fileImportDir()
1859 if (currentMapEditor())
1860 currentMapEditor()->importDir();
1863 void Main::fileExportXML()
1865 if (currentMapEditor())
1867 QString dir=browseDirectory(tr("Export XML to directory"));
1868 if (dir !="" && reallyWriteDirectory(dir) )
1869 currentMapEditor()->exportXML(dir);
1874 void Main::fileExportXHTML()
1876 MapEditor *me=currentMapEditor();
1880 ExportXHTMLDialog dia(this);
1881 dia.setFilePath (me->getFilePath() );
1882 dia.setMapName (me->getMapName() );
1885 if (dia.exec()==QDialog::Accepted)
1887 QString dir=dia.getDir();
1888 // Check, if warnings should be used before overwriting
1889 // the output directory
1892 ok=reallyWriteDirectory(dir);
1898 me->exportXML (dia.getDir() );
1899 dia.doExport(me->getMapName() );
1900 if (dia.hasChanged())
1907 void Main::fileExportImage(int item)
1909 MapEditor *me=currentMapEditor();
1912 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1914 if ( !fn.isEmpty() )
1915 me->exportImage(fn,item);
1917 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1922 void Main::fileExportASCII()
1924 MapEditor *me=currentMapEditor();
1928 ex.setMapCenter(me->getMapCenter());
1929 ex.addFilter ("TXT (*.txt)");
1930 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1931 if (ex.execDialog() )
1933 me->setExportMode(true);
1935 me->setExportMode(false);
1940 void Main::fileExportLaTeX()
1942 MapEditor *me=currentMapEditor();
1946 ex.setMapCenter(me->getMapCenter());
1947 ex.addFilter ("Tex (*.tex)");
1948 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1949 if (ex.execDialog() )
1951 me->setExportMode(true);
1953 me->setExportMode(false);
1958 void Main::fileExportKDEBookmarks()
1960 ExportKDEBookmarks ex;
1961 MapEditor *me=currentMapEditor();
1964 ex.setMapCenter (me->getMapCenter() );
1969 void Main::fileExportTaskjuggler()
1971 ExportTaskjuggler ex;
1972 MapEditor *me=currentMapEditor();
1975 ex.setMapCenter (me->getMapCenter() );
1976 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
1977 ex.addFilter ("Taskjuggler (*.tjp)");
1978 if (ex.execDialog() )
1980 me->setExportMode(true);
1982 me->setExportMode(false);
1987 void Main::fileExportOOPresentation()
1989 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
1990 // FIXME add extra info in dialog
1991 //ImagePreview *p =new ImagePreview (fd);
1992 //fd->setContentsPreviewEnabled( TRUE );
1993 //fd->setContentsPreview( p, p );
1994 //fd->setPreviewMode( QFileDialog::Contents );
1995 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
1996 //fd->setDir (lastImageDir);
1999 if ( fd->exec() == QDialog::Accepted )
2001 QString fn=fd->selectedFile();
2002 //lastImageDir=fn.left(fn.findRev ("/"));
2003 if (currentMapEditor())
2004 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2008 void Main::fileCloseMap()
2010 if (currentMapEditor())
2012 if (currentMapEditor()->hasChanged())
2014 QMessageBox mb( __VYM,
2015 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2016 QMessageBox::Warning,
2017 QMessageBox::Yes | QMessageBox::Default,
2019 QMessageBox::Cancel | QMessageBox::Escape );
2020 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2021 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2024 case QMessageBox::Yes:
2026 fileSave(CompleteMap);
2028 case QMessageBox::No:
2029 // close without saving
2031 case QMessageBox::Cancel:
2036 currentMapEditor()->closeMap();
2037 tabWidget->removePage(currentMapEditor());
2038 if (tabWidget->count()==0)
2039 actionFilePrint->setEnabled (false);
2043 void Main::filePrint()
2045 if (currentMapEditor())
2046 currentMapEditor()->print();
2049 void Main::fileExitVYM()
2051 // Check if one or more editors have changed
2054 for (i=0;i<=tabWidget->count() -1;i++)
2057 me=(MapEditor*)tabWidget->page(i);
2059 // If something changed, ask what to do
2060 if (me->isUnsaved())
2062 tabWidget->setCurrentPage(i);
2063 QMessageBox mb( __VYM,
2064 tr("This map is not saved yet. Do you want to"),
2065 QMessageBox::Warning,
2066 QMessageBox::Yes | QMessageBox::Default,
2068 QMessageBox::Cancel | QMessageBox::Escape );
2069 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2070 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2072 // Call undocumented function: setActiveWindow is only
2073 // possible, if widget is visible. This depends on
2075 #if defined(Q_OS_LINUX)
2076 qt_wait_for_window_manager( this);
2078 mb.setActiveWindow();
2079 switch( mb.exec() ) {
2080 case QMessageBox::Yes:
2081 // save (the changed editors) and exit
2082 fileSave(CompleteMap);
2084 case QMessageBox::No:
2085 // exit without saving
2087 case QMessageBox::Cancel:
2088 // don't save and don't exit
2092 } // loop over all MEs
2096 void Main::editUndo()
2098 if (currentMapEditor())
2099 currentMapEditor()->undo();
2102 void Main::editRedo()
2104 if (currentMapEditor())
2105 currentMapEditor()->redo();
2108 void Main::editCopy()
2110 if (currentMapEditor())
2111 currentMapEditor()->copy();
2114 void Main::editPaste()
2116 if (currentMapEditor())
2117 currentMapEditor()->paste();
2120 void Main::editCut()
2122 if (currentMapEditor())
2123 currentMapEditor()->cut();
2126 void Main::editOpenFindWindow()
2128 findWindow->popup();
2129 findWindow->raise();
2131 // Call undocumented function: setActiveWindow is only
2132 // possible, if widget is visible. This depends on
2134 #if defined(Q_OS_LINUX)
2135 qt_wait_for_window_manager( this);
2137 findWindow->setActiveWindow();
2140 void Main::editFind(QString s)
2143 BranchObj *bo=currentMapEditor()->findText(s, cs);
2146 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2149 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2150 tr("No matches found for <b>%1</b>").arg(s));
2154 void Main::editFindChanged()
2155 { // Notify editor, to abort the current find process
2156 currentMapEditor()->findReset();
2159 void Main::editOpenURL()
2162 if (currentMapEditor())
2164 QString url=currentMapEditor()->getURL();
2165 if (url=="") return;
2166 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2167 procBrowser = new QProcess( this );
2169 procBrowser->addArgument( browser);
2170 procBrowser->addArgument( url);
2172 if ( !procBrowser->start() )
2174 // try to set path to browser
2175 QMessageBox::warning(0,
2177 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2178 tr("Please use Settings->")+tr("Set application to open an URL"));
2183 void Main::editOpenURLTab()
2185 if (currentMapEditor())
2187 QString url=currentMapEditor()->getURL();
2188 if (url=="") return;
2189 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2190 if (browser.contains("konqueror") && procBrowser && procBrowser->isRunning())
2192 // Try to open new tab in existing browser
2193 QProcess *p=new QProcess (this);
2194 p->addArgument ("dcop");
2195 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2196 p->addArgument ("konqueror-mainwindow#1");
2197 p->addArgument ("newTab");
2198 p->addArgument (url);
2200 // try to set browser
2201 QMessageBox::warning(0,
2203 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2210 void Main::editURL()
2212 if (currentMapEditor())
2213 currentMapEditor()->editURL();
2216 void Main::editHeading2URL()
2218 if (currentMapEditor())
2219 currentMapEditor()->editHeading2URL();
2222 void Main::editBugzilla2URL()
2224 if (currentMapEditor())
2225 currentMapEditor()->editBugzilla2URL();
2228 void Main::editFATE2URL()
2230 if (currentMapEditor())
2231 currentMapEditor()->editFATE2URL();
2234 void Main::editOpenVymLink()
2236 // Get current path to map
2237 QString currentVymLink;
2238 if (currentMapEditor())
2240 currentVymLink=currentMapEditor()->getVymLink();
2241 // compare path with already loaded maps
2245 for (i=0;i<=tabWidget->count() -1;i++)
2247 me=(MapEditor*)tabWidget->page(i);
2248 if (currentVymLink==me->getFilePath() )
2257 if (!QFile(currentVymLink).exists() )
2258 QMessageBox::critical( 0, tr( "Critical Error" ),
2259 tr("Couldn't open map %1").arg(currentVymLink));
2262 fileLoad (currentVymLink, NewMap);
2263 tabWidget->setCurrentPage (tabWidget->count()-1);
2266 // Go to tab containing the map
2267 tabWidget->setCurrentPage (index);
2271 void Main::editVymLink()
2273 if (currentMapEditor())
2274 currentMapEditor()->editVymLink();
2277 void Main::editDeleteVymLink()
2279 if (currentMapEditor())
2280 currentMapEditor()->deleteVymLink();
2283 void Main::editToggleHideExport()
2285 if (currentMapEditor())
2286 currentMapEditor()->setHideExport();
2289 void Main::editMapInfo()
2291 if (currentMapEditor())
2292 currentMapEditor()->editMapInfo();
2295 void Main::editMoveUp()
2297 if (currentMapEditor())
2298 currentMapEditor()->moveBranchUp();
2301 void Main::editMoveDown()
2303 if (currentMapEditor())
2304 currentMapEditor()->moveBranchDown();
2307 void Main::editToggleScroll()
2309 if (currentMapEditor())
2311 currentMapEditor()->toggleScroll();
2315 void Main::editUnScrollAll()
2317 if (currentMapEditor())
2319 currentMapEditor()->unScrollAll();
2323 void Main::editHeading()
2325 if (currentMapEditor())
2326 currentMapEditor()->editHeading();
2329 void Main::editNewBranch()
2331 if (currentMapEditor())
2332 currentMapEditor()->addNewBranch(0);
2335 void Main::editNewBranchHere()
2337 if (currentMapEditor())
2338 currentMapEditor()->addNewBranchHere();
2341 void Main::editNewBranchAbove()
2343 if (currentMapEditor())
2344 currentMapEditor()->addNewBranch(-1);
2347 void Main::editNewBranchBelow()
2349 if (currentMapEditor())
2350 currentMapEditor()->addNewBranch(1);
2353 void Main::editImportAdd()
2355 fileLoad (ImportAdd);
2358 void Main::editImportReplace()
2360 fileLoad (ImportReplace);
2363 void Main::editSaveBranch()
2365 fileSaveAs (PartOfMap);
2368 void Main::editRemoveBranchHere()
2370 if (currentMapEditor())
2371 currentMapEditor()->removeBranchHere();
2374 void Main::editRemoveChilds()
2376 if (currentMapEditor())
2377 currentMapEditor()->removeChilds();
2380 void Main::editDeleteSelection()
2382 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2383 currentMapEditor()->deleteSelection();
2386 void Main::editUpperBranch()
2388 if (currentMapEditor())
2389 currentMapEditor()->selectUpperBranch();
2392 void Main::editLowerBranch()
2394 if (currentMapEditor())
2395 currentMapEditor()->selectLowerBranch();
2398 void Main::editLeftBranch()
2400 if (currentMapEditor())
2401 currentMapEditor()->selectLeftBranch();
2404 void Main::editRightBranch()
2406 if (currentMapEditor())
2407 currentMapEditor()->selectRightBranch();
2410 void Main::editFirstBranch()
2412 if (currentMapEditor())
2413 currentMapEditor()->selectFirstBranch();
2416 void Main::editLastBranch()
2418 if (currentMapEditor())
2419 currentMapEditor()->selectLastBranch();
2422 void Main::editLoadImage()
2424 if (currentMapEditor())
2425 currentMapEditor()->loadFloatImage();
2428 void Main::editSaveImage(int item)
2430 if (currentMapEditor())
2431 currentMapEditor()->saveFloatImage(item);
2434 void Main::editFollowXLink(int item)
2436 if (currentMapEditor())
2437 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2440 void Main::editEditXLink(int item)
2442 if (currentMapEditor())
2443 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2446 void Main::formatSelectColor()
2448 if (currentMapEditor())
2450 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2451 if ( !col.isValid() ) return;
2452 currentMapEditor()->setColor( col );
2453 colorChanged( col );
2457 void Main::formatPickColor()
2459 if (currentMapEditor())
2460 colorChanged( currentMapEditor()->pickColor() );
2463 void Main::colorChanged(QColor c)
2465 QPixmap pix( 16, 16 );
2467 actionFormatColor->setIconSet( pix );
2470 void Main::formatColorItem()
2472 if (currentMapEditor())
2473 currentMapEditor()->colorItem();
2476 void Main::formatColorBranch()
2478 if (currentMapEditor())
2479 currentMapEditor()->colorBranch();
2482 void Main::formatLinkStyleLine()
2484 if (currentMapEditor())
2485 currentMapEditor()->setLinkStyle(StyleLine);
2488 void Main::formatLinkStyleParabel()
2490 if (currentMapEditor())
2491 currentMapEditor()->setLinkStyle(StyleParabel);
2494 void Main::formatLinkStylePolyLine()
2496 if (currentMapEditor())
2497 currentMapEditor()->setLinkStyle(StylePolyLine);
2500 void Main::formatLinkStylePolyParabel()
2502 if (currentMapEditor())
2503 currentMapEditor()->setLinkStyle(StylePolyParabel);
2506 void Main::formatSelectBackColor()
2508 if (currentMapEditor())
2509 currentMapEditor()->selectBackgroundColor();
2512 void Main::formatSelectLinkColor()
2514 if (currentMapEditor())
2515 currentMapEditor()->selectLinkColor();
2518 void Main::formatToggleLinkColorHint()
2520 currentMapEditor()->toggleLinkColorHint();
2523 void Main::formatFrameNone()
2525 if (currentMapEditor())
2526 currentMapEditor()->setFrame(NoFrame);
2529 void Main::formatFrameRectangle()
2531 if (currentMapEditor())
2532 currentMapEditor()->setFrame(Rectangle);
2535 void Main::formatIncludeImagesVer()
2537 if (currentMapEditor())
2538 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2541 void Main::formatIncludeImagesHor()
2543 if (currentMapEditor())
2544 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2547 void Main::formatHideLinkUnselected()
2549 if (currentMapEditor())
2550 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2553 void Main::viewZoomReset()
2555 if (currentMapEditor())
2559 currentMapEditor()->setWorldMatrix( m );
2560 currentMapEditor()->setViewCenter();
2561 currentMapEditor()->adjustCanvasSize();
2565 void Main::viewZoomIn()
2567 if (currentMapEditor())
2569 QWMatrix m = currentMapEditor()->worldMatrix();
2570 m.scale( 1.25, 1.25 );
2571 currentMapEditor()->setWorldMatrix( m );
2572 currentMapEditor()->setViewCenter();
2573 currentMapEditor()->adjustCanvasSize();
2577 void Main::viewZoomOut()
2579 if (currentMapEditor())
2581 QWMatrix m = currentMapEditor()->worldMatrix();
2582 m.scale( 0.8, 0.8 );
2583 currentMapEditor()->setWorldMatrix( m );
2584 currentMapEditor()->setViewCenter();
2585 currentMapEditor()->adjustCanvasSize();
2589 void Main::modModeColor()
2593 void Main::modModeLink()
2597 bool Main::settingsPDF()
2599 // Default browser is set in constructor
2601 QString text = QInputDialog::getText(
2602 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2603 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2605 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2610 bool Main::settingsURL()
2612 // Default browser is set in constructor
2614 QString text = QInputDialog::getText(
2615 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2616 settings.readEntry("/vym/mainwindow/readerURL")
2619 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2623 void Main::windowToggleNoteEditor()
2625 if (textEditor->showWithMain() )
2626 windowHideNoteEditor();
2628 windowShowNoteEditor();
2631 void Main::updateNoteFlag()
2633 if (currentMapEditor())
2634 currentMapEditor()->updateNoteFlag();
2637 void Main::windowShowNoteEditor()
2639 textEditor->setShowWithMain(true);
2641 actionViewToggleNoteEditor->setOn (true);
2644 void Main::windowHideNoteEditor()
2646 textEditor->setShowWithMain(false);
2648 actionViewToggleNoteEditor->setOn (false);
2651 void Main::windowNextEditor()
2653 if (tabWidget->currentPageIndex() < tabWidget->count())
2654 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2657 void Main::windowPreviousEditor()
2659 if (tabWidget->currentPageIndex() >0)
2660 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2663 void Main::standardFlagChanged()
2665 currentMapEditor()->toggleStandardFlag(sender()->name());
2668 void Main::testFunction()
2670 currentMapEditor()->testFunction();
2673 void Main::helpDoc()
2676 #if defined(Q_OS_MACX)
2677 docpath="./vym.app/Contents/vym.pdf";
2679 // default path in SUSE LINUX
2680 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2683 if (!QFile (docpath).exists() )
2685 // relative path for easy testing in tarball
2686 docpath="doc/vym.pdf";
2687 if (!QFile (docpath).exists() )
2689 // relative path for testing while still writing vym.tex
2690 docpath="doc/tex/vym.pdf";
2691 if (!QFile (docpath).exists() )
2693 // Try yet another one for Knoppix
2694 docpath="/usr/share/doc/packages/vym/vym.pdf";
2695 if (!QFile (docpath).exists() )
2697 QMessageBox::critical(0,
2698 tr("Critcal error"),
2699 tr("Couldn't find the documentation\n"
2700 "vym.pdf in various places."));
2707 Process *pdfProc = new Process();
2708 pdfProc->clearArguments();
2709 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2710 pdfProc->addArgument( docpath);
2712 if ( !pdfProc->start() )
2715 QMessageBox::warning(0,
2717 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
2718 tr("Please use Settings->")+tr("Set application to open PDF files"));
2725 void Main::helpAbout()
2728 ad.setName ("aboutwindow");
2729 ad.setMinimumSize(500,500);
2730 ad.resize (QSize (500,500));
2734 void Main::helpAboutQT()
2736 QMessageBox::aboutQt( this, "Qt Application Example" );