1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
15 #include "historywindow.h"
17 #include "mapeditor.h"
22 #include "shortcuts.h"
23 #include "texteditor.h"
24 #include "warningdialog.h"
25 #include "xlinkitem.h"
27 //#include <modeltest.h> // FIXME-3
29 #if defined(Q_OS_WIN32)
30 // Define only this structure as opposed to
31 // including full 'windows.h'. FindWindow
32 // clashes with the one in Win32 API.
33 typedef struct _PROCESS_INFORMATION
39 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
42 extern TextEditor *textEditor;
43 extern Main *mainWindow;
44 extern QString tmpVymDir;
45 extern QString clipboardDir;
46 extern QString clipboardFile;
47 extern bool clipboardEmpty;
48 extern int statusbarTime;
49 extern FlagRow *standardFlagsMaster;
50 extern FlagRow *systemFlagsMaster;
51 extern QString vymName;
52 extern QString vymVersion;
53 extern QString vymBuildDate;
56 QMenu* branchContextMenu;
57 QMenu* branchAddContextMenu;
58 QMenu* branchRemoveContextMenu;
59 QMenu* branchLinksContextMenu;
60 QMenu* branchXLinksContextMenuEdit;
61 QMenu* floatimageContextMenu;
62 QMenu* canvasContextMenu;
63 QMenu* fileLastMapsMenu;
64 QMenu* fileImportMenu;
65 QMenu* fileExportMenu;
68 extern Settings settings;
69 extern Options options;
70 extern ImageIO imageIO;
72 extern QDir vymBaseDir;
73 extern QDir lastImageDir;
74 extern QDir lastFileDir;
75 #if defined(Q_OS_WIN32)
76 extern QDir vymInstallDir;
78 extern QString iconPath;
79 extern QString flagsPath;
82 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
83 QMainWindow(parent,name,f)
87 setCaption ("VYM - View Your Mind");
89 // Load window settings
90 #if defined(Q_OS_WIN32)
91 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
93 setWindowState(Qt::WindowMaximized);
98 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
99 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
102 // Sometimes we may need to remember old selections
106 currentColor=Qt::black;
108 // Create unique temporary directory
110 tmpVymDir=makeTmpDir (ok,"vym");
113 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
116 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
118 // Create direcctory for clipboard
119 clipboardDir=tmpVymDir+"/clipboard";
120 clipboardFile="map.xml";
121 QDir d(clipboardDir);
122 d.mkdir (clipboardDir,true);
123 makeSubDirs (clipboardDir);
126 browserPID=new qint64;
129 // Satellite windows //////////////////////////////////////////
131 historyWindow=new HistoryWindow();
132 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
135 branchPropertyWindow = new BranchPropertyWindow();
136 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
138 // Connect TextEditor, so that we can update flags if text changes
139 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
140 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
142 // Initialize script editor
143 scriptEditor = new SimpleScriptEditor();
144 scriptEditor->move (50,50);
146 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
147 this, SLOT( runScript( QString ) ) );
149 // Initialize some settings, which are platform dependant
152 // application to open URLs
153 p="/mainwindow/readerURL";
154 #if defined(Q_OS_LINUX)
155 s=settings.value (p,"xdg-open").toString();
157 #if defined(Q_OS_MACX)
158 s=settings.value (p,"/usr/bin/open").toString();
161 #if defined(Q_OS_WIN32)
162 // Assume that system has been set up so that
163 // Explorer automagically opens up the URL
164 // in the user's preferred browser.
165 s=settings.value (p,"explorer").toString();
167 s=settings.value (p,"mozilla").toString();
171 settings.setValue( p,s);
173 // application to open PDFs
174 p="/mainwindow/readerPDF";
175 #if defined(Q_OS_LINUX)
176 s=settings.value (p,"xdg-open").toString();
178 #if defined(Q_OS_MACX)
179 s=settings.value (p,"/usr/bin/open").toString();
180 #elif defined(Q_OS_WIN32)
181 s=settings.value (p,"acrord32").toString();
183 s=settings.value (p,"acroread").toString();
186 settings.setValue( p,s);
188 // width of xLinksMenu
191 // Create tab widget which holds the maps
192 tabWidget= new QTabWidget (this);
193 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
194 this, SLOT( editorChanged( QWidget * ) ) );
196 setCentralWidget(tabWidget);
200 setupFormatActions();
204 setupNetworkActions();
205 setupSettingsActions();
208 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
211 // Status bar and progress bar there
214 progressBar=new QProgressBar;
216 statusBar()->addPermanentWidget(progressBar);
218 restoreState (settings.value("/mainwindow/state",0).toByteArray());
226 #if defined(Q_OS_WIN32)
227 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
229 settings.setValue ("/mainwindow/geometry/size", size());
230 settings.setValue ("/mainwindow/geometry/pos", pos());
231 settings.setValue ("/mainwindow/state",saveState(0));
233 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
234 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
235 settings.setValue( "/version/version", vymVersion );
236 settings.setValue( "/version/builddate", vymBuildDate );
238 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
239 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
240 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
241 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
242 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
243 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
244 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
245 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
247 //TODO save scriptEditor settings
249 // call the destructors
251 delete historyWindow;
252 delete branchPropertyWindow;
255 // Remove temporary directory
256 removeDir (QDir(tmpVymDir));
259 void Main::loadCmdLine()
261 /* TODO draw some kind of splashscreen while loading...
267 QStringList flist=options.getFileList();
268 QStringList::Iterator it=flist.begin();
270 while (it !=flist.end() )
272 fileLoad (*it, NewMap);
278 void Main::statusMessage(const QString &s)
280 // Surpress messages while progressbar during
282 if (progressMin==progressMax)
283 statusBar()->message( s);
286 void Main::setProgressMinimum (int min)
288 progressBar->setMinimum(min);
292 void Main::setProgressMaximum (int max)
294 progressBar->setMaximum(max);
298 statusBar()->addPermanentWidget(progressBar);
303 void Main::setProgressValue (int v)
305 progressBar->setValue (v);
308 void Main::removeProgressBar()
311 statusBar()->removeWidget(progressBar);
312 progressMax=progressMin=0;
315 void Main::closeEvent (QCloseEvent* )
321 void Main::setupFileActions()
323 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
324 QToolBar *tb = addToolBar( tr ("&Map") );
325 tb->setObjectName ("mapTB");
328 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
329 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
330 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
332 fileMenu->addAction (a);
333 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
335 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
336 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
337 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
338 fileMenu->addAction (a);
339 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
342 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
343 a->setStatusTip (tr( "Open","Status tip File menu" ) );
344 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
346 fileMenu->addAction (a);
347 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
349 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
350 fileMenu->addSeparator();
352 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
353 a->setStatusTip ( tr( "Save","Status tip file menu" ));
354 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
356 fileMenu->addAction (a);
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
360 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
361 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
362 fileMenu->addAction (a);
363 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
365 fileMenu->addSeparator();
367 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
369 a = new QAction(tr("KDE 3 Bookmarks"), this);
370 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
371 a->addTo (fileImportMenu);
372 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
374 a = new QAction(tr("KDE 4 Bookmarks"), this);
375 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
376 a->addTo (fileImportMenu);
377 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
379 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
381 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
382 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
383 a->addTo (fileImportMenu);
384 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
387 a = new QAction("Freemind...",this);
388 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
389 fileImportMenu->addAction (a);
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
392 a = new QAction("Mind Manager...",this);
393 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
394 fileImportMenu->addAction (a);
395 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
397 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
398 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
399 fileImportMenu->addAction (a);
400 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
402 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
404 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
405 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
406 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
407 fileExportMenu->addAction (a);
409 a = new QAction( "Open Office...", this);
410 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
411 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
412 fileExportMenu->addAction (a);
414 a = new QAction( "Webpage (XHTML)...",this );
415 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
416 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
417 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
418 fileExportMenu->addAction (a);
420 a = new QAction( "Text (A&O report)...", this);
421 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
422 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
423 fileExportMenu->addAction (a);
425 a = new QAction( "Text (ASCII)...", this);
426 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
427 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
428 fileExportMenu->addAction (a);
430 a = new QAction( "Spreadsheet (CSV)...", this);
431 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
432 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
433 fileExportMenu->addAction (a);
435 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
436 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
437 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
438 fileExportMenu->addAction (a);
440 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
441 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
442 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
443 fileExportMenu->addAction (a);
445 a = new QAction( "Taskjuggler...", this );
446 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
447 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
448 fileExportMenu->addAction (a);
450 a = new QAction( "LaTeX...", this);
451 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
452 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
453 fileExportMenu->addAction (a);
455 a = new QAction( "XML..." , this );
456 a->setStatusTip (tr( "Export as %1").arg("XML"));
457 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
458 fileExportMenu->addAction (a);
460 fileMenu->addSeparator();
462 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
463 a->setStatusTip ( tr( "Print" ,"File menu") );
464 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
466 fileMenu->addAction (a);
467 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
470 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
471 a->setStatusTip (tr( "Close Map" ) );
472 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
473 fileMenu->addAction (a);
474 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
476 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
477 a->setStatusTip ( tr( "Exit")+" "+vymName );
478 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
479 fileMenu->addAction (a);
480 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
485 void Main::setupEditActions()
487 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
488 tb->setLabel( "Edit Actions" );
489 tb->setObjectName ("actionsTB");
490 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
494 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
495 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
496 a->setStatusTip (tr( "Undo" ) );
497 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
498 a->setEnabled (false);
500 editMenu->addAction (a);
503 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
504 a->setStatusTip (tr( "Redo" ));
505 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
507 editMenu->addAction (a);
508 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
511 editMenu->addSeparator();
512 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
513 a->setStatusTip ( tr( "Copy" ) );
514 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
515 a->setEnabled (false);
517 editMenu->addAction (a);
518 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
521 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
522 a->setStatusTip ( tr( "Cut" ) );
523 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
524 a->setEnabled (false);
526 editMenu->addAction (a);
528 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
530 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
531 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
532 a->setStatusTip ( tr( "Paste" ) );
533 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
534 a->setEnabled (false);
536 editMenu->addAction (a);
539 // Shortcut to delete selection
540 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
541 a->setStatusTip (tr( "Delete Selection" ));
542 a->setShortcut ( Qt::Key_Delete); //Delete selection
543 a->setShortcutContext (Qt::WindowShortcut);
545 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
548 // Shortcut to add attribute
549 a= new QAction(tr( "Add attribute" ), this);
550 a->setShortcut ( Qt::Key_Q);
551 a->setShortcutContext (Qt::WindowShortcut);
553 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
554 actionAddAttribute= a;
557 // Shortcut to add mapcenter
558 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
559 a->setShortcut ( Qt::Key_M);
560 a->setShortcutContext (Qt::WindowShortcut);
561 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
562 //actionListBranches.append(a);
564 actionAddMapCenter = a;
567 // Shortcut to add branch
568 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
569 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
570 alt->setShortcut (Qt::Key_A); //Add branch
571 alt->setShortcutContext (Qt::WindowShortcut);
573 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
574 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
575 a->setStatusTip ( tr( "Add a branch as child of selection" ));
576 a->setShortcut (Qt::Key_Insert); //Add branch
577 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
578 actionListBranches.append(a);
579 #if defined (Q_OS_MACX)
580 // In OSX show different shortcut in menues, the keys work indepently always
585 editMenu->addAction (actionAddBranch);
586 tb->addAction (actionAddBranch);
589 // Add branch by inserting it at selection
590 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
591 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
592 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
593 a->setShortcutContext (Qt::WindowShortcut);
595 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
596 a->setEnabled (false);
597 actionListBranches.append(a);
598 actionAddBranchBefore=a;
599 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
600 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
601 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
602 a->setShortcutContext (Qt::WindowShortcut);
604 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
605 actionListBranches.append(a);
608 a = new QAction(tr( "Add branch above","Edit menu" ), this);
609 a->setStatusTip ( tr( "Add a branch above selection" ));
610 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
611 a->setShortcutContext (Qt::WindowShortcut);
613 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
614 a->setEnabled (false);
615 actionListBranches.append(a);
616 actionAddBranchAbove=a;
617 a = new QAction(tr( "Add branch above","Edit menu" ), this);
618 a->setStatusTip ( tr( "Add a branch above selection" ));
619 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
620 a->setShortcutContext (Qt::WindowShortcut);
622 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
623 actionListBranches.append(a);
626 a = new QAction(tr( "Add branch below","Edit menu" ), this);
627 a->setStatusTip ( tr( "Add a branch below selection" ));
628 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
629 a->setShortcutContext (Qt::WindowShortcut);
631 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
632 a->setEnabled (false);
633 actionListBranches.append(a);
634 actionAddBranchBelow=a;
635 a = new QAction(tr( "Add branch below","Edit menu" ), this);
636 a->setStatusTip ( tr( "Add a branch below selection" ));
637 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
638 a->setShortcutContext (Qt::WindowShortcut);
640 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
641 actionListBranches.append(a);
643 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
644 a->setStatusTip ( tr( "Move branch up" ) );
645 a->setShortcut (Qt::Key_PageUp ); // Move branch up
646 a->setEnabled (false);
648 editMenu->addAction (a);
649 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
652 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
653 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
654 a->setStatusTip (tr( "Move branch down" ) );
655 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
656 a->setEnabled (false);
658 editMenu->addAction (a);
661 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
662 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
663 a->setShortcut ( Qt::Key_D ); // Detach branch
664 editMenu->addAction (a);
665 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
668 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
669 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
670 a->setEnabled (true);
672 editMenu->addAction (a);
673 actionSortChildren=a;
675 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
676 alt->setShortcut ( Qt::Key_S ); // Scroll branch
677 alt->setStatusTip (tr( "Scroll branch" ));
678 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
679 #if defined(Q_OS_MACX)
680 actionToggleScroll=alt;
682 actionToggleScroll=a;
684 actionToggleScroll->setEnabled (false);
685 actionToggleScroll->setToggleAction(true);
686 tb->addAction (actionToggleScroll);
687 editMenu->addAction ( actionToggleScroll);
688 editMenu->addAction (actionToggleScroll);
691 actionListBranches.append(actionToggleScroll);
693 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
694 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
695 a->setStatusTip (tr( "Expand all branches" ));
696 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
698 actionExpandAll->setEnabled (false);
699 actionExpandAll->setToggleAction(false);
700 //tb->addAction (actionExpandAll);
701 editMenu->addAction ( actionExpandAll);
703 actionListBranches.append(actionExpandAll);
705 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
706 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
707 a->setStatusTip (tr( "Expand one level in tree editor" ));
708 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
709 a->setEnabled (false);
710 a->setToggleAction(false);
711 actionExpandOneLevel=a;
713 editMenu->addAction ( a);
715 actionListBranches.append(a);
717 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
718 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
719 a->setStatusTip (tr( "Collapse one level in tree editor" ));
720 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
721 a->setEnabled (false);
722 a->setToggleAction(false);
723 actionCollapseOneLevel=a;
725 editMenu->addAction ( a);
727 actionListBranches.append(a);
729 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
730 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
731 editMenu->addAction (a);
732 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
734 editMenu->addSeparator();
736 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
737 a->setStatusTip (tr( "Find" ) );
738 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
739 editMenu->addAction (a);
740 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
742 editMenu->addSeparator();
744 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
745 a->setShortcut (Qt::SHIFT + Qt::Key_U );
746 a->setShortcut (tr( "Open URL" ));
749 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
752 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
753 a->setStatusTip (tr( "Open URL in new tab" ));
754 //a->setShortcut (Qt::CTRL+Qt::Key_U );
756 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
759 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
760 a->setStatusTip (tr( "Open all URLs in subtree" ));
761 a->setShortcut ( Qt::CTRL + Qt::Key_U );
763 actionListBranches.append(a);
764 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
765 actionOpenMultipleURLTabs=a;
767 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
768 a->setStatusTip ( tr( "Edit URL" ) );
769 a->setShortcut ( Qt::Key_U );
770 a->setShortcutContext (Qt::WindowShortcut);
771 actionListBranches.append(a);
773 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
776 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
777 a->setStatusTip ( tr( "Edit local URL" ) );
778 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
779 a->setShortcutContext (Qt::WindowShortcut);
780 actionListBranches.append(a);
782 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
785 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
786 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
787 a->setEnabled (false);
788 actionListBranches.append(a);
789 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
792 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
793 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
794 a->setEnabled (false);
795 actionListBranches.append(a);
796 a->setShortcut ( Qt::Key_B );
797 a->setShortcutContext (Qt::WindowShortcut);
799 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
800 actionBugzilla2URL=a;
802 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
803 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
804 a->setEnabled (false);
805 actionListBranches.append(a);
806 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
809 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
810 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
812 a->setEnabled (false);
813 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
816 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
817 a->setStatusTip ( tr( "Open all vym links in subtree" ));
818 a->setEnabled (false);
819 actionListBranches.append(a);
820 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
821 actionOpenMultipleVymLinks=a;
824 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
825 a->setEnabled (false);
826 a->setStatusTip ( tr( "Edit link to another vym map" ));
827 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
828 actionListBranches.append(a);
831 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
832 a->setStatusTip ( tr( "Delete link to another vym map" ));
833 a->setEnabled (false);
834 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
835 actionDeleteVymLink=a;
837 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
838 a->setStatusTip ( tr( "Hide object in exports" ) );
839 a->setShortcut (Qt::Key_H );
840 a->setToggleAction(true);
842 a->setEnabled (false);
843 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
844 actionToggleHideExport=a;
846 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
847 a->setStatusTip ( tr( "Add timestamp" ));
848 a->setEnabled (false);
849 actionListBranches.append(a);
850 a->setShortcut ( Qt::Key_T ); // Add timestamp
851 a->setShortcutContext (Qt::WindowShortcut);
853 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
854 actionAddTimestamp=a;
856 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
857 a->setStatusTip ( tr( "Edit Map Info" ));
858 a->setEnabled (true);
859 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
862 // Import at selection (adding to selection)
863 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
864 a->setStatusTip (tr( "Add map at selection" ));
865 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
866 a->setEnabled (false);
867 actionListBranches.append(a);
870 // Import at selection (replacing selection)
871 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
872 a->setStatusTip (tr( "Replace selection with map" ));
873 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
874 a->setEnabled (false);
875 actionListBranches.append(a);
876 actionImportReplace=a;
879 a = new QAction( tr( "Save selection","Edit menu" ), this);
880 a->setStatusTip (tr( "Save selection" ));
881 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
882 a->setEnabled (false);
883 actionListBranches.append(a);
886 // Only remove branch, not its children
887 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
888 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
889 a->setShortcut (Qt::ALT + Qt::Key_Delete );
890 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
891 a->setEnabled (false);
893 actionListBranches.append(a);
894 actionDeleteKeepChildren=a;
896 // Only remove children of a branch
897 a = new QAction( tr( "Remove children","Edit menu" ), this);
898 a->setStatusTip (tr( "Remove children of branch" ));
899 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
900 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
901 a->setEnabled (false);
902 actionListBranches.append(a);
903 actionDeleteChildren=a;
905 a = new QAction( tr( "Add Image...","Edit menu" ), this);
906 a->setStatusTip (tr( "Add Image" ));
907 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
910 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
911 a->setStatusTip (tr( "Set properties for selection" ));
912 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
913 a->setShortcutContext (Qt::WindowShortcut);
914 a->setToggleAction (true);
916 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
917 actionViewTogglePropertyWindow=a;
921 void Main::setupFormatActions()
923 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
925 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
926 tb->setObjectName ("formatTB");
929 pix.fill (Qt::black);
930 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
931 a->setStatusTip ( tr( "Set Color" ));
932 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
934 formatMenu->addAction (a);
936 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
937 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
938 a->setShortcut (Qt::CTRL + Qt::Key_K );
939 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
940 a->setEnabled (false);
942 formatMenu->addAction (a);
943 actionListBranches.append(a);
944 actionFormatPickColor=a;
946 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
947 a->setStatusTip ( tr( "Color branch" ) );
948 a->setShortcut (Qt::CTRL + Qt::Key_B);
949 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
950 a->setEnabled (false);
952 formatMenu->addAction (a);
953 actionListBranches.append(a);
954 actionFormatColorSubtree=a;
956 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
957 a->setStatusTip ( tr( "Color Subtree" ));
958 //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree
959 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
960 a->setEnabled (false);
961 formatMenu->addAction (a);
963 actionListBranches.append(a);
964 actionFormatColorSubtree=a;
966 formatMenu->addSeparator();
967 actionGroupFormatLinkStyles=new QActionGroup ( this);
968 actionGroupFormatLinkStyles->setExclusive (true);
969 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
970 a->setStatusTip (tr( "Line" ));
971 a->setToggleAction(true);
972 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
973 formatMenu->addAction (a);
974 actionFormatLinkStyleLine=a;
975 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
976 a->setStatusTip (tr( "Line" ));
977 a->setToggleAction(true);
978 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
979 formatMenu->addAction (a);
980 actionFormatLinkStyleParabel=a;
981 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
982 a->setStatusTip (tr( "PolyLine" ));
983 a->setToggleAction(true);
984 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
985 formatMenu->addAction (a);
986 actionFormatLinkStylePolyLine=a;
987 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
988 a->setStatusTip (tr( "PolyParabel" ) );
989 a->setToggleAction(true);
990 a->setChecked (true);
991 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
992 formatMenu->addAction (a);
993 actionFormatLinkStylePolyParabel=a;
995 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
996 a->setStatusTip (tr( "Hide link" ));
997 a->setToggleAction(true);
998 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
999 actionFormatHideLinkUnselected=a;
1001 formatMenu->addSeparator();
1002 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1003 a->setStatusTip (tr( "Use same color for links and headings" ));
1004 a->setToggleAction(true);
1005 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1006 formatMenu->addAction (a);
1007 actionFormatLinkColorHint=a;
1009 pix.fill (Qt::white);
1010 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1011 a->setStatusTip (tr( "Set Link Color" ));
1012 formatMenu->addAction (a);
1013 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1014 actionFormatLinkColor=a;
1016 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1017 a->setStatusTip (tr( "Set Selection Color" ));
1018 formatMenu->addAction (a);
1019 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1020 actionFormatSelectionColor=a;
1022 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1023 a->setStatusTip (tr( "Set Background Color" ));
1024 formatMenu->addAction (a);
1025 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1026 actionFormatBackColor=a;
1028 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1029 a->setStatusTip (tr( "Set Background image" ));
1030 formatMenu->addAction (a);
1031 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1032 actionFormatBackImage=a;
1036 void Main::setupViewActions()
1038 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1039 tb->setLabel( "View Actions" );
1040 tb->setObjectName ("viewTB");
1041 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1043 Switchboard switchboard; //FIXME-1 testing...
1046 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1047 a->setStatusTip ( tr( "Zoom reset" ) );
1048 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1049 switchboard.addConnection(a,"CTRL+0");
1051 viewMenu->addAction (a);
1052 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1054 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1055 a->setStatusTip (tr( "Zoom in" ));
1056 switchboard.addConnection(a,"CTRL++");
1058 viewMenu->addAction (a);
1059 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1061 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1062 a->setStatusTip (tr( "Zoom out" ));
1063 switchboard.addConnection(a,"CTRL+-");
1065 viewMenu->addAction (a);
1066 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1068 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1069 a->setStatusTip (tr( "Show selection" ));
1070 switchboard.addConnection(a,".");
1072 viewMenu->addAction (a);
1073 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1075 viewMenu->addSeparator();
1077 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1078 a->setStatusTip ( tr( "Show Note Editor" ));
1079 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1080 a->setToggleAction(true);
1082 viewMenu->addAction (a);
1083 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1084 actionViewToggleNoteEditor=a;
1086 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1087 a->setStatusTip ( tr( "Show History Window" ));
1088 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1089 a->setToggleAction(true);
1091 viewMenu->addAction (a);
1092 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1093 actionViewToggleHistoryWindow=a;
1095 viewMenu->addAction (actionViewTogglePropertyWindow);
1097 viewMenu->addSeparator();
1099 a = new QAction(tr( "Antialiasing","View action" ),this );
1100 a->setStatusTip ( tr( "Antialiasing" ));
1101 a->setToggleAction(true);
1102 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1103 viewMenu->addAction (a);
1104 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1105 actionViewToggleAntiAlias=a;
1107 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1108 a->setStatusTip (a->text());
1109 a->setToggleAction(true);
1110 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1111 viewMenu->addAction (a);
1112 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1113 actionViewToggleSmoothPixmapTransform=a;
1115 a = new QAction(tr( "Next Map","View action" ), this);
1116 a->setStatusTip (a->text());
1117 a->setShortcut (Qt::ALT + Qt::Key_N );
1118 viewMenu->addAction (a);
1119 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1121 a = new QAction (tr( "Previous Map","View action" ), this );
1122 a->setStatusTip (a->text());
1123 a->setShortcut (Qt::ALT + Qt::Key_P );
1124 viewMenu->addAction (a);
1125 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1127 if (debug) switchboard.print();
1131 void Main::setupModeActions()
1133 //QPopupMenu *menu = new QPopupMenu( this );
1134 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1136 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1137 tb->setObjectName ("modesTB");
1139 actionGroupModModes=new QActionGroup ( this);
1140 actionGroupModModes->setExclusive (true);
1141 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1142 a->setShortcut (Qt::Key_J);
1143 a->setStatusTip ( tr( "Use modifier to color branches" ));
1144 a->setToggleAction(true);
1146 a->setChecked(true);
1147 actionModModeColor=a;
1149 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1150 a->setShortcut( Qt::Key_K);
1151 a->setStatusTip( tr( "Use modifier to copy" ));
1152 a->setToggleAction(true);
1154 actionModModeCopy=a;
1156 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1157 a->setShortcut (Qt::Key_L);
1158 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1159 a->setToggleAction(true);
1161 actionModModeXLink=a;
1165 void Main::setupFlagActions()
1167 // Create System Flags
1170 Flag *flag=new Flag;;
1171 flag->setVisible(true);
1173 flag->load(QPixmap(flagsPath+"flag-note.png"));
1174 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1176 flag->load(QPixmap(flagsPath+"flag-url.png"));
1177 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1179 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1180 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1182 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1183 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1185 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1186 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1188 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1189 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1191 // Create Standard Flags
1192 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1193 tb->setObjectName ("standardFlagTB");
1194 standardFlagsMaster->setToolBar (tb);
1196 flag->load(flagsPath+"flag-exclamationmark.png");
1197 flag->setGroup("standard-mark");
1198 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1200 flag->load(flagsPath+"flag-questionmark.png");
1201 flag->setGroup("standard-mark");
1202 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1204 flag->load(flagsPath+"flag-hook-green.png");
1205 flag->setGroup("standard-status");
1206 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1208 flag->load(flagsPath+"flag-wip.png");
1209 flag->setGroup("standard-status");
1210 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1212 flag->load(flagsPath+"flag-cross-red.png");
1213 flag->setGroup("standard-status");
1214 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1217 flag->load(flagsPath+"flag-stopsign.png");
1218 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1220 flag->load(flagsPath+"flag-smiley-good.png");
1221 flag->setGroup("standard-smiley");
1222 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1224 flag->load(flagsPath+"flag-smiley-sad.png");
1225 flag->setGroup("standard-smiley");
1226 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1228 flag->load(flagsPath+"flag-smiley-omg.png");
1229 flag->setGroup("standard-smiley");
1230 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1231 // Original omg.png (in KDE emoticons)
1234 flag->load(flagsPath+"flag-kalarm.png");
1235 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1237 flag->load(flagsPath+"flag-phone.png");
1238 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1240 flag->load(flagsPath+"flag-lamp.png");
1241 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1243 flag->load(flagsPath+"flag-arrow-up.png");
1244 flag->setGroup("standard-arrow");
1245 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1247 flag->load(flagsPath+"flag-arrow-down.png");
1248 flag->setGroup("standard-arrow");
1249 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1251 flag->load(flagsPath+"flag-arrow-2up.png");
1252 flag->setGroup("standard-arrow");
1253 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1255 flag->load(flagsPath+"flag-arrow-2down.png");
1256 flag->setGroup("standard-arrow");
1257 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1260 flag->load(flagsPath+"flag-thumb-up.png");
1261 flag->setGroup("standard-thumb");
1262 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1264 flag->load(flagsPath+"flag-thumb-down.png");
1265 flag->setGroup("standard-thumb");
1266 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1269 flag->load(flagsPath+"flag-rose.png");
1270 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1272 flag->load(flagsPath+"flag-heart.png");
1273 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1275 flag->load(flagsPath+"flag-present.png");
1276 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1278 flag->load(flagsPath+"flag-flash.png");
1279 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1281 // Original: xsldbg_output.png
1282 flag->load(flagsPath+"flag-info.png");
1283 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1285 // Original khelpcenter.png
1286 flag->load(flagsPath+"flag-lifebelt.png");
1287 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1290 flag->setVisible(false);
1291 flag->load(flagsPath+"freemind/warning.png");
1292 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1294 for (int i=1; i<8; i++)
1296 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1297 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1300 flag->load(flagsPath+"freemind/back.png");
1301 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1303 flag->load(flagsPath+"freemind/forward.png");
1304 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1306 flag->load(flagsPath+"freemind/attach.png");
1307 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1309 flag->load(flagsPath+"freemind/clanbomber.png");
1310 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1312 flag->load(flagsPath+"freemind/desktopnew.png");
1313 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1315 flag->load(flagsPath+"freemind/flag.png");
1316 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1319 flag->load(flagsPath+"freemind/gohome.png");
1320 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1323 flag->load(flagsPath+"freemind/kaddressbook.png");
1324 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1326 flag->load(flagsPath+"freemind/knotify.png");
1327 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1329 flag->load(flagsPath+"freemind/korn.png");
1330 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1332 flag->load(flagsPath+"freemind/mail.png");
1333 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1335 flag->load(flagsPath+"freemind/password.png");
1336 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1338 flag->load(flagsPath+"freemind/pencil.png");
1339 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1341 flag->load(flagsPath+"freemind/stop.png");
1342 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1344 flag->load(flagsPath+"freemind/wizard.png");
1345 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1347 flag->load(flagsPath+"freemind/xmag.png");
1348 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1350 flag->load(flagsPath+"freemind/bell.png");
1351 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1353 flag->load(flagsPath+"freemind/bookmark.png");
1354 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1356 flag->load(flagsPath+"freemind/penguin.png");
1357 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1359 flag->load(flagsPath+"freemind/licq.png");
1360 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1363 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1365 flag->setName(name);
1366 flag->setToolTip (tooltip);
1370 a=new QAction (flag->getPixmap(),name,this);
1373 flag->setAction (a);
1374 a->setVisible (flag->isVisible());
1375 a->setCheckable(true);
1376 a->setObjectName(name);
1377 a->setToolTip(tooltip);
1378 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1379 standardFlagsMaster->addFlag (flag);
1383 systemFlagsMaster->addFlag (flag);
1388 void Main::setupNetworkActions()
1390 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1392 QMenu *netMenu = menuBar()->addMenu( "Network" );
1396 a = new QAction( "Start TCPserver for MapEditor",this);
1397 //a->setStatusTip ( "Set application to open pdf files"));
1398 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1399 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1400 netMenu->addAction (a);
1402 a = new QAction( "Connect MapEditor to server",this);
1403 //a->setStatusTip ( "Set application to open pdf files"));
1404 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1405 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1406 netMenu->addAction (a);
1410 void Main::setupSettingsActions()
1412 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1416 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1417 a->setStatusTip ( tr( "Set application to open pdf files"));
1418 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1419 settingsMenu->addAction (a);
1421 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1422 a->setStatusTip( tr( "Set application to open external links"));
1423 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1424 settingsMenu->addAction (a);
1426 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1427 a->setStatusTip( tr( "Set path for macros"));
1428 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1429 settingsMenu->addAction (a);
1431 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1432 a->setStatusTip( tr( "Set number of undo levels"));
1433 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1434 settingsMenu->addAction (a);
1436 settingsMenu->addSeparator();
1438 a = new QAction( tr( "Autosave","Settings action"), this);
1439 a->setStatusTip( tr( "Autosave"));
1440 a->setToggleAction(true);
1441 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1442 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1443 settingsMenu->addAction (a);
1444 actionSettingsAutosaveToggle=a;
1446 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1447 a->setStatusTip( tr( "Autosave time"));
1448 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1449 settingsMenu->addAction (a);
1450 actionSettingsAutosaveTime=a;
1452 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1453 a->setStatusTip( tr( "Write backup file on save"));
1454 a->setToggleAction(true);
1455 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1456 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1457 settingsMenu->addAction (a);
1458 actionSettingsWriteBackupFile=a;
1460 settingsMenu->addSeparator();
1462 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1463 a->setStatusTip( tr( "Edit branch after adding it" ));
1464 a->setToggleAction(true);
1465 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1466 settingsMenu->addAction (a);
1467 actionSettingsAutoEditNewBranch=a;
1469 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1470 a->setStatusTip( tr( "Select branch after adding it" ));
1471 a->setToggleAction(true);
1472 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1473 settingsMenu->addAction (a);
1474 actionSettingsAutoSelectNewBranch=a;
1476 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1477 a->setStatusTip( tr( "Select heading before editing" ));
1478 a->setToggleAction(true);
1479 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1480 settingsMenu->addAction (a);
1481 actionSettingsAutoSelectText=a;
1483 a= new QAction( tr( "Delete key","Settings action" ), this);
1484 a->setStatusTip( tr( "Delete key for deleting branches" ));
1485 a->setToggleAction(true);
1486 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1487 settingsMenu->addAction (a);
1488 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1489 actionSettingsUseDelKey=a;
1491 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1492 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1493 a->setToggleAction(true);
1494 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1495 settingsMenu->addAction (a);
1496 actionSettingsUseFlagGroups=a;
1498 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1499 a->setStatusTip( tr( "Use hide flag during exports " ));
1500 a->setToggleAction(true);
1501 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1502 settingsMenu->addAction (a);
1503 actionSettingsUseHideExport=a;
1505 a = new QAction( tr( "Animation","Settings action"), this);
1506 a->setStatusTip( tr( "Animation"));
1507 a->setToggleAction(true);
1508 a->setChecked (settings.value("/animation/use",true).toBool() );
1509 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1510 settingsMenu->addAction (a);
1511 actionSettingsUseAnimation=a;
1515 void Main::setupTestActions()
1517 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1520 a = new QAction( "Test function 1" , this);
1521 a->setStatusTip( "Call test function 1" );
1522 a->setShortcut (Qt::CTRL + Qt::Key_T); // Test function 1 //FIXME-2 originally: color subtree
1523 testMenu->addAction (a);
1524 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1526 a = new QAction( "Test function 2" , this);
1527 a->setStatusTip( "Call test function 2" );
1528 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 2
1529 testMenu->addAction (a);
1530 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1532 a = new QAction( "Command" , this);
1533 a->setStatusTip( "Enter command to call in editor" );
1534 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1535 testMenu->addAction (a);
1539 void Main::setupHelpActions()
1541 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1544 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1545 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1546 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1547 helpMenu->addAction (a);
1549 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1550 a->setStatusTip( tr( "Open VYM example maps " ));
1551 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1552 helpMenu->addAction (a);
1554 a = new QAction( tr( "About VYM","Help action" ), this);
1555 a->setStatusTip( tr( "About VYM")+vymName);
1556 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1557 helpMenu->addAction (a);
1559 a = new QAction( tr( "About QT","Help action" ), this);
1560 a->setStatusTip( tr( "Information about QT toolkit" ));
1561 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1562 helpMenu->addAction (a);
1566 void Main::setupContextMenus()
1570 // Context Menu for branch or mapcenter
1571 branchContextMenu =new QMenu (this);
1572 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1573 branchContextMenu->addSeparator();
1576 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1577 branchAddContextMenu->addAction (actionPaste );
1578 branchAddContextMenu->addAction ( actionAddMapCenter );
1579 branchAddContextMenu->addAction ( actionAddBranch );
1580 branchAddContextMenu->addAction ( actionAddBranchBefore );
1581 branchAddContextMenu->addAction ( actionAddBranchAbove);
1582 branchAddContextMenu->addAction ( actionAddBranchBelow );
1583 branchAddContextMenu->addSeparator();
1584 branchAddContextMenu->addAction ( actionImportAdd );
1585 branchAddContextMenu->addAction ( actionImportReplace );
1588 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1589 branchRemoveContextMenu->addAction (actionCut);
1590 branchRemoveContextMenu->addAction ( actionDelete );
1591 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1592 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1595 actionSaveBranch->addTo( branchContextMenu );
1596 actionFileNewCopy->addTo (branchContextMenu );
1597 actionDetach->addTo (branchContextMenu );
1599 branchContextMenu->addSeparator();
1600 branchContextMenu->addAction ( actionLoadImage);
1601 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1602 branchContextMenu->addAction ( actionAddAttribute);
1604 // Submenu for Links (URLs, vymLinks)
1605 branchLinksContextMenu =new QMenu (this);
1607 branchContextMenu->addSeparator();
1608 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1609 branchLinksContextMenu->addAction ( actionOpenURL );
1610 branchLinksContextMenu->addAction ( actionOpenURLTab );
1611 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1612 branchLinksContextMenu->addAction ( actionURL );
1613 branchLinksContextMenu->addAction ( actionLocalURL );
1614 branchLinksContextMenu->addAction ( actionHeading2URL );
1615 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1616 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1618 branchLinksContextMenu->addAction ( actionFATE2URL );
1620 branchLinksContextMenu->addSeparator();
1621 branchLinksContextMenu->addAction ( actionOpenVymLink );
1622 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1623 branchLinksContextMenu->addAction ( actionVymLink );
1624 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1627 // Context Menu for XLinks in a branch menu
1628 // This will be populated "on demand" in MapEditor::updateActions
1629 branchContextMenu->addSeparator();
1630 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1631 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1634 // Context menu for floatimage
1635 floatimageContextMenu =new QMenu (this);
1636 a= new QAction (tr ("Save image","Context action"),this);
1637 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1638 floatimageContextMenu->addAction (a);
1640 floatimageContextMenu->addSeparator();
1641 actionCopy->addTo( floatimageContextMenu );
1642 actionCut->addTo( floatimageContextMenu );
1644 floatimageContextMenu->addSeparator();
1645 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1648 // Context menu for canvas
1649 canvasContextMenu =new QMenu (this);
1650 actionAddMapCenter->addTo( canvasContextMenu );
1651 actionMapInfo->addTo( canvasContextMenu );
1652 canvasContextMenu->insertSeparator();
1653 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1654 canvasContextMenu->insertSeparator();
1655 actionFormatLinkColorHint->addTo( canvasContextMenu );
1656 actionFormatLinkColor->addTo( canvasContextMenu );
1657 actionFormatSelectionColor->addTo( canvasContextMenu );
1658 actionFormatBackColor->addTo( canvasContextMenu );
1659 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1661 // Menu for last opened files
1663 for (int i = 0; i < MaxRecentFiles; ++i)
1665 recentFileActions[i] = new QAction(this);
1666 recentFileActions[i]->setVisible(false);
1667 fileLastMapsMenu->addAction(recentFileActions[i]);
1668 connect(recentFileActions[i], SIGNAL(triggered()),
1669 this, SLOT(fileLoadRecent()));
1671 setupRecentMapsMenu();
1674 void Main::setupRecentMapsMenu()
1676 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1678 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1680 for (int i = 0; i < numRecentFiles; ++i) {
1681 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1682 recentFileActions[i]->setText(text);
1683 recentFileActions[i]->setData(files[i]);
1684 recentFileActions[i]->setVisible(true);
1686 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1687 recentFileActions[j]->setVisible(false);
1690 void Main::setupMacros()
1692 for (int i = 0; i <= 11; i++)
1694 macroActions[i] = new QAction(this);
1695 macroActions[i]->setData(i);
1696 addAction (macroActions[i]);
1697 connect(macroActions[i], SIGNAL(triggered()),
1698 this, SLOT(callMacro()));
1700 macroActions[0]->setShortcut ( Qt::Key_F1 );
1701 macroActions[1]->setShortcut ( Qt::Key_F2 );
1702 macroActions[2]->setShortcut ( Qt::Key_F3 );
1703 macroActions[3]->setShortcut ( Qt::Key_F4 );
1704 macroActions[4]->setShortcut ( Qt::Key_F5 );
1705 macroActions[5]->setShortcut ( Qt::Key_F6 );
1706 macroActions[6]->setShortcut ( Qt::Key_F7 );
1707 macroActions[7]->setShortcut ( Qt::Key_F8 );
1708 macroActions[8]->setShortcut ( Qt::Key_F9 );
1709 macroActions[9]->setShortcut ( Qt::Key_F10 );
1710 macroActions[10]->setShortcut ( Qt::Key_F11 );
1711 macroActions[11]->setShortcut ( Qt::Key_F12 );
1714 void Main::hideEvent (QHideEvent * )
1716 if (!textEditor->isMinimized() ) textEditor->hide();
1719 void Main::showEvent (QShowEvent * )
1721 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1725 MapEditor* Main::currentMapEditor() const
1727 if ( tabWidget->currentPage())
1728 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1732 VymModel* Main::currentModel() const
1734 if ( tabWidget->currentPage())
1735 return vymViews.at(tabWidget->currentIndex())->getModel();
1740 void Main::editorChanged(QWidget *)
1742 // Unselect all possibly selected objects
1743 // (Important to update note editor)
1745 for (int i=0;i<=tabWidget->count() -1;i++)
1747 m= vymViews.at(i)->getModel();
1748 if (m) m->unselect();
1751 if (m) m->reselect();
1753 // Update actions to in menus and toolbars according to editor
1757 void Main::fileNew()
1759 VymModel *vm=new VymModel;
1761 /////////////////////////////////////
1762 // new ModelTest(vm, this); //FIXME-3
1763 /////////////////////////////////////
1765 VymView *vv=new VymView (vm);
1766 vymViews.append (vv);
1767 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1768 tabWidget->setCurrentIndex (vymViews.count() );
1771 // Create MapCenter for empty map
1775 // For the very first map we do not have flagrows yet...
1779 void Main::fileNewCopy()
1781 QString fn="unnamed";
1782 VymModel *srcModel=currentModel();
1787 VymModel *dstModel=vymViews.last()->getModel();
1788 dstModel->select("mc:");
1789 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1793 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1795 ErrorCode err=success;
1797 // fn is usually the archive, mapfile the file after uncompressing
1800 // Make fn absolute (needed for unzip)
1801 fn=QDir (fn).absPath();
1807 // Check, if map is already loaded
1809 while (i<=tabWidget->count() -1)
1811 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1813 // Already there, ask for confirmation
1814 QMessageBox mb( vymName,
1815 tr("The map %1\nis already opened."
1816 "Opening the same map in multiple editors may lead \n"
1817 "to confusion when finishing working with vym."
1818 "Do you want to").arg(fn),
1819 QMessageBox::Warning,
1820 QMessageBox::Yes | QMessageBox::Default,
1821 QMessageBox::Cancel | QMessageBox::Escape,
1822 QMessageBox::NoButton);
1823 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1824 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1827 case QMessageBox::Yes:
1828 // end loop and load anyway
1829 i=tabWidget->count();
1831 case QMessageBox::Cancel:
1841 int tabIndex=tabWidget->currentPageIndex();
1844 if ( !fn.isEmpty() )
1846 vm = currentModel();
1847 // Check first, if mapeditor exists
1848 // If it is not default AND we want a new map,
1849 // create a new mapeditor in a new tab
1850 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1853 VymView *vv=new VymView (vm);
1854 vymViews.append (vv);
1855 tabWidget->addTab (vv,fn);
1856 tabIndex=tabWidget->count()-1;
1857 tabWidget->setCurrentPage (tabIndex);
1861 // Check, if file exists (important for creating new files
1862 // from command line
1863 if (!QFile(fn).exists() )
1865 QMessageBox mb( vymName,
1866 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1867 QMessageBox::Question,
1869 QMessageBox::Cancel | QMessageBox::Default,
1870 QMessageBox::NoButton );
1872 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1873 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1876 case QMessageBox::Yes:
1878 currentMapEditor()->getModel()->setFilePath(fn);
1879 tabWidget->setTabText (tabIndex,
1880 currentMapEditor()->getModel()->getFileName() );
1881 statusBar()->message( "Created " + fn , statusbarTime );
1884 case QMessageBox::Cancel:
1885 // don't create new map
1886 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1893 //tabWidget->currentPage() won't be NULL here, because of above...
1894 tabWidget->setCurrentIndex (tabIndex);
1895 //FIXME-3 no me anymore... me->viewport()->setFocus();
1899 // Save existing filename in case we import
1900 QString fn_org=vm->getFilePath();
1902 // Finally load map into mapEditor
1903 vm->setFilePath (fn);
1904 err=vm->load(fn,lmode,ftype);
1906 // Restore old (maybe empty) filepath, if this is an import
1908 vm->setFilePath (fn_org);
1911 // Finally check for errors and go home
1914 if (lmode==NewMap) fileCloseMap();
1915 statusBar()->message( "Could not load " + fn, statusbarTime );
1920 vm->setFilePath (fn);
1921 tabWidget->setTabText (tabIndex, vm->getFileName());
1922 if (!isInTmpDir (fn))
1924 // Only append to lastMaps if not loaded from a tmpDir
1925 // e.g. imported bookmarks are in a tmpDir
1926 addRecentMap(vm->getFilePath() );
1928 actionFilePrint->setEnabled (true);
1930 statusBar()->message( "Loaded " + fn, statusbarTime );
1937 void Main::fileLoad(const LoadMode &lmode)
1939 QStringList filters;
1940 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1941 QFileDialog *fd=new QFileDialog( this);
1942 fd->setDir (lastFileDir);
1943 fd->setFileMode (QFileDialog::ExistingFiles);
1944 fd->setFilters (filters);
1948 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1951 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1954 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1960 if ( fd->exec() == QDialog::Accepted )
1962 lastFileDir=fd->directory().path();
1963 QStringList flist = fd->selectedFiles();
1964 QStringList::Iterator it = flist.begin();
1965 while( it != flist.end() )
1968 fileLoad(*it, lmode);
1975 void Main::fileLoad()
1980 void Main::fileLoadRecent()
1982 QAction *action = qobject_cast<QAction *>(sender());
1984 fileLoad (action->data().toString(), NewMap);
1987 void Main::addRecentMap (const QString &fileName)
1990 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1991 files.removeAll(fileName);
1992 files.prepend(fileName);
1993 while (files.size() > MaxRecentFiles)
1996 settings.setValue("/mainwindow/recentFileList", files);
1998 setupRecentMapsMenu();
2001 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2005 if ( m->getFilePath().isEmpty() )
2007 // We have no filepath yet,
2008 // call fileSaveAs() now, this will call fileSave()
2010 // First switch to editor
2011 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2012 fileSaveAs(savemode);
2015 if (m->save (savemode)==success)
2017 statusBar()->message(
2018 tr("Saved %1").arg(m->getFilePath()),
2020 addRecentMap (m->getFilePath() );
2022 statusBar()->message(
2023 tr("Couldn't save ").arg(m->getFilePath()),
2027 void Main::fileSave()
2029 fileSave (currentModel(), CompleteMap);
2032 void Main::fileSave(VymModel *m)
2034 fileSave (m,CompleteMap);
2037 void Main::fileSaveAs(const SaveMode& savemode)
2041 if (currentMapEditor())
2043 if (savemode==CompleteMap)
2044 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2046 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2047 if ( !fn.isEmpty() )
2049 // Check for existing file
2050 if (QFile (fn).exists())
2052 QMessageBox mb( vymName,
2053 tr("The file %1\nexists already. Do you want to").arg(fn),
2054 QMessageBox::Warning,
2055 QMessageBox::Yes | QMessageBox::Default,
2056 QMessageBox::Cancel | QMessageBox::Escape,
2057 QMessageBox::NoButton);
2058 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2059 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2062 case QMessageBox::Yes:
2065 case QMessageBox::Cancel:
2072 // New file, add extension to filename, if missing
2073 // This is always .vym or .vyp, depending on savemode
2074 if (savemode==CompleteMap)
2076 if (!fn.contains (".vym") && !fn.contains (".xml"))
2080 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2089 VymModel *m=currentModel();
2091 fileSave(m, savemode);
2093 // Set name of tab, assuming current tab is the one we just saved
2094 if (savemode==CompleteMap)
2095 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2101 void Main::fileSaveAs()
2103 fileSaveAs (CompleteMap);
2106 void Main::fileImportKDE3Bookmarks()
2108 ImportKDE3Bookmarks im;
2110 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2111 currentMapEditor()->getModel()->setFilePath ("");
2114 void Main::fileImportKDE4Bookmarks()
2116 ImportKDE4Bookmarks im;
2118 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2119 currentMapEditor()->getModel()->setFilePath ("");
2122 void Main::fileImportFirefoxBookmarks()
2124 Q3FileDialog *fd=new Q3FileDialog( this);
2125 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2126 fd->setMode (Q3FileDialog::ExistingFiles);
2127 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2128 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2131 if ( fd->exec() == QDialog::Accepted )
2133 ImportFirefoxBookmarks im;
2134 QStringList flist = fd->selectedFiles();
2135 QStringList::Iterator it = flist.begin();
2136 while( it != flist.end() )
2139 if (im.transform() &&
2140 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2141 currentMapEditor() )
2142 currentMapEditor()->getModel()->setFilePath ("");
2149 void Main::fileImportFreemind()
2151 QStringList filters;
2152 filters <<"Freemind map (*.mm)"<<"All files (*)";
2153 QFileDialog *fd=new QFileDialog( this);
2154 fd->setDir (lastFileDir);
2155 fd->setFileMode (QFileDialog::ExistingFiles);
2156 fd->setFilters (filters);
2157 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2161 if ( fd->exec() == QDialog::Accepted )
2163 lastFileDir=fd->directory().path();
2164 QStringList flist = fd->selectedFiles();
2165 QStringList::Iterator it = flist.begin();
2166 while( it != flist.end() )
2169 if ( fileLoad (fn,NewMap, FreemindMap) )
2171 currentMapEditor()->getModel()->setFilePath ("");
2180 void Main::fileImportMM()
2184 Q3FileDialog *fd=new Q3FileDialog( this);
2185 fd->setDir (lastFileDir);
2186 fd->setMode (Q3FileDialog::ExistingFiles);
2187 fd->addFilter ("Mind Manager (*.mmap)");
2188 fd->setCaption(tr("Import")+" "+"Mind Manager");
2191 if ( fd->exec() == QDialog::Accepted )
2193 lastFileDir=fd->dirPath();
2194 QStringList flist = fd->selectedFiles();
2195 QStringList::Iterator it = flist.begin();
2196 while( it != flist.end() )
2199 if (im.transform() &&
2200 success==fileLoad (im.getTransformedFile(),NewMap) &&
2201 currentMapEditor() )
2202 currentMapEditor()->getModel()->setFilePath ("");
2209 void Main::fileImportDir()
2211 VymModel *m=currentModel();
2212 if (m) m->importDir();
2215 void Main::fileExportXML()
2217 VymModel *m=currentModel();
2218 if (m) m->exportXML();
2222 void Main::fileExportXHTML()
2224 VymModel *m=currentModel();
2225 if (m) m->exportXHTML();
2228 void Main::fileExportImage()
2230 VymModel *m=currentModel();
2231 if (m) m->exportImage();
2234 void Main::fileExportAO()
2236 VymModel *m=currentModel();
2237 if (m) m->exportAO();
2240 void Main::fileExportASCII()
2242 VymModel *m=currentModel();
2243 if (m) m->exportASCII();
2246 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2248 VymModel *m=currentModel();
2253 ex.addFilter ("CSV (*.csv)");
2254 ex.setDir(lastImageDir);
2255 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2256 if (ex.execDialog() )
2258 m->setExportMode(true);
2260 m->setExportMode(false);
2265 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2267 VymModel *m=currentModel();
2272 ex.addFilter ("Tex (*.tex)");
2273 ex.setDir(lastImageDir);
2274 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2275 if (ex.execDialog() )
2277 m->setExportMode(true);
2279 m->setExportMode(false);
2284 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2286 ExportKDE3Bookmarks ex;
2287 VymModel *m=currentModel();
2295 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2297 ExportKDE4Bookmarks ex;
2298 VymModel *m=currentModel();
2306 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2308 ExportTaskjuggler ex;
2309 VymModel *m=currentModel();
2313 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2314 ex.setDir(lastImageDir);
2315 ex.addFilter ("Taskjuggler (*.tjp)");
2316 if (ex.execDialog() )
2318 m->setExportMode(true);
2320 m->setExportMode(false);
2325 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2327 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2328 // TODO add preview in dialog
2329 //ImagePreview *p =new ImagePreview (fd);
2330 //fd->setContentsPreviewEnabled( TRUE );
2331 //fd->setContentsPreview( p, p );
2332 //fd->setPreviewMode( QFileDialog::Contents );
2333 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2334 fd->setDir (QDir().current());
2335 if (fd->foundConfig())
2339 if ( fd->exec() == QDialog::Accepted )
2341 QString fn=fd->selectedFile();
2342 if (!fn.contains (".odp"))
2345 //lastImageDir=fn.left(fn.findRev ("/"));
2346 VymModel *m=currentModel();
2347 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2351 QMessageBox::warning(0,
2353 tr("Couldn't find configuration for export to Open Office\n"));
2357 void Main::fileCloseMap()
2359 VymModel *m=currentModel();
2362 if (m->hasChanged())
2364 QMessageBox mb( vymName,
2365 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2366 QMessageBox::Warning,
2367 QMessageBox::Yes | QMessageBox::Default,
2369 QMessageBox::Cancel | QMessageBox::Escape );
2370 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2371 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2374 case QMessageBox::Yes:
2376 fileSave(m, CompleteMap);
2378 case QMessageBox::No:
2379 // close without saving
2381 case QMessageBox::Cancel:
2386 // And here comes the segfault, because removeTab triggers
2387 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2388 vymViews.removeAt (tabWidget->currentIndex() );
2389 tabWidget->removeTab (tabWidget->currentIndex() );
2391 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2392 // Better would be delete (me), but then we could have a Qt error:
2393 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2394 // So we only remove data now and call deconstructor when vym closes later
2395 // this needs to be moved to vymview... me->clear();
2396 // some model->clear is needed to free up memory ...
2398 delete (m->getMapEditor());
2405 void Main::filePrint()
2407 if (currentMapEditor())
2408 currentMapEditor()->print();
2411 void Main::fileExitVYM()
2413 // Check if one or more editors have changed
2415 for (i=0;i<=vymViews.count() -1;i++)
2417 // If something changed, ask what to do
2418 if (vymViews.at(i)->getModel()->hasChanged())
2420 tabWidget->setCurrentPage(i);
2421 QMessageBox mb( vymName,
2422 tr("This map is not saved yet. Do you want to"),
2423 QMessageBox::Warning,
2424 QMessageBox::Yes | QMessageBox::Default,
2426 QMessageBox::Cancel | QMessageBox::Escape );
2427 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2428 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2431 mb.setActiveWindow();
2432 switch( mb.exec() ) {
2433 case QMessageBox::Yes:
2434 // save (the changed editors) and exit
2435 fileSave(currentModel(), CompleteMap);
2437 case QMessageBox::No:
2438 // exit without saving
2440 case QMessageBox::Cancel:
2441 // don't save and don't exit
2445 } // loop over all MEs
2449 void Main::editUndo()
2451 VymModel *m=currentModel();
2455 void Main::editRedo()
2457 VymModel *m=currentModel();
2461 void Main::gotoHistoryStep (int i)
2463 VymModel *m=currentModel();
2464 if (m) m->gotoHistoryStep(i);
2467 void Main::editCopy()
2469 VymModel *m=currentModel();
2473 void Main::editPaste()
2475 VymModel *m=currentModel();
2479 void Main::editCut()
2481 VymModel *m=currentModel();
2485 void Main::editOpenFindWidget()
2487 VymModel *m=currentModel();
2488 if (m) m->emitShowFindWidget();
2491 void Main::openTabs(QStringList urls)
2493 if (!urls.isEmpty())
2497 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2498 if (*browserPID==0) //FIXME-2 need to check if browser is really still there instead of this
2500 QString u=urls.takeFirst();
2502 QString workDir=QDir::currentDirPath();
2503 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2505 // try to set path to browser
2506 QMessageBox::warning(0,
2508 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2509 tr("Please use Settings->")+tr("Set application to open an URL"));
2512 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2513 #if defined(Q_OS_WIN32)
2514 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2515 this->thread()->wait(3000);
2517 sleep (3); //FIXME-3 needed?
2521 if (browser.contains("konqueror"))
2523 for (int i=0; i<urls.size(); i++)
2526 // Try to open new tab in existing konqueror started previously by vym
2530 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2531 "konqueror-mainwindow#1"<<
2535 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2536 "/konqueror/MainWindow_1"<<
2540 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2541 if (!QProcess::startDetached ("qdbus",args))
2545 QMessageBox::warning(0,
2547 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2549 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2551 for (int i=0; i<urls.size(); i++)
2553 // Try to open new tab in firefox
2554 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2555 if (!QProcess::startDetached (browser,args))
2559 QMessageBox::warning(0,
2561 tr("Couldn't start %1 to open a new tab").arg(browser));
2564 QMessageBox::warning(0,
2566 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2570 void Main::editOpenURL()
2573 VymModel *m=currentModel();
2576 QString url=m->getURL();
2578 if (url=="") return;
2579 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2581 QString workDir=QDir::currentDirPath();
2582 if (!procBrowser->startDetached(browser,args))
2584 // try to set path to browser
2585 QMessageBox::warning(0,
2587 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2588 tr("Please use Settings->")+tr("Set application to open an URL"));
2593 void Main::editOpenURLTab()
2595 VymModel *m=currentModel();
2599 urls.append(m->getURL());
2603 void Main::editOpenMultipleURLTabs()
2605 VymModel *m=currentModel();
2615 void Main::editURL()
2617 VymModel *m=currentModel();
2618 if (m) m->editURL();
2621 void Main::editLocalURL()
2623 VymModel *m=currentModel();
2624 if (m) m->editLocalURL();
2627 void Main::editHeading2URL()
2629 VymModel *m=currentModel();
2630 if (m) m->editHeading2URL();
2633 void Main::editBugzilla2URL()
2635 VymModel *m=currentModel();
2636 if (m) m->editBugzilla2URL();
2639 void Main::editFATE2URL()
2641 VymModel *m=currentModel();
2642 if (m) m->editFATE2URL();
2645 void Main::editHeadingFinished(VymModel *m)
2649 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2650 !prevSelection.isEmpty())
2651 m->select(prevSelection);
2656 void Main::openVymLinks(const QStringList &vl)
2658 for (int j=0; j<vl.size(); j++)
2660 // compare path with already loaded maps
2663 for (i=0;i<=vymViews.count() -1;i++)
2665 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2674 if (!QFile(vl.at(j)).exists() )
2675 QMessageBox::critical( 0, tr( "Critical Error" ),
2676 tr("Couldn't open map %1").arg(vl.at(j)));
2679 fileLoad (vl.at(j), NewMap);
2680 tabWidget->setCurrentIndex (tabWidget->count()-1);
2683 // Go to tab containing the map
2684 tabWidget->setCurrentIndex (index);
2688 void Main::editOpenVymLink()
2690 VymModel *m=currentModel();
2694 vl.append(m->getVymLink());
2699 void Main::editOpenMultipleVymLinks()
2701 QString currentVymLink;
2702 VymModel *m=currentModel();
2705 QStringList vl=m->getVymLinks();
2710 void Main::editVymLink()
2712 VymModel *m=currentModel();
2717 void Main::editDeleteVymLink()
2719 VymModel *m=currentModel();
2720 if (m) m->deleteVymLink();
2723 void Main::editToggleHideExport()
2725 VymModel *m=currentModel();
2726 if (m) m->toggleHideExport();
2729 void Main::editAddTimestamp()
2731 VymModel *m=currentModel();
2732 if (m) m->addTimestamp();
2735 void Main::editMapInfo()
2737 VymModel *m=currentModel();
2740 ExtraInfoDialog dia;
2741 dia.setMapName (m->getFileName() );
2742 dia.setAuthor (m->getAuthor() );
2743 dia.setComment(m->getComment() );
2747 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2753 BranchItem *cur=NULL;
2754 BranchItem *prev=NULL;
2755 m->nextBranch(cur,prev);
2758 if (!cur->getNote().isEmpty() ) n++;
2759 f+= cur->imageCount();
2761 xl+=cur->xlinkCount();
2762 m->nextBranch(cur,prev);
2765 stats+=QString ("%1 xLinks \n").arg (xl,6);
2766 stats+=QString ("%1 notes\n").arg (n,6);
2767 stats+=QString ("%1 images\n").arg (f,6);
2768 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2769 dia.setStats (stats);
2771 // Finally show dialog
2772 if (dia.exec() == QDialog::Accepted)
2774 m->setAuthor (dia.getAuthor() );
2775 m->setComment (dia.getComment() );
2779 void Main::editMoveUp()
2781 VymModel *m=currentModel();
2785 void Main::editMoveDown()
2787 VymModel *m=currentModel();
2788 if (m) m->moveDown();
2791 void Main::editDetach()
2793 VymModel *m=currentModel();
2797 void Main::editSortChildren()
2799 VymModel *m=currentModel();
2800 if (m) m->sortChildren();
2803 void Main::editToggleScroll()
2805 VymModel *m=currentModel();
2806 if (m) m->toggleScroll();
2809 void Main::editExpandAll()
2811 VymModel *m=currentModel();
2812 if (m) m->emitExpandAll();
2815 void Main::editExpandOneLevel()
2817 VymModel *m=currentModel();
2818 if (m) m->emitExpandOneLevel();
2821 void Main::editCollapseOneLevel()
2823 VymModel *m=currentModel();
2824 if (m) m->emitCollapseOneLevel();
2827 void Main::editUnscrollChildren()
2829 VymModel *m=currentModel();
2830 if (m) m->unscrollChildren();
2833 void Main::editAddAttribute()
2835 VymModel *m=currentModel();
2836 if (m) m->addAttribute();
2839 void Main::editAddMapCenter()
2841 VymModel *m=currentModel();
2842 if (m) m->addMapCenter ();
2845 void Main::editNewBranch()
2847 VymModel *m=currentModel();
2850 BranchItem *bi=m->addNewBranch();
2853 if (actionSettingsAutoEditNewBranch->isOn()
2854 && !actionSettingsAutoSelectNewBranch->isOn() )
2855 prevSelection=m->getSelectString();
2857 prevSelection=QString();
2859 if (actionSettingsAutoSelectNewBranch->isOn()
2860 || actionSettingsAutoEditNewBranch->isOn())
2863 if (actionSettingsAutoEditNewBranch->isOn())
2864 currentMapEditor()->editHeading();
2869 void Main::editNewBranchBefore()
2871 VymModel *m=currentModel();
2874 BranchItem *bi=m->addNewBranchBefore();
2881 if (actionSettingsAutoEditNewBranch->isOn())
2883 if (!actionSettingsAutoSelectNewBranch->isOn())
2884 prevSelection=m->getSelectString(bi);
2885 currentMapEditor()->editHeading();
2890 void Main::editNewBranchAbove()
2892 VymModel *m=currentModel();
2895 BranchItem *bi=m->addNewBranch (-1);
2903 if (actionSettingsAutoEditNewBranch->isOn())
2905 if (!actionSettingsAutoSelectNewBranch->isOn())
2906 prevSelection=m->getSelectString (bi);
2907 currentMapEditor()->editHeading();
2912 void Main::editNewBranchBelow()
2914 VymModel *m=currentModel();
2917 BranchItem *bi=m->addNewBranch (1);
2924 if (actionSettingsAutoEditNewBranch->isOn())
2926 if (!actionSettingsAutoSelectNewBranch->isOn())
2927 prevSelection=m->getSelectString(bi);
2928 currentMapEditor()->editHeading();
2933 void Main::editImportAdd()
2935 fileLoad (ImportAdd);
2938 void Main::editImportReplace()
2940 fileLoad (ImportReplace);
2943 void Main::editSaveBranch()
2945 fileSaveAs (PartOfMap);
2948 void Main::editDeleteKeepChildren()
2950 VymModel *m=currentModel();
2951 if (m) m->deleteKeepChildren();
2954 void Main::editDeleteChildren()
2956 VymModel *m=currentModel();
2957 if (m) m->deleteChildren();
2960 void Main::editDeleteSelection()
2962 VymModel *m=currentModel();
2963 if (m && actionSettingsUseDelKey->isOn())
2964 m->deleteSelection();
2967 void Main::editLoadImage()
2969 VymModel *m=currentModel();
2970 if (m) m->loadFloatImage();
2973 void Main::editSaveImage()
2975 VymModel *m=currentModel();
2976 if (m) m->saveFloatImage();
2979 void Main::editEditXLink(QAction *a)
2981 VymModel *m=currentModel();
2983 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2986 void Main::formatSelectColor()
2988 QColor col = QColorDialog::getColor((currentColor ), this );
2989 if ( !col.isValid() ) return;
2990 colorChanged( col );
2993 void Main::formatPickColor()
2995 VymModel *m=currentModel();
2997 colorChanged( m->getCurrentHeadingColor() );
3000 void Main::colorChanged(QColor c)
3002 QPixmap pix( 16, 16 );
3004 actionFormatColor->setIconSet( pix );
3008 void Main::formatColorBranch()
3010 VymModel *m=currentModel();
3011 if (m) m->colorBranch(currentColor);
3014 void Main::formatColorSubtree()
3016 VymModel *m=currentModel();
3017 if (m) m->colorSubtree (currentColor);
3020 void Main::formatLinkStyleLine()
3022 VymModel *m=currentModel();
3025 m->setMapLinkStyle("StyleLine");
3026 actionFormatLinkStyleLine->setChecked(true);
3030 void Main::formatLinkStyleParabel()
3032 VymModel *m=currentModel();
3035 m->setMapLinkStyle("StyleParabel");
3036 actionFormatLinkStyleParabel->setChecked(true);
3040 void Main::formatLinkStylePolyLine()
3042 VymModel *m=currentModel();
3045 m->setMapLinkStyle("StylePolyLine");
3046 actionFormatLinkStylePolyLine->setChecked(true);
3050 void Main::formatLinkStylePolyParabel()
3052 VymModel *m=currentModel();
3055 m->setMapLinkStyle("StylePolyParabel");
3056 actionFormatLinkStylePolyParabel->setChecked(true);
3060 void Main::formatSelectBackColor()
3062 VymModel *m=currentModel();
3063 if (m) m->selectMapBackgroundColor();
3066 void Main::formatSelectBackImage()
3068 VymModel *m=currentModel();
3070 m->selectMapBackgroundImage();
3073 void Main::formatSelectLinkColor()
3075 VymModel *m=currentModel();
3078 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3079 m->setMapDefLinkColor( col );
3083 void Main::formatSelectSelectionColor()
3085 VymModel *m=currentModel();
3088 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3089 m->setSelectionColor (col);
3094 void Main::formatToggleLinkColorHint()
3096 VymModel *m=currentModel();
3097 if (m) m->toggleMapLinkColorHint();
3101 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3103 VymModel *m=currentModel();
3105 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3108 void Main::viewZoomReset()
3110 MapEditor *me=currentMapEditor();
3111 if (me) me->setZoomFactorTarget (1);
3114 void Main::viewZoomIn()
3116 MapEditor *me=currentMapEditor();
3117 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3120 void Main::viewZoomOut()
3122 MapEditor *me=currentMapEditor();
3123 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3126 void Main::viewCenter()
3128 VymModel *m=currentModel();
3129 if (m) m->emitShowSelection();
3132 void Main::networkStartServer()
3134 VymModel *m=currentModel();
3135 if (m) m->newServer();
3138 void Main::networkConnect()
3140 VymModel *m=currentModel();
3141 if (m) m->connectToServer();
3144 bool Main::settingsPDF()
3146 // Default browser is set in constructor
3148 QString text = QInputDialog::getText(
3149 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3150 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3152 settings.setValue ("/mainwindow/readerPDF",text);
3157 bool Main::settingsURL()
3159 // Default browser is set in constructor
3161 QString text = QInputDialog::getText(
3162 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3163 settings.value("/mainwindow/readerURL").toString()
3166 settings.setValue ("/mainwindow/readerURL",text);
3170 void Main::settingsMacroDir()
3172 QDir defdir(vymBaseDir.path() + "/macros");
3173 if (!defdir.exists())
3175 QDir dir=QFileDialog::getExistingDirectory (
3177 tr ("Directory with vym macros:"),
3178 settings.value ("/macros/macroDir",defdir.path()).toString()
3181 settings.setValue ("/macros/macroDir",dir.absolutePath());
3184 void Main::settingsUndoLevels()
3187 int i = QInputDialog::getInteger(
3189 tr("QInputDialog::getInteger()"),
3190 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3193 settings.setValue ("/mapeditor/stepsTotal",i);
3194 QMessageBox::information( this, tr( "VYM -Information:" ),
3195 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3199 void Main::settingsAutosaveToggle()
3201 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3204 void Main::settingsAutosaveTime()
3207 int i = QInputDialog::getInteger(
3209 tr("QInputDialog::getInteger()"),
3210 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3212 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3215 void Main::settingsWriteBackupFileToggle()
3217 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3220 void Main::settingsToggleAnimation()
3222 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3225 void Main::settingsToggleDelKey()
3227 if (actionSettingsUseDelKey->isOn())
3229 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3232 actionDelete->setAccel (QKeySequence (""));
3236 void Main::windowToggleNoteEditor()
3238 if (textEditor->isVisible() )
3239 windowHideNoteEditor();
3241 windowShowNoteEditor();
3244 void Main::windowToggleHistory()
3246 if (historyWindow->isVisible())
3247 historyWindow->hide();
3249 historyWindow->show();
3253 void Main::windowToggleProperty()
3255 if (branchPropertyWindow->isVisible())
3256 branchPropertyWindow->hide();
3258 branchPropertyWindow->show();
3259 branchPropertyWindow->setModel (currentModel() );
3262 void Main::windowToggleAntiAlias()
3264 bool b=actionViewToggleAntiAlias->isOn();
3266 for (int i=0;i<vymViews.count();i++)
3268 me=vymViews.at(i)->getMapEditor();
3269 if (me) me->setAntiAlias(b);
3274 bool Main::isAliased()
3276 return actionViewToggleAntiAlias->isOn();
3279 bool Main::hasSmoothPixmapTransform()
3281 return actionViewToggleSmoothPixmapTransform->isOn();
3284 void Main::windowToggleSmoothPixmap()
3286 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3288 for (int i=0;i<vymViews.count();i++)
3291 me=vymViews.at(i)->getMapEditor();
3292 if (me) me->setSmoothPixmap(b);
3296 void Main::updateHistory(SimpleSettings &undoSet)
3298 historyWindow->update (undoSet);
3301 void Main::updateNoteFlag()
3303 // this slot is connected to TextEditor::textHasChanged()
3305 VymModel *m=currentModel();
3306 if (m) m->updateNoteFlag();
3309 void Main::updateNoteEditor(QModelIndex index )
3311 cout << QObject::sender();
3312 QObject *obj=QObject::sender();
3313 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3314 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3315 //cout << "Main::updateNoteEditor model="<<sender();
3316 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3317 textEditor->setNote (ti->getNoteObj() );
3320 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3322 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3324 if (model && model==currentModel() )
3328 if (!oldsel.indexes().isEmpty() )
3330 ti=model->getItem(oldsel.indexes().first());
3332 // Don't update note if both treeItem and textEditor are empty
3333 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3334 // ti->setNoteObj (textEditor->getNoteObj(),false );
3336 if (!newsel.indexes().isEmpty() )
3338 ti=model->getItem(newsel.indexes().first());
3339 if (!ti->hasEmptyNote() )
3340 textEditor->setNote(ti->getNoteObj() );
3342 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3344 // Show URL and link in statusbar
3346 QString s=ti->getURL();
3347 if (!s.isEmpty() ) status+="URL: "+s+" ";
3349 if (!s.isEmpty() ) status+="Link: "+s;
3350 if (!status.isEmpty() ) statusMessage (status);
3353 textEditor->setInactive();
3359 void Main::updateActions()
3361 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3362 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3363 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3364 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3366 VymModel *m =currentModel();
3370 actionFilePrint->setEnabled (true);
3372 // Link style in context menu
3373 switch (m->getMapLinkStyle())
3375 case LinkableMapObj::Line:
3376 actionFormatLinkStyleLine->setChecked(true);
3378 case LinkableMapObj::Parabel:
3379 actionFormatLinkStyleParabel->setChecked(true);
3381 case LinkableMapObj::PolyLine:
3382 actionFormatLinkStylePolyLine->setChecked(true);
3384 case LinkableMapObj::PolyParabel:
3385 actionFormatLinkStylePolyParabel->setChecked(true);
3392 QPixmap pix( 16, 16 );
3393 pix.fill( m->getMapBackgroundColor() );
3394 actionFormatBackColor->setIconSet( pix );
3395 pix.fill( m->getSelectionColor() );
3396 actionFormatSelectionColor->setIconSet( pix );
3397 pix.fill( m->getMapDefLinkColor() );
3398 actionFormatLinkColor->setIconSet( pix );
3401 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3404 // Expanding/collapsing
3405 actionExpandAll->setEnabled (true);
3406 actionExpandOneLevel->setEnabled (true);
3407 actionCollapseOneLevel->setEnabled (true);
3411 actionFilePrint->setEnabled (false);
3413 // Expanding/collapsing
3414 actionExpandAll->setEnabled (false);
3415 actionExpandOneLevel->setEnabled (false);
3416 actionCollapseOneLevel->setEnabled (false);
3419 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3420 actionFormatLinkColorHint->setChecked(true);
3422 actionFormatLinkColorHint->setChecked(false);
3425 if (m && m->hasChanged() )
3426 actionFileSave->setEnabled( true);
3428 actionFileSave->setEnabled( false);
3429 if (m && m->isUndoAvailable())
3430 actionUndo->setEnabled( true);
3432 actionUndo->setEnabled( false);
3434 if (m && m->isRedoAvailable())
3435 actionRedo->setEnabled( true);
3437 actionRedo->setEnabled( false);
3441 TreeItem *selti=m->getSelectedItem();
3442 BranchItem *selbi=m->getSelectedBranch();
3445 if (selbi || selti->getType()==TreeItem::Image)
3447 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3448 actionFormatHideLinkUnselected->setEnabled (true);
3453 // Take care of xlinks
3454 branchXLinksContextMenuEdit->clear();
3455 if (selbi->xlinkCount()>0)
3459 for (int i=0; i<selbi->xlinkCount();++i)
3461 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3465 if (s.length()>xLinkMenuWidth)
3466 s=s.left(xLinkMenuWidth)+"...";
3467 branchXLinksContextMenuEdit->addAction (s);
3472 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3475 actionToggleScroll->setEnabled (true);
3476 if ( selbi->isScrolled() )
3477 actionToggleScroll->setChecked(true);
3479 actionToggleScroll->setChecked(false);
3481 if ( selti->getURL().isEmpty() )
3483 actionOpenURL->setEnabled (false);
3484 actionOpenURLTab->setEnabled (false);
3488 actionOpenURL->setEnabled (true);
3489 actionOpenURLTab->setEnabled (true);
3491 if ( selti->getVymLink().isEmpty() )
3493 actionOpenVymLink->setEnabled (false);
3494 actionDeleteVymLink->setEnabled (false);
3497 actionOpenVymLink->setEnabled (true);
3498 actionDeleteVymLink->setEnabled (true);
3501 if (selbi->canMoveUp())
3502 actionMoveUp->setEnabled (true);
3504 actionMoveUp->setEnabled (false);
3505 if (selbi->canMoveDown())
3506 actionMoveDown->setEnabled (true);
3508 actionMoveDown->setEnabled (false);
3510 actionSortChildren->setEnabled (true);
3512 actionToggleHideExport->setEnabled (true);
3513 actionToggleHideExport->setChecked (selbi->hideInExport() );
3515 actionCopy->setEnabled (true);
3516 actionCut->setEnabled (true);
3517 if (!clipboardEmpty)
3518 actionPaste->setEnabled (true);
3520 actionPaste->setEnabled (false);
3521 for (int i=0; i<actionListBranches.size(); ++i)
3522 actionListBranches.at(i)->setEnabled(true);
3523 actionDelete->setEnabled (true);
3525 if ( selti->getType()==TreeItem::Image)
3527 actionOpenURL->setEnabled (false);
3528 actionOpenVymLink->setEnabled (false);
3529 actionDeleteVymLink->setEnabled (false);
3530 actionToggleHideExport->setEnabled (true);
3531 actionToggleHideExport->setChecked (selti->hideInExport() );
3534 actionCopy->setEnabled (true);
3535 actionCut->setEnabled (true);
3536 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3537 for (int i=0; i<actionListBranches.size(); ++i)
3538 actionListBranches.at(i)->setEnabled(false);
3539 actionDelete->setEnabled (true);
3540 actionMoveUp->setEnabled (false);
3541 actionMoveDown->setEnabled (false);
3546 actionCopy->setEnabled (false);
3547 actionCut->setEnabled (false);
3548 actionPaste->setEnabled (false);
3549 for (int i=0; i<actionListBranches.size(); ++i)
3550 actionListBranches.at(i)->setEnabled(false);
3552 actionToggleScroll->setEnabled (false);
3553 actionOpenURL->setEnabled (false);
3554 actionOpenVymLink->setEnabled (false);
3555 actionDeleteVymLink->setEnabled (false);
3556 actionHeading2URL->setEnabled (false);
3557 actionDelete->setEnabled (false);
3558 actionMoveUp->setEnabled (false);
3559 actionMoveDown->setEnabled (false);
3560 actionFormatHideLinkUnselected->setEnabled (false);
3561 actionSortChildren->setEnabled (false);
3562 actionToggleHideExport->setEnabled (false);
3567 Main::ModMode Main::getModMode()
3569 if (actionModModeColor->isOn()) return ModModeColor;
3570 if (actionModModeCopy->isOn()) return ModModeCopy;
3571 if (actionModModeXLink->isOn()) return ModModeXLink;
3575 bool Main::autoEditNewBranch()
3577 return actionSettingsAutoEditNewBranch->isOn();
3580 bool Main::autoSelectNewBranch()
3582 return actionSettingsAutoSelectNewBranch->isOn();
3585 void Main::windowShowNoteEditor()
3587 textEditor->setShowWithMain(true);
3589 actionViewToggleNoteEditor->setChecked (true);
3592 void Main::windowHideNoteEditor()
3594 textEditor->setShowWithMain(false);
3596 actionViewToggleNoteEditor->setChecked (false);
3599 void Main::setScript (const QString &script)
3601 scriptEditor->setScript (script);
3604 void Main::runScript (const QString &script)
3606 VymModel *m=currentModel();
3607 if (m) m->runScript (script);
3610 void Main::runScriptEverywhere (const QString &script)
3613 for (int i=0;i<=tabWidget->count() -1;i++)
3615 me=(MapEditor*)tabWidget->page(i);
3616 if (me) me->getModel()->runScript (script);
3620 void Main::windowNextEditor()
3622 if (tabWidget->currentIndex() < tabWidget->count())
3623 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3626 void Main::windowPreviousEditor()
3628 if (tabWidget->currentIndex() >0)
3629 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3632 void Main::standardFlagChanged()
3636 if ( actionSettingsUseFlagGroups->isOn() )
3637 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3639 currentModel()->toggleStandardFlag(sender()->name());
3644 void Main::testFunction1()
3646 if (!currentMapEditor()) return;
3647 currentMapEditor()->testFunction1();
3650 VymModel *m=currentModel();
3654 QString text = QInputDialog::getText(
3655 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3656 m->getSortFilter(), &ok, NULL);
3658 // user entered something and pressed OK
3659 m->setSortFilter (text);
3663 void Main::testFunction2()
3665 if (!currentMapEditor()) return;
3666 currentMapEditor()->testFunction2();
3669 void Main::testCommand()
3671 if (!currentMapEditor()) return;
3672 scriptEditor->show();
3675 QString com = QInputDialog::getText(
3676 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3677 if (ok) currentMapEditor()->parseAtom(com);
3681 void Main::helpDoc()
3683 QString locale = QLocale::system().name();
3685 if (locale.left(2)=="es")
3686 docname="vym_es.pdf";
3690 QStringList searchList;
3692 #if defined(Q_OS_MACX)
3693 searchList << "./vym.app/Contents/Resources/doc";
3694 #elif defined(Q_OS_WIN32)
3695 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3697 #if defined(VYM_DOCDIR)
3698 searchList << VYM_DOCDIR;
3700 // default path in SUSE LINUX
3701 searchList << "/usr/share/doc/packages/vym";
3704 searchList << "doc"; // relative path for easy testing in tarball
3705 searchList << "doc/tex"; // Easy testing working on vym.tex
3706 searchList << "/usr/share/doc/vym"; // Debian
3707 searchList << "/usr/share/doc/packages";// Knoppix
3711 for (int i=0; i<searchList.count(); ++i)
3713 docfile.setFileName(searchList.at(i)+"/"+docname);
3714 if (docfile.exists())
3723 QMessageBox::critical(0,
3724 tr("Critcal error"),
3725 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3730 Process *pdfProc = new Process();
3731 args << QDir::toNativeSeparators(docfile.fileName());
3733 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3736 QMessageBox::warning(0,
3738 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3739 tr("Please use Settings->")+tr("Set application to open PDF files"));
3746 void Main::helpDemo()
3748 QStringList filters;
3749 filters <<"VYM example map (*.vym)";
3750 QFileDialog *fd=new QFileDialog( this);
3751 #if defined(Q_OS_MACX)
3752 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3754 // default path in SUSE LINUX
3755 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3758 fd->setFileMode (QFileDialog::ExistingFiles);
3759 fd->setFilters (filters);
3760 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3764 if ( fd->exec() == QDialog::Accepted )
3766 lastFileDir=fd->directory().path();
3767 QStringList flist = fd->selectedFiles();
3768 QStringList::Iterator it = flist.begin();
3769 while( it != flist.end() )
3772 fileLoad(*it, NewMap);
3780 void Main::helpAbout()
3783 ad.setName ("aboutwindow");
3784 ad.setMinimumSize(500,500);
3785 ad.resize (QSize (500,500));
3789 void Main::helpAboutQT()
3791 QMessageBox::aboutQt( this, "Qt Application Example" );
3794 void Main::callMacro ()
3796 QAction *action = qobject_cast<QAction *>(sender());
3800 i=action->data().toInt();
3801 QString mDir (settings.value ("macros/macroDir").toString() );
3803 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3805 if ( !f.open( QIODevice::ReadOnly ) )
3807 QMessageBox::warning(0,
3809 tr("Couldn't find a macro at %1.\n").arg(fn)+
3810 tr("Please use Settings->")+tr("Set directory for vym macros"));
3814 QTextStream ts( &f );
3815 QString macro= ts.read();
3817 if (! macro.isEmpty())
3819 VymModel *m=currentModel();
3820 if (m) m->runScript(macro);