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( tb );
477 // Add branch by inserting it at selection
478 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
479 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
480 a->setEnabled (false);
481 actionListBranches.append(a);
482 actionEditAddBranchHere=a;
483 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
484 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
485 actionListBranches.append(a);
488 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
489 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
490 a->setEnabled (false);
491 actionListBranches.append(a);
492 actionEditAddBranchAbove=a;
493 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
494 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
495 actionListBranches.append(a);
498 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
499 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
500 a->setEnabled (false);
501 actionListBranches.append(a);
502 actionEditAddBranchBelow=a;
503 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
504 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
505 actionListBranches.append(a);
507 a = new QAction( tr( "Move branch up" ), QPixmap(iconPath+"up.png" ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
508 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
509 a->setEnabled (false);
514 a = new QAction( tr( "Move branch down" ), QPixmap( iconPath+"down.png"), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
515 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
516 a->setEnabled (false);
519 actionEditMoveDown=a;
522 a = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
523 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
524 alt = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_S, this, "scroll" );
525 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
526 #if defined(Q_OS_MACX)
527 actionEditToggleScroll=alt;
529 actionEditToggleScroll=a;
531 actionEditToggleScroll->setEnabled (false);
532 actionEditToggleScroll->setToggleAction(true);
533 actionEditToggleScroll->addTo( tb );
534 actionEditToggleScroll->addTo( menu );
535 actionListBranches.append(actionEditToggleScroll);
537 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
538 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
541 menu->insertSeparator();
543 a = new QAction( tr( "Find" ), QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
544 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
547 menu->insertSeparator();
549 a = new QAction( tr( "Open URL" ), QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), CTRL + Key_U, this, "url" );
550 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
552 a->setEnabled (false);
555 a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), CTRL + Key_U, this, "urltab" );
556 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
557 a->setEnabled (false);
558 actionEditOpenURLTab=a;
560 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
561 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
562 a->setEnabled (false);
563 actionListBranches.append(a);
566 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
567 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
568 a->setEnabled (false);
569 actionListBranches.append(a);
570 actionEditHeading2URL=a;
572 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
573 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
574 a->setEnabled (false);
575 actionListBranches.append(a);
576 actionEditBugzilla2URL=a;
578 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
579 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
580 a->setEnabled (false);
581 actionListBranches.append(a);
582 actionEditFATE2URL=a;
584 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" );
585 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
587 a->setEnabled (false);
588 actionEditOpenVymLink=a;
590 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
591 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
592 a->setEnabled (false);
593 actionListBranches.append(a);
596 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
597 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
598 a->setEnabled (false);
599 actionEditDeleteVymLink=a;
601 a = new QAction( tr( "Hide object in exports" ), QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), Key_H, this, "hideExport" );
602 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
603 a->setToggleAction(true);
605 a->setEnabled (false);
606 actionEditToggleHideExport=a;
608 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
609 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
610 a->setEnabled (true);
613 menu->insertSeparator();
615 // Import at selection (adding to selection)
616 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
617 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
618 a->setEnabled (false);
619 actionListBranches.append(a);
620 actionEditImportAdd=a;
622 // Import at selection (replacing selection)
623 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
624 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
625 a->setEnabled (false);
626 actionListBranches.append(a);
627 actionEditImportReplace=a;
630 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
631 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 actionEditSaveBranch=a;
636 // Only remove branch, not its childs
637 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
638 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
639 a->setEnabled (false);
640 actionListBranches.append(a);
641 actionEditRemoveBranchKeepChilds=a;
643 // Only remove childs of a branch
644 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
645 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
646 a->setEnabled (false);
647 actionListBranches.append(a);
648 actionEditRemoveChilds=a;
650 // Shortcuts for navigating with cursor:
651 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
652 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
653 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
654 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
655 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
656 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
657 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
658 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
659 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
660 a->setEnabled (false);
662 actionListBranches.append(a);
663 actionEditSelectFirst=a;
664 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
665 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
666 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
667 a->setEnabled (false);
669 actionListBranches.append(a);
670 actionEditSelectLast=a;
672 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
673 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
674 actionEditLoadImage=a;
679 void Main::setupFormatActions()
681 QPopupMenu *menu = new QPopupMenu( this );
682 menuBar()->insertItem( tr( "F&ormat" ), menu );
684 QToolBar *tb = new QToolBar( this );
688 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
689 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
690 actionFormatColor->addTo( tb );
691 actionFormatColor->addTo( menu );
692 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" );
693 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
694 a->setEnabled (false);
697 actionListBranches.append(a);
698 actionFormatPickColor=a;
699 a= new QAction( tr( "Color branch" ), QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
700 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
701 a->setEnabled (false);
704 actionListBranches.append(a);
705 actionFormatColorBranch=a;
706 a= new QAction( tr( "Color Subtree" ), QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
707 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
708 a->setEnabled (false);
711 actionListBranches.append(a);
712 actionFormatColorSubtree=a;
714 menu->insertSeparator();
715 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
716 actionGroupFormatLinkStyles->setExclusive (true);
717 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
718 a->setToggleAction(true);
719 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
720 actionFormatLinkStyleLine=a;
721 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
722 a->setToggleAction(true);
723 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
724 actionFormatLinkStyleParabel=a;
725 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
726 a->setToggleAction(true);
727 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
728 actionFormatLinkStylePolyLine=a;
729 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
730 a->setToggleAction(true);
731 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
732 actionFormatLinkStylePolyParabel=a;
733 actionGroupFormatLinkStyles->addTo (menu);
735 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
736 actionGroupFormatFrameTypes->setExclusive (true);
737 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
738 a->setToggleAction(true);
739 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
740 actionFormatFrameNone=a;
741 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
742 a->setToggleAction(true);
743 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
744 actionFormatFrameRectangle=a;
746 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
747 a->setToggleAction(true);
748 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
749 actionFormatIncludeImagesVer=a;
751 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
752 a->setToggleAction(true);
753 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
754 actionFormatIncludeImagesHor=a;
756 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
757 a->setToggleAction(true);
758 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
759 actionFormatHideLinkUnselected=a;
761 menu->insertSeparator();
762 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
763 a->setToggleAction(true);
764 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
766 actionFormatLinkColorHint=a;
768 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
769 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
770 actionFormatLinkColor->addTo( menu );
771 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
772 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
773 actionFormatBackColor->addTo( menu );
777 void Main::setupViewActions()
779 QToolBar *tb = new QToolBar( this );
780 tb->setLabel( "View Actions" );
781 QPopupMenu *menu = new QPopupMenu( this );
782 menuBar()->insertItem( tr( "&View" ), menu );
785 a = new QAction( tr( "Zoom reset" ), QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
786 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
789 a = new QAction( tr( "Zoom in" ), QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
790 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
793 a = new QAction( tr( "Zoom out" ), QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
794 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
799 a = new QAction( tr( "Show Note Editor" ), QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ), CTRL + Key_E , this, "noteEditor" );
800 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
801 a->setToggleAction(true);
802 if (textEditor->showWithMain())
808 actionViewToggleNoteEditor=a;
810 a = new QAction( tr( "Show history window" ), QPixmap(), tr( "Show history window" ), CTRL + Key_H , this, "historyWindow" );
811 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
812 a->setToggleAction(false);
814 actionViewToggleHistoryWindow=a;
816 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
817 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
819 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
820 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
825 void Main::setupModeActions()
827 //QPopupMenu *menu = new QPopupMenu( this );
828 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
830 QToolBar *tb = new QToolBar( this );
831 tb->setLabel( tr ("Modes when using modifiers") );
833 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
834 actionGroupModModes->setExclusive (true);
835 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(iconPath+"modecolor.png"), 0, Key_J, actionGroupModModes, "modModeColor" );
836 a->setToggleAction(true);
839 actionModModeColor=a;
841 a= new QAction( tr( "Use modifier to copy" ), QPixmap(iconPath+"modecopy.png"), 0, Key_K, actionGroupModModes, "modModeCopy" );
842 a->setToggleAction(true);
846 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(iconPath+"modelink.png"), 0, Key_L, actionGroupModModes, "modModeLink" );
847 a->setToggleAction(true);
853 void Main::setupFlagActions()
855 // Create System Flags
856 systemFlagsDefault = new FlagRowObj ();
857 systemFlagsDefault->setVisibility (false);
858 systemFlagsDefault->setName ("systemFlagsDef");
860 FlagObj *fo = new FlagObj ();
861 fo->load(QPixmap(flagsPath+"flag-note.png"));
863 fo->setToolTip(tr("Note","Systemflag"));
864 systemFlagsDefault->addFlag (fo); // makes deep copy
866 fo->load(QPixmap(flagsPath+"flag-url.png"));
868 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
869 systemFlagsDefault->addFlag (fo);
871 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
872 fo->setName("vymLink");
873 fo->setToolTip(tr("Link to another vym map","Systemflag"));
874 systemFlagsDefault->addFlag (fo);
876 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
877 fo->setName("scrolledright");
878 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
879 systemFlagsDefault->addFlag (fo);
881 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
882 fo->setName("tmpUnscrolledright");
883 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
884 systemFlagsDefault->addFlag (fo);
886 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
887 fo->setName("hideInExport");
888 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
889 systemFlagsDefault->addFlag (fo);
891 // Create Standard Flags
892 standardFlagsDefault = new FlagRowObj ();
893 standardFlagsDefault->setVisibility (false);
894 standardFlagsDefault->setName ("standardFlagsDef");
896 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
897 fo->setName ("exclamationmark");
898 fo->setGroup("standard-mark");
899 fo->setToolTip(tr("Take care!","Standardflag"));
900 standardFlagsDefault->addFlag (fo); // makes deep copy
902 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
903 fo->setName("questionmark");
904 fo->setGroup("standard-mark");
905 fo->setToolTip(tr("Really?","Standardflag"));
906 standardFlagsDefault->addFlag (fo);
908 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
909 fo->setName("hook-green");
910 fo->setGroup("standard-hook");
911 fo->setToolTip(tr("ok!","Standardflag"));
912 standardFlagsDefault->addFlag (fo);
914 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
915 fo->setName("cross-red");
916 fo->setGroup("standard-hook");
917 fo->setToolTip(tr("Not ok!","Standardflag"));
918 standardFlagsDefault->addFlag (fo);
920 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
921 fo->setName("stopsign");
922 fo->setToolTip(tr("This won't work!","Standardflag"));
923 standardFlagsDefault->addFlag (fo);
925 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
926 fo->setName("smiley-good");
927 fo->setGroup("standard-smiley");
928 fo->setToolTip(tr("Good","Standardflag"));
929 standardFlagsDefault->addFlag (fo);
931 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
932 fo->setName("smiley-sad");
933 fo->setGroup("standard-smiley");
934 fo->setToolTip(tr("Bad","Standardflag"));
935 standardFlagsDefault->addFlag (fo);
937 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
938 // Original omg.png (in KDE emoticons)
939 fo->setName("smiley-omg");
940 fo->setGroup("standard-smiley");
941 fo->setToolTip(tr("Oh no!","Standardflag"));
942 standardFlagsDefault->addFlag (fo);
944 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
945 fo->setName("clock");
946 fo->setToolTip(tr("Time critical","Standardflag"));
947 standardFlagsDefault->addFlag (fo);
949 fo->load(QPixmap(flagsPath+"flag-phone.png"));
950 fo->setName("phone");
951 fo->setToolTip(tr("Call...","Standardflag"));
952 standardFlagsDefault->addFlag (fo);
954 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
956 fo->setToolTip(tr("Idea!","Standardflag"));
957 standardFlagsDefault->addFlag (fo);
959 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
960 fo->setName("arrow-up");
961 fo->setGroup("standard-arrow");
962 fo->setToolTip(tr("Important","Standardflag"));
963 standardFlagsDefault->addFlag (fo);
965 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
966 fo->setName("arrow-down");
967 fo->setGroup("standard-arrow");
968 fo->setToolTip(tr("Unimportant","Standardflag"));
969 standardFlagsDefault->addFlag (fo);
971 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
972 fo->setName("2arrow-up");
973 fo->setGroup("standard-arrow");
974 fo->setToolTip(tr("Very important!","Standardflag"));
975 standardFlagsDefault->addFlag (fo);
977 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
978 fo->setName("2arrow-down");
979 fo->setGroup("standard-arrow");
980 fo->setToolTip(tr("Very unimportant!","Standardflag"));
981 standardFlagsDefault->addFlag (fo);
983 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
984 fo->setName("thumb-up");
985 fo->setGroup("standard-thumb");
986 fo->setToolTip(tr("I like this","Standardflag"));
987 standardFlagsDefault->addFlag (fo);
989 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
990 fo->setName("thumb-down");
991 fo->setGroup("standard-thumb");
992 fo->setToolTip(tr("I like this","Standardflag"));
993 fo->setToolTip(tr("I do not like this","Standardflag"));
994 standardFlagsDefault->addFlag (fo);
996 fo->load(QPixmap(flagsPath+"flag-rose.png"));
998 fo->setToolTip(tr("Rose","Standardflag"));
999 standardFlagsDefault->addFlag (fo);
1001 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1002 fo->setName("heart");
1003 fo->setToolTip(tr("I just love... ","Standardflag"));
1004 standardFlagsDefault->addFlag (fo);
1006 fo->load(QPixmap(flagsPath+"flag-present.png"));
1007 fo->setName("present");
1008 fo->setToolTip(tr("Surprise!","Standardflag"));
1009 standardFlagsDefault->addFlag (fo);
1011 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1012 fo->setName("flash");
1013 fo->setToolTip(tr("Dangerous","Standardflag"));
1014 standardFlagsDefault->addFlag (fo);
1016 fo->load(QPixmap(flagsPath+"flag-info.png"));
1017 // Original: xsldbg_output.png
1018 fo->setName("info");
1019 fo->setToolTip(tr("Info","Standardflag"));
1020 standardFlagsDefault->addFlag (fo);
1022 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1023 // Original khelpcenter.png
1024 fo->setName("lifebelt");
1025 fo->setToolTip(tr("This will help","Standardflag"));
1026 standardFlagsDefault->addFlag (fo);
1030 standardFlagsDefault->makeToolbar(this, "Standard Flags");
1034 void Main::setupSettingsActions()
1036 QPopupMenu *menu = new QPopupMenu( this );
1037 menuBar()->insertItem( tr( "&Settings" ), menu );
1042 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1043 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1046 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1047 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1050 menu->insertSeparator();
1051 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1052 a->setToggleAction(true);
1053 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1055 actionSettingsAutoedit=a;
1057 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1058 a->setToggleAction(true);
1059 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1061 actionSettingsAutoselectHeading=a;
1063 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1064 a->setToggleAction(true);
1065 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1067 actionSettingsAutoselectText=a;
1069 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1070 a->setToggleAction(true);
1071 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1073 actionSettingsPasteNewHeading=a;
1075 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1076 a->setToggleAction(true);
1077 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1079 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1080 actionSettingsUseDelKey=a;
1082 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1083 a->setToggleAction(true);
1084 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1086 actionSettingsUseFlagGroups=a;
1088 a= new QAction( tr( "Use hide flag during exports " ), QPixmap(), tr( "Use hide flags" ), 0, this, "hideexport" );
1089 a->setToggleAction(true);
1090 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1092 actionSettingsUseHideExport=a;
1096 void Main::setupTestActions()
1098 QPopupMenu *menu = new QPopupMenu( this );
1099 menuBar()->insertItem( tr( "&Test" ), menu );
1102 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1103 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1108 void Main::setupHelpActions()
1110 QPopupMenu *menu = new QPopupMenu( this );
1111 menuBar()->insertItem( tr( "&Help" ), menu );
1114 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1115 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1118 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1119 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1122 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1123 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1128 void Main::setupContextMenus()
1132 // Context Menu for branch or mapcenter
1133 branchContextMenu =new QPopupMenu (this);
1136 branchAddContextMenu =new QPopupMenu (this);
1137 actionEditPaste->addTo ( branchAddContextMenu );
1138 actionEditAddBranch->addTo ( branchAddContextMenu );
1139 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1140 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1141 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1142 branchAddContextMenu->insertSeparator();
1143 actionEditLoadImage->addTo( branchAddContextMenu );
1144 branchAddContextMenu->insertSeparator();
1145 actionEditImportAdd->addTo ( branchAddContextMenu );
1146 actionEditImportReplace->addTo ( branchAddContextMenu );
1149 branchRemoveContextMenu =new QPopupMenu (this);
1150 actionEditCut->addTo ( branchRemoveContextMenu );
1151 actionEditDelete->addTo ( branchRemoveContextMenu );
1152 actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu );
1153 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1155 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1156 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1158 actionEditSaveBranch->addTo( branchContextMenu );
1160 branchContextMenu->insertSeparator();
1161 actionEditOpenURL->addTo ( branchContextMenu );
1162 actionEditOpenURLTab->addTo ( branchContextMenu );
1163 actionEditURL->addTo ( branchContextMenu );
1164 actionEditHeading2URL->addTo ( branchContextMenu );
1165 actionEditBugzilla2URL->addTo( branchContextMenu );
1166 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1168 actionEditFATE2URL->addTo( branchContextMenu );
1170 branchContextMenu->insertSeparator();
1171 actionEditOpenVymLink->addTo ( branchContextMenu );
1172 actionEditVymLink->addTo ( branchContextMenu );
1173 actionEditDeleteVymLink->addTo ( branchContextMenu );
1175 branchContextMenu->insertSeparator();
1176 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1178 branchContextMenu->insertSeparator();
1179 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1180 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1181 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1183 // Context Menu for links in a branch menu
1184 // This will be populated "on demand" in MapEditor::updateActions
1185 branchContextMenu->insertSeparator();
1186 branchLinksContextMenu =new QPopupMenu (this);
1187 branchLinksContextMenuDup =new QPopupMenu (this);
1188 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1189 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1191 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1192 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1194 // Context menu for floatimage
1195 floatimageContextMenu =new QPopupMenu (this);
1196 saveImageFormatMenu=new QPopupMenu (this);
1197 exportImageFormatMenu=new QPopupMenu (this);
1199 QStrList fmt = QImage::outputFormats();
1200 for (const char* f = fmt.first(); f; f = fmt.next())
1202 saveImageFormatMenu->insertItem( f );
1203 exportImageFormatMenu->insertItem( f );
1205 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1206 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1207 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1209 floatimageContextMenu->insertSeparator();
1210 actionEditCopy->addTo( floatimageContextMenu );
1211 actionEditCut->addTo( floatimageContextMenu );
1213 /* FIXME not needed any longer
1214 floatimageContextMenu->insertSeparator();
1215 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1216 a->setToggleAction(true);
1217 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1218 a->addTo( floatimageContextMenu);
1219 actionEditToggleFloatExport=a;
1222 floatimageContextMenu->insertSeparator();
1223 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1225 exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1227 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1228 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1229 a->addTo (exportMenu);
1231 a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" );
1232 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1233 a->addTo( exportMenu );
1235 a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" );
1236 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1237 a->addTo( exportMenu );
1239 a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
1240 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1241 a->addTo (exportMenu);
1243 a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
1244 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1245 a->addTo( exportMenu );
1247 a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1248 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1249 a->addTo( exportMenu );
1251 a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" );
1252 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1253 a->addTo( exportMenu );
1255 // Context menu for canvas
1256 canvasContextMenu =new QPopupMenu (this);
1257 actionEditMapInfo->addTo( canvasContextMenu );
1258 canvasContextMenu->insertSeparator();
1259 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1260 canvasContextMenu->insertSeparator();
1261 actionFormatLinkColorHint->addTo( canvasContextMenu );
1262 actionFormatLinkColor->addTo( canvasContextMenu );
1263 actionFormatBackColor->addTo( canvasContextMenu );
1265 // Menu for last opened files
1266 // Read settings initially
1268 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1269 for (int i=1;i<=j;i++)
1271 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1272 if (!s.isEmpty() && j<=maxLastMaps)
1275 setupLastMapsMenu();
1276 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1279 void Main::setupLastMapsMenu()
1281 // Remove double entries
1282 QStringList::Iterator it=lastMaps.begin();
1283 QStringList::Iterator jt;
1284 while (it!=lastMaps.end() )
1288 while (jt!=lastMaps.end() )
1291 jt=lastMaps.remove(jt);
1298 // Limit length of list to maxLastMaps
1299 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1301 // build Menu from lastMaps string list
1302 lastMapsMenu->clear();
1303 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1304 lastMapsMenu->insertItem (*it );
1308 void Main::hideEvent (QHideEvent * )
1310 if (!textEditor->isMinimized() ) textEditor->hide();
1313 void Main::showEvent (QShowEvent * )
1315 if (textEditor->showWithMain()) textEditor->showNormal();
1318 bool Main::reallyWriteDirectory(const QString &dir)
1320 QStringList eList = QDir(dir).entryList();
1321 if (eList.first() ==".") eList.pop_front(); // remove "."
1322 if (eList.first() =="..") eList.pop_front(); // remove "."
1323 if (!eList.isEmpty())
1325 QMessageBox mb( __VYM,
1326 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1327 QMessageBox::Warning,
1329 QMessageBox::Cancel | QMessageBox::Default,
1330 QMessageBox::QMessageBox::NoButton );
1332 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1333 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1336 case QMessageBox::Yes:
1339 case QMessageBox::Cancel:
1347 QString Main::browseDirectory (const QString &caption)
1349 QFileDialog fd(this,caption);
1350 fd.setMode (QFileDialog::DirectoryOnly);
1351 fd.setCaption(__VYM " - "+caption);
1354 if ( fd.exec() == QDialog::Accepted )
1355 return fd.selectedFile();
1360 MapEditor* Main::currentMapEditor() const
1362 if ( tabWidget->currentPage() &&
1363 tabWidget->currentPage()->inherits( "MapEditor" ) )
1364 return (MapEditor*)tabWidget->currentPage();
1368 //TODO not used now, maybe use this for overview window later
1369 void Main::newView()
1371 // Open a new view... have it delete when closed.
1372 Main *m = new Main(0, 0, WDestructiveClose);
1373 qApp->setMainWidget(m);
1375 qApp->setMainWidget(0);
1378 void Main::editorChanged(QWidget *)
1380 // Unselect all possibly selected objects
1381 // (Important to update note editor)
1384 for (i=0;i<=tabWidget->count() -1;i++)
1387 me=(MapEditor*)tabWidget->page(i);
1390 currentMapEditor()->reselect();
1392 // Update actions to in menus and toolbars according to editor
1393 currentMapEditor()->updateActions();
1396 void Main::fileNew()
1398 QString fn="unnamed";
1399 MapEditor* medit = new MapEditor (tabWidget, true);
1400 tabWidget->addTab (medit,fn);
1401 tabWidget->showPage(medit);
1402 medit->viewport()->setFocus();
1403 // For the very first map we do not have flagrows yet...
1404 medit->select("mc:");
1407 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1409 ErrorCode err=success;
1411 // fn is usually the archive, mapfile the file after uncompressing
1414 // Make fn absolute (needed for unzip)
1415 fn=QDir (fn).absPath();
1421 // Check, if map is already loaded
1423 while (i<=tabWidget->count() -1)
1425 me=(MapEditor*)tabWidget->page(i);
1426 if (me->getFilePath() == fn)
1428 // Already there, ask for confirmation
1429 QMessageBox mb( __VYM,
1430 tr("The map %1\nis already opened."
1431 "Opening the same map in multiple editors may lead \n"
1432 "to confusion when finishing working with vym."
1433 "Do you want to").arg(fn),
1434 QMessageBox::Warning,
1435 QMessageBox::Yes | QMessageBox::Default,
1436 QMessageBox::Cancel | QMessageBox::Escape,
1437 QMessageBox::QMessageBox::NoButton);
1438 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1439 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1442 case QMessageBox::Yes:
1444 i=tabWidget->count();
1446 case QMessageBox::Cancel:
1458 if ( !fn.isEmpty() )
1460 me = currentMapEditor();
1461 int tabIndex=tabWidget->currentPageIndex();
1462 // Check first, if mapeditor exists
1463 // If it is not default AND we want a new map,
1464 // create a new mapeditor in a new tab
1465 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1467 me = new MapEditor (tabWidget,true);
1468 tabWidget->addTab (me,fn);
1469 tabIndex=tabWidget->indexOf (me);
1470 tabWidget->setCurrentPage (tabIndex);
1473 // Check, if file exists (important for creating new files
1474 // from command line
1475 if (!QFile(fn).exists() )
1477 QMessageBox mb( __VYM,
1478 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1479 QMessageBox::Question,
1481 QMessageBox::Cancel | QMessageBox::Default,
1482 QMessageBox::QMessageBox::NoButton );
1484 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1485 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1488 case QMessageBox::Yes:
1490 currentMapEditor()->setFilePath(fn);
1491 tabWidget->setTabLabel (currentMapEditor(),
1492 currentMapEditor()->getFileName() );
1493 statusBar()->message( "Created " + fn , statusbarTime );
1496 case QMessageBox::Cancel:
1497 // don't create new map
1498 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1505 //tabWidget->currentPage() won't be NULL here, because of above...
1506 tabWidget->showPage(me);
1507 me->viewport()->setFocus();
1509 // Create temporary directory for packing
1510 char tmpdir1[]="/tmp/vym-XXXXXX";
1511 QString tmpMapDir=mkdtemp(tmpdir1);
1513 // Try to unzip file
1514 err=unzipDir (tmpMapDir,fn);
1518 me->setZipped(false);
1521 me->setZipped(true);
1523 // Look for mapname.xml
1524 mapfile= fn.left(fn.findRev(".",-1,true));
1525 mapfile=mapfile.section( '/', -1 );
1526 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1527 if (!file.exists() )
1529 // mapname.xml does not exist, well,
1530 // maybe some renamed the mapname.vym file...
1531 // Try to find any .xml in the toplevel
1532 // directory of the .vym file
1533 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1534 if (flist.count()==1)
1536 // Only one entry, take this one
1537 mapfile=tmpMapDir + "/"+flist.first();
1540 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1541 *it=tmpMapDir + "/" + *it;
1542 // TODO Multiple entries, load all (but only the first one into this ME)
1543 //mainWindow->fileLoadFromTmp (flist);
1544 //returnCode=1; // Silently forget this attempt to load
1545 qWarning ("MainWindow::load (fn) multimap found...");
1548 if (flist.isEmpty() )
1550 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1551 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1554 } //file doesn't exist
1556 mapfile=file.name();
1561 // Save existing filename in case we import
1562 QString fn_org=me->getFilePath();
1564 // Finally load map into mapEditor
1565 me->setFilePath (mapfile,fn);
1566 err=me->load(mapfile,lmode);
1568 // Restore old (maybe empty) filepath, if this is an import
1570 me->setFilePath (fn_org);
1573 // Finally check for errors and go home
1576 if (lmode==NewMap) fileCloseMap();
1577 statusBar()->message( "Could not load " + fn, statusbarTime );
1582 me->setFilePath (fn);
1583 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1584 if (fn.left(9)!="/tmp/vym-")
1586 // Only append to lastMaps if not loaded from a tmpDir
1587 // e.g. imported bookmarks are in a tmpDir
1588 lastMaps.prepend(me->getFilePath() );
1589 setupLastMapsMenu();
1591 actionFilePrint->setEnabled (true);
1593 statusBar()->message( "Loaded " + fn, statusbarTime );
1597 removeDir (QDir(tmpMapDir));
1603 void Main::fileLoad(const LoadMode &lmode)
1605 QFileDialog *fd=new QFileDialog( this);
1606 if (!lastFileDir.isEmpty())
1607 fd->setDir (lastFileDir);
1608 fd->setMode (QFileDialog::ExistingFiles);
1609 fd->addFilter ("XML (*.xml)");
1610 fd->addFilter ("VYM map (*.vym *.vyp)");
1614 fd->setCaption(tr("Load vym map"));
1617 fd->setCaption(tr("Import: Add vym map to selection"));
1620 fd->setCaption(tr("Import: Replace selection with vym map"));
1626 if ( fd->exec() == QDialog::Accepted )
1628 lastFileDir=fd->dirPath();
1629 QStringList flist = fd->selectedFiles();
1630 QStringList::Iterator it = flist.begin();
1631 while( it != flist.end() )
1634 fileLoad(*it, lmode);
1641 void Main::fileLoad()
1646 void Main::fileLoadLast(int i)
1648 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1651 void Main::fileSave(const SaveMode &savemode)
1653 // tmp dir for zipping
1657 ErrorCode err=success;
1659 QString safeFilePath;
1661 bool saveZipped=currentMapEditor()->saveZipped();
1663 MapEditor * me=currentMapEditor();
1666 QString fn=me->getFilePath();
1667 // filename=unnamed, filepath="" in constructor...
1668 if ( !fn.isEmpty() )
1670 // We have a filepath, go on saving
1671 // First remove existing file, we
1672 // don't want to add to old zip archives
1676 QMessageBox::warning( 0, tr( "Save Error" ),
1677 fn+ tr("\ncould not be removed before saving"));
1679 // Look, if we should zip the data:
1682 QMessageBox mb( __VYM,
1683 tr("The map %1\ndid not use the compressed "
1684 "vym file format.\nWriting it uncompressed will also write images \n"
1685 "and flags and thus may overwrite files in the "
1686 "given directory\n\nDo you want to write the map").arg(fn),
1687 QMessageBox::Warning,
1688 QMessageBox::Yes | QMessageBox::Default,
1690 QMessageBox::Cancel | QMessageBox::Escape);
1691 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1692 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1693 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1696 case QMessageBox::Yes:
1697 // save compressed (default file format)
1700 case QMessageBox::No:
1701 // save uncompressed
1704 case QMessageBox::Cancel:
1713 char tmpdir1[]="/tmp/vym-XXXXXX";
1714 tmpMapDir=mkdtemp(tmpdir1);
1716 safeFilePath=me->getFilePath();
1717 me->setFilePath (tmpMapDir+"/"+
1718 me->getMapName()+ ".xml",
1720 me->save (savemode);
1721 me->setFilePath (safeFilePath);
1723 zipDir (tmpMapDir,fn);
1728 safeFilePath=me->getFilePath();
1729 me->setFilePath (fn, safeFilePath);
1730 me->save (savemode);
1731 me->setFilePath (safeFilePath);
1733 } // filepath available
1736 // We have no filepath yet,
1737 // call fileSaveAs() now, this will call fileSave()
1739 fileSaveAs(savemode);
1743 if (saveZipped && !tmpMapDir.isEmpty())
1745 removeDir (QDir(tmpMapDir));
1749 statusBar()->message(
1750 tr("Saved %1").arg(me->getFilePath()),
1752 lastMaps.prepend(me->getFilePath() );
1753 setupLastMapsMenu();
1755 statusBar()->message(
1756 tr("Couldn't save ").arg(me->getFilePath()),
1760 void Main::fileSave()
1762 fileSave (CompleteMap);
1765 void Main::fileSaveAs(const SaveMode& savemode)
1769 if (currentMapEditor())
1771 if (savemode==CompleteMap)
1772 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1774 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1775 if ( !fn.isEmpty() )
1777 // Check for existing file
1778 if (QFile (fn).exists())
1780 QMessageBox mb( __VYM,
1781 tr("The file %1\nexists already. Do you want to").arg(fn),
1782 QMessageBox::Warning,
1783 QMessageBox::Yes | QMessageBox::Default,
1784 QMessageBox::Cancel | QMessageBox::Escape,
1785 QMessageBox::QMessageBox::NoButton);
1786 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1787 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1790 case QMessageBox::Yes:
1793 case QMessageBox::Cancel:
1800 // New file, add extension to filename, if missing
1801 // This is always .vym or .vyp, depending on savemode
1802 if (savemode==CompleteMap)
1804 if (!fn.contains (".vym") && !fn.contains (".xml"))
1808 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1817 currentMapEditor()->setFilePath(fn);
1821 if (savemode==CompleteMap)
1822 tabWidget->setTabLabel (currentMapEditor(),
1823 currentMapEditor()->getFileName() );
1829 void Main::fileSaveAs()
1831 fileSaveAs (CompleteMap);
1834 void Main::fileImportKDEBookmarks()
1836 ImportKDEBookmarks im;
1838 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1839 currentMapEditor()->setFilePath ("");
1842 void Main::fileImportFirefoxBookmarks()
1844 QFileDialog *fd=new QFileDialog( this);
1845 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
1846 fd->setMode (QFileDialog::ExistingFiles);
1847 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
1848 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
1851 if ( fd->exec() == QDialog::Accepted )
1853 ImportFirefoxBookmarks im;
1854 QStringList flist = fd->selectedFiles();
1855 QStringList::Iterator it = flist.begin();
1856 while( it != flist.end() )
1859 if (im.transform() &&
1860 success==fileLoad (im.getTransformedFile(),NewMap) &&
1861 currentMapEditor() )
1862 currentMapEditor()->setFilePath ("");
1869 void Main::fileImportMM()
1873 QFileDialog *fd=new QFileDialog( this);
1874 if (!lastFileDir.isEmpty())
1875 fd->setDir (lastFileDir);
1876 fd->setMode (QFileDialog::ExistingFiles);
1877 fd->addFilter ("Mind Manager (*.mmap)");
1878 fd->setCaption(tr("Import")+" "+"Mind Manager");
1881 if ( fd->exec() == QDialog::Accepted )
1883 lastFileDir=fd->dirPath();
1884 QStringList flist = fd->selectedFiles();
1885 QStringList::Iterator it = flist.begin();
1886 while( it != flist.end() )
1889 if (im.transform() &&
1890 success==fileLoad (im.getTransformedFile(),NewMap) &&
1891 currentMapEditor() )
1892 currentMapEditor()->setFilePath ("");
1901 void Main::fileImportDir()
1903 if (currentMapEditor())
1904 currentMapEditor()->importDir();
1907 void Main::fileExportXML()
1909 if (currentMapEditor())
1911 QString dir=browseDirectory(tr("Export XML to directory"));
1912 if (dir !="" && reallyWriteDirectory(dir) )
1913 currentMapEditor()->exportXML(dir);
1918 void Main::fileExportXHTML()
1920 MapEditor *me=currentMapEditor();
1924 ExportXHTMLDialog dia(this);
1925 dia.setFilePath (me->getFilePath() );
1926 dia.setMapName (me->getMapName() );
1929 if (dia.exec()==QDialog::Accepted)
1931 QString dir=dia.getDir();
1932 // Check, if warnings should be used before overwriting
1933 // the output directory
1936 ok=reallyWriteDirectory(dir);
1942 me->exportXML (dia.getDir() );
1943 dia.doExport(me->getMapName() );
1944 if (dia.hasChanged())
1951 void Main::fileExportImage(int item)
1953 MapEditor *me=currentMapEditor();
1956 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1958 if ( !fn.isEmpty() )
1959 me->exportImage(fn,item);
1961 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1966 void Main::fileExportASCII()
1968 MapEditor *me=currentMapEditor();
1972 ex.setMapCenter(me->getMapCenter());
1973 ex.addFilter ("TXT (*.txt)");
1974 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1975 if (ex.execDialog() )
1977 me->setExportMode(true);
1979 me->setExportMode(false);
1984 void Main::fileExportLaTeX()
1986 MapEditor *me=currentMapEditor();
1990 ex.setMapCenter(me->getMapCenter());
1991 ex.addFilter ("Tex (*.tex)");
1992 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1993 if (ex.execDialog() )
1995 me->setExportMode(true);
1997 me->setExportMode(false);
2002 void Main::fileExportKDEBookmarks()
2004 ExportKDEBookmarks ex;
2005 MapEditor *me=currentMapEditor();
2008 ex.setMapCenter (me->getMapCenter() );
2013 void Main::fileExportTaskjuggler()
2015 ExportTaskjuggler ex;
2016 MapEditor *me=currentMapEditor();
2019 ex.setMapCenter (me->getMapCenter() );
2020 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2021 ex.addFilter ("Taskjuggler (*.tjp)");
2022 if (ex.execDialog() )
2024 me->setExportMode(true);
2026 me->setExportMode(false);
2031 void Main::fileExportOOPresentation()
2033 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2034 // FIXME add extra info in dialog
2035 //ImagePreview *p =new ImagePreview (fd);
2036 //fd->setContentsPreviewEnabled( TRUE );
2037 //fd->setContentsPreview( p, p );
2038 //fd->setPreviewMode( QFileDialog::Contents );
2039 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2040 //fd->setDir (lastImageDir);
2043 if ( fd->exec() == QDialog::Accepted )
2045 QString fn=fd->selectedFile();
2046 //lastImageDir=fn.left(fn.findRev ("/"));
2047 if (currentMapEditor())
2048 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2052 void Main::fileCloseMap()
2054 if (currentMapEditor())
2056 if (currentMapEditor()->hasChanged())
2058 QMessageBox mb( __VYM,
2059 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2060 QMessageBox::Warning,
2061 QMessageBox::Yes | QMessageBox::Default,
2063 QMessageBox::Cancel | QMessageBox::Escape );
2064 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2065 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2068 case QMessageBox::Yes:
2070 fileSave(CompleteMap);
2072 case QMessageBox::No:
2073 // close without saving
2075 case QMessageBox::Cancel:
2080 currentMapEditor()->closeMap();
2081 tabWidget->removePage(currentMapEditor());
2082 if (tabWidget->count()==0)
2083 actionFilePrint->setEnabled (false);
2087 void Main::filePrint()
2089 if (currentMapEditor())
2090 currentMapEditor()->print();
2093 void Main::fileExitVYM()
2095 // Check if one or more editors have changed
2098 for (i=0;i<=tabWidget->count() -1;i++)
2101 me=(MapEditor*)tabWidget->page(i);
2103 // If something changed, ask what to do
2104 if (me->isUnsaved())
2106 tabWidget->setCurrentPage(i);
2107 QMessageBox mb( __VYM,
2108 tr("This map is not saved yet. Do you want to"),
2109 QMessageBox::Warning,
2110 QMessageBox::Yes | QMessageBox::Default,
2112 QMessageBox::Cancel | QMessageBox::Escape );
2113 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2114 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2116 // Call undocumented function: setActiveWindow is only
2117 // possible, if widget is visible. This depends on
2119 #if defined(Q_OS_LINUX)
2120 qt_wait_for_window_manager( this);
2122 mb.setActiveWindow();
2123 switch( mb.exec() ) {
2124 case QMessageBox::Yes:
2125 // save (the changed editors) and exit
2126 fileSave(CompleteMap);
2128 case QMessageBox::No:
2129 // exit without saving
2131 case QMessageBox::Cancel:
2132 // don't save and don't exit
2136 } // loop over all MEs
2140 void Main::editUndo()
2142 if (currentMapEditor())
2143 currentMapEditor()->undo();
2146 void Main::editRedo()
2148 if (currentMapEditor())
2149 currentMapEditor()->redo();
2152 void Main::editCopy()
2154 if (currentMapEditor())
2155 currentMapEditor()->copy();
2158 void Main::editPaste()
2160 if (currentMapEditor())
2161 currentMapEditor()->paste();
2164 void Main::editCut()
2166 if (currentMapEditor())
2167 currentMapEditor()->cut();
2170 void Main::editOpenFindWindow()
2172 findWindow->popup();
2173 findWindow->raise();
2175 // Call undocumented function: setActiveWindow is only
2176 // possible, if widget is visible. This depends on
2178 #if defined(Q_OS_LINUX)
2179 qt_wait_for_window_manager( this);
2181 findWindow->setActiveWindow();
2184 void Main::editFind(QString s)
2187 BranchObj *bo=currentMapEditor()->findText(s, cs);
2190 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2193 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2194 tr("No matches found for \"%1\"").arg(s));
2198 void Main::editFindChanged()
2199 { // Notify editor, to abort the current find process
2200 currentMapEditor()->findReset();
2203 void Main::editOpenURL()
2206 if (currentMapEditor())
2208 QString url=currentMapEditor()->getURL();
2209 if (url=="") return;
2210 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2211 procBrowser = new QProcess( this );
2213 procBrowser->addArgument( browser);
2214 procBrowser->addArgument( url);
2216 if ( !procBrowser->start() )
2218 // try to set path to browser
2219 QMessageBox::warning(0,
2221 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2222 tr("Please use Settings->")+tr("Set application to open an URL"));
2227 void Main::editOpenURLTab()
2229 if (currentMapEditor())
2231 QString url=currentMapEditor()->getURL();
2232 if (url=="") return;
2233 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2234 if (procBrowser && procBrowser->isRunning())
2236 if (browser.contains("konqueror"))
2238 // Try to open new tab in existing konqueror started previously by vym
2239 QProcess *p=new QProcess (this);
2240 p->addArgument ("dcop");
2241 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2242 p->addArgument ("konqueror-mainwindow#1");
2243 p->addArgument ("newTab");
2244 p->addArgument (url);
2246 // try to set browser
2247 QMessageBox::warning(0,
2249 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2251 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2253 // Try to open new tab in firefox
2254 QProcess *p=new QProcess (this);
2255 p->addArgument (browser);
2256 p->addArgument ("-remote");
2257 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2259 // try to set browser
2260 QMessageBox::warning(0,
2262 tr("Couldn't start %1 to open a new tab").arg(browser));
2271 void Main::editURL()
2273 if (currentMapEditor())
2274 currentMapEditor()->editURL();
2277 void Main::editHeading2URL()
2279 if (currentMapEditor())
2280 currentMapEditor()->editHeading2URL();
2283 void Main::editBugzilla2URL()
2285 if (currentMapEditor())
2286 currentMapEditor()->editBugzilla2URL();
2289 void Main::editFATE2URL()
2291 if (currentMapEditor())
2292 currentMapEditor()->editFATE2URL();
2295 void Main::editOpenVymLink()
2297 // Get current path to map
2298 QString currentVymLink;
2299 if (currentMapEditor())
2301 currentVymLink=currentMapEditor()->getVymLink();
2302 // compare path with already loaded maps
2306 for (i=0;i<=tabWidget->count() -1;i++)
2308 me=(MapEditor*)tabWidget->page(i);
2309 if (currentVymLink==me->getFilePath() )
2318 if (!QFile(currentVymLink).exists() )
2319 QMessageBox::critical( 0, tr( "Critical Error" ),
2320 tr("Couldn't open map %1").arg(currentVymLink));
2323 fileLoad (currentVymLink, NewMap);
2324 tabWidget->setCurrentPage (tabWidget->count()-1);
2327 // Go to tab containing the map
2328 tabWidget->setCurrentPage (index);
2332 void Main::editVymLink()
2334 if (currentMapEditor())
2335 currentMapEditor()->editVymLink();
2338 void Main::editDeleteVymLink()
2340 if (currentMapEditor())
2341 currentMapEditor()->deleteVymLink();
2344 void Main::editToggleHideExport()
2346 if (currentMapEditor())
2347 currentMapEditor()->toggleHideExport();
2350 void Main::editMapInfo()
2352 if (currentMapEditor())
2353 currentMapEditor()->editMapInfo();
2356 void Main::editMoveUp()
2358 if (currentMapEditor())
2359 currentMapEditor()->moveBranchUp();
2362 void Main::editMoveDown()
2364 if (currentMapEditor())
2365 currentMapEditor()->moveBranchDown();
2368 void Main::editToggleScroll()
2370 if (currentMapEditor())
2372 currentMapEditor()->toggleScroll();
2376 void Main::editUnScrollAll()
2378 if (currentMapEditor())
2380 currentMapEditor()->unScrollAll();
2384 void Main::editHeading()
2386 if (currentMapEditor())
2387 currentMapEditor()->editHeading();
2390 void Main::editNewBranch()
2392 if (currentMapEditor())
2393 currentMapEditor()->addNewBranch(0);
2396 void Main::editNewBranchHere()
2398 if (currentMapEditor())
2399 currentMapEditor()->addNewBranchHere();
2402 void Main::editNewBranchAbove()
2404 if (currentMapEditor())
2405 currentMapEditor()->addNewBranch(-1);
2408 void Main::editNewBranchBelow()
2410 if (currentMapEditor())
2411 currentMapEditor()->addNewBranch(1);
2414 void Main::editImportAdd()
2416 fileLoad (ImportAdd);
2419 void Main::editImportReplace()
2421 fileLoad (ImportReplace);
2424 void Main::editSaveBranch()
2426 fileSaveAs (PartOfMap);
2429 void Main::editRemoveBranchKeepChilds()
2431 if (currentMapEditor())
2432 currentMapEditor()->removeBranchKeepChilds();
2435 void Main::editRemoveChilds()
2437 if (currentMapEditor())
2438 currentMapEditor()->removeChilds();
2441 void Main::editDeleteSelection()
2443 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2444 currentMapEditor()->deleteSelection();
2447 void Main::editUpperBranch()
2449 if (currentMapEditor())
2450 currentMapEditor()->selectUpperBranch();
2453 void Main::editLowerBranch()
2455 if (currentMapEditor())
2456 currentMapEditor()->selectLowerBranch();
2459 void Main::editLeftBranch()
2461 if (currentMapEditor())
2462 currentMapEditor()->selectLeftBranch();
2465 void Main::editRightBranch()
2467 if (currentMapEditor())
2468 currentMapEditor()->selectRightBranch();
2471 void Main::editFirstBranch()
2473 if (currentMapEditor())
2474 currentMapEditor()->selectFirstBranch();
2477 void Main::editLastBranch()
2479 if (currentMapEditor())
2480 currentMapEditor()->selectLastBranch();
2483 void Main::editLoadImage()
2485 if (currentMapEditor())
2486 currentMapEditor()->loadFloatImage();
2489 void Main::editSaveImage(int item)
2491 if (currentMapEditor())
2492 currentMapEditor()->saveFloatImage(item);
2495 void Main::editFollowXLink(int item)
2497 if (currentMapEditor())
2498 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2501 void Main::editEditXLink(int item)
2503 if (currentMapEditor())
2504 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2507 void Main::formatSelectColor()
2509 if (currentMapEditor())
2511 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2512 if ( !col.isValid() ) return;
2513 currentMapEditor()->setColor( col );
2514 colorChanged( col );
2518 void Main::formatPickColor()
2520 if (currentMapEditor())
2521 colorChanged( currentMapEditor()->pickColor() );
2524 void Main::colorChanged(QColor c)
2526 QPixmap pix( 16, 16 );
2528 actionFormatColor->setIconSet( pix );
2531 void Main::formatColorItem()
2533 if (currentMapEditor())
2534 currentMapEditor()->colorItem();
2537 void Main::formatColorBranch()
2539 if (currentMapEditor())
2540 currentMapEditor()->colorBranch();
2543 void Main::formatLinkStyleLine()
2545 if (currentMapEditor())
2546 currentMapEditor()->setLinkStyle(StyleLine);
2549 void Main::formatLinkStyleParabel()
2551 if (currentMapEditor())
2552 currentMapEditor()->setLinkStyle(StyleParabel);
2555 void Main::formatLinkStylePolyLine()
2557 if (currentMapEditor())
2558 currentMapEditor()->setLinkStyle(StylePolyLine);
2561 void Main::formatLinkStylePolyParabel()
2563 if (currentMapEditor())
2564 currentMapEditor()->setLinkStyle(StylePolyParabel);
2567 void Main::formatSelectBackColor()
2569 if (currentMapEditor())
2570 currentMapEditor()->selectBackgroundColor();
2573 void Main::formatSelectLinkColor()
2575 if (currentMapEditor())
2576 currentMapEditor()->selectLinkColor();
2579 void Main::formatToggleLinkColorHint()
2581 currentMapEditor()->toggleLinkColorHint();
2584 void Main::formatFrameNone()
2586 if (currentMapEditor())
2587 currentMapEditor()->setFrame(NoFrame);
2590 void Main::formatFrameRectangle()
2592 if (currentMapEditor())
2593 currentMapEditor()->setFrame(Rectangle);
2596 void Main::formatIncludeImagesVer()
2598 if (currentMapEditor())
2599 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2602 void Main::formatIncludeImagesHor()
2604 if (currentMapEditor())
2605 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2608 void Main::formatHideLinkUnselected()
2610 if (currentMapEditor())
2611 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2614 void Main::viewZoomReset()
2616 if (currentMapEditor())
2620 currentMapEditor()->setWorldMatrix( m );
2621 currentMapEditor()->setViewCenter();
2622 currentMapEditor()->adjustCanvasSize();
2626 void Main::viewZoomIn()
2628 if (currentMapEditor())
2630 QWMatrix m = currentMapEditor()->worldMatrix();
2631 m.scale( 1.25, 1.25 );
2632 currentMapEditor()->setWorldMatrix( m );
2633 currentMapEditor()->setViewCenter();
2634 currentMapEditor()->adjustCanvasSize();
2638 void Main::viewZoomOut()
2640 if (currentMapEditor())
2642 QWMatrix m = currentMapEditor()->worldMatrix();
2643 m.scale( 0.8, 0.8 );
2644 currentMapEditor()->setWorldMatrix( m );
2645 currentMapEditor()->setViewCenter();
2646 currentMapEditor()->adjustCanvasSize();
2650 void Main::modModeColor()
2654 void Main::modModeLink()
2658 bool Main::settingsPDF()
2660 // Default browser is set in constructor
2662 QString text = QInputDialog::getText(
2663 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2664 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2666 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2671 bool Main::settingsURL()
2673 // Default browser is set in constructor
2675 QString text = QInputDialog::getText(
2676 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2677 settings.readEntry("/vym/mainwindow/readerURL")
2680 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2684 void Main::settingsToggleDelKey()
2686 if (actionSettingsUseDelKey->isOn())
2688 actionEditDelete->setAccel (QKeySequence (Key_Delete));
2691 actionEditDelete->setAccel (QKeySequence (""));
2695 void Main::windowToggleNoteEditor()
2697 if (textEditor->showWithMain() )
2698 windowHideNoteEditor();
2700 windowShowNoteEditor();
2703 void Main::windowToggleHistory()
2705 if (currentMapEditor())
2706 currentMapEditor()->toggleHistoryWindow();
2709 void Main::updateNoteFlag()
2711 if (currentMapEditor())
2712 currentMapEditor()->updateNoteFlag();
2715 void Main::windowShowNoteEditor()
2717 textEditor->setShowWithMain(true);
2719 actionViewToggleNoteEditor->setOn (true);
2722 void Main::windowHideNoteEditor()
2724 textEditor->setShowWithMain(false);
2726 actionViewToggleNoteEditor->setOn (false);
2729 void Main::windowNextEditor()
2731 if (tabWidget->currentPageIndex() < tabWidget->count())
2732 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2735 void Main::windowPreviousEditor()
2737 if (tabWidget->currentPageIndex() >0)
2738 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2741 void Main::standardFlagChanged()
2743 currentMapEditor()->toggleStandardFlag(sender()->name());
2746 void Main::testFunction()
2748 currentMapEditor()->testFunction();
2751 void Main::helpDoc()
2754 #if defined(Q_OS_MACX)
2755 docpath="./vym.app/Contents/vym.pdf";
2757 // default path in SUSE LINUX
2758 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2761 if (!QFile (docpath).exists() )
2763 // relative path for easy testing in tarball
2764 docpath="doc/vym.pdf";
2765 if (!QFile (docpath).exists() )
2767 // relative path for testing while still writing vym.tex
2768 docpath="doc/tex/vym.pdf";
2769 if (!QFile (docpath).exists() )
2771 // Try yet another one for Knoppix
2772 docpath="/usr/share/doc/packages/vym/vym.pdf";
2773 if (!QFile (docpath).exists() )
2775 QMessageBox::critical(0,
2776 tr("Critcal error"),
2777 tr("Couldn't find the documentation\n"
2778 "vym.pdf in various places."));
2785 Process *pdfProc = new Process();
2786 pdfProc->clearArguments();
2787 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2788 pdfProc->addArgument( docpath);
2790 if ( !pdfProc->start() )
2793 QMessageBox::warning(0,
2795 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
2796 tr("Please use Settings->")+tr("Set application to open PDF files"));
2803 void Main::helpAbout()
2806 ad.setName ("aboutwindow");
2807 ad.setMinimumSize(500,500);
2808 ad.resize (QSize (500,500));
2812 void Main::helpAboutQT()
2814 QMessageBox::aboutQt( this, "Qt Application Example" );