1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "branchpropwindow.h"
9 #include "exportoofiledialog.h"
12 #include "flagrowobj.h"
13 #include "historywindow.h"
15 #include "mapeditor.h"
20 #include "texteditor.h"
21 #include "warningdialog.h"
23 extern TextEditor *textEditor;
24 extern Main *mainWindow;
25 extern QString tmpVymDir;
26 extern QString clipboardDir;
27 extern QString clipboardFile;
28 extern bool clipboardEmpty;
29 extern int statusbarTime;
30 extern FlagRowObj* standardFlagsDefault;
31 extern FlagRowObj* systemFlagsDefault;
32 extern QString vymName;
33 extern QString vymVersion;
34 extern QString vymBuildDate;
37 QMenu* branchContextMenu;
38 QMenu* branchAddContextMenu;
39 QMenu* branchRemoveContextMenu;
40 QMenu* branchLinksContextMenu;
41 QMenu* branchXLinksContextMenuEdit;
42 QMenu* branchXLinksContextMenuFollow;
43 QMenu* floatimageContextMenu;
44 QMenu* canvasContextMenu;
45 QMenu* fileLastMapsMenu;
46 QMenu* fileImportMenu;
47 QMenu* fileExportMenu;
50 extern Settings settings;
51 extern Options options;
52 extern ImageIO imageIO;
54 extern QDir vymBaseDir;
55 extern QDir lastImageDir;
56 extern QDir lastFileDir;
57 extern QString iconPath;
58 extern QString flagsPath;
60 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
61 QMainWindow(parent,name,f)
65 setCaption ("VYM - View Your Mind");
67 // Load window settings
68 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
69 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
72 // Sometimes we may need to remember old selections
76 currentColor=Qt::black;
78 // Create unique temporary directory
80 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
83 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
86 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
88 // Create direcctory for clipboard
89 clipboardDir=tmpVymDir+"/clipboard";
90 clipboardFile="map.xml";
92 d.mkdir (clipboardDir,true);
93 makeSubDirs (clipboardDir);
98 // Satellite windows //////////////////////////////////////////
101 historyWindow=new HistoryWindow();
102 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
105 branchPropertyWindow = new BranchPropertyWindow();
106 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
108 // Connect TextEditor, so that we can update flags if text changes
109 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
110 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
112 // Connect HistoryWindow, so that we can update flags
113 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
116 // Initialize script editor
117 scriptEditor = new SimpleScriptEditor();
118 scriptEditor->move (50,50);
120 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
121 this, SLOT( runScript( QString ) ) );
124 // Initialize Find window
125 findWindow=new FindWindow(NULL);
126 findWindow->move (x(),y()+70);
127 connect (findWindow, SIGNAL( findButton(QString) ),
128 this, SLOT(editFind(QString) ) );
129 connect (findWindow, SIGNAL( somethingChanged() ),
130 this, SLOT(editFindChanged() ) );
132 // Initialize some settings, which are platform dependant
135 // application to open URLs
136 p="/mainwindow/readerURL";
137 #if defined(Q_OS_LINUX)
138 s=settings.value (p,"konqueror").toString();
140 #if defined(Q_OS_MACX)
141 s=settings.value (p,"/usr/bin/open").toString();
143 s=settings.value (p,"mozilla");
146 settings.setValue( p,s);
148 // application to open PDFs
149 p="/mainwindow/readerPDF";
150 #if defined(Q_OS_LINUX)
151 s=settings.value (p,"acroread").toString();
153 #if defined(Q_OS_MACX)
154 s=settings.value (p,"/usr/bin/open").toString();
156 s=settings.value (p,"acroread").toString();
159 settings.setValue( p,s);
162 // Create tab widget which holds the maps
163 tabWidget= new QTabWidget (this);
164 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
165 this, SLOT( editorChanged( QWidget * ) ) );
167 lineedit=new QLineEdit (this);
170 setCentralWidget(tabWidget);
174 setupFormatActions();
178 setupSettingsActions();
181 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
186 restoreState (settings.value("/mainwindow/state",0).toByteArray());
194 settings.setValue ( "/mainwindow/geometry/size", size() );
195 settings.setValue ( "/mainwindow/geometry/pos", pos() );
196 settings.setValue ("/mainwindow/state",saveState(0));
198 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
199 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
200 settings.setValue( "/version/version", vymVersion );
201 settings.setValue( "/version/builddate", vymBuildDate );
203 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
204 settings.setValue( "/mapeditor/editmode/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
205 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
206 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->isOn() );
207 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
208 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
209 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
211 //TODO save scriptEditor settings
213 // call the destructors
215 delete historyWindow;
216 delete branchPropertyWindow;
218 // Remove temporary directory
219 removeDir (QDir(tmpVymDir));
222 void Main::loadCmdLine()
224 /* TODO draw some kind of splashscreen while loading...
230 QStringList flist=options.getFileList();
231 QStringList::Iterator it=flist.begin();
233 while (it !=flist.end() )
235 fileLoad (*it, NewMap);
241 void Main::statusMessage(const QString &s)
243 statusBar()->message( s);
246 void Main::closeEvent (QCloseEvent* )
252 void Main::setupFileActions()
254 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
255 QToolBar *tb = addToolBar( tr ("&Map") );
256 tb->setObjectName ("mapTB");
259 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
260 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
261 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
263 fileMenu->addAction (a);
264 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
266 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
267 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
268 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
269 fileMenu->addAction (a);
270 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
272 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
273 a->setStatusTip (tr( "Open","Status tip File menu" ) );
274 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
276 fileMenu->addAction (a);
277 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
279 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
280 fileMenu->addSeparator();
282 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
283 a->setStatusTip ( tr( "Save","Status tip file menu" ));
284 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
286 fileMenu->addAction (a);
287 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
290 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
291 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
292 fileMenu->addAction (a);
293 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
295 fileMenu->addSeparator();
297 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
299 a = new QAction(tr("KDE Bookmarks"), this);
300 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
301 a->addTo (fileImportMenu);
302 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
304 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
306 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
307 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
308 a->addTo (fileImportMenu);
309 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
312 a = new QAction("Mind Manager...",this);
313 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
314 fileImportMenu->addAction (a);
315 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
317 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
318 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
319 fileImportMenu->addAction (a);
320 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
322 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
324 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
325 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
326 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
327 fileExportMenu->addAction (a);
329 a = new QAction( "Open Office...", this);
330 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
331 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
332 fileExportMenu->addAction (a);
334 a = new QAction( "Webpage (XHTML)...",this );
335 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
336 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
338 fileExportMenu->addAction (a);
340 a = new QAction( "Text (ASCII)...", this);
341 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
343 fileExportMenu->addAction (a);
345 a = new QAction( "Spreadsheet (CSV)...", this);
346 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
347 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
348 fileExportMenu->addAction (a);
350 a = new QAction( tr("KDE Bookmarks","File menu"), this);
351 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
352 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
353 fileExportMenu->addAction (a);
355 a = new QAction( "Taskjuggler...", this );
356 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
358 fileExportMenu->addAction (a);
360 a = new QAction( "LaTeX...", this);
361 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
362 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
363 fileExportMenu->addAction (a);
365 a = new QAction( "XML..." , this );
366 a->setStatusTip (tr( "Export as %1").arg("XML"));
367 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
368 fileExportMenu->addAction (a);
370 fileMenu->addSeparator();
372 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
373 a->setStatusTip ( tr( "Print" ,"File menu") );
374 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
376 fileMenu->addAction (a);
377 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
380 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
381 a->setStatusTip (tr( "Close Map" ) );
382 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
383 fileMenu->addAction (a);
384 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
386 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
387 a->setStatusTip ( tr( "Exit")+" "+vymName );
388 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
389 fileMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
395 void Main::setupEditActions()
397 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
398 tb->setLabel( "Edit Actions" );
399 tb->setObjectName ("actionsTB");
400 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
404 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
405 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
406 a->setStatusTip (tr( "Undo" ) );
407 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
408 a->setEnabled (false);
410 editMenu->addAction (a);
413 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
414 a->setStatusTip (tr( "Redo" ));
415 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
417 editMenu->addAction (a);
418 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
421 editMenu->addSeparator();
422 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
423 a->setStatusTip ( tr( "Copy" ) );
424 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
425 a->setEnabled (false);
427 editMenu->addAction (a);
428 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
431 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
432 a->setStatusTip ( tr( "Cut" ) );
433 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
434 a->setEnabled (false);
436 editMenu->addAction (a);
438 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
440 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
441 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
442 a->setStatusTip ( tr( "Paste" ) );
443 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
444 a->setEnabled (false);
446 editMenu->addAction (a);
449 // Shortcuts to modify heading:
450 a = new QAction(tr( "Edit heading","Edit menu" ),this);
451 a->setStatusTip ( tr( "edit Heading" ));
452 a->setShortcut ( Qt::Key_Enter); //Edit heading
453 // a->setShortcutContext (Qt::WindowShortcut);
455 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
456 actionListBranches.append(a);
457 a = new QAction( tr( "Edit heading","Edit menu" ), this);
458 a->setStatusTip (tr( "edit Heading" ));
459 a->setShortcut (Qt::Key_Return ); //Edit heading
460 //a->setShortcutContext (Qt::WindowShortcut);
462 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
463 actionListBranches.append(a);
464 editMenu->addAction (a);
466 a = new QAction( tr( "Edit heading","Edit menu" ), this);
467 a->setStatusTip (tr( "edit Heading" ));
468 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
469 a->setShortcutContext (Qt::WindowShortcut);
471 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
472 actionListBranches.append(a);
474 // Shortcut to delete selection
475 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
476 a->setStatusTip (tr( "Delete Selection" ));
477 a->setShortcut ( Qt::Key_Delete); //Delete selection
478 a->setShortcutContext (Qt::WindowShortcut);
480 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
483 // Shortcut to add branch
484 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
485 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
486 alt->setShortcut (Qt::Key_A); //Add branch
487 alt->setShortcutContext (Qt::WindowShortcut);
489 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
490 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
491 a->setStatusTip ( tr( "Add a branch as child of selection" ));
492 a->setShortcut (Qt::Key_Insert); //Add branch
493 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
494 actionListBranches.append(a);
495 #if defined (Q_OS_MACX)
496 // In OSX show different shortcut in menues, the keys work indepently always
497 actionEditAddBranch=alt;
499 actionEditAddBranch=a;
501 editMenu->addAction (actionEditAddBranch);
502 tb->addAction (actionEditAddBranch);
505 // Add branch by inserting it at selection
506 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
507 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
508 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
509 a->setShortcutContext (Qt::WindowShortcut);
511 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
512 a->setEnabled (false);
513 actionListBranches.append(a);
514 actionEditAddBranchBefore=a;
515 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
516 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
517 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
518 a->setShortcutContext (Qt::WindowShortcut);
520 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
521 actionListBranches.append(a);
524 a = new QAction(tr( "Add branch above","Edit menu" ), this);
525 a->setStatusTip ( tr( "Add a branch above selection" ));
526 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
527 a->setShortcutContext (Qt::WindowShortcut);
529 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
530 a->setEnabled (false);
531 actionListBranches.append(a);
532 actionEditAddBranchAbove=a;
533 a = new QAction(tr( "Add branch above","Edit menu" ), this);
534 a->setStatusTip ( tr( "Add a branch above selection" ));
535 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
536 a->setShortcutContext (Qt::WindowShortcut);
538 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
539 actionListBranches.append(a);
542 a = new QAction(tr( "Add branch below","Edit menu" ), this);
543 a->setStatusTip ( tr( "Add a branch below selection" ));
544 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
545 a->setShortcutContext (Qt::WindowShortcut);
547 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
548 a->setEnabled (false);
549 actionListBranches.append(a);
550 actionEditAddBranchBelow=a;
551 a = new QAction(tr( "Add branch below","Edit menu" ), this);
552 a->setStatusTip ( tr( "Add a branch below selection" ));
553 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
554 a->setShortcutContext (Qt::WindowShortcut);
556 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
557 actionListBranches.append(a);
559 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
560 a->setStatusTip ( tr( "Move branch up" ) );
561 a->setShortcut (Qt::Key_PageUp ); // Move branch up
562 a->setEnabled (false);
564 editMenu->addAction (a);
565 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
568 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
569 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
570 a->setStatusTip (tr( "Move branch down" ) );
571 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
572 a->setEnabled (false);
574 editMenu->addAction (a);
575 actionEditMoveDown=a;
578 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
579 a->setShortcut ( Qt::Key_ScrollLock );
580 a->setStatusTip (tr( "Scroll branch" ) );
581 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
583 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
584 alt->setShortcut ( Qt::Key_S ); // Scroll branch
585 alt->setStatusTip (tr( "Scroll branch" ));
586 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
587 #if defined(Q_OS_MACX)
588 actionEditToggleScroll=alt;
590 actionEditToggleScroll=a;
592 actionEditToggleScroll->setEnabled (false);
593 actionEditToggleScroll->setToggleAction(true);
594 tb->addAction (actionEditToggleScroll);
595 editMenu->addAction ( actionEditToggleScroll);
596 editMenu->addAction (actionEditToggleScroll);
599 actionListBranches.append(actionEditToggleScroll);
601 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
602 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
603 editMenu->addAction (a);
604 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
606 editMenu->addSeparator();
608 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
609 a->setStatusTip (tr( "Find" ) );
610 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
611 editMenu->addAction (a);
612 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
614 editMenu->addSeparator();
616 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
617 a->setShortcut (Qt::CTRL + Qt::Key_U );
618 a->setShortcut (tr( "Open URL" ));
621 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
624 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
625 a->setStatusTip (tr( "Open URL in new tab" ));
626 a->setShortcut (Qt::CTRL+Qt::Key_U );
628 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
629 actionEditOpenURLTab=a;
631 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
632 a->setStatusTip (tr( "Open all URLs in subtree" ));
634 actionListBranches.append(a);
635 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
636 actionEditOpenMultipleURLTabs=a;
638 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
639 a->setStatusTip ( tr( "Edit URL" ) );
640 a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
641 //a->setShortcut ( Qt::Key_U );
642 a->setShortcutContext (Qt::WindowShortcut);
643 actionListBranches.append(a);
645 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
648 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
649 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
650 a->setEnabled (false);
651 actionListBranches.append(a);
652 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
653 actionEditHeading2URL=a;
655 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
656 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
657 a->setEnabled (false);
658 actionListBranches.append(a);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
660 actionEditBugzilla2URL=a;
662 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
663 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
664 a->setEnabled (false);
665 actionListBranches.append(a);
666 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
667 actionEditFATE2URL=a;
669 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
670 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
672 a->setEnabled (false);
673 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
674 actionEditOpenVymLink=a;
676 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
677 a->setStatusTip ( tr( "Open all vym links in subtree" ));
678 a->setEnabled (false);
679 actionListBranches.append(a);
680 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
681 actionEditOpenMultipleVymLinks=a;
684 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
685 a->setEnabled (false);
686 a->setStatusTip ( tr( "Edit link to another vym map" ));
687 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
688 actionListBranches.append(a);
691 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
692 a->setStatusTip ( tr( "Delete link to another vym map" ));
693 a->setEnabled (false);
694 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
695 actionEditDeleteVymLink=a;
697 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
698 a->setStatusTip ( tr( "Hide object in exports" ) );
699 a->setShortcut (Qt::Key_H );
700 a->setToggleAction(true);
702 a->setEnabled (false);
703 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
704 actionEditToggleHideExport=a;
706 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
707 a->setStatusTip ( tr( "Edit Map Info" ));
708 a->setEnabled (true);
709 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
712 // Import at selection (adding to selection)
713 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
714 a->setStatusTip (tr( "Add map at selection" ));
715 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
716 a->setEnabled (false);
717 actionListBranches.append(a);
718 actionEditImportAdd=a;
720 // Import at selection (replacing selection)
721 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
722 a->setStatusTip (tr( "Replace selection with map" ));
723 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
724 a->setEnabled (false);
725 actionListBranches.append(a);
726 actionEditImportReplace=a;
729 a = new QAction( tr( "Save selection","Edit menu" ), this);
730 a->setStatusTip (tr( "Save selection" ));
731 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
732 a->setEnabled (false);
733 actionListBranches.append(a);
734 actionEditSaveBranch=a;
736 // Only remove branch, not its childs
737 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
738 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
739 a->setShortcut (Qt::ALT + Qt::Key_Delete );
740 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
741 a->setEnabled (false);
743 actionListBranches.append(a);
744 actionEditDeleteKeepChilds=a;
746 // Only remove childs of a branch
747 a = new QAction( tr( "Remove childs","Edit menu" ), this);
748 a->setStatusTip (tr( "Remove childs of branch" ));
749 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
750 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
751 a->setEnabled (false);
752 actionListBranches.append(a);
753 actionEditDeleteChilds=a;
755 // Shortcuts for navigating with cursor:
756 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
757 a->setStatusTip ( tr( "Select upper branch" ));
758 a->setShortcut (Qt::Key_Up );
759 a->setShortcutContext (Qt::WindowShortcut);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
762 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
763 a->setStatusTip (tr( "Select lower branch" ));
764 a->setShortcut ( Qt::Key_Down );
765 a->setShortcutContext (Qt::WindowShortcut);
767 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
768 a = new QAction(tr( "Select left branch","Edit menu" ), this);
769 a->setStatusTip ( tr( "Select left branch" ));
770 a->setShortcut (Qt::Key_Left );
771 a->setShortcutContext (Qt::WindowShortcut);
773 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
774 a = new QAction( tr( "Select child branch","Edit menu" ), this);
775 a->setStatusTip (tr( "Select right branch" ));
776 a->setShortcut (Qt::Key_Right);
777 a->setShortcutContext (Qt::WindowShortcut);
779 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
780 a = new QAction( tr( "Select first branch","Edit menu" ), this);
781 a->setStatusTip (tr( "Select first branch" ));
782 a->setShortcut (Qt::Key_Home );
783 a->setShortcutContext (Qt::WindowShortcut);
785 a->setEnabled (false);
786 editMenu->addAction (a);
787 actionListBranches.append(a);
788 actionEditSelectFirst=a;
789 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
790 a = new QAction( tr( "Select last branch","Edit menu" ),this);
791 a->setStatusTip (tr( "Select last branch" ));
792 a->setShortcut ( Qt::Key_End );
793 a->setShortcutContext (Qt::WindowShortcut);
795 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
796 a->setEnabled (false);
797 editMenu->addAction (a);
798 actionListBranches.append(a);
799 actionEditSelectLast=a;
801 a = new QAction( tr( "Add Image...","Edit menu" ), this);
802 a->setStatusTip (tr( "Add Image" ));
803 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
804 actionEditLoadImage=a;
806 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
807 a->setStatusTip (tr( "Set properties for selection" ));
808 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
809 a->setShortcutContext (Qt::WindowShortcut);
810 a->setToggleAction (true);
812 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
813 actionViewTogglePropertyWindow=a;
817 void Main::setupFormatActions()
819 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
821 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
822 tb->setObjectName ("formatTB");
825 pix.fill (Qt::black);
826 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
827 a->setStatusTip ( tr( "Set Color" ));
828 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
830 formatMenu->addAction (a);
832 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
833 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
834 a->setShortcut (Qt::CTRL + Qt::Key_K );
835 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
836 a->setEnabled (false);
838 formatMenu->addAction (a);
839 actionListBranches.append(a);
840 actionFormatPickColor=a;
842 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
843 a->setStatusTip ( tr( "Color branch" ) );
844 a->setShortcut (Qt::CTRL + Qt::Key_B);
845 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
846 a->setEnabled (false);
848 formatMenu->addAction (a);
849 actionListBranches.append(a);
850 actionFormatColorSubtree=a;
852 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
853 a->setStatusTip ( tr( "Color Subtree" ));
854 a->setShortcut (Qt::CTRL + Qt::Key_T);
855 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
856 a->setEnabled (false);
857 formatMenu->addAction (a);
859 actionListBranches.append(a);
860 actionFormatColorSubtree=a;
862 formatMenu->addSeparator();
863 actionGroupFormatLinkStyles=new QActionGroup ( this);
864 actionGroupFormatLinkStyles->setExclusive (true);
865 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
866 a->setStatusTip (tr( "Line" ));
867 a->setToggleAction(true);
868 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
869 formatMenu->addAction (a);
870 actionFormatLinkStyleLine=a;
871 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
872 a->setStatusTip (tr( "Line" ));
873 a->setToggleAction(true);
874 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
875 formatMenu->addAction (a);
876 actionFormatLinkStyleParabel=a;
877 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
878 a->setStatusTip (tr( "PolyLine" ));
879 a->setToggleAction(true);
880 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
881 formatMenu->addAction (a);
882 actionFormatLinkStylePolyLine=a;
883 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
884 a->setStatusTip (tr( "PolyParabel" ) );
885 a->setToggleAction(true);
886 a->setChecked (true);
887 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
888 formatMenu->addAction (a);
889 actionFormatLinkStylePolyParabel=a;
891 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
892 a->setStatusTip (tr( "Hide link" ));
893 a->setToggleAction(true);
894 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
895 actionFormatHideLinkUnselected=a;
897 formatMenu->addSeparator();
898 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
899 a->setStatusTip (tr( "Use same color for links and headings" ));
900 a->setToggleAction(true);
901 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
902 formatMenu->addAction (a);
903 actionFormatLinkColorHint=a;
905 pix.fill (Qt::white);
906 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
907 a->setStatusTip (tr( "Set Link Color" ));
908 formatMenu->addAction (a);
909 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
910 actionFormatLinkColor=a;
912 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
913 a->setStatusTip (tr( "Set Selection Color" ));
914 formatMenu->addAction (a);
915 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
916 actionFormatSelectionColor=a;
918 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
919 a->setStatusTip (tr( "Set Background Color" ));
920 formatMenu->addAction (a);
921 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
922 actionFormatBackColor=a;
924 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
925 a->setStatusTip (tr( "Set Background image" ));
926 formatMenu->addAction (a);
927 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
928 actionFormatBackImage=a;
932 void Main::setupViewActions()
934 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
935 tb->setLabel( "View Actions" );
936 tb->setObjectName ("viewTB");
937 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
940 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
941 a->setStatusTip ( tr( "Zoom reset" ) );
942 a->setShortcut (Qt::CTRL + Qt::Key_0 );
944 viewMenu->addAction (a);
945 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
947 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
948 a->setStatusTip (tr( "Zoom in" ));
949 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
951 viewMenu->addAction (a);
952 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
954 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
955 a->setStatusTip (tr( "Zoom out" ));
956 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
958 viewMenu->addAction (a);
959 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
961 viewMenu->addSeparator();
963 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
964 a->setStatusTip ( tr( "Show Note Editor" ));
965 a->setShortcut ( Qt::CTRL + Qt::Key_E );
966 a->setToggleAction(true);
968 viewMenu->addAction (a);
969 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
970 actionViewToggleNoteEditor=a;
972 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
973 a->setStatusTip ( tr( "Show History Window" ));
974 a->setShortcut ( Qt::CTRL + Qt::Key_H );
975 a->setToggleAction(true);
977 viewMenu->addAction (a);
978 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
979 actionViewToggleHistoryWindow=a;
981 viewMenu->addAction (actionViewTogglePropertyWindow);
983 viewMenu->addSeparator();
985 a = new QAction(tr( "Antialiasing","View action" ),this );
986 a->setStatusTip ( tr( "Antialiasing" ));
987 a->setToggleAction(true);
988 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
989 viewMenu->addAction (a);
990 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
991 actionViewToggleAntiAlias=a;
993 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
994 a->setStatusTip (a->text());
995 a->setToggleAction(true);
996 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
997 viewMenu->addAction (a);
998 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
999 actionViewToggleSmoothPixmapTransform=a;
1001 a = new QAction(tr( "Next Map","View action" ), this);
1002 a->setStatusTip (a->text());
1003 a->setShortcut (Qt::ALT + Qt::Key_N );
1004 viewMenu->addAction (a);
1005 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1007 a = new QAction (tr( "Previous Map","View action" ), this );
1008 a->setStatusTip (a->text());
1009 a->setShortcut (Qt::ALT + Qt::Key_P );
1010 viewMenu->addAction (a);
1011 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1015 void Main::setupModeActions()
1017 //QPopupMenu *menu = new QPopupMenu( this );
1018 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1020 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1021 tb->setObjectName ("modesTB");
1023 actionGroupModModes=new QActionGroup ( this);
1024 actionGroupModModes->setExclusive (true);
1025 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1026 a->setShortcut (Qt::Key_J);
1027 a->setStatusTip ( tr( "Use modifier to color branches" ));
1028 a->setToggleAction(true);
1031 actionModModeColor=a;
1033 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1034 a->setShortcut( Qt::Key_K);
1035 a->setStatusTip( tr( "Use modifier to copy" ));
1036 a->setToggleAction(true);
1038 actionModModeCopy=a;
1040 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1041 a->setShortcut (Qt::Key_L);
1042 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1043 a->setToggleAction(true);
1045 actionModModeXLink=a;
1049 void Main::setupFlagActions()
1051 // Create System Flags
1052 systemFlagsDefault = new FlagRowObj ();
1053 systemFlagsDefault->setVisibility (false);
1054 systemFlagsDefault->setName ("systemFlagsDef");
1056 FlagObj *fo = new FlagObj ();
1057 fo->load(QPixmap(flagsPath+"flag-note.png"));
1058 fo->setName("note");
1059 fo->setToolTip(tr("Note","Systemflag"));
1060 systemFlagsDefault->addFlag (fo); // makes deep copy
1062 fo->load(QPixmap(flagsPath+"flag-url.png"));
1064 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1065 systemFlagsDefault->addFlag (fo);
1067 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1068 fo->setName("vymLink");
1069 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1070 systemFlagsDefault->addFlag (fo);
1072 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1073 fo->setName("scrolledright");
1074 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1075 systemFlagsDefault->addFlag (fo);
1077 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1078 fo->setName("tmpUnscrolledright");
1079 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1080 systemFlagsDefault->addFlag (fo);
1082 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1083 fo->setName("hideInExport");
1084 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1085 systemFlagsDefault->addFlag (fo);
1087 // Create Standard Flags
1088 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1089 tb->setObjectName ("standardFlagTB");
1091 standardFlagsDefault = new FlagRowObj ();
1092 standardFlagsDefault->setVisibility (false);
1093 standardFlagsDefault->setName ("standardFlagsDef");
1094 standardFlagsDefault->setToolBar (tb);
1096 fo->load(flagsPath+"flag-exclamationmark.png");
1097 fo->setName ("exclamationmark");
1098 fo->setGroup("standard-mark");
1099 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1102 a->setCheckable(true);
1103 a->setObjectName(fo->getName());
1104 a->setToolTip(tr("Take care!","Standardflag"));
1105 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1106 standardFlagsDefault->addFlag (fo); // makes deep copy
1108 fo->load(flagsPath+"flag-questionmark.png");
1109 fo->setName("questionmark");
1110 fo->setGroup("standard-mark");
1111 a=new QAction (fo->getPixmap(),fo->getName(),this);
1114 a->setCheckable(true);
1115 a->setObjectName(fo->getName());
1116 a->setToolTip(tr("Really?","Standardflag"));
1117 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1118 standardFlagsDefault->addFlag (fo);
1120 fo->load(flagsPath+"flag-hook-green.png");
1121 fo->setName("hook-green");
1122 fo->setGroup("standard-hook");
1123 a=new QAction (fo->getPixmap(),fo->getName(),this);
1126 a->setCheckable(true);
1127 a->setObjectName(fo->getName());
1128 a->setToolTip(tr("ok!","Standardflag"));
1129 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1130 standardFlagsDefault->addFlag (fo);
1132 fo->load(flagsPath+"flag-cross-red.png");
1133 fo->setName("cross-red");
1134 fo->setGroup("standard-hook");
1135 a=new QAction (fo->getPixmap(),fo->getName(),this);
1138 a->setCheckable(true);
1139 a->setObjectName(fo->getName());
1140 a->setToolTip(tr("Not ok!","Standardflag"));
1141 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1142 standardFlagsDefault->addFlag (fo);
1144 fo->load(flagsPath+"flag-stopsign.png");
1145 fo->setName("stopsign");
1146 a=new QAction (fo->getPixmap(),fo->getName(),this);
1149 a->setCheckable(true);
1150 a->setObjectName(fo->getName());
1151 a->setToolTip(tr("This won't work!","Standardflag"));
1152 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1153 standardFlagsDefault->addFlag (fo);
1155 fo->load(flagsPath+"flag-smiley-good.png");
1156 fo->setName("smiley-good");
1157 fo->setGroup("standard-smiley");
1158 a=new QAction (fo->getPixmap(),fo->getName(),this);
1161 a->setCheckable(true);
1162 a->setObjectName(fo->getName());
1163 a->setToolTip(tr("Good","Standardflag"));
1164 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1165 standardFlagsDefault->addFlag (fo);
1167 fo->load(flagsPath+"flag-smiley-sad.png");
1168 fo->setName("smiley-sad");
1169 fo->setGroup("standard-smiley");
1170 a=new QAction (fo->getPixmap(),fo->getName(),this);
1173 a->setCheckable(true);
1174 a->setObjectName(fo->getName());
1175 a->setToolTip(tr("Bad","Standardflag"));
1176 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1177 standardFlagsDefault->addFlag (fo);
1179 fo->load(flagsPath+"flag-smiley-omg.png");
1180 // Original omg.png (in KDE emoticons)
1181 fo->setName("smiley-omg");
1182 fo->setGroup("standard-smiley");
1183 a=new QAction (fo->getPixmap(),fo->getName(),this);
1186 a->setCheckable(true);
1187 a->setObjectName(fo->getName());
1188 a->setToolTip(tr("Oh no!","Standardflag"));
1189 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1190 standardFlagsDefault->addFlag (fo);
1192 fo->load(flagsPath+"flag-kalarm.png");
1193 fo->setName("clock");
1194 a=new QAction (fo->getPixmap(),fo->getName(),this);
1197 a->setCheckable(true);
1198 a->setObjectName(fo->getName());
1199 a->setToolTip(tr("Time critical","Standardflag"));
1200 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1201 standardFlagsDefault->addFlag (fo);
1203 fo->load(flagsPath+"flag-phone.png");
1204 fo->setName("phone");
1205 a=new QAction (fo->getPixmap(),fo->getName(),this);
1208 a->setCheckable(true);
1209 a->setObjectName(fo->getName());
1210 a->setToolTip(tr("Call...","Standardflag"));
1211 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1212 standardFlagsDefault->addFlag (fo);
1214 fo->load(flagsPath+"flag-lamp.png");
1215 fo->setName("lamp");
1216 a=new QAction (fo->getPixmap(),fo->getName(),this);
1219 a->setCheckable(true);
1220 a->setObjectName(fo->getName());
1221 a->setToolTip(tr("Idea!","Standardflag"));
1222 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1223 standardFlagsDefault->addFlag (fo);
1225 fo->load(flagsPath+"flag-arrow-up.png");
1226 fo->setName("arrow-up");
1227 fo->setGroup("standard-arrow");
1228 a=new QAction (fo->getPixmap(),fo->getName(),this);
1231 a->setCheckable(true);
1232 a->setObjectName(fo->getName());
1233 a->setToolTip(tr("Important","Standardflag"));
1234 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1235 standardFlagsDefault->addFlag (fo);
1237 fo->load(flagsPath+"flag-arrow-down.png");
1238 fo->setName("arrow-down");
1239 fo->setGroup("standard-arrow");
1240 a=new QAction (fo->getPixmap(),fo->getName(),this);
1243 a->setCheckable(true);
1244 a->setObjectName(fo->getName());
1245 a->setToolTip(tr("Unimportant","Standardflag"));
1246 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1247 standardFlagsDefault->addFlag (fo);
1249 fo->load(flagsPath+"flag-arrow-2up.png");
1250 fo->setName("2arrow-up");
1251 fo->setGroup("standard-arrow");
1252 a=new QAction (fo->getPixmap(),fo->getName(),this);
1255 a->setCheckable(true);
1256 a->setObjectName(fo->getName());
1257 a->setToolTip(tr("Very important!","Standardflag"));
1258 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1259 standardFlagsDefault->addFlag (fo);
1261 fo->load(flagsPath+"flag-arrow-2down.png");
1262 fo->setName("2arrow-down");
1263 fo->setGroup("standard-arrow");
1264 a=new QAction (fo->getPixmap(),fo->getName(),this);
1267 a->setCheckable(true);
1268 a->setObjectName(fo->getName());
1269 a->setToolTip(tr("Very unimportant!","Standardflag"));
1270 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1271 standardFlagsDefault->addFlag (fo);
1273 fo->load(flagsPath+"flag-thumb-up.png");
1274 fo->setName("thumb-up");
1275 fo->setGroup("standard-thumb");
1276 a=new QAction (fo->getPixmap(),fo->getName(),this);
1279 a->setCheckable(true);
1280 a->setObjectName(fo->getName());
1281 a->setToolTip(tr("I like this","Standardflag"));
1282 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1283 standardFlagsDefault->addFlag (fo);
1285 fo->load(flagsPath+"flag-thumb-down.png");
1286 fo->setName("thumb-down");
1287 fo->setGroup("standard-thumb");
1288 a=new QAction (fo->getPixmap(),fo->getName(),this);
1291 a->setCheckable(true);
1292 a->setObjectName(fo->getName());
1293 a->setToolTip(tr("I do not like this","Standardflag"));
1294 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1295 standardFlagsDefault->addFlag (fo);
1297 fo->load(flagsPath+"flag-rose.png");
1298 fo->setName("rose");
1299 a=new QAction (fo->getPixmap(),fo->getName(),this);
1302 a->setCheckable(true);
1303 a->setObjectName(fo->getName());
1304 a->setToolTip(tr("Rose","Standardflag"));
1305 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1306 standardFlagsDefault->addFlag (fo);
1308 fo->load(flagsPath+"flag-heart.png");
1309 fo->setName("heart");
1310 a=new QAction (fo->getPixmap(),fo->getName(),this);
1312 a->setCheckable(true);
1313 a->setObjectName(fo->getName());
1314 a->setToolTip(tr("I just love... ","Standardflag"));
1315 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1316 standardFlagsDefault->addFlag (fo);
1318 fo->load(flagsPath+"flag-present.png");
1319 fo->setName("present");
1320 a=new QAction (fo->getPixmap(),fo->getName(),this);
1323 a->setCheckable(true);
1324 a->setObjectName(fo->getName());
1325 a->setToolTip(tr("Surprise!","Standardflag"));
1326 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1327 standardFlagsDefault->addFlag (fo);
1329 fo->load(flagsPath+"flag-flash.png");
1330 fo->setName("flash");
1331 a=new QAction (fo->getPixmap(),fo->getName(),this);
1334 a->setCheckable(true);
1335 a->setObjectName(fo->getName());
1336 a->setToolTip(tr("Dangerous","Standardflag"));
1337 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1338 standardFlagsDefault->addFlag (fo);
1340 fo->load(flagsPath+"flag-info.png");
1341 // Original: xsldbg_output.png
1342 fo->setName("info");
1343 a=new QAction (fo->getPixmap(),fo->getName(),this);
1346 a->setCheckable(true);
1347 a->setObjectName(fo->getName());
1348 a->setToolTip(tr("Info","Standardflag"));
1349 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1350 standardFlagsDefault->addFlag (fo);
1352 fo->load(flagsPath+"flag-lifebelt.png");
1353 // Original khelpcenter.png
1354 fo->setName("lifebelt");
1355 a=new QAction (fo->getPixmap(),fo->getName(),this);
1358 a->setCheckable(true);
1359 a->setObjectName(fo->getName());
1360 a->setToolTip(tr("This will help","Standardflag"));
1361 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1362 standardFlagsDefault->addFlag (fo);
1368 void Main::setupSettingsActions()
1370 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1374 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1375 a->setStatusTip ( tr( "Set application to open pdf files"));
1376 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1377 settingsMenu->addAction (a);
1379 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1380 a->setStatusTip( tr( "Set application to open external links"));
1381 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1382 settingsMenu->addAction (a);
1384 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1385 a->setStatusTip( tr( "Set path for macros"));
1386 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1387 settingsMenu->addAction (a);
1389 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1390 a->setStatusTip( tr( "Set number of undo levels"));
1391 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1392 settingsMenu->addAction (a);
1394 settingsMenu->addSeparator();
1396 a = new QAction( tr( "Autosave","Settings action"), this);
1397 a->setStatusTip( tr( "Autosave"));
1398 a->setToggleAction(true);
1399 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1400 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1401 settingsMenu->addAction (a);
1402 actionSettingsAutosaveToggle=a;
1404 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1405 a->setStatusTip( tr( "Autosave time"));
1406 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1407 settingsMenu->addAction (a);
1408 actionSettingsAutosaveTime=a;
1410 settingsMenu->addSeparator();
1412 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1413 a->setStatusTip( tr( "Edit branch after adding it" ));
1414 a->setToggleAction(true);
1415 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1416 settingsMenu->addAction (a);
1417 actionSettingsAutoEdit=a;
1419 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1420 a->setStatusTip( tr( "Select branch after adding it" ));
1421 a->setToggleAction(true);
1422 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1423 settingsMenu->addAction (a);
1424 actionSettingsAutoSelectHeading=a;
1426 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1427 a->setStatusTip( tr( "Select heading before editing" ));
1428 a->setToggleAction(true);
1429 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1430 settingsMenu->addAction (a);
1431 actionSettingsAutoSelectText=a;
1433 a= new QAction( tr( "Delete key","Settings action" ), this);
1434 a->setStatusTip( tr( "Delete key for deleting branches" ));
1435 a->setToggleAction(true);
1436 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1437 settingsMenu->addAction (a);
1438 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1439 actionSettingsUseDelKey=a;
1441 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1442 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1443 a->setToggleAction(true);
1444 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1445 settingsMenu->addAction (a);
1446 actionSettingsUseFlagGroups=a;
1448 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1449 a->setStatusTip( tr( "Use hide flag during exports " ));
1450 a->setToggleAction(true);
1451 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1452 settingsMenu->addAction (a);
1453 actionSettingsUseHideExport=a;
1457 void Main::setupTestActions()
1459 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1462 a = new QAction( "Test function" , this);
1463 a->setStatusTip( "Call test function" );
1464 //a->setShortcut (Qt::Key_F4 );
1465 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1466 testMenu->addAction (a);
1467 a = new QAction( "Command" , this);
1468 a->setStatusTip( "Enter command to call in editor" );
1469 //a->setShortcut (Qt::Key_F5 );
1470 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1471 testMenu->addAction (a);
1475 void Main::setupHelpActions()
1477 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1480 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1481 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1482 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1483 helpMenu->addAction (a);
1485 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1486 a->setStatusTip( tr( "Open VYM example maps " ));
1487 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1488 helpMenu->addAction (a);
1490 a = new QAction( tr( "About VYM","Help action" ), this);
1491 a->setStatusTip( tr( "About VYM")+vymName);
1492 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1493 helpMenu->addAction (a);
1495 a = new QAction( tr( "About QT","Help action" ), this);
1496 a->setStatusTip( tr( "Information about QT toolkit" ));
1497 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1498 helpMenu->addAction (a);
1502 void Main::setupContextMenus()
1506 // Context Menu for branch or mapcenter
1507 branchContextMenu =new QMenu (this);
1508 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1509 branchContextMenu->addSeparator();
1512 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1513 branchAddContextMenu->addAction (actionEditPaste );
1514 branchAddContextMenu->addAction ( actionEditAddBranch );
1515 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1516 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1517 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1518 branchAddContextMenu->addSeparator();
1519 branchAddContextMenu->addAction ( actionEditImportAdd );
1520 branchAddContextMenu->addAction ( actionEditImportReplace );
1523 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1524 branchRemoveContextMenu->addAction (actionEditCut);
1525 branchRemoveContextMenu->addAction ( actionEditDelete );
1526 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1527 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1530 actionEditSaveBranch->addTo( branchContextMenu );
1532 branchContextMenu->addSeparator();
1533 branchContextMenu->addAction ( actionEditLoadImage);
1535 // Submenu for Links (URLs, vymLinks)
1536 branchLinksContextMenu =new QMenu (this);
1538 branchContextMenu->addSeparator();
1539 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1540 branchLinksContextMenu->addAction ( actionEditOpenURL );
1541 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1542 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1543 branchLinksContextMenu->addAction ( actionEditURL );
1544 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1545 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1546 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1548 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1550 branchLinksContextMenu->addSeparator();
1551 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1552 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1553 branchLinksContextMenu->addAction ( actionEditVymLink );
1554 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1557 // Context Menu for XLinks in a branch menu
1558 // This will be populated "on demand" in MapEditor::updateActions
1559 branchContextMenu->addSeparator();
1560 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1561 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1562 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1563 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1566 // Context menu for floatimage
1567 floatimageContextMenu =new QMenu (this);
1568 a= new QAction (tr ("Save image","Context action"),this);
1569 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1570 floatimageContextMenu->addAction (a);
1572 floatimageContextMenu->addSeparator();
1573 actionEditCopy->addTo( floatimageContextMenu );
1574 actionEditCut->addTo( floatimageContextMenu );
1576 floatimageContextMenu->addSeparator();
1577 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1580 // Context menu for canvas
1581 canvasContextMenu =new QMenu (this);
1582 actionEditMapInfo->addTo( canvasContextMenu );
1583 canvasContextMenu->insertSeparator();
1584 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1585 canvasContextMenu->insertSeparator();
1586 actionFormatLinkColorHint->addTo( canvasContextMenu );
1587 actionFormatLinkColor->addTo( canvasContextMenu );
1588 actionFormatSelectionColor->addTo( canvasContextMenu );
1589 actionFormatBackColor->addTo( canvasContextMenu );
1590 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1592 // Menu for last opened files
1594 for (int i = 0; i < MaxRecentFiles; ++i)
1596 recentFileActions[i] = new QAction(this);
1597 recentFileActions[i]->setVisible(false);
1598 fileLastMapsMenu->addAction(recentFileActions[i]);
1599 connect(recentFileActions[i], SIGNAL(triggered()),
1600 this, SLOT(fileLoadRecent()));
1602 setupRecentMapsMenu();
1605 void Main::setupRecentMapsMenu()
1607 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1609 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1611 for (int i = 0; i < numRecentFiles; ++i) {
1612 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1613 recentFileActions[i]->setText(text);
1614 recentFileActions[i]->setData(files[i]);
1615 recentFileActions[i]->setVisible(true);
1617 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1618 recentFileActions[j]->setVisible(false);
1621 void Main::setupMacros()
1623 for (int i = 0; i <= 11; i++)
1625 macroActions[i] = new QAction(this);
1626 macroActions[i]->setData(i);
1627 addAction (macroActions[i]);
1628 connect(macroActions[i], SIGNAL(triggered()),
1629 this, SLOT(callMacro()));
1631 macroActions[0]->setShortcut ( Qt::Key_F1 );
1632 macroActions[1]->setShortcut ( Qt::Key_F2 );
1633 macroActions[2]->setShortcut ( Qt::Key_F3 );
1634 macroActions[3]->setShortcut ( Qt::Key_F4 );
1635 macroActions[4]->setShortcut ( Qt::Key_F5 );
1636 macroActions[5]->setShortcut ( Qt::Key_F6 );
1637 macroActions[6]->setShortcut ( Qt::Key_F7 );
1638 macroActions[7]->setShortcut ( Qt::Key_F8 );
1639 macroActions[8]->setShortcut ( Qt::Key_F9 );
1640 macroActions[9]->setShortcut ( Qt::Key_F10 );
1641 macroActions[10]->setShortcut ( Qt::Key_F11 );
1642 macroActions[11]->setShortcut ( Qt::Key_F12 );
1645 void Main::hideEvent (QHideEvent * )
1647 if (!textEditor->isMinimized() ) textEditor->hide();
1650 void Main::showEvent (QShowEvent * )
1652 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1655 bool Main::reallyWriteDirectory(const QString &dir)
1657 QStringList eList = QDir(dir).entryList();
1658 if (eList.first() ==".") eList.pop_front(); // remove "."
1659 if (eList.first() =="..") eList.pop_front(); // remove "."
1660 if (!eList.isEmpty())
1662 QMessageBox mb( vymName,
1663 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1664 QMessageBox::Warning,
1666 QMessageBox::Cancel | QMessageBox::Default,
1667 QMessageBox::QMessageBox::NoButton );
1669 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1670 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1673 case QMessageBox::Yes:
1676 case QMessageBox::Cancel:
1684 QString Main::browseDirectory (const QString &caption)
1686 QFileDialog fd(this,caption);
1687 fd.setMode (QFileDialog::DirectoryOnly);
1688 fd.setCaption(vymName+ " - "+caption);
1689 fd.setDir (lastFileDir);
1692 if ( fd.exec() == QDialog::Accepted )
1693 return fd.selectedFile();
1698 MapEditor* Main::currentMapEditor() const
1700 if ( tabWidget->currentPage() &&
1701 tabWidget->currentPage()->inherits( "MapEditor" ) )
1702 return (MapEditor*)tabWidget->currentPage();
1707 void Main::editorChanged(QWidget *)
1709 // Unselect all possibly selected objects
1710 // (Important to update note editor)
1712 for (int i=0;i<=tabWidget->count() -1;i++)
1715 me=(MapEditor*)tabWidget->page(i);
1718 currentMapEditor()->reselect();
1720 // Update actions to in menus and toolbars according to editor
1724 void Main::fileNew()
1726 QString fn="unnamed";
1727 MapEditor* me = new MapEditor ( NULL);
1728 tabWidget->addTab (me,fn);
1729 tabWidget->showPage(me);
1730 me->viewport()->setFocus();
1731 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1732 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1734 // For the very first map we do not have flagrows yet...
1738 void Main::fileNewCopy()
1740 QString fn="unnamed";
1741 MapEditor* oldME =currentMapEditor();
1745 MapEditor* newME = new MapEditor ( NULL);
1748 tabWidget->addTab (newME,fn);
1749 tabWidget->showPage(newME);
1750 newME->viewport()->setFocus();
1751 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1752 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1753 // For the very first map we do not have flagrows yet...
1754 newME->select("mc:");
1755 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace);
1761 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1763 ErrorCode err=success;
1765 // fn is usually the archive, mapfile the file after uncompressing
1768 // Make fn absolute (needed for unzip)
1769 fn=QDir (fn).absPath();
1775 // Check, if map is already loaded
1777 while (i<=tabWidget->count() -1)
1779 me=(MapEditor*)tabWidget->page(i);
1780 if (me->getFilePath() == fn)
1782 // Already there, ask for confirmation
1783 QMessageBox mb( vymName,
1784 tr("The map %1\nis already opened."
1785 "Opening the same map in multiple editors may lead \n"
1786 "to confusion when finishing working with vym."
1787 "Do you want to").arg(fn),
1788 QMessageBox::Warning,
1789 QMessageBox::Yes | QMessageBox::Default,
1790 QMessageBox::Cancel | QMessageBox::Escape,
1791 QMessageBox::NoButton);
1792 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1793 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1796 case QMessageBox::Yes:
1798 i=tabWidget->count();
1800 case QMessageBox::Cancel:
1812 if ( !fn.isEmpty() )
1814 me = currentMapEditor();
1815 int tabIndex=tabWidget->currentPageIndex();
1816 // Check first, if mapeditor exists
1817 // If it is not default AND we want a new map,
1818 // create a new mapeditor in a new tab
1819 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1821 me= new MapEditor ( NULL);
1822 tabWidget->addTab (me,fn);
1823 tabIndex=tabWidget->indexOf (me);
1824 tabWidget->setCurrentPage (tabIndex);
1825 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1826 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1829 // Check, if file exists (important for creating new files
1830 // from command line
1831 if (!QFile(fn).exists() )
1833 QMessageBox mb( vymName,
1834 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1835 QMessageBox::Question,
1837 QMessageBox::Cancel | QMessageBox::Default,
1838 QMessageBox::NoButton );
1840 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1841 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1844 case QMessageBox::Yes:
1846 currentMapEditor()->setFilePath(fn);
1847 tabWidget->setTabLabel (currentMapEditor(),
1848 currentMapEditor()->getFileName() );
1849 statusBar()->message( "Created " + fn , statusbarTime );
1852 case QMessageBox::Cancel:
1853 // don't create new map
1854 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1861 //tabWidget->currentPage() won't be NULL here, because of above...
1862 tabWidget->showPage(me);
1863 me->viewport()->setFocus();
1865 // Create temporary directory for packing
1867 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1870 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1871 tr("Couldn't create temporary directory before load\n"));
1875 // Try to unzip file
1876 err=unzipDir (tmpMapDir,fn);
1880 me->setZipped(false);
1883 me->setZipped(true);
1885 // Look for mapname.xml
1886 mapfile= fn.left(fn.findRev(".",-1,true));
1887 mapfile=mapfile.section( '/', -1 );
1888 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1889 if (!file.exists() )
1891 // mapname.xml does not exist, well,
1892 // maybe someone renamed the mapname.vym file...
1893 // Try to find any .xml in the toplevel
1894 // directory of the .vym file
1895 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1896 if (flist.count()==1)
1898 // Only one entry, take this one
1899 mapfile=tmpMapDir + "/"+flist.first();
1902 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1903 *it=tmpMapDir + "/" + *it;
1904 // TODO Multiple entries, load all (but only the first one into this ME)
1905 //mainWindow->fileLoadFromTmp (flist);
1906 //returnCode=1; // Silently forget this attempt to load
1907 qWarning ("MainWindow::load (fn) multimap found...");
1910 if (flist.isEmpty() )
1912 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1913 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1916 } //file doesn't exist
1918 mapfile=file.name();
1923 // Save existing filename in case we import
1924 QString fn_org=me->getFilePath();
1926 // Finally load map into mapEditor
1927 me->setFilePath (mapfile,fn);
1928 err=me->load(mapfile,lmode);
1930 // Restore old (maybe empty) filepath, if this is an import
1932 me->setFilePath (fn_org);
1935 // Finally check for errors and go home
1938 if (lmode==NewMap) fileCloseMap();
1939 statusBar()->message( "Could not load " + fn, statusbarTime );
1944 me->setFilePath (fn);
1945 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1946 if (fn.left(9)!="/tmp/vym-")
1948 // Only append to lastMaps if not loaded from a tmpDir
1949 // e.g. imported bookmarks are in a tmpDir
1950 addRecentMap(me->getFilePath() );
1952 actionFilePrint->setEnabled (true);
1954 statusBar()->message( "Loaded " + fn, statusbarTime );
1958 removeDir (QDir(tmpMapDir));
1964 void Main::fileLoad(const LoadMode &lmode)
1966 QStringList filters;
1967 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1968 QFileDialog *fd=new QFileDialog( this);
1969 fd->setDir (lastFileDir);
1970 fd->setFileMode (QFileDialog::ExistingFiles);
1971 fd->setFilters (filters);
1975 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1978 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1981 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1987 if ( fd->exec() == QDialog::Accepted )
1989 lastFileDir=fd->directory().path();
1990 QStringList flist = fd->selectedFiles();
1991 QStringList::Iterator it = flist.begin();
1992 while( it != flist.end() )
1995 fileLoad(*it, lmode);
2002 void Main::fileLoad()
2007 void Main::fileLoadRecent()
2009 QAction *action = qobject_cast<QAction *>(sender());
2011 fileLoad (action->data().toString(), NewMap);
2014 void Main::addRecentMap (const QString &fileName)
2017 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2018 files.removeAll(fileName);
2019 files.prepend(fileName);
2020 while (files.size() > MaxRecentFiles)
2023 settings.setValue("/mainwindow/recentFileList", files);
2025 setupRecentMapsMenu();
2028 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
2030 // tmp dir for zipping
2034 ErrorCode err=success;
2036 QString safeFilePath;
2038 bool saveZipped=me->saveZipped();
2042 QString fn=me->getFilePath();
2043 // filename=unnamed, filepath="" in constructor of mapEditor
2044 if ( !fn.isEmpty() )
2046 // We have a filepath, go on saving
2047 // First remove existing file, we
2048 // don't want to add to old zip archives
2052 QMessageBox::warning( 0, tr( "Save Error" ),
2053 fn+ tr("\ncould not be removed before saving"));
2055 // Look, if we should zip the data:
2058 QMessageBox mb( vymName,
2059 tr("The map %1\ndid not use the compressed "
2060 "vym file format.\nWriting it uncompressed will also write images \n"
2061 "and flags and thus may overwrite files in the "
2062 "given directory\n\nDo you want to write the map").arg(fn),
2063 QMessageBox::Warning,
2064 QMessageBox::Yes | QMessageBox::Default,
2066 QMessageBox::Cancel | QMessageBox::Escape);
2067 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2068 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2069 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2072 case QMessageBox::Yes:
2073 // save compressed (default file format)
2076 case QMessageBox::No:
2077 // save uncompressed
2080 case QMessageBox::Cancel:
2089 // Create temporary directory for packing
2091 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2094 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2095 tr("Couldn't create temporary directory before save\n"));
2099 safeFilePath=me->getFilePath();
2100 me->setFilePath (tmpMapDir+"/"+
2101 me->getMapName()+ ".xml",
2103 me->save (savemode);
2104 me->setFilePath (safeFilePath);
2106 zipDir (tmpMapDir,fn);
2111 safeFilePath=me->getFilePath();
2112 me->setFilePath (fn, safeFilePath);
2113 me->save (savemode);
2114 me->setFilePath (safeFilePath);
2116 } // filepath available
2119 // We have no filepath yet,
2120 // call fileSaveAs() now, this will call fileSave()
2122 // First switch to editor
2123 tabWidget->setCurrentWidget (me);
2124 fileSaveAs(savemode);
2128 if (saveZipped && !tmpMapDir.isEmpty())
2130 removeDir (QDir(tmpMapDir));
2134 statusBar()->message(
2135 tr("Saved %1").arg(me->getFilePath()),
2137 addRecentMap (me->getFilePath() );
2139 statusBar()->message(
2140 tr("Couldn't save ").arg(me->getFilePath()),
2144 void Main::fileSave()
2146 fileSave (currentMapEditor(), CompleteMap);
2149 void Main::fileSave(MapEditor *me)
2151 fileSave (me,CompleteMap);
2154 void Main::fileSaveAs(const SaveMode& savemode)
2158 if (currentMapEditor())
2160 if (savemode==CompleteMap)
2161 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2163 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2164 if ( !fn.isEmpty() )
2166 // Check for existing file
2167 if (QFile (fn).exists())
2169 QMessageBox mb( vymName,
2170 tr("The file %1\nexists already. Do you want to").arg(fn),
2171 QMessageBox::Warning,
2172 QMessageBox::Yes | QMessageBox::Default,
2173 QMessageBox::Cancel | QMessageBox::Escape,
2174 QMessageBox::NoButton);
2175 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2176 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2179 case QMessageBox::Yes:
2182 case QMessageBox::Cancel:
2189 // New file, add extension to filename, if missing
2190 // This is always .vym or .vyp, depending on savemode
2191 if (savemode==CompleteMap)
2193 if (!fn.contains (".vym") && !fn.contains (".xml"))
2197 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2206 currentMapEditor()->setFilePath(fn);
2207 fileSave(currentMapEditor(), savemode);
2210 if (savemode==CompleteMap)
2211 tabWidget->setTabLabel (currentMapEditor(),
2212 currentMapEditor()->getFileName() );
2218 void Main::fileSaveAs()
2220 fileSaveAs (CompleteMap);
2223 void Main::fileImportKDEBookmarks()
2225 ImportKDEBookmarks im;
2227 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2228 currentMapEditor()->setFilePath ("");
2231 void Main::fileImportFirefoxBookmarks()
2233 Q3FileDialog *fd=new Q3FileDialog( this);
2234 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2235 fd->setMode (Q3FileDialog::ExistingFiles);
2236 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2237 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2240 if ( fd->exec() == QDialog::Accepted )
2242 ImportFirefoxBookmarks im;
2243 QStringList flist = fd->selectedFiles();
2244 QStringList::Iterator it = flist.begin();
2245 while( it != flist.end() )
2248 if (im.transform() &&
2249 success==fileLoad (im.getTransformedFile(),NewMap) &&
2250 currentMapEditor() )
2251 currentMapEditor()->setFilePath ("");
2258 void Main::fileImportMM()
2262 Q3FileDialog *fd=new Q3FileDialog( this);
2263 fd->setDir (lastFileDir);
2264 fd->setMode (Q3FileDialog::ExistingFiles);
2265 fd->addFilter ("Mind Manager (*.mmap)");
2266 fd->setCaption(tr("Import")+" "+"Mind Manager");
2269 if ( fd->exec() == QDialog::Accepted )
2271 lastFileDir=fd->dirPath();
2272 QStringList flist = fd->selectedFiles();
2273 QStringList::Iterator it = flist.begin();
2274 while( it != flist.end() )
2277 if (im.transform() &&
2278 success==fileLoad (im.getTransformedFile(),NewMap) &&
2279 currentMapEditor() )
2280 currentMapEditor()->setFilePath ("");
2289 void Main::fileImportDir()
2291 if (currentMapEditor())
2292 currentMapEditor()->importDir();
2295 void Main::fileExportXML() //FIXME not scriptable yet
2297 if (currentMapEditor())
2299 QString dir=browseDirectory(tr("Export XML to directory"));
2300 if (dir !="" && reallyWriteDirectory(dir) )
2301 currentMapEditor()->exportXML(dir);
2306 void Main::fileExportXHTML()
2308 MapEditor *me=currentMapEditor();
2309 if (me) me->exportXHTML();
2312 void Main::fileExportImage()
2314 MapEditor *me=currentMapEditor();
2315 if (me) me->exportImage();
2318 void Main::fileExportASCII()
2320 MapEditor *me=currentMapEditor();
2321 if (me) me->exportASCII();
2324 void Main::fileExportCSV() //FIXME not scriptable yet
2326 MapEditor *me=currentMapEditor();
2330 ex.setMapCenter(me->getMapCenter());
2331 ex.addFilter ("CSV (*.csv)");
2332 ex.setDir(lastImageDir);
2333 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2334 if (ex.execDialog() )
2336 me->setExportMode(true);
2338 me->setExportMode(false);
2343 void Main::fileExportLaTeX() //FIXME not scriptable yet
2345 MapEditor *me=currentMapEditor();
2349 ex.setMapCenter(me->getMapCenter());
2350 ex.addFilter ("Tex (*.tex)");
2351 ex.setDir(lastImageDir);
2352 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2353 if (ex.execDialog() )
2355 me->setExportMode(true);
2357 me->setExportMode(false);
2362 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2364 ExportKDEBookmarks ex;
2365 MapEditor *me=currentMapEditor();
2368 ex.setMapCenter (me->getMapCenter() );
2373 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2375 ExportTaskjuggler ex;
2376 MapEditor *me=currentMapEditor();
2379 ex.setMapCenter (me->getMapCenter() );
2380 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2381 ex.setDir(lastImageDir);
2382 ex.addFilter ("Taskjuggler (*.tjp)");
2383 if (ex.execDialog() )
2385 me->setExportMode(true);
2387 me->setExportMode(false);
2392 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2394 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2395 // TODO add preview in dialog
2396 //ImagePreview *p =new ImagePreview (fd);
2397 //fd->setContentsPreviewEnabled( TRUE );
2398 //fd->setContentsPreview( p, p );
2399 //fd->setPreviewMode( QFileDialog::Contents );
2400 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2401 fd->setDir (QDir().current());
2402 if (fd->foundConfig())
2406 if ( fd->exec() == QDialog::Accepted )
2408 QString fn=fd->selectedFile();
2409 if (!fn.contains (".odp"))
2412 //lastImageDir=fn.left(fn.findRev ("/"));
2413 if (currentMapEditor())
2414 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2418 QMessageBox::warning(0,
2420 tr("Couldn't find configuration for export to Open Office\n"));
2424 void Main::fileCloseMap()
2426 if (currentMapEditor())
2428 if (currentMapEditor()->hasChanged())
2430 QMessageBox mb( vymName,
2431 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2432 QMessageBox::Warning,
2433 QMessageBox::Yes | QMessageBox::Default,
2435 QMessageBox::Cancel | QMessageBox::Escape );
2436 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2437 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2440 case QMessageBox::Yes:
2442 fileSave(currentMapEditor(), CompleteMap);
2444 case QMessageBox::No:
2445 // close without saving
2447 case QMessageBox::Cancel:
2452 currentMapEditor()->closeMap();
2453 tabWidget->removePage(currentMapEditor());
2454 if (tabWidget->count()==0)
2455 actionFilePrint->setEnabled (false);
2459 void Main::filePrint()
2461 if (currentMapEditor())
2462 currentMapEditor()->print();
2465 void Main::fileExitVYM()
2467 // Check if one or more editors have changed
2470 for (i=0;i<=tabWidget->count() -1;i++)
2473 me=(MapEditor*)tabWidget->page(i);
2475 // If something changed, ask what to do
2476 if (me->hasChanged())
2478 tabWidget->setCurrentPage(i);
2479 QMessageBox mb( vymName,
2480 tr("This map is not saved yet. Do you want to"),
2481 QMessageBox::Warning,
2482 QMessageBox::Yes | QMessageBox::Default,
2484 QMessageBox::Cancel | QMessageBox::Escape );
2485 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2486 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2489 mb.setActiveWindow();
2490 switch( mb.exec() ) {
2491 case QMessageBox::Yes:
2492 // save (the changed editors) and exit
2493 fileSave(currentMapEditor(), CompleteMap);
2495 case QMessageBox::No:
2496 // exit without saving
2498 case QMessageBox::Cancel:
2499 // don't save and don't exit
2503 } // loop over all MEs
2507 void Main::editUndo()
2509 if (currentMapEditor())
2510 currentMapEditor()->undo();
2513 void Main::editRedo()
2515 if (currentMapEditor())
2516 currentMapEditor()->redo();
2519 void Main::gotoHistoryStep (int i)
2521 if (currentMapEditor())
2522 currentMapEditor()->gotoHistoryStep (i);
2525 void Main::editCopy()
2527 if (currentMapEditor())
2528 currentMapEditor()->copy();
2531 void Main::editPaste()
2533 if (currentMapEditor())
2534 currentMapEditor()->paste();
2537 void Main::editCut()
2539 if (currentMapEditor())
2540 currentMapEditor()->cut();
2543 void Main::editOpenFindWindow()
2545 findWindow->popup();
2546 findWindow->raise();
2547 findWindow->setActiveWindow();
2550 void Main::editFind(QString s)
2553 BranchObj *bo=currentMapEditor()->findText(s, cs);
2556 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2559 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2560 tr("No matches found for \"%1\"").arg(s));
2564 void Main::editFindChanged()
2565 { // Notify editor, to abort the current find process
2566 currentMapEditor()->findReset();
2569 void Main::openTabs(QStringList urls)
2571 if (!urls.isEmpty())
2575 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2577 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2579 QString u=urls.takeFirst();
2580 procBrowser = new QProcess( this );
2582 procBrowser->start(browser,args);
2583 if ( !procBrowser->waitForStarted())
2585 // try to set path to browser
2586 QMessageBox::warning(0,
2588 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2589 tr("Please use Settings->")+tr("Set application to open an URL"));
2594 if (browser.contains("konqueror"))
2596 for (int i=0; i<urls.size(); i++)
2599 // Try to open new tab in existing konqueror started previously by vym
2600 p=new QProcess (this);
2602 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2603 "konqueror-mainwindow#1"<<
2606 p->start ("dcop",args);
2607 if ( !p->waitForStarted() ) success=false;
2610 QMessageBox::warning(0,
2612 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2614 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2616 for (int i=0; i<urls.size(); i++)
2618 // Try to open new tab in firefox
2619 p=new QProcess (this);
2620 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2621 p->start (browser,args);
2622 if ( !p->waitForStarted() ) success=false;
2625 QMessageBox::warning(0,
2627 tr("Couldn't start %1 to open a new tab").arg(browser));
2630 QMessageBox::warning(0,
2632 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2636 void Main::editOpenURL()
2639 if (currentMapEditor())
2641 QString url=currentMapEditor()->getURL();
2643 if (url=="") return;
2644 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2645 procBrowser = new QProcess( this );
2647 procBrowser->start(browser,args);
2648 if ( !procBrowser->waitForStarted())
2650 // try to set path to browser
2651 QMessageBox::warning(0,
2653 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2654 tr("Please use Settings->")+tr("Set application to open an URL"));
2659 void Main::editOpenURLTab()
2661 if (currentMapEditor())
2664 urls.append(currentMapEditor()->getURL());
2668 void Main::editOpenMultipleURLTabs()
2670 if (currentMapEditor())
2673 urls=currentMapEditor()->getURLs();
2679 void Main::editURL()
2681 if (currentMapEditor())
2682 currentMapEditor()->editURL();
2685 void Main::editHeading2URL()
2687 if (currentMapEditor())
2688 currentMapEditor()->editHeading2URL();
2691 void Main::editBugzilla2URL()
2693 if (currentMapEditor())
2694 currentMapEditor()->editBugzilla2URL();
2697 void Main::editFATE2URL()
2699 if (currentMapEditor())
2700 currentMapEditor()->editFATE2URL();
2703 void Main::editHeadingFinished()
2705 // only called from editHeading(), so there is a currentME
2706 MapEditor *me=currentMapEditor();
2709 me->setStateEditHeading (false);
2710 QPoint p; //Not used here, only to find out pos of branch
2712 QString s=me->getHeading(ok,p);
2714 #if defined(Q_OS_MACX)
2716 if (ok && s!=lineedit->text())
2717 me->setHeading(lineedit->text());
2719 lineedit->releaseKeyboard();
2723 if (!prevSelection.isEmpty()) me->select(prevSelection);
2728 void Main::editHeading()
2730 if (currentMapEditor())
2732 MapEditor *me=currentMapEditor();
2733 QString oldSel=me->getSelectString();
2735 if (lineedit->isVisible())
2736 editHeadingFinished();
2741 QString s=currentMapEditor()->getHeading(ok,p);
2745 me->setStateEditHeading (true);
2746 #if defined(Q_OS_MACX)
2747 p=currentMapEditor()->mapTo (this,p);
2748 QDialog *d =new QDialog(NULL);
2749 QLineEdit *le=new QLineEdit (d);
2750 d->setWindowFlags (Qt::FramelessWindowHint);
2751 d->setGeometry(p.x(),p.y(),230,25);
2752 le->resize (d->width()-10,d->height());
2755 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2756 d->activateWindow();
2758 currentMapEditor()->setHeading (le->text());
2761 editHeadingFinished();
2763 p=currentMapEditor()->mapTo (this,p);
2764 lineedit->setGeometry(p.x(),p.y(),230,25);
2765 lineedit->setText(s);
2766 lineedit->setCursorPosition(1);
2767 lineedit->selectAll();
2769 lineedit->grabKeyboard();
2770 lineedit->setFocus();
2774 } // currentMapEditor()
2777 void Main::openVymLinks(const QStringList &vl)
2779 for (int j=0; j<vl.size(); j++)
2781 // compare path with already loaded maps
2785 for (i=0;i<=tabWidget->count() -1;i++)
2787 me=(MapEditor*)tabWidget->page(i);
2788 if (vl.at(j)==me->getFilePath() )
2797 if (!QFile(vl.at(j)).exists() )
2798 QMessageBox::critical( 0, tr( "Critical Error" ),
2799 tr("Couldn't open map %1").arg(vl.at(j)));
2802 fileLoad (vl.at(j), NewMap);
2803 tabWidget->setCurrentPage (tabWidget->count()-1);
2806 // Go to tab containing the map
2807 tabWidget->setCurrentPage (index);
2811 void Main::editOpenVymLink()
2813 if (currentMapEditor())
2816 vl.append(currentMapEditor()->getVymLink());
2821 void Main::editOpenMultipleVymLinks()
2823 QString currentVymLink;
2824 if (currentMapEditor())
2826 QStringList vl=currentMapEditor()->getVymLinks();
2831 void Main::editVymLink()
2833 if (currentMapEditor())
2834 currentMapEditor()->editVymLink();
2837 void Main::editDeleteVymLink()
2839 if (currentMapEditor())
2840 currentMapEditor()->deleteVymLink();
2843 void Main::editToggleHideExport()
2845 if (currentMapEditor())
2846 currentMapEditor()->toggleHideExport();
2849 void Main::editMapInfo()
2851 if (currentMapEditor())
2852 currentMapEditor()->editMapInfo();
2855 void Main::editMoveUp()
2857 if (currentMapEditor())
2858 currentMapEditor()->moveBranchUp();
2861 void Main::editMoveDown()
2863 if (currentMapEditor())
2864 currentMapEditor()->moveBranchDown();
2867 void Main::editToggleScroll()
2869 if (currentMapEditor())
2871 currentMapEditor()->toggleScroll();
2875 void Main::editUnscrollChilds()
2877 if (currentMapEditor())
2878 currentMapEditor()->unscrollChilds();
2881 void Main::editNewBranch()
2883 MapEditor *me=currentMapEditor();
2884 if (!lineedit->isVisible() && me)
2886 BranchObj *bo=(BranchObj*)me->getSelection();
2887 BranchObj *newbo=me->addNewBranch(0);
2890 me->select (newbo->getSelectString());
2894 if (actionSettingsAutoEdit->isOn())
2896 if (!actionSettingsAutoSelectHeading->isOn())
2897 prevSelection=bo->getSelectString();
2903 void Main::editNewBranchBefore()
2905 MapEditor *me=currentMapEditor();
2906 if (!lineedit->isVisible() && me)
2908 BranchObj *bo=(BranchObj*)me->getSelection();
2909 BranchObj *newbo=me->addNewBranchBefore();
2912 me->select (newbo->getSelectString());
2916 if (actionSettingsAutoEdit->isOn())
2918 if (!actionSettingsAutoSelectHeading->isOn())
2919 prevSelection=bo->getSelectString();
2925 void Main::editNewBranchAbove()
2927 MapEditor *me=currentMapEditor();
2928 if (!lineedit->isVisible() && me)
2930 BranchObj *bo=(BranchObj*)me->getSelection();
2931 BranchObj *newbo=me->addNewBranch (-1);
2934 me->select (newbo->getSelectString());
2938 if (actionSettingsAutoEdit->isOn())
2940 if (!actionSettingsAutoSelectHeading->isOn())
2941 prevSelection=bo->getSelectString();
2947 void Main::editNewBranchBelow()
2949 MapEditor *me=currentMapEditor();
2950 if (!lineedit->isVisible() && me)
2952 BranchObj *bo=(BranchObj*)me->getSelection();
2953 BranchObj *newbo=me->addNewBranch (1);
2956 me->select (newbo->getSelectString());
2960 if (actionSettingsAutoEdit->isOn())
2962 if (!actionSettingsAutoSelectHeading->isOn())
2963 prevSelection=bo->getSelectString();
2969 void Main::editImportAdd()
2971 fileLoad (ImportAdd);
2974 void Main::editImportReplace()
2976 fileLoad (ImportReplace);
2979 void Main::editSaveBranch()
2981 fileSaveAs (PartOfMap);
2984 void Main::editDeleteKeepChilds()
2986 if (currentMapEditor())
2987 currentMapEditor()->deleteKeepChilds();
2990 void Main::editDeleteChilds()
2992 if (currentMapEditor())
2993 currentMapEditor()->deleteChilds();
2996 void Main::editDeleteSelection()
2998 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2999 currentMapEditor()->deleteSelection();
3002 void Main::editUpperBranch()
3004 if (currentMapEditor())
3005 currentMapEditor()->selectUpperBranch();
3008 void Main::editLowerBranch()
3010 if (currentMapEditor())
3011 currentMapEditor()->selectLowerBranch();
3014 void Main::editLeftBranch()
3016 if (currentMapEditor())
3017 currentMapEditor()->selectLeftBranch();
3020 void Main::editRightBranch()
3022 if (currentMapEditor())
3023 currentMapEditor()->selectRightBranch();
3026 void Main::editFirstBranch()
3028 if (currentMapEditor())
3029 currentMapEditor()->selectFirstBranch();
3032 void Main::editLastBranch()
3034 if (currentMapEditor())
3035 currentMapEditor()->selectLastBranch();
3038 void Main::editLoadImage()
3040 if (currentMapEditor())
3041 currentMapEditor()->loadFloatImage();
3044 void Main::editSaveImage()
3046 if (currentMapEditor())
3047 currentMapEditor()->saveFloatImage();
3050 void Main::editFollowXLink(QAction *a)
3053 if (currentMapEditor())
3054 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3057 void Main::editEditXLink(QAction *a)
3059 if (currentMapEditor())
3060 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3063 void Main::formatSelectColor()
3065 if (currentMapEditor())
3067 QColor col = QColorDialog::getColor((currentColor ), this );
3068 if ( !col.isValid() ) return;
3069 colorChanged( col );
3073 void Main::formatPickColor()
3075 if (currentMapEditor())
3076 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3079 void Main::colorChanged(QColor c)
3081 QPixmap pix( 16, 16 );
3083 actionFormatColor->setIconSet( pix );
3087 void Main::formatColorBranch()
3089 if (currentMapEditor())
3090 currentMapEditor()->colorBranch(currentColor);
3093 void Main::formatColorSubtree()
3095 if (currentMapEditor())
3096 currentMapEditor()->colorSubtree (currentColor);
3099 void Main::formatLinkStyleLine()
3101 if (currentMapEditor())
3102 currentMapEditor()->setMapLinkStyle("StyleLine");
3105 void Main::formatLinkStyleParabel()
3107 if (currentMapEditor())
3108 currentMapEditor()->setMapLinkStyle("StyleParabel");
3111 void Main::formatLinkStylePolyLine()
3113 if (currentMapEditor())
3114 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3117 void Main::formatLinkStylePolyParabel()
3119 if (currentMapEditor())
3120 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3123 void Main::formatSelectBackColor()
3125 if (currentMapEditor())
3126 currentMapEditor()->selectMapBackgroundColor();
3129 void Main::formatSelectBackImage()
3131 if (currentMapEditor())
3132 currentMapEditor()->selectMapBackgroundImage();
3135 void Main::formatSelectLinkColor()
3137 if (currentMapEditor())
3138 currentMapEditor()->selectMapLinkColor();
3141 void Main::formatSelectSelectionColor()
3143 if (currentMapEditor())
3144 currentMapEditor()->selectMapSelectionColor();
3147 void Main::formatToggleLinkColorHint()
3149 currentMapEditor()->toggleMapLinkColorHint();
3153 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3155 if (currentMapEditor())
3156 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3159 void Main::viewZoomReset()
3161 if (currentMapEditor())
3165 currentMapEditor()->setMatrix( m );
3169 void Main::viewZoomIn()
3171 if (currentMapEditor())
3173 QMatrix m = currentMapEditor()->matrix();
3174 m.scale( 1.25, 1.25 );
3175 currentMapEditor()->setMatrix( m );
3179 void Main::viewZoomOut()
3181 if (currentMapEditor())
3183 QMatrix m = currentMapEditor()->matrix();
3184 m.scale( 0.8, 0.8 );
3185 currentMapEditor()->setMatrix( m );
3189 bool Main::settingsPDF()
3191 // Default browser is set in constructor
3193 QString text = QInputDialog::getText(
3194 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3195 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3197 settings.setValue ("/mainwindow/readerPDF",text);
3202 bool Main::settingsURL()
3204 // Default browser is set in constructor
3206 QString text = QInputDialog::getText(
3207 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3208 settings.value("/mainwindow/readerURL").toString()
3211 settings.setValue ("/mainwindow/readerURL",text);
3215 void Main::settingsMacroDir()
3217 QDir defdir=vymBaseDir;
3218 defdir.cd("macros");
3219 if (!defdir.exists())
3221 QDir dir=QFileDialog::getExistingDirectory (
3223 tr ("Directory with vym macros:"),
3224 settings.value ("/macros/macroDir",defdir.path()).toString()
3227 settings.setValue ("/macros/macroDir",dir.path());
3230 void Main::settingsUndoLevels()
3233 int i = QInputDialog::getInteger(
3235 tr("QInputDialog::getInteger()"),
3236 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3239 settings.setValue ("/mapeditor/stepsTotal",i);
3240 QMessageBox::information( this, tr( "VYM -Information:" ),
3241 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3245 void Main::settingsAutosaveToggle()
3247 settings.setValue ("/mapeditor/autosave/used",actionSettingsAutosaveToggle->isOn() );
3250 void Main::settingsAutosaveTime()
3253 int i = QInputDialog::getInteger(
3255 tr("QInputDialog::getInteger()"),
3256 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3259 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3263 void Main::settingsToggleDelKey()
3265 if (actionSettingsUseDelKey->isOn())
3267 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3270 actionEditDelete->setAccel (QKeySequence (""));
3274 void Main::windowToggleNoteEditor()
3276 if (textEditor->isVisible() )
3277 windowHideNoteEditor();
3279 windowShowNoteEditor();
3282 void Main::windowToggleHistory()
3284 if (historyWindow->isVisible())
3285 historyWindow->hide();
3287 historyWindow->show();
3291 void Main::windowToggleProperty()
3293 if (branchPropertyWindow->isVisible())
3294 branchPropertyWindow->hide();
3296 branchPropertyWindow->show();
3298 if(currentMapEditor())
3300 LinkableMapObj *sel=currentMapEditor()->getSelection();
3301 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3302 typeid(*sel) == typeid(MapCenterObj)))
3304 branchPropertyWindow->setMapEditor(currentMapEditor());
3305 branchPropertyWindow->setBranch((BranchObj*)sel);
3310 branchPropertyWindow->setBranch(NULL);
3313 void Main::windowToggleAntiAlias()
3315 bool b=actionViewToggleAntiAlias->isOn();
3317 for (int i=0;i<tabWidget->count();i++)
3320 me=(MapEditor*)tabWidget->page(i);
3321 me->setAntiAlias(b);
3326 void Main::windowToggleSmoothPixmap()
3328 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3330 for (int i=0;i<tabWidget->count();i++)
3333 me=(MapEditor*)tabWidget->page(i);
3334 me->setSmoothPixmap(b);
3338 void Main::updateHistory(SimpleSettings &undoSet)
3340 historyWindow->update (undoSet);
3343 void Main::updateNoteFlag()
3345 if (currentMapEditor())
3346 currentMapEditor()->updateNoteFlag();
3349 void Main::updateSatellites(MapEditor *me)
3351 branchPropertyWindow->setMapEditor (me);
3354 void Main::updateActions()
3356 MapEditor *me=currentMapEditor();
3359 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3361 // updateActions is also called when NoteEditor is closed
3362 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3363 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3364 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3366 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3367 actionFormatLinkColorHint->setOn(true);
3369 actionFormatLinkColorHint->setOn(false);
3371 switch (me->getMapLinkStyle())
3373 case LinkableMapObj::Line:
3374 actionFormatLinkStyleLine->setOn(true);
3376 case LinkableMapObj::Parabel:
3377 actionFormatLinkStyleParabel->setOn(true);
3379 case LinkableMapObj::PolyLine:
3380 actionFormatLinkStylePolyLine->setOn(true);
3382 case LinkableMapObj::PolyParabel:
3383 actionFormatLinkStylePolyParabel->setOn(true);
3390 QPixmap pix( 16, 16 );
3391 pix.fill( me->getMapBackgroundColor() );
3392 actionFormatBackColor->setIconSet( pix );
3393 pix.fill( me->getSelectionColor() );
3394 actionFormatSelectionColor->setIconSet( pix );
3395 pix.fill( me->getMapDefLinkColor() );
3396 actionFormatLinkColor->setIconSet( pix );
3399 actionFileSave->setEnabled( me->hasChanged() );
3400 if (me->isUndoAvailable())
3401 actionEditUndo->setEnabled( true);
3403 actionEditUndo->setEnabled( false);
3405 if (me->isRedoAvailable())
3406 actionEditRedo->setEnabled( true);
3408 actionEditRedo->setEnabled( false);
3410 LinkableMapObj *selection=me->getSelection();
3413 if ( (typeid(*selection) == typeid(BranchObj)) ||
3414 (typeid(*selection) == typeid(MapCenterObj)) )
3416 BranchObj *bo=(BranchObj*)selection;
3417 // Take care of links
3418 if (bo->countXLinks()==0)
3420 branchXLinksContextMenuEdit->clear();
3421 branchXLinksContextMenuFollow->clear();
3426 branchXLinksContextMenuEdit->clear();
3427 branchXLinksContextMenuFollow->clear();
3428 for (int i=0; i<=bo->countXLinks();i++)
3430 bot=bo->XLinkTargetAt(i);
3433 s=bot->getHeading();
3436 branchXLinksContextMenuFollow->addAction (s);
3437 branchXLinksContextMenuEdit->addAction (s);
3442 standardFlagsDefault->setEnabled (true);
3444 actionEditToggleScroll->setEnabled (true);
3445 if ( bo->isScrolled() )
3446 actionEditToggleScroll->setOn(true);
3448 actionEditToggleScroll->setOn(false);
3450 if ( bo->getURL().isEmpty() )
3452 actionEditOpenURL->setEnabled (false);
3453 actionEditOpenURLTab->setEnabled (false);
3457 actionEditOpenURL->setEnabled (true);
3458 actionEditOpenURLTab->setEnabled (true);
3460 if ( bo->getVymLink().isEmpty() )
3462 actionEditOpenVymLink->setEnabled (false);
3463 actionEditDeleteVymLink->setEnabled (false);
3466 actionEditOpenVymLink->setEnabled (true);
3467 actionEditDeleteVymLink->setEnabled (true);
3470 if (bo->canMoveBranchUp())
3471 actionEditMoveUp->setEnabled (true);
3473 actionEditMoveUp->setEnabled (false);
3474 if (bo->canMoveBranchDown())
3475 actionEditMoveDown->setEnabled (true);
3477 actionEditMoveDown->setEnabled (false);
3480 actionEditToggleHideExport->setEnabled (true);
3481 actionEditToggleHideExport->setOn (bo->hideInExport() );
3483 actionEditCopy->setEnabled (true);
3484 actionEditCut->setEnabled (true);
3485 if (!clipboardEmpty)
3486 actionEditPaste->setEnabled (true);
3488 actionEditPaste->setEnabled (false);
3489 for (int i=0; i<actionListBranches.size(); ++i)
3490 actionListBranches.at(i)->setEnabled(true);
3491 actionEditDelete->setEnabled (true);
3492 actionFormatHideLinkUnselected->setOn
3493 (selection->getHideLinkUnselected());
3495 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3497 FloatObj *fo=(FloatImageObj*)selection;
3499 actionEditOpenURL->setEnabled (false);
3500 actionEditOpenVymLink->setEnabled (false);
3501 actionEditDeleteVymLink->setEnabled (false);
3502 actionEditToggleHideExport->setEnabled (true);
3503 actionEditToggleHideExport->setOn (fo->hideInExport() );
3506 actionEditCopy->setEnabled (true);
3507 actionEditCut->setEnabled (true);
3508 actionEditPaste->setEnabled (false);
3509 for (int i=0; i<actionListBranches.size(); ++i)
3510 actionListBranches.at(i)->setEnabled(false);
3511 actionEditDelete->setEnabled (true);
3512 actionFormatHideLinkUnselected->setOn
3513 ( selection->getHideLinkUnselected());
3514 actionEditMoveUp->setEnabled (false);
3515 actionEditMoveDown->setEnabled (false);
3520 actionEditCopy->setEnabled (false);
3521 actionEditCut->setEnabled (false);
3522 actionEditPaste->setEnabled (false);
3523 for (int i=0; i<actionListBranches.size(); ++i)
3524 actionListBranches.at(i)->setEnabled(false);
3526 actionEditToggleScroll->setEnabled (false);
3527 actionEditOpenURL->setEnabled (false);
3528 actionEditOpenVymLink->setEnabled (false);
3529 actionEditDeleteVymLink->setEnabled (false);
3530 actionEditHeading2URL->setEnabled (false);
3531 actionEditDelete->setEnabled (false);
3532 actionEditMoveUp->setEnabled (false);
3533 actionEditMoveDown->setEnabled (false);
3534 actionEditToggleHideExport->setEnabled (false);
3538 Main::ModMode Main::getModMode()
3540 if (actionModModeColor->isOn()) return ModModeColor;
3541 if (actionModModeCopy->isOn()) return ModModeCopy;
3542 if (actionModModeXLink->isOn()) return ModModeXLink;
3546 bool Main::autoEdit()
3548 return actionSettingsAutoEdit->isOn();
3551 bool Main::autoSelectHeading()
3553 return actionSettingsAutoSelectHeading->isOn();
3556 bool Main::useFlagGroups()
3558 return actionSettingsUseFlagGroups->isOn();
3561 void Main::windowShowNoteEditor()
3563 textEditor->setShowWithMain(true);
3565 actionViewToggleNoteEditor->setOn (true);
3568 void Main::windowHideNoteEditor()
3570 textEditor->setShowWithMain(false);
3572 actionViewToggleNoteEditor->setOn (false);
3575 void Main::setScript (const QString &script)
3577 scriptEditor->setScript (script);
3580 void Main::runScript (const QString &script)
3582 if (currentMapEditor())
3583 currentMapEditor()->runScript (script);
3586 void Main::runScriptEverywhere (const QString &script)
3589 for (int i=0;i<=tabWidget->count() -1;i++)
3591 me=(MapEditor*)tabWidget->page(i);
3592 if (me) me->runScript (script);
3596 void Main::windowNextEditor()
3598 if (tabWidget->currentPageIndex() < tabWidget->count())
3599 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3602 void Main::windowPreviousEditor()
3604 if (tabWidget->currentPageIndex() >0)
3605 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3608 void Main::standardFlagChanged()
3610 if (currentMapEditor())
3611 currentMapEditor()->toggleStandardFlag(sender()->name());
3614 void Main::testFunction()
3616 if (!currentMapEditor()) return;
3617 currentMapEditor()->testFunction();
3620 void Main::testCommand()
3622 if (!currentMapEditor()) return;
3623 scriptEditor->show();
3626 QString com = QInputDialog::getText(
3627 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3628 if (ok) currentMapEditor()->parseAtom(com);
3632 void Main::helpDoc()
3634 QString locale = QLocale::system().name();
3636 if (locale.left(2)=="es")
3637 docname="vym_es.pdf";
3641 QStringList searchList;
3643 #if defined(Q_OS_MACX)
3644 searchList << "./vym.app/Contents";
3646 // default path in SUSE LINUX
3647 searchList <<"/usr/share/doc/packages/vym/doc";
3650 searchList << "doc"; // relative path for easy testing in tarball
3651 searchList << "doc/tex"; // Easy testing working on vym.tex
3652 searchList << "/usr/share/doc/vym"; // Debian
3653 searchList << "/usr/share/doc/packages";// Knoppix
3657 for (int i=0; i<searchList.count(); ++i)
3659 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3660 if (docfile.exists() )
3669 QMessageBox::critical(0,
3670 tr("Critcal error"),
3671 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3676 Process *pdfProc = new Process();
3677 args <<docfile.fileName();
3679 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3680 if ( !pdfProc->waitForStarted() )
3683 QMessageBox::warning(0,
3685 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3686 tr("Please use Settings->")+tr("Set application to open PDF files"));
3693 void Main::helpDemo()
3695 QStringList filters;
3696 filters <<"VYM example map (*.vym)";
3697 QFileDialog *fd=new QFileDialog( this);
3698 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3699 fd->setFileMode (QFileDialog::ExistingFiles);
3700 fd->setFilters (filters);
3701 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3705 if ( fd->exec() == QDialog::Accepted )
3707 lastFileDir=fd->directory().path();
3708 QStringList flist = fd->selectedFiles();
3709 QStringList::Iterator it = flist.begin();
3710 while( it != flist.end() )
3713 fileLoad(*it, NewMap);
3721 void Main::helpAbout()
3724 ad.setName ("aboutwindow");
3725 ad.setMinimumSize(500,500);
3726 ad.resize (QSize (500,500));
3730 void Main::helpAboutQT()
3732 QMessageBox::aboutQt( this, "Qt Application Example" );
3735 void Main::callMacro ()
3737 QAction *action = qobject_cast<QAction *>(sender());
3741 i=action->data().toInt();
3742 QString mDir (settings.value ("macros/macroDir").toString() );
3744 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3746 if ( !f.open( QIODevice::ReadOnly ) )
3748 QMessageBox::warning(0,
3750 tr("Couldn't find a macro at %1.\n").arg(fn)+
3751 tr("Please use Settings->")+tr("Set directory for vym macros"));
3755 QTextStream ts( &f );
3756 QString m= ts.read();
3760 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3761 currentMapEditor()->runScript (m);