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 QString tmpVymDir;
64 extern int statusbarTime;
65 extern MapEditor *clipboardME;
66 extern FlagRowObj* standardFlagsDefault;
68 extern QPtrList <QAction> actionListBranches;
70 extern QAction* actionFileSave;
71 extern QAction* actionFilePrint;
72 extern QAction* actionEditUndo;
73 extern QAction* actionEditRedo;
74 extern QAction *actionEditCopy;
75 extern QAction *actionEditCut;
76 extern QAction *actionEditPaste;
77 extern QAction *actionEditMoveUp;
78 extern QAction *actionEditMoveDown;
79 extern QAction *actionEditToggleScroll;
80 extern QAction* actionEditOpenURL;
81 extern QAction* actionEditURL;
82 extern QAction* actionEditHeading2URL;
83 extern QAction* actionEditBugzilla2URL;
84 extern QAction *actionEditOpenVymLink;
85 extern QAction *actionEditVymLink;
86 extern QAction *actionEditDeleteVymLink;
87 extern QAction *actionEditMapInfo;
88 extern QAction *actionEditHeading;
89 extern QAction *actionEditDelete;
90 extern QAction *actionEditAddBranch;
91 extern QAction *actionEditAddBranchHere;
92 extern QAction *actionEditAddBranchAbove;
93 extern QAction *actionEditAddBranchBelow;
94 extern QAction *actionEditRemoveBranchHere;
95 extern QAction *actionEditRemoveChilds;
96 extern QAction *actionEditImportAdd;
97 extern QAction *actionEditImportReplace;
98 extern QAction *actionEditSaveBranch;
99 extern QAction *actionEditSelectFirst;
100 extern QAction *actionEditSelectLast;
101 extern QAction *actionEditLoadImage;
102 extern QAction *actionEditToggleFloatExport;
104 extern QAction* actionFormatColor;
105 extern QAction* actionFormatPickColor;
106 extern QAction* actionFormatColorBranch;
107 extern QAction* actionFormatColorSubtree;
108 extern QAction* actionFormatLinkColorHint;
109 extern QAction* actionFormatBackColor;
110 extern QAction* actionFormatLinkColor;
112 extern QActionGroup* actionGroupModModes;
113 extern QAction* actionModModeColor;
114 extern QAction* actionModModeLink;
115 extern QAction* actionModModeCopy;
117 extern QActionGroup *actionGroupFormatFrameTypes;
118 extern QAction *actionFormatFrameNone;
119 extern QAction *actionFormatFrameRectangle;
121 extern QActionGroup *actionGroupFormatLinkStyles;
122 extern QAction *actionFormatLinkStyleLine;
123 extern QAction *actionFormatLinkStyleParabel;
124 extern QAction *actionFormatLinkStylePolyLine;
125 extern QAction *actionFormatLinkStylePolyParabel;
126 extern QAction *actionFormatHideLinkUnselected;
128 extern QAction *actionViewToggleNoteEditor;
130 extern QAction* actionSettingsAutoedit;
131 extern QAction* actionSettingsAutoselectHeading;
132 extern QAction* actionSettingsAutoselectHeading;
133 extern QAction* actionSettingsAutoselectText;
134 extern QAction* actionSettingsPasteNewHeading;
135 extern QAction* actionSettingsUseDelKey;
136 extern QAction* actionSettingsUseFlagGroups;
138 extern QPopupMenu* branchContextMenu;
139 extern QPopupMenu* branchAddContextMenu;
140 extern QPopupMenu* branchRemoveContextMenu;
141 extern QPopupMenu* branchLinksContextMenu;
142 extern QPopupMenu* branchLinksContextMenuDup;
143 extern QPopupMenu* floatimageContextMenu;
144 extern QPopupMenu* saveImageFormatMenu;
145 extern QPopupMenu* canvasContextMenu;
146 extern QPopupMenu* lastMapsMenu;
147 extern QPopupMenu* exportMenu;
148 extern QPopupMenu* exportImageFormatMenu;
151 extern Settings settings;
152 extern Options options;
154 #if defined(Q_OS_LINUX)
155 extern void qt_wait_for_window_manager( QWidget* w );
158 Main::Main(QWidget* parent, const char* name, WFlags f) :
159 QMainWindow(parent,name,f)
163 setCaption ("VYM - View Your Mind");
165 // Load window settings
166 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
167 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
168 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
169 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
172 // Create unique temporary directory
173 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
175 // TODO Create direcctory for clipboard
177 // Set random seed (random used for object IDs)
178 QTime t = QTime::currentTime(); // set random seed
179 srand( t.hour()*12+t.minute()*60+t.second()*60 );
182 // Initialize some settings, which are platform dependant
185 // application to open URLs
186 p="/vym/mainwindow/readerURL";
187 #if defined(Q_OS_LINUX)
188 s=settings.readEntry (p,"konqueror");
190 #if defined(Q_OS_MACX)
191 s=settings.readEntry (p,"/usr/bin/open");
193 s=settings.readEntry (p,"mozilla");
196 settings.writeEntry( p,s);
198 // application to open PDFs
199 p="/vym/mainwindow/readerPDF";
200 #if defined(Q_OS_LINUX)
201 s=settings.readEntry (p,"acroread");
203 #if defined(Q_OS_MACX)
204 s=settings.readEntry (p,"/usr/bin/open");
206 s=settings.readEntry (p,"acroread");
209 settings.writeEntry( p,s);
214 // Create tab widget which holds the maps
215 tabWidget= new QTabWidget (this);
216 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
217 this, SLOT( editorChanged( QWidget * ) ) );
219 setCentralWidget(tabWidget);
223 setupFormatActions();
227 setupSettingsActions();
229 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
232 // After menu is created, we can enable some actions
233 actionFilePrint->setEnabled (true);
238 // Initialize Find window
239 findWindow=new FindWindow(NULL,"findwindow");
240 connect (findWindow, SIGNAL( findButton(QString) ),
241 this, SLOT(editFind(QString) ) );
242 connect (findWindow, SIGNAL( somethingChanged() ),
243 this, SLOT(editFindChanged() ) );
245 // Connect TextEditor, so that we can update flags if text changes
246 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
250 // Creating the default map into first tab is done in main.cpp now...
256 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
257 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
258 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
259 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
261 settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
262 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
264 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
265 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
266 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
267 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
268 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
269 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
272 int maps=lastMaps.count();
273 settings.writeEntry( "/vym/lastMaps/number",maps );
274 for (int i=1;i<=maps;i++)
276 QStringList::Iterator it = lastMaps.at(i-1);
277 s=QString("/vym/lastMaps/map-%1").arg(i);
278 if (!s.isEmpty() && i<=maxLastMaps)
279 settings.writeEntry (s, *it);
283 // To make the texteditor save its settings, call the destructor
286 // Remove temporary directory
287 removeDir (QDir(tmpVymDir));
290 void Main::loadCmdLine()
292 /* TODO draw some kind of splashscreen while loading...
298 QStringList flist=options.getFileList();
299 QStringList::Iterator it=flist.begin();
301 while (it !=flist.end() )
303 fileLoad (*it, NewMap);
309 void Main::statusMessage(const QString &s)
311 statusBar()->message (s);
314 void Main::closeEvent (QCloseEvent* )
320 void Main::setupFileActions()
322 QToolBar *tb = new QToolBar( this );
323 tb->setLabel( "File Actions" );
324 QPopupMenu *menu = new QPopupMenu( this );
325 menuBar()->insertItem( tr( "&File" ), menu );
327 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
330 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
331 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
335 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
336 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
340 lastMapsMenu = new QPopupMenu (this);
342 menu->insertItem (tr("Open Recent"),lastMapsMenu );
343 menu->insertSeparator();
345 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
346 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
351 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
352 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
355 menu->insertSeparator();
357 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
358 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
361 exportMenu = new QPopupMenu (this);
362 menu->insertItem (tr("Export"),exportMenu );
364 menu->insertSeparator();
367 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
368 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
373 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
374 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
377 a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
378 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
384 void Main::setupEditActions()
386 QToolBar *tb = new QToolBar( this );
387 tb->setLabel( "Edit Actions" );
388 QPopupMenu *menu = new QPopupMenu( this );
389 menuBar()->insertItem( tr( "&Edit" ), menu );
393 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
394 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
395 a->setEnabled (false);
400 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
402 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
403 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
408 menu->insertSeparator();
409 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
410 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
411 a->setEnabled (false);
415 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
416 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
417 a->setEnabled (false);
421 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
422 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
423 a->setEnabled (false);
428 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
429 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
430 a->setEnabled (false);
433 actionListBranches.append(a);
436 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
437 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
438 a->setEnabled (false);
441 actionListBranches.append(a);
442 actionEditMoveDown=a;
445 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
446 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
447 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
448 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
449 #if defined(Q_OS_MACX)
450 actionEditToggleScroll=alt;
452 actionEditToggleScroll=a;
454 actionEditToggleScroll->setEnabled (false);
455 actionEditToggleScroll->addTo( tb );
456 actionEditToggleScroll->addTo( menu );
457 actionListBranches.append(actionEditToggleScroll);
459 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
460 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
463 menu->insertSeparator();
465 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
466 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
469 menu->insertSeparator();
471 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
472 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
474 a->setEnabled (false);
477 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
478 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
479 a->setEnabled (false);
480 actionListBranches.append(a);
483 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
484 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
485 a->setEnabled (false);
486 actionListBranches.append(a);
487 actionEditHeading2URL=a;
489 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
490 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
491 a->setEnabled (false);
492 actionListBranches.append(a);
493 actionEditBugzilla2URL=a;
496 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" );
497 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
499 a->setEnabled (false);
500 actionEditOpenVymLink=a;
502 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
503 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
504 a->setEnabled (false);
505 actionListBranches.append(a);
508 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
509 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
510 a->setEnabled (false);
511 actionEditDeleteVymLink=a;
513 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info"+QString("...") ), 0, this, "editMapInfo" );
514 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
515 a->setEnabled (true);
518 menu->insertSeparator();
520 // Shortcuts to modify heading:
521 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
522 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
523 actionListBranches.append(a);
524 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
525 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
526 actionListBranches.append(a);
528 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
529 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
530 a->setEnabled (false);
532 actionListBranches.append(a);
534 // Shortcut to delete selection
535 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
536 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
537 a->setEnabled (false);
540 // Shortcut to add branch
541 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
542 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
543 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
544 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
545 a->setEnabled (false);
546 actionListBranches.append(a);
547 #if defined (Q_OS_MACX)
548 actionEditAddBranch=alt;
550 actionEditAddBranch=a;
553 // Add branch by inserting it at selection
554 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
555 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
556 a->setEnabled (false);
557 actionListBranches.append(a);
558 actionEditAddBranchHere=a;
561 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
562 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
563 a->setEnabled (false);
564 actionListBranches.append(a);
565 actionEditAddBranchAbove=a;
568 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
569 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
570 a->setEnabled (false);
571 actionListBranches.append(a);
572 actionEditAddBranchBelow=a;
574 // Import at selection (adding to selection)
575 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
576 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
577 a->setEnabled (false);
578 actionListBranches.append(a);
579 actionEditImportAdd=a;
581 // Import at selection (replacing selection)
582 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
583 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
584 a->setEnabled (false);
585 actionListBranches.append(a);
586 actionEditImportReplace=a;
589 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
590 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
591 a->setEnabled (false);
592 actionListBranches.append(a);
593 actionEditSaveBranch=a;
595 // Only remove branch, not its childs
596 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
597 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
598 a->setEnabled (false);
599 actionListBranches.append(a);
600 actionEditRemoveBranchHere=a;
602 // Only remove childs of a branch
603 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
604 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
605 a->setEnabled (false);
606 actionListBranches.append(a);
607 actionEditRemoveChilds=a;
609 // Shortcuts for navigating with cursor:
610 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
611 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
612 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
613 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
614 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
615 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
616 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
617 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
618 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
619 a->setEnabled (false);
621 actionListBranches.append(a);
622 actionEditSelectFirst=a;
623 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
624 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
625 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
626 a->setEnabled (false);
628 actionListBranches.append(a);
629 actionEditSelectLast=a;
631 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
632 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
633 actionEditLoadImage=a;
638 void Main::setupFormatActions()
640 QPopupMenu *menu = new QPopupMenu( this );
641 menuBar()->insertItem( tr( "&Format" ), menu );
643 QToolBar *tb = new QToolBar( this );
647 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
648 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
649 actionFormatColor->addTo( tb );
650 actionFormatColor->addTo( menu );
651 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" );
652 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
653 a->setEnabled (false);
656 actionListBranches.append(a);
657 actionFormatPickColor=a;
658 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
659 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
660 a->setEnabled (false);
663 actionListBranches.append(a);
664 actionFormatColorBranch=a;
665 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
666 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
667 a->setEnabled (false);
670 actionListBranches.append(a);
671 actionFormatColorSubtree=a;
673 menu->insertSeparator();
674 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
675 actionGroupFormatLinkStyles->setExclusive (true);
676 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
677 a->setToggleAction(true);
678 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
679 actionFormatLinkStyleLine=a;
680 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
681 a->setToggleAction(true);
682 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
683 actionFormatLinkStyleParabel=a;
684 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
685 a->setToggleAction(true);
686 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
687 actionFormatLinkStylePolyLine=a;
688 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
689 a->setToggleAction(true);
690 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
691 actionFormatLinkStylePolyParabel=a;
692 actionGroupFormatLinkStyles->addTo (menu);
694 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
695 actionGroupFormatFrameTypes->setExclusive (true);
696 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
697 a->setToggleAction(true);
698 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
699 actionFormatFrameNone=a;
700 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
701 a->setToggleAction(true);
702 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
703 actionFormatFrameRectangle=a;
705 a = new QAction( tr( "Hide link" ),tr( "Hide link if object is not selected" ), 0, actionFormatHideLinkUnselected, "hideLinkUnselected" );
706 a->setToggleAction(true);
707 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
708 actionFormatHideLinkUnselected=a;
710 menu->insertSeparator();
711 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
712 a->setToggleAction(true);
713 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
715 actionFormatLinkColorHint=a;
717 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
718 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
719 actionFormatLinkColor->addTo( menu );
720 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
721 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
722 actionFormatBackColor->addTo( menu );
726 void Main::setupViewActions()
728 QToolBar *tb = new QToolBar( this );
729 tb->setLabel( "View Actions" );
730 QPopupMenu *menu = new QPopupMenu( this );
731 menuBar()->insertItem( tr( "&View" ), menu );
734 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
735 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
738 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
739 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
742 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
743 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
746 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
747 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
748 a->setToggleAction(true);
749 if (textEditor->showWithMain())
755 actionViewToggleNoteEditor=a;
756 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
757 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
759 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
760 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
765 void Main::setupModeActions()
767 //QPopupMenu *menu = new QPopupMenu( this );
768 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
770 QToolBar *tb = new QToolBar( this );
771 tb->setLabel( tr ("Modes when using modifiers") );
773 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
774 actionGroupModModes->setExclusive (true);
775 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
776 a->setToggleAction(true);
779 actionModModeColor=a;
781 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
782 a->setToggleAction(true);
786 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
787 a->setToggleAction(true);
793 void Main::setupFlagActions()
795 standardFlagsDefault->makeToolbar(this, "Standard Flags");
799 void Main::setupSettingsActions()
801 QPopupMenu *menu = new QPopupMenu( this );
802 menuBar()->insertItem( tr( "&Settings" ), menu );
807 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files ...") , 0, this, "setPDF" );
808 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
811 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links..."), 0, this, "setURL" );
812 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
815 menu->insertSeparator();
816 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
817 a->setToggleAction(true);
818 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
820 actionSettingsAutoedit=a;
822 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
823 a->setToggleAction(true);
824 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
826 actionSettingsAutoselectHeading=a;
828 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
829 a->setToggleAction(true);
830 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
832 actionSettingsAutoselectText=a;
834 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
835 a->setToggleAction(true);
836 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
838 actionSettingsPasteNewHeading=a;
840 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
841 a->setToggleAction(true);
842 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
844 actionSettingsUseDelKey=a;
846 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
847 a->setToggleAction(true);
848 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
850 actionSettingsUseFlagGroups=a;
854 void Main::setupTestActions()
856 QPopupMenu *menu = new QPopupMenu( this );
857 menuBar()->insertItem( tr( "&Test" ), menu );
860 a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
861 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
864 a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
865 connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
870 void Main::setupHelpActions()
872 QPopupMenu *menu = new QPopupMenu( this );
873 menuBar()->insertItem( tr( "&Help" ), menu );
876 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
877 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
880 a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
881 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
884 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
885 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
890 void Main::setupContextMenus()
894 // Context Menu for branch or mapcenter
895 branchContextMenu =new QPopupMenu (this);
898 branchAddContextMenu =new QPopupMenu (this);
899 actionEditPaste->addTo ( branchAddContextMenu );
900 actionEditAddBranch->addTo ( branchAddContextMenu );
901 actionEditAddBranchHere->addTo ( branchAddContextMenu );
902 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
903 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
904 branchAddContextMenu->insertSeparator();
905 actionEditLoadImage->addTo( branchAddContextMenu );
906 branchAddContextMenu->insertSeparator();
907 actionEditImportAdd->addTo ( branchAddContextMenu );
908 actionEditImportReplace->addTo ( branchAddContextMenu );
911 branchRemoveContextMenu =new QPopupMenu (this);
912 actionEditCut->addTo ( branchRemoveContextMenu );
913 actionEditDelete->addTo ( branchRemoveContextMenu );
914 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
915 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
917 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
918 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
920 actionEditSaveBranch->addTo( branchContextMenu );
922 branchContextMenu->insertSeparator();
923 actionEditOpenURL->addTo ( branchContextMenu );
924 actionEditURL->addTo ( branchContextMenu );
925 actionEditHeading2URL->addTo ( branchContextMenu );
926 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
927 actionEditBugzilla2URL->addTo( branchContextMenu );
929 branchContextMenu->insertSeparator();
930 actionEditOpenVymLink->addTo ( branchContextMenu );
931 actionEditVymLink->addTo ( branchContextMenu );
932 actionEditDeleteVymLink->addTo ( branchContextMenu );
934 branchContextMenu->insertSeparator();
935 actionGroupFormatFrameTypes->addTo( branchContextMenu );
937 branchContextMenu->insertSeparator();
938 actionFormatHideLinkUnselected->addTo( branchContextMenu );
940 // Context Menu for links in a branch menu
941 // This will be populated "on demand" in MapEditor::updateActions
942 branchContextMenu->insertSeparator();
943 branchLinksContextMenu =new QPopupMenu (this);
944 branchLinksContextMenuDup =new QPopupMenu (this);
945 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
946 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
948 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
949 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
951 // Context menu for floatimage
952 floatimageContextMenu =new QPopupMenu (this);
953 saveImageFormatMenu=new QPopupMenu (this);
954 exportImageFormatMenu=new QPopupMenu (this);
956 QStrList fmt = QImage::outputFormats();
957 for (const char* f = fmt.first(); f; f = fmt.next())
959 saveImageFormatMenu->insertItem( f );
960 exportImageFormatMenu->insertItem( f );
962 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
963 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
964 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
966 floatimageContextMenu->insertSeparator();
967 actionEditCopy->addTo( floatimageContextMenu );
968 actionEditCut->addTo( floatimageContextMenu );
970 floatimageContextMenu->insertSeparator();
971 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
972 a->setToggleAction(true);
973 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
974 a->addTo( floatimageContextMenu);
975 actionEditToggleFloatExport=a;
977 floatimageContextMenu->insertSeparator();
978 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
980 // Context menu for exports
981 exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
983 a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" +QString("...")), 0, this, "exportASCII" );
984 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
985 a->addTo( exportMenu );
987 a = new QAction( tr( "Export as LaTeX (still experimental)" ), QPixmap(), tr( "Export (LaTeX)" +QString("...")), 0, this, "exportLaTeX" );
988 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
989 a->addTo( exportMenu );
991 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
993 a = new QAction( tr( "Export as Open Office 1.3.x Presentation (still experimental)" ), QPixmap(), tr( "Export (OO Presentation)" +QString("...")), 0, this, "exportOOPresentation" );
994 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
995 a->addTo( exportMenu );
998 a = new QAction( tr( "Export (XML)" ), QPixmap(), tr( "Export (XML)" )+QString("..."), 0, this, "exportXML" );
999 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1000 a->addTo( exportMenu );
1002 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1004 a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export (HTML)" )+QString("..."), 0, this, "exportHTML");
1005 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
1006 a->addTo( exportMenu );
1009 a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" )+QString("..."), ALT + Key_X, this, "exportXHTML" );
1010 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1011 a->addTo( exportMenu );
1014 // Context menu for canvas
1015 canvasContextMenu =new QPopupMenu (this);
1016 actionEditMapInfo->addTo( canvasContextMenu );
1017 canvasContextMenu->insertSeparator();
1018 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1019 canvasContextMenu->insertSeparator();
1020 actionFormatLinkColorHint->addTo( canvasContextMenu );
1021 actionFormatLinkColor->addTo( canvasContextMenu );
1022 actionFormatBackColor->addTo( canvasContextMenu );
1024 // Menu for last opened files
1025 // Read settings initially
1027 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1028 for (int i=1;i<=j;i++)
1030 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1031 if (!s.isEmpty() && j<=maxLastMaps)
1034 setupLastMapsMenu();
1035 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1038 void Main::setupLastMapsMenu()
1040 // Remove double entries
1041 QStringList::Iterator it=lastMaps.begin();
1042 QStringList::Iterator jt;
1043 while (it!=lastMaps.end() )
1047 while (jt!=lastMaps.end() )
1050 jt=lastMaps.remove(jt);
1057 // Limit length of list to maxLastMaps
1058 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1060 // build Menu from lastMaps string list
1061 lastMapsMenu->clear();
1062 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1063 lastMapsMenu->insertItem (*it );
1067 void Main::hideEvent (QHideEvent * )
1069 if (!textEditor->isMinimized() ) textEditor->hide();
1072 void Main::showEvent (QShowEvent * )
1074 if (textEditor->showWithMain()) textEditor->showNormal();
1077 bool Main::reallyWriteDirectory(const QString &dir)
1079 QStringList eList = QDir(dir).entryList();
1080 if (eList.first() ==".") eList.pop_front(); // remove "."
1081 if (eList.first() =="..") eList.pop_front(); // remove "."
1082 if (!eList.isEmpty())
1084 QMessageBox mb( "VYM",
1085 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1086 QMessageBox::Warning,
1088 QMessageBox::Cancel | QMessageBox::Default,
1089 QMessageBox::QMessageBox::NoButton );
1091 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1092 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1095 case QMessageBox::Yes:
1098 case QMessageBox::Cancel:
1106 QString Main::browseDirectory (const QString &caption)
1108 QFileDialog fd(this,caption);
1109 fd.setMode (QFileDialog::DirectoryOnly);
1110 fd.setCaption("VYM - "+caption);
1113 if ( fd.exec() == QDialog::Accepted )
1114 return fd.selectedFile();
1119 MapEditor* Main::currentMapEditor() const
1121 if ( tabWidget->currentPage() &&
1122 tabWidget->currentPage()->inherits( "MapEditor" ) )
1123 return (MapEditor*)tabWidget->currentPage();
1127 //TODO not used now, maybe use this for overview window later
1128 void Main::newView()
1130 // Open a new view... have it delete when closed.
1131 Main *m = new Main(0, 0, WDestructiveClose);
1132 qApp->setMainWidget(m);
1134 qApp->setMainWidget(0);
1137 void Main::editorChanged(QWidget *)
1139 // Unselect all possibly selected objects
1140 // (Important to update note editor)
1143 for (i=0;i<=tabWidget->count() -1;i++)
1146 me=(MapEditor*)tabWidget->page(i);
1149 currentMapEditor()->reselect();
1151 // Update actions to in menus and toolbars according to editor
1152 currentMapEditor()->updateActions();
1155 void Main::fileNew()
1157 QString fn="unnamed";
1158 MapEditor* medit = new MapEditor (tabWidget, true);
1159 tabWidget->addTab (medit,fn);
1160 tabWidget->showPage(medit);
1161 medit->viewport()->setFocus();
1162 medit->select("mc:");
1165 void Main::fileLoad(QString fn, const LoadMode &lmode)
1168 enum errorCode {success,aborted};
1169 errorCode err=success;
1171 // fn is usually the archive, mapfile the file after uncompressing
1174 // Make fn absolute (needed for unzip)
1175 fn=QDir (fn).absPath();
1181 // Check, if map is already loaded
1183 while (i<=tabWidget->count() -1)
1185 me=(MapEditor*)tabWidget->page(i);
1186 if (me->getFilePath() == fn)
1188 // Already there, ask for confirmation
1189 QMessageBox mb( "VYM",
1190 tr("The map %1\nis already opened."
1191 "Opening the same map in multiple editors may lead \n"
1192 "to confusion when finishing working with vym."
1193 "Do you want to").arg(fn),
1194 QMessageBox::Warning,
1195 QMessageBox::Yes | QMessageBox::Default,
1196 QMessageBox::Cancel | QMessageBox::Escape,
1197 QMessageBox::QMessageBox::NoButton);
1198 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1199 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1202 case QMessageBox::Yes:
1204 i=tabWidget->count();
1206 case QMessageBox::Cancel:
1218 if ( !fn.isEmpty() )
1220 me = currentMapEditor();
1221 int tabIndex=tabWidget->currentPageIndex();
1222 // Check first, if mapeditor exists
1223 // If it is not default AND we want a new map,
1224 // create a new mapeditor in a new tab
1225 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1227 me = new MapEditor (tabWidget,true);
1228 tabWidget->addTab (me,fn);
1229 tabIndex=tabWidget->indexOf (me);
1230 tabWidget->setCurrentPage (tabIndex);
1233 // Check, if file exists (important for creating new files
1234 // from command line
1235 if (!QFile(fn).exists() )
1237 QMessageBox mb( "VYM",
1238 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1239 QMessageBox::Question,
1241 QMessageBox::Cancel | QMessageBox::Default,
1242 QMessageBox::QMessageBox::NoButton );
1244 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1245 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1248 case QMessageBox::Yes:
1250 currentMapEditor()->setFilePath(fn);
1251 tabWidget->setTabLabel (currentMapEditor(),
1252 currentMapEditor()->getFileName() );
1253 statusBar()->message( "Created " + fn , statusbarTime );
1256 case QMessageBox::Cancel:
1257 // don't create new map
1258 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1265 //tabWidget->currentPage() won't be NULL here, because of above...
1266 tabWidget->showPage(me);
1267 me->viewport()->setFocus();
1269 // Create temporary directory for packing
1270 char tmpdir1[]="/tmp/vym-XXXXXX";
1271 QString tmpMapDir=mkdtemp(tmpdir1);
1273 // Try to unzip file
1274 Process *zipProc=new Process ();
1275 zipProc->clearArguments();
1276 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1277 zipProc->addArgument ("unzip");
1278 zipProc->addArgument (fn );
1279 zipProc->addArgument ("-d");
1280 zipProc->addArgument (tmpMapDir);
1282 if (!zipProc->start() )
1284 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1285 tr("Couldn't start unzip to decompress data."));
1290 zipProc->waitFinished();
1291 if (!zipProc->normalExit() )
1293 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1294 tr("unzip didn't exit normally") +
1295 zipProc->getErrout() );
1299 if (zipProc->exitStatus()>0)
1301 if (zipProc->exitStatus()==9)
1303 // no zipped file, but maybe .xml or old version? Try again.
1305 me->setZipped(false);
1309 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1310 QString("unzip exit code: %1").arg(zipProc->exitStatus() ) +
1311 zipProc->getErrout() );
1315 { // Uncompressing was successfull,
1316 // load from uncompressed temporary directory
1318 me->setZipped(true);
1321 // Look for mapname.xml
1322 mapfile= fn.left(fn.findRev(".",-1,true));
1323 mapfile=mapfile.section( '/', -1 );
1324 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1325 if (!file.exists() )
1327 // mapname.xml does not exist, well,
1328 // maybe some renamed the mapname.vym file...
1329 // Try to find any .xml in the toplevel
1330 // directory of the .vym file
1331 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1332 if (flist.count()==1)
1334 // Only one entry, take this one
1335 mapfile=tmpMapDir + "/"+flist.first();
1338 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1339 *it=tmpMapDir + "/" + *it;
1340 // TODO Multiple entries, load all (but only the first one into this ME)
1341 //mainWindow->fileLoadFromTmp (flist);
1342 //returnCode=1; // Silently forget this attempt to load
1343 qWarning ("MainWindow::load (fn) multimap found...");
1346 if (flist.isEmpty() )
1348 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1349 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1352 } //file doesn't exist
1354 mapfile=file.name();
1355 } // Uncompressing successfull
1360 // Save existing filename
1361 QString fn_org=me->getFilePath();
1363 // Finally load map into mapEditor
1364 me->setFilePath (mapfile,fn);
1365 if (me->load(mapfile,lmode))
1368 // Restore old (maybe empty) filepath, if this is an import
1370 me->setFilePath (fn_org);
1373 system ( "rm -rf "+tmpMapDir);
1380 me->setFilePath (fn);
1381 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1382 lastMaps.prepend(me->getFilePath() );
1383 setupLastMapsMenu();
1384 actionFilePrint->setEnabled (true);
1386 statusBar()->message( "Loaded " + fn, statusbarTime );
1396 statusBar()->message( "Could not load " + fn, statusbarTime );
1400 void Main::fileLoad(const LoadMode &lmode)
1402 QFileDialog *fd=new QFileDialog( this);
1403 if (!lastFileDir.isEmpty())
1404 fd->setDir (lastFileDir);
1405 fd->addFilter ("XML (*.xml)");
1406 fd->addFilter ("VYM map (*.vym *.vyp)");
1410 fd->setCaption(tr("Load vym map"));
1413 fd->setCaption(tr("Import: Add vym map to selection"));
1416 fd->setCaption(tr("Import: Replace selection with vym map"));
1422 if ( fd->exec() == QDialog::Accepted )
1424 lastFileDir=fd->dirPath();
1425 fn = fd->selectedFile();
1426 fileLoad(fn, lmode);
1430 void Main::fileLoad()
1435 void Main::fileLoadLast(int i)
1437 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1440 void Main::fileSave(const SaveMode &savemode)
1442 // tmp dir for zipping
1446 enum errorCode {success,aborted};
1447 errorCode err=success;
1449 QString safeFilePath;
1451 bool saveZipped=currentMapEditor()->saveZipped();
1453 MapEditor * me=currentMapEditor();
1456 QString fn=me->getFilePath();
1457 // filename=unnamed, filepath="" in constructor...
1458 if ( !fn.isEmpty() )
1460 // We have a filepath, go on saving
1461 // First remove existing file, we
1462 // don't want to add to old zip archives
1466 QMessageBox::warning( 0, tr( "Save Error" ),
1467 fn+ tr("\ncould not be removed before saving"));
1469 // Look, if we should zip the data:
1472 QMessageBox mb( "VYM",
1473 tr("The map %1\ndid not use the compressed "
1474 "vym file format.\nWriting it uncompressed will also write images \n"
1475 "and flags and thus may overwrite files in the "
1476 "given directory\n\nDo you want to write the map").arg(fn),
1477 QMessageBox::Warning,
1478 QMessageBox::Yes | QMessageBox::Default,
1480 QMessageBox::Cancel | QMessageBox::Escape);
1481 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1482 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1483 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1486 case QMessageBox::Yes:
1487 // save compressed (default file format)
1490 case QMessageBox::No:
1491 // save uncompressed
1494 case QMessageBox::Cancel:
1503 char tmpdir1[]="/tmp/vym-XXXXXX";
1504 tmpMapDir=mkdtemp(tmpdir1);
1506 safeFilePath=me->getFilePath();
1507 me->setFilePath (tmpMapDir+"/"+
1508 me->getMapName()+ ".xml",
1510 me->save (savemode);
1511 me->setFilePath (safeFilePath);
1513 // zip the temporary directory
1514 Process *zipProc=new Process ();
1515 zipProc->clearArguments();
1516 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1517 zipProc->addArgument ("zip");
1518 zipProc->addArgument ("-r");
1519 zipProc->addArgument (fn);
1520 zipProc->addArgument (".");
1522 if (!zipProc->start() )
1524 // zip could not be started
1525 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1526 tr("Couldn't start zip to compress data."));
1530 // zip could be started
1531 zipProc->waitFinished();
1532 if (!zipProc->normalExit() )
1534 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1535 tr("zip didn't exit normally")+
1536 "\n" + zipProc->getErrout());
1540 if (zipProc->exitStatus()>0)
1542 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1543 QString("zip exit code: %1").arg(zipProc->exitStatus() )+
1544 "\n" + zipProc->getErrout() );
1548 } // zip could be started
1553 safeFilePath=me->getFilePath();
1554 me->setFilePath (fn, safeFilePath);
1555 me->save (savemode);
1556 me->setFilePath (safeFilePath);
1558 } // filepath available
1561 // We have no filepath yet,
1562 // call fileSaveAs() now, this will call fileSave()
1564 fileSaveAs(savemode);
1568 if (me->saveZipped())
1571 system ( "rm -rf "+ tmpMapDir );
1576 statusBar()->message(
1577 tr("Saved %1").arg(me->getFilePath()),
1579 lastMaps.prepend(me->getFilePath() );
1580 setupLastMapsMenu();
1582 statusBar()->message(
1583 tr("Couldn't save ").arg(me->getFilePath()),
1587 void Main::fileSave()
1589 fileSave (CompleteMap);
1592 void Main::fileSaveAs(const SaveMode& savemode)
1597 if (currentMapEditor())
1599 if (savemode==CompleteMap)
1600 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1602 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1603 if ( !fn.isEmpty() )
1605 // Check for existing file
1606 if (QFile (fn).exists())
1608 QMessageBox mb( "VYM",
1609 tr("The file %1\nexists already. Do you want to").arg(fn),
1610 QMessageBox::Warning,
1611 QMessageBox::Yes | QMessageBox::Default,
1612 QMessageBox::Cancel | QMessageBox::Escape,
1613 QMessageBox::QMessageBox::NoButton);
1614 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1615 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1618 case QMessageBox::Yes:
1621 case QMessageBox::Cancel:
1628 // New file, add extension to filename, if missing
1629 // This is always .vym or .vyp, depending on savemode
1630 if (savemode==CompleteMap)
1632 if (!fn.contains (".vym") && !fn.contains (".xml"))
1636 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1645 currentMapEditor()->setFilePath(fn);
1649 if (savemode==CompleteMap)
1650 tabWidget->setTabLabel (currentMapEditor(),
1651 currentMapEditor()->getFileName() );
1657 void Main::fileSaveAs()
1659 fileSaveAs (CompleteMap);
1662 void Main::fileImportDir()
1664 if (currentMapEditor())
1665 currentMapEditor()->importDir();
1668 void Main::fileExportXML()
1670 if (currentMapEditor())
1672 QString dir=browseDirectory(tr("Export XML to directory"));
1673 if (dir !="" && reallyWriteDirectory(dir) )
1674 currentMapEditor()->exportXML(dir);
1678 void Main::fileExportHTML()
1680 if (currentMapEditor())
1682 ExportHTMLDialog dia(this);
1684 if (dia.exec()==QDialog::Accepted)
1686 QString dir=dia.getDir();
1687 if (reallyWriteDirectory(dir) )
1689 currentMapEditor()->exportXML (dia.getDir() );
1690 dia.doExport(currentMapEditor()->getMapName() );
1696 void Main::fileExportXHTML()
1699 if (currentMapEditor())
1701 ExportXHTMLDialog dia(this);
1702 dia.setFilePath (currentMapEditor()->getFilePath() );
1703 dia.setMapName (currentMapEditor()->getMapName() );
1706 if (dia.exec()==QDialog::Accepted)
1708 QString dir=dia.getDir();
1709 // Check, if warnings should be used before overwriting
1710 // the output directory
1713 ok=reallyWriteDirectory(dir);
1719 currentMapEditor()->exportXML (dia.getDir() );
1720 dia.doExport(currentMapEditor()->getMapName() );
1721 if (dia.hasChanged())
1722 currentMapEditor()->setChanged();
1728 void Main::fileExportImage(int item)
1730 if (currentMapEditor())
1732 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1734 if ( !fn.isEmpty() )
1736 currentMapEditor()->exportImage(fn,item);
1738 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
1743 void Main::fileExportASCII()
1745 if (currentMapEditor())
1746 currentMapEditor()->exportASCII();
1749 void Main::fileExportLaTeX()
1751 if (currentMapEditor())
1752 currentMapEditor()->exportLaTeX();
1755 void Main::fileExportOOPresentation()
1757 if (currentMapEditor())
1758 currentMapEditor()->exportOOPresentation();
1761 void Main::fileCloseMap()
1763 if (currentMapEditor())
1765 if (currentMapEditor()->hasChanged())
1767 QMessageBox mb( "VYM",
1768 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
1769 QMessageBox::Warning,
1770 QMessageBox::Yes | QMessageBox::Default,
1772 QMessageBox::Cancel | QMessageBox::Escape );
1773 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1774 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1777 case QMessageBox::Yes:
1779 fileSave(CompleteMap);
1781 case QMessageBox::No:
1782 // close without saving
1784 case QMessageBox::Cancel:
1789 currentMapEditor()->closeMap();
1790 tabWidget->removePage(currentMapEditor());
1791 if (tabWidget->count()==0)
1792 actionFilePrint->setEnabled (false);
1796 void Main::filePrint()
1798 if (currentMapEditor())
1799 currentMapEditor()->print();
1802 void Main::fileExitVYM()
1804 // Check if one or more editors have changed
1807 for (i=0;i<=tabWidget->count() -1;i++)
1810 me=(MapEditor*)tabWidget->page(i);
1812 // If something changed, ask what to do
1813 if (me->isUnsaved())
1815 tabWidget->setCurrentPage(i);
1816 QMessageBox mb( "VYM",
1817 tr("This map is not saved yet. Do you want to"),
1818 QMessageBox::Warning,
1819 QMessageBox::Yes | QMessageBox::Default,
1821 QMessageBox::Cancel | QMessageBox::Escape );
1822 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1823 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1825 // Call undocumented function: setActiveWindow is only
1826 // possible, if widget is visible. This depends on
1828 #if defined(Q_OS_LINUX)
1829 qt_wait_for_window_manager( this);
1831 mb.setActiveWindow();
1832 switch( mb.exec() ) {
1833 case QMessageBox::Yes:
1834 // save (the changed editors) and exit
1835 fileSave(CompleteMap);
1837 case QMessageBox::No:
1838 // exit without saving
1840 case QMessageBox::Cancel:
1841 // don't save and don't exit
1845 } // loop over all MEs
1849 void Main::editUndo()
1851 if (currentMapEditor())
1852 currentMapEditor()->undo();
1855 void Main::editRedo()
1857 if (currentMapEditor())
1858 currentMapEditor()->redo();
1861 void Main::editCopy()
1863 if (currentMapEditor())
1864 currentMapEditor()->copy();
1867 void Main::editPaste()
1869 if (currentMapEditor())
1870 currentMapEditor()->paste();
1873 void Main::editCut()
1875 if (currentMapEditor())
1876 currentMapEditor()->cut();
1879 void Main::editOpenFindWindow()
1881 findWindow->popup();
1882 findWindow->raise();
1884 // Call undocumented function: setActiveWindow is only
1885 // possible, if widget is visible. This depends on
1887 #if defined(Q_OS_LINUX)
1888 qt_wait_for_window_manager( this);
1890 findWindow->setActiveWindow();
1893 void Main::editFind(QString s)
1896 BranchObj *bo=currentMapEditor()->findText(s, cs);
1899 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
1902 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
1903 tr("No matches found for <b>%1</b>").arg(s));
1907 void Main::editFindChanged()
1908 { // Notify editor, to abort the current find process
1909 currentMapEditor()->findReset();
1912 void Main::editOpenURL()
1914 if (currentMapEditor())
1915 currentMapEditor()->openURL();
1918 void Main::editURL()
1920 if (currentMapEditor())
1921 currentMapEditor()->editURL();
1924 void Main::editHeading2URL()
1926 if (currentMapEditor())
1927 currentMapEditor()->editHeading2URL();
1930 void Main::editBugzilla2URL()
1932 if (currentMapEditor())
1933 currentMapEditor()->editBugzilla2URL();
1936 void Main::editOpenVymLink()
1938 // Get current path to map
1939 QString currentVymLink;
1940 if (currentMapEditor())
1942 currentVymLink=currentMapEditor()->getVymLink();
1943 // compare path with already loaded maps
1947 for (i=0;i<=tabWidget->count() -1;i++)
1949 me=(MapEditor*)tabWidget->page(i);
1950 if (currentVymLink==me->getFilePath() )
1959 if (!QFile(currentVymLink).exists() )
1960 QMessageBox::critical( 0, tr( "Critical Error" ),
1961 tr("Couldn't open map %1").arg(currentVymLink));
1964 fileLoad (currentVymLink, NewMap);
1965 tabWidget->setCurrentPage (tabWidget->count()-1);
1968 // Go to tab containing the map
1969 tabWidget->setCurrentPage (index);
1973 void Main::editVymLink()
1975 if (currentMapEditor())
1976 currentMapEditor()->editVymLink();
1979 void Main::editDeleteVymLink()
1981 if (currentMapEditor())
1982 currentMapEditor()->deleteVymLink();
1985 void Main::editMapInfo()
1987 if (currentMapEditor())
1988 currentMapEditor()->editMapInfo();
1991 void Main::editMoveUp()
1993 if (currentMapEditor())
1994 currentMapEditor()->moveBranchUp();
1997 void Main::editMoveDown()
1999 if (currentMapEditor())
2000 currentMapEditor()->moveBranchDown();
2003 void Main::editToggleScroll()
2005 if (currentMapEditor())
2007 currentMapEditor()->toggleScroll();
2011 void Main::editUnScrollAll()
2013 if (currentMapEditor())
2015 currentMapEditor()->unScrollAll();
2019 void Main::editHeading()
2021 if (currentMapEditor())
2022 currentMapEditor()->editHeading();
2025 void Main::editNewBranch()
2027 if (currentMapEditor())
2028 currentMapEditor()->addNewBranch(0);
2031 void Main::editNewBranchHere()
2033 if (currentMapEditor())
2034 currentMapEditor()->addNewBranchHere();
2037 void Main::editNewBranchAbove()
2039 if (currentMapEditor())
2040 currentMapEditor()->addNewBranch(-1);
2043 void Main::editNewBranchBelow()
2045 if (currentMapEditor())
2046 currentMapEditor()->addNewBranch(1);
2049 void Main::editImportAdd()
2051 fileLoad (ImportAdd);
2054 void Main::editImportReplace()
2056 fileLoad (ImportReplace);
2059 void Main::editSaveBranch()
2061 fileSaveAs (PartOfMap);
2064 void Main::editRemoveBranchHere()
2066 if (currentMapEditor())
2067 currentMapEditor()->removeBranchHere();
2070 void Main::editRemoveChilds()
2072 if (currentMapEditor())
2073 currentMapEditor()->removeChilds();
2076 void Main::editDeleteSelection()
2078 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2079 currentMapEditor()->deleteSelection();
2082 void Main::editUpperBranch()
2084 if (currentMapEditor())
2085 currentMapEditor()->selectUpperBranch();
2088 void Main::editLowerBranch()
2090 if (currentMapEditor())
2091 currentMapEditor()->selectLowerBranch();
2094 void Main::editLeftBranch()
2096 if (currentMapEditor())
2097 currentMapEditor()->selectLeftBranch();
2100 void Main::editRightBranch()
2102 if (currentMapEditor())
2103 currentMapEditor()->selectRightBranch();
2106 void Main::editFirstBranch()
2108 if (currentMapEditor())
2109 currentMapEditor()->selectFirstBranch();
2112 void Main::editLastBranch()
2114 if (currentMapEditor())
2115 currentMapEditor()->selectLastBranch();
2118 void Main::editLoadImage()
2120 if (currentMapEditor())
2121 currentMapEditor()->loadFloatImage();
2124 void Main::editSaveImage(int item)
2126 if (currentMapEditor())
2127 currentMapEditor()->saveFloatImage(item);
2130 void Main::editToggleFloatExport()
2132 if (currentMapEditor())
2133 currentMapEditor()->toggleFloatExport();
2136 void Main::editFollowXLink(int item)
2138 if (currentMapEditor())
2139 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2142 void Main::editEditXLink(int item)
2144 if (currentMapEditor())
2145 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2148 void Main::formatSelectColor()
2150 if (currentMapEditor())
2152 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2153 if ( !col.isValid() ) return;
2154 currentMapEditor()->setColor( col );
2155 colorChanged( col );
2159 void Main::formatPickColor()
2161 if (currentMapEditor())
2162 colorChanged( currentMapEditor()->pickColor() );
2165 void Main::colorChanged(QColor c)
2167 QPixmap pix( 16, 16 );
2169 actionFormatColor->setIconSet( pix );
2172 void Main::formatColorItem()
2174 if (currentMapEditor())
2175 currentMapEditor()->colorItem();
2178 void Main::formatColorBranch()
2180 if (currentMapEditor())
2181 currentMapEditor()->colorBranch();
2184 void Main::formatLinkStyleLine()
2186 if (currentMapEditor())
2187 currentMapEditor()->setLinkStyle(StyleLine);
2190 void Main::formatLinkStyleParabel()
2192 if (currentMapEditor())
2193 currentMapEditor()->setLinkStyle(StyleParabel);
2196 void Main::formatLinkStylePolyLine()
2198 if (currentMapEditor())
2199 currentMapEditor()->setLinkStyle(StylePolyLine);
2202 void Main::formatLinkStylePolyParabel()
2204 if (currentMapEditor())
2205 currentMapEditor()->setLinkStyle(StylePolyParabel);
2208 void Main::formatSelectBackColor()
2210 if (currentMapEditor())
2211 currentMapEditor()->selectBackgroundColor();
2214 void Main::formatSelectLinkColor()
2216 if (currentMapEditor())
2217 currentMapEditor()->selectLinkColor();
2220 void Main::formatToggleLinkColorHint()
2222 currentMapEditor()->toggleLinkColorHint();
2225 void Main::formatFrameNone()
2227 if (currentMapEditor())
2228 currentMapEditor()->setFrame(NoFrame);
2231 void Main::formatFrameRectangle()
2233 if (currentMapEditor())
2234 currentMapEditor()->setFrame(Rectangle);
2237 void Main::formatHideLinkUnselected()
2239 if (currentMapEditor())
2240 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2243 void Main::viewZoomReset()
2245 if (currentMapEditor())
2249 currentMapEditor()->setWorldMatrix( m );
2250 currentMapEditor()->setViewCenter();
2251 currentMapEditor()->adjustCanvasSize();
2255 void Main::viewZoomIn()
2257 if (currentMapEditor())
2259 QWMatrix m = currentMapEditor()->worldMatrix();
2260 m.scale( 1.25, 1.25 );
2261 currentMapEditor()->setWorldMatrix( m );
2262 currentMapEditor()->setViewCenter();
2263 currentMapEditor()->adjustCanvasSize();
2267 void Main::viewZoomOut()
2269 if (currentMapEditor())
2271 QWMatrix m = currentMapEditor()->worldMatrix();
2272 m.scale( 0.8, 0.8 );
2273 currentMapEditor()->setWorldMatrix( m );
2274 currentMapEditor()->setViewCenter();
2275 currentMapEditor()->adjustCanvasSize();
2279 void Main::modModeColor()
2283 void Main::modModeLink()
2287 bool Main::settingsPDF()
2289 // Default browser is set in constructor
2291 QString text = QInputDialog::getText(
2292 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2293 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2295 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2300 bool Main::settingsURL()
2302 // Default browser is set in constructor
2304 QString text = QInputDialog::getText(
2305 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2306 settings.readEntry("/vym/mainwindow/readerURL")
2309 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2313 void Main::windowToggleNoteEditor()
2315 if (textEditor->showWithMain() )
2316 windowHideNoteEditor();
2318 windowShowNoteEditor();
2321 void Main::updateNoteFlag()
2323 if (currentMapEditor())
2324 currentMapEditor()->updateNoteFlag();
2327 void Main::windowShowNoteEditor()
2329 textEditor->setShowWithMain(true);
2331 actionViewToggleNoteEditor->setOn (true);
2334 void Main::windowHideNoteEditor()
2336 textEditor->setShowWithMain(false);
2338 actionViewToggleNoteEditor->setOn (false);
2341 void Main::windowNextEditor()
2343 if (tabWidget->currentPageIndex() < tabWidget->count())
2344 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2347 void Main::windowPreviousEditor()
2349 if (tabWidget->currentPageIndex() >0)
2350 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2353 void Main::standardFlagChanged()
2355 currentMapEditor()->toggleStandardFlag(sender()->name());
2358 void Main::testFunction()
2360 //textEditor->stackUnder(this);
2361 currentMapEditor()->testFunction();
2364 void Main::testShowClipboard()
2366 clipboardME->show();
2369 void Main::helpDoc()
2372 #if defined(Q_OS_MACX)
2373 docpath="./vym.app/Contents/vym.pdf";
2375 // default path in SUSE LINUX
2376 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2379 if (!QFile (docpath).exists() )
2381 // relative path for easy testing in tarball
2382 docpath="doc/vym.pdf";
2383 if (!QFile (docpath).exists() )
2385 // relative path for testing while still writing vym.tex
2386 docpath="doc/tex/vym.pdf";
2387 if (!QFile (docpath).exists() )
2389 QMessageBox::critical(0,
2390 tr("Critcal error"),
2391 tr("Couldn't find the documentation\n"
2392 "vym.pdf in various places."));
2398 Process *pdfProc = new Process();
2399 pdfProc->clearArguments();
2400 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2401 pdfProc->addArgument( docpath);
2403 if ( !pdfProc->start() )
2406 QMessageBox::critical(0,
2407 tr("Critcal error"),
2408 tr("Couldn't find a viewer to read vym.pdf.\n"
2409 "Please use Settings->")+tr("Set application to open pdf files"));
2415 void Main::helpAbout()
2418 ad.setName ("aboutwindow");
2419 ad.setMinimumSize(500,500);
2420 ad.resize (QSize (500,500));
2424 void Main::helpAboutQT()
2426 QMessageBox::aboutQt( this, "Qt Application Example" );