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
23 #include "aboutdialog.h"
25 #include "icons/filenew.xpm"
26 #include "icons/fileopen.xpm"
27 #include "icons/filesave.xpm"
28 #include "icons/fileprint.xpm"
29 #include "icons/editundo.xpm"
30 //#include "icons/editredo.xpm" // TODO
31 #include "icons/editcopy.xpm"
32 #include "icons/editcut.xpm"
33 #include "icons/editpaste.xpm"
34 #include "icons/editmoveup.xpm"
35 #include "icons/editmovedown.xpm"
36 #include "icons/formatcoloritem.xpm"
37 #include "icons/formatcolorbranch.xpm"
38 #include "icons/formatcolorpicker.xpm"
39 #include "icons/viewzoomreset.xpm"
40 #include "icons/viewzoomin.xpm"
41 #include "icons/viewzoomout.xpm"
42 #include "icons/modecolor.xpm"
43 #include "icons/modelink.xpm"
44 #include "icons/modecopy.xpm"
45 //#include "icons/vym-48x48.xpm"
46 #include "icons/flag-note.xpm"
47 #include "icons/flag-url.xpm"
48 #include "icons/flag-vymlink.xpm"
49 #include "icons/flag-scrolled-right.xpm"
51 #include "flagrowobj.h"
52 #include "texteditor.h"
53 #include "mapeditor.h"
54 #include "exporthtmldialog.h"
55 #include "exportxhtmldialog.h"
56 #include "showtextdialog.h"
61 extern TextEditor *textEditor;
62 extern Main *mainWindow;
63 extern int statusbarTime;
64 extern MapEditor *clipboardME;
65 extern FlagRowObj* standardFlagsDefault;
67 extern QPtrList <QAction> actionListBranches;
69 extern QAction* actionFileSave;
70 extern QAction* actionFilePrint;
71 extern QAction* actionEditUndo;
72 extern QAction *actionEditCopy;
73 extern QAction *actionEditCut;
74 extern QAction *actionEditPaste;
75 extern QAction *actionEditMoveUp;
76 extern QAction *actionEditMoveDown;
77 extern QAction *actionEditToggleScroll;
78 extern QAction* actionEditOpenURL;
79 extern QAction* actionEditURL;
80 extern QAction* actionEditHeading2URL;
81 extern QAction* actionEditBugzilla2URL;
82 extern QAction *actionEditOpenVymLink;
83 extern QAction *actionEditVymLink;
84 extern QAction *actionEditDeleteVymLink;
85 extern QAction *actionEditMapInfo;
86 extern QAction *actionEditHeading;
87 extern QAction *actionEditDelete;
88 extern QAction *actionEditAddBranch;
89 extern QAction *actionEditAddBranchHere;
90 extern QAction *actionEditAddBranchAbove;
91 extern QAction *actionEditAddBranchBelow;
92 extern QAction *actionEditRemoveBranchHere;
93 extern QAction *actionEditRemoveChilds;
94 extern QAction *actionEditImportAdd;
95 extern QAction *actionEditImportReplace;
96 extern QAction *actionEditSaveBranch;
97 extern QAction *actionEditSelectFirst;
98 extern QAction *actionEditSelectLast;
99 extern QAction *actionEditLoadImage;
100 extern QAction *actionEditToggleFloatExport;
102 extern QAction* actionFormatColor;
103 extern QAction* actionFormatPickColor;
104 extern QAction* actionFormatColorBranch;
105 extern QAction* actionFormatColorSubtree;
106 extern QAction* actionFormatLinkColorHint;
107 extern QAction* actionFormatBackColor;
108 extern QAction* actionFormatLinkColor;
110 extern QActionGroup* actionGroupModModes;
111 extern QAction* actionModModeColor;
112 extern QAction* actionModModeLink;
113 extern QAction* actionModModeCopy;
115 extern QActionGroup *actionGroupFormatFrameTypes;
116 extern QAction *actionFormatFrameNone;
117 extern QAction *actionFormatFrameRectangle;
119 extern QActionGroup *actionGroupFormatLinkStyles;
120 extern QAction *actionFormatLinkStyleLine;
121 extern QAction *actionFormatLinkStyleParabel;
122 extern QAction *actionFormatLinkStylePolyLine;
123 extern QAction *actionFormatLinkStylePolyParabel;
124 extern QAction *actionFormatHideLinkUnselected;
126 extern QAction *actionViewToggleNoteEditor;
128 extern QAction* actionSettingsAutoedit;
129 extern QAction* actionSettingsAutoselectHeading;
130 extern QAction* actionSettingsAutoselectHeading;
131 extern QAction* actionSettingsAutoselectText;
132 extern QAction* actionSettingsPasteNewHeading;
133 extern QAction* actionSettingsUseDelKey;
134 extern QAction* actionSettingsUseFlagGroups;
136 extern QPopupMenu* branchContextMenu;
137 extern QPopupMenu* branchAddContextMenu;
138 extern QPopupMenu* branchRemoveContextMenu;
139 extern QPopupMenu* branchLinksContextMenu;
140 extern QPopupMenu* branchLinksContextMenuDup;
141 extern QPopupMenu* floatimageContextMenu;
142 extern QPopupMenu* saveImageFormatMenu;
143 extern QPopupMenu* canvasContextMenu;
144 extern QPopupMenu* lastMapsMenu;
145 extern QPopupMenu* exportMenu;
146 extern QPopupMenu* exportImageFormatMenu;
149 extern Settings settings;
150 extern Options options;
152 #if defined(Q_OS_LINUX)
153 extern void qt_wait_for_window_manager( QWidget* w );
156 Main::Main(QWidget* parent, const char* name, WFlags f) :
157 QMainWindow(parent,name,f)
161 setCaption ("VYM - View Your Mind");
163 // Load window settings
164 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
165 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
166 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
167 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
170 // Set random seed (random used for object IDs)
171 QTime t = QTime::currentTime(); // set random seed
172 srand( t.hour()*12+t.minute()*60+t.second()*60 );
175 // Initialize some settings, which are platform dependant
178 // application to open URLs
179 p="/vym/mainwindow/readerURL";
180 #if defined(Q_OS_LINUX)
181 s=settings.readEntry (p,"konqueror");
183 #if defined(Q_OS_MACX)
184 s=settings.readEntry (p,"/usr/bin/open");
186 s=settings.readEntry (p,"mozilla");
189 settings.writeEntry( p,s);
191 // application to open PDFs
192 p="/vym/mainwindow/readerPDF";
193 #if defined(Q_OS_LINUX)
194 s=settings.readEntry (p,"acroread");
196 #if defined(Q_OS_MACX)
197 s=settings.readEntry (p,"/usr/bin/open");
199 s=settings.readEntry (p,"acroread");
202 settings.writeEntry( p,s);
207 // Create tab widget which holds the maps
208 tabWidget= new QTabWidget (this);
209 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
210 this, SLOT( editorChanged( QWidget * ) ) );
212 setCentralWidget(tabWidget);
216 setupFormatActions();
220 setupSettingsActions();
222 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
225 // After menu is created, we can enable some actions
226 actionFilePrint->setEnabled (true);
231 // Initialize Find window
232 findWindow=new FindWindow(NULL,"findwindow");
233 connect (findWindow, SIGNAL( findButton(QString) ),
234 this, SLOT(editFind(QString) ) );
235 connect (findWindow, SIGNAL( somethingChanged() ),
236 this, SLOT(editFindChanged() ) );
239 // Connect TextEditor, so that we can update flags if text changes
240 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
244 // Creating the default map into first tab is done in main.cpp now...
250 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
251 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
252 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
253 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
255 settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
256 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
258 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
259 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
260 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
261 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
262 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
263 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
266 int maps=lastMaps.count();
267 settings.writeEntry( "/vym/lastMaps/number",maps );
268 for (int i=1;i<=maps;i++)
270 QStringList::Iterator it = lastMaps.at(i-1);
271 s=QString("/vym/lastMaps/map-%1").arg(i);
272 if (!s.isEmpty() && i<=maxLastMaps)
273 settings.writeEntry (s, *it);
277 // To make the texteditor save its settings, call the destructor
281 void Main::loadCmdLine()
283 /* TODO draw some kind of splashscreen while loading...
289 QStringList flist=options.getFileList();
290 QStringList::Iterator it=flist.begin();
292 while (it !=flist.end() )
294 fileLoad (*it, NewMap);
300 void Main::statusMessage(const QString &s)
302 statusBar()->message (s);
305 void Main::closeEvent (QCloseEvent* )
311 void Main::setupFileActions()
313 QToolBar *tb = new QToolBar( this );
314 tb->setLabel( "File Actions" );
315 QPopupMenu *menu = new QPopupMenu( this );
316 menuBar()->insertItem( tr( "&File" ), menu );
318 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
321 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
322 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
326 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
327 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
331 lastMapsMenu = new QPopupMenu (this);
333 menu->insertItem (tr("Open Recent"),lastMapsMenu );
334 menu->insertSeparator();
336 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
337 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
342 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
343 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
346 menu->insertSeparator();
348 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
349 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
352 exportMenu = new QPopupMenu (this);
353 menu->insertItem (tr("Export"),exportMenu );
355 menu->insertSeparator();
358 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
359 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
364 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
365 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
368 a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
369 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
375 void Main::setupEditActions()
377 QToolBar *tb = new QToolBar( this );
378 tb->setLabel( "Edit Actions" );
379 QPopupMenu *menu = new QPopupMenu( this );
380 menuBar()->insertItem( tr( "&Edit" ), menu );
384 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
385 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
386 a->setEnabled (false);
391 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
392 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
396 menu->insertSeparator();
397 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
398 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
399 a->setEnabled (false);
403 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
404 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
405 a->setEnabled (false);
409 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
410 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
411 a->setEnabled (false);
416 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
417 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
418 a->setEnabled (false);
421 actionListBranches.append(a);
424 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
425 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
426 a->setEnabled (false);
429 actionListBranches.append(a);
430 actionEditMoveDown=a;
433 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
434 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
435 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
436 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
437 #if defined(Q_OS_MACX)
438 actionEditToggleScroll=alt;
440 actionEditToggleScroll=a;
442 actionEditToggleScroll->setEnabled (false);
443 actionEditToggleScroll->addTo( tb );
444 actionEditToggleScroll->addTo( menu );
445 actionListBranches.append(actionEditToggleScroll);
447 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
448 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
451 menu->insertSeparator();
453 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
454 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
457 menu->insertSeparator();
459 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
460 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
462 a->setEnabled (false);
465 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
466 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
467 a->setEnabled (false);
468 actionListBranches.append(a);
471 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
472 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
473 a->setEnabled (false);
474 actionListBranches.append(a);
475 actionEditHeading2URL=a;
477 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
478 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
479 a->setEnabled (false);
480 actionListBranches.append(a);
481 actionEditBugzilla2URL=a;
484 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" );
485 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
487 a->setEnabled (false);
488 actionEditOpenVymLink=a;
490 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
491 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
492 a->setEnabled (false);
493 actionListBranches.append(a);
496 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
497 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
498 a->setEnabled (false);
499 actionEditDeleteVymLink=a;
501 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
502 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
503 a->setEnabled (true);
506 menu->insertSeparator();
508 // Shortcuts to modify heading:
509 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
510 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
511 actionListBranches.append(a);
512 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
513 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
514 actionListBranches.append(a);
516 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
517 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
518 a->setEnabled (false);
520 actionListBranches.append(a);
522 // Shortcut to delete selection
523 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
524 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
525 a->setEnabled (false);
528 // Shortcut to add branch
529 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
530 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
531 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
532 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
533 a->setEnabled (false);
534 actionListBranches.append(a);
535 #if defined (Q_OS_MACX)
536 actionEditAddBranch=alt;
538 actionEditAddBranch=a;
541 // Add branch by inserting it at selection
542 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
543 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
544 a->setEnabled (false);
545 actionListBranches.append(a);
546 actionEditAddBranchHere=a;
549 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
550 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
551 a->setEnabled (false);
552 actionListBranches.append(a);
553 actionEditAddBranchAbove=a;
556 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
557 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
558 a->setEnabled (false);
559 actionListBranches.append(a);
560 actionEditAddBranchBelow=a;
562 // Import at selection (adding to selection)
563 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
564 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
565 a->setEnabled (false);
566 actionListBranches.append(a);
567 actionEditImportAdd=a;
569 // Import at selection (replacing selection)
570 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
571 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
572 a->setEnabled (false);
573 actionListBranches.append(a);
574 actionEditImportReplace=a;
577 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
578 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
579 a->setEnabled (false);
580 actionListBranches.append(a);
581 actionEditSaveBranch=a;
583 // Only remove branch, not its childs
584 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
585 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
586 a->setEnabled (false);
587 actionListBranches.append(a);
588 actionEditRemoveBranchHere=a;
590 // Only remove childs of a branch
591 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
592 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
593 a->setEnabled (false);
594 actionListBranches.append(a);
595 actionEditRemoveChilds=a;
597 // Shortcuts for navigating with cursor:
598 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
599 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
600 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
601 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
602 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
603 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
604 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
605 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
606 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
607 a->setEnabled (false);
609 actionListBranches.append(a);
610 actionEditSelectFirst=a;
611 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
612 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
613 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
614 a->setEnabled (false);
616 actionListBranches.append(a);
617 actionEditSelectLast=a;
619 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
620 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
621 actionEditLoadImage=a;
626 void Main::setupFormatActions()
628 QPopupMenu *menu = new QPopupMenu( this );
629 menuBar()->insertItem( tr( "&Format" ), menu );
631 QToolBar *tb = new QToolBar( this );
635 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
636 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
637 actionFormatColor->addTo( tb );
638 actionFormatColor->addTo( menu );
639 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" );
640 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
641 a->setEnabled (false);
644 actionListBranches.append(a);
645 actionFormatPickColor=a;
646 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
647 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
648 a->setEnabled (false);
651 actionListBranches.append(a);
652 actionFormatColorBranch=a;
653 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
654 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
655 a->setEnabled (false);
658 actionListBranches.append(a);
659 actionFormatColorSubtree=a;
661 menu->insertSeparator();
662 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
663 actionGroupFormatLinkStyles->setExclusive (true);
664 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
665 a->setToggleAction(true);
666 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
667 actionFormatLinkStyleLine=a;
668 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
669 a->setToggleAction(true);
670 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
671 actionFormatLinkStyleParabel=a;
672 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
673 a->setToggleAction(true);
674 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
675 actionFormatLinkStylePolyLine=a;
676 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
677 a->setToggleAction(true);
678 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
679 actionFormatLinkStylePolyParabel=a;
680 actionGroupFormatLinkStyles->addTo (menu);
682 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
683 actionGroupFormatFrameTypes->setExclusive (true);
684 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
685 a->setToggleAction(true);
686 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
687 actionFormatFrameNone=a;
688 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
689 a->setToggleAction(true);
690 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
691 actionFormatFrameRectangle=a;
693 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
694 a->setToggleAction(true);
695 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
696 actionFormatHideLinkUnselected=a;
698 menu->insertSeparator();
699 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
700 a->setToggleAction(true);
701 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
703 actionFormatLinkColorHint=a;
705 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
706 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
707 actionFormatLinkColor->addTo( menu );
708 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
709 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
710 actionFormatBackColor->addTo( menu );
714 void Main::setupViewActions()
716 QToolBar *tb = new QToolBar( this );
717 tb->setLabel( "View Actions" );
718 QPopupMenu *menu = new QPopupMenu( this );
719 menuBar()->insertItem( tr( "&View" ), menu );
722 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
723 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
726 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
727 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
730 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
731 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
734 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
735 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
736 a->setToggleAction(true);
737 if (textEditor->showWithMain())
743 actionViewToggleNoteEditor=a;
744 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
745 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
747 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
748 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
753 void Main::setupModeActions()
755 //QPopupMenu *menu = new QPopupMenu( this );
756 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
758 QToolBar *tb = new QToolBar( this );
759 tb->setLabel( tr ("Modes when using modifiers") );
761 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
762 actionGroupModModes->setExclusive (true);
763 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
764 a->setToggleAction(true);
767 actionModModeColor=a;
769 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
770 a->setToggleAction(true);
774 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
775 a->setToggleAction(true);
781 void Main::setupFlagActions()
783 standardFlagsDefault->makeToolbar(this, "Standard Flags");
787 void Main::setupSettingsActions()
789 QPopupMenu *menu = new QPopupMenu( this );
790 menuBar()->insertItem( tr( "&Settings" ), menu );
795 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
796 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
799 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
800 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
803 menu->insertSeparator();
804 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
805 a->setToggleAction(true);
806 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
808 actionSettingsAutoedit=a;
810 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
811 a->setToggleAction(true);
812 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
814 actionSettingsAutoselectHeading=a;
816 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
817 a->setToggleAction(true);
818 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
820 actionSettingsAutoselectText=a;
822 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
823 a->setToggleAction(true);
824 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
826 actionSettingsPasteNewHeading=a;
828 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
829 a->setToggleAction(true);
830 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
832 actionSettingsUseDelKey=a;
834 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
835 a->setToggleAction(true);
836 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
838 actionSettingsUseFlagGroups=a;
842 void Main::setupTestActions()
844 QPopupMenu *menu = new QPopupMenu( this );
845 menuBar()->insertItem( tr( "&Test" ), menu );
848 a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
849 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
852 a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
853 connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
858 void Main::setupHelpActions()
860 QPopupMenu *menu = new QPopupMenu( this );
861 menuBar()->insertItem( tr( "&Help" ), menu );
864 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
865 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
868 a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
869 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
872 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
873 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
878 void Main::setupContextMenus()
882 // Context Menu for branch or mapcenter
883 branchContextMenu =new QPopupMenu (this);
886 branchAddContextMenu =new QPopupMenu (this);
887 actionEditPaste->addTo ( branchAddContextMenu );
888 actionEditAddBranch->addTo ( branchAddContextMenu );
889 actionEditAddBranchHere->addTo ( branchAddContextMenu );
890 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
891 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
892 branchAddContextMenu->insertSeparator();
893 actionEditLoadImage->addTo( branchAddContextMenu );
894 branchAddContextMenu->insertSeparator();
895 actionEditImportAdd->addTo ( branchAddContextMenu );
896 actionEditImportReplace->addTo ( branchAddContextMenu );
899 branchRemoveContextMenu =new QPopupMenu (this);
900 actionEditCut->addTo ( branchRemoveContextMenu );
901 actionEditDelete->addTo ( branchRemoveContextMenu );
902 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
903 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
905 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
906 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
908 actionEditSaveBranch->addTo( branchContextMenu );
910 branchContextMenu->insertSeparator();
911 actionEditOpenURL->addTo ( branchContextMenu );
912 actionEditURL->addTo ( branchContextMenu );
913 actionEditHeading2URL->addTo ( branchContextMenu );
914 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
915 actionEditBugzilla2URL->addTo( branchContextMenu );
917 branchContextMenu->insertSeparator();
918 actionEditOpenVymLink->addTo ( branchContextMenu );
919 actionEditVymLink->addTo ( branchContextMenu );
920 actionEditDeleteVymLink->addTo ( branchContextMenu );
922 branchContextMenu->insertSeparator();
923 actionGroupFormatFrameTypes->addTo( branchContextMenu );
925 branchContextMenu->insertSeparator();
926 actionFormatHideLinkUnselected->addTo( branchContextMenu );
928 // Context Menu for links in a branch menu
929 // This will be populated "on demand" in MapEditor::updateActions
930 branchContextMenu->insertSeparator();
931 branchLinksContextMenu =new QPopupMenu (this);
932 branchLinksContextMenuDup =new QPopupMenu (this);
933 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
934 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
936 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
937 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
939 // Context menu for floatimage
940 floatimageContextMenu =new QPopupMenu (this);
941 saveImageFormatMenu=new QPopupMenu (this);
942 exportImageFormatMenu=new QPopupMenu (this);
944 QStrList fmt = QImage::outputFormats();
945 for (const char* f = fmt.first(); f; f = fmt.next())
947 saveImageFormatMenu->insertItem( f );
948 exportImageFormatMenu->insertItem( f );
950 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
951 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
952 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
954 floatimageContextMenu->insertSeparator();
955 actionEditCopy->addTo( floatimageContextMenu );
956 actionEditCut->addTo( floatimageContextMenu );
958 floatimageContextMenu->insertSeparator();
959 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
960 a->setToggleAction(true);
961 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
962 a->addTo( floatimageContextMenu);
963 actionEditToggleFloatExport=a;
965 floatimageContextMenu->insertSeparator();
966 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
968 // Context menu for exports
969 exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
971 a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" +QString("...")), 0, this, "exportASCII" );
972 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
973 a->addTo( exportMenu );
975 a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ), 0, this, "exportXML"+QString("...") );
976 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
977 a->addTo( exportMenu );
979 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
981 a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export HTML" ), 0, this, "exportHTML"+QString("...") );
982 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
983 a->addTo( exportMenu );
986 a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" )+QString("..."), ALT + Key_X, this, "exportXHTML" );
987 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
988 a->addTo( exportMenu );
991 // Context menu for canvas
992 canvasContextMenu =new QPopupMenu (this);
993 actionEditMapInfo->addTo( canvasContextMenu );
994 canvasContextMenu->insertSeparator();
995 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
996 canvasContextMenu->insertSeparator();
997 actionFormatLinkColorHint->addTo( canvasContextMenu );
998 actionFormatLinkColor->addTo( canvasContextMenu );
999 actionFormatBackColor->addTo( canvasContextMenu );
1001 // Menu for last opened files
1002 // Read settings initially
1004 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1005 for (int i=1;i<=j;i++)
1007 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1008 if (!s.isEmpty() && j<=maxLastMaps)
1011 setupLastMapsMenu();
1012 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1015 void Main::setupLastMapsMenu()
1017 // Remove double entries
1018 QStringList::Iterator it=lastMaps.begin();
1019 QStringList::Iterator jt;
1020 while (it!=lastMaps.end() )
1024 while (jt!=lastMaps.end() )
1027 jt=lastMaps.remove(jt);
1034 // Limit length of list to maxLastMaps
1035 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1037 // build Menu from lastMaps string list
1038 lastMapsMenu->clear();
1039 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1040 lastMapsMenu->insertItem (*it );
1044 void Main::hideEvent (QHideEvent * )
1046 if (!textEditor->isMinimized() ) textEditor->hide();
1049 void Main::showEvent (QShowEvent * )
1051 if (textEditor->showWithMain()) textEditor->showNormal();
1054 bool Main::reallyWriteDirectory(const QString &dir)
1056 QStringList eList = QDir(dir).entryList();
1057 if (eList.first() ==".") eList.pop_front(); // remove "."
1058 if (eList.first() =="..") eList.pop_front(); // remove "."
1059 if (!eList.isEmpty())
1061 QMessageBox mb( "VYM",
1062 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1063 QMessageBox::Warning,
1065 QMessageBox::Cancel | QMessageBox::Default,
1066 QMessageBox::QMessageBox::NoButton );
1068 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1069 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1072 case QMessageBox::Yes:
1075 case QMessageBox::Cancel:
1083 QString Main::browseDirectory (const QString &caption)
1085 QFileDialog fd(this,caption);
1086 fd.setMode (QFileDialog::DirectoryOnly);
1087 fd.setCaption("VYM - "+caption);
1090 if ( fd.exec() == QDialog::Accepted )
1091 return fd.selectedFile();
1096 MapEditor* Main::currentMapEditor() const
1098 if ( tabWidget->currentPage() &&
1099 tabWidget->currentPage()->inherits( "MapEditor" ) )
1100 return (MapEditor*)tabWidget->currentPage();
1104 //TODO not used now, maybe use this for overview window later
1105 void Main::newView()
1107 // Open a new view... have it delete when closed.
1108 Main *m = new Main(0, 0, WDestructiveClose);
1109 qApp->setMainWidget(m);
1111 qApp->setMainWidget(0);
1114 void Main::editorChanged(QWidget *)
1116 // Unselect all possibly selected objects
1117 // (Important to update note editor)
1120 for (i=0;i<=tabWidget->count() -1;i++)
1123 me=(MapEditor*)tabWidget->page(i);
1126 currentMapEditor()->reselect();
1128 // Update actions to in menus and toolbars according to editor
1129 currentMapEditor()->updateActions();
1132 void Main::fileNew()
1134 QString fn="unnamed";
1135 MapEditor* medit = new MapEditor (tabWidget, true);
1136 tabWidget->addTab (medit,fn);
1137 tabWidget->showPage(medit);
1138 medit->viewport()->setFocus();
1139 medit->select("mc:");
1142 void Main::fileLoad(QString fn, const LoadMode &lmode)
1145 enum errorCode {success,aborted};
1146 errorCode err=success;
1148 // fn is usually the archive, mapfile the file after uncompressing
1151 // Make fn absolute (needed for unzip)
1152 fn=QDir (fn).absPath();
1158 // Check, if map is already loaded
1160 while (i<=tabWidget->count() -1)
1162 me=(MapEditor*)tabWidget->page(i);
1163 if (me->getFilePath() == fn)
1165 // Already there, ask for confirmation
1166 QMessageBox mb( "VYM",
1167 tr("The map %1\nis already opened."
1168 "Opening the same map in multiple editors may lead \n"
1169 "to confusion when finishing working with vym."
1170 "Do you want to").arg(fn),
1171 QMessageBox::Warning,
1172 QMessageBox::Yes | QMessageBox::Default,
1173 QMessageBox::Cancel | QMessageBox::Escape,
1174 QMessageBox::QMessageBox::NoButton);
1175 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1176 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1179 case QMessageBox::Yes:
1181 i=tabWidget->count();
1183 case QMessageBox::Cancel:
1195 if ( !fn.isEmpty() )
1197 me = currentMapEditor();
1198 int tabIndex=tabWidget->currentPageIndex();
1199 // Check first, if mapeditor exists
1200 // If it is not default AND we want a new map,
1201 // create a new mapeditor in a new tab
1202 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1204 me = new MapEditor (tabWidget,true);
1205 tabWidget->addTab (me,fn);
1206 tabIndex=tabWidget->indexOf (me);
1207 tabWidget->setCurrentPage (tabIndex);
1210 // Check, if file exists (important for creating new files
1211 // from command line
1212 if (!QFile(fn).exists() )
1214 QMessageBox mb( "VYM",
1215 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1216 QMessageBox::Question,
1218 QMessageBox::Cancel | QMessageBox::Default,
1219 QMessageBox::QMessageBox::NoButton );
1221 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1222 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1225 case QMessageBox::Yes:
1227 currentMapEditor()->setFilePath(fn);
1228 tabWidget->setTabLabel (currentMapEditor(),
1229 currentMapEditor()->getFileName() );
1230 statusBar()->message( "Created " + fn , statusbarTime );
1233 case QMessageBox::Cancel:
1234 // don't create new map
1235 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1242 //tabWidget->currentPage() won't be NULL here, because of above...
1243 tabWidget->showPage(me);
1244 me->viewport()->setFocus();
1246 // Create temporary directory for packing
1247 char tmpdir1[]="/tmp/vym-XXXXXX";
1248 QString tmpMapDir=mkdtemp(tmpdir1);
1250 // Try to unzip file
1251 Process *zipProc=new Process ();
1252 zipProc->clearArguments();
1253 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1254 zipProc->addArgument ("unzip");
1255 zipProc->addArgument (fn );
1256 zipProc->addArgument ("-d");
1257 zipProc->addArgument (tmpMapDir);
1259 if (!zipProc->start() )
1261 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1262 tr("Couldn't start unzip to decompress data."));
1267 zipProc->waitFinished();
1268 if (!zipProc->normalExit() )
1270 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1271 tr("unzip didn't exit normally") +
1272 zipProc->getErrout() );
1276 if (zipProc->exitStatus()>0)
1278 if (zipProc->exitStatus()==9)
1280 // no zipped file, but maybe .xml or old version? Try again.
1282 me->setZipped(false);
1286 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1287 QString("unzip exit code: %1").arg(zipProc->exitStatus() ) +
1288 zipProc->getErrout() );
1292 { // Uncompressing was successfull,
1293 // load from uncompressed temporary directory
1295 me->setZipped(true);
1298 // Look for mapname.xml
1299 mapfile= fn.left(fn.findRev(".",-1,true));
1300 mapfile=mapfile.section( '/', -1 );
1301 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1302 if (!file.exists() )
1304 // mapname.xml does not exist, well,
1305 // maybe some renamed the mapname.vym file...
1306 // Try to find any .xml in the toplevel
1307 // directory of the .vym file
1308 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1309 if (flist.count()==1)
1311 // Only one entry, take this one
1312 mapfile=tmpMapDir + "/"+flist.first();
1315 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1316 *it=tmpMapDir + "/" + *it;
1317 // FIXME Multiple entries, load all (but only the first one into this ME)
1318 //mainWindow->fileLoadFromTmp (flist);
1319 //returnCode=1; // Silently forget this attempt to load
1320 qWarning ("MainWindow::load (fn) multimap found...");
1323 if (flist.isEmpty() )
1325 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1326 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1329 } //file doesn't exist
1331 mapfile=file.name();
1332 } // Uncompressing successfull
1337 // Save existing filename
1338 QString fn_org=me->getFilePath();
1340 // Finally load map into mapEditor
1341 me->setFilePath (mapfile,fn);
1342 if (me->load(mapfile,lmode))
1345 // Restore old (maybe empty) filepath, if this is an import
1347 me->setFilePath (fn_org);
1350 system ( "rm -rf "+tmpMapDir);
1357 me->setFilePath (fn);
1358 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1359 lastMaps.prepend(me->getFilePath() );
1360 setupLastMapsMenu();
1361 actionFilePrint->setEnabled (true);
1363 statusBar()->message( "Loaded " + fn, statusbarTime );
1373 statusBar()->message( "Could not load " + fn, statusbarTime );
1377 void Main::fileLoad(const LoadMode &lmode)
1379 QFileDialog *fd=new QFileDialog( this);
1380 if (!lastFileDir.isEmpty())
1381 fd->setDir (lastFileDir);
1382 fd->addFilter ("XML (*.xml)");
1383 fd->addFilter ("VYM map (*.vym *.vyp)");
1387 fd->setCaption(tr("Load vym map"));
1390 fd->setCaption(tr("Import: Add vym map to selection"));
1393 fd->setCaption(tr("Import: Replace selection with vym map"));
1399 if ( fd->exec() == QDialog::Accepted )
1401 lastFileDir=fd->dirPath();
1402 fn = fd->selectedFile();
1403 fileLoad(fn, lmode);
1407 void Main::fileLoad()
1412 void Main::fileLoadLast(int i)
1414 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1417 void Main::fileSave(const SaveMode &savemode)
1419 // tmp dir for zipping
1423 enum errorCode {success,aborted};
1424 errorCode err=success;
1426 QString safeFilePath;
1428 bool saveZipped=currentMapEditor()->saveZipped();
1430 MapEditor * me=currentMapEditor();
1433 QString fn=me->getFilePath();
1434 // filename=unnamed, filepath="" in constructor...
1435 if ( !fn.isEmpty() )
1437 // We have a filepath, go on saving
1438 // First remove existing file, we
1439 // don't want to add to old zip archives
1443 QMessageBox::warning( 0, tr( "Save Error" ),
1444 fn+ tr("\ncould not be removed before saving"));
1446 // Look, if we should zip the data:
1449 QMessageBox mb( "VYM",
1450 tr("The map %1\ndid not use the compressed "
1451 "vym file format.\nWriting it uncompressed will also write images \n"
1452 "and flags and thus may overwrite files in the "
1453 "given directory\n\nDo you want to write the map").arg(fn),
1454 QMessageBox::Warning,
1455 QMessageBox::Yes | QMessageBox::Default,
1457 QMessageBox::Cancel | QMessageBox::Escape);
1458 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1459 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1460 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1463 case QMessageBox::Yes:
1464 // save compressed (default file format)
1467 case QMessageBox::No:
1468 // save uncompressed
1471 case QMessageBox::Cancel:
1480 char tmpdir1[]="/tmp/vym-XXXXXX";
1481 tmpMapDir=mkdtemp(tmpdir1);
1483 safeFilePath=me->getFilePath();
1484 me->setFilePath (tmpMapDir+"/"+
1485 me->getMapName()+ ".xml",
1487 me->save (savemode);
1488 me->setFilePath (safeFilePath);
1490 // zip the temporary directory
1491 Process *zipProc=new Process ();
1492 zipProc->clearArguments();
1493 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1494 zipProc->addArgument ("zip");
1495 zipProc->addArgument ("-r");
1496 zipProc->addArgument (fn);
1497 zipProc->addArgument (".");
1499 if (!zipProc->start() )
1501 // zip could not be started
1502 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1503 tr("Couldn't start zip to compress data."));
1507 // zip could be started
1508 zipProc->waitFinished();
1509 if (!zipProc->normalExit() )
1511 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1512 tr("zip didn't exit normally")+
1513 "\n" + zipProc->getErrout());
1517 if (zipProc->exitStatus()>0)
1519 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1520 QString("zip exit code: %1").arg(zipProc->exitStatus() )+
1521 "\n" + zipProc->getErrout() );
1525 } // zip could be started
1530 safeFilePath=me->getFilePath();
1531 me->setFilePath (fn, safeFilePath);
1532 me->save (savemode);
1533 me->setFilePath (safeFilePath);
1535 } // filepath available
1538 // We have no filepath yet,
1539 // call fileSaveAs() now, this will call fileSave()
1541 fileSaveAs(savemode);
1545 if (me->saveZipped())
1548 system ( "rm -rf "+ tmpMapDir );
1553 statusBar()->message(
1554 tr("Saved %1").arg(me->getFilePath()),
1556 lastMaps.prepend(me->getFilePath() );
1557 setupLastMapsMenu();
1559 statusBar()->message(
1560 tr("Couldn't save ").arg(me->getFilePath()),
1564 void Main::fileSave()
1566 fileSave (CompleteMap);
1569 void Main::fileSaveAs(const SaveMode& savemode)
1574 if (currentMapEditor())
1576 if (savemode==CompleteMap)
1577 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1579 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1580 if ( !fn.isEmpty() )
1582 // Check for existing file
1583 if (QFile (fn).exists())
1585 QMessageBox mb( "VYM",
1586 tr("The file %1\nexists already. Do you want to").arg(fn),
1587 QMessageBox::Warning,
1588 QMessageBox::Yes | QMessageBox::Default,
1589 QMessageBox::Cancel | QMessageBox::Escape,
1590 QMessageBox::QMessageBox::NoButton);
1591 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1592 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1595 case QMessageBox::Yes:
1598 case QMessageBox::Cancel:
1605 // New file, add extension to filename, if missing
1606 // This is always .vym or .vyp, depending on savemode
1607 if (savemode==CompleteMap)
1609 if (!fn.contains (".vym") && !fn.contains (".xml"))
1613 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1622 currentMapEditor()->setFilePath(fn);
1626 if (savemode==CompleteMap)
1627 tabWidget->setTabLabel (currentMapEditor(),
1628 currentMapEditor()->getFileName() );
1634 void Main::fileSaveAs()
1636 fileSaveAs (CompleteMap);
1639 void Main::fileImportDir()
1641 if (currentMapEditor())
1642 currentMapEditor()->importDir();
1645 void Main::fileExportXML()
1647 if (currentMapEditor())
1649 QString dir=browseDirectory(tr("Export XML to directory"));
1650 if (dir !="" && reallyWriteDirectory(dir) )
1651 currentMapEditor()->exportXML(dir);
1655 void Main::fileExportHTML()
1657 if (currentMapEditor())
1659 ExportHTMLDialog dia(this);
1661 if (dia.exec()==QDialog::Accepted)
1663 QString dir=dia.getDir();
1664 if (reallyWriteDirectory(dir) )
1666 currentMapEditor()->exportXML (dia.getDir() );
1667 dia.doExport(currentMapEditor()->getMapName() );
1673 void Main::fileExportXHTML()
1676 if (currentMapEditor())
1678 ExportXHTMLDialog dia(this);
1679 dia.setFilePath (currentMapEditor()->getFilePath() );
1680 dia.setMapName (currentMapEditor()->getMapName() );
1683 if (dia.exec()==QDialog::Accepted)
1685 QString dir=dia.getDir();
1686 // Check, if warnings should be used before overwriting
1687 // the output directory
1690 ok=reallyWriteDirectory(dir);
1696 currentMapEditor()->exportXML (dia.getDir() );
1697 dia.doExport(currentMapEditor()->getMapName() );
1698 if (dia.hasChanged())
1699 currentMapEditor()->setChanged();
1705 void Main::fileExportImage(int item)
1707 if (currentMapEditor())
1709 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1711 if ( !fn.isEmpty() )
1713 currentMapEditor()->exportImage(fn,item);
1715 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1720 void Main::fileExportASCII()
1722 if (currentMapEditor())
1723 currentMapEditor()->exportASCII();
1726 void Main::fileCloseMap()
1728 if (currentMapEditor())
1730 if (currentMapEditor()->hasChanged())
1732 QMessageBox mb( "VYM",
1733 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1734 QMessageBox::Warning,
1735 QMessageBox::Yes | QMessageBox::Default,
1737 QMessageBox::Cancel | QMessageBox::Escape );
1738 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1739 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1742 case QMessageBox::Yes:
1744 fileSave(CompleteMap);
1746 case QMessageBox::No:
1747 // close without saving
1749 case QMessageBox::Cancel:
1754 currentMapEditor()->closeMap();
1755 tabWidget->removePage(currentMapEditor());
1756 if (tabWidget->count()==0)
1757 actionFilePrint->setEnabled (false);
1761 void Main::filePrint()
1763 if (currentMapEditor())
1764 currentMapEditor()->print();
1767 void Main::fileExitVYM()
1769 // Check if one or more editors have changed
1772 for (i=0;i<=tabWidget->count() -1;i++)
1775 me=(MapEditor*)tabWidget->page(i);
1777 // If something changed, ask what to do
1778 if (me->isUnsaved())
1780 tabWidget->setCurrentPage(i);
1781 QMessageBox mb( "VYM",
1782 tr("This map is not saved yet. Do you want to"),
1783 QMessageBox::Warning,
1784 QMessageBox::Yes | QMessageBox::Default,
1786 QMessageBox::Cancel | QMessageBox::Escape );
1787 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1788 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1790 // Call undocumented function: setActiveWindow is only
1791 // possible, if widget is visible. This depends on
1793 #if defined(Q_OS_LINUX)
1794 qt_wait_for_window_manager( this);
1796 mb.setActiveWindow();
1797 switch( mb.exec() ) {
1798 case QMessageBox::Yes:
1799 // save (the changed editors) and exit
1800 fileSave(CompleteMap);
1802 case QMessageBox::No:
1803 // exit without saving
1805 case QMessageBox::Cancel:
1806 // don't save and don't exit
1810 } // loop over all MEs
1814 void Main::editUndo()
1816 if (currentMapEditor())
1817 currentMapEditor()->undo();
1820 void Main::editRedo() // TODO
1824 void Main::editCopy()
1826 if (currentMapEditor())
1827 currentMapEditor()->copy();
1830 void Main::editPaste()
1832 if (currentMapEditor())
1833 currentMapEditor()->paste();
1836 void Main::editCut()
1838 if (currentMapEditor())
1839 currentMapEditor()->cut();
1842 void Main::editOpenFindWindow()
1844 findWindow->popup();
1845 findWindow->raise();
1847 // Call undocumented function: setActiveWindow is only
1848 // possible, if widget is visible. This depends on
1850 #if defined(Q_OS_LINUX)
1851 qt_wait_for_window_manager( this);
1853 findWindow->setActiveWindow();
1856 void Main::editFind(QString s)
1859 BranchObj *bo=currentMapEditor()->findText(s, cs);
1862 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
1865 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
1866 tr("No matches found for <b>%1</b>").arg(s));
1870 void Main::editFindChanged()
1871 { // Notify editor, to abort the current find process
1872 currentMapEditor()->findReset();
1875 void Main::editOpenURL()
1877 if (currentMapEditor())
1878 currentMapEditor()->openURL();
1881 void Main::editURL()
1883 if (currentMapEditor())
1884 currentMapEditor()->editURL();
1887 void Main::editHeading2URL()
1889 if (currentMapEditor())
1890 currentMapEditor()->editHeading2URL();
1893 void Main::editBugzilla2URL()
1895 if (currentMapEditor())
1896 currentMapEditor()->editBugzilla2URL();
1899 void Main::editOpenVymLink()
1901 // Get current path to map
1902 QString currentVymLink;
1903 if (currentMapEditor())
1905 currentVymLink=currentMapEditor()->getVymLink();
1906 // compare path with already loaded maps
1910 for (i=0;i<=tabWidget->count() -1;i++)
1912 me=(MapEditor*)tabWidget->page(i);
1913 if (currentVymLink==me->getFilePath() )
1922 if (!QFile(currentVymLink).exists() )
1923 QMessageBox::critical( 0, tr( "Critical Error" ),
1924 tr("Couldn't open map %1").arg(currentVymLink));
1927 fileLoad (currentVymLink, NewMap);
1928 tabWidget->setCurrentPage (tabWidget->count()-1);
1931 // Go to tab containing the map
1932 tabWidget->setCurrentPage (index);
1936 void Main::editVymLink()
1938 if (currentMapEditor())
1939 currentMapEditor()->editVymLink();
1942 void Main::editDeleteVymLink()
1944 if (currentMapEditor())
1945 currentMapEditor()->deleteVymLink();
1948 void Main::editMapInfo()
1950 if (currentMapEditor())
1951 currentMapEditor()->editMapInfo();
1954 void Main::editMoveUp()
1956 if (currentMapEditor())
1957 currentMapEditor()->moveBranchUp();
1960 void Main::editMoveDown()
1962 if (currentMapEditor())
1963 currentMapEditor()->moveBranchDown();
1966 void Main::editToggleScroll()
1968 if (currentMapEditor())
1970 currentMapEditor()->toggleScroll();
1974 void Main::editUnScrollAll()
1976 if (currentMapEditor())
1978 currentMapEditor()->unScrollAll();
1982 void Main::editHeading()
1984 if (currentMapEditor())
1985 currentMapEditor()->editHeading();
1988 void Main::editNewBranch()
1990 if (currentMapEditor())
1991 currentMapEditor()->addNewBranch(0);
1994 void Main::editNewBranchHere()
1996 if (currentMapEditor())
1997 currentMapEditor()->addNewBranchHere();
2000 void Main::editNewBranchAbove()
2002 if (currentMapEditor())
2003 currentMapEditor()->addNewBranch(-1);
2006 void Main::editNewBranchBelow()
2008 if (currentMapEditor())
2009 currentMapEditor()->addNewBranch(1);
2012 void Main::editImportAdd()
2014 fileLoad (ImportAdd);
2017 void Main::editImportReplace()
2019 fileLoad (ImportReplace);
2022 void Main::editSaveBranch()
2024 fileSaveAs (PartOfMap);
2027 void Main::editRemoveBranchHere()
2029 if (currentMapEditor())
2030 currentMapEditor()->removeBranchHere();
2033 void Main::editRemoveChilds()
2035 if (currentMapEditor())
2036 currentMapEditor()->removeChilds();
2039 void Main::editDeleteSelection()
2041 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2042 currentMapEditor()->deleteSelection();
2045 void Main::editUpperBranch()
2047 if (currentMapEditor())
2048 currentMapEditor()->selectUpperBranch();
2051 void Main::editLowerBranch()
2053 if (currentMapEditor())
2054 currentMapEditor()->selectLowerBranch();
2057 void Main::editLeftBranch()
2059 if (currentMapEditor())
2060 currentMapEditor()->selectLeftBranch();
2063 void Main::editRightBranch()
2065 if (currentMapEditor())
2066 currentMapEditor()->selectRightBranch();
2069 void Main::editFirstBranch()
2071 if (currentMapEditor())
2072 currentMapEditor()->selectFirstBranch();
2075 void Main::editLastBranch()
2077 if (currentMapEditor())
2078 currentMapEditor()->selectLastBranch();
2081 void Main::editLoadImage()
2083 if (currentMapEditor())
2084 currentMapEditor()->loadFloatImage();
2087 void Main::editSaveImage(int item)
2089 if (currentMapEditor())
2090 currentMapEditor()->saveFloatImage(item);
2093 void Main::editToggleFloatExport()
2095 if (currentMapEditor())
2096 currentMapEditor()->toggleFloatExport();
2099 void Main::editFollowXLink(int item)
2101 if (currentMapEditor())
2102 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2105 void Main::editEditXLink(int item)
2107 if (currentMapEditor())
2108 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2111 void Main::formatSelectColor()
2113 if (currentMapEditor())
2115 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2116 if ( !col.isValid() ) return;
2117 currentMapEditor()->setColor( col );
2118 colorChanged( col );
2122 void Main::formatPickColor()
2124 if (currentMapEditor())
2125 colorChanged( currentMapEditor()->pickColor() );
2128 void Main::colorChanged(QColor c)
2130 QPixmap pix( 16, 16 );
2132 actionFormatColor->setIconSet( pix );
2135 void Main::formatColorItem()
2137 if (currentMapEditor())
2138 currentMapEditor()->colorItem();
2141 void Main::formatColorBranch()
2143 if (currentMapEditor())
2144 currentMapEditor()->colorBranch();
2147 void Main::formatLinkStyleLine()
2149 if (currentMapEditor())
2150 currentMapEditor()->setLinkStyle(StyleLine);
2153 void Main::formatLinkStyleParabel()
2155 if (currentMapEditor())
2156 currentMapEditor()->setLinkStyle(StyleParabel);
2159 void Main::formatLinkStylePolyLine()
2161 if (currentMapEditor())
2162 currentMapEditor()->setLinkStyle(StylePolyLine);
2165 void Main::formatLinkStylePolyParabel()
2167 if (currentMapEditor())
2168 currentMapEditor()->setLinkStyle(StylePolyParabel);
2171 void Main::formatSelectBackColor()
2173 if (currentMapEditor())
2174 currentMapEditor()->selectBackgroundColor();
2177 void Main::formatSelectLinkColor()
2179 if (currentMapEditor())
2180 currentMapEditor()->selectLinkColor();
2183 void Main::formatToggleLinkColorHint()
2185 currentMapEditor()->toggleLinkColorHint();
2188 void Main::formatFrameNone()
2190 if (currentMapEditor())
2191 currentMapEditor()->setFrame(NoFrame);
2194 void Main::formatFrameRectangle()
2196 if (currentMapEditor())
2197 currentMapEditor()->setFrame(Rectangle);
2200 void Main::formatHideLinkUnselected()
2202 if (currentMapEditor())
2203 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2206 void Main::viewZoomReset()
2208 if (currentMapEditor())
2212 currentMapEditor()->setWorldMatrix( m );
2213 currentMapEditor()->setViewCenter();
2214 currentMapEditor()->adjustCanvasSize();
2218 void Main::viewZoomIn()
2220 if (currentMapEditor())
2222 QWMatrix m = currentMapEditor()->worldMatrix();
2223 m.scale( 1.25, 1.25 );
2224 currentMapEditor()->setWorldMatrix( m );
2225 currentMapEditor()->setViewCenter();
2226 currentMapEditor()->adjustCanvasSize();
2230 void Main::viewZoomOut()
2232 if (currentMapEditor())
2234 QWMatrix m = currentMapEditor()->worldMatrix();
2235 m.scale( 0.8, 0.8 );
2236 currentMapEditor()->setWorldMatrix( m );
2237 currentMapEditor()->setViewCenter();
2238 currentMapEditor()->adjustCanvasSize();
2242 void Main::modModeColor()
2246 void Main::modModeLink()
2250 bool Main::settingsPDF()
2252 // Default browser is set in constructor
2254 QString text = QInputDialog::getText(
2255 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2256 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2258 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2263 bool Main::settingsURL()
2265 // Default browser is set in constructor
2267 QString text = QInputDialog::getText(
2268 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2269 settings.readEntry("/vym/mainwindow/readerURL")
2272 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2276 void Main::windowToggleNoteEditor()
2278 if (textEditor->showWithMain() )
2279 windowHideNoteEditor();
2281 windowShowNoteEditor();
2284 void Main::updateNoteFlag()
2286 if (currentMapEditor())
2287 currentMapEditor()->updateNoteFlag();
2290 void Main::windowShowNoteEditor()
2292 textEditor->setShowWithMain(true);
2294 actionViewToggleNoteEditor->setOn (true);
2297 void Main::windowHideNoteEditor()
2299 textEditor->setShowWithMain(false);
2301 actionViewToggleNoteEditor->setOn (false);
2304 void Main::windowNextEditor()
2306 if (tabWidget->currentPageIndex() < tabWidget->count())
2307 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2310 void Main::windowPreviousEditor()
2312 if (tabWidget->currentPageIndex() >0)
2313 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2316 void Main::standardFlagChanged()
2318 currentMapEditor()->toggleStandardFlag(sender()->name());
2321 void Main::testFunction()
2323 //textEditor->stackUnder(this);
2324 currentMapEditor()->testFunction();
2327 void Main::testShowClipboard()
2329 clipboardME->show();
2332 void Main::helpDoc()
2335 #if defined(Q_OS_MACX)
2336 docpath="./vym.app/Contents/vym.pdf";
2338 // default path in SUSE LINUX
2339 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2342 if (!QFile (docpath).exists() )
2344 // relative path for easy testing in tarball
2345 docpath="doc/vym.pdf";
2346 if (!QFile (docpath).exists() )
2348 // relative path for testing while still writing vym.tex
2349 docpath="doc/tex/vym.pdf";
2350 if (!QFile (docpath).exists() )
2352 QMessageBox::critical(0,
2353 tr("Critcal error"),
2354 tr("Couldn't find the documentation\n"
2355 "vym.pdf in various places."));
2361 Process *pdfProc = new Process();
2362 pdfProc->clearArguments();
2363 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2364 pdfProc->addArgument( docpath);
2366 if ( !pdfProc->start() )
2369 QMessageBox::critical(0,
2370 tr("Critcal error"),
2371 tr("Couldn't find a viewer to read vym.pdf.\n"
2372 "Please use Settings->")+tr("Set application to open pdf files"));
2378 void Main::helpAbout()
2381 ad.setName ("aboutwindow");
2382 ad.setMinimumSize(500,500);
2383 ad.resize (QSize (500,500));
2387 void Main::helpAboutQT()
2389 QMessageBox::aboutQt( this, "Qt Application Example" );