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 bool clipboardEmpty;
29 extern int statusbarTime;
30 extern FlagRowObj* standardFlagsDefault;
31 extern FlagRowObj* systemFlagsDefault;
32 extern QString vymName;
33 extern QString vymVersion;
34 extern QString vymBuildDate;
36 QMenu* branchContextMenu;
37 QMenu* branchAddContextMenu;
38 QMenu* branchRemoveContextMenu;
39 QMenu* branchLinksContextMenu;
40 QMenu* branchXLinksContextMenuEdit;
41 QMenu* branchXLinksContextMenuFollow;
42 QMenu* floatimageContextMenu;
43 QMenu* canvasContextMenu;
44 QMenu* fileLastMapsMenu;
45 QMenu* fileImportMenu;
46 QMenu* fileExportMenu;
49 extern Settings settings;
50 extern Options options;
51 extern ImageIO imageIO;
53 extern QDir vymBaseDir;
54 extern QDir lastImageDir;
55 extern QDir lastFileDir;
56 extern QString iconPath;
57 extern QString flagsPath;
59 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
60 QMainWindow(parent,name,f)
64 setCaption ("VYM - View Your Mind");
66 // Load window settings
67 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
68 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
71 // Sometimes we may need to remember old selections
75 currentColor=Qt::black;
77 // Create unique temporary directory
79 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
82 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
86 // Create direcctory for clipboard
87 clipboardDir=tmpVymDir+"/clipboard";
89 d.mkdir (clipboardDir,true);
90 makeSubDirs (clipboardDir);
95 // Initialize history window;
96 historyWindow=new HistoryWindow();
98 // Initialize properties window
99 branchPropertyWindow = new BranchPropertyWindow();
100 branchPropertyWindow->move (20,20);
101 branchPropertyWindow->resize (settings.value( "/branchpropertywindow/geometry/size",QSize (150,100)).toSize());
102 branchPropertyWindow->move (settings.value( "/branchpropertywindow/geometry/pos", QPoint(20,20)).toPoint());
105 // Initialize script editor
106 scriptEditor = new SimpleScriptEditor();
107 scriptEditor->move (50,50);
109 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
110 this, SLOT( runScript( QString ) ) );
112 // Initialize some settings, which are platform dependant
115 // application to open URLs
116 p="/mainwindow/readerURL";
117 #if defined(Q_OS_LINUX)
118 s=settings.value (p,"konqueror").toString();
120 #if defined(Q_OS_MACX)
121 s=settings.value (p,"/usr/bin/open").toString();
123 s=settings.value (p,"mozilla");
126 settings.setValue( p,s);
128 // application to open PDFs
129 p="/mainwindow/readerPDF";
130 #if defined(Q_OS_LINUX)
131 s=settings.value (p,"acroread").toString();
133 #if defined(Q_OS_MACX)
134 s=settings.value (p,"/usr/bin/open").toString();
136 s=settings.value (p,"acroread").toString();
139 settings.setValue( p,s);
142 // Create tab widget which holds the maps
143 tabWidget= new QTabWidget (this);
144 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
145 this, SLOT( editorChanged( QWidget * ) ) );
147 lineedit=new QLineEdit (this);
150 setCentralWidget(tabWidget);
154 setupFormatActions();
158 setupSettingsActions();
161 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
166 restoreState (settings.value("/mainwindow/state",0).toByteArray());
168 // Satellite windows //////////////////////////////////////////
170 // Initialize Find window
171 findWindow=new FindWindow(NULL);
172 findWindow->move (x(),y()+70);
173 connect (findWindow, SIGNAL( findButton(QString) ),
174 this, SLOT(editFind(QString) ) );
175 connect (findWindow, SIGNAL( somethingChanged() ),
176 this, SLOT(editFindChanged() ) );
178 // Connect TextEditor, so that we can update flags if text changes
179 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
180 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
182 // Connect HistoryWindow, so that we can update flags
183 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
191 settings.setValue ( "/mainwindow/geometry/size", size() );
192 settings.setValue ( "/mainwindow/geometry/pos", pos() );
193 settings.setValue ("/mainwindow/state",saveState(0));
195 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
196 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
197 settings.setValue( "/version/version", vymVersion );
198 settings.setValue( "/version/builddate", vymBuildDate );
200 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
201 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
202 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
203 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
204 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
205 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
207 //TODO save scriptEditor settings
209 // call the destructors
211 delete historyWindow;
212 delete branchPropertyWindow;
214 // Remove temporary directory
215 removeDir (QDir(tmpVymDir));
218 void Main::loadCmdLine()
220 /* TODO draw some kind of splashscreen while loading...
226 QStringList flist=options.getFileList();
227 QStringList::Iterator it=flist.begin();
229 while (it !=flist.end() )
231 fileLoad (*it, NewMap);
237 void Main::statusMessage(const QString &s)
239 statusBar()->message (s);
242 void Main::closeEvent (QCloseEvent* )
248 void Main::setupFileActions()
250 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
251 QToolBar *tb = addToolBar( tr ("&Map") );
252 tb->setObjectName ("mapTB");
255 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New...","File menu" ),this);
256 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
257 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
259 fileMenu->addAction (a);
260 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
262 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
263 a->setStatusTip (tr( "Open","Status tip File menu" ) );
264 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
266 fileMenu->addAction (a);
267 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
269 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
270 fileMenu->addSeparator();
272 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
273 a->setStatusTip ( tr( "Save","Status tip file menu" ));
274 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
276 fileMenu->addAction (a);
277 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
280 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
281 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
282 fileMenu->addAction (a);
283 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
285 fileMenu->addSeparator();
287 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
289 a = new QAction(tr("KDE Bookmarks"), this);
290 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
291 a->addTo (fileImportMenu);
292 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
294 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
296 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
297 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
298 a->addTo (fileImportMenu);
299 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
302 a = new QAction("Mind Manager...",this);
303 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
304 fileImportMenu->addAction (a);
305 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
307 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
308 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
309 fileImportMenu->addAction (a);
310 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
312 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
314 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
315 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
316 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
317 fileExportMenu->addAction (a);
319 a = new QAction( "Open Office...", this);
320 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
321 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
322 fileExportMenu->addAction (a);
324 a = new QAction( "Webpage (XHTML)...",this );
325 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
326 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
327 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
328 fileExportMenu->addAction (a);
330 a = new QAction( "Text (ASCII)...", this);
331 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
333 fileExportMenu->addAction (a);
335 a = new QAction( tr("KDE Bookmarks","File menu"), this);
336 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
338 fileExportMenu->addAction (a);
340 a = new QAction( "Taskjuggler...", this );
341 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
343 fileExportMenu->addAction (a);
345 a = new QAction( "LaTeX...", this);
346 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
347 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
348 fileExportMenu->addAction (a);
350 a = new QAction( "XML..." , this );
351 a->setStatusTip (tr( "Export as %1").arg("XML"));
352 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
353 fileExportMenu->addAction (a);
355 fileMenu->addSeparator();
357 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
358 a->setStatusTip ( tr( "Print" ,"File menu") );
359 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
361 fileMenu->addAction (a);
362 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
365 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
366 a->setStatusTip (tr( "Close Map" ) );
367 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
368 fileMenu->addAction (a);
369 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
371 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
372 a->setStatusTip ( tr( "Exit")+" "+vymName );
373 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
374 fileMenu->addAction (a);
375 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
380 void Main::setupEditActions()
382 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
383 tb->setLabel( "Edit Actions" );
384 tb->setObjectName ("actionsTB");
385 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
389 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
390 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
391 a->setStatusTip (tr( "Undo" ) );
392 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
393 a->setEnabled (false);
395 editMenu->addAction (a);
398 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
399 a->setStatusTip (tr( "Redo" ));
400 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
402 editMenu->addAction (a);
403 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
406 editMenu->addSeparator();
407 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
408 a->setStatusTip ( tr( "Copy" ) );
409 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
410 a->setEnabled (false);
412 editMenu->addAction (a);
413 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
416 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
417 a->setStatusTip ( tr( "Cut" ) );
418 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
419 a->setEnabled (false);
421 editMenu->addAction (a);
423 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
425 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
426 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
427 a->setStatusTip ( tr( "Paste" ) );
428 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
429 a->setEnabled (false);
431 editMenu->addAction (a);
434 // Shortcuts to modify heading:
435 a = new QAction(tr( "Edit heading","Edit menu" ),this);
436 a->setStatusTip ( tr( "edit Heading" ));
437 a->setShortcut ( Qt::Key_Enter); //Edit heading
438 // a->setShortcutContext (Qt::WindowShortcut);
440 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
441 actionListBranches.append(a);
442 a = new QAction( tr( "Edit heading","Edit menu" ), this);
443 a->setStatusTip (tr( "edit Heading" ));
444 a->setShortcut (Qt::Key_Return ); //Edit heading
445 //a->setShortcutContext (Qt::WindowShortcut);
447 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
448 actionListBranches.append(a);
449 editMenu->addAction (a);
451 a = new QAction( tr( "Edit heading","Edit menu" ), this);
452 a->setStatusTip (tr( "edit Heading" ));
453 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
454 a->setShortcutContext (Qt::WindowShortcut);
456 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
457 actionListBranches.append(a);
459 // Shortcut to delete selection
460 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
461 a->setStatusTip (tr( "Delete Selection" ));
462 a->setShortcut ( Qt::Key_Delete); //Delete selection
463 a->setShortcutContext (Qt::WindowShortcut);
465 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
468 // Shortcut to add branch
469 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
470 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
471 alt->setShortcut (Qt::Key_A); //Add branch
472 alt->setShortcutContext (Qt::WindowShortcut);
474 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
475 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
476 a->setStatusTip ( tr( "Add a branch as child of selection" ));
477 a->setShortcut (Qt::Key_Insert); //Add branch
478 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
479 actionListBranches.append(a);
480 #if defined (Q_OS_MACX)
481 // In OSX show different shortcut in menues, the keys work indepently always
482 actionEditAddBranch=alt;
484 actionEditAddBranch=a;
486 editMenu->addAction (actionEditAddBranch);
487 tb->addAction (actionEditAddBranch);
490 // Add branch by inserting it at selection
491 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
492 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
493 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
494 a->setShortcutContext (Qt::WindowShortcut);
496 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
497 a->setEnabled (false);
498 actionListBranches.append(a);
499 actionEditAddBranchBefore=a;
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_A ); //Insert branch
503 a->setShortcutContext (Qt::WindowShortcut);
505 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
506 actionListBranches.append(a);
509 a = new QAction(tr( "Add branch above","Edit menu" ), this);
510 a->setStatusTip ( tr( "Add a branch above selection" ));
511 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
512 a->setShortcutContext (Qt::WindowShortcut);
514 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
515 a->setEnabled (false);
516 actionListBranches.append(a);
517 actionEditAddBranchAbove=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_A ); //Add branch above
521 a->setShortcutContext (Qt::WindowShortcut);
523 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
524 actionListBranches.append(a);
527 a = new QAction(tr( "Add branch below","Edit menu" ), this);
528 a->setStatusTip ( tr( "Add a branch below selection" ));
529 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
530 a->setShortcutContext (Qt::WindowShortcut);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
533 a->setEnabled (false);
534 actionListBranches.append(a);
535 actionEditAddBranchBelow=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_A ); // Add branch below
539 a->setShortcutContext (Qt::WindowShortcut);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
542 actionListBranches.append(a);
544 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
545 a->setStatusTip ( tr( "Move branch up" ) );
546 a->setShortcut (Qt::Key_PageUp ); // Move branch up
547 a->setEnabled (false);
549 editMenu->addAction (a);
550 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
553 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
554 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
555 a->setStatusTip (tr( "Move branch down" ) );
556 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
557 a->setEnabled (false);
559 editMenu->addAction (a);
560 actionEditMoveDown=a;
563 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
564 a->setShortcut ( Qt::Key_ScrollLock );
565 a->setStatusTip (tr( "Scroll branch" ) );
566 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
568 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
569 alt->setShortcut ( Qt::Key_S ); // Scroll branch
570 alt->setStatusTip (tr( "Scroll branch" ));
571 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
572 #if defined(Q_OS_MACX)
573 actionEditToggleScroll=alt;
575 actionEditToggleScroll=a;
577 actionEditToggleScroll->setEnabled (false);
578 actionEditToggleScroll->setToggleAction(true);
579 tb->addAction (actionEditToggleScroll);
580 editMenu->addAction ( actionEditToggleScroll);
581 editMenu->addAction (actionEditToggleScroll);
584 actionListBranches.append(actionEditToggleScroll);
586 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
587 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
588 editMenu->addAction (a);
589 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
591 editMenu->addSeparator();
593 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
594 a->setStatusTip (tr( "Find" ) );
595 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
596 editMenu->addAction (a);
597 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
599 editMenu->addSeparator();
601 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
602 a->setShortcut (Qt::CTRL + Qt::Key_U );
603 a->setShortcut (tr( "Open URL" ));
606 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
609 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
610 a->setStatusTip (tr( "Open URL in new tab" ));
611 a->setShortcut (Qt::CTRL+Qt::Key_U );
613 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
614 actionEditOpenURLTab=a;
616 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
617 a->setStatusTip (tr( "Open all URLs in subtree" ));
619 actionListBranches.append(a);
620 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
621 actionEditOpenMultipleURLTabs=a;
623 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
624 a->setStatusTip ( tr( "Edit URL" ) );
625 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
626 //a->setShortcut ( Qt::Key_U );
627 a->setShortcutContext (Qt::WindowShortcut);
628 actionListBranches.append(a);
630 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
633 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
634 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
635 a->setEnabled (false);
636 actionListBranches.append(a);
637 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
638 actionEditHeading2URL=a;
640 a = new QAction(tr( "Create URL to Bugzilla","Edit menu" ), this);
641 a->setStatusTip ( tr( "Create URL to Bugzilla" ));
642 a->setEnabled (false);
643 actionListBranches.append(a);
644 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
645 actionEditBugzilla2URL=a;
647 a = new QAction(tr( "Create URL to FATE","Edit menu" ), this);
648 a->setStatusTip ( tr( "Create URL to FATE" ));
649 a->setEnabled (false);
650 actionListBranches.append(a);
651 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
652 actionEditFATE2URL=a;
654 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
655 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
657 a->setEnabled (false);
658 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
659 actionEditOpenVymLink=a;
661 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
662 a->setStatusTip ( tr( "Open all vym links in subtree" ));
663 a->setEnabled (false);
664 actionListBranches.append(a);
665 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
666 actionEditOpenMultipleVymLinks=a;
669 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
670 a->setEnabled (false);
671 a->setStatusTip ( tr( "Edit link to another vym map" ));
672 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
673 actionListBranches.append(a);
676 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
677 a->setStatusTip ( tr( "Delete link to another vym map" ));
678 a->setEnabled (false);
679 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
680 actionEditDeleteVymLink=a;
682 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
683 a->setStatusTip ( tr( "Hide object in exports" ) );
684 a->setShortcut (Qt::Key_H );
685 a->setToggleAction(true);
687 a->setEnabled (false);
688 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
689 actionEditToggleHideExport=a;
691 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
692 a->setStatusTip ( tr( "Edit Map Info" ));
693 a->setEnabled (true);
694 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
697 // Import at selection (adding to selection)
698 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
699 a->setStatusTip (tr( "Add map at selection" ));
700 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
701 a->setEnabled (false);
702 actionListBranches.append(a);
703 actionEditImportAdd=a;
705 // Import at selection (replacing selection)
706 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
707 a->setStatusTip (tr( "Replace selection with map" ));
708 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
709 a->setEnabled (false);
710 actionListBranches.append(a);
711 actionEditImportReplace=a;
714 a = new QAction( tr( "Save selection","Edit menu" ), this);
715 a->setStatusTip (tr( "Save selection" ));
716 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
717 a->setEnabled (false);
718 actionListBranches.append(a);
719 actionEditSaveBranch=a;
721 // Only remove branch, not its childs
722 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
723 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
724 a->setShortcut (Qt::ALT + Qt::Key_Delete );
725 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
726 a->setEnabled (false);
728 actionListBranches.append(a);
729 actionEditDeleteKeepChilds=a;
731 // Only remove childs of a branch
732 a = new QAction( tr( "Remove childs","Edit menu" ), this);
733 a->setStatusTip (tr( "Remove childs of branch" ));
734 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
735 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
736 a->setEnabled (false);
737 actionListBranches.append(a);
738 actionEditDeleteChilds=a;
740 // Shortcuts for navigating with cursor:
741 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
742 a->setStatusTip ( tr( "Select upper branch" ));
743 a->setShortcut (Qt::Key_Up );
744 a->setShortcutContext (Qt::WindowShortcut);
746 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
747 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
748 a->setStatusTip (tr( "Select lower branch" ));
749 a->setShortcut ( Qt::Key_Down );
750 a->setShortcutContext (Qt::WindowShortcut);
752 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
753 a = new QAction(tr( "Select left branch","Edit menu" ), this);
754 a->setStatusTip ( tr( "Select left branch" ));
755 a->setShortcut (Qt::Key_Left );
756 a->setShortcutContext (Qt::WindowShortcut);
758 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
759 a = new QAction( tr( "Select child branch","Edit menu" ), this);
760 a->setStatusTip (tr( "Select right branch" ));
761 a->setShortcut (Qt::Key_Right);
762 a->setShortcutContext (Qt::WindowShortcut);
764 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
765 a = new QAction( tr( "Select first branch","Edit menu" ), this);
766 a->setStatusTip (tr( "Select first branch" ));
767 a->setShortcut (Qt::Key_Home );
768 a->setShortcutContext (Qt::WindowShortcut);
770 a->setEnabled (false);
771 editMenu->addAction (a);
772 actionListBranches.append(a);
773 actionEditSelectFirst=a;
774 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
775 a = new QAction( tr( "Select last branch","Edit menu" ),this);
776 a->setStatusTip (tr( "Select last branch" ));
777 a->setShortcut ( Qt::Key_End );
778 a->setShortcutContext (Qt::WindowShortcut);
780 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
781 a->setEnabled (false);
782 editMenu->addAction (a);
783 actionListBranches.append(a);
784 actionEditSelectLast=a;
786 a = new QAction( tr( "Add Image...","Edit menu" ), this);
787 a->setStatusTip (tr( "Add Image" ));
788 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
789 actionEditLoadImage=a;
791 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
792 a->setStatusTip (tr( "Set properties for selection" ));
793 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
794 a->setShortcutContext (Qt::WindowShortcut);
796 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
797 actionTogglePropertyWindow=a;
801 void Main::setupFormatActions()
803 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
805 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
806 tb->setObjectName ("formatTB");
809 pix.fill (Qt::black);
810 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
811 a->setStatusTip ( tr( "Set Color" ));
812 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
814 formatMenu->addAction (a);
816 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
817 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
818 a->setShortcut (Qt::CTRL + Qt::Key_K );
819 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
820 a->setEnabled (false);
822 formatMenu->addAction (a);
823 actionListBranches.append(a);
824 actionFormatPickColor=a;
826 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
827 a->setStatusTip ( tr( "Color branch" ) );
828 a->setShortcut (Qt::CTRL + Qt::Key_B);
829 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
830 a->setEnabled (false);
832 formatMenu->addAction (a);
833 actionListBranches.append(a);
834 actionFormatColorSubtree=a;
836 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
837 a->setStatusTip ( tr( "Color Subtree" ));
838 a->setShortcut (Qt::CTRL + Qt::Key_T);
839 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
840 a->setEnabled (false);
841 formatMenu->addAction (a);
843 actionListBranches.append(a);
844 actionFormatColorSubtree=a;
846 formatMenu->addSeparator();
847 actionGroupFormatLinkStyles=new QActionGroup ( this);
848 actionGroupFormatLinkStyles->setExclusive (true);
849 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
850 a->setStatusTip (tr( "Line" ));
851 a->setToggleAction(true);
852 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
853 formatMenu->addAction (a);
854 actionFormatLinkStyleLine=a;
855 a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
856 a->setStatusTip (tr( "Line" ));
857 a->setToggleAction(true);
858 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
859 formatMenu->addAction (a);
860 actionFormatLinkStyleParabel=a;
861 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
862 a->setStatusTip (tr( "PolyLine" ));
863 a->setToggleAction(true);
864 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
865 formatMenu->addAction (a);
866 actionFormatLinkStylePolyLine=a;
867 a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
868 a->setStatusTip (tr( "PolyParabel" ) );
869 a->setToggleAction(true);
870 a->setChecked (true);
871 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
872 formatMenu->addAction (a);
873 actionFormatLinkStylePolyParabel=a;
875 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
876 a->setStatusTip (tr( "Hide link" ));
877 a->setToggleAction(true);
878 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
879 actionFormatHideLinkUnselected=a;
881 formatMenu->addSeparator();
882 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
883 a->setStatusTip (tr( "Use same color for links and headings" ));
884 a->setToggleAction(true);
885 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
886 formatMenu->addAction (a);
887 actionFormatLinkColorHint=a;
889 pix.fill (Qt::white);
890 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
891 a->setStatusTip (tr( "Set Link Color" ));
892 formatMenu->addAction (a);
893 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
894 actionFormatLinkColor=a;
896 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
897 a->setStatusTip (tr( "Set Selection Color" ));
898 formatMenu->addAction (a);
899 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
900 actionFormatSelectionColor=a;
902 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
903 a->setStatusTip (tr( "Set Background Color" ));
904 formatMenu->addAction (a);
905 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
906 actionFormatBackColor=a;
908 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
909 a->setStatusTip (tr( "Set Background image" ));
910 formatMenu->addAction (a);
911 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
912 actionFormatBackImage=a;
916 void Main::setupViewActions()
918 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
919 tb->setLabel( "View Actions" );
920 tb->setObjectName ("viewTB");
921 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
924 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
925 a->setStatusTip ( tr( "Zoom reset" ) );
926 a->setShortcut (Qt::CTRL + Qt::Key_0 );
928 viewMenu->addAction (a);
929 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
931 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
932 a->setStatusTip (tr( "Zoom in" ));
933 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
935 viewMenu->addAction (a);
936 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
938 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
939 a->setStatusTip (tr( "Zoom out" ));
940 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
942 viewMenu->addAction (a);
943 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
946 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
947 a->setStatusTip ( tr( "Show Note Editor" ));
948 a->setShortcut ( Qt::CTRL + Qt::Key_E );
949 a->setToggleAction(true);
950 if (textEditor->showWithMain())
955 viewMenu->addAction (a);
956 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
957 actionViewToggleNoteEditor=a;
959 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
960 a->setStatusTip ( tr( "Show History Window" ));
961 a->setShortcut ( Qt::CTRL + Qt::Key_H );
962 a->setToggleAction(true);
964 viewMenu->addAction (a);
965 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
966 actionViewToggleHistoryWindow=a;
968 viewMenu->addAction (actionTogglePropertyWindow);
970 a = new QAction(tr( "Antialiasing","View action" ),this );
971 a->setStatusTip ( tr( "Antialiasing" ));
972 a->setToggleAction(true);
973 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
974 viewMenu->addAction (a);
975 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
976 actionViewToggleAntiAlias=a;
978 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
979 a->setStatusTip (a->text());
980 a->setToggleAction(true);
981 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
982 viewMenu->addAction (a);
983 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
984 actionViewToggleSmoothPixmapTransform=a;
986 a = new QAction(tr( "Next Map","View action" ), this);
987 a->setStatusTip (a->text());
988 a->setShortcut (Qt::ALT + Qt::Key_N );
989 viewMenu->addAction (a);
990 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
992 a = new QAction (tr( "Previous Map","View action" ), this );
993 a->setStatusTip (a->text());
994 a->setShortcut (Qt::ALT + Qt::Key_P );
995 viewMenu->addAction (a);
996 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1000 void Main::setupModeActions()
1002 //QPopupMenu *menu = new QPopupMenu( this );
1003 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1005 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1006 tb->setObjectName ("modesTB");
1008 actionGroupModModes=new QActionGroup ( this);
1009 actionGroupModModes->setExclusive (true);
1010 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1011 a->setShortcut (Qt::Key_J);
1012 a->setStatusTip ( tr( "Use modifier to color branches" ));
1013 a->setToggleAction(true);
1016 actionModModeColor=a;
1018 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1019 a->setShortcut( Qt::Key_K);
1020 a->setStatusTip( tr( "Use modifier to copy" ));
1021 a->setToggleAction(true);
1023 actionModModeCopy=a;
1025 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1026 a->setShortcut (Qt::Key_L);
1027 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1028 a->setToggleAction(true);
1030 actionModModeXLink=a;
1034 void Main::setupFlagActions()
1036 // Create System Flags
1037 systemFlagsDefault = new FlagRowObj ();
1038 systemFlagsDefault->setVisibility (false);
1039 systemFlagsDefault->setName ("systemFlagsDef");
1041 FlagObj *fo = new FlagObj ();
1042 fo->load(QPixmap(flagsPath+"flag-note.png"));
1043 fo->setName("note");
1044 fo->setToolTip(tr("Note","Systemflag"));
1045 systemFlagsDefault->addFlag (fo); // makes deep copy
1047 fo->load(QPixmap(flagsPath+"flag-url.png"));
1049 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1050 systemFlagsDefault->addFlag (fo);
1052 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1053 fo->setName("vymLink");
1054 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1055 systemFlagsDefault->addFlag (fo);
1057 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1058 fo->setName("scrolledright");
1059 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1060 systemFlagsDefault->addFlag (fo);
1062 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1063 fo->setName("tmpUnscrolledright");
1064 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1065 systemFlagsDefault->addFlag (fo);
1067 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1068 fo->setName("hideInExport");
1069 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1070 systemFlagsDefault->addFlag (fo);
1072 // Create Standard Flags
1073 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1074 tb->setObjectName ("standardFlagTB");
1076 standardFlagsDefault = new FlagRowObj ();
1077 standardFlagsDefault->setVisibility (false);
1078 standardFlagsDefault->setName ("standardFlagsDef");
1079 standardFlagsDefault->setToolBar (tb);
1081 fo->load(flagsPath+"flag-exclamationmark.png");
1082 fo->setName ("exclamationmark");
1083 fo->setGroup("standard-mark");
1084 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1087 a->setCheckable(true);
1088 a->setObjectName(fo->getName());
1089 a->setToolTip(tr("Take care!","Standardflag"));
1090 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1091 standardFlagsDefault->addFlag (fo); // makes deep copy
1093 fo->load(flagsPath+"flag-questionmark.png");
1094 fo->setName("questionmark");
1095 fo->setGroup("standard-mark");
1096 a=new QAction (fo->getPixmap(),fo->getName(),this);
1099 a->setCheckable(true);
1100 a->setObjectName(fo->getName());
1101 a->setToolTip(tr("Really?","Standardflag"));
1102 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1103 standardFlagsDefault->addFlag (fo);
1105 fo->load(flagsPath+"flag-hook-green.png");
1106 fo->setName("hook-green");
1107 fo->setGroup("standard-hook");
1108 a=new QAction (fo->getPixmap(),fo->getName(),this);
1111 a->setCheckable(true);
1112 a->setObjectName(fo->getName());
1113 a->setToolTip(tr("ok!","Standardflag"));
1114 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1115 standardFlagsDefault->addFlag (fo);
1117 fo->load(flagsPath+"flag-cross-red.png");
1118 fo->setName("cross-red");
1119 fo->setGroup("standard-hook");
1120 a=new QAction (fo->getPixmap(),fo->getName(),this);
1123 a->setCheckable(true);
1124 a->setObjectName(fo->getName());
1125 a->setToolTip(tr("Not ok!","Standardflag"));
1126 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1127 standardFlagsDefault->addFlag (fo);
1129 fo->load(flagsPath+"flag-stopsign.png");
1130 fo->setName("stopsign");
1131 a=new QAction (fo->getPixmap(),fo->getName(),this);
1134 a->setCheckable(true);
1135 a->setObjectName(fo->getName());
1136 a->setToolTip(tr("This won't work!","Standardflag"));
1137 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1138 standardFlagsDefault->addFlag (fo);
1140 fo->load(flagsPath+"flag-smiley-good.png");
1141 fo->setName("smiley-good");
1142 fo->setGroup("standard-smiley");
1143 a=new QAction (fo->getPixmap(),fo->getName(),this);
1146 a->setCheckable(true);
1147 a->setObjectName(fo->getName());
1148 a->setToolTip(tr("Good","Standardflag"));
1149 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1150 standardFlagsDefault->addFlag (fo);
1152 fo->load(flagsPath+"flag-smiley-sad.png");
1153 fo->setName("smiley-sad");
1154 fo->setGroup("standard-smiley");
1155 a=new QAction (fo->getPixmap(),fo->getName(),this);
1158 a->setCheckable(true);
1159 a->setObjectName(fo->getName());
1160 a->setToolTip(tr("Bad","Standardflag"));
1161 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1162 standardFlagsDefault->addFlag (fo);
1164 fo->load(flagsPath+"flag-smiley-omg.png");
1165 // Original omg.png (in KDE emoticons)
1166 fo->setName("smiley-omg");
1167 fo->setGroup("standard-smiley");
1168 a=new QAction (fo->getPixmap(),fo->getName(),this);
1171 a->setCheckable(true);
1172 a->setObjectName(fo->getName());
1173 a->setToolTip(tr("Oh no!","Standardflag"));
1174 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1175 standardFlagsDefault->addFlag (fo);
1177 fo->load(flagsPath+"flag-kalarm.png");
1178 fo->setName("clock");
1179 a=new QAction (fo->getPixmap(),fo->getName(),this);
1182 a->setCheckable(true);
1183 a->setObjectName(fo->getName());
1184 a->setToolTip(tr("Time critical","Standardflag"));
1185 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1186 standardFlagsDefault->addFlag (fo);
1188 fo->load(flagsPath+"flag-phone.png");
1189 fo->setName("phone");
1190 a=new QAction (fo->getPixmap(),fo->getName(),this);
1193 a->setCheckable(true);
1194 a->setObjectName(fo->getName());
1195 a->setToolTip(tr("Call...","Standardflag"));
1196 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1197 standardFlagsDefault->addFlag (fo);
1199 fo->load(flagsPath+"flag-lamp.png");
1200 fo->setName("lamp");
1201 a=new QAction (fo->getPixmap(),fo->getName(),this);
1204 a->setCheckable(true);
1205 a->setObjectName(fo->getName());
1206 a->setToolTip(tr("Idea!","Standardflag"));
1207 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1208 standardFlagsDefault->addFlag (fo);
1210 fo->load(flagsPath+"flag-arrow-up.png");
1211 fo->setName("arrow-up");
1212 fo->setGroup("standard-arrow");
1213 a=new QAction (fo->getPixmap(),fo->getName(),this);
1216 a->setCheckable(true);
1217 a->setObjectName(fo->getName());
1218 a->setToolTip(tr("Important","Standardflag"));
1219 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1220 standardFlagsDefault->addFlag (fo);
1222 fo->load(flagsPath+"flag-arrow-down.png");
1223 fo->setName("arrow-down");
1224 fo->setGroup("standard-arrow");
1225 a=new QAction (fo->getPixmap(),fo->getName(),this);
1228 a->setCheckable(true);
1229 a->setObjectName(fo->getName());
1230 a->setToolTip(tr("Unimportant","Standardflag"));
1231 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1232 standardFlagsDefault->addFlag (fo);
1234 fo->load(flagsPath+"flag-arrow-2up.png");
1235 fo->setName("2arrow-up");
1236 fo->setGroup("standard-arrow");
1237 a=new QAction (fo->getPixmap(),fo->getName(),this);
1240 a->setCheckable(true);
1241 a->setObjectName(fo->getName());
1242 a->setToolTip(tr("Very important!","Standardflag"));
1243 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1244 standardFlagsDefault->addFlag (fo);
1246 fo->load(flagsPath+"flag-arrow-2down.png");
1247 fo->setName("2arrow-down");
1248 fo->setGroup("standard-arrow");
1249 a=new QAction (fo->getPixmap(),fo->getName(),this);
1252 a->setCheckable(true);
1253 a->setObjectName(fo->getName());
1254 a->setToolTip(tr("Very unimportant!","Standardflag"));
1255 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1256 standardFlagsDefault->addFlag (fo);
1258 fo->load(flagsPath+"flag-thumb-up.png");
1259 fo->setName("thumb-up");
1260 fo->setGroup("standard-thumb");
1261 a=new QAction (fo->getPixmap(),fo->getName(),this);
1264 a->setCheckable(true);
1265 a->setObjectName(fo->getName());
1266 a->setToolTip(tr("I like this","Standardflag"));
1267 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1268 standardFlagsDefault->addFlag (fo);
1270 fo->load(flagsPath+"flag-thumb-down.png");
1271 fo->setName("thumb-down");
1272 fo->setGroup("standard-thumb");
1273 a=new QAction (fo->getPixmap(),fo->getName(),this);
1276 a->setCheckable(true);
1277 a->setObjectName(fo->getName());
1278 a->setToolTip(tr("I do not like this","Standardflag"));
1279 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1280 standardFlagsDefault->addFlag (fo);
1282 fo->load(flagsPath+"flag-rose.png");
1283 fo->setName("rose");
1284 a=new QAction (fo->getPixmap(),fo->getName(),this);
1287 a->setCheckable(true);
1288 a->setObjectName(fo->getName());
1289 a->setToolTip(tr("Rose","Standardflag"));
1290 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1291 standardFlagsDefault->addFlag (fo);
1293 fo->load(flagsPath+"flag-heart.png");
1294 fo->setName("heart");
1295 a=new QAction (fo->getPixmap(),fo->getName(),this);
1297 a->setCheckable(true);
1298 a->setObjectName(fo->getName());
1299 a->setToolTip(tr("I just love... ","Standardflag"));
1300 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1301 standardFlagsDefault->addFlag (fo);
1303 fo->load(flagsPath+"flag-present.png");
1304 fo->setName("present");
1305 a=new QAction (fo->getPixmap(),fo->getName(),this);
1308 a->setCheckable(true);
1309 a->setObjectName(fo->getName());
1310 a->setToolTip(tr("Surprise!","Standardflag"));
1311 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1312 standardFlagsDefault->addFlag (fo);
1314 fo->load(flagsPath+"flag-flash.png");
1315 fo->setName("flash");
1316 a=new QAction (fo->getPixmap(),fo->getName(),this);
1319 a->setCheckable(true);
1320 a->setObjectName(fo->getName());
1321 a->setToolTip(tr("Dangerous","Standardflag"));
1322 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1323 standardFlagsDefault->addFlag (fo);
1325 fo->load(flagsPath+"flag-info.png");
1326 // Original: xsldbg_output.png
1327 fo->setName("info");
1328 a=new QAction (fo->getPixmap(),fo->getName(),this);
1331 a->setCheckable(true);
1332 a->setObjectName(fo->getName());
1333 a->setToolTip(tr("Info","Standardflag"));
1334 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1335 standardFlagsDefault->addFlag (fo);
1337 fo->load(flagsPath+"flag-lifebelt.png");
1338 // Original khelpcenter.png
1339 fo->setName("lifebelt");
1340 a=new QAction (fo->getPixmap(),fo->getName(),this);
1343 a->setCheckable(true);
1344 a->setObjectName(fo->getName());
1345 a->setToolTip(tr("This will help","Standardflag"));
1346 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1347 standardFlagsDefault->addFlag (fo);
1353 void Main::setupSettingsActions()
1355 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1359 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1360 a->setStatusTip ( tr( "Set application to open pdf files"));
1361 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1362 settingsMenu->addAction (a);
1364 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1365 a->setStatusTip( tr( "Set application to open external links"));
1366 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1367 settingsMenu->addAction (a);
1369 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1370 a->setStatusTip( tr( "Set path for macros"));
1371 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1372 settingsMenu->addAction (a);
1374 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1375 a->setStatusTip( tr( "Set number of undo levels"));
1376 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1377 settingsMenu->addAction (a);
1379 settingsMenu->addSeparator();
1381 a = new QAction( tr( "Autosave","Settings action"), this);
1382 a->setStatusTip( tr( "Autosave"));
1383 a->setToggleAction(true);
1384 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1385 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1386 settingsMenu->addAction (a);
1387 actionSettingsAutosaveToggle=a;
1389 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1390 a->setStatusTip( tr( "Autosave time"));
1391 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1392 settingsMenu->addAction (a);
1393 actionSettingsAutosaveTime=a;
1395 settingsMenu->addSeparator();
1397 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1398 a->setStatusTip( tr( "Edit branch after adding it" ));
1399 a->setToggleAction(true);
1400 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1401 settingsMenu->addAction (a);
1402 actionSettingsAutoEdit=a;
1404 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1405 a->setStatusTip( tr( "Select branch after adding it" ));
1406 a->setToggleAction(true);
1407 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1408 settingsMenu->addAction (a);
1409 actionSettingsAutoSelectHeading=a;
1411 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1412 a->setStatusTip( tr( "Select heading before editing" ));
1413 a->setToggleAction(true);
1414 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1415 settingsMenu->addAction (a);
1416 actionSettingsAutoSelectText=a;
1418 a= new QAction( tr( "Delete key","Settings action" ), this);
1419 a->setStatusTip( tr( "Delete key for deleting branches" ));
1420 a->setToggleAction(true);
1421 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",false).toBool() );
1422 settingsMenu->addAction (a);
1423 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1424 actionSettingsUseDelKey=a;
1426 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1427 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1428 a->setToggleAction(true);
1429 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1430 settingsMenu->addAction (a);
1431 actionSettingsUseFlagGroups=a;
1433 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1434 a->setStatusTip( tr( "Use hide flag during exports " ));
1435 a->setToggleAction(true);
1436 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1437 settingsMenu->addAction (a);
1438 actionSettingsUseHideExport=a;
1442 void Main::setupTestActions()
1444 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1447 a = new QAction( "Test function" , this);
1448 a->setStatusTip( "Call test function" );
1449 //a->setShortcut (Qt::Key_F4 );
1450 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1451 testMenu->addAction (a);
1452 a = new QAction( "Command" , this);
1453 a->setStatusTip( "Enter command to call in editor" );
1454 //a->setShortcut (Qt::Key_F5 );
1455 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1456 testMenu->addAction (a);
1460 void Main::setupHelpActions()
1462 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1465 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1466 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1467 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1468 helpMenu->addAction (a);
1470 a = new QAction( tr( "About VYM","Help action" ), this);
1471 a->setStatusTip( tr( "About VYM")+vymName);
1472 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1473 helpMenu->addAction (a);
1475 a = new QAction( tr( "About QT","Help action" ), this);
1476 a->setStatusTip( tr( "Information about QT toolkit" ));
1477 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1478 helpMenu->addAction (a);
1482 void Main::setupContextMenus()
1486 // Context Menu for branch or mapcenter
1487 branchContextMenu =new QMenu (this);
1488 branchContextMenu->addAction (actionTogglePropertyWindow);
1489 branchContextMenu->addSeparator();
1492 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1493 branchAddContextMenu->addAction (actionEditPaste );
1494 branchAddContextMenu->addAction ( actionEditAddBranch );
1495 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1496 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1497 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1498 branchAddContextMenu->addSeparator();
1499 branchAddContextMenu->addAction ( actionEditImportAdd );
1500 branchAddContextMenu->addAction ( actionEditImportReplace );
1503 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1504 branchRemoveContextMenu->addAction (actionEditCut);
1505 branchRemoveContextMenu->addAction ( actionEditDelete );
1506 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1507 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1510 actionEditSaveBranch->addTo( branchContextMenu );
1512 branchContextMenu->addSeparator();
1513 branchContextMenu->addAction ( actionEditLoadImage);
1515 // Submenu for Links (URLs, vymLinks)
1516 branchLinksContextMenu =new QMenu (this);
1518 branchContextMenu->addSeparator();
1519 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1520 branchLinksContextMenu->addAction ( actionEditOpenURL );
1521 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1522 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1523 branchLinksContextMenu->addAction ( actionEditURL );
1524 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1525 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1526 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1528 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1530 branchLinksContextMenu->addSeparator();
1531 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1532 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1533 branchLinksContextMenu->addAction ( actionEditVymLink );
1534 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1537 // Context Menu for XLinks in a branch menu
1538 // This will be populated "on demand" in MapEditor::updateActions
1539 branchContextMenu->addSeparator();
1540 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1541 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1542 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1543 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1546 // Context menu for floatimage
1547 floatimageContextMenu =new QMenu (this);
1548 a= new QAction (tr ("Save image","Context action"),this);
1549 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1550 floatimageContextMenu->addAction (a);
1552 floatimageContextMenu->addSeparator();
1553 actionEditCopy->addTo( floatimageContextMenu );
1554 actionEditCut->addTo( floatimageContextMenu );
1556 floatimageContextMenu->addSeparator();
1557 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1560 // Context menu for canvas
1561 canvasContextMenu =new QMenu (this);
1562 actionEditMapInfo->addTo( canvasContextMenu );
1563 canvasContextMenu->insertSeparator();
1564 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1565 canvasContextMenu->insertSeparator();
1566 actionFormatLinkColorHint->addTo( canvasContextMenu );
1567 actionFormatLinkColor->addTo( canvasContextMenu );
1568 actionFormatSelectionColor->addTo( canvasContextMenu );
1569 actionFormatBackColor->addTo( canvasContextMenu );
1570 actionFormatBackImage->addTo( canvasContextMenu );
1572 // Menu for last opened files
1574 for (int i = 0; i < MaxRecentFiles; ++i)
1576 recentFileActions[i] = new QAction(this);
1577 recentFileActions[i]->setVisible(false);
1578 fileLastMapsMenu->addAction(recentFileActions[i]);
1579 connect(recentFileActions[i], SIGNAL(triggered()),
1580 this, SLOT(fileLoadRecent()));
1582 setupRecentMapsMenu();
1585 void Main::setupRecentMapsMenu()
1587 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1589 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1591 for (int i = 0; i < numRecentFiles; ++i) {
1592 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1593 recentFileActions[i]->setText(text);
1594 recentFileActions[i]->setData(files[i]);
1595 recentFileActions[i]->setVisible(true);
1597 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1598 recentFileActions[j]->setVisible(false);
1601 void Main::setupMacros()
1603 for (int i = 0; i <= 11; i++)
1605 macroActions[i] = new QAction(this);
1606 macroActions[i]->setData(i);
1607 addAction (macroActions[i]);
1608 connect(macroActions[i], SIGNAL(triggered()),
1609 this, SLOT(callMacro()));
1611 macroActions[0]->setShortcut ( Qt::Key_F1 );
1612 macroActions[1]->setShortcut ( Qt::Key_F2 );
1613 macroActions[2]->setShortcut ( Qt::Key_F3 );
1614 macroActions[3]->setShortcut ( Qt::Key_F4 );
1615 macroActions[4]->setShortcut ( Qt::Key_F5 );
1616 macroActions[5]->setShortcut ( Qt::Key_F6 );
1617 macroActions[6]->setShortcut ( Qt::Key_F7 );
1618 macroActions[7]->setShortcut ( Qt::Key_F8 );
1619 macroActions[8]->setShortcut ( Qt::Key_F9 );
1620 macroActions[9]->setShortcut ( Qt::Key_F10 );
1621 macroActions[10]->setShortcut ( Qt::Key_F11 );
1622 macroActions[11]->setShortcut ( Qt::Key_F12 );
1625 void Main::hideEvent (QHideEvent * )
1627 if (!textEditor->isMinimized() ) textEditor->hide();
1630 void Main::showEvent (QShowEvent * )
1632 if (textEditor->showWithMain()) textEditor->showNormal();
1635 bool Main::reallyWriteDirectory(const QString &dir)
1637 QStringList eList = QDir(dir).entryList();
1638 if (eList.first() ==".") eList.pop_front(); // remove "."
1639 if (eList.first() =="..") eList.pop_front(); // remove "."
1640 if (!eList.isEmpty())
1642 QMessageBox mb( vymName,
1643 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1644 QMessageBox::Warning,
1646 QMessageBox::Cancel | QMessageBox::Default,
1647 QMessageBox::QMessageBox::NoButton );
1649 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1650 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1653 case QMessageBox::Yes:
1656 case QMessageBox::Cancel:
1664 QString Main::browseDirectory (const QString &caption)
1666 QFileDialog fd(this,caption);
1667 fd.setMode (QFileDialog::DirectoryOnly);
1668 fd.setCaption(vymName+ " - "+caption);
1669 fd.setDir (lastFileDir);
1672 if ( fd.exec() == QDialog::Accepted )
1673 return fd.selectedFile();
1678 MapEditor* Main::currentMapEditor() const
1680 if ( tabWidget->currentPage() &&
1681 tabWidget->currentPage()->inherits( "MapEditor" ) )
1682 return (MapEditor*)tabWidget->currentPage();
1687 void Main::editorChanged(QWidget *)
1689 // Unselect all possibly selected objects
1690 // (Important to update note editor)
1692 for (int i=0;i<=tabWidget->count() -1;i++)
1695 me=(MapEditor*)tabWidget->page(i);
1698 currentMapEditor()->reselect();
1700 // Update actions to in menus and toolbars according to editor
1704 void Main::fileNew()
1706 QString fn="unnamed";
1707 MapEditor* me = new MapEditor ( NULL);
1708 tabWidget->addTab (me,fn);
1709 tabWidget->showPage(me);
1710 me->viewport()->setFocus();
1711 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1712 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1714 // For the very first map we do not have flagrows yet...
1718 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1720 ErrorCode err=success;
1722 // fn is usually the archive, mapfile the file after uncompressing
1725 // Make fn absolute (needed for unzip)
1726 fn=QDir (fn).absPath();
1732 // Check, if map is already loaded
1734 while (i<=tabWidget->count() -1)
1736 me=(MapEditor*)tabWidget->page(i);
1737 if (me->getFilePath() == fn)
1739 // Already there, ask for confirmation
1740 QMessageBox mb( vymName,
1741 tr("The map %1\nis already opened."
1742 "Opening the same map in multiple editors may lead \n"
1743 "to confusion when finishing working with vym."
1744 "Do you want to").arg(fn),
1745 QMessageBox::Warning,
1746 QMessageBox::Yes | QMessageBox::Default,
1747 QMessageBox::Cancel | QMessageBox::Escape,
1748 QMessageBox::NoButton);
1749 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1750 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1753 case QMessageBox::Yes:
1755 i=tabWidget->count();
1757 case QMessageBox::Cancel:
1769 if ( !fn.isEmpty() )
1771 me = currentMapEditor();
1772 int tabIndex=tabWidget->currentPageIndex();
1773 // Check first, if mapeditor exists
1774 // If it is not default AND we want a new map,
1775 // create a new mapeditor in a new tab
1776 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1778 me= new MapEditor ( NULL);
1779 tabWidget->addTab (me,fn);
1780 tabIndex=tabWidget->indexOf (me);
1781 tabWidget->setCurrentPage (tabIndex);
1782 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1783 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1786 // Check, if file exists (important for creating new files
1787 // from command line
1788 if (!QFile(fn).exists() )
1790 QMessageBox mb( vymName,
1791 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1792 QMessageBox::Question,
1794 QMessageBox::Cancel | QMessageBox::Default,
1795 QMessageBox::NoButton );
1797 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1798 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1801 case QMessageBox::Yes:
1803 currentMapEditor()->setFilePath(fn);
1804 tabWidget->setTabLabel (currentMapEditor(),
1805 currentMapEditor()->getFileName() );
1806 statusBar()->message( "Created " + fn , statusbarTime );
1809 case QMessageBox::Cancel:
1810 // don't create new map
1811 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1818 //tabWidget->currentPage() won't be NULL here, because of above...
1819 tabWidget->showPage(me);
1820 me->viewport()->setFocus();
1822 // Create temporary directory for packing
1824 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1827 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1828 tr("Couldn't create temporary directory before load\n"));
1832 // Try to unzip file
1833 err=unzipDir (tmpMapDir,fn);
1837 me->setZipped(false);
1840 me->setZipped(true);
1842 // Look for mapname.xml
1843 mapfile= fn.left(fn.findRev(".",-1,true));
1844 mapfile=mapfile.section( '/', -1 );
1845 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1846 if (!file.exists() )
1848 // mapname.xml does not exist, well,
1849 // maybe someone renamed the mapname.vym file...
1850 // Try to find any .xml in the toplevel
1851 // directory of the .vym file
1852 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1853 if (flist.count()==1)
1855 // Only one entry, take this one
1856 mapfile=tmpMapDir + "/"+flist.first();
1859 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1860 *it=tmpMapDir + "/" + *it;
1861 // TODO Multiple entries, load all (but only the first one into this ME)
1862 //mainWindow->fileLoadFromTmp (flist);
1863 //returnCode=1; // Silently forget this attempt to load
1864 qWarning ("MainWindow::load (fn) multimap found...");
1867 if (flist.isEmpty() )
1869 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1870 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1873 } //file doesn't exist
1875 mapfile=file.name();
1880 // Save existing filename in case we import
1881 QString fn_org=me->getFilePath();
1883 // Finally load map into mapEditor
1884 me->setFilePath (mapfile,fn);
1885 err=me->load(mapfile,lmode);
1887 // Restore old (maybe empty) filepath, if this is an import
1889 me->setFilePath (fn_org);
1892 // Finally check for errors and go home
1895 if (lmode==NewMap) fileCloseMap();
1896 statusBar()->message( "Could not load " + fn, statusbarTime );
1901 me->setFilePath (fn);
1902 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1903 if (fn.left(9)!="/tmp/vym-")
1905 // Only append to lastMaps if not loaded from a tmpDir
1906 // e.g. imported bookmarks are in a tmpDir
1907 addRecentMap(me->getFilePath() );
1909 actionFilePrint->setEnabled (true);
1911 statusBar()->message( "Loaded " + fn, statusbarTime );
1915 removeDir (QDir(tmpMapDir));
1921 void Main::fileLoad(const LoadMode &lmode)
1923 QStringList filters;
1924 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1925 QFileDialog *fd=new QFileDialog( this);
1926 fd->setDir (lastFileDir);
1927 fd->setFileMode (QFileDialog::ExistingFiles);
1928 fd->setFilters (filters);
1932 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1935 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1938 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1944 if ( fd->exec() == QDialog::Accepted )
1946 lastFileDir=fd->directory().path();
1947 QStringList flist = fd->selectedFiles();
1948 QStringList::Iterator it = flist.begin();
1949 while( it != flist.end() )
1952 fileLoad(*it, lmode);
1959 void Main::fileLoad()
1964 void Main::fileLoadRecent()
1966 QAction *action = qobject_cast<QAction *>(sender());
1968 fileLoad (action->data().toString(), NewMap);
1971 void Main::addRecentMap (const QString &fileName)
1974 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1975 files.removeAll(fileName);
1976 files.prepend(fileName);
1977 while (files.size() > MaxRecentFiles)
1980 settings.setValue("/mainwindow/recentFileList", files);
1982 setupRecentMapsMenu();
1985 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1987 // tmp dir for zipping
1991 ErrorCode err=success;
1993 QString safeFilePath;
1995 bool saveZipped=me->saveZipped();
1999 QString fn=me->getFilePath();
2000 // filename=unnamed, filepath="" in constructor of mapEditor
2001 if ( !fn.isEmpty() )
2003 // We have a filepath, go on saving
2004 // First remove existing file, we
2005 // don't want to add to old zip archives
2009 QMessageBox::warning( 0, tr( "Save Error" ),
2010 fn+ tr("\ncould not be removed before saving"));
2012 // Look, if we should zip the data:
2015 QMessageBox mb( vymName,
2016 tr("The map %1\ndid not use the compressed "
2017 "vym file format.\nWriting it uncompressed will also write images \n"
2018 "and flags and thus may overwrite files in the "
2019 "given directory\n\nDo you want to write the map").arg(fn),
2020 QMessageBox::Warning,
2021 QMessageBox::Yes | QMessageBox::Default,
2023 QMessageBox::Cancel | QMessageBox::Escape);
2024 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2025 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2026 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2029 case QMessageBox::Yes:
2030 // save compressed (default file format)
2033 case QMessageBox::No:
2034 // save uncompressed
2037 case QMessageBox::Cancel:
2046 // Create temporary directory for packing
2048 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2051 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2052 tr("Couldn't create temporary directory before save\n"));
2056 safeFilePath=me->getFilePath();
2057 me->setFilePath (tmpMapDir+"/"+
2058 me->getMapName()+ ".xml",
2060 me->save (savemode);
2061 me->setFilePath (safeFilePath);
2063 zipDir (tmpMapDir,fn);
2068 safeFilePath=me->getFilePath();
2069 me->setFilePath (fn, safeFilePath);
2070 me->save (savemode);
2071 me->setFilePath (safeFilePath);
2073 } // filepath available
2076 // We have no filepath yet,
2077 // call fileSaveAs() now, this will call fileSave()
2079 // First switch to editor
2080 tabWidget->setCurrentWidget (me);
2081 fileSaveAs(savemode);
2085 if (saveZipped && !tmpMapDir.isEmpty())
2087 removeDir (QDir(tmpMapDir));
2091 statusBar()->message(
2092 tr("Saved %1").arg(me->getFilePath()),
2094 addRecentMap (me->getFilePath() );
2096 statusBar()->message(
2097 tr("Couldn't save ").arg(me->getFilePath()),
2101 void Main::fileSave()
2103 fileSave (currentMapEditor(), CompleteMap);
2106 void Main::fileSave(MapEditor *me)
2108 fileSave (me,CompleteMap);
2111 void Main::fileSaveAs(const SaveMode& savemode)
2115 if (currentMapEditor())
2117 if (savemode==CompleteMap)
2118 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2120 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2121 if ( !fn.isEmpty() )
2123 // Check for existing file
2124 if (QFile (fn).exists())
2126 QMessageBox mb( vymName,
2127 tr("The file %1\nexists already. Do you want to").arg(fn),
2128 QMessageBox::Warning,
2129 QMessageBox::Yes | QMessageBox::Default,
2130 QMessageBox::Cancel | QMessageBox::Escape,
2131 QMessageBox::NoButton);
2132 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2133 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2136 case QMessageBox::Yes:
2139 case QMessageBox::Cancel:
2146 // New file, add extension to filename, if missing
2147 // This is always .vym or .vyp, depending on savemode
2148 if (savemode==CompleteMap)
2150 if (!fn.contains (".vym") && !fn.contains (".xml"))
2154 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2163 currentMapEditor()->setFilePath(fn);
2164 fileSave(currentMapEditor(), savemode);
2167 if (savemode==CompleteMap)
2168 tabWidget->setTabLabel (currentMapEditor(),
2169 currentMapEditor()->getFileName() );
2175 void Main::fileSaveAs()
2177 fileSaveAs (CompleteMap);
2180 void Main::fileImportKDEBookmarks()
2182 ImportKDEBookmarks im;
2184 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2185 currentMapEditor()->setFilePath ("");
2188 void Main::fileImportFirefoxBookmarks()
2190 Q3FileDialog *fd=new Q3FileDialog( this);
2191 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2192 fd->setMode (Q3FileDialog::ExistingFiles);
2193 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2194 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2197 if ( fd->exec() == QDialog::Accepted )
2199 ImportFirefoxBookmarks im;
2200 QStringList flist = fd->selectedFiles();
2201 QStringList::Iterator it = flist.begin();
2202 while( it != flist.end() )
2205 if (im.transform() &&
2206 success==fileLoad (im.getTransformedFile(),NewMap) &&
2207 currentMapEditor() )
2208 currentMapEditor()->setFilePath ("");
2215 void Main::fileImportMM()
2219 Q3FileDialog *fd=new Q3FileDialog( this);
2220 fd->setDir (lastFileDir);
2221 fd->setMode (Q3FileDialog::ExistingFiles);
2222 fd->addFilter ("Mind Manager (*.mmap)");
2223 fd->setCaption(tr("Import")+" "+"Mind Manager");
2226 if ( fd->exec() == QDialog::Accepted )
2228 lastFileDir=fd->dirPath();
2229 QStringList flist = fd->selectedFiles();
2230 QStringList::Iterator it = flist.begin();
2231 while( it != flist.end() )
2234 if (im.transform() &&
2235 success==fileLoad (im.getTransformedFile(),NewMap) &&
2236 currentMapEditor() )
2237 currentMapEditor()->setFilePath ("");
2246 void Main::fileImportDir()
2248 if (currentMapEditor())
2249 currentMapEditor()->importDir();
2252 void Main::fileExportXML()
2254 if (currentMapEditor())
2256 QString dir=browseDirectory(tr("Export XML to directory"));
2257 if (dir !="" && reallyWriteDirectory(dir) )
2258 currentMapEditor()->exportXML(dir);
2263 void Main::fileExportXHTML()
2265 MapEditor *me=currentMapEditor();
2269 ExportXHTMLDialog dia(this);
2270 dia.setFilePath (me->getFilePath() );
2271 dia.setMapName (me->getMapName() );
2274 if (dia.exec()==QDialog::Accepted)
2276 QString dir=dia.getDir();
2277 // Check, if warnings should be used before overwriting
2278 // the output directory
2280 warn.showCancelButton (true);
2281 warn.setText(QString(
2282 "The directory %1 is not empty.\n"
2283 "Do you risk to overwrite some of its contents?").arg(dir));
2284 warn.setCaption("Warning: Directory not empty");
2285 warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
2286 if (warn.exec()==QDialog::Accepted)
2288 me->exportXML (dia.getDir() );
2289 dia.doExport(me->getMapName() );
2290 if (dia.hasChanged())
2297 void Main::fileExportImage()
2299 MapEditor *me=currentMapEditor();
2303 QFileDialog *fd=new QFileDialog (this);
2304 fd->setCaption (tr("Export map as image"));
2305 fd->setDirectory (lastImageDir);
2306 fd->setFileMode(QFileDialog::AnyFile);
2307 fd->setFilters (imageIO.getFilters() );
2310 fl=fd->selectedFiles();
2311 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2316 void Main::fileExportASCII()
2318 MapEditor *me=currentMapEditor();
2322 ex.setMapCenter(me->getMapCenter());
2323 ex.addFilter ("TXT (*.txt)");
2324 ex.setDir(lastImageDir);
2325 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2326 if (ex.execDialog() )
2328 me->setExportMode(true);
2330 me->setExportMode(false);
2335 void Main::fileExportLaTeX()
2337 MapEditor *me=currentMapEditor();
2341 ex.setMapCenter(me->getMapCenter());
2342 ex.addFilter ("Tex (*.tex)");
2343 ex.setDir(lastImageDir);
2344 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2345 if (ex.execDialog() )
2347 me->setExportMode(true);
2349 me->setExportMode(false);
2354 void Main::fileExportKDEBookmarks()
2356 ExportKDEBookmarks ex;
2357 MapEditor *me=currentMapEditor();
2360 ex.setMapCenter (me->getMapCenter() );
2365 void Main::fileExportTaskjuggler()
2367 ExportTaskjuggler ex;
2368 MapEditor *me=currentMapEditor();
2371 ex.setMapCenter (me->getMapCenter() );
2372 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2373 ex.setDir(lastImageDir);
2374 ex.addFilter ("Taskjuggler (*.tjp)");
2375 if (ex.execDialog() )
2377 me->setExportMode(true);
2379 me->setExportMode(false);
2384 void Main::fileExportOOPresentation()
2386 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2387 // TODO add preview in dialog
2388 //ImagePreview *p =new ImagePreview (fd);
2389 //fd->setContentsPreviewEnabled( TRUE );
2390 //fd->setContentsPreview( p, p );
2391 //fd->setPreviewMode( QFileDialog::Contents );
2392 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2393 fd->setDir (QDir().current());
2394 if (fd->foundConfig())
2398 if ( fd->exec() == QDialog::Accepted )
2400 QString fn=fd->selectedFile();
2401 if (!fn.contains (".odp"))
2404 //lastImageDir=fn.left(fn.findRev ("/"));
2405 if (currentMapEditor())
2406 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2410 QMessageBox::warning(0,
2412 tr("Couldn't find configuration for export to Open Office\n"));
2416 void Main::fileCloseMap()
2418 if (currentMapEditor())
2420 if (currentMapEditor()->hasChanged())
2422 QMessageBox mb( vymName,
2423 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2424 QMessageBox::Warning,
2425 QMessageBox::Yes | QMessageBox::Default,
2427 QMessageBox::Cancel | QMessageBox::Escape );
2428 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2429 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2432 case QMessageBox::Yes:
2434 fileSave(currentMapEditor(), CompleteMap);
2436 case QMessageBox::No:
2437 // close without saving
2439 case QMessageBox::Cancel:
2444 currentMapEditor()->closeMap();
2445 tabWidget->removePage(currentMapEditor());
2446 if (tabWidget->count()==0)
2447 actionFilePrint->setEnabled (false);
2451 void Main::filePrint()
2453 if (currentMapEditor())
2454 currentMapEditor()->print();
2457 void Main::fileExitVYM()
2459 // Check if one or more editors have changed
2462 for (i=0;i<=tabWidget->count() -1;i++)
2465 me=(MapEditor*)tabWidget->page(i);
2467 // If something changed, ask what to do
2468 if (me->isUnsaved())
2470 tabWidget->setCurrentPage(i);
2471 QMessageBox mb( vymName,
2472 tr("This map is not saved yet. Do you want to"),
2473 QMessageBox::Warning,
2474 QMessageBox::Yes | QMessageBox::Default,
2476 QMessageBox::Cancel | QMessageBox::Escape );
2477 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2478 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2481 mb.setActiveWindow();
2482 switch( mb.exec() ) {
2483 case QMessageBox::Yes:
2484 // save (the changed editors) and exit
2485 fileSave(currentMapEditor(), CompleteMap);
2487 case QMessageBox::No:
2488 // exit without saving
2490 case QMessageBox::Cancel:
2491 // don't save and don't exit
2495 } // loop over all MEs
2499 void Main::editUndo()
2501 if (currentMapEditor())
2502 currentMapEditor()->undo();
2505 void Main::editRedo()
2507 if (currentMapEditor())
2508 currentMapEditor()->redo();
2511 void Main::gotoHistoryStep (int i)
2513 if (currentMapEditor())
2514 currentMapEditor()->gotoHistoryStep (i);
2517 void Main::editCopy()
2519 if (currentMapEditor())
2520 currentMapEditor()->copy();
2523 void Main::editPaste()
2525 if (currentMapEditor())
2526 currentMapEditor()->paste();
2529 void Main::editCut()
2531 if (currentMapEditor())
2532 currentMapEditor()->cut();
2535 void Main::editOpenFindWindow()
2537 findWindow->popup();
2538 findWindow->raise();
2539 findWindow->setActiveWindow();
2542 void Main::editFind(QString s)
2545 BranchObj *bo=currentMapEditor()->findText(s, cs);
2548 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2551 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2552 tr("No matches found for \"%1\"").arg(s));
2556 void Main::editFindChanged()
2557 { // Notify editor, to abort the current find process
2558 currentMapEditor()->findReset();
2561 void Main::openTabs(QStringList urls)
2563 if (!urls.isEmpty())
2567 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2569 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2571 QString u=urls.takeFirst();
2572 procBrowser = new QProcess( this );
2574 procBrowser->start(browser,args);
2575 if ( !procBrowser->waitForStarted())
2577 // try to set path to browser
2578 QMessageBox::warning(0,
2580 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2581 tr("Please use Settings->")+tr("Set application to open an URL"));
2586 if (browser.contains("konqueror"))
2588 for (int i=0; i<urls.size(); i++)
2591 // Try to open new tab in existing konqueror started previously by vym
2592 p=new QProcess (this);
2594 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2595 "konqueror-mainwindow#1"<<
2598 p->start ("dcop",args);
2599 if ( !p->waitForStarted() ) success=false;
2602 QMessageBox::warning(0,
2604 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2606 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2608 for (int i=0; i<urls.size(); i++)
2610 // Try to open new tab in firefox
2611 p=new QProcess (this);
2612 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2613 p->start (browser,args);
2614 if ( !p->waitForStarted() ) success=false;
2617 QMessageBox::warning(0,
2619 tr("Couldn't start %1 to open a new tab").arg(browser));
2622 QMessageBox::warning(0,
2624 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2628 void Main::editOpenURL()
2631 if (currentMapEditor())
2633 QString url=currentMapEditor()->getURL();
2635 if (url=="") return;
2636 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2637 procBrowser = new QProcess( this );
2639 procBrowser->start(browser,args);
2640 if ( !procBrowser->waitForStarted())
2642 // try to set path to browser
2643 QMessageBox::warning(0,
2645 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2646 tr("Please use Settings->")+tr("Set application to open an URL"));
2651 void Main::editOpenURLTab()
2653 if (currentMapEditor())
2656 urls.append(currentMapEditor()->getURL());
2660 void Main::editOpenMultipleURLTabs()
2662 if (currentMapEditor())
2665 urls=currentMapEditor()->getURLs();
2671 void Main::editURL()
2673 if (currentMapEditor())
2674 currentMapEditor()->editURL();
2677 void Main::editHeading2URL()
2679 if (currentMapEditor())
2680 currentMapEditor()->editHeading2URL();
2683 void Main::editBugzilla2URL()
2685 if (currentMapEditor())
2686 currentMapEditor()->editBugzilla2URL();
2689 void Main::editFATE2URL()
2691 if (currentMapEditor())
2692 currentMapEditor()->editFATE2URL();
2695 void Main::editHeadingFinished()
2697 // only called from editHeading(), so there is a currentME
2698 MapEditor *me=currentMapEditor();
2701 QPoint p; //Not used here, only to find out pos of branch
2703 QString s=me->getHeading(ok,p);
2705 #if defined(Q_OS_MACX)
2707 if (ok && s!=lineedit->text())
2708 me->setHeading(lineedit->text());
2710 lineedit->releaseKeyboard();
2714 if (!prevSelection.isEmpty()) me->select(prevSelection);
2719 void Main::editHeading()
2721 if (currentMapEditor())
2723 MapEditor *me=currentMapEditor();
2724 QString oldSel=me->getSelectString();
2726 if (lineedit->isVisible())
2727 editHeadingFinished();
2732 QString s=currentMapEditor()->getHeading(ok,p);
2736 #if defined(Q_OS_MACX)
2737 p=currentMapEditor()->mapTo (this,p);
2738 QDialog *d =new QDialog(NULL);
2739 QLineEdit *le=new QLineEdit (d);
2740 d->setWindowFlags (Qt::FramelessWindowHint);
2741 d->setGeometry(p.x(),p.y(),230,25);
2742 le->resize (d->width()-10,d->height());
2745 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2746 d->activateWindow();
2748 currentMapEditor()->setHeading (le->text());
2751 editHeadingFinished();
2753 p=currentMapEditor()->mapTo (this,p);
2754 lineedit->setGeometry(p.x(),p.y(),230,25);
2755 lineedit->setText(s);
2756 lineedit->setCursorPosition(1);
2757 lineedit->selectAll();
2759 lineedit->grabKeyboard();
2760 lineedit->setFocus();
2764 } // currentMapEditor()
2767 void Main::openVymLinks(const QStringList &vl)
2769 for (int j=0; j<vl.size(); j++)
2771 // compare path with already loaded maps
2775 for (i=0;i<=tabWidget->count() -1;i++)
2777 me=(MapEditor*)tabWidget->page(i);
2778 if (vl.at(j)==me->getFilePath() )
2787 if (!QFile(vl.at(j)).exists() )
2788 QMessageBox::critical( 0, tr( "Critical Error" ),
2789 tr("Couldn't open map %1").arg(vl.at(j)));
2792 fileLoad (vl.at(j), NewMap);
2793 tabWidget->setCurrentPage (tabWidget->count()-1);
2796 // Go to tab containing the map
2797 tabWidget->setCurrentPage (index);
2801 void Main::editOpenVymLink()
2803 if (currentMapEditor())
2806 vl.append(currentMapEditor()->getVymLink());
2811 void Main::editOpenMultipleVymLinks()
2813 QString currentVymLink;
2814 if (currentMapEditor())
2816 QStringList vl=currentMapEditor()->getVymLinks();
2821 void Main::editVymLink()
2823 if (currentMapEditor())
2824 currentMapEditor()->editVymLink();
2827 void Main::editDeleteVymLink()
2829 if (currentMapEditor())
2830 currentMapEditor()->deleteVymLink();
2833 void Main::editToggleHideExport()
2835 if (currentMapEditor())
2836 currentMapEditor()->toggleHideExport();
2839 void Main::editMapInfo()
2841 if (currentMapEditor())
2842 currentMapEditor()->editMapInfo();
2845 void Main::editMoveUp()
2847 if (currentMapEditor())
2848 currentMapEditor()->moveBranchUp();
2851 void Main::editMoveDown()
2853 if (currentMapEditor())
2854 currentMapEditor()->moveBranchDown();
2857 void Main::editToggleScroll()
2859 if (currentMapEditor())
2861 currentMapEditor()->toggleScroll();
2865 void Main::editUnscrollChilds()
2867 if (currentMapEditor())
2868 currentMapEditor()->unscrollChilds();
2871 void Main::editNewBranch()
2873 MapEditor *me=currentMapEditor();
2874 if (!lineedit->isVisible() && me)
2876 BranchObj *bo=(BranchObj*)me->getSelection();
2877 BranchObj *newbo=me->addNewBranch(0);
2880 me->select (newbo->getSelectString());
2884 if (actionSettingsAutoEdit->isOn())
2886 if (!actionSettingsAutoSelectHeading->isOn())
2887 prevSelection=bo->getSelectString();
2893 void Main::editNewBranchBefore()
2895 MapEditor *me=currentMapEditor();
2896 if (!lineedit->isVisible() && me)
2898 BranchObj *bo=(BranchObj*)me->getSelection();
2899 BranchObj *newbo=me->addNewBranchBefore();
2902 me->select (newbo->getSelectString());
2906 if (actionSettingsAutoEdit->isOn())
2908 if (!actionSettingsAutoSelectHeading->isOn())
2909 prevSelection=bo->getSelectString();
2915 void Main::editNewBranchAbove()
2917 MapEditor *me=currentMapEditor();
2918 if (!lineedit->isVisible() && me)
2920 BranchObj *bo=(BranchObj*)me->getSelection();
2921 BranchObj *newbo=me->addNewBranch (-1);
2924 me->select (newbo->getSelectString());
2928 if (actionSettingsAutoEdit->isOn())
2930 if (!actionSettingsAutoSelectHeading->isOn())
2931 prevSelection=bo->getSelectString();
2937 void Main::editNewBranchBelow()
2939 MapEditor *me=currentMapEditor();
2940 if (!lineedit->isVisible() && me)
2942 BranchObj *bo=(BranchObj*)me->getSelection();
2943 BranchObj *newbo=me->addNewBranch (1);
2946 me->select (newbo->getSelectString());
2950 if (actionSettingsAutoEdit->isOn())
2952 if (!actionSettingsAutoSelectHeading->isOn())
2953 prevSelection=bo->getSelectString();
2959 void Main::editImportAdd()
2961 fileLoad (ImportAdd);
2964 void Main::editImportReplace()
2966 fileLoad (ImportReplace);
2969 void Main::editSaveBranch()
2971 fileSaveAs (PartOfMap);
2974 void Main::editDeleteKeepChilds()
2976 if (currentMapEditor())
2977 currentMapEditor()->deleteKeepChilds();
2980 void Main::editDeleteChilds()
2982 if (currentMapEditor())
2983 currentMapEditor()->deleteChilds();
2986 void Main::editDeleteSelection()
2988 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2989 currentMapEditor()->deleteSelection();
2992 void Main::editUpperBranch()
2994 if (currentMapEditor())
2995 currentMapEditor()->selectUpperBranch();
2998 void Main::editLowerBranch()
3000 if (currentMapEditor())
3001 currentMapEditor()->selectLowerBranch();
3004 void Main::editLeftBranch()
3006 if (currentMapEditor())
3007 currentMapEditor()->selectLeftBranch();
3010 void Main::editRightBranch()
3012 if (currentMapEditor())
3013 currentMapEditor()->selectRightBranch();
3016 void Main::editFirstBranch()
3018 if (currentMapEditor())
3019 currentMapEditor()->selectFirstBranch();
3022 void Main::editLastBranch()
3024 if (currentMapEditor())
3025 currentMapEditor()->selectLastBranch();
3028 void Main::editLoadImage()
3030 if (currentMapEditor())
3031 currentMapEditor()->loadFloatImage();
3034 void Main::editSaveImage()
3036 if (currentMapEditor())
3037 currentMapEditor()->saveFloatImage();
3040 void Main::editFollowXLink(QAction *a)
3043 if (currentMapEditor())
3044 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3047 void Main::editEditXLink(QAction *a)
3049 if (currentMapEditor())
3050 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3053 void Main::formatSelectColor()
3055 if (currentMapEditor())
3057 QColor col = QColorDialog::getColor((currentColor ), this );
3058 if ( !col.isValid() ) return;
3059 colorChanged( col );
3063 void Main::formatPickColor()
3065 if (currentMapEditor())
3066 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3069 void Main::colorChanged(QColor c)
3071 QPixmap pix( 16, 16 );
3073 actionFormatColor->setIconSet( pix );
3077 void Main::formatColorBranch()
3079 if (currentMapEditor())
3080 currentMapEditor()->colorBranch(currentColor);
3083 void Main::formatColorSubtree()
3085 if (currentMapEditor())
3086 currentMapEditor()->colorSubtree (currentColor);
3089 void Main::formatLinkStyleLine()
3091 if (currentMapEditor())
3092 currentMapEditor()->setMapLinkStyle("StyleLine");
3095 void Main::formatLinkStyleParabel()
3097 if (currentMapEditor())
3098 currentMapEditor()->setMapLinkStyle("StyleParabel");
3101 void Main::formatLinkStylePolyLine()
3103 if (currentMapEditor())
3104 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3107 void Main::formatLinkStylePolyParabel()
3109 if (currentMapEditor())
3110 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3113 void Main::formatSelectBackColor()
3115 if (currentMapEditor())
3116 currentMapEditor()->selectMapBackgroundColor();
3119 void Main::formatSelectBackImage()
3121 if (currentMapEditor())
3122 currentMapEditor()->selectMapBackgroundImage();
3125 void Main::formatSelectLinkColor()
3127 if (currentMapEditor())
3128 currentMapEditor()->selectMapLinkColor();
3131 void Main::formatSelectSelectionColor()
3133 if (currentMapEditor())
3134 currentMapEditor()->selectMapSelectionColor();
3137 void Main::formatToggleLinkColorHint()
3139 currentMapEditor()->toggleMapLinkColorHint();
3143 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3145 if (currentMapEditor())
3146 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3149 void Main::viewZoomReset()
3151 if (currentMapEditor())
3155 currentMapEditor()->setMatrix( m );
3159 void Main::viewZoomIn()
3161 if (currentMapEditor())
3163 QMatrix m = currentMapEditor()->matrix();
3164 m.scale( 1.25, 1.25 );
3165 currentMapEditor()->setMatrix( m );
3169 void Main::viewZoomOut()
3171 if (currentMapEditor())
3173 QMatrix m = currentMapEditor()->matrix();
3174 m.scale( 0.8, 0.8 );
3175 currentMapEditor()->setMatrix( m );
3179 bool Main::settingsPDF()
3181 // Default browser is set in constructor
3183 QString text = QInputDialog::getText(
3184 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3185 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3187 settings.setValue ("/mainwindow/readerPDF",text);
3192 bool Main::settingsURL()
3194 // Default browser is set in constructor
3196 QString text = QInputDialog::getText(
3197 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3198 settings.value("/mainwindow/readerURL").toString()
3201 settings.setValue ("/mainwindow/readerURL",text);
3205 void Main::settingsMacroDir()
3207 QDir defdir=vymBaseDir;
3208 defdir.cd("macros");
3209 if (!defdir.exists())
3211 QDir dir=QFileDialog::getExistingDirectory (
3213 tr ("Directory with vym macros:"),
3214 settings.value ("/macros/macroDir",defdir.path()).toString()
3217 settings.setValue ("/macros/macroDir",dir.path());
3220 void Main::settingsUndoLevels()
3223 int i = QInputDialog::getInteger(
3225 tr("QInputDialog::getInteger()"),
3226 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3229 settings.setValue ("/mapeditor/stepsTotal",i);
3230 QMessageBox::information( this, tr( "VYM -Information:" ),
3231 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3235 void Main::settingsAutosaveToggle()
3237 settings.setValue ("/mapeditor/autosave/used",actionSettingsAutosaveToggle->isOn() );
3240 void Main::settingsAutosaveTime()
3243 int i = QInputDialog::getInteger(
3245 tr("QInputDialog::getInteger()"),
3246 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3249 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3253 void Main::settingsToggleDelKey()
3255 if (actionSettingsUseDelKey->isOn())
3257 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3260 actionEditDelete->setAccel (QKeySequence (""));
3264 void Main::windowToggleNoteEditor()
3266 if (textEditor->showWithMain() )
3267 windowHideNoteEditor();
3269 windowShowNoteEditor();
3272 void Main::windowToggleHistory()
3274 if (historyWindow->isVisible())
3275 historyWindow->hide();
3277 historyWindow->show();
3281 void Main::windowToggleProperty()
3283 if (branchPropertyWindow->isVisible())
3284 branchPropertyWindow->hide();
3286 branchPropertyWindow->show();
3287 if(currentMapEditor())
3289 LinkableMapObj *sel=currentMapEditor()->getSelection();
3290 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3291 typeid(*sel) == typeid(MapCenterObj)))
3293 branchPropertyWindow->setMapEditor(currentMapEditor());
3294 branchPropertyWindow->setBranch((BranchObj*)sel);
3299 branchPropertyWindow->setBranch(NULL);
3302 void Main::windowToggleAntiAlias()
3304 bool b=actionViewToggleAntiAlias->isOn();
3306 for (int i=0;i<tabWidget->count();i++)
3309 me=(MapEditor*)tabWidget->page(i);
3310 me->setAntiAlias(b);
3315 void Main::windowToggleSmoothPixmap()
3317 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3319 for (int i=0;i<tabWidget->count();i++)
3322 me=(MapEditor*)tabWidget->page(i);
3323 me->setSmoothPixmap(b);
3327 void Main::updateHistory(SimpleSettings &undoSet)
3329 historyWindow->update (undoSet);
3332 void Main::updateNoteFlag()
3334 if (currentMapEditor())
3335 currentMapEditor()->updateNoteFlag();
3338 void Main::updateSatellites(MapEditor *me)
3340 branchPropertyWindow->setMapEditor (me);
3343 void Main::updateActions()
3345 MapEditor *me=currentMapEditor();
3348 historyWindow->setCaption (tr("History for %1").arg(currentMapEditor()->getFileName()));
3350 // updateActions is also called when NoteEditor is closed
3351 actionViewToggleNoteEditor->setOn (textEditor->showWithMain());
3352 actionViewToggleHistoryWindow->setOn (historyWindow->showWithMain());
3354 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3355 actionFormatLinkColorHint->setOn(true);
3357 actionFormatLinkColorHint->setOn(false);
3359 switch (me->getMapLinkStyle())
3361 case LinkableMapObj::Line:
3362 actionFormatLinkStyleLine->setOn(true);
3364 case LinkableMapObj::Parabel:
3365 actionFormatLinkStyleParabel->setOn(true);
3367 case LinkableMapObj::PolyLine:
3368 actionFormatLinkStylePolyLine->setOn(true);
3370 case LinkableMapObj::PolyParabel:
3371 actionFormatLinkStylePolyParabel->setOn(true);
3378 QPixmap pix( 16, 16 );
3379 pix.fill( me->getMapBackgroundColor() );
3380 actionFormatBackColor->setIconSet( pix );
3381 pix.fill( me->getSelectionColor() );
3382 actionFormatSelectionColor->setIconSet( pix );
3383 pix.fill( me->getMapDefLinkColor() );
3384 actionFormatLinkColor->setIconSet( pix );
3387 actionFileSave->setEnabled( me->isUnsaved() );
3388 if (me->isUndoAvailable())
3389 actionEditUndo->setEnabled( true);
3391 actionEditUndo->setEnabled( false);
3393 if (me->isRedoAvailable())
3394 actionEditRedo->setEnabled( true);
3396 actionEditRedo->setEnabled( false);
3398 LinkableMapObj *selection=me->getSelection();
3401 if ( (typeid(*selection) == typeid(BranchObj)) ||
3402 (typeid(*selection) == typeid(MapCenterObj)) )
3404 BranchObj *bo=(BranchObj*)selection;
3405 // Take care of links
3406 if (bo->countXLinks()==0)
3408 branchXLinksContextMenuEdit->clear();
3409 branchXLinksContextMenuFollow->clear();
3414 branchXLinksContextMenuEdit->clear();
3415 branchXLinksContextMenuFollow->clear();
3416 for (int i=0; i<=bo->countXLinks();i++)
3418 bot=bo->XLinkTargetAt(i);
3421 s=bot->getHeading();
3424 branchXLinksContextMenuFollow->addAction (s);
3425 branchXLinksContextMenuEdit->addAction (s);
3430 standardFlagsDefault->setEnabled (true);
3432 actionEditToggleScroll->setEnabled (true);
3433 if ( bo->isScrolled() )
3434 actionEditToggleScroll->setOn(true);
3436 actionEditToggleScroll->setOn(false);
3438 if ( bo->getURL().isEmpty() )
3440 actionEditOpenURL->setEnabled (false);
3441 actionEditOpenURLTab->setEnabled (false);
3445 actionEditOpenURL->setEnabled (true);
3446 actionEditOpenURLTab->setEnabled (true);
3448 if ( bo->getVymLink().isEmpty() )
3450 actionEditOpenVymLink->setEnabled (false);
3451 actionEditDeleteVymLink->setEnabled (false);
3454 actionEditOpenVymLink->setEnabled (true);
3455 actionEditDeleteVymLink->setEnabled (true);
3458 if (bo->canMoveBranchUp())
3459 actionEditMoveUp->setEnabled (true);
3461 actionEditMoveUp->setEnabled (false);
3462 if (bo->canMoveBranchDown())
3463 actionEditMoveDown->setEnabled (true);
3465 actionEditMoveDown->setEnabled (false);
3468 actionEditToggleHideExport->setEnabled (true);
3469 actionEditToggleHideExport->setOn (bo->hideInExport() );
3471 actionEditCopy->setEnabled (true);
3472 actionEditCut->setEnabled (true);
3473 if (!clipboardEmpty)
3474 actionEditPaste->setEnabled (true);
3476 actionEditPaste->setEnabled (false);
3477 for (int i=0; i<actionListBranches.size(); ++i)
3478 actionListBranches.at(i)->setEnabled(true);
3479 actionEditDelete->setEnabled (true);
3480 actionFormatHideLinkUnselected->setOn
3481 (selection->getHideLinkUnselected());
3483 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3485 FloatObj *fo=(FloatImageObj*)selection;
3487 actionEditOpenURL->setEnabled (false);
3488 actionEditOpenVymLink->setEnabled (false);
3489 actionEditDeleteVymLink->setEnabled (false);
3490 actionEditToggleHideExport->setEnabled (true);
3491 actionEditToggleHideExport->setOn (fo->hideInExport() );
3494 actionEditCopy->setEnabled (true);
3495 actionEditCut->setEnabled (true);
3496 actionEditPaste->setEnabled (false);
3497 for (int i=0; i<actionListBranches.size(); ++i)
3498 actionListBranches.at(i)->setEnabled(false);
3499 actionEditDelete->setEnabled (true);
3500 actionFormatHideLinkUnselected->setOn
3501 ( selection->getHideLinkUnselected());
3502 actionEditMoveUp->setEnabled (false);
3503 actionEditMoveDown->setEnabled (false);
3508 actionEditCopy->setEnabled (false);
3509 actionEditCut->setEnabled (false);
3510 actionEditPaste->setEnabled (false);
3511 for (int i=0; i<actionListBranches.size(); ++i)
3512 actionListBranches.at(i)->setEnabled(false);
3514 actionEditToggleScroll->setEnabled (false);
3515 actionEditOpenURL->setEnabled (false);
3516 actionEditOpenVymLink->setEnabled (false);
3517 actionEditDeleteVymLink->setEnabled (false);
3518 actionEditHeading2URL->setEnabled (false);
3519 actionEditDelete->setEnabled (false);
3520 actionEditMoveUp->setEnabled (false);
3521 actionEditMoveDown->setEnabled (false);
3522 actionEditToggleHideExport->setEnabled (false);
3526 Main::ModMode Main::getModMode()
3528 if (actionModModeColor->isOn()) return ModModeColor;
3529 if (actionModModeCopy->isOn()) return ModModeCopy;
3530 if (actionModModeXLink->isOn()) return ModModeXLink;
3534 bool Main::autoEdit()
3536 return actionSettingsAutoEdit->isOn();
3539 bool Main::autoSelectHeading()
3541 return actionSettingsAutoSelectHeading->isOn();
3544 bool Main::useFlagGroups()
3546 return actionSettingsUseFlagGroups->isOn();
3549 void Main::windowShowNoteEditor()
3551 textEditor->setShowWithMain(true);
3553 actionViewToggleNoteEditor->setOn (true);
3556 void Main::windowHideNoteEditor()
3558 textEditor->setShowWithMain(false);
3560 actionViewToggleNoteEditor->setOn (false);
3563 void Main::setScript (const QString &script)
3565 scriptEditor->setScript (script);
3568 void Main::runScript (const QString &script)
3570 if (currentMapEditor())
3571 currentMapEditor()->runScript (script);
3574 void Main::windowNextEditor()
3576 if (tabWidget->currentPageIndex() < tabWidget->count())
3577 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3580 void Main::windowPreviousEditor()
3582 if (tabWidget->currentPageIndex() >0)
3583 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3586 void Main::standardFlagChanged()
3588 if (currentMapEditor())
3589 currentMapEditor()->toggleStandardFlag(sender()->name());
3592 void Main::testFunction()
3594 if (!currentMapEditor()) return;
3595 currentMapEditor()->testFunction();
3598 void Main::testCommand()
3600 if (!currentMapEditor()) return;
3601 scriptEditor->show();
3604 QString com = QInputDialog::getText(
3605 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3606 if (ok) currentMapEditor()->parseAtom(com);
3610 void Main::helpDoc()
3612 QString locale = QLocale::system().name();
3614 if (locale.left(2)=="es")
3615 docname="vym_es.pdf";
3619 QStringList searchList;
3621 #if defined(Q_OS_MACX)
3622 searchList << "./vym.app/Contents";
3624 // default path in SUSE LINUX
3625 searchList <<"/usr/share/doc/packages/vym/doc";
3628 searchList << "doc"; // relative path for easy testing in tarball
3629 searchList << "doc/tex"; // Easy testing working on vym.tex
3630 searchList << "/usr/share/doc/vym"; // Debian
3631 searchList << "/usr/share/doc/packages";// Knoppix
3635 for (int i=0; i<searchList.count(); ++i)
3637 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3638 if (docfile.exists() )
3647 QMessageBox::critical(0,
3648 tr("Critcal error"),
3649 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3654 Process *pdfProc = new Process();
3655 args <<docfile.fileName();
3657 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3658 if ( !pdfProc->waitForStarted() )
3661 QMessageBox::warning(0,
3663 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3664 tr("Please use Settings->")+tr("Set application to open PDF files"));
3671 void Main::helpAbout()
3674 ad.setName ("aboutwindow");
3675 ad.setMinimumSize(500,500);
3676 ad.resize (QSize (500,500));
3680 void Main::helpAboutQT()
3682 QMessageBox::aboutQt( this, "Qt Application Example" );
3685 void Main::callMacro ()
3687 QAction *action = qobject_cast<QAction *>(sender());
3691 i=action->data().toInt();
3692 QString mDir (settings.value ("macros/macroDir").toString() );
3694 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3696 if ( !f.open( QIODevice::ReadOnly ) )
3698 QMessageBox::warning(0,
3700 tr("Couldn't find a macro at %1.\n").arg(fn)+
3701 tr("Please use Settings->")+tr("Set directory for vym macros"));
3705 QTextStream ts( &f );
3706 QString m= ts.read();
3710 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3711 currentMapEditor()->runScript (m);