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 setObjectName ("MainWindow");
84 setCaption ("VYM - View Your Mind");
86 // Load window settings
87 #if defined(Q_OS_WIN32)
88 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
90 setWindowState(Qt::WindowMaximized);
95 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
96 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
99 // Sometimes we may need to remember old selections
103 currentColor=Qt::black;
105 // Create unique temporary directory
107 tmpVymDir=makeTmpDir (ok,"vym");
110 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
113 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
115 // Create direcctory for clipboard
116 clipboardDir=tmpVymDir+"/clipboard";
117 clipboardFile="map.xml";
118 QDir d(clipboardDir);
119 d.mkdir (clipboardDir,true);
120 makeSubDirs (clipboardDir);
125 // Satellite windows //////////////////////////////////////////
128 historyWindow=new HistoryWindow();
129 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
132 branchPropertyWindow = new BranchPropertyWindow();
133 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
135 // Connect TextEditor, so that we can update flags if text changes
136 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
137 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
139 // Connect HistoryWindow, so that we can update flags
140 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
143 // Initialize script editor
144 scriptEditor = new SimpleScriptEditor();
145 scriptEditor->move (50,50);
147 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
148 this, SLOT( runScript( QString ) ) );
151 // Initialize Find window
152 findWindow=new FindWindow(NULL);
153 findWindow->move (x(),y()+70);
154 connect (findWindow, SIGNAL( findButton(QString) ),
155 this, SLOT(editFind(QString) ) );
156 connect (findWindow, SIGNAL( somethingChanged() ),
157 this, SLOT(editFindChanged() ) );
159 // Initialize some settings, which are platform dependant
162 // application to open URLs
163 p="/mainwindow/readerURL";
164 #if defined(Q_OS_LINUX)
165 s=settings.value (p,"xdg-open").toString();
167 #if defined(Q_OS_MACX)
168 s=settings.value (p,"/usr/bin/open").toString();
171 #if defined(Q_OS_WIN32)
172 // Assume that system has been set up so that
173 // Explorer automagically opens up the URL
174 // in the user's preferred browser.
175 s=settings.value (p,"explorer").toString();
177 s=settings.value (p,"mozilla").toString();
181 settings.setValue( p,s);
183 // application to open PDFs
184 p="/mainwindow/readerPDF";
185 #if defined(Q_OS_LINUX)
186 s=settings.value (p,"xdg-open").toString();
188 #if defined(Q_OS_MACX)
189 s=settings.value (p,"/usr/bin/open").toString();
190 #elif defined(Q_OS_WIN32)
191 s=settings.value (p,"acrord32").toString();
193 s=settings.value (p,"acroread").toString();
196 settings.setValue( p,s);
198 // width of xLinksMenu
201 // Create tab widget which holds the maps
202 tabWidget= new QTabWidget (this);
203 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
204 this, SLOT( editorChanged( QWidget * ) ) );
206 lineedit=new QLineEdit (this);
209 setCentralWidget(tabWidget);
213 setupFormatActions();
217 setupNetworkActions();
218 setupSettingsActions();
221 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
226 restoreState (settings.value("/mainwindow/state",0).toByteArray());
234 #if defined(Q_OS_WIN32)
235 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
237 settings.setValue ("/mainwindow/geometry/size", size());
238 settings.setValue ("/mainwindow/geometry/pos", pos());
239 settings.setValue ("/mainwindow/state",saveState(0));
241 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
242 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
243 settings.setValue( "/version/version", vymVersion );
244 settings.setValue( "/version/builddate", vymBuildDate );
246 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
247 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
248 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
249 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
250 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
251 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
252 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
253 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
255 //TODO save scriptEditor settings
257 // call the destructors
259 delete historyWindow;
260 delete branchPropertyWindow;
262 // Remove temporary directory
263 removeDir (QDir(tmpVymDir));
266 void Main::loadCmdLine()
268 /* TODO draw some kind of splashscreen while loading...
274 QStringList flist=options.getFileList();
275 QStringList::Iterator it=flist.begin();
277 while (it !=flist.end() )
279 fileLoad (*it, NewMap);
285 void Main::statusMessage(const QString &s)
287 statusBar()->message( s);
290 void Main::closeEvent (QCloseEvent* )
296 void Main::setupFileActions()
298 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
299 QToolBar *tb = addToolBar( tr ("&Map") );
300 tb->setObjectName ("mapTB");
303 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
304 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
305 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
307 fileMenu->addAction (a);
308 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
310 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
311 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
312 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
313 fileMenu->addAction (a);
314 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
317 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
318 a->setStatusTip (tr( "Open","Status tip File menu" ) );
319 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
321 fileMenu->addAction (a);
322 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
324 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
325 fileMenu->addSeparator();
327 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
328 a->setStatusTip ( tr( "Save","Status tip file menu" ));
329 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
331 fileMenu->addAction (a);
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
335 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
336 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
337 fileMenu->addAction (a);
338 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
340 fileMenu->addSeparator();
342 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
344 a = new QAction(tr("KDE Bookmarks"), this);
345 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
346 a->addTo (fileImportMenu);
347 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
349 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
351 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
352 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
353 a->addTo (fileImportMenu);
354 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
357 a = new QAction("Freemind...",this);
358 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
359 fileImportMenu->addAction (a);
360 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
362 a = new QAction("Mind Manager...",this);
363 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
364 fileImportMenu->addAction (a);
365 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
367 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
368 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
369 fileImportMenu->addAction (a);
370 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
372 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
374 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
375 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
376 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
377 fileExportMenu->addAction (a);
379 a = new QAction( "Open Office...", this);
380 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
381 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
382 fileExportMenu->addAction (a);
384 a = new QAction( "Webpage (XHTML)...",this );
385 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
386 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
387 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
388 fileExportMenu->addAction (a);
390 a = new QAction( "Text (ASCII)...", this);
391 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
393 fileExportMenu->addAction (a);
395 a = new QAction( "Spreadsheet (CSV)...", this);
396 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
397 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
398 fileExportMenu->addAction (a);
400 a = new QAction( tr("KDE Bookmarks","File menu"), this);
401 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
402 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
403 fileExportMenu->addAction (a);
405 a = new QAction( "Taskjuggler...", this );
406 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
407 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
408 fileExportMenu->addAction (a);
410 a = new QAction( "LaTeX...", this);
411 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
412 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
413 fileExportMenu->addAction (a);
415 a = new QAction( "XML..." , this );
416 a->setStatusTip (tr( "Export as %1").arg("XML"));
417 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
418 fileExportMenu->addAction (a);
420 fileMenu->addSeparator();
422 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
423 a->setStatusTip ( tr( "Print" ,"File menu") );
424 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
426 fileMenu->addAction (a);
427 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
430 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
431 a->setStatusTip (tr( "Close Map" ) );
432 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
433 fileMenu->addAction (a);
434 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
436 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
437 a->setStatusTip ( tr( "Exit")+" "+vymName );
438 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
439 fileMenu->addAction (a);
440 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
445 void Main::setupEditActions()
447 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
448 tb->setLabel( "Edit Actions" );
449 tb->setObjectName ("actionsTB");
450 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
454 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
455 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
456 a->setStatusTip (tr( "Undo" ) );
457 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
458 a->setEnabled (false);
460 editMenu->addAction (a);
463 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
464 a->setStatusTip (tr( "Redo" ));
465 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
467 editMenu->addAction (a);
468 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
471 editMenu->addSeparator();
472 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
473 a->setStatusTip ( tr( "Copy" ) );
474 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
475 a->setEnabled (false);
477 editMenu->addAction (a);
478 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
481 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
482 a->setStatusTip ( tr( "Cut" ) );
483 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
484 a->setEnabled (false);
486 editMenu->addAction (a);
488 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
490 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
491 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
492 a->setStatusTip ( tr( "Paste" ) );
493 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
494 a->setEnabled (false);
496 editMenu->addAction (a);
499 // Shortcuts to modify heading:
500 a = new QAction(tr( "Edit heading","Edit menu" ),this);
501 a->setStatusTip ( tr( "edit Heading" ));
502 a->setShortcut ( Qt::Key_Enter); //Edit heading
503 // a->setShortcutContext (Qt::WindowShortcut);
505 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
506 actionListBranches.append(a);
507 a = new QAction( tr( "Edit heading","Edit menu" ), this);
508 a->setStatusTip (tr( "edit Heading" ));
509 a->setShortcut (Qt::Key_Return ); //Edit heading
510 //a->setShortcutContext (Qt::WindowShortcut);
512 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
513 actionListBranches.append(a);
514 editMenu->addAction (a);
516 a = new QAction( tr( "Edit heading","Edit menu" ), this);
517 a->setStatusTip (tr( "edit Heading" ));
518 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
519 a->setShortcutContext (Qt::WindowShortcut);
521 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
522 actionListBranches.append(a);
524 // Shortcut to delete selection
525 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
526 a->setStatusTip (tr( "Delete Selection" ));
527 a->setShortcut ( Qt::Key_Delete); //Delete selection
528 a->setShortcutContext (Qt::WindowShortcut);
530 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
533 // Shortcut to add mapcenter
534 a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
535 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
536 actionEditAddMapCenter = a;
539 // Shortcut to add branch
540 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
541 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
542 alt->setShortcut (Qt::Key_A); //Add branch
543 alt->setShortcutContext (Qt::WindowShortcut);
545 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
546 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
547 a->setStatusTip ( tr( "Add a branch as child of selection" ));
548 a->setShortcut (Qt::Key_Insert); //Add branch
549 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
550 actionListBranches.append(a);
551 #if defined (Q_OS_MACX)
552 // In OSX show different shortcut in menues, the keys work indepently always
553 actionEditAddBranch=alt;
555 actionEditAddBranch=a;
557 editMenu->addAction (actionEditAddBranch);
558 tb->addAction (actionEditAddBranch);
561 // Add branch by inserting it at selection
562 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
563 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
564 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
565 a->setShortcutContext (Qt::WindowShortcut);
567 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
568 a->setEnabled (false);
569 actionListBranches.append(a);
570 actionEditAddBranchBefore=a;
571 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
572 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
573 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
574 a->setShortcutContext (Qt::WindowShortcut);
576 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
577 actionListBranches.append(a);
580 a = new QAction(tr( "Add branch above","Edit menu" ), this);
581 a->setStatusTip ( tr( "Add a branch above selection" ));
582 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
583 a->setShortcutContext (Qt::WindowShortcut);
585 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
586 a->setEnabled (false);
587 actionListBranches.append(a);
588 actionEditAddBranchAbove=a;
589 a = new QAction(tr( "Add branch above","Edit menu" ), this);
590 a->setStatusTip ( tr( "Add a branch above selection" ));
591 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
592 a->setShortcutContext (Qt::WindowShortcut);
594 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
595 actionListBranches.append(a);
598 a = new QAction(tr( "Add branch below","Edit menu" ), this);
599 a->setStatusTip ( tr( "Add a branch below selection" ));
600 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
601 a->setShortcutContext (Qt::WindowShortcut);
603 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
604 a->setEnabled (false);
605 actionListBranches.append(a);
606 actionEditAddBranchBelow=a;
607 a = new QAction(tr( "Add branch below","Edit menu" ), this);
608 a->setStatusTip ( tr( "Add a branch below selection" ));
609 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
610 a->setShortcutContext (Qt::WindowShortcut);
612 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
613 actionListBranches.append(a);
615 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
616 a->setStatusTip ( tr( "Move branch up" ) );
617 a->setShortcut (Qt::Key_PageUp ); // Move branch up
618 a->setEnabled (false);
620 editMenu->addAction (a);
621 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
624 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
625 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
626 a->setStatusTip (tr( "Move branch down" ) );
627 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
628 a->setEnabled (false);
630 editMenu->addAction (a);
631 actionEditMoveDown=a;
633 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
634 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
635 a->setEnabled (true);
637 editMenu->addAction (a);
638 actionEditSortChildren=a;
640 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
641 a->setShortcut ( Qt::Key_ScrollLock );
642 a->setStatusTip (tr( "Scroll branch" ) );
643 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
645 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
646 alt->setShortcut ( Qt::Key_S ); // Scroll branch
647 alt->setStatusTip (tr( "Scroll branch" ));
648 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
649 #if defined(Q_OS_MACX)
650 actionEditToggleScroll=alt;
652 actionEditToggleScroll=a;
654 actionEditToggleScroll->setEnabled (false);
655 actionEditToggleScroll->setToggleAction(true);
656 tb->addAction (actionEditToggleScroll);
657 editMenu->addAction ( actionEditToggleScroll);
658 editMenu->addAction (actionEditToggleScroll);
661 actionListBranches.append(actionEditToggleScroll);
663 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
664 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
665 editMenu->addAction (a);
666 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
668 editMenu->addSeparator();
670 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
671 a->setStatusTip (tr( "Find" ) );
672 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
673 editMenu->addAction (a);
674 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
676 editMenu->addSeparator();
678 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
679 a->setShortcut (Qt::CTRL + Qt::Key_U );
680 a->setShortcut (tr( "Open URL" ));
683 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
686 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
687 a->setStatusTip (tr( "Open URL in new tab" ));
688 //a->setShortcut (Qt::CTRL+Qt::Key_U );
690 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
691 actionEditOpenURLTab=a;
693 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
694 a->setStatusTip (tr( "Open all URLs in subtree" ));
696 actionListBranches.append(a);
697 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
698 actionEditOpenMultipleURLTabs=a;
700 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
701 a->setStatusTip ( tr( "Edit URL" ) );
702 a->setShortcut ( Qt::Key_U );
703 a->setShortcutContext (Qt::WindowShortcut);
704 actionListBranches.append(a);
706 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
709 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
710 a->setStatusTip ( tr( "Edit local URL" ) );
711 a->setShortcut (Qt::SHIFT + Qt::Key_U );
712 a->setShortcutContext (Qt::WindowShortcut);
713 actionListBranches.append(a);
715 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
716 actionEditLocalURL=a;
718 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
719 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
720 a->setEnabled (false);
721 actionListBranches.append(a);
722 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
723 actionEditHeading2URL=a;
725 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
726 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
727 a->setEnabled (false);
728 actionListBranches.append(a);
729 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
730 actionEditBugzilla2URL=a;
732 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
733 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
734 a->setEnabled (false);
735 actionListBranches.append(a);
736 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
737 actionEditFATE2URL=a;
739 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
740 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
742 a->setEnabled (false);
743 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
744 actionEditOpenVymLink=a;
746 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
747 a->setStatusTip ( tr( "Open all vym links in subtree" ));
748 a->setEnabled (false);
749 actionListBranches.append(a);
750 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
751 actionEditOpenMultipleVymLinks=a;
754 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
755 a->setEnabled (false);
756 a->setStatusTip ( tr( "Edit link to another vym map" ));
757 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
758 actionListBranches.append(a);
761 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
762 a->setStatusTip ( tr( "Delete link to another vym map" ));
763 a->setEnabled (false);
764 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
765 actionEditDeleteVymLink=a;
767 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
768 a->setStatusTip ( tr( "Hide object in exports" ) );
769 a->setShortcut (Qt::Key_H );
770 a->setToggleAction(true);
772 a->setEnabled (false);
773 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
774 actionEditToggleHideExport=a;
776 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
777 a->setStatusTip ( tr( "Edit Map Info" ));
778 a->setEnabled (true);
779 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
782 // Import at selection (adding to selection)
783 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
784 a->setStatusTip (tr( "Add map at selection" ));
785 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
786 a->setEnabled (false);
787 actionListBranches.append(a);
788 actionEditImportAdd=a;
790 // Import at selection (replacing selection)
791 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
792 a->setStatusTip (tr( "Replace selection with map" ));
793 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
794 a->setEnabled (false);
795 actionListBranches.append(a);
796 actionEditImportReplace=a;
799 a = new QAction( tr( "Save selection","Edit menu" ), this);
800 a->setStatusTip (tr( "Save selection" ));
801 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
802 a->setEnabled (false);
803 actionListBranches.append(a);
804 actionEditSaveBranch=a;
806 // Only remove branch, not its childs
807 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
808 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
809 a->setShortcut (Qt::ALT + Qt::Key_Delete );
810 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
811 a->setEnabled (false);
813 actionListBranches.append(a);
814 actionEditDeleteKeepChilds=a;
816 // Only remove childs of a branch
817 a = new QAction( tr( "Remove childs","Edit menu" ), this);
818 a->setStatusTip (tr( "Remove childs of branch" ));
819 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
820 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
821 a->setEnabled (false);
822 actionListBranches.append(a);
823 actionEditDeleteChilds=a;
825 // Shortcuts for navigating with cursor:
826 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
827 a->setStatusTip ( tr( "Select upper branch" ));
828 a->setShortcut (Qt::Key_Up );
829 a->setShortcutContext (Qt::WindowShortcut);
831 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
832 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
833 a->setStatusTip (tr( "Select lower branch" ));
834 a->setShortcut ( Qt::Key_Down );
835 a->setShortcutContext (Qt::WindowShortcut);
837 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
838 a = new QAction(tr( "Select left branch","Edit menu" ), this);
839 a->setStatusTip ( tr( "Select left branch" ));
840 a->setShortcut (Qt::Key_Left );
841 a->setShortcutContext (Qt::WindowShortcut);
843 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
844 a = new QAction( tr( "Select child branch","Edit menu" ), this);
845 a->setStatusTip (tr( "Select right branch" ));
846 a->setShortcut (Qt::Key_Right);
847 a->setShortcutContext (Qt::WindowShortcut);
849 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
850 a = new QAction( tr( "Select first branch","Edit menu" ), this);
851 a->setStatusTip (tr( "Select first branch" ));
852 a->setShortcut (Qt::Key_Home );
853 a->setShortcutContext (Qt::WindowShortcut);
855 a->setEnabled (false);
856 editMenu->addAction (a);
857 actionListBranches.append(a);
858 actionEditSelectFirst=a;
859 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
860 a = new QAction( tr( "Select last branch","Edit menu" ),this);
861 a->setStatusTip (tr( "Select last branch" ));
862 a->setShortcut ( Qt::Key_End );
863 a->setShortcutContext (Qt::WindowShortcut);
865 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
866 a->setEnabled (false);
867 editMenu->addAction (a);
868 actionListBranches.append(a);
869 actionEditSelectLast=a;
871 a = new QAction( tr( "Add Image...","Edit menu" ), this);
872 a->setStatusTip (tr( "Add Image" ));
873 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
874 actionEditLoadImage=a;
876 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
877 a->setStatusTip (tr( "Set properties for selection" ));
878 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
879 a->setShortcutContext (Qt::WindowShortcut);
880 a->setToggleAction (true);
882 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
883 actionViewTogglePropertyWindow=a;
887 void Main::setupFormatActions()
889 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
891 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
892 tb->setObjectName ("formatTB");
895 pix.fill (Qt::black);
896 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
897 a->setStatusTip ( tr( "Set Color" ));
898 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
900 formatMenu->addAction (a);
902 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
903 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
904 a->setShortcut (Qt::CTRL + Qt::Key_K );
905 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
906 a->setEnabled (false);
908 formatMenu->addAction (a);
909 actionListBranches.append(a);
910 actionFormatPickColor=a;
912 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
913 a->setStatusTip ( tr( "Color branch" ) );
914 a->setShortcut (Qt::CTRL + Qt::Key_B);
915 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
916 a->setEnabled (false);
918 formatMenu->addAction (a);
919 actionListBranches.append(a);
920 actionFormatColorSubtree=a;
922 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
923 a->setStatusTip ( tr( "Color Subtree" ));
924 a->setShortcut (Qt::CTRL + Qt::Key_T);
925 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
926 a->setEnabled (false);
927 formatMenu->addAction (a);
929 actionListBranches.append(a);
930 actionFormatColorSubtree=a;
932 formatMenu->addSeparator();
933 actionGroupFormatLinkStyles=new QActionGroup ( this);
934 actionGroupFormatLinkStyles->setExclusive (true);
935 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
936 a->setStatusTip (tr( "Line" ));
937 a->setToggleAction(true);
938 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
939 formatMenu->addAction (a);
940 actionFormatLinkStyleLine=a;
941 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
942 a->setStatusTip (tr( "Line" ));
943 a->setToggleAction(true);
944 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
945 formatMenu->addAction (a);
946 actionFormatLinkStyleParabel=a;
947 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
948 a->setStatusTip (tr( "PolyLine" ));
949 a->setToggleAction(true);
950 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
951 formatMenu->addAction (a);
952 actionFormatLinkStylePolyLine=a;
953 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
954 a->setStatusTip (tr( "PolyParabel" ) );
955 a->setToggleAction(true);
956 a->setChecked (true);
957 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
958 formatMenu->addAction (a);
959 actionFormatLinkStylePolyParabel=a;
961 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
962 a->setStatusTip (tr( "Hide link" ));
963 a->setToggleAction(true);
964 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
965 actionFormatHideLinkUnselected=a;
967 formatMenu->addSeparator();
968 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
969 a->setStatusTip (tr( "Use same color for links and headings" ));
970 a->setToggleAction(true);
971 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
972 formatMenu->addAction (a);
973 actionFormatLinkColorHint=a;
975 pix.fill (Qt::white);
976 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
977 a->setStatusTip (tr( "Set Link Color" ));
978 formatMenu->addAction (a);
979 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
980 actionFormatLinkColor=a;
982 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
983 a->setStatusTip (tr( "Set Selection Color" ));
984 formatMenu->addAction (a);
985 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
986 actionFormatSelectionColor=a;
988 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
989 a->setStatusTip (tr( "Set Background Color" ));
990 formatMenu->addAction (a);
991 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
992 actionFormatBackColor=a;
994 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
995 a->setStatusTip (tr( "Set Background image" ));
996 formatMenu->addAction (a);
997 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
998 actionFormatBackImage=a;
1002 void Main::setupViewActions()
1004 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1005 tb->setLabel( "View Actions" );
1006 tb->setObjectName ("viewTB");
1007 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1010 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1011 a->setStatusTip ( tr( "Zoom reset" ) );
1012 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1014 viewMenu->addAction (a);
1015 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1017 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1018 a->setStatusTip (tr( "Zoom in" ));
1019 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1021 viewMenu->addAction (a);
1022 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1024 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1025 a->setStatusTip (tr( "Zoom out" ));
1026 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1028 viewMenu->addAction (a);
1029 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1031 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1032 a->setStatusTip (tr( "Show selection" ));
1033 a->setShortcut (Qt::Key_Period);
1035 viewMenu->addAction (a);
1036 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1038 viewMenu->addSeparator();
1040 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1041 a->setStatusTip ( tr( "Show Note Editor" ));
1042 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1043 a->setToggleAction(true);
1045 viewMenu->addAction (a);
1046 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1047 actionViewToggleNoteEditor=a;
1049 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1050 a->setStatusTip ( tr( "Show History Window" ));
1051 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1052 a->setToggleAction(true);
1054 viewMenu->addAction (a);
1055 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1056 actionViewToggleHistoryWindow=a;
1058 viewMenu->addAction (actionViewTogglePropertyWindow);
1060 viewMenu->addSeparator();
1062 a = new QAction(tr( "Antialiasing","View action" ),this );
1063 a->setStatusTip ( tr( "Antialiasing" ));
1064 a->setToggleAction(true);
1065 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1066 viewMenu->addAction (a);
1067 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1068 actionViewToggleAntiAlias=a;
1070 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1071 a->setStatusTip (a->text());
1072 a->setToggleAction(true);
1073 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1074 viewMenu->addAction (a);
1075 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1076 actionViewToggleSmoothPixmapTransform=a;
1078 a = new QAction(tr( "Next Map","View action" ), this);
1079 a->setStatusTip (a->text());
1080 a->setShortcut (Qt::ALT + Qt::Key_N );
1081 viewMenu->addAction (a);
1082 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1084 a = new QAction (tr( "Previous Map","View action" ), this );
1085 a->setStatusTip (a->text());
1086 a->setShortcut (Qt::ALT + Qt::Key_P );
1087 viewMenu->addAction (a);
1088 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1092 void Main::setupModeActions()
1094 //QPopupMenu *menu = new QPopupMenu( this );
1095 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1097 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1098 tb->setObjectName ("modesTB");
1100 actionGroupModModes=new QActionGroup ( this);
1101 actionGroupModModes->setExclusive (true);
1102 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1103 a->setShortcut (Qt::Key_J);
1104 a->setStatusTip ( tr( "Use modifier to color branches" ));
1105 a->setToggleAction(true);
1108 actionModModeColor=a;
1110 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1111 a->setShortcut( Qt::Key_K);
1112 a->setStatusTip( tr( "Use modifier to copy" ));
1113 a->setToggleAction(true);
1115 actionModModeCopy=a;
1117 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1118 a->setShortcut (Qt::Key_L);
1119 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1120 a->setToggleAction(true);
1122 actionModModeXLink=a;
1126 void Main::setupFlagActions()
1128 // Create System Flags
1132 systemFlagsDefault = new FlagRowObj ();
1133 systemFlagsDefault->setVisibility (false);
1134 systemFlagsDefault->setName ("systemFlagsDef");
1136 FlagObj *fo = new FlagObj ();
1137 fo->load(QPixmap(flagsPath+"flag-note.png"));
1138 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1140 fo->load(QPixmap(flagsPath+"flag-url.png"));
1141 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1143 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1144 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1146 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1147 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1149 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1150 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1152 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1153 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1155 // Create Standard Flags
1156 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1157 tb->setObjectName ("standardFlagTB");
1159 standardFlagsDefault = new FlagRowObj ();
1160 standardFlagsDefault->setVisibility (false);
1161 standardFlagsDefault->setName ("standardFlagsDef");
1162 standardFlagsDefault->setToolBar (tb);
1164 fo->load(flagsPath+"flag-exclamationmark.png");
1165 fo->setGroup("standard-mark");
1166 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1168 fo->load(flagsPath+"flag-questionmark.png");
1169 fo->setGroup("standard-mark");
1170 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1172 fo->load(flagsPath+"flag-hook-green.png");
1173 fo->setGroup("standard-hook");
1174 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1176 fo->load(flagsPath+"flag-cross-red.png");
1177 fo->setGroup("standard-hook");
1178 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1181 fo->load(flagsPath+"flag-stopsign.png");
1182 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1184 fo->load(flagsPath+"flag-smiley-good.png");
1185 fo->setGroup("standard-smiley");
1186 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1188 fo->load(flagsPath+"flag-smiley-sad.png");
1189 fo->setGroup("standard-smiley");
1190 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1192 fo->load(flagsPath+"flag-smiley-omg.png");
1193 fo->setGroup("standard-smiley");
1194 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1195 // Original omg.png (in KDE emoticons)
1198 fo->load(flagsPath+"flag-kalarm.png");
1199 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1201 fo->load(flagsPath+"flag-phone.png");
1202 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1204 fo->load(flagsPath+"flag-lamp.png");
1205 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1207 fo->load(flagsPath+"flag-arrow-up.png");
1208 fo->setGroup("standard-arrow");
1209 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1211 fo->load(flagsPath+"flag-arrow-down.png");
1212 fo->setGroup("standard-arrow");
1213 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1215 fo->load(flagsPath+"flag-arrow-2up.png");
1216 fo->setGroup("standard-arrow");
1217 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1219 fo->load(flagsPath+"flag-arrow-2down.png");
1220 fo->setGroup("standard-arrow");
1221 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1224 fo->load(flagsPath+"flag-thumb-up.png");
1225 fo->setGroup("standard-thumb");
1226 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1228 fo->load(flagsPath+"flag-thumb-down.png");
1229 fo->setGroup("standard-thumb");
1230 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1233 fo->load(flagsPath+"flag-rose.png");
1234 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1236 fo->load(flagsPath+"flag-heart.png");
1237 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1239 fo->load(flagsPath+"flag-present.png");
1240 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1242 fo->load(flagsPath+"flag-flash.png");
1243 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1245 // Original: xsldbg_output.png
1246 fo->load(flagsPath+"flag-info.png");
1247 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1249 // Original khelpcenter.png
1250 fo->load(flagsPath+"flag-lifebelt.png");
1251 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1257 fo->load(flagsPath+"freemind/warning.png");
1258 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1260 for (int i=1; i<8; i++)
1262 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1263 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1266 fo->load(flagsPath+"freemind/back.png");
1267 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1269 fo->load(flagsPath+"freemind/forward.png");
1270 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1272 fo->load(flagsPath+"freemind/attach.png");
1273 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1275 fo->load(flagsPath+"freemind/clanbomber.png");
1276 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1278 fo->load(flagsPath+"freemind/desktopnew.png");
1279 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1281 fo->load(flagsPath+"freemind/flag.png");
1282 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1285 fo->load(flagsPath+"freemind/gohome.png");
1286 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1289 fo->load(flagsPath+"freemind/kaddressbook.png");
1290 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1292 fo->load(flagsPath+"freemind/knotify.png");
1293 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1295 fo->load(flagsPath+"freemind/korn.png");
1296 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1298 fo->load(flagsPath+"freemind/mail.png");
1299 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1301 fo->load(flagsPath+"freemind/password.png");
1302 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1304 fo->load(flagsPath+"freemind/pencil.png");
1305 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1307 fo->load(flagsPath+"freemind/stop.png");
1308 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1310 fo->load(flagsPath+"freemind/wizard.png");
1311 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1313 fo->load(flagsPath+"freemind/xmag.png");
1314 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1316 fo->load(flagsPath+"freemind/bell.png");
1317 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1319 fo->load(flagsPath+"freemind/bookmark.png");
1320 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1322 fo->load(flagsPath+"freemind/penguin.png");
1323 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1325 fo->load(flagsPath+"freemind/licq.png");
1326 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1331 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1334 fo->setToolTip (tooltip);
1335 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1341 fo->setAlwaysVisible(aw);
1342 a->setCheckable(true);
1343 a->setObjectName(fo->getName());
1344 a->setToolTip(tooltip);
1345 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1346 standardFlagsDefault->addFlag (fo);
1350 systemFlagsDefault->addFlag (fo);
1354 void Main::setupNetworkActions()
1356 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1358 QMenu *netMenu = menuBar()->addMenu( "Network" );
1362 a = new QAction( "Start TCPserver for MapEditor",this);
1363 //a->setStatusTip ( "Set application to open pdf files"));
1364 a->setShortcut ( Qt::Key_T ); //New TCP server
1365 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1366 netMenu->addAction (a);
1368 a = new QAction( "Connect MapEditor to server",this);
1369 //a->setStatusTip ( "Set application to open pdf files"));
1370 a->setShortcut ( Qt::Key_C ); // Connect to server
1371 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1372 netMenu->addAction (a);
1376 void Main::setupSettingsActions()
1378 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1382 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1383 a->setStatusTip ( tr( "Set application to open pdf files"));
1384 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1385 settingsMenu->addAction (a);
1387 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1388 a->setStatusTip( tr( "Set application to open external links"));
1389 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1390 settingsMenu->addAction (a);
1392 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1393 a->setStatusTip( tr( "Set path for macros"));
1394 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1395 settingsMenu->addAction (a);
1397 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1398 a->setStatusTip( tr( "Set number of undo levels"));
1399 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1400 settingsMenu->addAction (a);
1402 settingsMenu->addSeparator();
1404 a = new QAction( tr( "Autosave","Settings action"), this);
1405 a->setStatusTip( tr( "Autosave"));
1406 a->setToggleAction(true);
1407 a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool());
1408 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1409 settingsMenu->addAction (a);
1410 actionSettingsAutosaveToggle=a;
1412 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1413 a->setStatusTip( tr( "Autosave time"));
1414 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1415 settingsMenu->addAction (a);
1416 actionSettingsAutosaveTime=a;
1418 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1419 a->setStatusTip( tr( "Write backup file on save"));
1420 a->setToggleAction(true);
1421 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1422 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1423 settingsMenu->addAction (a);
1424 actionSettingsWriteBackupFile=a;
1426 settingsMenu->addSeparator();
1428 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1429 a->setStatusTip( tr( "Edit branch after adding it" ));
1430 a->setToggleAction(true);
1431 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1432 settingsMenu->addAction (a);
1433 actionSettingsAutoEditNewBranch=a;
1435 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1436 a->setStatusTip( tr( "Select branch after adding it" ));
1437 a->setToggleAction(true);
1438 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1439 settingsMenu->addAction (a);
1440 actionSettingsAutoSelectNewBranch=a;
1442 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1443 a->setStatusTip( tr( "Select heading before editing" ));
1444 a->setToggleAction(true);
1445 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1446 settingsMenu->addAction (a);
1447 actionSettingsAutoSelectText=a;
1449 a= new QAction( tr( "Delete key","Settings action" ), this);
1450 a->setStatusTip( tr( "Delete key for deleting branches" ));
1451 a->setToggleAction(true);
1452 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1453 settingsMenu->addAction (a);
1454 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1455 actionSettingsUseDelKey=a;
1457 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1458 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1459 a->setToggleAction(true);
1460 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1461 settingsMenu->addAction (a);
1462 actionSettingsUseFlagGroups=a;
1464 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1465 a->setStatusTip( tr( "Use hide flag during exports " ));
1466 a->setToggleAction(true);
1467 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1468 settingsMenu->addAction (a);
1469 actionSettingsUseHideExport=a;
1471 a = new QAction( tr( "Animation","Settings action"), this);
1472 a->setStatusTip( tr( "Animation"));
1473 a->setToggleAction(true);
1474 a->setOn (settings.value("/animation/use",false).toBool() );
1475 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1476 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1478 settingsMenu->addAction (a);
1480 actionSettingsUseAnimation=a;
1484 void Main::setupTestActions()
1486 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1489 a = new QAction( "Test function 1" , this);
1490 a->setStatusTip( "Call test function 1" );
1491 testMenu->addAction (a);
1492 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1494 a = new QAction( "Test function 2" , this);
1495 a->setStatusTip( "Call test function 2" );
1496 testMenu->addAction (a);
1497 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1499 a = new QAction( "Command" , this);
1500 a->setStatusTip( "Enter command to call in editor" );
1501 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1502 testMenu->addAction (a);
1506 void Main::setupHelpActions()
1508 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1511 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1512 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1513 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1514 helpMenu->addAction (a);
1516 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1517 a->setStatusTip( tr( "Open VYM example maps " ));
1518 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1519 helpMenu->addAction (a);
1521 a = new QAction( tr( "About VYM","Help action" ), this);
1522 a->setStatusTip( tr( "About VYM")+vymName);
1523 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1524 helpMenu->addAction (a);
1526 a = new QAction( tr( "About QT","Help action" ), this);
1527 a->setStatusTip( tr( "Information about QT toolkit" ));
1528 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1529 helpMenu->addAction (a);
1533 void Main::setupContextMenus()
1537 // Context Menu for branch or mapcenter
1538 branchContextMenu =new QMenu (this);
1539 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1540 branchContextMenu->addSeparator();
1543 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1544 branchAddContextMenu->addAction (actionEditPaste );
1545 branchAddContextMenu->addAction ( actionEditAddBranch );
1546 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1547 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1548 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1549 branchAddContextMenu->addSeparator();
1550 branchAddContextMenu->addAction ( actionEditImportAdd );
1551 branchAddContextMenu->addAction ( actionEditImportReplace );
1554 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1555 branchRemoveContextMenu->addAction (actionEditCut);
1556 branchRemoveContextMenu->addAction ( actionEditDelete );
1557 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1558 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1561 actionEditSaveBranch->addTo( branchContextMenu );
1562 actionFileNewCopy->addTo (branchContextMenu );
1564 branchContextMenu->addSeparator();
1565 branchContextMenu->addAction ( actionEditLoadImage);
1567 // Submenu for Links (URLs, vymLinks)
1568 branchLinksContextMenu =new QMenu (this);
1570 branchContextMenu->addSeparator();
1571 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1572 branchLinksContextMenu->addAction ( actionEditOpenURL );
1573 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1574 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1575 branchLinksContextMenu->addAction ( actionEditURL );
1576 branchLinksContextMenu->addAction ( actionEditLocalURL );
1577 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1578 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1579 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1581 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1583 branchLinksContextMenu->addSeparator();
1584 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1585 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1586 branchLinksContextMenu->addAction ( actionEditVymLink );
1587 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1590 // Context Menu for XLinks in a branch menu
1591 // This will be populated "on demand" in MapEditor::updateActions
1592 branchContextMenu->addSeparator();
1593 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1594 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1595 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1596 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1599 // Context menu for floatimage
1600 floatimageContextMenu =new QMenu (this);
1601 a= new QAction (tr ("Save image","Context action"),this);
1602 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1603 floatimageContextMenu->addAction (a);
1605 floatimageContextMenu->addSeparator();
1606 actionEditCopy->addTo( floatimageContextMenu );
1607 actionEditCut->addTo( floatimageContextMenu );
1609 floatimageContextMenu->addSeparator();
1610 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1613 // Context menu for canvas
1614 canvasContextMenu =new QMenu (this);
1615 actionEditMapInfo->addTo( canvasContextMenu );
1616 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1617 actionEditAddMapCenter->addTo( canvasContextMenu );
1618 canvasContextMenu->insertSeparator();
1619 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1620 canvasContextMenu->insertSeparator();
1621 actionFormatLinkColorHint->addTo( canvasContextMenu );
1622 actionFormatLinkColor->addTo( canvasContextMenu );
1623 actionFormatSelectionColor->addTo( canvasContextMenu );
1624 actionFormatBackColor->addTo( canvasContextMenu );
1625 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1627 // Menu for last opened files
1629 for (int i = 0; i < MaxRecentFiles; ++i)
1631 recentFileActions[i] = new QAction(this);
1632 recentFileActions[i]->setVisible(false);
1633 fileLastMapsMenu->addAction(recentFileActions[i]);
1634 connect(recentFileActions[i], SIGNAL(triggered()),
1635 this, SLOT(fileLoadRecent()));
1637 setupRecentMapsMenu();
1640 void Main::setupRecentMapsMenu()
1642 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1644 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1646 for (int i = 0; i < numRecentFiles; ++i) {
1647 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1648 recentFileActions[i]->setText(text);
1649 recentFileActions[i]->setData(files[i]);
1650 recentFileActions[i]->setVisible(true);
1652 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1653 recentFileActions[j]->setVisible(false);
1656 void Main::setupMacros()
1658 for (int i = 0; i <= 11; i++)
1660 macroActions[i] = new QAction(this);
1661 macroActions[i]->setData(i);
1662 addAction (macroActions[i]);
1663 connect(macroActions[i], SIGNAL(triggered()),
1664 this, SLOT(callMacro()));
1666 macroActions[0]->setShortcut ( Qt::Key_F1 );
1667 macroActions[1]->setShortcut ( Qt::Key_F2 );
1668 macroActions[2]->setShortcut ( Qt::Key_F3 );
1669 macroActions[3]->setShortcut ( Qt::Key_F4 );
1670 macroActions[4]->setShortcut ( Qt::Key_F5 );
1671 macroActions[5]->setShortcut ( Qt::Key_F6 );
1672 macroActions[6]->setShortcut ( Qt::Key_F7 );
1673 macroActions[7]->setShortcut ( Qt::Key_F8 );
1674 macroActions[8]->setShortcut ( Qt::Key_F9 );
1675 macroActions[9]->setShortcut ( Qt::Key_F10 );
1676 macroActions[10]->setShortcut ( Qt::Key_F11 );
1677 macroActions[11]->setShortcut ( Qt::Key_F12 );
1680 void Main::hideEvent (QHideEvent * )
1682 if (!textEditor->isMinimized() ) textEditor->hide();
1685 void Main::showEvent (QShowEvent * )
1687 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1691 MapEditor* Main::currentMapEditor() const
1693 if ( tabWidget->currentPage() &&
1694 tabWidget->currentPage()->inherits( "MapEditor" ) )
1695 return (MapEditor*)tabWidget->currentPage();
1700 void Main::editorChanged(QWidget *)
1702 // Unselect all possibly selected objects
1703 // (Important to update note editor)
1705 for (int i=0;i<=tabWidget->count() -1;i++)
1707 me=(MapEditor*)tabWidget->page(i);
1710 me=currentMapEditor();
1711 if (me) me->reselect();
1713 // Update actions to in menus and toolbars according to editor
1717 void Main::fileNew()
1719 QString fn="unnamed";
1720 MapEditor* me = new MapEditor ( NULL);
1721 tabWidget->addTab (me,fn);
1722 tabWidget->showPage(me);
1723 me->viewport()->setFocus();
1724 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1725 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1727 // For the very first map we do not have flagrows yet...
1731 void Main::fileNewCopy()
1733 QString fn="unnamed";
1734 MapEditor* oldME =currentMapEditor();
1738 MapEditor* newME = new MapEditor ( NULL);
1741 tabWidget->addTab (newME,fn);
1742 tabWidget->showPage(newME);
1743 newME->viewport()->setFocus();
1744 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1745 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1746 // For the very first map we do not have flagrows yet...
1747 newME->select("mc:");
1748 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1754 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1756 ErrorCode err=success;
1758 // fn is usually the archive, mapfile the file after uncompressing
1761 // Make fn absolute (needed for unzip)
1762 fn=QDir (fn).absPath();
1768 // Check, if map is already loaded
1770 while (i<=tabWidget->count() -1)
1772 me=(MapEditor*)tabWidget->page(i);
1773 if (me->getFilePath() == fn)
1775 // Already there, ask for confirmation
1776 QMessageBox mb( vymName,
1777 tr("The map %1\nis already opened."
1778 "Opening the same map in multiple editors may lead \n"
1779 "to confusion when finishing working with vym."
1780 "Do you want to").arg(fn),
1781 QMessageBox::Warning,
1782 QMessageBox::Yes | QMessageBox::Default,
1783 QMessageBox::Cancel | QMessageBox::Escape,
1784 QMessageBox::NoButton);
1785 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1786 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1789 case QMessageBox::Yes:
1791 i=tabWidget->count();
1793 case QMessageBox::Cancel:
1805 if ( !fn.isEmpty() )
1807 me = currentMapEditor();
1808 int tabIndex=tabWidget->currentPageIndex();
1809 // Check first, if mapeditor exists
1810 // If it is not default AND we want a new map,
1811 // create a new mapeditor in a new tab
1812 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1814 me= new MapEditor ( NULL);
1815 tabWidget->addTab (me,fn);
1816 tabIndex=tabWidget->indexOf (me);
1817 tabWidget->setCurrentPage (tabIndex);
1818 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1819 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1822 // Check, if file exists (important for creating new files
1823 // from command line
1826 if (!QFile(fn).exists() )
1828 QMessageBox mb( vymName,
1829 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1830 QMessageBox::Question,
1832 QMessageBox::Cancel | QMessageBox::Default,
1833 QMessageBox::NoButton );
1835 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1836 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1839 case QMessageBox::Yes:
1841 currentMapEditor()->setFilePath(fn);
1842 tabWidget->setTabLabel (currentMapEditor(),
1843 currentMapEditor()->getFileName() );
1844 statusBar()->message( "Created " + fn , statusbarTime );
1847 case QMessageBox::Cancel:
1848 // don't create new map
1849 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1855 //tabWidget->currentPage() won't be NULL here, because of above...
1856 tabWidget->showPage(me);
1857 me->viewport()->setFocus();
1861 // Save existing filename in case we import
1862 QString fn_org=me->getFilePath();
1864 // Finally load map into mapEditor
1865 me->setFilePath (fn);
1866 err=me->load(fn,lmode,ftype);
1868 // Restore old (maybe empty) filepath, if this is an import
1870 me->setFilePath (fn_org);
1873 // Finally check for errors and go home
1876 if (lmode==NewMap) fileCloseMap();
1877 statusBar()->message( "Could not load " + fn, statusbarTime );
1882 me->setFilePath (fn);
1883 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1884 if (!isInTmpDir (fn))
1886 // Only append to lastMaps if not loaded from a tmpDir
1887 // e.g. imported bookmarks are in a tmpDir
1888 addRecentMap(me->getFilePath() );
1890 //actionFilePrint->setEnabled (true);
1892 statusBar()->message( "Loaded " + fn, statusbarTime );
1899 void Main::fileLoad(const LoadMode &lmode)
1901 QStringList filters;
1902 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1903 QFileDialog *fd=new QFileDialog( this);
1904 fd->setDir (lastFileDir);
1905 fd->setFileMode (QFileDialog::ExistingFiles);
1906 fd->setFilters (filters);
1910 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1913 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1916 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1922 if ( fd->exec() == QDialog::Accepted )
1924 lastFileDir=fd->directory().path();
1925 QStringList flist = fd->selectedFiles();
1926 QStringList::Iterator it = flist.begin();
1927 while( it != flist.end() )
1930 fileLoad(*it, lmode);
1937 void Main::fileLoad()
1942 void Main::fileLoadRecent()
1944 QAction *action = qobject_cast<QAction *>(sender());
1946 fileLoad (action->data().toString(), NewMap);
1949 void Main::addRecentMap (const QString &fileName)
1952 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1953 files.removeAll(fileName);
1954 files.prepend(fileName);
1955 while (files.size() > MaxRecentFiles)
1958 settings.setValue("/mainwindow/recentFileList", files);
1960 setupRecentMapsMenu();
1963 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1967 if ( me->getFilePath().isEmpty() )
1969 // We have no filepath yet,
1970 // call fileSaveAs() now, this will call fileSave()
1972 // First switch to editor
1973 tabWidget->setCurrentWidget (me);
1974 fileSaveAs(savemode);
1977 if (me->save (savemode)==success)
1979 statusBar()->message(
1980 tr("Saved %1").arg(me->getFilePath()),
1982 addRecentMap (me->getFilePath() );
1984 statusBar()->message(
1985 tr("Couldn't save ").arg(me->getFilePath()),
1989 void Main::fileSave()
1991 fileSave (currentMapEditor(), CompleteMap);
1994 void Main::fileSave(MapEditor *me)
1996 fileSave (me,CompleteMap);
1999 void Main::fileSaveAs(const SaveMode& savemode)
2003 if (currentMapEditor())
2005 if (savemode==CompleteMap)
2006 fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2008 fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2009 if ( !fn.isEmpty() )
2011 // Check for existing file
2012 if (QFile (fn).exists())
2014 QMessageBox mb( vymName,
2015 tr("The file %1\nexists already. Do you want to").arg(fn),
2016 QMessageBox::Warning,
2017 QMessageBox::Yes | QMessageBox::Default,
2018 QMessageBox::Cancel | QMessageBox::Escape,
2019 QMessageBox::NoButton);
2020 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2021 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2024 case QMessageBox::Yes:
2027 case QMessageBox::Cancel:
2034 // New file, add extension to filename, if missing
2035 // This is always .vym or .vyp, depending on savemode
2036 if (savemode==CompleteMap)
2038 if (!fn.contains (".vym") && !fn.contains (".xml"))
2042 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2051 currentMapEditor()->setFilePath(fn);
2052 fileSave(currentMapEditor(), savemode);
2055 if (savemode==CompleteMap)
2056 tabWidget->setTabLabel (currentMapEditor(),
2057 currentMapEditor()->getFileName() );
2063 void Main::fileSaveAs()
2065 fileSaveAs (CompleteMap);
2068 void Main::fileImportKDEBookmarks()
2070 ImportKDEBookmarks im;
2072 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2073 currentMapEditor()->setFilePath ("");
2076 void Main::fileImportFirefoxBookmarks()
2078 QFileDialog *fd=new QFileDialog( this);
2079 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2080 fd->setMode (QFileDialog::ExistingFiles);
2081 //fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2082 QStringList filters = fd->filters();
2083 filters << tr("Firefox Bookmarks (*.html)");
2084 fd->setFilters(filters);
2085 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2088 if ( fd->exec() == QDialog::Accepted )
2090 ImportFirefoxBookmarks im;
2091 QStringList flist = fd->selectedFiles();
2092 QStringList::Iterator it = flist.begin();
2093 while( it != flist.end() )
2096 if (im.transform() &&
2097 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2098 currentMapEditor() )
2099 currentMapEditor()->setFilePath ("");
2106 void Main::fileImportFreemind()
2108 QStringList filters;
2109 filters <<"Freemind map (*.mm)"<<"All files (*)";
2110 QFileDialog *fd=new QFileDialog( this);
2111 fd->setDir (lastFileDir);
2112 fd->setFileMode (QFileDialog::ExistingFiles);
2113 fd->setFilters (filters);
2114 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2118 if ( fd->exec() == QDialog::Accepted )
2120 lastFileDir=fd->directory().path();
2121 QStringList flist = fd->selectedFiles();
2122 QStringList::Iterator it = flist.begin();
2123 while( it != flist.end() )
2126 if ( fileLoad (fn,NewMap, FreemindMap) )
2128 currentMapEditor()->setFilePath ("");
2137 void Main::fileImportMM()
2141 QFileDialog *fd=new QFileDialog( this);
2142 fd->setDir (lastFileDir);
2143 fd->setMode (QFileDialog::ExistingFiles);
2144 //fd->addFilter ("Mind Manager (*.mmap)");
2145 QStringList filters = fd->filters();
2146 filters << tr("Mind Manager (*.mmap)");
2147 fd->setFilters(filters);
2148 fd->setCaption(tr("Import")+" "+"Mind Manager");
2151 if ( fd->exec() == QDialog::Accepted )
2153 lastFileDir=fd->directory().path();
2154 QStringList flist = fd->selectedFiles();
2155 QStringList::Iterator it = flist.begin();
2156 while( it != flist.end() )
2159 if (im.transform() &&
2160 success==fileLoad (im.getTransformedFile(),NewMap) &&
2161 currentMapEditor() )
2162 currentMapEditor()->setFilePath ("");
2171 void Main::fileImportDir()
2173 if (currentMapEditor())
2174 currentMapEditor()->importDir();
2177 void Main::fileExportXML()
2179 MapEditor *me=currentMapEditor();
2180 if (me) me->exportXML();
2184 void Main::fileExportXHTML()
2186 MapEditor *me=currentMapEditor();
2187 if (me) me->exportXHTML();
2190 void Main::fileExportImage()
2192 MapEditor *me=currentMapEditor();
2193 if (me) me->exportImage();
2196 void Main::fileExportASCII()
2198 MapEditor *me=currentMapEditor();
2199 if (me) me->exportASCII();
2202 void Main::fileExportCSV() //FIXME not scriptable yet
2204 MapEditor *me=currentMapEditor();
2208 ex.setModel (me->getModel());
2209 ex.addFilter ("CSV (*.csv)");
2210 ex.setDir(lastImageDir);
2211 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2212 if (ex.execDialog() )
2214 me->setExportMode(true);
2216 me->setExportMode(false);
2221 void Main::fileExportLaTeX() //FIXME not scriptable yet
2223 MapEditor *me=currentMapEditor();
2227 ex.setModel (me->getModel());
2228 ex.addFilter ("Tex (*.tex)");
2229 ex.setDir(lastImageDir);
2230 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2231 if (ex.execDialog() )
2233 me->setExportMode(true);
2235 me->setExportMode(false);
2240 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2242 ExportKDEBookmarks ex;
2243 MapEditor *me=currentMapEditor();
2246 ex.setModel (me->getModel());
2251 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2253 ExportTaskjuggler ex;
2254 MapEditor *me=currentMapEditor();
2257 ex.setModel (me->getModel());
2258 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2259 ex.setDir(lastImageDir);
2260 ex.addFilter ("Taskjuggler (*.tjp)");
2261 if (ex.execDialog() )
2263 me->setExportMode(true);
2265 me->setExportMode(false);
2270 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2272 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2273 // TODO add preview in dialog
2274 //ImagePreview *p =new ImagePreview (fd);
2275 //fd->setContentsPreviewEnabled( TRUE );
2276 //fd->setContentsPreview( p, p );
2277 //fd->setPreviewMode( QFileDialog::Contents );
2278 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2279 fd->setDir (QDir().current());
2280 if (fd->foundConfig())
2284 if ( fd->exec() == QDialog::Accepted )
2286 QString fn=fd->selectedFile();
2287 if (!fn.contains (".odp"))
2290 //lastImageDir=fn.left(fn.findRev ("/"));
2291 if (currentMapEditor())
2292 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2296 QMessageBox::warning(0,
2298 tr("Couldn't find configuration for export to Open Office\n"));
2302 void Main::fileCloseMap()
2304 MapEditor *me = currentMapEditor();
2307 if (me->hasChanged())
2309 QMessageBox mb( vymName,
2310 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
2311 QMessageBox::Warning,
2312 QMessageBox::Yes | QMessageBox::Default,
2314 QMessageBox::Cancel | QMessageBox::Escape );
2315 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2316 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2319 case QMessageBox::Yes:
2321 fileSave(me, CompleteMap);
2323 case QMessageBox::No:
2324 // close without saving
2326 case QMessageBox::Cancel:
2332 tabWidget->removePage(me);
2333 //if (tabWidget->count()==0)
2334 // actionFilePrint->setEnabled (false);
2341 void Main::filePrint()
2343 if (currentMapEditor())
2344 currentMapEditor()->print();
2347 void Main::fileExitVYM()
2349 // Check if one or more editors have changed
2352 for (i=0;i<=tabWidget->count() -1;i++)
2355 me=(MapEditor*)tabWidget->page(i);
2357 // If something changed, ask what to do
2358 if (me->hasChanged())
2360 tabWidget->setCurrentPage(i);
2361 QMessageBox mb( vymName,
2362 tr("This map is not saved yet. Do you want to"),
2363 QMessageBox::Warning,
2364 QMessageBox::Yes | QMessageBox::Default,
2366 QMessageBox::Cancel | QMessageBox::Escape );
2367 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2368 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2371 mb.setActiveWindow();
2372 switch( mb.exec() ) {
2373 case QMessageBox::Yes:
2374 // save (the changed editors) and exit
2375 fileSave(currentMapEditor(), CompleteMap);
2377 case QMessageBox::No:
2378 // exit without saving
2380 case QMessageBox::Cancel:
2381 // don't save and don't exit
2385 } // loop over all MEs
2389 void Main::editUndo()
2391 if (currentMapEditor())
2392 currentMapEditor()->undo();
2395 void Main::editRedo()
2397 if (currentMapEditor())
2398 currentMapEditor()->redo();
2401 void Main::gotoHistoryStep (int i)
2403 if (currentMapEditor())
2404 currentMapEditor()->gotoHistoryStep (i);
2407 void Main::editCopy()
2409 if (currentMapEditor())
2410 currentMapEditor()->copy();
2413 void Main::editPaste()
2415 if (currentMapEditor())
2416 currentMapEditor()->paste();
2419 void Main::editCut()
2421 if (currentMapEditor())
2422 currentMapEditor()->cut();
2425 void Main::editOpenFindWindow()
2427 findWindow->popup();
2428 findWindow->raise();
2429 findWindow->setActiveWindow();
2432 void Main::editFind(QString s)
2435 BranchObj *bo=currentMapEditor()->findText(s, cs);
2438 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2441 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2442 tr("No matches found for \"%1\"").arg(s));
2446 void Main::editFindChanged()
2447 { // Notify editor, to abort the current find process
2448 currentMapEditor()->findReset();
2451 void Main::openTabs(QStringList urls)
2453 if (!urls.isEmpty())
2457 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2459 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2461 QString u=urls.takeFirst();
2462 procBrowser = new QProcess( this );
2464 procBrowser->start(browser,args);
2465 if ( !procBrowser->waitForStarted())
2467 // try to set path to browser
2468 QMessageBox::warning(0,
2470 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2471 tr("Please use Settings->")+tr("Set application to open an URL"));
2474 #if defined(Q_OS_WIN32)
2475 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2476 this->thread()->wait(3000);
2481 if (browser.contains("konqueror"))
2483 for (int i=0; i<urls.size(); i++)
2486 // Try to open new tab in existing konqueror started previously by vym
2487 p=new QProcess (this);
2489 #if defined(Q_OS_WIN32)
2490 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2491 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2492 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2493 "konqueror-mainwindow#1"<<
2497 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2498 "konqueror-mainwindow#1"<<
2502 p->start ("dcop",args);
2503 //cout << qPrintable (args.join(" "))<<endl;
2504 if ( !p->waitForStarted() ) success=false;
2507 QMessageBox::warning(0,
2509 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2511 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2513 for (int i=0; i<urls.size(); i++)
2515 // Try to open new tab in firefox
2516 p=new QProcess (this);
2517 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2518 p->start (browser,args);
2519 if ( !p->waitForStarted() ) success=false;
2522 QMessageBox::warning(0,
2524 tr("Couldn't start %1 to open a new tab").arg(browser));
2527 QMessageBox::warning(0,
2529 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2533 void Main::editOpenURL()
2536 if (currentMapEditor())
2538 QString url=currentMapEditor()->getURL();
2540 if (url=="") return;
2541 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2542 procBrowser = new QProcess( this );
2544 procBrowser->start(browser,args);
2545 if ( !procBrowser->waitForStarted())
2547 // try to set path to browser
2548 QMessageBox::warning(0,
2550 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2551 tr("Please use Settings->")+tr("Set application to open an URL"));
2556 void Main::editOpenURLTab()
2558 if (currentMapEditor())
2561 urls.append(currentMapEditor()->getURL());
2565 void Main::editOpenMultipleURLTabs()
2567 if (currentMapEditor())
2570 urls=currentMapEditor()->getURLs();
2576 void Main::editURL()
2578 if (currentMapEditor())
2579 currentMapEditor()->editURL();
2582 void Main::editLocalURL()
2584 if (currentMapEditor())
2585 currentMapEditor()->editLocalURL();
2588 void Main::editHeading2URL()
2590 if (currentMapEditor())
2591 currentMapEditor()->editHeading2URL();
2594 void Main::editBugzilla2URL()
2596 if (currentMapEditor())
2597 currentMapEditor()->editBugzilla2URL();
2600 void Main::editFATE2URL()
2602 if (currentMapEditor())
2603 currentMapEditor()->editFATE2URL();
2606 void Main::editHeadingFinished()
2608 // only called from editHeading(), so there is a currentME
2609 MapEditor *me=currentMapEditor();
2612 me->setStateEditHeading (false);
2613 QPoint p; //Not used here, only to find out pos of branch
2615 QString s=me->getHeading(ok,p);
2617 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2619 if (ok && s!=lineedit->text())
2620 me->setHeading(lineedit->text());
2622 lineedit->releaseKeyboard();
2626 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2627 !prevSelection.isEmpty())
2628 me->select(prevSelection);
2633 void Main::editHeading()
2635 if (currentMapEditor())
2637 MapEditor *me=currentMapEditor();
2638 QString oldSel=me->getSelectString();
2640 if (lineedit->isVisible())
2641 editHeadingFinished();
2646 QString s=me->getHeading(ok,p);
2650 me->setStateEditHeading (true);
2651 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2652 p=me->mapToGlobal (p);
2653 QDialog *d =new QDialog(NULL);
2654 QLineEdit *le=new QLineEdit (d);
2655 d->setWindowFlags (Qt::FramelessWindowHint);
2656 d->setGeometry(p.x(),p.y(),230,25);
2657 le->resize (d->width()-10,d->height());
2660 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2661 d->activateWindow();
2663 me->setHeading (le->text());
2666 editHeadingFinished();
2668 p=me->mapTo (this,p);
2669 lineedit->setGeometry(p.x(),p.y(),230,25);
2670 lineedit->setText(s);
2671 lineedit->setCursorPosition(1);
2672 lineedit->selectAll();
2674 lineedit->grabKeyboard();
2675 lineedit->setFocus();
2679 } // currentMapEditor()
2682 void Main::editAttributeFinished()
2684 // only called from editHeading(), so there is a currentME
2687 MapEditor *me=currentMapEditor();
2690 me->setStateEditHeading (false);
2691 QPoint p; //Not used here, only to find out pos of branch
2693 QString s=me->getHeading(ok,p);
2695 #if defined(Q_OS_MACX)
2697 if (ok && s!=lineedit->text())
2698 me->setHeading(lineedit->text());
2700 lineedit->releaseKeyboard();
2704 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2705 !prevSelection.isEmpty())
2706 me->select(prevSelection);
2712 #include "attribute.h"
2713 #include "attributedialog.h"
2714 void Main::editAttribute()
2716 MapEditor *me=currentMapEditor();
2719 BranchObj *bo=me->getSelectedBranch();
2722 AttributeDialog dia(this);
2723 dia.setTable (me->attributeTable() );
2725 dia.setMode (Definition);
2731 if (currentMapEditor())
2733 MapEditor *me=currentMapEditor();
2734 QString oldSel=me->getSelectString();
2736 if (lineedit->isVisible())
2737 editAttributeFinished();
2742 QString s=me->getHeading(ok,p);
2746 me->setStateEditHeading (true);
2747 #if defined(Q_OS_MACX)
2748 p=me->mapToGlobal (p);
2749 QDialog *d =new QDialog(NULL);
2750 QLineEdit *le=new QLineEdit (d);
2751 d->setWindowFlags (Qt::FramelessWindowHint);
2752 d->setGeometry(p.x(),p.y(),230,25);
2753 le->resize (d->width()-10,d->height());
2756 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2757 d->activateWindow();
2759 me->setHeading (le->text());
2762 editHeadingFinished();
2764 p=me->mapTo (this,p);
2765 lineedit->setGeometry(p.x(),p.y(),230,25);
2766 lineedit->setText(s);
2767 lineedit->setCursorPosition(1);
2768 lineedit->selectAll();
2770 lineedit->grabKeyboard();
2771 lineedit->setFocus();
2775 } // currentMapEditor()
2780 void Main::openVymLinks(const QStringList &vl)
2782 for (int j=0; j<vl.size(); j++)
2784 // compare path with already loaded maps
2788 for (i=0;i<=tabWidget->count() -1;i++)
2790 me=(MapEditor*)tabWidget->page(i);
2791 if (vl.at(j)==me->getFilePath() )
2800 if (!QFile(vl.at(j)).exists() )
2801 QMessageBox::critical( 0, tr( "Critical Error" ),
2802 tr("Couldn't open map %1").arg(vl.at(j)));
2805 fileLoad (vl.at(j), NewMap);
2806 tabWidget->setCurrentPage (tabWidget->count()-1);
2809 // Go to tab containing the map
2810 tabWidget->setCurrentPage (index);
2814 void Main::editOpenVymLink()
2816 if (currentMapEditor())
2819 vl.append(currentMapEditor()->getVymLink());
2824 void Main::editOpenMultipleVymLinks()
2826 QString currentVymLink;
2827 if (currentMapEditor())
2829 QStringList vl=currentMapEditor()->getVymLinks();
2834 void Main::editVymLink()
2836 if (currentMapEditor())
2837 currentMapEditor()->editVymLink();
2840 void Main::editDeleteVymLink()
2842 if (currentMapEditor())
2843 currentMapEditor()->deleteVymLink();
2846 void Main::editToggleHideExport()
2848 if (currentMapEditor())
2849 currentMapEditor()->toggleHideExport();
2852 void Main::editMapInfo()
2854 if (currentMapEditor())
2855 currentMapEditor()->editMapInfo();
2858 void Main::editMoveUp()
2860 if (currentMapEditor())
2861 currentMapEditor()->moveBranchUp();
2864 void Main::editMoveDown()
2866 if (currentMapEditor())
2867 currentMapEditor()->moveBranchDown();
2870 void Main::editSortChildren()
2872 if (currentMapEditor())
2873 currentMapEditor()->sortChildren();
2876 void Main::editToggleScroll()
2878 if (currentMapEditor())
2880 currentMapEditor()->toggleScroll();
2884 void Main::editUnscrollChilds()
2886 if (currentMapEditor())
2887 currentMapEditor()->unscrollChilds();
2890 void Main::editAddMapCenter()
2892 MapEditor *me=currentMapEditor();
2893 if (!lineedit->isVisible() && me)
2895 me->addMapCenter ();
2899 void Main::editNewBranch()
2901 MapEditor *me=currentMapEditor();
2902 if (!lineedit->isVisible() && me)
2904 BranchObj *bo=(BranchObj*)me->getSelection();
2905 BranchObj *newbo=me->addNewBranch(0);
2907 prevSelection=me->getModel()->getSelectString(bo);
2913 if (actionSettingsAutoEditNewBranch->isOn())
2918 if (!prevSelection.isEmpty())
2920 me->select(prevSelection);
2927 void Main::editNewBranchBefore()
2929 MapEditor *me=currentMapEditor();
2930 if (!lineedit->isVisible() && me)
2932 BranchObj *bo=(BranchObj*)me->getSelection();
2933 BranchObj *newbo=me->addNewBranchBefore();
2940 if (actionSettingsAutoEditNewBranch->isOn())
2942 if (!actionSettingsAutoSelectNewBranch->isOn())
2943 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2949 void Main::editNewBranchAbove()
2951 MapEditor *me=currentMapEditor();
2952 if (!lineedit->isVisible() && me)
2954 BranchObj *bo=(BranchObj*)me->getSelection();
2955 BranchObj *newbo=me->addNewBranch (-1);
2962 if (actionSettingsAutoEditNewBranch->isOn())
2964 if (!actionSettingsAutoSelectNewBranch->isOn())
2965 prevSelection=me->getModel()->getSelectString (bo); // TODO access directly
2971 void Main::editNewBranchBelow()
2973 MapEditor *me=currentMapEditor();
2974 if (!lineedit->isVisible() && me)
2976 BranchObj *bo=(BranchObj*)me->getSelection();
2977 BranchObj *newbo=me->addNewBranch (1);
2984 if (actionSettingsAutoEditNewBranch->isOn())
2986 if (!actionSettingsAutoSelectNewBranch->isOn())
2987 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2993 void Main::editImportAdd()
2995 fileLoad (ImportAdd);
2998 void Main::editImportReplace()
3000 fileLoad (ImportReplace);
3003 void Main::editSaveBranch()
3005 fileSaveAs (PartOfMap);
3008 void Main::editDeleteKeepChilds()
3010 if (currentMapEditor())
3011 currentMapEditor()->deleteKeepChilds();
3014 void Main::editDeleteChilds()
3016 if (currentMapEditor())
3017 currentMapEditor()->deleteChilds();
3020 void Main::editDeleteSelection()
3022 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3023 currentMapEditor()->deleteSelection();
3026 void Main::editUpperBranch()
3028 if (currentMapEditor())
3029 currentMapEditor()->selectUpperBranch();
3032 void Main::editLowerBranch()
3034 if (currentMapEditor())
3035 currentMapEditor()->selectLowerBranch();
3038 void Main::editLeftBranch()
3040 if (currentMapEditor())
3041 currentMapEditor()->selectLeftBranch();
3044 void Main::editRightBranch()
3046 if (currentMapEditor())
3047 currentMapEditor()->selectRightBranch();
3050 void Main::editFirstBranch()
3052 if (currentMapEditor())
3053 currentMapEditor()->selectFirstBranch();
3056 void Main::editLastBranch()
3058 if (currentMapEditor())
3059 currentMapEditor()->selectLastBranch();
3062 void Main::editLoadImage()
3064 if (currentMapEditor())
3065 currentMapEditor()->loadFloatImage();
3068 void Main::editSaveImage()
3070 if (currentMapEditor())
3071 currentMapEditor()->saveFloatImage();
3074 void Main::editFollowXLink(QAction *a)
3077 if (currentMapEditor())
3078 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3081 void Main::editEditXLink(QAction *a)
3083 if (currentMapEditor())
3084 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3087 void Main::formatSelectColor()
3089 if (currentMapEditor())
3091 QColor col = QColorDialog::getColor((currentColor ), this );
3092 if ( !col.isValid() ) return;
3093 colorChanged( col );
3097 void Main::formatPickColor()
3099 if (currentMapEditor())
3100 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3103 void Main::colorChanged(QColor c)
3105 QPixmap pix( 16, 16 );
3107 actionFormatColor->setIconSet( pix );
3111 void Main::formatColorBranch()
3113 if (currentMapEditor())
3114 currentMapEditor()->colorBranch(currentColor);
3117 void Main::formatColorSubtree()
3119 if (currentMapEditor())
3120 currentMapEditor()->colorSubtree (currentColor);
3123 void Main::formatLinkStyleLine()
3125 if (currentMapEditor())
3127 currentMapEditor()->setMapLinkStyle("StyleLine");
3128 actionFormatLinkStyleLine->setOn(true);
3132 void Main::formatLinkStyleParabel()
3134 if (currentMapEditor())
3136 currentMapEditor()->setMapLinkStyle("StyleParabel");
3137 actionFormatLinkStyleParabel->setOn(true);
3141 void Main::formatLinkStylePolyLine()
3143 if (currentMapEditor())
3145 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3146 actionFormatLinkStylePolyLine->setOn(true);
3150 void Main::formatLinkStylePolyParabel()
3152 if (currentMapEditor())
3154 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3155 actionFormatLinkStylePolyParabel->setOn(true);
3159 void Main::formatSelectBackColor()
3161 if (currentMapEditor())
3162 currentMapEditor()->selectMapBackgroundColor();
3165 void Main::formatSelectBackImage()
3167 if (currentMapEditor())
3168 currentMapEditor()->selectMapBackgroundImage();
3171 void Main::formatSelectLinkColor()
3173 if (currentMapEditor())
3174 currentMapEditor()->selectMapLinkColor();
3177 void Main::formatSelectSelectionColor()
3179 if (currentMapEditor())
3180 currentMapEditor()->selectMapSelectionColor();
3183 void Main::formatToggleLinkColorHint()
3185 currentMapEditor()->toggleMapLinkColorHint();
3189 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3191 if (currentMapEditor())
3192 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3195 void Main::viewZoomReset()
3197 if (currentMapEditor())
3201 currentMapEditor()->setMatrix( m );
3205 void Main::viewZoomIn()
3207 if (currentMapEditor())
3209 QMatrix m = currentMapEditor()->matrix();
3210 m.scale( 1.25, 1.25 );
3211 currentMapEditor()->setMatrix( m );
3215 void Main::viewZoomOut()
3217 if (currentMapEditor())
3219 QMatrix m = currentMapEditor()->matrix();
3220 m.scale( 0.8, 0.8 );
3221 currentMapEditor()->setMatrix( m );
3225 void Main::viewCenter()
3227 MapEditor *me=currentMapEditor();
3230 me->ensureSelectionVisible();
3234 void Main::networkStartServer()
3236 MapEditor *me=currentMapEditor();
3237 if (me) me->newServer();
3240 void Main::networkConnect()
3242 MapEditor *me=currentMapEditor();
3243 if (me) me->connectToServer();
3246 bool Main::settingsPDF()
3248 // Default browser is set in constructor
3250 QString text = QInputDialog::getText(
3251 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3252 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3254 settings.setValue ("/mainwindow/readerPDF",text);
3259 bool Main::settingsURL()
3261 // Default browser is set in constructor
3263 QString text = QInputDialog::getText(
3264 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3265 settings.value("/mainwindow/readerURL").toString()
3268 settings.setValue ("/mainwindow/readerURL",text);
3272 void Main::settingsMacroDir()
3274 QDir defdir(vymBaseDir.path() + "/macros");
3275 if (!defdir.exists())
3277 QDir dir=QFileDialog::getExistingDirectory (
3279 tr ("Directory with vym macros:"),
3280 settings.value ("/macros/macroDir",defdir.path()).toString()
3283 settings.setValue ("/macros/macroDir",dir.absolutePath());
3286 void Main::settingsUndoLevels()
3289 int i = QInputDialog::getInteger(
3291 tr("QInputDialog::getInteger()"),
3292 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3295 settings.setValue ("/mapeditor/stepsTotal",i);
3296 QMessageBox::information( this, tr( "VYM -Information:" ),
3297 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3301 void Main::settingsAutosaveToggle()
3303 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3306 void Main::settingsAutosaveTime()
3309 int i = QInputDialog::getInteger(
3311 tr("QInputDialog::getInteger()"),
3312 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3314 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3317 void Main::settingsWriteBackupFileToggle()
3319 settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3322 void Main::settingsToggleAnimation()
3324 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3327 void Main::settingsToggleDelKey()
3329 if (actionSettingsUseDelKey->isOn())
3331 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3334 actionEditDelete->setAccel (QKeySequence (""));
3338 void Main::windowToggleNoteEditor()
3340 if (textEditor->isVisible() )
3341 windowHideNoteEditor();
3343 windowShowNoteEditor();
3346 void Main::windowToggleHistory()
3348 if (historyWindow->isVisible())
3349 historyWindow->hide();
3351 historyWindow->show();
3355 void Main::windowToggleProperty()
3357 if (branchPropertyWindow->isVisible())
3358 branchPropertyWindow->hide();
3360 branchPropertyWindow->show();
3362 if(currentMapEditor())
3364 BranchObj *bo=currentMapEditor()->getSelectedBranch();
3367 branchPropertyWindow->setMapEditor(currentMapEditor());
3368 branchPropertyWindow->setBranch(bo);
3373 branchPropertyWindow->setBranch(NULL);
3376 void Main::windowToggleAntiAlias()
3378 bool b=actionViewToggleAntiAlias->isOn();
3380 for (int i=0;i<tabWidget->count();i++)
3383 me=(MapEditor*)tabWidget->page(i);
3384 me->setAntiAlias(b);
3389 void Main::windowToggleSmoothPixmap()
3391 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3393 for (int i=0;i<tabWidget->count();i++)
3396 me=(MapEditor*)tabWidget->page(i);
3397 me->setSmoothPixmap(b);
3401 void Main::updateHistory(SimpleSettings &undoSet)
3403 historyWindow->update (undoSet);
3406 void Main::updateNoteFlag()
3408 if (currentMapEditor())
3409 currentMapEditor()->updateNoteFlag();
3412 void Main::updateSatellites(MapEditor *me)
3414 branchPropertyWindow->setMapEditor (me);
3417 void Main::updateActions()
3419 MapEditor *me=currentMapEditor();
3422 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3424 // updateActions is also called when NoteEditor is closed
3425 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3426 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3427 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3429 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3430 actionFormatLinkColorHint->setOn(true);
3432 actionFormatLinkColorHint->setOn(false);
3434 switch (me->getMapLinkStyle())
3436 case LinkableMapObj::Line:
3437 actionFormatLinkStyleLine->setOn(true);
3439 case LinkableMapObj::Parabel:
3440 actionFormatLinkStyleParabel->setOn(true);
3442 case LinkableMapObj::PolyLine:
3443 actionFormatLinkStylePolyLine->setOn(true);
3445 case LinkableMapObj::PolyParabel:
3446 actionFormatLinkStylePolyParabel->setOn(true);
3453 QPixmap pix( 16, 16 );
3454 pix.fill( me->getMapBackgroundColor() );
3455 actionFormatBackColor->setIconSet( pix );
3456 pix.fill( me->getSelectionColor() );
3457 actionFormatSelectionColor->setIconSet( pix );
3458 pix.fill( me->getMapDefLinkColor() );
3459 actionFormatLinkColor->setIconSet( pix );
3462 actionFileSave->setEnabled( me->hasChanged() );
3463 if (me->isUndoAvailable())
3464 actionEditUndo->setEnabled( true);
3466 actionEditUndo->setEnabled( false);
3468 if (me->isRedoAvailable())
3469 actionEditRedo->setEnabled( true);
3471 actionEditRedo->setEnabled( false);
3473 LinkableMapObj *selection=me->getSelection();
3476 if ( (typeid(*selection) == typeid(BranchObj)) ||
3477 (typeid(*selection) == typeid(MapCenterObj)) )
3479 BranchObj *bo=(BranchObj*)selection;
3480 // Take care of links
3481 if (bo->countXLinks()==0)
3483 branchXLinksContextMenuEdit->clear();
3484 branchXLinksContextMenuFollow->clear();
3489 branchXLinksContextMenuEdit->clear();
3490 branchXLinksContextMenuFollow->clear();
3491 for (int i=0; i<=bo->countXLinks();i++)
3493 bot=bo->XLinkTargetAt(i);
3496 s=bot->getHeading();
3497 if (s.length()>xLinkMenuWidth)
3498 s=s.left(xLinkMenuWidth)+"...";
3499 branchXLinksContextMenuFollow->addAction (s);
3500 branchXLinksContextMenuEdit->addAction (s);
3505 standardFlagsDefault->setEnabled (true);
3507 actionEditToggleScroll->setEnabled (true);
3508 if ( bo->isScrolled() )
3509 actionEditToggleScroll->setOn(true);
3511 actionEditToggleScroll->setOn(false);
3513 if ( bo->getURL().isEmpty() )
3515 actionEditOpenURL->setEnabled (false);
3516 actionEditOpenURLTab->setEnabled (false);
3520 actionEditOpenURL->setEnabled (true);
3521 actionEditOpenURLTab->setEnabled (true);
3523 if ( bo->getVymLink().isEmpty() )
3525 actionEditOpenVymLink->setEnabled (false);
3526 actionEditDeleteVymLink->setEnabled (false);
3529 actionEditOpenVymLink->setEnabled (true);
3530 actionEditDeleteVymLink->setEnabled (true);
3533 if (bo->canMoveBranchUp())
3534 actionEditMoveUp->setEnabled (true);
3536 actionEditMoveUp->setEnabled (false);
3537 if (bo->canMoveBranchDown())
3538 actionEditMoveDown->setEnabled (true);
3540 actionEditMoveDown->setEnabled (false);
3543 actionEditToggleHideExport->setEnabled (true);
3544 actionEditToggleHideExport->setOn (bo->hideInExport() );
3546 actionEditCopy->setEnabled (true);
3547 actionEditCut->setEnabled (true);
3548 if (!clipboardEmpty)
3549 actionEditPaste->setEnabled (true);
3551 actionEditPaste->setEnabled (false);
3552 for (int i=0; i<actionListBranches.size(); ++i)
3553 actionListBranches.at(i)->setEnabled(true);
3554 actionEditDelete->setEnabled (true);
3555 actionFormatHideLinkUnselected->setOn
3556 (selection->getHideLinkUnselected());
3558 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3560 FloatObj *fo=(FloatImageObj*)selection;
3562 actionEditOpenURL->setEnabled (false);
3563 actionEditOpenVymLink->setEnabled (false);
3564 actionEditDeleteVymLink->setEnabled (false);
3565 actionEditToggleHideExport->setEnabled (true);
3566 actionEditToggleHideExport->setOn (fo->hideInExport() );
3569 actionEditCopy->setEnabled (true);
3570 actionEditCut->setEnabled (true);
3571 actionEditPaste->setEnabled (false);
3572 for (int i=0; i<actionListBranches.size(); ++i)
3573 actionListBranches.at(i)->setEnabled(false);
3574 actionEditDelete->setEnabled (true);
3575 actionFormatHideLinkUnselected->setOn
3576 ( selection->getHideLinkUnselected());
3577 actionEditMoveUp->setEnabled (false);
3578 actionEditMoveDown->setEnabled (false);
3583 actionEditCopy->setEnabled (false);
3584 actionEditCut->setEnabled (false);
3585 actionEditPaste->setEnabled (false);
3586 for (int i=0; i<actionListBranches.size(); ++i)
3587 actionListBranches.at(i)->setEnabled(false);
3589 actionEditToggleScroll->setEnabled (false);
3590 actionEditOpenURL->setEnabled (false);
3591 actionEditOpenVymLink->setEnabled (false);
3592 actionEditDeleteVymLink->setEnabled (false);
3593 actionEditHeading2URL->setEnabled (false);
3594 actionEditDelete->setEnabled (false);
3595 actionEditMoveUp->setEnabled (false);
3596 actionEditMoveDown->setEnabled (false);
3597 actionEditToggleHideExport->setEnabled (false);
3601 Main::ModMode Main::getModMode()
3603 if (actionModModeColor->isOn()) return ModModeColor;
3604 if (actionModModeCopy->isOn()) return ModModeCopy;
3605 if (actionModModeXLink->isOn()) return ModModeXLink;
3609 bool Main::autoEditNewBranch()
3611 return actionSettingsAutoEditNewBranch->isOn();
3614 bool Main::autoSelectNewBranch()
3616 return actionSettingsAutoSelectNewBranch->isOn();
3619 bool Main::useFlagGroups()
3621 return actionSettingsUseFlagGroups->isOn();
3624 void Main::windowShowNoteEditor()
3626 textEditor->setShowWithMain(true);
3628 actionViewToggleNoteEditor->setOn (true);
3631 void Main::windowHideNoteEditor()
3633 textEditor->setShowWithMain(false);
3635 actionViewToggleNoteEditor->setOn (false);
3638 void Main::setScript (const QString &script)
3640 scriptEditor->setScript (script);
3643 void Main::runScript (const QString &script)
3645 if (currentMapEditor())
3646 currentMapEditor()->runScript (script);
3649 void Main::runScriptEverywhere (const QString &script)
3652 for (int i=0;i<=tabWidget->count() -1;i++)
3654 me=(MapEditor*)tabWidget->page(i);
3655 if (me) me->runScript (script);
3659 void Main::windowNextEditor()
3661 if (tabWidget->currentPageIndex() < tabWidget->count())
3662 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3665 void Main::windowPreviousEditor()
3667 if (tabWidget->currentPageIndex() >0)
3668 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3671 void Main::standardFlagChanged()
3673 if (currentMapEditor())
3674 currentMapEditor()->toggleStandardFlag(sender()->name());
3677 void Main::testFunction1()
3679 if (!currentMapEditor()) return;
3680 currentMapEditor()->testFunction1();
3684 void Main::testFunction2()
3686 if (!currentMapEditor()) return;
3687 currentMapEditor()->testFunction2();
3690 void Main::testCommand()
3692 if (!currentMapEditor()) return;
3693 scriptEditor->show();
3696 QString com = QInputDialog::getText(
3697 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3698 if (ok) currentMapEditor()->parseAtom(com);
3702 void Main::helpDoc()
3704 QString locale = QLocale::system().name();
3706 if (locale.left(2)=="es")
3707 docname="vym_es.pdf";
3711 QStringList searchList;
3713 #if defined(Q_OS_MACX)
3714 searchList << "./vym.app/Contents/Resources/doc";
3715 #elif defined(Q_OS_WIN32)
3716 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3718 #if defined(VYM_DOCDIR)
3719 searchList << VYM_DOCDIR;
3721 // default path in SUSE LINUX
3722 searchList << "/usr/share/doc/packages/vym";
3725 searchList << "doc"; // relative path for easy testing in tarball
3726 searchList << "doc/tex"; // Easy testing working on vym.tex
3727 searchList << "/usr/share/doc/vym"; // Debian
3728 searchList << "/usr/share/doc/packages";// Knoppix
3732 for (int i=0; i<searchList.count(); ++i)
3734 docfile.setFileName(searchList.at(i)+"/"+docname);
3735 if (docfile.exists())
3744 QMessageBox::critical(0,
3745 tr("Critcal error"),
3746 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3751 Process *pdfProc = new Process();
3752 args << QDir::toNativeSeparators(docfile.fileName());
3754 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3755 if ( !pdfProc->waitForStarted() )
3758 QMessageBox::warning(0,
3760 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3761 tr("Please use Settings->")+tr("Set application to open PDF files"));
3768 void Main::helpDemo()
3770 QStringList filters;
3771 filters <<"VYM example map (*.vym)";
3772 QFileDialog *fd=new QFileDialog( this);
3773 #if defined(Q_OS_MACX)
3774 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3776 // default path in SUSE LINUX
3777 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3780 fd->setFileMode (QFileDialog::ExistingFiles);
3781 fd->setFilters (filters);
3782 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3786 if ( fd->exec() == QDialog::Accepted )
3788 lastFileDir=fd->directory().path();
3789 QStringList flist = fd->selectedFiles();
3790 QStringList::Iterator it = flist.begin();
3791 while( it != flist.end() )
3794 fileLoad(*it, NewMap);
3802 void Main::helpAbout()
3805 ad.setName ("aboutwindow");
3806 ad.setMinimumSize(500,500);
3807 ad.resize (QSize (500,500));
3811 void Main::helpAboutQT()
3813 QMessageBox::aboutQt( this, "Qt Application Example" );
3816 void Main::callMacro ()
3818 QAction *action = qobject_cast<QAction *>(sender());
3822 i=action->data().toInt();
3823 QString mDir (settings.value ("macros/macroDir").toString() );
3825 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3827 if ( !f.open( QIODevice::ReadOnly ) )
3829 QMessageBox::warning(0,
3831 tr("Couldn't find a macro at %1.\n").arg(fn)+
3832 tr("Please use Settings->")+tr("Set directory for vym macros"));
3836 QTextStream ts( &f );
3837 QString m= ts.read();
3841 //cout <<"Main::callMacro m="<<qPrintable (m)<<endl;
3842 currentMapEditor()->runScript (m);
3849 //////////////////////////////////
3851 @@ -2544,18 +2576,27 @@
3852 // Try to open new tab in existing konqueror started previously by vym
3853 p=new QProcess (this);
3855 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3856 - "konqueror-mainwindow#1"<<
3858 +#if defined(Q_OS_WIN32)
3859 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3860 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3861 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3862 + "konqueror-mainwindow#1"<<
3866 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3867 + "konqueror-mainwindow#1"<<
3871 p->start ("dcop",args);
3872 if ( !p->waitForStarted() ) success=false;