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 extern QString iconPath;
72 extern QString flagsPath;
74 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
75 QMainWindow(parent,name,f)
79 setCaption ("VYM - View Your Mind");
81 // Load window settings
82 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
83 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
86 // Sometimes we may need to remember old selections
90 currentColor=Qt::black;
92 // Create unique temporary directory
94 tmpVymDir=makeTmpDir (ok,"vym");
97 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
100 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
102 // Create direcctory for clipboard
103 clipboardDir=tmpVymDir+"/clipboard";
104 clipboardFile="map.xml";
105 QDir d(clipboardDir);
106 d.mkdir (clipboardDir,true);
107 makeSubDirs (clipboardDir);
112 // Satellite windows //////////////////////////////////////////
115 historyWindow=new HistoryWindow();
116 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
119 branchPropertyWindow = new BranchPropertyWindow();
120 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
122 // Connect TextEditor, so that we can update flags if text changes
123 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
124 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
126 // Connect HistoryWindow, so that we can update flags
127 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
130 // Initialize script editor
131 scriptEditor = new SimpleScriptEditor();
132 scriptEditor->move (50,50);
134 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
135 this, SLOT( runScript( QString ) ) );
138 // Initialize Find window
139 findWindow=new FindWindow(NULL);
140 findWindow->move (x(),y()+70);
141 connect (findWindow, SIGNAL( findButton(QString) ),
142 this, SLOT(editFind(QString) ) );
143 connect (findWindow, SIGNAL( somethingChanged() ),
144 this, SLOT(editFindChanged() ) );
146 // Initialize some settings, which are platform dependant
149 // application to open URLs
150 p="/mainwindow/readerURL";
151 #if defined(Q_OS_LINUX)
152 s=settings.value (p,"xdg-open").toString();
154 #if defined(Q_OS_MACX)
155 s=settings.value (p,"/usr/bin/open").toString();
158 #if defined(Q_OS_WIN32)
159 // Assume that system has been set up so that
160 // Explorer automagically opens up the URL
161 // in the user's preferred browser.
162 s=settings.value (p,"explorer").toString();
164 s=settings.value (p,"mozilla").toString();
168 settings.setValue( p,s);
170 // application to open PDFs
171 p="/mainwindow/readerPDF";
172 #if defined(Q_OS_LINUX)
173 s=settings.value (p,"xdg-open").toString();
175 #if defined(Q_OS_MACX)
176 s=settings.value (p,"/usr/bin/open").toString();
178 s=settings.value (p,"acroread").toString();
181 settings.setValue( p,s);
183 // width of xLinksMenu
186 // Create tab widget which holds the maps
187 tabWidget= new QTabWidget (this);
188 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
189 this, SLOT( editorChanged( QWidget * ) ) );
191 lineedit=new QLineEdit (this);
194 setCentralWidget(tabWidget);
198 setupFormatActions();
202 setupNetworkActions();
203 setupSettingsActions();
206 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
211 restoreState (settings.value("/mainwindow/state",0).toByteArray());
219 settings.setValue ( "/mainwindow/geometry/size", size() );
220 settings.setValue ( "/mainwindow/geometry/pos", pos() );
221 settings.setValue ("/mainwindow/state",saveState(0));
223 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
224 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
225 settings.setValue( "/version/version", vymVersion );
226 settings.setValue( "/version/builddate", vymBuildDate );
228 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
229 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
230 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
231 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
232 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
233 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
234 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
236 //TODO save scriptEditor settings
238 // call the destructors
240 delete historyWindow;
241 delete branchPropertyWindow;
243 // Remove temporary directory
244 removeDir (QDir(tmpVymDir));
247 void Main::loadCmdLine()
249 /* TODO draw some kind of splashscreen while loading...
255 QStringList flist=options.getFileList();
256 QStringList::Iterator it=flist.begin();
258 while (it !=flist.end() )
260 fileLoad (*it, NewMap);
266 void Main::statusMessage(const QString &s)
268 statusBar()->message( s);
271 void Main::closeEvent (QCloseEvent* )
277 void Main::setupFileActions()
279 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
280 QToolBar *tb = addToolBar( tr ("&Map") );
281 tb->setObjectName ("mapTB");
284 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
285 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
286 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
288 fileMenu->addAction (a);
289 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
291 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
292 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
293 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
294 fileMenu->addAction (a);
295 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
297 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
298 a->setStatusTip (tr( "Open","Status tip File menu" ) );
299 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
301 fileMenu->addAction (a);
302 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
304 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
305 fileMenu->addSeparator();
307 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
308 a->setStatusTip ( tr( "Save","Status tip file menu" ));
309 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
311 fileMenu->addAction (a);
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
315 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
316 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
317 fileMenu->addAction (a);
318 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
320 fileMenu->addSeparator();
322 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
324 a = new QAction(tr("KDE Bookmarks"), this);
325 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
326 a->addTo (fileImportMenu);
327 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
329 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
331 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
332 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
333 a->addTo (fileImportMenu);
334 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
337 a = new QAction("Freemind...",this);
338 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
339 fileImportMenu->addAction (a);
340 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
342 a = new QAction("Mind Manager...",this);
343 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
344 fileImportMenu->addAction (a);
345 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
347 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
348 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
349 fileImportMenu->addAction (a);
350 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
352 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
354 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
355 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
357 fileExportMenu->addAction (a);
359 a = new QAction( "Open Office...", this);
360 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
361 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
362 fileExportMenu->addAction (a);
364 a = new QAction( "Webpage (XHTML)...",this );
365 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
366 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
367 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
368 fileExportMenu->addAction (a);
370 a = new QAction( "Text (ASCII)...", this);
371 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
372 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
373 fileExportMenu->addAction (a);
375 a = new QAction( "Spreadsheet (CSV)...", this);
376 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
377 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
378 fileExportMenu->addAction (a);
380 a = new QAction( tr("KDE Bookmarks","File menu"), this);
381 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
382 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
383 fileExportMenu->addAction (a);
385 a = new QAction( "Taskjuggler...", this );
386 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
387 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
388 fileExportMenu->addAction (a);
390 a = new QAction( "LaTeX...", this);
391 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
393 fileExportMenu->addAction (a);
395 a = new QAction( "XML..." , this );
396 a->setStatusTip (tr( "Export as %1").arg("XML"));
397 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
398 fileExportMenu->addAction (a);
400 fileMenu->addSeparator();
402 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
403 a->setStatusTip ( tr( "Print" ,"File menu") );
404 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
406 fileMenu->addAction (a);
407 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
410 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
411 a->setStatusTip (tr( "Close Map" ) );
412 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
413 fileMenu->addAction (a);
414 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
416 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
417 a->setStatusTip ( tr( "Exit")+" "+vymName );
418 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
419 fileMenu->addAction (a);
420 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
425 void Main::setupEditActions()
427 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
428 tb->setLabel( "Edit Actions" );
429 tb->setObjectName ("actionsTB");
430 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
434 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
435 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
436 a->setStatusTip (tr( "Undo" ) );
437 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
438 a->setEnabled (false);
440 editMenu->addAction (a);
443 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
444 a->setStatusTip (tr( "Redo" ));
445 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
447 editMenu->addAction (a);
448 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
451 editMenu->addSeparator();
452 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
453 a->setStatusTip ( tr( "Copy" ) );
454 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
455 a->setEnabled (false);
457 editMenu->addAction (a);
458 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
461 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
462 a->setStatusTip ( tr( "Cut" ) );
463 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
464 a->setEnabled (false);
466 editMenu->addAction (a);
468 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
470 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
471 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
472 a->setStatusTip ( tr( "Paste" ) );
473 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
474 a->setEnabled (false);
476 editMenu->addAction (a);
479 // Shortcuts to modify heading:
480 a = new QAction(tr( "Edit heading","Edit menu" ),this);
481 a->setStatusTip ( tr( "edit Heading" ));
482 a->setShortcut ( Qt::Key_Enter); //Edit heading
483 // a->setShortcutContext (Qt::WindowShortcut);
485 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
486 actionListBranches.append(a);
487 a = new QAction( tr( "Edit heading","Edit menu" ), this);
488 a->setStatusTip (tr( "edit Heading" ));
489 a->setShortcut (Qt::Key_Return ); //Edit heading
490 //a->setShortcutContext (Qt::WindowShortcut);
492 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
493 actionListBranches.append(a);
494 editMenu->addAction (a);
496 a = new QAction( tr( "Edit heading","Edit menu" ), this);
497 a->setStatusTip (tr( "edit Heading" ));
498 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
499 a->setShortcutContext (Qt::WindowShortcut);
501 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
502 actionListBranches.append(a);
504 // Shortcut to delete selection
505 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
506 a->setStatusTip (tr( "Delete Selection" ));
507 a->setShortcut ( Qt::Key_Delete); //Delete selection
508 a->setShortcutContext (Qt::WindowShortcut);
510 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
513 // Shortcut to add branch
514 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
515 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
516 alt->setShortcut (Qt::Key_A); //Add branch
517 alt->setShortcutContext (Qt::WindowShortcut);
519 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
520 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
521 a->setStatusTip ( tr( "Add a branch as child of selection" ));
522 a->setShortcut (Qt::Key_Insert); //Add branch
523 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
524 actionListBranches.append(a);
525 #if defined (Q_OS_MACX)
526 // In OSX show different shortcut in menues, the keys work indepently always
527 actionEditAddBranch=alt;
529 actionEditAddBranch=a;
531 editMenu->addAction (actionEditAddBranch);
532 tb->addAction (actionEditAddBranch);
535 // Add branch by inserting it at selection
536 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
537 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
538 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
539 a->setShortcutContext (Qt::WindowShortcut);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
542 a->setEnabled (false);
543 actionListBranches.append(a);
544 actionEditAddBranchBefore=a;
545 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
546 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
547 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
548 a->setShortcutContext (Qt::WindowShortcut);
550 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
551 actionListBranches.append(a);
554 a = new QAction(tr( "Add branch above","Edit menu" ), this);
555 a->setStatusTip ( tr( "Add a branch above selection" ));
556 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
557 a->setShortcutContext (Qt::WindowShortcut);
559 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
560 a->setEnabled (false);
561 actionListBranches.append(a);
562 actionEditAddBranchAbove=a;
563 a = new QAction(tr( "Add branch above","Edit menu" ), this);
564 a->setStatusTip ( tr( "Add a branch above selection" ));
565 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
566 a->setShortcutContext (Qt::WindowShortcut);
568 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
569 actionListBranches.append(a);
572 a = new QAction(tr( "Add branch below","Edit menu" ), this);
573 a->setStatusTip ( tr( "Add a branch below selection" ));
574 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
575 a->setShortcutContext (Qt::WindowShortcut);
577 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
578 a->setEnabled (false);
579 actionListBranches.append(a);
580 actionEditAddBranchBelow=a;
581 a = new QAction(tr( "Add branch below","Edit menu" ), this);
582 a->setStatusTip ( tr( "Add a branch below selection" ));
583 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
584 a->setShortcutContext (Qt::WindowShortcut);
586 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
587 actionListBranches.append(a);
589 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
590 a->setStatusTip ( tr( "Move branch up" ) );
591 a->setShortcut (Qt::Key_PageUp ); // Move branch up
592 a->setEnabled (false);
594 editMenu->addAction (a);
595 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
598 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
599 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
600 a->setStatusTip (tr( "Move branch down" ) );
601 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
602 a->setEnabled (false);
604 editMenu->addAction (a);
605 actionEditMoveDown=a;
607 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
608 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
609 a->setEnabled (true);
611 editMenu->addAction (a);
612 actionEditSortChildren=a;
614 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
615 a->setShortcut ( Qt::Key_ScrollLock );
616 a->setStatusTip (tr( "Scroll branch" ) );
617 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
619 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
620 alt->setShortcut ( Qt::Key_S ); // Scroll branch
621 alt->setStatusTip (tr( "Scroll branch" ));
622 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
623 #if defined(Q_OS_MACX)
624 actionEditToggleScroll=alt;
626 actionEditToggleScroll=a;
628 actionEditToggleScroll->setEnabled (false);
629 actionEditToggleScroll->setToggleAction(true);
630 tb->addAction (actionEditToggleScroll);
631 editMenu->addAction ( actionEditToggleScroll);
632 editMenu->addAction (actionEditToggleScroll);
635 actionListBranches.append(actionEditToggleScroll);
637 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
638 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
639 editMenu->addAction (a);
640 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
642 editMenu->addSeparator();
644 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
645 a->setStatusTip (tr( "Find" ) );
646 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
647 editMenu->addAction (a);
648 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
650 editMenu->addSeparator();
652 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
653 a->setShortcut (Qt::CTRL + Qt::Key_U );
654 a->setShortcut (tr( "Open URL" ));
657 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
660 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
661 a->setStatusTip (tr( "Open URL in new tab" ));
662 //a->setShortcut (Qt::CTRL+Qt::Key_U );
664 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
665 actionEditOpenURLTab=a;
667 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
668 a->setStatusTip (tr( "Open all URLs in subtree" ));
670 actionListBranches.append(a);
671 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
672 actionEditOpenMultipleURLTabs=a;
674 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
675 a->setStatusTip ( tr( "Edit URL" ) );
676 a->setShortcut ( Qt::Key_U );
677 a->setShortcutContext (Qt::WindowShortcut);
678 actionListBranches.append(a);
680 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
683 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
684 a->setStatusTip ( tr( "Edit local URL" ) );
685 a->setShortcut (Qt::SHIFT + Qt::Key_U );
686 a->setShortcutContext (Qt::WindowShortcut);
687 actionListBranches.append(a);
689 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
690 actionEditLocalURL=a;
692 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
693 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
694 a->setEnabled (false);
695 actionListBranches.append(a);
696 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
697 actionEditHeading2URL=a;
699 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
700 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
701 a->setEnabled (false);
702 actionListBranches.append(a);
703 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
704 actionEditBugzilla2URL=a;
706 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
707 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
708 a->setEnabled (false);
709 actionListBranches.append(a);
710 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
711 actionEditFATE2URL=a;
713 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
714 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
716 a->setEnabled (false);
717 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
718 actionEditOpenVymLink=a;
720 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
721 a->setStatusTip ( tr( "Open all vym links in subtree" ));
722 a->setEnabled (false);
723 actionListBranches.append(a);
724 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
725 actionEditOpenMultipleVymLinks=a;
728 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
729 a->setEnabled (false);
730 a->setStatusTip ( tr( "Edit link to another vym map" ));
731 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
732 actionListBranches.append(a);
735 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
736 a->setStatusTip ( tr( "Delete link to another vym map" ));
737 a->setEnabled (false);
738 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
739 actionEditDeleteVymLink=a;
741 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
742 a->setStatusTip ( tr( "Hide object in exports" ) );
743 a->setShortcut (Qt::Key_H );
744 a->setToggleAction(true);
746 a->setEnabled (false);
747 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
748 actionEditToggleHideExport=a;
750 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
751 a->setStatusTip ( tr( "Edit Map Info" ));
752 a->setEnabled (true);
753 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
756 // Import at selection (adding to selection)
757 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
758 a->setStatusTip (tr( "Add map at selection" ));
759 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
760 a->setEnabled (false);
761 actionListBranches.append(a);
762 actionEditImportAdd=a;
764 // Import at selection (replacing selection)
765 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
766 a->setStatusTip (tr( "Replace selection with map" ));
767 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
768 a->setEnabled (false);
769 actionListBranches.append(a);
770 actionEditImportReplace=a;
773 a = new QAction( tr( "Save selection","Edit menu" ), this);
774 a->setStatusTip (tr( "Save selection" ));
775 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
776 a->setEnabled (false);
777 actionListBranches.append(a);
778 actionEditSaveBranch=a;
780 // Only remove branch, not its childs
781 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
782 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
783 a->setShortcut (Qt::ALT + Qt::Key_Delete );
784 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
785 a->setEnabled (false);
787 actionListBranches.append(a);
788 actionEditDeleteKeepChilds=a;
790 // Only remove childs of a branch
791 a = new QAction( tr( "Remove childs","Edit menu" ), this);
792 a->setStatusTip (tr( "Remove childs of branch" ));
793 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
794 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
795 a->setEnabled (false);
796 actionListBranches.append(a);
797 actionEditDeleteChilds=a;
799 // Shortcuts for navigating with cursor:
800 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
801 a->setStatusTip ( tr( "Select upper branch" ));
802 a->setShortcut (Qt::Key_Up );
803 a->setShortcutContext (Qt::WindowShortcut);
805 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
806 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
807 a->setStatusTip (tr( "Select lower branch" ));
808 a->setShortcut ( Qt::Key_Down );
809 a->setShortcutContext (Qt::WindowShortcut);
811 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
812 a = new QAction(tr( "Select left branch","Edit menu" ), this);
813 a->setStatusTip ( tr( "Select left branch" ));
814 a->setShortcut (Qt::Key_Left );
815 a->setShortcutContext (Qt::WindowShortcut);
817 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
818 a = new QAction( tr( "Select child branch","Edit menu" ), this);
819 a->setStatusTip (tr( "Select right branch" ));
820 a->setShortcut (Qt::Key_Right);
821 a->setShortcutContext (Qt::WindowShortcut);
823 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
824 a = new QAction( tr( "Select first branch","Edit menu" ), this);
825 a->setStatusTip (tr( "Select first branch" ));
826 a->setShortcut (Qt::Key_Home );
827 a->setShortcutContext (Qt::WindowShortcut);
829 a->setEnabled (false);
830 editMenu->addAction (a);
831 actionListBranches.append(a);
832 actionEditSelectFirst=a;
833 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
834 a = new QAction( tr( "Select last branch","Edit menu" ),this);
835 a->setStatusTip (tr( "Select last branch" ));
836 a->setShortcut ( Qt::Key_End );
837 a->setShortcutContext (Qt::WindowShortcut);
839 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
840 a->setEnabled (false);
841 editMenu->addAction (a);
842 actionListBranches.append(a);
843 actionEditSelectLast=a;
845 a = new QAction( tr( "Add Image...","Edit menu" ), this);
846 a->setStatusTip (tr( "Add Image" ));
847 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
848 actionEditLoadImage=a;
850 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
851 a->setStatusTip (tr( "Set properties for selection" ));
852 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
853 a->setShortcutContext (Qt::WindowShortcut);
854 a->setToggleAction (true);
856 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
857 actionViewTogglePropertyWindow=a;
861 void Main::setupFormatActions()
863 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
865 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
866 tb->setObjectName ("formatTB");
869 pix.fill (Qt::black);
870 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
871 a->setStatusTip ( tr( "Set Color" ));
872 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
874 formatMenu->addAction (a);
876 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
877 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
878 a->setShortcut (Qt::CTRL + Qt::Key_K );
879 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
880 a->setEnabled (false);
882 formatMenu->addAction (a);
883 actionListBranches.append(a);
884 actionFormatPickColor=a;
886 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
887 a->setStatusTip ( tr( "Color branch" ) );
888 a->setShortcut (Qt::CTRL + Qt::Key_B);
889 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
890 a->setEnabled (false);
892 formatMenu->addAction (a);
893 actionListBranches.append(a);
894 actionFormatColorSubtree=a;
896 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
897 a->setStatusTip ( tr( "Color Subtree" ));
898 a->setShortcut (Qt::CTRL + Qt::Key_T);
899 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
900 a->setEnabled (false);
901 formatMenu->addAction (a);
903 actionListBranches.append(a);
904 actionFormatColorSubtree=a;
906 formatMenu->addSeparator();
907 actionGroupFormatLinkStyles=new QActionGroup ( this);
908 actionGroupFormatLinkStyles->setExclusive (true);
909 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
910 a->setStatusTip (tr( "Line" ));
911 a->setToggleAction(true);
912 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
913 formatMenu->addAction (a);
914 actionFormatLinkStyleLine=a;
915 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
916 a->setStatusTip (tr( "Line" ));
917 a->setToggleAction(true);
918 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
919 formatMenu->addAction (a);
920 actionFormatLinkStyleParabel=a;
921 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
922 a->setStatusTip (tr( "PolyLine" ));
923 a->setToggleAction(true);
924 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
925 formatMenu->addAction (a);
926 actionFormatLinkStylePolyLine=a;
927 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
928 a->setStatusTip (tr( "PolyParabel" ) );
929 a->setToggleAction(true);
930 a->setChecked (true);
931 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
932 formatMenu->addAction (a);
933 actionFormatLinkStylePolyParabel=a;
935 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
936 a->setStatusTip (tr( "Hide link" ));
937 a->setToggleAction(true);
938 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
939 actionFormatHideLinkUnselected=a;
941 formatMenu->addSeparator();
942 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
943 a->setStatusTip (tr( "Use same color for links and headings" ));
944 a->setToggleAction(true);
945 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
946 formatMenu->addAction (a);
947 actionFormatLinkColorHint=a;
949 pix.fill (Qt::white);
950 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
951 a->setStatusTip (tr( "Set Link Color" ));
952 formatMenu->addAction (a);
953 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
954 actionFormatLinkColor=a;
956 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
957 a->setStatusTip (tr( "Set Selection Color" ));
958 formatMenu->addAction (a);
959 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
960 actionFormatSelectionColor=a;
962 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
963 a->setStatusTip (tr( "Set Background Color" ));
964 formatMenu->addAction (a);
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
966 actionFormatBackColor=a;
968 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
969 a->setStatusTip (tr( "Set Background image" ));
970 formatMenu->addAction (a);
971 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
972 actionFormatBackImage=a;
976 void Main::setupViewActions()
978 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
979 tb->setLabel( "View Actions" );
980 tb->setObjectName ("viewTB");
981 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
984 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
985 a->setStatusTip ( tr( "Zoom reset" ) );
986 a->setShortcut (Qt::CTRL + Qt::Key_0 );
988 viewMenu->addAction (a);
989 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
991 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
992 a->setStatusTip (tr( "Zoom in" ));
993 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
995 viewMenu->addAction (a);
996 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
998 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
999 a->setStatusTip (tr( "Zoom out" ));
1000 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1002 viewMenu->addAction (a);
1003 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1005 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1006 a->setStatusTip (tr( "Show selection" ));
1007 a->setShortcut (Qt::Key_Period);
1009 viewMenu->addAction (a);
1010 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1012 viewMenu->addSeparator();
1014 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1015 a->setStatusTip ( tr( "Show Note Editor" ));
1016 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1017 a->setToggleAction(true);
1019 viewMenu->addAction (a);
1020 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1021 actionViewToggleNoteEditor=a;
1023 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1024 a->setStatusTip ( tr( "Show History Window" ));
1025 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1026 a->setToggleAction(true);
1028 viewMenu->addAction (a);
1029 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1030 actionViewToggleHistoryWindow=a;
1032 viewMenu->addAction (actionViewTogglePropertyWindow);
1034 viewMenu->addSeparator();
1036 a = new QAction(tr( "Antialiasing","View action" ),this );
1037 a->setStatusTip ( tr( "Antialiasing" ));
1038 a->setToggleAction(true);
1039 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1040 viewMenu->addAction (a);
1041 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1042 actionViewToggleAntiAlias=a;
1044 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1045 a->setStatusTip (a->text());
1046 a->setToggleAction(true);
1047 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1048 viewMenu->addAction (a);
1049 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1050 actionViewToggleSmoothPixmapTransform=a;
1052 a = new QAction(tr( "Next Map","View action" ), this);
1053 a->setStatusTip (a->text());
1054 a->setShortcut (Qt::ALT + Qt::Key_N );
1055 viewMenu->addAction (a);
1056 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1058 a = new QAction (tr( "Previous Map","View action" ), this );
1059 a->setStatusTip (a->text());
1060 a->setShortcut (Qt::ALT + Qt::Key_P );
1061 viewMenu->addAction (a);
1062 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1066 void Main::setupModeActions()
1068 //QPopupMenu *menu = new QPopupMenu( this );
1069 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1071 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1072 tb->setObjectName ("modesTB");
1074 actionGroupModModes=new QActionGroup ( this);
1075 actionGroupModModes->setExclusive (true);
1076 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1077 a->setShortcut (Qt::Key_J);
1078 a->setStatusTip ( tr( "Use modifier to color branches" ));
1079 a->setToggleAction(true);
1082 actionModModeColor=a;
1084 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1085 a->setShortcut( Qt::Key_K);
1086 a->setStatusTip( tr( "Use modifier to copy" ));
1087 a->setToggleAction(true);
1089 actionModModeCopy=a;
1091 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1092 a->setShortcut (Qt::Key_L);
1093 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1094 a->setToggleAction(true);
1096 actionModModeXLink=a;
1100 void Main::setupFlagActions()
1102 // Create System Flags
1106 systemFlagsDefault = new FlagRowObj ();
1107 systemFlagsDefault->setVisibility (false);
1108 systemFlagsDefault->setName ("systemFlagsDef");
1110 FlagObj *fo = new FlagObj ();
1111 fo->load(QPixmap(flagsPath+"flag-note.png"));
1112 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1114 fo->load(QPixmap(flagsPath+"flag-url.png"));
1115 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1117 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1118 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1120 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1121 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1123 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1124 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1126 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1127 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1129 // Create Standard Flags
1130 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1131 tb->setObjectName ("standardFlagTB");
1133 standardFlagsDefault = new FlagRowObj ();
1134 standardFlagsDefault->setVisibility (false);
1135 standardFlagsDefault->setName ("standardFlagsDef");
1136 standardFlagsDefault->setToolBar (tb);
1138 fo->load(flagsPath+"flag-exclamationmark.png");
1139 fo->setGroup("standard-mark");
1140 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1142 fo->load(flagsPath+"flag-questionmark.png");
1143 fo->setGroup("standard-mark");
1144 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1146 fo->load(flagsPath+"flag-hook-green.png");
1147 fo->setGroup("standard-hook");
1148 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1150 fo->load(flagsPath+"flag-cross-red.png");
1151 fo->setGroup("standard-hook");
1152 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1155 fo->load(flagsPath+"flag-stopsign.png");
1156 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1158 fo->load(flagsPath+"flag-smiley-good.png");
1159 fo->setGroup("standard-smiley");
1160 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1162 fo->load(flagsPath+"flag-smiley-sad.png");
1163 fo->setGroup("standard-smiley");
1164 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1166 fo->load(flagsPath+"flag-smiley-omg.png");
1167 fo->setGroup("standard-smiley");
1168 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1169 // Original omg.png (in KDE emoticons)
1172 fo->load(flagsPath+"flag-kalarm.png");
1173 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1175 fo->load(flagsPath+"flag-phone.png");
1176 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1178 fo->load(flagsPath+"flag-lamp.png");
1179 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1181 fo->load(flagsPath+"flag-arrow-up.png");
1182 fo->setGroup("standard-arrow");
1183 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1185 fo->load(flagsPath+"flag-arrow-down.png");
1186 fo->setGroup("standard-arrow");
1187 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1189 fo->load(flagsPath+"flag-arrow-2up.png");
1190 fo->setGroup("standard-arrow");
1191 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1193 fo->load(flagsPath+"flag-arrow-2down.png");
1194 fo->setGroup("standard-arrow");
1195 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1198 fo->load(flagsPath+"flag-thumb-up.png");
1199 fo->setGroup("standard-thumb");
1200 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1202 fo->load(flagsPath+"flag-thumb-down.png");
1203 fo->setGroup("standard-thumb");
1204 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1207 fo->load(flagsPath+"flag-rose.png");
1208 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1210 fo->load(flagsPath+"flag-heart.png");
1211 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1213 fo->load(flagsPath+"flag-present.png");
1214 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1216 fo->load(flagsPath+"flag-flash.png");
1217 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1219 // Original: xsldbg_output.png
1220 fo->load(flagsPath+"flag-info.png");
1221 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1223 // Original khelpcenter.png
1224 fo->load(flagsPath+"flag-lifebelt.png");
1225 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1231 fo->load(flagsPath+"freemind/warning.png");
1232 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1234 for (int i=1; i<8; i++)
1236 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1237 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1240 fo->load(flagsPath+"freemind/back.png");
1241 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1243 fo->load(flagsPath+"freemind/forward.png");
1244 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1246 fo->load(flagsPath+"freemind/attach.png");
1247 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1249 fo->load(flagsPath+"freemind/clanbomber.png");
1250 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1252 fo->load(flagsPath+"freemind/desktopnew.png");
1253 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1255 fo->load(flagsPath+"freemind/flag.png");
1256 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1259 fo->load(flagsPath+"freemind/gohome.png");
1260 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1263 fo->load(flagsPath+"freemind/kaddressbook.png");
1264 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1266 fo->load(flagsPath+"freemind/knotify.png");
1267 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1269 fo->load(flagsPath+"freemind/korn.png");
1270 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1272 fo->load(flagsPath+"freemind/mail.png");
1273 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1275 fo->load(flagsPath+"freemind/password.png");
1276 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1278 fo->load(flagsPath+"freemind/pencil.png");
1279 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1281 fo->load(flagsPath+"freemind/stop.png");
1282 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1284 fo->load(flagsPath+"freemind/wizard.png");
1285 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1287 fo->load(flagsPath+"freemind/xmag.png");
1288 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1290 fo->load(flagsPath+"freemind/bell.png");
1291 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1293 fo->load(flagsPath+"freemind/bookmark.png");
1294 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1296 fo->load(flagsPath+"freemind/penguin.png");
1297 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1299 fo->load(flagsPath+"freemind/licq.png");
1300 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1305 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1308 fo->setToolTip (tooltip);
1309 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1315 fo->setAlwaysVisible(aw);
1316 a->setCheckable(true);
1317 a->setObjectName(fo->getName());
1318 a->setToolTip(tooltip);
1319 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1320 standardFlagsDefault->addFlag (fo);
1324 systemFlagsDefault->addFlag (fo);
1328 void Main::setupNetworkActions()
1330 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1332 QMenu *netMenu = menuBar()->addMenu( "&Network" );
1336 a = new QAction( "Start TCPserver for MapEditor",this);
1337 //a->setStatusTip ( "Set application to open pdf files"));
1338 a->setShortcut ( Qt::Key_T ); //New TCP server
1339 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1340 netMenu->addAction (a);
1342 a = new QAction( "Connect MapEditor to server",this);
1343 //a->setStatusTip ( "Set application to open pdf files"));
1344 a->setShortcut ( Qt::Key_C ); // Connect to server
1345 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1346 netMenu->addAction (a);
1350 void Main::setupSettingsActions()
1352 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1356 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1357 a->setStatusTip ( tr( "Set application to open pdf files"));
1358 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1359 settingsMenu->addAction (a);
1361 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1362 a->setStatusTip( tr( "Set application to open external links"));
1363 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1364 settingsMenu->addAction (a);
1366 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1367 a->setStatusTip( tr( "Set path for macros"));
1368 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1369 settingsMenu->addAction (a);
1371 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1372 a->setStatusTip( tr( "Set number of undo levels"));
1373 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1374 settingsMenu->addAction (a);
1376 settingsMenu->addSeparator();
1378 a = new QAction( tr( "Autosave","Settings action"), this);
1379 a->setStatusTip( tr( "Autosave"));
1380 a->setToggleAction(true);
1381 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1382 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1383 settingsMenu->addAction (a);
1384 actionSettingsAutosaveToggle=a;
1386 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1387 a->setStatusTip( tr( "Autosave time"));
1388 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1389 settingsMenu->addAction (a);
1390 actionSettingsAutosaveTime=a;
1392 settingsMenu->addSeparator();
1394 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1395 a->setStatusTip( tr( "Edit branch after adding it" ));
1396 a->setToggleAction(true);
1397 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1398 settingsMenu->addAction (a);
1399 actionSettingsAutoEditNewBranch=a;
1401 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1402 a->setStatusTip( tr( "Select branch after adding it" ));
1403 a->setToggleAction(true);
1404 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1405 settingsMenu->addAction (a);
1406 actionSettingsAutoSelectNewBranch=a;
1408 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1409 a->setStatusTip( tr( "Select heading before editing" ));
1410 a->setToggleAction(true);
1411 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1412 settingsMenu->addAction (a);
1413 actionSettingsAutoSelectText=a;
1415 a= new QAction( tr( "Delete key","Settings action" ), this);
1416 a->setStatusTip( tr( "Delete key for deleting branches" ));
1417 a->setToggleAction(true);
1418 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1419 settingsMenu->addAction (a);
1420 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1421 actionSettingsUseDelKey=a;
1423 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1424 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1425 a->setToggleAction(true);
1426 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1427 settingsMenu->addAction (a);
1428 actionSettingsUseFlagGroups=a;
1430 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1431 a->setStatusTip( tr( "Use hide flag during exports " ));
1432 a->setToggleAction(true);
1433 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1434 settingsMenu->addAction (a);
1435 actionSettingsUseHideExport=a;
1439 void Main::setupTestActions()
1441 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1444 a = new QAction( "Test function 1" , this);
1445 a->setStatusTip( "Call test function 1" );
1446 testMenu->addAction (a);
1447 //a->setShortcut (Qt::Key_F4 );
1448 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1450 a = new QAction( "Test function 2" , this);
1451 a->setStatusTip( "Call test function 2" );
1452 //a->setShortcut (Qt::Key_F4 );
1453 testMenu->addAction (a);
1454 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1456 a = new QAction( "Command" , this);
1457 a->setStatusTip( "Enter command to call in editor" );
1458 //a->setShortcut (Qt::Key_F5 );
1459 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1460 testMenu->addAction (a);
1464 void Main::setupHelpActions()
1466 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1469 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1470 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1471 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1472 helpMenu->addAction (a);
1474 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1475 a->setStatusTip( tr( "Open VYM example maps " ));
1476 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1477 helpMenu->addAction (a);
1479 a = new QAction( tr( "About VYM","Help action" ), this);
1480 a->setStatusTip( tr( "About VYM")+vymName);
1481 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1482 helpMenu->addAction (a);
1484 a = new QAction( tr( "About QT","Help action" ), this);
1485 a->setStatusTip( tr( "Information about QT toolkit" ));
1486 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1487 helpMenu->addAction (a);
1491 void Main::setupContextMenus()
1495 // Context Menu for branch or mapcenter
1496 branchContextMenu =new QMenu (this);
1497 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1498 branchContextMenu->addSeparator();
1501 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1502 branchAddContextMenu->addAction (actionEditPaste );
1503 branchAddContextMenu->addAction ( actionEditAddBranch );
1504 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1505 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1506 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1507 branchAddContextMenu->addSeparator();
1508 branchAddContextMenu->addAction ( actionEditImportAdd );
1509 branchAddContextMenu->addAction ( actionEditImportReplace );
1512 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1513 branchRemoveContextMenu->addAction (actionEditCut);
1514 branchRemoveContextMenu->addAction ( actionEditDelete );
1515 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1516 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1519 actionEditSaveBranch->addTo( branchContextMenu );
1521 branchContextMenu->addSeparator();
1522 branchContextMenu->addAction ( actionEditLoadImage);
1524 // Submenu for Links (URLs, vymLinks)
1525 branchLinksContextMenu =new QMenu (this);
1527 branchContextMenu->addSeparator();
1528 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1529 branchLinksContextMenu->addAction ( actionEditOpenURL );
1530 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1531 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1532 branchLinksContextMenu->addAction ( actionEditURL );
1533 branchLinksContextMenu->addAction ( actionEditLocalURL );
1534 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1535 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1536 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1538 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1540 branchLinksContextMenu->addSeparator();
1541 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1542 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1543 branchLinksContextMenu->addAction ( actionEditVymLink );
1544 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1547 // Context Menu for XLinks in a branch menu
1548 // This will be populated "on demand" in MapEditor::updateActions
1549 branchContextMenu->addSeparator();
1550 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1551 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1552 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1553 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1556 // Context menu for floatimage
1557 floatimageContextMenu =new QMenu (this);
1558 a= new QAction (tr ("Save image","Context action"),this);
1559 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1560 floatimageContextMenu->addAction (a);
1562 floatimageContextMenu->addSeparator();
1563 actionEditCopy->addTo( floatimageContextMenu );
1564 actionEditCut->addTo( floatimageContextMenu );
1566 floatimageContextMenu->addSeparator();
1567 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1570 // Context menu for canvas
1571 canvasContextMenu =new QMenu (this);
1572 actionEditMapInfo->addTo( canvasContextMenu );
1573 canvasContextMenu->insertSeparator();
1574 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1575 canvasContextMenu->insertSeparator();
1576 actionFormatLinkColorHint->addTo( canvasContextMenu );
1577 actionFormatLinkColor->addTo( canvasContextMenu );
1578 actionFormatSelectionColor->addTo( canvasContextMenu );
1579 actionFormatBackColor->addTo( canvasContextMenu );
1580 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1582 // Menu for last opened files
1584 for (int i = 0; i < MaxRecentFiles; ++i)
1586 recentFileActions[i] = new QAction(this);
1587 recentFileActions[i]->setVisible(false);
1588 fileLastMapsMenu->addAction(recentFileActions[i]);
1589 connect(recentFileActions[i], SIGNAL(triggered()),
1590 this, SLOT(fileLoadRecent()));
1592 setupRecentMapsMenu();
1595 void Main::setupRecentMapsMenu()
1597 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1599 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1601 for (int i = 0; i < numRecentFiles; ++i) {
1602 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1603 recentFileActions[i]->setText(text);
1604 recentFileActions[i]->setData(files[i]);
1605 recentFileActions[i]->setVisible(true);
1607 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1608 recentFileActions[j]->setVisible(false);
1611 void Main::setupMacros()
1613 for (int i = 0; i <= 11; i++)
1615 macroActions[i] = new QAction(this);
1616 macroActions[i]->setData(i);
1617 addAction (macroActions[i]);
1618 connect(macroActions[i], SIGNAL(triggered()),
1619 this, SLOT(callMacro()));
1621 macroActions[0]->setShortcut ( Qt::Key_F1 );
1622 macroActions[1]->setShortcut ( Qt::Key_F2 );
1623 macroActions[2]->setShortcut ( Qt::Key_F3 );
1624 macroActions[3]->setShortcut ( Qt::Key_F4 );
1625 macroActions[4]->setShortcut ( Qt::Key_F5 );
1626 macroActions[5]->setShortcut ( Qt::Key_F6 );
1627 macroActions[6]->setShortcut ( Qt::Key_F7 );
1628 macroActions[7]->setShortcut ( Qt::Key_F8 );
1629 macroActions[8]->setShortcut ( Qt::Key_F9 );
1630 macroActions[9]->setShortcut ( Qt::Key_F10 );
1631 macroActions[10]->setShortcut ( Qt::Key_F11 );
1632 macroActions[11]->setShortcut ( Qt::Key_F12 );
1635 void Main::hideEvent (QHideEvent * )
1637 if (!textEditor->isMinimized() ) textEditor->hide();
1640 void Main::showEvent (QShowEvent * )
1642 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1646 MapEditor* Main::currentMapEditor() const
1648 if ( tabWidget->currentPage() &&
1649 tabWidget->currentPage()->inherits( "MapEditor" ) )
1650 return (MapEditor*)tabWidget->currentPage();
1655 void Main::editorChanged(QWidget *)
1657 // Unselect all possibly selected objects
1658 // (Important to update note editor)
1660 for (int i=0;i<=tabWidget->count() -1;i++)
1663 me=(MapEditor*)tabWidget->page(i);
1666 currentMapEditor()->reselect();
1668 // Update actions to in menus and toolbars according to editor
1672 void Main::fileNew()
1674 QString fn="unnamed";
1675 MapEditor* me = new MapEditor ( NULL);
1676 tabWidget->addTab (me,fn);
1677 tabWidget->showPage(me);
1678 me->viewport()->setFocus();
1679 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1680 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1682 // For the very first map we do not have flagrows yet...
1686 void Main::fileNewCopy()
1688 QString fn="unnamed";
1689 MapEditor* oldME =currentMapEditor();
1693 MapEditor* newME = new MapEditor ( NULL);
1696 tabWidget->addTab (newME,fn);
1697 tabWidget->showPage(newME);
1698 newME->viewport()->setFocus();
1699 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1700 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1701 // For the very first map we do not have flagrows yet...
1702 newME->select("mc:");
1703 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1709 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1711 ErrorCode err=success;
1713 // fn is usually the archive, mapfile the file after uncompressing
1716 // Make fn absolute (needed for unzip)
1717 fn=QDir (fn).absPath();
1723 // Check, if map is already loaded
1725 while (i<=tabWidget->count() -1)
1727 me=(MapEditor*)tabWidget->page(i);
1728 if (me->getFilePath() == fn)
1730 // Already there, ask for confirmation
1731 QMessageBox mb( vymName,
1732 tr("The map %1\nis already opened."
1733 "Opening the same map in multiple editors may lead \n"
1734 "to confusion when finishing working with vym."
1735 "Do you want to").arg(fn),
1736 QMessageBox::Warning,
1737 QMessageBox::Yes | QMessageBox::Default,
1738 QMessageBox::Cancel | QMessageBox::Escape,
1739 QMessageBox::NoButton);
1740 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1741 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1744 case QMessageBox::Yes:
1746 i=tabWidget->count();
1748 case QMessageBox::Cancel:
1760 if ( !fn.isEmpty() )
1762 me = currentMapEditor();
1763 int tabIndex=tabWidget->currentPageIndex();
1764 // Check first, if mapeditor exists
1765 // If it is not default AND we want a new map,
1766 // create a new mapeditor in a new tab
1767 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1769 me= new MapEditor ( NULL);
1770 tabWidget->addTab (me,fn);
1771 tabIndex=tabWidget->indexOf (me);
1772 tabWidget->setCurrentPage (tabIndex);
1773 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1774 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1777 // Check, if file exists (important for creating new files
1778 // from command line
1779 if (!QFile(fn).exists() )
1781 QMessageBox mb( vymName,
1782 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1783 QMessageBox::Question,
1785 QMessageBox::Cancel | QMessageBox::Default,
1786 QMessageBox::NoButton );
1788 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1789 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1792 case QMessageBox::Yes:
1794 currentMapEditor()->setFilePath(fn);
1795 tabWidget->setTabLabel (currentMapEditor(),
1796 currentMapEditor()->getFileName() );
1797 statusBar()->message( "Created " + fn , statusbarTime );
1800 case QMessageBox::Cancel:
1801 // don't create new map
1802 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1809 //tabWidget->currentPage() won't be NULL here, because of above...
1810 tabWidget->showPage(me);
1811 me->viewport()->setFocus();
1813 // Create temporary directory for packing
1815 QString tmpMapDir=makeTmpDir (ok,"vym-pack");
1818 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1819 tr("Couldn't create temporary directory before load\n"));
1823 // Try to unzip file
1824 err=unzipDir (tmpMapDir,fn);
1828 me->setZipped(false);
1831 me->setZipped(true);
1833 // Look for mapname.xml
1834 mapfile= fn.left(fn.findRev(".",-1,true));
1835 mapfile=mapfile.section( '/', -1 );
1836 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1837 if (!file.exists() )
1839 // mapname.xml does not exist, well,
1840 // maybe someone renamed the mapname.vym file...
1841 // Try to find any .xml in the toplevel
1842 // directory of the .vym file
1843 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1844 if (flist.count()==1)
1846 // Only one entry, take this one
1847 mapfile=tmpMapDir + "/"+flist.first();
1850 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1851 *it=tmpMapDir + "/" + *it;
1852 // TODO Multiple entries, load all (but only the first one into this ME)
1853 //mainWindow->fileLoadFromTmp (flist);
1854 //returnCode=1; // Silently forget this attempt to load
1855 qWarning ("MainWindow::load (fn) multimap found...");
1858 if (flist.isEmpty() )
1860 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1861 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1864 } //file doesn't exist
1866 mapfile=file.name();
1871 // Save existing filename in case we import
1872 QString fn_org=me->getFilePath();
1874 // Finally load map into mapEditor
1875 me->setFilePath (mapfile,fn);
1876 err=me->load(mapfile,lmode,ftype);
1878 // Restore old (maybe empty) filepath, if this is an import
1880 me->setFilePath (fn_org);
1883 // Finally check for errors and go home
1886 if (lmode==NewMap) fileCloseMap();
1887 statusBar()->message( "Could not load " + fn, statusbarTime );
1892 me->setFilePath (fn);
1893 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1894 if (!isInTmpDir (fn))
1896 // Only append to lastMaps if not loaded from a tmpDir
1897 // e.g. imported bookmarks are in a tmpDir
1898 addRecentMap(me->getFilePath() );
1900 actionFilePrint->setEnabled (true);
1902 statusBar()->message( "Loaded " + fn, statusbarTime );
1906 removeDir (QDir(tmpMapDir));
1912 void Main::fileLoad(const LoadMode &lmode)
1914 QStringList filters;
1915 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1916 QFileDialog *fd=new QFileDialog( this);
1917 fd->setDir (lastFileDir);
1918 fd->setFileMode (QFileDialog::ExistingFiles);
1919 fd->setFilters (filters);
1923 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1926 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1929 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1935 if ( fd->exec() == QDialog::Accepted )
1937 lastFileDir=fd->directory().path();
1938 QStringList flist = fd->selectedFiles();
1939 QStringList::Iterator it = flist.begin();
1940 while( it != flist.end() )
1943 fileLoad(*it, lmode);
1950 void Main::fileLoad()
1955 void Main::fileLoadRecent()
1957 QAction *action = qobject_cast<QAction *>(sender());
1959 fileLoad (action->data().toString(), NewMap);
1962 void Main::addRecentMap (const QString &fileName)
1965 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1966 files.removeAll(fileName);
1967 files.prepend(fileName);
1968 while (files.size() > MaxRecentFiles)
1971 settings.setValue("/mainwindow/recentFileList", files);
1973 setupRecentMapsMenu();
1976 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1978 // tmp dir for zipping
1982 ErrorCode err=success;
1984 QString safeFilePath;
1986 bool saveZipped=me->saveZipped();
1990 QString fn=me->getFilePath();
1991 // filename=unnamed, filepath="" in constructor of mapEditor
1992 if ( !fn.isEmpty() )
1994 // We have a filepath, go on saving
1995 // First remove existing file, we
1996 // don't want to add to old zip archives
2000 QMessageBox::warning( 0, tr( "Save Error" ),
2001 fn+ tr("\ncould not be removed before saving"));
2003 // Look, if we should zip the data:
2006 QMessageBox mb( vymName,
2007 tr("The map %1\ndid not use the compressed "
2008 "vym file format.\nWriting it uncompressed will also write images \n"
2009 "and flags and thus may overwrite files in the "
2010 "given directory\n\nDo you want to write the map").arg(fn),
2011 QMessageBox::Warning,
2012 QMessageBox::Yes | QMessageBox::Default,
2014 QMessageBox::Cancel | QMessageBox::Escape);
2015 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2016 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2017 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2020 case QMessageBox::Yes:
2021 // save compressed (default file format)
2024 case QMessageBox::No:
2025 // save uncompressed
2028 case QMessageBox::Cancel:
2037 // Create temporary directory for packing
2039 QString tmpMapDir=makeTmpDir (ok,"vym-zip");
2042 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2043 tr("Couldn't create temporary directory before save\n"));
2047 safeFilePath=me->getFilePath();
2048 me->setFilePath (tmpMapDir+"/"+
2049 me->getMapName()+ ".xml",
2051 me->save (savemode);
2052 me->setFilePath (safeFilePath);
2054 zipDir (tmpMapDir,fn);
2059 safeFilePath=me->getFilePath();
2060 me->setFilePath (fn, safeFilePath);
2061 me->save (savemode);
2062 me->setFilePath (safeFilePath);
2064 } // filepath available
2067 // We have no filepath yet,
2068 // call fileSaveAs() now, this will call fileSave()
2070 // First switch to editor
2071 tabWidget->setCurrentWidget (me);
2072 fileSaveAs(savemode);
2076 if (saveZipped && !tmpMapDir.isEmpty())
2078 removeDir (QDir(tmpMapDir));
2082 statusBar()->message(
2083 tr("Saved %1").arg(me->getFilePath()),
2085 addRecentMap (me->getFilePath() );
2087 statusBar()->message(
2088 tr("Couldn't save ").arg(me->getFilePath()),
2092 void Main::fileSave()
2094 fileSave (currentMapEditor(), CompleteMap);
2097 void Main::fileSave(MapEditor *me)
2099 fileSave (me,CompleteMap);
2102 void Main::fileSaveAs(const SaveMode& savemode)
2106 if (currentMapEditor())
2108 if (savemode==CompleteMap)
2109 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2111 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2112 if ( !fn.isEmpty() )
2114 // Check for existing file
2115 if (QFile (fn).exists())
2117 QMessageBox mb( vymName,
2118 tr("The file %1\nexists already. Do you want to").arg(fn),
2119 QMessageBox::Warning,
2120 QMessageBox::Yes | QMessageBox::Default,
2121 QMessageBox::Cancel | QMessageBox::Escape,
2122 QMessageBox::NoButton);
2123 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2124 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2127 case QMessageBox::Yes:
2130 case QMessageBox::Cancel:
2137 // New file, add extension to filename, if missing
2138 // This is always .vym or .vyp, depending on savemode
2139 if (savemode==CompleteMap)
2141 if (!fn.contains (".vym") && !fn.contains (".xml"))
2145 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2154 currentMapEditor()->setFilePath(fn);
2155 fileSave(currentMapEditor(), savemode);
2158 if (savemode==CompleteMap)
2159 tabWidget->setTabLabel (currentMapEditor(),
2160 currentMapEditor()->getFileName() );
2166 void Main::fileSaveAs()
2168 fileSaveAs (CompleteMap);
2171 void Main::fileImportKDEBookmarks()
2173 ImportKDEBookmarks im;
2175 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2176 currentMapEditor()->setFilePath ("");
2179 void Main::fileImportFirefoxBookmarks()
2181 Q3FileDialog *fd=new Q3FileDialog( this);
2182 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2183 fd->setMode (Q3FileDialog::ExistingFiles);
2184 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2185 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2188 if ( fd->exec() == QDialog::Accepted )
2190 ImportFirefoxBookmarks im;
2191 QStringList flist = fd->selectedFiles();
2192 QStringList::Iterator it = flist.begin();
2193 while( it != flist.end() )
2196 if (im.transform() &&
2197 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2198 currentMapEditor() )
2199 currentMapEditor()->setFilePath ("");
2206 void Main::fileImportFreemind()
2208 QStringList filters;
2209 filters <<"Freemind map (*.mm)"<<"All files (*)";
2210 QFileDialog *fd=new QFileDialog( this);
2211 fd->setDir (lastFileDir);
2212 fd->setFileMode (QFileDialog::ExistingFiles);
2213 fd->setFilters (filters);
2214 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2218 if ( fd->exec() == QDialog::Accepted )
2220 lastFileDir=fd->directory().path();
2221 QStringList flist = fd->selectedFiles();
2222 QStringList::Iterator it = flist.begin();
2223 while( it != flist.end() )
2226 if ( fileLoad (fn,NewMap, FreemindMap) )
2228 currentMapEditor()->setFilePath ("");
2237 void Main::fileImportMM()
2241 Q3FileDialog *fd=new Q3FileDialog( this);
2242 fd->setDir (lastFileDir);
2243 fd->setMode (Q3FileDialog::ExistingFiles);
2244 fd->addFilter ("Mind Manager (*.mmap)");
2245 fd->setCaption(tr("Import")+" "+"Mind Manager");
2248 if ( fd->exec() == QDialog::Accepted )
2250 lastFileDir=fd->dirPath();
2251 QStringList flist = fd->selectedFiles();
2252 QStringList::Iterator it = flist.begin();
2253 while( it != flist.end() )
2256 if (im.transform() &&
2257 success==fileLoad (im.getTransformedFile(),NewMap) &&
2258 currentMapEditor() )
2259 currentMapEditor()->setFilePath ("");
2268 void Main::fileImportDir()
2270 if (currentMapEditor())
2271 currentMapEditor()->importDir();
2274 void Main::fileExportXML()
2276 MapEditor *me=currentMapEditor();
2277 if (me) me->exportXML();
2281 void Main::fileExportXHTML()
2283 MapEditor *me=currentMapEditor();
2284 if (me) me->exportXHTML();
2287 void Main::fileExportImage()
2289 MapEditor *me=currentMapEditor();
2290 if (me) me->exportImage();
2293 void Main::fileExportASCII()
2295 MapEditor *me=currentMapEditor();
2296 if (me) me->exportASCII();
2299 void Main::fileExportCSV() //FIXME not scriptable yet
2301 MapEditor *me=currentMapEditor();
2305 ex.setMapCenter(me->getMapCenter());
2306 ex.addFilter ("CSV (*.csv)");
2307 ex.setDir(lastImageDir);
2308 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2309 if (ex.execDialog() )
2311 me->setExportMode(true);
2313 me->setExportMode(false);
2318 void Main::fileExportLaTeX() //FIXME not scriptable yet
2320 MapEditor *me=currentMapEditor();
2324 ex.setMapCenter(me->getMapCenter());
2325 ex.addFilter ("Tex (*.tex)");
2326 ex.setDir(lastImageDir);
2327 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2328 if (ex.execDialog() )
2330 me->setExportMode(true);
2332 me->setExportMode(false);
2337 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2339 ExportKDEBookmarks ex;
2340 MapEditor *me=currentMapEditor();
2343 ex.setMapCenter (me->getMapCenter() );
2348 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2350 ExportTaskjuggler ex;
2351 MapEditor *me=currentMapEditor();
2354 ex.setMapCenter (me->getMapCenter() );
2355 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2356 ex.setDir(lastImageDir);
2357 ex.addFilter ("Taskjuggler (*.tjp)");
2358 if (ex.execDialog() )
2360 me->setExportMode(true);
2362 me->setExportMode(false);
2367 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2369 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2370 // TODO add preview in dialog
2371 //ImagePreview *p =new ImagePreview (fd);
2372 //fd->setContentsPreviewEnabled( TRUE );
2373 //fd->setContentsPreview( p, p );
2374 //fd->setPreviewMode( QFileDialog::Contents );
2375 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2376 fd->setDir (QDir().current());
2377 if (fd->foundConfig())
2381 if ( fd->exec() == QDialog::Accepted )
2383 QString fn=fd->selectedFile();
2384 if (!fn.contains (".odp"))
2387 //lastImageDir=fn.left(fn.findRev ("/"));
2388 if (currentMapEditor())
2389 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2393 QMessageBox::warning(0,
2395 tr("Couldn't find configuration for export to Open Office\n"));
2399 void Main::fileCloseMap()
2401 if (currentMapEditor())
2403 if (currentMapEditor()->hasChanged())
2405 QMessageBox mb( vymName,
2406 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2407 QMessageBox::Warning,
2408 QMessageBox::Yes | QMessageBox::Default,
2410 QMessageBox::Cancel | QMessageBox::Escape );
2411 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2412 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2415 case QMessageBox::Yes:
2417 fileSave(currentMapEditor(), CompleteMap);
2419 case QMessageBox::No:
2420 // close without saving
2422 case QMessageBox::Cancel:
2427 currentMapEditor()->closeMap();
2428 tabWidget->removePage(currentMapEditor());
2429 if (tabWidget->count()==0)
2430 actionFilePrint->setEnabled (false);
2434 void Main::filePrint()
2436 if (currentMapEditor())
2437 currentMapEditor()->print();
2440 void Main::fileExitVYM()
2442 // Check if one or more editors have changed
2445 for (i=0;i<=tabWidget->count() -1;i++)
2448 me=(MapEditor*)tabWidget->page(i);
2450 // If something changed, ask what to do
2451 if (me->hasChanged())
2453 tabWidget->setCurrentPage(i);
2454 QMessageBox mb( vymName,
2455 tr("This map is not saved yet. Do you want to"),
2456 QMessageBox::Warning,
2457 QMessageBox::Yes | QMessageBox::Default,
2459 QMessageBox::Cancel | QMessageBox::Escape );
2460 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2461 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2464 mb.setActiveWindow();
2465 switch( mb.exec() ) {
2466 case QMessageBox::Yes:
2467 // save (the changed editors) and exit
2468 fileSave(currentMapEditor(), CompleteMap);
2470 case QMessageBox::No:
2471 // exit without saving
2473 case QMessageBox::Cancel:
2474 // don't save and don't exit
2478 } // loop over all MEs
2482 void Main::editUndo()
2484 if (currentMapEditor())
2485 currentMapEditor()->undo();
2488 void Main::editRedo()
2490 if (currentMapEditor())
2491 currentMapEditor()->redo();
2494 void Main::gotoHistoryStep (int i)
2496 if (currentMapEditor())
2497 currentMapEditor()->gotoHistoryStep (i);
2500 void Main::editCopy()
2502 if (currentMapEditor())
2503 currentMapEditor()->copy();
2506 void Main::editPaste()
2508 if (currentMapEditor())
2509 currentMapEditor()->paste();
2512 void Main::editCut()
2514 if (currentMapEditor())
2515 currentMapEditor()->cut();
2518 void Main::editOpenFindWindow()
2520 findWindow->popup();
2521 findWindow->raise();
2522 findWindow->setActiveWindow();
2525 void Main::editFind(QString s)
2528 BranchObj *bo=currentMapEditor()->findText(s, cs);
2531 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2534 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2535 tr("No matches found for \"%1\"").arg(s));
2539 void Main::editFindChanged()
2540 { // Notify editor, to abort the current find process
2541 currentMapEditor()->findReset();
2544 void Main::openTabs(QStringList urls)
2546 if (!urls.isEmpty())
2550 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2552 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2554 QString u=urls.takeFirst();
2555 procBrowser = new QProcess( this );
2557 procBrowser->start(browser,args);
2558 if ( !procBrowser->waitForStarted())
2560 // try to set path to browser
2561 QMessageBox::warning(0,
2563 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2564 tr("Please use Settings->")+tr("Set application to open an URL"));
2567 #if defined(Q_OS_WIN32)
2568 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2569 this->thread()->wait(3000);
2574 if (browser.contains("konqueror"))
2576 for (int i=0; i<urls.size(); i++)
2579 // Try to open new tab in existing konqueror started previously by vym
2580 p=new QProcess (this);
2582 #if defined(Q_OS_WIN32)
2583 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2584 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2585 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2586 "konqueror-mainwindow#1"<<
2590 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2591 "konqueror-mainwindow#1"<<
2595 p->start ("dcop",args);
2596 cout << args.join(" ").ascii()<<endl;
2597 if ( !p->waitForStarted() ) success=false;
2600 QMessageBox::warning(0,
2602 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2604 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2606 for (int i=0; i<urls.size(); i++)
2608 // Try to open new tab in firefox
2609 p=new QProcess (this);
2610 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2611 p->start (browser,args);
2612 if ( !p->waitForStarted() ) success=false;
2615 QMessageBox::warning(0,
2617 tr("Couldn't start %1 to open a new tab").arg(browser));
2620 QMessageBox::warning(0,
2622 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2626 void Main::editOpenURL()
2629 if (currentMapEditor())
2631 QString url=currentMapEditor()->getURL();
2633 if (url=="") return;
2634 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2635 procBrowser = new QProcess( this );
2637 procBrowser->start(browser,args);
2638 if ( !procBrowser->waitForStarted())
2640 // try to set path to browser
2641 QMessageBox::warning(0,
2643 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2644 tr("Please use Settings->")+tr("Set application to open an URL"));
2649 void Main::editOpenURLTab()
2651 if (currentMapEditor())
2654 urls.append(currentMapEditor()->getURL());
2658 void Main::editOpenMultipleURLTabs()
2660 if (currentMapEditor())
2663 urls=currentMapEditor()->getURLs();
2669 void Main::editURL()
2671 if (currentMapEditor())
2672 currentMapEditor()->editURL();
2675 void Main::editLocalURL()
2677 if (currentMapEditor())
2678 currentMapEditor()->editLocalURL();
2681 void Main::editHeading2URL()
2683 if (currentMapEditor())
2684 currentMapEditor()->editHeading2URL();
2687 void Main::editBugzilla2URL()
2689 if (currentMapEditor())
2690 currentMapEditor()->editBugzilla2URL();
2693 void Main::editFATE2URL()
2695 if (currentMapEditor())
2696 currentMapEditor()->editFATE2URL();
2699 void Main::editHeadingFinished()
2701 // only called from editHeading(), so there is a currentME
2702 MapEditor *me=currentMapEditor();
2705 me->setStateEditHeading (false);
2706 QPoint p; //Not used here, only to find out pos of branch
2708 QString s=me->getHeading(ok,p);
2710 #if defined(Q_OS_MACX)
2712 if (ok && s!=lineedit->text())
2713 me->setHeading(lineedit->text());
2715 lineedit->releaseKeyboard();
2719 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2720 !prevSelection.isEmpty())
2721 me->select(prevSelection);
2726 void Main::editHeading()
2728 if (currentMapEditor())
2730 MapEditor *me=currentMapEditor();
2731 QString oldSel=me->getSelectString();
2733 if (lineedit->isVisible())
2734 editHeadingFinished();
2739 QString s=me->getHeading(ok,p);
2743 me->setStateEditHeading (true);
2744 #if defined(Q_OS_MACX)
2745 p=me->mapToGlobal (p);
2746 QDialog *d =new QDialog(NULL);
2747 QLineEdit *le=new QLineEdit (d);
2748 d->setWindowFlags (Qt::FramelessWindowHint);
2749 d->setGeometry(p.x(),p.y(),230,25);
2750 le->resize (d->width()-10,d->height());
2753 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2754 d->activateWindow();
2756 me->setHeading (le->text());
2759 editHeadingFinished();
2761 p=me->mapTo (this,p);
2762 lineedit->setGeometry(p.x(),p.y(),230,25);
2763 lineedit->setText(s);
2764 lineedit->setCursorPosition(1);
2765 lineedit->selectAll();
2767 lineedit->grabKeyboard();
2768 lineedit->setFocus();
2772 } // currentMapEditor()
2775 void Main::openVymLinks(const QStringList &vl)
2777 for (int j=0; j<vl.size(); j++)
2779 // compare path with already loaded maps
2783 for (i=0;i<=tabWidget->count() -1;i++)
2785 me=(MapEditor*)tabWidget->page(i);
2786 if (vl.at(j)==me->getFilePath() )
2795 if (!QFile(vl.at(j)).exists() )
2796 QMessageBox::critical( 0, tr( "Critical Error" ),
2797 tr("Couldn't open map %1").arg(vl.at(j)));
2800 fileLoad (vl.at(j), NewMap);
2801 tabWidget->setCurrentPage (tabWidget->count()-1);
2804 // Go to tab containing the map
2805 tabWidget->setCurrentPage (index);
2809 void Main::editOpenVymLink()
2811 if (currentMapEditor())
2814 vl.append(currentMapEditor()->getVymLink());
2819 void Main::editOpenMultipleVymLinks()
2821 QString currentVymLink;
2822 if (currentMapEditor())
2824 QStringList vl=currentMapEditor()->getVymLinks();
2829 void Main::editVymLink()
2831 if (currentMapEditor())
2832 currentMapEditor()->editVymLink();
2835 void Main::editDeleteVymLink()
2837 if (currentMapEditor())
2838 currentMapEditor()->deleteVymLink();
2841 void Main::editToggleHideExport()
2843 if (currentMapEditor())
2844 currentMapEditor()->toggleHideExport();
2847 void Main::editMapInfo()
2849 if (currentMapEditor())
2850 currentMapEditor()->editMapInfo();
2853 void Main::editMoveUp()
2855 if (currentMapEditor())
2856 currentMapEditor()->moveBranchUp();
2859 void Main::editMoveDown()
2861 if (currentMapEditor())
2862 currentMapEditor()->moveBranchDown();
2865 void Main::editSortChildren()
2867 if (currentMapEditor())
2868 currentMapEditor()->sortChildren();
2871 void Main::editToggleScroll()
2873 if (currentMapEditor())
2875 currentMapEditor()->toggleScroll();
2879 void Main::editUnscrollChilds()
2881 if (currentMapEditor())
2882 currentMapEditor()->unscrollChilds();
2885 void Main::editNewBranch()
2887 MapEditor *me=currentMapEditor();
2888 if (!lineedit->isVisible() && me)
2890 BranchObj *bo=(BranchObj*)me->getSelection();
2891 BranchObj *newbo=me->addNewBranch(0);
2893 prevSelection=bo->getSelectString();
2895 me->select (newbo->getSelectString());
2899 if (actionSettingsAutoEditNewBranch->isOn())
2904 if (!prevSelection.isEmpty())
2906 me->select(prevSelection);
2913 void Main::editNewBranchBefore()
2915 MapEditor *me=currentMapEditor();
2916 if (!lineedit->isVisible() && me)
2918 BranchObj *bo=(BranchObj*)me->getSelection();
2919 BranchObj *newbo=me->addNewBranchBefore();
2922 me->select (newbo->getSelectString());
2926 if (actionSettingsAutoEditNewBranch->isOn())
2928 if (!actionSettingsAutoSelectNewBranch->isOn())
2929 prevSelection=bo->getSelectString();
2935 void Main::editNewBranchAbove()
2937 MapEditor *me=currentMapEditor();
2938 if (!lineedit->isVisible() && me)
2940 BranchObj *bo=(BranchObj*)me->getSelection();
2941 BranchObj *newbo=me->addNewBranch (-1);
2944 me->select (newbo->getSelectString());
2948 if (actionSettingsAutoEditNewBranch->isOn())
2950 if (!actionSettingsAutoSelectNewBranch->isOn())
2951 prevSelection=bo->getSelectString();
2957 void Main::editNewBranchBelow()
2959 MapEditor *me=currentMapEditor();
2960 if (!lineedit->isVisible() && me)
2962 BranchObj *bo=(BranchObj*)me->getSelection();
2963 BranchObj *newbo=me->addNewBranch (1);
2966 me->select (newbo->getSelectString());
2970 if (actionSettingsAutoEditNewBranch->isOn())
2972 if (!actionSettingsAutoSelectNewBranch->isOn())
2973 prevSelection=bo->getSelectString();
2979 void Main::editImportAdd()
2981 fileLoad (ImportAdd);
2984 void Main::editImportReplace()
2986 fileLoad (ImportReplace);
2989 void Main::editSaveBranch()
2991 fileSaveAs (PartOfMap);
2994 void Main::editDeleteKeepChilds()
2996 if (currentMapEditor())
2997 currentMapEditor()->deleteKeepChilds();
3000 void Main::editDeleteChilds()
3002 if (currentMapEditor())
3003 currentMapEditor()->deleteChilds();
3006 void Main::editDeleteSelection()
3008 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3009 currentMapEditor()->deleteSelection();
3012 void Main::editUpperBranch()
3014 if (currentMapEditor())
3015 currentMapEditor()->selectUpperBranch();
3018 void Main::editLowerBranch()
3020 if (currentMapEditor())
3021 currentMapEditor()->selectLowerBranch();
3024 void Main::editLeftBranch()
3026 if (currentMapEditor())
3027 currentMapEditor()->selectLeftBranch();
3030 void Main::editRightBranch()
3032 if (currentMapEditor())
3033 currentMapEditor()->selectRightBranch();
3036 void Main::editFirstBranch()
3038 if (currentMapEditor())
3039 currentMapEditor()->selectFirstBranch();
3042 void Main::editLastBranch()
3044 if (currentMapEditor())
3045 currentMapEditor()->selectLastBranch();
3048 void Main::editLoadImage()
3050 if (currentMapEditor())
3051 currentMapEditor()->loadFloatImage();
3054 void Main::editSaveImage()
3056 if (currentMapEditor())
3057 currentMapEditor()->saveFloatImage();
3060 void Main::editFollowXLink(QAction *a)
3063 if (currentMapEditor())
3064 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3067 void Main::editEditXLink(QAction *a)
3069 if (currentMapEditor())
3070 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3073 void Main::formatSelectColor()
3075 if (currentMapEditor())
3077 QColor col = QColorDialog::getColor((currentColor ), this );
3078 if ( !col.isValid() ) return;
3079 colorChanged( col );
3083 void Main::formatPickColor()
3085 if (currentMapEditor())
3086 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3089 void Main::colorChanged(QColor c)
3091 QPixmap pix( 16, 16 );
3093 actionFormatColor->setIconSet( pix );
3097 void Main::formatColorBranch()
3099 if (currentMapEditor())
3100 currentMapEditor()->colorBranch(currentColor);
3103 void Main::formatColorSubtree()
3105 if (currentMapEditor())
3106 currentMapEditor()->colorSubtree (currentColor);
3109 void Main::formatLinkStyleLine()
3111 if (currentMapEditor())
3112 currentMapEditor()->setMapLinkStyle("StyleLine");
3115 void Main::formatLinkStyleParabel()
3117 if (currentMapEditor())
3118 currentMapEditor()->setMapLinkStyle("StyleParabel");
3121 void Main::formatLinkStylePolyLine()
3123 if (currentMapEditor())
3124 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3127 void Main::formatLinkStylePolyParabel()
3129 if (currentMapEditor())
3130 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3133 void Main::formatSelectBackColor()
3135 if (currentMapEditor())
3136 currentMapEditor()->selectMapBackgroundColor();
3139 void Main::formatSelectBackImage()
3141 if (currentMapEditor())
3142 currentMapEditor()->selectMapBackgroundImage();
3145 void Main::formatSelectLinkColor()
3147 if (currentMapEditor())
3148 currentMapEditor()->selectMapLinkColor();
3151 void Main::formatSelectSelectionColor()
3153 if (currentMapEditor())
3154 currentMapEditor()->selectMapSelectionColor();
3157 void Main::formatToggleLinkColorHint()
3159 currentMapEditor()->toggleMapLinkColorHint();
3163 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3165 if (currentMapEditor())
3166 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3169 void Main::viewZoomReset()
3171 if (currentMapEditor())
3175 currentMapEditor()->setMatrix( m );
3179 void Main::viewZoomIn()
3181 if (currentMapEditor())
3183 QMatrix m = currentMapEditor()->matrix();
3184 m.scale( 1.25, 1.25 );
3185 currentMapEditor()->setMatrix( m );
3189 void Main::viewZoomOut()
3191 if (currentMapEditor())
3193 QMatrix m = currentMapEditor()->matrix();
3194 m.scale( 0.8, 0.8 );
3195 currentMapEditor()->setMatrix( m );
3199 void Main::viewCenter()
3201 MapEditor *me=currentMapEditor();
3204 me->ensureSelectionVisible();
3208 void Main::networkStartServer()
3210 MapEditor *me=currentMapEditor();
3211 if (me) me->newServer();
3214 void Main::networkConnect()
3216 MapEditor *me=currentMapEditor();
3217 if (me) me->connectToServer();
3220 bool Main::settingsPDF()
3222 // Default browser is set in constructor
3224 QString text = QInputDialog::getText(
3225 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3226 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3228 settings.setValue ("/mainwindow/readerPDF",text);
3233 bool Main::settingsURL()
3235 // Default browser is set in constructor
3237 QString text = QInputDialog::getText(
3238 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3239 settings.value("/mainwindow/readerURL").toString()
3242 settings.setValue ("/mainwindow/readerURL",text);
3246 void Main::settingsMacroDir()
3248 QDir defdir=vymBaseDir;
3249 defdir.cd("macros");
3250 if (!defdir.exists())
3252 QDir dir=QFileDialog::getExistingDirectory (
3254 tr ("Directory with vym macros:"),
3255 settings.value ("/macros/macroDir",defdir.path()).toString()
3258 settings.setValue ("/macros/macroDir",dir.path());
3261 void Main::settingsUndoLevels()
3264 int i = QInputDialog::getInteger(
3266 tr("QInputDialog::getInteger()"),
3267 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3270 settings.setValue ("/mapeditor/stepsTotal",i);
3271 QMessageBox::information( this, tr( "VYM -Information:" ),
3272 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3276 void Main::settingsAutosaveToggle()
3278 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3281 void Main::settingsAutosaveTime()
3284 int i = QInputDialog::getInteger(
3286 tr("QInputDialog::getInteger()"),
3287 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3290 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3294 void Main::settingsToggleDelKey()
3296 if (actionSettingsUseDelKey->isOn())
3298 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3301 actionEditDelete->setAccel (QKeySequence (""));
3305 void Main::windowToggleNoteEditor()
3307 if (textEditor->isVisible() )
3308 windowHideNoteEditor();
3310 windowShowNoteEditor();
3313 void Main::windowToggleHistory()
3315 if (historyWindow->isVisible())
3316 historyWindow->hide();
3318 historyWindow->show();
3322 void Main::windowToggleProperty()
3324 if (branchPropertyWindow->isVisible())
3325 branchPropertyWindow->hide();
3327 branchPropertyWindow->show();
3329 if(currentMapEditor())
3331 LinkableMapObj *sel=currentMapEditor()->getSelection();
3332 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3333 typeid(*sel) == typeid(MapCenterObj)))
3335 branchPropertyWindow->setMapEditor(currentMapEditor());
3336 branchPropertyWindow->setBranch((BranchObj*)sel);
3341 branchPropertyWindow->setBranch(NULL);
3344 void Main::windowToggleAntiAlias()
3346 bool b=actionViewToggleAntiAlias->isOn();
3348 for (int i=0;i<tabWidget->count();i++)
3351 me=(MapEditor*)tabWidget->page(i);
3352 me->setAntiAlias(b);
3357 void Main::windowToggleSmoothPixmap()
3359 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3361 for (int i=0;i<tabWidget->count();i++)
3364 me=(MapEditor*)tabWidget->page(i);
3365 me->setSmoothPixmap(b);
3369 void Main::updateHistory(SimpleSettings &undoSet)
3371 historyWindow->update (undoSet);
3374 void Main::updateNoteFlag()
3376 if (currentMapEditor())
3377 currentMapEditor()->updateNoteFlag();
3380 void Main::updateSatellites(MapEditor *me)
3382 branchPropertyWindow->setMapEditor (me);
3385 void Main::updateActions()
3387 MapEditor *me=currentMapEditor();
3390 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3392 // updateActions is also called when NoteEditor is closed
3393 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3394 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3395 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3397 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3398 actionFormatLinkColorHint->setOn(true);
3400 actionFormatLinkColorHint->setOn(false);
3402 switch (me->getMapLinkStyle())
3404 case LinkableMapObj::Line:
3405 actionFormatLinkStyleLine->setOn(true);
3407 case LinkableMapObj::Parabel:
3408 actionFormatLinkStyleParabel->setOn(true);
3410 case LinkableMapObj::PolyLine:
3411 actionFormatLinkStylePolyLine->setOn(true);
3413 case LinkableMapObj::PolyParabel:
3414 actionFormatLinkStylePolyParabel->setOn(true);
3421 QPixmap pix( 16, 16 );
3422 pix.fill( me->getMapBackgroundColor() );
3423 actionFormatBackColor->setIconSet( pix );
3424 pix.fill( me->getSelectionColor() );
3425 actionFormatSelectionColor->setIconSet( pix );
3426 pix.fill( me->getMapDefLinkColor() );
3427 actionFormatLinkColor->setIconSet( pix );
3430 actionFileSave->setEnabled( me->hasChanged() );
3431 if (me->isUndoAvailable())
3432 actionEditUndo->setEnabled( true);
3434 actionEditUndo->setEnabled( false);
3436 if (me->isRedoAvailable())
3437 actionEditRedo->setEnabled( true);
3439 actionEditRedo->setEnabled( false);
3441 LinkableMapObj *selection=me->getSelection();
3444 if ( (typeid(*selection) == typeid(BranchObj)) ||
3445 (typeid(*selection) == typeid(MapCenterObj)) )
3447 BranchObj *bo=(BranchObj*)selection;
3448 // Take care of links
3449 if (bo->countXLinks()==0)
3451 branchXLinksContextMenuEdit->clear();
3452 branchXLinksContextMenuFollow->clear();
3457 branchXLinksContextMenuEdit->clear();
3458 branchXLinksContextMenuFollow->clear();
3459 for (int i=0; i<=bo->countXLinks();i++)
3461 bot=bo->XLinkTargetAt(i);
3464 s=bot->getHeading();
3465 if (s.length()>xLinkMenuWidth)
3466 s=s.left(xLinkMenuWidth)+"...";
3467 branchXLinksContextMenuFollow->addAction (s);
3468 branchXLinksContextMenuEdit->addAction (s);
3473 standardFlagsDefault->setEnabled (true);
3475 actionEditToggleScroll->setEnabled (true);
3476 if ( bo->isScrolled() )
3477 actionEditToggleScroll->setOn(true);
3479 actionEditToggleScroll->setOn(false);
3481 if ( bo->getURL().isEmpty() )
3483 actionEditOpenURL->setEnabled (false);
3484 actionEditOpenURLTab->setEnabled (false);
3488 actionEditOpenURL->setEnabled (true);
3489 actionEditOpenURLTab->setEnabled (true);
3491 if ( bo->getVymLink().isEmpty() )
3493 actionEditOpenVymLink->setEnabled (false);
3494 actionEditDeleteVymLink->setEnabled (false);
3497 actionEditOpenVymLink->setEnabled (true);
3498 actionEditDeleteVymLink->setEnabled (true);
3501 if (bo->canMoveBranchUp())
3502 actionEditMoveUp->setEnabled (true);
3504 actionEditMoveUp->setEnabled (false);
3505 if (bo->canMoveBranchDown())
3506 actionEditMoveDown->setEnabled (true);
3508 actionEditMoveDown->setEnabled (false);
3511 actionEditToggleHideExport->setEnabled (true);
3512 actionEditToggleHideExport->setOn (bo->hideInExport() );
3514 actionEditCopy->setEnabled (true);
3515 actionEditCut->setEnabled (true);
3516 if (!clipboardEmpty)
3517 actionEditPaste->setEnabled (true);
3519 actionEditPaste->setEnabled (false);
3520 for (int i=0; i<actionListBranches.size(); ++i)
3521 actionListBranches.at(i)->setEnabled(true);
3522 actionEditDelete->setEnabled (true);
3523 actionFormatHideLinkUnselected->setOn
3524 (selection->getHideLinkUnselected());
3526 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3528 FloatObj *fo=(FloatImageObj*)selection;
3530 actionEditOpenURL->setEnabled (false);
3531 actionEditOpenVymLink->setEnabled (false);
3532 actionEditDeleteVymLink->setEnabled (false);
3533 actionEditToggleHideExport->setEnabled (true);
3534 actionEditToggleHideExport->setOn (fo->hideInExport() );
3537 actionEditCopy->setEnabled (true);
3538 actionEditCut->setEnabled (true);
3539 actionEditPaste->setEnabled (false);
3540 for (int i=0; i<actionListBranches.size(); ++i)
3541 actionListBranches.at(i)->setEnabled(false);
3542 actionEditDelete->setEnabled (true);
3543 actionFormatHideLinkUnselected->setOn
3544 ( selection->getHideLinkUnselected());
3545 actionEditMoveUp->setEnabled (false);
3546 actionEditMoveDown->setEnabled (false);
3551 actionEditCopy->setEnabled (false);
3552 actionEditCut->setEnabled (false);
3553 actionEditPaste->setEnabled (false);
3554 for (int i=0; i<actionListBranches.size(); ++i)
3555 actionListBranches.at(i)->setEnabled(false);
3557 actionEditToggleScroll->setEnabled (false);
3558 actionEditOpenURL->setEnabled (false);
3559 actionEditOpenVymLink->setEnabled (false);
3560 actionEditDeleteVymLink->setEnabled (false);
3561 actionEditHeading2URL->setEnabled (false);
3562 actionEditDelete->setEnabled (false);
3563 actionEditMoveUp->setEnabled (false);
3564 actionEditMoveDown->setEnabled (false);
3565 actionEditToggleHideExport->setEnabled (false);
3569 Main::ModMode Main::getModMode()
3571 if (actionModModeColor->isOn()) return ModModeColor;
3572 if (actionModModeCopy->isOn()) return ModModeCopy;
3573 if (actionModModeXLink->isOn()) return ModModeXLink;
3577 bool Main::autoEditNewBranch()
3579 return actionSettingsAutoEditNewBranch->isOn();
3582 bool Main::autoSelectNewBranch()
3584 return actionSettingsAutoSelectNewBranch->isOn();
3587 bool Main::useFlagGroups()
3589 return actionSettingsUseFlagGroups->isOn();
3592 void Main::windowShowNoteEditor()
3594 textEditor->setShowWithMain(true);
3596 actionViewToggleNoteEditor->setOn (true);
3599 void Main::windowHideNoteEditor()
3601 textEditor->setShowWithMain(false);
3603 actionViewToggleNoteEditor->setOn (false);
3606 void Main::setScript (const QString &script)
3608 scriptEditor->setScript (script);
3611 void Main::runScript (const QString &script)
3613 if (currentMapEditor())
3614 currentMapEditor()->runScript (script);
3617 void Main::runScriptEverywhere (const QString &script)
3620 for (int i=0;i<=tabWidget->count() -1;i++)
3622 me=(MapEditor*)tabWidget->page(i);
3623 if (me) me->runScript (script);
3627 void Main::windowNextEditor()
3629 if (tabWidget->currentPageIndex() < tabWidget->count())
3630 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3633 void Main::windowPreviousEditor()
3635 if (tabWidget->currentPageIndex() >0)
3636 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3639 void Main::standardFlagChanged()
3641 if (currentMapEditor())
3642 currentMapEditor()->toggleStandardFlag(sender()->name());
3645 void Main::testFunction1()
3647 if (!currentMapEditor()) return;
3648 currentMapEditor()->testFunction1();
3651 void Main::testFunction2()
3653 if (!currentMapEditor()) return;
3654 currentMapEditor()->testFunction2();
3657 void Main::testCommand()
3659 if (!currentMapEditor()) return;
3660 scriptEditor->show();
3663 QString com = QInputDialog::getText(
3664 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3665 if (ok) currentMapEditor()->parseAtom(com);
3669 void Main::helpDoc()
3671 QString locale = QLocale::system().name();
3673 if (locale.left(2)=="es")
3674 docname="vym_es.pdf";
3678 QStringList searchList;
3680 #if defined(Q_OS_MACX)
3681 searchList << "./vym.app/Contents/Resources/doc";
3683 #if defined(VYM_DOCDIR)
3684 searchList << VYM_DOCDIR;
3686 // default path in SUSE LINUX
3687 searchList <<"/usr/share/doc/packages/vym";
3690 searchList << "doc"; // relative path for easy testing in tarball
3691 searchList << "doc/tex"; // Easy testing working on vym.tex
3692 searchList << "/usr/share/doc/vym"; // Debian
3693 searchList << "/usr/share/doc/packages";// Knoppix
3697 for (int i=0; i<searchList.count(); ++i)
3699 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3700 if (docfile.exists() )
3709 QMessageBox::critical(0,
3710 tr("Critcal error"),
3711 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3716 Process *pdfProc = new Process();
3717 args <<docfile.fileName();
3719 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3720 if ( !pdfProc->waitForStarted() )
3723 QMessageBox::warning(0,
3725 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3726 tr("Please use Settings->")+tr("Set application to open PDF files"));
3733 void Main::helpDemo()
3735 QStringList filters;
3736 filters <<"VYM example map (*.vym)";
3737 QFileDialog *fd=new QFileDialog( this);
3738 #if defined(Q_OS_MACX)
3739 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3741 // default path in SUSE LINUX
3742 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3745 fd->setFileMode (QFileDialog::ExistingFiles);
3746 fd->setFilters (filters);
3747 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3751 if ( fd->exec() == QDialog::Accepted )
3753 lastFileDir=fd->directory().path();
3754 QStringList flist = fd->selectedFiles();
3755 QStringList::Iterator it = flist.begin();
3756 while( it != flist.end() )
3759 fileLoad(*it, NewMap);
3767 void Main::helpAbout()
3770 ad.setName ("aboutwindow");
3771 ad.setMinimumSize(500,500);
3772 ad.resize (QSize (500,500));
3776 void Main::helpAboutQT()
3778 QMessageBox::aboutQt( this, "Qt Application Example" );
3781 void Main::callMacro ()
3783 QAction *action = qobject_cast<QAction *>(sender());
3787 i=action->data().toInt();
3788 QString mDir (settings.value ("macros/macroDir").toString() );
3790 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3792 if ( !f.open( QIODevice::ReadOnly ) )
3794 QMessageBox::warning(0,
3796 tr("Couldn't find a macro at %1.\n").arg(fn)+
3797 tr("Please use Settings->")+tr("Set directory for vym macros"));
3801 QTextStream ts( &f );
3802 QString m= ts.read();
3806 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3807 currentMapEditor()->runScript (m);
3814 //////////////////////////////////
3816 @@ -2544,18 +2576,27 @@
3817 // Try to open new tab in existing konqueror started previously by vym
3818 p=new QProcess (this);
3820 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3821 - "konqueror-mainwindow#1"<<
3823 +#if defined(Q_OS_WIN32)
3824 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3825 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3826 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3827 + "konqueror-mainwindow#1"<<
3831 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3832 + "konqueror-mainwindow#1"<<
3836 p->start ("dcop",args);
3837 if ( !p->waitForStarted() ) success=false;