1 #include "mainwindow.h"
3 #include <qstatusbar.h>
4 #include <qmessagebox.h>
6 #include <qapplication.h>
10 #include <qfiledialog.h>
12 #include <qcolordialog.h>
14 #include <qinputdialog.h>
15 //#include <qdatetime.h> // for random seed
22 #include "aboutdialog.h"
23 #include "exportoofiledialog.h"
25 #include "exportxhtmldialog.h"
27 #include "flagrowobj.h"
29 #include "mapeditor.h"
34 #include "showtextdialog.h"
35 #include "texteditor.h"
38 extern TextEditor *textEditor;
39 extern Main *mainWindow;
40 extern QString tmpVymDir;
41 extern QString clipboardDir;
42 extern bool clipboardEmpty;
43 extern int statusbarTime;
44 extern FlagRowObj* standardFlagsDefault;
45 extern FlagRowObj* systemFlagsDefault;
47 extern QPtrList <QAction> actionListBranches;
49 extern QAction* actionFileSave;
50 extern QAction* actionFilePrint;
51 extern QAction* actionEditUndo;
52 extern QAction* actionEditRedo;
53 extern QAction *actionEditCopy;
54 extern QAction *actionEditCut;
55 extern QAction *actionEditPaste;
56 extern QAction *actionEditMoveUp;
57 extern QAction *actionEditMoveDown;
58 extern QAction *actionEditToggleScroll;
59 extern QAction* actionEditOpenURL;
60 extern QAction* actionEditOpenURLTab;
61 extern QAction* actionEditURL;
62 extern QAction* actionEditHeading2URL;
63 extern QAction* actionEditBugzilla2URL;
64 extern QAction* actionEditFATE2URL;
65 extern QAction *actionEditOpenVymLink;
66 extern QAction *actionEditVymLink;
67 extern QAction *actionEditDeleteVymLink;
68 extern QAction *actionEditToggleHideExport;
69 extern QAction *actionEditMapInfo;
70 extern QAction *actionEditHeading;
71 extern QAction *actionEditDelete;
72 extern QAction *actionEditAddBranch;
73 extern QAction *actionEditAddBranchHere;
74 extern QAction *actionEditAddBranchAbove;
75 extern QAction *actionEditAddBranchBelow;
76 extern QAction *actionEditRemoveBranchKeepChilds;
77 extern QAction *actionEditRemoveChilds;
78 extern QAction *actionEditImportAdd;
79 extern QAction *actionEditImportReplace;
80 extern QAction *actionEditSaveBranch;
81 extern QAction *actionEditSelectFirst;
82 extern QAction *actionEditSelectLast;
83 extern QAction *actionEditLoadImage;
85 extern QAction* actionFormatColor;
86 extern QAction* actionFormatPickColor;
87 extern QAction* actionFormatColorBranch;
88 extern QAction* actionFormatColorSubtree;
89 extern QAction* actionFormatLinkColorHint;
90 extern QAction* actionFormatBackColor;
91 extern QAction* actionFormatLinkColor;
92 extern QAction *actionFormatIncludeImagesVer;
93 extern QAction *actionFormatIncludeImagesHor;
95 extern QActionGroup* actionGroupModModes;
96 extern QAction* actionModModeColor;
97 extern QAction* actionModModeLink;
98 extern QAction* actionModModeCopy;
100 extern QActionGroup *actionGroupFormatFrameTypes;
101 extern QAction *actionFormatFrameNone;
102 extern QAction *actionFormatFrameRectangle;
104 extern QActionGroup *actionGroupFormatLinkStyles;
105 extern QAction *actionFormatLinkStyleLine;
106 extern QAction *actionFormatLinkStyleParabel;
107 extern QAction *actionFormatLinkStylePolyLine;
108 extern QAction *actionFormatLinkStylePolyParabel;
109 extern QAction *actionFormatHideLinkUnselected;
111 extern QAction *actionViewToggleNoteEditor;
112 extern QAction *actionViewToggleHistoryWindow;
114 extern QAction* actionSettingsAutoedit;
115 extern QAction* actionSettingsAutoselectHeading;
116 extern QAction* actionSettingsAutoselectHeading;
117 extern QAction* actionSettingsAutoselectText;
118 extern QAction* actionSettingsPasteNewHeading;
119 extern QAction* actionSettingsUseDelKey;
120 extern QAction* actionSettingsUseFlagGroups;
121 extern QAction* actionSettingsUseHideExport;
123 extern QPopupMenu* branchContextMenu;
124 extern QPopupMenu* branchAddContextMenu;
125 extern QPopupMenu* branchRemoveContextMenu;
126 extern QPopupMenu* branchLinksContextMenu;
127 extern QPopupMenu* branchLinksContextMenuDup;
128 extern QPopupMenu* floatimageContextMenu;
129 extern QPopupMenu* saveImageFormatMenu;
130 extern QPopupMenu* canvasContextMenu;
131 extern QPopupMenu* lastMapsMenu;
132 extern QPopupMenu* importMenu;
133 extern QPopupMenu* exportMenu;
134 extern QPopupMenu* exportImageFormatMenu;
137 extern Settings settings;
138 extern Options options;
139 extern QDir vymBaseDir;
140 extern QString iconPath;
141 extern QString flagsPath;
143 #if defined(Q_OS_LINUX)
144 extern void qt_wait_for_window_manager( QWidget* w );
147 Main::Main(QWidget* parent, const char* name, WFlags f) :
148 QMainWindow(parent,name,f)
152 setCaption ("VYM - View Your Mind");
154 // Load window settings
155 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
156 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
157 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
158 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
161 // Create unique temporary directory
162 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
164 // Create direcctory for clipboard
165 clipboardDir=tmpVymDir+"/clipboard";
166 QDir d(clipboardDir);
167 d.mkdir (clipboardDir,true);
168 makeSubDirs (clipboardDir);
173 // FIXME not used currently
174 // Set random seed (random used for object IDs)
175 // QTime t = QTime::currentTime(); // set random seed
176 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
179 // Initialize some settings, which are platform dependant
182 // application to open URLs
183 p="/vym/mainwindow/readerURL";
184 #if defined(Q_OS_LINUX)
185 s=settings.readEntry (p,"konqueror");
187 #if defined(Q_OS_MACX)
188 s=settings.readEntry (p,"/usr/bin/open");
190 s=settings.readEntry (p,"mozilla");
193 settings.writeEntry( p,s);
195 // application to open PDFs
196 p="/vym/mainwindow/readerPDF";
197 #if defined(Q_OS_LINUX)
198 s=settings.readEntry (p,"acroread");
200 #if defined(Q_OS_MACX)
201 s=settings.readEntry (p,"/usr/bin/open");
203 s=settings.readEntry (p,"acroread");
206 settings.writeEntry( p,s);
211 // Create tab widget which holds the maps
212 tabWidget= new QTabWidget (this);
213 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
214 this, SLOT( editorChanged( QWidget * ) ) );
216 setCentralWidget(tabWidget);
220 setupFormatActions();
224 setupSettingsActions();
226 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
229 // After menu is created, we can enable some actions
230 actionFilePrint->setEnabled (true);
235 // Initialize Find window
236 findWindow=new FindWindow(NULL,"findwindow");
237 connect (findWindow, SIGNAL( findButton(QString) ),
238 this, SLOT(editFind(QString) ) );
239 connect (findWindow, SIGNAL( somethingChanged() ),
240 this, SLOT(editFindChanged() ) );
242 // Connect TextEditor, so that we can update flags if text changes
243 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
251 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
252 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
253 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
254 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
256 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
257 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
259 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
260 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
261 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
262 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
263 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
264 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
265 settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
268 int maps=lastMaps.count();
269 settings.writeEntry( "/vym/lastMaps/number",maps );
270 for (int i=1;i<=maps;i++)
272 QStringList::Iterator it = lastMaps.at(i-1);
273 s=QString("/vym/lastMaps/map-%1").arg(i);
274 if (!s.isEmpty() && i<=maxLastMaps)
275 settings.writeEntry (s, *it);
279 // To make the texteditor save its settings, call the destructor
282 // Remove temporary directory
283 removeDir (QDir(tmpVymDir));
286 void Main::loadCmdLine()
288 /* TODO draw some kind of splashscreen while loading...
294 QStringList flist=options.getFileList();
295 QStringList::Iterator it=flist.begin();
297 while (it !=flist.end() )
299 fileLoad (*it, NewMap);
305 void Main::statusMessage(const QString &s)
307 statusBar()->message (s);
310 void Main::closeEvent (QCloseEvent* )
316 void Main::setupFileActions()
318 QToolBar *tb = new QToolBar( this );
319 tb->setLabel( "File Actions" );
320 QPopupMenu *menu = new QPopupMenu( this );
321 menuBar()->insertItem( tr( "&File" ), menu );
323 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
326 a = new QAction( tr( "New map","File menu" ), QPixmap( iconPath+"filenew.png"), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
327 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
331 a = new QAction( tr( "Open","File menu" ), QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
332 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
336 lastMapsMenu = new QPopupMenu (this);
338 menu->insertItem (tr("Open Recent"),lastMapsMenu );
339 menu->insertSeparator();
341 a = new QAction( tr( "Save" ), QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
342 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
347 a = new QAction( tr( "Save &As" ), QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), 0, this, "fileSaveAs" );
348 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
351 menu->insertSeparator();
353 importMenu = new QPopupMenu (this);
354 menu->insertItem (tr("Import"),importMenu );
356 a = new QAction( tr( "Import")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
357 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
358 a->addTo (importMenu);
360 a = new QAction( tr( "Import")+" "+tr("Firefox Bookmarks" ), QPixmap(), tr("Firefox Bookmarks"), 0, this, "importFirefoxBookmarks" );
361 connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
362 a->addTo (importMenu);
364 a = new QAction( tr( "Import")+" Mind Manager" , QPixmap(), "Mind Manager...", 0, this, "importMM" );
365 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
366 a->addTo (importMenu);
368 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
369 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
370 a->addTo( importMenu);
372 exportMenu = new QPopupMenu (this);
373 menu->insertItem (tr("Export"),exportMenu );
375 menu->insertSeparator();
378 a = new QAction( tr( "Print" ), QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), CTRL + Key_P, this, "filePrint" );
379 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
384 a = new QAction( tr( "Close Map" ), QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
385 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
388 a = new QAction( tr( "Exit")+" "+__VYM, QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, CTRL + Key_Q, this, "fileExitVYM" );
389 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
395 void Main::setupEditActions()
397 QToolBar *tb = new QToolBar( this );
398 tb->setLabel( "Edit Actions" );
399 QPopupMenu *menu = new QPopupMenu( this );
400 menuBar()->insertItem( tr( "&Edit" ), menu );
404 a = new QAction( tr( "Undo" ), QPixmap( iconPath+"undo.png"), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
405 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
406 a->setEnabled (false);
411 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
413 a = new QAction( tr( "Redo" ), QPixmap( iconPath+"redo.png"), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
414 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
419 menu->insertSeparator();
420 a = new QAction( tr( "Copy" ), QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
421 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
422 a->setEnabled (false);
426 a = new QAction( tr( "Cut" ), QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
427 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
428 a->setEnabled (false);
432 a = new QAction( tr( "Paste" ), QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
433 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
434 a->setEnabled (false);
439 a = new QAction( tr( "Move branch up" ), QPixmap(iconPath+"up.png" ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
440 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
441 a->setEnabled (false);
446 a = new QAction( tr( "Move branch down" ), QPixmap( iconPath+"down.png"), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
447 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
448 a->setEnabled (false);
451 actionEditMoveDown=a;
454 a = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
455 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
456 alt = new QAction( tr( "Scroll branch" ), QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), Key_S, this, "scroll" );
457 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
458 #if defined(Q_OS_MACX)
459 actionEditToggleScroll=alt;
461 actionEditToggleScroll=a;
463 actionEditToggleScroll->setEnabled (false);
464 actionEditToggleScroll->setToggleAction(true);
465 actionEditToggleScroll->addTo( tb );
466 actionEditToggleScroll->addTo( menu );
467 actionListBranches.append(actionEditToggleScroll);
469 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
470 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
473 menu->insertSeparator();
475 a = new QAction( tr( "Find" ), QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
476 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
479 menu->insertSeparator();
481 a = new QAction( tr( "Open URL" ), QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), CTRL + Key_U, this, "url" );
482 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
484 a->setEnabled (false);
487 a = new QAction( tr( "Open URL in new tab" ), QPixmap(), tr( "Open URL in new tab" ), CTRL + Key_U, this, "urltab" );
488 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
489 a->setEnabled (false);
490 actionEditOpenURLTab=a;
492 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
493 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
494 a->setEnabled (false);
495 actionListBranches.append(a);
498 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
499 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
500 a->setEnabled (false);
501 actionListBranches.append(a);
502 actionEditHeading2URL=a;
504 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
505 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
506 a->setEnabled (false);
507 actionListBranches.append(a);
508 actionEditBugzilla2URL=a;
510 a = new QAction( tr( "Create URL to FATE" ), QPixmap(), tr( "Create URL to FATE" ), 0, this, "FATE2url" );
511 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
512 a->setEnabled (false);
513 actionListBranches.append(a);
514 actionEditFATE2URL=a;
516 a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), 0, this, "jumpMap" );
517 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
519 a->setEnabled (false);
520 actionEditOpenVymLink=a;
522 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
523 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
524 a->setEnabled (false);
525 actionListBranches.append(a);
528 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
529 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
530 a->setEnabled (false);
531 actionEditDeleteVymLink=a;
533 a = new QAction( tr( "Hide object in exports" ), QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), Key_H, this, "hideExport" );
534 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
535 a->setToggleAction(true);
537 a->setEnabled (false);
538 actionEditToggleHideExport=a;
540 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
541 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
542 a->setEnabled (true);
545 menu->insertSeparator();
547 // Shortcuts to modify heading:
548 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
549 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
550 actionListBranches.append(a);
551 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
552 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
553 actionListBranches.append(a);
555 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
556 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
557 a->setEnabled (false);
559 actionListBranches.append(a);
561 // Shortcut to delete selection
562 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
563 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
564 a->setEnabled (false);
567 // Shortcut to add branch
568 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
569 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
570 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
571 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
572 a->setEnabled (false);
573 actionListBranches.append(a);
574 #if defined (Q_OS_MACX)
575 // In OSX show different shortcut in menues, the keys work independtly always
576 actionEditAddBranch=alt;
578 actionEditAddBranch=a;
581 // Add branch by inserting it at selection
582 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
583 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
584 a->setEnabled (false);
585 actionListBranches.append(a);
586 actionEditAddBranchHere=a;
587 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_A, this, "newBranchHere" );
588 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
589 actionListBranches.append(a);
592 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
593 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
594 a->setEnabled (false);
595 actionListBranches.append(a);
596 actionEditAddBranchAbove=a;
597 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_A, this, "newBranch" );
598 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
599 actionListBranches.append(a);
602 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
603 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
604 a->setEnabled (false);
605 actionListBranches.append(a);
606 actionEditAddBranchBelow=a;
607 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_A, this, "newBranch" );
608 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
609 actionListBranches.append(a);
611 // Import at selection (adding to selection)
612 a = new QAction( tr( "Add map at selection" ),tr( "Add map (insert)" ), 0, this, "importAdd" );
613 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
614 a->setEnabled (false);
615 actionListBranches.append(a);
616 actionEditImportAdd=a;
618 // Import at selection (replacing selection)
619 a = new QAction( tr( "Replace selection with map" ),tr( "Add map (replace)" ), 0, this, "importReplace" );
620 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
621 a->setEnabled (false);
622 actionListBranches.append(a);
623 actionEditImportReplace=a;
626 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
627 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
628 a->setEnabled (false);
629 actionListBranches.append(a);
630 actionEditSaveBranch=a;
632 // Only remove branch, not its childs
633 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
634 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
635 a->setEnabled (false);
636 actionListBranches.append(a);
637 actionEditRemoveBranchKeepChilds=a;
639 // Only remove childs of a branch
640 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
641 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
642 a->setEnabled (false);
643 actionListBranches.append(a);
644 actionEditRemoveChilds=a;
646 // Shortcuts for navigating with cursor:
647 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
648 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
649 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
650 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
651 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
652 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
653 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
654 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
655 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
656 a->setEnabled (false);
658 actionListBranches.append(a);
659 actionEditSelectFirst=a;
660 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
661 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
662 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
663 a->setEnabled (false);
665 actionListBranches.append(a);
666 actionEditSelectLast=a;
668 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
669 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
670 actionEditLoadImage=a;
675 void Main::setupFormatActions()
677 QPopupMenu *menu = new QPopupMenu( this );
678 menuBar()->insertItem( tr( "F&ormat" ), menu );
680 QToolBar *tb = new QToolBar( this );
684 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
685 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
686 actionFormatColor->addTo( tb );
687 actionFormatColor->addTo( menu );
688 a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" );
689 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
690 a->setEnabled (false);
693 actionListBranches.append(a);
694 actionFormatPickColor=a;
695 a= new QAction( tr( "Color branch" ), QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
696 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
697 a->setEnabled (false);
700 actionListBranches.append(a);
701 actionFormatColorBranch=a;
702 a= new QAction( tr( "Color Subtree" ), QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
703 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
704 a->setEnabled (false);
707 actionListBranches.append(a);
708 actionFormatColorSubtree=a;
710 menu->insertSeparator();
711 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
712 actionGroupFormatLinkStyles->setExclusive (true);
713 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
714 a->setToggleAction(true);
715 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
716 actionFormatLinkStyleLine=a;
717 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
718 a->setToggleAction(true);
719 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
720 actionFormatLinkStyleParabel=a;
721 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
722 a->setToggleAction(true);
723 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
724 actionFormatLinkStylePolyLine=a;
725 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
726 a->setToggleAction(true);
727 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
728 actionFormatLinkStylePolyParabel=a;
729 actionGroupFormatLinkStyles->addTo (menu);
731 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
732 actionGroupFormatFrameTypes->setExclusive (true);
733 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
734 a->setToggleAction(true);
735 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
736 actionFormatFrameNone=a;
737 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
738 a->setToggleAction(true);
739 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
740 actionFormatFrameRectangle=a;
742 a = new QAction( tr ("Include top and bottom position of images into branch"), tr( "Include images vertically" ), 0, actionFormatIncludeImagesVer, "includeImagesVer" );
743 a->setToggleAction(true);
744 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
745 actionFormatIncludeImagesVer=a;
747 a = new QAction( tr ("Include left and right position of images into branch"), tr( "Include images horizontally" ), 0, actionFormatIncludeImagesHor, "includeImagesHor" );
748 a->setToggleAction(true);
749 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
750 actionFormatIncludeImagesHor=a;
752 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
753 a->setToggleAction(true);
754 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
755 actionFormatHideLinkUnselected=a;
757 menu->insertSeparator();
758 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
759 a->setToggleAction(true);
760 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
762 actionFormatLinkColorHint=a;
764 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
765 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
766 actionFormatLinkColor->addTo( menu );
767 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
768 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
769 actionFormatBackColor->addTo( menu );
773 void Main::setupViewActions()
775 QToolBar *tb = new QToolBar( this );
776 tb->setLabel( "View Actions" );
777 QPopupMenu *menu = new QPopupMenu( this );
778 menuBar()->insertItem( tr( "&View" ), menu );
781 a = new QAction( tr( "Zoom reset" ), QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
782 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
785 a = new QAction( tr( "Zoom in" ), QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
786 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
789 a = new QAction( tr( "Zoom out" ), QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
790 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
795 a = new QAction( tr( "Show Note Editor" ), QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ), CTRL + Key_E , this, "noteEditor" );
796 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
797 a->setToggleAction(true);
798 if (textEditor->showWithMain())
804 actionViewToggleNoteEditor=a;
806 a = new QAction( tr( "Show history window" ), QPixmap(), tr( "Show history window" ), CTRL + Key_H , this, "historyWindow" );
807 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
808 a->setToggleAction(false);
810 actionViewToggleHistoryWindow=a;
812 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
813 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
815 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
816 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
821 void Main::setupModeActions()
823 //QPopupMenu *menu = new QPopupMenu( this );
824 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
826 QToolBar *tb = new QToolBar( this );
827 tb->setLabel( tr ("Modes when using modifiers") );
829 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
830 actionGroupModModes->setExclusive (true);
831 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(iconPath+"modecolor.png"), 0, Key_J, actionGroupModModes, "modModeColor" );
832 a->setToggleAction(true);
835 actionModModeColor=a;
837 a= new QAction( tr( "Use modifier to copy" ), QPixmap(iconPath+"modecopy.png"), 0, Key_K, actionGroupModModes, "modModeCopy" );
838 a->setToggleAction(true);
842 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(iconPath+"modelink.png"), 0, Key_L, actionGroupModModes, "modModeLink" );
843 a->setToggleAction(true);
849 void Main::setupFlagActions()
851 // Create System Flags
852 systemFlagsDefault = new FlagRowObj ();
853 systemFlagsDefault->setVisibility (false);
854 systemFlagsDefault->setName ("systemFlagsDef");
856 FlagObj *fo = new FlagObj ();
857 fo->load(QPixmap(flagsPath+"flag-note.png"));
859 fo->setToolTip(tr("Note","Systemflag"));
860 systemFlagsDefault->addFlag (fo); // makes deep copy
862 fo->load(QPixmap(flagsPath+"flag-url.png"));
864 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
865 systemFlagsDefault->addFlag (fo);
867 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
868 fo->setName("vymLink");
869 fo->setToolTip(tr("Link to another vym map","Systemflag"));
870 systemFlagsDefault->addFlag (fo);
872 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
873 fo->setName("scrolledright");
874 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
875 systemFlagsDefault->addFlag (fo);
877 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
878 fo->setName("tmpUnscrolledright");
879 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
880 systemFlagsDefault->addFlag (fo);
882 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
883 fo->setName("hideInExport");
884 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
885 systemFlagsDefault->addFlag (fo);
887 // Create Standard Flags
888 standardFlagsDefault = new FlagRowObj ();
889 standardFlagsDefault->setVisibility (false);
890 standardFlagsDefault->setName ("standardFlagsDef");
892 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
893 fo->setName ("exclamationmark");
894 fo->setGroup("standard-mark");
895 fo->setToolTip(tr("Take care!","Standardflag"));
896 standardFlagsDefault->addFlag (fo); // makes deep copy
898 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
899 fo->setName("questionmark");
900 fo->setGroup("standard-mark");
901 fo->setToolTip(tr("Really?","Standardflag"));
902 standardFlagsDefault->addFlag (fo);
904 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
905 fo->setName("hook-green");
906 fo->setGroup("standard-hook");
907 fo->setToolTip(tr("ok!","Standardflag"));
908 standardFlagsDefault->addFlag (fo);
910 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
911 fo->setName("cross-red");
912 fo->setGroup("standard-hook");
913 fo->setToolTip(tr("Not ok!","Standardflag"));
914 standardFlagsDefault->addFlag (fo);
916 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
917 fo->setName("stopsign");
918 fo->setToolTip(tr("This won't work!","Standardflag"));
919 standardFlagsDefault->addFlag (fo);
921 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
922 fo->setName("smiley-good");
923 fo->setGroup("standard-smiley");
924 fo->setToolTip(tr("Good","Standardflag"));
925 standardFlagsDefault->addFlag (fo);
927 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
928 fo->setName("smiley-sad");
929 fo->setGroup("standard-smiley");
930 fo->setToolTip(tr("Bad","Standardflag"));
931 standardFlagsDefault->addFlag (fo);
933 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
934 // Original omg.png (in KDE emoticons)
935 fo->setName("smiley-omg");
936 fo->setGroup("standard-smiley");
937 fo->setToolTip(tr("Oh no!","Standardflag"));
938 standardFlagsDefault->addFlag (fo);
940 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
941 fo->setName("clock");
942 fo->setToolTip(tr("Time critical","Standardflag"));
943 standardFlagsDefault->addFlag (fo);
945 fo->load(QPixmap(flagsPath+"flag-phone.png"));
946 fo->setName("phone");
947 fo->setToolTip(tr("Call...","Standardflag"));
948 standardFlagsDefault->addFlag (fo);
950 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
952 fo->setToolTip(tr("Idea!","Standardflag"));
953 standardFlagsDefault->addFlag (fo);
955 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
956 fo->setName("arrow-up");
957 fo->setGroup("standard-arrow");
958 fo->setToolTip(tr("Important","Standardflag"));
959 standardFlagsDefault->addFlag (fo);
961 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
962 fo->setName("arrow-down");
963 fo->setGroup("standard-arrow");
964 fo->setToolTip(tr("Unimportant","Standardflag"));
965 standardFlagsDefault->addFlag (fo);
967 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
968 fo->setName("2arrow-up");
969 fo->setGroup("standard-arrow");
970 fo->setToolTip(tr("Very important!","Standardflag"));
971 standardFlagsDefault->addFlag (fo);
973 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
974 fo->setName("2arrow-down");
975 fo->setGroup("standard-arrow");
976 fo->setToolTip(tr("Very unimportant!","Standardflag"));
977 standardFlagsDefault->addFlag (fo);
979 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
980 fo->setName("thumb-up");
981 fo->setGroup("standard-thumb");
982 fo->setToolTip(tr("I like this","Standardflag"));
983 standardFlagsDefault->addFlag (fo);
985 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
986 fo->setName("thumb-down");
987 fo->setGroup("standard-thumb");
988 fo->setToolTip(tr("I like this","Standardflag"));
989 fo->setToolTip(tr("I do not like this","Standardflag"));
990 standardFlagsDefault->addFlag (fo);
992 fo->load(QPixmap(flagsPath+"flag-rose.png"));
994 fo->setToolTip(tr("Rose","Standardflag"));
995 standardFlagsDefault->addFlag (fo);
997 fo->load(QPixmap(flagsPath+"flag-heart.png"));
998 fo->setName("heart");
999 fo->setToolTip(tr("I just love... ","Standardflag"));
1000 standardFlagsDefault->addFlag (fo);
1002 fo->load(QPixmap(flagsPath+"flag-present.png"));
1003 fo->setName("present");
1004 fo->setToolTip(tr("Surprise!","Standardflag"));
1005 standardFlagsDefault->addFlag (fo);
1007 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1008 fo->setName("flash");
1009 fo->setToolTip(tr("Dangerous","Standardflag"));
1010 standardFlagsDefault->addFlag (fo);
1012 fo->load(QPixmap(flagsPath+"flag-info.png"));
1013 // Original: xsldbg_output.png
1014 fo->setName("info");
1015 fo->setToolTip(tr("Info","Standardflag"));
1016 standardFlagsDefault->addFlag (fo);
1018 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1019 // Original khelpcenter.png
1020 fo->setName("lifebelt");
1021 fo->setToolTip(tr("This will help","Standardflag"));
1022 standardFlagsDefault->addFlag (fo);
1026 standardFlagsDefault->makeToolbar(this, "Standard Flags");
1030 void Main::setupSettingsActions()
1032 QPopupMenu *menu = new QPopupMenu( this );
1033 menuBar()->insertItem( tr( "&Settings" ), menu );
1038 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
1039 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1042 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
1043 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1046 menu->insertSeparator();
1047 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
1048 a->setToggleAction(true);
1049 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1051 actionSettingsAutoedit=a;
1053 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
1054 a->setToggleAction(true);
1055 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1057 actionSettingsAutoselectHeading=a;
1059 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
1060 a->setToggleAction(true);
1061 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1063 actionSettingsAutoselectText=a;
1065 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
1066 a->setToggleAction(true);
1067 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1069 actionSettingsPasteNewHeading=a;
1071 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
1072 a->setToggleAction(true);
1073 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1075 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1076 actionSettingsUseDelKey=a;
1078 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1079 a->setToggleAction(true);
1080 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1082 actionSettingsUseFlagGroups=a;
1084 a= new QAction( tr( "Use hide flag during exports " ), QPixmap(), tr( "Use hide flags" ), 0, this, "hideexport" );
1085 a->setToggleAction(true);
1086 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1088 actionSettingsUseHideExport=a;
1092 void Main::setupTestActions()
1094 QPopupMenu *menu = new QPopupMenu( this );
1095 menuBar()->insertItem( tr( "&Test" ), menu );
1098 a = new QAction( tr( "Call test function" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1099 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1104 void Main::setupHelpActions()
1106 QPopupMenu *menu = new QPopupMenu( this );
1107 menuBar()->insertItem( tr( "&Help" ), menu );
1110 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1111 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1114 a = new QAction( tr( "About VYM")+" "__VYM, QPixmap(), tr( "About VYM" ), 0, this, "about" );
1115 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1118 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1119 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1124 void Main::setupContextMenus()
1128 // Context Menu for branch or mapcenter
1129 branchContextMenu =new QPopupMenu (this);
1132 branchAddContextMenu =new QPopupMenu (this);
1133 actionEditPaste->addTo ( branchAddContextMenu );
1134 actionEditAddBranch->addTo ( branchAddContextMenu );
1135 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1136 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1137 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1138 branchAddContextMenu->insertSeparator();
1139 actionEditLoadImage->addTo( branchAddContextMenu );
1140 branchAddContextMenu->insertSeparator();
1141 actionEditImportAdd->addTo ( branchAddContextMenu );
1142 actionEditImportReplace->addTo ( branchAddContextMenu );
1145 branchRemoveContextMenu =new QPopupMenu (this);
1146 actionEditCut->addTo ( branchRemoveContextMenu );
1147 actionEditDelete->addTo ( branchRemoveContextMenu );
1148 actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu );
1149 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1151 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1152 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1154 actionEditSaveBranch->addTo( branchContextMenu );
1156 branchContextMenu->insertSeparator();
1157 actionEditOpenURL->addTo ( branchContextMenu );
1158 actionEditOpenURLTab->addTo ( branchContextMenu );
1159 actionEditURL->addTo ( branchContextMenu );
1160 actionEditHeading2URL->addTo ( branchContextMenu );
1161 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1163 actionEditBugzilla2URL->addTo( branchContextMenu );
1164 actionEditFATE2URL->addTo( branchContextMenu );
1166 branchContextMenu->insertSeparator();
1167 actionEditOpenVymLink->addTo ( branchContextMenu );
1168 actionEditVymLink->addTo ( branchContextMenu );
1169 actionEditDeleteVymLink->addTo ( branchContextMenu );
1171 branchContextMenu->insertSeparator();
1172 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1174 branchContextMenu->insertSeparator();
1175 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1176 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1177 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1179 // Context Menu for links in a branch menu
1180 // This will be populated "on demand" in MapEditor::updateActions
1181 branchContextMenu->insertSeparator();
1182 branchLinksContextMenu =new QPopupMenu (this);
1183 branchLinksContextMenuDup =new QPopupMenu (this);
1184 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1185 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1187 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1188 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1190 // Context menu for floatimage
1191 floatimageContextMenu =new QPopupMenu (this);
1192 saveImageFormatMenu=new QPopupMenu (this);
1193 exportImageFormatMenu=new QPopupMenu (this);
1195 QStrList fmt = QImage::outputFormats();
1196 for (const char* f = fmt.first(); f; f = fmt.next())
1198 saveImageFormatMenu->insertItem( f );
1199 exportImageFormatMenu->insertItem( f );
1201 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1202 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1203 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1205 floatimageContextMenu->insertSeparator();
1206 actionEditCopy->addTo( floatimageContextMenu );
1207 actionEditCut->addTo( floatimageContextMenu );
1209 /* FIXME not needed any longer
1210 floatimageContextMenu->insertSeparator();
1211 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1212 a->setToggleAction(true);
1213 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1214 a->addTo( floatimageContextMenu);
1215 actionEditToggleFloatExport=a;
1218 floatimageContextMenu->insertSeparator();
1219 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1221 exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1223 a = new QAction( tr( "Export in Open Document Format used e.g. in Open Office " ), QPixmap(), "Open Office"+QString("..."), 0, this, "exportOOPresentation" );
1224 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1225 a->addTo (exportMenu);
1227 a = new QAction( tr( "Export as")+" webpage (XHTML)" , QPixmap(), "Webpage (XHTML)...", ALT + Key_X, this, "exportXHTML" );
1228 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1229 a->addTo( exportMenu );
1231 a = new QAction( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ), QPixmap(), "Text (ASCII)...", 0, this, "exportASCII" );
1232 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1233 a->addTo( exportMenu );
1235 a = new QAction( tr( "Export as")+" "+tr("KDE Bookmarks" ), QPixmap(), tr("KDE Bookmarks"), 0, this, "importKDEBookmarks" );
1236 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1237 a->addTo (exportMenu);
1239 a = new QAction( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ), QPixmap(), "Taskjuggler...", 0, this, "exportTJ" );
1240 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1241 a->addTo( exportMenu );
1243 a = new QAction( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ), QPixmap(), "LaTeX...", 0, this, "exportLaTeX" );
1244 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1245 a->addTo( exportMenu );
1247 a = new QAction( tr( "Export as")+" XML" , QPixmap(), "XML...", 0, this, "exportXML" );
1248 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1249 a->addTo( exportMenu );
1251 // Context menu for canvas
1252 canvasContextMenu =new QPopupMenu (this);
1253 actionEditMapInfo->addTo( canvasContextMenu );
1254 canvasContextMenu->insertSeparator();
1255 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1256 canvasContextMenu->insertSeparator();
1257 actionFormatLinkColorHint->addTo( canvasContextMenu );
1258 actionFormatLinkColor->addTo( canvasContextMenu );
1259 actionFormatBackColor->addTo( canvasContextMenu );
1261 // Menu for last opened files
1262 // Read settings initially
1264 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1265 for (int i=1;i<=j;i++)
1267 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1268 if (!s.isEmpty() && j<=maxLastMaps)
1271 setupLastMapsMenu();
1272 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1275 void Main::setupLastMapsMenu()
1277 // Remove double entries
1278 QStringList::Iterator it=lastMaps.begin();
1279 QStringList::Iterator jt;
1280 while (it!=lastMaps.end() )
1284 while (jt!=lastMaps.end() )
1287 jt=lastMaps.remove(jt);
1294 // Limit length of list to maxLastMaps
1295 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1297 // build Menu from lastMaps string list
1298 lastMapsMenu->clear();
1299 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1300 lastMapsMenu->insertItem (*it );
1304 void Main::hideEvent (QHideEvent * )
1306 if (!textEditor->isMinimized() ) textEditor->hide();
1309 void Main::showEvent (QShowEvent * )
1311 if (textEditor->showWithMain()) textEditor->showNormal();
1314 bool Main::reallyWriteDirectory(const QString &dir)
1316 QStringList eList = QDir(dir).entryList();
1317 if (eList.first() ==".") eList.pop_front(); // remove "."
1318 if (eList.first() =="..") eList.pop_front(); // remove "."
1319 if (!eList.isEmpty())
1321 QMessageBox mb( __VYM,
1322 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1323 QMessageBox::Warning,
1325 QMessageBox::Cancel | QMessageBox::Default,
1326 QMessageBox::QMessageBox::NoButton );
1328 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1329 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1332 case QMessageBox::Yes:
1335 case QMessageBox::Cancel:
1343 QString Main::browseDirectory (const QString &caption)
1345 QFileDialog fd(this,caption);
1346 fd.setMode (QFileDialog::DirectoryOnly);
1347 fd.setCaption(__VYM " - "+caption);
1350 if ( fd.exec() == QDialog::Accepted )
1351 return fd.selectedFile();
1356 MapEditor* Main::currentMapEditor() const
1358 if ( tabWidget->currentPage() &&
1359 tabWidget->currentPage()->inherits( "MapEditor" ) )
1360 return (MapEditor*)tabWidget->currentPage();
1364 //TODO not used now, maybe use this for overview window later
1365 void Main::newView()
1367 // Open a new view... have it delete when closed.
1368 Main *m = new Main(0, 0, WDestructiveClose);
1369 qApp->setMainWidget(m);
1371 qApp->setMainWidget(0);
1374 void Main::editorChanged(QWidget *)
1376 // Unselect all possibly selected objects
1377 // (Important to update note editor)
1380 for (i=0;i<=tabWidget->count() -1;i++)
1383 me=(MapEditor*)tabWidget->page(i);
1386 currentMapEditor()->reselect();
1388 // Update actions to in menus and toolbars according to editor
1389 currentMapEditor()->updateActions();
1392 void Main::fileNew()
1394 QString fn="unnamed";
1395 MapEditor* medit = new MapEditor (tabWidget, true);
1396 tabWidget->addTab (medit,fn);
1397 tabWidget->showPage(medit);
1398 medit->viewport()->setFocus();
1399 // For the very first map we do not have flagrows yet...
1400 medit->select("mc:");
1403 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1405 ErrorCode err=success;
1407 // fn is usually the archive, mapfile the file after uncompressing
1410 // Make fn absolute (needed for unzip)
1411 fn=QDir (fn).absPath();
1417 // Check, if map is already loaded
1419 while (i<=tabWidget->count() -1)
1421 me=(MapEditor*)tabWidget->page(i);
1422 if (me->getFilePath() == fn)
1424 // Already there, ask for confirmation
1425 QMessageBox mb( __VYM,
1426 tr("The map %1\nis already opened."
1427 "Opening the same map in multiple editors may lead \n"
1428 "to confusion when finishing working with vym."
1429 "Do you want to").arg(fn),
1430 QMessageBox::Warning,
1431 QMessageBox::Yes | QMessageBox::Default,
1432 QMessageBox::Cancel | QMessageBox::Escape,
1433 QMessageBox::QMessageBox::NoButton);
1434 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1435 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1438 case QMessageBox::Yes:
1440 i=tabWidget->count();
1442 case QMessageBox::Cancel:
1454 if ( !fn.isEmpty() )
1456 me = currentMapEditor();
1457 int tabIndex=tabWidget->currentPageIndex();
1458 // Check first, if mapeditor exists
1459 // If it is not default AND we want a new map,
1460 // create a new mapeditor in a new tab
1461 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1463 me = new MapEditor (tabWidget,true);
1464 tabWidget->addTab (me,fn);
1465 tabIndex=tabWidget->indexOf (me);
1466 tabWidget->setCurrentPage (tabIndex);
1469 // Check, if file exists (important for creating new files
1470 // from command line
1471 if (!QFile(fn).exists() )
1473 QMessageBox mb( __VYM,
1474 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1475 QMessageBox::Question,
1477 QMessageBox::Cancel | QMessageBox::Default,
1478 QMessageBox::QMessageBox::NoButton );
1480 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1481 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1484 case QMessageBox::Yes:
1486 currentMapEditor()->setFilePath(fn);
1487 tabWidget->setTabLabel (currentMapEditor(),
1488 currentMapEditor()->getFileName() );
1489 statusBar()->message( "Created " + fn , statusbarTime );
1492 case QMessageBox::Cancel:
1493 // don't create new map
1494 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1501 //tabWidget->currentPage() won't be NULL here, because of above...
1502 tabWidget->showPage(me);
1503 me->viewport()->setFocus();
1505 // Create temporary directory for packing
1506 char tmpdir1[]="/tmp/vym-XXXXXX";
1507 QString tmpMapDir=mkdtemp(tmpdir1);
1509 // Try to unzip file
1510 err=unzipDir (tmpMapDir,fn);
1514 me->setZipped(false);
1517 me->setZipped(true);
1519 // Look for mapname.xml
1520 mapfile= fn.left(fn.findRev(".",-1,true));
1521 mapfile=mapfile.section( '/', -1 );
1522 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1523 if (!file.exists() )
1525 // mapname.xml does not exist, well,
1526 // maybe some renamed the mapname.vym file...
1527 // Try to find any .xml in the toplevel
1528 // directory of the .vym file
1529 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1530 if (flist.count()==1)
1532 // Only one entry, take this one
1533 mapfile=tmpMapDir + "/"+flist.first();
1536 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1537 *it=tmpMapDir + "/" + *it;
1538 // TODO Multiple entries, load all (but only the first one into this ME)
1539 //mainWindow->fileLoadFromTmp (flist);
1540 //returnCode=1; // Silently forget this attempt to load
1541 qWarning ("MainWindow::load (fn) multimap found...");
1544 if (flist.isEmpty() )
1546 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1547 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1550 } //file doesn't exist
1552 mapfile=file.name();
1557 // Save existing filename in case we import
1558 QString fn_org=me->getFilePath();
1560 // Finally load map into mapEditor
1561 me->setFilePath (mapfile,fn);
1562 err=me->load(mapfile,lmode);
1564 // Restore old (maybe empty) filepath, if this is an import
1566 me->setFilePath (fn_org);
1569 // Finally check for errors and go home
1572 if (lmode==NewMap) fileCloseMap();
1573 statusBar()->message( "Could not load " + fn, statusbarTime );
1578 me->setFilePath (fn);
1579 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1580 if (fn.left(9)!="/tmp/vym-")
1582 // Only append to lastMaps if not loaded from a tmpDir
1583 // e.g. imported bookmarks are in a tmpDir
1584 lastMaps.prepend(me->getFilePath() );
1585 setupLastMapsMenu();
1587 actionFilePrint->setEnabled (true);
1589 statusBar()->message( "Loaded " + fn, statusbarTime );
1593 removeDir (QDir(tmpMapDir));
1599 void Main::fileLoad(const LoadMode &lmode)
1601 QFileDialog *fd=new QFileDialog( this);
1602 if (!lastFileDir.isEmpty())
1603 fd->setDir (lastFileDir);
1604 fd->setMode (QFileDialog::ExistingFiles);
1605 fd->addFilter ("XML (*.xml)");
1606 fd->addFilter ("VYM map (*.vym *.vyp)");
1610 fd->setCaption(tr("Load vym map"));
1613 fd->setCaption(tr("Import: Add vym map to selection"));
1616 fd->setCaption(tr("Import: Replace selection with vym map"));
1622 if ( fd->exec() == QDialog::Accepted )
1624 lastFileDir=fd->dirPath();
1625 QStringList flist = fd->selectedFiles();
1626 QStringList::Iterator it = flist.begin();
1627 while( it != flist.end() )
1630 fileLoad(*it, lmode);
1637 void Main::fileLoad()
1642 void Main::fileLoadLast(int i)
1644 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1647 void Main::fileSave(const SaveMode &savemode)
1649 // tmp dir for zipping
1653 ErrorCode err=success;
1655 QString safeFilePath;
1657 bool saveZipped=currentMapEditor()->saveZipped();
1659 MapEditor * me=currentMapEditor();
1662 QString fn=me->getFilePath();
1663 // filename=unnamed, filepath="" in constructor...
1664 if ( !fn.isEmpty() )
1666 // We have a filepath, go on saving
1667 // First remove existing file, we
1668 // don't want to add to old zip archives
1672 QMessageBox::warning( 0, tr( "Save Error" ),
1673 fn+ tr("\ncould not be removed before saving"));
1675 // Look, if we should zip the data:
1678 QMessageBox mb( __VYM,
1679 tr("The map %1\ndid not use the compressed "
1680 "vym file format.\nWriting it uncompressed will also write images \n"
1681 "and flags and thus may overwrite files in the "
1682 "given directory\n\nDo you want to write the map").arg(fn),
1683 QMessageBox::Warning,
1684 QMessageBox::Yes | QMessageBox::Default,
1686 QMessageBox::Cancel | QMessageBox::Escape);
1687 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1688 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1689 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1692 case QMessageBox::Yes:
1693 // save compressed (default file format)
1696 case QMessageBox::No:
1697 // save uncompressed
1700 case QMessageBox::Cancel:
1709 char tmpdir1[]="/tmp/vym-XXXXXX";
1710 tmpMapDir=mkdtemp(tmpdir1);
1712 safeFilePath=me->getFilePath();
1713 me->setFilePath (tmpMapDir+"/"+
1714 me->getMapName()+ ".xml",
1716 me->save (savemode);
1717 me->setFilePath (safeFilePath);
1719 zipDir (tmpMapDir,fn);
1724 safeFilePath=me->getFilePath();
1725 me->setFilePath (fn, safeFilePath);
1726 me->save (savemode);
1727 me->setFilePath (safeFilePath);
1729 } // filepath available
1732 // We have no filepath yet,
1733 // call fileSaveAs() now, this will call fileSave()
1735 fileSaveAs(savemode);
1739 if (saveZipped && !tmpMapDir.isEmpty())
1741 removeDir (QDir(tmpMapDir));
1745 statusBar()->message(
1746 tr("Saved %1").arg(me->getFilePath()),
1748 lastMaps.prepend(me->getFilePath() );
1749 setupLastMapsMenu();
1751 statusBar()->message(
1752 tr("Couldn't save ").arg(me->getFilePath()),
1756 void Main::fileSave()
1758 fileSave (CompleteMap);
1761 void Main::fileSaveAs(const SaveMode& savemode)
1765 if (currentMapEditor())
1767 if (savemode==CompleteMap)
1768 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1770 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1771 if ( !fn.isEmpty() )
1773 // Check for existing file
1774 if (QFile (fn).exists())
1776 QMessageBox mb( __VYM,
1777 tr("The file %1\nexists already. Do you want to").arg(fn),
1778 QMessageBox::Warning,
1779 QMessageBox::Yes | QMessageBox::Default,
1780 QMessageBox::Cancel | QMessageBox::Escape,
1781 QMessageBox::QMessageBox::NoButton);
1782 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1783 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1786 case QMessageBox::Yes:
1789 case QMessageBox::Cancel:
1796 // New file, add extension to filename, if missing
1797 // This is always .vym or .vyp, depending on savemode
1798 if (savemode==CompleteMap)
1800 if (!fn.contains (".vym") && !fn.contains (".xml"))
1804 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1813 currentMapEditor()->setFilePath(fn);
1817 if (savemode==CompleteMap)
1818 tabWidget->setTabLabel (currentMapEditor(),
1819 currentMapEditor()->getFileName() );
1825 void Main::fileSaveAs()
1827 fileSaveAs (CompleteMap);
1830 void Main::fileImportKDEBookmarks()
1832 ImportKDEBookmarks im;
1834 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
1835 currentMapEditor()->setFilePath ("");
1838 void Main::fileImportFirefoxBookmarks()
1840 QFileDialog *fd=new QFileDialog( this);
1841 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
1842 fd->setMode (QFileDialog::ExistingFiles);
1843 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
1844 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
1847 if ( fd->exec() == QDialog::Accepted )
1849 ImportFirefoxBookmarks im;
1850 QStringList flist = fd->selectedFiles();
1851 QStringList::Iterator it = flist.begin();
1852 while( it != flist.end() )
1855 if (im.transform() &&
1856 success==fileLoad (im.getTransformedFile(),NewMap) &&
1857 currentMapEditor() )
1858 currentMapEditor()->setFilePath ("");
1865 void Main::fileImportMM()
1869 QFileDialog *fd=new QFileDialog( this);
1870 if (!lastFileDir.isEmpty())
1871 fd->setDir (lastFileDir);
1872 fd->setMode (QFileDialog::ExistingFiles);
1873 fd->addFilter ("Mind Manager (*.mmap)");
1874 fd->setCaption(tr("Import")+" "+"Mind Manager");
1877 if ( fd->exec() == QDialog::Accepted )
1879 lastFileDir=fd->dirPath();
1880 QStringList flist = fd->selectedFiles();
1881 QStringList::Iterator it = flist.begin();
1882 while( it != flist.end() )
1885 if (im.transform() &&
1886 success==fileLoad (im.getTransformedFile(),NewMap) &&
1887 currentMapEditor() )
1888 currentMapEditor()->setFilePath ("");
1897 void Main::fileImportDir()
1899 if (currentMapEditor())
1900 currentMapEditor()->importDir();
1903 void Main::fileExportXML()
1905 if (currentMapEditor())
1907 QString dir=browseDirectory(tr("Export XML to directory"));
1908 if (dir !="" && reallyWriteDirectory(dir) )
1909 currentMapEditor()->exportXML(dir);
1914 void Main::fileExportXHTML()
1916 MapEditor *me=currentMapEditor();
1920 ExportXHTMLDialog dia(this);
1921 dia.setFilePath (me->getFilePath() );
1922 dia.setMapName (me->getMapName() );
1925 if (dia.exec()==QDialog::Accepted)
1927 QString dir=dia.getDir();
1928 // Check, if warnings should be used before overwriting
1929 // the output directory
1932 ok=reallyWriteDirectory(dir);
1938 me->exportXML (dia.getDir() );
1939 dia.doExport(me->getMapName() );
1940 if (dia.hasChanged())
1947 void Main::fileExportImage(int item)
1949 MapEditor *me=currentMapEditor();
1952 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1954 if ( !fn.isEmpty() )
1955 me->exportImage(fn,item);
1957 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1962 void Main::fileExportASCII()
1964 MapEditor *me=currentMapEditor();
1968 ex.setMapCenter(me->getMapCenter());
1969 ex.addFilter ("TXT (*.txt)");
1970 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
1971 if (ex.execDialog() )
1973 me->setExportMode(true);
1975 me->setExportMode(false);
1980 void Main::fileExportLaTeX()
1982 MapEditor *me=currentMapEditor();
1986 ex.setMapCenter(me->getMapCenter());
1987 ex.addFilter ("Tex (*.tex)");
1988 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
1989 if (ex.execDialog() )
1991 me->setExportMode(true);
1993 me->setExportMode(false);
1998 void Main::fileExportKDEBookmarks()
2000 ExportKDEBookmarks ex;
2001 MapEditor *me=currentMapEditor();
2004 ex.setMapCenter (me->getMapCenter() );
2009 void Main::fileExportTaskjuggler()
2011 ExportTaskjuggler ex;
2012 MapEditor *me=currentMapEditor();
2015 ex.setMapCenter (me->getMapCenter() );
2016 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2017 ex.addFilter ("Taskjuggler (*.tjp)");
2018 if (ex.execDialog() )
2020 me->setExportMode(true);
2022 me->setExportMode(false);
2027 void Main::fileExportOOPresentation()
2029 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2030 // FIXME add extra info in dialog
2031 //ImagePreview *p =new ImagePreview (fd);
2032 //fd->setContentsPreviewEnabled( TRUE );
2033 //fd->setContentsPreview( p, p );
2034 //fd->setPreviewMode( QFileDialog::Contents );
2035 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2036 //fd->setDir (lastImageDir);
2039 if ( fd->exec() == QDialog::Accepted )
2041 QString fn=fd->selectedFile();
2042 //lastImageDir=fn.left(fn.findRev ("/"));
2043 if (currentMapEditor())
2044 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2048 void Main::fileCloseMap()
2050 if (currentMapEditor())
2052 if (currentMapEditor()->hasChanged())
2054 QMessageBox mb( __VYM,
2055 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2056 QMessageBox::Warning,
2057 QMessageBox::Yes | QMessageBox::Default,
2059 QMessageBox::Cancel | QMessageBox::Escape );
2060 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2061 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2064 case QMessageBox::Yes:
2066 fileSave(CompleteMap);
2068 case QMessageBox::No:
2069 // close without saving
2071 case QMessageBox::Cancel:
2076 currentMapEditor()->closeMap();
2077 tabWidget->removePage(currentMapEditor());
2078 if (tabWidget->count()==0)
2079 actionFilePrint->setEnabled (false);
2083 void Main::filePrint()
2085 if (currentMapEditor())
2086 currentMapEditor()->print();
2089 void Main::fileExitVYM()
2091 // Check if one or more editors have changed
2094 for (i=0;i<=tabWidget->count() -1;i++)
2097 me=(MapEditor*)tabWidget->page(i);
2099 // If something changed, ask what to do
2100 if (me->isUnsaved())
2102 tabWidget->setCurrentPage(i);
2103 QMessageBox mb( __VYM,
2104 tr("This map is not saved yet. Do you want to"),
2105 QMessageBox::Warning,
2106 QMessageBox::Yes | QMessageBox::Default,
2108 QMessageBox::Cancel | QMessageBox::Escape );
2109 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2110 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2112 // Call undocumented function: setActiveWindow is only
2113 // possible, if widget is visible. This depends on
2115 #if defined(Q_OS_LINUX)
2116 qt_wait_for_window_manager( this);
2118 mb.setActiveWindow();
2119 switch( mb.exec() ) {
2120 case QMessageBox::Yes:
2121 // save (the changed editors) and exit
2122 fileSave(CompleteMap);
2124 case QMessageBox::No:
2125 // exit without saving
2127 case QMessageBox::Cancel:
2128 // don't save and don't exit
2132 } // loop over all MEs
2136 void Main::editUndo()
2138 if (currentMapEditor())
2139 currentMapEditor()->undo();
2142 void Main::editRedo()
2144 if (currentMapEditor())
2145 currentMapEditor()->redo();
2148 void Main::editCopy()
2150 if (currentMapEditor())
2151 currentMapEditor()->copy();
2154 void Main::editPaste()
2156 if (currentMapEditor())
2157 currentMapEditor()->paste();
2160 void Main::editCut()
2162 if (currentMapEditor())
2163 currentMapEditor()->cut();
2166 void Main::editOpenFindWindow()
2168 findWindow->popup();
2169 findWindow->raise();
2171 // Call undocumented function: setActiveWindow is only
2172 // possible, if widget is visible. This depends on
2174 #if defined(Q_OS_LINUX)
2175 qt_wait_for_window_manager( this);
2177 findWindow->setActiveWindow();
2180 void Main::editFind(QString s)
2183 BranchObj *bo=currentMapEditor()->findText(s, cs);
2186 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2189 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2190 tr("No matches found for <b>%1</b>").arg(s));
2194 void Main::editFindChanged()
2195 { // Notify editor, to abort the current find process
2196 currentMapEditor()->findReset();
2199 void Main::editOpenURL()
2202 if (currentMapEditor())
2204 QString url=currentMapEditor()->getURL();
2205 if (url=="") return;
2206 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2207 procBrowser = new QProcess( this );
2209 procBrowser->addArgument( browser);
2210 procBrowser->addArgument( url);
2212 if ( !procBrowser->start() )
2214 // try to set path to browser
2215 QMessageBox::warning(0,
2217 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2218 tr("Please use Settings->")+tr("Set application to open an URL"));
2223 void Main::editOpenURLTab()
2225 if (currentMapEditor())
2227 QString url=currentMapEditor()->getURL();
2228 if (url=="") return;
2229 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2230 if (browser.contains("konqueror") && procBrowser && procBrowser->isRunning())
2232 // Try to open new tab in existing browser
2233 QProcess *p=new QProcess (this);
2234 p->addArgument ("dcop");
2235 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2236 p->addArgument ("konqueror-mainwindow#1");
2237 p->addArgument ("newTab");
2238 p->addArgument (url);
2240 // try to set browser
2241 QMessageBox::warning(0,
2243 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2250 void Main::editURL()
2252 if (currentMapEditor())
2253 currentMapEditor()->editURL();
2256 void Main::editHeading2URL()
2258 if (currentMapEditor())
2259 currentMapEditor()->editHeading2URL();
2262 void Main::editBugzilla2URL()
2264 if (currentMapEditor())
2265 currentMapEditor()->editBugzilla2URL();
2268 void Main::editFATE2URL()
2270 if (currentMapEditor())
2271 currentMapEditor()->editFATE2URL();
2274 void Main::editOpenVymLink()
2276 // Get current path to map
2277 QString currentVymLink;
2278 if (currentMapEditor())
2280 currentVymLink=currentMapEditor()->getVymLink();
2281 // compare path with already loaded maps
2285 for (i=0;i<=tabWidget->count() -1;i++)
2287 me=(MapEditor*)tabWidget->page(i);
2288 if (currentVymLink==me->getFilePath() )
2297 if (!QFile(currentVymLink).exists() )
2298 QMessageBox::critical( 0, tr( "Critical Error" ),
2299 tr("Couldn't open map %1").arg(currentVymLink));
2302 fileLoad (currentVymLink, NewMap);
2303 tabWidget->setCurrentPage (tabWidget->count()-1);
2306 // Go to tab containing the map
2307 tabWidget->setCurrentPage (index);
2311 void Main::editVymLink()
2313 if (currentMapEditor())
2314 currentMapEditor()->editVymLink();
2317 void Main::editDeleteVymLink()
2319 if (currentMapEditor())
2320 currentMapEditor()->deleteVymLink();
2323 void Main::editToggleHideExport()
2325 if (currentMapEditor())
2326 currentMapEditor()->toggleHideExport();
2329 void Main::editMapInfo()
2331 if (currentMapEditor())
2332 currentMapEditor()->editMapInfo();
2335 void Main::editMoveUp()
2337 if (currentMapEditor())
2338 currentMapEditor()->moveBranchUp();
2341 void Main::editMoveDown()
2343 if (currentMapEditor())
2344 currentMapEditor()->moveBranchDown();
2347 void Main::editToggleScroll()
2349 if (currentMapEditor())
2351 currentMapEditor()->toggleScroll();
2355 void Main::editUnScrollAll()
2357 if (currentMapEditor())
2359 currentMapEditor()->unScrollAll();
2363 void Main::editHeading()
2365 if (currentMapEditor())
2366 currentMapEditor()->editHeading();
2369 void Main::editNewBranch()
2371 if (currentMapEditor())
2372 currentMapEditor()->addNewBranch(0);
2375 void Main::editNewBranchHere()
2377 if (currentMapEditor())
2378 currentMapEditor()->addNewBranchHere();
2381 void Main::editNewBranchAbove()
2383 if (currentMapEditor())
2384 currentMapEditor()->addNewBranch(-1);
2387 void Main::editNewBranchBelow()
2389 if (currentMapEditor())
2390 currentMapEditor()->addNewBranch(1);
2393 void Main::editImportAdd()
2395 fileLoad (ImportAdd);
2398 void Main::editImportReplace()
2400 fileLoad (ImportReplace);
2403 void Main::editSaveBranch()
2405 fileSaveAs (PartOfMap);
2408 void Main::editRemoveBranchKeepChilds()
2410 if (currentMapEditor())
2411 currentMapEditor()->removeBranchKeepChilds();
2414 void Main::editRemoveChilds()
2416 if (currentMapEditor())
2417 currentMapEditor()->removeChilds();
2420 void Main::editDeleteSelection()
2422 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2423 currentMapEditor()->deleteSelection();
2426 void Main::editUpperBranch()
2428 if (currentMapEditor())
2429 currentMapEditor()->selectUpperBranch();
2432 void Main::editLowerBranch()
2434 if (currentMapEditor())
2435 currentMapEditor()->selectLowerBranch();
2438 void Main::editLeftBranch()
2440 if (currentMapEditor())
2441 currentMapEditor()->selectLeftBranch();
2444 void Main::editRightBranch()
2446 if (currentMapEditor())
2447 currentMapEditor()->selectRightBranch();
2450 void Main::editFirstBranch()
2452 if (currentMapEditor())
2453 currentMapEditor()->selectFirstBranch();
2456 void Main::editLastBranch()
2458 if (currentMapEditor())
2459 currentMapEditor()->selectLastBranch();
2462 void Main::editLoadImage()
2464 if (currentMapEditor())
2465 currentMapEditor()->loadFloatImage();
2468 void Main::editSaveImage(int item)
2470 if (currentMapEditor())
2471 currentMapEditor()->saveFloatImage(item);
2474 void Main::editFollowXLink(int item)
2476 if (currentMapEditor())
2477 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2480 void Main::editEditXLink(int item)
2482 if (currentMapEditor())
2483 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2486 void Main::formatSelectColor()
2488 if (currentMapEditor())
2490 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2491 if ( !col.isValid() ) return;
2492 currentMapEditor()->setColor( col );
2493 colorChanged( col );
2497 void Main::formatPickColor()
2499 if (currentMapEditor())
2500 colorChanged( currentMapEditor()->pickColor() );
2503 void Main::colorChanged(QColor c)
2505 QPixmap pix( 16, 16 );
2507 actionFormatColor->setIconSet( pix );
2510 void Main::formatColorItem()
2512 if (currentMapEditor())
2513 currentMapEditor()->colorItem();
2516 void Main::formatColorBranch()
2518 if (currentMapEditor())
2519 currentMapEditor()->colorBranch();
2522 void Main::formatLinkStyleLine()
2524 if (currentMapEditor())
2525 currentMapEditor()->setLinkStyle(StyleLine);
2528 void Main::formatLinkStyleParabel()
2530 if (currentMapEditor())
2531 currentMapEditor()->setLinkStyle(StyleParabel);
2534 void Main::formatLinkStylePolyLine()
2536 if (currentMapEditor())
2537 currentMapEditor()->setLinkStyle(StylePolyLine);
2540 void Main::formatLinkStylePolyParabel()
2542 if (currentMapEditor())
2543 currentMapEditor()->setLinkStyle(StylePolyParabel);
2546 void Main::formatSelectBackColor()
2548 if (currentMapEditor())
2549 currentMapEditor()->selectBackgroundColor();
2552 void Main::formatSelectLinkColor()
2554 if (currentMapEditor())
2555 currentMapEditor()->selectLinkColor();
2558 void Main::formatToggleLinkColorHint()
2560 currentMapEditor()->toggleLinkColorHint();
2563 void Main::formatFrameNone()
2565 if (currentMapEditor())
2566 currentMapEditor()->setFrame(NoFrame);
2569 void Main::formatFrameRectangle()
2571 if (currentMapEditor())
2572 currentMapEditor()->setFrame(Rectangle);
2575 void Main::formatIncludeImagesVer()
2577 if (currentMapEditor())
2578 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2581 void Main::formatIncludeImagesHor()
2583 if (currentMapEditor())
2584 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2587 void Main::formatHideLinkUnselected()
2589 if (currentMapEditor())
2590 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2593 void Main::viewZoomReset()
2595 if (currentMapEditor())
2599 currentMapEditor()->setWorldMatrix( m );
2600 currentMapEditor()->setViewCenter();
2601 currentMapEditor()->adjustCanvasSize();
2605 void Main::viewZoomIn()
2607 if (currentMapEditor())
2609 QWMatrix m = currentMapEditor()->worldMatrix();
2610 m.scale( 1.25, 1.25 );
2611 currentMapEditor()->setWorldMatrix( m );
2612 currentMapEditor()->setViewCenter();
2613 currentMapEditor()->adjustCanvasSize();
2617 void Main::viewZoomOut()
2619 if (currentMapEditor())
2621 QWMatrix m = currentMapEditor()->worldMatrix();
2622 m.scale( 0.8, 0.8 );
2623 currentMapEditor()->setWorldMatrix( m );
2624 currentMapEditor()->setViewCenter();
2625 currentMapEditor()->adjustCanvasSize();
2629 void Main::modModeColor()
2633 void Main::modModeLink()
2637 bool Main::settingsPDF()
2639 // Default browser is set in constructor
2641 QString text = QInputDialog::getText(
2642 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2643 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2645 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2650 bool Main::settingsURL()
2652 // Default browser is set in constructor
2654 QString text = QInputDialog::getText(
2655 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2656 settings.readEntry("/vym/mainwindow/readerURL")
2659 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2663 void Main::settingsToggleDelKey()
2665 if (actionSettingsUseDelKey->isOn())
2667 actionEditDelete->setAccel (QKeySequence (Key_Delete));
2670 actionEditDelete->setAccel (QKeySequence (""));
2674 void Main::windowToggleNoteEditor()
2676 if (textEditor->showWithMain() )
2677 windowHideNoteEditor();
2679 windowShowNoteEditor();
2682 void Main::windowToggleHistory()
2684 if (currentMapEditor())
2685 currentMapEditor()->toggleHistoryWindow();
2688 void Main::updateNoteFlag()
2690 if (currentMapEditor())
2691 currentMapEditor()->updateNoteFlag();
2694 void Main::windowShowNoteEditor()
2696 textEditor->setShowWithMain(true);
2698 actionViewToggleNoteEditor->setOn (true);
2701 void Main::windowHideNoteEditor()
2703 textEditor->setShowWithMain(false);
2705 actionViewToggleNoteEditor->setOn (false);
2708 void Main::windowNextEditor()
2710 if (tabWidget->currentPageIndex() < tabWidget->count())
2711 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2714 void Main::windowPreviousEditor()
2716 if (tabWidget->currentPageIndex() >0)
2717 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2720 void Main::standardFlagChanged()
2722 currentMapEditor()->toggleStandardFlag(sender()->name());
2725 void Main::testFunction()
2727 currentMapEditor()->testFunction();
2730 void Main::helpDoc()
2733 #if defined(Q_OS_MACX)
2734 docpath="./vym.app/Contents/vym.pdf";
2736 // default path in SUSE LINUX
2737 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2740 if (!QFile (docpath).exists() )
2742 // relative path for easy testing in tarball
2743 docpath="doc/vym.pdf";
2744 if (!QFile (docpath).exists() )
2746 // relative path for testing while still writing vym.tex
2747 docpath="doc/tex/vym.pdf";
2748 if (!QFile (docpath).exists() )
2750 // Try yet another one for Knoppix
2751 docpath="/usr/share/doc/packages/vym/vym.pdf";
2752 if (!QFile (docpath).exists() )
2754 QMessageBox::critical(0,
2755 tr("Critcal error"),
2756 tr("Couldn't find the documentation\n"
2757 "vym.pdf in various places."));
2764 Process *pdfProc = new Process();
2765 pdfProc->clearArguments();
2766 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2767 pdfProc->addArgument( docpath);
2769 if ( !pdfProc->start() )
2772 QMessageBox::warning(0,
2774 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
2775 tr("Please use Settings->")+tr("Set application to open PDF files"));
2782 void Main::helpAbout()
2785 ad.setName ("aboutwindow");
2786 ad.setMinimumSize(500,500);
2787 ad.resize (QSize (500,500));
2791 void Main::helpAboutQT()
2793 QMessageBox::aboutQt( this, "Qt Application Example" );