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;
132 extern QAction* actionSettingsUseFlagGroups;
134 extern QPopupMenu* branchContextMenu;
135 extern QPopupMenu* branchAddContextMenu;
136 extern QPopupMenu* branchRemoveContextMenu;
137 extern QPopupMenu* branchLinksContextMenu;
138 extern QPopupMenu* branchLinksContextMenuDup;
139 extern QPopupMenu* floatimageContextMenu;
140 extern QPopupMenu* saveImageFormatMenu;
141 extern QPopupMenu* canvasContextMenu;
142 extern QPopupMenu* lastMapsMenu;
143 extern QPopupMenu* exportMenu;
144 extern QPopupMenu* exportImageFormatMenu;
147 extern Settings settings;
148 extern Options options;
150 #if defined(Q_OS_LINUX)
151 extern void qt_wait_for_window_manager( QWidget* w );
154 Main::Main(QWidget* parent, const char* name, WFlags f) :
155 QMainWindow(parent,name,f)
159 setCaption ("VYM - View Your Mind");
161 // Load window settings
162 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
163 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
164 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
165 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
168 // Set random seed (random used for object IDs)
169 QTime t = QTime::currentTime(); // set random seed
170 srand( t.hour()*12+t.minute()*60+t.second()*60 );
173 // Initialize some settings, which are platform dependant
176 // application to open URLs
177 p="/vym/mainwindow/readerURL";
178 #if defined(Q_OS_LINUX)
179 s=settings.readEntry (p,"konqueror");
181 #if defined(Q_OS_MACX)
182 s=settings.readEntry (p,"/usr/bin/open");
184 s=settings.readEntry (p,"mozilla");
187 settings.writeEntry( p,s);
189 // application to open PDFs
190 p="/vym/mainwindow/readerPDF";
191 #if defined(Q_OS_LINUX)
192 s=settings.readEntry (p,"acroread");
194 #if defined(Q_OS_MACX)
195 s=settings.readEntry (p,"/usr/bin/open");
197 s=settings.readEntry (p,"acroread");
200 settings.writeEntry( p,s);
205 // Create tab widget which holds the maps
206 tabWidget= new QTabWidget (this);
207 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
208 this, SLOT( editorChanged( QWidget * ) ) );
210 setCentralWidget(tabWidget);
214 setupFormatActions();
218 setupSettingsActions();
220 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
223 // After menu is created, we can enable some actions
224 actionFilePrint->setEnabled (true);
229 // Initialize Find window
230 findWindow=new FindWindow(NULL,"findwindow");
231 connect (findWindow, SIGNAL( findButton(QString) ),
232 this, SLOT(editFind(QString) ) );
233 connect (findWindow, SIGNAL( somethingChanged() ),
234 this, SLOT(editFindChanged() ) );
238 // Creating the default map into first tab is done in main.cpp now...
244 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
245 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
246 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
247 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
249 settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
250 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
252 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
253 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
254 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
255 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
256 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
257 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
260 int maps=lastMaps.count();
261 settings.writeEntry( "/vym/lastMaps/number",maps );
262 for (int i=1;i<=maps;i++)
264 QStringList::Iterator it = lastMaps.at(i-1);
265 s=QString("/vym/lastMaps/map-%1").arg(i);
266 if (!s.isEmpty() && i<=maxLastMaps)
267 settings.writeEntry (s, *it);
271 // To make the texteditor save its settings, call the destructor
275 void Main::loadCmdLine()
277 /* TODO draw some kind of splashscreen while loading...
283 QStringList flist=options.getFileList();
284 QStringList::Iterator it=flist.begin();
286 while (it !=flist.end() )
288 fileLoad (*it, NewMap);
294 void Main::statusMessage(const QString &s)
296 statusBar()->message (s);
299 void Main::closeEvent (QCloseEvent* )
305 void Main::setupFileActions()
307 QToolBar *tb = new QToolBar( this );
308 tb->setLabel( "File Actions" );
309 QPopupMenu *menu = new QPopupMenu( this );
310 menuBar()->insertItem( tr( "&File" ), menu );
312 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
315 a = new QAction( tr( "New map","File menu" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
316 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
320 a = new QAction( tr( "Open","File menu" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
321 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
325 lastMapsMenu = new QPopupMenu (this);
327 menu->insertItem (tr("Open Recent"),lastMapsMenu );
328 menu->insertSeparator();
330 a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
331 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
336 a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
337 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
340 menu->insertSeparator();
342 a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir" ), 0, this, "export" );
343 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
346 exportMenu = new QPopupMenu (this);
347 menu->insertItem (tr("Export"),exportMenu );
349 menu->insertSeparator();
352 a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
353 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
358 a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
359 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
362 a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
363 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
369 void Main::setupEditActions()
371 QToolBar *tb = new QToolBar( this );
372 tb->setLabel( "Edit Actions" );
373 QPopupMenu *menu = new QPopupMenu( this );
374 menuBar()->insertItem( tr( "&Edit" ), menu );
378 a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
379 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
380 a->setEnabled (false);
385 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
386 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
390 menu->insertSeparator();
391 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
392 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
393 a->setEnabled (false);
397 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
398 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
399 a->setEnabled (false);
403 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
404 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
405 a->setEnabled (false);
410 a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
411 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
412 a->setEnabled (false);
415 actionListBranches.append(a);
418 a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
419 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
420 a->setEnabled (false);
423 actionListBranches.append(a);
424 actionEditMoveDown=a;
427 a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
428 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
429 alt = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_S, this, "scroll" );
430 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
431 #if defined(Q_OS_MACX)
432 actionEditToggleScroll=alt;
434 actionEditToggleScroll=a;
436 actionEditToggleScroll->setEnabled (false);
437 actionEditToggleScroll->addTo( tb );
438 actionEditToggleScroll->addTo( menu );
439 actionListBranches.append(actionEditToggleScroll);
441 a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
442 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
445 menu->insertSeparator();
447 a = new QAction( tr( "Find" ), QPixmap(), tr( "Find" ), CTRL + Key_F, this, "find" );
448 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
451 menu->insertSeparator();
453 a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
454 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
457 a->setEnabled (false);
460 a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL" ), SHIFT + CTRL + Key_U, this, "url" );
461 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
463 a->setEnabled (false);
464 actionListBranches.append(a);
467 a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
468 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
470 a->setEnabled (false);
471 actionListBranches.append(a);
472 actionEditHeading2URL=a;
474 a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
475 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
476 a->setEnabled (false);
477 actionListBranches.append(a);
478 actionEditBugzilla2URL=a;
480 menu->insertSeparator();
482 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" );
483 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
486 a->setEnabled (false);
487 actionEditOpenVymLink=a;
489 a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link" ), 0, this, "editLinkMap" );
490 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
492 a->setEnabled (false);
493 actionListBranches.append(a);
496 a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
497 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
499 a->setEnabled (false);
500 actionEditDeleteVymLink=a;
502 menu->insertSeparator();
504 a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info" ), 0, this, "editMapInfo" );
505 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
507 a->setEnabled (true);
510 menu->insertSeparator();
512 // Shortcuts to modify heading:
513 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
514 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
515 actionListBranches.append(a);
516 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
517 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
518 actionListBranches.append(a);
520 a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_F2, this, "editHeading" );
521 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
522 a->setEnabled (false);
525 actionListBranches.append(a);
527 // Shortcut to delete selection
528 a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
529 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
530 a->setEnabled (false);
534 // Shortcut to add branch
535 alt = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_A, this, "newBranch" );
536 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
537 a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
538 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
539 a->setEnabled (false);
540 actionListBranches.append(a);
541 #if defined (Q_OS_MACX)
542 actionEditAddBranch=alt;
544 actionEditAddBranch=a;
547 // Add branch by inserting it at selection
548 a = new QAction( tr( "Add a branch by inserting and making selection its child" ),tr( "Add branch (insert)" ), ALT + Key_Insert, this, "newBranchHere" );
549 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
550 a->setEnabled (false);
551 actionListBranches.append(a);
552 actionEditAddBranchHere=a;
555 a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
556 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
557 a->setEnabled (false);
558 actionListBranches.append(a);
559 actionEditAddBranchAbove=a;
562 a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
563 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
564 a->setEnabled (false);
565 actionListBranches.append(a);
566 actionEditAddBranchBelow=a;
568 // Import at selection (adding to selection)
569 a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
570 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
571 a->setEnabled (false);
572 actionListBranches.append(a);
573 actionEditImportAdd=a;
575 // Import at selection (replacing selection)
576 a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
577 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
578 a->setEnabled (false);
579 actionListBranches.append(a);
580 actionEditImportReplace=a;
583 a = new QAction( tr( "Save selection" ),tr( "Save selection" ), 0, this, "saveSelection" );
584 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
585 a->setEnabled (false);
586 actionListBranches.append(a);
587 actionEditSaveBranch=a;
589 // Only remove branch, not its childs
590 a = new QAction( tr( "Remove only branch and keep its childs" ),tr( "Remove only branch " ), ALT + Key_Delete, this, "removeBranchHere" );
591 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchHere() ) );
592 a->setEnabled (false);
593 actionListBranches.append(a);
594 actionEditRemoveBranchHere=a;
596 // Only remove childs of a branch
597 a = new QAction( tr( "Remove childs of branch" ),tr( "Remove childs" ), SHIFT + Key_Delete, this, "removeBranchChilds" );
598 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
599 a->setEnabled (false);
600 actionListBranches.append(a);
601 actionEditRemoveChilds=a;
603 // Shortcuts for navigating with cursor:
604 a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
605 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
606 a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
607 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
608 a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
609 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
610 a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
611 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
612 a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
613 a->setEnabled (false);
615 actionListBranches.append(a);
616 actionEditSelectFirst=a;
617 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
618 a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
619 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
620 a->setEnabled (false);
622 actionListBranches.append(a);
623 actionEditSelectLast=a;
625 a = new QAction( tr( "Add Image" ),tr( "Add Image" ), 0, this, "loadImage" );
626 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
627 actionEditLoadImage=a;
632 void Main::setupFormatActions()
634 QPopupMenu *menu = new QPopupMenu( this );
635 menuBar()->insertItem( tr( "&Format" ), menu );
637 QToolBar *tb = new QToolBar( this );
641 actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" ), 0, this, "formatColor" );
642 connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
643 actionFormatColor->addTo( tb );
644 actionFormatColor->addTo( menu );
645 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" );
646 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
647 a->setEnabled (false);
650 actionListBranches.append(a);
651 actionFormatPickColor=a;
652 a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
653 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
654 a->setEnabled (false);
657 actionListBranches.append(a);
658 actionFormatColorBranch=a;
659 a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
660 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
661 a->setEnabled (false);
664 actionListBranches.append(a);
665 actionFormatColorSubtree=a;
667 menu->insertSeparator();
668 actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
669 actionGroupFormatLinkStyles->setExclusive (true);
670 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
671 a->setToggleAction(true);
672 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
673 actionFormatLinkStyleLine=a;
674 a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
675 a->setToggleAction(true);
676 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
677 actionFormatLinkStyleParabel=a;
678 a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
679 a->setToggleAction(true);
680 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
681 actionFormatLinkStylePolyLine=a;
682 a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
683 a->setToggleAction(true);
684 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
685 actionFormatLinkStylePolyParabel=a;
686 actionGroupFormatLinkStyles->addTo (menu);
688 actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
689 actionGroupFormatFrameTypes->setExclusive (true);
690 a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
691 a->setToggleAction(true);
692 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
693 actionFormatFrameNone=a;
694 a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
695 a->setToggleAction(true);
696 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
697 actionFormatFrameRectangle=a;
699 menu->insertSeparator();
700 a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
701 a->setToggleAction(true);
702 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
704 actionFormatLinkColorHint=a;
706 actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color" ), 0, this, "formatLinkColor" );
707 connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
708 actionFormatLinkColor->addTo( menu );
709 actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" ), 0, this, "formatBackColor" );
710 connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
711 actionFormatBackColor->addTo( menu );
715 void Main::setupViewActions()
717 QToolBar *tb = new QToolBar( this );
718 tb->setLabel( "View Actions" );
719 QPopupMenu *menu = new QPopupMenu( this );
720 menuBar()->insertItem( tr( "&View" ), menu );
723 a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), 0, this, "zoomReset" );
724 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
727 a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
728 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
731 a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
732 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
735 a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
736 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
737 a->setToggleAction(true);
738 if (textEditor->showWithMain())
744 actionViewToggleNoteEditor=a;
745 a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
746 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
748 a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
749 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
754 void Main::setupModeActions()
756 //QPopupMenu *menu = new QPopupMenu( this );
757 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
759 QToolBar *tb = new QToolBar( this );
760 tb->setLabel( tr ("Modes when using modifiers") );
762 actionGroupModModes=new QActionGroup ( this, "formatLinkStyles");
763 actionGroupModModes->setExclusive (true);
764 a= new QAction( tr( "Use modifier to color branches" ), QPixmap(modecolor_xpm), 0, Key_J, actionGroupModModes, "modModeColor" );
765 a->setToggleAction(true);
768 actionModModeColor=a;
770 a= new QAction( tr( "Use modifier to copy" ), QPixmap(modecopy_xpm), 0, Key_K, actionGroupModModes, "modModeCopy" );
771 a->setToggleAction(true);
775 a= new QAction( tr( "Use modifier to draw xLinks" ), QPixmap(modelink_xpm), 0, Key_L, actionGroupModModes, "modModeLink" );
776 a->setToggleAction(true);
782 void Main::setupFlagActions()
784 standardFlagsDefault->makeToolbar(this, "Standard Flags");
788 void Main::setupSettingsActions()
790 QPopupMenu *menu = new QPopupMenu( this );
791 menuBar()->insertItem( tr( "&Settings" ), menu );
796 a = new QAction( tr( "Set application to open pdf files" ), QPixmap(), tr( "Set application to open pdf files" ), 0, this, "setPDF" );
797 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
800 a = new QAction( tr( "Set application to open an URL" ), QPixmap(), tr( "Set application to open an URL" ), 0, this, "setURL" );
801 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
804 menu->insertSeparator();
805 a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
806 a->setToggleAction(true);
807 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
809 actionSettingsAutoedit=a;
811 a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
812 a->setToggleAction(true);
813 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
815 actionSettingsAutoselectHeading=a;
817 a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
818 a->setToggleAction(true);
819 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
821 actionSettingsAutoselectText=a;
823 a= new QAction( tr( "Enable pasting into new branch" ), QPixmap(), tr( "Enable pasting into new branch" ), 0, this, "pastenewheading" );
824 a->setToggleAction(true);
825 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
827 actionSettingsPasteNewHeading=a;
829 a= new QAction( tr( "Enable Delete key for deleting branches" ), QPixmap(), tr( "Enable Delete key" ), 0, this, "delkey" );
830 a->setToggleAction(true);
831 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
833 actionSettingsUseDelKey=a;
835 a= new QAction( tr( "Use exclusive flags in flag toolbars" ), QPixmap(), tr( "Enable exclusive flags" ), 0, this, "flaggroups" );
836 a->setToggleAction(true);
837 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
839 actionSettingsUseFlagGroups=a;
843 void Main::setupTestActions()
845 QPopupMenu *menu = new QPopupMenu( this );
846 menuBar()->insertItem( tr( "&Test" ), menu );
849 a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
850 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
853 a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
854 connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
859 void Main::setupHelpActions()
861 QPopupMenu *menu = new QPopupMenu( this );
862 menuBar()->insertItem( tr( "&Help" ), menu );
865 a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
866 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
869 a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
870 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
873 a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
874 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
879 void Main::setupContextMenus()
883 // Context Menu for branch or mapcenter
884 branchContextMenu =new QPopupMenu (this);
887 branchAddContextMenu =new QPopupMenu (this);
888 actionEditPaste->addTo ( branchAddContextMenu );
889 actionEditAddBranch->addTo ( branchAddContextMenu );
890 actionEditAddBranchHere->addTo ( branchAddContextMenu );
891 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
892 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
893 branchAddContextMenu->insertSeparator();
894 actionEditLoadImage->addTo( branchAddContextMenu );
895 branchAddContextMenu->insertSeparator();
896 actionEditImportAdd->addTo ( branchAddContextMenu );
897 actionEditImportReplace->addTo ( branchAddContextMenu );
900 branchRemoveContextMenu =new QPopupMenu (this);
901 actionEditCut->addTo ( branchRemoveContextMenu );
902 actionEditDelete->addTo ( branchRemoveContextMenu );
903 actionEditRemoveBranchHere->addTo( branchRemoveContextMenu );
904 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
906 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
907 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
909 actionEditSaveBranch->addTo( branchContextMenu );
911 branchContextMenu->insertSeparator();
912 actionEditOpenURL->addTo ( branchContextMenu );
913 actionEditURL->addTo ( branchContextMenu );
914 actionEditHeading2URL->addTo ( branchContextMenu );
915 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
916 actionEditBugzilla2URL->addTo( branchContextMenu );
918 branchContextMenu->insertSeparator();
919 actionEditOpenVymLink->addTo ( branchContextMenu );
920 actionEditVymLink->addTo ( branchContextMenu );
921 actionEditDeleteVymLink->addTo ( branchContextMenu );
923 branchContextMenu->insertSeparator();
924 actionGroupFormatFrameTypes->addTo( branchContextMenu );
926 // Context Menu for links in a branch menu
927 // This will be populated "on demand" in MapEditor::updateActions
928 branchContextMenu->insertSeparator();
929 branchLinksContextMenu =new QPopupMenu (this);
930 branchLinksContextMenuDup =new QPopupMenu (this);
931 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
932 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
934 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
935 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
937 // Context menu for floatimage
938 floatimageContextMenu =new QPopupMenu (this);
939 saveImageFormatMenu=new QPopupMenu (this);
940 exportImageFormatMenu=new QPopupMenu (this);
942 QStrList fmt = QImage::outputFormats();
943 for (const char* f = fmt.first(); f; f = fmt.next())
945 saveImageFormatMenu->insertItem( f );
946 exportImageFormatMenu->insertItem( f );
948 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
949 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
950 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
952 floatimageContextMenu->insertSeparator();
953 actionEditCopy->addTo( floatimageContextMenu );
954 actionEditCut->addTo( floatimageContextMenu );
956 floatimageContextMenu->insertSeparator();
957 a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
958 a->setToggleAction(true);
959 connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
960 a->addTo( floatimageContextMenu);
961 actionEditToggleFloatExport=a;
965 // Context menu for exports
966 exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
968 a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" ), 0, this, "exportASCII" );
969 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
970 // FIXME Usually deactivated, still experimental
971 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) ;
972 a->addTo( exportMenu );
974 a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ), 0, this, "exportXML" );
975 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
976 a->addTo( exportMenu );
978 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
980 a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export HTML" ), 0, this, "exportHTML" );
981 connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
982 a->addTo( exportMenu );
985 a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" ), ALT + Key_X, this, "exportXHTML" );
986 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
987 a->addTo( exportMenu );
990 // Context menu for canvas
991 canvasContextMenu =new QPopupMenu (this);
992 actionEditMapInfo->addTo( canvasContextMenu );
993 canvasContextMenu->insertSeparator();
994 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
995 canvasContextMenu->insertSeparator();
996 actionFormatLinkColorHint->addTo( canvasContextMenu );
997 actionFormatLinkColor->addTo( canvasContextMenu );
998 actionFormatBackColor->addTo( canvasContextMenu );
1000 // Menu for last opened files
1001 // Read settings initially
1003 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1004 for (int i=1;i<=j;i++)
1006 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1007 if (!s.isEmpty() && j<=maxLastMaps)
1010 setupLastMapsMenu();
1011 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1014 void Main::setupLastMapsMenu()
1016 // Remove double entries
1017 QStringList::Iterator it=lastMaps.begin();
1018 QStringList::Iterator jt;
1019 while (it!=lastMaps.end() )
1023 while (jt!=lastMaps.end() )
1026 jt=lastMaps.remove(jt);
1033 // Limit length of list to maxLastMaps
1034 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1036 // build Menu from lastMaps string list
1037 lastMapsMenu->clear();
1038 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1039 lastMapsMenu->insertItem (*it );
1043 void Main::hideEvent (QHideEvent * )
1045 if (!textEditor->isMinimized() ) textEditor->hide();
1048 void Main::showEvent (QShowEvent * )
1050 if (textEditor->showWithMain()) textEditor->showNormal();
1053 bool Main::reallyWriteDirectory(const QString &dir)
1055 QStringList eList = QDir(dir).entryList();
1056 if (eList.first() ==".") eList.pop_front(); // remove "."
1057 if (eList.first() =="..") eList.pop_front(); // remove "."
1058 if (!eList.isEmpty())
1060 QMessageBox mb( "VYM",
1061 tr("The directory ") + dir +
1062 tr(" is not empty. Do you risk to overwrite its contents?"),
1063 QMessageBox::Warning,
1065 QMessageBox::Cancel | QMessageBox::Default,
1066 QMessageBox::QMessageBox::NoButton );
1068 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1069 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1072 case QMessageBox::Yes:
1075 case QMessageBox::Cancel:
1083 QString Main::browseDirectory (const QString &caption)
1085 QFileDialog fd(this,caption);
1086 fd.setMode (QFileDialog::DirectoryOnly);
1087 fd.setCaption("VYM - "+caption);
1090 if ( fd.exec() == QDialog::Accepted )
1091 return fd.selectedFile();
1096 MapEditor* Main::currentMapEditor() const
1098 if ( tabWidget->currentPage() &&
1099 tabWidget->currentPage()->inherits( "MapEditor" ) )
1100 return (MapEditor*)tabWidget->currentPage();
1104 //TODO not used now, maybe use this for overview window later
1105 void Main::newView()
1107 // Open a new view... have it delete when closed.
1108 Main *m = new Main(0, 0, WDestructiveClose);
1109 qApp->setMainWidget(m);
1111 qApp->setMainWidget(0);
1114 void Main::editorChanged(QWidget *)
1116 // Unselect all possibly selected objects
1117 // (Important to update note editor)
1120 for (i=0;i<=tabWidget->count() -1;i++)
1123 me=(MapEditor*)tabWidget->page(i);
1126 currentMapEditor()->reselect();
1128 // Update actions to in menus and toolbars according to editor
1129 currentMapEditor()->updateActions();
1132 void Main::fileNew()
1134 QString fn="unnamed";
1135 MapEditor* medit = new MapEditor (tabWidget, true);
1136 tabWidget->addTab (medit,fn);
1137 tabWidget->showPage(medit);
1138 medit->viewport()->setFocus();
1139 medit->select("mc:");
1142 void Main::fileLoad(QString fn, const LoadMode &lmode)
1145 enum errorCode {success,aborted};
1146 errorCode err=success;
1148 // fn is usually the archive, mapfile the file after uncompressing
1151 // Make fn absolute (needed for unzip)
1152 fn=QDir (fn).absPath();
1158 // Check, if map is already loaded
1160 while (i<=tabWidget->count() -1)
1162 me=(MapEditor*)tabWidget->page(i);
1163 if (me->getFilePath() == fn)
1165 // Already there, ask for confirmation
1166 QMessageBox mb( "VYM",
1167 tr("The map ") + fn + tr ("\n is already opened."
1168 "Opening the same map in multiple editors may lead \n"
1169 "to confusion when finishing working with vym."
1171 QMessageBox::Warning,
1172 QMessageBox::Yes | QMessageBox::Default,
1173 QMessageBox::Cancel | QMessageBox::Escape,
1174 QMessageBox::QMessageBox::NoButton);
1175 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1176 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1179 case QMessageBox::Yes:
1181 i=tabWidget->count();
1183 case QMessageBox::Cancel:
1195 if ( !fn.isEmpty() )
1197 me = currentMapEditor();
1198 int tabIndex=tabWidget->currentPageIndex();
1199 // Check first, if mapeditor exists
1200 // If it is not default AND we want a new map,
1201 // create a new mapeditor in a new tab
1202 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1204 me = new MapEditor (tabWidget,true);
1205 tabWidget->addTab (me,fn);
1206 tabIndex=tabWidget->indexOf (me);
1207 tabWidget->setCurrentPage (tabIndex);
1210 // Check, if file exists (important for creating new files
1211 // from command line
1212 if (!QFile(fn).exists() )
1214 QMessageBox mb( "VYM",
1215 tr("This map does not exist:\n ")+fn+tr("\nDo you want to create a new one?"),
1216 QMessageBox::Question,
1218 QMessageBox::Cancel | QMessageBox::Default,
1219 QMessageBox::QMessageBox::NoButton );
1221 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1222 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1225 case QMessageBox::Yes:
1227 currentMapEditor()->setFilePath(fn);
1228 tabWidget->setTabLabel (currentMapEditor(),
1229 currentMapEditor()->getFileName() );
1230 statusBar()->message( "Created " + fn , statusbarTime );
1233 case QMessageBox::Cancel:
1234 // don't create new map
1235 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1242 //tabWidget->currentPage() won't be NULL here, because of above...
1243 tabWidget->showPage(me);
1244 me->viewport()->setFocus();
1246 // Create temporary directory for packing
1247 char tmpdir1[]="/tmp/vym-XXXXXX";
1248 QString tmpMapDir=mkdtemp(tmpdir1);
1250 // Try to unzip file
1251 Process *zipProc=new Process ();
1252 zipProc->clearArguments();
1253 zipProc->setWorkingDirectory (QDir(tmpMapDir));
1254 zipProc->addArgument ("unzip");
1255 zipProc->addArgument (fn );
1256 zipProc->addArgument ("-d");
1257 zipProc->addArgument (tmpMapDir);
1259 if (!zipProc->start() )
1261 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1262 tr("Couldn't start unzip to decompress data."));
1267 zipProc->waitFinished();
1268 if (!zipProc->normalExit() )
1270 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1271 tr("unzip didn't exit normally") +
1272 zipProc->getErrout() );
1276 if (zipProc->exitStatus()>0)
1278 if (zipProc->exitStatus()==9)
1280 // no zipped file, but maybe .xml or old version? Try again.
1282 me->setZipped(false);
1286 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1287 QString("unzip exit code: %1").arg(zipProc->exitStatus() ) +
1288 zipProc->getErrout() );
1292 { // Uncompressing was successfull,
1293 // load from uncompressed temporary directory
1295 me->setZipped(true);
1298 // Look for mapname.xml
1299 mapfile= fn.left(fn.findRev(".",-1,true));
1300 mapfile=mapfile.section( '/', -1 );
1301 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1302 if (!file.exists() )
1304 // mapname.xml does not exist, well,
1305 // maybe some renamed the mapname.vym file...
1306 // Try to find any .xml in the toplevel
1307 // directory of the .vym file
1308 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1309 if (flist.count()==1)
1311 // Only one entry, take this one
1312 mapfile=tmpMapDir + "/"+flist.first();
1315 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1316 *it=tmpMapDir + "/" + *it;
1317 // FIXME Multiple entries, load all (but only the first one into this ME)
1318 //mainWindow->fileLoadFromTmp (flist);
1319 //returnCode=1; // Silently forget this attempt to load
1320 qWarning ("MainWindow::load (fn) multimap found...");
1323 if (flist.isEmpty() )
1325 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1326 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1329 } //file doesn't exist
1331 mapfile=file.name();
1332 } // Uncompressing successfull
1337 // Save existing filename
1338 QString fn_org=me->getFilePath();
1340 // Finally load map into mapEditor
1341 me->setFilePath (mapfile,fn);
1342 if (me->load(mapfile,lmode))
1345 // Restore old (maybe empty) filepath, if this is an import
1347 me->setFilePath (fn_org);
1350 system ( "rm -rf "+tmpMapDir);
1357 me->setFilePath (fn);
1358 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1359 lastMaps.prepend(me->getFilePath() );
1360 setupLastMapsMenu();
1361 actionFilePrint->setEnabled (true);
1363 statusBar()->message( "Loaded " + fn, statusbarTime );
1373 statusBar()->message( "Could not load " + fn, statusbarTime );
1377 void Main::fileLoad(const LoadMode &lmode)
1379 QFileDialog *fd=new QFileDialog( this);
1380 if (!lastFileDir.isEmpty())
1381 fd->setDir (lastFileDir);
1382 fd->addFilter ("XML (*.xml)");
1383 fd->addFilter ("VYM map (*.vym *.vyp)");
1387 fd->setCaption(tr("Load vym map"));
1390 fd->setCaption(tr("Import: Add vym map to selection"));
1393 fd->setCaption(tr("Import: Replace selection with vym map"));
1399 if ( fd->exec() == QDialog::Accepted )
1401 lastFileDir=fd->dirPath();
1402 fn = fd->selectedFile();
1403 fileLoad(fn, lmode);
1407 void Main::fileLoad()
1412 void Main::fileLoadLast(int i)
1414 fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);
1417 void Main::fileSave(const SaveMode &savemode)
1419 // tmp dir for zipping
1423 enum errorCode {success,aborted};
1424 errorCode err=success;
1426 QString safeFilePath;
1428 bool saveZipped=currentMapEditor()->saveZipped();
1430 if (currentMapEditor())
1432 QString fn=currentMapEditor()->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=currentMapEditor()->getFilePath();
1484 currentMapEditor()->setFilePath (tmpMapDir+"/"+
1485 currentMapEditor()->getMapName()+ ".xml",
1487 currentMapEditor()->save (savemode);
1488 currentMapEditor()->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=currentMapEditor()->getFilePath();
1531 currentMapEditor()->setFilePath (fn, safeFilePath);
1532 currentMapEditor()->save (savemode);
1533 currentMapEditor()->setFilePath (safeFilePath);
1535 } // filepath available
1538 // We have no filepath yet,
1539 // call fileSaveAs() now, this will call fileSave()
1541 fileSaveAs(savemode);
1545 if (currentMapEditor()->saveZipped())
1548 system ( "rm -rf "+ tmpMapDir );
1552 statusBar()->message(
1553 tr("Saved")+" " + currentMapEditor()->getFilePath(),
1556 statusBar()->message(
1557 tr("Couldn't save")+" " + currentMapEditor()->getFilePath(),
1561 void Main::fileSave()
1563 fileSave (CompleteMap);
1566 void Main::fileSaveAs(const SaveMode& savemode)
1571 if (currentMapEditor())
1573 if (savemode==CompleteMap)
1574 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1576 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1577 if ( !fn.isEmpty() )
1579 // Check for existing file
1580 if (QFile (fn).exists())
1582 QMessageBox mb( "VYM",
1583 tr("The file ") + fn + tr ("\nexists already. Do you want to"),
1584 QMessageBox::Warning,
1585 QMessageBox::Yes | QMessageBox::Default,
1586 QMessageBox::Cancel | QMessageBox::Escape,
1587 QMessageBox::QMessageBox::NoButton);
1588 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1589 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1592 case QMessageBox::Yes:
1595 case QMessageBox::Cancel:
1602 // New file, add extension to filename, if missing
1603 // This is always .vym or .vyp, depending on savemode
1604 if (savemode==CompleteMap)
1606 if (!fn.contains (".vym") && !fn.contains (".xml"))
1610 if (!fn.contains (".vyp") && !fn.contains (".xml"))
1619 currentMapEditor()->setFilePath(fn);
1623 if (savemode==CompleteMap)
1624 tabWidget->setTabLabel (currentMapEditor(),
1625 currentMapEditor()->getFileName() );
1631 void Main::fileSaveAs()
1633 fileSaveAs (CompleteMap);
1636 void Main::fileImportDir()
1638 if (currentMapEditor())
1639 currentMapEditor()->importDir();
1642 void Main::fileExportXML()
1644 if (currentMapEditor())
1646 QString dir=browseDirectory(tr("Export XML to directory"));
1647 if (dir !="" && reallyWriteDirectory(dir) )
1648 currentMapEditor()->exportXML(dir);
1652 void Main::fileExportHTML()
1654 if (currentMapEditor())
1656 ExportHTMLDialog dia(this);
1658 if (dia.exec()==QDialog::Accepted)
1660 QString dir=dia.getDir();
1661 if (reallyWriteDirectory(dir) )
1663 currentMapEditor()->exportXML (dia.getDir() );
1664 dia.doExport(currentMapEditor()->getMapName() );
1670 void Main::fileExportXHTML()
1673 if (currentMapEditor())
1675 ExportXHTMLDialog dia(this);
1676 dia.setFilePath (currentMapEditor()->getFilePath() );
1677 dia.setMapName (currentMapEditor()->getMapName() );
1680 if (dia.exec()==QDialog::Accepted)
1682 QString dir=dia.getDir();
1683 // Check, if warnings should be used before overwriting
1684 // the output directory
1687 ok=reallyWriteDirectory(dir);
1693 currentMapEditor()->exportXML (dia.getDir() );
1694 dia.doExport(currentMapEditor()->getMapName() );
1695 if (dia.hasChanged())
1696 currentMapEditor()->setChanged();
1702 void Main::fileExportImage(int item)
1704 if (currentMapEditor())
1706 QString fn = QFileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
1708 if ( !fn.isEmpty() )
1710 currentMapEditor()->exportImage(fn,item);
1712 statusBar()->message( tr("Couldn't save") + fn, statusbarTime );
1717 void Main::fileExportASCII()
1719 if (currentMapEditor())
1720 currentMapEditor()->exportASCII();
1723 void Main::fileCloseMap()
1725 if (currentMapEditor())
1727 if (currentMapEditor()->hasChanged())
1729 QMessageBox mb( "VYM",
1730 tr("The map ") + currentMapEditor()->getFileName() +
1731 tr(" has been modified but not saved yet. Do you want to"),
1732 QMessageBox::Warning,
1733 QMessageBox::Yes | QMessageBox::Default,
1735 QMessageBox::Cancel | QMessageBox::Escape );
1736 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
1737 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
1740 case QMessageBox::Yes:
1742 fileSave(CompleteMap);
1744 case QMessageBox::No:
1745 // close without saving
1747 case QMessageBox::Cancel:
1752 currentMapEditor()->closeMap();
1753 tabWidget->removePage(currentMapEditor());
1754 if (tabWidget->count()==0)
1755 actionFilePrint->setEnabled (false);
1759 void Main::filePrint()
1761 if (currentMapEditor())
1762 currentMapEditor()->print();
1765 void Main::fileExitVYM()
1767 // Check if one or more editors have changed
1770 for (i=0;i<=tabWidget->count() -1;i++)
1773 me=(MapEditor*)tabWidget->page(i);
1775 // If something changed, ask what to do
1776 if (me->isUnsaved())
1778 tabWidget->setCurrentPage(i);
1779 QMessageBox mb( "VYM",
1780 tr("This map is not saved yet. Do you want to"),
1781 QMessageBox::Warning,
1782 QMessageBox::Yes | QMessageBox::Default,
1784 QMessageBox::Cancel | QMessageBox::Escape );
1785 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
1786 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
1788 // Call undocumented function: setActiveWindow is only
1789 // possible, if widget is visible. This depends on
1791 #if defined(Q_OS_LINUX)
1792 qt_wait_for_window_manager( this);
1794 mb.setActiveWindow();
1795 switch( mb.exec() ) {
1796 case QMessageBox::Yes:
1797 // save (the changed editors) and exit
1798 fileSave(CompleteMap);
1800 case QMessageBox::No:
1801 // exit without saving
1803 case QMessageBox::Cancel:
1804 // don't save and don't exit
1808 } // loop over all MEs
1812 void Main::editUndo()
1814 if (currentMapEditor())
1815 currentMapEditor()->undo();
1818 void Main::editRedo() // TODO
1822 void Main::editCopy()
1824 if (currentMapEditor())
1825 currentMapEditor()->copy();
1828 void Main::editPaste()
1830 if (currentMapEditor())
1831 currentMapEditor()->paste();
1834 void Main::editCut()
1836 if (currentMapEditor())
1837 currentMapEditor()->cut();
1840 void Main::editOpenFindWindow()
1842 findWindow->popup();
1843 findWindow->raise();
1845 // Call undocumented function: setActiveWindow is only
1846 // possible, if widget is visible. This depends on
1848 #if defined(Q_OS_LINUX)
1849 qt_wait_for_window_manager( this);
1851 findWindow->setActiveWindow();
1854 void Main::editFind(QString s)
1857 BranchObj *bo=currentMapEditor()->findText(s, cs);
1860 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
1863 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
1864 tr("No matches found for ")+
1869 void Main::editFindChanged()
1870 { // Notify editor, to abort the current find process
1871 currentMapEditor()->findReset();
1874 void Main::editOpenURL()
1876 if (currentMapEditor())
1877 currentMapEditor()->openURL();
1880 void Main::editURL()
1882 if (currentMapEditor())
1883 currentMapEditor()->editURL();
1886 void Main::editHeading2URL()
1888 if (currentMapEditor())
1889 currentMapEditor()->editHeading2URL();
1892 void Main::editBugzilla2URL()
1894 if (currentMapEditor())
1895 currentMapEditor()->editBugzilla2URL();
1898 void Main::editOpenVymLink()
1900 // Get current path to map
1901 QString currentVymLink;
1902 if (currentMapEditor())
1904 currentVymLink=currentMapEditor()->getVymLink();
1905 // compare path with already loaded maps
1909 for (i=0;i<=tabWidget->count() -1;i++)
1911 me=(MapEditor*)tabWidget->page(i);
1912 if (currentVymLink==me->getFilePath() )
1921 if (!QFile(currentVymLink).exists() )
1922 QMessageBox::critical( 0, tr( "Critical Error" ),
1923 tr("Couldn't open map " +currentVymLink)+".");
1926 fileLoad (currentVymLink, NewMap);
1927 tabWidget->setCurrentPage (tabWidget->count()-1);
1930 // Go to tab containing the map
1931 tabWidget->setCurrentPage (index);
1935 void Main::editVymLink()
1937 if (currentMapEditor())
1938 currentMapEditor()->editVymLink();
1941 void Main::editDeleteVymLink()
1943 if (currentMapEditor())
1944 currentMapEditor()->deleteVymLink();
1947 void Main::editMapInfo()
1949 if (currentMapEditor())
1950 currentMapEditor()->editMapInfo();
1953 void Main::editMoveUp()
1955 if (currentMapEditor())
1956 currentMapEditor()->moveBranchUp();
1959 void Main::editMoveDown()
1961 if (currentMapEditor())
1962 currentMapEditor()->moveBranchDown();
1965 void Main::editToggleScroll()
1967 if (currentMapEditor())
1969 currentMapEditor()->toggleScroll();
1973 void Main::editUnScrollAll()
1975 if (currentMapEditor())
1977 currentMapEditor()->unScrollAll();
1981 void Main::editHeading()
1983 if (currentMapEditor())
1984 currentMapEditor()->editHeading();
1987 void Main::editNewBranch()
1989 if (currentMapEditor())
1990 currentMapEditor()->addNewBranch(0);
1993 void Main::editNewBranchHere()
1995 if (currentMapEditor())
1996 currentMapEditor()->addNewBranchHere();
1999 void Main::editNewBranchAbove()
2001 if (currentMapEditor())
2002 currentMapEditor()->addNewBranch(-1);
2005 void Main::editNewBranchBelow()
2007 if (currentMapEditor())
2008 currentMapEditor()->addNewBranch(1);
2011 void Main::editImportAdd()
2013 fileLoad (ImportAdd);
2016 void Main::editImportReplace()
2018 fileLoad (ImportReplace);
2021 void Main::editSaveBranch()
2023 fileSaveAs (PartOfMap);
2026 void Main::editRemoveBranchHere()
2028 if (currentMapEditor())
2029 currentMapEditor()->removeBranchHere();
2032 void Main::editRemoveChilds()
2034 if (currentMapEditor())
2035 currentMapEditor()->removeChilds();
2038 void Main::editDeleteSelection()
2040 if (currentMapEditor())
2041 currentMapEditor()->deleteSelection();
2044 void Main::editUpperBranch()
2046 if (currentMapEditor())
2047 currentMapEditor()->selectUpperBranch();
2050 void Main::editLowerBranch()
2052 if (currentMapEditor())
2053 currentMapEditor()->selectLowerBranch();
2056 void Main::editLeftBranch()
2058 if (currentMapEditor())
2059 currentMapEditor()->selectLeftBranch();
2062 void Main::editRightBranch()
2064 if (currentMapEditor())
2065 currentMapEditor()->selectRightBranch();
2068 void Main::editFirstBranch()
2070 if (currentMapEditor())
2071 currentMapEditor()->selectFirstBranch();
2074 void Main::editLastBranch()
2076 if (currentMapEditor())
2077 currentMapEditor()->selectLastBranch();
2080 void Main::editLoadImage()
2082 if (currentMapEditor())
2083 currentMapEditor()->loadFloatImage();
2086 void Main::editSaveImage(int item)
2088 if (currentMapEditor())
2089 currentMapEditor()->saveFloatImage(item);
2092 void Main::editToggleFloatExport()
2094 if (currentMapEditor())
2095 currentMapEditor()->toggleFloatExport();
2098 void Main::editFollowXLink(int item)
2100 if (currentMapEditor())
2101 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2104 void Main::editEditXLink(int item)
2106 if (currentMapEditor())
2107 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2110 void Main::formatSelectColor()
2112 if (currentMapEditor())
2114 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2115 if ( !col.isValid() ) return;
2116 currentMapEditor()->setColor( col );
2117 colorChanged( col );
2121 void Main::formatPickColor()
2123 if (currentMapEditor())
2124 colorChanged( currentMapEditor()->pickColor() );
2127 void Main::colorChanged(QColor c)
2129 QPixmap pix( 16, 16 );
2131 actionFormatColor->setIconSet( pix );
2134 void Main::formatColorItem()
2136 if (currentMapEditor())
2137 currentMapEditor()->colorItem();
2140 void Main::formatColorBranch()
2142 if (currentMapEditor())
2143 currentMapEditor()->colorBranch();
2146 void Main::formatLinkStyleLine()
2148 if (currentMapEditor())
2149 currentMapEditor()->setLinkStyle(StyleLine);
2152 void Main::formatLinkStyleParabel()
2154 if (currentMapEditor())
2155 currentMapEditor()->setLinkStyle(StyleParabel);
2158 void Main::formatLinkStylePolyLine()
2160 if (currentMapEditor())
2161 currentMapEditor()->setLinkStyle(StylePolyLine);
2164 void Main::formatLinkStylePolyParabel()
2166 if (currentMapEditor())
2167 currentMapEditor()->setLinkStyle(StylePolyParabel);
2170 void Main::formatSelectBackColor()
2172 if (currentMapEditor())
2173 currentMapEditor()->selectBackgroundColor();
2176 void Main::formatSelectLinkColor()
2178 if (currentMapEditor())
2179 currentMapEditor()->selectLinkColor();
2182 void Main::formatToggleLinkColorHint()
2184 currentMapEditor()->toggleLinkColorHint();
2187 void Main::formatFrameNone()
2189 if (currentMapEditor())
2190 currentMapEditor()->setFrame(NoFrame);
2193 void Main::formatFrameRectangle()
2195 if (currentMapEditor())
2196 currentMapEditor()->setFrame(Rectangle);
2199 void Main::viewZoomReset()
2201 if (currentMapEditor())
2205 currentMapEditor()->setWorldMatrix( m );
2206 currentMapEditor()->setViewCenter();
2207 currentMapEditor()->adjustCanvasSize();
2211 void Main::viewZoomIn()
2213 if (currentMapEditor())
2215 QWMatrix m = currentMapEditor()->worldMatrix();
2216 m.scale( 1.25, 1.25 );
2217 currentMapEditor()->setWorldMatrix( m );
2218 currentMapEditor()->setViewCenter();
2219 currentMapEditor()->adjustCanvasSize();
2223 void Main::viewZoomOut()
2225 if (currentMapEditor())
2227 QWMatrix m = currentMapEditor()->worldMatrix();
2228 m.scale( 0.8, 0.8 );
2229 currentMapEditor()->setWorldMatrix( m );
2230 currentMapEditor()->setViewCenter();
2231 currentMapEditor()->adjustCanvasSize();
2235 void Main::modModeColor()
2239 void Main::modModeLink()
2243 bool Main::settingsPDF()
2245 // Default browser is set in constructor
2247 QString text = QInputDialog::getText(
2248 "VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
2249 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2251 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2256 bool Main::settingsURL()
2258 // Default browser is set in constructor
2260 QString text = QInputDialog::getText(
2261 "VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
2262 settings.readEntry("/vym/mainwindow/readerURL")
2265 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2269 void Main::windowToggleNoteEditor()
2271 if (textEditor->showWithMain() )
2272 windowHideNoteEditor();
2274 windowShowNoteEditor();
2277 void Main::windowShowNoteEditor()
2279 textEditor->setShowWithMain(true);
2281 actionViewToggleNoteEditor->setOn (true);
2284 void Main::windowHideNoteEditor()
2286 textEditor->setShowWithMain(false);
2288 actionViewToggleNoteEditor->setOn (false);
2291 void Main::windowNextEditor()
2293 if (tabWidget->currentPageIndex() < tabWidget->count())
2294 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
2297 void Main::windowPreviousEditor()
2299 if (tabWidget->currentPageIndex() >0)
2300 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
2303 void Main::standardFlagChanged()
2305 currentMapEditor()->toggleStandardFlag(sender()->name());
2308 void Main::testFunction()
2310 //textEditor->stackUnder(this);
2311 currentMapEditor()->testFunction();
2314 void Main::testShowClipboard()
2316 clipboardME->show();
2319 void Main::helpDoc()
2322 #if defined(Q_OS_MACX)
2323 docpath="./vym.app/Contents/vym.pdf";
2325 // default path in SUSE LINUX
2326 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
2329 if (!QFile (docpath).exists() )
2331 // relative path for easy testing in tarball
2332 docpath="doc/vym.pdf";
2333 if (!QFile (docpath).exists() )
2335 // relative path for testing while still writing vym.tex
2336 docpath="doc/tex/vym.pdf";
2337 if (!QFile (docpath).exists() )
2339 QMessageBox::critical(0,
2340 tr("Critcal error"),
2341 tr("Couldn't find the documentation\n"
2342 "vym.pdf in various places."));
2348 Process *pdfProc = new Process();
2349 pdfProc->clearArguments();
2350 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
2351 pdfProc->addArgument( docpath);
2353 if ( !pdfProc->start() )
2356 QMessageBox::critical(0,
2357 tr("Critcal error"),
2358 tr("Couldn't find a viewer to read vym.pdf.\n"
2359 "Please use Settings->")+tr("Set application to open pdf files"));
2365 void Main::helpAbout()
2367 static QMessageBox* about = new QMessageBox( "VYM",
2368 "<h3>VYM - View Your Mind </h3>"
2369 "<p> A tool to put the things you have got in your mind into a map.</p>"
2371 "<li> (c) by Uwe Drechsel (vym@InSilmaril.de)</li>"
2372 "<li> vym is released under the GPL (Gnu General Public License)"
2373 ", with one exception (see the file \"LICENSE\"which "
2374 "comes with vym). This exception is needed to build vym with QT libraries for proprietary operating systems.</li>"
2375 "<li> Project homepage <a href=\"http:/www.InSilmaril.de/vym\">"
2376 "http:/www.InSilmaril.de/vym</a></li>"
2379 "<li>Jakob Hilmer for image drag and drop patch </li>"
2380 "<li>Thomas Schraitle for the stylesheet used for XHTML-export </li>"
2381 "<li>Clemens Kraus for stylesheets and script used for HTML-export "
2382 "<a href=\"http://www.clemens-kraus.de\">(www.clemens-kraus.de)</a></li>"
2383 "<li>Alexander Johannesen for providing stylesheets from his xsiteable project "
2384 "<a href=\"http://www.shelter.nu/xsiteable/xsiteable.html\">(www.shelter.nu/xsiteable/xsiteable.html)</a>. </li>"
2385 "<li>Ken Wimer and Olaf Hering for Mac support</li>"
2388 "<li> Version " __VYM_VERSION__ "</li>"
2389 "<li> Build date " __BUILD_DATE__"</li>"
2390 "</ul>", QMessageBox::Information, 1, 0, 0, this, 0, FALSE );
2391 about->setButtonText( 1, "Dismiss" );
2392 about->setMinimumSize(QSize(300,300));
2393 about->setIconPixmap (QPixmap(vym_logo_xpm));
2397 void Main::helpAboutQT()
2399 QMessageBox::aboutQt( this, "Qt Application Example" );