1 #include "mainwindow.h"
3 #include <QtDBus/QtDBus>
9 #include "aboutdialog.h"
10 #include "branchpropwindow.h"
11 #include "branchitem.h"
12 #include "exportoofiledialog.h"
16 #include "historywindow.h"
18 #include "mapeditor.h"
23 #include "texteditor.h"
24 #include "warningdialog.h"
26 #if defined(Q_OS_WIN32)
27 // Define only this structure as opposed to
28 // including full 'windows.h'. FindWindow
29 // clashes with the one in Win32 API.
30 typedef struct _PROCESS_INFORMATION
36 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
39 extern TextEditor *textEditor;
40 extern Main *mainWindow;
41 extern QString tmpVymDir;
42 extern QString clipboardDir;
43 extern QString clipboardFile;
44 extern bool clipboardEmpty;
45 extern int statusbarTime;
46 extern FlagRow *standardFlagsMaster;
47 extern FlagRow *systemFlagsMaster;
48 extern QString vymName;
49 extern QString vymVersion;
50 extern QString vymBuildDate;
53 QMenu* branchContextMenu;
54 QMenu* branchAddContextMenu;
55 QMenu* branchRemoveContextMenu;
56 QMenu* branchLinksContextMenu;
57 QMenu* branchXLinksContextMenuEdit;
58 QMenu* branchXLinksContextMenuFollow;
59 QMenu* floatimageContextMenu;
60 QMenu* canvasContextMenu;
61 QMenu* fileLastMapsMenu;
62 QMenu* fileImportMenu;
63 QMenu* fileExportMenu;
66 extern Settings settings;
67 extern Options options;
68 extern ImageIO imageIO;
70 extern QDir vymBaseDir;
71 extern QDir lastImageDir;
72 extern QDir lastFileDir;
73 #if defined(Q_OS_WIN32)
74 extern QDir vymInstallDir;
76 extern QString iconPath;
77 extern QString flagsPath;
80 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
81 QMainWindow(parent,name,f)
85 setCaption ("VYM - View Your Mind");
87 // Load window settings
88 #if defined(Q_OS_WIN32)
89 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
91 setWindowState(Qt::WindowMaximized);
96 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
97 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
100 // Sometimes we may need to remember old selections
104 currentColor=Qt::black;
106 // Create unique temporary directory
108 tmpVymDir=makeTmpDir (ok,"vym");
111 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
114 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
116 // Create direcctory for clipboard
117 clipboardDir=tmpVymDir+"/clipboard";
118 clipboardFile="map.xml";
119 QDir d(clipboardDir);
120 d.mkdir (clipboardDir,true);
121 makeSubDirs (clipboardDir);
126 // Satellite windows //////////////////////////////////////////
128 historyWindow=new HistoryWindow();
129 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
132 branchPropertyWindow = new BranchPropertyWindow();
133 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
135 // Connect TextEditor, so that we can update flags if text changes
136 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
137 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
139 // Connect HistoryWindow, so that we can update flags
140 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
143 // Initialize script editor
144 scriptEditor = new SimpleScriptEditor();
145 scriptEditor->move (50,50);
147 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
148 this, SLOT( runScript( QString ) ) );
151 // Initialize Find window
152 findWindow=new FindWindow(NULL);
153 findWindow->move (x(),y()+70);
154 connect (findWindow, SIGNAL( findButton(QString) ),
155 this, SLOT(editFind(QString) ) );
156 connect (findWindow, SIGNAL( somethingChanged() ),
157 this, SLOT(editFindChanged() ) );
159 // Initialize some settings, which are platform dependant
162 // application to open URLs
163 p="/mainwindow/readerURL";
164 #if defined(Q_OS_LINUX)
165 s=settings.value (p,"xdg-open").toString();
167 #if defined(Q_OS_MACX)
168 s=settings.value (p,"/usr/bin/open").toString();
171 #if defined(Q_OS_WIN32)
172 // Assume that system has been set up so that
173 // Explorer automagically opens up the URL
174 // in the user's preferred browser.
175 s=settings.value (p,"explorer").toString();
177 s=settings.value (p,"mozilla").toString();
181 settings.setValue( p,s);
183 // application to open PDFs
184 p="/mainwindow/readerPDF";
185 #if defined(Q_OS_LINUX)
186 s=settings.value (p,"xdg-open").toString();
188 #if defined(Q_OS_MACX)
189 s=settings.value (p,"/usr/bin/open").toString();
190 #elif defined(Q_OS_WIN32)
191 s=settings.value (p,"acrord32").toString();
193 s=settings.value (p,"acroread").toString();
196 settings.setValue( p,s);
198 // width of xLinksMenu
201 // Create tab widget which holds the maps
202 tabWidget= new QTabWidget (this);
203 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
204 this, SLOT( editorChanged( QWidget * ) ) );
206 setCentralWidget(tabWidget);
210 setupFormatActions();
214 setupNetworkActions();
215 setupSettingsActions();
218 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
221 // Status bar and progress bar there
224 progressBar=new QProgressBar;
226 statusBar()->addPermanentWidget(progressBar);
228 restoreState (settings.value("/mainwindow/state",0).toByteArray());
236 #if defined(Q_OS_WIN32)
237 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
239 settings.setValue ("/mainwindow/geometry/size", size());
240 settings.setValue ("/mainwindow/geometry/pos", pos());
241 settings.setValue ("/mainwindow/state",saveState(0));
243 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
244 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
245 settings.setValue( "/version/version", vymVersion );
246 settings.setValue( "/version/builddate", vymBuildDate );
248 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
249 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
250 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
251 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
252 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
253 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
254 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
255 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
257 //TODO save scriptEditor settings
259 // call the destructors
261 delete historyWindow;
262 delete branchPropertyWindow;
265 // Remove temporary directory
266 removeDir (QDir(tmpVymDir));
269 void Main::loadCmdLine()
271 /* TODO draw some kind of splashscreen while loading...
277 QStringList flist=options.getFileList();
278 QStringList::Iterator it=flist.begin();
280 while (it !=flist.end() )
282 fileLoad (*it, NewMap);
288 void Main::statusMessage(const QString &s)
290 // Surpress messages while progressbar during
292 if (progressMin==progressMax)
293 statusBar()->message( s);
296 void Main::setProgressMinimum (int min)
298 progressBar->setMinimum(min);
302 void Main::setProgressMaximum (int max)
304 progressBar->setMaximum(max);
308 statusBar()->addPermanentWidget(progressBar);
313 void Main::setProgressValue (int v)
315 progressBar->setValue (v);
318 void Main::removeProgressBar()
321 statusBar()->removeWidget(progressBar);
322 progressMax=progressMin=0;
325 void Main::closeEvent (QCloseEvent* )
331 void Main::setupFileActions()
333 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
334 QToolBar *tb = addToolBar( tr ("&Map") );
335 tb->setObjectName ("mapTB");
338 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
339 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
340 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
342 fileMenu->addAction (a);
343 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
345 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
346 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
347 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
348 fileMenu->addAction (a);
349 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
352 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
353 a->setStatusTip (tr( "Open","Status tip File menu" ) );
354 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
356 fileMenu->addAction (a);
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
359 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
360 fileMenu->addSeparator();
362 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
363 a->setStatusTip ( tr( "Save","Status tip file menu" ));
364 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
366 fileMenu->addAction (a);
367 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
370 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
371 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
372 fileMenu->addAction (a);
373 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
375 fileMenu->addSeparator();
377 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
379 a = new QAction(tr("KDE 3 Bookmarks"), this);
380 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
381 a->addTo (fileImportMenu);
382 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
384 a = new QAction(tr("KDE 4 Bookmarks"), this);
385 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
386 a->addTo (fileImportMenu);
387 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
389 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
391 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
392 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
393 a->addTo (fileImportMenu);
394 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
397 a = new QAction("Freemind...",this);
398 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
399 fileImportMenu->addAction (a);
400 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
402 a = new QAction("Mind Manager...",this);
403 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
404 fileImportMenu->addAction (a);
405 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
407 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
408 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
409 fileImportMenu->addAction (a);
410 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
412 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
414 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
415 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
416 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
417 fileExportMenu->addAction (a);
419 a = new QAction( "Open Office...", this);
420 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
421 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
422 fileExportMenu->addAction (a);
424 a = new QAction( "Webpage (XHTML)...",this );
425 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
426 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
427 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
428 fileExportMenu->addAction (a);
430 a = new QAction( "Text (ASCII)...", this);
431 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
432 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
433 fileExportMenu->addAction (a);
435 a = new QAction( "Spreadsheet (CSV)...", this);
436 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
437 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
438 fileExportMenu->addAction (a);
440 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
441 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
442 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
443 fileExportMenu->addAction (a);
445 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
446 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
447 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
448 fileExportMenu->addAction (a);
450 a = new QAction( "Taskjuggler...", this );
451 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
452 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
453 fileExportMenu->addAction (a);
455 a = new QAction( "LaTeX...", this);
456 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
457 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
458 fileExportMenu->addAction (a);
460 a = new QAction( "XML..." , this );
461 a->setStatusTip (tr( "Export as %1").arg("XML"));
462 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
463 fileExportMenu->addAction (a);
465 fileMenu->addSeparator();
467 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
468 a->setStatusTip ( tr( "Print" ,"File menu") );
469 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
471 fileMenu->addAction (a);
472 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
475 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
476 a->setStatusTip (tr( "Close Map" ) );
477 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
478 fileMenu->addAction (a);
479 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
481 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
482 a->setStatusTip ( tr( "Exit")+" "+vymName );
483 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
484 fileMenu->addAction (a);
485 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
490 void Main::setupEditActions()
492 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
493 tb->setLabel( "Edit Actions" );
494 tb->setObjectName ("actionsTB");
495 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
499 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
500 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
501 a->setStatusTip (tr( "Undo" ) );
502 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
503 a->setEnabled (false);
505 editMenu->addAction (a);
508 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
509 a->setStatusTip (tr( "Redo" ));
510 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
512 editMenu->addAction (a);
513 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
516 editMenu->addSeparator();
517 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
518 a->setStatusTip ( tr( "Copy" ) );
519 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
520 a->setEnabled (false);
522 editMenu->addAction (a);
523 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
526 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
527 a->setStatusTip ( tr( "Cut" ) );
528 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
529 a->setEnabled (false);
531 editMenu->addAction (a);
533 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
535 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
536 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
537 a->setStatusTip ( tr( "Paste" ) );
538 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
539 a->setEnabled (false);
541 editMenu->addAction (a);
545 // Shortcuts to modify heading:
546 a = new QAction(tr( "Edit heading","Edit menu" ),this);
547 a->setStatusTip ( tr( "edit Heading" ));
548 a->setShortcut ( Qt::Key_Enter); //Edit heading
549 // a->setShortcutContext (Qt::WindowShortcut);
551 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
552 actionListBranches.append(a);
553 a = new QAction( tr( "Edit heading","Edit menu" ), this);
554 a->setStatusTip (tr( "edit Heading" ));
555 a->setShortcut (Qt::Key_Return ); //Edit heading
556 //a->setShortcutContext (Qt::WindowShortcut);
558 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
559 actionListBranches.append(a);
560 editMenu->addAction (a);
563 a = new QAction( tr( "Edit heading","Edit menu" ), this);
564 a->setStatusTip (tr( "edit Heading" ));
565 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
566 a->setShortcutContext (Qt::WindowShortcut);
568 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
569 actionListBranches.append(a);
572 // Shortcut to delete selection
573 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
574 a->setStatusTip (tr( "Delete Selection" ));
575 a->setShortcut ( Qt::Key_Delete); //Delete selection
576 a->setShortcutContext (Qt::WindowShortcut);
578 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
581 // Shortcut to add mapcenter
582 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
583 a->setShortcut ( Qt::Key_M);
584 a->setShortcutContext (Qt::WindowShortcut);
585 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
586 //actionListBranches.append(a);
588 actionAddMapCenter = a;
591 // Shortcut to add branch
592 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
593 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
594 alt->setShortcut (Qt::Key_A); //Add branch
595 alt->setShortcutContext (Qt::WindowShortcut);
597 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
598 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
599 a->setStatusTip ( tr( "Add a branch as child of selection" ));
600 a->setShortcut (Qt::Key_Insert); //Add branch
601 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
602 actionListBranches.append(a);
603 #if defined (Q_OS_MACX)
604 // In OSX show different shortcut in menues, the keys work indepently always
609 editMenu->addAction (actionAddBranch);
610 tb->addAction (actionAddBranch);
613 // Add branch by inserting it at selection
614 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
615 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
616 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
617 a->setShortcutContext (Qt::WindowShortcut);
619 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
620 a->setEnabled (false);
621 actionListBranches.append(a);
622 actionAddBranchBefore=a;
623 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
624 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
625 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
626 a->setShortcutContext (Qt::WindowShortcut);
628 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
629 actionListBranches.append(a);
632 a = new QAction(tr( "Add branch above","Edit menu" ), this);
633 a->setStatusTip ( tr( "Add a branch above selection" ));
634 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
635 a->setShortcutContext (Qt::WindowShortcut);
637 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
638 a->setEnabled (false);
639 actionListBranches.append(a);
640 actionAddBranchAbove=a;
641 a = new QAction(tr( "Add branch above","Edit menu" ), this);
642 a->setStatusTip ( tr( "Add a branch above selection" ));
643 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
644 a->setShortcutContext (Qt::WindowShortcut);
646 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
647 actionListBranches.append(a);
650 a = new QAction(tr( "Add branch below","Edit menu" ), this);
651 a->setStatusTip ( tr( "Add a branch below selection" ));
652 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
653 a->setShortcutContext (Qt::WindowShortcut);
655 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
656 a->setEnabled (false);
657 actionListBranches.append(a);
658 actionAddBranchBelow=a;
659 a = new QAction(tr( "Add branch below","Edit menu" ), this);
660 a->setStatusTip ( tr( "Add a branch below selection" ));
661 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
662 a->setShortcutContext (Qt::WindowShortcut);
664 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
665 actionListBranches.append(a);
667 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
668 a->setStatusTip ( tr( "Move branch up" ) );
669 a->setShortcut (Qt::Key_PageUp ); // Move branch up
670 a->setEnabled (false);
672 editMenu->addAction (a);
673 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
676 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
677 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
678 a->setStatusTip (tr( "Move branch down" ) );
679 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
680 a->setEnabled (false);
682 editMenu->addAction (a);
685 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
686 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
687 a->setEnabled (true);
689 editMenu->addAction (a);
690 actionSortChildren=a;
692 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
693 alt->setShortcut ( Qt::Key_S ); // Scroll branch
694 alt->setStatusTip (tr( "Scroll branch" ));
695 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
696 #if defined(Q_OS_MACX)
697 actionToggleScroll=alt;
699 actionToggleScroll=a;
701 actionToggleScroll->setEnabled (false);
702 actionToggleScroll->setToggleAction(true);
703 tb->addAction (actionToggleScroll);
704 editMenu->addAction ( actionToggleScroll);
705 editMenu->addAction (actionToggleScroll);
708 actionListBranches.append(actionToggleScroll);
710 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
711 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
712 a->setStatusTip (tr( "Expand all branches" ));
713 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
715 actionExpandAll->setEnabled (false);
716 actionExpandAll->setToggleAction(false);
717 //tb->addAction (actionExpandAll);
718 editMenu->addAction ( actionExpandAll);
720 actionListBranches.append(actionExpandAll);
723 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
724 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
725 editMenu->addAction (a);
726 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
728 editMenu->addSeparator();
730 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
731 a->setStatusTip (tr( "Find" ) );
732 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
733 editMenu->addAction (a);
734 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
736 editMenu->addSeparator();
738 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
739 a->setShortcut (Qt::CTRL + Qt::Key_U );
740 a->setShortcut (tr( "Open URL" ));
743 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
746 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
747 a->setStatusTip (tr( "Open URL in new tab" ));
748 //a->setShortcut (Qt::CTRL+Qt::Key_U );
750 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
753 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
754 a->setStatusTip (tr( "Open all URLs in subtree" ));
756 actionListBranches.append(a);
757 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
758 actionOpenMultipleURLTabs=a;
760 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
761 a->setStatusTip ( tr( "Edit URL" ) );
762 a->setShortcut ( Qt::Key_U );
763 a->setShortcutContext (Qt::WindowShortcut);
764 actionListBranches.append(a);
766 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
769 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
770 a->setStatusTip ( tr( "Edit local URL" ) );
771 a->setShortcut (Qt::SHIFT + Qt::Key_U );
772 a->setShortcutContext (Qt::WindowShortcut);
773 actionListBranches.append(a);
775 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
778 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
779 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
780 a->setEnabled (false);
781 actionListBranches.append(a);
782 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
785 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
786 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
787 a->setEnabled (false);
788 actionListBranches.append(a);
789 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
790 actionBugzilla2URL=a;
792 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
793 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
794 a->setEnabled (false);
795 actionListBranches.append(a);
796 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
799 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
800 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
802 a->setEnabled (false);
803 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
806 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
807 a->setStatusTip ( tr( "Open all vym links in subtree" ));
808 a->setEnabled (false);
809 actionListBranches.append(a);
810 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
811 actionOpenMultipleVymLinks=a;
814 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
815 a->setEnabled (false);
816 a->setStatusTip ( tr( "Edit link to another vym map" ));
817 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
818 actionListBranches.append(a);
821 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
822 a->setStatusTip ( tr( "Delete link to another vym map" ));
823 a->setEnabled (false);
824 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
825 actionDeleteVymLink=a;
827 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
828 a->setStatusTip ( tr( "Hide object in exports" ) );
829 a->setShortcut (Qt::Key_H );
830 a->setToggleAction(true);
832 a->setEnabled (false);
833 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
834 actionToggleHideExport=a;
836 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
837 a->setStatusTip ( tr( "Edit Map Info" ));
838 a->setEnabled (true);
839 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
842 // Import at selection (adding to selection)
843 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
844 a->setStatusTip (tr( "Add map at selection" ));
845 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
846 a->setEnabled (false);
847 actionListBranches.append(a);
850 // Import at selection (replacing selection)
851 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
852 a->setStatusTip (tr( "Replace selection with map" ));
853 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
854 a->setEnabled (false);
855 actionListBranches.append(a);
856 actionImportReplace=a;
859 a = new QAction( tr( "Save selection","Edit menu" ), this);
860 a->setStatusTip (tr( "Save selection" ));
861 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
862 a->setEnabled (false);
863 actionListBranches.append(a);
866 // Only remove branch, not its children
867 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
868 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
869 a->setShortcut (Qt::ALT + Qt::Key_Delete );
870 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
871 a->setEnabled (false);
873 actionListBranches.append(a);
874 actionDeleteKeepChildren=a;
876 // Only remove children of a branch
877 a = new QAction( tr( "Remove children","Edit menu" ), this);
878 a->setStatusTip (tr( "Remove children of branch" ));
879 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
880 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
881 a->setEnabled (false);
882 actionListBranches.append(a);
883 actionDeleteChildren=a;
885 // Shortcuts for navigating with cursor:
886 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
887 a->setStatusTip ( tr( "Select upper branch" ));
888 a->setShortcut (Qt::Key_Up );
889 a->setShortcutContext (Qt::WindowShortcut);
891 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
892 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
893 a->setStatusTip (tr( "Select lower branch" ));
894 a->setShortcut ( Qt::Key_Down );
895 a->setShortcutContext (Qt::WindowShortcut);
897 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
898 a = new QAction(tr( "Select left branch","Edit menu" ), this);
899 a->setStatusTip ( tr( "Select left branch" ));
900 a->setShortcut (Qt::Key_Left );
901 a->setShortcutContext (Qt::WindowShortcut);
903 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
904 a = new QAction( tr( "Select child branch","Edit menu" ), this);
905 a->setStatusTip (tr( "Select right branch" ));
906 a->setShortcut (Qt::Key_Right);
907 a->setShortcutContext (Qt::WindowShortcut);
909 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
910 a = new QAction( tr( "Select first branch","Edit menu" ), this);
911 a->setStatusTip (tr( "Select first branch" ));
912 a->setShortcut (Qt::Key_Home );
913 a->setShortcutContext (Qt::WindowShortcut);
915 a->setEnabled (false);
916 editMenu->addAction (a);
917 actionListBranches.append(a);
919 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
920 a = new QAction( tr( "Select last branch","Edit menu" ),this);
921 a->setStatusTip (tr( "Select last branch" ));
922 a->setShortcut ( Qt::Key_End );
923 a->setShortcutContext (Qt::WindowShortcut);
925 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
926 a->setEnabled (false);
927 editMenu->addAction (a);
928 actionListBranches.append(a);
931 a = new QAction( tr( "Add Image...","Edit menu" ), this);
932 a->setStatusTip (tr( "Add Image" ));
933 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
936 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
937 a->setStatusTip (tr( "Set properties for selection" ));
938 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
939 a->setShortcutContext (Qt::WindowShortcut);
940 a->setToggleAction (true);
942 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
943 actionViewTogglePropertyWindow=a;
947 void Main::setupFormatActions()
949 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
951 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
952 tb->setObjectName ("formatTB");
955 pix.fill (Qt::black);
956 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
957 a->setStatusTip ( tr( "Set Color" ));
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
960 formatMenu->addAction (a);
962 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
963 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
964 a->setShortcut (Qt::CTRL + Qt::Key_K );
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
966 a->setEnabled (false);
968 formatMenu->addAction (a);
969 actionListBranches.append(a);
970 actionFormatPickColor=a;
972 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
973 a->setStatusTip ( tr( "Color branch" ) );
974 a->setShortcut (Qt::CTRL + Qt::Key_B);
975 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
976 a->setEnabled (false);
978 formatMenu->addAction (a);
979 actionListBranches.append(a);
980 actionFormatColorSubtree=a;
982 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
983 a->setStatusTip ( tr( "Color Subtree" ));
984 a->setShortcut (Qt::CTRL + Qt::Key_T);
985 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
986 a->setEnabled (false);
987 formatMenu->addAction (a);
989 actionListBranches.append(a);
990 actionFormatColorSubtree=a;
992 formatMenu->addSeparator();
993 actionGroupFormatLinkStyles=new QActionGroup ( this);
994 actionGroupFormatLinkStyles->setExclusive (true);
995 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
996 a->setStatusTip (tr( "Line" ));
997 a->setToggleAction(true);
998 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
999 formatMenu->addAction (a);
1000 actionFormatLinkStyleLine=a;
1001 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1002 a->setStatusTip (tr( "Line" ));
1003 a->setToggleAction(true);
1004 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1005 formatMenu->addAction (a);
1006 actionFormatLinkStyleParabel=a;
1007 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1008 a->setStatusTip (tr( "PolyLine" ));
1009 a->setToggleAction(true);
1010 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1011 formatMenu->addAction (a);
1012 actionFormatLinkStylePolyLine=a;
1013 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1014 a->setStatusTip (tr( "PolyParabel" ) );
1015 a->setToggleAction(true);
1016 a->setChecked (true);
1017 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1018 formatMenu->addAction (a);
1019 actionFormatLinkStylePolyParabel=a;
1021 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1022 a->setStatusTip (tr( "Hide link" ));
1023 a->setToggleAction(true);
1024 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1025 actionFormatHideLinkUnselected=a;
1027 formatMenu->addSeparator();
1028 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1029 a->setStatusTip (tr( "Use same color for links and headings" ));
1030 a->setToggleAction(true);
1031 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1032 formatMenu->addAction (a);
1033 actionFormatLinkColorHint=a;
1035 pix.fill (Qt::white);
1036 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1037 a->setStatusTip (tr( "Set Link Color" ));
1038 formatMenu->addAction (a);
1039 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1040 actionFormatLinkColor=a;
1042 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1043 a->setStatusTip (tr( "Set Selection Color" ));
1044 formatMenu->addAction (a);
1045 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1046 actionFormatSelectionColor=a;
1048 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1049 a->setStatusTip (tr( "Set Background Color" ));
1050 formatMenu->addAction (a);
1051 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1052 actionFormatBackColor=a;
1054 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1055 a->setStatusTip (tr( "Set Background image" ));
1056 formatMenu->addAction (a);
1057 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1058 actionFormatBackImage=a;
1062 void Main::setupViewActions()
1064 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1065 tb->setLabel( "View Actions" );
1066 tb->setObjectName ("viewTB");
1067 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1070 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1071 a->setStatusTip ( tr( "Zoom reset" ) );
1072 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1074 viewMenu->addAction (a);
1075 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1077 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1078 a->setStatusTip (tr( "Zoom in" ));
1079 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1081 viewMenu->addAction (a);
1082 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1084 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1085 a->setStatusTip (tr( "Zoom out" ));
1086 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1088 viewMenu->addAction (a);
1089 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1091 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1092 a->setStatusTip (tr( "Show selection" ));
1093 a->setShortcut (Qt::Key_Period);
1095 viewMenu->addAction (a);
1096 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1098 viewMenu->addSeparator();
1100 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1101 a->setStatusTip ( tr( "Show Note Editor" ));
1102 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1103 a->setToggleAction(true);
1105 viewMenu->addAction (a);
1106 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1107 actionViewToggleNoteEditor=a;
1109 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1110 a->setStatusTip ( tr( "Show History Window" ));
1111 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1112 a->setToggleAction(true);
1114 viewMenu->addAction (a);
1115 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1116 actionViewToggleHistoryWindow=a;
1118 viewMenu->addAction (actionViewTogglePropertyWindow);
1120 viewMenu->addSeparator();
1122 a = new QAction(tr( "Antialiasing","View action" ),this );
1123 a->setStatusTip ( tr( "Antialiasing" ));
1124 a->setToggleAction(true);
1125 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1126 viewMenu->addAction (a);
1127 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1128 actionViewToggleAntiAlias=a;
1130 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1131 a->setStatusTip (a->text());
1132 a->setToggleAction(true);
1133 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1134 viewMenu->addAction (a);
1135 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1136 actionViewToggleSmoothPixmapTransform=a;
1138 a = new QAction(tr( "Next Map","View action" ), this);
1139 a->setStatusTip (a->text());
1140 a->setShortcut (Qt::ALT + Qt::Key_N );
1141 viewMenu->addAction (a);
1142 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1144 a = new QAction (tr( "Previous Map","View action" ), this );
1145 a->setStatusTip (a->text());
1146 a->setShortcut (Qt::ALT + Qt::Key_P );
1147 viewMenu->addAction (a);
1148 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1152 void Main::setupModeActions()
1154 //QPopupMenu *menu = new QPopupMenu( this );
1155 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1157 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1158 tb->setObjectName ("modesTB");
1160 actionGroupModModes=new QActionGroup ( this);
1161 actionGroupModModes->setExclusive (true);
1162 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1163 a->setShortcut (Qt::Key_J);
1164 a->setStatusTip ( tr( "Use modifier to color branches" ));
1165 a->setToggleAction(true);
1168 actionModModeColor=a;
1170 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1171 a->setShortcut( Qt::Key_K);
1172 a->setStatusTip( tr( "Use modifier to copy" ));
1173 a->setToggleAction(true);
1175 actionModModeCopy=a;
1177 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1178 a->setShortcut (Qt::Key_L);
1179 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1180 a->setToggleAction(true);
1182 actionModModeXLink=a;
1186 void Main::setupFlagActions()
1188 // Create System Flags
1191 Flag *flag=new Flag;;
1193 flag->load(QPixmap(flagsPath+"flag-note.png"));
1194 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1196 flag->load(QPixmap(flagsPath+"flag-url.png"));
1197 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1199 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1200 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1202 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1203 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1205 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1206 setupFlag (flag,tb,"system-tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1208 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1209 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1211 // Create Standard Flags
1212 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1213 tb->setObjectName ("standardFlagTB");
1216 flag->load(flagsPath+"flag-exclamationmark.png");
1217 flag->setGroup("standard-mark");
1218 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1220 flag->load(flagsPath+"flag-questionmark.png");
1221 flag->setGroup("standard-mark");
1222 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1224 flag->load(flagsPath+"flag-hook-green.png");
1225 flag->setGroup("standard-hook");
1226 setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
1228 flag->load(flagsPath+"flag-cross-red.png");
1229 flag->setGroup("standard-hook");
1230 setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
1233 flag->load(flagsPath+"flag-stopsign.png");
1234 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1236 flag->load(flagsPath+"flag-smiley-good.png");
1237 flag->setGroup("standard-smiley");
1238 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1240 flag->load(flagsPath+"flag-smiley-sad.png");
1241 flag->setGroup("standard-smiley");
1242 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1244 flag->load(flagsPath+"flag-smiley-omg.png");
1245 flag->setGroup("standard-smiley");
1246 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1247 // Original omg.png (in KDE emoticons)
1250 flag->load(flagsPath+"flag-kalarm.png");
1251 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1253 flag->load(flagsPath+"flag-phone.png");
1254 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1256 flag->load(flagsPath+"flag-lamp.png");
1257 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1259 flag->load(flagsPath+"flag-arrow-up.png");
1260 flag->setGroup("standard-arrow");
1261 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1263 flag->load(flagsPath+"flag-arrow-down.png");
1264 flag->setGroup("standard-arrow");
1265 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1267 flag->load(flagsPath+"flag-arrow-2up.png");
1268 flag->setGroup("standard-arrow");
1269 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1271 flag->load(flagsPath+"flag-arrow-2down.png");
1272 flag->setGroup("standard-arrow");
1273 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1276 flag->load(flagsPath+"flag-thumb-up.png");
1277 flag->setGroup("standard-thumb");
1278 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1280 flag->load(flagsPath+"flag-thumb-down.png");
1281 flag->setGroup("standard-thumb");
1282 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1285 flag->load(flagsPath+"flag-rose.png");
1286 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1288 flag->load(flagsPath+"flag-heart.png");
1289 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1291 flag->load(flagsPath+"flag-present.png");
1292 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1294 flag->load(flagsPath+"flag-flash.png");
1295 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1297 // Original: xsldbg_output.png
1298 flag->load(flagsPath+"flag-info.png");
1299 setupFlag (flag,tb,"inflag",tr("Info","Standardflag"));
1301 // Original khelpcenter.png
1302 flag->load(flagsPath+"flag-lifebelt.png");
1303 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1307 flag->load(flagsPath+"freemind/warning.png");
1308 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1310 for (int i=1; i<8; i++)
1312 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1313 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1316 flag->load(flagsPath+"freemind/back.png");
1317 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1319 flag->load(flagsPath+"freemind/forward.png");
1320 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1322 flag->load(flagsPath+"freemind/attach.png");
1323 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1325 flag->load(flagsPath+"freemind/clanbomber.png");
1326 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1328 flag->load(flagsPath+"freemind/desktopnew.png");
1329 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1331 flag->load(flagsPath+"freemind/flag.png");
1332 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1335 flag->load(flagsPath+"freemind/gohome.png");
1336 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1339 flag->load(flagsPath+"freemind/kaddressbook.png");
1340 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1342 flag->load(flagsPath+"freemind/knotify.png");
1343 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1345 flag->load(flagsPath+"freemind/korn.png");
1346 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1348 flag->load(flagsPath+"freemind/mail.png");
1349 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1351 flag->load(flagsPath+"freemind/password.png");
1352 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1354 flag->load(flagsPath+"freemind/pencil.png");
1355 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1357 flag->load(flagsPath+"freemind/stop.png");
1358 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1360 flag->load(flagsPath+"freemind/wizard.png");
1361 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1363 flag->load(flagsPath+"freemind/xmag.png");
1364 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1366 flag->load(flagsPath+"freemind/bell.png");
1367 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1369 flag->load(flagsPath+"freemind/bookmark.png");
1370 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1372 flag->load(flagsPath+"freemind/penguin.png");
1373 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1375 flag->load(flagsPath+"freemind/licq.png");
1376 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1379 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1381 flag->setName(name);
1382 flag->setToolTip (tooltip);
1386 a=new QAction (flag->getPixmap(),name,this);
1389 a->setCheckable(true);
1390 a->setObjectName(name);
1391 a->setToolTip(tooltip);
1392 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1393 standardFlagsMaster->addFlag (flag);
1397 systemFlagsMaster->addFlag (flag);
1402 void Main::setupNetworkActions()
1404 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1406 QMenu *netMenu = menuBar()->addMenu( "Network" );
1410 a = new QAction( "Start TCPserver for MapEditor",this);
1411 //a->setStatusTip ( "Set application to open pdf files"));
1412 a->setShortcut ( Qt::Key_T ); //New TCP server
1413 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1414 netMenu->addAction (a);
1416 a = new QAction( "Connect MapEditor to server",this);
1417 //a->setStatusTip ( "Set application to open pdf files"));
1418 a->setShortcut ( Qt::Key_C ); // Connect to server
1419 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1420 netMenu->addAction (a);
1424 void Main::setupSettingsActions()
1426 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1430 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1431 a->setStatusTip ( tr( "Set application to open pdf files"));
1432 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1433 settingsMenu->addAction (a);
1435 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1436 a->setStatusTip( tr( "Set application to open external links"));
1437 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1438 settingsMenu->addAction (a);
1440 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1441 a->setStatusTip( tr( "Set path for macros"));
1442 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1443 settingsMenu->addAction (a);
1445 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1446 a->setStatusTip( tr( "Set number of undo levels"));
1447 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1448 settingsMenu->addAction (a);
1450 settingsMenu->addSeparator();
1452 a = new QAction( tr( "Autosave","Settings action"), this);
1453 a->setStatusTip( tr( "Autosave"));
1454 a->setToggleAction(true);
1455 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1456 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1457 settingsMenu->addAction (a);
1458 actionSettingsAutosaveToggle=a;
1460 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1461 a->setStatusTip( tr( "Autosave time"));
1462 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1463 settingsMenu->addAction (a);
1464 actionSettingsAutosaveTime=a;
1466 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1467 a->setStatusTip( tr( "Write backup file on save"));
1468 a->setToggleAction(true);
1469 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1470 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1471 settingsMenu->addAction (a);
1472 actionSettingsWriteBackupFile=a;
1474 settingsMenu->addSeparator();
1476 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1477 a->setStatusTip( tr( "Edit branch after adding it" ));
1478 a->setToggleAction(true);
1479 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1480 settingsMenu->addAction (a);
1481 actionSettingsAutoEditNewBranch=a;
1483 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1484 a->setStatusTip( tr( "Select branch after adding it" ));
1485 a->setToggleAction(true);
1486 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1487 settingsMenu->addAction (a);
1488 actionSettingsAutoSelectNewBranch=a;
1490 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1491 a->setStatusTip( tr( "Select heading before editing" ));
1492 a->setToggleAction(true);
1493 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1494 settingsMenu->addAction (a);
1495 actionSettingsAutoSelectText=a;
1497 a= new QAction( tr( "Delete key","Settings action" ), this);
1498 a->setStatusTip( tr( "Delete key for deleting branches" ));
1499 a->setToggleAction(true);
1500 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1501 settingsMenu->addAction (a);
1502 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1503 actionSettingsUseDelKey=a;
1505 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1506 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1507 a->setToggleAction(true);
1508 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1509 settingsMenu->addAction (a);
1510 actionSettingsUseFlagGroups=a;
1512 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1513 a->setStatusTip( tr( "Use hide flag during exports " ));
1514 a->setToggleAction(true);
1515 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1516 settingsMenu->addAction (a);
1517 actionSettingsUseHideExport=a;
1519 a = new QAction( tr( "Animation","Settings action"), this);
1520 a->setStatusTip( tr( "Animation"));
1521 a->setToggleAction(true);
1522 a->setOn (settings.value("/animation/use",false).toBool() );
1523 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1524 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1526 settingsMenu->addAction (a);
1528 actionSettingsUseAnimation=a;
1532 void Main::setupTestActions()
1534 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1537 a = new QAction( "Test function 1" , this);
1538 a->setStatusTip( "Call test function 1" );
1539 testMenu->addAction (a);
1540 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1542 a = new QAction( "Test function 2" , this);
1543 a->setStatusTip( "Call test function 2" );
1544 testMenu->addAction (a);
1545 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1547 a = new QAction( "Command" , this);
1548 a->setStatusTip( "Enter command to call in editor" );
1549 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1550 testMenu->addAction (a);
1554 void Main::setupHelpActions()
1556 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1559 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1560 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1561 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1562 helpMenu->addAction (a);
1564 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1565 a->setStatusTip( tr( "Open VYM example maps " ));
1566 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1567 helpMenu->addAction (a);
1569 a = new QAction( tr( "About VYM","Help action" ), this);
1570 a->setStatusTip( tr( "About VYM")+vymName);
1571 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1572 helpMenu->addAction (a);
1574 a = new QAction( tr( "About QT","Help action" ), this);
1575 a->setStatusTip( tr( "Information about QT toolkit" ));
1576 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1577 helpMenu->addAction (a);
1581 void Main::setupContextMenus()
1585 // Context Menu for branch or mapcenter
1586 branchContextMenu =new QMenu (this);
1587 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1588 branchContextMenu->addSeparator();
1591 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1592 branchAddContextMenu->addAction (actionPaste );
1593 branchAddContextMenu->addAction ( actionAddMapCenter );
1594 branchAddContextMenu->addAction ( actionAddBranch );
1595 branchAddContextMenu->addAction ( actionAddBranchBefore );
1596 branchAddContextMenu->addAction ( actionAddBranchAbove);
1597 branchAddContextMenu->addAction ( actionAddBranchBelow );
1598 branchAddContextMenu->addSeparator();
1599 branchAddContextMenu->addAction ( actionImportAdd );
1600 branchAddContextMenu->addAction ( actionImportReplace );
1603 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1604 branchRemoveContextMenu->addAction (actionCut);
1605 branchRemoveContextMenu->addAction ( actionDelete );
1606 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1607 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1610 actionSaveBranch->addTo( branchContextMenu );
1611 actionFileNewCopy->addTo (branchContextMenu );
1613 branchContextMenu->addSeparator();
1614 branchContextMenu->addAction ( actionLoadImage);
1616 // Submenu for Links (URLs, vymLinks)
1617 branchLinksContextMenu =new QMenu (this);
1619 branchContextMenu->addSeparator();
1620 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1621 branchLinksContextMenu->addAction ( actionOpenURL );
1622 branchLinksContextMenu->addAction ( actionOpenURLTab );
1623 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1624 branchLinksContextMenu->addAction ( actionURL );
1625 branchLinksContextMenu->addAction ( actionLocalURL );
1626 branchLinksContextMenu->addAction ( actionHeading2URL );
1627 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1628 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1630 branchLinksContextMenu->addAction ( actionFATE2URL );
1632 branchLinksContextMenu->addSeparator();
1633 branchLinksContextMenu->addAction ( actionOpenVymLink );
1634 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1635 branchLinksContextMenu->addAction ( actionVymLink );
1636 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1639 // Context Menu for XLinks in a branch menu
1640 // This will be populated "on demand" in MapEditor::updateActions
1641 branchContextMenu->addSeparator();
1642 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1643 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1644 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1645 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1648 // Context menu for floatimage
1649 floatimageContextMenu =new QMenu (this);
1650 a= new QAction (tr ("Save image","Context action"),this);
1651 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1652 floatimageContextMenu->addAction (a);
1654 floatimageContextMenu->addSeparator();
1655 actionCopy->addTo( floatimageContextMenu );
1656 actionCut->addTo( floatimageContextMenu );
1658 floatimageContextMenu->addSeparator();
1659 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1662 // Context menu for canvas
1663 canvasContextMenu =new QMenu (this);
1664 actionAddMapCenter->addTo( canvasContextMenu );
1665 actionMapInfo->addTo( canvasContextMenu );
1666 canvasContextMenu->insertSeparator();
1667 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1668 canvasContextMenu->insertSeparator();
1669 actionFormatLinkColorHint->addTo( canvasContextMenu );
1670 actionFormatLinkColor->addTo( canvasContextMenu );
1671 actionFormatSelectionColor->addTo( canvasContextMenu );
1672 actionFormatBackColor->addTo( canvasContextMenu );
1673 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1675 // Menu for last opened files
1677 for (int i = 0; i < MaxRecentFiles; ++i)
1679 recentFileActions[i] = new QAction(this);
1680 recentFileActions[i]->setVisible(false);
1681 fileLastMapsMenu->addAction(recentFileActions[i]);
1682 connect(recentFileActions[i], SIGNAL(triggered()),
1683 this, SLOT(fileLoadRecent()));
1685 setupRecentMapsMenu();
1688 void Main::setupRecentMapsMenu()
1690 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1692 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1694 for (int i = 0; i < numRecentFiles; ++i) {
1695 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1696 recentFileActions[i]->setText(text);
1697 recentFileActions[i]->setData(files[i]);
1698 recentFileActions[i]->setVisible(true);
1700 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1701 recentFileActions[j]->setVisible(false);
1704 void Main::setupMacros()
1706 for (int i = 0; i <= 11; i++)
1708 macroActions[i] = new QAction(this);
1709 macroActions[i]->setData(i);
1710 addAction (macroActions[i]);
1711 connect(macroActions[i], SIGNAL(triggered()),
1712 this, SLOT(callMacro()));
1714 macroActions[0]->setShortcut ( Qt::Key_F1 );
1715 macroActions[1]->setShortcut ( Qt::Key_F2 );
1716 macroActions[2]->setShortcut ( Qt::Key_F3 );
1717 macroActions[3]->setShortcut ( Qt::Key_F4 );
1718 macroActions[4]->setShortcut ( Qt::Key_F5 );
1719 macroActions[5]->setShortcut ( Qt::Key_F6 );
1720 macroActions[6]->setShortcut ( Qt::Key_F7 );
1721 macroActions[7]->setShortcut ( Qt::Key_F8 );
1722 macroActions[8]->setShortcut ( Qt::Key_F9 );
1723 macroActions[9]->setShortcut ( Qt::Key_F10 );
1724 macroActions[10]->setShortcut ( Qt::Key_F11 );
1725 macroActions[11]->setShortcut ( Qt::Key_F12 );
1728 void Main::hideEvent (QHideEvent * )
1730 if (!textEditor->isMinimized() ) textEditor->hide();
1733 void Main::showEvent (QShowEvent * )
1735 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1739 MapEditor* Main::currentMapEditor() const
1741 if ( tabWidget->currentPage())
1742 return tabModel.at(tabWidget->currentIndex())->getMapEditor();
1746 VymModel* Main::currentModel() const
1748 if ( tabWidget->currentPage())
1749 return tabModel.at(tabWidget->currentIndex());
1754 void Main::editorChanged(QWidget *)
1756 // Unselect all possibly selected objects
1757 // (Important to update note editor)
1758 for (int i=0;i<=tabWidget->count() -1;i++)
1760 tabModel.at(i)->unselect();
1762 VymModel *m=currentModel();
1763 if (m) m->reselect();
1765 // Update actions to in menus and toolbars according to editor
1769 VymView *Main::createView (VymModel *model)
1771 VymView *vm=new VymView (model);
1775 void Main::fileNew()
1777 VymModel *m=new VymModel;
1778 tabModel.append (m);
1779 //MapEditor* me = new MapEditor (m);
1780 //me->setObjectName ("MapEditor");
1782 tabWidget->addTab (createView (m),tr("unnamed","MainWindow: name for new and empty file"));
1783 tabWidget->setCurrentIndex (tabModel.count() );
1785 // For the very first map we do not have flagrows yet...
1789 void Main::fileNewCopy()
1791 QString fn="unnamed";
1792 VymModel *srcModel=currentModel();
1797 VymModel *dstModel=tabModel.last ();
1798 dstModel->select("mc:");
1799 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1803 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1805 ErrorCode err=success;
1807 // fn is usually the archive, mapfile the file after uncompressing
1810 // Make fn absolute (needed for unzip)
1811 fn=QDir (fn).absPath();
1817 // Check, if map is already loaded
1819 while (i<=tabWidget->count() -1)
1821 if (tabModel.at(i)->getFilePath() == fn)
1823 // Already there, ask for confirmation
1824 QMessageBox mb( vymName,
1825 tr("The map %1\nis already opened."
1826 "Opening the same map in multiple editors may lead \n"
1827 "to confusion when finishing working with vym."
1828 "Do you want to").arg(fn),
1829 QMessageBox::Warning,
1830 QMessageBox::Yes | QMessageBox::Default,
1831 QMessageBox::Cancel | QMessageBox::Escape,
1832 QMessageBox::NoButton);
1833 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1834 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1837 case QMessageBox::Yes:
1838 // end loop and load anyway
1839 i=tabWidget->count();
1841 case QMessageBox::Cancel:
1851 int tabIndex=tabWidget->currentPageIndex();
1854 if ( !fn.isEmpty() )
1856 vm = currentModel();
1857 // Check first, if mapeditor exists
1858 // If it is not default AND we want a new map,
1859 // create a new mapeditor in a new tab
1860 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1863 tabModel.append (vm);
1864 tabWidget->addTab (createView (vm),fn);
1865 tabIndex=tabWidget->count()-1;
1866 tabWidget->setCurrentPage (tabIndex);
1869 // Check, if file exists (important for creating new files
1870 // from command line
1871 if (!QFile(fn).exists() )
1873 QMessageBox mb( vymName,
1874 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1875 QMessageBox::Question,
1877 QMessageBox::Cancel | QMessageBox::Default,
1878 QMessageBox::NoButton );
1880 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1881 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1884 case QMessageBox::Yes:
1886 currentMapEditor()->getModel()->setFilePath(fn);
1887 tabWidget->setTabText (tabIndex,
1888 currentMapEditor()->getModel()->getFileName() );
1889 statusBar()->message( "Created " + fn , statusbarTime );
1892 case QMessageBox::Cancel:
1893 // don't create new map
1894 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1901 //tabWidget->currentPage() won't be NULL here, because of above...
1902 tabWidget->setCurrentIndex (tabIndex);
1903 //FIXME-3 no me anymore... me->viewport()->setFocus();
1907 // Save existing filename in case we import
1908 QString fn_org=vm->getFilePath();
1910 // Finally load map into mapEditor
1911 vm->setFilePath (fn);
1912 err=vm->load(fn,lmode,ftype);
1914 // Restore old (maybe empty) filepath, if this is an import
1916 vm->setFilePath (fn_org);
1919 // Finally check for errors and go home
1922 if (lmode==NewMap) fileCloseMap();
1923 statusBar()->message( "Could not load " + fn, statusbarTime );
1928 vm->setFilePath (fn);
1929 tabWidget->setTabText (tabIndex, vm->getFileName());
1930 if (!isInTmpDir (fn))
1932 // Only append to lastMaps if not loaded from a tmpDir
1933 // e.g. imported bookmarks are in a tmpDir
1934 addRecentMap(vm->getFilePath() );
1936 actionFilePrint->setEnabled (true);
1938 statusBar()->message( "Loaded " + fn, statusbarTime );
1945 void Main::fileLoad(const LoadMode &lmode)
1947 QStringList filters;
1948 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1949 QFileDialog *fd=new QFileDialog( this);
1950 fd->setDir (lastFileDir);
1951 fd->setFileMode (QFileDialog::ExistingFiles);
1952 fd->setFilters (filters);
1956 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1959 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1962 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1968 if ( fd->exec() == QDialog::Accepted )
1970 lastFileDir=fd->directory().path();
1971 QStringList flist = fd->selectedFiles();
1972 QStringList::Iterator it = flist.begin();
1973 while( it != flist.end() )
1976 fileLoad(*it, lmode);
1983 void Main::fileLoad()
1988 void Main::fileLoadRecent()
1990 QAction *action = qobject_cast<QAction *>(sender());
1992 fileLoad (action->data().toString(), NewMap);
1995 void Main::addRecentMap (const QString &fileName)
1998 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1999 files.removeAll(fileName);
2000 files.prepend(fileName);
2001 while (files.size() > MaxRecentFiles)
2004 settings.setValue("/mainwindow/recentFileList", files);
2006 setupRecentMapsMenu();
2009 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2013 if ( m->getFilePath().isEmpty() )
2015 // We have no filepath yet,
2016 // call fileSaveAs() now, this will call fileSave()
2018 // First switch to editor
2019 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2020 fileSaveAs(savemode);
2023 if (m->save (savemode)==success)
2025 statusBar()->message(
2026 tr("Saved %1").arg(m->getFilePath()),
2028 addRecentMap (m->getFilePath() );
2030 statusBar()->message(
2031 tr("Couldn't save ").arg(m->getFilePath()),
2035 void Main::fileSave()
2037 fileSave (currentModel(), CompleteMap);
2040 void Main::fileSave(VymModel *m)
2042 fileSave (m,CompleteMap);
2045 void Main::fileSaveAs(const SaveMode& savemode)
2049 if (currentMapEditor())
2051 if (savemode==CompleteMap)
2052 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2054 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2055 if ( !fn.isEmpty() )
2057 // Check for existing file
2058 if (QFile (fn).exists())
2060 QMessageBox mb( vymName,
2061 tr("The file %1\nexists already. Do you want to").arg(fn),
2062 QMessageBox::Warning,
2063 QMessageBox::Yes | QMessageBox::Default,
2064 QMessageBox::Cancel | QMessageBox::Escape,
2065 QMessageBox::NoButton);
2066 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2067 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2070 case QMessageBox::Yes:
2073 case QMessageBox::Cancel:
2080 // New file, add extension to filename, if missing
2081 // This is always .vym or .vyp, depending on savemode
2082 if (savemode==CompleteMap)
2084 if (!fn.contains (".vym") && !fn.contains (".xml"))
2088 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2097 VymModel *m=currentModel();
2099 fileSave(m, savemode);
2101 // Set name of tab, assuming current tab is the one we just saved
2102 if (savemode==CompleteMap)
2103 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2109 void Main::fileSaveAs()
2111 fileSaveAs (CompleteMap);
2114 void Main::fileImportKDE3Bookmarks()
2116 ImportKDE3Bookmarks im;
2118 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2119 currentMapEditor()->getModel()->setFilePath ("");
2122 void Main::fileImportKDE4Bookmarks()
2124 ImportKDE4Bookmarks im;
2126 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2127 currentMapEditor()->getModel()->setFilePath ("");
2130 void Main::fileImportFirefoxBookmarks()
2132 Q3FileDialog *fd=new Q3FileDialog( this);
2133 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2134 fd->setMode (Q3FileDialog::ExistingFiles);
2135 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2136 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2139 if ( fd->exec() == QDialog::Accepted )
2141 ImportFirefoxBookmarks im;
2142 QStringList flist = fd->selectedFiles();
2143 QStringList::Iterator it = flist.begin();
2144 while( it != flist.end() )
2147 if (im.transform() &&
2148 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2149 currentMapEditor() )
2150 currentMapEditor()->getModel()->setFilePath ("");
2157 void Main::fileImportFreemind()
2159 QStringList filters;
2160 filters <<"Freemind map (*.mm)"<<"All files (*)";
2161 QFileDialog *fd=new QFileDialog( this);
2162 fd->setDir (lastFileDir);
2163 fd->setFileMode (QFileDialog::ExistingFiles);
2164 fd->setFilters (filters);
2165 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2169 if ( fd->exec() == QDialog::Accepted )
2171 lastFileDir=fd->directory().path();
2172 QStringList flist = fd->selectedFiles();
2173 QStringList::Iterator it = flist.begin();
2174 while( it != flist.end() )
2177 if ( fileLoad (fn,NewMap, FreemindMap) )
2179 currentMapEditor()->getModel()->setFilePath ("");
2188 void Main::fileImportMM()
2192 Q3FileDialog *fd=new Q3FileDialog( this);
2193 fd->setDir (lastFileDir);
2194 fd->setMode (Q3FileDialog::ExistingFiles);
2195 fd->addFilter ("Mind Manager (*.mmap)");
2196 fd->setCaption(tr("Import")+" "+"Mind Manager");
2199 if ( fd->exec() == QDialog::Accepted )
2201 lastFileDir=fd->dirPath();
2202 QStringList flist = fd->selectedFiles();
2203 QStringList::Iterator it = flist.begin();
2204 while( it != flist.end() )
2207 if (im.transform() &&
2208 success==fileLoad (im.getTransformedFile(),NewMap) &&
2209 currentMapEditor() )
2210 currentMapEditor()->getModel()->setFilePath ("");
2217 void Main::fileImportDir()
2219 VymModel *m=currentModel();
2220 if (m) m->importDir();
2223 void Main::fileExportXML()
2225 VymModel *m=currentModel();
2226 if (m) m->exportXML();
2230 void Main::fileExportXHTML()
2232 VymModel *m=currentModel();
2233 if (m) m->exportXHTML();
2236 void Main::fileExportImage()
2238 VymModel *m=currentModel();
2239 if (m) m->exportImage();
2242 void Main::fileExportASCII()
2244 VymModel *m=currentModel();
2245 if (m) m->exportASCII();
2248 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2250 VymModel *m=currentModel();
2255 ex.addFilter ("CSV (*.csv)");
2256 ex.setDir(lastImageDir);
2257 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2258 if (ex.execDialog() )
2260 m->setExportMode(true);
2262 m->setExportMode(false);
2267 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2269 VymModel *m=currentModel();
2274 ex.addFilter ("Tex (*.tex)");
2275 ex.setDir(lastImageDir);
2276 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2277 if (ex.execDialog() )
2279 m->setExportMode(true);
2281 m->setExportMode(false);
2286 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2288 ExportKDE3Bookmarks ex;
2289 VymModel *m=currentModel();
2297 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2299 ExportKDE4Bookmarks ex;
2300 VymModel *m=currentModel();
2308 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2310 ExportTaskjuggler ex;
2311 VymModel *m=currentModel();
2315 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2316 ex.setDir(lastImageDir);
2317 ex.addFilter ("Taskjuggler (*.tjp)");
2318 if (ex.execDialog() )
2320 m->setExportMode(true);
2322 m->setExportMode(false);
2327 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2329 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2330 // TODO add preview in dialog
2331 //ImagePreview *p =new ImagePreview (fd);
2332 //fd->setContentsPreviewEnabled( TRUE );
2333 //fd->setContentsPreview( p, p );
2334 //fd->setPreviewMode( QFileDialog::Contents );
2335 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2336 fd->setDir (QDir().current());
2337 if (fd->foundConfig())
2341 if ( fd->exec() == QDialog::Accepted )
2343 QString fn=fd->selectedFile();
2344 if (!fn.contains (".odp"))
2347 //lastImageDir=fn.left(fn.findRev ("/"));
2348 VymModel *m=currentModel();
2349 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2353 QMessageBox::warning(0,
2355 tr("Couldn't find configuration for export to Open Office\n"));
2359 void Main::fileCloseMap()
2361 MapEditor *me = currentMapEditor();
2362 VymModel *m=currentModel();
2365 if (m->hasChanged())
2367 QMessageBox mb( vymName,
2368 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
2369 QMessageBox::Warning,
2370 QMessageBox::Yes | QMessageBox::Default,
2372 QMessageBox::Cancel | QMessageBox::Escape );
2373 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2374 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2377 case QMessageBox::Yes:
2379 fileSave(m, CompleteMap);
2381 case QMessageBox::No:
2382 // close without saving
2384 case QMessageBox::Cancel:
2389 tabModel.removeAt (tabWidget->currentIndex() );
2390 tabWidget->removeTab (tabWidget->currentIndex() );
2392 // Remove mapEditor;
2393 // Better would be delete (me), but then we could have a Qt error:
2394 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2395 // So we only remove data now and call deconstructor when vym closes later
2396 // FIXME-3 this needs to be moved to vymview... me->clear();
2397 // some model->clear is needed to free up memory ...
2403 void Main::filePrint()
2405 if (currentMapEditor())
2406 currentMapEditor()->print();
2409 void Main::fileExitVYM()
2411 // Check if one or more editors have changed
2413 for (i=0;i<=tabModel.count() -1;i++)
2415 // If something changed, ask what to do
2416 if (tabModel.at(i)->hasChanged())
2418 tabWidget->setCurrentPage(i);
2419 QMessageBox mb( vymName,
2420 tr("This map is not saved yet. Do you want to"),
2421 QMessageBox::Warning,
2422 QMessageBox::Yes | QMessageBox::Default,
2424 QMessageBox::Cancel | QMessageBox::Escape );
2425 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2426 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2429 mb.setActiveWindow();
2430 switch( mb.exec() ) {
2431 case QMessageBox::Yes:
2432 // save (the changed editors) and exit
2433 fileSave(currentModel(), CompleteMap);
2435 case QMessageBox::No:
2436 // exit without saving
2438 case QMessageBox::Cancel:
2439 // don't save and don't exit
2443 } // loop over all MEs
2447 void Main::editUndo()
2449 VymModel *m=currentModel();
2453 void Main::editRedo()
2455 VymModel *m=currentModel();
2459 void Main::gotoHistoryStep (int i)
2461 VymModel *m=currentModel();
2462 if (m) m->gotoHistoryStep(i);
2465 void Main::editCopy()
2467 VymModel *m=currentModel();
2471 void Main::editPaste()
2473 VymModel *m=currentModel();
2477 void Main::editCut()
2479 VymModel *m=currentModel();
2483 void Main::editOpenFindWindow()
2485 findWindow->popup();
2486 findWindow->raise();
2487 findWindow->setActiveWindow();
2490 void Main::editFind(QString s)
2492 VymModel *m=currentModel();
2496 BranchItem *bi=m->findText(s, cs);
2499 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2502 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2503 tr("No matches found for \"%1\"").arg(s));
2508 void Main::editFindChanged()
2509 { // Notify editor, to abort the current find process
2510 VymModel *m=currentModel();
2511 if (m) m->findReset();
2514 void Main::openTabs(QStringList urls)
2516 if (!urls.isEmpty())
2520 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2522 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2524 QString u=urls.takeFirst();
2525 procBrowser = new QProcess( this );
2527 procBrowser->start(browser,args);
2528 if ( !procBrowser->waitForStarted())
2530 // try to set path to browser
2531 QMessageBox::warning(0,
2533 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2534 tr("Please use Settings->")+tr("Set application to open an URL"));
2537 #if defined(Q_OS_WIN32)
2538 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2539 this->thread()->wait(3000);
2544 if (browser.contains("konqueror"))
2546 for (int i=0; i<urls.size(); i++)
2549 // Try to open new tab in existing konqueror started previously by vym
2550 p=new QProcess (this);
2552 #if defined(Q_OS_WIN32)
2553 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2554 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2555 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2556 "konqueror-mainwindow#1"<<
2560 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2561 "konqueror-mainwindow#1"<<
2565 p->start ("dcop",args);
2566 if (debug) cout << "MainWindo::openURLs args="<<args.join(" ").toStdString()<<endl;
2567 if ( !p->waitForStarted() ) success=false;
2570 QMessageBox::warning(0,
2572 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2574 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2576 for (int i=0; i<urls.size(); i++)
2578 // Try to open new tab in firefox
2579 p=new QProcess (this);
2580 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2581 p->start (browser,args);
2582 if ( !p->waitForStarted() ) success=false;
2585 QMessageBox::warning(0,
2587 tr("Couldn't start %1 to open a new tab").arg(browser));
2590 QMessageBox::warning(0,
2592 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2596 void Main::editOpenURL()
2599 VymModel *m=currentModel();
2602 QString url=m->getURL();
2604 if (url=="") return;
2605 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2606 procBrowser = new QProcess( this );
2608 procBrowser->start(browser,args);
2609 if ( !procBrowser->waitForStarted())
2611 // try to set path to browser
2612 QMessageBox::warning(0,
2614 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2615 tr("Please use Settings->")+tr("Set application to open an URL"));
2620 void Main::editOpenURLTab()
2622 VymModel *m=currentModel();
2626 urls.append(m->getURL());
2630 void Main::editOpenMultipleURLTabs()
2632 VymModel *m=currentModel();
2642 void Main::editURL()
2644 VymModel *m=currentModel();
2645 if (m) m->editURL();
2648 void Main::editLocalURL()
2650 VymModel *m=currentModel();
2651 if (m) m->editLocalURL();
2654 void Main::editHeading2URL()
2656 VymModel *m=currentModel();
2657 if (m) m->editHeading2URL();
2660 void Main::editBugzilla2URL()
2662 VymModel *m=currentModel();
2663 if (m) m->editBugzilla2URL();
2666 void Main::editFATE2URL()
2668 VymModel *m=currentModel();
2669 if (m) m->editFATE2URL();
2672 void Main::editHeadingFinished(VymModel *m)
2676 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2677 !prevSelection.isEmpty())
2678 m->select(prevSelection);
2683 void Main::openVymLinks(const QStringList &vl)
2685 for (int j=0; j<vl.size(); j++)
2687 // compare path with already loaded maps
2690 for (i=0;i<=tabModel.count() -1;i++)
2692 if (vl.at(j)==tabModel.at(i)->getFilePath() )
2701 if (!QFile(vl.at(j)).exists() )
2702 QMessageBox::critical( 0, tr( "Critical Error" ),
2703 tr("Couldn't open map %1").arg(vl.at(j)));
2706 fileLoad (vl.at(j), NewMap);
2707 tabWidget->setCurrentIndex (tabWidget->count()-1);
2710 // Go to tab containing the map
2711 tabWidget->setCurrentIndex (index);
2715 void Main::editOpenVymLink()
2717 VymModel *m=currentModel();
2721 vl.append(m->getVymLink());
2726 void Main::editOpenMultipleVymLinks()
2728 QString currentVymLink;
2729 VymModel *m=currentModel();
2732 QStringList vl=m->getVymLinks();
2737 void Main::editVymLink()
2739 VymModel *m=currentModel();
2744 void Main::editDeleteVymLink()
2746 VymModel *m=currentModel();
2747 if (m) m->deleteVymLink();
2750 void Main::editToggleHideExport()
2752 VymModel *m=currentModel();
2753 if (m) m->toggleHideExport();
2756 void Main::editMapInfo()
2758 VymModel *m=currentModel();
2760 ExtraInfoDialog dia;
2761 dia.setMapName (m->getFileName() );
2762 dia.setAuthor (m->getAuthor() );
2763 dia.setComment(m->getComment() );
2767 /* FIXME-2 no stats at the moment (view dependent...)
2768 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2778 if (!bo->getNote().isEmpty() ) n++;
2779 f+= bo->countFloatImages();
2781 xl+=bo->countXLinks();
2784 stats+=QString ("%1 xLinks \n").arg (xl,6);
2785 stats+=QString ("%1 notes\n").arg (n,6);
2786 stats+=QString ("%1 images\n").arg (f,6);
2788 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2789 dia.setStats (stats);
2791 // Finally show dialog
2792 if (dia.exec() == QDialog::Accepted)
2794 m->setAuthor (dia.getAuthor() );
2795 m->setComment (dia.getComment() );
2799 void Main::editMoveUp()
2801 VymModel *m=currentModel();
2805 void Main::editMoveDown()
2807 VymModel *m=currentModel();
2808 if (m) m->moveDown();
2811 void Main::editSortChildren()
2813 VymModel *m=currentModel();
2814 if (m) m->sortChildren();
2817 void Main::editToggleScroll()
2819 VymModel *m=currentModel();
2820 if (m) m->toggleScroll();
2823 void Main::editExpandAll()
2825 VymModel *m=currentModel();
2826 if (m) m->emitExpandAll();
2829 void Main::editUnscrollChildren()
2831 VymModel *m=currentModel();
2832 if (m) m->unscrollChildren();
2835 void Main::editAddMapCenter()
2837 VymModel *m=currentModel();
2840 cout <<"Main::editAddMapCenter\n";
2845 void Main::editNewBranch()
2847 VymModel *m=currentModel();
2850 BranchItem *bi=m->createBranch();
2857 if (actionSettingsAutoEditNewBranch->isOn())
2859 currentMapEditor()->editHeading();
2862 if (!prevSelection.isEmpty())
2864 m->select(prevSelection);
2870 void Main::editNewBranchBefore()
2872 VymModel *m=currentModel();
2875 BranchItem *bi=m->createBranch(); //FIXME-1 missing: m->addNewBranchBefore();
2882 if (actionSettingsAutoEditNewBranch->isOn())
2884 if (!actionSettingsAutoSelectNewBranch->isOn())
2885 prevSelection=m->getSelectString(bi);
2886 currentMapEditor()->editHeading();
2891 void Main::editNewBranchAbove()
2893 VymModel *m=currentModel();
2896 BranchItem *bi=m->addNewBranch (-1);
2904 if (actionSettingsAutoEditNewBranch->isOn())
2906 if (!actionSettingsAutoSelectNewBranch->isOn())
2907 prevSelection=m->getSelectString (bi);
2908 currentMapEditor()->editHeading();
2913 void Main::editNewBranchBelow()
2915 VymModel *m=currentModel();
2918 BranchItem *bi=m->addNewBranch (1);
2925 if (actionSettingsAutoEditNewBranch->isOn())
2927 if (!actionSettingsAutoSelectNewBranch->isOn())
2928 prevSelection=m->getSelectString(bi);
2929 currentMapEditor()->editHeading();
2934 void Main::editImportAdd()
2936 fileLoad (ImportAdd);
2939 void Main::editImportReplace()
2941 fileLoad (ImportReplace);
2944 void Main::editSaveBranch()
2946 fileSaveAs (PartOfMap);
2949 void Main::editDeleteKeepChildren()
2951 VymModel *m=currentModel();
2952 if (m) m->deleteKeepChildren();
2955 void Main::editDeleteChildren()
2957 VymModel *m=currentModel();
2958 if (m) m->deleteChildren();
2961 void Main::editDeleteSelection()
2963 VymModel *m=currentModel();
2964 if (m && actionSettingsUseDelKey->isOn())
2965 m->deleteSelection();
2968 void Main::editUpperBranch()
2970 VymModel *m=currentModel();
2971 if (m) m->selectUpperBranch(); // FIXME-3 check also lower... this probably should go into view...
2974 void Main::editLowerBranch() // FIXME-3 check also lower... this probably should go into view...
2977 VymModel *m=currentModel();
2978 if (m) m->selectLowerBranch();
2981 void Main::editLeftBranch()
2983 VymModel *m=currentModel();
2984 if (m) m->selectLeftBranch();
2987 void Main::editRightBranch()
2989 VymModel *m=currentModel();
2990 if (m) m->selectRightBranch();
2993 void Main::editFirstBranch()
2995 VymModel *m=currentModel();
2996 if (m) m->selectFirstBranch();
2999 void Main::editLastBranch()
3001 VymModel *m=currentModel();
3002 if (m) m->selectLastBranch();
3005 void Main::editLoadImage()
3007 VymModel *m=currentModel();
3008 if (m) m->loadFloatImage();
3011 void Main::editSaveImage()
3013 VymModel *m=currentModel();
3014 if (m) m->saveFloatImage();
3017 void Main::editFollowXLink(QAction *a)
3020 VymModel *m=currentModel();
3022 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3025 void Main::editEditXLink(QAction *a)
3027 VymModel *m=currentModel();
3029 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3032 void Main::formatSelectColor()
3034 QColor col = QColorDialog::getColor((currentColor ), this );
3035 if ( !col.isValid() ) return;
3036 colorChanged( col );
3039 void Main::formatPickColor()
3041 VymModel *m=currentModel();
3043 colorChanged( m->getCurrentHeadingColor() );
3046 void Main::colorChanged(QColor c)
3048 QPixmap pix( 16, 16 );
3050 actionFormatColor->setIconSet( pix );
3054 void Main::formatColorBranch()
3056 VymModel *m=currentModel();
3057 if (m) m->colorBranch(currentColor);
3060 void Main::formatColorSubtree()
3062 VymModel *m=currentModel();
3063 if (m) m->colorSubtree (currentColor);
3066 void Main::formatLinkStyleLine()
3068 VymModel *m=currentModel();
3071 m->setMapLinkStyle("StyleLine");
3072 actionFormatLinkStyleLine->setOn(true);
3076 void Main::formatLinkStyleParabel()
3078 VymModel *m=currentModel();
3081 m->setMapLinkStyle("StyleParabel");
3082 actionFormatLinkStyleParabel->setOn(true);
3086 void Main::formatLinkStylePolyLine()
3088 VymModel *m=currentModel();
3091 m->setMapLinkStyle("StylePolyLine");
3092 actionFormatLinkStylePolyLine->setOn(true);
3096 void Main::formatLinkStylePolyParabel()
3098 VymModel *m=currentModel();
3101 m->setMapLinkStyle("StylePolyParabel");
3102 actionFormatLinkStylePolyParabel->setOn(true);
3106 void Main::formatSelectBackColor()
3108 VymModel *m=currentModel();
3109 if (m) m->selectMapBackgroundColor();
3112 void Main::formatSelectBackImage()
3114 VymModel *m=currentModel();
3116 m->selectMapBackgroundImage();
3119 void Main::formatSelectLinkColor()
3121 VymModel *m=currentModel();
3124 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3125 m->setMapDefLinkColor( col );
3129 void Main::formatSelectSelectionColor()
3131 VymModel *m=currentModel();
3134 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3135 m->setSelectionColor (col);
3140 void Main::formatToggleLinkColorHint()
3142 VymModel *m=currentModel();
3143 if (m) m->toggleMapLinkColorHint();
3147 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3149 VymModel *m=currentModel();
3151 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3154 void Main::viewZoomReset()
3156 MapEditor *me=currentMapEditor();
3157 if (me) me->setZoomFactorTarget (1);
3160 void Main::viewZoomIn()
3162 MapEditor *me=currentMapEditor();
3163 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3166 void Main::viewZoomOut()
3168 MapEditor *me=currentMapEditor();
3169 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3172 void Main::viewCenter()
3174 VymModel *m=currentModel();
3175 if (m) m->emitShowSelection();
3178 void Main::networkStartServer()
3180 VymModel *m=currentModel();
3181 if (m) m->newServer();
3184 void Main::networkConnect()
3186 VymModel *m=currentModel();
3187 if (m) m->connectToServer();
3190 bool Main::settingsPDF()
3192 // Default browser is set in constructor
3194 QString text = QInputDialog::getText(
3195 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3196 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3198 settings.setValue ("/mainwindow/readerPDF",text);
3203 bool Main::settingsURL()
3205 // Default browser is set in constructor
3207 QString text = QInputDialog::getText(
3208 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3209 settings.value("/mainwindow/readerURL").toString()
3212 settings.setValue ("/mainwindow/readerURL",text);
3216 void Main::settingsMacroDir()
3218 QDir defdir(vymBaseDir.path() + "/macros");
3219 if (!defdir.exists())
3221 QDir dir=QFileDialog::getExistingDirectory (
3223 tr ("Directory with vym macros:"),
3224 settings.value ("/macros/macroDir",defdir.path()).toString()
3227 settings.setValue ("/macros/macroDir",dir.absolutePath());
3230 void Main::settingsUndoLevels()
3233 int i = QInputDialog::getInteger(
3235 tr("QInputDialog::getInteger()"),
3236 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3239 settings.setValue ("/mapeditor/stepsTotal",i);
3240 QMessageBox::information( this, tr( "VYM -Information:" ),
3241 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3245 void Main::settingsAutosaveToggle()
3247 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3250 void Main::settingsAutosaveTime()
3253 int i = QInputDialog::getInteger(
3255 tr("QInputDialog::getInteger()"),
3256 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3258 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3261 void Main::settingsWriteBackupFileToggle()
3263 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3266 void Main::settingsToggleAnimation()
3268 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3271 void Main::settingsToggleDelKey()
3273 if (actionSettingsUseDelKey->isOn())
3275 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3278 actionDelete->setAccel (QKeySequence (""));
3282 void Main::windowToggleNoteEditor()
3284 if (textEditor->isVisible() )
3285 windowHideNoteEditor();
3287 windowShowNoteEditor();
3290 void Main::windowToggleHistory()
3292 if (historyWindow->isVisible())
3293 historyWindow->hide();
3295 historyWindow->show();
3299 void Main::windowToggleProperty()
3301 if (branchPropertyWindow->isVisible())
3302 branchPropertyWindow->hide();
3304 branchPropertyWindow->show();
3305 branchPropertyWindow->setModel (currentModel() );
3308 void Main::windowToggleAntiAlias()
3310 bool b=actionViewToggleAntiAlias->isOn();
3312 for (int i=0;i<tabModel.count();i++)
3314 me=tabModel.at(i)->getMapEditor();
3315 if (me) me->setAntiAlias(b);
3320 bool Main::isAliased()
3322 return actionViewToggleAntiAlias->isOn();
3325 bool Main::hasSmoothPixmapTransform()
3327 return actionViewToggleSmoothPixmapTransform->isOn();
3330 void Main::windowToggleSmoothPixmap()
3332 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3334 for (int i=0;i<tabModel.count();i++)
3337 me=tabModel.at(i)->getMapEditor();
3338 if (me) me->setSmoothPixmap(b);
3342 void Main::updateHistory(SimpleSettings &undoSet)
3344 historyWindow->update (undoSet);
3347 void Main::updateNoteFlag()
3349 // this slot is connected to TextEditor::textHasChanged()
3351 VymModel *m=currentModel();
3352 if (m) m->updateNoteFlag();
3355 void Main::updateNoteEditor(QModelIndex index )
3357 TreeItem *ti=((VymModel*)sender())->getItem(index);
3359 cout << "Main::updateNoteEditor model="<<sender();
3360 cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3362 textEditor->setNote (ti->getNoteObj() );
3365 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3367 //branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select()
3369 if (model && model==currentModel() )
3373 if (!oldsel.indexes().isEmpty() )
3375 ti=model->getItem(oldsel.indexes().first());
3376 //cout << "Main::changeSel getting note from "<<ti->getHeading().toStdString()<<": \""<<ti->getNote().toStdString()<<"\""<<endl;
3377 ti->setNoteObj (textEditor->getNoteObj(),false );
3379 if (!newsel.indexes().isEmpty() )
3381 ti=model->getItem(newsel.indexes().first());
3382 if (!ti->getNoteObj().isEmpty() )
3384 //cout << "Main::changeSel setting note of "<<ti->getHeading().toStdString()<<" m=("<<ti->getModel()<<") to \""<<ti->getNote().toStdString()<<"\""<<endl;
3385 textEditor->setNote(ti->getNoteObj() );
3387 textEditor->setNote(NoteObj() );
3389 textEditor->setInactive();
3391 // Show URL and link in statusbar // FIXME-2
3394 QString s=model->getURL();
3395 if (!s.isEmpty() ) status+="URL: "+s+" ";
3396 s=model->getVymLink();
3397 if (!s.isEmpty() ) status+="Link: "+s;
3398 if (!status.isEmpty() ) statusMessage (status);
3401 // Update Toolbar // FIXME-0, was so far in BranchObj
3402 //updateFlagsToolbar();
3408 void Main::updateActions()
3410 VymModel *m =currentModel();
3411 LinkableMapObj *selection;
3415 actionFilePrint->setEnabled (true);
3418 selection=m->getSelectedLMO();
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);
3485 TreeItem *selti=m->getSelectedItem();
3486 BranchItem *selbi=m->getSelectedBranchItem();
3491 // Take care of links // FIXME-1
3493 if (bo->countXLinks()==0)
3495 branchXLinksContextMenuEdit->clear();
3496 branchXLinksContextMenuFollow->clear();
3501 branchXLinksContextMenuEdit->clear();
3502 branchXLinksContextMenuFollow->clear();
3503 for (int i=0; i<=bo->countXLinks();i++)
3505 bot=bo->XLinkTargetAt(i);
3508 s=bot->getHeading();
3509 if (s.length()>xLinkMenuWidth)
3510 s=s.left(xLinkMenuWidth)+"...";
3511 branchXLinksContextMenuFollow->addAction (s);
3512 branchXLinksContextMenuEdit->addAction (s);
3518 actionToggleScroll->setEnabled (true);
3519 if ( selbi->isScrolled() )
3520 actionToggleScroll->setOn(true);
3522 actionToggleScroll->setOn(false);
3524 if ( selti->getURL().isEmpty() )
3526 actionOpenURL->setEnabled (false);
3527 actionOpenURLTab->setEnabled (false);
3531 actionOpenURL->setEnabled (true);
3532 actionOpenURLTab->setEnabled (true);
3534 if ( selti->getVymLink().isEmpty() )
3536 actionOpenVymLink->setEnabled (false);
3537 actionDeleteVymLink->setEnabled (false);
3540 actionOpenVymLink->setEnabled (true);
3541 actionDeleteVymLink->setEnabled (true);
3544 if (selbi->canMoveUp())
3545 actionMoveUp->setEnabled (true);
3547 actionMoveUp->setEnabled (false);
3548 if (selbi->canMoveDown())
3549 actionMoveDown->setEnabled (true);
3551 actionMoveDown->setEnabled (false);
3553 actionSortChildren->setEnabled (true);
3555 actionToggleHideExport->setEnabled (true);
3556 actionToggleHideExport->setOn (selbi->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 ( selti->getType()==TreeItem::Image)
3574 FloatObj *fo=(FloatImageObj*)selection;
3576 actionOpenURL->setEnabled (false);
3577 actionOpenVymLink->setEnabled (false);
3578 actionDeleteVymLink->setEnabled (false);
3579 actionToggleHideExport->setEnabled (true);
3580 actionToggleHideExport->setOn (fo->hideInExport() );
3583 actionCopy->setEnabled (true);
3584 actionCut->setEnabled (true);
3585 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3586 for (int i=0; i<actionListBranches.size(); ++i)
3587 actionListBranches.at(i)->setEnabled(false);
3588 actionDelete->setEnabled (true);
3589 actionFormatHideLinkUnselected->setOn
3590 ( selection->getHideLinkUnselected());
3591 actionMoveUp->setEnabled (false);
3592 actionMoveDown->setEnabled (false);
3598 actionFileSave->setEnabled (false);
3599 actionCopy->setEnabled (false);
3600 actionCut->setEnabled (false);
3601 actionPaste->setEnabled (false);
3602 for (int i=0; i<actionListBranches.size(); ++i)
3603 actionListBranches.at(i)->setEnabled(false);
3605 actionToggleScroll->setEnabled (false);
3606 actionOpenURL->setEnabled (false);
3607 actionOpenVymLink->setEnabled (false);
3608 actionDeleteVymLink->setEnabled (false);
3609 actionHeading2URL->setEnabled (false);
3610 actionDelete->setEnabled (false);
3611 actionMoveUp->setEnabled (false);
3612 actionMoveDown->setEnabled (false);
3613 actionSortChildren->setEnabled (false);
3614 actionToggleHideExport->setEnabled (false);
3618 Main::ModMode Main::getModMode()
3620 if (actionModModeColor->isOn()) return ModModeColor;
3621 if (actionModModeCopy->isOn()) return ModModeCopy;
3622 if (actionModModeXLink->isOn()) return ModModeXLink;
3626 bool Main::autoEditNewBranch()
3628 return actionSettingsAutoEditNewBranch->isOn();
3631 bool Main::autoSelectNewBranch()
3633 return actionSettingsAutoSelectNewBranch->isOn();
3636 void Main::windowShowNoteEditor()
3638 textEditor->setShowWithMain(true);
3640 actionViewToggleNoteEditor->setOn (true);
3643 void Main::windowHideNoteEditor()
3645 textEditor->setShowWithMain(false);
3647 actionViewToggleNoteEditor->setOn (false);
3650 void Main::setScript (const QString &script)
3652 scriptEditor->setScript (script);
3655 void Main::runScript (const QString &script)
3657 VymModel *m=currentModel();
3658 if (m) m->runScript (script);
3661 void Main::runScriptEverywhere (const QString &script)
3664 for (int i=0;i<=tabWidget->count() -1;i++)
3666 me=(MapEditor*)tabWidget->page(i);
3667 if (me) me->getModel()->runScript (script);
3671 void Main::windowNextEditor()
3673 if (tabWidget->currentIndex() < tabWidget->count())
3674 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3677 void Main::windowPreviousEditor()
3679 if (tabWidget->currentIndex() >0)
3680 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3683 void Main::standardFlagChanged()
3687 if ( actionSettingsUseFlagGroups->isOn() )
3688 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3690 currentModel()->toggleStandardFlag(sender()->name());
3694 void Main::testFunction1()
3696 if (!currentMapEditor()) return;
3697 currentMapEditor()->testFunction1();
3701 void Main::testFunction2()
3703 if (!currentMapEditor()) return;
3704 currentMapEditor()->testFunction2();
3707 void Main::testCommand()
3709 if (!currentMapEditor()) return;
3710 scriptEditor->show();
3713 QString com = QInputDialog::getText(
3714 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3715 if (ok) currentMapEditor()->parseAtom(com);
3719 void Main::helpDoc()
3721 QString locale = QLocale::system().name();
3723 if (locale.left(2)=="es")
3724 docname="vym_es.pdf";
3728 QStringList searchList;
3730 #if defined(Q_OS_MACX)
3731 searchList << "./vym.app/Contents/Resources/doc";
3732 #elif defined(Q_OS_WIN32)
3733 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3735 #if defined(VYM_DOCDIR)
3736 searchList << VYM_DOCDIR;
3738 // default path in SUSE LINUX
3739 searchList << "/usr/share/doc/packages/vym";
3742 searchList << "doc"; // relative path for easy testing in tarball
3743 searchList << "doc/tex"; // Easy testing working on vym.tex
3744 searchList << "/usr/share/doc/vym"; // Debian
3745 searchList << "/usr/share/doc/packages";// Knoppix
3749 for (int i=0; i<searchList.count(); ++i)
3751 docfile.setFileName(searchList.at(i)+"/"+docname);
3752 if (docfile.exists())
3761 QMessageBox::critical(0,
3762 tr("Critcal error"),
3763 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3768 Process *pdfProc = new Process();
3769 args << QDir::toNativeSeparators(docfile.fileName());
3771 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3772 if ( !pdfProc->waitForStarted() )
3775 QMessageBox::warning(0,
3777 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3778 tr("Please use Settings->")+tr("Set application to open PDF files"));
3785 void Main::helpDemo()
3787 QStringList filters;
3788 filters <<"VYM example map (*.vym)";
3789 QFileDialog *fd=new QFileDialog( this);
3790 #if defined(Q_OS_MACX)
3791 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3793 // default path in SUSE LINUX
3794 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3797 fd->setFileMode (QFileDialog::ExistingFiles);
3798 fd->setFilters (filters);
3799 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3803 if ( fd->exec() == QDialog::Accepted )
3805 lastFileDir=fd->directory().path();
3806 QStringList flist = fd->selectedFiles();
3807 QStringList::Iterator it = flist.begin();
3808 while( it != flist.end() )
3811 fileLoad(*it, NewMap);
3819 void Main::helpAbout()
3822 ad.setName ("aboutwindow");
3823 ad.setMinimumSize(500,500);
3824 ad.resize (QSize (500,500));
3828 void Main::helpAboutQT()
3830 QMessageBox::aboutQt( this, "Qt Application Example" );
3833 void Main::callMacro ()
3835 QAction *action = qobject_cast<QAction *>(sender());
3839 i=action->data().toInt();
3840 QString mDir (settings.value ("macros/macroDir").toString() );
3842 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3844 if ( !f.open( QIODevice::ReadOnly ) )
3846 QMessageBox::warning(0,
3848 tr("Couldn't find a macro at %1.\n").arg(fn)+
3849 tr("Please use Settings->")+tr("Set directory for vym macros"));
3853 QTextStream ts( &f );
3854 QString macro= ts.read();
3856 if (! macro.isEmpty())
3858 VymModel *m=currentModel();
3859 if (m) m->runScript(macro);