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();
2344 if (me) me->exportImage();
2347 void Main::fileExportASCII()
2349 MapEditor *me=currentMapEditor();
2350 if (me) me->exportASCII();
2353 void Main::fileExportCSV()
2355 MapEditor *me=currentMapEditor();
2359 ex.setMapCenter(me->getMapCenter());
2360 ex.addFilter ("CSV (*.csv)");
2361 ex.setDir(lastImageDir);
2362 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2363 if (ex.execDialog() )
2365 me->setExportMode(true);
2367 me->setExportMode(false);
2372 void Main::fileExportLaTeX()
2374 MapEditor *me=currentMapEditor();
2378 ex.setMapCenter(me->getMapCenter());
2379 ex.addFilter ("Tex (*.tex)");
2380 ex.setDir(lastImageDir);
2381 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2382 if (ex.execDialog() )
2384 me->setExportMode(true);
2386 me->setExportMode(false);
2391 void Main::fileExportKDEBookmarks()
2393 ExportKDEBookmarks ex;
2394 MapEditor *me=currentMapEditor();
2397 ex.setMapCenter (me->getMapCenter() );
2402 void Main::fileExportTaskjuggler()
2404 ExportTaskjuggler ex;
2405 MapEditor *me=currentMapEditor();
2408 ex.setMapCenter (me->getMapCenter() );
2409 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2410 ex.setDir(lastImageDir);
2411 ex.addFilter ("Taskjuggler (*.tjp)");
2412 if (ex.execDialog() )
2414 me->setExportMode(true);
2416 me->setExportMode(false);
2421 void Main::fileExportOOPresentation()
2423 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2424 // TODO add preview in dialog
2425 //ImagePreview *p =new ImagePreview (fd);
2426 //fd->setContentsPreviewEnabled( TRUE );
2427 //fd->setContentsPreview( p, p );
2428 //fd->setPreviewMode( QFileDialog::Contents );
2429 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2430 fd->setDir (QDir().current());
2431 if (fd->foundConfig())
2435 if ( fd->exec() == QDialog::Accepted )
2437 QString fn=fd->selectedFile();
2438 if (!fn.contains (".odp"))
2441 //lastImageDir=fn.left(fn.findRev ("/"));
2442 if (currentMapEditor())
2443 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2447 QMessageBox::warning(0,
2449 tr("Couldn't find configuration for export to Open Office\n"));
2453 void Main::fileCloseMap()
2455 if (currentMapEditor())
2457 if (currentMapEditor()->hasChanged())
2459 QMessageBox mb( vymName,
2460 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2461 QMessageBox::Warning,
2462 QMessageBox::Yes | QMessageBox::Default,
2464 QMessageBox::Cancel | QMessageBox::Escape );
2465 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2466 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2469 case QMessageBox::Yes:
2471 fileSave(currentMapEditor(), CompleteMap);
2473 case QMessageBox::No:
2474 // close without saving
2476 case QMessageBox::Cancel:
2481 currentMapEditor()->closeMap();
2482 tabWidget->removePage(currentMapEditor());
2483 if (tabWidget->count()==0)
2484 actionFilePrint->setEnabled (false);
2488 void Main::filePrint()
2490 if (currentMapEditor())
2491 currentMapEditor()->print();
2494 void Main::fileExitVYM()
2496 // Check if one or more editors have changed
2499 for (i=0;i<=tabWidget->count() -1;i++)
2502 me=(MapEditor*)tabWidget->page(i);
2504 // If something changed, ask what to do
2505 if (me->hasChanged())
2507 tabWidget->setCurrentPage(i);
2508 QMessageBox mb( vymName,
2509 tr("This map is not saved yet. Do you want to"),
2510 QMessageBox::Warning,
2511 QMessageBox::Yes | QMessageBox::Default,
2513 QMessageBox::Cancel | QMessageBox::Escape );
2514 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2515 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2518 mb.setActiveWindow();
2519 switch( mb.exec() ) {
2520 case QMessageBox::Yes:
2521 // save (the changed editors) and exit
2522 fileSave(currentMapEditor(), CompleteMap);
2524 case QMessageBox::No:
2525 // exit without saving
2527 case QMessageBox::Cancel:
2528 // don't save and don't exit
2532 } // loop over all MEs
2536 void Main::editUndo()
2538 if (currentMapEditor())
2539 currentMapEditor()->undo();
2542 void Main::editRedo()
2544 if (currentMapEditor())
2545 currentMapEditor()->redo();
2548 void Main::gotoHistoryStep (int i)
2550 if (currentMapEditor())
2551 currentMapEditor()->gotoHistoryStep (i);
2554 void Main::editCopy()
2556 if (currentMapEditor())
2557 currentMapEditor()->copy();
2560 void Main::editPaste()
2562 if (currentMapEditor())
2563 currentMapEditor()->paste();
2566 void Main::editCut()
2568 if (currentMapEditor())
2569 currentMapEditor()->cut();
2572 void Main::editOpenFindWindow()
2574 findWindow->popup();
2575 findWindow->raise();
2576 findWindow->setActiveWindow();
2579 void Main::editFind(QString s)
2582 BranchObj *bo=currentMapEditor()->findText(s, cs);
2585 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2588 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2589 tr("No matches found for \"%1\"").arg(s));
2593 void Main::editFindChanged()
2594 { // Notify editor, to abort the current find process
2595 currentMapEditor()->findReset();
2598 void Main::openTabs(QStringList urls)
2600 if (!urls.isEmpty())
2604 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2606 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2608 QString u=urls.takeFirst();
2609 procBrowser = new QProcess( this );
2611 procBrowser->start(browser,args);
2612 if ( !procBrowser->waitForStarted())
2614 // try to set path to browser
2615 QMessageBox::warning(0,
2617 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2618 tr("Please use Settings->")+tr("Set application to open an URL"));
2623 if (browser.contains("konqueror"))
2625 for (int i=0; i<urls.size(); i++)
2628 // Try to open new tab in existing konqueror started previously by vym
2629 p=new QProcess (this);
2631 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2632 "konqueror-mainwindow#1"<<
2635 p->start ("dcop",args);
2636 if ( !p->waitForStarted() ) success=false;
2639 QMessageBox::warning(0,
2641 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2643 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2645 for (int i=0; i<urls.size(); i++)
2647 // Try to open new tab in firefox
2648 p=new QProcess (this);
2649 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2650 p->start (browser,args);
2651 if ( !p->waitForStarted() ) success=false;
2654 QMessageBox::warning(0,
2656 tr("Couldn't start %1 to open a new tab").arg(browser));
2659 QMessageBox::warning(0,
2661 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2665 void Main::editOpenURL()
2668 if (currentMapEditor())
2670 QString url=currentMapEditor()->getURL();
2672 if (url=="") return;
2673 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2674 procBrowser = new QProcess( this );
2676 procBrowser->start(browser,args);
2677 if ( !procBrowser->waitForStarted())
2679 // try to set path to browser
2680 QMessageBox::warning(0,
2682 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2683 tr("Please use Settings->")+tr("Set application to open an URL"));
2688 void Main::editOpenURLTab()
2690 if (currentMapEditor())
2693 urls.append(currentMapEditor()->getURL());
2697 void Main::editOpenMultipleURLTabs()
2699 if (currentMapEditor())
2702 urls=currentMapEditor()->getURLs();
2708 void Main::editURL()
2710 if (currentMapEditor())
2711 currentMapEditor()->editURL();
2714 void Main::editHeading2URL()
2716 if (currentMapEditor())
2717 currentMapEditor()->editHeading2URL();
2720 void Main::editBugzilla2URL()
2722 if (currentMapEditor())
2723 currentMapEditor()->editBugzilla2URL();
2726 void Main::editFATE2URL()
2728 if (currentMapEditor())
2729 currentMapEditor()->editFATE2URL();
2732 void Main::editHeadingFinished()
2734 // only called from editHeading(), so there is a currentME
2735 MapEditor *me=currentMapEditor();
2738 me->setStateEditHeading (false);
2739 QPoint p; //Not used here, only to find out pos of branch
2741 QString s=me->getHeading(ok,p);
2743 #if defined(Q_OS_MACX)
2745 if (ok && s!=lineedit->text())
2746 me->setHeading(lineedit->text());
2748 lineedit->releaseKeyboard();
2752 if (!prevSelection.isEmpty()) me->select(prevSelection);
2757 void Main::editHeading()
2759 if (currentMapEditor())
2761 MapEditor *me=currentMapEditor();
2762 QString oldSel=me->getSelectString();
2764 if (lineedit->isVisible())
2765 editHeadingFinished();
2770 QString s=currentMapEditor()->getHeading(ok,p);
2774 me->setStateEditHeading (true);
2775 #if defined(Q_OS_MACX)
2776 p=currentMapEditor()->mapTo (this,p);
2777 QDialog *d =new QDialog(NULL);
2778 QLineEdit *le=new QLineEdit (d);
2779 d->setWindowFlags (Qt::FramelessWindowHint);
2780 d->setGeometry(p.x(),p.y(),230,25);
2781 le->resize (d->width()-10,d->height());
2784 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2785 d->activateWindow();
2787 currentMapEditor()->setHeading (le->text());
2790 editHeadingFinished();
2792 p=currentMapEditor()->mapTo (this,p);
2793 lineedit->setGeometry(p.x(),p.y(),230,25);
2794 lineedit->setText(s);
2795 lineedit->setCursorPosition(1);
2796 lineedit->selectAll();
2798 lineedit->grabKeyboard();
2799 lineedit->setFocus();
2803 } // currentMapEditor()
2806 void Main::openVymLinks(const QStringList &vl)
2808 for (int j=0; j<vl.size(); j++)
2810 // compare path with already loaded maps
2814 for (i=0;i<=tabWidget->count() -1;i++)
2816 me=(MapEditor*)tabWidget->page(i);
2817 if (vl.at(j)==me->getFilePath() )
2826 if (!QFile(vl.at(j)).exists() )
2827 QMessageBox::critical( 0, tr( "Critical Error" ),
2828 tr("Couldn't open map %1").arg(vl.at(j)));
2831 fileLoad (vl.at(j), NewMap);
2832 tabWidget->setCurrentPage (tabWidget->count()-1);
2835 // Go to tab containing the map
2836 tabWidget->setCurrentPage (index);
2840 void Main::editOpenVymLink()
2842 if (currentMapEditor())
2845 vl.append(currentMapEditor()->getVymLink());
2850 void Main::editOpenMultipleVymLinks()
2852 QString currentVymLink;
2853 if (currentMapEditor())
2855 QStringList vl=currentMapEditor()->getVymLinks();
2860 void Main::editVymLink()
2862 if (currentMapEditor())
2863 currentMapEditor()->editVymLink();
2866 void Main::editDeleteVymLink()
2868 if (currentMapEditor())
2869 currentMapEditor()->deleteVymLink();
2872 void Main::editToggleHideExport()
2874 if (currentMapEditor())
2875 currentMapEditor()->toggleHideExport();
2878 void Main::editMapInfo()
2880 if (currentMapEditor())
2881 currentMapEditor()->editMapInfo();
2884 void Main::editMoveUp()
2886 if (currentMapEditor())
2887 currentMapEditor()->moveBranchUp();
2890 void Main::editMoveDown()
2892 if (currentMapEditor())
2893 currentMapEditor()->moveBranchDown();
2896 void Main::editToggleScroll()
2898 if (currentMapEditor())
2900 currentMapEditor()->toggleScroll();
2904 void Main::editUnscrollChilds()
2906 if (currentMapEditor())
2907 currentMapEditor()->unscrollChilds();
2910 void Main::editNewBranch()
2912 MapEditor *me=currentMapEditor();
2913 if (!lineedit->isVisible() && me)
2915 BranchObj *bo=(BranchObj*)me->getSelection();
2916 BranchObj *newbo=me->addNewBranch(0);
2919 me->select (newbo->getSelectString());
2923 if (actionSettingsAutoEdit->isOn())
2925 if (!actionSettingsAutoSelectHeading->isOn())
2926 prevSelection=bo->getSelectString();
2932 void Main::editNewBranchBefore()
2934 MapEditor *me=currentMapEditor();
2935 if (!lineedit->isVisible() && me)
2937 BranchObj *bo=(BranchObj*)me->getSelection();
2938 BranchObj *newbo=me->addNewBranchBefore();
2941 me->select (newbo->getSelectString());
2945 if (actionSettingsAutoEdit->isOn())
2947 if (!actionSettingsAutoSelectHeading->isOn())
2948 prevSelection=bo->getSelectString();
2954 void Main::editNewBranchAbove()
2956 MapEditor *me=currentMapEditor();
2957 if (!lineedit->isVisible() && me)
2959 BranchObj *bo=(BranchObj*)me->getSelection();
2960 BranchObj *newbo=me->addNewBranch (-1);
2963 me->select (newbo->getSelectString());
2967 if (actionSettingsAutoEdit->isOn())
2969 if (!actionSettingsAutoSelectHeading->isOn())
2970 prevSelection=bo->getSelectString();
2976 void Main::editNewBranchBelow()
2978 MapEditor *me=currentMapEditor();
2979 if (!lineedit->isVisible() && me)
2981 BranchObj *bo=(BranchObj*)me->getSelection();
2982 BranchObj *newbo=me->addNewBranch (1);
2985 me->select (newbo->getSelectString());
2989 if (actionSettingsAutoEdit->isOn())
2991 if (!actionSettingsAutoSelectHeading->isOn())
2992 prevSelection=bo->getSelectString();
2998 void Main::editImportAdd()
3000 fileLoad (ImportAdd);
3003 void Main::editImportReplace()
3005 fileLoad (ImportReplace);
3008 void Main::editSaveBranch()
3010 fileSaveAs (PartOfMap);
3013 void Main::editDeleteKeepChilds()
3015 if (currentMapEditor())
3016 currentMapEditor()->deleteKeepChilds();
3019 void Main::editDeleteChilds()
3021 if (currentMapEditor())
3022 currentMapEditor()->deleteChilds();
3025 void Main::editDeleteSelection()
3027 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
3028 currentMapEditor()->deleteSelection();
3031 void Main::editUpperBranch()
3033 if (currentMapEditor())
3034 currentMapEditor()->selectUpperBranch();
3037 void Main::editLowerBranch()
3039 if (currentMapEditor())
3040 currentMapEditor()->selectLowerBranch();
3043 void Main::editLeftBranch()
3045 if (currentMapEditor())
3046 currentMapEditor()->selectLeftBranch();
3049 void Main::editRightBranch()
3051 if (currentMapEditor())
3052 currentMapEditor()->selectRightBranch();
3055 void Main::editFirstBranch()
3057 if (currentMapEditor())
3058 currentMapEditor()->selectFirstBranch();
3061 void Main::editLastBranch()
3063 if (currentMapEditor())
3064 currentMapEditor()->selectLastBranch();
3067 void Main::editLoadImage()
3069 if (currentMapEditor())
3070 currentMapEditor()->loadFloatImage();
3073 void Main::editSaveImage()
3075 if (currentMapEditor())
3076 currentMapEditor()->saveFloatImage();
3079 void Main::editFollowXLink(QAction *a)
3082 if (currentMapEditor())
3083 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3086 void Main::editEditXLink(QAction *a)
3088 if (currentMapEditor())
3089 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3092 void Main::formatSelectColor()
3094 if (currentMapEditor())
3096 QColor col = QColorDialog::getColor((currentColor ), this );
3097 if ( !col.isValid() ) return;
3098 colorChanged( col );
3102 void Main::formatPickColor()
3104 if (currentMapEditor())
3105 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3108 void Main::colorChanged(QColor c)
3110 QPixmap pix( 16, 16 );
3112 actionFormatColor->setIconSet( pix );
3116 void Main::formatColorBranch()
3118 if (currentMapEditor())
3119 currentMapEditor()->colorBranch(currentColor);
3122 void Main::formatColorSubtree()
3124 if (currentMapEditor())
3125 currentMapEditor()->colorSubtree (currentColor);
3128 void Main::formatLinkStyleLine()
3130 if (currentMapEditor())
3131 currentMapEditor()->setMapLinkStyle("StyleLine");
3134 void Main::formatLinkStyleParabel()
3136 if (currentMapEditor())
3137 currentMapEditor()->setMapLinkStyle("StyleParabel");
3140 void Main::formatLinkStylePolyLine()
3142 if (currentMapEditor())
3143 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3146 void Main::formatLinkStylePolyParabel()
3148 if (currentMapEditor())
3149 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3152 void Main::formatSelectBackColor()
3154 if (currentMapEditor())
3155 currentMapEditor()->selectMapBackgroundColor();
3158 void Main::formatSelectBackImage()
3160 if (currentMapEditor())
3161 currentMapEditor()->selectMapBackgroundImage();
3164 void Main::formatSelectLinkColor()
3166 if (currentMapEditor())
3167 currentMapEditor()->selectMapLinkColor();
3170 void Main::formatSelectSelectionColor()
3172 if (currentMapEditor())
3173 currentMapEditor()->selectMapSelectionColor();
3176 void Main::formatToggleLinkColorHint()
3178 currentMapEditor()->toggleMapLinkColorHint();
3182 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3184 if (currentMapEditor())
3185 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3188 void Main::viewZoomReset()
3190 if (currentMapEditor())
3194 currentMapEditor()->setMatrix( m );
3198 void Main::viewZoomIn()
3200 if (currentMapEditor())
3202 QMatrix m = currentMapEditor()->matrix();
3203 m.scale( 1.25, 1.25 );
3204 currentMapEditor()->setMatrix( m );
3208 void Main::viewZoomOut()
3210 if (currentMapEditor())
3212 QMatrix m = currentMapEditor()->matrix();
3213 m.scale( 0.8, 0.8 );
3214 currentMapEditor()->setMatrix( m );
3218 bool Main::settingsPDF()
3220 // Default browser is set in constructor
3222 QString text = QInputDialog::getText(
3223 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3224 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3226 settings.setValue ("/mainwindow/readerPDF",text);
3231 bool Main::settingsURL()
3233 // Default browser is set in constructor
3235 QString text = QInputDialog::getText(
3236 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3237 settings.value("/mainwindow/readerURL").toString()
3240 settings.setValue ("/mainwindow/readerURL",text);
3244 void Main::settingsMacroDir()
3246 QDir defdir=vymBaseDir;
3247 defdir.cd("macros");
3248 if (!defdir.exists())
3250 QDir dir=QFileDialog::getExistingDirectory (
3252 tr ("Directory with vym macros:"),
3253 settings.value ("/macros/macroDir",defdir.path()).toString()
3256 settings.setValue ("/macros/macroDir",dir.path());
3259 void Main::settingsUndoLevels()
3262 int i = QInputDialog::getInteger(
3264 tr("QInputDialog::getInteger()"),
3265 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3268 settings.setValue ("/mapeditor/stepsTotal",i);
3269 QMessageBox::information( this, tr( "VYM -Information:" ),
3270 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3274 void Main::settingsAutosaveToggle()
3276 settings.setValue ("/mapeditor/autosave/used",actionSettingsAutosaveToggle->isOn() );
3279 void Main::settingsAutosaveTime()
3282 int i = QInputDialog::getInteger(
3284 tr("QInputDialog::getInteger()"),
3285 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3288 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3292 void Main::settingsToggleDelKey()
3294 if (actionSettingsUseDelKey->isOn())
3296 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3299 actionEditDelete->setAccel (QKeySequence (""));
3303 void Main::windowToggleNoteEditor()
3305 if (textEditor->isVisible() )
3306 windowHideNoteEditor();
3308 windowShowNoteEditor();
3311 void Main::windowToggleHistory()
3313 if (historyWindow->isVisible())
3314 historyWindow->hide();
3316 historyWindow->show();
3320 void Main::windowToggleProperty()
3322 if (branchPropertyWindow->isVisible())
3323 branchPropertyWindow->hide();
3325 branchPropertyWindow->show();
3327 if(currentMapEditor())
3329 LinkableMapObj *sel=currentMapEditor()->getSelection();
3330 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3331 typeid(*sel) == typeid(MapCenterObj)))
3333 branchPropertyWindow->setMapEditor(currentMapEditor());
3334 branchPropertyWindow->setBranch((BranchObj*)sel);
3339 branchPropertyWindow->setBranch(NULL);
3342 void Main::windowToggleAntiAlias()
3344 bool b=actionViewToggleAntiAlias->isOn();
3346 for (int i=0;i<tabWidget->count();i++)
3349 me=(MapEditor*)tabWidget->page(i);
3350 me->setAntiAlias(b);
3355 void Main::windowToggleSmoothPixmap()
3357 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3359 for (int i=0;i<tabWidget->count();i++)
3362 me=(MapEditor*)tabWidget->page(i);
3363 me->setSmoothPixmap(b);
3367 void Main::updateHistory(SimpleSettings &undoSet)
3369 historyWindow->update (undoSet);
3372 void Main::updateNoteFlag()
3374 if (currentMapEditor())
3375 currentMapEditor()->updateNoteFlag();
3378 void Main::updateSatellites(MapEditor *me)
3380 branchPropertyWindow->setMapEditor (me);
3383 void Main::updateActions()
3385 MapEditor *me=currentMapEditor();
3388 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3390 // updateActions is also called when NoteEditor is closed
3391 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3392 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3393 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3395 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3396 actionFormatLinkColorHint->setOn(true);
3398 actionFormatLinkColorHint->setOn(false);
3400 switch (me->getMapLinkStyle())
3402 case LinkableMapObj::Line:
3403 actionFormatLinkStyleLine->setOn(true);
3405 case LinkableMapObj::Parabel:
3406 actionFormatLinkStyleParabel->setOn(true);
3408 case LinkableMapObj::PolyLine:
3409 actionFormatLinkStylePolyLine->setOn(true);
3411 case LinkableMapObj::PolyParabel:
3412 actionFormatLinkStylePolyParabel->setOn(true);
3419 QPixmap pix( 16, 16 );
3420 pix.fill( me->getMapBackgroundColor() );
3421 actionFormatBackColor->setIconSet( pix );
3422 pix.fill( me->getSelectionColor() );
3423 actionFormatSelectionColor->setIconSet( pix );
3424 pix.fill( me->getMapDefLinkColor() );
3425 actionFormatLinkColor->setIconSet( pix );
3428 actionFileSave->setEnabled( me->hasChanged() );
3429 if (me->isUndoAvailable())
3430 actionEditUndo->setEnabled( true);
3432 actionEditUndo->setEnabled( false);
3434 if (me->isRedoAvailable())
3435 actionEditRedo->setEnabled( true);
3437 actionEditRedo->setEnabled( false);
3439 LinkableMapObj *selection=me->getSelection();
3442 if ( (typeid(*selection) == typeid(BranchObj)) ||
3443 (typeid(*selection) == typeid(MapCenterObj)) )
3445 BranchObj *bo=(BranchObj*)selection;
3446 // Take care of links
3447 if (bo->countXLinks()==0)
3449 branchXLinksContextMenuEdit->clear();
3450 branchXLinksContextMenuFollow->clear();
3455 branchXLinksContextMenuEdit->clear();
3456 branchXLinksContextMenuFollow->clear();
3457 for (int i=0; i<=bo->countXLinks();i++)
3459 bot=bo->XLinkTargetAt(i);
3462 s=bot->getHeading();
3465 branchXLinksContextMenuFollow->addAction (s);
3466 branchXLinksContextMenuEdit->addAction (s);
3471 standardFlagsDefault->setEnabled (true);
3473 actionEditToggleScroll->setEnabled (true);
3474 if ( bo->isScrolled() )
3475 actionEditToggleScroll->setOn(true);
3477 actionEditToggleScroll->setOn(false);
3479 if ( bo->getURL().isEmpty() )
3481 actionEditOpenURL->setEnabled (false);
3482 actionEditOpenURLTab->setEnabled (false);
3486 actionEditOpenURL->setEnabled (true);
3487 actionEditOpenURLTab->setEnabled (true);
3489 if ( bo->getVymLink().isEmpty() )
3491 actionEditOpenVymLink->setEnabled (false);
3492 actionEditDeleteVymLink->setEnabled (false);
3495 actionEditOpenVymLink->setEnabled (true);
3496 actionEditDeleteVymLink->setEnabled (true);
3499 if (bo->canMoveBranchUp())
3500 actionEditMoveUp->setEnabled (true);
3502 actionEditMoveUp->setEnabled (false);
3503 if (bo->canMoveBranchDown())
3504 actionEditMoveDown->setEnabled (true);
3506 actionEditMoveDown->setEnabled (false);
3509 actionEditToggleHideExport->setEnabled (true);
3510 actionEditToggleHideExport->setOn (bo->hideInExport() );
3512 actionEditCopy->setEnabled (true);
3513 actionEditCut->setEnabled (true);
3514 if (!clipboardEmpty)
3515 actionEditPaste->setEnabled (true);
3517 actionEditPaste->setEnabled (false);
3518 for (int i=0; i<actionListBranches.size(); ++i)
3519 actionListBranches.at(i)->setEnabled(true);
3520 actionEditDelete->setEnabled (true);
3521 actionFormatHideLinkUnselected->setOn
3522 (selection->getHideLinkUnselected());
3524 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3526 FloatObj *fo=(FloatImageObj*)selection;
3528 actionEditOpenURL->setEnabled (false);
3529 actionEditOpenVymLink->setEnabled (false);
3530 actionEditDeleteVymLink->setEnabled (false);
3531 actionEditToggleHideExport->setEnabled (true);
3532 actionEditToggleHideExport->setOn (fo->hideInExport() );
3535 actionEditCopy->setEnabled (true);
3536 actionEditCut->setEnabled (true);
3537 actionEditPaste->setEnabled (false);
3538 for (int i=0; i<actionListBranches.size(); ++i)
3539 actionListBranches.at(i)->setEnabled(false);
3540 actionEditDelete->setEnabled (true);
3541 actionFormatHideLinkUnselected->setOn
3542 ( selection->getHideLinkUnselected());
3543 actionEditMoveUp->setEnabled (false);
3544 actionEditMoveDown->setEnabled (false);
3549 actionEditCopy->setEnabled (false);
3550 actionEditCut->setEnabled (false);
3551 actionEditPaste->setEnabled (false);
3552 for (int i=0; i<actionListBranches.size(); ++i)
3553 actionListBranches.at(i)->setEnabled(false);
3555 actionEditToggleScroll->setEnabled (false);
3556 actionEditOpenURL->setEnabled (false);
3557 actionEditOpenVymLink->setEnabled (false);
3558 actionEditDeleteVymLink->setEnabled (false);
3559 actionEditHeading2URL->setEnabled (false);
3560 actionEditDelete->setEnabled (false);
3561 actionEditMoveUp->setEnabled (false);
3562 actionEditMoveDown->setEnabled (false);
3563 actionEditToggleHideExport->setEnabled (false);
3567 Main::ModMode Main::getModMode()
3569 if (actionModModeColor->isOn()) return ModModeColor;
3570 if (actionModModeCopy->isOn()) return ModModeCopy;
3571 if (actionModModeXLink->isOn()) return ModModeXLink;
3575 bool Main::autoEdit()
3577 return actionSettingsAutoEdit->isOn();
3580 bool Main::autoSelectHeading()
3582 return actionSettingsAutoSelectHeading->isOn();
3585 bool Main::useFlagGroups()
3587 return actionSettingsUseFlagGroups->isOn();
3590 void Main::windowShowNoteEditor()
3592 textEditor->setShowWithMain(true);
3594 actionViewToggleNoteEditor->setOn (true);
3597 void Main::windowHideNoteEditor()
3599 textEditor->setShowWithMain(false);
3601 actionViewToggleNoteEditor->setOn (false);
3604 void Main::setScript (const QString &script)
3606 scriptEditor->setScript (script);
3609 void Main::runScript (const QString &script)
3611 if (currentMapEditor())
3612 currentMapEditor()->runScript (script);
3615 void Main::runScriptEverywhere (const QString &script)
3618 for (int i=0;i<=tabWidget->count() -1;i++)
3620 me=(MapEditor*)tabWidget->page(i);
3621 if (me) me->runScript (script);
3625 void Main::windowNextEditor()
3627 if (tabWidget->currentPageIndex() < tabWidget->count())
3628 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3631 void Main::windowPreviousEditor()
3633 if (tabWidget->currentPageIndex() >0)
3634 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3637 void Main::standardFlagChanged()
3639 if (currentMapEditor())
3640 currentMapEditor()->toggleStandardFlag(sender()->name());
3643 void Main::testFunction()
3645 if (!currentMapEditor()) return;
3646 currentMapEditor()->testFunction();
3649 void Main::testCommand()
3651 if (!currentMapEditor()) return;
3652 scriptEditor->show();
3655 QString com = QInputDialog::getText(
3656 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3657 if (ok) currentMapEditor()->parseAtom(com);
3661 void Main::helpDoc()
3663 QString locale = QLocale::system().name();
3665 if (locale.left(2)=="es")
3666 docname="vym_es.pdf";
3670 QStringList searchList;
3672 #if defined(Q_OS_MACX)
3673 searchList << "./vym.app/Contents";
3675 // default path in SUSE LINUX
3676 searchList <<"/usr/share/doc/packages/vym/doc";
3679 searchList << "doc"; // relative path for easy testing in tarball
3680 searchList << "doc/tex"; // Easy testing working on vym.tex
3681 searchList << "/usr/share/doc/vym"; // Debian
3682 searchList << "/usr/share/doc/packages";// Knoppix
3686 for (int i=0; i<searchList.count(); ++i)
3688 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3689 if (docfile.exists() )
3698 QMessageBox::critical(0,
3699 tr("Critcal error"),
3700 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3705 Process *pdfProc = new Process();
3706 args <<docfile.fileName();
3708 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3709 if ( !pdfProc->waitForStarted() )
3712 QMessageBox::warning(0,
3714 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3715 tr("Please use Settings->")+tr("Set application to open PDF files"));
3722 void Main::helpDemo()
3724 QStringList filters;
3725 filters <<"VYM example map (*.vym)";
3726 QFileDialog *fd=new QFileDialog( this);
3727 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3728 fd->setFileMode (QFileDialog::ExistingFiles);
3729 fd->setFilters (filters);
3730 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3734 if ( fd->exec() == QDialog::Accepted )
3736 lastFileDir=fd->directory().path();
3737 QStringList flist = fd->selectedFiles();
3738 QStringList::Iterator it = flist.begin();
3739 while( it != flist.end() )
3742 fileLoad(*it, NewMap);
3750 void Main::helpAbout()
3753 ad.setName ("aboutwindow");
3754 ad.setMinimumSize(500,500);
3755 ad.resize (QSize (500,500));
3759 void Main::helpAboutQT()
3761 QMessageBox::aboutQt( this, "Qt Application Example" );
3764 void Main::callMacro ()
3766 QAction *action = qobject_cast<QAction *>(sender());
3770 i=action->data().toInt();
3771 QString mDir (settings.value ("macros/macroDir").toString() );
3773 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3775 if ( !f.open( QIODevice::ReadOnly ) )
3777 QMessageBox::warning(0,
3779 tr("Couldn't find a macro at %1.\n").arg(fn)+
3780 tr("Please use Settings->")+tr("Set directory for vym macros"));
3784 QTextStream ts( &f );
3785 QString m= ts.read();
3789 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3790 currentMapEditor()->runScript (m);