1 #include "mainwindow.h"
7 #include "aboutdialog.h"
8 #include "branchpropwindow.h"
9 #include "exportoofiledialog.h"
12 #include "flagrowobj.h"
13 #include "historywindow.h"
15 #include "mapeditor.h"
20 #include "texteditor.h"
21 #include "warningdialog.h"
23 extern TextEditor *textEditor;
24 extern Main *mainWindow;
25 extern QString tmpVymDir;
26 extern QString clipboardDir;
27 extern QString clipboardFile;
28 extern bool clipboardEmpty;
29 extern int statusbarTime;
30 extern FlagRowObj* standardFlagsDefault;
31 extern FlagRowObj* systemFlagsDefault;
32 extern QString vymName;
33 extern QString vymVersion;
34 extern QString vymBuildDate;
37 QMenu* branchContextMenu;
38 QMenu* branchAddContextMenu;
39 QMenu* branchRemoveContextMenu;
40 QMenu* branchLinksContextMenu;
41 QMenu* branchXLinksContextMenuEdit;
42 QMenu* branchXLinksContextMenuFollow;
43 QMenu* floatimageContextMenu;
44 QMenu* canvasContextMenu;
45 QMenu* fileLastMapsMenu;
46 QMenu* fileImportMenu;
47 QMenu* fileExportMenu;
50 extern Settings settings;
51 extern Options options;
52 extern ImageIO imageIO;
54 extern QDir vymBaseDir;
55 extern QDir lastImageDir;
56 extern QDir lastFileDir;
57 extern QString iconPath;
58 extern QString flagsPath;
60 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
61 QMainWindow(parent,name,f)
65 setCaption ("VYM - View Your Mind");
67 // Load window settings
68 resize (settings.value( "/mainwindow/geometry/size",QSize (800,600)).toSize());
69 move (settings.value( "/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
72 // Sometimes we may need to remember old selections
76 currentColor=Qt::black;
78 // Create unique temporary directory
80 tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
83 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
86 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
88 // Create direcctory for clipboard
89 clipboardDir=tmpVymDir+"/clipboard";
90 clipboardFile="map.xml";
92 d.mkdir (clipboardDir,true);
93 makeSubDirs (clipboardDir);
98 // Satellite windows //////////////////////////////////////////
101 historyWindow=new HistoryWindow();
102 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
105 branchPropertyWindow = new BranchPropertyWindow();
106 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
108 // Connect TextEditor, so that we can update flags if text changes
109 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
110 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
112 // Connect HistoryWindow, so that we can update flags
113 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
116 // Initialize script editor
117 scriptEditor = new SimpleScriptEditor();
118 scriptEditor->move (50,50);
120 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
121 this, SLOT( runScript( QString ) ) );
124 // Initialize Find window
125 findWindow=new FindWindow(NULL);
126 findWindow->move (x(),y()+70);
127 connect (findWindow, SIGNAL( findButton(QString) ),
128 this, SLOT(editFind(QString) ) );
129 connect (findWindow, SIGNAL( somethingChanged() ),
130 this, SLOT(editFindChanged() ) );
132 // Initialize some settings, which are platform dependant
135 // application to open URLs
136 p="/mainwindow/readerURL";
137 #if defined(Q_OS_LINUX)
138 s=settings.value (p,"konqueror").toString();
140 #if defined(Q_OS_MACX)
141 s=settings.value (p,"/usr/bin/open").toString();
143 s=settings.value (p,"mozilla");
146 settings.setValue( p,s);
148 // application to open PDFs
149 p="/mainwindow/readerPDF";
150 #if defined(Q_OS_LINUX)
151 s=settings.value (p,"acroread").toString();
153 #if defined(Q_OS_MACX)
154 s=settings.value (p,"/usr/bin/open").toString();
156 s=settings.value (p,"acroread").toString();
159 settings.setValue( p,s);
162 // Create tab widget which holds the maps
163 tabWidget= new QTabWidget (this);
164 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
165 this, SLOT( editorChanged( QWidget * ) ) );
167 lineedit=new QLineEdit (this);
170 setCentralWidget(tabWidget);
174 setupFormatActions();
178 setupNetworkActions();
179 setupSettingsActions();
182 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
187 restoreState (settings.value("/mainwindow/state",0).toByteArray());
195 settings.setValue ( "/mainwindow/geometry/size", size() );
196 settings.setValue ( "/mainwindow/geometry/pos", pos() );
197 settings.setValue ("/mainwindow/state",saveState(0));
199 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
200 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
201 settings.setValue( "/version/version", vymVersion );
202 settings.setValue( "/version/builddate", vymBuildDate );
204 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
205 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
206 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
207 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
208 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
209 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
210 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
212 //TODO save scriptEditor settings
214 // call the destructors
216 delete historyWindow;
217 delete branchPropertyWindow;
219 // Remove temporary directory
220 removeDir (QDir(tmpVymDir));
223 void Main::loadCmdLine()
225 /* TODO draw some kind of splashscreen while loading...
231 QStringList flist=options.getFileList();
232 QStringList::Iterator it=flist.begin();
234 while (it !=flist.end() )
236 fileLoad (*it, NewMap);
242 void Main::statusMessage(const QString &s)
244 statusBar()->message( s);
247 void Main::closeEvent (QCloseEvent* )
253 void Main::setupFileActions()
255 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
256 QToolBar *tb = addToolBar( tr ("&Map") );
257 tb->setObjectName ("mapTB");
260 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
261 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
262 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
264 fileMenu->addAction (a);
265 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
267 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
268 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
269 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
270 fileMenu->addAction (a);
271 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
273 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
274 a->setStatusTip (tr( "Open","Status tip File menu" ) );
275 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
277 fileMenu->addAction (a);
278 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
280 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
281 fileMenu->addSeparator();
283 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
284 a->setStatusTip ( tr( "Save","Status tip file menu" ));
285 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
287 fileMenu->addAction (a);
288 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
291 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
292 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
293 fileMenu->addAction (a);
294 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
296 fileMenu->addSeparator();
298 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
300 a = new QAction(tr("KDE Bookmarks"), this);
301 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
302 a->addTo (fileImportMenu);
303 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
305 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
307 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
308 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
309 a->addTo (fileImportMenu);
310 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
313 a = new QAction("Freemind...",this);
314 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
315 fileImportMenu->addAction (a);
316 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
318 a = new QAction("Mind Manager...",this);
319 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
320 fileImportMenu->addAction (a);
321 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
323 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
324 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
325 fileImportMenu->addAction (a);
326 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
328 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
330 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
331 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
332 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
333 fileExportMenu->addAction (a);
335 a = new QAction( "Open Office...", this);
336 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
337 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
338 fileExportMenu->addAction (a);
340 a = new QAction( "Webpage (XHTML)...",this );
341 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
342 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
343 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
344 fileExportMenu->addAction (a);
346 a = new QAction( "Text (ASCII)...", this);
347 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
349 fileExportMenu->addAction (a);
351 a = new QAction( "Spreadsheet (CSV)...", this);
352 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
353 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
354 fileExportMenu->addAction (a);
356 a = new QAction( tr("KDE Bookmarks","File menu"), this);
357 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
358 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
359 fileExportMenu->addAction (a);
361 a = new QAction( "Taskjuggler...", this );
362 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
363 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
364 fileExportMenu->addAction (a);
366 a = new QAction( "LaTeX...", this);
367 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
368 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
369 fileExportMenu->addAction (a);
371 a = new QAction( "XML..." , this );
372 a->setStatusTip (tr( "Export as %1").arg("XML"));
373 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
374 fileExportMenu->addAction (a);
376 fileMenu->addSeparator();
378 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
379 a->setStatusTip ( tr( "Print" ,"File menu") );
380 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
382 fileMenu->addAction (a);
383 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
386 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
387 a->setStatusTip (tr( "Close Map" ) );
388 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
389 fileMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
392 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
393 a->setStatusTip ( tr( "Exit")+" "+vymName );
394 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
395 fileMenu->addAction (a);
396 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
401 void Main::setupEditActions()
403 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
404 tb->setLabel( "Edit Actions" );
405 tb->setObjectName ("actionsTB");
406 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
410 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
411 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
412 a->setStatusTip (tr( "Undo" ) );
413 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
414 a->setEnabled (false);
416 editMenu->addAction (a);
419 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
420 a->setStatusTip (tr( "Redo" ));
421 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
423 editMenu->addAction (a);
424 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
427 editMenu->addSeparator();
428 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
429 a->setStatusTip ( tr( "Copy" ) );
430 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
431 a->setEnabled (false);
433 editMenu->addAction (a);
434 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
437 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
438 a->setStatusTip ( tr( "Cut" ) );
439 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
440 a->setEnabled (false);
442 editMenu->addAction (a);
444 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
446 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
447 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
448 a->setStatusTip ( tr( "Paste" ) );
449 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
450 a->setEnabled (false);
452 editMenu->addAction (a);
455 // Shortcuts to modify heading:
456 a = new QAction(tr( "Edit heading","Edit menu" ),this);
457 a->setStatusTip ( tr( "edit Heading" ));
458 a->setShortcut ( Qt::Key_Enter); //Edit heading
459 // a->setShortcutContext (Qt::WindowShortcut);
461 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
462 actionListBranches.append(a);
463 a = new QAction( tr( "Edit heading","Edit menu" ), this);
464 a->setStatusTip (tr( "edit Heading" ));
465 a->setShortcut (Qt::Key_Return ); //Edit heading
466 //a->setShortcutContext (Qt::WindowShortcut);
468 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
469 actionListBranches.append(a);
470 editMenu->addAction (a);
472 a = new QAction( tr( "Edit heading","Edit menu" ), this);
473 a->setStatusTip (tr( "edit Heading" ));
474 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
475 a->setShortcutContext (Qt::WindowShortcut);
477 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
478 actionListBranches.append(a);
480 // Shortcut to delete selection
481 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
482 a->setStatusTip (tr( "Delete Selection" ));
483 a->setShortcut ( Qt::Key_Delete); //Delete selection
484 a->setShortcutContext (Qt::WindowShortcut);
486 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
489 // Shortcut to add branch
490 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
491 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
492 alt->setShortcut (Qt::Key_A); //Add branch
493 alt->setShortcutContext (Qt::WindowShortcut);
495 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
496 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
497 a->setStatusTip ( tr( "Add a branch as child of selection" ));
498 a->setShortcut (Qt::Key_Insert); //Add branch
499 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
500 actionListBranches.append(a);
501 #if defined (Q_OS_MACX)
502 // In OSX show different shortcut in menues, the keys work indepently always
503 actionEditAddBranch=alt;
505 actionEditAddBranch=a;
507 editMenu->addAction (actionEditAddBranch);
508 tb->addAction (actionEditAddBranch);
511 // Add branch by inserting it at selection
512 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
513 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
514 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
515 a->setShortcutContext (Qt::WindowShortcut);
517 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
518 a->setEnabled (false);
519 actionListBranches.append(a);
520 actionEditAddBranchBefore=a;
521 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
522 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
523 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
524 a->setShortcutContext (Qt::WindowShortcut);
526 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
527 actionListBranches.append(a);
530 a = new QAction(tr( "Add branch above","Edit menu" ), this);
531 a->setStatusTip ( tr( "Add a branch above selection" ));
532 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
533 a->setShortcutContext (Qt::WindowShortcut);
535 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
536 a->setEnabled (false);
537 actionListBranches.append(a);
538 actionEditAddBranchAbove=a;
539 a = new QAction(tr( "Add branch above","Edit menu" ), this);
540 a->setStatusTip ( tr( "Add a branch above selection" ));
541 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
542 a->setShortcutContext (Qt::WindowShortcut);
544 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
545 actionListBranches.append(a);
548 a = new QAction(tr( "Add branch below","Edit menu" ), this);
549 a->setStatusTip ( tr( "Add a branch below selection" ));
550 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
551 a->setShortcutContext (Qt::WindowShortcut);
553 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
554 a->setEnabled (false);
555 actionListBranches.append(a);
556 actionEditAddBranchBelow=a;
557 a = new QAction(tr( "Add branch below","Edit menu" ), this);
558 a->setStatusTip ( tr( "Add a branch below selection" ));
559 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
560 a->setShortcutContext (Qt::WindowShortcut);
562 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
563 actionListBranches.append(a);
565 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
566 a->setStatusTip ( tr( "Move branch up" ) );
567 a->setShortcut (Qt::Key_PageUp ); // Move branch up
568 a->setEnabled (false);
570 editMenu->addAction (a);
571 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
574 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
575 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
576 a->setStatusTip (tr( "Move branch down" ) );
577 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
578 a->setEnabled (false);
580 editMenu->addAction (a);
581 actionEditMoveDown=a;
584 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
585 a->setShortcut ( Qt::Key_ScrollLock );
586 a->setStatusTip (tr( "Scroll branch" ) );
587 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
589 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
590 alt->setShortcut ( Qt::Key_S ); // Scroll branch
591 alt->setStatusTip (tr( "Scroll branch" ));
592 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
593 #if defined(Q_OS_MACX)
594 actionEditToggleScroll=alt;
596 actionEditToggleScroll=a;
598 actionEditToggleScroll->setEnabled (false);
599 actionEditToggleScroll->setToggleAction(true);
600 tb->addAction (actionEditToggleScroll);
601 editMenu->addAction ( actionEditToggleScroll);
602 editMenu->addAction (actionEditToggleScroll);
605 actionListBranches.append(actionEditToggleScroll);
607 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
608 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
609 editMenu->addAction (a);
610 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
612 editMenu->addSeparator();
614 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
615 a->setStatusTip (tr( "Find" ) );
616 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
617 editMenu->addAction (a);
618 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
620 editMenu->addSeparator();
622 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
623 a->setShortcut (Qt::CTRL + Qt::Key_U );
624 a->setShortcut (tr( "Open URL" ));
627 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
630 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
631 a->setStatusTip (tr( "Open URL in new tab" ));
632 //a->setShortcut (Qt::CTRL+Qt::Key_U );
634 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
635 actionEditOpenURLTab=a;
637 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
638 a->setStatusTip (tr( "Open all URLs in subtree" ));
640 actionListBranches.append(a);
641 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
642 actionEditOpenMultipleURLTabs=a;
644 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
645 a->setStatusTip ( tr( "Edit URL" ) );
646 //a->setShortcut (Qt::SHIFT + Qt::CTRL + Qt::Key_U );
647 a->setShortcut ( Qt::Key_U );
648 a->setShortcutContext (Qt::WindowShortcut);
649 actionListBranches.append(a);
651 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
654 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
655 a->setStatusTip ( tr( "Edit local URL" ) );
656 a->setShortcut (Qt::SHIFT + Qt::Key_U );
657 a->setShortcutContext (Qt::WindowShortcut);
658 actionListBranches.append(a);
660 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
663 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
664 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
665 a->setEnabled (false);
666 actionListBranches.append(a);
667 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
668 actionEditHeading2URL=a;
670 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
671 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
672 a->setEnabled (false);
673 actionListBranches.append(a);
674 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
675 actionEditBugzilla2URL=a;
677 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
678 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
679 a->setEnabled (false);
680 actionListBranches.append(a);
681 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
682 actionEditFATE2URL=a;
684 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
685 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
687 a->setEnabled (false);
688 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
689 actionEditOpenVymLink=a;
691 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
692 a->setStatusTip ( tr( "Open all vym links in subtree" ));
693 a->setEnabled (false);
694 actionListBranches.append(a);
695 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
696 actionEditOpenMultipleVymLinks=a;
699 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
700 a->setEnabled (false);
701 a->setStatusTip ( tr( "Edit link to another vym map" ));
702 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
703 actionListBranches.append(a);
706 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
707 a->setStatusTip ( tr( "Delete link to another vym map" ));
708 a->setEnabled (false);
709 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
710 actionEditDeleteVymLink=a;
712 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
713 a->setStatusTip ( tr( "Hide object in exports" ) );
714 a->setShortcut (Qt::Key_H );
715 a->setToggleAction(true);
717 a->setEnabled (false);
718 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
719 actionEditToggleHideExport=a;
721 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
722 a->setStatusTip ( tr( "Edit Map Info" ));
723 a->setEnabled (true);
724 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
727 // Import at selection (adding to selection)
728 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
729 a->setStatusTip (tr( "Add map at selection" ));
730 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
731 a->setEnabled (false);
732 actionListBranches.append(a);
733 actionEditImportAdd=a;
735 // Import at selection (replacing selection)
736 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
737 a->setStatusTip (tr( "Replace selection with map" ));
738 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
739 a->setEnabled (false);
740 actionListBranches.append(a);
741 actionEditImportReplace=a;
744 a = new QAction( tr( "Save selection","Edit menu" ), this);
745 a->setStatusTip (tr( "Save selection" ));
746 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
747 a->setEnabled (false);
748 actionListBranches.append(a);
749 actionEditSaveBranch=a;
751 // Only remove branch, not its childs
752 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
753 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
754 a->setShortcut (Qt::ALT + Qt::Key_Delete );
755 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
756 a->setEnabled (false);
758 actionListBranches.append(a);
759 actionEditDeleteKeepChilds=a;
761 // Only remove childs of a branch
762 a = new QAction( tr( "Remove childs","Edit menu" ), this);
763 a->setStatusTip (tr( "Remove childs of branch" ));
764 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
765 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
766 a->setEnabled (false);
767 actionListBranches.append(a);
768 actionEditDeleteChilds=a;
770 // Shortcuts for navigating with cursor:
771 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
772 a->setStatusTip ( tr( "Select upper branch" ));
773 a->setShortcut (Qt::Key_Up );
774 a->setShortcutContext (Qt::WindowShortcut);
776 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
777 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
778 a->setStatusTip (tr( "Select lower branch" ));
779 a->setShortcut ( Qt::Key_Down );
780 a->setShortcutContext (Qt::WindowShortcut);
782 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
783 a = new QAction(tr( "Select left branch","Edit menu" ), this);
784 a->setStatusTip ( tr( "Select left branch" ));
785 a->setShortcut (Qt::Key_Left );
786 a->setShortcutContext (Qt::WindowShortcut);
788 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
789 a = new QAction( tr( "Select child branch","Edit menu" ), this);
790 a->setStatusTip (tr( "Select right branch" ));
791 a->setShortcut (Qt::Key_Right);
792 a->setShortcutContext (Qt::WindowShortcut);
794 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
795 a = new QAction( tr( "Select first branch","Edit menu" ), this);
796 a->setStatusTip (tr( "Select first branch" ));
797 a->setShortcut (Qt::Key_Home );
798 a->setShortcutContext (Qt::WindowShortcut);
800 a->setEnabled (false);
801 editMenu->addAction (a);
802 actionListBranches.append(a);
803 actionEditSelectFirst=a;
804 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
805 a = new QAction( tr( "Select last branch","Edit menu" ),this);
806 a->setStatusTip (tr( "Select last branch" ));
807 a->setShortcut ( Qt::Key_End );
808 a->setShortcutContext (Qt::WindowShortcut);
810 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
811 a->setEnabled (false);
812 editMenu->addAction (a);
813 actionListBranches.append(a);
814 actionEditSelectLast=a;
816 a = new QAction( tr( "Add Image...","Edit menu" ), this);
817 a->setStatusTip (tr( "Add Image" ));
818 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
819 actionEditLoadImage=a;
821 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
822 a->setStatusTip (tr( "Set properties for selection" ));
823 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
824 a->setShortcutContext (Qt::WindowShortcut);
825 a->setToggleAction (true);
827 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
828 actionViewTogglePropertyWindow=a;
832 void Main::setupFormatActions()
834 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
836 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
837 tb->setObjectName ("formatTB");
840 pix.fill (Qt::black);
841 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
842 a->setStatusTip ( tr( "Set Color" ));
843 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
845 formatMenu->addAction (a);
847 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
848 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
849 a->setShortcut (Qt::CTRL + Qt::Key_K );
850 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
851 a->setEnabled (false);
853 formatMenu->addAction (a);
854 actionListBranches.append(a);
855 actionFormatPickColor=a;
857 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
858 a->setStatusTip ( tr( "Color branch" ) );
859 a->setShortcut (Qt::CTRL + Qt::Key_B);
860 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
861 a->setEnabled (false);
863 formatMenu->addAction (a);
864 actionListBranches.append(a);
865 actionFormatColorSubtree=a;
867 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
868 a->setStatusTip ( tr( "Color Subtree" ));
869 a->setShortcut (Qt::CTRL + Qt::Key_T);
870 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
871 a->setEnabled (false);
872 formatMenu->addAction (a);
874 actionListBranches.append(a);
875 actionFormatColorSubtree=a;
877 formatMenu->addSeparator();
878 actionGroupFormatLinkStyles=new QActionGroup ( this);
879 actionGroupFormatLinkStyles->setExclusive (true);
880 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
881 a->setStatusTip (tr( "Line" ));
882 a->setToggleAction(true);
883 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
884 formatMenu->addAction (a);
885 actionFormatLinkStyleLine=a;
886 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
887 a->setStatusTip (tr( "Line" ));
888 a->setToggleAction(true);
889 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
890 formatMenu->addAction (a);
891 actionFormatLinkStyleParabel=a;
892 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
893 a->setStatusTip (tr( "PolyLine" ));
894 a->setToggleAction(true);
895 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
896 formatMenu->addAction (a);
897 actionFormatLinkStylePolyLine=a;
898 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
899 a->setStatusTip (tr( "PolyParabel" ) );
900 a->setToggleAction(true);
901 a->setChecked (true);
902 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
903 formatMenu->addAction (a);
904 actionFormatLinkStylePolyParabel=a;
906 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
907 a->setStatusTip (tr( "Hide link" ));
908 a->setToggleAction(true);
909 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
910 actionFormatHideLinkUnselected=a;
912 formatMenu->addSeparator();
913 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
914 a->setStatusTip (tr( "Use same color for links and headings" ));
915 a->setToggleAction(true);
916 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
917 formatMenu->addAction (a);
918 actionFormatLinkColorHint=a;
920 pix.fill (Qt::white);
921 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
922 a->setStatusTip (tr( "Set Link Color" ));
923 formatMenu->addAction (a);
924 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
925 actionFormatLinkColor=a;
927 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
928 a->setStatusTip (tr( "Set Selection Color" ));
929 formatMenu->addAction (a);
930 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
931 actionFormatSelectionColor=a;
933 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
934 a->setStatusTip (tr( "Set Background Color" ));
935 formatMenu->addAction (a);
936 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
937 actionFormatBackColor=a;
939 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
940 a->setStatusTip (tr( "Set Background image" ));
941 formatMenu->addAction (a);
942 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
943 actionFormatBackImage=a;
947 void Main::setupViewActions()
949 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
950 tb->setLabel( "View Actions" );
951 tb->setObjectName ("viewTB");
952 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
955 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
956 a->setStatusTip ( tr( "Zoom reset" ) );
957 a->setShortcut (Qt::CTRL + Qt::Key_0 );
959 viewMenu->addAction (a);
960 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
962 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
963 a->setStatusTip (tr( "Zoom in" ));
964 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
966 viewMenu->addAction (a);
967 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
969 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
970 a->setStatusTip (tr( "Zoom out" ));
971 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
973 viewMenu->addAction (a);
974 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
976 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
977 a->setStatusTip (tr( "Show selection" ));
978 a->setShortcut (Qt::Key_Period);
980 viewMenu->addAction (a);
981 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
983 viewMenu->addSeparator();
985 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
986 a->setStatusTip ( tr( "Show Note Editor" ));
987 a->setShortcut ( Qt::CTRL + Qt::Key_E );
988 a->setToggleAction(true);
990 viewMenu->addAction (a);
991 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
992 actionViewToggleNoteEditor=a;
994 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
995 a->setStatusTip ( tr( "Show History Window" ));
996 a->setShortcut ( Qt::CTRL + Qt::Key_H );
997 a->setToggleAction(true);
999 viewMenu->addAction (a);
1000 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1001 actionViewToggleHistoryWindow=a;
1003 viewMenu->addAction (actionViewTogglePropertyWindow);
1005 viewMenu->addSeparator();
1007 a = new QAction(tr( "Antialiasing","View action" ),this );
1008 a->setStatusTip ( tr( "Antialiasing" ));
1009 a->setToggleAction(true);
1010 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1011 viewMenu->addAction (a);
1012 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1013 actionViewToggleAntiAlias=a;
1015 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1016 a->setStatusTip (a->text());
1017 a->setToggleAction(true);
1018 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1019 viewMenu->addAction (a);
1020 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1021 actionViewToggleSmoothPixmapTransform=a;
1023 a = new QAction(tr( "Next Map","View action" ), this);
1024 a->setStatusTip (a->text());
1025 a->setShortcut (Qt::ALT + Qt::Key_N );
1026 viewMenu->addAction (a);
1027 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1029 a = new QAction (tr( "Previous Map","View action" ), this );
1030 a->setStatusTip (a->text());
1031 a->setShortcut (Qt::ALT + Qt::Key_P );
1032 viewMenu->addAction (a);
1033 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1037 void Main::setupModeActions()
1039 //QPopupMenu *menu = new QPopupMenu( this );
1040 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1042 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1043 tb->setObjectName ("modesTB");
1045 actionGroupModModes=new QActionGroup ( this);
1046 actionGroupModModes->setExclusive (true);
1047 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1048 a->setShortcut (Qt::Key_J);
1049 a->setStatusTip ( tr( "Use modifier to color branches" ));
1050 a->setToggleAction(true);
1053 actionModModeColor=a;
1055 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1056 a->setShortcut( Qt::Key_K);
1057 a->setStatusTip( tr( "Use modifier to copy" ));
1058 a->setToggleAction(true);
1060 actionModModeCopy=a;
1062 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1063 a->setShortcut (Qt::Key_L);
1064 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1065 a->setToggleAction(true);
1067 actionModModeXLink=a;
1071 void Main::setupFlagActions()
1073 // Create System Flags
1077 systemFlagsDefault = new FlagRowObj ();
1078 systemFlagsDefault->setVisibility (false);
1079 systemFlagsDefault->setName ("systemFlagsDef");
1081 FlagObj *fo = new FlagObj ();
1082 fo->load(QPixmap(flagsPath+"flag-note.png"));
1083 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1085 fo->load(QPixmap(flagsPath+"flag-url.png"));
1086 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1088 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1089 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1091 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1092 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1094 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1095 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1097 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1098 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1100 // Create Standard Flags
1101 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1102 tb->setObjectName ("standardFlagTB");
1104 standardFlagsDefault = new FlagRowObj ();
1105 standardFlagsDefault->setVisibility (false);
1106 standardFlagsDefault->setName ("standardFlagsDef");
1107 standardFlagsDefault->setToolBar (tb);
1109 fo->load(flagsPath+"flag-exclamationmark.png");
1110 fo->setGroup("standard-mark");
1111 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1113 fo->load(flagsPath+"flag-questionmark.png");
1114 fo->setGroup("standard-mark");
1115 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1117 fo->load(flagsPath+"flag-hook-green.png");
1118 fo->setGroup("standard-hook");
1119 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1121 fo->load(flagsPath+"flag-cross-red.png");
1122 fo->setGroup("standard-hook");
1123 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1126 fo->load(flagsPath+"flag-stopsign.png");
1127 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1129 fo->load(flagsPath+"flag-smiley-good.png");
1130 fo->setGroup("standard-smiley");
1131 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1133 fo->load(flagsPath+"flag-smiley-sad.png");
1134 fo->setGroup("standard-smiley");
1135 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1137 fo->load(flagsPath+"flag-smiley-omg.png");
1138 fo->setGroup("standard-smiley");
1139 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1140 // Original omg.png (in KDE emoticons)
1143 fo->load(flagsPath+"flag-kalarm.png");
1144 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1146 fo->load(flagsPath+"flag-phone.png");
1147 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1149 fo->load(flagsPath+"flag-lamp.png");
1150 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1152 fo->load(flagsPath+"flag-arrow-up.png");
1153 fo->setGroup("standard-arrow");
1154 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1156 fo->load(flagsPath+"flag-arrow-down.png");
1157 fo->setGroup("standard-arrow");
1158 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1160 fo->load(flagsPath+"flag-arrow-2up.png");
1161 fo->setGroup("standard-arrow");
1162 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1164 fo->load(flagsPath+"flag-arrow-2down.png");
1165 fo->setGroup("standard-arrow");
1166 setupFlag (fo,tb,avis,"present",tr("Very unimportant!","Standardflag"));
1169 fo->load(flagsPath+"flag-thumb-up.png");
1170 fo->setGroup("standard-thumb");
1171 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1173 fo->load(flagsPath+"flag-thumb-down.png");
1174 fo->setGroup("standard-thumb");
1175 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1178 fo->load(flagsPath+"flag-rose.png");
1179 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1181 fo->load(flagsPath+"flag-heart.png");
1182 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1184 fo->load(flagsPath+"flag-present.png");
1185 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1187 fo->load(flagsPath+"flag-flash.png");
1188 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1190 // Original: xsldbg_output.png
1191 fo->load(flagsPath+"flag-info.png");
1192 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1194 // Original khelpcenter.png
1195 fo->load(flagsPath+"flag-lifebelt.png");
1196 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1202 fo->load(flagsPath+"freemind/warning.png");
1203 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1205 for (int i=1; i<8; i++)
1207 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1208 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1211 fo->load(flagsPath+"freemind/back.png");
1212 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1214 fo->load(flagsPath+"freemind/forward.png");
1215 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1217 fo->load(flagsPath+"freemind/attach.png");
1218 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1220 fo->load(flagsPath+"freemind/clanbomber.png");
1221 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1223 fo->load(flagsPath+"freemind/desktopnew.png");
1224 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1226 fo->load(flagsPath+"freemind/flag.png");
1227 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1230 fo->load(flagsPath+"freemind/gohome.png");
1231 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1234 fo->load(flagsPath+"freemind/kaddressbook.png");
1235 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1237 fo->load(flagsPath+"freemind/knotify.png");
1238 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1240 fo->load(flagsPath+"freemind/korn.png");
1241 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1243 fo->load(flagsPath+"freemind/mail.png");
1244 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1246 fo->load(flagsPath+"freemind/password.png");
1247 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1249 fo->load(flagsPath+"freemind/pencil.png");
1250 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1252 fo->load(flagsPath+"freemind/stop.png");
1253 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1255 fo->load(flagsPath+"freemind/wizard.png");
1256 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1258 fo->load(flagsPath+"freemind/xmag.png");
1259 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1261 fo->load(flagsPath+"freemind/bell.png");
1262 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1264 fo->load(flagsPath+"freemind/bookmark.png");
1265 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1267 fo->load(flagsPath+"freemind/penguin.png");
1268 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1270 fo->load(flagsPath+"freemind/licq.png");
1271 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1276 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1279 fo->setToolTip (tooltip);
1280 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1286 fo->setAlwaysVisible(aw);
1287 a->setCheckable(true);
1288 a->setObjectName(fo->getName());
1289 a->setToolTip(tooltip);
1290 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1291 standardFlagsDefault->addFlag (fo);
1295 systemFlagsDefault->addFlag (fo);
1299 void Main::setupNetworkActions()
1301 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1303 QMenu *netMenu = menuBar()->addMenu( "&Network" );
1307 a = new QAction( "Start TCPserver for MapEditor",this);
1308 //a->setStatusTip ( "Set application to open pdf files"));
1309 a->setShortcut ( Qt::Key_T ); //New TCP server
1310 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1311 netMenu->addAction (a);
1313 a = new QAction( "Connect MapEditor to server",this);
1314 //a->setStatusTip ( "Set application to open pdf files"));
1315 a->setShortcut ( Qt::Key_C ); // Connect to server
1316 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1317 netMenu->addAction (a);
1321 void Main::setupSettingsActions()
1323 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1327 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1328 a->setStatusTip ( tr( "Set application to open pdf files"));
1329 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1330 settingsMenu->addAction (a);
1332 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1333 a->setStatusTip( tr( "Set application to open external links"));
1334 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1335 settingsMenu->addAction (a);
1337 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1338 a->setStatusTip( tr( "Set path for macros"));
1339 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1340 settingsMenu->addAction (a);
1342 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1343 a->setStatusTip( tr( "Set number of undo levels"));
1344 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1345 settingsMenu->addAction (a);
1347 settingsMenu->addSeparator();
1349 a = new QAction( tr( "Autosave","Settings action"), this);
1350 a->setStatusTip( tr( "Autosave"));
1351 a->setToggleAction(true);
1352 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1353 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1354 settingsMenu->addAction (a);
1355 actionSettingsAutosaveToggle=a;
1357 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1358 a->setStatusTip( tr( "Autosave time"));
1359 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1360 settingsMenu->addAction (a);
1361 actionSettingsAutosaveTime=a;
1363 settingsMenu->addSeparator();
1365 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1366 a->setStatusTip( tr( "Edit branch after adding it" ));
1367 a->setToggleAction(true);
1368 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1369 settingsMenu->addAction (a);
1370 actionSettingsAutoEditNewBranch=a;
1372 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1373 a->setStatusTip( tr( "Select branch after adding it" ));
1374 a->setToggleAction(true);
1375 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1376 settingsMenu->addAction (a);
1377 actionSettingsAutoSelectNewBranch=a;
1379 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1380 a->setStatusTip( tr( "Select heading before editing" ));
1381 a->setToggleAction(true);
1382 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1383 settingsMenu->addAction (a);
1384 actionSettingsAutoSelectText=a;
1386 a= new QAction( tr( "Delete key","Settings action" ), this);
1387 a->setStatusTip( tr( "Delete key for deleting branches" ));
1388 a->setToggleAction(true);
1389 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1390 settingsMenu->addAction (a);
1391 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1392 actionSettingsUseDelKey=a;
1394 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1395 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1396 a->setToggleAction(true);
1397 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1398 settingsMenu->addAction (a);
1399 actionSettingsUseFlagGroups=a;
1401 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1402 a->setStatusTip( tr( "Use hide flag during exports " ));
1403 a->setToggleAction(true);
1404 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1405 settingsMenu->addAction (a);
1406 actionSettingsUseHideExport=a;
1410 void Main::setupTestActions()
1412 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1415 a = new QAction( "Test function 1" , this);
1416 a->setStatusTip( "Call test function 1" );
1417 testMenu->addAction (a);
1418 //a->setShortcut (Qt::Key_F4 );
1419 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1421 a = new QAction( "Test function 2" , this);
1422 a->setStatusTip( "Call test function 2" );
1423 //a->setShortcut (Qt::Key_F4 );
1424 testMenu->addAction (a);
1425 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1427 a = new QAction( "Command" , this);
1428 a->setStatusTip( "Enter command to call in editor" );
1429 //a->setShortcut (Qt::Key_F5 );
1430 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1431 testMenu->addAction (a);
1435 void Main::setupHelpActions()
1437 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1440 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1441 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1442 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1443 helpMenu->addAction (a);
1445 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1446 a->setStatusTip( tr( "Open VYM example maps " ));
1447 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1448 helpMenu->addAction (a);
1450 a = new QAction( tr( "About VYM","Help action" ), this);
1451 a->setStatusTip( tr( "About VYM")+vymName);
1452 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1453 helpMenu->addAction (a);
1455 a = new QAction( tr( "About QT","Help action" ), this);
1456 a->setStatusTip( tr( "Information about QT toolkit" ));
1457 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1458 helpMenu->addAction (a);
1462 void Main::setupContextMenus()
1466 // Context Menu for branch or mapcenter
1467 branchContextMenu =new QMenu (this);
1468 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1469 branchContextMenu->addSeparator();
1472 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1473 branchAddContextMenu->addAction (actionEditPaste );
1474 branchAddContextMenu->addAction ( actionEditAddBranch );
1475 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1476 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1477 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1478 branchAddContextMenu->addSeparator();
1479 branchAddContextMenu->addAction ( actionEditImportAdd );
1480 branchAddContextMenu->addAction ( actionEditImportReplace );
1483 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1484 branchRemoveContextMenu->addAction (actionEditCut);
1485 branchRemoveContextMenu->addAction ( actionEditDelete );
1486 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1487 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1490 actionEditSaveBranch->addTo( branchContextMenu );
1492 branchContextMenu->addSeparator();
1493 branchContextMenu->addAction ( actionEditLoadImage);
1495 // Submenu for Links (URLs, vymLinks)
1496 branchLinksContextMenu =new QMenu (this);
1498 branchContextMenu->addSeparator();
1499 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1500 branchLinksContextMenu->addAction ( actionEditOpenURL );
1501 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1502 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1503 branchLinksContextMenu->addAction ( actionEditURL );
1504 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1505 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1506 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1508 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1510 branchLinksContextMenu->addSeparator();
1511 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1512 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1513 branchLinksContextMenu->addAction ( actionEditVymLink );
1514 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1517 // Context Menu for XLinks in a branch menu
1518 // This will be populated "on demand" in MapEditor::updateActions
1519 branchContextMenu->addSeparator();
1520 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1521 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1522 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1523 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1526 // Context menu for floatimage
1527 floatimageContextMenu =new QMenu (this);
1528 a= new QAction (tr ("Save image","Context action"),this);
1529 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1530 floatimageContextMenu->addAction (a);
1532 floatimageContextMenu->addSeparator();
1533 actionEditCopy->addTo( floatimageContextMenu );
1534 actionEditCut->addTo( floatimageContextMenu );
1536 floatimageContextMenu->addSeparator();
1537 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1540 // Context menu for canvas
1541 canvasContextMenu =new QMenu (this);
1542 actionEditMapInfo->addTo( canvasContextMenu );
1543 canvasContextMenu->insertSeparator();
1544 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1545 canvasContextMenu->insertSeparator();
1546 actionFormatLinkColorHint->addTo( canvasContextMenu );
1547 actionFormatLinkColor->addTo( canvasContextMenu );
1548 actionFormatSelectionColor->addTo( canvasContextMenu );
1549 actionFormatBackColor->addTo( canvasContextMenu );
1550 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1552 // Menu for last opened files
1554 for (int i = 0; i < MaxRecentFiles; ++i)
1556 recentFileActions[i] = new QAction(this);
1557 recentFileActions[i]->setVisible(false);
1558 fileLastMapsMenu->addAction(recentFileActions[i]);
1559 connect(recentFileActions[i], SIGNAL(triggered()),
1560 this, SLOT(fileLoadRecent()));
1562 setupRecentMapsMenu();
1565 void Main::setupRecentMapsMenu()
1567 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1569 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1571 for (int i = 0; i < numRecentFiles; ++i) {
1572 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1573 recentFileActions[i]->setText(text);
1574 recentFileActions[i]->setData(files[i]);
1575 recentFileActions[i]->setVisible(true);
1577 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1578 recentFileActions[j]->setVisible(false);
1581 void Main::setupMacros()
1583 for (int i = 0; i <= 11; i++)
1585 macroActions[i] = new QAction(this);
1586 macroActions[i]->setData(i);
1587 addAction (macroActions[i]);
1588 connect(macroActions[i], SIGNAL(triggered()),
1589 this, SLOT(callMacro()));
1591 macroActions[0]->setShortcut ( Qt::Key_F1 );
1592 macroActions[1]->setShortcut ( Qt::Key_F2 );
1593 macroActions[2]->setShortcut ( Qt::Key_F3 );
1594 macroActions[3]->setShortcut ( Qt::Key_F4 );
1595 macroActions[4]->setShortcut ( Qt::Key_F5 );
1596 macroActions[5]->setShortcut ( Qt::Key_F6 );
1597 macroActions[6]->setShortcut ( Qt::Key_F7 );
1598 macroActions[7]->setShortcut ( Qt::Key_F8 );
1599 macroActions[8]->setShortcut ( Qt::Key_F9 );
1600 macroActions[9]->setShortcut ( Qt::Key_F10 );
1601 macroActions[10]->setShortcut ( Qt::Key_F11 );
1602 macroActions[11]->setShortcut ( Qt::Key_F12 );
1605 void Main::hideEvent (QHideEvent * )
1607 if (!textEditor->isMinimized() ) textEditor->hide();
1610 void Main::showEvent (QShowEvent * )
1612 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1616 MapEditor* Main::currentMapEditor() const
1618 if ( tabWidget->currentPage() &&
1619 tabWidget->currentPage()->inherits( "MapEditor" ) )
1620 return (MapEditor*)tabWidget->currentPage();
1625 void Main::editorChanged(QWidget *)
1627 // Unselect all possibly selected objects
1628 // (Important to update note editor)
1630 for (int i=0;i<=tabWidget->count() -1;i++)
1633 me=(MapEditor*)tabWidget->page(i);
1636 currentMapEditor()->reselect();
1638 // Update actions to in menus and toolbars according to editor
1642 void Main::fileNew()
1644 QString fn="unnamed";
1645 MapEditor* me = new MapEditor ( NULL);
1646 tabWidget->addTab (me,fn);
1647 tabWidget->showPage(me);
1648 me->viewport()->setFocus();
1649 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1650 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1652 // For the very first map we do not have flagrows yet...
1656 void Main::fileNewCopy()
1658 QString fn="unnamed";
1659 MapEditor* oldME =currentMapEditor();
1663 MapEditor* newME = new MapEditor ( NULL);
1666 tabWidget->addTab (newME,fn);
1667 tabWidget->showPage(newME);
1668 newME->viewport()->setFocus();
1669 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1670 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1671 // For the very first map we do not have flagrows yet...
1672 newME->select("mc:");
1673 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1679 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1681 ErrorCode err=success;
1683 // fn is usually the archive, mapfile the file after uncompressing
1686 // Make fn absolute (needed for unzip)
1687 fn=QDir (fn).absPath();
1693 // Check, if map is already loaded
1695 while (i<=tabWidget->count() -1)
1697 me=(MapEditor*)tabWidget->page(i);
1698 if (me->getFilePath() == fn)
1700 // Already there, ask for confirmation
1701 QMessageBox mb( vymName,
1702 tr("The map %1\nis already opened."
1703 "Opening the same map in multiple editors may lead \n"
1704 "to confusion when finishing working with vym."
1705 "Do you want to").arg(fn),
1706 QMessageBox::Warning,
1707 QMessageBox::Yes | QMessageBox::Default,
1708 QMessageBox::Cancel | QMessageBox::Escape,
1709 QMessageBox::NoButton);
1710 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1711 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1714 case QMessageBox::Yes:
1716 i=tabWidget->count();
1718 case QMessageBox::Cancel:
1730 if ( !fn.isEmpty() )
1732 me = currentMapEditor();
1733 int tabIndex=tabWidget->currentPageIndex();
1734 // Check first, if mapeditor exists
1735 // If it is not default AND we want a new map,
1736 // create a new mapeditor in a new tab
1737 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1739 me= new MapEditor ( NULL);
1740 tabWidget->addTab (me,fn);
1741 tabIndex=tabWidget->indexOf (me);
1742 tabWidget->setCurrentPage (tabIndex);
1743 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1744 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1747 // Check, if file exists (important for creating new files
1748 // from command line
1749 if (!QFile(fn).exists() )
1751 QMessageBox mb( vymName,
1752 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1753 QMessageBox::Question,
1755 QMessageBox::Cancel | QMessageBox::Default,
1756 QMessageBox::NoButton );
1758 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1759 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1762 case QMessageBox::Yes:
1764 currentMapEditor()->setFilePath(fn);
1765 tabWidget->setTabLabel (currentMapEditor(),
1766 currentMapEditor()->getFileName() );
1767 statusBar()->message( "Created " + fn , statusbarTime );
1770 case QMessageBox::Cancel:
1771 // don't create new map
1772 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1779 //tabWidget->currentPage() won't be NULL here, because of above...
1780 tabWidget->showPage(me);
1781 me->viewport()->setFocus();
1783 // Create temporary directory for packing
1785 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1788 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1789 tr("Couldn't create temporary directory before load\n"));
1793 // Try to unzip file
1794 err=unzipDir (tmpMapDir,fn);
1798 me->setZipped(false);
1801 me->setZipped(true);
1803 // Look for mapname.xml
1804 mapfile= fn.left(fn.findRev(".",-1,true));
1805 mapfile=mapfile.section( '/', -1 );
1806 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1807 if (!file.exists() )
1809 // mapname.xml does not exist, well,
1810 // maybe someone renamed the mapname.vym file...
1811 // Try to find any .xml in the toplevel
1812 // directory of the .vym file
1813 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1814 if (flist.count()==1)
1816 // Only one entry, take this one
1817 mapfile=tmpMapDir + "/"+flist.first();
1820 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1821 *it=tmpMapDir + "/" + *it;
1822 // TODO Multiple entries, load all (but only the first one into this ME)
1823 //mainWindow->fileLoadFromTmp (flist);
1824 //returnCode=1; // Silently forget this attempt to load
1825 qWarning ("MainWindow::load (fn) multimap found...");
1828 if (flist.isEmpty() )
1830 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1831 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1834 } //file doesn't exist
1836 mapfile=file.name();
1841 // Save existing filename in case we import
1842 QString fn_org=me->getFilePath();
1844 // Finally load map into mapEditor
1845 me->setFilePath (mapfile,fn);
1846 err=me->load(mapfile,lmode,ftype);
1848 // Restore old (maybe empty) filepath, if this is an import
1850 me->setFilePath (fn_org);
1853 // Finally check for errors and go home
1856 if (lmode==NewMap) fileCloseMap();
1857 statusBar()->message( "Could not load " + fn, statusbarTime );
1862 me->setFilePath (fn);
1863 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1864 if (fn.left(9)!="/tmp/vym-")
1866 // Only append to lastMaps if not loaded from a tmpDir
1867 // e.g. imported bookmarks are in a tmpDir
1868 addRecentMap(me->getFilePath() );
1870 actionFilePrint->setEnabled (true);
1872 statusBar()->message( "Loaded " + fn, statusbarTime );
1876 removeDir (QDir(tmpMapDir));
1882 void Main::fileLoad(const LoadMode &lmode)
1884 QStringList filters;
1885 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1886 QFileDialog *fd=new QFileDialog( this);
1887 fd->setDir (lastFileDir);
1888 fd->setFileMode (QFileDialog::ExistingFiles);
1889 fd->setFilters (filters);
1893 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1896 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1899 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1905 if ( fd->exec() == QDialog::Accepted )
1907 lastFileDir=fd->directory().path();
1908 QStringList flist = fd->selectedFiles();
1909 QStringList::Iterator it = flist.begin();
1910 while( it != flist.end() )
1913 fileLoad(*it, lmode);
1920 void Main::fileLoad()
1925 void Main::fileLoadRecent()
1927 QAction *action = qobject_cast<QAction *>(sender());
1929 fileLoad (action->data().toString(), NewMap);
1932 void Main::addRecentMap (const QString &fileName)
1935 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1936 files.removeAll(fileName);
1937 files.prepend(fileName);
1938 while (files.size() > MaxRecentFiles)
1941 settings.setValue("/mainwindow/recentFileList", files);
1943 setupRecentMapsMenu();
1946 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1948 // tmp dir for zipping
1952 ErrorCode err=success;
1954 QString safeFilePath;
1956 bool saveZipped=me->saveZipped();
1960 QString fn=me->getFilePath();
1961 // filename=unnamed, filepath="" in constructor of mapEditor
1962 if ( !fn.isEmpty() )
1964 // We have a filepath, go on saving
1965 // First remove existing file, we
1966 // don't want to add to old zip archives
1970 QMessageBox::warning( 0, tr( "Save Error" ),
1971 fn+ tr("\ncould not be removed before saving"));
1973 // Look, if we should zip the data:
1976 QMessageBox mb( vymName,
1977 tr("The map %1\ndid not use the compressed "
1978 "vym file format.\nWriting it uncompressed will also write images \n"
1979 "and flags and thus may overwrite files in the "
1980 "given directory\n\nDo you want to write the map").arg(fn),
1981 QMessageBox::Warning,
1982 QMessageBox::Yes | QMessageBox::Default,
1984 QMessageBox::Cancel | QMessageBox::Escape);
1985 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1986 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1987 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1990 case QMessageBox::Yes:
1991 // save compressed (default file format)
1994 case QMessageBox::No:
1995 // save uncompressed
1998 case QMessageBox::Cancel:
2007 // Create temporary directory for packing
2009 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2012 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2013 tr("Couldn't create temporary directory before save\n"));
2017 safeFilePath=me->getFilePath();
2018 me->setFilePath (tmpMapDir+"/"+
2019 me->getMapName()+ ".xml",
2021 me->save (savemode);
2022 me->setFilePath (safeFilePath);
2024 zipDir (tmpMapDir,fn);
2029 safeFilePath=me->getFilePath();
2030 me->setFilePath (fn, safeFilePath);
2031 me->save (savemode);
2032 me->setFilePath (safeFilePath);
2034 } // filepath available
2037 // We have no filepath yet,
2038 // call fileSaveAs() now, this will call fileSave()
2040 // First switch to editor
2041 tabWidget->setCurrentWidget (me);
2042 fileSaveAs(savemode);
2046 if (saveZipped && !tmpMapDir.isEmpty())
2048 removeDir (QDir(tmpMapDir));
2052 statusBar()->message(
2053 tr("Saved %1").arg(me->getFilePath()),
2055 addRecentMap (me->getFilePath() );
2057 statusBar()->message(
2058 tr("Couldn't save ").arg(me->getFilePath()),
2062 void Main::fileSave()
2064 fileSave (currentMapEditor(), CompleteMap);
2067 void Main::fileSave(MapEditor *me)
2069 fileSave (me,CompleteMap);
2072 void Main::fileSaveAs(const SaveMode& savemode)
2076 if (currentMapEditor())
2078 if (savemode==CompleteMap)
2079 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2081 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2082 if ( !fn.isEmpty() )
2084 // Check for existing file
2085 if (QFile (fn).exists())
2087 QMessageBox mb( vymName,
2088 tr("The file %1\nexists already. Do you want to").arg(fn),
2089 QMessageBox::Warning,
2090 QMessageBox::Yes | QMessageBox::Default,
2091 QMessageBox::Cancel | QMessageBox::Escape,
2092 QMessageBox::NoButton);
2093 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2094 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2097 case QMessageBox::Yes:
2100 case QMessageBox::Cancel:
2107 // New file, add extension to filename, if missing
2108 // This is always .vym or .vyp, depending on savemode
2109 if (savemode==CompleteMap)
2111 if (!fn.contains (".vym") && !fn.contains (".xml"))
2115 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2124 currentMapEditor()->setFilePath(fn);
2125 fileSave(currentMapEditor(), savemode);
2128 if (savemode==CompleteMap)
2129 tabWidget->setTabLabel (currentMapEditor(),
2130 currentMapEditor()->getFileName() );
2136 void Main::fileSaveAs()
2138 fileSaveAs (CompleteMap);
2141 void Main::fileImportKDEBookmarks()
2143 ImportKDEBookmarks im;
2145 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2146 currentMapEditor()->setFilePath ("");
2149 void Main::fileImportFirefoxBookmarks()
2151 Q3FileDialog *fd=new Q3FileDialog( this);
2152 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2153 fd->setMode (Q3FileDialog::ExistingFiles);
2154 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2155 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2158 if ( fd->exec() == QDialog::Accepted )
2160 ImportFirefoxBookmarks im;
2161 QStringList flist = fd->selectedFiles();
2162 QStringList::Iterator it = flist.begin();
2163 while( it != flist.end() )
2166 if (im.transform() &&
2167 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2168 currentMapEditor() )
2169 currentMapEditor()->setFilePath ("");
2176 void Main::fileImportFreemind()
2178 QStringList filters;
2179 filters <<"Freemind map (*.mm)"<<"All files (*)";
2180 QFileDialog *fd=new QFileDialog( this);
2181 fd->setDir (lastFileDir);
2182 fd->setFileMode (QFileDialog::ExistingFiles);
2183 fd->setFilters (filters);
2184 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2188 if ( fd->exec() == QDialog::Accepted )
2190 lastFileDir=fd->directory().path();
2191 QStringList flist = fd->selectedFiles();
2192 QStringList::Iterator it = flist.begin();
2193 while( it != flist.end() )
2196 if ( fileLoad (fn,NewMap, FreemindMap) )
2198 currentMapEditor()->setFilePath ("");
2207 void Main::fileImportMM()
2211 Q3FileDialog *fd=new Q3FileDialog( this);
2212 fd->setDir (lastFileDir);
2213 fd->setMode (Q3FileDialog::ExistingFiles);
2214 fd->addFilter ("Mind Manager (*.mmap)");
2215 fd->setCaption(tr("Import")+" "+"Mind Manager");
2218 if ( fd->exec() == QDialog::Accepted )
2220 lastFileDir=fd->dirPath();
2221 QStringList flist = fd->selectedFiles();
2222 QStringList::Iterator it = flist.begin();
2223 while( it != flist.end() )
2226 if (im.transform() &&
2227 success==fileLoad (im.getTransformedFile(),NewMap) &&
2228 currentMapEditor() )
2229 currentMapEditor()->setFilePath ("");
2238 void Main::fileImportDir()
2240 if (currentMapEditor())
2241 currentMapEditor()->importDir();
2244 void Main::fileExportXML()
2246 MapEditor *me=currentMapEditor();
2247 if (me) me->exportXML();
2251 void Main::fileExportXHTML()
2253 MapEditor *me=currentMapEditor();
2254 if (me) me->exportXHTML();
2257 void Main::fileExportImage()
2259 MapEditor *me=currentMapEditor();
2260 if (me) me->exportImage();
2263 void Main::fileExportASCII()
2265 MapEditor *me=currentMapEditor();
2266 if (me) me->exportASCII();
2269 void Main::fileExportCSV() //FIXME not scriptable yet
2271 MapEditor *me=currentMapEditor();
2275 ex.setMapCenter(me->getMapCenter());
2276 ex.addFilter ("CSV (*.csv)");
2277 ex.setDir(lastImageDir);
2278 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2279 if (ex.execDialog() )
2281 me->setExportMode(true);
2283 me->setExportMode(false);
2288 void Main::fileExportLaTeX() //FIXME not scriptable yet
2290 MapEditor *me=currentMapEditor();
2294 ex.setMapCenter(me->getMapCenter());
2295 ex.addFilter ("Tex (*.tex)");
2296 ex.setDir(lastImageDir);
2297 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2298 if (ex.execDialog() )
2300 me->setExportMode(true);
2302 me->setExportMode(false);
2307 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2309 ExportKDEBookmarks ex;
2310 MapEditor *me=currentMapEditor();
2313 ex.setMapCenter (me->getMapCenter() );
2318 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2320 ExportTaskjuggler ex;
2321 MapEditor *me=currentMapEditor();
2324 ex.setMapCenter (me->getMapCenter() );
2325 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2326 ex.setDir(lastImageDir);
2327 ex.addFilter ("Taskjuggler (*.tjp)");
2328 if (ex.execDialog() )
2330 me->setExportMode(true);
2332 me->setExportMode(false);
2337 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2339 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2340 // TODO add preview in dialog
2341 //ImagePreview *p =new ImagePreview (fd);
2342 //fd->setContentsPreviewEnabled( TRUE );
2343 //fd->setContentsPreview( p, p );
2344 //fd->setPreviewMode( QFileDialog::Contents );
2345 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2346 fd->setDir (QDir().current());
2347 if (fd->foundConfig())
2351 if ( fd->exec() == QDialog::Accepted )
2353 QString fn=fd->selectedFile();
2354 if (!fn.contains (".odp"))
2357 //lastImageDir=fn.left(fn.findRev ("/"));
2358 if (currentMapEditor())
2359 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2363 QMessageBox::warning(0,
2365 tr("Couldn't find configuration for export to Open Office\n"));
2369 void Main::fileCloseMap()
2371 if (currentMapEditor())
2373 if (currentMapEditor()->hasChanged())
2375 QMessageBox mb( vymName,
2376 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2377 QMessageBox::Warning,
2378 QMessageBox::Yes | QMessageBox::Default,
2380 QMessageBox::Cancel | QMessageBox::Escape );
2381 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2382 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2385 case QMessageBox::Yes:
2387 fileSave(currentMapEditor(), CompleteMap);
2389 case QMessageBox::No:
2390 // close without saving
2392 case QMessageBox::Cancel:
2397 currentMapEditor()->closeMap();
2398 tabWidget->removePage(currentMapEditor());
2399 if (tabWidget->count()==0)
2400 actionFilePrint->setEnabled (false);
2404 void Main::filePrint()
2406 if (currentMapEditor())
2407 currentMapEditor()->print();
2410 void Main::fileExitVYM()
2412 // Check if one or more editors have changed
2415 for (i=0;i<=tabWidget->count() -1;i++)
2418 me=(MapEditor*)tabWidget->page(i);
2420 // If something changed, ask what to do
2421 if (me->hasChanged())
2423 tabWidget->setCurrentPage(i);
2424 QMessageBox mb( vymName,
2425 tr("This map is not saved yet. Do you want to"),
2426 QMessageBox::Warning,
2427 QMessageBox::Yes | QMessageBox::Default,
2429 QMessageBox::Cancel | QMessageBox::Escape );
2430 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2431 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2434 mb.setActiveWindow();
2435 switch( mb.exec() ) {
2436 case QMessageBox::Yes:
2437 // save (the changed editors) and exit
2438 fileSave(currentMapEditor(), CompleteMap);
2440 case QMessageBox::No:
2441 // exit without saving
2443 case QMessageBox::Cancel:
2444 // don't save and don't exit
2448 } // loop over all MEs
2452 void Main::editUndo()
2454 if (currentMapEditor())
2455 currentMapEditor()->undo();
2458 void Main::editRedo()
2460 if (currentMapEditor())
2461 currentMapEditor()->redo();
2464 void Main::gotoHistoryStep (int i)
2466 if (currentMapEditor())
2467 currentMapEditor()->gotoHistoryStep (i);
2470 void Main::editCopy()
2472 if (currentMapEditor())
2473 currentMapEditor()->copy();
2476 void Main::editPaste()
2478 if (currentMapEditor())
2479 currentMapEditor()->paste();
2482 void Main::editCut()
2484 if (currentMapEditor())
2485 currentMapEditor()->cut();
2488 void Main::editOpenFindWindow()
2490 findWindow->popup();
2491 findWindow->raise();
2492 findWindow->setActiveWindow();
2495 void Main::editFind(QString s)
2498 BranchObj *bo=currentMapEditor()->findText(s, cs);
2501 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2504 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2505 tr("No matches found for \"%1\"").arg(s));
2509 void Main::editFindChanged()
2510 { // Notify editor, to abort the current find process
2511 currentMapEditor()->findReset();
2514 void Main::openTabs(QStringList urls)
2516 if (!urls.isEmpty())
2520 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2522 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2524 QString u=urls.takeFirst();
2525 procBrowser = new QProcess( this );
2527 procBrowser->start(browser,args);
2528 if ( !procBrowser->waitForStarted())
2530 // try to set path to browser
2531 QMessageBox::warning(0,
2533 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2534 tr("Please use Settings->")+tr("Set application to open an URL"));
2539 if (browser.contains("konqueror"))
2541 for (int i=0; i<urls.size(); i++)
2544 // Try to open new tab in existing konqueror started previously by vym
2545 p=new QProcess (this);
2547 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2548 "konqueror-mainwindow#1"<<
2551 p->start ("dcop",args);
2552 if ( !p->waitForStarted() ) success=false;
2555 QMessageBox::warning(0,
2557 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2559 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2561 for (int i=0; i<urls.size(); i++)
2563 // Try to open new tab in firefox
2564 p=new QProcess (this);
2565 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2566 p->start (browser,args);
2567 if ( !p->waitForStarted() ) success=false;
2570 QMessageBox::warning(0,
2572 tr("Couldn't start %1 to open a new tab").arg(browser));
2575 QMessageBox::warning(0,
2577 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2581 void Main::editOpenURL()
2584 if (currentMapEditor())
2586 QString url=currentMapEditor()->getURL();
2588 if (url=="") return;
2589 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2590 procBrowser = new QProcess( this );
2592 procBrowser->start(browser,args);
2593 if ( !procBrowser->waitForStarted())
2595 // try to set path to browser
2596 QMessageBox::warning(0,
2598 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2599 tr("Please use Settings->")+tr("Set application to open an URL"));
2604 void Main::editOpenURLTab()
2606 if (currentMapEditor())
2609 urls.append(currentMapEditor()->getURL());
2613 void Main::editOpenMultipleURLTabs()
2615 if (currentMapEditor())
2618 urls=currentMapEditor()->getURLs();
2624 void Main::editURL()
2626 if (currentMapEditor())
2627 currentMapEditor()->editURL();
2630 void Main::editLocalURL()
2632 if (currentMapEditor())
2633 currentMapEditor()->editLocalURL();
2636 void Main::editHeading2URL()
2638 if (currentMapEditor())
2639 currentMapEditor()->editHeading2URL();
2642 void Main::editBugzilla2URL()
2644 if (currentMapEditor())
2645 currentMapEditor()->editBugzilla2URL();
2648 void Main::editFATE2URL()
2650 if (currentMapEditor())
2651 currentMapEditor()->editFATE2URL();
2654 void Main::editHeadingFinished()
2656 // only called from editHeading(), so there is a currentME
2657 MapEditor *me=currentMapEditor();
2660 me->setStateEditHeading (false);
2661 QPoint p; //Not used here, only to find out pos of branch
2663 QString s=me->getHeading(ok,p);
2665 #if defined(Q_OS_MACX)
2667 if (ok && s!=lineedit->text())
2668 me->setHeading(lineedit->text());
2670 lineedit->releaseKeyboard();
2674 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2675 !prevSelection.isEmpty())
2676 me->select(prevSelection);
2681 void Main::editHeading()
2683 if (currentMapEditor())
2685 MapEditor *me=currentMapEditor();
2686 QString oldSel=me->getSelectString();
2688 if (lineedit->isVisible())
2689 editHeadingFinished();
2694 QString s=me->getHeading(ok,p);
2698 me->setStateEditHeading (true);
2699 #if defined(Q_OS_MACX)
2700 p=me->mapToGlobal (p);
2701 QDialog *d =new QDialog(NULL);
2702 QLineEdit *le=new QLineEdit (d);
2703 d->setWindowFlags (Qt::FramelessWindowHint);
2704 d->setGeometry(p.x(),p.y(),230,25);
2705 le->resize (d->width()-10,d->height());
2708 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2709 d->activateWindow();
2711 me->setHeading (le->text());
2714 editHeadingFinished();
2716 p=me->mapTo (this,p);
2717 lineedit->setGeometry(p.x(),p.y(),230,25);
2718 lineedit->setText(s);
2719 lineedit->setCursorPosition(1);
2720 lineedit->selectAll();
2722 lineedit->grabKeyboard();
2723 lineedit->setFocus();
2727 } // currentMapEditor()
2730 void Main::openVymLinks(const QStringList &vl)
2732 for (int j=0; j<vl.size(); j++)
2734 // compare path with already loaded maps
2738 for (i=0;i<=tabWidget->count() -1;i++)
2740 me=(MapEditor*)tabWidget->page(i);
2741 if (vl.at(j)==me->getFilePath() )
2750 if (!QFile(vl.at(j)).exists() )
2751 QMessageBox::critical( 0, tr( "Critical Error" ),
2752 tr("Couldn't open map %1").arg(vl.at(j)));
2755 fileLoad (vl.at(j), NewMap);
2756 tabWidget->setCurrentPage (tabWidget->count()-1);
2759 // Go to tab containing the map
2760 tabWidget->setCurrentPage (index);
2764 void Main::editOpenVymLink()
2766 if (currentMapEditor())
2769 vl.append(currentMapEditor()->getVymLink());
2774 void Main::editOpenMultipleVymLinks()
2776 QString currentVymLink;
2777 if (currentMapEditor())
2779 QStringList vl=currentMapEditor()->getVymLinks();
2784 void Main::editVymLink()
2786 if (currentMapEditor())
2787 currentMapEditor()->editVymLink();
2790 void Main::editDeleteVymLink()
2792 if (currentMapEditor())
2793 currentMapEditor()->deleteVymLink();
2796 void Main::editToggleHideExport()
2798 if (currentMapEditor())
2799 currentMapEditor()->toggleHideExport();
2802 void Main::editMapInfo()
2804 if (currentMapEditor())
2805 currentMapEditor()->editMapInfo();
2808 void Main::editMoveUp()
2810 if (currentMapEditor())
2811 currentMapEditor()->moveBranchUp();
2814 void Main::editMoveDown()
2816 if (currentMapEditor())
2817 currentMapEditor()->moveBranchDown();
2820 void Main::editToggleScroll()
2822 if (currentMapEditor())
2824 currentMapEditor()->toggleScroll();
2828 void Main::editUnscrollChilds()
2830 if (currentMapEditor())
2831 currentMapEditor()->unscrollChilds();
2834 void Main::editNewBranch()
2836 MapEditor *me=currentMapEditor();
2837 if (!lineedit->isVisible() && me)
2839 BranchObj *bo=(BranchObj*)me->getSelection();
2840 BranchObj *newbo=me->addNewBranch(0);
2842 prevSelection=bo->getSelectString();
2844 me->select (newbo->getSelectString());
2848 if (actionSettingsAutoEditNewBranch->isOn())
2853 if (!prevSelection.isEmpty())
2855 me->select(prevSelection);
2862 void Main::editNewBranchBefore()
2864 MapEditor *me=currentMapEditor();
2865 if (!lineedit->isVisible() && me)
2867 BranchObj *bo=(BranchObj*)me->getSelection();
2868 BranchObj *newbo=me->addNewBranchBefore();
2871 me->select (newbo->getSelectString());
2875 if (actionSettingsAutoEditNewBranch->isOn())
2877 if (!actionSettingsAutoSelectNewBranch->isOn())
2878 prevSelection=bo->getSelectString();
2884 void Main::editNewBranchAbove()
2886 MapEditor *me=currentMapEditor();
2887 if (!lineedit->isVisible() && me)
2889 BranchObj *bo=(BranchObj*)me->getSelection();
2890 BranchObj *newbo=me->addNewBranch (-1);
2893 me->select (newbo->getSelectString());
2897 if (actionSettingsAutoEditNewBranch->isOn())
2899 if (!actionSettingsAutoSelectNewBranch->isOn())
2900 prevSelection=bo->getSelectString();
2906 void Main::editNewBranchBelow()
2908 MapEditor *me=currentMapEditor();
2909 if (!lineedit->isVisible() && me)
2911 BranchObj *bo=(BranchObj*)me->getSelection();
2912 BranchObj *newbo=me->addNewBranch (1);
2915 me->select (newbo->getSelectString());
2919 if (actionSettingsAutoEditNewBranch->isOn())
2921 if (!actionSettingsAutoSelectNewBranch->isOn())
2922 prevSelection=bo->getSelectString();
2928 void Main::editImportAdd()
2930 fileLoad (ImportAdd);
2933 void Main::editImportReplace()
2935 fileLoad (ImportReplace);
2938 void Main::editSaveBranch()
2940 fileSaveAs (PartOfMap);
2943 void Main::editDeleteKeepChilds()
2945 if (currentMapEditor())
2946 currentMapEditor()->deleteKeepChilds();
2949 void Main::editDeleteChilds()
2951 if (currentMapEditor())
2952 currentMapEditor()->deleteChilds();
2955 void Main::editDeleteSelection()
2957 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2958 currentMapEditor()->deleteSelection();
2961 void Main::editUpperBranch()
2963 if (currentMapEditor())
2964 currentMapEditor()->selectUpperBranch();
2967 void Main::editLowerBranch()
2969 if (currentMapEditor())
2970 currentMapEditor()->selectLowerBranch();
2973 void Main::editLeftBranch()
2975 if (currentMapEditor())
2976 currentMapEditor()->selectLeftBranch();
2979 void Main::editRightBranch()
2981 if (currentMapEditor())
2982 currentMapEditor()->selectRightBranch();
2985 void Main::editFirstBranch()
2987 if (currentMapEditor())
2988 currentMapEditor()->selectFirstBranch();
2991 void Main::editLastBranch()
2993 if (currentMapEditor())
2994 currentMapEditor()->selectLastBranch();
2997 void Main::editLoadImage()
2999 if (currentMapEditor())
3000 currentMapEditor()->loadFloatImage();
3003 void Main::editSaveImage()
3005 if (currentMapEditor())
3006 currentMapEditor()->saveFloatImage();
3009 void Main::editFollowXLink(QAction *a)
3012 if (currentMapEditor())
3013 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3016 void Main::editEditXLink(QAction *a)
3018 if (currentMapEditor())
3019 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3022 void Main::formatSelectColor()
3024 if (currentMapEditor())
3026 QColor col = QColorDialog::getColor((currentColor ), this );
3027 if ( !col.isValid() ) return;
3028 colorChanged( col );
3032 void Main::formatPickColor()
3034 if (currentMapEditor())
3035 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3038 void Main::colorChanged(QColor c)
3040 QPixmap pix( 16, 16 );
3042 actionFormatColor->setIconSet( pix );
3046 void Main::formatColorBranch()
3048 if (currentMapEditor())
3049 currentMapEditor()->colorBranch(currentColor);
3052 void Main::formatColorSubtree()
3054 if (currentMapEditor())
3055 currentMapEditor()->colorSubtree (currentColor);
3058 void Main::formatLinkStyleLine()
3060 if (currentMapEditor())
3061 currentMapEditor()->setMapLinkStyle("StyleLine");
3064 void Main::formatLinkStyleParabel()
3066 if (currentMapEditor())
3067 currentMapEditor()->setMapLinkStyle("StyleParabel");
3070 void Main::formatLinkStylePolyLine()
3072 if (currentMapEditor())
3073 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3076 void Main::formatLinkStylePolyParabel()
3078 if (currentMapEditor())
3079 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3082 void Main::formatSelectBackColor()
3084 if (currentMapEditor())
3085 currentMapEditor()->selectMapBackgroundColor();
3088 void Main::formatSelectBackImage()
3090 if (currentMapEditor())
3091 currentMapEditor()->selectMapBackgroundImage();
3094 void Main::formatSelectLinkColor()
3096 if (currentMapEditor())
3097 currentMapEditor()->selectMapLinkColor();
3100 void Main::formatSelectSelectionColor()
3102 if (currentMapEditor())
3103 currentMapEditor()->selectMapSelectionColor();
3106 void Main::formatToggleLinkColorHint()
3108 currentMapEditor()->toggleMapLinkColorHint();
3112 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3114 if (currentMapEditor())
3115 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3118 void Main::viewZoomReset()
3120 if (currentMapEditor())
3124 currentMapEditor()->setMatrix( m );
3128 void Main::viewZoomIn()
3130 if (currentMapEditor())
3132 QMatrix m = currentMapEditor()->matrix();
3133 m.scale( 1.25, 1.25 );
3134 currentMapEditor()->setMatrix( m );
3138 void Main::viewZoomOut()
3140 if (currentMapEditor())
3142 QMatrix m = currentMapEditor()->matrix();
3143 m.scale( 0.8, 0.8 );
3144 currentMapEditor()->setMatrix( m );
3148 void Main::viewCenter()
3150 MapEditor *me=currentMapEditor();
3153 me->ensureSelectionVisible();
3157 void Main::networkStartServer()
3159 MapEditor *me=currentMapEditor();
3160 if (me) me->newServer();
3163 void Main::networkConnect()
3165 MapEditor *me=currentMapEditor();
3166 if (me) me->connectToServer();
3169 bool Main::settingsPDF()
3171 // Default browser is set in constructor
3173 QString text = QInputDialog::getText(
3174 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3175 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3177 settings.setValue ("/mainwindow/readerPDF",text);
3182 bool Main::settingsURL()
3184 // Default browser is set in constructor
3186 QString text = QInputDialog::getText(
3187 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3188 settings.value("/mainwindow/readerURL").toString()
3191 settings.setValue ("/mainwindow/readerURL",text);
3195 void Main::settingsMacroDir()
3197 QDir defdir=vymBaseDir;
3198 defdir.cd("macros");
3199 if (!defdir.exists())
3201 QDir dir=QFileDialog::getExistingDirectory (
3203 tr ("Directory with vym macros:"),
3204 settings.value ("/macros/macroDir",defdir.path()).toString()
3207 settings.setValue ("/macros/macroDir",dir.path());
3210 void Main::settingsUndoLevels()
3213 int i = QInputDialog::getInteger(
3215 tr("QInputDialog::getInteger()"),
3216 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3219 settings.setValue ("/mapeditor/stepsTotal",i);
3220 QMessageBox::information( this, tr( "VYM -Information:" ),
3221 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3225 void Main::settingsAutosaveToggle()
3227 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3230 void Main::settingsAutosaveTime()
3233 int i = QInputDialog::getInteger(
3235 tr("QInputDialog::getInteger()"),
3236 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3239 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3243 void Main::settingsToggleDelKey()
3245 if (actionSettingsUseDelKey->isOn())
3247 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3250 actionEditDelete->setAccel (QKeySequence (""));
3254 void Main::windowToggleNoteEditor()
3256 if (textEditor->isVisible() )
3257 windowHideNoteEditor();
3259 windowShowNoteEditor();
3262 void Main::windowToggleHistory()
3264 if (historyWindow->isVisible())
3265 historyWindow->hide();
3267 historyWindow->show();
3271 void Main::windowToggleProperty()
3273 if (branchPropertyWindow->isVisible())
3274 branchPropertyWindow->hide();
3276 branchPropertyWindow->show();
3278 if(currentMapEditor())
3280 LinkableMapObj *sel=currentMapEditor()->getSelection();
3281 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3282 typeid(*sel) == typeid(MapCenterObj)))
3284 branchPropertyWindow->setMapEditor(currentMapEditor());
3285 branchPropertyWindow->setBranch((BranchObj*)sel);
3290 branchPropertyWindow->setBranch(NULL);
3293 void Main::windowToggleAntiAlias()
3295 bool b=actionViewToggleAntiAlias->isOn();
3297 for (int i=0;i<tabWidget->count();i++)
3300 me=(MapEditor*)tabWidget->page(i);
3301 me->setAntiAlias(b);
3306 void Main::windowToggleSmoothPixmap()
3308 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3310 for (int i=0;i<tabWidget->count();i++)
3313 me=(MapEditor*)tabWidget->page(i);
3314 me->setSmoothPixmap(b);
3318 void Main::updateHistory(SimpleSettings &undoSet)
3320 historyWindow->update (undoSet);
3323 void Main::updateNoteFlag()
3325 if (currentMapEditor())
3326 currentMapEditor()->updateNoteFlag();
3329 void Main::updateSatellites(MapEditor *me)
3331 branchPropertyWindow->setMapEditor (me);
3334 void Main::updateActions()
3336 MapEditor *me=currentMapEditor();
3339 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3341 // updateActions is also called when NoteEditor is closed
3342 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3343 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3344 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3346 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3347 actionFormatLinkColorHint->setOn(true);
3349 actionFormatLinkColorHint->setOn(false);
3351 switch (me->getMapLinkStyle())
3353 case LinkableMapObj::Line:
3354 actionFormatLinkStyleLine->setOn(true);
3356 case LinkableMapObj::Parabel:
3357 actionFormatLinkStyleParabel->setOn(true);
3359 case LinkableMapObj::PolyLine:
3360 actionFormatLinkStylePolyLine->setOn(true);
3362 case LinkableMapObj::PolyParabel:
3363 actionFormatLinkStylePolyParabel->setOn(true);
3370 QPixmap pix( 16, 16 );
3371 pix.fill( me->getMapBackgroundColor() );
3372 actionFormatBackColor->setIconSet( pix );
3373 pix.fill( me->getSelectionColor() );
3374 actionFormatSelectionColor->setIconSet( pix );
3375 pix.fill( me->getMapDefLinkColor() );
3376 actionFormatLinkColor->setIconSet( pix );
3379 actionFileSave->setEnabled( me->hasChanged() );
3380 if (me->isUndoAvailable())
3381 actionEditUndo->setEnabled( true);
3383 actionEditUndo->setEnabled( false);
3385 if (me->isRedoAvailable())
3386 actionEditRedo->setEnabled( true);
3388 actionEditRedo->setEnabled( false);
3390 LinkableMapObj *selection=me->getSelection();
3393 if ( (typeid(*selection) == typeid(BranchObj)) ||
3394 (typeid(*selection) == typeid(MapCenterObj)) )
3396 BranchObj *bo=(BranchObj*)selection;
3397 // Take care of links
3398 if (bo->countXLinks()==0)
3400 branchXLinksContextMenuEdit->clear();
3401 branchXLinksContextMenuFollow->clear();
3406 branchXLinksContextMenuEdit->clear();
3407 branchXLinksContextMenuFollow->clear();
3408 for (int i=0; i<=bo->countXLinks();i++)
3410 bot=bo->XLinkTargetAt(i);
3413 s=bot->getHeading();
3416 branchXLinksContextMenuFollow->addAction (s);
3417 branchXLinksContextMenuEdit->addAction (s);
3422 standardFlagsDefault->setEnabled (true);
3424 actionEditToggleScroll->setEnabled (true);
3425 if ( bo->isScrolled() )
3426 actionEditToggleScroll->setOn(true);
3428 actionEditToggleScroll->setOn(false);
3430 if ( bo->getURL().isEmpty() )
3432 actionEditOpenURL->setEnabled (false);
3433 actionEditOpenURLTab->setEnabled (false);
3437 actionEditOpenURL->setEnabled (true);
3438 actionEditOpenURLTab->setEnabled (true);
3440 if ( bo->getVymLink().isEmpty() )
3442 actionEditOpenVymLink->setEnabled (false);
3443 actionEditDeleteVymLink->setEnabled (false);
3446 actionEditOpenVymLink->setEnabled (true);
3447 actionEditDeleteVymLink->setEnabled (true);
3450 if (bo->canMoveBranchUp())
3451 actionEditMoveUp->setEnabled (true);
3453 actionEditMoveUp->setEnabled (false);
3454 if (bo->canMoveBranchDown())
3455 actionEditMoveDown->setEnabled (true);
3457 actionEditMoveDown->setEnabled (false);
3460 actionEditToggleHideExport->setEnabled (true);
3461 actionEditToggleHideExport->setOn (bo->hideInExport() );
3463 actionEditCopy->setEnabled (true);
3464 actionEditCut->setEnabled (true);
3465 if (!clipboardEmpty)
3466 actionEditPaste->setEnabled (true);
3468 actionEditPaste->setEnabled (false);
3469 for (int i=0; i<actionListBranches.size(); ++i)
3470 actionListBranches.at(i)->setEnabled(true);
3471 actionEditDelete->setEnabled (true);
3472 actionFormatHideLinkUnselected->setOn
3473 (selection->getHideLinkUnselected());
3475 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3477 FloatObj *fo=(FloatImageObj*)selection;
3479 actionEditOpenURL->setEnabled (false);
3480 actionEditOpenVymLink->setEnabled (false);
3481 actionEditDeleteVymLink->setEnabled (false);
3482 actionEditToggleHideExport->setEnabled (true);
3483 actionEditToggleHideExport->setOn (fo->hideInExport() );
3486 actionEditCopy->setEnabled (true);
3487 actionEditCut->setEnabled (true);
3488 actionEditPaste->setEnabled (false);
3489 for (int i=0; i<actionListBranches.size(); ++i)
3490 actionListBranches.at(i)->setEnabled(false);
3491 actionEditDelete->setEnabled (true);
3492 actionFormatHideLinkUnselected->setOn
3493 ( selection->getHideLinkUnselected());
3494 actionEditMoveUp->setEnabled (false);
3495 actionEditMoveDown->setEnabled (false);
3500 actionEditCopy->setEnabled (false);
3501 actionEditCut->setEnabled (false);
3502 actionEditPaste->setEnabled (false);
3503 for (int i=0; i<actionListBranches.size(); ++i)
3504 actionListBranches.at(i)->setEnabled(false);
3506 actionEditToggleScroll->setEnabled (false);
3507 actionEditOpenURL->setEnabled (false);
3508 actionEditOpenVymLink->setEnabled (false);
3509 actionEditDeleteVymLink->setEnabled (false);
3510 actionEditHeading2URL->setEnabled (false);
3511 actionEditDelete->setEnabled (false);
3512 actionEditMoveUp->setEnabled (false);
3513 actionEditMoveDown->setEnabled (false);
3514 actionEditToggleHideExport->setEnabled (false);
3518 Main::ModMode Main::getModMode()
3520 if (actionModModeColor->isOn()) return ModModeColor;
3521 if (actionModModeCopy->isOn()) return ModModeCopy;
3522 if (actionModModeXLink->isOn()) return ModModeXLink;
3526 bool Main::autoEditNewBranch()
3528 return actionSettingsAutoEditNewBranch->isOn();
3531 bool Main::autoSelectNewBranch()
3533 return actionSettingsAutoSelectNewBranch->isOn();
3536 bool Main::useFlagGroups()
3538 return actionSettingsUseFlagGroups->isOn();
3541 void Main::windowShowNoteEditor()
3543 textEditor->setShowWithMain(true);
3545 actionViewToggleNoteEditor->setOn (true);
3548 void Main::windowHideNoteEditor()
3550 textEditor->setShowWithMain(false);
3552 actionViewToggleNoteEditor->setOn (false);
3555 void Main::setScript (const QString &script)
3557 scriptEditor->setScript (script);
3560 void Main::runScript (const QString &script)
3562 if (currentMapEditor())
3563 currentMapEditor()->runScript (script);
3566 void Main::runScriptEverywhere (const QString &script)
3569 for (int i=0;i<=tabWidget->count() -1;i++)
3571 me=(MapEditor*)tabWidget->page(i);
3572 if (me) me->runScript (script);
3576 void Main::windowNextEditor()
3578 if (tabWidget->currentPageIndex() < tabWidget->count())
3579 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3582 void Main::windowPreviousEditor()
3584 if (tabWidget->currentPageIndex() >0)
3585 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3588 void Main::standardFlagChanged()
3590 if (currentMapEditor())
3591 currentMapEditor()->toggleStandardFlag(sender()->name());
3594 void Main::testFunction1()
3596 if (!currentMapEditor()) return;
3597 currentMapEditor()->testFunction1();
3600 void Main::testFunction2()
3602 if (!currentMapEditor()) return;
3603 currentMapEditor()->testFunction2();
3606 void Main::testCommand()
3608 if (!currentMapEditor()) return;
3609 scriptEditor->show();
3612 QString com = QInputDialog::getText(
3613 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3614 if (ok) currentMapEditor()->parseAtom(com);
3618 void Main::helpDoc()
3620 QString locale = QLocale::system().name();
3622 if (locale.left(2)=="es")
3623 docname="vym_es.pdf";
3627 QStringList searchList;
3629 #if defined(Q_OS_MACX)
3630 searchList << "./vym.app/Contents/Resources/doc";
3632 // default path in SUSE LINUX
3633 searchList <<"/usr/share/doc/packages/vym";
3636 searchList << "doc"; // relative path for easy testing in tarball
3637 searchList << "doc/tex"; // Easy testing working on vym.tex
3638 searchList << "/usr/share/doc/vym"; // Debian
3639 searchList << "/usr/share/doc/packages";// Knoppix
3643 for (int i=0; i<searchList.count(); ++i)
3645 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3646 if (docfile.exists() )
3655 QMessageBox::critical(0,
3656 tr("Critcal error"),
3657 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3662 Process *pdfProc = new Process();
3663 args <<docfile.fileName();
3665 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3666 if ( !pdfProc->waitForStarted() )
3669 QMessageBox::warning(0,
3671 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3672 tr("Please use Settings->")+tr("Set application to open PDF files"));
3679 void Main::helpDemo()
3681 QStringList filters;
3682 filters <<"VYM example map (*.vym)";
3683 QFileDialog *fd=new QFileDialog( this);
3684 #if defined(Q_OS_MACX)
3685 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3687 // default path in SUSE LINUX
3688 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3691 fd->setFileMode (QFileDialog::ExistingFiles);
3692 fd->setFilters (filters);
3693 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3697 if ( fd->exec() == QDialog::Accepted )
3699 lastFileDir=fd->directory().path();
3700 QStringList flist = fd->selectedFiles();
3701 QStringList::Iterator it = flist.begin();
3702 while( it != flist.end() )
3705 fileLoad(*it, NewMap);
3713 void Main::helpAbout()
3716 ad.setName ("aboutwindow");
3717 ad.setMinimumSize(500,500);
3718 ad.resize (QSize (500,500));
3722 void Main::helpAboutQT()
3724 QMessageBox::aboutQt( this, "Qt Application Example" );
3727 void Main::callMacro ()
3729 QAction *action = qobject_cast<QAction *>(sender());
3733 i=action->data().toInt();
3734 QString mDir (settings.value ("macros/macroDir").toString() );
3736 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3738 if ( !f.open( QIODevice::ReadOnly ) )
3740 QMessageBox::warning(0,
3742 tr("Couldn't find a macro at %1.\n").arg(fn)+
3743 tr("Please use Settings->")+tr("Set directory for vym macros"));
3747 QTextStream ts( &f );
3748 QString m= ts.read();
3752 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3753 currentMapEditor()->runScript (m);