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 (A&O report)...", this);
431 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
432 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
433 fileExportMenu->addAction (a);
435 a = new QAction( "Text (ASCII)...", this);
436 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
437 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
438 fileExportMenu->addAction (a);
440 a = new QAction( "Spreadsheet (CSV)...", this);
441 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
442 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
443 fileExportMenu->addAction (a);
445 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
446 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
447 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
448 fileExportMenu->addAction (a);
450 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
451 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
452 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
453 fileExportMenu->addAction (a);
455 a = new QAction( "Taskjuggler...", this );
456 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
457 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
458 fileExportMenu->addAction (a);
460 a = new QAction( "LaTeX...", this);
461 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
462 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
463 fileExportMenu->addAction (a);
465 a = new QAction( "XML..." , this );
466 a->setStatusTip (tr( "Export as %1").arg("XML"));
467 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
468 fileExportMenu->addAction (a);
470 fileMenu->addSeparator();
472 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
473 a->setStatusTip ( tr( "Print" ,"File menu") );
474 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
476 fileMenu->addAction (a);
477 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
480 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
481 a->setStatusTip (tr( "Close Map" ) );
482 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
483 fileMenu->addAction (a);
484 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
486 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
487 a->setStatusTip ( tr( "Exit")+" "+vymName );
488 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
489 fileMenu->addAction (a);
490 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
495 void Main::setupEditActions()
497 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
498 tb->setLabel( "Edit Actions" );
499 tb->setObjectName ("actionsTB");
500 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
504 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
505 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
506 a->setStatusTip (tr( "Undo" ) );
507 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
508 a->setEnabled (false);
510 editMenu->addAction (a);
513 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
514 a->setStatusTip (tr( "Redo" ));
515 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
517 editMenu->addAction (a);
518 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
521 editMenu->addSeparator();
522 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
523 a->setStatusTip ( tr( "Copy" ) );
524 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
525 a->setEnabled (false);
527 editMenu->addAction (a);
528 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
531 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
532 a->setStatusTip ( tr( "Cut" ) );
533 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
534 a->setEnabled (false);
536 editMenu->addAction (a);
538 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
540 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
541 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
542 a->setStatusTip ( tr( "Paste" ) );
543 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
544 a->setEnabled (false);
546 editMenu->addAction (a);
549 // Shortcut to delete selection
550 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
551 a->setStatusTip (tr( "Delete Selection" ));
552 a->setShortcut ( Qt::Key_Delete); //Delete selection
553 a->setShortcutContext (Qt::WindowShortcut);
555 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
558 // Shortcut to add attribute
559 a= new QAction(tr( "Add attribute" ), this);
560 a->setShortcut ( Qt::Key_Q);
561 a->setShortcutContext (Qt::WindowShortcut);
563 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
564 actionAddAttribute= a;
567 // Shortcut to add mapcenter
568 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
569 a->setShortcut ( Qt::Key_M);
570 a->setShortcutContext (Qt::WindowShortcut);
571 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
572 //actionListBranches.append(a);
574 actionAddMapCenter = a;
577 // Shortcut to add branch
578 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
579 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
580 alt->setShortcut (Qt::Key_A); //Add branch
581 alt->setShortcutContext (Qt::WindowShortcut);
583 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
584 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
585 a->setStatusTip ( tr( "Add a branch as child of selection" ));
586 a->setShortcut (Qt::Key_Insert); //Add branch
587 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
588 actionListBranches.append(a);
589 #if defined (Q_OS_MACX)
590 // In OSX show different shortcut in menues, the keys work indepently always
595 editMenu->addAction (actionAddBranch);
596 tb->addAction (actionAddBranch);
599 // Add branch by inserting it at selection
600 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
601 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
602 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
603 a->setShortcutContext (Qt::WindowShortcut);
605 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
606 a->setEnabled (false);
607 actionListBranches.append(a);
608 actionAddBranchBefore=a;
609 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
610 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
611 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
612 a->setShortcutContext (Qt::WindowShortcut);
614 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
615 actionListBranches.append(a);
618 a = new QAction(tr( "Add branch above","Edit menu" ), this);
619 a->setStatusTip ( tr( "Add a branch above selection" ));
620 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
621 a->setShortcutContext (Qt::WindowShortcut);
623 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
624 a->setEnabled (false);
625 actionListBranches.append(a);
626 actionAddBranchAbove=a;
627 a = new QAction(tr( "Add branch above","Edit menu" ), this);
628 a->setStatusTip ( tr( "Add a branch above selection" ));
629 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
630 a->setShortcutContext (Qt::WindowShortcut);
632 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
633 actionListBranches.append(a);
636 a = new QAction(tr( "Add branch below","Edit menu" ), this);
637 a->setStatusTip ( tr( "Add a branch below selection" ));
638 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
639 a->setShortcutContext (Qt::WindowShortcut);
641 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
642 a->setEnabled (false);
643 actionListBranches.append(a);
644 actionAddBranchBelow=a;
645 a = new QAction(tr( "Add branch below","Edit menu" ), this);
646 a->setStatusTip ( tr( "Add a branch below selection" ));
647 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
648 a->setShortcutContext (Qt::WindowShortcut);
650 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
651 actionListBranches.append(a);
653 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
654 a->setStatusTip ( tr( "Move branch up" ) );
655 a->setShortcut (Qt::Key_PageUp ); // Move branch up
656 a->setEnabled (false);
658 editMenu->addAction (a);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
662 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
663 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
664 a->setStatusTip (tr( "Move branch down" ) );
665 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
666 a->setEnabled (false);
668 editMenu->addAction (a);
671 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
672 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
673 a->setShortcut ( Qt::Key_D ); // Detach branch
674 editMenu->addAction (a);
675 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
678 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
679 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
680 a->setEnabled (true);
682 editMenu->addAction (a);
683 actionSortChildren=a;
685 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
686 alt->setShortcut ( Qt::Key_S ); // Scroll branch
687 alt->setStatusTip (tr( "Scroll branch" ));
688 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
689 #if defined(Q_OS_MACX)
690 actionToggleScroll=alt;
692 actionToggleScroll=a;
694 actionToggleScroll->setEnabled (false);
695 actionToggleScroll->setToggleAction(true);
696 tb->addAction (actionToggleScroll);
697 editMenu->addAction ( actionToggleScroll);
698 editMenu->addAction (actionToggleScroll);
701 actionListBranches.append(actionToggleScroll);
703 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
704 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
705 a->setStatusTip (tr( "Expand all branches" ));
706 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
708 actionExpandAll->setEnabled (false);
709 actionExpandAll->setToggleAction(false);
710 //tb->addAction (actionExpandAll);
711 editMenu->addAction ( actionExpandAll);
713 actionListBranches.append(actionExpandAll);
715 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
716 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
717 a->setStatusTip (tr( "Expand one level in tree editor" ));
718 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
719 a->setEnabled (false);
720 a->setToggleAction(false);
721 actionExpandOneLevel=a;
723 editMenu->addAction ( a);
725 actionListBranches.append(a);
727 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
728 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
729 a->setStatusTip (tr( "Collapse one level in tree editor" ));
730 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
731 a->setEnabled (false);
732 a->setToggleAction(false);
733 actionCollapseOneLevel=a;
735 editMenu->addAction ( a);
737 actionListBranches.append(a);
739 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
740 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
741 editMenu->addAction (a);
742 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
744 editMenu->addSeparator();
746 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
747 a->setStatusTip (tr( "Find" ) );
748 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
749 editMenu->addAction (a);
750 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
752 editMenu->addSeparator();
754 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
755 a->setShortcut (Qt::SHIFT + Qt::Key_U );
756 a->setShortcut (tr( "Open URL" ));
759 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
762 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
763 a->setStatusTip (tr( "Open URL in new tab" ));
764 //a->setShortcut (Qt::CTRL+Qt::Key_U );
766 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
769 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
770 a->setStatusTip (tr( "Open all URLs in subtree" ));
771 a->setShortcut ( Qt::CTRL + Qt::Key_U );
773 actionListBranches.append(a);
774 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
775 actionOpenMultipleURLTabs=a;
777 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
778 a->setStatusTip ( tr( "Edit URL" ) );
779 a->setShortcut ( Qt::Key_U );
780 a->setShortcutContext (Qt::WindowShortcut);
781 actionListBranches.append(a);
783 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
786 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
787 a->setStatusTip ( tr( "Edit local URL" ) );
788 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
789 a->setShortcutContext (Qt::WindowShortcut);
790 actionListBranches.append(a);
792 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
795 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
796 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
797 a->setEnabled (false);
798 actionListBranches.append(a);
799 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
802 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
803 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
804 a->setEnabled (false);
805 actionListBranches.append(a);
806 a->setShortcut ( Qt::Key_B );
807 a->setShortcutContext (Qt::WindowShortcut);
809 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
810 actionBugzilla2URL=a;
812 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
813 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
814 a->setEnabled (false);
815 actionListBranches.append(a);
816 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
819 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
820 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
822 a->setEnabled (false);
823 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
826 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
827 a->setStatusTip ( tr( "Open all vym links in subtree" ));
828 a->setEnabled (false);
829 actionListBranches.append(a);
830 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
831 actionOpenMultipleVymLinks=a;
834 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
835 a->setEnabled (false);
836 a->setStatusTip ( tr( "Edit link to another vym map" ));
837 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
838 actionListBranches.append(a);
841 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
842 a->setStatusTip ( tr( "Delete link to another vym map" ));
843 a->setEnabled (false);
844 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
845 actionDeleteVymLink=a;
847 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
848 a->setStatusTip ( tr( "Hide object in exports" ) );
849 a->setShortcut (Qt::Key_H );
850 a->setToggleAction(true);
852 a->setEnabled (false);
853 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
854 actionToggleHideExport=a;
856 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
857 a->setStatusTip ( tr( "Add timestamp" ));
858 a->setEnabled (false);
859 actionListBranches.append(a);
860 a->setShortcut ( Qt::Key_T ); // Add timestamp
861 a->setShortcutContext (Qt::WindowShortcut);
863 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
864 actionAddTimestamp=a;
866 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
867 a->setStatusTip ( tr( "Edit Map Info" ));
868 a->setEnabled (true);
869 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
872 // Import at selection (adding to selection)
873 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
874 a->setStatusTip (tr( "Add map at selection" ));
875 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
876 a->setEnabled (false);
877 actionListBranches.append(a);
880 // Import at selection (replacing selection)
881 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
882 a->setStatusTip (tr( "Replace selection with map" ));
883 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
884 a->setEnabled (false);
885 actionListBranches.append(a);
886 actionImportReplace=a;
889 a = new QAction( tr( "Save selection","Edit menu" ), this);
890 a->setStatusTip (tr( "Save selection" ));
891 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
892 a->setEnabled (false);
893 actionListBranches.append(a);
896 // Only remove branch, not its children
897 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
898 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
899 a->setShortcut (Qt::ALT + Qt::Key_Delete );
900 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
901 a->setEnabled (false);
903 actionListBranches.append(a);
904 actionDeleteKeepChildren=a;
906 // Only remove children of a branch
907 a = new QAction( tr( "Remove children","Edit menu" ), this);
908 a->setStatusTip (tr( "Remove children of branch" ));
909 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
910 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
911 a->setEnabled (false);
912 actionListBranches.append(a);
913 actionDeleteChildren=a;
915 a = new QAction( tr( "Add Image...","Edit menu" ), this);
916 a->setStatusTip (tr( "Add Image" ));
917 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
920 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
921 a->setStatusTip (tr( "Set properties for selection" ));
922 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
923 a->setShortcutContext (Qt::WindowShortcut);
924 a->setToggleAction (true);
926 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
927 actionViewTogglePropertyWindow=a;
931 void Main::setupFormatActions()
933 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
935 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
936 tb->setObjectName ("formatTB");
939 pix.fill (Qt::black);
940 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
941 a->setStatusTip ( tr( "Set Color" ));
942 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
944 formatMenu->addAction (a);
946 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
947 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
948 a->setShortcut (Qt::CTRL + Qt::Key_K );
949 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
950 a->setEnabled (false);
952 formatMenu->addAction (a);
953 actionListBranches.append(a);
954 actionFormatPickColor=a;
956 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
957 a->setStatusTip ( tr( "Color branch" ) );
958 a->setShortcut (Qt::CTRL + Qt::Key_B);
959 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
960 a->setEnabled (false);
962 formatMenu->addAction (a);
963 actionListBranches.append(a);
964 actionFormatColorSubtree=a;
966 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
967 a->setStatusTip ( tr( "Color Subtree" ));
968 //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree
969 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
970 a->setEnabled (false);
971 formatMenu->addAction (a);
973 actionListBranches.append(a);
974 actionFormatColorSubtree=a;
976 formatMenu->addSeparator();
977 actionGroupFormatLinkStyles=new QActionGroup ( this);
978 actionGroupFormatLinkStyles->setExclusive (true);
979 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
980 a->setStatusTip (tr( "Line" ));
981 a->setToggleAction(true);
982 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
983 formatMenu->addAction (a);
984 actionFormatLinkStyleLine=a;
985 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
986 a->setStatusTip (tr( "Line" ));
987 a->setToggleAction(true);
988 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
989 formatMenu->addAction (a);
990 actionFormatLinkStyleParabel=a;
991 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
992 a->setStatusTip (tr( "PolyLine" ));
993 a->setToggleAction(true);
994 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
995 formatMenu->addAction (a);
996 actionFormatLinkStylePolyLine=a;
997 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
998 a->setStatusTip (tr( "PolyParabel" ) );
999 a->setToggleAction(true);
1000 a->setChecked (true);
1001 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1002 formatMenu->addAction (a);
1003 actionFormatLinkStylePolyParabel=a;
1005 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1006 a->setStatusTip (tr( "Hide link" ));
1007 a->setToggleAction(true);
1008 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1009 actionFormatHideLinkUnselected=a;
1011 formatMenu->addSeparator();
1012 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1013 a->setStatusTip (tr( "Use same color for links and headings" ));
1014 a->setToggleAction(true);
1015 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1016 formatMenu->addAction (a);
1017 actionFormatLinkColorHint=a;
1019 pix.fill (Qt::white);
1020 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1021 a->setStatusTip (tr( "Set Link Color" ));
1022 formatMenu->addAction (a);
1023 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1024 actionFormatLinkColor=a;
1026 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1027 a->setStatusTip (tr( "Set Selection Color" ));
1028 formatMenu->addAction (a);
1029 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1030 actionFormatSelectionColor=a;
1032 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1033 a->setStatusTip (tr( "Set Background Color" ));
1034 formatMenu->addAction (a);
1035 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1036 actionFormatBackColor=a;
1038 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1039 a->setStatusTip (tr( "Set Background image" ));
1040 formatMenu->addAction (a);
1041 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1042 actionFormatBackImage=a;
1046 void Main::setupViewActions()
1048 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1049 tb->setLabel( "View Actions" );
1050 tb->setObjectName ("viewTB");
1051 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1053 Switchboard switchboard; //FIXME-1 testing...
1056 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1057 a->setStatusTip ( tr( "Zoom reset" ) );
1058 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1059 switchboard.addConnection(a,"CTRL+0");
1061 viewMenu->addAction (a);
1062 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1064 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1065 a->setStatusTip (tr( "Zoom in" ));
1066 switchboard.addConnection(a,"CTRL++");
1068 viewMenu->addAction (a);
1069 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1071 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1072 a->setStatusTip (tr( "Zoom out" ));
1073 switchboard.addConnection(a,"CTRL+-");
1075 viewMenu->addAction (a);
1076 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1078 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1079 a->setStatusTip (tr( "Show selection" ));
1080 switchboard.addConnection(a,".");
1082 viewMenu->addAction (a);
1083 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1085 viewMenu->addSeparator();
1087 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1088 a->setStatusTip ( tr( "Show Note Editor" ));
1089 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1090 a->setToggleAction(true);
1092 viewMenu->addAction (a);
1093 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1094 actionViewToggleNoteEditor=a;
1096 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1097 a->setStatusTip ( tr( "Show History Window" ));
1098 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1099 a->setToggleAction(true);
1101 viewMenu->addAction (a);
1102 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1103 actionViewToggleHistoryWindow=a;
1105 viewMenu->addAction (actionViewTogglePropertyWindow);
1107 viewMenu->addSeparator();
1109 a = new QAction(tr( "Antialiasing","View action" ),this );
1110 a->setStatusTip ( tr( "Antialiasing" ));
1111 a->setToggleAction(true);
1112 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1113 viewMenu->addAction (a);
1114 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1115 actionViewToggleAntiAlias=a;
1117 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1118 a->setStatusTip (a->text());
1119 a->setToggleAction(true);
1120 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1121 viewMenu->addAction (a);
1122 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1123 actionViewToggleSmoothPixmapTransform=a;
1125 a = new QAction(tr( "Next Map","View action" ), this);
1126 a->setStatusTip (a->text());
1127 a->setShortcut (Qt::ALT + Qt::Key_N );
1128 viewMenu->addAction (a);
1129 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1131 a = new QAction (tr( "Previous Map","View action" ), this );
1132 a->setStatusTip (a->text());
1133 a->setShortcut (Qt::ALT + Qt::Key_P );
1134 viewMenu->addAction (a);
1135 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1137 switchboard.print();
1141 void Main::setupModeActions()
1143 //QPopupMenu *menu = new QPopupMenu( this );
1144 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1146 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1147 tb->setObjectName ("modesTB");
1149 actionGroupModModes=new QActionGroup ( this);
1150 actionGroupModModes->setExclusive (true);
1151 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1152 a->setShortcut (Qt::Key_J);
1153 a->setStatusTip ( tr( "Use modifier to color branches" ));
1154 a->setToggleAction(true);
1156 a->setChecked(true);
1157 actionModModeColor=a;
1159 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1160 a->setShortcut( Qt::Key_K);
1161 a->setStatusTip( tr( "Use modifier to copy" ));
1162 a->setToggleAction(true);
1164 actionModModeCopy=a;
1166 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1167 a->setShortcut (Qt::Key_L);
1168 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1169 a->setToggleAction(true);
1171 actionModModeXLink=a;
1175 void Main::setupFlagActions()
1177 // Create System Flags
1180 Flag *flag=new Flag;;
1181 flag->setVisible(true);
1183 flag->load(QPixmap(flagsPath+"flag-note.png"));
1184 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1186 flag->load(QPixmap(flagsPath+"flag-url.png"));
1187 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1189 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1190 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1192 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1193 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1195 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1196 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1198 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1199 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1201 // Create Standard Flags
1202 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1203 tb->setObjectName ("standardFlagTB");
1204 standardFlagsMaster->setToolBar (tb);
1206 flag->load(flagsPath+"flag-exclamationmark.png");
1207 flag->setGroup("standard-mark");
1208 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1210 flag->load(flagsPath+"flag-questionmark.png");
1211 flag->setGroup("standard-mark");
1212 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1214 flag->load(flagsPath+"flag-hook-green.png");
1215 flag->setGroup("standard-hook");
1216 setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag"));
1218 flag->load(flagsPath+"flag-cross-red.png");
1219 flag->setGroup("standard-hook");
1220 setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag"));
1223 flag->load(flagsPath+"flag-stopsign.png");
1224 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1226 flag->load(flagsPath+"flag-smiley-good.png");
1227 flag->setGroup("standard-smiley");
1228 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1230 flag->load(flagsPath+"flag-smiley-sad.png");
1231 flag->setGroup("standard-smiley");
1232 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1234 flag->load(flagsPath+"flag-smiley-omg.png");
1235 flag->setGroup("standard-smiley");
1236 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1237 // Original omg.png (in KDE emoticons)
1240 flag->load(flagsPath+"flag-kalarm.png");
1241 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1243 flag->load(flagsPath+"flag-phone.png");
1244 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1246 flag->load(flagsPath+"flag-lamp.png");
1247 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1249 flag->load(flagsPath+"flag-arrow-up.png");
1250 flag->setGroup("standard-arrow");
1251 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1253 flag->load(flagsPath+"flag-arrow-down.png");
1254 flag->setGroup("standard-arrow");
1255 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1257 flag->load(flagsPath+"flag-arrow-2up.png");
1258 flag->setGroup("standard-arrow");
1259 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1261 flag->load(flagsPath+"flag-arrow-2down.png");
1262 flag->setGroup("standard-arrow");
1263 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1266 flag->load(flagsPath+"flag-thumb-up.png");
1267 flag->setGroup("standard-thumb");
1268 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1270 flag->load(flagsPath+"flag-thumb-down.png");
1271 flag->setGroup("standard-thumb");
1272 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1275 flag->load(flagsPath+"flag-rose.png");
1276 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1278 flag->load(flagsPath+"flag-heart.png");
1279 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1281 flag->load(flagsPath+"flag-present.png");
1282 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1284 flag->load(flagsPath+"flag-flash.png");
1285 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1287 // Original: xsldbg_output.png
1288 flag->load(flagsPath+"flag-info.png");
1289 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1291 // Original khelpcenter.png
1292 flag->load(flagsPath+"flag-lifebelt.png");
1293 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1296 flag->setVisible(false);
1297 flag->load(flagsPath+"freemind/warning.png");
1298 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1300 for (int i=1; i<8; i++)
1302 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1303 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1306 flag->load(flagsPath+"freemind/back.png");
1307 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1309 flag->load(flagsPath+"freemind/forward.png");
1310 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1312 flag->load(flagsPath+"freemind/attach.png");
1313 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1315 flag->load(flagsPath+"freemind/clanbomber.png");
1316 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1318 flag->load(flagsPath+"freemind/desktopnew.png");
1319 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1321 flag->load(flagsPath+"freemind/flag.png");
1322 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1325 flag->load(flagsPath+"freemind/gohome.png");
1326 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1329 flag->load(flagsPath+"freemind/kaddressbook.png");
1330 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1332 flag->load(flagsPath+"freemind/knotify.png");
1333 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1335 flag->load(flagsPath+"freemind/korn.png");
1336 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1338 flag->load(flagsPath+"freemind/mail.png");
1339 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1341 flag->load(flagsPath+"freemind/password.png");
1342 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1344 flag->load(flagsPath+"freemind/pencil.png");
1345 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1347 flag->load(flagsPath+"freemind/stop.png");
1348 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1350 flag->load(flagsPath+"freemind/wizard.png");
1351 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1353 flag->load(flagsPath+"freemind/xmag.png");
1354 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1356 flag->load(flagsPath+"freemind/bell.png");
1357 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1359 flag->load(flagsPath+"freemind/bookmark.png");
1360 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1362 flag->load(flagsPath+"freemind/penguin.png");
1363 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1365 flag->load(flagsPath+"freemind/licq.png");
1366 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1369 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1371 flag->setName(name);
1372 flag->setToolTip (tooltip);
1376 a=new QAction (flag->getPixmap(),name,this);
1379 flag->setAction (a);
1380 a->setVisible (flag->isVisible());
1381 a->setCheckable(true);
1382 a->setObjectName(name);
1383 a->setToolTip(tooltip);
1384 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1385 standardFlagsMaster->addFlag (flag);
1389 systemFlagsMaster->addFlag (flag);
1394 void Main::setupNetworkActions()
1396 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1398 QMenu *netMenu = menuBar()->addMenu( "Network" );
1402 a = new QAction( "Start TCPserver for MapEditor",this);
1403 //a->setStatusTip ( "Set application to open pdf files"));
1404 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1405 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1406 netMenu->addAction (a);
1408 a = new QAction( "Connect MapEditor to server",this);
1409 //a->setStatusTip ( "Set application to open pdf files"));
1410 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1411 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1412 netMenu->addAction (a);
1416 void Main::setupSettingsActions()
1418 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1422 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1423 a->setStatusTip ( tr( "Set application to open pdf files"));
1424 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1425 settingsMenu->addAction (a);
1427 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1428 a->setStatusTip( tr( "Set application to open external links"));
1429 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1430 settingsMenu->addAction (a);
1432 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1433 a->setStatusTip( tr( "Set path for macros"));
1434 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1435 settingsMenu->addAction (a);
1437 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1438 a->setStatusTip( tr( "Set number of undo levels"));
1439 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1440 settingsMenu->addAction (a);
1442 settingsMenu->addSeparator();
1444 a = new QAction( tr( "Autosave","Settings action"), this);
1445 a->setStatusTip( tr( "Autosave"));
1446 a->setToggleAction(true);
1447 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1448 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1449 settingsMenu->addAction (a);
1450 actionSettingsAutosaveToggle=a;
1452 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1453 a->setStatusTip( tr( "Autosave time"));
1454 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1455 settingsMenu->addAction (a);
1456 actionSettingsAutosaveTime=a;
1458 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1459 a->setStatusTip( tr( "Write backup file on save"));
1460 a->setToggleAction(true);
1461 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1462 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1463 settingsMenu->addAction (a);
1464 actionSettingsWriteBackupFile=a;
1466 settingsMenu->addSeparator();
1468 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1469 a->setStatusTip( tr( "Edit branch after adding it" ));
1470 a->setToggleAction(true);
1471 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1472 settingsMenu->addAction (a);
1473 actionSettingsAutoEditNewBranch=a;
1475 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1476 a->setStatusTip( tr( "Select branch after adding it" ));
1477 a->setToggleAction(true);
1478 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1479 settingsMenu->addAction (a);
1480 actionSettingsAutoSelectNewBranch=a;
1482 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1483 a->setStatusTip( tr( "Select heading before editing" ));
1484 a->setToggleAction(true);
1485 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1486 settingsMenu->addAction (a);
1487 actionSettingsAutoSelectText=a;
1489 a= new QAction( tr( "Delete key","Settings action" ), this);
1490 a->setStatusTip( tr( "Delete key for deleting branches" ));
1491 a->setToggleAction(true);
1492 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1493 settingsMenu->addAction (a);
1494 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1495 actionSettingsUseDelKey=a;
1497 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1498 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1499 a->setToggleAction(true);
1500 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1501 settingsMenu->addAction (a);
1502 actionSettingsUseFlagGroups=a;
1504 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1505 a->setStatusTip( tr( "Use hide flag during exports " ));
1506 a->setToggleAction(true);
1507 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1508 settingsMenu->addAction (a);
1509 actionSettingsUseHideExport=a;
1511 a = new QAction( tr( "Animation","Settings action"), this);
1512 a->setStatusTip( tr( "Animation"));
1513 a->setToggleAction(true);
1514 a->setChecked (settings.value("/animation/use",true).toBool() );
1515 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1516 settingsMenu->addAction (a);
1517 actionSettingsUseAnimation=a;
1521 void Main::setupTestActions()
1523 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1526 a = new QAction( "Test function 1" , this);
1527 a->setStatusTip( "Call test function 1" );
1528 a->setShortcut (Qt::CTRL + Qt::Key_T); // Test function 1 //FIXME-2 originally: color subtree
1529 testMenu->addAction (a);
1530 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1532 a = new QAction( "Test function 2" , this);
1533 a->setStatusTip( "Call test function 2" );
1534 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 2
1535 testMenu->addAction (a);
1536 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1538 a = new QAction( "Command" , this);
1539 a->setStatusTip( "Enter command to call in editor" );
1540 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1541 testMenu->addAction (a);
1545 void Main::setupHelpActions()
1547 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1550 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1551 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1552 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1553 helpMenu->addAction (a);
1555 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1556 a->setStatusTip( tr( "Open VYM example maps " ));
1557 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1558 helpMenu->addAction (a);
1560 a = new QAction( tr( "About VYM","Help action" ), this);
1561 a->setStatusTip( tr( "About VYM")+vymName);
1562 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1563 helpMenu->addAction (a);
1565 a = new QAction( tr( "About QT","Help action" ), this);
1566 a->setStatusTip( tr( "Information about QT toolkit" ));
1567 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1568 helpMenu->addAction (a);
1572 void Main::setupContextMenus()
1576 // Context Menu for branch or mapcenter
1577 branchContextMenu =new QMenu (this);
1578 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1579 branchContextMenu->addSeparator();
1582 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1583 branchAddContextMenu->addAction (actionPaste );
1584 branchAddContextMenu->addAction ( actionAddMapCenter );
1585 branchAddContextMenu->addAction ( actionAddBranch );
1586 branchAddContextMenu->addAction ( actionAddBranchBefore );
1587 branchAddContextMenu->addAction ( actionAddBranchAbove);
1588 branchAddContextMenu->addAction ( actionAddBranchBelow );
1589 branchAddContextMenu->addSeparator();
1590 branchAddContextMenu->addAction ( actionImportAdd );
1591 branchAddContextMenu->addAction ( actionImportReplace );
1594 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1595 branchRemoveContextMenu->addAction (actionCut);
1596 branchRemoveContextMenu->addAction ( actionDelete );
1597 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1598 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1601 actionSaveBranch->addTo( branchContextMenu );
1602 actionFileNewCopy->addTo (branchContextMenu );
1603 actionDetach->addTo (branchContextMenu );
1605 branchContextMenu->addSeparator();
1606 branchContextMenu->addAction ( actionLoadImage);
1608 // Submenu for Links (URLs, vymLinks)
1609 branchLinksContextMenu =new QMenu (this);
1611 branchContextMenu->addSeparator();
1612 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1613 branchLinksContextMenu->addAction ( actionOpenURL );
1614 branchLinksContextMenu->addAction ( actionOpenURLTab );
1615 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1616 branchLinksContextMenu->addAction ( actionURL );
1617 branchLinksContextMenu->addAction ( actionLocalURL );
1618 branchLinksContextMenu->addAction ( actionHeading2URL );
1619 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1620 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1622 branchLinksContextMenu->addAction ( actionFATE2URL );
1624 branchLinksContextMenu->addSeparator();
1625 branchLinksContextMenu->addAction ( actionOpenVymLink );
1626 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1627 branchLinksContextMenu->addAction ( actionVymLink );
1628 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1631 // Context Menu for XLinks in a branch menu
1632 // This will be populated "on demand" in MapEditor::updateActions
1633 branchContextMenu->addSeparator();
1634 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1635 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1636 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1637 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1640 // Context menu for floatimage
1641 floatimageContextMenu =new QMenu (this);
1642 a= new QAction (tr ("Save image","Context action"),this);
1643 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1644 floatimageContextMenu->addAction (a);
1646 floatimageContextMenu->addSeparator();
1647 actionCopy->addTo( floatimageContextMenu );
1648 actionCut->addTo( floatimageContextMenu );
1650 floatimageContextMenu->addSeparator();
1651 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1654 // Context menu for canvas
1655 canvasContextMenu =new QMenu (this);
1656 actionAddMapCenter->addTo( canvasContextMenu );
1657 actionMapInfo->addTo( canvasContextMenu );
1658 canvasContextMenu->insertSeparator();
1659 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1660 canvasContextMenu->insertSeparator();
1661 actionFormatLinkColorHint->addTo( canvasContextMenu );
1662 actionFormatLinkColor->addTo( canvasContextMenu );
1663 actionFormatSelectionColor->addTo( canvasContextMenu );
1664 actionFormatBackColor->addTo( canvasContextMenu );
1665 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1667 // Menu for last opened files
1669 for (int i = 0; i < MaxRecentFiles; ++i)
1671 recentFileActions[i] = new QAction(this);
1672 recentFileActions[i]->setVisible(false);
1673 fileLastMapsMenu->addAction(recentFileActions[i]);
1674 connect(recentFileActions[i], SIGNAL(triggered()),
1675 this, SLOT(fileLoadRecent()));
1677 setupRecentMapsMenu();
1680 void Main::setupRecentMapsMenu()
1682 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1684 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1686 for (int i = 0; i < numRecentFiles; ++i) {
1687 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1688 recentFileActions[i]->setText(text);
1689 recentFileActions[i]->setData(files[i]);
1690 recentFileActions[i]->setVisible(true);
1692 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1693 recentFileActions[j]->setVisible(false);
1696 void Main::setupMacros()
1698 for (int i = 0; i <= 11; i++)
1700 macroActions[i] = new QAction(this);
1701 macroActions[i]->setData(i);
1702 addAction (macroActions[i]);
1703 connect(macroActions[i], SIGNAL(triggered()),
1704 this, SLOT(callMacro()));
1706 macroActions[0]->setShortcut ( Qt::Key_F1 );
1707 macroActions[1]->setShortcut ( Qt::Key_F2 );
1708 macroActions[2]->setShortcut ( Qt::Key_F3 );
1709 macroActions[3]->setShortcut ( Qt::Key_F4 );
1710 macroActions[4]->setShortcut ( Qt::Key_F5 );
1711 macroActions[5]->setShortcut ( Qt::Key_F6 );
1712 macroActions[6]->setShortcut ( Qt::Key_F7 );
1713 macroActions[7]->setShortcut ( Qt::Key_F8 );
1714 macroActions[8]->setShortcut ( Qt::Key_F9 );
1715 macroActions[9]->setShortcut ( Qt::Key_F10 );
1716 macroActions[10]->setShortcut ( Qt::Key_F11 );
1717 macroActions[11]->setShortcut ( Qt::Key_F12 );
1720 void Main::hideEvent (QHideEvent * )
1722 if (!textEditor->isMinimized() ) textEditor->hide();
1725 void Main::showEvent (QShowEvent * )
1727 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1731 MapEditor* Main::currentMapEditor() const
1733 if ( tabWidget->currentPage())
1734 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1738 VymModel* Main::currentModel() const
1740 if ( tabWidget->currentPage())
1741 return vymViews.at(tabWidget->currentIndex())->getModel();
1746 void Main::editorChanged(QWidget *)
1748 // Unselect all possibly selected objects
1749 // (Important to update note editor)
1751 for (int i=0;i<=tabWidget->count() -1;i++)
1753 m= vymViews.at(i)->getModel();
1754 if (m) m->unselect();
1757 if (m) m->reselect();
1759 // Update actions to in menus and toolbars according to editor
1763 void Main::fileNew()
1765 VymModel *vm=new VymModel;
1767 /////////////////////////////////////
1768 new ModelTest(vm, this); //FIXME-3
1769 /////////////////////////////////////
1772 VymView *vv=new VymView (vm);
1773 vymViews.append (vv);
1774 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1775 tabWidget->setCurrentIndex (vymViews.count() );
1778 // Create MapCenter for empty map
1782 // For the very first map we do not have flagrows yet...
1786 void Main::fileNewCopy()
1788 QString fn="unnamed";
1789 VymModel *srcModel=currentModel();
1794 VymModel *dstModel=vymViews.last()->getModel();
1795 dstModel->select("mc:");
1796 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1800 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1802 ErrorCode err=success;
1804 // fn is usually the archive, mapfile the file after uncompressing
1807 // Make fn absolute (needed for unzip)
1808 fn=QDir (fn).absPath();
1814 // Check, if map is already loaded
1816 while (i<=tabWidget->count() -1)
1818 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1820 // Already there, ask for confirmation
1821 QMessageBox mb( vymName,
1822 tr("The map %1\nis already opened."
1823 "Opening the same map in multiple editors may lead \n"
1824 "to confusion when finishing working with vym."
1825 "Do you want to").arg(fn),
1826 QMessageBox::Warning,
1827 QMessageBox::Yes | QMessageBox::Default,
1828 QMessageBox::Cancel | QMessageBox::Escape,
1829 QMessageBox::NoButton);
1830 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1831 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1834 case QMessageBox::Yes:
1835 // end loop and load anyway
1836 i=tabWidget->count();
1838 case QMessageBox::Cancel:
1848 int tabIndex=tabWidget->currentPageIndex();
1851 if ( !fn.isEmpty() )
1853 vm = currentModel();
1854 // Check first, if mapeditor exists
1855 // If it is not default AND we want a new map,
1856 // create a new mapeditor in a new tab
1857 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1860 VymView *vv=new VymView (vm);
1861 vymViews.append (vv);
1862 tabWidget->addTab (vv,fn);
1863 tabIndex=tabWidget->count()-1;
1864 tabWidget->setCurrentPage (tabIndex);
1868 // Check, if file exists (important for creating new files
1869 // from command line
1870 if (!QFile(fn).exists() )
1872 QMessageBox mb( vymName,
1873 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1874 QMessageBox::Question,
1876 QMessageBox::Cancel | QMessageBox::Default,
1877 QMessageBox::NoButton );
1879 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1880 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1883 case QMessageBox::Yes:
1885 currentMapEditor()->getModel()->setFilePath(fn);
1886 tabWidget->setTabText (tabIndex,
1887 currentMapEditor()->getModel()->getFileName() );
1888 statusBar()->message( "Created " + fn , statusbarTime );
1891 case QMessageBox::Cancel:
1892 // don't create new map
1893 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1900 //tabWidget->currentPage() won't be NULL here, because of above...
1901 tabWidget->setCurrentIndex (tabIndex);
1902 //FIXME-3 no me anymore... me->viewport()->setFocus();
1906 // Save existing filename in case we import
1907 QString fn_org=vm->getFilePath();
1909 // Finally load map into mapEditor
1910 vm->setFilePath (fn);
1911 err=vm->load(fn,lmode,ftype);
1913 // Restore old (maybe empty) filepath, if this is an import
1915 vm->setFilePath (fn_org);
1918 // Finally check for errors and go home
1921 if (lmode==NewMap) fileCloseMap();
1922 statusBar()->message( "Could not load " + fn, statusbarTime );
1927 vm->setFilePath (fn);
1928 tabWidget->setTabText (tabIndex, vm->getFileName());
1929 if (!isInTmpDir (fn))
1931 // Only append to lastMaps if not loaded from a tmpDir
1932 // e.g. imported bookmarks are in a tmpDir
1933 addRecentMap(vm->getFilePath() );
1935 actionFilePrint->setEnabled (true);
1937 statusBar()->message( "Loaded " + fn, statusbarTime );
1944 void Main::fileLoad(const LoadMode &lmode)
1946 QStringList filters;
1947 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1948 QFileDialog *fd=new QFileDialog( this);
1949 fd->setDir (lastFileDir);
1950 fd->setFileMode (QFileDialog::ExistingFiles);
1951 fd->setFilters (filters);
1955 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1958 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1961 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1967 if ( fd->exec() == QDialog::Accepted )
1969 lastFileDir=fd->directory().path();
1970 QStringList flist = fd->selectedFiles();
1971 QStringList::Iterator it = flist.begin();
1972 while( it != flist.end() )
1975 fileLoad(*it, lmode);
1982 void Main::fileLoad()
1987 void Main::fileLoadRecent()
1989 QAction *action = qobject_cast<QAction *>(sender());
1991 fileLoad (action->data().toString(), NewMap);
1994 void Main::addRecentMap (const QString &fileName)
1997 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1998 files.removeAll(fileName);
1999 files.prepend(fileName);
2000 while (files.size() > MaxRecentFiles)
2003 settings.setValue("/mainwindow/recentFileList", files);
2005 setupRecentMapsMenu();
2008 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2012 if ( m->getFilePath().isEmpty() )
2014 // We have no filepath yet,
2015 // call fileSaveAs() now, this will call fileSave()
2017 // First switch to editor
2018 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2019 fileSaveAs(savemode);
2022 if (m->save (savemode)==success)
2024 statusBar()->message(
2025 tr("Saved %1").arg(m->getFilePath()),
2027 addRecentMap (m->getFilePath() );
2029 statusBar()->message(
2030 tr("Couldn't save ").arg(m->getFilePath()),
2034 void Main::fileSave()
2036 fileSave (currentModel(), CompleteMap);
2039 void Main::fileSave(VymModel *m)
2041 fileSave (m,CompleteMap);
2044 void Main::fileSaveAs(const SaveMode& savemode)
2048 if (currentMapEditor())
2050 if (savemode==CompleteMap)
2051 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2053 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2054 if ( !fn.isEmpty() )
2056 // Check for existing file
2057 if (QFile (fn).exists())
2059 QMessageBox mb( vymName,
2060 tr("The file %1\nexists already. Do you want to").arg(fn),
2061 QMessageBox::Warning,
2062 QMessageBox::Yes | QMessageBox::Default,
2063 QMessageBox::Cancel | QMessageBox::Escape,
2064 QMessageBox::NoButton);
2065 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2066 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2069 case QMessageBox::Yes:
2072 case QMessageBox::Cancel:
2079 // New file, add extension to filename, if missing
2080 // This is always .vym or .vyp, depending on savemode
2081 if (savemode==CompleteMap)
2083 if (!fn.contains (".vym") && !fn.contains (".xml"))
2087 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2096 VymModel *m=currentModel();
2098 fileSave(m, savemode);
2100 // Set name of tab, assuming current tab is the one we just saved
2101 if (savemode==CompleteMap)
2102 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2108 void Main::fileSaveAs()
2110 fileSaveAs (CompleteMap);
2113 void Main::fileImportKDE3Bookmarks()
2115 ImportKDE3Bookmarks im;
2117 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2118 currentMapEditor()->getModel()->setFilePath ("");
2121 void Main::fileImportKDE4Bookmarks()
2123 ImportKDE4Bookmarks im;
2125 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2126 currentMapEditor()->getModel()->setFilePath ("");
2129 void Main::fileImportFirefoxBookmarks()
2131 Q3FileDialog *fd=new Q3FileDialog( this);
2132 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2133 fd->setMode (Q3FileDialog::ExistingFiles);
2134 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2135 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2138 if ( fd->exec() == QDialog::Accepted )
2140 ImportFirefoxBookmarks im;
2141 QStringList flist = fd->selectedFiles();
2142 QStringList::Iterator it = flist.begin();
2143 while( it != flist.end() )
2146 if (im.transform() &&
2147 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2148 currentMapEditor() )
2149 currentMapEditor()->getModel()->setFilePath ("");
2156 void Main::fileImportFreemind()
2158 QStringList filters;
2159 filters <<"Freemind map (*.mm)"<<"All files (*)";
2160 QFileDialog *fd=new QFileDialog( this);
2161 fd->setDir (lastFileDir);
2162 fd->setFileMode (QFileDialog::ExistingFiles);
2163 fd->setFilters (filters);
2164 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2168 if ( fd->exec() == QDialog::Accepted )
2170 lastFileDir=fd->directory().path();
2171 QStringList flist = fd->selectedFiles();
2172 QStringList::Iterator it = flist.begin();
2173 while( it != flist.end() )
2176 if ( fileLoad (fn,NewMap, FreemindMap) )
2178 currentMapEditor()->getModel()->setFilePath ("");
2187 void Main::fileImportMM()
2191 Q3FileDialog *fd=new Q3FileDialog( this);
2192 fd->setDir (lastFileDir);
2193 fd->setMode (Q3FileDialog::ExistingFiles);
2194 fd->addFilter ("Mind Manager (*.mmap)");
2195 fd->setCaption(tr("Import")+" "+"Mind Manager");
2198 if ( fd->exec() == QDialog::Accepted )
2200 lastFileDir=fd->dirPath();
2201 QStringList flist = fd->selectedFiles();
2202 QStringList::Iterator it = flist.begin();
2203 while( it != flist.end() )
2206 if (im.transform() &&
2207 success==fileLoad (im.getTransformedFile(),NewMap) &&
2208 currentMapEditor() )
2209 currentMapEditor()->getModel()->setFilePath ("");
2216 void Main::fileImportDir()
2218 VymModel *m=currentModel();
2219 if (m) m->importDir();
2222 void Main::fileExportXML()
2224 VymModel *m=currentModel();
2225 if (m) m->exportXML();
2229 void Main::fileExportXHTML()
2231 VymModel *m=currentModel();
2232 if (m) m->exportXHTML();
2235 void Main::fileExportImage()
2237 VymModel *m=currentModel();
2238 if (m) m->exportImage();
2241 void Main::fileExportAO()
2243 VymModel *m=currentModel();
2244 if (m) m->exportAO();
2247 void Main::fileExportASCII()
2249 VymModel *m=currentModel();
2250 if (m) m->exportASCII();
2253 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2255 VymModel *m=currentModel();
2260 ex.addFilter ("CSV (*.csv)");
2261 ex.setDir(lastImageDir);
2262 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2263 if (ex.execDialog() )
2265 m->setExportMode(true);
2267 m->setExportMode(false);
2272 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2274 VymModel *m=currentModel();
2279 ex.addFilter ("Tex (*.tex)");
2280 ex.setDir(lastImageDir);
2281 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2282 if (ex.execDialog() )
2284 m->setExportMode(true);
2286 m->setExportMode(false);
2291 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2293 ExportKDE3Bookmarks ex;
2294 VymModel *m=currentModel();
2302 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2304 ExportKDE4Bookmarks ex;
2305 VymModel *m=currentModel();
2313 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2315 ExportTaskjuggler ex;
2316 VymModel *m=currentModel();
2320 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2321 ex.setDir(lastImageDir);
2322 ex.addFilter ("Taskjuggler (*.tjp)");
2323 if (ex.execDialog() )
2325 m->setExportMode(true);
2327 m->setExportMode(false);
2332 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2334 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2335 // TODO add preview in dialog
2336 //ImagePreview *p =new ImagePreview (fd);
2337 //fd->setContentsPreviewEnabled( TRUE );
2338 //fd->setContentsPreview( p, p );
2339 //fd->setPreviewMode( QFileDialog::Contents );
2340 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2341 fd->setDir (QDir().current());
2342 if (fd->foundConfig())
2346 if ( fd->exec() == QDialog::Accepted )
2348 QString fn=fd->selectedFile();
2349 if (!fn.contains (".odp"))
2352 //lastImageDir=fn.left(fn.findRev ("/"));
2353 VymModel *m=currentModel();
2354 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2358 QMessageBox::warning(0,
2360 tr("Couldn't find configuration for export to Open Office\n"));
2364 void Main::fileCloseMap()
2366 VymModel *m=currentModel();
2369 if (m->hasChanged())
2371 QMessageBox mb( vymName,
2372 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2373 QMessageBox::Warning,
2374 QMessageBox::Yes | QMessageBox::Default,
2376 QMessageBox::Cancel | QMessageBox::Escape );
2377 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2378 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2381 case QMessageBox::Yes:
2383 fileSave(m, CompleteMap);
2385 case QMessageBox::No:
2386 // close without saving
2388 case QMessageBox::Cancel:
2393 // And here comes the segfault, because removeTab triggers
2394 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2395 vymViews.removeAt (tabWidget->currentIndex() );
2396 tabWidget->removeTab (tabWidget->currentIndex() );
2398 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2399 // Better would be delete (me), but then we could have a Qt error:
2400 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2401 // So we only remove data now and call deconstructor when vym closes later
2402 // this needs to be moved to vymview... me->clear();
2403 // some model->clear is needed to free up memory ...
2405 delete (m->getMapEditor());
2412 void Main::filePrint()
2414 if (currentMapEditor())
2415 currentMapEditor()->print();
2418 void Main::fileExitVYM()
2420 // Check if one or more editors have changed
2422 for (i=0;i<=vymViews.count() -1;i++)
2424 // If something changed, ask what to do
2425 if (vymViews.at(i)->getModel()->hasChanged())
2427 tabWidget->setCurrentPage(i);
2428 QMessageBox mb( vymName,
2429 tr("This map is not saved yet. Do you want to"),
2430 QMessageBox::Warning,
2431 QMessageBox::Yes | QMessageBox::Default,
2433 QMessageBox::Cancel | QMessageBox::Escape );
2434 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2435 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2438 mb.setActiveWindow();
2439 switch( mb.exec() ) {
2440 case QMessageBox::Yes:
2441 // save (the changed editors) and exit
2442 fileSave(currentModel(), CompleteMap);
2444 case QMessageBox::No:
2445 // exit without saving
2447 case QMessageBox::Cancel:
2448 // don't save and don't exit
2452 } // loop over all MEs
2456 void Main::editUndo()
2458 VymModel *m=currentModel();
2462 void Main::editRedo()
2464 VymModel *m=currentModel();
2468 void Main::gotoHistoryStep (int i)
2470 VymModel *m=currentModel();
2471 if (m) m->gotoHistoryStep(i);
2474 void Main::editCopy()
2476 VymModel *m=currentModel();
2480 void Main::editPaste()
2482 VymModel *m=currentModel();
2486 void Main::editCut()
2488 VymModel *m=currentModel();
2492 void Main::editOpenFindWindow()
2494 findWindow->popup();
2495 findWindow->raise();
2496 findWindow->setActiveWindow();
2499 void Main::editFind(QString s)
2501 VymModel *m=currentModel();
2505 BranchItem *bi=m->findText(s, cs);
2508 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2511 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2512 tr("No matches found for \"%1\"").arg(s));
2517 void Main::editFindChanged()
2518 { // Notify editor, to abort the current find process
2519 VymModel *m=currentModel();
2520 if (m) m->findReset();
2523 void Main::openTabs(QStringList urls)
2525 if (!urls.isEmpty())
2529 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2530 if (*browserPID==0) //FIXME-2 need to check if browser is really still there instead of this
2532 QString u=urls.takeFirst();
2534 QString workDir=QDir::currentDirPath();
2535 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2537 // try to set path to browser
2538 QMessageBox::warning(0,
2540 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2541 tr("Please use Settings->")+tr("Set application to open an URL"));
2544 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2545 #if defined(Q_OS_WIN32)
2546 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2547 this->thread()->wait(3000);
2549 sleep (3); //FIXME-3 needed?
2553 if (browser.contains("konqueror"))
2555 for (int i=0; i<urls.size(); i++)
2558 // Try to open new tab in existing konqueror started previously by vym
2562 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2563 "konqueror-mainwindow#1"<<
2567 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2568 "/konqueror/MainWindow_1"<<
2572 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2573 if (!QProcess::startDetached ("qdbus",args))
2577 QMessageBox::warning(0,
2579 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2581 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2583 for (int i=0; i<urls.size(); i++)
2585 // Try to open new tab in firefox
2586 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2587 if (!QProcess::startDetached (browser,args))
2591 QMessageBox::warning(0,
2593 tr("Couldn't start %1 to open a new tab").arg(browser));
2596 QMessageBox::warning(0,
2598 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2602 void Main::editOpenURL()
2605 VymModel *m=currentModel();
2608 QString url=m->getURL();
2610 if (url=="") return;
2611 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2613 QString workDir=QDir::currentDirPath();
2614 if (!procBrowser->startDetached(browser,args))
2616 // try to set path to browser
2617 QMessageBox::warning(0,
2619 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2620 tr("Please use Settings->")+tr("Set application to open an URL"));
2625 void Main::editOpenURLTab()
2627 VymModel *m=currentModel();
2631 urls.append(m->getURL());
2635 void Main::editOpenMultipleURLTabs()
2637 VymModel *m=currentModel();
2647 void Main::editURL()
2649 VymModel *m=currentModel();
2650 if (m) m->editURL();
2653 void Main::editLocalURL()
2655 VymModel *m=currentModel();
2656 if (m) m->editLocalURL();
2659 void Main::editHeading2URL()
2661 VymModel *m=currentModel();
2662 if (m) m->editHeading2URL();
2665 void Main::editBugzilla2URL()
2667 VymModel *m=currentModel();
2668 if (m) m->editBugzilla2URL();
2671 void Main::editFATE2URL()
2673 VymModel *m=currentModel();
2674 if (m) m->editFATE2URL();
2677 void Main::editHeadingFinished(VymModel *m)
2681 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2682 !prevSelection.isEmpty())
2683 m->select(prevSelection);
2688 void Main::openVymLinks(const QStringList &vl)
2690 for (int j=0; j<vl.size(); j++)
2692 // compare path with already loaded maps
2695 for (i=0;i<=vymViews.count() -1;i++)
2697 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2706 if (!QFile(vl.at(j)).exists() )
2707 QMessageBox::critical( 0, tr( "Critical Error" ),
2708 tr("Couldn't open map %1").arg(vl.at(j)));
2711 fileLoad (vl.at(j), NewMap);
2712 tabWidget->setCurrentIndex (tabWidget->count()-1);
2715 // Go to tab containing the map
2716 tabWidget->setCurrentIndex (index);
2720 void Main::editOpenVymLink()
2722 VymModel *m=currentModel();
2726 vl.append(m->getVymLink());
2731 void Main::editOpenMultipleVymLinks()
2733 QString currentVymLink;
2734 VymModel *m=currentModel();
2737 QStringList vl=m->getVymLinks();
2742 void Main::editVymLink()
2744 VymModel *m=currentModel();
2749 void Main::editDeleteVymLink()
2751 VymModel *m=currentModel();
2752 if (m) m->deleteVymLink();
2755 void Main::editToggleHideExport()
2757 VymModel *m=currentModel();
2758 if (m) m->toggleHideExport();
2761 void Main::editAddTimestamp()
2763 VymModel *m=currentModel();
2764 if (m) m->addTimestamp();
2767 void Main::editMapInfo()
2769 VymModel *m=currentModel();
2772 ExtraInfoDialog dia;
2773 dia.setMapName (m->getFileName() );
2774 dia.setAuthor (m->getAuthor() );
2775 dia.setComment(m->getComment() );
2779 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2785 BranchItem *cur=NULL;
2786 BranchItem *prev=NULL;
2787 m->nextBranch(cur,prev);
2790 if (!cur->getNote().isEmpty() ) n++;
2791 f+= cur->imageCount();
2793 xl+=cur->xlinkCount();
2794 m->nextBranch(cur,prev);
2797 stats+=QString ("%1 xLinks \n").arg (xl,6);
2798 stats+=QString ("%1 notes\n").arg (n,6);
2799 stats+=QString ("%1 images\n").arg (f,6);
2800 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2801 dia.setStats (stats);
2803 // Finally show dialog
2804 if (dia.exec() == QDialog::Accepted)
2806 m->setAuthor (dia.getAuthor() );
2807 m->setComment (dia.getComment() );
2811 void Main::editMoveUp()
2813 VymModel *m=currentModel();
2817 void Main::editMoveDown()
2819 VymModel *m=currentModel();
2820 if (m) m->moveDown();
2823 void Main::editDetach()
2825 VymModel *m=currentModel();
2829 void Main::editSortChildren()
2831 VymModel *m=currentModel();
2832 if (m) m->sortChildren();
2835 void Main::editToggleScroll()
2837 VymModel *m=currentModel();
2838 if (m) m->toggleScroll();
2841 void Main::editExpandAll()
2843 VymModel *m=currentModel();
2844 if (m) m->emitExpandAll();
2847 void Main::editExpandOneLevel()
2849 VymModel *m=currentModel();
2850 if (m) m->emitExpandOneLevel();
2853 void Main::editCollapseOneLevel()
2855 VymModel *m=currentModel();
2856 if (m) m->emitCollapseOneLevel();
2859 void Main::editUnscrollChildren()
2861 VymModel *m=currentModel();
2862 if (m) m->unscrollChildren();
2865 void Main::editAddAttribute()
2867 VymModel *m=currentModel();
2868 if (m) m->addAttribute();
2871 void Main::editAddMapCenter()
2873 VymModel *m=currentModel();
2874 if (m) m->addMapCenter ();
2877 void Main::editNewBranch()
2879 VymModel *m=currentModel();
2882 BranchItem *bi=m->addNewBranch();
2885 if (actionSettingsAutoEditNewBranch->isOn()
2886 && !actionSettingsAutoSelectNewBranch->isOn() )
2887 prevSelection=m->getSelectString();
2889 prevSelection=QString();
2891 if (actionSettingsAutoSelectNewBranch->isOn()
2892 || actionSettingsAutoEditNewBranch->isOn())
2895 if (actionSettingsAutoEditNewBranch->isOn())
2896 currentMapEditor()->editHeading();
2901 void Main::editNewBranchBefore()
2903 VymModel *m=currentModel();
2906 BranchItem *bi=m->addNewBranchBefore();
2913 if (actionSettingsAutoEditNewBranch->isOn())
2915 if (!actionSettingsAutoSelectNewBranch->isOn())
2916 prevSelection=m->getSelectString(bi);
2917 currentMapEditor()->editHeading();
2922 void Main::editNewBranchAbove() // FIXME-1 can crash
2924 VymModel *m=currentModel();
2927 BranchItem *bi=m->addNewBranch (-1);
2935 if (actionSettingsAutoEditNewBranch->isOn())
2937 if (!actionSettingsAutoSelectNewBranch->isOn())
2938 prevSelection=m->getSelectString (bi);
2939 currentMapEditor()->editHeading();
2944 void Main::editNewBranchBelow()
2946 VymModel *m=currentModel();
2949 BranchItem *bi=m->addNewBranch (1);
2956 if (actionSettingsAutoEditNewBranch->isOn())
2958 if (!actionSettingsAutoSelectNewBranch->isOn())
2959 prevSelection=m->getSelectString(bi);
2960 currentMapEditor()->editHeading();
2965 void Main::editImportAdd()
2967 fileLoad (ImportAdd);
2970 void Main::editImportReplace()
2972 fileLoad (ImportReplace);
2975 void Main::editSaveBranch()
2977 fileSaveAs (PartOfMap);
2980 void Main::editDeleteKeepChildren()
2982 VymModel *m=currentModel();
2983 if (m) m->deleteKeepChildren();
2986 void Main::editDeleteChildren()
2988 VymModel *m=currentModel();
2989 if (m) m->deleteChildren();
2992 void Main::editDeleteSelection()
2994 VymModel *m=currentModel();
2995 if (m && actionSettingsUseDelKey->isOn())
2996 m->deleteSelection();
2999 void Main::editLoadImage()
3001 VymModel *m=currentModel();
3002 if (m) m->loadFloatImage();
3005 void Main::editSaveImage()
3007 VymModel *m=currentModel();
3008 if (m) m->saveFloatImage();
3011 void Main::editFollowXLink(QAction *a)
3014 VymModel *m=currentModel();
3016 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3019 void Main::editEditXLink(QAction *a)
3021 VymModel *m=currentModel();
3023 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3026 void Main::formatSelectColor()
3028 QColor col = QColorDialog::getColor((currentColor ), this );
3029 if ( !col.isValid() ) return;
3030 colorChanged( col );
3033 void Main::formatPickColor()
3035 VymModel *m=currentModel();
3037 colorChanged( m->getCurrentHeadingColor() );
3040 void Main::colorChanged(QColor c)
3042 QPixmap pix( 16, 16 );
3044 actionFormatColor->setIconSet( pix );
3048 void Main::formatColorBranch()
3050 VymModel *m=currentModel();
3051 if (m) m->colorBranch(currentColor);
3054 void Main::formatColorSubtree()
3056 VymModel *m=currentModel();
3057 if (m) m->colorSubtree (currentColor);
3060 void Main::formatLinkStyleLine()
3062 VymModel *m=currentModel();
3065 m->setMapLinkStyle("StyleLine");
3066 actionFormatLinkStyleLine->setChecked(true);
3070 void Main::formatLinkStyleParabel()
3072 VymModel *m=currentModel();
3075 m->setMapLinkStyle("StyleParabel");
3076 actionFormatLinkStyleParabel->setChecked(true);
3080 void Main::formatLinkStylePolyLine()
3082 VymModel *m=currentModel();
3085 m->setMapLinkStyle("StylePolyLine");
3086 actionFormatLinkStylePolyLine->setChecked(true);
3090 void Main::formatLinkStylePolyParabel()
3092 VymModel *m=currentModel();
3095 m->setMapLinkStyle("StylePolyParabel");
3096 actionFormatLinkStylePolyParabel->setChecked(true);
3100 void Main::formatSelectBackColor()
3102 VymModel *m=currentModel();
3103 if (m) m->selectMapBackgroundColor();
3106 void Main::formatSelectBackImage()
3108 VymModel *m=currentModel();
3110 m->selectMapBackgroundImage();
3113 void Main::formatSelectLinkColor()
3115 VymModel *m=currentModel();
3118 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3119 m->setMapDefLinkColor( col );
3123 void Main::formatSelectSelectionColor()
3125 VymModel *m=currentModel();
3128 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3129 m->setSelectionColor (col);
3134 void Main::formatToggleLinkColorHint()
3136 VymModel *m=currentModel();
3137 if (m) m->toggleMapLinkColorHint();
3141 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3143 VymModel *m=currentModel();
3145 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3148 void Main::viewZoomReset()
3150 MapEditor *me=currentMapEditor();
3151 if (me) me->setZoomFactorTarget (1);
3154 void Main::viewZoomIn()
3156 MapEditor *me=currentMapEditor();
3157 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3160 void Main::viewZoomOut()
3162 MapEditor *me=currentMapEditor();
3163 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3166 void Main::viewCenter()
3168 VymModel *m=currentModel();
3169 if (m) m->emitShowSelection();
3172 void Main::networkStartServer()
3174 VymModel *m=currentModel();
3175 if (m) m->newServer();
3178 void Main::networkConnect()
3180 VymModel *m=currentModel();
3181 if (m) m->connectToServer();
3184 bool Main::settingsPDF()
3186 // Default browser is set in constructor
3188 QString text = QInputDialog::getText(
3189 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3190 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3192 settings.setValue ("/mainwindow/readerPDF",text);
3197 bool Main::settingsURL()
3199 // Default browser is set in constructor
3201 QString text = QInputDialog::getText(
3202 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3203 settings.value("/mainwindow/readerURL").toString()
3206 settings.setValue ("/mainwindow/readerURL",text);
3210 void Main::settingsMacroDir()
3212 QDir defdir(vymBaseDir.path() + "/macros");
3213 if (!defdir.exists())
3215 QDir dir=QFileDialog::getExistingDirectory (
3217 tr ("Directory with vym macros:"),
3218 settings.value ("/macros/macroDir",defdir.path()).toString()
3221 settings.setValue ("/macros/macroDir",dir.absolutePath());
3224 void Main::settingsUndoLevels()
3227 int i = QInputDialog::getInteger(
3229 tr("QInputDialog::getInteger()"),
3230 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3233 settings.setValue ("/mapeditor/stepsTotal",i);
3234 QMessageBox::information( this, tr( "VYM -Information:" ),
3235 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3239 void Main::settingsAutosaveToggle()
3241 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3244 void Main::settingsAutosaveTime()
3247 int i = QInputDialog::getInteger(
3249 tr("QInputDialog::getInteger()"),
3250 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3252 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3255 void Main::settingsWriteBackupFileToggle()
3257 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3260 void Main::settingsToggleAnimation()
3262 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3265 void Main::settingsToggleDelKey()
3267 if (actionSettingsUseDelKey->isOn())
3269 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3272 actionDelete->setAccel (QKeySequence (""));
3276 void Main::windowToggleNoteEditor()
3278 if (textEditor->isVisible() )
3279 windowHideNoteEditor();
3281 windowShowNoteEditor();
3284 void Main::windowToggleHistory()
3286 if (historyWindow->isVisible())
3287 historyWindow->hide();
3289 historyWindow->show();
3293 void Main::windowToggleProperty()
3295 if (branchPropertyWindow->isVisible())
3296 branchPropertyWindow->hide();
3298 branchPropertyWindow->show();
3299 branchPropertyWindow->setModel (currentModel() );
3302 void Main::windowToggleAntiAlias()
3304 bool b=actionViewToggleAntiAlias->isOn();
3306 for (int i=0;i<vymViews.count();i++)
3308 me=vymViews.at(i)->getMapEditor();
3309 if (me) me->setAntiAlias(b);
3314 bool Main::isAliased()
3316 return actionViewToggleAntiAlias->isOn();
3319 bool Main::hasSmoothPixmapTransform()
3321 return actionViewToggleSmoothPixmapTransform->isOn();
3324 void Main::windowToggleSmoothPixmap()
3326 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3328 for (int i=0;i<vymViews.count();i++)
3331 me=vymViews.at(i)->getMapEditor();
3332 if (me) me->setSmoothPixmap(b);
3336 void Main::updateHistory(SimpleSettings &undoSet)
3338 historyWindow->update (undoSet);
3341 void Main::updateNoteFlag()
3343 // this slot is connected to TextEditor::textHasChanged()
3345 VymModel *m=currentModel();
3346 if (m) m->updateNoteFlag();
3349 void Main::updateNoteEditor(QModelIndex index )
3351 cout << QObject::sender();
3352 QObject *obj=QObject::sender();
3353 TreeItem *ti=((TreeModel*)obj)->getItem (index);
3354 //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3355 //cout << "Main::updateNoteEditor model="<<sender();
3356 //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3357 textEditor->setNote (ti->getNoteObj() );
3360 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3362 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3364 if (model && model==currentModel() )
3368 if (!oldsel.indexes().isEmpty() )
3370 ti=model->getItem(oldsel.indexes().first());
3372 // Don't update note if both treeItem and textEditor are empty
3373 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3374 // ti->setNoteObj (textEditor->getNoteObj(),false );
3376 if (!newsel.indexes().isEmpty() )
3378 ti=model->getItem(newsel.indexes().first());
3379 if (!ti->hasEmptyNote() )
3380 textEditor->setNote(ti->getNoteObj() );
3382 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3384 // Show URL and link in statusbar
3386 QString s=ti->getURL();
3387 if (!s.isEmpty() ) status+="URL: "+s+" ";
3389 if (!s.isEmpty() ) status+="Link: "+s;
3390 if (!status.isEmpty() ) statusMessage (status);
3393 textEditor->setInactive();
3399 void Main::updateActions()
3401 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3402 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3403 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3404 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3406 VymModel *m =currentModel();
3410 actionFilePrint->setEnabled (true);
3412 // Link style in context menu
3413 switch (m->getMapLinkStyle())
3415 case LinkableMapObj::Line:
3416 actionFormatLinkStyleLine->setChecked(true);
3418 case LinkableMapObj::Parabel:
3419 actionFormatLinkStyleParabel->setChecked(true);
3421 case LinkableMapObj::PolyLine:
3422 actionFormatLinkStylePolyLine->setChecked(true);
3424 case LinkableMapObj::PolyParabel:
3425 actionFormatLinkStylePolyParabel->setChecked(true);
3432 QPixmap pix( 16, 16 );
3433 pix.fill( m->getMapBackgroundColor() );
3434 actionFormatBackColor->setIconSet( pix );
3435 pix.fill( m->getSelectionColor() );
3436 actionFormatSelectionColor->setIconSet( pix );
3437 pix.fill( m->getMapDefLinkColor() );
3438 actionFormatLinkColor->setIconSet( pix );
3441 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3444 // Expanding/collapsing
3445 actionExpandAll->setEnabled (true);
3446 actionExpandOneLevel->setEnabled (true);
3447 actionCollapseOneLevel->setEnabled (true);
3451 actionFilePrint->setEnabled (false);
3453 // Expanding/collapsing
3454 actionExpandAll->setEnabled (false);
3455 actionExpandOneLevel->setEnabled (false);
3456 actionCollapseOneLevel->setEnabled (false);
3459 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3460 actionFormatLinkColorHint->setChecked(true);
3462 actionFormatLinkColorHint->setChecked(false);
3465 if (m && m->hasChanged() )
3466 actionFileSave->setEnabled( true);
3468 actionFileSave->setEnabled( false);
3469 if (m && m->isUndoAvailable())
3470 actionUndo->setEnabled( true);
3472 actionUndo->setEnabled( false);
3474 if (m && m->isRedoAvailable())
3475 actionRedo->setEnabled( true);
3477 actionRedo->setEnabled( false);
3481 TreeItem *selti=m->getSelectedItem();
3482 BranchItem *selbi=m->getSelectedBranch();
3485 if (selbi || selti->getType()==TreeItem::Image)
3487 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3488 actionFormatHideLinkUnselected->setEnabled (true);
3493 // Take care of xlinks
3494 branchXLinksContextMenuEdit->clear();
3495 branchXLinksContextMenuFollow->clear();
3496 if (selbi->xlinkCount()>0)
3500 for (int i=0; i<selbi->xlinkCount();++i)
3502 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3506 if (s.length()>xLinkMenuWidth)
3507 s=s.left(xLinkMenuWidth)+"...";
3508 branchXLinksContextMenuFollow->addAction (s);
3509 branchXLinksContextMenuEdit->addAction (s);
3514 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3517 actionToggleScroll->setEnabled (true);
3518 if ( selbi->isScrolled() )
3519 actionToggleScroll->setChecked(true);
3521 actionToggleScroll->setChecked(false);
3523 if ( selti->getURL().isEmpty() )
3525 actionOpenURL->setEnabled (false);
3526 actionOpenURLTab->setEnabled (false);
3530 actionOpenURL->setEnabled (true);
3531 actionOpenURLTab->setEnabled (true);
3533 if ( selti->getVymLink().isEmpty() )
3535 actionOpenVymLink->setEnabled (false);
3536 actionDeleteVymLink->setEnabled (false);
3539 actionOpenVymLink->setEnabled (true);
3540 actionDeleteVymLink->setEnabled (true);
3543 if (selbi->canMoveUp())
3544 actionMoveUp->setEnabled (true);
3546 actionMoveUp->setEnabled (false);
3547 if (selbi->canMoveDown())
3548 actionMoveDown->setEnabled (true);
3550 actionMoveDown->setEnabled (false);
3552 actionSortChildren->setEnabled (true);
3554 actionToggleHideExport->setEnabled (true);
3555 actionToggleHideExport->setChecked (selbi->hideInExport() );
3557 actionCopy->setEnabled (true);
3558 actionCut->setEnabled (true);
3559 if (!clipboardEmpty)
3560 actionPaste->setEnabled (true);
3562 actionPaste->setEnabled (false);
3563 for (int i=0; i<actionListBranches.size(); ++i)
3564 actionListBranches.at(i)->setEnabled(true);
3565 actionDelete->setEnabled (true);
3567 if ( selti->getType()==TreeItem::Image)
3569 actionOpenURL->setEnabled (false);
3570 actionOpenVymLink->setEnabled (false);
3571 actionDeleteVymLink->setEnabled (false);
3572 actionToggleHideExport->setEnabled (true);
3573 actionToggleHideExport->setChecked (selti->hideInExport() );
3576 actionCopy->setEnabled (true);
3577 actionCut->setEnabled (true);
3578 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3579 for (int i=0; i<actionListBranches.size(); ++i)
3580 actionListBranches.at(i)->setEnabled(false);
3581 actionDelete->setEnabled (true);
3582 actionMoveUp->setEnabled (false);
3583 actionMoveDown->setEnabled (false);
3588 actionCopy->setEnabled (false);
3589 actionCut->setEnabled (false);
3590 actionPaste->setEnabled (false);
3591 for (int i=0; i<actionListBranches.size(); ++i)
3592 actionListBranches.at(i)->setEnabled(false);
3594 actionToggleScroll->setEnabled (false);
3595 actionOpenURL->setEnabled (false);
3596 actionOpenVymLink->setEnabled (false);
3597 actionDeleteVymLink->setEnabled (false);
3598 actionHeading2URL->setEnabled (false);
3599 actionDelete->setEnabled (false);
3600 actionMoveUp->setEnabled (false);
3601 actionMoveDown->setEnabled (false);
3602 actionFormatHideLinkUnselected->setEnabled (false);
3603 actionSortChildren->setEnabled (false);
3604 actionToggleHideExport->setEnabled (false);
3609 Main::ModMode Main::getModMode()
3611 if (actionModModeColor->isOn()) return ModModeColor;
3612 if (actionModModeCopy->isOn()) return ModModeCopy;
3613 if (actionModModeXLink->isOn()) return ModModeXLink;
3617 bool Main::autoEditNewBranch()
3619 return actionSettingsAutoEditNewBranch->isOn();
3622 bool Main::autoSelectNewBranch()
3624 return actionSettingsAutoSelectNewBranch->isOn();
3627 void Main::windowShowNoteEditor()
3629 textEditor->setShowWithMain(true);
3631 actionViewToggleNoteEditor->setChecked (true);
3634 void Main::windowHideNoteEditor()
3636 textEditor->setShowWithMain(false);
3638 actionViewToggleNoteEditor->setChecked (false);
3641 void Main::setScript (const QString &script)
3643 scriptEditor->setScript (script);
3646 void Main::runScript (const QString &script)
3648 VymModel *m=currentModel();
3649 if (m) m->runScript (script);
3652 void Main::runScriptEverywhere (const QString &script)
3655 for (int i=0;i<=tabWidget->count() -1;i++)
3657 me=(MapEditor*)tabWidget->page(i);
3658 if (me) me->getModel()->runScript (script);
3662 void Main::windowNextEditor()
3664 if (tabWidget->currentIndex() < tabWidget->count())
3665 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3668 void Main::windowPreviousEditor()
3670 if (tabWidget->currentIndex() >0)
3671 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3674 void Main::standardFlagChanged()
3678 if ( actionSettingsUseFlagGroups->isOn() )
3679 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3681 currentModel()->toggleStandardFlag(sender()->name());
3686 void Main::testFunction1()
3688 if (!currentMapEditor()) return;
3689 currentMapEditor()->testFunction1();
3692 VymModel *m=currentModel();
3696 QString text = QInputDialog::getText(
3697 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3698 m->getSortFilter(), &ok, NULL);
3700 // user entered something and pressed OK
3701 m->setSortFilter (text);
3705 void Main::testFunction2()
3707 if (!currentMapEditor()) return;
3708 currentMapEditor()->testFunction2();
3711 void Main::testCommand()
3713 if (!currentMapEditor()) return;
3714 scriptEditor->show();
3717 QString com = QInputDialog::getText(
3718 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3719 if (ok) currentMapEditor()->parseAtom(com);
3723 void Main::helpDoc()
3725 QString locale = QLocale::system().name();
3727 if (locale.left(2)=="es")
3728 docname="vym_es.pdf";
3732 QStringList searchList;
3734 #if defined(Q_OS_MACX)
3735 searchList << "./vym.app/Contents/Resources/doc";
3736 #elif defined(Q_OS_WIN32)
3737 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3739 #if defined(VYM_DOCDIR)
3740 searchList << VYM_DOCDIR;
3742 // default path in SUSE LINUX
3743 searchList << "/usr/share/doc/packages/vym";
3746 searchList << "doc"; // relative path for easy testing in tarball
3747 searchList << "doc/tex"; // Easy testing working on vym.tex
3748 searchList << "/usr/share/doc/vym"; // Debian
3749 searchList << "/usr/share/doc/packages";// Knoppix
3753 for (int i=0; i<searchList.count(); ++i)
3755 docfile.setFileName(searchList.at(i)+"/"+docname);
3756 if (docfile.exists())
3765 QMessageBox::critical(0,
3766 tr("Critcal error"),
3767 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3772 Process *pdfProc = new Process();
3773 args << QDir::toNativeSeparators(docfile.fileName());
3775 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3778 QMessageBox::warning(0,
3780 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3781 tr("Please use Settings->")+tr("Set application to open PDF files"));
3788 void Main::helpDemo()
3790 QStringList filters;
3791 filters <<"VYM example map (*.vym)";
3792 QFileDialog *fd=new QFileDialog( this);
3793 #if defined(Q_OS_MACX)
3794 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3796 // default path in SUSE LINUX
3797 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3800 fd->setFileMode (QFileDialog::ExistingFiles);
3801 fd->setFilters (filters);
3802 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3806 if ( fd->exec() == QDialog::Accepted )
3808 lastFileDir=fd->directory().path();
3809 QStringList flist = fd->selectedFiles();
3810 QStringList::Iterator it = flist.begin();
3811 while( it != flist.end() )
3814 fileLoad(*it, NewMap);
3822 void Main::helpAbout()
3825 ad.setName ("aboutwindow");
3826 ad.setMinimumSize(500,500);
3827 ad.resize (QSize (500,500));
3831 void Main::helpAboutQT()
3833 QMessageBox::aboutQt( this, "Qt Application Example" );
3836 void Main::callMacro ()
3838 QAction *action = qobject_cast<QAction *>(sender());
3842 i=action->data().toInt();
3843 QString mDir (settings.value ("macros/macroDir").toString() );
3845 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3847 if ( !f.open( QIODevice::ReadOnly ) )
3849 QMessageBox::warning(0,
3851 tr("Couldn't find a macro at %1.\n").arg(fn)+
3852 tr("Please use Settings->")+tr("Set directory for vym macros"));
3856 QTextStream ts( &f );
3857 QString macro= ts.read();
3859 if (! macro.isEmpty())
3861 VymModel *m=currentModel();
3862 if (m) m->runScript(macro);