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"
24 #include "xlinkitem.h"
26 #include <modeltest.h> // FIXME-3
28 #if defined(Q_OS_WIN32)
29 // Define only this structure as opposed to
30 // including full 'windows.h'. FindWindow
31 // clashes with the one in Win32 API.
32 typedef struct _PROCESS_INFORMATION
38 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
41 extern TextEditor *textEditor;
42 extern Main *mainWindow;
43 extern QString tmpVymDir;
44 extern QString clipboardDir;
45 extern QString clipboardFile;
46 extern bool clipboardEmpty;
47 extern int statusbarTime;
48 extern FlagRow *standardFlagsMaster;
49 extern FlagRow *systemFlagsMaster;
50 extern QString vymName;
51 extern QString vymVersion;
52 extern QString vymBuildDate;
55 QMenu* branchContextMenu;
56 QMenu* branchAddContextMenu;
57 QMenu* branchRemoveContextMenu;
58 QMenu* branchLinksContextMenu;
59 QMenu* branchXLinksContextMenuEdit;
60 QMenu* branchXLinksContextMenuFollow;
61 QMenu* floatimageContextMenu;
62 QMenu* canvasContextMenu;
63 QMenu* fileLastMapsMenu;
64 QMenu* fileImportMenu;
65 QMenu* fileExportMenu;
68 extern Settings settings;
69 extern Options options;
70 extern ImageIO imageIO;
72 extern QDir vymBaseDir;
73 extern QDir lastImageDir;
74 extern QDir lastFileDir;
75 #if defined(Q_OS_WIN32)
76 extern QDir vymInstallDir;
78 extern QString iconPath;
79 extern QString flagsPath;
82 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
83 QMainWindow(parent,name,f)
87 setCaption ("VYM - View Your Mind");
89 // Load window settings
90 #if defined(Q_OS_WIN32)
91 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
93 setWindowState(Qt::WindowMaximized);
98 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
99 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
102 // Sometimes we may need to remember old selections
106 currentColor=Qt::black;
108 // Create unique temporary directory
110 tmpVymDir=makeTmpDir (ok,"vym");
113 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
116 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
118 // Create direcctory for clipboard
119 clipboardDir=tmpVymDir+"/clipboard";
120 clipboardFile="map.xml";
121 QDir d(clipboardDir);
122 d.mkdir (clipboardDir,true);
123 makeSubDirs (clipboardDir);
128 // Satellite windows //////////////////////////////////////////
130 historyWindow=new HistoryWindow();
131 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
134 branchPropertyWindow = new BranchPropertyWindow();
135 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
137 // Connect TextEditor, so that we can update flags if text changes
138 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
139 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
141 // Connect HistoryWindow, so that we can update flags
142 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
145 // Initialize script editor
146 scriptEditor = new SimpleScriptEditor();
147 scriptEditor->move (50,50);
149 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
150 this, SLOT( runScript( QString ) ) );
153 // Initialize Find window
154 findWindow=new FindWindow(NULL);
155 findWindow->move (x(),y()+70);
156 connect (findWindow, SIGNAL( findButton(QString) ),
157 this, SLOT(editFind(QString) ) );
158 connect (findWindow, SIGNAL( somethingChanged() ),
159 this, SLOT(editFindChanged() ) );
161 // Initialize some settings, which are platform dependant
164 // application to open URLs
165 p="/mainwindow/readerURL";
166 #if defined(Q_OS_LINUX)
167 s=settings.value (p,"xdg-open").toString();
169 #if defined(Q_OS_MACX)
170 s=settings.value (p,"/usr/bin/open").toString();
173 #if defined(Q_OS_WIN32)
174 // Assume that system has been set up so that
175 // Explorer automagically opens up the URL
176 // in the user's preferred browser.
177 s=settings.value (p,"explorer").toString();
179 s=settings.value (p,"mozilla").toString();
183 settings.setValue( p,s);
185 // application to open PDFs
186 p="/mainwindow/readerPDF";
187 #if defined(Q_OS_LINUX)
188 s=settings.value (p,"xdg-open").toString();
190 #if defined(Q_OS_MACX)
191 s=settings.value (p,"/usr/bin/open").toString();
192 #elif defined(Q_OS_WIN32)
193 s=settings.value (p,"acrord32").toString();
195 s=settings.value (p,"acroread").toString();
198 settings.setValue( p,s);
200 // width of xLinksMenu
203 // Create tab widget which holds the maps
204 tabWidget= new QTabWidget (this);
205 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
206 this, SLOT( editorChanged( QWidget * ) ) );
208 setCentralWidget(tabWidget);
212 setupFormatActions();
216 setupNetworkActions();
217 setupSettingsActions();
220 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
223 // Status bar and progress bar there
226 progressBar=new QProgressBar;
228 statusBar()->addPermanentWidget(progressBar);
230 restoreState (settings.value("/mainwindow/state",0).toByteArray());
238 #if defined(Q_OS_WIN32)
239 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
241 settings.setValue ("/mainwindow/geometry/size", size());
242 settings.setValue ("/mainwindow/geometry/pos", pos());
243 settings.setValue ("/mainwindow/state",saveState(0));
245 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
246 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
247 settings.setValue( "/version/version", vymVersion );
248 settings.setValue( "/version/builddate", vymBuildDate );
250 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
251 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
252 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
253 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
254 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
255 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
256 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
257 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
259 //TODO save scriptEditor settings
261 // call the destructors
263 delete historyWindow;
264 delete branchPropertyWindow;
267 // Remove temporary directory
268 removeDir (QDir(tmpVymDir));
271 void Main::loadCmdLine()
273 /* TODO draw some kind of splashscreen while loading...
279 QStringList flist=options.getFileList();
280 QStringList::Iterator it=flist.begin();
282 while (it !=flist.end() )
284 fileLoad (*it, NewMap);
290 void Main::statusMessage(const QString &s)
292 // Surpress messages while progressbar during
294 if (progressMin==progressMax)
295 statusBar()->message( s);
298 void Main::setProgressMinimum (int min)
300 progressBar->setMinimum(min);
304 void Main::setProgressMaximum (int max)
306 progressBar->setMaximum(max);
310 statusBar()->addPermanentWidget(progressBar);
315 void Main::setProgressValue (int v)
317 progressBar->setValue (v);
320 void Main::removeProgressBar()
323 statusBar()->removeWidget(progressBar);
324 progressMax=progressMin=0;
327 void Main::closeEvent (QCloseEvent* )
333 void Main::setupFileActions()
335 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
336 QToolBar *tb = addToolBar( tr ("&Map") );
337 tb->setObjectName ("mapTB");
340 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
341 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
342 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
344 fileMenu->addAction (a);
345 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
347 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
348 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
349 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
350 fileMenu->addAction (a);
351 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
354 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
355 a->setStatusTip (tr( "Open","Status tip File menu" ) );
356 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
358 fileMenu->addAction (a);
359 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
361 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
362 fileMenu->addSeparator();
364 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
365 a->setStatusTip ( tr( "Save","Status tip file menu" ));
366 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
368 fileMenu->addAction (a);
369 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
372 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
373 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
374 fileMenu->addAction (a);
375 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
377 fileMenu->addSeparator();
379 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
381 a = new QAction(tr("KDE 3 Bookmarks"), this);
382 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
383 a->addTo (fileImportMenu);
384 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
386 a = new QAction(tr("KDE 4 Bookmarks"), this);
387 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
388 a->addTo (fileImportMenu);
389 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
391 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
393 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
394 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
395 a->addTo (fileImportMenu);
396 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
399 a = new QAction("Freemind...",this);
400 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
401 fileImportMenu->addAction (a);
402 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
404 a = new QAction("Mind Manager...",this);
405 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
406 fileImportMenu->addAction (a);
407 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
409 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
410 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
411 fileImportMenu->addAction (a);
412 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
414 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
416 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
417 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
418 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
419 fileExportMenu->addAction (a);
421 a = new QAction( "Open Office...", this);
422 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
423 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
424 fileExportMenu->addAction (a);
426 a = new QAction( "Webpage (XHTML)...",this );
427 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
428 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
429 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
430 fileExportMenu->addAction (a);
432 a = new QAction( "Text (ASCII)...", this);
433 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
434 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
435 fileExportMenu->addAction (a);
437 a = new QAction( "Spreadsheet (CSV)...", this);
438 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
439 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
440 fileExportMenu->addAction (a);
442 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
443 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
444 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
445 fileExportMenu->addAction (a);
447 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
448 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
449 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
450 fileExportMenu->addAction (a);
452 a = new QAction( "Taskjuggler...", this );
453 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
454 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
455 fileExportMenu->addAction (a);
457 a = new QAction( "LaTeX...", this);
458 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
459 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
460 fileExportMenu->addAction (a);
462 a = new QAction( "XML..." , this );
463 a->setStatusTip (tr( "Export as %1").arg("XML"));
464 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
465 fileExportMenu->addAction (a);
467 fileMenu->addSeparator();
469 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
470 a->setStatusTip ( tr( "Print" ,"File menu") );
471 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
473 fileMenu->addAction (a);
474 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
477 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
478 a->setStatusTip (tr( "Close Map" ) );
479 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
480 fileMenu->addAction (a);
481 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
483 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
484 a->setStatusTip ( tr( "Exit")+" "+vymName );
485 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
486 fileMenu->addAction (a);
487 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
492 void Main::setupEditActions()
494 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
495 tb->setLabel( "Edit Actions" );
496 tb->setObjectName ("actionsTB");
497 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
501 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
502 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
503 a->setStatusTip (tr( "Undo" ) );
504 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
505 a->setEnabled (false);
507 editMenu->addAction (a);
510 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
511 a->setStatusTip (tr( "Redo" ));
512 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
514 editMenu->addAction (a);
515 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
518 editMenu->addSeparator();
519 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
520 a->setStatusTip ( tr( "Copy" ) );
521 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
522 a->setEnabled (false);
524 editMenu->addAction (a);
525 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
528 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
529 a->setStatusTip ( tr( "Cut" ) );
530 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
531 a->setEnabled (false);
533 editMenu->addAction (a);
535 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
537 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
538 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
539 a->setStatusTip ( tr( "Paste" ) );
540 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
541 a->setEnabled (false);
543 editMenu->addAction (a);
546 // Shortcut to delete selection
547 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
548 a->setStatusTip (tr( "Delete Selection" ));
549 a->setShortcut ( Qt::Key_Delete); //Delete selection
550 a->setShortcutContext (Qt::WindowShortcut);
552 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
555 // Shortcut to add attribute
556 a= new QAction(tr( "Add attribute" ), this);
557 a->setShortcut ( Qt::Key_Q);
558 a->setShortcutContext (Qt::WindowShortcut);
560 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
561 actionAddAttribute= a;
564 // Shortcut to add mapcenter
565 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
566 a->setShortcut ( Qt::Key_M);
567 a->setShortcutContext (Qt::WindowShortcut);
568 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
569 //actionListBranches.append(a);
571 actionAddMapCenter = a;
574 // Shortcut to add branch
575 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
576 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
577 alt->setShortcut (Qt::Key_A); //Add branch
578 alt->setShortcutContext (Qt::WindowShortcut);
580 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
581 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
582 a->setStatusTip ( tr( "Add a branch as child of selection" ));
583 a->setShortcut (Qt::Key_Insert); //Add branch
584 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
585 actionListBranches.append(a);
586 #if defined (Q_OS_MACX)
587 // In OSX show different shortcut in menues, the keys work indepently always
592 editMenu->addAction (actionAddBranch);
593 tb->addAction (actionAddBranch);
596 // Add branch by inserting it at selection
597 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
598 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
599 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
600 a->setShortcutContext (Qt::WindowShortcut);
602 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
603 a->setEnabled (false);
604 actionListBranches.append(a);
605 actionAddBranchBefore=a;
606 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
607 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
608 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
609 a->setShortcutContext (Qt::WindowShortcut);
611 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
612 actionListBranches.append(a);
615 a = new QAction(tr( "Add branch above","Edit menu" ), this);
616 a->setStatusTip ( tr( "Add a branch above selection" ));
617 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
618 a->setShortcutContext (Qt::WindowShortcut);
620 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
621 a->setEnabled (false);
622 actionListBranches.append(a);
623 actionAddBranchAbove=a;
624 a = new QAction(tr( "Add branch above","Edit menu" ), this);
625 a->setStatusTip ( tr( "Add a branch above selection" ));
626 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
627 a->setShortcutContext (Qt::WindowShortcut);
629 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
630 actionListBranches.append(a);
633 a = new QAction(tr( "Add branch below","Edit menu" ), this);
634 a->setStatusTip ( tr( "Add a branch below selection" ));
635 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
636 a->setShortcutContext (Qt::WindowShortcut);
638 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
639 a->setEnabled (false);
640 actionListBranches.append(a);
641 actionAddBranchBelow=a;
642 a = new QAction(tr( "Add branch below","Edit menu" ), this);
643 a->setStatusTip ( tr( "Add a branch below selection" ));
644 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
645 a->setShortcutContext (Qt::WindowShortcut);
647 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
648 actionListBranches.append(a);
650 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
651 a->setStatusTip ( tr( "Move branch up" ) );
652 a->setShortcut (Qt::Key_PageUp ); // Move branch up
653 a->setEnabled (false);
655 editMenu->addAction (a);
656 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
659 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
660 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
661 a->setStatusTip (tr( "Move branch down" ) );
662 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
663 a->setEnabled (false);
665 editMenu->addAction (a);
668 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
669 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
670 a->setEnabled (true);
672 editMenu->addAction (a);
673 actionSortChildren=a;
675 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
676 alt->setShortcut ( Qt::Key_S ); // Scroll branch
677 alt->setStatusTip (tr( "Scroll branch" ));
678 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
679 #if defined(Q_OS_MACX)
680 actionToggleScroll=alt;
682 actionToggleScroll=a;
684 actionToggleScroll->setEnabled (false);
685 actionToggleScroll->setToggleAction(true);
686 tb->addAction (actionToggleScroll);
687 editMenu->addAction ( actionToggleScroll);
688 editMenu->addAction (actionToggleScroll);
691 actionListBranches.append(actionToggleScroll);
693 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
694 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
695 a->setStatusTip (tr( "Expand all branches" ));
696 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
698 actionExpandAll->setEnabled (false);
699 actionExpandAll->setToggleAction(false);
700 //tb->addAction (actionExpandAll);
701 editMenu->addAction ( actionExpandAll);
703 actionListBranches.append(actionExpandAll);
706 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
707 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
708 editMenu->addAction (a);
709 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
711 editMenu->addSeparator();
713 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
714 a->setStatusTip (tr( "Find" ) );
715 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
716 editMenu->addAction (a);
717 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
719 editMenu->addSeparator();
721 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
722 a->setShortcut (Qt::CTRL + Qt::Key_U );
723 a->setShortcut (tr( "Open URL" ));
726 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
729 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
730 a->setStatusTip (tr( "Open URL in new tab" ));
731 //a->setShortcut (Qt::CTRL+Qt::Key_U );
733 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
736 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
737 a->setStatusTip (tr( "Open all URLs in subtree" ));
739 actionListBranches.append(a);
740 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
741 actionOpenMultipleURLTabs=a;
743 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
744 a->setStatusTip ( tr( "Edit URL" ) );
745 a->setShortcut ( Qt::Key_U );
746 a->setShortcutContext (Qt::WindowShortcut);
747 actionListBranches.append(a);
749 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
752 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
753 a->setStatusTip ( tr( "Edit local URL" ) );
754 a->setShortcut (Qt::SHIFT + Qt::Key_U );
755 a->setShortcutContext (Qt::WindowShortcut);
756 actionListBranches.append(a);
758 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
761 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
762 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
763 a->setEnabled (false);
764 actionListBranches.append(a);
765 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
768 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
769 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
770 a->setEnabled (false);
771 actionListBranches.append(a);
772 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
773 actionBugzilla2URL=a;
775 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
776 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
777 a->setEnabled (false);
778 actionListBranches.append(a);
779 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
782 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
783 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
785 a->setEnabled (false);
786 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
789 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
790 a->setStatusTip ( tr( "Open all vym links in subtree" ));
791 a->setEnabled (false);
792 actionListBranches.append(a);
793 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
794 actionOpenMultipleVymLinks=a;
797 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
798 a->setEnabled (false);
799 a->setStatusTip ( tr( "Edit link to another vym map" ));
800 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
801 actionListBranches.append(a);
804 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
805 a->setStatusTip ( tr( "Delete link to another vym map" ));
806 a->setEnabled (false);
807 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
808 actionDeleteVymLink=a;
810 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
811 a->setStatusTip ( tr( "Hide object in exports" ) );
812 a->setShortcut (Qt::Key_H );
813 a->setToggleAction(true);
815 a->setEnabled (false);
816 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
817 actionToggleHideExport=a;
819 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
820 a->setStatusTip ( tr( "Edit Map Info" ));
821 a->setEnabled (true);
822 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
825 // Import at selection (adding to selection)
826 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
827 a->setStatusTip (tr( "Add map at selection" ));
828 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
829 a->setEnabled (false);
830 actionListBranches.append(a);
833 // Import at selection (replacing selection)
834 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
835 a->setStatusTip (tr( "Replace selection with map" ));
836 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
837 a->setEnabled (false);
838 actionListBranches.append(a);
839 actionImportReplace=a;
842 a = new QAction( tr( "Save selection","Edit menu" ), this);
843 a->setStatusTip (tr( "Save selection" ));
844 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
845 a->setEnabled (false);
846 actionListBranches.append(a);
849 // Only remove branch, not its children
850 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
851 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
852 a->setShortcut (Qt::ALT + Qt::Key_Delete );
853 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
854 a->setEnabled (false);
856 actionListBranches.append(a);
857 actionDeleteKeepChildren=a;
859 // Only remove children of a branch
860 a = new QAction( tr( "Remove children","Edit menu" ), this);
861 a->setStatusTip (tr( "Remove children of branch" ));
862 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
863 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
864 a->setEnabled (false);
865 actionListBranches.append(a);
866 actionDeleteChildren=a;
868 a = new QAction( tr( "Add Image...","Edit menu" ), this);
869 a->setStatusTip (tr( "Add Image" ));
870 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
873 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
874 a->setStatusTip (tr( "Set properties for selection" ));
875 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
876 a->setShortcutContext (Qt::WindowShortcut);
877 a->setToggleAction (true);
879 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
880 actionViewTogglePropertyWindow=a;
884 void Main::setupFormatActions()
886 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
888 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
889 tb->setObjectName ("formatTB");
892 pix.fill (Qt::black);
893 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
894 a->setStatusTip ( tr( "Set Color" ));
895 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
897 formatMenu->addAction (a);
899 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
900 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
901 a->setShortcut (Qt::CTRL + Qt::Key_K );
902 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
903 a->setEnabled (false);
905 formatMenu->addAction (a);
906 actionListBranches.append(a);
907 actionFormatPickColor=a;
909 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
910 a->setStatusTip ( tr( "Color branch" ) );
911 a->setShortcut (Qt::CTRL + Qt::Key_B);
912 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
913 a->setEnabled (false);
915 formatMenu->addAction (a);
916 actionListBranches.append(a);
917 actionFormatColorSubtree=a;
919 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
920 a->setStatusTip ( tr( "Color Subtree" ));
921 a->setShortcut (Qt::CTRL + Qt::Key_T);
922 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
923 a->setEnabled (false);
924 formatMenu->addAction (a);
926 actionListBranches.append(a);
927 actionFormatColorSubtree=a;
929 formatMenu->addSeparator();
930 actionGroupFormatLinkStyles=new QActionGroup ( this);
931 actionGroupFormatLinkStyles->setExclusive (true);
932 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
933 a->setStatusTip (tr( "Line" ));
934 a->setToggleAction(true);
935 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
936 formatMenu->addAction (a);
937 actionFormatLinkStyleLine=a;
938 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
939 a->setStatusTip (tr( "Line" ));
940 a->setToggleAction(true);
941 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
942 formatMenu->addAction (a);
943 actionFormatLinkStyleParabel=a;
944 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
945 a->setStatusTip (tr( "PolyLine" ));
946 a->setToggleAction(true);
947 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
948 formatMenu->addAction (a);
949 actionFormatLinkStylePolyLine=a;
950 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
951 a->setStatusTip (tr( "PolyParabel" ) );
952 a->setToggleAction(true);
953 a->setChecked (true);
954 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
955 formatMenu->addAction (a);
956 actionFormatLinkStylePolyParabel=a;
958 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
959 a->setStatusTip (tr( "Hide link" ));
960 a->setToggleAction(true);
961 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
962 actionFormatHideLinkUnselected=a;
964 formatMenu->addSeparator();
965 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
966 a->setStatusTip (tr( "Use same color for links and headings" ));
967 a->setToggleAction(true);
968 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
969 formatMenu->addAction (a);
970 actionFormatLinkColorHint=a;
972 pix.fill (Qt::white);
973 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
974 a->setStatusTip (tr( "Set Link Color" ));
975 formatMenu->addAction (a);
976 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
977 actionFormatLinkColor=a;
979 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
980 a->setStatusTip (tr( "Set Selection Color" ));
981 formatMenu->addAction (a);
982 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
983 actionFormatSelectionColor=a;
985 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
986 a->setStatusTip (tr( "Set Background Color" ));
987 formatMenu->addAction (a);
988 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
989 actionFormatBackColor=a;
991 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
992 a->setStatusTip (tr( "Set Background image" ));
993 formatMenu->addAction (a);
994 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
995 actionFormatBackImage=a;
999 void Main::setupViewActions()
1001 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1002 tb->setLabel( "View Actions" );
1003 tb->setObjectName ("viewTB");
1004 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1007 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1008 a->setStatusTip ( tr( "Zoom reset" ) );
1009 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1011 viewMenu->addAction (a);
1012 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1014 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1015 a->setStatusTip (tr( "Zoom in" ));
1016 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1018 viewMenu->addAction (a);
1019 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1021 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1022 a->setStatusTip (tr( "Zoom out" ));
1023 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1025 viewMenu->addAction (a);
1026 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1028 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1029 a->setStatusTip (tr( "Show selection" ));
1030 a->setShortcut (Qt::Key_Period);
1032 viewMenu->addAction (a);
1033 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1035 viewMenu->addSeparator();
1037 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1038 a->setStatusTip ( tr( "Show Note Editor" ));
1039 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1040 a->setToggleAction(true);
1042 viewMenu->addAction (a);
1043 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1044 actionViewToggleNoteEditor=a;
1046 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1047 a->setStatusTip ( tr( "Show History Window" ));
1048 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1049 a->setToggleAction(true);
1051 viewMenu->addAction (a);
1052 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1053 actionViewToggleHistoryWindow=a;
1055 viewMenu->addAction (actionViewTogglePropertyWindow);
1057 viewMenu->addSeparator();
1059 a = new QAction(tr( "Antialiasing","View action" ),this );
1060 a->setStatusTip ( tr( "Antialiasing" ));
1061 a->setToggleAction(true);
1062 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1063 viewMenu->addAction (a);
1064 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1065 actionViewToggleAntiAlias=a;
1067 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1068 a->setStatusTip (a->text());
1069 a->setToggleAction(true);
1070 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1071 viewMenu->addAction (a);
1072 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1073 actionViewToggleSmoothPixmapTransform=a;
1075 a = new QAction(tr( "Next Map","View action" ), this);
1076 a->setStatusTip (a->text());
1077 a->setShortcut (Qt::ALT + Qt::Key_N );
1078 viewMenu->addAction (a);
1079 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1081 a = new QAction (tr( "Previous Map","View action" ), this );
1082 a->setStatusTip (a->text());
1083 a->setShortcut (Qt::ALT + Qt::Key_P );
1084 viewMenu->addAction (a);
1085 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1089 void Main::setupModeActions()
1091 //QPopupMenu *menu = new QPopupMenu( this );
1092 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1094 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1095 tb->setObjectName ("modesTB");
1097 actionGroupModModes=new QActionGroup ( this);
1098 actionGroupModModes->setExclusive (true);
1099 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1100 a->setShortcut (Qt::Key_J);
1101 a->setStatusTip ( tr( "Use modifier to color branches" ));
1102 a->setToggleAction(true);
1105 actionModModeColor=a;
1107 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1108 a->setShortcut( Qt::Key_K);
1109 a->setStatusTip( tr( "Use modifier to copy" ));
1110 a->setToggleAction(true);
1112 actionModModeCopy=a;
1114 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1115 a->setShortcut (Qt::Key_L);
1116 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1117 a->setToggleAction(true);
1119 actionModModeXLink=a;
1123 void Main::setupFlagActions()
1125 // Create System Flags
1128 Flag *flag=new Flag;;
1129 flag->setVisible(true);
1131 flag->load(QPixmap(flagsPath+"flag-note.png"));
1132 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1134 flag->load(QPixmap(flagsPath+"flag-url.png"));
1135 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1137 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1138 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1140 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1141 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1143 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1144 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1146 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1147 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1149 // Create Standard Flags
1150 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1151 tb->setObjectName ("standardFlagTB");
1152 standardFlagsMaster->setToolBar (tb);
1154 flag->load(flagsPath+"flag-exclamationmark.png");
1155 flag->setGroup("standard-mark");
1156 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1158 flag->load(flagsPath+"flag-questionmark.png");
1159 flag->setGroup("standard-mark");
1160 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1162 flag->load(flagsPath+"flag-hook-green.png");
1163 flag->setGroup("standard-hook");
1164 setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
1166 flag->load(flagsPath+"flag-cross-red.png");
1167 flag->setGroup("standard-hook");
1168 setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
1171 flag->load(flagsPath+"flag-stopsign.png");
1172 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1174 flag->load(flagsPath+"flag-smiley-good.png");
1175 flag->setGroup("standard-smiley");
1176 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1178 flag->load(flagsPath+"flag-smiley-sad.png");
1179 flag->setGroup("standard-smiley");
1180 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1182 flag->load(flagsPath+"flag-smiley-omg.png");
1183 flag->setGroup("standard-smiley");
1184 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1185 // Original omg.png (in KDE emoticons)
1188 flag->load(flagsPath+"flag-kalarm.png");
1189 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1191 flag->load(flagsPath+"flag-phone.png");
1192 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1194 flag->load(flagsPath+"flag-lamp.png");
1195 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1197 flag->load(flagsPath+"flag-arrow-up.png");
1198 flag->setGroup("standard-arrow");
1199 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1201 flag->load(flagsPath+"flag-arrow-down.png");
1202 flag->setGroup("standard-arrow");
1203 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1205 flag->load(flagsPath+"flag-arrow-2up.png");
1206 flag->setGroup("standard-arrow");
1207 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1209 flag->load(flagsPath+"flag-arrow-2down.png");
1210 flag->setGroup("standard-arrow");
1211 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1214 flag->load(flagsPath+"flag-thumb-up.png");
1215 flag->setGroup("standard-thumb");
1216 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1218 flag->load(flagsPath+"flag-thumb-down.png");
1219 flag->setGroup("standard-thumb");
1220 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1223 flag->load(flagsPath+"flag-rose.png");
1224 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1226 flag->load(flagsPath+"flag-heart.png");
1227 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1229 flag->load(flagsPath+"flag-present.png");
1230 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1232 flag->load(flagsPath+"flag-flash.png");
1233 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1235 // Original: xsldbg_output.png
1236 flag->load(flagsPath+"flag-info.png");
1237 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1239 // Original khelpcenter.png
1240 flag->load(flagsPath+"flag-lifebelt.png");
1241 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1244 flag->setVisible(false);
1245 flag->load(flagsPath+"freemind/warning.png");
1246 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1248 for (int i=1; i<8; i++)
1250 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1251 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1254 flag->load(flagsPath+"freemind/back.png");
1255 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1257 flag->load(flagsPath+"freemind/forward.png");
1258 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1260 flag->load(flagsPath+"freemind/attach.png");
1261 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1263 flag->load(flagsPath+"freemind/clanbomber.png");
1264 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1266 flag->load(flagsPath+"freemind/desktopnew.png");
1267 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1269 flag->load(flagsPath+"freemind/flag.png");
1270 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1273 flag->load(flagsPath+"freemind/gohome.png");
1274 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1277 flag->load(flagsPath+"freemind/kaddressbook.png");
1278 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1280 flag->load(flagsPath+"freemind/knotify.png");
1281 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1283 flag->load(flagsPath+"freemind/korn.png");
1284 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1286 flag->load(flagsPath+"freemind/mail.png");
1287 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1289 flag->load(flagsPath+"freemind/password.png");
1290 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1292 flag->load(flagsPath+"freemind/pencil.png");
1293 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1295 flag->load(flagsPath+"freemind/stop.png");
1296 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1298 flag->load(flagsPath+"freemind/wizard.png");
1299 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1301 flag->load(flagsPath+"freemind/xmag.png");
1302 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1304 flag->load(flagsPath+"freemind/bell.png");
1305 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1307 flag->load(flagsPath+"freemind/bookmark.png");
1308 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1310 flag->load(flagsPath+"freemind/penguin.png");
1311 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1313 flag->load(flagsPath+"freemind/licq.png");
1314 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1317 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1319 flag->setName(name);
1320 flag->setToolTip (tooltip);
1324 a=new QAction (flag->getPixmap(),name,this);
1327 flag->setAction (a);
1328 a->setVisible (flag->isVisible());
1329 a->setCheckable(true);
1330 a->setObjectName(name);
1331 a->setToolTip(tooltip);
1332 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1333 standardFlagsMaster->addFlag (flag);
1337 systemFlagsMaster->addFlag (flag);
1342 void Main::setupNetworkActions()
1344 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1346 QMenu *netMenu = menuBar()->addMenu( "Network" );
1350 a = new QAction( "Start TCPserver for MapEditor",this);
1351 //a->setStatusTip ( "Set application to open pdf files"));
1352 a->setShortcut ( Qt::Key_T ); //New TCP server
1353 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1354 netMenu->addAction (a);
1356 a = new QAction( "Connect MapEditor to server",this);
1357 //a->setStatusTip ( "Set application to open pdf files"));
1358 a->setShortcut ( Qt::Key_C ); // Connect to server
1359 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1360 netMenu->addAction (a);
1364 void Main::setupSettingsActions()
1366 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1370 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1371 a->setStatusTip ( tr( "Set application to open pdf files"));
1372 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1373 settingsMenu->addAction (a);
1375 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1376 a->setStatusTip( tr( "Set application to open external links"));
1377 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1378 settingsMenu->addAction (a);
1380 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1381 a->setStatusTip( tr( "Set path for macros"));
1382 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1383 settingsMenu->addAction (a);
1385 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1386 a->setStatusTip( tr( "Set number of undo levels"));
1387 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1388 settingsMenu->addAction (a);
1390 settingsMenu->addSeparator();
1392 a = new QAction( tr( "Autosave","Settings action"), this);
1393 a->setStatusTip( tr( "Autosave"));
1394 a->setToggleAction(true);
1395 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1396 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1397 settingsMenu->addAction (a);
1398 actionSettingsAutosaveToggle=a;
1400 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1401 a->setStatusTip( tr( "Autosave time"));
1402 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1403 settingsMenu->addAction (a);
1404 actionSettingsAutosaveTime=a;
1406 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1407 a->setStatusTip( tr( "Write backup file on save"));
1408 a->setToggleAction(true);
1409 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1410 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1411 settingsMenu->addAction (a);
1412 actionSettingsWriteBackupFile=a;
1414 settingsMenu->addSeparator();
1416 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1417 a->setStatusTip( tr( "Edit branch after adding it" ));
1418 a->setToggleAction(true);
1419 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1420 settingsMenu->addAction (a);
1421 actionSettingsAutoEditNewBranch=a;
1423 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1424 a->setStatusTip( tr( "Select branch after adding it" ));
1425 a->setToggleAction(true);
1426 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1427 settingsMenu->addAction (a);
1428 actionSettingsAutoSelectNewBranch=a;
1430 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1431 a->setStatusTip( tr( "Select heading before editing" ));
1432 a->setToggleAction(true);
1433 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1434 settingsMenu->addAction (a);
1435 actionSettingsAutoSelectText=a;
1437 a= new QAction( tr( "Delete key","Settings action" ), this);
1438 a->setStatusTip( tr( "Delete key for deleting branches" ));
1439 a->setToggleAction(true);
1440 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1441 settingsMenu->addAction (a);
1442 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1443 actionSettingsUseDelKey=a;
1445 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1446 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1447 a->setToggleAction(true);
1448 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1449 settingsMenu->addAction (a);
1450 actionSettingsUseFlagGroups=a;
1452 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1453 a->setStatusTip( tr( "Use hide flag during exports " ));
1454 a->setToggleAction(true);
1455 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1456 settingsMenu->addAction (a);
1457 actionSettingsUseHideExport=a;
1459 a = new QAction( tr( "Animation","Settings action"), this);
1460 a->setStatusTip( tr( "Animation"));
1461 a->setToggleAction(true);
1462 a->setOn (settings.value("/animation/use",false).toBool() );
1463 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1464 settingsMenu->addAction (a);
1465 actionSettingsUseAnimation=a;
1469 void Main::setupTestActions()
1471 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1474 a = new QAction( "Test function 1" , this);
1475 a->setStatusTip( "Call test function 1" );
1476 testMenu->addAction (a);
1477 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1479 a = new QAction( "Test function 2" , this);
1480 a->setStatusTip( "Call test function 2" );
1481 testMenu->addAction (a);
1482 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1484 a = new QAction( "Command" , this);
1485 a->setStatusTip( "Enter command to call in editor" );
1486 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1487 testMenu->addAction (a);
1491 void Main::setupHelpActions()
1493 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1496 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1497 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1498 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1499 helpMenu->addAction (a);
1501 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1502 a->setStatusTip( tr( "Open VYM example maps " ));
1503 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1504 helpMenu->addAction (a);
1506 a = new QAction( tr( "About VYM","Help action" ), this);
1507 a->setStatusTip( tr( "About VYM")+vymName);
1508 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1509 helpMenu->addAction (a);
1511 a = new QAction( tr( "About QT","Help action" ), this);
1512 a->setStatusTip( tr( "Information about QT toolkit" ));
1513 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1514 helpMenu->addAction (a);
1518 void Main::setupContextMenus()
1522 // Context Menu for branch or mapcenter
1523 branchContextMenu =new QMenu (this);
1524 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1525 branchContextMenu->addSeparator();
1528 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1529 branchAddContextMenu->addAction (actionPaste );
1530 branchAddContextMenu->addAction ( actionAddMapCenter );
1531 branchAddContextMenu->addAction ( actionAddBranch );
1532 branchAddContextMenu->addAction ( actionAddBranchBefore );
1533 branchAddContextMenu->addAction ( actionAddBranchAbove);
1534 branchAddContextMenu->addAction ( actionAddBranchBelow );
1535 branchAddContextMenu->addSeparator();
1536 branchAddContextMenu->addAction ( actionImportAdd );
1537 branchAddContextMenu->addAction ( actionImportReplace );
1540 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1541 branchRemoveContextMenu->addAction (actionCut);
1542 branchRemoveContextMenu->addAction ( actionDelete );
1543 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1544 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1547 actionSaveBranch->addTo( branchContextMenu );
1548 actionFileNewCopy->addTo (branchContextMenu );
1550 branchContextMenu->addSeparator();
1551 branchContextMenu->addAction ( actionLoadImage);
1553 // Submenu for Links (URLs, vymLinks)
1554 branchLinksContextMenu =new QMenu (this);
1556 branchContextMenu->addSeparator();
1557 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1558 branchLinksContextMenu->addAction ( actionOpenURL );
1559 branchLinksContextMenu->addAction ( actionOpenURLTab );
1560 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1561 branchLinksContextMenu->addAction ( actionURL );
1562 branchLinksContextMenu->addAction ( actionLocalURL );
1563 branchLinksContextMenu->addAction ( actionHeading2URL );
1564 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1565 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1567 branchLinksContextMenu->addAction ( actionFATE2URL );
1569 branchLinksContextMenu->addSeparator();
1570 branchLinksContextMenu->addAction ( actionOpenVymLink );
1571 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1572 branchLinksContextMenu->addAction ( actionVymLink );
1573 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1576 // Context Menu for XLinks in a branch menu
1577 // This will be populated "on demand" in MapEditor::updateActions
1578 branchContextMenu->addSeparator();
1579 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1580 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1581 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1582 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1585 // Context menu for floatimage
1586 floatimageContextMenu =new QMenu (this);
1587 a= new QAction (tr ("Save image","Context action"),this);
1588 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1589 floatimageContextMenu->addAction (a);
1591 floatimageContextMenu->addSeparator();
1592 actionCopy->addTo( floatimageContextMenu );
1593 actionCut->addTo( floatimageContextMenu );
1595 floatimageContextMenu->addSeparator();
1596 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1599 // Context menu for canvas
1600 canvasContextMenu =new QMenu (this);
1601 actionAddMapCenter->addTo( canvasContextMenu );
1602 actionMapInfo->addTo( canvasContextMenu );
1603 canvasContextMenu->insertSeparator();
1604 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1605 canvasContextMenu->insertSeparator();
1606 actionFormatLinkColorHint->addTo( canvasContextMenu );
1607 actionFormatLinkColor->addTo( canvasContextMenu );
1608 actionFormatSelectionColor->addTo( canvasContextMenu );
1609 actionFormatBackColor->addTo( canvasContextMenu );
1610 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1612 // Menu for last opened files
1614 for (int i = 0; i < MaxRecentFiles; ++i)
1616 recentFileActions[i] = new QAction(this);
1617 recentFileActions[i]->setVisible(false);
1618 fileLastMapsMenu->addAction(recentFileActions[i]);
1619 connect(recentFileActions[i], SIGNAL(triggered()),
1620 this, SLOT(fileLoadRecent()));
1622 setupRecentMapsMenu();
1625 void Main::setupRecentMapsMenu()
1627 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1629 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1631 for (int i = 0; i < numRecentFiles; ++i) {
1632 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1633 recentFileActions[i]->setText(text);
1634 recentFileActions[i]->setData(files[i]);
1635 recentFileActions[i]->setVisible(true);
1637 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1638 recentFileActions[j]->setVisible(false);
1641 void Main::setupMacros()
1643 for (int i = 0; i <= 11; i++)
1645 macroActions[i] = new QAction(this);
1646 macroActions[i]->setData(i);
1647 addAction (macroActions[i]);
1648 connect(macroActions[i], SIGNAL(triggered()),
1649 this, SLOT(callMacro()));
1651 macroActions[0]->setShortcut ( Qt::Key_F1 );
1652 macroActions[1]->setShortcut ( Qt::Key_F2 );
1653 macroActions[2]->setShortcut ( Qt::Key_F3 );
1654 macroActions[3]->setShortcut ( Qt::Key_F4 );
1655 macroActions[4]->setShortcut ( Qt::Key_F5 );
1656 macroActions[5]->setShortcut ( Qt::Key_F6 );
1657 macroActions[6]->setShortcut ( Qt::Key_F7 );
1658 macroActions[7]->setShortcut ( Qt::Key_F8 );
1659 macroActions[8]->setShortcut ( Qt::Key_F9 );
1660 macroActions[9]->setShortcut ( Qt::Key_F10 );
1661 macroActions[10]->setShortcut ( Qt::Key_F11 );
1662 macroActions[11]->setShortcut ( Qt::Key_F12 );
1665 void Main::hideEvent (QHideEvent * )
1667 if (!textEditor->isMinimized() ) textEditor->hide();
1670 void Main::showEvent (QShowEvent * )
1672 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1676 MapEditor* Main::currentMapEditor() const
1678 if ( tabWidget->currentPage())
1679 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1683 VymModel* Main::currentModel() const
1685 if ( tabWidget->currentPage())
1686 return vymViews.at(tabWidget->currentIndex())->getModel();
1691 void Main::editorChanged(QWidget *)
1693 // Unselect all possibly selected objects
1694 // (Important to update note editor)
1696 for (int i=0;i<=tabWidget->count() -1;i++)
1698 m= vymViews.at(tabWidget->currentIndex())->getModel();
1699 if (m) m->unselect();
1702 if (m) m->reselect();
1704 // Update actions to in menus and toolbars according to editor
1708 void Main::fileNew()
1710 VymModel *vm=new VymModel;
1712 new ModelTest(vm, this); //FIXME-3
1715 VymView *vv=new VymView (vm);
1716 vymViews.append (vv);
1717 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1718 tabWidget->setCurrentIndex (vymViews.count() );
1721 // Create MapCenter for empty map
1722 //vm->createMapCenter();
1724 // For the very first map we do not have flagrows yet...
1728 void Main::fileNewCopy()
1730 QString fn="unnamed";
1731 VymModel *srcModel=currentModel();
1736 VymModel *dstModel=vymViews.last()->getModel();
1737 dstModel->select("mc:");
1738 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1742 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1744 ErrorCode err=success;
1746 // fn is usually the archive, mapfile the file after uncompressing
1749 // Make fn absolute (needed for unzip)
1750 fn=QDir (fn).absPath();
1756 // Check, if map is already loaded
1758 while (i<=tabWidget->count() -1)
1760 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1762 // Already there, ask for confirmation
1763 QMessageBox mb( vymName,
1764 tr("The map %1\nis already opened."
1765 "Opening the same map in multiple editors may lead \n"
1766 "to confusion when finishing working with vym."
1767 "Do you want to").arg(fn),
1768 QMessageBox::Warning,
1769 QMessageBox::Yes | QMessageBox::Default,
1770 QMessageBox::Cancel | QMessageBox::Escape,
1771 QMessageBox::NoButton);
1772 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1773 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1776 case QMessageBox::Yes:
1777 // end loop and load anyway
1778 i=tabWidget->count();
1780 case QMessageBox::Cancel:
1790 int tabIndex=tabWidget->currentPageIndex();
1793 if ( !fn.isEmpty() )
1795 vm = currentModel();
1796 // Check first, if mapeditor exists
1797 // If it is not default AND we want a new map,
1798 // create a new mapeditor in a new tab
1799 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1802 VymView *vv=new VymView (vm);
1803 vymViews.append (vv);
1804 tabWidget->addTab (vv,fn);
1805 tabIndex=tabWidget->count()-1;
1806 tabWidget->setCurrentPage (tabIndex);
1810 // Check, if file exists (important for creating new files
1811 // from command line
1812 if (!QFile(fn).exists() )
1814 QMessageBox mb( vymName,
1815 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1816 QMessageBox::Question,
1818 QMessageBox::Cancel | QMessageBox::Default,
1819 QMessageBox::NoButton );
1821 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1822 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1825 case QMessageBox::Yes:
1827 currentMapEditor()->getModel()->setFilePath(fn);
1828 tabWidget->setTabText (tabIndex,
1829 currentMapEditor()->getModel()->getFileName() );
1830 statusBar()->message( "Created " + fn , statusbarTime );
1833 case QMessageBox::Cancel:
1834 // don't create new map
1835 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1842 //tabWidget->currentPage() won't be NULL here, because of above...
1843 tabWidget->setCurrentIndex (tabIndex);
1844 //FIXME-3 no me anymore... me->viewport()->setFocus();
1848 // Save existing filename in case we import
1849 QString fn_org=vm->getFilePath();
1851 // Finally load map into mapEditor
1852 vm->setFilePath (fn);
1853 err=vm->load(fn,lmode,ftype);
1855 // Restore old (maybe empty) filepath, if this is an import
1857 vm->setFilePath (fn_org);
1860 // Finally check for errors and go home
1863 if (lmode==NewMap) fileCloseMap();
1864 statusBar()->message( "Could not load " + fn, statusbarTime );
1869 vm->setFilePath (fn);
1870 tabWidget->setTabText (tabIndex, vm->getFileName());
1871 if (!isInTmpDir (fn))
1873 // Only append to lastMaps if not loaded from a tmpDir
1874 // e.g. imported bookmarks are in a tmpDir
1875 addRecentMap(vm->getFilePath() );
1877 actionFilePrint->setEnabled (true);
1879 statusBar()->message( "Loaded " + fn, statusbarTime );
1886 void Main::fileLoad(const LoadMode &lmode)
1888 QStringList filters;
1889 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1890 QFileDialog *fd=new QFileDialog( this);
1891 fd->setDir (lastFileDir);
1892 fd->setFileMode (QFileDialog::ExistingFiles);
1893 fd->setFilters (filters);
1897 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1900 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1903 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1909 if ( fd->exec() == QDialog::Accepted )
1911 lastFileDir=fd->directory().path();
1912 QStringList flist = fd->selectedFiles();
1913 QStringList::Iterator it = flist.begin();
1914 while( it != flist.end() )
1917 fileLoad(*it, lmode);
1924 void Main::fileLoad()
1929 void Main::fileLoadRecent()
1931 QAction *action = qobject_cast<QAction *>(sender());
1933 fileLoad (action->data().toString(), NewMap);
1936 void Main::addRecentMap (const QString &fileName)
1939 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1940 files.removeAll(fileName);
1941 files.prepend(fileName);
1942 while (files.size() > MaxRecentFiles)
1945 settings.setValue("/mainwindow/recentFileList", files);
1947 setupRecentMapsMenu();
1950 void Main::fileSave(VymModel *m, const SaveMode &savemode)
1954 if ( m->getFilePath().isEmpty() )
1956 // We have no filepath yet,
1957 // call fileSaveAs() now, this will call fileSave()
1959 // First switch to editor
1960 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
1961 fileSaveAs(savemode);
1964 if (m->save (savemode)==success)
1966 statusBar()->message(
1967 tr("Saved %1").arg(m->getFilePath()),
1969 addRecentMap (m->getFilePath() );
1971 statusBar()->message(
1972 tr("Couldn't save ").arg(m->getFilePath()),
1976 void Main::fileSave()
1978 fileSave (currentModel(), CompleteMap);
1981 void Main::fileSave(VymModel *m)
1983 fileSave (m,CompleteMap);
1986 void Main::fileSaveAs(const SaveMode& savemode)
1990 if (currentMapEditor())
1992 if (savemode==CompleteMap)
1993 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1995 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1996 if ( !fn.isEmpty() )
1998 // Check for existing file
1999 if (QFile (fn).exists())
2001 QMessageBox mb( vymName,
2002 tr("The file %1\nexists already. Do you want to").arg(fn),
2003 QMessageBox::Warning,
2004 QMessageBox::Yes | QMessageBox::Default,
2005 QMessageBox::Cancel | QMessageBox::Escape,
2006 QMessageBox::NoButton);
2007 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2008 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2011 case QMessageBox::Yes:
2014 case QMessageBox::Cancel:
2021 // New file, add extension to filename, if missing
2022 // This is always .vym or .vyp, depending on savemode
2023 if (savemode==CompleteMap)
2025 if (!fn.contains (".vym") && !fn.contains (".xml"))
2029 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2038 VymModel *m=currentModel();
2040 fileSave(m, savemode);
2042 // Set name of tab, assuming current tab is the one we just saved
2043 if (savemode==CompleteMap)
2044 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2050 void Main::fileSaveAs()
2052 fileSaveAs (CompleteMap);
2055 void Main::fileImportKDE3Bookmarks()
2057 ImportKDE3Bookmarks im;
2059 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2060 currentMapEditor()->getModel()->setFilePath ("");
2063 void Main::fileImportKDE4Bookmarks()
2065 ImportKDE4Bookmarks im;
2067 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2068 currentMapEditor()->getModel()->setFilePath ("");
2071 void Main::fileImportFirefoxBookmarks()
2073 Q3FileDialog *fd=new Q3FileDialog( this);
2074 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2075 fd->setMode (Q3FileDialog::ExistingFiles);
2076 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2077 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2080 if ( fd->exec() == QDialog::Accepted )
2082 ImportFirefoxBookmarks im;
2083 QStringList flist = fd->selectedFiles();
2084 QStringList::Iterator it = flist.begin();
2085 while( it != flist.end() )
2088 if (im.transform() &&
2089 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2090 currentMapEditor() )
2091 currentMapEditor()->getModel()->setFilePath ("");
2098 void Main::fileImportFreemind()
2100 QStringList filters;
2101 filters <<"Freemind map (*.mm)"<<"All files (*)";
2102 QFileDialog *fd=new QFileDialog( this);
2103 fd->setDir (lastFileDir);
2104 fd->setFileMode (QFileDialog::ExistingFiles);
2105 fd->setFilters (filters);
2106 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2110 if ( fd->exec() == QDialog::Accepted )
2112 lastFileDir=fd->directory().path();
2113 QStringList flist = fd->selectedFiles();
2114 QStringList::Iterator it = flist.begin();
2115 while( it != flist.end() )
2118 if ( fileLoad (fn,NewMap, FreemindMap) )
2120 currentMapEditor()->getModel()->setFilePath ("");
2129 void Main::fileImportMM()
2133 Q3FileDialog *fd=new Q3FileDialog( this);
2134 fd->setDir (lastFileDir);
2135 fd->setMode (Q3FileDialog::ExistingFiles);
2136 fd->addFilter ("Mind Manager (*.mmap)");
2137 fd->setCaption(tr("Import")+" "+"Mind Manager");
2140 if ( fd->exec() == QDialog::Accepted )
2142 lastFileDir=fd->dirPath();
2143 QStringList flist = fd->selectedFiles();
2144 QStringList::Iterator it = flist.begin();
2145 while( it != flist.end() )
2148 if (im.transform() &&
2149 success==fileLoad (im.getTransformedFile(),NewMap) &&
2150 currentMapEditor() )
2151 currentMapEditor()->getModel()->setFilePath ("");
2158 void Main::fileImportDir()
2160 VymModel *m=currentModel();
2161 if (m) m->importDir();
2164 void Main::fileExportXML()
2166 VymModel *m=currentModel();
2167 if (m) m->exportXML();
2171 void Main::fileExportXHTML()
2173 VymModel *m=currentModel();
2174 if (m) m->exportXHTML();
2177 void Main::fileExportImage()
2179 VymModel *m=currentModel();
2180 if (m) m->exportImage();
2183 void Main::fileExportASCII()
2185 VymModel *m=currentModel();
2186 if (m) m->exportASCII();
2189 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2191 VymModel *m=currentModel();
2196 ex.addFilter ("CSV (*.csv)");
2197 ex.setDir(lastImageDir);
2198 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2199 if (ex.execDialog() )
2201 m->setExportMode(true);
2203 m->setExportMode(false);
2208 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2210 VymModel *m=currentModel();
2215 ex.addFilter ("Tex (*.tex)");
2216 ex.setDir(lastImageDir);
2217 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2218 if (ex.execDialog() )
2220 m->setExportMode(true);
2222 m->setExportMode(false);
2227 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2229 ExportKDE3Bookmarks ex;
2230 VymModel *m=currentModel();
2238 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2240 ExportKDE4Bookmarks ex;
2241 VymModel *m=currentModel();
2249 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2251 ExportTaskjuggler ex;
2252 VymModel *m=currentModel();
2256 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2257 ex.setDir(lastImageDir);
2258 ex.addFilter ("Taskjuggler (*.tjp)");
2259 if (ex.execDialog() )
2261 m->setExportMode(true);
2263 m->setExportMode(false);
2268 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2270 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2271 // TODO add preview in dialog
2272 //ImagePreview *p =new ImagePreview (fd);
2273 //fd->setContentsPreviewEnabled( TRUE );
2274 //fd->setContentsPreview( p, p );
2275 //fd->setPreviewMode( QFileDialog::Contents );
2276 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2277 fd->setDir (QDir().current());
2278 if (fd->foundConfig())
2282 if ( fd->exec() == QDialog::Accepted )
2284 QString fn=fd->selectedFile();
2285 if (!fn.contains (".odp"))
2288 //lastImageDir=fn.left(fn.findRev ("/"));
2289 VymModel *m=currentModel();
2290 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2294 QMessageBox::warning(0,
2296 tr("Couldn't find configuration for export to Open Office\n"));
2300 void Main::fileCloseMap()
2302 VymModel *m=currentModel();
2305 if (m->hasChanged())
2307 QMessageBox mb( vymName,
2308 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2309 QMessageBox::Warning,
2310 QMessageBox::Yes | QMessageBox::Default,
2312 QMessageBox::Cancel | QMessageBox::Escape );
2313 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2314 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2317 case QMessageBox::Yes:
2319 fileSave(m, CompleteMap);
2321 case QMessageBox::No:
2322 // close without saving
2324 case QMessageBox::Cancel:
2329 // And here comes the segfault, because removeTab triggers
2330 // currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2331 vymViews.removeAt (tabWidget->currentIndex() );
2332 tabWidget->removeTab (tabWidget->currentIndex() );
2334 // Remove mapEditor/model FIXME-5
2335 // Better would be delete (me), but then we could have a Qt error:
2336 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2337 // So we only remove data now and call deconstructor when vym closes later
2338 // this needs to be moved to vymview... me->clear();
2339 // some model->clear is needed to free up memory ...
2345 void Main::filePrint()
2347 if (currentMapEditor())
2348 currentMapEditor()->print();
2351 void Main::fileExitVYM()
2353 // Check if one or more editors have changed
2355 for (i=0;i<=vymViews.count() -1;i++)
2357 // If something changed, ask what to do
2358 if (vymViews.at(i)->getModel()->hasChanged())
2360 tabWidget->setCurrentPage(i);
2361 QMessageBox mb( vymName,
2362 tr("This map is not saved yet. Do you want to"),
2363 QMessageBox::Warning,
2364 QMessageBox::Yes | QMessageBox::Default,
2366 QMessageBox::Cancel | QMessageBox::Escape );
2367 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2368 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2371 mb.setActiveWindow();
2372 switch( mb.exec() ) {
2373 case QMessageBox::Yes:
2374 // save (the changed editors) and exit
2375 fileSave(currentModel(), CompleteMap);
2377 case QMessageBox::No:
2378 // exit without saving
2380 case QMessageBox::Cancel:
2381 // don't save and don't exit
2385 } // loop over all MEs
2389 void Main::editUndo()
2391 VymModel *m=currentModel();
2395 void Main::editRedo()
2397 VymModel *m=currentModel();
2401 void Main::gotoHistoryStep (int i)
2403 VymModel *m=currentModel();
2404 if (m) m->gotoHistoryStep(i);
2407 void Main::editCopy()
2409 VymModel *m=currentModel();
2413 void Main::editPaste()
2415 VymModel *m=currentModel();
2419 void Main::editCut()
2421 VymModel *m=currentModel();
2425 void Main::editOpenFindWindow()
2427 findWindow->popup();
2428 findWindow->raise();
2429 findWindow->setActiveWindow();
2432 void Main::editFind(QString s)
2434 VymModel *m=currentModel();
2438 BranchItem *bi=m->findText(s, cs);
2441 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2444 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2445 tr("No matches found for \"%1\"").arg(s));
2450 void Main::editFindChanged()
2451 { // Notify editor, to abort the current find process
2452 VymModel *m=currentModel();
2453 if (m) m->findReset();
2456 void Main::openTabs(QStringList urls)
2458 if (!urls.isEmpty())
2462 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2464 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2466 QString u=urls.takeFirst();
2467 procBrowser = new QProcess( this );
2469 procBrowser->start(browser,args);
2470 if ( !procBrowser->waitForStarted())
2472 // try to set path to browser
2473 QMessageBox::warning(0,
2475 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2476 tr("Please use Settings->")+tr("Set application to open an URL"));
2479 #if defined(Q_OS_WIN32)
2480 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2481 this->thread()->wait(3000);
2486 if (browser.contains("konqueror"))
2488 for (int i=0; i<urls.size(); i++)
2491 // Try to open new tab in existing konqueror started previously by vym
2492 p=new QProcess (this);
2494 #if defined(Q_OS_WIN32)
2495 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2496 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2497 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2498 "konqueror-mainwindow#1"<<
2502 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2503 "konqueror-mainwindow#1"<<
2507 p->start ("dcop",args);
2508 if (debug) cout << "MainWindo::openURLs args="<<args.join(" ").toStdString()<<endl;
2509 if ( !p->waitForStarted() ) success=false;
2512 QMessageBox::warning(0,
2514 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2516 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2518 for (int i=0; i<urls.size(); i++)
2520 // Try to open new tab in firefox
2521 p=new QProcess (this);
2522 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2523 p->start (browser,args);
2524 if ( !p->waitForStarted() ) success=false;
2527 QMessageBox::warning(0,
2529 tr("Couldn't start %1 to open a new tab").arg(browser));
2532 QMessageBox::warning(0,
2534 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2538 void Main::editOpenURL()
2541 VymModel *m=currentModel();
2544 QString url=m->getURL();
2546 if (url=="") return;
2547 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2548 procBrowser = new QProcess( this );
2550 procBrowser->start(browser,args);
2551 if ( !procBrowser->waitForStarted())
2553 // try to set path to browser
2554 QMessageBox::warning(0,
2556 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2557 tr("Please use Settings->")+tr("Set application to open an URL"));
2562 void Main::editOpenURLTab()
2564 VymModel *m=currentModel();
2568 urls.append(m->getURL());
2572 void Main::editOpenMultipleURLTabs()
2574 VymModel *m=currentModel();
2584 void Main::editURL()
2586 VymModel *m=currentModel();
2587 if (m) m->editURL();
2590 void Main::editLocalURL()
2592 VymModel *m=currentModel();
2593 if (m) m->editLocalURL();
2596 void Main::editHeading2URL()
2598 VymModel *m=currentModel();
2599 if (m) m->editHeading2URL();
2602 void Main::editBugzilla2URL()
2604 VymModel *m=currentModel();
2605 if (m) m->editBugzilla2URL();
2608 void Main::editFATE2URL()
2610 VymModel *m=currentModel();
2611 if (m) m->editFATE2URL();
2614 void Main::editHeadingFinished(VymModel *m)
2618 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2619 !prevSelection.isEmpty())
2620 m->select(prevSelection);
2625 void Main::openVymLinks(const QStringList &vl)
2627 for (int j=0; j<vl.size(); j++)
2629 // compare path with already loaded maps
2632 for (i=0;i<=vymViews.count() -1;i++)
2634 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2643 if (!QFile(vl.at(j)).exists() )
2644 QMessageBox::critical( 0, tr( "Critical Error" ),
2645 tr("Couldn't open map %1").arg(vl.at(j)));
2648 fileLoad (vl.at(j), NewMap);
2649 tabWidget->setCurrentIndex (tabWidget->count()-1);
2652 // Go to tab containing the map
2653 tabWidget->setCurrentIndex (index);
2657 void Main::editOpenVymLink()
2659 VymModel *m=currentModel();
2663 vl.append(m->getVymLink());
2668 void Main::editOpenMultipleVymLinks()
2670 QString currentVymLink;
2671 VymModel *m=currentModel();
2674 QStringList vl=m->getVymLinks();
2679 void Main::editVymLink()
2681 VymModel *m=currentModel();
2686 void Main::editDeleteVymLink()
2688 VymModel *m=currentModel();
2689 if (m) m->deleteVymLink();
2692 void Main::editToggleHideExport()
2694 VymModel *m=currentModel();
2695 if (m) m->toggleHideExport();
2698 void Main::editMapInfo()
2700 VymModel *m=currentModel();
2702 ExtraInfoDialog dia;
2703 dia.setMapName (m->getFileName() );
2704 dia.setAuthor (m->getAuthor() );
2705 dia.setComment(m->getComment() );
2709 /* FIXME-2 no stats at the moment (view dependent...)
2710 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2720 if (!bo->getNote().isEmpty() ) n++;
2721 f+= bo->countFloatImages();
2723 xl+=bo->countXLinks();
2726 stats+=QString ("%1 xLinks \n").arg (xl,6);
2727 stats+=QString ("%1 notes\n").arg (n,6);
2728 stats+=QString ("%1 images\n").arg (f,6);
2730 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2731 dia.setStats (stats);
2733 // Finally show dialog
2734 if (dia.exec() == QDialog::Accepted)
2736 m->setAuthor (dia.getAuthor() );
2737 m->setComment (dia.getComment() );
2741 void Main::editMoveUp()
2743 VymModel *m=currentModel();
2747 void Main::editMoveDown()
2749 VymModel *m=currentModel();
2750 if (m) m->moveDown();
2753 void Main::editSortChildren()
2755 VymModel *m=currentModel();
2756 if (m) m->sortChildren();
2759 void Main::editToggleScroll()
2761 VymModel *m=currentModel();
2762 if (m) m->toggleScroll();
2765 void Main::editExpandAll()
2767 VymModel *m=currentModel();
2768 if (m) m->emitExpandAll();
2771 void Main::editUnscrollChildren()
2773 VymModel *m=currentModel();
2774 if (m) m->unscrollChildren();
2777 void Main::editAddAttribute()
2779 VymModel *m=currentModel();
2780 if (m) m->addAttribute();
2783 void Main::editAddMapCenter()
2785 VymModel *m=currentModel();
2786 if (m) m->addMapCenter ();
2789 void Main::editNewBranch()
2791 VymModel *m=currentModel();
2794 BranchItem *bi=m->addNewBranch();
2797 if (actionSettingsAutoEditNewBranch->isOn()
2798 && !actionSettingsAutoSelectNewBranch->isOn() )
2799 prevSelection=m->getSelectString();
2801 prevSelection=QString();
2803 if (actionSettingsAutoSelectNewBranch->isOn()
2804 || actionSettingsAutoEditNewBranch->isOn())
2807 cout << "Main::editNewBranch prevSel="<<prevSelection.toStdString()<<endl;
2808 if (actionSettingsAutoEditNewBranch->isOn())
2809 currentMapEditor()->editHeading();
2814 void Main::editNewBranchBefore()
2816 VymModel *m=currentModel();
2819 BranchItem *bi=m->addNewBranchBefore();
2826 if (actionSettingsAutoEditNewBranch->isOn())
2828 if (!actionSettingsAutoSelectNewBranch->isOn())
2829 prevSelection=m->getSelectString(bi);
2830 currentMapEditor()->editHeading();
2835 void Main::editNewBranchAbove()
2837 VymModel *m=currentModel();
2840 BranchItem *bi=m->addNewBranch (-1);
2848 if (actionSettingsAutoEditNewBranch->isOn())
2850 if (!actionSettingsAutoSelectNewBranch->isOn())
2851 prevSelection=m->getSelectString (bi);
2852 currentMapEditor()->editHeading();
2857 void Main::editNewBranchBelow()
2859 VymModel *m=currentModel();
2862 BranchItem *bi=m->addNewBranch (1);
2869 if (actionSettingsAutoEditNewBranch->isOn())
2871 if (!actionSettingsAutoSelectNewBranch->isOn())
2872 prevSelection=m->getSelectString(bi);
2873 currentMapEditor()->editHeading();
2878 void Main::editImportAdd()
2880 fileLoad (ImportAdd);
2883 void Main::editImportReplace()
2885 fileLoad (ImportReplace);
2888 void Main::editSaveBranch()
2890 fileSaveAs (PartOfMap);
2893 void Main::editDeleteKeepChildren()
2895 VymModel *m=currentModel();
2896 if (m) m->deleteKeepChildren();
2899 void Main::editDeleteChildren()
2901 VymModel *m=currentModel();
2902 if (m) m->deleteChildren();
2905 void Main::editDeleteSelection()
2907 VymModel *m=currentModel();
2908 if (m && actionSettingsUseDelKey->isOn())
2909 m->deleteSelection();
2912 void Main::editLoadImage()
2914 VymModel *m=currentModel();
2915 if (m) m->loadFloatImage();
2918 void Main::editSaveImage()
2920 VymModel *m=currentModel();
2921 if (m) m->saveFloatImage();
2924 void Main::editFollowXLink(QAction *a)
2927 VymModel *m=currentModel();
2929 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2932 void Main::editEditXLink(QAction *a)
2934 VymModel *m=currentModel();
2936 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2939 void Main::formatSelectColor()
2941 QColor col = QColorDialog::getColor((currentColor ), this );
2942 if ( !col.isValid() ) return;
2943 colorChanged( col );
2946 void Main::formatPickColor()
2948 VymModel *m=currentModel();
2950 colorChanged( m->getCurrentHeadingColor() );
2953 void Main::colorChanged(QColor c)
2955 QPixmap pix( 16, 16 );
2957 actionFormatColor->setIconSet( pix );
2961 void Main::formatColorBranch()
2963 VymModel *m=currentModel();
2964 if (m) m->colorBranch(currentColor);
2967 void Main::formatColorSubtree()
2969 VymModel *m=currentModel();
2970 if (m) m->colorSubtree (currentColor);
2973 void Main::formatLinkStyleLine()
2975 VymModel *m=currentModel();
2978 m->setMapLinkStyle("StyleLine");
2979 actionFormatLinkStyleLine->setOn(true);
2983 void Main::formatLinkStyleParabel()
2985 VymModel *m=currentModel();
2988 m->setMapLinkStyle("StyleParabel");
2989 actionFormatLinkStyleParabel->setOn(true);
2993 void Main::formatLinkStylePolyLine()
2995 VymModel *m=currentModel();
2998 m->setMapLinkStyle("StylePolyLine");
2999 actionFormatLinkStylePolyLine->setOn(true);
3003 void Main::formatLinkStylePolyParabel()
3005 VymModel *m=currentModel();
3008 m->setMapLinkStyle("StylePolyParabel");
3009 actionFormatLinkStylePolyParabel->setOn(true);
3013 void Main::formatSelectBackColor()
3015 VymModel *m=currentModel();
3016 if (m) m->selectMapBackgroundColor();
3019 void Main::formatSelectBackImage()
3021 VymModel *m=currentModel();
3023 m->selectMapBackgroundImage();
3026 void Main::formatSelectLinkColor()
3028 VymModel *m=currentModel();
3031 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3032 m->setMapDefLinkColor( col );
3036 void Main::formatSelectSelectionColor()
3038 VymModel *m=currentModel();
3041 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3042 m->setSelectionColor (col);
3047 void Main::formatToggleLinkColorHint()
3049 VymModel *m=currentModel();
3050 if (m) m->toggleMapLinkColorHint();
3054 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3056 VymModel *m=currentModel();
3058 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3061 void Main::viewZoomReset()
3063 MapEditor *me=currentMapEditor();
3064 if (me) me->setZoomFactorTarget (1);
3067 void Main::viewZoomIn()
3069 MapEditor *me=currentMapEditor();
3070 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3073 void Main::viewZoomOut()
3075 MapEditor *me=currentMapEditor();
3076 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3079 void Main::viewCenter()
3081 VymModel *m=currentModel();
3082 if (m) m->emitShowSelection();
3085 void Main::networkStartServer()
3087 VymModel *m=currentModel();
3088 if (m) m->newServer();
3091 void Main::networkConnect()
3093 VymModel *m=currentModel();
3094 if (m) m->connectToServer();
3097 bool Main::settingsPDF()
3099 // Default browser is set in constructor
3101 QString text = QInputDialog::getText(
3102 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3103 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3105 settings.setValue ("/mainwindow/readerPDF",text);
3110 bool Main::settingsURL()
3112 // Default browser is set in constructor
3114 QString text = QInputDialog::getText(
3115 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3116 settings.value("/mainwindow/readerURL").toString()
3119 settings.setValue ("/mainwindow/readerURL",text);
3123 void Main::settingsMacroDir()
3125 QDir defdir(vymBaseDir.path() + "/macros");
3126 if (!defdir.exists())
3128 QDir dir=QFileDialog::getExistingDirectory (
3130 tr ("Directory with vym macros:"),
3131 settings.value ("/macros/macroDir",defdir.path()).toString()
3134 settings.setValue ("/macros/macroDir",dir.absolutePath());
3137 void Main::settingsUndoLevels()
3140 int i = QInputDialog::getInteger(
3142 tr("QInputDialog::getInteger()"),
3143 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3146 settings.setValue ("/mapeditor/stepsTotal",i);
3147 QMessageBox::information( this, tr( "VYM -Information:" ),
3148 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3152 void Main::settingsAutosaveToggle()
3154 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3157 void Main::settingsAutosaveTime()
3160 int i = QInputDialog::getInteger(
3162 tr("QInputDialog::getInteger()"),
3163 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3165 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3168 void Main::settingsWriteBackupFileToggle()
3170 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3173 void Main::settingsToggleAnimation()
3175 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3178 void Main::settingsToggleDelKey()
3180 if (actionSettingsUseDelKey->isOn())
3182 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3185 actionDelete->setAccel (QKeySequence (""));
3189 void Main::windowToggleNoteEditor()
3191 if (textEditor->isVisible() )
3192 windowHideNoteEditor();
3194 windowShowNoteEditor();
3197 void Main::windowToggleHistory()
3199 if (historyWindow->isVisible())
3200 historyWindow->hide();
3202 historyWindow->show();
3206 void Main::windowToggleProperty()
3208 if (branchPropertyWindow->isVisible())
3209 branchPropertyWindow->hide();
3211 branchPropertyWindow->show();
3212 branchPropertyWindow->setModel (currentModel() );
3215 void Main::windowToggleAntiAlias()
3217 bool b=actionViewToggleAntiAlias->isOn();
3219 for (int i=0;i<vymViews.count();i++)
3221 me=vymViews.at(i)->getMapEditor();
3222 if (me) me->setAntiAlias(b);
3227 bool Main::isAliased()
3229 return actionViewToggleAntiAlias->isOn();
3232 bool Main::hasSmoothPixmapTransform()
3234 return actionViewToggleSmoothPixmapTransform->isOn();
3237 void Main::windowToggleSmoothPixmap()
3239 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3241 for (int i=0;i<vymViews.count();i++)
3244 me=vymViews.at(i)->getMapEditor();
3245 if (me) me->setSmoothPixmap(b);
3249 void Main::updateHistory(SimpleSettings &undoSet)
3251 historyWindow->update (undoSet);
3254 void Main::updateNoteFlag()
3256 // this slot is connected to TextEditor::textHasChanged()
3258 VymModel *m=currentModel();
3259 if (m) m->updateNoteFlag();
3262 void Main::updateNoteEditor(QModelIndex index )
3264 cout << QObject::sender();
3265 QObject *obj=QObject::sender();
3266 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3267 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3268 //cout << "Main::updateNoteEditor model="<<sender();
3269 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3270 textEditor->setNote (ti->getNoteObj() );
3273 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3275 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3277 if (model && model==currentModel() )
3281 if (!oldsel.indexes().isEmpty() )
3283 ti=model->getItem(oldsel.indexes().first());
3285 // Don't update note if both treeItem and textEditor are empty
3286 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3287 // ti->setNoteObj (textEditor->getNoteObj(),false );
3289 if (!newsel.indexes().isEmpty() )
3291 ti=model->getItem(newsel.indexes().first());
3292 if (!ti->hasEmptyNote() )
3293 textEditor->setNote(ti->getNoteObj() );
3295 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3297 // Show URL and link in statusbar
3299 QString s=ti->getURL();
3300 if (!s.isEmpty() ) status+="URL: "+s+" ";
3302 if (!s.isEmpty() ) status+="Link: "+s;
3303 if (!status.isEmpty() ) statusMessage (status);
3306 textEditor->setInactive();
3312 void Main::updateActions()
3314 VymModel *m =currentModel();
3318 actionFilePrint->setEnabled (true);
3320 // Link style in context menu
3321 switch (m->getMapLinkStyle())
3323 case LinkableMapObj::Line:
3324 actionFormatLinkStyleLine->setOn(true);
3326 case LinkableMapObj::Parabel:
3327 actionFormatLinkStyleParabel->setOn(true);
3329 case LinkableMapObj::PolyLine:
3330 actionFormatLinkStylePolyLine->setOn(true);
3332 case LinkableMapObj::PolyParabel:
3333 actionFormatLinkStylePolyParabel->setOn(true);
3340 QPixmap pix( 16, 16 );
3341 pix.fill( m->getMapBackgroundColor() );
3342 actionFormatBackColor->setIconSet( pix );
3343 pix.fill( m->getSelectionColor() );
3344 actionFormatSelectionColor->setIconSet( pix );
3345 pix.fill( m->getMapDefLinkColor() );
3346 actionFormatLinkColor->setIconSet( pix );
3349 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3354 actionFilePrint->setEnabled (false);
3357 // updateActions is also called when NoteEditor is closed
3358 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3359 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3360 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3362 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3363 actionFormatLinkColorHint->setOn(true);
3365 actionFormatLinkColorHint->setOn(false);
3368 if (m && m->hasChanged() )
3369 actionFileSave->setEnabled( true);
3371 actionFileSave->setEnabled( false);
3372 if (m && m->isUndoAvailable())
3373 actionUndo->setEnabled( true);
3375 actionUndo->setEnabled( false);
3377 if (m && m->isRedoAvailable())
3378 actionRedo->setEnabled( true);
3380 actionRedo->setEnabled( false);
3384 TreeItem *selti=m->getSelectedItem();
3385 BranchItem *selbi=m->getSelectedBranch();
3388 if (selbi || selti->getType()==TreeItem::Image)
3390 actionFormatHideLinkUnselected->setOn (((MapItem*)selti)->getHideLinkUnselected());
3391 actionFormatHideLinkUnselected->setEnabled (true);
3396 // Take care of xlinks
3397 branchXLinksContextMenuEdit->clear();
3398 branchXLinksContextMenuFollow->clear();
3399 if (selbi->xlinkCount()>0)
3403 for (int i=0; i<selbi->xlinkCount();++i)
3405 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3409 if (s.length()>xLinkMenuWidth)
3410 s=s.left(xLinkMenuWidth)+"...";
3411 branchXLinksContextMenuFollow->addAction (s);
3412 branchXLinksContextMenuEdit->addAction (s);
3417 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3420 actionToggleScroll->setEnabled (true);
3421 if ( selbi->isScrolled() )
3422 actionToggleScroll->setOn(true);
3424 actionToggleScroll->setOn(false);
3426 if ( selti->getURL().isEmpty() )
3428 actionOpenURL->setEnabled (false);
3429 actionOpenURLTab->setEnabled (false);
3433 actionOpenURL->setEnabled (true);
3434 actionOpenURLTab->setEnabled (true);
3436 if ( selti->getVymLink().isEmpty() )
3438 actionOpenVymLink->setEnabled (false);
3439 actionDeleteVymLink->setEnabled (false);
3442 actionOpenVymLink->setEnabled (true);
3443 actionDeleteVymLink->setEnabled (true);
3446 if (selbi->canMoveUp())
3447 actionMoveUp->setEnabled (true);
3449 actionMoveUp->setEnabled (false);
3450 if (selbi->canMoveDown())
3451 actionMoveDown->setEnabled (true);
3453 actionMoveDown->setEnabled (false);
3455 actionSortChildren->setEnabled (true);
3457 actionToggleHideExport->setEnabled (true);
3458 actionToggleHideExport->setOn (selbi->hideInExport() );
3460 actionCopy->setEnabled (true);
3461 actionCut->setEnabled (true);
3462 if (!clipboardEmpty)
3463 actionPaste->setEnabled (true);
3465 actionPaste->setEnabled (false);
3466 for (int i=0; i<actionListBranches.size(); ++i)
3467 actionListBranches.at(i)->setEnabled(true);
3468 actionDelete->setEnabled (true);
3470 if ( selti->getType()==TreeItem::Image)
3472 actionOpenURL->setEnabled (false);
3473 actionOpenVymLink->setEnabled (false);
3474 actionDeleteVymLink->setEnabled (false);
3475 actionToggleHideExport->setEnabled (true);
3476 actionToggleHideExport->setOn (selti->hideInExport() );
3479 actionCopy->setEnabled (true);
3480 actionCut->setEnabled (true);
3481 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3482 for (int i=0; i<actionListBranches.size(); ++i)
3483 actionListBranches.at(i)->setEnabled(false);
3484 actionDelete->setEnabled (true);
3485 actionMoveUp->setEnabled (false);
3486 actionMoveDown->setEnabled (false);
3491 actionCopy->setEnabled (false);
3492 actionCut->setEnabled (false);
3493 actionPaste->setEnabled (false);
3494 for (int i=0; i<actionListBranches.size(); ++i)
3495 actionListBranches.at(i)->setEnabled(false);
3497 actionToggleScroll->setEnabled (false);
3498 actionOpenURL->setEnabled (false);
3499 actionOpenVymLink->setEnabled (false);
3500 actionDeleteVymLink->setEnabled (false);
3501 actionHeading2URL->setEnabled (false);
3502 actionDelete->setEnabled (false);
3503 actionMoveUp->setEnabled (false);
3504 actionMoveDown->setEnabled (false);
3505 actionFormatHideLinkUnselected->setEnabled (false);
3506 actionSortChildren->setEnabled (false);
3507 actionToggleHideExport->setEnabled (false);
3512 Main::ModMode Main::getModMode()
3514 if (actionModModeColor->isOn()) return ModModeColor;
3515 if (actionModModeCopy->isOn()) return ModModeCopy;
3516 if (actionModModeXLink->isOn()) return ModModeXLink;
3520 bool Main::autoEditNewBranch()
3522 return actionSettingsAutoEditNewBranch->isOn();
3525 bool Main::autoSelectNewBranch()
3527 return actionSettingsAutoSelectNewBranch->isOn();
3530 void Main::windowShowNoteEditor()
3532 textEditor->setShowWithMain(true);
3534 actionViewToggleNoteEditor->setOn (true);
3537 void Main::windowHideNoteEditor()
3539 textEditor->setShowWithMain(false);
3541 actionViewToggleNoteEditor->setOn (false);
3544 void Main::setScript (const QString &script)
3546 scriptEditor->setScript (script);
3549 void Main::runScript (const QString &script)
3551 VymModel *m=currentModel();
3552 if (m) m->runScript (script);
3555 void Main::runScriptEverywhere (const QString &script)
3558 for (int i=0;i<=tabWidget->count() -1;i++)
3560 me=(MapEditor*)tabWidget->page(i);
3561 if (me) me->getModel()->runScript (script);
3565 void Main::windowNextEditor()
3567 if (tabWidget->currentIndex() < tabWidget->count())
3568 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3571 void Main::windowPreviousEditor()
3573 if (tabWidget->currentIndex() >0)
3574 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3577 void Main::standardFlagChanged()
3581 if ( actionSettingsUseFlagGroups->isOn() )
3582 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3584 currentModel()->toggleStandardFlag(sender()->name());
3589 void Main::testFunction1()
3591 if (!currentMapEditor()) return;
3592 currentMapEditor()->testFunction1();
3595 void Main::testFunction2()
3597 if (!currentMapEditor()) return;
3598 currentMapEditor()->setFocus();
3601 void Main::testCommand()
3603 if (!currentMapEditor()) return;
3604 scriptEditor->show();
3607 QString com = QInputDialog::getText(
3608 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3609 if (ok) currentMapEditor()->parseAtom(com);
3613 void Main::helpDoc()
3615 QString locale = QLocale::system().name();
3617 if (locale.left(2)=="es")
3618 docname="vym_es.pdf";
3622 QStringList searchList;
3624 #if defined(Q_OS_MACX)
3625 searchList << "./vym.app/Contents/Resources/doc";
3626 #elif defined(Q_OS_WIN32)
3627 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3629 #if defined(VYM_DOCDIR)
3630 searchList << VYM_DOCDIR;
3632 // default path in SUSE LINUX
3633 searchList << "/usr/share/doc/packages/vym";
3636 searchList << "doc"; // relative path for easy testing in tarball
3637 searchList << "doc/tex"; // Easy testing working on vym.tex
3638 searchList << "/usr/share/doc/vym"; // Debian
3639 searchList << "/usr/share/doc/packages";// Knoppix
3643 for (int i=0; i<searchList.count(); ++i)
3645 docfile.setFileName(searchList.at(i)+"/"+docname);
3646 if (docfile.exists())
3655 QMessageBox::critical(0,
3656 tr("Critcal error"),
3657 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3662 Process *pdfProc = new Process();
3663 args << QDir::toNativeSeparators(docfile.fileName());
3665 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3666 if ( !pdfProc->waitForStarted() )
3669 QMessageBox::warning(0,
3671 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3672 tr("Please use Settings->")+tr("Set application to open PDF files"));
3679 void Main::helpDemo()
3681 QStringList filters;
3682 filters <<"VYM example map (*.vym)";
3683 QFileDialog *fd=new QFileDialog( this);
3684 #if defined(Q_OS_MACX)
3685 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3687 // default path in SUSE LINUX
3688 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3691 fd->setFileMode (QFileDialog::ExistingFiles);
3692 fd->setFilters (filters);
3693 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3697 if ( fd->exec() == QDialog::Accepted )
3699 lastFileDir=fd->directory().path();
3700 QStringList flist = fd->selectedFiles();
3701 QStringList::Iterator it = flist.begin();
3702 while( it != flist.end() )
3705 fileLoad(*it, NewMap);
3713 void Main::helpAbout()
3716 ad.setName ("aboutwindow");
3717 ad.setMinimumSize(500,500);
3718 ad.resize (QSize (500,500));
3722 void Main::helpAboutQT()
3724 QMessageBox::aboutQt( this, "Qt Application Example" );
3727 void Main::callMacro ()
3729 QAction *action = qobject_cast<QAction *>(sender());
3733 i=action->data().toInt();
3734 QString mDir (settings.value ("macros/macroDir").toString() );
3736 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3738 if ( !f.open( QIODevice::ReadOnly ) )
3740 QMessageBox::warning(0,
3742 tr("Couldn't find a macro at %1.\n").arg(fn)+
3743 tr("Please use Settings->")+tr("Set directory for vym macros"));
3747 QTextStream ts( &f );
3748 QString macro= ts.read();
3750 if (! macro.isEmpty())
3752 VymModel *m=currentModel();
3753 if (m) m->runScript(macro);