1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "branchpropwindow.h"
9 #include "exportoofiledialog.h"
11 #include "exportxhtmldialog.h"
13 #include "flagrowobj.h"
14 #include "historywindow.h"
16 #include "mapeditor.h"
21 #include "texteditor.h"
22 #include "warningdialog.h"
24 extern TextEditor *textEditor;
25 extern Main *mainWindow;
26 extern QString tmpVymDir;
27 extern QString clipboardDir;
28 extern QString clipboardFile;
29 extern bool clipboardEmpty;
30 extern int statusbarTime;
31 extern FlagRowObj* standardFlagsDefault;
32 extern FlagRowObj* systemFlagsDefault;
33 extern QString vymName;
34 extern QString vymVersion;
35 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");
87 // Create direcctory for clipboard
88 clipboardDir=tmpVymDir+"/clipboard";
89 clipboardFile="part.xml";
91 d.mkdir (clipboardDir,true);
92 makeSubDirs (clipboardDir);
97 // Satellite windows //////////////////////////////////////////
100 historyWindow=new HistoryWindow();
101 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
104 branchPropertyWindow = new BranchPropertyWindow();
105 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
107 // Connect TextEditor, so that we can update flags if text changes
108 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
109 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
111 // Connect HistoryWindow, so that we can update flags
112 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
115 // Initialize script editor
116 scriptEditor = new SimpleScriptEditor();
117 scriptEditor->move (50,50);
119 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
120 this, SLOT( runScript( QString ) ) );
123 // Initialize Find window
124 findWindow=new FindWindow(NULL);
125 findWindow->move (x(),y()+70);
126 connect (findWindow, SIGNAL( findButton(QString) ),
127 this, SLOT(editFind(QString) ) );
128 connect (findWindow, SIGNAL( somethingChanged() ),
129 this, SLOT(editFindChanged() ) );
131 // Initialize some settings, which are platform dependant
134 // application to open URLs
135 p="/mainwindow/readerURL";
136 #if defined(Q_OS_LINUX)
137 s=settings.value (p,"konqueror").toString();
139 #if defined(Q_OS_MACX)
140 s=settings.value (p,"/usr/bin/open").toString();
142 s=settings.value (p,"mozilla");
145 settings.setValue( p,s);
147 // application to open PDFs
148 p="/mainwindow/readerPDF";
149 #if defined(Q_OS_LINUX)
150 s=settings.value (p,"acroread").toString();
152 #if defined(Q_OS_MACX)
153 s=settings.value (p,"/usr/bin/open").toString();
155 s=settings.value (p,"acroread").toString();
158 settings.setValue( p,s);
161 // Create tab widget which holds the maps
162 tabWidget= new QTabWidget (this);
163 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
164 this, SLOT( editorChanged( QWidget * ) ) );
166 lineedit=new QLineEdit (this);
169 setCentralWidget(tabWidget);
173 setupFormatActions();
177 setupSettingsActions();
180 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
185 restoreState (settings.value("/mainwindow/state",0).toByteArray());
193 settings.setValue ( "/mainwindow/geometry/size", size() );
194 settings.setValue ( "/mainwindow/geometry/pos", pos() );
195 settings.setValue ("/mainwindow/state",saveState(0));
197 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
198 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
199 settings.setValue( "/version/version", vymVersion );
200 settings.setValue( "/version/builddate", vymBuildDate );
202 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
203 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
204 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
205 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
206 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
207 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
208 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
210 //TODO save scriptEditor settings
212 // call the destructors
214 delete historyWindow;
215 delete branchPropertyWindow;
217 // Remove temporary directory
218 removeDir (QDir(tmpVymDir));
221 void Main::loadCmdLine()
223 /* TODO draw some kind of splashscreen while loading...
229 QStringList flist=options.getFileList();
230 QStringList::Iterator it=flist.begin();
232 while (it !=flist.end() )
234 fileLoad (*it, NewMap);
240 void Main::statusMessage(const QString &s)
242 statusBar()->message (s);
245 void Main::closeEvent (QCloseEvent* )
251 void Main::setupFileActions()
253 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
254 QToolBar *tb = addToolBar( tr ("&Map") );
255 tb->setObjectName ("mapTB");
258 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
259 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
260 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
262 fileMenu->addAction (a);
263 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
265 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
266 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
267 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
268 fileMenu->addAction (a);
269 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
271 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
272 a->setStatusTip (tr( "Open","Status tip File menu" ) );
273 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
275 fileMenu->addAction (a);
276 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
278 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
279 fileMenu->addSeparator();
281 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
282 a->setStatusTip ( tr( "Save","Status tip file menu" ));
283 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
285 fileMenu->addAction (a);
286 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
289 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
290 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
291 fileMenu->addAction (a);
292 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
294 fileMenu->addSeparator();
296 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
298 a = new QAction(tr("KDE Bookmarks"), this);
299 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
300 a->addTo (fileImportMenu);
301 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
303 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
305 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
306 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
307 a->addTo (fileImportMenu);
308 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
311 a = new QAction("Mind Manager...",this);
312 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
313 fileImportMenu->addAction (a);
314 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
316 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
317 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
318 fileImportMenu->addAction (a);
319 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
321 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
323 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
324 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
325 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
326 fileExportMenu->addAction (a);
328 a = new QAction( "Open Office...", this);
329 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
330 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
331 fileExportMenu->addAction (a);
333 a = new QAction( "Webpage (XHTML)...",this );
334 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
335 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
336 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
337 fileExportMenu->addAction (a);
339 a = new QAction( "Text (ASCII)...", this);
340 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
341 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
342 fileExportMenu->addAction (a);
344 a = new QAction( tr("KDE Bookmarks","File menu"), this);
345 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
346 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
347 fileExportMenu->addAction (a);
349 a = new QAction( "Taskjuggler...", this );
350 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
351 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
352 fileExportMenu->addAction (a);
354 a = new QAction( "LaTeX...", this);
355 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
357 fileExportMenu->addAction (a);
359 a = new QAction( "XML..." , this );
360 a->setStatusTip (tr( "Export as %1").arg("XML"));
361 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
362 fileExportMenu->addAction (a);
364 fileMenu->addSeparator();
366 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
367 a->setStatusTip ( tr( "Print" ,"File menu") );
368 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
370 fileMenu->addAction (a);
371 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
374 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
375 a->setStatusTip (tr( "Close Map" ) );
376 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
377 fileMenu->addAction (a);
378 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
380 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
381 a->setStatusTip ( tr( "Exit")+" "+vymName );
382 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
383 fileMenu->addAction (a);
384 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
389 void Main::setupEditActions()
391 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
392 tb->setLabel( "Edit Actions" );
393 tb->setObjectName ("actionsTB");
394 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
398 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
399 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
400 a->setStatusTip (tr( "Undo" ) );
401 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
402 a->setEnabled (false);
404 editMenu->addAction (a);
407 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
408 a->setStatusTip (tr( "Redo" ));
409 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
411 editMenu->addAction (a);
412 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
415 editMenu->addSeparator();
416 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
417 a->setStatusTip ( tr( "Copy" ) );
418 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
419 a->setEnabled (false);
421 editMenu->addAction (a);
422 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
425 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
426 a->setStatusTip ( tr( "Cut" ) );
427 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
428 a->setEnabled (false);
430 editMenu->addAction (a);
432 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
434 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
435 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
436 a->setStatusTip ( tr( "Paste" ) );
437 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
438 a->setEnabled (false);
440 editMenu->addAction (a);
443 // Shortcuts to modify heading:
444 a = new QAction(tr( "Edit heading","Edit menu" ),this);
445 a->setStatusTip ( tr( "edit Heading" ));
446 a->setShortcut ( Qt::Key_Enter); //Edit heading
447 // a->setShortcutContext (Qt::WindowShortcut);
449 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
450 actionListBranches.append(a);
451 a = new QAction( tr( "Edit heading","Edit menu" ), this);
452 a->setStatusTip (tr( "edit Heading" ));
453 a->setShortcut (Qt::Key_Return ); //Edit heading
454 //a->setShortcutContext (Qt::WindowShortcut);
456 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
457 actionListBranches.append(a);
458 editMenu->addAction (a);
460 a = new QAction( tr( "Edit heading","Edit menu" ), this);
461 a->setStatusTip (tr( "edit Heading" ));
462 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
463 a->setShortcutContext (Qt::WindowShortcut);
465 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
466 actionListBranches.append(a);
468 // Shortcut to delete selection
469 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
470 a->setStatusTip (tr( "Delete Selection" ));
471 a->setShortcut ( Qt::Key_Delete); //Delete selection
472 a->setShortcutContext (Qt::WindowShortcut);
474 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
477 // Shortcut to add branch
478 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
479 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
480 alt->setShortcut (Qt::Key_A); //Add branch
481 alt->setShortcutContext (Qt::WindowShortcut);
483 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
484 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
485 a->setStatusTip ( tr( "Add a branch as child of selection" ));
486 a->setShortcut (Qt::Key_Insert); //Add branch
487 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
488 actionListBranches.append(a);
489 #if defined (Q_OS_MACX)
490 // In OSX show different shortcut in menues, the keys work indepently always
491 actionEditAddBranch=alt;
493 actionEditAddBranch=a;
495 editMenu->addAction (actionEditAddBranch);
496 tb->addAction (actionEditAddBranch);
499 // Add branch by inserting it at selection
500 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
501 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
502 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
503 a->setShortcutContext (Qt::WindowShortcut);
505 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
506 a->setEnabled (false);
507 actionListBranches.append(a);
508 actionEditAddBranchBefore=a;
509 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
510 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
511 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
512 a->setShortcutContext (Qt::WindowShortcut);
514 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
515 actionListBranches.append(a);
518 a = new QAction(tr( "Add branch above","Edit menu" ), this);
519 a->setStatusTip ( tr( "Add a branch above selection" ));
520 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
521 a->setShortcutContext (Qt::WindowShortcut);
523 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
524 a->setEnabled (false);
525 actionListBranches.append(a);
526 actionEditAddBranchAbove=a;
527 a = new QAction(tr( "Add branch above","Edit menu" ), this);
528 a->setStatusTip ( tr( "Add a branch above selection" ));
529 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
530 a->setShortcutContext (Qt::WindowShortcut);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
533 actionListBranches.append(a);
536 a = new QAction(tr( "Add branch below","Edit menu" ), this);
537 a->setStatusTip ( tr( "Add a branch below selection" ));
538 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
539 a->setShortcutContext (Qt::WindowShortcut);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
542 a->setEnabled (false);
543 actionListBranches.append(a);
544 actionEditAddBranchBelow=a;
545 a = new QAction(tr( "Add branch below","Edit menu" ), this);
546 a->setStatusTip ( tr( "Add a branch below selection" ));
547 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
548 a->setShortcutContext (Qt::WindowShortcut);
550 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
551 actionListBranches.append(a);
553 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
554 a->setStatusTip ( tr( "Move branch up" ) );
555 a->setShortcut (Qt::Key_PageUp ); // Move branch up
556 a->setEnabled (false);
558 editMenu->addAction (a);
559 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
562 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
563 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
564 a->setStatusTip (tr( "Move branch down" ) );
565 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
566 a->setEnabled (false);
568 editMenu->addAction (a);
569 actionEditMoveDown=a;
572 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
573 a->setShortcut ( Qt::Key_ScrollLock );
574 a->setStatusTip (tr( "Scroll branch" ) );
575 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
577 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
578 alt->setShortcut ( Qt::Key_S ); // Scroll branch
579 alt->setStatusTip (tr( "Scroll branch" ));
580 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
581 #if defined(Q_OS_MACX)
582 actionEditToggleScroll=alt;
584 actionEditToggleScroll=a;
586 actionEditToggleScroll->setEnabled (false);
587 actionEditToggleScroll->setToggleAction(true);
588 tb->addAction (actionEditToggleScroll);
589 editMenu->addAction ( actionEditToggleScroll);
590 editMenu->addAction (actionEditToggleScroll);
593 actionListBranches.append(actionEditToggleScroll);
595 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
596 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
597 editMenu->addAction (a);
598 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
600 editMenu->addSeparator();
602 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
603 a->setStatusTip (tr( "Find" ) );
604 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
605 editMenu->addAction (a);
606 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
608 editMenu->addSeparator();
610 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
611 a->setShortcut (Qt::CTRL + Qt::Key_U );
612 a->setShortcut (tr( "Open URL" ));
615 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
618 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
619 a->setStatusTip (tr( "Open URL in new tab" ));
620 a->setShortcut (Qt::CTRL+Qt::Key_U );
622 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
623 actionEditOpenURLTab=a;
625 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
626 a->setStatusTip (tr( "Open all URLs in subtree" ));
628 actionListBranches.append(a);
629 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
630 actionEditOpenMultipleURLTabs=a;
632 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
633 a->setStatusTip ( tr( "Edit URL" ) );
634 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
635 //a->setShortcut ( Qt::Key_U );
636 a->setShortcutContext (Qt::WindowShortcut);
637 actionListBranches.append(a);
639 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
642 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
643 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
644 a->setEnabled (false);
645 actionListBranches.append(a);
646 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
647 actionEditHeading2URL=a;
649 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
650 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
651 a->setEnabled (false);
652 actionListBranches.append(a);
653 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
654 actionEditBugzilla2URL=a;
656 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
657 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
658 a->setEnabled (false);
659 actionListBranches.append(a);
660 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
661 actionEditFATE2URL=a;
663 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
664 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
666 a->setEnabled (false);
667 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
668 actionEditOpenVymLink=a;
670 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
671 a->setStatusTip ( tr( "Open all vym links in subtree" ));
672 a->setEnabled (false);
673 actionListBranches.append(a);
674 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
675 actionEditOpenMultipleVymLinks=a;
678 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
679 a->setEnabled (false);
680 a->setStatusTip ( tr( "Edit link to another vym map" ));
681 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
682 actionListBranches.append(a);
685 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
686 a->setStatusTip ( tr( "Delete link to another vym map" ));
687 a->setEnabled (false);
688 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
689 actionEditDeleteVymLink=a;
691 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
692 a->setStatusTip ( tr( "Hide object in exports" ) );
693 a->setShortcut (Qt::Key_H );
694 a->setToggleAction(true);
696 a->setEnabled (false);
697 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
698 actionEditToggleHideExport=a;
700 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
701 a->setStatusTip ( tr( "Edit Map Info" ));
702 a->setEnabled (true);
703 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
706 // Import at selection (adding to selection)
707 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
708 a->setStatusTip (tr( "Add map at selection" ));
709 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
710 a->setEnabled (false);
711 actionListBranches.append(a);
712 actionEditImportAdd=a;
714 // Import at selection (replacing selection)
715 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
716 a->setStatusTip (tr( "Replace selection with map" ));
717 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
718 a->setEnabled (false);
719 actionListBranches.append(a);
720 actionEditImportReplace=a;
723 a = new QAction( tr( "Save selection","Edit menu" ), this);
724 a->setStatusTip (tr( "Save selection" ));
725 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
726 a->setEnabled (false);
727 actionListBranches.append(a);
728 actionEditSaveBranch=a;
730 // Only remove branch, not its childs
731 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
732 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
733 a->setShortcut (Qt::ALT + Qt::Key_Delete );
734 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
735 a->setEnabled (false);
737 actionListBranches.append(a);
738 actionEditDeleteKeepChilds=a;
740 // Only remove childs of a branch
741 a = new QAction( tr( "Remove childs","Edit menu" ), this);
742 a->setStatusTip (tr( "Remove childs of branch" ));
743 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
744 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
745 a->setEnabled (false);
746 actionListBranches.append(a);
747 actionEditDeleteChilds=a;
749 // Shortcuts for navigating with cursor:
750 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
751 a->setStatusTip ( tr( "Select upper branch" ));
752 a->setShortcut (Qt::Key_Up );
753 a->setShortcutContext (Qt::WindowShortcut);
755 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
756 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
757 a->setStatusTip (tr( "Select lower branch" ));
758 a->setShortcut ( Qt::Key_Down );
759 a->setShortcutContext (Qt::WindowShortcut);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
762 a = new QAction(tr( "Select left branch","Edit menu" ), this);
763 a->setStatusTip ( tr( "Select left branch" ));
764 a->setShortcut (Qt::Key_Left );
765 a->setShortcutContext (Qt::WindowShortcut);
767 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
768 a = new QAction( tr( "Select child branch","Edit menu" ), this);
769 a->setStatusTip (tr( "Select right branch" ));
770 a->setShortcut (Qt::Key_Right);
771 a->setShortcutContext (Qt::WindowShortcut);
773 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
774 a = new QAction( tr( "Select first branch","Edit menu" ), this);
775 a->setStatusTip (tr( "Select first branch" ));
776 a->setShortcut (Qt::Key_Home );
777 a->setShortcutContext (Qt::WindowShortcut);
779 a->setEnabled (false);
780 editMenu->addAction (a);
781 actionListBranches.append(a);
782 actionEditSelectFirst=a;
783 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
784 a = new QAction( tr( "Select last branch","Edit menu" ),this);
785 a->setStatusTip (tr( "Select last branch" ));
786 a->setShortcut ( Qt::Key_End );
787 a->setShortcutContext (Qt::WindowShortcut);
789 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
790 a->setEnabled (false);
791 editMenu->addAction (a);
792 actionListBranches.append(a);
793 actionEditSelectLast=a;
795 a = new QAction( tr( "Add Image...","Edit menu" ), this);
796 a->setStatusTip (tr( "Add Image" ));
797 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
798 actionEditLoadImage=a;
800 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
801 a->setStatusTip (tr( "Set properties for selection" ));
802 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
803 a->setShortcutContext (Qt::WindowShortcut);
804 a->setToggleAction (true);
806 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
807 actionViewTogglePropertyWindow=a;
811 void Main::setupFormatActions()
813 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
815 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
816 tb->setObjectName ("formatTB");
819 pix.fill (Qt::black);
820 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
821 a->setStatusTip ( tr( "Set Color" ));
822 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
824 formatMenu->addAction (a);
826 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
827 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
828 a->setShortcut (Qt::CTRL + Qt::Key_K );
829 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
830 a->setEnabled (false);
832 formatMenu->addAction (a);
833 actionListBranches.append(a);
834 actionFormatPickColor=a;
836 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
837 a->setStatusTip ( tr( "Color branch" ) );
838 a->setShortcut (Qt::CTRL + Qt::Key_B);
839 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
840 a->setEnabled (false);
842 formatMenu->addAction (a);
843 actionListBranches.append(a);
844 actionFormatColorSubtree=a;
846 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
847 a->setStatusTip ( tr( "Color Subtree" ));
848 a->setShortcut (Qt::CTRL + Qt::Key_T);
849 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
850 a->setEnabled (false);
851 formatMenu->addAction (a);
853 actionListBranches.append(a);
854 actionFormatColorSubtree=a;
856 formatMenu->addSeparator();
857 actionGroupFormatLinkStyles=new QActionGroup ( this);
858 actionGroupFormatLinkStyles->setExclusive (true);
859 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
860 a->setStatusTip (tr( "Line" ));
861 a->setToggleAction(true);
862 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
863 formatMenu->addAction (a);
864 actionFormatLinkStyleLine=a;
865 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
866 a->setStatusTip (tr( "Line" ));
867 a->setToggleAction(true);
868 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
869 formatMenu->addAction (a);
870 actionFormatLinkStyleParabel=a;
871 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
872 a->setStatusTip (tr( "PolyLine" ));
873 a->setToggleAction(true);
874 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
875 formatMenu->addAction (a);
876 actionFormatLinkStylePolyLine=a;
877 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
878 a->setStatusTip (tr( "PolyParabel" ) );
879 a->setToggleAction(true);
880 a->setChecked (true);
881 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
882 formatMenu->addAction (a);
883 actionFormatLinkStylePolyParabel=a;
885 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
886 a->setStatusTip (tr( "Hide link" ));
887 a->setToggleAction(true);
888 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
889 actionFormatHideLinkUnselected=a;
891 formatMenu->addSeparator();
892 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
893 a->setStatusTip (tr( "Use same color for links and headings" ));
894 a->setToggleAction(true);
895 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
896 formatMenu->addAction (a);
897 actionFormatLinkColorHint=a;
899 pix.fill (Qt::white);
900 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
901 a->setStatusTip (tr( "Set Link Color" ));
902 formatMenu->addAction (a);
903 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
904 actionFormatLinkColor=a;
906 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
907 a->setStatusTip (tr( "Set Selection Color" ));
908 formatMenu->addAction (a);
909 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
910 actionFormatSelectionColor=a;
912 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
913 a->setStatusTip (tr( "Set Background Color" ));
914 formatMenu->addAction (a);
915 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
916 actionFormatBackColor=a;
918 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
919 a->setStatusTip (tr( "Set Background image" ));
920 formatMenu->addAction (a);
921 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
922 actionFormatBackImage=a;
926 void Main::setupViewActions()
928 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
929 tb->setLabel( "View Actions" );
930 tb->setObjectName ("viewTB");
931 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
934 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
935 a->setStatusTip ( tr( "Zoom reset" ) );
936 a->setShortcut (Qt::CTRL + Qt::Key_0 );
938 viewMenu->addAction (a);
939 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
941 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
942 a->setStatusTip (tr( "Zoom in" ));
943 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
945 viewMenu->addAction (a);
946 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
948 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
949 a->setStatusTip (tr( "Zoom out" ));
950 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
952 viewMenu->addAction (a);
953 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
955 viewMenu->addSeparator();
957 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
958 a->setStatusTip ( tr( "Show Note Editor" ));
959 a->setShortcut ( Qt::CTRL + Qt::Key_E );
960 a->setToggleAction(true);
962 viewMenu->addAction (a);
963 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
964 actionViewToggleNoteEditor=a;
966 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
967 a->setStatusTip ( tr( "Show History Window" ));
968 a->setShortcut ( Qt::CTRL + Qt::Key_H );
969 a->setToggleAction(true);
971 viewMenu->addAction (a);
972 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
973 actionViewToggleHistoryWindow=a;
975 viewMenu->addAction (actionViewTogglePropertyWindow);
977 viewMenu->addSeparator();
979 a = new QAction(tr( "Antialiasing","View action" ),this );
980 a->setStatusTip ( tr( "Antialiasing" ));
981 a->setToggleAction(true);
982 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
983 viewMenu->addAction (a);
984 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
985 actionViewToggleAntiAlias=a;
987 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
988 a->setStatusTip (a->text());
989 a->setToggleAction(true);
990 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
991 viewMenu->addAction (a);
992 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
993 actionViewToggleSmoothPixmapTransform=a;
995 a = new QAction(tr( "Next Map","View action" ), this);
996 a->setStatusTip (a->text());
997 a->setShortcut (Qt::ALT + Qt::Key_N );
998 viewMenu->addAction (a);
999 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1001 a = new QAction (tr( "Previous Map","View action" ), this );
1002 a->setStatusTip (a->text());
1003 a->setShortcut (Qt::ALT + Qt::Key_P );
1004 viewMenu->addAction (a);
1005 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1009 void Main::setupModeActions()
1011 //QPopupMenu *menu = new QPopupMenu( this );
1012 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1014 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1015 tb->setObjectName ("modesTB");
1017 actionGroupModModes=new QActionGroup ( this);
1018 actionGroupModModes->setExclusive (true);
1019 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1020 a->setShortcut (Qt::Key_J);
1021 a->setStatusTip ( tr( "Use modifier to color branches" ));
1022 a->setToggleAction(true);
1025 actionModModeColor=a;
1027 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1028 a->setShortcut( Qt::Key_K);
1029 a->setStatusTip( tr( "Use modifier to copy" ));
1030 a->setToggleAction(true);
1032 actionModModeCopy=a;
1034 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1035 a->setShortcut (Qt::Key_L);
1036 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1037 a->setToggleAction(true);
1039 actionModModeXLink=a;
1043 void Main::setupFlagActions()
1045 // Create System Flags
1046 systemFlagsDefault = new FlagRowObj ();
1047 systemFlagsDefault->setVisibility (false);
1048 systemFlagsDefault->setName ("systemFlagsDef");
1050 FlagObj *fo = new FlagObj ();
1051 fo->load(QPixmap(flagsPath+"flag-note.png"));
1052 fo->setName("note");
1053 fo->setToolTip(tr("Note","Systemflag"));
1054 systemFlagsDefault->addFlag (fo); // makes deep copy
1056 fo->load(QPixmap(flagsPath+"flag-url.png"));
1058 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1059 systemFlagsDefault->addFlag (fo);
1061 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1062 fo->setName("vymLink");
1063 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1064 systemFlagsDefault->addFlag (fo);
1066 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1067 fo->setName("scrolledright");
1068 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1069 systemFlagsDefault->addFlag (fo);
1071 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1072 fo->setName("tmpUnscrolledright");
1073 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1074 systemFlagsDefault->addFlag (fo);
1076 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1077 fo->setName("hideInExport");
1078 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1079 systemFlagsDefault->addFlag (fo);
1081 // Create Standard Flags
1082 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1083 tb->setObjectName ("standardFlagTB");
1085 standardFlagsDefault = new FlagRowObj ();
1086 standardFlagsDefault->setVisibility (false);
1087 standardFlagsDefault->setName ("standardFlagsDef");
1088 standardFlagsDefault->setToolBar (tb);
1090 fo->load(flagsPath+"flag-exclamationmark.png");
1091 fo->setName ("exclamationmark");
1092 fo->setGroup("standard-mark");
1093 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1096 a->setCheckable(true);
1097 a->setObjectName(fo->getName());
1098 a->setToolTip(tr("Take care!","Standardflag"));
1099 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1100 standardFlagsDefault->addFlag (fo); // makes deep copy
1102 fo->load(flagsPath+"flag-questionmark.png");
1103 fo->setName("questionmark");
1104 fo->setGroup("standard-mark");
1105 a=new QAction (fo->getPixmap(),fo->getName(),this);
1108 a->setCheckable(true);
1109 a->setObjectName(fo->getName());
1110 a->setToolTip(tr("Really?","Standardflag"));
1111 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1112 standardFlagsDefault->addFlag (fo);
1114 fo->load(flagsPath+"flag-hook-green.png");
1115 fo->setName("hook-green");
1116 fo->setGroup("standard-hook");
1117 a=new QAction (fo->getPixmap(),fo->getName(),this);
1120 a->setCheckable(true);
1121 a->setObjectName(fo->getName());
1122 a->setToolTip(tr("ok!","Standardflag"));
1123 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1124 standardFlagsDefault->addFlag (fo);
1126 fo->load(flagsPath+"flag-cross-red.png");
1127 fo->setName("cross-red");
1128 fo->setGroup("standard-hook");
1129 a=new QAction (fo->getPixmap(),fo->getName(),this);
1132 a->setCheckable(true);
1133 a->setObjectName(fo->getName());
1134 a->setToolTip(tr("Not ok!","Standardflag"));
1135 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1136 standardFlagsDefault->addFlag (fo);
1138 fo->load(flagsPath+"flag-stopsign.png");
1139 fo->setName("stopsign");
1140 a=new QAction (fo->getPixmap(),fo->getName(),this);
1143 a->setCheckable(true);
1144 a->setObjectName(fo->getName());
1145 a->setToolTip(tr("This won't work!","Standardflag"));
1146 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1147 standardFlagsDefault->addFlag (fo);
1149 fo->load(flagsPath+"flag-smiley-good.png");
1150 fo->setName("smiley-good");
1151 fo->setGroup("standard-smiley");
1152 a=new QAction (fo->getPixmap(),fo->getName(),this);
1155 a->setCheckable(true);
1156 a->setObjectName(fo->getName());
1157 a->setToolTip(tr("Good","Standardflag"));
1158 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1159 standardFlagsDefault->addFlag (fo);
1161 fo->load(flagsPath+"flag-smiley-sad.png");
1162 fo->setName("smiley-sad");
1163 fo->setGroup("standard-smiley");
1164 a=new QAction (fo->getPixmap(),fo->getName(),this);
1167 a->setCheckable(true);
1168 a->setObjectName(fo->getName());
1169 a->setToolTip(tr("Bad","Standardflag"));
1170 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1171 standardFlagsDefault->addFlag (fo);
1173 fo->load(flagsPath+"flag-smiley-omg.png");
1174 // Original omg.png (in KDE emoticons)
1175 fo->setName("smiley-omg");
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("Oh no!","Standardflag"));
1183 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1184 standardFlagsDefault->addFlag (fo);
1186 fo->load(flagsPath+"flag-kalarm.png");
1187 fo->setName("clock");
1188 a=new QAction (fo->getPixmap(),fo->getName(),this);
1191 a->setCheckable(true);
1192 a->setObjectName(fo->getName());
1193 a->setToolTip(tr("Time critical","Standardflag"));
1194 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1195 standardFlagsDefault->addFlag (fo);
1197 fo->load(flagsPath+"flag-phone.png");
1198 fo->setName("phone");
1199 a=new QAction (fo->getPixmap(),fo->getName(),this);
1202 a->setCheckable(true);
1203 a->setObjectName(fo->getName());
1204 a->setToolTip(tr("Call...","Standardflag"));
1205 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1206 standardFlagsDefault->addFlag (fo);
1208 fo->load(flagsPath+"flag-lamp.png");
1209 fo->setName("lamp");
1210 a=new QAction (fo->getPixmap(),fo->getName(),this);
1213 a->setCheckable(true);
1214 a->setObjectName(fo->getName());
1215 a->setToolTip(tr("Idea!","Standardflag"));
1216 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1217 standardFlagsDefault->addFlag (fo);
1219 fo->load(flagsPath+"flag-arrow-up.png");
1220 fo->setName("arrow-up");
1221 fo->setGroup("standard-arrow");
1222 a=new QAction (fo->getPixmap(),fo->getName(),this);
1225 a->setCheckable(true);
1226 a->setObjectName(fo->getName());
1227 a->setToolTip(tr("Important","Standardflag"));
1228 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1229 standardFlagsDefault->addFlag (fo);
1231 fo->load(flagsPath+"flag-arrow-down.png");
1232 fo->setName("arrow-down");
1233 fo->setGroup("standard-arrow");
1234 a=new QAction (fo->getPixmap(),fo->getName(),this);
1237 a->setCheckable(true);
1238 a->setObjectName(fo->getName());
1239 a->setToolTip(tr("Unimportant","Standardflag"));
1240 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1241 standardFlagsDefault->addFlag (fo);
1243 fo->load(flagsPath+"flag-arrow-2up.png");
1244 fo->setName("2arrow-up");
1245 fo->setGroup("standard-arrow");
1246 a=new QAction (fo->getPixmap(),fo->getName(),this);
1249 a->setCheckable(true);
1250 a->setObjectName(fo->getName());
1251 a->setToolTip(tr("Very important!","Standardflag"));
1252 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1253 standardFlagsDefault->addFlag (fo);
1255 fo->load(flagsPath+"flag-arrow-2down.png");
1256 fo->setName("2arrow-down");
1257 fo->setGroup("standard-arrow");
1258 a=new QAction (fo->getPixmap(),fo->getName(),this);
1261 a->setCheckable(true);
1262 a->setObjectName(fo->getName());
1263 a->setToolTip(tr("Very unimportant!","Standardflag"));
1264 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1265 standardFlagsDefault->addFlag (fo);
1267 fo->load(flagsPath+"flag-thumb-up.png");
1268 fo->setName("thumb-up");
1269 fo->setGroup("standard-thumb");
1270 a=new QAction (fo->getPixmap(),fo->getName(),this);
1273 a->setCheckable(true);
1274 a->setObjectName(fo->getName());
1275 a->setToolTip(tr("I like this","Standardflag"));
1276 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1277 standardFlagsDefault->addFlag (fo);
1279 fo->load(flagsPath+"flag-thumb-down.png");
1280 fo->setName("thumb-down");
1281 fo->setGroup("standard-thumb");
1282 a=new QAction (fo->getPixmap(),fo->getName(),this);
1285 a->setCheckable(true);
1286 a->setObjectName(fo->getName());
1287 a->setToolTip(tr("I do not like this","Standardflag"));
1288 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1289 standardFlagsDefault->addFlag (fo);
1291 fo->load(flagsPath+"flag-rose.png");
1292 fo->setName("rose");
1293 a=new QAction (fo->getPixmap(),fo->getName(),this);
1296 a->setCheckable(true);
1297 a->setObjectName(fo->getName());
1298 a->setToolTip(tr("Rose","Standardflag"));
1299 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1300 standardFlagsDefault->addFlag (fo);
1302 fo->load(flagsPath+"flag-heart.png");
1303 fo->setName("heart");
1304 a=new QAction (fo->getPixmap(),fo->getName(),this);
1306 a->setCheckable(true);
1307 a->setObjectName(fo->getName());
1308 a->setToolTip(tr("I just love... ","Standardflag"));
1309 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1310 standardFlagsDefault->addFlag (fo);
1312 fo->load(flagsPath+"flag-present.png");
1313 fo->setName("present");
1314 a=new QAction (fo->getPixmap(),fo->getName(),this);
1317 a->setCheckable(true);
1318 a->setObjectName(fo->getName());
1319 a->setToolTip(tr("Surprise!","Standardflag"));
1320 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1321 standardFlagsDefault->addFlag (fo);
1323 fo->load(flagsPath+"flag-flash.png");
1324 fo->setName("flash");
1325 a=new QAction (fo->getPixmap(),fo->getName(),this);
1328 a->setCheckable(true);
1329 a->setObjectName(fo->getName());
1330 a->setToolTip(tr("Dangerous","Standardflag"));
1331 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1332 standardFlagsDefault->addFlag (fo);
1334 fo->load(flagsPath+"flag-info.png");
1335 // Original: xsldbg_output.png
1336 fo->setName("info");
1337 a=new QAction (fo->getPixmap(),fo->getName(),this);
1340 a->setCheckable(true);
1341 a->setObjectName(fo->getName());
1342 a->setToolTip(tr("Info","Standardflag"));
1343 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1344 standardFlagsDefault->addFlag (fo);
1346 fo->load(flagsPath+"flag-lifebelt.png");
1347 // Original khelpcenter.png
1348 fo->setName("lifebelt");
1349 a=new QAction (fo->getPixmap(),fo->getName(),this);
1352 a->setCheckable(true);
1353 a->setObjectName(fo->getName());
1354 a->setToolTip(tr("This will help","Standardflag"));
1355 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1356 standardFlagsDefault->addFlag (fo);
1362 void Main::setupSettingsActions()
1364 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1368 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1369 a->setStatusTip ( tr( "Set application to open pdf files"));
1370 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1371 settingsMenu->addAction (a);
1373 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1374 a->setStatusTip( tr( "Set application to open external links"));
1375 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1376 settingsMenu->addAction (a);
1378 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1379 a->setStatusTip( tr( "Set path for macros"));
1380 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1381 settingsMenu->addAction (a);
1383 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1384 a->setStatusTip( tr( "Set number of undo levels"));
1385 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1386 settingsMenu->addAction (a);
1388 settingsMenu->addSeparator();
1390 a = new QAction( tr( "Autosave","Settings action"), this);
1391 a->setStatusTip( tr( "Autosave"));
1392 a->setToggleAction(true);
1393 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1394 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1395 settingsMenu->addAction (a);
1396 actionSettingsAutosaveToggle=a;
1398 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1399 a->setStatusTip( tr( "Autosave time"));
1400 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1401 settingsMenu->addAction (a);
1402 actionSettingsAutosaveTime=a;
1404 settingsMenu->addSeparator();
1406 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1407 a->setStatusTip( tr( "Edit branch after adding it" ));
1408 a->setToggleAction(true);
1409 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1410 settingsMenu->addAction (a);
1411 actionSettingsAutoEdit=a;
1413 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1414 a->setStatusTip( tr( "Select branch after adding it" ));
1415 a->setToggleAction(true);
1416 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1417 settingsMenu->addAction (a);
1418 actionSettingsAutoSelectHeading=a;
1420 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1421 a->setStatusTip( tr( "Select heading before editing" ));
1422 a->setToggleAction(true);
1423 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1424 settingsMenu->addAction (a);
1425 actionSettingsAutoSelectText=a;
1427 a= new QAction( tr( "Delete key","Settings action" ), this);
1428 a->setStatusTip( tr( "Delete key for deleting branches" ));
1429 a->setToggleAction(true);
1430 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1431 settingsMenu->addAction (a);
1432 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1433 actionSettingsUseDelKey=a;
1435 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1436 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1437 a->setToggleAction(true);
1438 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1439 settingsMenu->addAction (a);
1440 actionSettingsUseFlagGroups=a;
1442 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1443 a->setStatusTip( tr( "Use hide flag during exports " ));
1444 a->setToggleAction(true);
1445 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1446 settingsMenu->addAction (a);
1447 actionSettingsUseHideExport=a;
1451 void Main::setupTestActions()
1453 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1456 a = new QAction( "Test function" , this);
1457 a->setStatusTip( "Call test function" );
1458 //a->setShortcut (Qt::Key_F4 );
1459 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1460 testMenu->addAction (a);
1461 a = new QAction( "Command" , this);
1462 a->setStatusTip( "Enter command to call in editor" );
1463 //a->setShortcut (Qt::Key_F5 );
1464 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1465 testMenu->addAction (a);
1469 void Main::setupHelpActions()
1471 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1474 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1475 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1476 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1477 helpMenu->addAction (a);
1479 a = new QAction( tr( "About VYM","Help action" ), this);
1480 a->setStatusTip( tr( "About VYM")+vymName);
1481 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1482 helpMenu->addAction (a);
1484 a = new QAction( tr( "About QT","Help action" ), this);
1485 a->setStatusTip( tr( "Information about QT toolkit" ));
1486 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1487 helpMenu->addAction (a);
1491 void Main::setupContextMenus()
1495 // Context Menu for branch or mapcenter
1496 branchContextMenu =new QMenu (this);
1497 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1498 branchContextMenu->addSeparator();
1501 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1502 branchAddContextMenu->addAction (actionEditPaste );
1503 branchAddContextMenu->addAction ( actionEditAddBranch );
1504 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1505 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1506 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1507 branchAddContextMenu->addSeparator();
1508 branchAddContextMenu->addAction ( actionEditImportAdd );
1509 branchAddContextMenu->addAction ( actionEditImportReplace );
1512 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1513 branchRemoveContextMenu->addAction (actionEditCut);
1514 branchRemoveContextMenu->addAction ( actionEditDelete );
1515 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1516 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1519 actionEditSaveBranch->addTo( branchContextMenu );
1521 branchContextMenu->addSeparator();
1522 branchContextMenu->addAction ( actionEditLoadImage);
1524 // Submenu for Links (URLs, vymLinks)
1525 branchLinksContextMenu =new QMenu (this);
1527 branchContextMenu->addSeparator();
1528 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1529 branchLinksContextMenu->addAction ( actionEditOpenURL );
1530 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1531 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1532 branchLinksContextMenu->addAction ( actionEditURL );
1533 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1534 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1535 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1537 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1539 branchLinksContextMenu->addSeparator();
1540 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1541 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1542 branchLinksContextMenu->addAction ( actionEditVymLink );
1543 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1546 // Context Menu for XLinks in a branch menu
1547 // This will be populated "on demand" in MapEditor::updateActions
1548 branchContextMenu->addSeparator();
1549 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1550 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1551 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1552 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1555 // Context menu for floatimage
1556 floatimageContextMenu =new QMenu (this);
1557 a= new QAction (tr ("Save image","Context action"),this);
1558 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1559 floatimageContextMenu->addAction (a);
1561 floatimageContextMenu->addSeparator();
1562 actionEditCopy->addTo( floatimageContextMenu );
1563 actionEditCut->addTo( floatimageContextMenu );
1565 floatimageContextMenu->addSeparator();
1566 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1569 // Context menu for canvas
1570 canvasContextMenu =new QMenu (this);
1571 actionEditMapInfo->addTo( canvasContextMenu );
1572 canvasContextMenu->insertSeparator();
1573 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1574 canvasContextMenu->insertSeparator();
1575 actionFormatLinkColorHint->addTo( canvasContextMenu );
1576 actionFormatLinkColor->addTo( canvasContextMenu );
1577 actionFormatSelectionColor->addTo( canvasContextMenu );
1578 actionFormatBackColor->addTo( canvasContextMenu );
1579 actionFormatBackImage->addTo( canvasContextMenu );
1581 // Menu for last opened files
1583 for (int i = 0; i < MaxRecentFiles; ++i)
1585 recentFileActions[i] = new QAction(this);
1586 recentFileActions[i]->setVisible(false);
1587 fileLastMapsMenu->addAction(recentFileActions[i]);
1588 connect(recentFileActions[i], SIGNAL(triggered()),
1589 this, SLOT(fileLoadRecent()));
1591 setupRecentMapsMenu();
1594 void Main::setupRecentMapsMenu()
1596 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1598 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1600 for (int i = 0; i < numRecentFiles; ++i) {
1601 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1602 recentFileActions[i]->setText(text);
1603 recentFileActions[i]->setData(files[i]);
1604 recentFileActions[i]->setVisible(true);
1606 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1607 recentFileActions[j]->setVisible(false);
1610 void Main::setupMacros()
1612 for (int i = 0; i <= 11; i++)
1614 macroActions[i] = new QAction(this);
1615 macroActions[i]->setData(i);
1616 addAction (macroActions[i]);
1617 connect(macroActions[i], SIGNAL(triggered()),
1618 this, SLOT(callMacro()));
1620 macroActions[0]->setShortcut ( Qt::Key_F1 );
1621 macroActions[1]->setShortcut ( Qt::Key_F2 );
1622 macroActions[2]->setShortcut ( Qt::Key_F3 );
1623 macroActions[3]->setShortcut ( Qt::Key_F4 );
1624 macroActions[4]->setShortcut ( Qt::Key_F5 );
1625 macroActions[5]->setShortcut ( Qt::Key_F6 );
1626 macroActions[6]->setShortcut ( Qt::Key_F7 );
1627 macroActions[7]->setShortcut ( Qt::Key_F8 );
1628 macroActions[8]->setShortcut ( Qt::Key_F9 );
1629 macroActions[9]->setShortcut ( Qt::Key_F10 );
1630 macroActions[10]->setShortcut ( Qt::Key_F11 );
1631 macroActions[11]->setShortcut ( Qt::Key_F12 );
1634 void Main::hideEvent (QHideEvent * )
1636 if (!textEditor->isMinimized() ) textEditor->hide();
1639 void Main::showEvent (QShowEvent * )
1641 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1644 bool Main::reallyWriteDirectory(const QString &dir)
1646 QStringList eList = QDir(dir).entryList();
1647 if (eList.first() ==".") eList.pop_front(); // remove "."
1648 if (eList.first() =="..") eList.pop_front(); // remove "."
1649 if (!eList.isEmpty())
1651 QMessageBox mb( vymName,
1652 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1653 QMessageBox::Warning,
1655 QMessageBox::Cancel | QMessageBox::Default,
1656 QMessageBox::QMessageBox::NoButton );
1658 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1659 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1662 case QMessageBox::Yes:
1665 case QMessageBox::Cancel:
1673 QString Main::browseDirectory (const QString &caption)
1675 QFileDialog fd(this,caption);
1676 fd.setMode (QFileDialog::DirectoryOnly);
1677 fd.setCaption(vymName+ " - "+caption);
1678 fd.setDir (lastFileDir);
1681 if ( fd.exec() == QDialog::Accepted )
1682 return fd.selectedFile();
1687 MapEditor* Main::currentMapEditor() const
1689 if ( tabWidget->currentPage() &&
1690 tabWidget->currentPage()->inherits( "MapEditor" ) )
1691 return (MapEditor*)tabWidget->currentPage();
1696 void Main::editorChanged(QWidget *)
1698 // Unselect all possibly selected objects
1699 // (Important to update note editor)
1701 for (int i=0;i<=tabWidget->count() -1;i++)
1704 me=(MapEditor*)tabWidget->page(i);
1707 currentMapEditor()->reselect();
1709 // Update actions to in menus and toolbars according to editor
1713 void Main::fileNew()
1715 QString fn="unnamed";
1716 MapEditor* me = new MapEditor ( NULL);
1717 tabWidget->addTab (me,fn);
1718 tabWidget->showPage(me);
1719 me->viewport()->setFocus();
1720 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1721 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1723 // For the very first map we do not have flagrows yet...
1727 void Main::fileNewCopy()
1729 QString fn="unnamed";
1730 MapEditor* oldME =currentMapEditor();
1734 MapEditor* newME = new MapEditor ( NULL);
1737 tabWidget->addTab (newME,fn);
1738 tabWidget->showPage(newME);
1739 newME->viewport()->setFocus();
1740 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1741 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1742 // For the very first map we do not have flagrows yet...
1743 newME->select("mc:");
1744 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace);
1750 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1752 ErrorCode err=success;
1754 // fn is usually the archive, mapfile the file after uncompressing
1757 // Make fn absolute (needed for unzip)
1758 fn=QDir (fn).absPath();
1764 // Check, if map is already loaded
1766 while (i<=tabWidget->count() -1)
1768 me=(MapEditor*)tabWidget->page(i);
1769 if (me->getFilePath() == fn)
1771 // Already there, ask for confirmation
1772 QMessageBox mb( vymName,
1773 tr("The map %1\nis already opened."
1774 "Opening the same map in multiple editors may lead \n"
1775 "to confusion when finishing working with vym."
1776 "Do you want to").arg(fn),
1777 QMessageBox::Warning,
1778 QMessageBox::Yes | QMessageBox::Default,
1779 QMessageBox::Cancel | QMessageBox::Escape,
1780 QMessageBox::NoButton);
1781 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1782 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1785 case QMessageBox::Yes:
1787 i=tabWidget->count();
1789 case QMessageBox::Cancel:
1801 if ( !fn.isEmpty() )
1803 me = currentMapEditor();
1804 int tabIndex=tabWidget->currentPageIndex();
1805 // Check first, if mapeditor exists
1806 // If it is not default AND we want a new map,
1807 // create a new mapeditor in a new tab
1808 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1810 me= new MapEditor ( NULL);
1811 tabWidget->addTab (me,fn);
1812 tabIndex=tabWidget->indexOf (me);
1813 tabWidget->setCurrentPage (tabIndex);
1814 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1815 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1818 // Check, if file exists (important for creating new files
1819 // from command line
1820 if (!QFile(fn).exists() )
1822 QMessageBox mb( vymName,
1823 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1824 QMessageBox::Question,
1826 QMessageBox::Cancel | QMessageBox::Default,
1827 QMessageBox::NoButton );
1829 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1830 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1833 case QMessageBox::Yes:
1835 currentMapEditor()->setFilePath(fn);
1836 tabWidget->setTabLabel (currentMapEditor(),
1837 currentMapEditor()->getFileName() );
1838 statusBar()->message( "Created " + fn , statusbarTime );
1841 case QMessageBox::Cancel:
1842 // don't create new map
1843 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1850 //tabWidget->currentPage() won't be NULL here, because of above...
1851 tabWidget->showPage(me);
1852 me->viewport()->setFocus();
1854 // Create temporary directory for packing
1856 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1859 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1860 tr("Couldn't create temporary directory before load\n"));
1864 // Try to unzip file
1865 err=unzipDir (tmpMapDir,fn);
1869 me->setZipped(false);
1872 me->setZipped(true);
1874 // Look for mapname.xml
1875 mapfile= fn.left(fn.findRev(".",-1,true));
1876 mapfile=mapfile.section( '/', -1 );
1877 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1878 if (!file.exists() )
1880 // mapname.xml does not exist, well,
1881 // maybe someone renamed the mapname.vym file...
1882 // Try to find any .xml in the toplevel
1883 // directory of the .vym file
1884 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1885 if (flist.count()==1)
1887 // Only one entry, take this one
1888 mapfile=tmpMapDir + "/"+flist.first();
1891 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1892 *it=tmpMapDir + "/" + *it;
1893 // TODO Multiple entries, load all (but only the first one into this ME)
1894 //mainWindow->fileLoadFromTmp (flist);
1895 //returnCode=1; // Silently forget this attempt to load
1896 qWarning ("MainWindow::load (fn) multimap found...");
1899 if (flist.isEmpty() )
1901 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1902 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1905 } //file doesn't exist
1907 mapfile=file.name();
1912 // Save existing filename in case we import
1913 QString fn_org=me->getFilePath();
1915 // Finally load map into mapEditor
1916 me->setFilePath (mapfile,fn);
1917 err=me->load(mapfile,lmode);
1919 // Restore old (maybe empty) filepath, if this is an import
1921 me->setFilePath (fn_org);
1924 // Finally check for errors and go home
1927 if (lmode==NewMap) fileCloseMap();
1928 statusBar()->message( "Could not load " + fn, statusbarTime );
1933 me->setFilePath (fn);
1934 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1935 if (fn.left(9)!="/tmp/vym-")
1937 // Only append to lastMaps if not loaded from a tmpDir
1938 // e.g. imported bookmarks are in a tmpDir
1939 addRecentMap(me->getFilePath() );
1941 actionFilePrint->setEnabled (true);
1943 statusBar()->message( "Loaded " + fn, statusbarTime );
1947 removeDir (QDir(tmpMapDir));
1953 void Main::fileLoad(const LoadMode &lmode)
1955 QStringList filters;
1956 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1957 QFileDialog *fd=new QFileDialog( this);
1958 fd->setDir (lastFileDir);
1959 fd->setFileMode (QFileDialog::ExistingFiles);
1960 fd->setFilters (filters);
1964 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1967 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1970 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1976 if ( fd->exec() == QDialog::Accepted )
1978 lastFileDir=fd->directory().path();
1979 QStringList flist = fd->selectedFiles();
1980 QStringList::Iterator it = flist.begin();
1981 while( it != flist.end() )
1984 fileLoad(*it, lmode);
1991 void Main::fileLoad()
1996 void Main::fileLoadRecent()
1998 QAction *action = qobject_cast<QAction *>(sender());
2000 fileLoad (action->data().toString(), NewMap);
2003 void Main::addRecentMap (const QString &fileName)
2006 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2007 files.removeAll(fileName);
2008 files.prepend(fileName);
2009 while (files.size() > MaxRecentFiles)
2012 settings.setValue("/mainwindow/recentFileList", files);
2014 setupRecentMapsMenu();
2017 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
2019 // tmp dir for zipping
2023 ErrorCode err=success;
2025 QString safeFilePath;
2027 bool saveZipped=me->saveZipped();
2031 QString fn=me->getFilePath();
2032 // filename=unnamed, filepath="" in constructor of mapEditor
2033 if ( !fn.isEmpty() )
2035 // We have a filepath, go on saving
2036 // First remove existing file, we
2037 // don't want to add to old zip archives
2041 QMessageBox::warning( 0, tr( "Save Error" ),
2042 fn+ tr("\ncould not be removed before saving"));
2044 // Look, if we should zip the data:
2047 QMessageBox mb( vymName,
2048 tr("The map %1\ndid not use the compressed "
2049 "vym file format.\nWriting it uncompressed will also write images \n"
2050 "and flags and thus may overwrite files in the "
2051 "given directory\n\nDo you want to write the map").arg(fn),
2052 QMessageBox::Warning,
2053 QMessageBox::Yes | QMessageBox::Default,
2055 QMessageBox::Cancel | QMessageBox::Escape);
2056 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2057 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2058 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2061 case QMessageBox::Yes:
2062 // save compressed (default file format)
2065 case QMessageBox::No:
2066 // save uncompressed
2069 case QMessageBox::Cancel:
2078 // Create temporary directory for packing
2080 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2083 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2084 tr("Couldn't create temporary directory before save\n"));
2088 safeFilePath=me->getFilePath();
2089 me->setFilePath (tmpMapDir+"/"+
2090 me->getMapName()+ ".xml",
2092 me->save (savemode);
2093 me->setFilePath (safeFilePath);
2095 zipDir (tmpMapDir,fn);
2100 safeFilePath=me->getFilePath();
2101 me->setFilePath (fn, safeFilePath);
2102 me->save (savemode);
2103 me->setFilePath (safeFilePath);
2105 } // filepath available
2108 // We have no filepath yet,
2109 // call fileSaveAs() now, this will call fileSave()
2111 // First switch to editor
2112 tabWidget->setCurrentWidget (me);
2113 fileSaveAs(savemode);
2117 if (saveZipped && !tmpMapDir.isEmpty())
2119 removeDir (QDir(tmpMapDir));
2123 statusBar()->message(
2124 tr("Saved %1").arg(me->getFilePath()),
2126 addRecentMap (me->getFilePath() );
2128 statusBar()->message(
2129 tr("Couldn't save ").arg(me->getFilePath()),
2133 void Main::fileSave()
2135 fileSave (currentMapEditor(), CompleteMap);
2138 void Main::fileSave(MapEditor *me)
2140 fileSave (me,CompleteMap);
2143 void Main::fileSaveAs(const SaveMode& savemode)
2147 if (currentMapEditor())
2149 if (savemode==CompleteMap)
2150 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2152 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2153 if ( !fn.isEmpty() )
2155 // Check for existing file
2156 if (QFile (fn).exists())
2158 QMessageBox mb( vymName,
2159 tr("The file %1\nexists already. Do you want to").arg(fn),
2160 QMessageBox::Warning,
2161 QMessageBox::Yes | QMessageBox::Default,
2162 QMessageBox::Cancel | QMessageBox::Escape,
2163 QMessageBox::NoButton);
2164 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2165 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2168 case QMessageBox::Yes:
2171 case QMessageBox::Cancel:
2178 // New file, add extension to filename, if missing
2179 // This is always .vym or .vyp, depending on savemode
2180 if (savemode==CompleteMap)
2182 if (!fn.contains (".vym") && !fn.contains (".xml"))
2186 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2195 currentMapEditor()->setFilePath(fn);
2196 fileSave(currentMapEditor(), savemode);
2199 if (savemode==CompleteMap)
2200 tabWidget->setTabLabel (currentMapEditor(),
2201 currentMapEditor()->getFileName() );
2207 void Main::fileSaveAs()
2209 fileSaveAs (CompleteMap);
2212 void Main::fileImportKDEBookmarks()
2214 ImportKDEBookmarks im;
2216 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2217 currentMapEditor()->setFilePath ("");
2220 void Main::fileImportFirefoxBookmarks()
2222 Q3FileDialog *fd=new Q3FileDialog( this);
2223 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2224 fd->setMode (Q3FileDialog::ExistingFiles);
2225 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2226 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2229 if ( fd->exec() == QDialog::Accepted )
2231 ImportFirefoxBookmarks im;
2232 QStringList flist = fd->selectedFiles();
2233 QStringList::Iterator it = flist.begin();
2234 while( it != flist.end() )
2237 if (im.transform() &&
2238 success==fileLoad (im.getTransformedFile(),NewMap) &&
2239 currentMapEditor() )
2240 currentMapEditor()->setFilePath ("");
2247 void Main::fileImportMM()
2251 Q3FileDialog *fd=new Q3FileDialog( this);
2252 fd->setDir (lastFileDir);
2253 fd->setMode (Q3FileDialog::ExistingFiles);
2254 fd->addFilter ("Mind Manager (*.mmap)");
2255 fd->setCaption(tr("Import")+" "+"Mind Manager");
2258 if ( fd->exec() == QDialog::Accepted )
2260 lastFileDir=fd->dirPath();
2261 QStringList flist = fd->selectedFiles();
2262 QStringList::Iterator it = flist.begin();
2263 while( it != flist.end() )
2266 if (im.transform() &&
2267 success==fileLoad (im.getTransformedFile(),NewMap) &&
2268 currentMapEditor() )
2269 currentMapEditor()->setFilePath ("");
2278 void Main::fileImportDir()
2280 if (currentMapEditor())
2281 currentMapEditor()->importDir();
2284 void Main::fileExportXML()
2286 if (currentMapEditor())
2288 QString dir=browseDirectory(tr("Export XML to directory"));
2289 if (dir !="" && reallyWriteDirectory(dir) )
2290 currentMapEditor()->exportXML(dir);
2295 void Main::fileExportXHTML()
2297 MapEditor *me=currentMapEditor();
2301 ExportXHTMLDialog dia(this);
2302 dia.setFilePath (me->getFilePath() );
2303 dia.setMapName (me->getMapName() );
2306 if (dia.exec()==QDialog::Accepted)
2308 QString dir=dia.getDir();
2309 // Check, if warnings should be used before overwriting
2310 // the output directory
2312 warn.showCancelButton (true);
2313 warn.setText(QString(
2314 "The directory %1 is not empty.\n"
2315 "Do you risk to overwrite some of its contents?").arg(dir));
2316 warn.setCaption("Warning: Directory not empty");
2317 warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
2318 if (warn.exec()==QDialog::Accepted)
2320 me->exportXML (dia.getDir() );
2321 dia.doExport(me->getMapName() );
2322 if (dia.hasChanged())
2329 void Main::fileExportImage()
2331 MapEditor *me=currentMapEditor();
2335 QFileDialog *fd=new QFileDialog (this);
2336 fd->setCaption (tr("Export map as image"));
2337 fd->setDirectory (lastImageDir);
2338 fd->setFileMode(QFileDialog::AnyFile);
2339 fd->setFilters (imageIO.getFilters() );
2342 fl=fd->selectedFiles();
2343 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2348 void Main::fileExportASCII()
2350 MapEditor *me=currentMapEditor();
2354 ex.setMapCenter(me->getMapCenter());
2355 ex.addFilter ("TXT (*.txt)");
2356 ex.setDir(lastImageDir);
2357 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2358 if (ex.execDialog() )
2360 me->setExportMode(true);
2362 me->setExportMode(false);
2367 void Main::fileExportLaTeX()
2369 MapEditor *me=currentMapEditor();
2373 ex.setMapCenter(me->getMapCenter());
2374 ex.addFilter ("Tex (*.tex)");
2375 ex.setDir(lastImageDir);
2376 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2377 if (ex.execDialog() )
2379 me->setExportMode(true);
2381 me->setExportMode(false);
2386 void Main::fileExportKDEBookmarks()
2388 ExportKDEBookmarks ex;
2389 MapEditor *me=currentMapEditor();
2392 ex.setMapCenter (me->getMapCenter() );
2397 void Main::fileExportTaskjuggler()
2399 ExportTaskjuggler ex;
2400 MapEditor *me=currentMapEditor();
2403 ex.setMapCenter (me->getMapCenter() );
2404 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2405 ex.setDir(lastImageDir);
2406 ex.addFilter ("Taskjuggler (*.tjp)");
2407 if (ex.execDialog() )
2409 me->setExportMode(true);
2411 me->setExportMode(false);
2416 void Main::fileExportOOPresentation()
2418 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2419 // TODO add preview in dialog
2420 //ImagePreview *p =new ImagePreview (fd);
2421 //fd->setContentsPreviewEnabled( TRUE );
2422 //fd->setContentsPreview( p, p );
2423 //fd->setPreviewMode( QFileDialog::Contents );
2424 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2425 fd->setDir (QDir().current());
2426 if (fd->foundConfig())
2430 if ( fd->exec() == QDialog::Accepted )
2432 QString fn=fd->selectedFile();
2433 if (!fn.contains (".odp"))
2436 //lastImageDir=fn.left(fn.findRev ("/"));
2437 if (currentMapEditor())
2438 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2442 QMessageBox::warning(0,
2444 tr("Couldn't find configuration for export to Open Office\n"));
2448 void Main::fileCloseMap()
2450 if (currentMapEditor())
2452 if (currentMapEditor()->hasChanged())
2454 QMessageBox mb( vymName,
2455 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2456 QMessageBox::Warning,
2457 QMessageBox::Yes | QMessageBox::Default,
2459 QMessageBox::Cancel | QMessageBox::Escape );
2460 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2461 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2464 case QMessageBox::Yes:
2466 fileSave(currentMapEditor(), CompleteMap);
2468 case QMessageBox::No:
2469 // close without saving
2471 case QMessageBox::Cancel:
2476 currentMapEditor()->closeMap();
2477 tabWidget->removePage(currentMapEditor());
2478 if (tabWidget->count()==0)
2479 actionFilePrint->setEnabled (false);
2483 void Main::filePrint()
2485 if (currentMapEditor())
2486 currentMapEditor()->print();
2489 void Main::fileExitVYM()
2491 // Check if one or more editors have changed
2494 for (i=0;i<=tabWidget->count() -1;i++)
2497 me=(MapEditor*)tabWidget->page(i);
2499 // If something changed, ask what to do
2500 if (me->hasChanged())
2502 tabWidget->setCurrentPage(i);
2503 QMessageBox mb( vymName,
2504 tr("This map is not saved yet. Do you want to"),
2505 QMessageBox::Warning,
2506 QMessageBox::Yes | QMessageBox::Default,
2508 QMessageBox::Cancel | QMessageBox::Escape );
2509 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2510 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2513 mb.setActiveWindow();
2514 switch( mb.exec() ) {
2515 case QMessageBox::Yes:
2516 // save (the changed editors) and exit
2517 fileSave(currentMapEditor(), CompleteMap);
2519 case QMessageBox::No:
2520 // exit without saving
2522 case QMessageBox::Cancel:
2523 // don't save and don't exit
2527 } // loop over all MEs
2531 void Main::editUndo()
2533 if (currentMapEditor())
2534 currentMapEditor()->undo();
2537 void Main::editRedo()
2539 if (currentMapEditor())
2540 currentMapEditor()->redo();
2543 void Main::gotoHistoryStep (int i)
2545 if (currentMapEditor())
2546 currentMapEditor()->gotoHistoryStep (i);
2549 void Main::editCopy()
2551 if (currentMapEditor())
2552 currentMapEditor()->copy();
2555 void Main::editPaste()
2557 if (currentMapEditor())
2558 currentMapEditor()->paste();
2561 void Main::editCut()
2563 if (currentMapEditor())
2564 currentMapEditor()->cut();
2567 void Main::editOpenFindWindow()
2569 findWindow->popup();
2570 findWindow->raise();
2571 findWindow->setActiveWindow();
2574 void Main::editFind(QString s)
2577 BranchObj *bo=currentMapEditor()->findText(s, cs);
2580 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2583 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2584 tr("No matches found for \"%1\"").arg(s));
2588 void Main::editFindChanged()
2589 { // Notify editor, to abort the current find process
2590 currentMapEditor()->findReset();
2593 void Main::openTabs(QStringList urls)
2595 if (!urls.isEmpty())
2599 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2601 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2603 QString u=urls.takeFirst();
2604 procBrowser = new QProcess( this );
2606 procBrowser->start(browser,args);
2607 if ( !procBrowser->waitForStarted())
2609 // try to set path to browser
2610 QMessageBox::warning(0,
2612 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2613 tr("Please use Settings->")+tr("Set application to open an URL"));
2618 if (browser.contains("konqueror"))
2620 for (int i=0; i<urls.size(); i++)
2623 // Try to open new tab in existing konqueror started previously by vym
2624 p=new QProcess (this);
2626 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2627 "konqueror-mainwindow#1"<<
2630 p->start ("dcop",args);
2631 if ( !p->waitForStarted() ) success=false;
2634 QMessageBox::warning(0,
2636 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2638 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2640 for (int i=0; i<urls.size(); i++)
2642 // Try to open new tab in firefox
2643 p=new QProcess (this);
2644 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2645 p->start (browser,args);
2646 if ( !p->waitForStarted() ) success=false;
2649 QMessageBox::warning(0,
2651 tr("Couldn't start %1 to open a new tab").arg(browser));
2654 QMessageBox::warning(0,
2656 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2660 void Main::editOpenURL()
2663 if (currentMapEditor())
2665 QString url=currentMapEditor()->getURL();
2667 if (url=="") return;
2668 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2669 procBrowser = new QProcess( this );
2671 procBrowser->start(browser,args);
2672 if ( !procBrowser->waitForStarted())
2674 // try to set path to browser
2675 QMessageBox::warning(0,
2677 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2678 tr("Please use Settings->")+tr("Set application to open an URL"));
2683 void Main::editOpenURLTab()
2685 if (currentMapEditor())
2688 urls.append(currentMapEditor()->getURL());
2692 void Main::editOpenMultipleURLTabs()
2694 if (currentMapEditor())
2697 urls=currentMapEditor()->getURLs();
2703 void Main::editURL()
2705 if (currentMapEditor())
2706 currentMapEditor()->editURL();
2709 void Main::editHeading2URL()
2711 if (currentMapEditor())
2712 currentMapEditor()->editHeading2URL();
2715 void Main::editBugzilla2URL()
2717 if (currentMapEditor())
2718 currentMapEditor()->editBugzilla2URL();
2721 void Main::editFATE2URL()
2723 if (currentMapEditor())
2724 currentMapEditor()->editFATE2URL();
2727 void Main::editHeadingFinished()
2729 // only called from editHeading(), so there is a currentME
2730 MapEditor *me=currentMapEditor();
2733 me->setStateEditHeading (false);
2734 QPoint p; //Not used here, only to find out pos of branch
2736 QString s=me->getHeading(ok,p);
2738 #if defined(Q_OS_MACX)
2740 if (ok && s!=lineedit->text())
2741 me->setHeading(lineedit->text());
2743 lineedit->releaseKeyboard();
2747 if (!prevSelection.isEmpty()) me->select(prevSelection);
2752 void Main::editHeading()
2754 if (currentMapEditor())
2756 MapEditor *me=currentMapEditor();
2757 QString oldSel=me->getSelectString();
2759 if (lineedit->isVisible())
2760 editHeadingFinished();
2765 QString s=currentMapEditor()->getHeading(ok,p);
2769 me->setStateEditHeading (true);
2770 #if defined(Q_OS_MACX)
2771 p=currentMapEditor()->mapTo (this,p);
2772 QDialog *d =new QDialog(NULL);
2773 QLineEdit *le=new QLineEdit (d);
2774 d->setWindowFlags (Qt::FramelessWindowHint);
2775 d->setGeometry(p.x(),p.y(),230,25);
2776 le->resize (d->width()-10,d->height());
2779 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2780 d->activateWindow();
2782 currentMapEditor()->setHeading (le->text());
2785 editHeadingFinished();
2787 p=currentMapEditor()->mapTo (this,p);
2788 lineedit->setGeometry(p.x(),p.y(),230,25);
2789 lineedit->setText(s);
2790 lineedit->setCursorPosition(1);
2791 lineedit->selectAll();
2793 lineedit->grabKeyboard();
2794 lineedit->setFocus();
2798 } // currentMapEditor()
2801 void Main::openVymLinks(const QStringList &vl)
2803 for (int j=0; j<vl.size(); j++)
2805 // compare path with already loaded maps
2809 for (i=0;i<=tabWidget->count() -1;i++)
2811 me=(MapEditor*)tabWidget->page(i);
2812 if (vl.at(j)==me->getFilePath() )
2821 if (!QFile(vl.at(j)).exists() )
2822 QMessageBox::critical( 0, tr( "Critical Error" ),
2823 tr("Couldn't open map %1").arg(vl.at(j)));
2826 fileLoad (vl.at(j), NewMap);
2827 tabWidget->setCurrentPage (tabWidget->count()-1);
2830 // Go to tab containing the map
2831 tabWidget->setCurrentPage (index);
2835 void Main::editOpenVymLink()
2837 if (currentMapEditor())
2840 vl.append(currentMapEditor()->getVymLink());
2845 void Main::editOpenMultipleVymLinks()
2847 QString currentVymLink;
2848 if (currentMapEditor())
2850 QStringList vl=currentMapEditor()->getVymLinks();
2855 void Main::editVymLink()
2857 if (currentMapEditor())
2858 currentMapEditor()->editVymLink();
2861 void Main::editDeleteVymLink()
2863 if (currentMapEditor())
2864 currentMapEditor()->deleteVymLink();
2867 void Main::editToggleHideExport()
2869 if (currentMapEditor())
2870 currentMapEditor()->toggleHideExport();
2873 void Main::editMapInfo()
2875 if (currentMapEditor())
2876 currentMapEditor()->editMapInfo();
2879 void Main::editMoveUp()
2881 if (currentMapEditor())
2882 currentMapEditor()->moveBranchUp();
2885 void Main::editMoveDown()
2887 if (currentMapEditor())
2888 currentMapEditor()->moveBranchDown();
2891 void Main::editToggleScroll()
2893 if (currentMapEditor())
2895 currentMapEditor()->toggleScroll();
2899 void Main::editUnscrollChilds()
2901 if (currentMapEditor())
2902 currentMapEditor()->unscrollChilds();
2905 void Main::editNewBranch()
2907 MapEditor *me=currentMapEditor();
2908 if (!lineedit->isVisible() && me)
2910 BranchObj *bo=(BranchObj*)me->getSelection();
2911 BranchObj *newbo=me->addNewBranch(0);
2914 me->select (newbo->getSelectString());
2918 if (actionSettingsAutoEdit->isOn())
2920 if (!actionSettingsAutoSelectHeading->isOn())
2921 prevSelection=bo->getSelectString();
2927 void Main::editNewBranchBefore()
2929 MapEditor *me=currentMapEditor();
2930 if (!lineedit->isVisible() && me)
2932 BranchObj *bo=(BranchObj*)me->getSelection();
2933 BranchObj *newbo=me->addNewBranchBefore();
2936 me->select (newbo->getSelectString());
2940 if (actionSettingsAutoEdit->isOn())
2942 if (!actionSettingsAutoSelectHeading->isOn())
2943 prevSelection=bo->getSelectString();
2949 void Main::editNewBranchAbove()
2951 MapEditor *me=currentMapEditor();
2952 if (!lineedit->isVisible() && me)
2954 BranchObj *bo=(BranchObj*)me->getSelection();
2955 BranchObj *newbo=me->addNewBranch (-1);
2958 me->select (newbo->getSelectString());
2962 if (actionSettingsAutoEdit->isOn())
2964 if (!actionSettingsAutoSelectHeading->isOn())
2965 prevSelection=bo->getSelectString();
2971 void Main::editNewBranchBelow()
2973 MapEditor *me=currentMapEditor();
2974 if (!lineedit->isVisible() && me)
2976 BranchObj *bo=(BranchObj*)me->getSelection();
2977 BranchObj *newbo=me->addNewBranch (1);
2980 me->select (newbo->getSelectString());
2984 if (actionSettingsAutoEdit->isOn())
2986 if (!actionSettingsAutoSelectHeading->isOn())
2987 prevSelection=bo->getSelectString();
2993 void Main::editImportAdd()
2995 fileLoad (ImportAdd);
2998 void Main::editImportReplace()
3000 fileLoad (ImportReplace);
3003 void Main::editSaveBranch()
3005 fileSaveAs (PartOfMap);
3008 void Main::editDeleteKeepChilds()
3010 if (currentMapEditor())
3011 currentMapEditor()->deleteKeepChilds();
3014 void Main::editDeleteChilds()
3016 if (currentMapEditor())
3017 currentMapEditor()->deleteChilds();
3020 void Main::editDeleteSelection()
3022 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3023 currentMapEditor()->deleteSelection();
3026 void Main::editUpperBranch()
3028 if (currentMapEditor())
3029 currentMapEditor()->selectUpperBranch();
3032 void Main::editLowerBranch()
3034 if (currentMapEditor())
3035 currentMapEditor()->selectLowerBranch();
3038 void Main::editLeftBranch()
3040 if (currentMapEditor())
3041 currentMapEditor()->selectLeftBranch();
3044 void Main::editRightBranch()
3046 if (currentMapEditor())
3047 currentMapEditor()->selectRightBranch();
3050 void Main::editFirstBranch()
3052 if (currentMapEditor())
3053 currentMapEditor()->selectFirstBranch();
3056 void Main::editLastBranch()
3058 if (currentMapEditor())
3059 currentMapEditor()->selectLastBranch();
3062 void Main::editLoadImage()
3064 if (currentMapEditor())
3065 currentMapEditor()->loadFloatImage();
3068 void Main::editSaveImage()
3070 if (currentMapEditor())
3071 currentMapEditor()->saveFloatImage();
3074 void Main::editFollowXLink(QAction *a)
3077 if (currentMapEditor())
3078 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3081 void Main::editEditXLink(QAction *a)
3083 if (currentMapEditor())
3084 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3087 void Main::formatSelectColor()
3089 if (currentMapEditor())
3091 QColor col = QColorDialog::getColor((currentColor ), this );
3092 if ( !col.isValid() ) return;
3093 colorChanged( col );
3097 void Main::formatPickColor()
3099 if (currentMapEditor())
3100 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3103 void Main::colorChanged(QColor c)
3105 QPixmap pix( 16, 16 );
3107 actionFormatColor->setIconSet( pix );
3111 void Main::formatColorBranch()
3113 if (currentMapEditor())
3114 currentMapEditor()->colorBranch(currentColor);
3117 void Main::formatColorSubtree()
3119 if (currentMapEditor())
3120 currentMapEditor()->colorSubtree (currentColor);
3123 void Main::formatLinkStyleLine()
3125 if (currentMapEditor())
3126 currentMapEditor()->setMapLinkStyle("StyleLine");
3129 void Main::formatLinkStyleParabel()
3131 if (currentMapEditor())
3132 currentMapEditor()->setMapLinkStyle("StyleParabel");
3135 void Main::formatLinkStylePolyLine()
3137 if (currentMapEditor())
3138 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3141 void Main::formatLinkStylePolyParabel()
3143 if (currentMapEditor())
3144 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3147 void Main::formatSelectBackColor()
3149 if (currentMapEditor())
3150 currentMapEditor()->selectMapBackgroundColor();
3153 void Main::formatSelectBackImage()
3155 if (currentMapEditor())
3156 currentMapEditor()->selectMapBackgroundImage();
3159 void Main::formatSelectLinkColor()
3161 if (currentMapEditor())
3162 currentMapEditor()->selectMapLinkColor();
3165 void Main::formatSelectSelectionColor()
3167 if (currentMapEditor())
3168 currentMapEditor()->selectMapSelectionColor();
3171 void Main::formatToggleLinkColorHint()
3173 currentMapEditor()->toggleMapLinkColorHint();
3177 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3179 if (currentMapEditor())
3180 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3183 void Main::viewZoomReset()
3185 if (currentMapEditor())
3189 currentMapEditor()->setMatrix( m );
3193 void Main::viewZoomIn()
3195 if (currentMapEditor())
3197 QMatrix m = currentMapEditor()->matrix();
3198 m.scale( 1.25, 1.25 );
3199 currentMapEditor()->setMatrix( m );
3203 void Main::viewZoomOut()
3205 if (currentMapEditor())
3207 QMatrix m = currentMapEditor()->matrix();
3208 m.scale( 0.8, 0.8 );
3209 currentMapEditor()->setMatrix( m );
3213 bool Main::settingsPDF()
3215 // Default browser is set in constructor
3217 QString text = QInputDialog::getText(
3218 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3219 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3221 settings.setValue ("/mainwindow/readerPDF",text);
3226 bool Main::settingsURL()
3228 // Default browser is set in constructor
3230 QString text = QInputDialog::getText(
3231 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3232 settings.value("/mainwindow/readerURL").toString()
3235 settings.setValue ("/mainwindow/readerURL",text);
3239 void Main::settingsMacroDir()
3241 QDir defdir=vymBaseDir;
3242 defdir.cd("macros");
3243 if (!defdir.exists())
3245 QDir dir=QFileDialog::getExistingDirectory (
3247 tr ("Directory with vym macros:"),
3248 settings.value ("/macros/macroDir",defdir.path()).toString()
3251 settings.setValue ("/macros/macroDir",dir.path());
3254 void Main::settingsUndoLevels()
3257 int i = QInputDialog::getInteger(
3259 tr("QInputDialog::getInteger()"),
3260 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3263 settings.setValue ("/mapeditor/stepsTotal",i);
3264 QMessageBox::information( this, tr( "VYM -Information:" ),
3265 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3269 void Main::settingsAutosaveToggle()
3271 settings.setValue ("/mapeditor/autosave/used",actionSettingsAutosaveToggle->isOn() );
3274 void Main::settingsAutosaveTime()
3277 int i = QInputDialog::getInteger(
3279 tr("QInputDialog::getInteger()"),
3280 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3283 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3287 void Main::settingsToggleDelKey()
3289 if (actionSettingsUseDelKey->isOn())
3291 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3294 actionEditDelete->setAccel (QKeySequence (""));
3298 void Main::windowToggleNoteEditor()
3300 if (textEditor->isVisible() )
3306 void Main::windowToggleHistory()
3308 if (historyWindow->isVisible())
3309 historyWindow->hide();
3311 historyWindow->show();
3315 void Main::windowToggleProperty()
3317 if (branchPropertyWindow->isVisible())
3318 branchPropertyWindow->hide();
3320 branchPropertyWindow->show();
3322 if(currentMapEditor())
3324 LinkableMapObj *sel=currentMapEditor()->getSelection();
3325 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3326 typeid(*sel) == typeid(MapCenterObj)))
3328 branchPropertyWindow->setMapEditor(currentMapEditor());
3329 branchPropertyWindow->setBranch((BranchObj*)sel);
3334 branchPropertyWindow->setBranch(NULL);
3337 void Main::windowToggleAntiAlias()
3339 bool b=actionViewToggleAntiAlias->isOn();
3341 for (int i=0;i<tabWidget->count();i++)
3344 me=(MapEditor*)tabWidget->page(i);
3345 me->setAntiAlias(b);
3350 void Main::windowToggleSmoothPixmap()
3352 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3354 for (int i=0;i<tabWidget->count();i++)
3357 me=(MapEditor*)tabWidget->page(i);
3358 me->setSmoothPixmap(b);
3362 void Main::updateHistory(SimpleSettings &undoSet)
3364 historyWindow->update (undoSet);
3367 void Main::updateNoteFlag()
3369 if (currentMapEditor())
3370 currentMapEditor()->updateNoteFlag();
3373 void Main::updateSatellites(MapEditor *me)
3375 branchPropertyWindow->setMapEditor (me);
3378 void Main::updateActions()
3380 MapEditor *me=currentMapEditor();
3383 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3385 // updateActions is also called when NoteEditor is closed
3386 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3387 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3388 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3390 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3391 actionFormatLinkColorHint->setOn(true);
3393 actionFormatLinkColorHint->setOn(false);
3395 switch (me->getMapLinkStyle())
3397 case LinkableMapObj::Line:
3398 actionFormatLinkStyleLine->setOn(true);
3400 case LinkableMapObj::Parabel:
3401 actionFormatLinkStyleParabel->setOn(true);
3403 case LinkableMapObj::PolyLine:
3404 actionFormatLinkStylePolyLine->setOn(true);
3406 case LinkableMapObj::PolyParabel:
3407 actionFormatLinkStylePolyParabel->setOn(true);
3414 QPixmap pix( 16, 16 );
3415 pix.fill( me->getMapBackgroundColor() );
3416 actionFormatBackColor->setIconSet( pix );
3417 pix.fill( me->getSelectionColor() );
3418 actionFormatSelectionColor->setIconSet( pix );
3419 pix.fill( me->getMapDefLinkColor() );
3420 actionFormatLinkColor->setIconSet( pix );
3423 actionFileSave->setEnabled( me->hasChanged() );
3424 if (me->isUndoAvailable())
3425 actionEditUndo->setEnabled( true);
3427 actionEditUndo->setEnabled( false);
3429 if (me->isRedoAvailable())
3430 actionEditRedo->setEnabled( true);
3432 actionEditRedo->setEnabled( false);
3434 LinkableMapObj *selection=me->getSelection();
3437 if ( (typeid(*selection) == typeid(BranchObj)) ||
3438 (typeid(*selection) == typeid(MapCenterObj)) )
3440 BranchObj *bo=(BranchObj*)selection;
3441 // Take care of links
3442 if (bo->countXLinks()==0)
3444 branchXLinksContextMenuEdit->clear();
3445 branchXLinksContextMenuFollow->clear();
3450 branchXLinksContextMenuEdit->clear();
3451 branchXLinksContextMenuFollow->clear();
3452 for (int i=0; i<=bo->countXLinks();i++)
3454 bot=bo->XLinkTargetAt(i);
3457 s=bot->getHeading();
3460 branchXLinksContextMenuFollow->addAction (s);
3461 branchXLinksContextMenuEdit->addAction (s);
3466 standardFlagsDefault->setEnabled (true);
3468 actionEditToggleScroll->setEnabled (true);
3469 if ( bo->isScrolled() )
3470 actionEditToggleScroll->setOn(true);
3472 actionEditToggleScroll->setOn(false);
3474 if ( bo->getURL().isEmpty() )
3476 actionEditOpenURL->setEnabled (false);
3477 actionEditOpenURLTab->setEnabled (false);
3481 actionEditOpenURL->setEnabled (true);
3482 actionEditOpenURLTab->setEnabled (true);
3484 if ( bo->getVymLink().isEmpty() )
3486 actionEditOpenVymLink->setEnabled (false);
3487 actionEditDeleteVymLink->setEnabled (false);
3490 actionEditOpenVymLink->setEnabled (true);
3491 actionEditDeleteVymLink->setEnabled (true);
3494 if (bo->canMoveBranchUp())
3495 actionEditMoveUp->setEnabled (true);
3497 actionEditMoveUp->setEnabled (false);
3498 if (bo->canMoveBranchDown())
3499 actionEditMoveDown->setEnabled (true);
3501 actionEditMoveDown->setEnabled (false);
3504 actionEditToggleHideExport->setEnabled (true);
3505 actionEditToggleHideExport->setOn (bo->hideInExport() );
3507 actionEditCopy->setEnabled (true);
3508 actionEditCut->setEnabled (true);
3509 if (!clipboardEmpty)
3510 actionEditPaste->setEnabled (true);
3512 actionEditPaste->setEnabled (false);
3513 for (int i=0; i<actionListBranches.size(); ++i)
3514 actionListBranches.at(i)->setEnabled(true);
3515 actionEditDelete->setEnabled (true);
3516 actionFormatHideLinkUnselected->setOn
3517 (selection->getHideLinkUnselected());
3519 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3521 FloatObj *fo=(FloatImageObj*)selection;
3523 actionEditOpenURL->setEnabled (false);
3524 actionEditOpenVymLink->setEnabled (false);
3525 actionEditDeleteVymLink->setEnabled (false);
3526 actionEditToggleHideExport->setEnabled (true);
3527 actionEditToggleHideExport->setOn (fo->hideInExport() );
3530 actionEditCopy->setEnabled (true);
3531 actionEditCut->setEnabled (true);
3532 actionEditPaste->setEnabled (false);
3533 for (int i=0; i<actionListBranches.size(); ++i)
3534 actionListBranches.at(i)->setEnabled(false);
3535 actionEditDelete->setEnabled (true);
3536 actionFormatHideLinkUnselected->setOn
3537 ( selection->getHideLinkUnselected());
3538 actionEditMoveUp->setEnabled (false);
3539 actionEditMoveDown->setEnabled (false);
3544 actionEditCopy->setEnabled (false);
3545 actionEditCut->setEnabled (false);
3546 actionEditPaste->setEnabled (false);
3547 for (int i=0; i<actionListBranches.size(); ++i)
3548 actionListBranches.at(i)->setEnabled(false);
3550 actionEditToggleScroll->setEnabled (false);
3551 actionEditOpenURL->setEnabled (false);
3552 actionEditOpenVymLink->setEnabled (false);
3553 actionEditDeleteVymLink->setEnabled (false);
3554 actionEditHeading2URL->setEnabled (false);
3555 actionEditDelete->setEnabled (false);
3556 actionEditMoveUp->setEnabled (false);
3557 actionEditMoveDown->setEnabled (false);
3558 actionEditToggleHideExport->setEnabled (false);
3562 Main::ModMode Main::getModMode()
3564 if (actionModModeColor->isOn()) return ModModeColor;
3565 if (actionModModeCopy->isOn()) return ModModeCopy;
3566 if (actionModModeXLink->isOn()) return ModModeXLink;
3570 bool Main::autoEdit()
3572 return actionSettingsAutoEdit->isOn();
3575 bool Main::autoSelectHeading()
3577 return actionSettingsAutoSelectHeading->isOn();
3580 bool Main::useFlagGroups()
3582 return actionSettingsUseFlagGroups->isOn();
3585 void Main::windowShowNoteEditor()
3588 actionViewToggleNoteEditor->setOn (true);
3591 void Main::windowHideNoteEditor()
3594 actionViewToggleNoteEditor->setOn (false);
3597 void Main::setScript (const QString &script)
3599 scriptEditor->setScript (script);
3602 void Main::runScript (const QString &script)
3604 if (currentMapEditor())
3605 currentMapEditor()->runScript (script);
3608 void Main::windowNextEditor()
3610 if (tabWidget->currentPageIndex() < tabWidget->count())
3611 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3614 void Main::windowPreviousEditor()
3616 if (tabWidget->currentPageIndex() >0)
3617 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3620 void Main::standardFlagChanged()
3622 if (currentMapEditor())
3623 currentMapEditor()->toggleStandardFlag(sender()->name());
3626 void Main::testFunction()
3628 if (!currentMapEditor()) return;
3629 currentMapEditor()->testFunction();
3632 void Main::testCommand()
3634 if (!currentMapEditor()) return;
3635 scriptEditor->show();
3638 QString com = QInputDialog::getText(
3639 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3640 if (ok) currentMapEditor()->parseAtom(com);
3644 void Main::helpDoc()
3646 QString locale = QLocale::system().name();
3648 if (locale.left(2)=="es")
3649 docname="vym_es.pdf";
3653 QStringList searchList;
3655 #if defined(Q_OS_MACX)
3656 searchList << "./vym.app/Contents";
3658 // default path in SUSE LINUX
3659 searchList <<"/usr/share/doc/packages/vym/doc";
3662 searchList << "doc"; // relative path for easy testing in tarball
3663 searchList << "doc/tex"; // Easy testing working on vym.tex
3664 searchList << "/usr/share/doc/vym"; // Debian
3665 searchList << "/usr/share/doc/packages";// Knoppix
3669 for (int i=0; i<searchList.count(); ++i)
3671 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3672 if (docfile.exists() )
3681 QMessageBox::critical(0,
3682 tr("Critcal error"),
3683 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3688 Process *pdfProc = new Process();
3689 args <<docfile.fileName();
3691 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3692 if ( !pdfProc->waitForStarted() )
3695 QMessageBox::warning(0,
3697 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3698 tr("Please use Settings->")+tr("Set application to open PDF files"));
3705 void Main::helpAbout()
3708 ad.setName ("aboutwindow");
3709 ad.setMinimumSize(500,500);
3710 ad.resize (QSize (500,500));
3714 void Main::helpAboutQT()
3716 QMessageBox::aboutQt( this, "Qt Application Example" );
3719 void Main::callMacro ()
3721 QAction *action = qobject_cast<QAction *>(sender());
3725 i=action->data().toInt();
3726 QString mDir (settings.value ("macros/macroDir").toString() );
3728 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3730 if ( !f.open( QIODevice::ReadOnly ) )
3732 QMessageBox::warning(0,
3734 tr("Couldn't find a macro at %1.\n").arg(fn)+
3735 tr("Please use Settings->")+tr("Set directory for vym macros"));
3739 QTextStream ts( &f );
3740 QString m= ts.read();
3744 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3745 currentMapEditor()->runScript (m);