1 #include "mainwindow.h"
3 #include <QtDBus/QtDBus>
9 #include "aboutdialog.h"
10 #include "branchpropwindow.h"
11 #include "branchitem.h"
12 #include "exportoofiledialog.h"
16 #include "historywindow.h"
18 #include "mapeditor.h"
23 #include "texteditor.h"
24 #include "warningdialog.h"
26 #if defined(Q_OS_WIN32)
27 // Define only this structure as opposed to
28 // including full 'windows.h'. FindWindow
29 // clashes with the one in Win32 API.
30 typedef struct _PROCESS_INFORMATION
36 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
39 extern TextEditor *textEditor;
40 extern Main *mainWindow;
41 extern QString tmpVymDir;
42 extern QString clipboardDir;
43 extern QString clipboardFile;
44 extern bool clipboardEmpty;
45 extern int statusbarTime;
46 extern FlagRow *standardFlagsMaster;
47 extern FlagRow *systemFlagsMaster;
48 extern QString vymName;
49 extern QString vymVersion;
50 extern QString vymBuildDate;
53 QMenu* branchContextMenu;
54 QMenu* branchAddContextMenu;
55 QMenu* branchRemoveContextMenu;
56 QMenu* branchLinksContextMenu;
57 QMenu* branchXLinksContextMenuEdit;
58 QMenu* branchXLinksContextMenuFollow;
59 QMenu* floatimageContextMenu;
60 QMenu* canvasContextMenu;
61 QMenu* fileLastMapsMenu;
62 QMenu* fileImportMenu;
63 QMenu* fileExportMenu;
66 extern Settings settings;
67 extern Options options;
68 extern ImageIO imageIO;
70 extern QDir vymBaseDir;
71 extern QDir lastImageDir;
72 extern QDir lastFileDir;
73 #if defined(Q_OS_WIN32)
74 extern QDir vymInstallDir;
76 extern QString iconPath;
77 extern QString flagsPath;
80 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
81 QMainWindow(parent,name,f)
85 setCaption ("VYM - View Your Mind");
87 // Load window settings
88 #if defined(Q_OS_WIN32)
89 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
91 setWindowState(Qt::WindowMaximized);
96 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
97 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
100 // Sometimes we may need to remember old selections
104 currentColor=Qt::black;
106 // Create unique temporary directory
108 tmpVymDir=makeTmpDir (ok,"vym");
111 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
114 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
116 // Create direcctory for clipboard
117 clipboardDir=tmpVymDir+"/clipboard";
118 clipboardFile="map.xml";
119 QDir d(clipboardDir);
120 d.mkdir (clipboardDir,true);
121 makeSubDirs (clipboardDir);
126 // Satellite windows //////////////////////////////////////////
128 historyWindow=new HistoryWindow();
129 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
132 branchPropertyWindow = new BranchPropertyWindow();
133 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
135 // Connect TextEditor, so that we can update flags if text changes
136 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
137 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
139 // Connect HistoryWindow, so that we can update flags
140 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
143 // Initialize script editor
144 scriptEditor = new SimpleScriptEditor();
145 scriptEditor->move (50,50);
147 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
148 this, SLOT( runScript( QString ) ) );
151 // Initialize Find window
152 findWindow=new FindWindow(NULL);
153 findWindow->move (x(),y()+70);
154 connect (findWindow, SIGNAL( findButton(QString) ),
155 this, SLOT(editFind(QString) ) );
156 connect (findWindow, SIGNAL( somethingChanged() ),
157 this, SLOT(editFindChanged() ) );
159 // Initialize some settings, which are platform dependant
162 // application to open URLs
163 p="/mainwindow/readerURL";
164 #if defined(Q_OS_LINUX)
165 s=settings.value (p,"xdg-open").toString();
167 #if defined(Q_OS_MACX)
168 s=settings.value (p,"/usr/bin/open").toString();
171 #if defined(Q_OS_WIN32)
172 // Assume that system has been set up so that
173 // Explorer automagically opens up the URL
174 // in the user's preferred browser.
175 s=settings.value (p,"explorer").toString();
177 s=settings.value (p,"mozilla").toString();
181 settings.setValue( p,s);
183 // application to open PDFs
184 p="/mainwindow/readerPDF";
185 #if defined(Q_OS_LINUX)
186 s=settings.value (p,"xdg-open").toString();
188 #if defined(Q_OS_MACX)
189 s=settings.value (p,"/usr/bin/open").toString();
190 #elif defined(Q_OS_WIN32)
191 s=settings.value (p,"acrord32").toString();
193 s=settings.value (p,"acroread").toString();
196 settings.setValue( p,s);
198 // width of xLinksMenu
201 // Create tab widget which holds the maps
202 tabWidget= new QTabWidget (this);
203 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
204 this, SLOT( editorChanged( QWidget * ) ) );
206 setCentralWidget(tabWidget);
210 setupFormatActions();
214 setupNetworkActions();
215 setupSettingsActions();
218 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
221 // Status bar and progress bar there
224 progressBar=new QProgressBar;
226 statusBar()->addPermanentWidget(progressBar);
228 restoreState (settings.value("/mainwindow/state",0).toByteArray());
237 #if defined(Q_OS_WIN32)
238 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
240 settings.setValue ("/mainwindow/geometry/size", size());
241 settings.setValue ("/mainwindow/geometry/pos", pos());
242 settings.setValue ("/mainwindow/state",saveState(0));
244 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
245 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
246 settings.setValue( "/version/version", vymVersion );
247 settings.setValue( "/version/builddate", vymBuildDate );
249 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
250 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
251 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
252 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
253 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
254 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
255 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
256 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
258 //TODO save scriptEditor settings
260 // call the destructors
262 delete historyWindow;
263 delete branchPropertyWindow;
266 // Remove temporary directory
267 removeDir (QDir(tmpVymDir));
270 void Main::loadCmdLine()
272 /* TODO draw some kind of splashscreen while loading...
278 QStringList flist=options.getFileList();
279 QStringList::Iterator it=flist.begin();
281 while (it !=flist.end() )
283 fileLoad (*it, NewMap);
289 void Main::statusMessage(const QString &s)
291 // Surpress messages while progressbar during
293 if (progressMin==progressMax)
294 statusBar()->message( s);
297 void Main::setProgressMinimum (int min)
299 progressBar->setMinimum(min);
303 void Main::setProgressMaximum (int max)
305 progressBar->setMaximum(max);
309 statusBar()->addPermanentWidget(progressBar);
314 void Main::setProgressValue (int v)
316 progressBar->setValue (v);
319 void Main::removeProgressBar()
322 statusBar()->removeWidget(progressBar);
323 progressMax=progressMin=0;
326 void Main::closeEvent (QCloseEvent* )
332 void Main::setupFileActions()
334 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
335 QToolBar *tb = addToolBar( tr ("&Map") );
336 tb->setObjectName ("mapTB");
339 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
340 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
341 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
343 fileMenu->addAction (a);
344 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
346 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
347 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
348 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
349 fileMenu->addAction (a);
350 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
353 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
354 a->setStatusTip (tr( "Open","Status tip File menu" ) );
355 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
357 fileMenu->addAction (a);
358 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
360 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
361 fileMenu->addSeparator();
363 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
364 a->setStatusTip ( tr( "Save","Status tip file menu" ));
365 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
367 fileMenu->addAction (a);
368 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
371 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
372 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
373 fileMenu->addAction (a);
374 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
376 fileMenu->addSeparator();
378 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
380 a = new QAction(tr("KDE 3 Bookmarks"), this);
381 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
382 a->addTo (fileImportMenu);
383 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
385 a = new QAction(tr("KDE 4 Bookmarks"), this);
386 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
387 a->addTo (fileImportMenu);
388 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
390 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
392 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
393 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
394 a->addTo (fileImportMenu);
395 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
398 a = new QAction("Freemind...",this);
399 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
400 fileImportMenu->addAction (a);
401 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
403 a = new QAction("Mind Manager...",this);
404 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
405 fileImportMenu->addAction (a);
406 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
408 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
409 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
410 fileImportMenu->addAction (a);
411 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
413 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
415 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
416 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
417 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
418 fileExportMenu->addAction (a);
420 a = new QAction( "Open Office...", this);
421 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
422 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
423 fileExportMenu->addAction (a);
425 a = new QAction( "Webpage (XHTML)...",this );
426 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
427 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
428 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
429 fileExportMenu->addAction (a);
431 a = new QAction( "Text (ASCII)...", this);
432 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
433 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
434 fileExportMenu->addAction (a);
436 a = new QAction( "Spreadsheet (CSV)...", this);
437 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
438 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
439 fileExportMenu->addAction (a);
441 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
442 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
443 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
444 fileExportMenu->addAction (a);
446 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
447 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
448 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
449 fileExportMenu->addAction (a);
451 a = new QAction( "Taskjuggler...", this );
452 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
453 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
454 fileExportMenu->addAction (a);
456 a = new QAction( "LaTeX...", this);
457 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
458 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
459 fileExportMenu->addAction (a);
461 a = new QAction( "XML..." , this );
462 a->setStatusTip (tr( "Export as %1").arg("XML"));
463 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
464 fileExportMenu->addAction (a);
466 fileMenu->addSeparator();
468 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
469 a->setStatusTip ( tr( "Print" ,"File menu") );
470 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
472 fileMenu->addAction (a);
473 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
476 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
477 a->setStatusTip (tr( "Close Map" ) );
478 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
479 fileMenu->addAction (a);
480 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
482 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
483 a->setStatusTip ( tr( "Exit")+" "+vymName );
484 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
485 fileMenu->addAction (a);
486 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
491 void Main::setupEditActions()
493 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
494 tb->setLabel( "Edit Actions" );
495 tb->setObjectName ("actionsTB");
496 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
500 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
501 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
502 a->setStatusTip (tr( "Undo" ) );
503 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
504 a->setEnabled (false);
506 editMenu->addAction (a);
509 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
510 a->setStatusTip (tr( "Redo" ));
511 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
513 editMenu->addAction (a);
514 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
517 editMenu->addSeparator();
518 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
519 a->setStatusTip ( tr( "Copy" ) );
520 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
521 a->setEnabled (false);
523 editMenu->addAction (a);
524 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
527 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
528 a->setStatusTip ( tr( "Cut" ) );
529 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
530 a->setEnabled (false);
532 editMenu->addAction (a);
534 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
536 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
537 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
538 a->setStatusTip ( tr( "Paste" ) );
539 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
540 a->setEnabled (false);
542 editMenu->addAction (a);
546 // Shortcuts to modify heading:
547 a = new QAction(tr( "Edit heading","Edit menu" ),this);
548 a->setStatusTip ( tr( "edit Heading" ));
549 a->setShortcut ( Qt::Key_Enter); //Edit heading
550 // a->setShortcutContext (Qt::WindowShortcut);
552 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
553 actionListBranches.append(a);
554 a = new QAction( tr( "Edit heading","Edit menu" ), this);
555 a->setStatusTip (tr( "edit Heading" ));
556 a->setShortcut (Qt::Key_Return ); //Edit heading
557 //a->setShortcutContext (Qt::WindowShortcut);
559 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
560 actionListBranches.append(a);
561 editMenu->addAction (a);
564 a = new QAction( tr( "Edit heading","Edit menu" ), this);
565 a->setStatusTip (tr( "edit Heading" ));
566 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
567 a->setShortcutContext (Qt::WindowShortcut);
569 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
570 actionListBranches.append(a);
573 // Shortcut to delete selection
574 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
575 a->setStatusTip (tr( "Delete Selection" ));
576 a->setShortcut ( Qt::Key_Delete); //Delete selection
577 a->setShortcutContext (Qt::WindowShortcut);
579 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
582 // Shortcut to add mapcenter
583 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
584 a->setShortcut ( Qt::Key_M);
585 a->setShortcutContext (Qt::WindowShortcut);
586 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
587 //actionListBranches.append(a);
589 actionAddMapCenter = a;
592 // Shortcut to add branch
593 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
594 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
595 alt->setShortcut (Qt::Key_A); //Add branch
596 alt->setShortcutContext (Qt::WindowShortcut);
598 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
599 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
600 a->setStatusTip ( tr( "Add a branch as child of selection" ));
601 a->setShortcut (Qt::Key_Insert); //Add branch
602 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
603 actionListBranches.append(a);
604 #if defined (Q_OS_MACX)
605 // In OSX show different shortcut in menues, the keys work indepently always
610 editMenu->addAction (actionAddBranch);
611 tb->addAction (actionAddBranch);
614 // Add branch by inserting it at selection
615 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
616 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
617 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
618 a->setShortcutContext (Qt::WindowShortcut);
620 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
621 a->setEnabled (false);
622 actionListBranches.append(a);
623 actionAddBranchBefore=a;
624 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
625 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
626 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
627 a->setShortcutContext (Qt::WindowShortcut);
629 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
630 actionListBranches.append(a);
633 a = new QAction(tr( "Add branch above","Edit menu" ), this);
634 a->setStatusTip ( tr( "Add a branch above selection" ));
635 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
636 a->setShortcutContext (Qt::WindowShortcut);
638 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
639 a->setEnabled (false);
640 actionListBranches.append(a);
641 actionAddBranchAbove=a;
642 a = new QAction(tr( "Add branch above","Edit menu" ), this);
643 a->setStatusTip ( tr( "Add a branch above selection" ));
644 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
645 a->setShortcutContext (Qt::WindowShortcut);
647 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
648 actionListBranches.append(a);
651 a = new QAction(tr( "Add branch below","Edit menu" ), this);
652 a->setStatusTip ( tr( "Add a branch below selection" ));
653 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
654 a->setShortcutContext (Qt::WindowShortcut);
656 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
657 a->setEnabled (false);
658 actionListBranches.append(a);
659 actionAddBranchBelow=a;
660 a = new QAction(tr( "Add branch below","Edit menu" ), this);
661 a->setStatusTip ( tr( "Add a branch below selection" ));
662 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
663 a->setShortcutContext (Qt::WindowShortcut);
665 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
666 actionListBranches.append(a);
668 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
669 a->setStatusTip ( tr( "Move branch up" ) );
670 a->setShortcut (Qt::Key_PageUp ); // Move branch up
671 a->setEnabled (false);
673 editMenu->addAction (a);
674 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
677 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
678 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
679 a->setStatusTip (tr( "Move branch down" ) );
680 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
681 a->setEnabled (false);
683 editMenu->addAction (a);
686 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
687 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
688 a->setEnabled (true);
690 editMenu->addAction (a);
691 actionSortChildren=a;
693 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
694 alt->setShortcut ( Qt::Key_S ); // Scroll branch
695 alt->setStatusTip (tr( "Scroll branch" ));
696 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
697 #if defined(Q_OS_MACX)
698 actionToggleScroll=alt;
700 actionToggleScroll=a;
702 actionToggleScroll->setEnabled (false);
703 actionToggleScroll->setToggleAction(true);
704 tb->addAction (actionToggleScroll);
705 editMenu->addAction ( actionToggleScroll);
706 editMenu->addAction (actionToggleScroll);
709 actionListBranches.append(actionToggleScroll);
711 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
712 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
713 a->setStatusTip (tr( "Expand all branches" ));
714 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
716 actionExpandAll->setEnabled (false);
717 actionExpandAll->setToggleAction(false);
718 //tb->addAction (actionExpandAll);
719 editMenu->addAction ( actionExpandAll);
721 actionListBranches.append(actionExpandAll);
724 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
725 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
726 editMenu->addAction (a);
727 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
729 editMenu->addSeparator();
731 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
732 a->setStatusTip (tr( "Find" ) );
733 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
734 editMenu->addAction (a);
735 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
737 editMenu->addSeparator();
739 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
740 a->setShortcut (Qt::CTRL + Qt::Key_U );
741 a->setShortcut (tr( "Open URL" ));
744 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
747 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
748 a->setStatusTip (tr( "Open URL in new tab" ));
749 //a->setShortcut (Qt::CTRL+Qt::Key_U );
751 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
754 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
755 a->setStatusTip (tr( "Open all URLs in subtree" ));
757 actionListBranches.append(a);
758 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
759 actionOpenMultipleURLTabs=a;
761 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
762 a->setStatusTip ( tr( "Edit URL" ) );
763 a->setShortcut ( Qt::Key_U );
764 a->setShortcutContext (Qt::WindowShortcut);
765 actionListBranches.append(a);
767 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
770 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
771 a->setStatusTip ( tr( "Edit local URL" ) );
772 a->setShortcut (Qt::SHIFT + Qt::Key_U );
773 a->setShortcutContext (Qt::WindowShortcut);
774 actionListBranches.append(a);
776 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
779 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
780 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
781 a->setEnabled (false);
782 actionListBranches.append(a);
783 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
786 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
787 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
788 a->setEnabled (false);
789 actionListBranches.append(a);
790 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
791 actionBugzilla2URL=a;
793 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
794 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
795 a->setEnabled (false);
796 actionListBranches.append(a);
797 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
800 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
801 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
803 a->setEnabled (false);
804 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
807 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
808 a->setStatusTip ( tr( "Open all vym links in subtree" ));
809 a->setEnabled (false);
810 actionListBranches.append(a);
811 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
812 actionOpenMultipleVymLinks=a;
815 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
816 a->setEnabled (false);
817 a->setStatusTip ( tr( "Edit link to another vym map" ));
818 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
819 actionListBranches.append(a);
822 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
823 a->setStatusTip ( tr( "Delete link to another vym map" ));
824 a->setEnabled (false);
825 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
826 actionDeleteVymLink=a;
828 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
829 a->setStatusTip ( tr( "Hide object in exports" ) );
830 a->setShortcut (Qt::Key_H );
831 a->setToggleAction(true);
833 a->setEnabled (false);
834 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
835 actionToggleHideExport=a;
837 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
838 a->setStatusTip ( tr( "Edit Map Info" ));
839 a->setEnabled (true);
840 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
843 // Import at selection (adding to selection)
844 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
845 a->setStatusTip (tr( "Add map at selection" ));
846 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
847 a->setEnabled (false);
848 actionListBranches.append(a);
851 // Import at selection (replacing selection)
852 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
853 a->setStatusTip (tr( "Replace selection with map" ));
854 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
855 a->setEnabled (false);
856 actionListBranches.append(a);
857 actionImportReplace=a;
860 a = new QAction( tr( "Save selection","Edit menu" ), this);
861 a->setStatusTip (tr( "Save selection" ));
862 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
863 a->setEnabled (false);
864 actionListBranches.append(a);
867 // Only remove branch, not its children
868 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
869 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
870 a->setShortcut (Qt::ALT + Qt::Key_Delete );
871 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
872 a->setEnabled (false);
874 actionListBranches.append(a);
875 actionDeleteKeepChildren=a;
877 // Only remove children of a branch
878 a = new QAction( tr( "Remove children","Edit menu" ), this);
879 a->setStatusTip (tr( "Remove children of branch" ));
880 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
881 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
882 a->setEnabled (false);
883 actionListBranches.append(a);
884 actionDeleteChildren=a;
886 a = new QAction( tr( "Add Image...","Edit menu" ), this);
887 a->setStatusTip (tr( "Add Image" ));
888 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
891 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
892 a->setStatusTip (tr( "Set properties for selection" ));
893 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
894 a->setShortcutContext (Qt::WindowShortcut);
895 a->setToggleAction (true);
897 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
898 actionViewTogglePropertyWindow=a;
902 void Main::setupFormatActions()
904 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
906 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
907 tb->setObjectName ("formatTB");
910 pix.fill (Qt::black);
911 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
912 a->setStatusTip ( tr( "Set Color" ));
913 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
915 formatMenu->addAction (a);
917 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
918 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
919 a->setShortcut (Qt::CTRL + Qt::Key_K );
920 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
921 a->setEnabled (false);
923 formatMenu->addAction (a);
924 actionListBranches.append(a);
925 actionFormatPickColor=a;
927 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
928 a->setStatusTip ( tr( "Color branch" ) );
929 a->setShortcut (Qt::CTRL + Qt::Key_B);
930 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
931 a->setEnabled (false);
933 formatMenu->addAction (a);
934 actionListBranches.append(a);
935 actionFormatColorSubtree=a;
937 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
938 a->setStatusTip ( tr( "Color Subtree" ));
939 a->setShortcut (Qt::CTRL + Qt::Key_T);
940 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
941 a->setEnabled (false);
942 formatMenu->addAction (a);
944 actionListBranches.append(a);
945 actionFormatColorSubtree=a;
947 formatMenu->addSeparator();
948 actionGroupFormatLinkStyles=new QActionGroup ( this);
949 actionGroupFormatLinkStyles->setExclusive (true);
950 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
951 a->setStatusTip (tr( "Line" ));
952 a->setToggleAction(true);
953 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
954 formatMenu->addAction (a);
955 actionFormatLinkStyleLine=a;
956 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
957 a->setStatusTip (tr( "Line" ));
958 a->setToggleAction(true);
959 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
960 formatMenu->addAction (a);
961 actionFormatLinkStyleParabel=a;
962 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
963 a->setStatusTip (tr( "PolyLine" ));
964 a->setToggleAction(true);
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
966 formatMenu->addAction (a);
967 actionFormatLinkStylePolyLine=a;
968 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
969 a->setStatusTip (tr( "PolyParabel" ) );
970 a->setToggleAction(true);
971 a->setChecked (true);
972 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
973 formatMenu->addAction (a);
974 actionFormatLinkStylePolyParabel=a;
976 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
977 a->setStatusTip (tr( "Hide link" ));
978 a->setToggleAction(true);
979 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
980 actionFormatHideLinkUnselected=a;
982 formatMenu->addSeparator();
983 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
984 a->setStatusTip (tr( "Use same color for links and headings" ));
985 a->setToggleAction(true);
986 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
987 formatMenu->addAction (a);
988 actionFormatLinkColorHint=a;
990 pix.fill (Qt::white);
991 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
992 a->setStatusTip (tr( "Set Link Color" ));
993 formatMenu->addAction (a);
994 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
995 actionFormatLinkColor=a;
997 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
998 a->setStatusTip (tr( "Set Selection Color" ));
999 formatMenu->addAction (a);
1000 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1001 actionFormatSelectionColor=a;
1003 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1004 a->setStatusTip (tr( "Set Background Color" ));
1005 formatMenu->addAction (a);
1006 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1007 actionFormatBackColor=a;
1009 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1010 a->setStatusTip (tr( "Set Background image" ));
1011 formatMenu->addAction (a);
1012 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1013 actionFormatBackImage=a;
1017 void Main::setupViewActions()
1019 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1020 tb->setLabel( "View Actions" );
1021 tb->setObjectName ("viewTB");
1022 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1025 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1026 a->setStatusTip ( tr( "Zoom reset" ) );
1027 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1029 viewMenu->addAction (a);
1030 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1032 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1033 a->setStatusTip (tr( "Zoom in" ));
1034 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1036 viewMenu->addAction (a);
1037 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1039 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1040 a->setStatusTip (tr( "Zoom out" ));
1041 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1043 viewMenu->addAction (a);
1044 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1046 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1047 a->setStatusTip (tr( "Show selection" ));
1048 a->setShortcut (Qt::Key_Period);
1050 viewMenu->addAction (a);
1051 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1053 viewMenu->addSeparator();
1055 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1056 a->setStatusTip ( tr( "Show Note Editor" ));
1057 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1058 a->setToggleAction(true);
1060 viewMenu->addAction (a);
1061 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1062 actionViewToggleNoteEditor=a;
1064 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1065 a->setStatusTip ( tr( "Show History Window" ));
1066 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1067 a->setToggleAction(true);
1069 viewMenu->addAction (a);
1070 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1071 actionViewToggleHistoryWindow=a;
1073 viewMenu->addAction (actionViewTogglePropertyWindow);
1075 viewMenu->addSeparator();
1077 a = new QAction(tr( "Antialiasing","View action" ),this );
1078 a->setStatusTip ( tr( "Antialiasing" ));
1079 a->setToggleAction(true);
1080 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1081 viewMenu->addAction (a);
1082 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1083 actionViewToggleAntiAlias=a;
1085 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1086 a->setStatusTip (a->text());
1087 a->setToggleAction(true);
1088 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1089 viewMenu->addAction (a);
1090 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1091 actionViewToggleSmoothPixmapTransform=a;
1093 a = new QAction(tr( "Next Map","View action" ), this);
1094 a->setStatusTip (a->text());
1095 a->setShortcut (Qt::ALT + Qt::Key_N );
1096 viewMenu->addAction (a);
1097 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1099 a = new QAction (tr( "Previous Map","View action" ), this );
1100 a->setStatusTip (a->text());
1101 a->setShortcut (Qt::ALT + Qt::Key_P );
1102 viewMenu->addAction (a);
1103 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1107 void Main::setupModeActions()
1109 //QPopupMenu *menu = new QPopupMenu( this );
1110 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1112 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1113 tb->setObjectName ("modesTB");
1115 actionGroupModModes=new QActionGroup ( this);
1116 actionGroupModModes->setExclusive (true);
1117 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1118 a->setShortcut (Qt::Key_J);
1119 a->setStatusTip ( tr( "Use modifier to color branches" ));
1120 a->setToggleAction(true);
1123 actionModModeColor=a;
1125 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1126 a->setShortcut( Qt::Key_K);
1127 a->setStatusTip( tr( "Use modifier to copy" ));
1128 a->setToggleAction(true);
1130 actionModModeCopy=a;
1132 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1133 a->setShortcut (Qt::Key_L);
1134 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1135 a->setToggleAction(true);
1137 actionModModeXLink=a;
1141 void Main::setupFlagActions()
1143 // Create System Flags
1146 Flag *flag=new Flag;;
1148 flag->load(QPixmap(flagsPath+"flag-note.png"));
1149 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1151 flag->load(QPixmap(flagsPath+"flag-url.png"));
1152 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1154 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1155 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1157 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1158 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1160 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1161 setupFlag (flag,tb,"system-tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1163 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1164 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1166 // Create Standard Flags
1167 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1168 tb->setObjectName ("standardFlagTB");
1169 standardFlagsMaster->setToolBar (tb);
1172 flag->load(flagsPath+"flag-exclamationmark.png");
1173 flag->setGroup("standard-mark");
1174 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1176 flag->load(flagsPath+"flag-questionmark.png");
1177 flag->setGroup("standard-mark");
1178 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1180 flag->load(flagsPath+"flag-hook-green.png");
1181 flag->setGroup("standard-hook");
1182 setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
1184 flag->load(flagsPath+"flag-cross-red.png");
1185 flag->setGroup("standard-hook");
1186 setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
1189 flag->load(flagsPath+"flag-stopsign.png");
1190 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1192 flag->load(flagsPath+"flag-smiley-good.png");
1193 flag->setGroup("standard-smiley");
1194 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1196 flag->load(flagsPath+"flag-smiley-sad.png");
1197 flag->setGroup("standard-smiley");
1198 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1200 flag->load(flagsPath+"flag-smiley-omg.png");
1201 flag->setGroup("standard-smiley");
1202 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1203 // Original omg.png (in KDE emoticons)
1206 flag->load(flagsPath+"flag-kalarm.png");
1207 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1209 flag->load(flagsPath+"flag-phone.png");
1210 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1212 flag->load(flagsPath+"flag-lamp.png");
1213 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1215 flag->load(flagsPath+"flag-arrow-up.png");
1216 flag->setGroup("standard-arrow");
1217 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1219 flag->load(flagsPath+"flag-arrow-down.png");
1220 flag->setGroup("standard-arrow");
1221 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1223 flag->load(flagsPath+"flag-arrow-2up.png");
1224 flag->setGroup("standard-arrow");
1225 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1227 flag->load(flagsPath+"flag-arrow-2down.png");
1228 flag->setGroup("standard-arrow");
1229 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1232 flag->load(flagsPath+"flag-thumb-up.png");
1233 flag->setGroup("standard-thumb");
1234 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1236 flag->load(flagsPath+"flag-thumb-down.png");
1237 flag->setGroup("standard-thumb");
1238 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1241 flag->load(flagsPath+"flag-rose.png");
1242 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1244 flag->load(flagsPath+"flag-heart.png");
1245 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1247 flag->load(flagsPath+"flag-present.png");
1248 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1250 flag->load(flagsPath+"flag-flash.png");
1251 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1253 // Original: xsldbg_output.png
1254 flag->load(flagsPath+"flag-info.png");
1255 setupFlag (flag,tb,"inflag",tr("Info","Standardflag"));
1257 // Original khelpcenter.png
1258 flag->load(flagsPath+"flag-lifebelt.png");
1259 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1263 flag->load(flagsPath+"freemind/warning.png");
1264 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1266 for (int i=1; i<8; i++)
1268 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1269 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1272 flag->load(flagsPath+"freemind/back.png");
1273 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1275 flag->load(flagsPath+"freemind/forward.png");
1276 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1278 flag->load(flagsPath+"freemind/attach.png");
1279 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1281 flag->load(flagsPath+"freemind/clanbomber.png");
1282 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1284 flag->load(flagsPath+"freemind/desktopnew.png");
1285 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1287 flag->load(flagsPath+"freemind/flag.png");
1288 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1291 flag->load(flagsPath+"freemind/gohome.png");
1292 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1295 flag->load(flagsPath+"freemind/kaddressbook.png");
1296 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1298 flag->load(flagsPath+"freemind/knotify.png");
1299 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1301 flag->load(flagsPath+"freemind/korn.png");
1302 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1304 flag->load(flagsPath+"freemind/mail.png");
1305 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1307 flag->load(flagsPath+"freemind/password.png");
1308 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1310 flag->load(flagsPath+"freemind/pencil.png");
1311 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1313 flag->load(flagsPath+"freemind/stop.png");
1314 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1316 flag->load(flagsPath+"freemind/wizard.png");
1317 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1319 flag->load(flagsPath+"freemind/xmag.png");
1320 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1322 flag->load(flagsPath+"freemind/bell.png");
1323 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1325 flag->load(flagsPath+"freemind/bookmark.png");
1326 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1328 flag->load(flagsPath+"freemind/penguin.png");
1329 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1331 flag->load(flagsPath+"freemind/licq.png");
1332 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1335 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1337 flag->setName(name);
1338 flag->setToolTip (tooltip);
1342 a=new QAction (flag->getPixmap(),name,this);
1345 flag->setAction (a);
1346 a->setCheckable(true);
1347 a->setObjectName(name);
1348 a->setToolTip(tooltip);
1349 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1350 standardFlagsMaster->addFlag (flag);
1354 systemFlagsMaster->addFlag (flag);
1359 void Main::setupNetworkActions()
1361 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1363 QMenu *netMenu = menuBar()->addMenu( "Network" );
1367 a = new QAction( "Start TCPserver for MapEditor",this);
1368 //a->setStatusTip ( "Set application to open pdf files"));
1369 a->setShortcut ( Qt::Key_T ); //New TCP server
1370 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1371 netMenu->addAction (a);
1373 a = new QAction( "Connect MapEditor to server",this);
1374 //a->setStatusTip ( "Set application to open pdf files"));
1375 a->setShortcut ( Qt::Key_C ); // Connect to server
1376 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1377 netMenu->addAction (a);
1381 void Main::setupSettingsActions()
1383 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1387 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1388 a->setStatusTip ( tr( "Set application to open pdf files"));
1389 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1390 settingsMenu->addAction (a);
1392 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1393 a->setStatusTip( tr( "Set application to open external links"));
1394 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1395 settingsMenu->addAction (a);
1397 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1398 a->setStatusTip( tr( "Set path for macros"));
1399 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1400 settingsMenu->addAction (a);
1402 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1403 a->setStatusTip( tr( "Set number of undo levels"));
1404 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1405 settingsMenu->addAction (a);
1407 settingsMenu->addSeparator();
1409 a = new QAction( tr( "Autosave","Settings action"), this);
1410 a->setStatusTip( tr( "Autosave"));
1411 a->setToggleAction(true);
1412 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1413 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1414 settingsMenu->addAction (a);
1415 actionSettingsAutosaveToggle=a;
1417 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1418 a->setStatusTip( tr( "Autosave time"));
1419 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1420 settingsMenu->addAction (a);
1421 actionSettingsAutosaveTime=a;
1423 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1424 a->setStatusTip( tr( "Write backup file on save"));
1425 a->setToggleAction(true);
1426 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1427 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1428 settingsMenu->addAction (a);
1429 actionSettingsWriteBackupFile=a;
1431 settingsMenu->addSeparator();
1433 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1434 a->setStatusTip( tr( "Edit branch after adding it" ));
1435 a->setToggleAction(true);
1436 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1437 settingsMenu->addAction (a);
1438 actionSettingsAutoEditNewBranch=a;
1440 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1441 a->setStatusTip( tr( "Select branch after adding it" ));
1442 a->setToggleAction(true);
1443 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1444 settingsMenu->addAction (a);
1445 actionSettingsAutoSelectNewBranch=a;
1447 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1448 a->setStatusTip( tr( "Select heading before editing" ));
1449 a->setToggleAction(true);
1450 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1451 settingsMenu->addAction (a);
1452 actionSettingsAutoSelectText=a;
1454 a= new QAction( tr( "Delete key","Settings action" ), this);
1455 a->setStatusTip( tr( "Delete key for deleting branches" ));
1456 a->setToggleAction(true);
1457 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1458 settingsMenu->addAction (a);
1459 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1460 actionSettingsUseDelKey=a;
1462 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1463 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1464 a->setToggleAction(true);
1465 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1466 settingsMenu->addAction (a);
1467 actionSettingsUseFlagGroups=a;
1469 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1470 a->setStatusTip( tr( "Use hide flag during exports " ));
1471 a->setToggleAction(true);
1472 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1473 settingsMenu->addAction (a);
1474 actionSettingsUseHideExport=a;
1476 a = new QAction( tr( "Animation","Settings action"), this);
1477 a->setStatusTip( tr( "Animation"));
1478 a->setToggleAction(true);
1479 a->setOn (settings.value("/animation/use",false).toBool() );
1480 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1481 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1483 settingsMenu->addAction (a);
1485 actionSettingsUseAnimation=a;
1489 void Main::setupTestActions()
1491 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1494 a = new QAction( "Test function 1" , this);
1495 a->setStatusTip( "Call test function 1" );
1496 testMenu->addAction (a);
1497 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1499 a = new QAction( "Test function 2" , this);
1500 a->setStatusTip( "Call test function 2" );
1501 testMenu->addAction (a);
1502 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1504 a = new QAction( "Command" , this);
1505 a->setStatusTip( "Enter command to call in editor" );
1506 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1507 testMenu->addAction (a);
1511 void Main::setupHelpActions()
1513 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1516 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1517 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1518 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1519 helpMenu->addAction (a);
1521 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1522 a->setStatusTip( tr( "Open VYM example maps " ));
1523 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1524 helpMenu->addAction (a);
1526 a = new QAction( tr( "About VYM","Help action" ), this);
1527 a->setStatusTip( tr( "About VYM")+vymName);
1528 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1529 helpMenu->addAction (a);
1531 a = new QAction( tr( "About QT","Help action" ), this);
1532 a->setStatusTip( tr( "Information about QT toolkit" ));
1533 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1534 helpMenu->addAction (a);
1538 void Main::setupContextMenus()
1542 // Context Menu for branch or mapcenter
1543 branchContextMenu =new QMenu (this);
1544 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1545 branchContextMenu->addSeparator();
1548 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1549 branchAddContextMenu->addAction (actionPaste );
1550 branchAddContextMenu->addAction ( actionAddMapCenter );
1551 branchAddContextMenu->addAction ( actionAddBranch );
1552 branchAddContextMenu->addAction ( actionAddBranchBefore );
1553 branchAddContextMenu->addAction ( actionAddBranchAbove);
1554 branchAddContextMenu->addAction ( actionAddBranchBelow );
1555 branchAddContextMenu->addSeparator();
1556 branchAddContextMenu->addAction ( actionImportAdd );
1557 branchAddContextMenu->addAction ( actionImportReplace );
1560 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1561 branchRemoveContextMenu->addAction (actionCut);
1562 branchRemoveContextMenu->addAction ( actionDelete );
1563 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1564 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1567 actionSaveBranch->addTo( branchContextMenu );
1568 actionFileNewCopy->addTo (branchContextMenu );
1570 branchContextMenu->addSeparator();
1571 branchContextMenu->addAction ( actionLoadImage);
1573 // Submenu for Links (URLs, vymLinks)
1574 branchLinksContextMenu =new QMenu (this);
1576 branchContextMenu->addSeparator();
1577 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1578 branchLinksContextMenu->addAction ( actionOpenURL );
1579 branchLinksContextMenu->addAction ( actionOpenURLTab );
1580 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1581 branchLinksContextMenu->addAction ( actionURL );
1582 branchLinksContextMenu->addAction ( actionLocalURL );
1583 branchLinksContextMenu->addAction ( actionHeading2URL );
1584 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1585 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1587 branchLinksContextMenu->addAction ( actionFATE2URL );
1589 branchLinksContextMenu->addSeparator();
1590 branchLinksContextMenu->addAction ( actionOpenVymLink );
1591 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1592 branchLinksContextMenu->addAction ( actionVymLink );
1593 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1596 // Context Menu for XLinks in a branch menu
1597 // This will be populated "on demand" in MapEditor::updateActions
1598 branchContextMenu->addSeparator();
1599 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1600 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1601 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1602 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1605 // Context menu for floatimage
1606 floatimageContextMenu =new QMenu (this);
1607 a= new QAction (tr ("Save image","Context action"),this);
1608 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1609 floatimageContextMenu->addAction (a);
1611 floatimageContextMenu->addSeparator();
1612 actionCopy->addTo( floatimageContextMenu );
1613 actionCut->addTo( floatimageContextMenu );
1615 floatimageContextMenu->addSeparator();
1616 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1619 // Context menu for canvas
1620 canvasContextMenu =new QMenu (this);
1621 actionAddMapCenter->addTo( canvasContextMenu );
1622 actionMapInfo->addTo( canvasContextMenu );
1623 canvasContextMenu->insertSeparator();
1624 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1625 canvasContextMenu->insertSeparator();
1626 actionFormatLinkColorHint->addTo( canvasContextMenu );
1627 actionFormatLinkColor->addTo( canvasContextMenu );
1628 actionFormatSelectionColor->addTo( canvasContextMenu );
1629 actionFormatBackColor->addTo( canvasContextMenu );
1630 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1632 // Menu for last opened files
1634 for (int i = 0; i < MaxRecentFiles; ++i)
1636 recentFileActions[i] = new QAction(this);
1637 recentFileActions[i]->setVisible(false);
1638 fileLastMapsMenu->addAction(recentFileActions[i]);
1639 connect(recentFileActions[i], SIGNAL(triggered()),
1640 this, SLOT(fileLoadRecent()));
1642 setupRecentMapsMenu();
1645 void Main::setupRecentMapsMenu()
1647 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1649 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1651 for (int i = 0; i < numRecentFiles; ++i) {
1652 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1653 recentFileActions[i]->setText(text);
1654 recentFileActions[i]->setData(files[i]);
1655 recentFileActions[i]->setVisible(true);
1657 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1658 recentFileActions[j]->setVisible(false);
1661 void Main::setupMacros()
1663 for (int i = 0; i <= 11; i++)
1665 macroActions[i] = new QAction(this);
1666 macroActions[i]->setData(i);
1667 addAction (macroActions[i]);
1668 connect(macroActions[i], SIGNAL(triggered()),
1669 this, SLOT(callMacro()));
1671 macroActions[0]->setShortcut ( Qt::Key_F1 );
1672 macroActions[1]->setShortcut ( Qt::Key_F2 );
1673 macroActions[2]->setShortcut ( Qt::Key_F3 );
1674 macroActions[3]->setShortcut ( Qt::Key_F4 );
1675 macroActions[4]->setShortcut ( Qt::Key_F5 );
1676 macroActions[5]->setShortcut ( Qt::Key_F6 );
1677 macroActions[6]->setShortcut ( Qt::Key_F7 );
1678 macroActions[7]->setShortcut ( Qt::Key_F8 );
1679 macroActions[8]->setShortcut ( Qt::Key_F9 );
1680 macroActions[9]->setShortcut ( Qt::Key_F10 );
1681 macroActions[10]->setShortcut ( Qt::Key_F11 );
1682 macroActions[11]->setShortcut ( Qt::Key_F12 );
1685 void Main::hideEvent (QHideEvent * )
1687 if (!textEditor->isMinimized() ) textEditor->hide();
1690 void Main::showEvent (QShowEvent * )
1692 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1696 MapEditor* Main::currentMapEditor() const
1698 if ( tabWidget->currentPage())
1699 return tabModel.at(tabWidget->currentIndex())->getMapEditor();
1703 VymModel* Main::currentModel() const
1705 if ( tabWidget->currentPage())
1706 return tabModel.at(tabWidget->currentIndex());
1711 void Main::editorChanged(QWidget *)
1713 // Unselect all possibly selected objects
1714 // (Important to update note editor)
1715 for (int i=0;i<=tabWidget->count() -1;i++)
1717 tabModel.at(i)->unselect();
1719 VymModel *m=currentModel();
1720 if (m) m->reselect();
1722 // Update actions to in menus and toolbars according to editor
1726 void Main::fileNew()
1728 VymModel *vm=new VymModel;
1729 tabModel.append (vm);
1731 VymView *vv=new VymView (vm);
1732 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1733 tabWidget->setCurrentIndex (tabModel.count() );
1737 // For the very first map we do not have flagrows yet...
1741 void Main::fileNewCopy()
1743 QString fn="unnamed";
1744 VymModel *srcModel=currentModel();
1749 VymModel *dstModel=tabModel.last ();
1750 dstModel->select("mc:");
1751 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1755 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1757 ErrorCode err=success;
1759 // fn is usually the archive, mapfile the file after uncompressing
1762 // Make fn absolute (needed for unzip)
1763 fn=QDir (fn).absPath();
1769 // Check, if map is already loaded
1771 while (i<=tabWidget->count() -1)
1773 if (tabModel.at(i)->getFilePath() == fn)
1775 // Already there, ask for confirmation
1776 QMessageBox mb( vymName,
1777 tr("The map %1\nis already opened."
1778 "Opening the same map in multiple editors may lead \n"
1779 "to confusion when finishing working with vym."
1780 "Do you want to").arg(fn),
1781 QMessageBox::Warning,
1782 QMessageBox::Yes | QMessageBox::Default,
1783 QMessageBox::Cancel | QMessageBox::Escape,
1784 QMessageBox::NoButton);
1785 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1786 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1789 case QMessageBox::Yes:
1790 // end loop and load anyway
1791 i=tabWidget->count();
1793 case QMessageBox::Cancel:
1803 int tabIndex=tabWidget->currentPageIndex();
1806 if ( !fn.isEmpty() )
1808 vm = currentModel();
1809 // Check first, if mapeditor exists
1810 // If it is not default AND we want a new map,
1811 // create a new mapeditor in a new tab
1812 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1815 VymView *vv=new VymView (vm);
1816 tabModel.append (vm);
1817 tabWidget->addTab (vv,fn);
1818 tabIndex=tabWidget->count()-1;
1819 tabWidget->setCurrentPage (tabIndex);
1823 // Check, if file exists (important for creating new files
1824 // from command line
1825 if (!QFile(fn).exists() )
1827 QMessageBox mb( vymName,
1828 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1829 QMessageBox::Question,
1831 QMessageBox::Cancel | QMessageBox::Default,
1832 QMessageBox::NoButton );
1834 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1835 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1838 case QMessageBox::Yes:
1840 currentMapEditor()->getModel()->setFilePath(fn);
1841 tabWidget->setTabText (tabIndex,
1842 currentMapEditor()->getModel()->getFileName() );
1843 statusBar()->message( "Created " + fn , statusbarTime );
1846 case QMessageBox::Cancel:
1847 // don't create new map
1848 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1855 //tabWidget->currentPage() won't be NULL here, because of above...
1856 tabWidget->setCurrentIndex (tabIndex);
1857 //FIXME-3 no me anymore... me->viewport()->setFocus();
1861 // Save existing filename in case we import
1862 QString fn_org=vm->getFilePath();
1864 // Finally load map into mapEditor
1865 vm->setFilePath (fn);
1866 err=vm->load(fn,lmode,ftype);
1868 // Restore old (maybe empty) filepath, if this is an import
1870 vm->setFilePath (fn_org);
1873 // Finally check for errors and go home
1876 if (lmode==NewMap) fileCloseMap();
1877 statusBar()->message( "Could not load " + fn, statusbarTime );
1882 vm->setFilePath (fn);
1883 tabWidget->setTabText (tabIndex, vm->getFileName());
1884 if (!isInTmpDir (fn))
1886 // Only append to lastMaps if not loaded from a tmpDir
1887 // e.g. imported bookmarks are in a tmpDir
1888 addRecentMap(vm->getFilePath() );
1890 actionFilePrint->setEnabled (true);
1892 statusBar()->message( "Loaded " + fn, statusbarTime );
1899 void Main::fileLoad(const LoadMode &lmode)
1901 QStringList filters;
1902 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1903 QFileDialog *fd=new QFileDialog( this);
1904 fd->setDir (lastFileDir);
1905 fd->setFileMode (QFileDialog::ExistingFiles);
1906 fd->setFilters (filters);
1910 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1913 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1916 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1922 if ( fd->exec() == QDialog::Accepted )
1924 lastFileDir=fd->directory().path();
1925 QStringList flist = fd->selectedFiles();
1926 QStringList::Iterator it = flist.begin();
1927 while( it != flist.end() )
1930 fileLoad(*it, lmode);
1937 void Main::fileLoad()
1942 void Main::fileLoadRecent()
1944 QAction *action = qobject_cast<QAction *>(sender());
1946 fileLoad (action->data().toString(), NewMap);
1949 void Main::addRecentMap (const QString &fileName)
1952 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1953 files.removeAll(fileName);
1954 files.prepend(fileName);
1955 while (files.size() > MaxRecentFiles)
1958 settings.setValue("/mainwindow/recentFileList", files);
1960 setupRecentMapsMenu();
1963 void Main::fileSave(VymModel *m, const SaveMode &savemode)
1967 if ( m->getFilePath().isEmpty() )
1969 // We have no filepath yet,
1970 // call fileSaveAs() now, this will call fileSave()
1972 // First switch to editor
1973 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
1974 fileSaveAs(savemode);
1977 if (m->save (savemode)==success)
1979 statusBar()->message(
1980 tr("Saved %1").arg(m->getFilePath()),
1982 addRecentMap (m->getFilePath() );
1984 statusBar()->message(
1985 tr("Couldn't save ").arg(m->getFilePath()),
1989 void Main::fileSave()
1991 fileSave (currentModel(), CompleteMap);
1994 void Main::fileSave(VymModel *m)
1996 fileSave (m,CompleteMap);
1999 void Main::fileSaveAs(const SaveMode& savemode)
2003 if (currentMapEditor())
2005 if (savemode==CompleteMap)
2006 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2008 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2009 if ( !fn.isEmpty() )
2011 // Check for existing file
2012 if (QFile (fn).exists())
2014 QMessageBox mb( vymName,
2015 tr("The file %1\nexists already. Do you want to").arg(fn),
2016 QMessageBox::Warning,
2017 QMessageBox::Yes | QMessageBox::Default,
2018 QMessageBox::Cancel | QMessageBox::Escape,
2019 QMessageBox::NoButton);
2020 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2021 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2024 case QMessageBox::Yes:
2027 case QMessageBox::Cancel:
2034 // New file, add extension to filename, if missing
2035 // This is always .vym or .vyp, depending on savemode
2036 if (savemode==CompleteMap)
2038 if (!fn.contains (".vym") && !fn.contains (".xml"))
2042 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2051 VymModel *m=currentModel();
2053 fileSave(m, savemode);
2055 // Set name of tab, assuming current tab is the one we just saved
2056 if (savemode==CompleteMap)
2057 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2063 void Main::fileSaveAs()
2065 fileSaveAs (CompleteMap);
2068 void Main::fileImportKDE3Bookmarks()
2070 ImportKDE3Bookmarks im;
2072 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2073 currentMapEditor()->getModel()->setFilePath ("");
2076 void Main::fileImportKDE4Bookmarks()
2078 ImportKDE4Bookmarks im;
2080 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2081 currentMapEditor()->getModel()->setFilePath ("");
2084 void Main::fileImportFirefoxBookmarks()
2086 Q3FileDialog *fd=new Q3FileDialog( this);
2087 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2088 fd->setMode (Q3FileDialog::ExistingFiles);
2089 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2090 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2093 if ( fd->exec() == QDialog::Accepted )
2095 ImportFirefoxBookmarks im;
2096 QStringList flist = fd->selectedFiles();
2097 QStringList::Iterator it = flist.begin();
2098 while( it != flist.end() )
2101 if (im.transform() &&
2102 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2103 currentMapEditor() )
2104 currentMapEditor()->getModel()->setFilePath ("");
2111 void Main::fileImportFreemind()
2113 QStringList filters;
2114 filters <<"Freemind map (*.mm)"<<"All files (*)";
2115 QFileDialog *fd=new QFileDialog( this);
2116 fd->setDir (lastFileDir);
2117 fd->setFileMode (QFileDialog::ExistingFiles);
2118 fd->setFilters (filters);
2119 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2123 if ( fd->exec() == QDialog::Accepted )
2125 lastFileDir=fd->directory().path();
2126 QStringList flist = fd->selectedFiles();
2127 QStringList::Iterator it = flist.begin();
2128 while( it != flist.end() )
2131 if ( fileLoad (fn,NewMap, FreemindMap) )
2133 currentMapEditor()->getModel()->setFilePath ("");
2142 void Main::fileImportMM()
2146 Q3FileDialog *fd=new Q3FileDialog( this);
2147 fd->setDir (lastFileDir);
2148 fd->setMode (Q3FileDialog::ExistingFiles);
2149 fd->addFilter ("Mind Manager (*.mmap)");
2150 fd->setCaption(tr("Import")+" "+"Mind Manager");
2153 if ( fd->exec() == QDialog::Accepted )
2155 lastFileDir=fd->dirPath();
2156 QStringList flist = fd->selectedFiles();
2157 QStringList::Iterator it = flist.begin();
2158 while( it != flist.end() )
2161 if (im.transform() &&
2162 success==fileLoad (im.getTransformedFile(),NewMap) &&
2163 currentMapEditor() )
2164 currentMapEditor()->getModel()->setFilePath ("");
2171 void Main::fileImportDir()
2173 VymModel *m=currentModel();
2174 if (m) m->importDir();
2177 void Main::fileExportXML()
2179 VymModel *m=currentModel();
2180 if (m) m->exportXML();
2184 void Main::fileExportXHTML()
2186 VymModel *m=currentModel();
2187 if (m) m->exportXHTML();
2190 void Main::fileExportImage()
2192 VymModel *m=currentModel();
2193 if (m) m->exportImage();
2196 void Main::fileExportASCII()
2198 VymModel *m=currentModel();
2199 if (m) m->exportASCII();
2202 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2204 VymModel *m=currentModel();
2209 ex.addFilter ("CSV (*.csv)");
2210 ex.setDir(lastImageDir);
2211 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2212 if (ex.execDialog() )
2214 m->setExportMode(true);
2216 m->setExportMode(false);
2221 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2223 VymModel *m=currentModel();
2228 ex.addFilter ("Tex (*.tex)");
2229 ex.setDir(lastImageDir);
2230 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2231 if (ex.execDialog() )
2233 m->setExportMode(true);
2235 m->setExportMode(false);
2240 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2242 ExportKDE3Bookmarks ex;
2243 VymModel *m=currentModel();
2251 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2253 ExportKDE4Bookmarks ex;
2254 VymModel *m=currentModel();
2262 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2264 ExportTaskjuggler ex;
2265 VymModel *m=currentModel();
2269 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2270 ex.setDir(lastImageDir);
2271 ex.addFilter ("Taskjuggler (*.tjp)");
2272 if (ex.execDialog() )
2274 m->setExportMode(true);
2276 m->setExportMode(false);
2281 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2283 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2284 // TODO add preview in dialog
2285 //ImagePreview *p =new ImagePreview (fd);
2286 //fd->setContentsPreviewEnabled( TRUE );
2287 //fd->setContentsPreview( p, p );
2288 //fd->setPreviewMode( QFileDialog::Contents );
2289 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2290 fd->setDir (QDir().current());
2291 if (fd->foundConfig())
2295 if ( fd->exec() == QDialog::Accepted )
2297 QString fn=fd->selectedFile();
2298 if (!fn.contains (".odp"))
2301 //lastImageDir=fn.left(fn.findRev ("/"));
2302 VymModel *m=currentModel();
2303 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2307 QMessageBox::warning(0,
2309 tr("Couldn't find configuration for export to Open Office\n"));
2313 void Main::fileCloseMap()
2315 MapEditor *me = currentMapEditor();
2316 VymModel *m=currentModel();
2319 if (m->hasChanged())
2321 QMessageBox mb( vymName,
2322 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
2323 QMessageBox::Warning,
2324 QMessageBox::Yes | QMessageBox::Default,
2326 QMessageBox::Cancel | QMessageBox::Escape );
2327 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2328 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2331 case QMessageBox::Yes:
2333 fileSave(m, CompleteMap);
2335 case QMessageBox::No:
2336 // close without saving
2338 case QMessageBox::Cancel:
2343 tabModel.removeAt (tabWidget->currentIndex() );
2344 tabWidget->removeTab (tabWidget->currentIndex() );
2346 // Remove mapEditor;
2347 // Better would be delete (me), but then we could have a Qt error:
2348 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2349 // So we only remove data now and call deconstructor when vym closes later
2350 // FIXME-3 this needs to be moved to vymview... me->clear();
2351 // some model->clear is needed to free up memory ...
2357 void Main::filePrint()
2359 if (currentMapEditor())
2360 currentMapEditor()->print();
2363 void Main::fileExitVYM()
2365 // Check if one or more editors have changed
2367 for (i=0;i<=tabModel.count() -1;i++)
2369 // If something changed, ask what to do
2370 if (tabModel.at(i)->hasChanged())
2372 tabWidget->setCurrentPage(i);
2373 QMessageBox mb( vymName,
2374 tr("This map is not saved yet. Do you want to"),
2375 QMessageBox::Warning,
2376 QMessageBox::Yes | QMessageBox::Default,
2378 QMessageBox::Cancel | QMessageBox::Escape );
2379 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2380 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2383 mb.setActiveWindow();
2384 switch( mb.exec() ) {
2385 case QMessageBox::Yes:
2386 // save (the changed editors) and exit
2387 fileSave(currentModel(), CompleteMap);
2389 case QMessageBox::No:
2390 // exit without saving
2392 case QMessageBox::Cancel:
2393 // don't save and don't exit
2397 } // loop over all MEs
2401 void Main::editUndo()
2403 VymModel *m=currentModel();
2407 void Main::editRedo()
2409 VymModel *m=currentModel();
2413 void Main::gotoHistoryStep (int i)
2415 VymModel *m=currentModel();
2416 if (m) m->gotoHistoryStep(i);
2419 void Main::editCopy()
2421 VymModel *m=currentModel();
2425 void Main::editPaste()
2427 VymModel *m=currentModel();
2431 void Main::editCut()
2433 VymModel *m=currentModel();
2437 void Main::editOpenFindWindow()
2439 findWindow->popup();
2440 findWindow->raise();
2441 findWindow->setActiveWindow();
2444 void Main::editFind(QString s)
2446 VymModel *m=currentModel();
2450 BranchItem *bi=m->findText(s, cs);
2453 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2456 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2457 tr("No matches found for \"%1\"").arg(s));
2462 void Main::editFindChanged()
2463 { // Notify editor, to abort the current find process
2464 VymModel *m=currentModel();
2465 if (m) m->findReset();
2468 void Main::openTabs(QStringList urls)
2470 if (!urls.isEmpty())
2474 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2476 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2478 QString u=urls.takeFirst();
2479 procBrowser = new QProcess( this );
2481 procBrowser->start(browser,args);
2482 if ( !procBrowser->waitForStarted())
2484 // try to set path to browser
2485 QMessageBox::warning(0,
2487 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2488 tr("Please use Settings->")+tr("Set application to open an URL"));
2491 #if defined(Q_OS_WIN32)
2492 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2493 this->thread()->wait(3000);
2498 if (browser.contains("konqueror"))
2500 for (int i=0; i<urls.size(); i++)
2503 // Try to open new tab in existing konqueror started previously by vym
2504 p=new QProcess (this);
2506 #if defined(Q_OS_WIN32)
2507 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2508 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2509 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2510 "konqueror-mainwindow#1"<<
2514 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2515 "konqueror-mainwindow#1"<<
2519 p->start ("dcop",args);
2520 if (debug) cout << "MainWindo::openURLs args="<<args.join(" ").toStdString()<<endl;
2521 if ( !p->waitForStarted() ) success=false;
2524 QMessageBox::warning(0,
2526 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2528 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2530 for (int i=0; i<urls.size(); i++)
2532 // Try to open new tab in firefox
2533 p=new QProcess (this);
2534 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2535 p->start (browser,args);
2536 if ( !p->waitForStarted() ) success=false;
2539 QMessageBox::warning(0,
2541 tr("Couldn't start %1 to open a new tab").arg(browser));
2544 QMessageBox::warning(0,
2546 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2550 void Main::editOpenURL()
2553 VymModel *m=currentModel();
2556 QString url=m->getURL();
2558 if (url=="") return;
2559 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2560 procBrowser = new QProcess( this );
2562 procBrowser->start(browser,args);
2563 if ( !procBrowser->waitForStarted())
2565 // try to set path to browser
2566 QMessageBox::warning(0,
2568 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2569 tr("Please use Settings->")+tr("Set application to open an URL"));
2574 void Main::editOpenURLTab()
2576 VymModel *m=currentModel();
2580 urls.append(m->getURL());
2584 void Main::editOpenMultipleURLTabs()
2586 VymModel *m=currentModel();
2596 void Main::editURL()
2598 VymModel *m=currentModel();
2599 if (m) m->editURL();
2602 void Main::editLocalURL()
2604 VymModel *m=currentModel();
2605 if (m) m->editLocalURL();
2608 void Main::editHeading2URL()
2610 VymModel *m=currentModel();
2611 if (m) m->editHeading2URL();
2614 void Main::editBugzilla2URL()
2616 VymModel *m=currentModel();
2617 if (m) m->editBugzilla2URL();
2620 void Main::editFATE2URL()
2622 VymModel *m=currentModel();
2623 if (m) m->editFATE2URL();
2626 void Main::editHeadingFinished(VymModel *m)
2630 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2631 !prevSelection.isEmpty())
2632 m->select(prevSelection);
2637 void Main::openVymLinks(const QStringList &vl)
2639 for (int j=0; j<vl.size(); j++)
2641 // compare path with already loaded maps
2644 for (i=0;i<=tabModel.count() -1;i++)
2646 if (vl.at(j)==tabModel.at(i)->getFilePath() )
2655 if (!QFile(vl.at(j)).exists() )
2656 QMessageBox::critical( 0, tr( "Critical Error" ),
2657 tr("Couldn't open map %1").arg(vl.at(j)));
2660 fileLoad (vl.at(j), NewMap);
2661 tabWidget->setCurrentIndex (tabWidget->count()-1);
2664 // Go to tab containing the map
2665 tabWidget->setCurrentIndex (index);
2669 void Main::editOpenVymLink()
2671 VymModel *m=currentModel();
2675 vl.append(m->getVymLink());
2680 void Main::editOpenMultipleVymLinks()
2682 QString currentVymLink;
2683 VymModel *m=currentModel();
2686 QStringList vl=m->getVymLinks();
2691 void Main::editVymLink()
2693 VymModel *m=currentModel();
2698 void Main::editDeleteVymLink()
2700 VymModel *m=currentModel();
2701 if (m) m->deleteVymLink();
2704 void Main::editToggleHideExport()
2706 VymModel *m=currentModel();
2707 if (m) m->toggleHideExport();
2710 void Main::editMapInfo()
2712 VymModel *m=currentModel();
2714 ExtraInfoDialog dia;
2715 dia.setMapName (m->getFileName() );
2716 dia.setAuthor (m->getAuthor() );
2717 dia.setComment(m->getComment() );
2721 /* FIXME-2 no stats at the moment (view dependent...)
2722 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2732 if (!bo->getNote().isEmpty() ) n++;
2733 f+= bo->countFloatImages();
2735 xl+=bo->countXLinks();
2738 stats+=QString ("%1 xLinks \n").arg (xl,6);
2739 stats+=QString ("%1 notes\n").arg (n,6);
2740 stats+=QString ("%1 images\n").arg (f,6);
2742 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2743 dia.setStats (stats);
2745 // Finally show dialog
2746 if (dia.exec() == QDialog::Accepted)
2748 m->setAuthor (dia.getAuthor() );
2749 m->setComment (dia.getComment() );
2753 void Main::editMoveUp()
2755 VymModel *m=currentModel();
2759 void Main::editMoveDown()
2761 VymModel *m=currentModel();
2762 if (m) m->moveDown();
2765 void Main::editSortChildren()
2767 VymModel *m=currentModel();
2768 if (m) m->sortChildren();
2771 void Main::editToggleScroll()
2773 VymModel *m=currentModel();
2774 if (m) m->toggleScroll();
2777 void Main::editExpandAll()
2779 VymModel *m=currentModel();
2780 if (m) m->emitExpandAll();
2783 void Main::editUnscrollChildren()
2785 VymModel *m=currentModel();
2786 if (m) m->unscrollChildren();
2789 void Main::editAddMapCenter()
2791 VymModel *m=currentModel();
2794 cout <<"Main::editAddMapCenter\n";
2799 void Main::editNewBranch()
2801 VymModel *m=currentModel();
2804 BranchItem *bi=m->createBranch();
2811 if (actionSettingsAutoEditNewBranch->isOn())
2813 currentMapEditor()->editHeading();
2816 if (!prevSelection.isEmpty())
2818 m->select(prevSelection);
2824 void Main::editNewBranchBefore()
2826 VymModel *m=currentModel();
2829 BranchItem *bi=m->createBranch(); //FIXME-1 missing: m->addNewBranchBefore();
2836 if (actionSettingsAutoEditNewBranch->isOn())
2838 if (!actionSettingsAutoSelectNewBranch->isOn())
2839 prevSelection=m->getSelectString(bi);
2840 currentMapEditor()->editHeading();
2845 void Main::editNewBranchAbove()
2847 VymModel *m=currentModel();
2850 BranchItem *bi=m->addNewBranch (-1);
2858 if (actionSettingsAutoEditNewBranch->isOn())
2860 if (!actionSettingsAutoSelectNewBranch->isOn())
2861 prevSelection=m->getSelectString (bi);
2862 currentMapEditor()->editHeading();
2867 void Main::editNewBranchBelow()
2869 VymModel *m=currentModel();
2872 BranchItem *bi=m->addNewBranch (1);
2879 if (actionSettingsAutoEditNewBranch->isOn())
2881 if (!actionSettingsAutoSelectNewBranch->isOn())
2882 prevSelection=m->getSelectString(bi);
2883 currentMapEditor()->editHeading();
2888 void Main::editImportAdd()
2890 fileLoad (ImportAdd);
2893 void Main::editImportReplace()
2895 fileLoad (ImportReplace);
2898 void Main::editSaveBranch()
2900 fileSaveAs (PartOfMap);
2903 void Main::editDeleteKeepChildren()
2905 VymModel *m=currentModel();
2906 if (m) m->deleteKeepChildren();
2909 void Main::editDeleteChildren()
2911 VymModel *m=currentModel();
2912 if (m) m->deleteChildren();
2915 void Main::editDeleteSelection()
2917 VymModel *m=currentModel();
2918 if (m && actionSettingsUseDelKey->isOn())
2919 m->deleteSelection();
2922 void Main::editLoadImage()
2924 VymModel *m=currentModel();
2925 if (m) m->loadFloatImage();
2928 void Main::editSaveImage()
2930 VymModel *m=currentModel();
2931 if (m) m->saveFloatImage();
2934 void Main::editFollowXLink(QAction *a)
2937 VymModel *m=currentModel();
2939 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2942 void Main::editEditXLink(QAction *a)
2944 VymModel *m=currentModel();
2946 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2949 void Main::formatSelectColor()
2951 QColor col = QColorDialog::getColor((currentColor ), this );
2952 if ( !col.isValid() ) return;
2953 colorChanged( col );
2956 void Main::formatPickColor()
2958 VymModel *m=currentModel();
2960 colorChanged( m->getCurrentHeadingColor() );
2963 void Main::colorChanged(QColor c)
2965 QPixmap pix( 16, 16 );
2967 actionFormatColor->setIconSet( pix );
2971 void Main::formatColorBranch()
2973 VymModel *m=currentModel();
2974 if (m) m->colorBranch(currentColor);
2977 void Main::formatColorSubtree()
2979 VymModel *m=currentModel();
2980 if (m) m->colorSubtree (currentColor);
2983 void Main::formatLinkStyleLine()
2985 VymModel *m=currentModel();
2988 m->setMapLinkStyle("StyleLine");
2989 actionFormatLinkStyleLine->setOn(true);
2993 void Main::formatLinkStyleParabel()
2995 VymModel *m=currentModel();
2998 m->setMapLinkStyle("StyleParabel");
2999 actionFormatLinkStyleParabel->setOn(true);
3003 void Main::formatLinkStylePolyLine()
3005 VymModel *m=currentModel();
3008 m->setMapLinkStyle("StylePolyLine");
3009 actionFormatLinkStylePolyLine->setOn(true);
3013 void Main::formatLinkStylePolyParabel()
3015 VymModel *m=currentModel();
3018 m->setMapLinkStyle("StylePolyParabel");
3019 actionFormatLinkStylePolyParabel->setOn(true);
3023 void Main::formatSelectBackColor()
3025 VymModel *m=currentModel();
3026 if (m) m->selectMapBackgroundColor();
3029 void Main::formatSelectBackImage()
3031 VymModel *m=currentModel();
3033 m->selectMapBackgroundImage();
3036 void Main::formatSelectLinkColor()
3038 VymModel *m=currentModel();
3041 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3042 m->setMapDefLinkColor( col );
3046 void Main::formatSelectSelectionColor()
3048 VymModel *m=currentModel();
3051 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3052 m->setSelectionColor (col);
3057 void Main::formatToggleLinkColorHint()
3059 VymModel *m=currentModel();
3060 if (m) m->toggleMapLinkColorHint();
3064 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3066 VymModel *m=currentModel();
3068 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3071 void Main::viewZoomReset()
3073 MapEditor *me=currentMapEditor();
3074 if (me) me->setZoomFactorTarget (1);
3077 void Main::viewZoomIn()
3079 MapEditor *me=currentMapEditor();
3080 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3083 void Main::viewZoomOut()
3085 MapEditor *me=currentMapEditor();
3086 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3089 void Main::viewCenter()
3091 VymModel *m=currentModel();
3092 if (m) m->emitShowSelection();
3095 void Main::networkStartServer()
3097 VymModel *m=currentModel();
3098 if (m) m->newServer();
3101 void Main::networkConnect()
3103 VymModel *m=currentModel();
3104 if (m) m->connectToServer();
3107 bool Main::settingsPDF()
3109 // Default browser is set in constructor
3111 QString text = QInputDialog::getText(
3112 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3113 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3115 settings.setValue ("/mainwindow/readerPDF",text);
3120 bool Main::settingsURL()
3122 // Default browser is set in constructor
3124 QString text = QInputDialog::getText(
3125 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3126 settings.value("/mainwindow/readerURL").toString()
3129 settings.setValue ("/mainwindow/readerURL",text);
3133 void Main::settingsMacroDir()
3135 QDir defdir(vymBaseDir.path() + "/macros");
3136 if (!defdir.exists())
3138 QDir dir=QFileDialog::getExistingDirectory (
3140 tr ("Directory with vym macros:"),
3141 settings.value ("/macros/macroDir",defdir.path()).toString()
3144 settings.setValue ("/macros/macroDir",dir.absolutePath());
3147 void Main::settingsUndoLevels()
3150 int i = QInputDialog::getInteger(
3152 tr("QInputDialog::getInteger()"),
3153 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3156 settings.setValue ("/mapeditor/stepsTotal",i);
3157 QMessageBox::information( this, tr( "VYM -Information:" ),
3158 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3162 void Main::settingsAutosaveToggle()
3164 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3167 void Main::settingsAutosaveTime()
3170 int i = QInputDialog::getInteger(
3172 tr("QInputDialog::getInteger()"),
3173 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3175 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3178 void Main::settingsWriteBackupFileToggle()
3180 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3183 void Main::settingsToggleAnimation()
3185 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3188 void Main::settingsToggleDelKey()
3190 if (actionSettingsUseDelKey->isOn())
3192 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3195 actionDelete->setAccel (QKeySequence (""));
3199 void Main::windowToggleNoteEditor()
3201 if (textEditor->isVisible() )
3202 windowHideNoteEditor();
3204 windowShowNoteEditor();
3207 void Main::windowToggleHistory()
3209 if (historyWindow->isVisible())
3210 historyWindow->hide();
3212 historyWindow->show();
3216 void Main::windowToggleProperty()
3218 if (branchPropertyWindow->isVisible())
3219 branchPropertyWindow->hide();
3221 branchPropertyWindow->show();
3222 branchPropertyWindow->setModel (currentModel() );
3225 void Main::windowToggleAntiAlias()
3227 bool b=actionViewToggleAntiAlias->isOn();
3229 for (int i=0;i<tabModel.count();i++)
3231 me=tabModel.at(i)->getMapEditor();
3232 if (me) me->setAntiAlias(b);
3237 bool Main::isAliased()
3239 return actionViewToggleAntiAlias->isOn();
3242 bool Main::hasSmoothPixmapTransform()
3244 return actionViewToggleSmoothPixmapTransform->isOn();
3247 void Main::windowToggleSmoothPixmap()
3249 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3251 for (int i=0;i<tabModel.count();i++)
3254 me=tabModel.at(i)->getMapEditor();
3255 if (me) me->setSmoothPixmap(b);
3259 void Main::updateHistory(SimpleSettings &undoSet)
3261 historyWindow->update (undoSet);
3264 void Main::updateNoteFlag()
3266 // this slot is connected to TextEditor::textHasChanged()
3268 VymModel *m=currentModel();
3269 if (m) m->updateNoteFlag();
3272 void Main::updateNoteEditor(QModelIndex index )
3274 TreeItem *ti=((VymModel*)sender())->getItem(index);
3276 cout << "Main::updateNoteEditor model="<<sender();
3277 cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3279 textEditor->setNote (ti->getNoteObj() );
3282 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3284 //branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select(). Maybe use signal now...
3286 if (model && model==currentModel() )
3290 if (!oldsel.indexes().isEmpty() )
3292 ti=model->getItem(oldsel.indexes().first());
3294 // Don't update note if both treeItem and textEditor are empty
3295 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3296 // ti->setNoteObj (textEditor->getNoteObj(),false );
3298 if (!newsel.indexes().isEmpty() )
3300 ti=model->getItem(newsel.indexes().first());
3301 if (!ti->hasEmptyNote() )
3302 textEditor->setNote(ti->getNoteObj() );
3304 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3306 // Show URL and link in statusbar
3308 QString s=ti->getURL();
3309 if (!s.isEmpty() ) status+="URL: "+s+" ";
3311 if (!s.isEmpty() ) status+="Link: "+s;
3312 if (!status.isEmpty() ) statusMessage (status);
3315 textEditor->setInactive();
3321 void Main::updateActions()
3323 VymModel *m =currentModel();
3327 actionFilePrint->setEnabled (true);
3329 // Link style in context menu
3330 switch (m->getMapLinkStyle())
3332 case LinkableMapObj::Line:
3333 actionFormatLinkStyleLine->setOn(true);
3335 case LinkableMapObj::Parabel:
3336 actionFormatLinkStyleParabel->setOn(true);
3338 case LinkableMapObj::PolyLine:
3339 actionFormatLinkStylePolyLine->setOn(true);
3341 case LinkableMapObj::PolyParabel:
3342 actionFormatLinkStylePolyParabel->setOn(true);
3349 QPixmap pix( 16, 16 );
3350 pix.fill( m->getMapBackgroundColor() );
3351 actionFormatBackColor->setIconSet( pix );
3352 pix.fill( m->getSelectionColor() );
3353 actionFormatSelectionColor->setIconSet( pix );
3354 pix.fill( m->getMapDefLinkColor() );
3355 actionFormatLinkColor->setIconSet( pix );
3358 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3363 actionFilePrint->setEnabled (false);
3366 // updateActions is also called when NoteEditor is closed
3367 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3368 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3369 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3371 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3372 actionFormatLinkColorHint->setOn(true);
3374 actionFormatLinkColorHint->setOn(false);
3377 if (m && m->hasChanged() )
3378 actionFileSave->setEnabled( true);
3380 actionFileSave->setEnabled( true);
3381 if (m && m->isUndoAvailable())
3382 actionUndo->setEnabled( true);
3384 actionUndo->setEnabled( false);
3386 if (m && m->isRedoAvailable())
3387 actionRedo->setEnabled( true);
3389 actionRedo->setEnabled( false);
3391 TreeItem *selti=m->getSelectedItem();
3392 BranchItem *selbi=m->getSelectedBranchItem();
3397 // Take care of links // FIXME-1
3399 if (bo->countXLinks()==0)
3401 branchXLinksContextMenuEdit->clear();
3402 branchXLinksContextMenuFollow->clear();
3407 branchXLinksContextMenuEdit->clear();
3408 branchXLinksContextMenuFollow->clear();
3409 for (int i=0; i<=bo->countXLinks();i++)
3411 bot=bo->XLinkTargetAt(i);
3414 s=bot->getHeading();
3415 if (s.length()>xLinkMenuWidth)
3416 s=s.left(xLinkMenuWidth)+"...";
3417 branchXLinksContextMenuFollow->addAction (s);
3418 branchXLinksContextMenuEdit->addAction (s);
3424 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3427 actionToggleScroll->setEnabled (true);
3428 if ( selbi->isScrolled() )
3429 actionToggleScroll->setOn(true);
3431 actionToggleScroll->setOn(false);
3433 if ( selti->getURL().isEmpty() )
3435 actionOpenURL->setEnabled (false);
3436 actionOpenURLTab->setEnabled (false);
3440 actionOpenURL->setEnabled (true);
3441 actionOpenURLTab->setEnabled (true);
3443 if ( selti->getVymLink().isEmpty() )
3445 actionOpenVymLink->setEnabled (false);
3446 actionDeleteVymLink->setEnabled (false);
3449 actionOpenVymLink->setEnabled (true);
3450 actionDeleteVymLink->setEnabled (true);
3453 if (selbi->canMoveUp())
3454 actionMoveUp->setEnabled (true);
3456 actionMoveUp->setEnabled (false);
3457 if (selbi->canMoveDown())
3458 actionMoveDown->setEnabled (true);
3460 actionMoveDown->setEnabled (false);
3462 actionSortChildren->setEnabled (true);
3464 actionToggleHideExport->setEnabled (true);
3465 actionToggleHideExport->setOn (selbi->hideInExport() );
3467 actionFileSave->setEnabled (true);
3468 actionCopy->setEnabled (true);
3469 actionCut->setEnabled (true);
3470 if (!clipboardEmpty)
3471 actionPaste->setEnabled (true);
3473 actionPaste->setEnabled (false);
3474 for (int i=0; i<actionListBranches.size(); ++i)
3475 actionListBranches.at(i)->setEnabled(true);
3476 actionDelete->setEnabled (true);
3477 //FIXME-2 actionFormatHideLinkUnselected->setOn (selection->getHideLinkUnselected());
3479 if ( selti->getType()==TreeItem::Image)
3482 FloatObj *fo=(FloatImageObj*)selection;
3484 actionOpenURL->setEnabled (false);
3485 actionOpenVymLink->setEnabled (false);
3486 actionDeleteVymLink->setEnabled (false);
3487 actionToggleHideExport->setEnabled (true);
3488 actionToggleHideExport->setOn (fo->hideInExport() );
3491 actionCopy->setEnabled (true);
3492 actionCut->setEnabled (true);
3493 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3494 for (int i=0; i<actionListBranches.size(); ++i)
3495 actionListBranches.at(i)->setEnabled(false);
3496 actionDelete->setEnabled (true);
3497 actionFormatHideLinkUnselected->setOn
3498 ( selection->getHideLinkUnselected());
3499 actionMoveUp->setEnabled (false);
3500 actionMoveDown->setEnabled (false);
3506 actionFileSave->setEnabled (false);
3507 actionCopy->setEnabled (false);
3508 actionCut->setEnabled (false);
3509 actionPaste->setEnabled (false);
3510 for (int i=0; i<actionListBranches.size(); ++i)
3511 actionListBranches.at(i)->setEnabled(false);
3513 actionToggleScroll->setEnabled (false);
3514 actionOpenURL->setEnabled (false);
3515 actionOpenVymLink->setEnabled (false);
3516 actionDeleteVymLink->setEnabled (false);
3517 actionHeading2URL->setEnabled (false);
3518 actionDelete->setEnabled (false);
3519 actionMoveUp->setEnabled (false);
3520 actionMoveDown->setEnabled (false);
3521 actionSortChildren->setEnabled (false);
3522 actionToggleHideExport->setEnabled (false);
3526 Main::ModMode Main::getModMode()
3528 if (actionModModeColor->isOn()) return ModModeColor;
3529 if (actionModModeCopy->isOn()) return ModModeCopy;
3530 if (actionModModeXLink->isOn()) return ModModeXLink;
3534 bool Main::autoEditNewBranch()
3536 return actionSettingsAutoEditNewBranch->isOn();
3539 bool Main::autoSelectNewBranch()
3541 return actionSettingsAutoSelectNewBranch->isOn();
3544 void Main::windowShowNoteEditor()
3546 textEditor->setShowWithMain(true);
3548 actionViewToggleNoteEditor->setOn (true);
3551 void Main::windowHideNoteEditor()
3553 textEditor->setShowWithMain(false);
3555 actionViewToggleNoteEditor->setOn (false);
3558 void Main::setScript (const QString &script)
3560 scriptEditor->setScript (script);
3563 void Main::runScript (const QString &script)
3565 VymModel *m=currentModel();
3566 if (m) m->runScript (script);
3569 void Main::runScriptEverywhere (const QString &script)
3572 for (int i=0;i<=tabWidget->count() -1;i++)
3574 me=(MapEditor*)tabWidget->page(i);
3575 if (me) me->getModel()->runScript (script);
3579 void Main::windowNextEditor()
3581 if (tabWidget->currentIndex() < tabWidget->count())
3582 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3585 void Main::windowPreviousEditor()
3587 if (tabWidget->currentIndex() >0)
3588 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3591 void Main::standardFlagChanged()
3595 if ( actionSettingsUseFlagGroups->isOn() )
3596 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3598 currentModel()->toggleStandardFlag(sender()->name());
3603 void Main::testFunction1()
3605 if (!currentMapEditor()) return;
3606 currentMapEditor()->testFunction1();
3609 void Main::testFunction2()
3611 if (!currentMapEditor()) return;
3612 currentMapEditor()->setFocus();
3615 void Main::testCommand()
3617 if (!currentMapEditor()) return;
3618 scriptEditor->show();
3621 QString com = QInputDialog::getText(
3622 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3623 if (ok) currentMapEditor()->parseAtom(com);
3627 void Main::helpDoc()
3629 QString locale = QLocale::system().name();
3631 if (locale.left(2)=="es")
3632 docname="vym_es.pdf";
3636 QStringList searchList;
3638 #if defined(Q_OS_MACX)
3639 searchList << "./vym.app/Contents/Resources/doc";
3640 #elif defined(Q_OS_WIN32)
3641 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3643 #if defined(VYM_DOCDIR)
3644 searchList << VYM_DOCDIR;
3646 // default path in SUSE LINUX
3647 searchList << "/usr/share/doc/packages/vym";
3650 searchList << "doc"; // relative path for easy testing in tarball
3651 searchList << "doc/tex"; // Easy testing working on vym.tex
3652 searchList << "/usr/share/doc/vym"; // Debian
3653 searchList << "/usr/share/doc/packages";// Knoppix
3657 for (int i=0; i<searchList.count(); ++i)
3659 docfile.setFileName(searchList.at(i)+"/"+docname);
3660 if (docfile.exists())
3669 QMessageBox::critical(0,
3670 tr("Critcal error"),
3671 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3676 Process *pdfProc = new Process();
3677 args << QDir::toNativeSeparators(docfile.fileName());
3679 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3680 if ( !pdfProc->waitForStarted() )
3683 QMessageBox::warning(0,
3685 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3686 tr("Please use Settings->")+tr("Set application to open PDF files"));
3693 void Main::helpDemo()
3695 QStringList filters;
3696 filters <<"VYM example map (*.vym)";
3697 QFileDialog *fd=new QFileDialog( this);
3698 #if defined(Q_OS_MACX)
3699 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3701 // default path in SUSE LINUX
3702 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3705 fd->setFileMode (QFileDialog::ExistingFiles);
3706 fd->setFilters (filters);
3707 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3711 if ( fd->exec() == QDialog::Accepted )
3713 lastFileDir=fd->directory().path();
3714 QStringList flist = fd->selectedFiles();
3715 QStringList::Iterator it = flist.begin();
3716 while( it != flist.end() )
3719 fileLoad(*it, NewMap);
3727 void Main::helpAbout()
3730 ad.setName ("aboutwindow");
3731 ad.setMinimumSize(500,500);
3732 ad.resize (QSize (500,500));
3736 void Main::helpAboutQT()
3738 QMessageBox::aboutQt( this, "Qt Application Example" );
3741 void Main::callMacro ()
3743 QAction *action = qobject_cast<QAction *>(sender());
3747 i=action->data().toInt();
3748 QString mDir (settings.value ("macros/macroDir").toString() );
3750 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3752 if ( !f.open( QIODevice::ReadOnly ) )
3754 QMessageBox::warning(0,
3756 tr("Couldn't find a macro at %1.\n").arg(fn)+
3757 tr("Please use Settings->")+tr("Set directory for vym macros"));
3761 QTextStream ts( &f );
3762 QString macro= ts.read();
3764 if (! macro.isEmpty())
3766 VymModel *m=currentModel();
3767 if (m) m->runScript(macro);