1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "exportoofiledialog.h"
13 #include "flagrowobj.h"
14 #include "historywindow.h"
16 #include "mapeditor.h"
21 #include "texteditor.h"
22 #include "warningdialog.h"
24 #if defined(Q_OS_WIN32)
25 // Define only this structure as opposed to
26 // including full 'windows.h'. FindWindow
27 // clashes with the one in Win32 API.
28 typedef struct _PROCESS_INFORMATION
34 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
37 extern TextEditor *textEditor;
38 extern Main *mainWindow;
39 extern QString tmpVymDir;
40 extern QString clipboardDir;
41 extern QString clipboardFile;
42 extern bool clipboardEmpty;
43 extern int statusbarTime;
44 extern FlagRowObj* standardFlagsDefault;
45 extern FlagRowObj* systemFlagsDefault;
46 extern QString vymName;
47 extern QString vymVersion;
48 extern QString vymBuildDate;
51 QMenu* branchContextMenu;
52 QMenu* branchAddContextMenu;
53 QMenu* branchRemoveContextMenu;
54 QMenu* branchLinksContextMenu;
55 QMenu* branchXLinksContextMenuEdit;
56 QMenu* branchXLinksContextMenuFollow;
57 QMenu* floatimageContextMenu;
58 QMenu* canvasContextMenu;
59 QMenu* fileLastMapsMenu;
60 QMenu* fileImportMenu;
61 QMenu* fileExportMenu;
64 extern Settings settings;
65 extern Options options;
66 extern ImageIO imageIO;
68 extern QDir vymBaseDir;
69 extern QDir lastImageDir;
70 extern QDir lastFileDir;
71 #if defined(Q_OS_WIN32)
72 extern QDir vymInstallDir;
74 extern QString iconPath;
75 extern QString flagsPath;
78 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
79 QMainWindow(parent,name,f)
83 setCaption ("VYM - View Your Mind");
85 // Load window settings
86 #if defined(Q_OS_WIN32)
87 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
89 setWindowState(Qt::WindowMaximized);
94 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
95 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
98 // Sometimes we may need to remember old selections
102 currentColor=Qt::black;
104 // Create unique temporary directory
106 tmpVymDir=makeTmpDir (ok,"vym");
109 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
112 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
114 // Create direcctory for clipboard
115 clipboardDir=tmpVymDir+"/clipboard";
116 clipboardFile="map.xml";
117 QDir d(clipboardDir);
118 d.mkdir (clipboardDir,true);
119 makeSubDirs (clipboardDir);
124 // Satellite windows //////////////////////////////////////////
127 historyWindow=new HistoryWindow();
128 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
131 branchPropertyWindow = new BranchPropertyWindow();
132 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
134 // Connect TextEditor, so that we can update flags if text changes
135 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
136 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
138 // Connect HistoryWindow, so that we can update flags
139 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
142 // Initialize script editor
143 scriptEditor = new SimpleScriptEditor();
144 scriptEditor->move (50,50);
146 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
147 this, SLOT( runScript( QString ) ) );
150 // Initialize Find window
151 findWindow=new FindWindow(NULL);
152 findWindow->move (x(),y()+70);
153 connect (findWindow, SIGNAL( findButton(QString) ),
154 this, SLOT(editFind(QString) ) );
155 connect (findWindow, SIGNAL( somethingChanged() ),
156 this, SLOT(editFindChanged() ) );
158 // Initialize some settings, which are platform dependant
161 // application to open URLs
162 p="/mainwindow/readerURL";
163 #if defined(Q_OS_LINUX)
164 s=settings.value (p,"xdg-open").toString();
166 #if defined(Q_OS_MACX)
167 s=settings.value (p,"/usr/bin/open").toString();
170 #if defined(Q_OS_WIN32)
171 // Assume that system has been set up so that
172 // Explorer automagically opens up the URL
173 // in the user's preferred browser.
174 s=settings.value (p,"explorer").toString();
176 s=settings.value (p,"mozilla").toString();
180 settings.setValue( p,s);
182 // application to open PDFs
183 p="/mainwindow/readerPDF";
184 #if defined(Q_OS_LINUX)
185 s=settings.value (p,"xdg-open").toString();
187 #if defined(Q_OS_MACX)
188 s=settings.value (p,"/usr/bin/open").toString();
189 #elif defined(Q_OS_WIN32)
190 s=settings.value (p,"acrord32").toString();
192 s=settings.value (p,"acroread").toString();
195 settings.setValue( p,s);
197 // width of xLinksMenu
200 // Create tab widget which holds the maps
201 tabWidget= new QTabWidget (this);
202 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
203 this, SLOT( editorChanged( QWidget * ) ) );
205 setCentralWidget(tabWidget);
209 setupFormatActions();
213 setupNetworkActions();
214 setupSettingsActions();
217 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
220 // Status bar and progress bar there
223 progressBar=new QProgressBar;
225 statusBar()->addPermanentWidget(progressBar);
227 restoreState (settings.value("/mainwindow/state",0).toByteArray());
235 #if defined(Q_OS_WIN32)
236 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
238 settings.setValue ("/mainwindow/geometry/size", size());
239 settings.setValue ("/mainwindow/geometry/pos", pos());
240 settings.setValue ("/mainwindow/state",saveState(0));
242 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
243 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
244 settings.setValue( "/version/version", vymVersion );
245 settings.setValue( "/version/builddate", vymBuildDate );
247 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
248 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
249 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
250 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
251 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
252 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
253 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
254 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
256 //TODO save scriptEditor settings
258 // call the destructors
260 delete historyWindow;
261 delete branchPropertyWindow;
264 // Remove temporary directory
265 removeDir (QDir(tmpVymDir));
268 void Main::loadCmdLine()
270 /* TODO draw some kind of splashscreen while loading...
276 QStringList flist=options.getFileList();
277 QStringList::Iterator it=flist.begin();
279 while (it !=flist.end() )
281 fileLoad (*it, NewMap);
287 void Main::statusMessage(const QString &s)
289 // Surpress messages while progressbar during
291 if (progressMin==progressMax)
292 statusBar()->message( s);
295 void Main::setProgressMinimum (int min)
297 progressBar->setMinimum(min);
301 void Main::setProgressMaximum (int max)
303 progressBar->setMaximum(max);
307 statusBar()->addPermanentWidget(progressBar);
312 void Main::setProgressValue (int v)
314 progressBar->setValue (v);
317 void Main::removeProgressBar()
320 statusBar()->removeWidget(progressBar);
321 progressMax=progressMin=0;
324 void Main::closeEvent (QCloseEvent* )
330 void Main::setupFileActions()
332 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
333 QToolBar *tb = addToolBar( tr ("&Map") );
334 tb->setObjectName ("mapTB");
337 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
338 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
339 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
341 fileMenu->addAction (a);
342 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
344 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
345 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
346 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
347 fileMenu->addAction (a);
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
351 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
352 a->setStatusTip (tr( "Open","Status tip File menu" ) );
353 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
355 fileMenu->addAction (a);
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
358 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
359 fileMenu->addSeparator();
361 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
362 a->setStatusTip ( tr( "Save","Status tip file menu" ));
363 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
365 fileMenu->addAction (a);
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
369 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
370 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
371 fileMenu->addAction (a);
372 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
374 fileMenu->addSeparator();
376 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
378 a = new QAction(tr("KDE 3 Bookmarks"), this);
379 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
380 a->addTo (fileImportMenu);
381 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
383 a = new QAction(tr("KDE 4 Bookmarks"), this);
384 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
385 a->addTo (fileImportMenu);
386 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
388 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
390 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
391 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
392 a->addTo (fileImportMenu);
393 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
396 a = new QAction("Freemind...",this);
397 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
398 fileImportMenu->addAction (a);
399 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
401 a = new QAction("Mind Manager...",this);
402 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
403 fileImportMenu->addAction (a);
404 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
406 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
407 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
408 fileImportMenu->addAction (a);
409 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
411 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
413 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
414 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
415 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
416 fileExportMenu->addAction (a);
418 a = new QAction( "Open Office...", this);
419 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
420 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
421 fileExportMenu->addAction (a);
423 a = new QAction( "Webpage (XHTML)...",this );
424 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
425 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
426 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
427 fileExportMenu->addAction (a);
429 a = new QAction( "Text (ASCII)...", this);
430 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
431 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
432 fileExportMenu->addAction (a);
434 a = new QAction( "Spreadsheet (CSV)...", this);
435 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
436 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
437 fileExportMenu->addAction (a);
439 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
440 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
441 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
442 fileExportMenu->addAction (a);
444 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
445 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
446 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
447 fileExportMenu->addAction (a);
449 a = new QAction( "Taskjuggler...", this );
450 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
451 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
452 fileExportMenu->addAction (a);
454 a = new QAction( "LaTeX...", this);
455 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
456 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
457 fileExportMenu->addAction (a);
459 a = new QAction( "XML..." , this );
460 a->setStatusTip (tr( "Export as %1").arg("XML"));
461 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
462 fileExportMenu->addAction (a);
464 fileMenu->addSeparator();
466 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
467 a->setStatusTip ( tr( "Print" ,"File menu") );
468 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
470 fileMenu->addAction (a);
471 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
474 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
475 a->setStatusTip (tr( "Close Map" ) );
476 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
477 fileMenu->addAction (a);
478 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
480 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
481 a->setStatusTip ( tr( "Exit")+" "+vymName );
482 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
483 fileMenu->addAction (a);
484 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
489 void Main::setupEditActions()
491 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
492 tb->setLabel( "Edit Actions" );
493 tb->setObjectName ("actionsTB");
494 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
498 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
499 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
500 a->setStatusTip (tr( "Undo" ) );
501 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
502 a->setEnabled (false);
504 editMenu->addAction (a);
507 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
508 a->setStatusTip (tr( "Redo" ));
509 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
511 editMenu->addAction (a);
512 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
515 editMenu->addSeparator();
516 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
517 a->setStatusTip ( tr( "Copy" ) );
518 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
519 a->setEnabled (false);
521 editMenu->addAction (a);
522 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
525 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
526 a->setStatusTip ( tr( "Cut" ) );
527 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
528 a->setEnabled (false);
530 editMenu->addAction (a);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
534 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
535 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
536 a->setStatusTip ( tr( "Paste" ) );
537 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
538 a->setEnabled (false);
540 editMenu->addAction (a);
544 // Shortcuts to modify heading:
545 a = new QAction(tr( "Edit heading","Edit menu" ),this);
546 a->setStatusTip ( tr( "edit Heading" ));
547 a->setShortcut ( Qt::Key_Enter); //Edit heading
548 // a->setShortcutContext (Qt::WindowShortcut);
550 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
551 actionListBranches.append(a);
552 a = new QAction( tr( "Edit heading","Edit menu" ), this);
553 a->setStatusTip (tr( "edit Heading" ));
554 a->setShortcut (Qt::Key_Return ); //Edit heading
555 //a->setShortcutContext (Qt::WindowShortcut);
557 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
558 actionListBranches.append(a);
559 editMenu->addAction (a);
562 a = new QAction( tr( "Edit heading","Edit menu" ), this);
563 a->setStatusTip (tr( "edit Heading" ));
564 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
565 a->setShortcutContext (Qt::WindowShortcut);
567 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
568 actionListBranches.append(a);
571 // Shortcut to delete selection
572 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
573 a->setStatusTip (tr( "Delete Selection" ));
574 a->setShortcut ( Qt::Key_Delete); //Delete selection
575 a->setShortcutContext (Qt::WindowShortcut);
577 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
580 // Shortcut to add mapcenter
581 a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
582 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
583 actionAddMapCenter = a;
586 // Shortcut to add branch
587 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
588 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
589 alt->setShortcut (Qt::Key_A); //Add branch
590 alt->setShortcutContext (Qt::WindowShortcut);
592 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
593 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
594 a->setStatusTip ( tr( "Add a branch as child of selection" ));
595 a->setShortcut (Qt::Key_Insert); //Add branch
596 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
597 actionListBranches.append(a);
598 #if defined (Q_OS_MACX)
599 // In OSX show different shortcut in menues, the keys work indepently always
604 editMenu->addAction (actionAddBranch);
605 tb->addAction (actionAddBranch);
608 // Add branch by inserting it at selection
609 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
610 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
611 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
612 a->setShortcutContext (Qt::WindowShortcut);
614 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
615 a->setEnabled (false);
616 actionListBranches.append(a);
617 actionAddBranchBefore=a;
618 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
619 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
620 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
621 a->setShortcutContext (Qt::WindowShortcut);
623 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
624 actionListBranches.append(a);
627 a = new QAction(tr( "Add branch above","Edit menu" ), this);
628 a->setStatusTip ( tr( "Add a branch above selection" ));
629 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
630 a->setShortcutContext (Qt::WindowShortcut);
632 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
633 a->setEnabled (false);
634 actionListBranches.append(a);
635 actionAddBranchAbove=a;
636 a = new QAction(tr( "Add branch above","Edit menu" ), this);
637 a->setStatusTip ( tr( "Add a branch above selection" ));
638 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
639 a->setShortcutContext (Qt::WindowShortcut);
641 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
642 actionListBranches.append(a);
645 a = new QAction(tr( "Add branch below","Edit menu" ), this);
646 a->setStatusTip ( tr( "Add a branch below selection" ));
647 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
648 a->setShortcutContext (Qt::WindowShortcut);
650 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
651 a->setEnabled (false);
652 actionListBranches.append(a);
653 actionAddBranchBelow=a;
654 a = new QAction(tr( "Add branch below","Edit menu" ), this);
655 a->setStatusTip ( tr( "Add a branch below selection" ));
656 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
657 a->setShortcutContext (Qt::WindowShortcut);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
660 actionListBranches.append(a);
662 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
663 a->setStatusTip ( tr( "Move branch up" ) );
664 a->setShortcut (Qt::Key_PageUp ); // Move branch up
665 a->setEnabled (false);
667 editMenu->addAction (a);
668 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
671 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
672 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
673 a->setStatusTip (tr( "Move branch down" ) );
674 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
675 a->setEnabled (false);
677 editMenu->addAction (a);
680 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
681 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
682 a->setEnabled (true);
684 editMenu->addAction (a);
685 actionSortChildren=a;
687 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
688 a->setShortcut ( Qt::Key_ScrollLock );
689 a->setStatusTip (tr( "Scroll branch" ) );
690 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
692 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
693 alt->setShortcut ( Qt::Key_S ); // Scroll branch
694 alt->setStatusTip (tr( "Scroll branch" ));
695 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
696 #if defined(Q_OS_MACX)
697 actionToggleScroll=alt;
699 actionToggleScroll=a;
701 actionToggleScroll->setEnabled (false);
702 actionToggleScroll->setToggleAction(true);
703 tb->addAction (actionToggleScroll);
704 editMenu->addAction ( actionToggleScroll);
705 editMenu->addAction (actionToggleScroll);
708 actionListBranches.append(actionToggleScroll);
710 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
711 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
712 editMenu->addAction (a);
713 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
715 editMenu->addSeparator();
717 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
718 a->setStatusTip (tr( "Find" ) );
719 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
720 editMenu->addAction (a);
721 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
723 editMenu->addSeparator();
725 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
726 a->setShortcut (Qt::CTRL + Qt::Key_U );
727 a->setShortcut (tr( "Open URL" ));
730 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
733 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
734 a->setStatusTip (tr( "Open URL in new tab" ));
735 //a->setShortcut (Qt::CTRL+Qt::Key_U );
737 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
740 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
741 a->setStatusTip (tr( "Open all URLs in subtree" ));
743 actionListBranches.append(a);
744 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
745 actionOpenMultipleURLTabs=a;
747 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
748 a->setStatusTip ( tr( "Edit URL" ) );
749 a->setShortcut ( Qt::Key_U );
750 a->setShortcutContext (Qt::WindowShortcut);
751 actionListBranches.append(a);
753 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
756 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
757 a->setStatusTip ( tr( "Edit local URL" ) );
758 a->setShortcut (Qt::SHIFT + Qt::Key_U );
759 a->setShortcutContext (Qt::WindowShortcut);
760 actionListBranches.append(a);
762 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
765 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
766 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
767 a->setEnabled (false);
768 actionListBranches.append(a);
769 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
772 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
773 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
774 a->setEnabled (false);
775 actionListBranches.append(a);
776 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
777 actionBugzilla2URL=a;
779 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
780 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
781 a->setEnabled (false);
782 actionListBranches.append(a);
783 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
786 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
787 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
789 a->setEnabled (false);
790 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
793 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
794 a->setStatusTip ( tr( "Open all vym links in subtree" ));
795 a->setEnabled (false);
796 actionListBranches.append(a);
797 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
798 actionOpenMultipleVymLinks=a;
801 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
802 a->setEnabled (false);
803 a->setStatusTip ( tr( "Edit link to another vym map" ));
804 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
805 actionListBranches.append(a);
808 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
809 a->setStatusTip ( tr( "Delete link to another vym map" ));
810 a->setEnabled (false);
811 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
812 actionDeleteVymLink=a;
814 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
815 a->setStatusTip ( tr( "Hide object in exports" ) );
816 a->setShortcut (Qt::Key_H );
817 a->setToggleAction(true);
819 a->setEnabled (false);
820 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
821 actionToggleHideExport=a;
823 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
824 a->setStatusTip ( tr( "Edit Map Info" ));
825 a->setEnabled (true);
826 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
829 // Import at selection (adding to selection)
830 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
831 a->setStatusTip (tr( "Add map at selection" ));
832 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
833 a->setEnabled (false);
834 actionListBranches.append(a);
837 // Import at selection (replacing selection)
838 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
839 a->setStatusTip (tr( "Replace selection with map" ));
840 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
841 a->setEnabled (false);
842 actionListBranches.append(a);
843 actionImportReplace=a;
846 a = new QAction( tr( "Save selection","Edit menu" ), this);
847 a->setStatusTip (tr( "Save selection" ));
848 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
849 a->setEnabled (false);
850 actionListBranches.append(a);
853 // Only remove branch, not its children
854 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
855 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
856 a->setShortcut (Qt::ALT + Qt::Key_Delete );
857 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
858 a->setEnabled (false);
860 actionListBranches.append(a);
861 actionDeleteKeepChildren=a;
863 // Only remove children of a branch
864 a = new QAction( tr( "Remove children","Edit menu" ), this);
865 a->setStatusTip (tr( "Remove children of branch" ));
866 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
867 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
868 a->setEnabled (false);
869 actionListBranches.append(a);
870 actionDeleteChildren=a;
872 // Shortcuts for navigating with cursor:
873 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
874 a->setStatusTip ( tr( "Select upper branch" ));
875 a->setShortcut (Qt::Key_Up );
876 a->setShortcutContext (Qt::WindowShortcut);
878 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
879 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
880 a->setStatusTip (tr( "Select lower branch" ));
881 a->setShortcut ( Qt::Key_Down );
882 a->setShortcutContext (Qt::WindowShortcut);
884 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
885 a = new QAction(tr( "Select left branch","Edit menu" ), this);
886 a->setStatusTip ( tr( "Select left branch" ));
887 a->setShortcut (Qt::Key_Left );
888 a->setShortcutContext (Qt::WindowShortcut);
890 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
891 a = new QAction( tr( "Select child branch","Edit menu" ), this);
892 a->setStatusTip (tr( "Select right branch" ));
893 a->setShortcut (Qt::Key_Right);
894 a->setShortcutContext (Qt::WindowShortcut);
896 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
897 a = new QAction( tr( "Select first branch","Edit menu" ), this);
898 a->setStatusTip (tr( "Select first branch" ));
899 a->setShortcut (Qt::Key_Home );
900 a->setShortcutContext (Qt::WindowShortcut);
902 a->setEnabled (false);
903 editMenu->addAction (a);
904 actionListBranches.append(a);
906 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
907 a = new QAction( tr( "Select last branch","Edit menu" ),this);
908 a->setStatusTip (tr( "Select last branch" ));
909 a->setShortcut ( Qt::Key_End );
910 a->setShortcutContext (Qt::WindowShortcut);
912 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
913 a->setEnabled (false);
914 editMenu->addAction (a);
915 actionListBranches.append(a);
918 a = new QAction( tr( "Add Image...","Edit menu" ), this);
919 a->setStatusTip (tr( "Add Image" ));
920 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
923 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
924 a->setStatusTip (tr( "Set properties for selection" ));
925 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
926 a->setShortcutContext (Qt::WindowShortcut);
927 a->setToggleAction (true);
929 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
930 actionViewTogglePropertyWindow=a;
934 void Main::setupFormatActions()
936 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
938 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
939 tb->setObjectName ("formatTB");
942 pix.fill (Qt::black);
943 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
944 a->setStatusTip ( tr( "Set Color" ));
945 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
947 formatMenu->addAction (a);
949 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
950 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
951 a->setShortcut (Qt::CTRL + Qt::Key_K );
952 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
953 a->setEnabled (false);
955 formatMenu->addAction (a);
956 actionListBranches.append(a);
957 actionFormatPickColor=a;
959 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
960 a->setStatusTip ( tr( "Color branch" ) );
961 a->setShortcut (Qt::CTRL + Qt::Key_B);
962 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
963 a->setEnabled (false);
965 formatMenu->addAction (a);
966 actionListBranches.append(a);
967 actionFormatColorSubtree=a;
969 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
970 a->setStatusTip ( tr( "Color Subtree" ));
971 a->setShortcut (Qt::CTRL + Qt::Key_T);
972 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
973 a->setEnabled (false);
974 formatMenu->addAction (a);
976 actionListBranches.append(a);
977 actionFormatColorSubtree=a;
979 formatMenu->addSeparator();
980 actionGroupFormatLinkStyles=new QActionGroup ( this);
981 actionGroupFormatLinkStyles->setExclusive (true);
982 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
983 a->setStatusTip (tr( "Line" ));
984 a->setToggleAction(true);
985 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
986 formatMenu->addAction (a);
987 actionFormatLinkStyleLine=a;
988 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
989 a->setStatusTip (tr( "Line" ));
990 a->setToggleAction(true);
991 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
992 formatMenu->addAction (a);
993 actionFormatLinkStyleParabel=a;
994 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
995 a->setStatusTip (tr( "PolyLine" ));
996 a->setToggleAction(true);
997 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
998 formatMenu->addAction (a);
999 actionFormatLinkStylePolyLine=a;
1000 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1001 a->setStatusTip (tr( "PolyParabel" ) );
1002 a->setToggleAction(true);
1003 a->setChecked (true);
1004 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1005 formatMenu->addAction (a);
1006 actionFormatLinkStylePolyParabel=a;
1008 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1009 a->setStatusTip (tr( "Hide link" ));
1010 a->setToggleAction(true);
1011 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1012 actionFormatHideLinkUnselected=a;
1014 formatMenu->addSeparator();
1015 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1016 a->setStatusTip (tr( "Use same color for links and headings" ));
1017 a->setToggleAction(true);
1018 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1019 formatMenu->addAction (a);
1020 actionFormatLinkColorHint=a;
1022 pix.fill (Qt::white);
1023 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1024 a->setStatusTip (tr( "Set Link Color" ));
1025 formatMenu->addAction (a);
1026 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1027 actionFormatLinkColor=a;
1029 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1030 a->setStatusTip (tr( "Set Selection Color" ));
1031 formatMenu->addAction (a);
1032 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1033 actionFormatSelectionColor=a;
1035 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1036 a->setStatusTip (tr( "Set Background Color" ));
1037 formatMenu->addAction (a);
1038 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1039 actionFormatBackColor=a;
1041 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1042 a->setStatusTip (tr( "Set Background image" ));
1043 formatMenu->addAction (a);
1044 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1045 actionFormatBackImage=a;
1049 void Main::setupViewActions()
1051 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1052 tb->setLabel( "View Actions" );
1053 tb->setObjectName ("viewTB");
1054 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1057 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1058 a->setStatusTip ( tr( "Zoom reset" ) );
1059 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1061 viewMenu->addAction (a);
1062 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1064 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1065 a->setStatusTip (tr( "Zoom in" ));
1066 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1068 viewMenu->addAction (a);
1069 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1071 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1072 a->setStatusTip (tr( "Zoom out" ));
1073 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1075 viewMenu->addAction (a);
1076 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1078 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1079 a->setStatusTip (tr( "Show selection" ));
1080 a->setShortcut (Qt::Key_Period);
1082 viewMenu->addAction (a);
1083 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1085 viewMenu->addSeparator();
1087 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1088 a->setStatusTip ( tr( "Show Note Editor" ));
1089 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1090 a->setToggleAction(true);
1092 viewMenu->addAction (a);
1093 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1094 actionViewToggleNoteEditor=a;
1096 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1097 a->setStatusTip ( tr( "Show History Window" ));
1098 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1099 a->setToggleAction(true);
1101 viewMenu->addAction (a);
1102 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1103 actionViewToggleHistoryWindow=a;
1105 viewMenu->addAction (actionViewTogglePropertyWindow);
1107 viewMenu->addSeparator();
1109 a = new QAction(tr( "Antialiasing","View action" ),this );
1110 a->setStatusTip ( tr( "Antialiasing" ));
1111 a->setToggleAction(true);
1112 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1113 viewMenu->addAction (a);
1114 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1115 actionViewToggleAntiAlias=a;
1117 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1118 a->setStatusTip (a->text());
1119 a->setToggleAction(true);
1120 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1121 viewMenu->addAction (a);
1122 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1123 actionViewToggleSmoothPixmapTransform=a;
1125 a = new QAction(tr( "Next Map","View action" ), this);
1126 a->setStatusTip (a->text());
1127 a->setShortcut (Qt::ALT + Qt::Key_N );
1128 viewMenu->addAction (a);
1129 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1131 a = new QAction (tr( "Previous Map","View action" ), this );
1132 a->setStatusTip (a->text());
1133 a->setShortcut (Qt::ALT + Qt::Key_P );
1134 viewMenu->addAction (a);
1135 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1139 void Main::setupModeActions()
1141 //QPopupMenu *menu = new QPopupMenu( this );
1142 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1144 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1145 tb->setObjectName ("modesTB");
1147 actionGroupModModes=new QActionGroup ( this);
1148 actionGroupModModes->setExclusive (true);
1149 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1150 a->setShortcut (Qt::Key_J);
1151 a->setStatusTip ( tr( "Use modifier to color branches" ));
1152 a->setToggleAction(true);
1155 actionModModeColor=a;
1157 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1158 a->setShortcut( Qt::Key_K);
1159 a->setStatusTip( tr( "Use modifier to copy" ));
1160 a->setToggleAction(true);
1162 actionModModeCopy=a;
1164 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1165 a->setShortcut (Qt::Key_L);
1166 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1167 a->setToggleAction(true);
1169 actionModModeXLink=a;
1173 void Main::setupFlagActions()
1175 // Create System Flags
1179 systemFlagsDefault = new FlagRowObj ();
1180 systemFlagsDefault->setVisibility (false);
1181 systemFlagsDefault->setName ("systemFlagsDef");
1183 FlagObj *fo = new FlagObj ();
1184 fo->load(QPixmap(flagsPath+"flag-note.png"));
1185 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1187 fo->load(QPixmap(flagsPath+"flag-url.png"));
1188 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1190 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1191 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1193 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1194 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1196 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1197 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1199 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1200 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1202 // Create Standard Flags
1203 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1204 tb->setObjectName ("standardFlagTB");
1206 standardFlagsDefault = new FlagRowObj ();
1207 standardFlagsDefault->setVisibility (false);
1208 standardFlagsDefault->setName ("standardFlagsDef");
1209 standardFlagsDefault->setToolBar (tb);
1211 fo->load(flagsPath+"flag-exclamationmark.png");
1212 fo->setGroup("standard-mark");
1213 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1215 fo->load(flagsPath+"flag-questionmark.png");
1216 fo->setGroup("standard-mark");
1217 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1219 fo->load(flagsPath+"flag-hook-green.png");
1220 fo->setGroup("standard-hook");
1221 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1223 fo->load(flagsPath+"flag-cross-red.png");
1224 fo->setGroup("standard-hook");
1225 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1228 fo->load(flagsPath+"flag-stopsign.png");
1229 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1231 fo->load(flagsPath+"flag-smiley-good.png");
1232 fo->setGroup("standard-smiley");
1233 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1235 fo->load(flagsPath+"flag-smiley-sad.png");
1236 fo->setGroup("standard-smiley");
1237 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1239 fo->load(flagsPath+"flag-smiley-omg.png");
1240 fo->setGroup("standard-smiley");
1241 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1242 // Original omg.png (in KDE emoticons)
1245 fo->load(flagsPath+"flag-kalarm.png");
1246 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1248 fo->load(flagsPath+"flag-phone.png");
1249 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1251 fo->load(flagsPath+"flag-lamp.png");
1252 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1254 fo->load(flagsPath+"flag-arrow-up.png");
1255 fo->setGroup("standard-arrow");
1256 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1258 fo->load(flagsPath+"flag-arrow-down.png");
1259 fo->setGroup("standard-arrow");
1260 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1262 fo->load(flagsPath+"flag-arrow-2up.png");
1263 fo->setGroup("standard-arrow");
1264 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1266 fo->load(flagsPath+"flag-arrow-2down.png");
1267 fo->setGroup("standard-arrow");
1268 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1271 fo->load(flagsPath+"flag-thumb-up.png");
1272 fo->setGroup("standard-thumb");
1273 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1275 fo->load(flagsPath+"flag-thumb-down.png");
1276 fo->setGroup("standard-thumb");
1277 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1280 fo->load(flagsPath+"flag-rose.png");
1281 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1283 fo->load(flagsPath+"flag-heart.png");
1284 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1286 fo->load(flagsPath+"flag-present.png");
1287 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1289 fo->load(flagsPath+"flag-flash.png");
1290 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1292 // Original: xsldbg_output.png
1293 fo->load(flagsPath+"flag-info.png");
1294 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1296 // Original khelpcenter.png
1297 fo->load(flagsPath+"flag-lifebelt.png");
1298 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1304 fo->load(flagsPath+"freemind/warning.png");
1305 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1307 for (int i=1; i<8; i++)
1309 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1310 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1313 fo->load(flagsPath+"freemind/back.png");
1314 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1316 fo->load(flagsPath+"freemind/forward.png");
1317 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1319 fo->load(flagsPath+"freemind/attach.png");
1320 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1322 fo->load(flagsPath+"freemind/clanbomber.png");
1323 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1325 fo->load(flagsPath+"freemind/desktopnew.png");
1326 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1328 fo->load(flagsPath+"freemind/flag.png");
1329 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1332 fo->load(flagsPath+"freemind/gohome.png");
1333 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1336 fo->load(flagsPath+"freemind/kaddressbook.png");
1337 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1339 fo->load(flagsPath+"freemind/knotify.png");
1340 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1342 fo->load(flagsPath+"freemind/korn.png");
1343 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1345 fo->load(flagsPath+"freemind/mail.png");
1346 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1348 fo->load(flagsPath+"freemind/password.png");
1349 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1351 fo->load(flagsPath+"freemind/pencil.png");
1352 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1354 fo->load(flagsPath+"freemind/stop.png");
1355 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1357 fo->load(flagsPath+"freemind/wizard.png");
1358 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1360 fo->load(flagsPath+"freemind/xmag.png");
1361 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1363 fo->load(flagsPath+"freemind/bell.png");
1364 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1366 fo->load(flagsPath+"freemind/bookmark.png");
1367 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1369 fo->load(flagsPath+"freemind/penguin.png");
1370 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1372 fo->load(flagsPath+"freemind/licq.png");
1373 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1378 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1381 fo->setToolTip (tooltip);
1382 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1388 fo->setAlwaysVisible(aw);
1389 a->setCheckable(true);
1390 a->setObjectName(fo->getName());
1391 a->setToolTip(tooltip);
1392 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1393 standardFlagsDefault->addFlag (fo);
1397 systemFlagsDefault->addFlag (fo);
1401 void Main::setupNetworkActions()
1403 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1405 QMenu *netMenu = menuBar()->addMenu( "Network" );
1409 a = new QAction( "Start TCPserver for MapEditor",this);
1410 //a->setStatusTip ( "Set application to open pdf files"));
1411 a->setShortcut ( Qt::Key_T ); //New TCP server
1412 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1413 netMenu->addAction (a);
1415 a = new QAction( "Connect MapEditor to server",this);
1416 //a->setStatusTip ( "Set application to open pdf files"));
1417 a->setShortcut ( Qt::Key_C ); // Connect to server
1418 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1419 netMenu->addAction (a);
1423 void Main::setupSettingsActions()
1425 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1429 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1430 a->setStatusTip ( tr( "Set application to open pdf files"));
1431 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1432 settingsMenu->addAction (a);
1434 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1435 a->setStatusTip( tr( "Set application to open external links"));
1436 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1437 settingsMenu->addAction (a);
1439 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1440 a->setStatusTip( tr( "Set path for macros"));
1441 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1442 settingsMenu->addAction (a);
1444 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1445 a->setStatusTip( tr( "Set number of undo levels"));
1446 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1447 settingsMenu->addAction (a);
1449 settingsMenu->addSeparator();
1451 a = new QAction( tr( "Autosave","Settings action"), this);
1452 a->setStatusTip( tr( "Autosave"));
1453 a->setToggleAction(true);
1454 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1455 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1456 settingsMenu->addAction (a);
1457 actionSettingsAutosaveToggle=a;
1459 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1460 a->setStatusTip( tr( "Autosave time"));
1461 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1462 settingsMenu->addAction (a);
1463 actionSettingsAutosaveTime=a;
1465 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1466 a->setStatusTip( tr( "Write backup file on save"));
1467 a->setToggleAction(true);
1468 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1469 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1470 settingsMenu->addAction (a);
1471 actionSettingsWriteBackupFile=a;
1473 settingsMenu->addSeparator();
1475 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1476 a->setStatusTip( tr( "Edit branch after adding it" ));
1477 a->setToggleAction(true);
1478 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1479 settingsMenu->addAction (a);
1480 actionSettingsAutoEditNewBranch=a;
1482 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1483 a->setStatusTip( tr( "Select branch after adding it" ));
1484 a->setToggleAction(true);
1485 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1486 settingsMenu->addAction (a);
1487 actionSettingsAutoSelectNewBranch=a;
1489 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1490 a->setStatusTip( tr( "Select heading before editing" ));
1491 a->setToggleAction(true);
1492 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1493 settingsMenu->addAction (a);
1494 actionSettingsAutoSelectText=a;
1496 a= new QAction( tr( "Delete key","Settings action" ), this);
1497 a->setStatusTip( tr( "Delete key for deleting branches" ));
1498 a->setToggleAction(true);
1499 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1500 settingsMenu->addAction (a);
1501 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1502 actionSettingsUseDelKey=a;
1504 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1505 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1506 a->setToggleAction(true);
1507 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1508 settingsMenu->addAction (a);
1509 actionSettingsUseFlagGroups=a;
1511 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1512 a->setStatusTip( tr( "Use hide flag during exports " ));
1513 a->setToggleAction(true);
1514 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1515 settingsMenu->addAction (a);
1516 actionSettingsUseHideExport=a;
1518 a = new QAction( tr( "Animation","Settings action"), this);
1519 a->setStatusTip( tr( "Animation"));
1520 a->setToggleAction(true);
1521 a->setOn (settings.value("/animation/use",false).toBool() );
1522 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1523 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1525 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 testMenu->addAction (a);
1539 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1541 a = new QAction( "Test function 2" , this);
1542 a->setStatusTip( "Call test function 2" );
1543 testMenu->addAction (a);
1544 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1546 a = new QAction( "Command" , this);
1547 a->setStatusTip( "Enter command to call in editor" );
1548 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1549 testMenu->addAction (a);
1553 void Main::setupHelpActions()
1555 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1558 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1559 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1560 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1561 helpMenu->addAction (a);
1563 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1564 a->setStatusTip( tr( "Open VYM example maps " ));
1565 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1566 helpMenu->addAction (a);
1568 a = new QAction( tr( "About VYM","Help action" ), this);
1569 a->setStatusTip( tr( "About VYM")+vymName);
1570 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1571 helpMenu->addAction (a);
1573 a = new QAction( tr( "About QT","Help action" ), this);
1574 a->setStatusTip( tr( "Information about QT toolkit" ));
1575 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1576 helpMenu->addAction (a);
1580 void Main::setupContextMenus()
1584 // Context Menu for branch or mapcenter
1585 branchContextMenu =new QMenu (this);
1586 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1587 branchContextMenu->addSeparator();
1590 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1591 branchAddContextMenu->addAction (actionPaste );
1592 branchAddContextMenu->addAction ( actionAddBranch );
1593 branchAddContextMenu->addAction ( actionAddBranchBefore );
1594 branchAddContextMenu->addAction ( actionAddBranchAbove);
1595 branchAddContextMenu->addAction ( actionAddBranchBelow );
1596 branchAddContextMenu->addSeparator();
1597 branchAddContextMenu->addAction ( actionImportAdd );
1598 branchAddContextMenu->addAction ( actionImportReplace );
1601 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1602 branchRemoveContextMenu->addAction (actionCut);
1603 branchRemoveContextMenu->addAction ( actionDelete );
1604 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1605 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1608 actionSaveBranch->addTo( branchContextMenu );
1609 actionFileNewCopy->addTo (branchContextMenu );
1611 branchContextMenu->addSeparator();
1612 branchContextMenu->addAction ( actionLoadImage);
1614 // Submenu for Links (URLs, vymLinks)
1615 branchLinksContextMenu =new QMenu (this);
1617 branchContextMenu->addSeparator();
1618 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1619 branchLinksContextMenu->addAction ( actionOpenURL );
1620 branchLinksContextMenu->addAction ( actionOpenURLTab );
1621 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1622 branchLinksContextMenu->addAction ( actionURL );
1623 branchLinksContextMenu->addAction ( actionLocalURL );
1624 branchLinksContextMenu->addAction ( actionHeading2URL );
1625 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1626 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1628 branchLinksContextMenu->addAction ( actionFATE2URL );
1630 branchLinksContextMenu->addSeparator();
1631 branchLinksContextMenu->addAction ( actionOpenVymLink );
1632 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1633 branchLinksContextMenu->addAction ( actionVymLink );
1634 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1637 // Context Menu for XLinks in a branch menu
1638 // This will be populated "on demand" in MapEditor::updateActions
1639 branchContextMenu->addSeparator();
1640 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1641 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1642 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1643 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1646 // Context menu for floatimage
1647 floatimageContextMenu =new QMenu (this);
1648 a= new QAction (tr ("Save image","Context action"),this);
1649 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1650 floatimageContextMenu->addAction (a);
1652 floatimageContextMenu->addSeparator();
1653 actionCopy->addTo( floatimageContextMenu );
1654 actionCut->addTo( floatimageContextMenu );
1656 floatimageContextMenu->addSeparator();
1657 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1660 // Context menu for canvas
1661 canvasContextMenu =new QMenu (this);
1662 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1663 actionAddMapCenter->addTo( canvasContextMenu );
1664 actionMapInfo->addTo( canvasContextMenu );
1665 canvasContextMenu->insertSeparator();
1666 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1667 canvasContextMenu->insertSeparator();
1668 actionFormatLinkColorHint->addTo( canvasContextMenu );
1669 actionFormatLinkColor->addTo( canvasContextMenu );
1670 actionFormatSelectionColor->addTo( canvasContextMenu );
1671 actionFormatBackColor->addTo( canvasContextMenu );
1672 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1674 // Menu for last opened files
1676 for (int i = 0; i < MaxRecentFiles; ++i)
1678 recentFileActions[i] = new QAction(this);
1679 recentFileActions[i]->setVisible(false);
1680 fileLastMapsMenu->addAction(recentFileActions[i]);
1681 connect(recentFileActions[i], SIGNAL(triggered()),
1682 this, SLOT(fileLoadRecent()));
1684 setupRecentMapsMenu();
1687 void Main::setupRecentMapsMenu()
1689 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1691 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1693 for (int i = 0; i < numRecentFiles; ++i) {
1694 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1695 recentFileActions[i]->setText(text);
1696 recentFileActions[i]->setData(files[i]);
1697 recentFileActions[i]->setVisible(true);
1699 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1700 recentFileActions[j]->setVisible(false);
1703 void Main::setupMacros()
1705 for (int i = 0; i <= 11; i++)
1707 macroActions[i] = new QAction(this);
1708 macroActions[i]->setData(i);
1709 addAction (macroActions[i]);
1710 connect(macroActions[i], SIGNAL(triggered()),
1711 this, SLOT(callMacro()));
1713 macroActions[0]->setShortcut ( Qt::Key_F1 );
1714 macroActions[1]->setShortcut ( Qt::Key_F2 );
1715 macroActions[2]->setShortcut ( Qt::Key_F3 );
1716 macroActions[3]->setShortcut ( Qt::Key_F4 );
1717 macroActions[4]->setShortcut ( Qt::Key_F5 );
1718 macroActions[5]->setShortcut ( Qt::Key_F6 );
1719 macroActions[6]->setShortcut ( Qt::Key_F7 );
1720 macroActions[7]->setShortcut ( Qt::Key_F8 );
1721 macroActions[8]->setShortcut ( Qt::Key_F9 );
1722 macroActions[9]->setShortcut ( Qt::Key_F10 );
1723 macroActions[10]->setShortcut ( Qt::Key_F11 );
1724 macroActions[11]->setShortcut ( Qt::Key_F12 );
1727 void Main::hideEvent (QHideEvent * )
1729 if (!textEditor->isMinimized() ) textEditor->hide();
1732 void Main::showEvent (QShowEvent * )
1734 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1738 MapEditor* Main::currentMapEditor() const
1740 if ( tabWidget->currentPage())
1741 return tabModel.at(tabWidget->currentIndex())->getMapEditor();
1745 VymModel* Main::currentModel() const
1747 if ( tabWidget->currentPage())
1748 return tabModel.at(tabWidget->currentIndex());
1753 void Main::editorChanged(QWidget *)
1755 // Unselect all possibly selected objects
1756 // (Important to update note editor)
1757 for (int i=0;i<=tabWidget->count() -1;i++)
1759 tabModel.at(i)->unselect();
1761 VymModel *m=currentModel();
1762 if (m) m->reselect();
1764 // Update actions to in menus and toolbars according to editor
1768 VymView *Main::createView (VymModel *model)
1770 VymView *vm=new VymView (model);
1775 void Main::fileNew()
1777 VymModel *m=new VymModel;
1778 tabModel.append (m);
1779 //MapEditor* me = new MapEditor (m);
1780 //me->setObjectName ("MapEditor");
1782 VymView *view=createView (m);
1783 tabWidget->addTab (view,tr("unnamed","MainWindow: name for new and empty file"));
1784 tabWidget->setCurrentIndex (tabModel.count() );
1786 // For the very first map we do not have flagrows yet...
1790 void Main::fileNewCopy()
1792 QString fn="unnamed";
1793 VymModel *srcModel=currentModel();
1798 VymModel *dstModel=tabModel.last ();
1799 dstModel->select("mc:");
1800 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1804 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1806 ErrorCode err=success;
1808 // fn is usually the archive, mapfile the file after uncompressing
1811 // Make fn absolute (needed for unzip)
1812 fn=QDir (fn).absPath();
1818 // Check, if map is already loaded
1820 while (i<=tabWidget->count() -1)
1822 if (tabModel.at(i)->getFilePath() == fn)
1824 // Already there, ask for confirmation
1825 QMessageBox mb( vymName,
1826 tr("The map %1\nis already opened."
1827 "Opening the same map in multiple editors may lead \n"
1828 "to confusion when finishing working with vym."
1829 "Do you want to").arg(fn),
1830 QMessageBox::Warning,
1831 QMessageBox::Yes | QMessageBox::Default,
1832 QMessageBox::Cancel | QMessageBox::Escape,
1833 QMessageBox::NoButton);
1834 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1835 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1838 case QMessageBox::Yes:
1839 // end loop and load anyway
1840 i=tabWidget->count();
1842 case QMessageBox::Cancel:
1852 int tabIndex=tabWidget->currentPageIndex();
1855 if ( !fn.isEmpty() )
1857 vm = currentModel();
1858 // Check first, if mapeditor exists
1859 // If it is not default AND we want a new map,
1860 // create a new mapeditor in a new tab
1861 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1864 tabModel.append (vm);
1865 VymView *view=createView (vm);
1866 tabWidget->addTab (view,fn);
1867 tabIndex=tabWidget->count()-1;
1868 tabWidget->setCurrentPage (tabIndex);
1871 // Check, if file exists (important for creating new files
1872 // from command line
1873 if (!QFile(fn).exists() )
1875 QMessageBox mb( vymName,
1876 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1877 QMessageBox::Question,
1879 QMessageBox::Cancel | QMessageBox::Default,
1880 QMessageBox::NoButton );
1882 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1883 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1886 case QMessageBox::Yes:
1888 currentMapEditor()->getModel()->setFilePath(fn);
1889 tabWidget->setTabText (tabIndex,
1890 currentMapEditor()->getModel()->getFileName() );
1891 statusBar()->message( "Created " + fn , statusbarTime );
1894 case QMessageBox::Cancel:
1895 // don't create new map
1896 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1903 //tabWidget->currentPage() won't be NULL here, because of above...
1904 tabWidget->setCurrentIndex (tabIndex);
1905 //FIXME no me anymore... me->viewport()->setFocus();
1909 // Save existing filename in case we import
1910 QString fn_org=vm->getFilePath();
1912 // Finally load map into mapEditor
1913 vm->setFilePath (fn);
1914 err=vm->load(fn,lmode,ftype);
1916 // Restore old (maybe empty) filepath, if this is an import
1918 vm->setFilePath (fn_org);
1921 // Finally check for errors and go home
1924 if (lmode==NewMap) fileCloseMap();
1925 statusBar()->message( "Could not load " + fn, statusbarTime );
1930 vm->setFilePath (fn);
1931 tabWidget->setTabText (tabIndex, vm->getFileName());
1932 if (!isInTmpDir (fn))
1934 // Only append to lastMaps if not loaded from a tmpDir
1935 // e.g. imported bookmarks are in a tmpDir
1936 addRecentMap(vm->getFilePath() );
1938 actionFilePrint->setEnabled (true);
1940 statusBar()->message( "Loaded " + fn, statusbarTime );
1947 void Main::fileLoad(const LoadMode &lmode)
1949 QStringList filters;
1950 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1951 QFileDialog *fd=new QFileDialog( this);
1952 fd->setDir (lastFileDir);
1953 fd->setFileMode (QFileDialog::ExistingFiles);
1954 fd->setFilters (filters);
1958 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1961 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1964 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1970 if ( fd->exec() == QDialog::Accepted )
1972 lastFileDir=fd->directory().path();
1973 QStringList flist = fd->selectedFiles();
1974 QStringList::Iterator it = flist.begin();
1975 while( it != flist.end() )
1978 fileLoad(*it, lmode);
1985 void Main::fileLoad()
1990 void Main::fileLoadRecent()
1992 QAction *action = qobject_cast<QAction *>(sender());
1994 fileLoad (action->data().toString(), NewMap);
1997 void Main::addRecentMap (const QString &fileName)
2000 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2001 files.removeAll(fileName);
2002 files.prepend(fileName);
2003 while (files.size() > MaxRecentFiles)
2006 settings.setValue("/mainwindow/recentFileList", files);
2008 setupRecentMapsMenu();
2011 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2015 if ( m->getFilePath().isEmpty() )
2017 // We have no filepath yet,
2018 // call fileSaveAs() now, this will call fileSave()
2020 // First switch to editor
2021 //FIXME needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2022 fileSaveAs(savemode);
2025 if (m->save (savemode)==success)
2027 statusBar()->message(
2028 tr("Saved %1").arg(m->getFilePath()),
2030 addRecentMap (m->getFilePath() );
2032 statusBar()->message(
2033 tr("Couldn't save ").arg(m->getFilePath()),
2037 void Main::fileSave()
2039 fileSave (currentModel(), CompleteMap);
2042 void Main::fileSave(VymModel *m)
2044 fileSave (m,CompleteMap);
2047 void Main::fileSaveAs(const SaveMode& savemode)
2051 if (currentMapEditor())
2053 if (savemode==CompleteMap)
2054 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2056 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2057 if ( !fn.isEmpty() )
2059 // Check for existing file
2060 if (QFile (fn).exists())
2062 QMessageBox mb( vymName,
2063 tr("The file %1\nexists already. Do you want to").arg(fn),
2064 QMessageBox::Warning,
2065 QMessageBox::Yes | QMessageBox::Default,
2066 QMessageBox::Cancel | QMessageBox::Escape,
2067 QMessageBox::NoButton);
2068 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2069 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2072 case QMessageBox::Yes:
2075 case QMessageBox::Cancel:
2082 // New file, add extension to filename, if missing
2083 // This is always .vym or .vyp, depending on savemode
2084 if (savemode==CompleteMap)
2086 if (!fn.contains (".vym") && !fn.contains (".xml"))
2090 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2099 VymModel *m=currentModel();
2101 fileSave(m, savemode);
2103 // Set name of tab, assuming current tab is the one we just saved
2104 if (savemode==CompleteMap)
2105 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2111 void Main::fileSaveAs()
2113 fileSaveAs (CompleteMap);
2116 void Main::fileImportKDE3Bookmarks()
2118 ImportKDE3Bookmarks im;
2120 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2121 currentMapEditor()->getModel()->setFilePath ("");
2124 void Main::fileImportKDE4Bookmarks()
2126 ImportKDE4Bookmarks im;
2128 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2129 currentMapEditor()->getModel()->setFilePath ("");
2132 void Main::fileImportFirefoxBookmarks()
2134 Q3FileDialog *fd=new Q3FileDialog( this);
2135 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2136 fd->setMode (Q3FileDialog::ExistingFiles);
2137 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2138 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2141 if ( fd->exec() == QDialog::Accepted )
2143 ImportFirefoxBookmarks im;
2144 QStringList flist = fd->selectedFiles();
2145 QStringList::Iterator it = flist.begin();
2146 while( it != flist.end() )
2149 if (im.transform() &&
2150 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2151 currentMapEditor() )
2152 currentMapEditor()->getModel()->setFilePath ("");
2159 void Main::fileImportFreemind()
2161 QStringList filters;
2162 filters <<"Freemind map (*.mm)"<<"All files (*)";
2163 QFileDialog *fd=new QFileDialog( this);
2164 fd->setDir (lastFileDir);
2165 fd->setFileMode (QFileDialog::ExistingFiles);
2166 fd->setFilters (filters);
2167 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2171 if ( fd->exec() == QDialog::Accepted )
2173 lastFileDir=fd->directory().path();
2174 QStringList flist = fd->selectedFiles();
2175 QStringList::Iterator it = flist.begin();
2176 while( it != flist.end() )
2179 if ( fileLoad (fn,NewMap, FreemindMap) )
2181 currentMapEditor()->getModel()->setFilePath ("");
2190 void Main::fileImportMM()
2194 Q3FileDialog *fd=new Q3FileDialog( this);
2195 fd->setDir (lastFileDir);
2196 fd->setMode (Q3FileDialog::ExistingFiles);
2197 fd->addFilter ("Mind Manager (*.mmap)");
2198 fd->setCaption(tr("Import")+" "+"Mind Manager");
2201 if ( fd->exec() == QDialog::Accepted )
2203 lastFileDir=fd->dirPath();
2204 QStringList flist = fd->selectedFiles();
2205 QStringList::Iterator it = flist.begin();
2206 while( it != flist.end() )
2209 if (im.transform() &&
2210 success==fileLoad (im.getTransformedFile(),NewMap) &&
2211 currentMapEditor() )
2212 currentMapEditor()->getModel()->setFilePath ("");
2219 void Main::fileImportDir()
2221 VymModel *m=currentModel();
2222 if (m) m->importDir();
2225 void Main::fileExportXML()
2227 VymModel *m=currentModel();
2228 if (m) m->exportXML();
2232 void Main::fileExportXHTML()
2234 VymModel *m=currentModel();
2235 if (m) m->exportXHTML();
2238 void Main::fileExportImage()
2240 VymModel *m=currentModel();
2241 if (m) m->exportImage();
2244 void Main::fileExportASCII()
2246 VymModel *m=currentModel();
2247 if (m) m->exportASCII();
2250 void Main::fileExportCSV() //FIXME not scriptable yet
2252 VymModel *m=currentModel();
2257 ex.addFilter ("CSV (*.csv)");
2258 ex.setDir(lastImageDir);
2259 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2260 if (ex.execDialog() )
2262 m->setExportMode(true);
2264 m->setExportMode(false);
2269 void Main::fileExportLaTeX() //FIXME not scriptable yet
2271 VymModel *m=currentModel();
2276 ex.addFilter ("Tex (*.tex)");
2277 ex.setDir(lastImageDir);
2278 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2279 if (ex.execDialog() )
2281 m->setExportMode(true);
2283 m->setExportMode(false);
2288 void Main::fileExportKDE3Bookmarks() //FIXME not scriptable yet
2290 ExportKDE3Bookmarks ex;
2291 VymModel *m=currentModel();
2299 void Main::fileExportKDE4Bookmarks() //FIXME not scriptable yet
2301 ExportKDE4Bookmarks ex;
2302 VymModel *m=currentModel();
2310 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2312 ExportTaskjuggler ex;
2313 VymModel *m=currentModel();
2317 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2318 ex.setDir(lastImageDir);
2319 ex.addFilter ("Taskjuggler (*.tjp)");
2320 if (ex.execDialog() )
2322 m->setExportMode(true);
2324 m->setExportMode(false);
2329 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2331 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2332 // TODO add preview in dialog
2333 //ImagePreview *p =new ImagePreview (fd);
2334 //fd->setContentsPreviewEnabled( TRUE );
2335 //fd->setContentsPreview( p, p );
2336 //fd->setPreviewMode( QFileDialog::Contents );
2337 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2338 fd->setDir (QDir().current());
2339 if (fd->foundConfig())
2343 if ( fd->exec() == QDialog::Accepted )
2345 QString fn=fd->selectedFile();
2346 if (!fn.contains (".odp"))
2349 //lastImageDir=fn.left(fn.findRev ("/"));
2350 VymModel *m=currentModel();
2351 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2355 QMessageBox::warning(0,
2357 tr("Couldn't find configuration for export to Open Office\n"));
2361 void Main::fileCloseMap()
2363 MapEditor *me = currentMapEditor();
2364 VymModel *m=currentModel();
2367 if (m->hasChanged())
2369 QMessageBox mb( vymName,
2370 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
2371 QMessageBox::Warning,
2372 QMessageBox::Yes | QMessageBox::Default,
2374 QMessageBox::Cancel | QMessageBox::Escape );
2375 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2376 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2379 case QMessageBox::Yes:
2381 fileSave(m, CompleteMap);
2383 case QMessageBox::No:
2384 // close without saving
2386 case QMessageBox::Cancel:
2391 tabModel.removeAt (tabWidget->currentIndex() );
2392 tabWidget->removeTab (tabWidget->currentIndex() );
2394 // Remove mapEditor;
2395 // Better would be delete (me), but then we could have a Qt error:
2396 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2397 // So we only remove data now and call deconstructor when vym closes later
2398 // FIXME this needs to be moved to vymview... me->clear();
2399 // some model->clear is needed to free up memory ...
2405 void Main::filePrint()
2407 if (currentMapEditor())
2408 currentMapEditor()->print();
2411 void Main::fileExitVYM()
2413 // Check if one or more editors have changed
2415 for (i=0;i<=tabModel.count() -1;i++)
2417 // If something changed, ask what to do
2418 if (tabModel.at(i)->hasChanged())
2420 tabWidget->setCurrentPage(i);
2421 QMessageBox mb( vymName,
2422 tr("This map is not saved yet. Do you want to"),
2423 QMessageBox::Warning,
2424 QMessageBox::Yes | QMessageBox::Default,
2426 QMessageBox::Cancel | QMessageBox::Escape );
2427 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2428 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2431 mb.setActiveWindow();
2432 switch( mb.exec() ) {
2433 case QMessageBox::Yes:
2434 // save (the changed editors) and exit
2435 fileSave(currentModel(), CompleteMap);
2437 case QMessageBox::No:
2438 // exit without saving
2440 case QMessageBox::Cancel:
2441 // don't save and don't exit
2445 } // loop over all MEs
2449 void Main::editUndo()
2451 VymModel *m=currentModel();
2455 void Main::editRedo()
2457 VymModel *m=currentModel();
2461 void Main::gotoHistoryStep (int i)
2463 VymModel *m=currentModel();
2464 if (m) m->gotoHistoryStep(i);
2467 void Main::editCopy()
2469 VymModel *m=currentModel();
2473 void Main::editPaste()
2475 VymModel *m=currentModel();
2479 void Main::editCut()
2481 VymModel *m=currentModel();
2485 void Main::editOpenFindWindow()
2487 findWindow->popup();
2488 findWindow->raise();
2489 findWindow->setActiveWindow();
2492 void Main::editFind(QString s)
2494 VymModel *m=currentModel();
2498 BranchObj *bo=m->findText(s, cs);
2501 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2504 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2505 tr("No matches found for \"%1\"").arg(s));
2510 void Main::editFindChanged()
2511 { // Notify editor, to abort the current find process
2512 VymModel *m=currentModel();
2513 if (m) m->findReset();
2516 void Main::openTabs(QStringList urls)
2518 if (!urls.isEmpty())
2522 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2524 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2526 QString u=urls.takeFirst();
2527 procBrowser = new QProcess( this );
2529 procBrowser->start(browser,args);
2530 if ( !procBrowser->waitForStarted())
2532 // try to set path to browser
2533 QMessageBox::warning(0,
2535 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2536 tr("Please use Settings->")+tr("Set application to open an URL"));
2539 #if defined(Q_OS_WIN32)
2540 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2541 this->thread()->wait(3000);
2546 if (browser.contains("konqueror"))
2548 for (int i=0; i<urls.size(); i++)
2551 // Try to open new tab in existing konqueror started previously by vym
2552 p=new QProcess (this);
2554 #if defined(Q_OS_WIN32)
2555 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2556 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2557 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2558 "konqueror-mainwindow#1"<<
2562 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2563 "konqueror-mainwindow#1"<<
2567 p->start ("dcop",args);
2568 //cout << qPrintable (args.join(" "))<<endl;
2569 if ( !p->waitForStarted() ) success=false;
2572 QMessageBox::warning(0,
2574 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2576 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2578 for (int i=0; i<urls.size(); i++)
2580 // Try to open new tab in firefox
2581 p=new QProcess (this);
2582 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2583 p->start (browser,args);
2584 if ( !p->waitForStarted() ) success=false;
2587 QMessageBox::warning(0,
2589 tr("Couldn't start %1 to open a new tab").arg(browser));
2592 QMessageBox::warning(0,
2594 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2598 void Main::editOpenURL()
2601 VymModel *m=currentModel();
2604 QString url=m->getURL();
2606 if (url=="") return;
2607 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2608 procBrowser = new QProcess( this );
2610 procBrowser->start(browser,args);
2611 if ( !procBrowser->waitForStarted())
2613 // try to set path to browser
2614 QMessageBox::warning(0,
2616 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2617 tr("Please use Settings->")+tr("Set application to open an URL"));
2622 void Main::editOpenURLTab()
2624 VymModel *m=currentModel();
2628 urls.append(m->getURL());
2632 void Main::editOpenMultipleURLTabs()
2634 VymModel *m=currentModel();
2644 void Main::editURL()
2646 VymModel *m=currentModel();
2647 if (m) m->editURL();
2650 void Main::editLocalURL()
2652 VymModel *m=currentModel();
2653 if (m) m->editLocalURL();
2656 void Main::editHeading2URL()
2658 VymModel *m=currentModel();
2659 if (m) m->editHeading2URL();
2662 void Main::editBugzilla2URL()
2664 VymModel *m=currentModel();
2665 if (m) m->editBugzilla2URL();
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);
2686 void Main::editAttributeFinished()
2688 // only called from editHeading(), so there is a currentME
2691 MapEditor *me=currentMapEditor();
2694 me->setStateEditHeading (false);
2695 QPoint p; //Not used here, only to find out pos of branch
2697 QString s=me->getHeading(ok,p);
2699 #if defined(Q_OS_MACX)
2701 if (ok && s!=lineedit->text())
2702 me->setHeading(lineedit->text());
2704 lineedit->releaseKeyboard();
2708 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2709 !prevSelection.isEmpty())
2710 me->select(prevSelection);
2716 #include "attribute.h"
2717 #include "attributedialog.h"
2718 void Main::editAttribute()
2721 MapEditor *me=currentMapEditor();
2724 BranchObj *bo=me->getModel()->getSelectedBranch();
2727 AttributeDialog dia(this);
2728 dia.setTable (me->attributeTable() );
2730 dia.setMode (Definition);
2737 if (currentMapEditor())
2739 MapEditor *me=currentMapEditor();
2740 QString oldSel=me->getSelectString();
2742 if (lineedit->isVisible())
2743 editAttributeFinished();
2748 QString s=me->getHeading(ok,p);
2752 me->setStateEditHeading (true);
2753 #if defined(Q_OS_MACX)
2754 p=me->mapToGlobal (p);
2755 QDialog *d =new QDialog(NULL);
2756 QLineEdit *le=new QLineEdit (d);
2757 d->setWindowFlags (Qt::FramelessWindowHint);
2758 d->setGeometry(p.x(),p.y(),230,25);
2759 le->resize (d->width()-10,d->height());
2762 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2763 d->activateWindow();
2765 me->setHeading (le->text());
2768 editHeadingFinished();
2770 p=me->mapTo (this,p);
2771 lineedit->setGeometry(p.x(),p.y(),230,25);
2772 lineedit->setText(s);
2773 lineedit->setCursorPosition(1);
2774 lineedit->selectAll();
2776 lineedit->grabKeyboard();
2777 lineedit->setFocus();
2781 } // currentMapEditor()
2786 void Main::openVymLinks(const QStringList &vl)
2788 for (int j=0; j<vl.size(); j++)
2790 // compare path with already loaded maps
2793 for (i=0;i<=tabModel.count() -1;i++)
2795 if (vl.at(j)==tabModel.at(i)->getFilePath() )
2804 if (!QFile(vl.at(j)).exists() )
2805 QMessageBox::critical( 0, tr( "Critical Error" ),
2806 tr("Couldn't open map %1").arg(vl.at(j)));
2809 fileLoad (vl.at(j), NewMap);
2810 tabWidget->setCurrentIndex (tabWidget->count()-1);
2813 // Go to tab containing the map
2814 tabWidget->setCurrentIndex (index);
2818 void Main::editOpenVymLink()
2820 VymModel *m=currentModel();
2824 vl.append(m->getVymLink());
2829 void Main::editOpenMultipleVymLinks()
2831 QString currentVymLink;
2832 VymModel *m=currentModel();
2835 QStringList vl=m->getVymLinks();
2840 void Main::editVymLink()
2842 VymModel *m=currentModel();
2847 void Main::editDeleteVymLink()
2849 VymModel *m=currentModel();
2850 if (m) m->deleteVymLink();
2853 void Main::editToggleHideExport()
2855 VymModel *m=currentModel();
2856 if (m) m->toggleHideExport();
2859 void Main::editMapInfo()
2861 VymModel *m=currentModel();
2863 ExtraInfoDialog dia;
2864 dia.setMapName (m->getFileName() );
2865 dia.setAuthor (m->getAuthor() );
2866 dia.setComment(m->getComment() );
2870 /* FIXME no stats at the moment (view dependent...)
2871 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2881 if (!bo->getNote().isEmpty() ) n++;
2882 f+= bo->countFloatImages();
2884 xl+=bo->countXLinks();
2887 stats+=QString ("%1 xLinks \n").arg (xl,6);
2888 stats+=QString ("%1 notes\n").arg (n,6);
2889 stats+=QString ("%1 images\n").arg (f,6);
2891 stats+=QString ("%1 branches\n").arg (m->countBranches(),6);
2892 dia.setStats (stats);
2894 // Finally show dialog
2895 if (dia.exec() == QDialog::Accepted)
2897 m->setAuthor (dia.getAuthor() );
2898 m->setComment (dia.getComment() );
2902 void Main::editMoveUp()
2904 VymModel *m=currentModel();
2905 if (m) m->moveBranchUp();
2908 void Main::editMoveDown()
2910 VymModel *m=currentModel();
2911 if (m) m->moveBranchDown();
2914 void Main::editSortChildren()
2916 VymModel *m=currentModel();
2917 if (m) m->sortChildren();
2920 void Main::editToggleScroll()
2922 VymModel *m=currentModel();
2923 if (m) m->toggleScroll();
2926 void Main::editUnscrollChildren()
2928 VymModel *m=currentModel();
2929 if (m) m->unscrollChildren();
2932 void Main::editAddMapCenter()
2934 VymModel *m=currentModel();
2941 void Main::editNewBranch()
2943 VymModel *m=currentModel();
2946 BranchObj *bo=m->getSelectedBranch();
2947 prevSelection=m->getSelectString(bo);
2948 BranchObj *newbo=m->addNewBranch(0);
2955 if (actionSettingsAutoEditNewBranch->isOn())
2957 currentMapEditor()->editHeading();
2960 if (!prevSelection.isEmpty())
2962 m->select(prevSelection);
2968 void Main::editNewBranchBefore()
2970 VymModel *m=currentModel();
2973 BranchObj *bo=m->getSelectedBranch();
2974 BranchObj *newbo=m->addNewBranchBefore();
2981 if (actionSettingsAutoEditNewBranch->isOn())
2983 if (!actionSettingsAutoSelectNewBranch->isOn())
2984 prevSelection=m->getSelectString(bo);
2985 currentMapEditor()->editHeading();
2990 void Main::editNewBranchAbove()
2992 VymModel *m=currentModel();
2995 BranchObj *bo=m->getSelectedBranch();
2996 BranchObj *newbo=m->addNewBranch (-1);
3003 if (actionSettingsAutoEditNewBranch->isOn())
3005 if (!actionSettingsAutoSelectNewBranch->isOn())
3006 prevSelection=m->getSelectString (bo);
3007 currentMapEditor()->editHeading();
3012 void Main::editNewBranchBelow()
3014 VymModel *m=currentModel();
3017 BranchObj *bo=m->getSelectedBranch();
3018 BranchObj *newbo=m->addNewBranch (1);
3025 if (actionSettingsAutoEditNewBranch->isOn())
3027 if (!actionSettingsAutoSelectNewBranch->isOn())
3028 prevSelection=m->getSelectString(bo);
3029 currentMapEditor()->editHeading();
3034 void Main::editImportAdd()
3036 fileLoad (ImportAdd);
3039 void Main::editImportReplace()
3041 fileLoad (ImportReplace);
3044 void Main::editSaveBranch()
3046 fileSaveAs (PartOfMap);
3049 void Main::editDeleteKeepChildren()
3051 VymModel *m=currentModel();
3052 if (m) m->deleteKeepChildren();
3055 void Main::editDeleteChildren()
3057 VymModel *m=currentModel();
3058 if (m) m->deleteChildren();
3061 void Main::editDeleteSelection()
3063 VymModel *m=currentModel();
3064 if (m && actionSettingsUseDelKey->isOn())
3065 m->deleteSelection();
3068 void Main::editUpperBranch()
3070 VymModel *m=currentModel();
3071 if (m) m->selectUpperBranch();
3074 void Main::editLowerBranch()
3076 VymModel *m=currentModel();
3077 if (m) m->selectLowerBranch();
3080 void Main::editLeftBranch()
3082 VymModel *m=currentModel();
3083 if (m) m->selectLeftBranch();
3086 void Main::editRightBranch()
3088 VymModel *m=currentModel();
3089 if (m) m->selectRightBranch();
3092 void Main::editFirstBranch()
3094 VymModel *m=currentModel();
3095 if (m) m->selectFirstBranch();
3098 void Main::editLastBranch()
3100 VymModel *m=currentModel();
3101 if (m) m->selectLastBranch();
3104 void Main::editLoadImage()
3106 VymModel *m=currentModel();
3107 if (m) m->loadFloatImage();
3110 void Main::editSaveImage()
3112 VymModel *m=currentModel();
3113 if (m) m->saveFloatImage();
3116 void Main::editFollowXLink(QAction *a)
3119 VymModel *m=currentModel();
3121 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3124 void Main::editEditXLink(QAction *a)
3126 VymModel *m=currentModel();
3128 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3131 void Main::formatSelectColor()
3133 QColor col = QColorDialog::getColor((currentColor ), this );
3134 if ( !col.isValid() ) return;
3135 colorChanged( col );
3138 void Main::formatPickColor()
3140 VymModel *m=currentModel();
3142 colorChanged( m->getCurrentHeadingColor() );
3145 void Main::colorChanged(QColor c)
3147 QPixmap pix( 16, 16 );
3149 actionFormatColor->setIconSet( pix );
3153 void Main::formatColorBranch()
3155 VymModel *m=currentModel();
3156 if (m) m->colorBranch(currentColor);
3159 void Main::formatColorSubtree()
3161 VymModel *m=currentModel();
3162 if (m) m->colorSubtree (currentColor);
3165 void Main::formatLinkStyleLine()
3167 VymModel *m=currentModel();
3170 m->setMapLinkStyle("StyleLine");
3171 actionFormatLinkStyleLine->setOn(true);
3175 void Main::formatLinkStyleParabel()
3177 VymModel *m=currentModel();
3180 m->setMapLinkStyle("StyleParabel");
3181 actionFormatLinkStyleParabel->setOn(true);
3185 void Main::formatLinkStylePolyLine()
3187 VymModel *m=currentModel();
3190 m->setMapLinkStyle("StylePolyLine");
3191 actionFormatLinkStylePolyLine->setOn(true);
3195 void Main::formatLinkStylePolyParabel()
3197 VymModel *m=currentModel();
3200 m->setMapLinkStyle("StylePolyParabel");
3201 actionFormatLinkStylePolyParabel->setOn(true);
3205 void Main::formatSelectBackColor()
3207 VymModel *m=currentModel();
3208 if (m) m->selectMapBackgroundColor();
3211 void Main::formatSelectBackImage()
3213 VymModel *m=currentModel();
3215 m->selectMapBackgroundImage();
3218 void Main::formatSelectLinkColor()
3220 VymModel *m=currentModel();
3223 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3224 m->setMapDefLinkColor( col );
3228 void Main::formatSelectSelectionColor()
3230 VymModel *m=currentModel();
3233 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3234 m->setSelectionColor (col);
3239 void Main::formatToggleLinkColorHint()
3241 VymModel *m=currentModel();
3242 if (m) m->toggleMapLinkColorHint();
3246 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3248 VymModel *m=currentModel();
3250 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3253 void Main::viewZoomReset()
3255 if (currentMapEditor())
3259 currentMapEditor()->setMatrix( m );
3263 void Main::viewZoomIn()
3265 if (currentMapEditor())
3267 QMatrix m = currentMapEditor()->matrix();
3268 m.scale( 1.25, 1.25 );
3269 currentMapEditor()->setMatrix( m );
3273 void Main::viewZoomOut()
3275 if (currentMapEditor())
3277 QMatrix m = currentMapEditor()->matrix();
3278 m.scale( 0.8, 0.8 );
3279 currentMapEditor()->setMatrix( m );
3283 void Main::viewCenter()
3285 VymModel *m=currentModel();
3286 if (m) m->ensureSelectionVisible();
3289 void Main::networkStartServer()
3291 VymModel *m=currentModel();
3292 if (m) m->newServer();
3295 void Main::networkConnect()
3297 VymModel *m=currentModel();
3298 if (m) m->connectToServer();
3301 bool Main::settingsPDF()
3303 // Default browser is set in constructor
3305 QString text = QInputDialog::getText(
3306 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3307 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3309 settings.setValue ("/mainwindow/readerPDF",text);
3314 bool Main::settingsURL()
3316 // Default browser is set in constructor
3318 QString text = QInputDialog::getText(
3319 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3320 settings.value("/mainwindow/readerURL").toString()
3323 settings.setValue ("/mainwindow/readerURL",text);
3327 void Main::settingsMacroDir()
3329 QDir defdir(vymBaseDir.path() + "/macros");
3330 if (!defdir.exists())
3332 QDir dir=QFileDialog::getExistingDirectory (
3334 tr ("Directory with vym macros:"),
3335 settings.value ("/macros/macroDir",defdir.path()).toString()
3338 settings.setValue ("/macros/macroDir",dir.absolutePath());
3341 void Main::settingsUndoLevels()
3344 int i = QInputDialog::getInteger(
3346 tr("QInputDialog::getInteger()"),
3347 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3350 settings.setValue ("/mapeditor/stepsTotal",i);
3351 QMessageBox::information( this, tr( "VYM -Information:" ),
3352 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3356 void Main::settingsAutosaveToggle()
3358 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3361 void Main::settingsAutosaveTime()
3364 int i = QInputDialog::getInteger(
3366 tr("QInputDialog::getInteger()"),
3367 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3369 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3372 void Main::settingsWriteBackupFileToggle()
3374 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3377 void Main::settingsToggleAnimation()
3379 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3382 void Main::settingsToggleDelKey()
3384 if (actionSettingsUseDelKey->isOn())
3386 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3389 actionDelete->setAccel (QKeySequence (""));
3393 void Main::windowToggleNoteEditor()
3395 if (textEditor->isVisible() )
3396 windowHideNoteEditor();
3398 windowShowNoteEditor();
3401 void Main::windowToggleHistory()
3403 if (historyWindow->isVisible())
3404 historyWindow->hide();
3406 historyWindow->show();
3410 void Main::windowToggleProperty()
3412 if (branchPropertyWindow->isVisible())
3413 branchPropertyWindow->hide();
3415 branchPropertyWindow->show();
3416 branchPropertyWindow->setModel (currentModel() );
3419 void Main::windowToggleAntiAlias()
3421 bool b=actionViewToggleAntiAlias->isOn();
3423 for (int i=0;i<tabModel.count();i++)
3425 me=tabModel.at(i)->getMapEditor();
3426 if (me) me->setAntiAlias(b);
3431 bool Main::isAliased()
3433 return actionViewToggleAntiAlias->isOn();
3436 bool Main::hasSmoothPixmapTransform()
3438 return actionViewToggleSmoothPixmapTransform->isOn();
3441 void Main::windowToggleSmoothPixmap()
3443 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3445 for (int i=0;i<tabModel.count();i++)
3448 me=tabModel.at(i)->getMapEditor();
3449 if (me) me->setSmoothPixmap(b);
3453 void Main::updateHistory(SimpleSettings &undoSet)
3455 historyWindow->update (undoSet);
3458 void Main::updateNoteFlag()
3460 // this slot is connected to TextEditor::textHasChanged()
3462 VymModel *m=currentModel();
3463 if (m) m->updateNoteFlag();
3466 void Main::updateSatellites(VymModel* model)
3468 branchPropertyWindow->setModel (model );
3471 void Main::updateActions()
3473 VymModel *m =currentModel();
3474 LinkableMapObj *selection;
3478 actionFilePrint->setEnabled (true);
3481 selection=m->getSelectedLMO();
3483 // Link style in context menu
3484 switch (m->getMapLinkStyle())
3486 case LinkableMapObj::Line:
3487 actionFormatLinkStyleLine->setOn(true);
3489 case LinkableMapObj::Parabel:
3490 actionFormatLinkStyleParabel->setOn(true);
3492 case LinkableMapObj::PolyLine:
3493 actionFormatLinkStylePolyLine->setOn(true);
3495 case LinkableMapObj::PolyParabel:
3496 actionFormatLinkStylePolyParabel->setOn(true);
3503 QPixmap pix( 16, 16 );
3504 pix.fill( m->getMapBackgroundColor() );
3505 actionFormatBackColor->setIconSet( pix );
3506 pix.fill( m->getSelectionColor() );
3507 actionFormatSelectionColor->setIconSet( pix );
3508 pix.fill( m->getMapDefLinkColor() );
3509 actionFormatLinkColor->setIconSet( pix );
3512 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3517 actionFilePrint->setEnabled (false);
3523 // updateActions is also called when NoteEditor is closed
3524 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3525 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3526 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3528 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3529 actionFormatLinkColorHint->setOn(true);
3531 actionFormatLinkColorHint->setOn(false);
3534 if (m && m->hasChanged() )
3535 actionFileSave->setEnabled( true);
3537 actionFileSave->setEnabled( true);
3538 if (m && m->isUndoAvailable())
3539 actionUndo->setEnabled( true);
3541 actionUndo->setEnabled( false);
3543 if (m && m->isRedoAvailable())
3544 actionRedo->setEnabled( true);
3546 actionRedo->setEnabled( false);
3550 if ( (typeid(*selection) == typeid(BranchObj)) ||
3551 (typeid(*selection) == typeid(MapCenterObj)) )
3553 BranchObj *bo=(BranchObj*)selection;
3554 // Take care of links
3555 if (bo->countXLinks()==0)
3557 branchXLinksContextMenuEdit->clear();
3558 branchXLinksContextMenuFollow->clear();
3563 branchXLinksContextMenuEdit->clear();
3564 branchXLinksContextMenuFollow->clear();
3565 for (int i=0; i<=bo->countXLinks();i++)
3567 bot=bo->XLinkTargetAt(i);
3570 s=bot->getHeading();
3571 if (s.length()>xLinkMenuWidth)
3572 s=s.left(xLinkMenuWidth)+"...";
3573 branchXLinksContextMenuFollow->addAction (s);
3574 branchXLinksContextMenuEdit->addAction (s);
3579 standardFlagsDefault->setEnabled (true);
3581 actionToggleScroll->setEnabled (true);
3582 if ( bo->isScrolled() )
3583 actionToggleScroll->setOn(true);
3585 actionToggleScroll->setOn(false);
3587 if ( bo->getURL().isEmpty() )
3589 actionOpenURL->setEnabled (false);
3590 actionOpenURLTab->setEnabled (false);
3594 actionOpenURL->setEnabled (true);
3595 actionOpenURLTab->setEnabled (true);
3597 if ( bo->getVymLink().isEmpty() )
3599 actionOpenVymLink->setEnabled (false);
3600 actionDeleteVymLink->setEnabled (false);
3603 actionOpenVymLink->setEnabled (true);
3604 actionDeleteVymLink->setEnabled (true);
3607 if (bo->canMoveBranchUp())
3608 actionMoveUp->setEnabled (true);
3610 actionMoveUp->setEnabled (false);
3611 if (bo->canMoveBranchDown())
3612 actionMoveDown->setEnabled (true);
3614 actionMoveDown->setEnabled (false);
3616 actionSortChildren->setEnabled (true);
3618 actionToggleHideExport->setEnabled (true);
3619 actionToggleHideExport->setOn (bo->hideInExport() );
3621 actionFileSave->setEnabled (true);
3622 actionCopy->setEnabled (true);
3623 actionCut->setEnabled (true);
3624 if (!clipboardEmpty)
3625 actionPaste->setEnabled (true);
3627 actionPaste->setEnabled (false);
3628 for (int i=0; i<actionListBranches.size(); ++i)
3629 actionListBranches.at(i)->setEnabled(true);
3630 actionDelete->setEnabled (true);
3631 actionFormatHideLinkUnselected->setOn
3632 (selection->getHideLinkUnselected());
3634 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3636 FloatObj *fo=(FloatImageObj*)selection;
3638 actionOpenURL->setEnabled (false);
3639 actionOpenVymLink->setEnabled (false);
3640 actionDeleteVymLink->setEnabled (false);
3641 actionToggleHideExport->setEnabled (true);
3642 actionToggleHideExport->setOn (fo->hideInExport() );
3645 actionCopy->setEnabled (true);
3646 actionCut->setEnabled (true);
3647 actionPaste->setEnabled (false);
3648 for (int i=0; i<actionListBranches.size(); ++i)
3649 actionListBranches.at(i)->setEnabled(false);
3650 actionDelete->setEnabled (true);
3651 actionFormatHideLinkUnselected->setOn
3652 ( selection->getHideLinkUnselected());
3653 actionMoveUp->setEnabled (false);
3654 actionMoveDown->setEnabled (false);
3659 standardFlagsDefault->setEnabled (false);
3660 actionFileSave->setEnabled (false);
3661 actionCopy->setEnabled (false);
3662 actionCut->setEnabled (false);
3663 actionPaste->setEnabled (false);
3664 for (int i=0; i<actionListBranches.size(); ++i)
3665 actionListBranches.at(i)->setEnabled(false);
3667 actionToggleScroll->setEnabled (false);
3668 actionOpenURL->setEnabled (false);
3669 actionOpenVymLink->setEnabled (false);
3670 actionDeleteVymLink->setEnabled (false);
3671 actionHeading2URL->setEnabled (false);
3672 actionDelete->setEnabled (false);
3673 actionMoveUp->setEnabled (false);
3674 actionMoveDown->setEnabled (false);
3675 actionSortChildren->setEnabled (false);
3676 actionToggleHideExport->setEnabled (false);
3680 Main::ModMode Main::getModMode()
3682 if (actionModModeColor->isOn()) return ModModeColor;
3683 if (actionModModeCopy->isOn()) return ModModeCopy;
3684 if (actionModModeXLink->isOn()) return ModModeXLink;
3688 bool Main::autoEditNewBranch()
3690 return actionSettingsAutoEditNewBranch->isOn();
3693 bool Main::autoSelectNewBranch()
3695 return actionSettingsAutoSelectNewBranch->isOn();
3698 bool Main::useFlagGroups()
3700 return actionSettingsUseFlagGroups->isOn();
3703 void Main::windowShowNoteEditor()
3705 textEditor->setShowWithMain(true);
3707 actionViewToggleNoteEditor->setOn (true);
3710 void Main::windowHideNoteEditor()
3712 textEditor->setShowWithMain(false);
3714 actionViewToggleNoteEditor->setOn (false);
3717 void Main::setScript (const QString &script)
3719 scriptEditor->setScript (script);
3722 void Main::runScript (const QString &script)
3724 VymModel *m=currentModel();
3725 if (m) m->runScript (script);
3728 void Main::runScriptEverywhere (const QString &script)
3731 for (int i=0;i<=tabWidget->count() -1;i++)
3733 me=(MapEditor*)tabWidget->page(i);
3734 if (me) me->getModel()->runScript (script);
3738 void Main::windowNextEditor()
3740 if (tabWidget->currentIndex() < tabWidget->count())
3741 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3744 void Main::windowPreviousEditor()
3746 if (tabWidget->currentIndex() >0)
3747 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3750 void Main::standardFlagChanged()
3752 if (currentMapEditor())
3753 currentMapEditor()->toggleStandardFlag(sender()->name());
3756 void Main::testFunction1()
3758 if (!currentMapEditor()) return;
3759 currentMapEditor()->testFunction1();
3763 void Main::testFunction2()
3765 if (!currentMapEditor()) return;
3766 currentMapEditor()->testFunction2();
3769 void Main::testCommand()
3771 if (!currentMapEditor()) return;
3772 scriptEditor->show();
3775 QString com = QInputDialog::getText(
3776 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3777 if (ok) currentMapEditor()->parseAtom(com);
3781 void Main::helpDoc()
3783 QString locale = QLocale::system().name();
3785 if (locale.left(2)=="es")
3786 docname="vym_es.pdf";
3790 QStringList searchList;
3792 #if defined(Q_OS_MACX)
3793 searchList << "./vym.app/Contents/Resources/doc";
3794 #elif defined(Q_OS_WIN32)
3795 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3797 #if defined(VYM_DOCDIR)
3798 searchList << VYM_DOCDIR;
3800 // default path in SUSE LINUX
3801 searchList << "/usr/share/doc/packages/vym";
3804 searchList << "doc"; // relative path for easy testing in tarball
3805 searchList << "doc/tex"; // Easy testing working on vym.tex
3806 searchList << "/usr/share/doc/vym"; // Debian
3807 searchList << "/usr/share/doc/packages";// Knoppix
3811 for (int i=0; i<searchList.count(); ++i)
3813 docfile.setFileName(searchList.at(i)+"/"+docname);
3814 if (docfile.exists())
3823 QMessageBox::critical(0,
3824 tr("Critcal error"),
3825 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3830 Process *pdfProc = new Process();
3831 args << QDir::toNativeSeparators(docfile.fileName());
3833 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3834 if ( !pdfProc->waitForStarted() )
3837 QMessageBox::warning(0,
3839 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3840 tr("Please use Settings->")+tr("Set application to open PDF files"));
3847 void Main::helpDemo()
3849 QStringList filters;
3850 filters <<"VYM example map (*.vym)";
3851 QFileDialog *fd=new QFileDialog( this);
3852 #if defined(Q_OS_MACX)
3853 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3855 // default path in SUSE LINUX
3856 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3859 fd->setFileMode (QFileDialog::ExistingFiles);
3860 fd->setFilters (filters);
3861 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3865 if ( fd->exec() == QDialog::Accepted )
3867 lastFileDir=fd->directory().path();
3868 QStringList flist = fd->selectedFiles();
3869 QStringList::Iterator it = flist.begin();
3870 while( it != flist.end() )
3873 fileLoad(*it, NewMap);
3881 void Main::helpAbout()
3884 ad.setName ("aboutwindow");
3885 ad.setMinimumSize(500,500);
3886 ad.resize (QSize (500,500));
3890 void Main::helpAboutQT()
3892 QMessageBox::aboutQt( this, "Qt Application Example" );
3895 void Main::callMacro ()
3897 QAction *action = qobject_cast<QAction *>(sender());
3901 i=action->data().toInt();
3902 QString mDir (settings.value ("macros/macroDir").toString() );
3904 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3906 if ( !f.open( QIODevice::ReadOnly ) )
3908 QMessageBox::warning(0,
3910 tr("Couldn't find a macro at %1.\n").arg(fn)+
3911 tr("Please use Settings->")+tr("Set directory for vym macros"));
3915 QTextStream ts( &f );
3916 QString macro= ts.read();
3918 if (! macro.isEmpty())
3920 VymModel *m=currentModel();
3921 if (m) m->runScript(macro);