1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "exportoofiledialog.h"
13 #include "flagrowobj.h"
14 #include "historywindow.h"
16 #include "mapeditor.h"
21 #include "texteditor.h"
22 #include "warningdialog.h"
24 #if defined(Q_OS_WIN32)
25 // Define only this structure as opposed to
26 // including full 'windows.h'. FindWindow
27 // clashes with the one in Win32 API.
28 typedef struct _PROCESS_INFORMATION
34 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
37 extern TextEditor *textEditor;
38 extern Main *mainWindow;
39 extern QString tmpVymDir;
40 extern QString clipboardDir;
41 extern QString clipboardFile;
42 extern bool clipboardEmpty;
43 extern int statusbarTime;
44 extern FlagRowObj* standardFlagsDefault;
45 extern FlagRowObj* systemFlagsDefault;
46 extern QString vymName;
47 extern QString vymVersion;
48 extern QString vymBuildDate;
51 QMenu* branchContextMenu;
52 QMenu* branchAddContextMenu;
53 QMenu* branchRemoveContextMenu;
54 QMenu* branchLinksContextMenu;
55 QMenu* branchXLinksContextMenuEdit;
56 QMenu* branchXLinksContextMenuFollow;
57 QMenu* floatimageContextMenu;
58 QMenu* canvasContextMenu;
59 QMenu* fileLastMapsMenu;
60 QMenu* fileImportMenu;
61 QMenu* fileExportMenu;
64 extern Settings settings;
65 extern Options options;
66 extern ImageIO imageIO;
68 extern QDir vymBaseDir;
69 extern QDir lastImageDir;
70 extern QDir lastFileDir;
71 #if defined(Q_OS_WIN32)
72 extern QDir vymInstallDir;
74 extern QString iconPath;
75 extern QString flagsPath;
78 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
79 QMainWindow(parent,name,f)
83 setCaption ("VYM - View Your Mind");
85 // Load window settings
86 #if defined(Q_OS_WIN32)
87 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
89 setWindowState(Qt::WindowMaximized);
94 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
95 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
98 // Sometimes we may need to remember old selections
102 currentColor=Qt::black;
104 // Create unique temporary directory
106 tmpVymDir=makeTmpDir (ok,"vym");
109 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
112 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
114 // Create direcctory for clipboard
115 clipboardDir=tmpVymDir+"/clipboard";
116 clipboardFile="map.xml";
117 QDir d(clipboardDir);
118 d.mkdir (clipboardDir,true);
119 makeSubDirs (clipboardDir);
124 // Satellite windows //////////////////////////////////////////
127 historyWindow=new HistoryWindow();
128 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
131 branchPropertyWindow = new BranchPropertyWindow();
132 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
134 // Connect TextEditor, so that we can update flags if text changes
135 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
136 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
138 // Connect HistoryWindow, so that we can update flags
139 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
142 // Initialize script editor
143 scriptEditor = new SimpleScriptEditor();
144 scriptEditor->move (50,50);
146 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
147 this, SLOT( runScript( QString ) ) );
150 // Initialize Find window
151 findWindow=new FindWindow(NULL);
152 findWindow->move (x(),y()+70);
153 connect (findWindow, SIGNAL( findButton(QString) ),
154 this, SLOT(editFind(QString) ) );
155 connect (findWindow, SIGNAL( somethingChanged() ),
156 this, SLOT(editFindChanged() ) );
158 // Initialize some settings, which are platform dependant
161 // application to open URLs
162 p="/mainwindow/readerURL";
163 #if defined(Q_OS_LINUX)
164 s=settings.value (p,"xdg-open").toString();
166 #if defined(Q_OS_MACX)
167 s=settings.value (p,"/usr/bin/open").toString();
170 #if defined(Q_OS_WIN32)
171 // Assume that system has been set up so that
172 // Explorer automagically opens up the URL
173 // in the user's preferred browser.
174 s=settings.value (p,"explorer").toString();
176 s=settings.value (p,"mozilla").toString();
180 settings.setValue( p,s);
182 // application to open PDFs
183 p="/mainwindow/readerPDF";
184 #if defined(Q_OS_LINUX)
185 s=settings.value (p,"xdg-open").toString();
187 #if defined(Q_OS_MACX)
188 s=settings.value (p,"/usr/bin/open").toString();
189 #elif defined(Q_OS_WIN32)
190 s=settings.value (p,"acrord32").toString();
192 s=settings.value (p,"acroread").toString();
195 settings.setValue( p,s);
197 // width of xLinksMenu
200 // Create tab widget which holds the maps
201 tabWidget= new QTabWidget (this);
202 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
203 this, SLOT( editorChanged( QWidget * ) ) );
205 setCentralWidget(tabWidget);
209 setupFormatActions();
213 setupNetworkActions();
214 setupSettingsActions();
217 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
222 restoreState (settings.value("/mainwindow/state",0).toByteArray());
230 #if defined(Q_OS_WIN32)
231 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
233 settings.setValue ("/mainwindow/geometry/size", size());
234 settings.setValue ("/mainwindow/geometry/pos", pos());
235 settings.setValue ("/mainwindow/state",saveState(0));
237 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
238 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
239 settings.setValue( "/version/version", vymVersion );
240 settings.setValue( "/version/builddate", vymBuildDate );
242 settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
243 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
244 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
245 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
246 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
247 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
248 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
249 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
251 //TODO save scriptEditor settings
253 // call the destructors
255 delete historyWindow;
256 delete branchPropertyWindow;
258 // Remove temporary directory
259 removeDir (QDir(tmpVymDir));
262 void Main::loadCmdLine()
264 /* TODO draw some kind of splashscreen while loading...
270 QStringList flist=options.getFileList();
271 QStringList::Iterator it=flist.begin();
273 while (it !=flist.end() )
275 fileLoad (*it, NewMap);
281 void Main::statusMessage(const QString &s)
283 statusBar()->message( s);
286 void Main::closeEvent (QCloseEvent* )
292 void Main::setupFileActions()
294 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
295 QToolBar *tb = addToolBar( tr ("&Map") );
296 tb->setObjectName ("mapTB");
299 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
300 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
301 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
303 fileMenu->addAction (a);
304 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
306 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
307 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
308 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
309 fileMenu->addAction (a);
310 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
313 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
314 a->setStatusTip (tr( "Open","Status tip File menu" ) );
315 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
317 fileMenu->addAction (a);
318 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
320 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
321 fileMenu->addSeparator();
323 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
324 a->setStatusTip ( tr( "Save","Status tip file menu" ));
325 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
327 fileMenu->addAction (a);
328 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
331 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
332 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
333 fileMenu->addAction (a);
334 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
336 fileMenu->addSeparator();
338 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
340 a = new QAction(tr("KDE Bookmarks"), this);
341 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
342 a->addTo (fileImportMenu);
343 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
345 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
347 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
348 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
349 a->addTo (fileImportMenu);
350 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
353 a = new QAction("Freemind...",this);
354 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
355 fileImportMenu->addAction (a);
356 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
358 a = new QAction("Mind Manager...",this);
359 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
360 fileImportMenu->addAction (a);
361 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
363 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
364 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
365 fileImportMenu->addAction (a);
366 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
368 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
370 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
371 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
372 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
373 fileExportMenu->addAction (a);
375 a = new QAction( "Open Office...", this);
376 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
377 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
378 fileExportMenu->addAction (a);
380 a = new QAction( "Webpage (XHTML)...",this );
381 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
382 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
383 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
384 fileExportMenu->addAction (a);
386 a = new QAction( "Text (ASCII)...", this);
387 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
388 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
389 fileExportMenu->addAction (a);
391 a = new QAction( "Spreadsheet (CSV)...", this);
392 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
393 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
394 fileExportMenu->addAction (a);
396 a = new QAction( tr("KDE Bookmarks","File menu"), this);
397 a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
398 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
399 fileExportMenu->addAction (a);
401 a = new QAction( "Taskjuggler...", this );
402 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
403 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
404 fileExportMenu->addAction (a);
406 a = new QAction( "LaTeX...", this);
407 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
408 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
409 fileExportMenu->addAction (a);
411 a = new QAction( "XML..." , this );
412 a->setStatusTip (tr( "Export as %1").arg("XML"));
413 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
414 fileExportMenu->addAction (a);
416 fileMenu->addSeparator();
418 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
419 a->setStatusTip ( tr( "Print" ,"File menu") );
420 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
422 fileMenu->addAction (a);
423 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
426 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
427 a->setStatusTip (tr( "Close Map" ) );
428 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
429 fileMenu->addAction (a);
430 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
432 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
433 a->setStatusTip ( tr( "Exit")+" "+vymName );
434 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
435 fileMenu->addAction (a);
436 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
441 void Main::setupEditActions()
443 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
444 tb->setLabel( "Edit Actions" );
445 tb->setObjectName ("actionsTB");
446 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
450 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
451 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
452 a->setStatusTip (tr( "Undo" ) );
453 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
454 a->setEnabled (false);
456 editMenu->addAction (a);
459 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
460 a->setStatusTip (tr( "Redo" ));
461 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
463 editMenu->addAction (a);
464 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
467 editMenu->addSeparator();
468 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
469 a->setStatusTip ( tr( "Copy" ) );
470 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
471 a->setEnabled (false);
473 editMenu->addAction (a);
474 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
477 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
478 a->setStatusTip ( tr( "Cut" ) );
479 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
480 a->setEnabled (false);
482 editMenu->addAction (a);
484 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
486 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
487 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
488 a->setStatusTip ( tr( "Paste" ) );
489 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
490 a->setEnabled (false);
492 editMenu->addAction (a);
496 // Shortcuts to modify heading:
497 a = new QAction(tr( "Edit heading","Edit menu" ),this);
498 a->setStatusTip ( tr( "edit Heading" ));
499 a->setShortcut ( Qt::Key_Enter); //Edit heading
500 // a->setShortcutContext (Qt::WindowShortcut);
502 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
503 actionListBranches.append(a);
504 a = new QAction( tr( "Edit heading","Edit menu" ), this);
505 a->setStatusTip (tr( "edit Heading" ));
506 a->setShortcut (Qt::Key_Return ); //Edit heading
507 //a->setShortcutContext (Qt::WindowShortcut);
509 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
510 actionListBranches.append(a);
511 editMenu->addAction (a);
514 a = new QAction( tr( "Edit heading","Edit menu" ), this);
515 a->setStatusTip (tr( "edit Heading" ));
516 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
517 a->setShortcutContext (Qt::WindowShortcut);
519 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
520 actionListBranches.append(a);
523 // Shortcut to delete selection
524 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
525 a->setStatusTip (tr( "Delete Selection" ));
526 a->setShortcut ( Qt::Key_Delete); //Delete selection
527 a->setShortcutContext (Qt::WindowShortcut);
529 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
532 // Shortcut to add mapcenter
533 a= new QAction(tr( "Add mapcenter","Canvas context menu" ), this);
534 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
535 actionAddMapCenter = a;
538 // Shortcut to add branch
539 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
540 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
541 alt->setShortcut (Qt::Key_A); //Add branch
542 alt->setShortcutContext (Qt::WindowShortcut);
544 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
545 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
546 a->setStatusTip ( tr( "Add a branch as child of selection" ));
547 a->setShortcut (Qt::Key_Insert); //Add branch
548 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
549 actionListBranches.append(a);
550 #if defined (Q_OS_MACX)
551 // In OSX show different shortcut in menues, the keys work indepently always
556 editMenu->addAction (actionAddBranch);
557 tb->addAction (actionAddBranch);
560 // Add branch by inserting it at selection
561 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
562 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
563 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
564 a->setShortcutContext (Qt::WindowShortcut);
566 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
567 a->setEnabled (false);
568 actionListBranches.append(a);
569 actionAddBranchBefore=a;
570 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
571 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
572 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
573 a->setShortcutContext (Qt::WindowShortcut);
575 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
576 actionListBranches.append(a);
579 a = new QAction(tr( "Add branch above","Edit menu" ), this);
580 a->setStatusTip ( tr( "Add a branch above selection" ));
581 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
582 a->setShortcutContext (Qt::WindowShortcut);
584 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
585 a->setEnabled (false);
586 actionListBranches.append(a);
587 actionAddBranchAbove=a;
588 a = new QAction(tr( "Add branch above","Edit menu" ), this);
589 a->setStatusTip ( tr( "Add a branch above selection" ));
590 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
591 a->setShortcutContext (Qt::WindowShortcut);
593 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
594 actionListBranches.append(a);
597 a = new QAction(tr( "Add branch below","Edit menu" ), this);
598 a->setStatusTip ( tr( "Add a branch below selection" ));
599 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
600 a->setShortcutContext (Qt::WindowShortcut);
602 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
603 a->setEnabled (false);
604 actionListBranches.append(a);
605 actionAddBranchBelow=a;
606 a = new QAction(tr( "Add branch below","Edit menu" ), this);
607 a->setStatusTip ( tr( "Add a branch below selection" ));
608 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
609 a->setShortcutContext (Qt::WindowShortcut);
611 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
612 actionListBranches.append(a);
614 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
615 a->setStatusTip ( tr( "Move branch up" ) );
616 a->setShortcut (Qt::Key_PageUp ); // Move branch up
617 a->setEnabled (false);
619 editMenu->addAction (a);
620 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
623 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
624 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
625 a->setStatusTip (tr( "Move branch down" ) );
626 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
627 a->setEnabled (false);
629 editMenu->addAction (a);
632 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
633 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
634 a->setEnabled (true);
636 editMenu->addAction (a);
637 actionSortChildren=a;
639 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
640 a->setShortcut ( Qt::Key_ScrollLock );
641 a->setStatusTip (tr( "Scroll branch" ) );
642 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
644 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
645 alt->setShortcut ( Qt::Key_S ); // Scroll branch
646 alt->setStatusTip (tr( "Scroll branch" ));
647 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
648 #if defined(Q_OS_MACX)
649 actionToggleScroll=alt;
651 actionToggleScroll=a;
653 actionToggleScroll->setEnabled (false);
654 actionToggleScroll->setToggleAction(true);
655 tb->addAction (actionToggleScroll);
656 editMenu->addAction ( actionToggleScroll);
657 editMenu->addAction (actionToggleScroll);
660 actionListBranches.append(actionToggleScroll);
662 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
663 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
664 editMenu->addAction (a);
665 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
667 editMenu->addSeparator();
669 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
670 a->setStatusTip (tr( "Find" ) );
671 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
672 editMenu->addAction (a);
673 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
675 editMenu->addSeparator();
677 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
678 a->setShortcut (Qt::CTRL + Qt::Key_U );
679 a->setShortcut (tr( "Open URL" ));
682 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
685 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
686 a->setStatusTip (tr( "Open URL in new tab" ));
687 //a->setShortcut (Qt::CTRL+Qt::Key_U );
689 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
692 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
693 a->setStatusTip (tr( "Open all URLs in subtree" ));
695 actionListBranches.append(a);
696 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
697 actionOpenMultipleURLTabs=a;
699 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
700 a->setStatusTip ( tr( "Edit URL" ) );
701 a->setShortcut ( Qt::Key_U );
702 a->setShortcutContext (Qt::WindowShortcut);
703 actionListBranches.append(a);
705 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
708 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
709 a->setStatusTip ( tr( "Edit local URL" ) );
710 a->setShortcut (Qt::SHIFT + Qt::Key_U );
711 a->setShortcutContext (Qt::WindowShortcut);
712 actionListBranches.append(a);
714 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
717 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
718 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
719 a->setEnabled (false);
720 actionListBranches.append(a);
721 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
724 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
725 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
726 a->setEnabled (false);
727 actionListBranches.append(a);
728 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
729 actionBugzilla2URL=a;
731 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
732 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
733 a->setEnabled (false);
734 actionListBranches.append(a);
735 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
738 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
739 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
741 a->setEnabled (false);
742 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
745 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
746 a->setStatusTip ( tr( "Open all vym links in subtree" ));
747 a->setEnabled (false);
748 actionListBranches.append(a);
749 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
750 actionOpenMultipleVymLinks=a;
753 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
754 a->setEnabled (false);
755 a->setStatusTip ( tr( "Edit link to another vym map" ));
756 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
757 actionListBranches.append(a);
760 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
761 a->setStatusTip ( tr( "Delete link to another vym map" ));
762 a->setEnabled (false);
763 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
764 actionDeleteVymLink=a;
766 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
767 a->setStatusTip ( tr( "Hide object in exports" ) );
768 a->setShortcut (Qt::Key_H );
769 a->setToggleAction(true);
771 a->setEnabled (false);
772 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
773 actionToggleHideExport=a;
775 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
776 a->setStatusTip ( tr( "Edit Map Info" ));
777 a->setEnabled (true);
778 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
781 // Import at selection (adding to selection)
782 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
783 a->setStatusTip (tr( "Add map at selection" ));
784 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
785 a->setEnabled (false);
786 actionListBranches.append(a);
789 // Import at selection (replacing selection)
790 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
791 a->setStatusTip (tr( "Replace selection with map" ));
792 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
793 a->setEnabled (false);
794 actionListBranches.append(a);
795 actionImportReplace=a;
798 a = new QAction( tr( "Save selection","Edit menu" ), this);
799 a->setStatusTip (tr( "Save selection" ));
800 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
801 a->setEnabled (false);
802 actionListBranches.append(a);
805 // Only remove branch, not its children
806 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
807 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
808 a->setShortcut (Qt::ALT + Qt::Key_Delete );
809 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
810 a->setEnabled (false);
812 actionListBranches.append(a);
813 actionDeleteKeepChildren=a;
815 // Only remove children of a branch
816 a = new QAction( tr( "Remove children","Edit menu" ), this);
817 a->setStatusTip (tr( "Remove children of branch" ));
818 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
819 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
820 a->setEnabled (false);
821 actionListBranches.append(a);
822 actionDeleteChildren=a;
824 // Shortcuts for navigating with cursor:
825 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
826 a->setStatusTip ( tr( "Select upper branch" ));
827 a->setShortcut (Qt::Key_Up );
828 a->setShortcutContext (Qt::WindowShortcut);
830 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
831 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
832 a->setStatusTip (tr( "Select lower branch" ));
833 a->setShortcut ( Qt::Key_Down );
834 a->setShortcutContext (Qt::WindowShortcut);
836 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
837 a = new QAction(tr( "Select left branch","Edit menu" ), this);
838 a->setStatusTip ( tr( "Select left branch" ));
839 a->setShortcut (Qt::Key_Left );
840 a->setShortcutContext (Qt::WindowShortcut);
842 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
843 a = new QAction( tr( "Select child branch","Edit menu" ), this);
844 a->setStatusTip (tr( "Select right branch" ));
845 a->setShortcut (Qt::Key_Right);
846 a->setShortcutContext (Qt::WindowShortcut);
848 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
849 a = new QAction( tr( "Select first branch","Edit menu" ), this);
850 a->setStatusTip (tr( "Select first branch" ));
851 a->setShortcut (Qt::Key_Home );
852 a->setShortcutContext (Qt::WindowShortcut);
854 a->setEnabled (false);
855 editMenu->addAction (a);
856 actionListBranches.append(a);
858 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
859 a = new QAction( tr( "Select last branch","Edit menu" ),this);
860 a->setStatusTip (tr( "Select last branch" ));
861 a->setShortcut ( Qt::Key_End );
862 a->setShortcutContext (Qt::WindowShortcut);
864 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
865 a->setEnabled (false);
866 editMenu->addAction (a);
867 actionListBranches.append(a);
870 a = new QAction( tr( "Add Image...","Edit menu" ), this);
871 a->setStatusTip (tr( "Add Image" ));
872 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
875 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
876 a->setStatusTip (tr( "Set properties for selection" ));
877 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
878 a->setShortcutContext (Qt::WindowShortcut);
879 a->setToggleAction (true);
881 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
882 actionViewTogglePropertyWindow=a;
886 void Main::setupFormatActions()
888 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
890 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
891 tb->setObjectName ("formatTB");
894 pix.fill (Qt::black);
895 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
896 a->setStatusTip ( tr( "Set Color" ));
897 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
899 formatMenu->addAction (a);
901 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
902 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
903 a->setShortcut (Qt::CTRL + Qt::Key_K );
904 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
905 a->setEnabled (false);
907 formatMenu->addAction (a);
908 actionListBranches.append(a);
909 actionFormatPickColor=a;
911 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
912 a->setStatusTip ( tr( "Color branch" ) );
913 a->setShortcut (Qt::CTRL + Qt::Key_B);
914 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
915 a->setEnabled (false);
917 formatMenu->addAction (a);
918 actionListBranches.append(a);
919 actionFormatColorSubtree=a;
921 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
922 a->setStatusTip ( tr( "Color Subtree" ));
923 a->setShortcut (Qt::CTRL + Qt::Key_T);
924 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
925 a->setEnabled (false);
926 formatMenu->addAction (a);
928 actionListBranches.append(a);
929 actionFormatColorSubtree=a;
931 formatMenu->addSeparator();
932 actionGroupFormatLinkStyles=new QActionGroup ( this);
933 actionGroupFormatLinkStyles->setExclusive (true);
934 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
935 a->setStatusTip (tr( "Line" ));
936 a->setToggleAction(true);
937 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
938 formatMenu->addAction (a);
939 actionFormatLinkStyleLine=a;
940 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
941 a->setStatusTip (tr( "Line" ));
942 a->setToggleAction(true);
943 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
944 formatMenu->addAction (a);
945 actionFormatLinkStyleParabel=a;
946 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
947 a->setStatusTip (tr( "PolyLine" ));
948 a->setToggleAction(true);
949 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
950 formatMenu->addAction (a);
951 actionFormatLinkStylePolyLine=a;
952 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
953 a->setStatusTip (tr( "PolyParabel" ) );
954 a->setToggleAction(true);
955 a->setChecked (true);
956 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
957 formatMenu->addAction (a);
958 actionFormatLinkStylePolyParabel=a;
960 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
961 a->setStatusTip (tr( "Hide link" ));
962 a->setToggleAction(true);
963 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
964 actionFormatHideLinkUnselected=a;
966 formatMenu->addSeparator();
967 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
968 a->setStatusTip (tr( "Use same color for links and headings" ));
969 a->setToggleAction(true);
970 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
971 formatMenu->addAction (a);
972 actionFormatLinkColorHint=a;
974 pix.fill (Qt::white);
975 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
976 a->setStatusTip (tr( "Set Link Color" ));
977 formatMenu->addAction (a);
978 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
979 actionFormatLinkColor=a;
981 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
982 a->setStatusTip (tr( "Set Selection Color" ));
983 formatMenu->addAction (a);
984 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
985 actionFormatSelectionColor=a;
987 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
988 a->setStatusTip (tr( "Set Background Color" ));
989 formatMenu->addAction (a);
990 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
991 actionFormatBackColor=a;
993 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
994 a->setStatusTip (tr( "Set Background image" ));
995 formatMenu->addAction (a);
996 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
997 actionFormatBackImage=a;
1001 void Main::setupViewActions()
1003 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1004 tb->setLabel( "View Actions" );
1005 tb->setObjectName ("viewTB");
1006 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1009 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1010 a->setStatusTip ( tr( "Zoom reset" ) );
1011 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1013 viewMenu->addAction (a);
1014 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1016 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1017 a->setStatusTip (tr( "Zoom in" ));
1018 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1020 viewMenu->addAction (a);
1021 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1023 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1024 a->setStatusTip (tr( "Zoom out" ));
1025 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1027 viewMenu->addAction (a);
1028 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1030 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1031 a->setStatusTip (tr( "Show selection" ));
1032 a->setShortcut (Qt::Key_Period);
1034 viewMenu->addAction (a);
1035 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1037 viewMenu->addSeparator();
1039 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1040 a->setStatusTip ( tr( "Show Note Editor" ));
1041 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1042 a->setToggleAction(true);
1044 viewMenu->addAction (a);
1045 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1046 actionViewToggleNoteEditor=a;
1048 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1049 a->setStatusTip ( tr( "Show History Window" ));
1050 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1051 a->setToggleAction(true);
1053 viewMenu->addAction (a);
1054 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1055 actionViewToggleHistoryWindow=a;
1057 viewMenu->addAction (actionViewTogglePropertyWindow);
1059 viewMenu->addSeparator();
1061 a = new QAction(tr( "Antialiasing","View action" ),this );
1062 a->setStatusTip ( tr( "Antialiasing" ));
1063 a->setToggleAction(true);
1064 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1065 viewMenu->addAction (a);
1066 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1067 actionViewToggleAntiAlias=a;
1069 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1070 a->setStatusTip (a->text());
1071 a->setToggleAction(true);
1072 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1073 viewMenu->addAction (a);
1074 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1075 actionViewToggleSmoothPixmapTransform=a;
1077 a = new QAction(tr( "Next Map","View action" ), this);
1078 a->setStatusTip (a->text());
1079 a->setShortcut (Qt::ALT + Qt::Key_N );
1080 viewMenu->addAction (a);
1081 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1083 a = new QAction (tr( "Previous Map","View action" ), this );
1084 a->setStatusTip (a->text());
1085 a->setShortcut (Qt::ALT + Qt::Key_P );
1086 viewMenu->addAction (a);
1087 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1091 void Main::setupModeActions()
1093 //QPopupMenu *menu = new QPopupMenu( this );
1094 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1096 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1097 tb->setObjectName ("modesTB");
1099 actionGroupModModes=new QActionGroup ( this);
1100 actionGroupModModes->setExclusive (true);
1101 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1102 a->setShortcut (Qt::Key_J);
1103 a->setStatusTip ( tr( "Use modifier to color branches" ));
1104 a->setToggleAction(true);
1107 actionModModeColor=a;
1109 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1110 a->setShortcut( Qt::Key_K);
1111 a->setStatusTip( tr( "Use modifier to copy" ));
1112 a->setToggleAction(true);
1114 actionModModeCopy=a;
1116 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1117 a->setShortcut (Qt::Key_L);
1118 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1119 a->setToggleAction(true);
1121 actionModModeXLink=a;
1125 void Main::setupFlagActions()
1127 // Create System Flags
1131 systemFlagsDefault = new FlagRowObj ();
1132 systemFlagsDefault->setVisibility (false);
1133 systemFlagsDefault->setName ("systemFlagsDef");
1135 FlagObj *fo = new FlagObj ();
1136 fo->load(QPixmap(flagsPath+"flag-note.png"));
1137 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1139 fo->load(QPixmap(flagsPath+"flag-url.png"));
1140 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1142 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1143 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1145 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1146 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1148 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1149 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1151 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1152 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1154 // Create Standard Flags
1155 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1156 tb->setObjectName ("standardFlagTB");
1158 standardFlagsDefault = new FlagRowObj ();
1159 standardFlagsDefault->setVisibility (false);
1160 standardFlagsDefault->setName ("standardFlagsDef");
1161 standardFlagsDefault->setToolBar (tb);
1163 fo->load(flagsPath+"flag-exclamationmark.png");
1164 fo->setGroup("standard-mark");
1165 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1167 fo->load(flagsPath+"flag-questionmark.png");
1168 fo->setGroup("standard-mark");
1169 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1171 fo->load(flagsPath+"flag-hook-green.png");
1172 fo->setGroup("standard-hook");
1173 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1175 fo->load(flagsPath+"flag-cross-red.png");
1176 fo->setGroup("standard-hook");
1177 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1180 fo->load(flagsPath+"flag-stopsign.png");
1181 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1183 fo->load(flagsPath+"flag-smiley-good.png");
1184 fo->setGroup("standard-smiley");
1185 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1187 fo->load(flagsPath+"flag-smiley-sad.png");
1188 fo->setGroup("standard-smiley");
1189 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1191 fo->load(flagsPath+"flag-smiley-omg.png");
1192 fo->setGroup("standard-smiley");
1193 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1194 // Original omg.png (in KDE emoticons)
1197 fo->load(flagsPath+"flag-kalarm.png");
1198 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1200 fo->load(flagsPath+"flag-phone.png");
1201 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1203 fo->load(flagsPath+"flag-lamp.png");
1204 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1206 fo->load(flagsPath+"flag-arrow-up.png");
1207 fo->setGroup("standard-arrow");
1208 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1210 fo->load(flagsPath+"flag-arrow-down.png");
1211 fo->setGroup("standard-arrow");
1212 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1214 fo->load(flagsPath+"flag-arrow-2up.png");
1215 fo->setGroup("standard-arrow");
1216 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1218 fo->load(flagsPath+"flag-arrow-2down.png");
1219 fo->setGroup("standard-arrow");
1220 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1223 fo->load(flagsPath+"flag-thumb-up.png");
1224 fo->setGroup("standard-thumb");
1225 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1227 fo->load(flagsPath+"flag-thumb-down.png");
1228 fo->setGroup("standard-thumb");
1229 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1232 fo->load(flagsPath+"flag-rose.png");
1233 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1235 fo->load(flagsPath+"flag-heart.png");
1236 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1238 fo->load(flagsPath+"flag-present.png");
1239 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1241 fo->load(flagsPath+"flag-flash.png");
1242 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1244 // Original: xsldbg_output.png
1245 fo->load(flagsPath+"flag-info.png");
1246 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1248 // Original khelpcenter.png
1249 fo->load(flagsPath+"flag-lifebelt.png");
1250 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1256 fo->load(flagsPath+"freemind/warning.png");
1257 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1259 for (int i=1; i<8; i++)
1261 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1262 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1265 fo->load(flagsPath+"freemind/back.png");
1266 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1268 fo->load(flagsPath+"freemind/forward.png");
1269 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1271 fo->load(flagsPath+"freemind/attach.png");
1272 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1274 fo->load(flagsPath+"freemind/clanbomber.png");
1275 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1277 fo->load(flagsPath+"freemind/desktopnew.png");
1278 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1280 fo->load(flagsPath+"freemind/flag.png");
1281 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1284 fo->load(flagsPath+"freemind/gohome.png");
1285 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1288 fo->load(flagsPath+"freemind/kaddressbook.png");
1289 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1291 fo->load(flagsPath+"freemind/knotify.png");
1292 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1294 fo->load(flagsPath+"freemind/korn.png");
1295 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1297 fo->load(flagsPath+"freemind/mail.png");
1298 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1300 fo->load(flagsPath+"freemind/password.png");
1301 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1303 fo->load(flagsPath+"freemind/pencil.png");
1304 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1306 fo->load(flagsPath+"freemind/stop.png");
1307 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1309 fo->load(flagsPath+"freemind/wizard.png");
1310 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1312 fo->load(flagsPath+"freemind/xmag.png");
1313 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1315 fo->load(flagsPath+"freemind/bell.png");
1316 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1318 fo->load(flagsPath+"freemind/bookmark.png");
1319 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1321 fo->load(flagsPath+"freemind/penguin.png");
1322 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1324 fo->load(flagsPath+"freemind/licq.png");
1325 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1330 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1333 fo->setToolTip (tooltip);
1334 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1340 fo->setAlwaysVisible(aw);
1341 a->setCheckable(true);
1342 a->setObjectName(fo->getName());
1343 a->setToolTip(tooltip);
1344 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1345 standardFlagsDefault->addFlag (fo);
1349 systemFlagsDefault->addFlag (fo);
1353 void Main::setupNetworkActions()
1355 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1357 QMenu *netMenu = menuBar()->addMenu( "Network" );
1361 a = new QAction( "Start TCPserver for MapEditor",this);
1362 //a->setStatusTip ( "Set application to open pdf files"));
1363 a->setShortcut ( Qt::Key_T ); //New TCP server
1364 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1365 netMenu->addAction (a);
1367 a = new QAction( "Connect MapEditor to server",this);
1368 //a->setStatusTip ( "Set application to open pdf files"));
1369 a->setShortcut ( Qt::Key_C ); // Connect to server
1370 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1371 netMenu->addAction (a);
1375 void Main::setupSettingsActions()
1377 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1381 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1382 a->setStatusTip ( tr( "Set application to open pdf files"));
1383 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1384 settingsMenu->addAction (a);
1386 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1387 a->setStatusTip( tr( "Set application to open external links"));
1388 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1389 settingsMenu->addAction (a);
1391 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1392 a->setStatusTip( tr( "Set path for macros"));
1393 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1394 settingsMenu->addAction (a);
1396 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1397 a->setStatusTip( tr( "Set number of undo levels"));
1398 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1399 settingsMenu->addAction (a);
1401 settingsMenu->addSeparator();
1403 a = new QAction( tr( "Autosave","Settings action"), this);
1404 a->setStatusTip( tr( "Autosave"));
1405 a->setToggleAction(true);
1406 a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool());
1407 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1408 settingsMenu->addAction (a);
1409 actionSettingsAutosaveToggle=a;
1411 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1412 a->setStatusTip( tr( "Autosave time"));
1413 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1414 settingsMenu->addAction (a);
1415 actionSettingsAutosaveTime=a;
1417 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1418 a->setStatusTip( tr( "Write backup file on save"));
1419 a->setToggleAction(true);
1420 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1421 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1422 settingsMenu->addAction (a);
1423 actionSettingsWriteBackupFile=a;
1425 settingsMenu->addSeparator();
1427 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1428 a->setStatusTip( tr( "Edit branch after adding it" ));
1429 a->setToggleAction(true);
1430 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1431 settingsMenu->addAction (a);
1432 actionSettingsAutoEditNewBranch=a;
1434 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1435 a->setStatusTip( tr( "Select branch after adding it" ));
1436 a->setToggleAction(true);
1437 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1438 settingsMenu->addAction (a);
1439 actionSettingsAutoSelectNewBranch=a;
1441 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1442 a->setStatusTip( tr( "Select heading before editing" ));
1443 a->setToggleAction(true);
1444 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1445 settingsMenu->addAction (a);
1446 actionSettingsAutoSelectText=a;
1448 a= new QAction( tr( "Delete key","Settings action" ), this);
1449 a->setStatusTip( tr( "Delete key for deleting branches" ));
1450 a->setToggleAction(true);
1451 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1452 settingsMenu->addAction (a);
1453 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1454 actionSettingsUseDelKey=a;
1456 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1457 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1458 a->setToggleAction(true);
1459 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1460 settingsMenu->addAction (a);
1461 actionSettingsUseFlagGroups=a;
1463 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1464 a->setStatusTip( tr( "Use hide flag during exports " ));
1465 a->setToggleAction(true);
1466 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1467 settingsMenu->addAction (a);
1468 actionSettingsUseHideExport=a;
1470 a = new QAction( tr( "Animation","Settings action"), this);
1471 a->setStatusTip( tr( "Animation"));
1472 a->setToggleAction(true);
1473 a->setOn (settings.value("/animation/use",false).toBool() );
1474 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1475 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1477 settingsMenu->addAction (a);
1479 actionSettingsUseAnimation=a;
1483 void Main::setupTestActions()
1485 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1488 a = new QAction( "Test function 1" , this);
1489 a->setStatusTip( "Call test function 1" );
1490 testMenu->addAction (a);
1491 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1493 a = new QAction( "Test function 2" , this);
1494 a->setStatusTip( "Call test function 2" );
1495 testMenu->addAction (a);
1496 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1498 a = new QAction( "Command" , this);
1499 a->setStatusTip( "Enter command to call in editor" );
1500 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1501 testMenu->addAction (a);
1505 void Main::setupHelpActions()
1507 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1510 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1511 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1512 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1513 helpMenu->addAction (a);
1515 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1516 a->setStatusTip( tr( "Open VYM example maps " ));
1517 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1518 helpMenu->addAction (a);
1520 a = new QAction( tr( "About VYM","Help action" ), this);
1521 a->setStatusTip( tr( "About VYM")+vymName);
1522 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1523 helpMenu->addAction (a);
1525 a = new QAction( tr( "About QT","Help action" ), this);
1526 a->setStatusTip( tr( "Information about QT toolkit" ));
1527 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1528 helpMenu->addAction (a);
1532 void Main::setupContextMenus()
1536 // Context Menu for branch or mapcenter
1537 branchContextMenu =new QMenu (this);
1538 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1539 branchContextMenu->addSeparator();
1542 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1543 branchAddContextMenu->addAction (actionPaste );
1544 branchAddContextMenu->addAction ( actionAddBranch );
1545 branchAddContextMenu->addAction ( actionAddBranchBefore );
1546 branchAddContextMenu->addAction ( actionAddBranchAbove);
1547 branchAddContextMenu->addAction ( actionAddBranchBelow );
1548 branchAddContextMenu->addSeparator();
1549 branchAddContextMenu->addAction ( actionImportAdd );
1550 branchAddContextMenu->addAction ( actionImportReplace );
1553 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1554 branchRemoveContextMenu->addAction (actionCut);
1555 branchRemoveContextMenu->addAction ( actionDelete );
1556 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1557 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1560 actionSaveBranch->addTo( branchContextMenu );
1561 actionFileNewCopy->addTo (branchContextMenu );
1563 branchContextMenu->addSeparator();
1564 branchContextMenu->addAction ( actionLoadImage);
1566 // Submenu for Links (URLs, vymLinks)
1567 branchLinksContextMenu =new QMenu (this);
1569 branchContextMenu->addSeparator();
1570 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1571 branchLinksContextMenu->addAction ( actionOpenURL );
1572 branchLinksContextMenu->addAction ( actionOpenURLTab );
1573 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1574 branchLinksContextMenu->addAction ( actionURL );
1575 branchLinksContextMenu->addAction ( actionLocalURL );
1576 branchLinksContextMenu->addAction ( actionHeading2URL );
1577 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1578 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1580 branchLinksContextMenu->addAction ( actionFATE2URL );
1582 branchLinksContextMenu->addSeparator();
1583 branchLinksContextMenu->addAction ( actionOpenVymLink );
1584 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1585 branchLinksContextMenu->addAction ( actionVymLink );
1586 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1589 // Context Menu for XLinks in a branch menu
1590 // This will be populated "on demand" in MapEditor::updateActions
1591 branchContextMenu->addSeparator();
1592 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1593 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1594 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1595 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1598 // Context menu for floatimage
1599 floatimageContextMenu =new QMenu (this);
1600 a= new QAction (tr ("Save image","Context action"),this);
1601 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1602 floatimageContextMenu->addAction (a);
1604 floatimageContextMenu->addSeparator();
1605 actionCopy->addTo( floatimageContextMenu );
1606 actionCut->addTo( floatimageContextMenu );
1608 floatimageContextMenu->addSeparator();
1609 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1612 // Context menu for canvas
1613 canvasContextMenu =new QMenu (this);
1614 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1615 actionAddMapCenter->addTo( canvasContextMenu );
1616 actionMapInfo->addTo( canvasContextMenu );
1617 canvasContextMenu->insertSeparator();
1618 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1619 canvasContextMenu->insertSeparator();
1620 actionFormatLinkColorHint->addTo( canvasContextMenu );
1621 actionFormatLinkColor->addTo( canvasContextMenu );
1622 actionFormatSelectionColor->addTo( canvasContextMenu );
1623 actionFormatBackColor->addTo( canvasContextMenu );
1624 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME makes vym too slow: postponed for later version
1626 // Menu for last opened files
1628 for (int i = 0; i < MaxRecentFiles; ++i)
1630 recentFileActions[i] = new QAction(this);
1631 recentFileActions[i]->setVisible(false);
1632 fileLastMapsMenu->addAction(recentFileActions[i]);
1633 connect(recentFileActions[i], SIGNAL(triggered()),
1634 this, SLOT(fileLoadRecent()));
1636 setupRecentMapsMenu();
1639 void Main::setupRecentMapsMenu()
1641 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1643 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1645 for (int i = 0; i < numRecentFiles; ++i) {
1646 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1647 recentFileActions[i]->setText(text);
1648 recentFileActions[i]->setData(files[i]);
1649 recentFileActions[i]->setVisible(true);
1651 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1652 recentFileActions[j]->setVisible(false);
1655 void Main::setupMacros()
1657 for (int i = 0; i <= 11; i++)
1659 macroActions[i] = new QAction(this);
1660 macroActions[i]->setData(i);
1661 addAction (macroActions[i]);
1662 connect(macroActions[i], SIGNAL(triggered()),
1663 this, SLOT(callMacro()));
1665 macroActions[0]->setShortcut ( Qt::Key_F1 );
1666 macroActions[1]->setShortcut ( Qt::Key_F2 );
1667 macroActions[2]->setShortcut ( Qt::Key_F3 );
1668 macroActions[3]->setShortcut ( Qt::Key_F4 );
1669 macroActions[4]->setShortcut ( Qt::Key_F5 );
1670 macroActions[5]->setShortcut ( Qt::Key_F6 );
1671 macroActions[6]->setShortcut ( Qt::Key_F7 );
1672 macroActions[7]->setShortcut ( Qt::Key_F8 );
1673 macroActions[8]->setShortcut ( Qt::Key_F9 );
1674 macroActions[9]->setShortcut ( Qt::Key_F10 );
1675 macroActions[10]->setShortcut ( Qt::Key_F11 );
1676 macroActions[11]->setShortcut ( Qt::Key_F12 );
1679 void Main::hideEvent (QHideEvent * )
1681 if (!textEditor->isMinimized() ) textEditor->hide();
1684 void Main::showEvent (QShowEvent * )
1686 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1690 MapEditor* Main::currentMapEditor() const
1692 if ( tabWidget->currentPage())
1693 return tabModel.at(tabWidget->currentIndex())->getMapEditor();
1697 VymModel* Main::currentModel() const
1699 if ( tabWidget->currentPage())
1700 return tabModel.at(tabWidget->currentIndex());
1705 void Main::editorChanged(QWidget *)
1707 // Unselect all possibly selected objects
1708 // (Important to update note editor)
1709 for (int i=0;i<=tabWidget->count() -1;i++)
1711 tabModel.at(i)->unselect();
1713 VymModel *m=currentModel();
1714 if (m) m->reselect();
1716 // Update actions to in menus and toolbars according to editor
1720 VymView *Main::createView (VymModel *model)
1722 VymView *vm=new VymView;
1725 QTreeView *tv=new QTreeView;
1726 tv->setModel (model->getTreeModel() );
1728 // Create good old MapEditor
1729 MapEditor* me=model->getMapEditor();
1730 if (!me) me=new MapEditor (model);
1731 //me->viewport()->setFocus();
1732 me->setAntiAlias (actionViewToggleAntiAlias->isOn());
1733 me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
1742 vm->setSizes (sizes);
1747 void Main::fileNew()
1749 VymModel *m=new VymModel;
1750 tabModel.append (m);
1751 MapEditor* me = new MapEditor (m);
1752 me->setObjectName ("MapEditor");
1754 VymView *view=createView (m);
1755 tabWidget->addTab (view,tr("unnamed","MainWindow: name for new and empty file"));
1756 tabWidget->setCurrentIndex (tabModel.count() );
1758 // For the very first map we do not have flagrows yet...
1762 void Main::fileNewCopy()
1764 QString fn="unnamed";
1765 VymModel *srcModel=currentModel();
1770 VymModel *dstModel=tabModel.last ();
1771 dstModel->select("mc:");
1772 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1776 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1778 ErrorCode err=success;
1780 // fn is usually the archive, mapfile the file after uncompressing
1783 // Make fn absolute (needed for unzip)
1784 fn=QDir (fn).absPath();
1790 // Check, if map is already loaded
1792 while (i<=tabWidget->count() -1)
1794 if (tabModel.at(i)->getFilePath() == fn)
1796 // Already there, ask for confirmation
1797 QMessageBox mb( vymName,
1798 tr("The map %1\nis already opened."
1799 "Opening the same map in multiple editors may lead \n"
1800 "to confusion when finishing working with vym."
1801 "Do you want to").arg(fn),
1802 QMessageBox::Warning,
1803 QMessageBox::Yes | QMessageBox::Default,
1804 QMessageBox::Cancel | QMessageBox::Escape,
1805 QMessageBox::NoButton);
1806 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1807 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1810 case QMessageBox::Yes:
1811 // end loop and load anyway
1812 i=tabWidget->count();
1814 case QMessageBox::Cancel:
1824 int tabIndex=tabWidget->currentPageIndex();
1827 if ( !fn.isEmpty() )
1829 me = currentMapEditor();
1830 // Check first, if mapeditor exists
1831 // If it is not default AND we want a new map,
1832 // create a new mapeditor in a new tab
1833 if ( lmode==NewMap && (!me || !me->getModel()->isDefault() ) )
1835 VymModel *m=new VymModel;
1836 tabModel.append (m);
1837 VymView *view=createView (m);
1838 tabWidget->addTab (view,fn);
1839 tabIndex=tabWidget->count()-1;
1840 tabWidget->setCurrentPage (tabIndex);
1843 // Check, if file exists (important for creating new files
1844 // from command line
1845 if (!QFile(fn).exists() )
1847 QMessageBox mb( vymName,
1848 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1849 QMessageBox::Question,
1851 QMessageBox::Cancel | QMessageBox::Default,
1852 QMessageBox::NoButton );
1854 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1855 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1858 case QMessageBox::Yes:
1860 currentMapEditor()->getModel()->setFilePath(fn);
1861 tabWidget->setTabText (tabIndex,
1862 currentMapEditor()->getModel()->getFileName() );
1863 statusBar()->message( "Created " + fn , statusbarTime );
1866 case QMessageBox::Cancel:
1867 // don't create new map
1868 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1875 //tabWidget->currentPage() won't be NULL here, because of above...
1876 tabWidget->setCurrentIndex (tabIndex);
1877 me->viewport()->setFocus();
1881 // Save existing filename in case we import
1882 QString fn_org=me->getModel()->getFilePath();
1884 // Finally load map into mapEditor
1885 me->getModel()->setFilePath (fn);
1886 err=me->getModel()->load(fn,lmode,ftype);
1888 // Restore old (maybe empty) filepath, if this is an import
1890 me->getModel()->setFilePath (fn_org);
1893 // Finally check for errors and go home
1896 if (lmode==NewMap) fileCloseMap();
1897 statusBar()->message( "Could not load " + fn, statusbarTime );
1902 me->getModel()->setFilePath (fn);
1903 tabWidget->setTabText (tabIndex, me->getModel()->getFileName());
1904 if (!isInTmpDir (fn))
1906 // Only append to lastMaps if not loaded from a tmpDir
1907 // e.g. imported bookmarks are in a tmpDir
1908 addRecentMap(me->getModel()->getFilePath() );
1910 actionFilePrint->setEnabled (true);
1912 statusBar()->message( "Loaded " + fn, statusbarTime );
1919 void Main::fileLoad(const LoadMode &lmode)
1921 QStringList filters;
1922 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1923 QFileDialog *fd=new QFileDialog( this);
1924 fd->setDir (lastFileDir);
1925 fd->setFileMode (QFileDialog::ExistingFiles);
1926 fd->setFilters (filters);
1930 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1933 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1936 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1942 if ( fd->exec() == QDialog::Accepted )
1944 lastFileDir=fd->directory().path();
1945 QStringList flist = fd->selectedFiles();
1946 QStringList::Iterator it = flist.begin();
1947 while( it != flist.end() )
1950 fileLoad(*it, lmode);
1957 void Main::fileLoad()
1962 void Main::fileLoadRecent()
1964 QAction *action = qobject_cast<QAction *>(sender());
1966 fileLoad (action->data().toString(), NewMap);
1969 void Main::addRecentMap (const QString &fileName)
1972 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1973 files.removeAll(fileName);
1974 files.prepend(fileName);
1975 while (files.size() > MaxRecentFiles)
1978 settings.setValue("/mainwindow/recentFileList", files);
1980 setupRecentMapsMenu();
1983 void Main::fileSave(VymModel *m, const SaveMode &savemode)
1987 if ( m->getFilePath().isEmpty() )
1989 // We have no filepath yet,
1990 // call fileSaveAs() now, this will call fileSave()
1992 // First switch to editor
1993 //FIXME needed??? tabWidget->setCurrentWidget (m->getMapEditor());
1994 fileSaveAs(savemode);
1997 if (m->save (savemode)==success)
1999 statusBar()->message(
2000 tr("Saved %1").arg(m->getFilePath()),
2002 addRecentMap (m->getFilePath() );
2004 statusBar()->message(
2005 tr("Couldn't save ").arg(m->getFilePath()),
2009 void Main::fileSave()
2011 fileSave (currentModel(), CompleteMap);
2014 void Main::fileSave(VymModel *m)
2016 fileSave (m,CompleteMap);
2019 void Main::fileSaveAs(const SaveMode& savemode)
2023 if (currentMapEditor())
2025 if (savemode==CompleteMap)
2026 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2028 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2029 if ( !fn.isEmpty() )
2031 // Check for existing file
2032 if (QFile (fn).exists())
2034 QMessageBox mb( vymName,
2035 tr("The file %1\nexists already. Do you want to").arg(fn),
2036 QMessageBox::Warning,
2037 QMessageBox::Yes | QMessageBox::Default,
2038 QMessageBox::Cancel | QMessageBox::Escape,
2039 QMessageBox::NoButton);
2040 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2041 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2044 case QMessageBox::Yes:
2047 case QMessageBox::Cancel:
2054 // New file, add extension to filename, if missing
2055 // This is always .vym or .vyp, depending on savemode
2056 if (savemode==CompleteMap)
2058 if (!fn.contains (".vym") && !fn.contains (".xml"))
2062 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2071 VymModel *m=currentModel();
2073 fileSave(m, savemode);
2075 // Set name of tab, assuming current tab is the one we just saved
2076 if (savemode==CompleteMap)
2077 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2083 void Main::fileSaveAs()
2085 fileSaveAs (CompleteMap);
2088 void Main::fileImportKDEBookmarks()
2090 ImportKDEBookmarks im;
2092 if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2093 currentMapEditor()->getModel()->setFilePath ("");
2096 void Main::fileImportFirefoxBookmarks()
2098 Q3FileDialog *fd=new Q3FileDialog( this);
2099 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2100 fd->setMode (Q3FileDialog::ExistingFiles);
2101 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2102 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2105 if ( fd->exec() == QDialog::Accepted )
2107 ImportFirefoxBookmarks im;
2108 QStringList flist = fd->selectedFiles();
2109 QStringList::Iterator it = flist.begin();
2110 while( it != flist.end() )
2113 if (im.transform() &&
2114 success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2115 currentMapEditor() )
2116 currentMapEditor()->getModel()->setFilePath ("");
2123 void Main::fileImportFreemind()
2125 QStringList filters;
2126 filters <<"Freemind map (*.mm)"<<"All files (*)";
2127 QFileDialog *fd=new QFileDialog( this);
2128 fd->setDir (lastFileDir);
2129 fd->setFileMode (QFileDialog::ExistingFiles);
2130 fd->setFilters (filters);
2131 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2135 if ( fd->exec() == QDialog::Accepted )
2137 lastFileDir=fd->directory().path();
2138 QStringList flist = fd->selectedFiles();
2139 QStringList::Iterator it = flist.begin();
2140 while( it != flist.end() )
2143 if ( fileLoad (fn,NewMap, FreemindMap) )
2145 currentMapEditor()->getModel()->setFilePath ("");
2154 void Main::fileImportMM()
2158 Q3FileDialog *fd=new Q3FileDialog( this);
2159 fd->setDir (lastFileDir);
2160 fd->setMode (Q3FileDialog::ExistingFiles);
2161 fd->addFilter ("Mind Manager (*.mmap)");
2162 fd->setCaption(tr("Import")+" "+"Mind Manager");
2165 if ( fd->exec() == QDialog::Accepted )
2167 lastFileDir=fd->dirPath();
2168 QStringList flist = fd->selectedFiles();
2169 QStringList::Iterator it = flist.begin();
2170 while( it != flist.end() )
2173 if (im.transform() &&
2174 success==fileLoad (im.getTransformedFile(),NewMap) &&
2175 currentMapEditor() )
2176 currentMapEditor()->getModel()->setFilePath ("");
2183 void Main::fileImportDir()
2185 VymModel *m=currentModel();
2186 if (m) m->importDir();
2189 void Main::fileExportXML()
2191 VymModel *m=currentModel();
2192 if (m) m->exportXML();
2196 void Main::fileExportXHTML()
2198 VymModel *m=currentModel();
2199 if (m) m->exportXHTML();
2202 void Main::fileExportImage()
2204 VymModel *m=currentModel();
2205 if (m) m->exportImage();
2208 void Main::fileExportASCII()
2210 VymModel *m=currentModel();
2211 if (m) m->exportASCII();
2214 void Main::fileExportCSV() //FIXME not scriptable yet
2216 VymModel *m=currentModel();
2221 ex.addFilter ("CSV (*.csv)");
2222 ex.setDir(lastImageDir);
2223 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2224 if (ex.execDialog() )
2226 m->setExportMode(true);
2228 m->setExportMode(false);
2233 void Main::fileExportLaTeX() //FIXME not scriptable yet
2235 VymModel *m=currentModel();
2240 ex.addFilter ("Tex (*.tex)");
2241 ex.setDir(lastImageDir);
2242 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2243 if (ex.execDialog() )
2245 m->setExportMode(true);
2247 m->setExportMode(false);
2252 void Main::fileExportKDEBookmarks() //FIXME not scriptable yet
2254 ExportKDEBookmarks ex;
2255 VymModel *m=currentModel();
2263 void Main::fileExportTaskjuggler() //FIXME not scriptable yet
2265 ExportTaskjuggler ex;
2266 VymModel *m=currentModel();
2270 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2271 ex.setDir(lastImageDir);
2272 ex.addFilter ("Taskjuggler (*.tjp)");
2273 if (ex.execDialog() )
2275 m->setExportMode(true);
2277 m->setExportMode(false);
2282 void Main::fileExportOOPresentation() //FIXME not scriptable yet
2284 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2285 // TODO add preview in dialog
2286 //ImagePreview *p =new ImagePreview (fd);
2287 //fd->setContentsPreviewEnabled( TRUE );
2288 //fd->setContentsPreview( p, p );
2289 //fd->setPreviewMode( QFileDialog::Contents );
2290 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2291 fd->setDir (QDir().current());
2292 if (fd->foundConfig())
2296 if ( fd->exec() == QDialog::Accepted )
2298 QString fn=fd->selectedFile();
2299 if (!fn.contains (".odp"))
2302 //lastImageDir=fn.left(fn.findRev ("/"));
2303 VymModel *m=currentModel();
2304 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2308 QMessageBox::warning(0,
2310 tr("Couldn't find configuration for export to Open Office\n"));
2314 void Main::fileCloseMap()
2316 MapEditor *me = currentMapEditor();
2317 VymModel *m=currentModel();
2320 if (m->hasChanged())
2322 QMessageBox mb( vymName,
2323 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
2324 QMessageBox::Warning,
2325 QMessageBox::Yes | QMessageBox::Default,
2327 QMessageBox::Cancel | QMessageBox::Escape );
2328 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2329 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2332 case QMessageBox::Yes:
2334 fileSave(m, CompleteMap);
2336 case QMessageBox::No:
2337 // close without saving
2339 case QMessageBox::Cancel:
2345 tabModel.removeAt (tabWidget->currentIndex() );
2346 tabWidget->removeTab (tabWidget->currentIndex() );
2347 delete me; // FIXME if event was triggered _in_ ME this causes warning message
2352 void Main::filePrint()
2354 if (currentMapEditor())
2355 currentMapEditor()->print();
2358 void Main::fileExitVYM()
2360 // Check if one or more editors have changed
2362 for (i=0;i<=tabModel.count() -1;i++)
2364 // If something changed, ask what to do
2365 if (tabModel.at(i)->hasChanged())
2367 tabWidget->setCurrentPage(i);
2368 QMessageBox mb( vymName,
2369 tr("This map is not saved yet. Do you want to"),
2370 QMessageBox::Warning,
2371 QMessageBox::Yes | QMessageBox::Default,
2373 QMessageBox::Cancel | QMessageBox::Escape );
2374 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2375 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2378 mb.setActiveWindow();
2379 switch( mb.exec() ) {
2380 case QMessageBox::Yes:
2381 // save (the changed editors) and exit
2382 fileSave(currentModel(), CompleteMap);
2384 case QMessageBox::No:
2385 // exit without saving
2387 case QMessageBox::Cancel:
2388 // don't save and don't exit
2392 } // loop over all MEs
2396 void Main::editUndo()
2398 VymModel *m=currentModel();
2402 void Main::editRedo()
2404 VymModel *m=currentModel();
2408 void Main::gotoHistoryStep (int i)
2410 VymModel *m=currentModel();
2411 if (m) m->gotoHistoryStep(i);
2414 void Main::editCopy()
2416 VymModel *m=currentModel();
2420 void Main::editPaste()
2422 VymModel *m=currentModel();
2426 void Main::editCut()
2428 VymModel *m=currentModel();
2432 void Main::editOpenFindWindow()
2434 findWindow->popup();
2435 findWindow->raise();
2436 findWindow->setActiveWindow();
2439 void Main::editFind(QString s)
2441 VymModel *m=currentModel();
2445 BranchObj *bo=m->findText(s, cs);
2448 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2451 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2452 tr("No matches found for \"%1\"").arg(s));
2457 void Main::editFindChanged()
2458 { // Notify editor, to abort the current find process
2459 VymModel *m=currentModel();
2460 if (m) m->findReset();
2463 void Main::openTabs(QStringList urls)
2465 if (!urls.isEmpty())
2469 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2471 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2473 QString u=urls.takeFirst();
2474 procBrowser = new QProcess( this );
2476 procBrowser->start(browser,args);
2477 if ( !procBrowser->waitForStarted())
2479 // try to set path to browser
2480 QMessageBox::warning(0,
2482 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2483 tr("Please use Settings->")+tr("Set application to open an URL"));
2486 #if defined(Q_OS_WIN32)
2487 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2488 this->thread()->wait(3000);
2493 if (browser.contains("konqueror"))
2495 for (int i=0; i<urls.size(); i++)
2498 // Try to open new tab in existing konqueror started previously by vym
2499 p=new QProcess (this);
2501 #if defined(Q_OS_WIN32)
2502 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2503 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2504 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2505 "konqueror-mainwindow#1"<<
2509 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2510 "konqueror-mainwindow#1"<<
2514 p->start ("dcop",args);
2515 //cout << qPrintable (args.join(" "))<<endl;
2516 if ( !p->waitForStarted() ) success=false;
2519 QMessageBox::warning(0,
2521 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2523 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2525 for (int i=0; i<urls.size(); i++)
2527 // Try to open new tab in firefox
2528 p=new QProcess (this);
2529 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2530 p->start (browser,args);
2531 if ( !p->waitForStarted() ) success=false;
2534 QMessageBox::warning(0,
2536 tr("Couldn't start %1 to open a new tab").arg(browser));
2539 QMessageBox::warning(0,
2541 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2545 void Main::editOpenURL()
2548 VymModel *m=currentModel();
2551 QString url=m->getURL();
2553 if (url=="") return;
2554 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2555 procBrowser = new QProcess( this );
2557 procBrowser->start(browser,args);
2558 if ( !procBrowser->waitForStarted())
2560 // try to set path to browser
2561 QMessageBox::warning(0,
2563 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2564 tr("Please use Settings->")+tr("Set application to open an URL"));
2569 void Main::editOpenURLTab()
2571 VymModel *m=currentModel();
2575 urls.append(m->getURL());
2579 void Main::editOpenMultipleURLTabs()
2581 VymModel *m=currentModel();
2591 void Main::editURL()
2593 VymModel *m=currentModel();
2594 if (m) m->editURL();
2597 void Main::editLocalURL()
2599 VymModel *m=currentModel();
2600 if (m) m->editLocalURL();
2603 void Main::editHeading2URL()
2605 VymModel *m=currentModel();
2606 if (m) m->editHeading2URL();
2609 void Main::editBugzilla2URL()
2611 VymModel *m=currentModel();
2612 if (m) m->editBugzilla2URL();
2615 void Main::editFATE2URL()
2617 VymModel *m=currentModel();
2618 if (m) m->editFATE2URL();
2621 void Main::editHeadingFinished(VymModel *m)
2625 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2626 !prevSelection.isEmpty())
2627 m->select(prevSelection);
2633 void Main::editAttributeFinished()
2635 // only called from editHeading(), so there is a currentME
2638 MapEditor *me=currentMapEditor();
2641 me->setStateEditHeading (false);
2642 QPoint p; //Not used here, only to find out pos of branch
2644 QString s=me->getHeading(ok,p);
2646 #if defined(Q_OS_MACX)
2648 if (ok && s!=lineedit->text())
2649 me->setHeading(lineedit->text());
2651 lineedit->releaseKeyboard();
2655 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2656 !prevSelection.isEmpty())
2657 me->select(prevSelection);
2663 #include "attribute.h"
2664 #include "attributedialog.h"
2665 void Main::editAttribute()
2668 MapEditor *me=currentMapEditor();
2671 BranchObj *bo=me->getModel()->getSelectedBranch();
2674 AttributeDialog dia(this);
2675 dia.setTable (me->attributeTable() );
2677 dia.setMode (Definition);
2684 if (currentMapEditor())
2686 MapEditor *me=currentMapEditor();
2687 QString oldSel=me->getSelectString();
2689 if (lineedit->isVisible())
2690 editAttributeFinished();
2695 QString s=me->getHeading(ok,p);
2699 me->setStateEditHeading (true);
2700 #if defined(Q_OS_MACX)
2701 p=me->mapToGlobal (p);
2702 QDialog *d =new QDialog(NULL);
2703 QLineEdit *le=new QLineEdit (d);
2704 d->setWindowFlags (Qt::FramelessWindowHint);
2705 d->setGeometry(p.x(),p.y(),230,25);
2706 le->resize (d->width()-10,d->height());
2709 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2710 d->activateWindow();
2712 me->setHeading (le->text());
2715 editHeadingFinished();
2717 p=me->mapTo (this,p);
2718 lineedit->setGeometry(p.x(),p.y(),230,25);
2719 lineedit->setText(s);
2720 lineedit->setCursorPosition(1);
2721 lineedit->selectAll();
2723 lineedit->grabKeyboard();
2724 lineedit->setFocus();
2728 } // currentMapEditor()
2733 void Main::openVymLinks(const QStringList &vl)
2735 for (int j=0; j<vl.size(); j++)
2737 // compare path with already loaded maps
2740 for (i=0;i<=tabModel.count() -1;i++)
2742 if (vl.at(j)==tabModel.at(i)->getFilePath() )
2751 if (!QFile(vl.at(j)).exists() )
2752 QMessageBox::critical( 0, tr( "Critical Error" ),
2753 tr("Couldn't open map %1").arg(vl.at(j)));
2756 fileLoad (vl.at(j), NewMap);
2757 tabWidget->setCurrentIndex (tabWidget->count()-1);
2760 // Go to tab containing the map
2761 tabWidget->setCurrentIndex (index);
2765 void Main::editOpenVymLink()
2767 VymModel *m=currentModel();
2771 vl.append(m->getVymLink());
2776 void Main::editOpenMultipleVymLinks()
2778 QString currentVymLink;
2779 VymModel *m=currentModel();
2782 QStringList vl=m->getVymLinks();
2787 void Main::editVymLink()
2789 VymModel *m=currentModel();
2794 void Main::editDeleteVymLink()
2796 VymModel *m=currentModel();
2797 if (m) m->deleteVymLink();
2800 void Main::editToggleHideExport()
2802 VymModel *m=currentModel();
2803 if (m) m->toggleHideExport();
2806 void Main::editMapInfo()
2808 VymModel *m=currentModel();
2810 ExtraInfoDialog dia;
2811 dia.setMapName (m->getFileName() );
2812 dia.setAuthor (m->getAuthor() );
2813 dia.setComment(m->getComment() );
2815 /* FIXME no stats at the moment (view dependent...)
2818 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2828 if (!bo->getNote().isEmpty() ) n++;
2829 f+= bo->countFloatImages();
2831 xl+=bo->countXLinks();
2834 stats+=QString ("%1 branches\n").arg (b-1,6);
2835 stats+=QString ("%1 xLinks \n").arg (xl,6);
2836 stats+=QString ("%1 notes\n").arg (n,6);
2837 stats+=QString ("%1 images\n").arg (f,6);
2838 dia.setStats (stats);
2841 // Finally show dialog
2842 if (dia.exec() == QDialog::Accepted)
2844 m->setAuthor (dia.getAuthor() );
2845 m->setComment (dia.getComment() );
2849 void Main::editMoveUp()
2851 VymModel *m=currentModel();
2852 if (m) m->moveBranchUp();
2855 void Main::editMoveDown()
2857 VymModel *m=currentModel();
2858 if (m) m->moveBranchDown();
2861 void Main::editSortChildren()
2863 VymModel *m=currentModel();
2864 if (m) m->sortChildren();
2867 void Main::editToggleScroll()
2869 VymModel *m=currentModel();
2870 if (m) m->toggleScroll();
2873 void Main::editUnscrollChildren()
2875 VymModel *m=currentModel();
2876 if (m) m->unscrollChildren();
2879 void Main::editAddMapCenter()
2881 VymModel *m=currentModel();
2888 void Main::editNewBranch()
2890 VymModel *m=currentModel();
2893 BranchObj *bo=(BranchObj*)m->getSelection();
2894 BranchObj *newbo=m->addNewBranch(0);
2896 prevSelection=m->getSelectString(bo);
2902 if (actionSettingsAutoEditNewBranch->isOn())
2904 currentMapEditor()->editHeading();
2907 if (!prevSelection.isEmpty())
2909 m->select(prevSelection);
2915 void Main::editNewBranchBefore()
2917 VymModel *m=currentModel();
2920 BranchObj *bo=(BranchObj*)m->getSelection();
2921 BranchObj *newbo=m->addNewBranchBefore();
2928 if (actionSettingsAutoEditNewBranch->isOn())
2930 if (!actionSettingsAutoSelectNewBranch->isOn())
2931 prevSelection=m->getSelectString(bo);
2932 currentMapEditor()->editHeading();
2937 void Main::editNewBranchAbove()
2939 VymModel *m=currentModel();
2942 BranchObj *bo=(BranchObj*)m->getSelection();
2943 BranchObj *newbo=m->addNewBranch (-1);
2950 if (actionSettingsAutoEditNewBranch->isOn())
2952 if (!actionSettingsAutoSelectNewBranch->isOn())
2953 prevSelection=m->getSelectString (bo);
2954 currentMapEditor()->editHeading();
2959 void Main::editNewBranchBelow()
2961 VymModel *m=currentModel();
2964 BranchObj *bo=(BranchObj*)m->getSelection();
2965 BranchObj *newbo=m->addNewBranch (1);
2972 if (actionSettingsAutoEditNewBranch->isOn())
2974 if (!actionSettingsAutoSelectNewBranch->isOn())
2975 prevSelection=m->getSelectString(bo);
2976 currentMapEditor()->editHeading();
2981 void Main::editImportAdd()
2983 fileLoad (ImportAdd);
2986 void Main::editImportReplace()
2988 fileLoad (ImportReplace);
2991 void Main::editSaveBranch()
2993 fileSaveAs (PartOfMap);
2996 void Main::editDeleteKeepChildren()
2998 VymModel *m=currentModel();
2999 if (m) m->deleteKeepChildren();
3002 void Main::editDeleteChildren()
3004 VymModel *m=currentModel();
3005 if (m) m->deleteChildren();
3008 void Main::editDeleteSelection()
3010 VymModel *m=currentModel();
3011 if (m && actionSettingsUseDelKey->isOn())
3012 m->deleteSelection();
3015 void Main::editUpperBranch()
3017 VymModel *m=currentModel();
3018 if (m) m->selectUpperBranch();
3021 void Main::editLowerBranch()
3023 VymModel *m=currentModel();
3024 if (m) m->selectLowerBranch();
3027 void Main::editLeftBranch()
3029 VymModel *m=currentModel();
3030 if (m) m->selectLeftBranch();
3033 void Main::editRightBranch()
3035 VymModel *m=currentModel();
3036 if (m) m->selectRightBranch();
3039 void Main::editFirstBranch()
3041 VymModel *m=currentModel();
3042 if (m) m->selectFirstBranch();
3045 void Main::editLastBranch()
3047 VymModel *m=currentModel();
3048 if (m) m->selectLastBranch();
3051 void Main::editLoadImage()
3053 VymModel *m=currentModel();
3054 if (m) m->loadFloatImage();
3057 void Main::editSaveImage()
3059 VymModel *m=currentModel();
3060 if (m) m->saveFloatImage();
3063 void Main::editFollowXLink(QAction *a)
3066 VymModel *m=currentModel();
3068 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3071 void Main::editEditXLink(QAction *a)
3073 VymModel *m=currentModel();
3075 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3078 void Main::formatSelectColor()
3080 QColor col = QColorDialog::getColor((currentColor ), this );
3081 if ( !col.isValid() ) return;
3082 colorChanged( col );
3085 void Main::formatPickColor()
3087 VymModel *m=currentModel();
3089 colorChanged( m->getCurrentHeadingColor() );
3092 void Main::colorChanged(QColor c)
3094 QPixmap pix( 16, 16 );
3096 actionFormatColor->setIconSet( pix );
3100 void Main::formatColorBranch()
3102 VymModel *m=currentModel();
3103 if (m) m->colorBranch(currentColor);
3106 void Main::formatColorSubtree()
3108 VymModel *m=currentModel();
3109 if (m) m->colorSubtree (currentColor);
3112 void Main::formatLinkStyleLine()
3114 VymModel *m=currentModel();
3117 m->setMapLinkStyle("StyleLine");
3118 actionFormatLinkStyleLine->setOn(true);
3122 void Main::formatLinkStyleParabel()
3124 VymModel *m=currentModel();
3127 m->setMapLinkStyle("StyleParabel");
3128 actionFormatLinkStyleParabel->setOn(true);
3132 void Main::formatLinkStylePolyLine()
3134 VymModel *m=currentModel();
3137 m->setMapLinkStyle("StylePolyLine");
3138 actionFormatLinkStylePolyLine->setOn(true);
3142 void Main::formatLinkStylePolyParabel()
3144 VymModel *m=currentModel();
3147 m->setMapLinkStyle("StylePolyParabel");
3148 actionFormatLinkStylePolyParabel->setOn(true);
3152 void Main::formatSelectBackColor()
3154 VymModel *m=currentModel();
3155 if (m) m->selectMapBackgroundColor();
3158 void Main::formatSelectBackImage()
3160 VymModel *m=currentModel();
3162 m->selectMapBackgroundImage();
3165 void Main::formatSelectLinkColor()
3167 VymModel *m=currentModel();
3170 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3171 m->setMapDefLinkColor( col );
3175 void Main::formatSelectSelectionColor()
3177 VymModel *m=currentModel();
3180 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3181 m->setSelectionColor (col);
3186 void Main::formatToggleLinkColorHint()
3188 VymModel *m=currentModel();
3189 if (m) m->toggleMapLinkColorHint();
3193 void Main::formatHideLinkUnselected() //FIXME get rid of this with imagepropertydialog
3195 VymModel *m=currentModel();
3197 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3200 void Main::viewZoomReset()
3202 if (currentMapEditor())
3206 currentMapEditor()->setMatrix( m );
3210 void Main::viewZoomIn()
3212 if (currentMapEditor())
3214 QMatrix m = currentMapEditor()->matrix();
3215 m.scale( 1.25, 1.25 );
3216 currentMapEditor()->setMatrix( m );
3220 void Main::viewZoomOut()
3222 if (currentMapEditor())
3224 QMatrix m = currentMapEditor()->matrix();
3225 m.scale( 0.8, 0.8 );
3226 currentMapEditor()->setMatrix( m );
3230 void Main::viewCenter()
3232 VymModel *m=currentModel();
3233 if (m) m->ensureSelectionVisible();
3236 void Main::networkStartServer()
3238 VymModel *m=currentModel();
3239 if (m) m->newServer();
3242 void Main::networkConnect()
3244 VymModel *m=currentModel();
3245 if (m) m->connectToServer();
3248 bool Main::settingsPDF()
3250 // Default browser is set in constructor
3252 QString text = QInputDialog::getText(
3253 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3254 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3256 settings.setValue ("/mainwindow/readerPDF",text);
3261 bool Main::settingsURL()
3263 // Default browser is set in constructor
3265 QString text = QInputDialog::getText(
3266 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3267 settings.value("/mainwindow/readerURL").toString()
3270 settings.setValue ("/mainwindow/readerURL",text);
3274 void Main::settingsMacroDir()
3276 QDir defdir(vymBaseDir.path() + "/macros");
3277 if (!defdir.exists())
3279 QDir dir=QFileDialog::getExistingDirectory (
3281 tr ("Directory with vym macros:"),
3282 settings.value ("/macros/macroDir",defdir.path()).toString()
3285 settings.setValue ("/macros/macroDir",dir.absolutePath());
3288 void Main::settingsUndoLevels()
3291 int i = QInputDialog::getInteger(
3293 tr("QInputDialog::getInteger()"),
3294 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3297 settings.setValue ("/mapeditor/stepsTotal",i);
3298 QMessageBox::information( this, tr( "VYM -Information:" ),
3299 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3303 void Main::settingsAutosaveToggle()
3305 settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
3308 void Main::settingsAutosaveTime()
3311 int i = QInputDialog::getInteger(
3313 tr("QInputDialog::getInteger()"),
3314 tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3316 settings.setValue ("/mapeditor/autosave/ms",i * 1000);
3319 void Main::settingsWriteBackupFileToggle()
3321 settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3324 void Main::settingsToggleAnimation()
3326 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3329 void Main::settingsToggleDelKey()
3331 if (actionSettingsUseDelKey->isOn())
3333 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3336 actionDelete->setAccel (QKeySequence (""));
3340 void Main::windowToggleNoteEditor()
3342 if (textEditor->isVisible() )
3343 windowHideNoteEditor();
3345 windowShowNoteEditor();
3348 void Main::windowToggleHistory()
3350 if (historyWindow->isVisible())
3351 historyWindow->hide();
3353 historyWindow->show();
3357 void Main::windowToggleProperty()
3359 if (branchPropertyWindow->isVisible())
3360 branchPropertyWindow->hide();
3362 branchPropertyWindow->show();
3363 branchPropertyWindow->setModel (currentModel() );
3366 void Main::windowToggleAntiAlias()
3368 bool b=actionViewToggleAntiAlias->isOn();
3370 for (int i=0;i<tabModel.count();i++)
3372 me=tabModel.at(i)->getMapEditor();
3373 if (me) me->setAntiAlias(b);
3378 void Main::windowToggleSmoothPixmap()
3380 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3382 for (int i=0;i<tabModel.count();i++)
3385 me=tabModel.at(i)->getMapEditor();
3386 if (me) me->setSmoothPixmap(b);
3390 void Main::updateHistory(SimpleSettings &undoSet)
3392 historyWindow->update (undoSet);
3395 void Main::updateNoteFlag()
3397 // this slot is connected to TextEditor::textHasChanged()
3399 VymModel *m=currentModel();
3400 if (m) m->updateNoteFlag();
3403 void Main::updateSatellites(VymModel* model)
3405 branchPropertyWindow->setModel (model );
3408 void Main::updateActions()
3410 VymModel *m =currentModel();
3411 LinkableMapObj *selection;
3415 actionFilePrint->setEnabled (true);
3418 selection=m->getSelection();
3420 // Link style in context menu
3421 switch (m->getMapLinkStyle())
3423 case LinkableMapObj::Line:
3424 actionFormatLinkStyleLine->setOn(true);
3426 case LinkableMapObj::Parabel:
3427 actionFormatLinkStyleParabel->setOn(true);
3429 case LinkableMapObj::PolyLine:
3430 actionFormatLinkStylePolyLine->setOn(true);
3432 case LinkableMapObj::PolyParabel:
3433 actionFormatLinkStylePolyParabel->setOn(true);
3440 QPixmap pix( 16, 16 );
3441 pix.fill( m->getMapBackgroundColor() );
3442 actionFormatBackColor->setIconSet( pix );
3443 pix.fill( m->getSelectionColor() );
3444 actionFormatSelectionColor->setIconSet( pix );
3445 pix.fill( m->getMapDefLinkColor() );
3446 actionFormatLinkColor->setIconSet( pix );
3449 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3454 actionFilePrint->setEnabled (false);
3460 // updateActions is also called when NoteEditor is closed
3461 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3462 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3463 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3465 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3466 actionFormatLinkColorHint->setOn(true);
3468 actionFormatLinkColorHint->setOn(false);
3471 if (m && m->hasChanged() )
3472 actionFileSave->setEnabled( true);
3474 actionFileSave->setEnabled( true);
3475 if (m && m->isUndoAvailable())
3476 actionUndo->setEnabled( true);
3478 actionUndo->setEnabled( false);
3480 if (m && m->isRedoAvailable())
3481 actionRedo->setEnabled( true);
3483 actionRedo->setEnabled( false);
3487 if ( (typeid(*selection) == typeid(BranchObj)) ||
3488 (typeid(*selection) == typeid(MapCenterObj)) )
3490 BranchObj *bo=(BranchObj*)selection;
3491 // Take care of links
3492 if (bo->countXLinks()==0)
3494 branchXLinksContextMenuEdit->clear();
3495 branchXLinksContextMenuFollow->clear();
3500 branchXLinksContextMenuEdit->clear();
3501 branchXLinksContextMenuFollow->clear();
3502 for (int i=0; i<=bo->countXLinks();i++)
3504 bot=bo->XLinkTargetAt(i);
3507 s=bot->getHeading();
3508 if (s.length()>xLinkMenuWidth)
3509 s=s.left(xLinkMenuWidth)+"...";
3510 branchXLinksContextMenuFollow->addAction (s);
3511 branchXLinksContextMenuEdit->addAction (s);
3516 standardFlagsDefault->setEnabled (true);
3518 actionToggleScroll->setEnabled (true);
3519 if ( bo->isScrolled() )
3520 actionToggleScroll->setOn(true);
3522 actionToggleScroll->setOn(false);
3524 if ( bo->getURL().isEmpty() )
3526 actionOpenURL->setEnabled (false);
3527 actionOpenURLTab->setEnabled (false);
3531 actionOpenURL->setEnabled (true);
3532 actionOpenURLTab->setEnabled (true);
3534 if ( bo->getVymLink().isEmpty() )
3536 actionOpenVymLink->setEnabled (false);
3537 actionDeleteVymLink->setEnabled (false);
3540 actionOpenVymLink->setEnabled (true);
3541 actionDeleteVymLink->setEnabled (true);
3544 if (bo->canMoveBranchUp())
3545 actionMoveUp->setEnabled (true);
3547 actionMoveUp->setEnabled (false);
3548 if (bo->canMoveBranchDown())
3549 actionMoveDown->setEnabled (true);
3551 actionMoveDown->setEnabled (false);
3553 actionSortChildren->setEnabled (true);
3555 actionToggleHideExport->setEnabled (true);
3556 actionToggleHideExport->setOn (bo->hideInExport() );
3558 actionFileSave->setEnabled (true);
3559 actionCopy->setEnabled (true);
3560 actionCut->setEnabled (true);
3561 if (!clipboardEmpty)
3562 actionPaste->setEnabled (true);
3564 actionPaste->setEnabled (false);
3565 for (int i=0; i<actionListBranches.size(); ++i)
3566 actionListBranches.at(i)->setEnabled(true);
3567 actionDelete->setEnabled (true);
3568 actionFormatHideLinkUnselected->setOn
3569 (selection->getHideLinkUnselected());
3571 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3573 FloatObj *fo=(FloatImageObj*)selection;
3575 actionOpenURL->setEnabled (false);
3576 actionOpenVymLink->setEnabled (false);
3577 actionDeleteVymLink->setEnabled (false);
3578 actionToggleHideExport->setEnabled (true);
3579 actionToggleHideExport->setOn (fo->hideInExport() );
3582 actionCopy->setEnabled (true);
3583 actionCut->setEnabled (true);
3584 actionPaste->setEnabled (false);
3585 for (int i=0; i<actionListBranches.size(); ++i)
3586 actionListBranches.at(i)->setEnabled(false);
3587 actionDelete->setEnabled (true);
3588 actionFormatHideLinkUnselected->setOn
3589 ( selection->getHideLinkUnselected());
3590 actionMoveUp->setEnabled (false);
3591 actionMoveDown->setEnabled (false);
3596 standardFlagsDefault->setEnabled (false);
3597 actionFileSave->setEnabled (false);
3598 actionCopy->setEnabled (false);
3599 actionCut->setEnabled (false);
3600 actionPaste->setEnabled (false);
3601 for (int i=0; i<actionListBranches.size(); ++i)
3602 actionListBranches.at(i)->setEnabled(false);
3604 actionToggleScroll->setEnabled (false);
3605 actionOpenURL->setEnabled (false);
3606 actionOpenVymLink->setEnabled (false);
3607 actionDeleteVymLink->setEnabled (false);
3608 actionHeading2URL->setEnabled (false);
3609 actionDelete->setEnabled (false);
3610 actionMoveUp->setEnabled (false);
3611 actionMoveDown->setEnabled (false);
3612 actionSortChildren->setEnabled (false);
3613 actionToggleHideExport->setEnabled (false);
3617 Main::ModMode Main::getModMode()
3619 if (actionModModeColor->isOn()) return ModModeColor;
3620 if (actionModModeCopy->isOn()) return ModModeCopy;
3621 if (actionModModeXLink->isOn()) return ModModeXLink;
3625 bool Main::autoEditNewBranch()
3627 return actionSettingsAutoEditNewBranch->isOn();
3630 bool Main::autoSelectNewBranch()
3632 return actionSettingsAutoSelectNewBranch->isOn();
3635 bool Main::useFlagGroups()
3637 return actionSettingsUseFlagGroups->isOn();
3640 void Main::windowShowNoteEditor()
3642 textEditor->setShowWithMain(true);
3644 actionViewToggleNoteEditor->setOn (true);
3647 void Main::windowHideNoteEditor()
3649 textEditor->setShowWithMain(false);
3651 actionViewToggleNoteEditor->setOn (false);
3654 void Main::setScript (const QString &script)
3656 scriptEditor->setScript (script);
3659 void Main::runScript (const QString &script)
3661 VymModel *m=currentModel();
3662 if (m) m->runScript (script);
3665 void Main::runScriptEverywhere (const QString &script)
3668 for (int i=0;i<=tabWidget->count() -1;i++)
3670 me=(MapEditor*)tabWidget->page(i);
3671 if (me) me->getModel()->runScript (script);
3675 void Main::windowNextEditor()
3677 if (tabWidget->currentIndex() < tabWidget->count())
3678 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3681 void Main::windowPreviousEditor()
3683 if (tabWidget->currentIndex() >0)
3684 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3687 void Main::standardFlagChanged()
3689 if (currentMapEditor())
3690 currentMapEditor()->toggleStandardFlag(sender()->name());
3693 void Main::testFunction1()
3695 if (!currentMapEditor()) return;
3696 currentMapEditor()->testFunction1();
3700 void Main::testFunction2()
3702 if (!currentMapEditor()) return;
3703 currentMapEditor()->testFunction2();
3706 void Main::testCommand()
3708 if (!currentMapEditor()) return;
3709 scriptEditor->show();
3712 QString com = QInputDialog::getText(
3713 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3714 if (ok) currentMapEditor()->parseAtom(com);
3718 void Main::helpDoc()
3720 QString locale = QLocale::system().name();
3722 if (locale.left(2)=="es")
3723 docname="vym_es.pdf";
3727 QStringList searchList;
3729 #if defined(Q_OS_MACX)
3730 searchList << "./vym.app/Contents/Resources/doc";
3731 #elif defined(Q_OS_WIN32)
3732 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3734 #if defined(VYM_DOCDIR)
3735 searchList << VYM_DOCDIR;
3737 // default path in SUSE LINUX
3738 searchList << "/usr/share/doc/packages/vym";
3741 searchList << "doc"; // relative path for easy testing in tarball
3742 searchList << "doc/tex"; // Easy testing working on vym.tex
3743 searchList << "/usr/share/doc/vym"; // Debian
3744 searchList << "/usr/share/doc/packages";// Knoppix
3748 for (int i=0; i<searchList.count(); ++i)
3750 docfile.setFileName(searchList.at(i)+"/"+docname);
3751 if (docfile.exists())
3760 QMessageBox::critical(0,
3761 tr("Critcal error"),
3762 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3767 Process *pdfProc = new Process();
3768 args << QDir::toNativeSeparators(docfile.fileName());
3770 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3771 if ( !pdfProc->waitForStarted() )
3774 QMessageBox::warning(0,
3776 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3777 tr("Please use Settings->")+tr("Set application to open PDF files"));
3784 void Main::helpDemo()
3786 QStringList filters;
3787 filters <<"VYM example map (*.vym)";
3788 QFileDialog *fd=new QFileDialog( this);
3789 #if defined(Q_OS_MACX)
3790 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3792 // default path in SUSE LINUX
3793 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3796 fd->setFileMode (QFileDialog::ExistingFiles);
3797 fd->setFilters (filters);
3798 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3802 if ( fd->exec() == QDialog::Accepted )
3804 lastFileDir=fd->directory().path();
3805 QStringList flist = fd->selectedFiles();
3806 QStringList::Iterator it = flist.begin();
3807 while( it != flist.end() )
3810 fileLoad(*it, NewMap);
3818 void Main::helpAbout()
3821 ad.setName ("aboutwindow");
3822 ad.setMinimumSize(500,500);
3823 ad.resize (QSize (500,500));
3827 void Main::helpAboutQT()
3829 QMessageBox::aboutQt( this, "Qt Application Example" );
3832 void Main::callMacro ()
3834 QAction *action = qobject_cast<QAction *>(sender());
3838 i=action->data().toInt();
3839 QString mDir (settings.value ("macros/macroDir").toString() );
3841 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3843 if ( !f.open( QIODevice::ReadOnly ) )
3845 QMessageBox::warning(0,
3847 tr("Couldn't find a macro at %1.\n").arg(fn)+
3848 tr("Please use Settings->")+tr("Set directory for vym macros"));
3852 QTextStream ts( &f );
3853 QString macro= ts.read();
3855 if (! macro.isEmpty())
3857 VymModel *m=currentModel();
3858 if (m) m->runScript(macro);