Empty branches are always unscrolled after import, relinking to scrolled branch doesn't open branch, starting DBUS implementation
1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
15 #include "historywindow.h"
17 #include "mapeditor.h"
22 #include "texteditor.h"
23 #include "warningdialog.h"
25 #if defined(Q_OS_WIN32)
26 // Define only this structure as opposed to
27 // including full 'windows.h'. FindWindow
28 // clashes with the one in Win32 API.
29 typedef struct _PROCESS_INFORMATION
35 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
38 extern TextEditor *textEditor;
39 extern Main *mainWindow;
40 extern QDBusConnection dbusConnection;
41 extern QString tmpVymDir;
42 extern QString clipboardDir;
43 extern QString clipboardFile;
44 extern bool clipboardEmpty;
45 extern int statusbarTime;
46 extern FlagRow *standardFlagsMaster;
47 extern FlagRow *systemFlagsMaster;
48 extern QString vymName;
49 extern QString vymVersion;
50 extern QString vymBuildDate;
53 QMenu* branchContextMenu;
54 QMenu* branchAddContextMenu;
55 QMenu* branchRemoveContextMenu;
56 QMenu* branchLinksContextMenu;
57 QMenu* branchXLinksContextMenuEdit;
58 QMenu* branchXLinksContextMenuFollow;
59 QMenu* floatimageContextMenu;
60 QMenu* canvasContextMenu;
61 QMenu* fileLastMapsMenu;
62 QMenu* fileImportMenu;
63 QMenu* fileExportMenu;
66 extern Settings settings;
67 extern Options options;
68 extern ImageIO imageIO;
70 extern QDir vymBaseDir;
71 extern QDir lastImageDir;
72 extern QDir lastFileDir;
73 #if defined(Q_OS_WIN32)
74 extern QDir vymInstallDir;
76 extern QString iconPath;
77 extern QString flagsPath;
80 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
81 QMainWindow(parent,name,f)
85 setCaption ("VYM - View Your Mind");
87 // Load window settings
88 #if defined(Q_OS_WIN32)
89 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
91 setWindowState(Qt::WindowMaximized);
96 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
97 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
100 // Sometimes we may need to remember old selections
104 currentColor=Qt::black;
106 // Create unique temporary directory
108 tmpVymDir=makeTmpDir (ok,"vym");
111 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
114 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
116 // Create direcctory for clipboard
117 clipboardDir=tmpVymDir+"/clipboard";
118 clipboardFile="map.xml";
119 QDir d(clipboardDir);
120 d.mkdir (clipboardDir,true);
121 makeSubDirs (clipboardDir);
126 // Satellite windows //////////////////////////////////////////
128 historyWindow=new HistoryWindow();
129 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
132 branchPropertyWindow = new BranchPropertyWindow();
133 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
135 // Connect TextEditor, so that we can update flags if text changes
136 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
137 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
139 // Connect HistoryWindow, so that we can update flags
140 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
143 // Initialize script editor
144 scriptEditor = new SimpleScriptEditor();
145 scriptEditor->move (50,50);
147 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
148 this, SLOT( runScript( QString ) ) );
151 // Initialize Find window
152 findWindow=new FindWindow(NULL);
153 findWindow->move (x(),y()+70);
154 connect (findWindow, SIGNAL( findButton(QString) ),
155 this, SLOT(editFind(QString) ) );
156 connect (findWindow, SIGNAL( somethingChanged() ),
157 this, SLOT(editFindChanged() ) );
159 // Initialize some settings, which are platform dependant
162 // application to open URLs
163 p="/mainwindow/readerURL";
164 #if defined(Q_OS_LINUX)
165 s=settings.value (p,"xdg-open").toString();
167 #if defined(Q_OS_MACX)
168 s=settings.value (p,"/usr/bin/open").toString();
171 #if defined(Q_OS_WIN32)
172 // Assume that system has been set up so that
173 // Explorer automagically opens up the URL
174 // in the user's preferred browser.
175 s=settings.value (p,"explorer").toString();
177 s=settings.value (p,"mozilla").toString();
181 settings.setValue( p,s);
183 // application to open PDFs
184 p="/mainwindow/readerPDF";
185 #if defined(Q_OS_LINUX)
186 s=settings.value (p,"xdg-open").toString();
188 #if defined(Q_OS_MACX)
189 s=settings.value (p,"/usr/bin/open").toString();
190 #elif defined(Q_OS_WIN32)
191 s=settings.value (p,"acrord32").toString();
193 s=settings.value (p,"acroread").toString();
196 settings.setValue( p,s);
198 // width of xLinksMenu
201 // Create tab widget which holds the maps
202 tabWidget= new QTabWidget (this);
203 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
204 this, SLOT( editorChanged( QWidget * ) ) );
206 setCentralWidget(tabWidget);
210 setupFormatActions();
214 setupNetworkActions();
215 setupSettingsActions();
218 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
221 // Status bar and progress bar there
224 progressBar=new QProgressBar;
226 statusBar()->addPermanentWidget(progressBar);
228 restoreState (settings.value("/mainwindow/state",0).toByteArray());
234 dbusConnection = QDBusConnection::sessionBus();
235 dbusConnection.registerObject("/MainWindow", this);
236 dbusConnection.registerService("org.insilmaril.vym");
245 #if defined(Q_OS_WIN32)
246 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
248 settings.setValue ("/mainwindow/geometry/size", size());
249 settings.setValue ("/mainwindow/geometry/pos", pos());
250 settings.setValue ("/mainwindow/state",saveState(0));
252 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
253 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
254 settings.setValue( "/version/version", vymVersion );
255 settings.setValue( "/version/builddate", vymBuildDate );
257 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
258 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
259 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
260 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
261 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
262 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
263 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
264 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
266 //TODO save scriptEditor settings
268 // call the destructors
270 delete historyWindow;
271 delete branchPropertyWindow;
274 // Remove temporary directory
275 removeDir (QDir(tmpVymDir));
278 void Main::loadCmdLine()
280 /* TODO draw some kind of splashscreen while loading...
286 QStringList flist=options.getFileList();
287 QStringList::Iterator it=flist.begin();
289 while (it !=flist.end() )
291 fileLoad (*it, NewMap);
297 void Main::statusMessage(const QString &s)
299 // Surpress messages while progressbar during
301 if (progressMin==progressMax)
302 statusBar()->message( s);
305 void Main::setProgressMinimum (int min)
307 progressBar->setMinimum(min);
311 void Main::setProgressMaximum (int max)
313 progressBar->setMaximum(max);
317 statusBar()->addPermanentWidget(progressBar);
322 void Main::setProgressValue (int v)
324 progressBar->setValue (v);
327 void Main::removeProgressBar()
330 statusBar()->removeWidget(progressBar);
331 progressMax=progressMin=0;
334 void Main::closeEvent (QCloseEvent* )
340 void Main::setupFileActions()
342 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
343 QToolBar *tb = addToolBar( tr ("&Map") );
344 tb->setObjectName ("mapTB");
347 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
348 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
349 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
351 fileMenu->addAction (a);
352 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
354 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
355 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
356 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
357 fileMenu->addAction (a);
358 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
361 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
362 a->setStatusTip (tr( "Open","Status tip File menu" ) );
363 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
365 fileMenu->addAction (a);
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
368 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
369 fileMenu->addSeparator();
371 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
372 a->setStatusTip ( tr( "Save","Status tip file menu" ));
373 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
375 fileMenu->addAction (a);
376 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
379 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
380 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
381 fileMenu->addAction (a);
382 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
384 fileMenu->addSeparator();
386 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
388 a = new QAction(tr("KDE 3 Bookmarks"), this);
389 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
390 a->addTo (fileImportMenu);
391 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
393 a = new QAction(tr("KDE 4 Bookmarks"), this);
394 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
395 a->addTo (fileImportMenu);
396 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
398 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
400 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
401 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
402 a->addTo (fileImportMenu);
403 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
406 a = new QAction("Freemind...",this);
407 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
408 fileImportMenu->addAction (a);
409 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
411 a = new QAction("Mind Manager...",this);
412 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
413 fileImportMenu->addAction (a);
414 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
416 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
417 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
418 fileImportMenu->addAction (a);
419 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
421 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
423 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
424 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
425 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
426 fileExportMenu->addAction (a);
428 a = new QAction( "Open Office...", this);
429 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
430 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
431 fileExportMenu->addAction (a);
433 a = new QAction( "Webpage (XHTML)...",this );
434 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
435 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
436 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
437 fileExportMenu->addAction (a);
439 a = new QAction( "Text (ASCII)...", this);
440 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
441 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
442 fileExportMenu->addAction (a);
444 a = new QAction( "Spreadsheet (CSV)...", this);
445 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
446 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
447 fileExportMenu->addAction (a);
449 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
450 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
451 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
452 fileExportMenu->addAction (a);
454 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
455 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
456 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
457 fileExportMenu->addAction (a);
459 a = new QAction( "Taskjuggler...", this );
460 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
461 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
462 fileExportMenu->addAction (a);
464 a = new QAction( "LaTeX...", this);
465 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
466 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
467 fileExportMenu->addAction (a);
469 a = new QAction( "XML..." , this );
470 a->setStatusTip (tr( "Export as %1").arg("XML"));
471 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
472 fileExportMenu->addAction (a);
474 fileMenu->addSeparator();
476 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
477 a->setStatusTip ( tr( "Print" ,"File menu") );
478 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
480 fileMenu->addAction (a);
481 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
484 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
485 a->setStatusTip (tr( "Close Map" ) );
486 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
487 fileMenu->addAction (a);
488 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
490 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
491 a->setStatusTip ( tr( "Exit")+" "+vymName );
492 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
493 fileMenu->addAction (a);
494 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
499 void Main::setupEditActions()
501 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
502 tb->setLabel( "Edit Actions" );
503 tb->setObjectName ("actionsTB");
504 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
508 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
509 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
510 a->setStatusTip (tr( "Undo" ) );
511 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
512 a->setEnabled (false);
514 editMenu->addAction (a);
517 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
518 a->setStatusTip (tr( "Redo" ));
519 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
521 editMenu->addAction (a);
522 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
525 editMenu->addSeparator();
526 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
527 a->setStatusTip ( tr( "Copy" ) );
528 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
529 a->setEnabled (false);
531 editMenu->addAction (a);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
535 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
536 a->setStatusTip ( tr( "Cut" ) );
537 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
538 a->setEnabled (false);
540 editMenu->addAction (a);
542 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
544 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
545 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
546 a->setStatusTip ( tr( "Paste" ) );
547 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
548 a->setEnabled (false);
550 editMenu->addAction (a);
553 // Shortcut to delete selection
554 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
555 a->setStatusTip (tr( "Delete Selection" ));
556 a->setShortcut ( Qt::Key_Delete); //Delete selection
557 a->setShortcutContext (Qt::WindowShortcut);
559 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
562 // Shortcut to add mapcenter
563 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
564 a->setShortcut ( Qt::Key_M);
565 a->setShortcutContext (Qt::WindowShortcut);
566 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
567 //actionListBranches.append(a);
569 actionAddMapCenter = a;
572 // Shortcut to add branch
573 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
574 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
575 alt->setShortcut (Qt::Key_A); //Add branch
576 alt->setShortcutContext (Qt::WindowShortcut);
578 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
579 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
580 a->setStatusTip ( tr( "Add a branch as child of selection" ));
581 a->setShortcut (Qt::Key_Insert); //Add branch
582 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
583 actionListBranches.append(a);
584 #if defined (Q_OS_MACX)
585 // In OSX show different shortcut in menues, the keys work indepently always
590 editMenu->addAction (actionAddBranch);
591 tb->addAction (actionAddBranch);
594 // Add branch by inserting it at selection
595 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
596 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
597 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
598 a->setShortcutContext (Qt::WindowShortcut);
600 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
601 a->setEnabled (false);
602 actionListBranches.append(a);
603 actionAddBranchBefore=a;
604 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
605 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
606 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
607 a->setShortcutContext (Qt::WindowShortcut);
609 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
610 actionListBranches.append(a);
613 a = new QAction(tr( "Add branch above","Edit menu" ), this);
614 a->setStatusTip ( tr( "Add a branch above selection" ));
615 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
616 a->setShortcutContext (Qt::WindowShortcut);
618 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
619 a->setEnabled (false);
620 actionListBranches.append(a);
621 actionAddBranchAbove=a;
622 a = new QAction(tr( "Add branch above","Edit menu" ), this);
623 a->setStatusTip ( tr( "Add a branch above selection" ));
624 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
625 a->setShortcutContext (Qt::WindowShortcut);
627 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
628 actionListBranches.append(a);
631 a = new QAction(tr( "Add branch below","Edit menu" ), this);
632 a->setStatusTip ( tr( "Add a branch below selection" ));
633 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
634 a->setShortcutContext (Qt::WindowShortcut);
636 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
637 a->setEnabled (false);
638 actionListBranches.append(a);
639 actionAddBranchBelow=a;
640 a = new QAction(tr( "Add branch below","Edit menu" ), this);
641 a->setStatusTip ( tr( "Add a branch below selection" ));
642 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
643 a->setShortcutContext (Qt::WindowShortcut);
645 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
646 actionListBranches.append(a);
648 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
649 a->setStatusTip ( tr( "Move branch up" ) );
650 a->setShortcut (Qt::Key_PageUp ); // Move branch up
651 a->setEnabled (false);
653 editMenu->addAction (a);
654 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
657 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
658 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
659 a->setStatusTip (tr( "Move branch down" ) );
660 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
661 a->setEnabled (false);
663 editMenu->addAction (a);
666 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
667 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
668 a->setEnabled (true);
670 editMenu->addAction (a);
671 actionSortChildren=a;
673 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
674 alt->setShortcut ( Qt::Key_S ); // Scroll branch
675 alt->setStatusTip (tr( "Scroll branch" ));
676 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
677 #if defined(Q_OS_MACX)
678 actionToggleScroll=alt;
680 actionToggleScroll=a;
682 actionToggleScroll->setEnabled (false);
683 actionToggleScroll->setToggleAction(true);
684 tb->addAction (actionToggleScroll);
685 editMenu->addAction ( actionToggleScroll);
686 editMenu->addAction (actionToggleScroll);
689 actionListBranches.append(actionToggleScroll);
691 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
692 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
693 a->setStatusTip (tr( "Expand all branches" ));
694 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
696 actionExpandAll->setEnabled (false);
697 actionExpandAll->setToggleAction(false);
698 //tb->addAction (actionExpandAll);
699 editMenu->addAction ( actionExpandAll);
701 actionListBranches.append(actionExpandAll);
704 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
705 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
706 editMenu->addAction (a);
707 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
709 editMenu->addSeparator();
711 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
712 a->setStatusTip (tr( "Find" ) );
713 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
714 editMenu->addAction (a);
715 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
717 editMenu->addSeparator();
719 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
720 a->setShortcut (Qt::CTRL + Qt::Key_U );
721 a->setShortcut (tr( "Open URL" ));
724 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
727 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
728 a->setStatusTip (tr( "Open URL in new tab" ));
729 //a->setShortcut (Qt::CTRL+Qt::Key_U );
731 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
734 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
735 a->setStatusTip (tr( "Open all URLs in subtree" ));
737 actionListBranches.append(a);
738 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
739 actionOpenMultipleURLTabs=a;
741 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
742 a->setStatusTip ( tr( "Edit URL" ) );
743 a->setShortcut ( Qt::Key_U );
744 a->setShortcutContext (Qt::WindowShortcut);
745 actionListBranches.append(a);
747 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
750 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
751 a->setStatusTip ( tr( "Edit local URL" ) );
752 a->setShortcut (Qt::SHIFT + Qt::Key_U );
753 a->setShortcutContext (Qt::WindowShortcut);
754 actionListBranches.append(a);
756 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
759 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
760 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
761 a->setEnabled (false);
762 actionListBranches.append(a);
763 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
766 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
767 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
768 a->setEnabled (false);
769 actionListBranches.append(a);
770 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
771 actionBugzilla2URL=a;
773 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
774 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
775 a->setEnabled (false);
776 actionListBranches.append(a);
777 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
780 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
781 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
783 a->setEnabled (false);
784 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
787 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
788 a->setStatusTip ( tr( "Open all vym links in subtree" ));
789 a->setEnabled (false);
790 actionListBranches.append(a);
791 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
792 actionOpenMultipleVymLinks=a;
795 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
796 a->setEnabled (false);
797 a->setStatusTip ( tr( "Edit link to another vym map" ));
798 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
799 actionListBranches.append(a);
802 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
803 a->setStatusTip ( tr( "Delete link to another vym map" ));
804 a->setEnabled (false);
805 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
806 actionDeleteVymLink=a;
808 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
809 a->setStatusTip ( tr( "Hide object in exports" ) );
810 a->setShortcut (Qt::Key_H );
811 a->setToggleAction(true);
813 a->setEnabled (false);
814 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
815 actionToggleHideExport=a;
817 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
818 a->setStatusTip ( tr( "Edit Map Info" ));
819 a->setEnabled (true);
820 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
823 // Import at selection (adding to selection)
824 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
825 a->setStatusTip (tr( "Add map at selection" ));
826 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
827 a->setEnabled (false);
828 actionListBranches.append(a);
831 // Import at selection (replacing selection)
832 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
833 a->setStatusTip (tr( "Replace selection with map" ));
834 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
835 a->setEnabled (false);
836 actionListBranches.append(a);
837 actionImportReplace=a;
840 a = new QAction( tr( "Save selection","Edit menu" ), this);
841 a->setStatusTip (tr( "Save selection" ));
842 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
843 a->setEnabled (false);
844 actionListBranches.append(a);
847 // Only remove branch, not its children
848 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
849 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
850 a->setShortcut (Qt::ALT + Qt::Key_Delete );
851 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
852 a->setEnabled (false);
854 actionListBranches.append(a);
855 actionDeleteKeepChildren=a;
857 // Only remove children of a branch
858 a = new QAction( tr( "Remove children","Edit menu" ), this);
859 a->setStatusTip (tr( "Remove children of branch" ));
860 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
861 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
862 a->setEnabled (false);
863 actionListBranches.append(a);
864 actionDeleteChildren=a;
866 a = new QAction( tr( "Add Image...","Edit menu" ), this);
867 a->setStatusTip (tr( "Add Image" ));
868 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
871 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
872 a->setStatusTip (tr( "Set properties for selection" ));
873 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
874 a->setShortcutContext (Qt::WindowShortcut);
875 a->setToggleAction (true);
877 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
878 actionViewTogglePropertyWindow=a;
882 void Main::setupFormatActions()
884 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
886 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
887 tb->setObjectName ("formatTB");
890 pix.fill (Qt::black);
891 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
892 a->setStatusTip ( tr( "Set Color" ));
893 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
895 formatMenu->addAction (a);
897 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
898 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
899 a->setShortcut (Qt::CTRL + Qt::Key_K );
900 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
901 a->setEnabled (false);
903 formatMenu->addAction (a);
904 actionListBranches.append(a);
905 actionFormatPickColor=a;
907 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
908 a->setStatusTip ( tr( "Color branch" ) );
909 a->setShortcut (Qt::CTRL + Qt::Key_B);
910 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
911 a->setEnabled (false);
913 formatMenu->addAction (a);
914 actionListBranches.append(a);
915 actionFormatColorSubtree=a;
917 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
918 a->setStatusTip ( tr( "Color Subtree" ));
919 a->setShortcut (Qt::CTRL + Qt::Key_T);
920 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
921 a->setEnabled (false);
922 formatMenu->addAction (a);
924 actionListBranches.append(a);
925 actionFormatColorSubtree=a;
927 formatMenu->addSeparator();
928 actionGroupFormatLinkStyles=new QActionGroup ( this);
929 actionGroupFormatLinkStyles->setExclusive (true);
930 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
931 a->setStatusTip (tr( "Line" ));
932 a->setToggleAction(true);
933 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
934 formatMenu->addAction (a);
935 actionFormatLinkStyleLine=a;
936 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
937 a->setStatusTip (tr( "Line" ));
938 a->setToggleAction(true);
939 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
940 formatMenu->addAction (a);
941 actionFormatLinkStyleParabel=a;
942 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
943 a->setStatusTip (tr( "PolyLine" ));
944 a->setToggleAction(true);
945 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
946 formatMenu->addAction (a);
947 actionFormatLinkStylePolyLine=a;
948 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
949 a->setStatusTip (tr( "PolyParabel" ) );
950 a->setToggleAction(true);
951 a->setChecked (true);
952 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
953 formatMenu->addAction (a);
954 actionFormatLinkStylePolyParabel=a;
956 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
957 a->setStatusTip (tr( "Hide link" ));
958 a->setToggleAction(true);
959 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
960 actionFormatHideLinkUnselected=a;
962 formatMenu->addSeparator();
963 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
964 a->setStatusTip (tr( "Use same color for links and headings" ));
965 a->setToggleAction(true);
966 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
967 formatMenu->addAction (a);
968 actionFormatLinkColorHint=a;
970 pix.fill (Qt::white);
971 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
972 a->setStatusTip (tr( "Set Link Color" ));
973 formatMenu->addAction (a);
974 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
975 actionFormatLinkColor=a;
977 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
978 a->setStatusTip (tr( "Set Selection Color" ));
979 formatMenu->addAction (a);
980 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
981 actionFormatSelectionColor=a;
983 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
984 a->setStatusTip (tr( "Set Background Color" ));
985 formatMenu->addAction (a);
986 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
987 actionFormatBackColor=a;
989 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
990 a->setStatusTip (tr( "Set Background image" ));
991 formatMenu->addAction (a);
992 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
993 actionFormatBackImage=a;
997 void Main::setupViewActions()
999 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1000 tb->setLabel( "View Actions" );
1001 tb->setObjectName ("viewTB");
1002 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1005 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1006 a->setStatusTip ( tr( "Zoom reset" ) );
1007 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1009 viewMenu->addAction (a);
1010 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1012 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1013 a->setStatusTip (tr( "Zoom in" ));
1014 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1016 viewMenu->addAction (a);
1017 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1019 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1020 a->setStatusTip (tr( "Zoom out" ));
1021 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1023 viewMenu->addAction (a);
1024 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1026 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1027 a->setStatusTip (tr( "Show selection" ));
1028 a->setShortcut (Qt::Key_Period);
1030 viewMenu->addAction (a);
1031 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1033 viewMenu->addSeparator();
1035 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1036 a->setStatusTip ( tr( "Show Note Editor" ));
1037 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1038 a->setToggleAction(true);
1040 viewMenu->addAction (a);
1041 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1042 actionViewToggleNoteEditor=a;
1044 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1045 a->setStatusTip ( tr( "Show History Window" ));
1046 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1047 a->setToggleAction(true);
1049 viewMenu->addAction (a);
1050 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1051 actionViewToggleHistoryWindow=a;
1053 viewMenu->addAction (actionViewTogglePropertyWindow);
1055 viewMenu->addSeparator();
1057 a = new QAction(tr( "Antialiasing","View action" ),this );
1058 a->setStatusTip ( tr( "Antialiasing" ));
1059 a->setToggleAction(true);
1060 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1061 viewMenu->addAction (a);
1062 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1063 actionViewToggleAntiAlias=a;
1065 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1066 a->setStatusTip (a->text());
1067 a->setToggleAction(true);
1068 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1069 viewMenu->addAction (a);
1070 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1071 actionViewToggleSmoothPixmapTransform=a;
1073 a = new QAction(tr( "Next Map","View action" ), this);
1074 a->setStatusTip (a->text());
1075 a->setShortcut (Qt::ALT + Qt::Key_N );
1076 viewMenu->addAction (a);
1077 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1079 a = new QAction (tr( "Previous Map","View action" ), this );
1080 a->setStatusTip (a->text());
1081 a->setShortcut (Qt::ALT + Qt::Key_P );
1082 viewMenu->addAction (a);
1083 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1087 void Main::setupModeActions()
1089 //QPopupMenu *menu = new QPopupMenu( this );
1090 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1092 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1093 tb->setObjectName ("modesTB");
1095 actionGroupModModes=new QActionGroup ( this);
1096 actionGroupModModes->setExclusive (true);
1097 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1098 a->setShortcut (Qt::Key_J);
1099 a->setStatusTip ( tr( "Use modifier to color branches" ));
1100 a->setToggleAction(true);
1103 actionModModeColor=a;
1105 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1106 a->setShortcut( Qt::Key_K);
1107 a->setStatusTip( tr( "Use modifier to copy" ));
1108 a->setToggleAction(true);
1110 actionModModeCopy=a;
1112 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1113 a->setShortcut (Qt::Key_L);
1114 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1115 a->setToggleAction(true);
1117 actionModModeXLink=a;
1121 void Main::setupFlagActions()
1123 // Create System Flags
1126 Flag *flag=new Flag;;
1127 flag->setVisible(true);
1129 flag->load(QPixmap(flagsPath+"flag-note.png"));
1130 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1132 flag->load(QPixmap(flagsPath+"flag-url.png"));
1133 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1135 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1136 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1138 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1139 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1141 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1142 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1144 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1145 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1147 // Create Standard Flags
1148 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1149 tb->setObjectName ("standardFlagTB");
1150 standardFlagsMaster->setToolBar (tb);
1152 flag->load(flagsPath+"flag-exclamationmark.png");
1153 flag->setGroup("standard-mark");
1154 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1156 flag->load(flagsPath+"flag-questionmark.png");
1157 flag->setGroup("standard-mark");
1158 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1160 flag->load(flagsPath+"flag-hook-green.png");
1161 flag->setGroup("standard-hook");
1162 setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
1164 flag->load(flagsPath+"flag-cross-red.png");
1165 flag->setGroup("standard-hook");
1166 setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
1169 flag->load(flagsPath+"flag-stopsign.png");
1170 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1172 flag->load(flagsPath+"flag-smiley-good.png");
1173 flag->setGroup("standard-smiley");
1174 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1176 flag->load(flagsPath+"flag-smiley-sad.png");
1177 flag->setGroup("standard-smiley");
1178 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1180 flag->load(flagsPath+"flag-smiley-omg.png");
1181 flag->setGroup("standard-smiley");
1182 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1183 // Original omg.png (in KDE emoticons)
1186 flag->load(flagsPath+"flag-kalarm.png");
1187 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1189 flag->load(flagsPath+"flag-phone.png");
1190 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1192 flag->load(flagsPath+"flag-lamp.png");
1193 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1195 flag->load(flagsPath+"flag-arrow-up.png");
1196 flag->setGroup("standard-arrow");
1197 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1199 flag->load(flagsPath+"flag-arrow-down.png");
1200 flag->setGroup("standard-arrow");
1201 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1203 flag->load(flagsPath+"flag-arrow-2up.png");
1204 flag->setGroup("standard-arrow");
1205 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1207 flag->load(flagsPath+"flag-arrow-2down.png");
1208 flag->setGroup("standard-arrow");
1209 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1212 flag->load(flagsPath+"flag-thumb-up.png");
1213 flag->setGroup("standard-thumb");
1214 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1216 flag->load(flagsPath+"flag-thumb-down.png");
1217 flag->setGroup("standard-thumb");
1218 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1221 flag->load(flagsPath+"flag-rose.png");
1222 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1224 flag->load(flagsPath+"flag-heart.png");
1225 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1227 flag->load(flagsPath+"flag-present.png");
1228 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1230 flag->load(flagsPath+"flag-flash.png");
1231 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1233 // Original: xsldbg_output.png
1234 flag->load(flagsPath+"flag-info.png");
1235 setupFlag (flag,tb,"inflag",tr("Info","Standardflag"));
1237 // Original khelpcenter.png
1238 flag->load(flagsPath+"flag-lifebelt.png");
1239 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1242 flag->setVisible(false);
1243 flag->load(flagsPath+"freemind/warning.png");
1244 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1246 for (int i=1; i<8; i++)
1248 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1249 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1252 flag->load(flagsPath+"freemind/back.png");
1253 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1255 flag->load(flagsPath+"freemind/forward.png");
1256 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1258 flag->load(flagsPath+"freemind/attach.png");
1259 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1261 flag->load(flagsPath+"freemind/clanbomber.png");
1262 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1264 flag->load(flagsPath+"freemind/desktopnew.png");
1265 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1267 flag->load(flagsPath+"freemind/flag.png");
1268 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1271 flag->load(flagsPath+"freemind/gohome.png");
1272 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1275 flag->load(flagsPath+"freemind/kaddressbook.png");
1276 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1278 flag->load(flagsPath+"freemind/knotify.png");
1279 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1281 flag->load(flagsPath+"freemind/korn.png");
1282 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1284 flag->load(flagsPath+"freemind/mail.png");
1285 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1287 flag->load(flagsPath+"freemind/password.png");
1288 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1290 flag->load(flagsPath+"freemind/pencil.png");
1291 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1293 flag->load(flagsPath+"freemind/stop.png");
1294 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1296 flag->load(flagsPath+"freemind/wizard.png");
1297 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1299 flag->load(flagsPath+"freemind/xmag.png");
1300 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1302 flag->load(flagsPath+"freemind/bell.png");
1303 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1305 flag->load(flagsPath+"freemind/bookmark.png");
1306 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1308 flag->load(flagsPath+"freemind/penguin.png");
1309 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1311 flag->load(flagsPath+"freemind/licq.png");
1312 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1315 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1317 flag->setName(name);
1318 flag->setToolTip (tooltip);
1322 a=new QAction (flag->getPixmap(),name,this);
1325 flag->setAction (a);
1326 a->setVisible (flag->isVisible());
1327 a->setCheckable(true);
1328 a->setObjectName(name);
1329 a->setToolTip(tooltip);
1330 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1331 standardFlagsMaster->addFlag (flag);
1335 systemFlagsMaster->addFlag (flag);
1340 void Main::setupNetworkActions()
1342 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1344 QMenu *netMenu = menuBar()->addMenu( "Network" );
1348 a = new QAction( "Start TCPserver for MapEditor",this);
1349 //a->setStatusTip ( "Set application to open pdf files"));
1350 a->setShortcut ( Qt::Key_T ); //New TCP server
1351 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1352 netMenu->addAction (a);
1354 a = new QAction( "Connect MapEditor to server",this);
1355 //a->setStatusTip ( "Set application to open pdf files"));
1356 a->setShortcut ( Qt::Key_C ); // Connect to server
1357 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1358 netMenu->addAction (a);
1362 void Main::setupSettingsActions()
1364 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1368 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1369 a->setStatusTip ( tr( "Set application to open pdf files"));
1370 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1371 settingsMenu->addAction (a);
1373 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1374 a->setStatusTip( tr( "Set application to open external links"));
1375 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1376 settingsMenu->addAction (a);
1378 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1379 a->setStatusTip( tr( "Set path for macros"));
1380 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1381 settingsMenu->addAction (a);
1383 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1384 a->setStatusTip( tr( "Set number of undo levels"));
1385 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1386 settingsMenu->addAction (a);
1388 settingsMenu->addSeparator();
1390 a = new QAction( tr( "Autosave","Settings action"), this);
1391 a->setStatusTip( tr( "Autosave"));
1392 a->setToggleAction(true);
1393 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1394 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1395 settingsMenu->addAction (a);
1396 actionSettingsAutosaveToggle=a;
1398 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1399 a->setStatusTip( tr( "Autosave time"));
1400 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1401 settingsMenu->addAction (a);
1402 actionSettingsAutosaveTime=a;
1404 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1405 a->setStatusTip( tr( "Write backup file on save"));
1406 a->setToggleAction(true);
1407 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1408 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1409 settingsMenu->addAction (a);
1410 actionSettingsWriteBackupFile=a;
1412 settingsMenu->addSeparator();
1414 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1415 a->setStatusTip( tr( "Edit branch after adding it" ));
1416 a->setToggleAction(true);
1417 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1418 settingsMenu->addAction (a);
1419 actionSettingsAutoEditNewBranch=a;
1421 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1422 a->setStatusTip( tr( "Select branch after adding it" ));
1423 a->setToggleAction(true);
1424 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1425 settingsMenu->addAction (a);
1426 actionSettingsAutoSelectNewBranch=a;
1428 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1429 a->setStatusTip( tr( "Select heading before editing" ));
1430 a->setToggleAction(true);
1431 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1432 settingsMenu->addAction (a);
1433 actionSettingsAutoSelectText=a;
1435 a= new QAction( tr( "Delete key","Settings action" ), this);
1436 a->setStatusTip( tr( "Delete key for deleting branches" ));
1437 a->setToggleAction(true);
1438 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1439 settingsMenu->addAction (a);
1440 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1441 actionSettingsUseDelKey=a;
1443 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1444 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1445 a->setToggleAction(true);
1446 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1447 settingsMenu->addAction (a);
1448 actionSettingsUseFlagGroups=a;
1450 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1451 a->setStatusTip( tr( "Use hide flag during exports " ));
1452 a->setToggleAction(true);
1453 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1454 settingsMenu->addAction (a);
1455 actionSettingsUseHideExport=a;
1457 a = new QAction( tr( "Animation","Settings action"), this);
1458 a->setStatusTip( tr( "Animation"));
1459 a->setToggleAction(true);
1460 a->setOn (settings.value("/animation/use",false).toBool() );
1461 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1462 settingsMenu->addAction (a);
1463 actionSettingsUseAnimation=a;
1467 void Main::setupTestActions()
1469 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1472 a = new QAction( "Test function 1" , this);
1473 a->setStatusTip( "Call test function 1" );
1474 testMenu->addAction (a);
1475 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1477 a = new QAction( "Test function 2" , this);
1478 a->setStatusTip( "Call test function 2" );
1479 testMenu->addAction (a);
1480 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1482 a = new QAction( "Command" , this);
1483 a->setStatusTip( "Enter command to call in editor" );
1484 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1485 testMenu->addAction (a);
1489 void Main::setupHelpActions()
1491 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1494 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1495 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1496 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1497 helpMenu->addAction (a);
1499 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1500 a->setStatusTip( tr( "Open VYM example maps " ));
1501 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1502 helpMenu->addAction (a);
1504 a = new QAction( tr( "About VYM","Help action" ), this);
1505 a->setStatusTip( tr( "About VYM")+vymName);
1506 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1507 helpMenu->addAction (a);
1509 a = new QAction( tr( "About QT","Help action" ), this);
1510 a->setStatusTip( tr( "Information about QT toolkit" ));
1511 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1512 helpMenu->addAction (a);
1516 void Main::setupContextMenus()
1520 // Context Menu for branch or mapcenter
1521 branchContextMenu =new QMenu (this);
1522 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1523 branchContextMenu->addSeparator();
1526 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1527 branchAddContextMenu->addAction (actionPaste );
1528 branchAddContextMenu->addAction ( actionAddMapCenter );
1529 branchAddContextMenu->addAction ( actionAddBranch );
1530 branchAddContextMenu->addAction ( actionAddBranchBefore );
1531 branchAddContextMenu->addAction ( actionAddBranchAbove);
1532 branchAddContextMenu->addAction ( actionAddBranchBelow );
1533 branchAddContextMenu->addSeparator();
1534 branchAddContextMenu->addAction ( actionImportAdd );
1535 branchAddContextMenu->addAction ( actionImportReplace );
1538 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1539 branchRemoveContextMenu->addAction (actionCut);
1540 branchRemoveContextMenu->addAction ( actionDelete );
1541 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1542 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1545 actionSaveBranch->addTo( branchContextMenu );
1546 actionFileNewCopy->addTo (branchContextMenu );
1548 branchContextMenu->addSeparator();
1549 branchContextMenu->addAction ( actionLoadImage);
1551 // Submenu for Links (URLs, vymLinks)
1552 branchLinksContextMenu =new QMenu (this);
1554 branchContextMenu->addSeparator();
1555 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1556 branchLinksContextMenu->addAction ( actionOpenURL );
1557 branchLinksContextMenu->addAction ( actionOpenURLTab );
1558 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1559 branchLinksContextMenu->addAction ( actionURL );
1560 branchLinksContextMenu->addAction ( actionLocalURL );
1561 branchLinksContextMenu->addAction ( actionHeading2URL );
1562 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1563 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1565 branchLinksContextMenu->addAction ( actionFATE2URL );
1567 branchLinksContextMenu->addSeparator();
1568 branchLinksContextMenu->addAction ( actionOpenVymLink );
1569 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1570 branchLinksContextMenu->addAction ( actionVymLink );
1571 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1574 // Context Menu for XLinks in a branch menu
1575 // This will be populated "on demand" in MapEditor::updateActions
1576 branchContextMenu->addSeparator();
1577 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1578 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1579 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1580 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1583 // Context menu for floatimage
1584 floatimageContextMenu =new QMenu (this);
1585 a= new QAction (tr ("Save image","Context action"),this);
1586 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1587 floatimageContextMenu->addAction (a);
1589 floatimageContextMenu->addSeparator();
1590 actionCopy->addTo( floatimageContextMenu );
1591 actionCut->addTo( floatimageContextMenu );
1593 floatimageContextMenu->addSeparator();
1594 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1597 // Context menu for canvas
1598 canvasContextMenu =new QMenu (this);
1599 actionAddMapCenter->addTo( canvasContextMenu );
1600 actionMapInfo->addTo( canvasContextMenu );
1601 canvasContextMenu->insertSeparator();
1602 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1603 canvasContextMenu->insertSeparator();
1604 actionFormatLinkColorHint->addTo( canvasContextMenu );
1605 actionFormatLinkColor->addTo( canvasContextMenu );
1606 actionFormatSelectionColor->addTo( canvasContextMenu );
1607 actionFormatBackColor->addTo( canvasContextMenu );
1608 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1610 // Menu for last opened files
1612 for (int i = 0; i < MaxRecentFiles; ++i)
1614 recentFileActions[i] = new QAction(this);
1615 recentFileActions[i]->setVisible(false);
1616 fileLastMapsMenu->addAction(recentFileActions[i]);
1617 connect(recentFileActions[i], SIGNAL(triggered()),
1618 this, SLOT(fileLoadRecent()));
1620 setupRecentMapsMenu();
1623 void Main::setupRecentMapsMenu()
1625 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1627 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1629 for (int i = 0; i < numRecentFiles; ++i) {
1630 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1631 recentFileActions[i]->setText(text);
1632 recentFileActions[i]->setData(files[i]);
1633 recentFileActions[i]->setVisible(true);
1635 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1636 recentFileActions[j]->setVisible(false);
1639 void Main::setupMacros()
1641 for (int i = 0; i <= 11; i++)
1643 macroActions[i] = new QAction(this);
1644 macroActions[i]->setData(i);
1645 addAction (macroActions[i]);
1646 connect(macroActions[i], SIGNAL(triggered()),
1647 this, SLOT(callMacro()));
1649 macroActions[0]->setShortcut ( Qt::Key_F1 );
1650 macroActions[1]->setShortcut ( Qt::Key_F2 );
1651 macroActions[2]->setShortcut ( Qt::Key_F3 );
1652 macroActions[3]->setShortcut ( Qt::Key_F4 );
1653 macroActions[4]->setShortcut ( Qt::Key_F5 );
1654 macroActions[5]->setShortcut ( Qt::Key_F6 );
1655 macroActions[6]->setShortcut ( Qt::Key_F7 );
1656 macroActions[7]->setShortcut ( Qt::Key_F8 );
1657 macroActions[8]->setShortcut ( Qt::Key_F9 );
1658 macroActions[9]->setShortcut ( Qt::Key_F10 );
1659 macroActions[10]->setShortcut ( Qt::Key_F11 );
1660 macroActions[11]->setShortcut ( Qt::Key_F12 );
1663 void Main::hideEvent (QHideEvent * )
1665 if (!textEditor->isMinimized() ) textEditor->hide();
1668 void Main::showEvent (QShowEvent * )
1670 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1674 MapEditor* Main::currentMapEditor() const
1676 if ( tabWidget->currentPage())
1677 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1681 VymModel* Main::currentModel() const
1683 if ( tabWidget->currentPage())
1684 return vymViews.at(tabWidget->currentIndex())->getModel();
1689 void Main::editorChanged(QWidget *)
1691 // Unselect all possibly selected objects
1692 // (Important to update note editor)
1694 for (int i=0;i<=tabWidget->count() -1;i++)
1696 m= vymViews.at(tabWidget->currentIndex())->getModel();
1697 if (m) m->unselect();
1700 if (m) m->reselect();
1702 // Update actions to in menus and toolbars according to editor
1706 void Main::fileNew()
1708 VymModel *vm=new VymModel;
1710 VymView *vv=new VymView (vm);
1711 vymViews.append (vv);
1712 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1713 tabWidget->setCurrentIndex (vymViews.count() );
1717 // For the very first map we do not have flagrows yet...
1721 void Main::fileNewCopy()
1723 QString fn="unnamed";
1724 VymModel *srcModel=currentModel();
1729 VymModel *dstModel=vymViews.last()->getModel();
1730 dstModel->select("mc:");
1731 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1735 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1737 ErrorCode err=success;
1739 // fn is usually the archive, mapfile the file after uncompressing
1742 // Make fn absolute (needed for unzip)
1743 fn=QDir (fn).absPath();
1749 // Check, if map is already loaded
1751 while (i<=tabWidget->count() -1)
1753 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1755 // Already there, ask for confirmation
1756 QMessageBox mb( vymName,
1757 tr("The map %1\nis already opened."
1758 "Opening the same map in multiple editors may lead \n"
1759 "to confusion when finishing working with vym."
1760 "Do you want to").arg(fn),
1761 QMessageBox::Warning,
1762 QMessageBox::Yes | QMessageBox::Default,
1763 QMessageBox::Cancel | QMessageBox::Escape,
1764 QMessageBox::NoButton);
1765 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1766 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1769 case QMessageBox::Yes:
1770 // end loop and load anyway
1771 i=tabWidget->count();
1773 case QMessageBox::Cancel:
1783 int tabIndex=tabWidget->currentPageIndex();
1786 if ( !fn.isEmpty() )
1788 vm = currentModel();
1789 // Check first, if mapeditor exists
1790 // If it is not default AND we want a new map,
1791 // create a new mapeditor in a new tab
1792 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1795 VymView *vv=new VymView (vm);
1796 vymViews.append (vv);
1797 tabWidget->addTab (vv,fn);
1798 tabIndex=tabWidget->count()-1;
1799 tabWidget->setCurrentPage (tabIndex);
1803 // Check, if file exists (important for creating new files
1804 // from command line
1805 if (!QFile(fn).exists() )
1807 QMessageBox mb( vymName,
1808 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1809 QMessageBox::Question,
1811 QMessageBox::Cancel | QMessageBox::Default,
1812 QMessageBox::NoButton );
1814 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1815 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1818 case QMessageBox::Yes:
1820 currentMapEditor()->getModel()->setFilePath(fn);
1821 tabWidget->setTabText (tabIndex,
1822 currentMapEditor()->getModel()->getFileName() );
1823 statusBar()->message( "Created " + fn , statusbarTime );
1826 case QMessageBox::Cancel:
1827 // don't create new map
1828 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1835 //tabWidget->currentPage() won't be NULL here, because of above...
1836 tabWidget->setCurrentIndex (tabIndex);
1837 //FIXME-3 no me anymore... me->viewport()->setFocus();
1841 // Save existing filename in case we import
1842 QString fn_org=vm->getFilePath();
1844 // Finally load map into mapEditor
1845 vm->setFilePath (fn);
1846 err=vm->load(fn,lmode,ftype);
1848 // Restore old (maybe empty) filepath, if this is an import
1850 vm->setFilePath (fn_org);
1853 // Finally check for errors and go home
1856 if (lmode==NewMap) fileCloseMap();
1857 statusBar()->message( "Could not load " + fn, statusbarTime );
1862 vm->setFilePath (fn);
1863 tabWidget->setTabText (tabIndex, vm->getFileName());
1864 if (!isInTmpDir (fn))
1866 // Only append to lastMaps if not loaded from a tmpDir
1867 // e.g. imported bookmarks are in a tmpDir
1868 addRecentMap(vm->getFilePath() );
1870 actionFilePrint->setEnabled (true);
1872 statusBar()->message( "Loaded " + fn, statusbarTime );
1879 void Main::fileLoad(const LoadMode &lmode)
1881 QStringList filters;
1882 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1883 QFileDialog *fd=new QFileDialog( this);
1884 fd->setDir (lastFileDir);
1885 fd->setFileMode (QFileDialog::ExistingFiles);
1886 fd->setFilters (filters);
1890 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1893 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1896 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1902 if ( fd->exec() == QDialog::Accepted )
1904 lastFileDir=fd->directory().path();
1905 QStringList flist = fd->selectedFiles();
1906 QStringList::Iterator it = flist.begin();
1907 while( it != flist.end() )
1910 fileLoad(*it, lmode);
1917 void Main::fileLoad()
1922 void Main::fileLoadRecent()
1924 QAction *action = qobject_cast<QAction *>(sender());
1926 fileLoad (action->data().toString(), NewMap);
1929 void Main::addRecentMap (const QString &fileName)
1932 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1933 files.removeAll(fileName);
1934 files.prepend(fileName);
1935 while (files.size() > MaxRecentFiles)
1938 settings.setValue("/mainwindow/recentFileList", files);
1940 setupRecentMapsMenu();
1943 void Main::fileSave(VymModel *m, const SaveMode &savemode)
1947 if ( m->getFilePath().isEmpty() )
1949 // We have no filepath yet,
1950 // call fileSaveAs() now, this will call fileSave()
1952 // First switch to editor
1953 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
1954 fileSaveAs(savemode);
1957 if (m->save (savemode)==success)
1959 statusBar()->message(
1960 tr("Saved %1").arg(m->getFilePath()),
1962 addRecentMap (m->getFilePath() );
1964 statusBar()->message(
1965 tr("Couldn't save ").arg(m->getFilePath()),
1969 void Main::fileSave()
1971 fileSave (currentModel(), CompleteMap);
1974 void Main::fileSave(VymModel *m)
1976 fileSave (m,CompleteMap);
1979 void Main::fileSaveAs(const SaveMode& savemode)
1983 if (currentMapEditor())
1985 if (savemode==CompleteMap)
1986 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1988 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1989 if ( !fn.isEmpty() )
1991 // Check for existing file
1992 if (QFile (fn).exists())
1994 QMessageBox mb( vymName,
1995 tr("The file %1\nexists already. Do you want to").arg(fn),
1996 QMessageBox::Warning,
1997 QMessageBox::Yes | QMessageBox::Default,
1998 QMessageBox::Cancel | QMessageBox::Escape,
1999 QMessageBox::NoButton);
2000 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2001 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2004 case QMessageBox::Yes:
2007 case QMessageBox::Cancel:
2014 // New file, add extension to filename, if missing
2015 // This is always .vym or .vyp, depending on savemode
2016 if (savemode==CompleteMap)
2018 if (!fn.contains (".vym") && !fn.contains (".xml"))
2022 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2031 VymModel *m=currentModel();
2033 fileSave(m, savemode);
2035 // Set name of tab, assuming current tab is the one we just saved
2036 if (savemode==CompleteMap)
2037 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2043 void Main::fileSaveAs()
2045 fileSaveAs (CompleteMap);
2048 void Main::fileImportKDE3Bookmarks()
2050 ImportKDE3Bookmarks im;
2052 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2053 currentMapEditor()->getModel()->setFilePath ("");
2056 void Main::fileImportKDE4Bookmarks()
2058 ImportKDE4Bookmarks im;
2060 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2061 currentMapEditor()->getModel()->setFilePath ("");
2064 void Main::fileImportFirefoxBookmarks()
2066 Q3FileDialog *fd=new Q3FileDialog( this);
2067 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2068 fd->setMode (Q3FileDialog::ExistingFiles);
2069 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2070 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2073 if ( fd->exec() == QDialog::Accepted )
2075 ImportFirefoxBookmarks im;
2076 QStringList flist = fd->selectedFiles();
2077 QStringList::Iterator it = flist.begin();
2078 while( it != flist.end() )
2081 if (im.transform() &&
2082 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2083 currentMapEditor() )
2084 currentMapEditor()->getModel()->setFilePath ("");
2091 void Main::fileImportFreemind()
2093 QStringList filters;
2094 filters <<"Freemind map (*.mm)"<<"All files (*)";
2095 QFileDialog *fd=new QFileDialog( this);
2096 fd->setDir (lastFileDir);
2097 fd->setFileMode (QFileDialog::ExistingFiles);
2098 fd->setFilters (filters);
2099 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2103 if ( fd->exec() == QDialog::Accepted )
2105 lastFileDir=fd->directory().path();
2106 QStringList flist = fd->selectedFiles();
2107 QStringList::Iterator it = flist.begin();
2108 while( it != flist.end() )
2111 if ( fileLoad (fn,NewMap, FreemindMap) )
2113 currentMapEditor()->getModel()->setFilePath ("");
2122 void Main::fileImportMM()
2126 Q3FileDialog *fd=new Q3FileDialog( this);
2127 fd->setDir (lastFileDir);
2128 fd->setMode (Q3FileDialog::ExistingFiles);
2129 fd->addFilter ("Mind Manager (*.mmap)");
2130 fd->setCaption(tr("Import")+" "+"Mind Manager");
2133 if ( fd->exec() == QDialog::Accepted )
2135 lastFileDir=fd->dirPath();
2136 QStringList flist = fd->selectedFiles();
2137 QStringList::Iterator it = flist.begin();
2138 while( it != flist.end() )
2141 if (im.transform() &&
2142 success==fileLoad (im.getTransformedFile(),NewMap) &&
2143 currentMapEditor() )
2144 currentMapEditor()->getModel()->setFilePath ("");
2151 void Main::fileImportDir()
2153 VymModel *m=currentModel();
2154 if (m) m->importDir();
2157 void Main::fileExportXML()
2159 VymModel *m=currentModel();
2160 if (m) m->exportXML();
2164 void Main::fileExportXHTML()
2166 VymModel *m=currentModel();
2167 if (m) m->exportXHTML();
2170 void Main::fileExportImage()
2172 VymModel *m=currentModel();
2173 if (m) m->exportImage();
2176 void Main::fileExportASCII()
2178 VymModel *m=currentModel();
2179 if (m) m->exportASCII();
2182 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2184 VymModel *m=currentModel();
2189 ex.addFilter ("CSV (*.csv)");
2190 ex.setDir(lastImageDir);
2191 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2192 if (ex.execDialog() )
2194 m->setExportMode(true);
2196 m->setExportMode(false);
2201 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2203 VymModel *m=currentModel();
2208 ex.addFilter ("Tex (*.tex)");
2209 ex.setDir(lastImageDir);
2210 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2211 if (ex.execDialog() )
2213 m->setExportMode(true);
2215 m->setExportMode(false);
2220 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2222 ExportKDE3Bookmarks ex;
2223 VymModel *m=currentModel();
2231 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2233 ExportKDE4Bookmarks ex;
2234 VymModel *m=currentModel();
2242 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2244 ExportTaskjuggler ex;
2245 VymModel *m=currentModel();
2249 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2250 ex.setDir(lastImageDir);
2251 ex.addFilter ("Taskjuggler (*.tjp)");
2252 if (ex.execDialog() )
2254 m->setExportMode(true);
2256 m->setExportMode(false);
2261 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2263 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2264 // TODO add preview in dialog
2265 //ImagePreview *p =new ImagePreview (fd);
2266 //fd->setContentsPreviewEnabled( TRUE );
2267 //fd->setContentsPreview( p, p );
2268 //fd->setPreviewMode( QFileDialog::Contents );
2269 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2270 fd->setDir (QDir().current());
2271 if (fd->foundConfig())
2275 if ( fd->exec() == QDialog::Accepted )
2277 QString fn=fd->selectedFile();
2278 if (!fn.contains (".odp"))
2281 //lastImageDir=fn.left(fn.findRev ("/"));
2282 VymModel *m=currentModel();
2283 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2287 QMessageBox::warning(0,
2289 tr("Couldn't find configuration for export to Open Office\n"));
2293 void Main::fileCloseMap()
2295 VymModel *m=currentModel();
2298 if (m->hasChanged())
2300 QMessageBox mb( vymName,
2301 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2302 QMessageBox::Warning,
2303 QMessageBox::Yes | QMessageBox::Default,
2305 QMessageBox::Cancel | QMessageBox::Escape );
2306 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2307 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2310 case QMessageBox::Yes:
2312 fileSave(m, CompleteMap);
2314 case QMessageBox::No:
2315 // close without saving
2317 case QMessageBox::Cancel:
2322 // And here comes the segfault, because removeTab triggers
2323 // currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2324 vymViews.removeAt (tabWidget->currentIndex() );
2325 tabWidget->removeTab (tabWidget->currentIndex() );
2327 // Remove mapEditor/model FIXME-5
2328 // Better would be delete (me), but then we could have a Qt error:
2329 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2330 // So we only remove data now and call deconstructor when vym closes later
2331 // this needs to be moved to vymview... me->clear();
2332 // some model->clear is needed to free up memory ...
2338 void Main::filePrint()
2340 if (currentMapEditor())
2341 currentMapEditor()->print();
2344 void Main::fileExitVYM()
2346 // Check if one or more editors have changed
2348 for (i=0;i<=vymViews.count() -1;i++)
2350 // If something changed, ask what to do
2351 if (vymViews.at(i)->getModel()->hasChanged())
2353 tabWidget->setCurrentPage(i);
2354 QMessageBox mb( vymName,
2355 tr("This map is not saved yet. Do you want to"),
2356 QMessageBox::Warning,
2357 QMessageBox::Yes | QMessageBox::Default,
2359 QMessageBox::Cancel | QMessageBox::Escape );
2360 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2361 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2364 mb.setActiveWindow();
2365 switch( mb.exec() ) {
2366 case QMessageBox::Yes:
2367 // save (the changed editors) and exit
2368 fileSave(currentModel(), CompleteMap);
2370 case QMessageBox::No:
2371 // exit without saving
2373 case QMessageBox::Cancel:
2374 // don't save and don't exit
2378 } // loop over all MEs
2382 void Main::editUndo()
2384 VymModel *m=currentModel();
2388 void Main::editRedo()
2390 VymModel *m=currentModel();
2394 void Main::gotoHistoryStep (int i)
2396 VymModel *m=currentModel();
2397 if (m) m->gotoHistoryStep(i);
2400 void Main::editCopy()
2402 VymModel *m=currentModel();
2406 void Main::editPaste()
2408 VymModel *m=currentModel();
2412 void Main::editCut()
2414 VymModel *m=currentModel();
2418 void Main::editOpenFindWindow()
2420 findWindow->popup();
2421 findWindow->raise();
2422 findWindow->setActiveWindow();
2425 void Main::editFind(QString s)
2427 VymModel *m=currentModel();
2431 BranchItem *bi=m->findText(s, cs);
2434 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2437 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2438 tr("No matches found for \"%1\"").arg(s));
2443 void Main::editFindChanged()
2444 { // Notify editor, to abort the current find process
2445 VymModel *m=currentModel();
2446 if (m) m->findReset();
2449 void Main::openTabs(QStringList urls)
2451 if (!urls.isEmpty())
2455 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2457 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2459 QString u=urls.takeFirst();
2460 procBrowser = new QProcess( this );
2462 procBrowser->start(browser,args);
2463 if ( !procBrowser->waitForStarted())
2465 // try to set path to browser
2466 QMessageBox::warning(0,
2468 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2469 tr("Please use Settings->")+tr("Set application to open an URL"));
2472 #if defined(Q_OS_WIN32)
2473 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2474 this->thread()->wait(3000);
2479 if (browser.contains("konqueror"))
2481 for (int i=0; i<urls.size(); i++)
2484 // Try to open new tab in existing konqueror started previously by vym
2485 p=new QProcess (this);
2487 #if defined(Q_OS_WIN32)
2488 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2489 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2490 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2491 "konqueror-mainwindow#1"<<
2495 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2496 "konqueror-mainwindow#1"<<
2500 p->start ("dcop",args);
2501 if (debug) cout << "MainWindo::openURLs args="<<args.join(" ").toStdString()<<endl;
2502 if ( !p->waitForStarted() ) success=false;
2505 QMessageBox::warning(0,
2507 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2509 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2511 for (int i=0; i<urls.size(); i++)
2513 // Try to open new tab in firefox
2514 p=new QProcess (this);
2515 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2516 p->start (browser,args);
2517 if ( !p->waitForStarted() ) success=false;
2520 QMessageBox::warning(0,
2522 tr("Couldn't start %1 to open a new tab").arg(browser));
2525 QMessageBox::warning(0,
2527 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2531 void Main::editOpenURL()
2534 VymModel *m=currentModel();
2537 QString url=m->getURL();
2539 if (url=="") return;
2540 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2541 procBrowser = new QProcess( this );
2543 procBrowser->start(browser,args);
2544 if ( !procBrowser->waitForStarted())
2546 // try to set path to browser
2547 QMessageBox::warning(0,
2549 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2550 tr("Please use Settings->")+tr("Set application to open an URL"));
2555 void Main::editOpenURLTab()
2557 VymModel *m=currentModel();
2561 urls.append(m->getURL());
2565 void Main::editOpenMultipleURLTabs()
2567 VymModel *m=currentModel();
2577 void Main::editURL()
2579 VymModel *m=currentModel();
2580 if (m) m->editURL();
2583 void Main::editLocalURL()
2585 VymModel *m=currentModel();
2586 if (m) m->editLocalURL();
2589 void Main::editHeading2URL()
2591 VymModel *m=currentModel();
2592 if (m) m->editHeading2URL();
2595 void Main::editBugzilla2URL()
2597 VymModel *m=currentModel();
2598 if (m) m->editBugzilla2URL();
2601 void Main::editFATE2URL()
2603 VymModel *m=currentModel();
2604 if (m) m->editFATE2URL();
2607 void Main::editHeadingFinished(VymModel *m)
2611 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2612 !prevSelection.isEmpty())
2613 m->select(prevSelection);
2618 void Main::openVymLinks(const QStringList &vl)
2620 for (int j=0; j<vl.size(); j++)
2622 // compare path with already loaded maps
2625 for (i=0;i<=vymViews.count() -1;i++)
2627 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2636 if (!QFile(vl.at(j)).exists() )
2637 QMessageBox::critical( 0, tr( "Critical Error" ),
2638 tr("Couldn't open map %1").arg(vl.at(j)));
2641 fileLoad (vl.at(j), NewMap);
2642 tabWidget->setCurrentIndex (tabWidget->count()-1);
2645 // Go to tab containing the map
2646 tabWidget->setCurrentIndex (index);
2650 void Main::editOpenVymLink()
2652 VymModel *m=currentModel();
2656 vl.append(m->getVymLink());
2661 void Main::editOpenMultipleVymLinks()
2663 QString currentVymLink;
2664 VymModel *m=currentModel();
2667 QStringList vl=m->getVymLinks();
2672 void Main::editVymLink()
2674 VymModel *m=currentModel();
2679 void Main::editDeleteVymLink()
2681 VymModel *m=currentModel();
2682 if (m) m->deleteVymLink();
2685 void Main::editToggleHideExport()
2687 VymModel *m=currentModel();
2688 if (m) m->toggleHideExport();
2691 void Main::editMapInfo()
2693 VymModel *m=currentModel();
2695 ExtraInfoDialog dia;
2696 dia.setMapName (m->getFileName() );
2697 dia.setAuthor (m->getAuthor() );
2698 dia.setComment(m->getComment() );
2702 /* FIXME-2 no stats at the moment (view dependent...)
2703 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2713 if (!bo->getNote().isEmpty() ) n++;
2714 f+= bo->countFloatImages();
2716 xl+=bo->countXLinks();
2719 stats+=QString ("%1 xLinks \n").arg (xl,6);
2720 stats+=QString ("%1 notes\n").arg (n,6);
2721 stats+=QString ("%1 images\n").arg (f,6);
2723 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2724 dia.setStats (stats);
2726 // Finally show dialog
2727 if (dia.exec() == QDialog::Accepted)
2729 m->setAuthor (dia.getAuthor() );
2730 m->setComment (dia.getComment() );
2734 void Main::editMoveUp()
2736 VymModel *m=currentModel();
2740 void Main::editMoveDown()
2742 VymModel *m=currentModel();
2743 if (m) m->moveDown();
2746 void Main::editSortChildren()
2748 VymModel *m=currentModel();
2749 if (m) m->sortChildren();
2752 void Main::editToggleScroll()
2754 VymModel *m=currentModel();
2755 if (m) m->toggleScroll();
2758 void Main::editExpandAll()
2760 VymModel *m=currentModel();
2761 if (m) m->emitExpandAll();
2764 void Main::editUnscrollChildren()
2766 VymModel *m=currentModel();
2767 if (m) m->unscrollChildren();
2770 void Main::editAddMapCenter()
2772 VymModel *m=currentModel();
2773 if (m) m->addMapCenter ();
2776 void Main::editNewBranch()
2778 VymModel *m=currentModel();
2781 BranchItem *bi=m->addNewBranch();
2784 if (actionSettingsAutoEditNewBranch->isOn()
2785 && !actionSettingsAutoSelectNewBranch->isOn() )
2786 prevSelection=m->getSelectString();
2788 prevSelection=QString();
2790 if (actionSettingsAutoSelectNewBranch->isOn()
2791 || actionSettingsAutoEditNewBranch->isOn())
2794 if (actionSettingsAutoEditNewBranch->isOn())
2795 currentMapEditor()->editHeading();
2800 void Main::editNewBranchBefore()
2802 VymModel *m=currentModel();
2805 BranchItem *bi=m->addNewBranchBefore();
2812 if (actionSettingsAutoEditNewBranch->isOn())
2814 if (!actionSettingsAutoSelectNewBranch->isOn())
2815 prevSelection=m->getSelectString(bi);
2816 currentMapEditor()->editHeading();
2821 void Main::editNewBranchAbove()
2823 VymModel *m=currentModel();
2826 BranchItem *bi=m->addNewBranch (-1);
2834 if (actionSettingsAutoEditNewBranch->isOn())
2836 if (!actionSettingsAutoSelectNewBranch->isOn())
2837 prevSelection=m->getSelectString (bi);
2838 currentMapEditor()->editHeading();
2843 void Main::editNewBranchBelow()
2845 VymModel *m=currentModel();
2848 BranchItem *bi=m->addNewBranch (1);
2855 if (actionSettingsAutoEditNewBranch->isOn())
2857 if (!actionSettingsAutoSelectNewBranch->isOn())
2858 prevSelection=m->getSelectString(bi);
2859 currentMapEditor()->editHeading();
2864 void Main::editImportAdd()
2866 fileLoad (ImportAdd);
2869 void Main::editImportReplace()
2871 fileLoad (ImportReplace);
2874 void Main::editSaveBranch()
2876 fileSaveAs (PartOfMap);
2879 void Main::editDeleteKeepChildren()
2881 VymModel *m=currentModel();
2882 if (m) m->deleteKeepChildren();
2885 void Main::editDeleteChildren()
2887 VymModel *m=currentModel();
2888 if (m) m->deleteChildren();
2891 void Main::editDeleteSelection()
2893 VymModel *m=currentModel();
2894 if (m && actionSettingsUseDelKey->isOn())
2895 m->deleteSelection();
2898 void Main::editLoadImage()
2900 VymModel *m=currentModel();
2901 if (m) m->loadFloatImage();
2904 void Main::editSaveImage()
2906 VymModel *m=currentModel();
2907 if (m) m->saveFloatImage();
2910 void Main::editFollowXLink(QAction *a)
2913 VymModel *m=currentModel();
2915 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2918 void Main::editEditXLink(QAction *a)
2920 VymModel *m=currentModel();
2922 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2925 void Main::formatSelectColor()
2927 QColor col = QColorDialog::getColor((currentColor ), this );
2928 if ( !col.isValid() ) return;
2929 colorChanged( col );
2932 void Main::formatPickColor()
2934 VymModel *m=currentModel();
2936 colorChanged( m->getCurrentHeadingColor() );
2939 void Main::colorChanged(QColor c)
2941 QPixmap pix( 16, 16 );
2943 actionFormatColor->setIconSet( pix );
2947 void Main::formatColorBranch()
2949 VymModel *m=currentModel();
2950 if (m) m->colorBranch(currentColor);
2953 void Main::formatColorSubtree()
2955 VymModel *m=currentModel();
2956 if (m) m->colorSubtree (currentColor);
2959 void Main::formatLinkStyleLine()
2961 VymModel *m=currentModel();
2964 m->setMapLinkStyle("StyleLine");
2965 actionFormatLinkStyleLine->setOn(true);
2969 void Main::formatLinkStyleParabel()
2971 VymModel *m=currentModel();
2974 m->setMapLinkStyle("StyleParabel");
2975 actionFormatLinkStyleParabel->setOn(true);
2979 void Main::formatLinkStylePolyLine()
2981 VymModel *m=currentModel();
2984 m->setMapLinkStyle("StylePolyLine");
2985 actionFormatLinkStylePolyLine->setOn(true);
2989 void Main::formatLinkStylePolyParabel()
2991 VymModel *m=currentModel();
2994 m->setMapLinkStyle("StylePolyParabel");
2995 actionFormatLinkStylePolyParabel->setOn(true);
2999 void Main::formatSelectBackColor()
3001 VymModel *m=currentModel();
3002 if (m) m->selectMapBackgroundColor();
3005 void Main::formatSelectBackImage()
3007 VymModel *m=currentModel();
3009 m->selectMapBackgroundImage();
3012 void Main::formatSelectLinkColor()
3014 VymModel *m=currentModel();
3017 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3018 m->setMapDefLinkColor( col );
3022 void Main::formatSelectSelectionColor()
3024 VymModel *m=currentModel();
3027 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3028 m->setSelectionColor (col);
3033 void Main::formatToggleLinkColorHint()
3035 VymModel *m=currentModel();
3036 if (m) m->toggleMapLinkColorHint();
3040 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3042 VymModel *m=currentModel();
3044 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3047 void Main::viewZoomReset()
3049 MapEditor *me=currentMapEditor();
3050 if (me) me->setZoomFactorTarget (1);
3053 void Main::viewZoomIn()
3055 MapEditor *me=currentMapEditor();
3056 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3059 void Main::viewZoomOut()
3061 MapEditor *me=currentMapEditor();
3062 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3065 void Main::viewCenter()
3067 VymModel *m=currentModel();
3068 if (m) m->emitShowSelection();
3071 void Main::networkStartServer()
3073 VymModel *m=currentModel();
3074 if (m) m->newServer();
3077 void Main::networkConnect()
3079 VymModel *m=currentModel();
3080 if (m) m->connectToServer();
3083 bool Main::settingsPDF()
3085 // Default browser is set in constructor
3087 QString text = QInputDialog::getText(
3088 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3089 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3091 settings.setValue ("/mainwindow/readerPDF",text);
3096 bool Main::settingsURL()
3098 // Default browser is set in constructor
3100 QString text = QInputDialog::getText(
3101 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3102 settings.value("/mainwindow/readerURL").toString()
3105 settings.setValue ("/mainwindow/readerURL",text);
3109 void Main::settingsMacroDir()
3111 QDir defdir(vymBaseDir.path() + "/macros");
3112 if (!defdir.exists())
3114 QDir dir=QFileDialog::getExistingDirectory (
3116 tr ("Directory with vym macros:"),
3117 settings.value ("/macros/macroDir",defdir.path()).toString()
3120 settings.setValue ("/macros/macroDir",dir.absolutePath());
3123 void Main::settingsUndoLevels()
3126 int i = QInputDialog::getInteger(
3128 tr("QInputDialog::getInteger()"),
3129 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3132 settings.setValue ("/mapeditor/stepsTotal",i);
3133 QMessageBox::information( this, tr( "VYM -Information:" ),
3134 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3138 void Main::settingsAutosaveToggle()
3140 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3143 void Main::settingsAutosaveTime()
3146 int i = QInputDialog::getInteger(
3148 tr("QInputDialog::getInteger()"),
3149 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3151 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3154 void Main::settingsWriteBackupFileToggle()
3156 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3159 void Main::settingsToggleAnimation()
3161 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3164 void Main::settingsToggleDelKey()
3166 if (actionSettingsUseDelKey->isOn())
3168 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3171 actionDelete->setAccel (QKeySequence (""));
3175 void Main::windowToggleNoteEditor()
3177 if (textEditor->isVisible() )
3178 windowHideNoteEditor();
3180 windowShowNoteEditor();
3183 void Main::windowToggleHistory()
3185 if (historyWindow->isVisible())
3186 historyWindow->hide();
3188 historyWindow->show();
3192 void Main::windowToggleProperty()
3194 if (branchPropertyWindow->isVisible())
3195 branchPropertyWindow->hide();
3197 branchPropertyWindow->show();
3198 branchPropertyWindow->setModel (currentModel() );
3201 void Main::windowToggleAntiAlias()
3203 bool b=actionViewToggleAntiAlias->isOn();
3205 for (int i=0;i<vymViews.count();i++)
3207 me=vymViews.at(i)->getMapEditor();
3208 if (me) me->setAntiAlias(b);
3213 bool Main::isAliased()
3215 return actionViewToggleAntiAlias->isOn();
3218 bool Main::hasSmoothPixmapTransform()
3220 return actionViewToggleSmoothPixmapTransform->isOn();
3223 void Main::windowToggleSmoothPixmap()
3225 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3227 for (int i=0;i<vymViews.count();i++)
3230 me=vymViews.at(i)->getMapEditor();
3231 if (me) me->setSmoothPixmap(b);
3235 void Main::updateHistory(SimpleSettings &undoSet)
3237 historyWindow->update (undoSet);
3240 void Main::updateNoteFlag()
3242 // this slot is connected to TextEditor::textHasChanged()
3244 VymModel *m=currentModel();
3245 if (m) m->updateNoteFlag();
3248 void Main::updateNoteEditor(QModelIndex index )
3250 TreeItem *ti=((VymModel*)sender())->getItem(index);
3252 cout << "Main::updateNoteEditor model="<<sender();
3253 cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3255 textEditor->setNote (ti->getNoteObj() );
3258 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3260 branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select(). Maybe use signal now...
3262 if (model && model==currentModel() )
3266 if (!oldsel.indexes().isEmpty() )
3268 ti=model->getItem(oldsel.indexes().first());
3270 // Don't update note if both treeItem and textEditor are empty
3271 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3272 // ti->setNoteObj (textEditor->getNoteObj(),false );
3274 if (!newsel.indexes().isEmpty() )
3276 ti=model->getItem(newsel.indexes().first());
3277 if (!ti->hasEmptyNote() )
3278 textEditor->setNote(ti->getNoteObj() );
3280 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3282 // Show URL and link in statusbar
3284 QString s=ti->getURL();
3285 if (!s.isEmpty() ) status+="URL: "+s+" ";
3287 if (!s.isEmpty() ) status+="Link: "+s;
3288 if (!status.isEmpty() ) statusMessage (status);
3291 textEditor->setInactive();
3297 void Main::updateActions()
3299 VymModel *m =currentModel();
3303 actionFilePrint->setEnabled (true);
3305 // Link style in context menu
3306 switch (m->getMapLinkStyle())
3308 case LinkableMapObj::Line:
3309 actionFormatLinkStyleLine->setOn(true);
3311 case LinkableMapObj::Parabel:
3312 actionFormatLinkStyleParabel->setOn(true);
3314 case LinkableMapObj::PolyLine:
3315 actionFormatLinkStylePolyLine->setOn(true);
3317 case LinkableMapObj::PolyParabel:
3318 actionFormatLinkStylePolyParabel->setOn(true);
3325 QPixmap pix( 16, 16 );
3326 pix.fill( m->getMapBackgroundColor() );
3327 actionFormatBackColor->setIconSet( pix );
3328 pix.fill( m->getSelectionColor() );
3329 actionFormatSelectionColor->setIconSet( pix );
3330 pix.fill( m->getMapDefLinkColor() );
3331 actionFormatLinkColor->setIconSet( pix );
3334 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3339 actionFilePrint->setEnabled (false);
3342 // updateActions is also called when NoteEditor is closed
3343 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3344 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3345 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3347 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3348 actionFormatLinkColorHint->setOn(true);
3350 actionFormatLinkColorHint->setOn(false);
3353 if (m && m->hasChanged() )
3354 actionFileSave->setEnabled( true);
3356 actionFileSave->setEnabled( true);
3357 if (m && m->isUndoAvailable())
3358 actionUndo->setEnabled( true);
3360 actionUndo->setEnabled( false);
3362 if (m && m->isRedoAvailable())
3363 actionRedo->setEnabled( true);
3365 actionRedo->setEnabled( false);
3369 TreeItem *selti=m->getSelectedItem();
3370 BranchItem *selbi=m->getSelectedBranchItem();
3375 // Take care of links // FIXME-1
3377 if (bo->countXLinks()==0)
3379 branchXLinksContextMenuEdit->clear();
3380 branchXLinksContextMenuFollow->clear();
3385 branchXLinksContextMenuEdit->clear();
3386 branchXLinksContextMenuFollow->clear();
3387 for (int i=0; i<=bo->countXLinks();i++)
3389 bot=bo->XLinkTargetAt(i);
3392 s=bot->getHeading();
3393 if (s.length()>xLinkMenuWidth)
3394 s=s.left(xLinkMenuWidth)+"...";
3395 branchXLinksContextMenuFollow->addAction (s);
3396 branchXLinksContextMenuEdit->addAction (s);
3402 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3405 actionToggleScroll->setEnabled (true);
3406 if ( selbi->isScrolled() )
3407 actionToggleScroll->setOn(true);
3409 actionToggleScroll->setOn(false);
3411 if ( selti->getURL().isEmpty() )
3413 actionOpenURL->setEnabled (false);
3414 actionOpenURLTab->setEnabled (false);
3418 actionOpenURL->setEnabled (true);
3419 actionOpenURLTab->setEnabled (true);
3421 if ( selti->getVymLink().isEmpty() )
3423 actionOpenVymLink->setEnabled (false);
3424 actionDeleteVymLink->setEnabled (false);
3427 actionOpenVymLink->setEnabled (true);
3428 actionDeleteVymLink->setEnabled (true);
3431 if (selbi->canMoveUp())
3432 actionMoveUp->setEnabled (true);
3434 actionMoveUp->setEnabled (false);
3435 if (selbi->canMoveDown())
3436 actionMoveDown->setEnabled (true);
3438 actionMoveDown->setEnabled (false);
3440 actionSortChildren->setEnabled (true);
3442 actionToggleHideExport->setEnabled (true);
3443 actionToggleHideExport->setOn (selbi->hideInExport() );
3445 actionFileSave->setEnabled (true);
3446 actionCopy->setEnabled (true);
3447 actionCut->setEnabled (true);
3448 if (!clipboardEmpty)
3449 actionPaste->setEnabled (true);
3451 actionPaste->setEnabled (false);
3452 for (int i=0; i<actionListBranches.size(); ++i)
3453 actionListBranches.at(i)->setEnabled(true);
3454 actionDelete->setEnabled (true);
3455 //FIXME-2 actionFormatHideLinkUnselected->setOn (selection->getHideLinkUnselected());
3457 if ( selti->getType()==TreeItem::Image)
3459 actionOpenURL->setEnabled (false);
3460 actionOpenVymLink->setEnabled (false);
3461 actionDeleteVymLink->setEnabled (false);
3462 actionToggleHideExport->setEnabled (true);
3463 actionToggleHideExport->setOn (selti->hideInExport() );
3466 actionCopy->setEnabled (true);
3467 actionCut->setEnabled (true);
3468 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3469 for (int i=0; i<actionListBranches.size(); ++i)
3470 actionListBranches.at(i)->setEnabled(false);
3471 actionDelete->setEnabled (true);
3472 // FIXME-2 actionFormatHideLinkUnselected->setOn
3473 // ( selection->getHideLinkUnselected());
3474 actionMoveUp->setEnabled (false);
3475 actionMoveDown->setEnabled (false);
3480 actionFileSave->setEnabled (false);
3481 actionCopy->setEnabled (false);
3482 actionCut->setEnabled (false);
3483 actionPaste->setEnabled (false);
3484 for (int i=0; i<actionListBranches.size(); ++i)
3485 actionListBranches.at(i)->setEnabled(false);
3487 actionToggleScroll->setEnabled (false);
3488 actionOpenURL->setEnabled (false);
3489 actionOpenVymLink->setEnabled (false);
3490 actionDeleteVymLink->setEnabled (false);
3491 actionHeading2URL->setEnabled (false);
3492 actionDelete->setEnabled (false);
3493 actionMoveUp->setEnabled (false);
3494 actionMoveDown->setEnabled (false);
3495 actionSortChildren->setEnabled (false);
3496 actionToggleHideExport->setEnabled (false);
3501 Main::ModMode Main::getModMode()
3503 if (actionModModeColor->isOn()) return ModModeColor;
3504 if (actionModModeCopy->isOn()) return ModModeCopy;
3505 if (actionModModeXLink->isOn()) return ModModeXLink;
3509 bool Main::autoEditNewBranch()
3511 return actionSettingsAutoEditNewBranch->isOn();
3514 bool Main::autoSelectNewBranch()
3516 return actionSettingsAutoSelectNewBranch->isOn();
3519 void Main::windowShowNoteEditor()
3521 textEditor->setShowWithMain(true);
3523 actionViewToggleNoteEditor->setOn (true);
3526 void Main::windowHideNoteEditor()
3528 textEditor->setShowWithMain(false);
3530 actionViewToggleNoteEditor->setOn (false);
3533 void Main::setScript (const QString &script)
3535 scriptEditor->setScript (script);
3538 void Main::runScript (const QString &script)
3540 VymModel *m=currentModel();
3541 if (m) m->runScript (script);
3544 void Main::runScriptEverywhere (const QString &script)
3547 for (int i=0;i<=tabWidget->count() -1;i++)
3549 me=(MapEditor*)tabWidget->page(i);
3550 if (me) me->getModel()->runScript (script);
3554 void Main::windowNextEditor()
3556 if (tabWidget->currentIndex() < tabWidget->count())
3557 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3560 void Main::windowPreviousEditor()
3562 if (tabWidget->currentIndex() >0)
3563 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3566 void Main::standardFlagChanged()
3570 if ( actionSettingsUseFlagGroups->isOn() )
3571 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3573 currentModel()->toggleStandardFlag(sender()->name());
3578 void Main::testFunction1()
3580 if (!currentMapEditor()) return;
3581 currentMapEditor()->testFunction1();
3584 void Main::testFunction2()
3586 if (!currentMapEditor()) return;
3587 currentMapEditor()->setFocus();
3590 void Main::testCommand()
3592 if (!currentMapEditor()) return;
3593 scriptEditor->show();
3596 QString com = QInputDialog::getText(
3597 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3598 if (ok) currentMapEditor()->parseAtom(com);
3602 void Main::helpDoc()
3604 QString locale = QLocale::system().name();
3606 if (locale.left(2)=="es")
3607 docname="vym_es.pdf";
3611 QStringList searchList;
3613 #if defined(Q_OS_MACX)
3614 searchList << "./vym.app/Contents/Resources/doc";
3615 #elif defined(Q_OS_WIN32)
3616 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3618 #if defined(VYM_DOCDIR)
3619 searchList << VYM_DOCDIR;
3621 // default path in SUSE LINUX
3622 searchList << "/usr/share/doc/packages/vym";
3625 searchList << "doc"; // relative path for easy testing in tarball
3626 searchList << "doc/tex"; // Easy testing working on vym.tex
3627 searchList << "/usr/share/doc/vym"; // Debian
3628 searchList << "/usr/share/doc/packages";// Knoppix
3632 for (int i=0; i<searchList.count(); ++i)
3634 docfile.setFileName(searchList.at(i)+"/"+docname);
3635 if (docfile.exists())
3644 QMessageBox::critical(0,
3645 tr("Critcal error"),
3646 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3651 Process *pdfProc = new Process();
3652 args << QDir::toNativeSeparators(docfile.fileName());
3654 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3655 if ( !pdfProc->waitForStarted() )
3658 QMessageBox::warning(0,
3660 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3661 tr("Please use Settings->")+tr("Set application to open PDF files"));
3668 void Main::helpDemo()
3670 QStringList filters;
3671 filters <<"VYM example map (*.vym)";
3672 QFileDialog *fd=new QFileDialog( this);
3673 #if defined(Q_OS_MACX)
3674 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3676 // default path in SUSE LINUX
3677 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3680 fd->setFileMode (QFileDialog::ExistingFiles);
3681 fd->setFilters (filters);
3682 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3686 if ( fd->exec() == QDialog::Accepted )
3688 lastFileDir=fd->directory().path();
3689 QStringList flist = fd->selectedFiles();
3690 QStringList::Iterator it = flist.begin();
3691 while( it != flist.end() )
3694 fileLoad(*it, NewMap);
3702 void Main::helpAbout()
3705 ad.setName ("aboutwindow");
3706 ad.setMinimumSize(500,500);
3707 ad.resize (QSize (500,500));
3711 void Main::helpAboutQT()
3713 QMessageBox::aboutQt( this, "Qt Application Example" );
3716 void Main::callMacro ()
3718 QAction *action = qobject_cast<QAction *>(sender());
3722 i=action->data().toInt();
3723 QString mDir (settings.value ("macros/macroDir").toString() );
3725 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3727 if ( !f.open( QIODevice::ReadOnly ) )
3729 QMessageBox::warning(0,
3731 tr("Couldn't find a macro at %1.\n").arg(fn)+
3732 tr("Please use Settings->")+tr("Set directory for vym macros"));
3736 QTextStream ts( &f );
3737 QString macro= ts.read();
3739 if (! macro.isEmpty())
3741 VymModel *m=currentModel();
3742 if (m) m->runScript(macro);