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 ) ) );
151 // Initialize Find window
152 findWindow=new FindWindow(NULL);
153 findWindow->move (x(),y()+70);
154 connect (findWindow, SIGNAL( findButton(QString) ),
155 this, SLOT(editFind(QString) ) );
156 connect (findWindow, SIGNAL( somethingChanged() ),
157 this, SLOT(editFindChanged() ) );
159 // Initialize some settings, which are platform dependant
162 // application to open URLs
163 p="/mainwindow/readerURL";
164 #if defined(Q_OS_LINUX)
165 s=settings.value (p,"xdg-open").toString();
167 #if defined(Q_OS_MACX)
168 s=settings.value (p,"/usr/bin/open").toString();
171 #if defined(Q_OS_WIN32)
172 // Assume that system has been set up so that
173 // Explorer automagically opens up the URL
174 // in the user's preferred browser.
175 s=settings.value (p,"explorer").toString();
177 s=settings.value (p,"mozilla").toString();
181 settings.setValue( p,s);
183 // application to open PDFs
184 p="/mainwindow/readerPDF";
185 #if defined(Q_OS_LINUX)
186 s=settings.value (p,"xdg-open").toString();
188 #if defined(Q_OS_MACX)
189 s=settings.value (p,"/usr/bin/open").toString();
190 #elif defined(Q_OS_WIN32)
191 s=settings.value (p,"acrord32").toString();
193 s=settings.value (p,"acroread").toString();
196 settings.setValue( p,s);
198 // width of xLinksMenu
201 // Create tab widget which holds the maps
202 tabWidget= new QTabWidget (this);
203 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
204 this, SLOT( editorChanged( QWidget * ) ) );
206 setCentralWidget(tabWidget);
210 setupFormatActions();
214 setupNetworkActions();
215 setupSettingsActions();
218 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
221 // Status bar and progress bar there
224 progressBar=new QProgressBar;
226 statusBar()->addPermanentWidget(progressBar);
228 restoreState (settings.value("/mainwindow/state",0).toByteArray());
236 #if defined(Q_OS_WIN32)
237 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
239 settings.setValue ("/mainwindow/geometry/size", size());
240 settings.setValue ("/mainwindow/geometry/pos", pos());
241 settings.setValue ("/mainwindow/state",saveState(0));
243 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
244 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
245 settings.setValue( "/version/version", vymVersion );
246 settings.setValue( "/version/builddate", vymBuildDate );
248 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
249 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
250 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
251 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
252 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
253 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
254 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
255 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
257 //TODO save scriptEditor settings
259 // call the destructors
261 delete historyWindow;
262 delete branchPropertyWindow;
265 // Remove temporary directory
266 removeDir (QDir(tmpVymDir));
269 void Main::loadCmdLine()
271 /* TODO draw some kind of splashscreen while loading...
277 QStringList flist=options.getFileList();
278 QStringList::Iterator it=flist.begin();
280 while (it !=flist.end() )
282 fileLoad (*it, NewMap);
288 void Main::statusMessage(const QString &s)
290 // Surpress messages while progressbar during
292 if (progressMin==progressMax)
293 statusBar()->message( s);
296 void Main::setProgressMinimum (int min)
298 progressBar->setMinimum(min);
302 void Main::setProgressMaximum (int max)
304 progressBar->setMaximum(max);
308 statusBar()->addPermanentWidget(progressBar);
313 void Main::setProgressValue (int v)
315 progressBar->setValue (v);
318 void Main::removeProgressBar()
321 statusBar()->removeWidget(progressBar);
322 progressMax=progressMin=0;
325 void Main::closeEvent (QCloseEvent* )
331 void Main::setupFileActions()
333 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
334 QToolBar *tb = addToolBar( tr ("&Map") );
335 tb->setObjectName ("mapTB");
338 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
339 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
340 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
342 fileMenu->addAction (a);
343 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
345 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
346 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
347 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
348 fileMenu->addAction (a);
349 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
352 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
353 a->setStatusTip (tr( "Open","Status tip File menu" ) );
354 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
356 fileMenu->addAction (a);
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
359 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
360 fileMenu->addSeparator();
362 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
363 a->setStatusTip ( tr( "Save","Status tip file menu" ));
364 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
366 fileMenu->addAction (a);
367 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
370 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
371 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
372 fileMenu->addAction (a);
373 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
375 fileMenu->addSeparator();
377 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
379 a = new QAction(tr("KDE 3 Bookmarks"), this);
380 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
381 a->addTo (fileImportMenu);
382 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
384 a = new QAction(tr("KDE 4 Bookmarks"), this);
385 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
386 a->addTo (fileImportMenu);
387 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
389 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
391 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
392 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
393 a->addTo (fileImportMenu);
394 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
397 a = new QAction("Freemind...",this);
398 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
399 fileImportMenu->addAction (a);
400 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
402 a = new QAction("Mind Manager...",this);
403 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
404 fileImportMenu->addAction (a);
405 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
407 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
408 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
409 fileImportMenu->addAction (a);
410 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
412 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
414 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
415 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
416 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
417 fileExportMenu->addAction (a);
419 a = new QAction( "Open Office...", this);
420 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
421 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
422 fileExportMenu->addAction (a);
424 a = new QAction( "Webpage (XHTML)...",this );
425 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
426 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
427 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
428 fileExportMenu->addAction (a);
430 a = new QAction( "Text (ASCII)...", this);
431 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
432 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
433 fileExportMenu->addAction (a);
435 a = new QAction( "Spreadsheet (CSV)...", this);
436 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
437 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
438 fileExportMenu->addAction (a);
440 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
441 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
442 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
443 fileExportMenu->addAction (a);
445 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
446 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
447 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
448 fileExportMenu->addAction (a);
450 a = new QAction( "Taskjuggler...", this );
451 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
452 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
453 fileExportMenu->addAction (a);
455 a = new QAction( "LaTeX...", this);
456 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
457 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
458 fileExportMenu->addAction (a);
460 a = new QAction( "XML..." , this );
461 a->setStatusTip (tr( "Export as %1").arg("XML"));
462 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
463 fileExportMenu->addAction (a);
465 fileMenu->addSeparator();
467 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
468 a->setStatusTip ( tr( "Print" ,"File menu") );
469 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
471 fileMenu->addAction (a);
472 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
475 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
476 a->setStatusTip (tr( "Close Map" ) );
477 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
478 fileMenu->addAction (a);
479 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
481 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
482 a->setStatusTip ( tr( "Exit")+" "+vymName );
483 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
484 fileMenu->addAction (a);
485 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
490 void Main::setupEditActions()
492 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
493 tb->setLabel( "Edit Actions" );
494 tb->setObjectName ("actionsTB");
495 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
499 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
500 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
501 a->setStatusTip (tr( "Undo" ) );
502 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
503 a->setEnabled (false);
505 editMenu->addAction (a);
508 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
509 a->setStatusTip (tr( "Redo" ));
510 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
512 editMenu->addAction (a);
513 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
516 editMenu->addSeparator();
517 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
518 a->setStatusTip ( tr( "Copy" ) );
519 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
520 a->setEnabled (false);
522 editMenu->addAction (a);
523 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
526 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
527 a->setStatusTip ( tr( "Cut" ) );
528 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
529 a->setEnabled (false);
531 editMenu->addAction (a);
533 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
535 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
536 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
537 a->setStatusTip ( tr( "Paste" ) );
538 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
539 a->setEnabled (false);
541 editMenu->addAction (a);
544 // Shortcut to delete selection
545 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
546 a->setStatusTip (tr( "Delete Selection" ));
547 a->setShortcut ( Qt::Key_Delete); //Delete selection
548 a->setShortcutContext (Qt::WindowShortcut);
550 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
553 // Shortcut to add attribute
554 a= new QAction(tr( "Add attribute" ), this);
555 a->setShortcut ( Qt::Key_Q);
556 a->setShortcutContext (Qt::WindowShortcut);
558 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
559 actionAddAttribute= a;
562 // Shortcut to add mapcenter
563 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
564 a->setShortcut ( Qt::Key_M);
565 a->setShortcutContext (Qt::WindowShortcut);
566 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
567 //actionListBranches.append(a);
569 actionAddMapCenter = a;
572 // Shortcut to add branch
573 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
574 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
575 alt->setShortcut (Qt::Key_A); //Add branch
576 alt->setShortcutContext (Qt::WindowShortcut);
578 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
579 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
580 a->setStatusTip ( tr( "Add a branch as child of selection" ));
581 a->setShortcut (Qt::Key_Insert); //Add branch
582 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
583 actionListBranches.append(a);
584 #if defined (Q_OS_MACX)
585 // In OSX show different shortcut in menues, the keys work indepently always
590 editMenu->addAction (actionAddBranch);
591 tb->addAction (actionAddBranch);
594 // Add branch by inserting it at selection
595 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
596 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
597 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
598 a->setShortcutContext (Qt::WindowShortcut);
600 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
601 a->setEnabled (false);
602 actionListBranches.append(a);
603 actionAddBranchBefore=a;
604 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
605 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
606 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
607 a->setShortcutContext (Qt::WindowShortcut);
609 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
610 actionListBranches.append(a);
613 a = new QAction(tr( "Add branch above","Edit menu" ), this);
614 a->setStatusTip ( tr( "Add a branch above selection" ));
615 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
616 a->setShortcutContext (Qt::WindowShortcut);
618 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
619 a->setEnabled (false);
620 actionListBranches.append(a);
621 actionAddBranchAbove=a;
622 a = new QAction(tr( "Add branch above","Edit menu" ), this);
623 a->setStatusTip ( tr( "Add a branch above selection" ));
624 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
625 a->setShortcutContext (Qt::WindowShortcut);
627 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
628 actionListBranches.append(a);
631 a = new QAction(tr( "Add branch below","Edit menu" ), this);
632 a->setStatusTip ( tr( "Add a branch below selection" ));
633 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
634 a->setShortcutContext (Qt::WindowShortcut);
636 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
637 a->setEnabled (false);
638 actionListBranches.append(a);
639 actionAddBranchBelow=a;
640 a = new QAction(tr( "Add branch below","Edit menu" ), this);
641 a->setStatusTip ( tr( "Add a branch below selection" ));
642 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
643 a->setShortcutContext (Qt::WindowShortcut);
645 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
646 actionListBranches.append(a);
648 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
649 a->setStatusTip ( tr( "Move branch up" ) );
650 a->setShortcut (Qt::Key_PageUp ); // Move branch up
651 a->setEnabled (false);
653 editMenu->addAction (a);
654 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
657 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
658 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
659 a->setStatusTip (tr( "Move branch down" ) );
660 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
661 a->setEnabled (false);
663 editMenu->addAction (a);
666 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
667 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
668 a->setShortcut ( Qt::Key_D ); // Detach branch
669 editMenu->addAction (a);
670 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
673 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
674 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
675 a->setEnabled (true);
677 editMenu->addAction (a);
678 actionSortChildren=a;
680 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
681 alt->setShortcut ( Qt::Key_S ); // Scroll branch
682 alt->setStatusTip (tr( "Scroll branch" ));
683 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
684 #if defined(Q_OS_MACX)
685 actionToggleScroll=alt;
687 actionToggleScroll=a;
689 actionToggleScroll->setEnabled (false);
690 actionToggleScroll->setToggleAction(true);
691 tb->addAction (actionToggleScroll);
692 editMenu->addAction ( actionToggleScroll);
693 editMenu->addAction (actionToggleScroll);
696 actionListBranches.append(actionToggleScroll);
698 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
699 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
700 a->setStatusTip (tr( "Expand all branches" ));
701 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
703 actionExpandAll->setEnabled (false);
704 actionExpandAll->setToggleAction(false);
705 //tb->addAction (actionExpandAll);
706 editMenu->addAction ( actionExpandAll);
708 actionListBranches.append(actionExpandAll);
710 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
711 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
712 a->setStatusTip (tr( "Expand one level in tree editor" ));
713 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
714 a->setEnabled (false);
715 a->setToggleAction(false);
716 actionExpandOneLevel=a;
718 editMenu->addAction ( a);
720 actionListBranches.append(a);
722 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
723 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
724 a->setStatusTip (tr( "Collapse one level in tree editor" ));
725 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
726 a->setEnabled (false);
727 a->setToggleAction(false);
728 actionCollapseOneLevel=a;
730 editMenu->addAction ( a);
732 actionListBranches.append(a);
734 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
735 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
736 editMenu->addAction (a);
737 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
739 editMenu->addSeparator();
741 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
742 a->setStatusTip (tr( "Find" ) );
743 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
744 editMenu->addAction (a);
745 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
747 editMenu->addSeparator();
749 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
750 a->setShortcut (Qt::SHIFT + Qt::Key_U );
751 a->setShortcut (tr( "Open URL" ));
754 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
757 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
758 a->setStatusTip (tr( "Open URL in new tab" ));
759 //a->setShortcut (Qt::CTRL+Qt::Key_U );
761 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
764 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
765 a->setStatusTip (tr( "Open all URLs in subtree" ));
766 a->setShortcut ( Qt::CTRL + Qt::Key_U );
768 actionListBranches.append(a);
769 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
770 actionOpenMultipleURLTabs=a;
772 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
773 a->setStatusTip ( tr( "Edit URL" ) );
774 a->setShortcut ( Qt::Key_U );
775 a->setShortcutContext (Qt::WindowShortcut);
776 actionListBranches.append(a);
778 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
781 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
782 a->setStatusTip ( tr( "Edit local URL" ) );
783 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
784 a->setShortcutContext (Qt::WindowShortcut);
785 actionListBranches.append(a);
787 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
790 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
791 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
792 a->setEnabled (false);
793 actionListBranches.append(a);
794 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
797 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
798 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
799 a->setEnabled (false);
800 actionListBranches.append(a);
801 a->setShortcut ( Qt::Key_B );
802 a->setShortcutContext (Qt::WindowShortcut);
804 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
805 actionBugzilla2URL=a;
807 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
808 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
809 a->setEnabled (false);
810 actionListBranches.append(a);
811 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
814 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
815 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
817 a->setEnabled (false);
818 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
821 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
822 a->setStatusTip ( tr( "Open all vym links in subtree" ));
823 a->setEnabled (false);
824 actionListBranches.append(a);
825 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
826 actionOpenMultipleVymLinks=a;
829 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
830 a->setEnabled (false);
831 a->setStatusTip ( tr( "Edit link to another vym map" ));
832 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
833 actionListBranches.append(a);
836 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
837 a->setStatusTip ( tr( "Delete link to another vym map" ));
838 a->setEnabled (false);
839 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
840 actionDeleteVymLink=a;
842 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
843 a->setStatusTip ( tr( "Hide object in exports" ) );
844 a->setShortcut (Qt::Key_H );
845 a->setToggleAction(true);
847 a->setEnabled (false);
848 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
849 actionToggleHideExport=a;
851 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
852 a->setStatusTip ( tr( "Add timestamp" ));
853 a->setEnabled (false);
854 actionListBranches.append(a);
855 a->setShortcut ( Qt::Key_T ); // Add timestamp
856 a->setShortcutContext (Qt::WindowShortcut);
858 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
859 actionAddTimestamp=a;
861 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
862 a->setStatusTip ( tr( "Edit Map Info" ));
863 a->setEnabled (true);
864 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
867 // Import at selection (adding to selection)
868 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
869 a->setStatusTip (tr( "Add map at selection" ));
870 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
871 a->setEnabled (false);
872 actionListBranches.append(a);
875 // Import at selection (replacing selection)
876 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
877 a->setStatusTip (tr( "Replace selection with map" ));
878 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
879 a->setEnabled (false);
880 actionListBranches.append(a);
881 actionImportReplace=a;
884 a = new QAction( tr( "Save selection","Edit menu" ), this);
885 a->setStatusTip (tr( "Save selection" ));
886 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
887 a->setEnabled (false);
888 actionListBranches.append(a);
891 // Only remove branch, not its children
892 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
893 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
894 a->setShortcut (Qt::ALT + Qt::Key_Delete );
895 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
896 a->setEnabled (false);
898 actionListBranches.append(a);
899 actionDeleteKeepChildren=a;
901 // Only remove children of a branch
902 a = new QAction( tr( "Remove children","Edit menu" ), this);
903 a->setStatusTip (tr( "Remove children of branch" ));
904 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
905 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
906 a->setEnabled (false);
907 actionListBranches.append(a);
908 actionDeleteChildren=a;
910 a = new QAction( tr( "Add Image...","Edit menu" ), this);
911 a->setStatusTip (tr( "Add Image" ));
912 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
915 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
916 a->setStatusTip (tr( "Set properties for selection" ));
917 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
918 a->setShortcutContext (Qt::WindowShortcut);
919 a->setToggleAction (true);
921 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
922 actionViewTogglePropertyWindow=a;
926 void Main::setupFormatActions()
928 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
930 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
931 tb->setObjectName ("formatTB");
934 pix.fill (Qt::black);
935 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
936 a->setStatusTip ( tr( "Set Color" ));
937 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
939 formatMenu->addAction (a);
941 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
942 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
943 a->setShortcut (Qt::CTRL + Qt::Key_K );
944 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
945 a->setEnabled (false);
947 formatMenu->addAction (a);
948 actionListBranches.append(a);
949 actionFormatPickColor=a;
951 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
952 a->setStatusTip ( tr( "Color branch" ) );
953 a->setShortcut (Qt::CTRL + Qt::Key_B);
954 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
955 a->setEnabled (false);
957 formatMenu->addAction (a);
958 actionListBranches.append(a);
959 actionFormatColorSubtree=a;
961 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
962 a->setStatusTip ( tr( "Color Subtree" ));
963 //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree
964 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
965 a->setEnabled (false);
966 formatMenu->addAction (a);
968 actionListBranches.append(a);
969 actionFormatColorSubtree=a;
971 formatMenu->addSeparator();
972 actionGroupFormatLinkStyles=new QActionGroup ( this);
973 actionGroupFormatLinkStyles->setExclusive (true);
974 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
975 a->setStatusTip (tr( "Line" ));
976 a->setToggleAction(true);
977 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
978 formatMenu->addAction (a);
979 actionFormatLinkStyleLine=a;
980 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
981 a->setStatusTip (tr( "Line" ));
982 a->setToggleAction(true);
983 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
984 formatMenu->addAction (a);
985 actionFormatLinkStyleParabel=a;
986 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
987 a->setStatusTip (tr( "PolyLine" ));
988 a->setToggleAction(true);
989 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
990 formatMenu->addAction (a);
991 actionFormatLinkStylePolyLine=a;
992 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
993 a->setStatusTip (tr( "PolyParabel" ) );
994 a->setToggleAction(true);
995 a->setChecked (true);
996 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
997 formatMenu->addAction (a);
998 actionFormatLinkStylePolyParabel=a;
1000 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1001 a->setStatusTip (tr( "Hide link" ));
1002 a->setToggleAction(true);
1003 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1004 actionFormatHideLinkUnselected=a;
1006 formatMenu->addSeparator();
1007 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1008 a->setStatusTip (tr( "Use same color for links and headings" ));
1009 a->setToggleAction(true);
1010 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1011 formatMenu->addAction (a);
1012 actionFormatLinkColorHint=a;
1014 pix.fill (Qt::white);
1015 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1016 a->setStatusTip (tr( "Set Link Color" ));
1017 formatMenu->addAction (a);
1018 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1019 actionFormatLinkColor=a;
1021 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1022 a->setStatusTip (tr( "Set Selection Color" ));
1023 formatMenu->addAction (a);
1024 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1025 actionFormatSelectionColor=a;
1027 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1028 a->setStatusTip (tr( "Set Background Color" ));
1029 formatMenu->addAction (a);
1030 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1031 actionFormatBackColor=a;
1033 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1034 a->setStatusTip (tr( "Set Background image" ));
1035 formatMenu->addAction (a);
1036 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1037 actionFormatBackImage=a;
1041 void Main::setupViewActions()
1043 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1044 tb->setLabel( "View Actions" );
1045 tb->setObjectName ("viewTB");
1046 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1048 Switchboard switchboard; //FIXME-1 testing...
1051 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1052 a->setStatusTip ( tr( "Zoom reset" ) );
1053 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1054 switchboard.addConnection(a,"CTRL+0");
1056 viewMenu->addAction (a);
1057 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1059 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1060 a->setStatusTip (tr( "Zoom in" ));
1061 switchboard.addConnection(a,"CTRL++");
1063 viewMenu->addAction (a);
1064 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1066 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1067 a->setStatusTip (tr( "Zoom out" ));
1068 switchboard.addConnection(a,"CTRL+-");
1070 viewMenu->addAction (a);
1071 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1073 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1074 a->setStatusTip (tr( "Show selection" ));
1075 switchboard.addConnection(a,".");
1077 viewMenu->addAction (a);
1078 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1080 viewMenu->addSeparator();
1082 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1083 a->setStatusTip ( tr( "Show Note Editor" ));
1084 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1085 a->setToggleAction(true);
1087 viewMenu->addAction (a);
1088 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1089 actionViewToggleNoteEditor=a;
1091 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1092 a->setStatusTip ( tr( "Show History Window" ));
1093 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1094 a->setToggleAction(true);
1096 viewMenu->addAction (a);
1097 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1098 actionViewToggleHistoryWindow=a;
1100 viewMenu->addAction (actionViewTogglePropertyWindow);
1102 viewMenu->addSeparator();
1104 a = new QAction(tr( "Antialiasing","View action" ),this );
1105 a->setStatusTip ( tr( "Antialiasing" ));
1106 a->setToggleAction(true);
1107 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1108 viewMenu->addAction (a);
1109 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1110 actionViewToggleAntiAlias=a;
1112 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1113 a->setStatusTip (a->text());
1114 a->setToggleAction(true);
1115 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1116 viewMenu->addAction (a);
1117 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1118 actionViewToggleSmoothPixmapTransform=a;
1120 a = new QAction(tr( "Next Map","View action" ), this);
1121 a->setStatusTip (a->text());
1122 a->setShortcut (Qt::ALT + Qt::Key_N );
1123 viewMenu->addAction (a);
1124 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1126 a = new QAction (tr( "Previous Map","View action" ), this );
1127 a->setStatusTip (a->text());
1128 a->setShortcut (Qt::ALT + Qt::Key_P );
1129 viewMenu->addAction (a);
1130 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1132 switchboard.print();
1136 void Main::setupModeActions()
1138 //QPopupMenu *menu = new QPopupMenu( this );
1139 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1141 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1142 tb->setObjectName ("modesTB");
1144 actionGroupModModes=new QActionGroup ( this);
1145 actionGroupModModes->setExclusive (true);
1146 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1147 a->setShortcut (Qt::Key_J);
1148 a->setStatusTip ( tr( "Use modifier to color branches" ));
1149 a->setToggleAction(true);
1151 a->setChecked(true);
1152 actionModModeColor=a;
1154 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1155 a->setShortcut( Qt::Key_K);
1156 a->setStatusTip( tr( "Use modifier to copy" ));
1157 a->setToggleAction(true);
1159 actionModModeCopy=a;
1161 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1162 a->setShortcut (Qt::Key_L);
1163 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1164 a->setToggleAction(true);
1166 actionModModeXLink=a;
1170 void Main::setupFlagActions()
1172 // Create System Flags
1175 Flag *flag=new Flag;;
1176 flag->setVisible(true);
1178 flag->load(QPixmap(flagsPath+"flag-note.png"));
1179 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1181 flag->load(QPixmap(flagsPath+"flag-url.png"));
1182 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1184 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1185 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1187 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1188 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1190 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1191 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1193 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1194 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1196 // Create Standard Flags
1197 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1198 tb->setObjectName ("standardFlagTB");
1199 standardFlagsMaster->setToolBar (tb);
1201 flag->load(flagsPath+"flag-exclamationmark.png");
1202 flag->setGroup("standard-mark");
1203 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1205 flag->load(flagsPath+"flag-questionmark.png");
1206 flag->setGroup("standard-mark");
1207 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1209 flag->load(flagsPath+"flag-hook-green.png");
1210 flag->setGroup("standard-hook");
1211 setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
1213 flag->load(flagsPath+"flag-cross-red.png");
1214 flag->setGroup("standard-hook");
1215 setupFlag (flag,tb,"cross-red",tr("Not ok!","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 new ModelTest(vm, this); //FIXME-3
1765 VymView *vv=new VymView (vm);
1766 vymViews.append (vv);
1767 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1768 tabWidget->setCurrentIndex (vymViews.count() );
1771 // Create MapCenter for empty map
1775 // For the very first map we do not have flagrows yet...
1779 void Main::fileNewCopy()
1781 QString fn="unnamed";
1782 VymModel *srcModel=currentModel();
1787 VymModel *dstModel=vymViews.last()->getModel();
1788 dstModel->select("mc:");
1789 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1793 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1795 ErrorCode err=success;
1797 // fn is usually the archive, mapfile the file after uncompressing
1800 // Make fn absolute (needed for unzip)
1801 fn=QDir (fn).absPath();
1807 // Check, if map is already loaded
1809 while (i<=tabWidget->count() -1)
1811 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1813 // Already there, ask for confirmation
1814 QMessageBox mb( vymName,
1815 tr("The map %1\nis already opened."
1816 "Opening the same map in multiple editors may lead \n"
1817 "to confusion when finishing working with vym."
1818 "Do you want to").arg(fn),
1819 QMessageBox::Warning,
1820 QMessageBox::Yes | QMessageBox::Default,
1821 QMessageBox::Cancel | QMessageBox::Escape,
1822 QMessageBox::NoButton);
1823 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1824 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1827 case QMessageBox::Yes:
1828 // end loop and load anyway
1829 i=tabWidget->count();
1831 case QMessageBox::Cancel:
1841 int tabIndex=tabWidget->currentPageIndex();
1844 if ( !fn.isEmpty() )
1846 vm = currentModel();
1847 // Check first, if mapeditor exists
1848 // If it is not default AND we want a new map,
1849 // create a new mapeditor in a new tab
1850 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1853 VymView *vv=new VymView (vm);
1854 vymViews.append (vv);
1855 tabWidget->addTab (vv,fn);
1856 tabIndex=tabWidget->count()-1;
1857 tabWidget->setCurrentPage (tabIndex);
1861 // Check, if file exists (important for creating new files
1862 // from command line
1863 if (!QFile(fn).exists() )
1865 QMessageBox mb( vymName,
1866 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1867 QMessageBox::Question,
1869 QMessageBox::Cancel | QMessageBox::Default,
1870 QMessageBox::NoButton );
1872 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1873 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1876 case QMessageBox::Yes:
1878 currentMapEditor()->getModel()->setFilePath(fn);
1879 tabWidget->setTabText (tabIndex,
1880 currentMapEditor()->getModel()->getFileName() );
1881 statusBar()->message( "Created " + fn , statusbarTime );
1884 case QMessageBox::Cancel:
1885 // don't create new map
1886 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1893 //tabWidget->currentPage() won't be NULL here, because of above...
1894 tabWidget->setCurrentIndex (tabIndex);
1895 //FIXME-3 no me anymore... me->viewport()->setFocus();
1899 // Save existing filename in case we import
1900 QString fn_org=vm->getFilePath();
1902 // Finally load map into mapEditor
1903 vm->setFilePath (fn);
1904 err=vm->load(fn,lmode,ftype);
1906 // Restore old (maybe empty) filepath, if this is an import
1908 vm->setFilePath (fn_org);
1911 // Finally check for errors and go home
1914 if (lmode==NewMap) fileCloseMap();
1915 statusBar()->message( "Could not load " + fn, statusbarTime );
1920 vm->setFilePath (fn);
1921 tabWidget->setTabText (tabIndex, vm->getFileName());
1922 if (!isInTmpDir (fn))
1924 // Only append to lastMaps if not loaded from a tmpDir
1925 // e.g. imported bookmarks are in a tmpDir
1926 addRecentMap(vm->getFilePath() );
1928 actionFilePrint->setEnabled (true);
1930 statusBar()->message( "Loaded " + fn, statusbarTime );
1937 void Main::fileLoad(const LoadMode &lmode)
1939 QStringList filters;
1940 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1941 QFileDialog *fd=new QFileDialog( this);
1942 fd->setDir (lastFileDir);
1943 fd->setFileMode (QFileDialog::ExistingFiles);
1944 fd->setFilters (filters);
1948 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1951 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1954 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1960 if ( fd->exec() == QDialog::Accepted )
1962 lastFileDir=fd->directory().path();
1963 QStringList flist = fd->selectedFiles();
1964 QStringList::Iterator it = flist.begin();
1965 while( it != flist.end() )
1968 fileLoad(*it, lmode);
1975 void Main::fileLoad()
1980 void Main::fileLoadRecent()
1982 QAction *action = qobject_cast<QAction *>(sender());
1984 fileLoad (action->data().toString(), NewMap);
1987 void Main::addRecentMap (const QString &fileName)
1990 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1991 files.removeAll(fileName);
1992 files.prepend(fileName);
1993 while (files.size() > MaxRecentFiles)
1996 settings.setValue("/mainwindow/recentFileList", files);
1998 setupRecentMapsMenu();
2001 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2005 if ( m->getFilePath().isEmpty() )
2007 // We have no filepath yet,
2008 // call fileSaveAs() now, this will call fileSave()
2010 // First switch to editor
2011 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2012 fileSaveAs(savemode);
2015 if (m->save (savemode)==success)
2017 statusBar()->message(
2018 tr("Saved %1").arg(m->getFilePath()),
2020 addRecentMap (m->getFilePath() );
2022 statusBar()->message(
2023 tr("Couldn't save ").arg(m->getFilePath()),
2027 void Main::fileSave()
2029 fileSave (currentModel(), CompleteMap);
2032 void Main::fileSave(VymModel *m)
2034 fileSave (m,CompleteMap);
2037 void Main::fileSaveAs(const SaveMode& savemode)
2041 if (currentMapEditor())
2043 if (savemode==CompleteMap)
2044 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2046 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2047 if ( !fn.isEmpty() )
2049 // Check for existing file
2050 if (QFile (fn).exists())
2052 QMessageBox mb( vymName,
2053 tr("The file %1\nexists already. Do you want to").arg(fn),
2054 QMessageBox::Warning,
2055 QMessageBox::Yes | QMessageBox::Default,
2056 QMessageBox::Cancel | QMessageBox::Escape,
2057 QMessageBox::NoButton);
2058 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2059 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2062 case QMessageBox::Yes:
2065 case QMessageBox::Cancel:
2072 // New file, add extension to filename, if missing
2073 // This is always .vym or .vyp, depending on savemode
2074 if (savemode==CompleteMap)
2076 if (!fn.contains (".vym") && !fn.contains (".xml"))
2080 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2089 VymModel *m=currentModel();
2091 fileSave(m, savemode);
2093 // Set name of tab, assuming current tab is the one we just saved
2094 if (savemode==CompleteMap)
2095 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2101 void Main::fileSaveAs()
2103 fileSaveAs (CompleteMap);
2106 void Main::fileImportKDE3Bookmarks()
2108 ImportKDE3Bookmarks im;
2110 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2111 currentMapEditor()->getModel()->setFilePath ("");
2114 void Main::fileImportKDE4Bookmarks()
2116 ImportKDE4Bookmarks im;
2118 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2119 currentMapEditor()->getModel()->setFilePath ("");
2122 void Main::fileImportFirefoxBookmarks()
2124 Q3FileDialog *fd=new Q3FileDialog( this);
2125 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2126 fd->setMode (Q3FileDialog::ExistingFiles);
2127 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2128 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2131 if ( fd->exec() == QDialog::Accepted )
2133 ImportFirefoxBookmarks im;
2134 QStringList flist = fd->selectedFiles();
2135 QStringList::Iterator it = flist.begin();
2136 while( it != flist.end() )
2139 if (im.transform() &&
2140 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2141 currentMapEditor() )
2142 currentMapEditor()->getModel()->setFilePath ("");
2149 void Main::fileImportFreemind()
2151 QStringList filters;
2152 filters <<"Freemind map (*.mm)"<<"All files (*)";
2153 QFileDialog *fd=new QFileDialog( this);
2154 fd->setDir (lastFileDir);
2155 fd->setFileMode (QFileDialog::ExistingFiles);
2156 fd->setFilters (filters);
2157 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2161 if ( fd->exec() == QDialog::Accepted )
2163 lastFileDir=fd->directory().path();
2164 QStringList flist = fd->selectedFiles();
2165 QStringList::Iterator it = flist.begin();
2166 while( it != flist.end() )
2169 if ( fileLoad (fn,NewMap, FreemindMap) )
2171 currentMapEditor()->getModel()->setFilePath ("");
2180 void Main::fileImportMM()
2184 Q3FileDialog *fd=new Q3FileDialog( this);
2185 fd->setDir (lastFileDir);
2186 fd->setMode (Q3FileDialog::ExistingFiles);
2187 fd->addFilter ("Mind Manager (*.mmap)");
2188 fd->setCaption(tr("Import")+" "+"Mind Manager");
2191 if ( fd->exec() == QDialog::Accepted )
2193 lastFileDir=fd->dirPath();
2194 QStringList flist = fd->selectedFiles();
2195 QStringList::Iterator it = flist.begin();
2196 while( it != flist.end() )
2199 if (im.transform() &&
2200 success==fileLoad (im.getTransformedFile(),NewMap) &&
2201 currentMapEditor() )
2202 currentMapEditor()->getModel()->setFilePath ("");
2209 void Main::fileImportDir()
2211 VymModel *m=currentModel();
2212 if (m) m->importDir();
2215 void Main::fileExportXML()
2217 VymModel *m=currentModel();
2218 if (m) m->exportXML();
2222 void Main::fileExportXHTML()
2224 VymModel *m=currentModel();
2225 if (m) m->exportXHTML();
2228 void Main::fileExportImage()
2230 VymModel *m=currentModel();
2231 if (m) m->exportImage();
2234 void Main::fileExportASCII()
2236 VymModel *m=currentModel();
2237 if (m) m->exportASCII();
2240 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2242 VymModel *m=currentModel();
2247 ex.addFilter ("CSV (*.csv)");
2248 ex.setDir(lastImageDir);
2249 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2250 if (ex.execDialog() )
2252 m->setExportMode(true);
2254 m->setExportMode(false);
2259 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2261 VymModel *m=currentModel();
2266 ex.addFilter ("Tex (*.tex)");
2267 ex.setDir(lastImageDir);
2268 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2269 if (ex.execDialog() )
2271 m->setExportMode(true);
2273 m->setExportMode(false);
2278 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2280 ExportKDE3Bookmarks ex;
2281 VymModel *m=currentModel();
2289 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2291 ExportKDE4Bookmarks ex;
2292 VymModel *m=currentModel();
2300 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2302 ExportTaskjuggler ex;
2303 VymModel *m=currentModel();
2307 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2308 ex.setDir(lastImageDir);
2309 ex.addFilter ("Taskjuggler (*.tjp)");
2310 if (ex.execDialog() )
2312 m->setExportMode(true);
2314 m->setExportMode(false);
2319 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2321 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2322 // TODO add preview in dialog
2323 //ImagePreview *p =new ImagePreview (fd);
2324 //fd->setContentsPreviewEnabled( TRUE );
2325 //fd->setContentsPreview( p, p );
2326 //fd->setPreviewMode( QFileDialog::Contents );
2327 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2328 fd->setDir (QDir().current());
2329 if (fd->foundConfig())
2333 if ( fd->exec() == QDialog::Accepted )
2335 QString fn=fd->selectedFile();
2336 if (!fn.contains (".odp"))
2339 //lastImageDir=fn.left(fn.findRev ("/"));
2340 VymModel *m=currentModel();
2341 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2345 QMessageBox::warning(0,
2347 tr("Couldn't find configuration for export to Open Office\n"));
2351 void Main::fileCloseMap()
2353 VymModel *m=currentModel();
2356 if (m->hasChanged())
2358 QMessageBox mb( vymName,
2359 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2360 QMessageBox::Warning,
2361 QMessageBox::Yes | QMessageBox::Default,
2363 QMessageBox::Cancel | QMessageBox::Escape );
2364 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2365 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2368 case QMessageBox::Yes:
2370 fileSave(m, CompleteMap);
2372 case QMessageBox::No:
2373 // close without saving
2375 case QMessageBox::Cancel:
2380 // And here comes the segfault, because removeTab triggers
2381 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2382 vymViews.removeAt (tabWidget->currentIndex() );
2383 tabWidget->removeTab (tabWidget->currentIndex() );
2385 // Remove mapEditor/model FIXME-5
2386 // Better would be delete (me), but then we could have a Qt error:
2387 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2388 // So we only remove data now and call deconstructor when vym closes later
2389 // this needs to be moved to vymview... me->clear();
2390 // some model->clear is needed to free up memory ...
2396 void Main::filePrint()
2398 if (currentMapEditor())
2399 currentMapEditor()->print();
2402 void Main::fileExitVYM()
2404 // Check if one or more editors have changed
2406 for (i=0;i<=vymViews.count() -1;i++)
2408 // If something changed, ask what to do
2409 if (vymViews.at(i)->getModel()->hasChanged())
2411 tabWidget->setCurrentPage(i);
2412 QMessageBox mb( vymName,
2413 tr("This map is not saved yet. Do you want to"),
2414 QMessageBox::Warning,
2415 QMessageBox::Yes | QMessageBox::Default,
2417 QMessageBox::Cancel | QMessageBox::Escape );
2418 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2419 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2422 mb.setActiveWindow();
2423 switch( mb.exec() ) {
2424 case QMessageBox::Yes:
2425 // save (the changed editors) and exit
2426 fileSave(currentModel(), CompleteMap);
2428 case QMessageBox::No:
2429 // exit without saving
2431 case QMessageBox::Cancel:
2432 // don't save and don't exit
2436 } // loop over all MEs
2440 void Main::editUndo()
2442 VymModel *m=currentModel();
2446 void Main::editRedo()
2448 VymModel *m=currentModel();
2452 void Main::gotoHistoryStep (int i)
2454 VymModel *m=currentModel();
2455 if (m) m->gotoHistoryStep(i);
2458 void Main::editCopy()
2460 VymModel *m=currentModel();
2464 void Main::editPaste()
2466 VymModel *m=currentModel();
2470 void Main::editCut()
2472 VymModel *m=currentModel();
2476 void Main::editOpenFindWindow()
2478 findWindow->popup();
2479 findWindow->raise();
2480 findWindow->setActiveWindow();
2483 void Main::editFind(QString s)
2485 VymModel *m=currentModel();
2489 BranchItem *bi=m->findText(s, cs);
2492 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2495 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2496 tr("No matches found for \"%1\"").arg(s));
2501 void Main::editFindChanged()
2502 { // Notify editor, to abort the current find process
2503 VymModel *m=currentModel();
2504 if (m) m->findReset();
2507 void Main::openTabs(QStringList urls)
2509 if (!urls.isEmpty())
2513 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2514 if (*browserPID==0) //FIXME-2 need to check if browser is really still there instead of this
2516 QString u=urls.takeFirst();
2518 QString workDir=QDir::currentDirPath();
2519 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2521 // try to set path to browser
2522 QMessageBox::warning(0,
2524 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2525 tr("Please use Settings->")+tr("Set application to open an URL"));
2528 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2529 #if defined(Q_OS_WIN32)
2530 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2531 this->thread()->wait(3000);
2533 sleep (3); //FIXME-3 needed?
2537 if (browser.contains("konqueror"))
2539 for (int i=0; i<urls.size(); i++)
2542 // Try to open new tab in existing konqueror started previously by vym
2546 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2547 "konqueror-mainwindow#1"<<
2551 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2552 "/konqueror/MainWindow_1"<<
2556 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2557 if (!QProcess::startDetached ("qdbus",args))
2561 QMessageBox::warning(0,
2563 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2565 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2567 for (int i=0; i<urls.size(); i++)
2569 // Try to open new tab in firefox
2570 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2571 if (!QProcess::startDetached (browser,args))
2575 QMessageBox::warning(0,
2577 tr("Couldn't start %1 to open a new tab").arg(browser));
2580 QMessageBox::warning(0,
2582 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2586 void Main::editOpenURL()
2589 VymModel *m=currentModel();
2592 QString url=m->getURL();
2594 if (url=="") return;
2595 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2597 QString workDir=QDir::currentDirPath();
2598 if (!procBrowser->startDetached(browser,args))
2600 // try to set path to browser
2601 QMessageBox::warning(0,
2603 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2604 tr("Please use Settings->")+tr("Set application to open an URL"));
2609 void Main::editOpenURLTab()
2611 VymModel *m=currentModel();
2615 urls.append(m->getURL());
2619 void Main::editOpenMultipleURLTabs()
2621 VymModel *m=currentModel();
2631 void Main::editURL()
2633 VymModel *m=currentModel();
2634 if (m) m->editURL();
2637 void Main::editLocalURL()
2639 VymModel *m=currentModel();
2640 if (m) m->editLocalURL();
2643 void Main::editHeading2URL()
2645 VymModel *m=currentModel();
2646 if (m) m->editHeading2URL();
2649 void Main::editBugzilla2URL()
2651 VymModel *m=currentModel();
2652 if (m) m->editBugzilla2URL();
2655 void Main::editFATE2URL()
2657 VymModel *m=currentModel();
2658 if (m) m->editFATE2URL();
2661 void Main::editHeadingFinished(VymModel *m)
2665 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2666 !prevSelection.isEmpty())
2667 m->select(prevSelection);
2672 void Main::openVymLinks(const QStringList &vl)
2674 for (int j=0; j<vl.size(); j++)
2676 // compare path with already loaded maps
2679 for (i=0;i<=vymViews.count() -1;i++)
2681 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2690 if (!QFile(vl.at(j)).exists() )
2691 QMessageBox::critical( 0, tr( "Critical Error" ),
2692 tr("Couldn't open map %1").arg(vl.at(j)));
2695 fileLoad (vl.at(j), NewMap);
2696 tabWidget->setCurrentIndex (tabWidget->count()-1);
2699 // Go to tab containing the map
2700 tabWidget->setCurrentIndex (index);
2704 void Main::editOpenVymLink()
2706 VymModel *m=currentModel();
2710 vl.append(m->getVymLink());
2715 void Main::editOpenMultipleVymLinks()
2717 QString currentVymLink;
2718 VymModel *m=currentModel();
2721 QStringList vl=m->getVymLinks();
2726 void Main::editVymLink()
2728 VymModel *m=currentModel();
2733 void Main::editDeleteVymLink()
2735 VymModel *m=currentModel();
2736 if (m) m->deleteVymLink();
2739 void Main::editToggleHideExport()
2741 VymModel *m=currentModel();
2742 if (m) m->toggleHideExport();
2745 void Main::editAddTimestamp()
2747 VymModel *m=currentModel();
2748 if (m) m->addTimestamp();
2751 void Main::editMapInfo()
2753 VymModel *m=currentModel();
2756 ExtraInfoDialog dia;
2757 dia.setMapName (m->getFileName() );
2758 dia.setAuthor (m->getAuthor() );
2759 dia.setComment(m->getComment() );
2763 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2769 BranchItem *cur=NULL;
2770 BranchItem *prev=NULL;
2771 m->nextBranch(cur,prev);
2774 if (!cur->getNote().isEmpty() ) n++;
2775 f+= cur->imageCount();
2777 xl+=cur->xlinkCount();
2778 m->nextBranch(cur,prev);
2781 stats+=QString ("%1 xLinks \n").arg (xl,6);
2782 stats+=QString ("%1 notes\n").arg (n,6);
2783 stats+=QString ("%1 images\n").arg (f,6);
2784 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2785 dia.setStats (stats);
2787 // Finally show dialog
2788 if (dia.exec() == QDialog::Accepted)
2790 m->setAuthor (dia.getAuthor() );
2791 m->setComment (dia.getComment() );
2795 void Main::editMoveUp()
2797 VymModel *m=currentModel();
2801 void Main::editMoveDown()
2803 VymModel *m=currentModel();
2804 if (m) m->moveDown();
2807 void Main::editDetach()
2809 VymModel *m=currentModel();
2813 void Main::editSortChildren()
2815 VymModel *m=currentModel();
2816 if (m) m->sortChildren();
2819 void Main::editToggleScroll()
2821 VymModel *m=currentModel();
2822 if (m) m->toggleScroll();
2825 void Main::editExpandAll()
2827 VymModel *m=currentModel();
2828 if (m) m->emitExpandAll();
2831 void Main::editExpandOneLevel()
2833 VymModel *m=currentModel();
2834 if (m) m->emitExpandOneLevel();
2837 void Main::editCollapseOneLevel()
2839 VymModel *m=currentModel();
2840 if (m) m->emitCollapseOneLevel();
2843 void Main::editUnscrollChildren()
2845 VymModel *m=currentModel();
2846 if (m) m->unscrollChildren();
2849 void Main::editAddAttribute()
2851 VymModel *m=currentModel();
2852 if (m) m->addAttribute();
2855 void Main::editAddMapCenter()
2857 VymModel *m=currentModel();
2858 if (m) m->addMapCenter ();
2861 void Main::editNewBranch()
2863 VymModel *m=currentModel();
2866 BranchItem *bi=m->addNewBranch();
2869 if (actionSettingsAutoEditNewBranch->isOn()
2870 && !actionSettingsAutoSelectNewBranch->isOn() )
2871 prevSelection=m->getSelectString();
2873 prevSelection=QString();
2875 if (actionSettingsAutoSelectNewBranch->isOn()
2876 || actionSettingsAutoEditNewBranch->isOn())
2879 if (actionSettingsAutoEditNewBranch->isOn())
2880 currentMapEditor()->editHeading();
2885 void Main::editNewBranchBefore()
2887 VymModel *m=currentModel();
2890 BranchItem *bi=m->addNewBranchBefore();
2897 if (actionSettingsAutoEditNewBranch->isOn())
2899 if (!actionSettingsAutoSelectNewBranch->isOn())
2900 prevSelection=m->getSelectString(bi);
2901 currentMapEditor()->editHeading();
2906 void Main::editNewBranchAbove() // FIXME-1 can crash
2908 VymModel *m=currentModel();
2911 BranchItem *bi=m->addNewBranch (-1);
2919 if (actionSettingsAutoEditNewBranch->isOn())
2921 if (!actionSettingsAutoSelectNewBranch->isOn())
2922 prevSelection=m->getSelectString (bi);
2923 currentMapEditor()->editHeading();
2928 void Main::editNewBranchBelow()
2930 VymModel *m=currentModel();
2933 BranchItem *bi=m->addNewBranch (1);
2940 if (actionSettingsAutoEditNewBranch->isOn())
2942 if (!actionSettingsAutoSelectNewBranch->isOn())
2943 prevSelection=m->getSelectString(bi);
2944 currentMapEditor()->editHeading();
2949 void Main::editImportAdd()
2951 fileLoad (ImportAdd);
2954 void Main::editImportReplace()
2956 fileLoad (ImportReplace);
2959 void Main::editSaveBranch()
2961 fileSaveAs (PartOfMap);
2964 void Main::editDeleteKeepChildren()
2966 VymModel *m=currentModel();
2967 if (m) m->deleteKeepChildren();
2970 void Main::editDeleteChildren()
2972 VymModel *m=currentModel();
2973 if (m) m->deleteChildren();
2976 void Main::editDeleteSelection()
2978 VymModel *m=currentModel();
2979 if (m && actionSettingsUseDelKey->isOn())
2980 m->deleteSelection();
2983 void Main::editLoadImage()
2985 VymModel *m=currentModel();
2986 if (m) m->loadFloatImage();
2989 void Main::editSaveImage()
2991 VymModel *m=currentModel();
2992 if (m) m->saveFloatImage();
2995 void Main::editFollowXLink(QAction *a)
2998 VymModel *m=currentModel();
3000 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3003 void Main::editEditXLink(QAction *a)
3005 VymModel *m=currentModel();
3007 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3010 void Main::formatSelectColor()
3012 QColor col = QColorDialog::getColor((currentColor ), this );
3013 if ( !col.isValid() ) return;
3014 colorChanged( col );
3017 void Main::formatPickColor()
3019 VymModel *m=currentModel();
3021 colorChanged( m->getCurrentHeadingColor() );
3024 void Main::colorChanged(QColor c)
3026 QPixmap pix( 16, 16 );
3028 actionFormatColor->setIconSet( pix );
3032 void Main::formatColorBranch()
3034 VymModel *m=currentModel();
3035 if (m) m->colorBranch(currentColor);
3038 void Main::formatColorSubtree()
3040 VymModel *m=currentModel();
3041 if (m) m->colorSubtree (currentColor);
3044 void Main::formatLinkStyleLine()
3046 VymModel *m=currentModel();
3049 m->setMapLinkStyle("StyleLine");
3050 actionFormatLinkStyleLine->setChecked(true);
3054 void Main::formatLinkStyleParabel()
3056 VymModel *m=currentModel();
3059 m->setMapLinkStyle("StyleParabel");
3060 actionFormatLinkStyleParabel->setChecked(true);
3064 void Main::formatLinkStylePolyLine()
3066 VymModel *m=currentModel();
3069 m->setMapLinkStyle("StylePolyLine");
3070 actionFormatLinkStylePolyLine->setChecked(true);
3074 void Main::formatLinkStylePolyParabel()
3076 VymModel *m=currentModel();
3079 m->setMapLinkStyle("StylePolyParabel");
3080 actionFormatLinkStylePolyParabel->setChecked(true);
3084 void Main::formatSelectBackColor()
3086 VymModel *m=currentModel();
3087 if (m) m->selectMapBackgroundColor();
3090 void Main::formatSelectBackImage()
3092 VymModel *m=currentModel();
3094 m->selectMapBackgroundImage();
3097 void Main::formatSelectLinkColor()
3099 VymModel *m=currentModel();
3102 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3103 m->setMapDefLinkColor( col );
3107 void Main::formatSelectSelectionColor()
3109 VymModel *m=currentModel();
3112 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3113 m->setSelectionColor (col);
3118 void Main::formatToggleLinkColorHint()
3120 VymModel *m=currentModel();
3121 if (m) m->toggleMapLinkColorHint();
3125 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3127 VymModel *m=currentModel();
3129 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3132 void Main::viewZoomReset()
3134 MapEditor *me=currentMapEditor();
3135 if (me) me->setZoomFactorTarget (1);
3138 void Main::viewZoomIn()
3140 MapEditor *me=currentMapEditor();
3141 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3144 void Main::viewZoomOut()
3146 MapEditor *me=currentMapEditor();
3147 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3150 void Main::viewCenter()
3152 VymModel *m=currentModel();
3153 if (m) m->emitShowSelection();
3156 void Main::networkStartServer()
3158 VymModel *m=currentModel();
3159 if (m) m->newServer();
3162 void Main::networkConnect()
3164 VymModel *m=currentModel();
3165 if (m) m->connectToServer();
3168 bool Main::settingsPDF()
3170 // Default browser is set in constructor
3172 QString text = QInputDialog::getText(
3173 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3174 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3176 settings.setValue ("/mainwindow/readerPDF",text);
3181 bool Main::settingsURL()
3183 // Default browser is set in constructor
3185 QString text = QInputDialog::getText(
3186 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3187 settings.value("/mainwindow/readerURL").toString()
3190 settings.setValue ("/mainwindow/readerURL",text);
3194 void Main::settingsMacroDir()
3196 QDir defdir(vymBaseDir.path() + "/macros");
3197 if (!defdir.exists())
3199 QDir dir=QFileDialog::getExistingDirectory (
3201 tr ("Directory with vym macros:"),
3202 settings.value ("/macros/macroDir",defdir.path()).toString()
3205 settings.setValue ("/macros/macroDir",dir.absolutePath());
3208 void Main::settingsUndoLevels()
3211 int i = QInputDialog::getInteger(
3213 tr("QInputDialog::getInteger()"),
3214 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3217 settings.setValue ("/mapeditor/stepsTotal",i);
3218 QMessageBox::information( this, tr( "VYM -Information:" ),
3219 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3223 void Main::settingsAutosaveToggle()
3225 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3228 void Main::settingsAutosaveTime()
3231 int i = QInputDialog::getInteger(
3233 tr("QInputDialog::getInteger()"),
3234 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3236 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3239 void Main::settingsWriteBackupFileToggle()
3241 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3244 void Main::settingsToggleAnimation()
3246 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3249 void Main::settingsToggleDelKey()
3251 if (actionSettingsUseDelKey->isOn())
3253 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3256 actionDelete->setAccel (QKeySequence (""));
3260 void Main::windowToggleNoteEditor()
3262 if (textEditor->isVisible() )
3263 windowHideNoteEditor();
3265 windowShowNoteEditor();
3268 void Main::windowToggleHistory()
3270 if (historyWindow->isVisible())
3271 historyWindow->hide();
3273 historyWindow->show();
3277 void Main::windowToggleProperty()
3279 if (branchPropertyWindow->isVisible())
3280 branchPropertyWindow->hide();
3282 branchPropertyWindow->show();
3283 branchPropertyWindow->setModel (currentModel() );
3286 void Main::windowToggleAntiAlias()
3288 bool b=actionViewToggleAntiAlias->isOn();
3290 for (int i=0;i<vymViews.count();i++)
3292 me=vymViews.at(i)->getMapEditor();
3293 if (me) me->setAntiAlias(b);
3298 bool Main::isAliased()
3300 return actionViewToggleAntiAlias->isOn();
3303 bool Main::hasSmoothPixmapTransform()
3305 return actionViewToggleSmoothPixmapTransform->isOn();
3308 void Main::windowToggleSmoothPixmap()
3310 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3312 for (int i=0;i<vymViews.count();i++)
3315 me=vymViews.at(i)->getMapEditor();
3316 if (me) me->setSmoothPixmap(b);
3320 void Main::updateHistory(SimpleSettings &undoSet)
3322 historyWindow->update (undoSet);
3325 void Main::updateNoteFlag()
3327 // this slot is connected to TextEditor::textHasChanged()
3329 VymModel *m=currentModel();
3330 if (m) m->updateNoteFlag();
3333 void Main::updateNoteEditor(QModelIndex index )
3335 cout << QObject::sender();
3336 QObject *obj=QObject::sender();
3337 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3338 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3339 //cout << "Main::updateNoteEditor model="<<sender();
3340 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3341 textEditor->setNote (ti->getNoteObj() );
3344 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3346 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3348 if (model && model==currentModel() )
3352 if (!oldsel.indexes().isEmpty() )
3354 ti=model->getItem(oldsel.indexes().first());
3356 // Don't update note if both treeItem and textEditor are empty
3357 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3358 // ti->setNoteObj (textEditor->getNoteObj(),false );
3360 if (!newsel.indexes().isEmpty() )
3362 ti=model->getItem(newsel.indexes().first());
3363 if (!ti->hasEmptyNote() )
3364 textEditor->setNote(ti->getNoteObj() );
3366 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3368 // Show URL and link in statusbar
3370 QString s=ti->getURL();
3371 if (!s.isEmpty() ) status+="URL: "+s+" ";
3373 if (!s.isEmpty() ) status+="Link: "+s;
3374 if (!status.isEmpty() ) statusMessage (status);
3377 textEditor->setInactive();
3383 void Main::updateActions()
3385 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3386 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3387 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3388 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3390 VymModel *m =currentModel();
3394 actionFilePrint->setEnabled (true);
3396 // Link style in context menu
3397 switch (m->getMapLinkStyle())
3399 case LinkableMapObj::Line:
3400 actionFormatLinkStyleLine->setChecked(true);
3402 case LinkableMapObj::Parabel:
3403 actionFormatLinkStyleParabel->setChecked(true);
3405 case LinkableMapObj::PolyLine:
3406 actionFormatLinkStylePolyLine->setChecked(true);
3408 case LinkableMapObj::PolyParabel:
3409 actionFormatLinkStylePolyParabel->setChecked(true);
3416 QPixmap pix( 16, 16 );
3417 pix.fill( m->getMapBackgroundColor() );
3418 actionFormatBackColor->setIconSet( pix );
3419 pix.fill( m->getSelectionColor() );
3420 actionFormatSelectionColor->setIconSet( pix );
3421 pix.fill( m->getMapDefLinkColor() );
3422 actionFormatLinkColor->setIconSet( pix );
3425 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3428 // Expanding/collapsing
3429 actionExpandAll->setEnabled (true);
3430 actionExpandOneLevel->setEnabled (true);
3431 actionCollapseOneLevel->setEnabled (true);
3435 actionFilePrint->setEnabled (false);
3437 // Expanding/collapsing
3438 actionExpandAll->setEnabled (false);
3439 actionExpandOneLevel->setEnabled (false);
3440 actionCollapseOneLevel->setEnabled (false);
3443 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3444 actionFormatLinkColorHint->setChecked(true);
3446 actionFormatLinkColorHint->setChecked(false);
3449 if (m && m->hasChanged() )
3450 actionFileSave->setEnabled( true);
3452 actionFileSave->setEnabled( false);
3453 if (m && m->isUndoAvailable())
3454 actionUndo->setEnabled( true);
3456 actionUndo->setEnabled( false);
3458 if (m && m->isRedoAvailable())
3459 actionRedo->setEnabled( true);
3461 actionRedo->setEnabled( false);
3465 TreeItem *selti=m->getSelectedItem();
3466 BranchItem *selbi=m->getSelectedBranch();
3469 if (selbi || selti->getType()==TreeItem::Image)
3471 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3472 actionFormatHideLinkUnselected->setEnabled (true);
3477 // Take care of xlinks
3478 branchXLinksContextMenuEdit->clear();
3479 branchXLinksContextMenuFollow->clear();
3480 if (selbi->xlinkCount()>0)
3484 for (int i=0; i<selbi->xlinkCount();++i)
3486 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3490 if (s.length()>xLinkMenuWidth)
3491 s=s.left(xLinkMenuWidth)+"...";
3492 branchXLinksContextMenuFollow->addAction (s);
3493 branchXLinksContextMenuEdit->addAction (s);
3498 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3501 actionToggleScroll->setEnabled (true);
3502 if ( selbi->isScrolled() )
3503 actionToggleScroll->setChecked(true);
3505 actionToggleScroll->setChecked(false);
3507 if ( selti->getURL().isEmpty() )
3509 actionOpenURL->setEnabled (false);
3510 actionOpenURLTab->setEnabled (false);
3514 actionOpenURL->setEnabled (true);
3515 actionOpenURLTab->setEnabled (true);
3517 if ( selti->getVymLink().isEmpty() )
3519 actionOpenVymLink->setEnabled (false);
3520 actionDeleteVymLink->setEnabled (false);
3523 actionOpenVymLink->setEnabled (true);
3524 actionDeleteVymLink->setEnabled (true);
3527 if (selbi->canMoveUp())
3528 actionMoveUp->setEnabled (true);
3530 actionMoveUp->setEnabled (false);
3531 if (selbi->canMoveDown())
3532 actionMoveDown->setEnabled (true);
3534 actionMoveDown->setEnabled (false);
3536 actionSortChildren->setEnabled (true);
3538 actionToggleHideExport->setEnabled (true);
3539 actionToggleHideExport->setChecked (selbi->hideInExport() );
3541 actionCopy->setEnabled (true);
3542 actionCut->setEnabled (true);
3543 if (!clipboardEmpty)
3544 actionPaste->setEnabled (true);
3546 actionPaste->setEnabled (false);
3547 for (int i=0; i<actionListBranches.size(); ++i)
3548 actionListBranches.at(i)->setEnabled(true);
3549 actionDelete->setEnabled (true);
3551 if ( selti->getType()==TreeItem::Image)
3553 actionOpenURL->setEnabled (false);
3554 actionOpenVymLink->setEnabled (false);
3555 actionDeleteVymLink->setEnabled (false);
3556 actionToggleHideExport->setEnabled (true);
3557 actionToggleHideExport->setChecked (selti->hideInExport() );
3560 actionCopy->setEnabled (true);
3561 actionCut->setEnabled (true);
3562 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3563 for (int i=0; i<actionListBranches.size(); ++i)
3564 actionListBranches.at(i)->setEnabled(false);
3565 actionDelete->setEnabled (true);
3566 actionMoveUp->setEnabled (false);
3567 actionMoveDown->setEnabled (false);
3572 actionCopy->setEnabled (false);
3573 actionCut->setEnabled (false);
3574 actionPaste->setEnabled (false);
3575 for (int i=0; i<actionListBranches.size(); ++i)
3576 actionListBranches.at(i)->setEnabled(false);
3578 actionToggleScroll->setEnabled (false);
3579 actionOpenURL->setEnabled (false);
3580 actionOpenVymLink->setEnabled (false);
3581 actionDeleteVymLink->setEnabled (false);
3582 actionHeading2URL->setEnabled (false);
3583 actionDelete->setEnabled (false);
3584 actionMoveUp->setEnabled (false);
3585 actionMoveDown->setEnabled (false);
3586 actionFormatHideLinkUnselected->setEnabled (false);
3587 actionSortChildren->setEnabled (false);
3588 actionToggleHideExport->setEnabled (false);
3593 Main::ModMode Main::getModMode()
3595 if (actionModModeColor->isOn()) return ModModeColor;
3596 if (actionModModeCopy->isOn()) return ModModeCopy;
3597 if (actionModModeXLink->isOn()) return ModModeXLink;
3601 bool Main::autoEditNewBranch()
3603 return actionSettingsAutoEditNewBranch->isOn();
3606 bool Main::autoSelectNewBranch()
3608 return actionSettingsAutoSelectNewBranch->isOn();
3611 void Main::windowShowNoteEditor()
3613 textEditor->setShowWithMain(true);
3615 actionViewToggleNoteEditor->setChecked (true);
3618 void Main::windowHideNoteEditor()
3620 textEditor->setShowWithMain(false);
3622 actionViewToggleNoteEditor->setChecked (false);
3625 void Main::setScript (const QString &script)
3627 scriptEditor->setScript (script);
3630 void Main::runScript (const QString &script)
3632 VymModel *m=currentModel();
3633 if (m) m->runScript (script);
3636 void Main::runScriptEverywhere (const QString &script)
3639 for (int i=0;i<=tabWidget->count() -1;i++)
3641 me=(MapEditor*)tabWidget->page(i);
3642 if (me) me->getModel()->runScript (script);
3646 void Main::windowNextEditor()
3648 if (tabWidget->currentIndex() < tabWidget->count())
3649 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3652 void Main::windowPreviousEditor()
3654 if (tabWidget->currentIndex() >0)
3655 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3658 void Main::standardFlagChanged()
3662 if ( actionSettingsUseFlagGroups->isOn() )
3663 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3665 currentModel()->toggleStandardFlag(sender()->name());
3670 void Main::testFunction1()
3673 if (!currentMapEditor()) return;
3674 //currentMapEditor()->testFunction1();
3677 VymModel *m=currentModel();
3681 QString text = QInputDialog::getText(
3682 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3683 m->getSortFilter(), &ok, NULL);
3685 // user entered something and pressed OK
3686 m->setSortFilter (text);
3689 void Main::testFunction2()
3691 if (!currentMapEditor()) return;
3692 currentMapEditor()->testFunction2();
3695 void Main::testCommand()
3697 if (!currentMapEditor()) return;
3698 scriptEditor->show();
3701 QString com = QInputDialog::getText(
3702 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3703 if (ok) currentMapEditor()->parseAtom(com);
3707 void Main::helpDoc()
3709 QString locale = QLocale::system().name();
3711 if (locale.left(2)=="es")
3712 docname="vym_es.pdf";
3716 QStringList searchList;
3718 #if defined(Q_OS_MACX)
3719 searchList << "./vym.app/Contents/Resources/doc";
3720 #elif defined(Q_OS_WIN32)
3721 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3723 #if defined(VYM_DOCDIR)
3724 searchList << VYM_DOCDIR;
3726 // default path in SUSE LINUX
3727 searchList << "/usr/share/doc/packages/vym";
3730 searchList << "doc"; // relative path for easy testing in tarball
3731 searchList << "doc/tex"; // Easy testing working on vym.tex
3732 searchList << "/usr/share/doc/vym"; // Debian
3733 searchList << "/usr/share/doc/packages";// Knoppix
3737 for (int i=0; i<searchList.count(); ++i)
3739 docfile.setFileName(searchList.at(i)+"/"+docname);
3740 if (docfile.exists())
3749 QMessageBox::critical(0,
3750 tr("Critcal error"),
3751 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3756 Process *pdfProc = new Process();
3757 args << QDir::toNativeSeparators(docfile.fileName());
3759 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3762 QMessageBox::warning(0,
3764 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3765 tr("Please use Settings->")+tr("Set application to open PDF files"));
3772 void Main::helpDemo()
3774 QStringList filters;
3775 filters <<"VYM example map (*.vym)";
3776 QFileDialog *fd=new QFileDialog( this);
3777 #if defined(Q_OS_MACX)
3778 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3780 // default path in SUSE LINUX
3781 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3784 fd->setFileMode (QFileDialog::ExistingFiles);
3785 fd->setFilters (filters);
3786 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3790 if ( fd->exec() == QDialog::Accepted )
3792 lastFileDir=fd->directory().path();
3793 QStringList flist = fd->selectedFiles();
3794 QStringList::Iterator it = flist.begin();
3795 while( it != flist.end() )
3798 fileLoad(*it, NewMap);
3806 void Main::helpAbout()
3809 ad.setName ("aboutwindow");
3810 ad.setMinimumSize(500,500);
3811 ad.resize (QSize (500,500));
3815 void Main::helpAboutQT()
3817 QMessageBox::aboutQt( this, "Qt Application Example" );
3820 void Main::callMacro ()
3822 QAction *action = qobject_cast<QAction *>(sender());
3826 i=action->data().toInt();
3827 QString mDir (settings.value ("macros/macroDir").toString() );
3829 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3831 if ( !f.open( QIODevice::ReadOnly ) )
3833 QMessageBox::warning(0,
3835 tr("Couldn't find a macro at %1.\n").arg(fn)+
3836 tr("Please use Settings->")+tr("Set directory for vym macros"));
3840 QTextStream ts( &f );
3841 QString macro= ts.read();
3843 if (! macro.isEmpty())
3845 VymModel *m=currentModel();
3846 if (m) m->runScript(macro);