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 = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2008 fn = Q3FileDialog::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 Q3FileDialog *fd=new Q3FileDialog( this);
2079 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2080 fd->setMode (Q3FileDialog::ExistingFiles);
2081 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2082 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2085 if ( fd->exec() == QDialog::Accepted )
2087 ImportFirefoxBookmarks im;
2088 QStringList flist = fd->selectedFiles();
2089 QStringList::Iterator it = flist.begin();
2090 while( it != flist.end() )
2093 if (im.transform() &&
2094 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2095 currentMapEditor() )
2096 currentMapEditor()->setFilePath ("");
2103 void Main::fileImportFreemind()
2105 QStringList filters;
2106 filters <<"Freemind map (*.mm)"<<"All files (*)";
2107 QFileDialog *fd=new QFileDialog( this);
2108 fd->setDir (lastFileDir);
2109 fd->setFileMode (QFileDialog::ExistingFiles);
2110 fd->setFilters (filters);
2111 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2115 if ( fd->exec() == QDialog::Accepted )
2117 lastFileDir=fd->directory().path();
2118 QStringList flist = fd->selectedFiles();
2119 QStringList::Iterator it = flist.begin();
2120 while( it != flist.end() )
2123 if ( fileLoad (fn,NewMap, FreemindMap) )
2125 currentMapEditor()->setFilePath ("");
2134 void Main::fileImportMM()
2138 Q3FileDialog *fd=new Q3FileDialog( this);
2139 fd->setDir (lastFileDir);
2140 fd->setMode (Q3FileDialog::ExistingFiles);
2141 fd->addFilter ("Mind Manager (*.mmap)");
2142 fd->setCaption(tr("Import")+" "+"Mind Manager");
2145 if ( fd->exec() == QDialog::Accepted )
2147 lastFileDir=fd->dirPath();
2148 QStringList flist = fd->selectedFiles();
2149 QStringList::Iterator it = flist.begin();
2150 while( it != flist.end() )
2153 if (im.transform() &&
2154 success==fileLoad (im.getTransformedFile(),NewMap) &&
2155 currentMapEditor() )
2156 currentMapEditor()->setFilePath ("");
2165 void Main::fileImportDir()
2167 if (currentMapEditor())
2168 currentMapEditor()->importDir();
2171 void Main::fileExportXML()
2173 MapEditor *me=currentMapEditor();
2174 if (me) me->exportXML();
2178 void Main::fileExportXHTML()
2180 MapEditor *me=currentMapEditor();
2181 if (me) me->exportXHTML();
2184 void Main::fileExportImage()
2186 MapEditor *me=currentMapEditor();
2187 if (me) me->exportImage();
2190 void Main::fileExportASCII()
2192 MapEditor *me=currentMapEditor();
2193 if (me) me->exportASCII();
2196 void Main::fileExportCSV() //FIXME not scriptable yet
2198 MapEditor *me=currentMapEditor();
2202 ex.setModel (me->getModel());
2203 ex.addFilter ("CSV (*.csv)");
2204 ex.setDir(lastImageDir);
2205 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2206 if (ex.execDialog() )
2208 me->setExportMode(true);
2210 me->setExportMode(false);
2215 void Main::fileExportLaTeX() //FIXME not scriptable yet
2217 MapEditor *me=currentMapEditor();
2221 ex.setModel (me->getModel());
2222 ex.addFilter ("Tex (*.tex)");
2223 ex.setDir(lastImageDir);
2224 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2225 if (ex.execDialog() )
2227 me->setExportMode(true);
2229 me->setExportMode(false);
2234 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2236 ExportKDEBookmarks ex;
2237 MapEditor *me=currentMapEditor();
2240 ex.setModel (me->getModel());
2245 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2247 ExportTaskjuggler ex;
2248 MapEditor *me=currentMapEditor();
2251 ex.setModel (me->getModel());
2252 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2253 ex.setDir(lastImageDir);
2254 ex.addFilter ("Taskjuggler (*.tjp)");
2255 if (ex.execDialog() )
2257 me->setExportMode(true);
2259 me->setExportMode(false);
2264 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2266 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2267 // TODO add preview in dialog
2268 //ImagePreview *p =new ImagePreview (fd);
2269 //fd->setContentsPreviewEnabled( TRUE );
2270 //fd->setContentsPreview( p, p );
2271 //fd->setPreviewMode( QFileDialog::Contents );
2272 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2273 fd->setDir (QDir().current());
2274 if (fd->foundConfig())
2278 if ( fd->exec() == QDialog::Accepted )
2280 QString fn=fd->selectedFile();
2281 if (!fn.contains (".odp"))
2284 //lastImageDir=fn.left(fn.findRev ("/"));
2285 if (currentMapEditor())
2286 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2290 QMessageBox::warning(0,
2292 tr("Couldn't find configuration for export to Open Office\n"));
2296 void Main::fileCloseMap()
2298 MapEditor *me = currentMapEditor();
2301 if (me->hasChanged())
2303 QMessageBox mb( vymName,
2304 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
2305 QMessageBox::Warning,
2306 QMessageBox::Yes | QMessageBox::Default,
2308 QMessageBox::Cancel | QMessageBox::Escape );
2309 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2310 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2313 case QMessageBox::Yes:
2315 fileSave(me, CompleteMap);
2317 case QMessageBox::No:
2318 // close without saving
2320 case QMessageBox::Cancel:
2326 tabWidget->removePage(me);
2327 if (tabWidget->count()==0)
2328 actionFilePrint->setEnabled (false);
2335 void Main::filePrint()
2337 if (currentMapEditor())
2338 currentMapEditor()->print();
2341 void Main::fileExitVYM()
2343 // Check if one or more editors have changed
2346 for (i=0;i<=tabWidget->count() -1;i++)
2349 me=(MapEditor*)tabWidget->page(i);
2351 // If something changed, ask what to do
2352 if (me->hasChanged())
2354 tabWidget->setCurrentPage(i);
2355 QMessageBox mb( vymName,
2356 tr("This map is not saved yet. Do you want to"),
2357 QMessageBox::Warning,
2358 QMessageBox::Yes | QMessageBox::Default,
2360 QMessageBox::Cancel | QMessageBox::Escape );
2361 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2362 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2365 mb.setActiveWindow();
2366 switch( mb.exec() ) {
2367 case QMessageBox::Yes:
2368 // save (the changed editors) and exit
2369 fileSave(currentMapEditor(), CompleteMap);
2371 case QMessageBox::No:
2372 // exit without saving
2374 case QMessageBox::Cancel:
2375 // don't save and don't exit
2379 } // loop over all MEs
2383 void Main::editUndo()
2385 if (currentMapEditor())
2386 currentMapEditor()->undo();
2389 void Main::editRedo()
2391 if (currentMapEditor())
2392 currentMapEditor()->redo();
2395 void Main::gotoHistoryStep (int i)
2397 if (currentMapEditor())
2398 currentMapEditor()->gotoHistoryStep (i);
2401 void Main::editCopy()
2403 if (currentMapEditor())
2404 currentMapEditor()->copy();
2407 void Main::editPaste()
2409 if (currentMapEditor())
2410 currentMapEditor()->paste();
2413 void Main::editCut()
2415 if (currentMapEditor())
2416 currentMapEditor()->cut();
2419 void Main::editOpenFindWindow()
2421 findWindow->popup();
2422 findWindow->raise();
2423 findWindow->setActiveWindow();
2426 void Main::editFind(QString s)
2429 BranchObj *bo=currentMapEditor()->findText(s, cs);
2432 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2435 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2436 tr("No matches found for \"%1\"").arg(s));
2440 void Main::editFindChanged()
2441 { // Notify editor, to abort the current find process
2442 currentMapEditor()->findReset();
2445 void Main::openTabs(QStringList urls)
2447 if (!urls.isEmpty())
2451 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2453 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2455 QString u=urls.takeFirst();
2456 procBrowser = new QProcess( this );
2458 procBrowser->start(browser,args);
2459 if ( !procBrowser->waitForStarted())
2461 // try to set path to browser
2462 QMessageBox::warning(0,
2464 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2465 tr("Please use Settings->")+tr("Set application to open an URL"));
2468 #if defined(Q_OS_WIN32)
2469 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2470 this->thread()->wait(3000);
2475 if (browser.contains("konqueror"))
2477 for (int i=0; i<urls.size(); i++)
2480 // Try to open new tab in existing konqueror started previously by vym
2481 p=new QProcess (this);
2483 #if defined(Q_OS_WIN32)
2484 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2485 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2486 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2487 "konqueror-mainwindow#1"<<
2491 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2492 "konqueror-mainwindow#1"<<
2496 p->start ("dcop",args);
2497 //cout << qPrintable (args.join(" "))<<endl;
2498 if ( !p->waitForStarted() ) success=false;
2501 QMessageBox::warning(0,
2503 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2505 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2507 for (int i=0; i<urls.size(); i++)
2509 // Try to open new tab in firefox
2510 p=new QProcess (this);
2511 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2512 p->start (browser,args);
2513 if ( !p->waitForStarted() ) success=false;
2516 QMessageBox::warning(0,
2518 tr("Couldn't start %1 to open a new tab").arg(browser));
2521 QMessageBox::warning(0,
2523 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2527 void Main::editOpenURL()
2530 if (currentMapEditor())
2532 QString url=currentMapEditor()->getURL();
2534 if (url=="") return;
2535 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2536 procBrowser = new QProcess( this );
2538 procBrowser->start(browser,args);
2539 if ( !procBrowser->waitForStarted())
2541 // try to set path to browser
2542 QMessageBox::warning(0,
2544 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2545 tr("Please use Settings->")+tr("Set application to open an URL"));
2550 void Main::editOpenURLTab()
2552 if (currentMapEditor())
2555 urls.append(currentMapEditor()->getURL());
2559 void Main::editOpenMultipleURLTabs()
2561 if (currentMapEditor())
2564 urls=currentMapEditor()->getURLs();
2570 void Main::editURL()
2572 if (currentMapEditor())
2573 currentMapEditor()->editURL();
2576 void Main::editLocalURL()
2578 if (currentMapEditor())
2579 currentMapEditor()->editLocalURL();
2582 void Main::editHeading2URL()
2584 if (currentMapEditor())
2585 currentMapEditor()->editHeading2URL();
2588 void Main::editBugzilla2URL()
2590 if (currentMapEditor())
2591 currentMapEditor()->editBugzilla2URL();
2594 void Main::editFATE2URL()
2596 if (currentMapEditor())
2597 currentMapEditor()->editFATE2URL();
2600 void Main::editHeadingFinished()
2602 // only called from editHeading(), so there is a currentME
2603 MapEditor *me=currentMapEditor();
2606 me->setStateEditHeading (false);
2607 QPoint p; //Not used here, only to find out pos of branch
2609 QString s=me->getHeading(ok,p);
2611 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2613 if (ok && s!=lineedit->text())
2614 me->setHeading(lineedit->text());
2616 lineedit->releaseKeyboard();
2620 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2621 !prevSelection.isEmpty())
2622 me->select(prevSelection);
2627 void Main::editHeading()
2629 if (currentMapEditor())
2631 MapEditor *me=currentMapEditor();
2632 QString oldSel=me->getSelectString();
2634 if (lineedit->isVisible())
2635 editHeadingFinished();
2640 QString s=me->getHeading(ok,p);
2644 me->setStateEditHeading (true);
2645 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2646 p=me->mapToGlobal (p);
2647 QDialog *d =new QDialog(NULL);
2648 QLineEdit *le=new QLineEdit (d);
2649 d->setWindowFlags (Qt::FramelessWindowHint);
2650 d->setGeometry(p.x(),p.y(),230,25);
2651 le->resize (d->width()-10,d->height());
2654 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2655 d->activateWindow();
2657 me->setHeading (le->text());
2660 editHeadingFinished();
2662 p=me->mapTo (this,p);
2663 lineedit->setGeometry(p.x(),p.y(),230,25);
2664 lineedit->setText(s);
2665 lineedit->setCursorPosition(1);
2666 lineedit->selectAll();
2668 lineedit->grabKeyboard();
2669 lineedit->setFocus();
2673 } // currentMapEditor()
2676 void Main::editAttributeFinished()
2678 // only called from editHeading(), so there is a currentME
2681 MapEditor *me=currentMapEditor();
2684 me->setStateEditHeading (false);
2685 QPoint p; //Not used here, only to find out pos of branch
2687 QString s=me->getHeading(ok,p);
2689 #if defined(Q_OS_MACX)
2691 if (ok && s!=lineedit->text())
2692 me->setHeading(lineedit->text());
2694 lineedit->releaseKeyboard();
2698 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2699 !prevSelection.isEmpty())
2700 me->select(prevSelection);
2706 #include "attribute.h"
2707 #include "attributedialog.h"
2708 void Main::editAttribute()
2710 MapEditor *me=currentMapEditor();
2713 BranchObj *bo=me->getSelectedBranch();
2716 AttributeDialog dia(this);
2717 dia.setTable (me->attributeTable() );
2719 dia.setMode (Definition);
2725 if (currentMapEditor())
2727 MapEditor *me=currentMapEditor();
2728 QString oldSel=me->getSelectString();
2730 if (lineedit->isVisible())
2731 editAttributeFinished();
2736 QString s=me->getHeading(ok,p);
2740 me->setStateEditHeading (true);
2741 #if defined(Q_OS_MACX)
2742 p=me->mapToGlobal (p);
2743 QDialog *d =new QDialog(NULL);
2744 QLineEdit *le=new QLineEdit (d);
2745 d->setWindowFlags (Qt::FramelessWindowHint);
2746 d->setGeometry(p.x(),p.y(),230,25);
2747 le->resize (d->width()-10,d->height());
2750 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2751 d->activateWindow();
2753 me->setHeading (le->text());
2756 editHeadingFinished();
2758 p=me->mapTo (this,p);
2759 lineedit->setGeometry(p.x(),p.y(),230,25);
2760 lineedit->setText(s);
2761 lineedit->setCursorPosition(1);
2762 lineedit->selectAll();
2764 lineedit->grabKeyboard();
2765 lineedit->setFocus();
2769 } // currentMapEditor()
2774 void Main::openVymLinks(const QStringList &vl)
2776 for (int j=0; j<vl.size(); j++)
2778 // compare path with already loaded maps
2782 for (i=0;i<=tabWidget->count() -1;i++)
2784 me=(MapEditor*)tabWidget->page(i);
2785 if (vl.at(j)==me->getFilePath() )
2794 if (!QFile(vl.at(j)).exists() )
2795 QMessageBox::critical( 0, tr( "Critical Error" ),
2796 tr("Couldn't open map %1").arg(vl.at(j)));
2799 fileLoad (vl.at(j), NewMap);
2800 tabWidget->setCurrentPage (tabWidget->count()-1);
2803 // Go to tab containing the map
2804 tabWidget->setCurrentPage (index);
2808 void Main::editOpenVymLink()
2810 if (currentMapEditor())
2813 vl.append(currentMapEditor()->getVymLink());
2818 void Main::editOpenMultipleVymLinks()
2820 QString currentVymLink;
2821 if (currentMapEditor())
2823 QStringList vl=currentMapEditor()->getVymLinks();
2828 void Main::editVymLink()
2830 if (currentMapEditor())
2831 currentMapEditor()->editVymLink();
2834 void Main::editDeleteVymLink()
2836 if (currentMapEditor())
2837 currentMapEditor()->deleteVymLink();
2840 void Main::editToggleHideExport()
2842 if (currentMapEditor())
2843 currentMapEditor()->toggleHideExport();
2846 void Main::editMapInfo()
2848 if (currentMapEditor())
2849 currentMapEditor()->editMapInfo();
2852 void Main::editMoveUp()
2854 if (currentMapEditor())
2855 currentMapEditor()->moveBranchUp();
2858 void Main::editMoveDown()
2860 if (currentMapEditor())
2861 currentMapEditor()->moveBranchDown();
2864 void Main::editSortChildren()
2866 if (currentMapEditor())
2867 currentMapEditor()->sortChildren();
2870 void Main::editToggleScroll()
2872 if (currentMapEditor())
2874 currentMapEditor()->toggleScroll();
2878 void Main::editUnscrollChilds()
2880 if (currentMapEditor())
2881 currentMapEditor()->unscrollChilds();
2884 void Main::editAddMapCenter()
2886 MapEditor *me=currentMapEditor();
2887 if (!lineedit->isVisible() && me)
2889 me->addMapCenter ();
2893 void Main::editNewBranch()
2895 MapEditor *me=currentMapEditor();
2896 if (!lineedit->isVisible() && me)
2898 BranchObj *bo=(BranchObj*)me->getSelection();
2899 BranchObj *newbo=me->addNewBranch(0);
2901 prevSelection=me->getModel()->getSelectString(bo);
2907 if (actionSettingsAutoEditNewBranch->isOn())
2912 if (!prevSelection.isEmpty())
2914 me->select(prevSelection);
2921 void Main::editNewBranchBefore()
2923 MapEditor *me=currentMapEditor();
2924 if (!lineedit->isVisible() && me)
2926 BranchObj *bo=(BranchObj*)me->getSelection();
2927 BranchObj *newbo=me->addNewBranchBefore();
2934 if (actionSettingsAutoEditNewBranch->isOn())
2936 if (!actionSettingsAutoSelectNewBranch->isOn())
2937 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2943 void Main::editNewBranchAbove()
2945 MapEditor *me=currentMapEditor();
2946 if (!lineedit->isVisible() && me)
2948 BranchObj *bo=(BranchObj*)me->getSelection();
2949 BranchObj *newbo=me->addNewBranch (-1);
2956 if (actionSettingsAutoEditNewBranch->isOn())
2958 if (!actionSettingsAutoSelectNewBranch->isOn())
2959 prevSelection=me->getModel()->getSelectString (bo); // TODO access directly
2965 void Main::editNewBranchBelow()
2967 MapEditor *me=currentMapEditor();
2968 if (!lineedit->isVisible() && me)
2970 BranchObj *bo=(BranchObj*)me->getSelection();
2971 BranchObj *newbo=me->addNewBranch (1);
2978 if (actionSettingsAutoEditNewBranch->isOn())
2980 if (!actionSettingsAutoSelectNewBranch->isOn())
2981 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2987 void Main::editImportAdd()
2989 fileLoad (ImportAdd);
2992 void Main::editImportReplace()
2994 fileLoad (ImportReplace);
2997 void Main::editSaveBranch()
2999 fileSaveAs (PartOfMap);
3002 void Main::editDeleteKeepChilds()
3004 if (currentMapEditor())
3005 currentMapEditor()->deleteKeepChilds();
3008 void Main::editDeleteChilds()
3010 if (currentMapEditor())
3011 currentMapEditor()->deleteChilds();
3014 void Main::editDeleteSelection()
3016 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3017 currentMapEditor()->deleteSelection();
3020 void Main::editUpperBranch()
3022 if (currentMapEditor())
3023 currentMapEditor()->selectUpperBranch();
3026 void Main::editLowerBranch()
3028 if (currentMapEditor())
3029 currentMapEditor()->selectLowerBranch();
3032 void Main::editLeftBranch()
3034 if (currentMapEditor())
3035 currentMapEditor()->selectLeftBranch();
3038 void Main::editRightBranch()
3040 if (currentMapEditor())
3041 currentMapEditor()->selectRightBranch();
3044 void Main::editFirstBranch()
3046 if (currentMapEditor())
3047 currentMapEditor()->selectFirstBranch();
3050 void Main::editLastBranch()
3052 if (currentMapEditor())
3053 currentMapEditor()->selectLastBranch();
3056 void Main::editLoadImage()
3058 if (currentMapEditor())
3059 currentMapEditor()->loadFloatImage();
3062 void Main::editSaveImage()
3064 if (currentMapEditor())
3065 currentMapEditor()->saveFloatImage();
3068 void Main::editFollowXLink(QAction *a)
3071 if (currentMapEditor())
3072 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3075 void Main::editEditXLink(QAction *a)
3077 if (currentMapEditor())
3078 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3081 void Main::formatSelectColor()
3083 if (currentMapEditor())
3085 QColor col = QColorDialog::getColor((currentColor ), this );
3086 if ( !col.isValid() ) return;
3087 colorChanged( col );
3091 void Main::formatPickColor()
3093 if (currentMapEditor())
3094 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3097 void Main::colorChanged(QColor c)
3099 QPixmap pix( 16, 16 );
3101 actionFormatColor->setIconSet( pix );
3105 void Main::formatColorBranch()
3107 if (currentMapEditor())
3108 currentMapEditor()->colorBranch(currentColor);
3111 void Main::formatColorSubtree()
3113 if (currentMapEditor())
3114 currentMapEditor()->colorSubtree (currentColor);
3117 void Main::formatLinkStyleLine()
3119 if (currentMapEditor())
3121 currentMapEditor()->setMapLinkStyle("StyleLine");
3122 actionFormatLinkStyleLine->setOn(true);
3126 void Main::formatLinkStyleParabel()
3128 if (currentMapEditor())
3130 currentMapEditor()->setMapLinkStyle("StyleParabel");
3131 actionFormatLinkStyleParabel->setOn(true);
3135 void Main::formatLinkStylePolyLine()
3137 if (currentMapEditor())
3139 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3140 actionFormatLinkStylePolyLine->setOn(true);
3144 void Main::formatLinkStylePolyParabel()
3146 if (currentMapEditor())
3148 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3149 actionFormatLinkStylePolyParabel->setOn(true);
3153 void Main::formatSelectBackColor()
3155 if (currentMapEditor())
3156 currentMapEditor()->selectMapBackgroundColor();
3159 void Main::formatSelectBackImage()
3161 if (currentMapEditor())
3162 currentMapEditor()->selectMapBackgroundImage();
3165 void Main::formatSelectLinkColor()
3167 if (currentMapEditor())
3168 currentMapEditor()->selectMapLinkColor();
3171 void Main::formatSelectSelectionColor()
3173 if (currentMapEditor())
3174 currentMapEditor()->selectMapSelectionColor();
3177 void Main::formatToggleLinkColorHint()
3179 currentMapEditor()->toggleMapLinkColorHint();
3183 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3185 if (currentMapEditor())
3186 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3189 void Main::viewZoomReset()
3191 if (currentMapEditor())
3195 currentMapEditor()->setMatrix( m );
3199 void Main::viewZoomIn()
3201 if (currentMapEditor())
3203 QMatrix m = currentMapEditor()->matrix();
3204 m.scale( 1.25, 1.25 );
3205 currentMapEditor()->setMatrix( m );
3209 void Main::viewZoomOut()
3211 if (currentMapEditor())
3213 QMatrix m = currentMapEditor()->matrix();
3214 m.scale( 0.8, 0.8 );
3215 currentMapEditor()->setMatrix( m );
3219 void Main::viewCenter()
3221 MapEditor *me=currentMapEditor();
3224 me->ensureSelectionVisible();
3228 void Main::networkStartServer()
3230 MapEditor *me=currentMapEditor();
3231 if (me) me->newServer();
3234 void Main::networkConnect()
3236 MapEditor *me=currentMapEditor();
3237 if (me) me->connectToServer();
3240 bool Main::settingsPDF()
3242 // Default browser is set in constructor
3244 QString text = QInputDialog::getText(
3245 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3246 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3248 settings.setValue ("/mainwindow/readerPDF",text);
3253 bool Main::settingsURL()
3255 // Default browser is set in constructor
3257 QString text = QInputDialog::getText(
3258 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3259 settings.value("/mainwindow/readerURL").toString()
3262 settings.setValue ("/mainwindow/readerURL",text);
3266 void Main::settingsMacroDir()
3268 QDir defdir(vymBaseDir.path() + "/macros");
3269 if (!defdir.exists())
3271 QDir dir=QFileDialog::getExistingDirectory (
3273 tr ("Directory with vym macros:"),
3274 settings.value ("/macros/macroDir",defdir.path()).toString()
3277 settings.setValue ("/macros/macroDir",dir.absolutePath());
3280 void Main::settingsUndoLevels()
3283 int i = QInputDialog::getInteger(
3285 tr("QInputDialog::getInteger()"),
3286 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3289 settings.setValue ("/mapeditor/stepsTotal",i);
3290 QMessageBox::information( this, tr( "VYM -Information:" ),
3291 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3295 void Main::settingsAutosaveToggle()
3297 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3300 void Main::settingsAutosaveTime()
3303 int i = QInputDialog::getInteger(
3305 tr("QInputDialog::getInteger()"),
3306 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3308 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3311 void Main::settingsWriteBackupFileToggle()
3313 settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3316 void Main::settingsToggleAnimation()
3318 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3321 void Main::settingsToggleDelKey()
3323 if (actionSettingsUseDelKey->isOn())
3325 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3328 actionEditDelete->setAccel (QKeySequence (""));
3332 void Main::windowToggleNoteEditor()
3334 if (textEditor->isVisible() )
3335 windowHideNoteEditor();
3337 windowShowNoteEditor();
3340 void Main::windowToggleHistory()
3342 if (historyWindow->isVisible())
3343 historyWindow->hide();
3345 historyWindow->show();
3349 void Main::windowToggleProperty()
3351 if (branchPropertyWindow->isVisible())
3352 branchPropertyWindow->hide();
3354 branchPropertyWindow->show();
3356 if(currentMapEditor())
3358 BranchObj *bo=currentMapEditor()->getSelectedBranch();
3361 branchPropertyWindow->setMapEditor(currentMapEditor());
3362 branchPropertyWindow->setBranch(bo);
3367 branchPropertyWindow->setBranch(NULL);
3370 void Main::windowToggleAntiAlias()
3372 bool b=actionViewToggleAntiAlias->isOn();
3374 for (int i=0;i<tabWidget->count();i++)
3377 me=(MapEditor*)tabWidget->page(i);
3378 me->setAntiAlias(b);
3383 void Main::windowToggleSmoothPixmap()
3385 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3387 for (int i=0;i<tabWidget->count();i++)
3390 me=(MapEditor*)tabWidget->page(i);
3391 me->setSmoothPixmap(b);
3395 void Main::updateHistory(SimpleSettings &undoSet)
3397 historyWindow->update (undoSet);
3400 void Main::updateNoteFlag()
3402 if (currentMapEditor())
3403 currentMapEditor()->updateNoteFlag();
3406 void Main::updateSatellites(MapEditor *me)
3408 branchPropertyWindow->setMapEditor (me);
3411 void Main::updateActions()
3413 MapEditor *me=currentMapEditor();
3416 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3418 // updateActions is also called when NoteEditor is closed
3419 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3420 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3421 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3423 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3424 actionFormatLinkColorHint->setOn(true);
3426 actionFormatLinkColorHint->setOn(false);
3428 switch (me->getMapLinkStyle())
3430 case LinkableMapObj::Line:
3431 actionFormatLinkStyleLine->setOn(true);
3433 case LinkableMapObj::Parabel:
3434 actionFormatLinkStyleParabel->setOn(true);
3436 case LinkableMapObj::PolyLine:
3437 actionFormatLinkStylePolyLine->setOn(true);
3439 case LinkableMapObj::PolyParabel:
3440 actionFormatLinkStylePolyParabel->setOn(true);
3447 QPixmap pix( 16, 16 );
3448 pix.fill( me->getMapBackgroundColor() );
3449 actionFormatBackColor->setIconSet( pix );
3450 pix.fill( me->getSelectionColor() );
3451 actionFormatSelectionColor->setIconSet( pix );
3452 pix.fill( me->getMapDefLinkColor() );
3453 actionFormatLinkColor->setIconSet( pix );
3456 actionFileSave->setEnabled( me->hasChanged() );
3457 if (me->isUndoAvailable())
3458 actionEditUndo->setEnabled( true);
3460 actionEditUndo->setEnabled( false);
3462 if (me->isRedoAvailable())
3463 actionEditRedo->setEnabled( true);
3465 actionEditRedo->setEnabled( false);
3467 LinkableMapObj *selection=me->getSelection();
3470 if ( (typeid(*selection) == typeid(BranchObj)) ||
3471 (typeid(*selection) == typeid(MapCenterObj)) )
3473 BranchObj *bo=(BranchObj*)selection;
3474 // Take care of links
3475 if (bo->countXLinks()==0)
3477 branchXLinksContextMenuEdit->clear();
3478 branchXLinksContextMenuFollow->clear();
3483 branchXLinksContextMenuEdit->clear();
3484 branchXLinksContextMenuFollow->clear();
3485 for (int i=0; i<=bo->countXLinks();i++)
3487 bot=bo->XLinkTargetAt(i);
3490 s=bot->getHeading();
3491 if (s.length()>xLinkMenuWidth)
3492 s=s.left(xLinkMenuWidth)+"...";
3493 branchXLinksContextMenuFollow->addAction (s);
3494 branchXLinksContextMenuEdit->addAction (s);
3499 standardFlagsDefault->setEnabled (true);
3501 actionEditToggleScroll->setEnabled (true);
3502 if ( bo->isScrolled() )
3503 actionEditToggleScroll->setOn(true);
3505 actionEditToggleScroll->setOn(false);
3507 if ( bo->getURL().isEmpty() )
3509 actionEditOpenURL->setEnabled (false);
3510 actionEditOpenURLTab->setEnabled (false);
3514 actionEditOpenURL->setEnabled (true);
3515 actionEditOpenURLTab->setEnabled (true);
3517 if ( bo->getVymLink().isEmpty() )
3519 actionEditOpenVymLink->setEnabled (false);
3520 actionEditDeleteVymLink->setEnabled (false);
3523 actionEditOpenVymLink->setEnabled (true);
3524 actionEditDeleteVymLink->setEnabled (true);
3527 if (bo->canMoveBranchUp())
3528 actionEditMoveUp->setEnabled (true);
3530 actionEditMoveUp->setEnabled (false);
3531 if (bo->canMoveBranchDown())
3532 actionEditMoveDown->setEnabled (true);
3534 actionEditMoveDown->setEnabled (false);
3537 actionEditToggleHideExport->setEnabled (true);
3538 actionEditToggleHideExport->setOn (bo->hideInExport() );
3540 actionEditCopy->setEnabled (true);
3541 actionEditCut->setEnabled (true);
3542 if (!clipboardEmpty)
3543 actionEditPaste->setEnabled (true);
3545 actionEditPaste->setEnabled (false);
3546 for (int i=0; i<actionListBranches.size(); ++i)
3547 actionListBranches.at(i)->setEnabled(true);
3548 actionEditDelete->setEnabled (true);
3549 actionFormatHideLinkUnselected->setOn
3550 (selection->getHideLinkUnselected());
3552 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3554 FloatObj *fo=(FloatImageObj*)selection;
3556 actionEditOpenURL->setEnabled (false);
3557 actionEditOpenVymLink->setEnabled (false);
3558 actionEditDeleteVymLink->setEnabled (false);
3559 actionEditToggleHideExport->setEnabled (true);
3560 actionEditToggleHideExport->setOn (fo->hideInExport() );
3563 actionEditCopy->setEnabled (true);
3564 actionEditCut->setEnabled (true);
3565 actionEditPaste->setEnabled (false);
3566 for (int i=0; i<actionListBranches.size(); ++i)
3567 actionListBranches.at(i)->setEnabled(false);
3568 actionEditDelete->setEnabled (true);
3569 actionFormatHideLinkUnselected->setOn
3570 ( selection->getHideLinkUnselected());
3571 actionEditMoveUp->setEnabled (false);
3572 actionEditMoveDown->setEnabled (false);
3577 actionEditCopy->setEnabled (false);
3578 actionEditCut->setEnabled (false);
3579 actionEditPaste->setEnabled (false);
3580 for (int i=0; i<actionListBranches.size(); ++i)
3581 actionListBranches.at(i)->setEnabled(false);
3583 actionEditToggleScroll->setEnabled (false);
3584 actionEditOpenURL->setEnabled (false);
3585 actionEditOpenVymLink->setEnabled (false);
3586 actionEditDeleteVymLink->setEnabled (false);
3587 actionEditHeading2URL->setEnabled (false);
3588 actionEditDelete->setEnabled (false);
3589 actionEditMoveUp->setEnabled (false);
3590 actionEditMoveDown->setEnabled (false);
3591 actionEditToggleHideExport->setEnabled (false);
3595 Main::ModMode Main::getModMode()
3597 if (actionModModeColor->isOn()) return ModModeColor;
3598 if (actionModModeCopy->isOn()) return ModModeCopy;
3599 if (actionModModeXLink->isOn()) return ModModeXLink;
3603 bool Main::autoEditNewBranch()
3605 return actionSettingsAutoEditNewBranch->isOn();
3608 bool Main::autoSelectNewBranch()
3610 return actionSettingsAutoSelectNewBranch->isOn();
3613 bool Main::useFlagGroups()
3615 return actionSettingsUseFlagGroups->isOn();
3618 void Main::windowShowNoteEditor()
3620 textEditor->setShowWithMain(true);
3622 actionViewToggleNoteEditor->setOn (true);
3625 void Main::windowHideNoteEditor()
3627 textEditor->setShowWithMain(false);
3629 actionViewToggleNoteEditor->setOn (false);
3632 void Main::setScript (const QString &script)
3634 scriptEditor->setScript (script);
3637 void Main::runScript (const QString &script)
3639 if (currentMapEditor())
3640 currentMapEditor()->runScript (script);
3643 void Main::runScriptEverywhere (const QString &script)
3646 for (int i=0;i<=tabWidget->count() -1;i++)
3648 me=(MapEditor*)tabWidget->page(i);
3649 if (me) me->runScript (script);
3653 void Main::windowNextEditor()
3655 if (tabWidget->currentPageIndex() < tabWidget->count())
3656 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3659 void Main::windowPreviousEditor()
3661 if (tabWidget->currentPageIndex() >0)
3662 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3665 void Main::standardFlagChanged()
3667 if (currentMapEditor())
3668 currentMapEditor()->toggleStandardFlag(sender()->name());
3671 void Main::testFunction1()
3673 if (!currentMapEditor()) return;
3674 currentMapEditor()->testFunction1();
3678 void Main::testFunction2()
3680 if (!currentMapEditor()) return;
3681 currentMapEditor()->testFunction2();
3684 void Main::testCommand()
3686 if (!currentMapEditor()) return;
3687 scriptEditor->show();
3690 QString com = QInputDialog::getText(
3691 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3692 if (ok) currentMapEditor()->parseAtom(com);
3696 void Main::helpDoc()
3698 QString locale = QLocale::system().name();
3700 if (locale.left(2)=="es")
3701 docname="vym_es.pdf";
3705 QStringList searchList;
3707 #if defined(Q_OS_MACX)
3708 searchList << "./vym.app/Contents/Resources/doc";
3709 #elif defined(Q_OS_WIN32)
3710 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3712 #if defined(VYM_DOCDIR)
3713 searchList << VYM_DOCDIR;
3715 // default path in SUSE LINUX
3716 searchList << "/usr/share/doc/packages/vym";
3719 searchList << "doc"; // relative path for easy testing in tarball
3720 searchList << "doc/tex"; // Easy testing working on vym.tex
3721 searchList << "/usr/share/doc/vym"; // Debian
3722 searchList << "/usr/share/doc/packages";// Knoppix
3726 for (int i=0; i<searchList.count(); ++i)
3728 docfile.setFileName(searchList.at(i)+"/"+docname);
3729 if (docfile.exists())
3738 QMessageBox::critical(0,
3739 tr("Critcal error"),
3740 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3745 Process *pdfProc = new Process();
3746 args << QDir::toNativeSeparators(docfile.fileName());
3748 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3749 if ( !pdfProc->waitForStarted() )
3752 QMessageBox::warning(0,
3754 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3755 tr("Please use Settings->")+tr("Set application to open PDF files"));
3762 void Main::helpDemo()
3764 QStringList filters;
3765 filters <<"VYM example map (*.vym)";
3766 QFileDialog *fd=new QFileDialog( this);
3767 #if defined(Q_OS_MACX)
3768 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3770 // default path in SUSE LINUX
3771 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3774 fd->setFileMode (QFileDialog::ExistingFiles);
3775 fd->setFilters (filters);
3776 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3780 if ( fd->exec() == QDialog::Accepted )
3782 lastFileDir=fd->directory().path();
3783 QStringList flist = fd->selectedFiles();
3784 QStringList::Iterator it = flist.begin();
3785 while( it != flist.end() )
3788 fileLoad(*it, NewMap);
3796 void Main::helpAbout()
3799 ad.setName ("aboutwindow");
3800 ad.setMinimumSize(500,500);
3801 ad.resize (QSize (500,500));
3805 void Main::helpAboutQT()
3807 QMessageBox::aboutQt( this, "Qt Application Example" );
3810 void Main::callMacro ()
3812 QAction *action = qobject_cast<QAction *>(sender());
3816 i=action->data().toInt();
3817 QString mDir (settings.value ("macros/macroDir").toString() );
3819 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3821 if ( !f.open( QIODevice::ReadOnly ) )
3823 QMessageBox::warning(0,
3825 tr("Couldn't find a macro at %1.\n").arg(fn)+
3826 tr("Please use Settings->")+tr("Set directory for vym macros"));
3830 QTextStream ts( &f );
3831 QString m= ts.read();
3835 //cout <<"Main::callMacro m="<<qPrintable (m)<<endl;
3836 currentMapEditor()->runScript (m);
3843 //////////////////////////////////
3845 @@ -2544,18 +2576,27 @@
3846 // Try to open new tab in existing konqueror started previously by vym
3847 p=new QProcess (this);
3849 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3850 - "konqueror-mainwindow#1"<<
3852 +#if defined(Q_OS_WIN32)
3853 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3854 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3855 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3856 + "konqueror-mainwindow#1"<<
3860 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3861 + "konqueror-mainwindow#1"<<
3865 p->start ("dcop",args);
3866 if ( !p->waitForStarted() ) success=false;