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;
77 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
78 QMainWindow(parent,name,f)
82 setCaption ("VYM - View Your Mind");
84 // Load window settings
85 #if defined(Q_OS_WIN32)
86 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
88 setWindowState(Qt::WindowMaximized);
93 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
94 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
97 // Sometimes we may need to remember old selections
101 currentColor=Qt::black;
103 // Create unique temporary directory
105 tmpVymDir=makeTmpDir (ok,"vym");
108 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
111 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
113 // Create direcctory for clipboard
114 clipboardDir=tmpVymDir+"/clipboard";
115 clipboardFile="map.xml";
116 QDir d(clipboardDir);
117 d.mkdir (clipboardDir,true);
118 makeSubDirs (clipboardDir);
123 // 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 lineedit=new QLineEdit (this);
207 setCentralWidget(tabWidget);
211 setupFormatActions();
215 setupNetworkActions();
216 setupSettingsActions();
219 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
224 restoreState (settings.value("/mainwindow/state",0).toByteArray());
232 #if defined(Q_OS_WIN32)
233 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
235 settings.setValue ("/mainwindow/geometry/size", size());
236 settings.setValue ("/mainwindow/geometry/pos", pos());
237 settings.setValue ("/mainwindow/state",saveState(0));
239 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
240 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
241 settings.setValue( "/version/version", vymVersion );
242 settings.setValue( "/version/builddate", vymBuildDate );
244 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
245 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
246 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
247 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
248 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
249 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
250 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
251 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
253 //TODO save scriptEditor settings
255 // call the destructors
257 delete historyWindow;
258 delete branchPropertyWindow;
260 // Remove temporary directory
261 removeDir (QDir(tmpVymDir));
264 void Main::loadCmdLine()
266 /* TODO draw some kind of splashscreen while loading...
272 QStringList flist=options.getFileList();
273 QStringList::Iterator it=flist.begin();
275 while (it !=flist.end() )
277 fileLoad (*it, NewMap);
283 void Main::statusMessage(const QString &s)
285 statusBar()->message( s);
288 void Main::closeEvent (QCloseEvent* )
294 void Main::setupFileActions()
296 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
297 QToolBar *tb = addToolBar( tr ("&Map") );
298 tb->setObjectName ("mapTB");
301 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
302 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
303 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
305 fileMenu->addAction (a);
306 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
308 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
309 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
310 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
311 fileMenu->addAction (a);
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
315 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
316 a->setStatusTip (tr( "Open","Status tip File menu" ) );
317 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
319 fileMenu->addAction (a);
320 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
322 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
323 fileMenu->addSeparator();
325 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
326 a->setStatusTip ( tr( "Save","Status tip file menu" ));
327 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
329 fileMenu->addAction (a);
330 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
333 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
334 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
335 fileMenu->addAction (a);
336 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
338 fileMenu->addSeparator();
340 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
342 a = new QAction(tr("KDE Bookmarks"), this);
343 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
344 a->addTo (fileImportMenu);
345 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
347 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
349 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
350 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
351 a->addTo (fileImportMenu);
352 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
355 a = new QAction("Freemind...",this);
356 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
357 fileImportMenu->addAction (a);
358 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
360 a = new QAction("Mind Manager...",this);
361 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
362 fileImportMenu->addAction (a);
363 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
365 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
366 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
367 fileImportMenu->addAction (a);
368 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
370 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
372 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
373 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
374 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
375 fileExportMenu->addAction (a);
377 a = new QAction( "Open Office...", this);
378 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
379 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
380 fileExportMenu->addAction (a);
382 a = new QAction( "Webpage (XHTML)...",this );
383 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
384 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
385 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
386 fileExportMenu->addAction (a);
388 a = new QAction( "Text (ASCII)...", this);
389 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
391 fileExportMenu->addAction (a);
393 a = new QAction( "Spreadsheet (CSV)...", this);
394 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
395 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
396 fileExportMenu->addAction (a);
398 a = new QAction( tr("KDE Bookmarks","File menu"), this);
399 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
400 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
401 fileExportMenu->addAction (a);
403 a = new QAction( "Taskjuggler...", this );
404 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
405 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
406 fileExportMenu->addAction (a);
408 a = new QAction( "LaTeX...", this);
409 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
410 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
411 fileExportMenu->addAction (a);
413 a = new QAction( "XML..." , this );
414 a->setStatusTip (tr( "Export as %1").arg("XML"));
415 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
416 fileExportMenu->addAction (a);
418 fileMenu->addSeparator();
420 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
421 a->setStatusTip ( tr( "Print" ,"File menu") );
422 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
424 fileMenu->addAction (a);
425 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
428 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
429 a->setStatusTip (tr( "Close Map" ) );
430 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
431 fileMenu->addAction (a);
432 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
434 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
435 a->setStatusTip ( tr( "Exit")+" "+vymName );
436 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
437 fileMenu->addAction (a);
438 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
443 void Main::setupEditActions()
445 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
446 tb->setLabel( "Edit Actions" );
447 tb->setObjectName ("actionsTB");
448 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
452 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
453 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
454 a->setStatusTip (tr( "Undo" ) );
455 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
456 a->setEnabled (false);
458 editMenu->addAction (a);
461 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
462 a->setStatusTip (tr( "Redo" ));
463 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
465 editMenu->addAction (a);
466 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
469 editMenu->addSeparator();
470 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
471 a->setStatusTip ( tr( "Copy" ) );
472 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
473 a->setEnabled (false);
475 editMenu->addAction (a);
476 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
479 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
480 a->setStatusTip ( tr( "Cut" ) );
481 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
482 a->setEnabled (false);
484 editMenu->addAction (a);
486 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
488 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
489 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
490 a->setStatusTip ( tr( "Paste" ) );
491 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
492 a->setEnabled (false);
494 editMenu->addAction (a);
498 // Shortcuts to modify heading:
499 a = new QAction(tr( "Edit heading","Edit menu" ),this);
500 a->setStatusTip ( tr( "edit Heading" ));
501 a->setShortcut ( Qt::Key_Enter); //Edit heading
502 // a->setShortcutContext (Qt::WindowShortcut);
504 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
505 actionListBranches.append(a);
506 a = new QAction( tr( "Edit heading","Edit menu" ), this);
507 a->setStatusTip (tr( "edit Heading" ));
508 a->setShortcut (Qt::Key_Return ); //Edit heading
509 //a->setShortcutContext (Qt::WindowShortcut);
511 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
512 actionListBranches.append(a);
513 editMenu->addAction (a);
517 a = new QAction( tr( "Edit heading","Edit menu" ), this);
518 a->setStatusTip (tr( "edit Heading" ));
519 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
520 a->setShortcutContext (Qt::WindowShortcut);
522 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
523 actionListBranches.append(a);
525 // Shortcut to delete selection
526 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
527 a->setStatusTip (tr( "Delete Selection" ));
528 a->setShortcut ( Qt::Key_Delete); //Delete selection
529 a->setShortcutContext (Qt::WindowShortcut);
531 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
534 // Shortcut to add mapcenter
535 a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
536 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
537 actionEditAddMapCenter = a;
540 // Shortcut to add branch
541 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
542 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
543 alt->setShortcut (Qt::Key_A); //Add branch
544 alt->setShortcutContext (Qt::WindowShortcut);
546 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
547 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
548 a->setStatusTip ( tr( "Add a branch as child of selection" ));
549 a->setShortcut (Qt::Key_Insert); //Add branch
550 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
551 actionListBranches.append(a);
552 #if defined (Q_OS_MACX)
553 // In OSX show different shortcut in menues, the keys work indepently always
554 actionEditAddBranch=alt;
556 actionEditAddBranch=a;
558 editMenu->addAction (actionEditAddBranch);
559 tb->addAction (actionEditAddBranch);
562 // Add branch by inserting it at selection
563 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
564 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
565 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
566 a->setShortcutContext (Qt::WindowShortcut);
568 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
569 a->setEnabled (false);
570 actionListBranches.append(a);
571 actionEditAddBranchBefore=a;
572 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
573 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
574 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
575 a->setShortcutContext (Qt::WindowShortcut);
577 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
578 actionListBranches.append(a);
581 a = new QAction(tr( "Add branch above","Edit menu" ), this);
582 a->setStatusTip ( tr( "Add a branch above selection" ));
583 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
584 a->setShortcutContext (Qt::WindowShortcut);
586 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
587 a->setEnabled (false);
588 actionListBranches.append(a);
589 actionEditAddBranchAbove=a;
590 a = new QAction(tr( "Add branch above","Edit menu" ), this);
591 a->setStatusTip ( tr( "Add a branch above selection" ));
592 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
593 a->setShortcutContext (Qt::WindowShortcut);
595 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
596 actionListBranches.append(a);
599 a = new QAction(tr( "Add branch below","Edit menu" ), this);
600 a->setStatusTip ( tr( "Add a branch below selection" ));
601 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
602 a->setShortcutContext (Qt::WindowShortcut);
604 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
605 a->setEnabled (false);
606 actionListBranches.append(a);
607 actionEditAddBranchBelow=a;
608 a = new QAction(tr( "Add branch below","Edit menu" ), this);
609 a->setStatusTip ( tr( "Add a branch below selection" ));
610 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
611 a->setShortcutContext (Qt::WindowShortcut);
613 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
614 actionListBranches.append(a);
616 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
617 a->setStatusTip ( tr( "Move branch up" ) );
618 a->setShortcut (Qt::Key_PageUp ); // Move branch up
619 a->setEnabled (false);
621 editMenu->addAction (a);
622 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
625 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
626 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
627 a->setStatusTip (tr( "Move branch down" ) );
628 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
629 a->setEnabled (false);
631 editMenu->addAction (a);
632 actionEditMoveDown=a;
634 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
635 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
636 a->setEnabled (true);
638 editMenu->addAction (a);
639 actionEditSortChildren=a;
641 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
642 a->setShortcut ( Qt::Key_ScrollLock );
643 a->setStatusTip (tr( "Scroll branch" ) );
644 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
646 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
647 alt->setShortcut ( Qt::Key_S ); // Scroll branch
648 alt->setStatusTip (tr( "Scroll branch" ));
649 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
650 #if defined(Q_OS_MACX)
651 actionEditToggleScroll=alt;
653 actionEditToggleScroll=a;
655 actionEditToggleScroll->setEnabled (false);
656 actionEditToggleScroll->setToggleAction(true);
657 tb->addAction (actionEditToggleScroll);
658 editMenu->addAction ( actionEditToggleScroll);
659 editMenu->addAction (actionEditToggleScroll);
662 actionListBranches.append(actionEditToggleScroll);
664 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
665 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
666 editMenu->addAction (a);
667 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
669 editMenu->addSeparator();
671 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
672 a->setStatusTip (tr( "Find" ) );
673 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
674 editMenu->addAction (a);
675 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
677 editMenu->addSeparator();
679 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
680 a->setShortcut (Qt::CTRL + Qt::Key_U );
681 a->setShortcut (tr( "Open URL" ));
684 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
687 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
688 a->setStatusTip (tr( "Open URL in new tab" ));
689 //a->setShortcut (Qt::CTRL+Qt::Key_U );
691 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
692 actionEditOpenURLTab=a;
694 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
695 a->setStatusTip (tr( "Open all URLs in subtree" ));
697 actionListBranches.append(a);
698 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
699 actionEditOpenMultipleURLTabs=a;
701 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
702 a->setStatusTip ( tr( "Edit URL" ) );
703 a->setShortcut ( Qt::Key_U );
704 a->setShortcutContext (Qt::WindowShortcut);
705 actionListBranches.append(a);
707 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
710 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
711 a->setStatusTip ( tr( "Edit local URL" ) );
712 a->setShortcut (Qt::SHIFT + Qt::Key_U );
713 a->setShortcutContext (Qt::WindowShortcut);
714 actionListBranches.append(a);
716 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
717 actionEditLocalURL=a;
719 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
720 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
721 a->setEnabled (false);
722 actionListBranches.append(a);
723 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
724 actionEditHeading2URL=a;
726 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
727 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
728 a->setEnabled (false);
729 actionListBranches.append(a);
730 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
731 actionEditBugzilla2URL=a;
733 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
734 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
735 a->setEnabled (false);
736 actionListBranches.append(a);
737 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
738 actionEditFATE2URL=a;
740 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
741 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
743 a->setEnabled (false);
744 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
745 actionEditOpenVymLink=a;
747 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
748 a->setStatusTip ( tr( "Open all vym links in subtree" ));
749 a->setEnabled (false);
750 actionListBranches.append(a);
751 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
752 actionEditOpenMultipleVymLinks=a;
755 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
756 a->setEnabled (false);
757 a->setStatusTip ( tr( "Edit link to another vym map" ));
758 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
759 actionListBranches.append(a);
762 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
763 a->setStatusTip ( tr( "Delete link to another vym map" ));
764 a->setEnabled (false);
765 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
766 actionEditDeleteVymLink=a;
768 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
769 a->setStatusTip ( tr( "Hide object in exports" ) );
770 a->setShortcut (Qt::Key_H );
771 a->setToggleAction(true);
773 a->setEnabled (false);
774 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
775 actionEditToggleHideExport=a;
777 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
778 a->setStatusTip ( tr( "Edit Map Info" ));
779 a->setEnabled (true);
780 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
783 // Import at selection (adding to selection)
784 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
785 a->setStatusTip (tr( "Add map at selection" ));
786 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
787 a->setEnabled (false);
788 actionListBranches.append(a);
789 actionEditImportAdd=a;
791 // Import at selection (replacing selection)
792 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
793 a->setStatusTip (tr( "Replace selection with map" ));
794 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
795 a->setEnabled (false);
796 actionListBranches.append(a);
797 actionEditImportReplace=a;
800 a = new QAction( tr( "Save selection","Edit menu" ), this);
801 a->setStatusTip (tr( "Save selection" ));
802 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
803 a->setEnabled (false);
804 actionListBranches.append(a);
805 actionEditSaveBranch=a;
807 // Only remove branch, not its children
808 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
809 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
810 a->setShortcut (Qt::ALT + Qt::Key_Delete );
811 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
812 a->setEnabled (false);
814 actionListBranches.append(a);
815 actionEditDeleteKeepChildren=a;
817 // Only remove children of a branch
818 a = new QAction( tr( "Remove children","Edit menu" ), this);
819 a->setStatusTip (tr( "Remove children of branch" ));
820 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
821 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
822 a->setEnabled (false);
823 actionListBranches.append(a);
824 actionEditDeleteChildren=a;
826 // Shortcuts for navigating with cursor:
827 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
828 a->setStatusTip ( tr( "Select upper branch" ));
829 a->setShortcut (Qt::Key_Up );
830 a->setShortcutContext (Qt::WindowShortcut);
832 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
833 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
834 a->setStatusTip (tr( "Select lower branch" ));
835 a->setShortcut ( Qt::Key_Down );
836 a->setShortcutContext (Qt::WindowShortcut);
838 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
839 a = new QAction(tr( "Select left branch","Edit menu" ), this);
840 a->setStatusTip ( tr( "Select left branch" ));
841 a->setShortcut (Qt::Key_Left );
842 a->setShortcutContext (Qt::WindowShortcut);
844 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
845 a = new QAction( tr( "Select child branch","Edit menu" ), this);
846 a->setStatusTip (tr( "Select right branch" ));
847 a->setShortcut (Qt::Key_Right);
848 a->setShortcutContext (Qt::WindowShortcut);
850 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
851 a = new QAction( tr( "Select first branch","Edit menu" ), this);
852 a->setStatusTip (tr( "Select first branch" ));
853 a->setShortcut (Qt::Key_Home );
854 a->setShortcutContext (Qt::WindowShortcut);
856 a->setEnabled (false);
857 editMenu->addAction (a);
858 actionListBranches.append(a);
859 actionEditSelectFirst=a;
860 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
861 a = new QAction( tr( "Select last branch","Edit menu" ),this);
862 a->setStatusTip (tr( "Select last branch" ));
863 a->setShortcut ( Qt::Key_End );
864 a->setShortcutContext (Qt::WindowShortcut);
866 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
867 a->setEnabled (false);
868 editMenu->addAction (a);
869 actionListBranches.append(a);
870 actionEditSelectLast=a;
872 a = new QAction( tr( "Add Image...","Edit menu" ), this);
873 a->setStatusTip (tr( "Add Image" ));
874 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
875 actionEditLoadImage=a;
877 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
878 a->setStatusTip (tr( "Set properties for selection" ));
879 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
880 a->setShortcutContext (Qt::WindowShortcut);
881 a->setToggleAction (true);
883 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
884 actionViewTogglePropertyWindow=a;
888 void Main::setupFormatActions()
890 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
892 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
893 tb->setObjectName ("formatTB");
896 pix.fill (Qt::black);
897 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
898 a->setStatusTip ( tr( "Set Color" ));
899 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
901 formatMenu->addAction (a);
903 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
904 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
905 a->setShortcut (Qt::CTRL + Qt::Key_K );
906 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
907 a->setEnabled (false);
909 formatMenu->addAction (a);
910 actionListBranches.append(a);
911 actionFormatPickColor=a;
913 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
914 a->setStatusTip ( tr( "Color branch" ) );
915 a->setShortcut (Qt::CTRL + Qt::Key_B);
916 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
917 a->setEnabled (false);
919 formatMenu->addAction (a);
920 actionListBranches.append(a);
921 actionFormatColorSubtree=a;
923 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
924 a->setStatusTip ( tr( "Color Subtree" ));
925 a->setShortcut (Qt::CTRL + Qt::Key_T);
926 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
927 a->setEnabled (false);
928 formatMenu->addAction (a);
930 actionListBranches.append(a);
931 actionFormatColorSubtree=a;
933 formatMenu->addSeparator();
934 actionGroupFormatLinkStyles=new QActionGroup ( this);
935 actionGroupFormatLinkStyles->setExclusive (true);
936 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
937 a->setStatusTip (tr( "Line" ));
938 a->setToggleAction(true);
939 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
940 formatMenu->addAction (a);
941 actionFormatLinkStyleLine=a;
942 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
943 a->setStatusTip (tr( "Line" ));
944 a->setToggleAction(true);
945 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
946 formatMenu->addAction (a);
947 actionFormatLinkStyleParabel=a;
948 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
949 a->setStatusTip (tr( "PolyLine" ));
950 a->setToggleAction(true);
951 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
952 formatMenu->addAction (a);
953 actionFormatLinkStylePolyLine=a;
954 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
955 a->setStatusTip (tr( "PolyParabel" ) );
956 a->setToggleAction(true);
957 a->setChecked (true);
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
959 formatMenu->addAction (a);
960 actionFormatLinkStylePolyParabel=a;
962 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
963 a->setStatusTip (tr( "Hide link" ));
964 a->setToggleAction(true);
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
966 actionFormatHideLinkUnselected=a;
968 formatMenu->addSeparator();
969 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
970 a->setStatusTip (tr( "Use same color for links and headings" ));
971 a->setToggleAction(true);
972 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
973 formatMenu->addAction (a);
974 actionFormatLinkColorHint=a;
976 pix.fill (Qt::white);
977 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
978 a->setStatusTip (tr( "Set Link Color" ));
979 formatMenu->addAction (a);
980 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
981 actionFormatLinkColor=a;
983 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
984 a->setStatusTip (tr( "Set Selection Color" ));
985 formatMenu->addAction (a);
986 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
987 actionFormatSelectionColor=a;
989 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
990 a->setStatusTip (tr( "Set Background Color" ));
991 formatMenu->addAction (a);
992 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
993 actionFormatBackColor=a;
995 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
996 a->setStatusTip (tr( "Set Background image" ));
997 formatMenu->addAction (a);
998 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
999 actionFormatBackImage=a;
1003 void Main::setupViewActions()
1005 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1006 tb->setLabel( "View Actions" );
1007 tb->setObjectName ("viewTB");
1008 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1011 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1012 a->setStatusTip ( tr( "Zoom reset" ) );
1013 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1015 viewMenu->addAction (a);
1016 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1018 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1019 a->setStatusTip (tr( "Zoom in" ));
1020 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1022 viewMenu->addAction (a);
1023 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1025 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1026 a->setStatusTip (tr( "Zoom out" ));
1027 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1029 viewMenu->addAction (a);
1030 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1032 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1033 a->setStatusTip (tr( "Show selection" ));
1034 a->setShortcut (Qt::Key_Period);
1036 viewMenu->addAction (a);
1037 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1039 viewMenu->addSeparator();
1041 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1042 a->setStatusTip ( tr( "Show Note Editor" ));
1043 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1044 a->setToggleAction(true);
1046 viewMenu->addAction (a);
1047 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1048 actionViewToggleNoteEditor=a;
1050 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1051 a->setStatusTip ( tr( "Show History Window" ));
1052 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1053 a->setToggleAction(true);
1055 viewMenu->addAction (a);
1056 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1057 actionViewToggleHistoryWindow=a;
1059 viewMenu->addAction (actionViewTogglePropertyWindow);
1061 viewMenu->addSeparator();
1063 a = new QAction(tr( "Antialiasing","View action" ),this );
1064 a->setStatusTip ( tr( "Antialiasing" ));
1065 a->setToggleAction(true);
1066 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1067 viewMenu->addAction (a);
1068 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1069 actionViewToggleAntiAlias=a;
1071 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1072 a->setStatusTip (a->text());
1073 a->setToggleAction(true);
1074 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1075 viewMenu->addAction (a);
1076 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1077 actionViewToggleSmoothPixmapTransform=a;
1079 a = new QAction(tr( "Next Map","View action" ), this);
1080 a->setStatusTip (a->text());
1081 a->setShortcut (Qt::ALT + Qt::Key_N );
1082 viewMenu->addAction (a);
1083 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1085 a = new QAction (tr( "Previous Map","View action" ), this );
1086 a->setStatusTip (a->text());
1087 a->setShortcut (Qt::ALT + Qt::Key_P );
1088 viewMenu->addAction (a);
1089 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1093 void Main::setupModeActions()
1095 //QPopupMenu *menu = new QPopupMenu( this );
1096 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1098 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1099 tb->setObjectName ("modesTB");
1101 actionGroupModModes=new QActionGroup ( this);
1102 actionGroupModModes->setExclusive (true);
1103 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1104 a->setShortcut (Qt::Key_J);
1105 a->setStatusTip ( tr( "Use modifier to color branches" ));
1106 a->setToggleAction(true);
1109 actionModModeColor=a;
1111 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1112 a->setShortcut( Qt::Key_K);
1113 a->setStatusTip( tr( "Use modifier to copy" ));
1114 a->setToggleAction(true);
1116 actionModModeCopy=a;
1118 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1119 a->setShortcut (Qt::Key_L);
1120 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1121 a->setToggleAction(true);
1123 actionModModeXLink=a;
1127 void Main::setupFlagActions()
1129 // Create System Flags
1133 systemFlagsDefault = new FlagRowObj ();
1134 systemFlagsDefault->setVisibility (false);
1135 systemFlagsDefault->setName ("systemFlagsDef");
1137 FlagObj *fo = new FlagObj ();
1138 fo->load(QPixmap(flagsPath+"flag-note.png"));
1139 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1141 fo->load(QPixmap(flagsPath+"flag-url.png"));
1142 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1144 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1145 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1147 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1148 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1150 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1151 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1153 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1154 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1156 // Create Standard Flags
1157 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1158 tb->setObjectName ("standardFlagTB");
1160 standardFlagsDefault = new FlagRowObj ();
1161 standardFlagsDefault->setVisibility (false);
1162 standardFlagsDefault->setName ("standardFlagsDef");
1163 standardFlagsDefault->setToolBar (tb);
1165 fo->load(flagsPath+"flag-exclamationmark.png");
1166 fo->setGroup("standard-mark");
1167 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1169 fo->load(flagsPath+"flag-questionmark.png");
1170 fo->setGroup("standard-mark");
1171 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1173 fo->load(flagsPath+"flag-hook-green.png");
1174 fo->setGroup("standard-hook");
1175 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1177 fo->load(flagsPath+"flag-cross-red.png");
1178 fo->setGroup("standard-hook");
1179 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1182 fo->load(flagsPath+"flag-stopsign.png");
1183 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1185 fo->load(flagsPath+"flag-smiley-good.png");
1186 fo->setGroup("standard-smiley");
1187 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1189 fo->load(flagsPath+"flag-smiley-sad.png");
1190 fo->setGroup("standard-smiley");
1191 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1193 fo->load(flagsPath+"flag-smiley-omg.png");
1194 fo->setGroup("standard-smiley");
1195 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1196 // Original omg.png (in KDE emoticons)
1199 fo->load(flagsPath+"flag-kalarm.png");
1200 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1202 fo->load(flagsPath+"flag-phone.png");
1203 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1205 fo->load(flagsPath+"flag-lamp.png");
1206 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1208 fo->load(flagsPath+"flag-arrow-up.png");
1209 fo->setGroup("standard-arrow");
1210 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1212 fo->load(flagsPath+"flag-arrow-down.png");
1213 fo->setGroup("standard-arrow");
1214 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1216 fo->load(flagsPath+"flag-arrow-2up.png");
1217 fo->setGroup("standard-arrow");
1218 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1220 fo->load(flagsPath+"flag-arrow-2down.png");
1221 fo->setGroup("standard-arrow");
1222 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1225 fo->load(flagsPath+"flag-thumb-up.png");
1226 fo->setGroup("standard-thumb");
1227 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1229 fo->load(flagsPath+"flag-thumb-down.png");
1230 fo->setGroup("standard-thumb");
1231 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1234 fo->load(flagsPath+"flag-rose.png");
1235 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1237 fo->load(flagsPath+"flag-heart.png");
1238 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1240 fo->load(flagsPath+"flag-present.png");
1241 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1243 fo->load(flagsPath+"flag-flash.png");
1244 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1246 // Original: xsldbg_output.png
1247 fo->load(flagsPath+"flag-info.png");
1248 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1250 // Original khelpcenter.png
1251 fo->load(flagsPath+"flag-lifebelt.png");
1252 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1258 fo->load(flagsPath+"freemind/warning.png");
1259 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1261 for (int i=1; i<8; i++)
1263 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1264 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1267 fo->load(flagsPath+"freemind/back.png");
1268 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1270 fo->load(flagsPath+"freemind/forward.png");
1271 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1273 fo->load(flagsPath+"freemind/attach.png");
1274 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1276 fo->load(flagsPath+"freemind/clanbomber.png");
1277 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1279 fo->load(flagsPath+"freemind/desktopnew.png");
1280 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1282 fo->load(flagsPath+"freemind/flag.png");
1283 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1286 fo->load(flagsPath+"freemind/gohome.png");
1287 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1290 fo->load(flagsPath+"freemind/kaddressbook.png");
1291 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1293 fo->load(flagsPath+"freemind/knotify.png");
1294 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1296 fo->load(flagsPath+"freemind/korn.png");
1297 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1299 fo->load(flagsPath+"freemind/mail.png");
1300 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1302 fo->load(flagsPath+"freemind/password.png");
1303 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1305 fo->load(flagsPath+"freemind/pencil.png");
1306 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1308 fo->load(flagsPath+"freemind/stop.png");
1309 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1311 fo->load(flagsPath+"freemind/wizard.png");
1312 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1314 fo->load(flagsPath+"freemind/xmag.png");
1315 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1317 fo->load(flagsPath+"freemind/bell.png");
1318 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1320 fo->load(flagsPath+"freemind/bookmark.png");
1321 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1323 fo->load(flagsPath+"freemind/penguin.png");
1324 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1326 fo->load(flagsPath+"freemind/licq.png");
1327 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1332 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1335 fo->setToolTip (tooltip);
1336 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1342 fo->setAlwaysVisible(aw);
1343 a->setCheckable(true);
1344 a->setObjectName(fo->getName());
1345 a->setToolTip(tooltip);
1346 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1347 standardFlagsDefault->addFlag (fo);
1351 systemFlagsDefault->addFlag (fo);
1355 void Main::setupNetworkActions()
1357 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1359 QMenu *netMenu = menuBar()->addMenu( "Network" );
1363 a = new QAction( "Start TCPserver for MapEditor",this);
1364 //a->setStatusTip ( "Set application to open pdf files"));
1365 a->setShortcut ( Qt::Key_T ); //New TCP server
1366 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1367 netMenu->addAction (a);
1369 a = new QAction( "Connect MapEditor to server",this);
1370 //a->setStatusTip ( "Set application to open pdf files"));
1371 a->setShortcut ( Qt::Key_C ); // Connect to server
1372 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1373 netMenu->addAction (a);
1377 void Main::setupSettingsActions()
1379 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1383 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1384 a->setStatusTip ( tr( "Set application to open pdf files"));
1385 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1386 settingsMenu->addAction (a);
1388 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1389 a->setStatusTip( tr( "Set application to open external links"));
1390 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1391 settingsMenu->addAction (a);
1393 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1394 a->setStatusTip( tr( "Set path for macros"));
1395 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1396 settingsMenu->addAction (a);
1398 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1399 a->setStatusTip( tr( "Set number of undo levels"));
1400 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1401 settingsMenu->addAction (a);
1403 settingsMenu->addSeparator();
1405 a = new QAction( tr( "Autosave","Settings action"), this);
1406 a->setStatusTip( tr( "Autosave"));
1407 a->setToggleAction(true);
1408 a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool());
1409 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1410 settingsMenu->addAction (a);
1411 actionSettingsAutosaveToggle=a;
1413 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1414 a->setStatusTip( tr( "Autosave time"));
1415 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1416 settingsMenu->addAction (a);
1417 actionSettingsAutosaveTime=a;
1419 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1420 a->setStatusTip( tr( "Write backup file on save"));
1421 a->setToggleAction(true);
1422 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1423 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1424 settingsMenu->addAction (a);
1425 actionSettingsWriteBackupFile=a;
1427 settingsMenu->addSeparator();
1429 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1430 a->setStatusTip( tr( "Edit branch after adding it" ));
1431 a->setToggleAction(true);
1432 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1433 settingsMenu->addAction (a);
1434 actionSettingsAutoEditNewBranch=a;
1436 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1437 a->setStatusTip( tr( "Select branch after adding it" ));
1438 a->setToggleAction(true);
1439 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1440 settingsMenu->addAction (a);
1441 actionSettingsAutoSelectNewBranch=a;
1443 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1444 a->setStatusTip( tr( "Select heading before editing" ));
1445 a->setToggleAction(true);
1446 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1447 settingsMenu->addAction (a);
1448 actionSettingsAutoSelectText=a;
1450 a= new QAction( tr( "Delete key","Settings action" ), this);
1451 a->setStatusTip( tr( "Delete key for deleting branches" ));
1452 a->setToggleAction(true);
1453 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1454 settingsMenu->addAction (a);
1455 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1456 actionSettingsUseDelKey=a;
1458 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1459 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1460 a->setToggleAction(true);
1461 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1462 settingsMenu->addAction (a);
1463 actionSettingsUseFlagGroups=a;
1465 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1466 a->setStatusTip( tr( "Use hide flag during exports " ));
1467 a->setToggleAction(true);
1468 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1469 settingsMenu->addAction (a);
1470 actionSettingsUseHideExport=a;
1472 a = new QAction( tr( "Animation","Settings action"), this);
1473 a->setStatusTip( tr( "Animation"));
1474 a->setToggleAction(true);
1475 a->setOn (settings.value("/animation/use",false).toBool() );
1476 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1477 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1479 settingsMenu->addAction (a);
1481 actionSettingsUseAnimation=a;
1485 void Main::setupTestActions()
1487 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1490 a = new QAction( "Test function 1" , this);
1491 a->setStatusTip( "Call test function 1" );
1492 testMenu->addAction (a);
1493 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1495 a = new QAction( "Test function 2" , this);
1496 a->setStatusTip( "Call test function 2" );
1497 testMenu->addAction (a);
1498 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1500 a = new QAction( "Command" , this);
1501 a->setStatusTip( "Enter command to call in editor" );
1502 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1503 testMenu->addAction (a);
1507 void Main::setupHelpActions()
1509 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1512 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1513 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1514 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1515 helpMenu->addAction (a);
1517 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1518 a->setStatusTip( tr( "Open VYM example maps " ));
1519 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1520 helpMenu->addAction (a);
1522 a = new QAction( tr( "About VYM","Help action" ), this);
1523 a->setStatusTip( tr( "About VYM")+vymName);
1524 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1525 helpMenu->addAction (a);
1527 a = new QAction( tr( "About QT","Help action" ), this);
1528 a->setStatusTip( tr( "Information about QT toolkit" ));
1529 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1530 helpMenu->addAction (a);
1534 void Main::setupContextMenus()
1538 // Context Menu for branch or mapcenter
1539 branchContextMenu =new QMenu (this);
1540 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1541 branchContextMenu->addSeparator();
1544 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1545 branchAddContextMenu->addAction (actionEditPaste );
1546 branchAddContextMenu->addAction ( actionEditAddBranch );
1547 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1548 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1549 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1550 branchAddContextMenu->addSeparator();
1551 branchAddContextMenu->addAction ( actionEditImportAdd );
1552 branchAddContextMenu->addAction ( actionEditImportReplace );
1555 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1556 branchRemoveContextMenu->addAction (actionEditCut);
1557 branchRemoveContextMenu->addAction ( actionEditDelete );
1558 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChildren );
1559 branchRemoveContextMenu->addAction ( actionEditDeleteChildren );
1562 actionEditSaveBranch->addTo( branchContextMenu );
1563 actionFileNewCopy->addTo (branchContextMenu );
1565 branchContextMenu->addSeparator();
1566 branchContextMenu->addAction ( actionEditLoadImage);
1568 // Submenu for Links (URLs, vymLinks)
1569 branchLinksContextMenu =new QMenu (this);
1571 branchContextMenu->addSeparator();
1572 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1573 branchLinksContextMenu->addAction ( actionEditOpenURL );
1574 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1575 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1576 branchLinksContextMenu->addAction ( actionEditURL );
1577 branchLinksContextMenu->addAction ( actionEditLocalURL );
1578 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1579 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1580 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1582 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1584 branchLinksContextMenu->addSeparator();
1585 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1586 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1587 branchLinksContextMenu->addAction ( actionEditVymLink );
1588 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1591 // Context Menu for XLinks in a branch menu
1592 // This will be populated "on demand" in MapEditor::updateActions
1593 branchContextMenu->addSeparator();
1594 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1595 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1596 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1597 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1600 // Context menu for floatimage
1601 floatimageContextMenu =new QMenu (this);
1602 a= new QAction (tr ("Save image","Context action"),this);
1603 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1604 floatimageContextMenu->addAction (a);
1606 floatimageContextMenu->addSeparator();
1607 actionEditCopy->addTo( floatimageContextMenu );
1608 actionEditCut->addTo( floatimageContextMenu );
1610 floatimageContextMenu->addSeparator();
1611 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1614 // Context menu for canvas
1615 canvasContextMenu =new QMenu (this);
1616 actionEditMapInfo->addTo( canvasContextMenu );
1617 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1618 actionEditAddMapCenter->addTo( canvasContextMenu );
1619 canvasContextMenu->insertSeparator();
1620 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1621 canvasContextMenu->insertSeparator();
1622 actionFormatLinkColorHint->addTo( canvasContextMenu );
1623 actionFormatLinkColor->addTo( canvasContextMenu );
1624 actionFormatSelectionColor->addTo( canvasContextMenu );
1625 actionFormatBackColor->addTo( canvasContextMenu );
1626 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1628 // Menu for last opened files
1630 for (int i = 0; i < MaxRecentFiles; ++i)
1632 recentFileActions[i] = new QAction(this);
1633 recentFileActions[i]->setVisible(false);
1634 fileLastMapsMenu->addAction(recentFileActions[i]);
1635 connect(recentFileActions[i], SIGNAL(triggered()),
1636 this, SLOT(fileLoadRecent()));
1638 setupRecentMapsMenu();
1641 void Main::setupRecentMapsMenu()
1643 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1645 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1647 for (int i = 0; i < numRecentFiles; ++i) {
1648 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1649 recentFileActions[i]->setText(text);
1650 recentFileActions[i]->setData(files[i]);
1651 recentFileActions[i]->setVisible(true);
1653 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1654 recentFileActions[j]->setVisible(false);
1657 void Main::setupMacros()
1659 for (int i = 0; i <= 11; i++)
1661 macroActions[i] = new QAction(this);
1662 macroActions[i]->setData(i);
1663 addAction (macroActions[i]);
1664 connect(macroActions[i], SIGNAL(triggered()),
1665 this, SLOT(callMacro()));
1667 macroActions[0]->setShortcut ( Qt::Key_F1 );
1668 macroActions[1]->setShortcut ( Qt::Key_F2 );
1669 macroActions[2]->setShortcut ( Qt::Key_F3 );
1670 macroActions[3]->setShortcut ( Qt::Key_F4 );
1671 macroActions[4]->setShortcut ( Qt::Key_F5 );
1672 macroActions[5]->setShortcut ( Qt::Key_F6 );
1673 macroActions[6]->setShortcut ( Qt::Key_F7 );
1674 macroActions[7]->setShortcut ( Qt::Key_F8 );
1675 macroActions[8]->setShortcut ( Qt::Key_F9 );
1676 macroActions[9]->setShortcut ( Qt::Key_F10 );
1677 macroActions[10]->setShortcut ( Qt::Key_F11 );
1678 macroActions[11]->setShortcut ( Qt::Key_F12 );
1681 void Main::hideEvent (QHideEvent * )
1683 if (!textEditor->isMinimized() ) textEditor->hide();
1686 void Main::showEvent (QShowEvent * )
1688 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1692 MapEditor* Main::currentMapEditor() const
1694 // FIXME currentMapEditor should return the latest used editor for a model, or NULL if no editor is open
1695 if ( tabWidget->currentPage() &&
1696 tabWidget->currentPage()->inherits( "MapEditor" ) )
1697 return (MapEditor*)tabWidget->currentPage();
1701 VymModel* Main::currentModel() const
1703 // FIXME better get currentModel from a maintained list,
1704 // just in case we allow other views in tabs later
1705 MapEditor *me=currentMapEditor();
1707 return me->getModel();
1713 void Main::editorChanged(QWidget *)
1715 // Unselect all possibly selected objects
1716 // (Important to update note editor)
1718 for (int i=0;i<=tabWidget->count() -1;i++)
1721 me=(MapEditor*)tabWidget->page(i);
1722 me->getModel()->unselect();
1724 currentModel()->reselect();
1726 // Update actions to in menus and toolbars according to editor
1730 void Main::fileNew()
1732 VymModel *m=new VymModel;
1734 MapEditor* me = new MapEditor (m);
1735 QString fn="unnamed";
1736 tabWidget->addTab (me,fn);
1737 tabWidget->showPage(me);
1738 me->viewport()->setFocus();
1739 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1740 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1742 // For the very first map we do not have flagrows yet...
1743 currentModel()->select("mc:");
1746 void Main::fileNewCopy()
1748 QString fn="unnamed";
1749 MapEditor* oldME =currentMapEditor();
1752 oldME->getModel()->copy();
1753 VymModel *m=new VymModel;
1755 MapEditor* newME = new MapEditor ( m);
1758 tabWidget->addTab (newME,fn);
1759 tabWidget->showPage(newME);
1760 newME->viewport()->setFocus();
1761 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1762 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1763 // For the very first map we do not have flagrows yet...
1765 m->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1771 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1773 ErrorCode err=success;
1775 // fn is usually the archive, mapfile the file after uncompressing
1778 // Make fn absolute (needed for unzip)
1779 fn=QDir (fn).absPath();
1785 // Check, if map is already loaded
1787 while (i<=tabWidget->count() -1)
1789 me=(MapEditor*)tabWidget->page(i);
1790 if (me->getModel()->getFilePath() == fn)
1792 // Already there, ask for confirmation
1793 QMessageBox mb( vymName,
1794 tr("The map %1\nis already opened."
1795 "Opening the same map in multiple editors may lead \n"
1796 "to confusion when finishing working with vym."
1797 "Do you want to").arg(fn),
1798 QMessageBox::Warning,
1799 QMessageBox::Yes | QMessageBox::Default,
1800 QMessageBox::Cancel | QMessageBox::Escape,
1801 QMessageBox::NoButton);
1802 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1803 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1806 case QMessageBox::Yes:
1808 i=tabWidget->count();
1810 case QMessageBox::Cancel:
1822 if ( !fn.isEmpty() )
1824 me = currentMapEditor();
1825 int tabIndex=tabWidget->currentPageIndex();
1826 // Check first, if mapeditor exists
1827 // If it is not default AND we want a new map,
1828 // create a new mapeditor in a new tab
1829 if ( lmode==NewMap && (!me || !me->getModel()->isDefault() ) )
1831 VymModel *m=new VymModel;
1833 me= new MapEditor ( m);
1834 tabWidget->addTab (me,fn);
1835 tabIndex=tabWidget->indexOf (me);
1836 tabWidget->setCurrentPage (tabIndex);
1837 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1838 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1841 // Check, if file exists (important for creating new files
1842 // from command line
1843 if (!QFile(fn).exists() )
1845 QMessageBox mb( vymName,
1846 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1847 QMessageBox::Question,
1849 QMessageBox::Cancel | QMessageBox::Default,
1850 QMessageBox::NoButton );
1852 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1853 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1856 case QMessageBox::Yes:
1858 currentMapEditor()->getModel()->setFilePath(fn);
1859 tabWidget->setTabLabel (currentMapEditor(),
1860 currentMapEditor()->getModel()->getFileName() );
1861 statusBar()->message( "Created " + fn , statusbarTime );
1864 case QMessageBox::Cancel:
1865 // don't create new map
1866 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1873 //tabWidget->currentPage() won't be NULL here, because of above...
1874 tabWidget->showPage(me);
1875 me->viewport()->setFocus();
1879 // Save existing filename in case we import
1880 QString fn_org=me->getModel()->getFilePath();
1882 // Finally load map into mapEditor
1883 me->getModel()->setFilePath (fn);
1884 err=me->getModel()->load(fn,lmode,ftype);
1886 // Restore old (maybe empty) filepath, if this is an import
1888 me->getModel()->setFilePath (fn_org);
1891 // Finally check for errors and go home
1894 if (lmode==NewMap) fileCloseMap();
1895 statusBar()->message( "Could not load " + fn, statusbarTime );
1900 me->getModel()->setFilePath (fn);
1901 tabWidget->changeTab(tabWidget->page(tabIndex), me->getModel()->getFileName());
1902 if (!isInTmpDir (fn))
1904 // Only append to lastMaps if not loaded from a tmpDir
1905 // e.g. imported bookmarks are in a tmpDir
1906 addRecentMap(me->getModel()->getFilePath() );
1908 actionFilePrint->setEnabled (true);
1910 statusBar()->message( "Loaded " + fn, statusbarTime );
1917 void Main::fileLoad(const LoadMode &lmode)
1919 QStringList filters;
1920 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1921 QFileDialog *fd=new QFileDialog( this);
1922 fd->setDir (lastFileDir);
1923 fd->setFileMode (QFileDialog::ExistingFiles);
1924 fd->setFilters (filters);
1928 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1931 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1934 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1940 if ( fd->exec() == QDialog::Accepted )
1942 lastFileDir=fd->directory().path();
1943 QStringList flist = fd->selectedFiles();
1944 QStringList::Iterator it = flist.begin();
1945 while( it != flist.end() )
1948 fileLoad(*it, lmode);
1955 void Main::fileLoad()
1960 void Main::fileLoadRecent()
1962 QAction *action = qobject_cast<QAction *>(sender());
1964 fileLoad (action->data().toString(), NewMap);
1967 void Main::addRecentMap (const QString &fileName)
1970 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1971 files.removeAll(fileName);
1972 files.prepend(fileName);
1973 while (files.size() > MaxRecentFiles)
1976 settings.setValue("/mainwindow/recentFileList", files);
1978 setupRecentMapsMenu();
1981 void Main::fileSave(VymModel *m, const SaveMode &savemode)
1985 if ( m->getFilePath().isEmpty() )
1987 // We have no filepath yet,
1988 // call fileSaveAs() now, this will call fileSave()
1990 // First switch to editor
1991 tabWidget->setCurrentWidget (m->getMapEditor());
1992 fileSaveAs(savemode);
1995 if (m->save (savemode)==success)
1997 statusBar()->message(
1998 tr("Saved %1").arg(m->getFilePath()),
2000 addRecentMap (m->getFilePath() );
2002 statusBar()->message(
2003 tr("Couldn't save ").arg(m->getFilePath()),
2007 void Main::fileSave()
2009 fileSave (currentModel(), CompleteMap);
2012 void Main::fileSave(VymModel *m)
2014 fileSave (m,CompleteMap);
2017 void Main::fileSaveAs(const SaveMode& savemode)
2021 if (currentMapEditor())
2023 if (savemode==CompleteMap)
2024 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2026 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2027 if ( !fn.isEmpty() )
2029 // Check for existing file
2030 if (QFile (fn).exists())
2032 QMessageBox mb( vymName,
2033 tr("The file %1\nexists already. Do you want to").arg(fn),
2034 QMessageBox::Warning,
2035 QMessageBox::Yes | QMessageBox::Default,
2036 QMessageBox::Cancel | QMessageBox::Escape,
2037 QMessageBox::NoButton);
2038 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2039 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2042 case QMessageBox::Yes:
2045 case QMessageBox::Cancel:
2052 // New file, add extension to filename, if missing
2053 // This is always .vym or .vyp, depending on savemode
2054 if (savemode==CompleteMap)
2056 if (!fn.contains (".vym") && !fn.contains (".xml"))
2060 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2069 currentModel()->setFilePath(fn);
2070 fileSave(currentModel(), savemode);
2073 if (savemode==CompleteMap)
2074 tabWidget->setTabLabel (currentMapEditor(),
2075 currentModel()->getFileName() );
2081 void Main::fileSaveAs()
2083 fileSaveAs (CompleteMap);
2086 void Main::fileImportKDEBookmarks()
2088 ImportKDEBookmarks im;
2090 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2091 currentMapEditor()->getModel()->setFilePath ("");
2094 void Main::fileImportFirefoxBookmarks()
2096 Q3FileDialog *fd=new Q3FileDialog( this);
2097 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2098 fd->setMode (Q3FileDialog::ExistingFiles);
2099 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2100 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2103 if ( fd->exec() == QDialog::Accepted )
2105 ImportFirefoxBookmarks im;
2106 QStringList flist = fd->selectedFiles();
2107 QStringList::Iterator it = flist.begin();
2108 while( it != flist.end() )
2111 if (im.transform() &&
2112 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2113 currentMapEditor() )
2114 currentMapEditor()->getModel()->setFilePath ("");
2121 void Main::fileImportFreemind()
2123 QStringList filters;
2124 filters <<"Freemind map (*.mm)"<<"All files (*)";
2125 QFileDialog *fd=new QFileDialog( this);
2126 fd->setDir (lastFileDir);
2127 fd->setFileMode (QFileDialog::ExistingFiles);
2128 fd->setFilters (filters);
2129 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2133 if ( fd->exec() == QDialog::Accepted )
2135 lastFileDir=fd->directory().path();
2136 QStringList flist = fd->selectedFiles();
2137 QStringList::Iterator it = flist.begin();
2138 while( it != flist.end() )
2141 if ( fileLoad (fn,NewMap, FreemindMap) )
2143 currentMapEditor()->getModel()->setFilePath ("");
2152 void Main::fileImportMM()
2156 Q3FileDialog *fd=new Q3FileDialog( this);
2157 fd->setDir (lastFileDir);
2158 fd->setMode (Q3FileDialog::ExistingFiles);
2159 fd->addFilter ("Mind Manager (*.mmap)");
2160 fd->setCaption(tr("Import")+" "+"Mind Manager");
2163 if ( fd->exec() == QDialog::Accepted )
2165 lastFileDir=fd->dirPath();
2166 QStringList flist = fd->selectedFiles();
2167 QStringList::Iterator it = flist.begin();
2168 while( it != flist.end() )
2171 if (im.transform() &&
2172 success==fileLoad (im.getTransformedFile(),NewMap) &&
2173 currentMapEditor() )
2174 currentMapEditor()->getModel()->setFilePath ("");
2181 void Main::fileImportDir()
2183 VymModel *m=currentModel();
2184 if (m) m->importDir();
2187 void Main::fileExportXML()
2189 VymModel *m=currentModel();
2190 if (m) m->exportXML();
2194 void Main::fileExportXHTML()
2196 VymModel *m=currentModel();
2197 if (m) m->exportXHTML();
2200 void Main::fileExportImage()
2202 VymModel *m=currentModel();
2203 if (m) m->exportImage();
2206 void Main::fileExportASCII()
2208 VymModel *m=currentModel();
2209 if (m) m->exportASCII();
2212 void Main::fileExportCSV() //FIXME not scriptable yet
2214 VymModel *m=currentModel();
2219 ex.addFilter ("CSV (*.csv)");
2220 ex.setDir(lastImageDir);
2221 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2222 if (ex.execDialog() )
2224 m->setExportMode(true);
2226 m->setExportMode(false);
2231 void Main::fileExportLaTeX() //FIXME not scriptable yet
2233 VymModel *m=currentModel();
2238 ex.addFilter ("Tex (*.tex)");
2239 ex.setDir(lastImageDir);
2240 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2241 if (ex.execDialog() )
2243 m->setExportMode(true);
2245 m->setExportMode(false);
2250 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2252 ExportKDEBookmarks ex;
2253 VymModel *m=currentModel();
2261 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2263 ExportTaskjuggler ex;
2264 VymModel *m=currentModel();
2268 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2269 ex.setDir(lastImageDir);
2270 ex.addFilter ("Taskjuggler (*.tjp)");
2271 if (ex.execDialog() )
2273 m->setExportMode(true);
2275 m->setExportMode(false);
2280 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2282 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2283 // TODO add preview in dialog
2284 //ImagePreview *p =new ImagePreview (fd);
2285 //fd->setContentsPreviewEnabled( TRUE );
2286 //fd->setContentsPreview( p, p );
2287 //fd->setPreviewMode( QFileDialog::Contents );
2288 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2289 fd->setDir (QDir().current());
2290 if (fd->foundConfig())
2294 if ( fd->exec() == QDialog::Accepted )
2296 QString fn=fd->selectedFile();
2297 if (!fn.contains (".odp"))
2300 //lastImageDir=fn.left(fn.findRev ("/"));
2301 VymModel *m=currentModel();
2302 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2306 QMessageBox::warning(0,
2308 tr("Couldn't find configuration for export to Open Office\n"));
2312 void Main::fileCloseMap()
2314 MapEditor *me = currentMapEditor();
2315 VymModel *m=currentModel();
2318 if (m->hasChanged())
2320 QMessageBox mb( vymName,
2321 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
2322 QMessageBox::Warning,
2323 QMessageBox::Yes | QMessageBox::Default,
2325 QMessageBox::Cancel | QMessageBox::Escape );
2326 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2327 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2330 case QMessageBox::Yes:
2332 fileSave(m, CompleteMap);
2334 case QMessageBox::No:
2335 // close without saving
2337 case QMessageBox::Cancel:
2342 //me->closeMap(); FIXME should not be necessary any longer
2344 tabWidget->removePage(m->getMapEditor());
2345 if (tabWidget->count()==0)
2346 actionFilePrint->setEnabled (false);
2351 void Main::filePrint()
2353 if (currentMapEditor())
2354 currentMapEditor()->print();
2357 void Main::fileExitVYM()
2359 // Check if one or more editors have changed
2362 for (i=0;i<=tabWidget->count() -1;i++)
2365 me=(MapEditor*)tabWidget->page(i);
2367 // If something changed, ask what to do
2368 if (me->getModel()->hasChanged())
2370 tabWidget->setCurrentPage(i);
2371 QMessageBox mb( vymName,
2372 tr("This map is not saved yet. Do you want to"),
2373 QMessageBox::Warning,
2374 QMessageBox::Yes | QMessageBox::Default,
2376 QMessageBox::Cancel | QMessageBox::Escape );
2377 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2378 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2381 mb.setActiveWindow();
2382 switch( mb.exec() ) {
2383 case QMessageBox::Yes:
2384 // save (the changed editors) and exit
2385 fileSave(currentModel(), CompleteMap);
2387 case QMessageBox::No:
2388 // exit without saving
2390 case QMessageBox::Cancel:
2391 // don't save and don't exit
2395 } // loop over all MEs
2399 void Main::editUndo()
2401 VymModel *m=currentModel();
2405 void Main::editRedo()
2407 VymModel *m=currentModel();
2411 void Main::gotoHistoryStep (int i)
2413 VymModel *m=currentModel();
2414 if (m) m->gotoHistoryStep(i);
2417 void Main::editCopy()
2419 VymModel *m=currentModel();
2423 void Main::editPaste()
2425 VymModel *m=currentModel();
2429 void Main::editCut()
2431 VymModel *m=currentModel();
2435 void Main::editOpenFindWindow()
2437 findWindow->popup();
2438 findWindow->raise();
2439 findWindow->setActiveWindow();
2442 void Main::editFind(QString s)
2444 VymModel *m=currentModel();
2448 BranchObj *bo=m->findText(s, cs);
2451 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2454 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2455 tr("No matches found for \"%1\"").arg(s));
2460 void Main::editFindChanged()
2461 { // Notify editor, to abort the current find process
2462 VymModel *m=currentModel();
2463 if (m) m->findReset();
2466 void Main::openTabs(QStringList urls)
2468 if (!urls.isEmpty())
2472 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2474 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2476 QString u=urls.takeFirst();
2477 procBrowser = new QProcess( this );
2479 procBrowser->start(browser,args);
2480 if ( !procBrowser->waitForStarted())
2482 // try to set path to browser
2483 QMessageBox::warning(0,
2485 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2486 tr("Please use Settings->")+tr("Set application to open an URL"));
2489 #if defined(Q_OS_WIN32)
2490 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2491 this->thread()->wait(3000);
2496 if (browser.contains("konqueror"))
2498 for (int i=0; i<urls.size(); i++)
2501 // Try to open new tab in existing konqueror started previously by vym
2502 p=new QProcess (this);
2504 #if defined(Q_OS_WIN32)
2505 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2506 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2507 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2508 "konqueror-mainwindow#1"<<
2512 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2513 "konqueror-mainwindow#1"<<
2517 p->start ("dcop",args);
2518 //cout << qPrintable (args.join(" "))<<endl;
2519 if ( !p->waitForStarted() ) success=false;
2522 QMessageBox::warning(0,
2524 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2526 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2528 for (int i=0; i<urls.size(); i++)
2530 // Try to open new tab in firefox
2531 p=new QProcess (this);
2532 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2533 p->start (browser,args);
2534 if ( !p->waitForStarted() ) success=false;
2537 QMessageBox::warning(0,
2539 tr("Couldn't start %1 to open a new tab").arg(browser));
2542 QMessageBox::warning(0,
2544 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2548 void Main::editOpenURL()
2551 VymModel *m=currentModel();
2554 QString url=m->getURL();
2556 if (url=="") return;
2557 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2558 procBrowser = new QProcess( this );
2560 procBrowser->start(browser,args);
2561 if ( !procBrowser->waitForStarted())
2563 // try to set path to browser
2564 QMessageBox::warning(0,
2566 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2567 tr("Please use Settings->")+tr("Set application to open an URL"));
2572 void Main::editOpenURLTab()
2574 VymModel *m=currentModel();
2578 urls.append(m->getURL());
2582 void Main::editOpenMultipleURLTabs()
2584 VymModel *m=currentModel();
2594 void Main::editURL()
2596 VymModel *m=currentModel();
2597 if (m) m->editURL();
2600 void Main::editLocalURL()
2602 VymModel *m=currentModel();
2603 if (m) m->editLocalURL();
2606 void Main::editHeading2URL()
2608 VymModel *m=currentModel();
2609 if (m) m->editHeading2URL();
2612 void Main::editBugzilla2URL()
2614 VymModel *m=currentModel();
2615 if (m) m->editBugzilla2URL();
2618 void Main::editFATE2URL()
2620 VymModel *m=currentModel();
2621 if (m) m->editFATE2URL();
2624 void Main::editHeadingFinished(VymModel *m)
2628 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2629 !prevSelection.isEmpty())
2630 m->select(prevSelection);
2634 /* FIXME old code, remove now
2635 // only called from editHeading(), so there is a currentME
2636 VymModel *m=currentModel();
2639 m->setSelectionBlocked (false);
2640 QPoint p; //Not used here, only to find out pos of branch
2642 QString s=m->getHeading(ok,p);
2644 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2646 if (ok && s!=lineedit->text())
2647 m->setHeading(lineedit->text());
2649 lineedit->releaseKeyboard();
2653 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2654 !prevSelection.isEmpty())
2655 m->select(prevSelection);
2662 void Main::editHeading()
2664 MapEditor *me=currentMapEditor();
2665 VymModel *m=currentModel();
2668 QString oldSel=m->getSelectString();
2670 if (lineedit->isVisible())
2671 editHeadingFinished();
2676 QString s=m->getHeading(ok,p);
2680 m->setSelectionBlocked(true);
2681 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2682 p=me->mapToGlobal (p);
2683 QDialog *d =new QDialog(NULL);
2684 QLineEdit *le=new QLineEdit (d);
2685 d->setWindowFlags (Qt::FramelessWindowHint);
2686 d->setGeometry(p.x(),p.y(),230,25);
2687 le->resize (d->width()-10,d->height());
2690 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2691 d->activateWindow();
2693 m->setHeading (le->text());
2696 editHeadingFinished();
2698 p=me->mapTo (this,p);
2699 lineedit->setGeometry(p.x(),p.y(),230,25);
2700 lineedit->setText(s);
2701 lineedit->setCursorPosition(1);
2702 lineedit->selectAll();
2704 lineedit->grabKeyboard();
2705 lineedit->setFocus();
2713 void Main::editAttributeFinished()
2715 // only called from editHeading(), so there is a currentME
2718 MapEditor *me=currentMapEditor();
2721 me->setStateEditHeading (false);
2722 QPoint p; //Not used here, only to find out pos of branch
2724 QString s=me->getHeading(ok,p);
2726 #if defined(Q_OS_MACX)
2728 if (ok && s!=lineedit->text())
2729 me->setHeading(lineedit->text());
2731 lineedit->releaseKeyboard();
2735 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2736 !prevSelection.isEmpty())
2737 me->select(prevSelection);
2743 #include "attribute.h"
2744 #include "attributedialog.h"
2745 void Main::editAttribute()
2748 MapEditor *me=currentMapEditor();
2751 BranchObj *bo=me->getModel()->getSelectedBranch();
2754 AttributeDialog dia(this);
2755 dia.setTable (me->attributeTable() );
2757 dia.setMode (Definition);
2764 if (currentMapEditor())
2766 MapEditor *me=currentMapEditor();
2767 QString oldSel=me->getSelectString();
2769 if (lineedit->isVisible())
2770 editAttributeFinished();
2775 QString s=me->getHeading(ok,p);
2779 me->setStateEditHeading (true);
2780 #if defined(Q_OS_MACX)
2781 p=me->mapToGlobal (p);
2782 QDialog *d =new QDialog(NULL);
2783 QLineEdit *le=new QLineEdit (d);
2784 d->setWindowFlags (Qt::FramelessWindowHint);
2785 d->setGeometry(p.x(),p.y(),230,25);
2786 le->resize (d->width()-10,d->height());
2789 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2790 d->activateWindow();
2792 me->setHeading (le->text());
2795 editHeadingFinished();
2797 p=me->mapTo (this,p);
2798 lineedit->setGeometry(p.x(),p.y(),230,25);
2799 lineedit->setText(s);
2800 lineedit->setCursorPosition(1);
2801 lineedit->selectAll();
2803 lineedit->grabKeyboard();
2804 lineedit->setFocus();
2808 } // currentMapEditor()
2813 void Main::openVymLinks(const QStringList &vl)
2815 for (int j=0; j<vl.size(); j++)
2817 // compare path with already loaded maps
2821 for (i=0;i<=tabWidget->count() -1;i++)
2823 me=(MapEditor*)tabWidget->page(i);
2824 if (vl.at(j)==me->getModel()->getFilePath() )
2833 if (!QFile(vl.at(j)).exists() )
2834 QMessageBox::critical( 0, tr( "Critical Error" ),
2835 tr("Couldn't open map %1").arg(vl.at(j)));
2838 fileLoad (vl.at(j), NewMap);
2839 tabWidget->setCurrentPage (tabWidget->count()-1);
2842 // Go to tab containing the map
2843 tabWidget->setCurrentPage (index);
2847 void Main::editOpenVymLink()
2849 VymModel *m=currentModel();
2853 vl.append(m->getVymLink());
2858 void Main::editOpenMultipleVymLinks()
2860 QString currentVymLink;
2861 VymModel *m=currentModel();
2864 QStringList vl=m->getVymLinks();
2869 void Main::editVymLink()
2871 VymModel *m=currentModel();
2876 void Main::editDeleteVymLink()
2878 VymModel *m=currentModel();
2879 if (m) m->deleteVymLink();
2882 void Main::editToggleHideExport()
2884 VymModel *m=currentModel();
2885 if (m) m->toggleHideExport();
2888 void Main::editMapInfo()
2890 VymModel *m=currentModel();
2892 ExtraInfoDialog dia;
2893 dia.setMapName (m->getFileName() );
2894 dia.setAuthor (m->getAuthor() );
2895 dia.setComment(m->getComment() );
2897 /* FIXME no stats at the moment (view dependent...)
2900 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2910 if (!bo->getNote().isEmpty() ) n++;
2911 f+= bo->countFloatImages();
2913 xl+=bo->countXLinks();
2916 stats+=QString ("%1 branches\n").arg (b-1,6);
2917 stats+=QString ("%1 xLinks \n").arg (xl,6);
2918 stats+=QString ("%1 notes\n").arg (n,6);
2919 stats+=QString ("%1 images\n").arg (f,6);
2920 dia.setStats (stats);
2923 // Finally show dialog
2924 if (dia.exec() == QDialog::Accepted)
2926 m->setAuthor (dia.getAuthor() );
2927 m->setComment (dia.getComment() );
2931 void Main::editMoveUp()
2933 VymModel *m=currentModel();
2934 if (m) m->moveBranchUp();
2937 void Main::editMoveDown()
2939 VymModel *m=currentModel();
2940 if (m) m->moveBranchDown();
2943 void Main::editSortChildren()
2945 VymModel *m=currentModel();
2946 if (m) m->sortChildren();
2949 void Main::editToggleScroll()
2951 VymModel *m=currentModel();
2952 if (m) m->toggleScroll();
2955 void Main::editUnscrollChildren()
2957 VymModel *m=currentModel();
2958 if (m) m->unscrollChildren();
2961 void Main::editAddMapCenter()
2963 VymModel *m=currentModel();
2964 if (!lineedit->isVisible() && m)
2970 void Main::editNewBranch()
2972 VymModel *m=currentModel();
2973 if (!lineedit->isVisible() && m)
2975 BranchObj *bo=(BranchObj*)m->getSelection();
2976 BranchObj *newbo=m->addNewBranch(0);
2978 prevSelection=m->getSelectString(bo);
2984 if (actionSettingsAutoEditNewBranch->isOn())
2986 currentMapEditor()->editHeading();
2989 if (!prevSelection.isEmpty())
2991 m->select(prevSelection);
2997 void Main::editNewBranchBefore()
2999 VymModel *m=currentModel();
3000 if (!lineedit->isVisible() && m)
3002 BranchObj *bo=(BranchObj*)m->getSelection();
3003 BranchObj *newbo=m->addNewBranchBefore();
3010 if (actionSettingsAutoEditNewBranch->isOn())
3012 if (!actionSettingsAutoSelectNewBranch->isOn())
3013 prevSelection=m->getSelectString(bo);
3014 currentMapEditor()->editHeading();
3019 void Main::editNewBranchAbove()
3021 VymModel *m=currentModel();
3022 if (!lineedit->isVisible() && m)
3024 BranchObj *bo=(BranchObj*)m->getSelection();
3025 BranchObj *newbo=m->addNewBranch (-1);
3032 if (actionSettingsAutoEditNewBranch->isOn())
3034 if (!actionSettingsAutoSelectNewBranch->isOn())
3035 prevSelection=m->getSelectString (bo);
3036 currentMapEditor()->editHeading();
3041 void Main::editNewBranchBelow()
3043 VymModel *m=currentModel();
3044 if (!lineedit->isVisible() && m)
3046 BranchObj *bo=(BranchObj*)m->getSelection();
3047 BranchObj *newbo=m->addNewBranch (1);
3054 if (actionSettingsAutoEditNewBranch->isOn())
3056 if (!actionSettingsAutoSelectNewBranch->isOn())
3057 prevSelection=m->getSelectString(bo);
3058 currentMapEditor()->editHeading();
3063 void Main::editImportAdd()
3065 fileLoad (ImportAdd);
3068 void Main::editImportReplace()
3070 fileLoad (ImportReplace);
3073 void Main::editSaveBranch()
3075 fileSaveAs (PartOfMap);
3078 void Main::editDeleteKeepChildren()
3080 VymModel *m=currentModel();
3081 if (m) m->deleteKeepChildren();
3084 void Main::editDeleteChildren()
3086 VymModel *m=currentModel();
3087 if (m) m->deleteChildren();
3090 void Main::editDeleteSelection()
3092 VymModel *m=currentModel();
3093 if (m && actionSettingsUseDelKey->isOn())
3094 m->deleteSelection();
3097 void Main::editUpperBranch()
3099 VymModel *m=currentModel();
3100 if (m) m->selectUpperBranch();
3103 void Main::editLowerBranch()
3105 VymModel *m=currentModel();
3106 if (m) m->selectLowerBranch();
3109 void Main::editLeftBranch()
3111 VymModel *m=currentModel();
3112 if (m) m->selectLeftBranch();
3115 void Main::editRightBranch()
3117 VymModel *m=currentModel();
3118 if (m) m->selectRightBranch();
3121 void Main::editFirstBranch()
3123 VymModel *m=currentModel();
3124 if (m) m->selectFirstBranch();
3127 void Main::editLastBranch()
3129 VymModel *m=currentModel();
3130 if (m) m->selectLastBranch();
3133 void Main::editLoadImage()
3135 VymModel *m=currentModel();
3136 if (m) m->loadFloatImage();
3139 void Main::editSaveImage()
3141 VymModel *m=currentModel();
3142 if (m) m->saveFloatImage();
3145 void Main::editFollowXLink(QAction *a)
3148 VymModel *m=currentModel();
3150 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3153 void Main::editEditXLink(QAction *a)
3155 VymModel *m=currentModel();
3157 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3160 void Main::formatSelectColor()
3162 QColor col = QColorDialog::getColor((currentColor ), this );
3163 if ( !col.isValid() ) return;
3164 colorChanged( col );
3167 void Main::formatPickColor()
3169 VymModel *m=currentModel();
3171 colorChanged( m->getCurrentHeadingColor() );
3174 void Main::colorChanged(QColor c)
3176 QPixmap pix( 16, 16 );
3178 actionFormatColor->setIconSet( pix );
3182 void Main::formatColorBranch()
3184 VymModel *m=currentModel();
3185 if (m) m->colorBranch(currentColor);
3188 void Main::formatColorSubtree()
3190 VymModel *m=currentModel();
3191 if (m) m->colorSubtree (currentColor);
3194 void Main::formatLinkStyleLine()
3196 VymModel *m=currentModel();
3199 m->setMapLinkStyle("StyleLine");
3200 actionFormatLinkStyleLine->setOn(true);
3204 void Main::formatLinkStyleParabel()
3206 VymModel *m=currentModel();
3209 m->setMapLinkStyle("StyleParabel");
3210 actionFormatLinkStyleParabel->setOn(true);
3214 void Main::formatLinkStylePolyLine()
3216 VymModel *m=currentModel();
3219 m->setMapLinkStyle("StylePolyLine");
3220 actionFormatLinkStylePolyLine->setOn(true);
3224 void Main::formatLinkStylePolyParabel()
3226 VymModel *m=currentModel();
3229 m->setMapLinkStyle("StylePolyParabel");
3230 actionFormatLinkStylePolyParabel->setOn(true);
3234 void Main::formatSelectBackColor()
3236 VymModel *m=currentModel();
3237 if (m) m->selectMapBackgroundColor();
3240 void Main::formatSelectBackImage()
3242 VymModel *m=currentModel();
3244 m->selectMapBackgroundImage();
3247 void Main::formatSelectLinkColor()
3249 VymModel *m=currentModel();
3252 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3253 m->setMapDefLinkColor( col );
3257 void Main::formatSelectSelectionColor()
3259 VymModel *m=currentModel();
3262 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3263 m->setSelectionColor (col);
3268 void Main::formatToggleLinkColorHint()
3270 VymModel *m=currentModel();
3271 if (m) m->toggleMapLinkColorHint();
3275 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3277 VymModel *m=currentModel();
3279 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3282 void Main::viewZoomReset()
3284 if (currentMapEditor())
3288 currentMapEditor()->setMatrix( m );
3292 void Main::viewZoomIn()
3294 if (currentMapEditor())
3296 QMatrix m = currentMapEditor()->matrix();
3297 m.scale( 1.25, 1.25 );
3298 currentMapEditor()->setMatrix( m );
3302 void Main::viewZoomOut()
3304 if (currentMapEditor())
3306 QMatrix m = currentMapEditor()->matrix();
3307 m.scale( 0.8, 0.8 );
3308 currentMapEditor()->setMatrix( m );
3312 void Main::viewCenter()
3314 VymModel *m=currentModel();
3315 if (m) m->ensureSelectionVisible();
3318 void Main::networkStartServer()
3320 VymModel *m=currentModel();
3321 if (m) m->newServer();
3324 void Main::networkConnect()
3326 VymModel *m=currentModel();
3327 if (m) m->connectToServer();
3330 bool Main::settingsPDF()
3332 // Default browser is set in constructor
3334 QString text = QInputDialog::getText(
3335 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3336 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3338 settings.setValue ("/mainwindow/readerPDF",text);
3343 bool Main::settingsURL()
3345 // Default browser is set in constructor
3347 QString text = QInputDialog::getText(
3348 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3349 settings.value("/mainwindow/readerURL").toString()
3352 settings.setValue ("/mainwindow/readerURL",text);
3356 void Main::settingsMacroDir()
3358 QDir defdir(vymBaseDir.path() + "/macros");
3359 if (!defdir.exists())
3361 QDir dir=QFileDialog::getExistingDirectory (
3363 tr ("Directory with vym macros:"),
3364 settings.value ("/macros/macroDir",defdir.path()).toString()
3367 settings.setValue ("/macros/macroDir",dir.absolutePath());
3370 void Main::settingsUndoLevels()
3373 int i = QInputDialog::getInteger(
3375 tr("QInputDialog::getInteger()"),
3376 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3379 settings.setValue ("/mapeditor/stepsTotal",i);
3380 QMessageBox::information( this, tr( "VYM -Information:" ),
3381 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3385 void Main::settingsAutosaveToggle()
3387 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3390 void Main::settingsAutosaveTime()
3393 int i = QInputDialog::getInteger(
3395 tr("QInputDialog::getInteger()"),
3396 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3398 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3401 void Main::settingsWriteBackupFileToggle()
3403 settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3406 void Main::settingsToggleAnimation()
3408 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3411 void Main::settingsToggleDelKey()
3413 if (actionSettingsUseDelKey->isOn())
3415 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3418 actionEditDelete->setAccel (QKeySequence (""));
3422 void Main::windowToggleNoteEditor()
3424 if (textEditor->isVisible() )
3425 windowHideNoteEditor();
3427 windowShowNoteEditor();
3430 void Main::windowToggleHistory()
3432 if (historyWindow->isVisible())
3433 historyWindow->hide();
3435 historyWindow->show();
3439 void Main::windowToggleProperty()
3441 if (branchPropertyWindow->isVisible())
3442 branchPropertyWindow->hide();
3444 branchPropertyWindow->show();
3445 branchPropertyWindow->setModel (currentModel() );
3448 void Main::windowToggleAntiAlias()
3450 bool b=actionViewToggleAntiAlias->isOn();
3452 for (int i=0;i<tabWidget->count();i++)
3454 me=(MapEditor*)tabWidget->page(i);
3455 me->setAntiAlias(b);
3460 void Main::windowToggleSmoothPixmap()
3462 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3464 for (int i=0;i<tabWidget->count();i++)
3467 me=(MapEditor*)tabWidget->page(i);
3468 me->setSmoothPixmap(b);
3472 void Main::updateHistory(SimpleSettings &undoSet)
3474 historyWindow->update (undoSet);
3477 void Main::updateNoteFlag()
3479 // this slot is connected to TextEditor::textHasChanged()
3481 VymModel *m=currentModel();
3482 if (m) m->updateNoteFlag();
3485 void Main::updateSatellites(MapEditor *me)
3487 branchPropertyWindow->setModel (me->getModel() );
3490 void Main::updateActions()
3492 VymModel *m =currentModel();
3495 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3497 // updateActions is also called when NoteEditor is closed
3498 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3499 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3500 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3502 if (m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3503 actionFormatLinkColorHint->setOn(true);
3505 actionFormatLinkColorHint->setOn(false);
3507 switch (m->getMapLinkStyle())
3509 case LinkableMapObj::Line:
3510 actionFormatLinkStyleLine->setOn(true);
3512 case LinkableMapObj::Parabel:
3513 actionFormatLinkStyleParabel->setOn(true);
3515 case LinkableMapObj::PolyLine:
3516 actionFormatLinkStylePolyLine->setOn(true);
3518 case LinkableMapObj::PolyParabel:
3519 actionFormatLinkStylePolyParabel->setOn(true);
3526 QPixmap pix( 16, 16 );
3527 pix.fill( m->getMapBackgroundColor() );
3528 actionFormatBackColor->setIconSet( pix );
3529 pix.fill( m->getSelectionColor() );
3530 actionFormatSelectionColor->setIconSet( pix );
3531 pix.fill( m->getMapDefLinkColor() );
3532 actionFormatLinkColor->setIconSet( pix );
3535 actionFileSave->setEnabled( m->hasChanged() );
3536 if (m->isUndoAvailable())
3537 actionEditUndo->setEnabled( true);
3539 actionEditUndo->setEnabled( false);
3541 if (m->isRedoAvailable())
3542 actionEditRedo->setEnabled( true);
3544 actionEditRedo->setEnabled( false);
3546 LinkableMapObj *selection=m->getSelection();
3549 if ( (typeid(*selection) == typeid(BranchObj)) ||
3550 (typeid(*selection) == typeid(MapCenterObj)) )
3552 BranchObj *bo=(BranchObj*)selection;
3553 // Take care of links
3554 if (bo->countXLinks()==0)
3556 branchXLinksContextMenuEdit->clear();
3557 branchXLinksContextMenuFollow->clear();
3562 branchXLinksContextMenuEdit->clear();
3563 branchXLinksContextMenuFollow->clear();
3564 for (int i=0; i<=bo->countXLinks();i++)
3566 bot=bo->XLinkTargetAt(i);
3569 s=bot->getHeading();
3570 if (s.length()>xLinkMenuWidth)
3571 s=s.left(xLinkMenuWidth)+"...";
3572 branchXLinksContextMenuFollow->addAction (s);
3573 branchXLinksContextMenuEdit->addAction (s);
3578 standardFlagsDefault->setEnabled (true);
3580 actionEditToggleScroll->setEnabled (true);
3581 if ( bo->isScrolled() )
3582 actionEditToggleScroll->setOn(true);
3584 actionEditToggleScroll->setOn(false);
3586 if ( bo->getURL().isEmpty() )
3588 actionEditOpenURL->setEnabled (false);
3589 actionEditOpenURLTab->setEnabled (false);
3593 actionEditOpenURL->setEnabled (true);
3594 actionEditOpenURLTab->setEnabled (true);
3596 if ( bo->getVymLink().isEmpty() )
3598 actionEditOpenVymLink->setEnabled (false);
3599 actionEditDeleteVymLink->setEnabled (false);
3602 actionEditOpenVymLink->setEnabled (true);
3603 actionEditDeleteVymLink->setEnabled (true);
3606 if (bo->canMoveBranchUp())
3607 actionEditMoveUp->setEnabled (true);
3609 actionEditMoveUp->setEnabled (false);
3610 if (bo->canMoveBranchDown())
3611 actionEditMoveDown->setEnabled (true);
3613 actionEditMoveDown->setEnabled (false);
3616 actionEditToggleHideExport->setEnabled (true);
3617 actionEditToggleHideExport->setOn (bo->hideInExport() );
3619 actionEditCopy->setEnabled (true);
3620 actionEditCut->setEnabled (true);
3621 if (!clipboardEmpty)
3622 actionEditPaste->setEnabled (true);
3624 actionEditPaste->setEnabled (false);
3625 for (int i=0; i<actionListBranches.size(); ++i)
3626 actionListBranches.at(i)->setEnabled(true);
3627 actionEditDelete->setEnabled (true);
3628 actionFormatHideLinkUnselected->setOn
3629 (selection->getHideLinkUnselected());
3631 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3633 FloatObj *fo=(FloatImageObj*)selection;
3635 actionEditOpenURL->setEnabled (false);
3636 actionEditOpenVymLink->setEnabled (false);
3637 actionEditDeleteVymLink->setEnabled (false);
3638 actionEditToggleHideExport->setEnabled (true);
3639 actionEditToggleHideExport->setOn (fo->hideInExport() );
3642 actionEditCopy->setEnabled (true);
3643 actionEditCut->setEnabled (true);
3644 actionEditPaste->setEnabled (false);
3645 for (int i=0; i<actionListBranches.size(); ++i)
3646 actionListBranches.at(i)->setEnabled(false);
3647 actionEditDelete->setEnabled (true);
3648 actionFormatHideLinkUnselected->setOn
3649 ( selection->getHideLinkUnselected());
3650 actionEditMoveUp->setEnabled (false);
3651 actionEditMoveDown->setEnabled (false);
3656 actionEditCopy->setEnabled (false);
3657 actionEditCut->setEnabled (false);
3658 actionEditPaste->setEnabled (false);
3659 for (int i=0; i<actionListBranches.size(); ++i)
3660 actionListBranches.at(i)->setEnabled(false);
3662 actionEditToggleScroll->setEnabled (false);
3663 actionEditOpenURL->setEnabled (false);
3664 actionEditOpenVymLink->setEnabled (false);
3665 actionEditDeleteVymLink->setEnabled (false);
3666 actionEditHeading2URL->setEnabled (false);
3667 actionEditDelete->setEnabled (false);
3668 actionEditMoveUp->setEnabled (false);
3669 actionEditMoveDown->setEnabled (false);
3670 actionEditToggleHideExport->setEnabled (false);
3674 Main::ModMode Main::getModMode()
3676 if (actionModModeColor->isOn()) return ModModeColor;
3677 if (actionModModeCopy->isOn()) return ModModeCopy;
3678 if (actionModModeXLink->isOn()) return ModModeXLink;
3682 bool Main::autoEditNewBranch()
3684 return actionSettingsAutoEditNewBranch->isOn();
3687 bool Main::autoSelectNewBranch()
3689 return actionSettingsAutoSelectNewBranch->isOn();
3692 bool Main::useFlagGroups()
3694 return actionSettingsUseFlagGroups->isOn();
3697 void Main::windowShowNoteEditor()
3699 textEditor->setShowWithMain(true);
3701 actionViewToggleNoteEditor->setOn (true);
3704 void Main::windowHideNoteEditor()
3706 textEditor->setShowWithMain(false);
3708 actionViewToggleNoteEditor->setOn (false);
3711 void Main::setScript (const QString &script)
3713 scriptEditor->setScript (script);
3716 void Main::runScript (const QString &script)
3718 VymModel *m=currentModel();
3719 if (m) m->runScript (script);
3722 void Main::runScriptEverywhere (const QString &script)
3725 for (int i=0;i<=tabWidget->count() -1;i++)
3727 me=(MapEditor*)tabWidget->page(i);
3728 if (me) me->getModel()->runScript (script);
3732 void Main::windowNextEditor()
3734 if (tabWidget->currentPageIndex() < tabWidget->count())
3735 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3738 void Main::windowPreviousEditor()
3740 if (tabWidget->currentPageIndex() >0)
3741 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3744 void Main::standardFlagChanged()
3746 if (currentMapEditor())
3747 currentMapEditor()->toggleStandardFlag(sender()->name());
3750 void Main::testFunction1()
3752 if (!currentMapEditor()) return;
3753 currentMapEditor()->testFunction1();
3757 void Main::testFunction2()
3759 if (!currentMapEditor()) return;
3760 currentMapEditor()->testFunction2();
3763 void Main::testCommand()
3765 if (!currentMapEditor()) return;
3766 scriptEditor->show();
3769 QString com = QInputDialog::getText(
3770 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3771 if (ok) currentMapEditor()->parseAtom(com);
3775 void Main::helpDoc()
3777 QString locale = QLocale::system().name();
3779 if (locale.left(2)=="es")
3780 docname="vym_es.pdf";
3784 QStringList searchList;
3786 #if defined(Q_OS_MACX)
3787 searchList << "./vym.app/Contents/Resources/doc";
3788 #elif defined(Q_OS_WIN32)
3789 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3791 #if defined(VYM_DOCDIR)
3792 searchList << VYM_DOCDIR;
3794 // default path in SUSE LINUX
3795 searchList << "/usr/share/doc/packages/vym";
3798 searchList << "doc"; // relative path for easy testing in tarball
3799 searchList << "doc/tex"; // Easy testing working on vym.tex
3800 searchList << "/usr/share/doc/vym"; // Debian
3801 searchList << "/usr/share/doc/packages";// Knoppix
3805 for (int i=0; i<searchList.count(); ++i)
3807 docfile.setFileName(searchList.at(i)+"/"+docname);
3808 if (docfile.exists())
3817 QMessageBox::critical(0,
3818 tr("Critcal error"),
3819 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3824 Process *pdfProc = new Process();
3825 args << QDir::toNativeSeparators(docfile.fileName());
3827 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3828 if ( !pdfProc->waitForStarted() )
3831 QMessageBox::warning(0,
3833 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3834 tr("Please use Settings->")+tr("Set application to open PDF files"));
3841 void Main::helpDemo()
3843 QStringList filters;
3844 filters <<"VYM example map (*.vym)";
3845 QFileDialog *fd=new QFileDialog( this);
3846 #if defined(Q_OS_MACX)
3847 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3849 // default path in SUSE LINUX
3850 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3853 fd->setFileMode (QFileDialog::ExistingFiles);
3854 fd->setFilters (filters);
3855 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3859 if ( fd->exec() == QDialog::Accepted )
3861 lastFileDir=fd->directory().path();
3862 QStringList flist = fd->selectedFiles();
3863 QStringList::Iterator it = flist.begin();
3864 while( it != flist.end() )
3867 fileLoad(*it, NewMap);
3875 void Main::helpAbout()
3878 ad.setName ("aboutwindow");
3879 ad.setMinimumSize(500,500);
3880 ad.resize (QSize (500,500));
3884 void Main::helpAboutQT()
3886 QMessageBox::aboutQt( this, "Qt Application Example" );
3889 void Main::callMacro ()
3891 QAction *action = qobject_cast<QAction *>(sender());
3895 i=action->data().toInt();
3896 QString mDir (settings.value ("macros/macroDir").toString() );
3898 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3900 if ( !f.open( QIODevice::ReadOnly ) )
3902 QMessageBox::warning(0,
3904 tr("Couldn't find a macro at %1.\n").arg(fn)+
3905 tr("Please use Settings->")+tr("Set directory for vym macros"));
3909 QTextStream ts( &f );
3910 QString macro= ts.read();
3912 if (! macro.isEmpty())
3914 VymModel *m=currentModel();
3915 if (m) m->runScript(macro);