1 #include "mainwindow.h"
3 #include <qstatusbar.h>
4 #include <qmessagebox.h>
6 #include <qapplication.h>
10 #include <qfiledialog.h>
12 #include <qcolordialog.h>
14 #include <qinputdialog.h>
15 #include <qdatetime.h> // for random seed
24 #include "icons/filenew.xpm"
25 #include "icons/fileopen.xpm"
26 #include "icons/filesave.xpm"
27 #include "icons/fileprint.xpm"
28 #include "icons/editundo.xpm"
29 //#include "icons/editredo.xpm" // TODO
30 #include "icons/editcopy.xpm"
31 #include "icons/editcut.xpm"
32 #include "icons/editpaste.xpm"
33 #include "icons/editmoveup.xpm"
34 #include "icons/editmovedown.xpm"
35 #include "icons/formatcoloritem.xpm"
36 #include "icons/formatcolorbranch.xpm"
37 #include "icons/formatcolorpicker.xpm"
38 #include "icons/viewzoomreset.xpm"
39 #include "icons/viewzoomin.xpm"
40 #include "icons/viewzoomout.xpm"
41 #include "icons/modecolor.xpm"
42 #include "icons/modelink.xpm"
43 #include "icons/modecopy.xpm"
44 #include "icons/vym-48x48.xpm"
45 #include "icons/flag-note.xpm"
46 #include "icons/flag-url.xpm"
47 #include "icons/flag-vymlink.xpm"
48 #include "icons/flag-scrolled-right.xpm"
50 #include "flagrowobj.h"
51 #include "texteditor.h"
52 #include "mapeditor.h"
53 #include "exporthtmldialog.h"
54 #include "exportxhtmldialog.h"
55 #include "showtextdialog.h"
60 extern TextEditor *textEditor;
61 extern Main *mainWindow;
62 extern int statusbarTime;
63 extern MapEditor *clipboardME;
64 extern FlagRowObj* standardFlagsDefault;
66 extern QPtrList <QAction> actionListBranches;
68 extern QAction* actionFileSave;
69 extern QAction* actionFilePrint;
70 extern QAction* actionEditUndo;
71 extern QAction *actionEditCopy;
72 extern QAction *actionEditCut;
73 extern QAction *actionEditPaste;
74 extern QAction *actionEditMoveUp;
75 extern QAction *actionEditMoveDown;
76 extern QAction *actionEditToggleScroll;
77 extern QAction* actionEditOpenURL;
78 extern QAction* actionEditURL;
79 extern QAction* actionEditHeading2URL;
80 extern QAction* actionEditBugzilla2URL;
81 extern QAction *actionEditOpenVymLink;
82 extern QAction *actionEditVymLink;
83 extern QAction *actionEditDeleteVymLink;
84 extern QAction *actionEditMapInfo;
85 extern QAction *actionEditHeading;
86 extern QAction *actionEditDelete;
87 extern QAction *actionEditAddBranch;
88 extern QAction *actionEditAddBranchHere;
89 extern QAction *actionEditAddBranchAbove;
90 extern QAction *actionEditAddBranchBelow;
91 extern QAction *actionEditRemoveBranchHere;
92 extern QAction *actionEditRemoveChilds;
93 extern QAction *actionEditImportAdd;
94 extern QAction *actionEditImportReplace;
95 extern QAction *actionEditSaveBranch;
96 extern QAction *actionEditSelectFirst;
97 extern QAction *actionEditSelectLast;
98 extern QAction *actionEditLoadImage;
99 extern QAction *actionEditToggleFloatExport;
101 extern QAction* actionFormatColor;
102 extern QAction* actionFormatPickColor;
103 extern QAction* actionFormatColorBranch;
104 extern QAction* actionFormatColorSubtree;
105 extern QAction* actionFormatLinkColorHint;
106 extern QAction* actionFormatBackColor;
107 extern QAction* actionFormatLinkColor;
109 extern QActionGroup* actionGroupModModes;
110 extern QAction* actionModModeColor;
111 extern QAction* actionModModeLink;
112 extern QAction* actionModModeCopy;
114 extern QActionGroup *actionGroupFormatFrameTypes;
115 extern QAction *actionFormatFrameNone;
116 extern QAction *actionFormatFrameRectangle;
118 extern QActionGroup *actionGroupFormatLinkStyles;
119 extern QAction *actionFormatLinkStyleLine;
120 extern QAction *actionFormatLinkStyleParabel;
121 extern QAction *actionFormatLinkStylePolyLine;
122 extern QAction *actionFormatLinkStylePolyParabel;
124 extern QAction *actionViewToggleNoteEditor;
126 extern QAction* actionSettingsAutoedit;
127 extern QAction* actionSettingsAutoselectHeading;
128 extern QAction* actionSettingsAutoselectHeading;
129 extern QAction* actionSettingsAutoselectText;
130 extern QAction* actionSettingsPasteNewHeading;
131 extern QAction* actionSettingsUseDelKey;
133 extern QPopupMenu* branchContextMenu;
134 extern QPopupMenu* branchAddContextMenu;
135 extern QPopupMenu* branchRemoveContextMenu;
136 extern QPopupMenu* branchLinksContextMenu;
137 extern QPopupMenu* branchLinksContextMenuDup;
138 extern QPopupMenu* floatimageContextMenu;
139 extern QPopupMenu* saveImageFormatMenu;
140 extern QPopupMenu* canvasContextMenu;
141 extern QPopupMenu* lastMapsMenu;
142 extern QPopupMenu* exportMenu;
143 extern QPopupMenu* exportImageFormatMenu;
146 extern Settings settings;
147 extern Options options;
149 #if defined(Q_OS_LINUX)
150 extern void qt_wait_for_window_manager( QWidget* w );
153 Main::Main(QWidget* parent, const char* name, WFlags f) :
154 QMainWindow(parent,name,f)
158 setCaption ("VYM - View Your Mind");
160 // Load window settings
161 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
162 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
163 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
164 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
167 // Set random seed (random used for object IDs)
168 QTime t = QTime::currentTime(); // set random seed
169 srand( t.hour()*12+t.minute()*60+t.second()*60 );
172 // Initialize some settings, which are platform dependant
175 // application to open URLs
176 p="/vym/mainwindow/readerURL";
177 #if defined(Q_OS_LINUX)
178 s=settings.readEntry (p,"konqueror");
180 #if defined(Q_OS_MACX)
181 s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
183 s=settings.readEntry (p,"mozilla");
186 settings.writeEntry( p,s);
188 // application to open PDFs
189 p="/vym/mainwindow/readerPDF";
190 #if defined(Q_OS_LINUX)
191 s=settings.readEntry (p,"acroread");
193 #if defined(Q_OS_MACX)
194 s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
196 s=settings.readEntry (p,"acroread");
199 settings.writeEntry( p,s);
204 // Create tab widget which holds the maps
205 tabWidget= new QTabWidget (this);
206 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
207 this, SLOT( editorChanged( QWidget * ) ) );
209 setCentralWidget(tabWidget);
213 setupFormatActions();
217 setupSettingsActions();
219 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
222 // After menu is created, we can enable some actions
223 actionFilePrint->setEnabled (true);
228 // Initialize Find window
229 findWindow=new FindWindow(NULL,"findwindow");
230 connect (findWindow, SIGNAL( findButton(QString) ),
231 this, SLOT(editFind(QString) ) );
232 connect (findWindow, SIGNAL( somethingChanged() ),
233 this, SLOT(editFindChanged() ) );
237 // Creating the default map into first tab is done in main.cpp now...
243 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
244 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
245 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
246 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
248 settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
249 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
251 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
252 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
253 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
254 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
255 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
258 int maps=lastMaps.count();
259 settings.writeEntry( "/vym/lastMaps/number",maps );
260 for (int i=1;i<=maps;i++)
262 QStringList::Iterator it = lastMaps.at(i-1);
263 s=QString("/vym/lastMaps/map-%1").arg(i);
264 if (!s.isEmpty() && i<=maxLastMaps)
265 settings.writeEntry (s, *it);
269 // To make the texteditor save its settings, call the destructor
273 void Main::loadCmdLine()
275 /* TODO draw some kind of splashscreen while loading...
281 QStringList flist=options.getFileList();
282 QStringList::Iterator it=flist.begin();
284 while (it !=flist.end() )
286 fileLoad (*it, NewMap);
292 void Main::statusMessage(const QString &s)
294 statusBar()->message (s);
297 void Main::closeEvent (QCloseEvent* )
303 void Main::setupFileActions()
305 QToolBar *tb = new QToolBar( this );
306 tb->setLabel( "File Actions" );
307 QPopupMenu *menu = new QPopupMenu( this );
308 menuBar()->insertItem( tr( "&File" ), menu );
310 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
313 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
314 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
318 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
319 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
323 lastMapsMenu = new QPopupMenu (this);
325 menu->insertItem (tr("Open Recent"),lastMapsMenu );
326 menu->insertSeparator();
328 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
329 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
334 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
335 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
338 menu->insertSeparator();
340 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir" ), 0, this, "export" );
341 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
344 exportMenu = new QPopupMenu (this);
345 menu->insertItem (tr("Export"),exportMenu );
347 menu->insertSeparator();
350 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
351 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
356 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
357 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
360 a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
361 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
367 void Main::setupEditActions()
369 QToolBar *tb = new QToolBar( this );
370 tb->setLabel( "Edit Actions" );
371 QPopupMenu *menu = new QPopupMenu( this );
372 menuBar()->insertItem( tr( "&Edit" ), menu );
375 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
376 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
377 a->setEnabled (false);
382 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
383 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
387 menu->insertSeparator();
388 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
389 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
390 a->setEnabled (false);
394 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
395 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
396 a->setEnabled (false);
400 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
401 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
402 a->setEnabled (false);
407 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
408 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
409 a->setEnabled (false);
412 actionListBranches.append(a);
415 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
416 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
417 a->setEnabled (false);
420 actionListBranches.append(a);
421 actionEditMoveDown=a;
424 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
425 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
426 a->setEnabled (false);
429 actionListBranches.append(a);
430 actionEditToggleScroll=a;
432 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
433 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
436 menu->insertSeparator();
438 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find" ), CTRL + Key_F, this, "find" );
439 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
442 menu->insertSeparator();
444 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
445 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
448 a->setEnabled (false);
451 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL" ), SHIFT + CTRL + Key_U, this, "url" );
452 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
454 a->setEnabled (false);
455 actionListBranches.append(a);
458 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
459 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
461 a->setEnabled (false);
462 actionListBranches.append(a);
463 actionEditHeading2URL=a;
465 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
466 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
467 a->setEnabled (false);
468 actionListBranches.append(a);
469 actionEditBugzilla2URL=a;
471 menu->insertSeparator();
473 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" );
474 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
477 a->setEnabled (false);
478 actionEditOpenVymLink=a;
480 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link" ), 0, this, "editLinkMap" );
481 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
483 a->setEnabled (false);
484 actionListBranches.append(a);
487 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
488 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
490 a->setEnabled (false);
491 actionEditDeleteVymLink=a;
493 menu->insertSeparator();
495 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info" ), 0, this, "editMapInfo" );
496 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
498 a->setEnabled (true);
501 menu->insertSeparator();
503 // Shortcuts to modify heading:
504 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
505 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
506 a->setEnabled (false);
508 actionListBranches.append(a);
510 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
511 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
512 actionListBranches.append(a);
514 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
515 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
516 actionListBranches.append(a);
518 // Shortcut to delete selection
519 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
520 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
521 a->setEnabled (false);
525 // Shortcut to add branch
526 #if defined (Q_OS_MACX)
527 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), CTRL + Key_I, this, "newBranch" );
529 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
531 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
532 a->setEnabled (false);
533 actionListBranches.append(a);
534 actionEditAddBranch=a;
536 // Add branch by inserting it at selection
537 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
538 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
539 a->setEnabled (false);
540 actionListBranches.append(a);
541 actionEditAddBranchHere=a;
544 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
545 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
546 a->setEnabled (false);
547 actionListBranches.append(a);
548 actionEditAddBranchAbove=a;
551 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
552 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
553 a->setEnabled (false);
554 actionListBranches.append(a);
555 actionEditAddBranchBelow=a;
557 // Import at selection (adding to selection)
558 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
559 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
560 a->setEnabled (false);
561 actionListBranches.append(a);
562 actionEditImportAdd=a;
564 // Import at selection (replacing selection)
565 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
566 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
567 a->setEnabled (false);
568 actionListBranches.append(a);
569 actionEditImportReplace=a;
572 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
573 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
574 a->setEnabled (false);
575 actionListBranches.append(a);
576 actionEditSaveBranch=a;
578 // Only remove branch, not its childs
579 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
580 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
581 a->setEnabled (false);
582 actionListBranches.append(a);
583 actionEditRemoveBranchHere=a;
585 // Only remove childs of a branch
586 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
587 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
588 a->setEnabled (false);
589 actionListBranches.append(a);
590 actionEditRemoveChilds=a;
592 // Shortcuts for navigating with cursor:
593 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
594 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
595 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
596 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
597 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
598 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
599 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
600 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
601 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
602 a->setEnabled (false);
604 actionListBranches.append(a);
605 actionEditSelectFirst=a;
606 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
607 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
608 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
609 a->setEnabled (false);
611 actionListBranches.append(a);
612 actionEditSelectLast=a;
614 a = new QAction( tr( "Add Image" ),tr( "Add Image" ), 0, this, "loadImage" );
615 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
616 actionEditLoadImage=a;
621 void Main::setupFormatActions()
623 QPopupMenu *menu = new QPopupMenu( this );
624 menuBar()->insertItem( tr( "&Format" ), menu );
626 QToolBar *tb = new QToolBar( this );
630 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" ), 0, this, "formatColor" );
631 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
632 actionFormatColor->addTo( tb );
633 actionFormatColor->addTo( menu );
634 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" );
635 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
636 a->setEnabled (false);
639 actionListBranches.append(a);
640 actionFormatPickColor=a;
641 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
642 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
643 a->setEnabled (false);
646 actionListBranches.append(a);
647 actionFormatColorBranch=a;
648 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
649 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
650 a->setEnabled (false);
653 actionListBranches.append(a);
654 actionFormatColorSubtree=a;
656 menu->insertSeparator();
657 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
658 actionGroupFormatLinkStyles->setExclusive (true);
659 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
660 a->setToggleAction(true);
661 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
662 actionFormatLinkStyleLine=a;
663 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
664 a->setToggleAction(true);
665 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
666 actionFormatLinkStyleParabel=a;
667 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
668 a->setToggleAction(true);
669 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
670 actionFormatLinkStylePolyLine=a;
671 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
672 a->setToggleAction(true);
673 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
674 actionFormatLinkStylePolyParabel=a;
675 actionGroupFormatLinkStyles->addTo (menu);
677 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
678 actionGroupFormatFrameTypes->setExclusive (true);
679 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
680 a->setToggleAction(true);
681 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
682 actionFormatFrameNone=a;
683 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
684 a->setToggleAction(true);
685 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
686 actionFormatFrameRectangle=a;
688 menu->insertSeparator();
689 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
690 a->setToggleAction(true);
691 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
693 actionFormatLinkColorHint=a;
695 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color" ), 0, this, "formatLinkColor" );
696 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
697 actionFormatLinkColor->addTo( menu );
698 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" ), 0, this, "formatBackColor" );
699 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
700 actionFormatBackColor->addTo( menu );
704 void Main::setupViewActions()
706 QToolBar *tb = new QToolBar( this );
707 tb->setLabel( "View Actions" );
708 QPopupMenu *menu = new QPopupMenu( this );
709 menuBar()->insertItem( tr( "&View" ), menu );
712 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), 0, this, "zoomReset" );
713 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
716 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
717 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
720 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
721 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
724 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
725 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
726 a->setToggleAction(true);
727 if (textEditor->showWithMain())
733 actionViewToggleNoteEditor=a;
734 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
735 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
737 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
738 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
743 void Main::setupModeActions()
745 //QPopupMenu *menu = new QPopupMenu( this );
746 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
748 QToolBar *tb = new QToolBar( this );
749 tb->setLabel( tr ("Modes when using modifiers") );
751 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
752 actionGroupModModes->setExclusive (true);
753 //FIXME Linkstyle line???
754 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), tr( "Linkstyle Line" ), Key_K, actionGroupModModes, "modModeColor" );
755 a->setToggleAction(true);
758 actionModModeColor=a;
759 a= new QAction( tr( "Use modifier to draw links" ), QPixmap(modelink_xpm), tr( "Linkstyle Line" ), Key_L, actionGroupModModes, "modModeLink" );
760 //FIXME Linkstyle line???
762 a->setToggleAction(true);
765 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), tr( "Linkstyle Line" ), Key_C, actionGroupModModes, "modModeCopy" );
766 //FIXME Linkstyle line???
768 a->setToggleAction(true);
774 void Main::setupFlagActions()
776 standardFlagsDefault->makeToolbar(this, "Standard Flags");
780 void Main::setupSettingsActions()
782 QPopupMenu *menu = new QPopupMenu( this );
783 menuBar()->insertItem( tr( "&Settings" ), menu );
788 a = new QAction( tr( "Set application to open pdf files" ), QPixmap(), tr( "Set application to open pdf files" ), 0, this, "setPDF" );
789 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
792 a = new QAction( tr( "Set application to open an URL" ), QPixmap(), tr( "Set application to open an URL" ), 0, this, "setURL" );
793 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
796 menu->insertSeparator();
797 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
798 a->setToggleAction(true);
799 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
801 actionSettingsAutoedit=a;
803 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
804 a->setToggleAction(true);
805 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
807 actionSettingsAutoselectHeading=a;
809 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
810 a->setToggleAction(true);
811 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
813 actionSettingsAutoselectText=a;
815 a= new QAction( tr( "Enable pasting into new branch" ), QPixmap(), tr( "Enable pasting into new branch" ), 0, this, "pastenewheading" );
816 a->setToggleAction(true);
817 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
819 actionSettingsPasteNewHeading=a;
821 a= new QAction( tr( "Enable Delete key for deleting branches" ), QPixmap(), tr( "Enable Delete key" ), 0, this, "delkey" );
822 a->setToggleAction(true);
823 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
825 actionSettingsUseDelKey=a;
829 void Main::setupTestActions()
831 QPopupMenu *menu = new QPopupMenu( this );
832 menuBar()->insertItem( tr( "&Test" ), menu );
835 a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
836 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
839 a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
840 connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
845 void Main::setupHelpActions()
847 QPopupMenu *menu = new QPopupMenu( this );
848 menuBar()->insertItem( tr( "&Help" ), menu );
851 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
852 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
855 a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
856 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
859 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
860 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
865 void Main::setupContextMenus()
869 // Context Menu for branch or mapcenter
870 branchContextMenu =new QPopupMenu (this);
873 branchAddContextMenu =new QPopupMenu (this);
874 actionEditPaste->addTo ( branchAddContextMenu );
875 actionEditAddBranch->addTo ( branchAddContextMenu );
876 actionEditAddBranchHere->addTo ( branchAddContextMenu );
877 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
878 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
879 branchAddContextMenu->insertSeparator();
880 actionEditLoadImage->addTo( branchAddContextMenu );
881 branchAddContextMenu->insertSeparator();
882 actionEditImportAdd->addTo ( branchAddContextMenu );
883 actionEditImportReplace->addTo ( branchAddContextMenu );
886 branchRemoveContextMenu =new QPopupMenu (this);
887 actionEditCut->addTo ( branchRemoveContextMenu );
888 actionEditDelete->addTo ( branchRemoveContextMenu );
889 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
890 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
892 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
893 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
895 actionEditSaveBranch->addTo( branchContextMenu );
897 branchContextMenu->insertSeparator();
898 actionEditOpenURL->addTo ( branchContextMenu );
899 actionEditURL->addTo ( branchContextMenu );
900 actionEditHeading2URL->addTo ( branchContextMenu );
901 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
902 actionEditBugzilla2URL->addTo( branchContextMenu );
904 branchContextMenu->insertSeparator();
905 actionEditOpenVymLink->addTo ( branchContextMenu );
906 actionEditVymLink->addTo ( branchContextMenu );
907 actionEditDeleteVymLink->addTo ( branchContextMenu );
909 branchContextMenu->insertSeparator();
910 actionGroupFormatFrameTypes->addTo( branchContextMenu );
912 // Context Menu for links in a branch menu
913 // This will be populated "on demand" in MapEditor::updateActions
914 branchContextMenu->insertSeparator();
915 branchLinksContextMenu =new QPopupMenu (this);
916 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
917 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
919 branchLinksContextMenuDup =new QPopupMenu (this);
920 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
921 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
923 // Context menu for floatimage
924 floatimageContextMenu =new QPopupMenu (this);
925 saveImageFormatMenu=new QPopupMenu (this);
926 exportImageFormatMenu=new QPopupMenu (this);
928 QStrList fmt = QImage::outputFormats();
929 for (const char* f = fmt.first(); f; f = fmt.next())
931 saveImageFormatMenu->insertItem( f );
932 exportImageFormatMenu->insertItem( f );
934 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
935 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
936 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
938 floatimageContextMenu->insertSeparator();
939 actionEditCopy->addTo( floatimageContextMenu );
940 actionEditCut->addTo( floatimageContextMenu );
942 floatimageContextMenu->insertSeparator();
943 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
944 a->setToggleAction(true);
945 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
946 a->addTo( floatimageContextMenu);
947 actionEditToggleFloatExport=a;
951 // Context menu for exports
952 exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
954 a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" ), 0, this, "exportASCII" );
955 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
956 a->addTo( exportMenu );
958 a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ), 0, this, "exportXML" );
959 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
960 a->addTo( exportMenu );
962 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
964 a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export HTML" ), 0, this, "exportHTML" );
965 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
966 a->addTo( exportMenu );
969 a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" ), ALT + Key_X, this, "exportXHTML" );
970 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
971 a->addTo( exportMenu );
974 // Context menu for canvas
975 canvasContextMenu =new QPopupMenu (this);
976 actionEditMapInfo->addTo( canvasContextMenu );
977 canvasContextMenu->insertSeparator();
978 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
979 canvasContextMenu->insertSeparator();
980 actionFormatLinkColorHint->addTo( canvasContextMenu );
981 actionFormatLinkColor->addTo( canvasContextMenu );
982 actionFormatBackColor->addTo( canvasContextMenu );
984 // Menu for last opened files
985 // Read settings initially
987 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
988 for (int i=1;i<=j;i++)
990 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
991 if (!s.isEmpty() && j<=maxLastMaps)
995 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
998 void Main::setupLastMapsMenu()
1000 // Remove double entries
1001 QStringList::Iterator it=lastMaps.begin();
1002 QStringList::Iterator jt;
1003 while (it!=lastMaps.end() )
1007 while (jt!=lastMaps.end() )
1010 jt=lastMaps.remove(jt);
1017 // Limit length of list to maxLastMaps
1018 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1020 // build Menu from lastMaps string list
1021 lastMapsMenu->clear();
1022 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1023 lastMapsMenu->insertItem (*it );
1027 void Main::hideEvent (QHideEvent * )
1029 if (!textEditor->isMinimized() ) textEditor->hide();
1032 void Main::showEvent (QShowEvent * )
1034 if (textEditor->showWithMain()) textEditor->show();
1037 bool Main::reallyWriteDirectory(const QString &dir)
1039 QStringList eList = QDir(dir).entryList();
1040 if (eList.first() ==".") eList.pop_front(); // remove "."
1041 if (eList.first() =="..") eList.pop_front(); // remove "."
1042 if (!eList.isEmpty())
1044 QMessageBox mb( "VYM",
1045 tr("The directory ") + dir +
1046 tr(" is not empty. Do you risk to overwrite its contents?"),
1047 QMessageBox::Warning,
1049 QMessageBox::Cancel | QMessageBox::Default,
1050 QMessageBox::QMessageBox::NoButton );
1052 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1053 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1056 case QMessageBox::Yes:
1059 case QMessageBox::Cancel:
1067 QString Main::browseDirectory (const QString &caption)
1069 QFileDialog fd(this,caption);
1070 fd.setMode (QFileDialog::DirectoryOnly);
1071 fd.setCaption("VYM - "+caption);
1074 if ( fd.exec() == QDialog::Accepted )
1075 return fd.selectedFile();
1080 MapEditor* Main::currentMapEditor() const
1082 if ( tabWidget->currentPage() &&
1083 tabWidget->currentPage()->inherits( "MapEditor" ) )
1084 return (MapEditor*)tabWidget->currentPage();
1088 //TODO not used now, maybe use this for overview window later
1089 void Main::newView()
1091 // Open a new view... have it delete when closed.
1092 Main *m = new Main(0, 0, WDestructiveClose);
1093 qApp->setMainWidget(m);
1095 qApp->setMainWidget(0);
1098 void Main::editorChanged(QWidget *)
1100 // Unselect all possibly selected objects
1101 // (Important to update note editor)
1104 for (i=0;i<=tabWidget->count() -1;i++)
1107 me=(MapEditor*)tabWidget->page(i);
1110 currentMapEditor()->reselect();
1112 // Update actions to in menus and toolbars according to editor
1113 currentMapEditor()->updateActions();
1116 void Main::fileNew()
1118 QString fn="unnamed";
1119 MapEditor* medit = new MapEditor (tabWidget, true);
1120 tabWidget->addTab (medit,fn);
1121 tabWidget->showPage(medit);
1122 medit->viewport()->setFocus();
1123 medit->select("mc:");
1126 void Main::fileLoad(QString fn, const LoadMode &lmode)
1129 enum errorCode {success,aborted};
1130 errorCode err=success;
1132 // fn is usually the archive, mapfile the file after uncompressing
1135 // Make fn absolute (needed for unzip)
1136 fn=QDir (fn).absPath();
1142 // Check, if map is already loaded
1144 while (i<=tabWidget->count() -1)
1146 me=(MapEditor*)tabWidget->page(i);
1147 if (me->getFilePath() == fn)
1149 // Already there, ask for confirmation
1150 QMessageBox mb( "VYM",
1151 tr("The map ") + fn + tr ("\n is already opened."
1152 "Opening the same map in multiple editors may lead \n"
1153 "to confusion when finishing working with vym."
1155 QMessageBox::Warning,
1156 QMessageBox::Yes | QMessageBox::Default,
1157 QMessageBox::Cancel | QMessageBox::Escape,
1158 QMessageBox::QMessageBox::NoButton);
1159 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1160 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1163 case QMessageBox::Yes:
1165 i=tabWidget->count();
1167 case QMessageBox::Cancel:
1179 if ( !fn.isEmpty() )
1181 me = currentMapEditor();
1182 int tabIndex=tabWidget->currentPageIndex();
1183 // Check first, if mapeditor exists
1184 // If it is not default AND we want a new map,
1185 // create a new mapeditor in a new tab
1186 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1188 me = new MapEditor (tabWidget,true);
1189 tabWidget->addTab (me,fn);
1190 tabIndex=tabWidget->indexOf (me);
1191 tabWidget->setCurrentPage (tabIndex);
1194 // Check, if file exists (important for creating new files
1195 // from command line
1196 if (!QFile(fn).exists() )
1198 QMessageBox mb( "VYM",
1199 tr("This map does not exist:\n ")+fn+tr("\nDo you want to create a new one?"),
1200 QMessageBox::Question,
1202 QMessageBox::Cancel | QMessageBox::Default,
1203 QMessageBox::QMessageBox::NoButton );
1205 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1206 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1209 case QMessageBox::Yes:
1211 currentMapEditor()->setFilePath(fn);
1212 tabWidget->setTabLabel (currentMapEditor(),
1213 currentMapEditor()->getFileName() );
1214 statusBar()->message( "Created " + fn , statusbarTime );
1217 case QMessageBox::Cancel:
1218 // don't create new map
1219 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1226 //tabWidget->currentPage() won't be NULL here, because of above...
1227 tabWidget->showPage(me);
1228 me->viewport()->setFocus();
1230 // Create temporary directory for packing
1231 char tmpdir1[]="/tmp/vym-XXXXXX";
1232 QString tmpMapDir=mkdtemp(tmpdir1);
1234 // Try to unzip file
1235 Process *zipProc=new Process ();
1236 zipProc->clearArguments();
1237 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1238 zipProc->addArgument ("unzip");
1239 zipProc->addArgument (fn );
1240 zipProc->addArgument ("-d");
1241 zipProc->addArgument (tmpMapDir);
1243 if (!zipProc->start() )
1245 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1246 tr("Couldn't start unzip to decompress data."));
1251 zipProc->waitFinished();
1252 if (!zipProc->normalExit() )
1254 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1255 tr("unzip didn't exit normally") +
1256 zipProc->getErrout() );
1260 if (zipProc->exitStatus()>0)
1262 if (zipProc->exitStatus()==9)
1264 // no zipped file, but maybe .xml or old version? Try again.
1266 me->setZipped(false);
1270 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1271 QString("unzip exit code: %1").arg(zipProc->exitStatus() ) +
1272 zipProc->getErrout() );
1276 { // Uncompressing was successfull,
1277 // load from uncompressed temporary directory
1279 me->setZipped(true);
1282 // Look for mapname.xml
1283 mapfile= fn.left(fn.findRev(".",-1,true));
1284 mapfile=mapfile.section( '/', -1 );
1285 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1286 if (!file.exists() )
1288 // mapname.xml does not exist, well,
1289 // maybe some renamed the mapname.vym file...
1290 // Try to find any .xml in the toplevel
1291 // directory of the .vym file
1292 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1293 if (flist.count()==1)
1295 // Only one entry, take this one
1296 mapfile=tmpMapDir + "/"+flist.first();
1299 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1300 *it=tmpMapDir + "/" + *it;
1302 // Multiple entries, load all (but only the first one into this ME)
1303 //mainWindow->fileLoadFromTmp (flist);
1304 //returnCode=1; // Silently forget this attempt to load
1305 qWarning ("MainWindow::load (fn) multimap found...");
1308 if (flist.isEmpty() )
1310 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1311 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1314 } //file doesn't exist
1316 mapfile=file.name();
1317 } // Uncompressing successfull
1321 // Finally load map into mapEditor
1322 me->setFilePath (mapfile,fn);
1323 if (me->load(mapfile,lmode))
1327 system ( "rm -rf "+tmpMapDir);
1334 me->setFilePath (fn);
1335 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1336 lastMaps.prepend(me->getFilePath() );
1337 setupLastMapsMenu();
1338 actionFilePrint->setEnabled (true);
1340 statusBar()->message( "Loaded " + fn, statusbarTime );
1350 statusBar()->message( "Could not load " + fn, statusbarTime );
1354 void Main::fileLoad(const LoadMode &lmode)
1356 QFileDialog *fd=new QFileDialog( this);
1357 if (!lastFileDir.isEmpty())
1358 fd->setDir (lastFileDir);
1359 fd->addFilter ("XML (*.xml)");
1360 fd->addFilter ("VYM map (*.vym *.vyp)");
1364 fd->setCaption(tr("Load vym map"));
1367 fd->setCaption(tr("Import: Add vym map to selection"));
1370 fd->setCaption(tr("Import: Replace selection with vym map"));
1376 if ( fd->exec() == QDialog::Accepted )
1378 lastFileDir=fd->dirPath();
1379 fn = fd->selectedFile();
1380 fileLoad(fn, lmode);
1384 void Main::fileLoad()
1389 void Main::fileLoadLast(int i)
1391 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1394 void Main::fileSave(const SaveMode &savemode)
1396 // tmp dir for zipping
1400 enum errorCode {success,aborted};
1401 errorCode err=success;
1403 QString safeFilePath;
1405 bool saveZipped=currentMapEditor()->saveZipped();
1407 if (currentMapEditor())
1409 QString fn=currentMapEditor()->getFilePath();
1410 // filename=unnamed, filepath="" in constructor...
1411 if ( !fn.isEmpty() )
1413 // We have a filepath, go on saving
1414 // First remove existing file, we
1415 // don't want to add to old zip archives
1419 QMessageBox::warning( 0, tr( "Save Error" ),
1420 fn+ tr("\ncould not be removed before saving"));
1422 // Look, if we should zip the data:
1425 QMessageBox mb( "VYM",
1426 tr("The map ") + fn +
1427 tr ("\ndid not use the compressed "
1428 "vym file format.\nWriting it uncompressed will also write images \n"
1429 "and flags and thus may overwrite files in the "
1430 "given directory\n\nDo you want to write the map"),
1431 QMessageBox::Warning,
1432 QMessageBox::Yes | QMessageBox::Default,
1434 QMessageBox::Cancel | QMessageBox::Escape);
1435 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1436 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1437 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1440 case QMessageBox::Yes:
1441 // save compressed (default file format)
1444 case QMessageBox::No:
1445 // save uncompressed
1448 case QMessageBox::Cancel:
1457 char tmpdir1[]="/tmp/vym-XXXXXX";
1458 tmpMapDir=mkdtemp(tmpdir1);
1460 safeFilePath=currentMapEditor()->getFilePath();
1461 currentMapEditor()->setFilePath (tmpMapDir+"/"+
1462 currentMapEditor()->getMapName()+ ".xml",
1464 currentMapEditor()->save (savemode);
1465 currentMapEditor()->setFilePath (safeFilePath);
1467 // zip the temporary directory
1468 Process *zipProc=new Process ();
1469 zipProc->clearArguments();
1470 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1471 zipProc->addArgument ("zip");
1472 zipProc->addArgument ("-r");
1473 zipProc->addArgument (fn);
1474 zipProc->addArgument (".");
1476 if (!zipProc->start() )
1478 // zip could not be started
1479 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1480 tr("Couldn't start zip to compress data."));
1484 // zip could be started
1485 zipProc->waitFinished();
1486 if (!zipProc->normalExit() )
1488 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1489 tr("zip didn't exit normally")+
1490 "\n" + zipProc->getErrout());
1494 if (zipProc->exitStatus()>0)
1496 QMessageBox::critical( 0, tr( "Critical Save Error" ),
1497 QString("zip exit code: %1").arg(zipProc->exitStatus() )+
1498 "\n" + zipProc->getErrout() );
1502 } // zip could be started
1507 safeFilePath=currentMapEditor()->getFilePath();
1508 currentMapEditor()->setFilePath (fn, safeFilePath);
1509 currentMapEditor()->save (savemode);
1510 currentMapEditor()->setFilePath (safeFilePath);
1512 } // filepath available
1515 // We have no filepath yet,
1516 // call fileSaveAs() now, this will call fileSave()
1518 fileSaveAs(savemode);
1522 if (currentMapEditor()->saveZipped())
1525 system ( "rm -rf "+ tmpMapDir );
1529 statusBar()->message(
1530 tr("Saved")+" " + currentMapEditor()->getFilePath(),
1533 statusBar()->message(
1534 tr("Couldn't save")+" " + currentMapEditor()->getFilePath(),
1538 void Main::fileSave()
1540 fileSave (CompleteMap);
1543 void Main::fileSaveAs(const SaveMode& savemode)
1548 if (currentMapEditor())
1550 if (savemode==CompleteMap)
1551 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1553 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1554 if ( !fn.isEmpty() )
1556 // Check for existing file
1557 if (QFile (fn).exists())
1559 QMessageBox mb( "VYM",
1560 tr("The file ") + fn + tr ("\nexists already. Do you want to"),
1561 QMessageBox::Warning,
1562 QMessageBox::Yes | QMessageBox::Default,
1563 QMessageBox::Cancel | QMessageBox::Escape,
1564 QMessageBox::QMessageBox::NoButton);
1565 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1566 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1569 case QMessageBox::Yes:
1572 case QMessageBox::Cancel:
1579 // New file, add extension to filename, if missing
1580 // This is always .vym or .vyp, depending on savemode
1581 if (savemode==CompleteMap)
1583 if (!fn.contains (".vym") && !fn.contains (".xml"))
1587 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1596 currentMapEditor()->setFilePath(fn);
1600 if (savemode==CompleteMap)
1601 tabWidget->setTabLabel (currentMapEditor(),
1602 currentMapEditor()->getFileName() );
1608 void Main::fileSaveAs()
1610 fileSaveAs (CompleteMap);
1613 void Main::fileImportDir()
1615 if (currentMapEditor())
1616 currentMapEditor()->importDir();
1619 void Main::fileExportXML()
1621 if (currentMapEditor())
1623 QString dir=browseDirectory(tr("Export XML to directory"));
1624 if (dir !="" && reallyWriteDirectory(dir) )
1625 currentMapEditor()->exportXML(dir);
1629 void Main::fileExportHTML()
1631 if (currentMapEditor())
1633 ExportHTMLDialog dia(this);
1635 if (dia.exec()==QDialog::Accepted)
1637 QString dir=dia.getDir();
1638 if (reallyWriteDirectory(dir) )
1640 currentMapEditor()->exportXML (dia.getDir() );
1641 dia.doExport(currentMapEditor()->getMapName() );
1647 void Main::fileExportXHTML()
1650 if (currentMapEditor())
1652 ExportXHTMLDialog dia(this);
1653 dia.setFilePath (currentMapEditor()->getFilePath() );
1654 dia.setMapName (currentMapEditor()->getMapName() );
1657 if (dia.exec()==QDialog::Accepted)
1659 QString dir=dia.getDir();
1660 // Check, if warnings should be used before overwriting
1661 // the output directory
1664 ok=reallyWriteDirectory(dir);
1670 currentMapEditor()->exportXML (dia.getDir() );
1671 dia.doExport(currentMapEditor()->getMapName() );
1672 if (dia.hasChanged())
1673 currentMapEditor()->setChanged();
1679 void Main::fileExportImage(int item)
1681 if (currentMapEditor())
1683 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1685 if ( !fn.isEmpty() )
1687 currentMapEditor()->exportImage(fn,item);
1689 statusBar()->message( tr("Couldn't save") + fn, statusbarTime );
1694 void Main::fileExportASCII()
1696 if (currentMapEditor())
1697 currentMapEditor()->exportASCII();
1700 void Main::fileCloseMap()
1702 if (currentMapEditor())
1704 if (currentMapEditor()->hasChanged())
1706 QMessageBox mb( "VYM",
1707 tr("The map ") + currentMapEditor()->getFileName() +
1708 tr(" has been modified but not saved yet. Do you want to"),
1709 QMessageBox::Warning,
1710 QMessageBox::Yes | QMessageBox::Default,
1712 QMessageBox::Cancel | QMessageBox::Escape );
1713 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1714 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1717 case QMessageBox::Yes:
1719 fileSave(CompleteMap);
1721 case QMessageBox::No:
1722 // close without saving
1724 case QMessageBox::Cancel:
1729 currentMapEditor()->closeMap();
1730 tabWidget->removePage(currentMapEditor());
1731 if (tabWidget->count()==0)
1732 actionFilePrint->setEnabled (false);
1736 void Main::filePrint()
1738 if (currentMapEditor())
1739 currentMapEditor()->print();
1742 void Main::fileExitVYM()
1744 // Check if one or more editors have changed
1747 for (i=0;i<=tabWidget->count() -1;i++)
1750 me=(MapEditor*)tabWidget->page(i);
1752 // If something changed, ask what to do
1753 if (me->isUnsaved())
1755 tabWidget->setCurrentPage(i);
1756 QMessageBox mb( "VYM",
1757 tr("This map is not saved yet. Do you want to"),
1758 QMessageBox::Warning,
1759 QMessageBox::Yes | QMessageBox::Default,
1761 QMessageBox::Cancel | QMessageBox::Escape );
1762 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1763 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1765 // Call undocumented function: setActiveWindow is only
1766 // possible, if widget is visible. This depends on
1768 #if defined(Q_OS_LINUX)
1769 qt_wait_for_window_manager( this);
1771 mb.setActiveWindow();
1772 switch( mb.exec() ) {
1773 case QMessageBox::Yes:
1774 // save (the changed editors) and exit
1775 fileSave(CompleteMap);
1777 case QMessageBox::No:
1778 // exit without saving
1780 case QMessageBox::Cancel:
1781 // don't save and don't exit
1785 } // loop over all MEs
1789 void Main::editUndo()
1791 if (currentMapEditor())
1792 currentMapEditor()->undo();
1795 void Main::editRedo() // TODO
1799 void Main::editCopy()
1801 if (currentMapEditor())
1802 currentMapEditor()->copy();
1805 void Main::editPaste()
1807 if (currentMapEditor())
1808 currentMapEditor()->paste();
1811 void Main::editCut()
1813 if (currentMapEditor())
1814 currentMapEditor()->cut();
1817 void Main::editOpenFindWindow()
1819 findWindow->popup();
1820 findWindow->raise();
1822 // Call undocumented function: setActiveWindow is only
1823 // possible, if widget is visible. This depends on
1825 #if defined(Q_OS_LINUX)
1826 qt_wait_for_window_manager( this);
1828 findWindow->setActiveWindow();
1831 void Main::editFind(QString s)
1834 BranchObj *bo=currentMapEditor()->findText(s, cs);
1837 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
1840 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
1841 tr("No matches found for ")+
1846 void Main::editFindChanged()
1847 { // Notify editor, to abort the current find process
1848 currentMapEditor()->findReset();
1851 void Main::editOpenURL()
1853 if (currentMapEditor())
1854 currentMapEditor()->openURL();
1857 void Main::editURL()
1859 if (currentMapEditor())
1860 currentMapEditor()->editURL();
1863 void Main::editHeading2URL()
1865 if (currentMapEditor())
1866 currentMapEditor()->editHeading2URL();
1869 void Main::editBugzilla2URL()
1871 if (currentMapEditor())
1872 currentMapEditor()->editBugzilla2URL();
1875 void Main::editOpenVymLink()
1877 // Get current path to map
1878 QString currentVymLink;
1879 if (currentMapEditor())
1881 currentVymLink=currentMapEditor()->getVymLink();
1882 // compare path with already loaded maps
1886 for (i=0;i<=tabWidget->count() -1;i++)
1888 me=(MapEditor*)tabWidget->page(i);
1889 if (currentVymLink==me->getFilePath() )
1898 if (!QFile(currentVymLink).exists() )
1899 QMessageBox::critical( 0, tr( "Critical Error" ),
1900 tr("Couldn't open map " +currentVymLink)+".");
1903 fileLoad (currentVymLink, NewMap);
1904 tabWidget->setCurrentPage (tabWidget->count()-1);
1907 // Go to tab containing the map
1908 tabWidget->setCurrentPage (index);
1912 void Main::editVymLink()
1914 if (currentMapEditor())
1915 currentMapEditor()->editVymLink();
1918 void Main::editDeleteVymLink()
1920 if (currentMapEditor())
1921 currentMapEditor()->deleteVymLink();
1924 void Main::editMapInfo()
1926 if (currentMapEditor())
1927 currentMapEditor()->editMapInfo();
1930 void Main::editMoveUp()
1932 if (currentMapEditor())
1933 currentMapEditor()->moveBranchUp();
1936 void Main::editMoveDown()
1938 if (currentMapEditor())
1939 currentMapEditor()->moveBranchDown();
1942 void Main::editToggleScroll()
1944 if (currentMapEditor())
1946 currentMapEditor()->toggleScroll();
1950 void Main::editUnScrollAll()
1952 if (currentMapEditor())
1954 currentMapEditor()->unScrollAll();
1958 void Main::editHeading()
1960 if (currentMapEditor())
1961 currentMapEditor()->editHeading();
1964 void Main::editNewBranch()
1966 if (currentMapEditor())
1967 currentMapEditor()->addNewBranch(0);
1970 void Main::editNewBranchHere()
1972 if (currentMapEditor())
1973 currentMapEditor()->addNewBranchHere();
1976 void Main::editNewBranchAbove()
1978 if (currentMapEditor())
1979 currentMapEditor()->addNewBranch(-1);
1982 void Main::editNewBranchBelow()
1984 if (currentMapEditor())
1985 currentMapEditor()->addNewBranch(1);
1988 void Main::editImportAdd()
1990 fileLoad (ImportAdd);
1993 void Main::editImportReplace()
1995 fileLoad (ImportReplace);
1998 void Main::editSaveBranch()
2000 fileSaveAs (PartOfMap);
2003 void Main::editRemoveBranchHere()
2005 if (currentMapEditor())
2006 currentMapEditor()->removeBranchHere();
2009 void Main::editRemoveChilds()
2011 if (currentMapEditor())
2012 currentMapEditor()->removeChilds();
2015 void Main::editDeleteSelection()
2017 if (currentMapEditor())
2018 currentMapEditor()->deleteSelection();
2021 void Main::editUpperBranch()
2023 if (currentMapEditor())
2024 currentMapEditor()->selectUpperBranch();
2027 void Main::editLowerBranch()
2029 if (currentMapEditor())
2030 currentMapEditor()->selectLowerBranch();
2033 void Main::editLeftBranch()
2035 if (currentMapEditor())
2036 currentMapEditor()->selectLeftBranch();
2039 void Main::editRightBranch()
2041 if (currentMapEditor())
2042 currentMapEditor()->selectRightBranch();
2045 void Main::editFirstBranch()
2047 if (currentMapEditor())
2048 currentMapEditor()->selectFirstBranch();
2051 void Main::editLastBranch()
2053 if (currentMapEditor())
2054 currentMapEditor()->selectLastBranch();
2057 void Main::editLoadImage()
2059 if (currentMapEditor())
2060 currentMapEditor()->loadFloatImage();
2063 void Main::editSaveImage(int item)
2065 if (currentMapEditor())
2066 currentMapEditor()->saveFloatImage(item);
2069 void Main::editToggleFloatExport()
2071 if (currentMapEditor())
2072 currentMapEditor()->toggleFloatExport();
2075 void Main::editFollowXLink(int item)
2077 if (currentMapEditor())
2078 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2081 void Main::editEditXLink(int item)
2083 if (currentMapEditor())
2084 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2087 void Main::formatSelectColor()
2089 if (currentMapEditor())
2091 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2092 if ( !col.isValid() ) return;
2093 currentMapEditor()->setColor( col );
2094 colorChanged( col );
2098 void Main::formatPickColor()
2100 if (currentMapEditor())
2101 colorChanged( currentMapEditor()->pickColor() );
2104 void Main::colorChanged(QColor c)
2106 QPixmap pix( 16, 16 );
2108 actionFormatColor->setIconSet( pix );
2111 void Main::formatColorItem()
2113 if (currentMapEditor())
2114 currentMapEditor()->colorItem();
2117 void Main::formatColorBranch()
2119 if (currentMapEditor())
2120 currentMapEditor()->colorBranch();
2123 void Main::formatLinkStyleLine()
2125 if (currentMapEditor())
2126 currentMapEditor()->setLinkStyle(StyleLine);
2129 void Main::formatLinkStyleParabel()
2131 if (currentMapEditor())
2132 currentMapEditor()->setLinkStyle(StyleParabel);
2135 void Main::formatLinkStylePolyLine()
2137 if (currentMapEditor())
2138 currentMapEditor()->setLinkStyle(StylePolyLine);
2141 void Main::formatLinkStylePolyParabel()
2143 if (currentMapEditor())
2144 currentMapEditor()->setLinkStyle(StylePolyParabel);
2147 void Main::formatSelectBackColor()
2149 if (currentMapEditor())
2150 currentMapEditor()->selectBackgroundColor();
2153 void Main::formatSelectLinkColor()
2155 if (currentMapEditor())
2156 currentMapEditor()->selectLinkColor();
2159 void Main::formatToggleLinkColorHint()
2161 currentMapEditor()->toggleLinkColorHint();
2164 void Main::formatFrameNone()
2166 if (currentMapEditor())
2167 currentMapEditor()->setFrame(NoFrame);
2170 void Main::formatFrameRectangle()
2172 if (currentMapEditor())
2173 currentMapEditor()->setFrame(Rectangle);
2176 void Main::viewZoomReset()
2178 if (currentMapEditor())
2182 currentMapEditor()->setWorldMatrix( m );
2183 currentMapEditor()->setViewCenter();
2184 currentMapEditor()->adjustCanvasSize();
2188 void Main::viewZoomIn()
2190 if (currentMapEditor())
2192 QWMatrix m = currentMapEditor()->worldMatrix();
2193 m.scale( 1.25, 1.25 );
2194 currentMapEditor()->setWorldMatrix( m );
2195 currentMapEditor()->setViewCenter();
2196 currentMapEditor()->adjustCanvasSize();
2200 void Main::viewZoomOut()
2202 if (currentMapEditor())
2204 QWMatrix m = currentMapEditor()->worldMatrix();
2205 m.scale( 0.8, 0.8 );
2206 currentMapEditor()->setWorldMatrix( m );
2207 currentMapEditor()->setViewCenter();
2208 currentMapEditor()->adjustCanvasSize();
2212 void Main::modModeColor()
2216 void Main::modModeLink()
2220 bool Main::settingsPDF()
2222 // Default browser is set in constructor
2224 QString text = QInputDialog::getText(
2225 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2226 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2228 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2233 bool Main::settingsURL()
2235 // Default browser is set in constructor
2237 QString text = QInputDialog::getText(
2238 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2239 settings.readEntry("/vym/mainwindow/readerURL")
2242 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2246 void Main::windowToggleNoteEditor()
2248 if (textEditor->showWithMain() )
2249 windowHideNoteEditor();
2251 windowShowNoteEditor();
2254 void Main::windowShowNoteEditor()
2256 textEditor->setShowWithMain(true);
2258 actionViewToggleNoteEditor->setOn (true);
2261 void Main::windowHideNoteEditor()
2263 textEditor->setShowWithMain(false);
2265 actionViewToggleNoteEditor->setOn (false);
2268 void Main::windowNextEditor()
2270 if (tabWidget->currentPageIndex() < tabWidget->count())
2271 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2274 void Main::windowPreviousEditor()
2276 if (tabWidget->currentPageIndex() >0)
2277 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2280 void Main::standardFlagChanged()
2282 currentMapEditor()->toggleStandardFlag(sender()->name());
2285 void Main::testFunction()
2287 //textEditor->stackUnder(this);
2288 currentMapEditor()->testFunction();
2291 void Main::testShowClipboard()
2293 clipboardME->show();
2296 void Main::helpDoc()
2299 // default path in SUSE LINUX
2300 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2302 if (!QFile (docpath).exists() )
2304 // relative path for easy testing in tarball
2305 docpath="doc/vym.pdf";
2306 if (!QFile (docpath).exists() )
2308 // relative path for testing while still writing vym.tex
2309 docpath="doc/tex/vym.pdf";
2310 if (!QFile (docpath).exists() )
2312 QMessageBox::critical(0,
2313 tr("Critcal error"),
2314 tr("Couldn't find the documentation\n"
2315 "vym.pdf in various places."));
2321 Process *pdfProc = new Process();
2322 pdfProc->clearArguments();
2323 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2324 pdfProc->addArgument( docpath);
2326 if ( !pdfProc->start() )
2329 QMessageBox::critical(0,
2330 tr("Critcal error"),
2331 tr("Couldn't find a viewer to read vym.pdf.\n"
2332 "Please use Settings->")+tr("Set application to open pdf files"));
2338 void Main::helpAbout()
2340 static QMessageBox* about = new QMessageBox( "VYM",
2341 "<h3>VYM - View Your Mind </h3>"
2342 "<p> A tool to put the things you have got in your mind into a map.</p>"
2344 "<li> (c) by Uwe Drechsel (vym@InSilmaril.de)</li>"
2345 "<li> vym is released under the GPL (Gnu General Public License)"
2346 ", with one exception (see the file \"LICENSE\"which "
2347 "comes with vym). This exception is needed to build vym with QT libraries for proprietary operating systems.</li>"
2348 "<li> Project homepage <a href=\"http:/www.InSilmaril.de/vym\">"
2349 "http:/www.InSilmaril.de/vym</a></li>"
2352 "<li>Thomas Schraitle for the stylesheet used for XHTML-export </li>"
2353 "<li>Clemens Kraus for stylesheets and script used for HTML-export "
2354 "<a href=\"http://www.clemens-kraus.de\">(www.clemens-kraus.de)</a></li>"
2355 "<li>Alexander Johannesen for providing stylesheets from his xsiteable project "
2356 "<a href=\"http://www.shelter.nu/xsiteable/xsiteable.html\">(www.shelter.nu/xsiteable/xsiteable.html)</a>. </li>"
2357 "<li>Ken Wimer and Olaf Hering for Mac support</li>"
2360 "<li> Version " __VYM_VERSION__ "</li>"
2361 "<li> Build date " __BUILD_DATE__"</li>"
2362 "</ul>", QMessageBox::Information, 1, 0, 0, this, 0, FALSE );
2363 about->setButtonText( 1, "Dismiss" );
2364 about->setMinimumSize(QSize(300,300));
2365 about->setIconPixmap (QPixmap(vym_logo_xpm));
2369 void Main::helpAboutQT()
2371 QMessageBox::aboutQt( this, "Qt Application Example" );