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 Bugzilla","Edit menu" ), this);
809 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
810 a->setEnabled (false);
811 actionListBranches.append(a);
812 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
813 a->setShortcutContext (Qt::WindowShortcut);
815 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
816 actionGetBugzillaData=a;
818 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
819 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
820 a->setEnabled (false);
821 actionListBranches.append(a);
822 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
825 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
826 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
828 a->setEnabled (false);
829 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
832 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
833 a->setStatusTip ( tr( "Open all vym links in subtree" ));
834 a->setEnabled (false);
835 actionListBranches.append(a);
836 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
837 actionOpenMultipleVymLinks=a;
840 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
841 a->setEnabled (false);
842 a->setStatusTip ( tr( "Edit link to another vym map" ));
843 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
844 actionListBranches.append(a);
847 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
848 a->setStatusTip ( tr( "Delete link to another vym map" ));
849 a->setEnabled (false);
850 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
851 actionDeleteVymLink=a;
853 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
854 a->setStatusTip ( tr( "Hide object in exports" ) );
855 a->setShortcut (Qt::Key_H );
856 a->setToggleAction(true);
858 a->setEnabled (false);
859 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
860 actionToggleHideExport=a;
862 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
863 a->setStatusTip ( tr( "Add timestamp" ));
864 a->setEnabled (false);
865 actionListBranches.append(a);
866 a->setShortcut ( Qt::Key_T ); // Add timestamp
867 a->setShortcutContext (Qt::WindowShortcut);
869 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
870 actionAddTimestamp=a;
872 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
873 a->setStatusTip ( tr( "Edit Map Info" ));
874 a->setEnabled (true);
875 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
878 // Import at selection (adding to selection)
879 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
880 a->setStatusTip (tr( "Add map at selection" ));
881 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
882 a->setEnabled (false);
883 actionListBranches.append(a);
886 // Import at selection (replacing selection)
887 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
888 a->setStatusTip (tr( "Replace selection with map" ));
889 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
890 a->setEnabled (false);
891 actionListBranches.append(a);
892 actionImportReplace=a;
895 a = new QAction( tr( "Save selection","Edit menu" ), this);
896 a->setStatusTip (tr( "Save selection" ));
897 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
898 a->setEnabled (false);
899 actionListBranches.append(a);
902 // Only remove branch, not its children
903 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
904 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
905 a->setShortcut (Qt::ALT + Qt::Key_Delete );
906 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
907 a->setEnabled (false);
909 actionListBranches.append(a);
910 actionDeleteKeepChildren=a;
912 // Only remove children of a branch
913 a = new QAction( tr( "Remove children","Edit menu" ), this);
914 a->setStatusTip (tr( "Remove children of branch" ));
915 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
916 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
917 a->setEnabled (false);
918 actionListBranches.append(a);
919 actionDeleteChildren=a;
921 a = new QAction( tr( "Add Image...","Edit menu" ), this);
922 a->setStatusTip (tr( "Add Image" ));
923 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
926 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
927 a->setStatusTip (tr( "Set properties for selection" ));
928 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
929 a->setShortcutContext (Qt::WindowShortcut);
930 a->setToggleAction (true);
932 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
933 actionViewTogglePropertyWindow=a;
937 void Main::setupFormatActions()
939 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
941 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
942 tb->setObjectName ("formatTB");
945 pix.fill (Qt::black);
946 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
947 a->setStatusTip ( tr( "Set Color" ));
948 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
950 formatMenu->addAction (a);
952 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
953 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
954 a->setShortcut (Qt::CTRL + Qt::Key_K );
955 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
956 a->setEnabled (false);
958 formatMenu->addAction (a);
959 actionListBranches.append(a);
960 actionFormatPickColor=a;
962 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
963 a->setStatusTip ( tr( "Color branch" ) );
964 a->setShortcut (Qt::CTRL + Qt::Key_B);
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
966 a->setEnabled (false);
968 formatMenu->addAction (a);
969 actionListBranches.append(a);
970 actionFormatColorSubtree=a;
972 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
973 a->setStatusTip ( tr( "Color Subtree" ));
974 //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree
975 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
976 a->setEnabled (false);
977 formatMenu->addAction (a);
979 actionListBranches.append(a);
980 actionFormatColorSubtree=a;
982 formatMenu->addSeparator();
983 actionGroupFormatLinkStyles=new QActionGroup ( this);
984 actionGroupFormatLinkStyles->setExclusive (true);
985 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
986 a->setStatusTip (tr( "Line" ));
987 a->setToggleAction(true);
988 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
989 formatMenu->addAction (a);
990 actionFormatLinkStyleLine=a;
991 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
992 a->setStatusTip (tr( "Line" ));
993 a->setToggleAction(true);
994 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
995 formatMenu->addAction (a);
996 actionFormatLinkStyleParabel=a;
997 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
998 a->setStatusTip (tr( "PolyLine" ));
999 a->setToggleAction(true);
1000 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1001 formatMenu->addAction (a);
1002 actionFormatLinkStylePolyLine=a;
1003 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1004 a->setStatusTip (tr( "PolyParabel" ) );
1005 a->setToggleAction(true);
1006 a->setChecked (true);
1007 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1008 formatMenu->addAction (a);
1009 actionFormatLinkStylePolyParabel=a;
1011 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1012 a->setStatusTip (tr( "Hide link" ));
1013 a->setToggleAction(true);
1014 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1015 actionFormatHideLinkUnselected=a;
1017 formatMenu->addSeparator();
1018 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1019 a->setStatusTip (tr( "Use same color for links and headings" ));
1020 a->setToggleAction(true);
1021 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1022 formatMenu->addAction (a);
1023 actionFormatLinkColorHint=a;
1025 pix.fill (Qt::white);
1026 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1027 a->setStatusTip (tr( "Set Link Color" ));
1028 formatMenu->addAction (a);
1029 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1030 actionFormatLinkColor=a;
1032 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1033 a->setStatusTip (tr( "Set Selection Color" ));
1034 formatMenu->addAction (a);
1035 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1036 actionFormatSelectionColor=a;
1038 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1039 a->setStatusTip (tr( "Set Background Color" ));
1040 formatMenu->addAction (a);
1041 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1042 actionFormatBackColor=a;
1044 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1045 a->setStatusTip (tr( "Set Background image" ));
1046 formatMenu->addAction (a);
1047 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1048 actionFormatBackImage=a;
1052 void Main::setupViewActions()
1054 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1055 tb->setLabel( "View Actions" );
1056 tb->setObjectName ("viewTB");
1057 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1059 Switchboard switchboard; //FIXME-2 testing...
1062 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1063 a->setStatusTip ( tr( "Zoom reset" ) );
1064 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1065 switchboard.addConnection(a,"CTRL+0");
1067 viewMenu->addAction (a);
1068 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1070 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1071 a->setStatusTip (tr( "Zoom in" ));
1072 switchboard.addConnection(a,"CTRL++");
1074 viewMenu->addAction (a);
1075 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1077 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1078 a->setStatusTip (tr( "Zoom out" ));
1079 switchboard.addConnection(a,"CTRL+-");
1081 viewMenu->addAction (a);
1082 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1084 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1085 a->setStatusTip (tr( "Show selection" ));
1086 switchboard.addConnection(a,".");
1088 viewMenu->addAction (a);
1089 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1091 viewMenu->addSeparator();
1093 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1094 a->setStatusTip ( tr( "Show Note Editor" ));
1095 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1096 a->setToggleAction(true);
1098 viewMenu->addAction (a);
1099 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1100 actionViewToggleNoteEditor=a;
1102 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1103 a->setStatusTip ( tr( "Show History Window" ));
1104 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1105 a->setToggleAction(true);
1107 viewMenu->addAction (a);
1108 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1109 actionViewToggleHistoryWindow=a;
1111 viewMenu->addAction (actionViewTogglePropertyWindow);
1113 viewMenu->addSeparator();
1115 a = new QAction(tr( "Antialiasing","View action" ),this );
1116 a->setStatusTip ( tr( "Antialiasing" ));
1117 a->setToggleAction(true);
1118 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1119 viewMenu->addAction (a);
1120 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1121 actionViewToggleAntiAlias=a;
1123 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1124 a->setStatusTip (a->text());
1125 a->setToggleAction(true);
1126 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1127 viewMenu->addAction (a);
1128 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1129 actionViewToggleSmoothPixmapTransform=a;
1131 a = new QAction(tr( "Next Map","View action" ), this);
1132 a->setStatusTip (a->text());
1133 a->setShortcut (Qt::ALT + Qt::Key_N );
1134 viewMenu->addAction (a);
1135 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1137 a = new QAction (tr( "Previous Map","View action" ), this );
1138 a->setStatusTip (a->text());
1139 a->setShortcut (Qt::ALT + Qt::Key_P );
1140 viewMenu->addAction (a);
1141 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1143 if (debug) switchboard.print();
1147 void Main::setupModeActions()
1149 //QPopupMenu *menu = new QPopupMenu( this );
1150 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1152 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1153 tb->setObjectName ("modesTB");
1155 actionGroupModModes=new QActionGroup ( this);
1156 actionGroupModModes->setExclusive (true);
1157 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1158 a->setShortcut (Qt::Key_J);
1159 a->setStatusTip ( tr( "Use modifier to color branches" ));
1160 a->setToggleAction(true);
1162 a->setChecked(true);
1163 actionModModeColor=a;
1165 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1166 a->setShortcut( Qt::Key_K);
1167 a->setStatusTip( tr( "Use modifier to copy" ));
1168 a->setToggleAction(true);
1170 actionModModeCopy=a;
1172 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1173 a->setShortcut (Qt::Key_L);
1174 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1175 a->setToggleAction(true);
1177 actionModModeXLink=a;
1181 void Main::setupFlagActions()
1183 // Create System Flags
1186 Flag *flag=new Flag;;
1187 flag->setVisible(true);
1189 flag->load(QPixmap(flagsPath+"flag-note.png"));
1190 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1192 flag->load(QPixmap(flagsPath+"flag-url.png"));
1193 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1195 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1196 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1198 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1199 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1201 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1202 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1204 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1205 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1207 // Create Standard Flags
1208 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1209 tb->setObjectName ("standardFlagTB");
1210 standardFlagsMaster->setToolBar (tb);
1212 flag->load(flagsPath+"flag-exclamationmark.png");
1213 flag->setGroup("standard-mark");
1214 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1216 flag->load(flagsPath+"flag-questionmark.png");
1217 flag->setGroup("standard-mark");
1218 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1220 flag->load(flagsPath+"flag-hook-green.png");
1221 flag->setGroup("standard-status");
1222 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1224 flag->load(flagsPath+"flag-wip.png");
1225 flag->setGroup("standard-status");
1226 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1228 flag->load(flagsPath+"flag-cross-red.png");
1229 flag->setGroup("standard-status");
1230 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1233 flag->load(flagsPath+"flag-stopsign.png");
1234 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1236 flag->load(flagsPath+"flag-smiley-good.png");
1237 flag->setGroup("standard-smiley");
1238 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1240 flag->load(flagsPath+"flag-smiley-sad.png");
1241 flag->setGroup("standard-smiley");
1242 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1244 flag->load(flagsPath+"flag-smiley-omg.png");
1245 flag->setGroup("standard-smiley");
1246 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1247 // Original omg.png (in KDE emoticons)
1250 flag->load(flagsPath+"flag-kalarm.png");
1251 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1253 flag->load(flagsPath+"flag-phone.png");
1254 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1256 flag->load(flagsPath+"flag-lamp.png");
1257 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1259 flag->load(flagsPath+"flag-arrow-up.png");
1260 flag->setGroup("standard-arrow");
1261 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1263 flag->load(flagsPath+"flag-arrow-down.png");
1264 flag->setGroup("standard-arrow");
1265 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1267 flag->load(flagsPath+"flag-arrow-2up.png");
1268 flag->setGroup("standard-arrow");
1269 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1271 flag->load(flagsPath+"flag-arrow-2down.png");
1272 flag->setGroup("standard-arrow");
1273 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1276 flag->load(flagsPath+"flag-thumb-up.png");
1277 flag->setGroup("standard-thumb");
1278 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1280 flag->load(flagsPath+"flag-thumb-down.png");
1281 flag->setGroup("standard-thumb");
1282 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1285 flag->load(flagsPath+"flag-rose.png");
1286 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1288 flag->load(flagsPath+"flag-heart.png");
1289 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1291 flag->load(flagsPath+"flag-present.png");
1292 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1294 flag->load(flagsPath+"flag-flash.png");
1295 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1297 // Original: xsldbg_output.png
1298 flag->load(flagsPath+"flag-info.png");
1299 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1301 // Original khelpcenter.png
1302 flag->load(flagsPath+"flag-lifebelt.png");
1303 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1306 flag->setVisible(false);
1307 flag->load(flagsPath+"freemind/warning.png");
1308 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1310 for (int i=1; i<8; i++)
1312 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1313 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1316 flag->load(flagsPath+"freemind/back.png");
1317 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1319 flag->load(flagsPath+"freemind/forward.png");
1320 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1322 flag->load(flagsPath+"freemind/attach.png");
1323 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1325 flag->load(flagsPath+"freemind/clanbomber.png");
1326 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1328 flag->load(flagsPath+"freemind/desktopnew.png");
1329 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1331 flag->load(flagsPath+"freemind/flag.png");
1332 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1335 flag->load(flagsPath+"freemind/gohome.png");
1336 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1339 flag->load(flagsPath+"freemind/kaddressbook.png");
1340 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1342 flag->load(flagsPath+"freemind/knotify.png");
1343 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1345 flag->load(flagsPath+"freemind/korn.png");
1346 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1348 flag->load(flagsPath+"freemind/mail.png");
1349 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1351 flag->load(flagsPath+"freemind/password.png");
1352 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1354 flag->load(flagsPath+"freemind/pencil.png");
1355 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1357 flag->load(flagsPath+"freemind/stop.png");
1358 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1360 flag->load(flagsPath+"freemind/wizard.png");
1361 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1363 flag->load(flagsPath+"freemind/xmag.png");
1364 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1366 flag->load(flagsPath+"freemind/bell.png");
1367 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1369 flag->load(flagsPath+"freemind/bookmark.png");
1370 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1372 flag->load(flagsPath+"freemind/penguin.png");
1373 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1375 flag->load(flagsPath+"freemind/licq.png");
1376 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1379 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1381 flag->setName(name);
1382 flag->setToolTip (tooltip);
1386 a=new QAction (flag->getPixmap(),name,this);
1389 flag->setAction (a);
1390 a->setVisible (flag->isVisible());
1391 a->setCheckable(true);
1392 a->setObjectName(name);
1393 a->setToolTip(tooltip);
1394 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1395 standardFlagsMaster->addFlag (flag);
1399 systemFlagsMaster->addFlag (flag);
1404 void Main::setupNetworkActions()
1406 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1408 QMenu *netMenu = menuBar()->addMenu( "Network" );
1412 a = new QAction( "Start TCPserver for MapEditor",this);
1413 //a->setStatusTip ( "Set application to open pdf files"));
1414 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1415 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1416 netMenu->addAction (a);
1418 a = new QAction( "Connect MapEditor to server",this);
1419 //a->setStatusTip ( "Set application to open pdf files"));
1420 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1421 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1422 netMenu->addAction (a);
1426 void Main::setupSettingsActions()
1428 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1432 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1433 a->setStatusTip ( tr( "Set application to open pdf files"));
1434 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1435 settingsMenu->addAction (a);
1437 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1438 a->setStatusTip( tr( "Set application to open external links"));
1439 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1440 settingsMenu->addAction (a);
1442 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1443 a->setStatusTip( tr( "Set path for macros"));
1444 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1445 settingsMenu->addAction (a);
1447 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1448 a->setStatusTip( tr( "Set number of undo levels"));
1449 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1450 settingsMenu->addAction (a);
1452 settingsMenu->addSeparator();
1454 a = new QAction( tr( "Autosave","Settings action"), this);
1455 a->setStatusTip( tr( "Autosave"));
1456 a->setToggleAction(true);
1457 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1458 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1459 settingsMenu->addAction (a);
1460 actionSettingsAutosaveToggle=a;
1462 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1463 a->setStatusTip( tr( "Autosave time"));
1464 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1465 settingsMenu->addAction (a);
1466 actionSettingsAutosaveTime=a;
1468 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1469 a->setStatusTip( tr( "Write backup file on save"));
1470 a->setToggleAction(true);
1471 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1472 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1473 settingsMenu->addAction (a);
1474 actionSettingsWriteBackupFile=a;
1476 settingsMenu->addSeparator();
1478 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1479 a->setStatusTip( tr( "Edit branch after adding it" ));
1480 a->setToggleAction(true);
1481 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1482 settingsMenu->addAction (a);
1483 actionSettingsAutoEditNewBranch=a;
1485 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1486 a->setStatusTip( tr( "Select branch after adding it" ));
1487 a->setToggleAction(true);
1488 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1489 settingsMenu->addAction (a);
1490 actionSettingsAutoSelectNewBranch=a;
1492 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1493 a->setStatusTip( tr( "Select heading before editing" ));
1494 a->setToggleAction(true);
1495 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1496 settingsMenu->addAction (a);
1497 actionSettingsAutoSelectText=a;
1499 a= new QAction( tr( "Delete key","Settings action" ), this);
1500 a->setStatusTip( tr( "Delete key for deleting branches" ));
1501 a->setToggleAction(true);
1502 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1503 settingsMenu->addAction (a);
1504 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1505 actionSettingsUseDelKey=a;
1507 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1508 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1509 a->setToggleAction(true);
1510 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1511 settingsMenu->addAction (a);
1512 actionSettingsUseFlagGroups=a;
1514 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1515 a->setStatusTip( tr( "Use hide flag during exports " ));
1516 a->setToggleAction(true);
1517 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1518 settingsMenu->addAction (a);
1519 actionSettingsUseHideExport=a;
1521 a = new QAction( tr( "Animation","Settings action"), this);
1522 a->setStatusTip( tr( "Animation"));
1523 a->setToggleAction(true);
1524 a->setChecked (settings.value("/animation/use",true).toBool() );
1525 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1526 settingsMenu->addAction (a);
1527 actionSettingsUseAnimation=a;
1531 void Main::setupTestActions()
1533 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1536 a = new QAction( "Test function 1" , this);
1537 a->setStatusTip( "Call test function 1" );
1538 a->setShortcut (Qt::CTRL + Qt::Key_T); // Test function 1 //FIXME-2 originally: color subtree
1539 testMenu->addAction (a);
1540 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1542 a = new QAction( "Test function 2" , this);
1543 a->setStatusTip( "Call test function 2" );
1544 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 2
1545 testMenu->addAction (a);
1546 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1548 a = new QAction( "Command" , this);
1549 a->setStatusTip( "Enter command to call in editor" );
1550 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1551 testMenu->addAction (a);
1555 void Main::setupHelpActions()
1557 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1560 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1561 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1562 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1563 helpMenu->addAction (a);
1565 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1566 a->setStatusTip( tr( "Open VYM example maps " ));
1567 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1568 helpMenu->addAction (a);
1570 a = new QAction( tr( "About VYM","Help action" ), this);
1571 a->setStatusTip( tr( "About VYM")+vymName);
1572 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1573 helpMenu->addAction (a);
1575 a = new QAction( tr( "About QT","Help action" ), this);
1576 a->setStatusTip( tr( "Information about QT toolkit" ));
1577 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1578 helpMenu->addAction (a);
1582 void Main::setupContextMenus()
1586 // Context Menu for branch or mapcenter
1587 branchContextMenu =new QMenu (this);
1588 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1589 branchContextMenu->addSeparator();
1592 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1593 branchAddContextMenu->addAction (actionPaste );
1594 branchAddContextMenu->addAction ( actionAddMapCenter );
1595 branchAddContextMenu->addAction ( actionAddBranch );
1596 branchAddContextMenu->addAction ( actionAddBranchBefore );
1597 branchAddContextMenu->addAction ( actionAddBranchAbove);
1598 branchAddContextMenu->addAction ( actionAddBranchBelow );
1599 branchAddContextMenu->addSeparator();
1600 branchAddContextMenu->addAction ( actionImportAdd );
1601 branchAddContextMenu->addAction ( actionImportReplace );
1604 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1605 branchRemoveContextMenu->addAction (actionCut);
1606 branchRemoveContextMenu->addAction ( actionDelete );
1607 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1608 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1611 actionSaveBranch->addTo( branchContextMenu );
1612 actionFileNewCopy->addTo (branchContextMenu );
1613 actionDetach->addTo (branchContextMenu );
1615 branchContextMenu->addSeparator();
1616 branchContextMenu->addAction ( actionLoadImage);
1617 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1618 branchContextMenu->addAction ( actionAddAttribute);
1620 // Submenu for Links (URLs, vymLinks)
1621 branchLinksContextMenu =new QMenu (this);
1623 branchContextMenu->addSeparator();
1624 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1625 branchLinksContextMenu->addAction ( actionOpenURL );
1626 branchLinksContextMenu->addAction ( actionOpenURLTab );
1627 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1628 branchLinksContextMenu->addAction ( actionURL );
1629 branchLinksContextMenu->addAction ( actionLocalURL );
1630 branchLinksContextMenu->addAction ( actionHeading2URL );
1631 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1632 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1634 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1635 branchLinksContextMenu->addAction ( actionFATE2URL );
1637 branchLinksContextMenu->addSeparator();
1638 branchLinksContextMenu->addAction ( actionOpenVymLink );
1639 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1640 branchLinksContextMenu->addAction ( actionVymLink );
1641 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1644 // Context Menu for XLinks in a branch menu
1645 // This will be populated "on demand" in MapEditor::updateActions
1646 branchContextMenu->addSeparator();
1647 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1648 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1651 // Context menu for floatimage
1652 floatimageContextMenu =new QMenu (this);
1653 a= new QAction (tr ("Save image","Context action"),this);
1654 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1655 floatimageContextMenu->addAction (a);
1657 floatimageContextMenu->addSeparator();
1658 actionCopy->addTo( floatimageContextMenu );
1659 actionCut->addTo( floatimageContextMenu );
1661 floatimageContextMenu->addSeparator();
1662 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1665 // Context menu for canvas
1666 canvasContextMenu =new QMenu (this);
1667 actionAddMapCenter->addTo( canvasContextMenu );
1668 actionMapInfo->addTo( canvasContextMenu );
1669 canvasContextMenu->insertSeparator();
1670 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1671 canvasContextMenu->insertSeparator();
1672 actionFormatLinkColorHint->addTo( canvasContextMenu );
1673 actionFormatLinkColor->addTo( canvasContextMenu );
1674 actionFormatSelectionColor->addTo( canvasContextMenu );
1675 actionFormatBackColor->addTo( canvasContextMenu );
1676 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1678 // Menu for last opened files
1680 for (int i = 0; i < MaxRecentFiles; ++i)
1682 recentFileActions[i] = new QAction(this);
1683 recentFileActions[i]->setVisible(false);
1684 fileLastMapsMenu->addAction(recentFileActions[i]);
1685 connect(recentFileActions[i], SIGNAL(triggered()),
1686 this, SLOT(fileLoadRecent()));
1688 setupRecentMapsMenu();
1691 void Main::setupRecentMapsMenu()
1693 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1695 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1697 for (int i = 0; i < numRecentFiles; ++i) {
1698 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1699 recentFileActions[i]->setText(text);
1700 recentFileActions[i]->setData(files[i]);
1701 recentFileActions[i]->setVisible(true);
1703 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1704 recentFileActions[j]->setVisible(false);
1707 void Main::setupMacros()
1709 for (int i = 0; i <= 11; i++)
1711 macroActions[i] = new QAction(this);
1712 macroActions[i]->setData(i);
1713 addAction (macroActions[i]);
1714 connect(macroActions[i], SIGNAL(triggered()),
1715 this, SLOT(callMacro()));
1717 macroActions[0]->setShortcut ( Qt::Key_F1 );
1718 macroActions[1]->setShortcut ( Qt::Key_F2 );
1719 macroActions[2]->setShortcut ( Qt::Key_F3 );
1720 macroActions[3]->setShortcut ( Qt::Key_F4 );
1721 macroActions[4]->setShortcut ( Qt::Key_F5 );
1722 macroActions[5]->setShortcut ( Qt::Key_F6 );
1723 macroActions[6]->setShortcut ( Qt::Key_F7 );
1724 macroActions[7]->setShortcut ( Qt::Key_F8 );
1725 macroActions[8]->setShortcut ( Qt::Key_F9 );
1726 macroActions[9]->setShortcut ( Qt::Key_F10 );
1727 macroActions[10]->setShortcut ( Qt::Key_F11 );
1728 macroActions[11]->setShortcut ( Qt::Key_F12 );
1731 void Main::hideEvent (QHideEvent * )
1733 if (!textEditor->isMinimized() ) textEditor->hide();
1736 void Main::showEvent (QShowEvent * )
1738 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1742 MapEditor* Main::currentMapEditor() const
1744 if ( tabWidget->currentPage())
1745 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1749 VymModel* Main::currentModel() const
1751 if ( tabWidget->currentPage())
1752 return vymViews.at(tabWidget->currentIndex())->getModel();
1757 void Main::editorChanged(QWidget *)
1759 // Unselect all possibly selected objects
1760 // (Important to update note editor)
1762 for (int i=0;i<=tabWidget->count() -1;i++)
1764 m= vymViews.at(i)->getModel();
1765 if (m) m->unselect();
1768 if (m) m->reselect();
1770 // Update actions to in menus and toolbars according to editor
1774 void Main::fileNew()
1776 VymModel *vm=new VymModel;
1778 /////////////////////////////////////
1779 // new ModelTest(vm, this); //FIXME-3
1780 /////////////////////////////////////
1782 VymView *vv=new VymView (vm);
1783 vymViews.append (vv);
1784 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1785 tabWidget->setCurrentIndex (vymViews.count() );
1788 // Create MapCenter for empty map
1792 // For the very first map we do not have flagrows yet...
1796 void Main::fileNewCopy()
1798 QString fn="unnamed";
1799 VymModel *srcModel=currentModel();
1804 VymModel *dstModel=vymViews.last()->getModel();
1805 dstModel->select("mc:");
1806 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1810 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1812 ErrorCode err=success;
1814 // fn is usually the archive, mapfile the file after uncompressing
1817 // Make fn absolute (needed for unzip)
1818 fn=QDir (fn).absPath();
1824 // Check, if map is already loaded
1826 while (i<=tabWidget->count() -1)
1828 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1830 // Already there, ask for confirmation
1831 QMessageBox mb( vymName,
1832 tr("The map %1\nis already opened."
1833 "Opening the same map in multiple editors may lead \n"
1834 "to confusion when finishing working with vym."
1835 "Do you want to").arg(fn),
1836 QMessageBox::Warning,
1837 QMessageBox::Yes | QMessageBox::Default,
1838 QMessageBox::Cancel | QMessageBox::Escape,
1839 QMessageBox::NoButton);
1840 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1841 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1844 case QMessageBox::Yes:
1845 // end loop and load anyway
1846 i=tabWidget->count();
1848 case QMessageBox::Cancel:
1858 int tabIndex=tabWidget->currentPageIndex();
1861 if ( !fn.isEmpty() )
1863 vm = currentModel();
1864 // Check first, if mapeditor exists
1865 // If it is not default AND we want a new map,
1866 // create a new mapeditor in a new tab
1867 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1870 VymView *vv=new VymView (vm);
1871 vymViews.append (vv);
1872 tabWidget->addTab (vv,fn);
1873 tabIndex=tabWidget->count()-1;
1874 tabWidget->setCurrentPage (tabIndex);
1878 // Check, if file exists (important for creating new files
1879 // from command line
1880 if (!QFile(fn).exists() )
1882 QMessageBox mb( vymName,
1883 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1884 QMessageBox::Question,
1886 QMessageBox::Cancel | QMessageBox::Default,
1887 QMessageBox::NoButton );
1889 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1890 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1893 case QMessageBox::Yes:
1895 currentMapEditor()->getModel()->setFilePath(fn);
1896 tabWidget->setTabText (tabIndex,
1897 currentMapEditor()->getModel()->getFileName() );
1898 statusBar()->message( "Created " + fn , statusbarTime );
1901 case QMessageBox::Cancel:
1902 // don't create new map
1903 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1910 //tabWidget->currentPage() won't be NULL here, because of above...
1911 tabWidget->setCurrentIndex (tabIndex);
1912 //FIXME-3 no me anymore... me->viewport()->setFocus();
1916 // Save existing filename in case we import
1917 QString fn_org=vm->getFilePath();
1919 // Finally load map into mapEditor
1920 vm->setFilePath (fn);
1921 err=vm->load(fn,lmode,ftype);
1923 // Restore old (maybe empty) filepath, if this is an import
1925 vm->setFilePath (fn_org);
1928 // Finally check for errors and go home
1931 if (lmode==NewMap) fileCloseMap();
1932 statusBar()->message( "Could not load " + fn, statusbarTime );
1937 vm->setFilePath (fn);
1938 tabWidget->setTabText (tabIndex, vm->getFileName());
1939 if (!isInTmpDir (fn))
1941 // Only append to lastMaps if not loaded from a tmpDir
1942 // e.g. imported bookmarks are in a tmpDir
1943 addRecentMap(vm->getFilePath() );
1945 actionFilePrint->setEnabled (true);
1947 statusBar()->message( "Loaded " + fn, statusbarTime );
1954 void Main::fileLoad(const LoadMode &lmode)
1956 QStringList filters;
1957 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1958 QFileDialog *fd=new QFileDialog( this);
1959 fd->setDir (lastFileDir);
1960 fd->setFileMode (QFileDialog::ExistingFiles);
1961 fd->setFilters (filters);
1965 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1968 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1971 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1977 if ( fd->exec() == QDialog::Accepted )
1979 lastFileDir=fd->directory().path();
1980 QStringList flist = fd->selectedFiles();
1981 QStringList::Iterator it = flist.begin();
1982 while( it != flist.end() )
1985 fileLoad(*it, lmode);
1992 void Main::fileLoad()
1997 void Main::fileLoadRecent()
1999 QAction *action = qobject_cast<QAction *>(sender());
2001 fileLoad (action->data().toString(), NewMap);
2004 void Main::addRecentMap (const QString &fileName)
2007 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2008 files.removeAll(fileName);
2009 files.prepend(fileName);
2010 while (files.size() > MaxRecentFiles)
2013 settings.setValue("/mainwindow/recentFileList", files);
2015 setupRecentMapsMenu();
2018 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2022 if ( m->getFilePath().isEmpty() )
2024 // We have no filepath yet,
2025 // call fileSaveAs() now, this will call fileSave()
2027 // First switch to editor
2028 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2029 fileSaveAs(savemode);
2032 if (m->save (savemode)==success)
2034 statusBar()->message(
2035 tr("Saved %1").arg(m->getFilePath()),
2037 addRecentMap (m->getFilePath() );
2039 statusBar()->message(
2040 tr("Couldn't save ").arg(m->getFilePath()),
2044 void Main::fileSave()
2046 fileSave (currentModel(), CompleteMap);
2049 void Main::fileSave(VymModel *m)
2051 fileSave (m,CompleteMap);
2054 void Main::fileSaveAs(const SaveMode& savemode)
2058 if (currentMapEditor())
2060 if (savemode==CompleteMap)
2061 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2063 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2064 if ( !fn.isEmpty() )
2066 // Check for existing file
2067 if (QFile (fn).exists())
2069 QMessageBox mb( vymName,
2070 tr("The file %1\nexists already. Do you want to").arg(fn),
2071 QMessageBox::Warning,
2072 QMessageBox::Yes | QMessageBox::Default,
2073 QMessageBox::Cancel | QMessageBox::Escape,
2074 QMessageBox::NoButton);
2075 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2076 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2079 case QMessageBox::Yes:
2082 case QMessageBox::Cancel:
2089 // New file, add extension to filename, if missing
2090 // This is always .vym or .vyp, depending on savemode
2091 if (savemode==CompleteMap)
2093 if (!fn.contains (".vym") && !fn.contains (".xml"))
2097 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2106 VymModel *m=currentModel();
2108 fileSave(m, savemode);
2110 // Set name of tab, assuming current tab is the one we just saved
2111 if (savemode==CompleteMap)
2112 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2118 void Main::fileSaveAs()
2120 fileSaveAs (CompleteMap);
2123 void Main::fileImportKDE3Bookmarks()
2125 ImportKDE3Bookmarks im;
2127 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2128 currentMapEditor()->getModel()->setFilePath ("");
2131 void Main::fileImportKDE4Bookmarks()
2133 ImportKDE4Bookmarks im;
2135 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2136 currentMapEditor()->getModel()->setFilePath ("");
2139 void Main::fileImportFirefoxBookmarks()
2141 Q3FileDialog *fd=new Q3FileDialog( this);
2142 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2143 fd->setMode (Q3FileDialog::ExistingFiles);
2144 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2145 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2148 if ( fd->exec() == QDialog::Accepted )
2150 ImportFirefoxBookmarks im;
2151 QStringList flist = fd->selectedFiles();
2152 QStringList::Iterator it = flist.begin();
2153 while( it != flist.end() )
2156 if (im.transform() &&
2157 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2158 currentMapEditor() )
2159 currentMapEditor()->getModel()->setFilePath ("");
2166 void Main::fileImportFreemind()
2168 QStringList filters;
2169 filters <<"Freemind map (*.mm)"<<"All files (*)";
2170 QFileDialog *fd=new QFileDialog( this);
2171 fd->setDir (lastFileDir);
2172 fd->setFileMode (QFileDialog::ExistingFiles);
2173 fd->setFilters (filters);
2174 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2178 if ( fd->exec() == QDialog::Accepted )
2180 lastFileDir=fd->directory().path();
2181 QStringList flist = fd->selectedFiles();
2182 QStringList::Iterator it = flist.begin();
2183 while( it != flist.end() )
2186 if ( fileLoad (fn,NewMap, FreemindMap) )
2188 currentMapEditor()->getModel()->setFilePath ("");
2197 void Main::fileImportMM()
2201 Q3FileDialog *fd=new Q3FileDialog( this);
2202 fd->setDir (lastFileDir);
2203 fd->setMode (Q3FileDialog::ExistingFiles);
2204 fd->addFilter ("Mind Manager (*.mmap)");
2205 fd->setCaption(tr("Import")+" "+"Mind Manager");
2208 if ( fd->exec() == QDialog::Accepted )
2210 lastFileDir=fd->dirPath();
2211 QStringList flist = fd->selectedFiles();
2212 QStringList::Iterator it = flist.begin();
2213 while( it != flist.end() )
2216 if (im.transform() &&
2217 success==fileLoad (im.getTransformedFile(),NewMap) &&
2218 currentMapEditor() )
2219 currentMapEditor()->getModel()->setFilePath ("");
2226 void Main::fileImportDir()
2228 VymModel *m=currentModel();
2229 if (m) m->importDir();
2232 void Main::fileExportXML()
2234 VymModel *m=currentModel();
2235 if (m) m->exportXML();
2238 void Main::fileExportHTML()
2240 VymModel *m=currentModel();
2241 if (m) m->exportHTML();
2245 void Main::fileExportXHTML()
2247 VymModel *m=currentModel();
2248 if (m) m->exportXHTML();
2251 void Main::fileExportImage()
2253 VymModel *m=currentModel();
2254 if (m) m->exportImage();
2257 void Main::fileExportAO()
2259 VymModel *m=currentModel();
2260 if (m) m->exportAO();
2263 void Main::fileExportASCII()
2265 VymModel *m=currentModel();
2266 if (m) m->exportASCII();
2269 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2271 VymModel *m=currentModel();
2276 ex.addFilter ("CSV (*.csv)");
2277 ex.setDir(lastImageDir);
2278 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2279 if (ex.execDialog() )
2281 m->setExportMode(true);
2283 m->setExportMode(false);
2288 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2290 VymModel *m=currentModel();
2295 ex.addFilter ("Tex (*.tex)");
2296 ex.setDir(lastImageDir);
2297 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2298 if (ex.execDialog() )
2300 m->setExportMode(true);
2302 m->setExportMode(false);
2307 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2309 ExportKDE3Bookmarks ex;
2310 VymModel *m=currentModel();
2318 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2320 ExportKDE4Bookmarks ex;
2321 VymModel *m=currentModel();
2329 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2331 ExportTaskjuggler ex;
2332 VymModel *m=currentModel();
2336 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2337 ex.setDir(lastImageDir);
2338 ex.addFilter ("Taskjuggler (*.tjp)");
2339 if (ex.execDialog() )
2341 m->setExportMode(true);
2343 m->setExportMode(false);
2348 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2350 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2351 // TODO add preview in dialog
2352 //ImagePreview *p =new ImagePreview (fd);
2353 //fd->setContentsPreviewEnabled( TRUE );
2354 //fd->setContentsPreview( p, p );
2355 //fd->setPreviewMode( QFileDialog::Contents );
2356 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2357 fd->setDir (QDir().current());
2358 if (fd->foundConfig())
2362 if ( fd->exec() == QDialog::Accepted )
2364 QString fn=fd->selectedFile();
2365 if (!fn.contains (".odp"))
2368 //lastImageDir=fn.left(fn.findRev ("/"));
2369 VymModel *m=currentModel();
2370 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2374 QMessageBox::warning(0,
2376 tr("Couldn't find configuration for export to Open Office\n"));
2380 void Main::fileCloseMap()
2382 VymModel *m=currentModel();
2385 if (m->hasChanged())
2387 QMessageBox mb( vymName,
2388 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2389 QMessageBox::Warning,
2390 QMessageBox::Yes | QMessageBox::Default,
2392 QMessageBox::Cancel | QMessageBox::Escape );
2393 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2394 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2397 case QMessageBox::Yes:
2399 fileSave(m, CompleteMap);
2401 case QMessageBox::No:
2402 // close without saving
2404 case QMessageBox::Cancel:
2409 // And here comes the segfault, because removeTab triggers
2410 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2411 vymViews.removeAt (tabWidget->currentIndex() );
2412 tabWidget->removeTab (tabWidget->currentIndex() );
2414 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2415 // Better would be delete (me), but then we could have a Qt error:
2416 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2417 // So we only remove data now and call deconstructor when vym closes later
2418 // this needs to be moved to vymview... me->clear();
2419 // some model->clear is needed to free up memory ...
2421 delete (m->getMapEditor());
2428 void Main::filePrint()
2430 if (currentMapEditor())
2431 currentMapEditor()->print();
2434 void Main::fileExitVYM()
2436 // Check if one or more editors have changed
2438 for (i=0;i<=vymViews.count() -1;i++)
2440 // If something changed, ask what to do
2441 if (vymViews.at(i)->getModel()->hasChanged())
2443 tabWidget->setCurrentPage(i);
2444 QMessageBox mb( vymName,
2445 tr("This map is not saved yet. Do you want to"),
2446 QMessageBox::Warning,
2447 QMessageBox::Yes | QMessageBox::Default,
2449 QMessageBox::Cancel | QMessageBox::Escape );
2450 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2451 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2454 mb.setActiveWindow();
2455 switch( mb.exec() ) {
2456 case QMessageBox::Yes:
2457 // save (the changed editors) and exit
2458 fileSave(currentModel(), CompleteMap);
2460 case QMessageBox::No:
2461 // exit without saving
2463 case QMessageBox::Cancel:
2464 // don't save and don't exit
2468 } // loop over all MEs
2472 void Main::editUndo()
2474 VymModel *m=currentModel();
2478 void Main::editRedo()
2480 VymModel *m=currentModel();
2484 void Main::gotoHistoryStep (int i)
2486 VymModel *m=currentModel();
2487 if (m) m->gotoHistoryStep(i);
2490 void Main::editCopy()
2492 VymModel *m=currentModel();
2496 void Main::editPaste()
2498 VymModel *m=currentModel();
2502 void Main::editCut()
2504 VymModel *m=currentModel();
2508 void Main::editOpenFindWidget()
2510 VymModel *m=currentModel();
2511 if (m) m->emitShowFindWidget();
2514 void Main::openTabs(QStringList urls)
2516 if (!urls.isEmpty())
2520 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2521 if (*browserPID==0) //FIXME-2 need to check if browser is really still there instead of this
2523 QString u=urls.takeFirst();
2525 QString workDir=QDir::currentDirPath();
2526 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2528 // try to set path to browser
2529 QMessageBox::warning(0,
2531 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2532 tr("Please use Settings->")+tr("Set application to open an URL"));
2535 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2536 #if defined(Q_OS_WIN32)
2537 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2538 this->thread()->wait(3000);
2540 sleep (3); //FIXME-3 needed?
2544 if (browser.contains("konqueror"))
2546 for (int i=0; i<urls.size(); i++)
2549 // Try to open new tab in existing konqueror started previously by vym
2553 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2554 "konqueror-mainwindow#1"<<
2558 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2559 "/konqueror/MainWindow_1"<<
2563 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2564 if (!QProcess::startDetached ("qdbus",args))
2568 QMessageBox::warning(0,
2570 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2572 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2574 for (int i=0; i<urls.size(); i++)
2576 // Try to open new tab in firefox
2577 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2578 if (!QProcess::startDetached (browser,args))
2582 QMessageBox::warning(0,
2584 tr("Couldn't start %1 to open a new tab").arg(browser));
2587 QMessageBox::warning(0,
2589 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2593 void Main::editOpenURL()
2596 VymModel *m=currentModel();
2599 QString url=m->getURL();
2601 if (url=="") return;
2602 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2604 QString workDir=QDir::currentDirPath();
2605 if (!procBrowser->startDetached(browser,args))
2607 // try to set path to browser
2608 QMessageBox::warning(0,
2610 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2611 tr("Please use Settings->")+tr("Set application to open an URL"));
2616 void Main::editOpenURLTab()
2618 VymModel *m=currentModel();
2622 urls.append(m->getURL());
2626 void Main::editOpenMultipleURLTabs()
2628 VymModel *m=currentModel();
2638 void Main::editURL()
2640 VymModel *m=currentModel();
2641 if (m) m->editURL();
2644 void Main::editLocalURL()
2646 VymModel *m=currentModel();
2647 if (m) m->editLocalURL();
2650 void Main::editHeading2URL()
2652 VymModel *m=currentModel();
2653 if (m) m->editHeading2URL();
2656 void Main::editBugzilla2URL()
2658 VymModel *m=currentModel();
2659 if (m) m->editBugzilla2URL();
2662 void Main::getBugzillaData()
2664 VymModel *m=currentModel();
2665 if (m) m->getBugzillaData();
2668 void Main::editFATE2URL()
2670 VymModel *m=currentModel();
2671 if (m) m->editFATE2URL();
2674 void Main::editHeadingFinished(VymModel *m)
2678 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2679 !prevSelection.isEmpty())
2680 m->select(prevSelection);
2685 void Main::openVymLinks(const QStringList &vl)
2687 for (int j=0; j<vl.size(); j++)
2689 // compare path with already loaded maps
2692 for (i=0;i<=vymViews.count() -1;i++)
2694 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2703 if (!QFile(vl.at(j)).exists() )
2704 QMessageBox::critical( 0, tr( "Critical Error" ),
2705 tr("Couldn't open map %1").arg(vl.at(j)));
2708 fileLoad (vl.at(j), NewMap);
2709 tabWidget->setCurrentIndex (tabWidget->count()-1);
2712 // Go to tab containing the map
2713 tabWidget->setCurrentIndex (index);
2717 void Main::editOpenVymLink()
2719 VymModel *m=currentModel();
2723 vl.append(m->getVymLink());
2728 void Main::editOpenMultipleVymLinks()
2730 QString currentVymLink;
2731 VymModel *m=currentModel();
2734 QStringList vl=m->getVymLinks();
2739 void Main::editVymLink()
2741 VymModel *m=currentModel();
2746 void Main::editDeleteVymLink()
2748 VymModel *m=currentModel();
2749 if (m) m->deleteVymLink();
2752 void Main::editToggleHideExport()
2754 VymModel *m=currentModel();
2755 if (m) m->toggleHideExport();
2758 void Main::editAddTimestamp()
2760 VymModel *m=currentModel();
2761 if (m) m->addTimestamp();
2764 void Main::editMapInfo()
2766 VymModel *m=currentModel();
2769 ExtraInfoDialog dia;
2770 dia.setMapName (m->getFileName() );
2771 dia.setAuthor (m->getAuthor() );
2772 dia.setComment(m->getComment() );
2776 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2782 BranchItem *cur=NULL;
2783 BranchItem *prev=NULL;
2784 m->nextBranch(cur,prev);
2787 if (!cur->getNote().isEmpty() ) n++;
2788 f+= cur->imageCount();
2790 xl+=cur->xlinkCount();
2791 m->nextBranch(cur,prev);
2794 stats+=QString ("%1 xLinks \n").arg (xl,6);
2795 stats+=QString ("%1 notes\n").arg (n,6);
2796 stats+=QString ("%1 images\n").arg (f,6);
2797 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2798 dia.setStats (stats);
2800 // Finally show dialog
2801 if (dia.exec() == QDialog::Accepted)
2803 m->setAuthor (dia.getAuthor() );
2804 m->setComment (dia.getComment() );
2808 void Main::editMoveUp()
2810 VymModel *m=currentModel();
2814 void Main::editMoveDown()
2816 VymModel *m=currentModel();
2817 if (m) m->moveDown();
2820 void Main::editDetach()
2822 VymModel *m=currentModel();
2826 void Main::editSortChildren()
2828 VymModel *m=currentModel();
2829 if (m) m->sortChildren();
2832 void Main::editToggleScroll()
2834 VymModel *m=currentModel();
2835 if (m) m->toggleScroll();
2838 void Main::editExpandAll()
2840 VymModel *m=currentModel();
2841 if (m) m->emitExpandAll();
2844 void Main::editExpandOneLevel()
2846 VymModel *m=currentModel();
2847 if (m) m->emitExpandOneLevel();
2850 void Main::editCollapseOneLevel()
2852 VymModel *m=currentModel();
2853 if (m) m->emitCollapseOneLevel();
2856 void Main::editUnscrollChildren()
2858 VymModel *m=currentModel();
2859 if (m) m->unscrollChildren();
2862 void Main::editAddAttribute()
2864 VymModel *m=currentModel();
2872 void Main::editAddMapCenter()
2874 VymModel *m=currentModel();
2875 if (m) m->addMapCenter ();
2878 void Main::editNewBranch()
2880 VymModel *m=currentModel();
2883 BranchItem *bi=m->addNewBranch();
2886 if (actionSettingsAutoEditNewBranch->isOn()
2887 && !actionSettingsAutoSelectNewBranch->isOn() )
2888 prevSelection=m->getSelectString();
2890 prevSelection=QString();
2892 if (actionSettingsAutoSelectNewBranch->isOn()
2893 || actionSettingsAutoEditNewBranch->isOn())
2896 if (actionSettingsAutoEditNewBranch->isOn())
2897 currentMapEditor()->editHeading();
2902 void Main::editNewBranchBefore()
2904 VymModel *m=currentModel();
2907 BranchItem *bi=m->addNewBranchBefore();
2914 if (actionSettingsAutoEditNewBranch->isOn())
2916 if (!actionSettingsAutoSelectNewBranch->isOn())
2917 prevSelection=m->getSelectString(bi);
2918 currentMapEditor()->editHeading();
2923 void Main::editNewBranchAbove()
2925 VymModel *m=currentModel();
2928 BranchItem *bi=m->addNewBranch (-1);
2936 if (actionSettingsAutoEditNewBranch->isOn())
2938 if (!actionSettingsAutoSelectNewBranch->isOn())
2939 prevSelection=m->getSelectString (bi);
2940 currentMapEditor()->editHeading();
2945 void Main::editNewBranchBelow()
2947 VymModel *m=currentModel();
2950 BranchItem *bi=m->addNewBranch (1);
2957 if (actionSettingsAutoEditNewBranch->isOn())
2959 if (!actionSettingsAutoSelectNewBranch->isOn())
2960 prevSelection=m->getSelectString(bi);
2961 currentMapEditor()->editHeading();
2966 void Main::editImportAdd()
2968 fileLoad (ImportAdd);
2971 void Main::editImportReplace()
2973 fileLoad (ImportReplace);
2976 void Main::editSaveBranch()
2978 fileSaveAs (PartOfMap);
2981 void Main::editDeleteKeepChildren()
2983 VymModel *m=currentModel();
2984 if (m) m->deleteKeepChildren();
2987 void Main::editDeleteChildren()
2989 VymModel *m=currentModel();
2990 if (m) m->deleteChildren();
2993 void Main::editDeleteSelection()
2995 VymModel *m=currentModel();
2996 if (m && actionSettingsUseDelKey->isOn())
2997 m->deleteSelection();
3000 void Main::editLoadImage()
3002 VymModel *m=currentModel();
3003 if (m) m->loadFloatImage();
3006 void Main::editSaveImage()
3008 VymModel *m=currentModel();
3009 if (m) m->saveFloatImage();
3012 void Main::editEditXLink(QAction *a)
3014 VymModel *m=currentModel();
3016 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3019 void Main::formatSelectColor()
3021 QColor col = QColorDialog::getColor((currentColor ), this );
3022 if ( !col.isValid() ) return;
3023 colorChanged( col );
3026 void Main::formatPickColor()
3028 VymModel *m=currentModel();
3030 colorChanged( m->getCurrentHeadingColor() );
3033 void Main::colorChanged(QColor c)
3035 QPixmap pix( 16, 16 );
3037 actionFormatColor->setIconSet( pix );
3041 void Main::formatColorBranch()
3043 VymModel *m=currentModel();
3044 if (m) m->colorBranch(currentColor);
3047 void Main::formatColorSubtree()
3049 VymModel *m=currentModel();
3050 if (m) m->colorSubtree (currentColor);
3053 void Main::formatLinkStyleLine()
3055 VymModel *m=currentModel();
3058 m->setMapLinkStyle("StyleLine");
3059 actionFormatLinkStyleLine->setChecked(true);
3063 void Main::formatLinkStyleParabel()
3065 VymModel *m=currentModel();
3068 m->setMapLinkStyle("StyleParabel");
3069 actionFormatLinkStyleParabel->setChecked(true);
3073 void Main::formatLinkStylePolyLine()
3075 VymModel *m=currentModel();
3078 m->setMapLinkStyle("StylePolyLine");
3079 actionFormatLinkStylePolyLine->setChecked(true);
3083 void Main::formatLinkStylePolyParabel()
3085 VymModel *m=currentModel();
3088 m->setMapLinkStyle("StylePolyParabel");
3089 actionFormatLinkStylePolyParabel->setChecked(true);
3093 void Main::formatSelectBackColor()
3095 VymModel *m=currentModel();
3096 if (m) m->selectMapBackgroundColor();
3099 void Main::formatSelectBackImage()
3101 VymModel *m=currentModel();
3103 m->selectMapBackgroundImage();
3106 void Main::formatSelectLinkColor()
3108 VymModel *m=currentModel();
3111 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3112 m->setMapDefLinkColor( col );
3116 void Main::formatSelectSelectionColor()
3118 VymModel *m=currentModel();
3121 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3122 m->setSelectionColor (col);
3127 void Main::formatToggleLinkColorHint()
3129 VymModel *m=currentModel();
3130 if (m) m->toggleMapLinkColorHint();
3134 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3136 VymModel *m=currentModel();
3138 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3141 void Main::viewZoomReset()
3143 MapEditor *me=currentMapEditor();
3144 if (me) me->setZoomFactorTarget (1);
3147 void Main::viewZoomIn()
3149 MapEditor *me=currentMapEditor();
3150 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3153 void Main::viewZoomOut()
3155 MapEditor *me=currentMapEditor();
3156 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3159 void Main::viewCenter()
3161 VymModel *m=currentModel();
3162 if (m) m->emitShowSelection();
3165 void Main::networkStartServer()
3167 VymModel *m=currentModel();
3168 if (m) m->newServer();
3171 void Main::networkConnect()
3173 VymModel *m=currentModel();
3174 if (m) m->connectToServer();
3177 bool Main::settingsPDF()
3179 // Default browser is set in constructor
3181 QString text = QInputDialog::getText(
3182 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3183 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3185 settings.setValue ("/mainwindow/readerPDF",text);
3190 bool Main::settingsURL()
3192 // Default browser is set in constructor
3194 QString text = QInputDialog::getText(
3195 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3196 settings.value("/mainwindow/readerURL").toString()
3199 settings.setValue ("/mainwindow/readerURL",text);
3203 void Main::settingsMacroDir()
3205 QDir defdir(vymBaseDir.path() + "/macros");
3206 if (!defdir.exists())
3208 QDir dir=QFileDialog::getExistingDirectory (
3210 tr ("Directory with vym macros:"),
3211 settings.value ("/macros/macroDir",defdir.path()).toString()
3214 settings.setValue ("/macros/macroDir",dir.absolutePath());
3217 void Main::settingsUndoLevels()
3220 int i = QInputDialog::getInteger(
3222 tr("QInputDialog::getInteger()"),
3223 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3226 settings.setValue ("/mapeditor/stepsTotal",i);
3227 QMessageBox::information( this, tr( "VYM -Information:" ),
3228 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3232 void Main::settingsAutosaveToggle()
3234 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3237 void Main::settingsAutosaveTime()
3240 int i = QInputDialog::getInteger(
3242 tr("QInputDialog::getInteger()"),
3243 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3245 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3248 void Main::settingsWriteBackupFileToggle()
3250 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3253 void Main::settingsToggleAnimation()
3255 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3258 void Main::settingsToggleDelKey()
3260 if (actionSettingsUseDelKey->isOn())
3262 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3265 actionDelete->setAccel (QKeySequence (""));
3269 void Main::windowToggleNoteEditor()
3271 if (textEditor->isVisible() )
3272 windowHideNoteEditor();
3274 windowShowNoteEditor();
3277 void Main::windowToggleHistory()
3279 if (historyWindow->isVisible())
3280 historyWindow->hide();
3282 historyWindow->show();
3286 void Main::windowToggleProperty()
3288 if (branchPropertyWindow->isVisible())
3289 branchPropertyWindow->hide();
3291 branchPropertyWindow->show();
3292 branchPropertyWindow->setModel (currentModel() );
3295 void Main::windowToggleAntiAlias()
3297 bool b=actionViewToggleAntiAlias->isOn();
3299 for (int i=0;i<vymViews.count();i++)
3301 me=vymViews.at(i)->getMapEditor();
3302 if (me) me->setAntiAlias(b);
3307 bool Main::isAliased()
3309 return actionViewToggleAntiAlias->isOn();
3312 bool Main::hasSmoothPixmapTransform()
3314 return actionViewToggleSmoothPixmapTransform->isOn();
3317 void Main::windowToggleSmoothPixmap()
3319 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3321 for (int i=0;i<vymViews.count();i++)
3324 me=vymViews.at(i)->getMapEditor();
3325 if (me) me->setSmoothPixmap(b);
3329 void Main::updateHistory(SimpleSettings &undoSet)
3331 historyWindow->update (undoSet);
3334 void Main::updateNoteFlag()
3336 // this slot is connected to TextEditor::textHasChanged()
3338 VymModel *m=currentModel();
3339 if (m) m->updateNoteFlag();
3342 void Main::updateNoteEditor(QModelIndex index )
3344 cout << QObject::sender();
3345 QObject *obj=QObject::sender();
3346 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3347 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3348 //cout << "Main::updateNoteEditor model="<<sender();
3349 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3350 textEditor->setNote (ti->getNoteObj() );
3353 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3355 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3357 if (model && model==currentModel() )
3361 if (!oldsel.indexes().isEmpty() )
3363 ti=model->getItem(oldsel.indexes().first());
3365 // Don't update note if both treeItem and textEditor are empty
3366 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3367 // ti->setNoteObj (textEditor->getNoteObj(),false );
3369 if (!newsel.indexes().isEmpty() )
3371 ti=model->getItem(newsel.indexes().first());
3372 if (!ti->hasEmptyNote() )
3373 textEditor->setNote(ti->getNoteObj() );
3375 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3377 // Show URL and link in statusbar
3379 QString s=ti->getURL();
3380 if (!s.isEmpty() ) status+="URL: "+s+" ";
3382 if (!s.isEmpty() ) status+="Link: "+s;
3383 if (!status.isEmpty() ) statusMessage (status);
3386 textEditor->setInactive();
3392 void Main::updateActions()
3394 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3395 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3396 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3397 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3399 VymModel *m =currentModel();
3403 actionFilePrint->setEnabled (true);
3405 // Link style in context menu
3406 switch (m->getMapLinkStyle())
3408 case LinkableMapObj::Line:
3409 actionFormatLinkStyleLine->setChecked(true);
3411 case LinkableMapObj::Parabel:
3412 actionFormatLinkStyleParabel->setChecked(true);
3414 case LinkableMapObj::PolyLine:
3415 actionFormatLinkStylePolyLine->setChecked(true);
3417 case LinkableMapObj::PolyParabel:
3418 actionFormatLinkStylePolyParabel->setChecked(true);
3425 QPixmap pix( 16, 16 );
3426 pix.fill( m->getMapBackgroundColor() );
3427 actionFormatBackColor->setIconSet( pix );
3428 pix.fill( m->getSelectionColor() );
3429 actionFormatSelectionColor->setIconSet( pix );
3430 pix.fill( m->getMapDefLinkColor() );
3431 actionFormatLinkColor->setIconSet( pix );
3434 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3437 // Expanding/collapsing
3438 actionExpandAll->setEnabled (true);
3439 actionExpandOneLevel->setEnabled (true);
3440 actionCollapseOneLevel->setEnabled (true);
3444 actionFilePrint->setEnabled (false);
3446 // Expanding/collapsing
3447 actionExpandAll->setEnabled (false);
3448 actionExpandOneLevel->setEnabled (false);
3449 actionCollapseOneLevel->setEnabled (false);
3452 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3453 actionFormatLinkColorHint->setChecked(true);
3455 actionFormatLinkColorHint->setChecked(false);
3458 if (m && m->hasChanged() )
3459 actionFileSave->setEnabled( true);
3461 actionFileSave->setEnabled( false);
3462 if (m && m->isUndoAvailable())
3463 actionUndo->setEnabled( true);
3465 actionUndo->setEnabled( false);
3467 if (m && m->isRedoAvailable())
3468 actionRedo->setEnabled( true);
3470 actionRedo->setEnabled( false);
3474 TreeItem *selti=m->getSelectedItem();
3475 BranchItem *selbi=m->getSelectedBranch();
3478 if (selbi || selti->getType()==TreeItem::Image)
3480 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3481 actionFormatHideLinkUnselected->setEnabled (true);
3486 // Take care of xlinks
3487 branchXLinksContextMenuEdit->clear();
3488 if (selbi->xlinkCount()>0)
3492 for (int i=0; i<selbi->xlinkCount();++i)
3494 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3498 if (s.length()>xLinkMenuWidth)
3499 s=s.left(xLinkMenuWidth)+"...";
3500 branchXLinksContextMenuEdit->addAction (s);
3505 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3508 actionToggleScroll->setEnabled (true);
3509 if ( selbi->isScrolled() )
3510 actionToggleScroll->setChecked(true);
3512 actionToggleScroll->setChecked(false);
3514 if ( selti->getURL().isEmpty() )
3516 actionOpenURL->setEnabled (false);
3517 actionOpenURLTab->setEnabled (false);
3521 actionOpenURL->setEnabled (true);
3522 actionOpenURLTab->setEnabled (true);
3524 if ( selti->getVymLink().isEmpty() )
3526 actionOpenVymLink->setEnabled (false);
3527 actionDeleteVymLink->setEnabled (false);
3530 actionOpenVymLink->setEnabled (true);
3531 actionDeleteVymLink->setEnabled (true);
3534 if (selbi->canMoveUp())
3535 actionMoveUp->setEnabled (true);
3537 actionMoveUp->setEnabled (false);
3538 if (selbi->canMoveDown())
3539 actionMoveDown->setEnabled (true);
3541 actionMoveDown->setEnabled (false);
3543 actionSortChildren->setEnabled (true);
3545 actionToggleHideExport->setEnabled (true);
3546 actionToggleHideExport->setChecked (selbi->hideInExport() );
3548 actionCopy->setEnabled (true);
3549 actionCut->setEnabled (true);
3550 if (!clipboardEmpty)
3551 actionPaste->setEnabled (true);
3553 actionPaste->setEnabled (false);
3554 for (int i=0; i<actionListBranches.size(); ++i)
3555 actionListBranches.at(i)->setEnabled(true);
3556 actionDelete->setEnabled (true);
3558 if ( selti->getType()==TreeItem::Image)
3560 actionOpenURL->setEnabled (false);
3561 actionOpenVymLink->setEnabled (false);
3562 actionDeleteVymLink->setEnabled (false);
3563 actionToggleHideExport->setEnabled (true);
3564 actionToggleHideExport->setChecked (selti->hideInExport() );
3567 actionCopy->setEnabled (true);
3568 actionCut->setEnabled (true);
3569 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3570 for (int i=0; i<actionListBranches.size(); ++i)
3571 actionListBranches.at(i)->setEnabled(false);
3572 actionDelete->setEnabled (true);
3573 actionMoveUp->setEnabled (false);
3574 actionMoveDown->setEnabled (false);
3579 actionCopy->setEnabled (false);
3580 actionCut->setEnabled (false);
3581 actionPaste->setEnabled (false);
3582 for (int i=0; i<actionListBranches.size(); ++i)
3583 actionListBranches.at(i)->setEnabled(false);
3585 actionToggleScroll->setEnabled (false);
3586 actionOpenURL->setEnabled (false);
3587 actionOpenVymLink->setEnabled (false);
3588 actionDeleteVymLink->setEnabled (false);
3589 actionHeading2URL->setEnabled (false);
3590 actionDelete->setEnabled (false);
3591 actionMoveUp->setEnabled (false);
3592 actionMoveDown->setEnabled (false);
3593 actionFormatHideLinkUnselected->setEnabled (false);
3594 actionSortChildren->setEnabled (false);
3595 actionToggleHideExport->setEnabled (false);
3600 Main::ModMode Main::getModMode()
3602 if (actionModModeColor->isOn()) return ModModeColor;
3603 if (actionModModeCopy->isOn()) return ModModeCopy;
3604 if (actionModModeXLink->isOn()) return ModModeXLink;
3608 bool Main::autoEditNewBranch()
3610 return actionSettingsAutoEditNewBranch->isOn();
3613 bool Main::autoSelectNewBranch()
3615 return actionSettingsAutoSelectNewBranch->isOn();
3618 void Main::windowShowNoteEditor()
3620 textEditor->setShowWithMain(true);
3622 actionViewToggleNoteEditor->setChecked (true);
3625 void Main::windowHideNoteEditor()
3627 textEditor->setShowWithMain(false);
3629 actionViewToggleNoteEditor->setChecked (false);
3632 void Main::setScript (const QString &script)
3634 scriptEditor->setScript (script);
3637 void Main::runScript (const QString &script)
3639 VymModel *m=currentModel();
3640 if (m) m->runScript (script);
3643 void Main::runScriptEverywhere (const QString &script)
3646 for (int i=0;i<=tabWidget->count() -1;i++)
3648 me=(MapEditor*)tabWidget->page(i);
3649 if (me) me->getModel()->runScript (script);
3653 void Main::windowNextEditor()
3655 if (tabWidget->currentIndex() < tabWidget->count())
3656 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3659 void Main::windowPreviousEditor()
3661 if (tabWidget->currentIndex() >0)
3662 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3665 void Main::standardFlagChanged()
3669 if ( actionSettingsUseFlagGroups->isOn() )
3670 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3672 currentModel()->toggleStandardFlag(sender()->name());
3677 void Main::testFunction1()
3679 if (!currentMapEditor()) return;
3680 currentMapEditor()->testFunction1();
3683 VymModel *m=currentModel();
3687 QString text = QInputDialog::getText(
3688 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3689 m->getSortFilter(), &ok, NULL);
3691 // user entered something and pressed OK
3692 m->setSortFilter (text);
3696 void Main::testFunction2()
3698 if (!currentMapEditor()) return;
3699 currentMapEditor()->testFunction2();
3702 void Main::testCommand()
3704 if (!currentMapEditor()) return;
3705 scriptEditor->show();
3708 QString com = QInputDialog::getText(
3709 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3710 if (ok) currentMapEditor()->parseAtom(com);
3714 void Main::helpDoc()
3716 QString locale = QLocale::system().name();
3718 if (locale.left(2)=="es")
3719 docname="vym_es.pdf";
3723 QStringList searchList;
3725 #if defined(Q_OS_MACX)
3726 searchList << "./vym.app/Contents/Resources/doc";
3727 #elif defined(Q_OS_WIN32)
3728 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3730 #if defined(VYM_DOCDIR)
3731 searchList << VYM_DOCDIR;
3733 // default path in SUSE LINUX
3734 searchList << "/usr/share/doc/packages/vym";
3737 searchList << "doc"; // relative path for easy testing in tarball
3738 searchList << "doc/tex"; // Easy testing working on vym.tex
3739 searchList << "/usr/share/doc/vym"; // Debian
3740 searchList << "/usr/share/doc/packages";// Knoppix
3744 for (int i=0; i<searchList.count(); ++i)
3746 docfile.setFileName(searchList.at(i)+"/"+docname);
3747 if (docfile.exists())
3756 QMessageBox::critical(0,
3757 tr("Critcal error"),
3758 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3763 Process *pdfProc = new Process();
3764 args << QDir::toNativeSeparators(docfile.fileName());
3766 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3769 QMessageBox::warning(0,
3771 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3772 tr("Please use Settings->")+tr("Set application to open PDF files"));
3779 void Main::helpDemo()
3781 QStringList filters;
3782 filters <<"VYM example map (*.vym)";
3783 QFileDialog *fd=new QFileDialog( this);
3784 #if defined(Q_OS_MACX)
3785 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3787 // default path in SUSE LINUX
3788 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3791 fd->setFileMode (QFileDialog::ExistingFiles);
3792 fd->setFilters (filters);
3793 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3797 if ( fd->exec() == QDialog::Accepted )
3799 lastFileDir=fd->directory().path();
3800 QStringList flist = fd->selectedFiles();
3801 QStringList::Iterator it = flist.begin();
3802 while( it != flist.end() )
3805 fileLoad(*it, NewMap);
3813 void Main::helpAbout()
3816 ad.setName ("aboutwindow");
3817 ad.setMinimumSize(500,500);
3818 ad.resize (QSize (500,500));
3822 void Main::helpAboutQT()
3824 QMessageBox::aboutQt( this, "Qt Application Example" );
3827 void Main::callMacro ()
3829 QAction *action = qobject_cast<QAction *>(sender());
3833 i=action->data().toInt();
3834 QString mDir (settings.value ("macros/macroDir").toString() );
3836 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3838 if ( !f.open( QIODevice::ReadOnly ) )
3840 QMessageBox::warning(0,
3842 tr("Couldn't find a macro at %1.\n").arg(fn)+
3843 tr("Please use Settings->")+tr("Set directory for vym macros"));
3847 QTextStream ts( &f );
3848 QString macro= ts.read();
3850 if (! macro.isEmpty())
3852 VymModel *m=currentModel();
3853 if (m) m->runScript(macro);