1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "branchpropwindow.h"
9 #include "exportoofiledialog.h"
11 #include "exportxhtmldialog.h"
13 #include "flagrowobj.h"
14 #include "historywindow.h"
16 #include "mapeditor.h"
21 #include "texteditor.h"
22 #include "warningdialog.h"
24 extern TextEditor *textEditor;
25 extern Main *mainWindow;
26 extern QString tmpVymDir;
27 extern QString clipboardDir;
28 extern QString clipboardFile;
29 extern bool clipboardEmpty;
30 extern int statusbarTime;
31 extern FlagRowObj* standardFlagsDefault;
32 extern FlagRowObj* systemFlagsDefault;
33 extern QString vymName;
34 extern QString vymVersion;
35 extern QString vymBuildDate;
38 QMenu* branchContextMenu;
39 QMenu* branchAddContextMenu;
40 QMenu* branchRemoveContextMenu;
41 QMenu* branchLinksContextMenu;
42 QMenu* branchXLinksContextMenuEdit;
43 QMenu* branchXLinksContextMenuFollow;
44 QMenu* floatimageContextMenu;
45 QMenu* canvasContextMenu;
46 QMenu* fileLastMapsMenu;
47 QMenu* fileImportMenu;
48 QMenu* fileExportMenu;
51 extern Settings settings;
52 extern Options options;
53 extern ImageIO imageIO;
55 extern QDir vymBaseDir;
56 extern QDir lastImageDir;
57 extern QDir lastFileDir;
58 extern QString iconPath;
59 extern QString flagsPath;
61 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
62 QMainWindow(parent,name,f)
66 setCaption ("VYM - View Your Mind");
68 // Load window settings
69 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
70 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
73 // Sometimes we may need to remember old selections
77 currentColor=Qt::black;
79 // Create unique temporary directory
81 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
84 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
87 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
89 // Create direcctory for clipboard
90 clipboardDir=tmpVymDir+"/clipboard";
91 clipboardFile="map.xml";
93 d.mkdir (clipboardDir,true);
94 makeSubDirs (clipboardDir);
99 // Satellite windows //////////////////////////////////////////
102 historyWindow=new HistoryWindow();
103 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
106 branchPropertyWindow = new BranchPropertyWindow();
107 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
109 // Connect TextEditor, so that we can update flags if text changes
110 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
111 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
113 // Connect HistoryWindow, so that we can update flags
114 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
117 // Initialize script editor
118 scriptEditor = new SimpleScriptEditor();
119 scriptEditor->move (50,50);
121 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
122 this, SLOT( runScript( QString ) ) );
125 // Initialize Find window
126 findWindow=new FindWindow(NULL);
127 findWindow->move (x(),y()+70);
128 connect (findWindow, SIGNAL( findButton(QString) ),
129 this, SLOT(editFind(QString) ) );
130 connect (findWindow, SIGNAL( somethingChanged() ),
131 this, SLOT(editFindChanged() ) );
133 // Initialize some settings, which are platform dependant
136 // application to open URLs
137 p="/mainwindow/readerURL";
138 #if defined(Q_OS_LINUX)
139 s=settings.value (p,"konqueror").toString();
141 #if defined(Q_OS_MACX)
142 s=settings.value (p,"/usr/bin/open").toString();
144 s=settings.value (p,"mozilla");
147 settings.setValue( p,s);
149 // application to open PDFs
150 p="/mainwindow/readerPDF";
151 #if defined(Q_OS_LINUX)
152 s=settings.value (p,"acroread").toString();
154 #if defined(Q_OS_MACX)
155 s=settings.value (p,"/usr/bin/open").toString();
157 s=settings.value (p,"acroread").toString();
160 settings.setValue( p,s);
163 // Create tab widget which holds the maps
164 tabWidget= new QTabWidget (this);
165 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
166 this, SLOT( editorChanged( QWidget * ) ) );
168 lineedit=new QLineEdit (this);
171 setCentralWidget(tabWidget);
175 setupFormatActions();
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/autoSelectHeading",actionSettingsAutoSelectHeading->isOn() );
206 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
207 settings.setValue( "/mapeditor/editmode/autoEdit",actionSettingsAutoEdit->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( tr( "Use heading for URL","Edit menu" ), this);
650 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
651 a->setEnabled (false);
652 actionListBranches.append(a);
653 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
654 actionEditHeading2URL=a;
656 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
657 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
658 a->setEnabled (false);
659 actionListBranches.append(a);
660 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
661 actionEditBugzilla2URL=a;
663 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
664 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
665 a->setEnabled (false);
666 actionListBranches.append(a);
667 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
668 actionEditFATE2URL=a;
670 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
671 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
673 a->setEnabled (false);
674 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
675 actionEditOpenVymLink=a;
677 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
678 a->setStatusTip ( tr( "Open all vym links in subtree" ));
679 a->setEnabled (false);
680 actionListBranches.append(a);
681 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
682 actionEditOpenMultipleVymLinks=a;
685 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
686 a->setEnabled (false);
687 a->setStatusTip ( tr( "Edit link to another vym map" ));
688 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
689 actionListBranches.append(a);
692 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
693 a->setStatusTip ( tr( "Delete link to another vym map" ));
694 a->setEnabled (false);
695 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
696 actionEditDeleteVymLink=a;
698 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
699 a->setStatusTip ( tr( "Hide object in exports" ) );
700 a->setShortcut (Qt::Key_H );
701 a->setToggleAction(true);
703 a->setEnabled (false);
704 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
705 actionEditToggleHideExport=a;
707 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
708 a->setStatusTip ( tr( "Edit Map Info" ));
709 a->setEnabled (true);
710 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
713 // Import at selection (adding to selection)
714 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
715 a->setStatusTip (tr( "Add map at selection" ));
716 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
717 a->setEnabled (false);
718 actionListBranches.append(a);
719 actionEditImportAdd=a;
721 // Import at selection (replacing selection)
722 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
723 a->setStatusTip (tr( "Replace selection with map" ));
724 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
725 a->setEnabled (false);
726 actionListBranches.append(a);
727 actionEditImportReplace=a;
730 a = new QAction( tr( "Save selection","Edit menu" ), this);
731 a->setStatusTip (tr( "Save selection" ));
732 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
733 a->setEnabled (false);
734 actionListBranches.append(a);
735 actionEditSaveBranch=a;
737 // Only remove branch, not its childs
738 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
739 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
740 a->setShortcut (Qt::ALT + Qt::Key_Delete );
741 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
742 a->setEnabled (false);
744 actionListBranches.append(a);
745 actionEditDeleteKeepChilds=a;
747 // Only remove childs of a branch
748 a = new QAction( tr( "Remove childs","Edit menu" ), this);
749 a->setStatusTip (tr( "Remove childs of branch" ));
750 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
751 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
752 a->setEnabled (false);
753 actionListBranches.append(a);
754 actionEditDeleteChilds=a;
756 // Shortcuts for navigating with cursor:
757 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
758 a->setStatusTip ( tr( "Select upper branch" ));
759 a->setShortcut (Qt::Key_Up );
760 a->setShortcutContext (Qt::WindowShortcut);
762 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
763 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
764 a->setStatusTip (tr( "Select lower branch" ));
765 a->setShortcut ( Qt::Key_Down );
766 a->setShortcutContext (Qt::WindowShortcut);
768 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
769 a = new QAction(tr( "Select left branch","Edit menu" ), this);
770 a->setStatusTip ( tr( "Select left branch" ));
771 a->setShortcut (Qt::Key_Left );
772 a->setShortcutContext (Qt::WindowShortcut);
774 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
775 a = new QAction( tr( "Select child branch","Edit menu" ), this);
776 a->setStatusTip (tr( "Select right branch" ));
777 a->setShortcut (Qt::Key_Right);
778 a->setShortcutContext (Qt::WindowShortcut);
780 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
781 a = new QAction( tr( "Select first branch","Edit menu" ), this);
782 a->setStatusTip (tr( "Select first branch" ));
783 a->setShortcut (Qt::Key_Home );
784 a->setShortcutContext (Qt::WindowShortcut);
786 a->setEnabled (false);
787 editMenu->addAction (a);
788 actionListBranches.append(a);
789 actionEditSelectFirst=a;
790 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
791 a = new QAction( tr( "Select last branch","Edit menu" ),this);
792 a->setStatusTip (tr( "Select last branch" ));
793 a->setShortcut ( Qt::Key_End );
794 a->setShortcutContext (Qt::WindowShortcut);
796 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
797 a->setEnabled (false);
798 editMenu->addAction (a);
799 actionListBranches.append(a);
800 actionEditSelectLast=a;
802 a = new QAction( tr( "Add Image...","Edit menu" ), this);
803 a->setStatusTip (tr( "Add Image" ));
804 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
805 actionEditLoadImage=a;
807 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
808 a->setStatusTip (tr( "Set properties for selection" ));
809 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
810 a->setShortcutContext (Qt::WindowShortcut);
811 a->setToggleAction (true);
813 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
814 actionViewTogglePropertyWindow=a;
818 void Main::setupFormatActions()
820 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
822 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
823 tb->setObjectName ("formatTB");
826 pix.fill (Qt::black);
827 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
828 a->setStatusTip ( tr( "Set Color" ));
829 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
831 formatMenu->addAction (a);
833 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
834 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
835 a->setShortcut (Qt::CTRL + Qt::Key_K );
836 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
837 a->setEnabled (false);
839 formatMenu->addAction (a);
840 actionListBranches.append(a);
841 actionFormatPickColor=a;
843 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
844 a->setStatusTip ( tr( "Color branch" ) );
845 a->setShortcut (Qt::CTRL + Qt::Key_B);
846 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
847 a->setEnabled (false);
849 formatMenu->addAction (a);
850 actionListBranches.append(a);
851 actionFormatColorSubtree=a;
853 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
854 a->setStatusTip ( tr( "Color Subtree" ));
855 a->setShortcut (Qt::CTRL + Qt::Key_T);
856 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
857 a->setEnabled (false);
858 formatMenu->addAction (a);
860 actionListBranches.append(a);
861 actionFormatColorSubtree=a;
863 formatMenu->addSeparator();
864 actionGroupFormatLinkStyles=new QActionGroup ( this);
865 actionGroupFormatLinkStyles->setExclusive (true);
866 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
867 a->setStatusTip (tr( "Line" ));
868 a->setToggleAction(true);
869 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
870 formatMenu->addAction (a);
871 actionFormatLinkStyleLine=a;
872 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
873 a->setStatusTip (tr( "Line" ));
874 a->setToggleAction(true);
875 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
876 formatMenu->addAction (a);
877 actionFormatLinkStyleParabel=a;
878 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
879 a->setStatusTip (tr( "PolyLine" ));
880 a->setToggleAction(true);
881 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
882 formatMenu->addAction (a);
883 actionFormatLinkStylePolyLine=a;
884 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
885 a->setStatusTip (tr( "PolyParabel" ) );
886 a->setToggleAction(true);
887 a->setChecked (true);
888 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
889 formatMenu->addAction (a);
890 actionFormatLinkStylePolyParabel=a;
892 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
893 a->setStatusTip (tr( "Hide link" ));
894 a->setToggleAction(true);
895 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
896 actionFormatHideLinkUnselected=a;
898 formatMenu->addSeparator();
899 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
900 a->setStatusTip (tr( "Use same color for links and headings" ));
901 a->setToggleAction(true);
902 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
903 formatMenu->addAction (a);
904 actionFormatLinkColorHint=a;
906 pix.fill (Qt::white);
907 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
908 a->setStatusTip (tr( "Set Link Color" ));
909 formatMenu->addAction (a);
910 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
911 actionFormatLinkColor=a;
913 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
914 a->setStatusTip (tr( "Set Selection Color" ));
915 formatMenu->addAction (a);
916 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
917 actionFormatSelectionColor=a;
919 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
920 a->setStatusTip (tr( "Set Background Color" ));
921 formatMenu->addAction (a);
922 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
923 actionFormatBackColor=a;
925 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
926 a->setStatusTip (tr( "Set Background image" ));
927 formatMenu->addAction (a);
928 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
929 actionFormatBackImage=a;
933 void Main::setupViewActions()
935 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
936 tb->setLabel( "View Actions" );
937 tb->setObjectName ("viewTB");
938 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
941 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
942 a->setStatusTip ( tr( "Zoom reset" ) );
943 a->setShortcut (Qt::CTRL + Qt::Key_0 );
945 viewMenu->addAction (a);
946 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
948 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
949 a->setStatusTip (tr( "Zoom in" ));
950 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
952 viewMenu->addAction (a);
953 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
955 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
956 a->setStatusTip (tr( "Zoom out" ));
957 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
959 viewMenu->addAction (a);
960 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
962 viewMenu->addSeparator();
964 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
965 a->setStatusTip ( tr( "Show Note Editor" ));
966 a->setShortcut ( Qt::CTRL + Qt::Key_E );
967 a->setToggleAction(true);
969 viewMenu->addAction (a);
970 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
971 actionViewToggleNoteEditor=a;
973 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
974 a->setStatusTip ( tr( "Show History Window" ));
975 a->setShortcut ( Qt::CTRL + Qt::Key_H );
976 a->setToggleAction(true);
978 viewMenu->addAction (a);
979 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
980 actionViewToggleHistoryWindow=a;
982 viewMenu->addAction (actionViewTogglePropertyWindow);
984 viewMenu->addSeparator();
986 a = new QAction(tr( "Antialiasing","View action" ),this );
987 a->setStatusTip ( tr( "Antialiasing" ));
988 a->setToggleAction(true);
989 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
990 viewMenu->addAction (a);
991 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
992 actionViewToggleAntiAlias=a;
994 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
995 a->setStatusTip (a->text());
996 a->setToggleAction(true);
997 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
998 viewMenu->addAction (a);
999 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1000 actionViewToggleSmoothPixmapTransform=a;
1002 a = new QAction(tr( "Next Map","View action" ), this);
1003 a->setStatusTip (a->text());
1004 a->setShortcut (Qt::ALT + Qt::Key_N );
1005 viewMenu->addAction (a);
1006 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1008 a = new QAction (tr( "Previous Map","View action" ), this );
1009 a->setStatusTip (a->text());
1010 a->setShortcut (Qt::ALT + Qt::Key_P );
1011 viewMenu->addAction (a);
1012 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1016 void Main::setupModeActions()
1018 //QPopupMenu *menu = new QPopupMenu( this );
1019 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1021 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1022 tb->setObjectName ("modesTB");
1024 actionGroupModModes=new QActionGroup ( this);
1025 actionGroupModModes->setExclusive (true);
1026 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1027 a->setShortcut (Qt::Key_J);
1028 a->setStatusTip ( tr( "Use modifier to color branches" ));
1029 a->setToggleAction(true);
1032 actionModModeColor=a;
1034 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1035 a->setShortcut( Qt::Key_K);
1036 a->setStatusTip( tr( "Use modifier to copy" ));
1037 a->setToggleAction(true);
1039 actionModModeCopy=a;
1041 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1042 a->setShortcut (Qt::Key_L);
1043 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1044 a->setToggleAction(true);
1046 actionModModeXLink=a;
1050 void Main::setupFlagActions()
1052 // Create System Flags
1053 systemFlagsDefault = new FlagRowObj ();
1054 systemFlagsDefault->setVisibility (false);
1055 systemFlagsDefault->setName ("systemFlagsDef");
1057 FlagObj *fo = new FlagObj ();
1058 fo->load(QPixmap(flagsPath+"flag-note.png"));
1059 fo->setName("note");
1060 fo->setToolTip(tr("Note","Systemflag"));
1061 systemFlagsDefault->addFlag (fo); // makes deep copy
1063 fo->load(QPixmap(flagsPath+"flag-url.png"));
1065 fo->setToolTip(tr("WWW Document (external)","Systemflag"));
1066 systemFlagsDefault->addFlag (fo);
1068 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1069 fo->setName("vymLink");
1070 fo->setToolTip(tr("Link to another vym map","Systemflag"));
1071 systemFlagsDefault->addFlag (fo);
1073 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1074 fo->setName("scrolledright");
1075 fo->setToolTip(tr("subtree is scrolled","Systemflag"));
1076 systemFlagsDefault->addFlag (fo);
1078 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1079 fo->setName("tmpUnscrolledright");
1080 fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
1081 systemFlagsDefault->addFlag (fo);
1083 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1084 fo->setName("hideInExport");
1085 fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
1086 systemFlagsDefault->addFlag (fo);
1088 // Create Standard Flags
1089 QToolBar *tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1090 tb->setObjectName ("standardFlagTB");
1092 standardFlagsDefault = new FlagRowObj ();
1093 standardFlagsDefault->setVisibility (false);
1094 standardFlagsDefault->setName ("standardFlagsDef");
1095 standardFlagsDefault->setToolBar (tb);
1097 fo->load(flagsPath+"flag-exclamationmark.png");
1098 fo->setName ("exclamationmark");
1099 fo->setGroup("standard-mark");
1100 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1103 a->setCheckable(true);
1104 a->setObjectName(fo->getName());
1105 a->setToolTip(tr("Take care!","Standardflag"));
1106 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1107 standardFlagsDefault->addFlag (fo); // makes deep copy
1109 fo->load(flagsPath+"flag-questionmark.png");
1110 fo->setName("questionmark");
1111 fo->setGroup("standard-mark");
1112 a=new QAction (fo->getPixmap(),fo->getName(),this);
1115 a->setCheckable(true);
1116 a->setObjectName(fo->getName());
1117 a->setToolTip(tr("Really?","Standardflag"));
1118 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1119 standardFlagsDefault->addFlag (fo);
1121 fo->load(flagsPath+"flag-hook-green.png");
1122 fo->setName("hook-green");
1123 fo->setGroup("standard-hook");
1124 a=new QAction (fo->getPixmap(),fo->getName(),this);
1127 a->setCheckable(true);
1128 a->setObjectName(fo->getName());
1129 a->setToolTip(tr("ok!","Standardflag"));
1130 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1131 standardFlagsDefault->addFlag (fo);
1133 fo->load(flagsPath+"flag-cross-red.png");
1134 fo->setName("cross-red");
1135 fo->setGroup("standard-hook");
1136 a=new QAction (fo->getPixmap(),fo->getName(),this);
1139 a->setCheckable(true);
1140 a->setObjectName(fo->getName());
1141 a->setToolTip(tr("Not ok!","Standardflag"));
1142 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1143 standardFlagsDefault->addFlag (fo);
1145 fo->load(flagsPath+"flag-stopsign.png");
1146 fo->setName("stopsign");
1147 a=new QAction (fo->getPixmap(),fo->getName(),this);
1150 a->setCheckable(true);
1151 a->setObjectName(fo->getName());
1152 a->setToolTip(tr("This won't work!","Standardflag"));
1153 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1154 standardFlagsDefault->addFlag (fo);
1156 fo->load(flagsPath+"flag-smiley-good.png");
1157 fo->setName("smiley-good");
1158 fo->setGroup("standard-smiley");
1159 a=new QAction (fo->getPixmap(),fo->getName(),this);
1162 a->setCheckable(true);
1163 a->setObjectName(fo->getName());
1164 a->setToolTip(tr("Good","Standardflag"));
1165 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1166 standardFlagsDefault->addFlag (fo);
1168 fo->load(flagsPath+"flag-smiley-sad.png");
1169 fo->setName("smiley-sad");
1170 fo->setGroup("standard-smiley");
1171 a=new QAction (fo->getPixmap(),fo->getName(),this);
1174 a->setCheckable(true);
1175 a->setObjectName(fo->getName());
1176 a->setToolTip(tr("Bad","Standardflag"));
1177 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1178 standardFlagsDefault->addFlag (fo);
1180 fo->load(flagsPath+"flag-smiley-omg.png");
1181 // Original omg.png (in KDE emoticons)
1182 fo->setName("smiley-omg");
1183 fo->setGroup("standard-smiley");
1184 a=new QAction (fo->getPixmap(),fo->getName(),this);
1187 a->setCheckable(true);
1188 a->setObjectName(fo->getName());
1189 a->setToolTip(tr("Oh no!","Standardflag"));
1190 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1191 standardFlagsDefault->addFlag (fo);
1193 fo->load(flagsPath+"flag-kalarm.png");
1194 fo->setName("clock");
1195 a=new QAction (fo->getPixmap(),fo->getName(),this);
1198 a->setCheckable(true);
1199 a->setObjectName(fo->getName());
1200 a->setToolTip(tr("Time critical","Standardflag"));
1201 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1202 standardFlagsDefault->addFlag (fo);
1204 fo->load(flagsPath+"flag-phone.png");
1205 fo->setName("phone");
1206 a=new QAction (fo->getPixmap(),fo->getName(),this);
1209 a->setCheckable(true);
1210 a->setObjectName(fo->getName());
1211 a->setToolTip(tr("Call...","Standardflag"));
1212 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1213 standardFlagsDefault->addFlag (fo);
1215 fo->load(flagsPath+"flag-lamp.png");
1216 fo->setName("lamp");
1217 a=new QAction (fo->getPixmap(),fo->getName(),this);
1220 a->setCheckable(true);
1221 a->setObjectName(fo->getName());
1222 a->setToolTip(tr("Idea!","Standardflag"));
1223 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1224 standardFlagsDefault->addFlag (fo);
1226 fo->load(flagsPath+"flag-arrow-up.png");
1227 fo->setName("arrow-up");
1228 fo->setGroup("standard-arrow");
1229 a=new QAction (fo->getPixmap(),fo->getName(),this);
1232 a->setCheckable(true);
1233 a->setObjectName(fo->getName());
1234 a->setToolTip(tr("Important","Standardflag"));
1235 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1236 standardFlagsDefault->addFlag (fo);
1238 fo->load(flagsPath+"flag-arrow-down.png");
1239 fo->setName("arrow-down");
1240 fo->setGroup("standard-arrow");
1241 a=new QAction (fo->getPixmap(),fo->getName(),this);
1244 a->setCheckable(true);
1245 a->setObjectName(fo->getName());
1246 a->setToolTip(tr("Unimportant","Standardflag"));
1247 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1248 standardFlagsDefault->addFlag (fo);
1250 fo->load(flagsPath+"flag-arrow-2up.png");
1251 fo->setName("2arrow-up");
1252 fo->setGroup("standard-arrow");
1253 a=new QAction (fo->getPixmap(),fo->getName(),this);
1256 a->setCheckable(true);
1257 a->setObjectName(fo->getName());
1258 a->setToolTip(tr("Very important!","Standardflag"));
1259 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1260 standardFlagsDefault->addFlag (fo);
1262 fo->load(flagsPath+"flag-arrow-2down.png");
1263 fo->setName("2arrow-down");
1264 fo->setGroup("standard-arrow");
1265 a=new QAction (fo->getPixmap(),fo->getName(),this);
1268 a->setCheckable(true);
1269 a->setObjectName(fo->getName());
1270 a->setToolTip(tr("Very unimportant!","Standardflag"));
1271 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1272 standardFlagsDefault->addFlag (fo);
1274 fo->load(flagsPath+"flag-thumb-up.png");
1275 fo->setName("thumb-up");
1276 fo->setGroup("standard-thumb");
1277 a=new QAction (fo->getPixmap(),fo->getName(),this);
1280 a->setCheckable(true);
1281 a->setObjectName(fo->getName());
1282 a->setToolTip(tr("I like this","Standardflag"));
1283 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1284 standardFlagsDefault->addFlag (fo);
1286 fo->load(flagsPath+"flag-thumb-down.png");
1287 fo->setName("thumb-down");
1288 fo->setGroup("standard-thumb");
1289 a=new QAction (fo->getPixmap(),fo->getName(),this);
1292 a->setCheckable(true);
1293 a->setObjectName(fo->getName());
1294 a->setToolTip(tr("I do not like this","Standardflag"));
1295 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1296 standardFlagsDefault->addFlag (fo);
1298 fo->load(flagsPath+"flag-rose.png");
1299 fo->setName("rose");
1300 a=new QAction (fo->getPixmap(),fo->getName(),this);
1303 a->setCheckable(true);
1304 a->setObjectName(fo->getName());
1305 a->setToolTip(tr("Rose","Standardflag"));
1306 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1307 standardFlagsDefault->addFlag (fo);
1309 fo->load(flagsPath+"flag-heart.png");
1310 fo->setName("heart");
1311 a=new QAction (fo->getPixmap(),fo->getName(),this);
1313 a->setCheckable(true);
1314 a->setObjectName(fo->getName());
1315 a->setToolTip(tr("I just love... ","Standardflag"));
1316 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1317 standardFlagsDefault->addFlag (fo);
1319 fo->load(flagsPath+"flag-present.png");
1320 fo->setName("present");
1321 a=new QAction (fo->getPixmap(),fo->getName(),this);
1324 a->setCheckable(true);
1325 a->setObjectName(fo->getName());
1326 a->setToolTip(tr("Surprise!","Standardflag"));
1327 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1328 standardFlagsDefault->addFlag (fo);
1330 fo->load(flagsPath+"flag-flash.png");
1331 fo->setName("flash");
1332 a=new QAction (fo->getPixmap(),fo->getName(),this);
1335 a->setCheckable(true);
1336 a->setObjectName(fo->getName());
1337 a->setToolTip(tr("Dangerous","Standardflag"));
1338 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1339 standardFlagsDefault->addFlag (fo);
1341 fo->load(flagsPath+"flag-info.png");
1342 // Original: xsldbg_output.png
1343 fo->setName("info");
1344 a=new QAction (fo->getPixmap(),fo->getName(),this);
1347 a->setCheckable(true);
1348 a->setObjectName(fo->getName());
1349 a->setToolTip(tr("Info","Standardflag"));
1350 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1351 standardFlagsDefault->addFlag (fo);
1353 fo->load(flagsPath+"flag-lifebelt.png");
1354 // Original khelpcenter.png
1355 fo->setName("lifebelt");
1356 a=new QAction (fo->getPixmap(),fo->getName(),this);
1359 a->setCheckable(true);
1360 a->setObjectName(fo->getName());
1361 a->setToolTip(tr("This will help","Standardflag"));
1362 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1363 standardFlagsDefault->addFlag (fo);
1369 void Main::setupSettingsActions()
1371 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1375 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1376 a->setStatusTip ( tr( "Set application to open pdf files"));
1377 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1378 settingsMenu->addAction (a);
1380 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1381 a->setStatusTip( tr( "Set application to open external links"));
1382 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1383 settingsMenu->addAction (a);
1385 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1386 a->setStatusTip( tr( "Set path for macros"));
1387 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1388 settingsMenu->addAction (a);
1390 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1391 a->setStatusTip( tr( "Set number of undo levels"));
1392 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1393 settingsMenu->addAction (a);
1395 settingsMenu->addSeparator();
1397 a = new QAction( tr( "Autosave","Settings action"), this);
1398 a->setStatusTip( tr( "Autosave"));
1399 a->setToggleAction(true);
1400 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1401 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1402 settingsMenu->addAction (a);
1403 actionSettingsAutosaveToggle=a;
1405 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1406 a->setStatusTip( tr( "Autosave time"));
1407 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1408 settingsMenu->addAction (a);
1409 actionSettingsAutosaveTime=a;
1411 settingsMenu->addSeparator();
1413 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1414 a->setStatusTip( tr( "Edit branch after adding it" ));
1415 a->setToggleAction(true);
1416 a->setOn ( settings.value ("/mapeditor/editmode/autoEdit",true).toBool());
1417 settingsMenu->addAction (a);
1418 actionSettingsAutoEdit=a;
1420 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1421 a->setStatusTip( tr( "Select branch after adding it" ));
1422 a->setToggleAction(true);
1423 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectHeading",false).toBool() );
1424 settingsMenu->addAction (a);
1425 actionSettingsAutoSelectHeading=a;
1427 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1428 a->setStatusTip( tr( "Select heading before editing" ));
1429 a->setToggleAction(true);
1430 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1431 settingsMenu->addAction (a);
1432 actionSettingsAutoSelectText=a;
1434 a= new QAction( tr( "Delete key","Settings action" ), this);
1435 a->setStatusTip( tr( "Delete key for deleting branches" ));
1436 a->setToggleAction(true);
1437 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1438 settingsMenu->addAction (a);
1439 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1440 actionSettingsUseDelKey=a;
1442 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1443 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1444 a->setToggleAction(true);
1445 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1446 settingsMenu->addAction (a);
1447 actionSettingsUseFlagGroups=a;
1449 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1450 a->setStatusTip( tr( "Use hide flag during exports " ));
1451 a->setToggleAction(true);
1452 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1453 settingsMenu->addAction (a);
1454 actionSettingsUseHideExport=a;
1458 void Main::setupTestActions()
1460 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1463 a = new QAction( "Test function" , this);
1464 a->setStatusTip( "Call test function" );
1465 //a->setShortcut (Qt::Key_F4 );
1466 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction() ) );
1467 testMenu->addAction (a);
1468 a = new QAction( "Command" , this);
1469 a->setStatusTip( "Enter command to call in editor" );
1470 //a->setShortcut (Qt::Key_F5 );
1471 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1472 testMenu->addAction (a);
1476 void Main::setupHelpActions()
1478 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1481 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1482 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1483 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1484 helpMenu->addAction (a);
1486 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1487 a->setStatusTip( tr( "Open VYM example maps " ));
1488 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1489 helpMenu->addAction (a);
1491 a = new QAction( tr( "About VYM","Help action" ), this);
1492 a->setStatusTip( tr( "About VYM")+vymName);
1493 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1494 helpMenu->addAction (a);
1496 a = new QAction( tr( "About QT","Help action" ), this);
1497 a->setStatusTip( tr( "Information about QT toolkit" ));
1498 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1499 helpMenu->addAction (a);
1503 void Main::setupContextMenus()
1507 // Context Menu for branch or mapcenter
1508 branchContextMenu =new QMenu (this);
1509 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1510 branchContextMenu->addSeparator();
1513 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1514 branchAddContextMenu->addAction (actionEditPaste );
1515 branchAddContextMenu->addAction ( actionEditAddBranch );
1516 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1517 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1518 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1519 branchAddContextMenu->addSeparator();
1520 branchAddContextMenu->addAction ( actionEditImportAdd );
1521 branchAddContextMenu->addAction ( actionEditImportReplace );
1524 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1525 branchRemoveContextMenu->addAction (actionEditCut);
1526 branchRemoveContextMenu->addAction ( actionEditDelete );
1527 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1528 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1531 actionEditSaveBranch->addTo( branchContextMenu );
1533 branchContextMenu->addSeparator();
1534 branchContextMenu->addAction ( actionEditLoadImage);
1536 // Submenu for Links (URLs, vymLinks)
1537 branchLinksContextMenu =new QMenu (this);
1539 branchContextMenu->addSeparator();
1540 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1541 branchLinksContextMenu->addAction ( actionEditOpenURL );
1542 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1543 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1544 branchLinksContextMenu->addAction ( actionEditURL );
1545 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1546 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1547 if (settings.value( "/mainwindow/showTestMenu",true).toBool() )
1549 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1551 branchLinksContextMenu->addSeparator();
1552 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1553 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1554 branchLinksContextMenu->addAction ( actionEditVymLink );
1555 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1558 // Context Menu for XLinks in a branch menu
1559 // This will be populated "on demand" in MapEditor::updateActions
1560 branchContextMenu->addSeparator();
1561 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1562 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1563 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1564 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1567 // Context menu for floatimage
1568 floatimageContextMenu =new QMenu (this);
1569 a= new QAction (tr ("Save image","Context action"),this);
1570 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1571 floatimageContextMenu->addAction (a);
1573 floatimageContextMenu->addSeparator();
1574 actionEditCopy->addTo( floatimageContextMenu );
1575 actionEditCut->addTo( floatimageContextMenu );
1577 floatimageContextMenu->addSeparator();
1578 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1581 // Context menu for canvas
1582 canvasContextMenu =new QMenu (this);
1583 actionEditMapInfo->addTo( canvasContextMenu );
1584 canvasContextMenu->insertSeparator();
1585 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1586 canvasContextMenu->insertSeparator();
1587 actionFormatLinkColorHint->addTo( canvasContextMenu );
1588 actionFormatLinkColor->addTo( canvasContextMenu );
1589 actionFormatSelectionColor->addTo( canvasContextMenu );
1590 actionFormatBackColor->addTo( canvasContextMenu );
1591 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1593 // Menu for last opened files
1595 for (int i = 0; i < MaxRecentFiles; ++i)
1597 recentFileActions[i] = new QAction(this);
1598 recentFileActions[i]->setVisible(false);
1599 fileLastMapsMenu->addAction(recentFileActions[i]);
1600 connect(recentFileActions[i], SIGNAL(triggered()),
1601 this, SLOT(fileLoadRecent()));
1603 setupRecentMapsMenu();
1606 void Main::setupRecentMapsMenu()
1608 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1610 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1612 for (int i = 0; i < numRecentFiles; ++i) {
1613 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1614 recentFileActions[i]->setText(text);
1615 recentFileActions[i]->setData(files[i]);
1616 recentFileActions[i]->setVisible(true);
1618 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1619 recentFileActions[j]->setVisible(false);
1622 void Main::setupMacros()
1624 for (int i = 0; i <= 11; i++)
1626 macroActions[i] = new QAction(this);
1627 macroActions[i]->setData(i);
1628 addAction (macroActions[i]);
1629 connect(macroActions[i], SIGNAL(triggered()),
1630 this, SLOT(callMacro()));
1632 macroActions[0]->setShortcut ( Qt::Key_F1 );
1633 macroActions[1]->setShortcut ( Qt::Key_F2 );
1634 macroActions[2]->setShortcut ( Qt::Key_F3 );
1635 macroActions[3]->setShortcut ( Qt::Key_F4 );
1636 macroActions[4]->setShortcut ( Qt::Key_F5 );
1637 macroActions[5]->setShortcut ( Qt::Key_F6 );
1638 macroActions[6]->setShortcut ( Qt::Key_F7 );
1639 macroActions[7]->setShortcut ( Qt::Key_F8 );
1640 macroActions[8]->setShortcut ( Qt::Key_F9 );
1641 macroActions[9]->setShortcut ( Qt::Key_F10 );
1642 macroActions[10]->setShortcut ( Qt::Key_F11 );
1643 macroActions[11]->setShortcut ( Qt::Key_F12 );
1646 void Main::hideEvent (QHideEvent * )
1648 if (!textEditor->isMinimized() ) textEditor->hide();
1651 void Main::showEvent (QShowEvent * )
1653 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1656 bool Main::reallyWriteDirectory(const QString &dir)
1658 QStringList eList = QDir(dir).entryList();
1659 if (eList.first() ==".") eList.pop_front(); // remove "."
1660 if (eList.first() =="..") eList.pop_front(); // remove "."
1661 if (!eList.isEmpty())
1663 QMessageBox mb( vymName,
1664 tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
1665 QMessageBox::Warning,
1667 QMessageBox::Cancel | QMessageBox::Default,
1668 QMessageBox::QMessageBox::NoButton );
1670 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
1671 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1674 case QMessageBox::Yes:
1677 case QMessageBox::Cancel:
1685 QString Main::browseDirectory (const QString &caption)
1687 QFileDialog fd(this,caption);
1688 fd.setMode (QFileDialog::DirectoryOnly);
1689 fd.setCaption(vymName+ " - "+caption);
1690 fd.setDir (lastFileDir);
1693 if ( fd.exec() == QDialog::Accepted )
1694 return fd.selectedFile();
1699 MapEditor* Main::currentMapEditor() const
1701 if ( tabWidget->currentPage() &&
1702 tabWidget->currentPage()->inherits( "MapEditor" ) )
1703 return (MapEditor*)tabWidget->currentPage();
1708 void Main::editorChanged(QWidget *)
1710 // Unselect all possibly selected objects
1711 // (Important to update note editor)
1713 for (int i=0;i<=tabWidget->count() -1;i++)
1716 me=(MapEditor*)tabWidget->page(i);
1719 currentMapEditor()->reselect();
1721 // Update actions to in menus and toolbars according to editor
1725 void Main::fileNew()
1727 QString fn="unnamed";
1728 MapEditor* me = new MapEditor ( NULL);
1729 tabWidget->addTab (me,fn);
1730 tabWidget->showPage(me);
1731 me->viewport()->setFocus();
1732 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1733 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1735 // For the very first map we do not have flagrows yet...
1739 void Main::fileNewCopy()
1741 QString fn="unnamed";
1742 MapEditor* oldME =currentMapEditor();
1746 MapEditor* newME = new MapEditor ( NULL);
1749 tabWidget->addTab (newME,fn);
1750 tabWidget->showPage(newME);
1751 newME->viewport()->setFocus();
1752 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1753 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1754 // For the very first map we do not have flagrows yet...
1755 newME->select("mc:");
1756 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace);
1762 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
1764 ErrorCode err=success;
1766 // fn is usually the archive, mapfile the file after uncompressing
1769 // Make fn absolute (needed for unzip)
1770 fn=QDir (fn).absPath();
1776 // Check, if map is already loaded
1778 while (i<=tabWidget->count() -1)
1780 me=(MapEditor*)tabWidget->page(i);
1781 if (me->getFilePath() == fn)
1783 // Already there, ask for confirmation
1784 QMessageBox mb( vymName,
1785 tr("The map %1\nis already opened."
1786 "Opening the same map in multiple editors may lead \n"
1787 "to confusion when finishing working with vym."
1788 "Do you want to").arg(fn),
1789 QMessageBox::Warning,
1790 QMessageBox::Yes | QMessageBox::Default,
1791 QMessageBox::Cancel | QMessageBox::Escape,
1792 QMessageBox::NoButton);
1793 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1794 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1797 case QMessageBox::Yes:
1799 i=tabWidget->count();
1801 case QMessageBox::Cancel:
1813 if ( !fn.isEmpty() )
1815 me = currentMapEditor();
1816 int tabIndex=tabWidget->currentPageIndex();
1817 // Check first, if mapeditor exists
1818 // If it is not default AND we want a new map,
1819 // create a new mapeditor in a new tab
1820 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1822 me= new MapEditor ( NULL);
1823 tabWidget->addTab (me,fn);
1824 tabIndex=tabWidget->indexOf (me);
1825 tabWidget->setCurrentPage (tabIndex);
1826 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1827 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1830 // Check, if file exists (important for creating new files
1831 // from command line
1832 if (!QFile(fn).exists() )
1834 QMessageBox mb( vymName,
1835 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1836 QMessageBox::Question,
1838 QMessageBox::Cancel | QMessageBox::Default,
1839 QMessageBox::NoButton );
1841 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1842 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1845 case QMessageBox::Yes:
1847 currentMapEditor()->setFilePath(fn);
1848 tabWidget->setTabLabel (currentMapEditor(),
1849 currentMapEditor()->getFileName() );
1850 statusBar()->message( "Created " + fn , statusbarTime );
1853 case QMessageBox::Cancel:
1854 // don't create new map
1855 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1862 //tabWidget->currentPage() won't be NULL here, because of above...
1863 tabWidget->showPage(me);
1864 me->viewport()->setFocus();
1866 // Create temporary directory for packing
1868 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1871 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1872 tr("Couldn't create temporary directory before load\n"));
1876 // Try to unzip file
1877 err=unzipDir (tmpMapDir,fn);
1881 me->setZipped(false);
1884 me->setZipped(true);
1886 // Look for mapname.xml
1887 mapfile= fn.left(fn.findRev(".",-1,true));
1888 mapfile=mapfile.section( '/', -1 );
1889 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1890 if (!file.exists() )
1892 // mapname.xml does not exist, well,
1893 // maybe someone renamed the mapname.vym file...
1894 // Try to find any .xml in the toplevel
1895 // directory of the .vym file
1896 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1897 if (flist.count()==1)
1899 // Only one entry, take this one
1900 mapfile=tmpMapDir + "/"+flist.first();
1903 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1904 *it=tmpMapDir + "/" + *it;
1905 // TODO Multiple entries, load all (but only the first one into this ME)
1906 //mainWindow->fileLoadFromTmp (flist);
1907 //returnCode=1; // Silently forget this attempt to load
1908 qWarning ("MainWindow::load (fn) multimap found...");
1911 if (flist.isEmpty() )
1913 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1914 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1917 } //file doesn't exist
1919 mapfile=file.name();
1924 // Save existing filename in case we import
1925 QString fn_org=me->getFilePath();
1927 // Finally load map into mapEditor
1928 me->setFilePath (mapfile,fn);
1929 err=me->load(mapfile,lmode);
1931 // Restore old (maybe empty) filepath, if this is an import
1933 me->setFilePath (fn_org);
1936 // Finally check for errors and go home
1939 if (lmode==NewMap) fileCloseMap();
1940 statusBar()->message( "Could not load " + fn, statusbarTime );
1945 me->setFilePath (fn);
1946 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1947 if (fn.left(9)!="/tmp/vym-")
1949 // Only append to lastMaps if not loaded from a tmpDir
1950 // e.g. imported bookmarks are in a tmpDir
1951 addRecentMap(me->getFilePath() );
1953 actionFilePrint->setEnabled (true);
1955 statusBar()->message( "Loaded " + fn, statusbarTime );
1959 removeDir (QDir(tmpMapDir));
1965 void Main::fileLoad(const LoadMode &lmode)
1967 QStringList filters;
1968 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1969 QFileDialog *fd=new QFileDialog( this);
1970 fd->setDir (lastFileDir);
1971 fd->setFileMode (QFileDialog::ExistingFiles);
1972 fd->setFilters (filters);
1976 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1979 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1982 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1988 if ( fd->exec() == QDialog::Accepted )
1990 lastFileDir=fd->directory().path();
1991 QStringList flist = fd->selectedFiles();
1992 QStringList::Iterator it = flist.begin();
1993 while( it != flist.end() )
1996 fileLoad(*it, lmode);
2003 void Main::fileLoad()
2008 void Main::fileLoadRecent()
2010 QAction *action = qobject_cast<QAction *>(sender());
2012 fileLoad (action->data().toString(), NewMap);
2015 void Main::addRecentMap (const QString &fileName)
2018 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2019 files.removeAll(fileName);
2020 files.prepend(fileName);
2021 while (files.size() > MaxRecentFiles)
2024 settings.setValue("/mainwindow/recentFileList", files);
2026 setupRecentMapsMenu();
2029 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
2031 // tmp dir for zipping
2035 ErrorCode err=success;
2037 QString safeFilePath;
2039 bool saveZipped=me->saveZipped();
2043 QString fn=me->getFilePath();
2044 // filename=unnamed, filepath="" in constructor of mapEditor
2045 if ( !fn.isEmpty() )
2047 // We have a filepath, go on saving
2048 // First remove existing file, we
2049 // don't want to add to old zip archives
2053 QMessageBox::warning( 0, tr( "Save Error" ),
2054 fn+ tr("\ncould not be removed before saving"));
2056 // Look, if we should zip the data:
2059 QMessageBox mb( vymName,
2060 tr("The map %1\ndid not use the compressed "
2061 "vym file format.\nWriting it uncompressed will also write images \n"
2062 "and flags and thus may overwrite files in the "
2063 "given directory\n\nDo you want to write the map").arg(fn),
2064 QMessageBox::Warning,
2065 QMessageBox::Yes | QMessageBox::Default,
2067 QMessageBox::Cancel | QMessageBox::Escape);
2068 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
2069 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
2070 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2073 case QMessageBox::Yes:
2074 // save compressed (default file format)
2077 case QMessageBox::No:
2078 // save uncompressed
2081 case QMessageBox::Cancel:
2090 // Create temporary directory for packing
2092 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2095 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2096 tr("Couldn't create temporary directory before save\n"));
2100 safeFilePath=me->getFilePath();
2101 me->setFilePath (tmpMapDir+"/"+
2102 me->getMapName()+ ".xml",
2104 me->save (savemode);
2105 me->setFilePath (safeFilePath);
2107 zipDir (tmpMapDir,fn);
2112 safeFilePath=me->getFilePath();
2113 me->setFilePath (fn, safeFilePath);
2114 me->save (savemode);
2115 me->setFilePath (safeFilePath);
2117 } // filepath available
2120 // We have no filepath yet,
2121 // call fileSaveAs() now, this will call fileSave()
2123 // First switch to editor
2124 tabWidget->setCurrentWidget (me);
2125 fileSaveAs(savemode);
2129 if (saveZipped && !tmpMapDir.isEmpty())
2131 removeDir (QDir(tmpMapDir));
2135 statusBar()->message(
2136 tr("Saved %1").arg(me->getFilePath()),
2138 addRecentMap (me->getFilePath() );
2140 statusBar()->message(
2141 tr("Couldn't save ").arg(me->getFilePath()),
2145 void Main::fileSave()
2147 fileSave (currentMapEditor(), CompleteMap);
2150 void Main::fileSave(MapEditor *me)
2152 fileSave (me,CompleteMap);
2155 void Main::fileSaveAs(const SaveMode& savemode)
2159 if (currentMapEditor())
2161 if (savemode==CompleteMap)
2162 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2164 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2165 if ( !fn.isEmpty() )
2167 // Check for existing file
2168 if (QFile (fn).exists())
2170 QMessageBox mb( vymName,
2171 tr("The file %1\nexists already. Do you want to").arg(fn),
2172 QMessageBox::Warning,
2173 QMessageBox::Yes | QMessageBox::Default,
2174 QMessageBox::Cancel | QMessageBox::Escape,
2175 QMessageBox::NoButton);
2176 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2177 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2180 case QMessageBox::Yes:
2183 case QMessageBox::Cancel:
2190 // New file, add extension to filename, if missing
2191 // This is always .vym or .vyp, depending on savemode
2192 if (savemode==CompleteMap)
2194 if (!fn.contains (".vym") && !fn.contains (".xml"))
2198 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2207 currentMapEditor()->setFilePath(fn);
2208 fileSave(currentMapEditor(), savemode);
2211 if (savemode==CompleteMap)
2212 tabWidget->setTabLabel (currentMapEditor(),
2213 currentMapEditor()->getFileName() );
2219 void Main::fileSaveAs()
2221 fileSaveAs (CompleteMap);
2224 void Main::fileImportKDEBookmarks()
2226 ImportKDEBookmarks im;
2228 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2229 currentMapEditor()->setFilePath ("");
2232 void Main::fileImportFirefoxBookmarks()
2234 Q3FileDialog *fd=new Q3FileDialog( this);
2235 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2236 fd->setMode (Q3FileDialog::ExistingFiles);
2237 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2238 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2241 if ( fd->exec() == QDialog::Accepted )
2243 ImportFirefoxBookmarks im;
2244 QStringList flist = fd->selectedFiles();
2245 QStringList::Iterator it = flist.begin();
2246 while( it != flist.end() )
2249 if (im.transform() &&
2250 success==fileLoad (im.getTransformedFile(),NewMap) &&
2251 currentMapEditor() )
2252 currentMapEditor()->setFilePath ("");
2259 void Main::fileImportMM()
2263 Q3FileDialog *fd=new Q3FileDialog( this);
2264 fd->setDir (lastFileDir);
2265 fd->setMode (Q3FileDialog::ExistingFiles);
2266 fd->addFilter ("Mind Manager (*.mmap)");
2267 fd->setCaption(tr("Import")+" "+"Mind Manager");
2270 if ( fd->exec() == QDialog::Accepted )
2272 lastFileDir=fd->dirPath();
2273 QStringList flist = fd->selectedFiles();
2274 QStringList::Iterator it = flist.begin();
2275 while( it != flist.end() )
2278 if (im.transform() &&
2279 success==fileLoad (im.getTransformedFile(),NewMap) &&
2280 currentMapEditor() )
2281 currentMapEditor()->setFilePath ("");
2290 void Main::fileImportDir()
2292 if (currentMapEditor())
2293 currentMapEditor()->importDir();
2296 void Main::fileExportXML()
2298 if (currentMapEditor())
2300 QString dir=browseDirectory(tr("Export XML to directory"));
2301 if (dir !="" && reallyWriteDirectory(dir) )
2302 currentMapEditor()->exportXML(dir);
2307 void Main::fileExportXHTML()
2309 MapEditor *me=currentMapEditor();
2313 ExportXHTMLDialog dia(this);
2314 dia.setFilePath (me->getFilePath() );
2315 dia.setMapName (me->getMapName() );
2318 if (dia.exec()==QDialog::Accepted)
2320 QString dir=dia.getDir();
2321 // Check, if warnings should be used before overwriting
2322 // the output directory
2324 warn.showCancelButton (true);
2325 warn.setText(QString(
2326 "The directory %1 is not empty.\n"
2327 "Do you risk to overwrite some of its contents?").arg(dir));
2328 warn.setCaption("Warning: Directory not empty");
2329 warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
2330 if (warn.exec()==QDialog::Accepted)
2332 me->exportXML (dia.getDir() );
2333 dia.doExport(me->getMapName() );
2334 if (dia.hasChanged())
2341 void Main::fileExportImage()
2343 MapEditor *me=currentMapEditor();
2347 QFileDialog *fd=new QFileDialog (this);
2348 fd->setCaption (tr("Export map as image"));
2349 fd->setDirectory (lastImageDir);
2350 fd->setFileMode(QFileDialog::AnyFile);
2351 fd->setFilters (imageIO.getFilters() );
2354 fl=fd->selectedFiles();
2355 me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) );
2360 void Main::fileExportASCII()
2362 MapEditor *me=currentMapEditor();
2366 ex.setMapCenter(me->getMapCenter());
2367 ex.addFilter ("TXT (*.txt)");
2368 ex.setDir(lastImageDir);
2369 ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
2370 if (ex.execDialog() )
2372 me->setExportMode(true);
2374 me->setExportMode(false);
2379 void Main::fileExportCSV()
2381 MapEditor *me=currentMapEditor();
2385 ex.setMapCenter(me->getMapCenter());
2386 ex.addFilter ("CSV (*.csv)");
2387 ex.setDir(lastImageDir);
2388 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2389 if (ex.execDialog() )
2391 me->setExportMode(true);
2393 me->setExportMode(false);
2398 void Main::fileExportLaTeX()
2400 MapEditor *me=currentMapEditor();
2404 ex.setMapCenter(me->getMapCenter());
2405 ex.addFilter ("Tex (*.tex)");
2406 ex.setDir(lastImageDir);
2407 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2408 if (ex.execDialog() )
2410 me->setExportMode(true);
2412 me->setExportMode(false);
2417 void Main::fileExportKDEBookmarks()
2419 ExportKDEBookmarks ex;
2420 MapEditor *me=currentMapEditor();
2423 ex.setMapCenter (me->getMapCenter() );
2428 void Main::fileExportTaskjuggler()
2430 ExportTaskjuggler ex;
2431 MapEditor *me=currentMapEditor();
2434 ex.setMapCenter (me->getMapCenter() );
2435 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2436 ex.setDir(lastImageDir);
2437 ex.addFilter ("Taskjuggler (*.tjp)");
2438 if (ex.execDialog() )
2440 me->setExportMode(true);
2442 me->setExportMode(false);
2447 void Main::fileExportOOPresentation()
2449 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2450 // TODO add preview in dialog
2451 //ImagePreview *p =new ImagePreview (fd);
2452 //fd->setContentsPreviewEnabled( TRUE );
2453 //fd->setContentsPreview( p, p );
2454 //fd->setPreviewMode( QFileDialog::Contents );
2455 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2456 fd->setDir (QDir().current());
2457 if (fd->foundConfig())
2461 if ( fd->exec() == QDialog::Accepted )
2463 QString fn=fd->selectedFile();
2464 if (!fn.contains (".odp"))
2467 //lastImageDir=fn.left(fn.findRev ("/"));
2468 if (currentMapEditor())
2469 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2473 QMessageBox::warning(0,
2475 tr("Couldn't find configuration for export to Open Office\n"));
2479 void Main::fileCloseMap()
2481 if (currentMapEditor())
2483 if (currentMapEditor()->hasChanged())
2485 QMessageBox mb( vymName,
2486 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2487 QMessageBox::Warning,
2488 QMessageBox::Yes | QMessageBox::Default,
2490 QMessageBox::Cancel | QMessageBox::Escape );
2491 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2492 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2495 case QMessageBox::Yes:
2497 fileSave(currentMapEditor(), CompleteMap);
2499 case QMessageBox::No:
2500 // close without saving
2502 case QMessageBox::Cancel:
2507 currentMapEditor()->closeMap();
2508 tabWidget->removePage(currentMapEditor());
2509 if (tabWidget->count()==0)
2510 actionFilePrint->setEnabled (false);
2514 void Main::filePrint()
2516 if (currentMapEditor())
2517 currentMapEditor()->print();
2520 void Main::fileExitVYM()
2522 // Check if one or more editors have changed
2525 for (i=0;i<=tabWidget->count() -1;i++)
2528 me=(MapEditor*)tabWidget->page(i);
2530 // If something changed, ask what to do
2531 if (me->hasChanged())
2533 tabWidget->setCurrentPage(i);
2534 QMessageBox mb( vymName,
2535 tr("This map is not saved yet. Do you want to"),
2536 QMessageBox::Warning,
2537 QMessageBox::Yes | QMessageBox::Default,
2539 QMessageBox::Cancel | QMessageBox::Escape );
2540 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2541 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2544 mb.setActiveWindow();
2545 switch( mb.exec() ) {
2546 case QMessageBox::Yes:
2547 // save (the changed editors) and exit
2548 fileSave(currentMapEditor(), CompleteMap);
2550 case QMessageBox::No:
2551 // exit without saving
2553 case QMessageBox::Cancel:
2554 // don't save and don't exit
2558 } // loop over all MEs
2562 void Main::editUndo()
2564 if (currentMapEditor())
2565 currentMapEditor()->undo();
2568 void Main::editRedo()
2570 if (currentMapEditor())
2571 currentMapEditor()->redo();
2574 void Main::gotoHistoryStep (int i)
2576 if (currentMapEditor())
2577 currentMapEditor()->gotoHistoryStep (i);
2580 void Main::editCopy()
2582 if (currentMapEditor())
2583 currentMapEditor()->copy();
2586 void Main::editPaste()
2588 if (currentMapEditor())
2589 currentMapEditor()->paste();
2592 void Main::editCut()
2594 if (currentMapEditor())
2595 currentMapEditor()->cut();
2598 void Main::editOpenFindWindow()
2600 findWindow->popup();
2601 findWindow->raise();
2602 findWindow->setActiveWindow();
2605 void Main::editFind(QString s)
2608 BranchObj *bo=currentMapEditor()->findText(s, cs);
2611 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2614 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2615 tr("No matches found for \"%1\"").arg(s));
2619 void Main::editFindChanged()
2620 { // Notify editor, to abort the current find process
2621 currentMapEditor()->findReset();
2624 void Main::openTabs(QStringList urls)
2626 if (!urls.isEmpty())
2630 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2632 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2634 QString u=urls.takeFirst();
2635 procBrowser = new QProcess( this );
2637 procBrowser->start(browser,args);
2638 if ( !procBrowser->waitForStarted())
2640 // try to set path to browser
2641 QMessageBox::warning(0,
2643 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2644 tr("Please use Settings->")+tr("Set application to open an URL"));
2649 if (browser.contains("konqueror"))
2651 for (int i=0; i<urls.size(); i++)
2654 // Try to open new tab in existing konqueror started previously by vym
2655 p=new QProcess (this);
2657 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2658 "konqueror-mainwindow#1"<<
2661 p->start ("dcop",args);
2662 if ( !p->waitForStarted() ) success=false;
2665 QMessageBox::warning(0,
2667 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2669 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2671 for (int i=0; i<urls.size(); i++)
2673 // Try to open new tab in firefox
2674 p=new QProcess (this);
2675 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2676 p->start (browser,args);
2677 if ( !p->waitForStarted() ) success=false;
2680 QMessageBox::warning(0,
2682 tr("Couldn't start %1 to open a new tab").arg(browser));
2685 QMessageBox::warning(0,
2687 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2691 void Main::editOpenURL()
2694 if (currentMapEditor())
2696 QString url=currentMapEditor()->getURL();
2698 if (url=="") return;
2699 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2700 procBrowser = new QProcess( this );
2702 procBrowser->start(browser,args);
2703 if ( !procBrowser->waitForStarted())
2705 // try to set path to browser
2706 QMessageBox::warning(0,
2708 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2709 tr("Please use Settings->")+tr("Set application to open an URL"));
2714 void Main::editOpenURLTab()
2716 if (currentMapEditor())
2719 urls.append(currentMapEditor()->getURL());
2723 void Main::editOpenMultipleURLTabs()
2725 if (currentMapEditor())
2728 urls=currentMapEditor()->getURLs();
2734 void Main::editURL()
2736 if (currentMapEditor())
2737 currentMapEditor()->editURL();
2740 void Main::editHeading2URL()
2742 if (currentMapEditor())
2743 currentMapEditor()->editHeading2URL();
2746 void Main::editBugzilla2URL()
2748 if (currentMapEditor())
2749 currentMapEditor()->editBugzilla2URL();
2752 void Main::editFATE2URL()
2754 if (currentMapEditor())
2755 currentMapEditor()->editFATE2URL();
2758 void Main::editHeadingFinished()
2760 // only called from editHeading(), so there is a currentME
2761 MapEditor *me=currentMapEditor();
2764 me->setStateEditHeading (false);
2765 QPoint p; //Not used here, only to find out pos of branch
2767 QString s=me->getHeading(ok,p);
2769 #if defined(Q_OS_MACX)
2771 if (ok && s!=lineedit->text())
2772 me->setHeading(lineedit->text());
2774 lineedit->releaseKeyboard();
2778 if (!prevSelection.isEmpty()) me->select(prevSelection);
2783 void Main::editHeading()
2785 if (currentMapEditor())
2787 MapEditor *me=currentMapEditor();
2788 QString oldSel=me->getSelectString();
2790 if (lineedit->isVisible())
2791 editHeadingFinished();
2796 QString s=currentMapEditor()->getHeading(ok,p);
2800 me->setStateEditHeading (true);
2801 #if defined(Q_OS_MACX)
2802 p=currentMapEditor()->mapTo (this,p);
2803 QDialog *d =new QDialog(NULL);
2804 QLineEdit *le=new QLineEdit (d);
2805 d->setWindowFlags (Qt::FramelessWindowHint);
2806 d->setGeometry(p.x(),p.y(),230,25);
2807 le->resize (d->width()-10,d->height());
2810 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2811 d->activateWindow();
2813 currentMapEditor()->setHeading (le->text());
2816 editHeadingFinished();
2818 p=currentMapEditor()->mapTo (this,p);
2819 lineedit->setGeometry(p.x(),p.y(),230,25);
2820 lineedit->setText(s);
2821 lineedit->setCursorPosition(1);
2822 lineedit->selectAll();
2824 lineedit->grabKeyboard();
2825 lineedit->setFocus();
2829 } // currentMapEditor()
2832 void Main::openVymLinks(const QStringList &vl)
2834 for (int j=0; j<vl.size(); j++)
2836 // compare path with already loaded maps
2840 for (i=0;i<=tabWidget->count() -1;i++)
2842 me=(MapEditor*)tabWidget->page(i);
2843 if (vl.at(j)==me->getFilePath() )
2852 if (!QFile(vl.at(j)).exists() )
2853 QMessageBox::critical( 0, tr( "Critical Error" ),
2854 tr("Couldn't open map %1").arg(vl.at(j)));
2857 fileLoad (vl.at(j), NewMap);
2858 tabWidget->setCurrentPage (tabWidget->count()-1);
2861 // Go to tab containing the map
2862 tabWidget->setCurrentPage (index);
2866 void Main::editOpenVymLink()
2868 if (currentMapEditor())
2871 vl.append(currentMapEditor()->getVymLink());
2876 void Main::editOpenMultipleVymLinks()
2878 QString currentVymLink;
2879 if (currentMapEditor())
2881 QStringList vl=currentMapEditor()->getVymLinks();
2886 void Main::editVymLink()
2888 if (currentMapEditor())
2889 currentMapEditor()->editVymLink();
2892 void Main::editDeleteVymLink()
2894 if (currentMapEditor())
2895 currentMapEditor()->deleteVymLink();
2898 void Main::editToggleHideExport()
2900 if (currentMapEditor())
2901 currentMapEditor()->toggleHideExport();
2904 void Main::editMapInfo()
2906 if (currentMapEditor())
2907 currentMapEditor()->editMapInfo();
2910 void Main::editMoveUp()
2912 if (currentMapEditor())
2913 currentMapEditor()->moveBranchUp();
2916 void Main::editMoveDown()
2918 if (currentMapEditor())
2919 currentMapEditor()->moveBranchDown();
2922 void Main::editToggleScroll()
2924 if (currentMapEditor())
2926 currentMapEditor()->toggleScroll();
2930 void Main::editUnscrollChilds()
2932 if (currentMapEditor())
2933 currentMapEditor()->unscrollChilds();
2936 void Main::editNewBranch()
2938 MapEditor *me=currentMapEditor();
2939 if (!lineedit->isVisible() && me)
2941 BranchObj *bo=(BranchObj*)me->getSelection();
2942 BranchObj *newbo=me->addNewBranch(0);
2945 me->select (newbo->getSelectString());
2949 if (actionSettingsAutoEdit->isOn())
2951 if (!actionSettingsAutoSelectHeading->isOn())
2952 prevSelection=bo->getSelectString();
2958 void Main::editNewBranchBefore()
2960 MapEditor *me=currentMapEditor();
2961 if (!lineedit->isVisible() && me)
2963 BranchObj *bo=(BranchObj*)me->getSelection();
2964 BranchObj *newbo=me->addNewBranchBefore();
2967 me->select (newbo->getSelectString());
2971 if (actionSettingsAutoEdit->isOn())
2973 if (!actionSettingsAutoSelectHeading->isOn())
2974 prevSelection=bo->getSelectString();
2980 void Main::editNewBranchAbove()
2982 MapEditor *me=currentMapEditor();
2983 if (!lineedit->isVisible() && me)
2985 BranchObj *bo=(BranchObj*)me->getSelection();
2986 BranchObj *newbo=me->addNewBranch (-1);
2989 me->select (newbo->getSelectString());
2993 if (actionSettingsAutoEdit->isOn())
2995 if (!actionSettingsAutoSelectHeading->isOn())
2996 prevSelection=bo->getSelectString();
3002 void Main::editNewBranchBelow()
3004 MapEditor *me=currentMapEditor();
3005 if (!lineedit->isVisible() && me)
3007 BranchObj *bo=(BranchObj*)me->getSelection();
3008 BranchObj *newbo=me->addNewBranch (1);
3011 me->select (newbo->getSelectString());
3015 if (actionSettingsAutoEdit->isOn())
3017 if (!actionSettingsAutoSelectHeading->isOn())
3018 prevSelection=bo->getSelectString();
3024 void Main::editImportAdd()
3026 fileLoad (ImportAdd);
3029 void Main::editImportReplace()
3031 fileLoad (ImportReplace);
3034 void Main::editSaveBranch()
3036 fileSaveAs (PartOfMap);
3039 void Main::editDeleteKeepChilds()
3041 if (currentMapEditor())
3042 currentMapEditor()->deleteKeepChilds();
3045 void Main::editDeleteChilds()
3047 if (currentMapEditor())
3048 currentMapEditor()->deleteChilds();
3051 void Main::editDeleteSelection()
3053 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3054 currentMapEditor()->deleteSelection();
3057 void Main::editUpperBranch()
3059 if (currentMapEditor())
3060 currentMapEditor()->selectUpperBranch();
3063 void Main::editLowerBranch()
3065 if (currentMapEditor())
3066 currentMapEditor()->selectLowerBranch();
3069 void Main::editLeftBranch()
3071 if (currentMapEditor())
3072 currentMapEditor()->selectLeftBranch();
3075 void Main::editRightBranch()
3077 if (currentMapEditor())
3078 currentMapEditor()->selectRightBranch();
3081 void Main::editFirstBranch()
3083 if (currentMapEditor())
3084 currentMapEditor()->selectFirstBranch();
3087 void Main::editLastBranch()
3089 if (currentMapEditor())
3090 currentMapEditor()->selectLastBranch();
3093 void Main::editLoadImage()
3095 if (currentMapEditor())
3096 currentMapEditor()->loadFloatImage();
3099 void Main::editSaveImage()
3101 if (currentMapEditor())
3102 currentMapEditor()->saveFloatImage();
3105 void Main::editFollowXLink(QAction *a)
3108 if (currentMapEditor())
3109 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3112 void Main::editEditXLink(QAction *a)
3114 if (currentMapEditor())
3115 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3118 void Main::formatSelectColor()
3120 if (currentMapEditor())
3122 QColor col = QColorDialog::getColor((currentColor ), this );
3123 if ( !col.isValid() ) return;
3124 colorChanged( col );
3128 void Main::formatPickColor()
3130 if (currentMapEditor())
3131 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3134 void Main::colorChanged(QColor c)
3136 QPixmap pix( 16, 16 );
3138 actionFormatColor->setIconSet( pix );
3142 void Main::formatColorBranch()
3144 if (currentMapEditor())
3145 currentMapEditor()->colorBranch(currentColor);
3148 void Main::formatColorSubtree()
3150 if (currentMapEditor())
3151 currentMapEditor()->colorSubtree (currentColor);
3154 void Main::formatLinkStyleLine()
3156 if (currentMapEditor())
3157 currentMapEditor()->setMapLinkStyle("StyleLine");
3160 void Main::formatLinkStyleParabel()
3162 if (currentMapEditor())
3163 currentMapEditor()->setMapLinkStyle("StyleParabel");
3166 void Main::formatLinkStylePolyLine()
3168 if (currentMapEditor())
3169 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3172 void Main::formatLinkStylePolyParabel()
3174 if (currentMapEditor())
3175 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3178 void Main::formatSelectBackColor()
3180 if (currentMapEditor())
3181 currentMapEditor()->selectMapBackgroundColor();
3184 void Main::formatSelectBackImage()
3186 if (currentMapEditor())
3187 currentMapEditor()->selectMapBackgroundImage();
3190 void Main::formatSelectLinkColor()
3192 if (currentMapEditor())
3193 currentMapEditor()->selectMapLinkColor();
3196 void Main::formatSelectSelectionColor()
3198 if (currentMapEditor())
3199 currentMapEditor()->selectMapSelectionColor();
3202 void Main::formatToggleLinkColorHint()
3204 currentMapEditor()->toggleMapLinkColorHint();
3208 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3210 if (currentMapEditor())
3211 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3214 void Main::viewZoomReset()
3216 if (currentMapEditor())
3220 currentMapEditor()->setMatrix( m );
3224 void Main::viewZoomIn()
3226 if (currentMapEditor())
3228 QMatrix m = currentMapEditor()->matrix();
3229 m.scale( 1.25, 1.25 );
3230 currentMapEditor()->setMatrix( m );
3234 void Main::viewZoomOut()
3236 if (currentMapEditor())
3238 QMatrix m = currentMapEditor()->matrix();
3239 m.scale( 0.8, 0.8 );
3240 currentMapEditor()->setMatrix( m );
3244 bool Main::settingsPDF()
3246 // Default browser is set in constructor
3248 QString text = QInputDialog::getText(
3249 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3250 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3252 settings.setValue ("/mainwindow/readerPDF",text);
3257 bool Main::settingsURL()
3259 // Default browser is set in constructor
3261 QString text = QInputDialog::getText(
3262 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3263 settings.value("/mainwindow/readerURL").toString()
3266 settings.setValue ("/mainwindow/readerURL",text);
3270 void Main::settingsMacroDir()
3272 QDir defdir=vymBaseDir;
3273 defdir.cd("macros");
3274 if (!defdir.exists())
3276 QDir dir=QFileDialog::getExistingDirectory (
3278 tr ("Directory with vym macros:"),
3279 settings.value ("/macros/macroDir",defdir.path()).toString()
3282 settings.setValue ("/macros/macroDir",dir.path());
3285 void Main::settingsUndoLevels()
3288 int i = QInputDialog::getInteger(
3290 tr("QInputDialog::getInteger()"),
3291 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3294 settings.setValue ("/mapeditor/stepsTotal",i);
3295 QMessageBox::information( this, tr( "VYM -Information:" ),
3296 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3300 void Main::settingsAutosaveToggle()
3302 settings.setValue ("/mapeditor/autosave/used",actionSettingsAutosaveToggle->isOn() );
3305 void Main::settingsAutosaveTime()
3308 int i = QInputDialog::getInteger(
3310 tr("QInputDialog::getInteger()"),
3311 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3314 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3318 void Main::settingsToggleDelKey()
3320 if (actionSettingsUseDelKey->isOn())
3322 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3325 actionEditDelete->setAccel (QKeySequence (""));
3329 void Main::windowToggleNoteEditor()
3331 if (textEditor->isVisible() )
3332 windowHideNoteEditor();
3334 windowShowNoteEditor();
3337 void Main::windowToggleHistory()
3339 if (historyWindow->isVisible())
3340 historyWindow->hide();
3342 historyWindow->show();
3346 void Main::windowToggleProperty()
3348 if (branchPropertyWindow->isVisible())
3349 branchPropertyWindow->hide();
3351 branchPropertyWindow->show();
3353 if(currentMapEditor())
3355 LinkableMapObj *sel=currentMapEditor()->getSelection();
3356 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3357 typeid(*sel) == typeid(MapCenterObj)))
3359 branchPropertyWindow->setMapEditor(currentMapEditor());
3360 branchPropertyWindow->setBranch((BranchObj*)sel);
3365 branchPropertyWindow->setBranch(NULL);
3368 void Main::windowToggleAntiAlias()
3370 bool b=actionViewToggleAntiAlias->isOn();
3372 for (int i=0;i<tabWidget->count();i++)
3375 me=(MapEditor*)tabWidget->page(i);
3376 me->setAntiAlias(b);
3381 void Main::windowToggleSmoothPixmap()
3383 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3385 for (int i=0;i<tabWidget->count();i++)
3388 me=(MapEditor*)tabWidget->page(i);
3389 me->setSmoothPixmap(b);
3393 void Main::updateHistory(SimpleSettings &undoSet)
3395 historyWindow->update (undoSet);
3398 void Main::updateNoteFlag()
3400 if (currentMapEditor())
3401 currentMapEditor()->updateNoteFlag();
3404 void Main::updateSatellites(MapEditor *me)
3406 branchPropertyWindow->setMapEditor (me);
3409 void Main::updateActions()
3411 MapEditor *me=currentMapEditor();
3414 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3416 // updateActions is also called when NoteEditor is closed
3417 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3418 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3419 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3421 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3422 actionFormatLinkColorHint->setOn(true);
3424 actionFormatLinkColorHint->setOn(false);
3426 switch (me->getMapLinkStyle())
3428 case LinkableMapObj::Line:
3429 actionFormatLinkStyleLine->setOn(true);
3431 case LinkableMapObj::Parabel:
3432 actionFormatLinkStyleParabel->setOn(true);
3434 case LinkableMapObj::PolyLine:
3435 actionFormatLinkStylePolyLine->setOn(true);
3437 case LinkableMapObj::PolyParabel:
3438 actionFormatLinkStylePolyParabel->setOn(true);
3445 QPixmap pix( 16, 16 );
3446 pix.fill( me->getMapBackgroundColor() );
3447 actionFormatBackColor->setIconSet( pix );
3448 pix.fill( me->getSelectionColor() );
3449 actionFormatSelectionColor->setIconSet( pix );
3450 pix.fill( me->getMapDefLinkColor() );
3451 actionFormatLinkColor->setIconSet( pix );
3454 actionFileSave->setEnabled( me->hasChanged() );
3455 if (me->isUndoAvailable())
3456 actionEditUndo->setEnabled( true);
3458 actionEditUndo->setEnabled( false);
3460 if (me->isRedoAvailable())
3461 actionEditRedo->setEnabled( true);
3463 actionEditRedo->setEnabled( false);
3465 LinkableMapObj *selection=me->getSelection();
3468 if ( (typeid(*selection) == typeid(BranchObj)) ||
3469 (typeid(*selection) == typeid(MapCenterObj)) )
3471 BranchObj *bo=(BranchObj*)selection;
3472 // Take care of links
3473 if (bo->countXLinks()==0)
3475 branchXLinksContextMenuEdit->clear();
3476 branchXLinksContextMenuFollow->clear();
3481 branchXLinksContextMenuEdit->clear();
3482 branchXLinksContextMenuFollow->clear();
3483 for (int i=0; i<=bo->countXLinks();i++)
3485 bot=bo->XLinkTargetAt(i);
3488 s=bot->getHeading();
3491 branchXLinksContextMenuFollow->addAction (s);
3492 branchXLinksContextMenuEdit->addAction (s);
3497 standardFlagsDefault->setEnabled (true);
3499 actionEditToggleScroll->setEnabled (true);
3500 if ( bo->isScrolled() )
3501 actionEditToggleScroll->setOn(true);
3503 actionEditToggleScroll->setOn(false);
3505 if ( bo->getURL().isEmpty() )
3507 actionEditOpenURL->setEnabled (false);
3508 actionEditOpenURLTab->setEnabled (false);
3512 actionEditOpenURL->setEnabled (true);
3513 actionEditOpenURLTab->setEnabled (true);
3515 if ( bo->getVymLink().isEmpty() )
3517 actionEditOpenVymLink->setEnabled (false);
3518 actionEditDeleteVymLink->setEnabled (false);
3521 actionEditOpenVymLink->setEnabled (true);
3522 actionEditDeleteVymLink->setEnabled (true);
3525 if (bo->canMoveBranchUp())
3526 actionEditMoveUp->setEnabled (true);
3528 actionEditMoveUp->setEnabled (false);
3529 if (bo->canMoveBranchDown())
3530 actionEditMoveDown->setEnabled (true);
3532 actionEditMoveDown->setEnabled (false);
3535 actionEditToggleHideExport->setEnabled (true);
3536 actionEditToggleHideExport->setOn (bo->hideInExport() );
3538 actionEditCopy->setEnabled (true);
3539 actionEditCut->setEnabled (true);
3540 if (!clipboardEmpty)
3541 actionEditPaste->setEnabled (true);
3543 actionEditPaste->setEnabled (false);
3544 for (int i=0; i<actionListBranches.size(); ++i)
3545 actionListBranches.at(i)->setEnabled(true);
3546 actionEditDelete->setEnabled (true);
3547 actionFormatHideLinkUnselected->setOn
3548 (selection->getHideLinkUnselected());
3550 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3552 FloatObj *fo=(FloatImageObj*)selection;
3554 actionEditOpenURL->setEnabled (false);
3555 actionEditOpenVymLink->setEnabled (false);
3556 actionEditDeleteVymLink->setEnabled (false);
3557 actionEditToggleHideExport->setEnabled (true);
3558 actionEditToggleHideExport->setOn (fo->hideInExport() );
3561 actionEditCopy->setEnabled (true);
3562 actionEditCut->setEnabled (true);
3563 actionEditPaste->setEnabled (false);
3564 for (int i=0; i<actionListBranches.size(); ++i)
3565 actionListBranches.at(i)->setEnabled(false);
3566 actionEditDelete->setEnabled (true);
3567 actionFormatHideLinkUnselected->setOn
3568 ( selection->getHideLinkUnselected());
3569 actionEditMoveUp->setEnabled (false);
3570 actionEditMoveDown->setEnabled (false);
3575 actionEditCopy->setEnabled (false);
3576 actionEditCut->setEnabled (false);
3577 actionEditPaste->setEnabled (false);
3578 for (int i=0; i<actionListBranches.size(); ++i)
3579 actionListBranches.at(i)->setEnabled(false);
3581 actionEditToggleScroll->setEnabled (false);
3582 actionEditOpenURL->setEnabled (false);
3583 actionEditOpenVymLink->setEnabled (false);
3584 actionEditDeleteVymLink->setEnabled (false);
3585 actionEditHeading2URL->setEnabled (false);
3586 actionEditDelete->setEnabled (false);
3587 actionEditMoveUp->setEnabled (false);
3588 actionEditMoveDown->setEnabled (false);
3589 actionEditToggleHideExport->setEnabled (false);
3593 Main::ModMode Main::getModMode()
3595 if (actionModModeColor->isOn()) return ModModeColor;
3596 if (actionModModeCopy->isOn()) return ModModeCopy;
3597 if (actionModModeXLink->isOn()) return ModModeXLink;
3601 bool Main::autoEdit()
3603 return actionSettingsAutoEdit->isOn();
3606 bool Main::autoSelectHeading()
3608 return actionSettingsAutoSelectHeading->isOn();
3611 bool Main::useFlagGroups()
3613 return actionSettingsUseFlagGroups->isOn();
3616 void Main::windowShowNoteEditor()
3618 textEditor->setShowWithMain(true);
3620 actionViewToggleNoteEditor->setOn (true);
3623 void Main::windowHideNoteEditor()
3625 textEditor->setShowWithMain(false);
3627 actionViewToggleNoteEditor->setOn (false);
3630 void Main::setScript (const QString &script)
3632 scriptEditor->setScript (script);
3635 void Main::runScript (const QString &script)
3637 if (currentMapEditor())
3638 currentMapEditor()->runScript (script);
3641 void Main::windowNextEditor()
3643 if (tabWidget->currentPageIndex() < tabWidget->count())
3644 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3647 void Main::windowPreviousEditor()
3649 if (tabWidget->currentPageIndex() >0)
3650 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3653 void Main::standardFlagChanged()
3655 if (currentMapEditor())
3656 currentMapEditor()->toggleStandardFlag(sender()->name());
3659 void Main::testFunction()
3661 if (!currentMapEditor()) return;
3662 currentMapEditor()->testFunction();
3665 void Main::testCommand()
3667 if (!currentMapEditor()) return;
3668 scriptEditor->show();
3671 QString com = QInputDialog::getText(
3672 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3673 if (ok) currentMapEditor()->parseAtom(com);
3677 void Main::helpDoc()
3679 QString locale = QLocale::system().name();
3681 if (locale.left(2)=="es")
3682 docname="vym_es.pdf";
3686 QStringList searchList;
3688 #if defined(Q_OS_MACX)
3689 searchList << "./vym.app/Contents";
3691 // default path in SUSE LINUX
3692 searchList <<"/usr/share/doc/packages/vym/doc";
3695 searchList << "doc"; // relative path for easy testing in tarball
3696 searchList << "doc/tex"; // Easy testing working on vym.tex
3697 searchList << "/usr/share/doc/vym"; // Debian
3698 searchList << "/usr/share/doc/packages";// Knoppix
3702 for (int i=0; i<searchList.count(); ++i)
3704 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3705 if (docfile.exists() )
3714 QMessageBox::critical(0,
3715 tr("Critcal error"),
3716 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3721 Process *pdfProc = new Process();
3722 args <<docfile.fileName();
3724 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3725 if ( !pdfProc->waitForStarted() )
3728 QMessageBox::warning(0,
3730 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3731 tr("Please use Settings->")+tr("Set application to open PDF files"));
3738 void Main::helpDemo()
3740 QStringList filters;
3741 filters <<"VYM example map (*.vym)";
3742 QFileDialog *fd=new QFileDialog( this);
3743 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3744 fd->setFileMode (QFileDialog::ExistingFiles);
3745 fd->setFilters (filters);
3746 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3750 if ( fd->exec() == QDialog::Accepted )
3752 lastFileDir=fd->directory().path();
3753 QStringList flist = fd->selectedFiles();
3754 QStringList::Iterator it = flist.begin();
3755 while( it != flist.end() )
3758 fileLoad(*it, NewMap);
3766 void Main::helpAbout()
3769 ad.setName ("aboutwindow");
3770 ad.setMinimumSize(500,500);
3771 ad.resize (QSize (500,500));
3775 void Main::helpAboutQT()
3777 QMessageBox::aboutQt( this, "Qt Application Example" );
3780 void Main::callMacro ()
3782 QAction *action = qobject_cast<QAction *>(sender());
3786 i=action->data().toInt();
3787 QString mDir (settings.value ("macros/macroDir").toString() );
3789 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3791 if ( !f.open( QIODevice::ReadOnly ) )
3793 QMessageBox::warning(0,
3795 tr("Couldn't find a macro at %1.\n").arg(fn)+
3796 tr("Please use Settings->")+tr("Set directory for vym macros"));
3800 QTextStream ts( &f );
3801 QString m= ts.read();
3805 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3806 currentMapEditor()->runScript (m);