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
33 #include "aboutdialog.h"
34 #include "exportoofiledialog.h"
36 #include "exportxhtmldialog.h"
38 #include "flagrowobj.h"
40 #include "mapeditor.h"
45 #include "showtextdialog.h"
46 #include "texteditor.h"
49 extern TextEditor *textEditor;
50 extern Main *mainWindow;
51 extern QString tmpVymDir;
52 extern QString clipboardDir;
53 extern bool clipboardEmpty;
54 extern int statusbarTime;
55 extern FlagRowObj* standardFlagsDefault;
56 extern FlagRowObj* systemFlagsDefault;
58 extern Q3PtrList <QAction> actionListBranches;
60 extern QAction* actionFileSave;
61 extern QAction* actionFilePrint;
62 extern QAction* actionEditUndo;
63 extern QAction* actionEditRedo;
64 extern QAction *actionEditCopy;
65 extern QAction *actionEditCut;
66 extern QAction *actionEditPaste;
67 extern QAction *actionEditMoveUp;
68 extern QAction *actionEditMoveDown;
69 extern QAction *actionEditToggleScroll;
70 extern QAction* actionEditOpenURL;
71 extern QAction* actionEditOpenURLTab;
72 extern QAction* actionEditURL;
73 extern QAction* actionEditHeading2URL;
74 extern QAction* actionEditBugzilla2URL;
75 extern QAction* actionEditFATE2URL;
76 extern QAction *actionEditOpenVymLink;
77 extern QAction *actionEditVymLink;
78 extern QAction *actionEditDeleteVymLink;
79 extern QAction *actionEditToggleHideExport;
80 extern QAction *actionEditMapInfo;
81 extern QAction *actionEditHeading;
82 extern QAction *actionEditDelete;
83 extern QAction *actionEditAddBranch;
84 extern QAction *actionEditAddBranchHere;
85 extern QAction *actionEditAddBranchAbove;
86 extern QAction *actionEditAddBranchBelow;
87 extern QAction *actionEditRemoveBranchKeepChilds;
88 extern QAction *actionEditRemoveChilds;
89 extern QAction *actionEditImportAdd;
90 extern QAction *actionEditImportReplace;
91 extern QAction *actionEditSaveBranch;
92 extern QAction *actionEditSelectFirst;
93 extern QAction *actionEditSelectLast;
94 extern QAction *actionEditLoadImage;
96 extern QAction* actionFormatColor;
97 extern QAction* actionFormatPickColor;
98 extern QAction* actionFormatColorBranch;
99 extern QAction* actionFormatColorSubtree;
100 extern QAction* actionFormatLinkColorHint;
101 extern QAction* actionFormatBackColor;
102 extern QAction* actionFormatLinkColor;
103 extern QAction *actionFormatIncludeImagesVer;
104 extern QAction *actionFormatIncludeImagesHor;
106 extern QActionGroup* actionGroupModModes;
107 extern QAction* actionModModeColor;
108 extern QAction* actionModModeLink;
109 extern QAction* actionModModeCopy;
111 extern QActionGroup *actionGroupFormatFrameTypes;
112 extern QAction *actionFormatFrameNone;
113 extern QAction *actionFormatFrameRectangle;
115 extern QActionGroup *actionGroupFormatLinkStyles;
116 extern QAction *actionFormatLinkStyleLine;
117 extern QAction *actionFormatLinkStyleParabel;
118 extern QAction *actionFormatLinkStylePolyLine;
119 extern QAction *actionFormatLinkStylePolyParabel;
120 extern QAction *actionFormatHideLinkUnselected;
122 extern QAction *actionViewToggleNoteEditor;
123 extern QAction *actionViewToggleHistoryWindow;
125 extern QAction* actionSettingsAutoedit;
126 extern QAction* actionSettingsAutoselectHeading;
127 extern QAction* actionSettingsAutoselectHeading;
128 extern QAction* actionSettingsAutoselectText;
129 extern QAction* actionSettingsPasteNewHeading;
130 extern QAction* actionSettingsUseDelKey;
131 extern QAction* actionSettingsUseFlagGroups;
132 extern QAction* actionSettingsUseHideExport;
134 extern Q3PopupMenu* branchContextMenu;
135 extern Q3PopupMenu* branchAddContextMenu;
136 extern Q3PopupMenu* branchRemoveContextMenu;
137 extern Q3PopupMenu* branchLinksContextMenu;
138 extern Q3PopupMenu* branchLinksContextMenuDup;
139 extern Q3PopupMenu* floatimageContextMenu;
140 extern Q3PopupMenu* saveImageFormatMenu;
141 extern Q3PopupMenu* canvasContextMenu;
142 extern Q3PopupMenu* lastMapsMenu;
143 extern Q3PopupMenu* importMenu;
144 extern Q3PopupMenu* exportMenu;
145 extern Q3PopupMenu* exportImageFormatMenu;
148 extern Settings settings;
149 extern Options options;
150 extern QDir vymBaseDir;
151 extern QString iconPath;
152 extern QString flagsPath;
154 Main::Main(QWidget* parent, const char* name, Qt::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 // Create unique temporary directory
169 tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
171 // Create direcctory for clipboard
172 clipboardDir=tmpVymDir+"/clipboard";
173 QDir d(clipboardDir);
174 d.mkdir (clipboardDir,true);
175 makeSubDirs (clipboardDir);
180 // FIXME not used currently
181 // Set random seed (random used for object IDs)
182 // QTime t = QTime::currentTime(); // set random seed
183 // srand( t.hour()*12+t.minute()*60+t.second()*60 );
186 // Initialize some settings, which are platform dependant
189 // application to open URLs
190 p="/vym/mainwindow/readerURL";
191 #if defined(Q_OS_LINUX)
192 s=settings.readEntry (p,"konqueror");
194 #if defined(Q_OS_MACX)
195 s=settings.readEntry (p,"/usr/bin/open");
197 s=settings.readEntry (p,"mozilla");
200 settings.writeEntry( p,s);
202 // application to open PDFs
203 p="/vym/mainwindow/readerPDF";
204 #if defined(Q_OS_LINUX)
205 s=settings.readEntry (p,"acroread");
207 #if defined(Q_OS_MACX)
208 s=settings.readEntry (p,"/usr/bin/open");
210 s=settings.readEntry (p,"acroread");
213 settings.writeEntry( p,s);
218 // Create tab widget which holds the maps
219 tabWidget= new QTabWidget (this);
220 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
221 this, SLOT( editorChanged( QWidget * ) ) );
223 setCentralWidget(tabWidget);
227 setupFormatActions();
231 setupSettingsActions();
233 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) setupTestActions();
236 // After menu is created, we can enable some actions
237 actionFilePrint->setEnabled (true);
242 // Initialize Find window
243 findWindow=new FindWindow(NULL,"findwindow");
244 connect (findWindow, SIGNAL( findButton(QString) ),
245 this, SLOT(editFind(QString) ) );
246 connect (findWindow, SIGNAL( somethingChanged() ),
247 this, SLOT(editFindChanged() ) );
249 // Connect TextEditor, so that we can update flags if text changes
250 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
258 settings.writeEntry( "/vym/mainwindow/geometry/width", width() );
259 settings.writeEntry( "/vym/mainwindow/geometry/height", height() );
260 settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
261 settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
263 settings.writeEntry( "/vym/version/version", __VYM_VERSION );
264 settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
266 settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
267 settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
268 settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
269 settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
270 settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
271 settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
272 settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
275 int maps=lastMaps.count();
276 settings.writeEntry( "/vym/lastMaps/number",maps );
277 for (int i=1;i<=maps;i++)
279 s=QString("/vym/lastMaps/map-%1").arg(i);
280 if (!s.isEmpty() && i<=maxLastMaps)
281 settings.writeEntry (s, lastMaps.at(i-1));
285 // To make the texteditor save its settings, call the destructor
288 // Remove temporary directory
289 removeDir (QDir(tmpVymDir));
292 void Main::loadCmdLine()
294 /* TODO draw some kind of splashscreen while loading...
300 QStringList flist=options.getFileList();
301 QStringList::Iterator it=flist.begin();
303 while (it !=flist.end() )
305 fileLoad (*it, NewMap);
311 void Main::statusMessage(const QString &s)
313 statusBar()->message (s);
316 void Main::closeEvent (QCloseEvent* )
322 void Main::setupFileActions()
324 QToolBar *tb = addToolBar( tr ("&File") );
325 Q3PopupMenu *menu = new Q3PopupMenu( this );
326 menuBar()->insertItem( tr( "&File" ), menu );
328 // Keycodes: /usr/lib64/qt3/include/qnamespace.h
331 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
332 a->setStatusTip ( tr( "New map","File menu" ) );
333 a->setShortcut ( Qt::CTRL + Qt::Key_N );
336 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
338 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
339 a->setStatusTip (tr( "Open","File menu" ) );
340 a->setShortcut ( Qt::CTRL + Qt::Key_O );
343 connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
345 lastMapsMenu = new Q3PopupMenu (this);
347 menu->insertItem (tr("Open Recent"),lastMapsMenu );
348 menu->insertSeparator();
350 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
351 a->setStatusTip ( tr( "Save" ));
352 a->setShortcut (Qt::CTRL + Qt::Key_S );
355 connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
358 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
359 a->setStatusTip (tr( "Save &As" ) );
361 connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
363 menu->insertSeparator();
365 importMenu = new Q3PopupMenu (this);
366 menu->insertItem (tr("Import"),importMenu );
368 a = new QAction(tr("KDE Bookmarks"), this);
369 a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
370 a->addTo (importMenu);
371 connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
373 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
375 a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
376 a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
377 a->addTo (importMenu);
378 connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
381 a = new QAction("Mind Manager...",this);
382 a->setStatusTip ( tr( "Import")+" Mind Manager" );
383 a->addTo (importMenu);
384 connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
386 a = new QAction( tr( "Import Dir"+QString("...") ), this);
387 a->setStatusTip (tr( "Import directory structure (experimental)" ) );
388 a->addTo( importMenu);
389 connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
391 exportMenu = new Q3PopupMenu (this);
392 menu->insertItem (tr("Export"),exportMenu );
394 menu->insertSeparator();
397 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
398 a->setStatusTip ( tr( "Print" ) );
399 a->setShortcut (Qt::CTRL + Qt::Key_P );
402 connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
405 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
406 a->setStatusTip (tr( "Close Map" ) );
407 a->setShortcut (Qt::ALT + Qt::Key_C );
409 connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
411 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
412 a->setStatusTip ( tr( "Exit")+" "+__VYM );
413 a->setShortcut (Qt::CTRL + Qt::Key_Q );
415 connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
420 void Main::setupEditActions()
422 QToolBar *tb = addToolBar( tr ("&Edit") );
423 tb->setLabel( "Edit Actions" );
424 Q3PopupMenu *menu = new Q3PopupMenu( this );
425 menuBar()->insertItem( tr( "&Edit" ), menu );
429 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
430 connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
431 a->setStatusTip (tr( "Undo" ) );
432 a->setShortcut ( Qt::CTRL + Qt::Key_Z );
433 a->setEnabled (false);
438 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
440 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this);
441 a->setStatusTip (tr( "Redo" ));
442 a->setShortcut (Qt::CTRL + Qt::Key_Y );
445 connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
448 menu->insertSeparator();
449 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
450 a->setStatusTip ( tr( "Copy" ) );
451 a->setShortcut (Qt::CTRL + Qt::Key_C );
452 a->setEnabled (false);
455 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
458 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
459 a->setStatusTip ( tr( "Cut" ) );
460 a->setShortcut (Qt::CTRL + Qt::Key_X );
461 a->setEnabled (false);
465 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
467 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
468 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
469 a->setStatusTip ( tr( "Paste" ) );
470 a->setShortcut ( Qt::CTRL + Qt::Key_V );
471 a->setEnabled (false);
476 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
477 a->setStatusTip ( tr( "Move branch up" ) );
478 a->setShortcut (Qt::Key_PageUp );
479 a->setEnabled (false);
482 connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
485 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
486 connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
487 a->setStatusTip (tr( "Move branch down" ) );
488 a->setShortcut ( Qt::Key_PageDown );
489 a->setEnabled (false);
492 actionEditMoveDown=a;
495 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
496 a->setShortcut ( Qt::Key_ScrollLock );
497 a->setStatusTip (tr( "Scroll branch" ) );
498 connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
499 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
500 alt->setShortcut ( Qt::Key_S );
501 alt->setStatusTip (tr( "Scroll branch" ));
502 connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
503 #if defined(Q_OS_MACX)
504 actionEditToggleScroll=alt;
506 actionEditToggleScroll=a;
508 actionEditToggleScroll->setEnabled (false);
509 actionEditToggleScroll->setToggleAction(true);
510 actionEditToggleScroll->addTo( tb );
511 actionEditToggleScroll->addTo( menu );
512 actionListBranches.append(actionEditToggleScroll);
514 a = new QAction( tr( "Unscroll all scrolled branches" ), this);
515 a->setStatusTip (tr( "Unscroll all" ));
517 connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
519 menu->insertSeparator();
521 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
522 a->setStatusTip (tr( "Find" ) );
523 a->setShortcut (Qt::CTRL + Qt::Key_F );
525 connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
527 menu->insertSeparator();
529 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
530 a->setShortcut (Qt::CTRL + Qt::Key_U );
531 a->setShortcut (tr( "Open URL" ));
533 a->setEnabled (false);
534 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
537 a = new QAction( tr( "Open URL in new tab" ), this);
538 a->setStatusTip (tr( "Open URL in new tab" ));
539 a->setShortcut (Qt::CTRL+Qt::Key_U );
540 a->setEnabled (false);
541 connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
542 actionEditOpenURLTab=a;
544 a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
545 a->setStatusTip ( tr( "Edit URL" ) );
546 a->setShortcut (Qt::SHIFT + Qt::CTRL+Qt::Key_U );
547 a->setEnabled (false);
548 actionListBranches.append(a);
549 connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
552 a = new QAction( tr( "Use heading for URL" ), this);
553 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
554 a->setEnabled (false);
555 actionListBranches.append(a);
556 connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
557 actionEditHeading2URL=a;
559 a = new QAction(tr( "Create URL to Bugzilla" ), this);
560 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
561 a->setEnabled (false);
562 actionListBranches.append(a);
563 connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
564 actionEditBugzilla2URL=a;
566 a = new QAction(tr( "Create URL to FATE" ), this);
567 a->setStatusTip ( tr( "Create URL to FATE" ));
568 a->setEnabled (false);
569 actionListBranches.append(a);
570 connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
571 actionEditFATE2URL=a;
573 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
574 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
576 a->setEnabled (false);
577 connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
578 actionEditOpenVymLink=a;
580 a = new QAction(tr( "Edit vym link"+QString("...") ), this);
581 a->setEnabled (false);
582 a->setStatusTip ( tr( "Edit link to another vym map" ));
583 connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
584 actionListBranches.append(a);
587 a = new QAction(tr( "Delete vym link" ),this);
588 a->setStatusTip ( tr( "Delete link to another vym map" ));
589 a->setEnabled (false);
590 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
591 actionEditDeleteVymLink=a;
593 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
594 a->setStatusTip ( tr( "Hide object in exports" ) );
595 a->setShortcut (Qt::Key_H );
596 a->setToggleAction(true);
598 a->setEnabled (false);
599 connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
600 actionEditToggleHideExport=a;
602 a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
603 a->setStatusTip ( tr( "Edit Map Info" ));
604 a->setEnabled (true);
605 connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
608 menu->insertSeparator();
610 // Shortcuts to modify heading:
612 a = new QAction(tr( "Edit heading" ),this);
613 a->setStatusTip ( tr( "edit Heading" ));
614 a->setShortcut ( Qt::Key_Enter);
615 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
616 actionListBranches.append(a);
618 a = new QAction( tr( "Edit heading" ), this);
619 a->setStatusTip (tr( "edit Heading" ));
620 a->setShortcut (Qt::Key_Return );
621 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
622 //actionListBranches.append(a);
626 a = new QAction( tr( "Edit heading" ),this);
627 a->setStatusTip (tr( "edit Heading" ));
628 a->setShortcut ( Qt::Key_F2 );
629 connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
630 a->setEnabled (false);
631 actionListBranches.append(a);
634 // Shortcut to delete selection
635 a = new QAction( tr( "Delete Selection" ),this);
636 a->setStatusTip (tr( "Delete Selection" ));
637 a->setShortcut ( Qt::Key_Delete);
638 connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
639 a->setEnabled (false);
642 // Shortcut to add branch
643 alt = new QAction(tr( "Add branch as child" ), this);
644 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
645 alt->setShortcut (Qt::Key_A);
646 connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
647 a = new QAction(tr( "Add branch as child" ), this);
648 a->setStatusTip ( tr( "Add a branch as child of selection" ));
649 a->setShortcut (Qt::Key_Insert);
650 // a->setEnabled (false);
651 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
652 actionListBranches.append(a);
653 #if defined (Q_OS_MACX)
654 // In OSX show different shortcut in menues, the keys work independtly always
655 actionEditAddBranch=alt;
657 actionEditAddBranch=a;
660 // Add branch by inserting it at selection
661 a = new QAction(tr( "Add branch (insert)" ), this);
662 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
663 a->setShortcut (Qt::ALT + Qt::Key_Insert );
664 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
665 a->setEnabled (false);
666 actionListBranches.append(a);
667 actionEditAddBranchHere=a;
668 a = new QAction(tr( "Add branch (insert)" ),this);
669 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
670 a->setShortcut ( Qt::ALT + Qt::Key_A );
671 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
672 actionListBranches.append(a);
675 a = new QAction(tr( "Add branch above" ), this);
676 a->setStatusTip ( tr( "Add a branch above selection" ));
677 a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
678 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
679 a->setEnabled (false);
680 actionListBranches.append(a);
681 actionEditAddBranchAbove=a;
682 a = new QAction(tr( "Add branch above" ), this);
683 a->setStatusTip ( tr( "Add a branch above selection" ));
684 a->setShortcut (Qt::SHIFT+Qt::Key_A );
685 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
686 actionListBranches.append(a);
689 a = new QAction(tr( "Add branch below" ), this);
690 a->setStatusTip ( tr( "Add a branch below selection" ));
691 a->setShortcut (Qt::CTRL +Qt::Key_Insert );
692 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
693 a->setEnabled (false);
694 actionListBranches.append(a);
695 actionEditAddBranchBelow=a;
696 a = new QAction(tr( "Add branch below" ), this);
697 a->setStatusTip ( tr( "Add a branch below selection" ));
698 a->setShortcut (Qt::CTRL +Qt::Key_A );
699 connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
700 actionListBranches.append(a);
702 // Import at selection (adding to selection)
703 a = new QAction( tr( "Add map (insert)" ),this);
704 a->setStatusTip (tr( "Add map at selection" ));
705 connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
706 a->setEnabled (false);
707 actionListBranches.append(a);
708 actionEditImportAdd=a;
710 // Import at selection (replacing selection)
711 a = new QAction( tr( "Add map (replace)" ), this);
712 a->setStatusTip (tr( "Replace selection with map" ));
713 connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
714 a->setEnabled (false);
715 actionListBranches.append(a);
716 actionEditImportReplace=a;
719 a = new QAction( tr( "Save selection" ), this);
720 a->setStatusTip (tr( "Save selection" ));
721 connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
722 a->setEnabled (false);
723 actionListBranches.append(a);
724 actionEditSaveBranch=a;
726 // Only remove branch, not its childs
727 a = new QAction(tr( "Remove only branch " ), this);
728 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
729 a->setShortcut (Qt::ALT + Qt::Key_Delete );
730 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
731 a->setEnabled (false);
732 actionListBranches.append(a);
733 actionEditRemoveBranchKeepChilds=a;
735 // Only remove childs of a branch
736 a = new QAction( tr( "Remove childs" ), this);
737 a->setStatusTip (tr( "Remove childs of branch" ));
738 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
739 connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
740 a->setEnabled (false);
741 actionListBranches.append(a);
742 actionEditRemoveChilds=a;
744 // Shortcuts for navigating with cursor:
745 a = new QAction(tr( "Select upper branch" ), this);
746 a->setStatusTip ( tr( "Select upper branch" ));
747 a->setShortcut (Qt::Key_Up );
748 connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
749 a = new QAction( tr( "Select lower branch" ),this);
750 a->setStatusTip (tr( "Select lower branch" ));
751 a->setShortcut ( Qt::Key_Down );
752 connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
753 a = new QAction(tr( "Select left branch" ), this);
754 a->setStatusTip ( tr( "Select left branch" ));
755 a->setShortcut (Qt::Key_Left );
756 connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
757 a = new QAction( tr( "Select child branch" ), this);
758 a->setStatusTip (tr( "Select right branch" ));
759 a->setShortcut (Qt::Key_Right);
760 connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
761 a = new QAction( tr( "Select first branch" ), this);
762 a->setStatusTip (tr( "Select first branch" ));
763 a->setShortcut (Qt::Key_Home );
764 a->setEnabled (false);
766 actionListBranches.append(a);
767 actionEditSelectFirst=a;
768 connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
769 a = new QAction( tr( "Select last branch" ),this);
770 a->setStatusTip (tr( "Select last branch" ));
771 a->setShortcut ( Qt::Key_End );
772 connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
773 a->setEnabled (false);
775 actionListBranches.append(a);
776 actionEditSelectLast=a;
778 a = new QAction( tr( "Add Image" )+QString("..."), this);
779 a->setStatusTip (tr( "Add Image" ));
780 connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
781 actionEditLoadImage=a;
786 void Main::setupFormatActions()
788 Q3PopupMenu *menu = new Q3PopupMenu( this );
789 menuBar()->insertItem( tr( "F&ormat" ), menu );
791 QToolBar *tb = addToolBar( tr("Format Actions","Toolbars"));
794 pix.fill (Qt::black);
795 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
796 a->setStatusTip ( tr( "Set Color" ));
797 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
801 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
802 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
803 a->setShortcut (Qt::CTRL + Qt::Key_K );
804 connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
805 a->setEnabled (false);
808 actionListBranches.append(a);
809 actionFormatPickColor=a;
811 a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
812 a->setStatusTip ( tr( "Color branch" ) );
813 a->setShortcut (Qt::CTRL + Qt::Key_I);
814 connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
815 a->setEnabled (false);
818 actionListBranches.append(a);
819 actionFormatColorBranch=a;
821 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
822 a->setStatusTip ( tr( "Color Subtree" ));
823 a->setShortcut (Qt::CTRL + Qt::Key_T);
824 connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
825 a->setEnabled (false);
828 actionListBranches.append(a);
829 actionFormatColorSubtree=a;
831 menu->insertSeparator();
832 actionGroupFormatLinkStyles=new QActionGroup ( this);
833 actionGroupFormatLinkStyles->setExclusive (true);
834 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
835 a->setStatusTip (tr( "Line" ));
836 a->setToggleAction(true);
837 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
838 actionFormatLinkStyleLine=a;
839 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
840 a->setStatusTip (tr( "Line" ));
841 a->setToggleAction(true);
842 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
843 actionFormatLinkStyleParabel=a;
844 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
845 a->setStatusTip (tr( "PolyLine" ));
846 a->setToggleAction(true);
847 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
848 actionFormatLinkStylePolyLine=a;
849 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
850 a->setStatusTip (tr( "PolyParabel" ) );
851 a->setToggleAction(true);
852 connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
853 actionFormatLinkStylePolyParabel=a;
854 actionGroupFormatLinkStyles->addTo (menu);
856 actionGroupFormatFrameTypes=new QActionGroup ( this);
857 actionGroupFormatFrameTypes->setExclusive (true);
858 a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
859 a->setStatusTip (tr("No Frame"));
860 a->setToggleAction(true);
861 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
862 actionFormatFrameNone=a;
863 a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
864 a->setStatusTip (tr( "Rectangle" ));
865 a->setToggleAction(true);
866 connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
867 actionFormatFrameRectangle=a;
869 a = new QAction( tr( "Include images vertically" ), actionFormatIncludeImagesVer);
870 a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
871 a->setToggleAction(true);
872 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
873 actionFormatIncludeImagesVer=a;
875 a = new QAction( tr( "Include images horizontally" ), actionFormatIncludeImagesHor );
876 a->setStatusTip ( tr ("Include left and right position of images into branch"));
877 a->setToggleAction(true);
878 connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
879 actionFormatIncludeImagesHor=a;
881 a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
882 a->setStatusTip (tr( "Hide link" ));
883 a->setToggleAction(true);
884 connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
885 actionFormatHideLinkUnselected=a;
887 menu->insertSeparator();
888 a= new QAction( tr( "&Use color of heading for link" ), this);
889 a->setStatusTip (tr( "Use same color for links and headings" ));
890 a->setToggleAction(true);
891 connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
893 actionFormatLinkColorHint=a;
895 pix.fill (Qt::white);
896 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
897 a->setStatusTip (tr( "Set Link Color" ));
899 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
900 actionFormatLinkColor=a;
902 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
903 a->setStatusTip (tr( "Set Background Color" ));
905 connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
906 actionFormatBackColor=a;
910 void Main::setupViewActions()
912 QToolBar *tb = addToolBar( tr("View Actions","Toolbars") );
913 tb->setLabel( "View Actions" );
914 Q3PopupMenu *menu = new Q3PopupMenu( this );
915 menuBar()->insertItem( tr( "&View" ), menu );
918 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
919 a->setStatusTip ( tr( "Zoom reset" ) );
920 a->setShortcut (Qt::CTRL + Qt::Key_0 );
923 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
925 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
926 a->setStatusTip (tr( "Zoom in" ));
927 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
930 connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
932 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
933 a->setStatusTip (tr( "Zoom out" ));
934 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
937 connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
940 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
941 a->setStatusTip ( tr( "Show Note Editor" ));
942 a->setShortcut ( Qt::CTRL + Qt::Key_E );
943 a->setToggleAction(true);
944 if (textEditor->showWithMain())
950 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
951 actionViewToggleNoteEditor=a;
953 a = new QAction( tr( "Show history window" ),this );
954 a->setStatusTip ( tr( "Show history window" ));
955 a->setShortcut ( Qt::CTRL + Qt::Key_H );
956 a->setToggleAction(false);
958 connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
959 actionViewToggleHistoryWindow=a;
961 a = new QAction(tr( "Next Window" ), this);
962 a->setStatusTip ( tr( "&Next Window" ) );
963 a->setShortcut (Qt::ALT + Qt::Key_N );
965 connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
967 a = new QAction (tr( "Previous Window" ), this );
968 a->setStatusTip (tr( "&Previous Window" ));
969 a->setShortcut (Qt::ALT + Qt::Key_P );
971 connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
975 void Main::setupModeActions()
977 //QPopupMenu *menu = new QPopupMenu( this );
978 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
980 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Toolbars") );
982 actionGroupModModes=new QActionGroup ( this);
983 actionGroupModModes->setExclusive (true);
984 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
985 a->setShortcut (Qt::Key_J);
986 a->setStatusTip ( tr( "Use modifier to color branches" ));
987 a->setToggleAction(true);
990 actionModModeColor=a;
992 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
993 a->setShortcut( Qt::Key_K);
994 a->setStatusTip( tr( "Use modifier to copy" ));
995 a->setToggleAction(true);
999 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
1000 a->setShortcut (Qt::Key_L);
1001 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1002 a->setToggleAction(true);
1004 actionModModeLink=a;
1008 void Main::setupFlagActions()
1010 // Create System Flags
1011 systemFlagsDefault = new FlagRowObj ();
1012 systemFlagsDefault->setVisibility (false);
1013 systemFlagsDefault->setName ("systemFlagsDef");
1015 FlagObj *fo = new FlagObj ();
1016 fo->load(QPixmap(flagsPath+"flag-note.png"));
1017 fo->setName("note");
1018 fo->setToolTip(tr("Note","Systemflag"));
1019 systemFlagsDefault->addFlag (fo); // makes deep copy
1021 fo->load(QPixmap(flagsPath+"flag-url.png"));
1023 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1024 systemFlagsDefault->addFlag (fo);
1026 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1027 fo->setName("vymLink");
1028 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1029 systemFlagsDefault->addFlag (fo);
1031 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1032 fo->setName("scrolledright");
1033 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1034 systemFlagsDefault->addFlag (fo);
1036 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1037 fo->setName("tmpUnscrolledright");
1038 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1039 systemFlagsDefault->addFlag (fo);
1041 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1042 fo->setName("hideInExport");
1043 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1044 systemFlagsDefault->addFlag (fo);
1046 // Create Standard Flags
1047 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1049 standardFlagsDefault = new FlagRowObj ();
1050 standardFlagsDefault->setVisibility (false);
1051 standardFlagsDefault->setName ("standardFlagsDef");
1052 standardFlagsDefault->setToolBar (tb);
1054 fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
1055 fo->setName ("exclamationmark");
1056 fo->setGroup("standard-mark");
1057 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1060 a->setCheckable(true);
1061 a->setObjectName(fo->getName());
1062 a->setToolTip(tr("Take care!","Standardflag"));
1063 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1064 standardFlagsDefault->addFlag (fo); // makes deep copy
1066 fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
1067 fo->setName("questionmark");
1068 fo->setGroup("standard-mark");
1069 a=new QAction (fo->getPixmap(),fo->getName(),this);
1072 a->setCheckable(true);
1073 a->setObjectName(fo->getName());
1074 a->setToolTip(tr("Really?","Standardflag"));
1075 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1076 standardFlagsDefault->addFlag (fo);
1078 fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
1079 fo->setName("hook-green");
1080 fo->setGroup("standard-hook");
1081 a=new QAction (fo->getPixmap(),fo->getName(),this);
1084 a->setCheckable(true);
1085 a->setObjectName(fo->getName());
1086 a->setToolTip(tr("ok!","Standardflag"));
1087 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1088 standardFlagsDefault->addFlag (fo);
1090 fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
1091 fo->setName("cross-red");
1092 fo->setGroup("standard-hook");
1093 a=new QAction (fo->getPixmap(),fo->getName(),this);
1096 a->setCheckable(true);
1097 a->setObjectName(fo->getName());
1098 a->setToolTip(tr("Not ok!","Standardflag"));
1099 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1100 standardFlagsDefault->addFlag (fo);
1102 fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
1103 fo->setName("stopsign");
1104 a=new QAction (fo->getPixmap(),fo->getName(),this);
1107 a->setCheckable(true);
1108 a->setObjectName(fo->getName());
1109 a->setToolTip(tr("This won't work!","Standardflag"));
1110 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1111 standardFlagsDefault->addFlag (fo);
1113 fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
1114 fo->setName("smiley-good");
1115 fo->setGroup("standard-smiley");
1116 a=new QAction (fo->getPixmap(),fo->getName(),this);
1119 a->setCheckable(true);
1120 a->setObjectName(fo->getName());
1121 a->setToolTip(tr("Good","Standardflag"));
1122 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1123 standardFlagsDefault->addFlag (fo);
1125 fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
1126 fo->setName("smiley-sad");
1127 fo->setGroup("standard-smiley");
1128 a=new QAction (fo->getPixmap(),fo->getName(),this);
1131 a->setCheckable(true);
1132 a->setObjectName(fo->getName());
1133 a->setToolTip(tr("Bad","Standardflag"));
1134 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1135 standardFlagsDefault->addFlag (fo);
1137 fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
1138 // Original omg.png (in KDE emoticons)
1139 fo->setName("smiley-omg");
1140 fo->setGroup("standard-smiley");
1141 a=new QAction (fo->getPixmap(),fo->getName(),this);
1144 a->setCheckable(true);
1145 a->setObjectName(fo->getName());
1146 a->setToolTip(tr("Oh no!","Standardflag"));
1147 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1148 standardFlagsDefault->addFlag (fo);
1150 fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
1151 fo->setName("clock");
1152 a=new QAction (fo->getPixmap(),fo->getName(),this);
1155 a->setCheckable(true);
1156 a->setObjectName(fo->getName());
1157 a->setToolTip(tr("Time critical","Standardflag"));
1158 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1159 standardFlagsDefault->addFlag (fo);
1161 fo->load(QPixmap(flagsPath+"flag-phone.png"));
1162 fo->setName("phone");
1163 a=new QAction (fo->getPixmap(),fo->getName(),this);
1166 a->setCheckable(true);
1167 a->setObjectName(fo->getName());
1168 a->setToolTip(tr("Call...","Standardflag"));
1169 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1170 standardFlagsDefault->addFlag (fo);
1172 fo->load(QPixmap(flagsPath+"flag-lamp.png"));
1173 fo->setName("lamp");
1174 a=new QAction (fo->getPixmap(),fo->getName(),this);
1177 a->setCheckable(true);
1178 a->setObjectName(fo->getName());
1179 a->setToolTip(tr("Idea!","Standardflag"));
1180 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1181 standardFlagsDefault->addFlag (fo);
1183 fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
1184 fo->setName("arrow-up");
1185 fo->setGroup("standard-arrow");
1186 a=new QAction (fo->getPixmap(),fo->getName(),this);
1189 a->setCheckable(true);
1190 a->setObjectName(fo->getName());
1191 a->setToolTip(tr("Important","Standardflag"));
1192 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1193 standardFlagsDefault->addFlag (fo);
1195 fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
1196 fo->setName("arrow-down");
1197 fo->setGroup("standard-arrow");
1198 a=new QAction (fo->getPixmap(),fo->getName(),this);
1201 a->setCheckable(true);
1202 a->setObjectName(fo->getName());
1203 a->setToolTip(tr("Unimportant","Standardflag"));
1204 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1205 standardFlagsDefault->addFlag (fo);
1207 fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
1208 fo->setName("2arrow-up");
1209 fo->setGroup("standard-arrow");
1210 a=new QAction (fo->getPixmap(),fo->getName(),this);
1213 a->setCheckable(true);
1214 a->setObjectName(fo->getName());
1215 a->setToolTip(tr("Very important!","Standardflag"));
1216 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1217 standardFlagsDefault->addFlag (fo);
1219 fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
1220 fo->setName("2arrow-down");
1221 fo->setGroup("standard-arrow");
1222 a=new QAction (fo->getPixmap(),fo->getName(),this);
1225 a->setCheckable(true);
1226 a->setObjectName(fo->getName());
1227 a->setToolTip(tr("Very unimportant!","Standardflag"));
1228 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1229 standardFlagsDefault->addFlag (fo);
1231 fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
1232 fo->setName("thumb-up");
1233 fo->setGroup("standard-thumb");
1234 a=new QAction (fo->getPixmap(),fo->getName(),this);
1237 a->setCheckable(true);
1238 a->setObjectName(fo->getName());
1239 a->setToolTip(tr("I like this","Standardflag"));
1240 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1241 standardFlagsDefault->addFlag (fo);
1243 fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
1244 fo->setName("thumb-down");
1245 fo->setGroup("standard-thumb");
1246 a=new QAction (fo->getPixmap(),fo->getName(),this);
1249 a->setCheckable(true);
1250 a->setObjectName(fo->getName());
1251 a->setToolTip(tr("I do not like this","Standardflag"));
1252 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1253 standardFlagsDefault->addFlag (fo);
1255 fo->load(QPixmap(flagsPath+"flag-rose.png"));
1256 fo->setName("rose");
1257 a=new QAction (fo->getPixmap(),fo->getName(),this);
1260 a->setCheckable(true);
1261 a->setObjectName(fo->getName());
1262 a->setToolTip(tr("Rose","Standardflag"));
1263 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1264 standardFlagsDefault->addFlag (fo);
1266 fo->load(QPixmap(flagsPath+"flag-heart.png"));
1267 fo->setName("heart");
1268 a=new QAction (fo->getPixmap(),fo->getName(),this);
1270 a->setCheckable(true);
1271 a->setObjectName(fo->getName());
1272 a->setToolTip(tr("I just love... ","Standardflag"));
1273 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1274 standardFlagsDefault->addFlag (fo);
1276 fo->load(QPixmap(flagsPath+"flag-present.png"));
1277 fo->setName("present");
1278 a=new QAction (fo->getPixmap(),fo->getName(),this);
1281 a->setCheckable(true);
1282 a->setObjectName(fo->getName());
1283 a->setToolTip(tr("Surprise!","Standardflag"));
1284 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1285 standardFlagsDefault->addFlag (fo);
1287 fo->load(QPixmap(flagsPath+"flag-flash.png"));
1288 fo->setName("flash");
1289 a=new QAction (fo->getPixmap(),fo->getName(),this);
1292 a->setCheckable(true);
1293 a->setObjectName(fo->getName());
1294 a->setToolTip(tr("Dangerous","Standardflag"));
1295 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1296 standardFlagsDefault->addFlag (fo);
1298 fo->load(QPixmap(flagsPath+"flag-info.png"));
1299 // Original: xsldbg_output.png
1300 fo->setName("info");
1301 a=new QAction (fo->getPixmap(),fo->getName(),this);
1304 a->setCheckable(true);
1305 a->setObjectName(fo->getName());
1306 a->setToolTip(tr("Info","Standardflag"));
1307 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1308 standardFlagsDefault->addFlag (fo);
1310 fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
1311 // Original khelpcenter.png
1312 fo->setName("lifebelt");
1313 a=new QAction (fo->getPixmap(),fo->getName(),this);
1316 a->setCheckable(true);
1317 a->setObjectName(fo->getName());
1318 a->setToolTip(tr("This will help","Standardflag"));
1319 connect (a, SIGNAL( activated() ), this, SLOT( standardFlagChanged() ) );
1320 standardFlagsDefault->addFlag (fo);
1326 void Main::setupSettingsActions()
1328 Q3PopupMenu *menu = new Q3PopupMenu( this );
1329 menuBar()->insertItem( tr( "&Settings" ), menu );
1334 a = new QAction( tr( "Set application to open pdf files"), this);
1335 a->setStatusTip ( tr( "Set application to open pdf files"));
1336 connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
1339 a = new QAction( tr( "Set application to open external links"), this);
1340 a->setStatusTip( tr( "Set application to open external links"));
1341 connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
1344 menu->insertSeparator();
1345 a = new QAction( tr( "Edit branch after adding it" ), this );
1346 a->setStatusTip( tr( "Edit branch after adding it" ));
1347 a->setToggleAction(true);
1348 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
1350 actionSettingsAutoedit=a;
1352 a= new QAction( tr( "Select branch after adding it" ), this );
1353 a->setStatusTip( tr( "Select branch after adding it" ));
1354 a->setToggleAction(true);
1355 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
1357 actionSettingsAutoselectHeading=a;
1359 a= new QAction(tr( "Select existing heading" ), this);
1360 a->setStatusTip( tr( "Select heading before editing" ));
1361 a->setToggleAction(true);
1362 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
1364 actionSettingsAutoselectText=a;
1366 a= new QAction(tr( "pasting into new branch" ), this );
1367 a->setStatusTip( tr( "Pasting into new branch" ));
1368 a->setToggleAction(true);
1369 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
1371 actionSettingsPasteNewHeading=a;
1373 a= new QAction( tr( "Delete key" ), this);
1374 a->setStatusTip( tr( "Delete key for deleting branches" ));
1375 a->setToggleAction(true);
1376 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
1378 connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
1379 actionSettingsUseDelKey=a;
1381 a= new QAction( tr( "Exclusive flags" ), this);
1382 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1383 a->setToggleAction(true);
1384 a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
1386 actionSettingsUseFlagGroups=a;
1388 a= new QAction( tr( "Use hide flags" ), this);
1389 a->setStatusTip( tr( "Use hide flag during exports " ));
1390 a->setToggleAction(true);
1391 a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
1393 actionSettingsUseHideExport=a;
1397 void Main::setupTestActions()
1399 Q3PopupMenu *menu = new Q3PopupMenu( this );
1400 menuBar()->insertItem( tr( "&Test" ), menu );
1403 a = new QAction( tr( "test flag" ), this);
1404 a->setStatusTip( tr( "Call test function" ));
1405 connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
1410 void Main::setupHelpActions()
1412 Q3PopupMenu *menu = new Q3PopupMenu( this );
1413 menuBar()->insertItem( tr( "&Help" ), menu );
1416 a = new QAction( tr( "Open VYM Documentation (pdf) " ), this );
1417 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1418 connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
1421 a = new QAction( tr( "About VYM" ), this);
1422 a->setStatusTip( tr( "About VYM")+" "__VYM);
1423 connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
1426 a = new QAction( tr( "About QT" ), this);
1427 a->setStatusTip( tr( "Information about QT toolkit" ));
1428 connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
1433 void Main::setupContextMenus()
1437 // Context Menu for branch or mapcenter
1438 branchContextMenu =new Q3PopupMenu (this);
1441 branchAddContextMenu =new Q3PopupMenu (this);
1442 actionEditPaste->addTo ( branchAddContextMenu );
1443 actionEditAddBranch->addTo ( branchAddContextMenu );
1444 actionEditAddBranchHere->addTo ( branchAddContextMenu );
1445 actionEditAddBranchAbove->addTo ( branchAddContextMenu );
1446 actionEditAddBranchBelow->addTo ( branchAddContextMenu );
1447 branchAddContextMenu->insertSeparator();
1448 actionEditLoadImage->addTo( branchAddContextMenu );
1449 branchAddContextMenu->insertSeparator();
1450 actionEditImportAdd->addTo ( branchAddContextMenu );
1451 actionEditImportReplace->addTo ( branchAddContextMenu );
1454 branchRemoveContextMenu =new Q3PopupMenu (this);
1455 actionEditCut->addTo ( branchRemoveContextMenu );
1456 actionEditDelete->addTo ( branchRemoveContextMenu );
1457 actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu );
1458 actionEditRemoveChilds->addTo( branchRemoveContextMenu );
1460 branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);
1461 branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);
1463 actionEditSaveBranch->addTo( branchContextMenu );
1465 branchContextMenu->insertSeparator();
1466 actionEditOpenURL->addTo ( branchContextMenu );
1467 actionEditOpenURLTab->addTo ( branchContextMenu );
1468 actionEditURL->addTo ( branchContextMenu );
1469 actionEditHeading2URL->addTo ( branchContextMenu );
1470 actionEditBugzilla2URL->addTo( branchContextMenu );
1471 if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false))
1473 actionEditFATE2URL->addTo( branchContextMenu );
1475 branchContextMenu->insertSeparator();
1476 actionEditOpenVymLink->addTo ( branchContextMenu );
1477 actionEditVymLink->addTo ( branchContextMenu );
1478 actionEditDeleteVymLink->addTo ( branchContextMenu );
1480 branchContextMenu->insertSeparator();
1481 actionGroupFormatFrameTypes->addTo( branchContextMenu );
1483 branchContextMenu->insertSeparator();
1484 actionFormatIncludeImagesVer->addTo( branchContextMenu );
1485 actionFormatIncludeImagesHor->addTo( branchContextMenu );
1486 actionFormatHideLinkUnselected->addTo( branchContextMenu );
1488 // Context Menu for links in a branch menu
1489 // This will be populated "on demand" in MapEditor::updateActions
1490 branchContextMenu->insertSeparator();
1491 branchLinksContextMenu =new Q3PopupMenu (this);
1492 branchLinksContextMenuDup =new Q3PopupMenu (this);
1493 branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
1494 connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
1496 branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
1497 connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
1499 // Context menu for floatimage
1500 floatimageContextMenu =new Q3PopupMenu (this);
1501 saveImageFormatMenu=new Q3PopupMenu (this);
1502 exportImageFormatMenu=new Q3PopupMenu (this);
1504 /* FIXME strange error
1505 foreach (QByteArray format, QImageWriter::supportedImageFormats())
1507 QString text = tr("%1...").arg(QString(format).toUpper());
1508 saveImageFormatMenu->insertItem( text );
1509 exportImageFormatMenu->insertItem( text );
1513 /* FIXME not needed any longer
1514 Q3StrList fmt = QImageWriter::supportedImageFormats();
1515 for (const char* f = fmt.first(); f; f = fmt.next())
1517 saveImageFormatMenu->insertItem( f );
1518 exportImageFormatMenu->insertItem( f );
1521 connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
1522 connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
1523 floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
1525 floatimageContextMenu->insertSeparator();
1526 actionEditCopy->addTo( floatimageContextMenu );
1527 actionEditCut->addTo( floatimageContextMenu );
1529 floatimageContextMenu->insertSeparator();
1530 actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
1532 exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
1534 a = new QAction( "Open Office"+QString("..."), this);
1535 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
1536 connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
1537 a->addTo (exportMenu);
1539 a = new QAction( "Webpage (XHTML)...",this );
1540 a->setShortcut (Qt::ALT + Qt::Key_X);
1541 a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
1542 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
1543 a->addTo( exportMenu );
1545 a = new QAction( "Text (ASCII)...", this);
1546 a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
1547 connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
1548 a->addTo( exportMenu );
1550 a = new QAction( tr("KDE Bookmarks"), this);
1551 a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
1552 connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
1553 a->addTo (exportMenu);
1555 a = new QAction( "Taskjuggler...", this );
1556 a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
1557 connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
1558 a->addTo( exportMenu );
1560 a = new QAction( "LaTeX...", this);
1561 a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
1562 connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
1563 a->addTo( exportMenu );
1565 a = new QAction( "XML..." , this );
1566 a->setStatusTip (tr( "Export as")+" XML");
1567 connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
1568 a->addTo( exportMenu );
1570 // Context menu for canvas
1571 canvasContextMenu =new Q3PopupMenu (this);
1572 actionEditMapInfo->addTo( canvasContextMenu );
1573 canvasContextMenu->insertSeparator();
1574 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1575 canvasContextMenu->insertSeparator();
1576 actionFormatLinkColorHint->addTo( canvasContextMenu );
1577 actionFormatLinkColor->addTo( canvasContextMenu );
1578 actionFormatBackColor->addTo( canvasContextMenu );
1580 // Menu for last opened files
1581 // Read settings initially
1583 int j=settings.readNumEntry( "/vym/lastMaps/number",0);
1584 for (int i=1;i<=j;i++)
1586 s=settings.readEntry(QString("/vym/lastMaps/map-%1").arg(i),"");
1587 if (!s.isEmpty() && j<=maxLastMaps)
1590 setupLastMapsMenu();
1591 connect( lastMapsMenu, SIGNAL( activated(int) ), this, SLOT( fileLoadLast(int ) ) );
1594 void Main::setupLastMapsMenu()
1596 // Remove double entries
1597 QStringList::Iterator it=lastMaps.begin();
1598 QStringList::Iterator jt;
1599 while (it!=lastMaps.end() )
1603 while (jt!=lastMaps.end() )
1606 jt=lastMaps.remove(jt);
1613 // Limit length of list to maxLastMaps
1614 while ((int)(lastMaps.count()) > maxLastMaps) lastMaps.pop_back();
1616 // build Menu from lastMaps string list
1617 lastMapsMenu->clear();
1618 for (it = lastMaps.begin(); it != lastMaps.end(); ++it )
1619 lastMapsMenu->insertItem (*it );
1623 void Main::hideEvent (QHideEvent * )
1625 if (!textEditor->isMinimized() ) textEditor->hide();
1628 void Main::showEvent (QShowEvent * )
1630 if (textEditor->showWithMain()) textEditor->showNormal();
1633 bool Main::reallyWriteDirectory(const QString &dir)
1635 QStringList eList = QDir(dir).entryList();
1636 if (eList.first() ==".") eList.pop_front(); // remove "."
1637 if (eList.first() =="..") eList.pop_front(); // remove "."
1638 if (!eList.isEmpty())
1640 QMessageBox mb( __VYM,
1641 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
1642 QMessageBox::Warning,
1644 QMessageBox::Cancel | QMessageBox::Default,
1645 QMessageBox::QMessageBox::NoButton );
1647 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1648 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1651 case QMessageBox::Yes:
1654 case QMessageBox::Cancel:
1662 QString Main::browseDirectory (const QString &caption)
1664 Q3FileDialog fd(this,caption);
1665 fd.setMode (Q3FileDialog::DirectoryOnly);
1666 fd.setCaption(__VYM " - "+caption);
1669 if ( fd.exec() == QDialog::Accepted )
1670 return fd.selectedFile();
1675 MapEditor* Main::currentMapEditor() const
1677 if ( tabWidget->currentPage() &&
1678 tabWidget->currentPage()->inherits( "MapEditor" ) )
1679 return (MapEditor*)tabWidget->currentPage();
1683 //TODO not used now, maybe use this for overview window later
1684 void Main::newView()
1686 // Open a new view... have it delete when closed.
1687 Main *m = new Main(0, 0, Qt::WDestructiveClose);
1688 qApp->setMainWidget(m);
1690 qApp->setMainWidget(0);
1693 void Main::editorChanged(QWidget *)
1695 // Unselect all possibly selected objects
1696 // (Important to update note editor)
1699 for (i=0;i<=tabWidget->count() -1;i++)
1702 me=(MapEditor*)tabWidget->page(i);
1705 currentMapEditor()->reselect();
1707 // Update actions to in menus and toolbars according to editor
1708 currentMapEditor()->updateActions();
1711 void Main::fileNew()
1713 QString fn="unnamed";
1714 MapEditor* medit = new MapEditor ( NULL,true);
1715 tabWidget->addTab (medit,fn);
1716 tabWidget->showPage(medit);
1717 medit->viewport()->setFocus();
1718 // For the very first map we do not have flagrows yet...
1719 medit->select("mc:");
1722 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1724 ErrorCode err=success;
1726 // fn is usually the archive, mapfile the file after uncompressing
1729 // Make fn absolute (needed for unzip)
1730 fn=QDir (fn).absPath();
1736 // Check, if map is already loaded
1738 while (i<=tabWidget->count() -1)
1740 me=(MapEditor*)tabWidget->page(i);
1741 if (me->getFilePath() == fn)
1743 // Already there, ask for confirmation
1744 QMessageBox mb( __VYM,
1745 tr("The map %1\nis already opened."
1746 "Opening the same map in multiple editors may lead \n"
1747 "to confusion when finishing working with vym."
1748 "Do you want to").arg(fn),
1749 QMessageBox::Warning,
1750 QMessageBox::Yes | QMessageBox::Default,
1751 QMessageBox::Cancel | QMessageBox::Escape,
1752 QMessageBox::NoButton);
1753 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1754 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1757 case QMessageBox::Yes:
1759 i=tabWidget->count();
1761 case QMessageBox::Cancel:
1773 if ( !fn.isEmpty() )
1775 me = currentMapEditor();
1776 int tabIndex=tabWidget->currentPageIndex();
1777 // Check first, if mapeditor exists
1778 // If it is not default AND we want a new map,
1779 // create a new mapeditor in a new tab
1780 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1782 me= new MapEditor ( NULL,true);
1783 tabWidget->addTab (me,fn);
1784 tabIndex=tabWidget->indexOf (me);
1785 tabWidget->setCurrentPage (tabIndex);
1788 // Check, if file exists (important for creating new files
1789 // from command line
1790 if (!QFile(fn).exists() )
1792 QMessageBox mb( __VYM,
1793 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1794 QMessageBox::Question,
1796 QMessageBox::Cancel | QMessageBox::Default,
1797 QMessageBox::NoButton );
1799 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1800 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1803 case QMessageBox::Yes:
1805 currentMapEditor()->setFilePath(fn);
1806 tabWidget->setTabLabel (currentMapEditor(),
1807 currentMapEditor()->getFileName() );
1808 statusBar()->message( "Created " + fn , statusbarTime );
1811 case QMessageBox::Cancel:
1812 // don't create new map
1813 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1820 //tabWidget->currentPage() won't be NULL here, because of above...
1821 tabWidget->showPage(me);
1822 me->viewport()->setFocus();
1824 // Create temporary directory for packing
1825 char tmpdir1[]="/tmp/vym-XXXXXX";
1826 QString tmpMapDir=mkdtemp(tmpdir1);
1828 // Try to unzip file
1829 err=unzipDir (tmpMapDir,fn);
1833 me->setZipped(false);
1836 me->setZipped(true);
1838 // Look for mapname.xml
1839 mapfile= fn.left(fn.findRev(".",-1,true));
1840 mapfile=mapfile.section( '/', -1 );
1841 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1842 if (!file.exists() )
1844 // mapname.xml does not exist, well,
1845 // maybe some renamed the mapname.vym file...
1846 // Try to find any .xml in the toplevel
1847 // directory of the .vym file
1848 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1849 if (flist.count()==1)
1851 // Only one entry, take this one
1852 mapfile=tmpMapDir + "/"+flist.first();
1855 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1856 *it=tmpMapDir + "/" + *it;
1857 // TODO Multiple entries, load all (but only the first one into this ME)
1858 //mainWindow->fileLoadFromTmp (flist);
1859 //returnCode=1; // Silently forget this attempt to load
1860 qWarning ("MainWindow::load (fn) multimap found...");
1863 if (flist.isEmpty() )
1865 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1866 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1869 } //file doesn't exist
1871 mapfile=file.name();
1876 // Save existing filename in case we import
1877 QString fn_org=me->getFilePath();
1879 // Finally load map into mapEditor
1880 me->setFilePath (mapfile,fn);
1881 err=me->load(mapfile,lmode);
1883 // Restore old (maybe empty) filepath, if this is an import
1885 me->setFilePath (fn_org);
1888 // Finally check for errors and go home
1891 if (lmode==NewMap) fileCloseMap();
1892 statusBar()->message( "Could not load " + fn, statusbarTime );
1897 me->setFilePath (fn);
1898 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1899 if (fn.left(9)!="/tmp/vym-")
1901 // Only append to lastMaps if not loaded from a tmpDir
1902 // e.g. imported bookmarks are in a tmpDir
1903 lastMaps.prepend(me->getFilePath() );
1904 setupLastMapsMenu();
1906 actionFilePrint->setEnabled (true);
1908 statusBar()->message( "Loaded " + fn, statusbarTime );
1912 removeDir (QDir(tmpMapDir));
1918 void Main::fileLoad(const LoadMode &lmode)
1920 Q3FileDialog *fd=new Q3FileDialog( this);
1921 if (!lastFileDir.isEmpty())
1922 fd->setDir (lastFileDir);
1923 fd->setMode (Q3FileDialog::ExistingFiles);
1924 fd->addFilter ("XML (*.xml)");
1925 fd->addFilter ("VYM map (*.vym *.vyp)");
1929 fd->setCaption(tr("Load vym map"));
1932 fd->setCaption(tr("Import: Add vym map to selection"));
1935 fd->setCaption(tr("Import: Replace selection with vym map"));
1941 if ( fd->exec() == QDialog::Accepted )
1943 lastFileDir=fd->dirPath();
1944 QStringList flist = fd->selectedFiles();
1945 QStringList::Iterator it = flist.begin();
1946 while( it != flist.end() )
1949 fileLoad(*it, lmode);
1956 void Main::fileLoad()
1961 void Main::fileLoadLast(int i)
1963 fileLoad(QString(*lastMaps.at(lastMapsMenu->indexOf (i)) ),NewMap);
1966 void Main::fileSave(const SaveMode &savemode)
1968 // tmp dir for zipping
1972 ErrorCode err=success;
1974 QString safeFilePath;
1976 bool saveZipped=currentMapEditor()->saveZipped();
1978 MapEditor * me=currentMapEditor();
1981 QString fn=me->getFilePath();
1982 // filename=unnamed, filepath="" in constructor...
1983 if ( !fn.isEmpty() )
1985 // We have a filepath, go on saving
1986 // First remove existing file, we
1987 // don't want to add to old zip archives
1991 QMessageBox::warning( 0, tr( "Save Error" ),
1992 fn+ tr("\ncould not be removed before saving"));
1994 // Look, if we should zip the data:
1997 QMessageBox mb( __VYM,
1998 tr("The map %1\ndid not use the compressed "
1999 "vym file format.\nWriting it uncompressed will also write images \n"
2000 "and flags and thus may overwrite files in the "
2001 "given directory\n\nDo you want to write the map").arg(fn),
2002 QMessageBox::Warning,
2003 QMessageBox::Yes | QMessageBox::Default,
2005 QMessageBox::Cancel | QMessageBox::Escape);
2006 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2007 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2008 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2011 case QMessageBox::Yes:
2012 // save compressed (default file format)
2015 case QMessageBox::No:
2016 // save uncompressed
2019 case QMessageBox::Cancel:
2028 char tmpdir1[]="/tmp/vym-XXXXXX";
2029 tmpMapDir=mkdtemp(tmpdir1);
2031 safeFilePath=me->getFilePath();
2032 me->setFilePath (tmpMapDir+"/"+
2033 me->getMapName()+ ".xml",
2035 me->save (savemode);
2036 me->setFilePath (safeFilePath);
2038 zipDir (tmpMapDir,fn);
2043 safeFilePath=me->getFilePath();
2044 me->setFilePath (fn, safeFilePath);
2045 me->save (savemode);
2046 me->setFilePath (safeFilePath);
2048 } // filepath available
2051 // We have no filepath yet,
2052 // call fileSaveAs() now, this will call fileSave()
2054 fileSaveAs(savemode);
2058 if (saveZipped && !tmpMapDir.isEmpty())
2060 removeDir (QDir(tmpMapDir));
2064 statusBar()->message(
2065 tr("Saved %1").arg(me->getFilePath()),
2067 lastMaps.prepend(me->getFilePath() );
2068 setupLastMapsMenu();
2070 statusBar()->message(
2071 tr("Couldn't save ").arg(me->getFilePath()),
2075 void Main::fileSave()
2077 fileSave (CompleteMap);
2080 void Main::fileSaveAs(const SaveMode& savemode)
2084 if (currentMapEditor())
2086 if (savemode==CompleteMap)
2087 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2089 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2090 if ( !fn.isEmpty() )
2092 // Check for existing file
2093 if (QFile (fn).exists())
2095 QMessageBox mb( __VYM,
2096 tr("The file %1\nexists already. Do you want to").arg(fn),
2097 QMessageBox::Warning,
2098 QMessageBox::Yes | QMessageBox::Default,
2099 QMessageBox::Cancel | QMessageBox::Escape,
2100 QMessageBox::NoButton);
2101 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2102 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2105 case QMessageBox::Yes:
2108 case QMessageBox::Cancel:
2115 // New file, add extension to filename, if missing
2116 // This is always .vym or .vyp, depending on savemode
2117 if (savemode==CompleteMap)
2119 if (!fn.contains (".vym") && !fn.contains (".xml"))
2123 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2132 currentMapEditor()->setFilePath(fn);
2136 if (savemode==CompleteMap)
2137 tabWidget->setTabLabel (currentMapEditor(),
2138 currentMapEditor()->getFileName() );
2144 void Main::fileSaveAs()
2146 fileSaveAs (CompleteMap);
2149 void Main::fileImportKDEBookmarks()
2151 ImportKDEBookmarks im;
2153 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2154 currentMapEditor()->setFilePath ("");
2157 void Main::fileImportFirefoxBookmarks()
2159 Q3FileDialog *fd=new Q3FileDialog( this);
2160 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2161 fd->setMode (Q3FileDialog::ExistingFiles);
2162 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2163 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2166 if ( fd->exec() == QDialog::Accepted )
2168 ImportFirefoxBookmarks im;
2169 QStringList flist = fd->selectedFiles();
2170 QStringList::Iterator it = flist.begin();
2171 while( it != flist.end() )
2174 if (im.transform() &&
2175 success==fileLoad (im.getTransformedFile(),NewMap) &&
2176 currentMapEditor() )
2177 currentMapEditor()->setFilePath ("");
2184 void Main::fileImportMM()
2188 Q3FileDialog *fd=new Q3FileDialog( this);
2189 if (!lastFileDir.isEmpty())
2190 fd->setDir (lastFileDir);
2191 fd->setMode (Q3FileDialog::ExistingFiles);
2192 fd->addFilter ("Mind Manager (*.mmap)");
2193 fd->setCaption(tr("Import")+" "+"Mind Manager");
2196 if ( fd->exec() == QDialog::Accepted )
2198 lastFileDir=fd->dirPath();
2199 QStringList flist = fd->selectedFiles();
2200 QStringList::Iterator it = flist.begin();
2201 while( it != flist.end() )
2204 if (im.transform() &&
2205 success==fileLoad (im.getTransformedFile(),NewMap) &&
2206 currentMapEditor() )
2207 currentMapEditor()->setFilePath ("");
2216 void Main::fileImportDir()
2218 if (currentMapEditor())
2219 currentMapEditor()->importDir();
2222 void Main::fileExportXML()
2224 if (currentMapEditor())
2226 QString dir=browseDirectory(tr("Export XML to directory"));
2227 if (dir !="" && reallyWriteDirectory(dir) )
2228 currentMapEditor()->exportXML(dir);
2233 void Main::fileExportXHTML()
2235 MapEditor *me=currentMapEditor();
2239 ExportXHTMLDialog dia(this);
2240 dia.setFilePath (me->getFilePath() );
2241 dia.setMapName (me->getMapName() );
2244 if (dia.exec()==QDialog::Accepted)
2246 QString dir=dia.getDir();
2247 // Check, if warnings should be used before overwriting
2248 // the output directory
2251 ok=reallyWriteDirectory(dir);
2257 me->exportXML (dia.getDir() );
2258 dia.doExport(me->getMapName() );
2259 if (dia.hasChanged())
2266 void Main::fileExportImage(int item)
2268 MapEditor *me=currentMapEditor();
2271 QString fn = Q3FileDialog::getSaveFileName( QString::null, "Image (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
2273 if ( !fn.isEmpty() )
2274 me->exportImage(fn,item);
2276 statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
2281 void Main::fileExportASCII()
2283 MapEditor *me=currentMapEditor();
2287 ex.setMapCenter(me->getMapCenter());
2288 ex.addFilter ("TXT (*.txt)");
2289 ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2290 if (ex.execDialog() )
2292 me->setExportMode(true);
2294 me->setExportMode(false);
2299 void Main::fileExportLaTeX()
2301 MapEditor *me=currentMapEditor();
2305 ex.setMapCenter(me->getMapCenter());
2306 ex.addFilter ("Tex (*.tex)");
2307 ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2308 if (ex.execDialog() )
2310 me->setExportMode(true);
2312 me->setExportMode(false);
2317 void Main::fileExportKDEBookmarks()
2319 ExportKDEBookmarks ex;
2320 MapEditor *me=currentMapEditor();
2323 ex.setMapCenter (me->getMapCenter() );
2328 void Main::fileExportTaskjuggler()
2330 ExportTaskjuggler ex;
2331 MapEditor *me=currentMapEditor();
2334 ex.setMapCenter (me->getMapCenter() );
2335 ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2336 ex.addFilter ("Taskjuggler (*.tjp)");
2337 if (ex.execDialog() )
2339 me->setExportMode(true);
2341 me->setExportMode(false);
2346 void Main::fileExportOOPresentation()
2348 ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
2349 // FIXME add extra info in dialog
2350 //ImagePreview *p =new ImagePreview (fd);
2351 //fd->setContentsPreviewEnabled( TRUE );
2352 //fd->setContentsPreview( p, p );
2353 //fd->setPreviewMode( QFileDialog::Contents );
2354 fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
2355 //fd->setDir (lastImageDir);
2358 if ( fd->exec() == QDialog::Accepted )
2360 QString fn=fd->selectedFile();
2361 //lastImageDir=fn.left(fn.findRev ("/"));
2362 if (currentMapEditor())
2363 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2367 void Main::fileCloseMap()
2369 if (currentMapEditor())
2371 if (currentMapEditor()->hasChanged())
2373 QMessageBox mb( __VYM,
2374 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2375 QMessageBox::Warning,
2376 QMessageBox::Yes | QMessageBox::Default,
2378 QMessageBox::Cancel | QMessageBox::Escape );
2379 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2380 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2383 case QMessageBox::Yes:
2385 fileSave(CompleteMap);
2387 case QMessageBox::No:
2388 // close without saving
2390 case QMessageBox::Cancel:
2395 currentMapEditor()->closeMap();
2396 tabWidget->removePage(currentMapEditor());
2397 if (tabWidget->count()==0)
2398 actionFilePrint->setEnabled (false);
2402 void Main::filePrint()
2404 if (currentMapEditor())
2405 currentMapEditor()->print();
2408 void Main::fileExitVYM()
2410 // Check if one or more editors have changed
2413 for (i=0;i<=tabWidget->count() -1;i++)
2416 me=(MapEditor*)tabWidget->page(i);
2418 // If something changed, ask what to do
2419 if (me->isUnsaved())
2421 tabWidget->setCurrentPage(i);
2422 QMessageBox mb( __VYM,
2423 tr("This map is not saved yet. Do you want to"),
2424 QMessageBox::Warning,
2425 QMessageBox::Yes | QMessageBox::Default,
2427 QMessageBox::Cancel | QMessageBox::Escape );
2428 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2429 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2431 mb.setActiveWindow();
2432 switch( mb.exec() ) {
2433 case QMessageBox::Yes:
2434 // save (the changed editors) and exit
2435 fileSave(CompleteMap);
2437 case QMessageBox::No:
2438 // exit without saving
2440 case QMessageBox::Cancel:
2441 // don't save and don't exit
2445 } // loop over all MEs
2449 void Main::editUndo()
2451 if (currentMapEditor())
2452 currentMapEditor()->undo();
2455 void Main::editRedo()
2457 if (currentMapEditor())
2458 currentMapEditor()->redo();
2461 void Main::editCopy()
2463 if (currentMapEditor())
2464 currentMapEditor()->copy();
2467 void Main::editPaste()
2469 if (currentMapEditor())
2470 currentMapEditor()->paste();
2473 void Main::editCut()
2475 if (currentMapEditor())
2476 currentMapEditor()->cut();
2479 void Main::editOpenFindWindow()
2481 findWindow->popup();
2482 findWindow->raise();
2483 findWindow->setActiveWindow();
2486 void Main::editFind(QString s)
2489 BranchObj *bo=currentMapEditor()->findText(s, cs);
2492 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2495 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2496 tr("No matches found for \"%1\"").arg(s));
2500 void Main::editFindChanged()
2501 { // Notify editor, to abort the current find process
2502 currentMapEditor()->findReset();
2505 void Main::editOpenURL()
2508 if (currentMapEditor())
2510 QString url=currentMapEditor()->getURL();
2511 if (url=="") return;
2512 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2513 procBrowser = new Q3Process( this );
2515 procBrowser->addArgument( browser);
2516 procBrowser->addArgument( url);
2518 if ( !procBrowser->start() )
2520 // try to set path to browser
2521 QMessageBox::warning(0,
2523 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2524 tr("Please use Settings->")+tr("Set application to open an URL"));
2529 void Main::editOpenURLTab()
2531 if (currentMapEditor())
2533 QString url=currentMapEditor()->getURL();
2534 if (url=="") return;
2535 QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
2536 if (procBrowser && procBrowser->isRunning())
2538 if (browser.contains("konqueror"))
2540 // Try to open new tab in existing konqueror started previously by vym
2541 Q3Process *p=new Q3Process (this);
2542 p->addArgument ("dcop");
2543 p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
2544 p->addArgument ("konqueror-mainwindow#1");
2545 p->addArgument ("newTab");
2546 p->addArgument (url);
2548 // try to set browser
2549 QMessageBox::warning(0,
2551 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2553 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2555 // Try to open new tab in firefox
2556 Q3Process *p=new Q3Process (this);
2557 p->addArgument (browser);
2558 p->addArgument ("-remote");
2559 p->addArgument (QString("openurl(%1,new-tab)").arg(url));
2561 // try to set browser
2562 QMessageBox::warning(0,
2564 tr("Couldn't start %1 to open a new tab").arg(browser));
2573 void Main::editURL()
2575 if (currentMapEditor())
2576 currentMapEditor()->editURL();
2579 void Main::editHeading2URL()
2581 if (currentMapEditor())
2582 currentMapEditor()->editHeading2URL();
2585 void Main::editBugzilla2URL()
2587 if (currentMapEditor())
2588 currentMapEditor()->editBugzilla2URL();
2591 void Main::editFATE2URL()
2593 if (currentMapEditor())
2594 currentMapEditor()->editFATE2URL();
2597 void Main::editOpenVymLink()
2599 // Get current path to map
2600 QString currentVymLink;
2601 if (currentMapEditor())
2603 currentVymLink=currentMapEditor()->getVymLink();
2604 // compare path with already loaded maps
2608 for (i=0;i<=tabWidget->count() -1;i++)
2610 me=(MapEditor*)tabWidget->page(i);
2611 if (currentVymLink==me->getFilePath() )
2620 if (!QFile(currentVymLink).exists() )
2621 QMessageBox::critical( 0, tr( "Critical Error" ),
2622 tr("Couldn't open map %1").arg(currentVymLink));
2625 fileLoad (currentVymLink, NewMap);
2626 tabWidget->setCurrentPage (tabWidget->count()-1);
2629 // Go to tab containing the map
2630 tabWidget->setCurrentPage (index);
2634 void Main::editVymLink()
2636 if (currentMapEditor())
2637 currentMapEditor()->editVymLink();
2640 void Main::editDeleteVymLink()
2642 if (currentMapEditor())
2643 currentMapEditor()->deleteVymLink();
2646 void Main::editToggleHideExport()
2648 if (currentMapEditor())
2649 currentMapEditor()->toggleHideExport();
2652 void Main::editMapInfo()
2654 if (currentMapEditor())
2655 currentMapEditor()->editMapInfo();
2658 void Main::editMoveUp()
2660 if (currentMapEditor())
2661 currentMapEditor()->moveBranchUp();
2664 void Main::editMoveDown()
2666 if (currentMapEditor())
2667 currentMapEditor()->moveBranchDown();
2670 void Main::editToggleScroll()
2672 if (currentMapEditor())
2674 currentMapEditor()->toggleScroll();
2678 void Main::editUnScrollAll()
2680 if (currentMapEditor())
2682 currentMapEditor()->unScrollAll();
2686 void Main::editHeading()
2688 qWarning ("Main::editHeading called");
2689 if (currentMapEditor())
2690 currentMapEditor()->editHeading();
2693 void Main::editNewBranch()
2696 // tried to see if maybe currentMapEditor is not set, but
2697 // ME does not seem to send a key event anyway...:q
2698 //here i was last time...
2700 cout << "Main::editNewBranch\n";
2701 if (currentMapEditor())
2702 currentMapEditor()->addNewBranch(0);
2705 void Main::editNewBranchHere()
2707 if (currentMapEditor())
2708 currentMapEditor()->addNewBranchHere();
2711 void Main::editNewBranchAbove()
2713 if (currentMapEditor())
2714 currentMapEditor()->addNewBranch(-1);
2717 void Main::editNewBranchBelow()
2719 if (currentMapEditor())
2720 currentMapEditor()->addNewBranch(1);
2723 void Main::editImportAdd()
2725 fileLoad (ImportAdd);
2728 void Main::editImportReplace()
2730 fileLoad (ImportReplace);
2733 void Main::editSaveBranch()
2735 fileSaveAs (PartOfMap);
2738 void Main::editRemoveBranchKeepChilds()
2740 if (currentMapEditor())
2741 currentMapEditor()->removeBranchKeepChilds();
2744 void Main::editRemoveChilds()
2746 if (currentMapEditor())
2747 currentMapEditor()->removeChilds();
2750 void Main::editDeleteSelection()
2752 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2753 currentMapEditor()->deleteSelection();
2756 void Main::editUpperBranch()
2758 if (currentMapEditor())
2759 currentMapEditor()->selectUpperBranch();
2762 void Main::editLowerBranch()
2764 if (currentMapEditor())
2765 currentMapEditor()->selectLowerBranch();
2768 void Main::editLeftBranch()
2770 if (currentMapEditor())
2771 currentMapEditor()->selectLeftBranch();
2774 void Main::editRightBranch()
2776 if (currentMapEditor())
2777 currentMapEditor()->selectRightBranch();
2780 void Main::editFirstBranch()
2782 if (currentMapEditor())
2783 currentMapEditor()->selectFirstBranch();
2786 void Main::editLastBranch()
2788 if (currentMapEditor())
2789 currentMapEditor()->selectLastBranch();
2792 void Main::editLoadImage()
2794 if (currentMapEditor())
2795 currentMapEditor()->loadFloatImage();
2798 void Main::editSaveImage(int item)
2800 if (currentMapEditor())
2801 currentMapEditor()->saveFloatImage(item);
2804 void Main::editFollowXLink(int item)
2806 if (currentMapEditor())
2807 currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
2810 void Main::editEditXLink(int item)
2812 if (currentMapEditor())
2813 currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
2816 void Main::formatSelectColor()
2818 if (currentMapEditor())
2820 QColor col = QColorDialog::getColor( currentMapEditor()->color(), this );
2821 if ( !col.isValid() ) return;
2822 currentMapEditor()->setColor( col );
2823 colorChanged( col );
2827 void Main::formatPickColor()
2829 if (currentMapEditor())
2830 colorChanged( currentMapEditor()->pickColor() );
2833 void Main::colorChanged(QColor c)
2835 QPixmap pix( 16, 16 );
2837 actionFormatColor->setIconSet( pix );
2840 void Main::formatColorItem()
2842 if (currentMapEditor())
2843 currentMapEditor()->colorItem();
2846 void Main::formatColorBranch()
2848 if (currentMapEditor())
2849 currentMapEditor()->colorBranch();
2852 void Main::formatLinkStyleLine()
2854 if (currentMapEditor())
2855 currentMapEditor()->setLinkStyle(StyleLine);
2858 void Main::formatLinkStyleParabel()
2860 if (currentMapEditor())
2861 currentMapEditor()->setLinkStyle(StyleParabel);
2864 void Main::formatLinkStylePolyLine()
2866 if (currentMapEditor())
2867 currentMapEditor()->setLinkStyle(StylePolyLine);
2870 void Main::formatLinkStylePolyParabel()
2872 if (currentMapEditor())
2873 currentMapEditor()->setLinkStyle(StylePolyParabel);
2876 void Main::formatSelectBackColor()
2878 if (currentMapEditor())
2879 currentMapEditor()->selectBackgroundColor();
2882 void Main::formatSelectLinkColor()
2884 if (currentMapEditor())
2885 currentMapEditor()->selectLinkColor();
2888 void Main::formatToggleLinkColorHint()
2890 currentMapEditor()->toggleLinkColorHint();
2893 void Main::formatFrameNone()
2895 if (currentMapEditor())
2896 currentMapEditor()->setFrame(NoFrame);
2899 void Main::formatFrameRectangle()
2901 if (currentMapEditor())
2902 currentMapEditor()->setFrame(Rectangle);
2905 void Main::formatIncludeImagesVer()
2907 if (currentMapEditor())
2908 currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
2911 void Main::formatIncludeImagesHor()
2913 if (currentMapEditor())
2914 currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
2917 void Main::formatHideLinkUnselected()
2919 if (currentMapEditor())
2920 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
2923 void Main::viewZoomReset()
2925 if (currentMapEditor())
2929 currentMapEditor()->setWorldMatrix( m );
2930 currentMapEditor()->setViewCenter();
2931 currentMapEditor()->adjustCanvasSize();
2935 void Main::viewZoomIn()
2937 if (currentMapEditor())
2939 QMatrix m = currentMapEditor()->worldMatrix();
2940 m.scale( 1.25, 1.25 );
2941 currentMapEditor()->setWorldMatrix( m );
2942 currentMapEditor()->setViewCenter();
2943 currentMapEditor()->adjustCanvasSize();
2947 void Main::viewZoomOut()
2949 if (currentMapEditor())
2951 QMatrix m = currentMapEditor()->worldMatrix();
2952 m.scale( 0.8, 0.8 );
2953 currentMapEditor()->setWorldMatrix( m );
2954 currentMapEditor()->setViewCenter();
2955 currentMapEditor()->adjustCanvasSize();
2959 void Main::modModeColor()
2963 void Main::modModeLink()
2967 bool Main::settingsPDF()
2969 // Default browser is set in constructor
2971 QString text = QInputDialog::getText(
2972 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
2973 settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
2975 settings.writeEntry ("/vym/mainwindow/readerPDF",text);
2980 bool Main::settingsURL()
2982 // Default browser is set in constructor
2984 QString text = QInputDialog::getText(
2985 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
2986 settings.readEntry("/vym/mainwindow/readerURL")
2989 settings.writeEntry ("/vym/mainwindow/readerURL",text);
2993 void Main::settingsToggleDelKey()
2995 if (actionSettingsUseDelKey->isOn())
2997 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3000 actionEditDelete->setAccel (QKeySequence (""));
3004 void Main::windowToggleNoteEditor()
3006 if (textEditor->showWithMain() )
3007 windowHideNoteEditor();
3009 windowShowNoteEditor();
3012 void Main::windowToggleHistory()
3014 if (currentMapEditor())
3015 currentMapEditor()->toggleHistoryWindow();
3018 void Main::updateNoteFlag()
3020 if (currentMapEditor())
3021 currentMapEditor()->updateNoteFlag();
3024 void Main::windowShowNoteEditor()
3026 textEditor->setShowWithMain(true);
3028 actionViewToggleNoteEditor->setOn (true);
3031 void Main::windowHideNoteEditor()
3033 textEditor->setShowWithMain(false);
3035 actionViewToggleNoteEditor->setOn (false);
3038 void Main::windowNextEditor()
3040 if (tabWidget->currentPageIndex() < tabWidget->count())
3041 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3044 void Main::windowPreviousEditor()
3046 if (tabWidget->currentPageIndex() >0)
3047 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3050 void Main::standardFlagChanged()
3052 currentMapEditor()->toggleStandardFlag(sender()->name());
3055 void Main::testFunction()
3057 currentMapEditor()->testFunction();
3060 void Main::helpDoc()
3063 #if defined(Q_OS_MACX)
3064 docpath="./vym.app/Contents/vym.pdf";
3066 // default path in SUSE LINUX
3067 docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
3070 if (!QFile (docpath).exists() )
3072 // relative path for easy testing in tarball
3073 docpath="doc/vym.pdf";
3074 if (!QFile (docpath).exists() )
3076 // relative path for testing while still writing vym.tex
3077 docpath="doc/tex/vym.pdf";
3078 if (!QFile (docpath).exists() )
3080 // Try yet another one for Knoppix
3081 docpath="/usr/share/doc/packages/vym/vym.pdf";
3082 if (!QFile (docpath).exists() )
3084 QMessageBox::critical(0,
3085 tr("Critcal error"),
3086 tr("Couldn't find the documentation\n"
3087 "vym.pdf in various places."));
3094 Process *pdfProc = new Process();
3095 pdfProc->clearArguments();
3096 pdfProc->addArgument( settings.readEntry("/vym/mainwindow/readerPDF"));
3097 pdfProc->addArgument( docpath);
3099 if ( !pdfProc->start() )
3102 QMessageBox::warning(0,
3104 tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
3105 tr("Please use Settings->")+tr("Set application to open PDF files"));
3112 void Main::helpAbout()
3115 ad.setName ("aboutwindow");
3116 ad.setMinimumSize(500,500);
3117 ad.resize (QSize (500,500));
3121 void Main::helpAboutQT()
3123 QMessageBox::aboutQt( this, "Qt Application Example" );