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);
2044 if ( fd->exec() == QDialog::Accepted )
2046 QString fn=fd->selectedFile();
2047 //lastImageDir=fn.left(fn.findRev ("/"));
2048 if (currentMapEditor())
2049 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2053 void Main::fileCloseMap()
2055 if (currentMapEditor())
2057 if (currentMapEditor()->hasChanged())
2059 QMessageBox mb( __VYM,
2060 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2061 QMessageBox::Warning,
2062 QMessageBox::Yes | QMessageBox::Default,
2064 QMessageBox::Cancel | QMessageBox::Escape );
2065 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2066 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2069 case QMessageBox::Yes:
2071 fileSave(CompleteMap);
2073 case QMessageBox::No:
2074 // close without saving
2076 case QMessageBox::Cancel:
2081 currentMapEditor()->closeMap();
2082 tabWidget->removePage(currentMapEditor());
2083 if (tabWidget->count()==0)
2084 actionFilePrint->setEnabled (false);
2088 void Main::filePrint()
2090 if (currentMapEditor())
2091 currentMapEditor()->print();
2094 void Main::fileExitVYM()
2096 // Check if one or more editors have changed
2099 for (i=0;i<=tabWidget->count() -1;i++)
2102 me=(MapEditor*)tabWidget->page(i);
2104 // If something changed, ask what to do
2105 if (me->isUnsaved())
2107 tabWidget->setCurrentPage(i);
2108 QMessageBox mb( __VYM,
2109 tr("This map is not saved yet. Do you want to"),
2110 QMessageBox::Warning,
2111 QMessageBox::Yes | QMessageBox::Default,
2113 QMessageBox::Cancel | QMessageBox::Escape );
2114 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2115 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2117 // Call undocumented function: setActiveWindow is only
2118 // possible, if widget is visible. This depends on
2120 #if defined(Q_OS_LINUX)
2121 qt_wait_for_window_manager( this);
2123 mb.setActiveWindow();
2124 switch( mb.exec() ) {
2125 case QMessageBox::Yes:
2126 // save (the changed editors) and exit
2127 fileSave(CompleteMap);
2129 case QMessageBox::No:
2130 // exit without saving
2132 case QMessageBox::Cancel:
2133 // don't save and don't exit
2137 } // loop over all MEs
2141 void Main::editUndo()
2143 if (currentMapEditor())
2144 currentMapEditor()->undo();
2147 void Main::editRedo()
2149 if (currentMapEditor())
2150 currentMapEditor()->redo();
2153 void Main::editCopy()
2155 if (currentMapEditor())
2156 currentMapEditor()->copy();
2159 void Main::editPaste()
2161 if (currentMapEditor())
2162 currentMapEditor()->paste();
2165 void Main::editCut()
2167 if (currentMapEditor())
2168 currentMapEditor()->cut();
2171 void Main::editOpenFindWindow()
2173 findWindow->popup();
2174 findWindow->raise();
2176 // Call undocumented function: setActiveWindow is only
2177 // possible, if widget is visible. This depends on
2179 #if defined(Q_OS_LINUX)
2180 qt_wait_for_window_manager( this);
2182 findWindow->setActiveWindow();
2185 void Main::editFind(QString s)
2188 BranchObj *bo=currentMapEditor()->findText(s, cs);
2191 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2194 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2195 tr("No matches found for \"%1\"").arg(s));
2199 void Main::editFindChanged()
2200 { // Notify editor, to abort the current find process
2201 currentMapEditor()->findReset();
2204 void Main::editOpenURL()
2207 if (currentMapEditor())
2209 QString url=currentMapEditor()->getURL();
2210 if (url=="") return;
2211 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2212 procBrowser = new QProcess( this );
2214 procBrowser->addArgument( browser);
2215 procBrowser->addArgument( url);
2217 if ( !procBrowser->start() )
2219 // try to set path to browser
2220 QMessageBox::warning(0,
2222 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2223 tr("Please use Settings->")+tr("Set application to open an URL"));
2228 void Main::editOpenURLTab()
2230 if (currentMapEditor())
2232 QString url=currentMapEditor()->getURL();
2233 if (url=="") return;
2234 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2235 if (procBrowser && procBrowser->isRunning())
2237 if (browser.contains("konqueror"))
2239 // Try to open new tab in existing konqueror started previously by vym
2240 QProcess *p=new QProcess (this);
2241 p->addArgument ("dcop");
2242 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2243 p->addArgument ("konqueror-mainwindow#1");
2244 p->addArgument ("newTab");
2245 p->addArgument (url);
2247 // try to set browser
2248 QMessageBox::warning(0,
2250 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2252 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2254 // Try to open new tab in firefox
2255 QProcess *p=new QProcess (this);
2256 p->addArgument (browser);
2257 p->addArgument ("-remote");
2258 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2260 // try to set browser
2261 QMessageBox::warning(0,
2263 tr("Couldn't start %1 to open a new tab").arg(browser));
2272 void Main::editURL()
2274 if (currentMapEditor())
2275 currentMapEditor()->editURL();
2278 void Main::editHeading2URL()
2280 if (currentMapEditor())
2281 currentMapEditor()->editHeading2URL();
2284 void Main::editBugzilla2URL()
2286 if (currentMapEditor())
2287 currentMapEditor()->editBugzilla2URL();
2290 void Main::editFATE2URL()
2292 if (currentMapEditor())
2293 currentMapEditor()->editFATE2URL();
2296 void Main::editOpenVymLink()
2298 // Get current path to map
2299 QString currentVymLink;
2300 if (currentMapEditor())
2302 currentVymLink=currentMapEditor()->getVymLink();
2303 // compare path with already loaded maps
2307 for (i=0;i<=tabWidget->count() -1;i++)
2309 me=(MapEditor*)tabWidget->page(i);
2310 if (currentVymLink==me->getFilePath() )
2319 if (!QFile(currentVymLink).exists() )
2320 QMessageBox::critical( 0, tr( "Critical Error" ),
2321 tr("Couldn't open map %1").arg(currentVymLink));
2324 fileLoad (currentVymLink, NewMap);
2325 tabWidget->setCurrentPage (tabWidget->count()-1);
2328 // Go to tab containing the map
2329 tabWidget->setCurrentPage (index);
2333 void Main::editVymLink()
2335 if (currentMapEditor())
2336 currentMapEditor()->editVymLink();
2339 void Main::editDeleteVymLink()
2341 if (currentMapEditor())
2342 currentMapEditor()->deleteVymLink();
2345 void Main::editToggleHideExport()
2347 if (currentMapEditor())
2348 currentMapEditor()->toggleHideExport();
2351 void Main::editMapInfo()
2353 if (currentMapEditor())
2354 currentMapEditor()->editMapInfo();
2357 void Main::editMoveUp()
2359 if (currentMapEditor())
2360 currentMapEditor()->moveBranchUp();
2363 void Main::editMoveDown()
2365 if (currentMapEditor())
2366 currentMapEditor()->moveBranchDown();
2369 void Main::editToggleScroll()
2371 if (currentMapEditor())
2373 currentMapEditor()->toggleScroll();
2377 void Main::editUnScrollAll()
2379 if (currentMapEditor())
2381 currentMapEditor()->unScrollAll();
2385 void Main::editHeading()
2387 if (currentMapEditor())
2388 currentMapEditor()->editHeading();
2391 void Main::editNewBranch()
2393 if (currentMapEditor())
2394 currentMapEditor()->addNewBranch(0);
2397 void Main::editNewBranchHere()
2399 if (currentMapEditor())
2400 currentMapEditor()->addNewBranchHere();
2403 void Main::editNewBranchAbove()
2405 if (currentMapEditor())
2406 currentMapEditor()->addNewBranch(-1);
2409 void Main::editNewBranchBelow()
2411 if (currentMapEditor())
2412 currentMapEditor()->addNewBranch(1);
2415 void Main::editImportAdd()
2417 fileLoad (ImportAdd);
2420 void Main::editImportReplace()
2422 fileLoad (ImportReplace);
2425 void Main::editSaveBranch()
2427 fileSaveAs (PartOfMap);
2430 void Main::editRemoveBranchKeepChilds()
2432 if (currentMapEditor())
2433 currentMapEditor()->removeBranchKeepChilds();
2436 void Main::editRemoveChilds()
2438 if (currentMapEditor())
2439 currentMapEditor()->removeChilds();
2442 void Main::editDeleteSelection()
2444 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2445 currentMapEditor()->deleteSelection();
2448 void Main::editUpperBranch()
2450 if (currentMapEditor())
2451 currentMapEditor()->selectUpperBranch();
2454 void Main::editLowerBranch()
2456 if (currentMapEditor())
2457 currentMapEditor()->selectLowerBranch();
2460 void Main::editLeftBranch()
2462 if (currentMapEditor())
2463 currentMapEditor()->selectLeftBranch();
2466 void Main::editRightBranch()
2468 if (currentMapEditor())
2469 currentMapEditor()->selectRightBranch();
2472 void Main::editFirstBranch()
2474 if (currentMapEditor())
2475 currentMapEditor()->selectFirstBranch();
2478 void Main::editLastBranch()
2480 if (currentMapEditor())
2481 currentMapEditor()->selectLastBranch();
2484 void Main::editLoadImage()
2486 if (currentMapEditor())
2487 currentMapEditor()->loadFloatImage();
2490 void Main::editSaveImage(int item)
2492 if (currentMapEditor())
2493 currentMapEditor()->saveFloatImage(item);
2496 void Main::editFollowXLink(int item)
2498 if (currentMapEditor())
2499 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2502 void Main::editEditXLink(int item)
2504 if (currentMapEditor())
2505 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2508 void Main::formatSelectColor()
2510 if (currentMapEditor())
2512 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2513 if ( !col.isValid() ) return;
2514 currentMapEditor()->setColor( col );
2515 colorChanged( col );
2519 void Main::formatPickColor()
2521 if (currentMapEditor())
2522 colorChanged( currentMapEditor()->pickColor() );
2525 void Main::colorChanged(QColor c)
2527 QPixmap pix( 16, 16 );
2529 actionFormatColor->setIconSet( pix );
2532 void Main::formatColorItem()
2534 if (currentMapEditor())
2535 currentMapEditor()->colorItem();
2538 void Main::formatColorBranch()
2540 if (currentMapEditor())
2541 currentMapEditor()->colorBranch();
2544 void Main::formatLinkStyleLine()
2546 if (currentMapEditor())
2547 currentMapEditor()->setLinkStyle(StyleLine);
2550 void Main::formatLinkStyleParabel()
2552 if (currentMapEditor())
2553 currentMapEditor()->setLinkStyle(StyleParabel);
2556 void Main::formatLinkStylePolyLine()
2558 if (currentMapEditor())
2559 currentMapEditor()->setLinkStyle(StylePolyLine);
2562 void Main::formatLinkStylePolyParabel()
2564 if (currentMapEditor())
2565 currentMapEditor()->setLinkStyle(StylePolyParabel);
2568 void Main::formatSelectBackColor()
2570 if (currentMapEditor())
2571 currentMapEditor()->selectBackgroundColor();
2574 void Main::formatSelectLinkColor()
2576 if (currentMapEditor())
2577 currentMapEditor()->selectLinkColor();
2580 void Main::formatToggleLinkColorHint()
2582 currentMapEditor()->toggleLinkColorHint();
2585 void Main::formatFrameNone()
2587 if (currentMapEditor())
2588 currentMapEditor()->setFrame(NoFrame);
2591 void Main::formatFrameRectangle()
2593 if (currentMapEditor())
2594 currentMapEditor()->setFrame(Rectangle);
2597 void Main::formatIncludeImagesVer()
2599 if (currentMapEditor())
2600 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2603 void Main::formatIncludeImagesHor()
2605 if (currentMapEditor())
2606 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2609 void Main::formatHideLinkUnselected()
2611 if (currentMapEditor())
2612 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2615 void Main::viewZoomReset()
2617 if (currentMapEditor())
2621 currentMapEditor()->setWorldMatrix( m );
2622 currentMapEditor()->setViewCenter();
2623 currentMapEditor()->adjustCanvasSize();
2627 void Main::viewZoomIn()
2629 if (currentMapEditor())
2631 QWMatrix m = currentMapEditor()->worldMatrix();
2632 m.scale( 1.25, 1.25 );
2633 currentMapEditor()->setWorldMatrix( m );
2634 currentMapEditor()->setViewCenter();
2635 currentMapEditor()->adjustCanvasSize();
2639 void Main::viewZoomOut()
2641 if (currentMapEditor())
2643 QWMatrix m = currentMapEditor()->worldMatrix();
2644 m.scale( 0.8, 0.8 );
2645 currentMapEditor()->setWorldMatrix( m );
2646 currentMapEditor()->setViewCenter();
2647 currentMapEditor()->adjustCanvasSize();
2651 void Main::modModeColor()
2655 void Main::modModeLink()
2659 bool Main::settingsPDF()
2661 // Default browser is set in constructor
2663 QString text = QInputDialog::getText(
2664 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2665 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2667 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2672 bool Main::settingsURL()
2674 // Default browser is set in constructor
2676 QString text = QInputDialog::getText(
2677 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2678 settings.readEntry("/vym/mainwindow/readerURL")
2681 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2685 void Main::settingsToggleDelKey()
2687 if (actionSettingsUseDelKey->isOn())
2689 actionEditDelete->setAccel (QKeySequence (Key_Delete));
2692 actionEditDelete->setAccel (QKeySequence (""));
2696 void Main::windowToggleNoteEditor()
2698 if (textEditor->showWithMain() )
2699 windowHideNoteEditor();
2701 windowShowNoteEditor();
2704 void Main::windowToggleHistory()
2706 if (currentMapEditor())
2707 currentMapEditor()->toggleHistoryWindow();
2710 void Main::updateNoteFlag()
2712 if (currentMapEditor())
2713 currentMapEditor()->updateNoteFlag();
2716 void Main::windowShowNoteEditor()
2718 textEditor->setShowWithMain(true);
2720 actionViewToggleNoteEditor->setOn (true);
2723 void Main::windowHideNoteEditor()
2725 textEditor->setShowWithMain(false);
2727 actionViewToggleNoteEditor->setOn (false);
2730 void Main::windowNextEditor()
2732 if (tabWidget->currentPageIndex() < tabWidget->count())
2733 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2736 void Main::windowPreviousEditor()
2738 if (tabWidget->currentPageIndex() >0)
2739 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2742 void Main::standardFlagChanged()
2744 currentMapEditor()->toggleStandardFlag(sender()->name());
2747 void Main::testFunction()
2749 currentMapEditor()->testFunction();
2752 void Main::helpDoc()
2755 #if defined(Q_OS_MACX)
2756 docpath="./vym.app/Contents/vym.pdf";
2758 // default path in SUSE LINUX
2759 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2762 if (!QFile (docpath).exists() )
2764 // relative path for easy testing in tarball
2765 docpath="doc/vym.pdf";
2766 if (!QFile (docpath).exists() )
2768 // relative path for testing while still writing vym.tex
2769 docpath="doc/tex/vym.pdf";
2770 if (!QFile (docpath).exists() )
2772 // Try yet another one for Knoppix
2773 docpath="/usr/share/doc/packages/vym/vym.pdf";
2774 if (!QFile (docpath).exists() )
2776 QMessageBox::critical(0,
2777 tr("Critcal error"),
2778 tr("Couldn't find the documentation\n"
2779 "vym.pdf in various places."));
2786 Process *pdfProc = new Process();
2787 pdfProc->clearArguments();
2788 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2789 pdfProc->addArgument( docpath);
2791 if ( !pdfProc->start() )
2794 QMessageBox::warning(0,
2796 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
2797 tr("Please use Settings->")+tr("Set application to open PDF files"));
2804 void Main::helpAbout()
2807 ad.setName ("aboutwindow");
2808 ad.setMinimumSize(500,500);
2809 ad.resize (QSize (500,500));
2813 void Main::helpAboutQT()
2815 QMessageBox::aboutQt( this, "Qt Application Example" );