Fix for segfault when deleting MCO (invalid QModelIndex needs to be returned in index(TreeItem*) )
1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
15 #include "historywindow.h"
17 #include "mapeditor.h"
22 #include "texteditor.h"
23 #include "warningdialog.h"
25 #if defined(Q_OS_WIN32)
26 // Define only this structure as opposed to
27 // including full 'windows.h'. FindWindow
28 // clashes with the one in Win32 API.
29 typedef struct _PROCESS_INFORMATION
35 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
38 extern TextEditor *textEditor;
39 extern Main *mainWindow;
40 extern QString tmpVymDir;
41 extern QString clipboardDir;
42 extern QString clipboardFile;
43 extern bool clipboardEmpty;
44 extern int statusbarTime;
45 extern FlagRow *standardFlagsMaster;
46 extern FlagRow *systemFlagsMaster;
47 extern QString vymName;
48 extern QString vymVersion;
49 extern QString vymBuildDate;
52 QMenu* branchContextMenu;
53 QMenu* branchAddContextMenu;
54 QMenu* branchRemoveContextMenu;
55 QMenu* branchLinksContextMenu;
56 QMenu* branchXLinksContextMenuEdit;
57 QMenu* branchXLinksContextMenuFollow;
58 QMenu* floatimageContextMenu;
59 QMenu* canvasContextMenu;
60 QMenu* fileLastMapsMenu;
61 QMenu* fileImportMenu;
62 QMenu* fileExportMenu;
65 extern Settings settings;
66 extern Options options;
67 extern ImageIO imageIO;
69 extern QDir vymBaseDir;
70 extern QDir lastImageDir;
71 extern QDir lastFileDir;
72 #if defined(Q_OS_WIN32)
73 extern QDir vymInstallDir;
75 extern QString iconPath;
76 extern QString flagsPath;
79 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
80 QMainWindow(parent,name,f)
84 setCaption ("VYM - View Your Mind");
86 // Load window settings
87 #if defined(Q_OS_WIN32)
88 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
90 setWindowState(Qt::WindowMaximized);
95 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
96 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
99 // Sometimes we may need to remember old selections
103 currentColor=Qt::black;
105 // Create unique temporary directory
107 tmpVymDir=makeTmpDir (ok,"vym");
110 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
113 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
115 // Create direcctory for clipboard
116 clipboardDir=tmpVymDir+"/clipboard";
117 clipboardFile="map.xml";
118 QDir d(clipboardDir);
119 d.mkdir (clipboardDir,true);
120 makeSubDirs (clipboardDir);
125 // Satellite windows //////////////////////////////////////////
127 historyWindow=new HistoryWindow();
128 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
131 branchPropertyWindow = new BranchPropertyWindow();
132 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
134 // Connect TextEditor, so that we can update flags if text changes
135 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
136 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
138 // Connect HistoryWindow, so that we can update flags
139 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
142 // Initialize script editor
143 scriptEditor = new SimpleScriptEditor();
144 scriptEditor->move (50,50);
146 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
147 this, SLOT( runScript( QString ) ) );
150 // Initialize Find window
151 findWindow=new FindWindow(NULL);
152 findWindow->move (x(),y()+70);
153 connect (findWindow, SIGNAL( findButton(QString) ),
154 this, SLOT(editFind(QString) ) );
155 connect (findWindow, SIGNAL( somethingChanged() ),
156 this, SLOT(editFindChanged() ) );
158 // Initialize some settings, which are platform dependant
161 // application to open URLs
162 p="/mainwindow/readerURL";
163 #if defined(Q_OS_LINUX)
164 s=settings.value (p,"xdg-open").toString();
166 #if defined(Q_OS_MACX)
167 s=settings.value (p,"/usr/bin/open").toString();
170 #if defined(Q_OS_WIN32)
171 // Assume that system has been set up so that
172 // Explorer automagically opens up the URL
173 // in the user's preferred browser.
174 s=settings.value (p,"explorer").toString();
176 s=settings.value (p,"mozilla").toString();
180 settings.setValue( p,s);
182 // application to open PDFs
183 p="/mainwindow/readerPDF";
184 #if defined(Q_OS_LINUX)
185 s=settings.value (p,"xdg-open").toString();
187 #if defined(Q_OS_MACX)
188 s=settings.value (p,"/usr/bin/open").toString();
189 #elif defined(Q_OS_WIN32)
190 s=settings.value (p,"acrord32").toString();
192 s=settings.value (p,"acroread").toString();
195 settings.setValue( p,s);
197 // width of xLinksMenu
200 // Create tab widget which holds the maps
201 tabWidget= new QTabWidget (this);
202 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
203 this, SLOT( editorChanged( QWidget * ) ) );
205 setCentralWidget(tabWidget);
209 setupFormatActions();
213 setupNetworkActions();
214 setupSettingsActions();
217 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
220 // Status bar and progress bar there
223 progressBar=new QProgressBar;
225 statusBar()->addPermanentWidget(progressBar);
227 restoreState (settings.value("/mainwindow/state",0).toByteArray());
235 #if defined(Q_OS_WIN32)
236 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
238 settings.setValue ("/mainwindow/geometry/size", size());
239 settings.setValue ("/mainwindow/geometry/pos", pos());
240 settings.setValue ("/mainwindow/state",saveState(0));
242 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
243 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
244 settings.setValue( "/version/version", vymVersion );
245 settings.setValue( "/version/builddate", vymBuildDate );
247 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
248 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
249 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
250 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
251 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
252 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
253 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
254 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
256 //TODO save scriptEditor settings
258 // call the destructors
260 delete historyWindow;
261 delete branchPropertyWindow;
264 // Remove temporary directory
265 removeDir (QDir(tmpVymDir));
268 void Main::loadCmdLine()
270 /* TODO draw some kind of splashscreen while loading...
276 QStringList flist=options.getFileList();
277 QStringList::Iterator it=flist.begin();
279 while (it !=flist.end() )
281 fileLoad (*it, NewMap);
287 void Main::statusMessage(const QString &s)
289 // Surpress messages while progressbar during
291 if (progressMin==progressMax)
292 statusBar()->message( s);
295 void Main::setProgressMinimum (int min)
297 progressBar->setMinimum(min);
301 void Main::setProgressMaximum (int max)
303 progressBar->setMaximum(max);
307 statusBar()->addPermanentWidget(progressBar);
312 void Main::setProgressValue (int v)
314 progressBar->setValue (v);
317 void Main::removeProgressBar()
320 statusBar()->removeWidget(progressBar);
321 progressMax=progressMin=0;
324 void Main::closeEvent (QCloseEvent* )
330 void Main::setupFileActions()
332 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
333 QToolBar *tb = addToolBar( tr ("&Map") );
334 tb->setObjectName ("mapTB");
337 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
338 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
339 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
341 fileMenu->addAction (a);
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
344 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
345 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
346 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
347 fileMenu->addAction (a);
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
351 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
352 a->setStatusTip (tr( "Open","Status tip File menu" ) );
353 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
355 fileMenu->addAction (a);
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
358 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
359 fileMenu->addSeparator();
361 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
362 a->setStatusTip ( tr( "Save","Status tip file menu" ));
363 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
365 fileMenu->addAction (a);
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
369 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
370 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
371 fileMenu->addAction (a);
372 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
374 fileMenu->addSeparator();
376 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
378 a = new QAction(tr("KDE 3 Bookmarks"), this);
379 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
380 a->addTo (fileImportMenu);
381 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
383 a = new QAction(tr("KDE 4 Bookmarks"), this);
384 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
385 a->addTo (fileImportMenu);
386 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
388 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
390 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
391 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
392 a->addTo (fileImportMenu);
393 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
396 a = new QAction("Freemind...",this);
397 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
398 fileImportMenu->addAction (a);
399 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
401 a = new QAction("Mind Manager...",this);
402 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
403 fileImportMenu->addAction (a);
404 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
406 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
407 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
408 fileImportMenu->addAction (a);
409 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
411 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
413 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
414 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
415 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
416 fileExportMenu->addAction (a);
418 a = new QAction( "Open Office...", this);
419 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
420 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
421 fileExportMenu->addAction (a);
423 a = new QAction( "Webpage (XHTML)...",this );
424 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
425 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
426 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
427 fileExportMenu->addAction (a);
429 a = new QAction( "Text (ASCII)...", this);
430 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
431 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
432 fileExportMenu->addAction (a);
434 a = new QAction( "Spreadsheet (CSV)...", this);
435 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
436 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
437 fileExportMenu->addAction (a);
439 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
440 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
441 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
442 fileExportMenu->addAction (a);
444 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
445 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
446 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
447 fileExportMenu->addAction (a);
449 a = new QAction( "Taskjuggler...", this );
450 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
451 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
452 fileExportMenu->addAction (a);
454 a = new QAction( "LaTeX...", this);
455 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
456 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
457 fileExportMenu->addAction (a);
459 a = new QAction( "XML..." , this );
460 a->setStatusTip (tr( "Export as %1").arg("XML"));
461 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
462 fileExportMenu->addAction (a);
464 fileMenu->addSeparator();
466 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
467 a->setStatusTip ( tr( "Print" ,"File menu") );
468 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
470 fileMenu->addAction (a);
471 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
474 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
475 a->setStatusTip (tr( "Close Map" ) );
476 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
477 fileMenu->addAction (a);
478 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
480 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
481 a->setStatusTip ( tr( "Exit")+" "+vymName );
482 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
483 fileMenu->addAction (a);
484 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
489 void Main::setupEditActions()
491 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
492 tb->setLabel( "Edit Actions" );
493 tb->setObjectName ("actionsTB");
494 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
498 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
499 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
500 a->setStatusTip (tr( "Undo" ) );
501 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
502 a->setEnabled (false);
504 editMenu->addAction (a);
507 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
508 a->setStatusTip (tr( "Redo" ));
509 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
511 editMenu->addAction (a);
512 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
515 editMenu->addSeparator();
516 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
517 a->setStatusTip ( tr( "Copy" ) );
518 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
519 a->setEnabled (false);
521 editMenu->addAction (a);
522 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
525 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
526 a->setStatusTip ( tr( "Cut" ) );
527 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
528 a->setEnabled (false);
530 editMenu->addAction (a);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
534 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
535 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
536 a->setStatusTip ( tr( "Paste" ) );
537 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
538 a->setEnabled (false);
540 editMenu->addAction (a);
543 // Shortcut to delete selection
544 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
545 a->setStatusTip (tr( "Delete Selection" ));
546 a->setShortcut ( Qt::Key_Delete); //Delete selection
547 a->setShortcutContext (Qt::WindowShortcut);
549 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
552 // Shortcut to add attribute
553 a= new QAction(tr( "Add attribute" ), this);
554 a->setShortcut ( Qt::Key_Q);
555 a->setShortcutContext (Qt::WindowShortcut);
557 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
558 actionAddAttribute= a;
561 // Shortcut to add mapcenter
562 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
563 a->setShortcut ( Qt::Key_M);
564 a->setShortcutContext (Qt::WindowShortcut);
565 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
566 //actionListBranches.append(a);
568 actionAddMapCenter = a;
571 // Shortcut to add branch
572 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
573 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
574 alt->setShortcut (Qt::Key_A); //Add branch
575 alt->setShortcutContext (Qt::WindowShortcut);
577 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
578 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
579 a->setStatusTip ( tr( "Add a branch as child of selection" ));
580 a->setShortcut (Qt::Key_Insert); //Add branch
581 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
582 actionListBranches.append(a);
583 #if defined (Q_OS_MACX)
584 // In OSX show different shortcut in menues, the keys work indepently always
589 editMenu->addAction (actionAddBranch);
590 tb->addAction (actionAddBranch);
593 // Add branch by inserting it at selection
594 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
595 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
596 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
597 a->setShortcutContext (Qt::WindowShortcut);
599 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
600 a->setEnabled (false);
601 actionListBranches.append(a);
602 actionAddBranchBefore=a;
603 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
604 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
605 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
606 a->setShortcutContext (Qt::WindowShortcut);
608 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
609 actionListBranches.append(a);
612 a = new QAction(tr( "Add branch above","Edit menu" ), this);
613 a->setStatusTip ( tr( "Add a branch above selection" ));
614 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
615 a->setShortcutContext (Qt::WindowShortcut);
617 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
618 a->setEnabled (false);
619 actionListBranches.append(a);
620 actionAddBranchAbove=a;
621 a = new QAction(tr( "Add branch above","Edit menu" ), this);
622 a->setStatusTip ( tr( "Add a branch above selection" ));
623 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
624 a->setShortcutContext (Qt::WindowShortcut);
626 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
627 actionListBranches.append(a);
630 a = new QAction(tr( "Add branch below","Edit menu" ), this);
631 a->setStatusTip ( tr( "Add a branch below selection" ));
632 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
633 a->setShortcutContext (Qt::WindowShortcut);
635 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
636 a->setEnabled (false);
637 actionListBranches.append(a);
638 actionAddBranchBelow=a;
639 a = new QAction(tr( "Add branch below","Edit menu" ), this);
640 a->setStatusTip ( tr( "Add a branch below selection" ));
641 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
642 a->setShortcutContext (Qt::WindowShortcut);
644 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
645 actionListBranches.append(a);
647 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
648 a->setStatusTip ( tr( "Move branch up" ) );
649 a->setShortcut (Qt::Key_PageUp ); // Move branch up
650 a->setEnabled (false);
652 editMenu->addAction (a);
653 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
656 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
657 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
658 a->setStatusTip (tr( "Move branch down" ) );
659 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
660 a->setEnabled (false);
662 editMenu->addAction (a);
665 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
666 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
667 a->setEnabled (true);
669 editMenu->addAction (a);
670 actionSortChildren=a;
672 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
673 alt->setShortcut ( Qt::Key_S ); // Scroll branch
674 alt->setStatusTip (tr( "Scroll branch" ));
675 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
676 #if defined(Q_OS_MACX)
677 actionToggleScroll=alt;
679 actionToggleScroll=a;
681 actionToggleScroll->setEnabled (false);
682 actionToggleScroll->setToggleAction(true);
683 tb->addAction (actionToggleScroll);
684 editMenu->addAction ( actionToggleScroll);
685 editMenu->addAction (actionToggleScroll);
688 actionListBranches.append(actionToggleScroll);
690 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
691 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
692 a->setStatusTip (tr( "Expand all branches" ));
693 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
695 actionExpandAll->setEnabled (false);
696 actionExpandAll->setToggleAction(false);
697 //tb->addAction (actionExpandAll);
698 editMenu->addAction ( actionExpandAll);
700 actionListBranches.append(actionExpandAll);
703 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
704 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
705 editMenu->addAction (a);
706 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
708 editMenu->addSeparator();
710 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
711 a->setStatusTip (tr( "Find" ) );
712 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
713 editMenu->addAction (a);
714 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
716 editMenu->addSeparator();
718 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
719 a->setShortcut (Qt::CTRL + Qt::Key_U );
720 a->setShortcut (tr( "Open URL" ));
723 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
726 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
727 a->setStatusTip (tr( "Open URL in new tab" ));
728 //a->setShortcut (Qt::CTRL+Qt::Key_U );
730 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
733 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
734 a->setStatusTip (tr( "Open all URLs in subtree" ));
736 actionListBranches.append(a);
737 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
738 actionOpenMultipleURLTabs=a;
740 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
741 a->setStatusTip ( tr( "Edit URL" ) );
742 a->setShortcut ( Qt::Key_U );
743 a->setShortcutContext (Qt::WindowShortcut);
744 actionListBranches.append(a);
746 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
749 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
750 a->setStatusTip ( tr( "Edit local URL" ) );
751 a->setShortcut (Qt::SHIFT + Qt::Key_U );
752 a->setShortcutContext (Qt::WindowShortcut);
753 actionListBranches.append(a);
755 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
758 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
759 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
760 a->setEnabled (false);
761 actionListBranches.append(a);
762 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
765 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
766 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
767 a->setEnabled (false);
768 actionListBranches.append(a);
769 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
770 actionBugzilla2URL=a;
772 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
773 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
774 a->setEnabled (false);
775 actionListBranches.append(a);
776 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
779 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
780 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
782 a->setEnabled (false);
783 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
786 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
787 a->setStatusTip ( tr( "Open all vym links in subtree" ));
788 a->setEnabled (false);
789 actionListBranches.append(a);
790 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
791 actionOpenMultipleVymLinks=a;
794 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
795 a->setEnabled (false);
796 a->setStatusTip ( tr( "Edit link to another vym map" ));
797 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
798 actionListBranches.append(a);
801 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
802 a->setStatusTip ( tr( "Delete link to another vym map" ));
803 a->setEnabled (false);
804 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
805 actionDeleteVymLink=a;
807 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
808 a->setStatusTip ( tr( "Hide object in exports" ) );
809 a->setShortcut (Qt::Key_H );
810 a->setToggleAction(true);
812 a->setEnabled (false);
813 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
814 actionToggleHideExport=a;
816 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
817 a->setStatusTip ( tr( "Edit Map Info" ));
818 a->setEnabled (true);
819 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
822 // Import at selection (adding to selection)
823 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
824 a->setStatusTip (tr( "Add map at selection" ));
825 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
826 a->setEnabled (false);
827 actionListBranches.append(a);
830 // Import at selection (replacing selection)
831 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
832 a->setStatusTip (tr( "Replace selection with map" ));
833 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
834 a->setEnabled (false);
835 actionListBranches.append(a);
836 actionImportReplace=a;
839 a = new QAction( tr( "Save selection","Edit menu" ), this);
840 a->setStatusTip (tr( "Save selection" ));
841 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
842 a->setEnabled (false);
843 actionListBranches.append(a);
846 // Only remove branch, not its children
847 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
848 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
849 a->setShortcut (Qt::ALT + Qt::Key_Delete );
850 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
851 a->setEnabled (false);
853 actionListBranches.append(a);
854 actionDeleteKeepChildren=a;
856 // Only remove children of a branch
857 a = new QAction( tr( "Remove children","Edit menu" ), this);
858 a->setStatusTip (tr( "Remove children of branch" ));
859 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
860 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
861 a->setEnabled (false);
862 actionListBranches.append(a);
863 actionDeleteChildren=a;
865 a = new QAction( tr( "Add Image...","Edit menu" ), this);
866 a->setStatusTip (tr( "Add Image" ));
867 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
870 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
871 a->setStatusTip (tr( "Set properties for selection" ));
872 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
873 a->setShortcutContext (Qt::WindowShortcut);
874 a->setToggleAction (true);
876 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
877 actionViewTogglePropertyWindow=a;
881 void Main::setupFormatActions()
883 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
885 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
886 tb->setObjectName ("formatTB");
889 pix.fill (Qt::black);
890 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
891 a->setStatusTip ( tr( "Set Color" ));
892 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
894 formatMenu->addAction (a);
896 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
897 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
898 a->setShortcut (Qt::CTRL + Qt::Key_K );
899 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
900 a->setEnabled (false);
902 formatMenu->addAction (a);
903 actionListBranches.append(a);
904 actionFormatPickColor=a;
906 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
907 a->setStatusTip ( tr( "Color branch" ) );
908 a->setShortcut (Qt::CTRL + Qt::Key_B);
909 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
910 a->setEnabled (false);
912 formatMenu->addAction (a);
913 actionListBranches.append(a);
914 actionFormatColorSubtree=a;
916 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
917 a->setStatusTip ( tr( "Color Subtree" ));
918 a->setShortcut (Qt::CTRL + Qt::Key_T);
919 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
920 a->setEnabled (false);
921 formatMenu->addAction (a);
923 actionListBranches.append(a);
924 actionFormatColorSubtree=a;
926 formatMenu->addSeparator();
927 actionGroupFormatLinkStyles=new QActionGroup ( this);
928 actionGroupFormatLinkStyles->setExclusive (true);
929 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
930 a->setStatusTip (tr( "Line" ));
931 a->setToggleAction(true);
932 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
933 formatMenu->addAction (a);
934 actionFormatLinkStyleLine=a;
935 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
936 a->setStatusTip (tr( "Line" ));
937 a->setToggleAction(true);
938 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
939 formatMenu->addAction (a);
940 actionFormatLinkStyleParabel=a;
941 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
942 a->setStatusTip (tr( "PolyLine" ));
943 a->setToggleAction(true);
944 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
945 formatMenu->addAction (a);
946 actionFormatLinkStylePolyLine=a;
947 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
948 a->setStatusTip (tr( "PolyParabel" ) );
949 a->setToggleAction(true);
950 a->setChecked (true);
951 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
952 formatMenu->addAction (a);
953 actionFormatLinkStylePolyParabel=a;
955 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
956 a->setStatusTip (tr( "Hide link" ));
957 a->setToggleAction(true);
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
959 actionFormatHideLinkUnselected=a;
961 formatMenu->addSeparator();
962 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
963 a->setStatusTip (tr( "Use same color for links and headings" ));
964 a->setToggleAction(true);
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
966 formatMenu->addAction (a);
967 actionFormatLinkColorHint=a;
969 pix.fill (Qt::white);
970 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
971 a->setStatusTip (tr( "Set Link Color" ));
972 formatMenu->addAction (a);
973 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
974 actionFormatLinkColor=a;
976 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
977 a->setStatusTip (tr( "Set Selection Color" ));
978 formatMenu->addAction (a);
979 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
980 actionFormatSelectionColor=a;
982 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
983 a->setStatusTip (tr( "Set Background Color" ));
984 formatMenu->addAction (a);
985 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
986 actionFormatBackColor=a;
988 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
989 a->setStatusTip (tr( "Set Background image" ));
990 formatMenu->addAction (a);
991 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
992 actionFormatBackImage=a;
996 void Main::setupViewActions()
998 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
999 tb->setLabel( "View Actions" );
1000 tb->setObjectName ("viewTB");
1001 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1004 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1005 a->setStatusTip ( tr( "Zoom reset" ) );
1006 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1008 viewMenu->addAction (a);
1009 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1011 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1012 a->setStatusTip (tr( "Zoom in" ));
1013 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1015 viewMenu->addAction (a);
1016 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1018 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1019 a->setStatusTip (tr( "Zoom out" ));
1020 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1022 viewMenu->addAction (a);
1023 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1025 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1026 a->setStatusTip (tr( "Show selection" ));
1027 a->setShortcut (Qt::Key_Period);
1029 viewMenu->addAction (a);
1030 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1032 viewMenu->addSeparator();
1034 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1035 a->setStatusTip ( tr( "Show Note Editor" ));
1036 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1037 a->setToggleAction(true);
1039 viewMenu->addAction (a);
1040 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1041 actionViewToggleNoteEditor=a;
1043 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1044 a->setStatusTip ( tr( "Show History Window" ));
1045 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1046 a->setToggleAction(true);
1048 viewMenu->addAction (a);
1049 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1050 actionViewToggleHistoryWindow=a;
1052 viewMenu->addAction (actionViewTogglePropertyWindow);
1054 viewMenu->addSeparator();
1056 a = new QAction(tr( "Antialiasing","View action" ),this );
1057 a->setStatusTip ( tr( "Antialiasing" ));
1058 a->setToggleAction(true);
1059 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1060 viewMenu->addAction (a);
1061 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1062 actionViewToggleAntiAlias=a;
1064 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1065 a->setStatusTip (a->text());
1066 a->setToggleAction(true);
1067 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1068 viewMenu->addAction (a);
1069 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1070 actionViewToggleSmoothPixmapTransform=a;
1072 a = new QAction(tr( "Next Map","View action" ), this);
1073 a->setStatusTip (a->text());
1074 a->setShortcut (Qt::ALT + Qt::Key_N );
1075 viewMenu->addAction (a);
1076 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1078 a = new QAction (tr( "Previous Map","View action" ), this );
1079 a->setStatusTip (a->text());
1080 a->setShortcut (Qt::ALT + Qt::Key_P );
1081 viewMenu->addAction (a);
1082 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1086 void Main::setupModeActions()
1088 //QPopupMenu *menu = new QPopupMenu( this );
1089 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1091 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1092 tb->setObjectName ("modesTB");
1094 actionGroupModModes=new QActionGroup ( this);
1095 actionGroupModModes->setExclusive (true);
1096 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1097 a->setShortcut (Qt::Key_J);
1098 a->setStatusTip ( tr( "Use modifier to color branches" ));
1099 a->setToggleAction(true);
1102 actionModModeColor=a;
1104 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1105 a->setShortcut( Qt::Key_K);
1106 a->setStatusTip( tr( "Use modifier to copy" ));
1107 a->setToggleAction(true);
1109 actionModModeCopy=a;
1111 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1112 a->setShortcut (Qt::Key_L);
1113 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1114 a->setToggleAction(true);
1116 actionModModeXLink=a;
1120 void Main::setupFlagActions()
1122 // Create System Flags
1125 Flag *flag=new Flag;;
1126 flag->setVisible(true);
1128 flag->load(QPixmap(flagsPath+"flag-note.png"));
1129 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1131 flag->load(QPixmap(flagsPath+"flag-url.png"));
1132 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1134 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1135 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1137 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1138 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1140 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1141 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1143 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1144 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1146 // Create Standard Flags
1147 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1148 tb->setObjectName ("standardFlagTB");
1149 standardFlagsMaster->setToolBar (tb);
1151 flag->load(flagsPath+"flag-exclamationmark.png");
1152 flag->setGroup("standard-mark");
1153 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1155 flag->load(flagsPath+"flag-questionmark.png");
1156 flag->setGroup("standard-mark");
1157 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1159 flag->load(flagsPath+"flag-hook-green.png");
1160 flag->setGroup("standard-hook");
1161 setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
1163 flag->load(flagsPath+"flag-cross-red.png");
1164 flag->setGroup("standard-hook");
1165 setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
1168 flag->load(flagsPath+"flag-stopsign.png");
1169 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1171 flag->load(flagsPath+"flag-smiley-good.png");
1172 flag->setGroup("standard-smiley");
1173 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1175 flag->load(flagsPath+"flag-smiley-sad.png");
1176 flag->setGroup("standard-smiley");
1177 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1179 flag->load(flagsPath+"flag-smiley-omg.png");
1180 flag->setGroup("standard-smiley");
1181 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1182 // Original omg.png (in KDE emoticons)
1185 flag->load(flagsPath+"flag-kalarm.png");
1186 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1188 flag->load(flagsPath+"flag-phone.png");
1189 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1191 flag->load(flagsPath+"flag-lamp.png");
1192 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1194 flag->load(flagsPath+"flag-arrow-up.png");
1195 flag->setGroup("standard-arrow");
1196 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1198 flag->load(flagsPath+"flag-arrow-down.png");
1199 flag->setGroup("standard-arrow");
1200 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1202 flag->load(flagsPath+"flag-arrow-2up.png");
1203 flag->setGroup("standard-arrow");
1204 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1206 flag->load(flagsPath+"flag-arrow-2down.png");
1207 flag->setGroup("standard-arrow");
1208 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1211 flag->load(flagsPath+"flag-thumb-up.png");
1212 flag->setGroup("standard-thumb");
1213 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1215 flag->load(flagsPath+"flag-thumb-down.png");
1216 flag->setGroup("standard-thumb");
1217 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1220 flag->load(flagsPath+"flag-rose.png");
1221 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1223 flag->load(flagsPath+"flag-heart.png");
1224 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1226 flag->load(flagsPath+"flag-present.png");
1227 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1229 flag->load(flagsPath+"flag-flash.png");
1230 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1232 // Original: xsldbg_output.png
1233 flag->load(flagsPath+"flag-info.png");
1234 setupFlag (flag,tb,"inflag",tr("Info","Standardflag"));
1236 // Original khelpcenter.png
1237 flag->load(flagsPath+"flag-lifebelt.png");
1238 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1241 flag->setVisible(false);
1242 flag->load(flagsPath+"freemind/warning.png");
1243 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1245 for (int i=1; i<8; i++)
1247 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1248 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1251 flag->load(flagsPath+"freemind/back.png");
1252 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1254 flag->load(flagsPath+"freemind/forward.png");
1255 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1257 flag->load(flagsPath+"freemind/attach.png");
1258 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1260 flag->load(flagsPath+"freemind/clanbomber.png");
1261 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1263 flag->load(flagsPath+"freemind/desktopnew.png");
1264 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1266 flag->load(flagsPath+"freemind/flag.png");
1267 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1270 flag->load(flagsPath+"freemind/gohome.png");
1271 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1274 flag->load(flagsPath+"freemind/kaddressbook.png");
1275 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1277 flag->load(flagsPath+"freemind/knotify.png");
1278 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1280 flag->load(flagsPath+"freemind/korn.png");
1281 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1283 flag->load(flagsPath+"freemind/mail.png");
1284 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1286 flag->load(flagsPath+"freemind/password.png");
1287 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1289 flag->load(flagsPath+"freemind/pencil.png");
1290 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1292 flag->load(flagsPath+"freemind/stop.png");
1293 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1295 flag->load(flagsPath+"freemind/wizard.png");
1296 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1298 flag->load(flagsPath+"freemind/xmag.png");
1299 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1301 flag->load(flagsPath+"freemind/bell.png");
1302 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1304 flag->load(flagsPath+"freemind/bookmark.png");
1305 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1307 flag->load(flagsPath+"freemind/penguin.png");
1308 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1310 flag->load(flagsPath+"freemind/licq.png");
1311 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1314 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1316 flag->setName(name);
1317 flag->setToolTip (tooltip);
1321 a=new QAction (flag->getPixmap(),name,this);
1324 flag->setAction (a);
1325 a->setVisible (flag->isVisible());
1326 a->setCheckable(true);
1327 a->setObjectName(name);
1328 a->setToolTip(tooltip);
1329 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1330 standardFlagsMaster->addFlag (flag);
1334 systemFlagsMaster->addFlag (flag);
1339 void Main::setupNetworkActions()
1341 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1343 QMenu *netMenu = menuBar()->addMenu( "Network" );
1347 a = new QAction( "Start TCPserver for MapEditor",this);
1348 //a->setStatusTip ( "Set application to open pdf files"));
1349 a->setShortcut ( Qt::Key_T ); //New TCP server
1350 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1351 netMenu->addAction (a);
1353 a = new QAction( "Connect MapEditor to server",this);
1354 //a->setStatusTip ( "Set application to open pdf files"));
1355 a->setShortcut ( Qt::Key_C ); // Connect to server
1356 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1357 netMenu->addAction (a);
1361 void Main::setupSettingsActions()
1363 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1367 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1368 a->setStatusTip ( tr( "Set application to open pdf files"));
1369 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1370 settingsMenu->addAction (a);
1372 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1373 a->setStatusTip( tr( "Set application to open external links"));
1374 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1375 settingsMenu->addAction (a);
1377 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1378 a->setStatusTip( tr( "Set path for macros"));
1379 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1380 settingsMenu->addAction (a);
1382 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1383 a->setStatusTip( tr( "Set number of undo levels"));
1384 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1385 settingsMenu->addAction (a);
1387 settingsMenu->addSeparator();
1389 a = new QAction( tr( "Autosave","Settings action"), this);
1390 a->setStatusTip( tr( "Autosave"));
1391 a->setToggleAction(true);
1392 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1393 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1394 settingsMenu->addAction (a);
1395 actionSettingsAutosaveToggle=a;
1397 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1398 a->setStatusTip( tr( "Autosave time"));
1399 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1400 settingsMenu->addAction (a);
1401 actionSettingsAutosaveTime=a;
1403 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1404 a->setStatusTip( tr( "Write backup file on save"));
1405 a->setToggleAction(true);
1406 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1407 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1408 settingsMenu->addAction (a);
1409 actionSettingsWriteBackupFile=a;
1411 settingsMenu->addSeparator();
1413 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1414 a->setStatusTip( tr( "Edit branch after adding it" ));
1415 a->setToggleAction(true);
1416 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1417 settingsMenu->addAction (a);
1418 actionSettingsAutoEditNewBranch=a;
1420 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1421 a->setStatusTip( tr( "Select branch after adding it" ));
1422 a->setToggleAction(true);
1423 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1424 settingsMenu->addAction (a);
1425 actionSettingsAutoSelectNewBranch=a;
1427 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1428 a->setStatusTip( tr( "Select heading before editing" ));
1429 a->setToggleAction(true);
1430 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1431 settingsMenu->addAction (a);
1432 actionSettingsAutoSelectText=a;
1434 a= new QAction( tr( "Delete key","Settings action" ), this);
1435 a->setStatusTip( tr( "Delete key for deleting branches" ));
1436 a->setToggleAction(true);
1437 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1438 settingsMenu->addAction (a);
1439 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1440 actionSettingsUseDelKey=a;
1442 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1443 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1444 a->setToggleAction(true);
1445 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1446 settingsMenu->addAction (a);
1447 actionSettingsUseFlagGroups=a;
1449 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1450 a->setStatusTip( tr( "Use hide flag during exports " ));
1451 a->setToggleAction(true);
1452 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1453 settingsMenu->addAction (a);
1454 actionSettingsUseHideExport=a;
1456 a = new QAction( tr( "Animation","Settings action"), this);
1457 a->setStatusTip( tr( "Animation"));
1458 a->setToggleAction(true);
1459 a->setOn (settings.value("/animation/use",false).toBool() );
1460 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1461 settingsMenu->addAction (a);
1462 actionSettingsUseAnimation=a;
1466 void Main::setupTestActions()
1468 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1471 a = new QAction( "Test function 1" , this);
1472 a->setStatusTip( "Call test function 1" );
1473 testMenu->addAction (a);
1474 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1476 a = new QAction( "Test function 2" , this);
1477 a->setStatusTip( "Call test function 2" );
1478 testMenu->addAction (a);
1479 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1481 a = new QAction( "Command" , this);
1482 a->setStatusTip( "Enter command to call in editor" );
1483 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1484 testMenu->addAction (a);
1488 void Main::setupHelpActions()
1490 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1493 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1494 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1495 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1496 helpMenu->addAction (a);
1498 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1499 a->setStatusTip( tr( "Open VYM example maps " ));
1500 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1501 helpMenu->addAction (a);
1503 a = new QAction( tr( "About VYM","Help action" ), this);
1504 a->setStatusTip( tr( "About VYM")+vymName);
1505 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1506 helpMenu->addAction (a);
1508 a = new QAction( tr( "About QT","Help action" ), this);
1509 a->setStatusTip( tr( "Information about QT toolkit" ));
1510 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1511 helpMenu->addAction (a);
1515 void Main::setupContextMenus()
1519 // Context Menu for branch or mapcenter
1520 branchContextMenu =new QMenu (this);
1521 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1522 branchContextMenu->addSeparator();
1525 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1526 branchAddContextMenu->addAction (actionPaste );
1527 branchAddContextMenu->addAction ( actionAddMapCenter );
1528 branchAddContextMenu->addAction ( actionAddBranch );
1529 branchAddContextMenu->addAction ( actionAddBranchBefore );
1530 branchAddContextMenu->addAction ( actionAddBranchAbove);
1531 branchAddContextMenu->addAction ( actionAddBranchBelow );
1532 branchAddContextMenu->addSeparator();
1533 branchAddContextMenu->addAction ( actionImportAdd );
1534 branchAddContextMenu->addAction ( actionImportReplace );
1537 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1538 branchRemoveContextMenu->addAction (actionCut);
1539 branchRemoveContextMenu->addAction ( actionDelete );
1540 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1541 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1544 actionSaveBranch->addTo( branchContextMenu );
1545 actionFileNewCopy->addTo (branchContextMenu );
1547 branchContextMenu->addSeparator();
1548 branchContextMenu->addAction ( actionLoadImage);
1550 // Submenu for Links (URLs, vymLinks)
1551 branchLinksContextMenu =new QMenu (this);
1553 branchContextMenu->addSeparator();
1554 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1555 branchLinksContextMenu->addAction ( actionOpenURL );
1556 branchLinksContextMenu->addAction ( actionOpenURLTab );
1557 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1558 branchLinksContextMenu->addAction ( actionURL );
1559 branchLinksContextMenu->addAction ( actionLocalURL );
1560 branchLinksContextMenu->addAction ( actionHeading2URL );
1561 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1562 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1564 branchLinksContextMenu->addAction ( actionFATE2URL );
1566 branchLinksContextMenu->addSeparator();
1567 branchLinksContextMenu->addAction ( actionOpenVymLink );
1568 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1569 branchLinksContextMenu->addAction ( actionVymLink );
1570 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1573 // Context Menu for XLinks in a branch menu
1574 // This will be populated "on demand" in MapEditor::updateActions
1575 branchContextMenu->addSeparator();
1576 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1577 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1578 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1579 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1582 // Context menu for floatimage
1583 floatimageContextMenu =new QMenu (this);
1584 a= new QAction (tr ("Save image","Context action"),this);
1585 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1586 floatimageContextMenu->addAction (a);
1588 floatimageContextMenu->addSeparator();
1589 actionCopy->addTo( floatimageContextMenu );
1590 actionCut->addTo( floatimageContextMenu );
1592 floatimageContextMenu->addSeparator();
1593 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1596 // Context menu for canvas
1597 canvasContextMenu =new QMenu (this);
1598 actionAddMapCenter->addTo( canvasContextMenu );
1599 actionMapInfo->addTo( canvasContextMenu );
1600 canvasContextMenu->insertSeparator();
1601 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1602 canvasContextMenu->insertSeparator();
1603 actionFormatLinkColorHint->addTo( canvasContextMenu );
1604 actionFormatLinkColor->addTo( canvasContextMenu );
1605 actionFormatSelectionColor->addTo( canvasContextMenu );
1606 actionFormatBackColor->addTo( canvasContextMenu );
1607 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1609 // Menu for last opened files
1611 for (int i = 0; i < MaxRecentFiles; ++i)
1613 recentFileActions[i] = new QAction(this);
1614 recentFileActions[i]->setVisible(false);
1615 fileLastMapsMenu->addAction(recentFileActions[i]);
1616 connect(recentFileActions[i], SIGNAL(triggered()),
1617 this, SLOT(fileLoadRecent()));
1619 setupRecentMapsMenu();
1622 void Main::setupRecentMapsMenu()
1624 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1626 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1628 for (int i = 0; i < numRecentFiles; ++i) {
1629 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1630 recentFileActions[i]->setText(text);
1631 recentFileActions[i]->setData(files[i]);
1632 recentFileActions[i]->setVisible(true);
1634 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1635 recentFileActions[j]->setVisible(false);
1638 void Main::setupMacros()
1640 for (int i = 0; i <= 11; i++)
1642 macroActions[i] = new QAction(this);
1643 macroActions[i]->setData(i);
1644 addAction (macroActions[i]);
1645 connect(macroActions[i], SIGNAL(triggered()),
1646 this, SLOT(callMacro()));
1648 macroActions[0]->setShortcut ( Qt::Key_F1 );
1649 macroActions[1]->setShortcut ( Qt::Key_F2 );
1650 macroActions[2]->setShortcut ( Qt::Key_F3 );
1651 macroActions[3]->setShortcut ( Qt::Key_F4 );
1652 macroActions[4]->setShortcut ( Qt::Key_F5 );
1653 macroActions[5]->setShortcut ( Qt::Key_F6 );
1654 macroActions[6]->setShortcut ( Qt::Key_F7 );
1655 macroActions[7]->setShortcut ( Qt::Key_F8 );
1656 macroActions[8]->setShortcut ( Qt::Key_F9 );
1657 macroActions[9]->setShortcut ( Qt::Key_F10 );
1658 macroActions[10]->setShortcut ( Qt::Key_F11 );
1659 macroActions[11]->setShortcut ( Qt::Key_F12 );
1662 void Main::hideEvent (QHideEvent * )
1664 if (!textEditor->isMinimized() ) textEditor->hide();
1667 void Main::showEvent (QShowEvent * )
1669 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1673 MapEditor* Main::currentMapEditor() const
1675 if ( tabWidget->currentPage())
1676 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1680 VymModel* Main::currentModel() const
1682 if ( tabWidget->currentPage())
1683 return vymViews.at(tabWidget->currentIndex())->getModel();
1688 void Main::editorChanged(QWidget *)
1690 // Unselect all possibly selected objects
1691 // (Important to update note editor)
1693 for (int i=0;i<=tabWidget->count() -1;i++)
1695 m= vymViews.at(tabWidget->currentIndex())->getModel();
1696 if (m) m->unselect();
1699 if (m) m->reselect();
1701 // Update actions to in menus and toolbars according to editor
1705 void Main::fileNew()
1707 VymModel *vm=new VymModel;
1709 VymView *vv=new VymView (vm);
1710 vymViews.append (vv);
1711 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1712 tabWidget->setCurrentIndex (vymViews.count() );
1716 // For the very first map we do not have flagrows yet...
1720 void Main::fileNewCopy()
1722 QString fn="unnamed";
1723 VymModel *srcModel=currentModel();
1728 VymModel *dstModel=vymViews.last()->getModel();
1729 dstModel->select("mc:");
1730 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1734 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1736 ErrorCode err=success;
1738 // fn is usually the archive, mapfile the file after uncompressing
1741 // Make fn absolute (needed for unzip)
1742 fn=QDir (fn).absPath();
1748 // Check, if map is already loaded
1750 while (i<=tabWidget->count() -1)
1752 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1754 // Already there, ask for confirmation
1755 QMessageBox mb( vymName,
1756 tr("The map %1\nis already opened."
1757 "Opening the same map in multiple editors may lead \n"
1758 "to confusion when finishing working with vym."
1759 "Do you want to").arg(fn),
1760 QMessageBox::Warning,
1761 QMessageBox::Yes | QMessageBox::Default,
1762 QMessageBox::Cancel | QMessageBox::Escape,
1763 QMessageBox::NoButton);
1764 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1765 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1768 case QMessageBox::Yes:
1769 // end loop and load anyway
1770 i=tabWidget->count();
1772 case QMessageBox::Cancel:
1782 int tabIndex=tabWidget->currentPageIndex();
1785 if ( !fn.isEmpty() )
1787 vm = currentModel();
1788 // Check first, if mapeditor exists
1789 // If it is not default AND we want a new map,
1790 // create a new mapeditor in a new tab
1791 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1794 VymView *vv=new VymView (vm);
1795 vymViews.append (vv);
1796 tabWidget->addTab (vv,fn);
1797 tabIndex=tabWidget->count()-1;
1798 tabWidget->setCurrentPage (tabIndex);
1802 // Check, if file exists (important for creating new files
1803 // from command line
1804 if (!QFile(fn).exists() )
1806 QMessageBox mb( vymName,
1807 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1808 QMessageBox::Question,
1810 QMessageBox::Cancel | QMessageBox::Default,
1811 QMessageBox::NoButton );
1813 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1814 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1817 case QMessageBox::Yes:
1819 currentMapEditor()->getModel()->setFilePath(fn);
1820 tabWidget->setTabText (tabIndex,
1821 currentMapEditor()->getModel()->getFileName() );
1822 statusBar()->message( "Created " + fn , statusbarTime );
1825 case QMessageBox::Cancel:
1826 // don't create new map
1827 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1834 //tabWidget->currentPage() won't be NULL here, because of above...
1835 tabWidget->setCurrentIndex (tabIndex);
1836 //FIXME-3 no me anymore... me->viewport()->setFocus();
1840 // Save existing filename in case we import
1841 QString fn_org=vm->getFilePath();
1843 // Finally load map into mapEditor
1844 vm->setFilePath (fn);
1845 err=vm->load(fn,lmode,ftype);
1847 // Restore old (maybe empty) filepath, if this is an import
1849 vm->setFilePath (fn_org);
1852 // Finally check for errors and go home
1855 if (lmode==NewMap) fileCloseMap();
1856 statusBar()->message( "Could not load " + fn, statusbarTime );
1861 vm->setFilePath (fn);
1862 tabWidget->setTabText (tabIndex, vm->getFileName());
1863 if (!isInTmpDir (fn))
1865 // Only append to lastMaps if not loaded from a tmpDir
1866 // e.g. imported bookmarks are in a tmpDir
1867 addRecentMap(vm->getFilePath() );
1869 actionFilePrint->setEnabled (true);
1871 statusBar()->message( "Loaded " + fn, statusbarTime );
1878 void Main::fileLoad(const LoadMode &lmode)
1880 QStringList filters;
1881 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1882 QFileDialog *fd=new QFileDialog( this);
1883 fd->setDir (lastFileDir);
1884 fd->setFileMode (QFileDialog::ExistingFiles);
1885 fd->setFilters (filters);
1889 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1892 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1895 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1901 if ( fd->exec() == QDialog::Accepted )
1903 lastFileDir=fd->directory().path();
1904 QStringList flist = fd->selectedFiles();
1905 QStringList::Iterator it = flist.begin();
1906 while( it != flist.end() )
1909 fileLoad(*it, lmode);
1916 void Main::fileLoad()
1921 void Main::fileLoadRecent()
1923 QAction *action = qobject_cast<QAction *>(sender());
1925 fileLoad (action->data().toString(), NewMap);
1928 void Main::addRecentMap (const QString &fileName)
1931 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1932 files.removeAll(fileName);
1933 files.prepend(fileName);
1934 while (files.size() > MaxRecentFiles)
1937 settings.setValue("/mainwindow/recentFileList", files);
1939 setupRecentMapsMenu();
1942 void Main::fileSave(VymModel *m, const SaveMode &savemode)
1946 if ( m->getFilePath().isEmpty() )
1948 // We have no filepath yet,
1949 // call fileSaveAs() now, this will call fileSave()
1951 // First switch to editor
1952 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
1953 fileSaveAs(savemode);
1956 if (m->save (savemode)==success)
1958 statusBar()->message(
1959 tr("Saved %1").arg(m->getFilePath()),
1961 addRecentMap (m->getFilePath() );
1963 statusBar()->message(
1964 tr("Couldn't save ").arg(m->getFilePath()),
1968 void Main::fileSave()
1970 fileSave (currentModel(), CompleteMap);
1973 void Main::fileSave(VymModel *m)
1975 fileSave (m,CompleteMap);
1978 void Main::fileSaveAs(const SaveMode& savemode)
1982 if (currentMapEditor())
1984 if (savemode==CompleteMap)
1985 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1987 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1988 if ( !fn.isEmpty() )
1990 // Check for existing file
1991 if (QFile (fn).exists())
1993 QMessageBox mb( vymName,
1994 tr("The file %1\nexists already. Do you want to").arg(fn),
1995 QMessageBox::Warning,
1996 QMessageBox::Yes | QMessageBox::Default,
1997 QMessageBox::Cancel | QMessageBox::Escape,
1998 QMessageBox::NoButton);
1999 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2000 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2003 case QMessageBox::Yes:
2006 case QMessageBox::Cancel:
2013 // New file, add extension to filename, if missing
2014 // This is always .vym or .vyp, depending on savemode
2015 if (savemode==CompleteMap)
2017 if (!fn.contains (".vym") && !fn.contains (".xml"))
2021 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2030 VymModel *m=currentModel();
2032 fileSave(m, savemode);
2034 // Set name of tab, assuming current tab is the one we just saved
2035 if (savemode==CompleteMap)
2036 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2042 void Main::fileSaveAs()
2044 fileSaveAs (CompleteMap);
2047 void Main::fileImportKDE3Bookmarks()
2049 ImportKDE3Bookmarks im;
2051 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2052 currentMapEditor()->getModel()->setFilePath ("");
2055 void Main::fileImportKDE4Bookmarks()
2057 ImportKDE4Bookmarks im;
2059 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2060 currentMapEditor()->getModel()->setFilePath ("");
2063 void Main::fileImportFirefoxBookmarks()
2065 Q3FileDialog *fd=new Q3FileDialog( this);
2066 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2067 fd->setMode (Q3FileDialog::ExistingFiles);
2068 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2069 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2072 if ( fd->exec() == QDialog::Accepted )
2074 ImportFirefoxBookmarks im;
2075 QStringList flist = fd->selectedFiles();
2076 QStringList::Iterator it = flist.begin();
2077 while( it != flist.end() )
2080 if (im.transform() &&
2081 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2082 currentMapEditor() )
2083 currentMapEditor()->getModel()->setFilePath ("");
2090 void Main::fileImportFreemind()
2092 QStringList filters;
2093 filters <<"Freemind map (*.mm)"<<"All files (*)";
2094 QFileDialog *fd=new QFileDialog( this);
2095 fd->setDir (lastFileDir);
2096 fd->setFileMode (QFileDialog::ExistingFiles);
2097 fd->setFilters (filters);
2098 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2102 if ( fd->exec() == QDialog::Accepted )
2104 lastFileDir=fd->directory().path();
2105 QStringList flist = fd->selectedFiles();
2106 QStringList::Iterator it = flist.begin();
2107 while( it != flist.end() )
2110 if ( fileLoad (fn,NewMap, FreemindMap) )
2112 currentMapEditor()->getModel()->setFilePath ("");
2121 void Main::fileImportMM()
2125 Q3FileDialog *fd=new Q3FileDialog( this);
2126 fd->setDir (lastFileDir);
2127 fd->setMode (Q3FileDialog::ExistingFiles);
2128 fd->addFilter ("Mind Manager (*.mmap)");
2129 fd->setCaption(tr("Import")+" "+"Mind Manager");
2132 if ( fd->exec() == QDialog::Accepted )
2134 lastFileDir=fd->dirPath();
2135 QStringList flist = fd->selectedFiles();
2136 QStringList::Iterator it = flist.begin();
2137 while( it != flist.end() )
2140 if (im.transform() &&
2141 success==fileLoad (im.getTransformedFile(),NewMap) &&
2142 currentMapEditor() )
2143 currentMapEditor()->getModel()->setFilePath ("");
2150 void Main::fileImportDir()
2152 VymModel *m=currentModel();
2153 if (m) m->importDir();
2156 void Main::fileExportXML()
2158 VymModel *m=currentModel();
2159 if (m) m->exportXML();
2163 void Main::fileExportXHTML()
2165 VymModel *m=currentModel();
2166 if (m) m->exportXHTML();
2169 void Main::fileExportImage()
2171 VymModel *m=currentModel();
2172 if (m) m->exportImage();
2175 void Main::fileExportASCII()
2177 VymModel *m=currentModel();
2178 if (m) m->exportASCII();
2181 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2183 VymModel *m=currentModel();
2188 ex.addFilter ("CSV (*.csv)");
2189 ex.setDir(lastImageDir);
2190 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2191 if (ex.execDialog() )
2193 m->setExportMode(true);
2195 m->setExportMode(false);
2200 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2202 VymModel *m=currentModel();
2207 ex.addFilter ("Tex (*.tex)");
2208 ex.setDir(lastImageDir);
2209 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2210 if (ex.execDialog() )
2212 m->setExportMode(true);
2214 m->setExportMode(false);
2219 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2221 ExportKDE3Bookmarks ex;
2222 VymModel *m=currentModel();
2230 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2232 ExportKDE4Bookmarks ex;
2233 VymModel *m=currentModel();
2241 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2243 ExportTaskjuggler ex;
2244 VymModel *m=currentModel();
2248 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2249 ex.setDir(lastImageDir);
2250 ex.addFilter ("Taskjuggler (*.tjp)");
2251 if (ex.execDialog() )
2253 m->setExportMode(true);
2255 m->setExportMode(false);
2260 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2262 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2263 // TODO add preview in dialog
2264 //ImagePreview *p =new ImagePreview (fd);
2265 //fd->setContentsPreviewEnabled( TRUE );
2266 //fd->setContentsPreview( p, p );
2267 //fd->setPreviewMode( QFileDialog::Contents );
2268 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2269 fd->setDir (QDir().current());
2270 if (fd->foundConfig())
2274 if ( fd->exec() == QDialog::Accepted )
2276 QString fn=fd->selectedFile();
2277 if (!fn.contains (".odp"))
2280 //lastImageDir=fn.left(fn.findRev ("/"));
2281 VymModel *m=currentModel();
2282 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2286 QMessageBox::warning(0,
2288 tr("Couldn't find configuration for export to Open Office\n"));
2292 void Main::fileCloseMap()
2294 VymModel *m=currentModel();
2297 if (m->hasChanged())
2299 QMessageBox mb( vymName,
2300 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2301 QMessageBox::Warning,
2302 QMessageBox::Yes | QMessageBox::Default,
2304 QMessageBox::Cancel | QMessageBox::Escape );
2305 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2306 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2309 case QMessageBox::Yes:
2311 fileSave(m, CompleteMap);
2313 case QMessageBox::No:
2314 // close without saving
2316 case QMessageBox::Cancel:
2321 // And here comes the segfault, because removeTab triggers
2322 // currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2323 vymViews.removeAt (tabWidget->currentIndex() );
2324 tabWidget->removeTab (tabWidget->currentIndex() );
2326 // Remove mapEditor/model FIXME-5
2327 // Better would be delete (me), but then we could have a Qt error:
2328 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2329 // So we only remove data now and call deconstructor when vym closes later
2330 // this needs to be moved to vymview... me->clear();
2331 // some model->clear is needed to free up memory ...
2337 void Main::filePrint()
2339 if (currentMapEditor())
2340 currentMapEditor()->print();
2343 void Main::fileExitVYM()
2345 // Check if one or more editors have changed
2347 for (i=0;i<=vymViews.count() -1;i++)
2349 // If something changed, ask what to do
2350 if (vymViews.at(i)->getModel()->hasChanged())
2352 tabWidget->setCurrentPage(i);
2353 QMessageBox mb( vymName,
2354 tr("This map is not saved yet. Do you want to"),
2355 QMessageBox::Warning,
2356 QMessageBox::Yes | QMessageBox::Default,
2358 QMessageBox::Cancel | QMessageBox::Escape );
2359 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2360 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2363 mb.setActiveWindow();
2364 switch( mb.exec() ) {
2365 case QMessageBox::Yes:
2366 // save (the changed editors) and exit
2367 fileSave(currentModel(), CompleteMap);
2369 case QMessageBox::No:
2370 // exit without saving
2372 case QMessageBox::Cancel:
2373 // don't save and don't exit
2377 } // loop over all MEs
2381 void Main::editUndo()
2383 VymModel *m=currentModel();
2387 void Main::editRedo()
2389 VymModel *m=currentModel();
2393 void Main::gotoHistoryStep (int i)
2395 VymModel *m=currentModel();
2396 if (m) m->gotoHistoryStep(i);
2399 void Main::editCopy()
2401 VymModel *m=currentModel();
2405 void Main::editPaste()
2407 VymModel *m=currentModel();
2411 void Main::editCut()
2413 VymModel *m=currentModel();
2417 void Main::editOpenFindWindow()
2419 findWindow->popup();
2420 findWindow->raise();
2421 findWindow->setActiveWindow();
2424 void Main::editFind(QString s)
2426 VymModel *m=currentModel();
2430 BranchItem *bi=m->findText(s, cs);
2433 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2436 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2437 tr("No matches found for \"%1\"").arg(s));
2442 void Main::editFindChanged()
2443 { // Notify editor, to abort the current find process
2444 VymModel *m=currentModel();
2445 if (m) m->findReset();
2448 void Main::openTabs(QStringList urls)
2450 if (!urls.isEmpty())
2454 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2456 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2458 QString u=urls.takeFirst();
2459 procBrowser = new QProcess( this );
2461 procBrowser->start(browser,args);
2462 if ( !procBrowser->waitForStarted())
2464 // try to set path to browser
2465 QMessageBox::warning(0,
2467 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2468 tr("Please use Settings->")+tr("Set application to open an URL"));
2471 #if defined(Q_OS_WIN32)
2472 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2473 this->thread()->wait(3000);
2478 if (browser.contains("konqueror"))
2480 for (int i=0; i<urls.size(); i++)
2483 // Try to open new tab in existing konqueror started previously by vym
2484 p=new QProcess (this);
2486 #if defined(Q_OS_WIN32)
2487 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2488 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2489 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2490 "konqueror-mainwindow#1"<<
2494 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2495 "konqueror-mainwindow#1"<<
2499 p->start ("dcop",args);
2500 if (debug) cout << "MainWindo::openURLs args="<<args.join(" ").toStdString()<<endl;
2501 if ( !p->waitForStarted() ) success=false;
2504 QMessageBox::warning(0,
2506 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2508 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2510 for (int i=0; i<urls.size(); i++)
2512 // Try to open new tab in firefox
2513 p=new QProcess (this);
2514 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2515 p->start (browser,args);
2516 if ( !p->waitForStarted() ) success=false;
2519 QMessageBox::warning(0,
2521 tr("Couldn't start %1 to open a new tab").arg(browser));
2524 QMessageBox::warning(0,
2526 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2530 void Main::editOpenURL()
2533 VymModel *m=currentModel();
2536 QString url=m->getURL();
2538 if (url=="") return;
2539 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2540 procBrowser = new QProcess( this );
2542 procBrowser->start(browser,args);
2543 if ( !procBrowser->waitForStarted())
2545 // try to set path to browser
2546 QMessageBox::warning(0,
2548 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2549 tr("Please use Settings->")+tr("Set application to open an URL"));
2554 void Main::editOpenURLTab()
2556 VymModel *m=currentModel();
2560 urls.append(m->getURL());
2564 void Main::editOpenMultipleURLTabs()
2566 VymModel *m=currentModel();
2576 void Main::editURL()
2578 VymModel *m=currentModel();
2579 if (m) m->editURL();
2582 void Main::editLocalURL()
2584 VymModel *m=currentModel();
2585 if (m) m->editLocalURL();
2588 void Main::editHeading2URL()
2590 VymModel *m=currentModel();
2591 if (m) m->editHeading2URL();
2594 void Main::editBugzilla2URL()
2596 VymModel *m=currentModel();
2597 if (m) m->editBugzilla2URL();
2600 void Main::editFATE2URL()
2602 VymModel *m=currentModel();
2603 if (m) m->editFATE2URL();
2606 void Main::editHeadingFinished(VymModel *m)
2610 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2611 !prevSelection.isEmpty())
2612 m->select(prevSelection);
2617 void Main::openVymLinks(const QStringList &vl)
2619 for (int j=0; j<vl.size(); j++)
2621 // compare path with already loaded maps
2624 for (i=0;i<=vymViews.count() -1;i++)
2626 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2635 if (!QFile(vl.at(j)).exists() )
2636 QMessageBox::critical( 0, tr( "Critical Error" ),
2637 tr("Couldn't open map %1").arg(vl.at(j)));
2640 fileLoad (vl.at(j), NewMap);
2641 tabWidget->setCurrentIndex (tabWidget->count()-1);
2644 // Go to tab containing the map
2645 tabWidget->setCurrentIndex (index);
2649 void Main::editOpenVymLink()
2651 VymModel *m=currentModel();
2655 vl.append(m->getVymLink());
2660 void Main::editOpenMultipleVymLinks()
2662 QString currentVymLink;
2663 VymModel *m=currentModel();
2666 QStringList vl=m->getVymLinks();
2671 void Main::editVymLink()
2673 VymModel *m=currentModel();
2678 void Main::editDeleteVymLink()
2680 VymModel *m=currentModel();
2681 if (m) m->deleteVymLink();
2684 void Main::editToggleHideExport()
2686 VymModel *m=currentModel();
2687 if (m) m->toggleHideExport();
2690 void Main::editMapInfo()
2692 VymModel *m=currentModel();
2694 ExtraInfoDialog dia;
2695 dia.setMapName (m->getFileName() );
2696 dia.setAuthor (m->getAuthor() );
2697 dia.setComment(m->getComment() );
2701 /* FIXME-2 no stats at the moment (view dependent...)
2702 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2712 if (!bo->getNote().isEmpty() ) n++;
2713 f+= bo->countFloatImages();
2715 xl+=bo->countXLinks();
2718 stats+=QString ("%1 xLinks \n").arg (xl,6);
2719 stats+=QString ("%1 notes\n").arg (n,6);
2720 stats+=QString ("%1 images\n").arg (f,6);
2722 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2723 dia.setStats (stats);
2725 // Finally show dialog
2726 if (dia.exec() == QDialog::Accepted)
2728 m->setAuthor (dia.getAuthor() );
2729 m->setComment (dia.getComment() );
2733 void Main::editMoveUp()
2735 VymModel *m=currentModel();
2739 void Main::editMoveDown()
2741 VymModel *m=currentModel();
2742 if (m) m->moveDown();
2745 void Main::editSortChildren()
2747 VymModel *m=currentModel();
2748 if (m) m->sortChildren();
2751 void Main::editToggleScroll()
2753 VymModel *m=currentModel();
2754 if (m) m->toggleScroll();
2757 void Main::editExpandAll()
2759 VymModel *m=currentModel();
2760 if (m) m->emitExpandAll();
2763 void Main::editUnscrollChildren()
2765 VymModel *m=currentModel();
2766 if (m) m->unscrollChildren();
2769 void Main::editAddAttribute()
2771 VymModel *m=currentModel();
2772 if (m) m->addAttribute();
2775 void Main::editAddMapCenter()
2777 VymModel *m=currentModel();
2778 if (m) m->addMapCenter ();
2781 void Main::editNewBranch()
2783 VymModel *m=currentModel();
2786 BranchItem *bi=m->addNewBranch();
2789 if (actionSettingsAutoEditNewBranch->isOn()
2790 && !actionSettingsAutoSelectNewBranch->isOn() )
2791 prevSelection=m->getSelectString();
2793 prevSelection=QString();
2795 if (actionSettingsAutoSelectNewBranch->isOn()
2796 || actionSettingsAutoEditNewBranch->isOn())
2799 if (actionSettingsAutoEditNewBranch->isOn())
2800 currentMapEditor()->editHeading();
2805 void Main::editNewBranchBefore()
2807 VymModel *m=currentModel();
2810 BranchItem *bi=m->addNewBranchBefore();
2817 if (actionSettingsAutoEditNewBranch->isOn())
2819 if (!actionSettingsAutoSelectNewBranch->isOn())
2820 prevSelection=m->getSelectString(bi);
2821 currentMapEditor()->editHeading();
2826 void Main::editNewBranchAbove()
2828 VymModel *m=currentModel();
2831 BranchItem *bi=m->addNewBranch (-1);
2839 if (actionSettingsAutoEditNewBranch->isOn())
2841 if (!actionSettingsAutoSelectNewBranch->isOn())
2842 prevSelection=m->getSelectString (bi);
2843 currentMapEditor()->editHeading();
2848 void Main::editNewBranchBelow()
2850 VymModel *m=currentModel();
2853 BranchItem *bi=m->addNewBranch (1);
2860 if (actionSettingsAutoEditNewBranch->isOn())
2862 if (!actionSettingsAutoSelectNewBranch->isOn())
2863 prevSelection=m->getSelectString(bi);
2864 currentMapEditor()->editHeading();
2869 void Main::editImportAdd()
2871 fileLoad (ImportAdd);
2874 void Main::editImportReplace()
2876 fileLoad (ImportReplace);
2879 void Main::editSaveBranch()
2881 fileSaveAs (PartOfMap);
2884 void Main::editDeleteKeepChildren()
2886 VymModel *m=currentModel();
2887 if (m) m->deleteKeepChildren();
2890 void Main::editDeleteChildren()
2892 VymModel *m=currentModel();
2893 if (m) m->deleteChildren();
2896 void Main::editDeleteSelection()
2898 VymModel *m=currentModel();
2899 if (m && actionSettingsUseDelKey->isOn())
2900 m->deleteSelection();
2903 void Main::editLoadImage()
2905 VymModel *m=currentModel();
2906 if (m) m->loadFloatImage();
2909 void Main::editSaveImage()
2911 VymModel *m=currentModel();
2912 if (m) m->saveFloatImage();
2915 void Main::editFollowXLink(QAction *a)
2918 VymModel *m=currentModel();
2920 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2923 void Main::editEditXLink(QAction *a)
2925 VymModel *m=currentModel();
2927 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2930 void Main::formatSelectColor()
2932 QColor col = QColorDialog::getColor((currentColor ), this );
2933 if ( !col.isValid() ) return;
2934 colorChanged( col );
2937 void Main::formatPickColor()
2939 VymModel *m=currentModel();
2941 colorChanged( m->getCurrentHeadingColor() );
2944 void Main::colorChanged(QColor c)
2946 QPixmap pix( 16, 16 );
2948 actionFormatColor->setIconSet( pix );
2952 void Main::formatColorBranch()
2954 VymModel *m=currentModel();
2955 if (m) m->colorBranch(currentColor);
2958 void Main::formatColorSubtree()
2960 VymModel *m=currentModel();
2961 if (m) m->colorSubtree (currentColor);
2964 void Main::formatLinkStyleLine()
2966 VymModel *m=currentModel();
2969 m->setMapLinkStyle("StyleLine");
2970 actionFormatLinkStyleLine->setOn(true);
2974 void Main::formatLinkStyleParabel()
2976 VymModel *m=currentModel();
2979 m->setMapLinkStyle("StyleParabel");
2980 actionFormatLinkStyleParabel->setOn(true);
2984 void Main::formatLinkStylePolyLine()
2986 VymModel *m=currentModel();
2989 m->setMapLinkStyle("StylePolyLine");
2990 actionFormatLinkStylePolyLine->setOn(true);
2994 void Main::formatLinkStylePolyParabel()
2996 VymModel *m=currentModel();
2999 m->setMapLinkStyle("StylePolyParabel");
3000 actionFormatLinkStylePolyParabel->setOn(true);
3004 void Main::formatSelectBackColor()
3006 VymModel *m=currentModel();
3007 if (m) m->selectMapBackgroundColor();
3010 void Main::formatSelectBackImage()
3012 VymModel *m=currentModel();
3014 m->selectMapBackgroundImage();
3017 void Main::formatSelectLinkColor()
3019 VymModel *m=currentModel();
3022 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3023 m->setMapDefLinkColor( col );
3027 void Main::formatSelectSelectionColor()
3029 VymModel *m=currentModel();
3032 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3033 m->setSelectionColor (col);
3038 void Main::formatToggleLinkColorHint()
3040 VymModel *m=currentModel();
3041 if (m) m->toggleMapLinkColorHint();
3045 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3047 VymModel *m=currentModel();
3049 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3052 void Main::viewZoomReset()
3054 MapEditor *me=currentMapEditor();
3055 if (me) me->setZoomFactorTarget (1);
3058 void Main::viewZoomIn()
3060 MapEditor *me=currentMapEditor();
3061 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3064 void Main::viewZoomOut()
3066 MapEditor *me=currentMapEditor();
3067 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3070 void Main::viewCenter()
3072 VymModel *m=currentModel();
3073 if (m) m->emitShowSelection();
3076 void Main::networkStartServer()
3078 VymModel *m=currentModel();
3079 if (m) m->newServer();
3082 void Main::networkConnect()
3084 VymModel *m=currentModel();
3085 if (m) m->connectToServer();
3088 bool Main::settingsPDF()
3090 // Default browser is set in constructor
3092 QString text = QInputDialog::getText(
3093 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3094 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3096 settings.setValue ("/mainwindow/readerPDF",text);
3101 bool Main::settingsURL()
3103 // Default browser is set in constructor
3105 QString text = QInputDialog::getText(
3106 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3107 settings.value("/mainwindow/readerURL").toString()
3110 settings.setValue ("/mainwindow/readerURL",text);
3114 void Main::settingsMacroDir()
3116 QDir defdir(vymBaseDir.path() + "/macros");
3117 if (!defdir.exists())
3119 QDir dir=QFileDialog::getExistingDirectory (
3121 tr ("Directory with vym macros:"),
3122 settings.value ("/macros/macroDir",defdir.path()).toString()
3125 settings.setValue ("/macros/macroDir",dir.absolutePath());
3128 void Main::settingsUndoLevels()
3131 int i = QInputDialog::getInteger(
3133 tr("QInputDialog::getInteger()"),
3134 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3137 settings.setValue ("/mapeditor/stepsTotal",i);
3138 QMessageBox::information( this, tr( "VYM -Information:" ),
3139 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3143 void Main::settingsAutosaveToggle()
3145 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3148 void Main::settingsAutosaveTime()
3151 int i = QInputDialog::getInteger(
3153 tr("QInputDialog::getInteger()"),
3154 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3156 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3159 void Main::settingsWriteBackupFileToggle()
3161 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3164 void Main::settingsToggleAnimation()
3166 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3169 void Main::settingsToggleDelKey()
3171 if (actionSettingsUseDelKey->isOn())
3173 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3176 actionDelete->setAccel (QKeySequence (""));
3180 void Main::windowToggleNoteEditor()
3182 if (textEditor->isVisible() )
3183 windowHideNoteEditor();
3185 windowShowNoteEditor();
3188 void Main::windowToggleHistory()
3190 if (historyWindow->isVisible())
3191 historyWindow->hide();
3193 historyWindow->show();
3197 void Main::windowToggleProperty()
3199 if (branchPropertyWindow->isVisible())
3200 branchPropertyWindow->hide();
3202 branchPropertyWindow->show();
3203 branchPropertyWindow->setModel (currentModel() );
3206 void Main::windowToggleAntiAlias()
3208 bool b=actionViewToggleAntiAlias->isOn();
3210 for (int i=0;i<vymViews.count();i++)
3212 me=vymViews.at(i)->getMapEditor();
3213 if (me) me->setAntiAlias(b);
3218 bool Main::isAliased()
3220 return actionViewToggleAntiAlias->isOn();
3223 bool Main::hasSmoothPixmapTransform()
3225 return actionViewToggleSmoothPixmapTransform->isOn();
3228 void Main::windowToggleSmoothPixmap()
3230 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3232 for (int i=0;i<vymViews.count();i++)
3235 me=vymViews.at(i)->getMapEditor();
3236 if (me) me->setSmoothPixmap(b);
3240 void Main::updateHistory(SimpleSettings &undoSet)
3242 historyWindow->update (undoSet);
3245 void Main::updateNoteFlag()
3247 // this slot is connected to TextEditor::textHasChanged()
3249 VymModel *m=currentModel();
3250 if (m) m->updateNoteFlag();
3253 void Main::updateNoteEditor(QModelIndex index )
3255 cout << QObject::sender();
3256 QObject *obj=QObject::sender();
3257 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3258 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3259 //cout << "Main::updateNoteEditor model="<<sender();
3260 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3261 textEditor->setNote (ti->getNoteObj() );
3264 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3266 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3268 if (model && model==currentModel() )
3272 if (!oldsel.indexes().isEmpty() )
3274 ti=model->getItem(oldsel.indexes().first());
3276 // Don't update note if both treeItem and textEditor are empty
3277 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3278 // ti->setNoteObj (textEditor->getNoteObj(),false );
3280 if (!newsel.indexes().isEmpty() )
3282 ti=model->getItem(newsel.indexes().first());
3283 if (!ti->hasEmptyNote() )
3284 textEditor->setNote(ti->getNoteObj() );
3286 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3288 // Show URL and link in statusbar
3290 QString s=ti->getURL();
3291 if (!s.isEmpty() ) status+="URL: "+s+" ";
3293 if (!s.isEmpty() ) status+="Link: "+s;
3294 if (!status.isEmpty() ) statusMessage (status);
3297 textEditor->setInactive();
3303 void Main::updateActions()
3305 VymModel *m =currentModel();
3309 actionFilePrint->setEnabled (true);
3311 // Link style in context menu
3312 switch (m->getMapLinkStyle())
3314 case LinkableMapObj::Line:
3315 actionFormatLinkStyleLine->setOn(true);
3317 case LinkableMapObj::Parabel:
3318 actionFormatLinkStyleParabel->setOn(true);
3320 case LinkableMapObj::PolyLine:
3321 actionFormatLinkStylePolyLine->setOn(true);
3323 case LinkableMapObj::PolyParabel:
3324 actionFormatLinkStylePolyParabel->setOn(true);
3331 QPixmap pix( 16, 16 );
3332 pix.fill( m->getMapBackgroundColor() );
3333 actionFormatBackColor->setIconSet( pix );
3334 pix.fill( m->getSelectionColor() );
3335 actionFormatSelectionColor->setIconSet( pix );
3336 pix.fill( m->getMapDefLinkColor() );
3337 actionFormatLinkColor->setIconSet( pix );
3340 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3345 actionFilePrint->setEnabled (false);
3348 // updateActions is also called when NoteEditor is closed
3349 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3350 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3351 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3353 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3354 actionFormatLinkColorHint->setOn(true);
3356 actionFormatLinkColorHint->setOn(false);
3359 if (m && m->hasChanged() )
3360 actionFileSave->setEnabled( true);
3362 actionFileSave->setEnabled( false);
3363 if (m && m->isUndoAvailable())
3364 actionUndo->setEnabled( true);
3366 actionUndo->setEnabled( false);
3368 if (m && m->isRedoAvailable())
3369 actionRedo->setEnabled( true);
3371 actionRedo->setEnabled( false);
3375 TreeItem *selti=m->getSelectedItem();
3376 BranchItem *selbi=m->getSelectedBranch();
3379 if (selbi || selti->getType()==TreeItem::Image)
3381 actionFormatHideLinkUnselected->setOn (((MapItem*)selti)->getHideLinkUnselected());
3382 actionFormatHideLinkUnselected->setEnabled (true);
3385 if (selbi) // FIXME-4 many properties of former BranchObj are in TreeItem meanwhile...
3387 // Take care of links // updateActions: FIXME-1
3389 if (bo->countXLinks()==0)
3391 branchXLinksContextMenuEdit->clear();
3392 branchXLinksContextMenuFollow->clear();
3397 branchXLinksContextMenuEdit->clear();
3398 branchXLinksContextMenuFollow->clear();
3399 for (int i=0; i<=bo->countXLinks();i++)
3401 bot=bo->XLinkTargetAt(i);
3404 s=bot->getHeading();
3405 if (s.length()>xLinkMenuWidth)
3406 s=s.left(xLinkMenuWidth)+"...";
3407 branchXLinksContextMenuFollow->addAction (s);
3408 branchXLinksContextMenuEdit->addAction (s);
3414 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3417 actionToggleScroll->setEnabled (true);
3418 if ( selbi->isScrolled() )
3419 actionToggleScroll->setOn(true);
3421 actionToggleScroll->setOn(false);
3423 if ( selti->getURL().isEmpty() )
3425 actionOpenURL->setEnabled (false);
3426 actionOpenURLTab->setEnabled (false);
3430 actionOpenURL->setEnabled (true);
3431 actionOpenURLTab->setEnabled (true);
3433 if ( selti->getVymLink().isEmpty() )
3435 actionOpenVymLink->setEnabled (false);
3436 actionDeleteVymLink->setEnabled (false);
3439 actionOpenVymLink->setEnabled (true);
3440 actionDeleteVymLink->setEnabled (true);
3443 if (selbi->canMoveUp())
3444 actionMoveUp->setEnabled (true);
3446 actionMoveUp->setEnabled (false);
3447 if (selbi->canMoveDown())
3448 actionMoveDown->setEnabled (true);
3450 actionMoveDown->setEnabled (false);
3452 actionSortChildren->setEnabled (true);
3454 actionToggleHideExport->setEnabled (true);
3455 actionToggleHideExport->setOn (selbi->hideInExport() );
3457 actionCopy->setEnabled (true);
3458 actionCut->setEnabled (true);
3459 if (!clipboardEmpty)
3460 actionPaste->setEnabled (true);
3462 actionPaste->setEnabled (false);
3463 for (int i=0; i<actionListBranches.size(); ++i)
3464 actionListBranches.at(i)->setEnabled(true);
3465 actionDelete->setEnabled (true);
3467 if ( selti->getType()==TreeItem::Image)
3469 actionOpenURL->setEnabled (false);
3470 actionOpenVymLink->setEnabled (false);
3471 actionDeleteVymLink->setEnabled (false);
3472 actionToggleHideExport->setEnabled (true);
3473 actionToggleHideExport->setOn (selti->hideInExport() );
3476 actionCopy->setEnabled (true);
3477 actionCut->setEnabled (true);
3478 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3479 for (int i=0; i<actionListBranches.size(); ++i)
3480 actionListBranches.at(i)->setEnabled(false);
3481 actionDelete->setEnabled (true);
3482 actionMoveUp->setEnabled (false);
3483 actionMoveDown->setEnabled (false);
3488 actionCopy->setEnabled (false);
3489 actionCut->setEnabled (false);
3490 actionPaste->setEnabled (false);
3491 for (int i=0; i<actionListBranches.size(); ++i)
3492 actionListBranches.at(i)->setEnabled(false);
3494 actionToggleScroll->setEnabled (false);
3495 actionOpenURL->setEnabled (false);
3496 actionOpenVymLink->setEnabled (false);
3497 actionDeleteVymLink->setEnabled (false);
3498 actionHeading2URL->setEnabled (false);
3499 actionDelete->setEnabled (false);
3500 actionMoveUp->setEnabled (false);
3501 actionMoveDown->setEnabled (false);
3502 actionFormatHideLinkUnselected->setEnabled (false);
3503 actionSortChildren->setEnabled (false);
3504 actionToggleHideExport->setEnabled (false);
3509 Main::ModMode Main::getModMode()
3511 if (actionModModeColor->isOn()) return ModModeColor;
3512 if (actionModModeCopy->isOn()) return ModModeCopy;
3513 if (actionModModeXLink->isOn()) return ModModeXLink;
3517 bool Main::autoEditNewBranch()
3519 return actionSettingsAutoEditNewBranch->isOn();
3522 bool Main::autoSelectNewBranch()
3524 return actionSettingsAutoSelectNewBranch->isOn();
3527 void Main::windowShowNoteEditor()
3529 textEditor->setShowWithMain(true);
3531 actionViewToggleNoteEditor->setOn (true);
3534 void Main::windowHideNoteEditor()
3536 textEditor->setShowWithMain(false);
3538 actionViewToggleNoteEditor->setOn (false);
3541 void Main::setScript (const QString &script)
3543 scriptEditor->setScript (script);
3546 void Main::runScript (const QString &script)
3548 VymModel *m=currentModel();
3549 if (m) m->runScript (script);
3552 void Main::runScriptEverywhere (const QString &script)
3555 for (int i=0;i<=tabWidget->count() -1;i++)
3557 me=(MapEditor*)tabWidget->page(i);
3558 if (me) me->getModel()->runScript (script);
3562 void Main::windowNextEditor()
3564 if (tabWidget->currentIndex() < tabWidget->count())
3565 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3568 void Main::windowPreviousEditor()
3570 if (tabWidget->currentIndex() >0)
3571 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3574 void Main::standardFlagChanged()
3578 if ( actionSettingsUseFlagGroups->isOn() )
3579 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3581 currentModel()->toggleStandardFlag(sender()->name());
3586 void Main::testFunction1()
3588 if (!currentMapEditor()) return;
3589 currentMapEditor()->testFunction1();
3592 void Main::testFunction2()
3594 if (!currentMapEditor()) return;
3595 currentMapEditor()->setFocus();
3598 void Main::testCommand()
3600 if (!currentMapEditor()) return;
3601 scriptEditor->show();
3604 QString com = QInputDialog::getText(
3605 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3606 if (ok) currentMapEditor()->parseAtom(com);
3610 void Main::helpDoc()
3612 QString locale = QLocale::system().name();
3614 if (locale.left(2)=="es")
3615 docname="vym_es.pdf";
3619 QStringList searchList;
3621 #if defined(Q_OS_MACX)
3622 searchList << "./vym.app/Contents/Resources/doc";
3623 #elif defined(Q_OS_WIN32)
3624 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3626 #if defined(VYM_DOCDIR)
3627 searchList << VYM_DOCDIR;
3629 // default path in SUSE LINUX
3630 searchList << "/usr/share/doc/packages/vym";
3633 searchList << "doc"; // relative path for easy testing in tarball
3634 searchList << "doc/tex"; // Easy testing working on vym.tex
3635 searchList << "/usr/share/doc/vym"; // Debian
3636 searchList << "/usr/share/doc/packages";// Knoppix
3640 for (int i=0; i<searchList.count(); ++i)
3642 docfile.setFileName(searchList.at(i)+"/"+docname);
3643 if (docfile.exists())
3652 QMessageBox::critical(0,
3653 tr("Critcal error"),
3654 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3659 Process *pdfProc = new Process();
3660 args << QDir::toNativeSeparators(docfile.fileName());
3662 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3663 if ( !pdfProc->waitForStarted() )
3666 QMessageBox::warning(0,
3668 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3669 tr("Please use Settings->")+tr("Set application to open PDF files"));
3676 void Main::helpDemo()
3678 QStringList filters;
3679 filters <<"VYM example map (*.vym)";
3680 QFileDialog *fd=new QFileDialog( this);
3681 #if defined(Q_OS_MACX)
3682 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3684 // default path in SUSE LINUX
3685 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3688 fd->setFileMode (QFileDialog::ExistingFiles);
3689 fd->setFilters (filters);
3690 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3694 if ( fd->exec() == QDialog::Accepted )
3696 lastFileDir=fd->directory().path();
3697 QStringList flist = fd->selectedFiles();
3698 QStringList::Iterator it = flist.begin();
3699 while( it != flist.end() )
3702 fileLoad(*it, NewMap);
3710 void Main::helpAbout()
3713 ad.setName ("aboutwindow");
3714 ad.setMinimumSize(500,500);
3715 ad.resize (QSize (500,500));
3719 void Main::helpAboutQT()
3721 QMessageBox::aboutQt( this, "Qt Application Example" );
3724 void Main::callMacro ()
3726 QAction *action = qobject_cast<QAction *>(sender());
3730 i=action->data().toInt();
3731 QString mDir (settings.value ("macros/macroDir").toString() );
3733 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3735 if ( !f.open( QIODevice::ReadOnly ) )
3737 QMessageBox::warning(0,
3739 tr("Couldn't find a macro at %1.\n").arg(fn)+
3740 tr("Please use Settings->")+tr("Set directory for vym macros"));
3744 QTextStream ts( &f );
3745 QString macro= ts.read();
3747 if (! macro.isEmpty())
3749 VymModel *m=currentModel();
3750 if (m) m->runScript(macro);