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* branchXLinksContextMenuFollow;
62 QMenu* floatimageContextMenu;
63 QMenu* canvasContextMenu;
64 QMenu* fileLastMapsMenu;
65 QMenu* fileImportMenu;
66 QMenu* fileExportMenu;
69 extern Settings settings;
70 extern Options options;
71 extern ImageIO imageIO;
73 extern QDir vymBaseDir;
74 extern QDir lastImageDir;
75 extern QDir lastFileDir;
76 #if defined(Q_OS_WIN32)
77 extern QDir vymInstallDir;
79 extern QString iconPath;
80 extern QString flagsPath;
83 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
84 QMainWindow(parent,name,f)
88 setCaption ("VYM - View Your Mind");
90 // Load window settings
91 #if defined(Q_OS_WIN32)
92 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
94 setWindowState(Qt::WindowMaximized);
99 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
100 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
103 // Sometimes we may need to remember old selections
107 currentColor=Qt::black;
109 // Create unique temporary directory
111 tmpVymDir=makeTmpDir (ok,"vym");
114 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
117 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
119 // Create direcctory for clipboard
120 clipboardDir=tmpVymDir+"/clipboard";
121 clipboardFile="map.xml";
122 QDir d(clipboardDir);
123 d.mkdir (clipboardDir,true);
124 makeSubDirs (clipboardDir);
127 browserPID=new qint64;
130 // Satellite windows //////////////////////////////////////////
132 historyWindow=new HistoryWindow();
133 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
136 branchPropertyWindow = new BranchPropertyWindow();
137 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
139 // Connect TextEditor, so that we can update flags if text changes
140 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
141 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
143 // Initialize script editor
144 scriptEditor = new SimpleScriptEditor();
145 scriptEditor->move (50,50);
147 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
148 this, SLOT( runScript( QString ) ) );
150 // Initialize some settings, which are platform dependant
153 // application to open URLs
154 p="/mainwindow/readerURL";
155 #if defined(Q_OS_LINUX)
156 s=settings.value (p,"xdg-open").toString();
158 #if defined(Q_OS_MACX)
159 s=settings.value (p,"/usr/bin/open").toString();
162 #if defined(Q_OS_WIN32)
163 // Assume that system has been set up so that
164 // Explorer automagically opens up the URL
165 // in the user's preferred browser.
166 s=settings.value (p,"explorer").toString();
168 s=settings.value (p,"mozilla").toString();
172 settings.setValue( p,s);
174 // application to open PDFs
175 p="/mainwindow/readerPDF";
176 #if defined(Q_OS_LINUX)
177 s=settings.value (p,"xdg-open").toString();
179 #if defined(Q_OS_MACX)
180 s=settings.value (p,"/usr/bin/open").toString();
181 #elif defined(Q_OS_WIN32)
182 s=settings.value (p,"acrord32").toString();
184 s=settings.value (p,"acroread").toString();
187 settings.setValue( p,s);
189 // width of xLinksMenu
192 // Create tab widget which holds the maps
193 tabWidget= new QTabWidget (this);
194 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
195 this, SLOT( editorChanged( QWidget * ) ) );
197 setCentralWidget(tabWidget);
201 setupFormatActions();
205 setupNetworkActions();
206 setupSettingsActions();
209 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
212 // Status bar and progress bar there
215 progressBar=new QProgressBar;
217 statusBar()->addPermanentWidget(progressBar);
219 restoreState (settings.value("/mainwindow/state",0).toByteArray());
227 #if defined(Q_OS_WIN32)
228 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
230 settings.setValue ("/mainwindow/geometry/size", size());
231 settings.setValue ("/mainwindow/geometry/pos", pos());
232 settings.setValue ("/mainwindow/state",saveState(0));
234 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
235 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
236 settings.setValue( "/version/version", vymVersion );
237 settings.setValue( "/version/builddate", vymBuildDate );
239 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
240 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
241 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
242 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
243 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
244 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
245 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
246 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
248 //TODO save scriptEditor settings
250 // call the destructors
252 delete historyWindow;
253 delete branchPropertyWindow;
256 // Remove temporary directory
257 removeDir (QDir(tmpVymDir));
260 void Main::loadCmdLine()
262 /* TODO draw some kind of splashscreen while loading...
268 QStringList flist=options.getFileList();
269 QStringList::Iterator it=flist.begin();
271 while (it !=flist.end() )
273 fileLoad (*it, NewMap);
279 void Main::statusMessage(const QString &s)
281 // Surpress messages while progressbar during
283 if (progressMin==progressMax)
284 statusBar()->message( s);
287 void Main::setProgressMinimum (int min)
289 progressBar->setMinimum(min);
293 void Main::setProgressMaximum (int max)
295 progressBar->setMaximum(max);
299 statusBar()->addPermanentWidget(progressBar);
304 void Main::setProgressValue (int v)
306 progressBar->setValue (v);
309 void Main::removeProgressBar()
312 statusBar()->removeWidget(progressBar);
313 progressMax=progressMin=0;
316 void Main::closeEvent (QCloseEvent* )
322 void Main::setupFileActions()
324 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
325 QToolBar *tb = addToolBar( tr ("&Map") );
326 tb->setObjectName ("mapTB");
329 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
330 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
331 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
333 fileMenu->addAction (a);
334 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
336 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
337 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
338 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
339 fileMenu->addAction (a);
340 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
343 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
344 a->setStatusTip (tr( "Open","Status tip File menu" ) );
345 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
347 fileMenu->addAction (a);
348 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
350 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
351 fileMenu->addSeparator();
353 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
354 a->setStatusTip ( tr( "Save","Status tip file menu" ));
355 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
357 fileMenu->addAction (a);
358 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
361 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
362 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
363 fileMenu->addAction (a);
364 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
366 fileMenu->addSeparator();
368 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
370 a = new QAction(tr("KDE 3 Bookmarks"), this);
371 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
372 a->addTo (fileImportMenu);
373 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
375 a = new QAction(tr("KDE 4 Bookmarks"), this);
376 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
377 a->addTo (fileImportMenu);
378 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
380 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
382 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
383 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
384 a->addTo (fileImportMenu);
385 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
388 a = new QAction("Freemind...",this);
389 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
390 fileImportMenu->addAction (a);
391 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
393 a = new QAction("Mind Manager...",this);
394 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
395 fileImportMenu->addAction (a);
396 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
398 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
399 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
400 fileImportMenu->addAction (a);
401 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
403 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
405 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
406 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
407 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
408 fileExportMenu->addAction (a);
410 a = new QAction( "Open Office...", this);
411 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
412 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
413 fileExportMenu->addAction (a);
415 a = new QAction( "Webpage (XHTML)...",this );
416 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
417 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
418 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
419 fileExportMenu->addAction (a);
421 a = new QAction( "Text (A&O report)...", this);
422 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
423 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
424 fileExportMenu->addAction (a);
426 a = new QAction( "Text (ASCII)...", this);
427 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
428 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
429 fileExportMenu->addAction (a);
431 a = new QAction( "Spreadsheet (CSV)...", this);
432 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
433 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
434 fileExportMenu->addAction (a);
436 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
437 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
438 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
439 fileExportMenu->addAction (a);
441 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
442 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
443 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
444 fileExportMenu->addAction (a);
446 a = new QAction( "Taskjuggler...", this );
447 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
448 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
449 fileExportMenu->addAction (a);
451 a = new QAction( "LaTeX...", this);
452 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
453 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
454 fileExportMenu->addAction (a);
456 a = new QAction( "XML..." , this );
457 a->setStatusTip (tr( "Export as %1").arg("XML"));
458 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
459 fileExportMenu->addAction (a);
461 fileMenu->addSeparator();
463 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
464 a->setStatusTip ( tr( "Print" ,"File menu") );
465 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
467 fileMenu->addAction (a);
468 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
471 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
472 a->setStatusTip (tr( "Close Map" ) );
473 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
474 fileMenu->addAction (a);
475 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
477 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
478 a->setStatusTip ( tr( "Exit")+" "+vymName );
479 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
480 fileMenu->addAction (a);
481 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
486 void Main::setupEditActions()
488 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
489 tb->setLabel( "Edit Actions" );
490 tb->setObjectName ("actionsTB");
491 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
495 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
496 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
497 a->setStatusTip (tr( "Undo" ) );
498 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
499 a->setEnabled (false);
501 editMenu->addAction (a);
504 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
505 a->setStatusTip (tr( "Redo" ));
506 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
508 editMenu->addAction (a);
509 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
512 editMenu->addSeparator();
513 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
514 a->setStatusTip ( tr( "Copy" ) );
515 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
516 a->setEnabled (false);
518 editMenu->addAction (a);
519 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
522 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
523 a->setStatusTip ( tr( "Cut" ) );
524 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
525 a->setEnabled (false);
527 editMenu->addAction (a);
529 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
531 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
532 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
533 a->setStatusTip ( tr( "Paste" ) );
534 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
535 a->setEnabled (false);
537 editMenu->addAction (a);
540 // Shortcut to delete selection
541 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
542 a->setStatusTip (tr( "Delete Selection" ));
543 a->setShortcut ( Qt::Key_Delete); //Delete selection
544 a->setShortcutContext (Qt::WindowShortcut);
546 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
549 // Shortcut to add attribute
550 a= new QAction(tr( "Add attribute" ), this);
551 a->setShortcut ( Qt::Key_Q);
552 a->setShortcutContext (Qt::WindowShortcut);
554 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
555 actionAddAttribute= a;
558 // Shortcut to add mapcenter
559 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
560 a->setShortcut ( Qt::Key_M);
561 a->setShortcutContext (Qt::WindowShortcut);
562 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
563 //actionListBranches.append(a);
565 actionAddMapCenter = a;
568 // Shortcut to add branch
569 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
570 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
571 alt->setShortcut (Qt::Key_A); //Add branch
572 alt->setShortcutContext (Qt::WindowShortcut);
574 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
575 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
576 a->setStatusTip ( tr( "Add a branch as child of selection" ));
577 a->setShortcut (Qt::Key_Insert); //Add branch
578 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
579 actionListBranches.append(a);
580 #if defined (Q_OS_MACX)
581 // In OSX show different shortcut in menues, the keys work indepently always
586 editMenu->addAction (actionAddBranch);
587 tb->addAction (actionAddBranch);
590 // Add branch by inserting it at selection
591 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
592 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
593 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
594 a->setShortcutContext (Qt::WindowShortcut);
596 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
597 a->setEnabled (false);
598 actionListBranches.append(a);
599 actionAddBranchBefore=a;
600 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
601 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
602 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
603 a->setShortcutContext (Qt::WindowShortcut);
605 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
606 actionListBranches.append(a);
609 a = new QAction(tr( "Add branch above","Edit menu" ), this);
610 a->setStatusTip ( tr( "Add a branch above selection" ));
611 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
612 a->setShortcutContext (Qt::WindowShortcut);
614 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
615 a->setEnabled (false);
616 actionListBranches.append(a);
617 actionAddBranchAbove=a;
618 a = new QAction(tr( "Add branch above","Edit menu" ), this);
619 a->setStatusTip ( tr( "Add a branch above selection" ));
620 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
621 a->setShortcutContext (Qt::WindowShortcut);
623 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
624 actionListBranches.append(a);
627 a = new QAction(tr( "Add branch below","Edit menu" ), this);
628 a->setStatusTip ( tr( "Add a branch below selection" ));
629 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
630 a->setShortcutContext (Qt::WindowShortcut);
632 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
633 a->setEnabled (false);
634 actionListBranches.append(a);
635 actionAddBranchBelow=a;
636 a = new QAction(tr( "Add branch below","Edit menu" ), this);
637 a->setStatusTip ( tr( "Add a branch below selection" ));
638 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
639 a->setShortcutContext (Qt::WindowShortcut);
641 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
642 actionListBranches.append(a);
644 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
645 a->setStatusTip ( tr( "Move branch up" ) );
646 a->setShortcut (Qt::Key_PageUp ); // Move branch up
647 a->setEnabled (false);
649 editMenu->addAction (a);
650 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
653 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
654 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
655 a->setStatusTip (tr( "Move branch down" ) );
656 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
657 a->setEnabled (false);
659 editMenu->addAction (a);
662 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
663 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
664 a->setShortcut ( Qt::Key_D ); // Detach branch
665 editMenu->addAction (a);
666 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
669 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
670 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
671 a->setEnabled (true);
673 editMenu->addAction (a);
674 actionSortChildren=a;
676 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
677 alt->setShortcut ( Qt::Key_S ); // Scroll branch
678 alt->setStatusTip (tr( "Scroll branch" ));
679 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
680 #if defined(Q_OS_MACX)
681 actionToggleScroll=alt;
683 actionToggleScroll=a;
685 actionToggleScroll->setEnabled (false);
686 actionToggleScroll->setToggleAction(true);
687 tb->addAction (actionToggleScroll);
688 editMenu->addAction ( actionToggleScroll);
689 editMenu->addAction (actionToggleScroll);
692 actionListBranches.append(actionToggleScroll);
694 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
695 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
696 a->setStatusTip (tr( "Expand all branches" ));
697 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
699 actionExpandAll->setEnabled (false);
700 actionExpandAll->setToggleAction(false);
701 //tb->addAction (actionExpandAll);
702 editMenu->addAction ( actionExpandAll);
704 actionListBranches.append(actionExpandAll);
706 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
707 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
708 a->setStatusTip (tr( "Expand one level in tree editor" ));
709 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
710 a->setEnabled (false);
711 a->setToggleAction(false);
712 actionExpandOneLevel=a;
714 editMenu->addAction ( a);
716 actionListBranches.append(a);
718 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
719 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
720 a->setStatusTip (tr( "Collapse one level in tree editor" ));
721 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
722 a->setEnabled (false);
723 a->setToggleAction(false);
724 actionCollapseOneLevel=a;
726 editMenu->addAction ( a);
728 actionListBranches.append(a);
730 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
731 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
732 editMenu->addAction (a);
733 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
735 editMenu->addSeparator();
737 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
738 a->setStatusTip (tr( "Find" ) );
739 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
740 editMenu->addAction (a);
741 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
743 editMenu->addSeparator();
745 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
746 a->setShortcut (Qt::SHIFT + Qt::Key_U );
747 a->setShortcut (tr( "Open URL" ));
750 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
753 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
754 a->setStatusTip (tr( "Open URL in new tab" ));
755 //a->setShortcut (Qt::CTRL+Qt::Key_U );
757 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
760 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
761 a->setStatusTip (tr( "Open all URLs in subtree" ));
762 a->setShortcut ( Qt::CTRL + Qt::Key_U );
764 actionListBranches.append(a);
765 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
766 actionOpenMultipleURLTabs=a;
768 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
769 a->setStatusTip ( tr( "Edit URL" ) );
770 a->setShortcut ( Qt::Key_U );
771 a->setShortcutContext (Qt::WindowShortcut);
772 actionListBranches.append(a);
774 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
777 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
778 a->setStatusTip ( tr( "Edit local URL" ) );
779 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
780 a->setShortcutContext (Qt::WindowShortcut);
781 actionListBranches.append(a);
783 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
786 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
787 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
788 a->setEnabled (false);
789 actionListBranches.append(a);
790 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
793 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
794 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
795 a->setEnabled (false);
796 actionListBranches.append(a);
797 a->setShortcut ( Qt::Key_B );
798 a->setShortcutContext (Qt::WindowShortcut);
800 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
801 actionBugzilla2URL=a;
803 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
804 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
805 a->setEnabled (false);
806 actionListBranches.append(a);
807 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
810 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
811 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
813 a->setEnabled (false);
814 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
817 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
818 a->setStatusTip ( tr( "Open all vym links in subtree" ));
819 a->setEnabled (false);
820 actionListBranches.append(a);
821 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
822 actionOpenMultipleVymLinks=a;
825 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
826 a->setEnabled (false);
827 a->setStatusTip ( tr( "Edit link to another vym map" ));
828 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
829 actionListBranches.append(a);
832 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
833 a->setStatusTip ( tr( "Delete link to another vym map" ));
834 a->setEnabled (false);
835 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
836 actionDeleteVymLink=a;
838 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
839 a->setStatusTip ( tr( "Hide object in exports" ) );
840 a->setShortcut (Qt::Key_H );
841 a->setToggleAction(true);
843 a->setEnabled (false);
844 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
845 actionToggleHideExport=a;
847 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
848 a->setStatusTip ( tr( "Add timestamp" ));
849 a->setEnabled (false);
850 actionListBranches.append(a);
851 a->setShortcut ( Qt::Key_T ); // Add timestamp
852 a->setShortcutContext (Qt::WindowShortcut);
854 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
855 actionAddTimestamp=a;
857 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
858 a->setStatusTip ( tr( "Edit Map Info" ));
859 a->setEnabled (true);
860 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
863 // Import at selection (adding to selection)
864 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
865 a->setStatusTip (tr( "Add map at selection" ));
866 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
867 a->setEnabled (false);
868 actionListBranches.append(a);
871 // Import at selection (replacing selection)
872 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
873 a->setStatusTip (tr( "Replace selection with map" ));
874 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
875 a->setEnabled (false);
876 actionListBranches.append(a);
877 actionImportReplace=a;
880 a = new QAction( tr( "Save selection","Edit menu" ), this);
881 a->setStatusTip (tr( "Save selection" ));
882 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
883 a->setEnabled (false);
884 actionListBranches.append(a);
887 // Only remove branch, not its children
888 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
889 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
890 a->setShortcut (Qt::ALT + Qt::Key_Delete );
891 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
892 a->setEnabled (false);
894 actionListBranches.append(a);
895 actionDeleteKeepChildren=a;
897 // Only remove children of a branch
898 a = new QAction( tr( "Remove children","Edit menu" ), this);
899 a->setStatusTip (tr( "Remove children of branch" ));
900 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
901 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
902 a->setEnabled (false);
903 actionListBranches.append(a);
904 actionDeleteChildren=a;
906 a = new QAction( tr( "Add Image...","Edit menu" ), this);
907 a->setStatusTip (tr( "Add Image" ));
908 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
911 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
912 a->setStatusTip (tr( "Set properties for selection" ));
913 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
914 a->setShortcutContext (Qt::WindowShortcut);
915 a->setToggleAction (true);
917 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
918 actionViewTogglePropertyWindow=a;
922 void Main::setupFormatActions()
924 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
926 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
927 tb->setObjectName ("formatTB");
930 pix.fill (Qt::black);
931 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
932 a->setStatusTip ( tr( "Set Color" ));
933 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
935 formatMenu->addAction (a);
937 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
938 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
939 a->setShortcut (Qt::CTRL + Qt::Key_K );
940 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
941 a->setEnabled (false);
943 formatMenu->addAction (a);
944 actionListBranches.append(a);
945 actionFormatPickColor=a;
947 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
948 a->setStatusTip ( tr( "Color branch" ) );
949 a->setShortcut (Qt::CTRL + Qt::Key_B);
950 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
951 a->setEnabled (false);
953 formatMenu->addAction (a);
954 actionListBranches.append(a);
955 actionFormatColorSubtree=a;
957 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
958 a->setStatusTip ( tr( "Color Subtree" ));
959 //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree
960 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
961 a->setEnabled (false);
962 formatMenu->addAction (a);
964 actionListBranches.append(a);
965 actionFormatColorSubtree=a;
967 formatMenu->addSeparator();
968 actionGroupFormatLinkStyles=new QActionGroup ( this);
969 actionGroupFormatLinkStyles->setExclusive (true);
970 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
971 a->setStatusTip (tr( "Line" ));
972 a->setToggleAction(true);
973 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
974 formatMenu->addAction (a);
975 actionFormatLinkStyleLine=a;
976 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
977 a->setStatusTip (tr( "Line" ));
978 a->setToggleAction(true);
979 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
980 formatMenu->addAction (a);
981 actionFormatLinkStyleParabel=a;
982 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
983 a->setStatusTip (tr( "PolyLine" ));
984 a->setToggleAction(true);
985 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
986 formatMenu->addAction (a);
987 actionFormatLinkStylePolyLine=a;
988 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
989 a->setStatusTip (tr( "PolyParabel" ) );
990 a->setToggleAction(true);
991 a->setChecked (true);
992 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
993 formatMenu->addAction (a);
994 actionFormatLinkStylePolyParabel=a;
996 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
997 a->setStatusTip (tr( "Hide link" ));
998 a->setToggleAction(true);
999 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1000 actionFormatHideLinkUnselected=a;
1002 formatMenu->addSeparator();
1003 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1004 a->setStatusTip (tr( "Use same color for links and headings" ));
1005 a->setToggleAction(true);
1006 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1007 formatMenu->addAction (a);
1008 actionFormatLinkColorHint=a;
1010 pix.fill (Qt::white);
1011 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1012 a->setStatusTip (tr( "Set Link Color" ));
1013 formatMenu->addAction (a);
1014 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1015 actionFormatLinkColor=a;
1017 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1018 a->setStatusTip (tr( "Set Selection Color" ));
1019 formatMenu->addAction (a);
1020 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1021 actionFormatSelectionColor=a;
1023 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1024 a->setStatusTip (tr( "Set Background Color" ));
1025 formatMenu->addAction (a);
1026 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1027 actionFormatBackColor=a;
1029 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1030 a->setStatusTip (tr( "Set Background image" ));
1031 formatMenu->addAction (a);
1032 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1033 actionFormatBackImage=a;
1037 void Main::setupViewActions()
1039 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1040 tb->setLabel( "View Actions" );
1041 tb->setObjectName ("viewTB");
1042 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1044 Switchboard switchboard; //FIXME-1 testing...
1047 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1048 a->setStatusTip ( tr( "Zoom reset" ) );
1049 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1050 switchboard.addConnection(a,"CTRL+0");
1052 viewMenu->addAction (a);
1053 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1055 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1056 a->setStatusTip (tr( "Zoom in" ));
1057 switchboard.addConnection(a,"CTRL++");
1059 viewMenu->addAction (a);
1060 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1062 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1063 a->setStatusTip (tr( "Zoom out" ));
1064 switchboard.addConnection(a,"CTRL+-");
1066 viewMenu->addAction (a);
1067 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1069 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1070 a->setStatusTip (tr( "Show selection" ));
1071 switchboard.addConnection(a,".");
1073 viewMenu->addAction (a);
1074 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1076 viewMenu->addSeparator();
1078 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1079 a->setStatusTip ( tr( "Show Note Editor" ));
1080 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1081 a->setToggleAction(true);
1083 viewMenu->addAction (a);
1084 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1085 actionViewToggleNoteEditor=a;
1087 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1088 a->setStatusTip ( tr( "Show History Window" ));
1089 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1090 a->setToggleAction(true);
1092 viewMenu->addAction (a);
1093 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1094 actionViewToggleHistoryWindow=a;
1096 viewMenu->addAction (actionViewTogglePropertyWindow);
1098 viewMenu->addSeparator();
1100 a = new QAction(tr( "Antialiasing","View action" ),this );
1101 a->setStatusTip ( tr( "Antialiasing" ));
1102 a->setToggleAction(true);
1103 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1104 viewMenu->addAction (a);
1105 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1106 actionViewToggleAntiAlias=a;
1108 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1109 a->setStatusTip (a->text());
1110 a->setToggleAction(true);
1111 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1112 viewMenu->addAction (a);
1113 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1114 actionViewToggleSmoothPixmapTransform=a;
1116 a = new QAction(tr( "Next Map","View action" ), this);
1117 a->setStatusTip (a->text());
1118 a->setShortcut (Qt::ALT + Qt::Key_N );
1119 viewMenu->addAction (a);
1120 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1122 a = new QAction (tr( "Previous Map","View action" ), this );
1123 a->setStatusTip (a->text());
1124 a->setShortcut (Qt::ALT + Qt::Key_P );
1125 viewMenu->addAction (a);
1126 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1128 switchboard.print();
1132 void Main::setupModeActions()
1134 //QPopupMenu *menu = new QPopupMenu( this );
1135 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1137 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1138 tb->setObjectName ("modesTB");
1140 actionGroupModModes=new QActionGroup ( this);
1141 actionGroupModModes->setExclusive (true);
1142 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1143 a->setShortcut (Qt::Key_J);
1144 a->setStatusTip ( tr( "Use modifier to color branches" ));
1145 a->setToggleAction(true);
1147 a->setChecked(true);
1148 actionModModeColor=a;
1150 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1151 a->setShortcut( Qt::Key_K);
1152 a->setStatusTip( tr( "Use modifier to copy" ));
1153 a->setToggleAction(true);
1155 actionModModeCopy=a;
1157 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1158 a->setShortcut (Qt::Key_L);
1159 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1160 a->setToggleAction(true);
1162 actionModModeXLink=a;
1166 void Main::setupFlagActions()
1168 // Create System Flags
1171 Flag *flag=new Flag;;
1172 flag->setVisible(true);
1174 flag->load(QPixmap(flagsPath+"flag-note.png"));
1175 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1177 flag->load(QPixmap(flagsPath+"flag-url.png"));
1178 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1180 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1181 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1183 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1184 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1186 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1187 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1189 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1190 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1192 // Create Standard Flags
1193 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1194 tb->setObjectName ("standardFlagTB");
1195 standardFlagsMaster->setToolBar (tb);
1197 flag->load(flagsPath+"flag-exclamationmark.png");
1198 flag->setGroup("standard-mark");
1199 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1201 flag->load(flagsPath+"flag-questionmark.png");
1202 flag->setGroup("standard-mark");
1203 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1205 flag->load(flagsPath+"flag-hook-green.png");
1206 flag->setGroup("standard-hook");
1207 setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
1209 flag->load(flagsPath+"flag-cross-red.png");
1210 flag->setGroup("standard-hook");
1211 setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
1214 flag->load(flagsPath+"flag-stopsign.png");
1215 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1217 flag->load(flagsPath+"flag-smiley-good.png");
1218 flag->setGroup("standard-smiley");
1219 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1221 flag->load(flagsPath+"flag-smiley-sad.png");
1222 flag->setGroup("standard-smiley");
1223 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1225 flag->load(flagsPath+"flag-smiley-omg.png");
1226 flag->setGroup("standard-smiley");
1227 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1228 // Original omg.png (in KDE emoticons)
1231 flag->load(flagsPath+"flag-kalarm.png");
1232 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1234 flag->load(flagsPath+"flag-phone.png");
1235 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1237 flag->load(flagsPath+"flag-lamp.png");
1238 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1240 flag->load(flagsPath+"flag-arrow-up.png");
1241 flag->setGroup("standard-arrow");
1242 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1244 flag->load(flagsPath+"flag-arrow-down.png");
1245 flag->setGroup("standard-arrow");
1246 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1248 flag->load(flagsPath+"flag-arrow-2up.png");
1249 flag->setGroup("standard-arrow");
1250 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1252 flag->load(flagsPath+"flag-arrow-2down.png");
1253 flag->setGroup("standard-arrow");
1254 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1257 flag->load(flagsPath+"flag-thumb-up.png");
1258 flag->setGroup("standard-thumb");
1259 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1261 flag->load(flagsPath+"flag-thumb-down.png");
1262 flag->setGroup("standard-thumb");
1263 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1266 flag->load(flagsPath+"flag-rose.png");
1267 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1269 flag->load(flagsPath+"flag-heart.png");
1270 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1272 flag->load(flagsPath+"flag-present.png");
1273 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1275 flag->load(flagsPath+"flag-flash.png");
1276 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1278 // Original: xsldbg_output.png
1279 flag->load(flagsPath+"flag-info.png");
1280 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1282 // Original khelpcenter.png
1283 flag->load(flagsPath+"flag-lifebelt.png");
1284 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1287 flag->setVisible(false);
1288 flag->load(flagsPath+"freemind/warning.png");
1289 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1291 for (int i=1; i<8; i++)
1293 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1294 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1297 flag->load(flagsPath+"freemind/back.png");
1298 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1300 flag->load(flagsPath+"freemind/forward.png");
1301 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1303 flag->load(flagsPath+"freemind/attach.png");
1304 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1306 flag->load(flagsPath+"freemind/clanbomber.png");
1307 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1309 flag->load(flagsPath+"freemind/desktopnew.png");
1310 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1312 flag->load(flagsPath+"freemind/flag.png");
1313 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1316 flag->load(flagsPath+"freemind/gohome.png");
1317 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1320 flag->load(flagsPath+"freemind/kaddressbook.png");
1321 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1323 flag->load(flagsPath+"freemind/knotify.png");
1324 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1326 flag->load(flagsPath+"freemind/korn.png");
1327 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1329 flag->load(flagsPath+"freemind/mail.png");
1330 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1332 flag->load(flagsPath+"freemind/password.png");
1333 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1335 flag->load(flagsPath+"freemind/pencil.png");
1336 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1338 flag->load(flagsPath+"freemind/stop.png");
1339 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1341 flag->load(flagsPath+"freemind/wizard.png");
1342 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1344 flag->load(flagsPath+"freemind/xmag.png");
1345 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1347 flag->load(flagsPath+"freemind/bell.png");
1348 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1350 flag->load(flagsPath+"freemind/bookmark.png");
1351 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1353 flag->load(flagsPath+"freemind/penguin.png");
1354 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1356 flag->load(flagsPath+"freemind/licq.png");
1357 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1360 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1362 flag->setName(name);
1363 flag->setToolTip (tooltip);
1367 a=new QAction (flag->getPixmap(),name,this);
1370 flag->setAction (a);
1371 a->setVisible (flag->isVisible());
1372 a->setCheckable(true);
1373 a->setObjectName(name);
1374 a->setToolTip(tooltip);
1375 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1376 standardFlagsMaster->addFlag (flag);
1380 systemFlagsMaster->addFlag (flag);
1385 void Main::setupNetworkActions()
1387 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1389 QMenu *netMenu = menuBar()->addMenu( "Network" );
1393 a = new QAction( "Start TCPserver for MapEditor",this);
1394 //a->setStatusTip ( "Set application to open pdf files"));
1395 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1396 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1397 netMenu->addAction (a);
1399 a = new QAction( "Connect MapEditor to server",this);
1400 //a->setStatusTip ( "Set application to open pdf files"));
1401 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1402 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1403 netMenu->addAction (a);
1407 void Main::setupSettingsActions()
1409 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1413 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1414 a->setStatusTip ( tr( "Set application to open pdf files"));
1415 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1416 settingsMenu->addAction (a);
1418 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1419 a->setStatusTip( tr( "Set application to open external links"));
1420 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1421 settingsMenu->addAction (a);
1423 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1424 a->setStatusTip( tr( "Set path for macros"));
1425 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1426 settingsMenu->addAction (a);
1428 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1429 a->setStatusTip( tr( "Set number of undo levels"));
1430 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1431 settingsMenu->addAction (a);
1433 settingsMenu->addSeparator();
1435 a = new QAction( tr( "Autosave","Settings action"), this);
1436 a->setStatusTip( tr( "Autosave"));
1437 a->setToggleAction(true);
1438 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1439 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1440 settingsMenu->addAction (a);
1441 actionSettingsAutosaveToggle=a;
1443 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1444 a->setStatusTip( tr( "Autosave time"));
1445 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1446 settingsMenu->addAction (a);
1447 actionSettingsAutosaveTime=a;
1449 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1450 a->setStatusTip( tr( "Write backup file on save"));
1451 a->setToggleAction(true);
1452 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1453 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1454 settingsMenu->addAction (a);
1455 actionSettingsWriteBackupFile=a;
1457 settingsMenu->addSeparator();
1459 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1460 a->setStatusTip( tr( "Edit branch after adding it" ));
1461 a->setToggleAction(true);
1462 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1463 settingsMenu->addAction (a);
1464 actionSettingsAutoEditNewBranch=a;
1466 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1467 a->setStatusTip( tr( "Select branch after adding it" ));
1468 a->setToggleAction(true);
1469 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1470 settingsMenu->addAction (a);
1471 actionSettingsAutoSelectNewBranch=a;
1473 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1474 a->setStatusTip( tr( "Select heading before editing" ));
1475 a->setToggleAction(true);
1476 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1477 settingsMenu->addAction (a);
1478 actionSettingsAutoSelectText=a;
1480 a= new QAction( tr( "Delete key","Settings action" ), this);
1481 a->setStatusTip( tr( "Delete key for deleting branches" ));
1482 a->setToggleAction(true);
1483 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1484 settingsMenu->addAction (a);
1485 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1486 actionSettingsUseDelKey=a;
1488 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1489 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1490 a->setToggleAction(true);
1491 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1492 settingsMenu->addAction (a);
1493 actionSettingsUseFlagGroups=a;
1495 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1496 a->setStatusTip( tr( "Use hide flag during exports " ));
1497 a->setToggleAction(true);
1498 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1499 settingsMenu->addAction (a);
1500 actionSettingsUseHideExport=a;
1502 a = new QAction( tr( "Animation","Settings action"), this);
1503 a->setStatusTip( tr( "Animation"));
1504 a->setToggleAction(true);
1505 a->setChecked (settings.value("/animation/use",true).toBool() );
1506 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1507 settingsMenu->addAction (a);
1508 actionSettingsUseAnimation=a;
1512 void Main::setupTestActions()
1514 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1517 a = new QAction( "Test function 1" , this);
1518 a->setStatusTip( "Call test function 1" );
1519 a->setShortcut (Qt::CTRL + Qt::Key_T); // Test function 1 //FIXME-2 originally: color subtree
1520 testMenu->addAction (a);
1521 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1523 a = new QAction( "Test function 2" , this);
1524 a->setStatusTip( "Call test function 2" );
1525 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 2
1526 testMenu->addAction (a);
1527 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1529 a = new QAction( "Command" , this);
1530 a->setStatusTip( "Enter command to call in editor" );
1531 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1532 testMenu->addAction (a);
1536 void Main::setupHelpActions()
1538 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1541 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1542 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1543 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1544 helpMenu->addAction (a);
1546 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1547 a->setStatusTip( tr( "Open VYM example maps " ));
1548 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1549 helpMenu->addAction (a);
1551 a = new QAction( tr( "About VYM","Help action" ), this);
1552 a->setStatusTip( tr( "About VYM")+vymName);
1553 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1554 helpMenu->addAction (a);
1556 a = new QAction( tr( "About QT","Help action" ), this);
1557 a->setStatusTip( tr( "Information about QT toolkit" ));
1558 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1559 helpMenu->addAction (a);
1563 void Main::setupContextMenus()
1567 // Context Menu for branch or mapcenter
1568 branchContextMenu =new QMenu (this);
1569 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1570 branchContextMenu->addSeparator();
1573 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1574 branchAddContextMenu->addAction (actionPaste );
1575 branchAddContextMenu->addAction ( actionAddMapCenter );
1576 branchAddContextMenu->addAction ( actionAddBranch );
1577 branchAddContextMenu->addAction ( actionAddBranchBefore );
1578 branchAddContextMenu->addAction ( actionAddBranchAbove);
1579 branchAddContextMenu->addAction ( actionAddBranchBelow );
1580 branchAddContextMenu->addSeparator();
1581 branchAddContextMenu->addAction ( actionImportAdd );
1582 branchAddContextMenu->addAction ( actionImportReplace );
1585 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1586 branchRemoveContextMenu->addAction (actionCut);
1587 branchRemoveContextMenu->addAction ( actionDelete );
1588 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1589 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1592 actionSaveBranch->addTo( branchContextMenu );
1593 actionFileNewCopy->addTo (branchContextMenu );
1594 actionDetach->addTo (branchContextMenu );
1596 branchContextMenu->addSeparator();
1597 branchContextMenu->addAction ( actionLoadImage);
1599 // Submenu for Links (URLs, vymLinks)
1600 branchLinksContextMenu =new QMenu (this);
1602 branchContextMenu->addSeparator();
1603 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1604 branchLinksContextMenu->addAction ( actionOpenURL );
1605 branchLinksContextMenu->addAction ( actionOpenURLTab );
1606 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1607 branchLinksContextMenu->addAction ( actionURL );
1608 branchLinksContextMenu->addAction ( actionLocalURL );
1609 branchLinksContextMenu->addAction ( actionHeading2URL );
1610 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1611 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1613 branchLinksContextMenu->addAction ( actionFATE2URL );
1615 branchLinksContextMenu->addSeparator();
1616 branchLinksContextMenu->addAction ( actionOpenVymLink );
1617 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1618 branchLinksContextMenu->addAction ( actionVymLink );
1619 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1622 // Context Menu for XLinks in a branch menu
1623 // This will be populated "on demand" in MapEditor::updateActions
1624 branchContextMenu->addSeparator();
1625 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1626 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1627 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1628 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1631 // Context menu for floatimage
1632 floatimageContextMenu =new QMenu (this);
1633 a= new QAction (tr ("Save image","Context action"),this);
1634 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1635 floatimageContextMenu->addAction (a);
1637 floatimageContextMenu->addSeparator();
1638 actionCopy->addTo( floatimageContextMenu );
1639 actionCut->addTo( floatimageContextMenu );
1641 floatimageContextMenu->addSeparator();
1642 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1645 // Context menu for canvas
1646 canvasContextMenu =new QMenu (this);
1647 actionAddMapCenter->addTo( canvasContextMenu );
1648 actionMapInfo->addTo( canvasContextMenu );
1649 canvasContextMenu->insertSeparator();
1650 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1651 canvasContextMenu->insertSeparator();
1652 actionFormatLinkColorHint->addTo( canvasContextMenu );
1653 actionFormatLinkColor->addTo( canvasContextMenu );
1654 actionFormatSelectionColor->addTo( canvasContextMenu );
1655 actionFormatBackColor->addTo( canvasContextMenu );
1656 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1658 // Menu for last opened files
1660 for (int i = 0; i < MaxRecentFiles; ++i)
1662 recentFileActions[i] = new QAction(this);
1663 recentFileActions[i]->setVisible(false);
1664 fileLastMapsMenu->addAction(recentFileActions[i]);
1665 connect(recentFileActions[i], SIGNAL(triggered()),
1666 this, SLOT(fileLoadRecent()));
1668 setupRecentMapsMenu();
1671 void Main::setupRecentMapsMenu()
1673 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1675 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1677 for (int i = 0; i < numRecentFiles; ++i) {
1678 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1679 recentFileActions[i]->setText(text);
1680 recentFileActions[i]->setData(files[i]);
1681 recentFileActions[i]->setVisible(true);
1683 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1684 recentFileActions[j]->setVisible(false);
1687 void Main::setupMacros()
1689 for (int i = 0; i <= 11; i++)
1691 macroActions[i] = new QAction(this);
1692 macroActions[i]->setData(i);
1693 addAction (macroActions[i]);
1694 connect(macroActions[i], SIGNAL(triggered()),
1695 this, SLOT(callMacro()));
1697 macroActions[0]->setShortcut ( Qt::Key_F1 );
1698 macroActions[1]->setShortcut ( Qt::Key_F2 );
1699 macroActions[2]->setShortcut ( Qt::Key_F3 );
1700 macroActions[3]->setShortcut ( Qt::Key_F4 );
1701 macroActions[4]->setShortcut ( Qt::Key_F5 );
1702 macroActions[5]->setShortcut ( Qt::Key_F6 );
1703 macroActions[6]->setShortcut ( Qt::Key_F7 );
1704 macroActions[7]->setShortcut ( Qt::Key_F8 );
1705 macroActions[8]->setShortcut ( Qt::Key_F9 );
1706 macroActions[9]->setShortcut ( Qt::Key_F10 );
1707 macroActions[10]->setShortcut ( Qt::Key_F11 );
1708 macroActions[11]->setShortcut ( Qt::Key_F12 );
1711 void Main::hideEvent (QHideEvent * )
1713 if (!textEditor->isMinimized() ) textEditor->hide();
1716 void Main::showEvent (QShowEvent * )
1718 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1722 MapEditor* Main::currentMapEditor() const
1724 if ( tabWidget->currentPage())
1725 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1729 VymModel* Main::currentModel() const
1731 if ( tabWidget->currentPage())
1732 return vymViews.at(tabWidget->currentIndex())->getModel();
1737 void Main::editorChanged(QWidget *)
1739 // Unselect all possibly selected objects
1740 // (Important to update note editor)
1742 for (int i=0;i<=tabWidget->count() -1;i++)
1744 m= vymViews.at(i)->getModel();
1745 if (m) m->unselect();
1748 if (m) m->reselect();
1750 // Update actions to in menus and toolbars according to editor
1754 void Main::fileNew()
1756 VymModel *vm=new VymModel;
1758 /////////////////////////////////////
1759 new ModelTest(vm, this); //FIXME-3
1760 /////////////////////////////////////
1762 VymView *vv=new VymView (vm);
1763 vymViews.append (vv);
1764 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1765 tabWidget->setCurrentIndex (vymViews.count() );
1768 // Create MapCenter for empty map
1772 // For the very first map we do not have flagrows yet...
1776 void Main::fileNewCopy()
1778 QString fn="unnamed";
1779 VymModel *srcModel=currentModel();
1784 VymModel *dstModel=vymViews.last()->getModel();
1785 dstModel->select("mc:");
1786 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1790 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1792 ErrorCode err=success;
1794 // fn is usually the archive, mapfile the file after uncompressing
1797 // Make fn absolute (needed for unzip)
1798 fn=QDir (fn).absPath();
1804 // Check, if map is already loaded
1806 while (i<=tabWidget->count() -1)
1808 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1810 // Already there, ask for confirmation
1811 QMessageBox mb( vymName,
1812 tr("The map %1\nis already opened."
1813 "Opening the same map in multiple editors may lead \n"
1814 "to confusion when finishing working with vym."
1815 "Do you want to").arg(fn),
1816 QMessageBox::Warning,
1817 QMessageBox::Yes | QMessageBox::Default,
1818 QMessageBox::Cancel | QMessageBox::Escape,
1819 QMessageBox::NoButton);
1820 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1821 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1824 case QMessageBox::Yes:
1825 // end loop and load anyway
1826 i=tabWidget->count();
1828 case QMessageBox::Cancel:
1838 int tabIndex=tabWidget->currentPageIndex();
1841 if ( !fn.isEmpty() )
1843 vm = currentModel();
1844 // Check first, if mapeditor exists
1845 // If it is not default AND we want a new map,
1846 // create a new mapeditor in a new tab
1847 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1850 VymView *vv=new VymView (vm);
1851 vymViews.append (vv);
1852 tabWidget->addTab (vv,fn);
1853 tabIndex=tabWidget->count()-1;
1854 tabWidget->setCurrentPage (tabIndex);
1858 // Check, if file exists (important for creating new files
1859 // from command line
1860 if (!QFile(fn).exists() )
1862 QMessageBox mb( vymName,
1863 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1864 QMessageBox::Question,
1866 QMessageBox::Cancel | QMessageBox::Default,
1867 QMessageBox::NoButton );
1869 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1870 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1873 case QMessageBox::Yes:
1875 currentMapEditor()->getModel()->setFilePath(fn);
1876 tabWidget->setTabText (tabIndex,
1877 currentMapEditor()->getModel()->getFileName() );
1878 statusBar()->message( "Created " + fn , statusbarTime );
1881 case QMessageBox::Cancel:
1882 // don't create new map
1883 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1890 //tabWidget->currentPage() won't be NULL here, because of above...
1891 tabWidget->setCurrentIndex (tabIndex);
1892 //FIXME-3 no me anymore... me->viewport()->setFocus();
1896 // Save existing filename in case we import
1897 QString fn_org=vm->getFilePath();
1899 // Finally load map into mapEditor
1900 vm->setFilePath (fn);
1901 err=vm->load(fn,lmode,ftype);
1903 // Restore old (maybe empty) filepath, if this is an import
1905 vm->setFilePath (fn_org);
1908 // Finally check for errors and go home
1911 if (lmode==NewMap) fileCloseMap();
1912 statusBar()->message( "Could not load " + fn, statusbarTime );
1917 vm->setFilePath (fn);
1918 tabWidget->setTabText (tabIndex, vm->getFileName());
1919 if (!isInTmpDir (fn))
1921 // Only append to lastMaps if not loaded from a tmpDir
1922 // e.g. imported bookmarks are in a tmpDir
1923 addRecentMap(vm->getFilePath() );
1925 actionFilePrint->setEnabled (true);
1927 statusBar()->message( "Loaded " + fn, statusbarTime );
1934 void Main::fileLoad(const LoadMode &lmode)
1936 QStringList filters;
1937 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1938 QFileDialog *fd=new QFileDialog( this);
1939 fd->setDir (lastFileDir);
1940 fd->setFileMode (QFileDialog::ExistingFiles);
1941 fd->setFilters (filters);
1945 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1948 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1951 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1957 if ( fd->exec() == QDialog::Accepted )
1959 lastFileDir=fd->directory().path();
1960 QStringList flist = fd->selectedFiles();
1961 QStringList::Iterator it = flist.begin();
1962 while( it != flist.end() )
1965 fileLoad(*it, lmode);
1972 void Main::fileLoad()
1977 void Main::fileLoadRecent()
1979 QAction *action = qobject_cast<QAction *>(sender());
1981 fileLoad (action->data().toString(), NewMap);
1984 void Main::addRecentMap (const QString &fileName)
1987 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1988 files.removeAll(fileName);
1989 files.prepend(fileName);
1990 while (files.size() > MaxRecentFiles)
1993 settings.setValue("/mainwindow/recentFileList", files);
1995 setupRecentMapsMenu();
1998 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2002 if ( m->getFilePath().isEmpty() )
2004 // We have no filepath yet,
2005 // call fileSaveAs() now, this will call fileSave()
2007 // First switch to editor
2008 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2009 fileSaveAs(savemode);
2012 if (m->save (savemode)==success)
2014 statusBar()->message(
2015 tr("Saved %1").arg(m->getFilePath()),
2017 addRecentMap (m->getFilePath() );
2019 statusBar()->message(
2020 tr("Couldn't save ").arg(m->getFilePath()),
2024 void Main::fileSave()
2026 fileSave (currentModel(), CompleteMap);
2029 void Main::fileSave(VymModel *m)
2031 fileSave (m,CompleteMap);
2034 void Main::fileSaveAs(const SaveMode& savemode)
2038 if (currentMapEditor())
2040 if (savemode==CompleteMap)
2041 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2043 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2044 if ( !fn.isEmpty() )
2046 // Check for existing file
2047 if (QFile (fn).exists())
2049 QMessageBox mb( vymName,
2050 tr("The file %1\nexists already. Do you want to").arg(fn),
2051 QMessageBox::Warning,
2052 QMessageBox::Yes | QMessageBox::Default,
2053 QMessageBox::Cancel | QMessageBox::Escape,
2054 QMessageBox::NoButton);
2055 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2056 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2059 case QMessageBox::Yes:
2062 case QMessageBox::Cancel:
2069 // New file, add extension to filename, if missing
2070 // This is always .vym or .vyp, depending on savemode
2071 if (savemode==CompleteMap)
2073 if (!fn.contains (".vym") && !fn.contains (".xml"))
2077 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2086 VymModel *m=currentModel();
2088 fileSave(m, savemode);
2090 // Set name of tab, assuming current tab is the one we just saved
2091 if (savemode==CompleteMap)
2092 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2098 void Main::fileSaveAs()
2100 fileSaveAs (CompleteMap);
2103 void Main::fileImportKDE3Bookmarks()
2105 ImportKDE3Bookmarks im;
2107 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2108 currentMapEditor()->getModel()->setFilePath ("");
2111 void Main::fileImportKDE4Bookmarks()
2113 ImportKDE4Bookmarks im;
2115 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2116 currentMapEditor()->getModel()->setFilePath ("");
2119 void Main::fileImportFirefoxBookmarks()
2121 Q3FileDialog *fd=new Q3FileDialog( this);
2122 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2123 fd->setMode (Q3FileDialog::ExistingFiles);
2124 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2125 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2128 if ( fd->exec() == QDialog::Accepted )
2130 ImportFirefoxBookmarks im;
2131 QStringList flist = fd->selectedFiles();
2132 QStringList::Iterator it = flist.begin();
2133 while( it != flist.end() )
2136 if (im.transform() &&
2137 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2138 currentMapEditor() )
2139 currentMapEditor()->getModel()->setFilePath ("");
2146 void Main::fileImportFreemind()
2148 QStringList filters;
2149 filters <<"Freemind map (*.mm)"<<"All files (*)";
2150 QFileDialog *fd=new QFileDialog( this);
2151 fd->setDir (lastFileDir);
2152 fd->setFileMode (QFileDialog::ExistingFiles);
2153 fd->setFilters (filters);
2154 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2158 if ( fd->exec() == QDialog::Accepted )
2160 lastFileDir=fd->directory().path();
2161 QStringList flist = fd->selectedFiles();
2162 QStringList::Iterator it = flist.begin();
2163 while( it != flist.end() )
2166 if ( fileLoad (fn,NewMap, FreemindMap) )
2168 currentMapEditor()->getModel()->setFilePath ("");
2177 void Main::fileImportMM()
2181 Q3FileDialog *fd=new Q3FileDialog( this);
2182 fd->setDir (lastFileDir);
2183 fd->setMode (Q3FileDialog::ExistingFiles);
2184 fd->addFilter ("Mind Manager (*.mmap)");
2185 fd->setCaption(tr("Import")+" "+"Mind Manager");
2188 if ( fd->exec() == QDialog::Accepted )
2190 lastFileDir=fd->dirPath();
2191 QStringList flist = fd->selectedFiles();
2192 QStringList::Iterator it = flist.begin();
2193 while( it != flist.end() )
2196 if (im.transform() &&
2197 success==fileLoad (im.getTransformedFile(),NewMap) &&
2198 currentMapEditor() )
2199 currentMapEditor()->getModel()->setFilePath ("");
2206 void Main::fileImportDir()
2208 VymModel *m=currentModel();
2209 if (m) m->importDir();
2212 void Main::fileExportXML()
2214 VymModel *m=currentModel();
2215 if (m) m->exportXML();
2219 void Main::fileExportXHTML()
2221 VymModel *m=currentModel();
2222 if (m) m->exportXHTML();
2225 void Main::fileExportImage()
2227 VymModel *m=currentModel();
2228 if (m) m->exportImage();
2231 void Main::fileExportAO()
2233 VymModel *m=currentModel();
2234 if (m) m->exportAO();
2237 void Main::fileExportASCII()
2239 VymModel *m=currentModel();
2240 if (m) m->exportASCII();
2243 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2245 VymModel *m=currentModel();
2250 ex.addFilter ("CSV (*.csv)");
2251 ex.setDir(lastImageDir);
2252 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2253 if (ex.execDialog() )
2255 m->setExportMode(true);
2257 m->setExportMode(false);
2262 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2264 VymModel *m=currentModel();
2269 ex.addFilter ("Tex (*.tex)");
2270 ex.setDir(lastImageDir);
2271 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2272 if (ex.execDialog() )
2274 m->setExportMode(true);
2276 m->setExportMode(false);
2281 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2283 ExportKDE3Bookmarks ex;
2284 VymModel *m=currentModel();
2292 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2294 ExportKDE4Bookmarks ex;
2295 VymModel *m=currentModel();
2303 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2305 ExportTaskjuggler ex;
2306 VymModel *m=currentModel();
2310 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2311 ex.setDir(lastImageDir);
2312 ex.addFilter ("Taskjuggler (*.tjp)");
2313 if (ex.execDialog() )
2315 m->setExportMode(true);
2317 m->setExportMode(false);
2322 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2324 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2325 // TODO add preview in dialog
2326 //ImagePreview *p =new ImagePreview (fd);
2327 //fd->setContentsPreviewEnabled( TRUE );
2328 //fd->setContentsPreview( p, p );
2329 //fd->setPreviewMode( QFileDialog::Contents );
2330 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2331 fd->setDir (QDir().current());
2332 if (fd->foundConfig())
2336 if ( fd->exec() == QDialog::Accepted )
2338 QString fn=fd->selectedFile();
2339 if (!fn.contains (".odp"))
2342 //lastImageDir=fn.left(fn.findRev ("/"));
2343 VymModel *m=currentModel();
2344 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2348 QMessageBox::warning(0,
2350 tr("Couldn't find configuration for export to Open Office\n"));
2354 void Main::fileCloseMap()
2356 VymModel *m=currentModel();
2359 if (m->hasChanged())
2361 QMessageBox mb( vymName,
2362 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2363 QMessageBox::Warning,
2364 QMessageBox::Yes | QMessageBox::Default,
2366 QMessageBox::Cancel | QMessageBox::Escape );
2367 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2368 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2371 case QMessageBox::Yes:
2373 fileSave(m, CompleteMap);
2375 case QMessageBox::No:
2376 // close without saving
2378 case QMessageBox::Cancel:
2383 // And here comes the segfault, because removeTab triggers
2384 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2385 vymViews.removeAt (tabWidget->currentIndex() );
2386 tabWidget->removeTab (tabWidget->currentIndex() );
2388 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2389 // Better would be delete (me), but then we could have a Qt error:
2390 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2391 // So we only remove data now and call deconstructor when vym closes later
2392 // this needs to be moved to vymview... me->clear();
2393 // some model->clear is needed to free up memory ...
2395 delete (m->getMapEditor());
2402 void Main::filePrint()
2404 if (currentMapEditor())
2405 currentMapEditor()->print();
2408 void Main::fileExitVYM()
2410 // Check if one or more editors have changed
2412 for (i=0;i<=vymViews.count() -1;i++)
2414 // If something changed, ask what to do
2415 if (vymViews.at(i)->getModel()->hasChanged())
2417 tabWidget->setCurrentPage(i);
2418 QMessageBox mb( vymName,
2419 tr("This map is not saved yet. Do you want to"),
2420 QMessageBox::Warning,
2421 QMessageBox::Yes | QMessageBox::Default,
2423 QMessageBox::Cancel | QMessageBox::Escape );
2424 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2425 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2428 mb.setActiveWindow();
2429 switch( mb.exec() ) {
2430 case QMessageBox::Yes:
2431 // save (the changed editors) and exit
2432 fileSave(currentModel(), CompleteMap);
2434 case QMessageBox::No:
2435 // exit without saving
2437 case QMessageBox::Cancel:
2438 // don't save and don't exit
2442 } // loop over all MEs
2446 void Main::editUndo()
2448 VymModel *m=currentModel();
2452 void Main::editRedo()
2454 VymModel *m=currentModel();
2458 void Main::gotoHistoryStep (int i)
2460 VymModel *m=currentModel();
2461 if (m) m->gotoHistoryStep(i);
2464 void Main::editCopy()
2466 VymModel *m=currentModel();
2470 void Main::editPaste()
2472 VymModel *m=currentModel();
2476 void Main::editCut()
2478 VymModel *m=currentModel();
2482 void Main::editOpenFindWidget()
2484 VymModel *m=currentModel();
2485 if (m) m->emitShowFindWidget();
2488 void Main::openTabs(QStringList urls)
2490 if (!urls.isEmpty())
2494 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2495 if (*browserPID==0) //FIXME-2 need to check if browser is really still there instead of this
2497 QString u=urls.takeFirst();
2499 QString workDir=QDir::currentDirPath();
2500 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2502 // try to set path to browser
2503 QMessageBox::warning(0,
2505 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2506 tr("Please use Settings->")+tr("Set application to open an URL"));
2509 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2510 #if defined(Q_OS_WIN32)
2511 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2512 this->thread()->wait(3000);
2514 sleep (3); //FIXME-3 needed?
2518 if (browser.contains("konqueror"))
2520 for (int i=0; i<urls.size(); i++)
2523 // Try to open new tab in existing konqueror started previously by vym
2527 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2528 "konqueror-mainwindow#1"<<
2532 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2533 "/konqueror/MainWindow_1"<<
2537 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2538 if (!QProcess::startDetached ("qdbus",args))
2542 QMessageBox::warning(0,
2544 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2546 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2548 for (int i=0; i<urls.size(); i++)
2550 // Try to open new tab in firefox
2551 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2552 if (!QProcess::startDetached (browser,args))
2556 QMessageBox::warning(0,
2558 tr("Couldn't start %1 to open a new tab").arg(browser));
2561 QMessageBox::warning(0,
2563 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2567 void Main::editOpenURL()
2570 VymModel *m=currentModel();
2573 QString url=m->getURL();
2575 if (url=="") return;
2576 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2578 QString workDir=QDir::currentDirPath();
2579 if (!procBrowser->startDetached(browser,args))
2581 // try to set path to browser
2582 QMessageBox::warning(0,
2584 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2585 tr("Please use Settings->")+tr("Set application to open an URL"));
2590 void Main::editOpenURLTab()
2592 VymModel *m=currentModel();
2596 urls.append(m->getURL());
2600 void Main::editOpenMultipleURLTabs()
2602 VymModel *m=currentModel();
2612 void Main::editURL()
2614 VymModel *m=currentModel();
2615 if (m) m->editURL();
2618 void Main::editLocalURL()
2620 VymModel *m=currentModel();
2621 if (m) m->editLocalURL();
2624 void Main::editHeading2URL()
2626 VymModel *m=currentModel();
2627 if (m) m->editHeading2URL();
2630 void Main::editBugzilla2URL()
2632 VymModel *m=currentModel();
2633 if (m) m->editBugzilla2URL();
2636 void Main::editFATE2URL()
2638 VymModel *m=currentModel();
2639 if (m) m->editFATE2URL();
2642 void Main::editHeadingFinished(VymModel *m)
2646 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2647 !prevSelection.isEmpty())
2648 m->select(prevSelection);
2653 void Main::openVymLinks(const QStringList &vl)
2655 for (int j=0; j<vl.size(); j++)
2657 // compare path with already loaded maps
2660 for (i=0;i<=vymViews.count() -1;i++)
2662 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2671 if (!QFile(vl.at(j)).exists() )
2672 QMessageBox::critical( 0, tr( "Critical Error" ),
2673 tr("Couldn't open map %1").arg(vl.at(j)));
2676 fileLoad (vl.at(j), NewMap);
2677 tabWidget->setCurrentIndex (tabWidget->count()-1);
2680 // Go to tab containing the map
2681 tabWidget->setCurrentIndex (index);
2685 void Main::editOpenVymLink()
2687 VymModel *m=currentModel();
2691 vl.append(m->getVymLink());
2696 void Main::editOpenMultipleVymLinks()
2698 QString currentVymLink;
2699 VymModel *m=currentModel();
2702 QStringList vl=m->getVymLinks();
2707 void Main::editVymLink()
2709 VymModel *m=currentModel();
2714 void Main::editDeleteVymLink()
2716 VymModel *m=currentModel();
2717 if (m) m->deleteVymLink();
2720 void Main::editToggleHideExport()
2722 VymModel *m=currentModel();
2723 if (m) m->toggleHideExport();
2726 void Main::editAddTimestamp()
2728 VymModel *m=currentModel();
2729 if (m) m->addTimestamp();
2732 void Main::editMapInfo()
2734 VymModel *m=currentModel();
2737 ExtraInfoDialog dia;
2738 dia.setMapName (m->getFileName() );
2739 dia.setAuthor (m->getAuthor() );
2740 dia.setComment(m->getComment() );
2744 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2750 BranchItem *cur=NULL;
2751 BranchItem *prev=NULL;
2752 m->nextBranch(cur,prev);
2755 if (!cur->getNote().isEmpty() ) n++;
2756 f+= cur->imageCount();
2758 xl+=cur->xlinkCount();
2759 m->nextBranch(cur,prev);
2762 stats+=QString ("%1 xLinks \n").arg (xl,6);
2763 stats+=QString ("%1 notes\n").arg (n,6);
2764 stats+=QString ("%1 images\n").arg (f,6);
2765 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2766 dia.setStats (stats);
2768 // Finally show dialog
2769 if (dia.exec() == QDialog::Accepted)
2771 m->setAuthor (dia.getAuthor() );
2772 m->setComment (dia.getComment() );
2776 void Main::editMoveUp()
2778 VymModel *m=currentModel();
2782 void Main::editMoveDown()
2784 VymModel *m=currentModel();
2785 if (m) m->moveDown();
2788 void Main::editDetach()
2790 VymModel *m=currentModel();
2794 void Main::editSortChildren()
2796 VymModel *m=currentModel();
2797 if (m) m->sortChildren();
2800 void Main::editToggleScroll()
2802 VymModel *m=currentModel();
2803 if (m) m->toggleScroll();
2806 void Main::editExpandAll()
2808 VymModel *m=currentModel();
2809 if (m) m->emitExpandAll();
2812 void Main::editExpandOneLevel()
2814 VymModel *m=currentModel();
2815 if (m) m->emitExpandOneLevel();
2818 void Main::editCollapseOneLevel()
2820 VymModel *m=currentModel();
2821 if (m) m->emitCollapseOneLevel();
2824 void Main::editUnscrollChildren()
2826 VymModel *m=currentModel();
2827 if (m) m->unscrollChildren();
2830 void Main::editAddAttribute()
2832 VymModel *m=currentModel();
2833 if (m) m->addAttribute();
2836 void Main::editAddMapCenter()
2838 VymModel *m=currentModel();
2839 if (m) m->addMapCenter ();
2842 void Main::editNewBranch()
2844 VymModel *m=currentModel();
2847 BranchItem *bi=m->addNewBranch();
2850 if (actionSettingsAutoEditNewBranch->isOn()
2851 && !actionSettingsAutoSelectNewBranch->isOn() )
2852 prevSelection=m->getSelectString();
2854 prevSelection=QString();
2856 if (actionSettingsAutoSelectNewBranch->isOn()
2857 || actionSettingsAutoEditNewBranch->isOn())
2860 if (actionSettingsAutoEditNewBranch->isOn())
2861 currentMapEditor()->editHeading();
2866 void Main::editNewBranchBefore()
2868 VymModel *m=currentModel();
2871 BranchItem *bi=m->addNewBranchBefore();
2878 if (actionSettingsAutoEditNewBranch->isOn())
2880 if (!actionSettingsAutoSelectNewBranch->isOn())
2881 prevSelection=m->getSelectString(bi);
2882 currentMapEditor()->editHeading();
2887 void Main::editNewBranchAbove() // FIXME-1 can crash
2889 VymModel *m=currentModel();
2892 BranchItem *bi=m->addNewBranch (-1);
2900 if (actionSettingsAutoEditNewBranch->isOn())
2902 if (!actionSettingsAutoSelectNewBranch->isOn())
2903 prevSelection=m->getSelectString (bi);
2904 currentMapEditor()->editHeading();
2909 void Main::editNewBranchBelow()
2911 VymModel *m=currentModel();
2914 BranchItem *bi=m->addNewBranch (1);
2921 if (actionSettingsAutoEditNewBranch->isOn())
2923 if (!actionSettingsAutoSelectNewBranch->isOn())
2924 prevSelection=m->getSelectString(bi);
2925 currentMapEditor()->editHeading();
2930 void Main::editImportAdd()
2932 fileLoad (ImportAdd);
2935 void Main::editImportReplace()
2937 fileLoad (ImportReplace);
2940 void Main::editSaveBranch()
2942 fileSaveAs (PartOfMap);
2945 void Main::editDeleteKeepChildren()
2947 VymModel *m=currentModel();
2948 if (m) m->deleteKeepChildren();
2951 void Main::editDeleteChildren()
2953 VymModel *m=currentModel();
2954 if (m) m->deleteChildren();
2957 void Main::editDeleteSelection()
2959 VymModel *m=currentModel();
2960 if (m && actionSettingsUseDelKey->isOn())
2961 m->deleteSelection();
2964 void Main::editLoadImage()
2966 VymModel *m=currentModel();
2967 if (m) m->loadFloatImage();
2970 void Main::editSaveImage()
2972 VymModel *m=currentModel();
2973 if (m) m->saveFloatImage();
2976 void Main::editFollowXLink(QAction *a)
2979 VymModel *m=currentModel();
2981 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2984 void Main::editEditXLink(QAction *a)
2986 VymModel *m=currentModel();
2988 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2991 void Main::formatSelectColor()
2993 QColor col = QColorDialog::getColor((currentColor ), this );
2994 if ( !col.isValid() ) return;
2995 colorChanged( col );
2998 void Main::formatPickColor()
3000 VymModel *m=currentModel();
3002 colorChanged( m->getCurrentHeadingColor() );
3005 void Main::colorChanged(QColor c)
3007 QPixmap pix( 16, 16 );
3009 actionFormatColor->setIconSet( pix );
3013 void Main::formatColorBranch()
3015 VymModel *m=currentModel();
3016 if (m) m->colorBranch(currentColor);
3019 void Main::formatColorSubtree()
3021 VymModel *m=currentModel();
3022 if (m) m->colorSubtree (currentColor);
3025 void Main::formatLinkStyleLine()
3027 VymModel *m=currentModel();
3030 m->setMapLinkStyle("StyleLine");
3031 actionFormatLinkStyleLine->setChecked(true);
3035 void Main::formatLinkStyleParabel()
3037 VymModel *m=currentModel();
3040 m->setMapLinkStyle("StyleParabel");
3041 actionFormatLinkStyleParabel->setChecked(true);
3045 void Main::formatLinkStylePolyLine()
3047 VymModel *m=currentModel();
3050 m->setMapLinkStyle("StylePolyLine");
3051 actionFormatLinkStylePolyLine->setChecked(true);
3055 void Main::formatLinkStylePolyParabel()
3057 VymModel *m=currentModel();
3060 m->setMapLinkStyle("StylePolyParabel");
3061 actionFormatLinkStylePolyParabel->setChecked(true);
3065 void Main::formatSelectBackColor()
3067 VymModel *m=currentModel();
3068 if (m) m->selectMapBackgroundColor();
3071 void Main::formatSelectBackImage()
3073 VymModel *m=currentModel();
3075 m->selectMapBackgroundImage();
3078 void Main::formatSelectLinkColor()
3080 VymModel *m=currentModel();
3083 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3084 m->setMapDefLinkColor( col );
3088 void Main::formatSelectSelectionColor()
3090 VymModel *m=currentModel();
3093 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3094 m->setSelectionColor (col);
3099 void Main::formatToggleLinkColorHint()
3101 VymModel *m=currentModel();
3102 if (m) m->toggleMapLinkColorHint();
3106 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3108 VymModel *m=currentModel();
3110 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3113 void Main::viewZoomReset()
3115 MapEditor *me=currentMapEditor();
3116 if (me) me->setZoomFactorTarget (1);
3119 void Main::viewZoomIn()
3121 MapEditor *me=currentMapEditor();
3122 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3125 void Main::viewZoomOut()
3127 MapEditor *me=currentMapEditor();
3128 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3131 void Main::viewCenter()
3133 VymModel *m=currentModel();
3134 if (m) m->emitShowSelection();
3137 void Main::networkStartServer()
3139 VymModel *m=currentModel();
3140 if (m) m->newServer();
3143 void Main::networkConnect()
3145 VymModel *m=currentModel();
3146 if (m) m->connectToServer();
3149 bool Main::settingsPDF()
3151 // Default browser is set in constructor
3153 QString text = QInputDialog::getText(
3154 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3155 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3157 settings.setValue ("/mainwindow/readerPDF",text);
3162 bool Main::settingsURL()
3164 // Default browser is set in constructor
3166 QString text = QInputDialog::getText(
3167 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3168 settings.value("/mainwindow/readerURL").toString()
3171 settings.setValue ("/mainwindow/readerURL",text);
3175 void Main::settingsMacroDir()
3177 QDir defdir(vymBaseDir.path() + "/macros");
3178 if (!defdir.exists())
3180 QDir dir=QFileDialog::getExistingDirectory (
3182 tr ("Directory with vym macros:"),
3183 settings.value ("/macros/macroDir",defdir.path()).toString()
3186 settings.setValue ("/macros/macroDir",dir.absolutePath());
3189 void Main::settingsUndoLevels()
3192 int i = QInputDialog::getInteger(
3194 tr("QInputDialog::getInteger()"),
3195 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3198 settings.setValue ("/mapeditor/stepsTotal",i);
3199 QMessageBox::information( this, tr( "VYM -Information:" ),
3200 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3204 void Main::settingsAutosaveToggle()
3206 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3209 void Main::settingsAutosaveTime()
3212 int i = QInputDialog::getInteger(
3214 tr("QInputDialog::getInteger()"),
3215 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3217 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3220 void Main::settingsWriteBackupFileToggle()
3222 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3225 void Main::settingsToggleAnimation()
3227 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3230 void Main::settingsToggleDelKey()
3232 if (actionSettingsUseDelKey->isOn())
3234 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3237 actionDelete->setAccel (QKeySequence (""));
3241 void Main::windowToggleNoteEditor()
3243 if (textEditor->isVisible() )
3244 windowHideNoteEditor();
3246 windowShowNoteEditor();
3249 void Main::windowToggleHistory()
3251 if (historyWindow->isVisible())
3252 historyWindow->hide();
3254 historyWindow->show();
3258 void Main::windowToggleProperty()
3260 if (branchPropertyWindow->isVisible())
3261 branchPropertyWindow->hide();
3263 branchPropertyWindow->show();
3264 branchPropertyWindow->setModel (currentModel() );
3267 void Main::windowToggleAntiAlias()
3269 bool b=actionViewToggleAntiAlias->isOn();
3271 for (int i=0;i<vymViews.count();i++)
3273 me=vymViews.at(i)->getMapEditor();
3274 if (me) me->setAntiAlias(b);
3279 bool Main::isAliased()
3281 return actionViewToggleAntiAlias->isOn();
3284 bool Main::hasSmoothPixmapTransform()
3286 return actionViewToggleSmoothPixmapTransform->isOn();
3289 void Main::windowToggleSmoothPixmap()
3291 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3293 for (int i=0;i<vymViews.count();i++)
3296 me=vymViews.at(i)->getMapEditor();
3297 if (me) me->setSmoothPixmap(b);
3301 void Main::updateHistory(SimpleSettings &undoSet)
3303 historyWindow->update (undoSet);
3306 void Main::updateNoteFlag()
3308 // this slot is connected to TextEditor::textHasChanged()
3310 VymModel *m=currentModel();
3311 if (m) m->updateNoteFlag();
3314 void Main::updateNoteEditor(QModelIndex index )
3316 cout << QObject::sender();
3317 QObject *obj=QObject::sender();
3318 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3319 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3320 //cout << "Main::updateNoteEditor model="<<sender();
3321 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3322 textEditor->setNote (ti->getNoteObj() );
3325 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3327 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3329 if (model && model==currentModel() )
3333 if (!oldsel.indexes().isEmpty() )
3335 ti=model->getItem(oldsel.indexes().first());
3337 // Don't update note if both treeItem and textEditor are empty
3338 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3339 // ti->setNoteObj (textEditor->getNoteObj(),false );
3341 if (!newsel.indexes().isEmpty() )
3343 ti=model->getItem(newsel.indexes().first());
3344 if (!ti->hasEmptyNote() )
3345 textEditor->setNote(ti->getNoteObj() );
3347 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3349 // Show URL and link in statusbar
3351 QString s=ti->getURL();
3352 if (!s.isEmpty() ) status+="URL: "+s+" ";
3354 if (!s.isEmpty() ) status+="Link: "+s;
3355 if (!status.isEmpty() ) statusMessage (status);
3358 textEditor->setInactive();
3364 void Main::updateActions()
3366 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3367 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3368 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3369 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3371 VymModel *m =currentModel();
3375 actionFilePrint->setEnabled (true);
3377 // Link style in context menu
3378 switch (m->getMapLinkStyle())
3380 case LinkableMapObj::Line:
3381 actionFormatLinkStyleLine->setChecked(true);
3383 case LinkableMapObj::Parabel:
3384 actionFormatLinkStyleParabel->setChecked(true);
3386 case LinkableMapObj::PolyLine:
3387 actionFormatLinkStylePolyLine->setChecked(true);
3389 case LinkableMapObj::PolyParabel:
3390 actionFormatLinkStylePolyParabel->setChecked(true);
3397 QPixmap pix( 16, 16 );
3398 pix.fill( m->getMapBackgroundColor() );
3399 actionFormatBackColor->setIconSet( pix );
3400 pix.fill( m->getSelectionColor() );
3401 actionFormatSelectionColor->setIconSet( pix );
3402 pix.fill( m->getMapDefLinkColor() );
3403 actionFormatLinkColor->setIconSet( pix );
3406 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3409 // Expanding/collapsing
3410 actionExpandAll->setEnabled (true);
3411 actionExpandOneLevel->setEnabled (true);
3412 actionCollapseOneLevel->setEnabled (true);
3416 actionFilePrint->setEnabled (false);
3418 // Expanding/collapsing
3419 actionExpandAll->setEnabled (false);
3420 actionExpandOneLevel->setEnabled (false);
3421 actionCollapseOneLevel->setEnabled (false);
3424 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3425 actionFormatLinkColorHint->setChecked(true);
3427 actionFormatLinkColorHint->setChecked(false);
3430 if (m && m->hasChanged() )
3431 actionFileSave->setEnabled( true);
3433 actionFileSave->setEnabled( false);
3434 if (m && m->isUndoAvailable())
3435 actionUndo->setEnabled( true);
3437 actionUndo->setEnabled( false);
3439 if (m && m->isRedoAvailable())
3440 actionRedo->setEnabled( true);
3442 actionRedo->setEnabled( false);
3446 TreeItem *selti=m->getSelectedItem();
3447 BranchItem *selbi=m->getSelectedBranch();
3450 if (selbi || selti->getType()==TreeItem::Image)
3452 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3453 actionFormatHideLinkUnselected->setEnabled (true);
3458 // Take care of xlinks
3459 branchXLinksContextMenuEdit->clear();
3460 branchXLinksContextMenuFollow->clear();
3461 if (selbi->xlinkCount()>0)
3465 for (int i=0; i<selbi->xlinkCount();++i)
3467 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3471 if (s.length()>xLinkMenuWidth)
3472 s=s.left(xLinkMenuWidth)+"...";
3473 branchXLinksContextMenuFollow->addAction (s);
3474 branchXLinksContextMenuEdit->addAction (s);
3479 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3482 actionToggleScroll->setEnabled (true);
3483 if ( selbi->isScrolled() )
3484 actionToggleScroll->setChecked(true);
3486 actionToggleScroll->setChecked(false);
3488 if ( selti->getURL().isEmpty() )
3490 actionOpenURL->setEnabled (false);
3491 actionOpenURLTab->setEnabled (false);
3495 actionOpenURL->setEnabled (true);
3496 actionOpenURLTab->setEnabled (true);
3498 if ( selti->getVymLink().isEmpty() )
3500 actionOpenVymLink->setEnabled (false);
3501 actionDeleteVymLink->setEnabled (false);
3504 actionOpenVymLink->setEnabled (true);
3505 actionDeleteVymLink->setEnabled (true);
3508 if (selbi->canMoveUp())
3509 actionMoveUp->setEnabled (true);
3511 actionMoveUp->setEnabled (false);
3512 if (selbi->canMoveDown())
3513 actionMoveDown->setEnabled (true);
3515 actionMoveDown->setEnabled (false);
3517 actionSortChildren->setEnabled (true);
3519 actionToggleHideExport->setEnabled (true);
3520 actionToggleHideExport->setChecked (selbi->hideInExport() );
3522 actionCopy->setEnabled (true);
3523 actionCut->setEnabled (true);
3524 if (!clipboardEmpty)
3525 actionPaste->setEnabled (true);
3527 actionPaste->setEnabled (false);
3528 for (int i=0; i<actionListBranches.size(); ++i)
3529 actionListBranches.at(i)->setEnabled(true);
3530 actionDelete->setEnabled (true);
3532 if ( selti->getType()==TreeItem::Image)
3534 actionOpenURL->setEnabled (false);
3535 actionOpenVymLink->setEnabled (false);
3536 actionDeleteVymLink->setEnabled (false);
3537 actionToggleHideExport->setEnabled (true);
3538 actionToggleHideExport->setChecked (selti->hideInExport() );
3541 actionCopy->setEnabled (true);
3542 actionCut->setEnabled (true);
3543 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3544 for (int i=0; i<actionListBranches.size(); ++i)
3545 actionListBranches.at(i)->setEnabled(false);
3546 actionDelete->setEnabled (true);
3547 actionMoveUp->setEnabled (false);
3548 actionMoveDown->setEnabled (false);
3553 actionCopy->setEnabled (false);
3554 actionCut->setEnabled (false);
3555 actionPaste->setEnabled (false);
3556 for (int i=0; i<actionListBranches.size(); ++i)
3557 actionListBranches.at(i)->setEnabled(false);
3559 actionToggleScroll->setEnabled (false);
3560 actionOpenURL->setEnabled (false);
3561 actionOpenVymLink->setEnabled (false);
3562 actionDeleteVymLink->setEnabled (false);
3563 actionHeading2URL->setEnabled (false);
3564 actionDelete->setEnabled (false);
3565 actionMoveUp->setEnabled (false);
3566 actionMoveDown->setEnabled (false);
3567 actionFormatHideLinkUnselected->setEnabled (false);
3568 actionSortChildren->setEnabled (false);
3569 actionToggleHideExport->setEnabled (false);
3574 Main::ModMode Main::getModMode()
3576 if (actionModModeColor->isOn()) return ModModeColor;
3577 if (actionModModeCopy->isOn()) return ModModeCopy;
3578 if (actionModModeXLink->isOn()) return ModModeXLink;
3582 bool Main::autoEditNewBranch()
3584 return actionSettingsAutoEditNewBranch->isOn();
3587 bool Main::autoSelectNewBranch()
3589 return actionSettingsAutoSelectNewBranch->isOn();
3592 void Main::windowShowNoteEditor()
3594 textEditor->setShowWithMain(true);
3596 actionViewToggleNoteEditor->setChecked (true);
3599 void Main::windowHideNoteEditor()
3601 textEditor->setShowWithMain(false);
3603 actionViewToggleNoteEditor->setChecked (false);
3606 void Main::setScript (const QString &script)
3608 scriptEditor->setScript (script);
3611 void Main::runScript (const QString &script)
3613 VymModel *m=currentModel();
3614 if (m) m->runScript (script);
3617 void Main::runScriptEverywhere (const QString &script)
3620 for (int i=0;i<=tabWidget->count() -1;i++)
3622 me=(MapEditor*)tabWidget->page(i);
3623 if (me) me->getModel()->runScript (script);
3627 void Main::windowNextEditor()
3629 if (tabWidget->currentIndex() < tabWidget->count())
3630 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3633 void Main::windowPreviousEditor()
3635 if (tabWidget->currentIndex() >0)
3636 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3639 void Main::standardFlagChanged()
3643 if ( actionSettingsUseFlagGroups->isOn() )
3644 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3646 currentModel()->toggleStandardFlag(sender()->name());
3651 void Main::testFunction1()
3653 if (!currentMapEditor()) return;
3654 currentMapEditor()->testFunction1();
3657 VymModel *m=currentModel();
3661 QString text = QInputDialog::getText(
3662 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3663 m->getSortFilter(), &ok, NULL);
3665 // user entered something and pressed OK
3666 m->setSortFilter (text);
3670 void Main::testFunction2()
3672 if (!currentMapEditor()) return;
3673 currentMapEditor()->testFunction2();
3676 void Main::testCommand()
3678 if (!currentMapEditor()) return;
3679 scriptEditor->show();
3682 QString com = QInputDialog::getText(
3683 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3684 if (ok) currentMapEditor()->parseAtom(com);
3688 void Main::helpDoc()
3690 QString locale = QLocale::system().name();
3692 if (locale.left(2)=="es")
3693 docname="vym_es.pdf";
3697 QStringList searchList;
3699 #if defined(Q_OS_MACX)
3700 searchList << "./vym.app/Contents/Resources/doc";
3701 #elif defined(Q_OS_WIN32)
3702 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3704 #if defined(VYM_DOCDIR)
3705 searchList << VYM_DOCDIR;
3707 // default path in SUSE LINUX
3708 searchList << "/usr/share/doc/packages/vym";
3711 searchList << "doc"; // relative path for easy testing in tarball
3712 searchList << "doc/tex"; // Easy testing working on vym.tex
3713 searchList << "/usr/share/doc/vym"; // Debian
3714 searchList << "/usr/share/doc/packages";// Knoppix
3718 for (int i=0; i<searchList.count(); ++i)
3720 docfile.setFileName(searchList.at(i)+"/"+docname);
3721 if (docfile.exists())
3730 QMessageBox::critical(0,
3731 tr("Critcal error"),
3732 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3737 Process *pdfProc = new Process();
3738 args << QDir::toNativeSeparators(docfile.fileName());
3740 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3743 QMessageBox::warning(0,
3745 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3746 tr("Please use Settings->")+tr("Set application to open PDF files"));
3753 void Main::helpDemo()
3755 QStringList filters;
3756 filters <<"VYM example map (*.vym)";
3757 QFileDialog *fd=new QFileDialog( this);
3758 #if defined(Q_OS_MACX)
3759 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3761 // default path in SUSE LINUX
3762 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3765 fd->setFileMode (QFileDialog::ExistingFiles);
3766 fd->setFilters (filters);
3767 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3771 if ( fd->exec() == QDialog::Accepted )
3773 lastFileDir=fd->directory().path();
3774 QStringList flist = fd->selectedFiles();
3775 QStringList::Iterator it = flist.begin();
3776 while( it != flist.end() )
3779 fileLoad(*it, NewMap);
3787 void Main::helpAbout()
3790 ad.setName ("aboutwindow");
3791 ad.setMinimumSize(500,500);
3792 ad.resize (QSize (500,500));
3796 void Main::helpAboutQT()
3798 QMessageBox::aboutQt( this, "Qt Application Example" );
3801 void Main::callMacro ()
3803 QAction *action = qobject_cast<QAction *>(sender());
3807 i=action->data().toInt();
3808 QString mDir (settings.value ("macros/macroDir").toString() );
3810 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3812 if ( !f.open( QIODevice::ReadOnly ) )
3814 QMessageBox::warning(0,
3816 tr("Couldn't find a macro at %1.\n").arg(fn)+
3817 tr("Please use Settings->")+tr("Set directory for vym macros"));
3821 QTextStream ts( &f );
3822 QString macro= ts.read();
3824 if (! macro.isEmpty())
3826 VymModel *m=currentModel();
3827 if (m) m->runScript(macro);