1 #include "mainwindow.h"
3 #include <QtDBus/QtDBus>
9 #include "aboutdialog.h"
10 #include "branchpropwindow.h"
11 #include "branchitem.h"
12 #include "exportoofiledialog.h"
15 #include "flagrowobj.h"
16 #include "historywindow.h"
18 #include "mapeditor.h"
23 #include "texteditor.h"
24 #include "warningdialog.h"
26 #if defined(Q_OS_WIN32)
27 // Define only this structure as opposed to
28 // including full 'windows.h'. FindWindow
29 // clashes with the one in Win32 API.
30 typedef struct _PROCESS_INFORMATION
36 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
39 extern TextEditor *textEditor;
40 extern Main *mainWindow;
41 extern QString tmpVymDir;
42 extern QString clipboardDir;
43 extern QString clipboardFile;
44 extern bool clipboardEmpty;
45 extern int statusbarTime;
46 extern FlagRowObj* standardFlagsDefault;
47 extern FlagRowObj* systemFlagsDefault;
48 extern QString vymName;
49 extern QString vymVersion;
50 extern QString vymBuildDate;
53 QMenu* branchContextMenu;
54 QMenu* branchAddContextMenu;
55 QMenu* branchRemoveContextMenu;
56 QMenu* branchLinksContextMenu;
57 QMenu* branchXLinksContextMenuEdit;
58 QMenu* branchXLinksContextMenuFollow;
59 QMenu* floatimageContextMenu;
60 QMenu* canvasContextMenu;
61 QMenu* fileLastMapsMenu;
62 QMenu* fileImportMenu;
63 QMenu* fileExportMenu;
66 extern Settings settings;
67 extern Options options;
68 extern ImageIO imageIO;
70 extern QDir vymBaseDir;
71 extern QDir lastImageDir;
72 extern QDir lastFileDir;
73 #if defined(Q_OS_WIN32)
74 extern QDir vymInstallDir;
76 extern QString iconPath;
77 extern QString flagsPath;
80 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
81 QMainWindow(parent,name,f)
85 setCaption ("VYM - View Your Mind");
87 // Load window settings
88 #if defined(Q_OS_WIN32)
89 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
91 setWindowState(Qt::WindowMaximized);
96 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
97 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
100 // Sometimes we may need to remember old selections
104 currentColor=Qt::black;
106 // Create unique temporary directory
108 tmpVymDir=makeTmpDir (ok,"vym");
111 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
114 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
116 // Create direcctory for clipboard
117 clipboardDir=tmpVymDir+"/clipboard";
118 clipboardFile="map.xml";
119 QDir d(clipboardDir);
120 d.mkdir (clipboardDir,true);
121 makeSubDirs (clipboardDir);
126 // Satellite windows //////////////////////////////////////////
128 historyWindow=new HistoryWindow();
129 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
132 branchPropertyWindow = new BranchPropertyWindow();
133 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
135 // Connect TextEditor, so that we can update flags if text changes
136 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
137 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
139 // Connect HistoryWindow, so that we can update flags
140 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
143 // Initialize script editor
144 scriptEditor = new SimpleScriptEditor();
145 scriptEditor->move (50,50);
147 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
148 this, SLOT( runScript( QString ) ) );
151 // Initialize Find window
152 findWindow=new FindWindow(NULL);
153 findWindow->move (x(),y()+70);
154 connect (findWindow, SIGNAL( findButton(QString) ),
155 this, SLOT(editFind(QString) ) );
156 connect (findWindow, SIGNAL( somethingChanged() ),
157 this, SLOT(editFindChanged() ) );
159 // Initialize some settings, which are platform dependant
162 // application to open URLs
163 p="/mainwindow/readerURL";
164 #if defined(Q_OS_LINUX)
165 s=settings.value (p,"xdg-open").toString();
167 #if defined(Q_OS_MACX)
168 s=settings.value (p,"/usr/bin/open").toString();
171 #if defined(Q_OS_WIN32)
172 // Assume that system has been set up so that
173 // Explorer automagically opens up the URL
174 // in the user's preferred browser.
175 s=settings.value (p,"explorer").toString();
177 s=settings.value (p,"mozilla").toString();
181 settings.setValue( p,s);
183 // application to open PDFs
184 p="/mainwindow/readerPDF";
185 #if defined(Q_OS_LINUX)
186 s=settings.value (p,"xdg-open").toString();
188 #if defined(Q_OS_MACX)
189 s=settings.value (p,"/usr/bin/open").toString();
190 #elif defined(Q_OS_WIN32)
191 s=settings.value (p,"acrord32").toString();
193 s=settings.value (p,"acroread").toString();
196 settings.setValue( p,s);
198 // width of xLinksMenu
201 // Create tab widget which holds the maps
202 tabWidget= new QTabWidget (this);
203 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
204 this, SLOT( editorChanged( QWidget * ) ) );
206 setCentralWidget(tabWidget);
210 setupFormatActions();
214 setupNetworkActions();
215 setupSettingsActions();
218 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
221 // Status bar and progress bar there
224 progressBar=new QProgressBar;
226 statusBar()->addPermanentWidget(progressBar);
228 restoreState (settings.value("/mainwindow/state",0).toByteArray());
236 #if defined(Q_OS_WIN32)
237 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
239 settings.setValue ("/mainwindow/geometry/size", size());
240 settings.setValue ("/mainwindow/geometry/pos", pos());
241 settings.setValue ("/mainwindow/state",saveState(0));
243 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
244 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
245 settings.setValue( "/version/version", vymVersion );
246 settings.setValue( "/version/builddate", vymBuildDate );
248 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
249 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
250 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
251 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
252 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
253 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
254 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
255 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
257 //TODO save scriptEditor settings
259 // call the destructors
261 delete historyWindow;
262 delete branchPropertyWindow;
265 // Remove temporary directory
266 removeDir (QDir(tmpVymDir));
269 void Main::loadCmdLine()
271 /* TODO draw some kind of splashscreen while loading...
277 QStringList flist=options.getFileList();
278 QStringList::Iterator it=flist.begin();
280 while (it !=flist.end() )
282 fileLoad (*it, NewMap);
288 void Main::statusMessage(const QString &s)
290 // Surpress messages while progressbar during
292 if (progressMin==progressMax)
293 statusBar()->message( s);
296 void Main::setProgressMinimum (int min)
298 progressBar->setMinimum(min);
302 void Main::setProgressMaximum (int max)
304 progressBar->setMaximum(max);
308 statusBar()->addPermanentWidget(progressBar);
313 void Main::setProgressValue (int v)
315 progressBar->setValue (v);
318 void Main::removeProgressBar()
321 statusBar()->removeWidget(progressBar);
322 progressMax=progressMin=0;
325 void Main::closeEvent (QCloseEvent* )
331 void Main::setupFileActions()
333 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
334 QToolBar *tb = addToolBar( tr ("&Map") );
335 tb->setObjectName ("mapTB");
338 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
339 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
340 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
342 fileMenu->addAction (a);
343 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
345 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
346 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
347 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
348 fileMenu->addAction (a);
349 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
352 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
353 a->setStatusTip (tr( "Open","Status tip File menu" ) );
354 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
356 fileMenu->addAction (a);
357 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
359 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
360 fileMenu->addSeparator();
362 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
363 a->setStatusTip ( tr( "Save","Status tip file menu" ));
364 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
366 fileMenu->addAction (a);
367 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
370 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
371 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
372 fileMenu->addAction (a);
373 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
375 fileMenu->addSeparator();
377 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
379 a = new QAction(tr("KDE 3 Bookmarks"), this);
380 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
381 a->addTo (fileImportMenu);
382 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
384 a = new QAction(tr("KDE 4 Bookmarks"), this);
385 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
386 a->addTo (fileImportMenu);
387 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
389 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
391 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
392 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
393 a->addTo (fileImportMenu);
394 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
397 a = new QAction("Freemind...",this);
398 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
399 fileImportMenu->addAction (a);
400 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
402 a = new QAction("Mind Manager...",this);
403 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
404 fileImportMenu->addAction (a);
405 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
407 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
408 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
409 fileImportMenu->addAction (a);
410 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
412 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
414 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
415 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
416 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
417 fileExportMenu->addAction (a);
419 a = new QAction( "Open Office...", this);
420 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
421 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
422 fileExportMenu->addAction (a);
424 a = new QAction( "Webpage (XHTML)...",this );
425 a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML
426 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
427 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
428 fileExportMenu->addAction (a);
430 a = new QAction( "Text (ASCII)...", this);
431 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
432 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
433 fileExportMenu->addAction (a);
435 a = new QAction( "Spreadsheet (CSV)...", this);
436 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
437 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
438 fileExportMenu->addAction (a);
440 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
441 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
442 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
443 fileExportMenu->addAction (a);
445 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
446 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
447 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
448 fileExportMenu->addAction (a);
450 a = new QAction( "Taskjuggler...", this );
451 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
452 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
453 fileExportMenu->addAction (a);
455 a = new QAction( "LaTeX...", this);
456 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
457 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
458 fileExportMenu->addAction (a);
460 a = new QAction( "XML..." , this );
461 a->setStatusTip (tr( "Export as %1").arg("XML"));
462 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
463 fileExportMenu->addAction (a);
465 fileMenu->addSeparator();
467 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
468 a->setStatusTip ( tr( "Print" ,"File menu") );
469 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
471 fileMenu->addAction (a);
472 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
475 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
476 a->setStatusTip (tr( "Close Map" ) );
477 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
478 fileMenu->addAction (a);
479 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
481 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
482 a->setStatusTip ( tr( "Exit")+" "+vymName );
483 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
484 fileMenu->addAction (a);
485 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
490 void Main::setupEditActions()
492 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
493 tb->setLabel( "Edit Actions" );
494 tb->setObjectName ("actionsTB");
495 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
499 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
500 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
501 a->setStatusTip (tr( "Undo" ) );
502 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
503 a->setEnabled (false);
505 editMenu->addAction (a);
508 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
509 a->setStatusTip (tr( "Redo" ));
510 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
512 editMenu->addAction (a);
513 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
516 editMenu->addSeparator();
517 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
518 a->setStatusTip ( tr( "Copy" ) );
519 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
520 a->setEnabled (false);
522 editMenu->addAction (a);
523 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
526 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
527 a->setStatusTip ( tr( "Cut" ) );
528 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
529 a->setEnabled (false);
531 editMenu->addAction (a);
533 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
535 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
536 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
537 a->setStatusTip ( tr( "Paste" ) );
538 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
539 a->setEnabled (false);
541 editMenu->addAction (a);
545 // Shortcuts to modify heading:
546 a = new QAction(tr( "Edit heading","Edit menu" ),this);
547 a->setStatusTip ( tr( "edit Heading" ));
548 a->setShortcut ( Qt::Key_Enter); //Edit heading
549 // a->setShortcutContext (Qt::WindowShortcut);
551 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
552 actionListBranches.append(a);
553 a = new QAction( tr( "Edit heading","Edit menu" ), this);
554 a->setStatusTip (tr( "edit Heading" ));
555 a->setShortcut (Qt::Key_Return ); //Edit heading
556 //a->setShortcutContext (Qt::WindowShortcut);
558 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
559 actionListBranches.append(a);
560 editMenu->addAction (a);
563 a = new QAction( tr( "Edit heading","Edit menu" ), this);
564 a->setStatusTip (tr( "edit Heading" ));
565 //a->setShortcut ( Qt::Key_F2 ); //Edit heading
566 a->setShortcutContext (Qt::WindowShortcut);
568 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
569 actionListBranches.append(a);
572 // Shortcut to delete selection
573 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
574 a->setStatusTip (tr( "Delete Selection" ));
575 a->setShortcut ( Qt::Key_Delete); //Delete selection
576 a->setShortcutContext (Qt::WindowShortcut);
578 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
581 // Shortcut to add mapcenter
582 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
583 a->setShortcut ( Qt::Key_M);
584 a->setShortcutContext (Qt::WindowShortcut);
585 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
586 //actionListBranches.append(a);
588 actionAddMapCenter = a;
591 // Shortcut to add branch
592 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
593 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
594 alt->setShortcut (Qt::Key_A); //Add branch
595 alt->setShortcutContext (Qt::WindowShortcut);
597 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
598 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
599 a->setStatusTip ( tr( "Add a branch as child of selection" ));
600 a->setShortcut (Qt::Key_Insert); //Add branch
601 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
602 actionListBranches.append(a);
603 #if defined (Q_OS_MACX)
604 // In OSX show different shortcut in menues, the keys work indepently always
609 editMenu->addAction (actionAddBranch);
610 tb->addAction (actionAddBranch);
613 // Add branch by inserting it at selection
614 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
615 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
616 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
617 a->setShortcutContext (Qt::WindowShortcut);
619 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
620 a->setEnabled (false);
621 actionListBranches.append(a);
622 actionAddBranchBefore=a;
623 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
624 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
625 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
626 a->setShortcutContext (Qt::WindowShortcut);
628 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
629 actionListBranches.append(a);
632 a = new QAction(tr( "Add branch above","Edit menu" ), this);
633 a->setStatusTip ( tr( "Add a branch above selection" ));
634 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
635 a->setShortcutContext (Qt::WindowShortcut);
637 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
638 a->setEnabled (false);
639 actionListBranches.append(a);
640 actionAddBranchAbove=a;
641 a = new QAction(tr( "Add branch above","Edit menu" ), this);
642 a->setStatusTip ( tr( "Add a branch above selection" ));
643 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
644 a->setShortcutContext (Qt::WindowShortcut);
646 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
647 actionListBranches.append(a);
650 a = new QAction(tr( "Add branch below","Edit menu" ), this);
651 a->setStatusTip ( tr( "Add a branch below selection" ));
652 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
653 a->setShortcutContext (Qt::WindowShortcut);
655 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
656 a->setEnabled (false);
657 actionListBranches.append(a);
658 actionAddBranchBelow=a;
659 a = new QAction(tr( "Add branch below","Edit menu" ), this);
660 a->setStatusTip ( tr( "Add a branch below selection" ));
661 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
662 a->setShortcutContext (Qt::WindowShortcut);
664 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
665 actionListBranches.append(a);
667 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
668 a->setStatusTip ( tr( "Move branch up" ) );
669 a->setShortcut (Qt::Key_PageUp ); // Move branch up
670 a->setEnabled (false);
672 editMenu->addAction (a);
673 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
676 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
677 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
678 a->setStatusTip (tr( "Move branch down" ) );
679 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
680 a->setEnabled (false);
682 editMenu->addAction (a);
685 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
686 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
687 a->setEnabled (true);
689 editMenu->addAction (a);
690 actionSortChildren=a;
692 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
693 a->setShortcut ( Qt::Key_ScrollLock );
694 a->setStatusTip (tr( "Scroll branch" ) );
695 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
697 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
698 alt->setShortcut ( Qt::Key_S ); // Scroll branch
699 alt->setStatusTip (tr( "Scroll branch" ));
700 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
701 #if defined(Q_OS_MACX)
702 actionToggleScroll=alt;
704 actionToggleScroll=a;
706 actionToggleScroll->setEnabled (false);
707 actionToggleScroll->setToggleAction(true);
708 tb->addAction (actionToggleScroll);
709 editMenu->addAction ( actionToggleScroll);
710 editMenu->addAction (actionToggleScroll);
713 actionListBranches.append(actionToggleScroll);
715 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
716 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
717 editMenu->addAction (a);
718 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
720 editMenu->addSeparator();
722 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
723 a->setStatusTip (tr( "Find" ) );
724 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
725 editMenu->addAction (a);
726 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
728 editMenu->addSeparator();
730 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
731 a->setShortcut (Qt::CTRL + Qt::Key_U );
732 a->setShortcut (tr( "Open URL" ));
735 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
738 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
739 a->setStatusTip (tr( "Open URL in new tab" ));
740 //a->setShortcut (Qt::CTRL+Qt::Key_U );
742 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
745 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
746 a->setStatusTip (tr( "Open all URLs in subtree" ));
748 actionListBranches.append(a);
749 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
750 actionOpenMultipleURLTabs=a;
752 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
753 a->setStatusTip ( tr( "Edit URL" ) );
754 a->setShortcut ( Qt::Key_U );
755 a->setShortcutContext (Qt::WindowShortcut);
756 actionListBranches.append(a);
758 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
761 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
762 a->setStatusTip ( tr( "Edit local URL" ) );
763 a->setShortcut (Qt::SHIFT + Qt::Key_U );
764 a->setShortcutContext (Qt::WindowShortcut);
765 actionListBranches.append(a);
767 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
770 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
771 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
772 a->setEnabled (false);
773 actionListBranches.append(a);
774 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
777 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
778 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
779 a->setEnabled (false);
780 actionListBranches.append(a);
781 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
782 actionBugzilla2URL=a;
784 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
785 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
786 a->setEnabled (false);
787 actionListBranches.append(a);
788 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
791 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
792 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
794 a->setEnabled (false);
795 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
798 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
799 a->setStatusTip ( tr( "Open all vym links in subtree" ));
800 a->setEnabled (false);
801 actionListBranches.append(a);
802 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
803 actionOpenMultipleVymLinks=a;
806 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
807 a->setEnabled (false);
808 a->setStatusTip ( tr( "Edit link to another vym map" ));
809 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
810 actionListBranches.append(a);
813 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
814 a->setStatusTip ( tr( "Delete link to another vym map" ));
815 a->setEnabled (false);
816 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
817 actionDeleteVymLink=a;
819 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
820 a->setStatusTip ( tr( "Hide object in exports" ) );
821 a->setShortcut (Qt::Key_H );
822 a->setToggleAction(true);
824 a->setEnabled (false);
825 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
826 actionToggleHideExport=a;
828 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
829 a->setStatusTip ( tr( "Edit Map Info" ));
830 a->setEnabled (true);
831 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
834 // Import at selection (adding to selection)
835 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
836 a->setStatusTip (tr( "Add map at selection" ));
837 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
838 a->setEnabled (false);
839 actionListBranches.append(a);
842 // Import at selection (replacing selection)
843 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
844 a->setStatusTip (tr( "Replace selection with map" ));
845 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
846 a->setEnabled (false);
847 actionListBranches.append(a);
848 actionImportReplace=a;
851 a = new QAction( tr( "Save selection","Edit menu" ), this);
852 a->setStatusTip (tr( "Save selection" ));
853 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
854 a->setEnabled (false);
855 actionListBranches.append(a);
858 // Only remove branch, not its children
859 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
860 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
861 a->setShortcut (Qt::ALT + Qt::Key_Delete );
862 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
863 a->setEnabled (false);
865 actionListBranches.append(a);
866 actionDeleteKeepChildren=a;
868 // Only remove children of a branch
869 a = new QAction( tr( "Remove children","Edit menu" ), this);
870 a->setStatusTip (tr( "Remove children of branch" ));
871 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
872 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
873 a->setEnabled (false);
874 actionListBranches.append(a);
875 actionDeleteChildren=a;
877 // Shortcuts for navigating with cursor:
878 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
879 a->setStatusTip ( tr( "Select upper branch" ));
880 a->setShortcut (Qt::Key_Up );
881 a->setShortcutContext (Qt::WindowShortcut);
883 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
884 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
885 a->setStatusTip (tr( "Select lower branch" ));
886 a->setShortcut ( Qt::Key_Down );
887 a->setShortcutContext (Qt::WindowShortcut);
889 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
890 a = new QAction(tr( "Select left branch","Edit menu" ), this);
891 a->setStatusTip ( tr( "Select left branch" ));
892 a->setShortcut (Qt::Key_Left );
893 a->setShortcutContext (Qt::WindowShortcut);
895 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
896 a = new QAction( tr( "Select child branch","Edit menu" ), this);
897 a->setStatusTip (tr( "Select right branch" ));
898 a->setShortcut (Qt::Key_Right);
899 a->setShortcutContext (Qt::WindowShortcut);
901 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
902 a = new QAction( tr( "Select first branch","Edit menu" ), this);
903 a->setStatusTip (tr( "Select first branch" ));
904 a->setShortcut (Qt::Key_Home );
905 a->setShortcutContext (Qt::WindowShortcut);
907 a->setEnabled (false);
908 editMenu->addAction (a);
909 actionListBranches.append(a);
911 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
912 a = new QAction( tr( "Select last branch","Edit menu" ),this);
913 a->setStatusTip (tr( "Select last branch" ));
914 a->setShortcut ( Qt::Key_End );
915 a->setShortcutContext (Qt::WindowShortcut);
917 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
918 a->setEnabled (false);
919 editMenu->addAction (a);
920 actionListBranches.append(a);
923 a = new QAction( tr( "Add Image...","Edit menu" ), this);
924 a->setStatusTip (tr( "Add Image" ));
925 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
928 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
929 a->setStatusTip (tr( "Set properties for selection" ));
930 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
931 a->setShortcutContext (Qt::WindowShortcut);
932 a->setToggleAction (true);
934 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
935 actionViewTogglePropertyWindow=a;
939 void Main::setupFormatActions()
941 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
943 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
944 tb->setObjectName ("formatTB");
947 pix.fill (Qt::black);
948 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
949 a->setStatusTip ( tr( "Set Color" ));
950 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
952 formatMenu->addAction (a);
954 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
955 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
956 a->setShortcut (Qt::CTRL + Qt::Key_K );
957 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
958 a->setEnabled (false);
960 formatMenu->addAction (a);
961 actionListBranches.append(a);
962 actionFormatPickColor=a;
964 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
965 a->setStatusTip ( tr( "Color branch" ) );
966 a->setShortcut (Qt::CTRL + Qt::Key_B);
967 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
968 a->setEnabled (false);
970 formatMenu->addAction (a);
971 actionListBranches.append(a);
972 actionFormatColorSubtree=a;
974 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
975 a->setStatusTip ( tr( "Color Subtree" ));
976 a->setShortcut (Qt::CTRL + Qt::Key_T);
977 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
978 a->setEnabled (false);
979 formatMenu->addAction (a);
981 actionListBranches.append(a);
982 actionFormatColorSubtree=a;
984 formatMenu->addSeparator();
985 actionGroupFormatLinkStyles=new QActionGroup ( this);
986 actionGroupFormatLinkStyles->setExclusive (true);
987 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
988 a->setStatusTip (tr( "Line" ));
989 a->setToggleAction(true);
990 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
991 formatMenu->addAction (a);
992 actionFormatLinkStyleLine=a;
993 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
994 a->setStatusTip (tr( "Line" ));
995 a->setToggleAction(true);
996 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
997 formatMenu->addAction (a);
998 actionFormatLinkStyleParabel=a;
999 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1000 a->setStatusTip (tr( "PolyLine" ));
1001 a->setToggleAction(true);
1002 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1003 formatMenu->addAction (a);
1004 actionFormatLinkStylePolyLine=a;
1005 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1006 a->setStatusTip (tr( "PolyParabel" ) );
1007 a->setToggleAction(true);
1008 a->setChecked (true);
1009 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1010 formatMenu->addAction (a);
1011 actionFormatLinkStylePolyParabel=a;
1013 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1014 a->setStatusTip (tr( "Hide link" ));
1015 a->setToggleAction(true);
1016 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1017 actionFormatHideLinkUnselected=a;
1019 formatMenu->addSeparator();
1020 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1021 a->setStatusTip (tr( "Use same color for links and headings" ));
1022 a->setToggleAction(true);
1023 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1024 formatMenu->addAction (a);
1025 actionFormatLinkColorHint=a;
1027 pix.fill (Qt::white);
1028 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1029 a->setStatusTip (tr( "Set Link Color" ));
1030 formatMenu->addAction (a);
1031 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1032 actionFormatLinkColor=a;
1034 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1035 a->setStatusTip (tr( "Set Selection Color" ));
1036 formatMenu->addAction (a);
1037 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1038 actionFormatSelectionColor=a;
1040 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1041 a->setStatusTip (tr( "Set Background Color" ));
1042 formatMenu->addAction (a);
1043 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1044 actionFormatBackColor=a;
1046 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1047 a->setStatusTip (tr( "Set Background image" ));
1048 formatMenu->addAction (a);
1049 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1050 actionFormatBackImage=a;
1054 void Main::setupViewActions()
1056 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1057 tb->setLabel( "View Actions" );
1058 tb->setObjectName ("viewTB");
1059 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1062 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1063 a->setStatusTip ( tr( "Zoom reset" ) );
1064 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1066 viewMenu->addAction (a);
1067 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1069 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1070 a->setStatusTip (tr( "Zoom in" ));
1071 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1073 viewMenu->addAction (a);
1074 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1076 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1077 a->setStatusTip (tr( "Zoom out" ));
1078 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1080 viewMenu->addAction (a);
1081 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1083 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1084 a->setStatusTip (tr( "Show selection" ));
1085 a->setShortcut (Qt::Key_Period);
1087 viewMenu->addAction (a);
1088 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1090 viewMenu->addSeparator();
1092 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1093 a->setStatusTip ( tr( "Show Note Editor" ));
1094 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1095 a->setToggleAction(true);
1097 viewMenu->addAction (a);
1098 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1099 actionViewToggleNoteEditor=a;
1101 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1102 a->setStatusTip ( tr( "Show History Window" ));
1103 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1104 a->setToggleAction(true);
1106 viewMenu->addAction (a);
1107 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1108 actionViewToggleHistoryWindow=a;
1110 viewMenu->addAction (actionViewTogglePropertyWindow);
1112 viewMenu->addSeparator();
1114 a = new QAction(tr( "Antialiasing","View action" ),this );
1115 a->setStatusTip ( tr( "Antialiasing" ));
1116 a->setToggleAction(true);
1117 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1118 viewMenu->addAction (a);
1119 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1120 actionViewToggleAntiAlias=a;
1122 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1123 a->setStatusTip (a->text());
1124 a->setToggleAction(true);
1125 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1126 viewMenu->addAction (a);
1127 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1128 actionViewToggleSmoothPixmapTransform=a;
1130 a = new QAction(tr( "Next Map","View action" ), this);
1131 a->setStatusTip (a->text());
1132 a->setShortcut (Qt::ALT + Qt::Key_N );
1133 viewMenu->addAction (a);
1134 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1136 a = new QAction (tr( "Previous Map","View action" ), this );
1137 a->setStatusTip (a->text());
1138 a->setShortcut (Qt::ALT + Qt::Key_P );
1139 viewMenu->addAction (a);
1140 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1144 void Main::setupModeActions()
1146 //QPopupMenu *menu = new QPopupMenu( this );
1147 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1149 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1150 tb->setObjectName ("modesTB");
1152 actionGroupModModes=new QActionGroup ( this);
1153 actionGroupModModes->setExclusive (true);
1154 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1155 a->setShortcut (Qt::Key_J);
1156 a->setStatusTip ( tr( "Use modifier to color branches" ));
1157 a->setToggleAction(true);
1160 actionModModeColor=a;
1162 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1163 a->setShortcut( Qt::Key_K);
1164 a->setStatusTip( tr( "Use modifier to copy" ));
1165 a->setToggleAction(true);
1167 actionModModeCopy=a;
1169 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1170 a->setShortcut (Qt::Key_L);
1171 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1172 a->setToggleAction(true);
1174 actionModModeXLink=a;
1178 void Main::setupFlagActions()
1180 // Create System Flags
1184 systemFlagsDefault = new FlagRowObj ();
1185 systemFlagsDefault->setVisibility (false);
1186 systemFlagsDefault->setName ("systemFlagsDef");
1188 FlagObj *fo = new FlagObj ();
1189 fo->load(QPixmap(flagsPath+"flag-note.png"));
1190 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1192 fo->load(QPixmap(flagsPath+"flag-url.png"));
1193 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1195 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1196 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1198 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1199 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1201 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1202 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1204 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1205 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1207 // Create Standard Flags
1208 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1209 tb->setObjectName ("standardFlagTB");
1211 standardFlagsDefault = new FlagRowObj ();
1212 standardFlagsDefault->setVisibility (false);
1213 standardFlagsDefault->setName ("standardFlagsDef");
1214 standardFlagsDefault->setToolBar (tb);
1216 fo->load(flagsPath+"flag-exclamationmark.png");
1217 fo->setGroup("standard-mark");
1218 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1220 fo->load(flagsPath+"flag-questionmark.png");
1221 fo->setGroup("standard-mark");
1222 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1224 fo->load(flagsPath+"flag-hook-green.png");
1225 fo->setGroup("standard-hook");
1226 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1228 fo->load(flagsPath+"flag-cross-red.png");
1229 fo->setGroup("standard-hook");
1230 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1233 fo->load(flagsPath+"flag-stopsign.png");
1234 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1236 fo->load(flagsPath+"flag-smiley-good.png");
1237 fo->setGroup("standard-smiley");
1238 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1240 fo->load(flagsPath+"flag-smiley-sad.png");
1241 fo->setGroup("standard-smiley");
1242 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1244 fo->load(flagsPath+"flag-smiley-omg.png");
1245 fo->setGroup("standard-smiley");
1246 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1247 // Original omg.png (in KDE emoticons)
1250 fo->load(flagsPath+"flag-kalarm.png");
1251 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1253 fo->load(flagsPath+"flag-phone.png");
1254 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1256 fo->load(flagsPath+"flag-lamp.png");
1257 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1259 fo->load(flagsPath+"flag-arrow-up.png");
1260 fo->setGroup("standard-arrow");
1261 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1263 fo->load(flagsPath+"flag-arrow-down.png");
1264 fo->setGroup("standard-arrow");
1265 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1267 fo->load(flagsPath+"flag-arrow-2up.png");
1268 fo->setGroup("standard-arrow");
1269 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1271 fo->load(flagsPath+"flag-arrow-2down.png");
1272 fo->setGroup("standard-arrow");
1273 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1276 fo->load(flagsPath+"flag-thumb-up.png");
1277 fo->setGroup("standard-thumb");
1278 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1280 fo->load(flagsPath+"flag-thumb-down.png");
1281 fo->setGroup("standard-thumb");
1282 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1285 fo->load(flagsPath+"flag-rose.png");
1286 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1288 fo->load(flagsPath+"flag-heart.png");
1289 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1291 fo->load(flagsPath+"flag-present.png");
1292 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1294 fo->load(flagsPath+"flag-flash.png");
1295 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1297 // Original: xsldbg_output.png
1298 fo->load(flagsPath+"flag-info.png");
1299 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1301 // Original khelpcenter.png
1302 fo->load(flagsPath+"flag-lifebelt.png");
1303 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1309 fo->load(flagsPath+"freemind/warning.png");
1310 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1312 for (int i=1; i<8; i++)
1314 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1315 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1318 fo->load(flagsPath+"freemind/back.png");
1319 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1321 fo->load(flagsPath+"freemind/forward.png");
1322 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1324 fo->load(flagsPath+"freemind/attach.png");
1325 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1327 fo->load(flagsPath+"freemind/clanbomber.png");
1328 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1330 fo->load(flagsPath+"freemind/desktopnew.png");
1331 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1333 fo->load(flagsPath+"freemind/flag.png");
1334 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1337 fo->load(flagsPath+"freemind/gohome.png");
1338 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1341 fo->load(flagsPath+"freemind/kaddressbook.png");
1342 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1344 fo->load(flagsPath+"freemind/knotify.png");
1345 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1347 fo->load(flagsPath+"freemind/korn.png");
1348 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1350 fo->load(flagsPath+"freemind/mail.png");
1351 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1353 fo->load(flagsPath+"freemind/password.png");
1354 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1356 fo->load(flagsPath+"freemind/pencil.png");
1357 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1359 fo->load(flagsPath+"freemind/stop.png");
1360 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1362 fo->load(flagsPath+"freemind/wizard.png");
1363 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1365 fo->load(flagsPath+"freemind/xmag.png");
1366 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1368 fo->load(flagsPath+"freemind/bell.png");
1369 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1371 fo->load(flagsPath+"freemind/bookmark.png");
1372 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1374 fo->load(flagsPath+"freemind/penguin.png");
1375 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1377 fo->load(flagsPath+"freemind/licq.png");
1378 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1383 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1386 fo->setToolTip (tooltip);
1387 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1393 fo->setAlwaysVisible(aw);
1394 a->setCheckable(true);
1395 a->setObjectName(fo->getName());
1396 a->setToolTip(tooltip);
1397 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1398 standardFlagsDefault->addFlag (fo);
1402 systemFlagsDefault->addFlag (fo);
1406 void Main::setupNetworkActions()
1408 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1410 QMenu *netMenu = menuBar()->addMenu( "Network" );
1414 a = new QAction( "Start TCPserver for MapEditor",this);
1415 //a->setStatusTip ( "Set application to open pdf files"));
1416 a->setShortcut ( Qt::Key_T ); //New TCP server
1417 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1418 netMenu->addAction (a);
1420 a = new QAction( "Connect MapEditor to server",this);
1421 //a->setStatusTip ( "Set application to open pdf files"));
1422 a->setShortcut ( Qt::Key_C ); // Connect to server
1423 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1424 netMenu->addAction (a);
1428 void Main::setupSettingsActions()
1430 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1434 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1435 a->setStatusTip ( tr( "Set application to open pdf files"));
1436 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1437 settingsMenu->addAction (a);
1439 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1440 a->setStatusTip( tr( "Set application to open external links"));
1441 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1442 settingsMenu->addAction (a);
1444 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1445 a->setStatusTip( tr( "Set path for macros"));
1446 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1447 settingsMenu->addAction (a);
1449 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1450 a->setStatusTip( tr( "Set number of undo levels"));
1451 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1452 settingsMenu->addAction (a);
1454 settingsMenu->addSeparator();
1456 a = new QAction( tr( "Autosave","Settings action"), this);
1457 a->setStatusTip( tr( "Autosave"));
1458 a->setToggleAction(true);
1459 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1460 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1461 settingsMenu->addAction (a);
1462 actionSettingsAutosaveToggle=a;
1464 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1465 a->setStatusTip( tr( "Autosave time"));
1466 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1467 settingsMenu->addAction (a);
1468 actionSettingsAutosaveTime=a;
1470 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1471 a->setStatusTip( tr( "Write backup file on save"));
1472 a->setToggleAction(true);
1473 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1474 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1475 settingsMenu->addAction (a);
1476 actionSettingsWriteBackupFile=a;
1478 settingsMenu->addSeparator();
1480 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1481 a->setStatusTip( tr( "Edit branch after adding it" ));
1482 a->setToggleAction(true);
1483 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1484 settingsMenu->addAction (a);
1485 actionSettingsAutoEditNewBranch=a;
1487 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1488 a->setStatusTip( tr( "Select branch after adding it" ));
1489 a->setToggleAction(true);
1490 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1491 settingsMenu->addAction (a);
1492 actionSettingsAutoSelectNewBranch=a;
1494 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1495 a->setStatusTip( tr( "Select heading before editing" ));
1496 a->setToggleAction(true);
1497 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1498 settingsMenu->addAction (a);
1499 actionSettingsAutoSelectText=a;
1501 a= new QAction( tr( "Delete key","Settings action" ), this);
1502 a->setStatusTip( tr( "Delete key for deleting branches" ));
1503 a->setToggleAction(true);
1504 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1505 settingsMenu->addAction (a);
1506 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1507 actionSettingsUseDelKey=a;
1509 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1510 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1511 a->setToggleAction(true);
1512 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1513 settingsMenu->addAction (a);
1514 actionSettingsUseFlagGroups=a;
1516 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1517 a->setStatusTip( tr( "Use hide flag during exports " ));
1518 a->setToggleAction(true);
1519 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1520 settingsMenu->addAction (a);
1521 actionSettingsUseHideExport=a;
1523 a = new QAction( tr( "Animation","Settings action"), this);
1524 a->setStatusTip( tr( "Animation"));
1525 a->setToggleAction(true);
1526 a->setOn (settings.value("/animation/use",false).toBool() );
1527 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1528 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1530 settingsMenu->addAction (a);
1532 actionSettingsUseAnimation=a;
1536 void Main::setupTestActions()
1538 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1541 a = new QAction( "Test function 1" , this);
1542 a->setStatusTip( "Call test function 1" );
1543 testMenu->addAction (a);
1544 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1546 a = new QAction( "Test function 2" , this);
1547 a->setStatusTip( "Call test function 2" );
1548 testMenu->addAction (a);
1549 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1551 a = new QAction( "Command" , this);
1552 a->setStatusTip( "Enter command to call in editor" );
1553 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1554 testMenu->addAction (a);
1558 void Main::setupHelpActions()
1560 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1563 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1564 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1565 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1566 helpMenu->addAction (a);
1568 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1569 a->setStatusTip( tr( "Open VYM example maps " ));
1570 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1571 helpMenu->addAction (a);
1573 a = new QAction( tr( "About VYM","Help action" ), this);
1574 a->setStatusTip( tr( "About VYM")+vymName);
1575 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1576 helpMenu->addAction (a);
1578 a = new QAction( tr( "About QT","Help action" ), this);
1579 a->setStatusTip( tr( "Information about QT toolkit" ));
1580 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1581 helpMenu->addAction (a);
1585 void Main::setupContextMenus()
1589 // Context Menu for branch or mapcenter
1590 branchContextMenu =new QMenu (this);
1591 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1592 branchContextMenu->addSeparator();
1595 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1596 branchAddContextMenu->addAction (actionPaste );
1597 branchAddContextMenu->addAction ( actionAddMapCenter );
1598 branchAddContextMenu->addAction ( actionAddBranch );
1599 branchAddContextMenu->addAction ( actionAddBranchBefore );
1600 branchAddContextMenu->addAction ( actionAddBranchAbove);
1601 branchAddContextMenu->addAction ( actionAddBranchBelow );
1602 branchAddContextMenu->addSeparator();
1603 branchAddContextMenu->addAction ( actionImportAdd );
1604 branchAddContextMenu->addAction ( actionImportReplace );
1607 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1608 branchRemoveContextMenu->addAction (actionCut);
1609 branchRemoveContextMenu->addAction ( actionDelete );
1610 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1611 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1614 actionSaveBranch->addTo( branchContextMenu );
1615 actionFileNewCopy->addTo (branchContextMenu );
1617 branchContextMenu->addSeparator();
1618 branchContextMenu->addAction ( actionLoadImage);
1620 // Submenu for Links (URLs, vymLinks)
1621 branchLinksContextMenu =new QMenu (this);
1623 branchContextMenu->addSeparator();
1624 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1625 branchLinksContextMenu->addAction ( actionOpenURL );
1626 branchLinksContextMenu->addAction ( actionOpenURLTab );
1627 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1628 branchLinksContextMenu->addAction ( actionURL );
1629 branchLinksContextMenu->addAction ( actionLocalURL );
1630 branchLinksContextMenu->addAction ( actionHeading2URL );
1631 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1632 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1634 branchLinksContextMenu->addAction ( actionFATE2URL );
1636 branchLinksContextMenu->addSeparator();
1637 branchLinksContextMenu->addAction ( actionOpenVymLink );
1638 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1639 branchLinksContextMenu->addAction ( actionVymLink );
1640 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1643 // Context Menu for XLinks in a branch menu
1644 // This will be populated "on demand" in MapEditor::updateActions
1645 branchContextMenu->addSeparator();
1646 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1647 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1648 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1649 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1652 // Context menu for floatimage
1653 floatimageContextMenu =new QMenu (this);
1654 a= new QAction (tr ("Save image","Context action"),this);
1655 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1656 floatimageContextMenu->addAction (a);
1658 floatimageContextMenu->addSeparator();
1659 actionCopy->addTo( floatimageContextMenu );
1660 actionCut->addTo( floatimageContextMenu );
1662 floatimageContextMenu->addSeparator();
1663 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1666 // Context menu for canvas
1667 canvasContextMenu =new QMenu (this);
1668 actionAddMapCenter->addTo( canvasContextMenu );
1669 actionMapInfo->addTo( canvasContextMenu );
1670 canvasContextMenu->insertSeparator();
1671 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1672 canvasContextMenu->insertSeparator();
1673 actionFormatLinkColorHint->addTo( canvasContextMenu );
1674 actionFormatLinkColor->addTo( canvasContextMenu );
1675 actionFormatSelectionColor->addTo( canvasContextMenu );
1676 actionFormatBackColor->addTo( canvasContextMenu );
1677 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1679 // Menu for last opened files
1681 for (int i = 0; i < MaxRecentFiles; ++i)
1683 recentFileActions[i] = new QAction(this);
1684 recentFileActions[i]->setVisible(false);
1685 fileLastMapsMenu->addAction(recentFileActions[i]);
1686 connect(recentFileActions[i], SIGNAL(triggered()),
1687 this, SLOT(fileLoadRecent()));
1689 setupRecentMapsMenu();
1692 void Main::setupRecentMapsMenu()
1694 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1696 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1698 for (int i = 0; i < numRecentFiles; ++i) {
1699 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1700 recentFileActions[i]->setText(text);
1701 recentFileActions[i]->setData(files[i]);
1702 recentFileActions[i]->setVisible(true);
1704 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1705 recentFileActions[j]->setVisible(false);
1708 void Main::setupMacros()
1710 for (int i = 0; i <= 11; i++)
1712 macroActions[i] = new QAction(this);
1713 macroActions[i]->setData(i);
1714 addAction (macroActions[i]);
1715 connect(macroActions[i], SIGNAL(triggered()),
1716 this, SLOT(callMacro()));
1718 macroActions[0]->setShortcut ( Qt::Key_F1 );
1719 macroActions[1]->setShortcut ( Qt::Key_F2 );
1720 macroActions[2]->setShortcut ( Qt::Key_F3 );
1721 macroActions[3]->setShortcut ( Qt::Key_F4 );
1722 macroActions[4]->setShortcut ( Qt::Key_F5 );
1723 macroActions[5]->setShortcut ( Qt::Key_F6 );
1724 macroActions[6]->setShortcut ( Qt::Key_F7 );
1725 macroActions[7]->setShortcut ( Qt::Key_F8 );
1726 macroActions[8]->setShortcut ( Qt::Key_F9 );
1727 macroActions[9]->setShortcut ( Qt::Key_F10 );
1728 macroActions[10]->setShortcut ( Qt::Key_F11 );
1729 macroActions[11]->setShortcut ( Qt::Key_F12 );
1732 void Main::hideEvent (QHideEvent * )
1734 if (!textEditor->isMinimized() ) textEditor->hide();
1737 void Main::showEvent (QShowEvent * )
1739 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1743 MapEditor* Main::currentMapEditor() const
1745 if ( tabWidget->currentPage())
1746 return tabModel.at(tabWidget->currentIndex())->getMapEditor();
1750 VymModel* Main::currentModel() const
1752 if ( tabWidget->currentPage())
1753 return tabModel.at(tabWidget->currentIndex());
1758 void Main::editorChanged(QWidget *)
1760 // Unselect all possibly selected objects
1761 // (Important to update note editor)
1762 for (int i=0;i<=tabWidget->count() -1;i++)
1764 tabModel.at(i)->unselect();
1766 VymModel *m=currentModel();
1767 if (m) m->reselect();
1769 // Update actions to in menus and toolbars according to editor
1773 VymView *Main::createView (VymModel *model)
1775 VymView *vm=new VymView (model);
1780 void Main::fileNew()
1782 VymModel *m=new VymModel;
1783 tabModel.append (m);
1784 //MapEditor* me = new MapEditor (m);
1785 //me->setObjectName ("MapEditor");
1787 VymView *view=createView (m);
1788 tabWidget->addTab (view,tr("unnamed","MainWindow: name for new and empty file"));
1789 tabWidget->setCurrentIndex (tabModel.count() );
1791 // For the very first map we do not have flagrows yet...
1795 void Main::fileNewCopy()
1797 QString fn="unnamed";
1798 VymModel *srcModel=currentModel();
1803 VymModel *dstModel=tabModel.last ();
1804 dstModel->select("mc:");
1805 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1809 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1811 ErrorCode err=success;
1813 // fn is usually the archive, mapfile the file after uncompressing
1816 // Make fn absolute (needed for unzip)
1817 fn=QDir (fn).absPath();
1823 // Check, if map is already loaded
1825 while (i<=tabWidget->count() -1)
1827 if (tabModel.at(i)->getFilePath() == fn)
1829 // Already there, ask for confirmation
1830 QMessageBox mb( vymName,
1831 tr("The map %1\nis already opened."
1832 "Opening the same map in multiple editors may lead \n"
1833 "to confusion when finishing working with vym."
1834 "Do you want to").arg(fn),
1835 QMessageBox::Warning,
1836 QMessageBox::Yes | QMessageBox::Default,
1837 QMessageBox::Cancel | QMessageBox::Escape,
1838 QMessageBox::NoButton);
1839 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1840 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1843 case QMessageBox::Yes:
1844 // end loop and load anyway
1845 i=tabWidget->count();
1847 case QMessageBox::Cancel:
1857 int tabIndex=tabWidget->currentPageIndex();
1860 if ( !fn.isEmpty() )
1862 vm = currentModel();
1863 // Check first, if mapeditor exists
1864 // If it is not default AND we want a new map,
1865 // create a new mapeditor in a new tab
1866 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1869 tabModel.append (vm);
1870 VymView *view=createView (vm);
1871 tabWidget->addTab (view,fn);
1872 tabIndex=tabWidget->count()-1;
1873 tabWidget->setCurrentPage (tabIndex);
1876 // Check, if file exists (important for creating new files
1877 // from command line
1878 if (!QFile(fn).exists() )
1880 QMessageBox mb( vymName,
1881 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1882 QMessageBox::Question,
1884 QMessageBox::Cancel | QMessageBox::Default,
1885 QMessageBox::NoButton );
1887 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1888 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1891 case QMessageBox::Yes:
1893 currentMapEditor()->getModel()->setFilePath(fn);
1894 tabWidget->setTabText (tabIndex,
1895 currentMapEditor()->getModel()->getFileName() );
1896 statusBar()->message( "Created " + fn , statusbarTime );
1899 case QMessageBox::Cancel:
1900 // don't create new map
1901 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1908 //tabWidget->currentPage() won't be NULL here, because of above...
1909 tabWidget->setCurrentIndex (tabIndex);
1910 //FIXME-3 no me anymore... me->viewport()->setFocus();
1914 // Save existing filename in case we import
1915 QString fn_org=vm->getFilePath();
1917 // Finally load map into mapEditor
1918 vm->setFilePath (fn);
1919 err=vm->load(fn,lmode,ftype);
1921 // Restore old (maybe empty) filepath, if this is an import
1923 vm->setFilePath (fn_org);
1926 // Finally check for errors and go home
1929 if (lmode==NewMap) fileCloseMap();
1930 statusBar()->message( "Could not load " + fn, statusbarTime );
1935 vm->setFilePath (fn);
1936 tabWidget->setTabText (tabIndex, vm->getFileName());
1937 if (!isInTmpDir (fn))
1939 // Only append to lastMaps if not loaded from a tmpDir
1940 // e.g. imported bookmarks are in a tmpDir
1941 addRecentMap(vm->getFilePath() );
1943 actionFilePrint->setEnabled (true);
1945 statusBar()->message( "Loaded " + fn, statusbarTime );
1952 void Main::fileLoad(const LoadMode &lmode)
1954 QStringList filters;
1955 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1956 QFileDialog *fd=new QFileDialog( this);
1957 fd->setDir (lastFileDir);
1958 fd->setFileMode (QFileDialog::ExistingFiles);
1959 fd->setFilters (filters);
1963 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1966 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1969 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1975 if ( fd->exec() == QDialog::Accepted )
1977 lastFileDir=fd->directory().path();
1978 QStringList flist = fd->selectedFiles();
1979 QStringList::Iterator it = flist.begin();
1980 while( it != flist.end() )
1983 fileLoad(*it, lmode);
1990 void Main::fileLoad()
1995 void Main::fileLoadRecent()
1997 QAction *action = qobject_cast<QAction *>(sender());
1999 fileLoad (action->data().toString(), NewMap);
2002 void Main::addRecentMap (const QString &fileName)
2005 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2006 files.removeAll(fileName);
2007 files.prepend(fileName);
2008 while (files.size() > MaxRecentFiles)
2011 settings.setValue("/mainwindow/recentFileList", files);
2013 setupRecentMapsMenu();
2016 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2020 if ( m->getFilePath().isEmpty() )
2022 // We have no filepath yet,
2023 // call fileSaveAs() now, this will call fileSave()
2025 // First switch to editor
2026 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2027 fileSaveAs(savemode);
2030 if (m->save (savemode)==success)
2032 statusBar()->message(
2033 tr("Saved %1").arg(m->getFilePath()),
2035 addRecentMap (m->getFilePath() );
2037 statusBar()->message(
2038 tr("Couldn't save ").arg(m->getFilePath()),
2042 void Main::fileSave()
2044 fileSave (currentModel(), CompleteMap);
2047 void Main::fileSave(VymModel *m)
2049 fileSave (m,CompleteMap);
2052 void Main::fileSaveAs(const SaveMode& savemode)
2056 if (currentMapEditor())
2058 if (savemode==CompleteMap)
2059 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2061 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2062 if ( !fn.isEmpty() )
2064 // Check for existing file
2065 if (QFile (fn).exists())
2067 QMessageBox mb( vymName,
2068 tr("The file %1\nexists already. Do you want to").arg(fn),
2069 QMessageBox::Warning,
2070 QMessageBox::Yes | QMessageBox::Default,
2071 QMessageBox::Cancel | QMessageBox::Escape,
2072 QMessageBox::NoButton);
2073 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2074 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2077 case QMessageBox::Yes:
2080 case QMessageBox::Cancel:
2087 // New file, add extension to filename, if missing
2088 // This is always .vym or .vyp, depending on savemode
2089 if (savemode==CompleteMap)
2091 if (!fn.contains (".vym") && !fn.contains (".xml"))
2095 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2104 VymModel *m=currentModel();
2106 fileSave(m, savemode);
2108 // Set name of tab, assuming current tab is the one we just saved
2109 if (savemode==CompleteMap)
2110 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2116 void Main::fileSaveAs()
2118 fileSaveAs (CompleteMap);
2121 void Main::fileImportKDE3Bookmarks()
2123 ImportKDE3Bookmarks im;
2125 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2126 currentMapEditor()->getModel()->setFilePath ("");
2129 void Main::fileImportKDE4Bookmarks()
2131 ImportKDE4Bookmarks im;
2133 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2134 currentMapEditor()->getModel()->setFilePath ("");
2137 void Main::fileImportFirefoxBookmarks()
2139 Q3FileDialog *fd=new Q3FileDialog( this);
2140 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2141 fd->setMode (Q3FileDialog::ExistingFiles);
2142 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2143 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2146 if ( fd->exec() == QDialog::Accepted )
2148 ImportFirefoxBookmarks im;
2149 QStringList flist = fd->selectedFiles();
2150 QStringList::Iterator it = flist.begin();
2151 while( it != flist.end() )
2154 if (im.transform() &&
2155 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2156 currentMapEditor() )
2157 currentMapEditor()->getModel()->setFilePath ("");
2164 void Main::fileImportFreemind()
2166 QStringList filters;
2167 filters <<"Freemind map (*.mm)"<<"All files (*)";
2168 QFileDialog *fd=new QFileDialog( this);
2169 fd->setDir (lastFileDir);
2170 fd->setFileMode (QFileDialog::ExistingFiles);
2171 fd->setFilters (filters);
2172 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2176 if ( fd->exec() == QDialog::Accepted )
2178 lastFileDir=fd->directory().path();
2179 QStringList flist = fd->selectedFiles();
2180 QStringList::Iterator it = flist.begin();
2181 while( it != flist.end() )
2184 if ( fileLoad (fn,NewMap, FreemindMap) )
2186 currentMapEditor()->getModel()->setFilePath ("");
2195 void Main::fileImportMM()
2199 Q3FileDialog *fd=new Q3FileDialog( this);
2200 fd->setDir (lastFileDir);
2201 fd->setMode (Q3FileDialog::ExistingFiles);
2202 fd->addFilter ("Mind Manager (*.mmap)");
2203 fd->setCaption(tr("Import")+" "+"Mind Manager");
2206 if ( fd->exec() == QDialog::Accepted )
2208 lastFileDir=fd->dirPath();
2209 QStringList flist = fd->selectedFiles();
2210 QStringList::Iterator it = flist.begin();
2211 while( it != flist.end() )
2214 if (im.transform() &&
2215 success==fileLoad (im.getTransformedFile(),NewMap) &&
2216 currentMapEditor() )
2217 currentMapEditor()->getModel()->setFilePath ("");
2224 void Main::fileImportDir()
2226 VymModel *m=currentModel();
2227 if (m) m->importDir();
2230 void Main::fileExportXML()
2232 VymModel *m=currentModel();
2233 if (m) m->exportXML();
2237 void Main::fileExportXHTML()
2239 VymModel *m=currentModel();
2240 if (m) m->exportXHTML();
2243 void Main::fileExportImage()
2245 VymModel *m=currentModel();
2246 if (m) m->exportImage();
2249 void Main::fileExportASCII()
2251 VymModel *m=currentModel();
2252 if (m) m->exportASCII();
2255 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2257 VymModel *m=currentModel();
2262 ex.addFilter ("CSV (*.csv)");
2263 ex.setDir(lastImageDir);
2264 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2265 if (ex.execDialog() )
2267 m->setExportMode(true);
2269 m->setExportMode(false);
2274 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2276 VymModel *m=currentModel();
2281 ex.addFilter ("Tex (*.tex)");
2282 ex.setDir(lastImageDir);
2283 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2284 if (ex.execDialog() )
2286 m->setExportMode(true);
2288 m->setExportMode(false);
2293 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2295 ExportKDE3Bookmarks ex;
2296 VymModel *m=currentModel();
2304 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2306 ExportKDE4Bookmarks ex;
2307 VymModel *m=currentModel();
2315 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2317 ExportTaskjuggler ex;
2318 VymModel *m=currentModel();
2322 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2323 ex.setDir(lastImageDir);
2324 ex.addFilter ("Taskjuggler (*.tjp)");
2325 if (ex.execDialog() )
2327 m->setExportMode(true);
2329 m->setExportMode(false);
2334 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2336 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2337 // TODO add preview in dialog
2338 //ImagePreview *p =new ImagePreview (fd);
2339 //fd->setContentsPreviewEnabled( TRUE );
2340 //fd->setContentsPreview( p, p );
2341 //fd->setPreviewMode( QFileDialog::Contents );
2342 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2343 fd->setDir (QDir().current());
2344 if (fd->foundConfig())
2348 if ( fd->exec() == QDialog::Accepted )
2350 QString fn=fd->selectedFile();
2351 if (!fn.contains (".odp"))
2354 //lastImageDir=fn.left(fn.findRev ("/"));
2355 VymModel *m=currentModel();
2356 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2360 QMessageBox::warning(0,
2362 tr("Couldn't find configuration for export to Open Office\n"));
2366 void Main::fileCloseMap()
2368 MapEditor *me = currentMapEditor();
2369 VymModel *m=currentModel();
2372 if (m->hasChanged())
2374 QMessageBox mb( vymName,
2375 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
2376 QMessageBox::Warning,
2377 QMessageBox::Yes | QMessageBox::Default,
2379 QMessageBox::Cancel | QMessageBox::Escape );
2380 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2381 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2384 case QMessageBox::Yes:
2386 fileSave(m, CompleteMap);
2388 case QMessageBox::No:
2389 // close without saving
2391 case QMessageBox::Cancel:
2396 tabModel.removeAt (tabWidget->currentIndex() );
2397 tabWidget->removeTab (tabWidget->currentIndex() );
2399 // Remove mapEditor;
2400 // Better would be delete (me), but then we could have a Qt error:
2401 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2402 // So we only remove data now and call deconstructor when vym closes later
2403 // FIXME-3 this needs to be moved to vymview... me->clear();
2404 // some model->clear is needed to free up memory ...
2410 void Main::filePrint()
2412 if (currentMapEditor())
2413 currentMapEditor()->print();
2416 void Main::fileExitVYM()
2418 // Check if one or more editors have changed
2420 for (i=0;i<=tabModel.count() -1;i++)
2422 // If something changed, ask what to do
2423 if (tabModel.at(i)->hasChanged())
2425 tabWidget->setCurrentPage(i);
2426 QMessageBox mb( vymName,
2427 tr("This map is not saved yet. Do you want to"),
2428 QMessageBox::Warning,
2429 QMessageBox::Yes | QMessageBox::Default,
2431 QMessageBox::Cancel | QMessageBox::Escape );
2432 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2433 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2436 mb.setActiveWindow();
2437 switch( mb.exec() ) {
2438 case QMessageBox::Yes:
2439 // save (the changed editors) and exit
2440 fileSave(currentModel(), CompleteMap);
2442 case QMessageBox::No:
2443 // exit without saving
2445 case QMessageBox::Cancel:
2446 // don't save and don't exit
2450 } // loop over all MEs
2454 void Main::editUndo()
2456 VymModel *m=currentModel();
2460 void Main::editRedo()
2462 VymModel *m=currentModel();
2466 void Main::gotoHistoryStep (int i)
2468 VymModel *m=currentModel();
2469 if (m) m->gotoHistoryStep(i);
2472 void Main::editCopy()
2474 VymModel *m=currentModel();
2478 void Main::editPaste()
2480 VymModel *m=currentModel();
2484 void Main::editCut()
2486 VymModel *m=currentModel();
2490 void Main::editOpenFindWindow()
2492 findWindow->popup();
2493 findWindow->raise();
2494 findWindow->setActiveWindow();
2497 void Main::editFind(QString s)
2499 VymModel *m=currentModel();
2503 BranchItem *bi=m->findText(s, cs);
2506 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2509 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2510 tr("No matches found for \"%1\"").arg(s));
2515 void Main::editFindChanged()
2516 { // Notify editor, to abort the current find process
2517 VymModel *m=currentModel();
2518 if (m) m->findReset();
2521 void Main::openTabs(QStringList urls)
2523 if (!urls.isEmpty())
2527 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2529 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2531 QString u=urls.takeFirst();
2532 procBrowser = new QProcess( this );
2534 procBrowser->start(browser,args);
2535 if ( !procBrowser->waitForStarted())
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 defined(Q_OS_WIN32)
2545 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2546 this->thread()->wait(3000);
2551 if (browser.contains("konqueror"))
2553 for (int i=0; i<urls.size(); i++)
2556 // Try to open new tab in existing konqueror started previously by vym
2557 p=new QProcess (this);
2559 #if defined(Q_OS_WIN32)
2560 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2561 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2562 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2563 "konqueror-mainwindow#1"<<
2567 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2568 "konqueror-mainwindow#1"<<
2572 p->start ("dcop",args);
2573 if (debug) cout << "MainWindo::openURLs args="<<args.join(" ").toStdString()<<endl;
2574 if ( !p->waitForStarted() ) success=false;
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 p=new QProcess (this);
2587 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2588 p->start (browser,args);
2589 if ( !p->waitForStarted() ) success=false;
2592 QMessageBox::warning(0,
2594 tr("Couldn't start %1 to open a new tab").arg(browser));
2597 QMessageBox::warning(0,
2599 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2603 void Main::editOpenURL()
2606 VymModel *m=currentModel();
2609 QString url=m->getURL();
2611 if (url=="") return;
2612 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2613 procBrowser = new QProcess( this );
2615 procBrowser->start(browser,args);
2616 if ( !procBrowser->waitForStarted())
2618 // try to set path to browser
2619 QMessageBox::warning(0,
2621 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2622 tr("Please use Settings->")+tr("Set application to open an URL"));
2627 void Main::editOpenURLTab()
2629 VymModel *m=currentModel();
2633 urls.append(m->getURL());
2637 void Main::editOpenMultipleURLTabs()
2639 VymModel *m=currentModel();
2649 void Main::editURL()
2651 VymModel *m=currentModel();
2652 if (m) m->editURL();
2655 void Main::editLocalURL()
2657 VymModel *m=currentModel();
2658 if (m) m->editLocalURL();
2661 void Main::editHeading2URL()
2663 VymModel *m=currentModel();
2664 if (m) m->editHeading2URL();
2667 void Main::editBugzilla2URL()
2669 VymModel *m=currentModel();
2670 if (m) m->editBugzilla2URL();
2673 void Main::editFATE2URL()
2675 VymModel *m=currentModel();
2676 if (m) m->editFATE2URL();
2679 void Main::editHeadingFinished(VymModel *m)
2683 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2684 !prevSelection.isEmpty())
2685 m->select(prevSelection);
2691 void Main::editAttributeFinished()
2693 // only called from editHeading(), so there is a currentME
2696 MapEditor *me=currentMapEditor();
2699 me->setStateEditHeading (false);
2700 QPoint p; //Not used here, only to find out pos of branch
2702 QString s=me->getHeading(ok,p);
2704 #if defined(Q_OS_MACX)
2706 if (ok && s!=lineedit->text())
2707 me->setHeading(lineedit->text());
2709 lineedit->releaseKeyboard();
2713 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2714 !prevSelection.isEmpty())
2715 me->select(prevSelection);
2721 #include "attribute.h"
2722 #include "attributedialog.h"
2723 void Main::editAttribute()
2726 MapEditor *me=currentMapEditor();
2729 BranchObj *bo=me->getModel()->getSelectedBranch();
2732 AttributeDialog dia(this);
2733 dia.setTable (me->attributeTable() );
2735 dia.setMode (Definition);
2742 if (currentMapEditor())
2744 MapEditor *me=currentMapEditor();
2745 QString oldSel=me->getSelectString();
2747 if (lineedit->isVisible())
2748 editAttributeFinished();
2753 QString s=me->getHeading(ok,p);
2757 me->setStateEditHeading (true);
2758 #if defined(Q_OS_MACX)
2759 p=me->mapToGlobal (p);
2760 QDialog *d =new QDialog(NULL);
2761 QLineEdit *le=new QLineEdit (d);
2762 d->setWindowFlags (Qt::FramelessWindowHint);
2763 d->setGeometry(p.x(),p.y(),230,25);
2764 le->resize (d->width()-10,d->height());
2767 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2768 d->activateWindow();
2770 me->setHeading (le->text());
2773 editHeadingFinished();
2775 p=me->mapTo (this,p);
2776 lineedit->setGeometry(p.x(),p.y(),230,25);
2777 lineedit->setText(s);
2778 lineedit->setCursorPosition(1);
2779 lineedit->selectAll();
2781 lineedit->grabKeyboard();
2782 lineedit->setFocus();
2786 } // currentMapEditor()
2791 void Main::openVymLinks(const QStringList &vl)
2793 for (int j=0; j<vl.size(); j++)
2795 // compare path with already loaded maps
2798 for (i=0;i<=tabModel.count() -1;i++)
2800 if (vl.at(j)==tabModel.at(i)->getFilePath() )
2809 if (!QFile(vl.at(j)).exists() )
2810 QMessageBox::critical( 0, tr( "Critical Error" ),
2811 tr("Couldn't open map %1").arg(vl.at(j)));
2814 fileLoad (vl.at(j), NewMap);
2815 tabWidget->setCurrentIndex (tabWidget->count()-1);
2818 // Go to tab containing the map
2819 tabWidget->setCurrentIndex (index);
2823 void Main::editOpenVymLink()
2825 VymModel *m=currentModel();
2829 vl.append(m->getVymLink());
2834 void Main::editOpenMultipleVymLinks()
2836 QString currentVymLink;
2837 VymModel *m=currentModel();
2840 QStringList vl=m->getVymLinks();
2845 void Main::editVymLink()
2847 VymModel *m=currentModel();
2852 void Main::editDeleteVymLink()
2854 VymModel *m=currentModel();
2855 if (m) m->deleteVymLink();
2858 void Main::editToggleHideExport()
2860 VymModel *m=currentModel();
2861 if (m) m->toggleHideExport();
2864 void Main::editMapInfo()
2866 VymModel *m=currentModel();
2868 ExtraInfoDialog dia;
2869 dia.setMapName (m->getFileName() );
2870 dia.setAuthor (m->getAuthor() );
2871 dia.setComment(m->getComment() );
2875 /* FIXME-2 no stats at the moment (view dependent...)
2876 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2886 if (!bo->getNote().isEmpty() ) n++;
2887 f+= bo->countFloatImages();
2889 xl+=bo->countXLinks();
2892 stats+=QString ("%1 xLinks \n").arg (xl,6);
2893 stats+=QString ("%1 notes\n").arg (n,6);
2894 stats+=QString ("%1 images\n").arg (f,6);
2896 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2897 dia.setStats (stats);
2899 // Finally show dialog
2900 if (dia.exec() == QDialog::Accepted)
2902 m->setAuthor (dia.getAuthor() );
2903 m->setComment (dia.getComment() );
2907 void Main::editMoveUp()
2909 VymModel *m=currentModel();
2910 if (m) m->moveBranchUp();
2913 void Main::editMoveDown()
2915 VymModel *m=currentModel();
2916 if (m) m->moveBranchDown();
2919 void Main::editSortChildren()
2921 VymModel *m=currentModel();
2922 if (m) m->sortChildren();
2925 void Main::editToggleScroll()
2927 VymModel *m=currentModel();
2928 if (m) m->toggleScroll();
2931 void Main::editUnscrollChildren()
2933 VymModel *m=currentModel();
2934 if (m) m->unscrollChildren();
2937 void Main::editAddMapCenter()
2939 VymModel *m=currentModel();
2942 cout <<"Main::editAddMapCenter\n";
2947 void Main::editNewBranch()
2949 VymModel *m=currentModel();
2952 BranchItem *bi=m->createBranch();
2959 if (actionSettingsAutoEditNewBranch->isOn())
2961 currentMapEditor()->editHeading();
2964 if (!prevSelection.isEmpty())
2966 m->select(prevSelection);
2972 void Main::editNewBranchBefore()
2974 VymModel *m=currentModel();
2977 BranchItem *bi=m->createBranch(); //FIXME-1 missing: m->addNewBranchBefore();
2984 if (actionSettingsAutoEditNewBranch->isOn())
2986 if (!actionSettingsAutoSelectNewBranch->isOn())
2987 prevSelection=m->getSelectString(bi);
2988 currentMapEditor()->editHeading();
2993 void Main::editNewBranchAbove()
2995 VymModel *m=currentModel();
2998 BranchItem *bi=m->createBranch(); //FIXME-1 missing: m->addNewBranch (-1);
3006 if (actionSettingsAutoEditNewBranch->isOn())
3008 if (!actionSettingsAutoSelectNewBranch->isOn())
3009 prevSelection=m->getSelectString (bi);
3010 currentMapEditor()->editHeading();
3015 void Main::editNewBranchBelow()
3017 VymModel *m=currentModel();
3020 BranchItem *bi=m->createBranch();//FIXME-1 *newbo=m->addNewBranch (1);
3027 if (actionSettingsAutoEditNewBranch->isOn())
3029 if (!actionSettingsAutoSelectNewBranch->isOn())
3030 prevSelection=m->getSelectString(bi);
3031 currentMapEditor()->editHeading();
3036 void Main::editImportAdd()
3038 fileLoad (ImportAdd);
3041 void Main::editImportReplace()
3043 fileLoad (ImportReplace);
3046 void Main::editSaveBranch()
3048 fileSaveAs (PartOfMap);
3051 void Main::editDeleteKeepChildren()
3053 VymModel *m=currentModel();
3054 if (m) m->deleteKeepChildren();
3057 void Main::editDeleteChildren()
3059 VymModel *m=currentModel();
3060 if (m) m->deleteChildren();
3063 void Main::editDeleteSelection()
3065 VymModel *m=currentModel();
3066 if (m && actionSettingsUseDelKey->isOn())
3067 m->deleteSelection();
3070 void Main::editUpperBranch()
3072 VymModel *m=currentModel();
3073 if (m) m->selectUpperBranch(); // FIXME-3 check also lower... this probably should go into view...
3076 void Main::editLowerBranch() // FIXME-3 check also lower... this probably should go into view...
3079 VymModel *m=currentModel();
3080 if (m) m->selectLowerBranch();
3083 void Main::editLeftBranch()
3085 VymModel *m=currentModel();
3086 if (m) m->selectLeftBranch();
3089 void Main::editRightBranch()
3091 VymModel *m=currentModel();
3092 if (m) m->selectRightBranch();
3095 void Main::editFirstBranch()
3097 VymModel *m=currentModel();
3098 if (m) m->selectFirstBranch();
3101 void Main::editLastBranch()
3103 VymModel *m=currentModel();
3104 if (m) m->selectLastBranch();
3107 void Main::editLoadImage()
3109 VymModel *m=currentModel();
3110 if (m) m->loadFloatImage();
3113 void Main::editSaveImage()
3115 VymModel *m=currentModel();
3116 if (m) m->saveFloatImage();
3119 void Main::editFollowXLink(QAction *a)
3122 VymModel *m=currentModel();
3124 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3127 void Main::editEditXLink(QAction *a)
3129 VymModel *m=currentModel();
3131 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3134 void Main::formatSelectColor()
3136 QColor col = QColorDialog::getColor((currentColor ), this );
3137 if ( !col.isValid() ) return;
3138 colorChanged( col );
3141 void Main::formatPickColor()
3143 VymModel *m=currentModel();
3145 colorChanged( m->getCurrentHeadingColor() );
3148 void Main::colorChanged(QColor c)
3150 QPixmap pix( 16, 16 );
3152 actionFormatColor->setIconSet( pix );
3156 void Main::formatColorBranch()
3158 VymModel *m=currentModel();
3159 if (m) m->colorBranch(currentColor);
3162 void Main::formatColorSubtree()
3164 VymModel *m=currentModel();
3165 if (m) m->colorSubtree (currentColor);
3168 void Main::formatLinkStyleLine()
3170 VymModel *m=currentModel();
3173 m->setMapLinkStyle("StyleLine");
3174 actionFormatLinkStyleLine->setOn(true);
3178 void Main::formatLinkStyleParabel()
3180 VymModel *m=currentModel();
3183 m->setMapLinkStyle("StyleParabel");
3184 actionFormatLinkStyleParabel->setOn(true);
3188 void Main::formatLinkStylePolyLine()
3190 VymModel *m=currentModel();
3193 m->setMapLinkStyle("StylePolyLine");
3194 actionFormatLinkStylePolyLine->setOn(true);
3198 void Main::formatLinkStylePolyParabel()
3200 VymModel *m=currentModel();
3203 m->setMapLinkStyle("StylePolyParabel");
3204 actionFormatLinkStylePolyParabel->setOn(true);
3208 void Main::formatSelectBackColor()
3210 VymModel *m=currentModel();
3211 if (m) m->selectMapBackgroundColor();
3214 void Main::formatSelectBackImage()
3216 VymModel *m=currentModel();
3218 m->selectMapBackgroundImage();
3221 void Main::formatSelectLinkColor()
3223 VymModel *m=currentModel();
3226 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3227 m->setMapDefLinkColor( col );
3231 void Main::formatSelectSelectionColor()
3233 VymModel *m=currentModel();
3236 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3237 m->setSelectionColor (col);
3242 void Main::formatToggleLinkColorHint()
3244 VymModel *m=currentModel();
3245 if (m) m->toggleMapLinkColorHint();
3249 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3251 VymModel *m=currentModel();
3253 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3256 void Main::viewZoomReset()
3258 if (currentMapEditor())
3262 currentMapEditor()->setMatrix( m );
3266 void Main::viewZoomIn()
3268 if (currentMapEditor())
3270 QMatrix m = currentMapEditor()->matrix();
3271 m.scale( 1.25, 1.25 );
3272 currentMapEditor()->setMatrix( m );
3276 void Main::viewZoomOut()
3278 if (currentMapEditor())
3280 QMatrix m = currentMapEditor()->matrix();
3281 m.scale( 0.8, 0.8 );
3282 currentMapEditor()->setMatrix( m );
3286 void Main::viewCenter()
3288 VymModel *m=currentModel();
3289 if (m) m->ensureSelectionVisible();
3292 void Main::networkStartServer()
3294 VymModel *m=currentModel();
3295 if (m) m->newServer();
3298 void Main::networkConnect()
3300 VymModel *m=currentModel();
3301 if (m) m->connectToServer();
3304 bool Main::settingsPDF()
3306 // Default browser is set in constructor
3308 QString text = QInputDialog::getText(
3309 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3310 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3312 settings.setValue ("/mainwindow/readerPDF",text);
3317 bool Main::settingsURL()
3319 // Default browser is set in constructor
3321 QString text = QInputDialog::getText(
3322 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3323 settings.value("/mainwindow/readerURL").toString()
3326 settings.setValue ("/mainwindow/readerURL",text);
3330 void Main::settingsMacroDir()
3332 QDir defdir(vymBaseDir.path() + "/macros");
3333 if (!defdir.exists())
3335 QDir dir=QFileDialog::getExistingDirectory (
3337 tr ("Directory with vym macros:"),
3338 settings.value ("/macros/macroDir",defdir.path()).toString()
3341 settings.setValue ("/macros/macroDir",dir.absolutePath());
3344 void Main::settingsUndoLevels()
3347 int i = QInputDialog::getInteger(
3349 tr("QInputDialog::getInteger()"),
3350 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3353 settings.setValue ("/mapeditor/stepsTotal",i);
3354 QMessageBox::information( this, tr( "VYM -Information:" ),
3355 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3359 void Main::settingsAutosaveToggle()
3361 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3364 void Main::settingsAutosaveTime()
3367 int i = QInputDialog::getInteger(
3369 tr("QInputDialog::getInteger()"),
3370 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3372 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3375 void Main::settingsWriteBackupFileToggle()
3377 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3380 void Main::settingsToggleAnimation()
3382 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3385 void Main::settingsToggleDelKey()
3387 if (actionSettingsUseDelKey->isOn())
3389 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3392 actionDelete->setAccel (QKeySequence (""));
3396 void Main::windowToggleNoteEditor()
3398 if (textEditor->isVisible() )
3399 windowHideNoteEditor();
3401 windowShowNoteEditor();
3404 void Main::windowToggleHistory()
3406 if (historyWindow->isVisible())
3407 historyWindow->hide();
3409 historyWindow->show();
3413 void Main::windowToggleProperty()
3415 if (branchPropertyWindow->isVisible())
3416 branchPropertyWindow->hide();
3418 branchPropertyWindow->show();
3419 branchPropertyWindow->setModel (currentModel() );
3422 void Main::windowToggleAntiAlias()
3424 bool b=actionViewToggleAntiAlias->isOn();
3426 for (int i=0;i<tabModel.count();i++)
3428 me=tabModel.at(i)->getMapEditor();
3429 if (me) me->setAntiAlias(b);
3434 bool Main::isAliased()
3436 return actionViewToggleAntiAlias->isOn();
3439 bool Main::hasSmoothPixmapTransform()
3441 return actionViewToggleSmoothPixmapTransform->isOn();
3444 void Main::windowToggleSmoothPixmap()
3446 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3448 for (int i=0;i<tabModel.count();i++)
3451 me=tabModel.at(i)->getMapEditor();
3452 if (me) me->setSmoothPixmap(b);
3456 void Main::updateHistory(SimpleSettings &undoSet)
3458 historyWindow->update (undoSet);
3461 void Main::updateNoteFlag()
3463 // this slot is connected to TextEditor::textHasChanged()
3465 VymModel *m=currentModel();
3466 if (m) m->updateNoteFlag();
3469 void Main::updateNoteEditor(QModelIndex index )
3471 TreeItem *ti=((VymModel*)sender())->getItem(index);
3473 cout << "Main::updateNoteEditor model="<<sender();
3474 cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3476 textEditor->setNote (ti->getNoteObj() );
3479 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3481 //branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select()
3483 if (model && model==currentModel() )
3487 if (!oldsel.indexes().isEmpty() )
3489 ti=model->getItem(oldsel.indexes().first());
3490 //cout << "Main::changeSel getting note from "<<ti->getHeading().toStdString()<<": \""<<ti->getNote().toStdString()<<"\""<<endl;
3491 ti->setNoteObj (textEditor->getNoteObj(),false );
3493 if (!newsel.indexes().isEmpty() )
3495 ti=model->getItem(newsel.indexes().first());
3496 if (!ti->getNoteObj().isEmpty() )
3498 //cout << "Main::changeSel setting note of "<<ti->getHeading().toStdString()<<" m=("<<ti->getModel()<<") to \""<<ti->getNote().toStdString()<<"\""<<endl;
3499 textEditor->setNote(ti->getNoteObj() );
3501 textEditor->setNote(NoteObj() );
3503 textEditor->setInactive();
3505 // Show URL and link in statusbar // FIXME-2
3508 QString s=model->getURL();
3509 if (!s.isEmpty() ) status+="URL: "+s+" ";
3510 s=model->getVymLink();
3511 if (!s.isEmpty() ) status+="Link: "+s;
3512 if (!status.isEmpty() ) statusMessage (status);
3515 // Update Toolbar // FIXME-1, was so far in BranchObj
3516 //updateFlagsToolbar();
3522 void Main::updateActions()
3524 VymModel *m =currentModel();
3525 LinkableMapObj *selection;
3529 actionFilePrint->setEnabled (true);
3532 selection=m->getSelectedLMO();
3534 // Link style in context menu
3535 switch (m->getMapLinkStyle())
3537 case LinkableMapObj::Line:
3538 actionFormatLinkStyleLine->setOn(true);
3540 case LinkableMapObj::Parabel:
3541 actionFormatLinkStyleParabel->setOn(true);
3543 case LinkableMapObj::PolyLine:
3544 actionFormatLinkStylePolyLine->setOn(true);
3546 case LinkableMapObj::PolyParabel:
3547 actionFormatLinkStylePolyParabel->setOn(true);
3554 QPixmap pix( 16, 16 );
3555 pix.fill( m->getMapBackgroundColor() );
3556 actionFormatBackColor->setIconSet( pix );
3557 pix.fill( m->getSelectionColor() );
3558 actionFormatSelectionColor->setIconSet( pix );
3559 pix.fill( m->getMapDefLinkColor() );
3560 actionFormatLinkColor->setIconSet( pix );
3563 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3568 actionFilePrint->setEnabled (false);
3574 // updateActions is also called when NoteEditor is closed
3575 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3576 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3577 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3579 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3580 actionFormatLinkColorHint->setOn(true);
3582 actionFormatLinkColorHint->setOn(false);
3585 if (m && m->hasChanged() )
3586 actionFileSave->setEnabled( true);
3588 actionFileSave->setEnabled( true);
3589 if (m && m->isUndoAvailable())
3590 actionUndo->setEnabled( true);
3592 actionUndo->setEnabled( false);
3594 if (m && m->isRedoAvailable())
3595 actionRedo->setEnabled( true);
3597 actionRedo->setEnabled( false);
3599 TreeItem *selti=m->getSelectedItem();
3600 BranchItem *selbi=m->getSelectedBranchItem();
3605 // Take care of links // FIXME-1
3607 if (bo->countXLinks()==0)
3609 branchXLinksContextMenuEdit->clear();
3610 branchXLinksContextMenuFollow->clear();
3615 branchXLinksContextMenuEdit->clear();
3616 branchXLinksContextMenuFollow->clear();
3617 for (int i=0; i<=bo->countXLinks();i++)
3619 bot=bo->XLinkTargetAt(i);
3622 s=bot->getHeading();
3623 if (s.length()>xLinkMenuWidth)
3624 s=s.left(xLinkMenuWidth)+"...";
3625 branchXLinksContextMenuFollow->addAction (s);
3626 branchXLinksContextMenuEdit->addAction (s);
3632 standardFlagsDefault->setEnabled (true);
3634 actionToggleScroll->setEnabled (true);
3635 if ( selbi->isScrolled() )
3636 actionToggleScroll->setOn(true);
3638 actionToggleScroll->setOn(false);
3640 /* FIXME-1 if ( selti->getURL().isEmpty() )
3642 actionOpenURL->setEnabled (false);
3643 actionOpenURLTab->setEnabled (false);
3647 actionOpenURL->setEnabled (true);
3648 actionOpenURLTab->setEnabled (true);
3650 if ( selti->getVymLink().isEmpty() )
3652 actionOpenVymLink->setEnabled (false);
3653 actionDeleteVymLink->setEnabled (false);
3656 actionOpenVymLink->setEnabled (true);
3657 actionDeleteVymLink->setEnabled (true);
3660 /* FIXME-1 if (selbi->canMoveBranchUp())
3661 actionMoveUp->setEnabled (true);
3663 actionMoveUp->setEnabled (false);
3664 if (selbi->canMoveBranchDown())
3665 actionMoveDown->setEnabled (true);
3667 actionMoveDown->setEnabled (false);
3669 actionSortChildren->setEnabled (true);
3671 actionToggleHideExport->setEnabled (true);
3672 actionToggleHideExport->setOn (selbi->hideInExport() );
3674 actionFileSave->setEnabled (true);
3675 actionCopy->setEnabled (true);
3676 actionCut->setEnabled (true);
3677 if (!clipboardEmpty)
3678 actionPaste->setEnabled (true);
3680 actionPaste->setEnabled (false);
3681 for (int i=0; i<actionListBranches.size(); ++i)
3682 actionListBranches.at(i)->setEnabled(true);
3683 actionDelete->setEnabled (true);
3684 actionFormatHideLinkUnselected->setOn
3685 (selection->getHideLinkUnselected());
3687 if ( selti->getType()==TreeItem::Image)
3690 FloatObj *fo=(FloatImageObj*)selection;
3692 actionOpenURL->setEnabled (false);
3693 actionOpenVymLink->setEnabled (false);
3694 actionDeleteVymLink->setEnabled (false);
3695 actionToggleHideExport->setEnabled (true);
3696 actionToggleHideExport->setOn (fo->hideInExport() );
3699 actionCopy->setEnabled (true);
3700 actionCut->setEnabled (true);
3701 actionPaste->setEnabled (false);
3702 for (int i=0; i<actionListBranches.size(); ++i)
3703 actionListBranches.at(i)->setEnabled(false);
3704 actionDelete->setEnabled (true);
3705 actionFormatHideLinkUnselected->setOn
3706 ( selection->getHideLinkUnselected());
3707 actionMoveUp->setEnabled (false);
3708 actionMoveDown->setEnabled (false);
3714 standardFlagsDefault->setEnabled (false);
3715 actionFileSave->setEnabled (false);
3716 actionCopy->setEnabled (false);
3717 actionCut->setEnabled (false);
3718 actionPaste->setEnabled (false);
3719 for (int i=0; i<actionListBranches.size(); ++i)
3720 actionListBranches.at(i)->setEnabled(false);
3722 actionToggleScroll->setEnabled (false);
3723 actionOpenURL->setEnabled (false);
3724 actionOpenVymLink->setEnabled (false);
3725 actionDeleteVymLink->setEnabled (false);
3726 actionHeading2URL->setEnabled (false);
3727 actionDelete->setEnabled (false);
3728 actionMoveUp->setEnabled (false);
3729 actionMoveDown->setEnabled (false);
3730 actionSortChildren->setEnabled (false);
3731 actionToggleHideExport->setEnabled (false);
3735 Main::ModMode Main::getModMode()
3737 if (actionModModeColor->isOn()) return ModModeColor;
3738 if (actionModModeCopy->isOn()) return ModModeCopy;
3739 if (actionModModeXLink->isOn()) return ModModeXLink;
3743 bool Main::autoEditNewBranch()
3745 return actionSettingsAutoEditNewBranch->isOn();
3748 bool Main::autoSelectNewBranch()
3750 return actionSettingsAutoSelectNewBranch->isOn();
3753 bool Main::useFlagGroups()
3755 return actionSettingsUseFlagGroups->isOn();
3758 void Main::windowShowNoteEditor()
3760 textEditor->setShowWithMain(true);
3762 actionViewToggleNoteEditor->setOn (true);
3765 void Main::windowHideNoteEditor()
3767 textEditor->setShowWithMain(false);
3769 actionViewToggleNoteEditor->setOn (false);
3772 void Main::setScript (const QString &script)
3774 scriptEditor->setScript (script);
3777 void Main::runScript (const QString &script)
3779 VymModel *m=currentModel();
3780 if (m) m->runScript (script);
3783 void Main::runScriptEverywhere (const QString &script)
3786 for (int i=0;i<=tabWidget->count() -1;i++)
3788 me=(MapEditor*)tabWidget->page(i);
3789 if (me) me->getModel()->runScript (script);
3793 void Main::windowNextEditor()
3795 if (tabWidget->currentIndex() < tabWidget->count())
3796 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3799 void Main::windowPreviousEditor()
3801 if (tabWidget->currentIndex() >0)
3802 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3805 void Main::standardFlagChanged()
3807 if (currentMapEditor())
3808 currentMapEditor()->toggleStandardFlag(sender()->name());
3811 void Main::testFunction1()
3813 //if (!currentMapEditor()) return;
3814 //currentMapEditor()->testFunction1();
3818 void Main::testFunction2()
3820 if (!currentMapEditor()) return;
3821 currentMapEditor()->testFunction2();
3824 void Main::testCommand()
3826 if (!currentMapEditor()) return;
3827 scriptEditor->show();
3830 QString com = QInputDialog::getText(
3831 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3832 if (ok) currentMapEditor()->parseAtom(com);
3836 void Main::helpDoc()
3838 QString locale = QLocale::system().name();
3840 if (locale.left(2)=="es")
3841 docname="vym_es.pdf";
3845 QStringList searchList;
3847 #if defined(Q_OS_MACX)
3848 searchList << "./vym.app/Contents/Resources/doc";
3849 #elif defined(Q_OS_WIN32)
3850 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3852 #if defined(VYM_DOCDIR)
3853 searchList << VYM_DOCDIR;
3855 // default path in SUSE LINUX
3856 searchList << "/usr/share/doc/packages/vym";
3859 searchList << "doc"; // relative path for easy testing in tarball
3860 searchList << "doc/tex"; // Easy testing working on vym.tex
3861 searchList << "/usr/share/doc/vym"; // Debian
3862 searchList << "/usr/share/doc/packages";// Knoppix
3866 for (int i=0; i<searchList.count(); ++i)
3868 docfile.setFileName(searchList.at(i)+"/"+docname);
3869 if (docfile.exists())
3878 QMessageBox::critical(0,
3879 tr("Critcal error"),
3880 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3885 Process *pdfProc = new Process();
3886 args << QDir::toNativeSeparators(docfile.fileName());
3888 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3889 if ( !pdfProc->waitForStarted() )
3892 QMessageBox::warning(0,
3894 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3895 tr("Please use Settings->")+tr("Set application to open PDF files"));
3902 void Main::helpDemo()
3904 QStringList filters;
3905 filters <<"VYM example map (*.vym)";
3906 QFileDialog *fd=new QFileDialog( this);
3907 #if defined(Q_OS_MACX)
3908 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3910 // default path in SUSE LINUX
3911 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3914 fd->setFileMode (QFileDialog::ExistingFiles);
3915 fd->setFilters (filters);
3916 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3920 if ( fd->exec() == QDialog::Accepted )
3922 lastFileDir=fd->directory().path();
3923 QStringList flist = fd->selectedFiles();
3924 QStringList::Iterator it = flist.begin();
3925 while( it != flist.end() )
3928 fileLoad(*it, NewMap);
3936 void Main::helpAbout()
3939 ad.setName ("aboutwindow");
3940 ad.setMinimumSize(500,500);
3941 ad.resize (QSize (500,500));
3945 void Main::helpAboutQT()
3947 QMessageBox::aboutQt( this, "Qt Application Example" );
3950 void Main::callMacro ()
3952 QAction *action = qobject_cast<QAction *>(sender());
3956 i=action->data().toInt();
3957 QString mDir (settings.value ("macros/macroDir").toString() );
3959 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3961 if ( !f.open( QIODevice::ReadOnly ) )
3963 QMessageBox::warning(0,
3965 tr("Couldn't find a macro at %1.\n").arg(fn)+
3966 tr("Please use Settings->")+tr("Set directory for vym macros"));
3970 QTextStream ts( &f );
3971 QString macro= ts.read();
3973 if (! macro.isEmpty())
3975 VymModel *m=currentModel();
3976 if (m) m->runScript(macro);