1 #include "mainwindow.h"
8 #include "aboutdialog.h"
9 #include "branchpropwindow.h"
10 #include "branchitem.h"
11 #include "exportoofiledialog.h"
15 #include "historywindow.h"
17 #include "mapeditor.h"
22 #include "shortcuts.h"
23 #include "texteditor.h"
24 #include "warningdialog.h"
25 #include "xlinkitem.h"
27 //#include <modeltest.h> // FIXME-3
29 #if defined(Q_OS_WIN32)
30 // Define only this structure as opposed to
31 // including full 'windows.h'. FindWindow
32 // clashes with the one in Win32 API.
33 typedef struct _PROCESS_INFORMATION
39 } PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
42 extern TextEditor *textEditor;
43 extern Main *mainWindow;
44 extern QString tmpVymDir;
45 extern QString clipboardDir;
46 extern QString clipboardFile;
47 extern bool clipboardEmpty;
48 extern int statusbarTime;
49 extern FlagRow *standardFlagsMaster;
50 extern FlagRow *systemFlagsMaster;
51 extern QString vymName;
52 extern QString vymVersion;
53 extern QString vymBuildDate;
56 QMenu* branchContextMenu;
57 QMenu* branchAddContextMenu;
58 QMenu* branchRemoveContextMenu;
59 QMenu* branchLinksContextMenu;
60 QMenu* branchXLinksContextMenuEdit;
61 QMenu* floatimageContextMenu;
62 QMenu* canvasContextMenu;
63 QMenu* fileLastMapsMenu;
64 QMenu* fileImportMenu;
65 QMenu* fileExportMenu;
68 extern Settings settings;
69 extern Options options;
70 extern ImageIO imageIO;
72 extern QDir vymBaseDir;
73 extern QDir lastImageDir;
74 extern QDir lastFileDir;
75 #if defined(Q_OS_WIN32)
76 extern QDir vymInstallDir;
78 extern QString iconPath;
79 extern QString flagsPath;
82 Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
83 QMainWindow(parent,name,f)
87 setCaption ("VYM - View Your Mind");
89 // Load window settings
90 #if defined(Q_OS_WIN32)
91 if (settings.value("/mainwindow/geometry/maximized", false).toBool())
93 setWindowState(Qt::WindowMaximized);
98 resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize());
99 move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint());
102 // Sometimes we may need to remember old selections
106 currentColor=Qt::black;
108 // Create unique temporary directory
110 tmpVymDir=makeTmpDir (ok,"vym");
113 qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
116 if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) );
118 // Create direcctory for clipboard
119 clipboardDir=tmpVymDir+"/clipboard";
120 clipboardFile="map.xml";
121 QDir d(clipboardDir);
122 d.mkdir (clipboardDir,true);
123 makeSubDirs (clipboardDir);
126 browserPID=new qint64;
129 // Satellite windows //////////////////////////////////////////
131 historyWindow=new HistoryWindow();
132 connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
135 branchPropertyWindow = new BranchPropertyWindow();
136 connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
138 // Connect TextEditor, so that we can update flags if text changes
139 connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
140 connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions()));
142 // Initialize script editor
143 scriptEditor = new SimpleScriptEditor();
144 scriptEditor->move (50,50);
146 connect( scriptEditor, SIGNAL( runScript ( QString ) ),
147 this, SLOT( runScript( QString ) ) );
149 // Initialize some settings, which are platform dependant
152 // application to open URLs
153 p="/mainwindow/readerURL";
154 #if defined(Q_OS_LINUX)
155 s=settings.value (p,"xdg-open").toString();
157 #if defined(Q_OS_MACX)
158 s=settings.value (p,"/usr/bin/open").toString();
161 #if defined(Q_OS_WIN32)
162 // Assume that system has been set up so that
163 // Explorer automagically opens up the URL
164 // in the user's preferred browser.
165 s=settings.value (p,"explorer").toString();
167 s=settings.value (p,"mozilla").toString();
171 settings.setValue( p,s);
173 // application to open PDFs
174 p="/mainwindow/readerPDF";
175 #if defined(Q_OS_LINUX)
176 s=settings.value (p,"xdg-open").toString();
178 #if defined(Q_OS_MACX)
179 s=settings.value (p,"/usr/bin/open").toString();
180 #elif defined(Q_OS_WIN32)
181 s=settings.value (p,"acrord32").toString();
183 s=settings.value (p,"acroread").toString();
186 settings.setValue( p,s);
188 // width of xLinksMenu
191 // Create tab widget which holds the maps
192 tabWidget= new QTabWidget (this);
193 connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ),
194 this, SLOT( editorChanged( QWidget * ) ) );
196 setCentralWidget(tabWidget);
200 setupFormatActions();
204 setupNetworkActions();
205 setupSettingsActions();
208 if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
211 // Status bar and progress bar there
215 progressCounterTotal=0;
217 progressDialog.setLabelText (tr("Loading maps","Mainwindow"));
218 progressDialog.setAutoReset(false);
219 progressDialog.setAutoClose(false);
220 //progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down
221 //progressDialog.setCancelButton (NULL);
223 restoreState (settings.value("/mainwindow/state",0).toByteArray());
231 #if defined(Q_OS_WIN32)
232 settings.setValue ("/mainwindow/geometry/maximized", isMaximized());
234 settings.setValue ("/mainwindow/geometry/size", size());
235 settings.setValue ("/mainwindow/geometry/pos", pos());
236 settings.setValue ("/mainwindow/state",saveState(0));
238 settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
239 settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
240 settings.setValue( "/version/version", vymVersion );
241 settings.setValue( "/version/builddate", vymBuildDate );
243 settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
244 settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
245 settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
246 settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
247 settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() );
248 settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
249 settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
250 settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() );
252 //TODO save scriptEditor settings
254 // call the destructors
256 delete historyWindow;
257 delete branchPropertyWindow;
259 // Remove temporary directory
260 removeDir (QDir(tmpVymDir));
263 void Main::loadCmdLine()
265 /* TODO draw some kind of splashscreen while loading...
271 QStringList flist=options.getFileList();
272 QStringList::Iterator it=flist.begin();
274 progressCounter=flist.count();
275 progressCounterTotal=flist.count();
276 while (it !=flist.end() )
278 fileLoad (*it, NewMap);
284 void Main::statusMessage(const QString &s)
286 // Surpress messages while progressdialog during
289 statusBar()->message( s);
292 void Main::setProgressMaximum (int max)
294 if (progressCounterTotal!=0)
296 progressDialog.setRange (0,progressCounterTotal*1000);
298 progressDialog.setRange (0,max+10);
300 progressDialog.setValue (0);
301 progressMax=max*1000;
302 //cout << "Main max="<<max<<" v="<<progressDialog.value()<<endl;
303 progressDialog.show();
306 void Main::addProgressValue (float v)
308 //cout << "addVal v="<<v*1000<<"/"<<progressMax<<" cur="<<progressDialog.value()<<" counter="<<v+progressCounter<<"/"<<progressCounterTotal<<endl;
309 if (progressCounterTotal!=0)
310 progressDialog.setValue ( (v+progressCounterTotal-progressCounter)*1000 );
312 progressDialog.setValue (v+progressDialog.value());
315 void Main::removeProgressCounter()
319 if (progressCounter<=0)
322 progressCounterTotal=0;
323 progressDialog.reset();
324 progressDialog.hide();
328 void Main::closeEvent (QCloseEvent* )
334 void Main::setupFileActions()
336 QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") );
337 QToolBar *tb = addToolBar( tr ("&Map") );
338 tb->setObjectName ("mapTB");
341 a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this);
342 a->setStatusTip ( tr( "New map","Status tip File menu" ) );
343 a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map
345 fileMenu->addAction (a);
346 connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) );
348 a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this);
349 a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) );
350 a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map
351 fileMenu->addAction (a);
352 connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) );
355 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this);
356 a->setStatusTip (tr( "Open","Status tip File menu" ) );
357 a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map
359 fileMenu->addAction (a);
360 connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) );
362 fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu"));
363 fileMenu->addSeparator();
365 a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this);
366 a->setStatusTip ( tr( "Save","Status tip file menu" ));
367 a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map
369 fileMenu->addAction (a);
370 connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
373 a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this);
374 a->setStatusTip (tr( "Save &As","Status tip file menu" ) );
375 fileMenu->addAction (a);
376 connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) );
378 fileMenu->addSeparator();
380 fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
382 a = new QAction(tr("KDE 3 Bookmarks"), this);
383 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
384 a->addTo (fileImportMenu);
385 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
387 a = new QAction(tr("KDE 4 Bookmarks"), this);
388 a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
389 a->addTo (fileImportMenu);
390 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
392 if (settings.value( "/mainwindow/showTestMenu",false).toBool())
394 a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this);
395 a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) ));
396 a->addTo (fileImportMenu);
397 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) );
400 a = new QAction("Freemind...",this);
401 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") );
402 fileImportMenu->addAction (a);
403 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) );
405 a = new QAction("Mind Manager...",this);
406 a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") );
407 fileImportMenu->addAction (a);
408 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) );
410 a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this);
411 a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) );
412 fileImportMenu->addAction (a);
413 connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) );
415 fileExportMenu = fileMenu->addMenu (tr("Export","File menu"));
417 a = new QAction( tr("Image%1","File export menu").arg("..."), this);
418 a->setStatusTip( tr( "Export map as image","status tip file menu" ));
419 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) );
420 fileExportMenu->addAction (a);
422 a = new QAction( "Open Office...", this);
423 a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" ));
424 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
425 fileExportMenu->addAction (a);
427 a = new QAction( "Webpage (HTML)...",this );
428 a->setShortcut (Qt::ALT + Qt::Key_X); //Export HTML
429 a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
430 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
431 fileExportMenu->addAction (a);
433 a = new QAction( "Webpage (XHTML)...",this ); //Export XHTML
435 //a->setShortcut (Qt::ALT + Qt::SHIFT + Qt::Key_X); a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
436 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
437 fileExportMenu->addAction (a);
439 a = new QAction( "Text (A&O report)...", this);
440 a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" )));
441 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) );
442 fileExportMenu->addAction (a);
444 a = new QAction( "Text (ASCII)...", this);
445 a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" )));
446 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) );
447 fileExportMenu->addAction (a);
449 a = new QAction( "Spreadsheet (CSV)...", this);
450 a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" )));
451 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
452 fileExportMenu->addAction (a);
454 a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
455 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
456 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
457 fileExportMenu->addAction (a);
459 a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
460 a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
461 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
462 fileExportMenu->addAction (a);
464 a = new QAction( "Taskjuggler...", this );
465 a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" )));
466 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) );
467 fileExportMenu->addAction (a);
469 a = new QAction( "LaTeX...", this);
470 a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" )));
471 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) );
472 fileExportMenu->addAction (a);
474 a = new QAction( "XML..." , this );
475 a->setStatusTip (tr( "Export as %1").arg("XML"));
476 connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) );
477 fileExportMenu->addAction (a);
479 fileMenu->addSeparator();
481 a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
482 a->setStatusTip ( tr( "Print" ,"File menu") );
483 a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map
485 fileMenu->addAction (a);
486 connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
489 a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this);
490 a->setStatusTip (tr( "Close Map" ) );
491 a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map
492 fileMenu->addAction (a);
493 connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) );
495 a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this);
496 a->setStatusTip ( tr( "Exit")+" "+vymName );
497 a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym
498 fileMenu->addAction (a);
499 connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) );
504 void Main::setupEditActions()
506 QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") );
507 tb->setLabel( "Edit Actions" );
508 tb->setObjectName ("actionsTB");
509 QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") );
513 a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this);
514 connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) );
515 a->setStatusTip (tr( "Undo" ) );
516 a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action
517 a->setEnabled (false);
519 editMenu->addAction (a);
522 a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this);
523 a->setStatusTip (tr( "Redo" ));
524 a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action
526 editMenu->addAction (a);
527 connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) );
530 editMenu->addSeparator();
531 a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this);
532 a->setStatusTip ( tr( "Copy" ) );
533 a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy
534 a->setEnabled (false);
536 editMenu->addAction (a);
537 connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) );
540 a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this);
541 a->setStatusTip ( tr( "Cut" ) );
542 a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut
543 a->setEnabled (false);
545 editMenu->addAction (a);
547 connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) );
549 a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this);
550 connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) );
551 a->setStatusTip ( tr( "Paste" ) );
552 a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste
553 a->setEnabled (false);
555 editMenu->addAction (a);
558 // Shortcut to delete selection
559 a = new QAction( tr( "Delete Selection","Edit menu" ),this);
560 a->setStatusTip (tr( "Delete Selection" ));
561 a->setShortcut ( Qt::Key_Delete); //Delete selection
562 a->setShortcutContext (Qt::WindowShortcut);
564 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) );
567 // Shortcut to add attribute
568 a= new QAction(tr( "Add attribute" ), this);
569 a->setShortcut ( Qt::Key_Q);
570 a->setShortcutContext (Qt::WindowShortcut);
572 connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
573 actionAddAttribute= a;
576 // Shortcut to add mapcenter
577 a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this);
578 a->setShortcut ( Qt::Key_M);
579 a->setShortcutContext (Qt::WindowShortcut);
580 connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) );
581 //actionListBranches.append(a);
583 actionAddMapCenter = a;
586 // Shortcut to add branch
587 alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
588 alt->setStatusTip ( tr( "Add a branch as child of selection" ));
589 alt->setShortcut (Qt::Key_A); //Add branch
590 alt->setShortcutContext (Qt::WindowShortcut);
592 connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
593 a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this);
594 a->setStatusTip ( tr( "Add a branch as child of selection" ));
595 a->setShortcut (Qt::Key_Insert); //Add branch
596 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) );
597 actionListBranches.append(a);
598 #if defined (Q_OS_MACX)
599 // In OSX show different shortcut in menues, the keys work indepently always
604 editMenu->addAction (actionAddBranch);
605 tb->addAction (actionAddBranch);
608 // Add branch by inserting it at selection
609 a = new QAction(tr( "Add branch (insert)","Edit menu" ), this);
610 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
611 a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch
612 a->setShortcutContext (Qt::WindowShortcut);
614 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
615 a->setEnabled (false);
616 actionListBranches.append(a);
617 actionAddBranchBefore=a;
618 a = new QAction(tr( "Add branch (insert)","Edit menu" ),this);
619 a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
620 a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch
621 a->setShortcutContext (Qt::WindowShortcut);
623 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) );
624 actionListBranches.append(a);
627 a = new QAction(tr( "Add branch above","Edit menu" ), this);
628 a->setStatusTip ( tr( "Add a branch above selection" ));
629 a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above
630 a->setShortcutContext (Qt::WindowShortcut);
632 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
633 a->setEnabled (false);
634 actionListBranches.append(a);
635 actionAddBranchAbove=a;
636 a = new QAction(tr( "Add branch above","Edit menu" ), this);
637 a->setStatusTip ( tr( "Add a branch above selection" ));
638 a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above
639 a->setShortcutContext (Qt::WindowShortcut);
641 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) );
642 actionListBranches.append(a);
645 a = new QAction(tr( "Add branch below","Edit menu" ), this);
646 a->setStatusTip ( tr( "Add a branch below selection" ));
647 a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below
648 a->setShortcutContext (Qt::WindowShortcut);
650 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
651 a->setEnabled (false);
652 actionListBranches.append(a);
653 actionAddBranchBelow=a;
654 a = new QAction(tr( "Add branch below","Edit menu" ), this);
655 a->setStatusTip ( tr( "Add a branch below selection" ));
656 a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below
657 a->setShortcutContext (Qt::WindowShortcut);
659 connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) );
660 actionListBranches.append(a);
662 a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
663 a->setStatusTip ( tr( "Move branch up" ) );
664 a->setShortcut (Qt::Key_PageUp ); // Move branch up
665 a->setEnabled (false);
667 editMenu->addAction (a);
668 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) );
671 a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this);
672 connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) );
673 a->setStatusTip (tr( "Move branch down" ) );
674 a->setShortcut ( Qt::Key_PageDown ); // Move branch down
675 a->setEnabled (false);
677 editMenu->addAction (a);
680 a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this);
681 a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) );
682 a->setShortcut ( Qt::Key_D ); // Detach branch
683 editMenu->addAction (a);
684 connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) );
687 a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
688 connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
689 a->setEnabled (true);
691 editMenu->addAction (a);
692 actionSortChildren=a;
694 a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
695 connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
696 a->setEnabled (true);
698 editMenu->addAction (a);
699 actionSortBackChildren=a;
701 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
702 alt->setShortcut ( Qt::Key_S ); // Scroll branch
703 alt->setStatusTip (tr( "Scroll branch" ));
704 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
705 #if defined(Q_OS_MACX)
706 actionToggleScroll=alt;
708 actionToggleScroll=a;
710 actionToggleScroll->setEnabled (false);
711 actionToggleScroll->setToggleAction(true);
712 tb->addAction (actionToggleScroll);
713 editMenu->addAction ( actionToggleScroll);
714 editMenu->addAction (actionToggleScroll);
717 actionListBranches.append(actionToggleScroll);
719 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
720 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
721 a->setStatusTip (tr( "Expand all branches" ));
722 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
724 actionExpandAll->setEnabled (false);
725 actionExpandAll->setToggleAction(false);
726 //tb->addAction (actionExpandAll);
727 editMenu->addAction ( actionExpandAll);
729 actionListBranches.append(actionExpandAll);
731 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
732 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
733 a->setStatusTip (tr( "Expand one level in tree editor" ));
734 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
735 a->setEnabled (false);
736 a->setToggleAction(false);
737 actionExpandOneLevel=a;
739 editMenu->addAction ( a);
741 actionListBranches.append(a);
743 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
744 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
745 a->setStatusTip (tr( "Collapse one level in tree editor" ));
746 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
747 a->setEnabled (false);
748 a->setToggleAction(false);
749 actionCollapseOneLevel=a;
751 editMenu->addAction ( a);
753 actionListBranches.append(a);
755 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
756 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
757 editMenu->addAction (a);
758 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
760 editMenu->addSeparator();
762 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
763 a->setStatusTip (tr( "Find" ) );
764 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
765 editMenu->addAction (a);
766 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
768 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
769 //a->setStatusTip (tr( "Find" ) );
770 a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
771 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
772 editMenu->addAction (a);
773 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
775 editMenu->addSeparator();
777 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
778 a->setShortcut (Qt::SHIFT + Qt::Key_U );
779 a->setShortcut (tr( "Open URL" ));
782 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
785 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
786 a->setStatusTip (tr( "Open URL in new tab" ));
787 //a->setShortcut (Qt::CTRL+Qt::Key_U );
789 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
792 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
793 a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
794 a->setShortcut ( Qt::CTRL + Qt::Key_U );
796 actionListBranches.append(a);
797 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
798 actionOpenMultipleVisURLTabs=a;
800 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
801 a->setStatusTip (tr( "Open all URLs in subtree" ));
803 actionListBranches.append(a);
804 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
805 actionOpenMultipleURLTabs=a;
807 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
808 a->setStatusTip ( tr( "Edit URL" ) );
809 a->setShortcut ( Qt::Key_U );
810 a->setShortcutContext (Qt::WindowShortcut);
811 actionListBranches.append(a);
813 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
816 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
817 a->setStatusTip ( tr( "Edit local URL" ) );
818 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
819 a->setShortcutContext (Qt::WindowShortcut);
820 actionListBranches.append(a);
822 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
825 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
826 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
827 a->setEnabled (false);
828 actionListBranches.append(a);
829 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
832 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
833 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
834 a->setEnabled (false);
835 actionListBranches.append(a);
836 a->setShortcut ( Qt::Key_B );
837 a->setShortcutContext (Qt::WindowShortcut);
839 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
840 actionBugzilla2URL=a;
842 a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
843 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
844 a->setEnabled (false);
845 actionListBranches.append(a);
846 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
847 a->setShortcutContext (Qt::WindowShortcut);
849 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
850 actionGetBugzillaData=a;
852 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
853 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
854 a->setEnabled (false);
855 actionListBranches.append(a);
856 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
859 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
860 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
862 a->setEnabled (false);
863 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
866 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
867 a->setStatusTip ( tr( "Open all vym links in subtree" ));
868 a->setEnabled (false);
869 actionListBranches.append(a);
870 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
871 actionOpenMultipleVymLinks=a;
874 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
875 a->setEnabled (false);
876 a->setStatusTip ( tr( "Edit link to another vym map" ));
877 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
878 actionListBranches.append(a);
881 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
882 a->setStatusTip ( tr( "Delete link to another vym map" ));
883 a->setEnabled (false);
884 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
885 actionDeleteVymLink=a;
887 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
888 a->setStatusTip ( tr( "Hide object in exports" ) );
889 a->setShortcut (Qt::Key_H );
890 a->setToggleAction(true);
892 a->setEnabled (false);
893 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
894 actionToggleHideExport=a;
896 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
897 a->setStatusTip ( tr( "Add timestamp" ));
898 a->setEnabled (false);
899 actionListBranches.append(a);
900 a->setShortcut ( Qt::Key_T ); // Add timestamp
901 a->setShortcutContext (Qt::WindowShortcut);
903 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
904 actionAddTimestamp=a;
906 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
907 a->setStatusTip ( tr( "Edit Map Info" ));
908 a->setEnabled (true);
909 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
912 // Import at selection (adding to selection)
913 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
914 a->setStatusTip (tr( "Add map at selection" ));
915 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
916 a->setEnabled (false);
917 actionListBranches.append(a);
920 // Import at selection (replacing selection)
921 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
922 a->setStatusTip (tr( "Replace selection with map" ));
923 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
924 a->setEnabled (false);
925 actionListBranches.append(a);
926 actionImportReplace=a;
929 a = new QAction( tr( "Save selection","Edit menu" ), this);
930 a->setStatusTip (tr( "Save selection" ));
931 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
932 a->setEnabled (false);
933 actionListBranches.append(a);
936 // Only remove branch, not its children
937 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
938 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
939 a->setShortcut (Qt::ALT + Qt::Key_Delete );
940 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
941 a->setEnabled (false);
943 actionListBranches.append(a);
944 actionDeleteKeepChildren=a;
946 // Only remove children of a branch
947 a = new QAction( tr( "Remove children","Edit menu" ), this);
948 a->setStatusTip (tr( "Remove children of branch" ));
949 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
950 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
951 a->setEnabled (false);
952 actionListBranches.append(a);
953 actionDeleteChildren=a;
955 a = new QAction( tr( "Add Image...","Edit menu" ), this);
956 a->setStatusTip (tr( "Add Image" ));
957 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
960 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
961 a->setStatusTip (tr( "Set properties for selection" ));
962 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
963 a->setShortcutContext (Qt::WindowShortcut);
964 a->setToggleAction (true);
966 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
967 actionViewTogglePropertyWindow=a;
971 void Main::setupFormatActions()
973 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
975 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
976 tb->setObjectName ("formatTB");
979 pix.fill (Qt::black);
980 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
981 a->setStatusTip ( tr( "Set Color" ));
982 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
984 formatMenu->addAction (a);
986 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
987 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
988 a->setShortcut (Qt::CTRL + Qt::Key_K );
989 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
990 a->setEnabled (false);
992 formatMenu->addAction (a);
993 actionListBranches.append(a);
994 actionFormatPickColor=a;
996 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
997 a->setStatusTip ( tr( "Color branch" ) );
998 a->setShortcut (Qt::CTRL + Qt::Key_B);
999 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
1000 a->setEnabled (false);
1002 formatMenu->addAction (a);
1003 actionListBranches.append(a);
1004 actionFormatColorSubtree=a;
1006 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1007 a->setStatusTip ( tr( "Color Subtree" ));
1008 //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree
1009 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1010 a->setEnabled (false);
1011 formatMenu->addAction (a);
1013 actionListBranches.append(a);
1014 actionFormatColorSubtree=a;
1016 formatMenu->addSeparator();
1017 actionGroupFormatLinkStyles=new QActionGroup ( this);
1018 actionGroupFormatLinkStyles->setExclusive (true);
1019 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1020 a->setStatusTip (tr( "Line" ));
1021 a->setToggleAction(true);
1022 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1023 formatMenu->addAction (a);
1024 actionFormatLinkStyleLine=a;
1025 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1026 a->setStatusTip (tr( "Line" ));
1027 a->setToggleAction(true);
1028 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1029 formatMenu->addAction (a);
1030 actionFormatLinkStyleParabel=a;
1031 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1032 a->setStatusTip (tr( "PolyLine" ));
1033 a->setToggleAction(true);
1034 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1035 formatMenu->addAction (a);
1036 actionFormatLinkStylePolyLine=a;
1037 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1038 a->setStatusTip (tr( "PolyParabel" ) );
1039 a->setToggleAction(true);
1040 a->setChecked (true);
1041 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1042 formatMenu->addAction (a);
1043 actionFormatLinkStylePolyParabel=a;
1045 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1046 a->setStatusTip (tr( "Hide link" ));
1047 a->setToggleAction(true);
1048 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1049 actionFormatHideLinkUnselected=a;
1051 formatMenu->addSeparator();
1052 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1053 a->setStatusTip (tr( "Use same color for links and headings" ));
1054 a->setToggleAction(true);
1055 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1056 formatMenu->addAction (a);
1057 actionFormatLinkColorHint=a;
1059 pix.fill (Qt::white);
1060 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1061 a->setStatusTip (tr( "Set Link Color" ));
1062 formatMenu->addAction (a);
1063 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1064 actionFormatLinkColor=a;
1066 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1067 a->setStatusTip (tr( "Set Selection Color" ));
1068 formatMenu->addAction (a);
1069 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1070 actionFormatSelectionColor=a;
1072 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1073 a->setStatusTip (tr( "Set Background Color" ));
1074 formatMenu->addAction (a);
1075 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1076 actionFormatBackColor=a;
1078 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1079 a->setStatusTip (tr( "Set Background image" ));
1080 formatMenu->addAction (a);
1081 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1082 actionFormatBackImage=a;
1086 void Main::setupViewActions()
1088 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1089 tb->setLabel( "View Actions" );
1090 tb->setObjectName ("viewTB");
1091 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1093 Switchboard switchboard; //FIXME-2 testing...
1096 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1097 a->setStatusTip ( tr( "Zoom reset" ) );
1098 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1099 switchboard.addConnection(a,"CTRL+0");
1101 viewMenu->addAction (a);
1102 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1104 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1105 a->setStatusTip (tr( "Zoom in" ));
1106 switchboard.addConnection(a,"CTRL++");
1108 viewMenu->addAction (a);
1109 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1111 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1112 a->setStatusTip (tr( "Zoom out" ));
1113 switchboard.addConnection(a,"CTRL+-");
1115 viewMenu->addAction (a);
1116 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1118 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1119 a->setStatusTip (tr( "Show selection" ));
1120 switchboard.addConnection(a,".");
1122 viewMenu->addAction (a);
1123 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1125 viewMenu->addSeparator();
1127 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1128 a->setStatusTip ( tr( "Show Note Editor" ));
1129 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1130 a->setToggleAction(true);
1132 viewMenu->addAction (a);
1133 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1134 actionViewToggleNoteEditor=a;
1136 a = new QAction(QPixmap(), tr( "Show tree editor","View action" ),this);
1137 a->setStatusTip ( tr( "Show tree editor" ));
1138 a->setShortcut ( Qt::CTRL + Qt::Key_T ); // Toggle Note Editor // FIXME-3 originally: color subtree
1139 a->setToggleAction(true);
1141 viewMenu->addAction (a);
1142 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleTreeEditor() ) );
1143 actionViewToggleTreeEditor=a;
1145 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1146 a->setStatusTip ( tr( "Show History Window" ));
1147 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1148 a->setToggleAction(true);
1150 viewMenu->addAction (a);
1151 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1152 actionViewToggleHistoryWindow=a;
1154 viewMenu->addAction (actionViewTogglePropertyWindow);
1156 viewMenu->addSeparator();
1158 a = new QAction(tr( "Antialiasing","View action" ),this );
1159 a->setStatusTip ( tr( "Antialiasing" ));
1160 a->setToggleAction(true);
1161 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1162 viewMenu->addAction (a);
1163 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1164 actionViewToggleAntiAlias=a;
1166 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1167 a->setStatusTip (a->text());
1168 a->setToggleAction(true);
1169 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1170 viewMenu->addAction (a);
1171 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1172 actionViewToggleSmoothPixmapTransform=a;
1174 a = new QAction(tr( "Next Map","View action" ), this);
1175 a->setStatusTip (a->text());
1176 a->setShortcut (Qt::ALT + Qt::Key_N );
1177 viewMenu->addAction (a);
1178 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1180 a = new QAction (tr( "Previous Map","View action" ), this );
1181 a->setStatusTip (a->text());
1182 a->setShortcut (Qt::ALT + Qt::Key_P );
1183 viewMenu->addAction (a);
1184 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1186 if (debug) switchboard.print();
1190 void Main::setupModeActions()
1192 //QPopupMenu *menu = new QPopupMenu( this );
1193 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1195 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1196 tb->setObjectName ("modesTB");
1198 actionGroupModModes=new QActionGroup ( this);
1199 actionGroupModModes->setExclusive (true);
1200 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1201 a->setShortcut (Qt::Key_J);
1202 a->setStatusTip ( tr( "Use modifier to color branches" ));
1203 a->setToggleAction(true);
1205 a->setChecked(true);
1206 actionModModeColor=a;
1208 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1209 a->setShortcut( Qt::Key_K);
1210 a->setStatusTip( tr( "Use modifier to copy" ));
1211 a->setToggleAction(true);
1213 actionModModeCopy=a;
1215 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1216 a->setShortcut (Qt::Key_L);
1217 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1218 a->setToggleAction(true);
1220 actionModModeXLink=a;
1224 void Main::setupFlagActions()
1226 // Create System Flags
1229 Flag *flag=new Flag;;
1230 flag->setVisible(true);
1232 flag->load(flagsPath+"flag-note.png");
1233 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1235 flag->load(flagsPath+"flag-url.png");
1236 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1238 flag->load(flagsPath+"flag-url-bugzilla-novell.png");
1239 setupFlag (flag,tb,"system-url-bugzilla-novell",tr("URL to Bugzilla ","SystemFlag"));
1241 flag->load(flagsPath+"flag-vymlink.png");
1242 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1244 flag->load(flagsPath+"flag-scrolled-right.png");
1245 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1247 flag->load(flagsPath+"flag-tmpUnscrolled-right.png");
1248 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1250 flag->load(flagsPath+"flag-hideexport.png");
1251 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1253 // Create Standard Flags
1254 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1255 tb->setObjectName ("standardFlagTB");
1256 standardFlagsMaster->setToolBar (tb);
1258 flag->load(flagsPath+"flag-exclamationmark.png");
1259 flag->setGroup("standard-mark");
1260 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1262 flag->load(flagsPath+"flag-questionmark.png");
1263 flag->setGroup("standard-mark");
1264 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1266 flag->load(flagsPath+"flag-hook-green.png");
1267 flag->setGroup("standard-status");
1268 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1270 flag->load(flagsPath+"flag-wip.png");
1271 flag->setGroup("standard-status");
1272 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1274 flag->load(flagsPath+"flag-cross-red.png");
1275 flag->setGroup("standard-status");
1276 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1279 flag->load(flagsPath+"flag-stopsign.png");
1280 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1282 flag->load(flagsPath+"flag-smiley-good.png");
1283 flag->setGroup("standard-smiley");
1284 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1286 flag->load(flagsPath+"flag-smiley-sad.png");
1287 flag->setGroup("standard-smiley");
1288 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1290 flag->load(flagsPath+"flag-smiley-omg.png");
1291 flag->setGroup("standard-smiley");
1292 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1293 // Original omg.png (in KDE emoticons)
1296 flag->load(flagsPath+"flag-kalarm.png");
1297 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1299 flag->load(flagsPath+"flag-phone.png");
1300 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1302 flag->load(flagsPath+"flag-lamp.png");
1303 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1305 flag->load(flagsPath+"flag-arrow-up.png");
1306 flag->setGroup("standard-arrow");
1307 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1309 flag->load(flagsPath+"flag-arrow-down.png");
1310 flag->setGroup("standard-arrow");
1311 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1313 flag->load(flagsPath+"flag-arrow-2up.png");
1314 flag->setGroup("standard-arrow");
1315 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1317 flag->load(flagsPath+"flag-arrow-2down.png");
1318 flag->setGroup("standard-arrow");
1319 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1322 flag->load(flagsPath+"flag-thumb-up.png");
1323 flag->setGroup("standard-thumb");
1324 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1326 flag->load(flagsPath+"flag-thumb-down.png");
1327 flag->setGroup("standard-thumb");
1328 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1331 flag->load(flagsPath+"flag-rose.png");
1332 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1334 flag->load(flagsPath+"flag-heart.png");
1335 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1337 flag->load(flagsPath+"flag-present.png");
1338 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1340 flag->load(flagsPath+"flag-flash.png");
1341 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1343 // Original: xsldbg_output.png
1344 flag->load(flagsPath+"flag-info.png");
1345 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1347 // Original khelpcenter.png
1348 flag->load(flagsPath+"flag-lifebelt.png");
1349 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1352 flag->setVisible(false);
1353 flag->load(flagsPath+"freemind/warning.png");
1354 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1356 for (int i=1; i<8; i++)
1358 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1359 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1362 flag->load(flagsPath+"freemind/back.png");
1363 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1365 flag->load(flagsPath+"freemind/forward.png");
1366 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1368 flag->load(flagsPath+"freemind/attach.png");
1369 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1371 flag->load(flagsPath+"freemind/clanbomber.png");
1372 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1374 flag->load(flagsPath+"freemind/desktopnew.png");
1375 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1377 flag->load(flagsPath+"freemind/flag.png");
1378 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1381 flag->load(flagsPath+"freemind/gohome.png");
1382 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1385 flag->load(flagsPath+"freemind/kaddressbook.png");
1386 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1388 flag->load(flagsPath+"freemind/knotify.png");
1389 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1391 flag->load(flagsPath+"freemind/korn.png");
1392 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1394 flag->load(flagsPath+"freemind/mail.png");
1395 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1397 flag->load(flagsPath+"freemind/password.png");
1398 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1400 flag->load(flagsPath+"freemind/pencil.png");
1401 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1403 flag->load(flagsPath+"freemind/stop.png");
1404 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1406 flag->load(flagsPath+"freemind/wizard.png");
1407 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1409 flag->load(flagsPath+"freemind/xmag.png");
1410 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1412 flag->load(flagsPath+"freemind/bell.png");
1413 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1415 flag->load(flagsPath+"freemind/bookmark.png");
1416 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1418 flag->load(flagsPath+"freemind/penguin.png");
1419 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1421 flag->load(flagsPath+"freemind/licq.png");
1422 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1425 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1427 flag->setName(name);
1428 flag->setToolTip (tooltip);
1432 a=new QAction (flag->getPixmap(),name,this);
1435 flag->setAction (a);
1436 a->setVisible (flag->isVisible());
1437 a->setCheckable(true);
1438 a->setObjectName(name);
1439 a->setToolTip(tooltip);
1440 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1441 standardFlagsMaster->addFlag (flag);
1445 systemFlagsMaster->addFlag (flag);
1450 void Main::setupNetworkActions()
1452 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1454 QMenu *netMenu = menuBar()->addMenu( "Network" );
1458 a = new QAction( "Start TCPserver for MapEditor",this);
1459 //a->setStatusTip ( "Set application to open pdf files"));
1460 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1461 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1462 netMenu->addAction (a);
1464 a = new QAction( "Connect MapEditor to server",this);
1465 //a->setStatusTip ( "Set application to open pdf files"));
1466 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1467 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1468 netMenu->addAction (a);
1472 void Main::setupSettingsActions()
1474 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1478 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1479 a->setStatusTip ( tr( "Set application to open pdf files"));
1480 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1481 settingsMenu->addAction (a);
1483 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1484 a->setStatusTip( tr( "Set application to open external links"));
1485 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1486 settingsMenu->addAction (a);
1488 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1489 a->setStatusTip( tr( "Set path for macros"));
1490 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1491 settingsMenu->addAction (a);
1493 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1494 a->setStatusTip( tr( "Set number of undo levels"));
1495 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1496 settingsMenu->addAction (a);
1498 settingsMenu->addSeparator();
1500 a = new QAction( tr( "Autosave","Settings action"), this);
1501 a->setStatusTip( tr( "Autosave"));
1502 a->setToggleAction(true);
1503 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1504 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1505 settingsMenu->addAction (a);
1506 actionSettingsAutosaveToggle=a;
1508 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1509 a->setStatusTip( tr( "Autosave time"));
1510 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1511 settingsMenu->addAction (a);
1512 actionSettingsAutosaveTime=a;
1514 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1515 a->setStatusTip( tr( "Write backup file on save"));
1516 a->setToggleAction(true);
1517 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1518 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1519 settingsMenu->addAction (a);
1520 actionSettingsWriteBackupFile=a;
1522 settingsMenu->addSeparator();
1524 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1525 a->setStatusTip( tr( "Edit branch after adding it" ));
1526 a->setToggleAction(true);
1527 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1528 settingsMenu->addAction (a);
1529 actionSettingsAutoEditNewBranch=a;
1531 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1532 a->setStatusTip( tr( "Select branch after adding it" ));
1533 a->setToggleAction(true);
1534 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1535 settingsMenu->addAction (a);
1536 actionSettingsAutoSelectNewBranch=a;
1538 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1539 a->setStatusTip( tr( "Select heading before editing" ));
1540 a->setToggleAction(true);
1541 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1542 settingsMenu->addAction (a);
1543 actionSettingsAutoSelectText=a;
1545 a= new QAction( tr( "Delete key","Settings action" ), this);
1546 a->setStatusTip( tr( "Delete key for deleting branches" ));
1547 a->setToggleAction(true);
1548 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1549 settingsMenu->addAction (a);
1550 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1551 actionSettingsUseDelKey=a;
1553 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1554 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1555 a->setToggleAction(true);
1556 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1557 settingsMenu->addAction (a);
1558 actionSettingsUseFlagGroups=a;
1560 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1561 a->setStatusTip( tr( "Use hide flag during exports " ));
1562 a->setToggleAction(true);
1563 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1564 settingsMenu->addAction (a);
1565 actionSettingsUseHideExport=a;
1567 a = new QAction( tr( "Animation","Settings action"), this);
1568 a->setStatusTip( tr( "Animation"));
1569 a->setToggleAction(true);
1570 a->setChecked (settings.value("/animation/use",true).toBool() );
1571 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1572 settingsMenu->addAction (a);
1573 actionSettingsUseAnimation=a;
1577 void Main::setupTestActions()
1579 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1582 a = new QAction( "Test function 1" , this);
1583 a->setStatusTip( "Call test function 1" );
1584 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 1
1585 testMenu->addAction (a);
1586 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1588 a = new QAction( "Test function 2" , this);
1589 a->setStatusTip( "Call test function 2" );
1590 a->setShortcut (Qt::ALT + Qt::Key_T); // Test function 2
1591 testMenu->addAction (a);
1592 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1594 a = new QAction( "Command" , this);
1595 a->setStatusTip( "Enter command to call in editor" );
1596 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1597 testMenu->addAction (a);
1601 void Main::setupHelpActions()
1603 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1606 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1607 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1608 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1609 helpMenu->addAction (a);
1611 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1612 a->setStatusTip( tr( "Open VYM example maps " ));
1613 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1614 helpMenu->addAction (a);
1616 a = new QAction( tr( "About VYM","Help action" ), this);
1617 a->setStatusTip( tr( "About VYM")+vymName);
1618 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1619 helpMenu->addAction (a);
1621 a = new QAction( tr( "About QT","Help action" ), this);
1622 a->setStatusTip( tr( "Information about QT toolkit" ));
1623 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1624 helpMenu->addAction (a);
1628 void Main::setupContextMenus()
1632 // Context Menu for branch or mapcenter
1633 branchContextMenu =new QMenu (this);
1634 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1635 branchContextMenu->addSeparator();
1638 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1639 branchAddContextMenu->addAction (actionPaste );
1640 branchAddContextMenu->addAction ( actionAddMapCenter );
1641 branchAddContextMenu->addAction ( actionAddBranch );
1642 branchAddContextMenu->addAction ( actionAddBranchBefore );
1643 branchAddContextMenu->addAction ( actionAddBranchAbove);
1644 branchAddContextMenu->addAction ( actionAddBranchBelow );
1645 branchAddContextMenu->addSeparator();
1646 branchAddContextMenu->addAction ( actionImportAdd );
1647 branchAddContextMenu->addAction ( actionImportReplace );
1650 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1651 branchRemoveContextMenu->addAction (actionCut);
1652 branchRemoveContextMenu->addAction ( actionDelete );
1653 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1654 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1657 actionSaveBranch->addTo( branchContextMenu );
1658 actionFileNewCopy->addTo (branchContextMenu );
1659 actionDetach->addTo (branchContextMenu );
1661 branchContextMenu->addSeparator();
1662 branchContextMenu->addAction ( actionLoadImage);
1663 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1664 branchContextMenu->addAction ( actionAddAttribute);
1666 // Submenu for Links (URLs, vymLinks)
1667 branchLinksContextMenu =new QMenu (this);
1669 branchContextMenu->addSeparator();
1670 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1671 branchLinksContextMenu->addAction ( actionOpenURL );
1672 branchLinksContextMenu->addAction ( actionOpenURLTab );
1673 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1674 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1675 branchLinksContextMenu->addAction ( actionURL );
1676 branchLinksContextMenu->addAction ( actionLocalURL );
1677 branchLinksContextMenu->addAction ( actionHeading2URL );
1678 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1679 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1681 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1682 branchLinksContextMenu->addAction ( actionFATE2URL );
1684 branchLinksContextMenu->addSeparator();
1685 branchLinksContextMenu->addAction ( actionOpenVymLink );
1686 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1687 branchLinksContextMenu->addAction ( actionVymLink );
1688 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1691 // Context Menu for XLinks in a branch menu
1692 // This will be populated "on demand" in MapEditor::updateActions
1693 branchContextMenu->addSeparator();
1694 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1695 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1698 // Context menu for floatimage
1699 floatimageContextMenu =new QMenu (this);
1700 a= new QAction (tr ("Save image","Context action"),this);
1701 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1702 floatimageContextMenu->addAction (a);
1704 floatimageContextMenu->addSeparator();
1705 actionCopy->addTo( floatimageContextMenu );
1706 actionCut->addTo( floatimageContextMenu );
1708 floatimageContextMenu->addSeparator();
1709 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1712 // Context menu for canvas
1713 canvasContextMenu =new QMenu (this);
1714 actionAddMapCenter->addTo( canvasContextMenu );
1715 actionMapInfo->addTo( canvasContextMenu );
1716 canvasContextMenu->insertSeparator();
1717 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1718 canvasContextMenu->insertSeparator();
1719 actionFormatLinkColorHint->addTo( canvasContextMenu );
1720 actionFormatLinkColor->addTo( canvasContextMenu );
1721 actionFormatSelectionColor->addTo( canvasContextMenu );
1722 actionFormatBackColor->addTo( canvasContextMenu );
1723 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1725 // Menu for last opened files
1727 for (int i = 0; i < MaxRecentFiles; ++i)
1729 recentFileActions[i] = new QAction(this);
1730 recentFileActions[i]->setVisible(false);
1731 fileLastMapsMenu->addAction(recentFileActions[i]);
1732 connect(recentFileActions[i], SIGNAL(triggered()),
1733 this, SLOT(fileLoadRecent()));
1735 setupRecentMapsMenu();
1738 void Main::setupRecentMapsMenu()
1740 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1742 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1744 for (int i = 0; i < numRecentFiles; ++i) {
1745 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1746 recentFileActions[i]->setText(text);
1747 recentFileActions[i]->setData(files[i]);
1748 recentFileActions[i]->setVisible(true);
1750 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1751 recentFileActions[j]->setVisible(false);
1754 void Main::setupMacros()
1756 for (int i = 0; i <= 11; i++)
1758 macroActions[i] = new QAction(this);
1759 macroActions[i]->setData(i);
1760 addAction (macroActions[i]);
1761 connect(macroActions[i], SIGNAL(triggered()),
1762 this, SLOT(callMacro()));
1764 macroActions[0]->setShortcut ( Qt::Key_F1 );
1765 macroActions[1]->setShortcut ( Qt::Key_F2 );
1766 macroActions[2]->setShortcut ( Qt::Key_F3 );
1767 macroActions[3]->setShortcut ( Qt::Key_F4 );
1768 macroActions[4]->setShortcut ( Qt::Key_F5 );
1769 macroActions[5]->setShortcut ( Qt::Key_F6 );
1770 macroActions[6]->setShortcut ( Qt::Key_F7 );
1771 macroActions[7]->setShortcut ( Qt::Key_F8 );
1772 macroActions[8]->setShortcut ( Qt::Key_F9 );
1773 macroActions[9]->setShortcut ( Qt::Key_F10 );
1774 macroActions[10]->setShortcut ( Qt::Key_F11 );
1775 macroActions[11]->setShortcut ( Qt::Key_F12 );
1778 void Main::hideEvent (QHideEvent * )
1780 if (!textEditor->isMinimized() ) textEditor->hide();
1783 void Main::showEvent (QShowEvent * )
1785 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1789 MapEditor* Main::currentMapEditor() const
1791 if ( tabWidget->currentPage())
1792 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1796 VymModel* Main::currentModel() const
1798 if ( tabWidget->currentPage())
1799 return vymViews.at(tabWidget->currentIndex())->getModel();
1803 VymModel* Main::getModel(uint id) const
1805 if ( tabWidget->currentPage())
1806 return vymViews.at(tabWidget->currentIndex())->getModel();
1811 void Main::editorChanged(QWidget *)
1813 // Unselect all possibly selected objects
1814 // (Important to update note editor)
1816 for (int i=0;i<=tabWidget->count() -1;i++)
1818 m= vymViews.at(i)->getModel();
1819 if (m) m->unselect();
1822 if (m) m->reselect();
1824 // Update actions to in menus and toolbars according to editor
1828 void Main::fileNew()
1830 VymModel *vm=new VymModel;
1832 /////////////////////////////////////
1833 // new ModelTest(vm, this); //FIXME-3
1834 /////////////////////////////////////
1836 VymView *vv=new VymView (vm);
1837 vymViews.append (vv);
1838 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1839 tabWidget->setCurrentIndex (vymViews.count() );
1842 // Create MapCenter for empty map
1846 // For the very first map we do not have flagrows yet...
1850 void Main::fileNewCopy()
1852 QString fn="unnamed";
1853 VymModel *srcModel=currentModel();
1858 VymModel *dstModel=vymViews.last()->getModel();
1859 dstModel->select("mc:");
1860 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1864 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1866 ErrorCode err=success;
1868 // fn is usually the archive, mapfile the file after uncompressing
1871 // Make fn absolute (needed for unzip)
1872 fn=QDir (fn).absPath();
1878 // Check, if map is already loaded
1880 while (i<=tabWidget->count() -1)
1882 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1884 // Already there, ask for confirmation
1885 QMessageBox mb( vymName,
1886 tr("The map %1\nis already opened."
1887 "Opening the same map in multiple editors may lead \n"
1888 "to confusion when finishing working with vym."
1889 "Do you want to").arg(fn),
1890 QMessageBox::Warning,
1891 QMessageBox::Yes | QMessageBox::Default,
1892 QMessageBox::Cancel | QMessageBox::Escape,
1893 QMessageBox::NoButton);
1894 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1895 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1898 case QMessageBox::Yes:
1899 // end loop and load anyway
1900 i=tabWidget->count();
1902 case QMessageBox::Cancel:
1912 int tabIndex=tabWidget->currentPageIndex();
1915 if ( !fn.isEmpty() )
1917 vm = currentModel();
1918 // Check first, if mapeditor exists
1919 // If it is not default AND we want a new map,
1920 // create a new mapeditor in a new tab
1921 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1924 VymView *vv=new VymView (vm);
1925 vymViews.append (vv);
1926 tabWidget->addTab (vv,fn);
1927 tabIndex=tabWidget->count()-1;
1928 tabWidget->setCurrentPage (tabIndex);
1932 // Check, if file exists (important for creating new files
1933 // from command line
1934 if (!QFile(fn).exists() )
1936 QMessageBox mb( vymName,
1937 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1938 QMessageBox::Question,
1940 QMessageBox::Cancel | QMessageBox::Default,
1941 QMessageBox::NoButton );
1943 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1944 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1947 case QMessageBox::Yes:
1949 currentMapEditor()->getModel()->setFilePath(fn);
1950 tabWidget->setTabText (tabIndex,
1951 currentMapEditor()->getModel()->getFileName() );
1952 statusBar()->message( "Created " + fn , statusbarTime );
1955 case QMessageBox::Cancel:
1956 // don't create new map
1957 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1964 //tabWidget->currentPage() won't be NULL here, because of above...
1965 tabWidget->setCurrentIndex (tabIndex);
1966 //FIXME-3 no me anymore... me->viewport()->setFocus();
1970 // Save existing filename in case we import
1971 QString fn_org=vm->getFilePath();
1973 // Finally load map into mapEditor
1974 vm->setFilePath (fn);
1975 err=vm->load(fn,lmode,ftype);
1977 // Restore old (maybe empty) filepath, if this is an import
1979 vm->setFilePath (fn_org);
1982 // Finally check for errors and go home
1985 if (lmode==NewMap) fileCloseMap();
1986 statusBar()->message( "Could not load " + fn, statusbarTime );
1991 vm->setFilePath (fn);
1992 tabWidget->setTabText (tabIndex, vm->getFileName());
1993 if (!isInTmpDir (fn))
1995 // Only append to lastMaps if not loaded from a tmpDir
1996 // e.g. imported bookmarks are in a tmpDir
1997 addRecentMap(vm->getFilePath() );
1999 actionFilePrint->setEnabled (true);
2001 statusBar()->message( "Loaded " + fn, statusbarTime );
2008 void Main::fileLoad(const LoadMode &lmode)
2010 QStringList filters;
2011 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
2012 QFileDialog *fd=new QFileDialog( this);
2013 fd->setDir (lastFileDir);
2014 fd->setFileMode (QFileDialog::ExistingFiles);
2015 fd->setFilters (filters);
2019 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2022 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2025 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2031 if ( fd->exec() == QDialog::Accepted )
2033 lastFileDir=fd->directory().path();
2034 QStringList flist = fd->selectedFiles();
2035 QStringList::Iterator it = flist.begin();
2037 progressCounter=flist.count();
2038 progressCounterTotal=flist.count();
2039 while( it != flist.end() )
2042 fileLoad(*it, lmode);
2049 void Main::fileLoad()
2054 void Main::fileLoadRecent()
2056 QAction *action = qobject_cast<QAction *>(sender());
2058 fileLoad (action->data().toString(), NewMap);
2061 void Main::addRecentMap (const QString &fileName)
2064 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2065 files.removeAll(fileName);
2066 files.prepend(fileName);
2067 while (files.size() > MaxRecentFiles)
2070 settings.setValue("/mainwindow/recentFileList", files);
2072 setupRecentMapsMenu();
2075 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2079 if ( m->getFilePath().isEmpty() )
2081 // We have no filepath yet,
2082 // call fileSaveAs() now, this will call fileSave()
2084 // First switch to editor
2085 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2086 fileSaveAs(savemode);
2089 if (m->save (savemode)==success)
2091 statusBar()->message(
2092 tr("Saved %1").arg(m->getFilePath()),
2094 addRecentMap (m->getFilePath() );
2096 statusBar()->message(
2097 tr("Couldn't save ").arg(m->getFilePath()),
2101 void Main::fileSave()
2103 fileSave (currentModel(), CompleteMap);
2106 void Main::fileSave(VymModel *m)
2108 fileSave (m,CompleteMap);
2111 void Main::fileSaveAs(const SaveMode& savemode)
2115 if (currentMapEditor())
2117 if (savemode==CompleteMap)
2118 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2120 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2121 if ( !fn.isEmpty() )
2123 // Check for existing file
2124 if (QFile (fn).exists())
2126 QMessageBox mb( vymName,
2127 tr("The file %1\nexists already. Do you want to").arg(fn),
2128 QMessageBox::Warning,
2129 QMessageBox::Yes | QMessageBox::Default,
2130 QMessageBox::Cancel | QMessageBox::Escape,
2131 QMessageBox::NoButton);
2132 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2133 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2136 case QMessageBox::Yes:
2139 case QMessageBox::Cancel:
2146 // New file, add extension to filename, if missing
2147 // This is always .vym or .vyp, depending on savemode
2148 if (savemode==CompleteMap)
2150 if (!fn.contains (".vym") && !fn.contains (".xml"))
2154 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2163 VymModel *m=currentModel();
2165 fileSave(m, savemode);
2167 // Set name of tab, assuming current tab is the one we just saved
2168 if (savemode==CompleteMap)
2169 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2175 void Main::fileSaveAs()
2177 fileSaveAs (CompleteMap);
2180 void Main::fileImportKDE3Bookmarks()
2182 ImportKDE3Bookmarks im;
2184 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2185 currentMapEditor()->getModel()->setFilePath ("");
2188 void Main::fileImportKDE4Bookmarks()
2190 ImportKDE4Bookmarks im;
2192 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2193 currentMapEditor()->getModel()->setFilePath ("");
2196 void Main::fileImportFirefoxBookmarks()
2198 Q3FileDialog *fd=new Q3FileDialog( this);
2199 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2200 fd->setMode (Q3FileDialog::ExistingFiles);
2201 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2202 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2205 if ( fd->exec() == QDialog::Accepted )
2207 ImportFirefoxBookmarks im;
2208 QStringList flist = fd->selectedFiles();
2209 QStringList::Iterator it = flist.begin();
2210 while( it != flist.end() )
2213 if (im.transform() &&
2214 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2215 currentMapEditor() )
2216 currentMapEditor()->getModel()->setFilePath ("");
2223 void Main::fileImportFreemind()
2225 QStringList filters;
2226 filters <<"Freemind map (*.mm)"<<"All files (*)";
2227 QFileDialog *fd=new QFileDialog( this);
2228 fd->setDir (lastFileDir);
2229 fd->setFileMode (QFileDialog::ExistingFiles);
2230 fd->setFilters (filters);
2231 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2235 if ( fd->exec() == QDialog::Accepted )
2237 lastFileDir=fd->directory().path();
2238 QStringList flist = fd->selectedFiles();
2239 QStringList::Iterator it = flist.begin();
2240 while( it != flist.end() )
2243 if ( fileLoad (fn,NewMap, FreemindMap) )
2245 currentMapEditor()->getModel()->setFilePath ("");
2254 void Main::fileImportMM()
2258 Q3FileDialog *fd=new Q3FileDialog( this);
2259 fd->setDir (lastFileDir);
2260 fd->setMode (Q3FileDialog::ExistingFiles);
2261 fd->addFilter ("Mind Manager (*.mmap)");
2262 fd->setCaption(tr("Import")+" "+"Mind Manager");
2265 if ( fd->exec() == QDialog::Accepted )
2267 lastFileDir=fd->dirPath();
2268 QStringList flist = fd->selectedFiles();
2269 QStringList::Iterator it = flist.begin();
2270 while( it != flist.end() )
2273 if (im.transform() &&
2274 success==fileLoad (im.getTransformedFile(),NewMap) &&
2275 currentMapEditor() )
2276 currentMapEditor()->getModel()->setFilePath ("");
2283 void Main::fileImportDir()
2285 VymModel *m=currentModel();
2286 if (m) m->importDir();
2289 void Main::fileExportXML()
2291 VymModel *m=currentModel();
2292 if (m) m->exportXML();
2295 void Main::fileExportHTML()
2297 VymModel *m=currentModel();
2298 if (m) m->exportHTML();
2302 void Main::fileExportXHTML()
2304 VymModel *m=currentModel();
2305 if (m) m->exportXHTML();
2308 void Main::fileExportImage()
2310 VymModel *m=currentModel();
2311 if (m) m->exportImage();
2314 void Main::fileExportAO()
2316 VymModel *m=currentModel();
2317 if (m) m->exportAO();
2320 void Main::fileExportASCII()
2322 VymModel *m=currentModel();
2323 if (m) m->exportASCII();
2326 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2328 VymModel *m=currentModel();
2333 ex.addFilter ("CSV (*.csv)");
2334 ex.setDir(lastImageDir);
2335 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2336 if (ex.execDialog() )
2338 m->setExportMode(true);
2340 m->setExportMode(false);
2345 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2347 VymModel *m=currentModel();
2352 ex.addFilter ("Tex (*.tex)");
2353 ex.setDir(lastImageDir);
2354 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2355 if (ex.execDialog() )
2357 m->setExportMode(true);
2359 m->setExportMode(false);
2364 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2366 ExportKDE3Bookmarks ex;
2367 VymModel *m=currentModel();
2375 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2377 ExportKDE4Bookmarks ex;
2378 VymModel *m=currentModel();
2386 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2388 ExportTaskjuggler ex;
2389 VymModel *m=currentModel();
2393 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2394 ex.setDir(lastImageDir);
2395 ex.addFilter ("Taskjuggler (*.tjp)");
2396 if (ex.execDialog() )
2398 m->setExportMode(true);
2400 m->setExportMode(false);
2405 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2407 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2408 // TODO add preview in dialog
2409 //ImagePreview *p =new ImagePreview (fd);
2410 //fd->setContentsPreviewEnabled( TRUE );
2411 //fd->setContentsPreview( p, p );
2412 //fd->setPreviewMode( QFileDialog::Contents );
2413 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2414 fd->setDir (QDir().current());
2415 if (fd->foundConfig())
2419 if ( fd->exec() == QDialog::Accepted )
2421 QString fn=fd->selectedFile();
2422 if (!fn.contains (".odp"))
2425 //lastImageDir=fn.left(fn.findRev ("/"));
2426 VymModel *m=currentModel();
2427 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2431 QMessageBox::warning(0,
2433 tr("Couldn't find configuration for export to Open Office\n"));
2437 void Main::fileCloseMap()
2439 VymModel *m=currentModel();
2442 if (m->hasChanged())
2444 QMessageBox mb( vymName,
2445 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2446 QMessageBox::Warning,
2447 QMessageBox::Yes | QMessageBox::Default,
2449 QMessageBox::Cancel | QMessageBox::Escape );
2450 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2451 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2454 case QMessageBox::Yes:
2456 fileSave(m, CompleteMap);
2458 case QMessageBox::No:
2459 // close without saving
2461 case QMessageBox::Cancel:
2466 // And here comes the segfault, because removeTab triggers
2467 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2468 vymViews.removeAt (tabWidget->currentIndex() );
2469 tabWidget->removeTab (tabWidget->currentIndex() );
2471 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2472 // Better would be delete (me), but then we could have a Qt error:
2473 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2474 // So we only remove data now and call deconstructor when vym closes later
2475 // this needs to be moved to vymview... me->clear();
2476 // some model->clear is needed to free up memory ...
2478 delete (m->getMapEditor());
2485 void Main::filePrint()
2487 if (currentMapEditor())
2488 currentMapEditor()->print();
2491 void Main::fileExitVYM()
2493 // Check if one or more editors have changed
2495 for (i=0;i<=vymViews.count() -1;i++)
2497 // If something changed, ask what to do
2498 if (vymViews.at(i)->getModel()->hasChanged())
2500 tabWidget->setCurrentPage(i);
2501 QMessageBox mb( vymName,
2502 tr("This map is not saved yet. Do you want to"),
2503 QMessageBox::Warning,
2504 QMessageBox::Yes | QMessageBox::Default,
2506 QMessageBox::Cancel | QMessageBox::Escape );
2507 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2508 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2511 mb.setActiveWindow();
2512 switch( mb.exec() ) {
2513 case QMessageBox::Yes:
2514 // save (the changed editors) and exit
2515 fileSave(currentModel(), CompleteMap);
2517 case QMessageBox::No:
2518 // exit without saving
2520 case QMessageBox::Cancel:
2521 // don't save and don't exit
2525 } // loop over all MEs
2529 void Main::editUndo()
2531 VymModel *m=currentModel();
2535 void Main::editRedo()
2537 VymModel *m=currentModel();
2541 void Main::gotoHistoryStep (int i)
2543 VymModel *m=currentModel();
2544 if (m) m->gotoHistoryStep(i);
2547 void Main::editCopy()
2549 VymModel *m=currentModel();
2553 void Main::editPaste()
2555 VymModel *m=currentModel();
2559 void Main::editCut()
2561 VymModel *m=currentModel();
2565 void Main::editOpenFindWidget()
2567 VymModel *m=currentModel();
2568 if (m) m->emitShowFindWidget();
2571 void Main::editFindDuplicateURLs()
2573 VymModel *m=currentModel();
2574 if (m) m->findDuplicateURLs();
2577 void Main::openTabs(QStringList urls)
2579 if (!urls.isEmpty())
2583 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2584 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2585 if (*browserPID==0 ||
2586 (browser.contains("konqueror") &&
2587 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2590 // Start a new browser, if there is not one running already or
2591 // if a previously started konqueror is gone.
2592 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2593 QString u=urls.takeFirst();
2595 QString workDir=QDir::currentDirPath();
2596 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2598 // try to set path to browser
2599 QMessageBox::warning(0,
2601 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2602 tr("Please use Settings->")+tr("Set application to open an URL"));
2605 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2606 #if defined(Q_OS_WIN32)
2607 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2608 this->thread()->wait(3000);
2610 sleep (3); //FIXME-3 needed?
2614 if (browser.contains("konqueror"))
2616 for (int i=0; i<urls.size(); i++)
2619 // Try to open new tab in existing konqueror started previously by vym
2623 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2624 "konqueror-mainwindow#1"<<
2628 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2629 "/konqueror/MainWindow_1"<<
2633 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2634 if (!QProcess::startDetached ("qdbus",args))
2638 QMessageBox::warning(0,
2640 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2642 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2644 for (int i=0; i<urls.size(); i++)
2646 // Try to open new tab in firefox
2647 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2648 if (!QProcess::startDetached (browser,args))
2652 QMessageBox::warning(0,
2654 tr("Couldn't start %1 to open a new tab").arg(browser));
2657 QMessageBox::warning(0,
2659 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2663 void Main::editOpenURL()
2666 VymModel *m=currentModel();
2669 QString url=m->getURL();
2671 if (url=="") return;
2672 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2674 QString workDir=QDir::currentDirPath();
2675 if (!procBrowser->startDetached(browser,args))
2677 // try to set path to browser
2678 QMessageBox::warning(0,
2680 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2681 tr("Please use Settings->")+tr("Set application to open an URL"));
2686 void Main::editOpenURLTab()
2688 VymModel *m=currentModel();
2692 urls.append(m->getURL());
2697 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2699 VymModel *m=currentModel();
2703 urls=m->getURLs(ignoreScrolled);
2708 void Main::editOpenMultipleURLTabs()
2710 editOpenMultipleVisURLTabs (false);
2714 void Main::editURL()
2716 VymModel *m=currentModel();
2717 if (m) m->editURL();
2720 void Main::editLocalURL()
2722 VymModel *m=currentModel();
2723 if (m) m->editLocalURL();
2726 void Main::editHeading2URL()
2728 VymModel *m=currentModel();
2729 if (m) m->editHeading2URL();
2732 void Main::editBugzilla2URL()
2734 VymModel *m=currentModel();
2735 if (m) m->editBugzilla2URL();
2738 void Main::getBugzillaData()
2740 VymModel *m=currentModel();
2742 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2743 progress.setWindowModality(Qt::WindowModal);
2744 //progress.setCancelButton (NULL);
2746 progress.setMinimumDuration (0);
2747 progress.setValue (1);
2748 progress.setValue (5);
2752 QProgressBar *pb=new QProgressBar;
2758 if (m) m->getBugzillaData();
2761 void Main::editFATE2URL()
2763 VymModel *m=currentModel();
2764 if (m) m->editFATE2URL();
2767 void Main::editHeadingFinished(VymModel *m)
2771 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2772 !prevSelection.isEmpty())
2773 m->select(prevSelection);
2778 void Main::openVymLinks(const QStringList &vl)
2780 for (int j=0; j<vl.size(); j++)
2782 // compare path with already loaded maps
2785 for (i=0;i<=vymViews.count() -1;i++)
2787 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2796 if (!QFile(vl.at(j)).exists() )
2797 QMessageBox::critical( 0, tr( "Critical Error" ),
2798 tr("Couldn't open map %1").arg(vl.at(j)));
2801 fileLoad (vl.at(j), NewMap);
2802 tabWidget->setCurrentIndex (tabWidget->count()-1);
2805 // Go to tab containing the map
2806 tabWidget->setCurrentIndex (index);
2810 void Main::editOpenVymLink()
2812 VymModel *m=currentModel();
2816 vl.append(m->getVymLink());
2821 void Main::editOpenMultipleVymLinks()
2823 QString currentVymLink;
2824 VymModel *m=currentModel();
2827 QStringList vl=m->getVymLinks();
2832 void Main::editVymLink()
2834 VymModel *m=currentModel();
2839 void Main::editDeleteVymLink()
2841 VymModel *m=currentModel();
2842 if (m) m->deleteVymLink();
2845 void Main::editToggleHideExport()
2847 VymModel *m=currentModel();
2848 if (m) m->toggleHideExport();
2851 void Main::editAddTimestamp()
2853 VymModel *m=currentModel();
2854 if (m) m->addTimestamp();
2857 void Main::editMapInfo()
2859 VymModel *m=currentModel();
2862 ExtraInfoDialog dia;
2863 dia.setMapName (m->getFileName() );
2864 dia.setAuthor (m->getAuthor() );
2865 dia.setComment(m->getComment() );
2869 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2875 BranchItem *cur=NULL;
2876 BranchItem *prev=NULL;
2877 m->nextBranch(cur,prev);
2880 if (!cur->getNote().isEmpty() ) n++;
2881 f+= cur->imageCount();
2883 xl+=cur->xlinkCount();
2884 m->nextBranch(cur,prev);
2887 stats+=QString ("%1 xLinks \n").arg (xl,6);
2888 stats+=QString ("%1 notes\n").arg (n,6);
2889 stats+=QString ("%1 images\n").arg (f,6);
2890 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2891 dia.setStats (stats);
2893 // Finally show dialog
2894 if (dia.exec() == QDialog::Accepted)
2896 m->setAuthor (dia.getAuthor() );
2897 m->setComment (dia.getComment() );
2901 void Main::editMoveUp()
2903 VymModel *m=currentModel();
2907 void Main::editMoveDown()
2909 VymModel *m=currentModel();
2910 if (m) m->moveDown();
2913 void Main::editDetach()
2915 VymModel *m=currentModel();
2919 void Main::editSortChildren()
2921 VymModel *m=currentModel();
2922 if (m) m->sortChildren(false);
2925 void Main::editSortBackChildren()
2927 VymModel *m=currentModel();
2928 if (m) m->sortChildren(true);
2931 void Main::editToggleScroll()
2933 VymModel *m=currentModel();
2934 if (m) m->toggleScroll();
2937 void Main::editExpandAll()
2939 VymModel *m=currentModel();
2940 if (m) m->emitExpandAll();
2943 void Main::editExpandOneLevel()
2945 VymModel *m=currentModel();
2946 if (m) m->emitExpandOneLevel();
2949 void Main::editCollapseOneLevel()
2951 VymModel *m=currentModel();
2952 if (m) m->emitCollapseOneLevel();
2955 void Main::editUnscrollChildren()
2957 VymModel *m=currentModel();
2958 if (m) m->unscrollChildren();
2961 void Main::editAddAttribute()
2963 VymModel *m=currentModel();
2971 void Main::editAddMapCenter()
2973 VymModel *m=currentModel();
2974 if (m) m->addMapCenter ();
2977 void Main::editNewBranch()
2979 VymModel *m=currentModel();
2982 BranchItem *bi=m->addNewBranch();
2985 if (actionSettingsAutoEditNewBranch->isOn()
2986 && !actionSettingsAutoSelectNewBranch->isOn() )
2987 prevSelection=m->getSelectString();
2989 prevSelection=QString();
2991 if (actionSettingsAutoSelectNewBranch->isOn()
2992 || actionSettingsAutoEditNewBranch->isOn())
2995 if (actionSettingsAutoEditNewBranch->isOn())
2996 currentMapEditor()->editHeading();
3001 void Main::editNewBranchBefore()
3003 VymModel *m=currentModel();
3006 BranchItem *bi=m->addNewBranchBefore();
3013 if (actionSettingsAutoEditNewBranch->isOn())
3015 if (!actionSettingsAutoSelectNewBranch->isOn())
3016 prevSelection=m->getSelectString(bi);
3017 currentMapEditor()->editHeading();
3022 void Main::editNewBranchAbove()
3024 VymModel *m=currentModel();
3027 BranchItem *bi=m->addNewBranch (-1);
3035 if (actionSettingsAutoEditNewBranch->isOn())
3037 if (!actionSettingsAutoSelectNewBranch->isOn())
3038 prevSelection=m->getSelectString (bi);
3039 currentMapEditor()->editHeading();
3044 void Main::editNewBranchBelow()
3046 VymModel *m=currentModel();
3049 BranchItem *bi=m->addNewBranch (1);
3056 if (actionSettingsAutoEditNewBranch->isOn())
3058 if (!actionSettingsAutoSelectNewBranch->isOn())
3059 prevSelection=m->getSelectString(bi);
3060 currentMapEditor()->editHeading();
3065 void Main::editImportAdd()
3067 fileLoad (ImportAdd);
3070 void Main::editImportReplace()
3072 fileLoad (ImportReplace);
3075 void Main::editSaveBranch()
3077 fileSaveAs (PartOfMap);
3080 void Main::editDeleteKeepChildren()
3082 VymModel *m=currentModel();
3083 if (m) m->deleteKeepChildren();
3086 void Main::editDeleteChildren()
3088 VymModel *m=currentModel();
3089 if (m) m->deleteChildren();
3092 void Main::editDeleteSelection()
3094 VymModel *m=currentModel();
3095 if (m && actionSettingsUseDelKey->isOn())
3096 m->deleteSelection();
3099 void Main::editLoadImage()
3101 VymModel *m=currentModel();
3102 if (m) m->loadFloatImage();
3105 void Main::editSaveImage()
3107 VymModel *m=currentModel();
3108 if (m) m->saveFloatImage();
3111 void Main::editEditXLink(QAction *a)
3113 VymModel *m=currentModel();
3115 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3118 void Main::formatSelectColor()
3120 QColor col = QColorDialog::getColor((currentColor ), this );
3121 if ( !col.isValid() ) return;
3122 colorChanged( col );
3125 void Main::formatPickColor()
3127 VymModel *m=currentModel();
3129 colorChanged( m->getCurrentHeadingColor() );
3132 void Main::colorChanged(QColor c)
3134 QPixmap pix( 16, 16 );
3136 actionFormatColor->setIconSet( pix );
3140 void Main::formatColorBranch()
3142 VymModel *m=currentModel();
3143 if (m) m->colorBranch(currentColor);
3146 void Main::formatColorSubtree()
3148 VymModel *m=currentModel();
3149 if (m) m->colorSubtree (currentColor);
3152 void Main::formatLinkStyleLine()
3154 VymModel *m=currentModel();
3157 m->setMapLinkStyle("StyleLine");
3158 actionFormatLinkStyleLine->setChecked(true);
3162 void Main::formatLinkStyleParabel()
3164 VymModel *m=currentModel();
3167 m->setMapLinkStyle("StyleParabel");
3168 actionFormatLinkStyleParabel->setChecked(true);
3172 void Main::formatLinkStylePolyLine()
3174 VymModel *m=currentModel();
3177 m->setMapLinkStyle("StylePolyLine");
3178 actionFormatLinkStylePolyLine->setChecked(true);
3182 void Main::formatLinkStylePolyParabel()
3184 VymModel *m=currentModel();
3187 m->setMapLinkStyle("StylePolyParabel");
3188 actionFormatLinkStylePolyParabel->setChecked(true);
3192 void Main::formatSelectBackColor()
3194 VymModel *m=currentModel();
3195 if (m) m->selectMapBackgroundColor();
3198 void Main::formatSelectBackImage()
3200 VymModel *m=currentModel();
3202 m->selectMapBackgroundImage();
3205 void Main::formatSelectLinkColor()
3207 VymModel *m=currentModel();
3210 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3211 m->setMapDefLinkColor( col );
3215 void Main::formatSelectSelectionColor()
3217 VymModel *m=currentModel();
3220 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3221 m->setSelectionColor (col);
3226 void Main::formatToggleLinkColorHint()
3228 VymModel *m=currentModel();
3229 if (m) m->toggleMapLinkColorHint();
3233 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3235 VymModel *m=currentModel();
3237 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3240 void Main::viewZoomReset()
3242 MapEditor *me=currentMapEditor();
3243 if (me) me->setZoomFactorTarget (1);
3246 void Main::viewZoomIn()
3248 MapEditor *me=currentMapEditor();
3249 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3252 void Main::viewZoomOut()
3254 MapEditor *me=currentMapEditor();
3255 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3258 void Main::viewCenter()
3260 VymModel *m=currentModel();
3261 if (m) m->emitShowSelection();
3264 void Main::networkStartServer()
3266 VymModel *m=currentModel();
3267 if (m) m->newServer();
3270 void Main::networkConnect()
3272 VymModel *m=currentModel();
3273 if (m) m->connectToServer();
3276 bool Main::settingsPDF()
3278 // Default browser is set in constructor
3280 QString text = QInputDialog::getText(
3281 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3282 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3284 settings.setValue ("/mainwindow/readerPDF",text);
3289 bool Main::settingsURL()
3291 // Default browser is set in constructor
3293 QString text = QInputDialog::getText(
3294 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3295 settings.value("/mainwindow/readerURL").toString()
3298 settings.setValue ("/mainwindow/readerURL",text);
3302 void Main::settingsMacroDir()
3304 QDir defdir(vymBaseDir.path() + "/macros");
3305 if (!defdir.exists())
3307 QDir dir=QFileDialog::getExistingDirectory (
3309 tr ("Directory with vym macros:"),
3310 settings.value ("/macros/macroDir",defdir.path()).toString()
3313 settings.setValue ("/macros/macroDir",dir.absolutePath());
3316 void Main::settingsUndoLevels()
3319 int i = QInputDialog::getInteger(
3321 tr("QInputDialog::getInteger()"),
3322 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3325 settings.setValue ("/mapeditor/stepsTotal",i);
3326 QMessageBox::information( this, tr( "VYM -Information:" ),
3327 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3331 void Main::settingsAutosaveToggle()
3333 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3336 void Main::settingsAutosaveTime()
3339 int i = QInputDialog::getInteger(
3341 tr("QInputDialog::getInteger()"),
3342 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3344 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3347 void Main::settingsWriteBackupFileToggle()
3349 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3352 void Main::settingsToggleAnimation()
3354 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3357 void Main::settingsToggleDelKey()
3359 if (actionSettingsUseDelKey->isOn())
3361 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3364 actionDelete->setAccel (QKeySequence (""));
3368 void Main::windowToggleNoteEditor()
3370 if (textEditor->isVisible() )
3371 windowHideNoteEditor();
3373 windowShowNoteEditor();
3376 void Main::windowToggleTreeEditor()
3378 if ( tabWidget->currentPage())
3379 vymViews.at(tabWidget->currentIndex())->toggleTreeEditor();
3382 void Main::windowToggleHistory()
3384 if (historyWindow->isVisible())
3385 historyWindow->hide();
3387 historyWindow->show();
3391 void Main::windowToggleProperty()
3393 if (branchPropertyWindow->isVisible())
3394 branchPropertyWindow->hide();
3396 branchPropertyWindow->show();
3397 branchPropertyWindow->setModel (currentModel() );
3400 void Main::windowToggleAntiAlias()
3402 bool b=actionViewToggleAntiAlias->isOn();
3404 for (int i=0;i<vymViews.count();i++)
3406 me=vymViews.at(i)->getMapEditor();
3407 if (me) me->setAntiAlias(b);
3412 bool Main::isAliased()
3414 return actionViewToggleAntiAlias->isOn();
3417 bool Main::hasSmoothPixmapTransform()
3419 return actionViewToggleSmoothPixmapTransform->isOn();
3422 void Main::windowToggleSmoothPixmap()
3424 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3426 for (int i=0;i<vymViews.count();i++)
3429 me=vymViews.at(i)->getMapEditor();
3430 if (me) me->setSmoothPixmap(b);
3434 void Main::updateHistory(SimpleSettings &undoSet)
3436 historyWindow->update (undoSet);
3439 void Main::updateNoteFlag()
3441 // this slot is connected to TextEditor::textHasChanged()
3442 VymModel *m=currentModel();
3443 if (m) m->updateNoteFlag();
3446 void Main::updateNoteEditor(QModelIndex index )
3448 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3450 cout << "Main::updateNoteEditor model="<<sender();
3451 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3453 textEditor->setNote (ti->getNoteObj() );
3456 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3458 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3460 if (model && model==currentModel() )
3464 if (!oldsel.indexes().isEmpty() )
3466 ti=model->getItem(oldsel.indexes().first());
3468 // Don't update note if both treeItem and textEditor are empty
3469 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3470 // ti->setNoteObj (textEditor->getNoteObj(),false );
3472 if (!newsel.indexes().isEmpty() )
3474 ti=model->getItem(newsel.indexes().first());
3475 if (!ti->hasEmptyNote() )
3476 textEditor->setNote(ti->getNoteObj() );
3478 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3480 // Show URL and link in statusbar
3482 QString s=ti->getURL();
3483 if (!s.isEmpty() ) status+="URL: "+s+" ";
3485 if (!s.isEmpty() ) status+="Link: "+s;
3486 if (!status.isEmpty() ) statusMessage (status);
3489 textEditor->setInactive();
3495 void Main::updateActions()
3497 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3498 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3499 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3500 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3502 VymModel *m =currentModel();
3506 actionFilePrint->setEnabled (true);
3508 // Link style in context menu
3509 switch (m->getMapLinkStyle())
3511 case LinkableMapObj::Line:
3512 actionFormatLinkStyleLine->setChecked(true);
3514 case LinkableMapObj::Parabel:
3515 actionFormatLinkStyleParabel->setChecked(true);
3517 case LinkableMapObj::PolyLine:
3518 actionFormatLinkStylePolyLine->setChecked(true);
3520 case LinkableMapObj::PolyParabel:
3521 actionFormatLinkStylePolyParabel->setChecked(true);
3528 QPixmap pix( 16, 16 );
3529 pix.fill( m->getMapBackgroundColor() );
3530 actionFormatBackColor->setIconSet( pix );
3531 pix.fill( m->getSelectionColor() );
3532 actionFormatSelectionColor->setIconSet( pix );
3533 pix.fill( m->getMapDefLinkColor() );
3534 actionFormatLinkColor->setIconSet( pix );
3537 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3540 // Expanding/collapsing
3541 actionExpandAll->setEnabled (true);
3542 actionExpandOneLevel->setEnabled (true);
3543 actionCollapseOneLevel->setEnabled (true);
3547 actionFilePrint->setEnabled (false);
3549 // Expanding/collapsing
3550 actionExpandAll->setEnabled (false);
3551 actionExpandOneLevel->setEnabled (false);
3552 actionCollapseOneLevel->setEnabled (false);
3555 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3556 actionFormatLinkColorHint->setChecked(true);
3558 actionFormatLinkColorHint->setChecked(false);
3561 if (m && m->hasChanged() )
3562 actionFileSave->setEnabled( true);
3564 actionFileSave->setEnabled( false);
3565 if (m && m->isUndoAvailable())
3566 actionUndo->setEnabled( true);
3568 actionUndo->setEnabled( false);
3570 if (m && m->isRedoAvailable())
3571 actionRedo->setEnabled( true);
3573 actionRedo->setEnabled( false);
3577 TreeItem *selti=m->getSelectedItem();
3578 BranchItem *selbi=m->getSelectedBranch();
3581 if (selbi || selti->getType()==TreeItem::Image)
3583 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3584 actionFormatHideLinkUnselected->setEnabled (true);
3589 // Take care of xlinks
3590 branchXLinksContextMenuEdit->clear();
3591 if (selbi->xlinkCount()>0)
3595 for (int i=0; i<selbi->xlinkCount();++i)
3597 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3601 if (s.length()>xLinkMenuWidth)
3602 s=s.left(xLinkMenuWidth)+"...";
3603 branchXLinksContextMenuEdit->addAction (s);
3608 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3611 actionToggleScroll->setEnabled (true);
3612 if ( selbi->isScrolled() )
3613 actionToggleScroll->setChecked(true);
3615 actionToggleScroll->setChecked(false);
3617 if ( selti->getURL().isEmpty() )
3619 actionOpenURL->setEnabled (false);
3620 actionOpenURLTab->setEnabled (false);
3624 actionOpenURL->setEnabled (true);
3625 actionOpenURLTab->setEnabled (true);
3627 if ( selti->getVymLink().isEmpty() )
3629 actionOpenVymLink->setEnabled (false);
3630 actionDeleteVymLink->setEnabled (false);
3633 actionOpenVymLink->setEnabled (true);
3634 actionDeleteVymLink->setEnabled (true);
3637 if (selbi->canMoveUp())
3638 actionMoveUp->setEnabled (true);
3640 actionMoveUp->setEnabled (false);
3641 if (selbi->canMoveDown())
3642 actionMoveDown->setEnabled (true);
3644 actionMoveDown->setEnabled (false);
3646 actionSortChildren->setEnabled (true);
3647 actionSortBackChildren->setEnabled (true);
3649 actionToggleHideExport->setEnabled (true);
3650 actionToggleHideExport->setChecked (selbi->hideInExport() );
3652 actionCopy->setEnabled (true);
3653 actionCut->setEnabled (true);
3654 if (!clipboardEmpty)
3655 actionPaste->setEnabled (true);
3657 actionPaste->setEnabled (false);
3658 for (int i=0; i<actionListBranches.size(); ++i)
3659 actionListBranches.at(i)->setEnabled(true);
3660 actionDelete->setEnabled (true);
3662 if ( selti->getType()==TreeItem::Image)
3664 actionOpenURL->setEnabled (false);
3665 actionOpenVymLink->setEnabled (false);
3666 actionDeleteVymLink->setEnabled (false);
3667 actionToggleHideExport->setEnabled (true);
3668 actionToggleHideExport->setChecked (selti->hideInExport() );
3671 actionCopy->setEnabled (true);
3672 actionCut->setEnabled (true);
3673 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3674 for (int i=0; i<actionListBranches.size(); ++i)
3675 actionListBranches.at(i)->setEnabled(false);
3676 actionDelete->setEnabled (true);
3677 actionMoveUp->setEnabled (false);
3678 actionMoveDown->setEnabled (false);
3683 actionCopy->setEnabled (false);
3684 actionCut->setEnabled (false);
3685 actionPaste->setEnabled (false);
3686 for (int i=0; i<actionListBranches.size(); ++i)
3687 actionListBranches.at(i)->setEnabled(false);
3689 actionToggleScroll->setEnabled (false);
3690 actionOpenURL->setEnabled (false);
3691 actionOpenVymLink->setEnabled (false);
3692 actionDeleteVymLink->setEnabled (false);
3693 actionHeading2URL->setEnabled (false);
3694 actionDelete->setEnabled (false);
3695 actionMoveUp->setEnabled (false);
3696 actionMoveDown->setEnabled (false);
3697 actionFormatHideLinkUnselected->setEnabled (false);
3698 actionSortChildren->setEnabled (false);
3699 actionSortBackChildren->setEnabled (false);
3700 actionToggleHideExport->setEnabled (false);
3705 Main::ModMode Main::getModMode()
3707 if (actionModModeColor->isOn()) return ModModeColor;
3708 if (actionModModeCopy->isOn()) return ModModeCopy;
3709 if (actionModModeXLink->isOn()) return ModModeXLink;
3713 bool Main::autoEditNewBranch()
3715 return actionSettingsAutoEditNewBranch->isOn();
3718 bool Main::autoSelectNewBranch()
3720 return actionSettingsAutoSelectNewBranch->isOn();
3723 void Main::windowShowNoteEditor()
3725 textEditor->setShowWithMain(true);
3727 actionViewToggleNoteEditor->setChecked (true);
3730 void Main::windowHideNoteEditor()
3732 textEditor->setShowWithMain(false);
3734 actionViewToggleNoteEditor->setChecked (false);
3737 void Main::setScript (const QString &script)
3739 scriptEditor->setScript (script);
3742 void Main::runScript (const QString &script)
3744 VymModel *m=currentModel();
3745 if (m) m->runScript (script);
3748 void Main::runScriptEverywhere (const QString &script)
3751 for (int i=0;i<=tabWidget->count() -1;i++)
3753 me=(MapEditor*)tabWidget->page(i);
3754 if (me) me->getModel()->runScript (script);
3758 void Main::windowNextEditor()
3760 if (tabWidget->currentIndex() < tabWidget->count())
3761 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3764 void Main::windowPreviousEditor()
3766 if (tabWidget->currentIndex() >0)
3767 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3770 void Main::standardFlagChanged()
3774 if ( actionSettingsUseFlagGroups->isOn() )
3775 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3777 currentModel()->toggleStandardFlag(sender()->name());
3783 #include "attributeitem.h"
3784 void Main::testFunction1()
3786 VymModel *m=currentModel();
3789 BranchItem *selbi=m->getSelectedBranch();
3792 QList<QVariant> cData;
3793 cData << "new ai" << "undef";
3795 AttributeItem *ai=new AttributeItem (cData,selbi);
3796 ai->set ("Key 1","Val a",AttributeItem::FreeString);
3798 m->addAttribute (ai);
3803 if (!currentMapEditor()) return;
3804 currentMapEditor()->testFunction1();
3808 VymModel *m=currentModel();
3812 QString text = QInputDialog::getText(
3813 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3814 m->getSortFilter(), &ok, NULL);
3816 // user entered something and pressed OK
3817 m->setSortFilter (text);
3821 void Main::testFunction2()
3823 if (!currentMapEditor()) return;
3824 currentMapEditor()->testFunction2();
3827 void Main::testCommand()
3829 if (!currentMapEditor()) return;
3830 scriptEditor->show();
3833 QString com = QInputDialog::getText(
3834 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3835 if (ok) currentMapEditor()->parseAtom(com);
3839 void Main::helpDoc()
3841 QString locale = QLocale::system().name();
3843 if (locale.left(2)=="es")
3844 docname="vym_es.pdf";
3848 QStringList searchList;
3850 #if defined(Q_OS_MACX)
3851 searchList << "./vym.app/Contents/Resources/doc";
3852 #elif defined(Q_OS_WIN32)
3853 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3855 #if defined(VYM_DOCDIR)
3856 searchList << VYM_DOCDIR;
3858 // default path in SUSE LINUX
3859 searchList << "/usr/share/doc/packages/vym";
3862 searchList << "doc"; // relative path for easy testing in tarball
3863 searchList << "doc/tex"; // Easy testing working on vym.tex
3864 searchList << "/usr/share/doc/vym"; // Debian
3865 searchList << "/usr/share/doc/packages";// Knoppix
3869 for (int i=0; i<searchList.count(); ++i)
3871 docfile.setFileName(searchList.at(i)+"/"+docname);
3872 if (docfile.exists())
3881 QMessageBox::critical(0,
3882 tr("Critcal error"),
3883 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3888 Process *pdfProc = new Process();
3889 args << QDir::toNativeSeparators(docfile.fileName());
3891 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3894 QMessageBox::warning(0,
3896 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3897 tr("Please use Settings->")+tr("Set application to open PDF files"));
3904 void Main::helpDemo()
3906 QStringList filters;
3907 filters <<"VYM example map (*.vym)";
3908 QFileDialog *fd=new QFileDialog( this);
3909 #if defined(Q_OS_MACX)
3910 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3912 // default path in SUSE LINUX
3913 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3916 fd->setFileMode (QFileDialog::ExistingFiles);
3917 fd->setFilters (filters);
3918 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3922 if ( fd->exec() == QDialog::Accepted )
3924 lastFileDir=fd->directory().path();
3925 QStringList flist = fd->selectedFiles();
3926 QStringList::Iterator it = flist.begin();
3927 while( it != flist.end() )
3930 fileLoad(*it, NewMap);
3938 void Main::helpAbout()
3941 ad.setName ("aboutwindow");
3942 ad.setMinimumSize(500,500);
3943 ad.resize (QSize (500,500));
3947 void Main::helpAboutQT()
3949 QMessageBox::aboutQt( this, "Qt Application Example" );
3952 void Main::callMacro ()
3954 QAction *action = qobject_cast<QAction *>(sender());
3958 i=action->data().toInt();
3959 QString mDir (settings.value ("macros/macroDir").toString() );
3961 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3963 if ( !f.open( QIODevice::ReadOnly ) )
3965 QMessageBox::warning(0,
3967 tr("Couldn't find a macro at %1.\n").arg(fn)+
3968 tr("Please use Settings->")+tr("Set directory for vym macros"));
3972 QTextStream ts( &f );
3973 QString macro= ts.read();
3975 if (! macro.isEmpty())
3977 VymModel *m=currentModel();
3978 if (m) m->runScript(macro);