1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "exportoofiledialog.h"
13 #include "flagrowobj.h"
14 #include "historywindow.h"
16 #include "mapeditor.h"
21 #include "texteditor.h"
22 #include "warningdialog.h"
24 #if defined(Q_OS_WIN32)
25 // Define only this structure as opposed to
26 // including full 'windows.h'. FindWindow
27 // clashes with the one in Win32 API.
28 typedef struct _PROCESS_INFORMATION
34 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
37 extern TextEditor *textEditor;
38 extern Main *mainWindow;
39 extern QString tmpVymDir;
40 extern QString clipboardDir;
41 extern QString clipboardFile;
42 extern bool clipboardEmpty;
43 extern int statusbarTime;
44 extern FlagRowObj* standardFlagsDefault;
45 extern FlagRowObj* systemFlagsDefault;
46 extern QString vymName;
47 extern QString vymVersion;
48 extern QString vymBuildDate;
51 QMenu* branchContextMenu;
52 QMenu* branchAddContextMenu;
53 QMenu* branchRemoveContextMenu;
54 QMenu* branchLinksContextMenu;
55 QMenu* branchXLinksContextMenuEdit;
56 QMenu* branchXLinksContextMenuFollow;
57 QMenu* floatimageContextMenu;
58 QMenu* canvasContextMenu;
59 QMenu* fileLastMapsMenu;
60 QMenu* fileImportMenu;
61 QMenu* fileExportMenu;
64 extern Settings settings;
65 extern Options options;
66 extern ImageIO imageIO;
68 extern QDir vymBaseDir;
69 extern QDir lastImageDir;
70 extern QDir lastFileDir;
71 #if defined(Q_OS_WIN32)
72 extern QDir vymInstallDir;
74 extern QString iconPath;
75 extern QString flagsPath;
77 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
78 QMainWindow(parent,name,f)
82 setCaption ("VYM - View Your Mind");
84 // Load window settings
85 #if defined(Q_OS_WIN32)
86 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
88 setWindowState(Qt::WindowMaximized);
93 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
94 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
97 // Sometimes we may need to remember old selections
101 currentColor=Qt::black;
103 // Create unique temporary directory
105 tmpVymDir=makeTmpDir (ok,"vym");
108 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
111 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
113 // Create direcctory for clipboard
114 clipboardDir=tmpVymDir+"/clipboard";
115 clipboardFile="map.xml";
116 QDir d(clipboardDir);
117 d.mkdir (clipboardDir,true);
118 makeSubDirs (clipboardDir);
123 // Satellite windows //////////////////////////////////////////
126 historyWindow=new HistoryWindow();
127 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
130 branchPropertyWindow = new BranchPropertyWindow();
131 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
133 // Connect TextEditor, so that we can update flags if text changes
134 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
135 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
137 // Connect HistoryWindow, so that we can update flags
138 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
141 // Initialize script editor
142 scriptEditor = new SimpleScriptEditor();
143 scriptEditor->move (50,50);
145 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
146 this, SLOT( runScript( QString ) ) );
149 // Initialize Find window
150 findWindow=new FindWindow(NULL);
151 findWindow->move (x(),y()+70);
152 connect (findWindow, SIGNAL( findButton(QString) ),
153 this, SLOT(editFind(QString) ) );
154 connect (findWindow, SIGNAL( somethingChanged() ),
155 this, SLOT(editFindChanged() ) );
157 // Initialize some settings, which are platform dependant
160 // application to open URLs
161 p="/mainwindow/readerURL";
162 #if defined(Q_OS_LINUX)
163 s=settings.value (p,"xdg-open").toString();
165 #if defined(Q_OS_MACX)
166 s=settings.value (p,"/usr/bin/open").toString();
169 #if defined(Q_OS_WIN32)
170 // Assume that system has been set up so that
171 // Explorer automagically opens up the URL
172 // in the user's preferred browser.
173 s=settings.value (p,"explorer").toString();
175 s=settings.value (p,"mozilla").toString();
179 settings.setValue( p,s);
181 // application to open PDFs
182 p="/mainwindow/readerPDF";
183 #if defined(Q_OS_LINUX)
184 s=settings.value (p,"xdg-open").toString();
186 #if defined(Q_OS_MACX)
187 s=settings.value (p,"/usr/bin/open").toString();
188 #elif defined(Q_OS_WIN32)
189 s=settings.value (p,"acrord32").toString();
191 s=settings.value (p,"acroread").toString();
194 settings.setValue( p,s);
196 // width of xLinksMenu
199 // Create tab widget which holds the maps
200 tabWidget= new QTabWidget (this);
201 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
202 this, SLOT( editorChanged( QWidget * ) ) );
204 lineedit=new QLineEdit (this);
207 setCentralWidget(tabWidget);
211 setupFormatActions();
215 setupNetworkActions();
216 setupSettingsActions();
219 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
224 restoreState (settings.value("/mainwindow/state",0).toByteArray());
232 #if defined(Q_OS_WIN32)
233 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
235 settings.setValue ("/mainwindow/geometry/size", size());
236 settings.setValue ("/mainwindow/geometry/pos", pos());
237 settings.setValue ("/mainwindow/state",saveState(0));
239 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
240 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
241 settings.setValue( "/version/version", vymVersion );
242 settings.setValue( "/version/builddate", vymBuildDate );
244 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
245 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
246 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
247 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
248 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
249 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
250 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
251 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
253 //TODO save scriptEditor settings
255 // call the destructors
257 delete historyWindow;
258 delete branchPropertyWindow;
260 // Remove temporary directory
261 removeDir (QDir(tmpVymDir));
264 void Main::loadCmdLine()
266 /* TODO draw some kind of splashscreen while loading...
272 QStringList flist=options.getFileList();
273 QStringList::Iterator it=flist.begin();
275 while (it !=flist.end() )
277 fileLoad (*it, NewMap);
283 void Main::statusMessage(const QString &s)
285 statusBar()->message( s);
288 void Main::closeEvent (QCloseEvent* )
294 void Main::setupFileActions()
296 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
297 QToolBar *tb = addToolBar( tr ("&Map") );
298 tb->setObjectName ("mapTB");
301 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
302 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
303 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
305 fileMenu->addAction (a);
306 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
308 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
309 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
310 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
311 fileMenu->addAction (a);
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
314 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
315 a->setStatusTip (tr( "Open","Status tip File menu" ) );
316 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
318 fileMenu->addAction (a);
319 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
321 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
322 fileMenu->addSeparator();
324 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
325 a->setStatusTip ( tr( "Save","Status tip file menu" ));
326 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
328 fileMenu->addAction (a);
329 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
332 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
333 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
334 fileMenu->addAction (a);
335 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
337 fileMenu->addSeparator();
339 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
341 a = new QAction(tr("KDE Bookmarks"), this);
342 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
343 a->addTo (fileImportMenu);
344 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
346 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
348 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
349 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
350 a->addTo (fileImportMenu);
351 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
354 a = new QAction("Freemind...",this);
355 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
356 fileImportMenu->addAction (a);
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
359 a = new QAction("Mind Manager...",this);
360 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
361 fileImportMenu->addAction (a);
362 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
364 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
365 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
366 fileImportMenu->addAction (a);
367 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
369 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
371 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
372 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
373 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
374 fileExportMenu->addAction (a);
376 a = new QAction( "Open Office...", this);
377 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
378 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
379 fileExportMenu->addAction (a);
381 a = new QAction( "Webpage (XHTML)...",this );
382 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
383 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
384 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
385 fileExportMenu->addAction (a);
387 a = new QAction( "Text (ASCII)...", this);
388 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
389 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
390 fileExportMenu->addAction (a);
392 a = new QAction( "Spreadsheet (CSV)...", this);
393 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
394 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
395 fileExportMenu->addAction (a);
397 a = new QAction( tr("KDE Bookmarks","File menu"), this);
398 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
399 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
400 fileExportMenu->addAction (a);
402 a = new QAction( "Taskjuggler...", this );
403 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
404 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
405 fileExportMenu->addAction (a);
407 a = new QAction( "LaTeX...", this);
408 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
409 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
410 fileExportMenu->addAction (a);
412 a = new QAction( "XML..." , this );
413 a->setStatusTip (tr( "Export as %1").arg("XML"));
414 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
415 fileExportMenu->addAction (a);
417 fileMenu->addSeparator();
419 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
420 a->setStatusTip ( tr( "Print" ,"File menu") );
421 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
423 fileMenu->addAction (a);
424 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
427 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
428 a->setStatusTip (tr( "Close Map" ) );
429 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
430 fileMenu->addAction (a);
431 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
433 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
434 a->setStatusTip ( tr( "Exit")+" "+vymName );
435 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
436 fileMenu->addAction (a);
437 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
442 void Main::setupEditActions()
444 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
445 tb->setLabel( "Edit Actions" );
446 tb->setObjectName ("actionsTB");
447 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
451 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
452 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
453 a->setStatusTip (tr( "Undo" ) );
454 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
455 a->setEnabled (false);
457 editMenu->addAction (a);
460 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
461 a->setStatusTip (tr( "Redo" ));
462 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
464 editMenu->addAction (a);
465 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
468 editMenu->addSeparator();
469 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
470 a->setStatusTip ( tr( "Copy" ) );
471 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
472 a->setEnabled (false);
474 editMenu->addAction (a);
475 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
478 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
479 a->setStatusTip ( tr( "Cut" ) );
480 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
481 a->setEnabled (false);
483 editMenu->addAction (a);
485 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
487 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
488 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
489 a->setStatusTip ( tr( "Paste" ) );
490 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
491 a->setEnabled (false);
493 editMenu->addAction (a);
496 // Shortcuts to modify heading:
497 a = new QAction(tr( "Edit heading","Edit menu" ),this);
498 a->setStatusTip ( tr( "edit Heading" ));
499 a->setShortcut ( Qt::Key_Enter); //Edit heading
500 // a->setShortcutContext (Qt::WindowShortcut);
502 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
503 actionListBranches.append(a);
504 a = new QAction( tr( "Edit heading","Edit menu" ), this);
505 a->setStatusTip (tr( "edit Heading" ));
506 a->setShortcut (Qt::Key_Return ); //Edit heading
507 //a->setShortcutContext (Qt::WindowShortcut);
509 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
510 actionListBranches.append(a);
511 editMenu->addAction (a);
513 a = new QAction( tr( "Edit heading","Edit menu" ), this);
514 a->setStatusTip (tr( "edit Heading" ));
515 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
516 a->setShortcutContext (Qt::WindowShortcut);
518 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
519 actionListBranches.append(a);
521 // Shortcut to delete selection
522 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
523 a->setStatusTip (tr( "Delete Selection" ));
524 a->setShortcut ( Qt::Key_Delete); //Delete selection
525 a->setShortcutContext (Qt::WindowShortcut);
527 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
530 // Shortcut to add branch
531 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
532 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
533 alt->setShortcut (Qt::Key_A); //Add branch
534 alt->setShortcutContext (Qt::WindowShortcut);
536 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
537 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
538 a->setStatusTip ( tr( "Add a branch as child of selection" ));
539 a->setShortcut (Qt::Key_Insert); //Add branch
540 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
541 actionListBranches.append(a);
542 #if defined (Q_OS_MACX)
543 // In OSX show different shortcut in menues, the keys work indepently always
544 actionEditAddBranch=alt;
546 actionEditAddBranch=a;
548 editMenu->addAction (actionEditAddBranch);
549 tb->addAction (actionEditAddBranch);
552 // Add branch by inserting it at selection
553 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
554 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
555 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
556 a->setShortcutContext (Qt::WindowShortcut);
558 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
559 a->setEnabled (false);
560 actionListBranches.append(a);
561 actionEditAddBranchBefore=a;
562 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
563 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
564 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
565 a->setShortcutContext (Qt::WindowShortcut);
567 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
568 actionListBranches.append(a);
571 a = new QAction(tr( "Add branch above","Edit menu" ), this);
572 a->setStatusTip ( tr( "Add a branch above selection" ));
573 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
574 a->setShortcutContext (Qt::WindowShortcut);
576 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
577 a->setEnabled (false);
578 actionListBranches.append(a);
579 actionEditAddBranchAbove=a;
580 a = new QAction(tr( "Add branch above","Edit menu" ), this);
581 a->setStatusTip ( tr( "Add a branch above selection" ));
582 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
583 a->setShortcutContext (Qt::WindowShortcut);
585 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
586 actionListBranches.append(a);
589 a = new QAction(tr( "Add branch below","Edit menu" ), this);
590 a->setStatusTip ( tr( "Add a branch below selection" ));
591 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
592 a->setShortcutContext (Qt::WindowShortcut);
594 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
595 a->setEnabled (false);
596 actionListBranches.append(a);
597 actionEditAddBranchBelow=a;
598 a = new QAction(tr( "Add branch below","Edit menu" ), this);
599 a->setStatusTip ( tr( "Add a branch below selection" ));
600 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
601 a->setShortcutContext (Qt::WindowShortcut);
603 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
604 actionListBranches.append(a);
606 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
607 a->setStatusTip ( tr( "Move branch up" ) );
608 a->setShortcut (Qt::Key_PageUp ); // Move branch up
609 a->setEnabled (false);
611 editMenu->addAction (a);
612 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
615 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
616 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
617 a->setStatusTip (tr( "Move branch down" ) );
618 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
619 a->setEnabled (false);
621 editMenu->addAction (a);
622 actionEditMoveDown=a;
624 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
625 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
626 a->setEnabled (true);
628 editMenu->addAction (a);
629 actionEditSortChildren=a;
631 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
632 a->setShortcut ( Qt::Key_ScrollLock );
633 a->setStatusTip (tr( "Scroll branch" ) );
634 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
636 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
637 alt->setShortcut ( Qt::Key_S ); // Scroll branch
638 alt->setStatusTip (tr( "Scroll branch" ));
639 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
640 #if defined(Q_OS_MACX)
641 actionEditToggleScroll=alt;
643 actionEditToggleScroll=a;
645 actionEditToggleScroll->setEnabled (false);
646 actionEditToggleScroll->setToggleAction(true);
647 tb->addAction (actionEditToggleScroll);
648 editMenu->addAction ( actionEditToggleScroll);
649 editMenu->addAction (actionEditToggleScroll);
652 actionListBranches.append(actionEditToggleScroll);
654 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
655 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
656 editMenu->addAction (a);
657 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
659 editMenu->addSeparator();
661 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
662 a->setStatusTip (tr( "Find" ) );
663 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
664 editMenu->addAction (a);
665 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
667 editMenu->addSeparator();
669 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
670 a->setShortcut (Qt::CTRL + Qt::Key_U );
671 a->setShortcut (tr( "Open URL" ));
674 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
677 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
678 a->setStatusTip (tr( "Open URL in new tab" ));
679 //a->setShortcut (Qt::CTRL+Qt::Key_U );
681 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
682 actionEditOpenURLTab=a;
684 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
685 a->setStatusTip (tr( "Open all URLs in subtree" ));
687 actionListBranches.append(a);
688 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
689 actionEditOpenMultipleURLTabs=a;
691 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
692 a->setStatusTip ( tr( "Edit URL" ) );
693 a->setShortcut ( Qt::Key_U );
694 a->setShortcutContext (Qt::WindowShortcut);
695 actionListBranches.append(a);
697 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
700 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
701 a->setStatusTip ( tr( "Edit local URL" ) );
702 a->setShortcut (Qt::SHIFT + Qt::Key_U );
703 a->setShortcutContext (Qt::WindowShortcut);
704 actionListBranches.append(a);
706 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
707 actionEditLocalURL=a;
709 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
710 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
711 a->setEnabled (false);
712 actionListBranches.append(a);
713 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
714 actionEditHeading2URL=a;
716 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
717 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
718 a->setEnabled (false);
719 actionListBranches.append(a);
720 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
721 actionEditBugzilla2URL=a;
723 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
724 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
725 a->setEnabled (false);
726 actionListBranches.append(a);
727 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
728 actionEditFATE2URL=a;
730 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
731 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
733 a->setEnabled (false);
734 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
735 actionEditOpenVymLink=a;
737 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
738 a->setStatusTip ( tr( "Open all vym links in subtree" ));
739 a->setEnabled (false);
740 actionListBranches.append(a);
741 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
742 actionEditOpenMultipleVymLinks=a;
745 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
746 a->setEnabled (false);
747 a->setStatusTip ( tr( "Edit link to another vym map" ));
748 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
749 actionListBranches.append(a);
752 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
753 a->setStatusTip ( tr( "Delete link to another vym map" ));
754 a->setEnabled (false);
755 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
756 actionEditDeleteVymLink=a;
758 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
759 a->setStatusTip ( tr( "Hide object in exports" ) );
760 a->setShortcut (Qt::Key_H );
761 a->setToggleAction(true);
763 a->setEnabled (false);
764 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
765 actionEditToggleHideExport=a;
767 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
768 a->setStatusTip ( tr( "Edit Map Info" ));
769 a->setEnabled (true);
770 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
773 // Import at selection (adding to selection)
774 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
775 a->setStatusTip (tr( "Add map at selection" ));
776 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
777 a->setEnabled (false);
778 actionListBranches.append(a);
779 actionEditImportAdd=a;
781 // Import at selection (replacing selection)
782 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
783 a->setStatusTip (tr( "Replace selection with map" ));
784 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
785 a->setEnabled (false);
786 actionListBranches.append(a);
787 actionEditImportReplace=a;
790 a = new QAction( tr( "Save selection","Edit menu" ), this);
791 a->setStatusTip (tr( "Save selection" ));
792 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
793 a->setEnabled (false);
794 actionListBranches.append(a);
795 actionEditSaveBranch=a;
797 // Only remove branch, not its childs
798 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
799 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
800 a->setShortcut (Qt::ALT + Qt::Key_Delete );
801 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
802 a->setEnabled (false);
804 actionListBranches.append(a);
805 actionEditDeleteKeepChilds=a;
807 // Only remove childs of a branch
808 a = new QAction( tr( "Remove childs","Edit menu" ), this);
809 a->setStatusTip (tr( "Remove childs of branch" ));
810 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
811 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
812 a->setEnabled (false);
813 actionListBranches.append(a);
814 actionEditDeleteChilds=a;
816 // Shortcuts for navigating with cursor:
817 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
818 a->setStatusTip ( tr( "Select upper branch" ));
819 a->setShortcut (Qt::Key_Up );
820 a->setShortcutContext (Qt::WindowShortcut);
822 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
823 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
824 a->setStatusTip (tr( "Select lower branch" ));
825 a->setShortcut ( Qt::Key_Down );
826 a->setShortcutContext (Qt::WindowShortcut);
828 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
829 a = new QAction(tr( "Select left branch","Edit menu" ), this);
830 a->setStatusTip ( tr( "Select left branch" ));
831 a->setShortcut (Qt::Key_Left );
832 a->setShortcutContext (Qt::WindowShortcut);
834 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
835 a = new QAction( tr( "Select child branch","Edit menu" ), this);
836 a->setStatusTip (tr( "Select right branch" ));
837 a->setShortcut (Qt::Key_Right);
838 a->setShortcutContext (Qt::WindowShortcut);
840 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
841 a = new QAction( tr( "Select first branch","Edit menu" ), this);
842 a->setStatusTip (tr( "Select first branch" ));
843 a->setShortcut (Qt::Key_Home );
844 a->setShortcutContext (Qt::WindowShortcut);
846 a->setEnabled (false);
847 editMenu->addAction (a);
848 actionListBranches.append(a);
849 actionEditSelectFirst=a;
850 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
851 a = new QAction( tr( "Select last branch","Edit menu" ),this);
852 a->setStatusTip (tr( "Select last branch" ));
853 a->setShortcut ( Qt::Key_End );
854 a->setShortcutContext (Qt::WindowShortcut);
856 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
857 a->setEnabled (false);
858 editMenu->addAction (a);
859 actionListBranches.append(a);
860 actionEditSelectLast=a;
862 a = new QAction( tr( "Add Image...","Edit menu" ), this);
863 a->setStatusTip (tr( "Add Image" ));
864 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
865 actionEditLoadImage=a;
867 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
868 a->setStatusTip (tr( "Set properties for selection" ));
869 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
870 a->setShortcutContext (Qt::WindowShortcut);
871 a->setToggleAction (true);
873 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
874 actionViewTogglePropertyWindow=a;
878 void Main::setupFormatActions()
880 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
882 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
883 tb->setObjectName ("formatTB");
886 pix.fill (Qt::black);
887 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
888 a->setStatusTip ( tr( "Set Color" ));
889 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
891 formatMenu->addAction (a);
893 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
894 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
895 a->setShortcut (Qt::CTRL + Qt::Key_K );
896 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
897 a->setEnabled (false);
899 formatMenu->addAction (a);
900 actionListBranches.append(a);
901 actionFormatPickColor=a;
903 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
904 a->setStatusTip ( tr( "Color branch" ) );
905 a->setShortcut (Qt::CTRL + Qt::Key_B);
906 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
907 a->setEnabled (false);
909 formatMenu->addAction (a);
910 actionListBranches.append(a);
911 actionFormatColorSubtree=a;
913 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
914 a->setStatusTip ( tr( "Color Subtree" ));
915 a->setShortcut (Qt::CTRL + Qt::Key_T);
916 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
917 a->setEnabled (false);
918 formatMenu->addAction (a);
920 actionListBranches.append(a);
921 actionFormatColorSubtree=a;
923 formatMenu->addSeparator();
924 actionGroupFormatLinkStyles=new QActionGroup ( this);
925 actionGroupFormatLinkStyles->setExclusive (true);
926 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
927 a->setStatusTip (tr( "Line" ));
928 a->setToggleAction(true);
929 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
930 formatMenu->addAction (a);
931 actionFormatLinkStyleLine=a;
932 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
933 a->setStatusTip (tr( "Line" ));
934 a->setToggleAction(true);
935 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
936 formatMenu->addAction (a);
937 actionFormatLinkStyleParabel=a;
938 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
939 a->setStatusTip (tr( "PolyLine" ));
940 a->setToggleAction(true);
941 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
942 formatMenu->addAction (a);
943 actionFormatLinkStylePolyLine=a;
944 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
945 a->setStatusTip (tr( "PolyParabel" ) );
946 a->setToggleAction(true);
947 a->setChecked (true);
948 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
949 formatMenu->addAction (a);
950 actionFormatLinkStylePolyParabel=a;
952 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
953 a->setStatusTip (tr( "Hide link" ));
954 a->setToggleAction(true);
955 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
956 actionFormatHideLinkUnselected=a;
958 formatMenu->addSeparator();
959 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
960 a->setStatusTip (tr( "Use same color for links and headings" ));
961 a->setToggleAction(true);
962 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
963 formatMenu->addAction (a);
964 actionFormatLinkColorHint=a;
966 pix.fill (Qt::white);
967 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
968 a->setStatusTip (tr( "Set Link Color" ));
969 formatMenu->addAction (a);
970 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
971 actionFormatLinkColor=a;
973 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
974 a->setStatusTip (tr( "Set Selection Color" ));
975 formatMenu->addAction (a);
976 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
977 actionFormatSelectionColor=a;
979 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
980 a->setStatusTip (tr( "Set Background Color" ));
981 formatMenu->addAction (a);
982 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
983 actionFormatBackColor=a;
985 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
986 a->setStatusTip (tr( "Set Background image" ));
987 formatMenu->addAction (a);
988 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
989 actionFormatBackImage=a;
993 void Main::setupViewActions()
995 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
996 tb->setLabel( "View Actions" );
997 tb->setObjectName ("viewTB");
998 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1001 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1002 a->setStatusTip ( tr( "Zoom reset" ) );
1003 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1005 viewMenu->addAction (a);
1006 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1008 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1009 a->setStatusTip (tr( "Zoom in" ));
1010 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1012 viewMenu->addAction (a);
1013 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1015 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1016 a->setStatusTip (tr( "Zoom out" ));
1017 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1019 viewMenu->addAction (a);
1020 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1022 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1023 a->setStatusTip (tr( "Show selection" ));
1024 a->setShortcut (Qt::Key_Period);
1026 viewMenu->addAction (a);
1027 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1029 viewMenu->addSeparator();
1031 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1032 a->setStatusTip ( tr( "Show Note Editor" ));
1033 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1034 a->setToggleAction(true);
1036 viewMenu->addAction (a);
1037 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1038 actionViewToggleNoteEditor=a;
1040 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1041 a->setStatusTip ( tr( "Show History Window" ));
1042 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1043 a->setToggleAction(true);
1045 viewMenu->addAction (a);
1046 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1047 actionViewToggleHistoryWindow=a;
1049 viewMenu->addAction (actionViewTogglePropertyWindow);
1051 viewMenu->addSeparator();
1053 a = new QAction(tr( "Antialiasing","View action" ),this );
1054 a->setStatusTip ( tr( "Antialiasing" ));
1055 a->setToggleAction(true);
1056 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1057 viewMenu->addAction (a);
1058 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1059 actionViewToggleAntiAlias=a;
1061 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1062 a->setStatusTip (a->text());
1063 a->setToggleAction(true);
1064 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1065 viewMenu->addAction (a);
1066 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1067 actionViewToggleSmoothPixmapTransform=a;
1069 a = new QAction(tr( "Next Map","View action" ), this);
1070 a->setStatusTip (a->text());
1071 a->setShortcut (Qt::ALT + Qt::Key_N );
1072 viewMenu->addAction (a);
1073 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1075 a = new QAction (tr( "Previous Map","View action" ), this );
1076 a->setStatusTip (a->text());
1077 a->setShortcut (Qt::ALT + Qt::Key_P );
1078 viewMenu->addAction (a);
1079 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1083 void Main::setupModeActions()
1085 //QPopupMenu *menu = new QPopupMenu( this );
1086 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1088 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1089 tb->setObjectName ("modesTB");
1091 actionGroupModModes=new QActionGroup ( this);
1092 actionGroupModModes->setExclusive (true);
1093 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1094 a->setShortcut (Qt::Key_J);
1095 a->setStatusTip ( tr( "Use modifier to color branches" ));
1096 a->setToggleAction(true);
1099 actionModModeColor=a;
1101 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1102 a->setShortcut( Qt::Key_K);
1103 a->setStatusTip( tr( "Use modifier to copy" ));
1104 a->setToggleAction(true);
1106 actionModModeCopy=a;
1108 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1109 a->setShortcut (Qt::Key_L);
1110 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1111 a->setToggleAction(true);
1113 actionModModeXLink=a;
1117 void Main::setupFlagActions()
1119 // Create System Flags
1123 systemFlagsDefault = new FlagRowObj ();
1124 systemFlagsDefault->setVisibility (false);
1125 systemFlagsDefault->setName ("systemFlagsDef");
1127 FlagObj *fo = new FlagObj ();
1128 fo->load(QPixmap(flagsPath+"flag-note.png"));
1129 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1131 fo->load(QPixmap(flagsPath+"flag-url.png"));
1132 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1134 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1135 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1137 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1138 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1140 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1141 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1143 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1144 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1146 // Create Standard Flags
1147 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1148 tb->setObjectName ("standardFlagTB");
1150 standardFlagsDefault = new FlagRowObj ();
1151 standardFlagsDefault->setVisibility (false);
1152 standardFlagsDefault->setName ("standardFlagsDef");
1153 standardFlagsDefault->setToolBar (tb);
1155 fo->load(flagsPath+"flag-exclamationmark.png");
1156 fo->setGroup("standard-mark");
1157 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1159 fo->load(flagsPath+"flag-questionmark.png");
1160 fo->setGroup("standard-mark");
1161 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1163 fo->load(flagsPath+"flag-hook-green.png");
1164 fo->setGroup("standard-hook");
1165 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1167 fo->load(flagsPath+"flag-cross-red.png");
1168 fo->setGroup("standard-hook");
1169 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1172 fo->load(flagsPath+"flag-stopsign.png");
1173 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1175 fo->load(flagsPath+"flag-smiley-good.png");
1176 fo->setGroup("standard-smiley");
1177 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1179 fo->load(flagsPath+"flag-smiley-sad.png");
1180 fo->setGroup("standard-smiley");
1181 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1183 fo->load(flagsPath+"flag-smiley-omg.png");
1184 fo->setGroup("standard-smiley");
1185 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1186 // Original omg.png (in KDE emoticons)
1189 fo->load(flagsPath+"flag-kalarm.png");
1190 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1192 fo->load(flagsPath+"flag-phone.png");
1193 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1195 fo->load(flagsPath+"flag-lamp.png");
1196 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1198 fo->load(flagsPath+"flag-arrow-up.png");
1199 fo->setGroup("standard-arrow");
1200 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1202 fo->load(flagsPath+"flag-arrow-down.png");
1203 fo->setGroup("standard-arrow");
1204 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1206 fo->load(flagsPath+"flag-arrow-2up.png");
1207 fo->setGroup("standard-arrow");
1208 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1210 fo->load(flagsPath+"flag-arrow-2down.png");
1211 fo->setGroup("standard-arrow");
1212 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1215 fo->load(flagsPath+"flag-thumb-up.png");
1216 fo->setGroup("standard-thumb");
1217 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1219 fo->load(flagsPath+"flag-thumb-down.png");
1220 fo->setGroup("standard-thumb");
1221 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1224 fo->load(flagsPath+"flag-rose.png");
1225 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1227 fo->load(flagsPath+"flag-heart.png");
1228 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1230 fo->load(flagsPath+"flag-present.png");
1231 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1233 fo->load(flagsPath+"flag-flash.png");
1234 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1236 // Original: xsldbg_output.png
1237 fo->load(flagsPath+"flag-info.png");
1238 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1240 // Original khelpcenter.png
1241 fo->load(flagsPath+"flag-lifebelt.png");
1242 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1248 fo->load(flagsPath+"freemind/warning.png");
1249 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1251 for (int i=1; i<8; i++)
1253 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1254 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1257 fo->load(flagsPath+"freemind/back.png");
1258 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1260 fo->load(flagsPath+"freemind/forward.png");
1261 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1263 fo->load(flagsPath+"freemind/attach.png");
1264 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1266 fo->load(flagsPath+"freemind/clanbomber.png");
1267 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1269 fo->load(flagsPath+"freemind/desktopnew.png");
1270 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1272 fo->load(flagsPath+"freemind/flag.png");
1273 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1276 fo->load(flagsPath+"freemind/gohome.png");
1277 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1280 fo->load(flagsPath+"freemind/kaddressbook.png");
1281 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1283 fo->load(flagsPath+"freemind/knotify.png");
1284 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1286 fo->load(flagsPath+"freemind/korn.png");
1287 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1289 fo->load(flagsPath+"freemind/mail.png");
1290 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1292 fo->load(flagsPath+"freemind/password.png");
1293 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1295 fo->load(flagsPath+"freemind/pencil.png");
1296 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1298 fo->load(flagsPath+"freemind/stop.png");
1299 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1301 fo->load(flagsPath+"freemind/wizard.png");
1302 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1304 fo->load(flagsPath+"freemind/xmag.png");
1305 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1307 fo->load(flagsPath+"freemind/bell.png");
1308 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1310 fo->load(flagsPath+"freemind/bookmark.png");
1311 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1313 fo->load(flagsPath+"freemind/penguin.png");
1314 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1316 fo->load(flagsPath+"freemind/licq.png");
1317 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1322 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1325 fo->setToolTip (tooltip);
1326 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1332 fo->setAlwaysVisible(aw);
1333 a->setCheckable(true);
1334 a->setObjectName(fo->getName());
1335 a->setToolTip(tooltip);
1336 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1337 standardFlagsDefault->addFlag (fo);
1341 systemFlagsDefault->addFlag (fo);
1345 void Main::setupNetworkActions()
1347 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1349 QMenu *netMenu = menuBar()->addMenu( "Network" );
1353 a = new QAction( "Start TCPserver for MapEditor",this);
1354 //a->setStatusTip ( "Set application to open pdf files"));
1355 a->setShortcut ( Qt::Key_T ); //New TCP server
1356 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1357 netMenu->addAction (a);
1359 a = new QAction( "Connect MapEditor to server",this);
1360 //a->setStatusTip ( "Set application to open pdf files"));
1361 a->setShortcut ( Qt::Key_C ); // Connect to server
1362 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1363 netMenu->addAction (a);
1367 void Main::setupSettingsActions()
1369 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1373 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1374 a->setStatusTip ( tr( "Set application to open pdf files"));
1375 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1376 settingsMenu->addAction (a);
1378 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1379 a->setStatusTip( tr( "Set application to open external links"));
1380 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1381 settingsMenu->addAction (a);
1383 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1384 a->setStatusTip( tr( "Set path for macros"));
1385 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1386 settingsMenu->addAction (a);
1388 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1389 a->setStatusTip( tr( "Set number of undo levels"));
1390 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1391 settingsMenu->addAction (a);
1393 settingsMenu->addSeparator();
1395 a = new QAction( tr( "Autosave","Settings action"), this);
1396 a->setStatusTip( tr( "Autosave"));
1397 a->setToggleAction(true);
1398 a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool());
1399 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1400 settingsMenu->addAction (a);
1401 actionSettingsAutosaveToggle=a;
1403 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1404 a->setStatusTip( tr( "Autosave time"));
1405 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1406 settingsMenu->addAction (a);
1407 actionSettingsAutosaveTime=a;
1409 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1410 a->setStatusTip( tr( "Write backup file on save"));
1411 a->setToggleAction(true);
1412 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1413 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1414 settingsMenu->addAction (a);
1415 actionSettingsWriteBackupFile=a;
1417 settingsMenu->addSeparator();
1419 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1420 a->setStatusTip( tr( "Edit branch after adding it" ));
1421 a->setToggleAction(true);
1422 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1423 settingsMenu->addAction (a);
1424 actionSettingsAutoEditNewBranch=a;
1426 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1427 a->setStatusTip( tr( "Select branch after adding it" ));
1428 a->setToggleAction(true);
1429 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1430 settingsMenu->addAction (a);
1431 actionSettingsAutoSelectNewBranch=a;
1433 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1434 a->setStatusTip( tr( "Select heading before editing" ));
1435 a->setToggleAction(true);
1436 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1437 settingsMenu->addAction (a);
1438 actionSettingsAutoSelectText=a;
1440 a= new QAction( tr( "Delete key","Settings action" ), this);
1441 a->setStatusTip( tr( "Delete key for deleting branches" ));
1442 a->setToggleAction(true);
1443 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1444 settingsMenu->addAction (a);
1445 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1446 actionSettingsUseDelKey=a;
1448 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1449 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1450 a->setToggleAction(true);
1451 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1452 settingsMenu->addAction (a);
1453 actionSettingsUseFlagGroups=a;
1455 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1456 a->setStatusTip( tr( "Use hide flag during exports " ));
1457 a->setToggleAction(true);
1458 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1459 settingsMenu->addAction (a);
1460 actionSettingsUseHideExport=a;
1464 void Main::setupTestActions()
1466 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1469 a = new QAction( "Test function 1" , this);
1470 a->setStatusTip( "Call test function 1" );
1471 testMenu->addAction (a);
1472 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1474 a = new QAction( "Test function 2" , this);
1475 a->setStatusTip( "Call test function 2" );
1476 testMenu->addAction (a);
1477 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1479 a = new QAction( "Command" , this);
1480 a->setStatusTip( "Enter command to call in editor" );
1481 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1482 testMenu->addAction (a);
1486 void Main::setupHelpActions()
1488 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1491 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1492 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1493 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1494 helpMenu->addAction (a);
1496 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1497 a->setStatusTip( tr( "Open VYM example maps " ));
1498 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1499 helpMenu->addAction (a);
1501 a = new QAction( tr( "About VYM","Help action" ), this);
1502 a->setStatusTip( tr( "About VYM")+vymName);
1503 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1504 helpMenu->addAction (a);
1506 a = new QAction( tr( "About QT","Help action" ), this);
1507 a->setStatusTip( tr( "Information about QT toolkit" ));
1508 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1509 helpMenu->addAction (a);
1513 void Main::setupContextMenus()
1517 // Context Menu for branch or mapcenter
1518 branchContextMenu =new QMenu (this);
1519 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1520 branchContextMenu->addSeparator();
1523 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1524 branchAddContextMenu->addAction (actionEditPaste );
1525 branchAddContextMenu->addAction ( actionEditAddBranch );
1526 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1527 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1528 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1529 branchAddContextMenu->addSeparator();
1530 branchAddContextMenu->addAction ( actionEditImportAdd );
1531 branchAddContextMenu->addAction ( actionEditImportReplace );
1534 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1535 branchRemoveContextMenu->addAction (actionEditCut);
1536 branchRemoveContextMenu->addAction ( actionEditDelete );
1537 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1538 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1541 actionEditSaveBranch->addTo( branchContextMenu );
1543 branchContextMenu->addSeparator();
1544 branchContextMenu->addAction ( actionEditLoadImage);
1546 // Submenu for Links (URLs, vymLinks)
1547 branchLinksContextMenu =new QMenu (this);
1549 branchContextMenu->addSeparator();
1550 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1551 branchLinksContextMenu->addAction ( actionEditOpenURL );
1552 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1553 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1554 branchLinksContextMenu->addAction ( actionEditURL );
1555 branchLinksContextMenu->addAction ( actionEditLocalURL );
1556 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1557 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1558 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1560 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1562 branchLinksContextMenu->addSeparator();
1563 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1564 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1565 branchLinksContextMenu->addAction ( actionEditVymLink );
1566 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1569 // Context Menu for XLinks in a branch menu
1570 // This will be populated "on demand" in MapEditor::updateActions
1571 branchContextMenu->addSeparator();
1572 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1573 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1574 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1575 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1578 // Context menu for floatimage
1579 floatimageContextMenu =new QMenu (this);
1580 a= new QAction (tr ("Save image","Context action"),this);
1581 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1582 floatimageContextMenu->addAction (a);
1584 floatimageContextMenu->addSeparator();
1585 actionEditCopy->addTo( floatimageContextMenu );
1586 actionEditCut->addTo( floatimageContextMenu );
1588 floatimageContextMenu->addSeparator();
1589 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1592 // Context menu for canvas
1593 canvasContextMenu =new QMenu (this);
1594 actionEditMapInfo->addTo( canvasContextMenu );
1595 canvasContextMenu->insertSeparator();
1596 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1597 canvasContextMenu->insertSeparator();
1598 actionFormatLinkColorHint->addTo( canvasContextMenu );
1599 actionFormatLinkColor->addTo( canvasContextMenu );
1600 actionFormatSelectionColor->addTo( canvasContextMenu );
1601 actionFormatBackColor->addTo( canvasContextMenu );
1602 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1604 // Menu for last opened files
1606 for (int i = 0; i < MaxRecentFiles; ++i)
1608 recentFileActions[i] = new QAction(this);
1609 recentFileActions[i]->setVisible(false);
1610 fileLastMapsMenu->addAction(recentFileActions[i]);
1611 connect(recentFileActions[i], SIGNAL(triggered()),
1612 this, SLOT(fileLoadRecent()));
1614 setupRecentMapsMenu();
1617 void Main::setupRecentMapsMenu()
1619 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1621 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1623 for (int i = 0; i < numRecentFiles; ++i) {
1624 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1625 recentFileActions[i]->setText(text);
1626 recentFileActions[i]->setData(files[i]);
1627 recentFileActions[i]->setVisible(true);
1629 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1630 recentFileActions[j]->setVisible(false);
1633 void Main::setupMacros()
1635 for (int i = 0; i <= 11; i++)
1637 macroActions[i] = new QAction(this);
1638 macroActions[i]->setData(i);
1639 addAction (macroActions[i]);
1640 connect(macroActions[i], SIGNAL(triggered()),
1641 this, SLOT(callMacro()));
1643 macroActions[0]->setShortcut ( Qt::Key_F1 );
1644 macroActions[1]->setShortcut ( Qt::Key_F2 );
1645 macroActions[2]->setShortcut ( Qt::Key_F3 );
1646 macroActions[3]->setShortcut ( Qt::Key_F4 );
1647 macroActions[4]->setShortcut ( Qt::Key_F5 );
1648 macroActions[5]->setShortcut ( Qt::Key_F6 );
1649 macroActions[6]->setShortcut ( Qt::Key_F7 );
1650 macroActions[7]->setShortcut ( Qt::Key_F8 );
1651 macroActions[8]->setShortcut ( Qt::Key_F9 );
1652 macroActions[9]->setShortcut ( Qt::Key_F10 );
1653 macroActions[10]->setShortcut ( Qt::Key_F11 );
1654 macroActions[11]->setShortcut ( Qt::Key_F12 );
1657 void Main::hideEvent (QHideEvent * )
1659 if (!textEditor->isMinimized() ) textEditor->hide();
1662 void Main::showEvent (QShowEvent * )
1664 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1668 MapEditor* Main::currentMapEditor() const
1670 if ( tabWidget->currentPage() &&
1671 tabWidget->currentPage()->inherits( "MapEditor" ) )
1672 return (MapEditor*)tabWidget->currentPage();
1677 void Main::editorChanged(QWidget *)
1679 // Unselect all possibly selected objects
1680 // (Important to update note editor)
1682 for (int i=0;i<=tabWidget->count() -1;i++)
1685 me=(MapEditor*)tabWidget->page(i);
1688 currentMapEditor()->reselect();
1690 // Update actions to in menus and toolbars according to editor
1694 void Main::fileNew()
1696 QString fn="unnamed";
1697 MapEditor* me = new MapEditor ( NULL);
1698 tabWidget->addTab (me,fn);
1699 tabWidget->showPage(me);
1700 me->viewport()->setFocus();
1701 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1702 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1704 // For the very first map we do not have flagrows yet...
1708 void Main::fileNewCopy()
1710 QString fn="unnamed";
1711 MapEditor* oldME =currentMapEditor();
1715 MapEditor* newME = new MapEditor ( NULL);
1718 tabWidget->addTab (newME,fn);
1719 tabWidget->showPage(newME);
1720 newME->viewport()->setFocus();
1721 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1722 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1723 // For the very first map we do not have flagrows yet...
1724 newME->select("mc:");
1725 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1731 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1733 ErrorCode err=success;
1735 // fn is usually the archive, mapfile the file after uncompressing
1738 // Make fn absolute (needed for unzip)
1739 fn=QDir (fn).absPath();
1745 // Check, if map is already loaded
1747 while (i<=tabWidget->count() -1)
1749 me=(MapEditor*)tabWidget->page(i);
1750 if (me->getFilePath() == fn)
1752 // Already there, ask for confirmation
1753 QMessageBox mb( vymName,
1754 tr("The map %1\nis already opened."
1755 "Opening the same map in multiple editors may lead \n"
1756 "to confusion when finishing working with vym."
1757 "Do you want to").arg(fn),
1758 QMessageBox::Warning,
1759 QMessageBox::Yes | QMessageBox::Default,
1760 QMessageBox::Cancel | QMessageBox::Escape,
1761 QMessageBox::NoButton);
1762 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1763 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1766 case QMessageBox::Yes:
1768 i=tabWidget->count();
1770 case QMessageBox::Cancel:
1782 if ( !fn.isEmpty() )
1784 me = currentMapEditor();
1785 int tabIndex=tabWidget->currentPageIndex();
1786 // Check first, if mapeditor exists
1787 // If it is not default AND we want a new map,
1788 // create a new mapeditor in a new tab
1789 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1791 me= new MapEditor ( NULL);
1792 tabWidget->addTab (me,fn);
1793 tabIndex=tabWidget->indexOf (me);
1794 tabWidget->setCurrentPage (tabIndex);
1795 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1796 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1799 // Check, if file exists (important for creating new files
1800 // from command line
1801 if (!QFile(fn).exists() )
1803 QMessageBox mb( vymName,
1804 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1805 QMessageBox::Question,
1807 QMessageBox::Cancel | QMessageBox::Default,
1808 QMessageBox::NoButton );
1810 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1811 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1814 case QMessageBox::Yes:
1816 currentMapEditor()->setFilePath(fn);
1817 tabWidget->setTabLabel (currentMapEditor(),
1818 currentMapEditor()->getFileName() );
1819 statusBar()->message( "Created " + fn , statusbarTime );
1822 case QMessageBox::Cancel:
1823 // don't create new map
1824 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1831 //tabWidget->currentPage() won't be NULL here, because of above...
1832 tabWidget->showPage(me);
1833 me->viewport()->setFocus();
1837 // Save existing filename in case we import
1838 QString fn_org=me->getFilePath();
1840 // Finally load map into mapEditor
1841 me->setFilePath (fn);
1842 err=me->load(fn,lmode,ftype);
1844 // Restore old (maybe empty) filepath, if this is an import
1846 me->setFilePath (fn_org);
1849 // Finally check for errors and go home
1852 if (lmode==NewMap) fileCloseMap();
1853 statusBar()->message( "Could not load " + fn, statusbarTime );
1858 me->setFilePath (fn);
1859 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1860 if (!isInTmpDir (fn))
1862 // Only append to lastMaps if not loaded from a tmpDir
1863 // e.g. imported bookmarks are in a tmpDir
1864 addRecentMap(me->getFilePath() );
1866 actionFilePrint->setEnabled (true);
1868 statusBar()->message( "Loaded " + fn, statusbarTime );
1875 void Main::fileLoad(const LoadMode &lmode)
1877 QStringList filters;
1878 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1879 QFileDialog *fd=new QFileDialog( this);
1880 fd->setDir (lastFileDir);
1881 fd->setFileMode (QFileDialog::ExistingFiles);
1882 fd->setFilters (filters);
1886 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1889 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1892 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1898 if ( fd->exec() == QDialog::Accepted )
1900 lastFileDir=fd->directory().path();
1901 QStringList flist = fd->selectedFiles();
1902 QStringList::Iterator it = flist.begin();
1903 while( it != flist.end() )
1906 fileLoad(*it, lmode);
1913 void Main::fileLoad()
1918 void Main::fileLoadRecent()
1920 QAction *action = qobject_cast<QAction *>(sender());
1922 fileLoad (action->data().toString(), NewMap);
1925 void Main::addRecentMap (const QString &fileName)
1928 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1929 files.removeAll(fileName);
1930 files.prepend(fileName);
1931 while (files.size() > MaxRecentFiles)
1934 settings.setValue("/mainwindow/recentFileList", files);
1936 setupRecentMapsMenu();
1939 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1943 if ( me->getFilePath().isEmpty() )
1945 // We have no filepath yet,
1946 // call fileSaveAs() now, this will call fileSave()
1948 // First switch to editor
1949 tabWidget->setCurrentWidget (me);
1950 fileSaveAs(savemode);
1953 if (me->save (savemode)==success)
1955 statusBar()->message(
1956 tr("Saved %1").arg(me->getFilePath()),
1958 addRecentMap (me->getFilePath() );
1960 statusBar()->message(
1961 tr("Couldn't save ").arg(me->getFilePath()),
1965 void Main::fileSave()
1967 fileSave (currentMapEditor(), CompleteMap);
1970 void Main::fileSave(MapEditor *me)
1972 fileSave (me,CompleteMap);
1975 void Main::fileSaveAs(const SaveMode& savemode)
1979 if (currentMapEditor())
1981 if (savemode==CompleteMap)
1982 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
1984 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
1985 if ( !fn.isEmpty() )
1987 // Check for existing file
1988 if (QFile (fn).exists())
1990 QMessageBox mb( vymName,
1991 tr("The file %1\nexists already. Do you want to").arg(fn),
1992 QMessageBox::Warning,
1993 QMessageBox::Yes | QMessageBox::Default,
1994 QMessageBox::Cancel | QMessageBox::Escape,
1995 QMessageBox::NoButton);
1996 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1997 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2000 case QMessageBox::Yes:
2003 case QMessageBox::Cancel:
2010 // New file, add extension to filename, if missing
2011 // This is always .vym or .vyp, depending on savemode
2012 if (savemode==CompleteMap)
2014 if (!fn.contains (".vym") && !fn.contains (".xml"))
2018 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2027 currentMapEditor()->setFilePath(fn);
2028 fileSave(currentMapEditor(), savemode);
2031 if (savemode==CompleteMap)
2032 tabWidget->setTabLabel (currentMapEditor(),
2033 currentMapEditor()->getFileName() );
2039 void Main::fileSaveAs()
2041 fileSaveAs (CompleteMap);
2044 void Main::fileImportKDEBookmarks()
2046 ImportKDEBookmarks im;
2048 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2049 currentMapEditor()->setFilePath ("");
2052 void Main::fileImportFirefoxBookmarks()
2054 Q3FileDialog *fd=new Q3FileDialog( this);
2055 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2056 fd->setMode (Q3FileDialog::ExistingFiles);
2057 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2058 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2061 if ( fd->exec() == QDialog::Accepted )
2063 ImportFirefoxBookmarks im;
2064 QStringList flist = fd->selectedFiles();
2065 QStringList::Iterator it = flist.begin();
2066 while( it != flist.end() )
2069 if (im.transform() &&
2070 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2071 currentMapEditor() )
2072 currentMapEditor()->setFilePath ("");
2079 void Main::fileImportFreemind()
2081 QStringList filters;
2082 filters <<"Freemind map (*.mm)"<<"All files (*)";
2083 QFileDialog *fd=new QFileDialog( this);
2084 fd->setDir (lastFileDir);
2085 fd->setFileMode (QFileDialog::ExistingFiles);
2086 fd->setFilters (filters);
2087 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2091 if ( fd->exec() == QDialog::Accepted )
2093 lastFileDir=fd->directory().path();
2094 QStringList flist = fd->selectedFiles();
2095 QStringList::Iterator it = flist.begin();
2096 while( it != flist.end() )
2099 if ( fileLoad (fn,NewMap, FreemindMap) )
2101 currentMapEditor()->setFilePath ("");
2110 void Main::fileImportMM()
2114 Q3FileDialog *fd=new Q3FileDialog( this);
2115 fd->setDir (lastFileDir);
2116 fd->setMode (Q3FileDialog::ExistingFiles);
2117 fd->addFilter ("Mind Manager (*.mmap)");
2118 fd->setCaption(tr("Import")+" "+"Mind Manager");
2121 if ( fd->exec() == QDialog::Accepted )
2123 lastFileDir=fd->dirPath();
2124 QStringList flist = fd->selectedFiles();
2125 QStringList::Iterator it = flist.begin();
2126 while( it != flist.end() )
2129 if (im.transform() &&
2130 success==fileLoad (im.getTransformedFile(),NewMap) &&
2131 currentMapEditor() )
2132 currentMapEditor()->setFilePath ("");
2141 void Main::fileImportDir()
2143 if (currentMapEditor())
2144 currentMapEditor()->importDir();
2147 void Main::fileExportXML()
2149 MapEditor *me=currentMapEditor();
2150 if (me) me->exportXML();
2154 void Main::fileExportXHTML()
2156 MapEditor *me=currentMapEditor();
2157 if (me) me->exportXHTML();
2160 void Main::fileExportImage()
2162 MapEditor *me=currentMapEditor();
2163 if (me) me->exportImage();
2166 void Main::fileExportASCII()
2168 MapEditor *me=currentMapEditor();
2169 if (me) me->exportASCII();
2172 void Main::fileExportCSV() //FIXME not scriptable yet
2174 MapEditor *me=currentMapEditor();
2178 ex.setModel (me->getModel());
2179 ex.addFilter ("CSV (*.csv)");
2180 ex.setDir(lastImageDir);
2181 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2182 if (ex.execDialog() )
2184 me->setExportMode(true);
2186 me->setExportMode(false);
2191 void Main::fileExportLaTeX() //FIXME not scriptable yet
2193 MapEditor *me=currentMapEditor();
2197 ex.setModel (me->getModel());
2198 ex.addFilter ("Tex (*.tex)");
2199 ex.setDir(lastImageDir);
2200 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2201 if (ex.execDialog() )
2203 me->setExportMode(true);
2205 me->setExportMode(false);
2210 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2212 ExportKDEBookmarks ex;
2213 MapEditor *me=currentMapEditor();
2216 ex.setModel (me->getModel());
2221 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2223 ExportTaskjuggler ex;
2224 MapEditor *me=currentMapEditor();
2227 ex.setModel (me->getModel());
2228 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2229 ex.setDir(lastImageDir);
2230 ex.addFilter ("Taskjuggler (*.tjp)");
2231 if (ex.execDialog() )
2233 me->setExportMode(true);
2235 me->setExportMode(false);
2240 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2242 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2243 // TODO add preview in dialog
2244 //ImagePreview *p =new ImagePreview (fd);
2245 //fd->setContentsPreviewEnabled( TRUE );
2246 //fd->setContentsPreview( p, p );
2247 //fd->setPreviewMode( QFileDialog::Contents );
2248 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2249 fd->setDir (QDir().current());
2250 if (fd->foundConfig())
2254 if ( fd->exec() == QDialog::Accepted )
2256 QString fn=fd->selectedFile();
2257 if (!fn.contains (".odp"))
2260 //lastImageDir=fn.left(fn.findRev ("/"));
2261 if (currentMapEditor())
2262 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2266 QMessageBox::warning(0,
2268 tr("Couldn't find configuration for export to Open Office\n"));
2272 void Main::fileCloseMap()
2274 MapEditor *me = currentMapEditor();
2277 if (me->hasChanged())
2279 QMessageBox mb( vymName,
2280 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getFileName()),
2281 QMessageBox::Warning,
2282 QMessageBox::Yes | QMessageBox::Default,
2284 QMessageBox::Cancel | QMessageBox::Escape );
2285 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2286 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2289 case QMessageBox::Yes:
2291 fileSave(me, CompleteMap);
2293 case QMessageBox::No:
2294 // close without saving
2296 case QMessageBox::Cancel:
2302 tabWidget->removePage(me);
2303 if (tabWidget->count()==0)
2304 actionFilePrint->setEnabled (false);
2309 void Main::filePrint()
2311 if (currentMapEditor())
2312 currentMapEditor()->print();
2315 void Main::fileExitVYM()
2317 // Check if one or more editors have changed
2320 for (i=0;i<=tabWidget->count() -1;i++)
2323 me=(MapEditor*)tabWidget->page(i);
2325 // If something changed, ask what to do
2326 if (me->hasChanged())
2328 tabWidget->setCurrentPage(i);
2329 QMessageBox mb( vymName,
2330 tr("This map is not saved yet. Do you want to"),
2331 QMessageBox::Warning,
2332 QMessageBox::Yes | QMessageBox::Default,
2334 QMessageBox::Cancel | QMessageBox::Escape );
2335 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2336 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2339 mb.setActiveWindow();
2340 switch( mb.exec() ) {
2341 case QMessageBox::Yes:
2342 // save (the changed editors) and exit
2343 fileSave(currentMapEditor(), CompleteMap);
2345 case QMessageBox::No:
2346 // exit without saving
2348 case QMessageBox::Cancel:
2349 // don't save and don't exit
2353 } // loop over all MEs
2357 void Main::editUndo()
2359 if (currentMapEditor())
2360 currentMapEditor()->undo();
2363 void Main::editRedo()
2365 if (currentMapEditor())
2366 currentMapEditor()->redo();
2369 void Main::gotoHistoryStep (int i)
2371 if (currentMapEditor())
2372 currentMapEditor()->gotoHistoryStep (i);
2375 void Main::editCopy()
2377 if (currentMapEditor())
2378 currentMapEditor()->copy();
2381 void Main::editPaste()
2383 if (currentMapEditor())
2384 currentMapEditor()->paste();
2387 void Main::editCut()
2389 if (currentMapEditor())
2390 currentMapEditor()->cut();
2393 void Main::editOpenFindWindow()
2395 findWindow->popup();
2396 findWindow->raise();
2397 findWindow->setActiveWindow();
2400 void Main::editFind(QString s)
2403 BranchObj *bo=currentMapEditor()->findText(s, cs);
2406 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2409 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2410 tr("No matches found for \"%1\"").arg(s));
2414 void Main::editFindChanged()
2415 { // Notify editor, to abort the current find process
2416 currentMapEditor()->findReset();
2419 void Main::openTabs(QStringList urls)
2421 if (!urls.isEmpty())
2425 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2427 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2429 QString u=urls.takeFirst();
2430 procBrowser = new QProcess( this );
2432 procBrowser->start(browser,args);
2433 if ( !procBrowser->waitForStarted())
2435 // try to set path to browser
2436 QMessageBox::warning(0,
2438 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2439 tr("Please use Settings->")+tr("Set application to open an URL"));
2442 #if defined(Q_OS_WIN32)
2443 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2444 this->thread()->wait(3000);
2449 if (browser.contains("konqueror"))
2451 for (int i=0; i<urls.size(); i++)
2454 // Try to open new tab in existing konqueror started previously by vym
2455 p=new QProcess (this);
2457 #if defined(Q_OS_WIN32)
2458 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2459 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2460 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2461 "konqueror-mainwindow#1"<<
2465 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2466 "konqueror-mainwindow#1"<<
2470 p->start ("dcop",args);
2471 //cout << qPrintable (args.join(" "))<<endl;
2472 if ( !p->waitForStarted() ) success=false;
2475 QMessageBox::warning(0,
2477 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2479 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2481 for (int i=0; i<urls.size(); i++)
2483 // Try to open new tab in firefox
2484 p=new QProcess (this);
2485 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2486 p->start (browser,args);
2487 if ( !p->waitForStarted() ) success=false;
2490 QMessageBox::warning(0,
2492 tr("Couldn't start %1 to open a new tab").arg(browser));
2495 QMessageBox::warning(0,
2497 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2501 void Main::editOpenURL()
2504 if (currentMapEditor())
2506 QString url=currentMapEditor()->getURL();
2508 if (url=="") return;
2509 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2510 procBrowser = new QProcess( this );
2512 procBrowser->start(browser,args);
2513 if ( !procBrowser->waitForStarted())
2515 // try to set path to browser
2516 QMessageBox::warning(0,
2518 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2519 tr("Please use Settings->")+tr("Set application to open an URL"));
2524 void Main::editOpenURLTab()
2526 if (currentMapEditor())
2529 urls.append(currentMapEditor()->getURL());
2533 void Main::editOpenMultipleURLTabs()
2535 if (currentMapEditor())
2538 urls=currentMapEditor()->getURLs();
2544 void Main::editURL()
2546 if (currentMapEditor())
2547 currentMapEditor()->editURL();
2550 void Main::editLocalURL()
2552 if (currentMapEditor())
2553 currentMapEditor()->editLocalURL();
2556 void Main::editHeading2URL()
2558 if (currentMapEditor())
2559 currentMapEditor()->editHeading2URL();
2562 void Main::editBugzilla2URL()
2564 if (currentMapEditor())
2565 currentMapEditor()->editBugzilla2URL();
2568 void Main::editFATE2URL()
2570 if (currentMapEditor())
2571 currentMapEditor()->editFATE2URL();
2574 void Main::editHeadingFinished()
2576 // only called from editHeading(), so there is a currentME
2577 MapEditor *me=currentMapEditor();
2580 me->setStateEditHeading (false);
2581 QPoint p; //Not used here, only to find out pos of branch
2583 QString s=me->getHeading(ok,p);
2585 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2587 if (ok && s!=lineedit->text())
2588 me->setHeading(lineedit->text());
2590 lineedit->releaseKeyboard();
2594 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2595 !prevSelection.isEmpty())
2596 me->select(prevSelection);
2601 void Main::editHeading()
2603 if (currentMapEditor())
2605 MapEditor *me=currentMapEditor();
2606 QString oldSel=me->getSelectString();
2608 if (lineedit->isVisible())
2609 editHeadingFinished();
2614 QString s=me->getHeading(ok,p);
2618 me->setStateEditHeading (true);
2619 #if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
2620 p=me->mapToGlobal (p);
2621 QDialog *d =new QDialog(NULL);
2622 QLineEdit *le=new QLineEdit (d);
2623 d->setWindowFlags (Qt::FramelessWindowHint);
2624 d->setGeometry(p.x(),p.y(),230,25);
2625 le->resize (d->width()-10,d->height());
2628 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2629 d->activateWindow();
2631 me->setHeading (le->text());
2634 editHeadingFinished();
2636 p=me->mapTo (this,p);
2637 lineedit->setGeometry(p.x(),p.y(),230,25);
2638 lineedit->setText(s);
2639 lineedit->setCursorPosition(1);
2640 lineedit->selectAll();
2642 lineedit->grabKeyboard();
2643 lineedit->setFocus();
2647 } // currentMapEditor()
2650 void Main::editAttributeFinished()
2652 // only called from editHeading(), so there is a currentME
2655 MapEditor *me=currentMapEditor();
2658 me->setStateEditHeading (false);
2659 QPoint p; //Not used here, only to find out pos of branch
2661 QString s=me->getHeading(ok,p);
2663 #if defined(Q_OS_MACX)
2665 if (ok && s!=lineedit->text())
2666 me->setHeading(lineedit->text());
2668 lineedit->releaseKeyboard();
2672 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2673 !prevSelection.isEmpty())
2674 me->select(prevSelection);
2680 #include "attribute.h"
2681 #include "attributedialog.h"
2682 void Main::editAttribute()
2684 MapEditor *me=currentMapEditor();
2687 BranchObj *bo=me->getSelectedBranch();
2690 AttributeDialog dia(this);
2691 dia.setTable (me->attributeTable() );
2693 dia.setMode (Definition);
2699 if (currentMapEditor())
2701 MapEditor *me=currentMapEditor();
2702 QString oldSel=me->getSelectString();
2704 if (lineedit->isVisible())
2705 editAttributeFinished();
2710 QString s=me->getHeading(ok,p);
2714 me->setStateEditHeading (true);
2715 #if defined(Q_OS_MACX)
2716 p=me->mapToGlobal (p);
2717 QDialog *d =new QDialog(NULL);
2718 QLineEdit *le=new QLineEdit (d);
2719 d->setWindowFlags (Qt::FramelessWindowHint);
2720 d->setGeometry(p.x(),p.y(),230,25);
2721 le->resize (d->width()-10,d->height());
2724 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2725 d->activateWindow();
2727 me->setHeading (le->text());
2730 editHeadingFinished();
2732 p=me->mapTo (this,p);
2733 lineedit->setGeometry(p.x(),p.y(),230,25);
2734 lineedit->setText(s);
2735 lineedit->setCursorPosition(1);
2736 lineedit->selectAll();
2738 lineedit->grabKeyboard();
2739 lineedit->setFocus();
2743 } // currentMapEditor()
2748 void Main::openVymLinks(const QStringList &vl)
2750 for (int j=0; j<vl.size(); j++)
2752 // compare path with already loaded maps
2756 for (i=0;i<=tabWidget->count() -1;i++)
2758 me=(MapEditor*)tabWidget->page(i);
2759 if (vl.at(j)==me->getFilePath() )
2768 if (!QFile(vl.at(j)).exists() )
2769 QMessageBox::critical( 0, tr( "Critical Error" ),
2770 tr("Couldn't open map %1").arg(vl.at(j)));
2773 fileLoad (vl.at(j), NewMap);
2774 tabWidget->setCurrentPage (tabWidget->count()-1);
2777 // Go to tab containing the map
2778 tabWidget->setCurrentPage (index);
2782 void Main::editOpenVymLink()
2784 if (currentMapEditor())
2787 vl.append(currentMapEditor()->getVymLink());
2792 void Main::editOpenMultipleVymLinks()
2794 QString currentVymLink;
2795 if (currentMapEditor())
2797 QStringList vl=currentMapEditor()->getVymLinks();
2802 void Main::editVymLink()
2804 if (currentMapEditor())
2805 currentMapEditor()->editVymLink();
2808 void Main::editDeleteVymLink()
2810 if (currentMapEditor())
2811 currentMapEditor()->deleteVymLink();
2814 void Main::editToggleHideExport()
2816 if (currentMapEditor())
2817 currentMapEditor()->toggleHideExport();
2820 void Main::editMapInfo()
2822 if (currentMapEditor())
2823 currentMapEditor()->editMapInfo();
2826 void Main::editMoveUp()
2828 if (currentMapEditor())
2829 currentMapEditor()->moveBranchUp();
2832 void Main::editMoveDown()
2834 if (currentMapEditor())
2835 currentMapEditor()->moveBranchDown();
2838 void Main::editSortChildren()
2840 if (currentMapEditor())
2841 currentMapEditor()->sortChildren();
2844 void Main::editToggleScroll()
2846 if (currentMapEditor())
2848 currentMapEditor()->toggleScroll();
2852 void Main::editUnscrollChilds()
2854 if (currentMapEditor())
2855 currentMapEditor()->unscrollChilds();
2858 void Main::editNewBranch()
2860 MapEditor *me=currentMapEditor();
2861 if (!lineedit->isVisible() && me)
2863 BranchObj *bo=(BranchObj*)me->getSelection();
2864 BranchObj *newbo=me->addNewBranch(0);
2866 prevSelection=bo->getSelectString();
2868 me->select (newbo->getSelectString());
2872 if (actionSettingsAutoEditNewBranch->isOn())
2877 if (!prevSelection.isEmpty())
2879 me->select(prevSelection);
2886 void Main::editNewBranchBefore()
2888 MapEditor *me=currentMapEditor();
2889 if (!lineedit->isVisible() && me)
2891 BranchObj *bo=(BranchObj*)me->getSelection();
2892 BranchObj *newbo=me->addNewBranchBefore();
2895 me->select (newbo->getSelectString());
2899 if (actionSettingsAutoEditNewBranch->isOn())
2901 if (!actionSettingsAutoSelectNewBranch->isOn())
2902 prevSelection=bo->getSelectString();
2908 void Main::editNewBranchAbove()
2910 MapEditor *me=currentMapEditor();
2911 if (!lineedit->isVisible() && me)
2913 BranchObj *bo=(BranchObj*)me->getSelection();
2914 BranchObj *newbo=me->addNewBranch (-1);
2917 me->select (newbo->getSelectString());
2921 if (actionSettingsAutoEditNewBranch->isOn())
2923 if (!actionSettingsAutoSelectNewBranch->isOn())
2924 prevSelection=bo->getSelectString();
2930 void Main::editNewBranchBelow()
2932 MapEditor *me=currentMapEditor();
2933 if (!lineedit->isVisible() && me)
2935 BranchObj *bo=(BranchObj*)me->getSelection();
2936 BranchObj *newbo=me->addNewBranch (1);
2939 me->select (newbo->getSelectString());
2943 if (actionSettingsAutoEditNewBranch->isOn())
2945 if (!actionSettingsAutoSelectNewBranch->isOn())
2946 prevSelection=bo->getSelectString();
2952 void Main::editImportAdd()
2954 fileLoad (ImportAdd);
2957 void Main::editImportReplace()
2959 fileLoad (ImportReplace);
2962 void Main::editSaveBranch()
2964 fileSaveAs (PartOfMap);
2967 void Main::editDeleteKeepChilds()
2969 if (currentMapEditor())
2970 currentMapEditor()->deleteKeepChilds();
2973 void Main::editDeleteChilds()
2975 if (currentMapEditor())
2976 currentMapEditor()->deleteChilds();
2979 void Main::editDeleteSelection()
2981 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2982 currentMapEditor()->deleteSelection();
2985 void Main::editUpperBranch()
2987 if (currentMapEditor())
2988 currentMapEditor()->selectUpperBranch();
2991 void Main::editLowerBranch()
2993 if (currentMapEditor())
2994 currentMapEditor()->selectLowerBranch();
2997 void Main::editLeftBranch()
2999 if (currentMapEditor())
3000 currentMapEditor()->selectLeftBranch();
3003 void Main::editRightBranch()
3005 if (currentMapEditor())
3006 currentMapEditor()->selectRightBranch();
3009 void Main::editFirstBranch()
3011 if (currentMapEditor())
3012 currentMapEditor()->selectFirstBranch();
3015 void Main::editLastBranch()
3017 if (currentMapEditor())
3018 currentMapEditor()->selectLastBranch();
3021 void Main::editLoadImage()
3023 if (currentMapEditor())
3024 currentMapEditor()->loadFloatImage();
3027 void Main::editSaveImage()
3029 if (currentMapEditor())
3030 currentMapEditor()->saveFloatImage();
3033 void Main::editFollowXLink(QAction *a)
3036 if (currentMapEditor())
3037 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3040 void Main::editEditXLink(QAction *a)
3042 if (currentMapEditor())
3043 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3046 void Main::formatSelectColor()
3048 if (currentMapEditor())
3050 QColor col = QColorDialog::getColor((currentColor ), this );
3051 if ( !col.isValid() ) return;
3052 colorChanged( col );
3056 void Main::formatPickColor()
3058 if (currentMapEditor())
3059 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3062 void Main::colorChanged(QColor c)
3064 QPixmap pix( 16, 16 );
3066 actionFormatColor->setIconSet( pix );
3070 void Main::formatColorBranch()
3072 if (currentMapEditor())
3073 currentMapEditor()->colorBranch(currentColor);
3076 void Main::formatColorSubtree()
3078 if (currentMapEditor())
3079 currentMapEditor()->colorSubtree (currentColor);
3082 void Main::formatLinkStyleLine()
3084 if (currentMapEditor())
3086 currentMapEditor()->setMapLinkStyle("StyleLine");
3087 actionFormatLinkStyleLine->setOn(true);
3091 void Main::formatLinkStyleParabel()
3093 if (currentMapEditor())
3095 currentMapEditor()->setMapLinkStyle("StyleParabel");
3096 actionFormatLinkStyleParabel->setOn(true);
3100 void Main::formatLinkStylePolyLine()
3102 if (currentMapEditor())
3104 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3105 actionFormatLinkStylePolyLine->setOn(true);
3109 void Main::formatLinkStylePolyParabel()
3111 if (currentMapEditor())
3113 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3114 actionFormatLinkStylePolyParabel->setOn(true);
3118 void Main::formatSelectBackColor()
3120 if (currentMapEditor())
3121 currentMapEditor()->selectMapBackgroundColor();
3124 void Main::formatSelectBackImage()
3126 if (currentMapEditor())
3127 currentMapEditor()->selectMapBackgroundImage();
3130 void Main::formatSelectLinkColor()
3132 if (currentMapEditor())
3133 currentMapEditor()->selectMapLinkColor();
3136 void Main::formatSelectSelectionColor()
3138 if (currentMapEditor())
3139 currentMapEditor()->selectMapSelectionColor();
3142 void Main::formatToggleLinkColorHint()
3144 currentMapEditor()->toggleMapLinkColorHint();
3148 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3150 if (currentMapEditor())
3151 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3154 void Main::viewZoomReset()
3156 if (currentMapEditor())
3160 currentMapEditor()->setMatrix( m );
3164 void Main::viewZoomIn()
3166 if (currentMapEditor())
3168 QMatrix m = currentMapEditor()->matrix();
3169 m.scale( 1.25, 1.25 );
3170 currentMapEditor()->setMatrix( m );
3174 void Main::viewZoomOut()
3176 if (currentMapEditor())
3178 QMatrix m = currentMapEditor()->matrix();
3179 m.scale( 0.8, 0.8 );
3180 currentMapEditor()->setMatrix( m );
3184 void Main::viewCenter()
3186 MapEditor *me=currentMapEditor();
3189 me->ensureSelectionVisible();
3193 void Main::networkStartServer()
3195 MapEditor *me=currentMapEditor();
3196 if (me) me->newServer();
3199 void Main::networkConnect()
3201 MapEditor *me=currentMapEditor();
3202 if (me) me->connectToServer();
3205 bool Main::settingsPDF()
3207 // Default browser is set in constructor
3209 QString text = QInputDialog::getText(
3210 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3211 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3213 settings.setValue ("/mainwindow/readerPDF",text);
3218 bool Main::settingsURL()
3220 // Default browser is set in constructor
3222 QString text = QInputDialog::getText(
3223 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3224 settings.value("/mainwindow/readerURL").toString()
3227 settings.setValue ("/mainwindow/readerURL",text);
3231 void Main::settingsMacroDir()
3233 QDir defdir(vymBaseDir.path() + "/macros");
3234 if (!defdir.exists())
3236 QDir dir=QFileDialog::getExistingDirectory (
3238 tr ("Directory with vym macros:"),
3239 settings.value ("/macros/macroDir",defdir.path()).toString()
3242 settings.setValue ("/macros/macroDir",dir.absolutePath());
3245 void Main::settingsUndoLevels()
3248 int i = QInputDialog::getInteger(
3250 tr("QInputDialog::getInteger()"),
3251 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3254 settings.setValue ("/mapeditor/stepsTotal",i);
3255 QMessageBox::information( this, tr( "VYM -Information:" ),
3256 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3260 void Main::settingsAutosaveToggle()
3262 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3265 void Main::settingsAutosaveTime()
3268 int i = QInputDialog::getInteger(
3270 tr("QInputDialog::getInteger()"),
3271 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3273 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3276 void Main::settingsWriteBackupFileToggle()
3278 settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3281 void Main::settingsToggleDelKey()
3283 if (actionSettingsUseDelKey->isOn())
3285 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3288 actionEditDelete->setAccel (QKeySequence (""));
3292 void Main::windowToggleNoteEditor()
3294 if (textEditor->isVisible() )
3295 windowHideNoteEditor();
3297 windowShowNoteEditor();
3300 void Main::windowToggleHistory()
3302 if (historyWindow->isVisible())
3303 historyWindow->hide();
3305 historyWindow->show();
3309 void Main::windowToggleProperty()
3311 if (branchPropertyWindow->isVisible())
3312 branchPropertyWindow->hide();
3314 branchPropertyWindow->show();
3316 if(currentMapEditor())
3318 BranchObj *bo=currentMapEditor()->getSelectedBranch();
3321 branchPropertyWindow->setMapEditor(currentMapEditor());
3322 branchPropertyWindow->setBranch(bo);
3327 branchPropertyWindow->setBranch(NULL);
3330 void Main::windowToggleAntiAlias()
3332 bool b=actionViewToggleAntiAlias->isOn();
3334 for (int i=0;i<tabWidget->count();i++)
3337 me=(MapEditor*)tabWidget->page(i);
3338 me->setAntiAlias(b);
3343 void Main::windowToggleSmoothPixmap()
3345 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3347 for (int i=0;i<tabWidget->count();i++)
3350 me=(MapEditor*)tabWidget->page(i);
3351 me->setSmoothPixmap(b);
3355 void Main::updateHistory(SimpleSettings &undoSet)
3357 historyWindow->update (undoSet);
3360 void Main::updateNoteFlag()
3362 if (currentMapEditor())
3363 currentMapEditor()->updateNoteFlag();
3366 void Main::updateSatellites(MapEditor *me)
3368 branchPropertyWindow->setMapEditor (me);
3371 void Main::updateActions()
3373 MapEditor *me=currentMapEditor();
3376 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3378 // updateActions is also called when NoteEditor is closed
3379 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3380 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3381 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3383 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3384 actionFormatLinkColorHint->setOn(true);
3386 actionFormatLinkColorHint->setOn(false);
3388 switch (me->getMapLinkStyle())
3390 case LinkableMapObj::Line:
3391 actionFormatLinkStyleLine->setOn(true);
3393 case LinkableMapObj::Parabel:
3394 actionFormatLinkStyleParabel->setOn(true);
3396 case LinkableMapObj::PolyLine:
3397 actionFormatLinkStylePolyLine->setOn(true);
3399 case LinkableMapObj::PolyParabel:
3400 actionFormatLinkStylePolyParabel->setOn(true);
3407 QPixmap pix( 16, 16 );
3408 pix.fill( me->getMapBackgroundColor() );
3409 actionFormatBackColor->setIconSet( pix );
3410 pix.fill( me->getSelectionColor() );
3411 actionFormatSelectionColor->setIconSet( pix );
3412 pix.fill( me->getMapDefLinkColor() );
3413 actionFormatLinkColor->setIconSet( pix );
3416 actionFileSave->setEnabled( me->hasChanged() );
3417 if (me->isUndoAvailable())
3418 actionEditUndo->setEnabled( true);
3420 actionEditUndo->setEnabled( false);
3422 if (me->isRedoAvailable())
3423 actionEditRedo->setEnabled( true);
3425 actionEditRedo->setEnabled( false);
3427 LinkableMapObj *selection=me->getSelection();
3430 if ( (typeid(*selection) == typeid(BranchObj)) ||
3431 (typeid(*selection) == typeid(MapCenterObj)) )
3433 BranchObj *bo=(BranchObj*)selection;
3434 // Take care of links
3435 if (bo->countXLinks()==0)
3437 branchXLinksContextMenuEdit->clear();
3438 branchXLinksContextMenuFollow->clear();
3443 branchXLinksContextMenuEdit->clear();
3444 branchXLinksContextMenuFollow->clear();
3445 for (int i=0; i<=bo->countXLinks();i++)
3447 bot=bo->XLinkTargetAt(i);
3450 s=bot->getHeading();
3451 if (s.length()>xLinkMenuWidth)
3452 s=s.left(xLinkMenuWidth)+"...";
3453 branchXLinksContextMenuFollow->addAction (s);
3454 branchXLinksContextMenuEdit->addAction (s);
3459 standardFlagsDefault->setEnabled (true);
3461 actionEditToggleScroll->setEnabled (true);
3462 if ( bo->isScrolled() )
3463 actionEditToggleScroll->setOn(true);
3465 actionEditToggleScroll->setOn(false);
3467 if ( bo->getURL().isEmpty() )
3469 actionEditOpenURL->setEnabled (false);
3470 actionEditOpenURLTab->setEnabled (false);
3474 actionEditOpenURL->setEnabled (true);
3475 actionEditOpenURLTab->setEnabled (true);
3477 if ( bo->getVymLink().isEmpty() )
3479 actionEditOpenVymLink->setEnabled (false);
3480 actionEditDeleteVymLink->setEnabled (false);
3483 actionEditOpenVymLink->setEnabled (true);
3484 actionEditDeleteVymLink->setEnabled (true);
3487 if (bo->canMoveBranchUp())
3488 actionEditMoveUp->setEnabled (true);
3490 actionEditMoveUp->setEnabled (false);
3491 if (bo->canMoveBranchDown())
3492 actionEditMoveDown->setEnabled (true);
3494 actionEditMoveDown->setEnabled (false);
3497 actionEditToggleHideExport->setEnabled (true);
3498 actionEditToggleHideExport->setOn (bo->hideInExport() );
3500 actionEditCopy->setEnabled (true);
3501 actionEditCut->setEnabled (true);
3502 if (!clipboardEmpty)
3503 actionEditPaste->setEnabled (true);
3505 actionEditPaste->setEnabled (false);
3506 for (int i=0; i<actionListBranches.size(); ++i)
3507 actionListBranches.at(i)->setEnabled(true);
3508 actionEditDelete->setEnabled (true);
3509 actionFormatHideLinkUnselected->setOn
3510 (selection->getHideLinkUnselected());
3512 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3514 FloatObj *fo=(FloatImageObj*)selection;
3516 actionEditOpenURL->setEnabled (false);
3517 actionEditOpenVymLink->setEnabled (false);
3518 actionEditDeleteVymLink->setEnabled (false);
3519 actionEditToggleHideExport->setEnabled (true);
3520 actionEditToggleHideExport->setOn (fo->hideInExport() );
3523 actionEditCopy->setEnabled (true);
3524 actionEditCut->setEnabled (true);
3525 actionEditPaste->setEnabled (false);
3526 for (int i=0; i<actionListBranches.size(); ++i)
3527 actionListBranches.at(i)->setEnabled(false);
3528 actionEditDelete->setEnabled (true);
3529 actionFormatHideLinkUnselected->setOn
3530 ( selection->getHideLinkUnselected());
3531 actionEditMoveUp->setEnabled (false);
3532 actionEditMoveDown->setEnabled (false);
3537 actionEditCopy->setEnabled (false);
3538 actionEditCut->setEnabled (false);
3539 actionEditPaste->setEnabled (false);
3540 for (int i=0; i<actionListBranches.size(); ++i)
3541 actionListBranches.at(i)->setEnabled(false);
3543 actionEditToggleScroll->setEnabled (false);
3544 actionEditOpenURL->setEnabled (false);
3545 actionEditOpenVymLink->setEnabled (false);
3546 actionEditDeleteVymLink->setEnabled (false);
3547 actionEditHeading2URL->setEnabled (false);
3548 actionEditDelete->setEnabled (false);
3549 actionEditMoveUp->setEnabled (false);
3550 actionEditMoveDown->setEnabled (false);
3551 actionEditToggleHideExport->setEnabled (false);
3555 Main::ModMode Main::getModMode()
3557 if (actionModModeColor->isOn()) return ModModeColor;
3558 if (actionModModeCopy->isOn()) return ModModeCopy;
3559 if (actionModModeXLink->isOn()) return ModModeXLink;
3563 bool Main::autoEditNewBranch()
3565 return actionSettingsAutoEditNewBranch->isOn();
3568 bool Main::autoSelectNewBranch()
3570 return actionSettingsAutoSelectNewBranch->isOn();
3573 bool Main::useFlagGroups()
3575 return actionSettingsUseFlagGroups->isOn();
3578 void Main::windowShowNoteEditor()
3580 textEditor->setShowWithMain(true);
3582 actionViewToggleNoteEditor->setOn (true);
3585 void Main::windowHideNoteEditor()
3587 textEditor->setShowWithMain(false);
3589 actionViewToggleNoteEditor->setOn (false);
3592 void Main::setScript (const QString &script)
3594 scriptEditor->setScript (script);
3597 void Main::runScript (const QString &script)
3599 if (currentMapEditor())
3600 currentMapEditor()->runScript (script);
3603 void Main::runScriptEverywhere (const QString &script)
3606 for (int i=0;i<=tabWidget->count() -1;i++)
3608 me=(MapEditor*)tabWidget->page(i);
3609 if (me) me->runScript (script);
3613 void Main::windowNextEditor()
3615 if (tabWidget->currentPageIndex() < tabWidget->count())
3616 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3619 void Main::windowPreviousEditor()
3621 if (tabWidget->currentPageIndex() >0)
3622 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3625 void Main::standardFlagChanged()
3627 if (currentMapEditor())
3628 currentMapEditor()->toggleStandardFlag(sender()->name());
3631 void Main::testFunction1()
3633 if (!currentMapEditor()) return;
3634 //currentMapEditor()->testFunction1();
3638 void Main::testFunction2()
3640 if (!currentMapEditor()) return;
3641 currentMapEditor()->testFunction2();
3644 void Main::testCommand()
3646 if (!currentMapEditor()) return;
3647 scriptEditor->show();
3650 QString com = QInputDialog::getText(
3651 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3652 if (ok) currentMapEditor()->parseAtom(com);
3656 void Main::helpDoc()
3658 QString locale = QLocale::system().name();
3660 if (locale.left(2)=="es")
3661 docname="vym_es.pdf";
3665 QStringList searchList;
3667 #if defined(Q_OS_MACX)
3668 searchList << "./vym.app/Contents/Resources/doc";
3669 #elif defined(Q_OS_WIN32)
3670 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3672 #if defined(VYM_DOCDIR)
3673 searchList << VYM_DOCDIR;
3675 // default path in SUSE LINUX
3676 searchList << "/usr/share/doc/packages/vym";
3679 searchList << "doc"; // relative path for easy testing in tarball
3680 searchList << "doc/tex"; // Easy testing working on vym.tex
3681 searchList << "/usr/share/doc/vym"; // Debian
3682 searchList << "/usr/share/doc/packages";// Knoppix
3686 for (int i=0; i<searchList.count(); ++i)
3688 docfile.setFileName(searchList.at(i)+"/"+docname);
3689 if (docfile.exists())
3698 QMessageBox::critical(0,
3699 tr("Critcal error"),
3700 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3705 Process *pdfProc = new Process();
3706 args << QDir::toNativeSeparators(docfile.fileName());
3708 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3709 if ( !pdfProc->waitForStarted() )
3712 QMessageBox::warning(0,
3714 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3715 tr("Please use Settings->")+tr("Set application to open PDF files"));
3722 void Main::helpDemo()
3724 QStringList filters;
3725 filters <<"VYM example map (*.vym)";
3726 QFileDialog *fd=new QFileDialog( this);
3727 #if defined(Q_OS_MACX)
3728 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3730 // default path in SUSE LINUX
3731 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3734 fd->setFileMode (QFileDialog::ExistingFiles);
3735 fd->setFilters (filters);
3736 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3740 if ( fd->exec() == QDialog::Accepted )
3742 lastFileDir=fd->directory().path();
3743 QStringList flist = fd->selectedFiles();
3744 QStringList::Iterator it = flist.begin();
3745 while( it != flist.end() )
3748 fileLoad(*it, NewMap);
3756 void Main::helpAbout()
3759 ad.setName ("aboutwindow");
3760 ad.setMinimumSize(500,500);
3761 ad.resize (QSize (500,500));
3765 void Main::helpAboutQT()
3767 QMessageBox::aboutQt( this, "Qt Application Example" );
3770 void Main::callMacro ()
3772 QAction *action = qobject_cast<QAction *>(sender());
3776 i=action->data().toInt();
3777 QString mDir (settings.value ("macros/macroDir").toString() );
3779 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3781 if ( !f.open( QIODevice::ReadOnly ) )
3783 QMessageBox::warning(0,
3785 tr("Couldn't find a macro at %1.\n").arg(fn)+
3786 tr("Please use Settings->")+tr("Set directory for vym macros"));
3790 QTextStream ts( &f );
3791 QString m= ts.read();
3795 //cout <<"Main::callMacro m="<<qPrintable (m)<<endl;
3796 currentMapEditor()->runScript (m);
3803 //////////////////////////////////
3805 @@ -2544,18 +2576,27 @@
3806 // Try to open new tab in existing konqueror started previously by vym
3807 p=new QProcess (this);
3809 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3810 - "konqueror-mainwindow#1"<<
3812 +#if defined(Q_OS_WIN32)
3813 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3814 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3815 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3816 + "konqueror-mainwindow#1"<<
3820 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3821 + "konqueror-mainwindow#1"<<
3825 p->start ("dcop",args);
3826 if ( !p->waitForStarted() ) success=false;