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 if (debug) 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-status");
1207 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1209 flag->load(flagsPath+"flag-wip.png");
1210 flag->setGroup("standard-status");
1211 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1213 flag->load(flagsPath+"flag-cross-red.png");
1214 flag->setGroup("standard-status");
1215 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1218 flag->load(flagsPath+"flag-stopsign.png");
1219 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1221 flag->load(flagsPath+"flag-smiley-good.png");
1222 flag->setGroup("standard-smiley");
1223 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1225 flag->load(flagsPath+"flag-smiley-sad.png");
1226 flag->setGroup("standard-smiley");
1227 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1229 flag->load(flagsPath+"flag-smiley-omg.png");
1230 flag->setGroup("standard-smiley");
1231 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1232 // Original omg.png (in KDE emoticons)
1235 flag->load(flagsPath+"flag-kalarm.png");
1236 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1238 flag->load(flagsPath+"flag-phone.png");
1239 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1241 flag->load(flagsPath+"flag-lamp.png");
1242 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1244 flag->load(flagsPath+"flag-arrow-up.png");
1245 flag->setGroup("standard-arrow");
1246 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1248 flag->load(flagsPath+"flag-arrow-down.png");
1249 flag->setGroup("standard-arrow");
1250 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1252 flag->load(flagsPath+"flag-arrow-2up.png");
1253 flag->setGroup("standard-arrow");
1254 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1256 flag->load(flagsPath+"flag-arrow-2down.png");
1257 flag->setGroup("standard-arrow");
1258 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1261 flag->load(flagsPath+"flag-thumb-up.png");
1262 flag->setGroup("standard-thumb");
1263 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1265 flag->load(flagsPath+"flag-thumb-down.png");
1266 flag->setGroup("standard-thumb");
1267 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1270 flag->load(flagsPath+"flag-rose.png");
1271 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1273 flag->load(flagsPath+"flag-heart.png");
1274 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1276 flag->load(flagsPath+"flag-present.png");
1277 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1279 flag->load(flagsPath+"flag-flash.png");
1280 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1282 // Original: xsldbg_output.png
1283 flag->load(flagsPath+"flag-info.png");
1284 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1286 // Original khelpcenter.png
1287 flag->load(flagsPath+"flag-lifebelt.png");
1288 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1291 flag->setVisible(false);
1292 flag->load(flagsPath+"freemind/warning.png");
1293 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1295 for (int i=1; i<8; i++)
1297 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1298 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1301 flag->load(flagsPath+"freemind/back.png");
1302 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1304 flag->load(flagsPath+"freemind/forward.png");
1305 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1307 flag->load(flagsPath+"freemind/attach.png");
1308 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1310 flag->load(flagsPath+"freemind/clanbomber.png");
1311 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1313 flag->load(flagsPath+"freemind/desktopnew.png");
1314 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1316 flag->load(flagsPath+"freemind/flag.png");
1317 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1320 flag->load(flagsPath+"freemind/gohome.png");
1321 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1324 flag->load(flagsPath+"freemind/kaddressbook.png");
1325 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1327 flag->load(flagsPath+"freemind/knotify.png");
1328 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1330 flag->load(flagsPath+"freemind/korn.png");
1331 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1333 flag->load(flagsPath+"freemind/mail.png");
1334 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1336 flag->load(flagsPath+"freemind/password.png");
1337 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1339 flag->load(flagsPath+"freemind/pencil.png");
1340 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1342 flag->load(flagsPath+"freemind/stop.png");
1343 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1345 flag->load(flagsPath+"freemind/wizard.png");
1346 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1348 flag->load(flagsPath+"freemind/xmag.png");
1349 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1351 flag->load(flagsPath+"freemind/bell.png");
1352 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1354 flag->load(flagsPath+"freemind/bookmark.png");
1355 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1357 flag->load(flagsPath+"freemind/penguin.png");
1358 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1360 flag->load(flagsPath+"freemind/licq.png");
1361 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1364 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1366 flag->setName(name);
1367 flag->setToolTip (tooltip);
1371 a=new QAction (flag->getPixmap(),name,this);
1374 flag->setAction (a);
1375 a->setVisible (flag->isVisible());
1376 a->setCheckable(true);
1377 a->setObjectName(name);
1378 a->setToolTip(tooltip);
1379 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1380 standardFlagsMaster->addFlag (flag);
1384 systemFlagsMaster->addFlag (flag);
1389 void Main::setupNetworkActions()
1391 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1393 QMenu *netMenu = menuBar()->addMenu( "Network" );
1397 a = new QAction( "Start TCPserver for MapEditor",this);
1398 //a->setStatusTip ( "Set application to open pdf files"));
1399 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1400 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1401 netMenu->addAction (a);
1403 a = new QAction( "Connect MapEditor to server",this);
1404 //a->setStatusTip ( "Set application to open pdf files"));
1405 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1406 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1407 netMenu->addAction (a);
1411 void Main::setupSettingsActions()
1413 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1417 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1418 a->setStatusTip ( tr( "Set application to open pdf files"));
1419 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1420 settingsMenu->addAction (a);
1422 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1423 a->setStatusTip( tr( "Set application to open external links"));
1424 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1425 settingsMenu->addAction (a);
1427 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1428 a->setStatusTip( tr( "Set path for macros"));
1429 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1430 settingsMenu->addAction (a);
1432 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1433 a->setStatusTip( tr( "Set number of undo levels"));
1434 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1435 settingsMenu->addAction (a);
1437 settingsMenu->addSeparator();
1439 a = new QAction( tr( "Autosave","Settings action"), this);
1440 a->setStatusTip( tr( "Autosave"));
1441 a->setToggleAction(true);
1442 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1443 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1444 settingsMenu->addAction (a);
1445 actionSettingsAutosaveToggle=a;
1447 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1448 a->setStatusTip( tr( "Autosave time"));
1449 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1450 settingsMenu->addAction (a);
1451 actionSettingsAutosaveTime=a;
1453 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1454 a->setStatusTip( tr( "Write backup file on save"));
1455 a->setToggleAction(true);
1456 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1457 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1458 settingsMenu->addAction (a);
1459 actionSettingsWriteBackupFile=a;
1461 settingsMenu->addSeparator();
1463 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1464 a->setStatusTip( tr( "Edit branch after adding it" ));
1465 a->setToggleAction(true);
1466 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1467 settingsMenu->addAction (a);
1468 actionSettingsAutoEditNewBranch=a;
1470 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1471 a->setStatusTip( tr( "Select branch after adding it" ));
1472 a->setToggleAction(true);
1473 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1474 settingsMenu->addAction (a);
1475 actionSettingsAutoSelectNewBranch=a;
1477 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1478 a->setStatusTip( tr( "Select heading before editing" ));
1479 a->setToggleAction(true);
1480 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1481 settingsMenu->addAction (a);
1482 actionSettingsAutoSelectText=a;
1484 a= new QAction( tr( "Delete key","Settings action" ), this);
1485 a->setStatusTip( tr( "Delete key for deleting branches" ));
1486 a->setToggleAction(true);
1487 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1488 settingsMenu->addAction (a);
1489 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1490 actionSettingsUseDelKey=a;
1492 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1493 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1494 a->setToggleAction(true);
1495 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1496 settingsMenu->addAction (a);
1497 actionSettingsUseFlagGroups=a;
1499 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1500 a->setStatusTip( tr( "Use hide flag during exports " ));
1501 a->setToggleAction(true);
1502 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1503 settingsMenu->addAction (a);
1504 actionSettingsUseHideExport=a;
1506 a = new QAction( tr( "Animation","Settings action"), this);
1507 a->setStatusTip( tr( "Animation"));
1508 a->setToggleAction(true);
1509 a->setChecked (settings.value("/animation/use",true).toBool() );
1510 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1511 settingsMenu->addAction (a);
1512 actionSettingsUseAnimation=a;
1516 void Main::setupTestActions()
1518 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1521 a = new QAction( "Test function 1" , this);
1522 a->setStatusTip( "Call test function 1" );
1523 a->setShortcut (Qt::CTRL + Qt::Key_T); // Test function 1 //FIXME-2 originally: color subtree
1524 testMenu->addAction (a);
1525 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1527 a = new QAction( "Test function 2" , this);
1528 a->setStatusTip( "Call test function 2" );
1529 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 2
1530 testMenu->addAction (a);
1531 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1533 a = new QAction( "Command" , this);
1534 a->setStatusTip( "Enter command to call in editor" );
1535 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1536 testMenu->addAction (a);
1540 void Main::setupHelpActions()
1542 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1545 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1546 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1547 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1548 helpMenu->addAction (a);
1550 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1551 a->setStatusTip( tr( "Open VYM example maps " ));
1552 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1553 helpMenu->addAction (a);
1555 a = new QAction( tr( "About VYM","Help action" ), this);
1556 a->setStatusTip( tr( "About VYM")+vymName);
1557 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1558 helpMenu->addAction (a);
1560 a = new QAction( tr( "About QT","Help action" ), this);
1561 a->setStatusTip( tr( "Information about QT toolkit" ));
1562 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1563 helpMenu->addAction (a);
1567 void Main::setupContextMenus()
1571 // Context Menu for branch or mapcenter
1572 branchContextMenu =new QMenu (this);
1573 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1574 branchContextMenu->addSeparator();
1577 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1578 branchAddContextMenu->addAction (actionPaste );
1579 branchAddContextMenu->addAction ( actionAddMapCenter );
1580 branchAddContextMenu->addAction ( actionAddBranch );
1581 branchAddContextMenu->addAction ( actionAddBranchBefore );
1582 branchAddContextMenu->addAction ( actionAddBranchAbove);
1583 branchAddContextMenu->addAction ( actionAddBranchBelow );
1584 branchAddContextMenu->addSeparator();
1585 branchAddContextMenu->addAction ( actionImportAdd );
1586 branchAddContextMenu->addAction ( actionImportReplace );
1589 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1590 branchRemoveContextMenu->addAction (actionCut);
1591 branchRemoveContextMenu->addAction ( actionDelete );
1592 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1593 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1596 actionSaveBranch->addTo( branchContextMenu );
1597 actionFileNewCopy->addTo (branchContextMenu );
1598 actionDetach->addTo (branchContextMenu );
1600 branchContextMenu->addSeparator();
1601 branchContextMenu->addAction ( actionLoadImage);
1603 // Submenu for Links (URLs, vymLinks)
1604 branchLinksContextMenu =new QMenu (this);
1606 branchContextMenu->addSeparator();
1607 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1608 branchLinksContextMenu->addAction ( actionOpenURL );
1609 branchLinksContextMenu->addAction ( actionOpenURLTab );
1610 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1611 branchLinksContextMenu->addAction ( actionURL );
1612 branchLinksContextMenu->addAction ( actionLocalURL );
1613 branchLinksContextMenu->addAction ( actionHeading2URL );
1614 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1615 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1617 branchLinksContextMenu->addAction ( actionFATE2URL );
1619 branchLinksContextMenu->addSeparator();
1620 branchLinksContextMenu->addAction ( actionOpenVymLink );
1621 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1622 branchLinksContextMenu->addAction ( actionVymLink );
1623 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1626 // Context Menu for XLinks in a branch menu
1627 // This will be populated "on demand" in MapEditor::updateActions
1628 branchContextMenu->addSeparator();
1629 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1630 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1631 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1632 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1635 // Context menu for floatimage
1636 floatimageContextMenu =new QMenu (this);
1637 a= new QAction (tr ("Save image","Context action"),this);
1638 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1639 floatimageContextMenu->addAction (a);
1641 floatimageContextMenu->addSeparator();
1642 actionCopy->addTo( floatimageContextMenu );
1643 actionCut->addTo( floatimageContextMenu );
1645 floatimageContextMenu->addSeparator();
1646 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1649 // Context menu for canvas
1650 canvasContextMenu =new QMenu (this);
1651 actionAddMapCenter->addTo( canvasContextMenu );
1652 actionMapInfo->addTo( canvasContextMenu );
1653 canvasContextMenu->insertSeparator();
1654 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1655 canvasContextMenu->insertSeparator();
1656 actionFormatLinkColorHint->addTo( canvasContextMenu );
1657 actionFormatLinkColor->addTo( canvasContextMenu );
1658 actionFormatSelectionColor->addTo( canvasContextMenu );
1659 actionFormatBackColor->addTo( canvasContextMenu );
1660 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1662 // Menu for last opened files
1664 for (int i = 0; i < MaxRecentFiles; ++i)
1666 recentFileActions[i] = new QAction(this);
1667 recentFileActions[i]->setVisible(false);
1668 fileLastMapsMenu->addAction(recentFileActions[i]);
1669 connect(recentFileActions[i], SIGNAL(triggered()),
1670 this, SLOT(fileLoadRecent()));
1672 setupRecentMapsMenu();
1675 void Main::setupRecentMapsMenu()
1677 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1679 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1681 for (int i = 0; i < numRecentFiles; ++i) {
1682 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1683 recentFileActions[i]->setText(text);
1684 recentFileActions[i]->setData(files[i]);
1685 recentFileActions[i]->setVisible(true);
1687 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1688 recentFileActions[j]->setVisible(false);
1691 void Main::setupMacros()
1693 for (int i = 0; i <= 11; i++)
1695 macroActions[i] = new QAction(this);
1696 macroActions[i]->setData(i);
1697 addAction (macroActions[i]);
1698 connect(macroActions[i], SIGNAL(triggered()),
1699 this, SLOT(callMacro()));
1701 macroActions[0]->setShortcut ( Qt::Key_F1 );
1702 macroActions[1]->setShortcut ( Qt::Key_F2 );
1703 macroActions[2]->setShortcut ( Qt::Key_F3 );
1704 macroActions[3]->setShortcut ( Qt::Key_F4 );
1705 macroActions[4]->setShortcut ( Qt::Key_F5 );
1706 macroActions[5]->setShortcut ( Qt::Key_F6 );
1707 macroActions[6]->setShortcut ( Qt::Key_F7 );
1708 macroActions[7]->setShortcut ( Qt::Key_F8 );
1709 macroActions[8]->setShortcut ( Qt::Key_F9 );
1710 macroActions[9]->setShortcut ( Qt::Key_F10 );
1711 macroActions[10]->setShortcut ( Qt::Key_F11 );
1712 macroActions[11]->setShortcut ( Qt::Key_F12 );
1715 void Main::hideEvent (QHideEvent * )
1717 if (!textEditor->isMinimized() ) textEditor->hide();
1720 void Main::showEvent (QShowEvent * )
1722 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1726 MapEditor* Main::currentMapEditor() const
1728 if ( tabWidget->currentPage())
1729 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1733 VymModel* Main::currentModel() const
1735 if ( tabWidget->currentPage())
1736 return vymViews.at(tabWidget->currentIndex())->getModel();
1741 void Main::editorChanged(QWidget *)
1743 // Unselect all possibly selected objects
1744 // (Important to update note editor)
1746 for (int i=0;i<=tabWidget->count() -1;i++)
1748 m= vymViews.at(i)->getModel();
1749 if (m) m->unselect();
1752 if (m) m->reselect();
1754 // Update actions to in menus and toolbars according to editor
1758 void Main::fileNew()
1760 VymModel *vm=new VymModel;
1762 /////////////////////////////////////
1763 new ModelTest(vm, this); //FIXME-3
1764 /////////////////////////////////////
1766 VymView *vv=new VymView (vm);
1767 vymViews.append (vv);
1768 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1769 tabWidget->setCurrentIndex (vymViews.count() );
1772 // Create MapCenter for empty map
1776 // For the very first map we do not have flagrows yet...
1780 void Main::fileNewCopy()
1782 QString fn="unnamed";
1783 VymModel *srcModel=currentModel();
1788 VymModel *dstModel=vymViews.last()->getModel();
1789 dstModel->select("mc:");
1790 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1794 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1796 ErrorCode err=success;
1798 // fn is usually the archive, mapfile the file after uncompressing
1801 // Make fn absolute (needed for unzip)
1802 fn=QDir (fn).absPath();
1808 // Check, if map is already loaded
1810 while (i<=tabWidget->count() -1)
1812 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1814 // Already there, ask for confirmation
1815 QMessageBox mb( vymName,
1816 tr("The map %1\nis already opened."
1817 "Opening the same map in multiple editors may lead \n"
1818 "to confusion when finishing working with vym."
1819 "Do you want to").arg(fn),
1820 QMessageBox::Warning,
1821 QMessageBox::Yes | QMessageBox::Default,
1822 QMessageBox::Cancel | QMessageBox::Escape,
1823 QMessageBox::NoButton);
1824 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1825 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1828 case QMessageBox::Yes:
1829 // end loop and load anyway
1830 i=tabWidget->count();
1832 case QMessageBox::Cancel:
1842 int tabIndex=tabWidget->currentPageIndex();
1845 if ( !fn.isEmpty() )
1847 vm = currentModel();
1848 // Check first, if mapeditor exists
1849 // If it is not default AND we want a new map,
1850 // create a new mapeditor in a new tab
1851 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1854 VymView *vv=new VymView (vm);
1855 vymViews.append (vv);
1856 tabWidget->addTab (vv,fn);
1857 tabIndex=tabWidget->count()-1;
1858 tabWidget->setCurrentPage (tabIndex);
1862 // Check, if file exists (important for creating new files
1863 // from command line
1864 if (!QFile(fn).exists() )
1866 QMessageBox mb( vymName,
1867 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1868 QMessageBox::Question,
1870 QMessageBox::Cancel | QMessageBox::Default,
1871 QMessageBox::NoButton );
1873 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1874 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1877 case QMessageBox::Yes:
1879 currentMapEditor()->getModel()->setFilePath(fn);
1880 tabWidget->setTabText (tabIndex,
1881 currentMapEditor()->getModel()->getFileName() );
1882 statusBar()->message( "Created " + fn , statusbarTime );
1885 case QMessageBox::Cancel:
1886 // don't create new map
1887 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1894 //tabWidget->currentPage() won't be NULL here, because of above...
1895 tabWidget->setCurrentIndex (tabIndex);
1896 //FIXME-3 no me anymore... me->viewport()->setFocus();
1900 // Save existing filename in case we import
1901 QString fn_org=vm->getFilePath();
1903 // Finally load map into mapEditor
1904 vm->setFilePath (fn);
1905 err=vm->load(fn,lmode,ftype);
1907 // Restore old (maybe empty) filepath, if this is an import
1909 vm->setFilePath (fn_org);
1912 // Finally check for errors and go home
1915 if (lmode==NewMap) fileCloseMap();
1916 statusBar()->message( "Could not load " + fn, statusbarTime );
1921 vm->setFilePath (fn);
1922 tabWidget->setTabText (tabIndex, vm->getFileName());
1923 if (!isInTmpDir (fn))
1925 // Only append to lastMaps if not loaded from a tmpDir
1926 // e.g. imported bookmarks are in a tmpDir
1927 addRecentMap(vm->getFilePath() );
1929 actionFilePrint->setEnabled (true);
1931 statusBar()->message( "Loaded " + fn, statusbarTime );
1938 void Main::fileLoad(const LoadMode &lmode)
1940 QStringList filters;
1941 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1942 QFileDialog *fd=new QFileDialog( this);
1943 fd->setDir (lastFileDir);
1944 fd->setFileMode (QFileDialog::ExistingFiles);
1945 fd->setFilters (filters);
1949 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1952 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1955 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1961 if ( fd->exec() == QDialog::Accepted )
1963 lastFileDir=fd->directory().path();
1964 QStringList flist = fd->selectedFiles();
1965 QStringList::Iterator it = flist.begin();
1966 while( it != flist.end() )
1969 fileLoad(*it, lmode);
1976 void Main::fileLoad()
1981 void Main::fileLoadRecent()
1983 QAction *action = qobject_cast<QAction *>(sender());
1985 fileLoad (action->data().toString(), NewMap);
1988 void Main::addRecentMap (const QString &fileName)
1991 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1992 files.removeAll(fileName);
1993 files.prepend(fileName);
1994 while (files.size() > MaxRecentFiles)
1997 settings.setValue("/mainwindow/recentFileList", files);
1999 setupRecentMapsMenu();
2002 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2006 if ( m->getFilePath().isEmpty() )
2008 // We have no filepath yet,
2009 // call fileSaveAs() now, this will call fileSave()
2011 // First switch to editor
2012 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2013 fileSaveAs(savemode);
2016 if (m->save (savemode)==success)
2018 statusBar()->message(
2019 tr("Saved %1").arg(m->getFilePath()),
2021 addRecentMap (m->getFilePath() );
2023 statusBar()->message(
2024 tr("Couldn't save ").arg(m->getFilePath()),
2028 void Main::fileSave()
2030 fileSave (currentModel(), CompleteMap);
2033 void Main::fileSave(VymModel *m)
2035 fileSave (m,CompleteMap);
2038 void Main::fileSaveAs(const SaveMode& savemode)
2042 if (currentMapEditor())
2044 if (savemode==CompleteMap)
2045 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2047 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2048 if ( !fn.isEmpty() )
2050 // Check for existing file
2051 if (QFile (fn).exists())
2053 QMessageBox mb( vymName,
2054 tr("The file %1\nexists already. Do you want to").arg(fn),
2055 QMessageBox::Warning,
2056 QMessageBox::Yes | QMessageBox::Default,
2057 QMessageBox::Cancel | QMessageBox::Escape,
2058 QMessageBox::NoButton);
2059 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2060 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2063 case QMessageBox::Yes:
2066 case QMessageBox::Cancel:
2073 // New file, add extension to filename, if missing
2074 // This is always .vym or .vyp, depending on savemode
2075 if (savemode==CompleteMap)
2077 if (!fn.contains (".vym") && !fn.contains (".xml"))
2081 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2090 VymModel *m=currentModel();
2092 fileSave(m, savemode);
2094 // Set name of tab, assuming current tab is the one we just saved
2095 if (savemode==CompleteMap)
2096 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2102 void Main::fileSaveAs()
2104 fileSaveAs (CompleteMap);
2107 void Main::fileImportKDE3Bookmarks()
2109 ImportKDE3Bookmarks im;
2111 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2112 currentMapEditor()->getModel()->setFilePath ("");
2115 void Main::fileImportKDE4Bookmarks()
2117 ImportKDE4Bookmarks im;
2119 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2120 currentMapEditor()->getModel()->setFilePath ("");
2123 void Main::fileImportFirefoxBookmarks()
2125 Q3FileDialog *fd=new Q3FileDialog( this);
2126 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2127 fd->setMode (Q3FileDialog::ExistingFiles);
2128 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2129 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2132 if ( fd->exec() == QDialog::Accepted )
2134 ImportFirefoxBookmarks im;
2135 QStringList flist = fd->selectedFiles();
2136 QStringList::Iterator it = flist.begin();
2137 while( it != flist.end() )
2140 if (im.transform() &&
2141 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2142 currentMapEditor() )
2143 currentMapEditor()->getModel()->setFilePath ("");
2150 void Main::fileImportFreemind()
2152 QStringList filters;
2153 filters <<"Freemind map (*.mm)"<<"All files (*)";
2154 QFileDialog *fd=new QFileDialog( this);
2155 fd->setDir (lastFileDir);
2156 fd->setFileMode (QFileDialog::ExistingFiles);
2157 fd->setFilters (filters);
2158 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2162 if ( fd->exec() == QDialog::Accepted )
2164 lastFileDir=fd->directory().path();
2165 QStringList flist = fd->selectedFiles();
2166 QStringList::Iterator it = flist.begin();
2167 while( it != flist.end() )
2170 if ( fileLoad (fn,NewMap, FreemindMap) )
2172 currentMapEditor()->getModel()->setFilePath ("");
2181 void Main::fileImportMM()
2185 Q3FileDialog *fd=new Q3FileDialog( this);
2186 fd->setDir (lastFileDir);
2187 fd->setMode (Q3FileDialog::ExistingFiles);
2188 fd->addFilter ("Mind Manager (*.mmap)");
2189 fd->setCaption(tr("Import")+" "+"Mind Manager");
2192 if ( fd->exec() == QDialog::Accepted )
2194 lastFileDir=fd->dirPath();
2195 QStringList flist = fd->selectedFiles();
2196 QStringList::Iterator it = flist.begin();
2197 while( it != flist.end() )
2200 if (im.transform() &&
2201 success==fileLoad (im.getTransformedFile(),NewMap) &&
2202 currentMapEditor() )
2203 currentMapEditor()->getModel()->setFilePath ("");
2210 void Main::fileImportDir()
2212 VymModel *m=currentModel();
2213 if (m) m->importDir();
2216 void Main::fileExportXML()
2218 VymModel *m=currentModel();
2219 if (m) m->exportXML();
2223 void Main::fileExportXHTML()
2225 VymModel *m=currentModel();
2226 if (m) m->exportXHTML();
2229 void Main::fileExportImage()
2231 VymModel *m=currentModel();
2232 if (m) m->exportImage();
2235 void Main::fileExportAO()
2237 VymModel *m=currentModel();
2238 if (m) m->exportAO();
2241 void Main::fileExportASCII()
2243 VymModel *m=currentModel();
2244 if (m) m->exportASCII();
2247 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2249 VymModel *m=currentModel();
2254 ex.addFilter ("CSV (*.csv)");
2255 ex.setDir(lastImageDir);
2256 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2257 if (ex.execDialog() )
2259 m->setExportMode(true);
2261 m->setExportMode(false);
2266 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2268 VymModel *m=currentModel();
2273 ex.addFilter ("Tex (*.tex)");
2274 ex.setDir(lastImageDir);
2275 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2276 if (ex.execDialog() )
2278 m->setExportMode(true);
2280 m->setExportMode(false);
2285 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2287 ExportKDE3Bookmarks ex;
2288 VymModel *m=currentModel();
2296 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2298 ExportKDE4Bookmarks ex;
2299 VymModel *m=currentModel();
2307 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2309 ExportTaskjuggler ex;
2310 VymModel *m=currentModel();
2314 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2315 ex.setDir(lastImageDir);
2316 ex.addFilter ("Taskjuggler (*.tjp)");
2317 if (ex.execDialog() )
2319 m->setExportMode(true);
2321 m->setExportMode(false);
2326 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2328 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2329 // TODO add preview in dialog
2330 //ImagePreview *p =new ImagePreview (fd);
2331 //fd->setContentsPreviewEnabled( TRUE );
2332 //fd->setContentsPreview( p, p );
2333 //fd->setPreviewMode( QFileDialog::Contents );
2334 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2335 fd->setDir (QDir().current());
2336 if (fd->foundConfig())
2340 if ( fd->exec() == QDialog::Accepted )
2342 QString fn=fd->selectedFile();
2343 if (!fn.contains (".odp"))
2346 //lastImageDir=fn.left(fn.findRev ("/"));
2347 VymModel *m=currentModel();
2348 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2352 QMessageBox::warning(0,
2354 tr("Couldn't find configuration for export to Open Office\n"));
2358 void Main::fileCloseMap()
2360 VymModel *m=currentModel();
2363 if (m->hasChanged())
2365 QMessageBox mb( vymName,
2366 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2367 QMessageBox::Warning,
2368 QMessageBox::Yes | QMessageBox::Default,
2370 QMessageBox::Cancel | QMessageBox::Escape );
2371 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2372 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2375 case QMessageBox::Yes:
2377 fileSave(m, CompleteMap);
2379 case QMessageBox::No:
2380 // close without saving
2382 case QMessageBox::Cancel:
2387 // And here comes the segfault, because removeTab triggers
2388 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2389 vymViews.removeAt (tabWidget->currentIndex() );
2390 tabWidget->removeTab (tabWidget->currentIndex() );
2392 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2393 // Better would be delete (me), but then we could have a Qt error:
2394 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2395 // So we only remove data now and call deconstructor when vym closes later
2396 // this needs to be moved to vymview... me->clear();
2397 // some model->clear is needed to free up memory ...
2399 delete (m->getMapEditor());
2406 void Main::filePrint()
2408 if (currentMapEditor())
2409 currentMapEditor()->print();
2412 void Main::fileExitVYM()
2414 // Check if one or more editors have changed
2416 for (i=0;i<=vymViews.count() -1;i++)
2418 // If something changed, ask what to do
2419 if (vymViews.at(i)->getModel()->hasChanged())
2421 tabWidget->setCurrentPage(i);
2422 QMessageBox mb( vymName,
2423 tr("This map is not saved yet. Do you want to"),
2424 QMessageBox::Warning,
2425 QMessageBox::Yes | QMessageBox::Default,
2427 QMessageBox::Cancel | QMessageBox::Escape );
2428 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2429 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2432 mb.setActiveWindow();
2433 switch( mb.exec() ) {
2434 case QMessageBox::Yes:
2435 // save (the changed editors) and exit
2436 fileSave(currentModel(), CompleteMap);
2438 case QMessageBox::No:
2439 // exit without saving
2441 case QMessageBox::Cancel:
2442 // don't save and don't exit
2446 } // loop over all MEs
2450 void Main::editUndo()
2452 VymModel *m=currentModel();
2456 void Main::editRedo()
2458 VymModel *m=currentModel();
2462 void Main::gotoHistoryStep (int i)
2464 VymModel *m=currentModel();
2465 if (m) m->gotoHistoryStep(i);
2468 void Main::editCopy()
2470 VymModel *m=currentModel();
2474 void Main::editPaste()
2476 VymModel *m=currentModel();
2480 void Main::editCut()
2482 VymModel *m=currentModel();
2486 void Main::editOpenFindWidget()
2488 VymModel *m=currentModel();
2489 if (m) m->emitShowFindWidget();
2492 void Main::openTabs(QStringList urls)
2494 if (!urls.isEmpty())
2498 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2499 if (*browserPID==0) //FIXME-2 need to check if browser is really still there instead of this
2501 QString u=urls.takeFirst();
2503 QString workDir=QDir::currentDirPath();
2504 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2506 // try to set path to browser
2507 QMessageBox::warning(0,
2509 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2510 tr("Please use Settings->")+tr("Set application to open an URL"));
2513 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2514 #if defined(Q_OS_WIN32)
2515 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2516 this->thread()->wait(3000);
2518 sleep (3); //FIXME-3 needed?
2522 if (browser.contains("konqueror"))
2524 for (int i=0; i<urls.size(); i++)
2527 // Try to open new tab in existing konqueror started previously by vym
2531 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2532 "konqueror-mainwindow#1"<<
2536 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2537 "/konqueror/MainWindow_1"<<
2541 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2542 if (!QProcess::startDetached ("qdbus",args))
2546 QMessageBox::warning(0,
2548 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2550 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2552 for (int i=0; i<urls.size(); i++)
2554 // Try to open new tab in firefox
2555 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2556 if (!QProcess::startDetached (browser,args))
2560 QMessageBox::warning(0,
2562 tr("Couldn't start %1 to open a new tab").arg(browser));
2565 QMessageBox::warning(0,
2567 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2571 void Main::editOpenURL()
2574 VymModel *m=currentModel();
2577 QString url=m->getURL();
2579 if (url=="") return;
2580 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2582 QString workDir=QDir::currentDirPath();
2583 if (!procBrowser->startDetached(browser,args))
2585 // try to set path to browser
2586 QMessageBox::warning(0,
2588 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2589 tr("Please use Settings->")+tr("Set application to open an URL"));
2594 void Main::editOpenURLTab()
2596 VymModel *m=currentModel();
2600 urls.append(m->getURL());
2604 void Main::editOpenMultipleURLTabs()
2606 VymModel *m=currentModel();
2616 void Main::editURL()
2618 VymModel *m=currentModel();
2619 if (m) m->editURL();
2622 void Main::editLocalURL()
2624 VymModel *m=currentModel();
2625 if (m) m->editLocalURL();
2628 void Main::editHeading2URL()
2630 VymModel *m=currentModel();
2631 if (m) m->editHeading2URL();
2634 void Main::editBugzilla2URL()
2636 VymModel *m=currentModel();
2637 if (m) m->editBugzilla2URL();
2640 void Main::editFATE2URL()
2642 VymModel *m=currentModel();
2643 if (m) m->editFATE2URL();
2646 void Main::editHeadingFinished(VymModel *m)
2650 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2651 !prevSelection.isEmpty())
2652 m->select(prevSelection);
2657 void Main::openVymLinks(const QStringList &vl)
2659 for (int j=0; j<vl.size(); j++)
2661 // compare path with already loaded maps
2664 for (i=0;i<=vymViews.count() -1;i++)
2666 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2675 if (!QFile(vl.at(j)).exists() )
2676 QMessageBox::critical( 0, tr( "Critical Error" ),
2677 tr("Couldn't open map %1").arg(vl.at(j)));
2680 fileLoad (vl.at(j), NewMap);
2681 tabWidget->setCurrentIndex (tabWidget->count()-1);
2684 // Go to tab containing the map
2685 tabWidget->setCurrentIndex (index);
2689 void Main::editOpenVymLink()
2691 VymModel *m=currentModel();
2695 vl.append(m->getVymLink());
2700 void Main::editOpenMultipleVymLinks()
2702 QString currentVymLink;
2703 VymModel *m=currentModel();
2706 QStringList vl=m->getVymLinks();
2711 void Main::editVymLink()
2713 VymModel *m=currentModel();
2718 void Main::editDeleteVymLink()
2720 VymModel *m=currentModel();
2721 if (m) m->deleteVymLink();
2724 void Main::editToggleHideExport()
2726 VymModel *m=currentModel();
2727 if (m) m->toggleHideExport();
2730 void Main::editAddTimestamp()
2732 VymModel *m=currentModel();
2733 if (m) m->addTimestamp();
2736 void Main::editMapInfo()
2738 VymModel *m=currentModel();
2741 ExtraInfoDialog dia;
2742 dia.setMapName (m->getFileName() );
2743 dia.setAuthor (m->getAuthor() );
2744 dia.setComment(m->getComment() );
2748 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2754 BranchItem *cur=NULL;
2755 BranchItem *prev=NULL;
2756 m->nextBranch(cur,prev);
2759 if (!cur->getNote().isEmpty() ) n++;
2760 f+= cur->imageCount();
2762 xl+=cur->xlinkCount();
2763 m->nextBranch(cur,prev);
2766 stats+=QString ("%1 xLinks \n").arg (xl,6);
2767 stats+=QString ("%1 notes\n").arg (n,6);
2768 stats+=QString ("%1 images\n").arg (f,6);
2769 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2770 dia.setStats (stats);
2772 // Finally show dialog
2773 if (dia.exec() == QDialog::Accepted)
2775 m->setAuthor (dia.getAuthor() );
2776 m->setComment (dia.getComment() );
2780 void Main::editMoveUp()
2782 VymModel *m=currentModel();
2786 void Main::editMoveDown()
2788 VymModel *m=currentModel();
2789 if (m) m->moveDown();
2792 void Main::editDetach()
2794 VymModel *m=currentModel();
2798 void Main::editSortChildren()
2800 VymModel *m=currentModel();
2801 if (m) m->sortChildren();
2804 void Main::editToggleScroll()
2806 VymModel *m=currentModel();
2807 if (m) m->toggleScroll();
2810 void Main::editExpandAll()
2812 VymModel *m=currentModel();
2813 if (m) m->emitExpandAll();
2816 void Main::editExpandOneLevel()
2818 VymModel *m=currentModel();
2819 if (m) m->emitExpandOneLevel();
2822 void Main::editCollapseOneLevel()
2824 VymModel *m=currentModel();
2825 if (m) m->emitCollapseOneLevel();
2828 void Main::editUnscrollChildren()
2830 VymModel *m=currentModel();
2831 if (m) m->unscrollChildren();
2834 void Main::editAddAttribute()
2836 VymModel *m=currentModel();
2837 if (m) m->addAttribute();
2840 void Main::editAddMapCenter()
2842 VymModel *m=currentModel();
2843 if (m) m->addMapCenter ();
2846 void Main::editNewBranch()
2848 VymModel *m=currentModel();
2851 BranchItem *bi=m->addNewBranch();
2854 if (actionSettingsAutoEditNewBranch->isOn()
2855 && !actionSettingsAutoSelectNewBranch->isOn() )
2856 prevSelection=m->getSelectString();
2858 prevSelection=QString();
2860 if (actionSettingsAutoSelectNewBranch->isOn()
2861 || actionSettingsAutoEditNewBranch->isOn())
2864 if (actionSettingsAutoEditNewBranch->isOn())
2865 currentMapEditor()->editHeading();
2870 void Main::editNewBranchBefore()
2872 VymModel *m=currentModel();
2875 BranchItem *bi=m->addNewBranchBefore();
2882 if (actionSettingsAutoEditNewBranch->isOn())
2884 if (!actionSettingsAutoSelectNewBranch->isOn())
2885 prevSelection=m->getSelectString(bi);
2886 currentMapEditor()->editHeading();
2891 void Main::editNewBranchAbove()
2893 VymModel *m=currentModel();
2896 BranchItem *bi=m->addNewBranch (-1);
2904 if (actionSettingsAutoEditNewBranch->isOn())
2906 if (!actionSettingsAutoSelectNewBranch->isOn())
2907 prevSelection=m->getSelectString (bi);
2908 currentMapEditor()->editHeading();
2913 void Main::editNewBranchBelow()
2915 VymModel *m=currentModel();
2918 BranchItem *bi=m->addNewBranch (1);
2925 if (actionSettingsAutoEditNewBranch->isOn())
2927 if (!actionSettingsAutoSelectNewBranch->isOn())
2928 prevSelection=m->getSelectString(bi);
2929 currentMapEditor()->editHeading();
2934 void Main::editImportAdd()
2936 fileLoad (ImportAdd);
2939 void Main::editImportReplace()
2941 fileLoad (ImportReplace);
2944 void Main::editSaveBranch()
2946 fileSaveAs (PartOfMap);
2949 void Main::editDeleteKeepChildren()
2951 VymModel *m=currentModel();
2952 if (m) m->deleteKeepChildren();
2955 void Main::editDeleteChildren()
2957 VymModel *m=currentModel();
2958 if (m) m->deleteChildren();
2961 void Main::editDeleteSelection()
2963 VymModel *m=currentModel();
2964 if (m && actionSettingsUseDelKey->isOn())
2965 m->deleteSelection();
2968 void Main::editLoadImage()
2970 VymModel *m=currentModel();
2971 if (m) m->loadFloatImage();
2974 void Main::editSaveImage()
2976 VymModel *m=currentModel();
2977 if (m) m->saveFloatImage();
2980 void Main::editFollowXLink(QAction *a)
2983 VymModel *m=currentModel();
2985 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
2988 void Main::editEditXLink(QAction *a)
2990 VymModel *m=currentModel();
2992 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
2995 void Main::formatSelectColor()
2997 QColor col = QColorDialog::getColor((currentColor ), this );
2998 if ( !col.isValid() ) return;
2999 colorChanged( col );
3002 void Main::formatPickColor()
3004 VymModel *m=currentModel();
3006 colorChanged( m->getCurrentHeadingColor() );
3009 void Main::colorChanged(QColor c)
3011 QPixmap pix( 16, 16 );
3013 actionFormatColor->setIconSet( pix );
3017 void Main::formatColorBranch()
3019 VymModel *m=currentModel();
3020 if (m) m->colorBranch(currentColor);
3023 void Main::formatColorSubtree()
3025 VymModel *m=currentModel();
3026 if (m) m->colorSubtree (currentColor);
3029 void Main::formatLinkStyleLine()
3031 VymModel *m=currentModel();
3034 m->setMapLinkStyle("StyleLine");
3035 actionFormatLinkStyleLine->setChecked(true);
3039 void Main::formatLinkStyleParabel()
3041 VymModel *m=currentModel();
3044 m->setMapLinkStyle("StyleParabel");
3045 actionFormatLinkStyleParabel->setChecked(true);
3049 void Main::formatLinkStylePolyLine()
3051 VymModel *m=currentModel();
3054 m->setMapLinkStyle("StylePolyLine");
3055 actionFormatLinkStylePolyLine->setChecked(true);
3059 void Main::formatLinkStylePolyParabel()
3061 VymModel *m=currentModel();
3064 m->setMapLinkStyle("StylePolyParabel");
3065 actionFormatLinkStylePolyParabel->setChecked(true);
3069 void Main::formatSelectBackColor()
3071 VymModel *m=currentModel();
3072 if (m) m->selectMapBackgroundColor();
3075 void Main::formatSelectBackImage()
3077 VymModel *m=currentModel();
3079 m->selectMapBackgroundImage();
3082 void Main::formatSelectLinkColor()
3084 VymModel *m=currentModel();
3087 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3088 m->setMapDefLinkColor( col );
3092 void Main::formatSelectSelectionColor()
3094 VymModel *m=currentModel();
3097 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3098 m->setSelectionColor (col);
3103 void Main::formatToggleLinkColorHint()
3105 VymModel *m=currentModel();
3106 if (m) m->toggleMapLinkColorHint();
3110 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3112 VymModel *m=currentModel();
3114 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3117 void Main::viewZoomReset()
3119 MapEditor *me=currentMapEditor();
3120 if (me) me->setZoomFactorTarget (1);
3123 void Main::viewZoomIn()
3125 MapEditor *me=currentMapEditor();
3126 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3129 void Main::viewZoomOut()
3131 MapEditor *me=currentMapEditor();
3132 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3135 void Main::viewCenter()
3137 VymModel *m=currentModel();
3138 if (m) m->emitShowSelection();
3141 void Main::networkStartServer()
3143 VymModel *m=currentModel();
3144 if (m) m->newServer();
3147 void Main::networkConnect()
3149 VymModel *m=currentModel();
3150 if (m) m->connectToServer();
3153 bool Main::settingsPDF()
3155 // Default browser is set in constructor
3157 QString text = QInputDialog::getText(
3158 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3159 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3161 settings.setValue ("/mainwindow/readerPDF",text);
3166 bool Main::settingsURL()
3168 // Default browser is set in constructor
3170 QString text = QInputDialog::getText(
3171 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3172 settings.value("/mainwindow/readerURL").toString()
3175 settings.setValue ("/mainwindow/readerURL",text);
3179 void Main::settingsMacroDir()
3181 QDir defdir(vymBaseDir.path() + "/macros");
3182 if (!defdir.exists())
3184 QDir dir=QFileDialog::getExistingDirectory (
3186 tr ("Directory with vym macros:"),
3187 settings.value ("/macros/macroDir",defdir.path()).toString()
3190 settings.setValue ("/macros/macroDir",dir.absolutePath());
3193 void Main::settingsUndoLevels()
3196 int i = QInputDialog::getInteger(
3198 tr("QInputDialog::getInteger()"),
3199 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3202 settings.setValue ("/mapeditor/stepsTotal",i);
3203 QMessageBox::information( this, tr( "VYM -Information:" ),
3204 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3208 void Main::settingsAutosaveToggle()
3210 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3213 void Main::settingsAutosaveTime()
3216 int i = QInputDialog::getInteger(
3218 tr("QInputDialog::getInteger()"),
3219 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3221 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3224 void Main::settingsWriteBackupFileToggle()
3226 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3229 void Main::settingsToggleAnimation()
3231 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3234 void Main::settingsToggleDelKey()
3236 if (actionSettingsUseDelKey->isOn())
3238 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3241 actionDelete->setAccel (QKeySequence (""));
3245 void Main::windowToggleNoteEditor()
3247 if (textEditor->isVisible() )
3248 windowHideNoteEditor();
3250 windowShowNoteEditor();
3253 void Main::windowToggleHistory()
3255 if (historyWindow->isVisible())
3256 historyWindow->hide();
3258 historyWindow->show();
3262 void Main::windowToggleProperty()
3264 if (branchPropertyWindow->isVisible())
3265 branchPropertyWindow->hide();
3267 branchPropertyWindow->show();
3268 branchPropertyWindow->setModel (currentModel() );
3271 void Main::windowToggleAntiAlias()
3273 bool b=actionViewToggleAntiAlias->isOn();
3275 for (int i=0;i<vymViews.count();i++)
3277 me=vymViews.at(i)->getMapEditor();
3278 if (me) me->setAntiAlias(b);
3283 bool Main::isAliased()
3285 return actionViewToggleAntiAlias->isOn();
3288 bool Main::hasSmoothPixmapTransform()
3290 return actionViewToggleSmoothPixmapTransform->isOn();
3293 void Main::windowToggleSmoothPixmap()
3295 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3297 for (int i=0;i<vymViews.count();i++)
3300 me=vymViews.at(i)->getMapEditor();
3301 if (me) me->setSmoothPixmap(b);
3305 void Main::updateHistory(SimpleSettings &undoSet)
3307 historyWindow->update (undoSet);
3310 void Main::updateNoteFlag()
3312 // this slot is connected to TextEditor::textHasChanged()
3314 VymModel *m=currentModel();
3315 if (m) m->updateNoteFlag();
3318 void Main::updateNoteEditor(QModelIndex index )
3320 cout << QObject::sender();
3321 QObject *obj=QObject::sender();
3322 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3323 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3324 //cout << "Main::updateNoteEditor model="<<sender();
3325 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3326 textEditor->setNote (ti->getNoteObj() );
3329 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3331 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3333 if (model && model==currentModel() )
3337 if (!oldsel.indexes().isEmpty() )
3339 ti=model->getItem(oldsel.indexes().first());
3341 // Don't update note if both treeItem and textEditor are empty
3342 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3343 // ti->setNoteObj (textEditor->getNoteObj(),false );
3345 if (!newsel.indexes().isEmpty() )
3347 ti=model->getItem(newsel.indexes().first());
3348 if (!ti->hasEmptyNote() )
3349 textEditor->setNote(ti->getNoteObj() );
3351 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3353 // Show URL and link in statusbar
3355 QString s=ti->getURL();
3356 if (!s.isEmpty() ) status+="URL: "+s+" ";
3358 if (!s.isEmpty() ) status+="Link: "+s;
3359 if (!status.isEmpty() ) statusMessage (status);
3362 textEditor->setInactive();
3368 void Main::updateActions()
3370 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3371 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3372 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3373 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3375 VymModel *m =currentModel();
3379 actionFilePrint->setEnabled (true);
3381 // Link style in context menu
3382 switch (m->getMapLinkStyle())
3384 case LinkableMapObj::Line:
3385 actionFormatLinkStyleLine->setChecked(true);
3387 case LinkableMapObj::Parabel:
3388 actionFormatLinkStyleParabel->setChecked(true);
3390 case LinkableMapObj::PolyLine:
3391 actionFormatLinkStylePolyLine->setChecked(true);
3393 case LinkableMapObj::PolyParabel:
3394 actionFormatLinkStylePolyParabel->setChecked(true);
3401 QPixmap pix( 16, 16 );
3402 pix.fill( m->getMapBackgroundColor() );
3403 actionFormatBackColor->setIconSet( pix );
3404 pix.fill( m->getSelectionColor() );
3405 actionFormatSelectionColor->setIconSet( pix );
3406 pix.fill( m->getMapDefLinkColor() );
3407 actionFormatLinkColor->setIconSet( pix );
3410 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3413 // Expanding/collapsing
3414 actionExpandAll->setEnabled (true);
3415 actionExpandOneLevel->setEnabled (true);
3416 actionCollapseOneLevel->setEnabled (true);
3420 actionFilePrint->setEnabled (false);
3422 // Expanding/collapsing
3423 actionExpandAll->setEnabled (false);
3424 actionExpandOneLevel->setEnabled (false);
3425 actionCollapseOneLevel->setEnabled (false);
3428 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3429 actionFormatLinkColorHint->setChecked(true);
3431 actionFormatLinkColorHint->setChecked(false);
3434 if (m && m->hasChanged() )
3435 actionFileSave->setEnabled( true);
3437 actionFileSave->setEnabled( false);
3438 if (m && m->isUndoAvailable())
3439 actionUndo->setEnabled( true);
3441 actionUndo->setEnabled( false);
3443 if (m && m->isRedoAvailable())
3444 actionRedo->setEnabled( true);
3446 actionRedo->setEnabled( false);
3450 TreeItem *selti=m->getSelectedItem();
3451 BranchItem *selbi=m->getSelectedBranch();
3454 if (selbi || selti->getType()==TreeItem::Image)
3456 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3457 actionFormatHideLinkUnselected->setEnabled (true);
3462 // Take care of xlinks
3463 branchXLinksContextMenuEdit->clear();
3464 branchXLinksContextMenuFollow->clear();
3465 if (selbi->xlinkCount()>0)
3469 for (int i=0; i<selbi->xlinkCount();++i)
3471 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3475 if (s.length()>xLinkMenuWidth)
3476 s=s.left(xLinkMenuWidth)+"...";
3477 branchXLinksContextMenuFollow->addAction (s);
3478 branchXLinksContextMenuEdit->addAction (s);
3483 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3486 actionToggleScroll->setEnabled (true);
3487 if ( selbi->isScrolled() )
3488 actionToggleScroll->setChecked(true);
3490 actionToggleScroll->setChecked(false);
3492 if ( selti->getURL().isEmpty() )
3494 actionOpenURL->setEnabled (false);
3495 actionOpenURLTab->setEnabled (false);
3499 actionOpenURL->setEnabled (true);
3500 actionOpenURLTab->setEnabled (true);
3502 if ( selti->getVymLink().isEmpty() )
3504 actionOpenVymLink->setEnabled (false);
3505 actionDeleteVymLink->setEnabled (false);
3508 actionOpenVymLink->setEnabled (true);
3509 actionDeleteVymLink->setEnabled (true);
3512 if (selbi->canMoveUp())
3513 actionMoveUp->setEnabled (true);
3515 actionMoveUp->setEnabled (false);
3516 if (selbi->canMoveDown())
3517 actionMoveDown->setEnabled (true);
3519 actionMoveDown->setEnabled (false);
3521 actionSortChildren->setEnabled (true);
3523 actionToggleHideExport->setEnabled (true);
3524 actionToggleHideExport->setChecked (selbi->hideInExport() );
3526 actionCopy->setEnabled (true);
3527 actionCut->setEnabled (true);
3528 if (!clipboardEmpty)
3529 actionPaste->setEnabled (true);
3531 actionPaste->setEnabled (false);
3532 for (int i=0; i<actionListBranches.size(); ++i)
3533 actionListBranches.at(i)->setEnabled(true);
3534 actionDelete->setEnabled (true);
3536 if ( selti->getType()==TreeItem::Image)
3538 actionOpenURL->setEnabled (false);
3539 actionOpenVymLink->setEnabled (false);
3540 actionDeleteVymLink->setEnabled (false);
3541 actionToggleHideExport->setEnabled (true);
3542 actionToggleHideExport->setChecked (selti->hideInExport() );
3545 actionCopy->setEnabled (true);
3546 actionCut->setEnabled (true);
3547 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3548 for (int i=0; i<actionListBranches.size(); ++i)
3549 actionListBranches.at(i)->setEnabled(false);
3550 actionDelete->setEnabled (true);
3551 actionMoveUp->setEnabled (false);
3552 actionMoveDown->setEnabled (false);
3557 actionCopy->setEnabled (false);
3558 actionCut->setEnabled (false);
3559 actionPaste->setEnabled (false);
3560 for (int i=0; i<actionListBranches.size(); ++i)
3561 actionListBranches.at(i)->setEnabled(false);
3563 actionToggleScroll->setEnabled (false);
3564 actionOpenURL->setEnabled (false);
3565 actionOpenVymLink->setEnabled (false);
3566 actionDeleteVymLink->setEnabled (false);
3567 actionHeading2URL->setEnabled (false);
3568 actionDelete->setEnabled (false);
3569 actionMoveUp->setEnabled (false);
3570 actionMoveDown->setEnabled (false);
3571 actionFormatHideLinkUnselected->setEnabled (false);
3572 actionSortChildren->setEnabled (false);
3573 actionToggleHideExport->setEnabled (false);
3578 Main::ModMode Main::getModMode()
3580 if (actionModModeColor->isOn()) return ModModeColor;
3581 if (actionModModeCopy->isOn()) return ModModeCopy;
3582 if (actionModModeXLink->isOn()) return ModModeXLink;
3586 bool Main::autoEditNewBranch()
3588 return actionSettingsAutoEditNewBranch->isOn();
3591 bool Main::autoSelectNewBranch()
3593 return actionSettingsAutoSelectNewBranch->isOn();
3596 void Main::windowShowNoteEditor()
3598 textEditor->setShowWithMain(true);
3600 actionViewToggleNoteEditor->setChecked (true);
3603 void Main::windowHideNoteEditor()
3605 textEditor->setShowWithMain(false);
3607 actionViewToggleNoteEditor->setChecked (false);
3610 void Main::setScript (const QString &script)
3612 scriptEditor->setScript (script);
3615 void Main::runScript (const QString &script)
3617 VymModel *m=currentModel();
3618 if (m) m->runScript (script);
3621 void Main::runScriptEverywhere (const QString &script)
3624 for (int i=0;i<=tabWidget->count() -1;i++)
3626 me=(MapEditor*)tabWidget->page(i);
3627 if (me) me->getModel()->runScript (script);
3631 void Main::windowNextEditor()
3633 if (tabWidget->currentIndex() < tabWidget->count())
3634 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3637 void Main::windowPreviousEditor()
3639 if (tabWidget->currentIndex() >0)
3640 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3643 void Main::standardFlagChanged()
3647 if ( actionSettingsUseFlagGroups->isOn() )
3648 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3650 currentModel()->toggleStandardFlag(sender()->name());
3655 void Main::testFunction1()
3657 if (!currentMapEditor()) return;
3658 currentMapEditor()->testFunction1();
3661 VymModel *m=currentModel();
3665 QString text = QInputDialog::getText(
3666 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3667 m->getSortFilter(), &ok, NULL);
3669 // user entered something and pressed OK
3670 m->setSortFilter (text);
3674 void Main::testFunction2()
3676 if (!currentMapEditor()) return;
3677 currentMapEditor()->testFunction2();
3680 void Main::testCommand()
3682 if (!currentMapEditor()) return;
3683 scriptEditor->show();
3686 QString com = QInputDialog::getText(
3687 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3688 if (ok) currentMapEditor()->parseAtom(com);
3692 void Main::helpDoc()
3694 QString locale = QLocale::system().name();
3696 if (locale.left(2)=="es")
3697 docname="vym_es.pdf";
3701 QStringList searchList;
3703 #if defined(Q_OS_MACX)
3704 searchList << "./vym.app/Contents/Resources/doc";
3705 #elif defined(Q_OS_WIN32)
3706 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3708 #if defined(VYM_DOCDIR)
3709 searchList << VYM_DOCDIR;
3711 // default path in SUSE LINUX
3712 searchList << "/usr/share/doc/packages/vym";
3715 searchList << "doc"; // relative path for easy testing in tarball
3716 searchList << "doc/tex"; // Easy testing working on vym.tex
3717 searchList << "/usr/share/doc/vym"; // Debian
3718 searchList << "/usr/share/doc/packages";// Knoppix
3722 for (int i=0; i<searchList.count(); ++i)
3724 docfile.setFileName(searchList.at(i)+"/"+docname);
3725 if (docfile.exists())
3734 QMessageBox::critical(0,
3735 tr("Critcal error"),
3736 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3741 Process *pdfProc = new Process();
3742 args << QDir::toNativeSeparators(docfile.fileName());
3744 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3747 QMessageBox::warning(0,
3749 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3750 tr("Please use Settings->")+tr("Set application to open PDF files"));
3757 void Main::helpDemo()
3759 QStringList filters;
3760 filters <<"VYM example map (*.vym)";
3761 QFileDialog *fd=new QFileDialog( this);
3762 #if defined(Q_OS_MACX)
3763 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3765 // default path in SUSE LINUX
3766 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3769 fd->setFileMode (QFileDialog::ExistingFiles);
3770 fd->setFilters (filters);
3771 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3775 if ( fd->exec() == QDialog::Accepted )
3777 lastFileDir=fd->directory().path();
3778 QStringList flist = fd->selectedFiles();
3779 QStringList::Iterator it = flist.begin();
3780 while( it != flist.end() )
3783 fileLoad(*it, NewMap);
3791 void Main::helpAbout()
3794 ad.setName ("aboutwindow");
3795 ad.setMinimumSize(500,500);
3796 ad.resize (QSize (500,500));
3800 void Main::helpAboutQT()
3802 QMessageBox::aboutQt( this, "Qt Application Example" );
3805 void Main::callMacro ()
3807 QAction *action = qobject_cast<QAction *>(sender());
3811 i=action->data().toInt();
3812 QString mDir (settings.value ("macros/macroDir").toString() );
3814 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3816 if ( !f.open( QIODevice::ReadOnly ) )
3818 QMessageBox::warning(0,
3820 tr("Couldn't find a macro at %1.\n").arg(fn)+
3821 tr("Please use Settings->")+tr("Set directory for vym macros"));
3825 QTextStream ts( &f );
3826 QString macro= ts.read();
3828 if (! macro.isEmpty())
3830 VymModel *m=currentModel();
3831 if (m) m->runScript(macro);