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);
161 // width of xLinksMenu
164 // Create tab widget which holds the maps
165 tabWidget= new QTabWidget (this);
166 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
167 this, SLOT( editorChanged( QWidget * ) ) );
169 lineedit=new QLineEdit (this);
172 setCentralWidget(tabWidget);
176 setupFormatActions();
180 setupNetworkActions();
181 setupSettingsActions();
184 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
189 restoreState (settings.value("/mainwindow/state",0).toByteArray());
197 settings.setValue ( "/mainwindow/geometry/size", size() );
198 settings.setValue ( "/mainwindow/geometry/pos", pos() );
199 settings.setValue ("/mainwindow/state",saveState(0));
201 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
202 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
203 settings.setValue( "/version/version", vymVersion );
204 settings.setValue( "/version/builddate", vymBuildDate );
206 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
207 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
208 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
209 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
210 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
211 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
212 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
214 //TODO save scriptEditor settings
216 // call the destructors
218 delete historyWindow;
219 delete branchPropertyWindow;
221 // Remove temporary directory
222 removeDir (QDir(tmpVymDir));
225 void Main::loadCmdLine()
227 /* TODO draw some kind of splashscreen while loading...
233 QStringList flist=options.getFileList();
234 QStringList::Iterator it=flist.begin();
236 while (it !=flist.end() )
238 fileLoad (*it, NewMap);
244 void Main::statusMessage(const QString &s)
246 statusBar()->message( s);
249 void Main::closeEvent (QCloseEvent* )
255 void Main::setupFileActions()
257 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
258 QToolBar *tb = addToolBar( tr ("&Map") );
259 tb->setObjectName ("mapTB");
262 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
263 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
264 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
266 fileMenu->addAction (a);
267 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
269 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
270 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
271 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
272 fileMenu->addAction (a);
273 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
275 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
276 a->setStatusTip (tr( "Open","Status tip File menu" ) );
277 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
279 fileMenu->addAction (a);
280 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
282 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
283 fileMenu->addSeparator();
285 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
286 a->setStatusTip ( tr( "Save","Status tip file menu" ));
287 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
289 fileMenu->addAction (a);
290 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
293 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
294 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
295 fileMenu->addAction (a);
296 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
298 fileMenu->addSeparator();
300 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
302 a = new QAction(tr("KDE Bookmarks"), this);
303 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
304 a->addTo (fileImportMenu);
305 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
307 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
309 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
310 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
311 a->addTo (fileImportMenu);
312 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
315 a = new QAction("Freemind...",this);
316 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
317 fileImportMenu->addAction (a);
318 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
320 a = new QAction("Mind Manager...",this);
321 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
322 fileImportMenu->addAction (a);
323 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
325 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
326 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
327 fileImportMenu->addAction (a);
328 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
330 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
332 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
333 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
334 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
335 fileExportMenu->addAction (a);
337 a = new QAction( "Open Office...", this);
338 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
339 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
340 fileExportMenu->addAction (a);
342 a = new QAction( "Webpage (XHTML)...",this );
343 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
344 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
345 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
346 fileExportMenu->addAction (a);
348 a = new QAction( "Text (ASCII)...", this);
349 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
350 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
351 fileExportMenu->addAction (a);
353 a = new QAction( "Spreadsheet (CSV)...", this);
354 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
355 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
356 fileExportMenu->addAction (a);
358 a = new QAction( tr("KDE Bookmarks","File menu"), this);
359 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
360 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
361 fileExportMenu->addAction (a);
363 a = new QAction( "Taskjuggler...", this );
364 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
365 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
366 fileExportMenu->addAction (a);
368 a = new QAction( "LaTeX...", this);
369 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
370 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
371 fileExportMenu->addAction (a);
373 a = new QAction( "XML..." , this );
374 a->setStatusTip (tr( "Export as %1").arg("XML"));
375 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
376 fileExportMenu->addAction (a);
378 fileMenu->addSeparator();
380 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
381 a->setStatusTip ( tr( "Print" ,"File menu") );
382 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
384 fileMenu->addAction (a);
385 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
388 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
389 a->setStatusTip (tr( "Close Map" ) );
390 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
391 fileMenu->addAction (a);
392 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
394 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
395 a->setStatusTip ( tr( "Exit")+" "+vymName );
396 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
397 fileMenu->addAction (a);
398 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
403 void Main::setupEditActions()
405 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
406 tb->setLabel( "Edit Actions" );
407 tb->setObjectName ("actionsTB");
408 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
412 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
413 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
414 a->setStatusTip (tr( "Undo" ) );
415 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
416 a->setEnabled (false);
418 editMenu->addAction (a);
421 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
422 a->setStatusTip (tr( "Redo" ));
423 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
425 editMenu->addAction (a);
426 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
429 editMenu->addSeparator();
430 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
431 a->setStatusTip ( tr( "Copy" ) );
432 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
433 a->setEnabled (false);
435 editMenu->addAction (a);
436 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
439 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
440 a->setStatusTip ( tr( "Cut" ) );
441 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
442 a->setEnabled (false);
444 editMenu->addAction (a);
446 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
448 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
449 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
450 a->setStatusTip ( tr( "Paste" ) );
451 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
452 a->setEnabled (false);
454 editMenu->addAction (a);
457 // Shortcuts to modify heading:
458 a = new QAction(tr( "Edit heading","Edit menu" ),this);
459 a->setStatusTip ( tr( "edit Heading" ));
460 a->setShortcut ( Qt::Key_Enter); //Edit heading
461 // a->setShortcutContext (Qt::WindowShortcut);
463 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
464 actionListBranches.append(a);
465 a = new QAction( tr( "Edit heading","Edit menu" ), this);
466 a->setStatusTip (tr( "edit Heading" ));
467 a->setShortcut (Qt::Key_Return ); //Edit heading
468 //a->setShortcutContext (Qt::WindowShortcut);
470 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
471 actionListBranches.append(a);
472 editMenu->addAction (a);
474 a = new QAction( tr( "Edit heading","Edit menu" ), this);
475 a->setStatusTip (tr( "edit Heading" ));
476 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
477 a->setShortcutContext (Qt::WindowShortcut);
479 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
480 actionListBranches.append(a);
482 // Shortcut to delete selection
483 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
484 a->setStatusTip (tr( "Delete Selection" ));
485 a->setShortcut ( Qt::Key_Delete); //Delete selection
486 a->setShortcutContext (Qt::WindowShortcut);
488 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
491 // Shortcut to add branch
492 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
493 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
494 alt->setShortcut (Qt::Key_A); //Add branch
495 alt->setShortcutContext (Qt::WindowShortcut);
497 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
498 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
499 a->setStatusTip ( tr( "Add a branch as child of selection" ));
500 a->setShortcut (Qt::Key_Insert); //Add branch
501 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
502 actionListBranches.append(a);
503 #if defined (Q_OS_MACX)
504 // In OSX show different shortcut in menues, the keys work indepently always
505 actionEditAddBranch=alt;
507 actionEditAddBranch=a;
509 editMenu->addAction (actionEditAddBranch);
510 tb->addAction (actionEditAddBranch);
513 // Add branch by inserting it at selection
514 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
515 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
516 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
517 a->setShortcutContext (Qt::WindowShortcut);
519 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
520 a->setEnabled (false);
521 actionListBranches.append(a);
522 actionEditAddBranchBefore=a;
523 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
524 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
525 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
526 a->setShortcutContext (Qt::WindowShortcut);
528 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
529 actionListBranches.append(a);
532 a = new QAction(tr( "Add branch above","Edit menu" ), this);
533 a->setStatusTip ( tr( "Add a branch above selection" ));
534 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
535 a->setShortcutContext (Qt::WindowShortcut);
537 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
538 a->setEnabled (false);
539 actionListBranches.append(a);
540 actionEditAddBranchAbove=a;
541 a = new QAction(tr( "Add branch above","Edit menu" ), this);
542 a->setStatusTip ( tr( "Add a branch above selection" ));
543 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
544 a->setShortcutContext (Qt::WindowShortcut);
546 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
547 actionListBranches.append(a);
550 a = new QAction(tr( "Add branch below","Edit menu" ), this);
551 a->setStatusTip ( tr( "Add a branch below selection" ));
552 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
553 a->setShortcutContext (Qt::WindowShortcut);
555 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
556 a->setEnabled (false);
557 actionListBranches.append(a);
558 actionEditAddBranchBelow=a;
559 a = new QAction(tr( "Add branch below","Edit menu" ), this);
560 a->setStatusTip ( tr( "Add a branch below selection" ));
561 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
562 a->setShortcutContext (Qt::WindowShortcut);
564 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
565 actionListBranches.append(a);
567 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
568 a->setStatusTip ( tr( "Move branch up" ) );
569 a->setShortcut (Qt::Key_PageUp ); // Move branch up
570 a->setEnabled (false);
572 editMenu->addAction (a);
573 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
576 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
577 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
578 a->setStatusTip (tr( "Move branch down" ) );
579 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
580 a->setEnabled (false);
582 editMenu->addAction (a);
583 actionEditMoveDown=a;
586 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
587 a->setShortcut ( Qt::Key_ScrollLock );
588 a->setStatusTip (tr( "Scroll branch" ) );
589 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
591 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
592 alt->setShortcut ( Qt::Key_S ); // Scroll branch
593 alt->setStatusTip (tr( "Scroll branch" ));
594 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
595 #if defined(Q_OS_MACX)
596 actionEditToggleScroll=alt;
598 actionEditToggleScroll=a;
600 actionEditToggleScroll->setEnabled (false);
601 actionEditToggleScroll->setToggleAction(true);
602 tb->addAction (actionEditToggleScroll);
603 editMenu->addAction ( actionEditToggleScroll);
604 editMenu->addAction (actionEditToggleScroll);
607 actionListBranches.append(actionEditToggleScroll);
609 a = new QAction( tr( "Unscroll childs","Edit menu" ), this);
610 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
611 editMenu->addAction (a);
612 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChilds() ) );
614 editMenu->addSeparator();
616 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
617 a->setStatusTip (tr( "Find" ) );
618 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
619 editMenu->addAction (a);
620 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
622 editMenu->addSeparator();
624 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
625 a->setShortcut (Qt::CTRL + Qt::Key_U );
626 a->setShortcut (tr( "Open URL" ));
629 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
632 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
633 a->setStatusTip (tr( "Open URL in new tab" ));
634 //a->setShortcut (Qt::CTRL+Qt::Key_U );
636 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
637 actionEditOpenURLTab=a;
639 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
640 a->setStatusTip (tr( "Open all URLs in subtree" ));
642 actionListBranches.append(a);
643 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
644 actionEditOpenMultipleURLTabs=a;
646 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
647 a->setStatusTip ( tr( "Edit URL" ) );
648 a->setShortcut ( Qt::Key_U );
649 a->setShortcutContext (Qt::WindowShortcut);
650 actionListBranches.append(a);
652 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
655 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
656 a->setStatusTip ( tr( "Edit local URL" ) );
657 a->setShortcut (Qt::SHIFT + Qt::Key_U );
658 a->setShortcutContext (Qt::WindowShortcut);
659 actionListBranches.append(a);
661 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
662 actionEditLocalURL=a;
664 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
665 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
666 a->setEnabled (false);
667 actionListBranches.append(a);
668 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
669 actionEditHeading2URL=a;
671 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
672 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
673 a->setEnabled (false);
674 actionListBranches.append(a);
675 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
676 actionEditBugzilla2URL=a;
678 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
679 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
680 a->setEnabled (false);
681 actionListBranches.append(a);
682 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
683 actionEditFATE2URL=a;
685 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
686 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
688 a->setEnabled (false);
689 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
690 actionEditOpenVymLink=a;
692 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
693 a->setStatusTip ( tr( "Open all vym links in subtree" ));
694 a->setEnabled (false);
695 actionListBranches.append(a);
696 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
697 actionEditOpenMultipleVymLinks=a;
700 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
701 a->setEnabled (false);
702 a->setStatusTip ( tr( "Edit link to another vym map" ));
703 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
704 actionListBranches.append(a);
707 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
708 a->setStatusTip ( tr( "Delete link to another vym map" ));
709 a->setEnabled (false);
710 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
711 actionEditDeleteVymLink=a;
713 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
714 a->setStatusTip ( tr( "Hide object in exports" ) );
715 a->setShortcut (Qt::Key_H );
716 a->setToggleAction(true);
718 a->setEnabled (false);
719 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
720 actionEditToggleHideExport=a;
722 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
723 a->setStatusTip ( tr( "Edit Map Info" ));
724 a->setEnabled (true);
725 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
728 // Import at selection (adding to selection)
729 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
730 a->setStatusTip (tr( "Add map at selection" ));
731 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
732 a->setEnabled (false);
733 actionListBranches.append(a);
734 actionEditImportAdd=a;
736 // Import at selection (replacing selection)
737 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
738 a->setStatusTip (tr( "Replace selection with map" ));
739 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
740 a->setEnabled (false);
741 actionListBranches.append(a);
742 actionEditImportReplace=a;
745 a = new QAction( tr( "Save selection","Edit menu" ), this);
746 a->setStatusTip (tr( "Save selection" ));
747 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
748 a->setEnabled (false);
749 actionListBranches.append(a);
750 actionEditSaveBranch=a;
752 // Only remove branch, not its childs
753 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
754 a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
755 a->setShortcut (Qt::ALT + Qt::Key_Delete );
756 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChilds() ) );
757 a->setEnabled (false);
759 actionListBranches.append(a);
760 actionEditDeleteKeepChilds=a;
762 // Only remove childs of a branch
763 a = new QAction( tr( "Remove childs","Edit menu" ), this);
764 a->setStatusTip (tr( "Remove childs of branch" ));
765 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
766 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChilds() ) );
767 a->setEnabled (false);
768 actionListBranches.append(a);
769 actionEditDeleteChilds=a;
771 // Shortcuts for navigating with cursor:
772 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
773 a->setStatusTip ( tr( "Select upper branch" ));
774 a->setShortcut (Qt::Key_Up );
775 a->setShortcutContext (Qt::WindowShortcut);
777 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
778 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
779 a->setStatusTip (tr( "Select lower branch" ));
780 a->setShortcut ( Qt::Key_Down );
781 a->setShortcutContext (Qt::WindowShortcut);
783 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
784 a = new QAction(tr( "Select left branch","Edit menu" ), this);
785 a->setStatusTip ( tr( "Select left branch" ));
786 a->setShortcut (Qt::Key_Left );
787 a->setShortcutContext (Qt::WindowShortcut);
789 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
790 a = new QAction( tr( "Select child branch","Edit menu" ), this);
791 a->setStatusTip (tr( "Select right branch" ));
792 a->setShortcut (Qt::Key_Right);
793 a->setShortcutContext (Qt::WindowShortcut);
795 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
796 a = new QAction( tr( "Select first branch","Edit menu" ), this);
797 a->setStatusTip (tr( "Select first branch" ));
798 a->setShortcut (Qt::Key_Home );
799 a->setShortcutContext (Qt::WindowShortcut);
801 a->setEnabled (false);
802 editMenu->addAction (a);
803 actionListBranches.append(a);
804 actionEditSelectFirst=a;
805 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
806 a = new QAction( tr( "Select last branch","Edit menu" ),this);
807 a->setStatusTip (tr( "Select last branch" ));
808 a->setShortcut ( Qt::Key_End );
809 a->setShortcutContext (Qt::WindowShortcut);
811 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
812 a->setEnabled (false);
813 editMenu->addAction (a);
814 actionListBranches.append(a);
815 actionEditSelectLast=a;
817 a = new QAction( tr( "Add Image...","Edit menu" ), this);
818 a->setStatusTip (tr( "Add Image" ));
819 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
820 actionEditLoadImage=a;
822 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
823 a->setStatusTip (tr( "Set properties for selection" ));
824 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
825 a->setShortcutContext (Qt::WindowShortcut);
826 a->setToggleAction (true);
828 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
829 actionViewTogglePropertyWindow=a;
833 void Main::setupFormatActions()
835 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
837 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
838 tb->setObjectName ("formatTB");
841 pix.fill (Qt::black);
842 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
843 a->setStatusTip ( tr( "Set Color" ));
844 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
846 formatMenu->addAction (a);
848 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
849 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
850 a->setShortcut (Qt::CTRL + Qt::Key_K );
851 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
852 a->setEnabled (false);
854 formatMenu->addAction (a);
855 actionListBranches.append(a);
856 actionFormatPickColor=a;
858 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
859 a->setStatusTip ( tr( "Color branch" ) );
860 a->setShortcut (Qt::CTRL + Qt::Key_B);
861 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
862 a->setEnabled (false);
864 formatMenu->addAction (a);
865 actionListBranches.append(a);
866 actionFormatColorSubtree=a;
868 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
869 a->setStatusTip ( tr( "Color Subtree" ));
870 a->setShortcut (Qt::CTRL + Qt::Key_T);
871 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
872 a->setEnabled (false);
873 formatMenu->addAction (a);
875 actionListBranches.append(a);
876 actionFormatColorSubtree=a;
878 formatMenu->addSeparator();
879 actionGroupFormatLinkStyles=new QActionGroup ( this);
880 actionGroupFormatLinkStyles->setExclusive (true);
881 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
882 a->setStatusTip (tr( "Line" ));
883 a->setToggleAction(true);
884 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
885 formatMenu->addAction (a);
886 actionFormatLinkStyleLine=a;
887 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
888 a->setStatusTip (tr( "Line" ));
889 a->setToggleAction(true);
890 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
891 formatMenu->addAction (a);
892 actionFormatLinkStyleParabel=a;
893 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
894 a->setStatusTip (tr( "PolyLine" ));
895 a->setToggleAction(true);
896 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
897 formatMenu->addAction (a);
898 actionFormatLinkStylePolyLine=a;
899 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
900 a->setStatusTip (tr( "PolyParabel" ) );
901 a->setToggleAction(true);
902 a->setChecked (true);
903 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
904 formatMenu->addAction (a);
905 actionFormatLinkStylePolyParabel=a;
907 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
908 a->setStatusTip (tr( "Hide link" ));
909 a->setToggleAction(true);
910 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
911 actionFormatHideLinkUnselected=a;
913 formatMenu->addSeparator();
914 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
915 a->setStatusTip (tr( "Use same color for links and headings" ));
916 a->setToggleAction(true);
917 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
918 formatMenu->addAction (a);
919 actionFormatLinkColorHint=a;
921 pix.fill (Qt::white);
922 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
923 a->setStatusTip (tr( "Set Link Color" ));
924 formatMenu->addAction (a);
925 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
926 actionFormatLinkColor=a;
928 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
929 a->setStatusTip (tr( "Set Selection Color" ));
930 formatMenu->addAction (a);
931 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
932 actionFormatSelectionColor=a;
934 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
935 a->setStatusTip (tr( "Set Background Color" ));
936 formatMenu->addAction (a);
937 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
938 actionFormatBackColor=a;
940 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
941 a->setStatusTip (tr( "Set Background image" ));
942 formatMenu->addAction (a);
943 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
944 actionFormatBackImage=a;
948 void Main::setupViewActions()
950 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
951 tb->setLabel( "View Actions" );
952 tb->setObjectName ("viewTB");
953 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
956 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
957 a->setStatusTip ( tr( "Zoom reset" ) );
958 a->setShortcut (Qt::CTRL + Qt::Key_0 );
960 viewMenu->addAction (a);
961 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
963 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
964 a->setStatusTip (tr( "Zoom in" ));
965 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
967 viewMenu->addAction (a);
968 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
970 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
971 a->setStatusTip (tr( "Zoom out" ));
972 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
974 viewMenu->addAction (a);
975 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
977 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
978 a->setStatusTip (tr( "Show selection" ));
979 a->setShortcut (Qt::Key_Period);
981 viewMenu->addAction (a);
982 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
984 viewMenu->addSeparator();
986 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
987 a->setStatusTip ( tr( "Show Note Editor" ));
988 a->setShortcut ( Qt::CTRL + Qt::Key_E );
989 a->setToggleAction(true);
991 viewMenu->addAction (a);
992 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
993 actionViewToggleNoteEditor=a;
995 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
996 a->setStatusTip ( tr( "Show History Window" ));
997 a->setShortcut ( Qt::CTRL + Qt::Key_H );
998 a->setToggleAction(true);
1000 viewMenu->addAction (a);
1001 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1002 actionViewToggleHistoryWindow=a;
1004 viewMenu->addAction (actionViewTogglePropertyWindow);
1006 viewMenu->addSeparator();
1008 a = new QAction(tr( "Antialiasing","View action" ),this );
1009 a->setStatusTip ( tr( "Antialiasing" ));
1010 a->setToggleAction(true);
1011 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1012 viewMenu->addAction (a);
1013 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1014 actionViewToggleAntiAlias=a;
1016 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1017 a->setStatusTip (a->text());
1018 a->setToggleAction(true);
1019 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1020 viewMenu->addAction (a);
1021 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1022 actionViewToggleSmoothPixmapTransform=a;
1024 a = new QAction(tr( "Next Map","View action" ), this);
1025 a->setStatusTip (a->text());
1026 a->setShortcut (Qt::ALT + Qt::Key_N );
1027 viewMenu->addAction (a);
1028 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1030 a = new QAction (tr( "Previous Map","View action" ), this );
1031 a->setStatusTip (a->text());
1032 a->setShortcut (Qt::ALT + Qt::Key_P );
1033 viewMenu->addAction (a);
1034 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1038 void Main::setupModeActions()
1040 //QPopupMenu *menu = new QPopupMenu( this );
1041 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1043 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1044 tb->setObjectName ("modesTB");
1046 actionGroupModModes=new QActionGroup ( this);
1047 actionGroupModModes->setExclusive (true);
1048 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1049 a->setShortcut (Qt::Key_J);
1050 a->setStatusTip ( tr( "Use modifier to color branches" ));
1051 a->setToggleAction(true);
1054 actionModModeColor=a;
1056 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1057 a->setShortcut( Qt::Key_K);
1058 a->setStatusTip( tr( "Use modifier to copy" ));
1059 a->setToggleAction(true);
1061 actionModModeCopy=a;
1063 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1064 a->setShortcut (Qt::Key_L);
1065 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1066 a->setToggleAction(true);
1068 actionModModeXLink=a;
1072 void Main::setupFlagActions()
1074 // Create System Flags
1078 systemFlagsDefault = new FlagRowObj ();
1079 systemFlagsDefault->setVisibility (false);
1080 systemFlagsDefault->setName ("systemFlagsDef");
1082 FlagObj *fo = new FlagObj ();
1083 fo->load(QPixmap(flagsPath+"flag-note.png"));
1084 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1086 fo->load(QPixmap(flagsPath+"flag-url.png"));
1087 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1089 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1090 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1092 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1093 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1095 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1096 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1098 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1099 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1101 // Create Standard Flags
1102 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1103 tb->setObjectName ("standardFlagTB");
1105 standardFlagsDefault = new FlagRowObj ();
1106 standardFlagsDefault->setVisibility (false);
1107 standardFlagsDefault->setName ("standardFlagsDef");
1108 standardFlagsDefault->setToolBar (tb);
1110 fo->load(flagsPath+"flag-exclamationmark.png");
1111 fo->setGroup("standard-mark");
1112 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1114 fo->load(flagsPath+"flag-questionmark.png");
1115 fo->setGroup("standard-mark");
1116 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1118 fo->load(flagsPath+"flag-hook-green.png");
1119 fo->setGroup("standard-hook");
1120 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1122 fo->load(flagsPath+"flag-cross-red.png");
1123 fo->setGroup("standard-hook");
1124 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1127 fo->load(flagsPath+"flag-stopsign.png");
1128 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1130 fo->load(flagsPath+"flag-smiley-good.png");
1131 fo->setGroup("standard-smiley");
1132 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1134 fo->load(flagsPath+"flag-smiley-sad.png");
1135 fo->setGroup("standard-smiley");
1136 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1138 fo->load(flagsPath+"flag-smiley-omg.png");
1139 fo->setGroup("standard-smiley");
1140 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1141 // Original omg.png (in KDE emoticons)
1144 fo->load(flagsPath+"flag-kalarm.png");
1145 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1147 fo->load(flagsPath+"flag-phone.png");
1148 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1150 fo->load(flagsPath+"flag-lamp.png");
1151 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1153 fo->load(flagsPath+"flag-arrow-up.png");
1154 fo->setGroup("standard-arrow");
1155 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1157 fo->load(flagsPath+"flag-arrow-down.png");
1158 fo->setGroup("standard-arrow");
1159 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1161 fo->load(flagsPath+"flag-arrow-2up.png");
1162 fo->setGroup("standard-arrow");
1163 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1165 fo->load(flagsPath+"flag-arrow-2down.png");
1166 fo->setGroup("standard-arrow");
1167 setupFlag (fo,tb,avis,"present",tr("Very unimportant!","Standardflag"));
1170 fo->load(flagsPath+"flag-thumb-up.png");
1171 fo->setGroup("standard-thumb");
1172 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1174 fo->load(flagsPath+"flag-thumb-down.png");
1175 fo->setGroup("standard-thumb");
1176 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1179 fo->load(flagsPath+"flag-rose.png");
1180 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1182 fo->load(flagsPath+"flag-heart.png");
1183 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1185 fo->load(flagsPath+"flag-present.png");
1186 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1188 fo->load(flagsPath+"flag-flash.png");
1189 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1191 // Original: xsldbg_output.png
1192 fo->load(flagsPath+"flag-info.png");
1193 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1195 // Original khelpcenter.png
1196 fo->load(flagsPath+"flag-lifebelt.png");
1197 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1203 fo->load(flagsPath+"freemind/warning.png");
1204 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1206 for (int i=1; i<8; i++)
1208 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1209 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1212 fo->load(flagsPath+"freemind/back.png");
1213 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1215 fo->load(flagsPath+"freemind/forward.png");
1216 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1218 fo->load(flagsPath+"freemind/attach.png");
1219 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1221 fo->load(flagsPath+"freemind/clanbomber.png");
1222 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1224 fo->load(flagsPath+"freemind/desktopnew.png");
1225 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1227 fo->load(flagsPath+"freemind/flag.png");
1228 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1231 fo->load(flagsPath+"freemind/gohome.png");
1232 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1235 fo->load(flagsPath+"freemind/kaddressbook.png");
1236 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1238 fo->load(flagsPath+"freemind/knotify.png");
1239 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1241 fo->load(flagsPath+"freemind/korn.png");
1242 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1244 fo->load(flagsPath+"freemind/mail.png");
1245 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1247 fo->load(flagsPath+"freemind/password.png");
1248 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1250 fo->load(flagsPath+"freemind/pencil.png");
1251 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1253 fo->load(flagsPath+"freemind/stop.png");
1254 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1256 fo->load(flagsPath+"freemind/wizard.png");
1257 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1259 fo->load(flagsPath+"freemind/xmag.png");
1260 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1262 fo->load(flagsPath+"freemind/bell.png");
1263 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1265 fo->load(flagsPath+"freemind/bookmark.png");
1266 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1268 fo->load(flagsPath+"freemind/penguin.png");
1269 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1271 fo->load(flagsPath+"freemind/licq.png");
1272 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1277 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1280 fo->setToolTip (tooltip);
1281 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1287 fo->setAlwaysVisible(aw);
1288 a->setCheckable(true);
1289 a->setObjectName(fo->getName());
1290 a->setToolTip(tooltip);
1291 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1292 standardFlagsDefault->addFlag (fo);
1296 systemFlagsDefault->addFlag (fo);
1300 void Main::setupNetworkActions()
1302 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1304 QMenu *netMenu = menuBar()->addMenu( "&Network" );
1308 a = new QAction( "Start TCPserver for MapEditor",this);
1309 //a->setStatusTip ( "Set application to open pdf files"));
1310 a->setShortcut ( Qt::Key_T ); //New TCP server
1311 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1312 netMenu->addAction (a);
1314 a = new QAction( "Connect MapEditor to server",this);
1315 //a->setStatusTip ( "Set application to open pdf files"));
1316 a->setShortcut ( Qt::Key_C ); // Connect to server
1317 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1318 netMenu->addAction (a);
1322 void Main::setupSettingsActions()
1324 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1328 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1329 a->setStatusTip ( tr( "Set application to open pdf files"));
1330 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1331 settingsMenu->addAction (a);
1333 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1334 a->setStatusTip( tr( "Set application to open external links"));
1335 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1336 settingsMenu->addAction (a);
1338 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1339 a->setStatusTip( tr( "Set path for macros"));
1340 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1341 settingsMenu->addAction (a);
1343 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1344 a->setStatusTip( tr( "Set number of undo levels"));
1345 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1346 settingsMenu->addAction (a);
1348 settingsMenu->addSeparator();
1350 a = new QAction( tr( "Autosave","Settings action"), this);
1351 a->setStatusTip( tr( "Autosave"));
1352 a->setToggleAction(true);
1353 a->setOn ( settings.value ("/mapeditor/autosave/use",true).toBool());
1354 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1355 settingsMenu->addAction (a);
1356 actionSettingsAutosaveToggle=a;
1358 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1359 a->setStatusTip( tr( "Autosave time"));
1360 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1361 settingsMenu->addAction (a);
1362 actionSettingsAutosaveTime=a;
1364 settingsMenu->addSeparator();
1366 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1367 a->setStatusTip( tr( "Edit branch after adding it" ));
1368 a->setToggleAction(true);
1369 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1370 settingsMenu->addAction (a);
1371 actionSettingsAutoEditNewBranch=a;
1373 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1374 a->setStatusTip( tr( "Select branch after adding it" ));
1375 a->setToggleAction(true);
1376 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1377 settingsMenu->addAction (a);
1378 actionSettingsAutoSelectNewBranch=a;
1380 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1381 a->setStatusTip( tr( "Select heading before editing" ));
1382 a->setToggleAction(true);
1383 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1384 settingsMenu->addAction (a);
1385 actionSettingsAutoSelectText=a;
1387 a= new QAction( tr( "Delete key","Settings action" ), this);
1388 a->setStatusTip( tr( "Delete key for deleting branches" ));
1389 a->setToggleAction(true);
1390 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1391 settingsMenu->addAction (a);
1392 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1393 actionSettingsUseDelKey=a;
1395 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1396 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1397 a->setToggleAction(true);
1398 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1399 settingsMenu->addAction (a);
1400 actionSettingsUseFlagGroups=a;
1402 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1403 a->setStatusTip( tr( "Use hide flag during exports " ));
1404 a->setToggleAction(true);
1405 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1406 settingsMenu->addAction (a);
1407 actionSettingsUseHideExport=a;
1411 void Main::setupTestActions()
1413 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1416 a = new QAction( "Test function 1" , this);
1417 a->setStatusTip( "Call test function 1" );
1418 testMenu->addAction (a);
1419 //a->setShortcut (Qt::Key_F4 );
1420 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1422 a = new QAction( "Test function 2" , this);
1423 a->setStatusTip( "Call test function 2" );
1424 //a->setShortcut (Qt::Key_F4 );
1425 testMenu->addAction (a);
1426 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1428 a = new QAction( "Command" , this);
1429 a->setStatusTip( "Enter command to call in editor" );
1430 //a->setShortcut (Qt::Key_F5 );
1431 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1432 testMenu->addAction (a);
1436 void Main::setupHelpActions()
1438 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1441 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1442 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1443 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1444 helpMenu->addAction (a);
1446 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1447 a->setStatusTip( tr( "Open VYM example maps " ));
1448 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1449 helpMenu->addAction (a);
1451 a = new QAction( tr( "About VYM","Help action" ), this);
1452 a->setStatusTip( tr( "About VYM")+vymName);
1453 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1454 helpMenu->addAction (a);
1456 a = new QAction( tr( "About QT","Help action" ), this);
1457 a->setStatusTip( tr( "Information about QT toolkit" ));
1458 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1459 helpMenu->addAction (a);
1463 void Main::setupContextMenus()
1467 // Context Menu for branch or mapcenter
1468 branchContextMenu =new QMenu (this);
1469 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1470 branchContextMenu->addSeparator();
1473 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1474 branchAddContextMenu->addAction (actionEditPaste );
1475 branchAddContextMenu->addAction ( actionEditAddBranch );
1476 branchAddContextMenu->addAction ( actionEditAddBranchBefore );
1477 branchAddContextMenu->addAction ( actionEditAddBranchAbove);
1478 branchAddContextMenu->addAction ( actionEditAddBranchBelow );
1479 branchAddContextMenu->addSeparator();
1480 branchAddContextMenu->addAction ( actionEditImportAdd );
1481 branchAddContextMenu->addAction ( actionEditImportReplace );
1484 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1485 branchRemoveContextMenu->addAction (actionEditCut);
1486 branchRemoveContextMenu->addAction ( actionEditDelete );
1487 branchRemoveContextMenu->addAction ( actionEditDeleteKeepChilds );
1488 branchRemoveContextMenu->addAction ( actionEditDeleteChilds );
1491 actionEditSaveBranch->addTo( branchContextMenu );
1493 branchContextMenu->addSeparator();
1494 branchContextMenu->addAction ( actionEditLoadImage);
1496 // Submenu for Links (URLs, vymLinks)
1497 branchLinksContextMenu =new QMenu (this);
1499 branchContextMenu->addSeparator();
1500 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1501 branchLinksContextMenu->addAction ( actionEditOpenURL );
1502 branchLinksContextMenu->addAction ( actionEditOpenURLTab );
1503 branchLinksContextMenu->addAction ( actionEditOpenMultipleURLTabs );
1504 branchLinksContextMenu->addAction ( actionEditURL );
1505 branchLinksContextMenu->addAction ( actionEditLocalURL );
1506 branchLinksContextMenu->addAction ( actionEditHeading2URL );
1507 branchLinksContextMenu->addAction ( actionEditBugzilla2URL );
1508 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1510 branchLinksContextMenu->addAction ( actionEditFATE2URL );
1512 branchLinksContextMenu->addSeparator();
1513 branchLinksContextMenu->addAction ( actionEditOpenVymLink );
1514 branchLinksContextMenu->addAction ( actionEditOpenMultipleVymLinks );
1515 branchLinksContextMenu->addAction ( actionEditVymLink );
1516 branchLinksContextMenu->addAction ( actionEditDeleteVymLink );
1519 // Context Menu for XLinks in a branch menu
1520 // This will be populated "on demand" in MapEditor::updateActions
1521 branchContextMenu->addSeparator();
1522 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1523 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1524 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1525 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1528 // Context menu for floatimage
1529 floatimageContextMenu =new QMenu (this);
1530 a= new QAction (tr ("Save image","Context action"),this);
1531 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1532 floatimageContextMenu->addAction (a);
1534 floatimageContextMenu->addSeparator();
1535 actionEditCopy->addTo( floatimageContextMenu );
1536 actionEditCut->addTo( floatimageContextMenu );
1538 floatimageContextMenu->addSeparator();
1539 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1542 // Context menu for canvas
1543 canvasContextMenu =new QMenu (this);
1544 actionEditMapInfo->addTo( canvasContextMenu );
1545 canvasContextMenu->insertSeparator();
1546 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1547 canvasContextMenu->insertSeparator();
1548 actionFormatLinkColorHint->addTo( canvasContextMenu );
1549 actionFormatLinkColor->addTo( canvasContextMenu );
1550 actionFormatSelectionColor->addTo( canvasContextMenu );
1551 actionFormatBackColor->addTo( canvasContextMenu );
1552 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1554 // Menu for last opened files
1556 for (int i = 0; i < MaxRecentFiles; ++i)
1558 recentFileActions[i] = new QAction(this);
1559 recentFileActions[i]->setVisible(false);
1560 fileLastMapsMenu->addAction(recentFileActions[i]);
1561 connect(recentFileActions[i], SIGNAL(triggered()),
1562 this, SLOT(fileLoadRecent()));
1564 setupRecentMapsMenu();
1567 void Main::setupRecentMapsMenu()
1569 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1571 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1573 for (int i = 0; i < numRecentFiles; ++i) {
1574 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1575 recentFileActions[i]->setText(text);
1576 recentFileActions[i]->setData(files[i]);
1577 recentFileActions[i]->setVisible(true);
1579 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1580 recentFileActions[j]->setVisible(false);
1583 void Main::setupMacros()
1585 for (int i = 0; i <= 11; i++)
1587 macroActions[i] = new QAction(this);
1588 macroActions[i]->setData(i);
1589 addAction (macroActions[i]);
1590 connect(macroActions[i], SIGNAL(triggered()),
1591 this, SLOT(callMacro()));
1593 macroActions[0]->setShortcut ( Qt::Key_F1 );
1594 macroActions[1]->setShortcut ( Qt::Key_F2 );
1595 macroActions[2]->setShortcut ( Qt::Key_F3 );
1596 macroActions[3]->setShortcut ( Qt::Key_F4 );
1597 macroActions[4]->setShortcut ( Qt::Key_F5 );
1598 macroActions[5]->setShortcut ( Qt::Key_F6 );
1599 macroActions[6]->setShortcut ( Qt::Key_F7 );
1600 macroActions[7]->setShortcut ( Qt::Key_F8 );
1601 macroActions[8]->setShortcut ( Qt::Key_F9 );
1602 macroActions[9]->setShortcut ( Qt::Key_F10 );
1603 macroActions[10]->setShortcut ( Qt::Key_F11 );
1604 macroActions[11]->setShortcut ( Qt::Key_F12 );
1607 void Main::hideEvent (QHideEvent * )
1609 if (!textEditor->isMinimized() ) textEditor->hide();
1612 void Main::showEvent (QShowEvent * )
1614 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1618 MapEditor* Main::currentMapEditor() const
1620 if ( tabWidget->currentPage() &&
1621 tabWidget->currentPage()->inherits( "MapEditor" ) )
1622 return (MapEditor*)tabWidget->currentPage();
1627 void Main::editorChanged(QWidget *)
1629 // Unselect all possibly selected objects
1630 // (Important to update note editor)
1632 for (int i=0;i<=tabWidget->count() -1;i++)
1635 me=(MapEditor*)tabWidget->page(i);
1638 currentMapEditor()->reselect();
1640 // Update actions to in menus and toolbars according to editor
1644 void Main::fileNew()
1646 QString fn="unnamed";
1647 MapEditor* me = new MapEditor ( NULL);
1648 tabWidget->addTab (me,fn);
1649 tabWidget->showPage(me);
1650 me->viewport()->setFocus();
1651 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1652 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1654 // For the very first map we do not have flagrows yet...
1658 void Main::fileNewCopy()
1660 QString fn="unnamed";
1661 MapEditor* oldME =currentMapEditor();
1665 MapEditor* newME = new MapEditor ( NULL);
1668 tabWidget->addTab (newME,fn);
1669 tabWidget->showPage(newME);
1670 newME->viewport()->setFocus();
1671 newME->setAntiAlias (actionViewToggleAntiAlias->isOn());
1672 newME->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1673 // For the very first map we do not have flagrows yet...
1674 newME->select("mc:");
1675 newME->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1681 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1683 ErrorCode err=success;
1685 // fn is usually the archive, mapfile the file after uncompressing
1688 // Make fn absolute (needed for unzip)
1689 fn=QDir (fn).absPath();
1695 // Check, if map is already loaded
1697 while (i<=tabWidget->count() -1)
1699 me=(MapEditor*)tabWidget->page(i);
1700 if (me->getFilePath() == fn)
1702 // Already there, ask for confirmation
1703 QMessageBox mb( vymName,
1704 tr("The map %1\nis already opened."
1705 "Opening the same map in multiple editors may lead \n"
1706 "to confusion when finishing working with vym."
1707 "Do you want to").arg(fn),
1708 QMessageBox::Warning,
1709 QMessageBox::Yes | QMessageBox::Default,
1710 QMessageBox::Cancel | QMessageBox::Escape,
1711 QMessageBox::NoButton);
1712 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1713 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1716 case QMessageBox::Yes:
1718 i=tabWidget->count();
1720 case QMessageBox::Cancel:
1732 if ( !fn.isEmpty() )
1734 me = currentMapEditor();
1735 int tabIndex=tabWidget->currentPageIndex();
1736 // Check first, if mapeditor exists
1737 // If it is not default AND we want a new map,
1738 // create a new mapeditor in a new tab
1739 if ( lmode==NewMap && (!me || !me->isDefault() ) )
1741 me= new MapEditor ( NULL);
1742 tabWidget->addTab (me,fn);
1743 tabIndex=tabWidget->indexOf (me);
1744 tabWidget->setCurrentPage (tabIndex);
1745 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1746 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1749 // Check, if file exists (important for creating new files
1750 // from command line
1751 if (!QFile(fn).exists() )
1753 QMessageBox mb( vymName,
1754 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1755 QMessageBox::Question,
1757 QMessageBox::Cancel | QMessageBox::Default,
1758 QMessageBox::NoButton );
1760 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1761 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1764 case QMessageBox::Yes:
1766 currentMapEditor()->setFilePath(fn);
1767 tabWidget->setTabLabel (currentMapEditor(),
1768 currentMapEditor()->getFileName() );
1769 statusBar()->message( "Created " + fn , statusbarTime );
1772 case QMessageBox::Cancel:
1773 // don't create new map
1774 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1781 //tabWidget->currentPage() won't be NULL here, because of above...
1782 tabWidget->showPage(me);
1783 me->viewport()->setFocus();
1785 // Create temporary directory for packing
1787 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
1790 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1791 tr("Couldn't create temporary directory before load\n"));
1795 // Try to unzip file
1796 err=unzipDir (tmpMapDir,fn);
1800 me->setZipped(false);
1803 me->setZipped(true);
1805 // Look for mapname.xml
1806 mapfile= fn.left(fn.findRev(".",-1,true));
1807 mapfile=mapfile.section( '/', -1 );
1808 QFile file( tmpMapDir + "/" + mapfile + ".xml");
1809 if (!file.exists() )
1811 // mapname.xml does not exist, well,
1812 // maybe someone renamed the mapname.vym file...
1813 // Try to find any .xml in the toplevel
1814 // directory of the .vym file
1815 QStringList flist=QDir (tmpMapDir).entryList("*.xml");
1816 if (flist.count()==1)
1818 // Only one entry, take this one
1819 mapfile=tmpMapDir + "/"+flist.first();
1822 for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it )
1823 *it=tmpMapDir + "/" + *it;
1824 // TODO Multiple entries, load all (but only the first one into this ME)
1825 //mainWindow->fileLoadFromTmp (flist);
1826 //returnCode=1; // Silently forget this attempt to load
1827 qWarning ("MainWindow::load (fn) multimap found...");
1830 if (flist.isEmpty() )
1832 QMessageBox::critical( 0, tr( "Critical Load Error" ),
1833 tr("Couldn't find a map (*.xml) in .vym archive.\n"));
1836 } //file doesn't exist
1838 mapfile=file.name();
1843 // Save existing filename in case we import
1844 QString fn_org=me->getFilePath();
1846 // Finally load map into mapEditor
1847 me->setFilePath (mapfile,fn);
1848 err=me->load(mapfile,lmode,ftype);
1850 // Restore old (maybe empty) filepath, if this is an import
1852 me->setFilePath (fn_org);
1855 // Finally check for errors and go home
1858 if (lmode==NewMap) fileCloseMap();
1859 statusBar()->message( "Could not load " + fn, statusbarTime );
1864 me->setFilePath (fn);
1865 tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
1866 if (fn.left(9)!="/tmp/vym-")
1868 // Only append to lastMaps if not loaded from a tmpDir
1869 // e.g. imported bookmarks are in a tmpDir
1870 addRecentMap(me->getFilePath() );
1872 actionFilePrint->setEnabled (true);
1874 statusBar()->message( "Loaded " + fn, statusbarTime );
1878 removeDir (QDir(tmpMapDir));
1884 void Main::fileLoad(const LoadMode &lmode)
1886 QStringList filters;
1887 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1888 QFileDialog *fd=new QFileDialog( this);
1889 fd->setDir (lastFileDir);
1890 fd->setFileMode (QFileDialog::ExistingFiles);
1891 fd->setFilters (filters);
1895 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1898 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1901 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1907 if ( fd->exec() == QDialog::Accepted )
1909 lastFileDir=fd->directory().path();
1910 QStringList flist = fd->selectedFiles();
1911 QStringList::Iterator it = flist.begin();
1912 while( it != flist.end() )
1915 fileLoad(*it, lmode);
1922 void Main::fileLoad()
1927 void Main::fileLoadRecent()
1929 QAction *action = qobject_cast<QAction *>(sender());
1931 fileLoad (action->data().toString(), NewMap);
1934 void Main::addRecentMap (const QString &fileName)
1937 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1938 files.removeAll(fileName);
1939 files.prepend(fileName);
1940 while (files.size() > MaxRecentFiles)
1943 settings.setValue("/mainwindow/recentFileList", files);
1945 setupRecentMapsMenu();
1948 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
1950 // tmp dir for zipping
1954 ErrorCode err=success;
1956 QString safeFilePath;
1958 bool saveZipped=me->saveZipped();
1962 QString fn=me->getFilePath();
1963 // filename=unnamed, filepath="" in constructor of mapEditor
1964 if ( !fn.isEmpty() )
1966 // We have a filepath, go on saving
1967 // First remove existing file, we
1968 // don't want to add to old zip archives
1972 QMessageBox::warning( 0, tr( "Save Error" ),
1973 fn+ tr("\ncould not be removed before saving"));
1975 // Look, if we should zip the data:
1978 QMessageBox mb( vymName,
1979 tr("The map %1\ndid not use the compressed "
1980 "vym file format.\nWriting it uncompressed will also write images \n"
1981 "and flags and thus may overwrite files in the "
1982 "given directory\n\nDo you want to write the map").arg(fn),
1983 QMessageBox::Warning,
1984 QMessageBox::Yes | QMessageBox::Default,
1986 QMessageBox::Cancel | QMessageBox::Escape);
1987 mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
1988 mb.setButtonText( QMessageBox::No, tr("uncompressed") );
1989 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1992 case QMessageBox::Yes:
1993 // save compressed (default file format)
1996 case QMessageBox::No:
1997 // save uncompressed
2000 case QMessageBox::Cancel:
2009 // Create temporary directory for packing
2011 QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
2014 QMessageBox::critical( 0, tr( "Critical Load Error" ),
2015 tr("Couldn't create temporary directory before save\n"));
2019 safeFilePath=me->getFilePath();
2020 me->setFilePath (tmpMapDir+"/"+
2021 me->getMapName()+ ".xml",
2023 me->save (savemode);
2024 me->setFilePath (safeFilePath);
2026 zipDir (tmpMapDir,fn);
2031 safeFilePath=me->getFilePath();
2032 me->setFilePath (fn, safeFilePath);
2033 me->save (savemode);
2034 me->setFilePath (safeFilePath);
2036 } // filepath available
2039 // We have no filepath yet,
2040 // call fileSaveAs() now, this will call fileSave()
2042 // First switch to editor
2043 tabWidget->setCurrentWidget (me);
2044 fileSaveAs(savemode);
2048 if (saveZipped && !tmpMapDir.isEmpty())
2050 removeDir (QDir(tmpMapDir));
2054 statusBar()->message(
2055 tr("Saved %1").arg(me->getFilePath()),
2057 addRecentMap (me->getFilePath() );
2059 statusBar()->message(
2060 tr("Couldn't save ").arg(me->getFilePath()),
2064 void Main::fileSave()
2066 fileSave (currentMapEditor(), CompleteMap);
2069 void Main::fileSave(MapEditor *me)
2071 fileSave (me,CompleteMap);
2074 void Main::fileSaveAs(const SaveMode& savemode)
2078 if (currentMapEditor())
2080 if (savemode==CompleteMap)
2081 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2083 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2084 if ( !fn.isEmpty() )
2086 // Check for existing file
2087 if (QFile (fn).exists())
2089 QMessageBox mb( vymName,
2090 tr("The file %1\nexists already. Do you want to").arg(fn),
2091 QMessageBox::Warning,
2092 QMessageBox::Yes | QMessageBox::Default,
2093 QMessageBox::Cancel | QMessageBox::Escape,
2094 QMessageBox::NoButton);
2095 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2096 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2099 case QMessageBox::Yes:
2102 case QMessageBox::Cancel:
2109 // New file, add extension to filename, if missing
2110 // This is always .vym or .vyp, depending on savemode
2111 if (savemode==CompleteMap)
2113 if (!fn.contains (".vym") && !fn.contains (".xml"))
2117 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2126 currentMapEditor()->setFilePath(fn);
2127 fileSave(currentMapEditor(), savemode);
2130 if (savemode==CompleteMap)
2131 tabWidget->setTabLabel (currentMapEditor(),
2132 currentMapEditor()->getFileName() );
2138 void Main::fileSaveAs()
2140 fileSaveAs (CompleteMap);
2143 void Main::fileImportKDEBookmarks()
2145 ImportKDEBookmarks im;
2147 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2148 currentMapEditor()->setFilePath ("");
2151 void Main::fileImportFirefoxBookmarks()
2153 Q3FileDialog *fd=new Q3FileDialog( this);
2154 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2155 fd->setMode (Q3FileDialog::ExistingFiles);
2156 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2157 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2160 if ( fd->exec() == QDialog::Accepted )
2162 ImportFirefoxBookmarks im;
2163 QStringList flist = fd->selectedFiles();
2164 QStringList::Iterator it = flist.begin();
2165 while( it != flist.end() )
2168 if (im.transform() &&
2169 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2170 currentMapEditor() )
2171 currentMapEditor()->setFilePath ("");
2178 void Main::fileImportFreemind()
2180 QStringList filters;
2181 filters <<"Freemind map (*.mm)"<<"All files (*)";
2182 QFileDialog *fd=new QFileDialog( this);
2183 fd->setDir (lastFileDir);
2184 fd->setFileMode (QFileDialog::ExistingFiles);
2185 fd->setFilters (filters);
2186 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2190 if ( fd->exec() == QDialog::Accepted )
2192 lastFileDir=fd->directory().path();
2193 QStringList flist = fd->selectedFiles();
2194 QStringList::Iterator it = flist.begin();
2195 while( it != flist.end() )
2198 if ( fileLoad (fn,NewMap, FreemindMap) )
2200 currentMapEditor()->setFilePath ("");
2209 void Main::fileImportMM()
2213 Q3FileDialog *fd=new Q3FileDialog( this);
2214 fd->setDir (lastFileDir);
2215 fd->setMode (Q3FileDialog::ExistingFiles);
2216 fd->addFilter ("Mind Manager (*.mmap)");
2217 fd->setCaption(tr("Import")+" "+"Mind Manager");
2220 if ( fd->exec() == QDialog::Accepted )
2222 lastFileDir=fd->dirPath();
2223 QStringList flist = fd->selectedFiles();
2224 QStringList::Iterator it = flist.begin();
2225 while( it != flist.end() )
2228 if (im.transform() &&
2229 success==fileLoad (im.getTransformedFile(),NewMap) &&
2230 currentMapEditor() )
2231 currentMapEditor()->setFilePath ("");
2240 void Main::fileImportDir()
2242 if (currentMapEditor())
2243 currentMapEditor()->importDir();
2246 void Main::fileExportXML()
2248 MapEditor *me=currentMapEditor();
2249 if (me) me->exportXML();
2253 void Main::fileExportXHTML()
2255 MapEditor *me=currentMapEditor();
2256 if (me) me->exportXHTML();
2259 void Main::fileExportImage()
2261 MapEditor *me=currentMapEditor();
2262 if (me) me->exportImage();
2265 void Main::fileExportASCII()
2267 MapEditor *me=currentMapEditor();
2268 if (me) me->exportASCII();
2271 void Main::fileExportCSV() //FIXME not scriptable yet
2273 MapEditor *me=currentMapEditor();
2277 ex.setMapCenter(me->getMapCenter());
2278 ex.addFilter ("CSV (*.csv)");
2279 ex.setDir(lastImageDir);
2280 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2281 if (ex.execDialog() )
2283 me->setExportMode(true);
2285 me->setExportMode(false);
2290 void Main::fileExportLaTeX() //FIXME not scriptable yet
2292 MapEditor *me=currentMapEditor();
2296 ex.setMapCenter(me->getMapCenter());
2297 ex.addFilter ("Tex (*.tex)");
2298 ex.setDir(lastImageDir);
2299 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2300 if (ex.execDialog() )
2302 me->setExportMode(true);
2304 me->setExportMode(false);
2309 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2311 ExportKDEBookmarks ex;
2312 MapEditor *me=currentMapEditor();
2315 ex.setMapCenter (me->getMapCenter() );
2320 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2322 ExportTaskjuggler ex;
2323 MapEditor *me=currentMapEditor();
2326 ex.setMapCenter (me->getMapCenter() );
2327 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2328 ex.setDir(lastImageDir);
2329 ex.addFilter ("Taskjuggler (*.tjp)");
2330 if (ex.execDialog() )
2332 me->setExportMode(true);
2334 me->setExportMode(false);
2339 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2341 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2342 // TODO add preview in dialog
2343 //ImagePreview *p =new ImagePreview (fd);
2344 //fd->setContentsPreviewEnabled( TRUE );
2345 //fd->setContentsPreview( p, p );
2346 //fd->setPreviewMode( QFileDialog::Contents );
2347 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2348 fd->setDir (QDir().current());
2349 if (fd->foundConfig())
2353 if ( fd->exec() == QDialog::Accepted )
2355 QString fn=fd->selectedFile();
2356 if (!fn.contains (".odp"))
2359 //lastImageDir=fn.left(fn.findRev ("/"));
2360 if (currentMapEditor())
2361 currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());
2365 QMessageBox::warning(0,
2367 tr("Couldn't find configuration for export to Open Office\n"));
2371 void Main::fileCloseMap()
2373 if (currentMapEditor())
2375 if (currentMapEditor()->hasChanged())
2377 QMessageBox mb( vymName,
2378 tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
2379 QMessageBox::Warning,
2380 QMessageBox::Yes | QMessageBox::Default,
2382 QMessageBox::Cancel | QMessageBox::Escape );
2383 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2384 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2387 case QMessageBox::Yes:
2389 fileSave(currentMapEditor(), CompleteMap);
2391 case QMessageBox::No:
2392 // close without saving
2394 case QMessageBox::Cancel:
2399 currentMapEditor()->closeMap();
2400 tabWidget->removePage(currentMapEditor());
2401 if (tabWidget->count()==0)
2402 actionFilePrint->setEnabled (false);
2406 void Main::filePrint()
2408 if (currentMapEditor())
2409 currentMapEditor()->print();
2412 void Main::fileExitVYM()
2414 // Check if one or more editors have changed
2417 for (i=0;i<=tabWidget->count() -1;i++)
2420 me=(MapEditor*)tabWidget->page(i);
2422 // If something changed, ask what to do
2423 if (me->hasChanged())
2425 tabWidget->setCurrentPage(i);
2426 QMessageBox mb( vymName,
2427 tr("This map is not saved yet. Do you want to"),
2428 QMessageBox::Warning,
2429 QMessageBox::Yes | QMessageBox::Default,
2431 QMessageBox::Cancel | QMessageBox::Escape );
2432 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2433 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2436 mb.setActiveWindow();
2437 switch( mb.exec() ) {
2438 case QMessageBox::Yes:
2439 // save (the changed editors) and exit
2440 fileSave(currentMapEditor(), CompleteMap);
2442 case QMessageBox::No:
2443 // exit without saving
2445 case QMessageBox::Cancel:
2446 // don't save and don't exit
2450 } // loop over all MEs
2454 void Main::editUndo()
2456 if (currentMapEditor())
2457 currentMapEditor()->undo();
2460 void Main::editRedo()
2462 if (currentMapEditor())
2463 currentMapEditor()->redo();
2466 void Main::gotoHistoryStep (int i)
2468 if (currentMapEditor())
2469 currentMapEditor()->gotoHistoryStep (i);
2472 void Main::editCopy()
2474 if (currentMapEditor())
2475 currentMapEditor()->copy();
2478 void Main::editPaste()
2480 if (currentMapEditor())
2481 currentMapEditor()->paste();
2484 void Main::editCut()
2486 if (currentMapEditor())
2487 currentMapEditor()->cut();
2490 void Main::editOpenFindWindow()
2492 findWindow->popup();
2493 findWindow->raise();
2494 findWindow->setActiveWindow();
2497 void Main::editFind(QString s)
2500 BranchObj *bo=currentMapEditor()->findText(s, cs);
2503 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2506 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2507 tr("No matches found for \"%1\"").arg(s));
2511 void Main::editFindChanged()
2512 { // Notify editor, to abort the current find process
2513 currentMapEditor()->findReset();
2516 void Main::openTabs(QStringList urls)
2518 if (!urls.isEmpty())
2522 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2524 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2526 QString u=urls.takeFirst();
2527 procBrowser = new QProcess( this );
2529 procBrowser->start(browser,args);
2530 if ( !procBrowser->waitForStarted())
2532 // try to set path to browser
2533 QMessageBox::warning(0,
2535 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2536 tr("Please use Settings->")+tr("Set application to open an URL"));
2541 if (browser.contains("konqueror"))
2543 for (int i=0; i<urls.size(); i++)
2546 // Try to open new tab in existing konqueror started previously by vym
2547 p=new QProcess (this);
2549 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2550 "konqueror-mainwindow#1"<<
2553 p->start ("dcop",args);
2554 if ( !p->waitForStarted() ) success=false;
2557 QMessageBox::warning(0,
2559 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2561 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2563 for (int i=0; i<urls.size(); i++)
2565 // Try to open new tab in firefox
2566 p=new QProcess (this);
2567 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2568 p->start (browser,args);
2569 if ( !p->waitForStarted() ) success=false;
2572 QMessageBox::warning(0,
2574 tr("Couldn't start %1 to open a new tab").arg(browser));
2577 QMessageBox::warning(0,
2579 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2583 void Main::editOpenURL()
2586 if (currentMapEditor())
2588 QString url=currentMapEditor()->getURL();
2590 if (url=="") return;
2591 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2592 procBrowser = new QProcess( this );
2594 procBrowser->start(browser,args);
2595 if ( !procBrowser->waitForStarted())
2597 // try to set path to browser
2598 QMessageBox::warning(0,
2600 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2601 tr("Please use Settings->")+tr("Set application to open an URL"));
2606 void Main::editOpenURLTab()
2608 if (currentMapEditor())
2611 urls.append(currentMapEditor()->getURL());
2615 void Main::editOpenMultipleURLTabs()
2617 if (currentMapEditor())
2620 urls=currentMapEditor()->getURLs();
2626 void Main::editURL()
2628 if (currentMapEditor())
2629 currentMapEditor()->editURL();
2632 void Main::editLocalURL()
2634 if (currentMapEditor())
2635 currentMapEditor()->editLocalURL();
2638 void Main::editHeading2URL()
2640 if (currentMapEditor())
2641 currentMapEditor()->editHeading2URL();
2644 void Main::editBugzilla2URL()
2646 if (currentMapEditor())
2647 currentMapEditor()->editBugzilla2URL();
2650 void Main::editFATE2URL()
2652 if (currentMapEditor())
2653 currentMapEditor()->editFATE2URL();
2656 void Main::editHeadingFinished()
2658 // only called from editHeading(), so there is a currentME
2659 MapEditor *me=currentMapEditor();
2662 me->setStateEditHeading (false);
2663 QPoint p; //Not used here, only to find out pos of branch
2665 QString s=me->getHeading(ok,p);
2667 #if defined(Q_OS_MACX)
2669 if (ok && s!=lineedit->text())
2670 me->setHeading(lineedit->text());
2672 lineedit->releaseKeyboard();
2676 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2677 !prevSelection.isEmpty())
2678 me->select(prevSelection);
2683 void Main::editHeading()
2685 if (currentMapEditor())
2687 MapEditor *me=currentMapEditor();
2688 QString oldSel=me->getSelectString();
2690 if (lineedit->isVisible())
2691 editHeadingFinished();
2696 QString s=me->getHeading(ok,p);
2700 me->setStateEditHeading (true);
2701 #if defined(Q_OS_MACX)
2702 p=me->mapToGlobal (p);
2703 QDialog *d =new QDialog(NULL);
2704 QLineEdit *le=new QLineEdit (d);
2705 d->setWindowFlags (Qt::FramelessWindowHint);
2706 d->setGeometry(p.x(),p.y(),230,25);
2707 le->resize (d->width()-10,d->height());
2710 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2711 d->activateWindow();
2713 me->setHeading (le->text());
2716 editHeadingFinished();
2718 p=me->mapTo (this,p);
2719 lineedit->setGeometry(p.x(),p.y(),230,25);
2720 lineedit->setText(s);
2721 lineedit->setCursorPosition(1);
2722 lineedit->selectAll();
2724 lineedit->grabKeyboard();
2725 lineedit->setFocus();
2729 } // currentMapEditor()
2732 void Main::openVymLinks(const QStringList &vl)
2734 for (int j=0; j<vl.size(); j++)
2736 // compare path with already loaded maps
2740 for (i=0;i<=tabWidget->count() -1;i++)
2742 me=(MapEditor*)tabWidget->page(i);
2743 if (vl.at(j)==me->getFilePath() )
2752 if (!QFile(vl.at(j)).exists() )
2753 QMessageBox::critical( 0, tr( "Critical Error" ),
2754 tr("Couldn't open map %1").arg(vl.at(j)));
2757 fileLoad (vl.at(j), NewMap);
2758 tabWidget->setCurrentPage (tabWidget->count()-1);
2761 // Go to tab containing the map
2762 tabWidget->setCurrentPage (index);
2766 void Main::editOpenVymLink()
2768 if (currentMapEditor())
2771 vl.append(currentMapEditor()->getVymLink());
2776 void Main::editOpenMultipleVymLinks()
2778 QString currentVymLink;
2779 if (currentMapEditor())
2781 QStringList vl=currentMapEditor()->getVymLinks();
2786 void Main::editVymLink()
2788 if (currentMapEditor())
2789 currentMapEditor()->editVymLink();
2792 void Main::editDeleteVymLink()
2794 if (currentMapEditor())
2795 currentMapEditor()->deleteVymLink();
2798 void Main::editToggleHideExport()
2800 if (currentMapEditor())
2801 currentMapEditor()->toggleHideExport();
2804 void Main::editMapInfo()
2806 if (currentMapEditor())
2807 currentMapEditor()->editMapInfo();
2810 void Main::editMoveUp()
2812 if (currentMapEditor())
2813 currentMapEditor()->moveBranchUp();
2816 void Main::editMoveDown()
2818 if (currentMapEditor())
2819 currentMapEditor()->moveBranchDown();
2822 void Main::editToggleScroll()
2824 if (currentMapEditor())
2826 currentMapEditor()->toggleScroll();
2830 void Main::editUnscrollChilds()
2832 if (currentMapEditor())
2833 currentMapEditor()->unscrollChilds();
2836 void Main::editNewBranch()
2838 MapEditor *me=currentMapEditor();
2839 if (!lineedit->isVisible() && me)
2841 BranchObj *bo=(BranchObj*)me->getSelection();
2842 BranchObj *newbo=me->addNewBranch(0);
2844 prevSelection=bo->getSelectString();
2846 me->select (newbo->getSelectString());
2850 if (actionSettingsAutoEditNewBranch->isOn())
2855 if (!prevSelection.isEmpty())
2857 me->select(prevSelection);
2864 void Main::editNewBranchBefore()
2866 MapEditor *me=currentMapEditor();
2867 if (!lineedit->isVisible() && me)
2869 BranchObj *bo=(BranchObj*)me->getSelection();
2870 BranchObj *newbo=me->addNewBranchBefore();
2873 me->select (newbo->getSelectString());
2877 if (actionSettingsAutoEditNewBranch->isOn())
2879 if (!actionSettingsAutoSelectNewBranch->isOn())
2880 prevSelection=bo->getSelectString();
2886 void Main::editNewBranchAbove()
2888 MapEditor *me=currentMapEditor();
2889 if (!lineedit->isVisible() && me)
2891 BranchObj *bo=(BranchObj*)me->getSelection();
2892 BranchObj *newbo=me->addNewBranch (-1);
2895 me->select (newbo->getSelectString());
2899 if (actionSettingsAutoEditNewBranch->isOn())
2901 if (!actionSettingsAutoSelectNewBranch->isOn())
2902 prevSelection=bo->getSelectString();
2908 void Main::editNewBranchBelow()
2910 MapEditor *me=currentMapEditor();
2911 if (!lineedit->isVisible() && me)
2913 BranchObj *bo=(BranchObj*)me->getSelection();
2914 BranchObj *newbo=me->addNewBranch (1);
2917 me->select (newbo->getSelectString());
2921 if (actionSettingsAutoEditNewBranch->isOn())
2923 if (!actionSettingsAutoSelectNewBranch->isOn())
2924 prevSelection=bo->getSelectString();
2930 void Main::editImportAdd()
2932 fileLoad (ImportAdd);
2935 void Main::editImportReplace()
2937 fileLoad (ImportReplace);
2940 void Main::editSaveBranch()
2942 fileSaveAs (PartOfMap);
2945 void Main::editDeleteKeepChilds()
2947 if (currentMapEditor())
2948 currentMapEditor()->deleteKeepChilds();
2951 void Main::editDeleteChilds()
2953 if (currentMapEditor())
2954 currentMapEditor()->deleteChilds();
2957 void Main::editDeleteSelection()
2959 if (currentMapEditor() && actionSettingsUseDelKey->isOn())
2960 currentMapEditor()->deleteSelection();
2963 void Main::editUpperBranch()
2965 if (currentMapEditor())
2966 currentMapEditor()->selectUpperBranch();
2969 void Main::editLowerBranch()
2971 if (currentMapEditor())
2972 currentMapEditor()->selectLowerBranch();
2975 void Main::editLeftBranch()
2977 if (currentMapEditor())
2978 currentMapEditor()->selectLeftBranch();
2981 void Main::editRightBranch()
2983 if (currentMapEditor())
2984 currentMapEditor()->selectRightBranch();
2987 void Main::editFirstBranch()
2989 if (currentMapEditor())
2990 currentMapEditor()->selectFirstBranch();
2993 void Main::editLastBranch()
2995 if (currentMapEditor())
2996 currentMapEditor()->selectLastBranch();
2999 void Main::editLoadImage()
3001 if (currentMapEditor())
3002 currentMapEditor()->loadFloatImage();
3005 void Main::editSaveImage()
3007 if (currentMapEditor())
3008 currentMapEditor()->saveFloatImage();
3011 void Main::editFollowXLink(QAction *a)
3014 if (currentMapEditor())
3015 currentMapEditor()->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3018 void Main::editEditXLink(QAction *a)
3020 if (currentMapEditor())
3021 currentMapEditor()->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3024 void Main::formatSelectColor()
3026 if (currentMapEditor())
3028 QColor col = QColorDialog::getColor((currentColor ), this );
3029 if ( !col.isValid() ) return;
3030 colorChanged( col );
3034 void Main::formatPickColor()
3036 if (currentMapEditor())
3037 colorChanged( currentMapEditor()->getCurrentHeadingColor() );
3040 void Main::colorChanged(QColor c)
3042 QPixmap pix( 16, 16 );
3044 actionFormatColor->setIconSet( pix );
3048 void Main::formatColorBranch()
3050 if (currentMapEditor())
3051 currentMapEditor()->colorBranch(currentColor);
3054 void Main::formatColorSubtree()
3056 if (currentMapEditor())
3057 currentMapEditor()->colorSubtree (currentColor);
3060 void Main::formatLinkStyleLine()
3062 if (currentMapEditor())
3063 currentMapEditor()->setMapLinkStyle("StyleLine");
3066 void Main::formatLinkStyleParabel()
3068 if (currentMapEditor())
3069 currentMapEditor()->setMapLinkStyle("StyleParabel");
3072 void Main::formatLinkStylePolyLine()
3074 if (currentMapEditor())
3075 currentMapEditor()->setMapLinkStyle("StylePolyLine");
3078 void Main::formatLinkStylePolyParabel()
3080 if (currentMapEditor())
3081 currentMapEditor()->setMapLinkStyle("StylePolyParabel");
3084 void Main::formatSelectBackColor()
3086 if (currentMapEditor())
3087 currentMapEditor()->selectMapBackgroundColor();
3090 void Main::formatSelectBackImage()
3092 if (currentMapEditor())
3093 currentMapEditor()->selectMapBackgroundImage();
3096 void Main::formatSelectLinkColor()
3098 if (currentMapEditor())
3099 currentMapEditor()->selectMapLinkColor();
3102 void Main::formatSelectSelectionColor()
3104 if (currentMapEditor())
3105 currentMapEditor()->selectMapSelectionColor();
3108 void Main::formatToggleLinkColorHint()
3110 currentMapEditor()->toggleMapLinkColorHint();
3114 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3116 if (currentMapEditor())
3117 currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3120 void Main::viewZoomReset()
3122 if (currentMapEditor())
3126 currentMapEditor()->setMatrix( m );
3130 void Main::viewZoomIn()
3132 if (currentMapEditor())
3134 QMatrix m = currentMapEditor()->matrix();
3135 m.scale( 1.25, 1.25 );
3136 currentMapEditor()->setMatrix( m );
3140 void Main::viewZoomOut()
3142 if (currentMapEditor())
3144 QMatrix m = currentMapEditor()->matrix();
3145 m.scale( 0.8, 0.8 );
3146 currentMapEditor()->setMatrix( m );
3150 void Main::viewCenter()
3152 MapEditor *me=currentMapEditor();
3155 me->ensureSelectionVisible();
3159 void Main::networkStartServer()
3161 MapEditor *me=currentMapEditor();
3162 if (me) me->newServer();
3165 void Main::networkConnect()
3167 MapEditor *me=currentMapEditor();
3168 if (me) me->connectToServer();
3171 bool Main::settingsPDF()
3173 // Default browser is set in constructor
3175 QString text = QInputDialog::getText(
3176 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3177 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3179 settings.setValue ("/mainwindow/readerPDF",text);
3184 bool Main::settingsURL()
3186 // Default browser is set in constructor
3188 QString text = QInputDialog::getText(
3189 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3190 settings.value("/mainwindow/readerURL").toString()
3193 settings.setValue ("/mainwindow/readerURL",text);
3197 void Main::settingsMacroDir()
3199 QDir defdir=vymBaseDir;
3200 defdir.cd("macros");
3201 if (!defdir.exists())
3203 QDir dir=QFileDialog::getExistingDirectory (
3205 tr ("Directory with vym macros:"),
3206 settings.value ("/macros/macroDir",defdir.path()).toString()
3209 settings.setValue ("/macros/macroDir",dir.path());
3212 void Main::settingsUndoLevels()
3215 int i = QInputDialog::getInteger(
3217 tr("QInputDialog::getInteger()"),
3218 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3221 settings.setValue ("/mapeditor/stepsTotal",i);
3222 QMessageBox::information( this, tr( "VYM -Information:" ),
3223 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3227 void Main::settingsAutosaveToggle()
3229 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3232 void Main::settingsAutosaveTime()
3235 int i = QInputDialog::getInteger(
3237 tr("QInputDialog::getInteger()"),
3238 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3241 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3245 void Main::settingsToggleDelKey()
3247 if (actionSettingsUseDelKey->isOn())
3249 actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
3252 actionEditDelete->setAccel (QKeySequence (""));
3256 void Main::windowToggleNoteEditor()
3258 if (textEditor->isVisible() )
3259 windowHideNoteEditor();
3261 windowShowNoteEditor();
3264 void Main::windowToggleHistory()
3266 if (historyWindow->isVisible())
3267 historyWindow->hide();
3269 historyWindow->show();
3273 void Main::windowToggleProperty()
3275 if (branchPropertyWindow->isVisible())
3276 branchPropertyWindow->hide();
3278 branchPropertyWindow->show();
3280 if(currentMapEditor())
3282 LinkableMapObj *sel=currentMapEditor()->getSelection();
3283 if (sel && (typeid(*sel) == typeid(BranchObj) ||
3284 typeid(*sel) == typeid(MapCenterObj)))
3286 branchPropertyWindow->setMapEditor(currentMapEditor());
3287 branchPropertyWindow->setBranch((BranchObj*)sel);
3292 branchPropertyWindow->setBranch(NULL);
3295 void Main::windowToggleAntiAlias()
3297 bool b=actionViewToggleAntiAlias->isOn();
3299 for (int i=0;i<tabWidget->count();i++)
3302 me=(MapEditor*)tabWidget->page(i);
3303 me->setAntiAlias(b);
3308 void Main::windowToggleSmoothPixmap()
3310 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3312 for (int i=0;i<tabWidget->count();i++)
3315 me=(MapEditor*)tabWidget->page(i);
3316 me->setSmoothPixmap(b);
3320 void Main::updateHistory(SimpleSettings &undoSet)
3322 historyWindow->update (undoSet);
3325 void Main::updateNoteFlag()
3327 if (currentMapEditor())
3328 currentMapEditor()->updateNoteFlag();
3331 void Main::updateSatellites(MapEditor *me)
3333 branchPropertyWindow->setMapEditor (me);
3336 void Main::updateActions()
3338 MapEditor *me=currentMapEditor();
3341 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(currentMapEditor()->getFileName()));
3343 // updateActions is also called when NoteEditor is closed
3344 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3345 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3346 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3348 if (me->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3349 actionFormatLinkColorHint->setOn(true);
3351 actionFormatLinkColorHint->setOn(false);
3353 switch (me->getMapLinkStyle())
3355 case LinkableMapObj::Line:
3356 actionFormatLinkStyleLine->setOn(true);
3358 case LinkableMapObj::Parabel:
3359 actionFormatLinkStyleParabel->setOn(true);
3361 case LinkableMapObj::PolyLine:
3362 actionFormatLinkStylePolyLine->setOn(true);
3364 case LinkableMapObj::PolyParabel:
3365 actionFormatLinkStylePolyParabel->setOn(true);
3372 QPixmap pix( 16, 16 );
3373 pix.fill( me->getMapBackgroundColor() );
3374 actionFormatBackColor->setIconSet( pix );
3375 pix.fill( me->getSelectionColor() );
3376 actionFormatSelectionColor->setIconSet( pix );
3377 pix.fill( me->getMapDefLinkColor() );
3378 actionFormatLinkColor->setIconSet( pix );
3381 actionFileSave->setEnabled( me->hasChanged() );
3382 if (me->isUndoAvailable())
3383 actionEditUndo->setEnabled( true);
3385 actionEditUndo->setEnabled( false);
3387 if (me->isRedoAvailable())
3388 actionEditRedo->setEnabled( true);
3390 actionEditRedo->setEnabled( false);
3392 LinkableMapObj *selection=me->getSelection();
3395 if ( (typeid(*selection) == typeid(BranchObj)) ||
3396 (typeid(*selection) == typeid(MapCenterObj)) )
3398 BranchObj *bo=(BranchObj*)selection;
3399 // Take care of links
3400 if (bo->countXLinks()==0)
3402 branchXLinksContextMenuEdit->clear();
3403 branchXLinksContextMenuFollow->clear();
3408 branchXLinksContextMenuEdit->clear();
3409 branchXLinksContextMenuFollow->clear();
3410 for (int i=0; i<=bo->countXLinks();i++)
3412 bot=bo->XLinkTargetAt(i);
3415 s=bot->getHeading();
3416 if (s.length()>xLinkMenuWidth)
3417 s=s.left(xLinkMenuWidth)+"...";
3418 branchXLinksContextMenuFollow->addAction (s);
3419 branchXLinksContextMenuEdit->addAction (s);
3424 standardFlagsDefault->setEnabled (true);
3426 actionEditToggleScroll->setEnabled (true);
3427 if ( bo->isScrolled() )
3428 actionEditToggleScroll->setOn(true);
3430 actionEditToggleScroll->setOn(false);
3432 if ( bo->getURL().isEmpty() )
3434 actionEditOpenURL->setEnabled (false);
3435 actionEditOpenURLTab->setEnabled (false);
3439 actionEditOpenURL->setEnabled (true);
3440 actionEditOpenURLTab->setEnabled (true);
3442 if ( bo->getVymLink().isEmpty() )
3444 actionEditOpenVymLink->setEnabled (false);
3445 actionEditDeleteVymLink->setEnabled (false);
3448 actionEditOpenVymLink->setEnabled (true);
3449 actionEditDeleteVymLink->setEnabled (true);
3452 if (bo->canMoveBranchUp())
3453 actionEditMoveUp->setEnabled (true);
3455 actionEditMoveUp->setEnabled (false);
3456 if (bo->canMoveBranchDown())
3457 actionEditMoveDown->setEnabled (true);
3459 actionEditMoveDown->setEnabled (false);
3462 actionEditToggleHideExport->setEnabled (true);
3463 actionEditToggleHideExport->setOn (bo->hideInExport() );
3465 actionEditCopy->setEnabled (true);
3466 actionEditCut->setEnabled (true);
3467 if (!clipboardEmpty)
3468 actionEditPaste->setEnabled (true);
3470 actionEditPaste->setEnabled (false);
3471 for (int i=0; i<actionListBranches.size(); ++i)
3472 actionListBranches.at(i)->setEnabled(true);
3473 actionEditDelete->setEnabled (true);
3474 actionFormatHideLinkUnselected->setOn
3475 (selection->getHideLinkUnselected());
3477 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3479 FloatObj *fo=(FloatImageObj*)selection;
3481 actionEditOpenURL->setEnabled (false);
3482 actionEditOpenVymLink->setEnabled (false);
3483 actionEditDeleteVymLink->setEnabled (false);
3484 actionEditToggleHideExport->setEnabled (true);
3485 actionEditToggleHideExport->setOn (fo->hideInExport() );
3488 actionEditCopy->setEnabled (true);
3489 actionEditCut->setEnabled (true);
3490 actionEditPaste->setEnabled (false);
3491 for (int i=0; i<actionListBranches.size(); ++i)
3492 actionListBranches.at(i)->setEnabled(false);
3493 actionEditDelete->setEnabled (true);
3494 actionFormatHideLinkUnselected->setOn
3495 ( selection->getHideLinkUnselected());
3496 actionEditMoveUp->setEnabled (false);
3497 actionEditMoveDown->setEnabled (false);
3502 actionEditCopy->setEnabled (false);
3503 actionEditCut->setEnabled (false);
3504 actionEditPaste->setEnabled (false);
3505 for (int i=0; i<actionListBranches.size(); ++i)
3506 actionListBranches.at(i)->setEnabled(false);
3508 actionEditToggleScroll->setEnabled (false);
3509 actionEditOpenURL->setEnabled (false);
3510 actionEditOpenVymLink->setEnabled (false);
3511 actionEditDeleteVymLink->setEnabled (false);
3512 actionEditHeading2URL->setEnabled (false);
3513 actionEditDelete->setEnabled (false);
3514 actionEditMoveUp->setEnabled (false);
3515 actionEditMoveDown->setEnabled (false);
3516 actionEditToggleHideExport->setEnabled (false);
3520 Main::ModMode Main::getModMode()
3522 if (actionModModeColor->isOn()) return ModModeColor;
3523 if (actionModModeCopy->isOn()) return ModModeCopy;
3524 if (actionModModeXLink->isOn()) return ModModeXLink;
3528 bool Main::autoEditNewBranch()
3530 return actionSettingsAutoEditNewBranch->isOn();
3533 bool Main::autoSelectNewBranch()
3535 return actionSettingsAutoSelectNewBranch->isOn();
3538 bool Main::useFlagGroups()
3540 return actionSettingsUseFlagGroups->isOn();
3543 void Main::windowShowNoteEditor()
3545 textEditor->setShowWithMain(true);
3547 actionViewToggleNoteEditor->setOn (true);
3550 void Main::windowHideNoteEditor()
3552 textEditor->setShowWithMain(false);
3554 actionViewToggleNoteEditor->setOn (false);
3557 void Main::setScript (const QString &script)
3559 scriptEditor->setScript (script);
3562 void Main::runScript (const QString &script)
3564 if (currentMapEditor())
3565 currentMapEditor()->runScript (script);
3568 void Main::runScriptEverywhere (const QString &script)
3571 for (int i=0;i<=tabWidget->count() -1;i++)
3573 me=(MapEditor*)tabWidget->page(i);
3574 if (me) me->runScript (script);
3578 void Main::windowNextEditor()
3580 if (tabWidget->currentPageIndex() < tabWidget->count())
3581 tabWidget->setCurrentPage (tabWidget->currentPageIndex() +1);
3584 void Main::windowPreviousEditor()
3586 if (tabWidget->currentPageIndex() >0)
3587 tabWidget->setCurrentPage (tabWidget->currentPageIndex() -1);
3590 void Main::standardFlagChanged()
3592 if (currentMapEditor())
3593 currentMapEditor()->toggleStandardFlag(sender()->name());
3596 void Main::testFunction1()
3598 if (!currentMapEditor()) return;
3599 currentMapEditor()->testFunction1();
3602 void Main::testFunction2()
3604 if (!currentMapEditor()) return;
3605 currentMapEditor()->testFunction2();
3608 void Main::testCommand()
3610 if (!currentMapEditor()) return;
3611 scriptEditor->show();
3614 QString com = QInputDialog::getText(
3615 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3616 if (ok) currentMapEditor()->parseAtom(com);
3620 void Main::helpDoc()
3622 QString locale = QLocale::system().name();
3624 if (locale.left(2)=="es")
3625 docname="vym_es.pdf";
3629 QStringList searchList;
3631 #if defined(Q_OS_MACX)
3632 searchList << "./vym.app/Contents/Resources/doc";
3634 // default path in SUSE LINUX
3635 searchList <<"/usr/share/doc/packages/vym";
3638 searchList << "doc"; // relative path for easy testing in tarball
3639 searchList << "doc/tex"; // Easy testing working on vym.tex
3640 searchList << "/usr/share/doc/vym"; // Debian
3641 searchList << "/usr/share/doc/packages";// Knoppix
3645 for (int i=0; i<searchList.count(); ++i)
3647 docfile.setFileName(QDir::convertSeparators(searchList.at(i)+"/"+docname));
3648 if (docfile.exists() )
3657 QMessageBox::critical(0,
3658 tr("Critcal error"),
3659 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3664 Process *pdfProc = new Process();
3665 args <<docfile.fileName();
3667 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3668 if ( !pdfProc->waitForStarted() )
3671 QMessageBox::warning(0,
3673 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3674 tr("Please use Settings->")+tr("Set application to open PDF files"));
3681 void Main::helpDemo()
3683 QStringList filters;
3684 filters <<"VYM example map (*.vym)";
3685 QFileDialog *fd=new QFileDialog( this);
3686 #if defined(Q_OS_MACX)
3687 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3689 // default path in SUSE LINUX
3690 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3693 fd->setFileMode (QFileDialog::ExistingFiles);
3694 fd->setFilters (filters);
3695 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3699 if ( fd->exec() == QDialog::Accepted )
3701 lastFileDir=fd->directory().path();
3702 QStringList flist = fd->selectedFiles();
3703 QStringList::Iterator it = flist.begin();
3704 while( it != flist.end() )
3707 fileLoad(*it, NewMap);
3715 void Main::helpAbout()
3718 ad.setName ("aboutwindow");
3719 ad.setMinimumSize(500,500);
3720 ad.resize (QSize (500,500));
3724 void Main::helpAboutQT()
3726 QMessageBox::aboutQt( this, "Qt Application Example" );
3729 void Main::callMacro ()
3731 QAction *action = qobject_cast<QAction *>(sender());
3735 i=action->data().toInt();
3736 QString mDir (settings.value ("macros/macroDir").toString() );
3738 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3740 if ( !f.open( QIODevice::ReadOnly ) )
3742 QMessageBox::warning(0,
3744 tr("Couldn't find a macro at %1.\n").arg(fn)+
3745 tr("Please use Settings->")+tr("Set directory for vym macros"));
3749 QTextStream ts( &f );
3750 QString m= ts.read();
3754 //cout <<"Main::callMacro m="<<m.ascii()<<endl;
3755 currentMapEditor()->runScript (m);