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 "shortcuts.h"
23 #include "texteditor.h"
24 #include "warningdialog.h"
25 #include "xlinkitem.h"
27 //#include <modeltest.h> // FIXME-3
29 #if defined(Q_OS_WIN32)
30 // Define only this structure as opposed to
31 // including full 'windows.h'. FindWindow
32 // clashes with the one in Win32 API.
33 typedef struct _PROCESS_INFORMATION
39 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
42 extern TextEditor *textEditor;
43 extern Main *mainWindow;
44 extern QString tmpVymDir;
45 extern QString clipboardDir;
46 extern QString clipboardFile;
47 extern bool clipboardEmpty;
48 extern int statusbarTime;
49 extern FlagRow *standardFlagsMaster;
50 extern FlagRow *systemFlagsMaster;
51 extern QString vymName;
52 extern QString vymVersion;
53 extern QString vymBuildDate;
56 QMenu* branchContextMenu;
57 QMenu* branchAddContextMenu;
58 QMenu* branchRemoveContextMenu;
59 QMenu* branchLinksContextMenu;
60 QMenu* branchXLinksContextMenuEdit;
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);
126 browserPID=new qint64;
129 // Satellite windows //////////////////////////////////////////
131 historyWindow=new HistoryWindow();
132 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
135 branchPropertyWindow = new BranchPropertyWindow();
136 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
138 // Connect TextEditor, so that we can update flags if text changes
139 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
140 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
142 // Initialize script editor
143 scriptEditor = new SimpleScriptEditor();
144 scriptEditor->move (50,50);
146 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
147 this, SLOT( runScript( QString ) ) );
149 // Initialize some settings, which are platform dependant
152 // application to open URLs
153 p="/mainwindow/readerURL";
154 #if defined(Q_OS_LINUX)
155 s=settings.value (p,"xdg-open").toString();
157 #if defined(Q_OS_MACX)
158 s=settings.value (p,"/usr/bin/open").toString();
161 #if defined(Q_OS_WIN32)
162 // Assume that system has been set up so that
163 // Explorer automagically opens up the URL
164 // in the user's preferred browser.
165 s=settings.value (p,"explorer").toString();
167 s=settings.value (p,"mozilla").toString();
171 settings.setValue( p,s);
173 // application to open PDFs
174 p="/mainwindow/readerPDF";
175 #if defined(Q_OS_LINUX)
176 s=settings.value (p,"xdg-open").toString();
178 #if defined(Q_OS_MACX)
179 s=settings.value (p,"/usr/bin/open").toString();
180 #elif defined(Q_OS_WIN32)
181 s=settings.value (p,"acrord32").toString();
183 s=settings.value (p,"acroread").toString();
186 settings.setValue( p,s);
188 // width of xLinksMenu
191 // Create tab widget which holds the maps
192 tabWidget= new QTabWidget (this);
193 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
194 this, SLOT( editorChanged( QWidget * ) ) );
196 setCentralWidget(tabWidget);
200 setupFormatActions();
204 setupNetworkActions();
205 setupSettingsActions();
208 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
211 // Status bar and progress bar there
214 progressBar=new QProgressBar;
216 statusBar()->addPermanentWidget(progressBar);
218 restoreState (settings.value("/mainwindow/state",0).toByteArray());
226 #if defined(Q_OS_WIN32)
227 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
229 settings.setValue ("/mainwindow/geometry/size", size());
230 settings.setValue ("/mainwindow/geometry/pos", pos());
231 settings.setValue ("/mainwindow/state",saveState(0));
233 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
234 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
235 settings.setValue( "/version/version", vymVersion );
236 settings.setValue( "/version/builddate", vymBuildDate );
238 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
239 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
240 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
241 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
242 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
243 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
244 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
245 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
247 //TODO save scriptEditor settings
249 // call the destructors
251 delete historyWindow;
252 delete branchPropertyWindow;
255 // Remove temporary directory
256 removeDir (QDir(tmpVymDir));
259 void Main::loadCmdLine()
261 /* TODO draw some kind of splashscreen while loading...
267 QStringList flist=options.getFileList();
268 QStringList::Iterator it=flist.begin();
270 while (it !=flist.end() )
272 fileLoad (*it, NewMap);
278 void Main::statusMessage(const QString &s)
280 // Surpress messages while progressbar during
282 if (progressMin==progressMax)
283 statusBar()->message( s);
286 void Main::setProgressMinimum (int min)
288 progressBar->setMinimum(min);
292 void Main::setProgressMaximum (int max)
294 progressBar->setMaximum(max);
298 statusBar()->addPermanentWidget(progressBar);
303 void Main::setProgressValue (int v)
305 progressBar->setValue (v);
308 void Main::removeProgressBar()
311 statusBar()->removeWidget(progressBar);
312 progressMax=progressMin=0;
315 void Main::closeEvent (QCloseEvent* )
321 void Main::setupFileActions()
323 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
324 QToolBar *tb = addToolBar( tr ("&Map") );
325 tb->setObjectName ("mapTB");
328 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
329 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
330 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
332 fileMenu->addAction (a);
333 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
335 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
336 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
337 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
338 fileMenu->addAction (a);
339 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
342 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
343 a->setStatusTip (tr( "Open","Status tip File menu" ) );
344 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
346 fileMenu->addAction (a);
347 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
349 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
350 fileMenu->addSeparator();
352 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
353 a->setStatusTip ( tr( "Save","Status tip file menu" ));
354 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
356 fileMenu->addAction (a);
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
360 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
361 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
362 fileMenu->addAction (a);
363 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
365 fileMenu->addSeparator();
367 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
369 a = new QAction(tr("KDE 3 Bookmarks"), this);
370 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
371 a->addTo (fileImportMenu);
372 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
374 a = new QAction(tr("KDE 4 Bookmarks"), this);
375 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
376 a->addTo (fileImportMenu);
377 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
379 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
381 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
382 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
383 a->addTo (fileImportMenu);
384 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
387 a = new QAction("Freemind...",this);
388 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
389 fileImportMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
392 a = new QAction("Mind Manager...",this);
393 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
394 fileImportMenu->addAction (a);
395 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
397 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
398 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
399 fileImportMenu->addAction (a);
400 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
402 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
404 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
405 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
406 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
407 fileExportMenu->addAction (a);
409 a = new QAction( "Open Office...", this);
410 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
411 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
412 fileExportMenu->addAction (a);
414 a = new QAction( "Webpage (HTML)...",this );
415 a->setShortcut (Qt::ALT + Qt::Key_X); //Export HTML
416 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
417 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
418 fileExportMenu->addAction (a);
420 a = new QAction( "Webpage (XHTML)...",this ); //Export XHTML
422 //a->setShortcut (Qt::ALT + Qt::SHIFT + Qt::Key_X); a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
423 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
424 fileExportMenu->addAction (a);
426 a = new QAction( "Text (A&O report)...", this);
427 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
428 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
429 fileExportMenu->addAction (a);
431 a = new QAction( "Text (ASCII)...", this);
432 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
433 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
434 fileExportMenu->addAction (a);
436 a = new QAction( "Spreadsheet (CSV)...", this);
437 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
438 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
439 fileExportMenu->addAction (a);
441 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
442 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
443 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
444 fileExportMenu->addAction (a);
446 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
447 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
448 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
449 fileExportMenu->addAction (a);
451 a = new QAction( "Taskjuggler...", this );
452 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
453 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
454 fileExportMenu->addAction (a);
456 a = new QAction( "LaTeX...", this);
457 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
458 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
459 fileExportMenu->addAction (a);
461 a = new QAction( "XML..." , this );
462 a->setStatusTip (tr( "Export as %1").arg("XML"));
463 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
464 fileExportMenu->addAction (a);
466 fileMenu->addSeparator();
468 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
469 a->setStatusTip ( tr( "Print" ,"File menu") );
470 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
472 fileMenu->addAction (a);
473 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
476 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
477 a->setStatusTip (tr( "Close Map" ) );
478 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
479 fileMenu->addAction (a);
480 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
482 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
483 a->setStatusTip ( tr( "Exit")+" "+vymName );
484 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
485 fileMenu->addAction (a);
486 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
491 void Main::setupEditActions()
493 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
494 tb->setLabel( "Edit Actions" );
495 tb->setObjectName ("actionsTB");
496 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
500 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
501 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
502 a->setStatusTip (tr( "Undo" ) );
503 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
504 a->setEnabled (false);
506 editMenu->addAction (a);
509 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
510 a->setStatusTip (tr( "Redo" ));
511 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
513 editMenu->addAction (a);
514 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
517 editMenu->addSeparator();
518 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
519 a->setStatusTip ( tr( "Copy" ) );
520 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
521 a->setEnabled (false);
523 editMenu->addAction (a);
524 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
527 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
528 a->setStatusTip ( tr( "Cut" ) );
529 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
530 a->setEnabled (false);
532 editMenu->addAction (a);
534 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
536 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
537 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
538 a->setStatusTip ( tr( "Paste" ) );
539 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
540 a->setEnabled (false);
542 editMenu->addAction (a);
545 // Shortcut to delete selection
546 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
547 a->setStatusTip (tr( "Delete Selection" ));
548 a->setShortcut ( Qt::Key_Delete); //Delete selection
549 a->setShortcutContext (Qt::WindowShortcut);
551 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
554 // Shortcut to add attribute
555 a= new QAction(tr( "Add attribute" ), this);
556 a->setShortcut ( Qt::Key_Q);
557 a->setShortcutContext (Qt::WindowShortcut);
559 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
560 actionAddAttribute= a;
563 // Shortcut to add mapcenter
564 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
565 a->setShortcut ( Qt::Key_M);
566 a->setShortcutContext (Qt::WindowShortcut);
567 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
568 //actionListBranches.append(a);
570 actionAddMapCenter = a;
573 // Shortcut to add branch
574 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
575 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
576 alt->setShortcut (Qt::Key_A); //Add branch
577 alt->setShortcutContext (Qt::WindowShortcut);
579 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
580 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
581 a->setStatusTip ( tr( "Add a branch as child of selection" ));
582 a->setShortcut (Qt::Key_Insert); //Add branch
583 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
584 actionListBranches.append(a);
585 #if defined (Q_OS_MACX)
586 // In OSX show different shortcut in menues, the keys work indepently always
591 editMenu->addAction (actionAddBranch);
592 tb->addAction (actionAddBranch);
595 // Add branch by inserting it at selection
596 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
597 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
598 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
599 a->setShortcutContext (Qt::WindowShortcut);
601 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
602 a->setEnabled (false);
603 actionListBranches.append(a);
604 actionAddBranchBefore=a;
605 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
606 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
607 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
608 a->setShortcutContext (Qt::WindowShortcut);
610 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
611 actionListBranches.append(a);
614 a = new QAction(tr( "Add branch above","Edit menu" ), this);
615 a->setStatusTip ( tr( "Add a branch above selection" ));
616 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
617 a->setShortcutContext (Qt::WindowShortcut);
619 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
620 a->setEnabled (false);
621 actionListBranches.append(a);
622 actionAddBranchAbove=a;
623 a = new QAction(tr( "Add branch above","Edit menu" ), this);
624 a->setStatusTip ( tr( "Add a branch above selection" ));
625 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
626 a->setShortcutContext (Qt::WindowShortcut);
628 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
629 actionListBranches.append(a);
632 a = new QAction(tr( "Add branch below","Edit menu" ), this);
633 a->setStatusTip ( tr( "Add a branch below selection" ));
634 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
635 a->setShortcutContext (Qt::WindowShortcut);
637 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
638 a->setEnabled (false);
639 actionListBranches.append(a);
640 actionAddBranchBelow=a;
641 a = new QAction(tr( "Add branch below","Edit menu" ), this);
642 a->setStatusTip ( tr( "Add a branch below selection" ));
643 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
644 a->setShortcutContext (Qt::WindowShortcut);
646 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
647 actionListBranches.append(a);
649 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
650 a->setStatusTip ( tr( "Move branch up" ) );
651 a->setShortcut (Qt::Key_PageUp ); // Move branch up
652 a->setEnabled (false);
654 editMenu->addAction (a);
655 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
658 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
660 a->setStatusTip (tr( "Move branch down" ) );
661 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
662 a->setEnabled (false);
664 editMenu->addAction (a);
667 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
668 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
669 a->setShortcut ( Qt::Key_D ); // Detach branch
670 editMenu->addAction (a);
671 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
674 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
675 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
676 a->setEnabled (true);
678 editMenu->addAction (a);
679 actionSortChildren=a;
681 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
682 alt->setShortcut ( Qt::Key_S ); // Scroll branch
683 alt->setStatusTip (tr( "Scroll branch" ));
684 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
685 #if defined(Q_OS_MACX)
686 actionToggleScroll=alt;
688 actionToggleScroll=a;
690 actionToggleScroll->setEnabled (false);
691 actionToggleScroll->setToggleAction(true);
692 tb->addAction (actionToggleScroll);
693 editMenu->addAction ( actionToggleScroll);
694 editMenu->addAction (actionToggleScroll);
697 actionListBranches.append(actionToggleScroll);
699 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
700 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
701 a->setStatusTip (tr( "Expand all branches" ));
702 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
704 actionExpandAll->setEnabled (false);
705 actionExpandAll->setToggleAction(false);
706 //tb->addAction (actionExpandAll);
707 editMenu->addAction ( actionExpandAll);
709 actionListBranches.append(actionExpandAll);
711 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
712 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
713 a->setStatusTip (tr( "Expand one level in tree editor" ));
714 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
715 a->setEnabled (false);
716 a->setToggleAction(false);
717 actionExpandOneLevel=a;
719 editMenu->addAction ( a);
721 actionListBranches.append(a);
723 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
724 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
725 a->setStatusTip (tr( "Collapse one level in tree editor" ));
726 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
727 a->setEnabled (false);
728 a->setToggleAction(false);
729 actionCollapseOneLevel=a;
731 editMenu->addAction ( a);
733 actionListBranches.append(a);
735 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
736 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
737 editMenu->addAction (a);
738 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
740 editMenu->addSeparator();
742 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
743 a->setStatusTip (tr( "Find" ) );
744 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
745 editMenu->addAction (a);
746 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
748 editMenu->addSeparator();
750 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
751 a->setShortcut (Qt::SHIFT + Qt::Key_U );
752 a->setShortcut (tr( "Open URL" ));
755 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
758 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
759 a->setStatusTip (tr( "Open URL in new tab" ));
760 //a->setShortcut (Qt::CTRL+Qt::Key_U );
762 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
765 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
766 a->setStatusTip (tr( "Open all URLs in subtree" ));
767 a->setShortcut ( Qt::CTRL + Qt::Key_U );
769 actionListBranches.append(a);
770 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
771 actionOpenMultipleURLTabs=a;
773 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
774 a->setStatusTip ( tr( "Edit URL" ) );
775 a->setShortcut ( Qt::Key_U );
776 a->setShortcutContext (Qt::WindowShortcut);
777 actionListBranches.append(a);
779 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
782 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
783 a->setStatusTip ( tr( "Edit local URL" ) );
784 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
785 a->setShortcutContext (Qt::WindowShortcut);
786 actionListBranches.append(a);
788 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
791 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
792 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
793 a->setEnabled (false);
794 actionListBranches.append(a);
795 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
798 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
799 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
800 a->setEnabled (false);
801 actionListBranches.append(a);
802 a->setShortcut ( Qt::Key_B );
803 a->setShortcutContext (Qt::WindowShortcut);
805 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
806 actionBugzilla2URL=a;
808 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
809 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
810 a->setEnabled (false);
811 actionListBranches.append(a);
812 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
815 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
816 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
818 a->setEnabled (false);
819 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
822 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
823 a->setStatusTip ( tr( "Open all vym links in subtree" ));
824 a->setEnabled (false);
825 actionListBranches.append(a);
826 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
827 actionOpenMultipleVymLinks=a;
830 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
831 a->setEnabled (false);
832 a->setStatusTip ( tr( "Edit link to another vym map" ));
833 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
834 actionListBranches.append(a);
837 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
838 a->setStatusTip ( tr( "Delete link to another vym map" ));
839 a->setEnabled (false);
840 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
841 actionDeleteVymLink=a;
843 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
844 a->setStatusTip ( tr( "Hide object in exports" ) );
845 a->setShortcut (Qt::Key_H );
846 a->setToggleAction(true);
848 a->setEnabled (false);
849 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
850 actionToggleHideExport=a;
852 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
853 a->setStatusTip ( tr( "Add timestamp" ));
854 a->setEnabled (false);
855 actionListBranches.append(a);
856 a->setShortcut ( Qt::Key_T ); // Add timestamp
857 a->setShortcutContext (Qt::WindowShortcut);
859 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
860 actionAddTimestamp=a;
862 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
863 a->setStatusTip ( tr( "Edit Map Info" ));
864 a->setEnabled (true);
865 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
868 // Import at selection (adding to selection)
869 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
870 a->setStatusTip (tr( "Add map at selection" ));
871 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
872 a->setEnabled (false);
873 actionListBranches.append(a);
876 // Import at selection (replacing selection)
877 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
878 a->setStatusTip (tr( "Replace selection with map" ));
879 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
880 a->setEnabled (false);
881 actionListBranches.append(a);
882 actionImportReplace=a;
885 a = new QAction( tr( "Save selection","Edit menu" ), this);
886 a->setStatusTip (tr( "Save selection" ));
887 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
888 a->setEnabled (false);
889 actionListBranches.append(a);
892 // Only remove branch, not its children
893 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
894 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
895 a->setShortcut (Qt::ALT + Qt::Key_Delete );
896 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
897 a->setEnabled (false);
899 actionListBranches.append(a);
900 actionDeleteKeepChildren=a;
902 // Only remove children of a branch
903 a = new QAction( tr( "Remove children","Edit menu" ), this);
904 a->setStatusTip (tr( "Remove children of branch" ));
905 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
906 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
907 a->setEnabled (false);
908 actionListBranches.append(a);
909 actionDeleteChildren=a;
911 a = new QAction( tr( "Add Image...","Edit menu" ), this);
912 a->setStatusTip (tr( "Add Image" ));
913 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
916 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
917 a->setStatusTip (tr( "Set properties for selection" ));
918 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
919 a->setShortcutContext (Qt::WindowShortcut);
920 a->setToggleAction (true);
922 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
923 actionViewTogglePropertyWindow=a;
927 void Main::setupFormatActions()
929 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
931 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
932 tb->setObjectName ("formatTB");
935 pix.fill (Qt::black);
936 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
937 a->setStatusTip ( tr( "Set Color" ));
938 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
940 formatMenu->addAction (a);
942 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
943 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
944 a->setShortcut (Qt::CTRL + Qt::Key_K );
945 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
946 a->setEnabled (false);
948 formatMenu->addAction (a);
949 actionListBranches.append(a);
950 actionFormatPickColor=a;
952 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
953 a->setStatusTip ( tr( "Color branch" ) );
954 a->setShortcut (Qt::CTRL + Qt::Key_B);
955 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
956 a->setEnabled (false);
958 formatMenu->addAction (a);
959 actionListBranches.append(a);
960 actionFormatColorSubtree=a;
962 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
963 a->setStatusTip ( tr( "Color Subtree" ));
964 //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
966 a->setEnabled (false);
967 formatMenu->addAction (a);
969 actionListBranches.append(a);
970 actionFormatColorSubtree=a;
972 formatMenu->addSeparator();
973 actionGroupFormatLinkStyles=new QActionGroup ( this);
974 actionGroupFormatLinkStyles->setExclusive (true);
975 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
976 a->setStatusTip (tr( "Line" ));
977 a->setToggleAction(true);
978 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
979 formatMenu->addAction (a);
980 actionFormatLinkStyleLine=a;
981 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
982 a->setStatusTip (tr( "Line" ));
983 a->setToggleAction(true);
984 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
985 formatMenu->addAction (a);
986 actionFormatLinkStyleParabel=a;
987 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
988 a->setStatusTip (tr( "PolyLine" ));
989 a->setToggleAction(true);
990 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
991 formatMenu->addAction (a);
992 actionFormatLinkStylePolyLine=a;
993 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
994 a->setStatusTip (tr( "PolyParabel" ) );
995 a->setToggleAction(true);
996 a->setChecked (true);
997 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
998 formatMenu->addAction (a);
999 actionFormatLinkStylePolyParabel=a;
1001 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1002 a->setStatusTip (tr( "Hide link" ));
1003 a->setToggleAction(true);
1004 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1005 actionFormatHideLinkUnselected=a;
1007 formatMenu->addSeparator();
1008 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1009 a->setStatusTip (tr( "Use same color for links and headings" ));
1010 a->setToggleAction(true);
1011 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1012 formatMenu->addAction (a);
1013 actionFormatLinkColorHint=a;
1015 pix.fill (Qt::white);
1016 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1017 a->setStatusTip (tr( "Set Link Color" ));
1018 formatMenu->addAction (a);
1019 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1020 actionFormatLinkColor=a;
1022 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1023 a->setStatusTip (tr( "Set Selection Color" ));
1024 formatMenu->addAction (a);
1025 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1026 actionFormatSelectionColor=a;
1028 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1029 a->setStatusTip (tr( "Set Background Color" ));
1030 formatMenu->addAction (a);
1031 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1032 actionFormatBackColor=a;
1034 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1035 a->setStatusTip (tr( "Set Background image" ));
1036 formatMenu->addAction (a);
1037 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1038 actionFormatBackImage=a;
1042 void Main::setupViewActions()
1044 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1045 tb->setLabel( "View Actions" );
1046 tb->setObjectName ("viewTB");
1047 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1049 Switchboard switchboard; //FIXME-2 testing...
1052 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1053 a->setStatusTip ( tr( "Zoom reset" ) );
1054 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1055 switchboard.addConnection(a,"CTRL+0");
1057 viewMenu->addAction (a);
1058 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1060 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1061 a->setStatusTip (tr( "Zoom in" ));
1062 switchboard.addConnection(a,"CTRL++");
1064 viewMenu->addAction (a);
1065 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1067 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1068 a->setStatusTip (tr( "Zoom out" ));
1069 switchboard.addConnection(a,"CTRL+-");
1071 viewMenu->addAction (a);
1072 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1074 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1075 a->setStatusTip (tr( "Show selection" ));
1076 switchboard.addConnection(a,".");
1078 viewMenu->addAction (a);
1079 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1081 viewMenu->addSeparator();
1083 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1084 a->setStatusTip ( tr( "Show Note Editor" ));
1085 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1086 a->setToggleAction(true);
1088 viewMenu->addAction (a);
1089 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1090 actionViewToggleNoteEditor=a;
1092 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1093 a->setStatusTip ( tr( "Show History Window" ));
1094 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1095 a->setToggleAction(true);
1097 viewMenu->addAction (a);
1098 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1099 actionViewToggleHistoryWindow=a;
1101 viewMenu->addAction (actionViewTogglePropertyWindow);
1103 viewMenu->addSeparator();
1105 a = new QAction(tr( "Antialiasing","View action" ),this );
1106 a->setStatusTip ( tr( "Antialiasing" ));
1107 a->setToggleAction(true);
1108 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1109 viewMenu->addAction (a);
1110 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1111 actionViewToggleAntiAlias=a;
1113 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1114 a->setStatusTip (a->text());
1115 a->setToggleAction(true);
1116 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1117 viewMenu->addAction (a);
1118 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1119 actionViewToggleSmoothPixmapTransform=a;
1121 a = new QAction(tr( "Next Map","View action" ), this);
1122 a->setStatusTip (a->text());
1123 a->setShortcut (Qt::ALT + Qt::Key_N );
1124 viewMenu->addAction (a);
1125 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1127 a = new QAction (tr( "Previous Map","View action" ), this );
1128 a->setStatusTip (a->text());
1129 a->setShortcut (Qt::ALT + Qt::Key_P );
1130 viewMenu->addAction (a);
1131 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1133 if (debug) switchboard.print();
1137 void Main::setupModeActions()
1139 //QPopupMenu *menu = new QPopupMenu( this );
1140 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1142 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1143 tb->setObjectName ("modesTB");
1145 actionGroupModModes=new QActionGroup ( this);
1146 actionGroupModModes->setExclusive (true);
1147 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1148 a->setShortcut (Qt::Key_J);
1149 a->setStatusTip ( tr( "Use modifier to color branches" ));
1150 a->setToggleAction(true);
1152 a->setChecked(true);
1153 actionModModeColor=a;
1155 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1156 a->setShortcut( Qt::Key_K);
1157 a->setStatusTip( tr( "Use modifier to copy" ));
1158 a->setToggleAction(true);
1160 actionModModeCopy=a;
1162 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1163 a->setShortcut (Qt::Key_L);
1164 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1165 a->setToggleAction(true);
1167 actionModModeXLink=a;
1171 void Main::setupFlagActions()
1173 // Create System Flags
1176 Flag *flag=new Flag;;
1177 flag->setVisible(true);
1179 flag->load(QPixmap(flagsPath+"flag-note.png"));
1180 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1182 flag->load(QPixmap(flagsPath+"flag-url.png"));
1183 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1185 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1186 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1188 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1189 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1191 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1192 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1194 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1195 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1197 // Create Standard Flags
1198 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1199 tb->setObjectName ("standardFlagTB");
1200 standardFlagsMaster->setToolBar (tb);
1202 flag->load(flagsPath+"flag-exclamationmark.png");
1203 flag->setGroup("standard-mark");
1204 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1206 flag->load(flagsPath+"flag-questionmark.png");
1207 flag->setGroup("standard-mark");
1208 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1210 flag->load(flagsPath+"flag-hook-green.png");
1211 flag->setGroup("standard-status");
1212 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1214 flag->load(flagsPath+"flag-wip.png");
1215 flag->setGroup("standard-status");
1216 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1218 flag->load(flagsPath+"flag-cross-red.png");
1219 flag->setGroup("standard-status");
1220 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1223 flag->load(flagsPath+"flag-stopsign.png");
1224 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1226 flag->load(flagsPath+"flag-smiley-good.png");
1227 flag->setGroup("standard-smiley");
1228 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1230 flag->load(flagsPath+"flag-smiley-sad.png");
1231 flag->setGroup("standard-smiley");
1232 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1234 flag->load(flagsPath+"flag-smiley-omg.png");
1235 flag->setGroup("standard-smiley");
1236 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1237 // Original omg.png (in KDE emoticons)
1240 flag->load(flagsPath+"flag-kalarm.png");
1241 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1243 flag->load(flagsPath+"flag-phone.png");
1244 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1246 flag->load(flagsPath+"flag-lamp.png");
1247 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1249 flag->load(flagsPath+"flag-arrow-up.png");
1250 flag->setGroup("standard-arrow");
1251 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1253 flag->load(flagsPath+"flag-arrow-down.png");
1254 flag->setGroup("standard-arrow");
1255 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1257 flag->load(flagsPath+"flag-arrow-2up.png");
1258 flag->setGroup("standard-arrow");
1259 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1261 flag->load(flagsPath+"flag-arrow-2down.png");
1262 flag->setGroup("standard-arrow");
1263 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1266 flag->load(flagsPath+"flag-thumb-up.png");
1267 flag->setGroup("standard-thumb");
1268 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1270 flag->load(flagsPath+"flag-thumb-down.png");
1271 flag->setGroup("standard-thumb");
1272 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1275 flag->load(flagsPath+"flag-rose.png");
1276 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1278 flag->load(flagsPath+"flag-heart.png");
1279 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1281 flag->load(flagsPath+"flag-present.png");
1282 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1284 flag->load(flagsPath+"flag-flash.png");
1285 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1287 // Original: xsldbg_output.png
1288 flag->load(flagsPath+"flag-info.png");
1289 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1291 // Original khelpcenter.png
1292 flag->load(flagsPath+"flag-lifebelt.png");
1293 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1296 flag->setVisible(false);
1297 flag->load(flagsPath+"freemind/warning.png");
1298 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1300 for (int i=1; i<8; i++)
1302 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1303 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1306 flag->load(flagsPath+"freemind/back.png");
1307 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1309 flag->load(flagsPath+"freemind/forward.png");
1310 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1312 flag->load(flagsPath+"freemind/attach.png");
1313 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1315 flag->load(flagsPath+"freemind/clanbomber.png");
1316 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1318 flag->load(flagsPath+"freemind/desktopnew.png");
1319 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1321 flag->load(flagsPath+"freemind/flag.png");
1322 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1325 flag->load(flagsPath+"freemind/gohome.png");
1326 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1329 flag->load(flagsPath+"freemind/kaddressbook.png");
1330 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1332 flag->load(flagsPath+"freemind/knotify.png");
1333 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1335 flag->load(flagsPath+"freemind/korn.png");
1336 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1338 flag->load(flagsPath+"freemind/mail.png");
1339 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1341 flag->load(flagsPath+"freemind/password.png");
1342 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1344 flag->load(flagsPath+"freemind/pencil.png");
1345 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1347 flag->load(flagsPath+"freemind/stop.png");
1348 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1350 flag->load(flagsPath+"freemind/wizard.png");
1351 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1353 flag->load(flagsPath+"freemind/xmag.png");
1354 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1356 flag->load(flagsPath+"freemind/bell.png");
1357 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1359 flag->load(flagsPath+"freemind/bookmark.png");
1360 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1362 flag->load(flagsPath+"freemind/penguin.png");
1363 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1365 flag->load(flagsPath+"freemind/licq.png");
1366 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1369 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1371 flag->setName(name);
1372 flag->setToolTip (tooltip);
1376 a=new QAction (flag->getPixmap(),name,this);
1379 flag->setAction (a);
1380 a->setVisible (flag->isVisible());
1381 a->setCheckable(true);
1382 a->setObjectName(name);
1383 a->setToolTip(tooltip);
1384 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1385 standardFlagsMaster->addFlag (flag);
1389 systemFlagsMaster->addFlag (flag);
1394 void Main::setupNetworkActions()
1396 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1398 QMenu *netMenu = menuBar()->addMenu( "Network" );
1402 a = new QAction( "Start TCPserver for MapEditor",this);
1403 //a->setStatusTip ( "Set application to open pdf files"));
1404 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1405 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1406 netMenu->addAction (a);
1408 a = new QAction( "Connect MapEditor to server",this);
1409 //a->setStatusTip ( "Set application to open pdf files"));
1410 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1411 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1412 netMenu->addAction (a);
1416 void Main::setupSettingsActions()
1418 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1422 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1423 a->setStatusTip ( tr( "Set application to open pdf files"));
1424 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1425 settingsMenu->addAction (a);
1427 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1428 a->setStatusTip( tr( "Set application to open external links"));
1429 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1430 settingsMenu->addAction (a);
1432 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1433 a->setStatusTip( tr( "Set path for macros"));
1434 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1435 settingsMenu->addAction (a);
1437 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1438 a->setStatusTip( tr( "Set number of undo levels"));
1439 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1440 settingsMenu->addAction (a);
1442 settingsMenu->addSeparator();
1444 a = new QAction( tr( "Autosave","Settings action"), this);
1445 a->setStatusTip( tr( "Autosave"));
1446 a->setToggleAction(true);
1447 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1448 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1449 settingsMenu->addAction (a);
1450 actionSettingsAutosaveToggle=a;
1452 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1453 a->setStatusTip( tr( "Autosave time"));
1454 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1455 settingsMenu->addAction (a);
1456 actionSettingsAutosaveTime=a;
1458 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1459 a->setStatusTip( tr( "Write backup file on save"));
1460 a->setToggleAction(true);
1461 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1462 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1463 settingsMenu->addAction (a);
1464 actionSettingsWriteBackupFile=a;
1466 settingsMenu->addSeparator();
1468 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1469 a->setStatusTip( tr( "Edit branch after adding it" ));
1470 a->setToggleAction(true);
1471 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1472 settingsMenu->addAction (a);
1473 actionSettingsAutoEditNewBranch=a;
1475 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1476 a->setStatusTip( tr( "Select branch after adding it" ));
1477 a->setToggleAction(true);
1478 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1479 settingsMenu->addAction (a);
1480 actionSettingsAutoSelectNewBranch=a;
1482 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1483 a->setStatusTip( tr( "Select heading before editing" ));
1484 a->setToggleAction(true);
1485 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1486 settingsMenu->addAction (a);
1487 actionSettingsAutoSelectText=a;
1489 a= new QAction( tr( "Delete key","Settings action" ), this);
1490 a->setStatusTip( tr( "Delete key for deleting branches" ));
1491 a->setToggleAction(true);
1492 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1493 settingsMenu->addAction (a);
1494 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1495 actionSettingsUseDelKey=a;
1497 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1498 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1499 a->setToggleAction(true);
1500 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1501 settingsMenu->addAction (a);
1502 actionSettingsUseFlagGroups=a;
1504 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1505 a->setStatusTip( tr( "Use hide flag during exports " ));
1506 a->setToggleAction(true);
1507 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1508 settingsMenu->addAction (a);
1509 actionSettingsUseHideExport=a;
1511 a = new QAction( tr( "Animation","Settings action"), this);
1512 a->setStatusTip( tr( "Animation"));
1513 a->setToggleAction(true);
1514 a->setChecked (settings.value("/animation/use",true).toBool() );
1515 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1516 settingsMenu->addAction (a);
1517 actionSettingsUseAnimation=a;
1521 void Main::setupTestActions()
1523 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1526 a = new QAction( "Test function 1" , this);
1527 a->setStatusTip( "Call test function 1" );
1528 a->setShortcut (Qt::CTRL + Qt::Key_T); // Test function 1 //FIXME-2 originally: color subtree
1529 testMenu->addAction (a);
1530 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1532 a = new QAction( "Test function 2" , this);
1533 a->setStatusTip( "Call test function 2" );
1534 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 2
1535 testMenu->addAction (a);
1536 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1538 a = new QAction( "Command" , this);
1539 a->setStatusTip( "Enter command to call in editor" );
1540 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1541 testMenu->addAction (a);
1545 void Main::setupHelpActions()
1547 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1550 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1551 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1552 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1553 helpMenu->addAction (a);
1555 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1556 a->setStatusTip( tr( "Open VYM example maps " ));
1557 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1558 helpMenu->addAction (a);
1560 a = new QAction( tr( "About VYM","Help action" ), this);
1561 a->setStatusTip( tr( "About VYM")+vymName);
1562 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1563 helpMenu->addAction (a);
1565 a = new QAction( tr( "About QT","Help action" ), this);
1566 a->setStatusTip( tr( "Information about QT toolkit" ));
1567 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1568 helpMenu->addAction (a);
1572 void Main::setupContextMenus()
1576 // Context Menu for branch or mapcenter
1577 branchContextMenu =new QMenu (this);
1578 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1579 branchContextMenu->addSeparator();
1582 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1583 branchAddContextMenu->addAction (actionPaste );
1584 branchAddContextMenu->addAction ( actionAddMapCenter );
1585 branchAddContextMenu->addAction ( actionAddBranch );
1586 branchAddContextMenu->addAction ( actionAddBranchBefore );
1587 branchAddContextMenu->addAction ( actionAddBranchAbove);
1588 branchAddContextMenu->addAction ( actionAddBranchBelow );
1589 branchAddContextMenu->addSeparator();
1590 branchAddContextMenu->addAction ( actionImportAdd );
1591 branchAddContextMenu->addAction ( actionImportReplace );
1594 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1595 branchRemoveContextMenu->addAction (actionCut);
1596 branchRemoveContextMenu->addAction ( actionDelete );
1597 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1598 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1601 actionSaveBranch->addTo( branchContextMenu );
1602 actionFileNewCopy->addTo (branchContextMenu );
1603 actionDetach->addTo (branchContextMenu );
1605 branchContextMenu->addSeparator();
1606 branchContextMenu->addAction ( actionLoadImage);
1607 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1608 branchContextMenu->addAction ( actionAddAttribute);
1610 // Submenu for Links (URLs, vymLinks)
1611 branchLinksContextMenu =new QMenu (this);
1613 branchContextMenu->addSeparator();
1614 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1615 branchLinksContextMenu->addAction ( actionOpenURL );
1616 branchLinksContextMenu->addAction ( actionOpenURLTab );
1617 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1618 branchLinksContextMenu->addAction ( actionURL );
1619 branchLinksContextMenu->addAction ( actionLocalURL );
1620 branchLinksContextMenu->addAction ( actionHeading2URL );
1621 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1622 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1624 branchLinksContextMenu->addAction ( actionFATE2URL );
1626 branchLinksContextMenu->addSeparator();
1627 branchLinksContextMenu->addAction ( actionOpenVymLink );
1628 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1629 branchLinksContextMenu->addAction ( actionVymLink );
1630 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1633 // Context Menu for XLinks in a branch menu
1634 // This will be populated "on demand" in MapEditor::updateActions
1635 branchContextMenu->addSeparator();
1636 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1637 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1640 // Context menu for floatimage
1641 floatimageContextMenu =new QMenu (this);
1642 a= new QAction (tr ("Save image","Context action"),this);
1643 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1644 floatimageContextMenu->addAction (a);
1646 floatimageContextMenu->addSeparator();
1647 actionCopy->addTo( floatimageContextMenu );
1648 actionCut->addTo( floatimageContextMenu );
1650 floatimageContextMenu->addSeparator();
1651 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1654 // Context menu for canvas
1655 canvasContextMenu =new QMenu (this);
1656 actionAddMapCenter->addTo( canvasContextMenu );
1657 actionMapInfo->addTo( canvasContextMenu );
1658 canvasContextMenu->insertSeparator();
1659 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1660 canvasContextMenu->insertSeparator();
1661 actionFormatLinkColorHint->addTo( canvasContextMenu );
1662 actionFormatLinkColor->addTo( canvasContextMenu );
1663 actionFormatSelectionColor->addTo( canvasContextMenu );
1664 actionFormatBackColor->addTo( canvasContextMenu );
1665 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1667 // Menu for last opened files
1669 for (int i = 0; i < MaxRecentFiles; ++i)
1671 recentFileActions[i] = new QAction(this);
1672 recentFileActions[i]->setVisible(false);
1673 fileLastMapsMenu->addAction(recentFileActions[i]);
1674 connect(recentFileActions[i], SIGNAL(triggered()),
1675 this, SLOT(fileLoadRecent()));
1677 setupRecentMapsMenu();
1680 void Main::setupRecentMapsMenu()
1682 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1684 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1686 for (int i = 0; i < numRecentFiles; ++i) {
1687 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1688 recentFileActions[i]->setText(text);
1689 recentFileActions[i]->setData(files[i]);
1690 recentFileActions[i]->setVisible(true);
1692 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1693 recentFileActions[j]->setVisible(false);
1696 void Main::setupMacros()
1698 for (int i = 0; i <= 11; i++)
1700 macroActions[i] = new QAction(this);
1701 macroActions[i]->setData(i);
1702 addAction (macroActions[i]);
1703 connect(macroActions[i], SIGNAL(triggered()),
1704 this, SLOT(callMacro()));
1706 macroActions[0]->setShortcut ( Qt::Key_F1 );
1707 macroActions[1]->setShortcut ( Qt::Key_F2 );
1708 macroActions[2]->setShortcut ( Qt::Key_F3 );
1709 macroActions[3]->setShortcut ( Qt::Key_F4 );
1710 macroActions[4]->setShortcut ( Qt::Key_F5 );
1711 macroActions[5]->setShortcut ( Qt::Key_F6 );
1712 macroActions[6]->setShortcut ( Qt::Key_F7 );
1713 macroActions[7]->setShortcut ( Qt::Key_F8 );
1714 macroActions[8]->setShortcut ( Qt::Key_F9 );
1715 macroActions[9]->setShortcut ( Qt::Key_F10 );
1716 macroActions[10]->setShortcut ( Qt::Key_F11 );
1717 macroActions[11]->setShortcut ( Qt::Key_F12 );
1720 void Main::hideEvent (QHideEvent * )
1722 if (!textEditor->isMinimized() ) textEditor->hide();
1725 void Main::showEvent (QShowEvent * )
1727 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1731 MapEditor* Main::currentMapEditor() const
1733 if ( tabWidget->currentPage())
1734 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1738 VymModel* Main::currentModel() const
1740 if ( tabWidget->currentPage())
1741 return vymViews.at(tabWidget->currentIndex())->getModel();
1746 void Main::editorChanged(QWidget *)
1748 // Unselect all possibly selected objects
1749 // (Important to update note editor)
1751 for (int i=0;i<=tabWidget->count() -1;i++)
1753 m= vymViews.at(i)->getModel();
1754 if (m) m->unselect();
1757 if (m) m->reselect();
1759 // Update actions to in menus and toolbars according to editor
1763 void Main::fileNew()
1765 VymModel *vm=new VymModel;
1767 /////////////////////////////////////
1768 // new ModelTest(vm, this); //FIXME-3
1769 /////////////////////////////////////
1771 VymView *vv=new VymView (vm);
1772 vymViews.append (vv);
1773 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1774 tabWidget->setCurrentIndex (vymViews.count() );
1777 // Create MapCenter for empty map
1781 // For the very first map we do not have flagrows yet...
1785 void Main::fileNewCopy()
1787 QString fn="unnamed";
1788 VymModel *srcModel=currentModel();
1793 VymModel *dstModel=vymViews.last()->getModel();
1794 dstModel->select("mc:");
1795 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1799 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1801 ErrorCode err=success;
1803 // fn is usually the archive, mapfile the file after uncompressing
1806 // Make fn absolute (needed for unzip)
1807 fn=QDir (fn).absPath();
1813 // Check, if map is already loaded
1815 while (i<=tabWidget->count() -1)
1817 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1819 // Already there, ask for confirmation
1820 QMessageBox mb( vymName,
1821 tr("The map %1\nis already opened."
1822 "Opening the same map in multiple editors may lead \n"
1823 "to confusion when finishing working with vym."
1824 "Do you want to").arg(fn),
1825 QMessageBox::Warning,
1826 QMessageBox::Yes | QMessageBox::Default,
1827 QMessageBox::Cancel | QMessageBox::Escape,
1828 QMessageBox::NoButton);
1829 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1830 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1833 case QMessageBox::Yes:
1834 // end loop and load anyway
1835 i=tabWidget->count();
1837 case QMessageBox::Cancel:
1847 int tabIndex=tabWidget->currentPageIndex();
1850 if ( !fn.isEmpty() )
1852 vm = currentModel();
1853 // Check first, if mapeditor exists
1854 // If it is not default AND we want a new map,
1855 // create a new mapeditor in a new tab
1856 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1859 VymView *vv=new VymView (vm);
1860 vymViews.append (vv);
1861 tabWidget->addTab (vv,fn);
1862 tabIndex=tabWidget->count()-1;
1863 tabWidget->setCurrentPage (tabIndex);
1867 // Check, if file exists (important for creating new files
1868 // from command line
1869 if (!QFile(fn).exists() )
1871 QMessageBox mb( vymName,
1872 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1873 QMessageBox::Question,
1875 QMessageBox::Cancel | QMessageBox::Default,
1876 QMessageBox::NoButton );
1878 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1879 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1882 case QMessageBox::Yes:
1884 currentMapEditor()->getModel()->setFilePath(fn);
1885 tabWidget->setTabText (tabIndex,
1886 currentMapEditor()->getModel()->getFileName() );
1887 statusBar()->message( "Created " + fn , statusbarTime );
1890 case QMessageBox::Cancel:
1891 // don't create new map
1892 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1899 //tabWidget->currentPage() won't be NULL here, because of above...
1900 tabWidget->setCurrentIndex (tabIndex);
1901 //FIXME-3 no me anymore... me->viewport()->setFocus();
1905 // Save existing filename in case we import
1906 QString fn_org=vm->getFilePath();
1908 // Finally load map into mapEditor
1909 vm->setFilePath (fn);
1910 err=vm->load(fn,lmode,ftype);
1912 // Restore old (maybe empty) filepath, if this is an import
1914 vm->setFilePath (fn_org);
1917 // Finally check for errors and go home
1920 if (lmode==NewMap) fileCloseMap();
1921 statusBar()->message( "Could not load " + fn, statusbarTime );
1926 vm->setFilePath (fn);
1927 tabWidget->setTabText (tabIndex, vm->getFileName());
1928 if (!isInTmpDir (fn))
1930 // Only append to lastMaps if not loaded from a tmpDir
1931 // e.g. imported bookmarks are in a tmpDir
1932 addRecentMap(vm->getFilePath() );
1934 actionFilePrint->setEnabled (true);
1936 statusBar()->message( "Loaded " + fn, statusbarTime );
1943 void Main::fileLoad(const LoadMode &lmode)
1945 QStringList filters;
1946 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1947 QFileDialog *fd=new QFileDialog( this);
1948 fd->setDir (lastFileDir);
1949 fd->setFileMode (QFileDialog::ExistingFiles);
1950 fd->setFilters (filters);
1954 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1957 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1960 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1966 if ( fd->exec() == QDialog::Accepted )
1968 lastFileDir=fd->directory().path();
1969 QStringList flist = fd->selectedFiles();
1970 QStringList::Iterator it = flist.begin();
1971 while( it != flist.end() )
1974 fileLoad(*it, lmode);
1981 void Main::fileLoad()
1986 void Main::fileLoadRecent()
1988 QAction *action = qobject_cast<QAction *>(sender());
1990 fileLoad (action->data().toString(), NewMap);
1993 void Main::addRecentMap (const QString &fileName)
1996 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1997 files.removeAll(fileName);
1998 files.prepend(fileName);
1999 while (files.size() > MaxRecentFiles)
2002 settings.setValue("/mainwindow/recentFileList", files);
2004 setupRecentMapsMenu();
2007 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2011 if ( m->getFilePath().isEmpty() )
2013 // We have no filepath yet,
2014 // call fileSaveAs() now, this will call fileSave()
2016 // First switch to editor
2017 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2018 fileSaveAs(savemode);
2021 if (m->save (savemode)==success)
2023 statusBar()->message(
2024 tr("Saved %1").arg(m->getFilePath()),
2026 addRecentMap (m->getFilePath() );
2028 statusBar()->message(
2029 tr("Couldn't save ").arg(m->getFilePath()),
2033 void Main::fileSave()
2035 fileSave (currentModel(), CompleteMap);
2038 void Main::fileSave(VymModel *m)
2040 fileSave (m,CompleteMap);
2043 void Main::fileSaveAs(const SaveMode& savemode)
2047 if (currentMapEditor())
2049 if (savemode==CompleteMap)
2050 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2052 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2053 if ( !fn.isEmpty() )
2055 // Check for existing file
2056 if (QFile (fn).exists())
2058 QMessageBox mb( vymName,
2059 tr("The file %1\nexists already. Do you want to").arg(fn),
2060 QMessageBox::Warning,
2061 QMessageBox::Yes | QMessageBox::Default,
2062 QMessageBox::Cancel | QMessageBox::Escape,
2063 QMessageBox::NoButton);
2064 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2065 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2068 case QMessageBox::Yes:
2071 case QMessageBox::Cancel:
2078 // New file, add extension to filename, if missing
2079 // This is always .vym or .vyp, depending on savemode
2080 if (savemode==CompleteMap)
2082 if (!fn.contains (".vym") && !fn.contains (".xml"))
2086 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2095 VymModel *m=currentModel();
2097 fileSave(m, savemode);
2099 // Set name of tab, assuming current tab is the one we just saved
2100 if (savemode==CompleteMap)
2101 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2107 void Main::fileSaveAs()
2109 fileSaveAs (CompleteMap);
2112 void Main::fileImportKDE3Bookmarks()
2114 ImportKDE3Bookmarks im;
2116 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2117 currentMapEditor()->getModel()->setFilePath ("");
2120 void Main::fileImportKDE4Bookmarks()
2122 ImportKDE4Bookmarks im;
2124 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2125 currentMapEditor()->getModel()->setFilePath ("");
2128 void Main::fileImportFirefoxBookmarks()
2130 Q3FileDialog *fd=new Q3FileDialog( this);
2131 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2132 fd->setMode (Q3FileDialog::ExistingFiles);
2133 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2134 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2137 if ( fd->exec() == QDialog::Accepted )
2139 ImportFirefoxBookmarks im;
2140 QStringList flist = fd->selectedFiles();
2141 QStringList::Iterator it = flist.begin();
2142 while( it != flist.end() )
2145 if (im.transform() &&
2146 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2147 currentMapEditor() )
2148 currentMapEditor()->getModel()->setFilePath ("");
2155 void Main::fileImportFreemind()
2157 QStringList filters;
2158 filters <<"Freemind map (*.mm)"<<"All files (*)";
2159 QFileDialog *fd=new QFileDialog( this);
2160 fd->setDir (lastFileDir);
2161 fd->setFileMode (QFileDialog::ExistingFiles);
2162 fd->setFilters (filters);
2163 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2167 if ( fd->exec() == QDialog::Accepted )
2169 lastFileDir=fd->directory().path();
2170 QStringList flist = fd->selectedFiles();
2171 QStringList::Iterator it = flist.begin();
2172 while( it != flist.end() )
2175 if ( fileLoad (fn,NewMap, FreemindMap) )
2177 currentMapEditor()->getModel()->setFilePath ("");
2186 void Main::fileImportMM()
2190 Q3FileDialog *fd=new Q3FileDialog( this);
2191 fd->setDir (lastFileDir);
2192 fd->setMode (Q3FileDialog::ExistingFiles);
2193 fd->addFilter ("Mind Manager (*.mmap)");
2194 fd->setCaption(tr("Import")+" "+"Mind Manager");
2197 if ( fd->exec() == QDialog::Accepted )
2199 lastFileDir=fd->dirPath();
2200 QStringList flist = fd->selectedFiles();
2201 QStringList::Iterator it = flist.begin();
2202 while( it != flist.end() )
2205 if (im.transform() &&
2206 success==fileLoad (im.getTransformedFile(),NewMap) &&
2207 currentMapEditor() )
2208 currentMapEditor()->getModel()->setFilePath ("");
2215 void Main::fileImportDir()
2217 VymModel *m=currentModel();
2218 if (m) m->importDir();
2221 void Main::fileExportXML()
2223 VymModel *m=currentModel();
2224 if (m) m->exportXML();
2227 void Main::fileExportHTML()
2229 VymModel *m=currentModel();
2230 if (m) m->exportHTML();
2234 void Main::fileExportXHTML()
2236 VymModel *m=currentModel();
2237 if (m) m->exportXHTML();
2240 void Main::fileExportImage()
2242 VymModel *m=currentModel();
2243 if (m) m->exportImage();
2246 void Main::fileExportAO()
2248 VymModel *m=currentModel();
2249 if (m) m->exportAO();
2252 void Main::fileExportASCII()
2254 VymModel *m=currentModel();
2255 if (m) m->exportASCII();
2258 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2260 VymModel *m=currentModel();
2265 ex.addFilter ("CSV (*.csv)");
2266 ex.setDir(lastImageDir);
2267 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2268 if (ex.execDialog() )
2270 m->setExportMode(true);
2272 m->setExportMode(false);
2277 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2279 VymModel *m=currentModel();
2284 ex.addFilter ("Tex (*.tex)");
2285 ex.setDir(lastImageDir);
2286 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2287 if (ex.execDialog() )
2289 m->setExportMode(true);
2291 m->setExportMode(false);
2296 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2298 ExportKDE3Bookmarks ex;
2299 VymModel *m=currentModel();
2307 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2309 ExportKDE4Bookmarks ex;
2310 VymModel *m=currentModel();
2318 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2320 ExportTaskjuggler ex;
2321 VymModel *m=currentModel();
2325 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2326 ex.setDir(lastImageDir);
2327 ex.addFilter ("Taskjuggler (*.tjp)");
2328 if (ex.execDialog() )
2330 m->setExportMode(true);
2332 m->setExportMode(false);
2337 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2339 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2340 // TODO add preview in dialog
2341 //ImagePreview *p =new ImagePreview (fd);
2342 //fd->setContentsPreviewEnabled( TRUE );
2343 //fd->setContentsPreview( p, p );
2344 //fd->setPreviewMode( QFileDialog::Contents );
2345 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2346 fd->setDir (QDir().current());
2347 if (fd->foundConfig())
2351 if ( fd->exec() == QDialog::Accepted )
2353 QString fn=fd->selectedFile();
2354 if (!fn.contains (".odp"))
2357 //lastImageDir=fn.left(fn.findRev ("/"));
2358 VymModel *m=currentModel();
2359 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2363 QMessageBox::warning(0,
2365 tr("Couldn't find configuration for export to Open Office\n"));
2369 void Main::fileCloseMap()
2371 VymModel *m=currentModel();
2374 if (m->hasChanged())
2376 QMessageBox mb( vymName,
2377 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2378 QMessageBox::Warning,
2379 QMessageBox::Yes | QMessageBox::Default,
2381 QMessageBox::Cancel | QMessageBox::Escape );
2382 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2383 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2386 case QMessageBox::Yes:
2388 fileSave(m, CompleteMap);
2390 case QMessageBox::No:
2391 // close without saving
2393 case QMessageBox::Cancel:
2398 // And here comes the segfault, because removeTab triggers
2399 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2400 vymViews.removeAt (tabWidget->currentIndex() );
2401 tabWidget->removeTab (tabWidget->currentIndex() );
2403 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2404 // Better would be delete (me), but then we could have a Qt error:
2405 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2406 // So we only remove data now and call deconstructor when vym closes later
2407 // this needs to be moved to vymview... me->clear();
2408 // some model->clear is needed to free up memory ...
2410 delete (m->getMapEditor());
2417 void Main::filePrint()
2419 if (currentMapEditor())
2420 currentMapEditor()->print();
2423 void Main::fileExitVYM()
2425 // Check if one or more editors have changed
2427 for (i=0;i<=vymViews.count() -1;i++)
2429 // If something changed, ask what to do
2430 if (vymViews.at(i)->getModel()->hasChanged())
2432 tabWidget->setCurrentPage(i);
2433 QMessageBox mb( vymName,
2434 tr("This map is not saved yet. Do you want to"),
2435 QMessageBox::Warning,
2436 QMessageBox::Yes | QMessageBox::Default,
2438 QMessageBox::Cancel | QMessageBox::Escape );
2439 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2440 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2443 mb.setActiveWindow();
2444 switch( mb.exec() ) {
2445 case QMessageBox::Yes:
2446 // save (the changed editors) and exit
2447 fileSave(currentModel(), CompleteMap);
2449 case QMessageBox::No:
2450 // exit without saving
2452 case QMessageBox::Cancel:
2453 // don't save and don't exit
2457 } // loop over all MEs
2461 void Main::editUndo()
2463 VymModel *m=currentModel();
2467 void Main::editRedo()
2469 VymModel *m=currentModel();
2473 void Main::gotoHistoryStep (int i)
2475 VymModel *m=currentModel();
2476 if (m) m->gotoHistoryStep(i);
2479 void Main::editCopy()
2481 VymModel *m=currentModel();
2485 void Main::editPaste()
2487 VymModel *m=currentModel();
2491 void Main::editCut()
2493 VymModel *m=currentModel();
2497 void Main::editOpenFindWidget()
2499 VymModel *m=currentModel();
2500 if (m) m->emitShowFindWidget();
2503 void Main::openTabs(QStringList urls)
2505 if (!urls.isEmpty())
2509 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2510 if (*browserPID==0) //FIXME-2 need to check if browser is really still there instead of this
2512 QString u=urls.takeFirst();
2514 QString workDir=QDir::currentDirPath();
2515 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2517 // try to set path to browser
2518 QMessageBox::warning(0,
2520 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2521 tr("Please use Settings->")+tr("Set application to open an URL"));
2524 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2525 #if defined(Q_OS_WIN32)
2526 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2527 this->thread()->wait(3000);
2529 sleep (3); //FIXME-3 needed?
2533 if (browser.contains("konqueror"))
2535 for (int i=0; i<urls.size(); i++)
2538 // Try to open new tab in existing konqueror started previously by vym
2542 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2543 "konqueror-mainwindow#1"<<
2547 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2548 "/konqueror/MainWindow_1"<<
2552 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2553 if (!QProcess::startDetached ("qdbus",args))
2557 QMessageBox::warning(0,
2559 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2561 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2563 for (int i=0; i<urls.size(); i++)
2565 // Try to open new tab in firefox
2566 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2567 if (!QProcess::startDetached (browser,args))
2571 QMessageBox::warning(0,
2573 tr("Couldn't start %1 to open a new tab").arg(browser));
2576 QMessageBox::warning(0,
2578 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2582 void Main::editOpenURL()
2585 VymModel *m=currentModel();
2588 QString url=m->getURL();
2590 if (url=="") return;
2591 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2593 QString workDir=QDir::currentDirPath();
2594 if (!procBrowser->startDetached(browser,args))
2596 // try to set path to browser
2597 QMessageBox::warning(0,
2599 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2600 tr("Please use Settings->")+tr("Set application to open an URL"));
2605 void Main::editOpenURLTab()
2607 VymModel *m=currentModel();
2611 urls.append(m->getURL());
2615 void Main::editOpenMultipleURLTabs()
2617 VymModel *m=currentModel();
2627 void Main::editURL()
2629 VymModel *m=currentModel();
2630 if (m) m->editURL();
2633 void Main::editLocalURL()
2635 VymModel *m=currentModel();
2636 if (m) m->editLocalURL();
2639 void Main::editHeading2URL()
2641 VymModel *m=currentModel();
2642 if (m) m->editHeading2URL();
2645 void Main::editBugzilla2URL()
2647 VymModel *m=currentModel();
2648 if (m) m->editBugzilla2URL();
2651 void Main::editFATE2URL()
2653 VymModel *m=currentModel();
2654 if (m) m->editFATE2URL();
2657 void Main::editHeadingFinished(VymModel *m)
2661 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2662 !prevSelection.isEmpty())
2663 m->select(prevSelection);
2668 void Main::openVymLinks(const QStringList &vl)
2670 for (int j=0; j<vl.size(); j++)
2672 // compare path with already loaded maps
2675 for (i=0;i<=vymViews.count() -1;i++)
2677 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2686 if (!QFile(vl.at(j)).exists() )
2687 QMessageBox::critical( 0, tr( "Critical Error" ),
2688 tr("Couldn't open map %1").arg(vl.at(j)));
2691 fileLoad (vl.at(j), NewMap);
2692 tabWidget->setCurrentIndex (tabWidget->count()-1);
2695 // Go to tab containing the map
2696 tabWidget->setCurrentIndex (index);
2700 void Main::editOpenVymLink()
2702 VymModel *m=currentModel();
2706 vl.append(m->getVymLink());
2711 void Main::editOpenMultipleVymLinks()
2713 QString currentVymLink;
2714 VymModel *m=currentModel();
2717 QStringList vl=m->getVymLinks();
2722 void Main::editVymLink()
2724 VymModel *m=currentModel();
2729 void Main::editDeleteVymLink()
2731 VymModel *m=currentModel();
2732 if (m) m->deleteVymLink();
2735 void Main::editToggleHideExport()
2737 VymModel *m=currentModel();
2738 if (m) m->toggleHideExport();
2741 void Main::editAddTimestamp()
2743 VymModel *m=currentModel();
2744 if (m) m->addTimestamp();
2747 void Main::editMapInfo()
2749 VymModel *m=currentModel();
2752 ExtraInfoDialog dia;
2753 dia.setMapName (m->getFileName() );
2754 dia.setAuthor (m->getAuthor() );
2755 dia.setComment(m->getComment() );
2759 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2765 BranchItem *cur=NULL;
2766 BranchItem *prev=NULL;
2767 m->nextBranch(cur,prev);
2770 if (!cur->getNote().isEmpty() ) n++;
2771 f+= cur->imageCount();
2773 xl+=cur->xlinkCount();
2774 m->nextBranch(cur,prev);
2777 stats+=QString ("%1 xLinks \n").arg (xl,6);
2778 stats+=QString ("%1 notes\n").arg (n,6);
2779 stats+=QString ("%1 images\n").arg (f,6);
2780 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2781 dia.setStats (stats);
2783 // Finally show dialog
2784 if (dia.exec() == QDialog::Accepted)
2786 m->setAuthor (dia.getAuthor() );
2787 m->setComment (dia.getComment() );
2791 void Main::editMoveUp()
2793 VymModel *m=currentModel();
2797 void Main::editMoveDown()
2799 VymModel *m=currentModel();
2800 if (m) m->moveDown();
2803 void Main::editDetach()
2805 VymModel *m=currentModel();
2809 void Main::editSortChildren()
2811 VymModel *m=currentModel();
2812 if (m) m->sortChildren();
2815 void Main::editToggleScroll()
2817 VymModel *m=currentModel();
2818 if (m) m->toggleScroll();
2821 void Main::editExpandAll()
2823 VymModel *m=currentModel();
2824 if (m) m->emitExpandAll();
2827 void Main::editExpandOneLevel()
2829 VymModel *m=currentModel();
2830 if (m) m->emitExpandOneLevel();
2833 void Main::editCollapseOneLevel()
2835 VymModel *m=currentModel();
2836 if (m) m->emitCollapseOneLevel();
2839 void Main::editUnscrollChildren()
2841 VymModel *m=currentModel();
2842 if (m) m->unscrollChildren();
2845 void Main::editAddAttribute()
2847 VymModel *m=currentModel();
2855 void Main::editAddMapCenter()
2857 VymModel *m=currentModel();
2858 if (m) m->addMapCenter ();
2861 void Main::editNewBranch()
2863 VymModel *m=currentModel();
2866 BranchItem *bi=m->addNewBranch();
2869 if (actionSettingsAutoEditNewBranch->isOn()
2870 && !actionSettingsAutoSelectNewBranch->isOn() )
2871 prevSelection=m->getSelectString();
2873 prevSelection=QString();
2875 if (actionSettingsAutoSelectNewBranch->isOn()
2876 || actionSettingsAutoEditNewBranch->isOn())
2879 if (actionSettingsAutoEditNewBranch->isOn())
2880 currentMapEditor()->editHeading();
2885 void Main::editNewBranchBefore()
2887 VymModel *m=currentModel();
2890 BranchItem *bi=m->addNewBranchBefore();
2897 if (actionSettingsAutoEditNewBranch->isOn())
2899 if (!actionSettingsAutoSelectNewBranch->isOn())
2900 prevSelection=m->getSelectString(bi);
2901 currentMapEditor()->editHeading();
2906 void Main::editNewBranchAbove()
2908 VymModel *m=currentModel();
2911 BranchItem *bi=m->addNewBranch (-1);
2919 if (actionSettingsAutoEditNewBranch->isOn())
2921 if (!actionSettingsAutoSelectNewBranch->isOn())
2922 prevSelection=m->getSelectString (bi);
2923 currentMapEditor()->editHeading();
2928 void Main::editNewBranchBelow()
2930 VymModel *m=currentModel();
2933 BranchItem *bi=m->addNewBranch (1);
2940 if (actionSettingsAutoEditNewBranch->isOn())
2942 if (!actionSettingsAutoSelectNewBranch->isOn())
2943 prevSelection=m->getSelectString(bi);
2944 currentMapEditor()->editHeading();
2949 void Main::editImportAdd()
2951 fileLoad (ImportAdd);
2954 void Main::editImportReplace()
2956 fileLoad (ImportReplace);
2959 void Main::editSaveBranch()
2961 fileSaveAs (PartOfMap);
2964 void Main::editDeleteKeepChildren()
2966 VymModel *m=currentModel();
2967 if (m) m->deleteKeepChildren();
2970 void Main::editDeleteChildren()
2972 VymModel *m=currentModel();
2973 if (m) m->deleteChildren();
2976 void Main::editDeleteSelection()
2978 VymModel *m=currentModel();
2979 if (m && actionSettingsUseDelKey->isOn())
2980 m->deleteSelection();
2983 void Main::editLoadImage()
2985 VymModel *m=currentModel();
2986 if (m) m->loadFloatImage();
2989 void Main::editSaveImage()
2991 VymModel *m=currentModel();
2992 if (m) m->saveFloatImage();
2995 void Main::editEditXLink(QAction *a)
2997 VymModel *m=currentModel();
2999 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3002 void Main::formatSelectColor()
3004 QColor col = QColorDialog::getColor((currentColor ), this );
3005 if ( !col.isValid() ) return;
3006 colorChanged( col );
3009 void Main::formatPickColor()
3011 VymModel *m=currentModel();
3013 colorChanged( m->getCurrentHeadingColor() );
3016 void Main::colorChanged(QColor c)
3018 QPixmap pix( 16, 16 );
3020 actionFormatColor->setIconSet( pix );
3024 void Main::formatColorBranch()
3026 VymModel *m=currentModel();
3027 if (m) m->colorBranch(currentColor);
3030 void Main::formatColorSubtree()
3032 VymModel *m=currentModel();
3033 if (m) m->colorSubtree (currentColor);
3036 void Main::formatLinkStyleLine()
3038 VymModel *m=currentModel();
3041 m->setMapLinkStyle("StyleLine");
3042 actionFormatLinkStyleLine->setChecked(true);
3046 void Main::formatLinkStyleParabel()
3048 VymModel *m=currentModel();
3051 m->setMapLinkStyle("StyleParabel");
3052 actionFormatLinkStyleParabel->setChecked(true);
3056 void Main::formatLinkStylePolyLine()
3058 VymModel *m=currentModel();
3061 m->setMapLinkStyle("StylePolyLine");
3062 actionFormatLinkStylePolyLine->setChecked(true);
3066 void Main::formatLinkStylePolyParabel()
3068 VymModel *m=currentModel();
3071 m->setMapLinkStyle("StylePolyParabel");
3072 actionFormatLinkStylePolyParabel->setChecked(true);
3076 void Main::formatSelectBackColor()
3078 VymModel *m=currentModel();
3079 if (m) m->selectMapBackgroundColor();
3082 void Main::formatSelectBackImage()
3084 VymModel *m=currentModel();
3086 m->selectMapBackgroundImage();
3089 void Main::formatSelectLinkColor()
3091 VymModel *m=currentModel();
3094 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3095 m->setMapDefLinkColor( col );
3099 void Main::formatSelectSelectionColor()
3101 VymModel *m=currentModel();
3104 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3105 m->setSelectionColor (col);
3110 void Main::formatToggleLinkColorHint()
3112 VymModel *m=currentModel();
3113 if (m) m->toggleMapLinkColorHint();
3117 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3119 VymModel *m=currentModel();
3121 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3124 void Main::viewZoomReset()
3126 MapEditor *me=currentMapEditor();
3127 if (me) me->setZoomFactorTarget (1);
3130 void Main::viewZoomIn()
3132 MapEditor *me=currentMapEditor();
3133 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3136 void Main::viewZoomOut()
3138 MapEditor *me=currentMapEditor();
3139 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3142 void Main::viewCenter()
3144 VymModel *m=currentModel();
3145 if (m) m->emitShowSelection();
3148 void Main::networkStartServer()
3150 VymModel *m=currentModel();
3151 if (m) m->newServer();
3154 void Main::networkConnect()
3156 VymModel *m=currentModel();
3157 if (m) m->connectToServer();
3160 bool Main::settingsPDF()
3162 // Default browser is set in constructor
3164 QString text = QInputDialog::getText(
3165 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3166 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3168 settings.setValue ("/mainwindow/readerPDF",text);
3173 bool Main::settingsURL()
3175 // Default browser is set in constructor
3177 QString text = QInputDialog::getText(
3178 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3179 settings.value("/mainwindow/readerURL").toString()
3182 settings.setValue ("/mainwindow/readerURL",text);
3186 void Main::settingsMacroDir()
3188 QDir defdir(vymBaseDir.path() + "/macros");
3189 if (!defdir.exists())
3191 QDir dir=QFileDialog::getExistingDirectory (
3193 tr ("Directory with vym macros:"),
3194 settings.value ("/macros/macroDir",defdir.path()).toString()
3197 settings.setValue ("/macros/macroDir",dir.absolutePath());
3200 void Main::settingsUndoLevels()
3203 int i = QInputDialog::getInteger(
3205 tr("QInputDialog::getInteger()"),
3206 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3209 settings.setValue ("/mapeditor/stepsTotal",i);
3210 QMessageBox::information( this, tr( "VYM -Information:" ),
3211 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3215 void Main::settingsAutosaveToggle()
3217 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3220 void Main::settingsAutosaveTime()
3223 int i = QInputDialog::getInteger(
3225 tr("QInputDialog::getInteger()"),
3226 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3228 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3231 void Main::settingsWriteBackupFileToggle()
3233 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3236 void Main::settingsToggleAnimation()
3238 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3241 void Main::settingsToggleDelKey()
3243 if (actionSettingsUseDelKey->isOn())
3245 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3248 actionDelete->setAccel (QKeySequence (""));
3252 void Main::windowToggleNoteEditor()
3254 if (textEditor->isVisible() )
3255 windowHideNoteEditor();
3257 windowShowNoteEditor();
3260 void Main::windowToggleHistory()
3262 if (historyWindow->isVisible())
3263 historyWindow->hide();
3265 historyWindow->show();
3269 void Main::windowToggleProperty()
3271 if (branchPropertyWindow->isVisible())
3272 branchPropertyWindow->hide();
3274 branchPropertyWindow->show();
3275 branchPropertyWindow->setModel (currentModel() );
3278 void Main::windowToggleAntiAlias()
3280 bool b=actionViewToggleAntiAlias->isOn();
3282 for (int i=0;i<vymViews.count();i++)
3284 me=vymViews.at(i)->getMapEditor();
3285 if (me) me->setAntiAlias(b);
3290 bool Main::isAliased()
3292 return actionViewToggleAntiAlias->isOn();
3295 bool Main::hasSmoothPixmapTransform()
3297 return actionViewToggleSmoothPixmapTransform->isOn();
3300 void Main::windowToggleSmoothPixmap()
3302 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3304 for (int i=0;i<vymViews.count();i++)
3307 me=vymViews.at(i)->getMapEditor();
3308 if (me) me->setSmoothPixmap(b);
3312 void Main::updateHistory(SimpleSettings &undoSet)
3314 historyWindow->update (undoSet);
3317 void Main::updateNoteFlag()
3319 // this slot is connected to TextEditor::textHasChanged()
3321 VymModel *m=currentModel();
3322 if (m) m->updateNoteFlag();
3325 void Main::updateNoteEditor(QModelIndex index )
3327 cout << QObject::sender();
3328 QObject *obj=QObject::sender();
3329 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3330 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3331 //cout << "Main::updateNoteEditor model="<<sender();
3332 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3333 textEditor->setNote (ti->getNoteObj() );
3336 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3338 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3340 if (model && model==currentModel() )
3344 if (!oldsel.indexes().isEmpty() )
3346 ti=model->getItem(oldsel.indexes().first());
3348 // Don't update note if both treeItem and textEditor are empty
3349 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3350 // ti->setNoteObj (textEditor->getNoteObj(),false );
3352 if (!newsel.indexes().isEmpty() )
3354 ti=model->getItem(newsel.indexes().first());
3355 if (!ti->hasEmptyNote() )
3356 textEditor->setNote(ti->getNoteObj() );
3358 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3360 // Show URL and link in statusbar
3362 QString s=ti->getURL();
3363 if (!s.isEmpty() ) status+="URL: "+s+" ";
3365 if (!s.isEmpty() ) status+="Link: "+s;
3366 if (!status.isEmpty() ) statusMessage (status);
3369 textEditor->setInactive();
3375 void Main::updateActions()
3377 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3378 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3379 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3380 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3382 VymModel *m =currentModel();
3386 actionFilePrint->setEnabled (true);
3388 // Link style in context menu
3389 switch (m->getMapLinkStyle())
3391 case LinkableMapObj::Line:
3392 actionFormatLinkStyleLine->setChecked(true);
3394 case LinkableMapObj::Parabel:
3395 actionFormatLinkStyleParabel->setChecked(true);
3397 case LinkableMapObj::PolyLine:
3398 actionFormatLinkStylePolyLine->setChecked(true);
3400 case LinkableMapObj::PolyParabel:
3401 actionFormatLinkStylePolyParabel->setChecked(true);
3408 QPixmap pix( 16, 16 );
3409 pix.fill( m->getMapBackgroundColor() );
3410 actionFormatBackColor->setIconSet( pix );
3411 pix.fill( m->getSelectionColor() );
3412 actionFormatSelectionColor->setIconSet( pix );
3413 pix.fill( m->getMapDefLinkColor() );
3414 actionFormatLinkColor->setIconSet( pix );
3417 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3420 // Expanding/collapsing
3421 actionExpandAll->setEnabled (true);
3422 actionExpandOneLevel->setEnabled (true);
3423 actionCollapseOneLevel->setEnabled (true);
3427 actionFilePrint->setEnabled (false);
3429 // Expanding/collapsing
3430 actionExpandAll->setEnabled (false);
3431 actionExpandOneLevel->setEnabled (false);
3432 actionCollapseOneLevel->setEnabled (false);
3435 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3436 actionFormatLinkColorHint->setChecked(true);
3438 actionFormatLinkColorHint->setChecked(false);
3441 if (m && m->hasChanged() )
3442 actionFileSave->setEnabled( true);
3444 actionFileSave->setEnabled( false);
3445 if (m && m->isUndoAvailable())
3446 actionUndo->setEnabled( true);
3448 actionUndo->setEnabled( false);
3450 if (m && m->isRedoAvailable())
3451 actionRedo->setEnabled( true);
3453 actionRedo->setEnabled( false);
3457 TreeItem *selti=m->getSelectedItem();
3458 BranchItem *selbi=m->getSelectedBranch();
3461 if (selbi || selti->getType()==TreeItem::Image)
3463 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3464 actionFormatHideLinkUnselected->setEnabled (true);
3469 // Take care of xlinks
3470 branchXLinksContextMenuEdit->clear();
3471 if (selbi->xlinkCount()>0)
3475 for (int i=0; i<selbi->xlinkCount();++i)
3477 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3481 if (s.length()>xLinkMenuWidth)
3482 s=s.left(xLinkMenuWidth)+"...";
3483 branchXLinksContextMenuEdit->addAction (s);
3488 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3491 actionToggleScroll->setEnabled (true);
3492 if ( selbi->isScrolled() )
3493 actionToggleScroll->setChecked(true);
3495 actionToggleScroll->setChecked(false);
3497 if ( selti->getURL().isEmpty() )
3499 actionOpenURL->setEnabled (false);
3500 actionOpenURLTab->setEnabled (false);
3504 actionOpenURL->setEnabled (true);
3505 actionOpenURLTab->setEnabled (true);
3507 if ( selti->getVymLink().isEmpty() )
3509 actionOpenVymLink->setEnabled (false);
3510 actionDeleteVymLink->setEnabled (false);
3513 actionOpenVymLink->setEnabled (true);
3514 actionDeleteVymLink->setEnabled (true);
3517 if (selbi->canMoveUp())
3518 actionMoveUp->setEnabled (true);
3520 actionMoveUp->setEnabled (false);
3521 if (selbi->canMoveDown())
3522 actionMoveDown->setEnabled (true);
3524 actionMoveDown->setEnabled (false);
3526 actionSortChildren->setEnabled (true);
3528 actionToggleHideExport->setEnabled (true);
3529 actionToggleHideExport->setChecked (selbi->hideInExport() );
3531 actionCopy->setEnabled (true);
3532 actionCut->setEnabled (true);
3533 if (!clipboardEmpty)
3534 actionPaste->setEnabled (true);
3536 actionPaste->setEnabled (false);
3537 for (int i=0; i<actionListBranches.size(); ++i)
3538 actionListBranches.at(i)->setEnabled(true);
3539 actionDelete->setEnabled (true);
3541 if ( selti->getType()==TreeItem::Image)
3543 actionOpenURL->setEnabled (false);
3544 actionOpenVymLink->setEnabled (false);
3545 actionDeleteVymLink->setEnabled (false);
3546 actionToggleHideExport->setEnabled (true);
3547 actionToggleHideExport->setChecked (selti->hideInExport() );
3550 actionCopy->setEnabled (true);
3551 actionCut->setEnabled (true);
3552 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3553 for (int i=0; i<actionListBranches.size(); ++i)
3554 actionListBranches.at(i)->setEnabled(false);
3555 actionDelete->setEnabled (true);
3556 actionMoveUp->setEnabled (false);
3557 actionMoveDown->setEnabled (false);
3562 actionCopy->setEnabled (false);
3563 actionCut->setEnabled (false);
3564 actionPaste->setEnabled (false);
3565 for (int i=0; i<actionListBranches.size(); ++i)
3566 actionListBranches.at(i)->setEnabled(false);
3568 actionToggleScroll->setEnabled (false);
3569 actionOpenURL->setEnabled (false);
3570 actionOpenVymLink->setEnabled (false);
3571 actionDeleteVymLink->setEnabled (false);
3572 actionHeading2URL->setEnabled (false);
3573 actionDelete->setEnabled (false);
3574 actionMoveUp->setEnabled (false);
3575 actionMoveDown->setEnabled (false);
3576 actionFormatHideLinkUnselected->setEnabled (false);
3577 actionSortChildren->setEnabled (false);
3578 actionToggleHideExport->setEnabled (false);
3583 Main::ModMode Main::getModMode()
3585 if (actionModModeColor->isOn()) return ModModeColor;
3586 if (actionModModeCopy->isOn()) return ModModeCopy;
3587 if (actionModModeXLink->isOn()) return ModModeXLink;
3591 bool Main::autoEditNewBranch()
3593 return actionSettingsAutoEditNewBranch->isOn();
3596 bool Main::autoSelectNewBranch()
3598 return actionSettingsAutoSelectNewBranch->isOn();
3601 void Main::windowShowNoteEditor()
3603 textEditor->setShowWithMain(true);
3605 actionViewToggleNoteEditor->setChecked (true);
3608 void Main::windowHideNoteEditor()
3610 textEditor->setShowWithMain(false);
3612 actionViewToggleNoteEditor->setChecked (false);
3615 void Main::setScript (const QString &script)
3617 scriptEditor->setScript (script);
3620 void Main::runScript (const QString &script)
3622 VymModel *m=currentModel();
3623 if (m) m->runScript (script);
3626 void Main::runScriptEverywhere (const QString &script)
3629 for (int i=0;i<=tabWidget->count() -1;i++)
3631 me=(MapEditor*)tabWidget->page(i);
3632 if (me) me->getModel()->runScript (script);
3636 void Main::windowNextEditor()
3638 if (tabWidget->currentIndex() < tabWidget->count())
3639 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3642 void Main::windowPreviousEditor()
3644 if (tabWidget->currentIndex() >0)
3645 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3648 void Main::standardFlagChanged()
3652 if ( actionSettingsUseFlagGroups->isOn() )
3653 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3655 currentModel()->toggleStandardFlag(sender()->name());
3660 void Main::testFunction1()
3662 if (!currentMapEditor()) return;
3663 currentMapEditor()->testFunction1();
3666 VymModel *m=currentModel();
3670 QString text = QInputDialog::getText(
3671 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3672 m->getSortFilter(), &ok, NULL);
3674 // user entered something and pressed OK
3675 m->setSortFilter (text);
3679 void Main::testFunction2()
3681 if (!currentMapEditor()) return;
3682 currentMapEditor()->testFunction2();
3685 void Main::testCommand()
3687 if (!currentMapEditor()) return;
3688 scriptEditor->show();
3691 QString com = QInputDialog::getText(
3692 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3693 if (ok) currentMapEditor()->parseAtom(com);
3697 void Main::helpDoc()
3699 QString locale = QLocale::system().name();
3701 if (locale.left(2)=="es")
3702 docname="vym_es.pdf";
3706 QStringList searchList;
3708 #if defined(Q_OS_MACX)
3709 searchList << "./vym.app/Contents/Resources/doc";
3710 #elif defined(Q_OS_WIN32)
3711 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3713 #if defined(VYM_DOCDIR)
3714 searchList << VYM_DOCDIR;
3716 // default path in SUSE LINUX
3717 searchList << "/usr/share/doc/packages/vym";
3720 searchList << "doc"; // relative path for easy testing in tarball
3721 searchList << "doc/tex"; // Easy testing working on vym.tex
3722 searchList << "/usr/share/doc/vym"; // Debian
3723 searchList << "/usr/share/doc/packages";// Knoppix
3727 for (int i=0; i<searchList.count(); ++i)
3729 docfile.setFileName(searchList.at(i)+"/"+docname);
3730 if (docfile.exists())
3739 QMessageBox::critical(0,
3740 tr("Critcal error"),
3741 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3746 Process *pdfProc = new Process();
3747 args << QDir::toNativeSeparators(docfile.fileName());
3749 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3752 QMessageBox::warning(0,
3754 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3755 tr("Please use Settings->")+tr("Set application to open PDF files"));
3762 void Main::helpDemo()
3764 QStringList filters;
3765 filters <<"VYM example map (*.vym)";
3766 QFileDialog *fd=new QFileDialog( this);
3767 #if defined(Q_OS_MACX)
3768 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3770 // default path in SUSE LINUX
3771 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3774 fd->setFileMode (QFileDialog::ExistingFiles);
3775 fd->setFilters (filters);
3776 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3780 if ( fd->exec() == QDialog::Accepted )
3782 lastFileDir=fd->directory().path();
3783 QStringList flist = fd->selectedFiles();
3784 QStringList::Iterator it = flist.begin();
3785 while( it != flist.end() )
3788 fileLoad(*it, NewMap);
3796 void Main::helpAbout()
3799 ad.setName ("aboutwindow");
3800 ad.setMinimumSize(500,500);
3801 ad.resize (QSize (500,500));
3805 void Main::helpAboutQT()
3807 QMessageBox::aboutQt( this, "Qt Application Example" );
3810 void Main::callMacro ()
3812 QAction *action = qobject_cast<QAction *>(sender());
3816 i=action->data().toInt();
3817 QString mDir (settings.value ("macros/macroDir").toString() );
3819 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3821 if ( !f.open( QIODevice::ReadOnly ) )
3823 QMessageBox::warning(0,
3825 tr("Couldn't find a macro at %1.\n").arg(fn)+
3826 tr("Please use Settings->")+tr("Set directory for vym macros"));
3830 QTextStream ts( &f );
3831 QString macro= ts.read();
3833 if (! macro.isEmpty())
3835 VymModel *m=currentModel();
3836 if (m) m->runScript(macro);