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);
497 // Shortcuts to modify heading:
498 a = new QAction(tr( "Edit heading","Edit menu" ),this);
499 a->setStatusTip ( tr( "edit Heading" ));
500 a->setShortcut ( Qt::Key_Enter); //Edit heading
501 // a->setShortcutContext (Qt::WindowShortcut);
503 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
504 actionListBranches.append(a);
505 a = new QAction( tr( "Edit heading","Edit menu" ), this);
506 a->setStatusTip (tr( "edit Heading" ));
507 a->setShortcut (Qt::Key_Return ); //Edit heading
508 //a->setShortcutContext (Qt::WindowShortcut);
510 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
511 actionListBranches.append(a);
512 editMenu->addAction (a);
514 a = new QAction( tr( "Edit heading","Edit menu" ), this);
515 a->setStatusTip (tr( "edit Heading" ));
516 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
517 a->setShortcutContext (Qt::WindowShortcut);
519 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
520 actionListBranches.append(a);
522 // Shortcut to delete selection
523 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
524 a->setStatusTip (tr( "Delete Selection" ));
525 a->setShortcut ( Qt::Key_Delete); //Delete selection
526 a->setShortcutContext (Qt::WindowShortcut);
528 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
531 // Shortcut to add mapcenter
532 a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
533 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
534 actionEditAddMapCenter = a;
537 // Shortcut to add branch
538 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
539 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
540 alt->setShortcut (Qt::Key_A); //Add branch
541 alt->setShortcutContext (Qt::WindowShortcut);
543 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
544 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
545 a->setStatusTip ( tr( "Add a branch as child of selection" ));
546 a->setShortcut (Qt::Key_Insert); //Add branch
547 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
548 actionListBranches.append(a);
549 #if defined (Q_OS_MACX)
550 // In OSX show different shortcut in menues, the keys work indepently always
551 actionEditAddBranch=alt;
553 actionEditAddBranch=a;
555 editMenu->addAction (actionEditAddBranch);
556 tb->addAction (actionEditAddBranch);
559 // Add branch by inserting it at selection
560 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
561 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
562 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
563 a->setShortcutContext (Qt::WindowShortcut);
565 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
566 a->setEnabled (false);
567 actionListBranches.append(a);
568 actionEditAddBranchBefore=a;
569 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
570 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
571 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
572 a->setShortcutContext (Qt::WindowShortcut);
574 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
575 actionListBranches.append(a);
578 a = new QAction(tr( "Add branch above","Edit menu" ), this);
579 a->setStatusTip ( tr( "Add a branch above selection" ));
580 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
581 a->setShortcutContext (Qt::WindowShortcut);
583 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
584 a->setEnabled (false);
585 actionListBranches.append(a);
586 actionEditAddBranchAbove=a;
587 a = new QAction(tr( "Add branch above","Edit menu" ), this);
588 a->setStatusTip ( tr( "Add a branch above selection" ));
589 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
590 a->setShortcutContext (Qt::WindowShortcut);
592 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
593 actionListBranches.append(a);
596 a = new QAction(tr( "Add branch below","Edit menu" ), this);
597 a->setStatusTip ( tr( "Add a branch below selection" ));
598 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
599 a->setShortcutContext (Qt::WindowShortcut);
601 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
602 a->setEnabled (false);
603 actionListBranches.append(a);
604 actionEditAddBranchBelow=a;
605 a = new QAction(tr( "Add branch below","Edit menu" ), this);
606 a->setStatusTip ( tr( "Add a branch below selection" ));
607 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
608 a->setShortcutContext (Qt::WindowShortcut);
610 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
611 actionListBranches.append(a);
613 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
614 a->setStatusTip ( tr( "Move branch up" ) );
615 a->setShortcut (Qt::Key_PageUp ); // Move branch up
616 a->setEnabled (false);
618 editMenu->addAction (a);
619 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
622 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
623 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
624 a->setStatusTip (tr( "Move branch down" ) );
625 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
626 a->setEnabled (false);
628 editMenu->addAction (a);
629 actionEditMoveDown=a;
631 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
632 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
633 a->setEnabled (true);
635 editMenu->addAction (a);
636 actionEditSortChildren=a;
638 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
639 a->setShortcut ( Qt::Key_ScrollLock );
640 a->setStatusTip (tr( "Scroll branch" ) );
641 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
643 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
644 alt->setShortcut ( Qt::Key_S ); // Scroll branch
645 alt->setStatusTip (tr( "Scroll branch" ));
646 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
647 #if defined(Q_OS_MACX)
648 actionEditToggleScroll=alt;
650 actionEditToggleScroll=a;
652 actionEditToggleScroll->setEnabled (false);
653 actionEditToggleScroll->setToggleAction(true);
654 tb->addAction (actionEditToggleScroll);
655 editMenu->addAction ( actionEditToggleScroll);
656 editMenu->addAction (actionEditToggleScroll);
659 actionListBranches.append(actionEditToggleScroll);
661 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
662 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
663 editMenu->addAction (a);
664 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
666 editMenu->addSeparator();
668 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
669 a->setStatusTip (tr( "Find" ) );
670 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
671 editMenu->addAction (a);
672 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
674 editMenu->addSeparator();
676 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
677 a->setShortcut (Qt::CTRL + Qt::Key_U );
678 a->setShortcut (tr( "Open URL" ));
681 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
684 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
685 a->setStatusTip (tr( "Open URL in new tab" ));
686 //a->setShortcut (Qt::CTRL+Qt::Key_U );
688 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
689 actionEditOpenURLTab=a;
691 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
692 a->setStatusTip (tr( "Open all URLs in subtree" ));
694 actionListBranches.append(a);
695 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
696 actionEditOpenMultipleURLTabs=a;
698 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
699 a->setStatusTip ( tr( "Edit URL" ) );
700 a->setShortcut ( Qt::Key_U );
701 a->setShortcutContext (Qt::WindowShortcut);
702 actionListBranches.append(a);
704 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
707 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
708 a->setStatusTip ( tr( "Edit local URL" ) );
709 a->setShortcut (Qt::SHIFT + Qt::Key_U );
710 a->setShortcutContext (Qt::WindowShortcut);
711 actionListBranches.append(a);
713 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
714 actionEditLocalURL=a;
716 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
717 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
718 a->setEnabled (false);
719 actionListBranches.append(a);
720 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
721 actionEditHeading2URL=a;
723 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
724 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
725 a->setEnabled (false);
726 actionListBranches.append(a);
727 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
728 actionEditBugzilla2URL=a;
730 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
731 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
732 a->setEnabled (false);
733 actionListBranches.append(a);
734 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
735 actionEditFATE2URL=a;
737 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
738 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
740 a->setEnabled (false);
741 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
742 actionEditOpenVymLink=a;
744 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
745 a->setStatusTip ( tr( "Open all vym links in subtree" ));
746 a->setEnabled (false);
747 actionListBranches.append(a);
748 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
749 actionEditOpenMultipleVymLinks=a;
752 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
753 a->setEnabled (false);
754 a->setStatusTip ( tr( "Edit link to another vym map" ));
755 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
756 actionListBranches.append(a);
759 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
760 a->setStatusTip ( tr( "Delete link to another vym map" ));
761 a->setEnabled (false);
762 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
763 actionEditDeleteVymLink=a;
765 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
766 a->setStatusTip ( tr( "Hide object in exports" ) );
767 a->setShortcut (Qt::Key_H );
768 a->setToggleAction(true);
770 a->setEnabled (false);
771 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
772 actionEditToggleHideExport=a;
774 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
775 a->setStatusTip ( tr( "Edit Map Info" ));
776 a->setEnabled (true);
777 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
780 // Import at selection (adding to selection)
781 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
782 a->setStatusTip (tr( "Add map at selection" ));
783 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
784 a->setEnabled (false);
785 actionListBranches.append(a);
786 actionEditImportAdd=a;
788 // Import at selection (replacing selection)
789 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
790 a->setStatusTip (tr( "Replace selection with map" ));
791 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
792 a->setEnabled (false);
793 actionListBranches.append(a);
794 actionEditImportReplace=a;
797 a = new QAction( tr( "Save selection","Edit menu" ), this);
798 a->setStatusTip (tr( "Save selection" ));
799 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
800 a->setEnabled (false);
801 actionListBranches.append(a);
802 actionEditSaveBranch=a;
804 // Only remove branch, not its childs
805 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
806 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
807 a->setShortcut (Qt::ALT + Qt::Key_Delete );
808 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
809 a->setEnabled (false);
811 actionListBranches.append(a);
812 actionEditDeleteKeepChilds=a;
814 // Only remove childs of a branch
815 a = new QAction( tr( "Remove childs","Edit menu" ), this);
816 a->setStatusTip (tr( "Remove childs of branch" ));
817 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
818 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
819 a->setEnabled (false);
820 actionListBranches.append(a);
821 actionEditDeleteChilds=a;
823 // Shortcuts for navigating with cursor:
824 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
825 a->setStatusTip ( tr( "Select upper branch" ));
826 a->setShortcut (Qt::Key_Up );
827 a->setShortcutContext (Qt::WindowShortcut);
829 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
830 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
831 a->setStatusTip (tr( "Select lower branch" ));
832 a->setShortcut ( Qt::Key_Down );
833 a->setShortcutContext (Qt::WindowShortcut);
835 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
836 a = new QAction(tr( "Select left branch","Edit menu" ), this);
837 a->setStatusTip ( tr( "Select left branch" ));
838 a->setShortcut (Qt::Key_Left );
839 a->setShortcutContext (Qt::WindowShortcut);
841 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
842 a = new QAction( tr( "Select child branch","Edit menu" ), this);
843 a->setStatusTip (tr( "Select right branch" ));
844 a->setShortcut (Qt::Key_Right);
845 a->setShortcutContext (Qt::WindowShortcut);
847 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
848 a = new QAction( tr( "Select first branch","Edit menu" ), this);
849 a->setStatusTip (tr( "Select first branch" ));
850 a->setShortcut (Qt::Key_Home );
851 a->setShortcutContext (Qt::WindowShortcut);
853 a->setEnabled (false);
854 editMenu->addAction (a);
855 actionListBranches.append(a);
856 actionEditSelectFirst=a;
857 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
858 a = new QAction( tr( "Select last branch","Edit menu" ),this);
859 a->setStatusTip (tr( "Select last branch" ));
860 a->setShortcut ( Qt::Key_End );
861 a->setShortcutContext (Qt::WindowShortcut);
863 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
864 a->setEnabled (false);
865 editMenu->addAction (a);
866 actionListBranches.append(a);
867 actionEditSelectLast=a;
869 a = new QAction( tr( "Add Image...","Edit menu" ), this);
870 a->setStatusTip (tr( "Add Image" ));
871 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
872 actionEditLoadImage=a;
874 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
875 a->setStatusTip (tr( "Set properties for selection" ));
876 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
877 a->setShortcutContext (Qt::WindowShortcut);
878 a->setToggleAction (true);
880 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
881 actionViewTogglePropertyWindow=a;
885 void Main::setupFormatActions()
887 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
889 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
890 tb->setObjectName ("formatTB");
893 pix.fill (Qt::black);
894 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
895 a->setStatusTip ( tr( "Set Color" ));
896 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
898 formatMenu->addAction (a);
900 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
901 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
902 a->setShortcut (Qt::CTRL + Qt::Key_K );
903 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
904 a->setEnabled (false);
906 formatMenu->addAction (a);
907 actionListBranches.append(a);
908 actionFormatPickColor=a;
910 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
911 a->setStatusTip ( tr( "Color branch" ) );
912 a->setShortcut (Qt::CTRL + Qt::Key_B);
913 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
914 a->setEnabled (false);
916 formatMenu->addAction (a);
917 actionListBranches.append(a);
918 actionFormatColorSubtree=a;
920 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
921 a->setStatusTip ( tr( "Color Subtree" ));
922 a->setShortcut (Qt::CTRL + Qt::Key_T);
923 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
924 a->setEnabled (false);
925 formatMenu->addAction (a);
927 actionListBranches.append(a);
928 actionFormatColorSubtree=a;
930 formatMenu->addSeparator();
931 actionGroupFormatLinkStyles=new QActionGroup ( this);
932 actionGroupFormatLinkStyles->setExclusive (true);
933 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
934 a->setStatusTip (tr( "Line" ));
935 a->setToggleAction(true);
936 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
937 formatMenu->addAction (a);
938 actionFormatLinkStyleLine=a;
939 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
940 a->setStatusTip (tr( "Line" ));
941 a->setToggleAction(true);
942 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
943 formatMenu->addAction (a);
944 actionFormatLinkStyleParabel=a;
945 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
946 a->setStatusTip (tr( "PolyLine" ));
947 a->setToggleAction(true);
948 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
949 formatMenu->addAction (a);
950 actionFormatLinkStylePolyLine=a;
951 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
952 a->setStatusTip (tr( "PolyParabel" ) );
953 a->setToggleAction(true);
954 a->setChecked (true);
955 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
956 formatMenu->addAction (a);
957 actionFormatLinkStylePolyParabel=a;
959 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
960 a->setStatusTip (tr( "Hide link" ));
961 a->setToggleAction(true);
962 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
963 actionFormatHideLinkUnselected=a;
965 formatMenu->addSeparator();
966 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
967 a->setStatusTip (tr( "Use same color for links and headings" ));
968 a->setToggleAction(true);
969 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
970 formatMenu->addAction (a);
971 actionFormatLinkColorHint=a;
973 pix.fill (Qt::white);
974 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
975 a->setStatusTip (tr( "Set Link Color" ));
976 formatMenu->addAction (a);
977 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
978 actionFormatLinkColor=a;
980 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
981 a->setStatusTip (tr( "Set Selection Color" ));
982 formatMenu->addAction (a);
983 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
984 actionFormatSelectionColor=a;
986 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
987 a->setStatusTip (tr( "Set Background Color" ));
988 formatMenu->addAction (a);
989 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
990 actionFormatBackColor=a;
992 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
993 a->setStatusTip (tr( "Set Background image" ));
994 formatMenu->addAction (a);
995 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
996 actionFormatBackImage=a;
1000 void Main::setupViewActions()
1002 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1003 tb->setLabel( "View Actions" );
1004 tb->setObjectName ("viewTB");
1005 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1008 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1009 a->setStatusTip ( tr( "Zoom reset" ) );
1010 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1012 viewMenu->addAction (a);
1013 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1015 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1016 a->setStatusTip (tr( "Zoom in" ));
1017 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1019 viewMenu->addAction (a);
1020 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1022 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1023 a->setStatusTip (tr( "Zoom out" ));
1024 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1026 viewMenu->addAction (a);
1027 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1029 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1030 a->setStatusTip (tr( "Show selection" ));
1031 a->setShortcut (Qt::Key_Period);
1033 viewMenu->addAction (a);
1034 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1036 viewMenu->addSeparator();
1038 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1039 a->setStatusTip ( tr( "Show Note Editor" ));
1040 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1041 a->setToggleAction(true);
1043 viewMenu->addAction (a);
1044 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1045 actionViewToggleNoteEditor=a;
1047 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1048 a->setStatusTip ( tr( "Show History Window" ));
1049 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1050 a->setToggleAction(true);
1052 viewMenu->addAction (a);
1053 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1054 actionViewToggleHistoryWindow=a;
1056 viewMenu->addAction (actionViewTogglePropertyWindow);
1058 viewMenu->addSeparator();
1060 a = new QAction(tr( "Antialiasing","View action" ),this );
1061 a->setStatusTip ( tr( "Antialiasing" ));
1062 a->setToggleAction(true);
1063 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1064 viewMenu->addAction (a);
1065 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1066 actionViewToggleAntiAlias=a;
1068 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1069 a->setStatusTip (a->text());
1070 a->setToggleAction(true);
1071 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1072 viewMenu->addAction (a);
1073 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1074 actionViewToggleSmoothPixmapTransform=a;
1076 a = new QAction(tr( "Next Map","View action" ), this);
1077 a->setStatusTip (a->text());
1078 a->setShortcut (Qt::ALT + Qt::Key_N );
1079 viewMenu->addAction (a);
1080 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1082 a = new QAction (tr( "Previous Map","View action" ), this );
1083 a->setStatusTip (a->text());
1084 a->setShortcut (Qt::ALT + Qt::Key_P );
1085 viewMenu->addAction (a);
1086 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1090 void Main::setupModeActions()
1092 //QPopupMenu *menu = new QPopupMenu( this );
1093 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1095 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1096 tb->setObjectName ("modesTB");
1098 actionGroupModModes=new QActionGroup ( this);
1099 actionGroupModModes->setExclusive (true);
1100 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1101 a->setShortcut (Qt::Key_J);
1102 a->setStatusTip ( tr( "Use modifier to color branches" ));
1103 a->setToggleAction(true);
1106 actionModModeColor=a;
1108 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1109 a->setShortcut( Qt::Key_K);
1110 a->setStatusTip( tr( "Use modifier to copy" ));
1111 a->setToggleAction(true);
1113 actionModModeCopy=a;
1115 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1116 a->setShortcut (Qt::Key_L);
1117 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1118 a->setToggleAction(true);
1120 actionModModeXLink=a;
1124 void Main::setupFlagActions()
1126 // Create System Flags
1130 systemFlagsDefault = new FlagRowObj ();
1131 systemFlagsDefault->setVisibility (false);
1132 systemFlagsDefault->setName ("systemFlagsDef");
1134 FlagObj *fo = new FlagObj ();
1135 fo->load(QPixmap(flagsPath+"flag-note.png"));
1136 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1138 fo->load(QPixmap(flagsPath+"flag-url.png"));
1139 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1141 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1142 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1144 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1145 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1147 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1148 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1150 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1151 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1153 // Create Standard Flags
1154 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1155 tb->setObjectName ("standardFlagTB");
1157 standardFlagsDefault = new FlagRowObj ();
1158 standardFlagsDefault->setVisibility (false);
1159 standardFlagsDefault->setName ("standardFlagsDef");
1160 standardFlagsDefault->setToolBar (tb);
1162 fo->load(flagsPath+"flag-exclamationmark.png");
1163 fo->setGroup("standard-mark");
1164 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1166 fo->load(flagsPath+"flag-questionmark.png");
1167 fo->setGroup("standard-mark");
1168 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1170 fo->load(flagsPath+"flag-hook-green.png");
1171 fo->setGroup("standard-hook");
1172 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1174 fo->load(flagsPath+"flag-cross-red.png");
1175 fo->setGroup("standard-hook");
1176 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1179 fo->load(flagsPath+"flag-stopsign.png");
1180 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1182 fo->load(flagsPath+"flag-smiley-good.png");
1183 fo->setGroup("standard-smiley");
1184 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1186 fo->load(flagsPath+"flag-smiley-sad.png");
1187 fo->setGroup("standard-smiley");
1188 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1190 fo->load(flagsPath+"flag-smiley-omg.png");
1191 fo->setGroup("standard-smiley");
1192 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1193 // Original omg.png (in KDE emoticons)
1196 fo->load(flagsPath+"flag-kalarm.png");
1197 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1199 fo->load(flagsPath+"flag-phone.png");
1200 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1202 fo->load(flagsPath+"flag-lamp.png");
1203 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1205 fo->load(flagsPath+"flag-arrow-up.png");
1206 fo->setGroup("standard-arrow");
1207 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1209 fo->load(flagsPath+"flag-arrow-down.png");
1210 fo->setGroup("standard-arrow");
1211 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1213 fo->load(flagsPath+"flag-arrow-2up.png");
1214 fo->setGroup("standard-arrow");
1215 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1217 fo->load(flagsPath+"flag-arrow-2down.png");
1218 fo->setGroup("standard-arrow");
1219 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1222 fo->load(flagsPath+"flag-thumb-up.png");
1223 fo->setGroup("standard-thumb");
1224 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1226 fo->load(flagsPath+"flag-thumb-down.png");
1227 fo->setGroup("standard-thumb");
1228 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1231 fo->load(flagsPath+"flag-rose.png");
1232 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1234 fo->load(flagsPath+"flag-heart.png");
1235 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1237 fo->load(flagsPath+"flag-present.png");
1238 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1240 fo->load(flagsPath+"flag-flash.png");
1241 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1243 // Original: xsldbg_output.png
1244 fo->load(flagsPath+"flag-info.png");
1245 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1247 // Original khelpcenter.png
1248 fo->load(flagsPath+"flag-lifebelt.png");
1249 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1255 fo->load(flagsPath+"freemind/warning.png");
1256 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1258 for (int i=1; i<8; i++)
1260 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1261 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1264 fo->load(flagsPath+"freemind/back.png");
1265 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1267 fo->load(flagsPath+"freemind/forward.png");
1268 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1270 fo->load(flagsPath+"freemind/attach.png");
1271 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1273 fo->load(flagsPath+"freemind/clanbomber.png");
1274 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1276 fo->load(flagsPath+"freemind/desktopnew.png");
1277 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1279 fo->load(flagsPath+"freemind/flag.png");
1280 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1283 fo->load(flagsPath+"freemind/gohome.png");
1284 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1287 fo->load(flagsPath+"freemind/kaddressbook.png");
1288 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1290 fo->load(flagsPath+"freemind/knotify.png");
1291 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1293 fo->load(flagsPath+"freemind/korn.png");
1294 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1296 fo->load(flagsPath+"freemind/mail.png");
1297 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1299 fo->load(flagsPath+"freemind/password.png");
1300 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1302 fo->load(flagsPath+"freemind/pencil.png");
1303 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1305 fo->load(flagsPath+"freemind/stop.png");
1306 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1308 fo->load(flagsPath+"freemind/wizard.png");
1309 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1311 fo->load(flagsPath+"freemind/xmag.png");
1312 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1314 fo->load(flagsPath+"freemind/bell.png");
1315 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1317 fo->load(flagsPath+"freemind/bookmark.png");
1318 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1320 fo->load(flagsPath+"freemind/penguin.png");
1321 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1323 fo->load(flagsPath+"freemind/licq.png");
1324 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1329 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1332 fo->setToolTip (tooltip);
1333 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1339 fo->setAlwaysVisible(aw);
1340 a->setCheckable(true);
1341 a->setObjectName(fo->getName());
1342 a->setToolTip(tooltip);
1343 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1344 standardFlagsDefault->addFlag (fo);
1348 systemFlagsDefault->addFlag (fo);
1352 void Main::setupNetworkActions()
1354 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1356 QMenu *netMenu = menuBar()->addMenu( "Network" );
1360 a = new QAction( "Start TCPserver for MapEditor",this);
1361 //a->setStatusTip ( "Set application to open pdf files"));
1362 a->setShortcut ( Qt::Key_T ); //New TCP server
1363 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1364 netMenu->addAction (a);
1366 a = new QAction( "Connect MapEditor to server",this);
1367 //a->setStatusTip ( "Set application to open pdf files"));
1368 a->setShortcut ( Qt::Key_C ); // Connect to server
1369 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1370 netMenu->addAction (a);
1374 void Main::setupSettingsActions()
1376 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1380 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1381 a->setStatusTip ( tr( "Set application to open pdf files"));
1382 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1383 settingsMenu->addAction (a);
1385 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1386 a->setStatusTip( tr( "Set application to open external links"));
1387 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1388 settingsMenu->addAction (a);
1390 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1391 a->setStatusTip( tr( "Set path for macros"));
1392 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1393 settingsMenu->addAction (a);
1395 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1396 a->setStatusTip( tr( "Set number of undo levels"));
1397 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1398 settingsMenu->addAction (a);
1400 settingsMenu->addSeparator();
1402 a = new QAction( tr( "Autosave","Settings action"), this);
1403 a->setStatusTip( tr( "Autosave"));
1404 a->setToggleAction(true);
1405 a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool());
1406 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1407 settingsMenu->addAction (a);
1408 actionSettingsAutosaveToggle=a;
1410 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1411 a->setStatusTip( tr( "Autosave time"));
1412 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1413 settingsMenu->addAction (a);
1414 actionSettingsAutosaveTime=a;
1416 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1417 a->setStatusTip( tr( "Write backup file on save"));
1418 a->setToggleAction(true);
1419 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1420 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1421 settingsMenu->addAction (a);
1422 actionSettingsWriteBackupFile=a;
1424 settingsMenu->addSeparator();
1426 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1427 a->setStatusTip( tr( "Edit branch after adding it" ));
1428 a->setToggleAction(true);
1429 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1430 settingsMenu->addAction (a);
1431 actionSettingsAutoEditNewBranch=a;
1433 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1434 a->setStatusTip( tr( "Select branch after adding it" ));
1435 a->setToggleAction(true);
1436 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1437 settingsMenu->addAction (a);
1438 actionSettingsAutoSelectNewBranch=a;
1440 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1441 a->setStatusTip( tr( "Select heading before editing" ));
1442 a->setToggleAction(true);
1443 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1444 settingsMenu->addAction (a);
1445 actionSettingsAutoSelectText=a;
1447 a= new QAction( tr( "Delete key","Settings action" ), this);
1448 a->setStatusTip( tr( "Delete key for deleting branches" ));
1449 a->setToggleAction(true);
1450 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1451 settingsMenu->addAction (a);
1452 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1453 actionSettingsUseDelKey=a;
1455 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1456 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1457 a->setToggleAction(true);
1458 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1459 settingsMenu->addAction (a);
1460 actionSettingsUseFlagGroups=a;
1462 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1463 a->setStatusTip( tr( "Use hide flag during exports " ));
1464 a->setToggleAction(true);
1465 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1466 settingsMenu->addAction (a);
1467 actionSettingsUseHideExport=a;
1469 a = new QAction( tr( "Animation","Settings action"), this);
1470 a->setStatusTip( tr( "Animation"));
1471 a->setToggleAction(true);
1472 a->setOn (settings.value("/animation/use",false).toBool() );
1473 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1474 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1476 settingsMenu->addAction (a);
1478 actionSettingsUseAnimation=a;
1482 void Main::setupTestActions()
1484 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1487 a = new QAction( "Test function 1" , this);
1488 a->setStatusTip( "Call test function 1" );
1489 testMenu->addAction (a);
1490 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1492 a = new QAction( "Test function 2" , this);
1493 a->setStatusTip( "Call test function 2" );
1494 testMenu->addAction (a);
1495 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1497 a = new QAction( "Command" , this);
1498 a->setStatusTip( "Enter command to call in editor" );
1499 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1500 testMenu->addAction (a);
1504 void Main::setupHelpActions()
1506 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1509 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1510 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1511 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1512 helpMenu->addAction (a);
1514 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1515 a->setStatusTip( tr( "Open VYM example maps " ));
1516 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1517 helpMenu->addAction (a);
1519 a = new QAction( tr( "About VYM","Help action" ), this);
1520 a->setStatusTip( tr( "About VYM")+vymName);
1521 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1522 helpMenu->addAction (a);
1524 a = new QAction( tr( "About QT","Help action" ), this);
1525 a->setStatusTip( tr( "Information about QT toolkit" ));
1526 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1527 helpMenu->addAction (a);
1531 void Main::setupContextMenus()
1535 // Context Menu for branch or mapcenter
1536 branchContextMenu =new QMenu (this);
1537 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1538 branchContextMenu->addSeparator();
1541 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1542 branchAddContextMenu->addAction (actionEditPaste );
1543 branchAddContextMenu->addAction ( actionEditAddBranch );
1544 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1545 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1546 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1547 branchAddContextMenu->addSeparator();
1548 branchAddContextMenu->addAction ( actionEditImportAdd );
1549 branchAddContextMenu->addAction ( actionEditImportReplace );
1552 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1553 branchRemoveContextMenu->addAction (actionEditCut);
1554 branchRemoveContextMenu->addAction ( actionEditDelete );
1555 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1556 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1559 actionEditSaveBranch->addTo( branchContextMenu );
1560 actionFileNewCopy->addTo (branchContextMenu );
1562 branchContextMenu->addSeparator();
1563 branchContextMenu->addAction ( actionEditLoadImage);
1565 // Submenu for Links (URLs, vymLinks)
1566 branchLinksContextMenu =new QMenu (this);
1568 branchContextMenu->addSeparator();
1569 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1570 branchLinksContextMenu->addAction ( actionEditOpenURL );
1571 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1572 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1573 branchLinksContextMenu->addAction ( actionEditURL );
1574 branchLinksContextMenu->addAction ( actionEditLocalURL );
1575 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1576 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1577 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1579 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1581 branchLinksContextMenu->addSeparator();
1582 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1583 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1584 branchLinksContextMenu->addAction ( actionEditVymLink );
1585 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1588 // Context Menu for XLinks in a branch menu
1589 // This will be populated "on demand" in MapEditor::updateActions
1590 branchContextMenu->addSeparator();
1591 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1592 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1593 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1594 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1597 // Context menu for floatimage
1598 floatimageContextMenu =new QMenu (this);
1599 a= new QAction (tr ("Save image","Context action"),this);
1600 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1601 floatimageContextMenu->addAction (a);
1603 floatimageContextMenu->addSeparator();
1604 actionEditCopy->addTo( floatimageContextMenu );
1605 actionEditCut->addTo( floatimageContextMenu );
1607 floatimageContextMenu->addSeparator();
1608 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1611 // Context menu for canvas
1612 canvasContextMenu =new QMenu (this);
1613 actionEditMapInfo->addTo( canvasContextMenu );
1614 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1615 actionEditAddMapCenter->addTo( canvasContextMenu );
1616 canvasContextMenu->insertSeparator();
1617 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1618 canvasContextMenu->insertSeparator();
1619 actionFormatLinkColorHint->addTo( canvasContextMenu );
1620 actionFormatLinkColor->addTo( canvasContextMenu );
1621 actionFormatSelectionColor->addTo( canvasContextMenu );
1622 actionFormatBackColor->addTo( canvasContextMenu );
1623 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1625 // Menu for last opened files
1627 for (int i = 0; i < MaxRecentFiles; ++i)
1629 recentFileActions[i] = new QAction(this);
1630 recentFileActions[i]->setVisible(false);
1631 fileLastMapsMenu->addAction(recentFileActions[i]);
1632 connect(recentFileActions[i], SIGNAL(triggered()),
1633 this, SLOT(fileLoadRecent()));
1635 setupRecentMapsMenu();
1638 void Main::setupRecentMapsMenu()
1640 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1642 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1644 for (int i = 0; i < numRecentFiles; ++i) {
1645 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1646 recentFileActions[i]->setText(text);
1647 recentFileActions[i]->setData(files[i]);
1648 recentFileActions[i]->setVisible(true);
1650 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1651 recentFileActions[j]->setVisible(false);
1654 void Main::setupMacros()
1656 for (int i = 0; i <= 11; i++)
1658 macroActions[i] = new QAction(this);
1659 macroActions[i]->setData(i);
1660 addAction (macroActions[i]);
1661 connect(macroActions[i], SIGNAL(triggered()),
1662 this, SLOT(callMacro()));
1664 macroActions[0]->setShortcut ( Qt::Key_F1 );
1665 macroActions[1]->setShortcut ( Qt::Key_F2 );
1666 macroActions[2]->setShortcut ( Qt::Key_F3 );
1667 macroActions[3]->setShortcut ( Qt::Key_F4 );
1668 macroActions[4]->setShortcut ( Qt::Key_F5 );
1669 macroActions[5]->setShortcut ( Qt::Key_F6 );
1670 macroActions[6]->setShortcut ( Qt::Key_F7 );
1671 macroActions[7]->setShortcut ( Qt::Key_F8 );
1672 macroActions[8]->setShortcut ( Qt::Key_F9 );
1673 macroActions[9]->setShortcut ( Qt::Key_F10 );
1674 macroActions[10]->setShortcut ( Qt::Key_F11 );
1675 macroActions[11]->setShortcut ( Qt::Key_F12 );
1678 void Main::hideEvent (QHideEvent * )
1680 if (!textEditor->isMinimized() ) textEditor->hide();
1683 void Main::showEvent (QShowEvent * )
1685 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1689 MapEditor* Main::currentMapEditor() const
1691 if ( tabWidget->currentPage() &&
1692 tabWidget->currentPage()->inherits( "MapEditor" ) )
1693 return (MapEditor*)tabWidget->currentPage();
1698 void Main::editorChanged(QWidget *)
1700 // Unselect all possibly selected objects
1701 // (Important to update note editor)
1703 for (int i=0;i<=tabWidget->count() -1;i++)
1706 me=(MapEditor*)tabWidget->page(i);
1709 currentMapEditor()->reselect();
1711 // Update actions to in menus and toolbars according to editor
1715 void Main::fileNew()
1717 QString fn="unnamed";
1718 MapEditor* me = new MapEditor ( NULL);
1719 tabWidget->addTab (me,fn);
1720 tabWidget->showPage(me);
1721 me->viewport()->setFocus();
1722 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1723 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1725 // For the very first map we do not have flagrows yet...
1729 void Main::fileNewCopy()
1731 QString fn="unnamed";
1732 MapEditor* oldME =currentMapEditor();
1736 MapEditor* newME = new MapEditor ( NULL);
1739 tabWidget->addTab (newME,fn);
1740 tabWidget->showPage(newME);
1741 newME->viewport()->setFocus();
1742 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1743 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1744 // For the very first map we do not have flagrows yet...
1745 newME->select("mc:");
1746 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1752 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1754 ErrorCode err=success;
1756 // fn is usually the archive, mapfile the file after uncompressing
1759 // Make fn absolute (needed for unzip)
1760 fn=QDir (fn).absPath();
1766 // Check, if map is already loaded
1768 while (i<=tabWidget->count() -1)
1770 me=(MapEditor*)tabWidget->page(i);
1771 if (me->getFilePath() == fn)
1773 // Already there, ask for confirmation
1774 QMessageBox mb( vymName,
1775 tr("The map %1\nis already opened."
1776 "Opening the same map in multiple editors may lead \n"
1777 "to confusion when finishing working with vym."
1778 "Do you want to").arg(fn),
1779 QMessageBox::Warning,
1780 QMessageBox::Yes | QMessageBox::Default,
1781 QMessageBox::Cancel | QMessageBox::Escape,
1782 QMessageBox::NoButton);
1783 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1784 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1787 case QMessageBox::Yes:
1789 i=tabWidget->count();
1791 case QMessageBox::Cancel:
1803 if ( !fn.isEmpty() )
1805 me = currentMapEditor();
1806 int tabIndex=tabWidget->currentPageIndex();
1807 // Check first, if mapeditor exists
1808 // If it is not default AND we want a new map,
1809 // create a new mapeditor in a new tab
1810 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1812 me= new MapEditor ( NULL);
1813 tabWidget->addTab (me,fn);
1814 tabIndex=tabWidget->indexOf (me);
1815 tabWidget->setCurrentPage (tabIndex);
1816 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1817 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1820 // Check, if file exists (important for creating new files
1821 // from command line
1822 if (!QFile(fn).exists() )
1824 QMessageBox mb( vymName,
1825 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1826 QMessageBox::Question,
1828 QMessageBox::Cancel | QMessageBox::Default,
1829 QMessageBox::NoButton );
1831 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1832 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1835 case QMessageBox::Yes:
1837 currentMapEditor()->setFilePath(fn);
1838 tabWidget->setTabLabel (currentMapEditor(),
1839 currentMapEditor()->getFileName() );
1840 statusBar()->message( "Created " + fn , statusbarTime );
1843 case QMessageBox::Cancel:
1844 // don't create new map
1845 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1852 //tabWidget->currentPage() won't be NULL here, because of above...
1853 tabWidget->showPage(me);
1854 me->viewport()->setFocus();
1858 // Save existing filename in case we import
1859 QString fn_org=me->getFilePath();
1861 // Finally load map into mapEditor
1862 me->setFilePath (fn);
1863 err=me->load(fn,lmode,ftype);
1865 // Restore old (maybe empty) filepath, if this is an import
1867 me->setFilePath (fn_org);
1870 // Finally check for errors and go home
1873 if (lmode==NewMap) fileCloseMap();
1874 statusBar()->message( "Could not load " + fn, statusbarTime );
1879 me->setFilePath (fn);
1880 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1881 if (!isInTmpDir (fn))
1883 // Only append to lastMaps if not loaded from a tmpDir
1884 // e.g. imported bookmarks are in a tmpDir
1885 addRecentMap(me->getFilePath() );
1887 actionFilePrint->setEnabled (true);
1889 statusBar()->message( "Loaded " + fn, statusbarTime );
1896 void Main::fileLoad(const LoadMode &lmode)
1898 QStringList filters;
1899 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1900 QFileDialog *fd=new QFileDialog( this);
1901 fd->setDir (lastFileDir);
1902 fd->setFileMode (QFileDialog::ExistingFiles);
1903 fd->setFilters (filters);
1907 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1910 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1913 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1919 if ( fd->exec() == QDialog::Accepted )
1921 lastFileDir=fd->directory().path();
1922 QStringList flist = fd->selectedFiles();
1923 QStringList::Iterator it = flist.begin();
1924 while( it != flist.end() )
1927 fileLoad(*it, lmode);
1934 void Main::fileLoad()
1939 void Main::fileLoadRecent()
1941 QAction *action = qobject_cast<QAction *>(sender());
1943 fileLoad (action->data().toString(), NewMap);
1946 void Main::addRecentMap (const QString &fileName)
1949 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1950 files.removeAll(fileName);
1951 files.prepend(fileName);
1952 while (files.size() > MaxRecentFiles)
1955 settings.setValue("/mainwindow/recentFileList", files);
1957 setupRecentMapsMenu();
1960 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1964 if ( me->getFilePath().isEmpty() )
1966 // We have no filepath yet,
1967 // call fileSaveAs() now, this will call fileSave()
1969 // First switch to editor
1970 tabWidget->setCurrentWidget (me);
1971 fileSaveAs(savemode);
1974 if (me->save (savemode)==success)
1976 statusBar()->message(
1977 tr("Saved %1").arg(me->getFilePath()),
1979 addRecentMap (me->getFilePath() );
1981 statusBar()->message(
1982 tr("Couldn't save ").arg(me->getFilePath()),
1986 void Main::fileSave()
1988 fileSave (currentMapEditor(), CompleteMap);
1991 void Main::fileSave(MapEditor *me)
1993 fileSave (me,CompleteMap);
1996 void Main::fileSaveAs(const SaveMode& savemode)
2000 if (currentMapEditor())
2002 if (savemode==CompleteMap)
2003 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2005 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2006 if ( !fn.isEmpty() )
2008 // Check for existing file
2009 if (QFile (fn).exists())
2011 QMessageBox mb( vymName,
2012 tr("The file %1\nexists already. Do you want to").arg(fn),
2013 QMessageBox::Warning,
2014 QMessageBox::Yes | QMessageBox::Default,
2015 QMessageBox::Cancel | QMessageBox::Escape,
2016 QMessageBox::NoButton);
2017 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2018 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2021 case QMessageBox::Yes:
2024 case QMessageBox::Cancel:
2031 // New file, add extension to filename, if missing
2032 // This is always .vym or .vyp, depending on savemode
2033 if (savemode==CompleteMap)
2035 if (!fn.contains (".vym") && !fn.contains (".xml"))
2039 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2048 currentMapEditor()->setFilePath(fn);
2049 fileSave(currentMapEditor(), savemode);
2052 if (savemode==CompleteMap)
2053 tabWidget->setTabLabel (currentMapEditor(),
2054 currentMapEditor()->getFileName() );
2060 void Main::fileSaveAs()
2062 fileSaveAs (CompleteMap);
2065 void Main::fileImportKDEBookmarks()
2067 ImportKDEBookmarks im;
2069 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2070 currentMapEditor()->setFilePath ("");
2073 void Main::fileImportFirefoxBookmarks()
2075 Q3FileDialog *fd=new Q3FileDialog( this);
2076 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2077 fd->setMode (Q3FileDialog::ExistingFiles);
2078 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2079 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2082 if ( fd->exec() == QDialog::Accepted )
2084 ImportFirefoxBookmarks im;
2085 QStringList flist = fd->selectedFiles();
2086 QStringList::Iterator it = flist.begin();
2087 while( it != flist.end() )
2090 if (im.transform() &&
2091 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2092 currentMapEditor() )
2093 currentMapEditor()->setFilePath ("");
2100 void Main::fileImportFreemind()
2102 QStringList filters;
2103 filters <<"Freemind map (*.mm)"<<"All files (*)";
2104 QFileDialog *fd=new QFileDialog( this);
2105 fd->setDir (lastFileDir);
2106 fd->setFileMode (QFileDialog::ExistingFiles);
2107 fd->setFilters (filters);
2108 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2112 if ( fd->exec() == QDialog::Accepted )
2114 lastFileDir=fd->directory().path();
2115 QStringList flist = fd->selectedFiles();
2116 QStringList::Iterator it = flist.begin();
2117 while( it != flist.end() )
2120 if ( fileLoad (fn,NewMap, FreemindMap) )
2122 currentMapEditor()->setFilePath ("");
2131 void Main::fileImportMM()
2135 Q3FileDialog *fd=new Q3FileDialog( this);
2136 fd->setDir (lastFileDir);
2137 fd->setMode (Q3FileDialog::ExistingFiles);
2138 fd->addFilter ("Mind Manager (*.mmap)");
2139 fd->setCaption(tr("Import")+" "+"Mind Manager");
2142 if ( fd->exec() == QDialog::Accepted )
2144 lastFileDir=fd->dirPath();
2145 QStringList flist = fd->selectedFiles();
2146 QStringList::Iterator it = flist.begin();
2147 while( it != flist.end() )
2150 if (im.transform() &&
2151 success==fileLoad (im.getTransformedFile(),NewMap) &&
2152 currentMapEditor() )
2153 currentMapEditor()->setFilePath ("");
2162 void Main::fileImportDir()
2164 if (currentMapEditor())
2165 currentMapEditor()->importDir();
2168 void Main::fileExportXML()
2170 MapEditor *me=currentMapEditor();
2171 if (me) me->exportXML();
2175 void Main::fileExportXHTML()
2177 MapEditor *me=currentMapEditor();
2178 if (me) me->exportXHTML();
2181 void Main::fileExportImage()
2183 MapEditor *me=currentMapEditor();
2184 if (me) me->exportImage();
2187 void Main::fileExportASCII()
2189 MapEditor *me=currentMapEditor();
2190 if (me) me->exportASCII();
2193 void Main::fileExportCSV() //FIXME not scriptable yet
2195 MapEditor *me=currentMapEditor();
2199 ex.setModel (me->getModel());
2200 ex.addFilter ("CSV (*.csv)");
2201 ex.setDir(lastImageDir);
2202 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2203 if (ex.execDialog() )
2205 me->setExportMode(true);
2207 me->setExportMode(false);
2212 void Main::fileExportLaTeX() //FIXME not scriptable yet
2214 MapEditor *me=currentMapEditor();
2218 ex.setModel (me->getModel());
2219 ex.addFilter ("Tex (*.tex)");
2220 ex.setDir(lastImageDir);
2221 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2222 if (ex.execDialog() )
2224 me->setExportMode(true);
2226 me->setExportMode(false);
2231 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2233 ExportKDEBookmarks ex;
2234 MapEditor *me=currentMapEditor();
2237 ex.setModel (me->getModel());
2242 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2244 ExportTaskjuggler ex;
2245 MapEditor *me=currentMapEditor();
2248 ex.setModel (me->getModel());
2249 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2250 ex.setDir(lastImageDir);
2251 ex.addFilter ("Taskjuggler (*.tjp)");
2252 if (ex.execDialog() )
2254 me->setExportMode(true);
2256 me->setExportMode(false);
2261 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2263 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2264 // TODO add preview in dialog
2265 //ImagePreview *p =new ImagePreview (fd);
2266 //fd->setContentsPreviewEnabled( TRUE );
2267 //fd->setContentsPreview( p, p );
2268 //fd->setPreviewMode( QFileDialog::Contents );
2269 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2270 fd->setDir (QDir().current());
2271 if (fd->foundConfig())
2275 if ( fd->exec() == QDialog::Accepted )
2277 QString fn=fd->selectedFile();
2278 if (!fn.contains (".odp"))
2281 //lastImageDir=fn.left(fn.findRev ("/"));
2282 if (currentMapEditor())
2283 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2287 QMessageBox::warning(0,
2289 tr("Couldn't find configuration for export to Open Office\n"));
2293 void Main::fileCloseMap()
2295 MapEditor *me = currentMapEditor();
2298 if (me->hasChanged())
2300 QMessageBox mb( vymName,
2301 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
2302 QMessageBox::Warning,
2303 QMessageBox::Yes | QMessageBox::Default,
2305 QMessageBox::Cancel | QMessageBox::Escape );
2306 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2307 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2310 case QMessageBox::Yes:
2312 fileSave(me, CompleteMap);
2314 case QMessageBox::No:
2315 // close without saving
2317 case QMessageBox::Cancel:
2323 tabWidget->removePage(me);
2324 if (tabWidget->count()==0)
2325 actionFilePrint->setEnabled (false);
2330 void Main::filePrint()
2332 if (currentMapEditor())
2333 currentMapEditor()->print();
2336 void Main::fileExitVYM()
2338 // Check if one or more editors have changed
2341 for (i=0;i<=tabWidget->count() -1;i++)
2344 me=(MapEditor*)tabWidget->page(i);
2346 // If something changed, ask what to do
2347 if (me->hasChanged())
2349 tabWidget->setCurrentPage(i);
2350 QMessageBox mb( vymName,
2351 tr("This map is not saved yet. Do you want to"),
2352 QMessageBox::Warning,
2353 QMessageBox::Yes | QMessageBox::Default,
2355 QMessageBox::Cancel | QMessageBox::Escape );
2356 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2357 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2360 mb.setActiveWindow();
2361 switch( mb.exec() ) {
2362 case QMessageBox::Yes:
2363 // save (the changed editors) and exit
2364 fileSave(currentMapEditor(), CompleteMap);
2366 case QMessageBox::No:
2367 // exit without saving
2369 case QMessageBox::Cancel:
2370 // don't save and don't exit
2374 } // loop over all MEs
2378 void Main::editUndo()
2380 if (currentMapEditor())
2381 currentMapEditor()->undo();
2384 void Main::editRedo()
2386 if (currentMapEditor())
2387 currentMapEditor()->redo();
2390 void Main::gotoHistoryStep (int i)
2392 if (currentMapEditor())
2393 currentMapEditor()->gotoHistoryStep (i);
2396 void Main::editCopy()
2398 if (currentMapEditor())
2399 currentMapEditor()->copy();
2402 void Main::editPaste()
2404 if (currentMapEditor())
2405 currentMapEditor()->paste();
2408 void Main::editCut()
2410 if (currentMapEditor())
2411 currentMapEditor()->cut();
2414 void Main::editOpenFindWindow()
2416 findWindow->popup();
2417 findWindow->raise();
2418 findWindow->setActiveWindow();
2421 void Main::editFind(QString s)
2424 BranchObj *bo=currentMapEditor()->findText(s, cs);
2427 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2430 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2431 tr("No matches found for \"%1\"").arg(s));
2435 void Main::editFindChanged()
2436 { // Notify editor, to abort the current find process
2437 currentMapEditor()->findReset();
2440 void Main::openTabs(QStringList urls)
2442 if (!urls.isEmpty())
2446 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2448 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2450 QString u=urls.takeFirst();
2451 procBrowser = new QProcess( this );
2453 procBrowser->start(browser,args);
2454 if ( !procBrowser->waitForStarted())
2456 // try to set path to browser
2457 QMessageBox::warning(0,
2459 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2460 tr("Please use Settings->")+tr("Set application to open an URL"));
2463 #if defined(Q_OS_WIN32)
2464 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2465 this->thread()->wait(3000);
2470 if (browser.contains("konqueror"))
2472 for (int i=0; i<urls.size(); i++)
2475 // Try to open new tab in existing konqueror started previously by vym
2476 p=new QProcess (this);
2478 #if defined(Q_OS_WIN32)
2479 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2480 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2481 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2482 "konqueror-mainwindow#1"<<
2486 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2487 "konqueror-mainwindow#1"<<
2491 p->start ("dcop",args);
2492 //cout << qPrintable (args.join(" "))<<endl;
2493 if ( !p->waitForStarted() ) success=false;
2496 QMessageBox::warning(0,
2498 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2500 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2502 for (int i=0; i<urls.size(); i++)
2504 // Try to open new tab in firefox
2505 p=new QProcess (this);
2506 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2507 p->start (browser,args);
2508 if ( !p->waitForStarted() ) success=false;
2511 QMessageBox::warning(0,
2513 tr("Couldn't start %1 to open a new tab").arg(browser));
2516 QMessageBox::warning(0,
2518 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2522 void Main::editOpenURL()
2525 if (currentMapEditor())
2527 QString url=currentMapEditor()->getURL();
2529 if (url=="") return;
2530 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2531 procBrowser = new QProcess( this );
2533 procBrowser->start(browser,args);
2534 if ( !procBrowser->waitForStarted())
2536 // try to set path to browser
2537 QMessageBox::warning(0,
2539 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2540 tr("Please use Settings->")+tr("Set application to open an URL"));
2545 void Main::editOpenURLTab()
2547 if (currentMapEditor())
2550 urls.append(currentMapEditor()->getURL());
2554 void Main::editOpenMultipleURLTabs()
2556 if (currentMapEditor())
2559 urls=currentMapEditor()->getURLs();
2565 void Main::editURL()
2567 if (currentMapEditor())
2568 currentMapEditor()->editURL();
2571 void Main::editLocalURL()
2573 if (currentMapEditor())
2574 currentMapEditor()->editLocalURL();
2577 void Main::editHeading2URL()
2579 if (currentMapEditor())
2580 currentMapEditor()->editHeading2URL();
2583 void Main::editBugzilla2URL()
2585 if (currentMapEditor())
2586 currentMapEditor()->editBugzilla2URL();
2589 void Main::editFATE2URL()
2591 if (currentMapEditor())
2592 currentMapEditor()->editFATE2URL();
2595 void Main::editHeadingFinished()
2597 // only called from editHeading(), so there is a currentME
2598 MapEditor *me=currentMapEditor();
2601 me->setStateEditHeading (false);
2602 QPoint p; //Not used here, only to find out pos of branch
2604 QString s=me->getHeading(ok,p);
2606 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2608 if (ok && s!=lineedit->text())
2609 me->setHeading(lineedit->text());
2611 lineedit->releaseKeyboard();
2615 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2616 !prevSelection.isEmpty())
2617 me->select(prevSelection);
2622 void Main::editHeading()
2624 if (currentMapEditor())
2626 MapEditor *me=currentMapEditor();
2627 QString oldSel=me->getSelectString();
2629 if (lineedit->isVisible())
2630 editHeadingFinished();
2635 QString s=me->getHeading(ok,p);
2639 me->setStateEditHeading (true);
2640 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2641 p=me->mapToGlobal (p);
2642 QDialog *d =new QDialog(NULL);
2643 QLineEdit *le=new QLineEdit (d);
2644 d->setWindowFlags (Qt::FramelessWindowHint);
2645 d->setGeometry(p.x(),p.y(),230,25);
2646 le->resize (d->width()-10,d->height());
2649 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2650 d->activateWindow();
2652 me->setHeading (le->text());
2655 editHeadingFinished();
2657 p=me->mapTo (this,p);
2658 lineedit->setGeometry(p.x(),p.y(),230,25);
2659 lineedit->setText(s);
2660 lineedit->setCursorPosition(1);
2661 lineedit->selectAll();
2663 lineedit->grabKeyboard();
2664 lineedit->setFocus();
2668 } // currentMapEditor()
2671 void Main::editAttributeFinished()
2673 // only called from editHeading(), so there is a currentME
2676 MapEditor *me=currentMapEditor();
2679 me->setStateEditHeading (false);
2680 QPoint p; //Not used here, only to find out pos of branch
2682 QString s=me->getHeading(ok,p);
2684 #if defined(Q_OS_MACX)
2686 if (ok && s!=lineedit->text())
2687 me->setHeading(lineedit->text());
2689 lineedit->releaseKeyboard();
2693 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2694 !prevSelection.isEmpty())
2695 me->select(prevSelection);
2701 #include "attribute.h"
2702 #include "attributedialog.h"
2703 void Main::editAttribute()
2705 MapEditor *me=currentMapEditor();
2708 BranchObj *bo=me->getSelectedBranch();
2711 AttributeDialog dia(this);
2712 dia.setTable (me->attributeTable() );
2714 dia.setMode (Definition);
2720 if (currentMapEditor())
2722 MapEditor *me=currentMapEditor();
2723 QString oldSel=me->getSelectString();
2725 if (lineedit->isVisible())
2726 editAttributeFinished();
2731 QString s=me->getHeading(ok,p);
2735 me->setStateEditHeading (true);
2736 #if defined(Q_OS_MACX)
2737 p=me->mapToGlobal (p);
2738 QDialog *d =new QDialog(NULL);
2739 QLineEdit *le=new QLineEdit (d);
2740 d->setWindowFlags (Qt::FramelessWindowHint);
2741 d->setGeometry(p.x(),p.y(),230,25);
2742 le->resize (d->width()-10,d->height());
2745 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2746 d->activateWindow();
2748 me->setHeading (le->text());
2751 editHeadingFinished();
2753 p=me->mapTo (this,p);
2754 lineedit->setGeometry(p.x(),p.y(),230,25);
2755 lineedit->setText(s);
2756 lineedit->setCursorPosition(1);
2757 lineedit->selectAll();
2759 lineedit->grabKeyboard();
2760 lineedit->setFocus();
2764 } // currentMapEditor()
2769 void Main::openVymLinks(const QStringList &vl)
2771 for (int j=0; j<vl.size(); j++)
2773 // compare path with already loaded maps
2777 for (i=0;i<=tabWidget->count() -1;i++)
2779 me=(MapEditor*)tabWidget->page(i);
2780 if (vl.at(j)==me->getFilePath() )
2789 if (!QFile(vl.at(j)).exists() )
2790 QMessageBox::critical( 0, tr( "Critical Error" ),
2791 tr("Couldn't open map %1").arg(vl.at(j)));
2794 fileLoad (vl.at(j), NewMap);
2795 tabWidget->setCurrentPage (tabWidget->count()-1);
2798 // Go to tab containing the map
2799 tabWidget->setCurrentPage (index);
2803 void Main::editOpenVymLink()
2805 if (currentMapEditor())
2808 vl.append(currentMapEditor()->getVymLink());
2813 void Main::editOpenMultipleVymLinks()
2815 QString currentVymLink;
2816 if (currentMapEditor())
2818 QStringList vl=currentMapEditor()->getVymLinks();
2823 void Main::editVymLink()
2825 if (currentMapEditor())
2826 currentMapEditor()->editVymLink();
2829 void Main::editDeleteVymLink()
2831 if (currentMapEditor())
2832 currentMapEditor()->deleteVymLink();
2835 void Main::editToggleHideExport()
2837 if (currentMapEditor())
2838 currentMapEditor()->toggleHideExport();
2841 void Main::editMapInfo()
2843 if (currentMapEditor())
2844 currentMapEditor()->editMapInfo();
2847 void Main::editMoveUp()
2849 if (currentMapEditor())
2850 currentMapEditor()->moveBranchUp();
2853 void Main::editMoveDown()
2855 if (currentMapEditor())
2856 currentMapEditor()->moveBranchDown();
2859 void Main::editSortChildren()
2861 if (currentMapEditor())
2862 currentMapEditor()->sortChildren();
2865 void Main::editToggleScroll()
2867 if (currentMapEditor())
2869 currentMapEditor()->toggleScroll();
2873 void Main::editUnscrollChilds()
2875 if (currentMapEditor())
2876 currentMapEditor()->unscrollChilds();
2879 void Main::editAddMapCenter()
2881 MapEditor *me=currentMapEditor();
2882 if (!lineedit->isVisible() && me)
2884 me->addMapCenter ();
2888 void Main::editNewBranch()
2890 MapEditor *me=currentMapEditor();
2891 if (!lineedit->isVisible() && me)
2893 BranchObj *bo=(BranchObj*)me->getSelection();
2894 BranchObj *newbo=me->addNewBranch(0);
2896 prevSelection=me->getModel()->getSelectString(bo);
2902 if (actionSettingsAutoEditNewBranch->isOn())
2907 if (!prevSelection.isEmpty())
2909 me->select(prevSelection);
2916 void Main::editNewBranchBefore()
2918 MapEditor *me=currentMapEditor();
2919 if (!lineedit->isVisible() && me)
2921 BranchObj *bo=(BranchObj*)me->getSelection();
2922 BranchObj *newbo=me->addNewBranchBefore();
2929 if (actionSettingsAutoEditNewBranch->isOn())
2931 if (!actionSettingsAutoSelectNewBranch->isOn())
2932 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2938 void Main::editNewBranchAbove()
2940 MapEditor *me=currentMapEditor();
2941 if (!lineedit->isVisible() && me)
2943 BranchObj *bo=(BranchObj*)me->getSelection();
2944 BranchObj *newbo=me->addNewBranch (-1);
2951 if (actionSettingsAutoEditNewBranch->isOn())
2953 if (!actionSettingsAutoSelectNewBranch->isOn())
2954 prevSelection=me->getModel()->getSelectString (bo); // TODO access directly
2960 void Main::editNewBranchBelow()
2962 MapEditor *me=currentMapEditor();
2963 if (!lineedit->isVisible() && me)
2965 BranchObj *bo=(BranchObj*)me->getSelection();
2966 BranchObj *newbo=me->addNewBranch (1);
2973 if (actionSettingsAutoEditNewBranch->isOn())
2975 if (!actionSettingsAutoSelectNewBranch->isOn())
2976 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2982 void Main::editImportAdd()
2984 fileLoad (ImportAdd);
2987 void Main::editImportReplace()
2989 fileLoad (ImportReplace);
2992 void Main::editSaveBranch()
2994 fileSaveAs (PartOfMap);
2997 void Main::editDeleteKeepChilds()
2999 if (currentMapEditor())
3000 currentMapEditor()->deleteKeepChilds();
3003 void Main::editDeleteChilds()
3005 if (currentMapEditor())
3006 currentMapEditor()->deleteChilds();
3009 void Main::editDeleteSelection()
3011 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3012 currentMapEditor()->deleteSelection();
3015 void Main::editUpperBranch()
3017 if (currentMapEditor())
3018 currentMapEditor()->selectUpperBranch();
3021 void Main::editLowerBranch()
3023 if (currentMapEditor())
3024 currentMapEditor()->selectLowerBranch();
3027 void Main::editLeftBranch()
3029 if (currentMapEditor())
3030 currentMapEditor()->selectLeftBranch();
3033 void Main::editRightBranch()
3035 if (currentMapEditor())
3036 currentMapEditor()->selectRightBranch();
3039 void Main::editFirstBranch()
3041 if (currentMapEditor())
3042 currentMapEditor()->selectFirstBranch();
3045 void Main::editLastBranch()
3047 if (currentMapEditor())
3048 currentMapEditor()->selectLastBranch();
3051 void Main::editLoadImage()
3053 if (currentMapEditor())
3054 currentMapEditor()->loadFloatImage();
3057 void Main::editSaveImage()
3059 if (currentMapEditor())
3060 currentMapEditor()->saveFloatImage();
3063 void Main::editFollowXLink(QAction *a)
3066 if (currentMapEditor())
3067 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3070 void Main::editEditXLink(QAction *a)
3072 if (currentMapEditor())
3073 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3076 void Main::formatSelectColor()
3078 if (currentMapEditor())
3080 QColor col = QColorDialog::getColor((currentColor ), this );
3081 if ( !col.isValid() ) return;
3082 colorChanged( col );
3086 void Main::formatPickColor()
3088 if (currentMapEditor())
3089 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3092 void Main::colorChanged(QColor c)
3094 QPixmap pix( 16, 16 );
3096 actionFormatColor->setIconSet( pix );
3100 void Main::formatColorBranch()
3102 if (currentMapEditor())
3103 currentMapEditor()->colorBranch(currentColor);
3106 void Main::formatColorSubtree()
3108 if (currentMapEditor())
3109 currentMapEditor()->colorSubtree (currentColor);
3112 void Main::formatLinkStyleLine()
3114 if (currentMapEditor())
3116 currentMapEditor()->setMapLinkStyle("StyleLine");
3117 actionFormatLinkStyleLine->setOn(true);
3121 void Main::formatLinkStyleParabel()
3123 if (currentMapEditor())
3125 currentMapEditor()->setMapLinkStyle("StyleParabel");
3126 actionFormatLinkStyleParabel->setOn(true);
3130 void Main::formatLinkStylePolyLine()
3132 if (currentMapEditor())
3134 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3135 actionFormatLinkStylePolyLine->setOn(true);
3139 void Main::formatLinkStylePolyParabel()
3141 if (currentMapEditor())
3143 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3144 actionFormatLinkStylePolyParabel->setOn(true);
3148 void Main::formatSelectBackColor()
3150 if (currentMapEditor())
3151 currentMapEditor()->selectMapBackgroundColor();
3154 void Main::formatSelectBackImage()
3156 if (currentMapEditor())
3157 currentMapEditor()->selectMapBackgroundImage();
3160 void Main::formatSelectLinkColor()
3162 if (currentMapEditor())
3163 currentMapEditor()->selectMapLinkColor();
3166 void Main::formatSelectSelectionColor()
3168 if (currentMapEditor())
3169 currentMapEditor()->selectMapSelectionColor();
3172 void Main::formatToggleLinkColorHint()
3174 currentMapEditor()->toggleMapLinkColorHint();
3178 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3180 if (currentMapEditor())
3181 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3184 void Main::viewZoomReset()
3186 if (currentMapEditor())
3190 currentMapEditor()->setMatrix( m );
3194 void Main::viewZoomIn()
3196 if (currentMapEditor())
3198 QMatrix m = currentMapEditor()->matrix();
3199 m.scale( 1.25, 1.25 );
3200 currentMapEditor()->setMatrix( m );
3204 void Main::viewZoomOut()
3206 if (currentMapEditor())
3208 QMatrix m = currentMapEditor()->matrix();
3209 m.scale( 0.8, 0.8 );
3210 currentMapEditor()->setMatrix( m );
3214 void Main::viewCenter()
3216 MapEditor *me=currentMapEditor();
3219 me->ensureSelectionVisible();
3223 void Main::networkStartServer()
3225 MapEditor *me=currentMapEditor();
3226 if (me) me->newServer();
3229 void Main::networkConnect()
3231 MapEditor *me=currentMapEditor();
3232 if (me) me->connectToServer();
3235 bool Main::settingsPDF()
3237 // Default browser is set in constructor
3239 QString text = QInputDialog::getText(
3240 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3241 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3243 settings.setValue ("/mainwindow/readerPDF",text);
3248 bool Main::settingsURL()
3250 // Default browser is set in constructor
3252 QString text = QInputDialog::getText(
3253 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3254 settings.value("/mainwindow/readerURL").toString()
3257 settings.setValue ("/mainwindow/readerURL",text);
3261 void Main::settingsMacroDir()
3263 QDir defdir(vymBaseDir.path() + "/macros");
3264 if (!defdir.exists())
3266 QDir dir=QFileDialog::getExistingDirectory (
3268 tr ("Directory with vym macros:"),
3269 settings.value ("/macros/macroDir",defdir.path()).toString()
3272 settings.setValue ("/macros/macroDir",dir.absolutePath());
3275 void Main::settingsUndoLevels()
3278 int i = QInputDialog::getInteger(
3280 tr("QInputDialog::getInteger()"),
3281 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3284 settings.setValue ("/mapeditor/stepsTotal",i);
3285 QMessageBox::information( this, tr( "VYM -Information:" ),
3286 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3290 void Main::settingsAutosaveToggle()
3292 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3295 void Main::settingsAutosaveTime()
3298 int i = QInputDialog::getInteger(
3300 tr("QInputDialog::getInteger()"),
3301 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3303 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3306 void Main::settingsWriteBackupFileToggle()
3308 settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3311 void Main::settingsToggleAnimation()
3313 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3316 void Main::settingsToggleDelKey()
3318 if (actionSettingsUseDelKey->isOn())
3320 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3323 actionEditDelete->setAccel (QKeySequence (""));
3327 void Main::windowToggleNoteEditor()
3329 if (textEditor->isVisible() )
3330 windowHideNoteEditor();
3332 windowShowNoteEditor();
3335 void Main::windowToggleHistory()
3337 if (historyWindow->isVisible())
3338 historyWindow->hide();
3340 historyWindow->show();
3344 void Main::windowToggleProperty()
3346 if (branchPropertyWindow->isVisible())
3347 branchPropertyWindow->hide();
3349 branchPropertyWindow->show();
3351 if(currentMapEditor())
3353 BranchObj *bo=currentMapEditor()->getSelectedBranch();
3356 branchPropertyWindow->setMapEditor(currentMapEditor());
3357 branchPropertyWindow->setBranch(bo);
3362 branchPropertyWindow->setBranch(NULL);
3365 void Main::windowToggleAntiAlias()
3367 bool b=actionViewToggleAntiAlias->isOn();
3369 for (int i=0;i<tabWidget->count();i++)
3372 me=(MapEditor*)tabWidget->page(i);
3373 me->setAntiAlias(b);
3378 void Main::windowToggleSmoothPixmap()
3380 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3382 for (int i=0;i<tabWidget->count();i++)
3385 me=(MapEditor*)tabWidget->page(i);
3386 me->setSmoothPixmap(b);
3390 void Main::updateHistory(SimpleSettings &undoSet)
3392 historyWindow->update (undoSet);
3395 void Main::updateNoteFlag()
3397 if (currentMapEditor())
3398 currentMapEditor()->updateNoteFlag();
3401 void Main::updateSatellites(MapEditor *me)
3403 branchPropertyWindow->setMapEditor (me);
3406 void Main::updateActions()
3408 MapEditor *me=currentMapEditor();
3411 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3413 // updateActions is also called when NoteEditor is closed
3414 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3415 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3416 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3418 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3419 actionFormatLinkColorHint->setOn(true);
3421 actionFormatLinkColorHint->setOn(false);
3423 switch (me->getMapLinkStyle())
3425 case LinkableMapObj::Line:
3426 actionFormatLinkStyleLine->setOn(true);
3428 case LinkableMapObj::Parabel:
3429 actionFormatLinkStyleParabel->setOn(true);
3431 case LinkableMapObj::PolyLine:
3432 actionFormatLinkStylePolyLine->setOn(true);
3434 case LinkableMapObj::PolyParabel:
3435 actionFormatLinkStylePolyParabel->setOn(true);
3442 QPixmap pix( 16, 16 );
3443 pix.fill( me->getMapBackgroundColor() );
3444 actionFormatBackColor->setIconSet( pix );
3445 pix.fill( me->getSelectionColor() );
3446 actionFormatSelectionColor->setIconSet( pix );
3447 pix.fill( me->getMapDefLinkColor() );
3448 actionFormatLinkColor->setIconSet( pix );
3451 actionFileSave->setEnabled( me->hasChanged() );
3452 if (me->isUndoAvailable())
3453 actionEditUndo->setEnabled( true);
3455 actionEditUndo->setEnabled( false);
3457 if (me->isRedoAvailable())
3458 actionEditRedo->setEnabled( true);
3460 actionEditRedo->setEnabled( false);
3462 LinkableMapObj *selection=me->getSelection();
3465 if ( (typeid(*selection) == typeid(BranchObj)) ||
3466 (typeid(*selection) == typeid(MapCenterObj)) )
3468 BranchObj *bo=(BranchObj*)selection;
3469 // Take care of links
3470 if (bo->countXLinks()==0)
3472 branchXLinksContextMenuEdit->clear();
3473 branchXLinksContextMenuFollow->clear();
3478 branchXLinksContextMenuEdit->clear();
3479 branchXLinksContextMenuFollow->clear();
3480 for (int i=0; i<=bo->countXLinks();i++)
3482 bot=bo->XLinkTargetAt(i);
3485 s=bot->getHeading();
3486 if (s.length()>xLinkMenuWidth)
3487 s=s.left(xLinkMenuWidth)+"...";
3488 branchXLinksContextMenuFollow->addAction (s);
3489 branchXLinksContextMenuEdit->addAction (s);
3494 standardFlagsDefault->setEnabled (true);
3496 actionEditToggleScroll->setEnabled (true);
3497 if ( bo->isScrolled() )
3498 actionEditToggleScroll->setOn(true);
3500 actionEditToggleScroll->setOn(false);
3502 if ( bo->getURL().isEmpty() )
3504 actionEditOpenURL->setEnabled (false);
3505 actionEditOpenURLTab->setEnabled (false);
3509 actionEditOpenURL->setEnabled (true);
3510 actionEditOpenURLTab->setEnabled (true);
3512 if ( bo->getVymLink().isEmpty() )
3514 actionEditOpenVymLink->setEnabled (false);
3515 actionEditDeleteVymLink->setEnabled (false);
3518 actionEditOpenVymLink->setEnabled (true);
3519 actionEditDeleteVymLink->setEnabled (true);
3522 if (bo->canMoveBranchUp())
3523 actionEditMoveUp->setEnabled (true);
3525 actionEditMoveUp->setEnabled (false);
3526 if (bo->canMoveBranchDown())
3527 actionEditMoveDown->setEnabled (true);
3529 actionEditMoveDown->setEnabled (false);
3532 actionEditToggleHideExport->setEnabled (true);
3533 actionEditToggleHideExport->setOn (bo->hideInExport() );
3535 actionEditCopy->setEnabled (true);
3536 actionEditCut->setEnabled (true);
3537 if (!clipboardEmpty)
3538 actionEditPaste->setEnabled (true);
3540 actionEditPaste->setEnabled (false);
3541 for (int i=0; i<actionListBranches.size(); ++i)
3542 actionListBranches.at(i)->setEnabled(true);
3543 actionEditDelete->setEnabled (true);
3544 actionFormatHideLinkUnselected->setOn
3545 (selection->getHideLinkUnselected());
3547 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3549 FloatObj *fo=(FloatImageObj*)selection;
3551 actionEditOpenURL->setEnabled (false);
3552 actionEditOpenVymLink->setEnabled (false);
3553 actionEditDeleteVymLink->setEnabled (false);
3554 actionEditToggleHideExport->setEnabled (true);
3555 actionEditToggleHideExport->setOn (fo->hideInExport() );
3558 actionEditCopy->setEnabled (true);
3559 actionEditCut->setEnabled (true);
3560 actionEditPaste->setEnabled (false);
3561 for (int i=0; i<actionListBranches.size(); ++i)
3562 actionListBranches.at(i)->setEnabled(false);
3563 actionEditDelete->setEnabled (true);
3564 actionFormatHideLinkUnselected->setOn
3565 ( selection->getHideLinkUnselected());
3566 actionEditMoveUp->setEnabled (false);
3567 actionEditMoveDown->setEnabled (false);
3572 actionEditCopy->setEnabled (false);
3573 actionEditCut->setEnabled (false);
3574 actionEditPaste->setEnabled (false);
3575 for (int i=0; i<actionListBranches.size(); ++i)
3576 actionListBranches.at(i)->setEnabled(false);
3578 actionEditToggleScroll->setEnabled (false);
3579 actionEditOpenURL->setEnabled (false);
3580 actionEditOpenVymLink->setEnabled (false);
3581 actionEditDeleteVymLink->setEnabled (false);
3582 actionEditHeading2URL->setEnabled (false);
3583 actionEditDelete->setEnabled (false);
3584 actionEditMoveUp->setEnabled (false);
3585 actionEditMoveDown->setEnabled (false);
3586 actionEditToggleHideExport->setEnabled (false);
3590 Main::ModMode Main::getModMode()
3592 if (actionModModeColor->isOn()) return ModModeColor;
3593 if (actionModModeCopy->isOn()) return ModModeCopy;
3594 if (actionModModeXLink->isOn()) return ModModeXLink;
3598 bool Main::autoEditNewBranch()
3600 return actionSettingsAutoEditNewBranch->isOn();
3603 bool Main::autoSelectNewBranch()
3605 return actionSettingsAutoSelectNewBranch->isOn();
3608 bool Main::useFlagGroups()
3610 return actionSettingsUseFlagGroups->isOn();
3613 void Main::windowShowNoteEditor()
3615 textEditor->setShowWithMain(true);
3617 actionViewToggleNoteEditor->setOn (true);
3620 void Main::windowHideNoteEditor()
3622 textEditor->setShowWithMain(false);
3624 actionViewToggleNoteEditor->setOn (false);
3627 void Main::setScript (const QString &script)
3629 scriptEditor->setScript (script);
3632 void Main::runScript (const QString &script)
3634 if (currentMapEditor())
3635 currentMapEditor()->runScript (script);
3638 void Main::runScriptEverywhere (const QString &script)
3641 for (int i=0;i<=tabWidget->count() -1;i++)
3643 me=(MapEditor*)tabWidget->page(i);
3644 if (me) me->runScript (script);
3648 void Main::windowNextEditor()
3650 if (tabWidget->currentPageIndex() < tabWidget->count())
3651 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3654 void Main::windowPreviousEditor()
3656 if (tabWidget->currentPageIndex() >0)
3657 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3660 void Main::standardFlagChanged()
3662 if (currentMapEditor())
3663 currentMapEditor()->toggleStandardFlag(sender()->name());
3666 void Main::testFunction1()
3668 if (!currentMapEditor()) return;
3669 currentMapEditor()->testFunction1();
3673 void Main::testFunction2()
3675 if (!currentMapEditor()) return;
3676 currentMapEditor()->testFunction2();
3679 void Main::testCommand()
3681 if (!currentMapEditor()) return;
3682 scriptEditor->show();
3685 QString com = QInputDialog::getText(
3686 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3687 if (ok) currentMapEditor()->parseAtom(com);
3691 void Main::helpDoc()
3693 QString locale = QLocale::system().name();
3695 if (locale.left(2)=="es")
3696 docname="vym_es.pdf";
3700 QStringList searchList;
3702 #if defined(Q_OS_MACX)
3703 searchList << "./vym.app/Contents/Resources/doc";
3704 #elif defined(Q_OS_WIN32)
3705 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3707 #if defined(VYM_DOCDIR)
3708 searchList << VYM_DOCDIR;
3710 // default path in SUSE LINUX
3711 searchList << "/usr/share/doc/packages/vym";
3714 searchList << "doc"; // relative path for easy testing in tarball
3715 searchList << "doc/tex"; // Easy testing working on vym.tex
3716 searchList << "/usr/share/doc/vym"; // Debian
3717 searchList << "/usr/share/doc/packages";// Knoppix
3721 for (int i=0; i<searchList.count(); ++i)
3723 docfile.setFileName(searchList.at(i)+"/"+docname);
3724 if (docfile.exists())
3733 QMessageBox::critical(0,
3734 tr("Critcal error"),
3735 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3740 Process *pdfProc = new Process();
3741 args << QDir::toNativeSeparators(docfile.fileName());
3743 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3744 if ( !pdfProc->waitForStarted() )
3747 QMessageBox::warning(0,
3749 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3750 tr("Please use Settings->")+tr("Set application to open PDF files"));
3757 void Main::helpDemo()
3759 QStringList filters;
3760 filters <<"VYM example map (*.vym)";
3761 QFileDialog *fd=new QFileDialog( this);
3762 #if defined(Q_OS_MACX)
3763 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3765 // default path in SUSE LINUX
3766 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3769 fd->setFileMode (QFileDialog::ExistingFiles);
3770 fd->setFilters (filters);
3771 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3775 if ( fd->exec() == QDialog::Accepted )
3777 lastFileDir=fd->directory().path();
3778 QStringList flist = fd->selectedFiles();
3779 QStringList::Iterator it = flist.begin();
3780 while( it != flist.end() )
3783 fileLoad(*it, NewMap);
3791 void Main::helpAbout()
3794 ad.setName ("aboutwindow");
3795 ad.setMinimumSize(500,500);
3796 ad.resize (QSize (500,500));
3800 void Main::helpAboutQT()
3802 QMessageBox::aboutQt( this, "Qt Application Example" );
3805 void Main::callMacro ()
3807 QAction *action = qobject_cast<QAction *>(sender());
3811 i=action->data().toInt();
3812 QString mDir (settings.value ("macros/macroDir").toString() );
3814 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3816 if ( !f.open( QIODevice::ReadOnly ) )
3818 QMessageBox::warning(0,
3820 tr("Couldn't find a macro at %1.\n").arg(fn)+
3821 tr("Please use Settings->")+tr("Set directory for vym macros"));
3825 QTextStream ts( &f );
3826 QString m= ts.read();
3830 //cout <<"Main::callMacro m="<<qPrintable (m)<<endl;
3831 currentMapEditor()->runScript (m);
3838 //////////////////////////////////
3840 @@ -2544,18 +2576,27 @@
3841 // Try to open new tab in existing konqueror started previously by vym
3842 p=new QProcess (this);
3844 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3845 - "konqueror-mainwindow#1"<<
3847 +#if defined(Q_OS_WIN32)
3848 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3849 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3850 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3851 + "konqueror-mainwindow#1"<<
3855 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3856 + "konqueror-mainwindow#1"<<
3860 p->start ("dcop",args);
3861 if ( !p->waitForStarted() ) success=false;