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 QString tmpVymDir;
41 extern QString clipboardDir;
42 extern QString clipboardFile;
43 extern bool clipboardEmpty;
44 extern int statusbarTime;
45 extern FlagRow *standardFlagsMaster;
46 extern FlagRow *systemFlagsMaster;
47 extern QString vymName;
48 extern QString vymVersion;
49 extern QString vymBuildDate;
52 QMenu* branchContextMenu;
53 QMenu* branchAddContextMenu;
54 QMenu* branchRemoveContextMenu;
55 QMenu* branchLinksContextMenu;
56 QMenu* branchXLinksContextMenuEdit;
57 QMenu* branchXLinksContextMenuFollow;
58 QMenu* floatimageContextMenu;
59 QMenu* canvasContextMenu;
60 QMenu* fileLastMapsMenu;
61 QMenu* fileImportMenu;
62 QMenu* fileExportMenu;
65 extern Settings settings;
66 extern Options options;
67 extern ImageIO imageIO;
69 extern QDir vymBaseDir;
70 extern QDir lastImageDir;
71 extern QDir lastFileDir;
72 #if defined(Q_OS_WIN32)
73 extern QDir vymInstallDir;
75 extern QString iconPath;
76 extern QString flagsPath;
79 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
80 QMainWindow(parent,name,f)
84 setCaption ("VYM - View Your Mind");
86 // Load window settings
87 #if defined(Q_OS_WIN32)
88 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
90 setWindowState(Qt::WindowMaximized);
95 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
96 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
99 // Sometimes we may need to remember old selections
103 currentColor=Qt::black;
105 // Create unique temporary directory
107 tmpVymDir=makeTmpDir (ok,"vym");
110 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
113 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
115 // Create direcctory for clipboard
116 clipboardDir=tmpVymDir+"/clipboard";
117 clipboardFile="map.xml";
118 QDir d(clipboardDir);
119 d.mkdir (clipboardDir,true);
120 makeSubDirs (clipboardDir);
125 // Satellite windows //////////////////////////////////////////
127 historyWindow=new HistoryWindow();
128 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
131 branchPropertyWindow = new BranchPropertyWindow();
132 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
134 // Connect TextEditor, so that we can update flags if text changes
135 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
136 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
138 // Connect HistoryWindow, so that we can update flags
139 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
142 // Initialize script editor
143 scriptEditor = new SimpleScriptEditor();
144 scriptEditor->move (50,50);
146 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
147 this, SLOT( runScript( QString ) ) );
150 // Initialize Find window
151 findWindow=new FindWindow(NULL);
152 findWindow->move (x(),y()+70);
153 connect (findWindow, SIGNAL( findButton(QString) ),
154 this, SLOT(editFind(QString) ) );
155 connect (findWindow, SIGNAL( somethingChanged() ),
156 this, SLOT(editFindChanged() ) );
158 // Initialize some settings, which are platform dependant
161 // application to open URLs
162 p="/mainwindow/readerURL";
163 #if defined(Q_OS_LINUX)
164 s=settings.value (p,"xdg-open").toString();
166 #if defined(Q_OS_MACX)
167 s=settings.value (p,"/usr/bin/open").toString();
170 #if defined(Q_OS_WIN32)
171 // Assume that system has been set up so that
172 // Explorer automagically opens up the URL
173 // in the user's preferred browser.
174 s=settings.value (p,"explorer").toString();
176 s=settings.value (p,"mozilla").toString();
180 settings.setValue( p,s);
182 // application to open PDFs
183 p="/mainwindow/readerPDF";
184 #if defined(Q_OS_LINUX)
185 s=settings.value (p,"xdg-open").toString();
187 #if defined(Q_OS_MACX)
188 s=settings.value (p,"/usr/bin/open").toString();
189 #elif defined(Q_OS_WIN32)
190 s=settings.value (p,"acrord32").toString();
192 s=settings.value (p,"acroread").toString();
195 settings.setValue( p,s);
197 // width of xLinksMenu
200 // Create tab widget which holds the maps
201 tabWidget= new QTabWidget (this);
202 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
203 this, SLOT( editorChanged( QWidget * ) ) );
205 setCentralWidget(tabWidget);
209 setupFormatActions();
213 setupNetworkActions();
214 setupSettingsActions();
217 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
220 // Status bar and progress bar there
223 progressBar=new QProgressBar;
225 statusBar()->addPermanentWidget(progressBar);
227 restoreState (settings.value("/mainwindow/state",0).toByteArray());
235 #if defined(Q_OS_WIN32)
236 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
238 settings.setValue ("/mainwindow/geometry/size", size());
239 settings.setValue ("/mainwindow/geometry/pos", pos());
240 settings.setValue ("/mainwindow/state",saveState(0));
242 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
243 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
244 settings.setValue( "/version/version", vymVersion );
245 settings.setValue( "/version/builddate", vymBuildDate );
247 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
248 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
249 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
250 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
251 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
252 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
253 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
254 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
256 //TODO save scriptEditor settings
258 // call the destructors
260 delete historyWindow;
261 delete branchPropertyWindow;
264 // Remove temporary directory
265 removeDir (QDir(tmpVymDir));
268 void Main::loadCmdLine()
270 /* TODO draw some kind of splashscreen while loading...
276 QStringList flist=options.getFileList();
277 QStringList::Iterator it=flist.begin();
279 while (it !=flist.end() )
281 fileLoad (*it, NewMap);
287 void Main::statusMessage(const QString &s)
289 // Surpress messages while progressbar during
291 if (progressMin==progressMax)
292 statusBar()->message( s);
295 void Main::setProgressMinimum (int min)
297 progressBar->setMinimum(min);
301 void Main::setProgressMaximum (int max)
303 progressBar->setMaximum(max);
307 statusBar()->addPermanentWidget(progressBar);
312 void Main::setProgressValue (int v)
314 progressBar->setValue (v);
317 void Main::removeProgressBar()
320 statusBar()->removeWidget(progressBar);
321 progressMax=progressMin=0;
324 void Main::closeEvent (QCloseEvent* )
330 void Main::setupFileActions()
332 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
333 QToolBar *tb = addToolBar( tr ("&Map") );
334 tb->setObjectName ("mapTB");
337 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
338 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
339 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
341 fileMenu->addAction (a);
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
344 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
345 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
346 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
347 fileMenu->addAction (a);
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
351 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
352 a->setStatusTip (tr( "Open","Status tip File menu" ) );
353 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
355 fileMenu->addAction (a);
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
358 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
359 fileMenu->addSeparator();
361 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
362 a->setStatusTip ( tr( "Save","Status tip file menu" ));
363 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
365 fileMenu->addAction (a);
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
369 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
370 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
371 fileMenu->addAction (a);
372 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
374 fileMenu->addSeparator();
376 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
378 a = new QAction(tr("KDE 3 Bookmarks"), this);
379 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
380 a->addTo (fileImportMenu);
381 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
383 a = new QAction(tr("KDE 4 Bookmarks"), this);
384 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
385 a->addTo (fileImportMenu);
386 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
388 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
390 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
391 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
392 a->addTo (fileImportMenu);
393 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
396 a = new QAction("Freemind...",this);
397 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
398 fileImportMenu->addAction (a);
399 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
401 a = new QAction("Mind Manager...",this);
402 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
403 fileImportMenu->addAction (a);
404 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
406 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
407 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
408 fileImportMenu->addAction (a);
409 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
411 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
413 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
414 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
415 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
416 fileExportMenu->addAction (a);
418 a = new QAction( "Open Office...", this);
419 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
420 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
421 fileExportMenu->addAction (a);
423 a = new QAction( "Webpage (XHTML)...",this );
424 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
425 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
426 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
427 fileExportMenu->addAction (a);
429 a = new QAction( "Text (ASCII)...", this);
430 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
431 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
432 fileExportMenu->addAction (a);
434 a = new QAction( "Spreadsheet (CSV)...", this);
435 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
436 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
437 fileExportMenu->addAction (a);
439 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
440 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
441 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
442 fileExportMenu->addAction (a);
444 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
445 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
446 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
447 fileExportMenu->addAction (a);
449 a = new QAction( "Taskjuggler...", this );
450 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
451 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
452 fileExportMenu->addAction (a);
454 a = new QAction( "LaTeX...", this);
455 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
456 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
457 fileExportMenu->addAction (a);
459 a = new QAction( "XML..." , this );
460 a->setStatusTip (tr( "Export as %1").arg("XML"));
461 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
462 fileExportMenu->addAction (a);
464 fileMenu->addSeparator();
466 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
467 a->setStatusTip ( tr( "Print" ,"File menu") );
468 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
470 fileMenu->addAction (a);
471 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
474 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
475 a->setStatusTip (tr( "Close Map" ) );
476 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
477 fileMenu->addAction (a);
478 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
480 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
481 a->setStatusTip ( tr( "Exit")+" "+vymName );
482 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
483 fileMenu->addAction (a);
484 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
489 void Main::setupEditActions()
491 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
492 tb->setLabel( "Edit Actions" );
493 tb->setObjectName ("actionsTB");
494 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
498 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
499 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
500 a->setStatusTip (tr( "Undo" ) );
501 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
502 a->setEnabled (false);
504 editMenu->addAction (a);
507 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
508 a->setStatusTip (tr( "Redo" ));
509 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
511 editMenu->addAction (a);
512 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
515 editMenu->addSeparator();
516 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
517 a->setStatusTip ( tr( "Copy" ) );
518 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
519 a->setEnabled (false);
521 editMenu->addAction (a);
522 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
525 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
526 a->setStatusTip ( tr( "Cut" ) );
527 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
528 a->setEnabled (false);
530 editMenu->addAction (a);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
534 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
535 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
536 a->setStatusTip ( tr( "Paste" ) );
537 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
538 a->setEnabled (false);
540 editMenu->addAction (a);
543 // Shortcut to delete selection
544 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
545 a->setStatusTip (tr( "Delete Selection" ));
546 a->setShortcut ( Qt::Key_Delete); //Delete selection
547 a->setShortcutContext (Qt::WindowShortcut);
549 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
552 // Shortcut to add mapcenter
553 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
554 a->setShortcut ( Qt::Key_M);
555 a->setShortcutContext (Qt::WindowShortcut);
556 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
557 //actionListBranches.append(a);
559 actionAddMapCenter = a;
562 // Shortcut to add branch
563 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
564 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
565 alt->setShortcut (Qt::Key_A); //Add branch
566 alt->setShortcutContext (Qt::WindowShortcut);
568 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
569 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
570 a->setStatusTip ( tr( "Add a branch as child of selection" ));
571 a->setShortcut (Qt::Key_Insert); //Add branch
572 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
573 actionListBranches.append(a);
574 #if defined (Q_OS_MACX)
575 // In OSX show different shortcut in menues, the keys work indepently always
580 editMenu->addAction (actionAddBranch);
581 tb->addAction (actionAddBranch);
584 // Add branch by inserting it at selection
585 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
586 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
587 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
588 a->setShortcutContext (Qt::WindowShortcut);
590 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
591 a->setEnabled (false);
592 actionListBranches.append(a);
593 actionAddBranchBefore=a;
594 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
595 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
596 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
597 a->setShortcutContext (Qt::WindowShortcut);
599 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
600 actionListBranches.append(a);
603 a = new QAction(tr( "Add branch above","Edit menu" ), this);
604 a->setStatusTip ( tr( "Add a branch above selection" ));
605 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
606 a->setShortcutContext (Qt::WindowShortcut);
608 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
609 a->setEnabled (false);
610 actionListBranches.append(a);
611 actionAddBranchAbove=a;
612 a = new QAction(tr( "Add branch above","Edit menu" ), this);
613 a->setStatusTip ( tr( "Add a branch above selection" ));
614 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
615 a->setShortcutContext (Qt::WindowShortcut);
617 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
618 actionListBranches.append(a);
621 a = new QAction(tr( "Add branch below","Edit menu" ), this);
622 a->setStatusTip ( tr( "Add a branch below selection" ));
623 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
624 a->setShortcutContext (Qt::WindowShortcut);
626 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
627 a->setEnabled (false);
628 actionListBranches.append(a);
629 actionAddBranchBelow=a;
630 a = new QAction(tr( "Add branch below","Edit menu" ), this);
631 a->setStatusTip ( tr( "Add a branch below selection" ));
632 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
633 a->setShortcutContext (Qt::WindowShortcut);
635 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
636 actionListBranches.append(a);
638 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
639 a->setStatusTip ( tr( "Move branch up" ) );
640 a->setShortcut (Qt::Key_PageUp ); // Move branch up
641 a->setEnabled (false);
643 editMenu->addAction (a);
644 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
647 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
648 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
649 a->setStatusTip (tr( "Move branch down" ) );
650 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
651 a->setEnabled (false);
653 editMenu->addAction (a);
656 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
657 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
658 a->setEnabled (true);
660 editMenu->addAction (a);
661 actionSortChildren=a;
663 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
664 alt->setShortcut ( Qt::Key_S ); // Scroll branch
665 alt->setStatusTip (tr( "Scroll branch" ));
666 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
667 #if defined(Q_OS_MACX)
668 actionToggleScroll=alt;
670 actionToggleScroll=a;
672 actionToggleScroll->setEnabled (false);
673 actionToggleScroll->setToggleAction(true);
674 tb->addAction (actionToggleScroll);
675 editMenu->addAction ( actionToggleScroll);
676 editMenu->addAction (actionToggleScroll);
679 actionListBranches.append(actionToggleScroll);
681 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
682 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
683 a->setStatusTip (tr( "Expand all branches" ));
684 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
686 actionExpandAll->setEnabled (false);
687 actionExpandAll->setToggleAction(false);
688 //tb->addAction (actionExpandAll);
689 editMenu->addAction ( actionExpandAll);
691 actionListBranches.append(actionExpandAll);
694 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
695 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
696 editMenu->addAction (a);
697 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
699 editMenu->addSeparator();
701 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
702 a->setStatusTip (tr( "Find" ) );
703 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
704 editMenu->addAction (a);
705 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
707 editMenu->addSeparator();
709 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
710 a->setShortcut (Qt::CTRL + Qt::Key_U );
711 a->setShortcut (tr( "Open URL" ));
714 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
717 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
718 a->setStatusTip (tr( "Open URL in new tab" ));
719 //a->setShortcut (Qt::CTRL+Qt::Key_U );
721 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
724 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
725 a->setStatusTip (tr( "Open all URLs in subtree" ));
727 actionListBranches.append(a);
728 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
729 actionOpenMultipleURLTabs=a;
731 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
732 a->setStatusTip ( tr( "Edit URL" ) );
733 a->setShortcut ( Qt::Key_U );
734 a->setShortcutContext (Qt::WindowShortcut);
735 actionListBranches.append(a);
737 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
740 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
741 a->setStatusTip ( tr( "Edit local URL" ) );
742 a->setShortcut (Qt::SHIFT + Qt::Key_U );
743 a->setShortcutContext (Qt::WindowShortcut);
744 actionListBranches.append(a);
746 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
749 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
750 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
751 a->setEnabled (false);
752 actionListBranches.append(a);
753 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
756 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
757 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
758 a->setEnabled (false);
759 actionListBranches.append(a);
760 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
761 actionBugzilla2URL=a;
763 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
764 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
765 a->setEnabled (false);
766 actionListBranches.append(a);
767 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
770 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
771 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
773 a->setEnabled (false);
774 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
777 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
778 a->setStatusTip ( tr( "Open all vym links in subtree" ));
779 a->setEnabled (false);
780 actionListBranches.append(a);
781 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
782 actionOpenMultipleVymLinks=a;
785 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
786 a->setEnabled (false);
787 a->setStatusTip ( tr( "Edit link to another vym map" ));
788 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
789 actionListBranches.append(a);
792 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
793 a->setStatusTip ( tr( "Delete link to another vym map" ));
794 a->setEnabled (false);
795 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
796 actionDeleteVymLink=a;
798 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
799 a->setStatusTip ( tr( "Hide object in exports" ) );
800 a->setShortcut (Qt::Key_H );
801 a->setToggleAction(true);
803 a->setEnabled (false);
804 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
805 actionToggleHideExport=a;
807 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
808 a->setStatusTip ( tr( "Edit Map Info" ));
809 a->setEnabled (true);
810 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
813 // Import at selection (adding to selection)
814 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
815 a->setStatusTip (tr( "Add map at selection" ));
816 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
817 a->setEnabled (false);
818 actionListBranches.append(a);
821 // Import at selection (replacing selection)
822 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
823 a->setStatusTip (tr( "Replace selection with map" ));
824 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
825 a->setEnabled (false);
826 actionListBranches.append(a);
827 actionImportReplace=a;
830 a = new QAction( tr( "Save selection","Edit menu" ), this);
831 a->setStatusTip (tr( "Save selection" ));
832 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
833 a->setEnabled (false);
834 actionListBranches.append(a);
837 // Only remove branch, not its children
838 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
839 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
840 a->setShortcut (Qt::ALT + Qt::Key_Delete );
841 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
842 a->setEnabled (false);
844 actionListBranches.append(a);
845 actionDeleteKeepChildren=a;
847 // Only remove children of a branch
848 a = new QAction( tr( "Remove children","Edit menu" ), this);
849 a->setStatusTip (tr( "Remove children of branch" ));
850 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
851 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
852 a->setEnabled (false);
853 actionListBranches.append(a);
854 actionDeleteChildren=a;
856 a = new QAction( tr( "Add Image...","Edit menu" ), this);
857 a->setStatusTip (tr( "Add Image" ));
858 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
861 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
862 a->setStatusTip (tr( "Set properties for selection" ));
863 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
864 a->setShortcutContext (Qt::WindowShortcut);
865 a->setToggleAction (true);
867 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
868 actionViewTogglePropertyWindow=a;
872 void Main::setupFormatActions()
874 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
876 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
877 tb->setObjectName ("formatTB");
880 pix.fill (Qt::black);
881 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
882 a->setStatusTip ( tr( "Set Color" ));
883 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
885 formatMenu->addAction (a);
887 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
888 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
889 a->setShortcut (Qt::CTRL + Qt::Key_K );
890 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
891 a->setEnabled (false);
893 formatMenu->addAction (a);
894 actionListBranches.append(a);
895 actionFormatPickColor=a;
897 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
898 a->setStatusTip ( tr( "Color branch" ) );
899 a->setShortcut (Qt::CTRL + Qt::Key_B);
900 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
901 a->setEnabled (false);
903 formatMenu->addAction (a);
904 actionListBranches.append(a);
905 actionFormatColorSubtree=a;
907 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
908 a->setStatusTip ( tr( "Color Subtree" ));
909 a->setShortcut (Qt::CTRL + Qt::Key_T);
910 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
911 a->setEnabled (false);
912 formatMenu->addAction (a);
914 actionListBranches.append(a);
915 actionFormatColorSubtree=a;
917 formatMenu->addSeparator();
918 actionGroupFormatLinkStyles=new QActionGroup ( this);
919 actionGroupFormatLinkStyles->setExclusive (true);
920 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
921 a->setStatusTip (tr( "Line" ));
922 a->setToggleAction(true);
923 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
924 formatMenu->addAction (a);
925 actionFormatLinkStyleLine=a;
926 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
927 a->setStatusTip (tr( "Line" ));
928 a->setToggleAction(true);
929 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
930 formatMenu->addAction (a);
931 actionFormatLinkStyleParabel=a;
932 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
933 a->setStatusTip (tr( "PolyLine" ));
934 a->setToggleAction(true);
935 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
936 formatMenu->addAction (a);
937 actionFormatLinkStylePolyLine=a;
938 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
939 a->setStatusTip (tr( "PolyParabel" ) );
940 a->setToggleAction(true);
941 a->setChecked (true);
942 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
943 formatMenu->addAction (a);
944 actionFormatLinkStylePolyParabel=a;
946 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
947 a->setStatusTip (tr( "Hide link" ));
948 a->setToggleAction(true);
949 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
950 actionFormatHideLinkUnselected=a;
952 formatMenu->addSeparator();
953 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
954 a->setStatusTip (tr( "Use same color for links and headings" ));
955 a->setToggleAction(true);
956 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
957 formatMenu->addAction (a);
958 actionFormatLinkColorHint=a;
960 pix.fill (Qt::white);
961 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
962 a->setStatusTip (tr( "Set Link Color" ));
963 formatMenu->addAction (a);
964 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
965 actionFormatLinkColor=a;
967 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
968 a->setStatusTip (tr( "Set Selection Color" ));
969 formatMenu->addAction (a);
970 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
971 actionFormatSelectionColor=a;
973 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
974 a->setStatusTip (tr( "Set Background Color" ));
975 formatMenu->addAction (a);
976 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
977 actionFormatBackColor=a;
979 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
980 a->setStatusTip (tr( "Set Background image" ));
981 formatMenu->addAction (a);
982 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
983 actionFormatBackImage=a;
987 void Main::setupViewActions()
989 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
990 tb->setLabel( "View Actions" );
991 tb->setObjectName ("viewTB");
992 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
995 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
996 a->setStatusTip ( tr( "Zoom reset" ) );
997 a->setShortcut (Qt::CTRL + Qt::Key_0 );
999 viewMenu->addAction (a);
1000 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1002 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1003 a->setStatusTip (tr( "Zoom in" ));
1004 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1006 viewMenu->addAction (a);
1007 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1009 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1010 a->setStatusTip (tr( "Zoom out" ));
1011 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1013 viewMenu->addAction (a);
1014 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1016 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1017 a->setStatusTip (tr( "Show selection" ));
1018 a->setShortcut (Qt::Key_Period);
1020 viewMenu->addAction (a);
1021 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1023 viewMenu->addSeparator();
1025 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1026 a->setStatusTip ( tr( "Show Note Editor" ));
1027 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1028 a->setToggleAction(true);
1030 viewMenu->addAction (a);
1031 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1032 actionViewToggleNoteEditor=a;
1034 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1035 a->setStatusTip ( tr( "Show History Window" ));
1036 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1037 a->setToggleAction(true);
1039 viewMenu->addAction (a);
1040 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1041 actionViewToggleHistoryWindow=a;
1043 viewMenu->addAction (actionViewTogglePropertyWindow);
1045 viewMenu->addSeparator();
1047 a = new QAction(tr( "Antialiasing","View action" ),this );
1048 a->setStatusTip ( tr( "Antialiasing" ));
1049 a->setToggleAction(true);
1050 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1051 viewMenu->addAction (a);
1052 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1053 actionViewToggleAntiAlias=a;
1055 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1056 a->setStatusTip (a->text());
1057 a->setToggleAction(true);
1058 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1059 viewMenu->addAction (a);
1060 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1061 actionViewToggleSmoothPixmapTransform=a;
1063 a = new QAction(tr( "Next Map","View action" ), this);
1064 a->setStatusTip (a->text());
1065 a->setShortcut (Qt::ALT + Qt::Key_N );
1066 viewMenu->addAction (a);
1067 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1069 a = new QAction (tr( "Previous Map","View action" ), this );
1070 a->setStatusTip (a->text());
1071 a->setShortcut (Qt::ALT + Qt::Key_P );
1072 viewMenu->addAction (a);
1073 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1077 void Main::setupModeActions()
1079 //QPopupMenu *menu = new QPopupMenu( this );
1080 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1082 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1083 tb->setObjectName ("modesTB");
1085 actionGroupModModes=new QActionGroup ( this);
1086 actionGroupModModes->setExclusive (true);
1087 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1088 a->setShortcut (Qt::Key_J);
1089 a->setStatusTip ( tr( "Use modifier to color branches" ));
1090 a->setToggleAction(true);
1093 actionModModeColor=a;
1095 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1096 a->setShortcut( Qt::Key_K);
1097 a->setStatusTip( tr( "Use modifier to copy" ));
1098 a->setToggleAction(true);
1100 actionModModeCopy=a;
1102 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1103 a->setShortcut (Qt::Key_L);
1104 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1105 a->setToggleAction(true);
1107 actionModModeXLink=a;
1111 void Main::setupFlagActions()
1113 // Create System Flags
1116 Flag *flag=new Flag;;
1117 flag->setVisible(true);
1119 flag->load(QPixmap(flagsPath+"flag-note.png"));
1120 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1122 flag->load(QPixmap(flagsPath+"flag-url.png"));
1123 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1125 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1126 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1128 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1129 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1131 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1132 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1134 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1135 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1137 // Create Standard Flags
1138 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1139 tb->setObjectName ("standardFlagTB");
1140 standardFlagsMaster->setToolBar (tb);
1142 flag->load(flagsPath+"flag-exclamationmark.png");
1143 flag->setGroup("standard-mark");
1144 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1146 flag->load(flagsPath+"flag-questionmark.png");
1147 flag->setGroup("standard-mark");
1148 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1150 flag->load(flagsPath+"flag-hook-green.png");
1151 flag->setGroup("standard-hook");
1152 setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
1154 flag->load(flagsPath+"flag-cross-red.png");
1155 flag->setGroup("standard-hook");
1156 setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
1159 flag->load(flagsPath+"flag-stopsign.png");
1160 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1162 flag->load(flagsPath+"flag-smiley-good.png");
1163 flag->setGroup("standard-smiley");
1164 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1166 flag->load(flagsPath+"flag-smiley-sad.png");
1167 flag->setGroup("standard-smiley");
1168 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1170 flag->load(flagsPath+"flag-smiley-omg.png");
1171 flag->setGroup("standard-smiley");
1172 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1173 // Original omg.png (in KDE emoticons)
1176 flag->load(flagsPath+"flag-kalarm.png");
1177 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1179 flag->load(flagsPath+"flag-phone.png");
1180 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1182 flag->load(flagsPath+"flag-lamp.png");
1183 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1185 flag->load(flagsPath+"flag-arrow-up.png");
1186 flag->setGroup("standard-arrow");
1187 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1189 flag->load(flagsPath+"flag-arrow-down.png");
1190 flag->setGroup("standard-arrow");
1191 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1193 flag->load(flagsPath+"flag-arrow-2up.png");
1194 flag->setGroup("standard-arrow");
1195 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1197 flag->load(flagsPath+"flag-arrow-2down.png");
1198 flag->setGroup("standard-arrow");
1199 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1202 flag->load(flagsPath+"flag-thumb-up.png");
1203 flag->setGroup("standard-thumb");
1204 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1206 flag->load(flagsPath+"flag-thumb-down.png");
1207 flag->setGroup("standard-thumb");
1208 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1211 flag->load(flagsPath+"flag-rose.png");
1212 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1214 flag->load(flagsPath+"flag-heart.png");
1215 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1217 flag->load(flagsPath+"flag-present.png");
1218 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1220 flag->load(flagsPath+"flag-flash.png");
1221 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1223 // Original: xsldbg_output.png
1224 flag->load(flagsPath+"flag-info.png");
1225 setupFlag (flag,tb,"inflag",tr("Info","Standardflag"));
1227 // Original khelpcenter.png
1228 flag->load(flagsPath+"flag-lifebelt.png");
1229 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1232 flag->setVisible(false);
1233 flag->load(flagsPath+"freemind/warning.png");
1234 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1236 for (int i=1; i<8; i++)
1238 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1239 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1242 flag->load(flagsPath+"freemind/back.png");
1243 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1245 flag->load(flagsPath+"freemind/forward.png");
1246 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1248 flag->load(flagsPath+"freemind/attach.png");
1249 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1251 flag->load(flagsPath+"freemind/clanbomber.png");
1252 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1254 flag->load(flagsPath+"freemind/desktopnew.png");
1255 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1257 flag->load(flagsPath+"freemind/flag.png");
1258 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1261 flag->load(flagsPath+"freemind/gohome.png");
1262 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1265 flag->load(flagsPath+"freemind/kaddressbook.png");
1266 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1268 flag->load(flagsPath+"freemind/knotify.png");
1269 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1271 flag->load(flagsPath+"freemind/korn.png");
1272 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1274 flag->load(flagsPath+"freemind/mail.png");
1275 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1277 flag->load(flagsPath+"freemind/password.png");
1278 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1280 flag->load(flagsPath+"freemind/pencil.png");
1281 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1283 flag->load(flagsPath+"freemind/stop.png");
1284 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1286 flag->load(flagsPath+"freemind/wizard.png");
1287 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1289 flag->load(flagsPath+"freemind/xmag.png");
1290 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1292 flag->load(flagsPath+"freemind/bell.png");
1293 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1295 flag->load(flagsPath+"freemind/bookmark.png");
1296 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1298 flag->load(flagsPath+"freemind/penguin.png");
1299 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1301 flag->load(flagsPath+"freemind/licq.png");
1302 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1305 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1307 flag->setName(name);
1308 flag->setToolTip (tooltip);
1312 a=new QAction (flag->getPixmap(),name,this);
1315 flag->setAction (a);
1316 a->setVisible (flag->isVisible());
1317 a->setCheckable(true);
1318 a->setObjectName(name);
1319 a->setToolTip(tooltip);
1320 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1321 standardFlagsMaster->addFlag (flag);
1325 systemFlagsMaster->addFlag (flag);
1330 void Main::setupNetworkActions()
1332 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1334 QMenu *netMenu = menuBar()->addMenu( "Network" );
1338 a = new QAction( "Start TCPserver for MapEditor",this);
1339 //a->setStatusTip ( "Set application to open pdf files"));
1340 a->setShortcut ( Qt::Key_T ); //New TCP server
1341 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1342 netMenu->addAction (a);
1344 a = new QAction( "Connect MapEditor to server",this);
1345 //a->setStatusTip ( "Set application to open pdf files"));
1346 a->setShortcut ( Qt::Key_C ); // Connect to server
1347 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1348 netMenu->addAction (a);
1352 void Main::setupSettingsActions()
1354 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1358 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1359 a->setStatusTip ( tr( "Set application to open pdf files"));
1360 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1361 settingsMenu->addAction (a);
1363 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1364 a->setStatusTip( tr( "Set application to open external links"));
1365 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1366 settingsMenu->addAction (a);
1368 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1369 a->setStatusTip( tr( "Set path for macros"));
1370 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1371 settingsMenu->addAction (a);
1373 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1374 a->setStatusTip( tr( "Set number of undo levels"));
1375 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1376 settingsMenu->addAction (a);
1378 settingsMenu->addSeparator();
1380 a = new QAction( tr( "Autosave","Settings action"), this);
1381 a->setStatusTip( tr( "Autosave"));
1382 a->setToggleAction(true);
1383 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1384 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1385 settingsMenu->addAction (a);
1386 actionSettingsAutosaveToggle=a;
1388 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1389 a->setStatusTip( tr( "Autosave time"));
1390 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1391 settingsMenu->addAction (a);
1392 actionSettingsAutosaveTime=a;
1394 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1395 a->setStatusTip( tr( "Write backup file on save"));
1396 a->setToggleAction(true);
1397 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1398 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1399 settingsMenu->addAction (a);
1400 actionSettingsWriteBackupFile=a;
1402 settingsMenu->addSeparator();
1404 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1405 a->setStatusTip( tr( "Edit branch after adding it" ));
1406 a->setToggleAction(true);
1407 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1408 settingsMenu->addAction (a);
1409 actionSettingsAutoEditNewBranch=a;
1411 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1412 a->setStatusTip( tr( "Select branch after adding it" ));
1413 a->setToggleAction(true);
1414 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1415 settingsMenu->addAction (a);
1416 actionSettingsAutoSelectNewBranch=a;
1418 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1419 a->setStatusTip( tr( "Select heading before editing" ));
1420 a->setToggleAction(true);
1421 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1422 settingsMenu->addAction (a);
1423 actionSettingsAutoSelectText=a;
1425 a= new QAction( tr( "Delete key","Settings action" ), this);
1426 a->setStatusTip( tr( "Delete key for deleting branches" ));
1427 a->setToggleAction(true);
1428 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1429 settingsMenu->addAction (a);
1430 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1431 actionSettingsUseDelKey=a;
1433 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1434 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1435 a->setToggleAction(true);
1436 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1437 settingsMenu->addAction (a);
1438 actionSettingsUseFlagGroups=a;
1440 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1441 a->setStatusTip( tr( "Use hide flag during exports " ));
1442 a->setToggleAction(true);
1443 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1444 settingsMenu->addAction (a);
1445 actionSettingsUseHideExport=a;
1447 a = new QAction( tr( "Animation","Settings action"), this);
1448 a->setStatusTip( tr( "Animation"));
1449 a->setToggleAction(true);
1450 a->setOn (settings.value("/animation/use",false).toBool() );
1451 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1452 settingsMenu->addAction (a);
1453 actionSettingsUseAnimation=a;
1457 void Main::setupTestActions()
1459 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1462 a = new QAction( "Test function 1" , this);
1463 a->setStatusTip( "Call test function 1" );
1464 testMenu->addAction (a);
1465 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1467 a = new QAction( "Test function 2" , this);
1468 a->setStatusTip( "Call test function 2" );
1469 testMenu->addAction (a);
1470 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1472 a = new QAction( "Command" , this);
1473 a->setStatusTip( "Enter command to call in editor" );
1474 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1475 testMenu->addAction (a);
1479 void Main::setupHelpActions()
1481 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1484 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1485 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1486 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1487 helpMenu->addAction (a);
1489 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1490 a->setStatusTip( tr( "Open VYM example maps " ));
1491 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1492 helpMenu->addAction (a);
1494 a = new QAction( tr( "About VYM","Help action" ), this);
1495 a->setStatusTip( tr( "About VYM")+vymName);
1496 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1497 helpMenu->addAction (a);
1499 a = new QAction( tr( "About QT","Help action" ), this);
1500 a->setStatusTip( tr( "Information about QT toolkit" ));
1501 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1502 helpMenu->addAction (a);
1506 void Main::setupContextMenus()
1510 // Context Menu for branch or mapcenter
1511 branchContextMenu =new QMenu (this);
1512 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1513 branchContextMenu->addSeparator();
1516 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1517 branchAddContextMenu->addAction (actionPaste );
1518 branchAddContextMenu->addAction ( actionAddMapCenter );
1519 branchAddContextMenu->addAction ( actionAddBranch );
1520 branchAddContextMenu->addAction ( actionAddBranchBefore );
1521 branchAddContextMenu->addAction ( actionAddBranchAbove);
1522 branchAddContextMenu->addAction ( actionAddBranchBelow );
1523 branchAddContextMenu->addSeparator();
1524 branchAddContextMenu->addAction ( actionImportAdd );
1525 branchAddContextMenu->addAction ( actionImportReplace );
1528 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1529 branchRemoveContextMenu->addAction (actionCut);
1530 branchRemoveContextMenu->addAction ( actionDelete );
1531 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1532 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1535 actionSaveBranch->addTo( branchContextMenu );
1536 actionFileNewCopy->addTo (branchContextMenu );
1538 branchContextMenu->addSeparator();
1539 branchContextMenu->addAction ( actionLoadImage);
1541 // Submenu for Links (URLs, vymLinks)
1542 branchLinksContextMenu =new QMenu (this);
1544 branchContextMenu->addSeparator();
1545 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1546 branchLinksContextMenu->addAction ( actionOpenURL );
1547 branchLinksContextMenu->addAction ( actionOpenURLTab );
1548 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1549 branchLinksContextMenu->addAction ( actionURL );
1550 branchLinksContextMenu->addAction ( actionLocalURL );
1551 branchLinksContextMenu->addAction ( actionHeading2URL );
1552 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1553 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1555 branchLinksContextMenu->addAction ( actionFATE2URL );
1557 branchLinksContextMenu->addSeparator();
1558 branchLinksContextMenu->addAction ( actionOpenVymLink );
1559 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1560 branchLinksContextMenu->addAction ( actionVymLink );
1561 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1564 // Context Menu for XLinks in a branch menu
1565 // This will be populated "on demand" in MapEditor::updateActions
1566 branchContextMenu->addSeparator();
1567 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1568 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1569 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1570 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1573 // Context menu for floatimage
1574 floatimageContextMenu =new QMenu (this);
1575 a= new QAction (tr ("Save image","Context action"),this);
1576 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1577 floatimageContextMenu->addAction (a);
1579 floatimageContextMenu->addSeparator();
1580 actionCopy->addTo( floatimageContextMenu );
1581 actionCut->addTo( floatimageContextMenu );
1583 floatimageContextMenu->addSeparator();
1584 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1587 // Context menu for canvas
1588 canvasContextMenu =new QMenu (this);
1589 actionAddMapCenter->addTo( canvasContextMenu );
1590 actionMapInfo->addTo( canvasContextMenu );
1591 canvasContextMenu->insertSeparator();
1592 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1593 canvasContextMenu->insertSeparator();
1594 actionFormatLinkColorHint->addTo( canvasContextMenu );
1595 actionFormatLinkColor->addTo( canvasContextMenu );
1596 actionFormatSelectionColor->addTo( canvasContextMenu );
1597 actionFormatBackColor->addTo( canvasContextMenu );
1598 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1600 // Menu for last opened files
1602 for (int i = 0; i < MaxRecentFiles; ++i)
1604 recentFileActions[i] = new QAction(this);
1605 recentFileActions[i]->setVisible(false);
1606 fileLastMapsMenu->addAction(recentFileActions[i]);
1607 connect(recentFileActions[i], SIGNAL(triggered()),
1608 this, SLOT(fileLoadRecent()));
1610 setupRecentMapsMenu();
1613 void Main::setupRecentMapsMenu()
1615 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1617 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1619 for (int i = 0; i < numRecentFiles; ++i) {
1620 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1621 recentFileActions[i]->setText(text);
1622 recentFileActions[i]->setData(files[i]);
1623 recentFileActions[i]->setVisible(true);
1625 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1626 recentFileActions[j]->setVisible(false);
1629 void Main::setupMacros()
1631 for (int i = 0; i <= 11; i++)
1633 macroActions[i] = new QAction(this);
1634 macroActions[i]->setData(i);
1635 addAction (macroActions[i]);
1636 connect(macroActions[i], SIGNAL(triggered()),
1637 this, SLOT(callMacro()));
1639 macroActions[0]->setShortcut ( Qt::Key_F1 );
1640 macroActions[1]->setShortcut ( Qt::Key_F2 );
1641 macroActions[2]->setShortcut ( Qt::Key_F3 );
1642 macroActions[3]->setShortcut ( Qt::Key_F4 );
1643 macroActions[4]->setShortcut ( Qt::Key_F5 );
1644 macroActions[5]->setShortcut ( Qt::Key_F6 );
1645 macroActions[6]->setShortcut ( Qt::Key_F7 );
1646 macroActions[7]->setShortcut ( Qt::Key_F8 );
1647 macroActions[8]->setShortcut ( Qt::Key_F9 );
1648 macroActions[9]->setShortcut ( Qt::Key_F10 );
1649 macroActions[10]->setShortcut ( Qt::Key_F11 );
1650 macroActions[11]->setShortcut ( Qt::Key_F12 );
1653 void Main::hideEvent (QHideEvent * )
1655 if (!textEditor->isMinimized() ) textEditor->hide();
1658 void Main::showEvent (QShowEvent * )
1660 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1664 MapEditor* Main::currentMapEditor() const
1666 if ( tabWidget->currentPage())
1667 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1671 VymModel* Main::currentModel() const
1673 if ( tabWidget->currentPage())
1674 return vymViews.at(tabWidget->currentIndex())->getModel();
1679 void Main::editorChanged(QWidget *)
1681 // Unselect all possibly selected objects
1682 // (Important to update note editor)
1684 for (int i=0;i<=tabWidget->count() -1;i++)
1686 m= vymViews.at(tabWidget->currentIndex())->getModel();
1687 if (m) m->unselect();
1690 if (m) m->reselect();
1692 // Update actions to in menus and toolbars according to editor
1696 void Main::fileNew()
1698 VymModel *vm=new VymModel;
1700 VymView *vv=new VymView (vm);
1701 vymViews.append (vv);
1702 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1703 tabWidget->setCurrentIndex (vymViews.count() );
1707 // For the very first map we do not have flagrows yet...
1711 void Main::fileNewCopy()
1713 QString fn="unnamed";
1714 VymModel *srcModel=currentModel();
1719 VymModel *dstModel=vymViews.last()->getModel();
1720 dstModel->select("mc:");
1721 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1725 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1727 ErrorCode err=success;
1729 // fn is usually the archive, mapfile the file after uncompressing
1732 // Make fn absolute (needed for unzip)
1733 fn=QDir (fn).absPath();
1739 // Check, if map is already loaded
1741 while (i<=tabWidget->count() -1)
1743 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1745 // Already there, ask for confirmation
1746 QMessageBox mb( vymName,
1747 tr("The map %1\nis already opened."
1748 "Opening the same map in multiple editors may lead \n"
1749 "to confusion when finishing working with vym."
1750 "Do you want to").arg(fn),
1751 QMessageBox::Warning,
1752 QMessageBox::Yes | QMessageBox::Default,
1753 QMessageBox::Cancel | QMessageBox::Escape,
1754 QMessageBox::NoButton);
1755 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1756 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1759 case QMessageBox::Yes:
1760 // end loop and load anyway
1761 i=tabWidget->count();
1763 case QMessageBox::Cancel:
1773 int tabIndex=tabWidget->currentPageIndex();
1776 if ( !fn.isEmpty() )
1778 vm = currentModel();
1779 // Check first, if mapeditor exists
1780 // If it is not default AND we want a new map,
1781 // create a new mapeditor in a new tab
1782 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1785 VymView *vv=new VymView (vm);
1786 vymViews.append (vv);
1787 tabWidget->addTab (vv,fn);
1788 tabIndex=tabWidget->count()-1;
1789 tabWidget->setCurrentPage (tabIndex);
1793 // Check, if file exists (important for creating new files
1794 // from command line
1795 if (!QFile(fn).exists() )
1797 QMessageBox mb( vymName,
1798 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1799 QMessageBox::Question,
1801 QMessageBox::Cancel | QMessageBox::Default,
1802 QMessageBox::NoButton );
1804 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1805 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1808 case QMessageBox::Yes:
1810 currentMapEditor()->getModel()->setFilePath(fn);
1811 tabWidget->setTabText (tabIndex,
1812 currentMapEditor()->getModel()->getFileName() );
1813 statusBar()->message( "Created " + fn , statusbarTime );
1816 case QMessageBox::Cancel:
1817 // don't create new map
1818 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1825 //tabWidget->currentPage() won't be NULL here, because of above...
1826 tabWidget->setCurrentIndex (tabIndex);
1827 //FIXME-3 no me anymore... me->viewport()->setFocus();
1831 // Save existing filename in case we import
1832 QString fn_org=vm->getFilePath();
1834 // Finally load map into mapEditor
1835 vm->setFilePath (fn);
1836 err=vm->load(fn,lmode,ftype);
1838 // Restore old (maybe empty) filepath, if this is an import
1840 vm->setFilePath (fn_org);
1843 // Finally check for errors and go home
1846 if (lmode==NewMap) fileCloseMap();
1847 statusBar()->message( "Could not load " + fn, statusbarTime );
1852 vm->setFilePath (fn);
1853 tabWidget->setTabText (tabIndex, vm->getFileName());
1854 if (!isInTmpDir (fn))
1856 // Only append to lastMaps if not loaded from a tmpDir
1857 // e.g. imported bookmarks are in a tmpDir
1858 addRecentMap(vm->getFilePath() );
1860 actionFilePrint->setEnabled (true);
1862 statusBar()->message( "Loaded " + fn, statusbarTime );
1869 void Main::fileLoad(const LoadMode &lmode)
1871 QStringList filters;
1872 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1873 QFileDialog *fd=new QFileDialog( this);
1874 fd->setDir (lastFileDir);
1875 fd->setFileMode (QFileDialog::ExistingFiles);
1876 fd->setFilters (filters);
1880 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1883 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1886 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1892 if ( fd->exec() == QDialog::Accepted )
1894 lastFileDir=fd->directory().path();
1895 QStringList flist = fd->selectedFiles();
1896 QStringList::Iterator it = flist.begin();
1897 while( it != flist.end() )
1900 fileLoad(*it, lmode);
1907 void Main::fileLoad()
1912 void Main::fileLoadRecent()
1914 QAction *action = qobject_cast<QAction *>(sender());
1916 fileLoad (action->data().toString(), NewMap);
1919 void Main::addRecentMap (const QString &fileName)
1922 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1923 files.removeAll(fileName);
1924 files.prepend(fileName);
1925 while (files.size() > MaxRecentFiles)
1928 settings.setValue("/mainwindow/recentFileList", files);
1930 setupRecentMapsMenu();
1933 void Main::fileSave(VymModel *m, const SaveMode &savemode)
1937 if ( m->getFilePath().isEmpty() )
1939 // We have no filepath yet,
1940 // call fileSaveAs() now, this will call fileSave()
1942 // First switch to editor
1943 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
1944 fileSaveAs(savemode);
1947 if (m->save (savemode)==success)
1949 statusBar()->message(
1950 tr("Saved %1").arg(m->getFilePath()),
1952 addRecentMap (m->getFilePath() );
1954 statusBar()->message(
1955 tr("Couldn't save ").arg(m->getFilePath()),
1959 void Main::fileSave()
1961 fileSave (currentModel(), CompleteMap);
1964 void Main::fileSave(VymModel *m)
1966 fileSave (m,CompleteMap);
1969 void Main::fileSaveAs(const SaveMode& savemode)
1973 if (currentMapEditor())
1975 if (savemode==CompleteMap)
1976 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1978 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1979 if ( !fn.isEmpty() )
1981 // Check for existing file
1982 if (QFile (fn).exists())
1984 QMessageBox mb( vymName,
1985 tr("The file %1\nexists already. Do you want to").arg(fn),
1986 QMessageBox::Warning,
1987 QMessageBox::Yes | QMessageBox::Default,
1988 QMessageBox::Cancel | QMessageBox::Escape,
1989 QMessageBox::NoButton);
1990 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1991 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1994 case QMessageBox::Yes:
1997 case QMessageBox::Cancel:
2004 // New file, add extension to filename, if missing
2005 // This is always .vym or .vyp, depending on savemode
2006 if (savemode==CompleteMap)
2008 if (!fn.contains (".vym") && !fn.contains (".xml"))
2012 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2021 VymModel *m=currentModel();
2023 fileSave(m, savemode);
2025 // Set name of tab, assuming current tab is the one we just saved
2026 if (savemode==CompleteMap)
2027 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2033 void Main::fileSaveAs()
2035 fileSaveAs (CompleteMap);
2038 void Main::fileImportKDE3Bookmarks()
2040 ImportKDE3Bookmarks im;
2042 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2043 currentMapEditor()->getModel()->setFilePath ("");
2046 void Main::fileImportKDE4Bookmarks()
2048 ImportKDE4Bookmarks im;
2050 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2051 currentMapEditor()->getModel()->setFilePath ("");
2054 void Main::fileImportFirefoxBookmarks()
2056 Q3FileDialog *fd=new Q3FileDialog( this);
2057 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2058 fd->setMode (Q3FileDialog::ExistingFiles);
2059 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2060 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2063 if ( fd->exec() == QDialog::Accepted )
2065 ImportFirefoxBookmarks im;
2066 QStringList flist = fd->selectedFiles();
2067 QStringList::Iterator it = flist.begin();
2068 while( it != flist.end() )
2071 if (im.transform() &&
2072 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2073 currentMapEditor() )
2074 currentMapEditor()->getModel()->setFilePath ("");
2081 void Main::fileImportFreemind()
2083 QStringList filters;
2084 filters <<"Freemind map (*.mm)"<<"All files (*)";
2085 QFileDialog *fd=new QFileDialog( this);
2086 fd->setDir (lastFileDir);
2087 fd->setFileMode (QFileDialog::ExistingFiles);
2088 fd->setFilters (filters);
2089 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2093 if ( fd->exec() == QDialog::Accepted )
2095 lastFileDir=fd->directory().path();
2096 QStringList flist = fd->selectedFiles();
2097 QStringList::Iterator it = flist.begin();
2098 while( it != flist.end() )
2101 if ( fileLoad (fn,NewMap, FreemindMap) )
2103 currentMapEditor()->getModel()->setFilePath ("");
2112 void Main::fileImportMM()
2116 Q3FileDialog *fd=new Q3FileDialog( this);
2117 fd->setDir (lastFileDir);
2118 fd->setMode (Q3FileDialog::ExistingFiles);
2119 fd->addFilter ("Mind Manager (*.mmap)");
2120 fd->setCaption(tr("Import")+" "+"Mind Manager");
2123 if ( fd->exec() == QDialog::Accepted )
2125 lastFileDir=fd->dirPath();
2126 QStringList flist = fd->selectedFiles();
2127 QStringList::Iterator it = flist.begin();
2128 while( it != flist.end() )
2131 if (im.transform() &&
2132 success==fileLoad (im.getTransformedFile(),NewMap) &&
2133 currentMapEditor() )
2134 currentMapEditor()->getModel()->setFilePath ("");
2141 void Main::fileImportDir()
2143 VymModel *m=currentModel();
2144 if (m) m->importDir();
2147 void Main::fileExportXML()
2149 VymModel *m=currentModel();
2150 if (m) m->exportXML();
2154 void Main::fileExportXHTML()
2156 VymModel *m=currentModel();
2157 if (m) m->exportXHTML();
2160 void Main::fileExportImage()
2162 VymModel *m=currentModel();
2163 if (m) m->exportImage();
2166 void Main::fileExportASCII()
2168 VymModel *m=currentModel();
2169 if (m) m->exportASCII();
2172 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2174 VymModel *m=currentModel();
2179 ex.addFilter ("CSV (*.csv)");
2180 ex.setDir(lastImageDir);
2181 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2182 if (ex.execDialog() )
2184 m->setExportMode(true);
2186 m->setExportMode(false);
2191 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2193 VymModel *m=currentModel();
2198 ex.addFilter ("Tex (*.tex)");
2199 ex.setDir(lastImageDir);
2200 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2201 if (ex.execDialog() )
2203 m->setExportMode(true);
2205 m->setExportMode(false);
2210 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2212 ExportKDE3Bookmarks ex;
2213 VymModel *m=currentModel();
2221 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2223 ExportKDE4Bookmarks ex;
2224 VymModel *m=currentModel();
2232 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2234 ExportTaskjuggler ex;
2235 VymModel *m=currentModel();
2239 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2240 ex.setDir(lastImageDir);
2241 ex.addFilter ("Taskjuggler (*.tjp)");
2242 if (ex.execDialog() )
2244 m->setExportMode(true);
2246 m->setExportMode(false);
2251 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2253 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2254 // TODO add preview in dialog
2255 //ImagePreview *p =new ImagePreview (fd);
2256 //fd->setContentsPreviewEnabled( TRUE );
2257 //fd->setContentsPreview( p, p );
2258 //fd->setPreviewMode( QFileDialog::Contents );
2259 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2260 fd->setDir (QDir().current());
2261 if (fd->foundConfig())
2265 if ( fd->exec() == QDialog::Accepted )
2267 QString fn=fd->selectedFile();
2268 if (!fn.contains (".odp"))
2271 //lastImageDir=fn.left(fn.findRev ("/"));
2272 VymModel *m=currentModel();
2273 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2277 QMessageBox::warning(0,
2279 tr("Couldn't find configuration for export to Open Office\n"));
2283 void Main::fileCloseMap()
2285 VymModel *m=currentModel();
2288 if (m->hasChanged())
2290 QMessageBox mb( vymName,
2291 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2292 QMessageBox::Warning,
2293 QMessageBox::Yes | QMessageBox::Default,
2295 QMessageBox::Cancel | QMessageBox::Escape );
2296 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2297 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2300 case QMessageBox::Yes:
2302 fileSave(m, CompleteMap);
2304 case QMessageBox::No:
2305 // close without saving
2307 case QMessageBox::Cancel:
2312 // And here comes the segfault, because removeTab triggers
2313 // currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2314 vymViews.removeAt (tabWidget->currentIndex() );
2315 tabWidget->removeTab (tabWidget->currentIndex() );
2317 // Remove mapEditor/model FIXME-5
2318 // Better would be delete (me), but then we could have a Qt error:
2319 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2320 // So we only remove data now and call deconstructor when vym closes later
2321 // this needs to be moved to vymview... me->clear();
2322 // some model->clear is needed to free up memory ...
2328 void Main::filePrint()
2330 if (currentMapEditor())
2331 currentMapEditor()->print();
2334 void Main::fileExitVYM()
2336 // Check if one or more editors have changed
2338 for (i=0;i<=vymViews.count() -1;i++)
2340 // If something changed, ask what to do
2341 if (vymViews.at(i)->getModel()->hasChanged())
2343 tabWidget->setCurrentPage(i);
2344 QMessageBox mb( vymName,
2345 tr("This map is not saved yet. Do you want to"),
2346 QMessageBox::Warning,
2347 QMessageBox::Yes | QMessageBox::Default,
2349 QMessageBox::Cancel | QMessageBox::Escape );
2350 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2351 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2354 mb.setActiveWindow();
2355 switch( mb.exec() ) {
2356 case QMessageBox::Yes:
2357 // save (the changed editors) and exit
2358 fileSave(currentModel(), CompleteMap);
2360 case QMessageBox::No:
2361 // exit without saving
2363 case QMessageBox::Cancel:
2364 // don't save and don't exit
2368 } // loop over all MEs
2372 void Main::editUndo()
2374 VymModel *m=currentModel();
2378 void Main::editRedo()
2380 VymModel *m=currentModel();
2384 void Main::gotoHistoryStep (int i)
2386 VymModel *m=currentModel();
2387 if (m) m->gotoHistoryStep(i);
2390 void Main::editCopy()
2392 VymModel *m=currentModel();
2396 void Main::editPaste()
2398 VymModel *m=currentModel();
2402 void Main::editCut()
2404 VymModel *m=currentModel();
2408 void Main::editOpenFindWindow()
2410 findWindow->popup();
2411 findWindow->raise();
2412 findWindow->setActiveWindow();
2415 void Main::editFind(QString s)
2417 VymModel *m=currentModel();
2421 BranchItem *bi=m->findText(s, cs);
2424 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2427 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2428 tr("No matches found for \"%1\"").arg(s));
2433 void Main::editFindChanged()
2434 { // Notify editor, to abort the current find process
2435 VymModel *m=currentModel();
2436 if (m) m->findReset();
2439 void Main::openTabs(QStringList urls)
2441 if (!urls.isEmpty())
2445 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2447 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2449 QString u=urls.takeFirst();
2450 procBrowser = new QProcess( this );
2452 procBrowser->start(browser,args);
2453 if ( !procBrowser->waitForStarted())
2455 // try to set path to browser
2456 QMessageBox::warning(0,
2458 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2459 tr("Please use Settings->")+tr("Set application to open an URL"));
2462 #if defined(Q_OS_WIN32)
2463 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2464 this->thread()->wait(3000);
2469 if (browser.contains("konqueror"))
2471 for (int i=0; i<urls.size(); i++)
2474 // Try to open new tab in existing konqueror started previously by vym
2475 p=new QProcess (this);
2477 #if defined(Q_OS_WIN32)
2478 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2479 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2480 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2481 "konqueror-mainwindow#1"<<
2485 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2486 "konqueror-mainwindow#1"<<
2490 p->start ("dcop",args);
2491 if (debug) cout << "MainWindo::openURLs args="<<args.join(" ").toStdString()<<endl;
2492 if ( !p->waitForStarted() ) success=false;
2495 QMessageBox::warning(0,
2497 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2499 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2501 for (int i=0; i<urls.size(); i++)
2503 // Try to open new tab in firefox
2504 p=new QProcess (this);
2505 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2506 p->start (browser,args);
2507 if ( !p->waitForStarted() ) success=false;
2510 QMessageBox::warning(0,
2512 tr("Couldn't start %1 to open a new tab").arg(browser));
2515 QMessageBox::warning(0,
2517 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2521 void Main::editOpenURL()
2524 VymModel *m=currentModel();
2527 QString url=m->getURL();
2529 if (url=="") return;
2530 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2531 procBrowser = new QProcess( this );
2533 procBrowser->start(browser,args);
2534 if ( !procBrowser->waitForStarted())
2536 // try to set path to browser
2537 QMessageBox::warning(0,
2539 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2540 tr("Please use Settings->")+tr("Set application to open an URL"));
2545 void Main::editOpenURLTab()
2547 VymModel *m=currentModel();
2551 urls.append(m->getURL());
2555 void Main::editOpenMultipleURLTabs()
2557 VymModel *m=currentModel();
2567 void Main::editURL()
2569 VymModel *m=currentModel();
2570 if (m) m->editURL();
2573 void Main::editLocalURL()
2575 VymModel *m=currentModel();
2576 if (m) m->editLocalURL();
2579 void Main::editHeading2URL()
2581 VymModel *m=currentModel();
2582 if (m) m->editHeading2URL();
2585 void Main::editBugzilla2URL()
2587 VymModel *m=currentModel();
2588 if (m) m->editBugzilla2URL();
2591 void Main::editFATE2URL()
2593 VymModel *m=currentModel();
2594 if (m) m->editFATE2URL();
2597 void Main::editHeadingFinished(VymModel *m)
2601 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2602 !prevSelection.isEmpty())
2603 m->select(prevSelection);
2608 void Main::openVymLinks(const QStringList &vl)
2610 for (int j=0; j<vl.size(); j++)
2612 // compare path with already loaded maps
2615 for (i=0;i<=vymViews.count() -1;i++)
2617 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2626 if (!QFile(vl.at(j)).exists() )
2627 QMessageBox::critical( 0, tr( "Critical Error" ),
2628 tr("Couldn't open map %1").arg(vl.at(j)));
2631 fileLoad (vl.at(j), NewMap);
2632 tabWidget->setCurrentIndex (tabWidget->count()-1);
2635 // Go to tab containing the map
2636 tabWidget->setCurrentIndex (index);
2640 void Main::editOpenVymLink()
2642 VymModel *m=currentModel();
2646 vl.append(m->getVymLink());
2651 void Main::editOpenMultipleVymLinks()
2653 QString currentVymLink;
2654 VymModel *m=currentModel();
2657 QStringList vl=m->getVymLinks();
2662 void Main::editVymLink()
2664 VymModel *m=currentModel();
2669 void Main::editDeleteVymLink()
2671 VymModel *m=currentModel();
2672 if (m) m->deleteVymLink();
2675 void Main::editToggleHideExport()
2677 VymModel *m=currentModel();
2678 if (m) m->toggleHideExport();
2681 void Main::editMapInfo()
2683 VymModel *m=currentModel();
2685 ExtraInfoDialog dia;
2686 dia.setMapName (m->getFileName() );
2687 dia.setAuthor (m->getAuthor() );
2688 dia.setComment(m->getComment() );
2692 /* FIXME-2 no stats at the moment (view dependent...)
2693 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2703 if (!bo->getNote().isEmpty() ) n++;
2704 f+= bo->countFloatImages();
2706 xl+=bo->countXLinks();
2709 stats+=QString ("%1 xLinks \n").arg (xl,6);
2710 stats+=QString ("%1 notes\n").arg (n,6);
2711 stats+=QString ("%1 images\n").arg (f,6);
2713 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2714 dia.setStats (stats);
2716 // Finally show dialog
2717 if (dia.exec() == QDialog::Accepted)
2719 m->setAuthor (dia.getAuthor() );
2720 m->setComment (dia.getComment() );
2724 void Main::editMoveUp()
2726 VymModel *m=currentModel();
2730 void Main::editMoveDown()
2732 VymModel *m=currentModel();
2733 if (m) m->moveDown();
2736 void Main::editSortChildren()
2738 VymModel *m=currentModel();
2739 if (m) m->sortChildren();
2742 void Main::editToggleScroll()
2744 VymModel *m=currentModel();
2745 if (m) m->toggleScroll();
2748 void Main::editExpandAll()
2750 VymModel *m=currentModel();
2751 if (m) m->emitExpandAll();
2754 void Main::editUnscrollChildren()
2756 VymModel *m=currentModel();
2757 if (m) m->unscrollChildren();
2760 void Main::editAddMapCenter()
2762 VymModel *m=currentModel();
2763 if (m) m->addMapCenter ();
2766 void Main::editNewBranch()
2768 VymModel *m=currentModel();
2771 BranchItem *bi=m->addNewBranch();
2774 if (actionSettingsAutoEditNewBranch->isOn()
2775 && !actionSettingsAutoSelectNewBranch->isOn() )
2776 prevSelection=m->getSelectString();
2778 prevSelection=QString();
2780 if (actionSettingsAutoSelectNewBranch->isOn()
2781 || actionSettingsAutoEditNewBranch->isOn())
2784 if (actionSettingsAutoEditNewBranch->isOn())
2785 currentMapEditor()->editHeading();
2790 void Main::editNewBranchBefore()
2792 VymModel *m=currentModel();
2795 BranchItem *bi=m->addNewBranchBefore();
2802 if (actionSettingsAutoEditNewBranch->isOn())
2804 if (!actionSettingsAutoSelectNewBranch->isOn())
2805 prevSelection=m->getSelectString(bi);
2806 currentMapEditor()->editHeading();
2811 void Main::editNewBranchAbove()
2813 VymModel *m=currentModel();
2816 BranchItem *bi=m->addNewBranch (-1);
2824 if (actionSettingsAutoEditNewBranch->isOn())
2826 if (!actionSettingsAutoSelectNewBranch->isOn())
2827 prevSelection=m->getSelectString (bi);
2828 currentMapEditor()->editHeading();
2833 void Main::editNewBranchBelow()
2835 VymModel *m=currentModel();
2838 BranchItem *bi=m->addNewBranch (1);
2845 if (actionSettingsAutoEditNewBranch->isOn())
2847 if (!actionSettingsAutoSelectNewBranch->isOn())
2848 prevSelection=m->getSelectString(bi);
2849 currentMapEditor()->editHeading();
2854 void Main::editImportAdd()
2856 fileLoad (ImportAdd);
2859 void Main::editImportReplace()
2861 fileLoad (ImportReplace);
2864 void Main::editSaveBranch()
2866 fileSaveAs (PartOfMap);
2869 void Main::editDeleteKeepChildren()
2871 VymModel *m=currentModel();
2872 if (m) m->deleteKeepChildren();
2875 void Main::editDeleteChildren()
2877 VymModel *m=currentModel();
2878 if (m) m->deleteChildren();
2881 void Main::editDeleteSelection()
2883 VymModel *m=currentModel();
2884 if (m && actionSettingsUseDelKey->isOn())
2885 m->deleteSelection();
2888 void Main::editLoadImage()
2890 VymModel *m=currentModel();
2891 if (m) m->loadFloatImage();
2894 void Main::editSaveImage()
2896 VymModel *m=currentModel();
2897 if (m) m->saveFloatImage();
2900 void Main::editFollowXLink(QAction *a)
2903 VymModel *m=currentModel();
2905 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2908 void Main::editEditXLink(QAction *a)
2910 VymModel *m=currentModel();
2912 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2915 void Main::formatSelectColor()
2917 QColor col = QColorDialog::getColor((currentColor ), this );
2918 if ( !col.isValid() ) return;
2919 colorChanged( col );
2922 void Main::formatPickColor()
2924 VymModel *m=currentModel();
2926 colorChanged( m->getCurrentHeadingColor() );
2929 void Main::colorChanged(QColor c)
2931 QPixmap pix( 16, 16 );
2933 actionFormatColor->setIconSet( pix );
2937 void Main::formatColorBranch()
2939 VymModel *m=currentModel();
2940 if (m) m->colorBranch(currentColor);
2943 void Main::formatColorSubtree()
2945 VymModel *m=currentModel();
2946 if (m) m->colorSubtree (currentColor);
2949 void Main::formatLinkStyleLine()
2951 VymModel *m=currentModel();
2954 m->setMapLinkStyle("StyleLine");
2955 actionFormatLinkStyleLine->setOn(true);
2959 void Main::formatLinkStyleParabel()
2961 VymModel *m=currentModel();
2964 m->setMapLinkStyle("StyleParabel");
2965 actionFormatLinkStyleParabel->setOn(true);
2969 void Main::formatLinkStylePolyLine()
2971 VymModel *m=currentModel();
2974 m->setMapLinkStyle("StylePolyLine");
2975 actionFormatLinkStylePolyLine->setOn(true);
2979 void Main::formatLinkStylePolyParabel()
2981 VymModel *m=currentModel();
2984 m->setMapLinkStyle("StylePolyParabel");
2985 actionFormatLinkStylePolyParabel->setOn(true);
2989 void Main::formatSelectBackColor()
2991 VymModel *m=currentModel();
2992 if (m) m->selectMapBackgroundColor();
2995 void Main::formatSelectBackImage()
2997 VymModel *m=currentModel();
2999 m->selectMapBackgroundImage();
3002 void Main::formatSelectLinkColor()
3004 VymModel *m=currentModel();
3007 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3008 m->setMapDefLinkColor( col );
3012 void Main::formatSelectSelectionColor()
3014 VymModel *m=currentModel();
3017 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3018 m->setSelectionColor (col);
3023 void Main::formatToggleLinkColorHint()
3025 VymModel *m=currentModel();
3026 if (m) m->toggleMapLinkColorHint();
3030 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3032 VymModel *m=currentModel();
3034 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3037 void Main::viewZoomReset()
3039 MapEditor *me=currentMapEditor();
3040 if (me) me->setZoomFactorTarget (1);
3043 void Main::viewZoomIn()
3045 MapEditor *me=currentMapEditor();
3046 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3049 void Main::viewZoomOut()
3051 MapEditor *me=currentMapEditor();
3052 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3055 void Main::viewCenter()
3057 VymModel *m=currentModel();
3058 if (m) m->emitShowSelection();
3061 void Main::networkStartServer()
3063 VymModel *m=currentModel();
3064 if (m) m->newServer();
3067 void Main::networkConnect()
3069 VymModel *m=currentModel();
3070 if (m) m->connectToServer();
3073 bool Main::settingsPDF()
3075 // Default browser is set in constructor
3077 QString text = QInputDialog::getText(
3078 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3079 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3081 settings.setValue ("/mainwindow/readerPDF",text);
3086 bool Main::settingsURL()
3088 // Default browser is set in constructor
3090 QString text = QInputDialog::getText(
3091 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3092 settings.value("/mainwindow/readerURL").toString()
3095 settings.setValue ("/mainwindow/readerURL",text);
3099 void Main::settingsMacroDir()
3101 QDir defdir(vymBaseDir.path() + "/macros");
3102 if (!defdir.exists())
3104 QDir dir=QFileDialog::getExistingDirectory (
3106 tr ("Directory with vym macros:"),
3107 settings.value ("/macros/macroDir",defdir.path()).toString()
3110 settings.setValue ("/macros/macroDir",dir.absolutePath());
3113 void Main::settingsUndoLevels()
3116 int i = QInputDialog::getInteger(
3118 tr("QInputDialog::getInteger()"),
3119 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3122 settings.setValue ("/mapeditor/stepsTotal",i);
3123 QMessageBox::information( this, tr( "VYM -Information:" ),
3124 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3128 void Main::settingsAutosaveToggle()
3130 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3133 void Main::settingsAutosaveTime()
3136 int i = QInputDialog::getInteger(
3138 tr("QInputDialog::getInteger()"),
3139 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3141 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3144 void Main::settingsWriteBackupFileToggle()
3146 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3149 void Main::settingsToggleAnimation()
3151 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3154 void Main::settingsToggleDelKey()
3156 if (actionSettingsUseDelKey->isOn())
3158 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3161 actionDelete->setAccel (QKeySequence (""));
3165 void Main::windowToggleNoteEditor()
3167 if (textEditor->isVisible() )
3168 windowHideNoteEditor();
3170 windowShowNoteEditor();
3173 void Main::windowToggleHistory()
3175 if (historyWindow->isVisible())
3176 historyWindow->hide();
3178 historyWindow->show();
3182 void Main::windowToggleProperty()
3184 if (branchPropertyWindow->isVisible())
3185 branchPropertyWindow->hide();
3187 branchPropertyWindow->show();
3188 branchPropertyWindow->setModel (currentModel() );
3191 void Main::windowToggleAntiAlias()
3193 bool b=actionViewToggleAntiAlias->isOn();
3195 for (int i=0;i<vymViews.count();i++)
3197 me=vymViews.at(i)->getMapEditor();
3198 if (me) me->setAntiAlias(b);
3203 bool Main::isAliased()
3205 return actionViewToggleAntiAlias->isOn();
3208 bool Main::hasSmoothPixmapTransform()
3210 return actionViewToggleSmoothPixmapTransform->isOn();
3213 void Main::windowToggleSmoothPixmap()
3215 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3217 for (int i=0;i<vymViews.count();i++)
3220 me=vymViews.at(i)->getMapEditor();
3221 if (me) me->setSmoothPixmap(b);
3225 void Main::updateHistory(SimpleSettings &undoSet)
3227 historyWindow->update (undoSet);
3230 void Main::updateNoteFlag()
3232 // this slot is connected to TextEditor::textHasChanged()
3234 VymModel *m=currentModel();
3235 if (m) m->updateNoteFlag();
3238 void Main::updateNoteEditor(QModelIndex index )
3240 cout << QObject::sender();
3241 QObject *obj=QObject::sender();
3242 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3243 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3244 //cout << "Main::updateNoteEditor model="<<sender();
3245 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3246 textEditor->setNote (ti->getNoteObj() );
3249 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3251 branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select(). Maybe use signal now...
3253 if (model && model==currentModel() )
3257 if (!oldsel.indexes().isEmpty() )
3259 ti=model->getItem(oldsel.indexes().first());
3261 // Don't update note if both treeItem and textEditor are empty
3262 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3263 // ti->setNoteObj (textEditor->getNoteObj(),false );
3265 if (!newsel.indexes().isEmpty() )
3267 ti=model->getItem(newsel.indexes().first());
3268 if (!ti->hasEmptyNote() )
3269 textEditor->setNote(ti->getNoteObj() );
3271 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3273 // Show URL and link in statusbar
3275 QString s=ti->getURL();
3276 if (!s.isEmpty() ) status+="URL: "+s+" ";
3278 if (!s.isEmpty() ) status+="Link: "+s;
3279 if (!status.isEmpty() ) statusMessage (status);
3282 textEditor->setInactive();
3288 void Main::updateActions()
3290 VymModel *m =currentModel();
3294 actionFilePrint->setEnabled (true);
3296 // Link style in context menu
3297 switch (m->getMapLinkStyle())
3299 case LinkableMapObj::Line:
3300 actionFormatLinkStyleLine->setOn(true);
3302 case LinkableMapObj::Parabel:
3303 actionFormatLinkStyleParabel->setOn(true);
3305 case LinkableMapObj::PolyLine:
3306 actionFormatLinkStylePolyLine->setOn(true);
3308 case LinkableMapObj::PolyParabel:
3309 actionFormatLinkStylePolyParabel->setOn(true);
3316 QPixmap pix( 16, 16 );
3317 pix.fill( m->getMapBackgroundColor() );
3318 actionFormatBackColor->setIconSet( pix );
3319 pix.fill( m->getSelectionColor() );
3320 actionFormatSelectionColor->setIconSet( pix );
3321 pix.fill( m->getMapDefLinkColor() );
3322 actionFormatLinkColor->setIconSet( pix );
3325 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3330 actionFilePrint->setEnabled (false);
3333 // updateActions is also called when NoteEditor is closed
3334 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3335 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3336 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3338 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3339 actionFormatLinkColorHint->setOn(true);
3341 actionFormatLinkColorHint->setOn(false);
3344 if (m && m->hasChanged() )
3345 actionFileSave->setEnabled( true);
3347 actionFileSave->setEnabled( true);
3348 if (m && m->isUndoAvailable())
3349 actionUndo->setEnabled( true);
3351 actionUndo->setEnabled( false);
3353 if (m && m->isRedoAvailable())
3354 actionRedo->setEnabled( true);
3356 actionRedo->setEnabled( false);
3360 TreeItem *selti=m->getSelectedItem();
3361 BranchItem *selbi=m->getSelectedBranchItem();
3366 // Take care of links // FIXME-1
3368 if (bo->countXLinks()==0)
3370 branchXLinksContextMenuEdit->clear();
3371 branchXLinksContextMenuFollow->clear();
3376 branchXLinksContextMenuEdit->clear();
3377 branchXLinksContextMenuFollow->clear();
3378 for (int i=0; i<=bo->countXLinks();i++)
3380 bot=bo->XLinkTargetAt(i);
3383 s=bot->getHeading();
3384 if (s.length()>xLinkMenuWidth)
3385 s=s.left(xLinkMenuWidth)+"...";
3386 branchXLinksContextMenuFollow->addAction (s);
3387 branchXLinksContextMenuEdit->addAction (s);
3393 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3396 actionToggleScroll->setEnabled (true);
3397 if ( selbi->isScrolled() )
3398 actionToggleScroll->setOn(true);
3400 actionToggleScroll->setOn(false);
3402 if ( selti->getURL().isEmpty() )
3404 actionOpenURL->setEnabled (false);
3405 actionOpenURLTab->setEnabled (false);
3409 actionOpenURL->setEnabled (true);
3410 actionOpenURLTab->setEnabled (true);
3412 if ( selti->getVymLink().isEmpty() )
3414 actionOpenVymLink->setEnabled (false);
3415 actionDeleteVymLink->setEnabled (false);
3418 actionOpenVymLink->setEnabled (true);
3419 actionDeleteVymLink->setEnabled (true);
3422 if (selbi->canMoveUp())
3423 actionMoveUp->setEnabled (true);
3425 actionMoveUp->setEnabled (false);
3426 if (selbi->canMoveDown())
3427 actionMoveDown->setEnabled (true);
3429 actionMoveDown->setEnabled (false);
3431 actionSortChildren->setEnabled (true);
3433 actionToggleHideExport->setEnabled (true);
3434 actionToggleHideExport->setOn (selbi->hideInExport() );
3436 actionFileSave->setEnabled (true);
3437 actionCopy->setEnabled (true);
3438 actionCut->setEnabled (true);
3439 if (!clipboardEmpty)
3440 actionPaste->setEnabled (true);
3442 actionPaste->setEnabled (false);
3443 for (int i=0; i<actionListBranches.size(); ++i)
3444 actionListBranches.at(i)->setEnabled(true);
3445 actionDelete->setEnabled (true);
3446 //FIXME-2 actionFormatHideLinkUnselected->setOn (selection->getHideLinkUnselected());
3448 if ( selti->getType()==TreeItem::Image)
3450 actionOpenURL->setEnabled (false);
3451 actionOpenVymLink->setEnabled (false);
3452 actionDeleteVymLink->setEnabled (false);
3453 actionToggleHideExport->setEnabled (true);
3454 actionToggleHideExport->setOn (selti->hideInExport() );
3457 actionCopy->setEnabled (true);
3458 actionCut->setEnabled (true);
3459 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3460 for (int i=0; i<actionListBranches.size(); ++i)
3461 actionListBranches.at(i)->setEnabled(false);
3462 actionDelete->setEnabled (true);
3463 // FIXME-2 actionFormatHideLinkUnselected->setOn
3464 // ( selection->getHideLinkUnselected());
3465 actionMoveUp->setEnabled (false);
3466 actionMoveDown->setEnabled (false);
3471 actionFileSave->setEnabled (false);
3472 actionCopy->setEnabled (false);
3473 actionCut->setEnabled (false);
3474 actionPaste->setEnabled (false);
3475 for (int i=0; i<actionListBranches.size(); ++i)
3476 actionListBranches.at(i)->setEnabled(false);
3478 actionToggleScroll->setEnabled (false);
3479 actionOpenURL->setEnabled (false);
3480 actionOpenVymLink->setEnabled (false);
3481 actionDeleteVymLink->setEnabled (false);
3482 actionHeading2URL->setEnabled (false);
3483 actionDelete->setEnabled (false);
3484 actionMoveUp->setEnabled (false);
3485 actionMoveDown->setEnabled (false);
3486 actionSortChildren->setEnabled (false);
3487 actionToggleHideExport->setEnabled (false);
3492 Main::ModMode Main::getModMode()
3494 if (actionModModeColor->isOn()) return ModModeColor;
3495 if (actionModModeCopy->isOn()) return ModModeCopy;
3496 if (actionModModeXLink->isOn()) return ModModeXLink;
3500 bool Main::autoEditNewBranch()
3502 return actionSettingsAutoEditNewBranch->isOn();
3505 bool Main::autoSelectNewBranch()
3507 return actionSettingsAutoSelectNewBranch->isOn();
3510 void Main::windowShowNoteEditor()
3512 textEditor->setShowWithMain(true);
3514 actionViewToggleNoteEditor->setOn (true);
3517 void Main::windowHideNoteEditor()
3519 textEditor->setShowWithMain(false);
3521 actionViewToggleNoteEditor->setOn (false);
3524 void Main::setScript (const QString &script)
3526 scriptEditor->setScript (script);
3529 void Main::runScript (const QString &script)
3531 VymModel *m=currentModel();
3532 if (m) m->runScript (script);
3535 void Main::runScriptEverywhere (const QString &script)
3538 for (int i=0;i<=tabWidget->count() -1;i++)
3540 me=(MapEditor*)tabWidget->page(i);
3541 if (me) me->getModel()->runScript (script);
3545 void Main::windowNextEditor()
3547 if (tabWidget->currentIndex() < tabWidget->count())
3548 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3551 void Main::windowPreviousEditor()
3553 if (tabWidget->currentIndex() >0)
3554 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3557 void Main::standardFlagChanged()
3561 if ( actionSettingsUseFlagGroups->isOn() )
3562 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3564 currentModel()->toggleStandardFlag(sender()->name());
3569 void Main::testFunction1()
3571 if (!currentMapEditor()) return;
3572 currentMapEditor()->testFunction1();
3575 void Main::testFunction2()
3577 if (!currentMapEditor()) return;
3578 currentMapEditor()->setFocus();
3581 void Main::testCommand()
3583 if (!currentMapEditor()) return;
3584 scriptEditor->show();
3587 QString com = QInputDialog::getText(
3588 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3589 if (ok) currentMapEditor()->parseAtom(com);
3593 void Main::helpDoc()
3595 QString locale = QLocale::system().name();
3597 if (locale.left(2)=="es")
3598 docname="vym_es.pdf";
3602 QStringList searchList;
3604 #if defined(Q_OS_MACX)
3605 searchList << "./vym.app/Contents/Resources/doc";
3606 #elif defined(Q_OS_WIN32)
3607 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3609 #if defined(VYM_DOCDIR)
3610 searchList << VYM_DOCDIR;
3612 // default path in SUSE LINUX
3613 searchList << "/usr/share/doc/packages/vym";
3616 searchList << "doc"; // relative path for easy testing in tarball
3617 searchList << "doc/tex"; // Easy testing working on vym.tex
3618 searchList << "/usr/share/doc/vym"; // Debian
3619 searchList << "/usr/share/doc/packages";// Knoppix
3623 for (int i=0; i<searchList.count(); ++i)
3625 docfile.setFileName(searchList.at(i)+"/"+docname);
3626 if (docfile.exists())
3635 QMessageBox::critical(0,
3636 tr("Critcal error"),
3637 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3642 Process *pdfProc = new Process();
3643 args << QDir::toNativeSeparators(docfile.fileName());
3645 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3646 if ( !pdfProc->waitForStarted() )
3649 QMessageBox::warning(0,
3651 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3652 tr("Please use Settings->")+tr("Set application to open PDF files"));
3659 void Main::helpDemo()
3661 QStringList filters;
3662 filters <<"VYM example map (*.vym)";
3663 QFileDialog *fd=new QFileDialog( this);
3664 #if defined(Q_OS_MACX)
3665 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3667 // default path in SUSE LINUX
3668 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3671 fd->setFileMode (QFileDialog::ExistingFiles);
3672 fd->setFilters (filters);
3673 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3677 if ( fd->exec() == QDialog::Accepted )
3679 lastFileDir=fd->directory().path();
3680 QStringList flist = fd->selectedFiles();
3681 QStringList::Iterator it = flist.begin();
3682 while( it != flist.end() )
3685 fileLoad(*it, NewMap);
3693 void Main::helpAbout()
3696 ad.setName ("aboutwindow");
3697 ad.setMinimumSize(500,500);
3698 ad.resize (QSize (500,500));
3702 void Main::helpAboutQT()
3704 QMessageBox::aboutQt( this, "Qt Application Example" );
3707 void Main::callMacro ()
3709 QAction *action = qobject_cast<QAction *>(sender());
3713 i=action->data().toInt();
3714 QString mDir (settings.value ("macros/macroDir").toString() );
3716 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3718 if ( !f.open( QIODevice::ReadOnly ) )
3720 QMessageBox::warning(0,
3722 tr("Couldn't find a macro at %1.\n").arg(fn)+
3723 tr("Please use Settings->")+tr("Set directory for vym macros"));
3727 QTextStream ts( &f );
3728 QString macro= ts.read();
3730 if (! macro.isEmpty())
3732 VymModel *m=currentModel();
3733 if (m) m->runScript(macro);