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
24 #include "aboutdialog.h"
26 #include "icons/filenew.xpm"
27 #include "icons/fileopen.xpm"
28 #include "icons/filesave.xpm"
29 #include "icons/fileprint.xpm"
30 #include "icons/editundo.xpm"
31 #include "icons/editredo.xpm"
32 #include "icons/editcopy.xpm"
33 #include "icons/editcut.xpm"
34 #include "icons/editpaste.xpm"
35 #include "icons/editmoveup.xpm"
36 #include "icons/editmovedown.xpm"
37 #include "icons/formatcoloritem.xpm"
38 #include "icons/formatcolorbranch.xpm"
39 #include "icons/formatcolorpicker.xpm"
40 #include "icons/viewzoomreset.xpm"
41 #include "icons/viewzoomin.xpm"
42 #include "icons/viewzoomout.xpm"
43 #include "icons/modecolor.xpm"
44 #include "icons/modelink.xpm"
45 #include "icons/modecopy.xpm"
46 //#include "icons/vym-48x48.xpm"
48 #include "icons/flag-questionmark.xpm"
49 #include "icons/flag-exclamationmark.xpm"
50 #include "icons/flag-hook-green.xpm"
51 #include "icons/flag-cross-red.xpm"
52 #include "icons/flag-stopsign.xpm"
53 #include "icons/flag-smiley-good.xpm"
54 #include "icons/flag-smiley-sad.xpm"
55 #include "icons/flag-clock.xpm"
56 #include "icons/flag-lamp.xpm"
57 #include "icons/flag-arrow-up.xpm"
58 #include "icons/flag-arrow-down.xpm"
59 #include "icons/flag-thumb-up.xpm"
60 #include "icons/flag-thumb-down.xpm"
61 #include "icons/flag-heart.xpm"
62 #include "icons/flag-flash.xpm"
63 #include "icons/flag-lifebelt.xpm"
65 #include "icons/flag-note.xpm"
66 #include "icons/flag-url.xpm"
67 #include "icons/flag-vymlink.xpm"
68 #include "icons/flag-scrolled-right.xpm"
69 #include "icons/flag-tmpUnscrolled-right.xpm"
71 #include "flagrowobj.h"
72 #include "texteditor.h"
73 #include "mapeditor.h"
74 #include "exporthtmldialog.h"
75 #include "exportxhtmldialog.h"
76 #include "showtextdialog.h"
81 extern TextEditor *textEditor;
82 extern Main *mainWindow;
83 extern QString tmpVymDir;
84 extern QString clipboardDir;
85 extern bool clipboardEmpty;
86 extern int statusbarTime;
87 extern MapEditor *clipboardME;
88 extern FlagRowObj* standardFlagsDefault;
89 extern FlagRowObj* systemFlagsDefault;
91 extern QPtrList <QAction> actionListBranches;
93 extern QAction* actionFileSave;
94 extern QAction* actionFilePrint;
95 extern QAction* actionEditUndo;
96 extern QAction* actionEditRedo;
97 extern QAction *actionEditCopy;
98 extern QAction *actionEditCut;
99 extern QAction *actionEditPaste;
100 extern QAction *actionEditMoveUp;
101 extern QAction *actionEditMoveDown;
102 extern QAction *actionEditToggleScroll;
103 extern QAction* actionEditOpenURL;
104 extern QAction* actionEditURL;
105 extern QAction* actionEditHeading2URL;
106 extern QAction* actionEditBugzilla2URL;
107 extern QAction *actionEditOpenVymLink;
108 extern QAction *actionEditVymLink;
109 extern QAction *actionEditDeleteVymLink;
110 extern QAction *actionEditMapInfo;
111 extern QAction *actionEditHeading;
112 extern QAction *actionEditDelete;
113 extern QAction *actionEditAddBranch;
114 extern QAction *actionEditAddBranchHere;
115 extern QAction *actionEditAddBranchAbove;
116 extern QAction *actionEditAddBranchBelow;
117 extern QAction *actionEditRemoveBranchHere;
118 extern QAction *actionEditRemoveChilds;
119 extern QAction *actionEditImportAdd;
120 extern QAction *actionEditImportReplace;
121 extern QAction *actionEditSaveBranch;
122 extern QAction *actionEditSelectFirst;
123 extern QAction *actionEditSelectLast;
124 extern QAction *actionEditLoadImage;
125 extern QAction *actionEditToggleFloatExport;
127 extern QAction* actionFormatColor;
128 extern QAction* actionFormatPickColor;
129 extern QAction* actionFormatColorBranch;
130 extern QAction* actionFormatColorSubtree;
131 extern QAction* actionFormatLinkColorHint;
132 extern QAction* actionFormatBackColor;
133 extern QAction* actionFormatLinkColor;
135 extern QActionGroup* actionGroupModModes;
136 extern QAction* actionModModeColor;
137 extern QAction* actionModModeLink;
138 extern QAction* actionModModeCopy;
140 extern QActionGroup *actionGroupFormatFrameTypes;
141 extern QAction *actionFormatFrameNone;
142 extern QAction *actionFormatFrameRectangle;
144 extern QActionGroup *actionGroupFormatLinkStyles;
145 extern QAction *actionFormatLinkStyleLine;
146 extern QAction *actionFormatLinkStyleParabel;
147 extern QAction *actionFormatLinkStylePolyLine;
148 extern QAction *actionFormatLinkStylePolyParabel;
149 extern QAction *actionFormatHideLinkUnselected;
151 extern QAction *actionViewToggleNoteEditor;
153 extern QAction* actionSettingsAutoedit;
154 extern QAction* actionSettingsAutoselectHeading;
155 extern QAction* actionSettingsAutoselectHeading;
156 extern QAction* actionSettingsAutoselectText;
157 extern QAction* actionSettingsPasteNewHeading;
158 extern QAction* actionSettingsUseDelKey;
159 extern QAction* actionSettingsUseFlagGroups;
161 extern QPopupMenu* branchContextMenu;
162 extern QPopupMenu* branchAddContextMenu;
163 extern QPopupMenu* branchRemoveContextMenu;
164 extern QPopupMenu* branchLinksContextMenu;
165 extern QPopupMenu* branchLinksContextMenuDup;
166 extern QPopupMenu* floatimageContextMenu;
167 extern QPopupMenu* saveImageFormatMenu;
168 extern QPopupMenu* canvasContextMenu;
169 extern QPopupMenu* lastMapsMenu;
170 extern QPopupMenu* exportMenu;
171 extern QPopupMenu* exportImageFormatMenu;
174 extern Settings settings;
175 extern Options options;
177 #if defined(Q_OS_LINUX)
178 extern void qt_wait_for_window_manager( QWidget* w );
181 Main::Main(QWidget* parent, const char* name, WFlags f) :
182 QMainWindow(parent,name,f)
186 setCaption ("VYM - View Your Mind");
188 // Load window settings
189 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
190 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
191 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
192 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
195 // Create unique temporary directory
196 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
198 // Create direcctory for clipboard
199 clipboardDir=tmpVymDir+"/clipboard";
200 QDir d(clipboardDir);
201 d.mkdir (clipboardDir,true);
202 makeSubDirs (clipboardDir);
205 // FIXME not used currently
206 // Set random seed (random used for object IDs)
207 // QTime t = QTime::currentTime(); // set random seed
208 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
211 // Initialize some settings, which are platform dependant
214 // application to open URLs
215 p="/vym/mainwindow/readerURL";
216 #if defined(Q_OS_LINUX)
217 s=settings.readEntry (p,"konqueror");
219 #if defined(Q_OS_MACX)
220 s=settings.readEntry (p,"/usr/bin/open");
222 s=settings.readEntry (p,"mozilla");
225 settings.writeEntry( p,s);
227 // application to open PDFs
228 p="/vym/mainwindow/readerPDF";
229 #if defined(Q_OS_LINUX)
230 s=settings.readEntry (p,"acroread");
232 #if defined(Q_OS_MACX)
233 s=settings.readEntry (p,"/usr/bin/open");
235 s=settings.readEntry (p,"acroread");
238 settings.writeEntry( p,s);
243 // Create tab widget which holds the maps
244 tabWidget= new QTabWidget (this);
245 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
246 this, SLOT( editorChanged( QWidget * ) ) );
248 setCentralWidget(tabWidget);
252 setupFormatActions();
256 setupSettingsActions();
258 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
261 // After menu is created, we can enable some actions
262 actionFilePrint->setEnabled (true);
267 // Initialize Find window
268 findWindow=new FindWindow(NULL,"findwindow");
269 connect (findWindow, SIGNAL( findButton(QString) ),
270 this, SLOT(editFind(QString) ) );
271 connect (findWindow, SIGNAL( somethingChanged() ),
272 this, SLOT(editFindChanged() ) );
274 // Connect TextEditor, so that we can update flags if text changes
275 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
283 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
284 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
285 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
286 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
288 settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
289 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
291 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
292 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
293 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
294 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
295 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
296 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
299 int maps=lastMaps.count();
300 settings.writeEntry( "/vym/lastMaps/number",maps );
301 for (int i=1;i<=maps;i++)
303 QStringList::Iterator it = lastMaps.at(i-1);
304 s=QString("/vym/lastMaps/map-%1").arg(i);
305 if (!s.isEmpty() && i<=maxLastMaps)
306 settings.writeEntry (s, *it);
310 // To make the texteditor save its settings, call the destructor
313 // Remove temporary directory
314 removeDir (QDir(tmpVymDir));
317 void Main::loadCmdLine()
319 /* TODO draw some kind of splashscreen while loading...
325 QStringList flist=options.getFileList();
326 QStringList::Iterator it=flist.begin();
328 while (it !=flist.end() )
330 fileLoad (*it, NewMap);
336 void Main::statusMessage(const QString &s)
338 statusBar()->message (s);
341 void Main::closeEvent (QCloseEvent* )
347 void Main::setupFileActions()
349 QToolBar *tb = new QToolBar( this );
350 tb->setLabel( "File Actions" );
351 QPopupMenu *menu = new QPopupMenu( this );
352 menuBar()->insertItem( tr( "&File" ), menu );
354 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
357 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
358 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
362 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
363 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
367 lastMapsMenu = new QPopupMenu (this);
369 menu->insertItem (tr("Open Recent"),lastMapsMenu );
370 menu->insertSeparator();
372 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
373 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
378 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
379 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
382 menu->insertSeparator();
384 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
385 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
388 exportMenu = new QPopupMenu (this);
389 menu->insertItem (tr("Export"),exportMenu );
391 menu->insertSeparator();
394 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
395 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
400 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
401 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
404 a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
405 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
411 void Main::setupEditActions()
413 QToolBar *tb = new QToolBar( this );
414 tb->setLabel( "Edit Actions" );
415 QPopupMenu *menu = new QPopupMenu( this );
416 menuBar()->insertItem( tr( "&Edit" ), menu );
420 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
421 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
422 a->setEnabled (false);
427 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
429 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
430 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
435 menu->insertSeparator();
436 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
437 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
438 a->setEnabled (false);
442 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
443 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
444 a->setEnabled (false);
448 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
449 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
450 a->setEnabled (false);
455 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
456 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
457 a->setEnabled (false);
460 actionListBranches.append(a);
463 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
464 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
465 a->setEnabled (false);
468 actionListBranches.append(a);
469 actionEditMoveDown=a;
472 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
473 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
474 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
475 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
476 #if defined(Q_OS_MACX)
477 actionEditToggleScroll=alt;
479 actionEditToggleScroll=a;
481 actionEditToggleScroll->setEnabled (false);
482 actionEditToggleScroll->addTo( tb );
483 actionEditToggleScroll->addTo( menu );
484 actionListBranches.append(actionEditToggleScroll);
486 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
487 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
490 menu->insertSeparator();
492 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
493 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
496 menu->insertSeparator();
498 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
499 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
501 a->setEnabled (false);
504 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
505 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
506 a->setEnabled (false);
507 actionListBranches.append(a);
510 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
511 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
512 a->setEnabled (false);
513 actionListBranches.append(a);
514 actionEditHeading2URL=a;
516 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
517 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
518 a->setEnabled (false);
519 actionListBranches.append(a);
520 actionEditBugzilla2URL=a;
523 a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flag_vymlink_xpm), tr( "Jump to map" ), 0, this, "jumpMap" );
524 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
526 a->setEnabled (false);
527 actionEditOpenVymLink=a;
529 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
530 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
531 a->setEnabled (false);
532 actionListBranches.append(a);
535 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
536 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
537 a->setEnabled (false);
538 actionEditDeleteVymLink=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 actionEditAddBranch=alt;
577 actionEditAddBranch=a;
580 // Add branch by inserting it at selection
581 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
582 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
583 a->setEnabled (false);
584 actionListBranches.append(a);
585 actionEditAddBranchHere=a;
588 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
589 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
590 a->setEnabled (false);
591 actionListBranches.append(a);
592 actionEditAddBranchAbove=a;
595 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
596 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
597 a->setEnabled (false);
598 actionListBranches.append(a);
599 actionEditAddBranchBelow=a;
601 // Import at selection (adding to selection)
602 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
603 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
604 a->setEnabled (false);
605 actionListBranches.append(a);
606 actionEditImportAdd=a;
608 // Import at selection (replacing selection)
609 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
610 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
611 a->setEnabled (false);
612 actionListBranches.append(a);
613 actionEditImportReplace=a;
616 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
617 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
618 a->setEnabled (false);
619 actionListBranches.append(a);
620 actionEditSaveBranch=a;
622 // Only remove branch, not its childs
623 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
624 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
625 a->setEnabled (false);
626 actionListBranches.append(a);
627 actionEditRemoveBranchHere=a;
629 // Only remove childs of a branch
630 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
631 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 actionEditRemoveChilds=a;
636 // Shortcuts for navigating with cursor:
637 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
638 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
639 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
640 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
641 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
642 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
643 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
644 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
645 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
646 a->setEnabled (false);
648 actionListBranches.append(a);
649 actionEditSelectFirst=a;
650 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
651 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
652 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
653 a->setEnabled (false);
655 actionListBranches.append(a);
656 actionEditSelectLast=a;
658 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
659 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
660 actionEditLoadImage=a;
665 void Main::setupFormatActions()
667 QPopupMenu *menu = new QPopupMenu( this );
668 menuBar()->insertItem( tr( "&Format" ), menu );
670 QToolBar *tb = new QToolBar( this );
674 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
675 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
676 actionFormatColor->addTo( tb );
677 actionFormatColor->addTo( menu );
678 a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(formatcolorpicker_xpm), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" );
679 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
680 a->setEnabled (false);
683 actionListBranches.append(a);
684 actionFormatPickColor=a;
685 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
686 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
687 a->setEnabled (false);
690 actionListBranches.append(a);
691 actionFormatColorBranch=a;
692 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
693 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
694 a->setEnabled (false);
697 actionListBranches.append(a);
698 actionFormatColorSubtree=a;
700 menu->insertSeparator();
701 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
702 actionGroupFormatLinkStyles->setExclusive (true);
703 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
704 a->setToggleAction(true);
705 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
706 actionFormatLinkStyleLine=a;
707 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
708 a->setToggleAction(true);
709 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
710 actionFormatLinkStyleParabel=a;
711 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
712 a->setToggleAction(true);
713 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
714 actionFormatLinkStylePolyLine=a;
715 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
716 a->setToggleAction(true);
717 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
718 actionFormatLinkStylePolyParabel=a;
719 actionGroupFormatLinkStyles->addTo (menu);
721 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
722 actionGroupFormatFrameTypes->setExclusive (true);
723 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
724 a->setToggleAction(true);
725 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
726 actionFormatFrameNone=a;
727 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
728 a->setToggleAction(true);
729 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
730 actionFormatFrameRectangle=a;
732 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
733 a->setToggleAction(true);
734 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
735 actionFormatHideLinkUnselected=a;
737 menu->insertSeparator();
738 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
739 a->setToggleAction(true);
740 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
742 actionFormatLinkColorHint=a;
744 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
745 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
746 actionFormatLinkColor->addTo( menu );
747 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
748 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
749 actionFormatBackColor->addTo( menu );
753 void Main::setupViewActions()
755 QToolBar *tb = new QToolBar( this );
756 tb->setLabel( "View Actions" );
757 QPopupMenu *menu = new QPopupMenu( this );
758 menuBar()->insertItem( tr( "&View" ), menu );
761 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
762 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
765 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
766 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
769 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
770 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
773 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
774 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
775 a->setToggleAction(true);
776 if (textEditor->showWithMain())
782 actionViewToggleNoteEditor=a;
783 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
784 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
786 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
787 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
792 void Main::setupModeActions()
794 //QPopupMenu *menu = new QPopupMenu( this );
795 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
797 QToolBar *tb = new QToolBar( this );
798 tb->setLabel( tr ("Modes when using modifiers") );
800 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
801 actionGroupModModes->setExclusive (true);
802 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
803 a->setToggleAction(true);
806 actionModModeColor=a;
808 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
809 a->setToggleAction(true);
813 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
814 a->setToggleAction(true);
820 void Main::setupFlagActions()
822 // Create System Flags
823 systemFlagsDefault = new FlagRowObj ();
824 systemFlagsDefault->setVisibility (false);
825 systemFlagsDefault->setName ("systemFlagsDef");
827 FlagObj *fo = new FlagObj ();
828 fo->load(QPixmap(flag_note_xpm));
830 fo->setToolTip(tr("Note","Systemflag"));
831 systemFlagsDefault->addFlag (fo); // makes deep copy
833 fo->load(QPixmap(flag_url_xpm));
835 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
836 systemFlagsDefault->addFlag (fo);
838 fo->load(QPixmap(flag_vymlink_xpm));
839 fo->setName("vymLink");
840 fo->setToolTip(tr("Link to another vym map","Systemflag"));
841 systemFlagsDefault->addFlag (fo);
843 fo->load(QPixmap(flag_scrolled_right_xpm));
844 fo->setName("scrolledright");
845 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
846 systemFlagsDefault->addFlag (fo);
848 fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
849 fo->setName("tmpUnscrolledright");
850 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
851 systemFlagsDefault->addFlag (fo);
853 // Create Standard Flags
854 standardFlagsDefault = new FlagRowObj ();
855 standardFlagsDefault->setVisibility (false);
856 standardFlagsDefault->setName ("standardFlagsDef");
858 fo->load(QPixmap(flag_exclamationmark_xpm));
859 fo->setName ("exclamationmark");
860 fo->setGroup("standard-mark");
861 fo->setToolTip(tr("Take care!","Standardflag"));
862 standardFlagsDefault->addFlag (fo); // makes deep copy
864 fo->load(QPixmap(flag_questionmark_xpm));
865 fo->setName("questionmark");
866 fo->setGroup("standard-mark");
867 fo->setToolTip(tr("Really?","Standardflag"));
868 standardFlagsDefault->addFlag (fo);
870 fo->load(QPixmap(flag_hook_green_xpm));
871 fo->setName("hook-green");
872 fo->setGroup("standard-hook");
873 fo->setToolTip(tr("ok!","Standardflag"));
874 standardFlagsDefault->addFlag (fo);
876 fo->load(QPixmap(flag_cross_red_xpm));
877 fo->setName("cross-red");
878 fo->setGroup("standard-hook");
879 fo->setToolTip(tr("Not ok!","Standardflag"));
880 standardFlagsDefault->addFlag (fo);
882 fo->load(QPixmap(flag_stopsign_xpm));
883 fo->setName("stopsign");
884 fo->setToolTip(tr("This won't work!","Standardflag"));
885 standardFlagsDefault->addFlag (fo);
887 fo->load(QPixmap(flag_smiley_good_xpm));
888 fo->setName("smiley-good");
889 fo->setGroup("standard-smiley");
890 fo->setToolTip(tr("Good","Standardflag"));
891 standardFlagsDefault->addFlag (fo);
893 fo->load(QPixmap(flag_smiley_sad_xpm));
894 fo->setName("smiley-sad");
895 fo->setGroup("standard-smiley");
896 fo->setToolTip(tr("Bad","Standardflag"));
897 standardFlagsDefault->addFlag (fo);
899 fo->load(QPixmap(flag_clock_xpm));
900 fo->setName("clock");
901 fo->setToolTip(tr("Time critical","Standardflag"));
902 standardFlagsDefault->addFlag (fo);
904 fo->load(QPixmap(flag_lamp_xpm));
906 fo->setToolTip(tr("Idea!","Standardflag"));
907 standardFlagsDefault->addFlag (fo);
909 fo->load(QPixmap(flag_arrow_up_xpm));
910 fo->setName("arrow-up");
911 fo->setGroup("standard-arrow");
912 fo->setToolTip(tr("Important","Standardflag"));
913 standardFlagsDefault->addFlag (fo);
915 fo->load(QPixmap(flag_arrow_down_xpm));
916 fo->setName("arrow-down");
917 fo->setGroup("standard-arrow");
918 fo->setToolTip(tr("Unimportant","Standardflag"));
919 standardFlagsDefault->addFlag (fo);
921 fo->load(QPixmap(flag_thumb_up_xpm));
922 fo->setName("thumb-up");
923 fo->setGroup("standard-thumb");
924 fo->setToolTip(tr("I like this","Standardflag"));
925 standardFlagsDefault->addFlag (fo);
927 fo->load(QPixmap(flag_thumb_down_xpm));
928 fo->setName("thumb-down");
929 fo->setGroup("standard-thumb");
930 fo->setToolTip(tr("I like this","Standardflag"));
931 fo->setToolTip(tr("I do not like this","Standardflag"));
932 standardFlagsDefault->addFlag (fo);
934 fo->load(QPixmap(flag_heart_xpm));
935 fo->setName("heart");
936 fo->setToolTip(tr("I just love... ","Standardflag"));
937 standardFlagsDefault->addFlag (fo);
939 fo->load(QPixmap(flag_flash_xpm));
940 fo->setName("flash");
941 fo->setToolTip(tr("Dangerous","Standardflag"));
942 standardFlagsDefault->addFlag (fo);
944 fo->load(QPixmap(flag_lifebelt_xpm));
945 fo->setName("lifebelt");
946 fo->setToolTip(tr("This will help","Standardflag"));
947 standardFlagsDefault->addFlag (fo);
950 standardFlagsDefault->makeToolbar(this, "Standard Flags");
954 void Main::setupSettingsActions()
956 QPopupMenu *menu = new QPopupMenu( this );
957 menuBar()->insertItem( tr( "&Settings" ), menu );
962 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
963 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
966 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
967 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
970 menu->insertSeparator();
971 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
972 a->setToggleAction(true);
973 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
975 actionSettingsAutoedit=a;
977 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
978 a->setToggleAction(true);
979 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
981 actionSettingsAutoselectHeading=a;
983 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
984 a->setToggleAction(true);
985 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
987 actionSettingsAutoselectText=a;
989 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
990 a->setToggleAction(true);
991 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
993 actionSettingsPasteNewHeading=a;
995 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
996 a->setToggleAction(true);
997 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
999 actionSettingsUseDelKey=a;
1001 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
1002 a->setToggleAction(true);
1003 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1005 actionSettingsUseFlagGroups=a;
1009 void Main::setupTestActions()
1011 QPopupMenu *menu = new QPopupMenu( this );
1012 menuBar()->insertItem( tr( "&Test" ), menu );
1015 a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
1016 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1021 void Main::setupHelpActions()
1023 QPopupMenu *menu = new QPopupMenu( this );
1024 menuBar()->insertItem( tr( "&Help" ), menu );
1027 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
1028 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1031 a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
1032 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1035 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
1036 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1041 void Main::setupContextMenus()
1045 // Context Menu for branch or mapcenter
1046 branchContextMenu =new QPopupMenu (this);
1049 branchAddContextMenu =new QPopupMenu (this);
1050 actionEditPaste->addTo ( branchAddContextMenu );
1051 actionEditAddBranch->addTo ( branchAddContextMenu );
1052 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1053 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1054 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1055 branchAddContextMenu->insertSeparator();
1056 actionEditLoadImage->addTo( branchAddContextMenu );
1057 branchAddContextMenu->insertSeparator();
1058 actionEditImportAdd->addTo ( branchAddContextMenu );
1059 actionEditImportReplace->addTo ( branchAddContextMenu );
1062 branchRemoveContextMenu =new QPopupMenu (this);
1063 actionEditCut->addTo ( branchRemoveContextMenu );
1064 actionEditDelete->addTo ( branchRemoveContextMenu );
1065 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
1066 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1068 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1069 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1071 actionEditSaveBranch->addTo( branchContextMenu );
1073 branchContextMenu->insertSeparator();
1074 actionEditOpenURL->addTo ( branchContextMenu );
1075 actionEditURL->addTo ( branchContextMenu );
1076 actionEditHeading2URL->addTo ( branchContextMenu );
1077 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1078 actionEditBugzilla2URL->addTo( branchContextMenu );
1080 branchContextMenu->insertSeparator();
1081 actionEditOpenVymLink->addTo ( branchContextMenu );
1082 actionEditVymLink->addTo ( branchContextMenu );
1083 actionEditDeleteVymLink->addTo ( branchContextMenu );
1085 branchContextMenu->insertSeparator();
1086 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1088 branchContextMenu->insertSeparator();
1089 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1091 // Context Menu for links in a branch menu
1092 // This will be populated "on demand" in MapEditor::updateActions
1093 branchContextMenu->insertSeparator();
1094 branchLinksContextMenu =new QPopupMenu (this);
1095 branchLinksContextMenuDup =new QPopupMenu (this);
1096 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1097 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1099 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1100 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1102 // Context menu for floatimage
1103 floatimageContextMenu =new QPopupMenu (this);
1104 saveImageFormatMenu=new QPopupMenu (this);
1105 exportImageFormatMenu=new QPopupMenu (this);
1107 QStrList fmt = QImage::outputFormats();
1108 for (const char* f = fmt.first(); f; f = fmt.next())
1110 saveImageFormatMenu->insertItem( f );
1111 exportImageFormatMenu->insertItem( f );
1113 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1114 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1115 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1117 floatimageContextMenu->insertSeparator();
1118 actionEditCopy->addTo( floatimageContextMenu );
1119 actionEditCut->addTo( floatimageContextMenu );
1121 floatimageContextMenu->insertSeparator();
1122 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
1123 a->setToggleAction(true);
1124 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
1125 a->addTo( floatimageContextMenu);
1126 actionEditToggleFloatExport=a;
1128 floatimageContextMenu->insertSeparator();
1129 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1131 // Context menu for exports
1132 exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
1134 a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" +QString("...")), 0, this, "exportASCII" );
1135 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1136 a->addTo( exportMenu );
1138 a = new QAction( tr( "Export as LaTeX (still experimental)" ), QPixmap(), tr( "Export (LaTeX)" +QString("...")), 0, this, "exportLaTeX" );
1139 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1140 a->addTo( exportMenu );
1142 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1144 a = new QAction( tr( "Export as Open Office 1.3.x Presentation (still experimental)" ), QPixmap(), tr( "Export (OO Presentation)" +QString("...")), 0, this, "exportOOPresentation" );
1145 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1146 a->addTo( exportMenu );
1149 a = new QAction( tr( "Export (XML)" ), QPixmap(), tr( "Export (XML)" )+QString("..."), 0, this, "exportXML" );
1150 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1151 a->addTo( exportMenu );
1153 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1155 a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export (HTML)" )+QString("..."), 0, this, "exportHTML");
1156 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1157 a->addTo( exportMenu );
1160 a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" )+QString("..."), ALT + Key_X, this, "exportXHTML" );
1161 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1162 a->addTo( exportMenu );
1165 // Context menu for canvas
1166 canvasContextMenu =new QPopupMenu (this);
1167 actionEditMapInfo->addTo( canvasContextMenu );
1168 canvasContextMenu->insertSeparator();
1169 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1170 canvasContextMenu->insertSeparator();
1171 actionFormatLinkColorHint->addTo( canvasContextMenu );
1172 actionFormatLinkColor->addTo( canvasContextMenu );
1173 actionFormatBackColor->addTo( canvasContextMenu );
1175 // Menu for last opened files
1176 // Read settings initially
1178 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1179 for (int i=1;i<=j;i++)
1181 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1182 if (!s.isEmpty() && j<=maxLastMaps)
1185 setupLastMapsMenu();
1186 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1189 void Main::setupLastMapsMenu()
1191 // Remove double entries
1192 QStringList::Iterator it=lastMaps.begin();
1193 QStringList::Iterator jt;
1194 while (it!=lastMaps.end() )
1198 while (jt!=lastMaps.end() )
1201 jt=lastMaps.remove(jt);
1208 // Limit length of list to maxLastMaps
1209 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1211 // build Menu from lastMaps string list
1212 lastMapsMenu->clear();
1213 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1214 lastMapsMenu->insertItem (*it );
1218 void Main::hideEvent (QHideEvent * )
1220 if (!textEditor->isMinimized() ) textEditor->hide();
1223 void Main::showEvent (QShowEvent * )
1225 if (textEditor->showWithMain()) textEditor->showNormal();
1228 bool Main::reallyWriteDirectory(const QString &dir)
1230 QStringList eList = QDir(dir).entryList();
1231 if (eList.first() ==".") eList.pop_front(); // remove "."
1232 if (eList.first() =="..") eList.pop_front(); // remove "."
1233 if (!eList.isEmpty())
1235 QMessageBox mb( "VYM",
1236 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1237 QMessageBox::Warning,
1239 QMessageBox::Cancel | QMessageBox::Default,
1240 QMessageBox::QMessageBox::NoButton );
1242 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1243 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1246 case QMessageBox::Yes:
1249 case QMessageBox::Cancel:
1257 QString Main::browseDirectory (const QString &caption)
1259 QFileDialog fd(this,caption);
1260 fd.setMode (QFileDialog::DirectoryOnly);
1261 fd.setCaption("VYM - "+caption);
1264 if ( fd.exec() == QDialog::Accepted )
1265 return fd.selectedFile();
1270 MapEditor* Main::currentMapEditor() const
1272 if ( tabWidget->currentPage() &&
1273 tabWidget->currentPage()->inherits( "MapEditor" ) )
1274 return (MapEditor*)tabWidget->currentPage();
1278 //TODO not used now, maybe use this for overview window later
1279 void Main::newView()
1281 // Open a new view... have it delete when closed.
1282 Main *m = new Main(0, 0, WDestructiveClose);
1283 qApp->setMainWidget(m);
1285 qApp->setMainWidget(0);
1288 void Main::editorChanged(QWidget *)
1290 // Unselect all possibly selected objects
1291 // (Important to update note editor)
1294 for (i=0;i<=tabWidget->count() -1;i++)
1297 me=(MapEditor*)tabWidget->page(i);
1300 currentMapEditor()->reselect();
1302 // Update actions to in menus and toolbars according to editor
1303 currentMapEditor()->updateActions();
1306 void Main::fileNew()
1308 QString fn="unnamed";
1309 MapEditor* medit = new MapEditor (tabWidget, true);
1310 tabWidget->addTab (medit,fn);
1311 tabWidget->showPage(medit);
1312 medit->viewport()->setFocus();
1313 // For the very first map we do not have flagrows yet...
1314 medit->select("mc:");
1317 void Main::fileLoad(QString fn, const LoadMode &lmode)
1320 enum errorCode {success,aborted};
1321 errorCode err=success;
1323 // fn is usually the archive, mapfile the file after uncompressing
1326 // Make fn absolute (needed for unzip)
1327 fn=QDir (fn).absPath();
1333 // Check, if map is already loaded
1335 while (i<=tabWidget->count() -1)
1337 me=(MapEditor*)tabWidget->page(i);
1338 if (me->getFilePath() == fn)
1340 // Already there, ask for confirmation
1341 QMessageBox mb( "VYM",
1342 tr("The map %1\nis already opened."
1343 "Opening the same map in multiple editors may lead \n"
1344 "to confusion when finishing working with vym."
1345 "Do you want to").arg(fn),
1346 QMessageBox::Warning,
1347 QMessageBox::Yes | QMessageBox::Default,
1348 QMessageBox::Cancel | QMessageBox::Escape,
1349 QMessageBox::QMessageBox::NoButton);
1350 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1351 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1354 case QMessageBox::Yes:
1356 i=tabWidget->count();
1358 case QMessageBox::Cancel:
1370 if ( !fn.isEmpty() )
1372 me = currentMapEditor();
1373 int tabIndex=tabWidget->currentPageIndex();
1374 // Check first, if mapeditor exists
1375 // If it is not default AND we want a new map,
1376 // create a new mapeditor in a new tab
1377 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1379 me = new MapEditor (tabWidget,true);
1380 tabWidget->addTab (me,fn);
1381 tabIndex=tabWidget->indexOf (me);
1382 tabWidget->setCurrentPage (tabIndex);
1385 // Check, if file exists (important for creating new files
1386 // from command line
1387 if (!QFile(fn).exists() )
1389 QMessageBox mb( "VYM",
1390 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1391 QMessageBox::Question,
1393 QMessageBox::Cancel | QMessageBox::Default,
1394 QMessageBox::QMessageBox::NoButton );
1396 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1397 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1400 case QMessageBox::Yes:
1402 currentMapEditor()->setFilePath(fn);
1403 tabWidget->setTabLabel (currentMapEditor(),
1404 currentMapEditor()->getFileName() );
1405 statusBar()->message( "Created " + fn , statusbarTime );
1408 case QMessageBox::Cancel:
1409 // don't create new map
1410 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1417 //tabWidget->currentPage() won't be NULL here, because of above...
1418 tabWidget->showPage(me);
1419 me->viewport()->setFocus();
1421 // Create temporary directory for packing
1422 char tmpdir1[]="/tmp/vym-XXXXXX";
1423 QString tmpMapDir=mkdtemp(tmpdir1);
1425 // Try to unzip file
1426 Process *zipProc=new Process ();
1427 zipProc->clearArguments();
1428 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1429 zipProc->addArgument ("unzip");
1430 zipProc->addArgument (fn );
1431 zipProc->addArgument ("-d");
1432 zipProc->addArgument (tmpMapDir);
1434 if (!zipProc->start() )
1436 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1437 tr("Couldn't start unzip to decompress data."));
1442 zipProc->waitFinished();
1443 if (!zipProc->normalExit() )
1445 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1446 tr("unzip didn't exit normally") +
1447 zipProc->getErrout() );
1451 if (zipProc->exitStatus()>0)
1453 if (zipProc->exitStatus()==9)
1455 // no zipped file, but maybe .xml or old version? Try again.
1457 me->setZipped(false);
1461 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1462 QString("unzip exit code: %1").arg(zipProc->exitStatus() ) +
1463 zipProc->getErrout() );
1467 { // Uncompressing was successfull,
1468 // load from uncompressed temporary directory
1470 me->setZipped(true);
1473 // Look for mapname.xml
1474 mapfile= fn.left(fn.findRev(".",-1,true));
1475 mapfile=mapfile.section( '/', -1 );
1476 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1477 if (!file.exists() )
1479 // mapname.xml does not exist, well,
1480 // maybe some renamed the mapname.vym file...
1481 // Try to find any .xml in the toplevel
1482 // directory of the .vym file
1483 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1484 if (flist.count()==1)
1486 // Only one entry, take this one
1487 mapfile=tmpMapDir + "/"+flist.first();
1490 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1491 *it=tmpMapDir + "/" + *it;
1492 // TODO Multiple entries, load all (but only the first one into this ME)
1493 //mainWindow->fileLoadFromTmp (flist);
1494 //returnCode=1; // Silently forget this attempt to load
1495 qWarning ("MainWindow::load (fn) multimap found...");
1498 if (flist.isEmpty() )
1500 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1501 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1504 } //file doesn't exist
1506 mapfile=file.name();
1507 } // Uncompressing successfull
1512 // Save existing filename
1513 QString fn_org=me->getFilePath();
1515 // Finally load map into mapEditor
1516 me->setFilePath (mapfile,fn);
1517 if (me->load(mapfile,lmode))
1520 // Restore old (maybe empty) filepath, if this is an import
1522 me->setFilePath (fn_org);
1525 system ( "rm -rf "+tmpMapDir);
1532 me->setFilePath (fn);
1533 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1534 lastMaps.prepend(me->getFilePath() );
1535 setupLastMapsMenu();
1536 actionFilePrint->setEnabled (true);
1538 statusBar()->message( "Loaded " + fn, statusbarTime );
1548 statusBar()->message( "Could not load " + fn, statusbarTime );
1552 void Main::fileLoad(const LoadMode &lmode)
1554 QFileDialog *fd=new QFileDialog( this);
1555 if (!lastFileDir.isEmpty())
1556 fd->setDir (lastFileDir);
1557 fd->addFilter ("XML (*.xml)");
1558 fd->addFilter ("VYM map (*.vym *.vyp)");
1562 fd->setCaption(tr("Load vym map"));
1565 fd->setCaption(tr("Import: Add vym map to selection"));
1568 fd->setCaption(tr("Import: Replace selection with vym map"));
1574 if ( fd->exec() == QDialog::Accepted )
1576 lastFileDir=fd->dirPath();
1577 fn = fd->selectedFile();
1578 fileLoad(fn, lmode);
1582 void Main::fileLoad()
1587 void Main::fileLoadLast(int i)
1589 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1592 void Main::fileSave(const SaveMode &savemode)
1594 // tmp dir for zipping
1598 enum errorCode {success,aborted};
1599 errorCode err=success;
1601 QString safeFilePath;
1603 bool saveZipped=currentMapEditor()->saveZipped();
1605 MapEditor * me=currentMapEditor();
1608 QString fn=me->getFilePath();
1609 // filename=unnamed, filepath="" in constructor...
1610 if ( !fn.isEmpty() )
1612 // We have a filepath, go on saving
1613 // First remove existing file, we
1614 // don't want to add to old zip archives
1618 QMessageBox::warning( 0, tr( "Save Error" ),
1619 fn+ tr("\ncould not be removed before saving"));
1621 // Look, if we should zip the data:
1624 QMessageBox mb( "VYM",
1625 tr("The map %1\ndid not use the compressed "
1626 "vym file format.\nWriting it uncompressed will also write images \n"
1627 "and flags and thus may overwrite files in the "
1628 "given directory\n\nDo you want to write the map").arg(fn),
1629 QMessageBox::Warning,
1630 QMessageBox::Yes | QMessageBox::Default,
1632 QMessageBox::Cancel | QMessageBox::Escape);
1633 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1634 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1635 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1638 case QMessageBox::Yes:
1639 // save compressed (default file format)
1642 case QMessageBox::No:
1643 // save uncompressed
1646 case QMessageBox::Cancel:
1655 char tmpdir1[]="/tmp/vym-XXXXXX";
1656 tmpMapDir=mkdtemp(tmpdir1);
1658 safeFilePath=me->getFilePath();
1659 me->setFilePath (tmpMapDir+"/"+
1660 me->getMapName()+ ".xml",
1662 me->save (savemode);
1663 me->setFilePath (safeFilePath);
1665 // zip the temporary directory
1666 Process *zipProc=new Process ();
1667 zipProc->clearArguments();
1668 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1669 zipProc->addArgument ("zip");
1670 zipProc->addArgument ("-r");
1671 zipProc->addArgument (fn);
1672 zipProc->addArgument (".");
1674 if (!zipProc->start() )
1676 // zip could not be started
1677 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1678 tr("Couldn't start zip to compress data."));
1682 // zip could be started
1683 zipProc->waitFinished();
1684 if (!zipProc->normalExit() )
1686 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1687 tr("zip didn't exit normally")+
1688 "\n" + zipProc->getErrout());
1692 if (zipProc->exitStatus()>0)
1694 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1695 QString("zip exit code: %1").arg(zipProc->exitStatus() )+
1696 "\n" + zipProc->getErrout() );
1700 } // zip could be started
1705 safeFilePath=me->getFilePath();
1706 me->setFilePath (fn, safeFilePath);
1707 me->save (savemode);
1708 me->setFilePath (safeFilePath);
1710 } // filepath available
1713 // We have no filepath yet,
1714 // call fileSaveAs() now, this will call fileSave()
1716 fileSaveAs(savemode);
1720 if (me->saveZipped())
1723 system ( "rm -rf "+ tmpMapDir );
1728 statusBar()->message(
1729 tr("Saved %1").arg(me->getFilePath()),
1731 lastMaps.prepend(me->getFilePath() );
1732 setupLastMapsMenu();
1734 statusBar()->message(
1735 tr("Couldn't save ").arg(me->getFilePath()),
1739 void Main::fileSave()
1741 fileSave (CompleteMap);
1744 void Main::fileSaveAs(const SaveMode& savemode)
1749 if (currentMapEditor())
1751 if (savemode==CompleteMap)
1752 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1754 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1755 if ( !fn.isEmpty() )
1757 // Check for existing file
1758 if (QFile (fn).exists())
1760 QMessageBox mb( "VYM",
1761 tr("The file %1\nexists already. Do you want to").arg(fn),
1762 QMessageBox::Warning,
1763 QMessageBox::Yes | QMessageBox::Default,
1764 QMessageBox::Cancel | QMessageBox::Escape,
1765 QMessageBox::QMessageBox::NoButton);
1766 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1767 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1770 case QMessageBox::Yes:
1773 case QMessageBox::Cancel:
1780 // New file, add extension to filename, if missing
1781 // This is always .vym or .vyp, depending on savemode
1782 if (savemode==CompleteMap)
1784 if (!fn.contains (".vym") && !fn.contains (".xml"))
1788 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1797 currentMapEditor()->setFilePath(fn);
1801 if (savemode==CompleteMap)
1802 tabWidget->setTabLabel (currentMapEditor(),
1803 currentMapEditor()->getFileName() );
1809 void Main::fileSaveAs()
1811 fileSaveAs (CompleteMap);
1814 void Main::fileImportDir()
1816 if (currentMapEditor())
1817 currentMapEditor()->importDir();
1820 void Main::fileExportXML()
1822 if (currentMapEditor())
1824 QString dir=browseDirectory(tr("Export XML to directory"));
1825 if (dir !="" && reallyWriteDirectory(dir) )
1826 currentMapEditor()->exportXML(dir);
1830 void Main::fileExportHTML()
1832 if (currentMapEditor())
1834 ExportHTMLDialog dia(this);
1836 if (dia.exec()==QDialog::Accepted)
1838 QString dir=dia.getDir();
1839 if (reallyWriteDirectory(dir) )
1841 currentMapEditor()->exportXML (dia.getDir() );
1842 dia.doExport(currentMapEditor()->getMapName() );
1848 void Main::fileExportXHTML()
1851 if (currentMapEditor())
1853 ExportXHTMLDialog dia(this);
1854 dia.setFilePath (currentMapEditor()->getFilePath() );
1855 dia.setMapName (currentMapEditor()->getMapName() );
1858 if (dia.exec()==QDialog::Accepted)
1860 QString dir=dia.getDir();
1861 // Check, if warnings should be used before overwriting
1862 // the output directory
1865 ok=reallyWriteDirectory(dir);
1871 currentMapEditor()->exportXML (dia.getDir() );
1872 dia.doExport(currentMapEditor()->getMapName() );
1873 if (dia.hasChanged())
1874 currentMapEditor()->setChanged();
1880 void Main::fileExportImage(int item)
1882 if (currentMapEditor())
1884 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1886 if ( !fn.isEmpty() )
1888 currentMapEditor()->exportImage(fn,item);
1890 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1895 void Main::fileExportASCII()
1897 if (currentMapEditor())
1898 currentMapEditor()->exportASCII();
1901 void Main::fileExportLaTeX()
1903 if (currentMapEditor())
1904 currentMapEditor()->exportLaTeX();
1907 void Main::fileExportOOPresentation()
1909 if (currentMapEditor())
1910 currentMapEditor()->exportOOPresentation();
1913 void Main::fileCloseMap()
1915 if (currentMapEditor())
1917 if (currentMapEditor()->hasChanged())
1919 QMessageBox mb( "VYM",
1920 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1921 QMessageBox::Warning,
1922 QMessageBox::Yes | QMessageBox::Default,
1924 QMessageBox::Cancel | QMessageBox::Escape );
1925 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1926 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1929 case QMessageBox::Yes:
1931 fileSave(CompleteMap);
1933 case QMessageBox::No:
1934 // close without saving
1936 case QMessageBox::Cancel:
1941 currentMapEditor()->closeMap();
1942 tabWidget->removePage(currentMapEditor());
1943 if (tabWidget->count()==0)
1944 actionFilePrint->setEnabled (false);
1948 void Main::filePrint()
1950 if (currentMapEditor())
1951 currentMapEditor()->print();
1954 void Main::fileExitVYM()
1956 // Check if one or more editors have changed
1959 for (i=0;i<=tabWidget->count() -1;i++)
1962 me=(MapEditor*)tabWidget->page(i);
1964 // If something changed, ask what to do
1965 if (me->isUnsaved())
1967 tabWidget->setCurrentPage(i);
1968 QMessageBox mb( "VYM",
1969 tr("This map is not saved yet. Do you want to"),
1970 QMessageBox::Warning,
1971 QMessageBox::Yes | QMessageBox::Default,
1973 QMessageBox::Cancel | QMessageBox::Escape );
1974 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1975 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1977 // Call undocumented function: setActiveWindow is only
1978 // possible, if widget is visible. This depends on
1980 #if defined(Q_OS_LINUX)
1981 qt_wait_for_window_manager( this);
1983 mb.setActiveWindow();
1984 switch( mb.exec() ) {
1985 case QMessageBox::Yes:
1986 // save (the changed editors) and exit
1987 fileSave(CompleteMap);
1989 case QMessageBox::No:
1990 // exit without saving
1992 case QMessageBox::Cancel:
1993 // don't save and don't exit
1997 } // loop over all MEs
2001 void Main::editUndo()
2003 if (currentMapEditor())
2004 currentMapEditor()->undo();
2007 void Main::editRedo()
2009 if (currentMapEditor())
2010 currentMapEditor()->redo();
2013 void Main::editCopy()
2015 if (currentMapEditor())
2016 currentMapEditor()->copy();
2019 void Main::editPaste()
2021 if (currentMapEditor())
2022 currentMapEditor()->paste();
2025 void Main::editCut()
2027 if (currentMapEditor())
2028 currentMapEditor()->cut();
2031 void Main::editOpenFindWindow()
2033 findWindow->popup();
2034 findWindow->raise();
2036 // Call undocumented function: setActiveWindow is only
2037 // possible, if widget is visible. This depends on
2039 #if defined(Q_OS_LINUX)
2040 qt_wait_for_window_manager( this);
2042 findWindow->setActiveWindow();
2045 void Main::editFind(QString s)
2048 BranchObj *bo=currentMapEditor()->findText(s, cs);
2051 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2054 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2055 tr("No matches found for <b>%1</b>").arg(s));
2059 void Main::editFindChanged()
2060 { // Notify editor, to abort the current find process
2061 currentMapEditor()->findReset();
2064 void Main::editOpenURL()
2066 if (currentMapEditor())
2067 currentMapEditor()->openURL();
2070 void Main::editURL()
2072 if (currentMapEditor())
2073 currentMapEditor()->editURL();
2076 void Main::editHeading2URL()
2078 if (currentMapEditor())
2079 currentMapEditor()->editHeading2URL();
2082 void Main::editBugzilla2URL()
2084 if (currentMapEditor())
2085 currentMapEditor()->editBugzilla2URL();
2088 void Main::editOpenVymLink()
2090 // Get current path to map
2091 QString currentVymLink;
2092 if (currentMapEditor())
2094 currentVymLink=currentMapEditor()->getVymLink();
2095 // compare path with already loaded maps
2099 for (i=0;i<=tabWidget->count() -1;i++)
2101 me=(MapEditor*)tabWidget->page(i);
2102 if (currentVymLink==me->getFilePath() )
2111 if (!QFile(currentVymLink).exists() )
2112 QMessageBox::critical( 0, tr( "Critical Error" ),
2113 tr("Couldn't open map %1").arg(currentVymLink));
2116 fileLoad (currentVymLink, NewMap);
2117 tabWidget->setCurrentPage (tabWidget->count()-1);
2120 // Go to tab containing the map
2121 tabWidget->setCurrentPage (index);
2125 void Main::editVymLink()
2127 if (currentMapEditor())
2128 currentMapEditor()->editVymLink();
2131 void Main::editDeleteVymLink()
2133 if (currentMapEditor())
2134 currentMapEditor()->deleteVymLink();
2137 void Main::editMapInfo()
2139 if (currentMapEditor())
2140 currentMapEditor()->editMapInfo();
2143 void Main::editMoveUp()
2145 if (currentMapEditor())
2146 currentMapEditor()->moveBranchUp();
2149 void Main::editMoveDown()
2151 if (currentMapEditor())
2152 currentMapEditor()->moveBranchDown();
2155 void Main::editToggleScroll()
2157 if (currentMapEditor())
2159 currentMapEditor()->toggleScroll();
2163 void Main::editUnScrollAll()
2165 if (currentMapEditor())
2167 currentMapEditor()->unScrollAll();
2171 void Main::editHeading()
2173 if (currentMapEditor())
2174 currentMapEditor()->editHeading();
2177 void Main::editNewBranch()
2179 if (currentMapEditor())
2180 currentMapEditor()->addNewBranch(0);
2183 void Main::editNewBranchHere()
2185 if (currentMapEditor())
2186 currentMapEditor()->addNewBranchHere();
2189 void Main::editNewBranchAbove()
2191 if (currentMapEditor())
2192 currentMapEditor()->addNewBranch(-1);
2195 void Main::editNewBranchBelow()
2197 if (currentMapEditor())
2198 currentMapEditor()->addNewBranch(1);
2201 void Main::editImportAdd()
2203 fileLoad (ImportAdd);
2206 void Main::editImportReplace()
2208 fileLoad (ImportReplace);
2211 void Main::editSaveBranch()
2213 fileSaveAs (PartOfMap);
2216 void Main::editRemoveBranchHere()
2218 if (currentMapEditor())
2219 currentMapEditor()->removeBranchHere();
2222 void Main::editRemoveChilds()
2224 if (currentMapEditor())
2225 currentMapEditor()->removeChilds();
2228 void Main::editDeleteSelection()
2230 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2231 currentMapEditor()->deleteSelection();
2234 void Main::editUpperBranch()
2236 if (currentMapEditor())
2237 currentMapEditor()->selectUpperBranch();
2240 void Main::editLowerBranch()
2242 if (currentMapEditor())
2243 currentMapEditor()->selectLowerBranch();
2246 void Main::editLeftBranch()
2248 if (currentMapEditor())
2249 currentMapEditor()->selectLeftBranch();
2252 void Main::editRightBranch()
2254 if (currentMapEditor())
2255 currentMapEditor()->selectRightBranch();
2258 void Main::editFirstBranch()
2260 if (currentMapEditor())
2261 currentMapEditor()->selectFirstBranch();
2264 void Main::editLastBranch()
2266 if (currentMapEditor())
2267 currentMapEditor()->selectLastBranch();
2270 void Main::editLoadImage()
2272 if (currentMapEditor())
2273 currentMapEditor()->loadFloatImage();
2276 void Main::editSaveImage(int item)
2278 if (currentMapEditor())
2279 currentMapEditor()->saveFloatImage(item);
2282 void Main::editToggleFloatExport()
2284 if (currentMapEditor())
2285 currentMapEditor()->toggleFloatExport();
2288 void Main::editFollowXLink(int item)
2290 if (currentMapEditor())
2291 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2294 void Main::editEditXLink(int item)
2296 if (currentMapEditor())
2297 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2300 void Main::formatSelectColor()
2302 if (currentMapEditor())
2304 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2305 if ( !col.isValid() ) return;
2306 currentMapEditor()->setColor( col );
2307 colorChanged( col );
2311 void Main::formatPickColor()
2313 if (currentMapEditor())
2314 colorChanged( currentMapEditor()->pickColor() );
2317 void Main::colorChanged(QColor c)
2319 QPixmap pix( 16, 16 );
2321 actionFormatColor->setIconSet( pix );
2324 void Main::formatColorItem()
2326 if (currentMapEditor())
2327 currentMapEditor()->colorItem();
2330 void Main::formatColorBranch()
2332 if (currentMapEditor())
2333 currentMapEditor()->colorBranch();
2336 void Main::formatLinkStyleLine()
2338 if (currentMapEditor())
2339 currentMapEditor()->setLinkStyle(StyleLine);
2342 void Main::formatLinkStyleParabel()
2344 if (currentMapEditor())
2345 currentMapEditor()->setLinkStyle(StyleParabel);
2348 void Main::formatLinkStylePolyLine()
2350 if (currentMapEditor())
2351 currentMapEditor()->setLinkStyle(StylePolyLine);
2354 void Main::formatLinkStylePolyParabel()
2356 if (currentMapEditor())
2357 currentMapEditor()->setLinkStyle(StylePolyParabel);
2360 void Main::formatSelectBackColor()
2362 if (currentMapEditor())
2363 currentMapEditor()->selectBackgroundColor();
2366 void Main::formatSelectLinkColor()
2368 if (currentMapEditor())
2369 currentMapEditor()->selectLinkColor();
2372 void Main::formatToggleLinkColorHint()
2374 currentMapEditor()->toggleLinkColorHint();
2377 void Main::formatFrameNone()
2379 if (currentMapEditor())
2380 currentMapEditor()->setFrame(NoFrame);
2383 void Main::formatFrameRectangle()
2385 if (currentMapEditor())
2386 currentMapEditor()->setFrame(Rectangle);
2389 void Main::formatHideLinkUnselected()
2391 if (currentMapEditor())
2392 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2395 void Main::viewZoomReset()
2397 if (currentMapEditor())
2401 currentMapEditor()->setWorldMatrix( m );
2402 currentMapEditor()->setViewCenter();
2403 currentMapEditor()->adjustCanvasSize();
2407 void Main::viewZoomIn()
2409 if (currentMapEditor())
2411 QWMatrix m = currentMapEditor()->worldMatrix();
2412 m.scale( 1.25, 1.25 );
2413 currentMapEditor()->setWorldMatrix( m );
2414 currentMapEditor()->setViewCenter();
2415 currentMapEditor()->adjustCanvasSize();
2419 void Main::viewZoomOut()
2421 if (currentMapEditor())
2423 QWMatrix m = currentMapEditor()->worldMatrix();
2424 m.scale( 0.8, 0.8 );
2425 currentMapEditor()->setWorldMatrix( m );
2426 currentMapEditor()->setViewCenter();
2427 currentMapEditor()->adjustCanvasSize();
2431 void Main::modModeColor()
2435 void Main::modModeLink()
2439 bool Main::settingsPDF()
2441 // Default browser is set in constructor
2443 QString text = QInputDialog::getText(
2444 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2445 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2447 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2452 bool Main::settingsURL()
2454 // Default browser is set in constructor
2456 QString text = QInputDialog::getText(
2457 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2458 settings.readEntry("/vym/mainwindow/readerURL")
2461 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2465 void Main::windowToggleNoteEditor()
2467 if (textEditor->showWithMain() )
2468 windowHideNoteEditor();
2470 windowShowNoteEditor();
2473 void Main::updateNoteFlag()
2475 if (currentMapEditor())
2476 currentMapEditor()->updateNoteFlag();
2479 void Main::windowShowNoteEditor()
2481 textEditor->setShowWithMain(true);
2483 actionViewToggleNoteEditor->setOn (true);
2486 void Main::windowHideNoteEditor()
2488 textEditor->setShowWithMain(false);
2490 actionViewToggleNoteEditor->setOn (false);
2493 void Main::windowNextEditor()
2495 if (tabWidget->currentPageIndex() < tabWidget->count())
2496 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2499 void Main::windowPreviousEditor()
2501 if (tabWidget->currentPageIndex() >0)
2502 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2505 void Main::standardFlagChanged()
2507 currentMapEditor()->toggleStandardFlag(sender()->name());
2510 void Main::testFunction()
2512 //textEditor->stackUnder(this);
2513 currentMapEditor()->testFunction();
2516 void Main::helpDoc()
2519 #if defined(Q_OS_MACX)
2520 docpath="./vym.app/Contents/vym.pdf";
2522 // default path in SUSE LINUX
2523 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2526 if (!QFile (docpath).exists() )
2528 // relative path for easy testing in tarball
2529 docpath="doc/vym.pdf";
2530 if (!QFile (docpath).exists() )
2532 // relative path for testing while still writing vym.tex
2533 docpath="doc/tex/vym.pdf";
2534 if (!QFile (docpath).exists() )
2536 QMessageBox::critical(0,
2537 tr("Critcal error"),
2538 tr("Couldn't find the documentation\n"
2539 "vym.pdf in various places."));
2545 Process *pdfProc = new Process();
2546 pdfProc->clearArguments();
2547 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2548 pdfProc->addArgument( docpath);
2550 if ( !pdfProc->start() )
2553 QMessageBox::critical(0,
2554 tr("Critcal error"),
2555 tr("Couldn't find a viewer to read vym.pdf.\n"
2556 "Please use Settings->")+tr("Set application to open pdf files"));
2562 void Main::helpAbout()
2565 ad.setName ("aboutwindow");
2566 ad.setMinimumSize(500,500);
2567 ad.resize (QSize (500,500));
2571 void Main::helpAboutQT()
2573 QMessageBox::aboutQt( this, "Qt Application Example" );