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");
1136 fo->load(flagsPath+"flag-smiley-omg.png");
1137 fo->setGroup("standard-smiley");
1138 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1139 // Original omg.png (in KDE emoticons)
1142 fo->load(flagsPath+"flag-kalarm.png");
1143 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1145 fo->load(flagsPath+"flag-phone.png");
1146 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1148 fo->load(flagsPath+"flag-lamp.png");
1149 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1151 fo->load(flagsPath+"flag-arrow-up.png");
1152 fo->setGroup("standard-arrow");
1153 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1155 fo->load(flagsPath+"flag-arrow-down.png");
1156 fo->setGroup("standard-arrow");
1157 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1159 fo->load(flagsPath+"flag-arrow-2up.png");
1160 fo->setGroup("standard-arrow");
1161 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1163 fo->load(flagsPath+"flag-arrow-2down.png");
1164 fo->setGroup("standard-arrow");
1165 setupFlag (fo,tb,avis,"present",tr("Very unimportant!","Standardflag"));
1168 fo->load(flagsPath+"flag-thumb-up.png");
1169 fo->setGroup("standard-thumb");
1170 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1172 fo->load(flagsPath+"flag-thumb-down.png");
1173 fo->setGroup("standard-thumb");
1174 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1177 fo->load(flagsPath+"flag-rose.png");
1178 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1180 fo->load(flagsPath+"flag-heart.png");
1181 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1183 fo->load(flagsPath+"flag-present.png");
1184 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1186 fo->load(flagsPath+"flag-flash.png");
1187 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1189 // Original: xsldbg_output.png
1190 fo->load(flagsPath+"flag-info.png");
1191 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1193 // Original khelpcenter.png
1194 fo->load(flagsPath+"flag-lifebelt.png");
1195 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1201 fo->load(flagsPath+"freemind/warning.png");
1202 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1204 for (int i=1; i<8; i++)
1206 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1207 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1210 fo->load(flagsPath+"freemind/back.png");
1211 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1213 fo->load(flagsPath+"freemind/forward.png");
1214 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1216 fo->load(flagsPath+"freemind/attach.png");
1217 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1219 fo->load(flagsPath+"freemind/clanbomber.png");
1220 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1222 fo->load(flagsPath+"freemind/desktopnew.png");
1223 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1225 fo->load(flagsPath+"freemind/flag.png");
1226 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1229 fo->load(flagsPath+"freemind/gohome.png");
1230 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1233 fo->load(flagsPath+"freemind/kaddressbook.png");
1234 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1236 fo->load(flagsPath+"freemind/knotify.png");
1237 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1239 fo->load(flagsPath+"freemind/korn.png");
1240 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1242 fo->load(flagsPath+"freemind/mail.png");
1243 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1245 fo->load(flagsPath+"freemind/password.png");
1246 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1248 fo->load(flagsPath+"freemind/pencil.png");
1249 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1251 fo->load(flagsPath+"freemind/stop.png");
1252 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1254 fo->load(flagsPath+"freemind/wizard.png");
1255 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1257 fo->load(flagsPath+"freemind/xmag.png");
1258 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1260 fo->load(flagsPath+"freemind/bell.png");
1261 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1263 fo->load(flagsPath+"freemind/bookmark.png");
1264 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1266 fo->load(flagsPath+"freemind/penguin.png");
1267 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1269 fo->load(flagsPath+"freemind/licq.png");
1270 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1275 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1278 fo->setToolTip (tooltip);
1279 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1285 fo->setAlwaysVisible(aw);
1286 a->setCheckable(true);
1287 a->setObjectName(fo->getName());
1288 a->setToolTip(tooltip);
1289 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1290 standardFlagsDefault->addFlag (fo);
1294 systemFlagsDefault->addFlag (fo);
1298 void Main::setupNetworkActions()
1300 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1302 QMenu *netMenu = menuBar()->addMenu( "&Network" );
1306 a = new QAction( "Start TCPserver for MapEditor",this);
1307 //a->setStatusTip ( "Set application to open pdf files"));
1308 a->setShortcut ( Qt::Key_T ); //New TCP server
1309 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1310 netMenu->addAction (a);
1312 a = new QAction( "Connect MapEditor to server",this);
1313 //a->setStatusTip ( "Set application to open pdf files"));
1314 a->setShortcut ( Qt::Key_C ); // Connect to server
1315 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1316 netMenu->addAction (a);
1320 void Main::setupSettingsActions()
1322 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1326 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1327 a->setStatusTip ( tr( "Set application to open pdf files"));
1328 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1329 settingsMenu->addAction (a);
1331 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1332 a->setStatusTip( tr( "Set application to open external links"));
1333 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1334 settingsMenu->addAction (a);
1336 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1337 a->setStatusTip( tr( "Set path for macros"));
1338 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1339 settingsMenu->addAction (a);
1341 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1342 a->setStatusTip( tr( "Set number of undo levels"));
1343 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1344 settingsMenu->addAction (a);
1346 settingsMenu->addSeparator();
1348 a = new QAction( tr( "Autosave","Settings action"), this);
1349 a->setStatusTip( tr( "Autosave"));
1350 a->setToggleAction(true);
1351 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1352 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1353 settingsMenu->addAction (a);
1354 actionSettingsAutosaveToggle=a;
1356 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1357 a->setStatusTip( tr( "Autosave time"));
1358 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1359 settingsMenu->addAction (a);
1360 actionSettingsAutosaveTime=a;
1362 settingsMenu->addSeparator();
1364 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1365 a->setStatusTip( tr( "Edit branch after adding it" ));
1366 a->setToggleAction(true);
1367 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1368 settingsMenu->addAction (a);
1369 actionSettingsAutoEditNewBranch=a;
1371 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1372 a->setStatusTip( tr( "Select branch after adding it" ));
1373 a->setToggleAction(true);
1374 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1375 settingsMenu->addAction (a);
1376 actionSettingsAutoSelectNewBranch=a;
1378 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1379 a->setStatusTip( tr( "Select heading before editing" ));
1380 a->setToggleAction(true);
1381 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1382 settingsMenu->addAction (a);
1383 actionSettingsAutoSelectText=a;
1385 a= new QAction( tr( "Delete key","Settings action" ), this);
1386 a->setStatusTip( tr( "Delete key for deleting branches" ));
1387 a->setToggleAction(true);
1388 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1389 settingsMenu->addAction (a);
1390 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1391 actionSettingsUseDelKey=a;
1393 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1394 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1395 a->setToggleAction(true);
1396 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1397 settingsMenu->addAction (a);
1398 actionSettingsUseFlagGroups=a;
1400 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1401 a->setStatusTip( tr( "Use hide flag during exports " ));
1402 a->setToggleAction(true);
1403 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1404 settingsMenu->addAction (a);
1405 actionSettingsUseHideExport=a;
1409 void Main::setupTestActions()
1411 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1414 a = new QAction( "Test function 1" , this);
1415 a->setStatusTip( "Call test function 1" );
1416 testMenu->addAction (a);
1417 //a->setShortcut (Qt::Key_F4 );
1418 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1420 a = new QAction( "Test function 2" , this);
1421 a->setStatusTip( "Call test function 2" );
1422 //a->setShortcut (Qt::Key_F4 );
1423 testMenu->addAction (a);
1424 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1426 a = new QAction( "Command" , this);
1427 a->setStatusTip( "Enter command to call in editor" );
1428 //a->setShortcut (Qt::Key_F5 );
1429 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1430 testMenu->addAction (a);
1434 void Main::setupHelpActions()
1436 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1439 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1440 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1441 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1442 helpMenu->addAction (a);
1444 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1445 a->setStatusTip( tr( "Open VYM example maps " ));
1446 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1447 helpMenu->addAction (a);
1449 a = new QAction( tr( "About VYM","Help action" ), this);
1450 a->setStatusTip( tr( "About VYM")+vymName);
1451 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1452 helpMenu->addAction (a);
1454 a = new QAction( tr( "About QT","Help action" ), this);
1455 a->setStatusTip( tr( "Information about QT toolkit" ));
1456 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1457 helpMenu->addAction (a);
1461 void Main::setupContextMenus()
1465 // Context Menu for branch or mapcenter
1466 branchContextMenu =new QMenu (this);
1467 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1468 branchContextMenu->addSeparator();
1471 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1472 branchAddContextMenu->addAction (actionEditPaste );
1473 branchAddContextMenu->addAction ( actionEditAddBranch );
1474 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1475 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1476 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1477 branchAddContextMenu->addSeparator();
1478 branchAddContextMenu->addAction ( actionEditImportAdd );
1479 branchAddContextMenu->addAction ( actionEditImportReplace );
1482 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1483 branchRemoveContextMenu->addAction (actionEditCut);
1484 branchRemoveContextMenu->addAction ( actionEditDelete );
1485 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1486 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1489 actionEditSaveBranch->addTo( branchContextMenu );
1491 branchContextMenu->addSeparator();
1492 branchContextMenu->addAction ( actionEditLoadImage);
1494 // Submenu for Links (URLs, vymLinks)
1495 branchLinksContextMenu =new QMenu (this);
1497 branchContextMenu->addSeparator();
1498 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1499 branchLinksContextMenu->addAction ( actionEditOpenURL );
1500 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1501 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1502 branchLinksContextMenu->addAction ( actionEditURL );
1503 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1504 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1505 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1507 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1509 branchLinksContextMenu->addSeparator();
1510 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1511 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1512 branchLinksContextMenu->addAction ( actionEditVymLink );
1513 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1516 // Context Menu for XLinks in a branch menu
1517 // This will be populated "on demand" in MapEditor::updateActions
1518 branchContextMenu->addSeparator();
1519 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1520 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1521 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1522 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1525 // Context menu for floatimage
1526 floatimageContextMenu =new QMenu (this);
1527 a= new QAction (tr ("Save image","Context action"),this);
1528 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1529 floatimageContextMenu->addAction (a);
1531 floatimageContextMenu->addSeparator();
1532 actionEditCopy->addTo( floatimageContextMenu );
1533 actionEditCut->addTo( floatimageContextMenu );
1535 floatimageContextMenu->addSeparator();
1536 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1539 // Context menu for canvas
1540 canvasContextMenu =new QMenu (this);
1541 actionEditMapInfo->addTo( canvasContextMenu );
1542 canvasContextMenu->insertSeparator();
1543 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1544 canvasContextMenu->insertSeparator();
1545 actionFormatLinkColorHint->addTo( canvasContextMenu );
1546 actionFormatLinkColor->addTo( canvasContextMenu );
1547 actionFormatSelectionColor->addTo( canvasContextMenu );
1548 actionFormatBackColor->addTo( canvasContextMenu );
1549 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1551 // Menu for last opened files
1553 for (int i = 0; i < MaxRecentFiles; ++i)
1555 recentFileActions[i] = new QAction(this);
1556 recentFileActions[i]->setVisible(false);
1557 fileLastMapsMenu->addAction(recentFileActions[i]);
1558 connect(recentFileActions[i], SIGNAL(triggered()),
1559 this, SLOT(fileLoadRecent()));
1561 setupRecentMapsMenu();
1564 void Main::setupRecentMapsMenu()
1566 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1568 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1570 for (int i = 0; i < numRecentFiles; ++i) {
1571 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1572 recentFileActions[i]->setText(text);
1573 recentFileActions[i]->setData(files[i]);
1574 recentFileActions[i]->setVisible(true);
1576 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1577 recentFileActions[j]->setVisible(false);
1580 void Main::setupMacros()
1582 for (int i = 0; i <= 11; i++)
1584 macroActions[i] = new QAction(this);
1585 macroActions[i]->setData(i);
1586 addAction (macroActions[i]);
1587 connect(macroActions[i], SIGNAL(triggered()),
1588 this, SLOT(callMacro()));
1590 macroActions[0]->setShortcut ( Qt::Key_F1 );
1591 macroActions[1]->setShortcut ( Qt::Key_F2 );
1592 macroActions[2]->setShortcut ( Qt::Key_F3 );
1593 macroActions[3]->setShortcut ( Qt::Key_F4 );
1594 macroActions[4]->setShortcut ( Qt::Key_F5 );
1595 macroActions[5]->setShortcut ( Qt::Key_F6 );
1596 macroActions[6]->setShortcut ( Qt::Key_F7 );
1597 macroActions[7]->setShortcut ( Qt::Key_F8 );
1598 macroActions[8]->setShortcut ( Qt::Key_F9 );
1599 macroActions[9]->setShortcut ( Qt::Key_F10 );
1600 macroActions[10]->setShortcut ( Qt::Key_F11 );
1601 macroActions[11]->setShortcut ( Qt::Key_F12 );
1604 void Main::hideEvent (QHideEvent * )
1606 if (!textEditor->isMinimized() ) textEditor->hide();
1609 void Main::showEvent (QShowEvent * )
1611 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1615 MapEditor* Main::currentMapEditor() const
1617 if ( tabWidget->currentPage() &&
1618 tabWidget->currentPage()->inherits( "MapEditor" ) )
1619 return (MapEditor*)tabWidget->currentPage();
1624 void Main::editorChanged(QWidget *)
1626 // Unselect all possibly selected objects
1627 // (Important to update note editor)
1629 for (int i=0;i<=tabWidget->count() -1;i++)
1632 me=(MapEditor*)tabWidget->page(i);
1635 currentMapEditor()->reselect();
1637 // Update actions to in menus and toolbars according to editor
1641 void Main::fileNew()
1643 QString fn="unnamed";
1644 MapEditor* me = new MapEditor ( NULL);
1645 tabWidget->addTab (me,fn);
1646 tabWidget->showPage(me);
1647 me->viewport()->setFocus();
1648 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1649 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1651 // For the very first map we do not have flagrows yet...
1655 void Main::fileNewCopy()
1657 QString fn="unnamed";
1658 MapEditor* oldME =currentMapEditor();
1662 MapEditor* newME = new MapEditor ( NULL);
1665 tabWidget->addTab (newME,fn);
1666 tabWidget->showPage(newME);
1667 newME->viewport()->setFocus();
1668 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1669 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1670 // For the very first map we do not have flagrows yet...
1671 newME->select("mc:");
1672 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1678 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1680 ErrorCode err=success;
1682 // fn is usually the archive, mapfile the file after uncompressing
1685 // Make fn absolute (needed for unzip)
1686 fn=QDir (fn).absPath();
1692 // Check, if map is already loaded
1694 while (i<=tabWidget->count() -1)
1696 me=(MapEditor*)tabWidget->page(i);
1697 if (me->getFilePath() == fn)
1699 // Already there, ask for confirmation
1700 QMessageBox mb( vymName,
1701 tr("The map %1\nis already opened."
1702 "Opening the same map in multiple editors may lead \n"
1703 "to confusion when finishing working with vym."
1704 "Do you want to").arg(fn),
1705 QMessageBox::Warning,
1706 QMessageBox::Yes | QMessageBox::Default,
1707 QMessageBox::Cancel | QMessageBox::Escape,
1708 QMessageBox::NoButton);
1709 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1710 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1713 case QMessageBox::Yes:
1715 i=tabWidget->count();
1717 case QMessageBox::Cancel:
1729 if ( !fn.isEmpty() )
1731 me = currentMapEditor();
1732 int tabIndex=tabWidget->currentPageIndex();
1733 // Check first, if mapeditor exists
1734 // If it is not default AND we want a new map,
1735 // create a new mapeditor in a new tab
1736 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1738 me= new MapEditor ( NULL);
1739 tabWidget->addTab (me,fn);
1740 tabIndex=tabWidget->indexOf (me);
1741 tabWidget->setCurrentPage (tabIndex);
1742 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1743 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1746 // Check, if file exists (important for creating new files
1747 // from command line
1748 if (!QFile(fn).exists() )
1750 QMessageBox mb( vymName,
1751 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1752 QMessageBox::Question,
1754 QMessageBox::Cancel | QMessageBox::Default,
1755 QMessageBox::NoButton );
1757 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1758 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1761 case QMessageBox::Yes:
1763 currentMapEditor()->setFilePath(fn);
1764 tabWidget->setTabLabel (currentMapEditor(),
1765 currentMapEditor()->getFileName() );
1766 statusBar()->message( "Created " + fn , statusbarTime );
1769 case QMessageBox::Cancel:
1770 // don't create new map
1771 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1778 //tabWidget->currentPage() won't be NULL here, because of above...
1779 tabWidget->showPage(me);
1780 me->viewport()->setFocus();
1782 // Create temporary directory for packing
1784 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1787 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1788 tr("Couldn't create temporary directory before load\n"));
1792 // Try to unzip file
1793 err=unzipDir (tmpMapDir,fn);
1797 me->setZipped(false);
1800 me->setZipped(true);
1802 // Look for mapname.xml
1803 mapfile= fn.left(fn.findRev(".",-1,true));
1804 mapfile=mapfile.section( '/', -1 );
1805 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1806 if (!file.exists() )
1808 // mapname.xml does not exist, well,
1809 // maybe someone renamed the mapname.vym file...
1810 // Try to find any .xml in the toplevel
1811 // directory of the .vym file
1812 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1813 if (flist.count()==1)
1815 // Only one entry, take this one
1816 mapfile=tmpMapDir + "/"+flist.first();
1819 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1820 *it=tmpMapDir + "/" + *it;
1821 // TODO Multiple entries, load all (but only the first one into this ME)
1822 //mainWindow->fileLoadFromTmp (flist);
1823 //returnCode=1; // Silently forget this attempt to load
1824 qWarning ("MainWindow::load (fn) multimap found...");
1827 if (flist.isEmpty() )
1829 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1830 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1833 } //file doesn't exist
1835 mapfile=file.name();
1840 // Save existing filename in case we import
1841 QString fn_org=me->getFilePath();
1843 // Finally load map into mapEditor
1844 me->setFilePath (mapfile,fn);
1845 err=me->load(mapfile,lmode,ftype);
1847 // Restore old (maybe empty) filepath, if this is an import
1849 me->setFilePath (fn_org);
1852 // Finally check for errors and go home
1855 if (lmode==NewMap) fileCloseMap();
1856 statusBar()->message( "Could not load " + fn, statusbarTime );
1861 me->setFilePath (fn);
1862 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1863 if (fn.left(9)!="/tmp/vym-")
1865 // Only append to lastMaps if not loaded from a tmpDir
1866 // e.g. imported bookmarks are in a tmpDir
1867 addRecentMap(me->getFilePath() );
1869 actionFilePrint->setEnabled (true);
1871 statusBar()->message( "Loaded " + fn, statusbarTime );
1875 removeDir (QDir(tmpMapDir));
1881 void Main::fileLoad(const LoadMode &lmode)
1883 QStringList filters;
1884 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1885 QFileDialog *fd=new QFileDialog( this);
1886 fd->setDir (lastFileDir);
1887 fd->setFileMode (QFileDialog::ExistingFiles);
1888 fd->setFilters (filters);
1892 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1895 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1898 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1904 if ( fd->exec() == QDialog::Accepted )
1906 lastFileDir=fd->directory().path();
1907 QStringList flist = fd->selectedFiles();
1908 QStringList::Iterator it = flist.begin();
1909 while( it != flist.end() )
1912 fileLoad(*it, lmode);
1919 void Main::fileLoad()
1924 void Main::fileLoadRecent()
1926 QAction *action = qobject_cast<QAction *>(sender());
1928 fileLoad (action->data().toString(), NewMap);
1931 void Main::addRecentMap (const QString &fileName)
1934 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1935 files.removeAll(fileName);
1936 files.prepend(fileName);
1937 while (files.size() > MaxRecentFiles)
1940 settings.setValue("/mainwindow/recentFileList", files);
1942 setupRecentMapsMenu();
1945 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1947 // tmp dir for zipping
1951 ErrorCode err=success;
1953 QString safeFilePath;
1955 bool saveZipped=me->saveZipped();
1959 QString fn=me->getFilePath();
1960 // filename=unnamed, filepath="" in constructor of mapEditor
1961 if ( !fn.isEmpty() )
1963 // We have a filepath, go on saving
1964 // First remove existing file, we
1965 // don't want to add to old zip archives
1969 QMessageBox::warning( 0, tr( "Save Error" ),
1970 fn+ tr("\ncould not be removed before saving"));
1972 // Look, if we should zip the data:
1975 QMessageBox mb( vymName,
1976 tr("The map %1\ndid not use the compressed "
1977 "vym file format.\nWriting it uncompressed will also write images \n"
1978 "and flags and thus may overwrite files in the "
1979 "given directory\n\nDo you want to write the map").arg(fn),
1980 QMessageBox::Warning,
1981 QMessageBox::Yes | QMessageBox::Default,
1983 QMessageBox::Cancel | QMessageBox::Escape);
1984 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1985 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1986 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1989 case QMessageBox::Yes:
1990 // save compressed (default file format)
1993 case QMessageBox::No:
1994 // save uncompressed
1997 case QMessageBox::Cancel:
2006 // Create temporary directory for packing
2008 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2011 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2012 tr("Couldn't create temporary directory before save\n"));
2016 safeFilePath=me->getFilePath();
2017 me->setFilePath (tmpMapDir+"/"+
2018 me->getMapName()+ ".xml",
2020 me->save (savemode);
2021 me->setFilePath (safeFilePath);
2023 zipDir (tmpMapDir,fn);
2028 safeFilePath=me->getFilePath();
2029 me->setFilePath (fn, safeFilePath);
2030 me->save (savemode);
2031 me->setFilePath (safeFilePath);
2033 } // filepath available
2036 // We have no filepath yet,
2037 // call fileSaveAs() now, this will call fileSave()
2039 // First switch to editor
2040 tabWidget->setCurrentWidget (me);
2041 fileSaveAs(savemode);
2045 if (saveZipped && !tmpMapDir.isEmpty())
2047 removeDir (QDir(tmpMapDir));
2051 statusBar()->message(
2052 tr("Saved %1").arg(me->getFilePath()),
2054 addRecentMap (me->getFilePath() );
2056 statusBar()->message(
2057 tr("Couldn't save ").arg(me->getFilePath()),
2061 void Main::fileSave()
2063 fileSave (currentMapEditor(), CompleteMap);
2066 void Main::fileSave(MapEditor *me)
2068 fileSave (me,CompleteMap);
2071 void Main::fileSaveAs(const SaveMode& savemode)
2075 if (currentMapEditor())
2077 if (savemode==CompleteMap)
2078 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2080 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2081 if ( !fn.isEmpty() )
2083 // Check for existing file
2084 if (QFile (fn).exists())
2086 QMessageBox mb( vymName,
2087 tr("The file %1\nexists already. Do you want to").arg(fn),
2088 QMessageBox::Warning,
2089 QMessageBox::Yes | QMessageBox::Default,
2090 QMessageBox::Cancel | QMessageBox::Escape,
2091 QMessageBox::NoButton);
2092 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2093 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2096 case QMessageBox::Yes:
2099 case QMessageBox::Cancel:
2106 // New file, add extension to filename, if missing
2107 // This is always .vym or .vyp, depending on savemode
2108 if (savemode==CompleteMap)
2110 if (!fn.contains (".vym") && !fn.contains (".xml"))
2114 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2123 currentMapEditor()->setFilePath(fn);
2124 fileSave(currentMapEditor(), savemode);
2127 if (savemode==CompleteMap)
2128 tabWidget->setTabLabel (currentMapEditor(),
2129 currentMapEditor()->getFileName() );
2135 void Main::fileSaveAs()
2137 fileSaveAs (CompleteMap);
2140 void Main::fileImportKDEBookmarks()
2142 ImportKDEBookmarks im;
2144 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2145 currentMapEditor()->setFilePath ("");
2148 void Main::fileImportFirefoxBookmarks()
2150 Q3FileDialog *fd=new Q3FileDialog( this);
2151 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2152 fd->setMode (Q3FileDialog::ExistingFiles);
2153 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2154 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2157 if ( fd->exec() == QDialog::Accepted )
2159 ImportFirefoxBookmarks im;
2160 QStringList flist = fd->selectedFiles();
2161 QStringList::Iterator it = flist.begin();
2162 while( it != flist.end() )
2165 if (im.transform() &&
2166 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2167 currentMapEditor() )
2168 currentMapEditor()->setFilePath ("");
2175 void Main::fileImportFreemind()
2177 QStringList filters;
2178 filters <<"Freemind map (*.mm)"<<"All files (*)";
2179 QFileDialog *fd=new QFileDialog( this);
2180 fd->setDir (lastFileDir);
2181 fd->setFileMode (QFileDialog::ExistingFiles);
2182 fd->setFilters (filters);
2183 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2187 if ( fd->exec() == QDialog::Accepted )
2189 lastFileDir=fd->directory().path();
2190 QStringList flist = fd->selectedFiles();
2191 QStringList::Iterator it = flist.begin();
2192 while( it != flist.end() )
2195 if ( fileLoad (fn,NewMap, FreemindMap) )
2197 currentMapEditor()->setFilePath ("");
2206 void Main::fileImportMM()
2210 Q3FileDialog *fd=new Q3FileDialog( this);
2211 fd->setDir (lastFileDir);
2212 fd->setMode (Q3FileDialog::ExistingFiles);
2213 fd->addFilter ("Mind Manager (*.mmap)");
2214 fd->setCaption(tr("Import")+" "+"Mind Manager");
2217 if ( fd->exec() == QDialog::Accepted )
2219 lastFileDir=fd->dirPath();
2220 QStringList flist = fd->selectedFiles();
2221 QStringList::Iterator it = flist.begin();
2222 while( it != flist.end() )
2225 if (im.transform() &&
2226 success==fileLoad (im.getTransformedFile(),NewMap) &&
2227 currentMapEditor() )
2228 currentMapEditor()->setFilePath ("");
2237 void Main::fileImportDir()
2239 if (currentMapEditor())
2240 currentMapEditor()->importDir();
2243 void Main::fileExportXML()
2245 MapEditor *me=currentMapEditor();
2246 if (me) me->exportXML();
2250 void Main::fileExportXHTML()
2252 MapEditor *me=currentMapEditor();
2253 if (me) me->exportXHTML();
2256 void Main::fileExportImage()
2258 MapEditor *me=currentMapEditor();
2259 if (me) me->exportImage();
2262 void Main::fileExportASCII()
2264 MapEditor *me=currentMapEditor();
2265 if (me) me->exportASCII();
2268 void Main::fileExportCSV() //FIXME not scriptable yet
2270 MapEditor *me=currentMapEditor();
2274 ex.setMapCenter(me->getMapCenter());
2275 ex.addFilter ("CSV (*.csv)");
2276 ex.setDir(lastImageDir);
2277 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2278 if (ex.execDialog() )
2280 me->setExportMode(true);
2282 me->setExportMode(false);
2287 void Main::fileExportLaTeX() //FIXME not scriptable yet
2289 MapEditor *me=currentMapEditor();
2293 ex.setMapCenter(me->getMapCenter());
2294 ex.addFilter ("Tex (*.tex)");
2295 ex.setDir(lastImageDir);
2296 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2297 if (ex.execDialog() )
2299 me->setExportMode(true);
2301 me->setExportMode(false);
2306 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2308 ExportKDEBookmarks ex;
2309 MapEditor *me=currentMapEditor();
2312 ex.setMapCenter (me->getMapCenter() );
2317 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2319 ExportTaskjuggler ex;
2320 MapEditor *me=currentMapEditor();
2323 ex.setMapCenter (me->getMapCenter() );
2324 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2325 ex.setDir(lastImageDir);
2326 ex.addFilter ("Taskjuggler (*.tjp)");
2327 if (ex.execDialog() )
2329 me->setExportMode(true);
2331 me->setExportMode(false);
2336 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2338 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2339 // TODO add preview in dialog
2340 //ImagePreview *p =new ImagePreview (fd);
2341 //fd->setContentsPreviewEnabled( TRUE );
2342 //fd->setContentsPreview( p, p );
2343 //fd->setPreviewMode( QFileDialog::Contents );
2344 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2345 fd->setDir (QDir().current());
2346 if (fd->foundConfig())
2350 if ( fd->exec() == QDialog::Accepted )
2352 QString fn=fd->selectedFile();
2353 if (!fn.contains (".odp"))
2356 //lastImageDir=fn.left(fn.findRev ("/"));
2357 if (currentMapEditor())
2358 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2362 QMessageBox::warning(0,
2364 tr("Couldn't find configuration for export to Open Office\n"));
2368 void Main::fileCloseMap()
2370 if (currentMapEditor())
2372 if (currentMapEditor()->hasChanged())
2374 QMessageBox mb( vymName,
2375 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2376 QMessageBox::Warning,
2377 QMessageBox::Yes | QMessageBox::Default,
2379 QMessageBox::Cancel | QMessageBox::Escape );
2380 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2381 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2384 case QMessageBox::Yes:
2386 fileSave(currentMapEditor(), CompleteMap);
2388 case QMessageBox::No:
2389 // close without saving
2391 case QMessageBox::Cancel:
2396 currentMapEditor()->closeMap();
2397 tabWidget->removePage(currentMapEditor());
2398 if (tabWidget->count()==0)
2399 actionFilePrint->setEnabled (false);
2403 void Main::filePrint()
2405 if (currentMapEditor())
2406 currentMapEditor()->print();
2409 void Main::fileExitVYM()
2411 // Check if one or more editors have changed
2414 for (i=0;i<=tabWidget->count() -1;i++)
2417 me=(MapEditor*)tabWidget->page(i);
2419 // If something changed, ask what to do
2420 if (me->hasChanged())
2422 tabWidget->setCurrentPage(i);
2423 QMessageBox mb( vymName,
2424 tr("This map is not saved yet. Do you want to"),
2425 QMessageBox::Warning,
2426 QMessageBox::Yes | QMessageBox::Default,
2428 QMessageBox::Cancel | QMessageBox::Escape );
2429 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2430 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2433 mb.setActiveWindow();
2434 switch( mb.exec() ) {
2435 case QMessageBox::Yes:
2436 // save (the changed editors) and exit
2437 fileSave(currentMapEditor(), CompleteMap);
2439 case QMessageBox::No:
2440 // exit without saving
2442 case QMessageBox::Cancel:
2443 // don't save and don't exit
2447 } // loop over all MEs
2451 void Main::editUndo()
2453 if (currentMapEditor())
2454 currentMapEditor()->undo();
2457 void Main::editRedo()
2459 if (currentMapEditor())
2460 currentMapEditor()->redo();
2463 void Main::gotoHistoryStep (int i)
2465 if (currentMapEditor())
2466 currentMapEditor()->gotoHistoryStep (i);
2469 void Main::editCopy()
2471 if (currentMapEditor())
2472 currentMapEditor()->copy();
2475 void Main::editPaste()
2477 if (currentMapEditor())
2478 currentMapEditor()->paste();
2481 void Main::editCut()
2483 if (currentMapEditor())
2484 currentMapEditor()->cut();
2487 void Main::editOpenFindWindow()
2489 findWindow->popup();
2490 findWindow->raise();
2491 findWindow->setActiveWindow();
2494 void Main::editFind(QString s)
2497 BranchObj *bo=currentMapEditor()->findText(s, cs);
2500 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2503 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2504 tr("No matches found for \"%1\"").arg(s));
2508 void Main::editFindChanged()
2509 { // Notify editor, to abort the current find process
2510 currentMapEditor()->findReset();
2513 void Main::openTabs(QStringList urls)
2515 if (!urls.isEmpty())
2519 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2521 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2523 QString u=urls.takeFirst();
2524 procBrowser = new QProcess( this );
2526 procBrowser->start(browser,args);
2527 if ( !procBrowser->waitForStarted())
2529 // try to set path to browser
2530 QMessageBox::warning(0,
2532 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2533 tr("Please use Settings->")+tr("Set application to open an URL"));
2538 if (browser.contains("konqueror"))
2540 for (int i=0; i<urls.size(); i++)
2543 // Try to open new tab in existing konqueror started previously by vym
2544 p=new QProcess (this);
2546 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2547 "konqueror-mainwindow#1"<<
2550 p->start ("dcop",args);
2551 if ( !p->waitForStarted() ) success=false;
2554 QMessageBox::warning(0,
2556 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2558 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2560 for (int i=0; i<urls.size(); i++)
2562 // Try to open new tab in firefox
2563 p=new QProcess (this);
2564 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2565 p->start (browser,args);
2566 if ( !p->waitForStarted() ) success=false;
2569 QMessageBox::warning(0,
2571 tr("Couldn't start %1 to open a new tab").arg(browser));
2574 QMessageBox::warning(0,
2576 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2580 void Main::editOpenURL()
2583 if (currentMapEditor())
2585 QString url=currentMapEditor()->getURL();
2587 if (url=="") return;
2588 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2589 procBrowser = new QProcess( this );
2591 procBrowser->start(browser,args);
2592 if ( !procBrowser->waitForStarted())
2594 // try to set path to browser
2595 QMessageBox::warning(0,
2597 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2598 tr("Please use Settings->")+tr("Set application to open an URL"));
2603 void Main::editOpenURLTab()
2605 if (currentMapEditor())
2608 urls.append(currentMapEditor()->getURL());
2612 void Main::editOpenMultipleURLTabs()
2614 if (currentMapEditor())
2617 urls=currentMapEditor()->getURLs();
2623 void Main::editURL()
2625 if (currentMapEditor())
2626 currentMapEditor()->editURL();
2629 void Main::editLocalURL()
2631 if (currentMapEditor())
2632 currentMapEditor()->editLocalURL();
2635 void Main::editHeading2URL()
2637 if (currentMapEditor())
2638 currentMapEditor()->editHeading2URL();
2641 void Main::editBugzilla2URL()
2643 if (currentMapEditor())
2644 currentMapEditor()->editBugzilla2URL();
2647 void Main::editFATE2URL()
2649 if (currentMapEditor())
2650 currentMapEditor()->editFATE2URL();
2653 void Main::editHeadingFinished()
2655 // only called from editHeading(), so there is a currentME
2656 MapEditor *me=currentMapEditor();
2659 me->setStateEditHeading (false);
2660 QPoint p; //Not used here, only to find out pos of branch
2662 QString s=me->getHeading(ok,p);
2664 #if defined(Q_OS_MACX)
2666 if (ok && s!=lineedit->text())
2667 me->setHeading(lineedit->text());
2669 lineedit->releaseKeyboard();
2673 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2674 !prevSelection.isEmpty())
2675 me->select(prevSelection);
2680 void Main::editHeading()
2682 if (currentMapEditor())
2684 MapEditor *me=currentMapEditor();
2685 QString oldSel=me->getSelectString();
2687 if (lineedit->isVisible())
2688 editHeadingFinished();
2693 QString s=me->getHeading(ok,p);
2697 me->setStateEditHeading (true);
2698 #if defined(Q_OS_MACX)
2699 p=me->mapToGlobal (p);
2700 QDialog *d =new QDialog(NULL);
2701 QLineEdit *le=new QLineEdit (d);
2702 d->setWindowFlags (Qt::FramelessWindowHint);
2703 d->setGeometry(p.x(),p.y(),230,25);
2704 le->resize (d->width()-10,d->height());
2707 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2708 d->activateWindow();
2710 me->setHeading (le->text());
2713 editHeadingFinished();
2715 p=me->mapTo (this,p);
2716 lineedit->setGeometry(p.x(),p.y(),230,25);
2717 lineedit->setText(s);
2718 lineedit->setCursorPosition(1);
2719 lineedit->selectAll();
2721 lineedit->grabKeyboard();
2722 lineedit->setFocus();
2726 } // currentMapEditor()
2729 void Main::openVymLinks(const QStringList &vl)
2731 for (int j=0; j<vl.size(); j++)
2733 // compare path with already loaded maps
2737 for (i=0;i<=tabWidget->count() -1;i++)
2739 me=(MapEditor*)tabWidget->page(i);
2740 if (vl.at(j)==me->getFilePath() )
2749 if (!QFile(vl.at(j)).exists() )
2750 QMessageBox::critical( 0, tr( "Critical Error" ),
2751 tr("Couldn't open map %1").arg(vl.at(j)));
2754 fileLoad (vl.at(j), NewMap);
2755 tabWidget->setCurrentPage (tabWidget->count()-1);
2758 // Go to tab containing the map
2759 tabWidget->setCurrentPage (index);
2763 void Main::editOpenVymLink()
2765 if (currentMapEditor())
2768 vl.append(currentMapEditor()->getVymLink());
2773 void Main::editOpenMultipleVymLinks()
2775 QString currentVymLink;
2776 if (currentMapEditor())
2778 QStringList vl=currentMapEditor()->getVymLinks();
2783 void Main::editVymLink()
2785 if (currentMapEditor())
2786 currentMapEditor()->editVymLink();
2789 void Main::editDeleteVymLink()
2791 if (currentMapEditor())
2792 currentMapEditor()->deleteVymLink();
2795 void Main::editToggleHideExport()
2797 if (currentMapEditor())
2798 currentMapEditor()->toggleHideExport();
2801 void Main::editMapInfo()
2803 if (currentMapEditor())
2804 currentMapEditor()->editMapInfo();
2807 void Main::editMoveUp()
2809 if (currentMapEditor())
2810 currentMapEditor()->moveBranchUp();
2813 void Main::editMoveDown()
2815 if (currentMapEditor())
2816 currentMapEditor()->moveBranchDown();
2819 void Main::editToggleScroll()
2821 if (currentMapEditor())
2823 currentMapEditor()->toggleScroll();
2827 void Main::editUnscrollChilds()
2829 if (currentMapEditor())
2830 currentMapEditor()->unscrollChilds();
2833 void Main::editNewBranch()
2835 MapEditor *me=currentMapEditor();
2836 if (!lineedit->isVisible() && me)
2838 BranchObj *bo=(BranchObj*)me->getSelection();
2839 BranchObj *newbo=me->addNewBranch(0);
2841 prevSelection=bo->getSelectString();
2843 me->select (newbo->getSelectString());
2847 if (actionSettingsAutoEditNewBranch->isOn())
2852 if (!prevSelection.isEmpty())
2854 me->select(prevSelection);
2861 void Main::editNewBranchBefore()
2863 MapEditor *me=currentMapEditor();
2864 if (!lineedit->isVisible() && me)
2866 BranchObj *bo=(BranchObj*)me->getSelection();
2867 BranchObj *newbo=me->addNewBranchBefore();
2870 me->select (newbo->getSelectString());
2874 if (actionSettingsAutoEditNewBranch->isOn())
2876 if (!actionSettingsAutoSelectNewBranch->isOn())
2877 prevSelection=bo->getSelectString();
2883 void Main::editNewBranchAbove()
2885 MapEditor *me=currentMapEditor();
2886 if (!lineedit->isVisible() && me)
2888 BranchObj *bo=(BranchObj*)me->getSelection();
2889 BranchObj *newbo=me->addNewBranch (-1);
2892 me->select (newbo->getSelectString());
2896 if (actionSettingsAutoEditNewBranch->isOn())
2898 if (!actionSettingsAutoSelectNewBranch->isOn())
2899 prevSelection=bo->getSelectString();
2905 void Main::editNewBranchBelow()
2907 MapEditor *me=currentMapEditor();
2908 if (!lineedit->isVisible() && me)
2910 BranchObj *bo=(BranchObj*)me->getSelection();
2911 BranchObj *newbo=me->addNewBranch (1);
2914 me->select (newbo->getSelectString());
2918 if (actionSettingsAutoEditNewBranch->isOn())
2920 if (!actionSettingsAutoSelectNewBranch->isOn())
2921 prevSelection=bo->getSelectString();
2927 void Main::editImportAdd()
2929 fileLoad (ImportAdd);
2932 void Main::editImportReplace()
2934 fileLoad (ImportReplace);
2937 void Main::editSaveBranch()
2939 fileSaveAs (PartOfMap);
2942 void Main::editDeleteKeepChilds()
2944 if (currentMapEditor())
2945 currentMapEditor()->deleteKeepChilds();
2948 void Main::editDeleteChilds()
2950 if (currentMapEditor())
2951 currentMapEditor()->deleteChilds();
2954 void Main::editDeleteSelection()
2956 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2957 currentMapEditor()->deleteSelection();
2960 void Main::editUpperBranch()
2962 if (currentMapEditor())
2963 currentMapEditor()->selectUpperBranch();
2966 void Main::editLowerBranch()
2968 if (currentMapEditor())
2969 currentMapEditor()->selectLowerBranch();
2972 void Main::editLeftBranch()
2974 if (currentMapEditor())
2975 currentMapEditor()->selectLeftBranch();
2978 void Main::editRightBranch()
2980 if (currentMapEditor())
2981 currentMapEditor()->selectRightBranch();
2984 void Main::editFirstBranch()
2986 if (currentMapEditor())
2987 currentMapEditor()->selectFirstBranch();
2990 void Main::editLastBranch()
2992 if (currentMapEditor())
2993 currentMapEditor()->selectLastBranch();
2996 void Main::editLoadImage()
2998 if (currentMapEditor())
2999 currentMapEditor()->loadFloatImage();
3002 void Main::editSaveImage()
3004 if (currentMapEditor())
3005 currentMapEditor()->saveFloatImage();
3008 void Main::editFollowXLink(QAction *a)
3011 if (currentMapEditor())
3012 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3015 void Main::editEditXLink(QAction *a)
3017 if (currentMapEditor())
3018 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3021 void Main::formatSelectColor()
3023 if (currentMapEditor())
3025 QColor col = QColorDialog::getColor((currentColor ), this );
3026 if ( !col.isValid() ) return;
3027 colorChanged( col );
3031 void Main::formatPickColor()
3033 if (currentMapEditor())
3034 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3037 void Main::colorChanged(QColor c)
3039 QPixmap pix( 16, 16 );
3041 actionFormatColor->setIconSet( pix );
3045 void Main::formatColorBranch()
3047 if (currentMapEditor())
3048 currentMapEditor()->colorBranch(currentColor);
3051 void Main::formatColorSubtree()
3053 if (currentMapEditor())
3054 currentMapEditor()->colorSubtree (currentColor);
3057 void Main::formatLinkStyleLine()
3059 if (currentMapEditor())
3060 currentMapEditor()->setMapLinkStyle("StyleLine");
3063 void Main::formatLinkStyleParabel()
3065 if (currentMapEditor())
3066 currentMapEditor()->setMapLinkStyle("StyleParabel");
3069 void Main::formatLinkStylePolyLine()
3071 if (currentMapEditor())
3072 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3075 void Main::formatLinkStylePolyParabel()
3077 if (currentMapEditor())
3078 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3081 void Main::formatSelectBackColor()
3083 if (currentMapEditor())
3084 currentMapEditor()->selectMapBackgroundColor();
3087 void Main::formatSelectBackImage()
3089 if (currentMapEditor())
3090 currentMapEditor()->selectMapBackgroundImage();
3093 void Main::formatSelectLinkColor()
3095 if (currentMapEditor())
3096 currentMapEditor()->selectMapLinkColor();
3099 void Main::formatSelectSelectionColor()
3101 if (currentMapEditor())
3102 currentMapEditor()->selectMapSelectionColor();
3105 void Main::formatToggleLinkColorHint()
3107 currentMapEditor()->toggleMapLinkColorHint();
3111 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3113 if (currentMapEditor())
3114 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3117 void Main::viewZoomReset()
3119 if (currentMapEditor())
3123 currentMapEditor()->setMatrix( m );
3127 void Main::viewZoomIn()
3129 if (currentMapEditor())
3131 QMatrix m = currentMapEditor()->matrix();
3132 m.scale( 1.25, 1.25 );
3133 currentMapEditor()->setMatrix( m );
3137 void Main::viewZoomOut()
3139 if (currentMapEditor())
3141 QMatrix m = currentMapEditor()->matrix();
3142 m.scale( 0.8, 0.8 );
3143 currentMapEditor()->setMatrix( m );
3147 void Main::viewCenter()
3149 MapEditor *me=currentMapEditor();
3152 me->ensureSelectionVisible();
3156 void Main::networkStartServer()
3158 MapEditor *me=currentMapEditor();
3159 if (me) me->newServer();
3162 void Main::networkConnect()
3164 MapEditor *me=currentMapEditor();
3165 if (me) me->connectToServer();
3168 bool Main::settingsPDF()
3170 // Default browser is set in constructor
3172 QString text = QInputDialog::getText(
3173 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3174 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3176 settings.setValue ("/mainwindow/readerPDF",text);
3181 bool Main::settingsURL()
3183 // Default browser is set in constructor
3185 QString text = QInputDialog::getText(
3186 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3187 settings.value("/mainwindow/readerURL").toString()
3190 settings.setValue ("/mainwindow/readerURL",text);
3194 void Main::settingsMacroDir()
3196 QDir defdir=vymBaseDir;
3197 defdir.cd("macros");
3198 if (!defdir.exists())
3200 QDir dir=QFileDialog::getExistingDirectory (
3202 tr ("Directory with vym macros:"),
3203 settings.value ("/macros/macroDir",defdir.path()).toString()
3206 settings.setValue ("/macros/macroDir",dir.path());
3209 void Main::settingsUndoLevels()
3212 int i = QInputDialog::getInteger(
3214 tr("QInputDialog::getInteger()"),
3215 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3218 settings.setValue ("/mapeditor/stepsTotal",i);
3219 QMessageBox::information( this, tr( "VYM -Information:" ),
3220 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3224 void Main::settingsAutosaveToggle()
3226 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3229 void Main::settingsAutosaveTime()
3232 int i = QInputDialog::getInteger(
3234 tr("QInputDialog::getInteger()"),
3235 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3238 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3242 void Main::settingsToggleDelKey()
3244 if (actionSettingsUseDelKey->isOn())
3246 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3249 actionEditDelete->setAccel (QKeySequence (""));
3253 void Main::windowToggleNoteEditor()
3255 if (textEditor->isVisible() )
3256 windowHideNoteEditor();
3258 windowShowNoteEditor();
3261 void Main::windowToggleHistory()
3263 if (historyWindow->isVisible())
3264 historyWindow->hide();
3266 historyWindow->show();
3270 void Main::windowToggleProperty()
3272 if (branchPropertyWindow->isVisible())
3273 branchPropertyWindow->hide();
3275 branchPropertyWindow->show();
3277 if(currentMapEditor())
3279 LinkableMapObj *sel=currentMapEditor()->getSelection();
3280 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3281 typeid(*sel) == typeid(MapCenterObj)))
3283 branchPropertyWindow->setMapEditor(currentMapEditor());
3284 branchPropertyWindow->setBranch((BranchObj*)sel);
3289 branchPropertyWindow->setBranch(NULL);
3292 void Main::windowToggleAntiAlias()
3294 bool b=actionViewToggleAntiAlias->isOn();
3296 for (int i=0;i<tabWidget->count();i++)
3299 me=(MapEditor*)tabWidget->page(i);
3300 me->setAntiAlias(b);
3305 void Main::windowToggleSmoothPixmap()
3307 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3309 for (int i=0;i<tabWidget->count();i++)
3312 me=(MapEditor*)tabWidget->page(i);
3313 me->setSmoothPixmap(b);
3317 void Main::updateHistory(SimpleSettings &undoSet)
3319 historyWindow->update (undoSet);
3322 void Main::updateNoteFlag()
3324 if (currentMapEditor())
3325 currentMapEditor()->updateNoteFlag();
3328 void Main::updateSatellites(MapEditor *me)
3330 branchPropertyWindow->setMapEditor (me);
3333 void Main::updateActions()
3335 MapEditor *me=currentMapEditor();
3338 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3340 // updateActions is also called when NoteEditor is closed
3341 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3342 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3343 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3345 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3346 actionFormatLinkColorHint->setOn(true);
3348 actionFormatLinkColorHint->setOn(false);
3350 switch (me->getMapLinkStyle())
3352 case LinkableMapObj::Line:
3353 actionFormatLinkStyleLine->setOn(true);
3355 case LinkableMapObj::Parabel:
3356 actionFormatLinkStyleParabel->setOn(true);
3358 case LinkableMapObj::PolyLine:
3359 actionFormatLinkStylePolyLine->setOn(true);
3361 case LinkableMapObj::PolyParabel:
3362 actionFormatLinkStylePolyParabel->setOn(true);
3369 QPixmap pix( 16, 16 );
3370 pix.fill( me->getMapBackgroundColor() );
3371 actionFormatBackColor->setIconSet( pix );
3372 pix.fill( me->getSelectionColor() );
3373 actionFormatSelectionColor->setIconSet( pix );
3374 pix.fill( me->getMapDefLinkColor() );
3375 actionFormatLinkColor->setIconSet( pix );
3378 actionFileSave->setEnabled( me->hasChanged() );
3379 if (me->isUndoAvailable())
3380 actionEditUndo->setEnabled( true);
3382 actionEditUndo->setEnabled( false);
3384 if (me->isRedoAvailable())
3385 actionEditRedo->setEnabled( true);
3387 actionEditRedo->setEnabled( false);
3389 LinkableMapObj *selection=me->getSelection();
3392 if ( (typeid(*selection) == typeid(BranchObj)) ||
3393 (typeid(*selection) == typeid(MapCenterObj)) )
3395 BranchObj *bo=(BranchObj*)selection;
3396 // Take care of links
3397 if (bo->countXLinks()==0)
3399 branchXLinksContextMenuEdit->clear();
3400 branchXLinksContextMenuFollow->clear();
3405 branchXLinksContextMenuEdit->clear();
3406 branchXLinksContextMenuFollow->clear();
3407 for (int i=0; i<=bo->countXLinks();i++)
3409 bot=bo->XLinkTargetAt(i);
3412 s=bot->getHeading();
3415 branchXLinksContextMenuFollow->addAction (s);
3416 branchXLinksContextMenuEdit->addAction (s);
3421 standardFlagsDefault->setEnabled (true);
3423 actionEditToggleScroll->setEnabled (true);
3424 if ( bo->isScrolled() )
3425 actionEditToggleScroll->setOn(true);
3427 actionEditToggleScroll->setOn(false);
3429 if ( bo->getURL().isEmpty() )
3431 actionEditOpenURL->setEnabled (false);
3432 actionEditOpenURLTab->setEnabled (false);
3436 actionEditOpenURL->setEnabled (true);
3437 actionEditOpenURLTab->setEnabled (true);
3439 if ( bo->getVymLink().isEmpty() )
3441 actionEditOpenVymLink->setEnabled (false);
3442 actionEditDeleteVymLink->setEnabled (false);
3445 actionEditOpenVymLink->setEnabled (true);
3446 actionEditDeleteVymLink->setEnabled (true);
3449 if (bo->canMoveBranchUp())
3450 actionEditMoveUp->setEnabled (true);
3452 actionEditMoveUp->setEnabled (false);
3453 if (bo->canMoveBranchDown())
3454 actionEditMoveDown->setEnabled (true);
3456 actionEditMoveDown->setEnabled (false);
3459 actionEditToggleHideExport->setEnabled (true);
3460 actionEditToggleHideExport->setOn (bo->hideInExport() );
3462 actionEditCopy->setEnabled (true);
3463 actionEditCut->setEnabled (true);
3464 if (!clipboardEmpty)
3465 actionEditPaste->setEnabled (true);
3467 actionEditPaste->setEnabled (false);
3468 for (int i=0; i<actionListBranches.size(); ++i)
3469 actionListBranches.at(i)->setEnabled(true);
3470 actionEditDelete->setEnabled (true);
3471 actionFormatHideLinkUnselected->setOn
3472 (selection->getHideLinkUnselected());
3474 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3476 FloatObj *fo=(FloatImageObj*)selection;
3478 actionEditOpenURL->setEnabled (false);
3479 actionEditOpenVymLink->setEnabled (false);
3480 actionEditDeleteVymLink->setEnabled (false);
3481 actionEditToggleHideExport->setEnabled (true);
3482 actionEditToggleHideExport->setOn (fo->hideInExport() );
3485 actionEditCopy->setEnabled (true);
3486 actionEditCut->setEnabled (true);
3487 actionEditPaste->setEnabled (false);
3488 for (int i=0; i<actionListBranches.size(); ++i)
3489 actionListBranches.at(i)->setEnabled(false);
3490 actionEditDelete->setEnabled (true);
3491 actionFormatHideLinkUnselected->setOn
3492 ( selection->getHideLinkUnselected());
3493 actionEditMoveUp->setEnabled (false);
3494 actionEditMoveDown->setEnabled (false);
3499 actionEditCopy->setEnabled (false);
3500 actionEditCut->setEnabled (false);
3501 actionEditPaste->setEnabled (false);
3502 for (int i=0; i<actionListBranches.size(); ++i)
3503 actionListBranches.at(i)->setEnabled(false);
3505 actionEditToggleScroll->setEnabled (false);
3506 actionEditOpenURL->setEnabled (false);
3507 actionEditOpenVymLink->setEnabled (false);
3508 actionEditDeleteVymLink->setEnabled (false);
3509 actionEditHeading2URL->setEnabled (false);
3510 actionEditDelete->setEnabled (false);
3511 actionEditMoveUp->setEnabled (false);
3512 actionEditMoveDown->setEnabled (false);
3513 actionEditToggleHideExport->setEnabled (false);
3517 Main::ModMode Main::getModMode()
3519 if (actionModModeColor->isOn()) return ModModeColor;
3520 if (actionModModeCopy->isOn()) return ModModeCopy;
3521 if (actionModModeXLink->isOn()) return ModModeXLink;
3525 bool Main::autoEditNewBranch()
3527 return actionSettingsAutoEditNewBranch->isOn();
3530 bool Main::autoSelectNewBranch()
3532 return actionSettingsAutoSelectNewBranch->isOn();
3535 bool Main::useFlagGroups()
3537 return actionSettingsUseFlagGroups->isOn();
3540 void Main::windowShowNoteEditor()
3542 textEditor->setShowWithMain(true);
3544 actionViewToggleNoteEditor->setOn (true);
3547 void Main::windowHideNoteEditor()
3549 textEditor->setShowWithMain(false);
3551 actionViewToggleNoteEditor->setOn (false);
3554 void Main::setScript (const QString &script)
3556 scriptEditor->setScript (script);
3559 void Main::runScript (const QString &script)
3561 if (currentMapEditor())
3562 currentMapEditor()->runScript (script);
3565 void Main::runScriptEverywhere (const QString &script)
3568 for (int i=0;i<=tabWidget->count() -1;i++)
3570 me=(MapEditor*)tabWidget->page(i);
3571 if (me) me->runScript (script);
3575 void Main::windowNextEditor()
3577 if (tabWidget->currentPageIndex() < tabWidget->count())
3578 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3581 void Main::windowPreviousEditor()
3583 if (tabWidget->currentPageIndex() >0)
3584 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3587 void Main::standardFlagChanged()
3589 if (currentMapEditor())
3590 currentMapEditor()->toggleStandardFlag(sender()->name());
3593 void Main::testFunction1()
3595 if (!currentMapEditor()) return;
3596 currentMapEditor()->testFunction1();
3599 void Main::testFunction2()
3601 if (!currentMapEditor()) return;
3602 currentMapEditor()->testFunction2();
3605 void Main::testCommand()
3607 if (!currentMapEditor()) return;
3608 scriptEditor->show();
3611 QString com = QInputDialog::getText(
3612 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3613 if (ok) currentMapEditor()->parseAtom(com);
3617 void Main::helpDoc()
3619 QString locale = QLocale::system().name();
3621 if (locale.left(2)=="es")
3622 docname="vym_es.pdf";
3626 QStringList searchList;
3628 #if defined(Q_OS_MACX)
3629 searchList << "./vym.app/Contents/Resources/doc";
3631 // default path in SUSE LINUX
3632 searchList <<"/usr/share/doc/packages/vym/doc";
3635 searchList << "doc"; // relative path for easy testing in tarball
3636 searchList << "doc/tex"; // Easy testing working on vym.tex
3637 searchList << "/usr/share/doc/vym"; // Debian
3638 searchList << "/usr/share/doc/packages";// Knoppix
3642 for (int i=0; i<searchList.count(); ++i)
3644 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3645 if (docfile.exists() )
3654 QMessageBox::critical(0,
3655 tr("Critcal error"),
3656 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3661 Process *pdfProc = new Process();
3662 args <<docfile.fileName();
3664 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3665 if ( !pdfProc->waitForStarted() )
3668 QMessageBox::warning(0,
3670 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3671 tr("Please use Settings->")+tr("Set application to open PDF files"));
3678 void Main::helpDemo()
3680 QStringList filters;
3681 filters <<"VYM example map (*.vym)";
3682 QFileDialog *fd=new QFileDialog( this);
3683 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3684 fd->setFileMode (QFileDialog::ExistingFiles);
3685 fd->setFilters (filters);
3686 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3690 if ( fd->exec() == QDialog::Accepted )
3692 lastFileDir=fd->directory().path();
3693 QStringList flist = fd->selectedFiles();
3694 QStringList::Iterator it = flist.begin();
3695 while( it != flist.end() )
3698 fileLoad(*it, NewMap);
3706 void Main::helpAbout()
3709 ad.setName ("aboutwindow");
3710 ad.setMinimumSize(500,500);
3711 ad.resize (QSize (500,500));
3715 void Main::helpAboutQT()
3717 QMessageBox::aboutQt( this, "Qt Application Example" );
3720 void Main::callMacro ()
3722 QAction *action = qobject_cast<QAction *>(sender());
3726 i=action->data().toInt();
3727 QString mDir (settings.value ("macros/macroDir").toString() );
3729 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3731 if ( !f.open( QIODevice::ReadOnly ) )
3733 QMessageBox::warning(0,
3735 tr("Couldn't find a macro at %1.\n").arg(fn)+
3736 tr("Please use Settings->")+tr("Set directory for vym macros"));
3740 QTextStream ts( &f );
3741 QString m= ts.read();
3745 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3746 currentMapEditor()->runScript (m);