1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "branchpropwindow.h"
9 #include "exportoofiledialog.h"
12 #include "flagrowobj.h"
13 #include "historywindow.h"
15 #include "mapeditor.h"
20 #include "texteditor.h"
21 #include "warningdialog.h"
23 extern TextEditor *textEditor;
24 extern Main *mainWindow;
25 extern QString tmpVymDir;
26 extern QString clipboardDir;
27 extern QString clipboardFile;
28 extern bool clipboardEmpty;
29 extern int statusbarTime;
30 extern FlagRowObj* standardFlagsDefault;
31 extern FlagRowObj* systemFlagsDefault;
32 extern QString vymName;
33 extern QString vymVersion;
34 extern QString vymBuildDate;
37 QMenu* branchContextMenu;
38 QMenu* branchAddContextMenu;
39 QMenu* branchRemoveContextMenu;
40 QMenu* branchLinksContextMenu;
41 QMenu* branchXLinksContextMenuEdit;
42 QMenu* branchXLinksContextMenuFollow;
43 QMenu* floatimageContextMenu;
44 QMenu* canvasContextMenu;
45 QMenu* fileLastMapsMenu;
46 QMenu* fileImportMenu;
47 QMenu* fileExportMenu;
50 extern Settings settings;
51 extern Options options;
52 extern ImageIO imageIO;
54 extern QDir vymBaseDir;
55 extern QDir lastImageDir;
56 extern QDir lastFileDir;
57 extern QString iconPath;
58 extern QString flagsPath;
60 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
61 QMainWindow(parent,name,f)
65 setCaption ("VYM - View Your Mind");
67 // Load window settings
68 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
69 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
72 // Sometimes we may need to remember old selections
76 currentColor=Qt::black;
78 // Create unique temporary directory
80 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
83 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
86 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
88 // Create direcctory for clipboard
89 clipboardDir=tmpVymDir+"/clipboard";
90 clipboardFile="map.xml";
92 d.mkdir (clipboardDir,true);
93 makeSubDirs (clipboardDir);
98 // Satellite windows //////////////////////////////////////////
101 historyWindow=new HistoryWindow();
102 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
105 branchPropertyWindow = new BranchPropertyWindow();
106 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
108 // Connect TextEditor, so that we can update flags if text changes
109 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
110 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
112 // Connect HistoryWindow, so that we can update flags
113 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
116 // Initialize script editor
117 scriptEditor = new SimpleScriptEditor();
118 scriptEditor->move (50,50);
120 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
121 this, SLOT( runScript( QString ) ) );
124 // Initialize Find window
125 findWindow=new FindWindow(NULL);
126 findWindow->move (x(),y()+70);
127 connect (findWindow, SIGNAL( findButton(QString) ),
128 this, SLOT(editFind(QString) ) );
129 connect (findWindow, SIGNAL( somethingChanged() ),
130 this, SLOT(editFindChanged() ) );
132 // Initialize some settings, which are platform dependant
135 // application to open URLs
136 p="/mainwindow/readerURL";
137 #if defined(Q_OS_LINUX)
138 s=settings.value (p,"konqueror").toString();
140 #if defined(Q_OS_MACX)
141 s=settings.value (p,"/usr/bin/open").toString();
143 s=settings.value (p,"mozilla");
146 settings.setValue( p,s);
148 // application to open PDFs
149 p="/mainwindow/readerPDF";
150 #if defined(Q_OS_LINUX)
151 s=settings.value (p,"acroread").toString();
153 #if defined(Q_OS_MACX)
154 s=settings.value (p,"/usr/bin/open").toString();
156 s=settings.value (p,"acroread").toString();
159 settings.setValue( p,s);
162 // Create tab widget which holds the maps
163 tabWidget= new QTabWidget (this);
164 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
165 this, SLOT( editorChanged( QWidget * ) ) );
167 lineedit=new QLineEdit (this);
170 setCentralWidget(tabWidget);
174 setupFormatActions();
178 setupSettingsActions();
181 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
186 restoreState (settings.value("/mainwindow/state",0).toByteArray());
194 settings.setValue ( "/mainwindow/geometry/size", size() );
195 settings.setValue ( "/mainwindow/geometry/pos", pos() );
196 settings.setValue ("/mainwindow/state",saveState(0));
198 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
199 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
200 settings.setValue( "/version/version", vymVersion );
201 settings.setValue( "/version/builddate", vymBuildDate );
203 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
204 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
205 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
206 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
207 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
208 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
209 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
211 //TODO save scriptEditor settings
213 // call the destructors
215 delete historyWindow;
216 delete branchPropertyWindow;
218 // Remove temporary directory
219 removeDir (QDir(tmpVymDir));
222 void Main::loadCmdLine()
224 /* TODO draw some kind of splashscreen while loading...
230 QStringList flist=options.getFileList();
231 QStringList::Iterator it=flist.begin();
233 while (it !=flist.end() )
235 fileLoad (*it, NewMap);
241 void Main::statusMessage(const QString &s)
243 statusBar()->message( s);
246 void Main::closeEvent (QCloseEvent* )
252 void Main::setupFileActions()
254 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
255 QToolBar *tb = addToolBar( tr ("&Map") );
256 tb->setObjectName ("mapTB");
259 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
260 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
261 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
263 fileMenu->addAction (a);
264 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
266 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
267 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
268 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
269 fileMenu->addAction (a);
270 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
272 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
273 a->setStatusTip (tr( "Open","Status tip File menu" ) );
274 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
276 fileMenu->addAction (a);
277 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
279 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
280 fileMenu->addSeparator();
282 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
283 a->setStatusTip ( tr( "Save","Status tip file menu" ));
284 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
286 fileMenu->addAction (a);
287 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
290 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
291 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
292 fileMenu->addAction (a);
293 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
295 fileMenu->addSeparator();
297 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
299 a = new QAction(tr("KDE Bookmarks"), this);
300 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
301 a->addTo (fileImportMenu);
302 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
304 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
306 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
307 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
308 a->addTo (fileImportMenu);
309 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
312 a = new QAction("Mind Manager...",this);
313 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
314 fileImportMenu->addAction (a);
315 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
317 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
318 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
319 fileImportMenu->addAction (a);
320 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
322 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
324 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
325 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
326 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
327 fileExportMenu->addAction (a);
329 a = new QAction( "Open Office...", this);
330 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
331 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
332 fileExportMenu->addAction (a);
334 a = new QAction( "Webpage (XHTML)...",this );
335 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
336 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
338 fileExportMenu->addAction (a);
340 a = new QAction( "Text (ASCII)...", this);
341 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
343 fileExportMenu->addAction (a);
345 a = new QAction( "Spreadsheet (CSV)...", this);
346 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
347 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
348 fileExportMenu->addAction (a);
350 a = new QAction( tr("KDE Bookmarks","File menu"), this);
351 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
352 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
353 fileExportMenu->addAction (a);
355 a = new QAction( "Taskjuggler...", this );
356 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
358 fileExportMenu->addAction (a);
360 a = new QAction( "LaTeX...", this);
361 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
362 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
363 fileExportMenu->addAction (a);
365 a = new QAction( "XML..." , this );
366 a->setStatusTip (tr( "Export as %1").arg("XML"));
367 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
368 fileExportMenu->addAction (a);
370 fileMenu->addSeparator();
372 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
373 a->setStatusTip ( tr( "Print" ,"File menu") );
374 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
376 fileMenu->addAction (a);
377 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
380 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
381 a->setStatusTip (tr( "Close Map" ) );
382 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
383 fileMenu->addAction (a);
384 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
386 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
387 a->setStatusTip ( tr( "Exit")+" "+vymName );
388 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
389 fileMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
395 void Main::setupEditActions()
397 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
398 tb->setLabel( "Edit Actions" );
399 tb->setObjectName ("actionsTB");
400 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
404 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
405 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
406 a->setStatusTip (tr( "Undo" ) );
407 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
408 a->setEnabled (false);
410 editMenu->addAction (a);
413 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
414 a->setStatusTip (tr( "Redo" ));
415 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
417 editMenu->addAction (a);
418 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
421 editMenu->addSeparator();
422 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
423 a->setStatusTip ( tr( "Copy" ) );
424 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
425 a->setEnabled (false);
427 editMenu->addAction (a);
428 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
431 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
432 a->setStatusTip ( tr( "Cut" ) );
433 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
434 a->setEnabled (false);
436 editMenu->addAction (a);
438 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
440 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
441 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
442 a->setStatusTip ( tr( "Paste" ) );
443 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
444 a->setEnabled (false);
446 editMenu->addAction (a);
449 // Shortcuts to modify heading:
450 a = new QAction(tr( "Edit heading","Edit menu" ),this);
451 a->setStatusTip ( tr( "edit Heading" ));
452 a->setShortcut ( Qt::Key_Enter); //Edit heading
453 // a->setShortcutContext (Qt::WindowShortcut);
455 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
456 actionListBranches.append(a);
457 a = new QAction( tr( "Edit heading","Edit menu" ), this);
458 a->setStatusTip (tr( "edit Heading" ));
459 a->setShortcut (Qt::Key_Return ); //Edit heading
460 //a->setShortcutContext (Qt::WindowShortcut);
462 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
463 actionListBranches.append(a);
464 editMenu->addAction (a);
466 a = new QAction( tr( "Edit heading","Edit menu" ), this);
467 a->setStatusTip (tr( "edit Heading" ));
468 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
469 a->setShortcutContext (Qt::WindowShortcut);
471 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
472 actionListBranches.append(a);
474 // Shortcut to delete selection
475 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
476 a->setStatusTip (tr( "Delete Selection" ));
477 a->setShortcut ( Qt::Key_Delete); //Delete selection
478 a->setShortcutContext (Qt::WindowShortcut);
480 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
483 // Shortcut to add branch
484 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
485 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
486 alt->setShortcut (Qt::Key_A); //Add branch
487 alt->setShortcutContext (Qt::WindowShortcut);
489 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
490 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
491 a->setStatusTip ( tr( "Add a branch as child of selection" ));
492 a->setShortcut (Qt::Key_Insert); //Add branch
493 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
494 actionListBranches.append(a);
495 #if defined (Q_OS_MACX)
496 // In OSX show different shortcut in menues, the keys work indepently always
497 actionEditAddBranch=alt;
499 actionEditAddBranch=a;
501 editMenu->addAction (actionEditAddBranch);
502 tb->addAction (actionEditAddBranch);
505 // Add branch by inserting it at selection
506 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
507 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
508 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
509 a->setShortcutContext (Qt::WindowShortcut);
511 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
512 a->setEnabled (false);
513 actionListBranches.append(a);
514 actionEditAddBranchBefore=a;
515 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
516 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
517 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
518 a->setShortcutContext (Qt::WindowShortcut);
520 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
521 actionListBranches.append(a);
524 a = new QAction(tr( "Add branch above","Edit menu" ), this);
525 a->setStatusTip ( tr( "Add a branch above selection" ));
526 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
527 a->setShortcutContext (Qt::WindowShortcut);
529 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
530 a->setEnabled (false);
531 actionListBranches.append(a);
532 actionEditAddBranchAbove=a;
533 a = new QAction(tr( "Add branch above","Edit menu" ), this);
534 a->setStatusTip ( tr( "Add a branch above selection" ));
535 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
536 a->setShortcutContext (Qt::WindowShortcut);
538 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
539 actionListBranches.append(a);
542 a = new QAction(tr( "Add branch below","Edit menu" ), this);
543 a->setStatusTip ( tr( "Add a branch below selection" ));
544 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
545 a->setShortcutContext (Qt::WindowShortcut);
547 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
548 a->setEnabled (false);
549 actionListBranches.append(a);
550 actionEditAddBranchBelow=a;
551 a = new QAction(tr( "Add branch below","Edit menu" ), this);
552 a->setStatusTip ( tr( "Add a branch below selection" ));
553 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
554 a->setShortcutContext (Qt::WindowShortcut);
556 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
557 actionListBranches.append(a);
559 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
560 a->setStatusTip ( tr( "Move branch up" ) );
561 a->setShortcut (Qt::Key_PageUp ); // Move branch up
562 a->setEnabled (false);
564 editMenu->addAction (a);
565 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
568 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
569 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
570 a->setStatusTip (tr( "Move branch down" ) );
571 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
572 a->setEnabled (false);
574 editMenu->addAction (a);
575 actionEditMoveDown=a;
578 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
579 a->setShortcut ( Qt::Key_ScrollLock );
580 a->setStatusTip (tr( "Scroll branch" ) );
581 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
583 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
584 alt->setShortcut ( Qt::Key_S ); // Scroll branch
585 alt->setStatusTip (tr( "Scroll branch" ));
586 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
587 #if defined(Q_OS_MACX)
588 actionEditToggleScroll=alt;
590 actionEditToggleScroll=a;
592 actionEditToggleScroll->setEnabled (false);
593 actionEditToggleScroll->setToggleAction(true);
594 tb->addAction (actionEditToggleScroll);
595 editMenu->addAction ( actionEditToggleScroll);
596 editMenu->addAction (actionEditToggleScroll);
599 actionListBranches.append(actionEditToggleScroll);
601 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
602 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
603 editMenu->addAction (a);
604 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
606 editMenu->addSeparator();
608 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
609 a->setStatusTip (tr( "Find" ) );
610 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
611 editMenu->addAction (a);
612 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
614 editMenu->addSeparator();
616 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
617 a->setShortcut (Qt::CTRL + Qt::Key_U );
618 a->setShortcut (tr( "Open URL" ));
621 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
624 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
625 a->setStatusTip (tr( "Open URL in new tab" ));
626 a->setShortcut (Qt::CTRL+Qt::Key_U );
628 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
629 actionEditOpenURLTab=a;
631 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
632 a->setStatusTip (tr( "Open all URLs in subtree" ));
634 actionListBranches.append(a);
635 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
636 actionEditOpenMultipleURLTabs=a;
638 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
639 a->setStatusTip ( tr( "Edit URL" ) );
640 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
641 //a->setShortcut ( Qt::Key_U );
642 a->setShortcutContext (Qt::WindowShortcut);
643 actionListBranches.append(a);
645 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
648 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
649 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
650 a->setEnabled (false);
651 actionListBranches.append(a);
652 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
653 actionEditHeading2URL=a;
655 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
656 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
657 a->setEnabled (false);
658 actionListBranches.append(a);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
660 actionEditBugzilla2URL=a;
662 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
663 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
664 a->setEnabled (false);
665 actionListBranches.append(a);
666 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
667 actionEditFATE2URL=a;
669 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
670 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
672 a->setEnabled (false);
673 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
674 actionEditOpenVymLink=a;
676 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
677 a->setStatusTip ( tr( "Open all vym links in subtree" ));
678 a->setEnabled (false);
679 actionListBranches.append(a);
680 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
681 actionEditOpenMultipleVymLinks=a;
684 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
685 a->setEnabled (false);
686 a->setStatusTip ( tr( "Edit link to another vym map" ));
687 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
688 actionListBranches.append(a);
691 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
692 a->setStatusTip ( tr( "Delete link to another vym map" ));
693 a->setEnabled (false);
694 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
695 actionEditDeleteVymLink=a;
697 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
698 a->setStatusTip ( tr( "Hide object in exports" ) );
699 a->setShortcut (Qt::Key_H );
700 a->setToggleAction(true);
702 a->setEnabled (false);
703 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
704 actionEditToggleHideExport=a;
706 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
707 a->setStatusTip ( tr( "Edit Map Info" ));
708 a->setEnabled (true);
709 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
712 // Import at selection (adding to selection)
713 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
714 a->setStatusTip (tr( "Add map at selection" ));
715 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
716 a->setEnabled (false);
717 actionListBranches.append(a);
718 actionEditImportAdd=a;
720 // Import at selection (replacing selection)
721 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
722 a->setStatusTip (tr( "Replace selection with map" ));
723 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
724 a->setEnabled (false);
725 actionListBranches.append(a);
726 actionEditImportReplace=a;
729 a = new QAction( tr( "Save selection","Edit menu" ), this);
730 a->setStatusTip (tr( "Save selection" ));
731 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
732 a->setEnabled (false);
733 actionListBranches.append(a);
734 actionEditSaveBranch=a;
736 // Only remove branch, not its childs
737 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
738 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
739 a->setShortcut (Qt::ALT + Qt::Key_Delete );
740 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
741 a->setEnabled (false);
743 actionListBranches.append(a);
744 actionEditDeleteKeepChilds=a;
746 // Only remove childs of a branch
747 a = new QAction( tr( "Remove childs","Edit menu" ), this);
748 a->setStatusTip (tr( "Remove childs of branch" ));
749 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
750 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
751 a->setEnabled (false);
752 actionListBranches.append(a);
753 actionEditDeleteChilds=a;
755 // Shortcuts for navigating with cursor:
756 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
757 a->setStatusTip ( tr( "Select upper branch" ));
758 a->setShortcut (Qt::Key_Up );
759 a->setShortcutContext (Qt::WindowShortcut);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
762 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
763 a->setStatusTip (tr( "Select lower branch" ));
764 a->setShortcut ( Qt::Key_Down );
765 a->setShortcutContext (Qt::WindowShortcut);
767 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
768 a = new QAction(tr( "Select left branch","Edit menu" ), this);
769 a->setStatusTip ( tr( "Select left branch" ));
770 a->setShortcut (Qt::Key_Left );
771 a->setShortcutContext (Qt::WindowShortcut);
773 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
774 a = new QAction( tr( "Select child branch","Edit menu" ), this);
775 a->setStatusTip (tr( "Select right branch" ));
776 a->setShortcut (Qt::Key_Right);
777 a->setShortcutContext (Qt::WindowShortcut);
779 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
780 a = new QAction( tr( "Select first branch","Edit menu" ), this);
781 a->setStatusTip (tr( "Select first branch" ));
782 a->setShortcut (Qt::Key_Home );
783 a->setShortcutContext (Qt::WindowShortcut);
785 a->setEnabled (false);
786 editMenu->addAction (a);
787 actionListBranches.append(a);
788 actionEditSelectFirst=a;
789 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
790 a = new QAction( tr( "Select last branch","Edit menu" ),this);
791 a->setStatusTip (tr( "Select last branch" ));
792 a->setShortcut ( Qt::Key_End );
793 a->setShortcutContext (Qt::WindowShortcut);
795 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
796 a->setEnabled (false);
797 editMenu->addAction (a);
798 actionListBranches.append(a);
799 actionEditSelectLast=a;
801 a = new QAction( tr( "Add Image...","Edit menu" ), this);
802 a->setStatusTip (tr( "Add Image" ));
803 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
804 actionEditLoadImage=a;
806 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
807 a->setStatusTip (tr( "Set properties for selection" ));
808 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
809 a->setShortcutContext (Qt::WindowShortcut);
810 a->setToggleAction (true);
812 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
813 actionViewTogglePropertyWindow=a;
817 void Main::setupFormatActions()
819 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
821 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
822 tb->setObjectName ("formatTB");
825 pix.fill (Qt::black);
826 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
827 a->setStatusTip ( tr( "Set Color" ));
828 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
830 formatMenu->addAction (a);
832 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
833 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
834 a->setShortcut (Qt::CTRL + Qt::Key_K );
835 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
836 a->setEnabled (false);
838 formatMenu->addAction (a);
839 actionListBranches.append(a);
840 actionFormatPickColor=a;
842 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
843 a->setStatusTip ( tr( "Color branch" ) );
844 a->setShortcut (Qt::CTRL + Qt::Key_B);
845 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
846 a->setEnabled (false);
848 formatMenu->addAction (a);
849 actionListBranches.append(a);
850 actionFormatColorSubtree=a;
852 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
853 a->setStatusTip ( tr( "Color Subtree" ));
854 a->setShortcut (Qt::CTRL + Qt::Key_T);
855 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
856 a->setEnabled (false);
857 formatMenu->addAction (a);
859 actionListBranches.append(a);
860 actionFormatColorSubtree=a;
862 formatMenu->addSeparator();
863 actionGroupFormatLinkStyles=new QActionGroup ( this);
864 actionGroupFormatLinkStyles->setExclusive (true);
865 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
866 a->setStatusTip (tr( "Line" ));
867 a->setToggleAction(true);
868 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
869 formatMenu->addAction (a);
870 actionFormatLinkStyleLine=a;
871 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
872 a->setStatusTip (tr( "Line" ));
873 a->setToggleAction(true);
874 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
875 formatMenu->addAction (a);
876 actionFormatLinkStyleParabel=a;
877 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
878 a->setStatusTip (tr( "PolyLine" ));
879 a->setToggleAction(true);
880 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
881 formatMenu->addAction (a);
882 actionFormatLinkStylePolyLine=a;
883 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
884 a->setStatusTip (tr( "PolyParabel" ) );
885 a->setToggleAction(true);
886 a->setChecked (true);
887 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
888 formatMenu->addAction (a);
889 actionFormatLinkStylePolyParabel=a;
891 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
892 a->setStatusTip (tr( "Hide link" ));
893 a->setToggleAction(true);
894 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
895 actionFormatHideLinkUnselected=a;
897 formatMenu->addSeparator();
898 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
899 a->setStatusTip (tr( "Use same color for links and headings" ));
900 a->setToggleAction(true);
901 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
902 formatMenu->addAction (a);
903 actionFormatLinkColorHint=a;
905 pix.fill (Qt::white);
906 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
907 a->setStatusTip (tr( "Set Link Color" ));
908 formatMenu->addAction (a);
909 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
910 actionFormatLinkColor=a;
912 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
913 a->setStatusTip (tr( "Set Selection Color" ));
914 formatMenu->addAction (a);
915 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
916 actionFormatSelectionColor=a;
918 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
919 a->setStatusTip (tr( "Set Background Color" ));
920 formatMenu->addAction (a);
921 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
922 actionFormatBackColor=a;
924 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
925 a->setStatusTip (tr( "Set Background image" ));
926 formatMenu->addAction (a);
927 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
928 actionFormatBackImage=a;
932 void Main::setupViewActions()
934 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
935 tb->setLabel( "View Actions" );
936 tb->setObjectName ("viewTB");
937 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
940 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
941 a->setStatusTip ( tr( "Zoom reset" ) );
942 a->setShortcut (Qt::CTRL + Qt::Key_0 );
944 viewMenu->addAction (a);
945 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
947 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
948 a->setStatusTip (tr( "Zoom in" ));
949 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
951 viewMenu->addAction (a);
952 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
954 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
955 a->setStatusTip (tr( "Zoom out" ));
956 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
958 viewMenu->addAction (a);
959 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
961 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
962 a->setStatusTip (tr( "Show selection" ));
963 a->setShortcut (Qt::Key_Period);
965 viewMenu->addAction (a);
966 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
968 viewMenu->addSeparator();
970 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
971 a->setStatusTip ( tr( "Show Note Editor" ));
972 a->setShortcut ( Qt::CTRL + Qt::Key_E );
973 a->setToggleAction(true);
975 viewMenu->addAction (a);
976 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
977 actionViewToggleNoteEditor=a;
979 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
980 a->setStatusTip ( tr( "Show History Window" ));
981 a->setShortcut ( Qt::CTRL + Qt::Key_H );
982 a->setToggleAction(true);
984 viewMenu->addAction (a);
985 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
986 actionViewToggleHistoryWindow=a;
988 viewMenu->addAction (actionViewTogglePropertyWindow);
990 viewMenu->addSeparator();
992 a = new QAction(tr( "Antialiasing","View action" ),this );
993 a->setStatusTip ( tr( "Antialiasing" ));
994 a->setToggleAction(true);
995 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
996 viewMenu->addAction (a);
997 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
998 actionViewToggleAntiAlias=a;
1000 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1001 a->setStatusTip (a->text());
1002 a->setToggleAction(true);
1003 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1004 viewMenu->addAction (a);
1005 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1006 actionViewToggleSmoothPixmapTransform=a;
1008 a = new QAction(tr( "Next Map","View action" ), this);
1009 a->setStatusTip (a->text());
1010 a->setShortcut (Qt::ALT + Qt::Key_N );
1011 viewMenu->addAction (a);
1012 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1014 a = new QAction (tr( "Previous Map","View action" ), this );
1015 a->setStatusTip (a->text());
1016 a->setShortcut (Qt::ALT + Qt::Key_P );
1017 viewMenu->addAction (a);
1018 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1022 void Main::setupModeActions()
1024 //QPopupMenu *menu = new QPopupMenu( this );
1025 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1027 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1028 tb->setObjectName ("modesTB");
1030 actionGroupModModes=new QActionGroup ( this);
1031 actionGroupModModes->setExclusive (true);
1032 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1033 a->setShortcut (Qt::Key_J);
1034 a->setStatusTip ( tr( "Use modifier to color branches" ));
1035 a->setToggleAction(true);
1038 actionModModeColor=a;
1040 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1041 a->setShortcut( Qt::Key_K);
1042 a->setStatusTip( tr( "Use modifier to copy" ));
1043 a->setToggleAction(true);
1045 actionModModeCopy=a;
1047 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1048 a->setShortcut (Qt::Key_L);
1049 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1050 a->setToggleAction(true);
1052 actionModModeXLink=a;
1056 void Main::setupFlagActions()
1058 // Create System Flags
1059 systemFlagsDefault = new FlagRowObj ();
1060 systemFlagsDefault->setVisibility (false);
1061 systemFlagsDefault->setName ("systemFlagsDef");
1063 FlagObj *fo = new FlagObj ();
1064 fo->load(QPixmap(flagsPath+"flag-note.png"));
1065 fo->setName("note");
1066 fo->setToolTip(tr("Note","Systemflag"));
1067 systemFlagsDefault->addFlag (fo); // makes deep copy
1069 fo->load(QPixmap(flagsPath+"flag-url.png"));
1071 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1072 systemFlagsDefault->addFlag (fo);
1074 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1075 fo->setName("vymLink");
1076 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1077 systemFlagsDefault->addFlag (fo);
1079 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1080 fo->setName("scrolledright");
1081 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1082 systemFlagsDefault->addFlag (fo);
1084 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1085 fo->setName("tmpUnscrolledright");
1086 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1087 systemFlagsDefault->addFlag (fo);
1089 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1090 fo->setName("hideInExport");
1091 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1092 systemFlagsDefault->addFlag (fo);
1094 // Create Standard Flags
1095 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1096 tb->setObjectName ("standardFlagTB");
1098 standardFlagsDefault = new FlagRowObj ();
1099 standardFlagsDefault->setVisibility (false);
1100 standardFlagsDefault->setName ("standardFlagsDef");
1101 standardFlagsDefault->setToolBar (tb);
1103 fo->load(flagsPath+"flag-exclamationmark.png");
1104 fo->setName ("exclamationmark");
1105 fo->setGroup("standard-mark");
1106 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1109 a->setCheckable(true);
1110 a->setObjectName(fo->getName());
1111 a->setToolTip(tr("Take care!","Standardflag"));
1112 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1113 standardFlagsDefault->addFlag (fo); // makes deep copy
1115 fo->load(flagsPath+"flag-questionmark.png");
1116 fo->setName("questionmark");
1117 fo->setGroup("standard-mark");
1118 a=new QAction (fo->getPixmap(),fo->getName(),this);
1121 a->setCheckable(true);
1122 a->setObjectName(fo->getName());
1123 a->setToolTip(tr("Really?","Standardflag"));
1124 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1125 standardFlagsDefault->addFlag (fo);
1127 fo->load(flagsPath+"flag-hook-green.png");
1128 fo->setName("hook-green");
1129 fo->setGroup("standard-hook");
1130 a=new QAction (fo->getPixmap(),fo->getName(),this);
1133 a->setCheckable(true);
1134 a->setObjectName(fo->getName());
1135 a->setToolTip(tr("ok!","Standardflag"));
1136 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1137 standardFlagsDefault->addFlag (fo);
1139 fo->load(flagsPath+"flag-cross-red.png");
1140 fo->setName("cross-red");
1141 fo->setGroup("standard-hook");
1142 a=new QAction (fo->getPixmap(),fo->getName(),this);
1145 a->setCheckable(true);
1146 a->setObjectName(fo->getName());
1147 a->setToolTip(tr("Not ok!","Standardflag"));
1148 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1149 standardFlagsDefault->addFlag (fo);
1151 fo->load(flagsPath+"flag-stopsign.png");
1152 fo->setName("stopsign");
1153 a=new QAction (fo->getPixmap(),fo->getName(),this);
1156 a->setCheckable(true);
1157 a->setObjectName(fo->getName());
1158 a->setToolTip(tr("This won't work!","Standardflag"));
1159 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1160 standardFlagsDefault->addFlag (fo);
1162 fo->load(flagsPath+"flag-smiley-good.png");
1163 fo->setName("smiley-good");
1164 fo->setGroup("standard-smiley");
1165 a=new QAction (fo->getPixmap(),fo->getName(),this);
1168 a->setCheckable(true);
1169 a->setObjectName(fo->getName());
1170 a->setToolTip(tr("Good","Standardflag"));
1171 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1172 standardFlagsDefault->addFlag (fo);
1174 fo->load(flagsPath+"flag-smiley-sad.png");
1175 fo->setName("smiley-sad");
1176 fo->setGroup("standard-smiley");
1177 a=new QAction (fo->getPixmap(),fo->getName(),this);
1180 a->setCheckable(true);
1181 a->setObjectName(fo->getName());
1182 a->setToolTip(tr("Bad","Standardflag"));
1183 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1184 standardFlagsDefault->addFlag (fo);
1186 fo->load(flagsPath+"flag-smiley-omg.png");
1187 // Original omg.png (in KDE emoticons)
1188 fo->setName("smiley-omg");
1189 fo->setGroup("standard-smiley");
1190 a=new QAction (fo->getPixmap(),fo->getName(),this);
1193 a->setCheckable(true);
1194 a->setObjectName(fo->getName());
1195 a->setToolTip(tr("Oh no!","Standardflag"));
1196 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1197 standardFlagsDefault->addFlag (fo);
1199 fo->load(flagsPath+"flag-kalarm.png");
1200 fo->setName("clock");
1201 a=new QAction (fo->getPixmap(),fo->getName(),this);
1204 a->setCheckable(true);
1205 a->setObjectName(fo->getName());
1206 a->setToolTip(tr("Time critical","Standardflag"));
1207 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1208 standardFlagsDefault->addFlag (fo);
1210 fo->load(flagsPath+"flag-phone.png");
1211 fo->setName("phone");
1212 a=new QAction (fo->getPixmap(),fo->getName(),this);
1215 a->setCheckable(true);
1216 a->setObjectName(fo->getName());
1217 a->setToolTip(tr("Call...","Standardflag"));
1218 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1219 standardFlagsDefault->addFlag (fo);
1221 fo->load(flagsPath+"flag-lamp.png");
1222 fo->setName("lamp");
1223 a=new QAction (fo->getPixmap(),fo->getName(),this);
1226 a->setCheckable(true);
1227 a->setObjectName(fo->getName());
1228 a->setToolTip(tr("Idea!","Standardflag"));
1229 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1230 standardFlagsDefault->addFlag (fo);
1232 fo->load(flagsPath+"flag-arrow-up.png");
1233 fo->setName("arrow-up");
1234 fo->setGroup("standard-arrow");
1235 a=new QAction (fo->getPixmap(),fo->getName(),this);
1238 a->setCheckable(true);
1239 a->setObjectName(fo->getName());
1240 a->setToolTip(tr("Important","Standardflag"));
1241 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1242 standardFlagsDefault->addFlag (fo);
1244 fo->load(flagsPath+"flag-arrow-down.png");
1245 fo->setName("arrow-down");
1246 fo->setGroup("standard-arrow");
1247 a=new QAction (fo->getPixmap(),fo->getName(),this);
1250 a->setCheckable(true);
1251 a->setObjectName(fo->getName());
1252 a->setToolTip(tr("Unimportant","Standardflag"));
1253 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1254 standardFlagsDefault->addFlag (fo);
1256 fo->load(flagsPath+"flag-arrow-2up.png");
1257 fo->setName("2arrow-up");
1258 fo->setGroup("standard-arrow");
1259 a=new QAction (fo->getPixmap(),fo->getName(),this);
1262 a->setCheckable(true);
1263 a->setObjectName(fo->getName());
1264 a->setToolTip(tr("Very important!","Standardflag"));
1265 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1266 standardFlagsDefault->addFlag (fo);
1268 fo->load(flagsPath+"flag-arrow-2down.png");
1269 fo->setName("2arrow-down");
1270 fo->setGroup("standard-arrow");
1271 a=new QAction (fo->getPixmap(),fo->getName(),this);
1274 a->setCheckable(true);
1275 a->setObjectName(fo->getName());
1276 a->setToolTip(tr("Very unimportant!","Standardflag"));
1277 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1278 standardFlagsDefault->addFlag (fo);
1280 fo->load(flagsPath+"flag-thumb-up.png");
1281 fo->setName("thumb-up");
1282 fo->setGroup("standard-thumb");
1283 a=new QAction (fo->getPixmap(),fo->getName(),this);
1286 a->setCheckable(true);
1287 a->setObjectName(fo->getName());
1288 a->setToolTip(tr("I like this","Standardflag"));
1289 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1290 standardFlagsDefault->addFlag (fo);
1292 fo->load(flagsPath+"flag-thumb-down.png");
1293 fo->setName("thumb-down");
1294 fo->setGroup("standard-thumb");
1295 a=new QAction (fo->getPixmap(),fo->getName(),this);
1298 a->setCheckable(true);
1299 a->setObjectName(fo->getName());
1300 a->setToolTip(tr("I do not like this","Standardflag"));
1301 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1302 standardFlagsDefault->addFlag (fo);
1304 fo->load(flagsPath+"flag-rose.png");
1305 fo->setName("rose");
1306 a=new QAction (fo->getPixmap(),fo->getName(),this);
1309 a->setCheckable(true);
1310 a->setObjectName(fo->getName());
1311 a->setToolTip(tr("Rose","Standardflag"));
1312 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1313 standardFlagsDefault->addFlag (fo);
1315 fo->load(flagsPath+"flag-heart.png");
1316 fo->setName("heart");
1317 a=new QAction (fo->getPixmap(),fo->getName(),this);
1319 a->setCheckable(true);
1320 a->setObjectName(fo->getName());
1321 a->setToolTip(tr("I just love... ","Standardflag"));
1322 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1323 standardFlagsDefault->addFlag (fo);
1325 fo->load(flagsPath+"flag-present.png");
1326 fo->setName("present");
1327 a=new QAction (fo->getPixmap(),fo->getName(),this);
1330 a->setCheckable(true);
1331 a->setObjectName(fo->getName());
1332 a->setToolTip(tr("Surprise!","Standardflag"));
1333 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1334 standardFlagsDefault->addFlag (fo);
1336 fo->load(flagsPath+"flag-flash.png");
1337 fo->setName("flash");
1338 a=new QAction (fo->getPixmap(),fo->getName(),this);
1341 a->setCheckable(true);
1342 a->setObjectName(fo->getName());
1343 a->setToolTip(tr("Dangerous","Standardflag"));
1344 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1345 standardFlagsDefault->addFlag (fo);
1347 fo->load(flagsPath+"flag-info.png");
1348 // Original: xsldbg_output.png
1349 fo->setName("info");
1350 a=new QAction (fo->getPixmap(),fo->getName(),this);
1353 a->setCheckable(true);
1354 a->setObjectName(fo->getName());
1355 a->setToolTip(tr("Info","Standardflag"));
1356 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1357 standardFlagsDefault->addFlag (fo);
1359 fo->load(flagsPath+"flag-lifebelt.png");
1360 // Original khelpcenter.png
1361 fo->setName("lifebelt");
1362 a=new QAction (fo->getPixmap(),fo->getName(),this);
1365 a->setCheckable(true);
1366 a->setObjectName(fo->getName());
1367 a->setToolTip(tr("This will help","Standardflag"));
1368 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1369 standardFlagsDefault->addFlag (fo);
1375 void Main::setupSettingsActions()
1377 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1381 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1382 a->setStatusTip ( tr( "Set application to open pdf files"));
1383 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1384 settingsMenu->addAction (a);
1386 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1387 a->setStatusTip( tr( "Set application to open external links"));
1388 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1389 settingsMenu->addAction (a);
1391 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1392 a->setStatusTip( tr( "Set path for macros"));
1393 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1394 settingsMenu->addAction (a);
1396 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1397 a->setStatusTip( tr( "Set number of undo levels"));
1398 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1399 settingsMenu->addAction (a);
1401 settingsMenu->addSeparator();
1403 a = new QAction( tr( "Autosave","Settings action"), this);
1404 a->setStatusTip( tr( "Autosave"));
1405 a->setToggleAction(true);
1406 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1407 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1408 settingsMenu->addAction (a);
1409 actionSettingsAutosaveToggle=a;
1411 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1412 a->setStatusTip( tr( "Autosave time"));
1413 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1414 settingsMenu->addAction (a);
1415 actionSettingsAutosaveTime=a;
1417 settingsMenu->addSeparator();
1419 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1420 a->setStatusTip( tr( "Edit branch after adding it" ));
1421 a->setToggleAction(true);
1422 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1423 settingsMenu->addAction (a);
1424 actionSettingsAutoEdit=a;
1426 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1427 a->setStatusTip( tr( "Select branch after adding it" ));
1428 a->setToggleAction(true);
1429 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1430 settingsMenu->addAction (a);
1431 actionSettingsAutoSelectHeading=a;
1433 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1434 a->setStatusTip( tr( "Select heading before editing" ));
1435 a->setToggleAction(true);
1436 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1437 settingsMenu->addAction (a);
1438 actionSettingsAutoSelectText=a;
1440 a= new QAction( tr( "Delete key","Settings action" ), this);
1441 a->setStatusTip( tr( "Delete key for deleting branches" ));
1442 a->setToggleAction(true);
1443 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1444 settingsMenu->addAction (a);
1445 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1446 actionSettingsUseDelKey=a;
1448 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1449 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1450 a->setToggleAction(true);
1451 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1452 settingsMenu->addAction (a);
1453 actionSettingsUseFlagGroups=a;
1455 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1456 a->setStatusTip( tr( "Use hide flag during exports " ));
1457 a->setToggleAction(true);
1458 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1459 settingsMenu->addAction (a);
1460 actionSettingsUseHideExport=a;
1464 void Main::setupTestActions()
1466 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1469 a = new QAction( "Test function" , this);
1470 a->setStatusTip( "Call test function" );
1471 //a->setShortcut (Qt::Key_F4 );
1472 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1473 testMenu->addAction (a);
1474 a = new QAction( "Command" , this);
1475 a->setStatusTip( "Enter command to call in editor" );
1476 //a->setShortcut (Qt::Key_F5 );
1477 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1478 testMenu->addAction (a);
1482 void Main::setupHelpActions()
1484 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1487 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1488 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1489 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1490 helpMenu->addAction (a);
1492 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1493 a->setStatusTip( tr( "Open VYM example maps " ));
1494 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1495 helpMenu->addAction (a);
1497 a = new QAction( tr( "About VYM","Help action" ), this);
1498 a->setStatusTip( tr( "About VYM")+vymName);
1499 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1500 helpMenu->addAction (a);
1502 a = new QAction( tr( "About QT","Help action" ), this);
1503 a->setStatusTip( tr( "Information about QT toolkit" ));
1504 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1505 helpMenu->addAction (a);
1509 void Main::setupContextMenus()
1513 // Context Menu for branch or mapcenter
1514 branchContextMenu =new QMenu (this);
1515 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1516 branchContextMenu->addSeparator();
1519 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1520 branchAddContextMenu->addAction (actionEditPaste );
1521 branchAddContextMenu->addAction ( actionEditAddBranch );
1522 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1523 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1524 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1525 branchAddContextMenu->addSeparator();
1526 branchAddContextMenu->addAction ( actionEditImportAdd );
1527 branchAddContextMenu->addAction ( actionEditImportReplace );
1530 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1531 branchRemoveContextMenu->addAction (actionEditCut);
1532 branchRemoveContextMenu->addAction ( actionEditDelete );
1533 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1534 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1537 actionEditSaveBranch->addTo( branchContextMenu );
1539 branchContextMenu->addSeparator();
1540 branchContextMenu->addAction ( actionEditLoadImage);
1542 // Submenu for Links (URLs, vymLinks)
1543 branchLinksContextMenu =new QMenu (this);
1545 branchContextMenu->addSeparator();
1546 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1547 branchLinksContextMenu->addAction ( actionEditOpenURL );
1548 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1549 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1550 branchLinksContextMenu->addAction ( actionEditURL );
1551 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1552 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1553 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1555 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1557 branchLinksContextMenu->addSeparator();
1558 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1559 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1560 branchLinksContextMenu->addAction ( actionEditVymLink );
1561 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1564 // Context Menu for XLinks in a branch menu
1565 // This will be populated "on demand" in MapEditor::updateActions
1566 branchContextMenu->addSeparator();
1567 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1568 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1569 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1570 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1573 // Context menu for floatimage
1574 floatimageContextMenu =new QMenu (this);
1575 a= new QAction (tr ("Save image","Context action"),this);
1576 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1577 floatimageContextMenu->addAction (a);
1579 floatimageContextMenu->addSeparator();
1580 actionEditCopy->addTo( floatimageContextMenu );
1581 actionEditCut->addTo( floatimageContextMenu );
1583 floatimageContextMenu->addSeparator();
1584 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1587 // Context menu for canvas
1588 canvasContextMenu =new QMenu (this);
1589 actionEditMapInfo->addTo( canvasContextMenu );
1590 canvasContextMenu->insertSeparator();
1591 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1592 canvasContextMenu->insertSeparator();
1593 actionFormatLinkColorHint->addTo( canvasContextMenu );
1594 actionFormatLinkColor->addTo( canvasContextMenu );
1595 actionFormatSelectionColor->addTo( canvasContextMenu );
1596 actionFormatBackColor->addTo( canvasContextMenu );
1597 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1599 // Menu for last opened files
1601 for (int i = 0; i < MaxRecentFiles; ++i)
1603 recentFileActions[i] = new QAction(this);
1604 recentFileActions[i]->setVisible(false);
1605 fileLastMapsMenu->addAction(recentFileActions[i]);
1606 connect(recentFileActions[i], SIGNAL(triggered()),
1607 this, SLOT(fileLoadRecent()));
1609 setupRecentMapsMenu();
1612 void Main::setupRecentMapsMenu()
1614 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1616 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1618 for (int i = 0; i < numRecentFiles; ++i) {
1619 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1620 recentFileActions[i]->setText(text);
1621 recentFileActions[i]->setData(files[i]);
1622 recentFileActions[i]->setVisible(true);
1624 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1625 recentFileActions[j]->setVisible(false);
1628 void Main::setupMacros()
1630 for (int i = 0; i <= 11; i++)
1632 macroActions[i] = new QAction(this);
1633 macroActions[i]->setData(i);
1634 addAction (macroActions[i]);
1635 connect(macroActions[i], SIGNAL(triggered()),
1636 this, SLOT(callMacro()));
1638 macroActions[0]->setShortcut ( Qt::Key_F1 );
1639 macroActions[1]->setShortcut ( Qt::Key_F2 );
1640 macroActions[2]->setShortcut ( Qt::Key_F3 );
1641 macroActions[3]->setShortcut ( Qt::Key_F4 );
1642 macroActions[4]->setShortcut ( Qt::Key_F5 );
1643 macroActions[5]->setShortcut ( Qt::Key_F6 );
1644 macroActions[6]->setShortcut ( Qt::Key_F7 );
1645 macroActions[7]->setShortcut ( Qt::Key_F8 );
1646 macroActions[8]->setShortcut ( Qt::Key_F9 );
1647 macroActions[9]->setShortcut ( Qt::Key_F10 );
1648 macroActions[10]->setShortcut ( Qt::Key_F11 );
1649 macroActions[11]->setShortcut ( Qt::Key_F12 );
1652 void Main::hideEvent (QHideEvent * )
1654 if (!textEditor->isMinimized() ) textEditor->hide();
1657 void Main::showEvent (QShowEvent * )
1659 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1663 MapEditor* Main::currentMapEditor() const
1665 if ( tabWidget->currentPage() &&
1666 tabWidget->currentPage()->inherits( "MapEditor" ) )
1667 return (MapEditor*)tabWidget->currentPage();
1672 void Main::editorChanged(QWidget *)
1674 // Unselect all possibly selected objects
1675 // (Important to update note editor)
1677 for (int i=0;i<=tabWidget->count() -1;i++)
1680 me=(MapEditor*)tabWidget->page(i);
1683 currentMapEditor()->reselect();
1685 // Update actions to in menus and toolbars according to editor
1689 void Main::fileNew()
1691 QString fn="unnamed";
1692 MapEditor* me = new MapEditor ( NULL);
1693 tabWidget->addTab (me,fn);
1694 tabWidget->showPage(me);
1695 me->viewport()->setFocus();
1696 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1697 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1699 // For the very first map we do not have flagrows yet...
1703 void Main::fileNewCopy()
1705 QString fn="unnamed";
1706 MapEditor* oldME =currentMapEditor();
1710 MapEditor* newME = new MapEditor ( NULL);
1713 tabWidget->addTab (newME,fn);
1714 tabWidget->showPage(newME);
1715 newME->viewport()->setFocus();
1716 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1717 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1718 // For the very first map we do not have flagrows yet...
1719 newME->select("mc:");
1720 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace);
1726 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1728 ErrorCode err=success;
1730 // fn is usually the archive, mapfile the file after uncompressing
1733 // Make fn absolute (needed for unzip)
1734 fn=QDir (fn).absPath();
1740 // Check, if map is already loaded
1742 while (i<=tabWidget->count() -1)
1744 me=(MapEditor*)tabWidget->page(i);
1745 if (me->getFilePath() == fn)
1747 // Already there, ask for confirmation
1748 QMessageBox mb( vymName,
1749 tr("The map %1\nis already opened."
1750 "Opening the same map in multiple editors may lead \n"
1751 "to confusion when finishing working with vym."
1752 "Do you want to").arg(fn),
1753 QMessageBox::Warning,
1754 QMessageBox::Yes | QMessageBox::Default,
1755 QMessageBox::Cancel | QMessageBox::Escape,
1756 QMessageBox::NoButton);
1757 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1758 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1761 case QMessageBox::Yes:
1763 i=tabWidget->count();
1765 case QMessageBox::Cancel:
1777 if ( !fn.isEmpty() )
1779 me = currentMapEditor();
1780 int tabIndex=tabWidget->currentPageIndex();
1781 // Check first, if mapeditor exists
1782 // If it is not default AND we want a new map,
1783 // create a new mapeditor in a new tab
1784 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1786 me= new MapEditor ( NULL);
1787 tabWidget->addTab (me,fn);
1788 tabIndex=tabWidget->indexOf (me);
1789 tabWidget->setCurrentPage (tabIndex);
1790 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1791 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1794 // Check, if file exists (important for creating new files
1795 // from command line
1796 if (!QFile(fn).exists() )
1798 QMessageBox mb( vymName,
1799 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1800 QMessageBox::Question,
1802 QMessageBox::Cancel | QMessageBox::Default,
1803 QMessageBox::NoButton );
1805 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1806 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1809 case QMessageBox::Yes:
1811 currentMapEditor()->setFilePath(fn);
1812 tabWidget->setTabLabel (currentMapEditor(),
1813 currentMapEditor()->getFileName() );
1814 statusBar()->message( "Created " + fn , statusbarTime );
1817 case QMessageBox::Cancel:
1818 // don't create new map
1819 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1826 //tabWidget->currentPage() won't be NULL here, because of above...
1827 tabWidget->showPage(me);
1828 me->viewport()->setFocus();
1830 // Create temporary directory for packing
1832 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1835 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1836 tr("Couldn't create temporary directory before load\n"));
1840 // Try to unzip file
1841 err=unzipDir (tmpMapDir,fn);
1845 me->setZipped(false);
1848 me->setZipped(true);
1850 // Look for mapname.xml
1851 mapfile= fn.left(fn.findRev(".",-1,true));
1852 mapfile=mapfile.section( '/', -1 );
1853 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1854 if (!file.exists() )
1856 // mapname.xml does not exist, well,
1857 // maybe someone renamed the mapname.vym file...
1858 // Try to find any .xml in the toplevel
1859 // directory of the .vym file
1860 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1861 if (flist.count()==1)
1863 // Only one entry, take this one
1864 mapfile=tmpMapDir + "/"+flist.first();
1867 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1868 *it=tmpMapDir + "/" + *it;
1869 // TODO Multiple entries, load all (but only the first one into this ME)
1870 //mainWindow->fileLoadFromTmp (flist);
1871 //returnCode=1; // Silently forget this attempt to load
1872 qWarning ("MainWindow::load (fn) multimap found...");
1875 if (flist.isEmpty() )
1877 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1878 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1881 } //file doesn't exist
1883 mapfile=file.name();
1888 // Save existing filename in case we import
1889 QString fn_org=me->getFilePath();
1891 // Finally load map into mapEditor
1892 me->setFilePath (mapfile,fn);
1893 err=me->load(mapfile,lmode);
1895 // Restore old (maybe empty) filepath, if this is an import
1897 me->setFilePath (fn_org);
1900 // Finally check for errors and go home
1903 if (lmode==NewMap) fileCloseMap();
1904 statusBar()->message( "Could not load " + fn, statusbarTime );
1909 me->setFilePath (fn);
1910 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1911 if (fn.left(9)!="/tmp/vym-")
1913 // Only append to lastMaps if not loaded from a tmpDir
1914 // e.g. imported bookmarks are in a tmpDir
1915 addRecentMap(me->getFilePath() );
1917 actionFilePrint->setEnabled (true);
1919 statusBar()->message( "Loaded " + fn, statusbarTime );
1923 removeDir (QDir(tmpMapDir));
1929 void Main::fileLoad(const LoadMode &lmode)
1931 QStringList filters;
1932 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1933 QFileDialog *fd=new QFileDialog( this);
1934 fd->setDir (lastFileDir);
1935 fd->setFileMode (QFileDialog::ExistingFiles);
1936 fd->setFilters (filters);
1940 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1943 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1946 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1952 if ( fd->exec() == QDialog::Accepted )
1954 lastFileDir=fd->directory().path();
1955 QStringList flist = fd->selectedFiles();
1956 QStringList::Iterator it = flist.begin();
1957 while( it != flist.end() )
1960 fileLoad(*it, lmode);
1967 void Main::fileLoad()
1972 void Main::fileLoadRecent()
1974 QAction *action = qobject_cast<QAction *>(sender());
1976 fileLoad (action->data().toString(), NewMap);
1979 void Main::addRecentMap (const QString &fileName)
1982 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1983 files.removeAll(fileName);
1984 files.prepend(fileName);
1985 while (files.size() > MaxRecentFiles)
1988 settings.setValue("/mainwindow/recentFileList", files);
1990 setupRecentMapsMenu();
1993 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1995 // tmp dir for zipping
1999 ErrorCode err=success;
2001 QString safeFilePath;
2003 bool saveZipped=me->saveZipped();
2007 QString fn=me->getFilePath();
2008 // filename=unnamed, filepath="" in constructor of mapEditor
2009 if ( !fn.isEmpty() )
2011 // We have a filepath, go on saving
2012 // First remove existing file, we
2013 // don't want to add to old zip archives
2017 QMessageBox::warning( 0, tr( "Save Error" ),
2018 fn+ tr("\ncould not be removed before saving"));
2020 // Look, if we should zip the data:
2023 QMessageBox mb( vymName,
2024 tr("The map %1\ndid not use the compressed "
2025 "vym file format.\nWriting it uncompressed will also write images \n"
2026 "and flags and thus may overwrite files in the "
2027 "given directory\n\nDo you want to write the map").arg(fn),
2028 QMessageBox::Warning,
2029 QMessageBox::Yes | QMessageBox::Default,
2031 QMessageBox::Cancel | QMessageBox::Escape);
2032 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2033 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2034 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2037 case QMessageBox::Yes:
2038 // save compressed (default file format)
2041 case QMessageBox::No:
2042 // save uncompressed
2045 case QMessageBox::Cancel:
2054 // Create temporary directory for packing
2056 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2059 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2060 tr("Couldn't create temporary directory before save\n"));
2064 safeFilePath=me->getFilePath();
2065 me->setFilePath (tmpMapDir+"/"+
2066 me->getMapName()+ ".xml",
2068 me->save (savemode);
2069 me->setFilePath (safeFilePath);
2071 zipDir (tmpMapDir,fn);
2076 safeFilePath=me->getFilePath();
2077 me->setFilePath (fn, safeFilePath);
2078 me->save (savemode);
2079 me->setFilePath (safeFilePath);
2081 } // filepath available
2084 // We have no filepath yet,
2085 // call fileSaveAs() now, this will call fileSave()
2087 // First switch to editor
2088 tabWidget->setCurrentWidget (me);
2089 fileSaveAs(savemode);
2093 if (saveZipped && !tmpMapDir.isEmpty())
2095 removeDir (QDir(tmpMapDir));
2099 statusBar()->message(
2100 tr("Saved %1").arg(me->getFilePath()),
2102 addRecentMap (me->getFilePath() );
2104 statusBar()->message(
2105 tr("Couldn't save ").arg(me->getFilePath()),
2109 void Main::fileSave()
2111 fileSave (currentMapEditor(), CompleteMap);
2114 void Main::fileSave(MapEditor *me)
2116 fileSave (me,CompleteMap);
2119 void Main::fileSaveAs(const SaveMode& savemode)
2123 if (currentMapEditor())
2125 if (savemode==CompleteMap)
2126 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2128 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2129 if ( !fn.isEmpty() )
2131 // Check for existing file
2132 if (QFile (fn).exists())
2134 QMessageBox mb( vymName,
2135 tr("The file %1\nexists already. Do you want to").arg(fn),
2136 QMessageBox::Warning,
2137 QMessageBox::Yes | QMessageBox::Default,
2138 QMessageBox::Cancel | QMessageBox::Escape,
2139 QMessageBox::NoButton);
2140 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2141 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2144 case QMessageBox::Yes:
2147 case QMessageBox::Cancel:
2154 // New file, add extension to filename, if missing
2155 // This is always .vym or .vyp, depending on savemode
2156 if (savemode==CompleteMap)
2158 if (!fn.contains (".vym") && !fn.contains (".xml"))
2162 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2171 currentMapEditor()->setFilePath(fn);
2172 fileSave(currentMapEditor(), savemode);
2175 if (savemode==CompleteMap)
2176 tabWidget->setTabLabel (currentMapEditor(),
2177 currentMapEditor()->getFileName() );
2183 void Main::fileSaveAs()
2185 fileSaveAs (CompleteMap);
2188 void Main::fileImportKDEBookmarks()
2190 ImportKDEBookmarks im;
2192 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2193 currentMapEditor()->setFilePath ("");
2196 void Main::fileImportFirefoxBookmarks()
2198 Q3FileDialog *fd=new Q3FileDialog( this);
2199 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2200 fd->setMode (Q3FileDialog::ExistingFiles);
2201 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2202 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2205 if ( fd->exec() == QDialog::Accepted )
2207 ImportFirefoxBookmarks im;
2208 QStringList flist = fd->selectedFiles();
2209 QStringList::Iterator it = flist.begin();
2210 while( it != flist.end() )
2213 if (im.transform() &&
2214 success==fileLoad (im.getTransformedFile(),NewMap) &&
2215 currentMapEditor() )
2216 currentMapEditor()->setFilePath ("");
2223 void Main::fileImportMM()
2227 Q3FileDialog *fd=new Q3FileDialog( this);
2228 fd->setDir (lastFileDir);
2229 fd->setMode (Q3FileDialog::ExistingFiles);
2230 fd->addFilter ("Mind Manager (*.mmap)");
2231 fd->setCaption(tr("Import")+" "+"Mind Manager");
2234 if ( fd->exec() == QDialog::Accepted )
2236 lastFileDir=fd->dirPath();
2237 QStringList flist = fd->selectedFiles();
2238 QStringList::Iterator it = flist.begin();
2239 while( it != flist.end() )
2242 if (im.transform() &&
2243 success==fileLoad (im.getTransformedFile(),NewMap) &&
2244 currentMapEditor() )
2245 currentMapEditor()->setFilePath ("");
2254 void Main::fileImportDir()
2256 if (currentMapEditor())
2257 currentMapEditor()->importDir();
2260 void Main::fileExportXML()
2262 MapEditor *me=currentMapEditor();
2263 if (me) me->exportXML();
2267 void Main::fileExportXHTML()
2269 MapEditor *me=currentMapEditor();
2270 if (me) me->exportXHTML();
2273 void Main::fileExportImage()
2275 MapEditor *me=currentMapEditor();
2276 if (me) me->exportImage();
2279 void Main::fileExportASCII()
2281 MapEditor *me=currentMapEditor();
2282 if (me) me->exportASCII();
2285 void Main::fileExportCSV() //FIXME not scriptable yet
2287 MapEditor *me=currentMapEditor();
2291 ex.setMapCenter(me->getMapCenter());
2292 ex.addFilter ("CSV (*.csv)");
2293 ex.setDir(lastImageDir);
2294 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2295 if (ex.execDialog() )
2297 me->setExportMode(true);
2299 me->setExportMode(false);
2304 void Main::fileExportLaTeX() //FIXME not scriptable yet
2306 MapEditor *me=currentMapEditor();
2310 ex.setMapCenter(me->getMapCenter());
2311 ex.addFilter ("Tex (*.tex)");
2312 ex.setDir(lastImageDir);
2313 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2314 if (ex.execDialog() )
2316 me->setExportMode(true);
2318 me->setExportMode(false);
2323 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2325 ExportKDEBookmarks ex;
2326 MapEditor *me=currentMapEditor();
2329 ex.setMapCenter (me->getMapCenter() );
2334 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2336 ExportTaskjuggler ex;
2337 MapEditor *me=currentMapEditor();
2340 ex.setMapCenter (me->getMapCenter() );
2341 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2342 ex.setDir(lastImageDir);
2343 ex.addFilter ("Taskjuggler (*.tjp)");
2344 if (ex.execDialog() )
2346 me->setExportMode(true);
2348 me->setExportMode(false);
2353 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2355 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2356 // TODO add preview in dialog
2357 //ImagePreview *p =new ImagePreview (fd);
2358 //fd->setContentsPreviewEnabled( TRUE );
2359 //fd->setContentsPreview( p, p );
2360 //fd->setPreviewMode( QFileDialog::Contents );
2361 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2362 fd->setDir (QDir().current());
2363 if (fd->foundConfig())
2367 if ( fd->exec() == QDialog::Accepted )
2369 QString fn=fd->selectedFile();
2370 if (!fn.contains (".odp"))
2373 //lastImageDir=fn.left(fn.findRev ("/"));
2374 if (currentMapEditor())
2375 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2379 QMessageBox::warning(0,
2381 tr("Couldn't find configuration for export to Open Office\n"));
2385 void Main::fileCloseMap()
2387 if (currentMapEditor())
2389 if (currentMapEditor()->hasChanged())
2391 QMessageBox mb( vymName,
2392 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2393 QMessageBox::Warning,
2394 QMessageBox::Yes | QMessageBox::Default,
2396 QMessageBox::Cancel | QMessageBox::Escape );
2397 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2398 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2401 case QMessageBox::Yes:
2403 fileSave(currentMapEditor(), CompleteMap);
2405 case QMessageBox::No:
2406 // close without saving
2408 case QMessageBox::Cancel:
2413 currentMapEditor()->closeMap();
2414 tabWidget->removePage(currentMapEditor());
2415 if (tabWidget->count()==0)
2416 actionFilePrint->setEnabled (false);
2420 void Main::filePrint()
2422 if (currentMapEditor())
2423 currentMapEditor()->print();
2426 void Main::fileExitVYM()
2428 // Check if one or more editors have changed
2431 for (i=0;i<=tabWidget->count() -1;i++)
2434 me=(MapEditor*)tabWidget->page(i);
2436 // If something changed, ask what to do
2437 if (me->hasChanged())
2439 tabWidget->setCurrentPage(i);
2440 QMessageBox mb( vymName,
2441 tr("This map is not saved yet. Do you want to"),
2442 QMessageBox::Warning,
2443 QMessageBox::Yes | QMessageBox::Default,
2445 QMessageBox::Cancel | QMessageBox::Escape );
2446 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2447 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2450 mb.setActiveWindow();
2451 switch( mb.exec() ) {
2452 case QMessageBox::Yes:
2453 // save (the changed editors) and exit
2454 fileSave(currentMapEditor(), CompleteMap);
2456 case QMessageBox::No:
2457 // exit without saving
2459 case QMessageBox::Cancel:
2460 // don't save and don't exit
2464 } // loop over all MEs
2468 void Main::editUndo()
2470 if (currentMapEditor())
2471 currentMapEditor()->undo();
2474 void Main::editRedo()
2476 if (currentMapEditor())
2477 currentMapEditor()->redo();
2480 void Main::gotoHistoryStep (int i)
2482 if (currentMapEditor())
2483 currentMapEditor()->gotoHistoryStep (i);
2486 void Main::editCopy()
2488 if (currentMapEditor())
2489 currentMapEditor()->copy();
2492 void Main::editPaste()
2494 if (currentMapEditor())
2495 currentMapEditor()->paste();
2498 void Main::editCut()
2500 if (currentMapEditor())
2501 currentMapEditor()->cut();
2504 void Main::editOpenFindWindow()
2506 findWindow->popup();
2507 findWindow->raise();
2508 findWindow->setActiveWindow();
2511 void Main::editFind(QString s)
2514 BranchObj *bo=currentMapEditor()->findText(s, cs);
2517 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2520 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2521 tr("No matches found for \"%1\"").arg(s));
2525 void Main::editFindChanged()
2526 { // Notify editor, to abort the current find process
2527 currentMapEditor()->findReset();
2530 void Main::openTabs(QStringList urls)
2532 if (!urls.isEmpty())
2536 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2538 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2540 QString u=urls.takeFirst();
2541 procBrowser = new QProcess( this );
2543 procBrowser->start(browser,args);
2544 if ( !procBrowser->waitForStarted())
2546 // try to set path to browser
2547 QMessageBox::warning(0,
2549 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2550 tr("Please use Settings->")+tr("Set application to open an URL"));
2555 if (browser.contains("konqueror"))
2557 for (int i=0; i<urls.size(); i++)
2560 // Try to open new tab in existing konqueror started previously by vym
2561 p=new QProcess (this);
2563 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2564 "konqueror-mainwindow#1"<<
2567 p->start ("dcop",args);
2568 if ( !p->waitForStarted() ) success=false;
2571 QMessageBox::warning(0,
2573 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2575 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2577 for (int i=0; i<urls.size(); i++)
2579 // Try to open new tab in firefox
2580 p=new QProcess (this);
2581 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2582 p->start (browser,args);
2583 if ( !p->waitForStarted() ) success=false;
2586 QMessageBox::warning(0,
2588 tr("Couldn't start %1 to open a new tab").arg(browser));
2591 QMessageBox::warning(0,
2593 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2597 void Main::editOpenURL()
2600 if (currentMapEditor())
2602 QString url=currentMapEditor()->getURL();
2604 if (url=="") return;
2605 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2606 procBrowser = new QProcess( this );
2608 procBrowser->start(browser,args);
2609 if ( !procBrowser->waitForStarted())
2611 // try to set path to browser
2612 QMessageBox::warning(0,
2614 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2615 tr("Please use Settings->")+tr("Set application to open an URL"));
2620 void Main::editOpenURLTab()
2622 if (currentMapEditor())
2625 urls.append(currentMapEditor()->getURL());
2629 void Main::editOpenMultipleURLTabs()
2631 if (currentMapEditor())
2634 urls=currentMapEditor()->getURLs();
2640 void Main::editURL()
2642 if (currentMapEditor())
2643 currentMapEditor()->editURL();
2646 void Main::editHeading2URL()
2648 if (currentMapEditor())
2649 currentMapEditor()->editHeading2URL();
2652 void Main::editBugzilla2URL()
2654 if (currentMapEditor())
2655 currentMapEditor()->editBugzilla2URL();
2658 void Main::editFATE2URL()
2660 if (currentMapEditor())
2661 currentMapEditor()->editFATE2URL();
2664 void Main::editHeadingFinished()
2666 // only called from editHeading(), so there is a currentME
2667 MapEditor *me=currentMapEditor();
2670 me->setStateEditHeading (false);
2671 QPoint p; //Not used here, only to find out pos of branch
2673 QString s=me->getHeading(ok,p);
2675 #if defined(Q_OS_MACX)
2677 if (ok && s!=lineedit->text())
2678 me->setHeading(lineedit->text());
2680 lineedit->releaseKeyboard();
2684 if (!prevSelection.isEmpty()) me->select(prevSelection);
2689 void Main::editHeading()
2691 if (currentMapEditor())
2693 MapEditor *me=currentMapEditor();
2694 QString oldSel=me->getSelectString();
2696 if (lineedit->isVisible())
2697 editHeadingFinished();
2702 QString s=currentMapEditor()->getHeading(ok,p);
2706 me->setStateEditHeading (true);
2707 #if defined(Q_OS_MACX)
2708 p=currentMapEditor()->mapTo (this,p);
2709 QDialog *d =new QDialog(NULL);
2710 QLineEdit *le=new QLineEdit (d);
2711 d->setWindowFlags (Qt::FramelessWindowHint);
2712 d->setGeometry(p.x(),p.y(),230,25);
2713 le->resize (d->width()-10,d->height());
2716 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2717 d->activateWindow();
2719 currentMapEditor()->setHeading (le->text());
2722 editHeadingFinished();
2724 p=currentMapEditor()->mapTo (this,p);
2725 lineedit->setGeometry(p.x(),p.y(),230,25);
2726 lineedit->setText(s);
2727 lineedit->setCursorPosition(1);
2728 lineedit->selectAll();
2730 lineedit->grabKeyboard();
2731 lineedit->setFocus();
2735 } // currentMapEditor()
2738 void Main::openVymLinks(const QStringList &vl)
2740 for (int j=0; j<vl.size(); j++)
2742 // compare path with already loaded maps
2746 for (i=0;i<=tabWidget->count() -1;i++)
2748 me=(MapEditor*)tabWidget->page(i);
2749 if (vl.at(j)==me->getFilePath() )
2758 if (!QFile(vl.at(j)).exists() )
2759 QMessageBox::critical( 0, tr( "Critical Error" ),
2760 tr("Couldn't open map %1").arg(vl.at(j)));
2763 fileLoad (vl.at(j), NewMap);
2764 tabWidget->setCurrentPage (tabWidget->count()-1);
2767 // Go to tab containing the map
2768 tabWidget->setCurrentPage (index);
2772 void Main::editOpenVymLink()
2774 if (currentMapEditor())
2777 vl.append(currentMapEditor()->getVymLink());
2782 void Main::editOpenMultipleVymLinks()
2784 QString currentVymLink;
2785 if (currentMapEditor())
2787 QStringList vl=currentMapEditor()->getVymLinks();
2792 void Main::editVymLink()
2794 if (currentMapEditor())
2795 currentMapEditor()->editVymLink();
2798 void Main::editDeleteVymLink()
2800 if (currentMapEditor())
2801 currentMapEditor()->deleteVymLink();
2804 void Main::editToggleHideExport()
2806 if (currentMapEditor())
2807 currentMapEditor()->toggleHideExport();
2810 void Main::editMapInfo()
2812 if (currentMapEditor())
2813 currentMapEditor()->editMapInfo();
2816 void Main::editMoveUp()
2818 if (currentMapEditor())
2819 currentMapEditor()->moveBranchUp();
2822 void Main::editMoveDown()
2824 if (currentMapEditor())
2825 currentMapEditor()->moveBranchDown();
2828 void Main::editToggleScroll()
2830 if (currentMapEditor())
2832 currentMapEditor()->toggleScroll();
2836 void Main::editUnscrollChilds()
2838 if (currentMapEditor())
2839 currentMapEditor()->unscrollChilds();
2842 void Main::editNewBranch()
2844 MapEditor *me=currentMapEditor();
2845 if (!lineedit->isVisible() && me)
2847 BranchObj *bo=(BranchObj*)me->getSelection();
2848 BranchObj *newbo=me->addNewBranch(0);
2851 me->select (newbo->getSelectString());
2855 if (actionSettingsAutoEdit->isOn())
2857 if (!actionSettingsAutoSelectHeading->isOn())
2858 prevSelection=bo->getSelectString();
2864 void Main::editNewBranchBefore()
2866 MapEditor *me=currentMapEditor();
2867 if (!lineedit->isVisible() && me)
2869 BranchObj *bo=(BranchObj*)me->getSelection();
2870 BranchObj *newbo=me->addNewBranchBefore();
2873 me->select (newbo->getSelectString());
2877 if (actionSettingsAutoEdit->isOn())
2879 if (!actionSettingsAutoSelectHeading->isOn())
2880 prevSelection=bo->getSelectString();
2886 void Main::editNewBranchAbove()
2888 MapEditor *me=currentMapEditor();
2889 if (!lineedit->isVisible() && me)
2891 BranchObj *bo=(BranchObj*)me->getSelection();
2892 BranchObj *newbo=me->addNewBranch (-1);
2895 me->select (newbo->getSelectString());
2899 if (actionSettingsAutoEdit->isOn())
2901 if (!actionSettingsAutoSelectHeading->isOn())
2902 prevSelection=bo->getSelectString();
2908 void Main::editNewBranchBelow()
2910 MapEditor *me=currentMapEditor();
2911 if (!lineedit->isVisible() && me)
2913 BranchObj *bo=(BranchObj*)me->getSelection();
2914 BranchObj *newbo=me->addNewBranch (1);
2917 me->select (newbo->getSelectString());
2921 if (actionSettingsAutoEdit->isOn())
2923 if (!actionSettingsAutoSelectHeading->isOn())
2924 prevSelection=bo->getSelectString();
2930 void Main::editImportAdd()
2932 fileLoad (ImportAdd);
2935 void Main::editImportReplace()
2937 fileLoad (ImportReplace);
2940 void Main::editSaveBranch()
2942 fileSaveAs (PartOfMap);
2945 void Main::editDeleteKeepChilds()
2947 if (currentMapEditor())
2948 currentMapEditor()->deleteKeepChilds();
2951 void Main::editDeleteChilds()
2953 if (currentMapEditor())
2954 currentMapEditor()->deleteChilds();
2957 void Main::editDeleteSelection()
2959 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2960 currentMapEditor()->deleteSelection();
2963 void Main::editUpperBranch()
2965 if (currentMapEditor())
2966 currentMapEditor()->selectUpperBranch();
2969 void Main::editLowerBranch()
2971 if (currentMapEditor())
2972 currentMapEditor()->selectLowerBranch();
2975 void Main::editLeftBranch()
2977 if (currentMapEditor())
2978 currentMapEditor()->selectLeftBranch();
2981 void Main::editRightBranch()
2983 if (currentMapEditor())
2984 currentMapEditor()->selectRightBranch();
2987 void Main::editFirstBranch()
2989 if (currentMapEditor())
2990 currentMapEditor()->selectFirstBranch();
2993 void Main::editLastBranch()
2995 if (currentMapEditor())
2996 currentMapEditor()->selectLastBranch();
2999 void Main::editLoadImage()
3001 if (currentMapEditor())
3002 currentMapEditor()->loadFloatImage();
3005 void Main::editSaveImage()
3007 if (currentMapEditor())
3008 currentMapEditor()->saveFloatImage();
3011 void Main::editFollowXLink(QAction *a)
3014 if (currentMapEditor())
3015 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3018 void Main::editEditXLink(QAction *a)
3020 if (currentMapEditor())
3021 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3024 void Main::formatSelectColor()
3026 if (currentMapEditor())
3028 QColor col = QColorDialog::getColor((currentColor ), this );
3029 if ( !col.isValid() ) return;
3030 colorChanged( col );
3034 void Main::formatPickColor()
3036 if (currentMapEditor())
3037 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3040 void Main::colorChanged(QColor c)
3042 QPixmap pix( 16, 16 );
3044 actionFormatColor->setIconSet( pix );
3048 void Main::formatColorBranch()
3050 if (currentMapEditor())
3051 currentMapEditor()->colorBranch(currentColor);
3054 void Main::formatColorSubtree()
3056 if (currentMapEditor())
3057 currentMapEditor()->colorSubtree (currentColor);
3060 void Main::formatLinkStyleLine()
3062 if (currentMapEditor())
3063 currentMapEditor()->setMapLinkStyle("StyleLine");
3066 void Main::formatLinkStyleParabel()
3068 if (currentMapEditor())
3069 currentMapEditor()->setMapLinkStyle("StyleParabel");
3072 void Main::formatLinkStylePolyLine()
3074 if (currentMapEditor())
3075 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3078 void Main::formatLinkStylePolyParabel()
3080 if (currentMapEditor())
3081 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3084 void Main::formatSelectBackColor()
3086 if (currentMapEditor())
3087 currentMapEditor()->selectMapBackgroundColor();
3090 void Main::formatSelectBackImage()
3092 if (currentMapEditor())
3093 currentMapEditor()->selectMapBackgroundImage();
3096 void Main::formatSelectLinkColor()
3098 if (currentMapEditor())
3099 currentMapEditor()->selectMapLinkColor();
3102 void Main::formatSelectSelectionColor()
3104 if (currentMapEditor())
3105 currentMapEditor()->selectMapSelectionColor();
3108 void Main::formatToggleLinkColorHint()
3110 currentMapEditor()->toggleMapLinkColorHint();
3114 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3116 if (currentMapEditor())
3117 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3120 void Main::viewZoomReset()
3122 if (currentMapEditor())
3126 currentMapEditor()->setMatrix( m );
3130 void Main::viewZoomIn()
3132 if (currentMapEditor())
3134 QMatrix m = currentMapEditor()->matrix();
3135 m.scale( 1.25, 1.25 );
3136 currentMapEditor()->setMatrix( m );
3140 void Main::viewZoomOut()
3142 if (currentMapEditor())
3144 QMatrix m = currentMapEditor()->matrix();
3145 m.scale( 0.8, 0.8 );
3146 currentMapEditor()->setMatrix( m );
3150 void Main::viewCenter()
3152 MapEditor *me=currentMapEditor();
3155 me->ensureSelectionVisible();
3159 bool Main::settingsPDF()
3161 // Default browser is set in constructor
3163 QString text = QInputDialog::getText(
3164 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3165 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3167 settings.setValue ("/mainwindow/readerPDF",text);
3172 bool Main::settingsURL()
3174 // Default browser is set in constructor
3176 QString text = QInputDialog::getText(
3177 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3178 settings.value("/mainwindow/readerURL").toString()
3181 settings.setValue ("/mainwindow/readerURL",text);
3185 void Main::settingsMacroDir()
3187 QDir defdir=vymBaseDir;
3188 defdir.cd("macros");
3189 if (!defdir.exists())
3191 QDir dir=QFileDialog::getExistingDirectory (
3193 tr ("Directory with vym macros:"),
3194 settings.value ("/macros/macroDir",defdir.path()).toString()
3197 settings.setValue ("/macros/macroDir",dir.path());
3200 void Main::settingsUndoLevels()
3203 int i = QInputDialog::getInteger(
3205 tr("QInputDialog::getInteger()"),
3206 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3209 settings.setValue ("/mapeditor/stepsTotal",i);
3210 QMessageBox::information( this, tr( "VYM -Information:" ),
3211 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3215 void Main::settingsAutosaveToggle()
3217 settings.setValue ("/mapeditor/autosave/used",actionSettingsAutosaveToggle->isOn() );
3220 void Main::settingsAutosaveTime()
3223 int i = QInputDialog::getInteger(
3225 tr("QInputDialog::getInteger()"),
3226 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3229 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3233 void Main::settingsToggleDelKey()
3235 if (actionSettingsUseDelKey->isOn())
3237 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3240 actionEditDelete->setAccel (QKeySequence (""));
3244 void Main::windowToggleNoteEditor()
3246 if (textEditor->isVisible() )
3247 windowHideNoteEditor();
3249 windowShowNoteEditor();
3252 void Main::windowToggleHistory()
3254 if (historyWindow->isVisible())
3255 historyWindow->hide();
3257 historyWindow->show();
3261 void Main::windowToggleProperty()
3263 if (branchPropertyWindow->isVisible())
3264 branchPropertyWindow->hide();
3266 branchPropertyWindow->show();
3268 if(currentMapEditor())
3270 LinkableMapObj *sel=currentMapEditor()->getSelection();
3271 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3272 typeid(*sel) == typeid(MapCenterObj)))
3274 branchPropertyWindow->setMapEditor(currentMapEditor());
3275 branchPropertyWindow->setBranch((BranchObj*)sel);
3280 branchPropertyWindow->setBranch(NULL);
3283 void Main::windowToggleAntiAlias()
3285 bool b=actionViewToggleAntiAlias->isOn();
3287 for (int i=0;i<tabWidget->count();i++)
3290 me=(MapEditor*)tabWidget->page(i);
3291 me->setAntiAlias(b);
3296 void Main::windowToggleSmoothPixmap()
3298 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3300 for (int i=0;i<tabWidget->count();i++)
3303 me=(MapEditor*)tabWidget->page(i);
3304 me->setSmoothPixmap(b);
3308 void Main::updateHistory(SimpleSettings &undoSet)
3310 historyWindow->update (undoSet);
3313 void Main::updateNoteFlag()
3315 if (currentMapEditor())
3316 currentMapEditor()->updateNoteFlag();
3319 void Main::updateSatellites(MapEditor *me)
3321 branchPropertyWindow->setMapEditor (me);
3324 void Main::updateActions()
3326 MapEditor *me=currentMapEditor();
3329 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3331 // updateActions is also called when NoteEditor is closed
3332 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3333 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3334 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3336 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3337 actionFormatLinkColorHint->setOn(true);
3339 actionFormatLinkColorHint->setOn(false);
3341 switch (me->getMapLinkStyle())
3343 case LinkableMapObj::Line:
3344 actionFormatLinkStyleLine->setOn(true);
3346 case LinkableMapObj::Parabel:
3347 actionFormatLinkStyleParabel->setOn(true);
3349 case LinkableMapObj::PolyLine:
3350 actionFormatLinkStylePolyLine->setOn(true);
3352 case LinkableMapObj::PolyParabel:
3353 actionFormatLinkStylePolyParabel->setOn(true);
3360 QPixmap pix( 16, 16 );
3361 pix.fill( me->getMapBackgroundColor() );
3362 actionFormatBackColor->setIconSet( pix );
3363 pix.fill( me->getSelectionColor() );
3364 actionFormatSelectionColor->setIconSet( pix );
3365 pix.fill( me->getMapDefLinkColor() );
3366 actionFormatLinkColor->setIconSet( pix );
3369 actionFileSave->setEnabled( me->hasChanged() );
3370 if (me->isUndoAvailable())
3371 actionEditUndo->setEnabled( true);
3373 actionEditUndo->setEnabled( false);
3375 if (me->isRedoAvailable())
3376 actionEditRedo->setEnabled( true);
3378 actionEditRedo->setEnabled( false);
3380 LinkableMapObj *selection=me->getSelection();
3383 if ( (typeid(*selection) == typeid(BranchObj)) ||
3384 (typeid(*selection) == typeid(MapCenterObj)) )
3386 BranchObj *bo=(BranchObj*)selection;
3387 // Take care of links
3388 if (bo->countXLinks()==0)
3390 branchXLinksContextMenuEdit->clear();
3391 branchXLinksContextMenuFollow->clear();
3396 branchXLinksContextMenuEdit->clear();
3397 branchXLinksContextMenuFollow->clear();
3398 for (int i=0; i<=bo->countXLinks();i++)
3400 bot=bo->XLinkTargetAt(i);
3403 s=bot->getHeading();
3406 branchXLinksContextMenuFollow->addAction (s);
3407 branchXLinksContextMenuEdit->addAction (s);
3412 standardFlagsDefault->setEnabled (true);
3414 actionEditToggleScroll->setEnabled (true);
3415 if ( bo->isScrolled() )
3416 actionEditToggleScroll->setOn(true);
3418 actionEditToggleScroll->setOn(false);
3420 if ( bo->getURL().isEmpty() )
3422 actionEditOpenURL->setEnabled (false);
3423 actionEditOpenURLTab->setEnabled (false);
3427 actionEditOpenURL->setEnabled (true);
3428 actionEditOpenURLTab->setEnabled (true);
3430 if ( bo->getVymLink().isEmpty() )
3432 actionEditOpenVymLink->setEnabled (false);
3433 actionEditDeleteVymLink->setEnabled (false);
3436 actionEditOpenVymLink->setEnabled (true);
3437 actionEditDeleteVymLink->setEnabled (true);
3440 if (bo->canMoveBranchUp())
3441 actionEditMoveUp->setEnabled (true);
3443 actionEditMoveUp->setEnabled (false);
3444 if (bo->canMoveBranchDown())
3445 actionEditMoveDown->setEnabled (true);
3447 actionEditMoveDown->setEnabled (false);
3450 actionEditToggleHideExport->setEnabled (true);
3451 actionEditToggleHideExport->setOn (bo->hideInExport() );
3453 actionEditCopy->setEnabled (true);
3454 actionEditCut->setEnabled (true);
3455 if (!clipboardEmpty)
3456 actionEditPaste->setEnabled (true);
3458 actionEditPaste->setEnabled (false);
3459 for (int i=0; i<actionListBranches.size(); ++i)
3460 actionListBranches.at(i)->setEnabled(true);
3461 actionEditDelete->setEnabled (true);
3462 actionFormatHideLinkUnselected->setOn
3463 (selection->getHideLinkUnselected());
3465 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3467 FloatObj *fo=(FloatImageObj*)selection;
3469 actionEditOpenURL->setEnabled (false);
3470 actionEditOpenVymLink->setEnabled (false);
3471 actionEditDeleteVymLink->setEnabled (false);
3472 actionEditToggleHideExport->setEnabled (true);
3473 actionEditToggleHideExport->setOn (fo->hideInExport() );
3476 actionEditCopy->setEnabled (true);
3477 actionEditCut->setEnabled (true);
3478 actionEditPaste->setEnabled (false);
3479 for (int i=0; i<actionListBranches.size(); ++i)
3480 actionListBranches.at(i)->setEnabled(false);
3481 actionEditDelete->setEnabled (true);
3482 actionFormatHideLinkUnselected->setOn
3483 ( selection->getHideLinkUnselected());
3484 actionEditMoveUp->setEnabled (false);
3485 actionEditMoveDown->setEnabled (false);
3490 actionEditCopy->setEnabled (false);
3491 actionEditCut->setEnabled (false);
3492 actionEditPaste->setEnabled (false);
3493 for (int i=0; i<actionListBranches.size(); ++i)
3494 actionListBranches.at(i)->setEnabled(false);
3496 actionEditToggleScroll->setEnabled (false);
3497 actionEditOpenURL->setEnabled (false);
3498 actionEditOpenVymLink->setEnabled (false);
3499 actionEditDeleteVymLink->setEnabled (false);
3500 actionEditHeading2URL->setEnabled (false);
3501 actionEditDelete->setEnabled (false);
3502 actionEditMoveUp->setEnabled (false);
3503 actionEditMoveDown->setEnabled (false);
3504 actionEditToggleHideExport->setEnabled (false);
3508 Main::ModMode Main::getModMode()
3510 if (actionModModeColor->isOn()) return ModModeColor;
3511 if (actionModModeCopy->isOn()) return ModModeCopy;
3512 if (actionModModeXLink->isOn()) return ModModeXLink;
3516 bool Main::autoEdit()
3518 return actionSettingsAutoEdit->isOn();
3521 bool Main::autoSelectHeading()
3523 return actionSettingsAutoSelectHeading->isOn();
3526 bool Main::useFlagGroups()
3528 return actionSettingsUseFlagGroups->isOn();
3531 void Main::windowShowNoteEditor()
3533 textEditor->setShowWithMain(true);
3535 actionViewToggleNoteEditor->setOn (true);
3538 void Main::windowHideNoteEditor()
3540 textEditor->setShowWithMain(false);
3542 actionViewToggleNoteEditor->setOn (false);
3545 void Main::setScript (const QString &script)
3547 scriptEditor->setScript (script);
3550 void Main::runScript (const QString &script)
3552 if (currentMapEditor())
3553 currentMapEditor()->runScript (script);
3556 void Main::runScriptEverywhere (const QString &script)
3559 for (int i=0;i<=tabWidget->count() -1;i++)
3561 me=(MapEditor*)tabWidget->page(i);
3562 if (me) me->runScript (script);
3566 void Main::windowNextEditor()
3568 if (tabWidget->currentPageIndex() < tabWidget->count())
3569 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3572 void Main::windowPreviousEditor()
3574 if (tabWidget->currentPageIndex() >0)
3575 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3578 void Main::standardFlagChanged()
3580 if (currentMapEditor())
3581 currentMapEditor()->toggleStandardFlag(sender()->name());
3584 void Main::testFunction()
3586 if (!currentMapEditor()) return;
3587 currentMapEditor()->testFunction();
3590 void Main::testCommand()
3592 if (!currentMapEditor()) return;
3593 scriptEditor->show();
3596 QString com = QInputDialog::getText(
3597 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3598 if (ok) currentMapEditor()->parseAtom(com);
3602 void Main::helpDoc()
3604 QString locale = QLocale::system().name();
3606 if (locale.left(2)=="es")
3607 docname="vym_es.pdf";
3611 QStringList searchList;
3613 #if defined(Q_OS_MACX)
3614 searchList << "./vym.app/Contents";
3616 // default path in SUSE LINUX
3617 searchList <<"/usr/share/doc/packages/vym/doc";
3620 searchList << "doc"; // relative path for easy testing in tarball
3621 searchList << "doc/tex"; // Easy testing working on vym.tex
3622 searchList << "/usr/share/doc/vym"; // Debian
3623 searchList << "/usr/share/doc/packages";// Knoppix
3627 for (int i=0; i<searchList.count(); ++i)
3629 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3630 if (docfile.exists() )
3639 QMessageBox::critical(0,
3640 tr("Critcal error"),
3641 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3646 Process *pdfProc = new Process();
3647 args <<docfile.fileName();
3649 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3650 if ( !pdfProc->waitForStarted() )
3653 QMessageBox::warning(0,
3655 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3656 tr("Please use Settings->")+tr("Set application to open PDF files"));
3663 void Main::helpDemo()
3665 QStringList filters;
3666 filters <<"VYM example map (*.vym)";
3667 QFileDialog *fd=new QFileDialog( this);
3668 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3669 fd->setFileMode (QFileDialog::ExistingFiles);
3670 fd->setFilters (filters);
3671 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3675 if ( fd->exec() == QDialog::Accepted )
3677 lastFileDir=fd->directory().path();
3678 QStringList flist = fd->selectedFiles();
3679 QStringList::Iterator it = flist.begin();
3680 while( it != flist.end() )
3683 fileLoad(*it, NewMap);
3691 void Main::helpAbout()
3694 ad.setName ("aboutwindow");
3695 ad.setMinimumSize(500,500);
3696 ad.resize (QSize (500,500));
3700 void Main::helpAboutQT()
3702 QMessageBox::aboutQt( this, "Qt Application Example" );
3705 void Main::callMacro ()
3707 QAction *action = qobject_cast<QAction *>(sender());
3711 i=action->data().toInt();
3712 QString mDir (settings.value ("macros/macroDir").toString() );
3714 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3716 if ( !f.open( QIODevice::ReadOnly ) )
3718 QMessageBox::warning(0,
3720 tr("Couldn't find a macro at %1.\n").arg(fn)+
3721 tr("Please use Settings->")+tr("Set directory for vym macros"));
3725 QTextStream ts( &f );
3726 QString m= ts.read();
3730 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3731 currentMapEditor()->runScript (m);