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 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
693 alt->setShortcut ( Qt::Key_S ); // Scroll branch
694 alt->setStatusTip (tr( "Scroll branch" ));
695 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
696 #if defined(Q_OS_MACX)
697 actionToggleScroll=alt;
699 actionToggleScroll=a;
701 actionToggleScroll->setEnabled (false);
702 actionToggleScroll->setToggleAction(true);
703 tb->addAction (actionToggleScroll);
704 editMenu->addAction ( actionToggleScroll);
705 editMenu->addAction (actionToggleScroll);
708 actionListBranches.append(actionToggleScroll);
710 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
711 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
712 a->setStatusTip (tr( "Expand all branches" ));
713 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
715 actionExpandAll->setEnabled (false);
716 actionExpandAll->setToggleAction(false);
717 //tb->addAction (actionExpandAll);
718 editMenu->addAction ( actionExpandAll);
720 actionListBranches.append(actionExpandAll);
723 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
724 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
725 editMenu->addAction (a);
726 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
728 editMenu->addSeparator();
730 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
731 a->setStatusTip (tr( "Find" ) );
732 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
733 editMenu->addAction (a);
734 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
736 editMenu->addSeparator();
738 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
739 a->setShortcut (Qt::CTRL + Qt::Key_U );
740 a->setShortcut (tr( "Open URL" ));
743 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
746 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
747 a->setStatusTip (tr( "Open URL in new tab" ));
748 //a->setShortcut (Qt::CTRL+Qt::Key_U );
750 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
753 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
754 a->setStatusTip (tr( "Open all URLs in subtree" ));
756 actionListBranches.append(a);
757 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
758 actionOpenMultipleURLTabs=a;
760 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
761 a->setStatusTip ( tr( "Edit URL" ) );
762 a->setShortcut ( Qt::Key_U );
763 a->setShortcutContext (Qt::WindowShortcut);
764 actionListBranches.append(a);
766 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
769 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
770 a->setStatusTip ( tr( "Edit local URL" ) );
771 a->setShortcut (Qt::SHIFT + Qt::Key_U );
772 a->setShortcutContext (Qt::WindowShortcut);
773 actionListBranches.append(a);
775 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
778 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
779 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
780 a->setEnabled (false);
781 actionListBranches.append(a);
782 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
785 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
786 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
787 a->setEnabled (false);
788 actionListBranches.append(a);
789 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
790 actionBugzilla2URL=a;
792 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
793 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
794 a->setEnabled (false);
795 actionListBranches.append(a);
796 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
799 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
800 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
802 a->setEnabled (false);
803 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
806 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
807 a->setStatusTip ( tr( "Open all vym links in subtree" ));
808 a->setEnabled (false);
809 actionListBranches.append(a);
810 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
811 actionOpenMultipleVymLinks=a;
814 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
815 a->setEnabled (false);
816 a->setStatusTip ( tr( "Edit link to another vym map" ));
817 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
818 actionListBranches.append(a);
821 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
822 a->setStatusTip ( tr( "Delete link to another vym map" ));
823 a->setEnabled (false);
824 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
825 actionDeleteVymLink=a;
827 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
828 a->setStatusTip ( tr( "Hide object in exports" ) );
829 a->setShortcut (Qt::Key_H );
830 a->setToggleAction(true);
832 a->setEnabled (false);
833 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
834 actionToggleHideExport=a;
836 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
837 a->setStatusTip ( tr( "Edit Map Info" ));
838 a->setEnabled (true);
839 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
842 // Import at selection (adding to selection)
843 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
844 a->setStatusTip (tr( "Add map at selection" ));
845 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
846 a->setEnabled (false);
847 actionListBranches.append(a);
850 // Import at selection (replacing selection)
851 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
852 a->setStatusTip (tr( "Replace selection with map" ));
853 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
854 a->setEnabled (false);
855 actionListBranches.append(a);
856 actionImportReplace=a;
859 a = new QAction( tr( "Save selection","Edit menu" ), this);
860 a->setStatusTip (tr( "Save selection" ));
861 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
862 a->setEnabled (false);
863 actionListBranches.append(a);
866 // Only remove branch, not its children
867 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
868 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
869 a->setShortcut (Qt::ALT + Qt::Key_Delete );
870 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
871 a->setEnabled (false);
873 actionListBranches.append(a);
874 actionDeleteKeepChildren=a;
876 // Only remove children of a branch
877 a = new QAction( tr( "Remove children","Edit menu" ), this);
878 a->setStatusTip (tr( "Remove children of branch" ));
879 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
880 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
881 a->setEnabled (false);
882 actionListBranches.append(a);
883 actionDeleteChildren=a;
885 // Shortcuts for navigating with cursor:
886 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
887 a->setStatusTip ( tr( "Select upper branch" ));
888 a->setShortcut (Qt::Key_Up );
889 a->setShortcutContext (Qt::WindowShortcut);
891 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
892 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
893 a->setStatusTip (tr( "Select lower branch" ));
894 a->setShortcut ( Qt::Key_Down );
895 a->setShortcutContext (Qt::WindowShortcut);
897 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
898 a = new QAction(tr( "Select left branch","Edit menu" ), this);
899 a->setStatusTip ( tr( "Select left branch" ));
900 a->setShortcut (Qt::Key_Left );
901 a->setShortcutContext (Qt::WindowShortcut);
903 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
904 a = new QAction( tr( "Select child branch","Edit menu" ), this);
905 a->setStatusTip (tr( "Select right branch" ));
906 a->setShortcut (Qt::Key_Right);
907 a->setShortcutContext (Qt::WindowShortcut);
909 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
910 a = new QAction( tr( "Select first branch","Edit menu" ), this);
911 a->setStatusTip (tr( "Select first branch" ));
912 a->setShortcut (Qt::Key_Home );
913 a->setShortcutContext (Qt::WindowShortcut);
915 a->setEnabled (false);
916 editMenu->addAction (a);
917 actionListBranches.append(a);
919 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
920 a = new QAction( tr( "Select last branch","Edit menu" ),this);
921 a->setStatusTip (tr( "Select last branch" ));
922 a->setShortcut ( Qt::Key_End );
923 a->setShortcutContext (Qt::WindowShortcut);
925 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
926 a->setEnabled (false);
927 editMenu->addAction (a);
928 actionListBranches.append(a);
931 a = new QAction( tr( "Add Image...","Edit menu" ), this);
932 a->setStatusTip (tr( "Add Image" ));
933 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
936 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
937 a->setStatusTip (tr( "Set properties for selection" ));
938 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
939 a->setShortcutContext (Qt::WindowShortcut);
940 a->setToggleAction (true);
942 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
943 actionViewTogglePropertyWindow=a;
947 void Main::setupFormatActions()
949 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
951 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
952 tb->setObjectName ("formatTB");
955 pix.fill (Qt::black);
956 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
957 a->setStatusTip ( tr( "Set Color" ));
958 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
960 formatMenu->addAction (a);
962 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
963 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
964 a->setShortcut (Qt::CTRL + Qt::Key_K );
965 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
966 a->setEnabled (false);
968 formatMenu->addAction (a);
969 actionListBranches.append(a);
970 actionFormatPickColor=a;
972 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
973 a->setStatusTip ( tr( "Color branch" ) );
974 a->setShortcut (Qt::CTRL + Qt::Key_B);
975 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
976 a->setEnabled (false);
978 formatMenu->addAction (a);
979 actionListBranches.append(a);
980 actionFormatColorSubtree=a;
982 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
983 a->setStatusTip ( tr( "Color Subtree" ));
984 a->setShortcut (Qt::CTRL + Qt::Key_T);
985 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
986 a->setEnabled (false);
987 formatMenu->addAction (a);
989 actionListBranches.append(a);
990 actionFormatColorSubtree=a;
992 formatMenu->addSeparator();
993 actionGroupFormatLinkStyles=new QActionGroup ( this);
994 actionGroupFormatLinkStyles->setExclusive (true);
995 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
996 a->setStatusTip (tr( "Line" ));
997 a->setToggleAction(true);
998 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
999 formatMenu->addAction (a);
1000 actionFormatLinkStyleLine=a;
1001 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1002 a->setStatusTip (tr( "Line" ));
1003 a->setToggleAction(true);
1004 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1005 formatMenu->addAction (a);
1006 actionFormatLinkStyleParabel=a;
1007 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1008 a->setStatusTip (tr( "PolyLine" ));
1009 a->setToggleAction(true);
1010 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1011 formatMenu->addAction (a);
1012 actionFormatLinkStylePolyLine=a;
1013 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1014 a->setStatusTip (tr( "PolyParabel" ) );
1015 a->setToggleAction(true);
1016 a->setChecked (true);
1017 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1018 formatMenu->addAction (a);
1019 actionFormatLinkStylePolyParabel=a;
1021 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1022 a->setStatusTip (tr( "Hide link" ));
1023 a->setToggleAction(true);
1024 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1025 actionFormatHideLinkUnselected=a;
1027 formatMenu->addSeparator();
1028 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1029 a->setStatusTip (tr( "Use same color for links and headings" ));
1030 a->setToggleAction(true);
1031 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1032 formatMenu->addAction (a);
1033 actionFormatLinkColorHint=a;
1035 pix.fill (Qt::white);
1036 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1037 a->setStatusTip (tr( "Set Link Color" ));
1038 formatMenu->addAction (a);
1039 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1040 actionFormatLinkColor=a;
1042 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1043 a->setStatusTip (tr( "Set Selection Color" ));
1044 formatMenu->addAction (a);
1045 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1046 actionFormatSelectionColor=a;
1048 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1049 a->setStatusTip (tr( "Set Background Color" ));
1050 formatMenu->addAction (a);
1051 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1052 actionFormatBackColor=a;
1054 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1055 a->setStatusTip (tr( "Set Background image" ));
1056 formatMenu->addAction (a);
1057 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1058 actionFormatBackImage=a;
1062 void Main::setupViewActions()
1064 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1065 tb->setLabel( "View Actions" );
1066 tb->setObjectName ("viewTB");
1067 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1070 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1071 a->setStatusTip ( tr( "Zoom reset" ) );
1072 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1074 viewMenu->addAction (a);
1075 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1077 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1078 a->setStatusTip (tr( "Zoom in" ));
1079 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1081 viewMenu->addAction (a);
1082 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1084 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1085 a->setStatusTip (tr( "Zoom out" ));
1086 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1088 viewMenu->addAction (a);
1089 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1091 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1092 a->setStatusTip (tr( "Show selection" ));
1093 a->setShortcut (Qt::Key_Period);
1095 viewMenu->addAction (a);
1096 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1098 viewMenu->addSeparator();
1100 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1101 a->setStatusTip ( tr( "Show Note Editor" ));
1102 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1103 a->setToggleAction(true);
1105 viewMenu->addAction (a);
1106 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1107 actionViewToggleNoteEditor=a;
1109 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1110 a->setStatusTip ( tr( "Show History Window" ));
1111 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1112 a->setToggleAction(true);
1114 viewMenu->addAction (a);
1115 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1116 actionViewToggleHistoryWindow=a;
1118 viewMenu->addAction (actionViewTogglePropertyWindow);
1120 viewMenu->addSeparator();
1122 a = new QAction(tr( "Antialiasing","View action" ),this );
1123 a->setStatusTip ( tr( "Antialiasing" ));
1124 a->setToggleAction(true);
1125 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1126 viewMenu->addAction (a);
1127 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1128 actionViewToggleAntiAlias=a;
1130 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1131 a->setStatusTip (a->text());
1132 a->setToggleAction(true);
1133 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1134 viewMenu->addAction (a);
1135 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1136 actionViewToggleSmoothPixmapTransform=a;
1138 a = new QAction(tr( "Next Map","View action" ), this);
1139 a->setStatusTip (a->text());
1140 a->setShortcut (Qt::ALT + Qt::Key_N );
1141 viewMenu->addAction (a);
1142 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1144 a = new QAction (tr( "Previous Map","View action" ), this );
1145 a->setStatusTip (a->text());
1146 a->setShortcut (Qt::ALT + Qt::Key_P );
1147 viewMenu->addAction (a);
1148 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1152 void Main::setupModeActions()
1154 //QPopupMenu *menu = new QPopupMenu( this );
1155 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1157 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1158 tb->setObjectName ("modesTB");
1160 actionGroupModModes=new QActionGroup ( this);
1161 actionGroupModModes->setExclusive (true);
1162 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1163 a->setShortcut (Qt::Key_J);
1164 a->setStatusTip ( tr( "Use modifier to color branches" ));
1165 a->setToggleAction(true);
1168 actionModModeColor=a;
1170 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1171 a->setShortcut( Qt::Key_K);
1172 a->setStatusTip( tr( "Use modifier to copy" ));
1173 a->setToggleAction(true);
1175 actionModModeCopy=a;
1177 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1178 a->setShortcut (Qt::Key_L);
1179 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1180 a->setToggleAction(true);
1182 actionModModeXLink=a;
1186 void Main::setupFlagActions()
1188 // Create System Flags
1192 systemFlagsDefault = new FlagRowObj ();
1193 systemFlagsDefault->setVisibility (false);
1194 systemFlagsDefault->setName ("systemFlagsDef");
1196 FlagObj *fo = new FlagObj ();
1197 fo->load(QPixmap(flagsPath+"flag-note.png"));
1198 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1200 fo->load(QPixmap(flagsPath+"flag-url.png"));
1201 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1203 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1204 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1206 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1207 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1209 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1210 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1212 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1213 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1215 // Create Standard Flags
1216 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1217 tb->setObjectName ("standardFlagTB");
1219 standardFlagsDefault = new FlagRowObj ();
1220 standardFlagsDefault->setVisibility (false);
1221 standardFlagsDefault->setName ("standardFlagsDef");
1222 standardFlagsDefault->setToolBar (tb);
1224 fo->load(flagsPath+"flag-exclamationmark.png");
1225 fo->setGroup("standard-mark");
1226 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1228 fo->load(flagsPath+"flag-questionmark.png");
1229 fo->setGroup("standard-mark");
1230 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1232 fo->load(flagsPath+"flag-hook-green.png");
1233 fo->setGroup("standard-hook");
1234 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1236 fo->load(flagsPath+"flag-cross-red.png");
1237 fo->setGroup("standard-hook");
1238 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1241 fo->load(flagsPath+"flag-stopsign.png");
1242 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1244 fo->load(flagsPath+"flag-smiley-good.png");
1245 fo->setGroup("standard-smiley");
1246 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1248 fo->load(flagsPath+"flag-smiley-sad.png");
1249 fo->setGroup("standard-smiley");
1250 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1252 fo->load(flagsPath+"flag-smiley-omg.png");
1253 fo->setGroup("standard-smiley");
1254 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1255 // Original omg.png (in KDE emoticons)
1258 fo->load(flagsPath+"flag-kalarm.png");
1259 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1261 fo->load(flagsPath+"flag-phone.png");
1262 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1264 fo->load(flagsPath+"flag-lamp.png");
1265 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1267 fo->load(flagsPath+"flag-arrow-up.png");
1268 fo->setGroup("standard-arrow");
1269 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1271 fo->load(flagsPath+"flag-arrow-down.png");
1272 fo->setGroup("standard-arrow");
1273 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1275 fo->load(flagsPath+"flag-arrow-2up.png");
1276 fo->setGroup("standard-arrow");
1277 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1279 fo->load(flagsPath+"flag-arrow-2down.png");
1280 fo->setGroup("standard-arrow");
1281 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1284 fo->load(flagsPath+"flag-thumb-up.png");
1285 fo->setGroup("standard-thumb");
1286 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1288 fo->load(flagsPath+"flag-thumb-down.png");
1289 fo->setGroup("standard-thumb");
1290 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1293 fo->load(flagsPath+"flag-rose.png");
1294 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1296 fo->load(flagsPath+"flag-heart.png");
1297 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1299 fo->load(flagsPath+"flag-present.png");
1300 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1302 fo->load(flagsPath+"flag-flash.png");
1303 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1305 // Original: xsldbg_output.png
1306 fo->load(flagsPath+"flag-info.png");
1307 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1309 // Original khelpcenter.png
1310 fo->load(flagsPath+"flag-lifebelt.png");
1311 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1317 fo->load(flagsPath+"freemind/warning.png");
1318 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1320 for (int i=1; i<8; i++)
1322 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1323 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1326 fo->load(flagsPath+"freemind/back.png");
1327 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1329 fo->load(flagsPath+"freemind/forward.png");
1330 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1332 fo->load(flagsPath+"freemind/attach.png");
1333 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1335 fo->load(flagsPath+"freemind/clanbomber.png");
1336 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1338 fo->load(flagsPath+"freemind/desktopnew.png");
1339 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1341 fo->load(flagsPath+"freemind/flag.png");
1342 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1345 fo->load(flagsPath+"freemind/gohome.png");
1346 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1349 fo->load(flagsPath+"freemind/kaddressbook.png");
1350 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1352 fo->load(flagsPath+"freemind/knotify.png");
1353 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1355 fo->load(flagsPath+"freemind/korn.png");
1356 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1358 fo->load(flagsPath+"freemind/mail.png");
1359 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1361 fo->load(flagsPath+"freemind/password.png");
1362 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1364 fo->load(flagsPath+"freemind/pencil.png");
1365 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1367 fo->load(flagsPath+"freemind/stop.png");
1368 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1370 fo->load(flagsPath+"freemind/wizard.png");
1371 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1373 fo->load(flagsPath+"freemind/xmag.png");
1374 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1376 fo->load(flagsPath+"freemind/bell.png");
1377 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1379 fo->load(flagsPath+"freemind/bookmark.png");
1380 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1382 fo->load(flagsPath+"freemind/penguin.png");
1383 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1385 fo->load(flagsPath+"freemind/licq.png");
1386 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1391 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1394 fo->setToolTip (tooltip);
1395 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1401 fo->setAlwaysVisible(aw);
1402 a->setCheckable(true);
1403 a->setObjectName(fo->getName());
1404 a->setToolTip(tooltip);
1405 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1406 standardFlagsDefault->addFlag (fo);
1410 systemFlagsDefault->addFlag (fo);
1414 void Main::setupNetworkActions()
1416 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1418 QMenu *netMenu = menuBar()->addMenu( "Network" );
1422 a = new QAction( "Start TCPserver for MapEditor",this);
1423 //a->setStatusTip ( "Set application to open pdf files"));
1424 a->setShortcut ( Qt::Key_T ); //New TCP server
1425 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1426 netMenu->addAction (a);
1428 a = new QAction( "Connect MapEditor to server",this);
1429 //a->setStatusTip ( "Set application to open pdf files"));
1430 a->setShortcut ( Qt::Key_C ); // Connect to server
1431 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1432 netMenu->addAction (a);
1436 void Main::setupSettingsActions()
1438 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1442 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1443 a->setStatusTip ( tr( "Set application to open pdf files"));
1444 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1445 settingsMenu->addAction (a);
1447 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1448 a->setStatusTip( tr( "Set application to open external links"));
1449 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1450 settingsMenu->addAction (a);
1452 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1453 a->setStatusTip( tr( "Set path for macros"));
1454 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1455 settingsMenu->addAction (a);
1457 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1458 a->setStatusTip( tr( "Set number of undo levels"));
1459 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1460 settingsMenu->addAction (a);
1462 settingsMenu->addSeparator();
1464 a = new QAction( tr( "Autosave","Settings action"), this);
1465 a->setStatusTip( tr( "Autosave"));
1466 a->setToggleAction(true);
1467 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1468 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1469 settingsMenu->addAction (a);
1470 actionSettingsAutosaveToggle=a;
1472 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1473 a->setStatusTip( tr( "Autosave time"));
1474 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1475 settingsMenu->addAction (a);
1476 actionSettingsAutosaveTime=a;
1478 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1479 a->setStatusTip( tr( "Write backup file on save"));
1480 a->setToggleAction(true);
1481 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1482 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1483 settingsMenu->addAction (a);
1484 actionSettingsWriteBackupFile=a;
1486 settingsMenu->addSeparator();
1488 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1489 a->setStatusTip( tr( "Edit branch after adding it" ));
1490 a->setToggleAction(true);
1491 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1492 settingsMenu->addAction (a);
1493 actionSettingsAutoEditNewBranch=a;
1495 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1496 a->setStatusTip( tr( "Select branch after adding it" ));
1497 a->setToggleAction(true);
1498 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1499 settingsMenu->addAction (a);
1500 actionSettingsAutoSelectNewBranch=a;
1502 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1503 a->setStatusTip( tr( "Select heading before editing" ));
1504 a->setToggleAction(true);
1505 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1506 settingsMenu->addAction (a);
1507 actionSettingsAutoSelectText=a;
1509 a= new QAction( tr( "Delete key","Settings action" ), this);
1510 a->setStatusTip( tr( "Delete key for deleting branches" ));
1511 a->setToggleAction(true);
1512 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1513 settingsMenu->addAction (a);
1514 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1515 actionSettingsUseDelKey=a;
1517 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1518 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1519 a->setToggleAction(true);
1520 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1521 settingsMenu->addAction (a);
1522 actionSettingsUseFlagGroups=a;
1524 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1525 a->setStatusTip( tr( "Use hide flag during exports " ));
1526 a->setToggleAction(true);
1527 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1528 settingsMenu->addAction (a);
1529 actionSettingsUseHideExport=a;
1531 a = new QAction( tr( "Animation","Settings action"), this);
1532 a->setStatusTip( tr( "Animation"));
1533 a->setToggleAction(true);
1534 a->setOn (settings.value("/animation/use",false).toBool() );
1535 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1536 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1538 settingsMenu->addAction (a);
1540 actionSettingsUseAnimation=a;
1544 void Main::setupTestActions()
1546 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1549 a = new QAction( "Test function 1" , this);
1550 a->setStatusTip( "Call test function 1" );
1551 testMenu->addAction (a);
1552 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1554 a = new QAction( "Test function 2" , this);
1555 a->setStatusTip( "Call test function 2" );
1556 testMenu->addAction (a);
1557 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1559 a = new QAction( "Command" , this);
1560 a->setStatusTip( "Enter command to call in editor" );
1561 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1562 testMenu->addAction (a);
1566 void Main::setupHelpActions()
1568 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1571 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1572 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1573 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1574 helpMenu->addAction (a);
1576 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1577 a->setStatusTip( tr( "Open VYM example maps " ));
1578 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1579 helpMenu->addAction (a);
1581 a = new QAction( tr( "About VYM","Help action" ), this);
1582 a->setStatusTip( tr( "About VYM")+vymName);
1583 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1584 helpMenu->addAction (a);
1586 a = new QAction( tr( "About QT","Help action" ), this);
1587 a->setStatusTip( tr( "Information about QT toolkit" ));
1588 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1589 helpMenu->addAction (a);
1593 void Main::setupContextMenus()
1597 // Context Menu for branch or mapcenter
1598 branchContextMenu =new QMenu (this);
1599 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1600 branchContextMenu->addSeparator();
1603 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1604 branchAddContextMenu->addAction (actionPaste );
1605 branchAddContextMenu->addAction ( actionAddMapCenter );
1606 branchAddContextMenu->addAction ( actionAddBranch );
1607 branchAddContextMenu->addAction ( actionAddBranchBefore );
1608 branchAddContextMenu->addAction ( actionAddBranchAbove);
1609 branchAddContextMenu->addAction ( actionAddBranchBelow );
1610 branchAddContextMenu->addSeparator();
1611 branchAddContextMenu->addAction ( actionImportAdd );
1612 branchAddContextMenu->addAction ( actionImportReplace );
1615 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1616 branchRemoveContextMenu->addAction (actionCut);
1617 branchRemoveContextMenu->addAction ( actionDelete );
1618 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1619 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1622 actionSaveBranch->addTo( branchContextMenu );
1623 actionFileNewCopy->addTo (branchContextMenu );
1625 branchContextMenu->addSeparator();
1626 branchContextMenu->addAction ( actionLoadImage);
1628 // Submenu for Links (URLs, vymLinks)
1629 branchLinksContextMenu =new QMenu (this);
1631 branchContextMenu->addSeparator();
1632 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1633 branchLinksContextMenu->addAction ( actionOpenURL );
1634 branchLinksContextMenu->addAction ( actionOpenURLTab );
1635 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1636 branchLinksContextMenu->addAction ( actionURL );
1637 branchLinksContextMenu->addAction ( actionLocalURL );
1638 branchLinksContextMenu->addAction ( actionHeading2URL );
1639 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1640 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1642 branchLinksContextMenu->addAction ( actionFATE2URL );
1644 branchLinksContextMenu->addSeparator();
1645 branchLinksContextMenu->addAction ( actionOpenVymLink );
1646 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1647 branchLinksContextMenu->addAction ( actionVymLink );
1648 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1651 // Context Menu for XLinks in a branch menu
1652 // This will be populated "on demand" in MapEditor::updateActions
1653 branchContextMenu->addSeparator();
1654 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1655 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1656 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1657 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1660 // Context menu for floatimage
1661 floatimageContextMenu =new QMenu (this);
1662 a= new QAction (tr ("Save image","Context action"),this);
1663 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1664 floatimageContextMenu->addAction (a);
1666 floatimageContextMenu->addSeparator();
1667 actionCopy->addTo( floatimageContextMenu );
1668 actionCut->addTo( floatimageContextMenu );
1670 floatimageContextMenu->addSeparator();
1671 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1674 // Context menu for canvas
1675 canvasContextMenu =new QMenu (this);
1676 actionAddMapCenter->addTo( canvasContextMenu );
1677 actionMapInfo->addTo( canvasContextMenu );
1678 canvasContextMenu->insertSeparator();
1679 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1680 canvasContextMenu->insertSeparator();
1681 actionFormatLinkColorHint->addTo( canvasContextMenu );
1682 actionFormatLinkColor->addTo( canvasContextMenu );
1683 actionFormatSelectionColor->addTo( canvasContextMenu );
1684 actionFormatBackColor->addTo( canvasContextMenu );
1685 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1687 // Menu for last opened files
1689 for (int i = 0; i < MaxRecentFiles; ++i)
1691 recentFileActions[i] = new QAction(this);
1692 recentFileActions[i]->setVisible(false);
1693 fileLastMapsMenu->addAction(recentFileActions[i]);
1694 connect(recentFileActions[i], SIGNAL(triggered()),
1695 this, SLOT(fileLoadRecent()));
1697 setupRecentMapsMenu();
1700 void Main::setupRecentMapsMenu()
1702 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1704 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1706 for (int i = 0; i < numRecentFiles; ++i) {
1707 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1708 recentFileActions[i]->setText(text);
1709 recentFileActions[i]->setData(files[i]);
1710 recentFileActions[i]->setVisible(true);
1712 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1713 recentFileActions[j]->setVisible(false);
1716 void Main::setupMacros()
1718 for (int i = 0; i <= 11; i++)
1720 macroActions[i] = new QAction(this);
1721 macroActions[i]->setData(i);
1722 addAction (macroActions[i]);
1723 connect(macroActions[i], SIGNAL(triggered()),
1724 this, SLOT(callMacro()));
1726 macroActions[0]->setShortcut ( Qt::Key_F1 );
1727 macroActions[1]->setShortcut ( Qt::Key_F2 );
1728 macroActions[2]->setShortcut ( Qt::Key_F3 );
1729 macroActions[3]->setShortcut ( Qt::Key_F4 );
1730 macroActions[4]->setShortcut ( Qt::Key_F5 );
1731 macroActions[5]->setShortcut ( Qt::Key_F6 );
1732 macroActions[6]->setShortcut ( Qt::Key_F7 );
1733 macroActions[7]->setShortcut ( Qt::Key_F8 );
1734 macroActions[8]->setShortcut ( Qt::Key_F9 );
1735 macroActions[9]->setShortcut ( Qt::Key_F10 );
1736 macroActions[10]->setShortcut ( Qt::Key_F11 );
1737 macroActions[11]->setShortcut ( Qt::Key_F12 );
1740 void Main::hideEvent (QHideEvent * )
1742 if (!textEditor->isMinimized() ) textEditor->hide();
1745 void Main::showEvent (QShowEvent * )
1747 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1751 MapEditor* Main::currentMapEditor() const
1753 if ( tabWidget->currentPage())
1754 return tabModel.at(tabWidget->currentIndex())->getMapEditor();
1758 VymModel* Main::currentModel() const
1760 if ( tabWidget->currentPage())
1761 return tabModel.at(tabWidget->currentIndex());
1766 void Main::editorChanged(QWidget *)
1768 // Unselect all possibly selected objects
1769 // (Important to update note editor)
1770 for (int i=0;i<=tabWidget->count() -1;i++)
1772 tabModel.at(i)->unselect();
1774 VymModel *m=currentModel();
1775 if (m) m->reselect();
1777 // Update actions to in menus and toolbars according to editor
1781 VymView *Main::createView (VymModel *model)
1783 VymView *vm=new VymView (model);
1787 void Main::fileNew()
1789 VymModel *m=new VymModel;
1790 tabModel.append (m);
1791 //MapEditor* me = new MapEditor (m);
1792 //me->setObjectName ("MapEditor");
1794 tabWidget->addTab (createView (m),tr("unnamed","MainWindow: name for new and empty file"));
1795 tabWidget->setCurrentIndex (tabModel.count() );
1797 // For the very first map we do not have flagrows yet...
1801 void Main::fileNewCopy()
1803 QString fn="unnamed";
1804 VymModel *srcModel=currentModel();
1809 VymModel *dstModel=tabModel.last ();
1810 dstModel->select("mc:");
1811 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1815 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1817 ErrorCode err=success;
1819 // fn is usually the archive, mapfile the file after uncompressing
1822 // Make fn absolute (needed for unzip)
1823 fn=QDir (fn).absPath();
1829 // Check, if map is already loaded
1831 while (i<=tabWidget->count() -1)
1833 if (tabModel.at(i)->getFilePath() == fn)
1835 // Already there, ask for confirmation
1836 QMessageBox mb( vymName,
1837 tr("The map %1\nis already opened."
1838 "Opening the same map in multiple editors may lead \n"
1839 "to confusion when finishing working with vym."
1840 "Do you want to").arg(fn),
1841 QMessageBox::Warning,
1842 QMessageBox::Yes | QMessageBox::Default,
1843 QMessageBox::Cancel | QMessageBox::Escape,
1844 QMessageBox::NoButton);
1845 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1846 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1849 case QMessageBox::Yes:
1850 // end loop and load anyway
1851 i=tabWidget->count();
1853 case QMessageBox::Cancel:
1863 int tabIndex=tabWidget->currentPageIndex();
1866 if ( !fn.isEmpty() )
1868 vm = currentModel();
1869 // Check first, if mapeditor exists
1870 // If it is not default AND we want a new map,
1871 // create a new mapeditor in a new tab
1872 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1875 tabModel.append (vm);
1876 tabWidget->addTab (createView (vm),fn);
1877 tabIndex=tabWidget->count()-1;
1878 tabWidget->setCurrentPage (tabIndex);
1881 // Check, if file exists (important for creating new files
1882 // from command line
1883 if (!QFile(fn).exists() )
1885 QMessageBox mb( vymName,
1886 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1887 QMessageBox::Question,
1889 QMessageBox::Cancel | QMessageBox::Default,
1890 QMessageBox::NoButton );
1892 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1893 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1896 case QMessageBox::Yes:
1898 currentMapEditor()->getModel()->setFilePath(fn);
1899 tabWidget->setTabText (tabIndex,
1900 currentMapEditor()->getModel()->getFileName() );
1901 statusBar()->message( "Created " + fn , statusbarTime );
1904 case QMessageBox::Cancel:
1905 // don't create new map
1906 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1913 //tabWidget->currentPage() won't be NULL here, because of above...
1914 tabWidget->setCurrentIndex (tabIndex);
1915 //FIXME-3 no me anymore... me->viewport()->setFocus();
1919 // Save existing filename in case we import
1920 QString fn_org=vm->getFilePath();
1922 // Finally load map into mapEditor
1923 vm->setFilePath (fn);
1924 err=vm->load(fn,lmode,ftype);
1926 // Restore old (maybe empty) filepath, if this is an import
1928 vm->setFilePath (fn_org);
1931 // Finally check for errors and go home
1934 if (lmode==NewMap) fileCloseMap();
1935 statusBar()->message( "Could not load " + fn, statusbarTime );
1940 vm->setFilePath (fn);
1941 tabWidget->setTabText (tabIndex, vm->getFileName());
1942 if (!isInTmpDir (fn))
1944 // Only append to lastMaps if not loaded from a tmpDir
1945 // e.g. imported bookmarks are in a tmpDir
1946 addRecentMap(vm->getFilePath() );
1948 actionFilePrint->setEnabled (true);
1950 statusBar()->message( "Loaded " + fn, statusbarTime );
1957 void Main::fileLoad(const LoadMode &lmode)
1959 QStringList filters;
1960 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1961 QFileDialog *fd=new QFileDialog( this);
1962 fd->setDir (lastFileDir);
1963 fd->setFileMode (QFileDialog::ExistingFiles);
1964 fd->setFilters (filters);
1968 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1971 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1974 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1980 if ( fd->exec() == QDialog::Accepted )
1982 lastFileDir=fd->directory().path();
1983 QStringList flist = fd->selectedFiles();
1984 QStringList::Iterator it = flist.begin();
1985 while( it != flist.end() )
1988 fileLoad(*it, lmode);
1995 void Main::fileLoad()
2000 void Main::fileLoadRecent()
2002 QAction *action = qobject_cast<QAction *>(sender());
2004 fileLoad (action->data().toString(), NewMap);
2007 void Main::addRecentMap (const QString &fileName)
2010 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2011 files.removeAll(fileName);
2012 files.prepend(fileName);
2013 while (files.size() > MaxRecentFiles)
2016 settings.setValue("/mainwindow/recentFileList", files);
2018 setupRecentMapsMenu();
2021 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2025 if ( m->getFilePath().isEmpty() )
2027 // We have no filepath yet,
2028 // call fileSaveAs() now, this will call fileSave()
2030 // First switch to editor
2031 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2032 fileSaveAs(savemode);
2035 if (m->save (savemode)==success)
2037 statusBar()->message(
2038 tr("Saved %1").arg(m->getFilePath()),
2040 addRecentMap (m->getFilePath() );
2042 statusBar()->message(
2043 tr("Couldn't save ").arg(m->getFilePath()),
2047 void Main::fileSave()
2049 fileSave (currentModel(), CompleteMap);
2052 void Main::fileSave(VymModel *m)
2054 fileSave (m,CompleteMap);
2057 void Main::fileSaveAs(const SaveMode& savemode)
2061 if (currentMapEditor())
2063 if (savemode==CompleteMap)
2064 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2066 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2067 if ( !fn.isEmpty() )
2069 // Check for existing file
2070 if (QFile (fn).exists())
2072 QMessageBox mb( vymName,
2073 tr("The file %1\nexists already. Do you want to").arg(fn),
2074 QMessageBox::Warning,
2075 QMessageBox::Yes | QMessageBox::Default,
2076 QMessageBox::Cancel | QMessageBox::Escape,
2077 QMessageBox::NoButton);
2078 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2079 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2082 case QMessageBox::Yes:
2085 case QMessageBox::Cancel:
2092 // New file, add extension to filename, if missing
2093 // This is always .vym or .vyp, depending on savemode
2094 if (savemode==CompleteMap)
2096 if (!fn.contains (".vym") && !fn.contains (".xml"))
2100 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2109 VymModel *m=currentModel();
2111 fileSave(m, savemode);
2113 // Set name of tab, assuming current tab is the one we just saved
2114 if (savemode==CompleteMap)
2115 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2121 void Main::fileSaveAs()
2123 fileSaveAs (CompleteMap);
2126 void Main::fileImportKDE3Bookmarks()
2128 ImportKDE3Bookmarks im;
2130 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2131 currentMapEditor()->getModel()->setFilePath ("");
2134 void Main::fileImportKDE4Bookmarks()
2136 ImportKDE4Bookmarks im;
2138 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2139 currentMapEditor()->getModel()->setFilePath ("");
2142 void Main::fileImportFirefoxBookmarks()
2144 Q3FileDialog *fd=new Q3FileDialog( this);
2145 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2146 fd->setMode (Q3FileDialog::ExistingFiles);
2147 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2148 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2151 if ( fd->exec() == QDialog::Accepted )
2153 ImportFirefoxBookmarks im;
2154 QStringList flist = fd->selectedFiles();
2155 QStringList::Iterator it = flist.begin();
2156 while( it != flist.end() )
2159 if (im.transform() &&
2160 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2161 currentMapEditor() )
2162 currentMapEditor()->getModel()->setFilePath ("");
2169 void Main::fileImportFreemind()
2171 QStringList filters;
2172 filters <<"Freemind map (*.mm)"<<"All files (*)";
2173 QFileDialog *fd=new QFileDialog( this);
2174 fd->setDir (lastFileDir);
2175 fd->setFileMode (QFileDialog::ExistingFiles);
2176 fd->setFilters (filters);
2177 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2181 if ( fd->exec() == QDialog::Accepted )
2183 lastFileDir=fd->directory().path();
2184 QStringList flist = fd->selectedFiles();
2185 QStringList::Iterator it = flist.begin();
2186 while( it != flist.end() )
2189 if ( fileLoad (fn,NewMap, FreemindMap) )
2191 currentMapEditor()->getModel()->setFilePath ("");
2200 void Main::fileImportMM()
2204 Q3FileDialog *fd=new Q3FileDialog( this);
2205 fd->setDir (lastFileDir);
2206 fd->setMode (Q3FileDialog::ExistingFiles);
2207 fd->addFilter ("Mind Manager (*.mmap)");
2208 fd->setCaption(tr("Import")+" "+"Mind Manager");
2211 if ( fd->exec() == QDialog::Accepted )
2213 lastFileDir=fd->dirPath();
2214 QStringList flist = fd->selectedFiles();
2215 QStringList::Iterator it = flist.begin();
2216 while( it != flist.end() )
2219 if (im.transform() &&
2220 success==fileLoad (im.getTransformedFile(),NewMap) &&
2221 currentMapEditor() )
2222 currentMapEditor()->getModel()->setFilePath ("");
2229 void Main::fileImportDir()
2231 VymModel *m=currentModel();
2232 if (m) m->importDir();
2235 void Main::fileExportXML()
2237 VymModel *m=currentModel();
2238 if (m) m->exportXML();
2242 void Main::fileExportXHTML()
2244 VymModel *m=currentModel();
2245 if (m) m->exportXHTML();
2248 void Main::fileExportImage()
2250 VymModel *m=currentModel();
2251 if (m) m->exportImage();
2254 void Main::fileExportASCII()
2256 VymModel *m=currentModel();
2257 if (m) m->exportASCII();
2260 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2262 VymModel *m=currentModel();
2267 ex.addFilter ("CSV (*.csv)");
2268 ex.setDir(lastImageDir);
2269 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2270 if (ex.execDialog() )
2272 m->setExportMode(true);
2274 m->setExportMode(false);
2279 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2281 VymModel *m=currentModel();
2286 ex.addFilter ("Tex (*.tex)");
2287 ex.setDir(lastImageDir);
2288 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2289 if (ex.execDialog() )
2291 m->setExportMode(true);
2293 m->setExportMode(false);
2298 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2300 ExportKDE3Bookmarks ex;
2301 VymModel *m=currentModel();
2309 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2311 ExportKDE4Bookmarks ex;
2312 VymModel *m=currentModel();
2320 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2322 ExportTaskjuggler ex;
2323 VymModel *m=currentModel();
2327 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2328 ex.setDir(lastImageDir);
2329 ex.addFilter ("Taskjuggler (*.tjp)");
2330 if (ex.execDialog() )
2332 m->setExportMode(true);
2334 m->setExportMode(false);
2339 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2341 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2342 // TODO add preview in dialog
2343 //ImagePreview *p =new ImagePreview (fd);
2344 //fd->setContentsPreviewEnabled( TRUE );
2345 //fd->setContentsPreview( p, p );
2346 //fd->setPreviewMode( QFileDialog::Contents );
2347 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2348 fd->setDir (QDir().current());
2349 if (fd->foundConfig())
2353 if ( fd->exec() == QDialog::Accepted )
2355 QString fn=fd->selectedFile();
2356 if (!fn.contains (".odp"))
2359 //lastImageDir=fn.left(fn.findRev ("/"));
2360 VymModel *m=currentModel();
2361 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2365 QMessageBox::warning(0,
2367 tr("Couldn't find configuration for export to Open Office\n"));
2371 void Main::fileCloseMap()
2373 MapEditor *me = currentMapEditor();
2374 VymModel *m=currentModel();
2377 if (m->hasChanged())
2379 QMessageBox mb( vymName,
2380 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
2381 QMessageBox::Warning,
2382 QMessageBox::Yes | QMessageBox::Default,
2384 QMessageBox::Cancel | QMessageBox::Escape );
2385 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2386 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2389 case QMessageBox::Yes:
2391 fileSave(m, CompleteMap);
2393 case QMessageBox::No:
2394 // close without saving
2396 case QMessageBox::Cancel:
2401 tabModel.removeAt (tabWidget->currentIndex() );
2402 tabWidget->removeTab (tabWidget->currentIndex() );
2404 // Remove mapEditor;
2405 // Better would be delete (me), but then we could have a Qt error:
2406 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2407 // So we only remove data now and call deconstructor when vym closes later
2408 // FIXME-3 this needs to be moved to vymview... me->clear();
2409 // some model->clear is needed to free up memory ...
2415 void Main::filePrint()
2417 if (currentMapEditor())
2418 currentMapEditor()->print();
2421 void Main::fileExitVYM()
2423 // Check if one or more editors have changed
2425 for (i=0;i<=tabModel.count() -1;i++)
2427 // If something changed, ask what to do
2428 if (tabModel.at(i)->hasChanged())
2430 tabWidget->setCurrentPage(i);
2431 QMessageBox mb( vymName,
2432 tr("This map is not saved yet. Do you want to"),
2433 QMessageBox::Warning,
2434 QMessageBox::Yes | QMessageBox::Default,
2436 QMessageBox::Cancel | QMessageBox::Escape );
2437 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2438 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2441 mb.setActiveWindow();
2442 switch( mb.exec() ) {
2443 case QMessageBox::Yes:
2444 // save (the changed editors) and exit
2445 fileSave(currentModel(), CompleteMap);
2447 case QMessageBox::No:
2448 // exit without saving
2450 case QMessageBox::Cancel:
2451 // don't save and don't exit
2455 } // loop over all MEs
2459 void Main::editUndo()
2461 VymModel *m=currentModel();
2465 void Main::editRedo()
2467 VymModel *m=currentModel();
2471 void Main::gotoHistoryStep (int i)
2473 VymModel *m=currentModel();
2474 if (m) m->gotoHistoryStep(i);
2477 void Main::editCopy()
2479 VymModel *m=currentModel();
2483 void Main::editPaste()
2485 VymModel *m=currentModel();
2489 void Main::editCut()
2491 VymModel *m=currentModel();
2495 void Main::editOpenFindWindow()
2497 findWindow->popup();
2498 findWindow->raise();
2499 findWindow->setActiveWindow();
2502 void Main::editFind(QString s)
2504 VymModel *m=currentModel();
2508 BranchItem *bi=m->findText(s, cs);
2511 statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
2514 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2515 tr("No matches found for \"%1\"").arg(s));
2520 void Main::editFindChanged()
2521 { // Notify editor, to abort the current find process
2522 VymModel *m=currentModel();
2523 if (m) m->findReset();
2526 void Main::openTabs(QStringList urls)
2528 if (!urls.isEmpty())
2532 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2534 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2536 QString u=urls.takeFirst();
2537 procBrowser = new QProcess( this );
2539 procBrowser->start(browser,args);
2540 if ( !procBrowser->waitForStarted())
2542 // try to set path to browser
2543 QMessageBox::warning(0,
2545 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2546 tr("Please use Settings->")+tr("Set application to open an URL"));
2549 #if defined(Q_OS_WIN32)
2550 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2551 this->thread()->wait(3000);
2556 if (browser.contains("konqueror"))
2558 for (int i=0; i<urls.size(); i++)
2561 // Try to open new tab in existing konqueror started previously by vym
2562 p=new QProcess (this);
2564 #if defined(Q_OS_WIN32)
2565 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2566 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2567 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2568 "konqueror-mainwindow#1"<<
2572 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2573 "konqueror-mainwindow#1"<<
2577 p->start ("dcop",args);
2578 if (debug) cout << "MainWindo::openURLs args="<<args.join(" ").toStdString()<<endl;
2579 if ( !p->waitForStarted() ) success=false;
2582 QMessageBox::warning(0,
2584 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2586 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2588 for (int i=0; i<urls.size(); i++)
2590 // Try to open new tab in firefox
2591 p=new QProcess (this);
2592 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2593 p->start (browser,args);
2594 if ( !p->waitForStarted() ) success=false;
2597 QMessageBox::warning(0,
2599 tr("Couldn't start %1 to open a new tab").arg(browser));
2602 QMessageBox::warning(0,
2604 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2608 void Main::editOpenURL()
2611 VymModel *m=currentModel();
2614 QString url=m->getURL();
2616 if (url=="") return;
2617 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2618 procBrowser = new QProcess( this );
2620 procBrowser->start(browser,args);
2621 if ( !procBrowser->waitForStarted())
2623 // try to set path to browser
2624 QMessageBox::warning(0,
2626 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2627 tr("Please use Settings->")+tr("Set application to open an URL"));
2632 void Main::editOpenURLTab()
2634 VymModel *m=currentModel();
2638 urls.append(m->getURL());
2642 void Main::editOpenMultipleURLTabs()
2644 VymModel *m=currentModel();
2654 void Main::editURL()
2656 VymModel *m=currentModel();
2657 if (m) m->editURL();
2660 void Main::editLocalURL()
2662 VymModel *m=currentModel();
2663 if (m) m->editLocalURL();
2666 void Main::editHeading2URL()
2668 VymModel *m=currentModel();
2669 if (m) m->editHeading2URL();
2672 void Main::editBugzilla2URL()
2674 VymModel *m=currentModel();
2675 if (m) m->editBugzilla2URL();
2678 void Main::editFATE2URL()
2680 VymModel *m=currentModel();
2681 if (m) m->editFATE2URL();
2684 void Main::editHeadingFinished(VymModel *m)
2688 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2689 !prevSelection.isEmpty())
2690 m->select(prevSelection);
2696 void Main::editAttributeFinished()
2698 // only called from editHeading(), so there is a currentME
2701 MapEditor *me=currentMapEditor();
2704 me->setStateEditHeading (false);
2705 QPoint p; //Not used here, only to find out pos of branch
2707 QString s=me->getHeading(ok,p);
2709 #if defined(Q_OS_MACX)
2711 if (ok && s!=lineedit->text())
2712 me->setHeading(lineedit->text());
2714 lineedit->releaseKeyboard();
2718 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2719 !prevSelection.isEmpty())
2720 me->select(prevSelection);
2726 #include "attribute.h"
2727 #include "attributedialog.h"
2728 void Main::editAttribute()
2731 MapEditor *me=currentMapEditor();
2734 BranchObj *bo=me->getModel()->getSelectedBranch();
2737 AttributeDialog dia(this);
2738 dia.setTable (me->attributeTable() );
2740 dia.setMode (Definition);
2747 if (currentMapEditor())
2749 MapEditor *me=currentMapEditor();
2750 QString oldSel=me->getSelectString();
2752 if (lineedit->isVisible())
2753 editAttributeFinished();
2758 QString s=me->getHeading(ok,p);
2762 me->setStateEditHeading (true);
2763 #if defined(Q_OS_MACX)
2764 p=me->mapToGlobal (p);
2765 QDialog *d =new QDialog(NULL);
2766 QLineEdit *le=new QLineEdit (d);
2767 d->setWindowFlags (Qt::FramelessWindowHint);
2768 d->setGeometry(p.x(),p.y(),230,25);
2769 le->resize (d->width()-10,d->height());
2772 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2773 d->activateWindow();
2775 me->setHeading (le->text());
2778 editHeadingFinished();
2780 p=me->mapTo (this,p);
2781 lineedit->setGeometry(p.x(),p.y(),230,25);
2782 lineedit->setText(s);
2783 lineedit->setCursorPosition(1);
2784 lineedit->selectAll();
2786 lineedit->grabKeyboard();
2787 lineedit->setFocus();
2791 } // currentMapEditor()
2796 void Main::openVymLinks(const QStringList &vl)
2798 for (int j=0; j<vl.size(); j++)
2800 // compare path with already loaded maps
2803 for (i=0;i<=tabModel.count() -1;i++)
2805 if (vl.at(j)==tabModel.at(i)->getFilePath() )
2814 if (!QFile(vl.at(j)).exists() )
2815 QMessageBox::critical( 0, tr( "Critical Error" ),
2816 tr("Couldn't open map %1").arg(vl.at(j)));
2819 fileLoad (vl.at(j), NewMap);
2820 tabWidget->setCurrentIndex (tabWidget->count()-1);
2823 // Go to tab containing the map
2824 tabWidget->setCurrentIndex (index);
2828 void Main::editOpenVymLink()
2830 VymModel *m=currentModel();
2834 vl.append(m->getVymLink());
2839 void Main::editOpenMultipleVymLinks()
2841 QString currentVymLink;
2842 VymModel *m=currentModel();
2845 QStringList vl=m->getVymLinks();
2850 void Main::editVymLink()
2852 VymModel *m=currentModel();
2857 void Main::editDeleteVymLink()
2859 VymModel *m=currentModel();
2860 if (m) m->deleteVymLink();
2863 void Main::editToggleHideExport()
2865 VymModel *m=currentModel();
2866 if (m) m->toggleHideExport();
2869 void Main::editMapInfo()
2871 VymModel *m=currentModel();
2873 ExtraInfoDialog dia;
2874 dia.setMapName (m->getFileName() );
2875 dia.setAuthor (m->getAuthor() );
2876 dia.setComment(m->getComment() );
2880 /* FIXME-2 no stats at the moment (view dependent...)
2881 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2891 if (!bo->getNote().isEmpty() ) n++;
2892 f+= bo->countFloatImages();
2894 xl+=bo->countXLinks();
2897 stats+=QString ("%1 xLinks \n").arg (xl,6);
2898 stats+=QString ("%1 notes\n").arg (n,6);
2899 stats+=QString ("%1 images\n").arg (f,6);
2901 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2902 dia.setStats (stats);
2904 // Finally show dialog
2905 if (dia.exec() == QDialog::Accepted)
2907 m->setAuthor (dia.getAuthor() );
2908 m->setComment (dia.getComment() );
2912 void Main::editMoveUp()
2914 VymModel *m=currentModel();
2915 if (m) m->moveBranchUp();
2918 void Main::editMoveDown()
2920 VymModel *m=currentModel();
2921 if (m) m->moveBranchDown();
2924 void Main::editSortChildren()
2926 VymModel *m=currentModel();
2927 if (m) m->sortChildren();
2930 void Main::editToggleScroll()
2932 VymModel *m=currentModel();
2933 if (m) m->toggleScroll();
2936 void Main::editExpandAll()
2938 VymModel *m=currentModel();
2939 if (m) m->emitExpandAll();
2942 void Main::editUnscrollChildren()
2944 VymModel *m=currentModel();
2945 if (m) m->unscrollChildren();
2948 void Main::editAddMapCenter()
2950 VymModel *m=currentModel();
2953 cout <<"Main::editAddMapCenter\n";
2958 void Main::editNewBranch()
2960 VymModel *m=currentModel();
2963 BranchItem *bi=m->createBranch();
2970 if (actionSettingsAutoEditNewBranch->isOn())
2972 currentMapEditor()->editHeading();
2975 if (!prevSelection.isEmpty())
2977 m->select(prevSelection);
2983 void Main::editNewBranchBefore()
2985 VymModel *m=currentModel();
2988 BranchItem *bi=m->createBranch(); //FIXME-1 missing: m->addNewBranchBefore();
2995 if (actionSettingsAutoEditNewBranch->isOn())
2997 if (!actionSettingsAutoSelectNewBranch->isOn())
2998 prevSelection=m->getSelectString(bi);
2999 currentMapEditor()->editHeading();
3004 void Main::editNewBranchAbove()
3006 VymModel *m=currentModel();
3009 BranchItem *bi=m->addNewBranch (-1);
3017 if (actionSettingsAutoEditNewBranch->isOn())
3019 if (!actionSettingsAutoSelectNewBranch->isOn())
3020 prevSelection=m->getSelectString (bi);
3021 currentMapEditor()->editHeading();
3026 void Main::editNewBranchBelow()
3028 VymModel *m=currentModel();
3031 BranchItem *bi=m->addNewBranch (1);
3038 if (actionSettingsAutoEditNewBranch->isOn())
3040 if (!actionSettingsAutoSelectNewBranch->isOn())
3041 prevSelection=m->getSelectString(bi);
3042 currentMapEditor()->editHeading();
3047 void Main::editImportAdd()
3049 fileLoad (ImportAdd);
3052 void Main::editImportReplace()
3054 fileLoad (ImportReplace);
3057 void Main::editSaveBranch()
3059 fileSaveAs (PartOfMap);
3062 void Main::editDeleteKeepChildren()
3064 VymModel *m=currentModel();
3065 if (m) m->deleteKeepChildren();
3068 void Main::editDeleteChildren()
3070 VymModel *m=currentModel();
3071 if (m) m->deleteChildren();
3074 void Main::editDeleteSelection()
3076 VymModel *m=currentModel();
3077 if (m && actionSettingsUseDelKey->isOn())
3078 m->deleteSelection();
3081 void Main::editUpperBranch()
3083 VymModel *m=currentModel();
3084 if (m) m->selectUpperBranch(); // FIXME-3 check also lower... this probably should go into view...
3087 void Main::editLowerBranch() // FIXME-3 check also lower... this probably should go into view...
3090 VymModel *m=currentModel();
3091 if (m) m->selectLowerBranch();
3094 void Main::editLeftBranch()
3096 VymModel *m=currentModel();
3097 if (m) m->selectLeftBranch();
3100 void Main::editRightBranch()
3102 VymModel *m=currentModel();
3103 if (m) m->selectRightBranch();
3106 void Main::editFirstBranch()
3108 VymModel *m=currentModel();
3109 if (m) m->selectFirstBranch();
3112 void Main::editLastBranch()
3114 VymModel *m=currentModel();
3115 if (m) m->selectLastBranch();
3118 void Main::editLoadImage()
3120 VymModel *m=currentModel();
3121 if (m) m->loadFloatImage();
3124 void Main::editSaveImage()
3126 VymModel *m=currentModel();
3127 if (m) m->saveFloatImage();
3130 void Main::editFollowXLink(QAction *a)
3133 VymModel *m=currentModel();
3135 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3138 void Main::editEditXLink(QAction *a)
3140 VymModel *m=currentModel();
3142 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3145 void Main::formatSelectColor()
3147 QColor col = QColorDialog::getColor((currentColor ), this );
3148 if ( !col.isValid() ) return;
3149 colorChanged( col );
3152 void Main::formatPickColor()
3154 VymModel *m=currentModel();
3156 colorChanged( m->getCurrentHeadingColor() );
3159 void Main::colorChanged(QColor c)
3161 QPixmap pix( 16, 16 );
3163 actionFormatColor->setIconSet( pix );
3167 void Main::formatColorBranch()
3169 VymModel *m=currentModel();
3170 if (m) m->colorBranch(currentColor);
3173 void Main::formatColorSubtree()
3175 VymModel *m=currentModel();
3176 if (m) m->colorSubtree (currentColor);
3179 void Main::formatLinkStyleLine()
3181 VymModel *m=currentModel();
3184 m->setMapLinkStyle("StyleLine");
3185 actionFormatLinkStyleLine->setOn(true);
3189 void Main::formatLinkStyleParabel()
3191 VymModel *m=currentModel();
3194 m->setMapLinkStyle("StyleParabel");
3195 actionFormatLinkStyleParabel->setOn(true);
3199 void Main::formatLinkStylePolyLine()
3201 VymModel *m=currentModel();
3204 m->setMapLinkStyle("StylePolyLine");
3205 actionFormatLinkStylePolyLine->setOn(true);
3209 void Main::formatLinkStylePolyParabel()
3211 VymModel *m=currentModel();
3214 m->setMapLinkStyle("StylePolyParabel");
3215 actionFormatLinkStylePolyParabel->setOn(true);
3219 void Main::formatSelectBackColor()
3221 VymModel *m=currentModel();
3222 if (m) m->selectMapBackgroundColor();
3225 void Main::formatSelectBackImage()
3227 VymModel *m=currentModel();
3229 m->selectMapBackgroundImage();
3232 void Main::formatSelectLinkColor()
3234 VymModel *m=currentModel();
3237 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3238 m->setMapDefLinkColor( col );
3242 void Main::formatSelectSelectionColor()
3244 VymModel *m=currentModel();
3247 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3248 m->setSelectionColor (col);
3253 void Main::formatToggleLinkColorHint()
3255 VymModel *m=currentModel();
3256 if (m) m->toggleMapLinkColorHint();
3260 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3262 VymModel *m=currentModel();
3264 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3267 void Main::viewZoomReset()
3269 if (currentMapEditor())
3273 currentMapEditor()->setMatrix( m );
3277 void Main::viewZoomIn()
3279 if (currentMapEditor())
3281 QMatrix m = currentMapEditor()->matrix();
3282 m.scale( 1.25, 1.25 );
3283 currentMapEditor()->setMatrix( m );
3287 void Main::viewZoomOut()
3289 if (currentMapEditor())
3291 QMatrix m = currentMapEditor()->matrix();
3292 m.scale( 0.8, 0.8 );
3293 currentMapEditor()->setMatrix( m );
3297 void Main::viewCenter()
3299 VymModel *m=currentModel();
3300 if (m) m->emitShowSelection();
3303 void Main::networkStartServer()
3305 VymModel *m=currentModel();
3306 if (m) m->newServer();
3309 void Main::networkConnect()
3311 VymModel *m=currentModel();
3312 if (m) m->connectToServer();
3315 bool Main::settingsPDF()
3317 // Default browser is set in constructor
3319 QString text = QInputDialog::getText(
3320 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3321 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3323 settings.setValue ("/mainwindow/readerPDF",text);
3328 bool Main::settingsURL()
3330 // Default browser is set in constructor
3332 QString text = QInputDialog::getText(
3333 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3334 settings.value("/mainwindow/readerURL").toString()
3337 settings.setValue ("/mainwindow/readerURL",text);
3341 void Main::settingsMacroDir()
3343 QDir defdir(vymBaseDir.path() + "/macros");
3344 if (!defdir.exists())
3346 QDir dir=QFileDialog::getExistingDirectory (
3348 tr ("Directory with vym macros:"),
3349 settings.value ("/macros/macroDir",defdir.path()).toString()
3352 settings.setValue ("/macros/macroDir",dir.absolutePath());
3355 void Main::settingsUndoLevels()
3358 int i = QInputDialog::getInteger(
3360 tr("QInputDialog::getInteger()"),
3361 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3364 settings.setValue ("/mapeditor/stepsTotal",i);
3365 QMessageBox::information( this, tr( "VYM -Information:" ),
3366 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3370 void Main::settingsAutosaveToggle()
3372 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3375 void Main::settingsAutosaveTime()
3378 int i = QInputDialog::getInteger(
3380 tr("QInputDialog::getInteger()"),
3381 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3383 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3386 void Main::settingsWriteBackupFileToggle()
3388 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3391 void Main::settingsToggleAnimation()
3393 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3396 void Main::settingsToggleDelKey()
3398 if (actionSettingsUseDelKey->isOn())
3400 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3403 actionDelete->setAccel (QKeySequence (""));
3407 void Main::windowToggleNoteEditor()
3409 if (textEditor->isVisible() )
3410 windowHideNoteEditor();
3412 windowShowNoteEditor();
3415 void Main::windowToggleHistory()
3417 if (historyWindow->isVisible())
3418 historyWindow->hide();
3420 historyWindow->show();
3424 void Main::windowToggleProperty()
3426 if (branchPropertyWindow->isVisible())
3427 branchPropertyWindow->hide();
3429 branchPropertyWindow->show();
3430 branchPropertyWindow->setModel (currentModel() );
3433 void Main::windowToggleAntiAlias()
3435 bool b=actionViewToggleAntiAlias->isOn();
3437 for (int i=0;i<tabModel.count();i++)
3439 me=tabModel.at(i)->getMapEditor();
3440 if (me) me->setAntiAlias(b);
3445 bool Main::isAliased()
3447 return actionViewToggleAntiAlias->isOn();
3450 bool Main::hasSmoothPixmapTransform()
3452 return actionViewToggleSmoothPixmapTransform->isOn();
3455 void Main::windowToggleSmoothPixmap()
3457 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3459 for (int i=0;i<tabModel.count();i++)
3462 me=tabModel.at(i)->getMapEditor();
3463 if (me) me->setSmoothPixmap(b);
3467 void Main::updateHistory(SimpleSettings &undoSet)
3469 historyWindow->update (undoSet);
3472 void Main::updateNoteFlag()
3474 // this slot is connected to TextEditor::textHasChanged()
3476 VymModel *m=currentModel();
3477 if (m) m->updateNoteFlag();
3480 void Main::updateNoteEditor(QModelIndex index )
3482 TreeItem *ti=((VymModel*)sender())->getItem(index);
3484 cout << "Main::updateNoteEditor model="<<sender();
3485 cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
3487 textEditor->setNote (ti->getNoteObj() );
3490 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3492 //branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select()
3494 if (model && model==currentModel() )
3498 if (!oldsel.indexes().isEmpty() )
3500 ti=model->getItem(oldsel.indexes().first());
3501 //cout << "Main::changeSel getting note from "<<ti->getHeading().toStdString()<<": \""<<ti->getNote().toStdString()<<"\""<<endl;
3502 ti->setNoteObj (textEditor->getNoteObj(),false );
3504 if (!newsel.indexes().isEmpty() )
3506 ti=model->getItem(newsel.indexes().first());
3507 if (!ti->getNoteObj().isEmpty() )
3509 //cout << "Main::changeSel setting note of "<<ti->getHeading().toStdString()<<" m=("<<ti->getModel()<<") to \""<<ti->getNote().toStdString()<<"\""<<endl;
3510 textEditor->setNote(ti->getNoteObj() );
3512 textEditor->setNote(NoteObj() );
3514 textEditor->setInactive();
3516 // Show URL and link in statusbar // FIXME-2
3519 QString s=model->getURL();
3520 if (!s.isEmpty() ) status+="URL: "+s+" ";
3521 s=model->getVymLink();
3522 if (!s.isEmpty() ) status+="Link: "+s;
3523 if (!status.isEmpty() ) statusMessage (status);
3526 // Update Toolbar // FIXME-1, was so far in BranchObj
3527 //updateFlagsToolbar();
3533 void Main::updateActions()
3535 VymModel *m =currentModel();
3536 LinkableMapObj *selection;
3540 actionFilePrint->setEnabled (true);
3543 selection=m->getSelectedLMO();
3545 // Link style in context menu
3546 switch (m->getMapLinkStyle())
3548 case LinkableMapObj::Line:
3549 actionFormatLinkStyleLine->setOn(true);
3551 case LinkableMapObj::Parabel:
3552 actionFormatLinkStyleParabel->setOn(true);
3554 case LinkableMapObj::PolyLine:
3555 actionFormatLinkStylePolyLine->setOn(true);
3557 case LinkableMapObj::PolyParabel:
3558 actionFormatLinkStylePolyParabel->setOn(true);
3565 QPixmap pix( 16, 16 );
3566 pix.fill( m->getMapBackgroundColor() );
3567 actionFormatBackColor->setIconSet( pix );
3568 pix.fill( m->getSelectionColor() );
3569 actionFormatSelectionColor->setIconSet( pix );
3570 pix.fill( m->getMapDefLinkColor() );
3571 actionFormatLinkColor->setIconSet( pix );
3574 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3579 actionFilePrint->setEnabled (false);
3585 // updateActions is also called when NoteEditor is closed
3586 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3587 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3588 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3590 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3591 actionFormatLinkColorHint->setOn(true);
3593 actionFormatLinkColorHint->setOn(false);
3596 if (m && m->hasChanged() )
3597 actionFileSave->setEnabled( true);
3599 actionFileSave->setEnabled( true);
3600 if (m && m->isUndoAvailable())
3601 actionUndo->setEnabled( true);
3603 actionUndo->setEnabled( false);
3605 if (m && m->isRedoAvailable())
3606 actionRedo->setEnabled( true);
3608 actionRedo->setEnabled( false);
3610 TreeItem *selti=m->getSelectedItem();
3611 BranchItem *selbi=m->getSelectedBranchItem();
3616 // Take care of links // FIXME-1
3618 if (bo->countXLinks()==0)
3620 branchXLinksContextMenuEdit->clear();
3621 branchXLinksContextMenuFollow->clear();
3626 branchXLinksContextMenuEdit->clear();
3627 branchXLinksContextMenuFollow->clear();
3628 for (int i=0; i<=bo->countXLinks();i++)
3630 bot=bo->XLinkTargetAt(i);
3633 s=bot->getHeading();
3634 if (s.length()>xLinkMenuWidth)
3635 s=s.left(xLinkMenuWidth)+"...";
3636 branchXLinksContextMenuFollow->addAction (s);
3637 branchXLinksContextMenuEdit->addAction (s);
3643 standardFlagsDefault->setEnabled (true);
3645 actionToggleScroll->setEnabled (true);
3646 if ( selbi->isScrolled() )
3647 actionToggleScroll->setOn(true);
3649 actionToggleScroll->setOn(false);
3651 /* FIXME-1 if ( selti->getURL().isEmpty() )
3653 actionOpenURL->setEnabled (false);
3654 actionOpenURLTab->setEnabled (false);
3658 actionOpenURL->setEnabled (true);
3659 actionOpenURLTab->setEnabled (true);
3661 if ( selti->getVymLink().isEmpty() )
3663 actionOpenVymLink->setEnabled (false);
3664 actionDeleteVymLink->setEnabled (false);
3667 actionOpenVymLink->setEnabled (true);
3668 actionDeleteVymLink->setEnabled (true);
3671 /* FIXME-1 if (selbi->canMoveBranchUp())
3672 actionMoveUp->setEnabled (true);
3674 actionMoveUp->setEnabled (false);
3675 if (selbi->canMoveBranchDown())
3676 actionMoveDown->setEnabled (true);
3678 actionMoveDown->setEnabled (false);
3680 actionSortChildren->setEnabled (true);
3682 actionToggleHideExport->setEnabled (true);
3683 actionToggleHideExport->setOn (selbi->hideInExport() );
3685 actionFileSave->setEnabled (true);
3686 actionCopy->setEnabled (true);
3687 actionCut->setEnabled (true);
3688 if (!clipboardEmpty)
3689 actionPaste->setEnabled (true);
3691 actionPaste->setEnabled (false);
3692 for (int i=0; i<actionListBranches.size(); ++i)
3693 actionListBranches.at(i)->setEnabled(true);
3694 actionDelete->setEnabled (true);
3695 actionFormatHideLinkUnselected->setOn
3696 (selection->getHideLinkUnselected());
3698 if ( selti->getType()==TreeItem::Image)
3701 FloatObj *fo=(FloatImageObj*)selection;
3703 actionOpenURL->setEnabled (false);
3704 actionOpenVymLink->setEnabled (false);
3705 actionDeleteVymLink->setEnabled (false);
3706 actionToggleHideExport->setEnabled (true);
3707 actionToggleHideExport->setOn (fo->hideInExport() );
3710 actionCopy->setEnabled (true);
3711 actionCut->setEnabled (true);
3712 actionPaste->setEnabled (false);
3713 for (int i=0; i<actionListBranches.size(); ++i)
3714 actionListBranches.at(i)->setEnabled(false);
3715 actionDelete->setEnabled (true);
3716 actionFormatHideLinkUnselected->setOn
3717 ( selection->getHideLinkUnselected());
3718 actionMoveUp->setEnabled (false);
3719 actionMoveDown->setEnabled (false);
3725 standardFlagsDefault->setEnabled (false);
3726 actionFileSave->setEnabled (false);
3727 actionCopy->setEnabled (false);
3728 actionCut->setEnabled (false);
3729 actionPaste->setEnabled (false);
3730 for (int i=0; i<actionListBranches.size(); ++i)
3731 actionListBranches.at(i)->setEnabled(false);
3733 actionToggleScroll->setEnabled (false);
3734 actionOpenURL->setEnabled (false);
3735 actionOpenVymLink->setEnabled (false);
3736 actionDeleteVymLink->setEnabled (false);
3737 actionHeading2URL->setEnabled (false);
3738 actionDelete->setEnabled (false);
3739 actionMoveUp->setEnabled (false);
3740 actionMoveDown->setEnabled (false);
3741 actionSortChildren->setEnabled (false);
3742 actionToggleHideExport->setEnabled (false);
3746 Main::ModMode Main::getModMode()
3748 if (actionModModeColor->isOn()) return ModModeColor;
3749 if (actionModModeCopy->isOn()) return ModModeCopy;
3750 if (actionModModeXLink->isOn()) return ModModeXLink;
3754 bool Main::autoEditNewBranch()
3756 return actionSettingsAutoEditNewBranch->isOn();
3759 bool Main::autoSelectNewBranch()
3761 return actionSettingsAutoSelectNewBranch->isOn();
3764 bool Main::useFlagGroups()
3766 return actionSettingsUseFlagGroups->isOn();
3769 void Main::windowShowNoteEditor()
3771 textEditor->setShowWithMain(true);
3773 actionViewToggleNoteEditor->setOn (true);
3776 void Main::windowHideNoteEditor()
3778 textEditor->setShowWithMain(false);
3780 actionViewToggleNoteEditor->setOn (false);
3783 void Main::setScript (const QString &script)
3785 scriptEditor->setScript (script);
3788 void Main::runScript (const QString &script)
3790 VymModel *m=currentModel();
3791 if (m) m->runScript (script);
3794 void Main::runScriptEverywhere (const QString &script)
3797 for (int i=0;i<=tabWidget->count() -1;i++)
3799 me=(MapEditor*)tabWidget->page(i);
3800 if (me) me->getModel()->runScript (script);
3804 void Main::windowNextEditor()
3806 if (tabWidget->currentIndex() < tabWidget->count())
3807 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3810 void Main::windowPreviousEditor()
3812 if (tabWidget->currentIndex() >0)
3813 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3816 void Main::standardFlagChanged()
3818 if (currentMapEditor())
3819 currentMapEditor()->toggleStandardFlag(sender()->name());
3822 void Main::testFunction1()
3824 //if (!currentMapEditor()) return;
3825 //currentMapEditor()->testFunction1();
3829 void Main::testFunction2()
3831 if (!currentMapEditor()) return;
3832 currentMapEditor()->testFunction2();
3835 void Main::testCommand()
3837 if (!currentMapEditor()) return;
3838 scriptEditor->show();
3841 QString com = QInputDialog::getText(
3842 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3843 if (ok) currentMapEditor()->parseAtom(com);
3847 void Main::helpDoc()
3849 QString locale = QLocale::system().name();
3851 if (locale.left(2)=="es")
3852 docname="vym_es.pdf";
3856 QStringList searchList;
3858 #if defined(Q_OS_MACX)
3859 searchList << "./vym.app/Contents/Resources/doc";
3860 #elif defined(Q_OS_WIN32)
3861 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3863 #if defined(VYM_DOCDIR)
3864 searchList << VYM_DOCDIR;
3866 // default path in SUSE LINUX
3867 searchList << "/usr/share/doc/packages/vym";
3870 searchList << "doc"; // relative path for easy testing in tarball
3871 searchList << "doc/tex"; // Easy testing working on vym.tex
3872 searchList << "/usr/share/doc/vym"; // Debian
3873 searchList << "/usr/share/doc/packages";// Knoppix
3877 for (int i=0; i<searchList.count(); ++i)
3879 docfile.setFileName(searchList.at(i)+"/"+docname);
3880 if (docfile.exists())
3889 QMessageBox::critical(0,
3890 tr("Critcal error"),
3891 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3896 Process *pdfProc = new Process();
3897 args << QDir::toNativeSeparators(docfile.fileName());
3899 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3900 if ( !pdfProc->waitForStarted() )
3903 QMessageBox::warning(0,
3905 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3906 tr("Please use Settings->")+tr("Set application to open PDF files"));
3913 void Main::helpDemo()
3915 QStringList filters;
3916 filters <<"VYM example map (*.vym)";
3917 QFileDialog *fd=new QFileDialog( this);
3918 #if defined(Q_OS_MACX)
3919 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3921 // default path in SUSE LINUX
3922 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3925 fd->setFileMode (QFileDialog::ExistingFiles);
3926 fd->setFilters (filters);
3927 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3931 if ( fd->exec() == QDialog::Accepted )
3933 lastFileDir=fd->directory().path();
3934 QStringList flist = fd->selectedFiles();
3935 QStringList::Iterator it = flist.begin();
3936 while( it != flist.end() )
3939 fileLoad(*it, NewMap);
3947 void Main::helpAbout()
3950 ad.setName ("aboutwindow");
3951 ad.setMinimumSize(500,500);
3952 ad.resize (QSize (500,500));
3956 void Main::helpAboutQT()
3958 QMessageBox::aboutQt( this, "Qt Application Example" );
3961 void Main::callMacro ()
3963 QAction *action = qobject_cast<QAction *>(sender());
3967 i=action->data().toInt();
3968 QString mDir (settings.value ("macros/macroDir").toString() );
3970 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3972 if ( !f.open( QIODevice::ReadOnly ) )
3974 QMessageBox::warning(0,
3976 tr("Couldn't find a macro at %1.\n").arg(fn)+
3977 tr("Please use Settings->")+tr("Set directory for vym macros"));
3981 QTextStream ts( &f );
3982 QString macro= ts.read();
3984 if (! macro.isEmpty())
3986 VymModel *m=currentModel();
3987 if (m) m->runScript(macro);