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 // Shortcuts to modify heading:
443 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
444 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
445 actionListBranches.append(a);
446 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
447 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
448 actionListBranches.append(a);
450 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
451 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
452 a->setEnabled (false);
454 actionListBranches.append(a);
456 // Shortcut to delete selection
457 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
458 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
459 a->setEnabled (false);
462 // Shortcut to add branch
463 alt = new QAction( tr( "Add a branch as child of selection" ),QPixmap(iconPath+"newbranch.png"),tr( "Add branch as child" ), Key_A, this, "newBranch" );
464 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
465 a = new QAction( tr( "Add a branch as child of selection" ),QPixmap(iconPath+"newbranch.png"),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
466 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
467 a->setEnabled (false);
468 actionListBranches.append(a);
469 #if defined (Q_OS_MACX)
470 // In OSX show different shortcut in menues, the keys work independtly always
471 actionEditAddBranch=alt;
473 actionEditAddBranch=a;
475 actionEditAddBranch->addTo( menu );
476 actionEditAddBranch->addTo( tb );
478 // Add branch by inserting it at selection
479 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
480 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
481 a->setEnabled (false);
482 actionListBranches.append(a);
483 actionEditAddBranchHere=a;
484 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
485 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
486 actionListBranches.append(a);
489 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
490 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
491 a->setEnabled (false);
492 actionListBranches.append(a);
493 actionEditAddBranchAbove=a;
494 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
495 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
496 actionListBranches.append(a);
499 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
500 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
501 a->setEnabled (false);
502 actionListBranches.append(a);
503 actionEditAddBranchBelow=a;
504 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
505 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
506 actionListBranches.append(a);
508 a = new QAction( tr( "Move branch up" ), QPixmap(iconPath+"up.png" ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
509 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
510 a->setEnabled (false);
515 a = new QAction( tr( "Move branch down" ), QPixmap( iconPath+"down.png"), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
516 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
517 a->setEnabled (false);
520 actionEditMoveDown=a;
523 a = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
524 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
525 alt = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_S, this, "scroll" );
526 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
527 #if defined(Q_OS_MACX)
528 actionEditToggleScroll=alt;
530 actionEditToggleScroll=a;
532 actionEditToggleScroll->setEnabled (false);
533 actionEditToggleScroll->setToggleAction(true);
534 actionEditToggleScroll->addTo( tb );
535 actionEditToggleScroll->addTo( menu );
536 actionListBranches.append(actionEditToggleScroll);
538 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
539 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
542 menu->insertSeparator();
544 a = new QAction( tr( "Find" ), QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
545 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
548 menu->insertSeparator();
550 a = new QAction( tr( "Open URL" ), QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), CTRL + Key_U, this, "url" );
551 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
553 a->setEnabled (false);
556 a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), CTRL + Key_U, this, "urltab" );
557 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
558 a->setEnabled (false);
559 actionEditOpenURLTab=a;
561 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
562 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
563 a->setEnabled (false);
564 actionListBranches.append(a);
567 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
568 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
569 a->setEnabled (false);
570 actionListBranches.append(a);
571 actionEditHeading2URL=a;
573 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
574 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
575 a->setEnabled (false);
576 actionListBranches.append(a);
577 actionEditBugzilla2URL=a;
579 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
580 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
581 a->setEnabled (false);
582 actionListBranches.append(a);
583 actionEditFATE2URL=a;
585 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" );
586 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
588 a->setEnabled (false);
589 actionEditOpenVymLink=a;
591 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
592 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
593 a->setEnabled (false);
594 actionListBranches.append(a);
597 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
598 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
599 a->setEnabled (false);
600 actionEditDeleteVymLink=a;
602 a = new QAction( tr( "Hide object in exports" ), QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), Key_H, this, "hideExport" );
603 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
604 a->setToggleAction(true);
606 a->setEnabled (false);
607 actionEditToggleHideExport=a;
609 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
610 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
611 a->setEnabled (true);
614 menu->insertSeparator();
616 // Import at selection (adding to selection)
617 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
618 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
619 a->setEnabled (false);
620 actionListBranches.append(a);
621 actionEditImportAdd=a;
623 // Import at selection (replacing selection)
624 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
625 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
626 a->setEnabled (false);
627 actionListBranches.append(a);
628 actionEditImportReplace=a;
631 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
632 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
633 a->setEnabled (false);
634 actionListBranches.append(a);
635 actionEditSaveBranch=a;
637 // Only remove branch, not its childs
638 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
639 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
640 a->setEnabled (false);
641 actionListBranches.append(a);
642 actionEditRemoveBranchKeepChilds=a;
644 // Only remove childs of a branch
645 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
646 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
647 a->setEnabled (false);
648 actionListBranches.append(a);
649 actionEditRemoveChilds=a;
651 // Shortcuts for navigating with cursor:
652 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
653 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
654 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
655 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
656 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
657 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
658 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
659 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
660 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
661 a->setEnabled (false);
663 actionListBranches.append(a);
664 actionEditSelectFirst=a;
665 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
666 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
667 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
668 a->setEnabled (false);
670 actionListBranches.append(a);
671 actionEditSelectLast=a;
673 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
674 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
675 actionEditLoadImage=a;
680 void Main::setupFormatActions()
682 QPopupMenu *menu = new QPopupMenu( this );
683 menuBar()->insertItem( tr( "F&ormat" ), menu );
685 QToolBar *tb = new QToolBar( this );
689 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
690 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
691 actionFormatColor->addTo( tb );
692 actionFormatColor->addTo( menu );
693 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" );
694 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
695 a->setEnabled (false);
698 actionListBranches.append(a);
699 actionFormatPickColor=a;
700 a= new QAction( tr( "Color branch" ), QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
701 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
702 a->setEnabled (false);
705 actionListBranches.append(a);
706 actionFormatColorBranch=a;
707 a= new QAction( tr( "Color Subtree" ), QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
708 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
709 a->setEnabled (false);
712 actionListBranches.append(a);
713 actionFormatColorSubtree=a;
715 menu->insertSeparator();
716 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
717 actionGroupFormatLinkStyles->setExclusive (true);
718 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
719 a->setToggleAction(true);
720 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
721 actionFormatLinkStyleLine=a;
722 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
723 a->setToggleAction(true);
724 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
725 actionFormatLinkStyleParabel=a;
726 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
727 a->setToggleAction(true);
728 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
729 actionFormatLinkStylePolyLine=a;
730 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
731 a->setToggleAction(true);
732 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
733 actionFormatLinkStylePolyParabel=a;
734 actionGroupFormatLinkStyles->addTo (menu);
736 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
737 actionGroupFormatFrameTypes->setExclusive (true);
738 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
739 a->setToggleAction(true);
740 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
741 actionFormatFrameNone=a;
742 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
743 a->setToggleAction(true);
744 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
745 actionFormatFrameRectangle=a;
747 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
748 a->setToggleAction(true);
749 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
750 actionFormatIncludeImagesVer=a;
752 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
753 a->setToggleAction(true);
754 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
755 actionFormatIncludeImagesHor=a;
757 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
758 a->setToggleAction(true);
759 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
760 actionFormatHideLinkUnselected=a;
762 menu->insertSeparator();
763 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
764 a->setToggleAction(true);
765 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
767 actionFormatLinkColorHint=a;
769 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
770 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
771 actionFormatLinkColor->addTo( menu );
772 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
773 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
774 actionFormatBackColor->addTo( menu );
778 void Main::setupViewActions()
780 QToolBar *tb = new QToolBar( this );
781 tb->setLabel( "View Actions" );
782 QPopupMenu *menu = new QPopupMenu( this );
783 menuBar()->insertItem( tr( "&View" ), menu );
786 a = new QAction( tr( "Zoom reset" ), QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
787 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
790 a = new QAction( tr( "Zoom in" ), QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
791 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
794 a = new QAction( tr( "Zoom out" ), QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
795 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
800 a = new QAction( tr( "Show Note Editor" ), QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ), CTRL + Key_E , this, "noteEditor" );
801 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
802 a->setToggleAction(true);
803 if (textEditor->showWithMain())
809 actionViewToggleNoteEditor=a;
811 a = new QAction( tr( "Show history window" ), QPixmap(), tr( "Show history window" ), CTRL + Key_H , this, "historyWindow" );
812 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
813 a->setToggleAction(false);
815 actionViewToggleHistoryWindow=a;
817 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
818 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
820 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
821 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
826 void Main::setupModeActions()
828 //QPopupMenu *menu = new QPopupMenu( this );
829 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
831 QToolBar *tb = new QToolBar( this );
832 tb->setLabel( tr ("Modes when using modifiers") );
834 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
835 actionGroupModModes->setExclusive (true);
836 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(iconPath+"modecolor.png"), 0, Key_J, actionGroupModModes, "modModeColor" );
837 a->setToggleAction(true);
840 actionModModeColor=a;
842 a= new QAction( tr( "Use modifier to copy" ), QPixmap(iconPath+"modecopy.png"), 0, Key_K, actionGroupModModes, "modModeCopy" );
843 a->setToggleAction(true);
847 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(iconPath+"modelink.png"), 0, Key_L, actionGroupModModes, "modModeLink" );
848 a->setToggleAction(true);
854 void Main::setupFlagActions()
856 // Create System Flags
857 systemFlagsDefault = new FlagRowObj ();
858 systemFlagsDefault->setVisibility (false);
859 systemFlagsDefault->setName ("systemFlagsDef");
861 FlagObj *fo = new FlagObj ();
862 fo->load(QPixmap(flagsPath+"flag-note.png"));
864 fo->setToolTip(tr("Note","Systemflag"));
865 systemFlagsDefault->addFlag (fo); // makes deep copy
867 fo->load(QPixmap(flagsPath+"flag-url.png"));
869 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
870 systemFlagsDefault->addFlag (fo);
872 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
873 fo->setName("vymLink");
874 fo->setToolTip(tr("Link to another vym map","Systemflag"));
875 systemFlagsDefault->addFlag (fo);
877 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
878 fo->setName("scrolledright");
879 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
880 systemFlagsDefault->addFlag (fo);
882 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
883 fo->setName("tmpUnscrolledright");
884 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
885 systemFlagsDefault->addFlag (fo);
887 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
888 fo->setName("hideInExport");
889 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
890 systemFlagsDefault->addFlag (fo);
892 // Create Standard Flags
893 standardFlagsDefault = new FlagRowObj ();
894 standardFlagsDefault->setVisibility (false);
895 standardFlagsDefault->setName ("standardFlagsDef");
897 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
898 fo->setName ("exclamationmark");
899 fo->setGroup("standard-mark");
900 fo->setToolTip(tr("Take care!","Standardflag"));
901 standardFlagsDefault->addFlag (fo); // makes deep copy
903 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
904 fo->setName("questionmark");
905 fo->setGroup("standard-mark");
906 fo->setToolTip(tr("Really?","Standardflag"));
907 standardFlagsDefault->addFlag (fo);
909 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
910 fo->setName("hook-green");
911 fo->setGroup("standard-hook");
912 fo->setToolTip(tr("ok!","Standardflag"));
913 standardFlagsDefault->addFlag (fo);
915 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
916 fo->setName("cross-red");
917 fo->setGroup("standard-hook");
918 fo->setToolTip(tr("Not ok!","Standardflag"));
919 standardFlagsDefault->addFlag (fo);
921 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
922 fo->setName("stopsign");
923 fo->setToolTip(tr("This won't work!","Standardflag"));
924 standardFlagsDefault->addFlag (fo);
926 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
927 fo->setName("smiley-good");
928 fo->setGroup("standard-smiley");
929 fo->setToolTip(tr("Good","Standardflag"));
930 standardFlagsDefault->addFlag (fo);
932 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
933 fo->setName("smiley-sad");
934 fo->setGroup("standard-smiley");
935 fo->setToolTip(tr("Bad","Standardflag"));
936 standardFlagsDefault->addFlag (fo);
938 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
939 // Original omg.png (in KDE emoticons)
940 fo->setName("smiley-omg");
941 fo->setGroup("standard-smiley");
942 fo->setToolTip(tr("Oh no!","Standardflag"));
943 standardFlagsDefault->addFlag (fo);
945 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
946 fo->setName("clock");
947 fo->setToolTip(tr("Time critical","Standardflag"));
948 standardFlagsDefault->addFlag (fo);
950 fo->load(QPixmap(flagsPath+"flag-phone.png"));
951 fo->setName("phone");
952 fo->setToolTip(tr("Call...","Standardflag"));
953 standardFlagsDefault->addFlag (fo);
955 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
957 fo->setToolTip(tr("Idea!","Standardflag"));
958 standardFlagsDefault->addFlag (fo);
960 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
961 fo->setName("arrow-up");
962 fo->setGroup("standard-arrow");
963 fo->setToolTip(tr("Important","Standardflag"));
964 standardFlagsDefault->addFlag (fo);
966 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
967 fo->setName("arrow-down");
968 fo->setGroup("standard-arrow");
969 fo->setToolTip(tr("Unimportant","Standardflag"));
970 standardFlagsDefault->addFlag (fo);
972 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
973 fo->setName("2arrow-up");
974 fo->setGroup("standard-arrow");
975 fo->setToolTip(tr("Very important!","Standardflag"));
976 standardFlagsDefault->addFlag (fo);
978 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
979 fo->setName("2arrow-down");
980 fo->setGroup("standard-arrow");
981 fo->setToolTip(tr("Very unimportant!","Standardflag"));
982 standardFlagsDefault->addFlag (fo);
984 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
985 fo->setName("thumb-up");
986 fo->setGroup("standard-thumb");
987 fo->setToolTip(tr("I like this","Standardflag"));
988 standardFlagsDefault->addFlag (fo);
990 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
991 fo->setName("thumb-down");
992 fo->setGroup("standard-thumb");
993 fo->setToolTip(tr("I like this","Standardflag"));
994 fo->setToolTip(tr("I do not like this","Standardflag"));
995 standardFlagsDefault->addFlag (fo);
997 fo->load(QPixmap(flagsPath+"flag-rose.png"));
999 fo->setToolTip(tr("Rose","Standardflag"));
1000 standardFlagsDefault->addFlag (fo);
1002 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1003 fo->setName("heart");
1004 fo->setToolTip(tr("I just love... ","Standardflag"));
1005 standardFlagsDefault->addFlag (fo);
1007 fo->load(QPixmap(flagsPath+"flag-present.png"));
1008 fo->setName("present");
1009 fo->setToolTip(tr("Surprise!","Standardflag"));
1010 standardFlagsDefault->addFlag (fo);
1012 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1013 fo->setName("flash");
1014 fo->setToolTip(tr("Dangerous","Standardflag"));
1015 standardFlagsDefault->addFlag (fo);
1017 fo->load(QPixmap(flagsPath+"flag-info.png"));
1018 // Original: xsldbg_output.png
1019 fo->setName("info");
1020 fo->setToolTip(tr("Info","Standardflag"));
1021 standardFlagsDefault->addFlag (fo);
1023 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1024 // Original khelpcenter.png
1025 fo->setName("lifebelt");
1026 fo->setToolTip(tr("This will help","Standardflag"));
1027 standardFlagsDefault->addFlag (fo);
1031 standardFlagsDefault->makeToolbar(this, "Standard Flags");
1035 void Main::setupSettingsActions()
1037 QPopupMenu *menu = new QPopupMenu( this );
1038 menuBar()->insertItem( tr( "&Settings" ), menu );
1043 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1044 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1047 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1048 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1051 menu->insertSeparator();
1052 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1053 a->setToggleAction(true);
1054 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1056 actionSettingsAutoedit=a;
1058 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1059 a->setToggleAction(true);
1060 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1062 actionSettingsAutoselectHeading=a;
1064 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1065 a->setToggleAction(true);
1066 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1068 actionSettingsAutoselectText=a;
1070 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1071 a->setToggleAction(true);
1072 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1074 actionSettingsPasteNewHeading=a;
1076 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1077 a->setToggleAction(true);
1078 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1080 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1081 actionSettingsUseDelKey=a;
1083 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1084 a->setToggleAction(true);
1085 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1087 actionSettingsUseFlagGroups=a;
1089 a= new QAction( tr( "Use hide flag during exports " ), QPixmap(), tr( "Use hide flags" ), 0, this, "hideexport" );
1090 a->setToggleAction(true);
1091 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1093 actionSettingsUseHideExport=a;
1097 void Main::setupTestActions()
1099 QPopupMenu *menu = new QPopupMenu( this );
1100 menuBar()->insertItem( tr( "&Test" ), menu );
1103 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1104 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1109 void Main::setupHelpActions()
1111 QPopupMenu *menu = new QPopupMenu( this );
1112 menuBar()->insertItem( tr( "&Help" ), menu );
1115 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1116 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1119 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1120 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1123 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1124 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1129 void Main::setupContextMenus()
1133 // Context Menu for branch or mapcenter
1134 branchContextMenu =new QPopupMenu (this);
1137 branchAddContextMenu =new QPopupMenu (this);
1138 actionEditPaste->addTo ( branchAddContextMenu );
1139 actionEditAddBranch->addTo ( branchAddContextMenu );
1140 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1141 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1142 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1143 branchAddContextMenu->insertSeparator();
1144 actionEditLoadImage->addTo( branchAddContextMenu );
1145 branchAddContextMenu->insertSeparator();
1146 actionEditImportAdd->addTo ( branchAddContextMenu );
1147 actionEditImportReplace->addTo ( branchAddContextMenu );
1150 branchRemoveContextMenu =new QPopupMenu (this);
1151 actionEditCut->addTo ( branchRemoveContextMenu );
1152 actionEditDelete->addTo ( branchRemoveContextMenu );
1153 actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu );
1154 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1156 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1157 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1159 actionEditSaveBranch->addTo( branchContextMenu );
1161 branchContextMenu->insertSeparator();
1162 actionEditOpenURL->addTo ( branchContextMenu );
1163 actionEditOpenURLTab->addTo ( branchContextMenu );
1164 actionEditURL->addTo ( branchContextMenu );
1165 actionEditHeading2URL->addTo ( branchContextMenu );
1166 actionEditBugzilla2URL->addTo( branchContextMenu );
1167 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1169 actionEditFATE2URL->addTo( branchContextMenu );
1171 branchContextMenu->insertSeparator();
1172 actionEditOpenVymLink->addTo ( branchContextMenu );
1173 actionEditVymLink->addTo ( branchContextMenu );
1174 actionEditDeleteVymLink->addTo ( branchContextMenu );
1176 branchContextMenu->insertSeparator();
1177 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1179 branchContextMenu->insertSeparator();
1180 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1181 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1182 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1184 // Context Menu for links in a branch menu
1185 // This will be populated "on demand" in MapEditor::updateActions
1186 branchContextMenu->insertSeparator();
1187 branchLinksContextMenu =new QPopupMenu (this);
1188 branchLinksContextMenuDup =new QPopupMenu (this);
1189 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1190 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1192 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1193 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1195 // Context menu for floatimage
1196 floatimageContextMenu =new QPopupMenu (this);
1197 saveImageFormatMenu=new QPopupMenu (this);
1198 exportImageFormatMenu=new QPopupMenu (this);
1200 QStrList fmt = QImage::outputFormats();
1201 for (const char* f = fmt.first(); f; f = fmt.next())
1203 saveImageFormatMenu->insertItem( f );
1204 exportImageFormatMenu->insertItem( f );
1206 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1207 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1208 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1210 floatimageContextMenu->insertSeparator();
1211 actionEditCopy->addTo( floatimageContextMenu );
1212 actionEditCut->addTo( floatimageContextMenu );
1214 /* FIXME not needed any longer
1215 floatimageContextMenu->insertSeparator();
1216 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1217 a->setToggleAction(true);
1218 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1219 a->addTo( floatimageContextMenu);
1220 actionEditToggleFloatExport=a;
1223 floatimageContextMenu->insertSeparator();
1224 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1226 exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1228 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1229 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1230 a->addTo (exportMenu);
1232 a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" );
1233 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1234 a->addTo( exportMenu );
1236 a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" );
1237 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1238 a->addTo( exportMenu );
1240 a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
1241 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1242 a->addTo (exportMenu);
1244 a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
1245 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1246 a->addTo( exportMenu );
1248 a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1249 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1250 a->addTo( exportMenu );
1252 a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" );
1253 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1254 a->addTo( exportMenu );
1256 // Context menu for canvas
1257 canvasContextMenu =new QPopupMenu (this);
1258 actionEditMapInfo->addTo( canvasContextMenu );
1259 canvasContextMenu->insertSeparator();
1260 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1261 canvasContextMenu->insertSeparator();
1262 actionFormatLinkColorHint->addTo( canvasContextMenu );
1263 actionFormatLinkColor->addTo( canvasContextMenu );
1264 actionFormatBackColor->addTo( canvasContextMenu );
1266 // Menu for last opened files
1267 // Read settings initially
1269 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1270 for (int i=1;i<=j;i++)
1272 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1273 if (!s.isEmpty() && j<=maxLastMaps)
1276 setupLastMapsMenu();
1277 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1280 void Main::setupLastMapsMenu()
1282 // Remove double entries
1283 QStringList::Iterator it=lastMaps.begin();
1284 QStringList::Iterator jt;
1285 while (it!=lastMaps.end() )
1289 while (jt!=lastMaps.end() )
1292 jt=lastMaps.remove(jt);
1299 // Limit length of list to maxLastMaps
1300 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1302 // build Menu from lastMaps string list
1303 lastMapsMenu->clear();
1304 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1305 lastMapsMenu->insertItem (*it );
1309 void Main::hideEvent (QHideEvent * )
1311 if (!textEditor->isMinimized() ) textEditor->hide();
1314 void Main::showEvent (QShowEvent * )
1316 if (textEditor->showWithMain()) textEditor->showNormal();
1319 bool Main::reallyWriteDirectory(const QString &dir)
1321 QStringList eList = QDir(dir).entryList();
1322 if (eList.first() ==".") eList.pop_front(); // remove "."
1323 if (eList.first() =="..") eList.pop_front(); // remove "."
1324 if (!eList.isEmpty())
1326 QMessageBox mb( __VYM,
1327 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1328 QMessageBox::Warning,
1330 QMessageBox::Cancel | QMessageBox::Default,
1331 QMessageBox::QMessageBox::NoButton );
1333 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1334 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1337 case QMessageBox::Yes:
1340 case QMessageBox::Cancel:
1348 QString Main::browseDirectory (const QString &caption)
1350 QFileDialog fd(this,caption);
1351 fd.setMode (QFileDialog::DirectoryOnly);
1352 fd.setCaption(__VYM " - "+caption);
1355 if ( fd.exec() == QDialog::Accepted )
1356 return fd.selectedFile();
1361 MapEditor* Main::currentMapEditor() const
1363 if ( tabWidget->currentPage() &&
1364 tabWidget->currentPage()->inherits( "MapEditor" ) )
1365 return (MapEditor*)tabWidget->currentPage();
1369 //TODO not used now, maybe use this for overview window later
1370 void Main::newView()
1372 // Open a new view... have it delete when closed.
1373 Main *m = new Main(0, 0, WDestructiveClose);
1374 qApp->setMainWidget(m);
1376 qApp->setMainWidget(0);
1379 void Main::editorChanged(QWidget *)
1381 // Unselect all possibly selected objects
1382 // (Important to update note editor)
1385 for (i=0;i<=tabWidget->count() -1;i++)
1388 me=(MapEditor*)tabWidget->page(i);
1391 currentMapEditor()->reselect();
1393 // Update actions to in menus and toolbars according to editor
1394 currentMapEditor()->updateActions();
1397 void Main::fileNew()
1399 QString fn="unnamed";
1400 MapEditor* medit = new MapEditor (tabWidget, true);
1401 tabWidget->addTab (medit,fn);
1402 tabWidget->showPage(medit);
1403 medit->viewport()->setFocus();
1404 // For the very first map we do not have flagrows yet...
1405 medit->select("mc:");
1408 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1410 ErrorCode err=success;
1412 // fn is usually the archive, mapfile the file after uncompressing
1415 // Make fn absolute (needed for unzip)
1416 fn=QDir (fn).absPath();
1422 // Check, if map is already loaded
1424 while (i<=tabWidget->count() -1)
1426 me=(MapEditor*)tabWidget->page(i);
1427 if (me->getFilePath() == fn)
1429 // Already there, ask for confirmation
1430 QMessageBox mb( __VYM,
1431 tr("The map %1\nis already opened."
1432 "Opening the same map in multiple editors may lead \n"
1433 "to confusion when finishing working with vym."
1434 "Do you want to").arg(fn),
1435 QMessageBox::Warning,
1436 QMessageBox::Yes | QMessageBox::Default,
1437 QMessageBox::Cancel | QMessageBox::Escape,
1438 QMessageBox::QMessageBox::NoButton);
1439 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1440 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1443 case QMessageBox::Yes:
1445 i=tabWidget->count();
1447 case QMessageBox::Cancel:
1459 if ( !fn.isEmpty() )
1461 me = currentMapEditor();
1462 int tabIndex=tabWidget->currentPageIndex();
1463 // Check first, if mapeditor exists
1464 // If it is not default AND we want a new map,
1465 // create a new mapeditor in a new tab
1466 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1468 me = new MapEditor (tabWidget,true);
1469 tabWidget->addTab (me,fn);
1470 tabIndex=tabWidget->indexOf (me);
1471 tabWidget->setCurrentPage (tabIndex);
1474 // Check, if file exists (important for creating new files
1475 // from command line
1476 if (!QFile(fn).exists() )
1478 QMessageBox mb( __VYM,
1479 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1480 QMessageBox::Question,
1482 QMessageBox::Cancel | QMessageBox::Default,
1483 QMessageBox::QMessageBox::NoButton );
1485 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1486 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1489 case QMessageBox::Yes:
1491 currentMapEditor()->setFilePath(fn);
1492 tabWidget->setTabLabel (currentMapEditor(),
1493 currentMapEditor()->getFileName() );
1494 statusBar()->message( "Created " + fn , statusbarTime );
1497 case QMessageBox::Cancel:
1498 // don't create new map
1499 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1506 //tabWidget->currentPage() won't be NULL here, because of above...
1507 tabWidget->showPage(me);
1508 me->viewport()->setFocus();
1510 // Create temporary directory for packing
1511 char tmpdir1[]="/tmp/vym-XXXXXX";
1512 QString tmpMapDir=mkdtemp(tmpdir1);
1514 // Try to unzip file
1515 err=unzipDir (tmpMapDir,fn);
1519 me->setZipped(false);
1522 me->setZipped(true);
1524 // Look for mapname.xml
1525 mapfile= fn.left(fn.findRev(".",-1,true));
1526 mapfile=mapfile.section( '/', -1 );
1527 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1528 if (!file.exists() )
1530 // mapname.xml does not exist, well,
1531 // maybe some renamed the mapname.vym file...
1532 // Try to find any .xml in the toplevel
1533 // directory of the .vym file
1534 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1535 if (flist.count()==1)
1537 // Only one entry, take this one
1538 mapfile=tmpMapDir + "/"+flist.first();
1541 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1542 *it=tmpMapDir + "/" + *it;
1543 // TODO Multiple entries, load all (but only the first one into this ME)
1544 //mainWindow->fileLoadFromTmp (flist);
1545 //returnCode=1; // Silently forget this attempt to load
1546 qWarning ("MainWindow::load (fn) multimap found...");
1549 if (flist.isEmpty() )
1551 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1552 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1555 } //file doesn't exist
1557 mapfile=file.name();
1562 // Save existing filename in case we import
1563 QString fn_org=me->getFilePath();
1565 // Finally load map into mapEditor
1566 me->setFilePath (mapfile,fn);
1567 err=me->load(mapfile,lmode);
1569 // Restore old (maybe empty) filepath, if this is an import
1571 me->setFilePath (fn_org);
1574 // Finally check for errors and go home
1577 if (lmode==NewMap) fileCloseMap();
1578 statusBar()->message( "Could not load " + fn, statusbarTime );
1583 me->setFilePath (fn);
1584 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1585 if (fn.left(9)!="/tmp/vym-")
1587 // Only append to lastMaps if not loaded from a tmpDir
1588 // e.g. imported bookmarks are in a tmpDir
1589 lastMaps.prepend(me->getFilePath() );
1590 setupLastMapsMenu();
1592 actionFilePrint->setEnabled (true);
1594 statusBar()->message( "Loaded " + fn, statusbarTime );
1598 removeDir (QDir(tmpMapDir));
1604 void Main::fileLoad(const LoadMode &lmode)
1606 QFileDialog *fd=new QFileDialog( this);
1607 if (!lastFileDir.isEmpty())
1608 fd->setDir (lastFileDir);
1609 fd->setMode (QFileDialog::ExistingFiles);
1610 fd->addFilter ("XML (*.xml)");
1611 fd->addFilter ("VYM map (*.vym *.vyp)");
1615 fd->setCaption(tr("Load vym map"));
1618 fd->setCaption(tr("Import: Add vym map to selection"));
1621 fd->setCaption(tr("Import: Replace selection with vym map"));
1627 if ( fd->exec() == QDialog::Accepted )
1629 lastFileDir=fd->dirPath();
1630 QStringList flist = fd->selectedFiles();
1631 QStringList::Iterator it = flist.begin();
1632 while( it != flist.end() )
1635 fileLoad(*it, lmode);
1642 void Main::fileLoad()
1647 void Main::fileLoadLast(int i)
1649 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1652 void Main::fileSave(const SaveMode &savemode)
1654 // tmp dir for zipping
1658 ErrorCode err=success;
1660 QString safeFilePath;
1662 bool saveZipped=currentMapEditor()->saveZipped();
1664 MapEditor * me=currentMapEditor();
1667 QString fn=me->getFilePath();
1668 // filename=unnamed, filepath="" in constructor...
1669 if ( !fn.isEmpty() )
1671 // We have a filepath, go on saving
1672 // First remove existing file, we
1673 // don't want to add to old zip archives
1677 QMessageBox::warning( 0, tr( "Save Error" ),
1678 fn+ tr("\ncould not be removed before saving"));
1680 // Look, if we should zip the data:
1683 QMessageBox mb( __VYM,
1684 tr("The map %1\ndid not use the compressed "
1685 "vym file format.\nWriting it uncompressed will also write images \n"
1686 "and flags and thus may overwrite files in the "
1687 "given directory\n\nDo you want to write the map").arg(fn),
1688 QMessageBox::Warning,
1689 QMessageBox::Yes | QMessageBox::Default,
1691 QMessageBox::Cancel | QMessageBox::Escape);
1692 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1693 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1694 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1697 case QMessageBox::Yes:
1698 // save compressed (default file format)
1701 case QMessageBox::No:
1702 // save uncompressed
1705 case QMessageBox::Cancel:
1714 char tmpdir1[]="/tmp/vym-XXXXXX";
1715 tmpMapDir=mkdtemp(tmpdir1);
1717 safeFilePath=me->getFilePath();
1718 me->setFilePath (tmpMapDir+"/"+
1719 me->getMapName()+ ".xml",
1721 me->save (savemode);
1722 me->setFilePath (safeFilePath);
1724 zipDir (tmpMapDir,fn);
1729 safeFilePath=me->getFilePath();
1730 me->setFilePath (fn, safeFilePath);
1731 me->save (savemode);
1732 me->setFilePath (safeFilePath);
1734 } // filepath available
1737 // We have no filepath yet,
1738 // call fileSaveAs() now, this will call fileSave()
1740 fileSaveAs(savemode);
1744 if (saveZipped && !tmpMapDir.isEmpty())
1746 removeDir (QDir(tmpMapDir));
1750 statusBar()->message(
1751 tr("Saved %1").arg(me->getFilePath()),
1753 lastMaps.prepend(me->getFilePath() );
1754 setupLastMapsMenu();
1756 statusBar()->message(
1757 tr("Couldn't save ").arg(me->getFilePath()),
1761 void Main::fileSave()
1763 fileSave (CompleteMap);
1766 void Main::fileSaveAs(const SaveMode& savemode)
1770 if (currentMapEditor())
1772 if (savemode==CompleteMap)
1773 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1775 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1776 if ( !fn.isEmpty() )
1778 // Check for existing file
1779 if (QFile (fn).exists())
1781 QMessageBox mb( __VYM,
1782 tr("The file %1\nexists already. Do you want to").arg(fn),
1783 QMessageBox::Warning,
1784 QMessageBox::Yes | QMessageBox::Default,
1785 QMessageBox::Cancel | QMessageBox::Escape,
1786 QMessageBox::QMessageBox::NoButton);
1787 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1788 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1791 case QMessageBox::Yes:
1794 case QMessageBox::Cancel:
1801 // New file, add extension to filename, if missing
1802 // This is always .vym or .vyp, depending on savemode
1803 if (savemode==CompleteMap)
1805 if (!fn.contains (".vym") && !fn.contains (".xml"))
1809 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1818 currentMapEditor()->setFilePath(fn);
1822 if (savemode==CompleteMap)
1823 tabWidget->setTabLabel (currentMapEditor(),
1824 currentMapEditor()->getFileName() );
1830 void Main::fileSaveAs()
1832 fileSaveAs (CompleteMap);
1835 void Main::fileImportKDEBookmarks()
1837 ImportKDEBookmarks im;
1839 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1840 currentMapEditor()->setFilePath ("");
1843 void Main::fileImportFirefoxBookmarks()
1845 QFileDialog *fd=new QFileDialog( this);
1846 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
1847 fd->setMode (QFileDialog::ExistingFiles);
1848 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
1849 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
1852 if ( fd->exec() == QDialog::Accepted )
1854 ImportFirefoxBookmarks im;
1855 QStringList flist = fd->selectedFiles();
1856 QStringList::Iterator it = flist.begin();
1857 while( it != flist.end() )
1860 if (im.transform() &&
1861 success==fileLoad (im.getTransformedFile(),NewMap) &&
1862 currentMapEditor() )
1863 currentMapEditor()->setFilePath ("");
1870 void Main::fileImportMM()
1874 QFileDialog *fd=new QFileDialog( this);
1875 if (!lastFileDir.isEmpty())
1876 fd->setDir (lastFileDir);
1877 fd->setMode (QFileDialog::ExistingFiles);
1878 fd->addFilter ("Mind Manager (*.mmap)");
1879 fd->setCaption(tr("Import")+" "+"Mind Manager");
1882 if ( fd->exec() == QDialog::Accepted )
1884 lastFileDir=fd->dirPath();
1885 QStringList flist = fd->selectedFiles();
1886 QStringList::Iterator it = flist.begin();
1887 while( it != flist.end() )
1890 if (im.transform() &&
1891 success==fileLoad (im.getTransformedFile(),NewMap) &&
1892 currentMapEditor() )
1893 currentMapEditor()->setFilePath ("");
1902 void Main::fileImportDir()
1904 if (currentMapEditor())
1905 currentMapEditor()->importDir();
1908 void Main::fileExportXML()
1910 if (currentMapEditor())
1912 QString dir=browseDirectory(tr("Export XML to directory"));
1913 if (dir !="" && reallyWriteDirectory(dir) )
1914 currentMapEditor()->exportXML(dir);
1919 void Main::fileExportXHTML()
1921 MapEditor *me=currentMapEditor();
1925 ExportXHTMLDialog dia(this);
1926 dia.setFilePath (me->getFilePath() );
1927 dia.setMapName (me->getMapName() );
1930 if (dia.exec()==QDialog::Accepted)
1932 QString dir=dia.getDir();
1933 // Check, if warnings should be used before overwriting
1934 // the output directory
1937 ok=reallyWriteDirectory(dir);
1943 me->exportXML (dia.getDir() );
1944 dia.doExport(me->getMapName() );
1945 if (dia.hasChanged())
1952 void Main::fileExportImage(int item)
1954 MapEditor *me=currentMapEditor();
1957 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1959 if ( !fn.isEmpty() )
1960 me->exportImage(fn,item);
1962 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1967 void Main::fileExportASCII()
1969 MapEditor *me=currentMapEditor();
1973 ex.setMapCenter(me->getMapCenter());
1974 ex.addFilter ("TXT (*.txt)");
1975 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1976 if (ex.execDialog() )
1978 me->setExportMode(true);
1980 me->setExportMode(false);
1985 void Main::fileExportLaTeX()
1987 MapEditor *me=currentMapEditor();
1991 ex.setMapCenter(me->getMapCenter());
1992 ex.addFilter ("Tex (*.tex)");
1993 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1994 if (ex.execDialog() )
1996 me->setExportMode(true);
1998 me->setExportMode(false);
2003 void Main::fileExportKDEBookmarks()
2005 ExportKDEBookmarks ex;
2006 MapEditor *me=currentMapEditor();
2009 ex.setMapCenter (me->getMapCenter() );
2014 void Main::fileExportTaskjuggler()
2016 ExportTaskjuggler ex;
2017 MapEditor *me=currentMapEditor();
2020 ex.setMapCenter (me->getMapCenter() );
2021 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2022 ex.addFilter ("Taskjuggler (*.tjp)");
2023 if (ex.execDialog() )
2025 me->setExportMode(true);
2027 me->setExportMode(false);
2032 void Main::fileExportOOPresentation()
2034 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2035 // FIXME add extra info in dialog
2036 //ImagePreview *p =new ImagePreview (fd);
2037 //fd->setContentsPreviewEnabled( TRUE );
2038 //fd->setContentsPreview( p, p );
2039 //fd->setPreviewMode( QFileDialog::Contents );
2040 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2041 //fd->setDir (lastImageDir);
2042 if (fd->foundConfig())
2046 if ( fd->exec() == QDialog::Accepted )
2048 QString fn=fd->selectedFile();
2049 //lastImageDir=fn.left(fn.findRev ("/"));
2050 if (currentMapEditor())
2051 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2055 QMessageBox::warning(0,
2057 tr("Couldn't find configuration for export to Open Office\n"));
2061 void Main::fileCloseMap()
2063 if (currentMapEditor())
2065 if (currentMapEditor()->hasChanged())
2067 QMessageBox mb( __VYM,
2068 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2069 QMessageBox::Warning,
2070 QMessageBox::Yes | QMessageBox::Default,
2072 QMessageBox::Cancel | QMessageBox::Escape );
2073 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2074 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2077 case QMessageBox::Yes:
2079 fileSave(CompleteMap);
2081 case QMessageBox::No:
2082 // close without saving
2084 case QMessageBox::Cancel:
2089 currentMapEditor()->closeMap();
2090 tabWidget->removePage(currentMapEditor());
2091 if (tabWidget->count()==0)
2092 actionFilePrint->setEnabled (false);
2096 void Main::filePrint()
2098 if (currentMapEditor())
2099 currentMapEditor()->print();
2102 void Main::fileExitVYM()
2104 // Check if one or more editors have changed
2107 for (i=0;i<=tabWidget->count() -1;i++)
2110 me=(MapEditor*)tabWidget->page(i);
2112 // If something changed, ask what to do
2113 if (me->isUnsaved())
2115 tabWidget->setCurrentPage(i);
2116 QMessageBox mb( __VYM,
2117 tr("This map is not saved yet. Do you want to"),
2118 QMessageBox::Warning,
2119 QMessageBox::Yes | QMessageBox::Default,
2121 QMessageBox::Cancel | QMessageBox::Escape );
2122 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2123 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2125 // Call undocumented function: setActiveWindow is only
2126 // possible, if widget is visible. This depends on
2128 #if defined(Q_OS_LINUX)
2129 qt_wait_for_window_manager( this);
2131 mb.setActiveWindow();
2132 switch( mb.exec() ) {
2133 case QMessageBox::Yes:
2134 // save (the changed editors) and exit
2135 fileSave(CompleteMap);
2137 case QMessageBox::No:
2138 // exit without saving
2140 case QMessageBox::Cancel:
2141 // don't save and don't exit
2145 } // loop over all MEs
2149 void Main::editUndo()
2151 if (currentMapEditor())
2152 currentMapEditor()->undo();
2155 void Main::editRedo()
2157 if (currentMapEditor())
2158 currentMapEditor()->redo();
2161 void Main::editCopy()
2163 if (currentMapEditor())
2164 currentMapEditor()->copy();
2167 void Main::editPaste()
2169 if (currentMapEditor())
2170 currentMapEditor()->paste();
2173 void Main::editCut()
2175 if (currentMapEditor())
2176 currentMapEditor()->cut();
2179 void Main::editOpenFindWindow()
2181 findWindow->popup();
2182 findWindow->raise();
2184 // Call undocumented function: setActiveWindow is only
2185 // possible, if widget is visible. This depends on
2187 #if defined(Q_OS_LINUX)
2188 qt_wait_for_window_manager( this);
2190 findWindow->setActiveWindow();
2193 void Main::editFind(QString s)
2196 BranchObj *bo=currentMapEditor()->findText(s, cs);
2199 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2202 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2203 tr("No matches found for \"%1\"").arg(s));
2207 void Main::editFindChanged()
2208 { // Notify editor, to abort the current find process
2209 currentMapEditor()->findReset();
2212 void Main::editOpenURL()
2215 if (currentMapEditor())
2217 QString url=currentMapEditor()->getURL();
2218 if (url=="") return;
2219 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2220 procBrowser = new QProcess( this );
2222 procBrowser->addArgument( browser);
2223 procBrowser->addArgument( url);
2225 if ( !procBrowser->start() )
2227 // try to set path to browser
2228 QMessageBox::warning(0,
2230 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2231 tr("Please use Settings->")+tr("Set application to open an URL"));
2236 void Main::editOpenURLTab()
2238 if (currentMapEditor())
2240 QString url=currentMapEditor()->getURL();
2241 if (url=="") return;
2242 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2243 if (procBrowser && procBrowser->isRunning())
2245 if (browser.contains("konqueror"))
2247 // Try to open new tab in existing konqueror started previously by vym
2248 QProcess *p=new QProcess (this);
2249 p->addArgument ("dcop");
2250 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2251 p->addArgument ("konqueror-mainwindow#1");
2252 p->addArgument ("newTab");
2253 p->addArgument (url);
2255 // try to set browser
2256 QMessageBox::warning(0,
2258 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2260 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2262 // Try to open new tab in firefox
2263 QProcess *p=new QProcess (this);
2264 p->addArgument (browser);
2265 p->addArgument ("-remote");
2266 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2268 // try to set browser
2269 QMessageBox::warning(0,
2271 tr("Couldn't start %1 to open a new tab").arg(browser));
2280 void Main::editURL()
2282 if (currentMapEditor())
2283 currentMapEditor()->editURL();
2286 void Main::editHeading2URL()
2288 if (currentMapEditor())
2289 currentMapEditor()->editHeading2URL();
2292 void Main::editBugzilla2URL()
2294 if (currentMapEditor())
2295 currentMapEditor()->editBugzilla2URL();
2298 void Main::editFATE2URL()
2300 if (currentMapEditor())
2301 currentMapEditor()->editFATE2URL();
2304 void Main::editOpenVymLink()
2306 // Get current path to map
2307 QString currentVymLink;
2308 if (currentMapEditor())
2310 currentVymLink=currentMapEditor()->getVymLink();
2311 // compare path with already loaded maps
2315 for (i=0;i<=tabWidget->count() -1;i++)
2317 me=(MapEditor*)tabWidget->page(i);
2318 if (currentVymLink==me->getFilePath() )
2327 if (!QFile(currentVymLink).exists() )
2328 QMessageBox::critical( 0, tr( "Critical Error" ),
2329 tr("Couldn't open map %1").arg(currentVymLink));
2332 fileLoad (currentVymLink, NewMap);
2333 tabWidget->setCurrentPage (tabWidget->count()-1);
2336 // Go to tab containing the map
2337 tabWidget->setCurrentPage (index);
2341 void Main::editVymLink()
2343 if (currentMapEditor())
2344 currentMapEditor()->editVymLink();
2347 void Main::editDeleteVymLink()
2349 if (currentMapEditor())
2350 currentMapEditor()->deleteVymLink();
2353 void Main::editToggleHideExport()
2355 if (currentMapEditor())
2356 currentMapEditor()->toggleHideExport();
2359 void Main::editMapInfo()
2361 if (currentMapEditor())
2362 currentMapEditor()->editMapInfo();
2365 void Main::editMoveUp()
2367 if (currentMapEditor())
2368 currentMapEditor()->moveBranchUp();
2371 void Main::editMoveDown()
2373 if (currentMapEditor())
2374 currentMapEditor()->moveBranchDown();
2377 void Main::editToggleScroll()
2379 if (currentMapEditor())
2381 currentMapEditor()->toggleScroll();
2385 void Main::editUnScrollAll()
2387 if (currentMapEditor())
2389 currentMapEditor()->unScrollAll();
2393 void Main::editHeading()
2395 if (currentMapEditor())
2396 currentMapEditor()->editHeading();
2399 void Main::editNewBranch()
2401 if (currentMapEditor())
2402 currentMapEditor()->addNewBranch(0);
2405 void Main::editNewBranchHere()
2407 if (currentMapEditor())
2408 currentMapEditor()->addNewBranchHere();
2411 void Main::editNewBranchAbove()
2413 if (currentMapEditor())
2414 currentMapEditor()->addNewBranch(-1);
2417 void Main::editNewBranchBelow()
2419 if (currentMapEditor())
2420 currentMapEditor()->addNewBranch(1);
2423 void Main::editImportAdd()
2425 fileLoad (ImportAdd);
2428 void Main::editImportReplace()
2430 fileLoad (ImportReplace);
2433 void Main::editSaveBranch()
2435 fileSaveAs (PartOfMap);
2438 void Main::editRemoveBranchKeepChilds()
2440 if (currentMapEditor())
2441 currentMapEditor()->removeBranchKeepChilds();
2444 void Main::editRemoveChilds()
2446 if (currentMapEditor())
2447 currentMapEditor()->removeChilds();
2450 void Main::editDeleteSelection()
2452 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2453 currentMapEditor()->deleteSelection();
2456 void Main::editUpperBranch()
2458 if (currentMapEditor())
2459 currentMapEditor()->selectUpperBranch();
2462 void Main::editLowerBranch()
2464 if (currentMapEditor())
2465 currentMapEditor()->selectLowerBranch();
2468 void Main::editLeftBranch()
2470 if (currentMapEditor())
2471 currentMapEditor()->selectLeftBranch();
2474 void Main::editRightBranch()
2476 if (currentMapEditor())
2477 currentMapEditor()->selectRightBranch();
2480 void Main::editFirstBranch()
2482 if (currentMapEditor())
2483 currentMapEditor()->selectFirstBranch();
2486 void Main::editLastBranch()
2488 if (currentMapEditor())
2489 currentMapEditor()->selectLastBranch();
2492 void Main::editLoadImage()
2494 if (currentMapEditor())
2495 currentMapEditor()->loadFloatImage();
2498 void Main::editSaveImage(int item)
2500 if (currentMapEditor())
2501 currentMapEditor()->saveFloatImage(item);
2504 void Main::editFollowXLink(int item)
2506 if (currentMapEditor())
2507 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2510 void Main::editEditXLink(int item)
2512 if (currentMapEditor())
2513 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2516 void Main::formatSelectColor()
2518 if (currentMapEditor())
2520 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2521 if ( !col.isValid() ) return;
2522 currentMapEditor()->setColor( col );
2523 colorChanged( col );
2527 void Main::formatPickColor()
2529 if (currentMapEditor())
2530 colorChanged( currentMapEditor()->pickColor() );
2533 void Main::colorChanged(QColor c)
2535 QPixmap pix( 16, 16 );
2537 actionFormatColor->setIconSet( pix );
2540 void Main::formatColorItem()
2542 if (currentMapEditor())
2543 currentMapEditor()->colorItem();
2546 void Main::formatColorBranch()
2548 if (currentMapEditor())
2549 currentMapEditor()->colorBranch();
2552 void Main::formatLinkStyleLine()
2554 if (currentMapEditor())
2555 currentMapEditor()->setLinkStyle(StyleLine);
2558 void Main::formatLinkStyleParabel()
2560 if (currentMapEditor())
2561 currentMapEditor()->setLinkStyle(StyleParabel);
2564 void Main::formatLinkStylePolyLine()
2566 if (currentMapEditor())
2567 currentMapEditor()->setLinkStyle(StylePolyLine);
2570 void Main::formatLinkStylePolyParabel()
2572 if (currentMapEditor())
2573 currentMapEditor()->setLinkStyle(StylePolyParabel);
2576 void Main::formatSelectBackColor()
2578 if (currentMapEditor())
2579 currentMapEditor()->selectBackgroundColor();
2582 void Main::formatSelectLinkColor()
2584 if (currentMapEditor())
2585 currentMapEditor()->selectLinkColor();
2588 void Main::formatToggleLinkColorHint()
2590 currentMapEditor()->toggleLinkColorHint();
2593 void Main::formatFrameNone()
2595 if (currentMapEditor())
2596 currentMapEditor()->setFrame(NoFrame);
2599 void Main::formatFrameRectangle()
2601 if (currentMapEditor())
2602 currentMapEditor()->setFrame(Rectangle);
2605 void Main::formatIncludeImagesVer()
2607 if (currentMapEditor())
2608 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2611 void Main::formatIncludeImagesHor()
2613 if (currentMapEditor())
2614 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2617 void Main::formatHideLinkUnselected()
2619 if (currentMapEditor())
2620 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2623 void Main::viewZoomReset()
2625 if (currentMapEditor())
2629 currentMapEditor()->setWorldMatrix( m );
2630 currentMapEditor()->setViewCenter();
2631 currentMapEditor()->adjustCanvasSize();
2635 void Main::viewZoomIn()
2637 if (currentMapEditor())
2639 QWMatrix m = currentMapEditor()->worldMatrix();
2640 m.scale( 1.25, 1.25 );
2641 currentMapEditor()->setWorldMatrix( m );
2642 currentMapEditor()->setViewCenter();
2643 currentMapEditor()->adjustCanvasSize();
2647 void Main::viewZoomOut()
2649 if (currentMapEditor())
2651 QWMatrix m = currentMapEditor()->worldMatrix();
2652 m.scale( 0.8, 0.8 );
2653 currentMapEditor()->setWorldMatrix( m );
2654 currentMapEditor()->setViewCenter();
2655 currentMapEditor()->adjustCanvasSize();
2659 void Main::modModeColor()
2663 void Main::modModeLink()
2667 bool Main::settingsPDF()
2669 // Default browser is set in constructor
2671 QString text = QInputDialog::getText(
2672 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2673 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2675 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2680 bool Main::settingsURL()
2682 // Default browser is set in constructor
2684 QString text = QInputDialog::getText(
2685 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2686 settings.readEntry("/vym/mainwindow/readerURL")
2689 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2693 void Main::settingsToggleDelKey()
2695 if (actionSettingsUseDelKey->isOn())
2697 actionEditDelete->setAccel (QKeySequence (Key_Delete));
2700 actionEditDelete->setAccel (QKeySequence (""));
2704 void Main::windowToggleNoteEditor()
2706 if (textEditor->showWithMain() )
2707 windowHideNoteEditor();
2709 windowShowNoteEditor();
2712 void Main::windowToggleHistory()
2714 if (currentMapEditor())
2715 currentMapEditor()->toggleHistoryWindow();
2718 void Main::updateNoteFlag()
2720 if (currentMapEditor())
2721 currentMapEditor()->updateNoteFlag();
2724 void Main::windowShowNoteEditor()
2726 textEditor->setShowWithMain(true);
2728 actionViewToggleNoteEditor->setOn (true);
2731 void Main::windowHideNoteEditor()
2733 textEditor->setShowWithMain(false);
2735 actionViewToggleNoteEditor->setOn (false);
2738 void Main::windowNextEditor()
2740 if (tabWidget->currentPageIndex() < tabWidget->count())
2741 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2744 void Main::windowPreviousEditor()
2746 if (tabWidget->currentPageIndex() >0)
2747 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2750 void Main::standardFlagChanged()
2752 currentMapEditor()->toggleStandardFlag(sender()->name());
2755 void Main::testFunction()
2757 currentMapEditor()->testFunction();
2760 void Main::helpDoc()
2763 #if defined(Q_OS_MACX)
2764 docpath="./vym.app/Contents/vym.pdf";
2766 // default path in SUSE LINUX
2767 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2770 if (!QFile (docpath).exists() )
2772 // relative path for easy testing in tarball
2773 docpath="doc/vym.pdf";
2774 if (!QFile (docpath).exists() )
2776 // relative path for testing while still writing vym.tex
2777 docpath="doc/tex/vym.pdf";
2778 if (!QFile (docpath).exists() )
2780 // Try yet another one for Knoppix
2781 docpath="/usr/share/doc/packages/vym/vym.pdf";
2782 if (!QFile (docpath).exists() )
2784 QMessageBox::critical(0,
2785 tr("Critcal error"),
2786 tr("Couldn't find the documentation\n"
2787 "vym.pdf in various places."));
2794 Process *pdfProc = new Process();
2795 pdfProc->clearArguments();
2796 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2797 pdfProc->addArgument( docpath);
2799 if ( !pdfProc->start() )
2802 QMessageBox::warning(0,
2804 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
2805 tr("Please use Settings->")+tr("Set application to open PDF files"));
2812 void Main::helpAbout()
2815 ad.setName ("aboutwindow");
2816 ad.setMinimumSize(500,500);
2817 ad.resize (QSize (500,500));
2821 void Main::helpAboutQT()
2823 QMessageBox::aboutQt( this, "Qt Application Example" );