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 //////////////////////////////////////////
126 historyWindow=new HistoryWindow();
127 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
130 branchPropertyWindow = new BranchPropertyWindow();
131 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
133 // Connect TextEditor, so that we can update flags if text changes
134 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
135 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
137 // Connect HistoryWindow, so that we can update flags
138 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
141 // Initialize script editor
142 scriptEditor = new SimpleScriptEditor();
143 scriptEditor->move (50,50);
145 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
146 this, SLOT( runScript( QString ) ) );
149 // Initialize Find window
150 findWindow=new FindWindow(NULL);
151 findWindow->move (x(),y()+70);
152 connect (findWindow, SIGNAL( findButton(QString) ),
153 this, SLOT(editFind(QString) ) );
154 connect (findWindow, SIGNAL( somethingChanged() ),
155 this, SLOT(editFindChanged() ) );
157 // Initialize some settings, which are platform dependant
160 // application to open URLs
161 p="/mainwindow/readerURL";
162 #if defined(Q_OS_LINUX)
163 s=settings.value (p,"xdg-open").toString();
165 #if defined(Q_OS_MACX)
166 s=settings.value (p,"/usr/bin/open").toString();
169 #if defined(Q_OS_WIN32)
170 // Assume that system has been set up so that
171 // Explorer automagically opens up the URL
172 // in the user's preferred browser.
173 s=settings.value (p,"explorer").toString();
175 s=settings.value (p,"mozilla").toString();
179 settings.setValue( p,s);
181 // application to open PDFs
182 p="/mainwindow/readerPDF";
183 #if defined(Q_OS_LINUX)
184 s=settings.value (p,"xdg-open").toString();
186 #if defined(Q_OS_MACX)
187 s=settings.value (p,"/usr/bin/open").toString();
188 #elif defined(Q_OS_WIN32)
189 s=settings.value (p,"acrord32").toString();
191 s=settings.value (p,"acroread").toString();
194 settings.setValue( p,s);
196 // width of xLinksMenu
199 // Create tab widget which holds the maps
200 tabWidget= new QTabWidget (this);
201 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
202 this, SLOT( editorChanged( QWidget * ) ) );
204 setCentralWidget(tabWidget);
208 setupFormatActions();
212 setupNetworkActions();
213 setupSettingsActions();
216 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
219 // Status bar and progress bar there
222 progressBar=new QProgressBar;
224 statusBar()->addPermanentWidget(progressBar);
226 restoreState (settings.value("/mainwindow/state",0).toByteArray());
234 #if defined(Q_OS_WIN32)
235 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
237 settings.setValue ("/mainwindow/geometry/size", size());
238 settings.setValue ("/mainwindow/geometry/pos", pos());
239 settings.setValue ("/mainwindow/state",saveState(0));
241 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
242 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
243 settings.setValue( "/version/version", vymVersion );
244 settings.setValue( "/version/builddate", vymBuildDate );
246 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
247 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
248 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
249 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
250 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
251 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
252 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
253 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
255 //TODO save scriptEditor settings
257 // call the destructors
259 delete historyWindow;
260 delete branchPropertyWindow;
263 // Remove temporary directory
264 removeDir (QDir(tmpVymDir));
267 void Main::loadCmdLine()
269 /* TODO draw some kind of splashscreen while loading...
275 QStringList flist=options.getFileList();
276 QStringList::Iterator it=flist.begin();
278 while (it !=flist.end() )
280 fileLoad (*it, NewMap);
286 void Main::statusMessage(const QString &s)
288 // Surpress messages while progressbar during
290 if (progressMin==progressMax)
291 statusBar()->message( s);
294 void Main::setProgressMinimum (int min)
296 progressBar->setMinimum(min);
300 void Main::setProgressMaximum (int max)
302 progressBar->setMaximum(max);
306 statusBar()->addPermanentWidget(progressBar);
311 void Main::setProgressValue (int v)
313 progressBar->setValue (v);
316 void Main::removeProgressBar()
319 statusBar()->removeWidget(progressBar);
320 progressMax=progressMin=0;
323 void Main::closeEvent (QCloseEvent* )
329 void Main::setupFileActions()
331 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
332 QToolBar *tb = addToolBar( tr ("&Map") );
333 tb->setObjectName ("mapTB");
336 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
337 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
338 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
340 fileMenu->addAction (a);
341 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
343 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
344 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
345 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
346 fileMenu->addAction (a);
347 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
350 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
351 a->setStatusTip (tr( "Open","Status tip File menu" ) );
352 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
354 fileMenu->addAction (a);
355 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
357 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
358 fileMenu->addSeparator();
360 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
361 a->setStatusTip ( tr( "Save","Status tip file menu" ));
362 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
364 fileMenu->addAction (a);
365 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
368 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
369 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
370 fileMenu->addAction (a);
371 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
373 fileMenu->addSeparator();
375 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
377 a = new QAction(tr("KDE 3 Bookmarks"), this);
378 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
379 a->addTo (fileImportMenu);
380 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
382 a = new QAction(tr("KDE 4 Bookmarks"), this);
383 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
384 a->addTo (fileImportMenu);
385 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
387 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
389 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
390 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
391 a->addTo (fileImportMenu);
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
395 a = new QAction("Freemind...",this);
396 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
397 fileImportMenu->addAction (a);
398 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
400 a = new QAction("Mind Manager...",this);
401 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
402 fileImportMenu->addAction (a);
403 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
405 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
406 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
407 fileImportMenu->addAction (a);
408 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
410 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
412 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
413 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
414 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
415 fileExportMenu->addAction (a);
417 a = new QAction( "Open Office...", this);
418 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
419 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
420 fileExportMenu->addAction (a);
422 a = new QAction( "Webpage (XHTML)...",this );
423 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
424 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
425 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
426 fileExportMenu->addAction (a);
428 a = new QAction( "Text (ASCII)...", this);
429 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
430 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
431 fileExportMenu->addAction (a);
433 a = new QAction( "Spreadsheet (CSV)...", this);
434 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
435 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
436 fileExportMenu->addAction (a);
438 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
439 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
440 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
441 fileExportMenu->addAction (a);
443 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
444 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
445 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
446 fileExportMenu->addAction (a);
448 a = new QAction( "Taskjuggler...", this );
449 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
450 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
451 fileExportMenu->addAction (a);
453 a = new QAction( "LaTeX...", this);
454 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
455 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
456 fileExportMenu->addAction (a);
458 a = new QAction( "XML..." , this );
459 a->setStatusTip (tr( "Export as %1").arg("XML"));
460 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
461 fileExportMenu->addAction (a);
463 fileMenu->addSeparator();
465 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
466 a->setStatusTip ( tr( "Print" ,"File menu") );
467 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
469 fileMenu->addAction (a);
470 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
473 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
474 a->setStatusTip (tr( "Close Map" ) );
475 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
476 fileMenu->addAction (a);
477 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
479 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
480 a->setStatusTip ( tr( "Exit")+" "+vymName );
481 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
482 fileMenu->addAction (a);
483 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
488 void Main::setupEditActions()
490 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
491 tb->setLabel( "Edit Actions" );
492 tb->setObjectName ("actionsTB");
493 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
497 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
498 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
499 a->setStatusTip (tr( "Undo" ) );
500 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
501 a->setEnabled (false);
503 editMenu->addAction (a);
506 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
507 a->setStatusTip (tr( "Redo" ));
508 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
510 editMenu->addAction (a);
511 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
514 editMenu->addSeparator();
515 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
516 a->setStatusTip ( tr( "Copy" ) );
517 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
518 a->setEnabled (false);
520 editMenu->addAction (a);
521 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
524 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
525 a->setStatusTip ( tr( "Cut" ) );
526 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
527 a->setEnabled (false);
529 editMenu->addAction (a);
531 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
533 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
534 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
535 a->setStatusTip ( tr( "Paste" ) );
536 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
537 a->setEnabled (false);
539 editMenu->addAction (a);
543 // Shortcuts to modify heading:
544 a = new QAction(tr( "Edit heading","Edit menu" ),this);
545 a->setStatusTip ( tr( "edit Heading" ));
546 a->setShortcut ( Qt::Key_Enter); //Edit heading
547 // a->setShortcutContext (Qt::WindowShortcut);
549 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
550 actionListBranches.append(a);
551 a = new QAction( tr( "Edit heading","Edit menu" ), this);
552 a->setStatusTip (tr( "edit Heading" ));
553 a->setShortcut (Qt::Key_Return ); //Edit heading
554 //a->setShortcutContext (Qt::WindowShortcut);
556 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
557 actionListBranches.append(a);
558 editMenu->addAction (a);
561 a = new QAction( tr( "Edit heading","Edit menu" ), this);
562 a->setStatusTip (tr( "edit Heading" ));
563 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
564 a->setShortcutContext (Qt::WindowShortcut);
566 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
567 actionListBranches.append(a);
570 // Shortcut to delete selection
571 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
572 a->setStatusTip (tr( "Delete Selection" ));
573 a->setShortcut ( Qt::Key_Delete); //Delete selection
574 a->setShortcutContext (Qt::WindowShortcut);
576 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
579 // Shortcut to add mapcenter
580 a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
581 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
582 actionAddMapCenter = a;
585 // Shortcut to add branch
586 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
587 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
588 alt->setShortcut (Qt::Key_A); //Add branch
589 alt->setShortcutContext (Qt::WindowShortcut);
591 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
592 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
593 a->setStatusTip ( tr( "Add a branch as child of selection" ));
594 a->setShortcut (Qt::Key_Insert); //Add branch
595 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
596 actionListBranches.append(a);
597 #if defined (Q_OS_MACX)
598 // In OSX show different shortcut in menues, the keys work indepently always
603 editMenu->addAction (actionAddBranch);
604 tb->addAction (actionAddBranch);
607 // Add branch by inserting it at selection
608 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
609 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
610 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
611 a->setShortcutContext (Qt::WindowShortcut);
613 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
614 a->setEnabled (false);
615 actionListBranches.append(a);
616 actionAddBranchBefore=a;
617 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
618 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
619 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
620 a->setShortcutContext (Qt::WindowShortcut);
622 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
623 actionListBranches.append(a);
626 a = new QAction(tr( "Add branch above","Edit menu" ), this);
627 a->setStatusTip ( tr( "Add a branch above selection" ));
628 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
629 a->setShortcutContext (Qt::WindowShortcut);
631 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 actionAddBranchAbove=a;
635 a = new QAction(tr( "Add branch above","Edit menu" ), this);
636 a->setStatusTip ( tr( "Add a branch above selection" ));
637 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
638 a->setShortcutContext (Qt::WindowShortcut);
640 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
641 actionListBranches.append(a);
644 a = new QAction(tr( "Add branch below","Edit menu" ), this);
645 a->setStatusTip ( tr( "Add a branch below selection" ));
646 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
647 a->setShortcutContext (Qt::WindowShortcut);
649 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
650 a->setEnabled (false);
651 actionListBranches.append(a);
652 actionAddBranchBelow=a;
653 a = new QAction(tr( "Add branch below","Edit menu" ), this);
654 a->setStatusTip ( tr( "Add a branch below selection" ));
655 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
656 a->setShortcutContext (Qt::WindowShortcut);
658 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
659 actionListBranches.append(a);
661 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
662 a->setStatusTip ( tr( "Move branch up" ) );
663 a->setShortcut (Qt::Key_PageUp ); // Move branch up
664 a->setEnabled (false);
666 editMenu->addAction (a);
667 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
670 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
671 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
672 a->setStatusTip (tr( "Move branch down" ) );
673 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
674 a->setEnabled (false);
676 editMenu->addAction (a);
679 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
680 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
681 a->setEnabled (true);
683 editMenu->addAction (a);
684 actionSortChildren=a;
686 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
687 a->setShortcut ( Qt::Key_ScrollLock );
688 a->setStatusTip (tr( "Scroll branch" ) );
689 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
691 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
692 alt->setShortcut ( Qt::Key_S ); // Scroll branch
693 alt->setStatusTip (tr( "Scroll branch" ));
694 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
695 #if defined(Q_OS_MACX)
696 actionToggleScroll=alt;
698 actionToggleScroll=a;
700 actionToggleScroll->setEnabled (false);
701 actionToggleScroll->setToggleAction(true);
702 tb->addAction (actionToggleScroll);
703 editMenu->addAction ( actionToggleScroll);
704 editMenu->addAction (actionToggleScroll);
707 actionListBranches.append(actionToggleScroll);
709 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
710 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
711 editMenu->addAction (a);
712 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
714 editMenu->addSeparator();
716 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
717 a->setStatusTip (tr( "Find" ) );
718 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
719 editMenu->addAction (a);
720 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
722 editMenu->addSeparator();
724 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
725 a->setShortcut (Qt::CTRL + Qt::Key_U );
726 a->setShortcut (tr( "Open URL" ));
729 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
732 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
733 a->setStatusTip (tr( "Open URL in new tab" ));
734 //a->setShortcut (Qt::CTRL+Qt::Key_U );
736 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
739 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
740 a->setStatusTip (tr( "Open all URLs in subtree" ));
742 actionListBranches.append(a);
743 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
744 actionOpenMultipleURLTabs=a;
746 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
747 a->setStatusTip ( tr( "Edit URL" ) );
748 a->setShortcut ( Qt::Key_U );
749 a->setShortcutContext (Qt::WindowShortcut);
750 actionListBranches.append(a);
752 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
755 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
756 a->setStatusTip ( tr( "Edit local URL" ) );
757 a->setShortcut (Qt::SHIFT + Qt::Key_U );
758 a->setShortcutContext (Qt::WindowShortcut);
759 actionListBranches.append(a);
761 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
764 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
765 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
766 a->setEnabled (false);
767 actionListBranches.append(a);
768 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
771 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
772 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
773 a->setEnabled (false);
774 actionListBranches.append(a);
775 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
776 actionBugzilla2URL=a;
778 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
779 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
780 a->setEnabled (false);
781 actionListBranches.append(a);
782 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
785 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
786 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
788 a->setEnabled (false);
789 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
792 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
793 a->setStatusTip ( tr( "Open all vym links in subtree" ));
794 a->setEnabled (false);
795 actionListBranches.append(a);
796 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
797 actionOpenMultipleVymLinks=a;
800 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
801 a->setEnabled (false);
802 a->setStatusTip ( tr( "Edit link to another vym map" ));
803 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
804 actionListBranches.append(a);
807 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
808 a->setStatusTip ( tr( "Delete link to another vym map" ));
809 a->setEnabled (false);
810 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
811 actionDeleteVymLink=a;
813 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
814 a->setStatusTip ( tr( "Hide object in exports" ) );
815 a->setShortcut (Qt::Key_H );
816 a->setToggleAction(true);
818 a->setEnabled (false);
819 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
820 actionToggleHideExport=a;
822 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
823 a->setStatusTip ( tr( "Edit Map Info" ));
824 a->setEnabled (true);
825 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
828 // Import at selection (adding to selection)
829 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
830 a->setStatusTip (tr( "Add map at selection" ));
831 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
832 a->setEnabled (false);
833 actionListBranches.append(a);
836 // Import at selection (replacing selection)
837 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
838 a->setStatusTip (tr( "Replace selection with map" ));
839 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
840 a->setEnabled (false);
841 actionListBranches.append(a);
842 actionImportReplace=a;
845 a = new QAction( tr( "Save selection","Edit menu" ), this);
846 a->setStatusTip (tr( "Save selection" ));
847 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
848 a->setEnabled (false);
849 actionListBranches.append(a);
852 // Only remove branch, not its children
853 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
854 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
855 a->setShortcut (Qt::ALT + Qt::Key_Delete );
856 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
857 a->setEnabled (false);
859 actionListBranches.append(a);
860 actionDeleteKeepChildren=a;
862 // Only remove children of a branch
863 a = new QAction( tr( "Remove children","Edit menu" ), this);
864 a->setStatusTip (tr( "Remove children of branch" ));
865 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
866 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
867 a->setEnabled (false);
868 actionListBranches.append(a);
869 actionDeleteChildren=a;
871 // Shortcuts for navigating with cursor:
872 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
873 a->setStatusTip ( tr( "Select upper branch" ));
874 a->setShortcut (Qt::Key_Up );
875 a->setShortcutContext (Qt::WindowShortcut);
877 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
878 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
879 a->setStatusTip (tr( "Select lower branch" ));
880 a->setShortcut ( Qt::Key_Down );
881 a->setShortcutContext (Qt::WindowShortcut);
883 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
884 a = new QAction(tr( "Select left branch","Edit menu" ), this);
885 a->setStatusTip ( tr( "Select left branch" ));
886 a->setShortcut (Qt::Key_Left );
887 a->setShortcutContext (Qt::WindowShortcut);
889 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
890 a = new QAction( tr( "Select child branch","Edit menu" ), this);
891 a->setStatusTip (tr( "Select right branch" ));
892 a->setShortcut (Qt::Key_Right);
893 a->setShortcutContext (Qt::WindowShortcut);
895 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
896 a = new QAction( tr( "Select first branch","Edit menu" ), this);
897 a->setStatusTip (tr( "Select first branch" ));
898 a->setShortcut (Qt::Key_Home );
899 a->setShortcutContext (Qt::WindowShortcut);
901 a->setEnabled (false);
902 editMenu->addAction (a);
903 actionListBranches.append(a);
905 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
906 a = new QAction( tr( "Select last branch","Edit menu" ),this);
907 a->setStatusTip (tr( "Select last branch" ));
908 a->setShortcut ( Qt::Key_End );
909 a->setShortcutContext (Qt::WindowShortcut);
911 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
912 a->setEnabled (false);
913 editMenu->addAction (a);
914 actionListBranches.append(a);
917 a = new QAction( tr( "Add Image...","Edit menu" ), this);
918 a->setStatusTip (tr( "Add Image" ));
919 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
922 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
923 a->setStatusTip (tr( "Set properties for selection" ));
924 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
925 a->setShortcutContext (Qt::WindowShortcut);
926 a->setToggleAction (true);
928 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
929 actionViewTogglePropertyWindow=a;
933 void Main::setupFormatActions()
935 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
937 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
938 tb->setObjectName ("formatTB");
941 pix.fill (Qt::black);
942 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
943 a->setStatusTip ( tr( "Set Color" ));
944 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
946 formatMenu->addAction (a);
948 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
949 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
950 a->setShortcut (Qt::CTRL + Qt::Key_K );
951 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
952 a->setEnabled (false);
954 formatMenu->addAction (a);
955 actionListBranches.append(a);
956 actionFormatPickColor=a;
958 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
959 a->setStatusTip ( tr( "Color branch" ) );
960 a->setShortcut (Qt::CTRL + Qt::Key_B);
961 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
962 a->setEnabled (false);
964 formatMenu->addAction (a);
965 actionListBranches.append(a);
966 actionFormatColorSubtree=a;
968 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
969 a->setStatusTip ( tr( "Color Subtree" ));
970 a->setShortcut (Qt::CTRL + Qt::Key_T);
971 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
972 a->setEnabled (false);
973 formatMenu->addAction (a);
975 actionListBranches.append(a);
976 actionFormatColorSubtree=a;
978 formatMenu->addSeparator();
979 actionGroupFormatLinkStyles=new QActionGroup ( this);
980 actionGroupFormatLinkStyles->setExclusive (true);
981 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
982 a->setStatusTip (tr( "Line" ));
983 a->setToggleAction(true);
984 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
985 formatMenu->addAction (a);
986 actionFormatLinkStyleLine=a;
987 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
988 a->setStatusTip (tr( "Line" ));
989 a->setToggleAction(true);
990 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
991 formatMenu->addAction (a);
992 actionFormatLinkStyleParabel=a;
993 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
994 a->setStatusTip (tr( "PolyLine" ));
995 a->setToggleAction(true);
996 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
997 formatMenu->addAction (a);
998 actionFormatLinkStylePolyLine=a;
999 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1000 a->setStatusTip (tr( "PolyParabel" ) );
1001 a->setToggleAction(true);
1002 a->setChecked (true);
1003 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1004 formatMenu->addAction (a);
1005 actionFormatLinkStylePolyParabel=a;
1007 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1008 a->setStatusTip (tr( "Hide link" ));
1009 a->setToggleAction(true);
1010 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1011 actionFormatHideLinkUnselected=a;
1013 formatMenu->addSeparator();
1014 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1015 a->setStatusTip (tr( "Use same color for links and headings" ));
1016 a->setToggleAction(true);
1017 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1018 formatMenu->addAction (a);
1019 actionFormatLinkColorHint=a;
1021 pix.fill (Qt::white);
1022 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1023 a->setStatusTip (tr( "Set Link Color" ));
1024 formatMenu->addAction (a);
1025 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1026 actionFormatLinkColor=a;
1028 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1029 a->setStatusTip (tr( "Set Selection Color" ));
1030 formatMenu->addAction (a);
1031 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1032 actionFormatSelectionColor=a;
1034 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1035 a->setStatusTip (tr( "Set Background Color" ));
1036 formatMenu->addAction (a);
1037 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1038 actionFormatBackColor=a;
1040 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1041 a->setStatusTip (tr( "Set Background image" ));
1042 formatMenu->addAction (a);
1043 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1044 actionFormatBackImage=a;
1048 void Main::setupViewActions()
1050 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1051 tb->setLabel( "View Actions" );
1052 tb->setObjectName ("viewTB");
1053 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1056 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1057 a->setStatusTip ( tr( "Zoom reset" ) );
1058 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1060 viewMenu->addAction (a);
1061 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1063 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1064 a->setStatusTip (tr( "Zoom in" ));
1065 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1067 viewMenu->addAction (a);
1068 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1070 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1071 a->setStatusTip (tr( "Zoom out" ));
1072 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1074 viewMenu->addAction (a);
1075 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1077 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1078 a->setStatusTip (tr( "Show selection" ));
1079 a->setShortcut (Qt::Key_Period);
1081 viewMenu->addAction (a);
1082 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1084 viewMenu->addSeparator();
1086 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1087 a->setStatusTip ( tr( "Show Note Editor" ));
1088 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1089 a->setToggleAction(true);
1091 viewMenu->addAction (a);
1092 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1093 actionViewToggleNoteEditor=a;
1095 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1096 a->setStatusTip ( tr( "Show History Window" ));
1097 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1098 a->setToggleAction(true);
1100 viewMenu->addAction (a);
1101 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1102 actionViewToggleHistoryWindow=a;
1104 viewMenu->addAction (actionViewTogglePropertyWindow);
1106 viewMenu->addSeparator();
1108 a = new QAction(tr( "Antialiasing","View action" ),this );
1109 a->setStatusTip ( tr( "Antialiasing" ));
1110 a->setToggleAction(true);
1111 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1112 viewMenu->addAction (a);
1113 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1114 actionViewToggleAntiAlias=a;
1116 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1117 a->setStatusTip (a->text());
1118 a->setToggleAction(true);
1119 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1120 viewMenu->addAction (a);
1121 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1122 actionViewToggleSmoothPixmapTransform=a;
1124 a = new QAction(tr( "Next Map","View action" ), this);
1125 a->setStatusTip (a->text());
1126 a->setShortcut (Qt::ALT + Qt::Key_N );
1127 viewMenu->addAction (a);
1128 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1130 a = new QAction (tr( "Previous Map","View action" ), this );
1131 a->setStatusTip (a->text());
1132 a->setShortcut (Qt::ALT + Qt::Key_P );
1133 viewMenu->addAction (a);
1134 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1138 void Main::setupModeActions()
1140 //QPopupMenu *menu = new QPopupMenu( this );
1141 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1143 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1144 tb->setObjectName ("modesTB");
1146 actionGroupModModes=new QActionGroup ( this);
1147 actionGroupModModes->setExclusive (true);
1148 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1149 a->setShortcut (Qt::Key_J);
1150 a->setStatusTip ( tr( "Use modifier to color branches" ));
1151 a->setToggleAction(true);
1154 actionModModeColor=a;
1156 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1157 a->setShortcut( Qt::Key_K);
1158 a->setStatusTip( tr( "Use modifier to copy" ));
1159 a->setToggleAction(true);
1161 actionModModeCopy=a;
1163 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1164 a->setShortcut (Qt::Key_L);
1165 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1166 a->setToggleAction(true);
1168 actionModModeXLink=a;
1172 void Main::setupFlagActions()
1174 // Create System Flags
1178 systemFlagsDefault = new FlagRowObj ();
1179 systemFlagsDefault->setVisibility (false);
1180 systemFlagsDefault->setName ("systemFlagsDef");
1182 FlagObj *fo = new FlagObj ();
1183 fo->load(QPixmap(flagsPath+"flag-note.png"));
1184 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1186 fo->load(QPixmap(flagsPath+"flag-url.png"));
1187 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1189 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1190 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1192 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1193 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1195 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1196 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1198 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1199 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1201 // Create Standard Flags
1202 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1203 tb->setObjectName ("standardFlagTB");
1205 standardFlagsDefault = new FlagRowObj ();
1206 standardFlagsDefault->setVisibility (false);
1207 standardFlagsDefault->setName ("standardFlagsDef");
1208 standardFlagsDefault->setToolBar (tb);
1210 fo->load(flagsPath+"flag-exclamationmark.png");
1211 fo->setGroup("standard-mark");
1212 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1214 fo->load(flagsPath+"flag-questionmark.png");
1215 fo->setGroup("standard-mark");
1216 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1218 fo->load(flagsPath+"flag-hook-green.png");
1219 fo->setGroup("standard-hook");
1220 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1222 fo->load(flagsPath+"flag-cross-red.png");
1223 fo->setGroup("standard-hook");
1224 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1227 fo->load(flagsPath+"flag-stopsign.png");
1228 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1230 fo->load(flagsPath+"flag-smiley-good.png");
1231 fo->setGroup("standard-smiley");
1232 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1234 fo->load(flagsPath+"flag-smiley-sad.png");
1235 fo->setGroup("standard-smiley");
1236 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1238 fo->load(flagsPath+"flag-smiley-omg.png");
1239 fo->setGroup("standard-smiley");
1240 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1241 // Original omg.png (in KDE emoticons)
1244 fo->load(flagsPath+"flag-kalarm.png");
1245 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1247 fo->load(flagsPath+"flag-phone.png");
1248 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1250 fo->load(flagsPath+"flag-lamp.png");
1251 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1253 fo->load(flagsPath+"flag-arrow-up.png");
1254 fo->setGroup("standard-arrow");
1255 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1257 fo->load(flagsPath+"flag-arrow-down.png");
1258 fo->setGroup("standard-arrow");
1259 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1261 fo->load(flagsPath+"flag-arrow-2up.png");
1262 fo->setGroup("standard-arrow");
1263 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1265 fo->load(flagsPath+"flag-arrow-2down.png");
1266 fo->setGroup("standard-arrow");
1267 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1270 fo->load(flagsPath+"flag-thumb-up.png");
1271 fo->setGroup("standard-thumb");
1272 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1274 fo->load(flagsPath+"flag-thumb-down.png");
1275 fo->setGroup("standard-thumb");
1276 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1279 fo->load(flagsPath+"flag-rose.png");
1280 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1282 fo->load(flagsPath+"flag-heart.png");
1283 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1285 fo->load(flagsPath+"flag-present.png");
1286 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1288 fo->load(flagsPath+"flag-flash.png");
1289 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1291 // Original: xsldbg_output.png
1292 fo->load(flagsPath+"flag-info.png");
1293 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1295 // Original khelpcenter.png
1296 fo->load(flagsPath+"flag-lifebelt.png");
1297 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1303 fo->load(flagsPath+"freemind/warning.png");
1304 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1306 for (int i=1; i<8; i++)
1308 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1309 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1312 fo->load(flagsPath+"freemind/back.png");
1313 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1315 fo->load(flagsPath+"freemind/forward.png");
1316 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1318 fo->load(flagsPath+"freemind/attach.png");
1319 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1321 fo->load(flagsPath+"freemind/clanbomber.png");
1322 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1324 fo->load(flagsPath+"freemind/desktopnew.png");
1325 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1327 fo->load(flagsPath+"freemind/flag.png");
1328 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1331 fo->load(flagsPath+"freemind/gohome.png");
1332 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1335 fo->load(flagsPath+"freemind/kaddressbook.png");
1336 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1338 fo->load(flagsPath+"freemind/knotify.png");
1339 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1341 fo->load(flagsPath+"freemind/korn.png");
1342 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1344 fo->load(flagsPath+"freemind/mail.png");
1345 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1347 fo->load(flagsPath+"freemind/password.png");
1348 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1350 fo->load(flagsPath+"freemind/pencil.png");
1351 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1353 fo->load(flagsPath+"freemind/stop.png");
1354 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1356 fo->load(flagsPath+"freemind/wizard.png");
1357 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1359 fo->load(flagsPath+"freemind/xmag.png");
1360 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1362 fo->load(flagsPath+"freemind/bell.png");
1363 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1365 fo->load(flagsPath+"freemind/bookmark.png");
1366 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1368 fo->load(flagsPath+"freemind/penguin.png");
1369 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1371 fo->load(flagsPath+"freemind/licq.png");
1372 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1377 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1380 fo->setToolTip (tooltip);
1381 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1387 fo->setAlwaysVisible(aw);
1388 a->setCheckable(true);
1389 a->setObjectName(fo->getName());
1390 a->setToolTip(tooltip);
1391 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1392 standardFlagsDefault->addFlag (fo);
1396 systemFlagsDefault->addFlag (fo);
1400 void Main::setupNetworkActions()
1402 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1404 QMenu *netMenu = menuBar()->addMenu( "Network" );
1408 a = new QAction( "Start TCPserver for MapEditor",this);
1409 //a->setStatusTip ( "Set application to open pdf files"));
1410 a->setShortcut ( Qt::Key_T ); //New TCP server
1411 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1412 netMenu->addAction (a);
1414 a = new QAction( "Connect MapEditor to server",this);
1415 //a->setStatusTip ( "Set application to open pdf files"));
1416 a->setShortcut ( Qt::Key_C ); // Connect to server
1417 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1418 netMenu->addAction (a);
1422 void Main::setupSettingsActions()
1424 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1428 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1429 a->setStatusTip ( tr( "Set application to open pdf files"));
1430 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1431 settingsMenu->addAction (a);
1433 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1434 a->setStatusTip( tr( "Set application to open external links"));
1435 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1436 settingsMenu->addAction (a);
1438 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1439 a->setStatusTip( tr( "Set path for macros"));
1440 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1441 settingsMenu->addAction (a);
1443 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1444 a->setStatusTip( tr( "Set number of undo levels"));
1445 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1446 settingsMenu->addAction (a);
1448 settingsMenu->addSeparator();
1450 a = new QAction( tr( "Autosave","Settings action"), this);
1451 a->setStatusTip( tr( "Autosave"));
1452 a->setToggleAction(true);
1453 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1454 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1455 settingsMenu->addAction (a);
1456 actionSettingsAutosaveToggle=a;
1458 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1459 a->setStatusTip( tr( "Autosave time"));
1460 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1461 settingsMenu->addAction (a);
1462 actionSettingsAutosaveTime=a;
1464 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1465 a->setStatusTip( tr( "Write backup file on save"));
1466 a->setToggleAction(true);
1467 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1468 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1469 settingsMenu->addAction (a);
1470 actionSettingsWriteBackupFile=a;
1472 settingsMenu->addSeparator();
1474 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1475 a->setStatusTip( tr( "Edit branch after adding it" ));
1476 a->setToggleAction(true);
1477 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1478 settingsMenu->addAction (a);
1479 actionSettingsAutoEditNewBranch=a;
1481 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1482 a->setStatusTip( tr( "Select branch after adding it" ));
1483 a->setToggleAction(true);
1484 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1485 settingsMenu->addAction (a);
1486 actionSettingsAutoSelectNewBranch=a;
1488 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1489 a->setStatusTip( tr( "Select heading before editing" ));
1490 a->setToggleAction(true);
1491 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1492 settingsMenu->addAction (a);
1493 actionSettingsAutoSelectText=a;
1495 a= new QAction( tr( "Delete key","Settings action" ), this);
1496 a->setStatusTip( tr( "Delete key for deleting branches" ));
1497 a->setToggleAction(true);
1498 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1499 settingsMenu->addAction (a);
1500 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1501 actionSettingsUseDelKey=a;
1503 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1504 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1505 a->setToggleAction(true);
1506 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1507 settingsMenu->addAction (a);
1508 actionSettingsUseFlagGroups=a;
1510 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1511 a->setStatusTip( tr( "Use hide flag during exports " ));
1512 a->setToggleAction(true);
1513 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1514 settingsMenu->addAction (a);
1515 actionSettingsUseHideExport=a;
1517 a = new QAction( tr( "Animation","Settings action"), this);
1518 a->setStatusTip( tr( "Animation"));
1519 a->setToggleAction(true);
1520 a->setOn (settings.value("/animation/use",false).toBool() );
1521 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1522 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1524 settingsMenu->addAction (a);
1526 actionSettingsUseAnimation=a;
1530 void Main::setupTestActions()
1532 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1535 a = new QAction( "Test function 1" , this);
1536 a->setStatusTip( "Call test function 1" );
1537 testMenu->addAction (a);
1538 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1540 a = new QAction( "Test function 2" , this);
1541 a->setStatusTip( "Call test function 2" );
1542 testMenu->addAction (a);
1543 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1545 a = new QAction( "Command" , this);
1546 a->setStatusTip( "Enter command to call in editor" );
1547 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1548 testMenu->addAction (a);
1552 void Main::setupHelpActions()
1554 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1557 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1558 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1559 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1560 helpMenu->addAction (a);
1562 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1563 a->setStatusTip( tr( "Open VYM example maps " ));
1564 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1565 helpMenu->addAction (a);
1567 a = new QAction( tr( "About VYM","Help action" ), this);
1568 a->setStatusTip( tr( "About VYM")+vymName);
1569 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1570 helpMenu->addAction (a);
1572 a = new QAction( tr( "About QT","Help action" ), this);
1573 a->setStatusTip( tr( "Information about QT toolkit" ));
1574 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1575 helpMenu->addAction (a);
1579 void Main::setupContextMenus()
1583 // Context Menu for branch or mapcenter
1584 branchContextMenu =new QMenu (this);
1585 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1586 branchContextMenu->addSeparator();
1589 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1590 branchAddContextMenu->addAction (actionPaste );
1591 branchAddContextMenu->addAction ( actionAddBranch );
1592 branchAddContextMenu->addAction ( actionAddBranchBefore );
1593 branchAddContextMenu->addAction ( actionAddBranchAbove);
1594 branchAddContextMenu->addAction ( actionAddBranchBelow );
1595 branchAddContextMenu->addSeparator();
1596 branchAddContextMenu->addAction ( actionImportAdd );
1597 branchAddContextMenu->addAction ( actionImportReplace );
1600 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1601 branchRemoveContextMenu->addAction (actionCut);
1602 branchRemoveContextMenu->addAction ( actionDelete );
1603 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1604 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1607 actionSaveBranch->addTo( branchContextMenu );
1608 actionFileNewCopy->addTo (branchContextMenu );
1610 branchContextMenu->addSeparator();
1611 branchContextMenu->addAction ( actionLoadImage);
1613 // Submenu for Links (URLs, vymLinks)
1614 branchLinksContextMenu =new QMenu (this);
1616 branchContextMenu->addSeparator();
1617 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1618 branchLinksContextMenu->addAction ( actionOpenURL );
1619 branchLinksContextMenu->addAction ( actionOpenURLTab );
1620 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1621 branchLinksContextMenu->addAction ( actionURL );
1622 branchLinksContextMenu->addAction ( actionLocalURL );
1623 branchLinksContextMenu->addAction ( actionHeading2URL );
1624 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1625 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1627 branchLinksContextMenu->addAction ( actionFATE2URL );
1629 branchLinksContextMenu->addSeparator();
1630 branchLinksContextMenu->addAction ( actionOpenVymLink );
1631 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1632 branchLinksContextMenu->addAction ( actionVymLink );
1633 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1636 // Context Menu for XLinks in a branch menu
1637 // This will be populated "on demand" in MapEditor::updateActions
1638 branchContextMenu->addSeparator();
1639 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1640 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1641 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1642 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1645 // Context menu for floatimage
1646 floatimageContextMenu =new QMenu (this);
1647 a= new QAction (tr ("Save image","Context action"),this);
1648 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1649 floatimageContextMenu->addAction (a);
1651 floatimageContextMenu->addSeparator();
1652 actionCopy->addTo( floatimageContextMenu );
1653 actionCut->addTo( floatimageContextMenu );
1655 floatimageContextMenu->addSeparator();
1656 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1659 // Context menu for canvas
1660 canvasContextMenu =new QMenu (this);
1661 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1662 actionAddMapCenter->addTo( canvasContextMenu );
1663 actionMapInfo->addTo( canvasContextMenu );
1664 canvasContextMenu->insertSeparator();
1665 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1666 canvasContextMenu->insertSeparator();
1667 actionFormatLinkColorHint->addTo( canvasContextMenu );
1668 actionFormatLinkColor->addTo( canvasContextMenu );
1669 actionFormatSelectionColor->addTo( canvasContextMenu );
1670 actionFormatBackColor->addTo( canvasContextMenu );
1671 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1673 // Menu for last opened files
1675 for (int i = 0; i < MaxRecentFiles; ++i)
1677 recentFileActions[i] = new QAction(this);
1678 recentFileActions[i]->setVisible(false);
1679 fileLastMapsMenu->addAction(recentFileActions[i]);
1680 connect(recentFileActions[i], SIGNAL(triggered()),
1681 this, SLOT(fileLoadRecent()));
1683 setupRecentMapsMenu();
1686 void Main::setupRecentMapsMenu()
1688 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1690 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1692 for (int i = 0; i < numRecentFiles; ++i) {
1693 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1694 recentFileActions[i]->setText(text);
1695 recentFileActions[i]->setData(files[i]);
1696 recentFileActions[i]->setVisible(true);
1698 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1699 recentFileActions[j]->setVisible(false);
1702 void Main::setupMacros()
1704 for (int i = 0; i <= 11; i++)
1706 macroActions[i] = new QAction(this);
1707 macroActions[i]->setData(i);
1708 addAction (macroActions[i]);
1709 connect(macroActions[i], SIGNAL(triggered()),
1710 this, SLOT(callMacro()));
1712 macroActions[0]->setShortcut ( Qt::Key_F1 );
1713 macroActions[1]->setShortcut ( Qt::Key_F2 );
1714 macroActions[2]->setShortcut ( Qt::Key_F3 );
1715 macroActions[3]->setShortcut ( Qt::Key_F4 );
1716 macroActions[4]->setShortcut ( Qt::Key_F5 );
1717 macroActions[5]->setShortcut ( Qt::Key_F6 );
1718 macroActions[6]->setShortcut ( Qt::Key_F7 );
1719 macroActions[7]->setShortcut ( Qt::Key_F8 );
1720 macroActions[8]->setShortcut ( Qt::Key_F9 );
1721 macroActions[9]->setShortcut ( Qt::Key_F10 );
1722 macroActions[10]->setShortcut ( Qt::Key_F11 );
1723 macroActions[11]->setShortcut ( Qt::Key_F12 );
1726 void Main::hideEvent (QHideEvent * )
1728 if (!textEditor->isMinimized() ) textEditor->hide();
1731 void Main::showEvent (QShowEvent * )
1733 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1737 MapEditor* Main::currentMapEditor() const
1739 if ( tabWidget->currentPage())
1740 return tabModel.at(tabWidget->currentIndex())->getMapEditor();
1744 VymModel* Main::currentModel() const
1746 if ( tabWidget->currentPage())
1747 return tabModel.at(tabWidget->currentIndex());
1752 void Main::editorChanged(QWidget *)
1754 // Unselect all possibly selected objects
1755 // (Important to update note editor)
1756 for (int i=0;i<=tabWidget->count() -1;i++)
1758 tabModel.at(i)->unselect();
1760 VymModel *m=currentModel();
1761 if (m) m->reselect();
1763 // Update actions to in menus and toolbars according to editor
1767 VymView *Main::createView (VymModel *model)
1769 VymView *vm=new VymView (model);
1774 void Main::fileNew()
1776 VymModel *m=new VymModel;
1777 tabModel.append (m);
1778 //MapEditor* me = new MapEditor (m);
1779 //me->setObjectName ("MapEditor");
1781 VymView *view=createView (m);
1782 tabWidget->addTab (view,tr("unnamed","MainWindow: name for new and empty file"));
1783 tabWidget->setCurrentIndex (tabModel.count() );
1785 // For the very first map we do not have flagrows yet...
1789 void Main::fileNewCopy()
1791 QString fn="unnamed";
1792 VymModel *srcModel=currentModel();
1797 VymModel *dstModel=tabModel.last ();
1798 dstModel->select("mc:");
1799 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1803 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1805 ErrorCode err=success;
1807 // fn is usually the archive, mapfile the file after uncompressing
1810 // Make fn absolute (needed for unzip)
1811 fn=QDir (fn).absPath();
1817 // Check, if map is already loaded
1819 while (i<=tabWidget->count() -1)
1821 if (tabModel.at(i)->getFilePath() == fn)
1823 // Already there, ask for confirmation
1824 QMessageBox mb( vymName,
1825 tr("The map %1\nis already opened."
1826 "Opening the same map in multiple editors may lead \n"
1827 "to confusion when finishing working with vym."
1828 "Do you want to").arg(fn),
1829 QMessageBox::Warning,
1830 QMessageBox::Yes | QMessageBox::Default,
1831 QMessageBox::Cancel | QMessageBox::Escape,
1832 QMessageBox::NoButton);
1833 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1834 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1837 case QMessageBox::Yes:
1838 // end loop and load anyway
1839 i=tabWidget->count();
1841 case QMessageBox::Cancel:
1851 int tabIndex=tabWidget->currentPageIndex();
1854 if ( !fn.isEmpty() )
1856 vm = currentModel();
1857 // Check first, if mapeditor exists
1858 // If it is not default AND we want a new map,
1859 // create a new mapeditor in a new tab
1860 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1863 tabModel.append (vm);
1864 VymView *view=createView (vm);
1865 tabWidget->addTab (view,fn);
1866 tabIndex=tabWidget->count()-1;
1867 tabWidget->setCurrentPage (tabIndex);
1870 // Check, if file exists (important for creating new files
1871 // from command line
1872 if (!QFile(fn).exists() )
1874 QMessageBox mb( vymName,
1875 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1876 QMessageBox::Question,
1878 QMessageBox::Cancel | QMessageBox::Default,
1879 QMessageBox::NoButton );
1881 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1882 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1885 case QMessageBox::Yes:
1887 currentMapEditor()->getModel()->setFilePath(fn);
1888 tabWidget->setTabText (tabIndex,
1889 currentMapEditor()->getModel()->getFileName() );
1890 statusBar()->message( "Created " + fn , statusbarTime );
1893 case QMessageBox::Cancel:
1894 // don't create new map
1895 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1902 //tabWidget->currentPage() won't be NULL here, because of above...
1903 tabWidget->setCurrentIndex (tabIndex);
1904 //FIXME-3 no me anymore... me->viewport()->setFocus();
1908 // Save existing filename in case we import
1909 QString fn_org=vm->getFilePath();
1911 // Finally load map into mapEditor
1912 vm->setFilePath (fn);
1913 err=vm->load(fn,lmode,ftype);
1915 // Restore old (maybe empty) filepath, if this is an import
1917 vm->setFilePath (fn_org);
1920 // Finally check for errors and go home
1923 if (lmode==NewMap) fileCloseMap();
1924 statusBar()->message( "Could not load " + fn, statusbarTime );
1929 vm->setFilePath (fn);
1930 tabWidget->setTabText (tabIndex, vm->getFileName());
1931 if (!isInTmpDir (fn))
1933 // Only append to lastMaps if not loaded from a tmpDir
1934 // e.g. imported bookmarks are in a tmpDir
1935 addRecentMap(vm->getFilePath() );
1937 actionFilePrint->setEnabled (true);
1939 statusBar()->message( "Loaded " + fn, statusbarTime );
1946 void Main::fileLoad(const LoadMode &lmode)
1948 QStringList filters;
1949 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1950 QFileDialog *fd=new QFileDialog( this);
1951 fd->setDir (lastFileDir);
1952 fd->setFileMode (QFileDialog::ExistingFiles);
1953 fd->setFilters (filters);
1957 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1960 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1963 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1969 if ( fd->exec() == QDialog::Accepted )
1971 lastFileDir=fd->directory().path();
1972 QStringList flist = fd->selectedFiles();
1973 QStringList::Iterator it = flist.begin();
1974 while( it != flist.end() )
1977 fileLoad(*it, lmode);
1984 void Main::fileLoad()
1989 void Main::fileLoadRecent()
1991 QAction *action = qobject_cast<QAction *>(sender());
1993 fileLoad (action->data().toString(), NewMap);
1996 void Main::addRecentMap (const QString &fileName)
1999 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2000 files.removeAll(fileName);
2001 files.prepend(fileName);
2002 while (files.size() > MaxRecentFiles)
2005 settings.setValue("/mainwindow/recentFileList", files);
2007 setupRecentMapsMenu();
2010 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2014 if ( m->getFilePath().isEmpty() )
2016 // We have no filepath yet,
2017 // call fileSaveAs() now, this will call fileSave()
2019 // First switch to editor
2020 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2021 fileSaveAs(savemode);
2024 if (m->save (savemode)==success)
2026 statusBar()->message(
2027 tr("Saved %1").arg(m->getFilePath()),
2029 addRecentMap (m->getFilePath() );
2031 statusBar()->message(
2032 tr("Couldn't save ").arg(m->getFilePath()),
2036 void Main::fileSave()
2038 fileSave (currentModel(), CompleteMap);
2041 void Main::fileSave(VymModel *m)
2043 fileSave (m,CompleteMap);
2046 void Main::fileSaveAs(const SaveMode& savemode)
2050 if (currentMapEditor())
2052 if (savemode==CompleteMap)
2053 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2055 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2056 if ( !fn.isEmpty() )
2058 // Check for existing file
2059 if (QFile (fn).exists())
2061 QMessageBox mb( vymName,
2062 tr("The file %1\nexists already. Do you want to").arg(fn),
2063 QMessageBox::Warning,
2064 QMessageBox::Yes | QMessageBox::Default,
2065 QMessageBox::Cancel | QMessageBox::Escape,
2066 QMessageBox::NoButton);
2067 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2068 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2071 case QMessageBox::Yes:
2074 case QMessageBox::Cancel:
2081 // New file, add extension to filename, if missing
2082 // This is always .vym or .vyp, depending on savemode
2083 if (savemode==CompleteMap)
2085 if (!fn.contains (".vym") && !fn.contains (".xml"))
2089 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2098 VymModel *m=currentModel();
2100 fileSave(m, savemode);
2102 // Set name of tab, assuming current tab is the one we just saved
2103 if (savemode==CompleteMap)
2104 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2110 void Main::fileSaveAs()
2112 fileSaveAs (CompleteMap);
2115 void Main::fileImportKDE3Bookmarks()
2117 ImportKDE3Bookmarks im;
2119 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2120 currentMapEditor()->getModel()->setFilePath ("");
2123 void Main::fileImportKDE4Bookmarks()
2125 ImportKDE4Bookmarks im;
2127 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2128 currentMapEditor()->getModel()->setFilePath ("");
2131 void Main::fileImportFirefoxBookmarks()
2133 Q3FileDialog *fd=new Q3FileDialog( this);
2134 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2135 fd->setMode (Q3FileDialog::ExistingFiles);
2136 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2137 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2140 if ( fd->exec() == QDialog::Accepted )
2142 ImportFirefoxBookmarks im;
2143 QStringList flist = fd->selectedFiles();
2144 QStringList::Iterator it = flist.begin();
2145 while( it != flist.end() )
2148 if (im.transform() &&
2149 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2150 currentMapEditor() )
2151 currentMapEditor()->getModel()->setFilePath ("");
2158 void Main::fileImportFreemind()
2160 QStringList filters;
2161 filters <<"Freemind map (*.mm)"<<"All files (*)";
2162 QFileDialog *fd=new QFileDialog( this);
2163 fd->setDir (lastFileDir);
2164 fd->setFileMode (QFileDialog::ExistingFiles);
2165 fd->setFilters (filters);
2166 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2170 if ( fd->exec() == QDialog::Accepted )
2172 lastFileDir=fd->directory().path();
2173 QStringList flist = fd->selectedFiles();
2174 QStringList::Iterator it = flist.begin();
2175 while( it != flist.end() )
2178 if ( fileLoad (fn,NewMap, FreemindMap) )
2180 currentMapEditor()->getModel()->setFilePath ("");
2189 void Main::fileImportMM()
2193 Q3FileDialog *fd=new Q3FileDialog( this);
2194 fd->setDir (lastFileDir);
2195 fd->setMode (Q3FileDialog::ExistingFiles);
2196 fd->addFilter ("Mind Manager (*.mmap)");
2197 fd->setCaption(tr("Import")+" "+"Mind Manager");
2200 if ( fd->exec() == QDialog::Accepted )
2202 lastFileDir=fd->dirPath();
2203 QStringList flist = fd->selectedFiles();
2204 QStringList::Iterator it = flist.begin();
2205 while( it != flist.end() )
2208 if (im.transform() &&
2209 success==fileLoad (im.getTransformedFile(),NewMap) &&
2210 currentMapEditor() )
2211 currentMapEditor()->getModel()->setFilePath ("");
2218 void Main::fileImportDir()
2220 VymModel *m=currentModel();
2221 if (m) m->importDir();
2224 void Main::fileExportXML()
2226 VymModel *m=currentModel();
2227 if (m) m->exportXML();
2231 void Main::fileExportXHTML()
2233 VymModel *m=currentModel();
2234 if (m) m->exportXHTML();
2237 void Main::fileExportImage()
2239 VymModel *m=currentModel();
2240 if (m) m->exportImage();
2243 void Main::fileExportASCII()
2245 VymModel *m=currentModel();
2246 if (m) m->exportASCII();
2249 void Main::fileExportCSV() //FIXME-2 not scriptable yet
2251 VymModel *m=currentModel();
2256 ex.addFilter ("CSV (*.csv)");
2257 ex.setDir(lastImageDir);
2258 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2259 if (ex.execDialog() )
2261 m->setExportMode(true);
2263 m->setExportMode(false);
2268 void Main::fileExportLaTeX() //FIXME-2 not scriptable yet
2270 VymModel *m=currentModel();
2275 ex.addFilter ("Tex (*.tex)");
2276 ex.setDir(lastImageDir);
2277 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2278 if (ex.execDialog() )
2280 m->setExportMode(true);
2282 m->setExportMode(false);
2287 void Main::fileExportKDE3Bookmarks() //FIXME-2 not scriptable yet
2289 ExportKDE3Bookmarks ex;
2290 VymModel *m=currentModel();
2298 void Main::fileExportKDE4Bookmarks() //FIXME-2 not scriptable yet
2300 ExportKDE4Bookmarks ex;
2301 VymModel *m=currentModel();
2309 void Main::fileExportTaskjuggler() //FIXME-2 not scriptable yet
2311 ExportTaskjuggler ex;
2312 VymModel *m=currentModel();
2316 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2317 ex.setDir(lastImageDir);
2318 ex.addFilter ("Taskjuggler (*.tjp)");
2319 if (ex.execDialog() )
2321 m->setExportMode(true);
2323 m->setExportMode(false);
2328 void Main::fileExportOOPresentation() //FIXME-2 not scriptable yet
2330 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2331 // TODO add preview in dialog
2332 //ImagePreview *p =new ImagePreview (fd);
2333 //fd->setContentsPreviewEnabled( TRUE );
2334 //fd->setContentsPreview( p, p );
2335 //fd->setPreviewMode( QFileDialog::Contents );
2336 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2337 fd->setDir (QDir().current());
2338 if (fd->foundConfig())
2342 if ( fd->exec() == QDialog::Accepted )
2344 QString fn=fd->selectedFile();
2345 if (!fn.contains (".odp"))
2348 //lastImageDir=fn.left(fn.findRev ("/"));
2349 VymModel *m=currentModel();
2350 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2354 QMessageBox::warning(0,
2356 tr("Couldn't find configuration for export to Open Office\n"));
2360 void Main::fileCloseMap()
2362 MapEditor *me = currentMapEditor();
2363 VymModel *m=currentModel();
2366 if (m->hasChanged())
2368 QMessageBox mb( vymName,
2369 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
2370 QMessageBox::Warning,
2371 QMessageBox::Yes | QMessageBox::Default,
2373 QMessageBox::Cancel | QMessageBox::Escape );
2374 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2375 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2378 case QMessageBox::Yes:
2380 fileSave(m, CompleteMap);
2382 case QMessageBox::No:
2383 // close without saving
2385 case QMessageBox::Cancel:
2390 tabModel.removeAt (tabWidget->currentIndex() );
2391 tabWidget->removeTab (tabWidget->currentIndex() );
2393 // Remove mapEditor;
2394 // Better would be delete (me), but then we could have a Qt error:
2395 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2396 // So we only remove data now and call deconstructor when vym closes later
2397 // FIXME-3 this needs to be moved to vymview... me->clear();
2398 // some model->clear is needed to free up memory ...
2404 void Main::filePrint()
2406 if (currentMapEditor())
2407 currentMapEditor()->print();
2410 void Main::fileExitVYM()
2412 // Check if one or more editors have changed
2414 for (i=0;i<=tabModel.count() -1;i++)
2416 // If something changed, ask what to do
2417 if (tabModel.at(i)->hasChanged())
2419 tabWidget->setCurrentPage(i);
2420 QMessageBox mb( vymName,
2421 tr("This map is not saved yet. Do you want to"),
2422 QMessageBox::Warning,
2423 QMessageBox::Yes | QMessageBox::Default,
2425 QMessageBox::Cancel | QMessageBox::Escape );
2426 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2427 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2430 mb.setActiveWindow();
2431 switch( mb.exec() ) {
2432 case QMessageBox::Yes:
2433 // save (the changed editors) and exit
2434 fileSave(currentModel(), CompleteMap);
2436 case QMessageBox::No:
2437 // exit without saving
2439 case QMessageBox::Cancel:
2440 // don't save and don't exit
2444 } // loop over all MEs
2448 void Main::editUndo()
2450 VymModel *m=currentModel();
2454 void Main::editRedo()
2456 VymModel *m=currentModel();
2460 void Main::gotoHistoryStep (int i)
2462 VymModel *m=currentModel();
2463 if (m) m->gotoHistoryStep(i);
2466 void Main::editCopy()
2468 VymModel *m=currentModel();
2472 void Main::editPaste()
2474 VymModel *m=currentModel();
2478 void Main::editCut()
2480 VymModel *m=currentModel();
2484 void Main::editOpenFindWindow()
2486 findWindow->popup();
2487 findWindow->raise();
2488 findWindow->setActiveWindow();
2491 void Main::editFind(QString s)
2493 VymModel *m=currentModel();
2497 BranchObj *bo=m->findText(s, cs);
2500 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2503 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2504 tr("No matches found for \"%1\"").arg(s));
2509 void Main::editFindChanged()
2510 { // Notify editor, to abort the current find process
2511 VymModel *m=currentModel();
2512 if (m) m->findReset();
2515 void Main::openTabs(QStringList urls)
2517 if (!urls.isEmpty())
2521 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2523 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2525 QString u=urls.takeFirst();
2526 procBrowser = new QProcess( this );
2528 procBrowser->start(browser,args);
2529 if ( !procBrowser->waitForStarted())
2531 // try to set path to browser
2532 QMessageBox::warning(0,
2534 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2535 tr("Please use Settings->")+tr("Set application to open an URL"));
2538 #if defined(Q_OS_WIN32)
2539 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2540 this->thread()->wait(3000);
2545 if (browser.contains("konqueror"))
2547 for (int i=0; i<urls.size(); i++)
2550 // Try to open new tab in existing konqueror started previously by vym
2551 p=new QProcess (this);
2553 #if defined(Q_OS_WIN32)
2554 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2555 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2556 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2557 "konqueror-mainwindow#1"<<
2561 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2562 "konqueror-mainwindow#1"<<
2566 p->start ("dcop",args);
2567 //cout << qPrintable (args.join(" "))<<endl;
2568 if ( !p->waitForStarted() ) success=false;
2571 QMessageBox::warning(0,
2573 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2575 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2577 for (int i=0; i<urls.size(); i++)
2579 // Try to open new tab in firefox
2580 p=new QProcess (this);
2581 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2582 p->start (browser,args);
2583 if ( !p->waitForStarted() ) success=false;
2586 QMessageBox::warning(0,
2588 tr("Couldn't start %1 to open a new tab").arg(browser));
2591 QMessageBox::warning(0,
2593 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2597 void Main::editOpenURL()
2600 VymModel *m=currentModel();
2603 QString url=m->getURL();
2605 if (url=="") return;
2606 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2607 procBrowser = new QProcess( this );
2609 procBrowser->start(browser,args);
2610 if ( !procBrowser->waitForStarted())
2612 // try to set path to browser
2613 QMessageBox::warning(0,
2615 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2616 tr("Please use Settings->")+tr("Set application to open an URL"));
2621 void Main::editOpenURLTab()
2623 VymModel *m=currentModel();
2627 urls.append(m->getURL());
2631 void Main::editOpenMultipleURLTabs()
2633 VymModel *m=currentModel();
2643 void Main::editURL()
2645 VymModel *m=currentModel();
2646 if (m) m->editURL();
2649 void Main::editLocalURL()
2651 VymModel *m=currentModel();
2652 if (m) m->editLocalURL();
2655 void Main::editHeading2URL()
2657 VymModel *m=currentModel();
2658 if (m) m->editHeading2URL();
2661 void Main::editBugzilla2URL()
2663 VymModel *m=currentModel();
2664 if (m) m->editBugzilla2URL();
2667 void Main::editFATE2URL()
2669 VymModel *m=currentModel();
2670 if (m) m->editFATE2URL();
2673 void Main::editHeadingFinished(VymModel *m)
2677 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2678 !prevSelection.isEmpty())
2679 m->select(prevSelection);
2685 void Main::editAttributeFinished()
2687 // only called from editHeading(), so there is a currentME
2690 MapEditor *me=currentMapEditor();
2693 me->setStateEditHeading (false);
2694 QPoint p; //Not used here, only to find out pos of branch
2696 QString s=me->getHeading(ok,p);
2698 #if defined(Q_OS_MACX)
2700 if (ok && s!=lineedit->text())
2701 me->setHeading(lineedit->text());
2703 lineedit->releaseKeyboard();
2707 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2708 !prevSelection.isEmpty())
2709 me->select(prevSelection);
2715 #include "attribute.h"
2716 #include "attributedialog.h"
2717 void Main::editAttribute()
2720 MapEditor *me=currentMapEditor();
2723 BranchObj *bo=me->getModel()->getSelectedBranch();
2726 AttributeDialog dia(this);
2727 dia.setTable (me->attributeTable() );
2729 dia.setMode (Definition);
2736 if (currentMapEditor())
2738 MapEditor *me=currentMapEditor();
2739 QString oldSel=me->getSelectString();
2741 if (lineedit->isVisible())
2742 editAttributeFinished();
2747 QString s=me->getHeading(ok,p);
2751 me->setStateEditHeading (true);
2752 #if defined(Q_OS_MACX)
2753 p=me->mapToGlobal (p);
2754 QDialog *d =new QDialog(NULL);
2755 QLineEdit *le=new QLineEdit (d);
2756 d->setWindowFlags (Qt::FramelessWindowHint);
2757 d->setGeometry(p.x(),p.y(),230,25);
2758 le->resize (d->width()-10,d->height());
2761 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2762 d->activateWindow();
2764 me->setHeading (le->text());
2767 editHeadingFinished();
2769 p=me->mapTo (this,p);
2770 lineedit->setGeometry(p.x(),p.y(),230,25);
2771 lineedit->setText(s);
2772 lineedit->setCursorPosition(1);
2773 lineedit->selectAll();
2775 lineedit->grabKeyboard();
2776 lineedit->setFocus();
2780 } // currentMapEditor()
2785 void Main::openVymLinks(const QStringList &vl)
2787 for (int j=0; j<vl.size(); j++)
2789 // compare path with already loaded maps
2792 for (i=0;i<=tabModel.count() -1;i++)
2794 if (vl.at(j)==tabModel.at(i)->getFilePath() )
2803 if (!QFile(vl.at(j)).exists() )
2804 QMessageBox::critical( 0, tr( "Critical Error" ),
2805 tr("Couldn't open map %1").arg(vl.at(j)));
2808 fileLoad (vl.at(j), NewMap);
2809 tabWidget->setCurrentIndex (tabWidget->count()-1);
2812 // Go to tab containing the map
2813 tabWidget->setCurrentIndex (index);
2817 void Main::editOpenVymLink()
2819 VymModel *m=currentModel();
2823 vl.append(m->getVymLink());
2828 void Main::editOpenMultipleVymLinks()
2830 QString currentVymLink;
2831 VymModel *m=currentModel();
2834 QStringList vl=m->getVymLinks();
2839 void Main::editVymLink()
2841 VymModel *m=currentModel();
2846 void Main::editDeleteVymLink()
2848 VymModel *m=currentModel();
2849 if (m) m->deleteVymLink();
2852 void Main::editToggleHideExport()
2854 VymModel *m=currentModel();
2855 if (m) m->toggleHideExport();
2858 void Main::editMapInfo()
2860 VymModel *m=currentModel();
2862 ExtraInfoDialog dia;
2863 dia.setMapName (m->getFileName() );
2864 dia.setAuthor (m->getAuthor() );
2865 dia.setComment(m->getComment() );
2869 /* FIXME-2 no stats at the moment (view dependent...)
2870 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2880 if (!bo->getNote().isEmpty() ) n++;
2881 f+= bo->countFloatImages();
2883 xl+=bo->countXLinks();
2886 stats+=QString ("%1 xLinks \n").arg (xl,6);
2887 stats+=QString ("%1 notes\n").arg (n,6);
2888 stats+=QString ("%1 images\n").arg (f,6);
2890 stats+=QString ("%1 branches\n").arg (m->countBranches(),6);
2891 dia.setStats (stats);
2893 // Finally show dialog
2894 if (dia.exec() == QDialog::Accepted)
2896 m->setAuthor (dia.getAuthor() );
2897 m->setComment (dia.getComment() );
2901 void Main::editMoveUp()
2903 VymModel *m=currentModel();
2904 if (m) m->moveBranchUp();
2907 void Main::editMoveDown()
2909 VymModel *m=currentModel();
2910 if (m) m->moveBranchDown();
2913 void Main::editSortChildren()
2915 VymModel *m=currentModel();
2916 if (m) m->sortChildren();
2919 void Main::editToggleScroll()
2921 VymModel *m=currentModel();
2922 if (m) m->toggleScroll();
2925 void Main::editUnscrollChildren()
2927 VymModel *m=currentModel();
2928 if (m) m->unscrollChildren();
2931 void Main::editAddMapCenter()
2933 VymModel *m=currentModel();
2940 void Main::editNewBranch()
2942 VymModel *m=currentModel();
2945 BranchObj *bo=m->getSelectedBranch();
2946 prevSelection=m->getSelectString(bo);
2947 BranchObj *newbo=m->addNewBranch(0);
2954 if (actionSettingsAutoEditNewBranch->isOn())
2956 currentMapEditor()->editHeading();
2959 if (!prevSelection.isEmpty())
2961 m->select(prevSelection);
2967 void Main::editNewBranchBefore()
2969 VymModel *m=currentModel();
2972 BranchObj *bo=m->getSelectedBranch();
2973 BranchObj *newbo=m->addNewBranchBefore();
2980 if (actionSettingsAutoEditNewBranch->isOn())
2982 if (!actionSettingsAutoSelectNewBranch->isOn())
2983 prevSelection=m->getSelectString(bo);
2984 currentMapEditor()->editHeading();
2989 void Main::editNewBranchAbove()
2991 VymModel *m=currentModel();
2994 BranchObj *bo=m->getSelectedBranch();
2995 BranchObj *newbo=m->addNewBranch (-1);
3002 if (actionSettingsAutoEditNewBranch->isOn())
3004 if (!actionSettingsAutoSelectNewBranch->isOn())
3005 prevSelection=m->getSelectString (bo);
3006 currentMapEditor()->editHeading();
3011 void Main::editNewBranchBelow()
3013 VymModel *m=currentModel();
3016 BranchObj *bo=m->getSelectedBranch();
3017 BranchObj *newbo=m->addNewBranch (1);
3024 if (actionSettingsAutoEditNewBranch->isOn())
3026 if (!actionSettingsAutoSelectNewBranch->isOn())
3027 prevSelection=m->getSelectString(bo);
3028 currentMapEditor()->editHeading();
3033 void Main::editImportAdd()
3035 fileLoad (ImportAdd);
3038 void Main::editImportReplace()
3040 fileLoad (ImportReplace);
3043 void Main::editSaveBranch()
3045 fileSaveAs (PartOfMap);
3048 void Main::editDeleteKeepChildren()
3050 VymModel *m=currentModel();
3051 if (m) m->deleteKeepChildren();
3054 void Main::editDeleteChildren()
3056 VymModel *m=currentModel();
3057 if (m) m->deleteChildren();
3060 void Main::editDeleteSelection()
3062 VymModel *m=currentModel();
3063 if (m && actionSettingsUseDelKey->isOn())
3064 m->deleteSelection();
3067 void Main::editUpperBranch()
3069 VymModel *m=currentModel();
3070 if (m) m->selectUpperBranch();
3073 void Main::editLowerBranch()
3075 VymModel *m=currentModel();
3076 if (m) m->selectLowerBranch();
3079 void Main::editLeftBranch()
3081 VymModel *m=currentModel();
3082 if (m) m->selectLeftBranch();
3085 void Main::editRightBranch()
3087 VymModel *m=currentModel();
3088 if (m) m->selectRightBranch();
3091 void Main::editFirstBranch()
3093 VymModel *m=currentModel();
3094 if (m) m->selectFirstBranch();
3097 void Main::editLastBranch()
3099 VymModel *m=currentModel();
3100 if (m) m->selectLastBranch();
3103 void Main::editLoadImage()
3105 VymModel *m=currentModel();
3106 if (m) m->loadFloatImage();
3109 void Main::editSaveImage()
3111 VymModel *m=currentModel();
3112 if (m) m->saveFloatImage();
3115 void Main::editFollowXLink(QAction *a)
3118 VymModel *m=currentModel();
3120 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3123 void Main::editEditXLink(QAction *a)
3125 VymModel *m=currentModel();
3127 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3130 void Main::formatSelectColor()
3132 QColor col = QColorDialog::getColor((currentColor ), this );
3133 if ( !col.isValid() ) return;
3134 colorChanged( col );
3137 void Main::formatPickColor()
3139 VymModel *m=currentModel();
3141 colorChanged( m->getCurrentHeadingColor() );
3144 void Main::colorChanged(QColor c)
3146 QPixmap pix( 16, 16 );
3148 actionFormatColor->setIconSet( pix );
3152 void Main::formatColorBranch()
3154 VymModel *m=currentModel();
3155 if (m) m->colorBranch(currentColor);
3158 void Main::formatColorSubtree()
3160 VymModel *m=currentModel();
3161 if (m) m->colorSubtree (currentColor);
3164 void Main::formatLinkStyleLine()
3166 VymModel *m=currentModel();
3169 m->setMapLinkStyle("StyleLine");
3170 actionFormatLinkStyleLine->setOn(true);
3174 void Main::formatLinkStyleParabel()
3176 VymModel *m=currentModel();
3179 m->setMapLinkStyle("StyleParabel");
3180 actionFormatLinkStyleParabel->setOn(true);
3184 void Main::formatLinkStylePolyLine()
3186 VymModel *m=currentModel();
3189 m->setMapLinkStyle("StylePolyLine");
3190 actionFormatLinkStylePolyLine->setOn(true);
3194 void Main::formatLinkStylePolyParabel()
3196 VymModel *m=currentModel();
3199 m->setMapLinkStyle("StylePolyParabel");
3200 actionFormatLinkStylePolyParabel->setOn(true);
3204 void Main::formatSelectBackColor()
3206 VymModel *m=currentModel();
3207 if (m) m->selectMapBackgroundColor();
3210 void Main::formatSelectBackImage()
3212 VymModel *m=currentModel();
3214 m->selectMapBackgroundImage();
3217 void Main::formatSelectLinkColor()
3219 VymModel *m=currentModel();
3222 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3223 m->setMapDefLinkColor( col );
3227 void Main::formatSelectSelectionColor()
3229 VymModel *m=currentModel();
3232 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3233 m->setSelectionColor (col);
3238 void Main::formatToggleLinkColorHint()
3240 VymModel *m=currentModel();
3241 if (m) m->toggleMapLinkColorHint();
3245 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3247 VymModel *m=currentModel();
3249 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3252 void Main::viewZoomReset()
3254 if (currentMapEditor())
3258 currentMapEditor()->setMatrix( m );
3262 void Main::viewZoomIn()
3264 if (currentMapEditor())
3266 QMatrix m = currentMapEditor()->matrix();
3267 m.scale( 1.25, 1.25 );
3268 currentMapEditor()->setMatrix( m );
3272 void Main::viewZoomOut()
3274 if (currentMapEditor())
3276 QMatrix m = currentMapEditor()->matrix();
3277 m.scale( 0.8, 0.8 );
3278 currentMapEditor()->setMatrix( m );
3282 void Main::viewCenter()
3284 VymModel *m=currentModel();
3285 if (m) m->ensureSelectionVisible();
3288 void Main::networkStartServer()
3290 VymModel *m=currentModel();
3291 if (m) m->newServer();
3294 void Main::networkConnect()
3296 VymModel *m=currentModel();
3297 if (m) m->connectToServer();
3300 bool Main::settingsPDF()
3302 // Default browser is set in constructor
3304 QString text = QInputDialog::getText(
3305 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3306 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3308 settings.setValue ("/mainwindow/readerPDF",text);
3313 bool Main::settingsURL()
3315 // Default browser is set in constructor
3317 QString text = QInputDialog::getText(
3318 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3319 settings.value("/mainwindow/readerURL").toString()
3322 settings.setValue ("/mainwindow/readerURL",text);
3326 void Main::settingsMacroDir()
3328 QDir defdir(vymBaseDir.path() + "/macros");
3329 if (!defdir.exists())
3331 QDir dir=QFileDialog::getExistingDirectory (
3333 tr ("Directory with vym macros:"),
3334 settings.value ("/macros/macroDir",defdir.path()).toString()
3337 settings.setValue ("/macros/macroDir",dir.absolutePath());
3340 void Main::settingsUndoLevels()
3343 int i = QInputDialog::getInteger(
3345 tr("QInputDialog::getInteger()"),
3346 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3349 settings.setValue ("/mapeditor/stepsTotal",i);
3350 QMessageBox::information( this, tr( "VYM -Information:" ),
3351 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3355 void Main::settingsAutosaveToggle()
3357 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3360 void Main::settingsAutosaveTime()
3363 int i = QInputDialog::getInteger(
3365 tr("QInputDialog::getInteger()"),
3366 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3368 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3371 void Main::settingsWriteBackupFileToggle()
3373 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3376 void Main::settingsToggleAnimation()
3378 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3381 void Main::settingsToggleDelKey()
3383 if (actionSettingsUseDelKey->isOn())
3385 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3388 actionDelete->setAccel (QKeySequence (""));
3392 void Main::windowToggleNoteEditor()
3394 if (textEditor->isVisible() )
3395 windowHideNoteEditor();
3397 windowShowNoteEditor();
3400 void Main::windowToggleHistory()
3402 if (historyWindow->isVisible())
3403 historyWindow->hide();
3405 historyWindow->show();
3409 void Main::windowToggleProperty()
3411 if (branchPropertyWindow->isVisible())
3412 branchPropertyWindow->hide();
3414 branchPropertyWindow->show();
3415 branchPropertyWindow->setModel (currentModel() );
3418 void Main::windowToggleAntiAlias()
3420 bool b=actionViewToggleAntiAlias->isOn();
3422 for (int i=0;i<tabModel.count();i++)
3424 me=tabModel.at(i)->getMapEditor();
3425 if (me) me->setAntiAlias(b);
3430 bool Main::isAliased()
3432 return actionViewToggleAntiAlias->isOn();
3435 bool Main::hasSmoothPixmapTransform()
3437 return actionViewToggleSmoothPixmapTransform->isOn();
3440 void Main::windowToggleSmoothPixmap()
3442 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3444 for (int i=0;i<tabModel.count();i++)
3447 me=tabModel.at(i)->getMapEditor();
3448 if (me) me->setSmoothPixmap(b);
3452 void Main::updateHistory(SimpleSettings &undoSet)
3454 historyWindow->update (undoSet);
3457 void Main::updateNoteFlag()
3459 // this slot is connected to TextEditor::textHasChanged()
3461 VymModel *m=currentModel();
3462 if (m) m->updateNoteFlag();
3466 void Main::updateNoteInEditor (VymModel *model, const NoteObj ¬e)
3468 if (model&& model==currentModel() )
3470 textEditor->setNote (note);
3475 void Main::updateContent (QModelIndex index )
3477 cout << "Main::updateContent model="<<sender();
3478 TreeItem *ti=((VymModel*)sender())->getItem(index);
3479 cout << " item="<<ti->getHeading().toStdString()<<" ("<<ti<<")"<<endl;
3480 textEditor->setNote (ti->getNoteObj() );
3483 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3485 //branchPropertyWindow->setModel (model ); //FIXME-1 this used to be called from BranchObj::select()
3486 if (model && model==currentModel() )
3490 if (!oldsel.indexes().isEmpty() )
3492 ti=model->getItem(oldsel.indexes().first());
3493 //cout << "Main::changeSel getting note from "<<ti->getHeading().toStdString()<<": \""<<ti->getNote().toStdString()<<"\""<<endl;
3494 ti->setNoteObj (textEditor->getNoteObj(),false );
3496 if (!newsel.indexes().isEmpty() )
3498 ti=model->getItem(newsel.indexes().first());
3499 if (!ti->getNoteObj().isEmpty() )
3501 //cout << "Main::changeSel setting note of "<<ti->getHeading().toStdString()<<" m=("<<ti->getModel()<<") to \""<<ti->getNote().toStdString()<<"\""<<endl;
3502 textEditor->setNote(ti->getNoteObj() );
3504 textEditor->setNote(NoteObj() );
3507 textEditor->setInactive();
3510 // Show URL and link in statusbar
3512 QString s=model->getURL();
3513 if (!s.isEmpty() ) status+="URL: "+s+" ";
3514 s=model->getVymLink();
3515 if (!s.isEmpty() ) status+="Link: "+s;
3516 if (!status.isEmpty() ) statusMessage (status);
3519 // Update Toolbar // FIXME-1, was so far in BranchObj
3520 //updateFlagsToolbar();
3527 void Main::updateActions()
3529 VymModel *m =currentModel();
3530 LinkableMapObj *selection;
3534 actionFilePrint->setEnabled (true);
3537 selection=m->getSelectedLMO();
3539 // Link style in context menu
3540 switch (m->getMapLinkStyle())
3542 case LinkableMapObj::Line:
3543 actionFormatLinkStyleLine->setOn(true);
3545 case LinkableMapObj::Parabel:
3546 actionFormatLinkStyleParabel->setOn(true);
3548 case LinkableMapObj::PolyLine:
3549 actionFormatLinkStylePolyLine->setOn(true);
3551 case LinkableMapObj::PolyParabel:
3552 actionFormatLinkStylePolyParabel->setOn(true);
3559 QPixmap pix( 16, 16 );
3560 pix.fill( m->getMapBackgroundColor() );
3561 actionFormatBackColor->setIconSet( pix );
3562 pix.fill( m->getSelectionColor() );
3563 actionFormatSelectionColor->setIconSet( pix );
3564 pix.fill( m->getMapDefLinkColor() );
3565 actionFormatLinkColor->setIconSet( pix );
3568 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3573 actionFilePrint->setEnabled (false);
3579 // updateActions is also called when NoteEditor is closed
3580 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3581 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3582 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3584 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3585 actionFormatLinkColorHint->setOn(true);
3587 actionFormatLinkColorHint->setOn(false);
3590 if (m && m->hasChanged() )
3591 actionFileSave->setEnabled( true);
3593 actionFileSave->setEnabled( true);
3594 if (m && m->isUndoAvailable())
3595 actionUndo->setEnabled( true);
3597 actionUndo->setEnabled( false);
3599 if (m && m->isRedoAvailable())
3600 actionRedo->setEnabled( true);
3602 actionRedo->setEnabled( false);
3606 if ( (typeid(*selection) == typeid(BranchObj)) ||
3607 (typeid(*selection) == typeid(MapCenterObj)) )
3609 BranchObj *bo=(BranchObj*)selection;
3610 // Take care of links
3611 if (bo->countXLinks()==0)
3613 branchXLinksContextMenuEdit->clear();
3614 branchXLinksContextMenuFollow->clear();
3619 branchXLinksContextMenuEdit->clear();
3620 branchXLinksContextMenuFollow->clear();
3621 for (int i=0; i<=bo->countXLinks();i++)
3623 bot=bo->XLinkTargetAt(i);
3626 s=bot->getHeading();
3627 if (s.length()>xLinkMenuWidth)
3628 s=s.left(xLinkMenuWidth)+"...";
3629 branchXLinksContextMenuFollow->addAction (s);
3630 branchXLinksContextMenuEdit->addAction (s);
3635 standardFlagsDefault->setEnabled (true);
3637 actionToggleScroll->setEnabled (true);
3638 if ( bo->isScrolled() )
3639 actionToggleScroll->setOn(true);
3641 actionToggleScroll->setOn(false);
3643 if ( bo->getURL().isEmpty() )
3645 actionOpenURL->setEnabled (false);
3646 actionOpenURLTab->setEnabled (false);
3650 actionOpenURL->setEnabled (true);
3651 actionOpenURLTab->setEnabled (true);
3653 if ( bo->getVymLink().isEmpty() )
3655 actionOpenVymLink->setEnabled (false);
3656 actionDeleteVymLink->setEnabled (false);
3659 actionOpenVymLink->setEnabled (true);
3660 actionDeleteVymLink->setEnabled (true);
3663 if (bo->canMoveBranchUp())
3664 actionMoveUp->setEnabled (true);
3666 actionMoveUp->setEnabled (false);
3667 if (bo->canMoveBranchDown())
3668 actionMoveDown->setEnabled (true);
3670 actionMoveDown->setEnabled (false);
3672 actionSortChildren->setEnabled (true);
3674 actionToggleHideExport->setEnabled (true);
3675 actionToggleHideExport->setOn (bo->hideInExport() );
3677 actionFileSave->setEnabled (true);
3678 actionCopy->setEnabled (true);
3679 actionCut->setEnabled (true);
3680 if (!clipboardEmpty)
3681 actionPaste->setEnabled (true);
3683 actionPaste->setEnabled (false);
3684 for (int i=0; i<actionListBranches.size(); ++i)
3685 actionListBranches.at(i)->setEnabled(true);
3686 actionDelete->setEnabled (true);
3687 actionFormatHideLinkUnselected->setOn
3688 (selection->getHideLinkUnselected());
3690 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3692 FloatObj *fo=(FloatImageObj*)selection;
3694 actionOpenURL->setEnabled (false);
3695 actionOpenVymLink->setEnabled (false);
3696 actionDeleteVymLink->setEnabled (false);
3697 actionToggleHideExport->setEnabled (true);
3698 actionToggleHideExport->setOn (fo->hideInExport() );
3701 actionCopy->setEnabled (true);
3702 actionCut->setEnabled (true);
3703 actionPaste->setEnabled (false);
3704 for (int i=0; i<actionListBranches.size(); ++i)
3705 actionListBranches.at(i)->setEnabled(false);
3706 actionDelete->setEnabled (true);
3707 actionFormatHideLinkUnselected->setOn
3708 ( selection->getHideLinkUnselected());
3709 actionMoveUp->setEnabled (false);
3710 actionMoveDown->setEnabled (false);
3715 standardFlagsDefault->setEnabled (false);
3716 actionFileSave->setEnabled (false);
3717 actionCopy->setEnabled (false);
3718 actionCut->setEnabled (false);
3719 actionPaste->setEnabled (false);
3720 for (int i=0; i<actionListBranches.size(); ++i)
3721 actionListBranches.at(i)->setEnabled(false);
3723 actionToggleScroll->setEnabled (false);
3724 actionOpenURL->setEnabled (false);
3725 actionOpenVymLink->setEnabled (false);
3726 actionDeleteVymLink->setEnabled (false);
3727 actionHeading2URL->setEnabled (false);
3728 actionDelete->setEnabled (false);
3729 actionMoveUp->setEnabled (false);
3730 actionMoveDown->setEnabled (false);
3731 actionSortChildren->setEnabled (false);
3732 actionToggleHideExport->setEnabled (false);
3736 Main::ModMode Main::getModMode()
3738 if (actionModModeColor->isOn()) return ModModeColor;
3739 if (actionModModeCopy->isOn()) return ModModeCopy;
3740 if (actionModModeXLink->isOn()) return ModModeXLink;
3744 bool Main::autoEditNewBranch()
3746 return actionSettingsAutoEditNewBranch->isOn();
3749 bool Main::autoSelectNewBranch()
3751 return actionSettingsAutoSelectNewBranch->isOn();
3754 bool Main::useFlagGroups()
3756 return actionSettingsUseFlagGroups->isOn();
3759 void Main::windowShowNoteEditor()
3761 textEditor->setShowWithMain(true);
3763 actionViewToggleNoteEditor->setOn (true);
3766 void Main::windowHideNoteEditor()
3768 textEditor->setShowWithMain(false);
3770 actionViewToggleNoteEditor->setOn (false);
3773 void Main::setScript (const QString &script)
3775 scriptEditor->setScript (script);
3778 void Main::runScript (const QString &script)
3780 VymModel *m=currentModel();
3781 if (m) m->runScript (script);
3784 void Main::runScriptEverywhere (const QString &script)
3787 for (int i=0;i<=tabWidget->count() -1;i++)
3789 me=(MapEditor*)tabWidget->page(i);
3790 if (me) me->getModel()->runScript (script);
3794 void Main::windowNextEditor()
3796 if (tabWidget->currentIndex() < tabWidget->count())
3797 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3800 void Main::windowPreviousEditor()
3802 if (tabWidget->currentIndex() >0)
3803 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3806 void Main::standardFlagChanged()
3808 if (currentMapEditor())
3809 currentMapEditor()->toggleStandardFlag(sender()->name());
3812 void Main::testFunction1()
3814 if (!currentMapEditor()) return;
3815 currentMapEditor()->testFunction1();
3819 void Main::testFunction2()
3821 if (!currentMapEditor()) return;
3822 currentMapEditor()->testFunction2();
3825 void Main::testCommand()
3827 if (!currentMapEditor()) return;
3828 scriptEditor->show();
3831 QString com = QInputDialog::getText(
3832 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3833 if (ok) currentMapEditor()->parseAtom(com);
3837 void Main::helpDoc()
3839 QString locale = QLocale::system().name();
3841 if (locale.left(2)=="es")
3842 docname="vym_es.pdf";
3846 QStringList searchList;
3848 #if defined(Q_OS_MACX)
3849 searchList << "./vym.app/Contents/Resources/doc";
3850 #elif defined(Q_OS_WIN32)
3851 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3853 #if defined(VYM_DOCDIR)
3854 searchList << VYM_DOCDIR;
3856 // default path in SUSE LINUX
3857 searchList << "/usr/share/doc/packages/vym";
3860 searchList << "doc"; // relative path for easy testing in tarball
3861 searchList << "doc/tex"; // Easy testing working on vym.tex
3862 searchList << "/usr/share/doc/vym"; // Debian
3863 searchList << "/usr/share/doc/packages";// Knoppix
3867 for (int i=0; i<searchList.count(); ++i)
3869 docfile.setFileName(searchList.at(i)+"/"+docname);
3870 if (docfile.exists())
3879 QMessageBox::critical(0,
3880 tr("Critcal error"),
3881 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3886 Process *pdfProc = new Process();
3887 args << QDir::toNativeSeparators(docfile.fileName());
3889 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3890 if ( !pdfProc->waitForStarted() )
3893 QMessageBox::warning(0,
3895 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3896 tr("Please use Settings->")+tr("Set application to open PDF files"));
3903 void Main::helpDemo()
3905 QStringList filters;
3906 filters <<"VYM example map (*.vym)";
3907 QFileDialog *fd=new QFileDialog( this);
3908 #if defined(Q_OS_MACX)
3909 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3911 // default path in SUSE LINUX
3912 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3915 fd->setFileMode (QFileDialog::ExistingFiles);
3916 fd->setFilters (filters);
3917 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3921 if ( fd->exec() == QDialog::Accepted )
3923 lastFileDir=fd->directory().path();
3924 QStringList flist = fd->selectedFiles();
3925 QStringList::Iterator it = flist.begin();
3926 while( it != flist.end() )
3929 fileLoad(*it, NewMap);
3937 void Main::helpAbout()
3940 ad.setName ("aboutwindow");
3941 ad.setMinimumSize(500,500);
3942 ad.resize (QSize (500,500));
3946 void Main::helpAboutQT()
3948 QMessageBox::aboutQt( this, "Qt Application Example" );
3951 void Main::callMacro ()
3953 QAction *action = qobject_cast<QAction *>(sender());
3957 i=action->data().toInt();
3958 QString mDir (settings.value ("macros/macroDir").toString() );
3960 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3962 if ( !f.open( QIODevice::ReadOnly ) )
3964 QMessageBox::warning(0,
3966 tr("Couldn't find a macro at %1.\n").arg(fn)+
3967 tr("Please use Settings->")+tr("Set directory for vym macros"));
3971 QTextStream ts( &f );
3972 QString macro= ts.read();
3974 if (! macro.isEmpty())
3976 VymModel *m=currentModel();
3977 if (m) m->runScript(macro);