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());
233 //cout << "Destr MainWindow\n";
235 #if defined(Q_OS_WIN32)
236 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
238 settings.setValue ("/mainwindow/geometry/size", size());
239 settings.setValue ("/mainwindow/geometry/pos", pos());
240 settings.setValue ("/mainwindow/state",saveState(0));
242 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
243 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
244 settings.setValue( "/version/version", vymVersion );
245 settings.setValue( "/version/builddate", vymBuildDate );
247 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
248 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
249 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
250 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
251 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
252 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
253 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
254 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
256 //TODO save scriptEditor settings
258 // call the destructors
260 delete historyWindow;
261 delete branchPropertyWindow;
263 // Remove temporary directory
264 removeDir (QDir(tmpVymDir));
267 void Main::loadCmdLine()
269 /* TODO draw some kind of splashscreen while loading...
275 QStringList flist=options.getFileList();
276 QStringList::Iterator it=flist.begin();
278 while (it !=flist.end() )
280 fileLoad (*it, NewMap);
286 void Main::statusMessage(const QString &s)
288 statusBar()->message( s);
291 void Main::closeEvent (QCloseEvent* )
297 void Main::setupFileActions()
299 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
300 QToolBar *tb = addToolBar( tr ("&Map") );
301 tb->setObjectName ("mapTB");
304 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
305 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
306 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
308 fileMenu->addAction (a);
309 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
311 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
312 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
313 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
314 fileMenu->addAction (a);
315 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
318 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
319 a->setStatusTip (tr( "Open","Status tip File menu" ) );
320 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
322 fileMenu->addAction (a);
323 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
325 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
326 fileMenu->addSeparator();
328 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
329 a->setStatusTip ( tr( "Save","Status tip file menu" ));
330 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
332 fileMenu->addAction (a);
333 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
336 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
337 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
338 fileMenu->addAction (a);
339 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
341 fileMenu->addSeparator();
343 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
345 a = new QAction(tr("KDE Bookmarks"), this);
346 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
347 a->addTo (fileImportMenu);
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
350 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
352 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
353 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
354 a->addTo (fileImportMenu);
355 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
358 a = new QAction("Freemind...",this);
359 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
360 fileImportMenu->addAction (a);
361 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
363 a = new QAction("Mind Manager...",this);
364 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
365 fileImportMenu->addAction (a);
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
368 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
369 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
370 fileImportMenu->addAction (a);
371 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
373 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
375 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
376 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
377 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
378 fileExportMenu->addAction (a);
380 a = new QAction( "Open Office...", this);
381 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
382 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
383 fileExportMenu->addAction (a);
385 a = new QAction( "Webpage (XHTML)...",this );
386 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
387 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
388 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
389 fileExportMenu->addAction (a);
391 a = new QAction( "Text (ASCII)...", this);
392 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
393 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
394 fileExportMenu->addAction (a);
396 a = new QAction( "Spreadsheet (CSV)...", this);
397 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
398 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
399 fileExportMenu->addAction (a);
401 a = new QAction( tr("KDE Bookmarks","File menu"), this);
402 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
403 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
404 fileExportMenu->addAction (a);
406 a = new QAction( "Taskjuggler...", this );
407 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
408 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
409 fileExportMenu->addAction (a);
411 a = new QAction( "LaTeX...", this);
412 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
413 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
414 fileExportMenu->addAction (a);
416 a = new QAction( "XML..." , this );
417 a->setStatusTip (tr( "Export as %1").arg("XML"));
418 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
419 fileExportMenu->addAction (a);
421 fileMenu->addSeparator();
423 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
424 a->setStatusTip ( tr( "Print" ,"File menu") );
425 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
427 fileMenu->addAction (a);
428 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
431 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
432 a->setStatusTip (tr( "Close Map" ) );
433 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
434 fileMenu->addAction (a);
435 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
437 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
438 a->setStatusTip ( tr( "Exit")+" "+vymName );
439 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
440 fileMenu->addAction (a);
441 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
446 void Main::setupEditActions()
448 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
449 tb->setLabel( "Edit Actions" );
450 tb->setObjectName ("actionsTB");
451 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
455 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
456 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
457 a->setStatusTip (tr( "Undo" ) );
458 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
459 a->setEnabled (false);
461 editMenu->addAction (a);
464 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
465 a->setStatusTip (tr( "Redo" ));
466 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
468 editMenu->addAction (a);
469 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
472 editMenu->addSeparator();
473 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
474 a->setStatusTip ( tr( "Copy" ) );
475 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
476 a->setEnabled (false);
478 editMenu->addAction (a);
479 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
482 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
483 a->setStatusTip ( tr( "Cut" ) );
484 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
485 a->setEnabled (false);
487 editMenu->addAction (a);
489 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
491 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
492 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
493 a->setStatusTip ( tr( "Paste" ) );
494 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
495 a->setEnabled (false);
497 editMenu->addAction (a);
500 // Shortcuts to modify heading:
501 a = new QAction(tr( "Edit heading","Edit menu" ),this);
502 a->setStatusTip ( tr( "edit Heading" ));
503 a->setShortcut ( Qt::Key_Enter); //Edit heading
504 // a->setShortcutContext (Qt::WindowShortcut);
506 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
507 actionListBranches.append(a);
508 a = new QAction( tr( "Edit heading","Edit menu" ), this);
509 a->setStatusTip (tr( "edit Heading" ));
510 a->setShortcut (Qt::Key_Return ); //Edit heading
511 //a->setShortcutContext (Qt::WindowShortcut);
513 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
514 actionListBranches.append(a);
515 editMenu->addAction (a);
517 a = new QAction( tr( "Edit heading","Edit menu" ), this);
518 a->setStatusTip (tr( "edit Heading" ));
519 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
520 a->setShortcutContext (Qt::WindowShortcut);
522 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
523 actionListBranches.append(a);
525 // Shortcut to delete selection
526 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
527 a->setStatusTip (tr( "Delete Selection" ));
528 a->setShortcut ( Qt::Key_Delete); //Delete selection
529 a->setShortcutContext (Qt::WindowShortcut);
531 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
534 // Shortcut to add mapcenter
535 a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
536 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
537 actionEditAddMapCenter = a;
540 // Shortcut to add branch
541 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
542 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
543 alt->setShortcut (Qt::Key_A); //Add branch
544 alt->setShortcutContext (Qt::WindowShortcut);
546 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
547 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
548 a->setStatusTip ( tr( "Add a branch as child of selection" ));
549 a->setShortcut (Qt::Key_Insert); //Add branch
550 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
551 actionListBranches.append(a);
552 #if defined (Q_OS_MACX)
553 // In OSX show different shortcut in menues, the keys work indepently always
554 actionEditAddBranch=alt;
556 actionEditAddBranch=a;
558 editMenu->addAction (actionEditAddBranch);
559 tb->addAction (actionEditAddBranch);
562 // Add branch by inserting it at selection
563 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
564 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
565 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
566 a->setShortcutContext (Qt::WindowShortcut);
568 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
569 a->setEnabled (false);
570 actionListBranches.append(a);
571 actionEditAddBranchBefore=a;
572 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
573 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
574 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
575 a->setShortcutContext (Qt::WindowShortcut);
577 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
578 actionListBranches.append(a);
581 a = new QAction(tr( "Add branch above","Edit menu" ), this);
582 a->setStatusTip ( tr( "Add a branch above selection" ));
583 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
584 a->setShortcutContext (Qt::WindowShortcut);
586 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
587 a->setEnabled (false);
588 actionListBranches.append(a);
589 actionEditAddBranchAbove=a;
590 a = new QAction(tr( "Add branch above","Edit menu" ), this);
591 a->setStatusTip ( tr( "Add a branch above selection" ));
592 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
593 a->setShortcutContext (Qt::WindowShortcut);
595 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
596 actionListBranches.append(a);
599 a = new QAction(tr( "Add branch below","Edit menu" ), this);
600 a->setStatusTip ( tr( "Add a branch below selection" ));
601 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
602 a->setShortcutContext (Qt::WindowShortcut);
604 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
605 a->setEnabled (false);
606 actionListBranches.append(a);
607 actionEditAddBranchBelow=a;
608 a = new QAction(tr( "Add branch below","Edit menu" ), this);
609 a->setStatusTip ( tr( "Add a branch below selection" ));
610 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
611 a->setShortcutContext (Qt::WindowShortcut);
613 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
614 actionListBranches.append(a);
616 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
617 a->setStatusTip ( tr( "Move branch up" ) );
618 a->setShortcut (Qt::Key_PageUp ); // Move branch up
619 a->setEnabled (false);
621 editMenu->addAction (a);
622 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
625 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
626 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
627 a->setStatusTip (tr( "Move branch down" ) );
628 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
629 a->setEnabled (false);
631 editMenu->addAction (a);
632 actionEditMoveDown=a;
634 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
635 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
636 a->setEnabled (true);
638 editMenu->addAction (a);
639 actionEditSortChildren=a;
641 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
642 a->setShortcut ( Qt::Key_ScrollLock );
643 a->setStatusTip (tr( "Scroll branch" ) );
644 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
646 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
647 alt->setShortcut ( Qt::Key_S ); // Scroll branch
648 alt->setStatusTip (tr( "Scroll branch" ));
649 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
650 #if defined(Q_OS_MACX)
651 actionEditToggleScroll=alt;
653 actionEditToggleScroll=a;
655 actionEditToggleScroll->setEnabled (false);
656 actionEditToggleScroll->setToggleAction(true);
657 tb->addAction (actionEditToggleScroll);
658 editMenu->addAction ( actionEditToggleScroll);
659 editMenu->addAction (actionEditToggleScroll);
662 actionListBranches.append(actionEditToggleScroll);
664 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
665 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
666 editMenu->addAction (a);
667 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
669 editMenu->addSeparator();
671 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
672 a->setStatusTip (tr( "Find" ) );
673 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
674 editMenu->addAction (a);
675 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
677 editMenu->addSeparator();
679 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
680 a->setShortcut (Qt::CTRL + Qt::Key_U );
681 a->setShortcut (tr( "Open URL" ));
684 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
687 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
688 a->setStatusTip (tr( "Open URL in new tab" ));
689 //a->setShortcut (Qt::CTRL+Qt::Key_U );
691 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
692 actionEditOpenURLTab=a;
694 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
695 a->setStatusTip (tr( "Open all URLs in subtree" ));
697 actionListBranches.append(a);
698 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
699 actionEditOpenMultipleURLTabs=a;
701 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
702 a->setStatusTip ( tr( "Edit URL" ) );
703 a->setShortcut ( Qt::Key_U );
704 a->setShortcutContext (Qt::WindowShortcut);
705 actionListBranches.append(a);
707 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
710 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
711 a->setStatusTip ( tr( "Edit local URL" ) );
712 a->setShortcut (Qt::SHIFT + Qt::Key_U );
713 a->setShortcutContext (Qt::WindowShortcut);
714 actionListBranches.append(a);
716 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
717 actionEditLocalURL=a;
719 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
720 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
721 a->setEnabled (false);
722 actionListBranches.append(a);
723 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
724 actionEditHeading2URL=a;
726 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
727 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
728 a->setEnabled (false);
729 actionListBranches.append(a);
730 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
731 actionEditBugzilla2URL=a;
733 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
734 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
735 a->setEnabled (false);
736 actionListBranches.append(a);
737 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
738 actionEditFATE2URL=a;
740 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
741 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
743 a->setEnabled (false);
744 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
745 actionEditOpenVymLink=a;
747 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
748 a->setStatusTip ( tr( "Open all vym links in subtree" ));
749 a->setEnabled (false);
750 actionListBranches.append(a);
751 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
752 actionEditOpenMultipleVymLinks=a;
755 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
756 a->setEnabled (false);
757 a->setStatusTip ( tr( "Edit link to another vym map" ));
758 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
759 actionListBranches.append(a);
762 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
763 a->setStatusTip ( tr( "Delete link to another vym map" ));
764 a->setEnabled (false);
765 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
766 actionEditDeleteVymLink=a;
768 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
769 a->setStatusTip ( tr( "Hide object in exports" ) );
770 a->setShortcut (Qt::Key_H );
771 a->setToggleAction(true);
773 a->setEnabled (false);
774 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
775 actionEditToggleHideExport=a;
777 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
778 a->setStatusTip ( tr( "Edit Map Info" ));
779 a->setEnabled (true);
780 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
783 // Import at selection (adding to selection)
784 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
785 a->setStatusTip (tr( "Add map at selection" ));
786 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
787 a->setEnabled (false);
788 actionListBranches.append(a);
789 actionEditImportAdd=a;
791 // Import at selection (replacing selection)
792 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
793 a->setStatusTip (tr( "Replace selection with map" ));
794 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
795 a->setEnabled (false);
796 actionListBranches.append(a);
797 actionEditImportReplace=a;
800 a = new QAction( tr( "Save selection","Edit menu" ), this);
801 a->setStatusTip (tr( "Save selection" ));
802 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
803 a->setEnabled (false);
804 actionListBranches.append(a);
805 actionEditSaveBranch=a;
807 // Only remove branch, not its childs
808 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
809 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
810 a->setShortcut (Qt::ALT + Qt::Key_Delete );
811 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
812 a->setEnabled (false);
814 actionListBranches.append(a);
815 actionEditDeleteKeepChilds=a;
817 // Only remove childs of a branch
818 a = new QAction( tr( "Remove childs","Edit menu" ), this);
819 a->setStatusTip (tr( "Remove childs of branch" ));
820 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
821 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
822 a->setEnabled (false);
823 actionListBranches.append(a);
824 actionEditDeleteChilds=a;
826 // Shortcuts for navigating with cursor:
827 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
828 a->setStatusTip ( tr( "Select upper branch" ));
829 a->setShortcut (Qt::Key_Up );
830 a->setShortcutContext (Qt::WindowShortcut);
832 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
833 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
834 a->setStatusTip (tr( "Select lower branch" ));
835 a->setShortcut ( Qt::Key_Down );
836 a->setShortcutContext (Qt::WindowShortcut);
838 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
839 a = new QAction(tr( "Select left branch","Edit menu" ), this);
840 a->setStatusTip ( tr( "Select left branch" ));
841 a->setShortcut (Qt::Key_Left );
842 a->setShortcutContext (Qt::WindowShortcut);
844 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
845 a = new QAction( tr( "Select child branch","Edit menu" ), this);
846 a->setStatusTip (tr( "Select right branch" ));
847 a->setShortcut (Qt::Key_Right);
848 a->setShortcutContext (Qt::WindowShortcut);
850 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
851 a = new QAction( tr( "Select first branch","Edit menu" ), this);
852 a->setStatusTip (tr( "Select first branch" ));
853 a->setShortcut (Qt::Key_Home );
854 a->setShortcutContext (Qt::WindowShortcut);
856 a->setEnabled (false);
857 editMenu->addAction (a);
858 actionListBranches.append(a);
859 actionEditSelectFirst=a;
860 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
861 a = new QAction( tr( "Select last branch","Edit menu" ),this);
862 a->setStatusTip (tr( "Select last branch" ));
863 a->setShortcut ( Qt::Key_End );
864 a->setShortcutContext (Qt::WindowShortcut);
866 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
867 a->setEnabled (false);
868 editMenu->addAction (a);
869 actionListBranches.append(a);
870 actionEditSelectLast=a;
872 a = new QAction( tr( "Add Image...","Edit menu" ), this);
873 a->setStatusTip (tr( "Add Image" ));
874 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
875 actionEditLoadImage=a;
877 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
878 a->setStatusTip (tr( "Set properties for selection" ));
879 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
880 a->setShortcutContext (Qt::WindowShortcut);
881 a->setToggleAction (true);
883 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
884 actionViewTogglePropertyWindow=a;
888 void Main::setupFormatActions()
890 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
892 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
893 tb->setObjectName ("formatTB");
896 pix.fill (Qt::black);
897 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
898 a->setStatusTip ( tr( "Set Color" ));
899 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
901 formatMenu->addAction (a);
903 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
904 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
905 a->setShortcut (Qt::CTRL + Qt::Key_K );
906 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
907 a->setEnabled (false);
909 formatMenu->addAction (a);
910 actionListBranches.append(a);
911 actionFormatPickColor=a;
913 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
914 a->setStatusTip ( tr( "Color branch" ) );
915 a->setShortcut (Qt::CTRL + Qt::Key_B);
916 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
917 a->setEnabled (false);
919 formatMenu->addAction (a);
920 actionListBranches.append(a);
921 actionFormatColorSubtree=a;
923 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
924 a->setStatusTip ( tr( "Color Subtree" ));
925 a->setShortcut (Qt::CTRL + Qt::Key_T);
926 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
927 a->setEnabled (false);
928 formatMenu->addAction (a);
930 actionListBranches.append(a);
931 actionFormatColorSubtree=a;
933 formatMenu->addSeparator();
934 actionGroupFormatLinkStyles=new QActionGroup ( this);
935 actionGroupFormatLinkStyles->setExclusive (true);
936 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
937 a->setStatusTip (tr( "Line" ));
938 a->setToggleAction(true);
939 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
940 formatMenu->addAction (a);
941 actionFormatLinkStyleLine=a;
942 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
943 a->setStatusTip (tr( "Line" ));
944 a->setToggleAction(true);
945 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
946 formatMenu->addAction (a);
947 actionFormatLinkStyleParabel=a;
948 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
949 a->setStatusTip (tr( "PolyLine" ));
950 a->setToggleAction(true);
951 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
952 formatMenu->addAction (a);
953 actionFormatLinkStylePolyLine=a;
954 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
955 a->setStatusTip (tr( "PolyParabel" ) );
956 a->setToggleAction(true);
957 a->setChecked (true);
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
959 formatMenu->addAction (a);
960 actionFormatLinkStylePolyParabel=a;
962 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
963 a->setStatusTip (tr( "Hide link" ));
964 a->setToggleAction(true);
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
966 actionFormatHideLinkUnselected=a;
968 formatMenu->addSeparator();
969 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
970 a->setStatusTip (tr( "Use same color for links and headings" ));
971 a->setToggleAction(true);
972 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
973 formatMenu->addAction (a);
974 actionFormatLinkColorHint=a;
976 pix.fill (Qt::white);
977 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
978 a->setStatusTip (tr( "Set Link Color" ));
979 formatMenu->addAction (a);
980 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
981 actionFormatLinkColor=a;
983 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
984 a->setStatusTip (tr( "Set Selection Color" ));
985 formatMenu->addAction (a);
986 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
987 actionFormatSelectionColor=a;
989 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
990 a->setStatusTip (tr( "Set Background Color" ));
991 formatMenu->addAction (a);
992 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
993 actionFormatBackColor=a;
995 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
996 a->setStatusTip (tr( "Set Background image" ));
997 formatMenu->addAction (a);
998 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
999 actionFormatBackImage=a;
1003 void Main::setupViewActions()
1005 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1006 tb->setLabel( "View Actions" );
1007 tb->setObjectName ("viewTB");
1008 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1011 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1012 a->setStatusTip ( tr( "Zoom reset" ) );
1013 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1015 viewMenu->addAction (a);
1016 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1018 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1019 a->setStatusTip (tr( "Zoom in" ));
1020 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1022 viewMenu->addAction (a);
1023 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1025 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1026 a->setStatusTip (tr( "Zoom out" ));
1027 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1029 viewMenu->addAction (a);
1030 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1032 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1033 a->setStatusTip (tr( "Show selection" ));
1034 a->setShortcut (Qt::Key_Period);
1036 viewMenu->addAction (a);
1037 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1039 viewMenu->addSeparator();
1041 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1042 a->setStatusTip ( tr( "Show Note Editor" ));
1043 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1044 a->setToggleAction(true);
1046 viewMenu->addAction (a);
1047 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1048 actionViewToggleNoteEditor=a;
1050 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1051 a->setStatusTip ( tr( "Show History Window" ));
1052 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1053 a->setToggleAction(true);
1055 viewMenu->addAction (a);
1056 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1057 actionViewToggleHistoryWindow=a;
1059 viewMenu->addAction (actionViewTogglePropertyWindow);
1061 viewMenu->addSeparator();
1063 a = new QAction(tr( "Antialiasing","View action" ),this );
1064 a->setStatusTip ( tr( "Antialiasing" ));
1065 a->setToggleAction(true);
1066 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1067 viewMenu->addAction (a);
1068 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1069 actionViewToggleAntiAlias=a;
1071 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1072 a->setStatusTip (a->text());
1073 a->setToggleAction(true);
1074 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1075 viewMenu->addAction (a);
1076 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1077 actionViewToggleSmoothPixmapTransform=a;
1079 a = new QAction(tr( "Next Map","View action" ), this);
1080 a->setStatusTip (a->text());
1081 a->setShortcut (Qt::ALT + Qt::Key_N );
1082 viewMenu->addAction (a);
1083 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1085 a = new QAction (tr( "Previous Map","View action" ), this );
1086 a->setStatusTip (a->text());
1087 a->setShortcut (Qt::ALT + Qt::Key_P );
1088 viewMenu->addAction (a);
1089 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1093 void Main::setupModeActions()
1095 //QPopupMenu *menu = new QPopupMenu( this );
1096 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1098 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1099 tb->setObjectName ("modesTB");
1101 actionGroupModModes=new QActionGroup ( this);
1102 actionGroupModModes->setExclusive (true);
1103 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1104 a->setShortcut (Qt::Key_J);
1105 a->setStatusTip ( tr( "Use modifier to color branches" ));
1106 a->setToggleAction(true);
1109 actionModModeColor=a;
1111 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1112 a->setShortcut( Qt::Key_K);
1113 a->setStatusTip( tr( "Use modifier to copy" ));
1114 a->setToggleAction(true);
1116 actionModModeCopy=a;
1118 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1119 a->setShortcut (Qt::Key_L);
1120 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1121 a->setToggleAction(true);
1123 actionModModeXLink=a;
1127 void Main::setupFlagActions()
1129 // Create System Flags
1133 systemFlagsDefault = new FlagRowObj ();
1134 systemFlagsDefault->setVisibility (false);
1135 systemFlagsDefault->setName ("systemFlagsDef");
1137 FlagObj *fo = new FlagObj ();
1138 fo->load(QPixmap(flagsPath+"flag-note.png"));
1139 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1141 fo->load(QPixmap(flagsPath+"flag-url.png"));
1142 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1144 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1145 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1147 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1148 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1150 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1151 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1153 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1154 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1156 // Create Standard Flags
1157 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1158 tb->setObjectName ("standardFlagTB");
1160 standardFlagsDefault = new FlagRowObj ();
1161 standardFlagsDefault->setVisibility (false);
1162 standardFlagsDefault->setName ("standardFlagsDef");
1163 standardFlagsDefault->setToolBar (tb);
1165 fo->load(flagsPath+"flag-exclamationmark.png");
1166 fo->setGroup("standard-mark");
1167 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1169 fo->load(flagsPath+"flag-questionmark.png");
1170 fo->setGroup("standard-mark");
1171 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1173 fo->load(flagsPath+"flag-hook-green.png");
1174 fo->setGroup("standard-hook");
1175 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1177 fo->load(flagsPath+"flag-cross-red.png");
1178 fo->setGroup("standard-hook");
1179 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1182 fo->load(flagsPath+"flag-stopsign.png");
1183 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1185 fo->load(flagsPath+"flag-smiley-good.png");
1186 fo->setGroup("standard-smiley");
1187 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1189 fo->load(flagsPath+"flag-smiley-sad.png");
1190 fo->setGroup("standard-smiley");
1191 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1193 fo->load(flagsPath+"flag-smiley-omg.png");
1194 fo->setGroup("standard-smiley");
1195 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1196 // Original omg.png (in KDE emoticons)
1199 fo->load(flagsPath+"flag-kalarm.png");
1200 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1202 fo->load(flagsPath+"flag-phone.png");
1203 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1205 fo->load(flagsPath+"flag-lamp.png");
1206 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1208 fo->load(flagsPath+"flag-arrow-up.png");
1209 fo->setGroup("standard-arrow");
1210 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1212 fo->load(flagsPath+"flag-arrow-down.png");
1213 fo->setGroup("standard-arrow");
1214 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1216 fo->load(flagsPath+"flag-arrow-2up.png");
1217 fo->setGroup("standard-arrow");
1218 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1220 fo->load(flagsPath+"flag-arrow-2down.png");
1221 fo->setGroup("standard-arrow");
1222 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1225 fo->load(flagsPath+"flag-thumb-up.png");
1226 fo->setGroup("standard-thumb");
1227 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1229 fo->load(flagsPath+"flag-thumb-down.png");
1230 fo->setGroup("standard-thumb");
1231 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1234 fo->load(flagsPath+"flag-rose.png");
1235 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1237 fo->load(flagsPath+"flag-heart.png");
1238 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1240 fo->load(flagsPath+"flag-present.png");
1241 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1243 fo->load(flagsPath+"flag-flash.png");
1244 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1246 // Original: xsldbg_output.png
1247 fo->load(flagsPath+"flag-info.png");
1248 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1250 // Original khelpcenter.png
1251 fo->load(flagsPath+"flag-lifebelt.png");
1252 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1258 fo->load(flagsPath+"freemind/warning.png");
1259 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1261 for (int i=1; i<8; i++)
1263 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1264 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1267 fo->load(flagsPath+"freemind/back.png");
1268 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1270 fo->load(flagsPath+"freemind/forward.png");
1271 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1273 fo->load(flagsPath+"freemind/attach.png");
1274 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1276 fo->load(flagsPath+"freemind/clanbomber.png");
1277 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1279 fo->load(flagsPath+"freemind/desktopnew.png");
1280 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1282 fo->load(flagsPath+"freemind/flag.png");
1283 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1286 fo->load(flagsPath+"freemind/gohome.png");
1287 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1290 fo->load(flagsPath+"freemind/kaddressbook.png");
1291 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1293 fo->load(flagsPath+"freemind/knotify.png");
1294 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1296 fo->load(flagsPath+"freemind/korn.png");
1297 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1299 fo->load(flagsPath+"freemind/mail.png");
1300 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1302 fo->load(flagsPath+"freemind/password.png");
1303 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1305 fo->load(flagsPath+"freemind/pencil.png");
1306 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1308 fo->load(flagsPath+"freemind/stop.png");
1309 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1311 fo->load(flagsPath+"freemind/wizard.png");
1312 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1314 fo->load(flagsPath+"freemind/xmag.png");
1315 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1317 fo->load(flagsPath+"freemind/bell.png");
1318 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1320 fo->load(flagsPath+"freemind/bookmark.png");
1321 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1323 fo->load(flagsPath+"freemind/penguin.png");
1324 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1326 fo->load(flagsPath+"freemind/licq.png");
1327 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1332 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1335 fo->setToolTip (tooltip);
1336 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1342 fo->setAlwaysVisible(aw);
1343 a->setCheckable(true);
1344 a->setObjectName(fo->getName());
1345 a->setToolTip(tooltip);
1346 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1347 standardFlagsDefault->addFlag (fo);
1351 systemFlagsDefault->addFlag (fo);
1355 void Main::setupNetworkActions()
1357 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1359 QMenu *netMenu = menuBar()->addMenu( "Network" );
1363 a = new QAction( "Start TCPserver for MapEditor",this);
1364 //a->setStatusTip ( "Set application to open pdf files"));
1365 a->setShortcut ( Qt::Key_T ); //New TCP server
1366 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1367 netMenu->addAction (a);
1369 a = new QAction( "Connect MapEditor to server",this);
1370 //a->setStatusTip ( "Set application to open pdf files"));
1371 a->setShortcut ( Qt::Key_C ); // Connect to server
1372 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1373 netMenu->addAction (a);
1377 void Main::setupSettingsActions()
1379 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1383 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1384 a->setStatusTip ( tr( "Set application to open pdf files"));
1385 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1386 settingsMenu->addAction (a);
1388 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1389 a->setStatusTip( tr( "Set application to open external links"));
1390 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1391 settingsMenu->addAction (a);
1393 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1394 a->setStatusTip( tr( "Set path for macros"));
1395 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1396 settingsMenu->addAction (a);
1398 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1399 a->setStatusTip( tr( "Set number of undo levels"));
1400 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1401 settingsMenu->addAction (a);
1403 settingsMenu->addSeparator();
1405 a = new QAction( tr( "Autosave","Settings action"), this);
1406 a->setStatusTip( tr( "Autosave"));
1407 a->setToggleAction(true);
1408 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1409 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1410 settingsMenu->addAction (a);
1411 actionSettingsAutosaveToggle=a;
1413 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1414 a->setStatusTip( tr( "Autosave time"));
1415 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1416 settingsMenu->addAction (a);
1417 actionSettingsAutosaveTime=a;
1419 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1420 a->setStatusTip( tr( "Write backup file on save"));
1421 a->setToggleAction(true);
1422 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1423 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1424 settingsMenu->addAction (a);
1425 actionSettingsWriteBackupFile=a;
1427 settingsMenu->addSeparator();
1429 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1430 a->setStatusTip( tr( "Edit branch after adding it" ));
1431 a->setToggleAction(true);
1432 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1433 settingsMenu->addAction (a);
1434 actionSettingsAutoEditNewBranch=a;
1436 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1437 a->setStatusTip( tr( "Select branch after adding it" ));
1438 a->setToggleAction(true);
1439 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1440 settingsMenu->addAction (a);
1441 actionSettingsAutoSelectNewBranch=a;
1443 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1444 a->setStatusTip( tr( "Select heading before editing" ));
1445 a->setToggleAction(true);
1446 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1447 settingsMenu->addAction (a);
1448 actionSettingsAutoSelectText=a;
1450 a= new QAction( tr( "Delete key","Settings action" ), this);
1451 a->setStatusTip( tr( "Delete key for deleting branches" ));
1452 a->setToggleAction(true);
1453 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1454 settingsMenu->addAction (a);
1455 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1456 actionSettingsUseDelKey=a;
1458 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1459 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1460 a->setToggleAction(true);
1461 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1462 settingsMenu->addAction (a);
1463 actionSettingsUseFlagGroups=a;
1465 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1466 a->setStatusTip( tr( "Use hide flag during exports " ));
1467 a->setToggleAction(true);
1468 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1469 settingsMenu->addAction (a);
1470 actionSettingsUseHideExport=a;
1472 a = new QAction( tr( "Animation","Settings action"), this);
1473 a->setStatusTip( tr( "Animation"));
1474 a->setToggleAction(true);
1475 a->setOn (settings.value("/animation/use",false).toBool() );
1476 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1477 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1479 settingsMenu->addAction (a);
1481 actionSettingsUseAnimation=a;
1485 void Main::setupTestActions()
1487 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1490 a = new QAction( "Test function 1" , this);
1491 a->setStatusTip( "Call test function 1" );
1492 testMenu->addAction (a);
1493 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1495 a = new QAction( "Test function 2" , this);
1496 a->setStatusTip( "Call test function 2" );
1497 testMenu->addAction (a);
1498 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1500 a = new QAction( "Command" , this);
1501 a->setStatusTip( "Enter command to call in editor" );
1502 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1503 testMenu->addAction (a);
1507 void Main::setupHelpActions()
1509 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1512 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1513 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1514 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1515 helpMenu->addAction (a);
1517 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1518 a->setStatusTip( tr( "Open VYM example maps " ));
1519 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1520 helpMenu->addAction (a);
1522 a = new QAction( tr( "About VYM","Help action" ), this);
1523 a->setStatusTip( tr( "About VYM")+vymName);
1524 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1525 helpMenu->addAction (a);
1527 a = new QAction( tr( "About QT","Help action" ), this);
1528 a->setStatusTip( tr( "Information about QT toolkit" ));
1529 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1530 helpMenu->addAction (a);
1534 void Main::setupContextMenus()
1538 // Context Menu for branch or mapcenter
1539 branchContextMenu =new QMenu (this);
1540 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1541 branchContextMenu->addSeparator();
1544 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1545 branchAddContextMenu->addAction (actionEditPaste );
1546 branchAddContextMenu->addAction ( actionEditAddBranch );
1547 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1548 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1549 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1550 branchAddContextMenu->addSeparator();
1551 branchAddContextMenu->addAction ( actionEditImportAdd );
1552 branchAddContextMenu->addAction ( actionEditImportReplace );
1555 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1556 branchRemoveContextMenu->addAction (actionEditCut);
1557 branchRemoveContextMenu->addAction ( actionEditDelete );
1558 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1559 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1562 actionEditSaveBranch->addTo( branchContextMenu );
1563 actionFileNewCopy->addTo (branchContextMenu );
1565 branchContextMenu->addSeparator();
1566 branchContextMenu->addAction ( actionEditLoadImage);
1568 // Submenu for Links (URLs, vymLinks)
1569 branchLinksContextMenu =new QMenu (this);
1571 branchContextMenu->addSeparator();
1572 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1573 branchLinksContextMenu->addAction ( actionEditOpenURL );
1574 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1575 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1576 branchLinksContextMenu->addAction ( actionEditURL );
1577 branchLinksContextMenu->addAction ( actionEditLocalURL );
1578 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1579 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1580 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1582 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1584 branchLinksContextMenu->addSeparator();
1585 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1586 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1587 branchLinksContextMenu->addAction ( actionEditVymLink );
1588 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1591 // Context Menu for XLinks in a branch menu
1592 // This will be populated "on demand" in MapEditor::updateActions
1593 branchContextMenu->addSeparator();
1594 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1595 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1596 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1597 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1600 // Context menu for floatimage
1601 floatimageContextMenu =new QMenu (this);
1602 a= new QAction (tr ("Save image","Context action"),this);
1603 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1604 floatimageContextMenu->addAction (a);
1606 floatimageContextMenu->addSeparator();
1607 actionEditCopy->addTo( floatimageContextMenu );
1608 actionEditCut->addTo( floatimageContextMenu );
1610 floatimageContextMenu->addSeparator();
1611 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1614 // Context menu for canvas
1615 canvasContextMenu =new QMenu (this);
1616 actionEditMapInfo->addTo( canvasContextMenu );
1617 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1618 actionEditAddMapCenter->addTo( canvasContextMenu );
1619 canvasContextMenu->insertSeparator();
1620 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1621 canvasContextMenu->insertSeparator();
1622 actionFormatLinkColorHint->addTo( canvasContextMenu );
1623 actionFormatLinkColor->addTo( canvasContextMenu );
1624 actionFormatSelectionColor->addTo( canvasContextMenu );
1625 actionFormatBackColor->addTo( canvasContextMenu );
1626 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1628 // Menu for last opened files
1630 for (int i = 0; i < MaxRecentFiles; ++i)
1632 recentFileActions[i] = new QAction(this);
1633 recentFileActions[i]->setVisible(false);
1634 fileLastMapsMenu->addAction(recentFileActions[i]);
1635 connect(recentFileActions[i], SIGNAL(triggered()),
1636 this, SLOT(fileLoadRecent()));
1638 setupRecentMapsMenu();
1641 void Main::setupRecentMapsMenu()
1643 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1645 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1647 for (int i = 0; i < numRecentFiles; ++i) {
1648 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1649 recentFileActions[i]->setText(text);
1650 recentFileActions[i]->setData(files[i]);
1651 recentFileActions[i]->setVisible(true);
1653 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1654 recentFileActions[j]->setVisible(false);
1657 void Main::setupMacros()
1659 for (int i = 0; i <= 11; i++)
1661 macroActions[i] = new QAction(this);
1662 macroActions[i]->setData(i);
1663 addAction (macroActions[i]);
1664 connect(macroActions[i], SIGNAL(triggered()),
1665 this, SLOT(callMacro()));
1667 macroActions[0]->setShortcut ( Qt::Key_F1 );
1668 macroActions[1]->setShortcut ( Qt::Key_F2 );
1669 macroActions[2]->setShortcut ( Qt::Key_F3 );
1670 macroActions[3]->setShortcut ( Qt::Key_F4 );
1671 macroActions[4]->setShortcut ( Qt::Key_F5 );
1672 macroActions[5]->setShortcut ( Qt::Key_F6 );
1673 macroActions[6]->setShortcut ( Qt::Key_F7 );
1674 macroActions[7]->setShortcut ( Qt::Key_F8 );
1675 macroActions[8]->setShortcut ( Qt::Key_F9 );
1676 macroActions[9]->setShortcut ( Qt::Key_F10 );
1677 macroActions[10]->setShortcut ( Qt::Key_F11 );
1678 macroActions[11]->setShortcut ( Qt::Key_F12 );
1681 void Main::hideEvent (QHideEvent * )
1683 if (!textEditor->isMinimized() ) textEditor->hide();
1686 void Main::showEvent (QShowEvent * )
1688 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1692 MapEditor* Main::currentMapEditor() const
1694 if ( tabWidget->currentPage() &&
1695 tabWidget->currentPage()->inherits( "MapEditor" ) )
1696 return (MapEditor*)tabWidget->currentPage();
1701 void Main::editorChanged(QWidget *)
1703 // Unselect all possibly selected objects
1704 // (Important to update note editor)
1706 for (int i=0;i<=tabWidget->count() -1;i++)
1708 me=(MapEditor*)tabWidget->page(i);
1711 me=currentMapEditor();
1712 if (me) me->reselect();
1714 // Update actions to in menus and toolbars according to editor
1718 void Main::fileNew()
1720 QString fn="unnamed";
1721 MapEditor* me = new MapEditor ( NULL);
1722 tabWidget->addTab (me,fn);
1723 tabWidget->showPage(me);
1724 me->viewport()->setFocus();
1725 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1726 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1728 // For the very first map we do not have flagrows yet...
1732 void Main::fileNewCopy()
1734 QString fn="unnamed";
1735 MapEditor* oldME =currentMapEditor();
1739 MapEditor* newME = new MapEditor ( NULL);
1742 tabWidget->addTab (newME,fn);
1743 tabWidget->showPage(newME);
1744 newME->viewport()->setFocus();
1745 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1746 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1747 // For the very first map we do not have flagrows yet...
1748 newME->select("mc:");
1749 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1755 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1757 ErrorCode err=success;
1759 // fn is usually the archive, mapfile the file after uncompressing
1762 // Make fn absolute (needed for unzip)
1763 fn=QDir (fn).absPath();
1769 // Check, if map is already loaded
1771 while (i<=tabWidget->count() -1)
1773 me=(MapEditor*)tabWidget->page(i);
1774 if (me->getFilePath() == fn)
1776 // Already there, ask for confirmation
1777 QMessageBox mb( vymName,
1778 tr("The map %1\nis already opened."
1779 "Opening the same map in multiple editors may lead \n"
1780 "to confusion when finishing working with vym."
1781 "Do you want to").arg(fn),
1782 QMessageBox::Warning,
1783 QMessageBox::Yes | QMessageBox::Default,
1784 QMessageBox::Cancel | QMessageBox::Escape,
1785 QMessageBox::NoButton);
1786 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1787 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1790 case QMessageBox::Yes:
1792 i=tabWidget->count();
1794 case QMessageBox::Cancel:
1806 if ( !fn.isEmpty() )
1808 me = currentMapEditor();
1809 int tabIndex=tabWidget->currentPageIndex();
1810 // Check first, if mapeditor exists
1811 // If it is not default AND we want a new map,
1812 // create a new mapeditor in a new tab
1813 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1815 me= new MapEditor ( NULL);
1816 tabWidget->addTab (me,fn);
1817 tabIndex=tabWidget->indexOf (me);
1818 tabWidget->setCurrentPage (tabIndex);
1819 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1820 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1823 // Check, if file exists (important for creating new files
1824 // from command line
1827 if (!QFile(fn).exists() )
1829 QMessageBox mb( vymName,
1830 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1831 QMessageBox::Question,
1833 QMessageBox::Cancel | QMessageBox::Default,
1834 QMessageBox::NoButton );
1836 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1837 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1840 case QMessageBox::Yes:
1842 currentMapEditor()->setFilePath(fn);
1843 tabWidget->setTabLabel (currentMapEditor(),
1844 currentMapEditor()->getFileName() );
1845 statusBar()->message( "Created " + fn , statusbarTime );
1848 case QMessageBox::Cancel:
1849 // don't create new map
1850 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1856 //tabWidget->currentPage() won't be NULL here, because of above...
1857 tabWidget->showPage(me);
1858 me->viewport()->setFocus();
1862 // Save existing filename in case we import
1863 QString fn_org=me->getFilePath();
1865 // Finally load map into mapEditor
1866 me->setFilePath (fn);
1867 err=me->load(fn,lmode,ftype);
1869 // Restore old (maybe empty) filepath, if this is an import
1871 me->setFilePath (fn_org);
1874 // Finally check for errors and go home
1877 if (lmode==NewMap) fileCloseMap();
1878 statusBar()->message( "Could not load " + fn, statusbarTime );
1883 me->setFilePath (fn);
1884 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1885 if (!isInTmpDir (fn))
1887 // Only append to lastMaps if not loaded from a tmpDir
1888 // e.g. imported bookmarks are in a tmpDir
1889 addRecentMap(me->getFilePath() );
1891 actionFilePrint->setEnabled (true);
1893 statusBar()->message( "Loaded " + fn, statusbarTime );
1900 void Main::fileLoad(const LoadMode &lmode)
1902 QStringList filters;
1903 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1904 QFileDialog *fd=new QFileDialog( this);
1905 fd->setDir (lastFileDir);
1906 fd->setFileMode (QFileDialog::ExistingFiles);
1907 fd->setFilters (filters);
1911 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1914 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1917 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1923 if ( fd->exec() == QDialog::Accepted )
1925 lastFileDir=fd->directory().path();
1926 QStringList flist = fd->selectedFiles();
1927 QStringList::Iterator it = flist.begin();
1928 while( it != flist.end() )
1931 fileLoad(*it, lmode);
1938 void Main::fileLoad()
1943 void Main::fileLoadRecent()
1945 QAction *action = qobject_cast<QAction *>(sender());
1947 fileLoad (action->data().toString(), NewMap);
1950 void Main::addRecentMap (const QString &fileName)
1953 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1954 files.removeAll(fileName);
1955 files.prepend(fileName);
1956 while (files.size() > MaxRecentFiles)
1959 settings.setValue("/mainwindow/recentFileList", files);
1961 setupRecentMapsMenu();
1964 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1968 if ( me->getFilePath().isEmpty() )
1970 // We have no filepath yet,
1971 // call fileSaveAs() now, this will call fileSave()
1973 // First switch to editor
1974 tabWidget->setCurrentWidget (me);
1975 fileSaveAs(savemode);
1978 if (me->save (savemode)==success)
1980 statusBar()->message(
1981 tr("Saved %1").arg(me->getFilePath()),
1983 addRecentMap (me->getFilePath() );
1985 statusBar()->message(
1986 tr("Couldn't save ").arg(me->getFilePath()),
1990 void Main::fileSave()
1992 fileSave (currentMapEditor(), CompleteMap);
1995 void Main::fileSave(MapEditor *me)
1997 fileSave (me,CompleteMap);
2000 void Main::fileSaveAs(const SaveMode& savemode)
2004 if (currentMapEditor())
2006 if (savemode==CompleteMap)
2007 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2009 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2010 if ( !fn.isEmpty() )
2012 // Check for existing file
2013 if (QFile (fn).exists())
2015 QMessageBox mb( vymName,
2016 tr("The file %1\nexists already. Do you want to").arg(fn),
2017 QMessageBox::Warning,
2018 QMessageBox::Yes | QMessageBox::Default,
2019 QMessageBox::Cancel | QMessageBox::Escape,
2020 QMessageBox::NoButton);
2021 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2022 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2025 case QMessageBox::Yes:
2028 case QMessageBox::Cancel:
2035 // New file, add extension to filename, if missing
2036 // This is always .vym or .vyp, depending on savemode
2037 if (savemode==CompleteMap)
2039 if (!fn.contains (".vym") && !fn.contains (".xml"))
2043 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2052 currentMapEditor()->setFilePath(fn);
2053 fileSave(currentMapEditor(), savemode);
2056 if (savemode==CompleteMap)
2057 tabWidget->setTabLabel (currentMapEditor(),
2058 currentMapEditor()->getFileName() );
2064 void Main::fileSaveAs()
2066 fileSaveAs (CompleteMap);
2069 void Main::fileImportKDEBookmarks()
2071 ImportKDEBookmarks im;
2073 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2074 currentMapEditor()->setFilePath ("");
2077 void Main::fileImportFirefoxBookmarks()
2079 Q3FileDialog *fd=new Q3FileDialog( this);
2080 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2081 fd->setMode (Q3FileDialog::ExistingFiles);
2082 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2083 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2086 if ( fd->exec() == QDialog::Accepted )
2088 ImportFirefoxBookmarks im;
2089 QStringList flist = fd->selectedFiles();
2090 QStringList::Iterator it = flist.begin();
2091 while( it != flist.end() )
2094 if (im.transform() &&
2095 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2096 currentMapEditor() )
2097 currentMapEditor()->setFilePath ("");
2104 void Main::fileImportFreemind()
2106 QStringList filters;
2107 filters <<"Freemind map (*.mm)"<<"All files (*)";
2108 QFileDialog *fd=new QFileDialog( this);
2109 fd->setDir (lastFileDir);
2110 fd->setFileMode (QFileDialog::ExistingFiles);
2111 fd->setFilters (filters);
2112 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2116 if ( fd->exec() == QDialog::Accepted )
2118 lastFileDir=fd->directory().path();
2119 QStringList flist = fd->selectedFiles();
2120 QStringList::Iterator it = flist.begin();
2121 while( it != flist.end() )
2124 if ( fileLoad (fn,NewMap, FreemindMap) )
2126 currentMapEditor()->setFilePath ("");
2135 void Main::fileImportMM()
2139 Q3FileDialog *fd=new Q3FileDialog( this);
2140 fd->setDir (lastFileDir);
2141 fd->setMode (Q3FileDialog::ExistingFiles);
2142 fd->addFilter ("Mind Manager (*.mmap)");
2143 fd->setCaption(tr("Import")+" "+"Mind Manager");
2146 if ( fd->exec() == QDialog::Accepted )
2148 lastFileDir=fd->dirPath();
2149 QStringList flist = fd->selectedFiles();
2150 QStringList::Iterator it = flist.begin();
2151 while( it != flist.end() )
2154 if (im.transform() &&
2155 success==fileLoad (im.getTransformedFile(),NewMap) &&
2156 currentMapEditor() )
2157 currentMapEditor()->setFilePath ("");
2166 void Main::fileImportDir()
2168 if (currentMapEditor())
2169 currentMapEditor()->importDir();
2172 void Main::fileExportXML()
2174 MapEditor *me=currentMapEditor();
2175 if (me) me->exportXML();
2179 void Main::fileExportXHTML()
2181 MapEditor *me=currentMapEditor();
2182 if (me) me->exportXHTML();
2185 void Main::fileExportImage()
2187 MapEditor *me=currentMapEditor();
2188 if (me) me->exportImage();
2191 void Main::fileExportASCII()
2193 MapEditor *me=currentMapEditor();
2194 if (me) me->exportASCII();
2197 void Main::fileExportCSV() //FIXME not scriptable yet
2199 MapEditor *me=currentMapEditor();
2203 ex.setModel (me->getModel());
2204 ex.addFilter ("CSV (*.csv)");
2205 ex.setDir(lastImageDir);
2206 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2207 if (ex.execDialog() )
2209 me->setExportMode(true);
2211 me->setExportMode(false);
2216 void Main::fileExportLaTeX() //FIXME not scriptable yet
2218 MapEditor *me=currentMapEditor();
2222 ex.setModel (me->getModel());
2223 ex.addFilter ("Tex (*.tex)");
2224 ex.setDir(lastImageDir);
2225 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2226 if (ex.execDialog() )
2228 me->setExportMode(true);
2230 me->setExportMode(false);
2235 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2237 ExportKDEBookmarks ex;
2238 MapEditor *me=currentMapEditor();
2241 ex.setModel (me->getModel());
2246 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2248 ExportTaskjuggler ex;
2249 MapEditor *me=currentMapEditor();
2252 ex.setModel (me->getModel());
2253 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2254 ex.setDir(lastImageDir);
2255 ex.addFilter ("Taskjuggler (*.tjp)");
2256 if (ex.execDialog() )
2258 me->setExportMode(true);
2260 me->setExportMode(false);
2265 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2267 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2268 // TODO add preview in dialog
2269 //ImagePreview *p =new ImagePreview (fd);
2270 //fd->setContentsPreviewEnabled( TRUE );
2271 //fd->setContentsPreview( p, p );
2272 //fd->setPreviewMode( QFileDialog::Contents );
2273 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2274 fd->setDir (QDir().current());
2275 if (fd->foundConfig())
2279 if ( fd->exec() == QDialog::Accepted )
2281 QString fn=fd->selectedFile();
2282 if (!fn.contains (".odp"))
2285 //lastImageDir=fn.left(fn.findRev ("/"));
2286 if (currentMapEditor())
2287 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2291 QMessageBox::warning(0,
2293 tr("Couldn't find configuration for export to Open Office\n"));
2297 void Main::fileCloseMap()
2299 MapEditor *me = currentMapEditor();
2302 if (me->hasChanged())
2304 QMessageBox mb( vymName,
2305 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
2306 QMessageBox::Warning,
2307 QMessageBox::Yes | QMessageBox::Default,
2309 QMessageBox::Cancel | QMessageBox::Escape );
2310 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2311 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2314 case QMessageBox::Yes:
2316 fileSave(me, CompleteMap);
2318 case QMessageBox::No:
2319 // close without saving
2321 case QMessageBox::Cancel:
2327 tabWidget->removePage(me);
2328 if (tabWidget->count()==0)
2329 actionFilePrint->setEnabled (false);
2332 // Better would be delete (me), but then we have a Qt error:
2333 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2334 // So we only remove data now and call deconstructor when vym closes later
2339 void Main::filePrint()
2341 if (currentMapEditor())
2342 currentMapEditor()->print();
2345 void Main::fileExitVYM()
2347 // Check if one or more editors have changed
2350 for (i=0;i<=tabWidget->count() -1;i++)
2353 me=(MapEditor*)tabWidget->page(i);
2355 // If something changed, ask what to do
2356 if (me->hasChanged())
2358 tabWidget->setCurrentPage(i);
2359 QMessageBox mb( vymName,
2360 tr("This map is not saved yet. Do you want to"),
2361 QMessageBox::Warning,
2362 QMessageBox::Yes | QMessageBox::Default,
2364 QMessageBox::Cancel | QMessageBox::Escape );
2365 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2366 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2369 mb.setActiveWindow();
2370 switch( mb.exec() ) {
2371 case QMessageBox::Yes:
2372 // save (the changed editors) and exit
2373 fileSave(currentMapEditor(), CompleteMap);
2375 case QMessageBox::No:
2376 // exit without saving
2378 case QMessageBox::Cancel:
2379 // don't save and don't exit
2383 me->clear(); // remove and unselect now, before mainWindow has gone...
2384 } // loop over all MEs
2388 void Main::editUndo()
2390 if (currentMapEditor())
2391 currentMapEditor()->undo();
2394 void Main::editRedo()
2396 if (currentMapEditor())
2397 currentMapEditor()->redo();
2400 void Main::gotoHistoryStep (int i)
2402 if (currentMapEditor())
2403 currentMapEditor()->gotoHistoryStep (i);
2406 void Main::editCopy()
2408 if (currentMapEditor())
2409 currentMapEditor()->copy();
2412 void Main::editPaste()
2414 if (currentMapEditor())
2415 currentMapEditor()->paste();
2418 void Main::editCut()
2420 if (currentMapEditor())
2421 currentMapEditor()->cut();
2424 void Main::editOpenFindWindow()
2426 findWindow->popup();
2427 findWindow->raise();
2428 findWindow->setActiveWindow();
2431 void Main::editFind(QString s)
2434 BranchObj *bo=currentMapEditor()->findText(s, cs);
2437 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2440 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2441 tr("No matches found for \"%1\"").arg(s));
2445 void Main::editFindChanged()
2446 { // Notify editor, to abort the current find process
2447 currentMapEditor()->findReset();
2450 void Main::openTabs(QStringList urls)
2452 if (!urls.isEmpty())
2456 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2458 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2460 QString u=urls.takeFirst();
2461 procBrowser = new QProcess( this );
2463 procBrowser->start(browser,args);
2464 if ( !procBrowser->waitForStarted())
2466 // try to set path to browser
2467 QMessageBox::warning(0,
2469 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2470 tr("Please use Settings->")+tr("Set application to open an URL"));
2473 #if defined(Q_OS_WIN32)
2474 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2475 this->thread()->wait(3000);
2480 if (browser.contains("konqueror"))
2482 for (int i=0; i<urls.size(); i++)
2485 // Try to open new tab in existing konqueror started previously by vym
2486 p=new QProcess (this);
2488 #if defined(Q_OS_WIN32)
2489 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2490 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2491 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2492 "konqueror-mainwindow#1"<<
2496 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2497 "konqueror-mainwindow#1"<<
2501 p->start ("dcop",args);
2502 //cout << qPrintable (args.join(" "))<<endl;
2503 if ( !p->waitForStarted() ) success=false;
2506 QMessageBox::warning(0,
2508 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2510 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2512 for (int i=0; i<urls.size(); i++)
2514 // Try to open new tab in firefox
2515 p=new QProcess (this);
2516 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2517 p->start (browser,args);
2518 if ( !p->waitForStarted() ) success=false;
2521 QMessageBox::warning(0,
2523 tr("Couldn't start %1 to open a new tab").arg(browser));
2526 QMessageBox::warning(0,
2528 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2532 void Main::editOpenURL()
2535 if (currentMapEditor())
2537 QString url=currentMapEditor()->getURL();
2539 if (url=="") return;
2540 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2541 procBrowser = new QProcess( this );
2543 procBrowser->start(browser,args);
2544 if ( !procBrowser->waitForStarted())
2546 // try to set path to browser
2547 QMessageBox::warning(0,
2549 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2550 tr("Please use Settings->")+tr("Set application to open an URL"));
2555 void Main::editOpenURLTab()
2557 if (currentMapEditor())
2560 urls.append(currentMapEditor()->getURL());
2564 void Main::editOpenMultipleURLTabs()
2566 if (currentMapEditor())
2569 urls=currentMapEditor()->getURLs();
2575 void Main::editURL()
2577 if (currentMapEditor())
2578 currentMapEditor()->editURL();
2581 void Main::editLocalURL()
2583 if (currentMapEditor())
2584 currentMapEditor()->editLocalURL();
2587 void Main::editHeading2URL()
2589 if (currentMapEditor())
2590 currentMapEditor()->editHeading2URL();
2593 void Main::editBugzilla2URL()
2595 if (currentMapEditor())
2596 currentMapEditor()->editBugzilla2URL();
2599 void Main::editFATE2URL()
2601 if (currentMapEditor())
2602 currentMapEditor()->editFATE2URL();
2605 void Main::editHeadingFinished()
2607 // only called from editHeading(), so there is a currentME
2608 MapEditor *me=currentMapEditor();
2611 me->setStateEditHeading (false);
2612 QPoint p; //Not used here, only to find out pos of branch
2614 QString s=me->getHeading(ok,p);
2616 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2618 if (ok && s!=lineedit->text())
2619 me->setHeading(lineedit->text());
2621 lineedit->releaseKeyboard();
2625 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2626 !prevSelection.isEmpty())
2627 me->select(prevSelection);
2632 void Main::editHeading()
2634 if (currentMapEditor())
2636 MapEditor *me=currentMapEditor();
2637 QString oldSel=me->getSelectString();
2639 if (lineedit->isVisible())
2640 editHeadingFinished();
2645 QString s=me->getHeading(ok,p);
2649 me->setStateEditHeading (true);
2650 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2651 p=me->mapToGlobal (p);
2652 QDialog *d =new QDialog(NULL);
2653 QLineEdit *le=new QLineEdit (d);
2654 d->setWindowFlags (Qt::FramelessWindowHint);
2655 d->setGeometry(p.x(),p.y(),230,25);
2656 le->resize (d->width()-10,d->height());
2659 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2660 d->activateWindow();
2662 me->setHeading (le->text());
2665 editHeadingFinished();
2667 p=me->mapTo (this,p);
2668 lineedit->setGeometry(p.x(),p.y(),230,25);
2669 lineedit->setText(s);
2670 lineedit->setCursorPosition(1);
2671 lineedit->selectAll();
2673 lineedit->grabKeyboard();
2674 lineedit->setFocus();
2678 } // currentMapEditor()
2681 void Main::editAttributeFinished()
2683 // only called from editHeading(), so there is a currentME
2686 MapEditor *me=currentMapEditor();
2689 me->setStateEditHeading (false);
2690 QPoint p; //Not used here, only to find out pos of branch
2692 QString s=me->getHeading(ok,p);
2694 #if defined(Q_OS_MACX)
2696 if (ok && s!=lineedit->text())
2697 me->setHeading(lineedit->text());
2699 lineedit->releaseKeyboard();
2703 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2704 !prevSelection.isEmpty())
2705 me->select(prevSelection);
2711 #include "attribute.h"
2712 #include "attributedialog.h"
2713 void Main::editAttribute()
2715 MapEditor *me=currentMapEditor();
2718 BranchObj *bo=me->getSelectedBranch();
2721 AttributeDialog dia(this);
2722 dia.setTable (me->attributeTable() );
2724 dia.setMode (Definition);
2730 if (currentMapEditor())
2732 MapEditor *me=currentMapEditor();
2733 QString oldSel=me->getSelectString();
2735 if (lineedit->isVisible())
2736 editAttributeFinished();
2741 QString s=me->getHeading(ok,p);
2745 me->setStateEditHeading (true);
2746 #if defined(Q_OS_MACX)
2747 p=me->mapToGlobal (p);
2748 QDialog *d =new QDialog(NULL);
2749 QLineEdit *le=new QLineEdit (d);
2750 d->setWindowFlags (Qt::FramelessWindowHint);
2751 d->setGeometry(p.x(),p.y(),230,25);
2752 le->resize (d->width()-10,d->height());
2755 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2756 d->activateWindow();
2758 me->setHeading (le->text());
2761 editHeadingFinished();
2763 p=me->mapTo (this,p);
2764 lineedit->setGeometry(p.x(),p.y(),230,25);
2765 lineedit->setText(s);
2766 lineedit->setCursorPosition(1);
2767 lineedit->selectAll();
2769 lineedit->grabKeyboard();
2770 lineedit->setFocus();
2774 } // currentMapEditor()
2779 void Main::openVymLinks(const QStringList &vl)
2781 for (int j=0; j<vl.size(); j++)
2783 // compare path with already loaded maps
2787 for (i=0;i<=tabWidget->count() -1;i++)
2789 me=(MapEditor*)tabWidget->page(i);
2790 if (vl.at(j)==me->getFilePath() )
2799 if (!QFile(vl.at(j)).exists() )
2800 QMessageBox::critical( 0, tr( "Critical Error" ),
2801 tr("Couldn't open map %1").arg(vl.at(j)));
2804 fileLoad (vl.at(j), NewMap);
2805 tabWidget->setCurrentPage (tabWidget->count()-1);
2808 // Go to tab containing the map
2809 tabWidget->setCurrentPage (index);
2813 void Main::editOpenVymLink()
2815 if (currentMapEditor())
2818 vl.append(currentMapEditor()->getVymLink());
2823 void Main::editOpenMultipleVymLinks()
2825 QString currentVymLink;
2826 if (currentMapEditor())
2828 QStringList vl=currentMapEditor()->getVymLinks();
2833 void Main::editVymLink()
2835 if (currentMapEditor())
2836 currentMapEditor()->editVymLink();
2839 void Main::editDeleteVymLink()
2841 if (currentMapEditor())
2842 currentMapEditor()->deleteVymLink();
2845 void Main::editToggleHideExport()
2847 if (currentMapEditor())
2848 currentMapEditor()->toggleHideExport();
2851 void Main::editMapInfo()
2853 if (currentMapEditor())
2854 currentMapEditor()->editMapInfo();
2857 void Main::editMoveUp()
2859 if (currentMapEditor())
2860 currentMapEditor()->moveBranchUp();
2863 void Main::editMoveDown()
2865 if (currentMapEditor())
2866 currentMapEditor()->moveBranchDown();
2869 void Main::editSortChildren()
2871 if (currentMapEditor())
2872 currentMapEditor()->sortChildren();
2875 void Main::editToggleScroll()
2877 if (currentMapEditor())
2879 currentMapEditor()->toggleScroll();
2883 void Main::editUnscrollChilds()
2885 if (currentMapEditor())
2886 currentMapEditor()->unscrollChilds();
2889 void Main::editAddMapCenter()
2891 MapEditor *me=currentMapEditor();
2892 if (!lineedit->isVisible() && me)
2894 me->addMapCenter ();
2898 void Main::editNewBranch()
2900 MapEditor *me=currentMapEditor();
2901 if (!lineedit->isVisible() && me)
2903 BranchObj *bo=(BranchObj*)me->getSelection();
2904 BranchObj *newbo=me->addNewBranch(0);
2906 prevSelection=me->getModel()->getSelectString(bo);
2912 if (actionSettingsAutoEditNewBranch->isOn())
2917 if (!prevSelection.isEmpty())
2919 me->select(prevSelection);
2926 void Main::editNewBranchBefore()
2928 MapEditor *me=currentMapEditor();
2929 if (!lineedit->isVisible() && me)
2931 BranchObj *bo=(BranchObj*)me->getSelection();
2932 BranchObj *newbo=me->addNewBranchBefore();
2939 if (actionSettingsAutoEditNewBranch->isOn())
2941 if (!actionSettingsAutoSelectNewBranch->isOn())
2942 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2948 void Main::editNewBranchAbove()
2950 MapEditor *me=currentMapEditor();
2951 if (!lineedit->isVisible() && me)
2953 BranchObj *bo=(BranchObj*)me->getSelection();
2954 BranchObj *newbo=me->addNewBranch (-1);
2961 if (actionSettingsAutoEditNewBranch->isOn())
2963 if (!actionSettingsAutoSelectNewBranch->isOn())
2964 prevSelection=me->getModel()->getSelectString (bo); // TODO access directly
2970 void Main::editNewBranchBelow()
2972 MapEditor *me=currentMapEditor();
2973 if (!lineedit->isVisible() && me)
2975 BranchObj *bo=(BranchObj*)me->getSelection();
2976 BranchObj *newbo=me->addNewBranch (1);
2983 if (actionSettingsAutoEditNewBranch->isOn())
2985 if (!actionSettingsAutoSelectNewBranch->isOn())
2986 prevSelection=me->getModel()->getSelectString(bo); //TODO access directly
2992 void Main::editImportAdd()
2994 fileLoad (ImportAdd);
2997 void Main::editImportReplace()
2999 fileLoad (ImportReplace);
3002 void Main::editSaveBranch()
3004 fileSaveAs (PartOfMap);
3007 void Main::editDeleteKeepChilds()
3009 if (currentMapEditor())
3010 currentMapEditor()->deleteKeepChilds();
3013 void Main::editDeleteChilds()
3015 if (currentMapEditor())
3016 currentMapEditor()->deleteChilds();
3019 void Main::editDeleteSelection()
3021 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3022 currentMapEditor()->deleteSelection();
3025 void Main::editUpperBranch()
3027 if (currentMapEditor())
3028 currentMapEditor()->selectUpperBranch();
3031 void Main::editLowerBranch()
3033 if (currentMapEditor())
3034 currentMapEditor()->selectLowerBranch();
3037 void Main::editLeftBranch()
3039 if (currentMapEditor())
3040 currentMapEditor()->selectLeftBranch();
3043 void Main::editRightBranch()
3045 if (currentMapEditor())
3046 currentMapEditor()->selectRightBranch();
3049 void Main::editFirstBranch()
3051 if (currentMapEditor())
3052 currentMapEditor()->selectFirstBranch();
3055 void Main::editLastBranch()
3057 if (currentMapEditor())
3058 currentMapEditor()->selectLastBranch();
3061 void Main::editLoadImage()
3063 if (currentMapEditor())
3064 currentMapEditor()->loadFloatImage();
3067 void Main::editSaveImage()
3069 if (currentMapEditor())
3070 currentMapEditor()->saveFloatImage();
3073 void Main::editFollowXLink(QAction *a)
3076 if (currentMapEditor())
3077 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3080 void Main::editEditXLink(QAction *a)
3082 if (currentMapEditor())
3083 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3086 void Main::formatSelectColor()
3088 if (currentMapEditor())
3090 QColor col = QColorDialog::getColor((currentColor ), this );
3091 if ( !col.isValid() ) return;
3092 colorChanged( col );
3096 void Main::formatPickColor()
3098 if (currentMapEditor())
3099 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3102 void Main::colorChanged(QColor c)
3104 QPixmap pix( 16, 16 );
3106 actionFormatColor->setIconSet( pix );
3110 void Main::formatColorBranch()
3112 if (currentMapEditor())
3113 currentMapEditor()->colorBranch(currentColor);
3116 void Main::formatColorSubtree()
3118 if (currentMapEditor())
3119 currentMapEditor()->colorSubtree (currentColor);
3122 void Main::formatLinkStyleLine()
3124 if (currentMapEditor())
3126 currentMapEditor()->setMapLinkStyle("StyleLine");
3127 actionFormatLinkStyleLine->setOn(true);
3131 void Main::formatLinkStyleParabel()
3133 if (currentMapEditor())
3135 currentMapEditor()->setMapLinkStyle("StyleParabel");
3136 actionFormatLinkStyleParabel->setOn(true);
3140 void Main::formatLinkStylePolyLine()
3142 if (currentMapEditor())
3144 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3145 actionFormatLinkStylePolyLine->setOn(true);
3149 void Main::formatLinkStylePolyParabel()
3151 if (currentMapEditor())
3153 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3154 actionFormatLinkStylePolyParabel->setOn(true);
3158 void Main::formatSelectBackColor()
3160 if (currentMapEditor())
3161 currentMapEditor()->selectMapBackgroundColor();
3164 void Main::formatSelectBackImage()
3166 if (currentMapEditor())
3167 currentMapEditor()->selectMapBackgroundImage();
3170 void Main::formatSelectLinkColor()
3172 if (currentMapEditor())
3173 currentMapEditor()->selectMapLinkColor();
3176 void Main::formatSelectSelectionColor()
3178 if (currentMapEditor())
3179 currentMapEditor()->selectMapSelectionColor();
3182 void Main::formatToggleLinkColorHint()
3184 currentMapEditor()->toggleMapLinkColorHint();
3188 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3190 if (currentMapEditor())
3191 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3194 void Main::viewZoomReset()
3196 if (currentMapEditor())
3200 currentMapEditor()->setMatrix( m );
3204 void Main::viewZoomIn()
3206 if (currentMapEditor())
3208 QMatrix m = currentMapEditor()->matrix();
3209 m.scale( 1.25, 1.25 );
3210 currentMapEditor()->setMatrix( m );
3214 void Main::viewZoomOut()
3216 if (currentMapEditor())
3218 QMatrix m = currentMapEditor()->matrix();
3219 m.scale( 0.8, 0.8 );
3220 currentMapEditor()->setMatrix( m );
3224 void Main::viewCenter()
3226 MapEditor *me=currentMapEditor();
3229 me->ensureSelectionVisible();
3233 void Main::networkStartServer()
3235 MapEditor *me=currentMapEditor();
3236 if (me) me->newServer();
3239 void Main::networkConnect()
3241 MapEditor *me=currentMapEditor();
3242 if (me) me->connectToServer();
3245 bool Main::settingsPDF()
3247 // Default browser is set in constructor
3249 QString text = QInputDialog::getText(
3250 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3251 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3253 settings.setValue ("/mainwindow/readerPDF",text);
3258 bool Main::settingsURL()
3260 // Default browser is set in constructor
3262 QString text = QInputDialog::getText(
3263 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3264 settings.value("/mainwindow/readerURL").toString()
3267 settings.setValue ("/mainwindow/readerURL",text);
3271 void Main::settingsMacroDir()
3273 QDir defdir(vymBaseDir.path() + "/macros");
3274 if (!defdir.exists())
3276 QDir dir=QFileDialog::getExistingDirectory (
3278 tr ("Directory with vym macros:"),
3279 settings.value ("/macros/macroDir",defdir.path()).toString()
3282 settings.setValue ("/macros/macroDir",dir.absolutePath());
3285 void Main::settingsUndoLevels()
3288 int i = QInputDialog::getInteger(
3290 tr("QInputDialog::getInteger()"),
3291 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3294 settings.setValue ("/mapeditor/stepsTotal",i);
3295 QMessageBox::information( this, tr( "VYM -Information:" ),
3296 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3300 void Main::settingsAutosaveToggle()
3302 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3305 void Main::settingsAutosaveTime()
3308 int i = QInputDialog::getInteger(
3310 tr("QInputDialog::getInteger()"),
3311 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3313 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3316 void Main::settingsWriteBackupFileToggle()
3318 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3321 void Main::settingsToggleAnimation()
3323 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3326 void Main::settingsToggleDelKey()
3328 if (actionSettingsUseDelKey->isOn())
3330 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3333 actionEditDelete->setAccel (QKeySequence (""));
3337 void Main::windowToggleNoteEditor()
3339 if (textEditor->isVisible() )
3340 windowHideNoteEditor();
3342 windowShowNoteEditor();
3345 void Main::windowToggleHistory()
3347 if (historyWindow->isVisible())
3348 historyWindow->hide();
3350 historyWindow->show();
3354 void Main::windowToggleProperty()
3356 if (branchPropertyWindow->isVisible())
3357 branchPropertyWindow->hide();
3359 branchPropertyWindow->show();
3361 if(currentMapEditor())
3363 BranchObj *bo=currentMapEditor()->getSelectedBranch();
3366 branchPropertyWindow->setMapEditor(currentMapEditor());
3367 branchPropertyWindow->setBranch(bo);
3372 branchPropertyWindow->setBranch(NULL);
3375 void Main::windowToggleAntiAlias()
3377 bool b=actionViewToggleAntiAlias->isOn();
3379 for (int i=0;i<tabWidget->count();i++)
3382 me=(MapEditor*)tabWidget->page(i);
3383 me->setAntiAlias(b);
3388 void Main::windowToggleSmoothPixmap()
3390 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3392 for (int i=0;i<tabWidget->count();i++)
3395 me=(MapEditor*)tabWidget->page(i);
3396 me->setSmoothPixmap(b);
3400 void Main::updateHistory(SimpleSettings &undoSet)
3402 historyWindow->update (undoSet);
3405 void Main::updateNoteFlag()
3407 if (currentMapEditor())
3408 currentMapEditor()->updateNoteFlag();
3411 void Main::updateSatellites(MapEditor *me)
3413 branchPropertyWindow->setMapEditor (me);
3416 void Main::updateActions()
3418 MapEditor *me=currentMapEditor();
3421 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3423 // updateActions is also called when NoteEditor is closed
3424 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3425 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3426 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3428 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3429 actionFormatLinkColorHint->setOn(true);
3431 actionFormatLinkColorHint->setOn(false);
3433 switch (me->getMapLinkStyle())
3435 case LinkableMapObj::Line:
3436 actionFormatLinkStyleLine->setOn(true);
3438 case LinkableMapObj::Parabel:
3439 actionFormatLinkStyleParabel->setOn(true);
3441 case LinkableMapObj::PolyLine:
3442 actionFormatLinkStylePolyLine->setOn(true);
3444 case LinkableMapObj::PolyParabel:
3445 actionFormatLinkStylePolyParabel->setOn(true);
3452 QPixmap pix( 16, 16 );
3453 pix.fill( me->getMapBackgroundColor() );
3454 actionFormatBackColor->setIconSet( pix );
3455 pix.fill( me->getSelectionColor() );
3456 actionFormatSelectionColor->setIconSet( pix );
3457 pix.fill( me->getMapDefLinkColor() );
3458 actionFormatLinkColor->setIconSet( pix );
3461 actionFileSave->setEnabled( me->hasChanged() );
3462 if (me->isUndoAvailable())
3463 actionEditUndo->setEnabled( true);
3465 actionEditUndo->setEnabled( false);
3467 if (me->isRedoAvailable())
3468 actionEditRedo->setEnabled( true);
3470 actionEditRedo->setEnabled( false);
3472 LinkableMapObj *selection=me->getSelection();
3475 if ( (typeid(*selection) == typeid(BranchObj)) ||
3476 (typeid(*selection) == typeid(MapCenterObj)) )
3478 BranchObj *bo=(BranchObj*)selection;
3479 // Take care of links
3480 if (bo->countXLinks()==0)
3482 branchXLinksContextMenuEdit->clear();
3483 branchXLinksContextMenuFollow->clear();
3488 branchXLinksContextMenuEdit->clear();
3489 branchXLinksContextMenuFollow->clear();
3490 for (int i=0; i<=bo->countXLinks();i++)
3492 bot=bo->XLinkTargetAt(i);
3495 s=bot->getHeading();
3496 if (s.length()>xLinkMenuWidth)
3497 s=s.left(xLinkMenuWidth)+"...";
3498 branchXLinksContextMenuFollow->addAction (s);
3499 branchXLinksContextMenuEdit->addAction (s);
3504 standardFlagsDefault->setEnabled (true);
3506 actionEditToggleScroll->setEnabled (true);
3507 if ( bo->isScrolled() )
3508 actionEditToggleScroll->setOn(true);
3510 actionEditToggleScroll->setOn(false);
3512 if ( bo->getURL().isEmpty() )
3514 actionEditOpenURL->setEnabled (false);
3515 actionEditOpenURLTab->setEnabled (false);
3519 actionEditOpenURL->setEnabled (true);
3520 actionEditOpenURLTab->setEnabled (true);
3522 if ( bo->getVymLink().isEmpty() )
3524 actionEditOpenVymLink->setEnabled (false);
3525 actionEditDeleteVymLink->setEnabled (false);
3528 actionEditOpenVymLink->setEnabled (true);
3529 actionEditDeleteVymLink->setEnabled (true);
3532 if (bo->canMoveBranchUp())
3533 actionEditMoveUp->setEnabled (true);
3535 actionEditMoveUp->setEnabled (false);
3536 if (bo->canMoveBranchDown())
3537 actionEditMoveDown->setEnabled (true);
3539 actionEditMoveDown->setEnabled (false);
3542 actionEditToggleHideExport->setEnabled (true);
3543 actionEditToggleHideExport->setOn (bo->hideInExport() );
3545 actionEditCopy->setEnabled (true);
3546 actionEditCut->setEnabled (true);
3547 if (!clipboardEmpty)
3548 actionEditPaste->setEnabled (true);
3550 actionEditPaste->setEnabled (false);
3551 for (int i=0; i<actionListBranches.size(); ++i)
3552 actionListBranches.at(i)->setEnabled(true);
3553 actionEditDelete->setEnabled (true);
3554 actionFormatHideLinkUnselected->setOn
3555 (selection->getHideLinkUnselected());
3557 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3559 FloatObj *fo=(FloatImageObj*)selection;
3561 actionEditOpenURL->setEnabled (false);
3562 actionEditOpenVymLink->setEnabled (false);
3563 actionEditDeleteVymLink->setEnabled (false);
3564 actionEditToggleHideExport->setEnabled (true);
3565 actionEditToggleHideExport->setOn (fo->hideInExport() );
3568 actionEditCopy->setEnabled (true);
3569 actionEditCut->setEnabled (true);
3570 actionEditPaste->setEnabled (false);
3571 for (int i=0; i<actionListBranches.size(); ++i)
3572 actionListBranches.at(i)->setEnabled(false);
3573 actionEditDelete->setEnabled (true);
3574 actionFormatHideLinkUnselected->setOn
3575 ( selection->getHideLinkUnselected());
3576 actionEditMoveUp->setEnabled (false);
3577 actionEditMoveDown->setEnabled (false);
3582 actionEditCopy->setEnabled (false);
3583 actionEditCut->setEnabled (false);
3584 actionEditPaste->setEnabled (false);
3585 for (int i=0; i<actionListBranches.size(); ++i)
3586 actionListBranches.at(i)->setEnabled(false);
3588 actionEditToggleScroll->setEnabled (false);
3589 actionEditOpenURL->setEnabled (false);
3590 actionEditOpenVymLink->setEnabled (false);
3591 actionEditDeleteVymLink->setEnabled (false);
3592 actionEditHeading2URL->setEnabled (false);
3593 actionEditDelete->setEnabled (false);
3594 actionEditMoveUp->setEnabled (false);
3595 actionEditMoveDown->setEnabled (false);
3596 actionEditToggleHideExport->setEnabled (false);
3600 Main::ModMode Main::getModMode()
3602 if (actionModModeColor->isOn()) return ModModeColor;
3603 if (actionModModeCopy->isOn()) return ModModeCopy;
3604 if (actionModModeXLink->isOn()) return ModModeXLink;
3608 bool Main::autoEditNewBranch()
3610 return actionSettingsAutoEditNewBranch->isOn();
3613 bool Main::autoSelectNewBranch()
3615 return actionSettingsAutoSelectNewBranch->isOn();
3618 bool Main::useFlagGroups()
3620 return actionSettingsUseFlagGroups->isOn();
3623 void Main::windowShowNoteEditor()
3625 textEditor->setShowWithMain(true);
3627 actionViewToggleNoteEditor->setOn (true);
3630 void Main::windowHideNoteEditor()
3632 textEditor->setShowWithMain(false);
3634 actionViewToggleNoteEditor->setOn (false);
3637 void Main::setScript (const QString &script)
3639 scriptEditor->setScript (script);
3642 void Main::runScript (const QString &script)
3644 if (currentMapEditor())
3645 currentMapEditor()->runScript (script);
3648 void Main::runScriptEverywhere (const QString &script)
3651 for (int i=0;i<=tabWidget->count() -1;i++)
3653 me=(MapEditor*)tabWidget->page(i);
3654 if (me) me->runScript (script);
3658 void Main::windowNextEditor()
3660 if (tabWidget->currentPageIndex() < tabWidget->count())
3661 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3664 void Main::windowPreviousEditor()
3666 if (tabWidget->currentPageIndex() >0)
3667 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3670 void Main::standardFlagChanged()
3672 if (currentMapEditor())
3673 currentMapEditor()->toggleStandardFlag(sender()->name());
3676 void Main::testFunction1()
3678 if (!currentMapEditor()) return;
3679 currentMapEditor()->testFunction1();
3683 void Main::testFunction2()
3685 if (!currentMapEditor()) return;
3686 currentMapEditor()->testFunction2();
3689 void Main::testCommand()
3691 if (!currentMapEditor()) return;
3692 scriptEditor->show();
3695 QString com = QInputDialog::getText(
3696 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3697 if (ok) currentMapEditor()->parseAtom(com);
3701 void Main::helpDoc()
3703 QString locale = QLocale::system().name();
3705 if (locale.left(2)=="es")
3706 docname="vym_es.pdf";
3710 QStringList searchList;
3712 #if defined(Q_OS_MACX)
3713 searchList << "./vym.app/Contents/Resources/doc";
3714 #elif defined(Q_OS_WIN32)
3715 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3717 #if defined(VYM_DOCDIR)
3718 searchList << VYM_DOCDIR;
3720 // default path in SUSE LINUX
3721 searchList << "/usr/share/doc/packages/vym";
3724 searchList << "doc"; // relative path for easy testing in tarball
3725 searchList << "doc/tex"; // Easy testing working on vym.tex
3726 searchList << "/usr/share/doc/vym"; // Debian
3727 searchList << "/usr/share/doc/packages";// Knoppix
3731 for (int i=0; i<searchList.count(); ++i)
3733 docfile.setFileName(searchList.at(i)+"/"+docname);
3734 if (docfile.exists())
3743 QMessageBox::critical(0,
3744 tr("Critcal error"),
3745 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3750 Process *pdfProc = new Process();
3751 args << QDir::toNativeSeparators(docfile.fileName());
3753 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3754 if ( !pdfProc->waitForStarted() )
3757 QMessageBox::warning(0,
3759 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3760 tr("Please use Settings->")+tr("Set application to open PDF files"));
3767 void Main::helpDemo()
3769 QStringList filters;
3770 filters <<"VYM example map (*.vym)";
3771 QFileDialog *fd=new QFileDialog( this);
3772 #if defined(Q_OS_MACX)
3773 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3775 // default path in SUSE LINUX
3776 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3779 fd->setFileMode (QFileDialog::ExistingFiles);
3780 fd->setFilters (filters);
3781 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3785 if ( fd->exec() == QDialog::Accepted )
3787 lastFileDir=fd->directory().path();
3788 QStringList flist = fd->selectedFiles();
3789 QStringList::Iterator it = flist.begin();
3790 while( it != flist.end() )
3793 fileLoad(*it, NewMap);
3801 void Main::helpAbout()
3804 ad.setName ("aboutwindow");
3805 ad.setMinimumSize(500,500);
3806 ad.resize (QSize (500,500));
3810 void Main::helpAboutQT()
3812 QMessageBox::aboutQt( this, "Qt Application Example" );
3815 void Main::callMacro ()
3817 QAction *action = qobject_cast<QAction *>(sender());
3821 i=action->data().toInt();
3822 QString mDir (settings.value ("macros/macroDir").toString() );
3824 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3826 if ( !f.open( QIODevice::ReadOnly ) )
3828 QMessageBox::warning(0,
3830 tr("Couldn't find a macro at %1.\n").arg(fn)+
3831 tr("Please use Settings->")+tr("Set directory for vym macros"));
3835 QTextStream ts( &f );
3836 QString m= ts.read();
3840 //cout <<"Main::callMacro m="<<qPrintable (m)<<endl;
3841 currentMapEditor()->runScript (m);
3848 //////////////////////////////////
3850 @@ -2544,18 +2576,27 @@
3851 // Try to open new tab in existing konqueror started previously by vym
3852 p=new QProcess (this);
3854 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3855 - "konqueror-mainwindow#1"<<
3857 +#if defined(Q_OS_WIN32)
3858 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3859 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3860 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3861 + "konqueror-mainwindow#1"<<
3865 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3866 + "konqueror-mainwindow#1"<<
3870 p->start ("dcop",args);
3871 if ( !p->waitForStarted() ) success=false;