3 #include "mainwindow.h"
5 //#include <qstatusbar.h>
6 //#include <qmessagebox.h>
7 //#include <qmenubar.h>
8 //#include <qapplication.h>
12 #include <q3filedialog.h>
14 #include <qcolordialog.h>
16 #include <qinputdialog.h>
20 #include <QCloseEvent>
23 #include <Q3PopupMenu>
24 #include <QActionGroup>
26 //#include <qdatetime.h> // for random seed
32 #include "aboutdialog.h"
33 #include "exportoofiledialog.h"
35 #include "exportxhtmldialog.h"
37 #include "flagrowobj.h"
39 #include "mapeditor.h"
44 #include "showtextdialog.h"
45 #include "texteditor.h"
48 extern TextEditor *textEditor;
49 extern Main *mainWindow;
50 extern QString tmpVymDir;
51 extern QString clipboardDir;
52 extern bool clipboardEmpty;
53 extern int statusbarTime;
54 extern FlagRowObj* standardFlagsDefault;
55 extern FlagRowObj* systemFlagsDefault;
57 extern Q3PtrList <QAction> actionListBranches;
59 extern QAction* actionFileSave;
60 extern QAction* actionFilePrint;
61 extern QAction* actionEditUndo;
62 extern QAction* actionEditRedo;
63 extern QAction *actionEditCopy;
64 extern QAction *actionEditCut;
65 extern QAction *actionEditPaste;
66 extern QAction *actionEditMoveUp;
67 extern QAction *actionEditMoveDown;
68 extern QAction *actionEditToggleScroll;
69 extern QAction* actionEditOpenURL;
70 extern QAction* actionEditOpenURLTab;
71 extern QAction* actionEditURL;
72 extern QAction* actionEditHeading2URL;
73 extern QAction* actionEditBugzilla2URL;
74 extern QAction* actionEditFATE2URL;
75 extern QAction *actionEditOpenVymLink;
76 extern QAction *actionEditVymLink;
77 extern QAction *actionEditDeleteVymLink;
78 extern QAction *actionEditToggleHideExport;
79 extern QAction *actionEditMapInfo;
80 extern QAction *actionEditHeading;
81 extern QAction *actionEditDelete;
82 extern QAction *actionEditAddBranch;
83 extern QAction *actionEditAddBranchHere;
84 extern QAction *actionEditAddBranchAbove;
85 extern QAction *actionEditAddBranchBelow;
86 extern QAction *actionEditRemoveBranchKeepChilds;
87 extern QAction *actionEditRemoveChilds;
88 extern QAction *actionEditImportAdd;
89 extern QAction *actionEditImportReplace;
90 extern QAction *actionEditSaveBranch;
91 extern QAction *actionEditSelectFirst;
92 extern QAction *actionEditSelectLast;
93 extern QAction *actionEditLoadImage;
95 extern QAction* actionFormatColor;
96 extern QAction* actionFormatPickColor;
97 extern QAction* actionFormatColorBranch;
98 extern QAction* actionFormatColorSubtree;
99 extern QAction* actionFormatLinkColorHint;
100 extern QAction* actionFormatBackColor;
101 extern QAction* actionFormatLinkColor;
102 extern QAction *actionFormatIncludeImagesVer;
103 extern QAction *actionFormatIncludeImagesHor;
105 extern QActionGroup* actionGroupModModes;
106 extern QAction* actionModModeColor;
107 extern QAction* actionModModeLink;
108 extern QAction* actionModModeCopy;
110 extern QActionGroup *actionGroupFormatFrameTypes;
111 extern QAction *actionFormatFrameNone;
112 extern QAction *actionFormatFrameRectangle;
114 extern QActionGroup *actionGroupFormatLinkStyles;
115 extern QAction *actionFormatLinkStyleLine;
116 extern QAction *actionFormatLinkStyleParabel;
117 extern QAction *actionFormatLinkStylePolyLine;
118 extern QAction *actionFormatLinkStylePolyParabel;
119 extern QAction *actionFormatHideLinkUnselected;
121 extern QAction *actionViewToggleNoteEditor;
122 extern QAction *actionViewToggleHistoryWindow;
124 extern QAction* actionSettingsAutoedit;
125 extern QAction* actionSettingsAutoselectHeading;
126 extern QAction* actionSettingsAutoselectHeading;
127 extern QAction* actionSettingsAutoselectText;
128 extern QAction* actionSettingsPasteNewHeading;
129 extern QAction* actionSettingsUseDelKey;
130 extern QAction* actionSettingsUseFlagGroups;
131 extern QAction* actionSettingsUseHideExport;
133 extern QMenu* branchContextMenu;
134 extern QMenu* branchAddContextMenu;
135 extern QMenu* branchRemoveContextMenu;
136 extern QMenu* branchLinksContextMenu;
137 extern QMenu* branchLinksContextMenuDup;
138 extern QMenu* floatimageContextMenu;
139 extern QMenu* saveImageFormatMenu;
140 extern QMenu* canvasContextMenu;
141 extern QMenu* fileLastMapsMenu;
142 extern QMenu* fileImportMenu;
143 extern QMenu* fileExportMenu;
146 extern Settings settings;
147 extern Options options;
148 extern ImageIO imageIO;
150 extern QDir vymBaseDir;
151 extern QDir lastImageDir;
152 extern QString iconPath;
153 extern QString flagsPath;
155 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
156 QMainWindow(parent,name,f)
160 setCaption ("VYM - View Your Mind");
162 // Load window settings
163 resize (settings.readNumEntry( "/vym/mainwindow/geometry/width", 800),
164 settings.readNumEntry( "/vym/mainwindow/geometry/height",600));
165 move (settings.readNumEntry( "/vym/mainwindow/geometry/posX", 100),
166 settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
169 // Create unique temporary directory
170 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
172 // Create direcctory for clipboard
173 clipboardDir=tmpVymDir+"/clipboard";
174 QDir d(clipboardDir);
175 d.mkdir (clipboardDir,true);
176 makeSubDirs (clipboardDir);
181 // FIXME not used currently
182 // Set random seed (random used for object IDs)
183 // QTime t = QTime::currentTime(); // set random seed
184 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
187 // Initialize some settings, which are platform dependant
190 // application to open URLs
191 p="/vym/mainwindow/readerURL";
192 #if defined(Q_OS_LINUX)
193 s=settings.readEntry (p,"konqueror");
195 #if defined(Q_OS_MACX)
196 s=settings.readEntry (p,"/usr/bin/open");
198 s=settings.readEntry (p,"mozilla");
201 settings.writeEntry( p,s);
203 // application to open PDFs
204 p="/vym/mainwindow/readerPDF";
205 #if defined(Q_OS_LINUX)
206 s=settings.readEntry (p,"acroread");
208 #if defined(Q_OS_MACX)
209 s=settings.readEntry (p,"/usr/bin/open");
211 s=settings.readEntry (p,"acroread");
214 settings.writeEntry( p,s);
219 // Create tab widget which holds the maps
220 tabWidget= new QTabWidget (this);
221 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
222 this, SLOT( editorChanged( QWidget * ) ) );
224 setCentralWidget(tabWidget);
228 setupFormatActions();
232 setupSettingsActions();
234 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
237 // After menu is created, we can enable some actions
238 //FIXME testing actionFilePrint->setEnabled (true);
243 // Initialize Find window
244 findWindow=new FindWindow(NULL,"findwindow");
245 connect (findWindow, SIGNAL( findButton(QString) ),
246 this, SLOT(editFind(QString) ) );
247 connect (findWindow, SIGNAL( somethingChanged() ),
248 this, SLOT(editFindChanged() ) );
250 // Connect TextEditor, so that we can update flags if text changes
251 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
259 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
260 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
261 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
262 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
264 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
265 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
267 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
268 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
269 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
270 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
271 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
272 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
273 settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
276 int maps=lastMaps.count();
277 settings.writeEntry( "/vym/lastMaps/number",maps );
278 for (int i=1;i<=maps;i++)
280 s=QString("/vym/lastMaps/map-%1").arg(i);
281 if (!s.isEmpty() && i<=maxLastMaps)
282 settings.writeEntry (s, lastMaps.at(i-1));
286 // To make the texteditor save its settings, call the destructor
289 // Remove temporary directory
290 removeDir (QDir(tmpVymDir));
293 void Main::loadCmdLine()
295 /* TODO draw some kind of splashscreen while loading...
301 QStringList flist=options.getFileList();
302 QStringList::Iterator it=flist.begin();
304 while (it !=flist.end() )
306 fileLoad (*it, NewMap);
312 void Main::statusMessage(const QString &s)
314 statusBar()->message (s);
317 void Main::closeEvent (QCloseEvent* )
323 void Main::setupFileActions()
325 QMenu *fileMenu = menuBar()->addMenu ( tr ("&File") );
326 QToolBar *tb = addToolBar( tr ("&File") );
329 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
330 a->setStatusTip ( tr( "New map","File menu" ) );
331 a->setShortcut ( Qt::CTRL + Qt::Key_N );
333 fileMenu->addAction (a);
334 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
336 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
337 a->setStatusTip (tr( "Open","File menu" ) );
338 a->setShortcut ( Qt::CTRL + Qt::Key_O );
340 fileMenu->addAction (a);
341 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
343 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent"));
344 fileMenu->addSeparator();
346 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
347 a->setStatusTip ( tr( "Save" ));
348 a->setShortcut (Qt::CTRL + Qt::Key_S );
350 fileMenu->addAction (a);
351 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
354 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
355 a->setStatusTip (tr( "Save &As" ) );
356 fileMenu->addAction (a);
357 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
359 fileMenu->addSeparator();
361 fileImportMenu = fileMenu->addMenu (tr("Import"));
363 a = new QAction(tr("KDE Bookmarks"), this);
364 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
365 a->addTo (fileImportMenu);
366 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
368 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
370 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
371 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
372 a->addTo (fileImportMenu);
373 connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
376 a = new QAction("Mind Manager...",this);
377 a->setStatusTip ( tr( "Import")+" Mind Manager" );
378 fileImportMenu->addAction (a);
379 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
381 a = new QAction( tr( "Import Dir"+QString("...") ), this);
382 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
383 fileImportMenu->addAction (a);
384 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
386 fileExportMenu = fileMenu->addMenu (tr("Export"));
388 a = new QAction( tr("Image")+QString("..."), this);
389 a->setStatusTip( tr( "Export map as image" ));
390 connect( a, SIGNAL( activated() ), this, SLOT( fileExportImage() ) );
391 fileExportMenu->addAction (a);
393 a = new QAction( "Open Office"+QString("..."), this);
394 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
395 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
396 fileExportMenu->addAction (a);
398 a = new QAction( "Webpage (XHTML)...",this );
399 a->setShortcut (Qt::ALT + Qt::Key_X);
400 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
401 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
402 fileExportMenu->addAction (a);
404 a = new QAction( "Text (ASCII)...", this);
405 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
406 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
407 fileExportMenu->addAction (a);
409 a = new QAction( tr("KDE Bookmarks"), this);
410 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
411 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
412 fileExportMenu->addAction (a);
414 a = new QAction( "Taskjuggler...", this );
415 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
416 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
417 fileExportMenu->addAction (a);
419 a = new QAction( "LaTeX...", this);
420 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
421 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
422 fileExportMenu->addAction (a);
424 a = new QAction( "XML..." , this );
425 a->setStatusTip (tr( "Export as")+" XML");
426 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
427 fileExportMenu->addAction (a);
429 fileMenu->addSeparator();
431 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
432 a->setStatusTip ( tr( "Print" ) );
433 a->setShortcut (Qt::CTRL + Qt::Key_P );
435 fileMenu->addAction (a);
436 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
439 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
440 a->setStatusTip (tr( "Close Map" ) );
441 a->setShortcut (Qt::ALT + Qt::Key_C );
442 fileMenu->addAction (a);
443 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
445 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
446 a->setStatusTip ( tr( "Exit")+" "+__VYM );
447 a->setShortcut (Qt::CTRL + Qt::Key_Q );
448 fileMenu->addAction (a);
449 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
454 void Main::setupEditActions()
456 QToolBar *tb = addToolBar( tr ("&Edit") );
457 tb->setLabel( "Edit Actions" );
458 Q3PopupMenu *menu = new Q3PopupMenu( this );
459 menuBar()->insertItem( tr( "&Edit" ), menu );
463 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
464 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
465 a->setStatusTip (tr( "Undo" ) );
466 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
467 a->setEnabled (false);
472 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
474 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
475 a->setStatusTip (tr( "Redo" ));
476 a->setShortcut (Qt::CTRL + Qt::Key_Y );
479 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
482 menu->insertSeparator();
483 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
484 a->setStatusTip ( tr( "Copy" ) );
485 a->setShortcut (Qt::CTRL + Qt::Key_C );
486 a->setEnabled (false);
489 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
492 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
493 a->setStatusTip ( tr( "Cut" ) );
494 a->setShortcut (Qt::CTRL + Qt::Key_X );
495 a->setEnabled (false);
499 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
501 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
502 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
503 a->setStatusTip ( tr( "Paste" ) );
504 a->setShortcut ( Qt::CTRL + Qt::Key_V );
505 a->setEnabled (false);
510 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
511 a->setStatusTip ( tr( "Move branch up" ) );
512 a->setShortcut (Qt::Key_PageUp );
513 a->setEnabled (false);
516 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
519 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
520 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
521 a->setStatusTip (tr( "Move branch down" ) );
522 a->setShortcut ( Qt::Key_PageDown );
523 a->setEnabled (false);
526 actionEditMoveDown=a;
529 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
530 a->setShortcut ( Qt::Key_ScrollLock );
531 a->setStatusTip (tr( "Scroll branch" ) );
532 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
533 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
534 alt->setShortcut ( Qt::Key_S );
535 alt->setStatusTip (tr( "Scroll branch" ));
536 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
537 #if defined(Q_OS_MACX)
538 actionEditToggleScroll=alt;
540 actionEditToggleScroll=a;
542 actionEditToggleScroll->setEnabled (false);
543 actionEditToggleScroll->setToggleAction(true);
544 actionEditToggleScroll->addTo( tb );
545 actionEditToggleScroll->addTo( menu );
546 actionListBranches.append(actionEditToggleScroll);
548 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
549 a->setStatusTip (tr( "Unscroll all" ));
551 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
553 menu->insertSeparator();
555 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
556 a->setStatusTip (tr( "Find" ) );
557 a->setShortcut (Qt::CTRL + Qt::Key_F );
559 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
561 menu->insertSeparator();
563 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
564 a->setShortcut (Qt::CTRL + Qt::Key_U );
565 a->setShortcut (tr( "Open URL" ));
567 a->setEnabled (false);
568 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
571 a = new QAction( tr( "Open URL in new tab" ), this);
572 a->setStatusTip (tr( "Open URL in new tab" ));
573 a->setShortcut (Qt::CTRL+Qt::Key_U );
574 a->setEnabled (false);
575 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
576 actionEditOpenURLTab=a;
578 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
579 a->setStatusTip ( tr( "Edit URL" ) );
580 a->setShortcut (Qt::SHIFT + Qt::CTRL+Qt::Key_U );
581 a->setEnabled (false);
582 actionListBranches.append(a);
583 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
586 a = new QAction( tr( "Use heading for URL" ), this);
587 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
588 a->setEnabled (false);
589 actionListBranches.append(a);
590 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
591 actionEditHeading2URL=a;
593 a = new QAction(tr( "Create URL to Bugzilla" ), this);
594 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
595 a->setEnabled (false);
596 actionListBranches.append(a);
597 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
598 actionEditBugzilla2URL=a;
600 a = new QAction(tr( "Create URL to FATE" ), this);
601 a->setStatusTip ( tr( "Create URL to FATE" ));
602 a->setEnabled (false);
603 actionListBranches.append(a);
604 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
605 actionEditFATE2URL=a;
607 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
608 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
610 a->setEnabled (false);
611 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
612 actionEditOpenVymLink=a;
614 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
615 a->setEnabled (false);
616 a->setStatusTip ( tr( "Edit link to another vym map" ));
617 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
618 actionListBranches.append(a);
621 a = new QAction(tr( "Delete vym link" ),this);
622 a->setStatusTip ( tr( "Delete link to another vym map" ));
623 a->setEnabled (false);
624 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
625 actionEditDeleteVymLink=a;
627 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
628 a->setStatusTip ( tr( "Hide object in exports" ) );
629 a->setShortcut (Qt::Key_H );
630 a->setToggleAction(true);
632 a->setEnabled (false);
633 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
634 actionEditToggleHideExport=a;
636 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
637 a->setStatusTip ( tr( "Edit Map Info" ));
638 a->setEnabled (true);
639 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
642 menu->insertSeparator();
644 // Shortcuts to modify heading:
646 a = new QAction(tr( "Edit heading" ),this);
647 a->setStatusTip ( tr( "edit Heading" ));
648 a->setShortcut ( Qt::Key_Enter);
649 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
650 actionListBranches.append(a);
652 a = new QAction( tr( "Edit heading" ), this);
653 a->setStatusTip (tr( "edit Heading" ));
654 a->setShortcut (Qt::Key_Return );
655 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
656 //actionListBranches.append(a);
660 a = new QAction( tr( "Edit heading" ),this);
661 a->setStatusTip (tr( "edit Heading" ));
662 a->setShortcut ( Qt::Key_F2 );
663 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
664 a->setEnabled (false);
665 actionListBranches.append(a);
668 // Shortcut to delete selection
669 a = new QAction( tr( "Delete Selection" ),this);
670 a->setStatusTip (tr( "Delete Selection" ));
671 a->setShortcut ( Qt::Key_Delete);
672 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
673 a->setEnabled (false);
676 // Shortcut to add branch
677 alt = new QAction(tr( "Add branch as child" ), this);
678 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
679 alt->setShortcut (Qt::Key_A);
680 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
681 a = new QAction(tr( "Add branch as child" ), this);
682 a->setStatusTip ( tr( "Add a branch as child of selection" ));
683 a->setShortcut (Qt::Key_Insert);
684 // a->setEnabled (false);
685 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
686 actionListBranches.append(a);
687 #if defined (Q_OS_MACX)
688 // In OSX show different shortcut in menues, the keys work independtly always
689 actionEditAddBranch=alt;
691 actionEditAddBranch=a;
694 // Add branch by inserting it at selection
695 a = new QAction(tr( "Add branch (insert)" ), this);
696 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
697 a->setShortcut (Qt::ALT + Qt::Key_Insert );
698 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
699 a->setEnabled (false);
700 actionListBranches.append(a);
701 actionEditAddBranchHere=a;
702 a = new QAction(tr( "Add branch (insert)" ),this);
703 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
704 a->setShortcut ( Qt::ALT + Qt::Key_A );
705 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
706 actionListBranches.append(a);
709 a = new QAction(tr( "Add branch above" ), this);
710 a->setStatusTip ( tr( "Add a branch above selection" ));
711 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
712 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
713 a->setEnabled (false);
714 actionListBranches.append(a);
715 actionEditAddBranchAbove=a;
716 a = new QAction(tr( "Add branch above" ), this);
717 a->setStatusTip ( tr( "Add a branch above selection" ));
718 a->setShortcut (Qt::SHIFT+Qt::Key_A );
719 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
720 actionListBranches.append(a);
723 a = new QAction(tr( "Add branch below" ), this);
724 a->setStatusTip ( tr( "Add a branch below selection" ));
725 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
726 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
727 a->setEnabled (false);
728 actionListBranches.append(a);
729 actionEditAddBranchBelow=a;
730 a = new QAction(tr( "Add branch below" ), this);
731 a->setStatusTip ( tr( "Add a branch below selection" ));
732 a->setShortcut (Qt::CTRL +Qt::Key_A );
733 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
734 actionListBranches.append(a);
736 // Import at selection (adding to selection)
737 a = new QAction( tr( "Add map (insert)" ),this);
738 a->setStatusTip (tr( "Add map at selection" ));
739 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
740 a->setEnabled (false);
741 actionListBranches.append(a);
742 actionEditImportAdd=a;
744 // Import at selection (replacing selection)
745 a = new QAction( tr( "Add map (replace)" ), this);
746 a->setStatusTip (tr( "Replace selection with map" ));
747 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
748 a->setEnabled (false);
749 actionListBranches.append(a);
750 actionEditImportReplace=a;
753 a = new QAction( tr( "Save selection" ), this);
754 a->setStatusTip (tr( "Save selection" ));
755 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
756 a->setEnabled (false);
757 actionListBranches.append(a);
758 actionEditSaveBranch=a;
760 // Only remove branch, not its childs
761 a = new QAction(tr( "Remove only branch " ), this);
762 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
763 a->setShortcut (Qt::ALT + Qt::Key_Delete );
764 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
765 a->setEnabled (false);
766 actionListBranches.append(a);
767 actionEditRemoveBranchKeepChilds=a;
769 // Only remove childs of a branch
770 a = new QAction( tr( "Remove childs" ), this);
771 a->setStatusTip (tr( "Remove childs of branch" ));
772 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
773 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
774 a->setEnabled (false);
775 actionListBranches.append(a);
776 actionEditRemoveChilds=a;
778 // Shortcuts for navigating with cursor:
779 a = new QAction(tr( "Select upper branch" ), this);
780 a->setStatusTip ( tr( "Select upper branch" ));
781 a->setShortcut (Qt::Key_Up );
782 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
783 a = new QAction( tr( "Select lower branch" ),this);
784 a->setStatusTip (tr( "Select lower branch" ));
785 a->setShortcut ( Qt::Key_Down );
786 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
787 a = new QAction(tr( "Select left branch" ), this);
788 a->setStatusTip ( tr( "Select left branch" ));
789 a->setShortcut (Qt::Key_Left );
790 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
791 a = new QAction( tr( "Select child branch" ), this);
792 a->setStatusTip (tr( "Select right branch" ));
793 a->setShortcut (Qt::Key_Right);
794 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
795 a = new QAction( tr( "Select first branch" ), this);
796 a->setStatusTip (tr( "Select first branch" ));
797 a->setShortcut (Qt::Key_Home );
798 a->setEnabled (false);
800 actionListBranches.append(a);
801 actionEditSelectFirst=a;
802 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
803 a = new QAction( tr( "Select last branch" ),this);
804 a->setStatusTip (tr( "Select last branch" ));
805 a->setShortcut ( Qt::Key_End );
806 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
807 a->setEnabled (false);
809 actionListBranches.append(a);
810 actionEditSelectLast=a;
812 a = new QAction( tr( "Add Image" )+QString("..."), this);
813 a->setStatusTip (tr( "Add Image" ));
814 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
815 actionEditLoadImage=a;
820 void Main::setupFormatActions()
822 Q3PopupMenu *menu = new Q3PopupMenu( this );
823 menuBar()->insertItem( tr( "F&ormat" ), menu );
825 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
828 pix.fill (Qt::black);
829 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
830 a->setStatusTip ( tr( "Set Color" ));
831 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
835 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
836 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
837 a->setShortcut (Qt::CTRL + Qt::Key_K );
838 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
839 a->setEnabled (false);
842 actionListBranches.append(a);
843 actionFormatPickColor=a;
845 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
846 a->setStatusTip ( tr( "Color branch" ) );
847 a->setShortcut (Qt::CTRL + Qt::Key_I);
848 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
849 a->setEnabled (false);
852 actionListBranches.append(a);
853 actionFormatColorBranch=a;
855 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
856 a->setStatusTip ( tr( "Color Subtree" ));
857 a->setShortcut (Qt::CTRL + Qt::Key_T);
858 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
859 a->setEnabled (false);
862 actionListBranches.append(a);
863 actionFormatColorSubtree=a;
865 menu->insertSeparator();
866 actionGroupFormatLinkStyles=new QActionGroup ( this);
867 actionGroupFormatLinkStyles->setExclusive (true);
868 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
869 a->setStatusTip (tr( "Line" ));
870 a->setToggleAction(true);
871 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
872 actionFormatLinkStyleLine=a;
873 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
874 a->setStatusTip (tr( "Line" ));
875 a->setToggleAction(true);
876 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
877 actionFormatLinkStyleParabel=a;
878 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
879 a->setStatusTip (tr( "PolyLine" ));
880 a->setToggleAction(true);
881 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
882 actionFormatLinkStylePolyLine=a;
883 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
884 a->setStatusTip (tr( "PolyParabel" ) );
885 a->setToggleAction(true);
886 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
887 actionFormatLinkStylePolyParabel=a;
888 actionGroupFormatLinkStyles->addTo (menu);
890 actionGroupFormatFrameTypes=new QActionGroup ( this);
891 actionGroupFormatFrameTypes->setExclusive (true);
892 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
893 a->setStatusTip (tr("No Frame"));
894 a->setToggleAction(true);
895 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
896 actionFormatFrameNone=a;
897 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
898 a->setStatusTip (tr( "Rectangle" ));
899 a->setToggleAction(true);
900 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
901 actionFormatFrameRectangle=a;
903 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
904 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
905 a->setToggleAction(true);
906 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
907 actionFormatIncludeImagesVer=a;
909 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
910 a->setStatusTip ( tr ("Include left and right position of images into branch"));
911 a->setToggleAction(true);
912 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
913 actionFormatIncludeImagesHor=a;
915 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
916 a->setStatusTip (tr( "Hide link" ));
917 a->setToggleAction(true);
918 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
919 actionFormatHideLinkUnselected=a;
921 menu->insertSeparator();
922 a= new QAction( tr( "&Use color of heading for link" ), this);
923 a->setStatusTip (tr( "Use same color for links and headings" ));
924 a->setToggleAction(true);
925 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
927 actionFormatLinkColorHint=a;
929 pix.fill (Qt::white);
930 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
931 a->setStatusTip (tr( "Set Link Color" ));
933 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
934 actionFormatLinkColor=a;
936 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
937 a->setStatusTip (tr( "Set Background Color" ));
939 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
940 actionFormatBackColor=a;
944 void Main::setupViewActions()
946 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
947 tb->setLabel( "View Actions" );
948 Q3PopupMenu *menu = new Q3PopupMenu( this );
949 menuBar()->insertItem( tr( "&View" ), menu );
952 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
953 a->setStatusTip ( tr( "Zoom reset" ) );
954 a->setShortcut (Qt::CTRL + Qt::Key_0 );
957 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
959 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
960 a->setStatusTip (tr( "Zoom in" ));
961 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
964 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
966 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
967 a->setStatusTip (tr( "Zoom out" ));
968 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
971 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
974 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
975 a->setStatusTip ( tr( "Show Note Editor" ));
976 a->setShortcut ( Qt::CTRL + Qt::Key_E );
977 a->setToggleAction(true);
978 if (textEditor->showWithMain())
984 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
985 actionViewToggleNoteEditor=a;
987 a = new QAction( tr( "Show history window" ),this );
988 a->setStatusTip ( tr( "Show history window" ));
989 a->setShortcut ( Qt::CTRL + Qt::Key_H );
990 a->setToggleAction(false);
992 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
993 actionViewToggleHistoryWindow=a;
995 a = new QAction(tr( "Next Window" ), this);
996 a->setStatusTip ( tr( "&Next Window" ) );
997 a->setShortcut (Qt::ALT + Qt::Key_N );
999 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
1001 a = new QAction (tr( "Previous Window" ), this );
1002 a->setStatusTip (tr( "&Previous Window" ));
1003 a->setShortcut (Qt::ALT + Qt::Key_P );
1005 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
1009 void Main::setupModeActions()
1011 //QPopupMenu *menu = new QPopupMenu( this );
1012 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1014 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
1016 actionGroupModModes=new QActionGroup ( this);
1017 actionGroupModModes->setExclusive (true);
1018 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
1019 a->setShortcut (Qt::Key_J);
1020 a->setStatusTip ( tr( "Use modifier to color branches" ));
1021 a->setToggleAction(true);
1024 actionModModeColor=a;
1026 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
1027 a->setShortcut( Qt::Key_K);
1028 a->setStatusTip( tr( "Use modifier to copy" ));
1029 a->setToggleAction(true);
1031 actionModModeCopy=a;
1033 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1034 a->setShortcut (Qt::Key_L);
1035 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1036 a->setToggleAction(true);
1038 actionModModeLink=a;
1042 void Main::setupFlagActions()
1044 // Create System Flags
1045 systemFlagsDefault = new FlagRowObj ();
1046 systemFlagsDefault->setVisibility (false);
1047 systemFlagsDefault->setName ("systemFlagsDef");
1049 FlagObj *fo = new FlagObj ();
1050 fo->load(QPixmap(flagsPath+"flag-note.png"));
1051 fo->setName("note");
1052 fo->setToolTip(tr("Note","Systemflag"));
1053 systemFlagsDefault->addFlag (fo); // makes deep copy
1055 fo->load(QPixmap(flagsPath+"flag-url.png"));
1057 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1058 systemFlagsDefault->addFlag (fo);
1060 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1061 fo->setName("vymLink");
1062 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1063 systemFlagsDefault->addFlag (fo);
1065 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1066 fo->setName("scrolledright");
1067 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1068 systemFlagsDefault->addFlag (fo);
1070 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1071 fo->setName("tmpUnscrolledright");
1072 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1073 systemFlagsDefault->addFlag (fo);
1075 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1076 fo->setName("hideInExport");
1077 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1078 systemFlagsDefault->addFlag (fo);
1080 // Create Standard Flags
1081 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1083 standardFlagsDefault = new FlagRowObj ();
1084 standardFlagsDefault->setVisibility (false);
1085 standardFlagsDefault->setName ("standardFlagsDef");
1086 standardFlagsDefault->setToolBar (tb);
1088 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1089 fo->setName ("exclamationmark");
1090 fo->setGroup("standard-mark");
1091 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1094 a->setCheckable(true);
1095 a->setObjectName(fo->getName());
1096 a->setToolTip(tr("Take care!","Standardflag"));
1097 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1098 standardFlagsDefault->addFlag (fo); // makes deep copy
1100 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1101 fo->setName("questionmark");
1102 fo->setGroup("standard-mark");
1103 a=new QAction (fo->getPixmap(),fo->getName(),this);
1106 a->setCheckable(true);
1107 a->setObjectName(fo->getName());
1108 a->setToolTip(tr("Really?","Standardflag"));
1109 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1110 standardFlagsDefault->addFlag (fo);
1112 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1113 fo->setName("hook-green");
1114 fo->setGroup("standard-hook");
1115 a=new QAction (fo->getPixmap(),fo->getName(),this);
1118 a->setCheckable(true);
1119 a->setObjectName(fo->getName());
1120 a->setToolTip(tr("ok!","Standardflag"));
1121 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1122 standardFlagsDefault->addFlag (fo);
1124 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1125 fo->setName("cross-red");
1126 fo->setGroup("standard-hook");
1127 a=new QAction (fo->getPixmap(),fo->getName(),this);
1130 a->setCheckable(true);
1131 a->setObjectName(fo->getName());
1132 a->setToolTip(tr("Not ok!","Standardflag"));
1133 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1134 standardFlagsDefault->addFlag (fo);
1136 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1137 fo->setName("stopsign");
1138 a=new QAction (fo->getPixmap(),fo->getName(),this);
1141 a->setCheckable(true);
1142 a->setObjectName(fo->getName());
1143 a->setToolTip(tr("This won't work!","Standardflag"));
1144 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1145 standardFlagsDefault->addFlag (fo);
1147 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1148 fo->setName("smiley-good");
1149 fo->setGroup("standard-smiley");
1150 a=new QAction (fo->getPixmap(),fo->getName(),this);
1153 a->setCheckable(true);
1154 a->setObjectName(fo->getName());
1155 a->setToolTip(tr("Good","Standardflag"));
1156 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1157 standardFlagsDefault->addFlag (fo);
1159 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1160 fo->setName("smiley-sad");
1161 fo->setGroup("standard-smiley");
1162 a=new QAction (fo->getPixmap(),fo->getName(),this);
1165 a->setCheckable(true);
1166 a->setObjectName(fo->getName());
1167 a->setToolTip(tr("Bad","Standardflag"));
1168 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1169 standardFlagsDefault->addFlag (fo);
1171 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1172 // Original omg.png (in KDE emoticons)
1173 fo->setName("smiley-omg");
1174 fo->setGroup("standard-smiley");
1175 a=new QAction (fo->getPixmap(),fo->getName(),this);
1178 a->setCheckable(true);
1179 a->setObjectName(fo->getName());
1180 a->setToolTip(tr("Oh no!","Standardflag"));
1181 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1182 standardFlagsDefault->addFlag (fo);
1184 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1185 fo->setName("clock");
1186 a=new QAction (fo->getPixmap(),fo->getName(),this);
1189 a->setCheckable(true);
1190 a->setObjectName(fo->getName());
1191 a->setToolTip(tr("Time critical","Standardflag"));
1192 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1193 standardFlagsDefault->addFlag (fo);
1195 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1196 fo->setName("phone");
1197 a=new QAction (fo->getPixmap(),fo->getName(),this);
1200 a->setCheckable(true);
1201 a->setObjectName(fo->getName());
1202 a->setToolTip(tr("Call...","Standardflag"));
1203 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1204 standardFlagsDefault->addFlag (fo);
1206 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1207 fo->setName("lamp");
1208 a=new QAction (fo->getPixmap(),fo->getName(),this);
1211 a->setCheckable(true);
1212 a->setObjectName(fo->getName());
1213 a->setToolTip(tr("Idea!","Standardflag"));
1214 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1215 standardFlagsDefault->addFlag (fo);
1217 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1218 fo->setName("arrow-up");
1219 fo->setGroup("standard-arrow");
1220 a=new QAction (fo->getPixmap(),fo->getName(),this);
1223 a->setCheckable(true);
1224 a->setObjectName(fo->getName());
1225 a->setToolTip(tr("Important","Standardflag"));
1226 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1227 standardFlagsDefault->addFlag (fo);
1229 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1230 fo->setName("arrow-down");
1231 fo->setGroup("standard-arrow");
1232 a=new QAction (fo->getPixmap(),fo->getName(),this);
1235 a->setCheckable(true);
1236 a->setObjectName(fo->getName());
1237 a->setToolTip(tr("Unimportant","Standardflag"));
1238 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1239 standardFlagsDefault->addFlag (fo);
1241 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1242 fo->setName("2arrow-up");
1243 fo->setGroup("standard-arrow");
1244 a=new QAction (fo->getPixmap(),fo->getName(),this);
1247 a->setCheckable(true);
1248 a->setObjectName(fo->getName());
1249 a->setToolTip(tr("Very important!","Standardflag"));
1250 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1251 standardFlagsDefault->addFlag (fo);
1253 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1254 fo->setName("2arrow-down");
1255 fo->setGroup("standard-arrow");
1256 a=new QAction (fo->getPixmap(),fo->getName(),this);
1259 a->setCheckable(true);
1260 a->setObjectName(fo->getName());
1261 a->setToolTip(tr("Very unimportant!","Standardflag"));
1262 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1263 standardFlagsDefault->addFlag (fo);
1265 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1266 fo->setName("thumb-up");
1267 fo->setGroup("standard-thumb");
1268 a=new QAction (fo->getPixmap(),fo->getName(),this);
1271 a->setCheckable(true);
1272 a->setObjectName(fo->getName());
1273 a->setToolTip(tr("I like this","Standardflag"));
1274 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1275 standardFlagsDefault->addFlag (fo);
1277 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1278 fo->setName("thumb-down");
1279 fo->setGroup("standard-thumb");
1280 a=new QAction (fo->getPixmap(),fo->getName(),this);
1283 a->setCheckable(true);
1284 a->setObjectName(fo->getName());
1285 a->setToolTip(tr("I do not like this","Standardflag"));
1286 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1287 standardFlagsDefault->addFlag (fo);
1289 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1290 fo->setName("rose");
1291 a=new QAction (fo->getPixmap(),fo->getName(),this);
1294 a->setCheckable(true);
1295 a->setObjectName(fo->getName());
1296 a->setToolTip(tr("Rose","Standardflag"));
1297 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1298 standardFlagsDefault->addFlag (fo);
1300 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1301 fo->setName("heart");
1302 a=new QAction (fo->getPixmap(),fo->getName(),this);
1304 a->setCheckable(true);
1305 a->setObjectName(fo->getName());
1306 a->setToolTip(tr("I just love... ","Standardflag"));
1307 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1308 standardFlagsDefault->addFlag (fo);
1310 fo->load(QPixmap(flagsPath+"flag-present.png"));
1311 fo->setName("present");
1312 a=new QAction (fo->getPixmap(),fo->getName(),this);
1315 a->setCheckable(true);
1316 a->setObjectName(fo->getName());
1317 a->setToolTip(tr("Surprise!","Standardflag"));
1318 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1319 standardFlagsDefault->addFlag (fo);
1321 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1322 fo->setName("flash");
1323 a=new QAction (fo->getPixmap(),fo->getName(),this);
1326 a->setCheckable(true);
1327 a->setObjectName(fo->getName());
1328 a->setToolTip(tr("Dangerous","Standardflag"));
1329 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1330 standardFlagsDefault->addFlag (fo);
1332 fo->load(QPixmap(flagsPath+"flag-info.png"));
1333 // Original: xsldbg_output.png
1334 fo->setName("info");
1335 a=new QAction (fo->getPixmap(),fo->getName(),this);
1338 a->setCheckable(true);
1339 a->setObjectName(fo->getName());
1340 a->setToolTip(tr("Info","Standardflag"));
1341 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1342 standardFlagsDefault->addFlag (fo);
1344 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1345 // Original khelpcenter.png
1346 fo->setName("lifebelt");
1347 a=new QAction (fo->getPixmap(),fo->getName(),this);
1350 a->setCheckable(true);
1351 a->setObjectName(fo->getName());
1352 a->setToolTip(tr("This will help","Standardflag"));
1353 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1354 standardFlagsDefault->addFlag (fo);
1360 void Main::setupSettingsActions()
1362 Q3PopupMenu *menu = new Q3PopupMenu( this );
1363 menuBar()->insertItem( tr( "&Settings" ), menu );
1368 a = new QAction( tr( "Set application to open pdf files"), this);
1369 a->setStatusTip ( tr( "Set application to open pdf files"));
1370 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1373 a = new QAction( tr( "Set application to open external links"), this);
1374 a->setStatusTip( tr( "Set application to open external links"));
1375 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1378 menu->insertSeparator();
1379 a = new QAction( tr( "Edit branch after adding it" ), this );
1380 a->setStatusTip( tr( "Edit branch after adding it" ));
1381 a->setToggleAction(true);
1382 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1384 actionSettingsAutoedit=a;
1386 a= new QAction( tr( "Select branch after adding it" ), this );
1387 a->setStatusTip( tr( "Select branch after adding it" ));
1388 a->setToggleAction(true);
1389 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1391 actionSettingsAutoselectHeading=a;
1393 a= new QAction(tr( "Select existing heading" ), this);
1394 a->setStatusTip( tr( "Select heading before editing" ));
1395 a->setToggleAction(true);
1396 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1398 actionSettingsAutoselectText=a;
1400 a= new QAction(tr( "pasting into new branch" ), this );
1401 a->setStatusTip( tr( "Pasting into new branch" ));
1402 a->setToggleAction(true);
1403 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1405 actionSettingsPasteNewHeading=a;
1407 a= new QAction( tr( "Delete key" ), this);
1408 a->setStatusTip( tr( "Delete key for deleting branches" ));
1409 a->setToggleAction(true);
1410 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1412 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1413 actionSettingsUseDelKey=a;
1415 a= new QAction( tr( "Exclusive flags" ), this);
1416 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1417 a->setToggleAction(true);
1418 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1420 actionSettingsUseFlagGroups=a;
1422 a= new QAction( tr( "Use hide flags" ), this);
1423 a->setStatusTip( tr( "Use hide flag during exports " ));
1424 a->setToggleAction(true);
1425 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1427 actionSettingsUseHideExport=a;
1431 void Main::setupTestActions()
1433 Q3PopupMenu *menu = new Q3PopupMenu( this );
1434 menuBar()->insertItem( tr( "&Test" ), menu );
1437 a = new QAction( tr( "test flag" ), this);
1438 a->setStatusTip( tr( "Call test function" ));
1439 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1444 void Main::setupHelpActions()
1446 Q3PopupMenu *menu = new Q3PopupMenu( this );
1447 menuBar()->insertItem( tr( "&Help" ), menu );
1450 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1451 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1452 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1455 a = new QAction( tr( "About VYM" ), this);
1456 a->setStatusTip( tr( "About VYM")+" "__VYM);
1457 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1460 a = new QAction( tr( "About QT" ), this);
1461 a->setStatusTip( tr( "Information about QT toolkit" ));
1462 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1467 void Main::setupContextMenus()
1471 // Context Menu for branch or mapcenter
1472 branchContextMenu =new QMenu (this);
1475 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1476 branchAddContextMenu->addAction (actionEditPaste );
1477 branchAddContextMenu->addAction ( actionEditAddBranch );
1478 branchAddContextMenu->addAction ( actionEditAddBranchHere );
1479 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1480 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1481 branchAddContextMenu->addSeparator();
1482 branchAddContextMenu->addAction ( actionEditLoadImage);
1483 branchAddContextMenu->addSeparator();
1484 branchAddContextMenu->addAction ( actionEditLoadImage);
1485 branchAddContextMenu->addAction ( actionEditImportAdd );
1486 branchAddContextMenu->addAction ( actionEditImportReplace );
1489 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove"));
1490 branchRemoveContextMenu->addAction (actionEditCut);
1491 branchRemoveContextMenu->addAction ( actionEditDelete );
1492 branchRemoveContextMenu->addAction ( actionEditRemoveBranchKeepChilds );
1493 branchRemoveContextMenu->addAction ( actionEditRemoveChilds );
1496 actionEditSaveBranch->addTo( branchContextMenu );
1499 branchContextMenu->addSeparator();
1500 actionEditOpenURL->addTo ( branchContextMenu );
1501 actionEditOpenURLTab->addTo ( branchContextMenu );
1502 actionEditURL->addTo ( branchContextMenu );
1503 actionEditHeading2URL->addTo ( branchContextMenu );
1504 actionEditBugzilla2URL->addTo( branchContextMenu );
1505 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1507 actionEditFATE2URL->addTo( branchContextMenu );
1509 branchContextMenu->insertSeparator();
1510 actionEditOpenVymLink->addTo ( branchContextMenu );
1511 actionEditVymLink->addTo ( branchContextMenu );
1512 actionEditDeleteVymLink->addTo ( branchContextMenu );
1514 branchContextMenu->insertSeparator();
1515 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1517 branchContextMenu->insertSeparator();
1518 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1519 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1520 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1522 // Context Menu for links in a branch menu
1523 // This will be populated "on demand" in MapEditor::updateActions
1524 branchContextMenu->insertSeparator();
1525 branchLinksContextMenu =new Q3PopupMenu (this);
1526 branchLinksContextMenuDup =new Q3PopupMenu (this);
1527 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1528 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1530 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1531 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1534 // Context menu for floatimage
1535 floatimageContextMenu =new QMenu (this);
1536 saveImageFormatMenu=floatimageContextMenu->addMenu (tr("Save image"));
1538 foreach (QByteArray format, QImageWriter::supportedImageFormats())
1540 QString text = tr("%1...").arg(QString(format).toUpper());
1541 a= new QAction (text,this);
1542 saveImageFormatMenu->addAction ( a );
1545 /* FIXME not needed any longer
1546 Q3StrList fmt = QImageWriter::supportedImageFormats();
1547 for (const char* f = fmt.first(); f; f = fmt.next())
1549 saveImageFormatMenu->insertItem( f );
1550 exportImageFormatMenu->insertItem( f );
1553 // connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1554 // connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1556 floatimageContextMenu->addSeparator();
1557 actionEditCopy->addTo( floatimageContextMenu );
1558 actionEditCut->addTo( floatimageContextMenu );
1560 floatimageContextMenu->addSeparator();
1561 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1564 // Context menu for canvas
1565 canvasContextMenu =new QMenu (this);
1566 actionEditMapInfo->addTo( canvasContextMenu );
1567 canvasContextMenu->insertSeparator();
1568 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1569 canvasContextMenu->insertSeparator();
1570 actionFormatLinkColorHint->addTo( canvasContextMenu );
1571 actionFormatLinkColor->addTo( canvasContextMenu );
1572 actionFormatBackColor->addTo( canvasContextMenu );
1574 // Menu for last opened files
1575 // Read settings initially
1577 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1578 for (int i=1;i<=j;i++)
1580 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1581 if (!s.isEmpty() && j<=maxLastMaps)
1584 setupLastMapsMenu();
1585 // connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1588 void Main::setupLastMapsMenu()
1590 // Remove double entries
1591 QStringList::Iterator it=lastMaps.begin();
1592 QStringList::Iterator jt;
1593 while (it!=lastMaps.end() )
1597 while (jt!=lastMaps.end() )
1600 jt=lastMaps.remove(jt);
1607 // Limit length of list to maxLastMaps
1608 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1610 // build Menu from lastMaps string list
1611 fileLastMapsMenu->clear();
1612 /* FIXME add actions instead of strings in QT4
1613 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1614 fileLastMapsMenu->addAction (*it );
1619 void Main::hideEvent (QHideEvent * )
1621 if (!textEditor->isMinimized() ) textEditor->hide();
1624 void Main::showEvent (QShowEvent * )
1626 if (textEditor->showWithMain()) textEditor->showNormal();
1629 bool Main::reallyWriteDirectory(const QString &dir)
1631 QStringList eList = QDir(dir).entryList();
1632 if (eList.first() ==".") eList.pop_front(); // remove "."
1633 if (eList.first() =="..") eList.pop_front(); // remove "."
1634 if (!eList.isEmpty())
1636 QMessageBox mb( __VYM,
1637 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1638 QMessageBox::Warning,
1640 QMessageBox::Cancel | QMessageBox::Default,
1641 QMessageBox::QMessageBox::NoButton );
1643 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1644 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1647 case QMessageBox::Yes:
1650 case QMessageBox::Cancel:
1658 QString Main::browseDirectory (const QString &caption)
1660 Q3FileDialog fd(this,caption);
1661 fd.setMode (Q3FileDialog::DirectoryOnly);
1662 fd.setCaption(__VYM " - "+caption);
1665 if ( fd.exec() == QDialog::Accepted )
1666 return fd.selectedFile();
1671 MapEditor* Main::currentMapEditor() const
1673 if ( tabWidget->currentPage() &&
1674 tabWidget->currentPage()->inherits( "MapEditor" ) )
1675 return (MapEditor*)tabWidget->currentPage();
1679 //TODO not used now, maybe use this for overview window later
1680 void Main::newView()
1682 // Open a new view... have it delete when closed.
1683 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1684 qApp->setMainWidget(m);
1686 qApp->setMainWidget(0);
1689 void Main::editorChanged(QWidget *)
1691 // Unselect all possibly selected objects
1692 // (Important to update note editor)
1695 for (i=0;i<=tabWidget->count() -1;i++)
1698 me=(MapEditor*)tabWidget->page(i);
1701 currentMapEditor()->reselect();
1703 // Update actions to in menus and toolbars according to editor
1704 currentMapEditor()->updateActions();
1707 void Main::fileNew()
1709 QString fn="unnamed";
1710 MapEditor* medit = new MapEditor ( NULL,true);
1711 tabWidget->addTab (medit,fn);
1712 tabWidget->showPage(medit);
1713 medit->viewport()->setFocus();
1714 // For the very first map we do not have flagrows yet...
1715 medit->select("mc:");
1718 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1720 ErrorCode err=success;
1722 // fn is usually the archive, mapfile the file after uncompressing
1725 // Make fn absolute (needed for unzip)
1726 fn=QDir (fn).absPath();
1732 // Check, if map is already loaded
1734 while (i<=tabWidget->count() -1)
1736 me=(MapEditor*)tabWidget->page(i);
1737 if (me->getFilePath() == fn)
1739 // Already there, ask for confirmation
1740 QMessageBox mb( __VYM,
1741 tr("The map %1\nis already opened."
1742 "Opening the same map in multiple editors may lead \n"
1743 "to confusion when finishing working with vym."
1744 "Do you want to").arg(fn),
1745 QMessageBox::Warning,
1746 QMessageBox::Yes | QMessageBox::Default,
1747 QMessageBox::Cancel | QMessageBox::Escape,
1748 QMessageBox::NoButton);
1749 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1750 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1753 case QMessageBox::Yes:
1755 i=tabWidget->count();
1757 case QMessageBox::Cancel:
1769 if ( !fn.isEmpty() )
1771 me = currentMapEditor();
1772 int tabIndex=tabWidget->currentPageIndex();
1773 // Check first, if mapeditor exists
1774 // If it is not default AND we want a new map,
1775 // create a new mapeditor in a new tab
1776 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1778 me= new MapEditor ( NULL,true);
1779 tabWidget->addTab (me,fn);
1780 tabIndex=tabWidget->indexOf (me);
1781 tabWidget->setCurrentPage (tabIndex);
1784 // Check, if file exists (important for creating new files
1785 // from command line
1786 if (!QFile(fn).exists() )
1788 QMessageBox mb( __VYM,
1789 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1790 QMessageBox::Question,
1792 QMessageBox::Cancel | QMessageBox::Default,
1793 QMessageBox::NoButton );
1795 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1796 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1799 case QMessageBox::Yes:
1801 currentMapEditor()->setFilePath(fn);
1802 tabWidget->setTabLabel (currentMapEditor(),
1803 currentMapEditor()->getFileName() );
1804 statusBar()->message( "Created " + fn , statusbarTime );
1807 case QMessageBox::Cancel:
1808 // don't create new map
1809 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1816 //tabWidget->currentPage() won't be NULL here, because of above...
1817 tabWidget->showPage(me);
1818 me->viewport()->setFocus();
1820 // Create temporary directory for packing
1821 char tmpdir1[]="/tmp/vym-XXXXXX";
1822 QString tmpMapDir=mkdtemp(tmpdir1);
1824 // Try to unzip file
1825 err=unzipDir (tmpMapDir,fn);
1829 me->setZipped(false);
1832 me->setZipped(true);
1834 // Look for mapname.xml
1835 mapfile= fn.left(fn.findRev(".",-1,true));
1836 mapfile=mapfile.section( '/', -1 );
1837 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1838 if (!file.exists() )
1840 // mapname.xml does not exist, well,
1841 // maybe some renamed the mapname.vym file...
1842 // Try to find any .xml in the toplevel
1843 // directory of the .vym file
1844 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1845 if (flist.count()==1)
1847 // Only one entry, take this one
1848 mapfile=tmpMapDir + "/"+flist.first();
1851 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1852 *it=tmpMapDir + "/" + *it;
1853 // TODO Multiple entries, load all (but only the first one into this ME)
1854 //mainWindow->fileLoadFromTmp (flist);
1855 //returnCode=1; // Silently forget this attempt to load
1856 qWarning ("MainWindow::load (fn) multimap found...");
1859 if (flist.isEmpty() )
1861 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1862 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1865 } //file doesn't exist
1867 mapfile=file.name();
1872 // Save existing filename in case we import
1873 QString fn_org=me->getFilePath();
1875 // Finally load map into mapEditor
1876 me->setFilePath (mapfile,fn);
1877 err=me->load(mapfile,lmode);
1879 // Restore old (maybe empty) filepath, if this is an import
1881 me->setFilePath (fn_org);
1884 // Finally check for errors and go home
1887 if (lmode==NewMap) fileCloseMap();
1888 statusBar()->message( "Could not load " + fn, statusbarTime );
1893 me->setFilePath (fn);
1894 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1895 if (fn.left(9)!="/tmp/vym-")
1897 // Only append to lastMaps if not loaded from a tmpDir
1898 // e.g. imported bookmarks are in a tmpDir
1899 lastMaps.prepend(me->getFilePath() );
1900 setupLastMapsMenu();
1902 actionFilePrint->setEnabled (true);
1904 statusBar()->message( "Loaded " + fn, statusbarTime );
1908 removeDir (QDir(tmpMapDir));
1914 void Main::fileLoad(const LoadMode &lmode)
1916 Q3FileDialog *fd=new Q3FileDialog( this);
1917 if (!lastFileDir.isEmpty())
1918 fd->setDir (lastFileDir);
1919 fd->setMode (Q3FileDialog::ExistingFiles);
1920 fd->addFilter ("XML (*.xml)");
1921 fd->addFilter ("VYM map (*.vym *.vyp)");
1925 fd->setCaption(tr("Load vym map"));
1928 fd->setCaption(tr("Import: Add vym map to selection"));
1931 fd->setCaption(tr("Import: Replace selection with vym map"));
1937 if ( fd->exec() == QDialog::Accepted )
1939 lastFileDir=fd->dirPath();
1940 QStringList flist = fd->selectedFiles();
1941 QStringList::Iterator it = flist.begin();
1942 while( it != flist.end() )
1945 fileLoad(*it, lmode);
1952 void Main::fileLoad()
1957 void Main::fileLoadLast(int i)
1959 fileLoad(QString(*lastMaps.at(fileLastMapsMenu->indexOf (i)) ),NewMap);
1962 void Main::fileSave(const SaveMode &savemode)
1964 // tmp dir for zipping
1968 ErrorCode err=success;
1970 QString safeFilePath;
1972 bool saveZipped=currentMapEditor()->saveZipped();
1974 MapEditor * me=currentMapEditor();
1977 QString fn=me->getFilePath();
1978 // filename=unnamed, filepath="" in constructor...
1979 if ( !fn.isEmpty() )
1981 // We have a filepath, go on saving
1982 // First remove existing file, we
1983 // don't want to add to old zip archives
1987 QMessageBox::warning( 0, tr( "Save Error" ),
1988 fn+ tr("\ncould not be removed before saving"));
1990 // Look, if we should zip the data:
1993 QMessageBox mb( __VYM,
1994 tr("The map %1\ndid not use the compressed "
1995 "vym file format.\nWriting it uncompressed will also write images \n"
1996 "and flags and thus may overwrite files in the "
1997 "given directory\n\nDo you want to write the map").arg(fn),
1998 QMessageBox::Warning,
1999 QMessageBox::Yes | QMessageBox::Default,
2001 QMessageBox::Cancel | QMessageBox::Escape);
2002 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2003 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2004 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2007 case QMessageBox::Yes:
2008 // save compressed (default file format)
2011 case QMessageBox::No:
2012 // save uncompressed
2015 case QMessageBox::Cancel:
2024 char tmpdir1[]="/tmp/vym-XXXXXX";
2025 tmpMapDir=mkdtemp(tmpdir1);
2027 safeFilePath=me->getFilePath();
2028 me->setFilePath (tmpMapDir+"/"+
2029 me->getMapName()+ ".xml",
2031 me->save (savemode);
2032 me->setFilePath (safeFilePath);
2034 zipDir (tmpMapDir,fn);
2039 safeFilePath=me->getFilePath();
2040 me->setFilePath (fn, safeFilePath);
2041 me->save (savemode);
2042 me->setFilePath (safeFilePath);
2044 } // filepath available
2047 // We have no filepath yet,
2048 // call fileSaveAs() now, this will call fileSave()
2050 fileSaveAs(savemode);
2054 if (saveZipped && !tmpMapDir.isEmpty())
2056 removeDir (QDir(tmpMapDir));
2060 statusBar()->message(
2061 tr("Saved %1").arg(me->getFilePath()),
2063 lastMaps.prepend(me->getFilePath() );
2064 setupLastMapsMenu();
2066 statusBar()->message(
2067 tr("Couldn't save ").arg(me->getFilePath()),
2071 void Main::fileSave()
2073 fileSave (CompleteMap);
2076 void Main::fileSaveAs(const SaveMode& savemode)
2080 if (currentMapEditor())
2082 if (savemode==CompleteMap)
2083 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2085 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2086 if ( !fn.isEmpty() )
2088 // Check for existing file
2089 if (QFile (fn).exists())
2091 QMessageBox mb( __VYM,
2092 tr("The file %1\nexists already. Do you want to").arg(fn),
2093 QMessageBox::Warning,
2094 QMessageBox::Yes | QMessageBox::Default,
2095 QMessageBox::Cancel | QMessageBox::Escape,
2096 QMessageBox::NoButton);
2097 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2098 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2101 case QMessageBox::Yes:
2104 case QMessageBox::Cancel:
2111 // New file, add extension to filename, if missing
2112 // This is always .vym or .vyp, depending on savemode
2113 if (savemode==CompleteMap)
2115 if (!fn.contains (".vym") && !fn.contains (".xml"))
2119 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2128 currentMapEditor()->setFilePath(fn);
2132 if (savemode==CompleteMap)
2133 tabWidget->setTabLabel (currentMapEditor(),
2134 currentMapEditor()->getFileName() );
2140 void Main::fileSaveAs()
2142 fileSaveAs (CompleteMap);
2145 void Main::fileImportKDEBookmarks()
2147 ImportKDEBookmarks im;
2149 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2150 currentMapEditor()->setFilePath ("");
2153 void Main::fileImportFirefoxBookmarks()
2155 Q3FileDialog *fd=new Q3FileDialog( this);
2156 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2157 fd->setMode (Q3FileDialog::ExistingFiles);
2158 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2159 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2162 if ( fd->exec() == QDialog::Accepted )
2164 ImportFirefoxBookmarks im;
2165 QStringList flist = fd->selectedFiles();
2166 QStringList::Iterator it = flist.begin();
2167 while( it != flist.end() )
2170 if (im.transform() &&
2171 success==fileLoad (im.getTransformedFile(),NewMap) &&
2172 currentMapEditor() )
2173 currentMapEditor()->setFilePath ("");
2180 void Main::fileImportMM()
2184 Q3FileDialog *fd=new Q3FileDialog( this);
2185 if (!lastFileDir.isEmpty())
2186 fd->setDir (lastFileDir);
2187 fd->setMode (Q3FileDialog::ExistingFiles);
2188 fd->addFilter ("Mind Manager (*.mmap)");
2189 fd->setCaption(tr("Import")+" "+"Mind Manager");
2192 if ( fd->exec() == QDialog::Accepted )
2194 lastFileDir=fd->dirPath();
2195 QStringList flist = fd->selectedFiles();
2196 QStringList::Iterator it = flist.begin();
2197 while( it != flist.end() )
2200 if (im.transform() &&
2201 success==fileLoad (im.getTransformedFile(),NewMap) &&
2202 currentMapEditor() )
2203 currentMapEditor()->setFilePath ("");
2212 void Main::fileImportDir()
2214 if (currentMapEditor())
2215 currentMapEditor()->importDir();
2218 void Main::fileExportXML()
2220 if (currentMapEditor())
2222 QString dir=browseDirectory(tr("Export XML to directory"));
2223 if (dir !="" && reallyWriteDirectory(dir) )
2224 currentMapEditor()->exportXML(dir);
2229 void Main::fileExportXHTML()
2231 MapEditor *me=currentMapEditor();
2235 ExportXHTMLDialog dia(this);
2236 dia.setFilePath (me->getFilePath() );
2237 dia.setMapName (me->getMapName() );
2240 if (dia.exec()==QDialog::Accepted)
2242 QString dir=dia.getDir();
2243 // Check, if warnings should be used before overwriting
2244 // the output directory
2247 ok=reallyWriteDirectory(dir);
2253 me->exportXML (dia.getDir() );
2254 dia.doExport(me->getMapName() );
2255 if (dia.hasChanged())
2262 void Main::fileExportImage()
2264 MapEditor *me=currentMapEditor();
2268 QFileDialog *fd=new QFileDialog (this);
2269 fd->setCaption (tr("Export map as image"));
2270 fd->setFileMode(QFileDialog::AnyFile);
2271 fd->setFilters (imageIO.getFilters() );
2272 fd->setDirectory (lastImageDir);
2275 fl=fd->selectedFiles();
2276 qWarning ("Selected "+fl.first()+" filter: "+fd->selectedFilter());
2277 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2282 void Main::fileExportASCII()
2284 MapEditor *me=currentMapEditor();
2288 ex.setMapCenter(me->getMapCenter());
2289 ex.addFilter ("TXT (*.txt)");
2290 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2291 if (ex.execDialog() )
2293 me->setExportMode(true);
2295 me->setExportMode(false);
2300 void Main::fileExportLaTeX()
2302 MapEditor *me=currentMapEditor();
2306 ex.setMapCenter(me->getMapCenter());
2307 ex.addFilter ("Tex (*.tex)");
2308 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2309 if (ex.execDialog() )
2311 me->setExportMode(true);
2313 me->setExportMode(false);
2318 void Main::fileExportKDEBookmarks()
2320 ExportKDEBookmarks ex;
2321 MapEditor *me=currentMapEditor();
2324 ex.setMapCenter (me->getMapCenter() );
2329 void Main::fileExportTaskjuggler()
2331 ExportTaskjuggler ex;
2332 MapEditor *me=currentMapEditor();
2335 ex.setMapCenter (me->getMapCenter() );
2336 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2337 ex.addFilter ("Taskjuggler (*.tjp)");
2338 if (ex.execDialog() )
2340 me->setExportMode(true);
2342 me->setExportMode(false);
2347 void Main::fileExportOOPresentation()
2349 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2350 // FIXME add extra info in dialog
2351 //ImagePreview *p =new ImagePreview (fd);
2352 //fd->setContentsPreviewEnabled( TRUE );
2353 //fd->setContentsPreview( p, p );
2354 //fd->setPreviewMode( QFileDialog::Contents );
2355 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2356 //fd->setDir (lastImageDir);
2359 if ( fd->exec() == QDialog::Accepted )
2361 QString fn=fd->selectedFile();
2362 //lastImageDir=fn.left(fn.findRev ("/"));
2363 if (currentMapEditor())
2364 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2368 void Main::fileCloseMap()
2370 if (currentMapEditor())
2372 if (currentMapEditor()->hasChanged())
2374 QMessageBox mb( __VYM,
2375 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2376 QMessageBox::Warning,
2377 QMessageBox::Yes | QMessageBox::Default,
2379 QMessageBox::Cancel | QMessageBox::Escape );
2380 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2381 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2384 case QMessageBox::Yes:
2386 fileSave(CompleteMap);
2388 case QMessageBox::No:
2389 // close without saving
2391 case QMessageBox::Cancel:
2396 currentMapEditor()->closeMap();
2397 tabWidget->removePage(currentMapEditor());
2398 if (tabWidget->count()==0)
2399 actionFilePrint->setEnabled (false);
2403 void Main::filePrint()
2405 if (currentMapEditor())
2406 currentMapEditor()->print();
2409 void Main::fileExitVYM()
2411 // Check if one or more editors have changed
2414 for (i=0;i<=tabWidget->count() -1;i++)
2417 me=(MapEditor*)tabWidget->page(i);
2419 // If something changed, ask what to do
2420 if (me->isUnsaved())
2422 tabWidget->setCurrentPage(i);
2423 QMessageBox mb( __VYM,
2424 tr("This map is not saved yet. Do you want to"),
2425 QMessageBox::Warning,
2426 QMessageBox::Yes | QMessageBox::Default,
2428 QMessageBox::Cancel | QMessageBox::Escape );
2429 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2430 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2432 mb.setActiveWindow();
2433 switch( mb.exec() ) {
2434 case QMessageBox::Yes:
2435 // save (the changed editors) and exit
2436 fileSave(CompleteMap);
2438 case QMessageBox::No:
2439 // exit without saving
2441 case QMessageBox::Cancel:
2442 // don't save and don't exit
2446 } // loop over all MEs
2450 void Main::editUndo()
2452 if (currentMapEditor())
2453 currentMapEditor()->undo();
2456 void Main::editRedo()
2458 if (currentMapEditor())
2459 currentMapEditor()->redo();
2462 void Main::editCopy()
2464 if (currentMapEditor())
2465 currentMapEditor()->copy();
2468 void Main::editPaste()
2470 if (currentMapEditor())
2471 currentMapEditor()->paste();
2474 void Main::editCut()
2476 if (currentMapEditor())
2477 currentMapEditor()->cut();
2480 void Main::editOpenFindWindow()
2482 findWindow->popup();
2483 findWindow->raise();
2484 findWindow->setActiveWindow();
2487 void Main::editFind(QString s)
2490 BranchObj *bo=currentMapEditor()->findText(s, cs);
2493 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2496 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2497 tr("No matches found for \"%1\"").arg(s));
2501 void Main::editFindChanged()
2502 { // Notify editor, to abort the current find process
2503 currentMapEditor()->findReset();
2506 void Main::editOpenURL()
2509 if (currentMapEditor())
2511 QString url=currentMapEditor()->getURL();
2512 if (url=="") return;
2513 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2514 procBrowser = new Q3Process( this );
2516 procBrowser->addArgument( browser);
2517 procBrowser->addArgument( url);
2519 if ( !procBrowser->start() )
2521 // try to set path to browser
2522 QMessageBox::warning(0,
2524 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2525 tr("Please use Settings->")+tr("Set application to open an URL"));
2530 void Main::editOpenURLTab()
2532 if (currentMapEditor())
2534 QString url=currentMapEditor()->getURL();
2535 if (url=="") return;
2536 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2537 if (procBrowser && procBrowser->isRunning())
2539 if (browser.contains("konqueror"))
2541 // Try to open new tab in existing konqueror started previously by vym
2542 Q3Process *p=new Q3Process (this);
2543 p->addArgument ("dcop");
2544 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2545 p->addArgument ("konqueror-mainwindow#1");
2546 p->addArgument ("newTab");
2547 p->addArgument (url);
2549 // try to set browser
2550 QMessageBox::warning(0,
2552 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2554 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2556 // Try to open new tab in firefox
2557 Q3Process *p=new Q3Process (this);
2558 p->addArgument (browser);
2559 p->addArgument ("-remote");
2560 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2562 // try to set browser
2563 QMessageBox::warning(0,
2565 tr("Couldn't start %1 to open a new tab").arg(browser));
2574 void Main::editURL()
2576 if (currentMapEditor())
2577 currentMapEditor()->editURL();
2580 void Main::editHeading2URL()
2582 if (currentMapEditor())
2583 currentMapEditor()->editHeading2URL();
2586 void Main::editBugzilla2URL()
2588 if (currentMapEditor())
2589 currentMapEditor()->editBugzilla2URL();
2592 void Main::editFATE2URL()
2594 if (currentMapEditor())
2595 currentMapEditor()->editFATE2URL();
2598 void Main::editOpenVymLink()
2600 // Get current path to map
2601 QString currentVymLink;
2602 if (currentMapEditor())
2604 currentVymLink=currentMapEditor()->getVymLink();
2605 // compare path with already loaded maps
2609 for (i=0;i<=tabWidget->count() -1;i++)
2611 me=(MapEditor*)tabWidget->page(i);
2612 if (currentVymLink==me->getFilePath() )
2621 if (!QFile(currentVymLink).exists() )
2622 QMessageBox::critical( 0, tr( "Critical Error" ),
2623 tr("Couldn't open map %1").arg(currentVymLink));
2626 fileLoad (currentVymLink, NewMap);
2627 tabWidget->setCurrentPage (tabWidget->count()-1);
2630 // Go to tab containing the map
2631 tabWidget->setCurrentPage (index);
2635 void Main::editVymLink()
2637 if (currentMapEditor())
2638 currentMapEditor()->editVymLink();
2641 void Main::editDeleteVymLink()
2643 if (currentMapEditor())
2644 currentMapEditor()->deleteVymLink();
2647 void Main::editToggleHideExport()
2649 if (currentMapEditor())
2650 currentMapEditor()->toggleHideExport();
2653 void Main::editMapInfo()
2655 if (currentMapEditor())
2656 currentMapEditor()->editMapInfo();
2659 void Main::editMoveUp()
2661 if (currentMapEditor())
2662 currentMapEditor()->moveBranchUp();
2665 void Main::editMoveDown()
2667 if (currentMapEditor())
2668 currentMapEditor()->moveBranchDown();
2671 void Main::editToggleScroll()
2673 if (currentMapEditor())
2675 currentMapEditor()->toggleScroll();
2679 void Main::editUnScrollAll()
2681 if (currentMapEditor())
2683 currentMapEditor()->unScrollAll();
2687 void Main::editHeading()
2689 qWarning ("Main::editHeading called");
2690 if (currentMapEditor())
2691 currentMapEditor()->editHeading();
2694 void Main::editNewBranch()
2697 // tried to see if maybe currentMapEditor is not set, but
2698 // ME does not seem to send a key event anyway...:q
2699 //here i was last time...
2701 cout << "Main::editNewBranch\n";
2702 if (currentMapEditor())
2703 currentMapEditor()->addNewBranch(0);
2706 void Main::editNewBranchHere()
2708 if (currentMapEditor())
2709 currentMapEditor()->addNewBranchHere();
2712 void Main::editNewBranchAbove()
2714 if (currentMapEditor())
2715 currentMapEditor()->addNewBranch(-1);
2718 void Main::editNewBranchBelow()
2720 if (currentMapEditor())
2721 currentMapEditor()->addNewBranch(1);
2724 void Main::editImportAdd()
2726 fileLoad (ImportAdd);
2729 void Main::editImportReplace()
2731 fileLoad (ImportReplace);
2734 void Main::editSaveBranch()
2736 fileSaveAs (PartOfMap);
2739 void Main::editRemoveBranchKeepChilds()
2741 if (currentMapEditor())
2742 currentMapEditor()->removeBranchKeepChilds();
2745 void Main::editRemoveChilds()
2747 if (currentMapEditor())
2748 currentMapEditor()->removeChilds();
2751 void Main::editDeleteSelection()
2753 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2754 currentMapEditor()->deleteSelection();
2757 void Main::editUpperBranch()
2759 if (currentMapEditor())
2760 currentMapEditor()->selectUpperBranch();
2763 void Main::editLowerBranch()
2765 if (currentMapEditor())
2766 currentMapEditor()->selectLowerBranch();
2769 void Main::editLeftBranch()
2771 if (currentMapEditor())
2772 currentMapEditor()->selectLeftBranch();
2775 void Main::editRightBranch()
2777 if (currentMapEditor())
2778 currentMapEditor()->selectRightBranch();
2781 void Main::editFirstBranch()
2783 if (currentMapEditor())
2784 currentMapEditor()->selectFirstBranch();
2787 void Main::editLastBranch()
2789 if (currentMapEditor())
2790 currentMapEditor()->selectLastBranch();
2793 void Main::editLoadImage()
2795 if (currentMapEditor())
2796 currentMapEditor()->loadFloatImage();
2799 void Main::editSaveImage(int item)
2801 if (currentMapEditor())
2802 currentMapEditor()->saveFloatImage(item);
2805 void Main::editFollowXLink(int item)
2807 if (currentMapEditor())
2808 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2811 void Main::editEditXLink(int item)
2813 if (currentMapEditor())
2814 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2817 void Main::formatSelectColor()
2819 if (currentMapEditor())
2821 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2822 if ( !col.isValid() ) return;
2823 currentMapEditor()->setColor( col );
2824 colorChanged( col );
2828 void Main::formatPickColor()
2830 if (currentMapEditor())
2831 colorChanged( currentMapEditor()->pickColor() );
2834 void Main::colorChanged(QColor c)
2836 QPixmap pix( 16, 16 );
2838 actionFormatColor->setIconSet( pix );
2841 void Main::formatColorItem()
2843 if (currentMapEditor())
2844 currentMapEditor()->colorItem();
2847 void Main::formatColorBranch()
2849 if (currentMapEditor())
2850 currentMapEditor()->colorBranch();
2853 void Main::formatLinkStyleLine()
2855 if (currentMapEditor())
2856 currentMapEditor()->setLinkStyle(StyleLine);
2859 void Main::formatLinkStyleParabel()
2861 if (currentMapEditor())
2862 currentMapEditor()->setLinkStyle(StyleParabel);
2865 void Main::formatLinkStylePolyLine()
2867 if (currentMapEditor())
2868 currentMapEditor()->setLinkStyle(StylePolyLine);
2871 void Main::formatLinkStylePolyParabel()
2873 if (currentMapEditor())
2874 currentMapEditor()->setLinkStyle(StylePolyParabel);
2877 void Main::formatSelectBackColor()
2879 if (currentMapEditor())
2880 currentMapEditor()->selectBackgroundColor();
2883 void Main::formatSelectLinkColor()
2885 if (currentMapEditor())
2886 currentMapEditor()->selectLinkColor();
2889 void Main::formatToggleLinkColorHint()
2891 currentMapEditor()->toggleLinkColorHint();
2894 void Main::formatFrameNone()
2896 if (currentMapEditor())
2897 currentMapEditor()->setFrame(NoFrame);
2900 void Main::formatFrameRectangle()
2902 if (currentMapEditor())
2903 currentMapEditor()->setFrame(Rectangle);
2906 void Main::formatIncludeImagesVer()
2908 if (currentMapEditor())
2909 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2912 void Main::formatIncludeImagesHor()
2914 if (currentMapEditor())
2915 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2918 void Main::formatHideLinkUnselected()
2920 if (currentMapEditor())
2921 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2924 void Main::viewZoomReset()
2926 if (currentMapEditor())
2930 currentMapEditor()->setWorldMatrix( m );
2931 currentMapEditor()->setViewCenter();
2932 currentMapEditor()->adjustCanvasSize();
2936 void Main::viewZoomIn()
2938 if (currentMapEditor())
2940 QMatrix m = currentMapEditor()->worldMatrix();
2941 m.scale( 1.25, 1.25 );
2942 currentMapEditor()->setWorldMatrix( m );
2943 currentMapEditor()->setViewCenter();
2944 currentMapEditor()->adjustCanvasSize();
2948 void Main::viewZoomOut()
2950 if (currentMapEditor())
2952 QMatrix m = currentMapEditor()->worldMatrix();
2953 m.scale( 0.8, 0.8 );
2954 currentMapEditor()->setWorldMatrix( m );
2955 currentMapEditor()->setViewCenter();
2956 currentMapEditor()->adjustCanvasSize();
2960 void Main::modModeColor()
2964 void Main::modModeLink()
2968 bool Main::settingsPDF()
2970 // Default browser is set in constructor
2972 QString text = QInputDialog::getText(
2973 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2974 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2976 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2981 bool Main::settingsURL()
2983 // Default browser is set in constructor
2985 QString text = QInputDialog::getText(
2986 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2987 settings.readEntry("/vym/mainwindow/readerURL")
2990 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2994 void Main::settingsToggleDelKey()
2996 if (actionSettingsUseDelKey->isOn())
2998 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3001 actionEditDelete->setAccel (QKeySequence (""));
3005 void Main::windowToggleNoteEditor()
3007 if (textEditor->showWithMain() )
3008 windowHideNoteEditor();
3010 windowShowNoteEditor();
3013 void Main::windowToggleHistory()
3015 if (currentMapEditor())
3016 currentMapEditor()->toggleHistoryWindow();
3019 void Main::updateNoteFlag()
3021 if (currentMapEditor())
3022 currentMapEditor()->updateNoteFlag();
3025 void Main::windowShowNoteEditor()
3027 textEditor->setShowWithMain(true);
3029 actionViewToggleNoteEditor->setOn (true);
3032 void Main::windowHideNoteEditor()
3034 textEditor->setShowWithMain(false);
3036 actionViewToggleNoteEditor->setOn (false);
3039 void Main::windowNextEditor()
3041 if (tabWidget->currentPageIndex() < tabWidget->count())
3042 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3045 void Main::windowPreviousEditor()
3047 if (tabWidget->currentPageIndex() >0)
3048 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3051 void Main::standardFlagChanged()
3053 currentMapEditor()->toggleStandardFlag(sender()->name());
3056 void Main::testFunction()
3058 currentMapEditor()->testFunction();
3061 void Main::helpDoc()
3064 #if defined(Q_OS_MACX)
3065 docpath="./vym.app/Contents/vym.pdf";
3067 // default path in SUSE LINUX
3068 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3071 if (!QFile (docpath).exists() )
3073 // relative path for easy testing in tarball
3074 docpath="doc/vym.pdf";
3075 if (!QFile (docpath).exists() )
3077 // relative path for testing while still writing vym.tex
3078 docpath="doc/tex/vym.pdf";
3079 if (!QFile (docpath).exists() )
3081 // Try yet another one for Knoppix
3082 docpath="/usr/share/doc/packages/vym/vym.pdf";
3083 if (!QFile (docpath).exists() )
3085 QMessageBox::critical(0,
3086 tr("Critcal error"),
3087 tr("Couldn't find the documentation\n"
3088 "vym.pdf in various places."));
3095 Process *pdfProc = new Process();
3096 pdfProc->clearArguments();
3097 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
3098 pdfProc->addArgument( docpath);
3100 if ( !pdfProc->start() )
3103 QMessageBox::warning(0,
3105 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3106 tr("Please use Settings->")+tr("Set application to open PDF files"));
3113 void Main::helpAbout()
3116 ad.setName ("aboutwindow");
3117 ad.setMinimumSize(500,500);
3118 ad.resize (QSize (500,500));
3122 void Main::helpAboutQT()
3124 QMessageBox::aboutQt( this, "Qt Application Example" );