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 extern TextEditor *textEditor;
24 extern Main *mainWindow;
25 extern QString tmpVymDir;
26 extern QString clipboardDir;
27 extern QString clipboardFile;
28 extern bool clipboardEmpty;
29 extern int statusbarTime;
30 extern FlagRowObj* standardFlagsDefault;
31 extern FlagRowObj* systemFlagsDefault;
32 extern QString vymName;
33 extern QString vymVersion;
34 extern QString vymBuildDate;
37 QMenu* branchContextMenu;
38 QMenu* branchAddContextMenu;
39 QMenu* branchRemoveContextMenu;
40 QMenu* branchLinksContextMenu;
41 QMenu* branchXLinksContextMenuEdit;
42 QMenu* branchXLinksContextMenuFollow;
43 QMenu* floatimageContextMenu;
44 QMenu* canvasContextMenu;
45 QMenu* fileLastMapsMenu;
46 QMenu* fileImportMenu;
47 QMenu* fileExportMenu;
50 extern Settings settings;
51 extern Options options;
52 extern ImageIO imageIO;
54 extern QDir vymBaseDir;
55 extern QDir lastImageDir;
56 extern QDir lastFileDir;
57 extern QString iconPath;
58 extern QString flagsPath;
60 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
61 QMainWindow(parent,name,f)
65 setCaption ("VYM - View Your Mind");
67 // Load window settings
68 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
69 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
72 // Sometimes we may need to remember old selections
76 currentColor=Qt::black;
78 // Create unique temporary directory
80 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
83 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
86 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
88 // Create direcctory for clipboard
89 clipboardDir=tmpVymDir+"/clipboard";
90 clipboardFile="map.xml";
92 d.mkdir (clipboardDir,true);
93 makeSubDirs (clipboardDir);
98 // Satellite windows //////////////////////////////////////////
101 historyWindow=new HistoryWindow();
102 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
105 branchPropertyWindow = new BranchPropertyWindow();
106 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
108 // Connect TextEditor, so that we can update flags if text changes
109 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
110 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
112 // Connect HistoryWindow, so that we can update flags
113 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
116 // Initialize script editor
117 scriptEditor = new SimpleScriptEditor();
118 scriptEditor->move (50,50);
120 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
121 this, SLOT( runScript( QString ) ) );
124 // Initialize Find window
125 findWindow=new FindWindow(NULL);
126 findWindow->move (x(),y()+70);
127 connect (findWindow, SIGNAL( findButton(QString) ),
128 this, SLOT(editFind(QString) ) );
129 connect (findWindow, SIGNAL( somethingChanged() ),
130 this, SLOT(editFindChanged() ) );
132 // Initialize some settings, which are platform dependant
135 // application to open URLs
136 p="/mainwindow/readerURL";
137 #if defined(Q_OS_LINUX)
138 s=settings.value (p,"konqueror").toString();
140 #if defined(Q_OS_MACX)
141 s=settings.value (p,"/usr/bin/open").toString();
143 s=settings.value (p,"mozilla");
146 settings.setValue( p,s);
148 // application to open PDFs
149 p="/mainwindow/readerPDF";
150 #if defined(Q_OS_LINUX)
151 s=settings.value (p,"acroread").toString();
153 #if defined(Q_OS_MACX)
154 s=settings.value (p,"/usr/bin/open").toString();
156 s=settings.value (p,"acroread").toString();
159 settings.setValue( p,s);
162 // Create tab widget which holds the maps
163 tabWidget= new QTabWidget (this);
164 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
165 this, SLOT( editorChanged( QWidget * ) ) );
167 lineedit=new QLineEdit (this);
170 setCentralWidget(tabWidget);
174 setupFormatActions();
178 setupNetworkActions();
179 setupSettingsActions();
182 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
187 restoreState (settings.value("/mainwindow/state",0).toByteArray());
195 settings.setValue ( "/mainwindow/geometry/size", size() );
196 settings.setValue ( "/mainwindow/geometry/pos", pos() );
197 settings.setValue ("/mainwindow/state",saveState(0));
199 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
200 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
201 settings.setValue( "/version/version", vymVersion );
202 settings.setValue( "/version/builddate", vymBuildDate );
204 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
205 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
206 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
207 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
208 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
209 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
210 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
212 //TODO save scriptEditor settings
214 // call the destructors
216 delete historyWindow;
217 delete branchPropertyWindow;
219 // Remove temporary directory
220 removeDir (QDir(tmpVymDir));
223 void Main::loadCmdLine()
225 /* TODO draw some kind of splashscreen while loading...
231 QStringList flist=options.getFileList();
232 QStringList::Iterator it=flist.begin();
234 while (it !=flist.end() )
236 fileLoad (*it, NewMap);
242 void Main::statusMessage(const QString &s)
244 statusBar()->message( s);
247 void Main::closeEvent (QCloseEvent* )
253 void Main::setupFileActions()
255 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
256 QToolBar *tb = addToolBar( tr ("&Map") );
257 tb->setObjectName ("mapTB");
260 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
261 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
262 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
264 fileMenu->addAction (a);
265 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
267 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
268 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
269 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
270 fileMenu->addAction (a);
271 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
273 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
274 a->setStatusTip (tr( "Open","Status tip File menu" ) );
275 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
277 fileMenu->addAction (a);
278 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
280 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
281 fileMenu->addSeparator();
283 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
284 a->setStatusTip ( tr( "Save","Status tip file menu" ));
285 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
287 fileMenu->addAction (a);
288 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
291 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
292 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
293 fileMenu->addAction (a);
294 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
296 fileMenu->addSeparator();
298 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
300 a = new QAction(tr("KDE Bookmarks"), this);
301 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
302 a->addTo (fileImportMenu);
303 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
305 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
307 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
308 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
309 a->addTo (fileImportMenu);
310 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
313 a = new QAction("Freemind...",this);
314 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
315 fileImportMenu->addAction (a);
316 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
318 a = new QAction("Mind Manager...",this);
319 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
320 fileImportMenu->addAction (a);
321 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
323 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
324 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
325 fileImportMenu->addAction (a);
326 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
328 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
330 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
331 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
333 fileExportMenu->addAction (a);
335 a = new QAction( "Open Office...", this);
336 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
338 fileExportMenu->addAction (a);
340 a = new QAction( "Webpage (XHTML)...",this );
341 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
342 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
343 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
344 fileExportMenu->addAction (a);
346 a = new QAction( "Text (ASCII)...", this);
347 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
349 fileExportMenu->addAction (a);
351 a = new QAction( "Spreadsheet (CSV)...", this);
352 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
353 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
354 fileExportMenu->addAction (a);
356 a = new QAction( tr("KDE Bookmarks","File menu"), this);
357 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
358 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
359 fileExportMenu->addAction (a);
361 a = new QAction( "Taskjuggler...", this );
362 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
363 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
364 fileExportMenu->addAction (a);
366 a = new QAction( "LaTeX...", this);
367 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
368 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
369 fileExportMenu->addAction (a);
371 a = new QAction( "XML..." , this );
372 a->setStatusTip (tr( "Export as %1").arg("XML"));
373 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
374 fileExportMenu->addAction (a);
376 fileMenu->addSeparator();
378 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
379 a->setStatusTip ( tr( "Print" ,"File menu") );
380 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
382 fileMenu->addAction (a);
383 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
386 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
387 a->setStatusTip (tr( "Close Map" ) );
388 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
389 fileMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
392 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
393 a->setStatusTip ( tr( "Exit")+" "+vymName );
394 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
395 fileMenu->addAction (a);
396 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
401 void Main::setupEditActions()
403 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
404 tb->setLabel( "Edit Actions" );
405 tb->setObjectName ("actionsTB");
406 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
410 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
411 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
412 a->setStatusTip (tr( "Undo" ) );
413 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
414 a->setEnabled (false);
416 editMenu->addAction (a);
419 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
420 a->setStatusTip (tr( "Redo" ));
421 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
423 editMenu->addAction (a);
424 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
427 editMenu->addSeparator();
428 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
429 a->setStatusTip ( tr( "Copy" ) );
430 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
431 a->setEnabled (false);
433 editMenu->addAction (a);
434 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
437 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
438 a->setStatusTip ( tr( "Cut" ) );
439 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
440 a->setEnabled (false);
442 editMenu->addAction (a);
444 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
446 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
447 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
448 a->setStatusTip ( tr( "Paste" ) );
449 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
450 a->setEnabled (false);
452 editMenu->addAction (a);
455 // Shortcuts to modify heading:
456 a = new QAction(tr( "Edit heading","Edit menu" ),this);
457 a->setStatusTip ( tr( "edit Heading" ));
458 a->setShortcut ( Qt::Key_Enter); //Edit heading
459 // a->setShortcutContext (Qt::WindowShortcut);
461 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
462 actionListBranches.append(a);
463 a = new QAction( tr( "Edit heading","Edit menu" ), this);
464 a->setStatusTip (tr( "edit Heading" ));
465 a->setShortcut (Qt::Key_Return ); //Edit heading
466 //a->setShortcutContext (Qt::WindowShortcut);
468 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
469 actionListBranches.append(a);
470 editMenu->addAction (a);
472 a = new QAction( tr( "Edit heading","Edit menu" ), this);
473 a->setStatusTip (tr( "edit Heading" ));
474 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
475 a->setShortcutContext (Qt::WindowShortcut);
477 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
478 actionListBranches.append(a);
480 // Shortcut to delete selection
481 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
482 a->setStatusTip (tr( "Delete Selection" ));
483 a->setShortcut ( Qt::Key_Delete); //Delete selection
484 a->setShortcutContext (Qt::WindowShortcut);
486 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
489 // Shortcut to add branch
490 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
491 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
492 alt->setShortcut (Qt::Key_A); //Add branch
493 alt->setShortcutContext (Qt::WindowShortcut);
495 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
496 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
497 a->setStatusTip ( tr( "Add a branch as child of selection" ));
498 a->setShortcut (Qt::Key_Insert); //Add branch
499 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
500 actionListBranches.append(a);
501 #if defined (Q_OS_MACX)
502 // In OSX show different shortcut in menues, the keys work indepently always
503 actionEditAddBranch=alt;
505 actionEditAddBranch=a;
507 editMenu->addAction (actionEditAddBranch);
508 tb->addAction (actionEditAddBranch);
511 // Add branch by inserting it at selection
512 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
513 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
514 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
515 a->setShortcutContext (Qt::WindowShortcut);
517 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
518 a->setEnabled (false);
519 actionListBranches.append(a);
520 actionEditAddBranchBefore=a;
521 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
522 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
523 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
524 a->setShortcutContext (Qt::WindowShortcut);
526 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
527 actionListBranches.append(a);
530 a = new QAction(tr( "Add branch above","Edit menu" ), this);
531 a->setStatusTip ( tr( "Add a branch above selection" ));
532 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
533 a->setShortcutContext (Qt::WindowShortcut);
535 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
536 a->setEnabled (false);
537 actionListBranches.append(a);
538 actionEditAddBranchAbove=a;
539 a = new QAction(tr( "Add branch above","Edit menu" ), this);
540 a->setStatusTip ( tr( "Add a branch above selection" ));
541 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
542 a->setShortcutContext (Qt::WindowShortcut);
544 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
545 actionListBranches.append(a);
548 a = new QAction(tr( "Add branch below","Edit menu" ), this);
549 a->setStatusTip ( tr( "Add a branch below selection" ));
550 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
551 a->setShortcutContext (Qt::WindowShortcut);
553 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
554 a->setEnabled (false);
555 actionListBranches.append(a);
556 actionEditAddBranchBelow=a;
557 a = new QAction(tr( "Add branch below","Edit menu" ), this);
558 a->setStatusTip ( tr( "Add a branch below selection" ));
559 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
560 a->setShortcutContext (Qt::WindowShortcut);
562 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
563 actionListBranches.append(a);
565 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
566 a->setStatusTip ( tr( "Move branch up" ) );
567 a->setShortcut (Qt::Key_PageUp ); // Move branch up
568 a->setEnabled (false);
570 editMenu->addAction (a);
571 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
574 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
575 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
576 a->setStatusTip (tr( "Move branch down" ) );
577 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
578 a->setEnabled (false);
580 editMenu->addAction (a);
581 actionEditMoveDown=a;
584 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
585 a->setShortcut ( Qt::Key_ScrollLock );
586 a->setStatusTip (tr( "Scroll branch" ) );
587 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
589 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
590 alt->setShortcut ( Qt::Key_S ); // Scroll branch
591 alt->setStatusTip (tr( "Scroll branch" ));
592 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
593 #if defined(Q_OS_MACX)
594 actionEditToggleScroll=alt;
596 actionEditToggleScroll=a;
598 actionEditToggleScroll->setEnabled (false);
599 actionEditToggleScroll->setToggleAction(true);
600 tb->addAction (actionEditToggleScroll);
601 editMenu->addAction ( actionEditToggleScroll);
602 editMenu->addAction (actionEditToggleScroll);
605 actionListBranches.append(actionEditToggleScroll);
607 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
608 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
609 editMenu->addAction (a);
610 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
612 editMenu->addSeparator();
614 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
615 a->setStatusTip (tr( "Find" ) );
616 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
617 editMenu->addAction (a);
618 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
620 editMenu->addSeparator();
622 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
623 a->setShortcut (Qt::CTRL + Qt::Key_U );
624 a->setShortcut (tr( "Open URL" ));
627 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
630 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
631 a->setStatusTip (tr( "Open URL in new tab" ));
632 //a->setShortcut (Qt::CTRL+Qt::Key_U );
634 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
635 actionEditOpenURLTab=a;
637 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
638 a->setStatusTip (tr( "Open all URLs in subtree" ));
640 actionListBranches.append(a);
641 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
642 actionEditOpenMultipleURLTabs=a;
644 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
645 a->setStatusTip ( tr( "Edit URL" ) );
646 //a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
647 a->setShortcut ( Qt::Key_U );
648 a->setShortcutContext (Qt::WindowShortcut);
649 actionListBranches.append(a);
651 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
654 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
655 a->setStatusTip ( tr( "Edit local URL" ) );
656 a->setShortcut (Qt::SHIFT + Qt::Key_U );
657 a->setShortcutContext (Qt::WindowShortcut);
658 actionListBranches.append(a);
660 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
663 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
664 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
665 a->setEnabled (false);
666 actionListBranches.append(a);
667 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
668 actionEditHeading2URL=a;
670 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
671 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
672 a->setEnabled (false);
673 actionListBranches.append(a);
674 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
675 actionEditBugzilla2URL=a;
677 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
678 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
679 a->setEnabled (false);
680 actionListBranches.append(a);
681 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
682 actionEditFATE2URL=a;
684 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
685 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
687 a->setEnabled (false);
688 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
689 actionEditOpenVymLink=a;
691 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
692 a->setStatusTip ( tr( "Open all vym links in subtree" ));
693 a->setEnabled (false);
694 actionListBranches.append(a);
695 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
696 actionEditOpenMultipleVymLinks=a;
699 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
700 a->setEnabled (false);
701 a->setStatusTip ( tr( "Edit link to another vym map" ));
702 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
703 actionListBranches.append(a);
706 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
707 a->setStatusTip ( tr( "Delete link to another vym map" ));
708 a->setEnabled (false);
709 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
710 actionEditDeleteVymLink=a;
712 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
713 a->setStatusTip ( tr( "Hide object in exports" ) );
714 a->setShortcut (Qt::Key_H );
715 a->setToggleAction(true);
717 a->setEnabled (false);
718 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
719 actionEditToggleHideExport=a;
721 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
722 a->setStatusTip ( tr( "Edit Map Info" ));
723 a->setEnabled (true);
724 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
727 // Import at selection (adding to selection)
728 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
729 a->setStatusTip (tr( "Add map at selection" ));
730 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
731 a->setEnabled (false);
732 actionListBranches.append(a);
733 actionEditImportAdd=a;
735 // Import at selection (replacing selection)
736 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
737 a->setStatusTip (tr( "Replace selection with map" ));
738 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
739 a->setEnabled (false);
740 actionListBranches.append(a);
741 actionEditImportReplace=a;
744 a = new QAction( tr( "Save selection","Edit menu" ), this);
745 a->setStatusTip (tr( "Save selection" ));
746 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
747 a->setEnabled (false);
748 actionListBranches.append(a);
749 actionEditSaveBranch=a;
751 // Only remove branch, not its childs
752 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
753 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
754 a->setShortcut (Qt::ALT + Qt::Key_Delete );
755 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
756 a->setEnabled (false);
758 actionListBranches.append(a);
759 actionEditDeleteKeepChilds=a;
761 // Only remove childs of a branch
762 a = new QAction( tr( "Remove childs","Edit menu" ), this);
763 a->setStatusTip (tr( "Remove childs of branch" ));
764 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
765 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
766 a->setEnabled (false);
767 actionListBranches.append(a);
768 actionEditDeleteChilds=a;
770 // Shortcuts for navigating with cursor:
771 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
772 a->setStatusTip ( tr( "Select upper branch" ));
773 a->setShortcut (Qt::Key_Up );
774 a->setShortcutContext (Qt::WindowShortcut);
776 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
777 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
778 a->setStatusTip (tr( "Select lower branch" ));
779 a->setShortcut ( Qt::Key_Down );
780 a->setShortcutContext (Qt::WindowShortcut);
782 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
783 a = new QAction(tr( "Select left branch","Edit menu" ), this);
784 a->setStatusTip ( tr( "Select left branch" ));
785 a->setShortcut (Qt::Key_Left );
786 a->setShortcutContext (Qt::WindowShortcut);
788 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
789 a = new QAction( tr( "Select child branch","Edit menu" ), this);
790 a->setStatusTip (tr( "Select right branch" ));
791 a->setShortcut (Qt::Key_Right);
792 a->setShortcutContext (Qt::WindowShortcut);
794 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
795 a = new QAction( tr( "Select first branch","Edit menu" ), this);
796 a->setStatusTip (tr( "Select first branch" ));
797 a->setShortcut (Qt::Key_Home );
798 a->setShortcutContext (Qt::WindowShortcut);
800 a->setEnabled (false);
801 editMenu->addAction (a);
802 actionListBranches.append(a);
803 actionEditSelectFirst=a;
804 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
805 a = new QAction( tr( "Select last branch","Edit menu" ),this);
806 a->setStatusTip (tr( "Select last branch" ));
807 a->setShortcut ( Qt::Key_End );
808 a->setShortcutContext (Qt::WindowShortcut);
810 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
811 a->setEnabled (false);
812 editMenu->addAction (a);
813 actionListBranches.append(a);
814 actionEditSelectLast=a;
816 a = new QAction( tr( "Add Image...","Edit menu" ), this);
817 a->setStatusTip (tr( "Add Image" ));
818 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
819 actionEditLoadImage=a;
821 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
822 a->setStatusTip (tr( "Set properties for selection" ));
823 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
824 a->setShortcutContext (Qt::WindowShortcut);
825 a->setToggleAction (true);
827 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
828 actionViewTogglePropertyWindow=a;
832 void Main::setupFormatActions()
834 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
836 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
837 tb->setObjectName ("formatTB");
840 pix.fill (Qt::black);
841 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
842 a->setStatusTip ( tr( "Set Color" ));
843 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
845 formatMenu->addAction (a);
847 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
848 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
849 a->setShortcut (Qt::CTRL + Qt::Key_K );
850 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
851 a->setEnabled (false);
853 formatMenu->addAction (a);
854 actionListBranches.append(a);
855 actionFormatPickColor=a;
857 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
858 a->setStatusTip ( tr( "Color branch" ) );
859 a->setShortcut (Qt::CTRL + Qt::Key_B);
860 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
861 a->setEnabled (false);
863 formatMenu->addAction (a);
864 actionListBranches.append(a);
865 actionFormatColorSubtree=a;
867 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
868 a->setStatusTip ( tr( "Color Subtree" ));
869 a->setShortcut (Qt::CTRL + Qt::Key_T);
870 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
871 a->setEnabled (false);
872 formatMenu->addAction (a);
874 actionListBranches.append(a);
875 actionFormatColorSubtree=a;
877 formatMenu->addSeparator();
878 actionGroupFormatLinkStyles=new QActionGroup ( this);
879 actionGroupFormatLinkStyles->setExclusive (true);
880 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
881 a->setStatusTip (tr( "Line" ));
882 a->setToggleAction(true);
883 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
884 formatMenu->addAction (a);
885 actionFormatLinkStyleLine=a;
886 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
887 a->setStatusTip (tr( "Line" ));
888 a->setToggleAction(true);
889 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
890 formatMenu->addAction (a);
891 actionFormatLinkStyleParabel=a;
892 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
893 a->setStatusTip (tr( "PolyLine" ));
894 a->setToggleAction(true);
895 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
896 formatMenu->addAction (a);
897 actionFormatLinkStylePolyLine=a;
898 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
899 a->setStatusTip (tr( "PolyParabel" ) );
900 a->setToggleAction(true);
901 a->setChecked (true);
902 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
903 formatMenu->addAction (a);
904 actionFormatLinkStylePolyParabel=a;
906 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
907 a->setStatusTip (tr( "Hide link" ));
908 a->setToggleAction(true);
909 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
910 actionFormatHideLinkUnselected=a;
912 formatMenu->addSeparator();
913 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
914 a->setStatusTip (tr( "Use same color for links and headings" ));
915 a->setToggleAction(true);
916 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
917 formatMenu->addAction (a);
918 actionFormatLinkColorHint=a;
920 pix.fill (Qt::white);
921 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
922 a->setStatusTip (tr( "Set Link Color" ));
923 formatMenu->addAction (a);
924 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
925 actionFormatLinkColor=a;
927 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
928 a->setStatusTip (tr( "Set Selection Color" ));
929 formatMenu->addAction (a);
930 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
931 actionFormatSelectionColor=a;
933 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
934 a->setStatusTip (tr( "Set Background Color" ));
935 formatMenu->addAction (a);
936 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
937 actionFormatBackColor=a;
939 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
940 a->setStatusTip (tr( "Set Background image" ));
941 formatMenu->addAction (a);
942 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
943 actionFormatBackImage=a;
947 void Main::setupViewActions()
949 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
950 tb->setLabel( "View Actions" );
951 tb->setObjectName ("viewTB");
952 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
955 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
956 a->setStatusTip ( tr( "Zoom reset" ) );
957 a->setShortcut (Qt::CTRL + Qt::Key_0 );
959 viewMenu->addAction (a);
960 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
962 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
963 a->setStatusTip (tr( "Zoom in" ));
964 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
966 viewMenu->addAction (a);
967 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
969 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
970 a->setStatusTip (tr( "Zoom out" ));
971 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
973 viewMenu->addAction (a);
974 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
976 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
977 a->setStatusTip (tr( "Show selection" ));
978 a->setShortcut (Qt::Key_Period);
980 viewMenu->addAction (a);
981 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
983 viewMenu->addSeparator();
985 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
986 a->setStatusTip ( tr( "Show Note Editor" ));
987 a->setShortcut ( Qt::CTRL + Qt::Key_E );
988 a->setToggleAction(true);
990 viewMenu->addAction (a);
991 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
992 actionViewToggleNoteEditor=a;
994 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
995 a->setStatusTip ( tr( "Show History Window" ));
996 a->setShortcut ( Qt::CTRL + Qt::Key_H );
997 a->setToggleAction(true);
999 viewMenu->addAction (a);
1000 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1001 actionViewToggleHistoryWindow=a;
1003 viewMenu->addAction (actionViewTogglePropertyWindow);
1005 viewMenu->addSeparator();
1007 a = new QAction(tr( "Antialiasing","View action" ),this );
1008 a->setStatusTip ( tr( "Antialiasing" ));
1009 a->setToggleAction(true);
1010 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1011 viewMenu->addAction (a);
1012 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1013 actionViewToggleAntiAlias=a;
1015 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1016 a->setStatusTip (a->text());
1017 a->setToggleAction(true);
1018 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1019 viewMenu->addAction (a);
1020 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1021 actionViewToggleSmoothPixmapTransform=a;
1023 a = new QAction(tr( "Next Map","View action" ), this);
1024 a->setStatusTip (a->text());
1025 a->setShortcut (Qt::ALT + Qt::Key_N );
1026 viewMenu->addAction (a);
1027 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1029 a = new QAction (tr( "Previous Map","View action" ), this );
1030 a->setStatusTip (a->text());
1031 a->setShortcut (Qt::ALT + Qt::Key_P );
1032 viewMenu->addAction (a);
1033 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1037 void Main::setupModeActions()
1039 //QPopupMenu *menu = new QPopupMenu( this );
1040 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1042 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1043 tb->setObjectName ("modesTB");
1045 actionGroupModModes=new QActionGroup ( this);
1046 actionGroupModModes->setExclusive (true);
1047 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1048 a->setShortcut (Qt::Key_J);
1049 a->setStatusTip ( tr( "Use modifier to color branches" ));
1050 a->setToggleAction(true);
1053 actionModModeColor=a;
1055 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1056 a->setShortcut( Qt::Key_K);
1057 a->setStatusTip( tr( "Use modifier to copy" ));
1058 a->setToggleAction(true);
1060 actionModModeCopy=a;
1062 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1063 a->setShortcut (Qt::Key_L);
1064 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1065 a->setToggleAction(true);
1067 actionModModeXLink=a;
1071 void Main::setupFlagActions()
1073 // Create System Flags
1074 systemFlagsDefault = new FlagRowObj ();
1075 systemFlagsDefault->setVisibility (false);
1076 systemFlagsDefault->setName ("systemFlagsDef");
1078 FlagObj *fo = new FlagObj ();
1079 fo->load(QPixmap(flagsPath+"flag-note.png"));
1080 fo->setName("note");
1081 fo->setToolTip(tr("Note","Systemflag"));
1082 systemFlagsDefault->addFlag (fo); // makes deep copy
1084 fo->load(QPixmap(flagsPath+"flag-url.png"));
1086 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1087 systemFlagsDefault->addFlag (fo);
1089 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1090 fo->setName("vymLink");
1091 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1092 systemFlagsDefault->addFlag (fo);
1094 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1095 fo->setName("scrolledright");
1096 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1097 systemFlagsDefault->addFlag (fo);
1099 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1100 fo->setName("tmpUnscrolledright");
1101 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1102 systemFlagsDefault->addFlag (fo);
1104 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1105 fo->setName("hideInExport");
1106 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1107 systemFlagsDefault->addFlag (fo);
1109 // Create Standard Flags
1110 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1111 tb->setObjectName ("standardFlagTB");
1113 standardFlagsDefault = new FlagRowObj ();
1114 standardFlagsDefault->setVisibility (false);
1115 standardFlagsDefault->setName ("standardFlagsDef");
1116 standardFlagsDefault->setToolBar (tb);
1118 fo->load(flagsPath+"flag-exclamationmark.png");
1119 fo->setName ("exclamationmark");
1120 fo->setGroup("standard-mark");
1121 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1124 a->setCheckable(true);
1125 a->setObjectName(fo->getName());
1126 a->setToolTip(tr("Take care!","Standardflag"));
1127 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1128 standardFlagsDefault->addFlag (fo); // makes deep copy
1130 fo->load(flagsPath+"flag-questionmark.png");
1131 fo->setName("questionmark");
1132 fo->setGroup("standard-mark");
1133 a=new QAction (fo->getPixmap(),fo->getName(),this);
1136 a->setCheckable(true);
1137 a->setObjectName(fo->getName());
1138 a->setToolTip(tr("Really?","Standardflag"));
1139 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1140 standardFlagsDefault->addFlag (fo);
1142 fo->load(flagsPath+"flag-hook-green.png");
1143 fo->setName("hook-green");
1144 fo->setGroup("standard-hook");
1145 a=new QAction (fo->getPixmap(),fo->getName(),this);
1148 a->setCheckable(true);
1149 a->setObjectName(fo->getName());
1150 a->setToolTip(tr("ok!","Standardflag"));
1151 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1152 standardFlagsDefault->addFlag (fo);
1154 fo->load(flagsPath+"flag-cross-red.png");
1155 fo->setName("cross-red");
1156 fo->setGroup("standard-hook");
1157 a=new QAction (fo->getPixmap(),fo->getName(),this);
1160 a->setCheckable(true);
1161 a->setObjectName(fo->getName());
1162 a->setToolTip(tr("Not ok!","Standardflag"));
1163 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1164 standardFlagsDefault->addFlag (fo);
1166 fo->load(flagsPath+"flag-stopsign.png");
1167 fo->setName("stopsign");
1168 a=new QAction (fo->getPixmap(),fo->getName(),this);
1171 a->setCheckable(true);
1172 a->setObjectName(fo->getName());
1173 a->setToolTip(tr("This won't work!","Standardflag"));
1174 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1175 standardFlagsDefault->addFlag (fo);
1177 fo->load(flagsPath+"flag-smiley-good.png");
1178 fo->setName("smiley-good");
1179 fo->setGroup("standard-smiley");
1180 a=new QAction (fo->getPixmap(),fo->getName(),this);
1183 a->setCheckable(true);
1184 a->setObjectName(fo->getName());
1185 a->setToolTip(tr("Good","Standardflag"));
1186 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1187 standardFlagsDefault->addFlag (fo);
1189 fo->load(flagsPath+"flag-smiley-sad.png");
1190 fo->setName("smiley-sad");
1191 fo->setGroup("standard-smiley");
1192 a=new QAction (fo->getPixmap(),fo->getName(),this);
1195 a->setCheckable(true);
1196 a->setObjectName(fo->getName());
1197 a->setToolTip(tr("Bad","Standardflag"));
1198 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1199 standardFlagsDefault->addFlag (fo);
1201 fo->load(flagsPath+"flag-smiley-omg.png");
1202 // Original omg.png (in KDE emoticons)
1203 fo->setName("smiley-omg");
1204 fo->setGroup("standard-smiley");
1205 a=new QAction (fo->getPixmap(),fo->getName(),this);
1208 a->setCheckable(true);
1209 a->setObjectName(fo->getName());
1210 a->setToolTip(tr("Oh no!","Standardflag"));
1211 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1212 standardFlagsDefault->addFlag (fo);
1214 fo->load(flagsPath+"flag-kalarm.png");
1215 fo->setName("clock");
1216 a=new QAction (fo->getPixmap(),fo->getName(),this);
1219 a->setCheckable(true);
1220 a->setObjectName(fo->getName());
1221 a->setToolTip(tr("Time critical","Standardflag"));
1222 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1223 standardFlagsDefault->addFlag (fo);
1225 fo->load(flagsPath+"flag-phone.png");
1226 fo->setName("phone");
1227 a=new QAction (fo->getPixmap(),fo->getName(),this);
1230 a->setCheckable(true);
1231 a->setObjectName(fo->getName());
1232 a->setToolTip(tr("Call...","Standardflag"));
1233 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1234 standardFlagsDefault->addFlag (fo);
1236 fo->load(flagsPath+"flag-lamp.png");
1237 fo->setName("lamp");
1238 a=new QAction (fo->getPixmap(),fo->getName(),this);
1241 a->setCheckable(true);
1242 a->setObjectName(fo->getName());
1243 a->setToolTip(tr("Idea!","Standardflag"));
1244 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1245 standardFlagsDefault->addFlag (fo);
1247 fo->load(flagsPath+"flag-arrow-up.png");
1248 fo->setName("arrow-up");
1249 fo->setGroup("standard-arrow");
1250 a=new QAction (fo->getPixmap(),fo->getName(),this);
1253 a->setCheckable(true);
1254 a->setObjectName(fo->getName());
1255 a->setToolTip(tr("Important","Standardflag"));
1256 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1257 standardFlagsDefault->addFlag (fo);
1259 fo->load(flagsPath+"flag-arrow-down.png");
1260 fo->setName("arrow-down");
1261 fo->setGroup("standard-arrow");
1262 a=new QAction (fo->getPixmap(),fo->getName(),this);
1265 a->setCheckable(true);
1266 a->setObjectName(fo->getName());
1267 a->setToolTip(tr("Unimportant","Standardflag"));
1268 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1269 standardFlagsDefault->addFlag (fo);
1271 fo->load(flagsPath+"flag-arrow-2up.png");
1272 fo->setName("2arrow-up");
1273 fo->setGroup("standard-arrow");
1274 a=new QAction (fo->getPixmap(),fo->getName(),this);
1277 a->setCheckable(true);
1278 a->setObjectName(fo->getName());
1279 a->setToolTip(tr("Very important!","Standardflag"));
1280 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1281 standardFlagsDefault->addFlag (fo);
1283 fo->load(flagsPath+"flag-arrow-2down.png");
1284 fo->setName("2arrow-down");
1285 fo->setGroup("standard-arrow");
1286 a=new QAction (fo->getPixmap(),fo->getName(),this);
1289 a->setCheckable(true);
1290 a->setObjectName(fo->getName());
1291 a->setToolTip(tr("Very unimportant!","Standardflag"));
1292 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1293 standardFlagsDefault->addFlag (fo);
1295 fo->load(flagsPath+"flag-thumb-up.png");
1296 fo->setName("thumb-up");
1297 fo->setGroup("standard-thumb");
1298 a=new QAction (fo->getPixmap(),fo->getName(),this);
1301 a->setCheckable(true);
1302 a->setObjectName(fo->getName());
1303 a->setToolTip(tr("I like this","Standardflag"));
1304 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1305 standardFlagsDefault->addFlag (fo);
1307 fo->load(flagsPath+"flag-thumb-down.png");
1308 fo->setName("thumb-down");
1309 fo->setGroup("standard-thumb");
1310 a=new QAction (fo->getPixmap(),fo->getName(),this);
1313 a->setCheckable(true);
1314 a->setObjectName(fo->getName());
1315 a->setToolTip(tr("I do not like this","Standardflag"));
1316 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1317 standardFlagsDefault->addFlag (fo);
1319 fo->load(flagsPath+"flag-rose.png");
1320 fo->setName("rose");
1321 a=new QAction (fo->getPixmap(),fo->getName(),this);
1324 a->setCheckable(true);
1325 a->setObjectName(fo->getName());
1326 a->setToolTip(tr("Rose","Standardflag"));
1327 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1328 standardFlagsDefault->addFlag (fo);
1330 fo->load(flagsPath+"flag-heart.png");
1331 fo->setName("heart");
1332 a=new QAction (fo->getPixmap(),fo->getName(),this);
1334 a->setCheckable(true);
1335 a->setObjectName(fo->getName());
1336 a->setToolTip(tr("I just love... ","Standardflag"));
1337 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1338 standardFlagsDefault->addFlag (fo);
1341 fo->load(flagsPath+"flag-present.png");
1342 setupFlag (fo,tb,"present",tr("Surprise!","Standardflag"));
1344 fo->load(flagsPath+"flag-flash.png");
1345 setupFlag (fo,tb,"flash",tr("Dangerous","Standardflag"));
1347 // Original: xsldbg_output.png
1348 fo->load(flagsPath+"flag-info.png");
1349 setupFlag (fo,tb,"info",tr("Info","Standardflag"));
1351 // Original khelpcenter.png
1352 fo->load(flagsPath+"flag-lifebelt.png");
1353 setupFlag (fo,tb,"lifebelt",tr("This will help","Standardflag"));
1357 fo->load(flagsPath+"freemind/warning.png");
1358 setupFlag (fo,tb,"freemind-warning",tr("Important","Freemind-Flag"));
1360 for (int i=1; i<8; i++)
1362 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1363 setupFlag (fo,tb,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1366 fo->load(flagsPath+"freemind/back.png");
1367 setupFlag (fo,tb,"freemind-back",tr("Back","Freemind-Flag"));
1369 fo->load(flagsPath+"freemind/forward.png");
1370 setupFlag (fo,tb,"freemind-forward",tr("Forward","Freemind-Flag"));
1373 fo->load(flagsPath+"freemind/attach.png");
1374 setupFlag (fo,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1377 fo->load(flagsPath+"freemind/clanbomber.png");
1378 setupFlag (fo,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1381 fo->load(flagsPath+"freemind/desktopnew.png");
1382 setupFlag (fo,tb,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1385 fo->load(flagsPath+"freemind/flag.png");
1386 setupFlag (fo,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1389 fo->load(flagsPath+"freemind/gohome.png");
1390 setupFlag (fo,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1393 fo->load(flagsPath+"freemind/kaddressbook.png");
1394 setupFlag (fo,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1397 fo->load(flagsPath+"freemind/knotify.png");
1398 setupFlag (fo,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1401 fo->load(flagsPath+"freemind/korn.png");
1402 setupFlag (fo,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1405 fo->load(flagsPath+"freemind/mail.png");
1406 setupFlag (fo,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1408 fo->load(flagsPath+"freemind/password.png");
1409 setupFlag (fo,tb,"freemind-password",tr("Password","Freemind-Flag"));
1411 fo->load(flagsPath+"freemind/pencil.png");
1412 setupFlag (fo,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1414 fo->load(flagsPath+"freemind/stop.png");
1415 setupFlag (fo,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1417 fo->load(flagsPath+"freemind/wizard.png");
1418 setupFlag (fo,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1420 fo->load(flagsPath+"freemind/xmag.png");
1421 setupFlag (fo,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1423 fo->load(flagsPath+"freemind/bell.png");
1424 setupFlag (fo,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1426 fo->load(flagsPath+"freemind/bookmark.png");
1427 setupFlag (fo,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1429 fo->load(flagsPath+"freemind/penguin.png");
1430 setupFlag (fo,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1432 fo->load(flagsPath+"freemind/licq.png");
1433 setupFlag (fo,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1438 void Main::setupFlag (FlagObj *fo, QToolBar *tb, const QString &name, const QString &tooltip)
1441 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1444 a->setCheckable(true);
1445 a->setObjectName(fo->getName());
1446 a->setToolTip(tooltip);
1447 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1448 standardFlagsDefault->addFlag (fo);
1451 void Main::setupNetworkActions()
1453 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1455 QMenu *netMenu = menuBar()->addMenu( "&Network" );
1459 a = new QAction( "Start TCPserver for MapEditor",this);
1460 //a->setStatusTip ( "Set application to open pdf files"));
1461 a->setShortcut ( Qt::Key_T ); //New TCP server
1462 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1463 netMenu->addAction (a);
1465 a = new QAction( "Connect MapEditor to server",this);
1466 //a->setStatusTip ( "Set application to open pdf files"));
1467 a->setShortcut ( Qt::Key_C ); // Connect to server
1468 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1469 netMenu->addAction (a);
1473 void Main::setupSettingsActions()
1475 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1479 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1480 a->setStatusTip ( tr( "Set application to open pdf files"));
1481 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1482 settingsMenu->addAction (a);
1484 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1485 a->setStatusTip( tr( "Set application to open external links"));
1486 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1487 settingsMenu->addAction (a);
1489 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1490 a->setStatusTip( tr( "Set path for macros"));
1491 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1492 settingsMenu->addAction (a);
1494 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1495 a->setStatusTip( tr( "Set number of undo levels"));
1496 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1497 settingsMenu->addAction (a);
1499 settingsMenu->addSeparator();
1501 a = new QAction( tr( "Autosave","Settings action"), this);
1502 a->setStatusTip( tr( "Autosave"));
1503 a->setToggleAction(true);
1504 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1505 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1506 settingsMenu->addAction (a);
1507 actionSettingsAutosaveToggle=a;
1509 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1510 a->setStatusTip( tr( "Autosave time"));
1511 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1512 settingsMenu->addAction (a);
1513 actionSettingsAutosaveTime=a;
1515 settingsMenu->addSeparator();
1517 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1518 a->setStatusTip( tr( "Edit branch after adding it" ));
1519 a->setToggleAction(true);
1520 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1521 settingsMenu->addAction (a);
1522 actionSettingsAutoEditNewBranch=a;
1524 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1525 a->setStatusTip( tr( "Select branch after adding it" ));
1526 a->setToggleAction(true);
1527 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1528 settingsMenu->addAction (a);
1529 actionSettingsAutoSelectNewBranch=a;
1531 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1532 a->setStatusTip( tr( "Select heading before editing" ));
1533 a->setToggleAction(true);
1534 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1535 settingsMenu->addAction (a);
1536 actionSettingsAutoSelectText=a;
1538 a= new QAction( tr( "Delete key","Settings action" ), this);
1539 a->setStatusTip( tr( "Delete key for deleting branches" ));
1540 a->setToggleAction(true);
1541 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1542 settingsMenu->addAction (a);
1543 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1544 actionSettingsUseDelKey=a;
1546 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1547 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1548 a->setToggleAction(true);
1549 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1550 settingsMenu->addAction (a);
1551 actionSettingsUseFlagGroups=a;
1553 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1554 a->setStatusTip( tr( "Use hide flag during exports " ));
1555 a->setToggleAction(true);
1556 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1557 settingsMenu->addAction (a);
1558 actionSettingsUseHideExport=a;
1562 void Main::setupTestActions()
1564 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1567 a = new QAction( "Test function 1" , this);
1568 a->setStatusTip( "Call test function 1" );
1569 testMenu->addAction (a);
1570 //a->setShortcut (Qt::Key_F4 );
1571 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1573 a = new QAction( "Test function 2" , this);
1574 a->setStatusTip( "Call test function 2" );
1575 //a->setShortcut (Qt::Key_F4 );
1576 testMenu->addAction (a);
1577 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1579 a = new QAction( "Command" , this);
1580 a->setStatusTip( "Enter command to call in editor" );
1581 //a->setShortcut (Qt::Key_F5 );
1582 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1583 testMenu->addAction (a);
1587 void Main::setupHelpActions()
1589 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1592 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1593 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1594 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1595 helpMenu->addAction (a);
1597 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1598 a->setStatusTip( tr( "Open VYM example maps " ));
1599 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1600 helpMenu->addAction (a);
1602 a = new QAction( tr( "About VYM","Help action" ), this);
1603 a->setStatusTip( tr( "About VYM")+vymName);
1604 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1605 helpMenu->addAction (a);
1607 a = new QAction( tr( "About QT","Help action" ), this);
1608 a->setStatusTip( tr( "Information about QT toolkit" ));
1609 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1610 helpMenu->addAction (a);
1614 void Main::setupContextMenus()
1618 // Context Menu for branch or mapcenter
1619 branchContextMenu =new QMenu (this);
1620 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1621 branchContextMenu->addSeparator();
1624 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1625 branchAddContextMenu->addAction (actionEditPaste );
1626 branchAddContextMenu->addAction ( actionEditAddBranch );
1627 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1628 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1629 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1630 branchAddContextMenu->addSeparator();
1631 branchAddContextMenu->addAction ( actionEditImportAdd );
1632 branchAddContextMenu->addAction ( actionEditImportReplace );
1635 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1636 branchRemoveContextMenu->addAction (actionEditCut);
1637 branchRemoveContextMenu->addAction ( actionEditDelete );
1638 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1639 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1642 actionEditSaveBranch->addTo( branchContextMenu );
1644 branchContextMenu->addSeparator();
1645 branchContextMenu->addAction ( actionEditLoadImage);
1647 // Submenu for Links (URLs, vymLinks)
1648 branchLinksContextMenu =new QMenu (this);
1650 branchContextMenu->addSeparator();
1651 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1652 branchLinksContextMenu->addAction ( actionEditOpenURL );
1653 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1654 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1655 branchLinksContextMenu->addAction ( actionEditURL );
1656 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1657 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1658 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1660 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1662 branchLinksContextMenu->addSeparator();
1663 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1664 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1665 branchLinksContextMenu->addAction ( actionEditVymLink );
1666 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1669 // Context Menu for XLinks in a branch menu
1670 // This will be populated "on demand" in MapEditor::updateActions
1671 branchContextMenu->addSeparator();
1672 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1673 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1674 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1675 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1678 // Context menu for floatimage
1679 floatimageContextMenu =new QMenu (this);
1680 a= new QAction (tr ("Save image","Context action"),this);
1681 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1682 floatimageContextMenu->addAction (a);
1684 floatimageContextMenu->addSeparator();
1685 actionEditCopy->addTo( floatimageContextMenu );
1686 actionEditCut->addTo( floatimageContextMenu );
1688 floatimageContextMenu->addSeparator();
1689 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1692 // Context menu for canvas
1693 canvasContextMenu =new QMenu (this);
1694 actionEditMapInfo->addTo( canvasContextMenu );
1695 canvasContextMenu->insertSeparator();
1696 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1697 canvasContextMenu->insertSeparator();
1698 actionFormatLinkColorHint->addTo( canvasContextMenu );
1699 actionFormatLinkColor->addTo( canvasContextMenu );
1700 actionFormatSelectionColor->addTo( canvasContextMenu );
1701 actionFormatBackColor->addTo( canvasContextMenu );
1702 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1704 // Menu for last opened files
1706 for (int i = 0; i < MaxRecentFiles; ++i)
1708 recentFileActions[i] = new QAction(this);
1709 recentFileActions[i]->setVisible(false);
1710 fileLastMapsMenu->addAction(recentFileActions[i]);
1711 connect(recentFileActions[i], SIGNAL(triggered()),
1712 this, SLOT(fileLoadRecent()));
1714 setupRecentMapsMenu();
1717 void Main::setupRecentMapsMenu()
1719 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1721 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1723 for (int i = 0; i < numRecentFiles; ++i) {
1724 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1725 recentFileActions[i]->setText(text);
1726 recentFileActions[i]->setData(files[i]);
1727 recentFileActions[i]->setVisible(true);
1729 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1730 recentFileActions[j]->setVisible(false);
1733 void Main::setupMacros()
1735 for (int i = 0; i <= 11; i++)
1737 macroActions[i] = new QAction(this);
1738 macroActions[i]->setData(i);
1739 addAction (macroActions[i]);
1740 connect(macroActions[i], SIGNAL(triggered()),
1741 this, SLOT(callMacro()));
1743 macroActions[0]->setShortcut ( Qt::Key_F1 );
1744 macroActions[1]->setShortcut ( Qt::Key_F2 );
1745 macroActions[2]->setShortcut ( Qt::Key_F3 );
1746 macroActions[3]->setShortcut ( Qt::Key_F4 );
1747 macroActions[4]->setShortcut ( Qt::Key_F5 );
1748 macroActions[5]->setShortcut ( Qt::Key_F6 );
1749 macroActions[6]->setShortcut ( Qt::Key_F7 );
1750 macroActions[7]->setShortcut ( Qt::Key_F8 );
1751 macroActions[8]->setShortcut ( Qt::Key_F9 );
1752 macroActions[9]->setShortcut ( Qt::Key_F10 );
1753 macroActions[10]->setShortcut ( Qt::Key_F11 );
1754 macroActions[11]->setShortcut ( Qt::Key_F12 );
1757 void Main::hideEvent (QHideEvent * )
1759 if (!textEditor->isMinimized() ) textEditor->hide();
1762 void Main::showEvent (QShowEvent * )
1764 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1768 MapEditor* Main::currentMapEditor() const
1770 if ( tabWidget->currentPage() &&
1771 tabWidget->currentPage()->inherits( "MapEditor" ) )
1772 return (MapEditor*)tabWidget->currentPage();
1777 void Main::editorChanged(QWidget *)
1779 // Unselect all possibly selected objects
1780 // (Important to update note editor)
1782 for (int i=0;i<=tabWidget->count() -1;i++)
1785 me=(MapEditor*)tabWidget->page(i);
1788 currentMapEditor()->reselect();
1790 // Update actions to in menus and toolbars according to editor
1794 void Main::fileNew()
1796 QString fn="unnamed";
1797 MapEditor* me = new MapEditor ( NULL);
1798 tabWidget->addTab (me,fn);
1799 tabWidget->showPage(me);
1800 me->viewport()->setFocus();
1801 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1802 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1804 // For the very first map we do not have flagrows yet...
1808 void Main::fileNewCopy()
1810 QString fn="unnamed";
1811 MapEditor* oldME =currentMapEditor();
1815 MapEditor* newME = new MapEditor ( NULL);
1818 tabWidget->addTab (newME,fn);
1819 tabWidget->showPage(newME);
1820 newME->viewport()->setFocus();
1821 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1822 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1823 // For the very first map we do not have flagrows yet...
1824 newME->select("mc:");
1825 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1831 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1833 ErrorCode err=success;
1835 // fn is usually the archive, mapfile the file after uncompressing
1838 // Make fn absolute (needed for unzip)
1839 fn=QDir (fn).absPath();
1845 // Check, if map is already loaded
1847 while (i<=tabWidget->count() -1)
1849 me=(MapEditor*)tabWidget->page(i);
1850 if (me->getFilePath() == fn)
1852 // Already there, ask for confirmation
1853 QMessageBox mb( vymName,
1854 tr("The map %1\nis already opened."
1855 "Opening the same map in multiple editors may lead \n"
1856 "to confusion when finishing working with vym."
1857 "Do you want to").arg(fn),
1858 QMessageBox::Warning,
1859 QMessageBox::Yes | QMessageBox::Default,
1860 QMessageBox::Cancel | QMessageBox::Escape,
1861 QMessageBox::NoButton);
1862 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1863 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1866 case QMessageBox::Yes:
1868 i=tabWidget->count();
1870 case QMessageBox::Cancel:
1882 if ( !fn.isEmpty() )
1884 me = currentMapEditor();
1885 int tabIndex=tabWidget->currentPageIndex();
1886 // Check first, if mapeditor exists
1887 // If it is not default AND we want a new map,
1888 // create a new mapeditor in a new tab
1889 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1891 me= new MapEditor ( NULL);
1892 tabWidget->addTab (me,fn);
1893 tabIndex=tabWidget->indexOf (me);
1894 tabWidget->setCurrentPage (tabIndex);
1895 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1896 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1899 // Check, if file exists (important for creating new files
1900 // from command line
1901 if (!QFile(fn).exists() )
1903 QMessageBox mb( vymName,
1904 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1905 QMessageBox::Question,
1907 QMessageBox::Cancel | QMessageBox::Default,
1908 QMessageBox::NoButton );
1910 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1911 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1914 case QMessageBox::Yes:
1916 currentMapEditor()->setFilePath(fn);
1917 tabWidget->setTabLabel (currentMapEditor(),
1918 currentMapEditor()->getFileName() );
1919 statusBar()->message( "Created " + fn , statusbarTime );
1922 case QMessageBox::Cancel:
1923 // don't create new map
1924 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1931 //tabWidget->currentPage() won't be NULL here, because of above...
1932 tabWidget->showPage(me);
1933 me->viewport()->setFocus();
1935 // Create temporary directory for packing
1937 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1940 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1941 tr("Couldn't create temporary directory before load\n"));
1945 // Try to unzip file
1946 err=unzipDir (tmpMapDir,fn);
1950 me->setZipped(false);
1953 me->setZipped(true);
1955 // Look for mapname.xml
1956 mapfile= fn.left(fn.findRev(".",-1,true));
1957 mapfile=mapfile.section( '/', -1 );
1958 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1959 if (!file.exists() )
1961 // mapname.xml does not exist, well,
1962 // maybe someone renamed the mapname.vym file...
1963 // Try to find any .xml in the toplevel
1964 // directory of the .vym file
1965 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1966 if (flist.count()==1)
1968 // Only one entry, take this one
1969 mapfile=tmpMapDir + "/"+flist.first();
1972 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1973 *it=tmpMapDir + "/" + *it;
1974 // TODO Multiple entries, load all (but only the first one into this ME)
1975 //mainWindow->fileLoadFromTmp (flist);
1976 //returnCode=1; // Silently forget this attempt to load
1977 qWarning ("MainWindow::load (fn) multimap found...");
1980 if (flist.isEmpty() )
1982 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1983 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1986 } //file doesn't exist
1988 mapfile=file.name();
1993 // Save existing filename in case we import
1994 QString fn_org=me->getFilePath();
1996 // Finally load map into mapEditor
1997 me->setFilePath (mapfile,fn);
1998 err=me->load(mapfile,lmode,ftype);
2000 // Restore old (maybe empty) filepath, if this is an import
2002 me->setFilePath (fn_org);
2005 // Finally check for errors and go home
2008 if (lmode==NewMap) fileCloseMap();
2009 statusBar()->message( "Could not load " + fn, statusbarTime );
2014 me->setFilePath (fn);
2015 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
2016 if (fn.left(9)!="/tmp/vym-")
2018 // Only append to lastMaps if not loaded from a tmpDir
2019 // e.g. imported bookmarks are in a tmpDir
2020 addRecentMap(me->getFilePath() );
2022 actionFilePrint->setEnabled (true);
2024 statusBar()->message( "Loaded " + fn, statusbarTime );
2028 removeDir (QDir(tmpMapDir));
2034 void Main::fileLoad(const LoadMode &lmode)
2036 QStringList filters;
2037 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2038 QFileDialog *fd=new QFileDialog( this);
2039 fd->setDir (lastFileDir);
2040 fd->setFileMode (QFileDialog::ExistingFiles);
2041 fd->setFilters (filters);
2045 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2048 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2051 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2057 if ( fd->exec() == QDialog::Accepted )
2059 lastFileDir=fd->directory().path();
2060 QStringList flist = fd->selectedFiles();
2061 QStringList::Iterator it = flist.begin();
2062 while( it != flist.end() )
2065 fileLoad(*it, lmode);
2072 void Main::fileLoad()
2077 void Main::fileLoadRecent()
2079 QAction *action = qobject_cast<QAction *>(sender());
2081 fileLoad (action->data().toString(), NewMap);
2084 void Main::addRecentMap (const QString &fileName)
2087 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2088 files.removeAll(fileName);
2089 files.prepend(fileName);
2090 while (files.size() > MaxRecentFiles)
2093 settings.setValue("/mainwindow/recentFileList", files);
2095 setupRecentMapsMenu();
2098 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
2100 // tmp dir for zipping
2104 ErrorCode err=success;
2106 QString safeFilePath;
2108 bool saveZipped=me->saveZipped();
2112 QString fn=me->getFilePath();
2113 // filename=unnamed, filepath="" in constructor of mapEditor
2114 if ( !fn.isEmpty() )
2116 // We have a filepath, go on saving
2117 // First remove existing file, we
2118 // don't want to add to old zip archives
2122 QMessageBox::warning( 0, tr( "Save Error" ),
2123 fn+ tr("\ncould not be removed before saving"));
2125 // Look, if we should zip the data:
2128 QMessageBox mb( vymName,
2129 tr("The map %1\ndid not use the compressed "
2130 "vym file format.\nWriting it uncompressed will also write images \n"
2131 "and flags and thus may overwrite files in the "
2132 "given directory\n\nDo you want to write the map").arg(fn),
2133 QMessageBox::Warning,
2134 QMessageBox::Yes | QMessageBox::Default,
2136 QMessageBox::Cancel | QMessageBox::Escape);
2137 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2138 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2139 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2142 case QMessageBox::Yes:
2143 // save compressed (default file format)
2146 case QMessageBox::No:
2147 // save uncompressed
2150 case QMessageBox::Cancel:
2159 // Create temporary directory for packing
2161 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2164 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2165 tr("Couldn't create temporary directory before save\n"));
2169 safeFilePath=me->getFilePath();
2170 me->setFilePath (tmpMapDir+"/"+
2171 me->getMapName()+ ".xml",
2173 me->save (savemode);
2174 me->setFilePath (safeFilePath);
2176 zipDir (tmpMapDir,fn);
2181 safeFilePath=me->getFilePath();
2182 me->setFilePath (fn, safeFilePath);
2183 me->save (savemode);
2184 me->setFilePath (safeFilePath);
2186 } // filepath available
2189 // We have no filepath yet,
2190 // call fileSaveAs() now, this will call fileSave()
2192 // First switch to editor
2193 tabWidget->setCurrentWidget (me);
2194 fileSaveAs(savemode);
2198 if (saveZipped && !tmpMapDir.isEmpty())
2200 removeDir (QDir(tmpMapDir));
2204 statusBar()->message(
2205 tr("Saved %1").arg(me->getFilePath()),
2207 addRecentMap (me->getFilePath() );
2209 statusBar()->message(
2210 tr("Couldn't save ").arg(me->getFilePath()),
2214 void Main::fileSave()
2216 fileSave (currentMapEditor(), CompleteMap);
2219 void Main::fileSave(MapEditor *me)
2221 fileSave (me,CompleteMap);
2224 void Main::fileSaveAs(const SaveMode& savemode)
2228 if (currentMapEditor())
2230 if (savemode==CompleteMap)
2231 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2233 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2234 if ( !fn.isEmpty() )
2236 // Check for existing file
2237 if (QFile (fn).exists())
2239 QMessageBox mb( vymName,
2240 tr("The file %1\nexists already. Do you want to").arg(fn),
2241 QMessageBox::Warning,
2242 QMessageBox::Yes | QMessageBox::Default,
2243 QMessageBox::Cancel | QMessageBox::Escape,
2244 QMessageBox::NoButton);
2245 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2246 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2249 case QMessageBox::Yes:
2252 case QMessageBox::Cancel:
2259 // New file, add extension to filename, if missing
2260 // This is always .vym or .vyp, depending on savemode
2261 if (savemode==CompleteMap)
2263 if (!fn.contains (".vym") && !fn.contains (".xml"))
2267 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2276 currentMapEditor()->setFilePath(fn);
2277 fileSave(currentMapEditor(), savemode);
2280 if (savemode==CompleteMap)
2281 tabWidget->setTabLabel (currentMapEditor(),
2282 currentMapEditor()->getFileName() );
2288 void Main::fileSaveAs()
2290 fileSaveAs (CompleteMap);
2293 void Main::fileImportKDEBookmarks()
2295 ImportKDEBookmarks im;
2297 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2298 currentMapEditor()->setFilePath ("");
2301 void Main::fileImportFirefoxBookmarks()
2303 Q3FileDialog *fd=new Q3FileDialog( this);
2304 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2305 fd->setMode (Q3FileDialog::ExistingFiles);
2306 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2307 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2310 if ( fd->exec() == QDialog::Accepted )
2312 ImportFirefoxBookmarks im;
2313 QStringList flist = fd->selectedFiles();
2314 QStringList::Iterator it = flist.begin();
2315 while( it != flist.end() )
2318 if (im.transform() &&
2319 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2320 currentMapEditor() )
2321 currentMapEditor()->setFilePath ("");
2328 void Main::fileImportFreemind()
2330 QStringList filters;
2331 filters <<"Freemind map (*.mm)"<<"All files (*)";
2332 QFileDialog *fd=new QFileDialog( this);
2333 fd->setDir (lastFileDir);
2334 fd->setFileMode (QFileDialog::ExistingFiles);
2335 fd->setFilters (filters);
2336 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2340 if ( fd->exec() == QDialog::Accepted )
2342 lastFileDir=fd->directory().path();
2343 QStringList flist = fd->selectedFiles();
2344 QStringList::Iterator it = flist.begin();
2345 while( it != flist.end() )
2348 if ( fileLoad (fn,NewMap, FreemindMap) )
2350 currentMapEditor()->setFilePath ("");
2359 void Main::fileImportMM()
2363 Q3FileDialog *fd=new Q3FileDialog( this);
2364 fd->setDir (lastFileDir);
2365 fd->setMode (Q3FileDialog::ExistingFiles);
2366 fd->addFilter ("Mind Manager (*.mmap)");
2367 fd->setCaption(tr("Import")+" "+"Mind Manager");
2370 if ( fd->exec() == QDialog::Accepted )
2372 lastFileDir=fd->dirPath();
2373 QStringList flist = fd->selectedFiles();
2374 QStringList::Iterator it = flist.begin();
2375 while( it != flist.end() )
2378 if (im.transform() &&
2379 success==fileLoad (im.getTransformedFile(),NewMap) &&
2380 currentMapEditor() )
2381 currentMapEditor()->setFilePath ("");
2390 void Main::fileImportDir()
2392 if (currentMapEditor())
2393 currentMapEditor()->importDir();
2396 void Main::fileExportXML()
2398 MapEditor *me=currentMapEditor();
2399 if (me) me->exportXML();
2403 void Main::fileExportXHTML()
2405 MapEditor *me=currentMapEditor();
2406 if (me) me->exportXHTML();
2409 void Main::fileExportImage()
2411 MapEditor *me=currentMapEditor();
2412 if (me) me->exportImage();
2415 void Main::fileExportASCII()
2417 MapEditor *me=currentMapEditor();
2418 if (me) me->exportASCII();
2421 void Main::fileExportCSV() //FIXME not scriptable yet
2423 MapEditor *me=currentMapEditor();
2427 ex.setMapCenter(me->getMapCenter());
2428 ex.addFilter ("CSV (*.csv)");
2429 ex.setDir(lastImageDir);
2430 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2431 if (ex.execDialog() )
2433 me->setExportMode(true);
2435 me->setExportMode(false);
2440 void Main::fileExportLaTeX() //FIXME not scriptable yet
2442 MapEditor *me=currentMapEditor();
2446 ex.setMapCenter(me->getMapCenter());
2447 ex.addFilter ("Tex (*.tex)");
2448 ex.setDir(lastImageDir);
2449 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2450 if (ex.execDialog() )
2452 me->setExportMode(true);
2454 me->setExportMode(false);
2459 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2461 ExportKDEBookmarks ex;
2462 MapEditor *me=currentMapEditor();
2465 ex.setMapCenter (me->getMapCenter() );
2470 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2472 ExportTaskjuggler ex;
2473 MapEditor *me=currentMapEditor();
2476 ex.setMapCenter (me->getMapCenter() );
2477 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2478 ex.setDir(lastImageDir);
2479 ex.addFilter ("Taskjuggler (*.tjp)");
2480 if (ex.execDialog() )
2482 me->setExportMode(true);
2484 me->setExportMode(false);
2489 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2491 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2492 // TODO add preview in dialog
2493 //ImagePreview *p =new ImagePreview (fd);
2494 //fd->setContentsPreviewEnabled( TRUE );
2495 //fd->setContentsPreview( p, p );
2496 //fd->setPreviewMode( QFileDialog::Contents );
2497 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2498 fd->setDir (QDir().current());
2499 if (fd->foundConfig())
2503 if ( fd->exec() == QDialog::Accepted )
2505 QString fn=fd->selectedFile();
2506 if (!fn.contains (".odp"))
2509 //lastImageDir=fn.left(fn.findRev ("/"));
2510 if (currentMapEditor())
2511 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2515 QMessageBox::warning(0,
2517 tr("Couldn't find configuration for export to Open Office\n"));
2521 void Main::fileCloseMap()
2523 if (currentMapEditor())
2525 if (currentMapEditor()->hasChanged())
2527 QMessageBox mb( vymName,
2528 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2529 QMessageBox::Warning,
2530 QMessageBox::Yes | QMessageBox::Default,
2532 QMessageBox::Cancel | QMessageBox::Escape );
2533 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2534 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2537 case QMessageBox::Yes:
2539 fileSave(currentMapEditor(), CompleteMap);
2541 case QMessageBox::No:
2542 // close without saving
2544 case QMessageBox::Cancel:
2549 currentMapEditor()->closeMap();
2550 tabWidget->removePage(currentMapEditor());
2551 if (tabWidget->count()==0)
2552 actionFilePrint->setEnabled (false);
2556 void Main::filePrint()
2558 if (currentMapEditor())
2559 currentMapEditor()->print();
2562 void Main::fileExitVYM()
2564 // Check if one or more editors have changed
2567 for (i=0;i<=tabWidget->count() -1;i++)
2570 me=(MapEditor*)tabWidget->page(i);
2572 // If something changed, ask what to do
2573 if (me->hasChanged())
2575 tabWidget->setCurrentPage(i);
2576 QMessageBox mb( vymName,
2577 tr("This map is not saved yet. Do you want to"),
2578 QMessageBox::Warning,
2579 QMessageBox::Yes | QMessageBox::Default,
2581 QMessageBox::Cancel | QMessageBox::Escape );
2582 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2583 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2586 mb.setActiveWindow();
2587 switch( mb.exec() ) {
2588 case QMessageBox::Yes:
2589 // save (the changed editors) and exit
2590 fileSave(currentMapEditor(), CompleteMap);
2592 case QMessageBox::No:
2593 // exit without saving
2595 case QMessageBox::Cancel:
2596 // don't save and don't exit
2600 } // loop over all MEs
2604 void Main::editUndo()
2606 if (currentMapEditor())
2607 currentMapEditor()->undo();
2610 void Main::editRedo()
2612 if (currentMapEditor())
2613 currentMapEditor()->redo();
2616 void Main::gotoHistoryStep (int i)
2618 if (currentMapEditor())
2619 currentMapEditor()->gotoHistoryStep (i);
2622 void Main::editCopy()
2624 if (currentMapEditor())
2625 currentMapEditor()->copy();
2628 void Main::editPaste()
2630 if (currentMapEditor())
2631 currentMapEditor()->paste();
2634 void Main::editCut()
2636 if (currentMapEditor())
2637 currentMapEditor()->cut();
2640 void Main::editOpenFindWindow()
2642 findWindow->popup();
2643 findWindow->raise();
2644 findWindow->setActiveWindow();
2647 void Main::editFind(QString s)
2650 BranchObj *bo=currentMapEditor()->findText(s, cs);
2653 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2656 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2657 tr("No matches found for \"%1\"").arg(s));
2661 void Main::editFindChanged()
2662 { // Notify editor, to abort the current find process
2663 currentMapEditor()->findReset();
2666 void Main::openTabs(QStringList urls)
2668 if (!urls.isEmpty())
2672 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2674 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2676 QString u=urls.takeFirst();
2677 procBrowser = new QProcess( this );
2679 procBrowser->start(browser,args);
2680 if ( !procBrowser->waitForStarted())
2682 // try to set path to browser
2683 QMessageBox::warning(0,
2685 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2686 tr("Please use Settings->")+tr("Set application to open an URL"));
2691 if (browser.contains("konqueror"))
2693 for (int i=0; i<urls.size(); i++)
2696 // Try to open new tab in existing konqueror started previously by vym
2697 p=new QProcess (this);
2699 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2700 "konqueror-mainwindow#1"<<
2703 p->start ("dcop",args);
2704 if ( !p->waitForStarted() ) success=false;
2707 QMessageBox::warning(0,
2709 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2711 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2713 for (int i=0; i<urls.size(); i++)
2715 // Try to open new tab in firefox
2716 p=new QProcess (this);
2717 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2718 p->start (browser,args);
2719 if ( !p->waitForStarted() ) success=false;
2722 QMessageBox::warning(0,
2724 tr("Couldn't start %1 to open a new tab").arg(browser));
2727 QMessageBox::warning(0,
2729 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2733 void Main::editOpenURL()
2736 if (currentMapEditor())
2738 QString url=currentMapEditor()->getURL();
2740 if (url=="") return;
2741 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2742 procBrowser = new QProcess( this );
2744 procBrowser->start(browser,args);
2745 if ( !procBrowser->waitForStarted())
2747 // try to set path to browser
2748 QMessageBox::warning(0,
2750 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2751 tr("Please use Settings->")+tr("Set application to open an URL"));
2756 void Main::editOpenURLTab()
2758 if (currentMapEditor())
2761 urls.append(currentMapEditor()->getURL());
2765 void Main::editOpenMultipleURLTabs()
2767 if (currentMapEditor())
2770 urls=currentMapEditor()->getURLs();
2776 void Main::editURL()
2778 if (currentMapEditor())
2779 currentMapEditor()->editURL();
2782 void Main::editLocalURL()
2784 if (currentMapEditor())
2785 currentMapEditor()->editLocalURL();
2788 void Main::editHeading2URL()
2790 if (currentMapEditor())
2791 currentMapEditor()->editHeading2URL();
2794 void Main::editBugzilla2URL()
2796 if (currentMapEditor())
2797 currentMapEditor()->editBugzilla2URL();
2800 void Main::editFATE2URL()
2802 if (currentMapEditor())
2803 currentMapEditor()->editFATE2URL();
2806 void Main::editHeadingFinished()
2808 // only called from editHeading(), so there is a currentME
2809 MapEditor *me=currentMapEditor();
2812 me->setStateEditHeading (false);
2813 QPoint p; //Not used here, only to find out pos of branch
2815 QString s=me->getHeading(ok,p);
2817 #if defined(Q_OS_MACX)
2819 if (ok && s!=lineedit->text())
2820 me->setHeading(lineedit->text());
2822 lineedit->releaseKeyboard();
2826 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2827 !prevSelection.isEmpty())
2828 me->select(prevSelection);
2833 void Main::editHeading()
2835 if (currentMapEditor())
2837 MapEditor *me=currentMapEditor();
2838 QString oldSel=me->getSelectString();
2840 if (lineedit->isVisible())
2841 editHeadingFinished();
2846 QString s=me->getHeading(ok,p);
2850 me->setStateEditHeading (true);
2851 #if defined(Q_OS_MACX)
2852 p=me->mapToGlobal (p);
2853 QDialog *d =new QDialog(NULL);
2854 QLineEdit *le=new QLineEdit (d);
2855 d->setWindowFlags (Qt::FramelessWindowHint);
2856 d->setGeometry(p.x(),p.y(),230,25);
2857 le->resize (d->width()-10,d->height());
2860 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2861 d->activateWindow();
2863 me->setHeading (le->text());
2866 editHeadingFinished();
2868 p=me->mapTo (this,p);
2869 lineedit->setGeometry(p.x(),p.y(),230,25);
2870 lineedit->setText(s);
2871 lineedit->setCursorPosition(1);
2872 lineedit->selectAll();
2874 lineedit->grabKeyboard();
2875 lineedit->setFocus();
2879 } // currentMapEditor()
2882 void Main::openVymLinks(const QStringList &vl)
2884 for (int j=0; j<vl.size(); j++)
2886 // compare path with already loaded maps
2890 for (i=0;i<=tabWidget->count() -1;i++)
2892 me=(MapEditor*)tabWidget->page(i);
2893 if (vl.at(j)==me->getFilePath() )
2902 if (!QFile(vl.at(j)).exists() )
2903 QMessageBox::critical( 0, tr( "Critical Error" ),
2904 tr("Couldn't open map %1").arg(vl.at(j)));
2907 fileLoad (vl.at(j), NewMap);
2908 tabWidget->setCurrentPage (tabWidget->count()-1);
2911 // Go to tab containing the map
2912 tabWidget->setCurrentPage (index);
2916 void Main::editOpenVymLink()
2918 if (currentMapEditor())
2921 vl.append(currentMapEditor()->getVymLink());
2926 void Main::editOpenMultipleVymLinks()
2928 QString currentVymLink;
2929 if (currentMapEditor())
2931 QStringList vl=currentMapEditor()->getVymLinks();
2936 void Main::editVymLink()
2938 if (currentMapEditor())
2939 currentMapEditor()->editVymLink();
2942 void Main::editDeleteVymLink()
2944 if (currentMapEditor())
2945 currentMapEditor()->deleteVymLink();
2948 void Main::editToggleHideExport()
2950 if (currentMapEditor())
2951 currentMapEditor()->toggleHideExport();
2954 void Main::editMapInfo()
2956 if (currentMapEditor())
2957 currentMapEditor()->editMapInfo();
2960 void Main::editMoveUp()
2962 if (currentMapEditor())
2963 currentMapEditor()->moveBranchUp();
2966 void Main::editMoveDown()
2968 if (currentMapEditor())
2969 currentMapEditor()->moveBranchDown();
2972 void Main::editToggleScroll()
2974 if (currentMapEditor())
2976 currentMapEditor()->toggleScroll();
2980 void Main::editUnscrollChilds()
2982 if (currentMapEditor())
2983 currentMapEditor()->unscrollChilds();
2986 void Main::editNewBranch()
2988 MapEditor *me=currentMapEditor();
2989 if (!lineedit->isVisible() && me)
2991 BranchObj *bo=(BranchObj*)me->getSelection();
2992 BranchObj *newbo=me->addNewBranch(0);
2994 prevSelection=bo->getSelectString();
2996 me->select (newbo->getSelectString());
3000 if (actionSettingsAutoEditNewBranch->isOn())
3005 if (!prevSelection.isEmpty())
3007 me->select(prevSelection);
3014 void Main::editNewBranchBefore()
3016 MapEditor *me=currentMapEditor();
3017 if (!lineedit->isVisible() && me)
3019 BranchObj *bo=(BranchObj*)me->getSelection();
3020 BranchObj *newbo=me->addNewBranchBefore();
3023 me->select (newbo->getSelectString());
3027 if (actionSettingsAutoEditNewBranch->isOn())
3029 if (!actionSettingsAutoSelectNewBranch->isOn())
3030 prevSelection=bo->getSelectString();
3036 void Main::editNewBranchAbove()
3038 MapEditor *me=currentMapEditor();
3039 if (!lineedit->isVisible() && me)
3041 BranchObj *bo=(BranchObj*)me->getSelection();
3042 BranchObj *newbo=me->addNewBranch (-1);
3045 me->select (newbo->getSelectString());
3049 if (actionSettingsAutoEditNewBranch->isOn())
3051 if (!actionSettingsAutoSelectNewBranch->isOn())
3052 prevSelection=bo->getSelectString();
3058 void Main::editNewBranchBelow()
3060 MapEditor *me=currentMapEditor();
3061 if (!lineedit->isVisible() && me)
3063 BranchObj *bo=(BranchObj*)me->getSelection();
3064 BranchObj *newbo=me->addNewBranch (1);
3067 me->select (newbo->getSelectString());
3071 if (actionSettingsAutoEditNewBranch->isOn())
3073 if (!actionSettingsAutoSelectNewBranch->isOn())
3074 prevSelection=bo->getSelectString();
3080 void Main::editImportAdd()
3082 fileLoad (ImportAdd);
3085 void Main::editImportReplace()
3087 fileLoad (ImportReplace);
3090 void Main::editSaveBranch()
3092 fileSaveAs (PartOfMap);
3095 void Main::editDeleteKeepChilds()
3097 if (currentMapEditor())
3098 currentMapEditor()->deleteKeepChilds();
3101 void Main::editDeleteChilds()
3103 if (currentMapEditor())
3104 currentMapEditor()->deleteChilds();
3107 void Main::editDeleteSelection()
3109 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3110 currentMapEditor()->deleteSelection();
3113 void Main::editUpperBranch()
3115 if (currentMapEditor())
3116 currentMapEditor()->selectUpperBranch();
3119 void Main::editLowerBranch()
3121 if (currentMapEditor())
3122 currentMapEditor()->selectLowerBranch();
3125 void Main::editLeftBranch()
3127 if (currentMapEditor())
3128 currentMapEditor()->selectLeftBranch();
3131 void Main::editRightBranch()
3133 if (currentMapEditor())
3134 currentMapEditor()->selectRightBranch();
3137 void Main::editFirstBranch()
3139 if (currentMapEditor())
3140 currentMapEditor()->selectFirstBranch();
3143 void Main::editLastBranch()
3145 if (currentMapEditor())
3146 currentMapEditor()->selectLastBranch();
3149 void Main::editLoadImage()
3151 if (currentMapEditor())
3152 currentMapEditor()->loadFloatImage();
3155 void Main::editSaveImage()
3157 if (currentMapEditor())
3158 currentMapEditor()->saveFloatImage();
3161 void Main::editFollowXLink(QAction *a)
3164 if (currentMapEditor())
3165 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3168 void Main::editEditXLink(QAction *a)
3170 if (currentMapEditor())
3171 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3174 void Main::formatSelectColor()
3176 if (currentMapEditor())
3178 QColor col = QColorDialog::getColor((currentColor ), this );
3179 if ( !col.isValid() ) return;
3180 colorChanged( col );
3184 void Main::formatPickColor()
3186 if (currentMapEditor())
3187 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3190 void Main::colorChanged(QColor c)
3192 QPixmap pix( 16, 16 );
3194 actionFormatColor->setIconSet( pix );
3198 void Main::formatColorBranch()
3200 if (currentMapEditor())
3201 currentMapEditor()->colorBranch(currentColor);
3204 void Main::formatColorSubtree()
3206 if (currentMapEditor())
3207 currentMapEditor()->colorSubtree (currentColor);
3210 void Main::formatLinkStyleLine()
3212 if (currentMapEditor())
3213 currentMapEditor()->setMapLinkStyle("StyleLine");
3216 void Main::formatLinkStyleParabel()
3218 if (currentMapEditor())
3219 currentMapEditor()->setMapLinkStyle("StyleParabel");
3222 void Main::formatLinkStylePolyLine()
3224 if (currentMapEditor())
3225 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3228 void Main::formatLinkStylePolyParabel()
3230 if (currentMapEditor())
3231 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3234 void Main::formatSelectBackColor()
3236 if (currentMapEditor())
3237 currentMapEditor()->selectMapBackgroundColor();
3240 void Main::formatSelectBackImage()
3242 if (currentMapEditor())
3243 currentMapEditor()->selectMapBackgroundImage();
3246 void Main::formatSelectLinkColor()
3248 if (currentMapEditor())
3249 currentMapEditor()->selectMapLinkColor();
3252 void Main::formatSelectSelectionColor()
3254 if (currentMapEditor())
3255 currentMapEditor()->selectMapSelectionColor();
3258 void Main::formatToggleLinkColorHint()
3260 currentMapEditor()->toggleMapLinkColorHint();
3264 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3266 if (currentMapEditor())
3267 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3270 void Main::viewZoomReset()
3272 if (currentMapEditor())
3276 currentMapEditor()->setMatrix( m );
3280 void Main::viewZoomIn()
3282 if (currentMapEditor())
3284 QMatrix m = currentMapEditor()->matrix();
3285 m.scale( 1.25, 1.25 );
3286 currentMapEditor()->setMatrix( m );
3290 void Main::viewZoomOut()
3292 if (currentMapEditor())
3294 QMatrix m = currentMapEditor()->matrix();
3295 m.scale( 0.8, 0.8 );
3296 currentMapEditor()->setMatrix( m );
3300 void Main::viewCenter()
3302 MapEditor *me=currentMapEditor();
3305 me->ensureSelectionVisible();
3309 void Main::networkStartServer()
3311 MapEditor *me=currentMapEditor();
3312 if (me) me->newServer();
3315 void Main::networkConnect()
3317 MapEditor *me=currentMapEditor();
3318 if (me) me->connectToServer();
3321 bool Main::settingsPDF()
3323 // Default browser is set in constructor
3325 QString text = QInputDialog::getText(
3326 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3327 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3329 settings.setValue ("/mainwindow/readerPDF",text);
3334 bool Main::settingsURL()
3336 // Default browser is set in constructor
3338 QString text = QInputDialog::getText(
3339 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3340 settings.value("/mainwindow/readerURL").toString()
3343 settings.setValue ("/mainwindow/readerURL",text);
3347 void Main::settingsMacroDir()
3349 QDir defdir=vymBaseDir;
3350 defdir.cd("macros");
3351 if (!defdir.exists())
3353 QDir dir=QFileDialog::getExistingDirectory (
3355 tr ("Directory with vym macros:"),
3356 settings.value ("/macros/macroDir",defdir.path()).toString()
3359 settings.setValue ("/macros/macroDir",dir.path());
3362 void Main::settingsUndoLevels()
3365 int i = QInputDialog::getInteger(
3367 tr("QInputDialog::getInteger()"),
3368 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3371 settings.setValue ("/mapeditor/stepsTotal",i);
3372 QMessageBox::information( this, tr( "VYM -Information:" ),
3373 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3377 void Main::settingsAutosaveToggle()
3379 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3382 void Main::settingsAutosaveTime()
3385 int i = QInputDialog::getInteger(
3387 tr("QInputDialog::getInteger()"),
3388 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3391 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3395 void Main::settingsToggleDelKey()
3397 if (actionSettingsUseDelKey->isOn())
3399 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3402 actionEditDelete->setAccel (QKeySequence (""));
3406 void Main::windowToggleNoteEditor()
3408 if (textEditor->isVisible() )
3409 windowHideNoteEditor();
3411 windowShowNoteEditor();
3414 void Main::windowToggleHistory()
3416 if (historyWindow->isVisible())
3417 historyWindow->hide();
3419 historyWindow->show();
3423 void Main::windowToggleProperty()
3425 if (branchPropertyWindow->isVisible())
3426 branchPropertyWindow->hide();
3428 branchPropertyWindow->show();
3430 if(currentMapEditor())
3432 LinkableMapObj *sel=currentMapEditor()->getSelection();
3433 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3434 typeid(*sel) == typeid(MapCenterObj)))
3436 branchPropertyWindow->setMapEditor(currentMapEditor());
3437 branchPropertyWindow->setBranch((BranchObj*)sel);
3442 branchPropertyWindow->setBranch(NULL);
3445 void Main::windowToggleAntiAlias()
3447 bool b=actionViewToggleAntiAlias->isOn();
3449 for (int i=0;i<tabWidget->count();i++)
3452 me=(MapEditor*)tabWidget->page(i);
3453 me->setAntiAlias(b);
3458 void Main::windowToggleSmoothPixmap()
3460 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3462 for (int i=0;i<tabWidget->count();i++)
3465 me=(MapEditor*)tabWidget->page(i);
3466 me->setSmoothPixmap(b);
3470 void Main::updateHistory(SimpleSettings &undoSet)
3472 historyWindow->update (undoSet);
3475 void Main::updateNoteFlag()
3477 if (currentMapEditor())
3478 currentMapEditor()->updateNoteFlag();
3481 void Main::updateSatellites(MapEditor *me)
3483 branchPropertyWindow->setMapEditor (me);
3486 void Main::updateActions()
3488 MapEditor *me=currentMapEditor();
3491 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3493 // updateActions is also called when NoteEditor is closed
3494 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3495 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3496 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3498 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3499 actionFormatLinkColorHint->setOn(true);
3501 actionFormatLinkColorHint->setOn(false);
3503 switch (me->getMapLinkStyle())
3505 case LinkableMapObj::Line:
3506 actionFormatLinkStyleLine->setOn(true);
3508 case LinkableMapObj::Parabel:
3509 actionFormatLinkStyleParabel->setOn(true);
3511 case LinkableMapObj::PolyLine:
3512 actionFormatLinkStylePolyLine->setOn(true);
3514 case LinkableMapObj::PolyParabel:
3515 actionFormatLinkStylePolyParabel->setOn(true);
3522 QPixmap pix( 16, 16 );
3523 pix.fill( me->getMapBackgroundColor() );
3524 actionFormatBackColor->setIconSet( pix );
3525 pix.fill( me->getSelectionColor() );
3526 actionFormatSelectionColor->setIconSet( pix );
3527 pix.fill( me->getMapDefLinkColor() );
3528 actionFormatLinkColor->setIconSet( pix );
3531 actionFileSave->setEnabled( me->hasChanged() );
3532 if (me->isUndoAvailable())
3533 actionEditUndo->setEnabled( true);
3535 actionEditUndo->setEnabled( false);
3537 if (me->isRedoAvailable())
3538 actionEditRedo->setEnabled( true);
3540 actionEditRedo->setEnabled( false);
3542 LinkableMapObj *selection=me->getSelection();
3545 if ( (typeid(*selection) == typeid(BranchObj)) ||
3546 (typeid(*selection) == typeid(MapCenterObj)) )
3548 BranchObj *bo=(BranchObj*)selection;
3549 // Take care of links
3550 if (bo->countXLinks()==0)
3552 branchXLinksContextMenuEdit->clear();
3553 branchXLinksContextMenuFollow->clear();
3558 branchXLinksContextMenuEdit->clear();
3559 branchXLinksContextMenuFollow->clear();
3560 for (int i=0; i<=bo->countXLinks();i++)
3562 bot=bo->XLinkTargetAt(i);
3565 s=bot->getHeading();
3568 branchXLinksContextMenuFollow->addAction (s);
3569 branchXLinksContextMenuEdit->addAction (s);
3574 standardFlagsDefault->setEnabled (true);
3576 actionEditToggleScroll->setEnabled (true);
3577 if ( bo->isScrolled() )
3578 actionEditToggleScroll->setOn(true);
3580 actionEditToggleScroll->setOn(false);
3582 if ( bo->getURL().isEmpty() )
3584 actionEditOpenURL->setEnabled (false);
3585 actionEditOpenURLTab->setEnabled (false);
3589 actionEditOpenURL->setEnabled (true);
3590 actionEditOpenURLTab->setEnabled (true);
3592 if ( bo->getVymLink().isEmpty() )
3594 actionEditOpenVymLink->setEnabled (false);
3595 actionEditDeleteVymLink->setEnabled (false);
3598 actionEditOpenVymLink->setEnabled (true);
3599 actionEditDeleteVymLink->setEnabled (true);
3602 if (bo->canMoveBranchUp())
3603 actionEditMoveUp->setEnabled (true);
3605 actionEditMoveUp->setEnabled (false);
3606 if (bo->canMoveBranchDown())
3607 actionEditMoveDown->setEnabled (true);
3609 actionEditMoveDown->setEnabled (false);
3612 actionEditToggleHideExport->setEnabled (true);
3613 actionEditToggleHideExport->setOn (bo->hideInExport() );
3615 actionEditCopy->setEnabled (true);
3616 actionEditCut->setEnabled (true);
3617 if (!clipboardEmpty)
3618 actionEditPaste->setEnabled (true);
3620 actionEditPaste->setEnabled (false);
3621 for (int i=0; i<actionListBranches.size(); ++i)
3622 actionListBranches.at(i)->setEnabled(true);
3623 actionEditDelete->setEnabled (true);
3624 actionFormatHideLinkUnselected->setOn
3625 (selection->getHideLinkUnselected());
3627 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3629 FloatObj *fo=(FloatImageObj*)selection;
3631 actionEditOpenURL->setEnabled (false);
3632 actionEditOpenVymLink->setEnabled (false);
3633 actionEditDeleteVymLink->setEnabled (false);
3634 actionEditToggleHideExport->setEnabled (true);
3635 actionEditToggleHideExport->setOn (fo->hideInExport() );
3638 actionEditCopy->setEnabled (true);
3639 actionEditCut->setEnabled (true);
3640 actionEditPaste->setEnabled (false);
3641 for (int i=0; i<actionListBranches.size(); ++i)
3642 actionListBranches.at(i)->setEnabled(false);
3643 actionEditDelete->setEnabled (true);
3644 actionFormatHideLinkUnselected->setOn
3645 ( selection->getHideLinkUnselected());
3646 actionEditMoveUp->setEnabled (false);
3647 actionEditMoveDown->setEnabled (false);
3652 actionEditCopy->setEnabled (false);
3653 actionEditCut->setEnabled (false);
3654 actionEditPaste->setEnabled (false);
3655 for (int i=0; i<actionListBranches.size(); ++i)
3656 actionListBranches.at(i)->setEnabled(false);
3658 actionEditToggleScroll->setEnabled (false);
3659 actionEditOpenURL->setEnabled (false);
3660 actionEditOpenVymLink->setEnabled (false);
3661 actionEditDeleteVymLink->setEnabled (false);
3662 actionEditHeading2URL->setEnabled (false);
3663 actionEditDelete->setEnabled (false);
3664 actionEditMoveUp->setEnabled (false);
3665 actionEditMoveDown->setEnabled (false);
3666 actionEditToggleHideExport->setEnabled (false);
3670 Main::ModMode Main::getModMode()
3672 if (actionModModeColor->isOn()) return ModModeColor;
3673 if (actionModModeCopy->isOn()) return ModModeCopy;
3674 if (actionModModeXLink->isOn()) return ModModeXLink;
3678 bool Main::autoEditNewBranch()
3680 return actionSettingsAutoEditNewBranch->isOn();
3683 bool Main::autoSelectNewBranch()
3685 return actionSettingsAutoSelectNewBranch->isOn();
3688 bool Main::useFlagGroups()
3690 return actionSettingsUseFlagGroups->isOn();
3693 void Main::windowShowNoteEditor()
3695 textEditor->setShowWithMain(true);
3697 actionViewToggleNoteEditor->setOn (true);
3700 void Main::windowHideNoteEditor()
3702 textEditor->setShowWithMain(false);
3704 actionViewToggleNoteEditor->setOn (false);
3707 void Main::setScript (const QString &script)
3709 scriptEditor->setScript (script);
3712 void Main::runScript (const QString &script)
3714 if (currentMapEditor())
3715 currentMapEditor()->runScript (script);
3718 void Main::runScriptEverywhere (const QString &script)
3721 for (int i=0;i<=tabWidget->count() -1;i++)
3723 me=(MapEditor*)tabWidget->page(i);
3724 if (me) me->runScript (script);
3728 void Main::windowNextEditor()
3730 if (tabWidget->currentPageIndex() < tabWidget->count())
3731 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3734 void Main::windowPreviousEditor()
3736 if (tabWidget->currentPageIndex() >0)
3737 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3740 void Main::standardFlagChanged()
3742 if (currentMapEditor())
3743 currentMapEditor()->toggleStandardFlag(sender()->name());
3746 void Main::testFunction1()
3748 if (!currentMapEditor()) return;
3749 currentMapEditor()->testFunction1();
3752 void Main::testFunction2()
3754 if (!currentMapEditor()) return;
3755 currentMapEditor()->testFunction2();
3758 void Main::testCommand()
3760 if (!currentMapEditor()) return;
3761 scriptEditor->show();
3764 QString com = QInputDialog::getText(
3765 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3766 if (ok) currentMapEditor()->parseAtom(com);
3770 void Main::helpDoc()
3772 QString locale = QLocale::system().name();
3774 if (locale.left(2)=="es")
3775 docname="vym_es.pdf";
3779 QStringList searchList;
3781 #if defined(Q_OS_MACX)
3782 searchList << "./vym.app/Contents/Resources/doc";
3784 // default path in SUSE LINUX
3785 searchList <<"/usr/share/doc/packages/vym/doc";
3788 searchList << "doc"; // relative path for easy testing in tarball
3789 searchList << "doc/tex"; // Easy testing working on vym.tex
3790 searchList << "/usr/share/doc/vym"; // Debian
3791 searchList << "/usr/share/doc/packages";// Knoppix
3795 for (int i=0; i<searchList.count(); ++i)
3797 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3798 if (docfile.exists() )
3807 QMessageBox::critical(0,
3808 tr("Critcal error"),
3809 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3814 Process *pdfProc = new Process();
3815 args <<docfile.fileName();
3817 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3818 if ( !pdfProc->waitForStarted() )
3821 QMessageBox::warning(0,
3823 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3824 tr("Please use Settings->")+tr("Set application to open PDF files"));
3831 void Main::helpDemo()
3833 QStringList filters;
3834 filters <<"VYM example map (*.vym)";
3835 QFileDialog *fd=new QFileDialog( this);
3836 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3837 fd->setFileMode (QFileDialog::ExistingFiles);
3838 fd->setFilters (filters);
3839 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3843 if ( fd->exec() == QDialog::Accepted )
3845 lastFileDir=fd->directory().path();
3846 QStringList flist = fd->selectedFiles();
3847 QStringList::Iterator it = flist.begin();
3848 while( it != flist.end() )
3851 fileLoad(*it, NewMap);
3859 void Main::helpAbout()
3862 ad.setName ("aboutwindow");
3863 ad.setMinimumSize(500,500);
3864 ad.resize (QSize (500,500));
3868 void Main::helpAboutQT()
3870 QMessageBox::aboutQt( this, "Qt Application Example" );
3873 void Main::callMacro ()
3875 QAction *action = qobject_cast<QAction *>(sender());
3879 i=action->data().toInt();
3880 QString mDir (settings.value ("macros/macroDir").toString() );
3882 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3884 if ( !f.open( QIODevice::ReadOnly ) )
3886 QMessageBox::warning(0,
3888 tr("Couldn't find a macro at %1.\n").arg(fn)+
3889 tr("Please use Settings->")+tr("Set directory for vym macros"));
3893 QTextStream ts( &f );
3894 QString m= ts.read();
3898 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3899 currentMapEditor()->runScript (m);