1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "branchpropwindow.h"
9 #include "exportoofiledialog.h"
12 #include "flagrowobj.h"
13 #include "historywindow.h"
15 #include "mapeditor.h"
20 #include "texteditor.h"
21 #include "warningdialog.h"
23 #if defined(Q_OS_WIN32)
24 // Define only this structure as opposed to
25 // including full 'windows.h'. FindWindow
26 // clashes with the one in Win32 API.
27 typedef struct _PROCESS_INFORMATION
33 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
36 extern TextEditor *textEditor;
37 extern Main *mainWindow;
38 extern QString tmpVymDir;
39 extern QString clipboardDir;
40 extern QString clipboardFile;
41 extern bool clipboardEmpty;
42 extern int statusbarTime;
43 extern FlagRowObj* standardFlagsDefault;
44 extern FlagRowObj* systemFlagsDefault;
45 extern QString vymName;
46 extern QString vymVersion;
47 extern QString vymBuildDate;
50 QMenu* branchContextMenu;
51 QMenu* branchAddContextMenu;
52 QMenu* branchRemoveContextMenu;
53 QMenu* branchLinksContextMenu;
54 QMenu* branchXLinksContextMenuEdit;
55 QMenu* branchXLinksContextMenuFollow;
56 QMenu* floatimageContextMenu;
57 QMenu* canvasContextMenu;
58 QMenu* fileLastMapsMenu;
59 QMenu* fileImportMenu;
60 QMenu* fileExportMenu;
63 extern Settings settings;
64 extern Options options;
65 extern ImageIO imageIO;
67 extern QDir vymBaseDir;
68 extern QDir lastImageDir;
69 extern QDir lastFileDir;
70 extern QString iconPath;
71 extern QString flagsPath;
73 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
74 QMainWindow(parent,name,f)
78 setCaption ("VYM - View Your Mind");
80 // Load window settings
81 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
82 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
85 // Sometimes we may need to remember old selections
89 currentColor=Qt::black;
91 // Create unique temporary directory
93 tmpVymDir=makeTmpDir (ok,"vym");
96 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
99 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
101 // Create direcctory for clipboard
102 clipboardDir=tmpVymDir+"/clipboard";
103 clipboardFile="map.xml";
104 QDir d(clipboardDir);
105 d.mkdir (clipboardDir,true);
106 makeSubDirs (clipboardDir);
111 // Satellite windows //////////////////////////////////////////
114 historyWindow=new HistoryWindow();
115 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
118 branchPropertyWindow = new BranchPropertyWindow();
119 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
121 // Connect TextEditor, so that we can update flags if text changes
122 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
123 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
125 // Connect HistoryWindow, so that we can update flags
126 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
129 // Initialize script editor
130 scriptEditor = new SimpleScriptEditor();
131 scriptEditor->move (50,50);
133 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
134 this, SLOT( runScript( QString ) ) );
137 // Initialize Find window
138 findWindow=new FindWindow(NULL);
139 findWindow->move (x(),y()+70);
140 connect (findWindow, SIGNAL( findButton(QString) ),
141 this, SLOT(editFind(QString) ) );
142 connect (findWindow, SIGNAL( somethingChanged() ),
143 this, SLOT(editFindChanged() ) );
145 // Initialize some settings, which are platform dependant
148 // application to open URLs
149 p="/mainwindow/readerURL";
150 #if defined(Q_OS_LINUX)
151 s=settings.value (p,"xdg-open").toString();
153 #if defined(Q_OS_MACX)
154 s=settings.value (p,"/usr/bin/open").toString();
157 #if defined(Q_OS_WIN32)
158 // Assume that system has been set up so that
159 // Explorer automagically opens up the URL
160 // in the user's preferred browser.
161 s=settings.value (p,"explorer").toString();
163 s=settings.value (p,"mozilla").toString();
167 settings.setValue( p,s);
169 // application to open PDFs
170 p="/mainwindow/readerPDF";
171 #if defined(Q_OS_LINUX)
172 s=settings.value (p,"xdg-open").toString();
174 #if defined(Q_OS_MACX)
175 s=settings.value (p,"/usr/bin/open").toString();
177 s=settings.value (p,"acroread").toString();
180 settings.setValue( p,s);
182 // width of xLinksMenu
185 // Create tab widget which holds the maps
186 tabWidget= new QTabWidget (this);
187 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
188 this, SLOT( editorChanged( QWidget * ) ) );
190 lineedit=new QLineEdit (this);
193 setCentralWidget(tabWidget);
197 setupFormatActions();
201 setupNetworkActions();
202 setupSettingsActions();
205 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
210 restoreState (settings.value("/mainwindow/state",0).toByteArray());
218 settings.setValue ( "/mainwindow/geometry/size", size() );
219 settings.setValue ( "/mainwindow/geometry/pos", pos() );
220 settings.setValue ("/mainwindow/state",saveState(0));
222 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
223 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
224 settings.setValue( "/version/version", vymVersion );
225 settings.setValue( "/version/builddate", vymBuildDate );
227 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
228 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
229 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
230 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
231 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
232 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
233 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
235 //TODO save scriptEditor settings
237 // call the destructors
239 delete historyWindow;
240 delete branchPropertyWindow;
242 // Remove temporary directory
243 removeDir (QDir(tmpVymDir));
246 void Main::loadCmdLine()
248 /* TODO draw some kind of splashscreen while loading...
254 QStringList flist=options.getFileList();
255 QStringList::Iterator it=flist.begin();
257 while (it !=flist.end() )
259 fileLoad (*it, NewMap);
265 void Main::statusMessage(const QString &s)
267 statusBar()->message( s);
270 void Main::closeEvent (QCloseEvent* )
276 void Main::setupFileActions()
278 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
279 QToolBar *tb = addToolBar( tr ("&Map") );
280 tb->setObjectName ("mapTB");
283 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
284 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
285 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
287 fileMenu->addAction (a);
288 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
290 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
291 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
292 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
293 fileMenu->addAction (a);
294 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
296 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
297 a->setStatusTip (tr( "Open","Status tip File menu" ) );
298 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
300 fileMenu->addAction (a);
301 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
303 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
304 fileMenu->addSeparator();
306 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
307 a->setStatusTip ( tr( "Save","Status tip file menu" ));
308 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
310 fileMenu->addAction (a);
311 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
314 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
315 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
316 fileMenu->addAction (a);
317 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
319 fileMenu->addSeparator();
321 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
323 a = new QAction(tr("KDE Bookmarks"), this);
324 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
325 a->addTo (fileImportMenu);
326 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
328 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
330 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
331 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
332 a->addTo (fileImportMenu);
333 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
336 a = new QAction("Freemind...",this);
337 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
338 fileImportMenu->addAction (a);
339 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
341 a = new QAction("Mind Manager...",this);
342 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
343 fileImportMenu->addAction (a);
344 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
346 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
347 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
348 fileImportMenu->addAction (a);
349 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
351 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
353 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
354 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
355 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
356 fileExportMenu->addAction (a);
358 a = new QAction( "Open Office...", this);
359 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
360 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
361 fileExportMenu->addAction (a);
363 a = new QAction( "Webpage (XHTML)...",this );
364 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
365 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
367 fileExportMenu->addAction (a);
369 a = new QAction( "Text (ASCII)...", this);
370 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
371 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
372 fileExportMenu->addAction (a);
374 a = new QAction( "Spreadsheet (CSV)...", this);
375 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
376 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
377 fileExportMenu->addAction (a);
379 a = new QAction( tr("KDE Bookmarks","File menu"), this);
380 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
381 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
382 fileExportMenu->addAction (a);
384 a = new QAction( "Taskjuggler...", this );
385 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
386 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
387 fileExportMenu->addAction (a);
389 a = new QAction( "LaTeX...", this);
390 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
391 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
392 fileExportMenu->addAction (a);
394 a = new QAction( "XML..." , this );
395 a->setStatusTip (tr( "Export as %1").arg("XML"));
396 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
397 fileExportMenu->addAction (a);
399 fileMenu->addSeparator();
401 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
402 a->setStatusTip ( tr( "Print" ,"File menu") );
403 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
405 fileMenu->addAction (a);
406 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
409 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
410 a->setStatusTip (tr( "Close Map" ) );
411 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
412 fileMenu->addAction (a);
413 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
415 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
416 a->setStatusTip ( tr( "Exit")+" "+vymName );
417 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
418 fileMenu->addAction (a);
419 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
424 void Main::setupEditActions()
426 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
427 tb->setLabel( "Edit Actions" );
428 tb->setObjectName ("actionsTB");
429 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
433 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
434 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
435 a->setStatusTip (tr( "Undo" ) );
436 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
437 a->setEnabled (false);
439 editMenu->addAction (a);
442 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
443 a->setStatusTip (tr( "Redo" ));
444 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
446 editMenu->addAction (a);
447 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
450 editMenu->addSeparator();
451 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
452 a->setStatusTip ( tr( "Copy" ) );
453 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
454 a->setEnabled (false);
456 editMenu->addAction (a);
457 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
460 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
461 a->setStatusTip ( tr( "Cut" ) );
462 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
463 a->setEnabled (false);
465 editMenu->addAction (a);
467 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
469 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
470 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
471 a->setStatusTip ( tr( "Paste" ) );
472 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
473 a->setEnabled (false);
475 editMenu->addAction (a);
478 // Shortcuts to modify heading:
479 a = new QAction(tr( "Edit heading","Edit menu" ),this);
480 a->setStatusTip ( tr( "edit Heading" ));
481 a->setShortcut ( Qt::Key_Enter); //Edit heading
482 // a->setShortcutContext (Qt::WindowShortcut);
484 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
485 actionListBranches.append(a);
486 a = new QAction( tr( "Edit heading","Edit menu" ), this);
487 a->setStatusTip (tr( "edit Heading" ));
488 a->setShortcut (Qt::Key_Return ); //Edit heading
489 //a->setShortcutContext (Qt::WindowShortcut);
491 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
492 actionListBranches.append(a);
493 editMenu->addAction (a);
495 a = new QAction( tr( "Edit heading","Edit menu" ), this);
496 a->setStatusTip (tr( "edit Heading" ));
497 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
498 a->setShortcutContext (Qt::WindowShortcut);
500 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
501 actionListBranches.append(a);
503 // Shortcut to delete selection
504 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
505 a->setStatusTip (tr( "Delete Selection" ));
506 a->setShortcut ( Qt::Key_Delete); //Delete selection
507 a->setShortcutContext (Qt::WindowShortcut);
509 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
512 // Shortcut to add branch
513 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
514 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
515 alt->setShortcut (Qt::Key_A); //Add branch
516 alt->setShortcutContext (Qt::WindowShortcut);
518 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
519 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
520 a->setStatusTip ( tr( "Add a branch as child of selection" ));
521 a->setShortcut (Qt::Key_Insert); //Add branch
522 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
523 actionListBranches.append(a);
524 #if defined (Q_OS_MACX)
525 // In OSX show different shortcut in menues, the keys work indepently always
526 actionEditAddBranch=alt;
528 actionEditAddBranch=a;
530 editMenu->addAction (actionEditAddBranch);
531 tb->addAction (actionEditAddBranch);
534 // Add branch by inserting it at selection
535 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
536 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
537 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
538 a->setShortcutContext (Qt::WindowShortcut);
540 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
541 a->setEnabled (false);
542 actionListBranches.append(a);
543 actionEditAddBranchBefore=a;
544 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
545 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
546 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
547 a->setShortcutContext (Qt::WindowShortcut);
549 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
550 actionListBranches.append(a);
553 a = new QAction(tr( "Add branch above","Edit menu" ), this);
554 a->setStatusTip ( tr( "Add a branch above selection" ));
555 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
556 a->setShortcutContext (Qt::WindowShortcut);
558 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
559 a->setEnabled (false);
560 actionListBranches.append(a);
561 actionEditAddBranchAbove=a;
562 a = new QAction(tr( "Add branch above","Edit menu" ), this);
563 a->setStatusTip ( tr( "Add a branch above selection" ));
564 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
565 a->setShortcutContext (Qt::WindowShortcut);
567 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
568 actionListBranches.append(a);
571 a = new QAction(tr( "Add branch below","Edit menu" ), this);
572 a->setStatusTip ( tr( "Add a branch below selection" ));
573 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
574 a->setShortcutContext (Qt::WindowShortcut);
576 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
577 a->setEnabled (false);
578 actionListBranches.append(a);
579 actionEditAddBranchBelow=a;
580 a = new QAction(tr( "Add branch below","Edit menu" ), this);
581 a->setStatusTip ( tr( "Add a branch below selection" ));
582 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
583 a->setShortcutContext (Qt::WindowShortcut);
585 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
586 actionListBranches.append(a);
588 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
589 a->setStatusTip ( tr( "Move branch up" ) );
590 a->setShortcut (Qt::Key_PageUp ); // Move branch up
591 a->setEnabled (false);
593 editMenu->addAction (a);
594 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
597 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
598 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
599 a->setStatusTip (tr( "Move branch down" ) );
600 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
601 a->setEnabled (false);
603 editMenu->addAction (a);
604 actionEditMoveDown=a;
606 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
607 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
608 a->setEnabled (true);
610 actionEditSortChildren=a;
612 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
613 a->setShortcut ( Qt::Key_ScrollLock );
614 a->setStatusTip (tr( "Scroll branch" ) );
615 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
617 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
618 alt->setShortcut ( Qt::Key_S ); // Scroll branch
619 alt->setStatusTip (tr( "Scroll branch" ));
620 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
621 #if defined(Q_OS_MACX)
622 actionEditToggleScroll=alt;
624 actionEditToggleScroll=a;
626 actionEditToggleScroll->setEnabled (false);
627 actionEditToggleScroll->setToggleAction(true);
628 tb->addAction (actionEditToggleScroll);
629 editMenu->addAction ( actionEditToggleScroll);
630 editMenu->addAction (actionEditToggleScroll);
633 actionListBranches.append(actionEditToggleScroll);
635 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
636 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
637 editMenu->addAction (a);
638 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
640 editMenu->addSeparator();
642 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
643 a->setStatusTip (tr( "Find" ) );
644 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
645 editMenu->addAction (a);
646 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
648 editMenu->addSeparator();
650 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
651 a->setShortcut (Qt::CTRL + Qt::Key_U );
652 a->setShortcut (tr( "Open URL" ));
655 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
658 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
659 a->setStatusTip (tr( "Open URL in new tab" ));
660 //a->setShortcut (Qt::CTRL+Qt::Key_U );
662 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
663 actionEditOpenURLTab=a;
665 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
666 a->setStatusTip (tr( "Open all URLs in subtree" ));
668 actionListBranches.append(a);
669 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
670 actionEditOpenMultipleURLTabs=a;
672 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
673 a->setStatusTip ( tr( "Edit URL" ) );
674 a->setShortcut ( Qt::Key_U );
675 a->setShortcutContext (Qt::WindowShortcut);
676 actionListBranches.append(a);
678 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
681 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
682 a->setStatusTip ( tr( "Edit local URL" ) );
683 a->setShortcut (Qt::SHIFT + Qt::Key_U );
684 a->setShortcutContext (Qt::WindowShortcut);
685 actionListBranches.append(a);
687 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
688 actionEditLocalURL=a;
690 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
691 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
692 a->setEnabled (false);
693 actionListBranches.append(a);
694 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
695 actionEditHeading2URL=a;
697 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
698 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
699 a->setEnabled (false);
700 actionListBranches.append(a);
701 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
702 actionEditBugzilla2URL=a;
704 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
705 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
706 a->setEnabled (false);
707 actionListBranches.append(a);
708 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
709 actionEditFATE2URL=a;
711 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
712 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
714 a->setEnabled (false);
715 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
716 actionEditOpenVymLink=a;
718 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
719 a->setStatusTip ( tr( "Open all vym links in subtree" ));
720 a->setEnabled (false);
721 actionListBranches.append(a);
722 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
723 actionEditOpenMultipleVymLinks=a;
726 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
727 a->setEnabled (false);
728 a->setStatusTip ( tr( "Edit link to another vym map" ));
729 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
730 actionListBranches.append(a);
733 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
734 a->setStatusTip ( tr( "Delete link to another vym map" ));
735 a->setEnabled (false);
736 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
737 actionEditDeleteVymLink=a;
739 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
740 a->setStatusTip ( tr( "Hide object in exports" ) );
741 a->setShortcut (Qt::Key_H );
742 a->setToggleAction(true);
744 a->setEnabled (false);
745 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
746 actionEditToggleHideExport=a;
748 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
749 a->setStatusTip ( tr( "Edit Map Info" ));
750 a->setEnabled (true);
751 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
754 // Import at selection (adding to selection)
755 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
756 a->setStatusTip (tr( "Add map at selection" ));
757 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
758 a->setEnabled (false);
759 actionListBranches.append(a);
760 actionEditImportAdd=a;
762 // Import at selection (replacing selection)
763 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
764 a->setStatusTip (tr( "Replace selection with map" ));
765 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
766 a->setEnabled (false);
767 actionListBranches.append(a);
768 actionEditImportReplace=a;
771 a = new QAction( tr( "Save selection","Edit menu" ), this);
772 a->setStatusTip (tr( "Save selection" ));
773 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
774 a->setEnabled (false);
775 actionListBranches.append(a);
776 actionEditSaveBranch=a;
778 // Only remove branch, not its childs
779 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
780 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
781 a->setShortcut (Qt::ALT + Qt::Key_Delete );
782 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
783 a->setEnabled (false);
785 actionListBranches.append(a);
786 actionEditDeleteKeepChilds=a;
788 // Only remove childs of a branch
789 a = new QAction( tr( "Remove childs","Edit menu" ), this);
790 a->setStatusTip (tr( "Remove childs of branch" ));
791 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
792 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
793 a->setEnabled (false);
794 actionListBranches.append(a);
795 actionEditDeleteChilds=a;
797 // Shortcuts for navigating with cursor:
798 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
799 a->setStatusTip ( tr( "Select upper branch" ));
800 a->setShortcut (Qt::Key_Up );
801 a->setShortcutContext (Qt::WindowShortcut);
803 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
804 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
805 a->setStatusTip (tr( "Select lower branch" ));
806 a->setShortcut ( Qt::Key_Down );
807 a->setShortcutContext (Qt::WindowShortcut);
809 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
810 a = new QAction(tr( "Select left branch","Edit menu" ), this);
811 a->setStatusTip ( tr( "Select left branch" ));
812 a->setShortcut (Qt::Key_Left );
813 a->setShortcutContext (Qt::WindowShortcut);
815 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
816 a = new QAction( tr( "Select child branch","Edit menu" ), this);
817 a->setStatusTip (tr( "Select right branch" ));
818 a->setShortcut (Qt::Key_Right);
819 a->setShortcutContext (Qt::WindowShortcut);
821 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
822 a = new QAction( tr( "Select first branch","Edit menu" ), this);
823 a->setStatusTip (tr( "Select first branch" ));
824 a->setShortcut (Qt::Key_Home );
825 a->setShortcutContext (Qt::WindowShortcut);
827 a->setEnabled (false);
828 editMenu->addAction (a);
829 actionListBranches.append(a);
830 actionEditSelectFirst=a;
831 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
832 a = new QAction( tr( "Select last branch","Edit menu" ),this);
833 a->setStatusTip (tr( "Select last branch" ));
834 a->setShortcut ( Qt::Key_End );
835 a->setShortcutContext (Qt::WindowShortcut);
837 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
838 a->setEnabled (false);
839 editMenu->addAction (a);
840 actionListBranches.append(a);
841 actionEditSelectLast=a;
843 a = new QAction( tr( "Add Image...","Edit menu" ), this);
844 a->setStatusTip (tr( "Add Image" ));
845 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
846 actionEditLoadImage=a;
848 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
849 a->setStatusTip (tr( "Set properties for selection" ));
850 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
851 a->setShortcutContext (Qt::WindowShortcut);
852 a->setToggleAction (true);
854 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
855 actionViewTogglePropertyWindow=a;
859 void Main::setupFormatActions()
861 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
863 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
864 tb->setObjectName ("formatTB");
867 pix.fill (Qt::black);
868 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
869 a->setStatusTip ( tr( "Set Color" ));
870 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
872 formatMenu->addAction (a);
874 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
875 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
876 a->setShortcut (Qt::CTRL + Qt::Key_K );
877 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
878 a->setEnabled (false);
880 formatMenu->addAction (a);
881 actionListBranches.append(a);
882 actionFormatPickColor=a;
884 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
885 a->setStatusTip ( tr( "Color branch" ) );
886 a->setShortcut (Qt::CTRL + Qt::Key_B);
887 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
888 a->setEnabled (false);
890 formatMenu->addAction (a);
891 actionListBranches.append(a);
892 actionFormatColorSubtree=a;
894 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
895 a->setStatusTip ( tr( "Color Subtree" ));
896 a->setShortcut (Qt::CTRL + Qt::Key_T);
897 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
898 a->setEnabled (false);
899 formatMenu->addAction (a);
901 actionListBranches.append(a);
902 actionFormatColorSubtree=a;
904 formatMenu->addSeparator();
905 actionGroupFormatLinkStyles=new QActionGroup ( this);
906 actionGroupFormatLinkStyles->setExclusive (true);
907 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
908 a->setStatusTip (tr( "Line" ));
909 a->setToggleAction(true);
910 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
911 formatMenu->addAction (a);
912 actionFormatLinkStyleLine=a;
913 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
914 a->setStatusTip (tr( "Line" ));
915 a->setToggleAction(true);
916 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
917 formatMenu->addAction (a);
918 actionFormatLinkStyleParabel=a;
919 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
920 a->setStatusTip (tr( "PolyLine" ));
921 a->setToggleAction(true);
922 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
923 formatMenu->addAction (a);
924 actionFormatLinkStylePolyLine=a;
925 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
926 a->setStatusTip (tr( "PolyParabel" ) );
927 a->setToggleAction(true);
928 a->setChecked (true);
929 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
930 formatMenu->addAction (a);
931 actionFormatLinkStylePolyParabel=a;
933 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
934 a->setStatusTip (tr( "Hide link" ));
935 a->setToggleAction(true);
936 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
937 actionFormatHideLinkUnselected=a;
939 formatMenu->addSeparator();
940 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
941 a->setStatusTip (tr( "Use same color for links and headings" ));
942 a->setToggleAction(true);
943 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
944 formatMenu->addAction (a);
945 actionFormatLinkColorHint=a;
947 pix.fill (Qt::white);
948 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
949 a->setStatusTip (tr( "Set Link Color" ));
950 formatMenu->addAction (a);
951 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
952 actionFormatLinkColor=a;
954 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
955 a->setStatusTip (tr( "Set Selection Color" ));
956 formatMenu->addAction (a);
957 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
958 actionFormatSelectionColor=a;
960 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
961 a->setStatusTip (tr( "Set Background Color" ));
962 formatMenu->addAction (a);
963 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
964 actionFormatBackColor=a;
966 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
967 a->setStatusTip (tr( "Set Background image" ));
968 formatMenu->addAction (a);
969 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
970 actionFormatBackImage=a;
974 void Main::setupViewActions()
976 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
977 tb->setLabel( "View Actions" );
978 tb->setObjectName ("viewTB");
979 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
982 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
983 a->setStatusTip ( tr( "Zoom reset" ) );
984 a->setShortcut (Qt::CTRL + Qt::Key_0 );
986 viewMenu->addAction (a);
987 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
989 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
990 a->setStatusTip (tr( "Zoom in" ));
991 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
993 viewMenu->addAction (a);
994 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
996 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
997 a->setStatusTip (tr( "Zoom out" ));
998 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1000 viewMenu->addAction (a);
1001 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1003 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1004 a->setStatusTip (tr( "Show selection" ));
1005 a->setShortcut (Qt::Key_Period);
1007 viewMenu->addAction (a);
1008 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1010 viewMenu->addSeparator();
1012 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1013 a->setStatusTip ( tr( "Show Note Editor" ));
1014 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1015 a->setToggleAction(true);
1017 viewMenu->addAction (a);
1018 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1019 actionViewToggleNoteEditor=a;
1021 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1022 a->setStatusTip ( tr( "Show History Window" ));
1023 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1024 a->setToggleAction(true);
1026 viewMenu->addAction (a);
1027 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1028 actionViewToggleHistoryWindow=a;
1030 viewMenu->addAction (actionViewTogglePropertyWindow);
1032 viewMenu->addSeparator();
1034 a = new QAction(tr( "Antialiasing","View action" ),this );
1035 a->setStatusTip ( tr( "Antialiasing" ));
1036 a->setToggleAction(true);
1037 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1038 viewMenu->addAction (a);
1039 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1040 actionViewToggleAntiAlias=a;
1042 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1043 a->setStatusTip (a->text());
1044 a->setToggleAction(true);
1045 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1046 viewMenu->addAction (a);
1047 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1048 actionViewToggleSmoothPixmapTransform=a;
1050 a = new QAction(tr( "Next Map","View action" ), this);
1051 a->setStatusTip (a->text());
1052 a->setShortcut (Qt::ALT + Qt::Key_N );
1053 viewMenu->addAction (a);
1054 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1056 a = new QAction (tr( "Previous Map","View action" ), this );
1057 a->setStatusTip (a->text());
1058 a->setShortcut (Qt::ALT + Qt::Key_P );
1059 viewMenu->addAction (a);
1060 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1064 void Main::setupModeActions()
1066 //QPopupMenu *menu = new QPopupMenu( this );
1067 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1069 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1070 tb->setObjectName ("modesTB");
1072 actionGroupModModes=new QActionGroup ( this);
1073 actionGroupModModes->setExclusive (true);
1074 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1075 a->setShortcut (Qt::Key_J);
1076 a->setStatusTip ( tr( "Use modifier to color branches" ));
1077 a->setToggleAction(true);
1080 actionModModeColor=a;
1082 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1083 a->setShortcut( Qt::Key_K);
1084 a->setStatusTip( tr( "Use modifier to copy" ));
1085 a->setToggleAction(true);
1087 actionModModeCopy=a;
1089 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1090 a->setShortcut (Qt::Key_L);
1091 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1092 a->setToggleAction(true);
1094 actionModModeXLink=a;
1098 void Main::setupFlagActions()
1100 // Create System Flags
1104 systemFlagsDefault = new FlagRowObj ();
1105 systemFlagsDefault->setVisibility (false);
1106 systemFlagsDefault->setName ("systemFlagsDef");
1108 FlagObj *fo = new FlagObj ();
1109 fo->load(QPixmap(flagsPath+"flag-note.png"));
1110 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1112 fo->load(QPixmap(flagsPath+"flag-url.png"));
1113 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1115 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1116 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1118 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1119 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1121 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1122 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1124 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1125 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1127 // Create Standard Flags
1128 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1129 tb->setObjectName ("standardFlagTB");
1131 standardFlagsDefault = new FlagRowObj ();
1132 standardFlagsDefault->setVisibility (false);
1133 standardFlagsDefault->setName ("standardFlagsDef");
1134 standardFlagsDefault->setToolBar (tb);
1136 fo->load(flagsPath+"flag-exclamationmark.png");
1137 fo->setGroup("standard-mark");
1138 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1140 fo->load(flagsPath+"flag-questionmark.png");
1141 fo->setGroup("standard-mark");
1142 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1144 fo->load(flagsPath+"flag-hook-green.png");
1145 fo->setGroup("standard-hook");
1146 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1148 fo->load(flagsPath+"flag-cross-red.png");
1149 fo->setGroup("standard-hook");
1150 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1153 fo->load(flagsPath+"flag-stopsign.png");
1154 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1156 fo->load(flagsPath+"flag-smiley-good.png");
1157 fo->setGroup("standard-smiley");
1158 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1160 fo->load(flagsPath+"flag-smiley-sad.png");
1161 fo->setGroup("standard-smiley");
1162 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1164 fo->load(flagsPath+"flag-smiley-omg.png");
1165 fo->setGroup("standard-smiley");
1166 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1167 // Original omg.png (in KDE emoticons)
1170 fo->load(flagsPath+"flag-kalarm.png");
1171 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1173 fo->load(flagsPath+"flag-phone.png");
1174 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1176 fo->load(flagsPath+"flag-lamp.png");
1177 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1179 fo->load(flagsPath+"flag-arrow-up.png");
1180 fo->setGroup("standard-arrow");
1181 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1183 fo->load(flagsPath+"flag-arrow-down.png");
1184 fo->setGroup("standard-arrow");
1185 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1187 fo->load(flagsPath+"flag-arrow-2up.png");
1188 fo->setGroup("standard-arrow");
1189 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1191 fo->load(flagsPath+"flag-arrow-2down.png");
1192 fo->setGroup("standard-arrow");
1193 setupFlag (fo,tb,avis,"present",tr("Very unimportant!","Standardflag"));
1196 fo->load(flagsPath+"flag-thumb-up.png");
1197 fo->setGroup("standard-thumb");
1198 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1200 fo->load(flagsPath+"flag-thumb-down.png");
1201 fo->setGroup("standard-thumb");
1202 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1205 fo->load(flagsPath+"flag-rose.png");
1206 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1208 fo->load(flagsPath+"flag-heart.png");
1209 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1211 fo->load(flagsPath+"flag-present.png");
1212 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1214 fo->load(flagsPath+"flag-flash.png");
1215 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1217 // Original: xsldbg_output.png
1218 fo->load(flagsPath+"flag-info.png");
1219 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1221 // Original khelpcenter.png
1222 fo->load(flagsPath+"flag-lifebelt.png");
1223 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1229 fo->load(flagsPath+"freemind/warning.png");
1230 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1232 for (int i=1; i<8; i++)
1234 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1235 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1238 fo->load(flagsPath+"freemind/back.png");
1239 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1241 fo->load(flagsPath+"freemind/forward.png");
1242 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1244 fo->load(flagsPath+"freemind/attach.png");
1245 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1247 fo->load(flagsPath+"freemind/clanbomber.png");
1248 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1250 fo->load(flagsPath+"freemind/desktopnew.png");
1251 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1253 fo->load(flagsPath+"freemind/flag.png");
1254 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1257 fo->load(flagsPath+"freemind/gohome.png");
1258 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1261 fo->load(flagsPath+"freemind/kaddressbook.png");
1262 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1264 fo->load(flagsPath+"freemind/knotify.png");
1265 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1267 fo->load(flagsPath+"freemind/korn.png");
1268 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1270 fo->load(flagsPath+"freemind/mail.png");
1271 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1273 fo->load(flagsPath+"freemind/password.png");
1274 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1276 fo->load(flagsPath+"freemind/pencil.png");
1277 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1279 fo->load(flagsPath+"freemind/stop.png");
1280 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1282 fo->load(flagsPath+"freemind/wizard.png");
1283 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1285 fo->load(flagsPath+"freemind/xmag.png");
1286 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1288 fo->load(flagsPath+"freemind/bell.png");
1289 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1291 fo->load(flagsPath+"freemind/bookmark.png");
1292 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1294 fo->load(flagsPath+"freemind/penguin.png");
1295 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1297 fo->load(flagsPath+"freemind/licq.png");
1298 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1303 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1306 fo->setToolTip (tooltip);
1307 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1313 fo->setAlwaysVisible(aw);
1314 a->setCheckable(true);
1315 a->setObjectName(fo->getName());
1316 a->setToolTip(tooltip);
1317 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1318 standardFlagsDefault->addFlag (fo);
1322 systemFlagsDefault->addFlag (fo);
1326 void Main::setupNetworkActions()
1328 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1330 QMenu *netMenu = menuBar()->addMenu( "&Network" );
1334 a = new QAction( "Start TCPserver for MapEditor",this);
1335 //a->setStatusTip ( "Set application to open pdf files"));
1336 a->setShortcut ( Qt::Key_T ); //New TCP server
1337 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1338 netMenu->addAction (a);
1340 a = new QAction( "Connect MapEditor to server",this);
1341 //a->setStatusTip ( "Set application to open pdf files"));
1342 a->setShortcut ( Qt::Key_C ); // Connect to server
1343 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1344 netMenu->addAction (a);
1348 void Main::setupSettingsActions()
1350 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1354 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1355 a->setStatusTip ( tr( "Set application to open pdf files"));
1356 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1357 settingsMenu->addAction (a);
1359 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1360 a->setStatusTip( tr( "Set application to open external links"));
1361 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1362 settingsMenu->addAction (a);
1364 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1365 a->setStatusTip( tr( "Set path for macros"));
1366 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1367 settingsMenu->addAction (a);
1369 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1370 a->setStatusTip( tr( "Set number of undo levels"));
1371 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1372 settingsMenu->addAction (a);
1374 settingsMenu->addSeparator();
1376 a = new QAction( tr( "Autosave","Settings action"), this);
1377 a->setStatusTip( tr( "Autosave"));
1378 a->setToggleAction(true);
1379 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1380 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1381 settingsMenu->addAction (a);
1382 actionSettingsAutosaveToggle=a;
1384 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1385 a->setStatusTip( tr( "Autosave time"));
1386 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1387 settingsMenu->addAction (a);
1388 actionSettingsAutosaveTime=a;
1390 settingsMenu->addSeparator();
1392 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1393 a->setStatusTip( tr( "Edit branch after adding it" ));
1394 a->setToggleAction(true);
1395 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1396 settingsMenu->addAction (a);
1397 actionSettingsAutoEditNewBranch=a;
1399 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1400 a->setStatusTip( tr( "Select branch after adding it" ));
1401 a->setToggleAction(true);
1402 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1403 settingsMenu->addAction (a);
1404 actionSettingsAutoSelectNewBranch=a;
1406 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1407 a->setStatusTip( tr( "Select heading before editing" ));
1408 a->setToggleAction(true);
1409 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1410 settingsMenu->addAction (a);
1411 actionSettingsAutoSelectText=a;
1413 a= new QAction( tr( "Delete key","Settings action" ), this);
1414 a->setStatusTip( tr( "Delete key for deleting branches" ));
1415 a->setToggleAction(true);
1416 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1417 settingsMenu->addAction (a);
1418 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1419 actionSettingsUseDelKey=a;
1421 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1422 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1423 a->setToggleAction(true);
1424 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1425 settingsMenu->addAction (a);
1426 actionSettingsUseFlagGroups=a;
1428 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1429 a->setStatusTip( tr( "Use hide flag during exports " ));
1430 a->setToggleAction(true);
1431 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1432 settingsMenu->addAction (a);
1433 actionSettingsUseHideExport=a;
1437 void Main::setupTestActions()
1439 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1442 a = new QAction( "Test function 1" , this);
1443 a->setStatusTip( "Call test function 1" );
1444 testMenu->addAction (a);
1445 //a->setShortcut (Qt::Key_F4 );
1446 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1448 a = new QAction( "Test function 2" , this);
1449 a->setStatusTip( "Call test function 2" );
1450 //a->setShortcut (Qt::Key_F4 );
1451 testMenu->addAction (a);
1452 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1454 a = new QAction( "Command" , this);
1455 a->setStatusTip( "Enter command to call in editor" );
1456 //a->setShortcut (Qt::Key_F5 );
1457 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1458 testMenu->addAction (a);
1462 void Main::setupHelpActions()
1464 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1467 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1468 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1469 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1470 helpMenu->addAction (a);
1472 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1473 a->setStatusTip( tr( "Open VYM example maps " ));
1474 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1475 helpMenu->addAction (a);
1477 a = new QAction( tr( "About VYM","Help action" ), this);
1478 a->setStatusTip( tr( "About VYM")+vymName);
1479 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1480 helpMenu->addAction (a);
1482 a = new QAction( tr( "About QT","Help action" ), this);
1483 a->setStatusTip( tr( "Information about QT toolkit" ));
1484 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1485 helpMenu->addAction (a);
1489 void Main::setupContextMenus()
1493 // Context Menu for branch or mapcenter
1494 branchContextMenu =new QMenu (this);
1495 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1496 branchContextMenu->addSeparator();
1499 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1500 branchAddContextMenu->addAction (actionEditPaste );
1501 branchAddContextMenu->addAction ( actionEditAddBranch );
1502 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1503 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1504 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1505 branchAddContextMenu->addSeparator();
1506 branchAddContextMenu->addAction ( actionEditImportAdd );
1507 branchAddContextMenu->addAction ( actionEditImportReplace );
1510 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1511 branchRemoveContextMenu->addAction (actionEditCut);
1512 branchRemoveContextMenu->addAction ( actionEditDelete );
1513 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1514 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1517 actionEditSaveBranch->addTo( branchContextMenu );
1519 branchContextMenu->addSeparator();
1520 branchContextMenu->addAction ( actionEditLoadImage);
1522 // Submenu for Links (URLs, vymLinks)
1523 branchLinksContextMenu =new QMenu (this);
1525 branchContextMenu->addSeparator();
1526 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1527 branchLinksContextMenu->addAction ( actionEditOpenURL );
1528 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1529 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1530 branchLinksContextMenu->addAction ( actionEditURL );
1531 branchLinksContextMenu->addAction ( actionEditLocalURL );
1532 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1533 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1534 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1536 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1538 branchLinksContextMenu->addSeparator();
1539 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1540 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1541 branchLinksContextMenu->addAction ( actionEditVymLink );
1542 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1545 // Context Menu for XLinks in a branch menu
1546 // This will be populated "on demand" in MapEditor::updateActions
1547 branchContextMenu->addSeparator();
1548 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1549 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1550 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1551 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1554 // Context menu for floatimage
1555 floatimageContextMenu =new QMenu (this);
1556 a= new QAction (tr ("Save image","Context action"),this);
1557 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1558 floatimageContextMenu->addAction (a);
1560 floatimageContextMenu->addSeparator();
1561 actionEditCopy->addTo( floatimageContextMenu );
1562 actionEditCut->addTo( floatimageContextMenu );
1564 floatimageContextMenu->addSeparator();
1565 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1568 // Context menu for canvas
1569 canvasContextMenu =new QMenu (this);
1570 actionEditMapInfo->addTo( canvasContextMenu );
1571 canvasContextMenu->insertSeparator();
1572 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1573 canvasContextMenu->insertSeparator();
1574 actionFormatLinkColorHint->addTo( canvasContextMenu );
1575 actionFormatLinkColor->addTo( canvasContextMenu );
1576 actionFormatSelectionColor->addTo( canvasContextMenu );
1577 actionFormatBackColor->addTo( canvasContextMenu );
1578 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1580 // Menu for last opened files
1582 for (int i = 0; i < MaxRecentFiles; ++i)
1584 recentFileActions[i] = new QAction(this);
1585 recentFileActions[i]->setVisible(false);
1586 fileLastMapsMenu->addAction(recentFileActions[i]);
1587 connect(recentFileActions[i], SIGNAL(triggered()),
1588 this, SLOT(fileLoadRecent()));
1590 setupRecentMapsMenu();
1593 void Main::setupRecentMapsMenu()
1595 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1597 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1599 for (int i = 0; i < numRecentFiles; ++i) {
1600 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1601 recentFileActions[i]->setText(text);
1602 recentFileActions[i]->setData(files[i]);
1603 recentFileActions[i]->setVisible(true);
1605 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1606 recentFileActions[j]->setVisible(false);
1609 void Main::setupMacros()
1611 for (int i = 0; i <= 11; i++)
1613 macroActions[i] = new QAction(this);
1614 macroActions[i]->setData(i);
1615 addAction (macroActions[i]);
1616 connect(macroActions[i], SIGNAL(triggered()),
1617 this, SLOT(callMacro()));
1619 macroActions[0]->setShortcut ( Qt::Key_F1 );
1620 macroActions[1]->setShortcut ( Qt::Key_F2 );
1621 macroActions[2]->setShortcut ( Qt::Key_F3 );
1622 macroActions[3]->setShortcut ( Qt::Key_F4 );
1623 macroActions[4]->setShortcut ( Qt::Key_F5 );
1624 macroActions[5]->setShortcut ( Qt::Key_F6 );
1625 macroActions[6]->setShortcut ( Qt::Key_F7 );
1626 macroActions[7]->setShortcut ( Qt::Key_F8 );
1627 macroActions[8]->setShortcut ( Qt::Key_F9 );
1628 macroActions[9]->setShortcut ( Qt::Key_F10 );
1629 macroActions[10]->setShortcut ( Qt::Key_F11 );
1630 macroActions[11]->setShortcut ( Qt::Key_F12 );
1633 void Main::hideEvent (QHideEvent * )
1635 if (!textEditor->isMinimized() ) textEditor->hide();
1638 void Main::showEvent (QShowEvent * )
1640 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1644 MapEditor* Main::currentMapEditor() const
1646 if ( tabWidget->currentPage() &&
1647 tabWidget->currentPage()->inherits( "MapEditor" ) )
1648 return (MapEditor*)tabWidget->currentPage();
1653 void Main::editorChanged(QWidget *)
1655 // Unselect all possibly selected objects
1656 // (Important to update note editor)
1658 for (int i=0;i<=tabWidget->count() -1;i++)
1661 me=(MapEditor*)tabWidget->page(i);
1664 currentMapEditor()->reselect();
1666 // Update actions to in menus and toolbars according to editor
1670 void Main::fileNew()
1672 QString fn="unnamed";
1673 MapEditor* me = new MapEditor ( NULL);
1674 tabWidget->addTab (me,fn);
1675 tabWidget->showPage(me);
1676 me->viewport()->setFocus();
1677 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1678 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1680 // For the very first map we do not have flagrows yet...
1684 void Main::fileNewCopy()
1686 QString fn="unnamed";
1687 MapEditor* oldME =currentMapEditor();
1691 MapEditor* newME = new MapEditor ( NULL);
1694 tabWidget->addTab (newME,fn);
1695 tabWidget->showPage(newME);
1696 newME->viewport()->setFocus();
1697 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1698 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1699 // For the very first map we do not have flagrows yet...
1700 newME->select("mc:");
1701 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1707 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1709 ErrorCode err=success;
1711 // fn is usually the archive, mapfile the file after uncompressing
1714 // Make fn absolute (needed for unzip)
1715 fn=QDir (fn).absPath();
1721 // Check, if map is already loaded
1723 while (i<=tabWidget->count() -1)
1725 me=(MapEditor*)tabWidget->page(i);
1726 if (me->getFilePath() == fn)
1728 // Already there, ask for confirmation
1729 QMessageBox mb( vymName,
1730 tr("The map %1\nis already opened."
1731 "Opening the same map in multiple editors may lead \n"
1732 "to confusion when finishing working with vym."
1733 "Do you want to").arg(fn),
1734 QMessageBox::Warning,
1735 QMessageBox::Yes | QMessageBox::Default,
1736 QMessageBox::Cancel | QMessageBox::Escape,
1737 QMessageBox::NoButton);
1738 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1739 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1742 case QMessageBox::Yes:
1744 i=tabWidget->count();
1746 case QMessageBox::Cancel:
1758 if ( !fn.isEmpty() )
1760 me = currentMapEditor();
1761 int tabIndex=tabWidget->currentPageIndex();
1762 // Check first, if mapeditor exists
1763 // If it is not default AND we want a new map,
1764 // create a new mapeditor in a new tab
1765 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1767 me= new MapEditor ( NULL);
1768 tabWidget->addTab (me,fn);
1769 tabIndex=tabWidget->indexOf (me);
1770 tabWidget->setCurrentPage (tabIndex);
1771 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1772 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1775 // Check, if file exists (important for creating new files
1776 // from command line
1777 if (!QFile(fn).exists() )
1779 QMessageBox mb( vymName,
1780 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1781 QMessageBox::Question,
1783 QMessageBox::Cancel | QMessageBox::Default,
1784 QMessageBox::NoButton );
1786 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1787 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1790 case QMessageBox::Yes:
1792 currentMapEditor()->setFilePath(fn);
1793 tabWidget->setTabLabel (currentMapEditor(),
1794 currentMapEditor()->getFileName() );
1795 statusBar()->message( "Created " + fn , statusbarTime );
1798 case QMessageBox::Cancel:
1799 // don't create new map
1800 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1807 //tabWidget->currentPage() won't be NULL here, because of above...
1808 tabWidget->showPage(me);
1809 me->viewport()->setFocus();
1811 // Create temporary directory for packing
1813 QString tmpMapDir=makeTmpDir (ok,"vym-pack");
1816 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1817 tr("Couldn't create temporary directory before load\n"));
1821 // Try to unzip file
1822 err=unzipDir (tmpMapDir,fn);
1826 me->setZipped(false);
1829 me->setZipped(true);
1831 // Look for mapname.xml
1832 mapfile= fn.left(fn.findRev(".",-1,true));
1833 mapfile=mapfile.section( '/', -1 );
1834 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1835 if (!file.exists() )
1837 // mapname.xml does not exist, well,
1838 // maybe someone renamed the mapname.vym file...
1839 // Try to find any .xml in the toplevel
1840 // directory of the .vym file
1841 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1842 if (flist.count()==1)
1844 // Only one entry, take this one
1845 mapfile=tmpMapDir + "/"+flist.first();
1848 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1849 *it=tmpMapDir + "/" + *it;
1850 // TODO Multiple entries, load all (but only the first one into this ME)
1851 //mainWindow->fileLoadFromTmp (flist);
1852 //returnCode=1; // Silently forget this attempt to load
1853 qWarning ("MainWindow::load (fn) multimap found...");
1856 if (flist.isEmpty() )
1858 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1859 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1862 } //file doesn't exist
1864 mapfile=file.name();
1869 // Save existing filename in case we import
1870 QString fn_org=me->getFilePath();
1872 // Finally load map into mapEditor
1873 me->setFilePath (mapfile,fn);
1874 err=me->load(mapfile,lmode,ftype);
1876 // Restore old (maybe empty) filepath, if this is an import
1878 me->setFilePath (fn_org);
1881 // Finally check for errors and go home
1884 if (lmode==NewMap) fileCloseMap();
1885 statusBar()->message( "Could not load " + fn, statusbarTime );
1890 me->setFilePath (fn);
1891 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1892 if (!isInTmpDir (fn))
1894 // Only append to lastMaps if not loaded from a tmpDir
1895 // e.g. imported bookmarks are in a tmpDir
1896 addRecentMap(me->getFilePath() );
1898 actionFilePrint->setEnabled (true);
1900 statusBar()->message( "Loaded " + fn, statusbarTime );
1904 removeDir (QDir(tmpMapDir));
1910 void Main::fileLoad(const LoadMode &lmode)
1912 QStringList filters;
1913 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1914 QFileDialog *fd=new QFileDialog( this);
1915 fd->setDir (lastFileDir);
1916 fd->setFileMode (QFileDialog::ExistingFiles);
1917 fd->setFilters (filters);
1921 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1924 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1927 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1933 if ( fd->exec() == QDialog::Accepted )
1935 lastFileDir=fd->directory().path();
1936 QStringList flist = fd->selectedFiles();
1937 QStringList::Iterator it = flist.begin();
1938 while( it != flist.end() )
1941 fileLoad(*it, lmode);
1948 void Main::fileLoad()
1953 void Main::fileLoadRecent()
1955 QAction *action = qobject_cast<QAction *>(sender());
1957 fileLoad (action->data().toString(), NewMap);
1960 void Main::addRecentMap (const QString &fileName)
1963 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1964 files.removeAll(fileName);
1965 files.prepend(fileName);
1966 while (files.size() > MaxRecentFiles)
1969 settings.setValue("/mainwindow/recentFileList", files);
1971 setupRecentMapsMenu();
1974 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1976 // tmp dir for zipping
1980 ErrorCode err=success;
1982 QString safeFilePath;
1984 bool saveZipped=me->saveZipped();
1988 QString fn=me->getFilePath();
1989 // filename=unnamed, filepath="" in constructor of mapEditor
1990 if ( !fn.isEmpty() )
1992 // We have a filepath, go on saving
1993 // First remove existing file, we
1994 // don't want to add to old zip archives
1998 QMessageBox::warning( 0, tr( "Save Error" ),
1999 fn+ tr("\ncould not be removed before saving"));
2001 // Look, if we should zip the data:
2004 QMessageBox mb( vymName,
2005 tr("The map %1\ndid not use the compressed "
2006 "vym file format.\nWriting it uncompressed will also write images \n"
2007 "and flags and thus may overwrite files in the "
2008 "given directory\n\nDo you want to write the map").arg(fn),
2009 QMessageBox::Warning,
2010 QMessageBox::Yes | QMessageBox::Default,
2012 QMessageBox::Cancel | QMessageBox::Escape);
2013 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2014 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2015 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2018 case QMessageBox::Yes:
2019 // save compressed (default file format)
2022 case QMessageBox::No:
2023 // save uncompressed
2026 case QMessageBox::Cancel:
2035 // Create temporary directory for packing
2037 QString tmpMapDir=makeTmpDir (ok,"vym-zip");
2040 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2041 tr("Couldn't create temporary directory before save\n"));
2045 safeFilePath=me->getFilePath();
2046 me->setFilePath (tmpMapDir+"/"+
2047 me->getMapName()+ ".xml",
2049 me->save (savemode);
2050 me->setFilePath (safeFilePath);
2052 zipDir (tmpMapDir,fn);
2057 safeFilePath=me->getFilePath();
2058 me->setFilePath (fn, safeFilePath);
2059 me->save (savemode);
2060 me->setFilePath (safeFilePath);
2062 } // filepath available
2065 // We have no filepath yet,
2066 // call fileSaveAs() now, this will call fileSave()
2068 // First switch to editor
2069 tabWidget->setCurrentWidget (me);
2070 fileSaveAs(savemode);
2074 if (saveZipped && !tmpMapDir.isEmpty())
2076 removeDir (QDir(tmpMapDir));
2080 statusBar()->message(
2081 tr("Saved %1").arg(me->getFilePath()),
2083 addRecentMap (me->getFilePath() );
2085 statusBar()->message(
2086 tr("Couldn't save ").arg(me->getFilePath()),
2090 void Main::fileSave()
2092 fileSave (currentMapEditor(), CompleteMap);
2095 void Main::fileSave(MapEditor *me)
2097 fileSave (me,CompleteMap);
2100 void Main::fileSaveAs(const SaveMode& savemode)
2104 if (currentMapEditor())
2106 if (savemode==CompleteMap)
2107 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2109 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2110 if ( !fn.isEmpty() )
2112 // Check for existing file
2113 if (QFile (fn).exists())
2115 QMessageBox mb( vymName,
2116 tr("The file %1\nexists already. Do you want to").arg(fn),
2117 QMessageBox::Warning,
2118 QMessageBox::Yes | QMessageBox::Default,
2119 QMessageBox::Cancel | QMessageBox::Escape,
2120 QMessageBox::NoButton);
2121 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2122 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2125 case QMessageBox::Yes:
2128 case QMessageBox::Cancel:
2135 // New file, add extension to filename, if missing
2136 // This is always .vym or .vyp, depending on savemode
2137 if (savemode==CompleteMap)
2139 if (!fn.contains (".vym") && !fn.contains (".xml"))
2143 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2152 currentMapEditor()->setFilePath(fn);
2153 fileSave(currentMapEditor(), savemode);
2156 if (savemode==CompleteMap)
2157 tabWidget->setTabLabel (currentMapEditor(),
2158 currentMapEditor()->getFileName() );
2164 void Main::fileSaveAs()
2166 fileSaveAs (CompleteMap);
2169 void Main::fileImportKDEBookmarks()
2171 ImportKDEBookmarks im;
2173 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2174 currentMapEditor()->setFilePath ("");
2177 void Main::fileImportFirefoxBookmarks()
2179 Q3FileDialog *fd=new Q3FileDialog( this);
2180 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2181 fd->setMode (Q3FileDialog::ExistingFiles);
2182 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2183 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2186 if ( fd->exec() == QDialog::Accepted )
2188 ImportFirefoxBookmarks im;
2189 QStringList flist = fd->selectedFiles();
2190 QStringList::Iterator it = flist.begin();
2191 while( it != flist.end() )
2194 if (im.transform() &&
2195 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2196 currentMapEditor() )
2197 currentMapEditor()->setFilePath ("");
2204 void Main::fileImportFreemind()
2206 QStringList filters;
2207 filters <<"Freemind map (*.mm)"<<"All files (*)";
2208 QFileDialog *fd=new QFileDialog( this);
2209 fd->setDir (lastFileDir);
2210 fd->setFileMode (QFileDialog::ExistingFiles);
2211 fd->setFilters (filters);
2212 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2216 if ( fd->exec() == QDialog::Accepted )
2218 lastFileDir=fd->directory().path();
2219 QStringList flist = fd->selectedFiles();
2220 QStringList::Iterator it = flist.begin();
2221 while( it != flist.end() )
2224 if ( fileLoad (fn,NewMap, FreemindMap) )
2226 currentMapEditor()->setFilePath ("");
2235 void Main::fileImportMM()
2239 Q3FileDialog *fd=new Q3FileDialog( this);
2240 fd->setDir (lastFileDir);
2241 fd->setMode (Q3FileDialog::ExistingFiles);
2242 fd->addFilter ("Mind Manager (*.mmap)");
2243 fd->setCaption(tr("Import")+" "+"Mind Manager");
2246 if ( fd->exec() == QDialog::Accepted )
2248 lastFileDir=fd->dirPath();
2249 QStringList flist = fd->selectedFiles();
2250 QStringList::Iterator it = flist.begin();
2251 while( it != flist.end() )
2254 if (im.transform() &&
2255 success==fileLoad (im.getTransformedFile(),NewMap) &&
2256 currentMapEditor() )
2257 currentMapEditor()->setFilePath ("");
2266 void Main::fileImportDir()
2268 if (currentMapEditor())
2269 currentMapEditor()->importDir();
2272 void Main::fileExportXML()
2274 MapEditor *me=currentMapEditor();
2275 if (me) me->exportXML();
2279 void Main::fileExportXHTML()
2281 MapEditor *me=currentMapEditor();
2282 if (me) me->exportXHTML();
2285 void Main::fileExportImage()
2287 MapEditor *me=currentMapEditor();
2288 if (me) me->exportImage();
2291 void Main::fileExportASCII()
2293 MapEditor *me=currentMapEditor();
2294 if (me) me->exportASCII();
2297 void Main::fileExportCSV() //FIXME not scriptable yet
2299 MapEditor *me=currentMapEditor();
2303 ex.setMapCenter(me->getMapCenter());
2304 ex.addFilter ("CSV (*.csv)");
2305 ex.setDir(lastImageDir);
2306 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2307 if (ex.execDialog() )
2309 me->setExportMode(true);
2311 me->setExportMode(false);
2316 void Main::fileExportLaTeX() //FIXME not scriptable yet
2318 MapEditor *me=currentMapEditor();
2322 ex.setMapCenter(me->getMapCenter());
2323 ex.addFilter ("Tex (*.tex)");
2324 ex.setDir(lastImageDir);
2325 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2326 if (ex.execDialog() )
2328 me->setExportMode(true);
2330 me->setExportMode(false);
2335 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2337 ExportKDEBookmarks ex;
2338 MapEditor *me=currentMapEditor();
2341 ex.setMapCenter (me->getMapCenter() );
2346 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2348 ExportTaskjuggler ex;
2349 MapEditor *me=currentMapEditor();
2352 ex.setMapCenter (me->getMapCenter() );
2353 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2354 ex.setDir(lastImageDir);
2355 ex.addFilter ("Taskjuggler (*.tjp)");
2356 if (ex.execDialog() )
2358 me->setExportMode(true);
2360 me->setExportMode(false);
2365 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2367 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2368 // TODO add preview in dialog
2369 //ImagePreview *p =new ImagePreview (fd);
2370 //fd->setContentsPreviewEnabled( TRUE );
2371 //fd->setContentsPreview( p, p );
2372 //fd->setPreviewMode( QFileDialog::Contents );
2373 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2374 fd->setDir (QDir().current());
2375 if (fd->foundConfig())
2379 if ( fd->exec() == QDialog::Accepted )
2381 QString fn=fd->selectedFile();
2382 if (!fn.contains (".odp"))
2385 //lastImageDir=fn.left(fn.findRev ("/"));
2386 if (currentMapEditor())
2387 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2391 QMessageBox::warning(0,
2393 tr("Couldn't find configuration for export to Open Office\n"));
2397 void Main::fileCloseMap()
2399 if (currentMapEditor())
2401 if (currentMapEditor()->hasChanged())
2403 QMessageBox mb( vymName,
2404 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2405 QMessageBox::Warning,
2406 QMessageBox::Yes | QMessageBox::Default,
2408 QMessageBox::Cancel | QMessageBox::Escape );
2409 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2410 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2413 case QMessageBox::Yes:
2415 fileSave(currentMapEditor(), CompleteMap);
2417 case QMessageBox::No:
2418 // close without saving
2420 case QMessageBox::Cancel:
2425 currentMapEditor()->closeMap();
2426 tabWidget->removePage(currentMapEditor());
2427 if (tabWidget->count()==0)
2428 actionFilePrint->setEnabled (false);
2432 void Main::filePrint()
2434 if (currentMapEditor())
2435 currentMapEditor()->print();
2438 void Main::fileExitVYM()
2440 // Check if one or more editors have changed
2443 for (i=0;i<=tabWidget->count() -1;i++)
2446 me=(MapEditor*)tabWidget->page(i);
2448 // If something changed, ask what to do
2449 if (me->hasChanged())
2451 tabWidget->setCurrentPage(i);
2452 QMessageBox mb( vymName,
2453 tr("This map is not saved yet. Do you want to"),
2454 QMessageBox::Warning,
2455 QMessageBox::Yes | QMessageBox::Default,
2457 QMessageBox::Cancel | QMessageBox::Escape );
2458 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2459 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2462 mb.setActiveWindow();
2463 switch( mb.exec() ) {
2464 case QMessageBox::Yes:
2465 // save (the changed editors) and exit
2466 fileSave(currentMapEditor(), CompleteMap);
2468 case QMessageBox::No:
2469 // exit without saving
2471 case QMessageBox::Cancel:
2472 // don't save and don't exit
2476 } // loop over all MEs
2480 void Main::editUndo()
2482 if (currentMapEditor())
2483 currentMapEditor()->undo();
2486 void Main::editRedo()
2488 if (currentMapEditor())
2489 currentMapEditor()->redo();
2492 void Main::gotoHistoryStep (int i)
2494 if (currentMapEditor())
2495 currentMapEditor()->gotoHistoryStep (i);
2498 void Main::editCopy()
2500 if (currentMapEditor())
2501 currentMapEditor()->copy();
2504 void Main::editPaste()
2506 if (currentMapEditor())
2507 currentMapEditor()->paste();
2510 void Main::editCut()
2512 if (currentMapEditor())
2513 currentMapEditor()->cut();
2516 void Main::editOpenFindWindow()
2518 findWindow->popup();
2519 findWindow->raise();
2520 findWindow->setActiveWindow();
2523 void Main::editFind(QString s)
2526 BranchObj *bo=currentMapEditor()->findText(s, cs);
2529 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2532 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2533 tr("No matches found for \"%1\"").arg(s));
2537 void Main::editFindChanged()
2538 { // Notify editor, to abort the current find process
2539 currentMapEditor()->findReset();
2542 void Main::openTabs(QStringList urls)
2544 if (!urls.isEmpty())
2548 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2550 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2552 QString u=urls.takeFirst();
2553 procBrowser = new QProcess( this );
2555 procBrowser->start(browser,args);
2556 if ( !procBrowser->waitForStarted())
2558 // try to set path to browser
2559 QMessageBox::warning(0,
2561 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2562 tr("Please use Settings->")+tr("Set application to open an URL"));
2565 #if defined(Q_OS_WIN32)
2566 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2567 this->thread()->wait(3000);
2572 if (browser.contains("konqueror"))
2574 for (int i=0; i<urls.size(); i++)
2577 // Try to open new tab in existing konqueror started previously by vym
2578 p=new QProcess (this);
2580 #if defined(Q_OS_WIN32)
2581 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2582 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2583 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2584 "konqueror-mainwindow#1"<<
2588 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2589 "konqueror-mainwindow#1"<<
2593 p->start ("dcop",args);
2594 cout << args.join(" ").ascii()<<endl;
2595 if ( !p->waitForStarted() ) success=false;
2598 QMessageBox::warning(0,
2600 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2602 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2604 for (int i=0; i<urls.size(); i++)
2606 // Try to open new tab in firefox
2607 p=new QProcess (this);
2608 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2609 p->start (browser,args);
2610 if ( !p->waitForStarted() ) success=false;
2613 QMessageBox::warning(0,
2615 tr("Couldn't start %1 to open a new tab").arg(browser));
2618 QMessageBox::warning(0,
2620 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2624 void Main::editOpenURL()
2627 if (currentMapEditor())
2629 QString url=currentMapEditor()->getURL();
2631 if (url=="") return;
2632 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2633 procBrowser = new QProcess( this );
2635 procBrowser->start(browser,args);
2636 if ( !procBrowser->waitForStarted())
2638 // try to set path to browser
2639 QMessageBox::warning(0,
2641 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2642 tr("Please use Settings->")+tr("Set application to open an URL"));
2647 void Main::editOpenURLTab()
2649 if (currentMapEditor())
2652 urls.append(currentMapEditor()->getURL());
2656 void Main::editOpenMultipleURLTabs()
2658 if (currentMapEditor())
2661 urls=currentMapEditor()->getURLs();
2667 void Main::editURL()
2669 if (currentMapEditor())
2670 currentMapEditor()->editURL();
2673 void Main::editLocalURL()
2675 if (currentMapEditor())
2676 currentMapEditor()->editLocalURL();
2679 void Main::editHeading2URL()
2681 if (currentMapEditor())
2682 currentMapEditor()->editHeading2URL();
2685 void Main::editBugzilla2URL()
2687 if (currentMapEditor())
2688 currentMapEditor()->editBugzilla2URL();
2691 void Main::editFATE2URL()
2693 if (currentMapEditor())
2694 currentMapEditor()->editFATE2URL();
2697 void Main::editHeadingFinished()
2699 // only called from editHeading(), so there is a currentME
2700 MapEditor *me=currentMapEditor();
2703 me->setStateEditHeading (false);
2704 QPoint p; //Not used here, only to find out pos of branch
2706 QString s=me->getHeading(ok,p);
2708 #if defined(Q_OS_MACX)
2710 if (ok && s!=lineedit->text())
2711 me->setHeading(lineedit->text());
2713 lineedit->releaseKeyboard();
2717 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2718 !prevSelection.isEmpty())
2719 me->select(prevSelection);
2724 void Main::editHeading()
2726 if (currentMapEditor())
2728 MapEditor *me=currentMapEditor();
2729 QString oldSel=me->getSelectString();
2731 if (lineedit->isVisible())
2732 editHeadingFinished();
2737 QString s=me->getHeading(ok,p);
2741 me->setStateEditHeading (true);
2742 #if defined(Q_OS_MACX)
2743 p=me->mapToGlobal (p);
2744 QDialog *d =new QDialog(NULL);
2745 QLineEdit *le=new QLineEdit (d);
2746 d->setWindowFlags (Qt::FramelessWindowHint);
2747 d->setGeometry(p.x(),p.y(),230,25);
2748 le->resize (d->width()-10,d->height());
2751 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2752 d->activateWindow();
2754 me->setHeading (le->text());
2757 editHeadingFinished();
2759 p=me->mapTo (this,p);
2760 lineedit->setGeometry(p.x(),p.y(),230,25);
2761 lineedit->setText(s);
2762 lineedit->setCursorPosition(1);
2763 lineedit->selectAll();
2765 lineedit->grabKeyboard();
2766 lineedit->setFocus();
2770 } // currentMapEditor()
2773 void Main::openVymLinks(const QStringList &vl)
2775 for (int j=0; j<vl.size(); j++)
2777 // compare path with already loaded maps
2781 for (i=0;i<=tabWidget->count() -1;i++)
2783 me=(MapEditor*)tabWidget->page(i);
2784 if (vl.at(j)==me->getFilePath() )
2793 if (!QFile(vl.at(j)).exists() )
2794 QMessageBox::critical( 0, tr( "Critical Error" ),
2795 tr("Couldn't open map %1").arg(vl.at(j)));
2798 fileLoad (vl.at(j), NewMap);
2799 tabWidget->setCurrentPage (tabWidget->count()-1);
2802 // Go to tab containing the map
2803 tabWidget->setCurrentPage (index);
2807 void Main::editOpenVymLink()
2809 if (currentMapEditor())
2812 vl.append(currentMapEditor()->getVymLink());
2817 void Main::editOpenMultipleVymLinks()
2819 QString currentVymLink;
2820 if (currentMapEditor())
2822 QStringList vl=currentMapEditor()->getVymLinks();
2827 void Main::editVymLink()
2829 if (currentMapEditor())
2830 currentMapEditor()->editVymLink();
2833 void Main::editDeleteVymLink()
2835 if (currentMapEditor())
2836 currentMapEditor()->deleteVymLink();
2839 void Main::editToggleHideExport()
2841 if (currentMapEditor())
2842 currentMapEditor()->toggleHideExport();
2845 void Main::editMapInfo()
2847 if (currentMapEditor())
2848 currentMapEditor()->editMapInfo();
2851 void Main::editMoveUp()
2853 if (currentMapEditor())
2854 currentMapEditor()->moveBranchUp();
2857 void Main::editMoveDown()
2859 if (currentMapEditor())
2860 currentMapEditor()->moveBranchDown();
2863 void Main::editSortChildren()
2865 if (currentMapEditor())
2866 currentMapEditor()->sortChildren();
2869 void Main::editToggleScroll()
2871 if (currentMapEditor())
2873 currentMapEditor()->toggleScroll();
2877 void Main::editUnscrollChilds()
2879 if (currentMapEditor())
2880 currentMapEditor()->unscrollChilds();
2883 void Main::editNewBranch()
2885 MapEditor *me=currentMapEditor();
2886 if (!lineedit->isVisible() && me)
2888 BranchObj *bo=(BranchObj*)me->getSelection();
2889 BranchObj *newbo=me->addNewBranch(0);
2891 prevSelection=bo->getSelectString();
2893 me->select (newbo->getSelectString());
2897 if (actionSettingsAutoEditNewBranch->isOn())
2902 if (!prevSelection.isEmpty())
2904 me->select(prevSelection);
2911 void Main::editNewBranchBefore()
2913 MapEditor *me=currentMapEditor();
2914 if (!lineedit->isVisible() && me)
2916 BranchObj *bo=(BranchObj*)me->getSelection();
2917 BranchObj *newbo=me->addNewBranchBefore();
2920 me->select (newbo->getSelectString());
2924 if (actionSettingsAutoEditNewBranch->isOn())
2926 if (!actionSettingsAutoSelectNewBranch->isOn())
2927 prevSelection=bo->getSelectString();
2933 void Main::editNewBranchAbove()
2935 MapEditor *me=currentMapEditor();
2936 if (!lineedit->isVisible() && me)
2938 BranchObj *bo=(BranchObj*)me->getSelection();
2939 BranchObj *newbo=me->addNewBranch (-1);
2942 me->select (newbo->getSelectString());
2946 if (actionSettingsAutoEditNewBranch->isOn())
2948 if (!actionSettingsAutoSelectNewBranch->isOn())
2949 prevSelection=bo->getSelectString();
2955 void Main::editNewBranchBelow()
2957 MapEditor *me=currentMapEditor();
2958 if (!lineedit->isVisible() && me)
2960 BranchObj *bo=(BranchObj*)me->getSelection();
2961 BranchObj *newbo=me->addNewBranch (1);
2964 me->select (newbo->getSelectString());
2968 if (actionSettingsAutoEditNewBranch->isOn())
2970 if (!actionSettingsAutoSelectNewBranch->isOn())
2971 prevSelection=bo->getSelectString();
2977 void Main::editImportAdd()
2979 fileLoad (ImportAdd);
2982 void Main::editImportReplace()
2984 fileLoad (ImportReplace);
2987 void Main::editSaveBranch()
2989 fileSaveAs (PartOfMap);
2992 void Main::editDeleteKeepChilds()
2994 if (currentMapEditor())
2995 currentMapEditor()->deleteKeepChilds();
2998 void Main::editDeleteChilds()
3000 if (currentMapEditor())
3001 currentMapEditor()->deleteChilds();
3004 void Main::editDeleteSelection()
3006 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3007 currentMapEditor()->deleteSelection();
3010 void Main::editUpperBranch()
3012 if (currentMapEditor())
3013 currentMapEditor()->selectUpperBranch();
3016 void Main::editLowerBranch()
3018 if (currentMapEditor())
3019 currentMapEditor()->selectLowerBranch();
3022 void Main::editLeftBranch()
3024 if (currentMapEditor())
3025 currentMapEditor()->selectLeftBranch();
3028 void Main::editRightBranch()
3030 if (currentMapEditor())
3031 currentMapEditor()->selectRightBranch();
3034 void Main::editFirstBranch()
3036 if (currentMapEditor())
3037 currentMapEditor()->selectFirstBranch();
3040 void Main::editLastBranch()
3042 if (currentMapEditor())
3043 currentMapEditor()->selectLastBranch();
3046 void Main::editLoadImage()
3048 if (currentMapEditor())
3049 currentMapEditor()->loadFloatImage();
3052 void Main::editSaveImage()
3054 if (currentMapEditor())
3055 currentMapEditor()->saveFloatImage();
3058 void Main::editFollowXLink(QAction *a)
3061 if (currentMapEditor())
3062 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3065 void Main::editEditXLink(QAction *a)
3067 if (currentMapEditor())
3068 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3071 void Main::formatSelectColor()
3073 if (currentMapEditor())
3075 QColor col = QColorDialog::getColor((currentColor ), this );
3076 if ( !col.isValid() ) return;
3077 colorChanged( col );
3081 void Main::formatPickColor()
3083 if (currentMapEditor())
3084 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3087 void Main::colorChanged(QColor c)
3089 QPixmap pix( 16, 16 );
3091 actionFormatColor->setIconSet( pix );
3095 void Main::formatColorBranch()
3097 if (currentMapEditor())
3098 currentMapEditor()->colorBranch(currentColor);
3101 void Main::formatColorSubtree()
3103 if (currentMapEditor())
3104 currentMapEditor()->colorSubtree (currentColor);
3107 void Main::formatLinkStyleLine()
3109 if (currentMapEditor())
3110 currentMapEditor()->setMapLinkStyle("StyleLine");
3113 void Main::formatLinkStyleParabel()
3115 if (currentMapEditor())
3116 currentMapEditor()->setMapLinkStyle("StyleParabel");
3119 void Main::formatLinkStylePolyLine()
3121 if (currentMapEditor())
3122 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3125 void Main::formatLinkStylePolyParabel()
3127 if (currentMapEditor())
3128 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3131 void Main::formatSelectBackColor()
3133 if (currentMapEditor())
3134 currentMapEditor()->selectMapBackgroundColor();
3137 void Main::formatSelectBackImage()
3139 if (currentMapEditor())
3140 currentMapEditor()->selectMapBackgroundImage();
3143 void Main::formatSelectLinkColor()
3145 if (currentMapEditor())
3146 currentMapEditor()->selectMapLinkColor();
3149 void Main::formatSelectSelectionColor()
3151 if (currentMapEditor())
3152 currentMapEditor()->selectMapSelectionColor();
3155 void Main::formatToggleLinkColorHint()
3157 currentMapEditor()->toggleMapLinkColorHint();
3161 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3163 if (currentMapEditor())
3164 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3167 void Main::viewZoomReset()
3169 if (currentMapEditor())
3173 currentMapEditor()->setMatrix( m );
3177 void Main::viewZoomIn()
3179 if (currentMapEditor())
3181 QMatrix m = currentMapEditor()->matrix();
3182 m.scale( 1.25, 1.25 );
3183 currentMapEditor()->setMatrix( m );
3187 void Main::viewZoomOut()
3189 if (currentMapEditor())
3191 QMatrix m = currentMapEditor()->matrix();
3192 m.scale( 0.8, 0.8 );
3193 currentMapEditor()->setMatrix( m );
3197 void Main::viewCenter()
3199 MapEditor *me=currentMapEditor();
3202 me->ensureSelectionVisible();
3206 void Main::networkStartServer()
3208 MapEditor *me=currentMapEditor();
3209 if (me) me->newServer();
3212 void Main::networkConnect()
3214 MapEditor *me=currentMapEditor();
3215 if (me) me->connectToServer();
3218 bool Main::settingsPDF()
3220 // Default browser is set in constructor
3222 QString text = QInputDialog::getText(
3223 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3224 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3226 settings.setValue ("/mainwindow/readerPDF",text);
3231 bool Main::settingsURL()
3233 // Default browser is set in constructor
3235 QString text = QInputDialog::getText(
3236 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3237 settings.value("/mainwindow/readerURL").toString()
3240 settings.setValue ("/mainwindow/readerURL",text);
3244 void Main::settingsMacroDir()
3246 QDir defdir=vymBaseDir;
3247 defdir.cd("macros");
3248 if (!defdir.exists())
3250 QDir dir=QFileDialog::getExistingDirectory (
3252 tr ("Directory with vym macros:"),
3253 settings.value ("/macros/macroDir",defdir.path()).toString()
3256 settings.setValue ("/macros/macroDir",dir.path());
3259 void Main::settingsUndoLevels()
3262 int i = QInputDialog::getInteger(
3264 tr("QInputDialog::getInteger()"),
3265 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3268 settings.setValue ("/mapeditor/stepsTotal",i);
3269 QMessageBox::information( this, tr( "VYM -Information:" ),
3270 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3274 void Main::settingsAutosaveToggle()
3276 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3279 void Main::settingsAutosaveTime()
3282 int i = QInputDialog::getInteger(
3284 tr("QInputDialog::getInteger()"),
3285 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3288 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3292 void Main::settingsToggleDelKey()
3294 if (actionSettingsUseDelKey->isOn())
3296 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3299 actionEditDelete->setAccel (QKeySequence (""));
3303 void Main::windowToggleNoteEditor()
3305 if (textEditor->isVisible() )
3306 windowHideNoteEditor();
3308 windowShowNoteEditor();
3311 void Main::windowToggleHistory()
3313 if (historyWindow->isVisible())
3314 historyWindow->hide();
3316 historyWindow->show();
3320 void Main::windowToggleProperty()
3322 if (branchPropertyWindow->isVisible())
3323 branchPropertyWindow->hide();
3325 branchPropertyWindow->show();
3327 if(currentMapEditor())
3329 LinkableMapObj *sel=currentMapEditor()->getSelection();
3330 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3331 typeid(*sel) == typeid(MapCenterObj)))
3333 branchPropertyWindow->setMapEditor(currentMapEditor());
3334 branchPropertyWindow->setBranch((BranchObj*)sel);
3339 branchPropertyWindow->setBranch(NULL);
3342 void Main::windowToggleAntiAlias()
3344 bool b=actionViewToggleAntiAlias->isOn();
3346 for (int i=0;i<tabWidget->count();i++)
3349 me=(MapEditor*)tabWidget->page(i);
3350 me->setAntiAlias(b);
3355 void Main::windowToggleSmoothPixmap()
3357 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3359 for (int i=0;i<tabWidget->count();i++)
3362 me=(MapEditor*)tabWidget->page(i);
3363 me->setSmoothPixmap(b);
3367 void Main::updateHistory(SimpleSettings &undoSet)
3369 historyWindow->update (undoSet);
3372 void Main::updateNoteFlag()
3374 if (currentMapEditor())
3375 currentMapEditor()->updateNoteFlag();
3378 void Main::updateSatellites(MapEditor *me)
3380 branchPropertyWindow->setMapEditor (me);
3383 void Main::updateActions()
3385 MapEditor *me=currentMapEditor();
3388 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3390 // updateActions is also called when NoteEditor is closed
3391 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3392 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3393 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3395 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3396 actionFormatLinkColorHint->setOn(true);
3398 actionFormatLinkColorHint->setOn(false);
3400 switch (me->getMapLinkStyle())
3402 case LinkableMapObj::Line:
3403 actionFormatLinkStyleLine->setOn(true);
3405 case LinkableMapObj::Parabel:
3406 actionFormatLinkStyleParabel->setOn(true);
3408 case LinkableMapObj::PolyLine:
3409 actionFormatLinkStylePolyLine->setOn(true);
3411 case LinkableMapObj::PolyParabel:
3412 actionFormatLinkStylePolyParabel->setOn(true);
3419 QPixmap pix( 16, 16 );
3420 pix.fill( me->getMapBackgroundColor() );
3421 actionFormatBackColor->setIconSet( pix );
3422 pix.fill( me->getSelectionColor() );
3423 actionFormatSelectionColor->setIconSet( pix );
3424 pix.fill( me->getMapDefLinkColor() );
3425 actionFormatLinkColor->setIconSet( pix );
3428 actionFileSave->setEnabled( me->hasChanged() );
3429 if (me->isUndoAvailable())
3430 actionEditUndo->setEnabled( true);
3432 actionEditUndo->setEnabled( false);
3434 if (me->isRedoAvailable())
3435 actionEditRedo->setEnabled( true);
3437 actionEditRedo->setEnabled( false);
3439 LinkableMapObj *selection=me->getSelection();
3442 if ( (typeid(*selection) == typeid(BranchObj)) ||
3443 (typeid(*selection) == typeid(MapCenterObj)) )
3445 BranchObj *bo=(BranchObj*)selection;
3446 // Take care of links
3447 if (bo->countXLinks()==0)
3449 branchXLinksContextMenuEdit->clear();
3450 branchXLinksContextMenuFollow->clear();
3455 branchXLinksContextMenuEdit->clear();
3456 branchXLinksContextMenuFollow->clear();
3457 for (int i=0; i<=bo->countXLinks();i++)
3459 bot=bo->XLinkTargetAt(i);
3462 s=bot->getHeading();
3463 if (s.length()>xLinkMenuWidth)
3464 s=s.left(xLinkMenuWidth)+"...";
3465 branchXLinksContextMenuFollow->addAction (s);
3466 branchXLinksContextMenuEdit->addAction (s);
3471 standardFlagsDefault->setEnabled (true);
3473 actionEditToggleScroll->setEnabled (true);
3474 if ( bo->isScrolled() )
3475 actionEditToggleScroll->setOn(true);
3477 actionEditToggleScroll->setOn(false);
3479 if ( bo->getURL().isEmpty() )
3481 actionEditOpenURL->setEnabled (false);
3482 actionEditOpenURLTab->setEnabled (false);
3486 actionEditOpenURL->setEnabled (true);
3487 actionEditOpenURLTab->setEnabled (true);
3489 if ( bo->getVymLink().isEmpty() )
3491 actionEditOpenVymLink->setEnabled (false);
3492 actionEditDeleteVymLink->setEnabled (false);
3495 actionEditOpenVymLink->setEnabled (true);
3496 actionEditDeleteVymLink->setEnabled (true);
3499 if (bo->canMoveBranchUp())
3500 actionEditMoveUp->setEnabled (true);
3502 actionEditMoveUp->setEnabled (false);
3503 if (bo->canMoveBranchDown())
3504 actionEditMoveDown->setEnabled (true);
3506 actionEditMoveDown->setEnabled (false);
3509 actionEditToggleHideExport->setEnabled (true);
3510 actionEditToggleHideExport->setOn (bo->hideInExport() );
3512 actionEditCopy->setEnabled (true);
3513 actionEditCut->setEnabled (true);
3514 if (!clipboardEmpty)
3515 actionEditPaste->setEnabled (true);
3517 actionEditPaste->setEnabled (false);
3518 for (int i=0; i<actionListBranches.size(); ++i)
3519 actionListBranches.at(i)->setEnabled(true);
3520 actionEditDelete->setEnabled (true);
3521 actionFormatHideLinkUnselected->setOn
3522 (selection->getHideLinkUnselected());
3524 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3526 FloatObj *fo=(FloatImageObj*)selection;
3528 actionEditOpenURL->setEnabled (false);
3529 actionEditOpenVymLink->setEnabled (false);
3530 actionEditDeleteVymLink->setEnabled (false);
3531 actionEditToggleHideExport->setEnabled (true);
3532 actionEditToggleHideExport->setOn (fo->hideInExport() );
3535 actionEditCopy->setEnabled (true);
3536 actionEditCut->setEnabled (true);
3537 actionEditPaste->setEnabled (false);
3538 for (int i=0; i<actionListBranches.size(); ++i)
3539 actionListBranches.at(i)->setEnabled(false);
3540 actionEditDelete->setEnabled (true);
3541 actionFormatHideLinkUnselected->setOn
3542 ( selection->getHideLinkUnselected());
3543 actionEditMoveUp->setEnabled (false);
3544 actionEditMoveDown->setEnabled (false);
3549 actionEditCopy->setEnabled (false);
3550 actionEditCut->setEnabled (false);
3551 actionEditPaste->setEnabled (false);
3552 for (int i=0; i<actionListBranches.size(); ++i)
3553 actionListBranches.at(i)->setEnabled(false);
3555 actionEditToggleScroll->setEnabled (false);
3556 actionEditOpenURL->setEnabled (false);
3557 actionEditOpenVymLink->setEnabled (false);
3558 actionEditDeleteVymLink->setEnabled (false);
3559 actionEditHeading2URL->setEnabled (false);
3560 actionEditDelete->setEnabled (false);
3561 actionEditMoveUp->setEnabled (false);
3562 actionEditMoveDown->setEnabled (false);
3563 actionEditToggleHideExport->setEnabled (false);
3567 Main::ModMode Main::getModMode()
3569 if (actionModModeColor->isOn()) return ModModeColor;
3570 if (actionModModeCopy->isOn()) return ModModeCopy;
3571 if (actionModModeXLink->isOn()) return ModModeXLink;
3575 bool Main::autoEditNewBranch()
3577 return actionSettingsAutoEditNewBranch->isOn();
3580 bool Main::autoSelectNewBranch()
3582 return actionSettingsAutoSelectNewBranch->isOn();
3585 bool Main::useFlagGroups()
3587 return actionSettingsUseFlagGroups->isOn();
3590 void Main::windowShowNoteEditor()
3592 textEditor->setShowWithMain(true);
3594 actionViewToggleNoteEditor->setOn (true);
3597 void Main::windowHideNoteEditor()
3599 textEditor->setShowWithMain(false);
3601 actionViewToggleNoteEditor->setOn (false);
3604 void Main::setScript (const QString &script)
3606 scriptEditor->setScript (script);
3609 void Main::runScript (const QString &script)
3611 if (currentMapEditor())
3612 currentMapEditor()->runScript (script);
3615 void Main::runScriptEverywhere (const QString &script)
3618 for (int i=0;i<=tabWidget->count() -1;i++)
3620 me=(MapEditor*)tabWidget->page(i);
3621 if (me) me->runScript (script);
3625 void Main::windowNextEditor()
3627 if (tabWidget->currentPageIndex() < tabWidget->count())
3628 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3631 void Main::windowPreviousEditor()
3633 if (tabWidget->currentPageIndex() >0)
3634 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3637 void Main::standardFlagChanged()
3639 if (currentMapEditor())
3640 currentMapEditor()->toggleStandardFlag(sender()->name());
3643 void Main::testFunction1()
3645 if (!currentMapEditor()) return;
3646 currentMapEditor()->testFunction1();
3649 void Main::testFunction2()
3651 if (!currentMapEditor()) return;
3652 currentMapEditor()->testFunction2();
3655 void Main::testCommand()
3657 if (!currentMapEditor()) return;
3658 scriptEditor->show();
3661 QString com = QInputDialog::getText(
3662 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3663 if (ok) currentMapEditor()->parseAtom(com);
3667 void Main::helpDoc()
3669 QString locale = QLocale::system().name();
3671 if (locale.left(2)=="es")
3672 docname="vym_es.pdf";
3676 QStringList searchList;
3678 #if defined(Q_OS_MACX)
3679 searchList << "./vym.app/Contents/Resources/doc";
3681 #if defined(VYM_DOCDIR)
3682 searchList << VYM_DOCDIR;
3684 // default path in SUSE LINUX
3685 searchList <<"/usr/share/doc/packages/vym";
3688 searchList << "doc"; // relative path for easy testing in tarball
3689 searchList << "doc/tex"; // Easy testing working on vym.tex
3690 searchList << "/usr/share/doc/vym"; // Debian
3691 searchList << "/usr/share/doc/packages";// Knoppix
3695 for (int i=0; i<searchList.count(); ++i)
3697 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3698 if (docfile.exists() )
3707 QMessageBox::critical(0,
3708 tr("Critcal error"),
3709 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3714 Process *pdfProc = new Process();
3715 args <<docfile.fileName();
3717 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3718 if ( !pdfProc->waitForStarted() )
3721 QMessageBox::warning(0,
3723 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3724 tr("Please use Settings->")+tr("Set application to open PDF files"));
3731 void Main::helpDemo()
3733 QStringList filters;
3734 filters <<"VYM example map (*.vym)";
3735 QFileDialog *fd=new QFileDialog( this);
3736 #if defined(Q_OS_MACX)
3737 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3739 // default path in SUSE LINUX
3740 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3743 fd->setFileMode (QFileDialog::ExistingFiles);
3744 fd->setFilters (filters);
3745 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3749 if ( fd->exec() == QDialog::Accepted )
3751 lastFileDir=fd->directory().path();
3752 QStringList flist = fd->selectedFiles();
3753 QStringList::Iterator it = flist.begin();
3754 while( it != flist.end() )
3757 fileLoad(*it, NewMap);
3765 void Main::helpAbout()
3768 ad.setName ("aboutwindow");
3769 ad.setMinimumSize(500,500);
3770 ad.resize (QSize (500,500));
3774 void Main::helpAboutQT()
3776 QMessageBox::aboutQt( this, "Qt Application Example" );
3779 void Main::callMacro ()
3781 QAction *action = qobject_cast<QAction *>(sender());
3785 i=action->data().toInt();
3786 QString mDir (settings.value ("macros/macroDir").toString() );
3788 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3790 if ( !f.open( QIODevice::ReadOnly ) )
3792 QMessageBox::warning(0,
3794 tr("Couldn't find a macro at %1.\n").arg(fn)+
3795 tr("Please use Settings->")+tr("Set directory for vym macros"));
3799 QTextStream ts( &f );
3800 QString m= ts.read();
3804 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3805 currentMapEditor()->runScript (m);
3812 //////////////////////////////////
3814 @@ -2544,18 +2576,27 @@
3815 // Try to open new tab in existing konqueror started previously by vym
3816 p=new QProcess (this);
3818 - args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3819 - "konqueror-mainwindow#1"<<
3821 +#if defined(Q_OS_WIN32)
3822 + // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
3823 + // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
3824 + args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
3825 + "konqueror-mainwindow#1"<<
3829 + args<< QString("konqueror-%1").arg(procBrowser->pid())<<
3830 + "konqueror-mainwindow#1"<<
3834 p->start ("dcop",args);
3835 if ( !p->waitForStarted() ) success=false;