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"
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* actionEditRedo;
73 extern QAction *actionEditCopy;
74 extern QAction *actionEditCut;
75 extern QAction *actionEditPaste;
76 extern QAction *actionEditMoveUp;
77 extern QAction *actionEditMoveDown;
78 extern QAction *actionEditToggleScroll;
79 extern QAction* actionEditOpenURL;
80 extern QAction* actionEditURL;
81 extern QAction* actionEditHeading2URL;
82 extern QAction* actionEditBugzilla2URL;
83 extern QAction *actionEditOpenVymLink;
84 extern QAction *actionEditVymLink;
85 extern QAction *actionEditDeleteVymLink;
86 extern QAction *actionEditMapInfo;
87 extern QAction *actionEditHeading;
88 extern QAction *actionEditDelete;
89 extern QAction *actionEditAddBranch;
90 extern QAction *actionEditAddBranchHere;
91 extern QAction *actionEditAddBranchAbove;
92 extern QAction *actionEditAddBranchBelow;
93 extern QAction *actionEditRemoveBranchHere;
94 extern QAction *actionEditRemoveChilds;
95 extern QAction *actionEditImportAdd;
96 extern QAction *actionEditImportReplace;
97 extern QAction *actionEditSaveBranch;
98 extern QAction *actionEditSelectFirst;
99 extern QAction *actionEditSelectLast;
100 extern QAction *actionEditLoadImage;
101 extern QAction *actionEditToggleFloatExport;
103 extern QAction* actionFormatColor;
104 extern QAction* actionFormatPickColor;
105 extern QAction* actionFormatColorBranch;
106 extern QAction* actionFormatColorSubtree;
107 extern QAction* actionFormatLinkColorHint;
108 extern QAction* actionFormatBackColor;
109 extern QAction* actionFormatLinkColor;
111 extern QActionGroup* actionGroupModModes;
112 extern QAction* actionModModeColor;
113 extern QAction* actionModModeLink;
114 extern QAction* actionModModeCopy;
116 extern QActionGroup *actionGroupFormatFrameTypes;
117 extern QAction *actionFormatFrameNone;
118 extern QAction *actionFormatFrameRectangle;
120 extern QActionGroup *actionGroupFormatLinkStyles;
121 extern QAction *actionFormatLinkStyleLine;
122 extern QAction *actionFormatLinkStyleParabel;
123 extern QAction *actionFormatLinkStylePolyLine;
124 extern QAction *actionFormatLinkStylePolyParabel;
125 extern QAction *actionFormatHideLinkUnselected;
127 extern QAction *actionViewToggleNoteEditor;
129 extern QAction* actionSettingsAutoedit;
130 extern QAction* actionSettingsAutoselectHeading;
131 extern QAction* actionSettingsAutoselectHeading;
132 extern QAction* actionSettingsAutoselectText;
133 extern QAction* actionSettingsPasteNewHeading;
134 extern QAction* actionSettingsUseDelKey;
135 extern QAction* actionSettingsUseFlagGroups;
137 extern QPopupMenu* branchContextMenu;
138 extern QPopupMenu* branchAddContextMenu;
139 extern QPopupMenu* branchRemoveContextMenu;
140 extern QPopupMenu* branchLinksContextMenu;
141 extern QPopupMenu* branchLinksContextMenuDup;
142 extern QPopupMenu* floatimageContextMenu;
143 extern QPopupMenu* saveImageFormatMenu;
144 extern QPopupMenu* canvasContextMenu;
145 extern QPopupMenu* lastMapsMenu;
146 extern QPopupMenu* exportMenu;
147 extern QPopupMenu* exportImageFormatMenu;
150 extern Settings settings;
151 extern Options options;
153 #if defined(Q_OS_LINUX)
154 extern void qt_wait_for_window_manager( QWidget* w );
157 Main::Main(QWidget* parent, const char* name, WFlags f) :
158 QMainWindow(parent,name,f)
162 setCaption ("VYM - View Your Mind");
164 // Load window settings
165 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
166 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
167 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
168 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
171 // Set random seed (random used for object IDs)
172 QTime t = QTime::currentTime(); // set random seed
173 srand( t.hour()*12+t.minute()*60+t.second()*60 );
176 // Initialize some settings, which are platform dependant
179 // application to open URLs
180 p="/vym/mainwindow/readerURL";
181 #if defined(Q_OS_LINUX)
182 s=settings.readEntry (p,"konqueror");
184 #if defined(Q_OS_MACX)
185 s=settings.readEntry (p,"/usr/bin/open");
187 s=settings.readEntry (p,"mozilla");
190 settings.writeEntry( p,s);
192 // application to open PDFs
193 p="/vym/mainwindow/readerPDF";
194 #if defined(Q_OS_LINUX)
195 s=settings.readEntry (p,"acroread");
197 #if defined(Q_OS_MACX)
198 s=settings.readEntry (p,"/usr/bin/open");
200 s=settings.readEntry (p,"acroread");
203 settings.writeEntry( p,s);
208 // Create tab widget which holds the maps
209 tabWidget= new QTabWidget (this);
210 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
211 this, SLOT( editorChanged( QWidget * ) ) );
213 setCentralWidget(tabWidget);
217 setupFormatActions();
221 setupSettingsActions();
223 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
226 // After menu is created, we can enable some actions
227 actionFilePrint->setEnabled (true);
232 // Initialize Find window
233 findWindow=new FindWindow(NULL,"findwindow");
234 connect (findWindow, SIGNAL( findButton(QString) ),
235 this, SLOT(editFind(QString) ) );
236 connect (findWindow, SIGNAL( somethingChanged() ),
237 this, SLOT(editFindChanged() ) );
240 // Connect TextEditor, so that we can update flags if text changes
241 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
245 // Creating the default map into first tab is done in main.cpp now...
251 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
252 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
253 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
254 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
256 settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
257 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
259 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
260 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
261 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
262 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
263 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
264 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
267 int maps=lastMaps.count();
268 settings.writeEntry( "/vym/lastMaps/number",maps );
269 for (int i=1;i<=maps;i++)
271 QStringList::Iterator it = lastMaps.at(i-1);
272 s=QString("/vym/lastMaps/map-%1").arg(i);
273 if (!s.isEmpty() && i<=maxLastMaps)
274 settings.writeEntry (s, *it);
278 // To make the texteditor save its settings, call the destructor
282 void Main::loadCmdLine()
284 /* TODO draw some kind of splashscreen while loading...
290 QStringList flist=options.getFileList();
291 QStringList::Iterator it=flist.begin();
293 while (it !=flist.end() )
295 fileLoad (*it, NewMap);
301 void Main::statusMessage(const QString &s)
303 statusBar()->message (s);
306 void Main::closeEvent (QCloseEvent* )
312 void Main::setupFileActions()
314 QToolBar *tb = new QToolBar( this );
315 tb->setLabel( "File Actions" );
316 QPopupMenu *menu = new QPopupMenu( this );
317 menuBar()->insertItem( tr( "&File" ), menu );
319 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
322 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
323 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
327 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
328 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
332 lastMapsMenu = new QPopupMenu (this);
334 menu->insertItem (tr("Open Recent"),lastMapsMenu );
335 menu->insertSeparator();
337 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
338 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
343 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
344 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
347 menu->insertSeparator();
349 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
350 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
353 exportMenu = new QPopupMenu (this);
354 menu->insertItem (tr("Export"),exportMenu );
356 menu->insertSeparator();
359 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
360 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
365 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
366 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
369 a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
370 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
376 void Main::setupEditActions()
378 QToolBar *tb = new QToolBar( this );
379 tb->setLabel( "Edit Actions" );
380 QPopupMenu *menu = new QPopupMenu( this );
381 menuBar()->insertItem( tr( "&Edit" ), menu );
385 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
386 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
387 a->setEnabled (false);
392 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
394 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
395 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
400 menu->insertSeparator();
401 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
402 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
403 a->setEnabled (false);
407 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
408 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
409 a->setEnabled (false);
413 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
414 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
415 a->setEnabled (false);
420 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
421 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
422 a->setEnabled (false);
425 actionListBranches.append(a);
428 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
429 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
430 a->setEnabled (false);
433 actionListBranches.append(a);
434 actionEditMoveDown=a;
437 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
438 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
439 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
440 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
441 #if defined(Q_OS_MACX)
442 actionEditToggleScroll=alt;
444 actionEditToggleScroll=a;
446 actionEditToggleScroll->setEnabled (false);
447 actionEditToggleScroll->addTo( tb );
448 actionEditToggleScroll->addTo( menu );
449 actionListBranches.append(actionEditToggleScroll);
451 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
452 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
455 menu->insertSeparator();
457 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
458 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
461 menu->insertSeparator();
463 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
464 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
466 a->setEnabled (false);
469 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
470 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
471 a->setEnabled (false);
472 actionListBranches.append(a);
475 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
476 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
477 a->setEnabled (false);
478 actionListBranches.append(a);
479 actionEditHeading2URL=a;
481 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
482 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
483 a->setEnabled (false);
484 actionListBranches.append(a);
485 actionEditBugzilla2URL=a;
488 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" );
489 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
491 a->setEnabled (false);
492 actionEditOpenVymLink=a;
494 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
495 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
496 a->setEnabled (false);
497 actionListBranches.append(a);
500 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
501 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
502 a->setEnabled (false);
503 actionEditDeleteVymLink=a;
505 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
506 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
507 a->setEnabled (true);
510 menu->insertSeparator();
512 // Shortcuts to modify heading:
513 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
514 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
515 actionListBranches.append(a);
516 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
517 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
518 actionListBranches.append(a);
520 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
521 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
522 a->setEnabled (false);
524 actionListBranches.append(a);
526 // Shortcut to delete selection
527 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
528 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
529 a->setEnabled (false);
532 // Shortcut to add branch
533 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
534 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
535 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
536 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
537 a->setEnabled (false);
538 actionListBranches.append(a);
539 #if defined (Q_OS_MACX)
540 actionEditAddBranch=alt;
542 actionEditAddBranch=a;
545 // Add branch by inserting it at selection
546 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
547 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
548 a->setEnabled (false);
549 actionListBranches.append(a);
550 actionEditAddBranchHere=a;
553 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
554 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
555 a->setEnabled (false);
556 actionListBranches.append(a);
557 actionEditAddBranchAbove=a;
560 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
561 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
562 a->setEnabled (false);
563 actionListBranches.append(a);
564 actionEditAddBranchBelow=a;
566 // Import at selection (adding to selection)
567 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
568 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
569 a->setEnabled (false);
570 actionListBranches.append(a);
571 actionEditImportAdd=a;
573 // Import at selection (replacing selection)
574 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
575 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
576 a->setEnabled (false);
577 actionListBranches.append(a);
578 actionEditImportReplace=a;
581 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
582 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
583 a->setEnabled (false);
584 actionListBranches.append(a);
585 actionEditSaveBranch=a;
587 // Only remove branch, not its childs
588 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
589 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
590 a->setEnabled (false);
591 actionListBranches.append(a);
592 actionEditRemoveBranchHere=a;
594 // Only remove childs of a branch
595 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
596 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
597 a->setEnabled (false);
598 actionListBranches.append(a);
599 actionEditRemoveChilds=a;
601 // Shortcuts for navigating with cursor:
602 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
603 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
604 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
605 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
606 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
607 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
608 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
609 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
610 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
611 a->setEnabled (false);
613 actionListBranches.append(a);
614 actionEditSelectFirst=a;
615 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
616 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
617 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
618 a->setEnabled (false);
620 actionListBranches.append(a);
621 actionEditSelectLast=a;
623 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
624 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
625 actionEditLoadImage=a;
630 void Main::setupFormatActions()
632 QPopupMenu *menu = new QPopupMenu( this );
633 menuBar()->insertItem( tr( "&Format" ), menu );
635 QToolBar *tb = new QToolBar( this );
639 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
640 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
641 actionFormatColor->addTo( tb );
642 actionFormatColor->addTo( menu );
643 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" );
644 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
645 a->setEnabled (false);
648 actionListBranches.append(a);
649 actionFormatPickColor=a;
650 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
651 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
652 a->setEnabled (false);
655 actionListBranches.append(a);
656 actionFormatColorBranch=a;
657 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
658 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
659 a->setEnabled (false);
662 actionListBranches.append(a);
663 actionFormatColorSubtree=a;
665 menu->insertSeparator();
666 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
667 actionGroupFormatLinkStyles->setExclusive (true);
668 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
669 a->setToggleAction(true);
670 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
671 actionFormatLinkStyleLine=a;
672 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
673 a->setToggleAction(true);
674 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
675 actionFormatLinkStyleParabel=a;
676 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
677 a->setToggleAction(true);
678 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
679 actionFormatLinkStylePolyLine=a;
680 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
681 a->setToggleAction(true);
682 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
683 actionFormatLinkStylePolyParabel=a;
684 actionGroupFormatLinkStyles->addTo (menu);
686 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
687 actionGroupFormatFrameTypes->setExclusive (true);
688 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
689 a->setToggleAction(true);
690 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
691 actionFormatFrameNone=a;
692 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
693 a->setToggleAction(true);
694 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
695 actionFormatFrameRectangle=a;
697 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
698 a->setToggleAction(true);
699 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
700 actionFormatHideLinkUnselected=a;
702 menu->insertSeparator();
703 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
704 a->setToggleAction(true);
705 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
707 actionFormatLinkColorHint=a;
709 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
710 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
711 actionFormatLinkColor->addTo( menu );
712 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
713 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
714 actionFormatBackColor->addTo( menu );
718 void Main::setupViewActions()
720 QToolBar *tb = new QToolBar( this );
721 tb->setLabel( "View Actions" );
722 QPopupMenu *menu = new QPopupMenu( this );
723 menuBar()->insertItem( tr( "&View" ), menu );
726 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
727 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
730 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
731 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
734 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
735 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
738 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
739 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
740 a->setToggleAction(true);
741 if (textEditor->showWithMain())
747 actionViewToggleNoteEditor=a;
748 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
749 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
751 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
752 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
757 void Main::setupModeActions()
759 //QPopupMenu *menu = new QPopupMenu( this );
760 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
762 QToolBar *tb = new QToolBar( this );
763 tb->setLabel( tr ("Modes when using modifiers") );
765 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
766 actionGroupModModes->setExclusive (true);
767 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
768 a->setToggleAction(true);
771 actionModModeColor=a;
773 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
774 a->setToggleAction(true);
778 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
779 a->setToggleAction(true);
785 void Main::setupFlagActions()
787 standardFlagsDefault->makeToolbar(this, "Standard Flags");
791 void Main::setupSettingsActions()
793 QPopupMenu *menu = new QPopupMenu( this );
794 menuBar()->insertItem( tr( "&Settings" ), menu );
799 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
800 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
803 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
804 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
807 menu->insertSeparator();
808 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
809 a->setToggleAction(true);
810 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
812 actionSettingsAutoedit=a;
814 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
815 a->setToggleAction(true);
816 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
818 actionSettingsAutoselectHeading=a;
820 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
821 a->setToggleAction(true);
822 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
824 actionSettingsAutoselectText=a;
826 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
827 a->setToggleAction(true);
828 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
830 actionSettingsPasteNewHeading=a;
832 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
833 a->setToggleAction(true);
834 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
836 actionSettingsUseDelKey=a;
838 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
839 a->setToggleAction(true);
840 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
842 actionSettingsUseFlagGroups=a;
846 void Main::setupTestActions()
848 QPopupMenu *menu = new QPopupMenu( this );
849 menuBar()->insertItem( tr( "&Test" ), menu );
852 a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
853 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
856 a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
857 connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
862 void Main::setupHelpActions()
864 QPopupMenu *menu = new QPopupMenu( this );
865 menuBar()->insertItem( tr( "&Help" ), menu );
868 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
869 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
872 a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
873 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
876 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
877 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
882 void Main::setupContextMenus()
886 // Context Menu for branch or mapcenter
887 branchContextMenu =new QPopupMenu (this);
890 branchAddContextMenu =new QPopupMenu (this);
891 actionEditPaste->addTo ( branchAddContextMenu );
892 actionEditAddBranch->addTo ( branchAddContextMenu );
893 actionEditAddBranchHere->addTo ( branchAddContextMenu );
894 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
895 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
896 branchAddContextMenu->insertSeparator();
897 actionEditLoadImage->addTo( branchAddContextMenu );
898 branchAddContextMenu->insertSeparator();
899 actionEditImportAdd->addTo ( branchAddContextMenu );
900 actionEditImportReplace->addTo ( branchAddContextMenu );
903 branchRemoveContextMenu =new QPopupMenu (this);
904 actionEditCut->addTo ( branchRemoveContextMenu );
905 actionEditDelete->addTo ( branchRemoveContextMenu );
906 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
907 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
909 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
910 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
912 actionEditSaveBranch->addTo( branchContextMenu );
914 branchContextMenu->insertSeparator();
915 actionEditOpenURL->addTo ( branchContextMenu );
916 actionEditURL->addTo ( branchContextMenu );
917 actionEditHeading2URL->addTo ( branchContextMenu );
918 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
919 actionEditBugzilla2URL->addTo( branchContextMenu );
921 branchContextMenu->insertSeparator();
922 actionEditOpenVymLink->addTo ( branchContextMenu );
923 actionEditVymLink->addTo ( branchContextMenu );
924 actionEditDeleteVymLink->addTo ( branchContextMenu );
926 branchContextMenu->insertSeparator();
927 actionGroupFormatFrameTypes->addTo( branchContextMenu );
929 branchContextMenu->insertSeparator();
930 actionFormatHideLinkUnselected->addTo( branchContextMenu );
932 // Context Menu for links in a branch menu
933 // This will be populated "on demand" in MapEditor::updateActions
934 branchContextMenu->insertSeparator();
935 branchLinksContextMenu =new QPopupMenu (this);
936 branchLinksContextMenuDup =new QPopupMenu (this);
937 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
938 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
940 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
941 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
943 // Context menu for floatimage
944 floatimageContextMenu =new QPopupMenu (this);
945 saveImageFormatMenu=new QPopupMenu (this);
946 exportImageFormatMenu=new QPopupMenu (this);
948 QStrList fmt = QImage::outputFormats();
949 for (const char* f = fmt.first(); f; f = fmt.next())
951 saveImageFormatMenu->insertItem( f );
952 exportImageFormatMenu->insertItem( f );
954 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
955 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
956 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
958 floatimageContextMenu->insertSeparator();
959 actionEditCopy->addTo( floatimageContextMenu );
960 actionEditCut->addTo( floatimageContextMenu );
962 floatimageContextMenu->insertSeparator();
963 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
964 a->setToggleAction(true);
965 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
966 a->addTo( floatimageContextMenu);
967 actionEditToggleFloatExport=a;
969 floatimageContextMenu->insertSeparator();
970 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
972 // Context menu for exports
973 exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
975 a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" +QString("...")), 0, this, "exportASCII" );
976 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
977 a->addTo( exportMenu );
979 a = new QAction( tr( "Export as LaTeX (still experimental)" ), QPixmap(), tr( "Export (LaTeX)" +QString("...")), 0, this, "exportLaTeX" );
980 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
981 a->addTo( exportMenu );
983 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
985 a = new QAction( tr( "Export as Open Office 1.3.x Presentation (still experimental)" ), QPixmap(), tr( "Export (OO Presentation)" +QString("...")), 0, this, "exportOOPresentation" );
986 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
987 a->addTo( exportMenu );
990 a = new QAction( tr( "Export (XML)" ), QPixmap(), tr( "Export (XML)" )+QString("..."), 0, this, "exportXML" );
991 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
992 a->addTo( exportMenu );
994 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
996 a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export (HTML)" )+QString("..."), 0, this, "exportHTML");
997 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
998 a->addTo( exportMenu );
1001 a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" )+QString("..."), ALT + Key_X, this, "exportXHTML" );
1002 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1003 a->addTo( exportMenu );
1006 // Context menu for canvas
1007 canvasContextMenu =new QPopupMenu (this);
1008 actionEditMapInfo->addTo( canvasContextMenu );
1009 canvasContextMenu->insertSeparator();
1010 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1011 canvasContextMenu->insertSeparator();
1012 actionFormatLinkColorHint->addTo( canvasContextMenu );
1013 actionFormatLinkColor->addTo( canvasContextMenu );
1014 actionFormatBackColor->addTo( canvasContextMenu );
1016 // Menu for last opened files
1017 // Read settings initially
1019 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1020 for (int i=1;i<=j;i++)
1022 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1023 if (!s.isEmpty() && j<=maxLastMaps)
1026 setupLastMapsMenu();
1027 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1030 void Main::setupLastMapsMenu()
1032 // Remove double entries
1033 QStringList::Iterator it=lastMaps.begin();
1034 QStringList::Iterator jt;
1035 while (it!=lastMaps.end() )
1039 while (jt!=lastMaps.end() )
1042 jt=lastMaps.remove(jt);
1049 // Limit length of list to maxLastMaps
1050 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1052 // build Menu from lastMaps string list
1053 lastMapsMenu->clear();
1054 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1055 lastMapsMenu->insertItem (*it );
1059 void Main::hideEvent (QHideEvent * )
1061 if (!textEditor->isMinimized() ) textEditor->hide();
1064 void Main::showEvent (QShowEvent * )
1066 if (textEditor->showWithMain()) textEditor->showNormal();
1069 bool Main::reallyWriteDirectory(const QString &dir)
1071 QStringList eList = QDir(dir).entryList();
1072 if (eList.first() ==".") eList.pop_front(); // remove "."
1073 if (eList.first() =="..") eList.pop_front(); // remove "."
1074 if (!eList.isEmpty())
1076 QMessageBox mb( "VYM",
1077 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1078 QMessageBox::Warning,
1080 QMessageBox::Cancel | QMessageBox::Default,
1081 QMessageBox::QMessageBox::NoButton );
1083 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1084 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1087 case QMessageBox::Yes:
1090 case QMessageBox::Cancel:
1098 QString Main::browseDirectory (const QString &caption)
1100 QFileDialog fd(this,caption);
1101 fd.setMode (QFileDialog::DirectoryOnly);
1102 fd.setCaption("VYM - "+caption);
1105 if ( fd.exec() == QDialog::Accepted )
1106 return fd.selectedFile();
1111 MapEditor* Main::currentMapEditor() const
1113 if ( tabWidget->currentPage() &&
1114 tabWidget->currentPage()->inherits( "MapEditor" ) )
1115 return (MapEditor*)tabWidget->currentPage();
1119 //TODO not used now, maybe use this for overview window later
1120 void Main::newView()
1122 // Open a new view... have it delete when closed.
1123 Main *m = new Main(0, 0, WDestructiveClose);
1124 qApp->setMainWidget(m);
1126 qApp->setMainWidget(0);
1129 void Main::editorChanged(QWidget *)
1131 // Unselect all possibly selected objects
1132 // (Important to update note editor)
1135 for (i=0;i<=tabWidget->count() -1;i++)
1138 me=(MapEditor*)tabWidget->page(i);
1141 currentMapEditor()->reselect();
1143 // Update actions to in menus and toolbars according to editor
1144 currentMapEditor()->updateActions();
1147 void Main::fileNew()
1149 QString fn="unnamed";
1150 MapEditor* medit = new MapEditor (tabWidget, true);
1151 tabWidget->addTab (medit,fn);
1152 tabWidget->showPage(medit);
1153 medit->viewport()->setFocus();
1154 medit->select("mc:");
1157 void Main::fileLoad(QString fn, const LoadMode &lmode)
1160 enum errorCode {success,aborted};
1161 errorCode err=success;
1163 // fn is usually the archive, mapfile the file after uncompressing
1166 // Make fn absolute (needed for unzip)
1167 fn=QDir (fn).absPath();
1173 // Check, if map is already loaded
1175 while (i<=tabWidget->count() -1)
1177 me=(MapEditor*)tabWidget->page(i);
1178 if (me->getFilePath() == fn)
1180 // Already there, ask for confirmation
1181 QMessageBox mb( "VYM",
1182 tr("The map %1\nis already opened."
1183 "Opening the same map in multiple editors may lead \n"
1184 "to confusion when finishing working with vym."
1185 "Do you want to").arg(fn),
1186 QMessageBox::Warning,
1187 QMessageBox::Yes | QMessageBox::Default,
1188 QMessageBox::Cancel | QMessageBox::Escape,
1189 QMessageBox::QMessageBox::NoButton);
1190 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1191 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1194 case QMessageBox::Yes:
1196 i=tabWidget->count();
1198 case QMessageBox::Cancel:
1210 if ( !fn.isEmpty() )
1212 me = currentMapEditor();
1213 int tabIndex=tabWidget->currentPageIndex();
1214 // Check first, if mapeditor exists
1215 // If it is not default AND we want a new map,
1216 // create a new mapeditor in a new tab
1217 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1219 me = new MapEditor (tabWidget,true);
1220 tabWidget->addTab (me,fn);
1221 tabIndex=tabWidget->indexOf (me);
1222 tabWidget->setCurrentPage (tabIndex);
1225 // Check, if file exists (important for creating new files
1226 // from command line
1227 if (!QFile(fn).exists() )
1229 QMessageBox mb( "VYM",
1230 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1231 QMessageBox::Question,
1233 QMessageBox::Cancel | QMessageBox::Default,
1234 QMessageBox::QMessageBox::NoButton );
1236 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1237 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1240 case QMessageBox::Yes:
1242 currentMapEditor()->setFilePath(fn);
1243 tabWidget->setTabLabel (currentMapEditor(),
1244 currentMapEditor()->getFileName() );
1245 statusBar()->message( "Created " + fn , statusbarTime );
1248 case QMessageBox::Cancel:
1249 // don't create new map
1250 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1257 //tabWidget->currentPage() won't be NULL here, because of above...
1258 tabWidget->showPage(me);
1259 me->viewport()->setFocus();
1261 // Create temporary directory for packing
1262 char tmpdir1[]="/tmp/vym-XXXXXX";
1263 QString tmpMapDir=mkdtemp(tmpdir1);
1265 // Try to unzip file
1266 Process *zipProc=new Process ();
1267 zipProc->clearArguments();
1268 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1269 zipProc->addArgument ("unzip");
1270 zipProc->addArgument (fn );
1271 zipProc->addArgument ("-d");
1272 zipProc->addArgument (tmpMapDir);
1274 if (!zipProc->start() )
1276 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1277 tr("Couldn't start unzip to decompress data."));
1282 zipProc->waitFinished();
1283 if (!zipProc->normalExit() )
1285 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1286 tr("unzip didn't exit normally") +
1287 zipProc->getErrout() );
1291 if (zipProc->exitStatus()>0)
1293 if (zipProc->exitStatus()==9)
1295 // no zipped file, but maybe .xml or old version? Try again.
1297 me->setZipped(false);
1301 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1302 QString("unzip exit code: %1").arg(zipProc->exitStatus() ) +
1303 zipProc->getErrout() );
1307 { // Uncompressing was successfull,
1308 // load from uncompressed temporary directory
1310 me->setZipped(true);
1313 // Look for mapname.xml
1314 mapfile= fn.left(fn.findRev(".",-1,true));
1315 mapfile=mapfile.section( '/', -1 );
1316 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1317 if (!file.exists() )
1319 // mapname.xml does not exist, well,
1320 // maybe some renamed the mapname.vym file...
1321 // Try to find any .xml in the toplevel
1322 // directory of the .vym file
1323 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1324 if (flist.count()==1)
1326 // Only one entry, take this one
1327 mapfile=tmpMapDir + "/"+flist.first();
1330 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1331 *it=tmpMapDir + "/" + *it;
1332 // FIXME Multiple entries, load all (but only the first one into this ME)
1333 //mainWindow->fileLoadFromTmp (flist);
1334 //returnCode=1; // Silently forget this attempt to load
1335 qWarning ("MainWindow::load (fn) multimap found...");
1338 if (flist.isEmpty() )
1340 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1341 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1344 } //file doesn't exist
1346 mapfile=file.name();
1347 } // Uncompressing successfull
1352 // Save existing filename
1353 QString fn_org=me->getFilePath();
1355 // Finally load map into mapEditor
1356 me->setFilePath (mapfile,fn);
1357 if (me->load(mapfile,lmode))
1360 // Restore old (maybe empty) filepath, if this is an import
1362 me->setFilePath (fn_org);
1365 system ( "rm -rf "+tmpMapDir);
1372 me->setFilePath (fn);
1373 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1374 lastMaps.prepend(me->getFilePath() );
1375 setupLastMapsMenu();
1376 actionFilePrint->setEnabled (true);
1378 statusBar()->message( "Loaded " + fn, statusbarTime );
1388 statusBar()->message( "Could not load " + fn, statusbarTime );
1392 void Main::fileLoad(const LoadMode &lmode)
1394 QFileDialog *fd=new QFileDialog( this);
1395 if (!lastFileDir.isEmpty())
1396 fd->setDir (lastFileDir);
1397 fd->addFilter ("XML (*.xml)");
1398 fd->addFilter ("VYM map (*.vym *.vyp)");
1402 fd->setCaption(tr("Load vym map"));
1405 fd->setCaption(tr("Import: Add vym map to selection"));
1408 fd->setCaption(tr("Import: Replace selection with vym map"));
1414 if ( fd->exec() == QDialog::Accepted )
1416 lastFileDir=fd->dirPath();
1417 fn = fd->selectedFile();
1418 fileLoad(fn, lmode);
1422 void Main::fileLoad()
1427 void Main::fileLoadLast(int i)
1429 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1432 void Main::fileSave(const SaveMode &savemode)
1434 // tmp dir for zipping
1438 enum errorCode {success,aborted};
1439 errorCode err=success;
1441 QString safeFilePath;
1443 bool saveZipped=currentMapEditor()->saveZipped();
1445 MapEditor * me=currentMapEditor();
1448 QString fn=me->getFilePath();
1449 // filename=unnamed, filepath="" in constructor...
1450 if ( !fn.isEmpty() )
1452 // We have a filepath, go on saving
1453 // First remove existing file, we
1454 // don't want to add to old zip archives
1458 QMessageBox::warning( 0, tr( "Save Error" ),
1459 fn+ tr("\ncould not be removed before saving"));
1461 // Look, if we should zip the data:
1464 QMessageBox mb( "VYM",
1465 tr("The map %1\ndid not use the compressed "
1466 "vym file format.\nWriting it uncompressed will also write images \n"
1467 "and flags and thus may overwrite files in the "
1468 "given directory\n\nDo you want to write the map").arg(fn),
1469 QMessageBox::Warning,
1470 QMessageBox::Yes | QMessageBox::Default,
1472 QMessageBox::Cancel | QMessageBox::Escape);
1473 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1474 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1475 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1478 case QMessageBox::Yes:
1479 // save compressed (default file format)
1482 case QMessageBox::No:
1483 // save uncompressed
1486 case QMessageBox::Cancel:
1495 char tmpdir1[]="/tmp/vym-XXXXXX";
1496 tmpMapDir=mkdtemp(tmpdir1);
1498 safeFilePath=me->getFilePath();
1499 me->setFilePath (tmpMapDir+"/"+
1500 me->getMapName()+ ".xml",
1502 me->save (savemode);
1503 me->setFilePath (safeFilePath);
1505 // zip the temporary directory
1506 Process *zipProc=new Process ();
1507 zipProc->clearArguments();
1508 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1509 zipProc->addArgument ("zip");
1510 zipProc->addArgument ("-r");
1511 zipProc->addArgument (fn);
1512 zipProc->addArgument (".");
1514 if (!zipProc->start() )
1516 // zip could not be started
1517 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1518 tr("Couldn't start zip to compress data."));
1522 // zip could be started
1523 zipProc->waitFinished();
1524 if (!zipProc->normalExit() )
1526 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1527 tr("zip didn't exit normally")+
1528 "\n" + zipProc->getErrout());
1532 if (zipProc->exitStatus()>0)
1534 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1535 QString("zip exit code: %1").arg(zipProc->exitStatus() )+
1536 "\n" + zipProc->getErrout() );
1540 } // zip could be started
1545 safeFilePath=me->getFilePath();
1546 me->setFilePath (fn, safeFilePath);
1547 me->save (savemode);
1548 me->setFilePath (safeFilePath);
1550 } // filepath available
1553 // We have no filepath yet,
1554 // call fileSaveAs() now, this will call fileSave()
1556 fileSaveAs(savemode);
1560 if (me->saveZipped())
1563 system ( "rm -rf "+ tmpMapDir );
1568 statusBar()->message(
1569 tr("Saved %1").arg(me->getFilePath()),
1571 lastMaps.prepend(me->getFilePath() );
1572 setupLastMapsMenu();
1574 statusBar()->message(
1575 tr("Couldn't save ").arg(me->getFilePath()),
1579 void Main::fileSave()
1581 fileSave (CompleteMap);
1584 void Main::fileSaveAs(const SaveMode& savemode)
1589 if (currentMapEditor())
1591 if (savemode==CompleteMap)
1592 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1594 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1595 if ( !fn.isEmpty() )
1597 // Check for existing file
1598 if (QFile (fn).exists())
1600 QMessageBox mb( "VYM",
1601 tr("The file %1\nexists already. Do you want to").arg(fn),
1602 QMessageBox::Warning,
1603 QMessageBox::Yes | QMessageBox::Default,
1604 QMessageBox::Cancel | QMessageBox::Escape,
1605 QMessageBox::QMessageBox::NoButton);
1606 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1607 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1610 case QMessageBox::Yes:
1613 case QMessageBox::Cancel:
1620 // New file, add extension to filename, if missing
1621 // This is always .vym or .vyp, depending on savemode
1622 if (savemode==CompleteMap)
1624 if (!fn.contains (".vym") && !fn.contains (".xml"))
1628 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1637 currentMapEditor()->setFilePath(fn);
1641 if (savemode==CompleteMap)
1642 tabWidget->setTabLabel (currentMapEditor(),
1643 currentMapEditor()->getFileName() );
1649 void Main::fileSaveAs()
1651 fileSaveAs (CompleteMap);
1654 void Main::fileImportDir()
1656 if (currentMapEditor())
1657 currentMapEditor()->importDir();
1660 void Main::fileExportXML()
1662 if (currentMapEditor())
1664 QString dir=browseDirectory(tr("Export XML to directory"));
1665 if (dir !="" && reallyWriteDirectory(dir) )
1666 currentMapEditor()->exportXML(dir);
1670 void Main::fileExportHTML()
1672 if (currentMapEditor())
1674 ExportHTMLDialog dia(this);
1676 if (dia.exec()==QDialog::Accepted)
1678 QString dir=dia.getDir();
1679 if (reallyWriteDirectory(dir) )
1681 currentMapEditor()->exportXML (dia.getDir() );
1682 dia.doExport(currentMapEditor()->getMapName() );
1688 void Main::fileExportXHTML()
1691 if (currentMapEditor())
1693 ExportXHTMLDialog dia(this);
1694 dia.setFilePath (currentMapEditor()->getFilePath() );
1695 dia.setMapName (currentMapEditor()->getMapName() );
1698 if (dia.exec()==QDialog::Accepted)
1700 QString dir=dia.getDir();
1701 // Check, if warnings should be used before overwriting
1702 // the output directory
1705 ok=reallyWriteDirectory(dir);
1711 currentMapEditor()->exportXML (dia.getDir() );
1712 dia.doExport(currentMapEditor()->getMapName() );
1713 if (dia.hasChanged())
1714 currentMapEditor()->setChanged();
1720 void Main::fileExportImage(int item)
1722 if (currentMapEditor())
1724 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1726 if ( !fn.isEmpty() )
1728 currentMapEditor()->exportImage(fn,item);
1730 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1735 void Main::fileExportASCII()
1737 if (currentMapEditor())
1738 currentMapEditor()->exportASCII();
1741 void Main::fileExportLaTeX()
1743 if (currentMapEditor())
1744 currentMapEditor()->exportLaTeX();
1747 void Main::fileExportOOPresentation()
1749 if (currentMapEditor())
1750 currentMapEditor()->exportOOPresentation();
1753 void Main::fileCloseMap()
1755 if (currentMapEditor())
1757 if (currentMapEditor()->hasChanged())
1759 QMessageBox mb( "VYM",
1760 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1761 QMessageBox::Warning,
1762 QMessageBox::Yes | QMessageBox::Default,
1764 QMessageBox::Cancel | QMessageBox::Escape );
1765 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1766 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1769 case QMessageBox::Yes:
1771 fileSave(CompleteMap);
1773 case QMessageBox::No:
1774 // close without saving
1776 case QMessageBox::Cancel:
1781 currentMapEditor()->closeMap();
1782 tabWidget->removePage(currentMapEditor());
1783 if (tabWidget->count()==0)
1784 actionFilePrint->setEnabled (false);
1788 void Main::filePrint()
1790 if (currentMapEditor())
1791 currentMapEditor()->print();
1794 void Main::fileExitVYM()
1796 // Check if one or more editors have changed
1799 for (i=0;i<=tabWidget->count() -1;i++)
1802 me=(MapEditor*)tabWidget->page(i);
1804 // If something changed, ask what to do
1805 if (me->isUnsaved())
1807 tabWidget->setCurrentPage(i);
1808 QMessageBox mb( "VYM",
1809 tr("This map is not saved yet. Do you want to"),
1810 QMessageBox::Warning,
1811 QMessageBox::Yes | QMessageBox::Default,
1813 QMessageBox::Cancel | QMessageBox::Escape );
1814 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1815 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1817 // Call undocumented function: setActiveWindow is only
1818 // possible, if widget is visible. This depends on
1820 #if defined(Q_OS_LINUX)
1821 qt_wait_for_window_manager( this);
1823 mb.setActiveWindow();
1824 switch( mb.exec() ) {
1825 case QMessageBox::Yes:
1826 // save (the changed editors) and exit
1827 fileSave(CompleteMap);
1829 case QMessageBox::No:
1830 // exit without saving
1832 case QMessageBox::Cancel:
1833 // don't save and don't exit
1837 } // loop over all MEs
1841 void Main::editUndo()
1843 if (currentMapEditor())
1844 currentMapEditor()->undo();
1847 void Main::editRedo()
1849 if (currentMapEditor())
1850 currentMapEditor()->redo();
1853 void Main::editCopy()
1855 if (currentMapEditor())
1856 currentMapEditor()->copy();
1859 void Main::editPaste()
1861 if (currentMapEditor())
1862 currentMapEditor()->paste();
1865 void Main::editCut()
1867 if (currentMapEditor())
1868 currentMapEditor()->cut();
1871 void Main::editOpenFindWindow()
1873 findWindow->popup();
1874 findWindow->raise();
1876 // Call undocumented function: setActiveWindow is only
1877 // possible, if widget is visible. This depends on
1879 #if defined(Q_OS_LINUX)
1880 qt_wait_for_window_manager( this);
1882 findWindow->setActiveWindow();
1885 void Main::editFind(QString s)
1888 BranchObj *bo=currentMapEditor()->findText(s, cs);
1891 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
1894 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
1895 tr("No matches found for <b>%1</b>").arg(s));
1899 void Main::editFindChanged()
1900 { // Notify editor, to abort the current find process
1901 currentMapEditor()->findReset();
1904 void Main::editOpenURL()
1906 if (currentMapEditor())
1907 currentMapEditor()->openURL();
1910 void Main::editURL()
1912 if (currentMapEditor())
1913 currentMapEditor()->editURL();
1916 void Main::editHeading2URL()
1918 if (currentMapEditor())
1919 currentMapEditor()->editHeading2URL();
1922 void Main::editBugzilla2URL()
1924 if (currentMapEditor())
1925 currentMapEditor()->editBugzilla2URL();
1928 void Main::editOpenVymLink()
1930 // Get current path to map
1931 QString currentVymLink;
1932 if (currentMapEditor())
1934 currentVymLink=currentMapEditor()->getVymLink();
1935 // compare path with already loaded maps
1939 for (i=0;i<=tabWidget->count() -1;i++)
1941 me=(MapEditor*)tabWidget->page(i);
1942 if (currentVymLink==me->getFilePath() )
1951 if (!QFile(currentVymLink).exists() )
1952 QMessageBox::critical( 0, tr( "Critical Error" ),
1953 tr("Couldn't open map %1").arg(currentVymLink));
1956 fileLoad (currentVymLink, NewMap);
1957 tabWidget->setCurrentPage (tabWidget->count()-1);
1960 // Go to tab containing the map
1961 tabWidget->setCurrentPage (index);
1965 void Main::editVymLink()
1967 if (currentMapEditor())
1968 currentMapEditor()->editVymLink();
1971 void Main::editDeleteVymLink()
1973 if (currentMapEditor())
1974 currentMapEditor()->deleteVymLink();
1977 void Main::editMapInfo()
1979 if (currentMapEditor())
1980 currentMapEditor()->editMapInfo();
1983 void Main::editMoveUp()
1985 if (currentMapEditor())
1986 currentMapEditor()->moveBranchUp();
1989 void Main::editMoveDown()
1991 if (currentMapEditor())
1992 currentMapEditor()->moveBranchDown();
1995 void Main::editToggleScroll()
1997 if (currentMapEditor())
1999 currentMapEditor()->toggleScroll();
2003 void Main::editUnScrollAll()
2005 if (currentMapEditor())
2007 currentMapEditor()->unScrollAll();
2011 void Main::editHeading()
2013 if (currentMapEditor())
2014 currentMapEditor()->editHeading();
2017 void Main::editNewBranch()
2019 if (currentMapEditor())
2020 currentMapEditor()->addNewBranch(0);
2023 void Main::editNewBranchHere()
2025 if (currentMapEditor())
2026 currentMapEditor()->addNewBranchHere();
2029 void Main::editNewBranchAbove()
2031 if (currentMapEditor())
2032 currentMapEditor()->addNewBranch(-1);
2035 void Main::editNewBranchBelow()
2037 if (currentMapEditor())
2038 currentMapEditor()->addNewBranch(1);
2041 void Main::editImportAdd()
2043 fileLoad (ImportAdd);
2046 void Main::editImportReplace()
2048 fileLoad (ImportReplace);
2051 void Main::editSaveBranch()
2053 fileSaveAs (PartOfMap);
2056 void Main::editRemoveBranchHere()
2058 if (currentMapEditor())
2059 currentMapEditor()->removeBranchHere();
2062 void Main::editRemoveChilds()
2064 if (currentMapEditor())
2065 currentMapEditor()->removeChilds();
2068 void Main::editDeleteSelection()
2070 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2071 currentMapEditor()->deleteSelection();
2074 void Main::editUpperBranch()
2076 if (currentMapEditor())
2077 currentMapEditor()->selectUpperBranch();
2080 void Main::editLowerBranch()
2082 if (currentMapEditor())
2083 currentMapEditor()->selectLowerBranch();
2086 void Main::editLeftBranch()
2088 if (currentMapEditor())
2089 currentMapEditor()->selectLeftBranch();
2092 void Main::editRightBranch()
2094 if (currentMapEditor())
2095 currentMapEditor()->selectRightBranch();
2098 void Main::editFirstBranch()
2100 if (currentMapEditor())
2101 currentMapEditor()->selectFirstBranch();
2104 void Main::editLastBranch()
2106 if (currentMapEditor())
2107 currentMapEditor()->selectLastBranch();
2110 void Main::editLoadImage()
2112 if (currentMapEditor())
2113 currentMapEditor()->loadFloatImage();
2116 void Main::editSaveImage(int item)
2118 if (currentMapEditor())
2119 currentMapEditor()->saveFloatImage(item);
2122 void Main::editToggleFloatExport()
2124 if (currentMapEditor())
2125 currentMapEditor()->toggleFloatExport();
2128 void Main::editFollowXLink(int item)
2130 if (currentMapEditor())
2131 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2134 void Main::editEditXLink(int item)
2136 if (currentMapEditor())
2137 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2140 void Main::formatSelectColor()
2142 if (currentMapEditor())
2144 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2145 if ( !col.isValid() ) return;
2146 currentMapEditor()->setColor( col );
2147 colorChanged( col );
2151 void Main::formatPickColor()
2153 if (currentMapEditor())
2154 colorChanged( currentMapEditor()->pickColor() );
2157 void Main::colorChanged(QColor c)
2159 QPixmap pix( 16, 16 );
2161 actionFormatColor->setIconSet( pix );
2164 void Main::formatColorItem()
2166 if (currentMapEditor())
2167 currentMapEditor()->colorItem();
2170 void Main::formatColorBranch()
2172 if (currentMapEditor())
2173 currentMapEditor()->colorBranch();
2176 void Main::formatLinkStyleLine()
2178 if (currentMapEditor())
2179 currentMapEditor()->setLinkStyle(StyleLine);
2182 void Main::formatLinkStyleParabel()
2184 if (currentMapEditor())
2185 currentMapEditor()->setLinkStyle(StyleParabel);
2188 void Main::formatLinkStylePolyLine()
2190 if (currentMapEditor())
2191 currentMapEditor()->setLinkStyle(StylePolyLine);
2194 void Main::formatLinkStylePolyParabel()
2196 if (currentMapEditor())
2197 currentMapEditor()->setLinkStyle(StylePolyParabel);
2200 void Main::formatSelectBackColor()
2202 if (currentMapEditor())
2203 currentMapEditor()->selectBackgroundColor();
2206 void Main::formatSelectLinkColor()
2208 if (currentMapEditor())
2209 currentMapEditor()->selectLinkColor();
2212 void Main::formatToggleLinkColorHint()
2214 currentMapEditor()->toggleLinkColorHint();
2217 void Main::formatFrameNone()
2219 if (currentMapEditor())
2220 currentMapEditor()->setFrame(NoFrame);
2223 void Main::formatFrameRectangle()
2225 if (currentMapEditor())
2226 currentMapEditor()->setFrame(Rectangle);
2229 void Main::formatHideLinkUnselected()
2231 if (currentMapEditor())
2232 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2235 void Main::viewZoomReset()
2237 if (currentMapEditor())
2241 currentMapEditor()->setWorldMatrix( m );
2242 currentMapEditor()->setViewCenter();
2243 currentMapEditor()->adjustCanvasSize();
2247 void Main::viewZoomIn()
2249 if (currentMapEditor())
2251 QWMatrix m = currentMapEditor()->worldMatrix();
2252 m.scale( 1.25, 1.25 );
2253 currentMapEditor()->setWorldMatrix( m );
2254 currentMapEditor()->setViewCenter();
2255 currentMapEditor()->adjustCanvasSize();
2259 void Main::viewZoomOut()
2261 if (currentMapEditor())
2263 QWMatrix m = currentMapEditor()->worldMatrix();
2264 m.scale( 0.8, 0.8 );
2265 currentMapEditor()->setWorldMatrix( m );
2266 currentMapEditor()->setViewCenter();
2267 currentMapEditor()->adjustCanvasSize();
2271 void Main::modModeColor()
2275 void Main::modModeLink()
2279 bool Main::settingsPDF()
2281 // Default browser is set in constructor
2283 QString text = QInputDialog::getText(
2284 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2285 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2287 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2292 bool Main::settingsURL()
2294 // Default browser is set in constructor
2296 QString text = QInputDialog::getText(
2297 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2298 settings.readEntry("/vym/mainwindow/readerURL")
2301 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2305 void Main::windowToggleNoteEditor()
2307 if (textEditor->showWithMain() )
2308 windowHideNoteEditor();
2310 windowShowNoteEditor();
2313 void Main::updateNoteFlag()
2315 if (currentMapEditor())
2316 currentMapEditor()->updateNoteFlag();
2319 void Main::windowShowNoteEditor()
2321 textEditor->setShowWithMain(true);
2323 actionViewToggleNoteEditor->setOn (true);
2326 void Main::windowHideNoteEditor()
2328 textEditor->setShowWithMain(false);
2330 actionViewToggleNoteEditor->setOn (false);
2333 void Main::windowNextEditor()
2335 if (tabWidget->currentPageIndex() < tabWidget->count())
2336 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2339 void Main::windowPreviousEditor()
2341 if (tabWidget->currentPageIndex() >0)
2342 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2345 void Main::standardFlagChanged()
2347 currentMapEditor()->toggleStandardFlag(sender()->name());
2350 void Main::testFunction()
2352 //textEditor->stackUnder(this);
2353 currentMapEditor()->testFunction();
2356 void Main::testShowClipboard()
2358 clipboardME->show();
2361 void Main::helpDoc()
2364 #if defined(Q_OS_MACX)
2365 docpath="./vym.app/Contents/vym.pdf";
2367 // default path in SUSE LINUX
2368 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2371 if (!QFile (docpath).exists() )
2373 // relative path for easy testing in tarball
2374 docpath="doc/vym.pdf";
2375 if (!QFile (docpath).exists() )
2377 // relative path for testing while still writing vym.tex
2378 docpath="doc/tex/vym.pdf";
2379 if (!QFile (docpath).exists() )
2381 QMessageBox::critical(0,
2382 tr("Critcal error"),
2383 tr("Couldn't find the documentation\n"
2384 "vym.pdf in various places."));
2390 Process *pdfProc = new Process();
2391 pdfProc->clearArguments();
2392 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2393 pdfProc->addArgument( docpath);
2395 if ( !pdfProc->start() )
2398 QMessageBox::critical(0,
2399 tr("Critcal error"),
2400 tr("Couldn't find a viewer to read vym.pdf.\n"
2401 "Please use Settings->")+tr("Set application to open pdf files"));
2407 void Main::helpAbout()
2410 ad.setName ("aboutwindow");
2411 ad.setMinimumSize(500,500);
2412 ad.resize (QSize (500,500));
2416 void Main::helpAboutQT()
2418 QMessageBox::aboutQt( this, "Qt Application Example" );