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);
1602 // Submenu for Links (URLs, vymLinks)
1603 branchLinksContextMenu =new QMenu (this);
1605 branchContextMenu->addSeparator();
1606 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1607 branchLinksContextMenu->addAction ( actionOpenURL );
1608 branchLinksContextMenu->addAction ( actionOpenURLTab );
1609 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1610 branchLinksContextMenu->addAction ( actionURL );
1611 branchLinksContextMenu->addAction ( actionLocalURL );
1612 branchLinksContextMenu->addAction ( actionHeading2URL );
1613 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1614 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1616 branchLinksContextMenu->addAction ( actionFATE2URL );
1618 branchLinksContextMenu->addSeparator();
1619 branchLinksContextMenu->addAction ( actionOpenVymLink );
1620 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1621 branchLinksContextMenu->addAction ( actionVymLink );
1622 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1625 // Context Menu for XLinks in a branch menu
1626 // This will be populated "on demand" in MapEditor::updateActions
1627 branchContextMenu->addSeparator();
1628 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1629 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1632 // Context menu for floatimage
1633 floatimageContextMenu =new QMenu (this);
1634 a= new QAction (tr ("Save image","Context action"),this);
1635 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1636 floatimageContextMenu->addAction (a);
1638 floatimageContextMenu->addSeparator();
1639 actionCopy->addTo( floatimageContextMenu );
1640 actionCut->addTo( floatimageContextMenu );
1642 floatimageContextMenu->addSeparator();
1643 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1646 // Context menu for canvas
1647 canvasContextMenu =new QMenu (this);
1648 actionAddMapCenter->addTo( canvasContextMenu );
1649 actionMapInfo->addTo( canvasContextMenu );
1650 canvasContextMenu->insertSeparator();
1651 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1652 canvasContextMenu->insertSeparator();
1653 actionFormatLinkColorHint->addTo( canvasContextMenu );
1654 actionFormatLinkColor->addTo( canvasContextMenu );
1655 actionFormatSelectionColor->addTo( canvasContextMenu );
1656 actionFormatBackColor->addTo( canvasContextMenu );
1657 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1659 // Menu for last opened files
1661 for (int i = 0; i < MaxRecentFiles; ++i)
1663 recentFileActions[i] = new QAction(this);
1664 recentFileActions[i]->setVisible(false);
1665 fileLastMapsMenu->addAction(recentFileActions[i]);
1666 connect(recentFileActions[i], SIGNAL(triggered()),
1667 this, SLOT(fileLoadRecent()));
1669 setupRecentMapsMenu();
1672 void Main::setupRecentMapsMenu()
1674 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1676 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1678 for (int i = 0; i < numRecentFiles; ++i) {
1679 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1680 recentFileActions[i]->setText(text);
1681 recentFileActions[i]->setData(files[i]);
1682 recentFileActions[i]->setVisible(true);
1684 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1685 recentFileActions[j]->setVisible(false);
1688 void Main::setupMacros()
1690 for (int i = 0; i <= 11; i++)
1692 macroActions[i] = new QAction(this);
1693 macroActions[i]->setData(i);
1694 addAction (macroActions[i]);
1695 connect(macroActions[i], SIGNAL(triggered()),
1696 this, SLOT(callMacro()));
1698 macroActions[0]->setShortcut ( Qt::Key_F1 );
1699 macroActions[1]->setShortcut ( Qt::Key_F2 );
1700 macroActions[2]->setShortcut ( Qt::Key_F3 );
1701 macroActions[3]->setShortcut ( Qt::Key_F4 );
1702 macroActions[4]->setShortcut ( Qt::Key_F5 );
1703 macroActions[5]->setShortcut ( Qt::Key_F6 );
1704 macroActions[6]->setShortcut ( Qt::Key_F7 );
1705 macroActions[7]->setShortcut ( Qt::Key_F8 );
1706 macroActions[8]->setShortcut ( Qt::Key_F9 );
1707 macroActions[9]->setShortcut ( Qt::Key_F10 );
1708 macroActions[10]->setShortcut ( Qt::Key_F11 );
1709 macroActions[11]->setShortcut ( Qt::Key_F12 );
1712 void Main::hideEvent (QHideEvent * )
1714 if (!textEditor->isMinimized() ) textEditor->hide();
1717 void Main::showEvent (QShowEvent * )
1719 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1723 MapEditor* Main::currentMapEditor() const
1725 if ( tabWidget->currentPage())
1726 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1730 VymModel* Main::currentModel() const
1732 if ( tabWidget->currentPage())
1733 return vymViews.at(tabWidget->currentIndex())->getModel();
1738 void Main::editorChanged(QWidget *)
1740 // Unselect all possibly selected objects
1741 // (Important to update note editor)
1743 for (int i=0;i<=tabWidget->count() -1;i++)
1745 m= vymViews.at(i)->getModel();
1746 if (m) m->unselect();
1749 if (m) m->reselect();
1751 // Update actions to in menus and toolbars according to editor
1755 void Main::fileNew()
1757 VymModel *vm=new VymModel;
1759 /////////////////////////////////////
1760 // new ModelTest(vm, this); //FIXME-3
1761 /////////////////////////////////////
1763 VymView *vv=new VymView (vm);
1764 vymViews.append (vv);
1765 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1766 tabWidget->setCurrentIndex (vymViews.count() );
1769 // Create MapCenter for empty map
1773 // For the very first map we do not have flagrows yet...
1777 void Main::fileNewCopy()
1779 QString fn="unnamed";
1780 VymModel *srcModel=currentModel();
1785 VymModel *dstModel=vymViews.last()->getModel();
1786 dstModel->select("mc:");
1787 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1791 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1793 ErrorCode err=success;
1795 // fn is usually the archive, mapfile the file after uncompressing
1798 // Make fn absolute (needed for unzip)
1799 fn=QDir (fn).absPath();
1805 // Check, if map is already loaded
1807 while (i<=tabWidget->count() -1)
1809 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1811 // Already there, ask for confirmation
1812 QMessageBox mb( vymName,
1813 tr("The map %1\nis already opened."
1814 "Opening the same map in multiple editors may lead \n"
1815 "to confusion when finishing working with vym."
1816 "Do you want to").arg(fn),
1817 QMessageBox::Warning,
1818 QMessageBox::Yes | QMessageBox::Default,
1819 QMessageBox::Cancel | QMessageBox::Escape,
1820 QMessageBox::NoButton);
1821 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1822 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1825 case QMessageBox::Yes:
1826 // end loop and load anyway
1827 i=tabWidget->count();
1829 case QMessageBox::Cancel:
1839 int tabIndex=tabWidget->currentPageIndex();
1842 if ( !fn.isEmpty() )
1844 vm = currentModel();
1845 // Check first, if mapeditor exists
1846 // If it is not default AND we want a new map,
1847 // create a new mapeditor in a new tab
1848 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1851 VymView *vv=new VymView (vm);
1852 vymViews.append (vv);
1853 tabWidget->addTab (vv,fn);
1854 tabIndex=tabWidget->count()-1;
1855 tabWidget->setCurrentPage (tabIndex);
1859 // Check, if file exists (important for creating new files
1860 // from command line
1861 if (!QFile(fn).exists() )
1863 QMessageBox mb( vymName,
1864 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1865 QMessageBox::Question,
1867 QMessageBox::Cancel | QMessageBox::Default,
1868 QMessageBox::NoButton );
1870 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1871 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1874 case QMessageBox::Yes:
1876 currentMapEditor()->getModel()->setFilePath(fn);
1877 tabWidget->setTabText (tabIndex,
1878 currentMapEditor()->getModel()->getFileName() );
1879 statusBar()->message( "Created " + fn , statusbarTime );
1882 case QMessageBox::Cancel:
1883 // don't create new map
1884 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1891 //tabWidget->currentPage() won't be NULL here, because of above...
1892 tabWidget->setCurrentIndex (tabIndex);
1893 //FIXME-3 no me anymore... me->viewport()->setFocus();
1897 // Save existing filename in case we import
1898 QString fn_org=vm->getFilePath();
1900 // Finally load map into mapEditor
1901 vm->setFilePath (fn);
1902 err=vm->load(fn,lmode,ftype);
1904 // Restore old (maybe empty) filepath, if this is an import
1906 vm->setFilePath (fn_org);
1909 // Finally check for errors and go home
1912 if (lmode==NewMap) fileCloseMap();
1913 statusBar()->message( "Could not load " + fn, statusbarTime );
1918 vm->setFilePath (fn);
1919 tabWidget->setTabText (tabIndex, vm->getFileName());
1920 if (!isInTmpDir (fn))
1922 // Only append to lastMaps if not loaded from a tmpDir
1923 // e.g. imported bookmarks are in a tmpDir
1924 addRecentMap(vm->getFilePath() );
1926 actionFilePrint->setEnabled (true);
1928 statusBar()->message( "Loaded " + fn, statusbarTime );
1935 void Main::fileLoad(const LoadMode &lmode)
1937 QStringList filters;
1938 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1939 QFileDialog *fd=new QFileDialog( this);
1940 fd->setDir (lastFileDir);
1941 fd->setFileMode (QFileDialog::ExistingFiles);
1942 fd->setFilters (filters);
1946 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1949 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1952 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1958 if ( fd->exec() == QDialog::Accepted )
1960 lastFileDir=fd->directory().path();
1961 QStringList flist = fd->selectedFiles();
1962 QStringList::Iterator it = flist.begin();
1963 while( it != flist.end() )
1966 fileLoad(*it, lmode);
1973 void Main::fileLoad()
1978 void Main::fileLoadRecent()
1980 QAction *action = qobject_cast<QAction *>(sender());
1982 fileLoad (action->data().toString(), NewMap);
1985 void Main::addRecentMap (const QString &fileName)
1988 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1989 files.removeAll(fileName);
1990 files.prepend(fileName);
1991 while (files.size() > MaxRecentFiles)
1994 settings.setValue("/mainwindow/recentFileList", files);
1996 setupRecentMapsMenu();
1999 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2003 if ( m->getFilePath().isEmpty() )
2005 // We have no filepath yet,
2006 // call fileSaveAs() now, this will call fileSave()
2008 // First switch to editor
2009 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2010 fileSaveAs(savemode);
2013 if (m->save (savemode)==success)
2015 statusBar()->message(
2016 tr("Saved %1").arg(m->getFilePath()),
2018 addRecentMap (m->getFilePath() );
2020 statusBar()->message(
2021 tr("Couldn't save ").arg(m->getFilePath()),
2025 void Main::fileSave()
2027 fileSave (currentModel(), CompleteMap);
2030 void Main::fileSave(VymModel *m)
2032 fileSave (m,CompleteMap);
2035 void Main::fileSaveAs(const SaveMode& savemode)
2039 if (currentMapEditor())
2041 if (savemode==CompleteMap)
2042 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2044 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2045 if ( !fn.isEmpty() )
2047 // Check for existing file
2048 if (QFile (fn).exists())
2050 QMessageBox mb( vymName,
2051 tr("The file %1\nexists already. Do you want to").arg(fn),
2052 QMessageBox::Warning,
2053 QMessageBox::Yes | QMessageBox::Default,
2054 QMessageBox::Cancel | QMessageBox::Escape,
2055 QMessageBox::NoButton);
2056 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2057 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2060 case QMessageBox::Yes:
2063 case QMessageBox::Cancel:
2070 // New file, add extension to filename, if missing
2071 // This is always .vym or .vyp, depending on savemode
2072 if (savemode==CompleteMap)
2074 if (!fn.contains (".vym") && !fn.contains (".xml"))
2078 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2087 VymModel *m=currentModel();
2089 fileSave(m, savemode);
2091 // Set name of tab, assuming current tab is the one we just saved
2092 if (savemode==CompleteMap)
2093 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2099 void Main::fileSaveAs()
2101 fileSaveAs (CompleteMap);
2104 void Main::fileImportKDE3Bookmarks()
2106 ImportKDE3Bookmarks im;
2108 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2109 currentMapEditor()->getModel()->setFilePath ("");
2112 void Main::fileImportKDE4Bookmarks()
2114 ImportKDE4Bookmarks im;
2116 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2117 currentMapEditor()->getModel()->setFilePath ("");
2120 void Main::fileImportFirefoxBookmarks()
2122 Q3FileDialog *fd=new Q3FileDialog( this);
2123 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2124 fd->setMode (Q3FileDialog::ExistingFiles);
2125 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2126 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2129 if ( fd->exec() == QDialog::Accepted )
2131 ImportFirefoxBookmarks im;
2132 QStringList flist = fd->selectedFiles();
2133 QStringList::Iterator it = flist.begin();
2134 while( it != flist.end() )
2137 if (im.transform() &&
2138 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2139 currentMapEditor() )
2140 currentMapEditor()->getModel()->setFilePath ("");
2147 void Main::fileImportFreemind()
2149 QStringList filters;
2150 filters <<"Freemind map (*.mm)"<<"All files (*)";
2151 QFileDialog *fd=new QFileDialog( this);
2152 fd->setDir (lastFileDir);
2153 fd->setFileMode (QFileDialog::ExistingFiles);
2154 fd->setFilters (filters);
2155 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2159 if ( fd->exec() == QDialog::Accepted )
2161 lastFileDir=fd->directory().path();
2162 QStringList flist = fd->selectedFiles();
2163 QStringList::Iterator it = flist.begin();
2164 while( it != flist.end() )
2167 if ( fileLoad (fn,NewMap, FreemindMap) )
2169 currentMapEditor()->getModel()->setFilePath ("");
2178 void Main::fileImportMM()
2182 Q3FileDialog *fd=new Q3FileDialog( this);
2183 fd->setDir (lastFileDir);
2184 fd->setMode (Q3FileDialog::ExistingFiles);
2185 fd->addFilter ("Mind Manager (*.mmap)");
2186 fd->setCaption(tr("Import")+" "+"Mind Manager");
2189 if ( fd->exec() == QDialog::Accepted )
2191 lastFileDir=fd->dirPath();
2192 QStringList flist = fd->selectedFiles();
2193 QStringList::Iterator it = flist.begin();
2194 while( it != flist.end() )
2197 if (im.transform() &&
2198 success==fileLoad (im.getTransformedFile(),NewMap) &&
2199 currentMapEditor() )
2200 currentMapEditor()->getModel()->setFilePath ("");
2207 void Main::fileImportDir()
2209 VymModel *m=currentModel();
2210 if (m) m->importDir();
2213 void Main::fileExportXML()
2215 VymModel *m=currentModel();
2216 if (m) m->exportXML();
2220 void Main::fileExportXHTML()
2222 VymModel *m=currentModel();
2223 if (m) m->exportXHTML();
2226 void Main::fileExportImage()
2228 VymModel *m=currentModel();
2229 if (m) m->exportImage();
2232 void Main::fileExportAO()
2234 VymModel *m=currentModel();
2235 if (m) m->exportAO();
2238 void Main::fileExportASCII()
2240 VymModel *m=currentModel();
2241 if (m) m->exportASCII();
2244 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2246 VymModel *m=currentModel();
2251 ex.addFilter ("CSV (*.csv)");
2252 ex.setDir(lastImageDir);
2253 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2254 if (ex.execDialog() )
2256 m->setExportMode(true);
2258 m->setExportMode(false);
2263 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2265 VymModel *m=currentModel();
2270 ex.addFilter ("Tex (*.tex)");
2271 ex.setDir(lastImageDir);
2272 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2273 if (ex.execDialog() )
2275 m->setExportMode(true);
2277 m->setExportMode(false);
2282 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2284 ExportKDE3Bookmarks ex;
2285 VymModel *m=currentModel();
2293 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2295 ExportKDE4Bookmarks ex;
2296 VymModel *m=currentModel();
2304 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2306 ExportTaskjuggler ex;
2307 VymModel *m=currentModel();
2311 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2312 ex.setDir(lastImageDir);
2313 ex.addFilter ("Taskjuggler (*.tjp)");
2314 if (ex.execDialog() )
2316 m->setExportMode(true);
2318 m->setExportMode(false);
2323 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2325 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2326 // TODO add preview in dialog
2327 //ImagePreview *p =new ImagePreview (fd);
2328 //fd->setContentsPreviewEnabled( TRUE );
2329 //fd->setContentsPreview( p, p );
2330 //fd->setPreviewMode( QFileDialog::Contents );
2331 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2332 fd->setDir (QDir().current());
2333 if (fd->foundConfig())
2337 if ( fd->exec() == QDialog::Accepted )
2339 QString fn=fd->selectedFile();
2340 if (!fn.contains (".odp"))
2343 //lastImageDir=fn.left(fn.findRev ("/"));
2344 VymModel *m=currentModel();
2345 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2349 QMessageBox::warning(0,
2351 tr("Couldn't find configuration for export to Open Office\n"));
2355 void Main::fileCloseMap()
2357 VymModel *m=currentModel();
2360 if (m->hasChanged())
2362 QMessageBox mb( vymName,
2363 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2364 QMessageBox::Warning,
2365 QMessageBox::Yes | QMessageBox::Default,
2367 QMessageBox::Cancel | QMessageBox::Escape );
2368 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2369 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2372 case QMessageBox::Yes:
2374 fileSave(m, CompleteMap);
2376 case QMessageBox::No:
2377 // close without saving
2379 case QMessageBox::Cancel:
2384 // And here comes the segfault, because removeTab triggers
2385 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2386 vymViews.removeAt (tabWidget->currentIndex() );
2387 tabWidget->removeTab (tabWidget->currentIndex() );
2389 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2390 // Better would be delete (me), but then we could have a Qt error:
2391 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2392 // So we only remove data now and call deconstructor when vym closes later
2393 // this needs to be moved to vymview... me->clear();
2394 // some model->clear is needed to free up memory ...
2396 delete (m->getMapEditor());
2403 void Main::filePrint()
2405 if (currentMapEditor())
2406 currentMapEditor()->print();
2409 void Main::fileExitVYM()
2411 // Check if one or more editors have changed
2413 for (i=0;i<=vymViews.count() -1;i++)
2415 // If something changed, ask what to do
2416 if (vymViews.at(i)->getModel()->hasChanged())
2418 tabWidget->setCurrentPage(i);
2419 QMessageBox mb( vymName,
2420 tr("This map is not saved yet. Do you want to"),
2421 QMessageBox::Warning,
2422 QMessageBox::Yes | QMessageBox::Default,
2424 QMessageBox::Cancel | QMessageBox::Escape );
2425 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2426 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2429 mb.setActiveWindow();
2430 switch( mb.exec() ) {
2431 case QMessageBox::Yes:
2432 // save (the changed editors) and exit
2433 fileSave(currentModel(), CompleteMap);
2435 case QMessageBox::No:
2436 // exit without saving
2438 case QMessageBox::Cancel:
2439 // don't save and don't exit
2443 } // loop over all MEs
2447 void Main::editUndo()
2449 VymModel *m=currentModel();
2453 void Main::editRedo()
2455 VymModel *m=currentModel();
2459 void Main::gotoHistoryStep (int i)
2461 VymModel *m=currentModel();
2462 if (m) m->gotoHistoryStep(i);
2465 void Main::editCopy()
2467 VymModel *m=currentModel();
2471 void Main::editPaste()
2473 VymModel *m=currentModel();
2477 void Main::editCut()
2479 VymModel *m=currentModel();
2483 void Main::editOpenFindWidget()
2485 VymModel *m=currentModel();
2486 if (m) m->emitShowFindWidget();
2489 void Main::openTabs(QStringList urls)
2491 if (!urls.isEmpty())
2495 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2496 if (*browserPID==0) //FIXME-2 need to check if browser is really still there instead of this
2498 QString u=urls.takeFirst();
2500 QString workDir=QDir::currentDirPath();
2501 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2503 // try to set path to browser
2504 QMessageBox::warning(0,
2506 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2507 tr("Please use Settings->")+tr("Set application to open an URL"));
2510 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2511 #if defined(Q_OS_WIN32)
2512 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2513 this->thread()->wait(3000);
2515 sleep (3); //FIXME-3 needed?
2519 if (browser.contains("konqueror"))
2521 for (int i=0; i<urls.size(); i++)
2524 // Try to open new tab in existing konqueror started previously by vym
2528 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2529 "konqueror-mainwindow#1"<<
2533 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2534 "/konqueror/MainWindow_1"<<
2538 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2539 if (!QProcess::startDetached ("qdbus",args))
2543 QMessageBox::warning(0,
2545 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2547 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2549 for (int i=0; i<urls.size(); i++)
2551 // Try to open new tab in firefox
2552 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2553 if (!QProcess::startDetached (browser,args))
2557 QMessageBox::warning(0,
2559 tr("Couldn't start %1 to open a new tab").arg(browser));
2562 QMessageBox::warning(0,
2564 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2568 void Main::editOpenURL()
2571 VymModel *m=currentModel();
2574 QString url=m->getURL();
2576 if (url=="") return;
2577 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2579 QString workDir=QDir::currentDirPath();
2580 if (!procBrowser->startDetached(browser,args))
2582 // try to set path to browser
2583 QMessageBox::warning(0,
2585 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2586 tr("Please use Settings->")+tr("Set application to open an URL"));
2591 void Main::editOpenURLTab()
2593 VymModel *m=currentModel();
2597 urls.append(m->getURL());
2601 void Main::editOpenMultipleURLTabs()
2603 VymModel *m=currentModel();
2613 void Main::editURL()
2615 VymModel *m=currentModel();
2616 if (m) m->editURL();
2619 void Main::editLocalURL()
2621 VymModel *m=currentModel();
2622 if (m) m->editLocalURL();
2625 void Main::editHeading2URL()
2627 VymModel *m=currentModel();
2628 if (m) m->editHeading2URL();
2631 void Main::editBugzilla2URL()
2633 VymModel *m=currentModel();
2634 if (m) m->editBugzilla2URL();
2637 void Main::editFATE2URL()
2639 VymModel *m=currentModel();
2640 if (m) m->editFATE2URL();
2643 void Main::editHeadingFinished(VymModel *m)
2647 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2648 !prevSelection.isEmpty())
2649 m->select(prevSelection);
2654 void Main::openVymLinks(const QStringList &vl)
2656 for (int j=0; j<vl.size(); j++)
2658 // compare path with already loaded maps
2661 for (i=0;i<=vymViews.count() -1;i++)
2663 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2672 if (!QFile(vl.at(j)).exists() )
2673 QMessageBox::critical( 0, tr( "Critical Error" ),
2674 tr("Couldn't open map %1").arg(vl.at(j)));
2677 fileLoad (vl.at(j), NewMap);
2678 tabWidget->setCurrentIndex (tabWidget->count()-1);
2681 // Go to tab containing the map
2682 tabWidget->setCurrentIndex (index);
2686 void Main::editOpenVymLink()
2688 VymModel *m=currentModel();
2692 vl.append(m->getVymLink());
2697 void Main::editOpenMultipleVymLinks()
2699 QString currentVymLink;
2700 VymModel *m=currentModel();
2703 QStringList vl=m->getVymLinks();
2708 void Main::editVymLink()
2710 VymModel *m=currentModel();
2715 void Main::editDeleteVymLink()
2717 VymModel *m=currentModel();
2718 if (m) m->deleteVymLink();
2721 void Main::editToggleHideExport()
2723 VymModel *m=currentModel();
2724 if (m) m->toggleHideExport();
2727 void Main::editAddTimestamp()
2729 VymModel *m=currentModel();
2730 if (m) m->addTimestamp();
2733 void Main::editMapInfo()
2735 VymModel *m=currentModel();
2738 ExtraInfoDialog dia;
2739 dia.setMapName (m->getFileName() );
2740 dia.setAuthor (m->getAuthor() );
2741 dia.setComment(m->getComment() );
2745 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2751 BranchItem *cur=NULL;
2752 BranchItem *prev=NULL;
2753 m->nextBranch(cur,prev);
2756 if (!cur->getNote().isEmpty() ) n++;
2757 f+= cur->imageCount();
2759 xl+=cur->xlinkCount();
2760 m->nextBranch(cur,prev);
2763 stats+=QString ("%1 xLinks \n").arg (xl,6);
2764 stats+=QString ("%1 notes\n").arg (n,6);
2765 stats+=QString ("%1 images\n").arg (f,6);
2766 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2767 dia.setStats (stats);
2769 // Finally show dialog
2770 if (dia.exec() == QDialog::Accepted)
2772 m->setAuthor (dia.getAuthor() );
2773 m->setComment (dia.getComment() );
2777 void Main::editMoveUp()
2779 VymModel *m=currentModel();
2783 void Main::editMoveDown()
2785 VymModel *m=currentModel();
2786 if (m) m->moveDown();
2789 void Main::editDetach()
2791 VymModel *m=currentModel();
2795 void Main::editSortChildren()
2797 VymModel *m=currentModel();
2798 if (m) m->sortChildren();
2801 void Main::editToggleScroll()
2803 VymModel *m=currentModel();
2804 if (m) m->toggleScroll();
2807 void Main::editExpandAll()
2809 VymModel *m=currentModel();
2810 if (m) m->emitExpandAll();
2813 void Main::editExpandOneLevel()
2815 VymModel *m=currentModel();
2816 if (m) m->emitExpandOneLevel();
2819 void Main::editCollapseOneLevel()
2821 VymModel *m=currentModel();
2822 if (m) m->emitCollapseOneLevel();
2825 void Main::editUnscrollChildren()
2827 VymModel *m=currentModel();
2828 if (m) m->unscrollChildren();
2831 void Main::editAddAttribute()
2833 VymModel *m=currentModel();
2834 if (m) m->addAttribute();
2837 void Main::editAddMapCenter()
2839 VymModel *m=currentModel();
2840 if (m) m->addMapCenter ();
2843 void Main::editNewBranch()
2845 VymModel *m=currentModel();
2848 BranchItem *bi=m->addNewBranch();
2851 if (actionSettingsAutoEditNewBranch->isOn()
2852 && !actionSettingsAutoSelectNewBranch->isOn() )
2853 prevSelection=m->getSelectString();
2855 prevSelection=QString();
2857 if (actionSettingsAutoSelectNewBranch->isOn()
2858 || actionSettingsAutoEditNewBranch->isOn())
2861 if (actionSettingsAutoEditNewBranch->isOn())
2862 currentMapEditor()->editHeading();
2867 void Main::editNewBranchBefore()
2869 VymModel *m=currentModel();
2872 BranchItem *bi=m->addNewBranchBefore();
2879 if (actionSettingsAutoEditNewBranch->isOn())
2881 if (!actionSettingsAutoSelectNewBranch->isOn())
2882 prevSelection=m->getSelectString(bi);
2883 currentMapEditor()->editHeading();
2888 void Main::editNewBranchAbove()
2890 VymModel *m=currentModel();
2893 BranchItem *bi=m->addNewBranch (-1);
2901 if (actionSettingsAutoEditNewBranch->isOn())
2903 if (!actionSettingsAutoSelectNewBranch->isOn())
2904 prevSelection=m->getSelectString (bi);
2905 currentMapEditor()->editHeading();
2910 void Main::editNewBranchBelow()
2912 VymModel *m=currentModel();
2915 BranchItem *bi=m->addNewBranch (1);
2922 if (actionSettingsAutoEditNewBranch->isOn())
2924 if (!actionSettingsAutoSelectNewBranch->isOn())
2925 prevSelection=m->getSelectString(bi);
2926 currentMapEditor()->editHeading();
2931 void Main::editImportAdd()
2933 fileLoad (ImportAdd);
2936 void Main::editImportReplace()
2938 fileLoad (ImportReplace);
2941 void Main::editSaveBranch()
2943 fileSaveAs (PartOfMap);
2946 void Main::editDeleteKeepChildren()
2948 VymModel *m=currentModel();
2949 if (m) m->deleteKeepChildren();
2952 void Main::editDeleteChildren()
2954 VymModel *m=currentModel();
2955 if (m) m->deleteChildren();
2958 void Main::editDeleteSelection()
2960 VymModel *m=currentModel();
2961 if (m && actionSettingsUseDelKey->isOn())
2962 m->deleteSelection();
2965 void Main::editLoadImage()
2967 VymModel *m=currentModel();
2968 if (m) m->loadFloatImage();
2971 void Main::editSaveImage()
2973 VymModel *m=currentModel();
2974 if (m) m->saveFloatImage();
2977 void Main::editEditXLink(QAction *a)
2979 VymModel *m=currentModel();
2981 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2984 void Main::formatSelectColor()
2986 QColor col = QColorDialog::getColor((currentColor ), this );
2987 if ( !col.isValid() ) return;
2988 colorChanged( col );
2991 void Main::formatPickColor()
2993 VymModel *m=currentModel();
2995 colorChanged( m->getCurrentHeadingColor() );
2998 void Main::colorChanged(QColor c)
3000 QPixmap pix( 16, 16 );
3002 actionFormatColor->setIconSet( pix );
3006 void Main::formatColorBranch()
3008 VymModel *m=currentModel();
3009 if (m) m->colorBranch(currentColor);
3012 void Main::formatColorSubtree()
3014 VymModel *m=currentModel();
3015 if (m) m->colorSubtree (currentColor);
3018 void Main::formatLinkStyleLine()
3020 VymModel *m=currentModel();
3023 m->setMapLinkStyle("StyleLine");
3024 actionFormatLinkStyleLine->setChecked(true);
3028 void Main::formatLinkStyleParabel()
3030 VymModel *m=currentModel();
3033 m->setMapLinkStyle("StyleParabel");
3034 actionFormatLinkStyleParabel->setChecked(true);
3038 void Main::formatLinkStylePolyLine()
3040 VymModel *m=currentModel();
3043 m->setMapLinkStyle("StylePolyLine");
3044 actionFormatLinkStylePolyLine->setChecked(true);
3048 void Main::formatLinkStylePolyParabel()
3050 VymModel *m=currentModel();
3053 m->setMapLinkStyle("StylePolyParabel");
3054 actionFormatLinkStylePolyParabel->setChecked(true);
3058 void Main::formatSelectBackColor()
3060 VymModel *m=currentModel();
3061 if (m) m->selectMapBackgroundColor();
3064 void Main::formatSelectBackImage()
3066 VymModel *m=currentModel();
3068 m->selectMapBackgroundImage();
3071 void Main::formatSelectLinkColor()
3073 VymModel *m=currentModel();
3076 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3077 m->setMapDefLinkColor( col );
3081 void Main::formatSelectSelectionColor()
3083 VymModel *m=currentModel();
3086 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3087 m->setSelectionColor (col);
3092 void Main::formatToggleLinkColorHint()
3094 VymModel *m=currentModel();
3095 if (m) m->toggleMapLinkColorHint();
3099 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3101 VymModel *m=currentModel();
3103 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3106 void Main::viewZoomReset()
3108 MapEditor *me=currentMapEditor();
3109 if (me) me->setZoomFactorTarget (1);
3112 void Main::viewZoomIn()
3114 MapEditor *me=currentMapEditor();
3115 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3118 void Main::viewZoomOut()
3120 MapEditor *me=currentMapEditor();
3121 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3124 void Main::viewCenter()
3126 VymModel *m=currentModel();
3127 if (m) m->emitShowSelection();
3130 void Main::networkStartServer()
3132 VymModel *m=currentModel();
3133 if (m) m->newServer();
3136 void Main::networkConnect()
3138 VymModel *m=currentModel();
3139 if (m) m->connectToServer();
3142 bool Main::settingsPDF()
3144 // Default browser is set in constructor
3146 QString text = QInputDialog::getText(
3147 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3148 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3150 settings.setValue ("/mainwindow/readerPDF",text);
3155 bool Main::settingsURL()
3157 // Default browser is set in constructor
3159 QString text = QInputDialog::getText(
3160 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3161 settings.value("/mainwindow/readerURL").toString()
3164 settings.setValue ("/mainwindow/readerURL",text);
3168 void Main::settingsMacroDir()
3170 QDir defdir(vymBaseDir.path() + "/macros");
3171 if (!defdir.exists())
3173 QDir dir=QFileDialog::getExistingDirectory (
3175 tr ("Directory with vym macros:"),
3176 settings.value ("/macros/macroDir",defdir.path()).toString()
3179 settings.setValue ("/macros/macroDir",dir.absolutePath());
3182 void Main::settingsUndoLevels()
3185 int i = QInputDialog::getInteger(
3187 tr("QInputDialog::getInteger()"),
3188 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3191 settings.setValue ("/mapeditor/stepsTotal",i);
3192 QMessageBox::information( this, tr( "VYM -Information:" ),
3193 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3197 void Main::settingsAutosaveToggle()
3199 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3202 void Main::settingsAutosaveTime()
3205 int i = QInputDialog::getInteger(
3207 tr("QInputDialog::getInteger()"),
3208 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3210 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3213 void Main::settingsWriteBackupFileToggle()
3215 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3218 void Main::settingsToggleAnimation()
3220 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3223 void Main::settingsToggleDelKey()
3225 if (actionSettingsUseDelKey->isOn())
3227 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3230 actionDelete->setAccel (QKeySequence (""));
3234 void Main::windowToggleNoteEditor()
3236 if (textEditor->isVisible() )
3237 windowHideNoteEditor();
3239 windowShowNoteEditor();
3242 void Main::windowToggleHistory()
3244 if (historyWindow->isVisible())
3245 historyWindow->hide();
3247 historyWindow->show();
3251 void Main::windowToggleProperty()
3253 if (branchPropertyWindow->isVisible())
3254 branchPropertyWindow->hide();
3256 branchPropertyWindow->show();
3257 branchPropertyWindow->setModel (currentModel() );
3260 void Main::windowToggleAntiAlias()
3262 bool b=actionViewToggleAntiAlias->isOn();
3264 for (int i=0;i<vymViews.count();i++)
3266 me=vymViews.at(i)->getMapEditor();
3267 if (me) me->setAntiAlias(b);
3272 bool Main::isAliased()
3274 return actionViewToggleAntiAlias->isOn();
3277 bool Main::hasSmoothPixmapTransform()
3279 return actionViewToggleSmoothPixmapTransform->isOn();
3282 void Main::windowToggleSmoothPixmap()
3284 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3286 for (int i=0;i<vymViews.count();i++)
3289 me=vymViews.at(i)->getMapEditor();
3290 if (me) me->setSmoothPixmap(b);
3294 void Main::updateHistory(SimpleSettings &undoSet)
3296 historyWindow->update (undoSet);
3299 void Main::updateNoteFlag()
3301 // this slot is connected to TextEditor::textHasChanged()
3303 VymModel *m=currentModel();
3304 if (m) m->updateNoteFlag();
3307 void Main::updateNoteEditor(QModelIndex index )
3309 cout << QObject::sender();
3310 QObject *obj=QObject::sender();
3311 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3312 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3313 //cout << "Main::updateNoteEditor model="<<sender();
3314 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3315 textEditor->setNote (ti->getNoteObj() );
3318 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3320 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3322 if (model && model==currentModel() )
3326 if (!oldsel.indexes().isEmpty() )
3328 ti=model->getItem(oldsel.indexes().first());
3330 // Don't update note if both treeItem and textEditor are empty
3331 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3332 // ti->setNoteObj (textEditor->getNoteObj(),false );
3334 if (!newsel.indexes().isEmpty() )
3336 ti=model->getItem(newsel.indexes().first());
3337 if (!ti->hasEmptyNote() )
3338 textEditor->setNote(ti->getNoteObj() );
3340 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3342 // Show URL and link in statusbar
3344 QString s=ti->getURL();
3345 if (!s.isEmpty() ) status+="URL: "+s+" ";
3347 if (!s.isEmpty() ) status+="Link: "+s;
3348 if (!status.isEmpty() ) statusMessage (status);
3351 textEditor->setInactive();
3357 void Main::updateActions()
3359 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3360 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3361 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3362 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3364 VymModel *m =currentModel();
3368 actionFilePrint->setEnabled (true);
3370 // Link style in context menu
3371 switch (m->getMapLinkStyle())
3373 case LinkableMapObj::Line:
3374 actionFormatLinkStyleLine->setChecked(true);
3376 case LinkableMapObj::Parabel:
3377 actionFormatLinkStyleParabel->setChecked(true);
3379 case LinkableMapObj::PolyLine:
3380 actionFormatLinkStylePolyLine->setChecked(true);
3382 case LinkableMapObj::PolyParabel:
3383 actionFormatLinkStylePolyParabel->setChecked(true);
3390 QPixmap pix( 16, 16 );
3391 pix.fill( m->getMapBackgroundColor() );
3392 actionFormatBackColor->setIconSet( pix );
3393 pix.fill( m->getSelectionColor() );
3394 actionFormatSelectionColor->setIconSet( pix );
3395 pix.fill( m->getMapDefLinkColor() );
3396 actionFormatLinkColor->setIconSet( pix );
3399 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3402 // Expanding/collapsing
3403 actionExpandAll->setEnabled (true);
3404 actionExpandOneLevel->setEnabled (true);
3405 actionCollapseOneLevel->setEnabled (true);
3409 actionFilePrint->setEnabled (false);
3411 // Expanding/collapsing
3412 actionExpandAll->setEnabled (false);
3413 actionExpandOneLevel->setEnabled (false);
3414 actionCollapseOneLevel->setEnabled (false);
3417 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3418 actionFormatLinkColorHint->setChecked(true);
3420 actionFormatLinkColorHint->setChecked(false);
3423 if (m && m->hasChanged() )
3424 actionFileSave->setEnabled( true);
3426 actionFileSave->setEnabled( false);
3427 if (m && m->isUndoAvailable())
3428 actionUndo->setEnabled( true);
3430 actionUndo->setEnabled( false);
3432 if (m && m->isRedoAvailable())
3433 actionRedo->setEnabled( true);
3435 actionRedo->setEnabled( false);
3439 TreeItem *selti=m->getSelectedItem();
3440 BranchItem *selbi=m->getSelectedBranch();
3443 if (selbi || selti->getType()==TreeItem::Image)
3445 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3446 actionFormatHideLinkUnselected->setEnabled (true);
3451 // Take care of xlinks
3452 branchXLinksContextMenuEdit->clear();
3453 if (selbi->xlinkCount()>0)
3457 for (int i=0; i<selbi->xlinkCount();++i)
3459 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3463 if (s.length()>xLinkMenuWidth)
3464 s=s.left(xLinkMenuWidth)+"...";
3465 branchXLinksContextMenuEdit->addAction (s);
3470 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3473 actionToggleScroll->setEnabled (true);
3474 if ( selbi->isScrolled() )
3475 actionToggleScroll->setChecked(true);
3477 actionToggleScroll->setChecked(false);
3479 if ( selti->getURL().isEmpty() )
3481 actionOpenURL->setEnabled (false);
3482 actionOpenURLTab->setEnabled (false);
3486 actionOpenURL->setEnabled (true);
3487 actionOpenURLTab->setEnabled (true);
3489 if ( selti->getVymLink().isEmpty() )
3491 actionOpenVymLink->setEnabled (false);
3492 actionDeleteVymLink->setEnabled (false);
3495 actionOpenVymLink->setEnabled (true);
3496 actionDeleteVymLink->setEnabled (true);
3499 if (selbi->canMoveUp())
3500 actionMoveUp->setEnabled (true);
3502 actionMoveUp->setEnabled (false);
3503 if (selbi->canMoveDown())
3504 actionMoveDown->setEnabled (true);
3506 actionMoveDown->setEnabled (false);
3508 actionSortChildren->setEnabled (true);
3510 actionToggleHideExport->setEnabled (true);
3511 actionToggleHideExport->setChecked (selbi->hideInExport() );
3513 actionCopy->setEnabled (true);
3514 actionCut->setEnabled (true);
3515 if (!clipboardEmpty)
3516 actionPaste->setEnabled (true);
3518 actionPaste->setEnabled (false);
3519 for (int i=0; i<actionListBranches.size(); ++i)
3520 actionListBranches.at(i)->setEnabled(true);
3521 actionDelete->setEnabled (true);
3523 if ( selti->getType()==TreeItem::Image)
3525 actionOpenURL->setEnabled (false);
3526 actionOpenVymLink->setEnabled (false);
3527 actionDeleteVymLink->setEnabled (false);
3528 actionToggleHideExport->setEnabled (true);
3529 actionToggleHideExport->setChecked (selti->hideInExport() );
3532 actionCopy->setEnabled (true);
3533 actionCut->setEnabled (true);
3534 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3535 for (int i=0; i<actionListBranches.size(); ++i)
3536 actionListBranches.at(i)->setEnabled(false);
3537 actionDelete->setEnabled (true);
3538 actionMoveUp->setEnabled (false);
3539 actionMoveDown->setEnabled (false);
3544 actionCopy->setEnabled (false);
3545 actionCut->setEnabled (false);
3546 actionPaste->setEnabled (false);
3547 for (int i=0; i<actionListBranches.size(); ++i)
3548 actionListBranches.at(i)->setEnabled(false);
3550 actionToggleScroll->setEnabled (false);
3551 actionOpenURL->setEnabled (false);
3552 actionOpenVymLink->setEnabled (false);
3553 actionDeleteVymLink->setEnabled (false);
3554 actionHeading2URL->setEnabled (false);
3555 actionDelete->setEnabled (false);
3556 actionMoveUp->setEnabled (false);
3557 actionMoveDown->setEnabled (false);
3558 actionFormatHideLinkUnselected->setEnabled (false);
3559 actionSortChildren->setEnabled (false);
3560 actionToggleHideExport->setEnabled (false);
3565 Main::ModMode Main::getModMode()
3567 if (actionModModeColor->isOn()) return ModModeColor;
3568 if (actionModModeCopy->isOn()) return ModModeCopy;
3569 if (actionModModeXLink->isOn()) return ModModeXLink;
3573 bool Main::autoEditNewBranch()
3575 return actionSettingsAutoEditNewBranch->isOn();
3578 bool Main::autoSelectNewBranch()
3580 return actionSettingsAutoSelectNewBranch->isOn();
3583 void Main::windowShowNoteEditor()
3585 textEditor->setShowWithMain(true);
3587 actionViewToggleNoteEditor->setChecked (true);
3590 void Main::windowHideNoteEditor()
3592 textEditor->setShowWithMain(false);
3594 actionViewToggleNoteEditor->setChecked (false);
3597 void Main::setScript (const QString &script)
3599 scriptEditor->setScript (script);
3602 void Main::runScript (const QString &script)
3604 VymModel *m=currentModel();
3605 if (m) m->runScript (script);
3608 void Main::runScriptEverywhere (const QString &script)
3611 for (int i=0;i<=tabWidget->count() -1;i++)
3613 me=(MapEditor*)tabWidget->page(i);
3614 if (me) me->getModel()->runScript (script);
3618 void Main::windowNextEditor()
3620 if (tabWidget->currentIndex() < tabWidget->count())
3621 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3624 void Main::windowPreviousEditor()
3626 if (tabWidget->currentIndex() >0)
3627 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3630 void Main::standardFlagChanged()
3634 if ( actionSettingsUseFlagGroups->isOn() )
3635 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3637 currentModel()->toggleStandardFlag(sender()->name());
3642 void Main::testFunction1()
3644 if (!currentMapEditor()) return;
3645 currentMapEditor()->testFunction1();
3648 VymModel *m=currentModel();
3652 QString text = QInputDialog::getText(
3653 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3654 m->getSortFilter(), &ok, NULL);
3656 // user entered something and pressed OK
3657 m->setSortFilter (text);
3661 void Main::testFunction2()
3663 if (!currentMapEditor()) return;
3664 currentMapEditor()->testFunction2();
3667 void Main::testCommand()
3669 if (!currentMapEditor()) return;
3670 scriptEditor->show();
3673 QString com = QInputDialog::getText(
3674 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3675 if (ok) currentMapEditor()->parseAtom(com);
3679 void Main::helpDoc()
3681 QString locale = QLocale::system().name();
3683 if (locale.left(2)=="es")
3684 docname="vym_es.pdf";
3688 QStringList searchList;
3690 #if defined(Q_OS_MACX)
3691 searchList << "./vym.app/Contents/Resources/doc";
3692 #elif defined(Q_OS_WIN32)
3693 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3695 #if defined(VYM_DOCDIR)
3696 searchList << VYM_DOCDIR;
3698 // default path in SUSE LINUX
3699 searchList << "/usr/share/doc/packages/vym";
3702 searchList << "doc"; // relative path for easy testing in tarball
3703 searchList << "doc/tex"; // Easy testing working on vym.tex
3704 searchList << "/usr/share/doc/vym"; // Debian
3705 searchList << "/usr/share/doc/packages";// Knoppix
3709 for (int i=0; i<searchList.count(); ++i)
3711 docfile.setFileName(searchList.at(i)+"/"+docname);
3712 if (docfile.exists())
3721 QMessageBox::critical(0,
3722 tr("Critcal error"),
3723 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3728 Process *pdfProc = new Process();
3729 args << QDir::toNativeSeparators(docfile.fileName());
3731 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3734 QMessageBox::warning(0,
3736 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3737 tr("Please use Settings->")+tr("Set application to open PDF files"));
3744 void Main::helpDemo()
3746 QStringList filters;
3747 filters <<"VYM example map (*.vym)";
3748 QFileDialog *fd=new QFileDialog( this);
3749 #if defined(Q_OS_MACX)
3750 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3752 // default path in SUSE LINUX
3753 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3756 fd->setFileMode (QFileDialog::ExistingFiles);
3757 fd->setFilters (filters);
3758 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3762 if ( fd->exec() == QDialog::Accepted )
3764 lastFileDir=fd->directory().path();
3765 QStringList flist = fd->selectedFiles();
3766 QStringList::Iterator it = flist.begin();
3767 while( it != flist.end() )
3770 fileLoad(*it, NewMap);
3778 void Main::helpAbout()
3781 ad.setName ("aboutwindow");
3782 ad.setMinimumSize(500,500);
3783 ad.resize (QSize (500,500));
3787 void Main::helpAboutQT()
3789 QMessageBox::aboutQt( this, "Qt Application Example" );
3792 void Main::callMacro ()
3794 QAction *action = qobject_cast<QAction *>(sender());
3798 i=action->data().toInt();
3799 QString mDir (settings.value ("macros/macroDir").toString() );
3801 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3803 if ( !f.open( QIODevice::ReadOnly ) )
3805 QMessageBox::warning(0,
3807 tr("Couldn't find a macro at %1.\n").arg(fn)+
3808 tr("Please use Settings->")+tr("Set directory for vym macros"));
3812 QTextStream ts( &f );
3813 QString macro= ts.read();
3815 if (! macro.isEmpty())
3817 VymModel *m=currentModel();
3818 if (m) m->runScript(macro);