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")+" "+tr("Firefox Bookmarks" ), QPixmap(), tr("Firefox Bookmarks"), 0, this, "importFirefoxBookmarks" );
361 connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
362 a->addTo (importMenu);
364 a = new QAction( tr( "Import")+" Mind Manager" , QPixmap(), "Mind Manager...", 0, this, "importMM" );
365 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
366 a->addTo (importMenu);
368 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
369 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
370 a->addTo( importMenu);
372 exportMenu = new QPopupMenu (this);
373 menu->insertItem (tr("Export"),exportMenu );
375 menu->insertSeparator();
378 a = new QAction( tr( "Print" ), QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" );
379 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
384 a = new QAction( tr( "Close Map" ), QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
385 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
388 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
389 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
395 void Main::setupEditActions()
397 QToolBar *tb = new QToolBar( this );
398 tb->setLabel( "Edit Actions" );
399 QPopupMenu *menu = new QPopupMenu( this );
400 menuBar()->insertItem( tr( "&Edit" ), menu );
404 a = new QAction( tr( "Undo" ), QPixmap( iconPath+"undo.png"), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
405 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
406 a->setEnabled (false);
411 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
413 a = new QAction( tr( "Redo" ), QPixmap( iconPath+"redo.png"), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
414 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
419 menu->insertSeparator();
420 a = new QAction( tr( "Copy" ), QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
421 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
422 a->setEnabled (false);
426 a = new QAction( tr( "Cut" ), QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
427 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
428 a->setEnabled (false);
432 a = new QAction( tr( "Paste" ), QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
433 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
434 a->setEnabled (false);
439 a = new QAction( tr( "Move branch up" ), QPixmap(iconPath+"up.png" ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
440 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
441 a->setEnabled (false);
446 a = new QAction( tr( "Move branch down" ), QPixmap( iconPath+"down.png"), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
447 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
448 a->setEnabled (false);
451 actionEditMoveDown=a;
454 a = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
455 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
456 alt = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_S, this, "scroll" );
457 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
458 #if defined(Q_OS_MACX)
459 actionEditToggleScroll=alt;
461 actionEditToggleScroll=a;
463 actionEditToggleScroll->setEnabled (false);
464 actionEditToggleScroll->setToggleAction(true);
465 actionEditToggleScroll->addTo( tb );
466 actionEditToggleScroll->addTo( menu );
467 actionListBranches.append(actionEditToggleScroll);
469 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
470 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
473 menu->insertSeparator();
475 a = new QAction( tr( "Find" ), QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
476 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
479 menu->insertSeparator();
481 a = new QAction( tr( "Open URL" ), QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), CTRL + Key_U, this, "url" );
482 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
484 a->setEnabled (false);
487 a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), CTRL + Key_U, this, "urltab" );
488 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
489 a->setEnabled (false);
490 actionEditOpenURLTab=a;
492 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
493 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
494 a->setEnabled (false);
495 actionListBranches.append(a);
498 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
499 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
500 a->setEnabled (false);
501 actionListBranches.append(a);
502 actionEditHeading2URL=a;
504 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
505 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
506 a->setEnabled (false);
507 actionListBranches.append(a);
508 actionEditBugzilla2URL=a;
510 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
511 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
512 a->setEnabled (false);
513 actionListBranches.append(a);
514 actionEditFATE2URL=a;
516 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" );
517 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
519 a->setEnabled (false);
520 actionEditOpenVymLink=a;
522 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
523 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
524 a->setEnabled (false);
525 actionListBranches.append(a);
528 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
529 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
530 a->setEnabled (false);
531 actionEditDeleteVymLink=a;
533 a = new QAction( tr( "Hide object in exports" ), QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), Key_H, this, "hideExport" );
534 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
535 a->setToggleAction(true);
537 a->setEnabled (false);
538 actionEditToggleHideExport=a;
540 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
541 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
542 a->setEnabled (true);
545 menu->insertSeparator();
547 // Shortcuts to modify heading:
548 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
549 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
550 actionListBranches.append(a);
551 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
552 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
553 actionListBranches.append(a);
555 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
556 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
557 a->setEnabled (false);
559 actionListBranches.append(a);
561 // Shortcut to delete selection
562 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
563 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
564 a->setEnabled (false);
567 // Shortcut to add branch
568 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
569 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
570 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
571 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
572 a->setEnabled (false);
573 actionListBranches.append(a);
574 #if defined (Q_OS_MACX)
575 // In OSX show different shortcut in menues, the keys work independtly always
576 actionEditAddBranch=alt;
578 actionEditAddBranch=a;
581 // Add branch by inserting it at selection
582 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
583 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
584 a->setEnabled (false);
585 actionListBranches.append(a);
586 actionEditAddBranchHere=a;
587 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
588 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
589 actionListBranches.append(a);
592 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
593 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
594 a->setEnabled (false);
595 actionListBranches.append(a);
596 actionEditAddBranchAbove=a;
597 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
598 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
599 actionListBranches.append(a);
602 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
603 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
604 a->setEnabled (false);
605 actionListBranches.append(a);
606 actionEditAddBranchBelow=a;
607 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
608 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
609 actionListBranches.append(a);
611 // Import at selection (adding to selection)
612 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
613 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
614 a->setEnabled (false);
615 actionListBranches.append(a);
616 actionEditImportAdd=a;
618 // Import at selection (replacing selection)
619 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
620 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
621 a->setEnabled (false);
622 actionListBranches.append(a);
623 actionEditImportReplace=a;
626 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
627 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
628 a->setEnabled (false);
629 actionListBranches.append(a);
630 actionEditSaveBranch=a;
632 // Only remove branch, not its childs
633 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
634 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
635 a->setEnabled (false);
636 actionListBranches.append(a);
637 actionEditRemoveBranchKeepChilds=a;
639 // Only remove childs of a branch
640 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
641 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
642 a->setEnabled (false);
643 actionListBranches.append(a);
644 actionEditRemoveChilds=a;
646 // Shortcuts for navigating with cursor:
647 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
648 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
649 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
650 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
651 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
652 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
653 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
654 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
655 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
656 a->setEnabled (false);
658 actionListBranches.append(a);
659 actionEditSelectFirst=a;
660 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
661 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
662 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
663 a->setEnabled (false);
665 actionListBranches.append(a);
666 actionEditSelectLast=a;
668 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
669 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
670 actionEditLoadImage=a;
675 void Main::setupFormatActions()
677 QPopupMenu *menu = new QPopupMenu( this );
678 menuBar()->insertItem( tr( "F&ormat" ), menu );
680 QToolBar *tb = new QToolBar( this );
684 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
685 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
686 actionFormatColor->addTo( tb );
687 actionFormatColor->addTo( menu );
688 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" );
689 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
690 a->setEnabled (false);
693 actionListBranches.append(a);
694 actionFormatPickColor=a;
695 a= new QAction( tr( "Color branch" ), QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
696 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
697 a->setEnabled (false);
700 actionListBranches.append(a);
701 actionFormatColorBranch=a;
702 a= new QAction( tr( "Color Subtree" ), QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
703 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
704 a->setEnabled (false);
707 actionListBranches.append(a);
708 actionFormatColorSubtree=a;
710 menu->insertSeparator();
711 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
712 actionGroupFormatLinkStyles->setExclusive (true);
713 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
714 a->setToggleAction(true);
715 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
716 actionFormatLinkStyleLine=a;
717 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
718 a->setToggleAction(true);
719 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
720 actionFormatLinkStyleParabel=a;
721 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
722 a->setToggleAction(true);
723 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
724 actionFormatLinkStylePolyLine=a;
725 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
726 a->setToggleAction(true);
727 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
728 actionFormatLinkStylePolyParabel=a;
729 actionGroupFormatLinkStyles->addTo (menu);
731 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
732 actionGroupFormatFrameTypes->setExclusive (true);
733 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
734 a->setToggleAction(true);
735 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
736 actionFormatFrameNone=a;
737 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
738 a->setToggleAction(true);
739 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
740 actionFormatFrameRectangle=a;
742 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
743 a->setToggleAction(true);
744 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
745 actionFormatIncludeImagesVer=a;
747 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
748 a->setToggleAction(true);
749 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
750 actionFormatIncludeImagesHor=a;
752 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
753 a->setToggleAction(true);
754 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
755 actionFormatHideLinkUnselected=a;
757 menu->insertSeparator();
758 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
759 a->setToggleAction(true);
760 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
762 actionFormatLinkColorHint=a;
764 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
765 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
766 actionFormatLinkColor->addTo( menu );
767 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
768 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
769 actionFormatBackColor->addTo( menu );
773 void Main::setupViewActions()
775 QToolBar *tb = new QToolBar( this );
776 tb->setLabel( "View Actions" );
777 QPopupMenu *menu = new QPopupMenu( this );
778 menuBar()->insertItem( tr( "&View" ), menu );
781 a = new QAction( tr( "Zoom reset" ), QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
782 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
785 a = new QAction( tr( "Zoom in" ), QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
786 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
789 a = new QAction( tr( "Zoom out" ), QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
790 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
795 a = new QAction( tr( "Show Note Editor" ), QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ), CTRL + Key_E , this, "noteEditor" );
796 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
797 a->setToggleAction(true);
798 if (textEditor->showWithMain())
804 actionViewToggleNoteEditor=a;
806 a = new QAction( tr( "Show history window" ), QPixmap(), tr( "Show history window" ), CTRL + Key_H , this, "historyWindow" );
807 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
808 a->setToggleAction(false);
810 actionViewToggleHistoryWindow=a;
812 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
813 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
815 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
816 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
821 void Main::setupModeActions()
823 //QPopupMenu *menu = new QPopupMenu( this );
824 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
826 QToolBar *tb = new QToolBar( this );
827 tb->setLabel( tr ("Modes when using modifiers") );
829 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
830 actionGroupModModes->setExclusive (true);
831 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(iconPath+"modecolor.png"), 0, Key_J, actionGroupModModes, "modModeColor" );
832 a->setToggleAction(true);
835 actionModModeColor=a;
837 a= new QAction( tr( "Use modifier to copy" ), QPixmap(iconPath+"modecopy.png"), 0, Key_K, actionGroupModModes, "modModeCopy" );
838 a->setToggleAction(true);
842 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(iconPath+"modelink.png"), 0, Key_L, actionGroupModModes, "modModeLink" );
843 a->setToggleAction(true);
849 void Main::setupFlagActions()
851 // Create System Flags
852 systemFlagsDefault = new FlagRowObj ();
853 systemFlagsDefault->setVisibility (false);
854 systemFlagsDefault->setName ("systemFlagsDef");
856 FlagObj *fo = new FlagObj ();
857 fo->load(QPixmap(flagsPath+"flag-note.png"));
859 fo->setToolTip(tr("Note","Systemflag"));
860 systemFlagsDefault->addFlag (fo); // makes deep copy
862 fo->load(QPixmap(flagsPath+"flag-url.png"));
864 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
865 systemFlagsDefault->addFlag (fo);
867 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
868 fo->setName("vymLink");
869 fo->setToolTip(tr("Link to another vym map","Systemflag"));
870 systemFlagsDefault->addFlag (fo);
872 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
873 fo->setName("scrolledright");
874 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
875 systemFlagsDefault->addFlag (fo);
877 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
878 fo->setName("tmpUnscrolledright");
879 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
880 systemFlagsDefault->addFlag (fo);
882 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
883 fo->setName("hideInExport");
884 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
885 systemFlagsDefault->addFlag (fo);
887 // Create Standard Flags
888 standardFlagsDefault = new FlagRowObj ();
889 standardFlagsDefault->setVisibility (false);
890 standardFlagsDefault->setName ("standardFlagsDef");
892 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
893 fo->setName ("exclamationmark");
894 fo->setGroup("standard-mark");
895 fo->setToolTip(tr("Take care!","Standardflag"));
896 standardFlagsDefault->addFlag (fo); // makes deep copy
898 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
899 fo->setName("questionmark");
900 fo->setGroup("standard-mark");
901 fo->setToolTip(tr("Really?","Standardflag"));
902 standardFlagsDefault->addFlag (fo);
904 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
905 fo->setName("hook-green");
906 fo->setGroup("standard-hook");
907 fo->setToolTip(tr("ok!","Standardflag"));
908 standardFlagsDefault->addFlag (fo);
910 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
911 fo->setName("cross-red");
912 fo->setGroup("standard-hook");
913 fo->setToolTip(tr("Not ok!","Standardflag"));
914 standardFlagsDefault->addFlag (fo);
916 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
917 fo->setName("stopsign");
918 fo->setToolTip(tr("This won't work!","Standardflag"));
919 standardFlagsDefault->addFlag (fo);
921 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
922 fo->setName("smiley-good");
923 fo->setGroup("standard-smiley");
924 fo->setToolTip(tr("Good","Standardflag"));
925 standardFlagsDefault->addFlag (fo);
927 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
928 fo->setName("smiley-sad");
929 fo->setGroup("standard-smiley");
930 fo->setToolTip(tr("Bad","Standardflag"));
931 standardFlagsDefault->addFlag (fo);
933 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
934 // Original omg.png (in KDE emoticons)
935 fo->setName("smiley-omg");
936 fo->setGroup("standard-smiley");
937 fo->setToolTip(tr("Oh no!","Standardflag"));
938 standardFlagsDefault->addFlag (fo);
940 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
941 fo->setName("clock");
942 fo->setToolTip(tr("Time critical","Standardflag"));
943 standardFlagsDefault->addFlag (fo);
945 fo->load(QPixmap(flagsPath+"flag-phone.png"));
946 fo->setName("phone");
947 fo->setToolTip(tr("Call...","Standardflag"));
948 standardFlagsDefault->addFlag (fo);
950 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
952 fo->setToolTip(tr("Idea!","Standardflag"));
953 standardFlagsDefault->addFlag (fo);
955 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
956 fo->setName("arrow-up");
957 fo->setGroup("standard-arrow");
958 fo->setToolTip(tr("Important","Standardflag"));
959 standardFlagsDefault->addFlag (fo);
961 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
962 fo->setName("arrow-down");
963 fo->setGroup("standard-arrow");
964 fo->setToolTip(tr("Unimportant","Standardflag"));
965 standardFlagsDefault->addFlag (fo);
967 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
968 fo->setName("2arrow-up");
969 fo->setGroup("standard-arrow");
970 fo->setToolTip(tr("Very important!","Standardflag"));
971 standardFlagsDefault->addFlag (fo);
973 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
974 fo->setName("2arrow-down");
975 fo->setGroup("standard-arrow");
976 fo->setToolTip(tr("Very unimportant!","Standardflag"));
977 standardFlagsDefault->addFlag (fo);
979 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
980 fo->setName("thumb-up");
981 fo->setGroup("standard-thumb");
982 fo->setToolTip(tr("I like this","Standardflag"));
983 standardFlagsDefault->addFlag (fo);
985 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
986 fo->setName("thumb-down");
987 fo->setGroup("standard-thumb");
988 fo->setToolTip(tr("I like this","Standardflag"));
989 fo->setToolTip(tr("I do not like this","Standardflag"));
990 standardFlagsDefault->addFlag (fo);
992 fo->load(QPixmap(flagsPath+"flag-rose.png"));
994 fo->setToolTip(tr("Rose","Standardflag"));
995 standardFlagsDefault->addFlag (fo);
997 fo->load(QPixmap(flagsPath+"flag-heart.png"));
998 fo->setName("heart");
999 fo->setToolTip(tr("I just love... ","Standardflag"));
1000 standardFlagsDefault->addFlag (fo);
1002 fo->load(QPixmap(flagsPath+"flag-present.png"));
1003 fo->setName("present");
1004 fo->setToolTip(tr("Surprise!","Standardflag"));
1005 standardFlagsDefault->addFlag (fo);
1007 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1008 fo->setName("flash");
1009 fo->setToolTip(tr("Dangerous","Standardflag"));
1010 standardFlagsDefault->addFlag (fo);
1012 fo->load(QPixmap(flagsPath+"flag-info.png"));
1013 // Original: xsldbg_output.png
1014 fo->setName("info");
1015 fo->setToolTip(tr("Info","Standardflag"));
1016 standardFlagsDefault->addFlag (fo);
1018 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1019 // Original khelpcenter.png
1020 fo->setName("lifebelt");
1021 fo->setToolTip(tr("This will help","Standardflag"));
1022 standardFlagsDefault->addFlag (fo);
1026 standardFlagsDefault->makeToolbar(this, "Standard Flags");
1030 void Main::setupSettingsActions()
1032 QPopupMenu *menu = new QPopupMenu( this );
1033 menuBar()->insertItem( tr( "&Settings" ), menu );
1038 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1039 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1042 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1043 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1046 menu->insertSeparator();
1047 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1048 a->setToggleAction(true);
1049 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1051 actionSettingsAutoedit=a;
1053 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1054 a->setToggleAction(true);
1055 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1057 actionSettingsAutoselectHeading=a;
1059 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1060 a->setToggleAction(true);
1061 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1063 actionSettingsAutoselectText=a;
1065 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1066 a->setToggleAction(true);
1067 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1069 actionSettingsPasteNewHeading=a;
1071 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1072 a->setToggleAction(true);
1073 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1075 actionSettingsUseDelKey=a;
1077 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1078 a->setToggleAction(true);
1079 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1081 actionSettingsUseFlagGroups=a;
1083 a= new QAction( tr( "Use hide flag during exports " ), QPixmap(), tr( "Use hide flags" ), 0, this, "hideexport" );
1084 a->setToggleAction(true);
1085 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1087 actionSettingsUseHideExport=a;
1091 void Main::setupTestActions()
1093 QPopupMenu *menu = new QPopupMenu( this );
1094 menuBar()->insertItem( tr( "&Test" ), menu );
1097 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1098 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1103 void Main::setupHelpActions()
1105 QPopupMenu *menu = new QPopupMenu( this );
1106 menuBar()->insertItem( tr( "&Help" ), menu );
1109 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1110 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1113 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1114 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1117 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1118 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1123 void Main::setupContextMenus()
1127 // Context Menu for branch or mapcenter
1128 branchContextMenu =new QPopupMenu (this);
1131 branchAddContextMenu =new QPopupMenu (this);
1132 actionEditPaste->addTo ( branchAddContextMenu );
1133 actionEditAddBranch->addTo ( branchAddContextMenu );
1134 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1135 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1136 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1137 branchAddContextMenu->insertSeparator();
1138 actionEditLoadImage->addTo( branchAddContextMenu );
1139 branchAddContextMenu->insertSeparator();
1140 actionEditImportAdd->addTo ( branchAddContextMenu );
1141 actionEditImportReplace->addTo ( branchAddContextMenu );
1144 branchRemoveContextMenu =new QPopupMenu (this);
1145 actionEditCut->addTo ( branchRemoveContextMenu );
1146 actionEditDelete->addTo ( branchRemoveContextMenu );
1147 actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu );
1148 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1150 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1151 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1153 actionEditSaveBranch->addTo( branchContextMenu );
1155 branchContextMenu->insertSeparator();
1156 actionEditOpenURL->addTo ( branchContextMenu );
1157 actionEditOpenURLTab->addTo ( branchContextMenu );
1158 actionEditURL->addTo ( branchContextMenu );
1159 actionEditHeading2URL->addTo ( branchContextMenu );
1160 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1162 actionEditBugzilla2URL->addTo( branchContextMenu );
1163 actionEditFATE2URL->addTo( branchContextMenu );
1165 branchContextMenu->insertSeparator();
1166 actionEditOpenVymLink->addTo ( branchContextMenu );
1167 actionEditVymLink->addTo ( branchContextMenu );
1168 actionEditDeleteVymLink->addTo ( branchContextMenu );
1170 branchContextMenu->insertSeparator();
1171 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1173 branchContextMenu->insertSeparator();
1174 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1175 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1176 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1178 // Context Menu for links in a branch menu
1179 // This will be populated "on demand" in MapEditor::updateActions
1180 branchContextMenu->insertSeparator();
1181 branchLinksContextMenu =new QPopupMenu (this);
1182 branchLinksContextMenuDup =new QPopupMenu (this);
1183 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1184 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1186 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1187 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1189 // Context menu for floatimage
1190 floatimageContextMenu =new QPopupMenu (this);
1191 saveImageFormatMenu=new QPopupMenu (this);
1192 exportImageFormatMenu=new QPopupMenu (this);
1194 QStrList fmt = QImage::outputFormats();
1195 for (const char* f = fmt.first(); f; f = fmt.next())
1197 saveImageFormatMenu->insertItem( f );
1198 exportImageFormatMenu->insertItem( f );
1200 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1201 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1202 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1204 floatimageContextMenu->insertSeparator();
1205 actionEditCopy->addTo( floatimageContextMenu );
1206 actionEditCut->addTo( floatimageContextMenu );
1208 /* FIXME not needed any longer
1209 floatimageContextMenu->insertSeparator();
1210 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1211 a->setToggleAction(true);
1212 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1213 a->addTo( floatimageContextMenu);
1214 actionEditToggleFloatExport=a;
1217 floatimageContextMenu->insertSeparator();
1218 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1220 exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1222 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1223 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1224 a->addTo (exportMenu);
1226 a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" );
1227 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1228 a->addTo( exportMenu );
1230 a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" );
1231 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1232 a->addTo( exportMenu );
1234 a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
1235 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1236 a->addTo (exportMenu);
1238 a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
1239 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1240 a->addTo( exportMenu );
1242 a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1243 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1244 a->addTo( exportMenu );
1246 a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" );
1247 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1248 a->addTo( exportMenu );
1250 // Context menu for canvas
1251 canvasContextMenu =new QPopupMenu (this);
1252 actionEditMapInfo->addTo( canvasContextMenu );
1253 canvasContextMenu->insertSeparator();
1254 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1255 canvasContextMenu->insertSeparator();
1256 actionFormatLinkColorHint->addTo( canvasContextMenu );
1257 actionFormatLinkColor->addTo( canvasContextMenu );
1258 actionFormatBackColor->addTo( canvasContextMenu );
1260 // Menu for last opened files
1261 // Read settings initially
1263 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1264 for (int i=1;i<=j;i++)
1266 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1267 if (!s.isEmpty() && j<=maxLastMaps)
1270 setupLastMapsMenu();
1271 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1274 void Main::setupLastMapsMenu()
1276 // Remove double entries
1277 QStringList::Iterator it=lastMaps.begin();
1278 QStringList::Iterator jt;
1279 while (it!=lastMaps.end() )
1283 while (jt!=lastMaps.end() )
1286 jt=lastMaps.remove(jt);
1293 // Limit length of list to maxLastMaps
1294 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1296 // build Menu from lastMaps string list
1297 lastMapsMenu->clear();
1298 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1299 lastMapsMenu->insertItem (*it );
1303 void Main::hideEvent (QHideEvent * )
1305 if (!textEditor->isMinimized() ) textEditor->hide();
1308 void Main::showEvent (QShowEvent * )
1310 if (textEditor->showWithMain()) textEditor->showNormal();
1313 bool Main::reallyWriteDirectory(const QString &dir)
1315 QStringList eList = QDir(dir).entryList();
1316 if (eList.first() ==".") eList.pop_front(); // remove "."
1317 if (eList.first() =="..") eList.pop_front(); // remove "."
1318 if (!eList.isEmpty())
1320 QMessageBox mb( __VYM,
1321 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1322 QMessageBox::Warning,
1324 QMessageBox::Cancel | QMessageBox::Default,
1325 QMessageBox::QMessageBox::NoButton );
1327 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1328 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1331 case QMessageBox::Yes:
1334 case QMessageBox::Cancel:
1342 QString Main::browseDirectory (const QString &caption)
1344 QFileDialog fd(this,caption);
1345 fd.setMode (QFileDialog::DirectoryOnly);
1346 fd.setCaption(__VYM " - "+caption);
1349 if ( fd.exec() == QDialog::Accepted )
1350 return fd.selectedFile();
1355 MapEditor* Main::currentMapEditor() const
1357 if ( tabWidget->currentPage() &&
1358 tabWidget->currentPage()->inherits( "MapEditor" ) )
1359 return (MapEditor*)tabWidget->currentPage();
1363 //TODO not used now, maybe use this for overview window later
1364 void Main::newView()
1366 // Open a new view... have it delete when closed.
1367 Main *m = new Main(0, 0, WDestructiveClose);
1368 qApp->setMainWidget(m);
1370 qApp->setMainWidget(0);
1373 void Main::editorChanged(QWidget *)
1375 // Unselect all possibly selected objects
1376 // (Important to update note editor)
1379 for (i=0;i<=tabWidget->count() -1;i++)
1382 me=(MapEditor*)tabWidget->page(i);
1385 currentMapEditor()->reselect();
1387 // Update actions to in menus and toolbars according to editor
1388 currentMapEditor()->updateActions();
1391 void Main::fileNew()
1393 QString fn="unnamed";
1394 MapEditor* medit = new MapEditor (tabWidget, true);
1395 tabWidget->addTab (medit,fn);
1396 tabWidget->showPage(medit);
1397 medit->viewport()->setFocus();
1398 // For the very first map we do not have flagrows yet...
1399 medit->select("mc:");
1402 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1404 ErrorCode err=success;
1406 // fn is usually the archive, mapfile the file after uncompressing
1409 // Make fn absolute (needed for unzip)
1410 fn=QDir (fn).absPath();
1416 // Check, if map is already loaded
1418 while (i<=tabWidget->count() -1)
1420 me=(MapEditor*)tabWidget->page(i);
1421 if (me->getFilePath() == fn)
1423 // Already there, ask for confirmation
1424 QMessageBox mb( __VYM,
1425 tr("The map %1\nis already opened."
1426 "Opening the same map in multiple editors may lead \n"
1427 "to confusion when finishing working with vym."
1428 "Do you want to").arg(fn),
1429 QMessageBox::Warning,
1430 QMessageBox::Yes | QMessageBox::Default,
1431 QMessageBox::Cancel | QMessageBox::Escape,
1432 QMessageBox::QMessageBox::NoButton);
1433 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1434 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1437 case QMessageBox::Yes:
1439 i=tabWidget->count();
1441 case QMessageBox::Cancel:
1453 if ( !fn.isEmpty() )
1455 me = currentMapEditor();
1456 int tabIndex=tabWidget->currentPageIndex();
1457 // Check first, if mapeditor exists
1458 // If it is not default AND we want a new map,
1459 // create a new mapeditor in a new tab
1460 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1462 me = new MapEditor (tabWidget,true);
1463 tabWidget->addTab (me,fn);
1464 tabIndex=tabWidget->indexOf (me);
1465 tabWidget->setCurrentPage (tabIndex);
1468 // Check, if file exists (important for creating new files
1469 // from command line
1470 if (!QFile(fn).exists() )
1472 QMessageBox mb( __VYM,
1473 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1474 QMessageBox::Question,
1476 QMessageBox::Cancel | QMessageBox::Default,
1477 QMessageBox::QMessageBox::NoButton );
1479 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1480 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1483 case QMessageBox::Yes:
1485 currentMapEditor()->setFilePath(fn);
1486 tabWidget->setTabLabel (currentMapEditor(),
1487 currentMapEditor()->getFileName() );
1488 statusBar()->message( "Created " + fn , statusbarTime );
1491 case QMessageBox::Cancel:
1492 // don't create new map
1493 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1500 //tabWidget->currentPage() won't be NULL here, because of above...
1501 tabWidget->showPage(me);
1502 me->viewport()->setFocus();
1504 // Create temporary directory for packing
1505 char tmpdir1[]="/tmp/vym-XXXXXX";
1506 QString tmpMapDir=mkdtemp(tmpdir1);
1508 // Try to unzip file
1509 err=unzipDir (tmpMapDir,fn);
1513 me->setZipped(false);
1516 me->setZipped(true);
1518 // Look for mapname.xml
1519 mapfile= fn.left(fn.findRev(".",-1,true));
1520 mapfile=mapfile.section( '/', -1 );
1521 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1522 if (!file.exists() )
1524 // mapname.xml does not exist, well,
1525 // maybe some renamed the mapname.vym file...
1526 // Try to find any .xml in the toplevel
1527 // directory of the .vym file
1528 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1529 if (flist.count()==1)
1531 // Only one entry, take this one
1532 mapfile=tmpMapDir + "/"+flist.first();
1535 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1536 *it=tmpMapDir + "/" + *it;
1537 // TODO Multiple entries, load all (but only the first one into this ME)
1538 //mainWindow->fileLoadFromTmp (flist);
1539 //returnCode=1; // Silently forget this attempt to load
1540 qWarning ("MainWindow::load (fn) multimap found...");
1543 if (flist.isEmpty() )
1545 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1546 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1549 } //file doesn't exist
1551 mapfile=file.name();
1556 // Save existing filename in case we import
1557 QString fn_org=me->getFilePath();
1559 // Finally load map into mapEditor
1560 me->setFilePath (mapfile,fn);
1561 err=me->load(mapfile,lmode);
1563 // Restore old (maybe empty) filepath, if this is an import
1565 me->setFilePath (fn_org);
1568 // Finally check for errors and go home
1571 if (lmode==NewMap) fileCloseMap();
1572 statusBar()->message( "Could not load " + fn, statusbarTime );
1577 me->setFilePath (fn);
1578 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1579 if (fn.left(9)!="/tmp/vym-")
1581 // Only append to lastMaps if not loaded from a tmpDir
1582 // e.g. imported bookmarks are in a tmpDir
1583 lastMaps.prepend(me->getFilePath() );
1584 setupLastMapsMenu();
1586 actionFilePrint->setEnabled (true);
1588 statusBar()->message( "Loaded " + fn, statusbarTime );
1592 removeDir (QDir(tmpMapDir));
1598 void Main::fileLoad(const LoadMode &lmode)
1600 QFileDialog *fd=new QFileDialog( this);
1601 if (!lastFileDir.isEmpty())
1602 fd->setDir (lastFileDir);
1603 fd->setMode (QFileDialog::ExistingFiles);
1604 fd->addFilter ("XML (*.xml)");
1605 fd->addFilter ("VYM map (*.vym *.vyp)");
1609 fd->setCaption(tr("Load vym map"));
1612 fd->setCaption(tr("Import: Add vym map to selection"));
1615 fd->setCaption(tr("Import: Replace selection with vym map"));
1621 if ( fd->exec() == QDialog::Accepted )
1623 lastFileDir=fd->dirPath();
1624 QStringList flist = fd->selectedFiles();
1625 QStringList::Iterator it = flist.begin();
1626 while( it != flist.end() )
1629 fileLoad(*it, lmode);
1636 void Main::fileLoad()
1641 void Main::fileLoadLast(int i)
1643 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1646 void Main::fileSave(const SaveMode &savemode)
1648 // tmp dir for zipping
1652 ErrorCode err=success;
1654 QString safeFilePath;
1656 bool saveZipped=currentMapEditor()->saveZipped();
1658 MapEditor * me=currentMapEditor();
1661 QString fn=me->getFilePath();
1662 // filename=unnamed, filepath="" in constructor...
1663 if ( !fn.isEmpty() )
1665 // We have a filepath, go on saving
1666 // First remove existing file, we
1667 // don't want to add to old zip archives
1671 QMessageBox::warning( 0, tr( "Save Error" ),
1672 fn+ tr("\ncould not be removed before saving"));
1674 // Look, if we should zip the data:
1677 QMessageBox mb( __VYM,
1678 tr("The map %1\ndid not use the compressed "
1679 "vym file format.\nWriting it uncompressed will also write images \n"
1680 "and flags and thus may overwrite files in the "
1681 "given directory\n\nDo you want to write the map").arg(fn),
1682 QMessageBox::Warning,
1683 QMessageBox::Yes | QMessageBox::Default,
1685 QMessageBox::Cancel | QMessageBox::Escape);
1686 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1687 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1688 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1691 case QMessageBox::Yes:
1692 // save compressed (default file format)
1695 case QMessageBox::No:
1696 // save uncompressed
1699 case QMessageBox::Cancel:
1708 char tmpdir1[]="/tmp/vym-XXXXXX";
1709 tmpMapDir=mkdtemp(tmpdir1);
1711 safeFilePath=me->getFilePath();
1712 me->setFilePath (tmpMapDir+"/"+
1713 me->getMapName()+ ".xml",
1715 me->save (savemode);
1716 me->setFilePath (safeFilePath);
1718 zipDir (tmpMapDir,fn);
1723 safeFilePath=me->getFilePath();
1724 me->setFilePath (fn, safeFilePath);
1725 me->save (savemode);
1726 me->setFilePath (safeFilePath);
1728 } // filepath available
1731 // We have no filepath yet,
1732 // call fileSaveAs() now, this will call fileSave()
1734 fileSaveAs(savemode);
1738 if (saveZipped && !tmpMapDir.isEmpty())
1740 removeDir (QDir(tmpMapDir));
1744 statusBar()->message(
1745 tr("Saved %1").arg(me->getFilePath()),
1747 lastMaps.prepend(me->getFilePath() );
1748 setupLastMapsMenu();
1750 statusBar()->message(
1751 tr("Couldn't save ").arg(me->getFilePath()),
1755 void Main::fileSave()
1757 fileSave (CompleteMap);
1760 void Main::fileSaveAs(const SaveMode& savemode)
1764 if (currentMapEditor())
1766 if (savemode==CompleteMap)
1767 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1769 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1770 if ( !fn.isEmpty() )
1772 // Check for existing file
1773 if (QFile (fn).exists())
1775 QMessageBox mb( __VYM,
1776 tr("The file %1\nexists already. Do you want to").arg(fn),
1777 QMessageBox::Warning,
1778 QMessageBox::Yes | QMessageBox::Default,
1779 QMessageBox::Cancel | QMessageBox::Escape,
1780 QMessageBox::QMessageBox::NoButton);
1781 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1782 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1785 case QMessageBox::Yes:
1788 case QMessageBox::Cancel:
1795 // New file, add extension to filename, if missing
1796 // This is always .vym or .vyp, depending on savemode
1797 if (savemode==CompleteMap)
1799 if (!fn.contains (".vym") && !fn.contains (".xml"))
1803 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1812 currentMapEditor()->setFilePath(fn);
1816 if (savemode==CompleteMap)
1817 tabWidget->setTabLabel (currentMapEditor(),
1818 currentMapEditor()->getFileName() );
1824 void Main::fileSaveAs()
1826 fileSaveAs (CompleteMap);
1829 void Main::fileImportKDEBookmarks()
1831 ImportKDEBookmarks im;
1833 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1834 currentMapEditor()->setFilePath ("");
1837 void Main::fileImportFirefoxBookmarks()
1839 ImportFirefoxBookmarks im;
1841 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1842 currentMapEditor()->setFilePath ("");
1845 void Main::fileImportMM()
1849 QFileDialog *fd=new QFileDialog( this);
1850 if (!lastFileDir.isEmpty())
1851 fd->setDir (lastFileDir);
1852 fd->setMode (QFileDialog::ExistingFiles);
1853 fd->addFilter ("Mind Manager (*.mmap)");
1854 fd->setCaption(tr("Import")+" "+"Mind Manager");
1857 if ( fd->exec() == QDialog::Accepted )
1859 lastFileDir=fd->dirPath();
1860 QStringList flist = fd->selectedFiles();
1861 QStringList::Iterator it = flist.begin();
1862 while( it != flist.end() )
1865 if (im.transform() &&
1866 success==fileLoad (im.getTransformedFile(),NewMap) &&
1867 currentMapEditor() )
1868 currentMapEditor()->setFilePath ("");
1877 void Main::fileImportDir()
1879 if (currentMapEditor())
1880 currentMapEditor()->importDir();
1883 void Main::fileExportXML()
1885 if (currentMapEditor())
1887 QString dir=browseDirectory(tr("Export XML to directory"));
1888 if (dir !="" && reallyWriteDirectory(dir) )
1889 currentMapEditor()->exportXML(dir);
1894 void Main::fileExportXHTML()
1896 MapEditor *me=currentMapEditor();
1900 ExportXHTMLDialog dia(this);
1901 dia.setFilePath (me->getFilePath() );
1902 dia.setMapName (me->getMapName() );
1905 if (dia.exec()==QDialog::Accepted)
1907 QString dir=dia.getDir();
1908 // Check, if warnings should be used before overwriting
1909 // the output directory
1912 ok=reallyWriteDirectory(dir);
1918 me->exportXML (dia.getDir() );
1919 dia.doExport(me->getMapName() );
1920 if (dia.hasChanged())
1927 void Main::fileExportImage(int item)
1929 MapEditor *me=currentMapEditor();
1932 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1934 if ( !fn.isEmpty() )
1935 me->exportImage(fn,item);
1937 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1942 void Main::fileExportASCII()
1944 MapEditor *me=currentMapEditor();
1948 ex.setMapCenter(me->getMapCenter());
1949 ex.addFilter ("TXT (*.txt)");
1950 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1951 if (ex.execDialog() )
1953 me->setExportMode(true);
1955 me->setExportMode(false);
1960 void Main::fileExportLaTeX()
1962 MapEditor *me=currentMapEditor();
1966 ex.setMapCenter(me->getMapCenter());
1967 ex.addFilter ("Tex (*.tex)");
1968 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1969 if (ex.execDialog() )
1971 me->setExportMode(true);
1973 me->setExportMode(false);
1978 void Main::fileExportKDEBookmarks()
1980 ExportKDEBookmarks ex;
1981 MapEditor *me=currentMapEditor();
1984 ex.setMapCenter (me->getMapCenter() );
1989 void Main::fileExportTaskjuggler()
1991 ExportTaskjuggler ex;
1992 MapEditor *me=currentMapEditor();
1995 ex.setMapCenter (me->getMapCenter() );
1996 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
1997 ex.addFilter ("Taskjuggler (*.tjp)");
1998 if (ex.execDialog() )
2000 me->setExportMode(true);
2002 me->setExportMode(false);
2007 void Main::fileExportOOPresentation()
2009 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2010 // FIXME add extra info in dialog
2011 //ImagePreview *p =new ImagePreview (fd);
2012 //fd->setContentsPreviewEnabled( TRUE );
2013 //fd->setContentsPreview( p, p );
2014 //fd->setPreviewMode( QFileDialog::Contents );
2015 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2016 //fd->setDir (lastImageDir);
2019 if ( fd->exec() == QDialog::Accepted )
2021 QString fn=fd->selectedFile();
2022 //lastImageDir=fn.left(fn.findRev ("/"));
2023 if (currentMapEditor())
2024 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2028 void Main::fileCloseMap()
2030 if (currentMapEditor())
2032 if (currentMapEditor()->hasChanged())
2034 QMessageBox mb( __VYM,
2035 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2036 QMessageBox::Warning,
2037 QMessageBox::Yes | QMessageBox::Default,
2039 QMessageBox::Cancel | QMessageBox::Escape );
2040 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2041 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2044 case QMessageBox::Yes:
2046 fileSave(CompleteMap);
2048 case QMessageBox::No:
2049 // close without saving
2051 case QMessageBox::Cancel:
2056 currentMapEditor()->closeMap();
2057 tabWidget->removePage(currentMapEditor());
2058 if (tabWidget->count()==0)
2059 actionFilePrint->setEnabled (false);
2063 void Main::filePrint()
2065 if (currentMapEditor())
2066 currentMapEditor()->print();
2069 void Main::fileExitVYM()
2071 // Check if one or more editors have changed
2074 for (i=0;i<=tabWidget->count() -1;i++)
2077 me=(MapEditor*)tabWidget->page(i);
2079 // If something changed, ask what to do
2080 if (me->isUnsaved())
2082 tabWidget->setCurrentPage(i);
2083 QMessageBox mb( __VYM,
2084 tr("This map is not saved yet. Do you want to"),
2085 QMessageBox::Warning,
2086 QMessageBox::Yes | QMessageBox::Default,
2088 QMessageBox::Cancel | QMessageBox::Escape );
2089 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2090 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2092 // Call undocumented function: setActiveWindow is only
2093 // possible, if widget is visible. This depends on
2095 #if defined(Q_OS_LINUX)
2096 qt_wait_for_window_manager( this);
2098 mb.setActiveWindow();
2099 switch( mb.exec() ) {
2100 case QMessageBox::Yes:
2101 // save (the changed editors) and exit
2102 fileSave(CompleteMap);
2104 case QMessageBox::No:
2105 // exit without saving
2107 case QMessageBox::Cancel:
2108 // don't save and don't exit
2112 } // loop over all MEs
2116 void Main::editUndo()
2118 if (currentMapEditor())
2119 currentMapEditor()->undo();
2122 void Main::editRedo()
2124 if (currentMapEditor())
2125 currentMapEditor()->redo();
2128 void Main::editCopy()
2130 if (currentMapEditor())
2131 currentMapEditor()->copy();
2134 void Main::editPaste()
2136 if (currentMapEditor())
2137 currentMapEditor()->paste();
2140 void Main::editCut()
2142 if (currentMapEditor())
2143 currentMapEditor()->cut();
2146 void Main::editOpenFindWindow()
2148 findWindow->popup();
2149 findWindow->raise();
2151 // Call undocumented function: setActiveWindow is only
2152 // possible, if widget is visible. This depends on
2154 #if defined(Q_OS_LINUX)
2155 qt_wait_for_window_manager( this);
2157 findWindow->setActiveWindow();
2160 void Main::editFind(QString s)
2163 BranchObj *bo=currentMapEditor()->findText(s, cs);
2166 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2169 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2170 tr("No matches found for <b>%1</b>").arg(s));
2174 void Main::editFindChanged()
2175 { // Notify editor, to abort the current find process
2176 currentMapEditor()->findReset();
2179 void Main::editOpenURL()
2182 if (currentMapEditor())
2184 QString url=currentMapEditor()->getURL();
2185 if (url=="") return;
2186 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2187 procBrowser = new QProcess( this );
2189 procBrowser->addArgument( browser);
2190 procBrowser->addArgument( url);
2192 if ( !procBrowser->start() )
2194 // try to set path to browser
2195 QMessageBox::warning(0,
2197 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2198 tr("Please use Settings->")+tr("Set application to open an URL"));
2203 void Main::editOpenURLTab()
2205 if (currentMapEditor())
2207 QString url=currentMapEditor()->getURL();
2208 if (url=="") return;
2209 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2210 if (browser.contains("konqueror") && procBrowser && procBrowser->isRunning())
2212 // Try to open new tab in existing browser
2213 QProcess *p=new QProcess (this);
2214 p->addArgument ("dcop");
2215 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2216 p->addArgument ("konqueror-mainwindow#1");
2217 p->addArgument ("newTab");
2218 p->addArgument (url);
2220 // try to set browser
2221 QMessageBox::warning(0,
2223 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2230 void Main::editURL()
2232 if (currentMapEditor())
2233 currentMapEditor()->editURL();
2236 void Main::editHeading2URL()
2238 if (currentMapEditor())
2239 currentMapEditor()->editHeading2URL();
2242 void Main::editBugzilla2URL()
2244 if (currentMapEditor())
2245 currentMapEditor()->editBugzilla2URL();
2248 void Main::editFATE2URL()
2250 if (currentMapEditor())
2251 currentMapEditor()->editFATE2URL();
2254 void Main::editOpenVymLink()
2256 // Get current path to map
2257 QString currentVymLink;
2258 if (currentMapEditor())
2260 currentVymLink=currentMapEditor()->getVymLink();
2261 // compare path with already loaded maps
2265 for (i=0;i<=tabWidget->count() -1;i++)
2267 me=(MapEditor*)tabWidget->page(i);
2268 if (currentVymLink==me->getFilePath() )
2277 if (!QFile(currentVymLink).exists() )
2278 QMessageBox::critical( 0, tr( "Critical Error" ),
2279 tr("Couldn't open map %1").arg(currentVymLink));
2282 fileLoad (currentVymLink, NewMap);
2283 tabWidget->setCurrentPage (tabWidget->count()-1);
2286 // Go to tab containing the map
2287 tabWidget->setCurrentPage (index);
2291 void Main::editVymLink()
2293 if (currentMapEditor())
2294 currentMapEditor()->editVymLink();
2297 void Main::editDeleteVymLink()
2299 if (currentMapEditor())
2300 currentMapEditor()->deleteVymLink();
2303 void Main::editToggleHideExport()
2305 if (currentMapEditor())
2306 currentMapEditor()->toggleHideExport();
2309 void Main::editMapInfo()
2311 if (currentMapEditor())
2312 currentMapEditor()->editMapInfo();
2315 void Main::editMoveUp()
2317 if (currentMapEditor())
2318 currentMapEditor()->moveBranchUp();
2321 void Main::editMoveDown()
2323 if (currentMapEditor())
2324 currentMapEditor()->moveBranchDown();
2327 void Main::editToggleScroll()
2329 if (currentMapEditor())
2331 currentMapEditor()->toggleScroll();
2335 void Main::editUnScrollAll()
2337 if (currentMapEditor())
2339 currentMapEditor()->unScrollAll();
2343 void Main::editHeading()
2345 if (currentMapEditor())
2346 currentMapEditor()->editHeading();
2349 void Main::editNewBranch()
2351 if (currentMapEditor())
2352 currentMapEditor()->addNewBranch(0);
2355 void Main::editNewBranchHere()
2357 if (currentMapEditor())
2358 currentMapEditor()->addNewBranchHere();
2361 void Main::editNewBranchAbove()
2363 if (currentMapEditor())
2364 currentMapEditor()->addNewBranch(-1);
2367 void Main::editNewBranchBelow()
2369 if (currentMapEditor())
2370 currentMapEditor()->addNewBranch(1);
2373 void Main::editImportAdd()
2375 fileLoad (ImportAdd);
2378 void Main::editImportReplace()
2380 fileLoad (ImportReplace);
2383 void Main::editSaveBranch()
2385 fileSaveAs (PartOfMap);
2388 void Main::editRemoveBranchKeepChilds()
2390 if (currentMapEditor())
2391 currentMapEditor()->removeBranchKeepChilds();
2394 void Main::editRemoveChilds()
2396 if (currentMapEditor())
2397 currentMapEditor()->removeChilds();
2400 void Main::editDeleteSelection()
2402 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2403 currentMapEditor()->deleteSelection();
2406 void Main::editUpperBranch()
2408 if (currentMapEditor())
2409 currentMapEditor()->selectUpperBranch();
2412 void Main::editLowerBranch()
2414 if (currentMapEditor())
2415 currentMapEditor()->selectLowerBranch();
2418 void Main::editLeftBranch()
2420 if (currentMapEditor())
2421 currentMapEditor()->selectLeftBranch();
2424 void Main::editRightBranch()
2426 if (currentMapEditor())
2427 currentMapEditor()->selectRightBranch();
2430 void Main::editFirstBranch()
2432 if (currentMapEditor())
2433 currentMapEditor()->selectFirstBranch();
2436 void Main::editLastBranch()
2438 if (currentMapEditor())
2439 currentMapEditor()->selectLastBranch();
2442 void Main::editLoadImage()
2444 if (currentMapEditor())
2445 currentMapEditor()->loadFloatImage();
2448 void Main::editSaveImage(int item)
2450 if (currentMapEditor())
2451 currentMapEditor()->saveFloatImage(item);
2454 void Main::editFollowXLink(int item)
2456 if (currentMapEditor())
2457 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2460 void Main::editEditXLink(int item)
2462 if (currentMapEditor())
2463 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2466 void Main::formatSelectColor()
2468 if (currentMapEditor())
2470 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2471 if ( !col.isValid() ) return;
2472 currentMapEditor()->setColor( col );
2473 colorChanged( col );
2477 void Main::formatPickColor()
2479 if (currentMapEditor())
2480 colorChanged( currentMapEditor()->pickColor() );
2483 void Main::colorChanged(QColor c)
2485 QPixmap pix( 16, 16 );
2487 actionFormatColor->setIconSet( pix );
2490 void Main::formatColorItem()
2492 if (currentMapEditor())
2493 currentMapEditor()->colorItem();
2496 void Main::formatColorBranch()
2498 if (currentMapEditor())
2499 currentMapEditor()->colorBranch();
2502 void Main::formatLinkStyleLine()
2504 if (currentMapEditor())
2505 currentMapEditor()->setLinkStyle(StyleLine);
2508 void Main::formatLinkStyleParabel()
2510 if (currentMapEditor())
2511 currentMapEditor()->setLinkStyle(StyleParabel);
2514 void Main::formatLinkStylePolyLine()
2516 if (currentMapEditor())
2517 currentMapEditor()->setLinkStyle(StylePolyLine);
2520 void Main::formatLinkStylePolyParabel()
2522 if (currentMapEditor())
2523 currentMapEditor()->setLinkStyle(StylePolyParabel);
2526 void Main::formatSelectBackColor()
2528 if (currentMapEditor())
2529 currentMapEditor()->selectBackgroundColor();
2532 void Main::formatSelectLinkColor()
2534 if (currentMapEditor())
2535 currentMapEditor()->selectLinkColor();
2538 void Main::formatToggleLinkColorHint()
2540 currentMapEditor()->toggleLinkColorHint();
2543 void Main::formatFrameNone()
2545 if (currentMapEditor())
2546 currentMapEditor()->setFrame(NoFrame);
2549 void Main::formatFrameRectangle()
2551 if (currentMapEditor())
2552 currentMapEditor()->setFrame(Rectangle);
2555 void Main::formatIncludeImagesVer()
2557 if (currentMapEditor())
2558 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2561 void Main::formatIncludeImagesHor()
2563 if (currentMapEditor())
2564 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2567 void Main::formatHideLinkUnselected()
2569 if (currentMapEditor())
2570 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2573 void Main::viewZoomReset()
2575 if (currentMapEditor())
2579 currentMapEditor()->setWorldMatrix( m );
2580 currentMapEditor()->setViewCenter();
2581 currentMapEditor()->adjustCanvasSize();
2585 void Main::viewZoomIn()
2587 if (currentMapEditor())
2589 QWMatrix m = currentMapEditor()->worldMatrix();
2590 m.scale( 1.25, 1.25 );
2591 currentMapEditor()->setWorldMatrix( m );
2592 currentMapEditor()->setViewCenter();
2593 currentMapEditor()->adjustCanvasSize();
2597 void Main::viewZoomOut()
2599 if (currentMapEditor())
2601 QWMatrix m = currentMapEditor()->worldMatrix();
2602 m.scale( 0.8, 0.8 );
2603 currentMapEditor()->setWorldMatrix( m );
2604 currentMapEditor()->setViewCenter();
2605 currentMapEditor()->adjustCanvasSize();
2609 void Main::modModeColor()
2613 void Main::modModeLink()
2617 bool Main::settingsPDF()
2619 // Default browser is set in constructor
2621 QString text = QInputDialog::getText(
2622 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2623 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2625 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2630 bool Main::settingsURL()
2632 // Default browser is set in constructor
2634 QString text = QInputDialog::getText(
2635 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2636 settings.readEntry("/vym/mainwindow/readerURL")
2639 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2643 void Main::windowToggleNoteEditor()
2645 if (textEditor->showWithMain() )
2646 windowHideNoteEditor();
2648 windowShowNoteEditor();
2651 void Main::windowToggleHistory()
2653 if (currentMapEditor())
2654 currentMapEditor()->toggleHistoryWindow();
2657 void Main::updateNoteFlag()
2659 if (currentMapEditor())
2660 currentMapEditor()->updateNoteFlag();
2663 void Main::windowShowNoteEditor()
2665 textEditor->setShowWithMain(true);
2667 actionViewToggleNoteEditor->setOn (true);
2670 void Main::windowHideNoteEditor()
2672 textEditor->setShowWithMain(false);
2674 actionViewToggleNoteEditor->setOn (false);
2677 void Main::windowNextEditor()
2679 if (tabWidget->currentPageIndex() < tabWidget->count())
2680 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2683 void Main::windowPreviousEditor()
2685 if (tabWidget->currentPageIndex() >0)
2686 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2689 void Main::standardFlagChanged()
2691 currentMapEditor()->toggleStandardFlag(sender()->name());
2694 void Main::testFunction()
2696 currentMapEditor()->testFunction();
2699 void Main::helpDoc()
2702 #if defined(Q_OS_MACX)
2703 docpath="./vym.app/Contents/vym.pdf";
2705 // default path in SUSE LINUX
2706 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2709 if (!QFile (docpath).exists() )
2711 // relative path for easy testing in tarball
2712 docpath="doc/vym.pdf";
2713 if (!QFile (docpath).exists() )
2715 // relative path for testing while still writing vym.tex
2716 docpath="doc/tex/vym.pdf";
2717 if (!QFile (docpath).exists() )
2719 // Try yet another one for Knoppix
2720 docpath="/usr/share/doc/packages/vym/vym.pdf";
2721 if (!QFile (docpath).exists() )
2723 QMessageBox::critical(0,
2724 tr("Critcal error"),
2725 tr("Couldn't find the documentation\n"
2726 "vym.pdf in various places."));
2733 Process *pdfProc = new Process();
2734 pdfProc->clearArguments();
2735 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2736 pdfProc->addArgument( docpath);
2738 if ( !pdfProc->start() )
2741 QMessageBox::warning(0,
2743 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
2744 tr("Please use Settings->")+tr("Set application to open PDF files"));
2751 void Main::helpAbout()
2754 ad.setName ("aboutwindow");
2755 ad.setMinimumSize(500,500);
2756 ad.resize (QSize (500,500));
2760 void Main::helpAboutQT()
2762 QMessageBox::aboutQt( this, "Qt Application Example" );