GPL V2. Added settings to documentation
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("Mind Manager...",this);
314 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
315 fileImportMenu->addAction (a);
316 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
318 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
319 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
320 fileImportMenu->addAction (a);
321 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
323 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
325 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
326 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
327 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
328 fileExportMenu->addAction (a);
330 a = new QAction( "Open Office...", this);
331 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
333 fileExportMenu->addAction (a);
335 a = new QAction( "Webpage (XHTML)...",this );
336 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
337 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
338 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
339 fileExportMenu->addAction (a);
341 a = new QAction( "Text (ASCII)...", this);
342 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
343 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
344 fileExportMenu->addAction (a);
346 a = new QAction( "Spreadsheet (CSV)...", this);
347 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
349 fileExportMenu->addAction (a);
351 a = new QAction( tr("KDE Bookmarks","File menu"), this);
352 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
353 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
354 fileExportMenu->addAction (a);
356 a = new QAction( "Taskjuggler...", this );
357 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
358 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
359 fileExportMenu->addAction (a);
361 a = new QAction( "LaTeX...", this);
362 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
363 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
364 fileExportMenu->addAction (a);
366 a = new QAction( "XML..." , this );
367 a->setStatusTip (tr( "Export as %1").arg("XML"));
368 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
369 fileExportMenu->addAction (a);
371 fileMenu->addSeparator();
373 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
374 a->setStatusTip ( tr( "Print" ,"File menu") );
375 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
377 fileMenu->addAction (a);
378 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
381 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
382 a->setStatusTip (tr( "Close Map" ) );
383 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
384 fileMenu->addAction (a);
385 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
387 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
388 a->setStatusTip ( tr( "Exit")+" "+vymName );
389 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
390 fileMenu->addAction (a);
391 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
396 void Main::setupEditActions()
398 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
399 tb->setLabel( "Edit Actions" );
400 tb->setObjectName ("actionsTB");
401 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
405 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
406 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
407 a->setStatusTip (tr( "Undo" ) );
408 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
409 a->setEnabled (false);
411 editMenu->addAction (a);
414 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
415 a->setStatusTip (tr( "Redo" ));
416 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
418 editMenu->addAction (a);
419 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
422 editMenu->addSeparator();
423 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
424 a->setStatusTip ( tr( "Copy" ) );
425 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
426 a->setEnabled (false);
428 editMenu->addAction (a);
429 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
432 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
433 a->setStatusTip ( tr( "Cut" ) );
434 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
435 a->setEnabled (false);
437 editMenu->addAction (a);
439 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
441 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
442 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
443 a->setStatusTip ( tr( "Paste" ) );
444 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
445 a->setEnabled (false);
447 editMenu->addAction (a);
450 // Shortcuts to modify heading:
451 a = new QAction(tr( "Edit heading","Edit menu" ),this);
452 a->setStatusTip ( tr( "edit Heading" ));
453 a->setShortcut ( Qt::Key_Enter); //Edit heading
454 // a->setShortcutContext (Qt::WindowShortcut);
456 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
457 actionListBranches.append(a);
458 a = new QAction( tr( "Edit heading","Edit menu" ), this);
459 a->setStatusTip (tr( "edit Heading" ));
460 a->setShortcut (Qt::Key_Return ); //Edit heading
461 //a->setShortcutContext (Qt::WindowShortcut);
463 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
464 actionListBranches.append(a);
465 editMenu->addAction (a);
467 a = new QAction( tr( "Edit heading","Edit menu" ), this);
468 a->setStatusTip (tr( "edit Heading" ));
469 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
470 a->setShortcutContext (Qt::WindowShortcut);
472 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
473 actionListBranches.append(a);
475 // Shortcut to delete selection
476 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
477 a->setStatusTip (tr( "Delete Selection" ));
478 a->setShortcut ( Qt::Key_Delete); //Delete selection
479 a->setShortcutContext (Qt::WindowShortcut);
481 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
484 // Shortcut to add branch
485 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
486 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
487 alt->setShortcut (Qt::Key_A); //Add branch
488 alt->setShortcutContext (Qt::WindowShortcut);
490 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
491 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
492 a->setStatusTip ( tr( "Add a branch as child of selection" ));
493 a->setShortcut (Qt::Key_Insert); //Add branch
494 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
495 actionListBranches.append(a);
496 #if defined (Q_OS_MACX)
497 // In OSX show different shortcut in menues, the keys work indepently always
498 actionEditAddBranch=alt;
500 actionEditAddBranch=a;
502 editMenu->addAction (actionEditAddBranch);
503 tb->addAction (actionEditAddBranch);
506 // Add branch by inserting it at selection
507 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
508 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
509 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
510 a->setShortcutContext (Qt::WindowShortcut);
512 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
513 a->setEnabled (false);
514 actionListBranches.append(a);
515 actionEditAddBranchBefore=a;
516 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
517 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
518 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
519 a->setShortcutContext (Qt::WindowShortcut);
521 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
522 actionListBranches.append(a);
525 a = new QAction(tr( "Add branch above","Edit menu" ), this);
526 a->setStatusTip ( tr( "Add a branch above selection" ));
527 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
528 a->setShortcutContext (Qt::WindowShortcut);
530 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
531 a->setEnabled (false);
532 actionListBranches.append(a);
533 actionEditAddBranchAbove=a;
534 a = new QAction(tr( "Add branch above","Edit menu" ), this);
535 a->setStatusTip ( tr( "Add a branch above selection" ));
536 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
537 a->setShortcutContext (Qt::WindowShortcut);
539 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
540 actionListBranches.append(a);
543 a = new QAction(tr( "Add branch below","Edit menu" ), this);
544 a->setStatusTip ( tr( "Add a branch below selection" ));
545 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
546 a->setShortcutContext (Qt::WindowShortcut);
548 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
549 a->setEnabled (false);
550 actionListBranches.append(a);
551 actionEditAddBranchBelow=a;
552 a = new QAction(tr( "Add branch below","Edit menu" ), this);
553 a->setStatusTip ( tr( "Add a branch below selection" ));
554 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
555 a->setShortcutContext (Qt::WindowShortcut);
557 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
558 actionListBranches.append(a);
560 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
561 a->setStatusTip ( tr( "Move branch up" ) );
562 a->setShortcut (Qt::Key_PageUp ); // Move branch up
563 a->setEnabled (false);
565 editMenu->addAction (a);
566 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
569 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
570 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
571 a->setStatusTip (tr( "Move branch down" ) );
572 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
573 a->setEnabled (false);
575 editMenu->addAction (a);
576 actionEditMoveDown=a;
579 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
580 a->setShortcut ( Qt::Key_ScrollLock );
581 a->setStatusTip (tr( "Scroll branch" ) );
582 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
584 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
585 alt->setShortcut ( Qt::Key_S ); // Scroll branch
586 alt->setStatusTip (tr( "Scroll branch" ));
587 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
588 #if defined(Q_OS_MACX)
589 actionEditToggleScroll=alt;
591 actionEditToggleScroll=a;
593 actionEditToggleScroll->setEnabled (false);
594 actionEditToggleScroll->setToggleAction(true);
595 tb->addAction (actionEditToggleScroll);
596 editMenu->addAction ( actionEditToggleScroll);
597 editMenu->addAction (actionEditToggleScroll);
600 actionListBranches.append(actionEditToggleScroll);
602 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
603 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
604 editMenu->addAction (a);
605 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
607 editMenu->addSeparator();
609 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
610 a->setStatusTip (tr( "Find" ) );
611 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
612 editMenu->addAction (a);
613 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
615 editMenu->addSeparator();
617 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
618 a->setShortcut (Qt::CTRL + Qt::Key_U );
619 a->setShortcut (tr( "Open URL" ));
622 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
625 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
626 a->setStatusTip (tr( "Open URL in new tab" ));
627 //a->setShortcut (Qt::CTRL+Qt::Key_U );
629 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
630 actionEditOpenURLTab=a;
632 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
633 a->setStatusTip (tr( "Open all URLs in subtree" ));
635 actionListBranches.append(a);
636 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
637 actionEditOpenMultipleURLTabs=a;
639 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
640 a->setStatusTip ( tr( "Edit URL" ) );
641 //a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
642 a->setShortcut ( Qt::Key_U );
643 a->setShortcutContext (Qt::WindowShortcut);
644 actionListBranches.append(a);
646 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
649 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
650 a->setStatusTip ( tr( "Edit local URL" ) );
651 a->setShortcut (Qt::SHIFT + Qt::Key_U );
652 a->setShortcutContext (Qt::WindowShortcut);
653 actionListBranches.append(a);
655 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
658 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
659 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
660 a->setEnabled (false);
661 actionListBranches.append(a);
662 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
663 actionEditHeading2URL=a;
665 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
666 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
667 a->setEnabled (false);
668 actionListBranches.append(a);
669 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
670 actionEditBugzilla2URL=a;
672 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
673 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
674 a->setEnabled (false);
675 actionListBranches.append(a);
676 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
677 actionEditFATE2URL=a;
679 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
680 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
682 a->setEnabled (false);
683 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
684 actionEditOpenVymLink=a;
686 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
687 a->setStatusTip ( tr( "Open all vym links in subtree" ));
688 a->setEnabled (false);
689 actionListBranches.append(a);
690 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
691 actionEditOpenMultipleVymLinks=a;
694 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
695 a->setEnabled (false);
696 a->setStatusTip ( tr( "Edit link to another vym map" ));
697 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
698 actionListBranches.append(a);
701 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
702 a->setStatusTip ( tr( "Delete link to another vym map" ));
703 a->setEnabled (false);
704 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
705 actionEditDeleteVymLink=a;
707 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
708 a->setStatusTip ( tr( "Hide object in exports" ) );
709 a->setShortcut (Qt::Key_H );
710 a->setToggleAction(true);
712 a->setEnabled (false);
713 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
714 actionEditToggleHideExport=a;
716 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
717 a->setStatusTip ( tr( "Edit Map Info" ));
718 a->setEnabled (true);
719 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
722 // Import at selection (adding to selection)
723 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
724 a->setStatusTip (tr( "Add map at selection" ));
725 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
726 a->setEnabled (false);
727 actionListBranches.append(a);
728 actionEditImportAdd=a;
730 // Import at selection (replacing selection)
731 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
732 a->setStatusTip (tr( "Replace selection with map" ));
733 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
734 a->setEnabled (false);
735 actionListBranches.append(a);
736 actionEditImportReplace=a;
739 a = new QAction( tr( "Save selection","Edit menu" ), this);
740 a->setStatusTip (tr( "Save selection" ));
741 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
742 a->setEnabled (false);
743 actionListBranches.append(a);
744 actionEditSaveBranch=a;
746 // Only remove branch, not its childs
747 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
748 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
749 a->setShortcut (Qt::ALT + Qt::Key_Delete );
750 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
751 a->setEnabled (false);
753 actionListBranches.append(a);
754 actionEditDeleteKeepChilds=a;
756 // Only remove childs of a branch
757 a = new QAction( tr( "Remove childs","Edit menu" ), this);
758 a->setStatusTip (tr( "Remove childs of branch" ));
759 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
760 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
761 a->setEnabled (false);
762 actionListBranches.append(a);
763 actionEditDeleteChilds=a;
765 // Shortcuts for navigating with cursor:
766 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
767 a->setStatusTip ( tr( "Select upper branch" ));
768 a->setShortcut (Qt::Key_Up );
769 a->setShortcutContext (Qt::WindowShortcut);
771 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
772 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
773 a->setStatusTip (tr( "Select lower branch" ));
774 a->setShortcut ( Qt::Key_Down );
775 a->setShortcutContext (Qt::WindowShortcut);
777 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
778 a = new QAction(tr( "Select left branch","Edit menu" ), this);
779 a->setStatusTip ( tr( "Select left branch" ));
780 a->setShortcut (Qt::Key_Left );
781 a->setShortcutContext (Qt::WindowShortcut);
783 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
784 a = new QAction( tr( "Select child branch","Edit menu" ), this);
785 a->setStatusTip (tr( "Select right branch" ));
786 a->setShortcut (Qt::Key_Right);
787 a->setShortcutContext (Qt::WindowShortcut);
789 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
790 a = new QAction( tr( "Select first branch","Edit menu" ), this);
791 a->setStatusTip (tr( "Select first branch" ));
792 a->setShortcut (Qt::Key_Home );
793 a->setShortcutContext (Qt::WindowShortcut);
795 a->setEnabled (false);
796 editMenu->addAction (a);
797 actionListBranches.append(a);
798 actionEditSelectFirst=a;
799 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
800 a = new QAction( tr( "Select last branch","Edit menu" ),this);
801 a->setStatusTip (tr( "Select last branch" ));
802 a->setShortcut ( Qt::Key_End );
803 a->setShortcutContext (Qt::WindowShortcut);
805 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
806 a->setEnabled (false);
807 editMenu->addAction (a);
808 actionListBranches.append(a);
809 actionEditSelectLast=a;
811 a = new QAction( tr( "Add Image...","Edit menu" ), this);
812 a->setStatusTip (tr( "Add Image" ));
813 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
814 actionEditLoadImage=a;
816 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
817 a->setStatusTip (tr( "Set properties for selection" ));
818 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
819 a->setShortcutContext (Qt::WindowShortcut);
820 a->setToggleAction (true);
822 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
823 actionViewTogglePropertyWindow=a;
827 void Main::setupFormatActions()
829 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
831 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
832 tb->setObjectName ("formatTB");
835 pix.fill (Qt::black);
836 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
837 a->setStatusTip ( tr( "Set Color" ));
838 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
840 formatMenu->addAction (a);
842 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
843 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
844 a->setShortcut (Qt::CTRL + Qt::Key_K );
845 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
846 a->setEnabled (false);
848 formatMenu->addAction (a);
849 actionListBranches.append(a);
850 actionFormatPickColor=a;
852 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
853 a->setStatusTip ( tr( "Color branch" ) );
854 a->setShortcut (Qt::CTRL + Qt::Key_B);
855 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
856 a->setEnabled (false);
858 formatMenu->addAction (a);
859 actionListBranches.append(a);
860 actionFormatColorSubtree=a;
862 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
863 a->setStatusTip ( tr( "Color Subtree" ));
864 a->setShortcut (Qt::CTRL + Qt::Key_T);
865 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
866 a->setEnabled (false);
867 formatMenu->addAction (a);
869 actionListBranches.append(a);
870 actionFormatColorSubtree=a;
872 formatMenu->addSeparator();
873 actionGroupFormatLinkStyles=new QActionGroup ( this);
874 actionGroupFormatLinkStyles->setExclusive (true);
875 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
876 a->setStatusTip (tr( "Line" ));
877 a->setToggleAction(true);
878 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
879 formatMenu->addAction (a);
880 actionFormatLinkStyleLine=a;
881 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
882 a->setStatusTip (tr( "Line" ));
883 a->setToggleAction(true);
884 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
885 formatMenu->addAction (a);
886 actionFormatLinkStyleParabel=a;
887 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
888 a->setStatusTip (tr( "PolyLine" ));
889 a->setToggleAction(true);
890 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
891 formatMenu->addAction (a);
892 actionFormatLinkStylePolyLine=a;
893 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
894 a->setStatusTip (tr( "PolyParabel" ) );
895 a->setToggleAction(true);
896 a->setChecked (true);
897 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
898 formatMenu->addAction (a);
899 actionFormatLinkStylePolyParabel=a;
901 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
902 a->setStatusTip (tr( "Hide link" ));
903 a->setToggleAction(true);
904 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
905 actionFormatHideLinkUnselected=a;
907 formatMenu->addSeparator();
908 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
909 a->setStatusTip (tr( "Use same color for links and headings" ));
910 a->setToggleAction(true);
911 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
912 formatMenu->addAction (a);
913 actionFormatLinkColorHint=a;
915 pix.fill (Qt::white);
916 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
917 a->setStatusTip (tr( "Set Link Color" ));
918 formatMenu->addAction (a);
919 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
920 actionFormatLinkColor=a;
922 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
923 a->setStatusTip (tr( "Set Selection Color" ));
924 formatMenu->addAction (a);
925 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
926 actionFormatSelectionColor=a;
928 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
929 a->setStatusTip (tr( "Set Background Color" ));
930 formatMenu->addAction (a);
931 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
932 actionFormatBackColor=a;
934 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
935 a->setStatusTip (tr( "Set Background image" ));
936 formatMenu->addAction (a);
937 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
938 actionFormatBackImage=a;
942 void Main::setupViewActions()
944 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
945 tb->setLabel( "View Actions" );
946 tb->setObjectName ("viewTB");
947 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
950 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
951 a->setStatusTip ( tr( "Zoom reset" ) );
952 a->setShortcut (Qt::CTRL + Qt::Key_0 );
954 viewMenu->addAction (a);
955 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
957 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
958 a->setStatusTip (tr( "Zoom in" ));
959 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
961 viewMenu->addAction (a);
962 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
964 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
965 a->setStatusTip (tr( "Zoom out" ));
966 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
968 viewMenu->addAction (a);
969 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
971 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
972 a->setStatusTip (tr( "Show selection" ));
973 a->setShortcut (Qt::Key_Period);
975 viewMenu->addAction (a);
976 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
978 viewMenu->addSeparator();
980 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
981 a->setStatusTip ( tr( "Show Note Editor" ));
982 a->setShortcut ( Qt::CTRL + Qt::Key_E );
983 a->setToggleAction(true);
985 viewMenu->addAction (a);
986 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
987 actionViewToggleNoteEditor=a;
989 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
990 a->setStatusTip ( tr( "Show History Window" ));
991 a->setShortcut ( Qt::CTRL + Qt::Key_H );
992 a->setToggleAction(true);
994 viewMenu->addAction (a);
995 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
996 actionViewToggleHistoryWindow=a;
998 viewMenu->addAction (actionViewTogglePropertyWindow);
1000 viewMenu->addSeparator();
1002 a = new QAction(tr( "Antialiasing","View action" ),this );
1003 a->setStatusTip ( tr( "Antialiasing" ));
1004 a->setToggleAction(true);
1005 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1006 viewMenu->addAction (a);
1007 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1008 actionViewToggleAntiAlias=a;
1010 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1011 a->setStatusTip (a->text());
1012 a->setToggleAction(true);
1013 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1014 viewMenu->addAction (a);
1015 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1016 actionViewToggleSmoothPixmapTransform=a;
1018 a = new QAction(tr( "Next Map","View action" ), this);
1019 a->setStatusTip (a->text());
1020 a->setShortcut (Qt::ALT + Qt::Key_N );
1021 viewMenu->addAction (a);
1022 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1024 a = new QAction (tr( "Previous Map","View action" ), this );
1025 a->setStatusTip (a->text());
1026 a->setShortcut (Qt::ALT + Qt::Key_P );
1027 viewMenu->addAction (a);
1028 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1032 void Main::setupModeActions()
1034 //QPopupMenu *menu = new QPopupMenu( this );
1035 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1037 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1038 tb->setObjectName ("modesTB");
1040 actionGroupModModes=new QActionGroup ( this);
1041 actionGroupModModes->setExclusive (true);
1042 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1043 a->setShortcut (Qt::Key_J);
1044 a->setStatusTip ( tr( "Use modifier to color branches" ));
1045 a->setToggleAction(true);
1048 actionModModeColor=a;
1050 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1051 a->setShortcut( Qt::Key_K);
1052 a->setStatusTip( tr( "Use modifier to copy" ));
1053 a->setToggleAction(true);
1055 actionModModeCopy=a;
1057 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1058 a->setShortcut (Qt::Key_L);
1059 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1060 a->setToggleAction(true);
1062 actionModModeXLink=a;
1066 void Main::setupFlagActions()
1068 // Create System Flags
1069 systemFlagsDefault = new FlagRowObj ();
1070 systemFlagsDefault->setVisibility (false);
1071 systemFlagsDefault->setName ("systemFlagsDef");
1073 FlagObj *fo = new FlagObj ();
1074 fo->load(QPixmap(flagsPath+"flag-note.png"));
1075 fo->setName("note");
1076 fo->setToolTip(tr("Note","Systemflag"));
1077 systemFlagsDefault->addFlag (fo); // makes deep copy
1079 fo->load(QPixmap(flagsPath+"flag-url.png"));
1081 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1082 systemFlagsDefault->addFlag (fo);
1084 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1085 fo->setName("vymLink");
1086 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1087 systemFlagsDefault->addFlag (fo);
1089 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1090 fo->setName("scrolledright");
1091 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1092 systemFlagsDefault->addFlag (fo);
1094 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1095 fo->setName("tmpUnscrolledright");
1096 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1097 systemFlagsDefault->addFlag (fo);
1099 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1100 fo->setName("hideInExport");
1101 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1102 systemFlagsDefault->addFlag (fo);
1104 // Create Standard Flags
1105 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1106 tb->setObjectName ("standardFlagTB");
1108 standardFlagsDefault = new FlagRowObj ();
1109 standardFlagsDefault->setVisibility (false);
1110 standardFlagsDefault->setName ("standardFlagsDef");
1111 standardFlagsDefault->setToolBar (tb);
1113 fo->load(flagsPath+"flag-exclamationmark.png");
1114 fo->setName ("exclamationmark");
1115 fo->setGroup("standard-mark");
1116 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1119 a->setCheckable(true);
1120 a->setObjectName(fo->getName());
1121 a->setToolTip(tr("Take care!","Standardflag"));
1122 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1123 standardFlagsDefault->addFlag (fo); // makes deep copy
1125 fo->load(flagsPath+"flag-questionmark.png");
1126 fo->setName("questionmark");
1127 fo->setGroup("standard-mark");
1128 a=new QAction (fo->getPixmap(),fo->getName(),this);
1131 a->setCheckable(true);
1132 a->setObjectName(fo->getName());
1133 a->setToolTip(tr("Really?","Standardflag"));
1134 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1135 standardFlagsDefault->addFlag (fo);
1137 fo->load(flagsPath+"flag-hook-green.png");
1138 fo->setName("hook-green");
1139 fo->setGroup("standard-hook");
1140 a=new QAction (fo->getPixmap(),fo->getName(),this);
1143 a->setCheckable(true);
1144 a->setObjectName(fo->getName());
1145 a->setToolTip(tr("ok!","Standardflag"));
1146 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1147 standardFlagsDefault->addFlag (fo);
1149 fo->load(flagsPath+"flag-cross-red.png");
1150 fo->setName("cross-red");
1151 fo->setGroup("standard-hook");
1152 a=new QAction (fo->getPixmap(),fo->getName(),this);
1155 a->setCheckable(true);
1156 a->setObjectName(fo->getName());
1157 a->setToolTip(tr("Not ok!","Standardflag"));
1158 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1159 standardFlagsDefault->addFlag (fo);
1161 fo->load(flagsPath+"flag-stopsign.png");
1162 fo->setName("stopsign");
1163 a=new QAction (fo->getPixmap(),fo->getName(),this);
1166 a->setCheckable(true);
1167 a->setObjectName(fo->getName());
1168 a->setToolTip(tr("This won't work!","Standardflag"));
1169 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1170 standardFlagsDefault->addFlag (fo);
1172 fo->load(flagsPath+"flag-smiley-good.png");
1173 fo->setName("smiley-good");
1174 fo->setGroup("standard-smiley");
1175 a=new QAction (fo->getPixmap(),fo->getName(),this);
1178 a->setCheckable(true);
1179 a->setObjectName(fo->getName());
1180 a->setToolTip(tr("Good","Standardflag"));
1181 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1182 standardFlagsDefault->addFlag (fo);
1184 fo->load(flagsPath+"flag-smiley-sad.png");
1185 fo->setName("smiley-sad");
1186 fo->setGroup("standard-smiley");
1187 a=new QAction (fo->getPixmap(),fo->getName(),this);
1190 a->setCheckable(true);
1191 a->setObjectName(fo->getName());
1192 a->setToolTip(tr("Bad","Standardflag"));
1193 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1194 standardFlagsDefault->addFlag (fo);
1196 fo->load(flagsPath+"flag-smiley-omg.png");
1197 // Original omg.png (in KDE emoticons)
1198 fo->setName("smiley-omg");
1199 fo->setGroup("standard-smiley");
1200 a=new QAction (fo->getPixmap(),fo->getName(),this);
1203 a->setCheckable(true);
1204 a->setObjectName(fo->getName());
1205 a->setToolTip(tr("Oh no!","Standardflag"));
1206 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1207 standardFlagsDefault->addFlag (fo);
1209 fo->load(flagsPath+"flag-kalarm.png");
1210 fo->setName("clock");
1211 a=new QAction (fo->getPixmap(),fo->getName(),this);
1214 a->setCheckable(true);
1215 a->setObjectName(fo->getName());
1216 a->setToolTip(tr("Time critical","Standardflag"));
1217 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1218 standardFlagsDefault->addFlag (fo);
1220 fo->load(flagsPath+"flag-phone.png");
1221 fo->setName("phone");
1222 a=new QAction (fo->getPixmap(),fo->getName(),this);
1225 a->setCheckable(true);
1226 a->setObjectName(fo->getName());
1227 a->setToolTip(tr("Call...","Standardflag"));
1228 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1229 standardFlagsDefault->addFlag (fo);
1231 fo->load(flagsPath+"flag-lamp.png");
1232 fo->setName("lamp");
1233 a=new QAction (fo->getPixmap(),fo->getName(),this);
1236 a->setCheckable(true);
1237 a->setObjectName(fo->getName());
1238 a->setToolTip(tr("Idea!","Standardflag"));
1239 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1240 standardFlagsDefault->addFlag (fo);
1242 fo->load(flagsPath+"flag-arrow-up.png");
1243 fo->setName("arrow-up");
1244 fo->setGroup("standard-arrow");
1245 a=new QAction (fo->getPixmap(),fo->getName(),this);
1248 a->setCheckable(true);
1249 a->setObjectName(fo->getName());
1250 a->setToolTip(tr("Important","Standardflag"));
1251 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1252 standardFlagsDefault->addFlag (fo);
1254 fo->load(flagsPath+"flag-arrow-down.png");
1255 fo->setName("arrow-down");
1256 fo->setGroup("standard-arrow");
1257 a=new QAction (fo->getPixmap(),fo->getName(),this);
1260 a->setCheckable(true);
1261 a->setObjectName(fo->getName());
1262 a->setToolTip(tr("Unimportant","Standardflag"));
1263 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1264 standardFlagsDefault->addFlag (fo);
1266 fo->load(flagsPath+"flag-arrow-2up.png");
1267 fo->setName("2arrow-up");
1268 fo->setGroup("standard-arrow");
1269 a=new QAction (fo->getPixmap(),fo->getName(),this);
1272 a->setCheckable(true);
1273 a->setObjectName(fo->getName());
1274 a->setToolTip(tr("Very important!","Standardflag"));
1275 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1276 standardFlagsDefault->addFlag (fo);
1278 fo->load(flagsPath+"flag-arrow-2down.png");
1279 fo->setName("2arrow-down");
1280 fo->setGroup("standard-arrow");
1281 a=new QAction (fo->getPixmap(),fo->getName(),this);
1284 a->setCheckable(true);
1285 a->setObjectName(fo->getName());
1286 a->setToolTip(tr("Very unimportant!","Standardflag"));
1287 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1288 standardFlagsDefault->addFlag (fo);
1290 fo->load(flagsPath+"flag-thumb-up.png");
1291 fo->setName("thumb-up");
1292 fo->setGroup("standard-thumb");
1293 a=new QAction (fo->getPixmap(),fo->getName(),this);
1296 a->setCheckable(true);
1297 a->setObjectName(fo->getName());
1298 a->setToolTip(tr("I like this","Standardflag"));
1299 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1300 standardFlagsDefault->addFlag (fo);
1302 fo->load(flagsPath+"flag-thumb-down.png");
1303 fo->setName("thumb-down");
1304 fo->setGroup("standard-thumb");
1305 a=new QAction (fo->getPixmap(),fo->getName(),this);
1308 a->setCheckable(true);
1309 a->setObjectName(fo->getName());
1310 a->setToolTip(tr("I do not like this","Standardflag"));
1311 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1312 standardFlagsDefault->addFlag (fo);
1314 fo->load(flagsPath+"flag-rose.png");
1315 fo->setName("rose");
1316 a=new QAction (fo->getPixmap(),fo->getName(),this);
1319 a->setCheckable(true);
1320 a->setObjectName(fo->getName());
1321 a->setToolTip(tr("Rose","Standardflag"));
1322 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1323 standardFlagsDefault->addFlag (fo);
1325 fo->load(flagsPath+"flag-heart.png");
1326 fo->setName("heart");
1327 a=new QAction (fo->getPixmap(),fo->getName(),this);
1329 a->setCheckable(true);
1330 a->setObjectName(fo->getName());
1331 a->setToolTip(tr("I just love... ","Standardflag"));
1332 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1333 standardFlagsDefault->addFlag (fo);
1335 fo->load(flagsPath+"flag-present.png");
1336 fo->setName("present");
1337 a=new QAction (fo->getPixmap(),fo->getName(),this);
1340 a->setCheckable(true);
1341 a->setObjectName(fo->getName());
1342 a->setToolTip(tr("Surprise!","Standardflag"));
1343 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1344 standardFlagsDefault->addFlag (fo);
1346 fo->load(flagsPath+"flag-flash.png");
1347 fo->setName("flash");
1348 a=new QAction (fo->getPixmap(),fo->getName(),this);
1351 a->setCheckable(true);
1352 a->setObjectName(fo->getName());
1353 a->setToolTip(tr("Dangerous","Standardflag"));
1354 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1355 standardFlagsDefault->addFlag (fo);
1357 fo->load(flagsPath+"flag-info.png");
1358 // Original: xsldbg_output.png
1359 fo->setName("info");
1360 a=new QAction (fo->getPixmap(),fo->getName(),this);
1363 a->setCheckable(true);
1364 a->setObjectName(fo->getName());
1365 a->setToolTip(tr("Info","Standardflag"));
1366 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1367 standardFlagsDefault->addFlag (fo);
1369 fo->load(flagsPath+"flag-lifebelt.png");
1370 // Original khelpcenter.png
1371 fo->setName("lifebelt");
1372 a=new QAction (fo->getPixmap(),fo->getName(),this);
1375 a->setCheckable(true);
1376 a->setObjectName(fo->getName());
1377 a->setToolTip(tr("This will help","Standardflag"));
1378 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1379 standardFlagsDefault->addFlag (fo);
1385 void Main::setupNetworkActions()
1387 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1389 QMenu *netMenu = menuBar()->addMenu( "&Network" );
1393 a = new QAction( "Start TCPserver for MapEditor",this);
1394 //a->setStatusTip ( "Set application to open pdf files"));
1395 a->setShortcut ( Qt::Key_T ); //New TCP server
1396 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1397 netMenu->addAction (a);
1399 a = new QAction( "Connect MapEditor to server",this);
1400 //a->setStatusTip ( "Set application to open pdf files"));
1401 a->setShortcut ( Qt::Key_C ); // Connect to server
1402 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1403 netMenu->addAction (a);
1407 void Main::setupSettingsActions()
1409 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1413 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1414 a->setStatusTip ( tr( "Set application to open pdf files"));
1415 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1416 settingsMenu->addAction (a);
1418 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1419 a->setStatusTip( tr( "Set application to open external links"));
1420 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1421 settingsMenu->addAction (a);
1423 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1424 a->setStatusTip( tr( "Set path for macros"));
1425 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1426 settingsMenu->addAction (a);
1428 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1429 a->setStatusTip( tr( "Set number of undo levels"));
1430 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1431 settingsMenu->addAction (a);
1433 settingsMenu->addSeparator();
1435 a = new QAction( tr( "Autosave","Settings action"), this);
1436 a->setStatusTip( tr( "Autosave"));
1437 a->setToggleAction(true);
1438 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1439 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1440 settingsMenu->addAction (a);
1441 actionSettingsAutosaveToggle=a;
1443 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1444 a->setStatusTip( tr( "Autosave time"));
1445 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1446 settingsMenu->addAction (a);
1447 actionSettingsAutosaveTime=a;
1449 settingsMenu->addSeparator();
1451 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1452 a->setStatusTip( tr( "Edit branch after adding it" ));
1453 a->setToggleAction(true);
1454 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1455 settingsMenu->addAction (a);
1456 actionSettingsAutoEditNewBranch=a;
1458 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1459 a->setStatusTip( tr( "Select branch after adding it" ));
1460 a->setToggleAction(true);
1461 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1462 settingsMenu->addAction (a);
1463 actionSettingsAutoSelectNewBranch=a;
1465 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1466 a->setStatusTip( tr( "Select heading before editing" ));
1467 a->setToggleAction(true);
1468 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1469 settingsMenu->addAction (a);
1470 actionSettingsAutoSelectText=a;
1472 a= new QAction( tr( "Delete key","Settings action" ), this);
1473 a->setStatusTip( tr( "Delete key for deleting branches" ));
1474 a->setToggleAction(true);
1475 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1476 settingsMenu->addAction (a);
1477 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1478 actionSettingsUseDelKey=a;
1480 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1481 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1482 a->setToggleAction(true);
1483 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1484 settingsMenu->addAction (a);
1485 actionSettingsUseFlagGroups=a;
1487 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1488 a->setStatusTip( tr( "Use hide flag during exports " ));
1489 a->setToggleAction(true);
1490 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1491 settingsMenu->addAction (a);
1492 actionSettingsUseHideExport=a;
1496 void Main::setupTestActions()
1498 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1501 a = new QAction( "Test function 1" , this);
1502 a->setStatusTip( "Call test function 1" );
1503 testMenu->addAction (a);
1504 //a->setShortcut (Qt::Key_F4 );
1505 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1507 a = new QAction( "Test function 2" , this);
1508 a->setStatusTip( "Call test function 2" );
1509 //a->setShortcut (Qt::Key_F4 );
1510 testMenu->addAction (a);
1511 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1513 a = new QAction( "Command" , this);
1514 a->setStatusTip( "Enter command to call in editor" );
1515 //a->setShortcut (Qt::Key_F5 );
1516 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1517 testMenu->addAction (a);
1521 void Main::setupHelpActions()
1523 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1526 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1527 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1528 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1529 helpMenu->addAction (a);
1531 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1532 a->setStatusTip( tr( "Open VYM example maps " ));
1533 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1534 helpMenu->addAction (a);
1536 a = new QAction( tr( "About VYM","Help action" ), this);
1537 a->setStatusTip( tr( "About VYM")+vymName);
1538 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1539 helpMenu->addAction (a);
1541 a = new QAction( tr( "About QT","Help action" ), this);
1542 a->setStatusTip( tr( "Information about QT toolkit" ));
1543 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1544 helpMenu->addAction (a);
1548 void Main::setupContextMenus()
1552 // Context Menu for branch or mapcenter
1553 branchContextMenu =new QMenu (this);
1554 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1555 branchContextMenu->addSeparator();
1558 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1559 branchAddContextMenu->addAction (actionEditPaste );
1560 branchAddContextMenu->addAction ( actionEditAddBranch );
1561 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1562 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1563 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1564 branchAddContextMenu->addSeparator();
1565 branchAddContextMenu->addAction ( actionEditImportAdd );
1566 branchAddContextMenu->addAction ( actionEditImportReplace );
1569 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1570 branchRemoveContextMenu->addAction (actionEditCut);
1571 branchRemoveContextMenu->addAction ( actionEditDelete );
1572 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1573 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1576 actionEditSaveBranch->addTo( branchContextMenu );
1578 branchContextMenu->addSeparator();
1579 branchContextMenu->addAction ( actionEditLoadImage);
1581 // Submenu for Links (URLs, vymLinks)
1582 branchLinksContextMenu =new QMenu (this);
1584 branchContextMenu->addSeparator();
1585 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1586 branchLinksContextMenu->addAction ( actionEditOpenURL );
1587 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1588 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1589 branchLinksContextMenu->addAction ( actionEditURL );
1590 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1591 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1592 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1594 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1596 branchLinksContextMenu->addSeparator();
1597 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1598 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1599 branchLinksContextMenu->addAction ( actionEditVymLink );
1600 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1603 // Context Menu for XLinks in a branch menu
1604 // This will be populated "on demand" in MapEditor::updateActions
1605 branchContextMenu->addSeparator();
1606 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1607 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1608 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1609 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1612 // Context menu for floatimage
1613 floatimageContextMenu =new QMenu (this);
1614 a= new QAction (tr ("Save image","Context action"),this);
1615 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1616 floatimageContextMenu->addAction (a);
1618 floatimageContextMenu->addSeparator();
1619 actionEditCopy->addTo( floatimageContextMenu );
1620 actionEditCut->addTo( floatimageContextMenu );
1622 floatimageContextMenu->addSeparator();
1623 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1626 // Context menu for canvas
1627 canvasContextMenu =new QMenu (this);
1628 actionEditMapInfo->addTo( canvasContextMenu );
1629 canvasContextMenu->insertSeparator();
1630 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1631 canvasContextMenu->insertSeparator();
1632 actionFormatLinkColorHint->addTo( canvasContextMenu );
1633 actionFormatLinkColor->addTo( canvasContextMenu );
1634 actionFormatSelectionColor->addTo( canvasContextMenu );
1635 actionFormatBackColor->addTo( canvasContextMenu );
1636 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1638 // Menu for last opened files
1640 for (int i = 0; i < MaxRecentFiles; ++i)
1642 recentFileActions[i] = new QAction(this);
1643 recentFileActions[i]->setVisible(false);
1644 fileLastMapsMenu->addAction(recentFileActions[i]);
1645 connect(recentFileActions[i], SIGNAL(triggered()),
1646 this, SLOT(fileLoadRecent()));
1648 setupRecentMapsMenu();
1651 void Main::setupRecentMapsMenu()
1653 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1655 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1657 for (int i = 0; i < numRecentFiles; ++i) {
1658 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1659 recentFileActions[i]->setText(text);
1660 recentFileActions[i]->setData(files[i]);
1661 recentFileActions[i]->setVisible(true);
1663 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1664 recentFileActions[j]->setVisible(false);
1667 void Main::setupMacros()
1669 for (int i = 0; i <= 11; i++)
1671 macroActions[i] = new QAction(this);
1672 macroActions[i]->setData(i);
1673 addAction (macroActions[i]);
1674 connect(macroActions[i], SIGNAL(triggered()),
1675 this, SLOT(callMacro()));
1677 macroActions[0]->setShortcut ( Qt::Key_F1 );
1678 macroActions[1]->setShortcut ( Qt::Key_F2 );
1679 macroActions[2]->setShortcut ( Qt::Key_F3 );
1680 macroActions[3]->setShortcut ( Qt::Key_F4 );
1681 macroActions[4]->setShortcut ( Qt::Key_F5 );
1682 macroActions[5]->setShortcut ( Qt::Key_F6 );
1683 macroActions[6]->setShortcut ( Qt::Key_F7 );
1684 macroActions[7]->setShortcut ( Qt::Key_F8 );
1685 macroActions[8]->setShortcut ( Qt::Key_F9 );
1686 macroActions[9]->setShortcut ( Qt::Key_F10 );
1687 macroActions[10]->setShortcut ( Qt::Key_F11 );
1688 macroActions[11]->setShortcut ( Qt::Key_F12 );
1691 void Main::hideEvent (QHideEvent * )
1693 if (!textEditor->isMinimized() ) textEditor->hide();
1696 void Main::showEvent (QShowEvent * )
1698 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1702 MapEditor* Main::currentMapEditor() const
1704 if ( tabWidget->currentPage() &&
1705 tabWidget->currentPage()->inherits( "MapEditor" ) )
1706 return (MapEditor*)tabWidget->currentPage();
1711 void Main::editorChanged(QWidget *)
1713 // Unselect all possibly selected objects
1714 // (Important to update note editor)
1716 for (int i=0;i<=tabWidget->count() -1;i++)
1719 me=(MapEditor*)tabWidget->page(i);
1722 currentMapEditor()->reselect();
1724 // Update actions to in menus and toolbars according to editor
1728 void Main::fileNew()
1730 QString fn="unnamed";
1731 MapEditor* me = new MapEditor ( NULL);
1732 tabWidget->addTab (me,fn);
1733 tabWidget->showPage(me);
1734 me->viewport()->setFocus();
1735 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1736 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1738 // For the very first map we do not have flagrows yet...
1742 void Main::fileNewCopy()
1744 QString fn="unnamed";
1745 MapEditor* oldME =currentMapEditor();
1749 MapEditor* newME = new MapEditor ( NULL);
1752 tabWidget->addTab (newME,fn);
1753 tabWidget->showPage(newME);
1754 newME->viewport()->setFocus();
1755 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1756 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1757 // For the very first map we do not have flagrows yet...
1758 newME->select("mc:");
1759 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace);
1765 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1767 ErrorCode err=success;
1769 // fn is usually the archive, mapfile the file after uncompressing
1772 // Make fn absolute (needed for unzip)
1773 fn=QDir (fn).absPath();
1779 // Check, if map is already loaded
1781 while (i<=tabWidget->count() -1)
1783 me=(MapEditor*)tabWidget->page(i);
1784 if (me->getFilePath() == fn)
1786 // Already there, ask for confirmation
1787 QMessageBox mb( vymName,
1788 tr("The map %1\nis already opened."
1789 "Opening the same map in multiple editors may lead \n"
1790 "to confusion when finishing working with vym."
1791 "Do you want to").arg(fn),
1792 QMessageBox::Warning,
1793 QMessageBox::Yes | QMessageBox::Default,
1794 QMessageBox::Cancel | QMessageBox::Escape,
1795 QMessageBox::NoButton);
1796 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1797 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1800 case QMessageBox::Yes:
1802 i=tabWidget->count();
1804 case QMessageBox::Cancel:
1816 if ( !fn.isEmpty() )
1818 me = currentMapEditor();
1819 int tabIndex=tabWidget->currentPageIndex();
1820 // Check first, if mapeditor exists
1821 // If it is not default AND we want a new map,
1822 // create a new mapeditor in a new tab
1823 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1825 me= new MapEditor ( NULL);
1826 tabWidget->addTab (me,fn);
1827 tabIndex=tabWidget->indexOf (me);
1828 tabWidget->setCurrentPage (tabIndex);
1829 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1830 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1833 // Check, if file exists (important for creating new files
1834 // from command line
1835 if (!QFile(fn).exists() )
1837 QMessageBox mb( vymName,
1838 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1839 QMessageBox::Question,
1841 QMessageBox::Cancel | QMessageBox::Default,
1842 QMessageBox::NoButton );
1844 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1845 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1848 case QMessageBox::Yes:
1850 currentMapEditor()->setFilePath(fn);
1851 tabWidget->setTabLabel (currentMapEditor(),
1852 currentMapEditor()->getFileName() );
1853 statusBar()->message( "Created " + fn , statusbarTime );
1856 case QMessageBox::Cancel:
1857 // don't create new map
1858 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1865 //tabWidget->currentPage() won't be NULL here, because of above...
1866 tabWidget->showPage(me);
1867 me->viewport()->setFocus();
1869 // Create temporary directory for packing
1871 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1874 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1875 tr("Couldn't create temporary directory before load\n"));
1879 // Try to unzip file
1880 err=unzipDir (tmpMapDir,fn);
1884 me->setZipped(false);
1887 me->setZipped(true);
1889 // Look for mapname.xml
1890 mapfile= fn.left(fn.findRev(".",-1,true));
1891 mapfile=mapfile.section( '/', -1 );
1892 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1893 if (!file.exists() )
1895 // mapname.xml does not exist, well,
1896 // maybe someone renamed the mapname.vym file...
1897 // Try to find any .xml in the toplevel
1898 // directory of the .vym file
1899 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1900 if (flist.count()==1)
1902 // Only one entry, take this one
1903 mapfile=tmpMapDir + "/"+flist.first();
1906 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1907 *it=tmpMapDir + "/" + *it;
1908 // TODO Multiple entries, load all (but only the first one into this ME)
1909 //mainWindow->fileLoadFromTmp (flist);
1910 //returnCode=1; // Silently forget this attempt to load
1911 qWarning ("MainWindow::load (fn) multimap found...");
1914 if (flist.isEmpty() )
1916 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1917 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1920 } //file doesn't exist
1922 mapfile=file.name();
1927 // Save existing filename in case we import
1928 QString fn_org=me->getFilePath();
1930 // Finally load map into mapEditor
1931 me->setFilePath (mapfile,fn);
1932 err=me->load(mapfile,lmode);
1934 // Restore old (maybe empty) filepath, if this is an import
1936 me->setFilePath (fn_org);
1939 // Finally check for errors and go home
1942 if (lmode==NewMap) fileCloseMap();
1943 statusBar()->message( "Could not load " + fn, statusbarTime );
1948 me->setFilePath (fn);
1949 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1950 if (fn.left(9)!="/tmp/vym-")
1952 // Only append to lastMaps if not loaded from a tmpDir
1953 // e.g. imported bookmarks are in a tmpDir
1954 addRecentMap(me->getFilePath() );
1956 actionFilePrint->setEnabled (true);
1958 statusBar()->message( "Loaded " + fn, statusbarTime );
1962 removeDir (QDir(tmpMapDir));
1968 void Main::fileLoad(const LoadMode &lmode)
1970 QStringList filters;
1971 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1972 QFileDialog *fd=new QFileDialog( this);
1973 fd->setDir (lastFileDir);
1974 fd->setFileMode (QFileDialog::ExistingFiles);
1975 fd->setFilters (filters);
1979 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1982 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1985 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1991 if ( fd->exec() == QDialog::Accepted )
1993 lastFileDir=fd->directory().path();
1994 QStringList flist = fd->selectedFiles();
1995 QStringList::Iterator it = flist.begin();
1996 while( it != flist.end() )
1999 fileLoad(*it, lmode);
2006 void Main::fileLoad()
2011 void Main::fileLoadRecent()
2013 QAction *action = qobject_cast<QAction *>(sender());
2015 fileLoad (action->data().toString(), NewMap);
2018 void Main::addRecentMap (const QString &fileName)
2021 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2022 files.removeAll(fileName);
2023 files.prepend(fileName);
2024 while (files.size() > MaxRecentFiles)
2027 settings.setValue("/mainwindow/recentFileList", files);
2029 setupRecentMapsMenu();
2032 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
2034 // tmp dir for zipping
2038 ErrorCode err=success;
2040 QString safeFilePath;
2042 bool saveZipped=me->saveZipped();
2046 QString fn=me->getFilePath();
2047 // filename=unnamed, filepath="" in constructor of mapEditor
2048 if ( !fn.isEmpty() )
2050 // We have a filepath, go on saving
2051 // First remove existing file, we
2052 // don't want to add to old zip archives
2056 QMessageBox::warning( 0, tr( "Save Error" ),
2057 fn+ tr("\ncould not be removed before saving"));
2059 // Look, if we should zip the data:
2062 QMessageBox mb( vymName,
2063 tr("The map %1\ndid not use the compressed "
2064 "vym file format.\nWriting it uncompressed will also write images \n"
2065 "and flags and thus may overwrite files in the "
2066 "given directory\n\nDo you want to write the map").arg(fn),
2067 QMessageBox::Warning,
2068 QMessageBox::Yes | QMessageBox::Default,
2070 QMessageBox::Cancel | QMessageBox::Escape);
2071 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2072 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2073 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2076 case QMessageBox::Yes:
2077 // save compressed (default file format)
2080 case QMessageBox::No:
2081 // save uncompressed
2084 case QMessageBox::Cancel:
2093 // Create temporary directory for packing
2095 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2098 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2099 tr("Couldn't create temporary directory before save\n"));
2103 safeFilePath=me->getFilePath();
2104 me->setFilePath (tmpMapDir+"/"+
2105 me->getMapName()+ ".xml",
2107 me->save (savemode);
2108 me->setFilePath (safeFilePath);
2110 zipDir (tmpMapDir,fn);
2115 safeFilePath=me->getFilePath();
2116 me->setFilePath (fn, safeFilePath);
2117 me->save (savemode);
2118 me->setFilePath (safeFilePath);
2120 } // filepath available
2123 // We have no filepath yet,
2124 // call fileSaveAs() now, this will call fileSave()
2126 // First switch to editor
2127 tabWidget->setCurrentWidget (me);
2128 fileSaveAs(savemode);
2132 if (saveZipped && !tmpMapDir.isEmpty())
2134 removeDir (QDir(tmpMapDir));
2138 statusBar()->message(
2139 tr("Saved %1").arg(me->getFilePath()),
2141 addRecentMap (me->getFilePath() );
2143 statusBar()->message(
2144 tr("Couldn't save ").arg(me->getFilePath()),
2148 void Main::fileSave()
2150 fileSave (currentMapEditor(), CompleteMap);
2153 void Main::fileSave(MapEditor *me)
2155 fileSave (me,CompleteMap);
2158 void Main::fileSaveAs(const SaveMode& savemode)
2162 if (currentMapEditor())
2164 if (savemode==CompleteMap)
2165 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2167 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2168 if ( !fn.isEmpty() )
2170 // Check for existing file
2171 if (QFile (fn).exists())
2173 QMessageBox mb( vymName,
2174 tr("The file %1\nexists already. Do you want to").arg(fn),
2175 QMessageBox::Warning,
2176 QMessageBox::Yes | QMessageBox::Default,
2177 QMessageBox::Cancel | QMessageBox::Escape,
2178 QMessageBox::NoButton);
2179 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2180 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2183 case QMessageBox::Yes:
2186 case QMessageBox::Cancel:
2193 // New file, add extension to filename, if missing
2194 // This is always .vym or .vyp, depending on savemode
2195 if (savemode==CompleteMap)
2197 if (!fn.contains (".vym") && !fn.contains (".xml"))
2201 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2210 currentMapEditor()->setFilePath(fn);
2211 fileSave(currentMapEditor(), savemode);
2214 if (savemode==CompleteMap)
2215 tabWidget->setTabLabel (currentMapEditor(),
2216 currentMapEditor()->getFileName() );
2222 void Main::fileSaveAs()
2224 fileSaveAs (CompleteMap);
2227 void Main::fileImportKDEBookmarks()
2229 ImportKDEBookmarks im;
2231 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2232 currentMapEditor()->setFilePath ("");
2235 void Main::fileImportFirefoxBookmarks()
2237 Q3FileDialog *fd=new Q3FileDialog( this);
2238 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2239 fd->setMode (Q3FileDialog::ExistingFiles);
2240 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2241 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2244 if ( fd->exec() == QDialog::Accepted )
2246 ImportFirefoxBookmarks im;
2247 QStringList flist = fd->selectedFiles();
2248 QStringList::Iterator it = flist.begin();
2249 while( it != flist.end() )
2252 if (im.transform() &&
2253 success==fileLoad (im.getTransformedFile(),NewMap) &&
2254 currentMapEditor() )
2255 currentMapEditor()->setFilePath ("");
2262 void Main::fileImportMM()
2266 Q3FileDialog *fd=new Q3FileDialog( this);
2267 fd->setDir (lastFileDir);
2268 fd->setMode (Q3FileDialog::ExistingFiles);
2269 fd->addFilter ("Mind Manager (*.mmap)");
2270 fd->setCaption(tr("Import")+" "+"Mind Manager");
2273 if ( fd->exec() == QDialog::Accepted )
2275 lastFileDir=fd->dirPath();
2276 QStringList flist = fd->selectedFiles();
2277 QStringList::Iterator it = flist.begin();
2278 while( it != flist.end() )
2281 if (im.transform() &&
2282 success==fileLoad (im.getTransformedFile(),NewMap) &&
2283 currentMapEditor() )
2284 currentMapEditor()->setFilePath ("");
2293 void Main::fileImportDir()
2295 if (currentMapEditor())
2296 currentMapEditor()->importDir();
2299 void Main::fileExportXML()
2301 MapEditor *me=currentMapEditor();
2302 if (me) me->exportXML();
2306 void Main::fileExportXHTML()
2308 MapEditor *me=currentMapEditor();
2309 if (me) me->exportXHTML();
2312 void Main::fileExportImage()
2314 MapEditor *me=currentMapEditor();
2315 if (me) me->exportImage();
2318 void Main::fileExportASCII()
2320 MapEditor *me=currentMapEditor();
2321 if (me) me->exportASCII();
2324 void Main::fileExportCSV() //FIXME not scriptable yet
2326 MapEditor *me=currentMapEditor();
2330 ex.setMapCenter(me->getMapCenter());
2331 ex.addFilter ("CSV (*.csv)");
2332 ex.setDir(lastImageDir);
2333 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2334 if (ex.execDialog() )
2336 me->setExportMode(true);
2338 me->setExportMode(false);
2343 void Main::fileExportLaTeX() //FIXME not scriptable yet
2345 MapEditor *me=currentMapEditor();
2349 ex.setMapCenter(me->getMapCenter());
2350 ex.addFilter ("Tex (*.tex)");
2351 ex.setDir(lastImageDir);
2352 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2353 if (ex.execDialog() )
2355 me->setExportMode(true);
2357 me->setExportMode(false);
2362 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2364 ExportKDEBookmarks ex;
2365 MapEditor *me=currentMapEditor();
2368 ex.setMapCenter (me->getMapCenter() );
2373 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2375 ExportTaskjuggler ex;
2376 MapEditor *me=currentMapEditor();
2379 ex.setMapCenter (me->getMapCenter() );
2380 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2381 ex.setDir(lastImageDir);
2382 ex.addFilter ("Taskjuggler (*.tjp)");
2383 if (ex.execDialog() )
2385 me->setExportMode(true);
2387 me->setExportMode(false);
2392 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2394 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2395 // TODO add preview in dialog
2396 //ImagePreview *p =new ImagePreview (fd);
2397 //fd->setContentsPreviewEnabled( TRUE );
2398 //fd->setContentsPreview( p, p );
2399 //fd->setPreviewMode( QFileDialog::Contents );
2400 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2401 fd->setDir (QDir().current());
2402 if (fd->foundConfig())
2406 if ( fd->exec() == QDialog::Accepted )
2408 QString fn=fd->selectedFile();
2409 if (!fn.contains (".odp"))
2412 //lastImageDir=fn.left(fn.findRev ("/"));
2413 if (currentMapEditor())
2414 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2418 QMessageBox::warning(0,
2420 tr("Couldn't find configuration for export to Open Office\n"));
2424 void Main::fileCloseMap()
2426 if (currentMapEditor())
2428 if (currentMapEditor()->hasChanged())
2430 QMessageBox mb( vymName,
2431 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2432 QMessageBox::Warning,
2433 QMessageBox::Yes | QMessageBox::Default,
2435 QMessageBox::Cancel | QMessageBox::Escape );
2436 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2437 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2440 case QMessageBox::Yes:
2442 fileSave(currentMapEditor(), CompleteMap);
2444 case QMessageBox::No:
2445 // close without saving
2447 case QMessageBox::Cancel:
2452 currentMapEditor()->closeMap();
2453 tabWidget->removePage(currentMapEditor());
2454 if (tabWidget->count()==0)
2455 actionFilePrint->setEnabled (false);
2459 void Main::filePrint()
2461 if (currentMapEditor())
2462 currentMapEditor()->print();
2465 void Main::fileExitVYM()
2467 // Check if one or more editors have changed
2470 for (i=0;i<=tabWidget->count() -1;i++)
2473 me=(MapEditor*)tabWidget->page(i);
2475 // If something changed, ask what to do
2476 if (me->hasChanged())
2478 tabWidget->setCurrentPage(i);
2479 QMessageBox mb( vymName,
2480 tr("This map is not saved yet. Do you want to"),
2481 QMessageBox::Warning,
2482 QMessageBox::Yes | QMessageBox::Default,
2484 QMessageBox::Cancel | QMessageBox::Escape );
2485 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2486 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2489 mb.setActiveWindow();
2490 switch( mb.exec() ) {
2491 case QMessageBox::Yes:
2492 // save (the changed editors) and exit
2493 fileSave(currentMapEditor(), CompleteMap);
2495 case QMessageBox::No:
2496 // exit without saving
2498 case QMessageBox::Cancel:
2499 // don't save and don't exit
2503 } // loop over all MEs
2507 void Main::editUndo()
2509 if (currentMapEditor())
2510 currentMapEditor()->undo();
2513 void Main::editRedo()
2515 if (currentMapEditor())
2516 currentMapEditor()->redo();
2519 void Main::gotoHistoryStep (int i)
2521 if (currentMapEditor())
2522 currentMapEditor()->gotoHistoryStep (i);
2525 void Main::editCopy()
2527 if (currentMapEditor())
2528 currentMapEditor()->copy();
2531 void Main::editPaste()
2533 if (currentMapEditor())
2534 currentMapEditor()->paste();
2537 void Main::editCut()
2539 if (currentMapEditor())
2540 currentMapEditor()->cut();
2543 void Main::editOpenFindWindow()
2545 findWindow->popup();
2546 findWindow->raise();
2547 findWindow->setActiveWindow();
2550 void Main::editFind(QString s)
2553 BranchObj *bo=currentMapEditor()->findText(s, cs);
2556 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2559 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2560 tr("No matches found for \"%1\"").arg(s));
2564 void Main::editFindChanged()
2565 { // Notify editor, to abort the current find process
2566 currentMapEditor()->findReset();
2569 void Main::openTabs(QStringList urls)
2571 if (!urls.isEmpty())
2575 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2577 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2579 QString u=urls.takeFirst();
2580 procBrowser = new QProcess( this );
2582 procBrowser->start(browser,args);
2583 if ( !procBrowser->waitForStarted())
2585 // try to set path to browser
2586 QMessageBox::warning(0,
2588 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2589 tr("Please use Settings->")+tr("Set application to open an URL"));
2594 if (browser.contains("konqueror"))
2596 for (int i=0; i<urls.size(); i++)
2599 // Try to open new tab in existing konqueror started previously by vym
2600 p=new QProcess (this);
2602 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2603 "konqueror-mainwindow#1"<<
2606 p->start ("dcop",args);
2607 if ( !p->waitForStarted() ) success=false;
2610 QMessageBox::warning(0,
2612 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2614 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2616 for (int i=0; i<urls.size(); i++)
2618 // Try to open new tab in firefox
2619 p=new QProcess (this);
2620 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2621 p->start (browser,args);
2622 if ( !p->waitForStarted() ) success=false;
2625 QMessageBox::warning(0,
2627 tr("Couldn't start %1 to open a new tab").arg(browser));
2630 QMessageBox::warning(0,
2632 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2636 void Main::editOpenURL()
2639 if (currentMapEditor())
2641 QString url=currentMapEditor()->getURL();
2643 if (url=="") return;
2644 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2645 procBrowser = new QProcess( this );
2647 procBrowser->start(browser,args);
2648 if ( !procBrowser->waitForStarted())
2650 // try to set path to browser
2651 QMessageBox::warning(0,
2653 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2654 tr("Please use Settings->")+tr("Set application to open an URL"));
2659 void Main::editOpenURLTab()
2661 if (currentMapEditor())
2664 urls.append(currentMapEditor()->getURL());
2668 void Main::editOpenMultipleURLTabs()
2670 if (currentMapEditor())
2673 urls=currentMapEditor()->getURLs();
2679 void Main::editURL()
2681 if (currentMapEditor())
2682 currentMapEditor()->editURL();
2685 void Main::editLocalURL()
2687 if (currentMapEditor())
2688 currentMapEditor()->editLocalURL();
2691 void Main::editHeading2URL()
2693 if (currentMapEditor())
2694 currentMapEditor()->editHeading2URL();
2697 void Main::editBugzilla2URL()
2699 if (currentMapEditor())
2700 currentMapEditor()->editBugzilla2URL();
2703 void Main::editFATE2URL()
2705 if (currentMapEditor())
2706 currentMapEditor()->editFATE2URL();
2709 void Main::editHeadingFinished()
2711 // only called from editHeading(), so there is a currentME
2712 MapEditor *me=currentMapEditor();
2715 me->setStateEditHeading (false);
2716 QPoint p; //Not used here, only to find out pos of branch
2718 QString s=me->getHeading(ok,p);
2720 #if defined(Q_OS_MACX)
2722 if (ok && s!=lineedit->text())
2723 me->setHeading(lineedit->text());
2725 lineedit->releaseKeyboard();
2729 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2730 !prevSelection.isEmpty())
2731 me->select(prevSelection);
2736 void Main::editHeading()
2738 if (currentMapEditor())
2740 MapEditor *me=currentMapEditor();
2741 QString oldSel=me->getSelectString();
2743 if (lineedit->isVisible())
2744 editHeadingFinished();
2749 QString s=me->getHeading(ok,p);
2753 me->setStateEditHeading (true);
2754 #if defined(Q_OS_MACX)
2755 p=me->mapToGlobal (p);
2756 QDialog *d =new QDialog(NULL);
2757 QLineEdit *le=new QLineEdit (d);
2758 d->setWindowFlags (Qt::FramelessWindowHint);
2759 d->setGeometry(p.x(),p.y(),230,25);
2760 le->resize (d->width()-10,d->height());
2763 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2764 d->activateWindow();
2766 me->setHeading (le->text());
2769 editHeadingFinished();
2771 p=me->mapTo (this,p);
2772 lineedit->setGeometry(p.x(),p.y(),230,25);
2773 lineedit->setText(s);
2774 lineedit->setCursorPosition(1);
2775 lineedit->selectAll();
2777 lineedit->grabKeyboard();
2778 lineedit->setFocus();
2782 } // currentMapEditor()
2785 void Main::openVymLinks(const QStringList &vl)
2787 for (int j=0; j<vl.size(); j++)
2789 // compare path with already loaded maps
2793 for (i=0;i<=tabWidget->count() -1;i++)
2795 me=(MapEditor*)tabWidget->page(i);
2796 if (vl.at(j)==me->getFilePath() )
2805 if (!QFile(vl.at(j)).exists() )
2806 QMessageBox::critical( 0, tr( "Critical Error" ),
2807 tr("Couldn't open map %1").arg(vl.at(j)));
2810 fileLoad (vl.at(j), NewMap);
2811 tabWidget->setCurrentPage (tabWidget->count()-1);
2814 // Go to tab containing the map
2815 tabWidget->setCurrentPage (index);
2819 void Main::editOpenVymLink()
2821 if (currentMapEditor())
2824 vl.append(currentMapEditor()->getVymLink());
2829 void Main::editOpenMultipleVymLinks()
2831 QString currentVymLink;
2832 if (currentMapEditor())
2834 QStringList vl=currentMapEditor()->getVymLinks();
2839 void Main::editVymLink()
2841 if (currentMapEditor())
2842 currentMapEditor()->editVymLink();
2845 void Main::editDeleteVymLink()
2847 if (currentMapEditor())
2848 currentMapEditor()->deleteVymLink();
2851 void Main::editToggleHideExport()
2853 if (currentMapEditor())
2854 currentMapEditor()->toggleHideExport();
2857 void Main::editMapInfo()
2859 if (currentMapEditor())
2860 currentMapEditor()->editMapInfo();
2863 void Main::editMoveUp()
2865 if (currentMapEditor())
2866 currentMapEditor()->moveBranchUp();
2869 void Main::editMoveDown()
2871 if (currentMapEditor())
2872 currentMapEditor()->moveBranchDown();
2875 void Main::editToggleScroll()
2877 if (currentMapEditor())
2879 currentMapEditor()->toggleScroll();
2883 void Main::editUnscrollChilds()
2885 if (currentMapEditor())
2886 currentMapEditor()->unscrollChilds();
2889 void Main::editNewBranch()
2891 MapEditor *me=currentMapEditor();
2892 if (!lineedit->isVisible() && me)
2894 BranchObj *bo=(BranchObj*)me->getSelection();
2895 BranchObj *newbo=me->addNewBranch(0);
2897 prevSelection=bo->getSelectString();
2899 me->select (newbo->getSelectString());
2903 if (actionSettingsAutoEditNewBranch->isOn())
2908 if (!prevSelection.isEmpty())
2910 me->select(prevSelection);
2917 void Main::editNewBranchBefore()
2919 MapEditor *me=currentMapEditor();
2920 if (!lineedit->isVisible() && me)
2922 BranchObj *bo=(BranchObj*)me->getSelection();
2923 BranchObj *newbo=me->addNewBranchBefore();
2926 me->select (newbo->getSelectString());
2930 if (actionSettingsAutoEditNewBranch->isOn())
2932 if (!actionSettingsAutoSelectNewBranch->isOn())
2933 prevSelection=bo->getSelectString();
2939 void Main::editNewBranchAbove()
2941 MapEditor *me=currentMapEditor();
2942 if (!lineedit->isVisible() && me)
2944 BranchObj *bo=(BranchObj*)me->getSelection();
2945 BranchObj *newbo=me->addNewBranch (-1);
2948 me->select (newbo->getSelectString());
2952 if (actionSettingsAutoEditNewBranch->isOn())
2954 if (!actionSettingsAutoSelectNewBranch->isOn())
2955 prevSelection=bo->getSelectString();
2961 void Main::editNewBranchBelow()
2963 MapEditor *me=currentMapEditor();
2964 if (!lineedit->isVisible() && me)
2966 BranchObj *bo=(BranchObj*)me->getSelection();
2967 BranchObj *newbo=me->addNewBranch (1);
2970 me->select (newbo->getSelectString());
2974 if (actionSettingsAutoEditNewBranch->isOn())
2976 if (!actionSettingsAutoSelectNewBranch->isOn())
2977 prevSelection=bo->getSelectString();
2983 void Main::editImportAdd()
2985 fileLoad (ImportAdd);
2988 void Main::editImportReplace()
2990 fileLoad (ImportReplace);
2993 void Main::editSaveBranch()
2995 fileSaveAs (PartOfMap);
2998 void Main::editDeleteKeepChilds()
3000 if (currentMapEditor())
3001 currentMapEditor()->deleteKeepChilds();
3004 void Main::editDeleteChilds()
3006 if (currentMapEditor())
3007 currentMapEditor()->deleteChilds();
3010 void Main::editDeleteSelection()
3012 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3013 currentMapEditor()->deleteSelection();
3016 void Main::editUpperBranch()
3018 if (currentMapEditor())
3019 currentMapEditor()->selectUpperBranch();
3022 void Main::editLowerBranch()
3024 if (currentMapEditor())
3025 currentMapEditor()->selectLowerBranch();
3028 void Main::editLeftBranch()
3030 if (currentMapEditor())
3031 currentMapEditor()->selectLeftBranch();
3034 void Main::editRightBranch()
3036 if (currentMapEditor())
3037 currentMapEditor()->selectRightBranch();
3040 void Main::editFirstBranch()
3042 if (currentMapEditor())
3043 currentMapEditor()->selectFirstBranch();
3046 void Main::editLastBranch()
3048 if (currentMapEditor())
3049 currentMapEditor()->selectLastBranch();
3052 void Main::editLoadImage()
3054 if (currentMapEditor())
3055 currentMapEditor()->loadFloatImage();
3058 void Main::editSaveImage()
3060 if (currentMapEditor())
3061 currentMapEditor()->saveFloatImage();
3064 void Main::editFollowXLink(QAction *a)
3067 if (currentMapEditor())
3068 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3071 void Main::editEditXLink(QAction *a)
3073 if (currentMapEditor())
3074 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3077 void Main::formatSelectColor()
3079 if (currentMapEditor())
3081 QColor col = QColorDialog::getColor((currentColor ), this );
3082 if ( !col.isValid() ) return;
3083 colorChanged( col );
3087 void Main::formatPickColor()
3089 if (currentMapEditor())
3090 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3093 void Main::colorChanged(QColor c)
3095 QPixmap pix( 16, 16 );
3097 actionFormatColor->setIconSet( pix );
3101 void Main::formatColorBranch()
3103 if (currentMapEditor())
3104 currentMapEditor()->colorBranch(currentColor);
3107 void Main::formatColorSubtree()
3109 if (currentMapEditor())
3110 currentMapEditor()->colorSubtree (currentColor);
3113 void Main::formatLinkStyleLine()
3115 if (currentMapEditor())
3116 currentMapEditor()->setMapLinkStyle("StyleLine");
3119 void Main::formatLinkStyleParabel()
3121 if (currentMapEditor())
3122 currentMapEditor()->setMapLinkStyle("StyleParabel");
3125 void Main::formatLinkStylePolyLine()
3127 if (currentMapEditor())
3128 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3131 void Main::formatLinkStylePolyParabel()
3133 if (currentMapEditor())
3134 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3137 void Main::formatSelectBackColor()
3139 if (currentMapEditor())
3140 currentMapEditor()->selectMapBackgroundColor();
3143 void Main::formatSelectBackImage()
3145 if (currentMapEditor())
3146 currentMapEditor()->selectMapBackgroundImage();
3149 void Main::formatSelectLinkColor()
3151 if (currentMapEditor())
3152 currentMapEditor()->selectMapLinkColor();
3155 void Main::formatSelectSelectionColor()
3157 if (currentMapEditor())
3158 currentMapEditor()->selectMapSelectionColor();
3161 void Main::formatToggleLinkColorHint()
3163 currentMapEditor()->toggleMapLinkColorHint();
3167 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3169 if (currentMapEditor())
3170 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3173 void Main::viewZoomReset()
3175 if (currentMapEditor())
3179 currentMapEditor()->setMatrix( m );
3183 void Main::viewZoomIn()
3185 if (currentMapEditor())
3187 QMatrix m = currentMapEditor()->matrix();
3188 m.scale( 1.25, 1.25 );
3189 currentMapEditor()->setMatrix( m );
3193 void Main::viewZoomOut()
3195 if (currentMapEditor())
3197 QMatrix m = currentMapEditor()->matrix();
3198 m.scale( 0.8, 0.8 );
3199 currentMapEditor()->setMatrix( m );
3203 void Main::viewCenter()
3205 MapEditor *me=currentMapEditor();
3208 me->ensureSelectionVisible();
3212 void Main::networkStartServer()
3214 MapEditor *me=currentMapEditor();
3215 if (me) me->newServer();
3218 void Main::networkConnect()
3220 MapEditor *me=currentMapEditor();
3221 if (me) me->connectToServer();
3224 bool Main::settingsPDF()
3226 // Default browser is set in constructor
3228 QString text = QInputDialog::getText(
3229 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3230 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3232 settings.setValue ("/mainwindow/readerPDF",text);
3237 bool Main::settingsURL()
3239 // Default browser is set in constructor
3241 QString text = QInputDialog::getText(
3242 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3243 settings.value("/mainwindow/readerURL").toString()
3246 settings.setValue ("/mainwindow/readerURL",text);
3250 void Main::settingsMacroDir()
3252 QDir defdir=vymBaseDir;
3253 defdir.cd("macros");
3254 if (!defdir.exists())
3256 QDir dir=QFileDialog::getExistingDirectory (
3258 tr ("Directory with vym macros:"),
3259 settings.value ("/macros/macroDir",defdir.path()).toString()
3262 settings.setValue ("/macros/macroDir",dir.path());
3265 void Main::settingsUndoLevels()
3268 int i = QInputDialog::getInteger(
3270 tr("QInputDialog::getInteger()"),
3271 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3274 settings.setValue ("/mapeditor/stepsTotal",i);
3275 QMessageBox::information( this, tr( "VYM -Information:" ),
3276 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3280 void Main::settingsAutosaveToggle()
3282 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3285 void Main::settingsAutosaveTime()
3288 int i = QInputDialog::getInteger(
3290 tr("QInputDialog::getInteger()"),
3291 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3294 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3298 void Main::settingsToggleDelKey()
3300 if (actionSettingsUseDelKey->isOn())
3302 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3305 actionEditDelete->setAccel (QKeySequence (""));
3309 void Main::windowToggleNoteEditor()
3311 if (textEditor->isVisible() )
3312 windowHideNoteEditor();
3314 windowShowNoteEditor();
3317 void Main::windowToggleHistory()
3319 if (historyWindow->isVisible())
3320 historyWindow->hide();
3322 historyWindow->show();
3326 void Main::windowToggleProperty()
3328 if (branchPropertyWindow->isVisible())
3329 branchPropertyWindow->hide();
3331 branchPropertyWindow->show();
3333 if(currentMapEditor())
3335 LinkableMapObj *sel=currentMapEditor()->getSelection();
3336 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3337 typeid(*sel) == typeid(MapCenterObj)))
3339 branchPropertyWindow->setMapEditor(currentMapEditor());
3340 branchPropertyWindow->setBranch((BranchObj*)sel);
3345 branchPropertyWindow->setBranch(NULL);
3348 void Main::windowToggleAntiAlias()
3350 bool b=actionViewToggleAntiAlias->isOn();
3352 for (int i=0;i<tabWidget->count();i++)
3355 me=(MapEditor*)tabWidget->page(i);
3356 me->setAntiAlias(b);
3361 void Main::windowToggleSmoothPixmap()
3363 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3365 for (int i=0;i<tabWidget->count();i++)
3368 me=(MapEditor*)tabWidget->page(i);
3369 me->setSmoothPixmap(b);
3373 void Main::updateHistory(SimpleSettings &undoSet)
3375 historyWindow->update (undoSet);
3378 void Main::updateNoteFlag()
3380 if (currentMapEditor())
3381 currentMapEditor()->updateNoteFlag();
3384 void Main::updateSatellites(MapEditor *me)
3386 branchPropertyWindow->setMapEditor (me);
3389 void Main::updateActions()
3391 MapEditor *me=currentMapEditor();
3394 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3396 // updateActions is also called when NoteEditor is closed
3397 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3398 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3399 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3401 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3402 actionFormatLinkColorHint->setOn(true);
3404 actionFormatLinkColorHint->setOn(false);
3406 switch (me->getMapLinkStyle())
3408 case LinkableMapObj::Line:
3409 actionFormatLinkStyleLine->setOn(true);
3411 case LinkableMapObj::Parabel:
3412 actionFormatLinkStyleParabel->setOn(true);
3414 case LinkableMapObj::PolyLine:
3415 actionFormatLinkStylePolyLine->setOn(true);
3417 case LinkableMapObj::PolyParabel:
3418 actionFormatLinkStylePolyParabel->setOn(true);
3425 QPixmap pix( 16, 16 );
3426 pix.fill( me->getMapBackgroundColor() );
3427 actionFormatBackColor->setIconSet( pix );
3428 pix.fill( me->getSelectionColor() );
3429 actionFormatSelectionColor->setIconSet( pix );
3430 pix.fill( me->getMapDefLinkColor() );
3431 actionFormatLinkColor->setIconSet( pix );
3434 actionFileSave->setEnabled( me->hasChanged() );
3435 if (me->isUndoAvailable())
3436 actionEditUndo->setEnabled( true);
3438 actionEditUndo->setEnabled( false);
3440 if (me->isRedoAvailable())
3441 actionEditRedo->setEnabled( true);
3443 actionEditRedo->setEnabled( false);
3445 LinkableMapObj *selection=me->getSelection();
3448 if ( (typeid(*selection) == typeid(BranchObj)) ||
3449 (typeid(*selection) == typeid(MapCenterObj)) )
3451 BranchObj *bo=(BranchObj*)selection;
3452 // Take care of links
3453 if (bo->countXLinks()==0)
3455 branchXLinksContextMenuEdit->clear();
3456 branchXLinksContextMenuFollow->clear();
3461 branchXLinksContextMenuEdit->clear();
3462 branchXLinksContextMenuFollow->clear();
3463 for (int i=0; i<=bo->countXLinks();i++)
3465 bot=bo->XLinkTargetAt(i);
3468 s=bot->getHeading();
3471 branchXLinksContextMenuFollow->addAction (s);
3472 branchXLinksContextMenuEdit->addAction (s);
3477 standardFlagsDefault->setEnabled (true);
3479 actionEditToggleScroll->setEnabled (true);
3480 if ( bo->isScrolled() )
3481 actionEditToggleScroll->setOn(true);
3483 actionEditToggleScroll->setOn(false);
3485 if ( bo->getURL().isEmpty() )
3487 actionEditOpenURL->setEnabled (false);
3488 actionEditOpenURLTab->setEnabled (false);
3492 actionEditOpenURL->setEnabled (true);
3493 actionEditOpenURLTab->setEnabled (true);
3495 if ( bo->getVymLink().isEmpty() )
3497 actionEditOpenVymLink->setEnabled (false);
3498 actionEditDeleteVymLink->setEnabled (false);
3501 actionEditOpenVymLink->setEnabled (true);
3502 actionEditDeleteVymLink->setEnabled (true);
3505 if (bo->canMoveBranchUp())
3506 actionEditMoveUp->setEnabled (true);
3508 actionEditMoveUp->setEnabled (false);
3509 if (bo->canMoveBranchDown())
3510 actionEditMoveDown->setEnabled (true);
3512 actionEditMoveDown->setEnabled (false);
3515 actionEditToggleHideExport->setEnabled (true);
3516 actionEditToggleHideExport->setOn (bo->hideInExport() );
3518 actionEditCopy->setEnabled (true);
3519 actionEditCut->setEnabled (true);
3520 if (!clipboardEmpty)
3521 actionEditPaste->setEnabled (true);
3523 actionEditPaste->setEnabled (false);
3524 for (int i=0; i<actionListBranches.size(); ++i)
3525 actionListBranches.at(i)->setEnabled(true);
3526 actionEditDelete->setEnabled (true);
3527 actionFormatHideLinkUnselected->setOn
3528 (selection->getHideLinkUnselected());
3530 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3532 FloatObj *fo=(FloatImageObj*)selection;
3534 actionEditOpenURL->setEnabled (false);
3535 actionEditOpenVymLink->setEnabled (false);
3536 actionEditDeleteVymLink->setEnabled (false);
3537 actionEditToggleHideExport->setEnabled (true);
3538 actionEditToggleHideExport->setOn (fo->hideInExport() );
3541 actionEditCopy->setEnabled (true);
3542 actionEditCut->setEnabled (true);
3543 actionEditPaste->setEnabled (false);
3544 for (int i=0; i<actionListBranches.size(); ++i)
3545 actionListBranches.at(i)->setEnabled(false);
3546 actionEditDelete->setEnabled (true);
3547 actionFormatHideLinkUnselected->setOn
3548 ( selection->getHideLinkUnselected());
3549 actionEditMoveUp->setEnabled (false);
3550 actionEditMoveDown->setEnabled (false);
3555 actionEditCopy->setEnabled (false);
3556 actionEditCut->setEnabled (false);
3557 actionEditPaste->setEnabled (false);
3558 for (int i=0; i<actionListBranches.size(); ++i)
3559 actionListBranches.at(i)->setEnabled(false);
3561 actionEditToggleScroll->setEnabled (false);
3562 actionEditOpenURL->setEnabled (false);
3563 actionEditOpenVymLink->setEnabled (false);
3564 actionEditDeleteVymLink->setEnabled (false);
3565 actionEditHeading2URL->setEnabled (false);
3566 actionEditDelete->setEnabled (false);
3567 actionEditMoveUp->setEnabled (false);
3568 actionEditMoveDown->setEnabled (false);
3569 actionEditToggleHideExport->setEnabled (false);
3573 Main::ModMode Main::getModMode()
3575 if (actionModModeColor->isOn()) return ModModeColor;
3576 if (actionModModeCopy->isOn()) return ModModeCopy;
3577 if (actionModModeXLink->isOn()) return ModModeXLink;
3581 bool Main::autoEditNewBranch()
3583 return actionSettingsAutoEditNewBranch->isOn();
3586 bool Main::autoSelectNewBranch()
3588 return actionSettingsAutoSelectNewBranch->isOn();
3591 bool Main::useFlagGroups()
3593 return actionSettingsUseFlagGroups->isOn();
3596 void Main::windowShowNoteEditor()
3598 textEditor->setShowWithMain(true);
3600 actionViewToggleNoteEditor->setOn (true);
3603 void Main::windowHideNoteEditor()
3605 textEditor->setShowWithMain(false);
3607 actionViewToggleNoteEditor->setOn (false);
3610 void Main::setScript (const QString &script)
3612 scriptEditor->setScript (script);
3615 void Main::runScript (const QString &script)
3617 if (currentMapEditor())
3618 currentMapEditor()->runScript (script);
3621 void Main::runScriptEverywhere (const QString &script)
3624 for (int i=0;i<=tabWidget->count() -1;i++)
3626 me=(MapEditor*)tabWidget->page(i);
3627 if (me) me->runScript (script);
3631 void Main::windowNextEditor()
3633 if (tabWidget->currentPageIndex() < tabWidget->count())
3634 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3637 void Main::windowPreviousEditor()
3639 if (tabWidget->currentPageIndex() >0)
3640 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3643 void Main::standardFlagChanged()
3645 if (currentMapEditor())
3646 currentMapEditor()->toggleStandardFlag(sender()->name());
3649 void Main::testFunction1()
3651 if (!currentMapEditor()) return;
3652 currentMapEditor()->newServer();
3655 void Main::testFunction2()
3657 if (!currentMapEditor()) return;
3658 currentMapEditor()->connectToServer();
3661 void Main::testCommand()
3663 if (!currentMapEditor()) return;
3664 scriptEditor->show();
3667 QString com = QInputDialog::getText(
3668 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3669 if (ok) currentMapEditor()->parseAtom(com);
3673 void Main::helpDoc()
3675 QString locale = QLocale::system().name();
3677 if (locale.left(2)=="es")
3678 docname="vym_es.pdf";
3682 QStringList searchList;
3684 #if defined(Q_OS_MACX)
3685 searchList << "./vym.app/Contents/Resources/doc";
3687 // default path in SUSE LINUX
3688 searchList <<"/usr/share/doc/packages/vym/doc";
3691 searchList << "doc"; // relative path for easy testing in tarball
3692 searchList << "doc/tex"; // Easy testing working on vym.tex
3693 searchList << "/usr/share/doc/vym"; // Debian
3694 searchList << "/usr/share/doc/packages";// Knoppix
3698 for (int i=0; i<searchList.count(); ++i)
3700 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3701 if (docfile.exists() )
3710 QMessageBox::critical(0,
3711 tr("Critcal error"),
3712 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3717 Process *pdfProc = new Process();
3718 args <<docfile.fileName();
3720 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3721 if ( !pdfProc->waitForStarted() )
3724 QMessageBox::warning(0,
3726 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3727 tr("Please use Settings->")+tr("Set application to open PDF files"));
3734 void Main::helpDemo()
3736 QStringList filters;
3737 filters <<"VYM example map (*.vym)";
3738 QFileDialog *fd=new QFileDialog( this);
3739 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3740 fd->setFileMode (QFileDialog::ExistingFiles);
3741 fd->setFilters (filters);
3742 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3746 if ( fd->exec() == QDialog::Accepted )
3748 lastFileDir=fd->directory().path();
3749 QStringList flist = fd->selectedFiles();
3750 QStringList::Iterator it = flist.begin();
3751 while( it != flist.end() )
3754 fileLoad(*it, NewMap);
3762 void Main::helpAbout()
3765 ad.setName ("aboutwindow");
3766 ad.setMinimumSize(500,500);
3767 ad.resize (QSize (500,500));
3771 void Main::helpAboutQT()
3773 QMessageBox::aboutQt( this, "Qt Application Example" );
3776 void Main::callMacro ()
3778 QAction *action = qobject_cast<QAction *>(sender());
3782 i=action->data().toInt();
3783 QString mDir (settings.value ("macros/macroDir").toString() );
3785 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3787 if ( !f.open( QIODevice::ReadOnly ) )
3789 QMessageBox::warning(0,
3791 tr("Couldn't find a macro at %1.\n").arg(fn)+
3792 tr("Please use Settings->")+tr("Set directory for vym macros"));
3796 QTextStream ts( &f );
3797 QString m= ts.read();
3801 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3802 currentMapEditor()->runScript (m);