1 #include "mainwindow.h"
3 #include <qstatusbar.h>
4 #include <qmessagebox.h>
6 #include <qapplication.h>
10 #include <qfiledialog.h>
12 #include <qcolordialog.h>
14 #include <qinputdialog.h>
15 #include <qdatetime.h> // for random seed
23 #include "aboutdialog.h"
25 #include "icons/filenew.xpm"
26 #include "icons/fileopen.xpm"
27 #include "icons/filesave.xpm"
28 #include "icons/fileprint.xpm"
29 #include "icons/editundo.xpm"
30 //#include "icons/editredo.xpm" // TODO
31 #include "icons/editcopy.xpm"
32 #include "icons/editcut.xpm"
33 #include "icons/editpaste.xpm"
34 #include "icons/editmoveup.xpm"
35 #include "icons/editmovedown.xpm"
36 #include "icons/formatcoloritem.xpm"
37 #include "icons/formatcolorbranch.xpm"
38 #include "icons/formatcolorpicker.xpm"
39 #include "icons/viewzoomreset.xpm"
40 #include "icons/viewzoomin.xpm"
41 #include "icons/viewzoomout.xpm"
42 #include "icons/modecolor.xpm"
43 #include "icons/modelink.xpm"
44 #include "icons/modecopy.xpm"
45 //#include "icons/vym-48x48.xpm"
46 #include "icons/flag-note.xpm"
47 #include "icons/flag-url.xpm"
48 #include "icons/flag-vymlink.xpm"
49 #include "icons/flag-scrolled-right.xpm"
51 #include "flagrowobj.h"
52 #include "texteditor.h"
53 #include "mapeditor.h"
54 #include "exporthtmldialog.h"
55 #include "exportxhtmldialog.h"
56 #include "showtextdialog.h"
61 extern TextEditor *textEditor;
62 extern Main *mainWindow;
63 extern int statusbarTime;
64 extern MapEditor *clipboardME;
65 extern FlagRowObj* standardFlagsDefault;
67 extern QPtrList <QAction> actionListBranches;
69 extern QAction* actionFileSave;
70 extern QAction* actionFilePrint;
71 extern QAction* actionEditUndo;
72 extern QAction *actionEditCopy;
73 extern QAction *actionEditCut;
74 extern QAction *actionEditPaste;
75 extern QAction *actionEditMoveUp;
76 extern QAction *actionEditMoveDown;
77 extern QAction *actionEditToggleScroll;
78 extern QAction* actionEditOpenURL;
79 extern QAction* actionEditURL;
80 extern QAction* actionEditHeading2URL;
81 extern QAction* actionEditBugzilla2URL;
82 extern QAction *actionEditOpenVymLink;
83 extern QAction *actionEditVymLink;
84 extern QAction *actionEditDeleteVymLink;
85 extern QAction *actionEditMapInfo;
86 extern QAction *actionEditHeading;
87 extern QAction *actionEditDelete;
88 extern QAction *actionEditAddBranch;
89 extern QAction *actionEditAddBranchHere;
90 extern QAction *actionEditAddBranchAbove;
91 extern QAction *actionEditAddBranchBelow;
92 extern QAction *actionEditRemoveBranchHere;
93 extern QAction *actionEditRemoveChilds;
94 extern QAction *actionEditImportAdd;
95 extern QAction *actionEditImportReplace;
96 extern QAction *actionEditSaveBranch;
97 extern QAction *actionEditSelectFirst;
98 extern QAction *actionEditSelectLast;
99 extern QAction *actionEditLoadImage;
100 extern QAction *actionEditToggleFloatExport;
102 extern QAction* actionFormatColor;
103 extern QAction* actionFormatPickColor;
104 extern QAction* actionFormatColorBranch;
105 extern QAction* actionFormatColorSubtree;
106 extern QAction* actionFormatLinkColorHint;
107 extern QAction* actionFormatBackColor;
108 extern QAction* actionFormatLinkColor;
110 extern QActionGroup* actionGroupModModes;
111 extern QAction* actionModModeColor;
112 extern QAction* actionModModeLink;
113 extern QAction* actionModModeCopy;
115 extern QActionGroup *actionGroupFormatFrameTypes;
116 extern QAction *actionFormatFrameNone;
117 extern QAction *actionFormatFrameRectangle;
119 extern QActionGroup *actionGroupFormatLinkStyles;
120 extern QAction *actionFormatLinkStyleLine;
121 extern QAction *actionFormatLinkStyleParabel;
122 extern QAction *actionFormatLinkStylePolyLine;
123 extern QAction *actionFormatLinkStylePolyParabel;
125 extern QAction *actionViewToggleNoteEditor;
127 extern QAction* actionSettingsAutoedit;
128 extern QAction* actionSettingsAutoselectHeading;
129 extern QAction* actionSettingsAutoselectHeading;
130 extern QAction* actionSettingsAutoselectText;
131 extern QAction* actionSettingsPasteNewHeading;
132 extern QAction* actionSettingsUseDelKey;
133 extern QAction* actionSettingsUseFlagGroups;
135 extern QPopupMenu* branchContextMenu;
136 extern QPopupMenu* branchAddContextMenu;
137 extern QPopupMenu* branchRemoveContextMenu;
138 extern QPopupMenu* branchLinksContextMenu;
139 extern QPopupMenu* branchLinksContextMenuDup;
140 extern QPopupMenu* floatimageContextMenu;
141 extern QPopupMenu* saveImageFormatMenu;
142 extern QPopupMenu* canvasContextMenu;
143 extern QPopupMenu* lastMapsMenu;
144 extern QPopupMenu* exportMenu;
145 extern QPopupMenu* exportImageFormatMenu;
148 extern Settings settings;
149 extern Options options;
151 #if defined(Q_OS_LINUX)
152 extern void qt_wait_for_window_manager( QWidget* w );
155 Main::Main(QWidget* parent, const char* name, WFlags f) :
156 QMainWindow(parent,name,f)
160 setCaption ("VYM - View Your Mind");
162 // Load window settings
163 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
164 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
165 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
166 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
169 // Set random seed (random used for object IDs)
170 QTime t = QTime::currentTime(); // set random seed
171 srand( t.hour()*12+t.minute()*60+t.second()*60 );
174 // Initialize some settings, which are platform dependant
177 // application to open URLs
178 p="/vym/mainwindow/readerURL";
179 #if defined(Q_OS_LINUX)
180 s=settings.readEntry (p,"konqueror");
182 #if defined(Q_OS_MACX)
183 s=settings.readEntry (p,"/usr/bin/open");
185 s=settings.readEntry (p,"mozilla");
188 settings.writeEntry( p,s);
190 // application to open PDFs
191 p="/vym/mainwindow/readerPDF";
192 #if defined(Q_OS_LINUX)
193 s=settings.readEntry (p,"acroread");
195 #if defined(Q_OS_MACX)
196 s=settings.readEntry (p,"/usr/bin/open");
198 s=settings.readEntry (p,"acroread");
201 settings.writeEntry( p,s);
206 // Create tab widget which holds the maps
207 tabWidget= new QTabWidget (this);
208 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
209 this, SLOT( editorChanged( QWidget * ) ) );
211 setCentralWidget(tabWidget);
215 setupFormatActions();
219 setupSettingsActions();
221 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
224 // After menu is created, we can enable some actions
225 actionFilePrint->setEnabled (true);
230 // Initialize Find window
231 findWindow=new FindWindow(NULL,"findwindow");
232 connect (findWindow, SIGNAL( findButton(QString) ),
233 this, SLOT(editFind(QString) ) );
234 connect (findWindow, SIGNAL( somethingChanged() ),
235 this, SLOT(editFindChanged() ) );
239 // Creating the default map into first tab is done in main.cpp now...
245 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
246 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
247 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
248 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
250 settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
251 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
253 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
254 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
255 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
256 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
257 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
258 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
261 int maps=lastMaps.count();
262 settings.writeEntry( "/vym/lastMaps/number",maps );
263 for (int i=1;i<=maps;i++)
265 QStringList::Iterator it = lastMaps.at(i-1);
266 s=QString("/vym/lastMaps/map-%1").arg(i);
267 if (!s.isEmpty() && i<=maxLastMaps)
268 settings.writeEntry (s, *it);
272 // To make the texteditor save its settings, call the destructor
276 void Main::loadCmdLine()
278 /* TODO draw some kind of splashscreen while loading...
284 QStringList flist=options.getFileList();
285 QStringList::Iterator it=flist.begin();
287 while (it !=flist.end() )
289 fileLoad (*it, NewMap);
295 void Main::statusMessage(const QString &s)
297 statusBar()->message (s);
300 void Main::closeEvent (QCloseEvent* )
306 void Main::setupFileActions()
308 QToolBar *tb = new QToolBar( this );
309 tb->setLabel( "File Actions" );
310 QPopupMenu *menu = new QPopupMenu( this );
311 menuBar()->insertItem( tr( "&File" ), menu );
313 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
316 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
317 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
321 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
322 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
326 lastMapsMenu = new QPopupMenu (this);
328 menu->insertItem (tr("Open Recent"),lastMapsMenu );
329 menu->insertSeparator();
331 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
332 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
337 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
338 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
341 menu->insertSeparator();
343 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir"+QString("...") ), 0, this, "export" );
344 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
347 exportMenu = new QPopupMenu (this);
348 menu->insertItem (tr("Export"),exportMenu );
350 menu->insertSeparator();
353 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
354 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
359 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
360 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
363 a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
364 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
370 void Main::setupEditActions()
372 QToolBar *tb = new QToolBar( this );
373 tb->setLabel( "Edit Actions" );
374 QPopupMenu *menu = new QPopupMenu( this );
375 menuBar()->insertItem( tr( "&Edit" ), menu );
379 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
380 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
381 a->setEnabled (false);
386 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
387 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
391 menu->insertSeparator();
392 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
393 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
394 a->setEnabled (false);
398 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
399 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
400 a->setEnabled (false);
404 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
405 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
406 a->setEnabled (false);
411 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
412 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
413 a->setEnabled (false);
416 actionListBranches.append(a);
419 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
420 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
421 a->setEnabled (false);
424 actionListBranches.append(a);
425 actionEditMoveDown=a;
428 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
429 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
430 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
431 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
432 #if defined(Q_OS_MACX)
433 actionEditToggleScroll=alt;
435 actionEditToggleScroll=a;
437 actionEditToggleScroll->setEnabled (false);
438 actionEditToggleScroll->addTo( tb );
439 actionEditToggleScroll->addTo( menu );
440 actionListBranches.append(actionEditToggleScroll);
442 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
443 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
446 menu->insertSeparator();
448 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find"+QString("...") ), CTRL + Key_F, this, "find" );
449 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
452 menu->insertSeparator();
454 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
455 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
458 a->setEnabled (false);
461 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL"+QString("...") ), SHIFT + CTRL + Key_U, this, "url" );
462 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
464 a->setEnabled (false);
465 actionListBranches.append(a);
468 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
469 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
471 a->setEnabled (false);
472 actionListBranches.append(a);
473 actionEditHeading2URL=a;
475 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
476 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
477 a->setEnabled (false);
478 actionListBranches.append(a);
479 actionEditBugzilla2URL=a;
481 menu->insertSeparator();
483 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" );
484 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
487 a->setEnabled (false);
488 actionEditOpenVymLink=a;
490 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link"+QString("...") ), 0, this, "editLinkMap" );
491 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
493 a->setEnabled (false);
494 actionListBranches.append(a);
497 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
498 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
500 a->setEnabled (false);
501 actionEditDeleteVymLink=a;
503 menu->insertSeparator();
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() ) );
508 a->setEnabled (true);
511 menu->insertSeparator();
513 // Shortcuts to modify heading:
514 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
515 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
516 actionListBranches.append(a);
517 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
518 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
519 actionListBranches.append(a);
521 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
522 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
523 a->setEnabled (false);
526 actionListBranches.append(a);
528 // Shortcut to delete selection
529 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
530 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
531 a->setEnabled (false);
535 // Shortcut to add branch
536 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
537 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
538 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
539 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
540 a->setEnabled (false);
541 actionListBranches.append(a);
542 #if defined (Q_OS_MACX)
543 actionEditAddBranch=alt;
545 actionEditAddBranch=a;
548 // Add branch by inserting it at selection
549 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
550 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
551 a->setEnabled (false);
552 actionListBranches.append(a);
553 actionEditAddBranchHere=a;
556 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
557 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
558 a->setEnabled (false);
559 actionListBranches.append(a);
560 actionEditAddBranchAbove=a;
563 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
564 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
565 a->setEnabled (false);
566 actionListBranches.append(a);
567 actionEditAddBranchBelow=a;
569 // Import at selection (adding to selection)
570 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
571 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
572 a->setEnabled (false);
573 actionListBranches.append(a);
574 actionEditImportAdd=a;
576 // Import at selection (replacing selection)
577 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
578 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
579 a->setEnabled (false);
580 actionListBranches.append(a);
581 actionEditImportReplace=a;
584 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
585 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
586 a->setEnabled (false);
587 actionListBranches.append(a);
588 actionEditSaveBranch=a;
590 // Only remove branch, not its childs
591 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
592 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
593 a->setEnabled (false);
594 actionListBranches.append(a);
595 actionEditRemoveBranchHere=a;
597 // Only remove childs of a branch
598 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
599 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
600 a->setEnabled (false);
601 actionListBranches.append(a);
602 actionEditRemoveChilds=a;
604 // Shortcuts for navigating with cursor:
605 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
606 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
607 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
608 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
609 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
610 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
611 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
612 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
613 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
614 a->setEnabled (false);
616 actionListBranches.append(a);
617 actionEditSelectFirst=a;
618 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
619 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
620 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
621 a->setEnabled (false);
623 actionListBranches.append(a);
624 actionEditSelectLast=a;
626 a = new QAction( tr( "Add Image" ),tr( "Add Image" )+QString("..."), 0, this, "loadImage" );
627 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
628 actionEditLoadImage=a;
633 void Main::setupFormatActions()
635 QPopupMenu *menu = new QPopupMenu( this );
636 menuBar()->insertItem( tr( "&Format" ), menu );
638 QToolBar *tb = new QToolBar( this );
642 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" )+QString("..."), 0, this, "formatColor" );
643 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
644 actionFormatColor->addTo( tb );
645 actionFormatColor->addTo( menu );
646 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" );
647 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
648 a->setEnabled (false);
651 actionListBranches.append(a);
652 actionFormatPickColor=a;
653 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
654 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
655 a->setEnabled (false);
658 actionListBranches.append(a);
659 actionFormatColorBranch=a;
660 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
661 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
662 a->setEnabled (false);
665 actionListBranches.append(a);
666 actionFormatColorSubtree=a;
668 menu->insertSeparator();
669 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
670 actionGroupFormatLinkStyles->setExclusive (true);
671 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
672 a->setToggleAction(true);
673 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
674 actionFormatLinkStyleLine=a;
675 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
676 a->setToggleAction(true);
677 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
678 actionFormatLinkStyleParabel=a;
679 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
680 a->setToggleAction(true);
681 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
682 actionFormatLinkStylePolyLine=a;
683 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
684 a->setToggleAction(true);
685 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
686 actionFormatLinkStylePolyParabel=a;
687 actionGroupFormatLinkStyles->addTo (menu);
689 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
690 actionGroupFormatFrameTypes->setExclusive (true);
691 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
692 a->setToggleAction(true);
693 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
694 actionFormatFrameNone=a;
695 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
696 a->setToggleAction(true);
697 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
698 actionFormatFrameRectangle=a;
700 menu->insertSeparator();
701 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
702 a->setToggleAction(true);
703 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
705 actionFormatLinkColorHint=a;
707 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color"+QString("...") ), 0, this, "formatLinkColor" );
708 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
709 actionFormatLinkColor->addTo( menu );
710 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" )+QString("..."), 0, this, "formatBackColor" );
711 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
712 actionFormatBackColor->addTo( menu );
716 void Main::setupViewActions()
718 QToolBar *tb = new QToolBar( this );
719 tb->setLabel( "View Actions" );
720 QPopupMenu *menu = new QPopupMenu( this );
721 menuBar()->insertItem( tr( "&View" ), menu );
724 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), CTRL + Key_0, this, "zoomReset" );
725 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
728 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
729 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
732 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
733 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
736 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
737 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
738 a->setToggleAction(true);
739 if (textEditor->showWithMain())
745 actionViewToggleNoteEditor=a;
746 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
747 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
749 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
750 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
755 void Main::setupModeActions()
757 //QPopupMenu *menu = new QPopupMenu( this );
758 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
760 QToolBar *tb = new QToolBar( this );
761 tb->setLabel( tr ("Modes when using modifiers") );
763 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
764 actionGroupModModes->setExclusive (true);
765 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
766 a->setToggleAction(true);
769 actionModModeColor=a;
771 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
772 a->setToggleAction(true);
776 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
777 a->setToggleAction(true);
783 void Main::setupFlagActions()
785 standardFlagsDefault->makeToolbar(this, "Standard Flags");
789 void Main::setupSettingsActions()
791 QPopupMenu *menu = new QPopupMenu( this );
792 menuBar()->insertItem( tr( "&Settings" ), menu );
797 a = new QAction( tr( "Set application to open pdf files"), QPixmap(), tr( "Set application to open pdf files")+QString("...") , 0, this, "setPDF" );
798 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
801 a = new QAction( tr( "Set application to open external links"), QPixmap(), tr( "Set application to open external links")+QString("..."), 0, this, "setURL" );
802 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
805 menu->insertSeparator();
806 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
807 a->setToggleAction(true);
808 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
810 actionSettingsAutoedit=a;
812 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
813 a->setToggleAction(true);
814 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
816 actionSettingsAutoselectHeading=a;
818 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
819 a->setToggleAction(true);
820 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
822 actionSettingsAutoselectText=a;
824 a= new QAction( tr( "Pasting into new branch" ), QPixmap(), tr( "pasting into new branch" ), 0, this, "pastenewheading" );
825 a->setToggleAction(true);
826 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
828 actionSettingsPasteNewHeading=a;
830 a= new QAction( tr( "Delete key for deleting branches" ), QPixmap(), tr( "Delete key" ), 0, this, "delkey" );
831 a->setToggleAction(true);
832 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
834 actionSettingsUseDelKey=a;
836 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Exclusive flags" ), 0, this, "flaggroups" );
837 a->setToggleAction(true);
838 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
840 actionSettingsUseFlagGroups=a;
844 void Main::setupTestActions()
846 QPopupMenu *menu = new QPopupMenu( this );
847 menuBar()->insertItem( tr( "&Test" ), menu );
850 a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
851 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
854 a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
855 connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
860 void Main::setupHelpActions()
862 QPopupMenu *menu = new QPopupMenu( this );
863 menuBar()->insertItem( tr( "&Help" ), menu );
866 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
867 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
870 a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
871 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
874 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
875 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
880 void Main::setupContextMenus()
884 // Context Menu for branch or mapcenter
885 branchContextMenu =new QPopupMenu (this);
888 branchAddContextMenu =new QPopupMenu (this);
889 actionEditPaste->addTo ( branchAddContextMenu );
890 actionEditAddBranch->addTo ( branchAddContextMenu );
891 actionEditAddBranchHere->addTo ( branchAddContextMenu );
892 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
893 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
894 branchAddContextMenu->insertSeparator();
895 actionEditLoadImage->addTo( branchAddContextMenu );
896 branchAddContextMenu->insertSeparator();
897 actionEditImportAdd->addTo ( branchAddContextMenu );
898 actionEditImportReplace->addTo ( branchAddContextMenu );
901 branchRemoveContextMenu =new QPopupMenu (this);
902 actionEditCut->addTo ( branchRemoveContextMenu );
903 actionEditDelete->addTo ( branchRemoveContextMenu );
904 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
905 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
907 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
908 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
910 actionEditSaveBranch->addTo( branchContextMenu );
912 branchContextMenu->insertSeparator();
913 actionEditOpenURL->addTo ( branchContextMenu );
914 actionEditURL->addTo ( branchContextMenu );
915 actionEditHeading2URL->addTo ( branchContextMenu );
916 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
917 actionEditBugzilla2URL->addTo( branchContextMenu );
919 branchContextMenu->insertSeparator();
920 actionEditOpenVymLink->addTo ( branchContextMenu );
921 actionEditVymLink->addTo ( branchContextMenu );
922 actionEditDeleteVymLink->addTo ( branchContextMenu );
924 branchContextMenu->insertSeparator();
925 actionGroupFormatFrameTypes->addTo( branchContextMenu );
927 // Context Menu for links in a branch menu
928 // This will be populated "on demand" in MapEditor::updateActions
929 branchContextMenu->insertSeparator();
930 branchLinksContextMenu =new QPopupMenu (this);
931 branchLinksContextMenuDup =new QPopupMenu (this);
932 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
933 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
935 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
936 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
938 // Context menu for floatimage
939 floatimageContextMenu =new QPopupMenu (this);
940 saveImageFormatMenu=new QPopupMenu (this);
941 exportImageFormatMenu=new QPopupMenu (this);
943 QStrList fmt = QImage::outputFormats();
944 for (const char* f = fmt.first(); f; f = fmt.next())
946 saveImageFormatMenu->insertItem( f );
947 exportImageFormatMenu->insertItem( f );
949 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
950 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
951 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
953 floatimageContextMenu->insertSeparator();
954 actionEditCopy->addTo( floatimageContextMenu );
955 actionEditCut->addTo( floatimageContextMenu );
957 floatimageContextMenu->insertSeparator();
958 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
959 a->setToggleAction(true);
960 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
961 a->addTo( floatimageContextMenu);
962 actionEditToggleFloatExport=a;
966 // Context menu for exports
967 exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
969 a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" +QString("...")), 0, this, "exportASCII" );
970 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
971 a->addTo( exportMenu );
973 a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ), 0, this, "exportXML"+QString("...") );
974 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
975 a->addTo( exportMenu );
977 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
979 a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export HTML" ), 0, this, "exportHTML"+QString("...") );
980 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
981 a->addTo( exportMenu );
984 a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" )+QString("..."), ALT + Key_X, this, "exportXHTML" );
985 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
986 a->addTo( exportMenu );
989 // Context menu for canvas
990 canvasContextMenu =new QPopupMenu (this);
991 actionEditMapInfo->addTo( canvasContextMenu );
992 canvasContextMenu->insertSeparator();
993 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
994 canvasContextMenu->insertSeparator();
995 actionFormatLinkColorHint->addTo( canvasContextMenu );
996 actionFormatLinkColor->addTo( canvasContextMenu );
997 actionFormatBackColor->addTo( canvasContextMenu );
999 // Menu for last opened files
1000 // Read settings initially
1002 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1003 for (int i=1;i<=j;i++)
1005 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1006 if (!s.isEmpty() && j<=maxLastMaps)
1009 setupLastMapsMenu();
1010 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1013 void Main::setupLastMapsMenu()
1015 // Remove double entries
1016 QStringList::Iterator it=lastMaps.begin();
1017 QStringList::Iterator jt;
1018 while (it!=lastMaps.end() )
1022 while (jt!=lastMaps.end() )
1025 jt=lastMaps.remove(jt);
1032 // Limit length of list to maxLastMaps
1033 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1035 // build Menu from lastMaps string list
1036 lastMapsMenu->clear();
1037 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1038 lastMapsMenu->insertItem (*it );
1042 void Main::hideEvent (QHideEvent * )
1044 if (!textEditor->isMinimized() ) textEditor->hide();
1047 void Main::showEvent (QShowEvent * )
1049 if (textEditor->showWithMain()) textEditor->showNormal();
1052 bool Main::reallyWriteDirectory(const QString &dir)
1054 QStringList eList = QDir(dir).entryList();
1055 if (eList.first() ==".") eList.pop_front(); // remove "."
1056 if (eList.first() =="..") eList.pop_front(); // remove "."
1057 if (!eList.isEmpty())
1059 QMessageBox mb( "VYM",
1060 tr("The directory ") + dir +
1061 tr(" is not empty. Do you risk to overwrite its contents?"),
1062 QMessageBox::Warning,
1064 QMessageBox::Cancel | QMessageBox::Default,
1065 QMessageBox::QMessageBox::NoButton );
1067 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1068 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1071 case QMessageBox::Yes:
1074 case QMessageBox::Cancel:
1082 QString Main::browseDirectory (const QString &caption)
1084 QFileDialog fd(this,caption);
1085 fd.setMode (QFileDialog::DirectoryOnly);
1086 fd.setCaption("VYM - "+caption);
1089 if ( fd.exec() == QDialog::Accepted )
1090 return fd.selectedFile();
1095 MapEditor* Main::currentMapEditor() const
1097 if ( tabWidget->currentPage() &&
1098 tabWidget->currentPage()->inherits( "MapEditor" ) )
1099 return (MapEditor*)tabWidget->currentPage();
1103 //TODO not used now, maybe use this for overview window later
1104 void Main::newView()
1106 // Open a new view... have it delete when closed.
1107 Main *m = new Main(0, 0, WDestructiveClose);
1108 qApp->setMainWidget(m);
1110 qApp->setMainWidget(0);
1113 void Main::editorChanged(QWidget *)
1115 // Unselect all possibly selected objects
1116 // (Important to update note editor)
1119 for (i=0;i<=tabWidget->count() -1;i++)
1122 me=(MapEditor*)tabWidget->page(i);
1125 currentMapEditor()->reselect();
1127 // Update actions to in menus and toolbars according to editor
1128 currentMapEditor()->updateActions();
1131 void Main::fileNew()
1133 QString fn="unnamed";
1134 MapEditor* medit = new MapEditor (tabWidget, true);
1135 tabWidget->addTab (medit,fn);
1136 tabWidget->showPage(medit);
1137 medit->viewport()->setFocus();
1138 medit->select("mc:");
1141 void Main::fileLoad(QString fn, const LoadMode &lmode)
1144 enum errorCode {success,aborted};
1145 errorCode err=success;
1147 // fn is usually the archive, mapfile the file after uncompressing
1150 // Make fn absolute (needed for unzip)
1151 fn=QDir (fn).absPath();
1157 // Check, if map is already loaded
1159 while (i<=tabWidget->count() -1)
1161 me=(MapEditor*)tabWidget->page(i);
1162 if (me->getFilePath() == fn)
1164 // Already there, ask for confirmation
1165 QMessageBox mb( "VYM",
1166 tr("The map ") + fn + tr ("\n is already opened."
1167 "Opening the same map in multiple editors may lead \n"
1168 "to confusion when finishing working with vym."
1170 QMessageBox::Warning,
1171 QMessageBox::Yes | QMessageBox::Default,
1172 QMessageBox::Cancel | QMessageBox::Escape,
1173 QMessageBox::QMessageBox::NoButton);
1174 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1175 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1178 case QMessageBox::Yes:
1180 i=tabWidget->count();
1182 case QMessageBox::Cancel:
1194 if ( !fn.isEmpty() )
1196 me = currentMapEditor();
1197 int tabIndex=tabWidget->currentPageIndex();
1198 // Check first, if mapeditor exists
1199 // If it is not default AND we want a new map,
1200 // create a new mapeditor in a new tab
1201 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1203 me = new MapEditor (tabWidget,true);
1204 tabWidget->addTab (me,fn);
1205 tabIndex=tabWidget->indexOf (me);
1206 tabWidget->setCurrentPage (tabIndex);
1209 // Check, if file exists (important for creating new files
1210 // from command line
1211 if (!QFile(fn).exists() )
1213 QMessageBox mb( "VYM",
1214 tr("This map does not exist:\n ")+fn+tr("\nDo you want to create a new one?"),
1215 QMessageBox::Question,
1217 QMessageBox::Cancel | QMessageBox::Default,
1218 QMessageBox::QMessageBox::NoButton );
1220 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1221 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1224 case QMessageBox::Yes:
1226 currentMapEditor()->setFilePath(fn);
1227 tabWidget->setTabLabel (currentMapEditor(),
1228 currentMapEditor()->getFileName() );
1229 statusBar()->message( "Created " + fn , statusbarTime );
1232 case QMessageBox::Cancel:
1233 // don't create new map
1234 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1241 //tabWidget->currentPage() won't be NULL here, because of above...
1242 tabWidget->showPage(me);
1243 me->viewport()->setFocus();
1245 // Create temporary directory for packing
1246 char tmpdir1[]="/tmp/vym-XXXXXX";
1247 QString tmpMapDir=mkdtemp(tmpdir1);
1249 // Try to unzip file
1250 Process *zipProc=new Process ();
1251 zipProc->clearArguments();
1252 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1253 zipProc->addArgument ("unzip");
1254 zipProc->addArgument (fn );
1255 zipProc->addArgument ("-d");
1256 zipProc->addArgument (tmpMapDir);
1258 if (!zipProc->start() )
1260 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1261 tr("Couldn't start unzip to decompress data."));
1266 zipProc->waitFinished();
1267 if (!zipProc->normalExit() )
1269 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1270 tr("unzip didn't exit normally") +
1271 zipProc->getErrout() );
1275 if (zipProc->exitStatus()>0)
1277 if (zipProc->exitStatus()==9)
1279 // no zipped file, but maybe .xml or old version? Try again.
1281 me->setZipped(false);
1285 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1286 QString("unzip exit code: %1").arg(zipProc->exitStatus() ) +
1287 zipProc->getErrout() );
1291 { // Uncompressing was successfull,
1292 // load from uncompressed temporary directory
1294 me->setZipped(true);
1297 // Look for mapname.xml
1298 mapfile= fn.left(fn.findRev(".",-1,true));
1299 mapfile=mapfile.section( '/', -1 );
1300 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1301 if (!file.exists() )
1303 // mapname.xml does not exist, well,
1304 // maybe some renamed the mapname.vym file...
1305 // Try to find any .xml in the toplevel
1306 // directory of the .vym file
1307 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1308 if (flist.count()==1)
1310 // Only one entry, take this one
1311 mapfile=tmpMapDir + "/"+flist.first();
1314 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1315 *it=tmpMapDir + "/" + *it;
1316 // FIXME Multiple entries, load all (but only the first one into this ME)
1317 //mainWindow->fileLoadFromTmp (flist);
1318 //returnCode=1; // Silently forget this attempt to load
1319 qWarning ("MainWindow::load (fn) multimap found...");
1322 if (flist.isEmpty() )
1324 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1325 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1328 } //file doesn't exist
1330 mapfile=file.name();
1331 } // Uncompressing successfull
1336 // Save existing filename
1337 QString fn_org=me->getFilePath();
1339 // Finally load map into mapEditor
1340 me->setFilePath (mapfile,fn);
1341 if (me->load(mapfile,lmode))
1344 // Restore old (maybe empty) filepath, if this is an import
1346 me->setFilePath (fn_org);
1349 system ( "rm -rf "+tmpMapDir);
1356 me->setFilePath (fn);
1357 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1358 lastMaps.prepend(me->getFilePath() );
1359 setupLastMapsMenu();
1360 actionFilePrint->setEnabled (true);
1362 statusBar()->message( "Loaded " + fn, statusbarTime );
1372 statusBar()->message( "Could not load " + fn, statusbarTime );
1376 void Main::fileLoad(const LoadMode &lmode)
1378 QFileDialog *fd=new QFileDialog( this);
1379 if (!lastFileDir.isEmpty())
1380 fd->setDir (lastFileDir);
1381 fd->addFilter ("XML (*.xml)");
1382 fd->addFilter ("VYM map (*.vym *.vyp)");
1386 fd->setCaption(tr("Load vym map"));
1389 fd->setCaption(tr("Import: Add vym map to selection"));
1392 fd->setCaption(tr("Import: Replace selection with vym map"));
1398 if ( fd->exec() == QDialog::Accepted )
1400 lastFileDir=fd->dirPath();
1401 fn = fd->selectedFile();
1402 fileLoad(fn, lmode);
1406 void Main::fileLoad()
1411 void Main::fileLoadLast(int i)
1413 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1416 void Main::fileSave(const SaveMode &savemode)
1418 // tmp dir for zipping
1422 enum errorCode {success,aborted};
1423 errorCode err=success;
1425 QString safeFilePath;
1427 bool saveZipped=currentMapEditor()->saveZipped();
1429 MapEditor * me=currentMapEditor();
1432 QString fn=me->getFilePath();
1433 // filename=unnamed, filepath="" in constructor...
1434 if ( !fn.isEmpty() )
1436 // We have a filepath, go on saving
1437 // First remove existing file, we
1438 // don't want to add to old zip archives
1442 QMessageBox::warning( 0, tr( "Save Error" ),
1443 fn+ tr("\ncould not be removed before saving"));
1445 // Look, if we should zip the data:
1448 QMessageBox mb( "VYM",
1449 tr("The map ") + fn +
1450 tr ("\ndid not use the compressed "
1451 "vym file format.\nWriting it uncompressed will also write images \n"
1452 "and flags and thus may overwrite files in the "
1453 "given directory\n\nDo you want to write the map"),
1454 QMessageBox::Warning,
1455 QMessageBox::Yes | QMessageBox::Default,
1457 QMessageBox::Cancel | QMessageBox::Escape);
1458 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1459 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1460 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1463 case QMessageBox::Yes:
1464 // save compressed (default file format)
1467 case QMessageBox::No:
1468 // save uncompressed
1471 case QMessageBox::Cancel:
1480 char tmpdir1[]="/tmp/vym-XXXXXX";
1481 tmpMapDir=mkdtemp(tmpdir1);
1483 safeFilePath=me->getFilePath();
1484 me->setFilePath (tmpMapDir+"/"+
1485 me->getMapName()+ ".xml",
1487 me->save (savemode);
1488 me->setFilePath (safeFilePath);
1490 // zip the temporary directory
1491 Process *zipProc=new Process ();
1492 zipProc->clearArguments();
1493 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1494 zipProc->addArgument ("zip");
1495 zipProc->addArgument ("-r");
1496 zipProc->addArgument (fn);
1497 zipProc->addArgument (".");
1499 if (!zipProc->start() )
1501 // zip could not be started
1502 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1503 tr("Couldn't start zip to compress data."));
1507 // zip could be started
1508 zipProc->waitFinished();
1509 if (!zipProc->normalExit() )
1511 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1512 tr("zip didn't exit normally")+
1513 "\n" + zipProc->getErrout());
1517 if (zipProc->exitStatus()>0)
1519 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1520 QString("zip exit code: %1").arg(zipProc->exitStatus() )+
1521 "\n" + zipProc->getErrout() );
1525 } // zip could be started
1530 safeFilePath=me->getFilePath();
1531 me->setFilePath (fn, safeFilePath);
1532 me->save (savemode);
1533 me->setFilePath (safeFilePath);
1535 } // filepath available
1538 // We have no filepath yet,
1539 // call fileSaveAs() now, this will call fileSave()
1541 fileSaveAs(savemode);
1545 if (me->saveZipped())
1548 system ( "rm -rf "+ tmpMapDir );
1553 statusBar()->message(
1554 tr("Saved")+" " + me->getFilePath(),
1556 lastMaps.prepend(me->getFilePath() );
1557 setupLastMapsMenu();
1559 statusBar()->message(
1560 tr("Couldn't save")+" " + me->getFilePath(),
1564 void Main::fileSave()
1566 fileSave (CompleteMap);
1569 void Main::fileSaveAs(const SaveMode& savemode)
1574 if (currentMapEditor())
1576 if (savemode==CompleteMap)
1577 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1579 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1580 if ( !fn.isEmpty() )
1582 // Check for existing file
1583 if (QFile (fn).exists())
1585 QMessageBox mb( "VYM",
1586 tr("The file ") + fn + tr ("\nexists already. Do you want to"),
1587 QMessageBox::Warning,
1588 QMessageBox::Yes | QMessageBox::Default,
1589 QMessageBox::Cancel | QMessageBox::Escape,
1590 QMessageBox::QMessageBox::NoButton);
1591 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1592 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1595 case QMessageBox::Yes:
1598 case QMessageBox::Cancel:
1605 // New file, add extension to filename, if missing
1606 // This is always .vym or .vyp, depending on savemode
1607 if (savemode==CompleteMap)
1609 if (!fn.contains (".vym") && !fn.contains (".xml"))
1613 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1622 currentMapEditor()->setFilePath(fn);
1626 if (savemode==CompleteMap)
1627 tabWidget->setTabLabel (currentMapEditor(),
1628 currentMapEditor()->getFileName() );
1634 void Main::fileSaveAs()
1636 fileSaveAs (CompleteMap);
1639 void Main::fileImportDir()
1641 if (currentMapEditor())
1642 currentMapEditor()->importDir();
1645 void Main::fileExportXML()
1647 if (currentMapEditor())
1649 QString dir=browseDirectory(tr("Export XML to directory"));
1650 if (dir !="" && reallyWriteDirectory(dir) )
1651 currentMapEditor()->exportXML(dir);
1655 void Main::fileExportHTML()
1657 if (currentMapEditor())
1659 ExportHTMLDialog dia(this);
1661 if (dia.exec()==QDialog::Accepted)
1663 QString dir=dia.getDir();
1664 if (reallyWriteDirectory(dir) )
1666 currentMapEditor()->exportXML (dia.getDir() );
1667 dia.doExport(currentMapEditor()->getMapName() );
1673 void Main::fileExportXHTML()
1676 if (currentMapEditor())
1678 ExportXHTMLDialog dia(this);
1679 dia.setFilePath (currentMapEditor()->getFilePath() );
1680 dia.setMapName (currentMapEditor()->getMapName() );
1683 if (dia.exec()==QDialog::Accepted)
1685 QString dir=dia.getDir();
1686 // Check, if warnings should be used before overwriting
1687 // the output directory
1690 ok=reallyWriteDirectory(dir);
1696 currentMapEditor()->exportXML (dia.getDir() );
1697 dia.doExport(currentMapEditor()->getMapName() );
1698 if (dia.hasChanged())
1699 currentMapEditor()->setChanged();
1705 void Main::fileExportImage(int item)
1707 if (currentMapEditor())
1709 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1711 if ( !fn.isEmpty() )
1713 currentMapEditor()->exportImage(fn,item);
1715 statusBar()->message( tr("Couldn't save") + fn, statusbarTime );
1720 void Main::fileExportASCII()
1722 if (currentMapEditor())
1723 currentMapEditor()->exportASCII();
1726 void Main::fileCloseMap()
1728 if (currentMapEditor())
1730 if (currentMapEditor()->hasChanged())
1732 QMessageBox mb( "VYM",
1733 tr("The map ") + currentMapEditor()->getFileName() +
1734 tr(" has been modified but not saved yet. Do you want to"),
1735 QMessageBox::Warning,
1736 QMessageBox::Yes | QMessageBox::Default,
1738 QMessageBox::Cancel | QMessageBox::Escape );
1739 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1740 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1743 case QMessageBox::Yes:
1745 fileSave(CompleteMap);
1747 case QMessageBox::No:
1748 // close without saving
1750 case QMessageBox::Cancel:
1755 currentMapEditor()->closeMap();
1756 tabWidget->removePage(currentMapEditor());
1757 if (tabWidget->count()==0)
1758 actionFilePrint->setEnabled (false);
1762 void Main::filePrint()
1764 if (currentMapEditor())
1765 currentMapEditor()->print();
1768 void Main::fileExitVYM()
1770 // Check if one or more editors have changed
1773 for (i=0;i<=tabWidget->count() -1;i++)
1776 me=(MapEditor*)tabWidget->page(i);
1778 // If something changed, ask what to do
1779 if (me->isUnsaved())
1781 tabWidget->setCurrentPage(i);
1782 QMessageBox mb( "VYM",
1783 tr("This map is not saved yet. Do you want to"),
1784 QMessageBox::Warning,
1785 QMessageBox::Yes | QMessageBox::Default,
1787 QMessageBox::Cancel | QMessageBox::Escape );
1788 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1789 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1791 // Call undocumented function: setActiveWindow is only
1792 // possible, if widget is visible. This depends on
1794 #if defined(Q_OS_LINUX)
1795 qt_wait_for_window_manager( this);
1797 mb.setActiveWindow();
1798 switch( mb.exec() ) {
1799 case QMessageBox::Yes:
1800 // save (the changed editors) and exit
1801 fileSave(CompleteMap);
1803 case QMessageBox::No:
1804 // exit without saving
1806 case QMessageBox::Cancel:
1807 // don't save and don't exit
1811 } // loop over all MEs
1815 void Main::editUndo()
1817 if (currentMapEditor())
1818 currentMapEditor()->undo();
1821 void Main::editRedo() // TODO
1825 void Main::editCopy()
1827 if (currentMapEditor())
1828 currentMapEditor()->copy();
1831 void Main::editPaste()
1833 if (currentMapEditor())
1834 currentMapEditor()->paste();
1837 void Main::editCut()
1839 if (currentMapEditor())
1840 currentMapEditor()->cut();
1843 void Main::editOpenFindWindow()
1845 findWindow->popup();
1846 findWindow->raise();
1848 // Call undocumented function: setActiveWindow is only
1849 // possible, if widget is visible. This depends on
1851 #if defined(Q_OS_LINUX)
1852 qt_wait_for_window_manager( this);
1854 findWindow->setActiveWindow();
1857 void Main::editFind(QString s)
1860 BranchObj *bo=currentMapEditor()->findText(s, cs);
1863 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
1866 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
1867 tr("No matches found for ")+
1872 void Main::editFindChanged()
1873 { // Notify editor, to abort the current find process
1874 currentMapEditor()->findReset();
1877 void Main::editOpenURL()
1879 if (currentMapEditor())
1880 currentMapEditor()->openURL();
1883 void Main::editURL()
1885 if (currentMapEditor())
1886 currentMapEditor()->editURL();
1889 void Main::editHeading2URL()
1891 if (currentMapEditor())
1892 currentMapEditor()->editHeading2URL();
1895 void Main::editBugzilla2URL()
1897 if (currentMapEditor())
1898 currentMapEditor()->editBugzilla2URL();
1901 void Main::editOpenVymLink()
1903 // Get current path to map
1904 QString currentVymLink;
1905 if (currentMapEditor())
1907 currentVymLink=currentMapEditor()->getVymLink();
1908 // compare path with already loaded maps
1912 for (i=0;i<=tabWidget->count() -1;i++)
1914 me=(MapEditor*)tabWidget->page(i);
1915 if (currentVymLink==me->getFilePath() )
1924 if (!QFile(currentVymLink).exists() )
1925 QMessageBox::critical( 0, tr( "Critical Error" ),
1926 tr("Couldn't open map " +currentVymLink)+".");
1929 fileLoad (currentVymLink, NewMap);
1930 tabWidget->setCurrentPage (tabWidget->count()-1);
1933 // Go to tab containing the map
1934 tabWidget->setCurrentPage (index);
1938 void Main::editVymLink()
1940 if (currentMapEditor())
1941 currentMapEditor()->editVymLink();
1944 void Main::editDeleteVymLink()
1946 if (currentMapEditor())
1947 currentMapEditor()->deleteVymLink();
1950 void Main::editMapInfo()
1952 if (currentMapEditor())
1953 currentMapEditor()->editMapInfo();
1956 void Main::editMoveUp()
1958 if (currentMapEditor())
1959 currentMapEditor()->moveBranchUp();
1962 void Main::editMoveDown()
1964 if (currentMapEditor())
1965 currentMapEditor()->moveBranchDown();
1968 void Main::editToggleScroll()
1970 if (currentMapEditor())
1972 currentMapEditor()->toggleScroll();
1976 void Main::editUnScrollAll()
1978 if (currentMapEditor())
1980 currentMapEditor()->unScrollAll();
1984 void Main::editHeading()
1986 if (currentMapEditor())
1987 currentMapEditor()->editHeading();
1990 void Main::editNewBranch()
1992 if (currentMapEditor())
1993 currentMapEditor()->addNewBranch(0);
1996 void Main::editNewBranchHere()
1998 if (currentMapEditor())
1999 currentMapEditor()->addNewBranchHere();
2002 void Main::editNewBranchAbove()
2004 if (currentMapEditor())
2005 currentMapEditor()->addNewBranch(-1);
2008 void Main::editNewBranchBelow()
2010 if (currentMapEditor())
2011 currentMapEditor()->addNewBranch(1);
2014 void Main::editImportAdd()
2016 fileLoad (ImportAdd);
2019 void Main::editImportReplace()
2021 fileLoad (ImportReplace);
2024 void Main::editSaveBranch()
2026 fileSaveAs (PartOfMap);
2029 void Main::editRemoveBranchHere()
2031 if (currentMapEditor())
2032 currentMapEditor()->removeBranchHere();
2035 void Main::editRemoveChilds()
2037 if (currentMapEditor())
2038 currentMapEditor()->removeChilds();
2041 void Main::editDeleteSelection()
2043 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2044 currentMapEditor()->deleteSelection();
2047 void Main::editUpperBranch()
2049 if (currentMapEditor())
2050 currentMapEditor()->selectUpperBranch();
2053 void Main::editLowerBranch()
2055 if (currentMapEditor())
2056 currentMapEditor()->selectLowerBranch();
2059 void Main::editLeftBranch()
2061 if (currentMapEditor())
2062 currentMapEditor()->selectLeftBranch();
2065 void Main::editRightBranch()
2067 if (currentMapEditor())
2068 currentMapEditor()->selectRightBranch();
2071 void Main::editFirstBranch()
2073 if (currentMapEditor())
2074 currentMapEditor()->selectFirstBranch();
2077 void Main::editLastBranch()
2079 if (currentMapEditor())
2080 currentMapEditor()->selectLastBranch();
2083 void Main::editLoadImage()
2085 if (currentMapEditor())
2086 currentMapEditor()->loadFloatImage();
2089 void Main::editSaveImage(int item)
2091 if (currentMapEditor())
2092 currentMapEditor()->saveFloatImage(item);
2095 void Main::editToggleFloatExport()
2097 if (currentMapEditor())
2098 currentMapEditor()->toggleFloatExport();
2101 void Main::editFollowXLink(int item)
2103 if (currentMapEditor())
2104 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2107 void Main::editEditXLink(int item)
2109 if (currentMapEditor())
2110 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2113 void Main::formatSelectColor()
2115 if (currentMapEditor())
2117 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2118 if ( !col.isValid() ) return;
2119 currentMapEditor()->setColor( col );
2120 colorChanged( col );
2124 void Main::formatPickColor()
2126 if (currentMapEditor())
2127 colorChanged( currentMapEditor()->pickColor() );
2130 void Main::colorChanged(QColor c)
2132 QPixmap pix( 16, 16 );
2134 actionFormatColor->setIconSet( pix );
2137 void Main::formatColorItem()
2139 if (currentMapEditor())
2140 currentMapEditor()->colorItem();
2143 void Main::formatColorBranch()
2145 if (currentMapEditor())
2146 currentMapEditor()->colorBranch();
2149 void Main::formatLinkStyleLine()
2151 if (currentMapEditor())
2152 currentMapEditor()->setLinkStyle(StyleLine);
2155 void Main::formatLinkStyleParabel()
2157 if (currentMapEditor())
2158 currentMapEditor()->setLinkStyle(StyleParabel);
2161 void Main::formatLinkStylePolyLine()
2163 if (currentMapEditor())
2164 currentMapEditor()->setLinkStyle(StylePolyLine);
2167 void Main::formatLinkStylePolyParabel()
2169 if (currentMapEditor())
2170 currentMapEditor()->setLinkStyle(StylePolyParabel);
2173 void Main::formatSelectBackColor()
2175 if (currentMapEditor())
2176 currentMapEditor()->selectBackgroundColor();
2179 void Main::formatSelectLinkColor()
2181 if (currentMapEditor())
2182 currentMapEditor()->selectLinkColor();
2185 void Main::formatToggleLinkColorHint()
2187 currentMapEditor()->toggleLinkColorHint();
2190 void Main::formatFrameNone()
2192 if (currentMapEditor())
2193 currentMapEditor()->setFrame(NoFrame);
2196 void Main::formatFrameRectangle()
2198 if (currentMapEditor())
2199 currentMapEditor()->setFrame(Rectangle);
2202 void Main::viewZoomReset()
2204 if (currentMapEditor())
2208 currentMapEditor()->setWorldMatrix( m );
2209 currentMapEditor()->setViewCenter();
2210 currentMapEditor()->adjustCanvasSize();
2214 void Main::viewZoomIn()
2216 if (currentMapEditor())
2218 QWMatrix m = currentMapEditor()->worldMatrix();
2219 m.scale( 1.25, 1.25 );
2220 currentMapEditor()->setWorldMatrix( m );
2221 currentMapEditor()->setViewCenter();
2222 currentMapEditor()->adjustCanvasSize();
2226 void Main::viewZoomOut()
2228 if (currentMapEditor())
2230 QWMatrix m = currentMapEditor()->worldMatrix();
2231 m.scale( 0.8, 0.8 );
2232 currentMapEditor()->setWorldMatrix( m );
2233 currentMapEditor()->setViewCenter();
2234 currentMapEditor()->adjustCanvasSize();
2238 void Main::modModeColor()
2242 void Main::modModeLink()
2246 bool Main::settingsPDF()
2248 // Default browser is set in constructor
2250 QString text = QInputDialog::getText(
2251 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2252 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2254 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2259 bool Main::settingsURL()
2261 // Default browser is set in constructor
2263 QString text = QInputDialog::getText(
2264 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2265 settings.readEntry("/vym/mainwindow/readerURL")
2268 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2272 void Main::windowToggleNoteEditor()
2274 if (textEditor->showWithMain() )
2275 windowHideNoteEditor();
2277 windowShowNoteEditor();
2280 void Main::windowShowNoteEditor()
2282 textEditor->setShowWithMain(true);
2284 actionViewToggleNoteEditor->setOn (true);
2287 void Main::windowHideNoteEditor()
2289 textEditor->setShowWithMain(false);
2291 actionViewToggleNoteEditor->setOn (false);
2294 void Main::windowNextEditor()
2296 if (tabWidget->currentPageIndex() < tabWidget->count())
2297 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2300 void Main::windowPreviousEditor()
2302 if (tabWidget->currentPageIndex() >0)
2303 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2306 void Main::standardFlagChanged()
2308 currentMapEditor()->toggleStandardFlag(sender()->name());
2311 void Main::testFunction()
2313 //textEditor->stackUnder(this);
2314 currentMapEditor()->testFunction();
2317 void Main::testShowClipboard()
2319 clipboardME->show();
2322 void Main::helpDoc()
2325 #if defined(Q_OS_MACX)
2326 docpath="./vym.app/Contents/vym.pdf";
2328 // default path in SUSE LINUX
2329 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2332 if (!QFile (docpath).exists() )
2334 // relative path for easy testing in tarball
2335 docpath="doc/vym.pdf";
2336 if (!QFile (docpath).exists() )
2338 // relative path for testing while still writing vym.tex
2339 docpath="doc/tex/vym.pdf";
2340 if (!QFile (docpath).exists() )
2342 QMessageBox::critical(0,
2343 tr("Critcal error"),
2344 tr("Couldn't find the documentation\n"
2345 "vym.pdf in various places."));
2351 Process *pdfProc = new Process();
2352 pdfProc->clearArguments();
2353 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2354 pdfProc->addArgument( docpath);
2356 if ( !pdfProc->start() )
2359 QMessageBox::critical(0,
2360 tr("Critcal error"),
2361 tr("Couldn't find a viewer to read vym.pdf.\n"
2362 "Please use Settings->")+tr("Set application to open pdf files"));
2368 void Main::helpAbout()
2371 ad.setName ("aboutwindow");
2372 ad.setMinimumSize(500,500);
2373 ad.resize (QSize (500,500));
2377 void Main::helpAboutQT()
2379 QMessageBox::aboutQt( this, "Qt Application Example" );