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(tr( "Add mapcenter","Canvas context menu" ), this);
583 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
584 actionAddMapCenter = a;
587 // Shortcut to add branch
588 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
589 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
590 alt->setShortcut (Qt::Key_A); //Add branch
591 alt->setShortcutContext (Qt::WindowShortcut);
593 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
594 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
595 a->setStatusTip ( tr( "Add a branch as child of selection" ));
596 a->setShortcut (Qt::Key_Insert); //Add branch
597 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
598 actionListBranches.append(a);
599 #if defined (Q_OS_MACX)
600 // In OSX show different shortcut in menues, the keys work indepently always
605 editMenu->addAction (actionAddBranch);
606 tb->addAction (actionAddBranch);
609 // Add branch by inserting it at selection
610 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
611 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
612 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
613 a->setShortcutContext (Qt::WindowShortcut);
615 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
616 a->setEnabled (false);
617 actionListBranches.append(a);
618 actionAddBranchBefore=a;
619 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
620 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
621 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
622 a->setShortcutContext (Qt::WindowShortcut);
624 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
625 actionListBranches.append(a);
628 a = new QAction(tr( "Add branch above","Edit menu" ), this);
629 a->setStatusTip ( tr( "Add a branch above selection" ));
630 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
631 a->setShortcutContext (Qt::WindowShortcut);
633 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
634 a->setEnabled (false);
635 actionListBranches.append(a);
636 actionAddBranchAbove=a;
637 a = new QAction(tr( "Add branch above","Edit menu" ), this);
638 a->setStatusTip ( tr( "Add a branch above selection" ));
639 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
640 a->setShortcutContext (Qt::WindowShortcut);
642 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
643 actionListBranches.append(a);
646 a = new QAction(tr( "Add branch below","Edit menu" ), this);
647 a->setStatusTip ( tr( "Add a branch below selection" ));
648 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
649 a->setShortcutContext (Qt::WindowShortcut);
651 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
652 a->setEnabled (false);
653 actionListBranches.append(a);
654 actionAddBranchBelow=a;
655 a = new QAction(tr( "Add branch below","Edit menu" ), this);
656 a->setStatusTip ( tr( "Add a branch below selection" ));
657 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
658 a->setShortcutContext (Qt::WindowShortcut);
660 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
661 actionListBranches.append(a);
663 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
664 a->setStatusTip ( tr( "Move branch up" ) );
665 a->setShortcut (Qt::Key_PageUp ); // Move branch up
666 a->setEnabled (false);
668 editMenu->addAction (a);
669 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
672 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
673 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
674 a->setStatusTip (tr( "Move branch down" ) );
675 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
676 a->setEnabled (false);
678 editMenu->addAction (a);
681 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
682 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
683 a->setEnabled (true);
685 editMenu->addAction (a);
686 actionSortChildren=a;
688 a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
689 a->setShortcut ( Qt::Key_ScrollLock );
690 a->setStatusTip (tr( "Scroll branch" ) );
691 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
693 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
694 alt->setShortcut ( Qt::Key_S ); // Scroll branch
695 alt->setStatusTip (tr( "Scroll branch" ));
696 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
697 #if defined(Q_OS_MACX)
698 actionToggleScroll=alt;
700 actionToggleScroll=a;
702 actionToggleScroll->setEnabled (false);
703 actionToggleScroll->setToggleAction(true);
704 tb->addAction (actionToggleScroll);
705 editMenu->addAction ( actionToggleScroll);
706 editMenu->addAction (actionToggleScroll);
709 actionListBranches.append(actionToggleScroll);
711 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
712 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
713 editMenu->addAction (a);
714 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
716 editMenu->addSeparator();
718 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
719 a->setStatusTip (tr( "Find" ) );
720 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
721 editMenu->addAction (a);
722 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) );
724 editMenu->addSeparator();
726 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
727 a->setShortcut (Qt::CTRL + Qt::Key_U );
728 a->setShortcut (tr( "Open URL" ));
731 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
734 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
735 a->setStatusTip (tr( "Open URL in new tab" ));
736 //a->setShortcut (Qt::CTRL+Qt::Key_U );
738 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
741 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
742 a->setStatusTip (tr( "Open all URLs in subtree" ));
744 actionListBranches.append(a);
745 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
746 actionOpenMultipleURLTabs=a;
748 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
749 a->setStatusTip ( tr( "Edit URL" ) );
750 a->setShortcut ( Qt::Key_U );
751 a->setShortcutContext (Qt::WindowShortcut);
752 actionListBranches.append(a);
754 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
757 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
758 a->setStatusTip ( tr( "Edit local URL" ) );
759 a->setShortcut (Qt::SHIFT + Qt::Key_U );
760 a->setShortcutContext (Qt::WindowShortcut);
761 actionListBranches.append(a);
763 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
766 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
767 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
768 a->setEnabled (false);
769 actionListBranches.append(a);
770 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
773 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
774 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
775 a->setEnabled (false);
776 actionListBranches.append(a);
777 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
778 actionBugzilla2URL=a;
780 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
781 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
782 a->setEnabled (false);
783 actionListBranches.append(a);
784 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
787 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
788 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
790 a->setEnabled (false);
791 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
794 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
795 a->setStatusTip ( tr( "Open all vym links in subtree" ));
796 a->setEnabled (false);
797 actionListBranches.append(a);
798 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
799 actionOpenMultipleVymLinks=a;
802 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
803 a->setEnabled (false);
804 a->setStatusTip ( tr( "Edit link to another vym map" ));
805 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
806 actionListBranches.append(a);
809 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
810 a->setStatusTip ( tr( "Delete link to another vym map" ));
811 a->setEnabled (false);
812 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
813 actionDeleteVymLink=a;
815 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
816 a->setStatusTip ( tr( "Hide object in exports" ) );
817 a->setShortcut (Qt::Key_H );
818 a->setToggleAction(true);
820 a->setEnabled (false);
821 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
822 actionToggleHideExport=a;
824 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
825 a->setStatusTip ( tr( "Edit Map Info" ));
826 a->setEnabled (true);
827 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
830 // Import at selection (adding to selection)
831 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
832 a->setStatusTip (tr( "Add map at selection" ));
833 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
834 a->setEnabled (false);
835 actionListBranches.append(a);
838 // Import at selection (replacing selection)
839 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
840 a->setStatusTip (tr( "Replace selection with map" ));
841 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
842 a->setEnabled (false);
843 actionListBranches.append(a);
844 actionImportReplace=a;
847 a = new QAction( tr( "Save selection","Edit menu" ), this);
848 a->setStatusTip (tr( "Save selection" ));
849 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
850 a->setEnabled (false);
851 actionListBranches.append(a);
854 // Only remove branch, not its children
855 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
856 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
857 a->setShortcut (Qt::ALT + Qt::Key_Delete );
858 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
859 a->setEnabled (false);
861 actionListBranches.append(a);
862 actionDeleteKeepChildren=a;
864 // Only remove children of a branch
865 a = new QAction( tr( "Remove children","Edit menu" ), this);
866 a->setStatusTip (tr( "Remove children of branch" ));
867 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
868 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
869 a->setEnabled (false);
870 actionListBranches.append(a);
871 actionDeleteChildren=a;
873 // Shortcuts for navigating with cursor:
874 a = new QAction(tr( "Select upper branch","Edit menu" ), this);
875 a->setStatusTip ( tr( "Select upper branch" ));
876 a->setShortcut (Qt::Key_Up );
877 a->setShortcutContext (Qt::WindowShortcut);
879 connect( a, SIGNAL( triggered() ), this, SLOT( editUpperBranch() ) );
880 a = new QAction( tr( "Select lower branch","Edit menu" ),this);
881 a->setStatusTip (tr( "Select lower branch" ));
882 a->setShortcut ( Qt::Key_Down );
883 a->setShortcutContext (Qt::WindowShortcut);
885 connect( a, SIGNAL( triggered() ), this, SLOT( editLowerBranch() ) );
886 a = new QAction(tr( "Select left branch","Edit menu" ), this);
887 a->setStatusTip ( tr( "Select left branch" ));
888 a->setShortcut (Qt::Key_Left );
889 a->setShortcutContext (Qt::WindowShortcut);
891 connect( a, SIGNAL( triggered() ), this, SLOT( editLeftBranch() ) );
892 a = new QAction( tr( "Select child branch","Edit menu" ), this);
893 a->setStatusTip (tr( "Select right branch" ));
894 a->setShortcut (Qt::Key_Right);
895 a->setShortcutContext (Qt::WindowShortcut);
897 connect( a, SIGNAL( triggered() ), this, SLOT( editRightBranch() ) );
898 a = new QAction( tr( "Select first branch","Edit menu" ), this);
899 a->setStatusTip (tr( "Select first branch" ));
900 a->setShortcut (Qt::Key_Home );
901 a->setShortcutContext (Qt::WindowShortcut);
903 a->setEnabled (false);
904 editMenu->addAction (a);
905 actionListBranches.append(a);
907 connect( a, SIGNAL( triggered() ), this, SLOT( editFirstBranch() ) );
908 a = new QAction( tr( "Select last branch","Edit menu" ),this);
909 a->setStatusTip (tr( "Select last branch" ));
910 a->setShortcut ( Qt::Key_End );
911 a->setShortcutContext (Qt::WindowShortcut);
913 connect( a, SIGNAL( triggered() ), this, SLOT( editLastBranch() ) );
914 a->setEnabled (false);
915 editMenu->addAction (a);
916 actionListBranches.append(a);
919 a = new QAction( tr( "Add Image...","Edit menu" ), this);
920 a->setStatusTip (tr( "Add Image" ));
921 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
924 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
925 a->setStatusTip (tr( "Set properties for selection" ));
926 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
927 a->setShortcutContext (Qt::WindowShortcut);
928 a->setToggleAction (true);
930 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
931 actionViewTogglePropertyWindow=a;
935 void Main::setupFormatActions()
937 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
939 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
940 tb->setObjectName ("formatTB");
943 pix.fill (Qt::black);
944 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
945 a->setStatusTip ( tr( "Set Color" ));
946 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
948 formatMenu->addAction (a);
950 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
951 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
952 a->setShortcut (Qt::CTRL + Qt::Key_K );
953 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
954 a->setEnabled (false);
956 formatMenu->addAction (a);
957 actionListBranches.append(a);
958 actionFormatPickColor=a;
960 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
961 a->setStatusTip ( tr( "Color branch" ) );
962 a->setShortcut (Qt::CTRL + Qt::Key_B);
963 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
964 a->setEnabled (false);
966 formatMenu->addAction (a);
967 actionListBranches.append(a);
968 actionFormatColorSubtree=a;
970 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
971 a->setStatusTip ( tr( "Color Subtree" ));
972 a->setShortcut (Qt::CTRL + Qt::Key_T);
973 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
974 a->setEnabled (false);
975 formatMenu->addAction (a);
977 actionListBranches.append(a);
978 actionFormatColorSubtree=a;
980 formatMenu->addSeparator();
981 actionGroupFormatLinkStyles=new QActionGroup ( this);
982 actionGroupFormatLinkStyles->setExclusive (true);
983 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
984 a->setStatusTip (tr( "Line" ));
985 a->setToggleAction(true);
986 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
987 formatMenu->addAction (a);
988 actionFormatLinkStyleLine=a;
989 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
990 a->setStatusTip (tr( "Line" ));
991 a->setToggleAction(true);
992 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
993 formatMenu->addAction (a);
994 actionFormatLinkStyleParabel=a;
995 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
996 a->setStatusTip (tr( "PolyLine" ));
997 a->setToggleAction(true);
998 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
999 formatMenu->addAction (a);
1000 actionFormatLinkStylePolyLine=a;
1001 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1002 a->setStatusTip (tr( "PolyParabel" ) );
1003 a->setToggleAction(true);
1004 a->setChecked (true);
1005 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1006 formatMenu->addAction (a);
1007 actionFormatLinkStylePolyParabel=a;
1009 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1010 a->setStatusTip (tr( "Hide link" ));
1011 a->setToggleAction(true);
1012 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1013 actionFormatHideLinkUnselected=a;
1015 formatMenu->addSeparator();
1016 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1017 a->setStatusTip (tr( "Use same color for links and headings" ));
1018 a->setToggleAction(true);
1019 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1020 formatMenu->addAction (a);
1021 actionFormatLinkColorHint=a;
1023 pix.fill (Qt::white);
1024 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1025 a->setStatusTip (tr( "Set Link Color" ));
1026 formatMenu->addAction (a);
1027 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1028 actionFormatLinkColor=a;
1030 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1031 a->setStatusTip (tr( "Set Selection Color" ));
1032 formatMenu->addAction (a);
1033 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1034 actionFormatSelectionColor=a;
1036 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1037 a->setStatusTip (tr( "Set Background Color" ));
1038 formatMenu->addAction (a);
1039 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1040 actionFormatBackColor=a;
1042 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1043 a->setStatusTip (tr( "Set Background image" ));
1044 formatMenu->addAction (a);
1045 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1046 actionFormatBackImage=a;
1050 void Main::setupViewActions()
1052 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1053 tb->setLabel( "View Actions" );
1054 tb->setObjectName ("viewTB");
1055 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1058 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1059 a->setStatusTip ( tr( "Zoom reset" ) );
1060 a->setShortcut (Qt::CTRL + Qt::Key_0 );
1062 viewMenu->addAction (a);
1063 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1065 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1066 a->setStatusTip (tr( "Zoom in" ));
1067 a->setShortcut (Qt::CTRL + Qt::Key_Plus);
1069 viewMenu->addAction (a);
1070 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1072 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1073 a->setStatusTip (tr( "Zoom out" ));
1074 a->setShortcut (Qt::CTRL + Qt::Key_Minus );
1076 viewMenu->addAction (a);
1077 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1079 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1080 a->setStatusTip (tr( "Show selection" ));
1081 a->setShortcut (Qt::Key_Period);
1083 viewMenu->addAction (a);
1084 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1086 viewMenu->addSeparator();
1088 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1089 a->setStatusTip ( tr( "Show Note Editor" ));
1090 a->setShortcut ( Qt::CTRL + Qt::Key_E );
1091 a->setToggleAction(true);
1093 viewMenu->addAction (a);
1094 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1095 actionViewToggleNoteEditor=a;
1097 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1098 a->setStatusTip ( tr( "Show History Window" ));
1099 a->setShortcut ( Qt::CTRL + Qt::Key_H );
1100 a->setToggleAction(true);
1102 viewMenu->addAction (a);
1103 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1104 actionViewToggleHistoryWindow=a;
1106 viewMenu->addAction (actionViewTogglePropertyWindow);
1108 viewMenu->addSeparator();
1110 a = new QAction(tr( "Antialiasing","View action" ),this );
1111 a->setStatusTip ( tr( "Antialiasing" ));
1112 a->setToggleAction(true);
1113 a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1114 viewMenu->addAction (a);
1115 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1116 actionViewToggleAntiAlias=a;
1118 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1119 a->setStatusTip (a->text());
1120 a->setToggleAction(true);
1121 a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1122 viewMenu->addAction (a);
1123 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1124 actionViewToggleSmoothPixmapTransform=a;
1126 a = new QAction(tr( "Next Map","View action" ), this);
1127 a->setStatusTip (a->text());
1128 a->setShortcut (Qt::ALT + Qt::Key_N );
1129 viewMenu->addAction (a);
1130 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1132 a = new QAction (tr( "Previous Map","View action" ), this );
1133 a->setStatusTip (a->text());
1134 a->setShortcut (Qt::ALT + Qt::Key_P );
1135 viewMenu->addAction (a);
1136 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1140 void Main::setupModeActions()
1142 //QPopupMenu *menu = new QPopupMenu( this );
1143 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1145 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1146 tb->setObjectName ("modesTB");
1148 actionGroupModModes=new QActionGroup ( this);
1149 actionGroupModModes->setExclusive (true);
1150 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1151 a->setShortcut (Qt::Key_J);
1152 a->setStatusTip ( tr( "Use modifier to color branches" ));
1153 a->setToggleAction(true);
1156 actionModModeColor=a;
1158 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1159 a->setShortcut( Qt::Key_K);
1160 a->setStatusTip( tr( "Use modifier to copy" ));
1161 a->setToggleAction(true);
1163 actionModModeCopy=a;
1165 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1166 a->setShortcut (Qt::Key_L);
1167 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1168 a->setToggleAction(true);
1170 actionModModeXLink=a;
1174 void Main::setupFlagActions()
1176 // Create System Flags
1180 systemFlagsDefault = new FlagRowObj ();
1181 systemFlagsDefault->setVisibility (false);
1182 systemFlagsDefault->setName ("systemFlagsDef");
1184 FlagObj *fo = new FlagObj ();
1185 fo->load(QPixmap(flagsPath+"flag-note.png"));
1186 setupFlag (fo,tb,avis,"note",tr("Note","SystemFlag"));
1188 fo->load(QPixmap(flagsPath+"flag-url.png"));
1189 setupFlag (fo,tb,avis,"url",tr("URL to Document ","SystemFlag"));
1191 fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
1192 setupFlag (fo,tb,avis,"vymLink",tr("Link to another vym map","SystemFlag"));
1194 fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1195 setupFlag (fo,tb,avis,"scrolledright",tr("subtree is scrolled","SystemFlag"));
1197 fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1198 setupFlag (fo,tb,avis,"tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag"));
1200 fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
1201 setupFlag (fo,tb,avis,"hideInExport",tr("Hide object in exported maps","SystemFlag"));
1203 // Create Standard Flags
1204 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1205 tb->setObjectName ("standardFlagTB");
1207 standardFlagsDefault = new FlagRowObj ();
1208 standardFlagsDefault->setVisibility (false);
1209 standardFlagsDefault->setName ("standardFlagsDef");
1210 standardFlagsDefault->setToolBar (tb);
1212 fo->load(flagsPath+"flag-exclamationmark.png");
1213 fo->setGroup("standard-mark");
1214 setupFlag (fo,tb,avis,"exclamationmark",tr("Take care!","Standardflag"));
1216 fo->load(flagsPath+"flag-questionmark.png");
1217 fo->setGroup("standard-mark");
1218 setupFlag (fo,tb,avis,"questionmark",tr("Really?","Standardflag"));
1220 fo->load(flagsPath+"flag-hook-green.png");
1221 fo->setGroup("standard-hook");
1222 setupFlag (fo,tb,avis,"hook-green",tr("ok!","Standardflag"));
1224 fo->load(flagsPath+"flag-cross-red.png");
1225 fo->setGroup("standard-hook");
1226 setupFlag (fo,tb,avis,"cross-red",tr("Not ok!","Standardflag"));
1229 fo->load(flagsPath+"flag-stopsign.png");
1230 setupFlag (fo,tb,avis,"stopsign",tr("This won't work!","Standardflag"));
1232 fo->load(flagsPath+"flag-smiley-good.png");
1233 fo->setGroup("standard-smiley");
1234 setupFlag (fo,tb,avis,"smiley-good",tr("Good","Standardflag"));
1236 fo->load(flagsPath+"flag-smiley-sad.png");
1237 fo->setGroup("standard-smiley");
1238 setupFlag (fo,tb,avis,"smiley-sad",tr("Bad","Standardflag"));
1240 fo->load(flagsPath+"flag-smiley-omg.png");
1241 fo->setGroup("standard-smiley");
1242 setupFlag (fo,tb,avis,"smiley-omb",tr("Oh no!","Standardflag"));
1243 // Original omg.png (in KDE emoticons)
1246 fo->load(flagsPath+"flag-kalarm.png");
1247 setupFlag (fo,tb,avis,"clock",tr("Time critical","Standardflag"));
1249 fo->load(flagsPath+"flag-phone.png");
1250 setupFlag (fo,tb,avis,"phone",tr("Call...","Standardflag"));
1252 fo->load(flagsPath+"flag-lamp.png");
1253 setupFlag (fo,tb,avis,"lamp",tr("Idea!","Standardflag"));
1255 fo->load(flagsPath+"flag-arrow-up.png");
1256 fo->setGroup("standard-arrow");
1257 setupFlag (fo,tb,avis,"arrow-up",tr("Important","Standardflag"));
1259 fo->load(flagsPath+"flag-arrow-down.png");
1260 fo->setGroup("standard-arrow");
1261 setupFlag (fo,tb,avis,"arrow-down",tr("Unimportant","Standardflag"));
1263 fo->load(flagsPath+"flag-arrow-2up.png");
1264 fo->setGroup("standard-arrow");
1265 setupFlag (fo,tb,avis,"2arrow-up",tr("Very important!","Standardflag"));
1267 fo->load(flagsPath+"flag-arrow-2down.png");
1268 fo->setGroup("standard-arrow");
1269 setupFlag (fo,tb,avis,"2arrow-down",tr("Very unimportant!","Standardflag"));
1272 fo->load(flagsPath+"flag-thumb-up.png");
1273 fo->setGroup("standard-thumb");
1274 setupFlag (fo,tb,avis,"thumb-up",tr("I like this","Standardflag"));
1276 fo->load(flagsPath+"flag-thumb-down.png");
1277 fo->setGroup("standard-thumb");
1278 setupFlag (fo,tb,avis,"thumb-down",tr("I do not like this","Standardflag"));
1281 fo->load(flagsPath+"flag-rose.png");
1282 setupFlag (fo,tb,avis,"rose",tr("Rose","Standardflag"));
1284 fo->load(flagsPath+"flag-heart.png");
1285 setupFlag (fo,tb,avis,"heart",tr("I just love...","Standardflag"));
1287 fo->load(flagsPath+"flag-present.png");
1288 setupFlag (fo,tb,avis,"present",tr("Surprise!","Standardflag"));
1290 fo->load(flagsPath+"flag-flash.png");
1291 setupFlag (fo,tb,avis,"flash",tr("Dangerous","Standardflag"));
1293 // Original: xsldbg_output.png
1294 fo->load(flagsPath+"flag-info.png");
1295 setupFlag (fo,tb,avis,"info",tr("Info","Standardflag"));
1297 // Original khelpcenter.png
1298 fo->load(flagsPath+"flag-lifebelt.png");
1299 setupFlag (fo,tb,avis,"lifebelt",tr("This will help","Standardflag"));
1305 fo->load(flagsPath+"freemind/warning.png");
1306 setupFlag (fo,tb, avis, "freemind-warning",tr("Important","Freemind-Flag"));
1308 for (int i=1; i<8; i++)
1310 fo->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1311 setupFlag (fo,tb, avis,QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1314 fo->load(flagsPath+"freemind/back.png");
1315 setupFlag (fo,tb,avis,"freemind-back",tr("Back","Freemind-Flag"));
1317 fo->load(flagsPath+"freemind/forward.png");
1318 setupFlag (fo,tb,avis,"freemind-forward",tr("Forward","Freemind-Flag"));
1320 fo->load(flagsPath+"freemind/attach.png");
1321 setupFlag (fo,tb,avis,"freemind-attach",tr("Look here","Freemind-Flag"));
1323 fo->load(flagsPath+"freemind/clanbomber.png");
1324 setupFlag (fo,tb,avis,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1326 fo->load(flagsPath+"freemind/desktopnew.png");
1327 setupFlag (fo,tb,avis,"freemind-desktopnew",tr("Don't forget","Freemind-Flag"));
1329 fo->load(flagsPath+"freemind/flag.png");
1330 setupFlag (fo,tb,avis,"freemind-flag",tr("Flag","Freemind-Flag"));
1333 fo->load(flagsPath+"freemind/gohome.png");
1334 setupFlag (fo,tb,avis,"freemind-gohome",tr("Home","Freemind-Flag"));
1337 fo->load(flagsPath+"freemind/kaddressbook.png");
1338 setupFlag (fo,tb,avis,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1340 fo->load(flagsPath+"freemind/knotify.png");
1341 setupFlag (fo,tb,avis,"freemind-knotify",tr("Music","Freemind-Flag"));
1343 fo->load(flagsPath+"freemind/korn.png");
1344 setupFlag (fo,tb,avis,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1346 fo->load(flagsPath+"freemind/mail.png");
1347 setupFlag (fo,tb,avis,"freemind-mail",tr("Maix","Freemind-Flag"));
1349 fo->load(flagsPath+"freemind/password.png");
1350 setupFlag (fo,tb,avis,"freemind-password",tr("Password","Freemind-Flag"));
1352 fo->load(flagsPath+"freemind/pencil.png");
1353 setupFlag (fo,tb,avis,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1355 fo->load(flagsPath+"freemind/stop.png");
1356 setupFlag (fo,tb,avis,"freemind-stop",tr("Stop","Freemind-Flag"));
1358 fo->load(flagsPath+"freemind/wizard.png");
1359 setupFlag (fo,tb,avis,"freemind-wizard",tr("Magic","Freemind-Flag"));
1361 fo->load(flagsPath+"freemind/xmag.png");
1362 setupFlag (fo,tb,avis,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1364 fo->load(flagsPath+"freemind/bell.png");
1365 setupFlag (fo,tb,avis,"freemind-bell",tr("Reminder","Freemind-Flag"));
1367 fo->load(flagsPath+"freemind/bookmark.png");
1368 setupFlag (fo,tb,avis,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1370 fo->load(flagsPath+"freemind/penguin.png");
1371 setupFlag (fo,tb,avis,"freemind-penguin",tr("Linux","Freemind-Flag"));
1373 fo->load(flagsPath+"freemind/licq.png");
1374 setupFlag (fo,tb,avis,"freemind-licq",tr("Sweet","Freemind-Flag"));
1379 void Main::setupFlag (FlagObj *fo, QToolBar *tb, bool aw, const QString &name, const QString &tooltip)
1382 fo->setToolTip (tooltip);
1383 QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
1389 fo->setAlwaysVisible(aw);
1390 a->setCheckable(true);
1391 a->setObjectName(fo->getName());
1392 a->setToolTip(tooltip);
1393 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1394 standardFlagsDefault->addFlag (fo);
1398 systemFlagsDefault->addFlag (fo);
1402 void Main::setupNetworkActions()
1404 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1406 QMenu *netMenu = menuBar()->addMenu( "Network" );
1410 a = new QAction( "Start TCPserver for MapEditor",this);
1411 //a->setStatusTip ( "Set application to open pdf files"));
1412 a->setShortcut ( Qt::Key_T ); //New TCP server
1413 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1414 netMenu->addAction (a);
1416 a = new QAction( "Connect MapEditor to server",this);
1417 //a->setStatusTip ( "Set application to open pdf files"));
1418 a->setShortcut ( Qt::Key_C ); // Connect to server
1419 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1420 netMenu->addAction (a);
1424 void Main::setupSettingsActions()
1426 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1430 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1431 a->setStatusTip ( tr( "Set application to open pdf files"));
1432 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1433 settingsMenu->addAction (a);
1435 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1436 a->setStatusTip( tr( "Set application to open external links"));
1437 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1438 settingsMenu->addAction (a);
1440 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1441 a->setStatusTip( tr( "Set path for macros"));
1442 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1443 settingsMenu->addAction (a);
1445 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1446 a->setStatusTip( tr( "Set number of undo levels"));
1447 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1448 settingsMenu->addAction (a);
1450 settingsMenu->addSeparator();
1452 a = new QAction( tr( "Autosave","Settings action"), this);
1453 a->setStatusTip( tr( "Autosave"));
1454 a->setToggleAction(true);
1455 a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
1456 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1457 settingsMenu->addAction (a);
1458 actionSettingsAutosaveToggle=a;
1460 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1461 a->setStatusTip( tr( "Autosave time"));
1462 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1463 settingsMenu->addAction (a);
1464 actionSettingsAutosaveTime=a;
1466 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1467 a->setStatusTip( tr( "Write backup file on save"));
1468 a->setToggleAction(true);
1469 a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1470 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1471 settingsMenu->addAction (a);
1472 actionSettingsWriteBackupFile=a;
1474 settingsMenu->addSeparator();
1476 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1477 a->setStatusTip( tr( "Edit branch after adding it" ));
1478 a->setToggleAction(true);
1479 a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1480 settingsMenu->addAction (a);
1481 actionSettingsAutoEditNewBranch=a;
1483 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1484 a->setStatusTip( tr( "Select branch after adding it" ));
1485 a->setToggleAction(true);
1486 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1487 settingsMenu->addAction (a);
1488 actionSettingsAutoSelectNewBranch=a;
1490 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1491 a->setStatusTip( tr( "Select heading before editing" ));
1492 a->setToggleAction(true);
1493 a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1494 settingsMenu->addAction (a);
1495 actionSettingsAutoSelectText=a;
1497 a= new QAction( tr( "Delete key","Settings action" ), this);
1498 a->setStatusTip( tr( "Delete key for deleting branches" ));
1499 a->setToggleAction(true);
1500 a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1501 settingsMenu->addAction (a);
1502 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1503 actionSettingsUseDelKey=a;
1505 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1506 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1507 a->setToggleAction(true);
1508 a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1509 settingsMenu->addAction (a);
1510 actionSettingsUseFlagGroups=a;
1512 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1513 a->setStatusTip( tr( "Use hide flag during exports " ));
1514 a->setToggleAction(true);
1515 a->setOn ( settings.value ("/export/useHideExport",true).toBool() );
1516 settingsMenu->addAction (a);
1517 actionSettingsUseHideExport=a;
1519 a = new QAction( tr( "Animation","Settings action"), this);
1520 a->setStatusTip( tr( "Animation"));
1521 a->setToggleAction(true);
1522 a->setOn (settings.value("/animation/use",false).toBool() );
1523 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1524 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1526 settingsMenu->addAction (a);
1528 actionSettingsUseAnimation=a;
1532 void Main::setupTestActions()
1534 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1537 a = new QAction( "Test function 1" , this);
1538 a->setStatusTip( "Call test function 1" );
1539 testMenu->addAction (a);
1540 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1542 a = new QAction( "Test function 2" , this);
1543 a->setStatusTip( "Call test function 2" );
1544 testMenu->addAction (a);
1545 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1547 a = new QAction( "Command" , this);
1548 a->setStatusTip( "Enter command to call in editor" );
1549 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1550 testMenu->addAction (a);
1554 void Main::setupHelpActions()
1556 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1559 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1560 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1561 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1562 helpMenu->addAction (a);
1564 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1565 a->setStatusTip( tr( "Open VYM example maps " ));
1566 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1567 helpMenu->addAction (a);
1569 a = new QAction( tr( "About VYM","Help action" ), this);
1570 a->setStatusTip( tr( "About VYM")+vymName);
1571 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1572 helpMenu->addAction (a);
1574 a = new QAction( tr( "About QT","Help action" ), this);
1575 a->setStatusTip( tr( "Information about QT toolkit" ));
1576 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1577 helpMenu->addAction (a);
1581 void Main::setupContextMenus()
1585 // Context Menu for branch or mapcenter
1586 branchContextMenu =new QMenu (this);
1587 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1588 branchContextMenu->addSeparator();
1591 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1592 branchAddContextMenu->addAction (actionPaste );
1593 branchAddContextMenu->addAction ( actionAddBranch );
1594 branchAddContextMenu->addAction ( actionAddBranchBefore );
1595 branchAddContextMenu->addAction ( actionAddBranchAbove);
1596 branchAddContextMenu->addAction ( actionAddBranchBelow );
1597 branchAddContextMenu->addSeparator();
1598 branchAddContextMenu->addAction ( actionImportAdd );
1599 branchAddContextMenu->addAction ( actionImportReplace );
1602 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1603 branchRemoveContextMenu->addAction (actionCut);
1604 branchRemoveContextMenu->addAction ( actionDelete );
1605 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1606 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1609 actionSaveBranch->addTo( branchContextMenu );
1610 actionFileNewCopy->addTo (branchContextMenu );
1612 branchContextMenu->addSeparator();
1613 branchContextMenu->addAction ( actionLoadImage);
1615 // Submenu for Links (URLs, vymLinks)
1616 branchLinksContextMenu =new QMenu (this);
1618 branchContextMenu->addSeparator();
1619 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1620 branchLinksContextMenu->addAction ( actionOpenURL );
1621 branchLinksContextMenu->addAction ( actionOpenURLTab );
1622 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1623 branchLinksContextMenu->addAction ( actionURL );
1624 branchLinksContextMenu->addAction ( actionLocalURL );
1625 branchLinksContextMenu->addAction ( actionHeading2URL );
1626 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1627 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1629 branchLinksContextMenu->addAction ( actionFATE2URL );
1631 branchLinksContextMenu->addSeparator();
1632 branchLinksContextMenu->addAction ( actionOpenVymLink );
1633 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1634 branchLinksContextMenu->addAction ( actionVymLink );
1635 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1638 // Context Menu for XLinks in a branch menu
1639 // This will be populated "on demand" in MapEditor::updateActions
1640 branchContextMenu->addSeparator();
1641 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1642 branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name"));
1643 connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) );
1644 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1647 // Context menu for floatimage
1648 floatimageContextMenu =new QMenu (this);
1649 a= new QAction (tr ("Save image","Context action"),this);
1650 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1651 floatimageContextMenu->addAction (a);
1653 floatimageContextMenu->addSeparator();
1654 actionCopy->addTo( floatimageContextMenu );
1655 actionCut->addTo( floatimageContextMenu );
1657 floatimageContextMenu->addSeparator();
1658 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1661 // Context menu for canvas
1662 canvasContextMenu =new QMenu (this);
1663 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1664 actionAddMapCenter->addTo( canvasContextMenu );
1665 actionMapInfo->addTo( canvasContextMenu );
1666 canvasContextMenu->insertSeparator();
1667 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1668 canvasContextMenu->insertSeparator();
1669 actionFormatLinkColorHint->addTo( canvasContextMenu );
1670 actionFormatLinkColor->addTo( canvasContextMenu );
1671 actionFormatSelectionColor->addTo( canvasContextMenu );
1672 actionFormatBackColor->addTo( canvasContextMenu );
1673 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1675 // Menu for last opened files
1677 for (int i = 0; i < MaxRecentFiles; ++i)
1679 recentFileActions[i] = new QAction(this);
1680 recentFileActions[i]->setVisible(false);
1681 fileLastMapsMenu->addAction(recentFileActions[i]);
1682 connect(recentFileActions[i], SIGNAL(triggered()),
1683 this, SLOT(fileLoadRecent()));
1685 setupRecentMapsMenu();
1688 void Main::setupRecentMapsMenu()
1690 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1692 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1694 for (int i = 0; i < numRecentFiles; ++i) {
1695 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1696 recentFileActions[i]->setText(text);
1697 recentFileActions[i]->setData(files[i]);
1698 recentFileActions[i]->setVisible(true);
1700 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1701 recentFileActions[j]->setVisible(false);
1704 void Main::setupMacros()
1706 for (int i = 0; i <= 11; i++)
1708 macroActions[i] = new QAction(this);
1709 macroActions[i]->setData(i);
1710 addAction (macroActions[i]);
1711 connect(macroActions[i], SIGNAL(triggered()),
1712 this, SLOT(callMacro()));
1714 macroActions[0]->setShortcut ( Qt::Key_F1 );
1715 macroActions[1]->setShortcut ( Qt::Key_F2 );
1716 macroActions[2]->setShortcut ( Qt::Key_F3 );
1717 macroActions[3]->setShortcut ( Qt::Key_F4 );
1718 macroActions[4]->setShortcut ( Qt::Key_F5 );
1719 macroActions[5]->setShortcut ( Qt::Key_F6 );
1720 macroActions[6]->setShortcut ( Qt::Key_F7 );
1721 macroActions[7]->setShortcut ( Qt::Key_F8 );
1722 macroActions[8]->setShortcut ( Qt::Key_F9 );
1723 macroActions[9]->setShortcut ( Qt::Key_F10 );
1724 macroActions[10]->setShortcut ( Qt::Key_F11 );
1725 macroActions[11]->setShortcut ( Qt::Key_F12 );
1728 void Main::hideEvent (QHideEvent * )
1730 if (!textEditor->isMinimized() ) textEditor->hide();
1733 void Main::showEvent (QShowEvent * )
1735 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1739 MapEditor* Main::currentMapEditor() const
1741 if ( tabWidget->currentPage())
1742 return tabModel.at(tabWidget->currentIndex())->getMapEditor();
1746 VymModel* Main::currentModel() const
1748 if ( tabWidget->currentPage())
1749 return tabModel.at(tabWidget->currentIndex());
1754 void Main::editorChanged(QWidget *)
1756 // Unselect all possibly selected objects
1757 // (Important to update note editor)
1758 for (int i=0;i<=tabWidget->count() -1;i++)
1760 tabModel.at(i)->unselect();
1762 VymModel *m=currentModel();
1763 if (m) m->reselect();
1765 // Update actions to in menus and toolbars according to editor
1769 VymView *Main::createView (VymModel *model)
1771 VymView *vm=new VymView (model);
1776 void Main::fileNew()
1778 VymModel *m=new VymModel;
1779 tabModel.append (m);
1780 //MapEditor* me = new MapEditor (m);
1781 //me->setObjectName ("MapEditor");
1783 VymView *view=createView (m);
1784 tabWidget->addTab (view,tr("unnamed","MainWindow: name for new and empty file"));
1785 tabWidget->setCurrentIndex (tabModel.count() );
1787 // For the very first map we do not have flagrows yet...
1791 void Main::fileNewCopy()
1793 QString fn="unnamed";
1794 VymModel *srcModel=currentModel();
1799 VymModel *dstModel=tabModel.last ();
1800 dstModel->select("mc:");
1801 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1805 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1807 ErrorCode err=success;
1809 // fn is usually the archive, mapfile the file after uncompressing
1812 // Make fn absolute (needed for unzip)
1813 fn=QDir (fn).absPath();
1819 // Check, if map is already loaded
1821 while (i<=tabWidget->count() -1)
1823 if (tabModel.at(i)->getFilePath() == fn)
1825 // Already there, ask for confirmation
1826 QMessageBox mb( vymName,
1827 tr("The map %1\nis already opened."
1828 "Opening the same map in multiple editors may lead \n"
1829 "to confusion when finishing working with vym."
1830 "Do you want to").arg(fn),
1831 QMessageBox::Warning,
1832 QMessageBox::Yes | QMessageBox::Default,
1833 QMessageBox::Cancel | QMessageBox::Escape,
1834 QMessageBox::NoButton);
1835 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1836 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1839 case QMessageBox::Yes:
1840 // end loop and load anyway
1841 i=tabWidget->count();
1843 case QMessageBox::Cancel:
1853 int tabIndex=tabWidget->currentPageIndex();
1856 if ( !fn.isEmpty() )
1858 vm = currentModel();
1859 // Check first, if mapeditor exists
1860 // If it is not default AND we want a new map,
1861 // create a new mapeditor in a new tab
1862 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1865 tabModel.append (vm);
1866 VymView *view=createView (vm);
1867 tabWidget->addTab (view,fn);
1868 tabIndex=tabWidget->count()-1;
1869 tabWidget->setCurrentPage (tabIndex);
1872 // Check, if file exists (important for creating new files
1873 // from command line
1874 if (!QFile(fn).exists() )
1876 QMessageBox mb( vymName,
1877 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1878 QMessageBox::Question,
1880 QMessageBox::Cancel | QMessageBox::Default,
1881 QMessageBox::NoButton );
1883 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1884 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1887 case QMessageBox::Yes:
1889 currentMapEditor()->getModel()->setFilePath(fn);
1890 tabWidget->setTabText (tabIndex,
1891 currentMapEditor()->getModel()->getFileName() );
1892 statusBar()->message( "Created " + fn , statusbarTime );
1895 case QMessageBox::Cancel:
1896 // don't create new map
1897 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1904 //tabWidget->currentPage() won't be NULL here, because of above...
1905 tabWidget->setCurrentIndex (tabIndex);
1906 //FIXME-3 no me anymore... me->viewport()->setFocus();
1910 // Save existing filename in case we import
1911 QString fn_org=vm->getFilePath();
1913 // Finally load map into mapEditor
1914 vm->setFilePath (fn);
1915 err=vm->load(fn,lmode,ftype);
1917 // Restore old (maybe empty) filepath, if this is an import
1919 vm->setFilePath (fn_org);
1922 // Finally check for errors and go home
1925 if (lmode==NewMap) fileCloseMap();
1926 statusBar()->message( "Could not load " + fn, statusbarTime );
1931 vm->setFilePath (fn);
1932 tabWidget->setTabText (tabIndex, vm->getFileName());
1933 if (!isInTmpDir (fn))
1935 // Only append to lastMaps if not loaded from a tmpDir
1936 // e.g. imported bookmarks are in a tmpDir
1937 addRecentMap(vm->getFilePath() );
1939 actionFilePrint->setEnabled (true);
1941 statusBar()->message( "Loaded " + fn, statusbarTime );
1948 void Main::fileLoad(const LoadMode &lmode)
1950 QStringList filters;
1951 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1952 QFileDialog *fd=new QFileDialog( this);
1953 fd->setDir (lastFileDir);
1954 fd->setFileMode (QFileDialog::ExistingFiles);
1955 fd->setFilters (filters);
1959 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1962 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1965 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
1971 if ( fd->exec() == QDialog::Accepted )
1973 lastFileDir=fd->directory().path();
1974 QStringList flist = fd->selectedFiles();
1975 QStringList::Iterator it = flist.begin();
1976 while( it != flist.end() )
1979 fileLoad(*it, lmode);
1986 void Main::fileLoad()
1991 void Main::fileLoadRecent()
1993 QAction *action = qobject_cast<QAction *>(sender());
1995 fileLoad (action->data().toString(), NewMap);
1998 void Main::addRecentMap (const QString &fileName)
2001 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2002 files.removeAll(fileName);
2003 files.prepend(fileName);
2004 while (files.size() > MaxRecentFiles)
2007 settings.setValue("/mainwindow/recentFileList", files);
2009 setupRecentMapsMenu();
2012 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2016 if ( m->getFilePath().isEmpty() )
2018 // We have no filepath yet,
2019 // call fileSaveAs() now, this will call fileSave()
2021 // First switch to editor
2022 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2023 fileSaveAs(savemode);
2026 if (m->save (savemode)==success)
2028 statusBar()->message(
2029 tr("Saved %1").arg(m->getFilePath()),
2031 addRecentMap (m->getFilePath() );
2033 statusBar()->message(
2034 tr("Couldn't save ").arg(m->getFilePath()),
2038 void Main::fileSave()
2040 fileSave (currentModel(), CompleteMap);
2043 void Main::fileSave(VymModel *m)
2045 fileSave (m,CompleteMap);
2048 void Main::fileSaveAs(const SaveMode& savemode)
2052 if (currentMapEditor())
2054 if (savemode==CompleteMap)
2055 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2057 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2058 if ( !fn.isEmpty() )
2060 // Check for existing file
2061 if (QFile (fn).exists())
2063 QMessageBox mb( vymName,
2064 tr("The file %1\nexists already. Do you want to").arg(fn),
2065 QMessageBox::Warning,
2066 QMessageBox::Yes | QMessageBox::Default,
2067 QMessageBox::Cancel | QMessageBox::Escape,
2068 QMessageBox::NoButton);
2069 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2070 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2073 case QMessageBox::Yes:
2076 case QMessageBox::Cancel:
2083 // New file, add extension to filename, if missing
2084 // This is always .vym or .vyp, depending on savemode
2085 if (savemode==CompleteMap)
2087 if (!fn.contains (".vym") && !fn.contains (".xml"))
2091 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2100 VymModel *m=currentModel();
2102 fileSave(m, savemode);
2104 // Set name of tab, assuming current tab is the one we just saved
2105 if (savemode==CompleteMap)
2106 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2112 void Main::fileSaveAs()
2114 fileSaveAs (CompleteMap);
2117 void Main::fileImportKDE3Bookmarks()
2119 ImportKDE3Bookmarks im;
2121 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2122 currentMapEditor()->getModel()->setFilePath ("");
2125 void Main::fileImportKDE4Bookmarks()
2127 ImportKDE4Bookmarks im;
2129 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2130 currentMapEditor()->getModel()->setFilePath ("");
2133 void Main::fileImportFirefoxBookmarks()
2135 Q3FileDialog *fd=new Q3FileDialog( this);
2136 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2137 fd->setMode (Q3FileDialog::ExistingFiles);
2138 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2139 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2142 if ( fd->exec() == QDialog::Accepted )
2144 ImportFirefoxBookmarks im;
2145 QStringList flist = fd->selectedFiles();
2146 QStringList::Iterator it = flist.begin();
2147 while( it != flist.end() )
2150 if (im.transform() &&
2151 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2152 currentMapEditor() )
2153 currentMapEditor()->getModel()->setFilePath ("");
2160 void Main::fileImportFreemind()
2162 QStringList filters;
2163 filters <<"Freemind map (*.mm)"<<"All files (*)";
2164 QFileDialog *fd=new QFileDialog( this);
2165 fd->setDir (lastFileDir);
2166 fd->setFileMode (QFileDialog::ExistingFiles);
2167 fd->setFilters (filters);
2168 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2172 if ( fd->exec() == QDialog::Accepted )
2174 lastFileDir=fd->directory().path();
2175 QStringList flist = fd->selectedFiles();
2176 QStringList::Iterator it = flist.begin();
2177 while( it != flist.end() )
2180 if ( fileLoad (fn,NewMap, FreemindMap) )
2182 currentMapEditor()->getModel()->setFilePath ("");
2191 void Main::fileImportMM()
2195 Q3FileDialog *fd=new Q3FileDialog( this);
2196 fd->setDir (lastFileDir);
2197 fd->setMode (Q3FileDialog::ExistingFiles);
2198 fd->addFilter ("Mind Manager (*.mmap)");
2199 fd->setCaption(tr("Import")+" "+"Mind Manager");
2202 if ( fd->exec() == QDialog::Accepted )
2204 lastFileDir=fd->dirPath();
2205 QStringList flist = fd->selectedFiles();
2206 QStringList::Iterator it = flist.begin();
2207 while( it != flist.end() )
2210 if (im.transform() &&
2211 success==fileLoad (im.getTransformedFile(),NewMap) &&
2212 currentMapEditor() )
2213 currentMapEditor()->getModel()->setFilePath ("");
2220 void Main::fileImportDir()
2222 VymModel *m=currentModel();
2223 if (m) m->importDir();
2226 void Main::fileExportXML()
2228 VymModel *m=currentModel();
2229 if (m) m->exportXML();
2233 void Main::fileExportXHTML()
2235 VymModel *m=currentModel();
2236 if (m) m->exportXHTML();
2239 void Main::fileExportImage()
2241 VymModel *m=currentModel();
2242 if (m) m->exportImage();
2245 void Main::fileExportASCII()
2247 VymModel *m=currentModel();
2248 if (m) m->exportASCII();
2251 void Main::fileExportCSV() //FIXME-2 not scriptable yet
2253 VymModel *m=currentModel();
2258 ex.addFilter ("CSV (*.csv)");
2259 ex.setDir(lastImageDir);
2260 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2261 if (ex.execDialog() )
2263 m->setExportMode(true);
2265 m->setExportMode(false);
2270 void Main::fileExportLaTeX() //FIXME-2 not scriptable yet
2272 VymModel *m=currentModel();
2277 ex.addFilter ("Tex (*.tex)");
2278 ex.setDir(lastImageDir);
2279 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2280 if (ex.execDialog() )
2282 m->setExportMode(true);
2284 m->setExportMode(false);
2289 void Main::fileExportKDE3Bookmarks() //FIXME-2 not scriptable yet
2291 ExportKDE3Bookmarks ex;
2292 VymModel *m=currentModel();
2300 void Main::fileExportKDE4Bookmarks() //FIXME-2 not scriptable yet
2302 ExportKDE4Bookmarks ex;
2303 VymModel *m=currentModel();
2311 void Main::fileExportTaskjuggler() //FIXME-2 not scriptable yet
2313 ExportTaskjuggler ex;
2314 VymModel *m=currentModel();
2318 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2319 ex.setDir(lastImageDir);
2320 ex.addFilter ("Taskjuggler (*.tjp)");
2321 if (ex.execDialog() )
2323 m->setExportMode(true);
2325 m->setExportMode(false);
2330 void Main::fileExportOOPresentation() //FIXME-2 not scriptable yet
2332 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2333 // TODO add preview in dialog
2334 //ImagePreview *p =new ImagePreview (fd);
2335 //fd->setContentsPreviewEnabled( TRUE );
2336 //fd->setContentsPreview( p, p );
2337 //fd->setPreviewMode( QFileDialog::Contents );
2338 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2339 fd->setDir (QDir().current());
2340 if (fd->foundConfig())
2344 if ( fd->exec() == QDialog::Accepted )
2346 QString fn=fd->selectedFile();
2347 if (!fn.contains (".odp"))
2350 //lastImageDir=fn.left(fn.findRev ("/"));
2351 VymModel *m=currentModel();
2352 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2356 QMessageBox::warning(0,
2358 tr("Couldn't find configuration for export to Open Office\n"));
2362 void Main::fileCloseMap()
2364 MapEditor *me = currentMapEditor();
2365 VymModel *m=currentModel();
2368 if (m->hasChanged())
2370 QMessageBox mb( vymName,
2371 tr("The map %1 has been modified but not saved yet. Do you want to").arg(me->getModel()->getFileName()),
2372 QMessageBox::Warning,
2373 QMessageBox::Yes | QMessageBox::Default,
2375 QMessageBox::Cancel | QMessageBox::Escape );
2376 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2377 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2380 case QMessageBox::Yes:
2382 fileSave(m, CompleteMap);
2384 case QMessageBox::No:
2385 // close without saving
2387 case QMessageBox::Cancel:
2392 tabModel.removeAt (tabWidget->currentIndex() );
2393 tabWidget->removeTab (tabWidget->currentIndex() );
2395 // Remove mapEditor;
2396 // Better would be delete (me), but then we could have a Qt error:
2397 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2398 // So we only remove data now and call deconstructor when vym closes later
2399 // FIXME-3 this needs to be moved to vymview... me->clear();
2400 // some model->clear is needed to free up memory ...
2406 void Main::filePrint()
2408 if (currentMapEditor())
2409 currentMapEditor()->print();
2412 void Main::fileExitVYM()
2414 // Check if one or more editors have changed
2416 for (i=0;i<=tabModel.count() -1;i++)
2418 // If something changed, ask what to do
2419 if (tabModel.at(i)->hasChanged())
2421 tabWidget->setCurrentPage(i);
2422 QMessageBox mb( vymName,
2423 tr("This map is not saved yet. Do you want to"),
2424 QMessageBox::Warning,
2425 QMessageBox::Yes | QMessageBox::Default,
2427 QMessageBox::Cancel | QMessageBox::Escape );
2428 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2429 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2432 mb.setActiveWindow();
2433 switch( mb.exec() ) {
2434 case QMessageBox::Yes:
2435 // save (the changed editors) and exit
2436 fileSave(currentModel(), CompleteMap);
2438 case QMessageBox::No:
2439 // exit without saving
2441 case QMessageBox::Cancel:
2442 // don't save and don't exit
2446 } // loop over all MEs
2450 void Main::editUndo()
2452 VymModel *m=currentModel();
2456 void Main::editRedo()
2458 VymModel *m=currentModel();
2462 void Main::gotoHistoryStep (int i)
2464 VymModel *m=currentModel();
2465 if (m) m->gotoHistoryStep(i);
2468 void Main::editCopy()
2470 VymModel *m=currentModel();
2474 void Main::editPaste()
2476 VymModel *m=currentModel();
2480 void Main::editCut()
2482 VymModel *m=currentModel();
2486 void Main::editOpenFindWindow()
2488 findWindow->popup();
2489 findWindow->raise();
2490 findWindow->setActiveWindow();
2493 void Main::editFind(QString s)
2495 VymModel *m=currentModel();
2499 BranchObj *bo=m->findText(s, cs);
2502 statusBar()->message( "Found: " + bo->getHeading(), statusbarTime );
2505 QMessageBox::information( findWindow, tr( "VYM -Information:" ),
2506 tr("No matches found for \"%1\"").arg(s));
2511 void Main::editFindChanged()
2512 { // Notify editor, to abort the current find process
2513 VymModel *m=currentModel();
2514 if (m) m->findReset();
2517 void Main::openTabs(QStringList urls)
2519 if (!urls.isEmpty())
2523 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2525 if (!procBrowser || procBrowser->state()!=QProcess::Running)
2527 QString u=urls.takeFirst();
2528 procBrowser = new QProcess( this );
2530 procBrowser->start(browser,args);
2531 if ( !procBrowser->waitForStarted())
2533 // try to set path to browser
2534 QMessageBox::warning(0,
2536 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2537 tr("Please use Settings->")+tr("Set application to open an URL"));
2540 #if defined(Q_OS_WIN32)
2541 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2542 this->thread()->wait(3000);
2547 if (browser.contains("konqueror"))
2549 for (int i=0; i<urls.size(); i++)
2552 // Try to open new tab in existing konqueror started previously by vym
2553 p=new QProcess (this);
2555 #if defined(Q_OS_WIN32)
2556 // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
2557 // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
2558 args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
2559 "konqueror-mainwindow#1"<<
2563 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2564 "konqueror-mainwindow#1"<<
2568 p->start ("dcop",args);
2569 if (debug) cout << "MainWindo::openURLs args="<<args.join(" ").toStdString()<<endl;
2570 if ( !p->waitForStarted() ) success=false;
2573 QMessageBox::warning(0,
2575 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2577 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2579 for (int i=0; i<urls.size(); i++)
2581 // Try to open new tab in firefox
2582 p=new QProcess (this);
2583 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2584 p->start (browser,args);
2585 if ( !p->waitForStarted() ) success=false;
2588 QMessageBox::warning(0,
2590 tr("Couldn't start %1 to open a new tab").arg(browser));
2593 QMessageBox::warning(0,
2595 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2599 void Main::editOpenURL()
2602 VymModel *m=currentModel();
2605 QString url=m->getURL();
2607 if (url=="") return;
2608 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2609 procBrowser = new QProcess( this );
2611 procBrowser->start(browser,args);
2612 if ( !procBrowser->waitForStarted())
2614 // try to set path to browser
2615 QMessageBox::warning(0,
2617 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2618 tr("Please use Settings->")+tr("Set application to open an URL"));
2623 void Main::editOpenURLTab()
2625 VymModel *m=currentModel();
2629 urls.append(m->getURL());
2633 void Main::editOpenMultipleURLTabs()
2635 VymModel *m=currentModel();
2645 void Main::editURL()
2647 VymModel *m=currentModel();
2648 if (m) m->editURL();
2651 void Main::editLocalURL()
2653 VymModel *m=currentModel();
2654 if (m) m->editLocalURL();
2657 void Main::editHeading2URL()
2659 VymModel *m=currentModel();
2660 if (m) m->editHeading2URL();
2663 void Main::editBugzilla2URL()
2665 VymModel *m=currentModel();
2666 if (m) m->editBugzilla2URL();
2669 void Main::editFATE2URL()
2671 VymModel *m=currentModel();
2672 if (m) m->editFATE2URL();
2675 void Main::editHeadingFinished(VymModel *m)
2679 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2680 !prevSelection.isEmpty())
2681 m->select(prevSelection);
2687 void Main::editAttributeFinished()
2689 // only called from editHeading(), so there is a currentME
2692 MapEditor *me=currentMapEditor();
2695 me->setStateEditHeading (false);
2696 QPoint p; //Not used here, only to find out pos of branch
2698 QString s=me->getHeading(ok,p);
2700 #if defined(Q_OS_MACX)
2702 if (ok && s!=lineedit->text())
2703 me->setHeading(lineedit->text());
2705 lineedit->releaseKeyboard();
2709 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2710 !prevSelection.isEmpty())
2711 me->select(prevSelection);
2717 #include "attribute.h"
2718 #include "attributedialog.h"
2719 void Main::editAttribute()
2722 MapEditor *me=currentMapEditor();
2725 BranchObj *bo=me->getModel()->getSelectedBranch();
2728 AttributeDialog dia(this);
2729 dia.setTable (me->attributeTable() );
2731 dia.setMode (Definition);
2738 if (currentMapEditor())
2740 MapEditor *me=currentMapEditor();
2741 QString oldSel=me->getSelectString();
2743 if (lineedit->isVisible())
2744 editAttributeFinished();
2749 QString s=me->getHeading(ok,p);
2753 me->setStateEditHeading (true);
2754 #if defined(Q_OS_MACX)
2755 p=me->mapToGlobal (p);
2756 QDialog *d =new QDialog(NULL);
2757 QLineEdit *le=new QLineEdit (d);
2758 d->setWindowFlags (Qt::FramelessWindowHint);
2759 d->setGeometry(p.x(),p.y(),230,25);
2760 le->resize (d->width()-10,d->height());
2763 connect (le, SIGNAL (returnPressed()), d, SLOT (accept()));
2764 d->activateWindow();
2766 me->setHeading (le->text());
2769 editHeadingFinished();
2771 p=me->mapTo (this,p);
2772 lineedit->setGeometry(p.x(),p.y(),230,25);
2773 lineedit->setText(s);
2774 lineedit->setCursorPosition(1);
2775 lineedit->selectAll();
2777 lineedit->grabKeyboard();
2778 lineedit->setFocus();
2782 } // currentMapEditor()
2787 void Main::openVymLinks(const QStringList &vl)
2789 for (int j=0; j<vl.size(); j++)
2791 // compare path with already loaded maps
2794 for (i=0;i<=tabModel.count() -1;i++)
2796 if (vl.at(j)==tabModel.at(i)->getFilePath() )
2805 if (!QFile(vl.at(j)).exists() )
2806 QMessageBox::critical( 0, tr( "Critical Error" ),
2807 tr("Couldn't open map %1").arg(vl.at(j)));
2810 fileLoad (vl.at(j), NewMap);
2811 tabWidget->setCurrentIndex (tabWidget->count()-1);
2814 // Go to tab containing the map
2815 tabWidget->setCurrentIndex (index);
2819 void Main::editOpenVymLink()
2821 VymModel *m=currentModel();
2825 vl.append(m->getVymLink());
2830 void Main::editOpenMultipleVymLinks()
2832 QString currentVymLink;
2833 VymModel *m=currentModel();
2836 QStringList vl=m->getVymLinks();
2841 void Main::editVymLink()
2843 VymModel *m=currentModel();
2848 void Main::editDeleteVymLink()
2850 VymModel *m=currentModel();
2851 if (m) m->deleteVymLink();
2854 void Main::editToggleHideExport()
2856 VymModel *m=currentModel();
2857 if (m) m->toggleHideExport();
2860 void Main::editMapInfo()
2862 VymModel *m=currentModel();
2864 ExtraInfoDialog dia;
2865 dia.setMapName (m->getFileName() );
2866 dia.setAuthor (m->getAuthor() );
2867 dia.setComment(m->getComment() );
2871 /* FIXME-2 no stats at the moment (view dependent...)
2872 stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
2882 if (!bo->getNote().isEmpty() ) n++;
2883 f+= bo->countFloatImages();
2885 xl+=bo->countXLinks();
2888 stats+=QString ("%1 xLinks \n").arg (xl,6);
2889 stats+=QString ("%1 notes\n").arg (n,6);
2890 stats+=QString ("%1 images\n").arg (f,6);
2892 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2893 dia.setStats (stats);
2895 // Finally show dialog
2896 if (dia.exec() == QDialog::Accepted)
2898 m->setAuthor (dia.getAuthor() );
2899 m->setComment (dia.getComment() );
2903 void Main::editMoveUp()
2905 VymModel *m=currentModel();
2906 if (m) m->moveBranchUp();
2909 void Main::editMoveDown()
2911 VymModel *m=currentModel();
2912 if (m) m->moveBranchDown();
2915 void Main::editSortChildren()
2917 VymModel *m=currentModel();
2918 if (m) m->sortChildren();
2921 void Main::editToggleScroll()
2923 VymModel *m=currentModel();
2924 if (m) m->toggleScroll();
2927 void Main::editUnscrollChildren()
2929 VymModel *m=currentModel();
2930 if (m) m->unscrollChildren();
2933 void Main::editAddMapCenter()
2935 VymModel *m=currentModel();
2942 void Main::editNewBranch()
2944 VymModel *m=currentModel();
2947 BranchObj *bo=m->getSelectedBranch();
2948 prevSelection=m->getSelectString(bo);
2949 BranchObj *newbo=m->addNewBranch(0);
2956 if (actionSettingsAutoEditNewBranch->isOn())
2958 currentMapEditor()->editHeading();
2961 if (!prevSelection.isEmpty())
2963 m->select(prevSelection);
2969 void Main::editNewBranchBefore()
2971 VymModel *m=currentModel();
2974 BranchObj *bo=m->getSelectedBranch();
2975 BranchObj *newbo=m->addNewBranchBefore();
2982 if (actionSettingsAutoEditNewBranch->isOn())
2984 if (!actionSettingsAutoSelectNewBranch->isOn())
2985 prevSelection=m->getSelectString(bo);
2986 currentMapEditor()->editHeading();
2991 void Main::editNewBranchAbove()
2993 VymModel *m=currentModel();
2996 BranchObj *bo=m->getSelectedBranch();
2997 BranchObj *newbo=m->addNewBranch (-1);
3004 if (actionSettingsAutoEditNewBranch->isOn())
3006 if (!actionSettingsAutoSelectNewBranch->isOn())
3007 prevSelection=m->getSelectString (bo);
3008 currentMapEditor()->editHeading();
3013 void Main::editNewBranchBelow()
3015 VymModel *m=currentModel();
3018 BranchObj *bo=m->getSelectedBranch();
3019 BranchObj *newbo=m->addNewBranch (1);
3026 if (actionSettingsAutoEditNewBranch->isOn())
3028 if (!actionSettingsAutoSelectNewBranch->isOn())
3029 prevSelection=m->getSelectString(bo);
3030 currentMapEditor()->editHeading();
3035 void Main::editImportAdd()
3037 fileLoad (ImportAdd);
3040 void Main::editImportReplace()
3042 fileLoad (ImportReplace);
3045 void Main::editSaveBranch()
3047 fileSaveAs (PartOfMap);
3050 void Main::editDeleteKeepChildren()
3052 VymModel *m=currentModel();
3053 if (m) m->deleteKeepChildren();
3056 void Main::editDeleteChildren()
3058 VymModel *m=currentModel();
3059 if (m) m->deleteChildren();
3062 void Main::editDeleteSelection()
3064 VymModel *m=currentModel();
3065 if (m && actionSettingsUseDelKey->isOn())
3066 m->deleteSelection();
3069 void Main::editUpperBranch()
3071 VymModel *m=currentModel();
3072 if (m) m->selectUpperBranch();
3075 void Main::editLowerBranch()
3077 VymModel *m=currentModel();
3078 if (m) m->selectLowerBranch();
3081 void Main::editLeftBranch()
3083 VymModel *m=currentModel();
3084 if (m) m->selectLeftBranch();
3087 void Main::editRightBranch()
3089 VymModel *m=currentModel();
3090 if (m) m->selectRightBranch();
3093 void Main::editFirstBranch()
3095 VymModel *m=currentModel();
3096 if (m) m->selectFirstBranch();
3099 void Main::editLastBranch()
3101 VymModel *m=currentModel();
3102 if (m) m->selectLastBranch();
3105 void Main::editLoadImage()
3107 VymModel *m=currentModel();
3108 if (m) m->loadFloatImage();
3111 void Main::editSaveImage()
3113 VymModel *m=currentModel();
3114 if (m) m->saveFloatImage();
3117 void Main::editFollowXLink(QAction *a)
3120 VymModel *m=currentModel();
3122 m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a));
3125 void Main::editEditXLink(QAction *a)
3127 VymModel *m=currentModel();
3129 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3132 void Main::formatSelectColor()
3134 QColor col = QColorDialog::getColor((currentColor ), this );
3135 if ( !col.isValid() ) return;
3136 colorChanged( col );
3139 void Main::formatPickColor()
3141 VymModel *m=currentModel();
3143 colorChanged( m->getCurrentHeadingColor() );
3146 void Main::colorChanged(QColor c)
3148 QPixmap pix( 16, 16 );
3150 actionFormatColor->setIconSet( pix );
3154 void Main::formatColorBranch()
3156 VymModel *m=currentModel();
3157 if (m) m->colorBranch(currentColor);
3160 void Main::formatColorSubtree()
3162 VymModel *m=currentModel();
3163 if (m) m->colorSubtree (currentColor);
3166 void Main::formatLinkStyleLine()
3168 VymModel *m=currentModel();
3171 m->setMapLinkStyle("StyleLine");
3172 actionFormatLinkStyleLine->setOn(true);
3176 void Main::formatLinkStyleParabel()
3178 VymModel *m=currentModel();
3181 m->setMapLinkStyle("StyleParabel");
3182 actionFormatLinkStyleParabel->setOn(true);
3186 void Main::formatLinkStylePolyLine()
3188 VymModel *m=currentModel();
3191 m->setMapLinkStyle("StylePolyLine");
3192 actionFormatLinkStylePolyLine->setOn(true);
3196 void Main::formatLinkStylePolyParabel()
3198 VymModel *m=currentModel();
3201 m->setMapLinkStyle("StylePolyParabel");
3202 actionFormatLinkStylePolyParabel->setOn(true);
3206 void Main::formatSelectBackColor()
3208 VymModel *m=currentModel();
3209 if (m) m->selectMapBackgroundColor();
3212 void Main::formatSelectBackImage()
3214 VymModel *m=currentModel();
3216 m->selectMapBackgroundImage();
3219 void Main::formatSelectLinkColor()
3221 VymModel *m=currentModel();
3224 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3225 m->setMapDefLinkColor( col );
3229 void Main::formatSelectSelectionColor()
3231 VymModel *m=currentModel();
3234 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3235 m->setSelectionColor (col);
3240 void Main::formatToggleLinkColorHint()
3242 VymModel *m=currentModel();
3243 if (m) m->toggleMapLinkColorHint();
3247 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3249 VymModel *m=currentModel();
3251 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3254 void Main::viewZoomReset()
3256 if (currentMapEditor())
3260 currentMapEditor()->setMatrix( m );
3264 void Main::viewZoomIn()
3266 if (currentMapEditor())
3268 QMatrix m = currentMapEditor()->matrix();
3269 m.scale( 1.25, 1.25 );
3270 currentMapEditor()->setMatrix( m );
3274 void Main::viewZoomOut()
3276 if (currentMapEditor())
3278 QMatrix m = currentMapEditor()->matrix();
3279 m.scale( 0.8, 0.8 );
3280 currentMapEditor()->setMatrix( m );
3284 void Main::viewCenter()
3286 VymModel *m=currentModel();
3287 if (m) m->ensureSelectionVisible();
3290 void Main::networkStartServer()
3292 VymModel *m=currentModel();
3293 if (m) m->newServer();
3296 void Main::networkConnect()
3298 VymModel *m=currentModel();
3299 if (m) m->connectToServer();
3302 bool Main::settingsPDF()
3304 // Default browser is set in constructor
3306 QString text = QInputDialog::getText(
3307 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3308 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3310 settings.setValue ("/mainwindow/readerPDF",text);
3315 bool Main::settingsURL()
3317 // Default browser is set in constructor
3319 QString text = QInputDialog::getText(
3320 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3321 settings.value("/mainwindow/readerURL").toString()
3324 settings.setValue ("/mainwindow/readerURL",text);
3328 void Main::settingsMacroDir()
3330 QDir defdir(vymBaseDir.path() + "/macros");
3331 if (!defdir.exists())
3333 QDir dir=QFileDialog::getExistingDirectory (
3335 tr ("Directory with vym macros:"),
3336 settings.value ("/macros/macroDir",defdir.path()).toString()
3339 settings.setValue ("/macros/macroDir",dir.absolutePath());
3342 void Main::settingsUndoLevels()
3345 int i = QInputDialog::getInteger(
3347 tr("QInputDialog::getInteger()"),
3348 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3351 settings.setValue ("/mapeditor/stepsTotal",i);
3352 QMessageBox::information( this, tr( "VYM -Information:" ),
3353 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3357 void Main::settingsAutosaveToggle()
3359 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3362 void Main::settingsAutosaveTime()
3365 int i = QInputDialog::getInteger(
3367 tr("QInputDialog::getInteger()"),
3368 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3370 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3373 void Main::settingsWriteBackupFileToggle()
3375 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3378 void Main::settingsToggleAnimation()
3380 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3383 void Main::settingsToggleDelKey()
3385 if (actionSettingsUseDelKey->isOn())
3387 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3390 actionDelete->setAccel (QKeySequence (""));
3394 void Main::windowToggleNoteEditor()
3396 if (textEditor->isVisible() )
3397 windowHideNoteEditor();
3399 windowShowNoteEditor();
3402 void Main::windowToggleHistory()
3404 if (historyWindow->isVisible())
3405 historyWindow->hide();
3407 historyWindow->show();
3411 void Main::windowToggleProperty()
3413 if (branchPropertyWindow->isVisible())
3414 branchPropertyWindow->hide();
3416 branchPropertyWindow->show();
3417 branchPropertyWindow->setModel (currentModel() );
3420 void Main::windowToggleAntiAlias()
3422 bool b=actionViewToggleAntiAlias->isOn();
3424 for (int i=0;i<tabModel.count();i++)
3426 me=tabModel.at(i)->getMapEditor();
3427 if (me) me->setAntiAlias(b);
3432 bool Main::isAliased()
3434 return actionViewToggleAntiAlias->isOn();
3437 bool Main::hasSmoothPixmapTransform()
3439 return actionViewToggleSmoothPixmapTransform->isOn();
3442 void Main::windowToggleSmoothPixmap()
3444 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3446 for (int i=0;i<tabModel.count();i++)
3449 me=tabModel.at(i)->getMapEditor();
3450 if (me) me->setSmoothPixmap(b);
3454 void Main::updateHistory(SimpleSettings &undoSet)
3456 historyWindow->update (undoSet);
3459 void Main::updateNoteFlag()
3461 // this slot is connected to TextEditor::textHasChanged()
3463 VymModel *m=currentModel();
3464 if (m) m->updateNoteFlag();
3468 void Main::updateNoteInEditor (VymModel *model, const NoteObj ¬e)
3470 if (model&& model==currentModel() )
3472 textEditor->setNote (note);
3477 void Main::updateContent (QModelIndex index )
3479 cout << "Main::updateContent model="<<sender();
3480 TreeItem *ti=((VymModel*)sender())->getItem(index);
3481 cout << " item="<<ti->getHeading().toStdString()<<" ("<<ti<<")"<<endl;
3482 textEditor->setNote (ti->getNoteObj() );
3485 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3487 //branchPropertyWindow->setModel (model ); //FIXME-1 this used to be called from BranchObj::select()
3489 if (model && model==currentModel() )
3493 if (!oldsel.indexes().isEmpty() )
3495 ti=model->getItem(oldsel.indexes().first());
3496 //cout << "Main::changeSel getting note from "<<ti->getHeading().toStdString()<<": \""<<ti->getNote().toStdString()<<"\""<<endl;
3497 ti->setNoteObj (textEditor->getNoteObj(),false );
3499 if (!newsel.indexes().isEmpty() )
3501 ti=model->getItem(newsel.indexes().first());
3502 if (!ti->getNoteObj().isEmpty() )
3504 //cout << "Main::changeSel setting note of "<<ti->getHeading().toStdString()<<" m=("<<ti->getModel()<<") to \""<<ti->getNote().toStdString()<<"\""<<endl;
3505 textEditor->setNote(ti->getNoteObj() );
3507 textEditor->setNote(NoteObj() );
3510 textEditor->setInactive();
3513 // Show URL and link in statusbar
3515 QString s=model->getURL();
3516 if (!s.isEmpty() ) status+="URL: "+s+" ";
3517 s=model->getVymLink();
3518 if (!s.isEmpty() ) status+="Link: "+s;
3519 if (!status.isEmpty() ) statusMessage (status);
3522 // Update Toolbar // FIXME-1, was so far in BranchObj
3523 //updateFlagsToolbar();
3530 void Main::updateActions()
3532 VymModel *m =currentModel();
3533 LinkableMapObj *selection;
3537 actionFilePrint->setEnabled (true);
3540 selection=m->getSelectedLMO();
3542 // Link style in context menu
3543 switch (m->getMapLinkStyle())
3545 case LinkableMapObj::Line:
3546 actionFormatLinkStyleLine->setOn(true);
3548 case LinkableMapObj::Parabel:
3549 actionFormatLinkStyleParabel->setOn(true);
3551 case LinkableMapObj::PolyLine:
3552 actionFormatLinkStylePolyLine->setOn(true);
3554 case LinkableMapObj::PolyParabel:
3555 actionFormatLinkStylePolyParabel->setOn(true);
3562 QPixmap pix( 16, 16 );
3563 pix.fill( m->getMapBackgroundColor() );
3564 actionFormatBackColor->setIconSet( pix );
3565 pix.fill( m->getSelectionColor() );
3566 actionFormatSelectionColor->setIconSet( pix );
3567 pix.fill( m->getMapDefLinkColor() );
3568 actionFormatLinkColor->setIconSet( pix );
3571 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3576 actionFilePrint->setEnabled (false);
3582 // updateActions is also called when NoteEditor is closed
3583 actionViewToggleNoteEditor->setOn (textEditor->isVisible());
3584 actionViewToggleHistoryWindow->setOn (historyWindow->isVisible());
3585 actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible());
3587 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3588 actionFormatLinkColorHint->setOn(true);
3590 actionFormatLinkColorHint->setOn(false);
3593 if (m && m->hasChanged() )
3594 actionFileSave->setEnabled( true);
3596 actionFileSave->setEnabled( true);
3597 if (m && m->isUndoAvailable())
3598 actionUndo->setEnabled( true);
3600 actionUndo->setEnabled( false);
3602 if (m && m->isRedoAvailable())
3603 actionRedo->setEnabled( true);
3605 actionRedo->setEnabled( false);
3609 if ( (typeid(*selection) == typeid(BranchObj)) ||
3610 (typeid(*selection) == typeid(MapCenterObj)) )
3612 BranchItem *bi=(BranchItem*)(selection->getTreeItem() );
3613 BranchObj *bo=(BranchObj*)selection;
3614 // Take care of links // FIXME-1
3616 if (bo->countXLinks()==0)
3618 branchXLinksContextMenuEdit->clear();
3619 branchXLinksContextMenuFollow->clear();
3624 branchXLinksContextMenuEdit->clear();
3625 branchXLinksContextMenuFollow->clear();
3626 for (int i=0; i<=bo->countXLinks();i++)
3628 bot=bo->XLinkTargetAt(i);
3631 s=bot->getHeading();
3632 if (s.length()>xLinkMenuWidth)
3633 s=s.left(xLinkMenuWidth)+"...";
3634 branchXLinksContextMenuFollow->addAction (s);
3635 branchXLinksContextMenuEdit->addAction (s);
3641 standardFlagsDefault->setEnabled (true);
3643 actionToggleScroll->setEnabled (true);
3644 if ( bi->isScrolled() )
3645 actionToggleScroll->setOn(true);
3647 actionToggleScroll->setOn(false);
3649 if ( bo->getURL().isEmpty() )
3651 actionOpenURL->setEnabled (false);
3652 actionOpenURLTab->setEnabled (false);
3656 actionOpenURL->setEnabled (true);
3657 actionOpenURLTab->setEnabled (true);
3659 if ( bo->getVymLink().isEmpty() )
3661 actionOpenVymLink->setEnabled (false);
3662 actionDeleteVymLink->setEnabled (false);
3665 actionOpenVymLink->setEnabled (true);
3666 actionDeleteVymLink->setEnabled (true);
3669 if (bo->canMoveBranchUp())
3670 actionMoveUp->setEnabled (true);
3672 actionMoveUp->setEnabled (false);
3673 if (bo->canMoveBranchDown())
3674 actionMoveDown->setEnabled (true);
3676 actionMoveDown->setEnabled (false);
3678 actionSortChildren->setEnabled (true);
3680 actionToggleHideExport->setEnabled (true);
3681 actionToggleHideExport->setOn (bo->hideInExport() );
3683 actionFileSave->setEnabled (true);
3684 actionCopy->setEnabled (true);
3685 actionCut->setEnabled (true);
3686 if (!clipboardEmpty)
3687 actionPaste->setEnabled (true);
3689 actionPaste->setEnabled (false);
3690 for (int i=0; i<actionListBranches.size(); ++i)
3691 actionListBranches.at(i)->setEnabled(true);
3692 actionDelete->setEnabled (true);
3693 actionFormatHideLinkUnselected->setOn
3694 (selection->getHideLinkUnselected());
3696 if ( (typeid(*selection) == typeid(FloatImageObj)) )
3698 FloatObj *fo=(FloatImageObj*)selection;
3700 actionOpenURL->setEnabled (false);
3701 actionOpenVymLink->setEnabled (false);
3702 actionDeleteVymLink->setEnabled (false);
3703 actionToggleHideExport->setEnabled (true);
3704 actionToggleHideExport->setOn (fo->hideInExport() );
3707 actionCopy->setEnabled (true);
3708 actionCut->setEnabled (true);
3709 actionPaste->setEnabled (false);
3710 for (int i=0; i<actionListBranches.size(); ++i)
3711 actionListBranches.at(i)->setEnabled(false);
3712 actionDelete->setEnabled (true);
3713 actionFormatHideLinkUnselected->setOn
3714 ( selection->getHideLinkUnselected());
3715 actionMoveUp->setEnabled (false);
3716 actionMoveDown->setEnabled (false);
3721 standardFlagsDefault->setEnabled (false);
3722 actionFileSave->setEnabled (false);
3723 actionCopy->setEnabled (false);
3724 actionCut->setEnabled (false);
3725 actionPaste->setEnabled (false);
3726 for (int i=0; i<actionListBranches.size(); ++i)
3727 actionListBranches.at(i)->setEnabled(false);
3729 actionToggleScroll->setEnabled (false);
3730 actionOpenURL->setEnabled (false);
3731 actionOpenVymLink->setEnabled (false);
3732 actionDeleteVymLink->setEnabled (false);
3733 actionHeading2URL->setEnabled (false);
3734 actionDelete->setEnabled (false);
3735 actionMoveUp->setEnabled (false);
3736 actionMoveDown->setEnabled (false);
3737 actionSortChildren->setEnabled (false);
3738 actionToggleHideExport->setEnabled (false);
3742 Main::ModMode Main::getModMode()
3744 if (actionModModeColor->isOn()) return ModModeColor;
3745 if (actionModModeCopy->isOn()) return ModModeCopy;
3746 if (actionModModeXLink->isOn()) return ModModeXLink;
3750 bool Main::autoEditNewBranch()
3752 return actionSettingsAutoEditNewBranch->isOn();
3755 bool Main::autoSelectNewBranch()
3757 return actionSettingsAutoSelectNewBranch->isOn();
3760 bool Main::useFlagGroups()
3762 return actionSettingsUseFlagGroups->isOn();
3765 void Main::windowShowNoteEditor()
3767 textEditor->setShowWithMain(true);
3769 actionViewToggleNoteEditor->setOn (true);
3772 void Main::windowHideNoteEditor()
3774 textEditor->setShowWithMain(false);
3776 actionViewToggleNoteEditor->setOn (false);
3779 void Main::setScript (const QString &script)
3781 scriptEditor->setScript (script);
3784 void Main::runScript (const QString &script)
3786 VymModel *m=currentModel();
3787 if (m) m->runScript (script);
3790 void Main::runScriptEverywhere (const QString &script)
3793 for (int i=0;i<=tabWidget->count() -1;i++)
3795 me=(MapEditor*)tabWidget->page(i);
3796 if (me) me->getModel()->runScript (script);
3800 void Main::windowNextEditor()
3802 if (tabWidget->currentIndex() < tabWidget->count())
3803 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3806 void Main::windowPreviousEditor()
3808 if (tabWidget->currentIndex() >0)
3809 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3812 void Main::standardFlagChanged()
3814 if (currentMapEditor())
3815 currentMapEditor()->toggleStandardFlag(sender()->name());
3818 void Main::testFunction1()
3820 //if (!currentMapEditor()) return;
3821 //currentMapEditor()->testFunction1();
3825 void Main::testFunction2()
3827 if (!currentMapEditor()) return;
3828 currentMapEditor()->testFunction2();
3831 void Main::testCommand()
3833 if (!currentMapEditor()) return;
3834 scriptEditor->show();
3837 QString com = QInputDialog::getText(
3838 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3839 if (ok) currentMapEditor()->parseAtom(com);
3843 void Main::helpDoc()
3845 QString locale = QLocale::system().name();
3847 if (locale.left(2)=="es")
3848 docname="vym_es.pdf";
3852 QStringList searchList;
3854 #if defined(Q_OS_MACX)
3855 searchList << "./vym.app/Contents/Resources/doc";
3856 #elif defined(Q_OS_WIN32)
3857 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3859 #if defined(VYM_DOCDIR)
3860 searchList << VYM_DOCDIR;
3862 // default path in SUSE LINUX
3863 searchList << "/usr/share/doc/packages/vym";
3866 searchList << "doc"; // relative path for easy testing in tarball
3867 searchList << "doc/tex"; // Easy testing working on vym.tex
3868 searchList << "/usr/share/doc/vym"; // Debian
3869 searchList << "/usr/share/doc/packages";// Knoppix
3873 for (int i=0; i<searchList.count(); ++i)
3875 docfile.setFileName(searchList.at(i)+"/"+docname);
3876 if (docfile.exists())
3885 QMessageBox::critical(0,
3886 tr("Critcal error"),
3887 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3892 Process *pdfProc = new Process();
3893 args << QDir::toNativeSeparators(docfile.fileName());
3895 pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args);
3896 if ( !pdfProc->waitForStarted() )
3899 QMessageBox::warning(0,
3901 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3902 tr("Please use Settings->")+tr("Set application to open PDF files"));
3909 void Main::helpDemo()
3911 QStringList filters;
3912 filters <<"VYM example map (*.vym)";
3913 QFileDialog *fd=new QFileDialog( this);
3914 #if defined(Q_OS_MACX)
3915 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3917 // default path in SUSE LINUX
3918 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3921 fd->setFileMode (QFileDialog::ExistingFiles);
3922 fd->setFilters (filters);
3923 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3927 if ( fd->exec() == QDialog::Accepted )
3929 lastFileDir=fd->directory().path();
3930 QStringList flist = fd->selectedFiles();
3931 QStringList::Iterator it = flist.begin();
3932 while( it != flist.end() )
3935 fileLoad(*it, NewMap);
3943 void Main::helpAbout()
3946 ad.setName ("aboutwindow");
3947 ad.setMinimumSize(500,500);
3948 ad.resize (QSize (500,500));
3952 void Main::helpAboutQT()
3954 QMessageBox::aboutQt( this, "Qt Application Example" );
3957 void Main::callMacro ()
3959 QAction *action = qobject_cast<QAction *>(sender());
3963 i=action->data().toInt();
3964 QString mDir (settings.value ("macros/macroDir").toString() );
3966 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3968 if ( !f.open( QIODevice::ReadOnly ) )
3970 QMessageBox::warning(0,
3972 tr("Couldn't find a macro at %1.\n").arg(fn)+
3973 tr("Please use Settings->")+tr("Set directory for vym macros"));
3977 QTextStream ts( &f );
3978 QString macro= ts.read();
3980 if (! macro.isEmpty())
3982 VymModel *m=currentModel();
3983 if (m) m->runScript(macro);