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 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
362 a = new QAction( tr( "Import")+" "+tr("Firefox Bookmarks" ), QPixmap(), tr("Firefox Bookmarks"), 0, this, "importFirefoxBookmarks" );
363 connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
364 a->addTo (importMenu);
367 a = new QAction( tr( "Import")+" Mind Manager" , QPixmap(), "Mind Manager...", 0, this, "importMM" );
368 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
369 a->addTo (importMenu);
371 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
372 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
373 a->addTo( importMenu);
375 exportMenu = new QPopupMenu (this);
376 menu->insertItem (tr("Export"),exportMenu );
378 menu->insertSeparator();
381 a = new QAction( tr( "Print" ), QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" );
382 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
387 a = new QAction( tr( "Close Map" ), QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
388 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
391 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
392 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
398 void Main::setupEditActions()
400 QToolBar *tb = new QToolBar( this );
401 tb->setLabel( "Edit Actions" );
402 QPopupMenu *menu = new QPopupMenu( this );
403 menuBar()->insertItem( tr( "&Edit" ), menu );
407 a = new QAction( tr( "Undo" ), QPixmap( iconPath+"undo.png"), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
408 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
409 a->setEnabled (false);
414 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
416 a = new QAction( tr( "Redo" ), QPixmap( iconPath+"redo.png"), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
417 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
422 menu->insertSeparator();
423 a = new QAction( tr( "Copy" ), QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
424 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
425 a->setEnabled (false);
429 a = new QAction( tr( "Cut" ), QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
430 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
431 a->setEnabled (false);
435 a = new QAction( tr( "Paste" ), QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
436 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
437 a->setEnabled (false);
442 a = new QAction( tr( "Move branch up" ), QPixmap(iconPath+"up.png" ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
443 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
444 a->setEnabled (false);
449 a = new QAction( tr( "Move branch down" ), QPixmap( iconPath+"down.png"), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
450 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
451 a->setEnabled (false);
454 actionEditMoveDown=a;
457 a = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
458 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
459 alt = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_S, this, "scroll" );
460 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
461 #if defined(Q_OS_MACX)
462 actionEditToggleScroll=alt;
464 actionEditToggleScroll=a;
466 actionEditToggleScroll->setEnabled (false);
467 actionEditToggleScroll->setToggleAction(true);
468 actionEditToggleScroll->addTo( tb );
469 actionEditToggleScroll->addTo( menu );
470 actionListBranches.append(actionEditToggleScroll);
472 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
473 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
476 menu->insertSeparator();
478 a = new QAction( tr( "Find" ), QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
479 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
482 menu->insertSeparator();
484 a = new QAction( tr( "Open URL" ), QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), CTRL + Key_U, this, "url" );
485 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
487 a->setEnabled (false);
490 a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), CTRL + Key_U, this, "urltab" );
491 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
492 a->setEnabled (false);
493 actionEditOpenURLTab=a;
495 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
496 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
497 a->setEnabled (false);
498 actionListBranches.append(a);
501 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
502 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
503 a->setEnabled (false);
504 actionListBranches.append(a);
505 actionEditHeading2URL=a;
507 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
508 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
509 a->setEnabled (false);
510 actionListBranches.append(a);
511 actionEditBugzilla2URL=a;
513 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
514 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
515 a->setEnabled (false);
516 actionListBranches.append(a);
517 actionEditFATE2URL=a;
519 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" );
520 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
522 a->setEnabled (false);
523 actionEditOpenVymLink=a;
525 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
526 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
527 a->setEnabled (false);
528 actionListBranches.append(a);
531 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
532 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
533 a->setEnabled (false);
534 actionEditDeleteVymLink=a;
536 a = new QAction( tr( "Hide object in exports" ), QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), Key_H, this, "hideExport" );
537 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
538 a->setToggleAction(true);
540 a->setEnabled (false);
541 actionEditToggleHideExport=a;
543 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
544 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
545 a->setEnabled (true);
548 menu->insertSeparator();
550 // Shortcuts to modify heading:
551 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
552 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
553 actionListBranches.append(a);
554 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
555 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
556 actionListBranches.append(a);
558 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
559 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
560 a->setEnabled (false);
562 actionListBranches.append(a);
564 // Shortcut to delete selection
565 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
566 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
567 a->setEnabled (false);
570 // Shortcut to add branch
571 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
572 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
573 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
574 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
575 a->setEnabled (false);
576 actionListBranches.append(a);
577 #if defined (Q_OS_MACX)
578 // In OSX show different shortcut in menues, the keys work independtly always
579 actionEditAddBranch=alt;
581 actionEditAddBranch=a;
584 // Add branch by inserting it at selection
585 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
586 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
587 a->setEnabled (false);
588 actionListBranches.append(a);
589 actionEditAddBranchHere=a;
590 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
591 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
592 actionListBranches.append(a);
595 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
596 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
597 a->setEnabled (false);
598 actionListBranches.append(a);
599 actionEditAddBranchAbove=a;
600 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
601 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
602 actionListBranches.append(a);
605 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
606 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
607 a->setEnabled (false);
608 actionListBranches.append(a);
609 actionEditAddBranchBelow=a;
610 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
611 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
612 actionListBranches.append(a);
614 // Import at selection (adding to selection)
615 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
616 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
617 a->setEnabled (false);
618 actionListBranches.append(a);
619 actionEditImportAdd=a;
621 // Import at selection (replacing selection)
622 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
623 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
624 a->setEnabled (false);
625 actionListBranches.append(a);
626 actionEditImportReplace=a;
629 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
630 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
631 a->setEnabled (false);
632 actionListBranches.append(a);
633 actionEditSaveBranch=a;
635 // Only remove branch, not its childs
636 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
637 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
638 a->setEnabled (false);
639 actionListBranches.append(a);
640 actionEditRemoveBranchKeepChilds=a;
642 // Only remove childs of a branch
643 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
644 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
645 a->setEnabled (false);
646 actionListBranches.append(a);
647 actionEditRemoveChilds=a;
649 // Shortcuts for navigating with cursor:
650 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
651 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
652 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
653 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
654 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
655 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
656 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
657 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
658 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
659 a->setEnabled (false);
661 actionListBranches.append(a);
662 actionEditSelectFirst=a;
663 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
664 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
665 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
666 a->setEnabled (false);
668 actionListBranches.append(a);
669 actionEditSelectLast=a;
671 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
672 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
673 actionEditLoadImage=a;
678 void Main::setupFormatActions()
680 QPopupMenu *menu = new QPopupMenu( this );
681 menuBar()->insertItem( tr( "F&ormat" ), menu );
683 QToolBar *tb = new QToolBar( this );
687 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
688 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
689 actionFormatColor->addTo( tb );
690 actionFormatColor->addTo( menu );
691 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" );
692 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
693 a->setEnabled (false);
696 actionListBranches.append(a);
697 actionFormatPickColor=a;
698 a= new QAction( tr( "Color branch" ), QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
699 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
700 a->setEnabled (false);
703 actionListBranches.append(a);
704 actionFormatColorBranch=a;
705 a= new QAction( tr( "Color Subtree" ), QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
706 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
707 a->setEnabled (false);
710 actionListBranches.append(a);
711 actionFormatColorSubtree=a;
713 menu->insertSeparator();
714 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
715 actionGroupFormatLinkStyles->setExclusive (true);
716 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
717 a->setToggleAction(true);
718 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
719 actionFormatLinkStyleLine=a;
720 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
721 a->setToggleAction(true);
722 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
723 actionFormatLinkStyleParabel=a;
724 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
725 a->setToggleAction(true);
726 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
727 actionFormatLinkStylePolyLine=a;
728 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
729 a->setToggleAction(true);
730 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
731 actionFormatLinkStylePolyParabel=a;
732 actionGroupFormatLinkStyles->addTo (menu);
734 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
735 actionGroupFormatFrameTypes->setExclusive (true);
736 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
737 a->setToggleAction(true);
738 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
739 actionFormatFrameNone=a;
740 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
741 a->setToggleAction(true);
742 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
743 actionFormatFrameRectangle=a;
745 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
746 a->setToggleAction(true);
747 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
748 actionFormatIncludeImagesVer=a;
750 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
751 a->setToggleAction(true);
752 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
753 actionFormatIncludeImagesHor=a;
755 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
756 a->setToggleAction(true);
757 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
758 actionFormatHideLinkUnselected=a;
760 menu->insertSeparator();
761 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
762 a->setToggleAction(true);
763 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
765 actionFormatLinkColorHint=a;
767 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
768 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
769 actionFormatLinkColor->addTo( menu );
770 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
771 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
772 actionFormatBackColor->addTo( menu );
776 void Main::setupViewActions()
778 QToolBar *tb = new QToolBar( this );
779 tb->setLabel( "View Actions" );
780 QPopupMenu *menu = new QPopupMenu( this );
781 menuBar()->insertItem( tr( "&View" ), menu );
784 a = new QAction( tr( "Zoom reset" ), QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
785 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
788 a = new QAction( tr( "Zoom in" ), QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
789 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
792 a = new QAction( tr( "Zoom out" ), QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
793 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
798 a = new QAction( tr( "Show Note Editor" ), QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ), CTRL + Key_E , this, "noteEditor" );
799 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
800 a->setToggleAction(true);
801 if (textEditor->showWithMain())
807 actionViewToggleNoteEditor=a;
809 a = new QAction( tr( "Show history window" ), QPixmap(), tr( "Show history window" ), CTRL + Key_H , this, "historyWindow" );
810 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
811 a->setToggleAction(false);
813 actionViewToggleHistoryWindow=a;
815 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
816 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
818 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
819 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
824 void Main::setupModeActions()
826 //QPopupMenu *menu = new QPopupMenu( this );
827 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
829 QToolBar *tb = new QToolBar( this );
830 tb->setLabel( tr ("Modes when using modifiers") );
832 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
833 actionGroupModModes->setExclusive (true);
834 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(iconPath+"modecolor.png"), 0, Key_J, actionGroupModModes, "modModeColor" );
835 a->setToggleAction(true);
838 actionModModeColor=a;
840 a= new QAction( tr( "Use modifier to copy" ), QPixmap(iconPath+"modecopy.png"), 0, Key_K, actionGroupModModes, "modModeCopy" );
841 a->setToggleAction(true);
845 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(iconPath+"modelink.png"), 0, Key_L, actionGroupModModes, "modModeLink" );
846 a->setToggleAction(true);
852 void Main::setupFlagActions()
854 // Create System Flags
855 systemFlagsDefault = new FlagRowObj ();
856 systemFlagsDefault->setVisibility (false);
857 systemFlagsDefault->setName ("systemFlagsDef");
859 FlagObj *fo = new FlagObj ();
860 fo->load(QPixmap(flagsPath+"flag-note.png"));
862 fo->setToolTip(tr("Note","Systemflag"));
863 systemFlagsDefault->addFlag (fo); // makes deep copy
865 fo->load(QPixmap(flagsPath+"flag-url.png"));
867 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
868 systemFlagsDefault->addFlag (fo);
870 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
871 fo->setName("vymLink");
872 fo->setToolTip(tr("Link to another vym map","Systemflag"));
873 systemFlagsDefault->addFlag (fo);
875 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
876 fo->setName("scrolledright");
877 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
878 systemFlagsDefault->addFlag (fo);
880 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
881 fo->setName("tmpUnscrolledright");
882 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
883 systemFlagsDefault->addFlag (fo);
885 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
886 fo->setName("hideInExport");
887 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
888 systemFlagsDefault->addFlag (fo);
890 // Create Standard Flags
891 standardFlagsDefault = new FlagRowObj ();
892 standardFlagsDefault->setVisibility (false);
893 standardFlagsDefault->setName ("standardFlagsDef");
895 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
896 fo->setName ("exclamationmark");
897 fo->setGroup("standard-mark");
898 fo->setToolTip(tr("Take care!","Standardflag"));
899 standardFlagsDefault->addFlag (fo); // makes deep copy
901 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
902 fo->setName("questionmark");
903 fo->setGroup("standard-mark");
904 fo->setToolTip(tr("Really?","Standardflag"));
905 standardFlagsDefault->addFlag (fo);
907 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
908 fo->setName("hook-green");
909 fo->setGroup("standard-hook");
910 fo->setToolTip(tr("ok!","Standardflag"));
911 standardFlagsDefault->addFlag (fo);
913 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
914 fo->setName("cross-red");
915 fo->setGroup("standard-hook");
916 fo->setToolTip(tr("Not ok!","Standardflag"));
917 standardFlagsDefault->addFlag (fo);
919 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
920 fo->setName("stopsign");
921 fo->setToolTip(tr("This won't work!","Standardflag"));
922 standardFlagsDefault->addFlag (fo);
924 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
925 fo->setName("smiley-good");
926 fo->setGroup("standard-smiley");
927 fo->setToolTip(tr("Good","Standardflag"));
928 standardFlagsDefault->addFlag (fo);
930 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
931 fo->setName("smiley-sad");
932 fo->setGroup("standard-smiley");
933 fo->setToolTip(tr("Bad","Standardflag"));
934 standardFlagsDefault->addFlag (fo);
936 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
937 // Original omg.png (in KDE emoticons)
938 fo->setName("smiley-omg");
939 fo->setGroup("standard-smiley");
940 fo->setToolTip(tr("Oh no!","Standardflag"));
941 standardFlagsDefault->addFlag (fo);
943 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
944 fo->setName("clock");
945 fo->setToolTip(tr("Time critical","Standardflag"));
946 standardFlagsDefault->addFlag (fo);
948 fo->load(QPixmap(flagsPath+"flag-phone.png"));
949 fo->setName("phone");
950 fo->setToolTip(tr("Call...","Standardflag"));
951 standardFlagsDefault->addFlag (fo);
953 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
955 fo->setToolTip(tr("Idea!","Standardflag"));
956 standardFlagsDefault->addFlag (fo);
958 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
959 fo->setName("arrow-up");
960 fo->setGroup("standard-arrow");
961 fo->setToolTip(tr("Important","Standardflag"));
962 standardFlagsDefault->addFlag (fo);
964 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
965 fo->setName("arrow-down");
966 fo->setGroup("standard-arrow");
967 fo->setToolTip(tr("Unimportant","Standardflag"));
968 standardFlagsDefault->addFlag (fo);
970 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
971 fo->setName("2arrow-up");
972 fo->setGroup("standard-arrow");
973 fo->setToolTip(tr("Very important!","Standardflag"));
974 standardFlagsDefault->addFlag (fo);
976 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
977 fo->setName("2arrow-down");
978 fo->setGroup("standard-arrow");
979 fo->setToolTip(tr("Very unimportant!","Standardflag"));
980 standardFlagsDefault->addFlag (fo);
982 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
983 fo->setName("thumb-up");
984 fo->setGroup("standard-thumb");
985 fo->setToolTip(tr("I like this","Standardflag"));
986 standardFlagsDefault->addFlag (fo);
988 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
989 fo->setName("thumb-down");
990 fo->setGroup("standard-thumb");
991 fo->setToolTip(tr("I like this","Standardflag"));
992 fo->setToolTip(tr("I do not like this","Standardflag"));
993 standardFlagsDefault->addFlag (fo);
995 fo->load(QPixmap(flagsPath+"flag-rose.png"));
997 fo->setToolTip(tr("Rose","Standardflag"));
998 standardFlagsDefault->addFlag (fo);
1000 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1001 fo->setName("heart");
1002 fo->setToolTip(tr("I just love... ","Standardflag"));
1003 standardFlagsDefault->addFlag (fo);
1005 fo->load(QPixmap(flagsPath+"flag-present.png"));
1006 fo->setName("present");
1007 fo->setToolTip(tr("Surprise!","Standardflag"));
1008 standardFlagsDefault->addFlag (fo);
1010 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1011 fo->setName("flash");
1012 fo->setToolTip(tr("Dangerous","Standardflag"));
1013 standardFlagsDefault->addFlag (fo);
1015 fo->load(QPixmap(flagsPath+"flag-info.png"));
1016 // Original: xsldbg_output.png
1017 fo->setName("info");
1018 fo->setToolTip(tr("Info","Standardflag"));
1019 standardFlagsDefault->addFlag (fo);
1021 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1022 // Original khelpcenter.png
1023 fo->setName("lifebelt");
1024 fo->setToolTip(tr("This will help","Standardflag"));
1025 standardFlagsDefault->addFlag (fo);
1029 standardFlagsDefault->makeToolbar(this, "Standard Flags");
1033 void Main::setupSettingsActions()
1035 QPopupMenu *menu = new QPopupMenu( this );
1036 menuBar()->insertItem( tr( "&Settings" ), menu );
1041 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1042 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1045 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1046 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1049 menu->insertSeparator();
1050 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1051 a->setToggleAction(true);
1052 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1054 actionSettingsAutoedit=a;
1056 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1057 a->setToggleAction(true);
1058 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1060 actionSettingsAutoselectHeading=a;
1062 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1063 a->setToggleAction(true);
1064 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1066 actionSettingsAutoselectText=a;
1068 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1069 a->setToggleAction(true);
1070 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1072 actionSettingsPasteNewHeading=a;
1074 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1075 a->setToggleAction(true);
1076 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1078 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1079 actionSettingsUseDelKey=a;
1081 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1082 a->setToggleAction(true);
1083 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1085 actionSettingsUseFlagGroups=a;
1087 a= new QAction( tr( "Use hide flag during exports " ), QPixmap(), tr( "Use hide flags" ), 0, this, "hideexport" );
1088 a->setToggleAction(true);
1089 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1091 actionSettingsUseHideExport=a;
1095 void Main::setupTestActions()
1097 QPopupMenu *menu = new QPopupMenu( this );
1098 menuBar()->insertItem( tr( "&Test" ), menu );
1101 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1102 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1107 void Main::setupHelpActions()
1109 QPopupMenu *menu = new QPopupMenu( this );
1110 menuBar()->insertItem( tr( "&Help" ), menu );
1113 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1114 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1117 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1118 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1121 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1122 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1127 void Main::setupContextMenus()
1131 // Context Menu for branch or mapcenter
1132 branchContextMenu =new QPopupMenu (this);
1135 branchAddContextMenu =new QPopupMenu (this);
1136 actionEditPaste->addTo ( branchAddContextMenu );
1137 actionEditAddBranch->addTo ( branchAddContextMenu );
1138 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1139 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1140 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1141 branchAddContextMenu->insertSeparator();
1142 actionEditLoadImage->addTo( branchAddContextMenu );
1143 branchAddContextMenu->insertSeparator();
1144 actionEditImportAdd->addTo ( branchAddContextMenu );
1145 actionEditImportReplace->addTo ( branchAddContextMenu );
1148 branchRemoveContextMenu =new QPopupMenu (this);
1149 actionEditCut->addTo ( branchRemoveContextMenu );
1150 actionEditDelete->addTo ( branchRemoveContextMenu );
1151 actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu );
1152 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1154 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1155 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1157 actionEditSaveBranch->addTo( branchContextMenu );
1159 branchContextMenu->insertSeparator();
1160 actionEditOpenURL->addTo ( branchContextMenu );
1161 actionEditOpenURLTab->addTo ( branchContextMenu );
1162 actionEditURL->addTo ( branchContextMenu );
1163 actionEditHeading2URL->addTo ( branchContextMenu );
1164 actionEditBugzilla2URL->addTo( branchContextMenu );
1165 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1167 actionEditFATE2URL->addTo( branchContextMenu );
1169 branchContextMenu->insertSeparator();
1170 actionEditOpenVymLink->addTo ( branchContextMenu );
1171 actionEditVymLink->addTo ( branchContextMenu );
1172 actionEditDeleteVymLink->addTo ( branchContextMenu );
1174 branchContextMenu->insertSeparator();
1175 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1177 branchContextMenu->insertSeparator();
1178 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1179 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1180 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1182 // Context Menu for links in a branch menu
1183 // This will be populated "on demand" in MapEditor::updateActions
1184 branchContextMenu->insertSeparator();
1185 branchLinksContextMenu =new QPopupMenu (this);
1186 branchLinksContextMenuDup =new QPopupMenu (this);
1187 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1188 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1190 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1191 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1193 // Context menu for floatimage
1194 floatimageContextMenu =new QPopupMenu (this);
1195 saveImageFormatMenu=new QPopupMenu (this);
1196 exportImageFormatMenu=new QPopupMenu (this);
1198 QStrList fmt = QImage::outputFormats();
1199 for (const char* f = fmt.first(); f; f = fmt.next())
1201 saveImageFormatMenu->insertItem( f );
1202 exportImageFormatMenu->insertItem( f );
1204 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1205 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1206 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1208 floatimageContextMenu->insertSeparator();
1209 actionEditCopy->addTo( floatimageContextMenu );
1210 actionEditCut->addTo( floatimageContextMenu );
1212 /* FIXME not needed any longer
1213 floatimageContextMenu->insertSeparator();
1214 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1215 a->setToggleAction(true);
1216 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1217 a->addTo( floatimageContextMenu);
1218 actionEditToggleFloatExport=a;
1221 floatimageContextMenu->insertSeparator();
1222 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1224 exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1226 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1227 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1228 a->addTo (exportMenu);
1230 a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" );
1231 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1232 a->addTo( exportMenu );
1234 a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" );
1235 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1236 a->addTo( exportMenu );
1238 a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
1239 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1240 a->addTo (exportMenu);
1242 a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
1243 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1244 a->addTo( exportMenu );
1246 a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1247 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1248 a->addTo( exportMenu );
1250 a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" );
1251 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1252 a->addTo( exportMenu );
1254 // Context menu for canvas
1255 canvasContextMenu =new QPopupMenu (this);
1256 actionEditMapInfo->addTo( canvasContextMenu );
1257 canvasContextMenu->insertSeparator();
1258 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1259 canvasContextMenu->insertSeparator();
1260 actionFormatLinkColorHint->addTo( canvasContextMenu );
1261 actionFormatLinkColor->addTo( canvasContextMenu );
1262 actionFormatBackColor->addTo( canvasContextMenu );
1264 // Menu for last opened files
1265 // Read settings initially
1267 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1268 for (int i=1;i<=j;i++)
1270 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1271 if (!s.isEmpty() && j<=maxLastMaps)
1274 setupLastMapsMenu();
1275 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1278 void Main::setupLastMapsMenu()
1280 // Remove double entries
1281 QStringList::Iterator it=lastMaps.begin();
1282 QStringList::Iterator jt;
1283 while (it!=lastMaps.end() )
1287 while (jt!=lastMaps.end() )
1290 jt=lastMaps.remove(jt);
1297 // Limit length of list to maxLastMaps
1298 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1300 // build Menu from lastMaps string list
1301 lastMapsMenu->clear();
1302 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1303 lastMapsMenu->insertItem (*it );
1307 void Main::hideEvent (QHideEvent * )
1309 if (!textEditor->isMinimized() ) textEditor->hide();
1312 void Main::showEvent (QShowEvent * )
1314 if (textEditor->showWithMain()) textEditor->showNormal();
1317 bool Main::reallyWriteDirectory(const QString &dir)
1319 QStringList eList = QDir(dir).entryList();
1320 if (eList.first() ==".") eList.pop_front(); // remove "."
1321 if (eList.first() =="..") eList.pop_front(); // remove "."
1322 if (!eList.isEmpty())
1324 QMessageBox mb( __VYM,
1325 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1326 QMessageBox::Warning,
1328 QMessageBox::Cancel | QMessageBox::Default,
1329 QMessageBox::QMessageBox::NoButton );
1331 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1332 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1335 case QMessageBox::Yes:
1338 case QMessageBox::Cancel:
1346 QString Main::browseDirectory (const QString &caption)
1348 QFileDialog fd(this,caption);
1349 fd.setMode (QFileDialog::DirectoryOnly);
1350 fd.setCaption(__VYM " - "+caption);
1353 if ( fd.exec() == QDialog::Accepted )
1354 return fd.selectedFile();
1359 MapEditor* Main::currentMapEditor() const
1361 if ( tabWidget->currentPage() &&
1362 tabWidget->currentPage()->inherits( "MapEditor" ) )
1363 return (MapEditor*)tabWidget->currentPage();
1367 //TODO not used now, maybe use this for overview window later
1368 void Main::newView()
1370 // Open a new view... have it delete when closed.
1371 Main *m = new Main(0, 0, WDestructiveClose);
1372 qApp->setMainWidget(m);
1374 qApp->setMainWidget(0);
1377 void Main::editorChanged(QWidget *)
1379 // Unselect all possibly selected objects
1380 // (Important to update note editor)
1383 for (i=0;i<=tabWidget->count() -1;i++)
1386 me=(MapEditor*)tabWidget->page(i);
1389 currentMapEditor()->reselect();
1391 // Update actions to in menus and toolbars according to editor
1392 currentMapEditor()->updateActions();
1395 void Main::fileNew()
1397 QString fn="unnamed";
1398 MapEditor* medit = new MapEditor (tabWidget, true);
1399 tabWidget->addTab (medit,fn);
1400 tabWidget->showPage(medit);
1401 medit->viewport()->setFocus();
1402 // For the very first map we do not have flagrows yet...
1403 medit->select("mc:");
1406 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1408 ErrorCode err=success;
1410 // fn is usually the archive, mapfile the file after uncompressing
1413 // Make fn absolute (needed for unzip)
1414 fn=QDir (fn).absPath();
1420 // Check, if map is already loaded
1422 while (i<=tabWidget->count() -1)
1424 me=(MapEditor*)tabWidget->page(i);
1425 if (me->getFilePath() == fn)
1427 // Already there, ask for confirmation
1428 QMessageBox mb( __VYM,
1429 tr("The map %1\nis already opened."
1430 "Opening the same map in multiple editors may lead \n"
1431 "to confusion when finishing working with vym."
1432 "Do you want to").arg(fn),
1433 QMessageBox::Warning,
1434 QMessageBox::Yes | QMessageBox::Default,
1435 QMessageBox::Cancel | QMessageBox::Escape,
1436 QMessageBox::QMessageBox::NoButton);
1437 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1438 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1441 case QMessageBox::Yes:
1443 i=tabWidget->count();
1445 case QMessageBox::Cancel:
1457 if ( !fn.isEmpty() )
1459 me = currentMapEditor();
1460 int tabIndex=tabWidget->currentPageIndex();
1461 // Check first, if mapeditor exists
1462 // If it is not default AND we want a new map,
1463 // create a new mapeditor in a new tab
1464 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1466 me = new MapEditor (tabWidget,true);
1467 tabWidget->addTab (me,fn);
1468 tabIndex=tabWidget->indexOf (me);
1469 tabWidget->setCurrentPage (tabIndex);
1472 // Check, if file exists (important for creating new files
1473 // from command line
1474 if (!QFile(fn).exists() )
1476 QMessageBox mb( __VYM,
1477 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1478 QMessageBox::Question,
1480 QMessageBox::Cancel | QMessageBox::Default,
1481 QMessageBox::QMessageBox::NoButton );
1483 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1484 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1487 case QMessageBox::Yes:
1489 currentMapEditor()->setFilePath(fn);
1490 tabWidget->setTabLabel (currentMapEditor(),
1491 currentMapEditor()->getFileName() );
1492 statusBar()->message( "Created " + fn , statusbarTime );
1495 case QMessageBox::Cancel:
1496 // don't create new map
1497 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1504 //tabWidget->currentPage() won't be NULL here, because of above...
1505 tabWidget->showPage(me);
1506 me->viewport()->setFocus();
1508 // Create temporary directory for packing
1509 char tmpdir1[]="/tmp/vym-XXXXXX";
1510 QString tmpMapDir=mkdtemp(tmpdir1);
1512 // Try to unzip file
1513 err=unzipDir (tmpMapDir,fn);
1517 me->setZipped(false);
1520 me->setZipped(true);
1522 // Look for mapname.xml
1523 mapfile= fn.left(fn.findRev(".",-1,true));
1524 mapfile=mapfile.section( '/', -1 );
1525 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1526 if (!file.exists() )
1528 // mapname.xml does not exist, well,
1529 // maybe some renamed the mapname.vym file...
1530 // Try to find any .xml in the toplevel
1531 // directory of the .vym file
1532 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1533 if (flist.count()==1)
1535 // Only one entry, take this one
1536 mapfile=tmpMapDir + "/"+flist.first();
1539 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1540 *it=tmpMapDir + "/" + *it;
1541 // TODO Multiple entries, load all (but only the first one into this ME)
1542 //mainWindow->fileLoadFromTmp (flist);
1543 //returnCode=1; // Silently forget this attempt to load
1544 qWarning ("MainWindow::load (fn) multimap found...");
1547 if (flist.isEmpty() )
1549 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1550 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1553 } //file doesn't exist
1555 mapfile=file.name();
1560 // Save existing filename in case we import
1561 QString fn_org=me->getFilePath();
1563 // Finally load map into mapEditor
1564 me->setFilePath (mapfile,fn);
1565 err=me->load(mapfile,lmode);
1567 // Restore old (maybe empty) filepath, if this is an import
1569 me->setFilePath (fn_org);
1572 // Finally check for errors and go home
1575 if (lmode==NewMap) fileCloseMap();
1576 statusBar()->message( "Could not load " + fn, statusbarTime );
1581 me->setFilePath (fn);
1582 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1583 if (fn.left(9)!="/tmp/vym-")
1585 // Only append to lastMaps if not loaded from a tmpDir
1586 // e.g. imported bookmarks are in a tmpDir
1587 lastMaps.prepend(me->getFilePath() );
1588 setupLastMapsMenu();
1590 actionFilePrint->setEnabled (true);
1592 statusBar()->message( "Loaded " + fn, statusbarTime );
1596 removeDir (QDir(tmpMapDir));
1602 void Main::fileLoad(const LoadMode &lmode)
1604 QFileDialog *fd=new QFileDialog( this);
1605 if (!lastFileDir.isEmpty())
1606 fd->setDir (lastFileDir);
1607 fd->setMode (QFileDialog::ExistingFiles);
1608 fd->addFilter ("XML (*.xml)");
1609 fd->addFilter ("VYM map (*.vym *.vyp)");
1613 fd->setCaption(tr("Load vym map"));
1616 fd->setCaption(tr("Import: Add vym map to selection"));
1619 fd->setCaption(tr("Import: Replace selection with vym map"));
1625 if ( fd->exec() == QDialog::Accepted )
1627 lastFileDir=fd->dirPath();
1628 QStringList flist = fd->selectedFiles();
1629 QStringList::Iterator it = flist.begin();
1630 while( it != flist.end() )
1633 fileLoad(*it, lmode);
1640 void Main::fileLoad()
1645 void Main::fileLoadLast(int i)
1647 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1650 void Main::fileSave(const SaveMode &savemode)
1652 // tmp dir for zipping
1656 ErrorCode err=success;
1658 QString safeFilePath;
1660 bool saveZipped=currentMapEditor()->saveZipped();
1662 MapEditor * me=currentMapEditor();
1665 QString fn=me->getFilePath();
1666 // filename=unnamed, filepath="" in constructor...
1667 if ( !fn.isEmpty() )
1669 // We have a filepath, go on saving
1670 // First remove existing file, we
1671 // don't want to add to old zip archives
1675 QMessageBox::warning( 0, tr( "Save Error" ),
1676 fn+ tr("\ncould not be removed before saving"));
1678 // Look, if we should zip the data:
1681 QMessageBox mb( __VYM,
1682 tr("The map %1\ndid not use the compressed "
1683 "vym file format.\nWriting it uncompressed will also write images \n"
1684 "and flags and thus may overwrite files in the "
1685 "given directory\n\nDo you want to write the map").arg(fn),
1686 QMessageBox::Warning,
1687 QMessageBox::Yes | QMessageBox::Default,
1689 QMessageBox::Cancel | QMessageBox::Escape);
1690 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1691 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1692 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1695 case QMessageBox::Yes:
1696 // save compressed (default file format)
1699 case QMessageBox::No:
1700 // save uncompressed
1703 case QMessageBox::Cancel:
1712 char tmpdir1[]="/tmp/vym-XXXXXX";
1713 tmpMapDir=mkdtemp(tmpdir1);
1715 safeFilePath=me->getFilePath();
1716 me->setFilePath (tmpMapDir+"/"+
1717 me->getMapName()+ ".xml",
1719 me->save (savemode);
1720 me->setFilePath (safeFilePath);
1722 zipDir (tmpMapDir,fn);
1727 safeFilePath=me->getFilePath();
1728 me->setFilePath (fn, safeFilePath);
1729 me->save (savemode);
1730 me->setFilePath (safeFilePath);
1732 } // filepath available
1735 // We have no filepath yet,
1736 // call fileSaveAs() now, this will call fileSave()
1738 fileSaveAs(savemode);
1742 if (saveZipped && !tmpMapDir.isEmpty())
1744 removeDir (QDir(tmpMapDir));
1748 statusBar()->message(
1749 tr("Saved %1").arg(me->getFilePath()),
1751 lastMaps.prepend(me->getFilePath() );
1752 setupLastMapsMenu();
1754 statusBar()->message(
1755 tr("Couldn't save ").arg(me->getFilePath()),
1759 void Main::fileSave()
1761 fileSave (CompleteMap);
1764 void Main::fileSaveAs(const SaveMode& savemode)
1768 if (currentMapEditor())
1770 if (savemode==CompleteMap)
1771 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1773 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1774 if ( !fn.isEmpty() )
1776 // Check for existing file
1777 if (QFile (fn).exists())
1779 QMessageBox mb( __VYM,
1780 tr("The file %1\nexists already. Do you want to").arg(fn),
1781 QMessageBox::Warning,
1782 QMessageBox::Yes | QMessageBox::Default,
1783 QMessageBox::Cancel | QMessageBox::Escape,
1784 QMessageBox::QMessageBox::NoButton);
1785 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1786 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1789 case QMessageBox::Yes:
1792 case QMessageBox::Cancel:
1799 // New file, add extension to filename, if missing
1800 // This is always .vym or .vyp, depending on savemode
1801 if (savemode==CompleteMap)
1803 if (!fn.contains (".vym") && !fn.contains (".xml"))
1807 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1816 currentMapEditor()->setFilePath(fn);
1820 if (savemode==CompleteMap)
1821 tabWidget->setTabLabel (currentMapEditor(),
1822 currentMapEditor()->getFileName() );
1828 void Main::fileSaveAs()
1830 fileSaveAs (CompleteMap);
1833 void Main::fileImportKDEBookmarks()
1835 ImportKDEBookmarks im;
1837 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1838 currentMapEditor()->setFilePath ("");
1841 void Main::fileImportFirefoxBookmarks()
1843 QFileDialog *fd=new QFileDialog( this);
1844 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
1845 fd->setMode (QFileDialog::ExistingFiles);
1846 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
1847 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
1850 if ( fd->exec() == QDialog::Accepted )
1852 ImportFirefoxBookmarks im;
1853 QStringList flist = fd->selectedFiles();
1854 QStringList::Iterator it = flist.begin();
1855 while( it != flist.end() )
1858 if (im.transform() &&
1859 success==fileLoad (im.getTransformedFile(),NewMap) &&
1860 currentMapEditor() )
1861 currentMapEditor()->setFilePath ("");
1868 void Main::fileImportMM()
1872 QFileDialog *fd=new QFileDialog( this);
1873 if (!lastFileDir.isEmpty())
1874 fd->setDir (lastFileDir);
1875 fd->setMode (QFileDialog::ExistingFiles);
1876 fd->addFilter ("Mind Manager (*.mmap)");
1877 fd->setCaption(tr("Import")+" "+"Mind Manager");
1880 if ( fd->exec() == QDialog::Accepted )
1882 lastFileDir=fd->dirPath();
1883 QStringList flist = fd->selectedFiles();
1884 QStringList::Iterator it = flist.begin();
1885 while( it != flist.end() )
1888 if (im.transform() &&
1889 success==fileLoad (im.getTransformedFile(),NewMap) &&
1890 currentMapEditor() )
1891 currentMapEditor()->setFilePath ("");
1900 void Main::fileImportDir()
1902 if (currentMapEditor())
1903 currentMapEditor()->importDir();
1906 void Main::fileExportXML()
1908 if (currentMapEditor())
1910 QString dir=browseDirectory(tr("Export XML to directory"));
1911 if (dir !="" && reallyWriteDirectory(dir) )
1912 currentMapEditor()->exportXML(dir);
1917 void Main::fileExportXHTML()
1919 MapEditor *me=currentMapEditor();
1923 ExportXHTMLDialog dia(this);
1924 dia.setFilePath (me->getFilePath() );
1925 dia.setMapName (me->getMapName() );
1928 if (dia.exec()==QDialog::Accepted)
1930 QString dir=dia.getDir();
1931 // Check, if warnings should be used before overwriting
1932 // the output directory
1935 ok=reallyWriteDirectory(dir);
1941 me->exportXML (dia.getDir() );
1942 dia.doExport(me->getMapName() );
1943 if (dia.hasChanged())
1950 void Main::fileExportImage(int item)
1952 MapEditor *me=currentMapEditor();
1955 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1957 if ( !fn.isEmpty() )
1958 me->exportImage(fn,item);
1960 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1965 void Main::fileExportASCII()
1967 MapEditor *me=currentMapEditor();
1971 ex.setMapCenter(me->getMapCenter());
1972 ex.addFilter ("TXT (*.txt)");
1973 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1974 if (ex.execDialog() )
1976 me->setExportMode(true);
1978 me->setExportMode(false);
1983 void Main::fileExportLaTeX()
1985 MapEditor *me=currentMapEditor();
1989 ex.setMapCenter(me->getMapCenter());
1990 ex.addFilter ("Tex (*.tex)");
1991 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1992 if (ex.execDialog() )
1994 me->setExportMode(true);
1996 me->setExportMode(false);
2001 void Main::fileExportKDEBookmarks()
2003 ExportKDEBookmarks ex;
2004 MapEditor *me=currentMapEditor();
2007 ex.setMapCenter (me->getMapCenter() );
2012 void Main::fileExportTaskjuggler()
2014 ExportTaskjuggler ex;
2015 MapEditor *me=currentMapEditor();
2018 ex.setMapCenter (me->getMapCenter() );
2019 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2020 ex.addFilter ("Taskjuggler (*.tjp)");
2021 if (ex.execDialog() )
2023 me->setExportMode(true);
2025 me->setExportMode(false);
2030 void Main::fileExportOOPresentation()
2032 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2033 // FIXME add extra info in dialog
2034 //ImagePreview *p =new ImagePreview (fd);
2035 //fd->setContentsPreviewEnabled( TRUE );
2036 //fd->setContentsPreview( p, p );
2037 //fd->setPreviewMode( QFileDialog::Contents );
2038 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2039 //fd->setDir (lastImageDir);
2042 if ( fd->exec() == QDialog::Accepted )
2044 QString fn=fd->selectedFile();
2045 //lastImageDir=fn.left(fn.findRev ("/"));
2046 if (currentMapEditor())
2047 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2051 void Main::fileCloseMap()
2053 if (currentMapEditor())
2055 if (currentMapEditor()->hasChanged())
2057 QMessageBox mb( __VYM,
2058 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2059 QMessageBox::Warning,
2060 QMessageBox::Yes | QMessageBox::Default,
2062 QMessageBox::Cancel | QMessageBox::Escape );
2063 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2064 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2067 case QMessageBox::Yes:
2069 fileSave(CompleteMap);
2071 case QMessageBox::No:
2072 // close without saving
2074 case QMessageBox::Cancel:
2079 currentMapEditor()->closeMap();
2080 tabWidget->removePage(currentMapEditor());
2081 if (tabWidget->count()==0)
2082 actionFilePrint->setEnabled (false);
2086 void Main::filePrint()
2088 if (currentMapEditor())
2089 currentMapEditor()->print();
2092 void Main::fileExitVYM()
2094 // Check if one or more editors have changed
2097 for (i=0;i<=tabWidget->count() -1;i++)
2100 me=(MapEditor*)tabWidget->page(i);
2102 // If something changed, ask what to do
2103 if (me->isUnsaved())
2105 tabWidget->setCurrentPage(i);
2106 QMessageBox mb( __VYM,
2107 tr("This map is not saved yet. Do you want to"),
2108 QMessageBox::Warning,
2109 QMessageBox::Yes | QMessageBox::Default,
2111 QMessageBox::Cancel | QMessageBox::Escape );
2112 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2113 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2115 // Call undocumented function: setActiveWindow is only
2116 // possible, if widget is visible. This depends on
2118 #if defined(Q_OS_LINUX)
2119 qt_wait_for_window_manager( this);
2121 mb.setActiveWindow();
2122 switch( mb.exec() ) {
2123 case QMessageBox::Yes:
2124 // save (the changed editors) and exit
2125 fileSave(CompleteMap);
2127 case QMessageBox::No:
2128 // exit without saving
2130 case QMessageBox::Cancel:
2131 // don't save and don't exit
2135 } // loop over all MEs
2139 void Main::editUndo()
2141 if (currentMapEditor())
2142 currentMapEditor()->undo();
2145 void Main::editRedo()
2147 if (currentMapEditor())
2148 currentMapEditor()->redo();
2151 void Main::editCopy()
2153 if (currentMapEditor())
2154 currentMapEditor()->copy();
2157 void Main::editPaste()
2159 if (currentMapEditor())
2160 currentMapEditor()->paste();
2163 void Main::editCut()
2165 if (currentMapEditor())
2166 currentMapEditor()->cut();
2169 void Main::editOpenFindWindow()
2171 findWindow->popup();
2172 findWindow->raise();
2174 // Call undocumented function: setActiveWindow is only
2175 // possible, if widget is visible. This depends on
2177 #if defined(Q_OS_LINUX)
2178 qt_wait_for_window_manager( this);
2180 findWindow->setActiveWindow();
2183 void Main::editFind(QString s)
2186 BranchObj *bo=currentMapEditor()->findText(s, cs);
2189 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2192 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2193 tr("No matches found for \"%1\"").arg(s));
2197 void Main::editFindChanged()
2198 { // Notify editor, to abort the current find process
2199 currentMapEditor()->findReset();
2202 void Main::editOpenURL()
2205 if (currentMapEditor())
2207 QString url=currentMapEditor()->getURL();
2208 if (url=="") return;
2209 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2210 procBrowser = new QProcess( this );
2212 procBrowser->addArgument( browser);
2213 procBrowser->addArgument( url);
2215 if ( !procBrowser->start() )
2217 // try to set path to browser
2218 QMessageBox::warning(0,
2220 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2221 tr("Please use Settings->")+tr("Set application to open an URL"));
2226 void Main::editOpenURLTab()
2228 if (currentMapEditor())
2230 QString url=currentMapEditor()->getURL();
2231 if (url=="") return;
2232 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2233 if (procBrowser && procBrowser->isRunning())
2235 if (browser.contains("konqueror"))
2237 // Try to open new tab in existing konqueror started previously by vym
2238 QProcess *p=new QProcess (this);
2239 p->addArgument ("dcop");
2240 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2241 p->addArgument ("konqueror-mainwindow#1");
2242 p->addArgument ("newTab");
2243 p->addArgument (url);
2245 // try to set browser
2246 QMessageBox::warning(0,
2248 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2250 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2252 // Try to open new tab in firefox
2253 QProcess *p=new QProcess (this);
2254 p->addArgument (browser);
2255 p->addArgument ("-remote");
2256 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2258 // try to set browser
2259 QMessageBox::warning(0,
2261 tr("Couldn't start %1 to open a new tab").arg(browser));
2270 void Main::editURL()
2272 if (currentMapEditor())
2273 currentMapEditor()->editURL();
2276 void Main::editHeading2URL()
2278 if (currentMapEditor())
2279 currentMapEditor()->editHeading2URL();
2282 void Main::editBugzilla2URL()
2284 if (currentMapEditor())
2285 currentMapEditor()->editBugzilla2URL();
2288 void Main::editFATE2URL()
2290 if (currentMapEditor())
2291 currentMapEditor()->editFATE2URL();
2294 void Main::editOpenVymLink()
2296 // Get current path to map
2297 QString currentVymLink;
2298 if (currentMapEditor())
2300 currentVymLink=currentMapEditor()->getVymLink();
2301 // compare path with already loaded maps
2305 for (i=0;i<=tabWidget->count() -1;i++)
2307 me=(MapEditor*)tabWidget->page(i);
2308 if (currentVymLink==me->getFilePath() )
2317 if (!QFile(currentVymLink).exists() )
2318 QMessageBox::critical( 0, tr( "Critical Error" ),
2319 tr("Couldn't open map %1").arg(currentVymLink));
2322 fileLoad (currentVymLink, NewMap);
2323 tabWidget->setCurrentPage (tabWidget->count()-1);
2326 // Go to tab containing the map
2327 tabWidget->setCurrentPage (index);
2331 void Main::editVymLink()
2333 if (currentMapEditor())
2334 currentMapEditor()->editVymLink();
2337 void Main::editDeleteVymLink()
2339 if (currentMapEditor())
2340 currentMapEditor()->deleteVymLink();
2343 void Main::editToggleHideExport()
2345 if (currentMapEditor())
2346 currentMapEditor()->toggleHideExport();
2349 void Main::editMapInfo()
2351 if (currentMapEditor())
2352 currentMapEditor()->editMapInfo();
2355 void Main::editMoveUp()
2357 if (currentMapEditor())
2358 currentMapEditor()->moveBranchUp();
2361 void Main::editMoveDown()
2363 if (currentMapEditor())
2364 currentMapEditor()->moveBranchDown();
2367 void Main::editToggleScroll()
2369 if (currentMapEditor())
2371 currentMapEditor()->toggleScroll();
2375 void Main::editUnScrollAll()
2377 if (currentMapEditor())
2379 currentMapEditor()->unScrollAll();
2383 void Main::editHeading()
2385 if (currentMapEditor())
2386 currentMapEditor()->editHeading();
2389 void Main::editNewBranch()
2391 if (currentMapEditor())
2392 currentMapEditor()->addNewBranch(0);
2395 void Main::editNewBranchHere()
2397 if (currentMapEditor())
2398 currentMapEditor()->addNewBranchHere();
2401 void Main::editNewBranchAbove()
2403 if (currentMapEditor())
2404 currentMapEditor()->addNewBranch(-1);
2407 void Main::editNewBranchBelow()
2409 if (currentMapEditor())
2410 currentMapEditor()->addNewBranch(1);
2413 void Main::editImportAdd()
2415 fileLoad (ImportAdd);
2418 void Main::editImportReplace()
2420 fileLoad (ImportReplace);
2423 void Main::editSaveBranch()
2425 fileSaveAs (PartOfMap);
2428 void Main::editRemoveBranchKeepChilds()
2430 if (currentMapEditor())
2431 currentMapEditor()->removeBranchKeepChilds();
2434 void Main::editRemoveChilds()
2436 if (currentMapEditor())
2437 currentMapEditor()->removeChilds();
2440 void Main::editDeleteSelection()
2442 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2443 currentMapEditor()->deleteSelection();
2446 void Main::editUpperBranch()
2448 if (currentMapEditor())
2449 currentMapEditor()->selectUpperBranch();
2452 void Main::editLowerBranch()
2454 if (currentMapEditor())
2455 currentMapEditor()->selectLowerBranch();
2458 void Main::editLeftBranch()
2460 if (currentMapEditor())
2461 currentMapEditor()->selectLeftBranch();
2464 void Main::editRightBranch()
2466 if (currentMapEditor())
2467 currentMapEditor()->selectRightBranch();
2470 void Main::editFirstBranch()
2472 if (currentMapEditor())
2473 currentMapEditor()->selectFirstBranch();
2476 void Main::editLastBranch()
2478 if (currentMapEditor())
2479 currentMapEditor()->selectLastBranch();
2482 void Main::editLoadImage()
2484 if (currentMapEditor())
2485 currentMapEditor()->loadFloatImage();
2488 void Main::editSaveImage(int item)
2490 if (currentMapEditor())
2491 currentMapEditor()->saveFloatImage(item);
2494 void Main::editFollowXLink(int item)
2496 if (currentMapEditor())
2497 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2500 void Main::editEditXLink(int item)
2502 if (currentMapEditor())
2503 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2506 void Main::formatSelectColor()
2508 if (currentMapEditor())
2510 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2511 if ( !col.isValid() ) return;
2512 currentMapEditor()->setColor( col );
2513 colorChanged( col );
2517 void Main::formatPickColor()
2519 if (currentMapEditor())
2520 colorChanged( currentMapEditor()->pickColor() );
2523 void Main::colorChanged(QColor c)
2525 QPixmap pix( 16, 16 );
2527 actionFormatColor->setIconSet( pix );
2530 void Main::formatColorItem()
2532 if (currentMapEditor())
2533 currentMapEditor()->colorItem();
2536 void Main::formatColorBranch()
2538 if (currentMapEditor())
2539 currentMapEditor()->colorBranch();
2542 void Main::formatLinkStyleLine()
2544 if (currentMapEditor())
2545 currentMapEditor()->setLinkStyle(StyleLine);
2548 void Main::formatLinkStyleParabel()
2550 if (currentMapEditor())
2551 currentMapEditor()->setLinkStyle(StyleParabel);
2554 void Main::formatLinkStylePolyLine()
2556 if (currentMapEditor())
2557 currentMapEditor()->setLinkStyle(StylePolyLine);
2560 void Main::formatLinkStylePolyParabel()
2562 if (currentMapEditor())
2563 currentMapEditor()->setLinkStyle(StylePolyParabel);
2566 void Main::formatSelectBackColor()
2568 if (currentMapEditor())
2569 currentMapEditor()->selectBackgroundColor();
2572 void Main::formatSelectLinkColor()
2574 if (currentMapEditor())
2575 currentMapEditor()->selectLinkColor();
2578 void Main::formatToggleLinkColorHint()
2580 currentMapEditor()->toggleLinkColorHint();
2583 void Main::formatFrameNone()
2585 if (currentMapEditor())
2586 currentMapEditor()->setFrame(NoFrame);
2589 void Main::formatFrameRectangle()
2591 if (currentMapEditor())
2592 currentMapEditor()->setFrame(Rectangle);
2595 void Main::formatIncludeImagesVer()
2597 if (currentMapEditor())
2598 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2601 void Main::formatIncludeImagesHor()
2603 if (currentMapEditor())
2604 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2607 void Main::formatHideLinkUnselected()
2609 if (currentMapEditor())
2610 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2613 void Main::viewZoomReset()
2615 if (currentMapEditor())
2619 currentMapEditor()->setWorldMatrix( m );
2620 currentMapEditor()->setViewCenter();
2621 currentMapEditor()->adjustCanvasSize();
2625 void Main::viewZoomIn()
2627 if (currentMapEditor())
2629 QWMatrix m = currentMapEditor()->worldMatrix();
2630 m.scale( 1.25, 1.25 );
2631 currentMapEditor()->setWorldMatrix( m );
2632 currentMapEditor()->setViewCenter();
2633 currentMapEditor()->adjustCanvasSize();
2637 void Main::viewZoomOut()
2639 if (currentMapEditor())
2641 QWMatrix m = currentMapEditor()->worldMatrix();
2642 m.scale( 0.8, 0.8 );
2643 currentMapEditor()->setWorldMatrix( m );
2644 currentMapEditor()->setViewCenter();
2645 currentMapEditor()->adjustCanvasSize();
2649 void Main::modModeColor()
2653 void Main::modModeLink()
2657 bool Main::settingsPDF()
2659 // Default browser is set in constructor
2661 QString text = QInputDialog::getText(
2662 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2663 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2665 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2670 bool Main::settingsURL()
2672 // Default browser is set in constructor
2674 QString text = QInputDialog::getText(
2675 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2676 settings.readEntry("/vym/mainwindow/readerURL")
2679 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2683 void Main::settingsToggleDelKey()
2685 if (actionSettingsUseDelKey->isOn())
2687 actionEditDelete->setAccel (QKeySequence (Key_Delete));
2690 actionEditDelete->setAccel (QKeySequence (""));
2694 void Main::windowToggleNoteEditor()
2696 if (textEditor->showWithMain() )
2697 windowHideNoteEditor();
2699 windowShowNoteEditor();
2702 void Main::windowToggleHistory()
2704 if (currentMapEditor())
2705 currentMapEditor()->toggleHistoryWindow();
2708 void Main::updateNoteFlag()
2710 if (currentMapEditor())
2711 currentMapEditor()->updateNoteFlag();
2714 void Main::windowShowNoteEditor()
2716 textEditor->setShowWithMain(true);
2718 actionViewToggleNoteEditor->setOn (true);
2721 void Main::windowHideNoteEditor()
2723 textEditor->setShowWithMain(false);
2725 actionViewToggleNoteEditor->setOn (false);
2728 void Main::windowNextEditor()
2730 if (tabWidget->currentPageIndex() < tabWidget->count())
2731 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2734 void Main::windowPreviousEditor()
2736 if (tabWidget->currentPageIndex() >0)
2737 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2740 void Main::standardFlagChanged()
2742 currentMapEditor()->toggleStandardFlag(sender()->name());
2745 void Main::testFunction()
2747 currentMapEditor()->testFunction();
2750 void Main::helpDoc()
2753 #if defined(Q_OS_MACX)
2754 docpath="./vym.app/Contents/vym.pdf";
2756 // default path in SUSE LINUX
2757 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2760 if (!QFile (docpath).exists() )
2762 // relative path for easy testing in tarball
2763 docpath="doc/vym.pdf";
2764 if (!QFile (docpath).exists() )
2766 // relative path for testing while still writing vym.tex
2767 docpath="doc/tex/vym.pdf";
2768 if (!QFile (docpath).exists() )
2770 // Try yet another one for Knoppix
2771 docpath="/usr/share/doc/packages/vym/vym.pdf";
2772 if (!QFile (docpath).exists() )
2774 QMessageBox::critical(0,
2775 tr("Critcal error"),
2776 tr("Couldn't find the documentation\n"
2777 "vym.pdf in various places."));
2784 Process *pdfProc = new Process();
2785 pdfProc->clearArguments();
2786 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2787 pdfProc->addArgument( docpath);
2789 if ( !pdfProc->start() )
2792 QMessageBox::warning(0,
2794 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
2795 tr("Please use Settings->")+tr("Set application to open PDF files"));
2802 void Main::helpAbout()
2805 ad.setName ("aboutwindow");
2806 ad.setMinimumSize(500,500);
2807 ad.resize (QSize (500,500));
2811 void Main::helpAboutQT()
2813 QMessageBox::aboutQt( this, "Qt Application Example" );