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(iconPath+"history.png"), tr( "History Window","View action" ),this );
1137 a->setStatusTip ( tr( "Show History Window" ));
1138 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1139 a->setToggleAction(true);
1141 viewMenu->addAction (a);
1142 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1143 actionViewToggleHistoryWindow=a;
1145 viewMenu->addAction (actionViewTogglePropertyWindow);
1147 viewMenu->addSeparator();
1149 a = new QAction(tr( "Antialiasing","View action" ),this );
1150 a->setStatusTip ( tr( "Antialiasing" ));
1151 a->setToggleAction(true);
1152 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1153 viewMenu->addAction (a);
1154 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1155 actionViewToggleAntiAlias=a;
1157 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1158 a->setStatusTip (a->text());
1159 a->setToggleAction(true);
1160 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1161 viewMenu->addAction (a);
1162 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1163 actionViewToggleSmoothPixmapTransform=a;
1165 a = new QAction(tr( "Next Map","View action" ), this);
1166 a->setStatusTip (a->text());
1167 a->setShortcut (Qt::ALT + Qt::Key_N );
1168 viewMenu->addAction (a);
1169 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1171 a = new QAction (tr( "Previous Map","View action" ), this );
1172 a->setStatusTip (a->text());
1173 a->setShortcut (Qt::ALT + Qt::Key_P );
1174 viewMenu->addAction (a);
1175 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1177 if (debug) switchboard.print();
1181 void Main::setupModeActions()
1183 //QPopupMenu *menu = new QPopupMenu( this );
1184 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1186 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1187 tb->setObjectName ("modesTB");
1189 actionGroupModModes=new QActionGroup ( this);
1190 actionGroupModModes->setExclusive (true);
1191 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1192 a->setShortcut (Qt::Key_J);
1193 a->setStatusTip ( tr( "Use modifier to color branches" ));
1194 a->setToggleAction(true);
1196 a->setChecked(true);
1197 actionModModeColor=a;
1199 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1200 a->setShortcut( Qt::Key_K);
1201 a->setStatusTip( tr( "Use modifier to copy" ));
1202 a->setToggleAction(true);
1204 actionModModeCopy=a;
1206 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1207 a->setShortcut (Qt::Key_L);
1208 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1209 a->setToggleAction(true);
1211 actionModModeXLink=a;
1215 void Main::setupFlagActions()
1217 // Create System Flags
1220 Flag *flag=new Flag;;
1221 flag->setVisible(true);
1223 flag->load(QPixmap(flagsPath+"flag-note.png"));
1224 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1226 flag->load(QPixmap(flagsPath+"flag-url.png"));
1227 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1229 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1230 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1232 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1233 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1235 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1236 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1238 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1239 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1241 // Create Standard Flags
1242 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1243 tb->setObjectName ("standardFlagTB");
1244 standardFlagsMaster->setToolBar (tb);
1246 flag->load(flagsPath+"flag-exclamationmark.png");
1247 flag->setGroup("standard-mark");
1248 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1250 flag->load(flagsPath+"flag-questionmark.png");
1251 flag->setGroup("standard-mark");
1252 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1254 flag->load(flagsPath+"flag-hook-green.png");
1255 flag->setGroup("standard-status");
1256 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1258 flag->load(flagsPath+"flag-wip.png");
1259 flag->setGroup("standard-status");
1260 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1262 flag->load(flagsPath+"flag-cross-red.png");
1263 flag->setGroup("standard-status");
1264 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1267 flag->load(flagsPath+"flag-stopsign.png");
1268 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1270 flag->load(flagsPath+"flag-smiley-good.png");
1271 flag->setGroup("standard-smiley");
1272 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1274 flag->load(flagsPath+"flag-smiley-sad.png");
1275 flag->setGroup("standard-smiley");
1276 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1278 flag->load(flagsPath+"flag-smiley-omg.png");
1279 flag->setGroup("standard-smiley");
1280 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1281 // Original omg.png (in KDE emoticons)
1284 flag->load(flagsPath+"flag-kalarm.png");
1285 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1287 flag->load(flagsPath+"flag-phone.png");
1288 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1290 flag->load(flagsPath+"flag-lamp.png");
1291 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1293 flag->load(flagsPath+"flag-arrow-up.png");
1294 flag->setGroup("standard-arrow");
1295 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1297 flag->load(flagsPath+"flag-arrow-down.png");
1298 flag->setGroup("standard-arrow");
1299 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1301 flag->load(flagsPath+"flag-arrow-2up.png");
1302 flag->setGroup("standard-arrow");
1303 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1305 flag->load(flagsPath+"flag-arrow-2down.png");
1306 flag->setGroup("standard-arrow");
1307 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1310 flag->load(flagsPath+"flag-thumb-up.png");
1311 flag->setGroup("standard-thumb");
1312 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1314 flag->load(flagsPath+"flag-thumb-down.png");
1315 flag->setGroup("standard-thumb");
1316 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1319 flag->load(flagsPath+"flag-rose.png");
1320 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1322 flag->load(flagsPath+"flag-heart.png");
1323 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1325 flag->load(flagsPath+"flag-present.png");
1326 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1328 flag->load(flagsPath+"flag-flash.png");
1329 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1331 // Original: xsldbg_output.png
1332 flag->load(flagsPath+"flag-info.png");
1333 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1335 // Original khelpcenter.png
1336 flag->load(flagsPath+"flag-lifebelt.png");
1337 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1340 flag->setVisible(false);
1341 flag->load(flagsPath+"freemind/warning.png");
1342 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1344 for (int i=1; i<8; i++)
1346 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1347 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1350 flag->load(flagsPath+"freemind/back.png");
1351 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1353 flag->load(flagsPath+"freemind/forward.png");
1354 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1356 flag->load(flagsPath+"freemind/attach.png");
1357 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1359 flag->load(flagsPath+"freemind/clanbomber.png");
1360 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1362 flag->load(flagsPath+"freemind/desktopnew.png");
1363 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1365 flag->load(flagsPath+"freemind/flag.png");
1366 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1369 flag->load(flagsPath+"freemind/gohome.png");
1370 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1373 flag->load(flagsPath+"freemind/kaddressbook.png");
1374 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1376 flag->load(flagsPath+"freemind/knotify.png");
1377 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1379 flag->load(flagsPath+"freemind/korn.png");
1380 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1382 flag->load(flagsPath+"freemind/mail.png");
1383 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1385 flag->load(flagsPath+"freemind/password.png");
1386 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1388 flag->load(flagsPath+"freemind/pencil.png");
1389 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1391 flag->load(flagsPath+"freemind/stop.png");
1392 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1394 flag->load(flagsPath+"freemind/wizard.png");
1395 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1397 flag->load(flagsPath+"freemind/xmag.png");
1398 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1400 flag->load(flagsPath+"freemind/bell.png");
1401 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1403 flag->load(flagsPath+"freemind/bookmark.png");
1404 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1406 flag->load(flagsPath+"freemind/penguin.png");
1407 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1409 flag->load(flagsPath+"freemind/licq.png");
1410 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1413 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1415 flag->setName(name);
1416 flag->setToolTip (tooltip);
1420 a=new QAction (flag->getPixmap(),name,this);
1423 flag->setAction (a);
1424 a->setVisible (flag->isVisible());
1425 a->setCheckable(true);
1426 a->setObjectName(name);
1427 a->setToolTip(tooltip);
1428 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1429 standardFlagsMaster->addFlag (flag);
1433 systemFlagsMaster->addFlag (flag);
1438 void Main::setupNetworkActions()
1440 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1442 QMenu *netMenu = menuBar()->addMenu( "Network" );
1446 a = new QAction( "Start TCPserver for MapEditor",this);
1447 //a->setStatusTip ( "Set application to open pdf files"));
1448 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1449 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1450 netMenu->addAction (a);
1452 a = new QAction( "Connect MapEditor to server",this);
1453 //a->setStatusTip ( "Set application to open pdf files"));
1454 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1455 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1456 netMenu->addAction (a);
1460 void Main::setupSettingsActions()
1462 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1466 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1467 a->setStatusTip ( tr( "Set application to open pdf files"));
1468 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1469 settingsMenu->addAction (a);
1471 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1472 a->setStatusTip( tr( "Set application to open external links"));
1473 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1474 settingsMenu->addAction (a);
1476 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1477 a->setStatusTip( tr( "Set path for macros"));
1478 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1479 settingsMenu->addAction (a);
1481 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1482 a->setStatusTip( tr( "Set number of undo levels"));
1483 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1484 settingsMenu->addAction (a);
1486 settingsMenu->addSeparator();
1488 a = new QAction( tr( "Autosave","Settings action"), this);
1489 a->setStatusTip( tr( "Autosave"));
1490 a->setToggleAction(true);
1491 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1492 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1493 settingsMenu->addAction (a);
1494 actionSettingsAutosaveToggle=a;
1496 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1497 a->setStatusTip( tr( "Autosave time"));
1498 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1499 settingsMenu->addAction (a);
1500 actionSettingsAutosaveTime=a;
1502 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1503 a->setStatusTip( tr( "Write backup file on save"));
1504 a->setToggleAction(true);
1505 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1506 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1507 settingsMenu->addAction (a);
1508 actionSettingsWriteBackupFile=a;
1510 settingsMenu->addSeparator();
1512 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1513 a->setStatusTip( tr( "Edit branch after adding it" ));
1514 a->setToggleAction(true);
1515 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1516 settingsMenu->addAction (a);
1517 actionSettingsAutoEditNewBranch=a;
1519 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1520 a->setStatusTip( tr( "Select branch after adding it" ));
1521 a->setToggleAction(true);
1522 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1523 settingsMenu->addAction (a);
1524 actionSettingsAutoSelectNewBranch=a;
1526 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1527 a->setStatusTip( tr( "Select heading before editing" ));
1528 a->setToggleAction(true);
1529 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1530 settingsMenu->addAction (a);
1531 actionSettingsAutoSelectText=a;
1533 a= new QAction( tr( "Delete key","Settings action" ), this);
1534 a->setStatusTip( tr( "Delete key for deleting branches" ));
1535 a->setToggleAction(true);
1536 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1537 settingsMenu->addAction (a);
1538 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1539 actionSettingsUseDelKey=a;
1541 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1542 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1543 a->setToggleAction(true);
1544 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1545 settingsMenu->addAction (a);
1546 actionSettingsUseFlagGroups=a;
1548 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1549 a->setStatusTip( tr( "Use hide flag during exports " ));
1550 a->setToggleAction(true);
1551 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1552 settingsMenu->addAction (a);
1553 actionSettingsUseHideExport=a;
1555 a = new QAction( tr( "Animation","Settings action"), this);
1556 a->setStatusTip( tr( "Animation"));
1557 a->setToggleAction(true);
1558 a->setChecked (settings.value("/animation/use",true).toBool() );
1559 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1560 settingsMenu->addAction (a);
1561 actionSettingsUseAnimation=a;
1565 void Main::setupTestActions()
1567 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1570 a = new QAction( "Test function 1" , this);
1571 a->setStatusTip( "Call test function 1" );
1572 a->setShortcut (Qt::CTRL + Qt::Key_T); // Test function 1 //FIXME-2 originally: color subtree
1573 testMenu->addAction (a);
1574 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1576 a = new QAction( "Test function 2" , this);
1577 a->setStatusTip( "Call test function 2" );
1578 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 2
1579 testMenu->addAction (a);
1580 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1582 a = new QAction( "Command" , this);
1583 a->setStatusTip( "Enter command to call in editor" );
1584 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1585 testMenu->addAction (a);
1589 void Main::setupHelpActions()
1591 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1594 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1595 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1596 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1597 helpMenu->addAction (a);
1599 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1600 a->setStatusTip( tr( "Open VYM example maps " ));
1601 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1602 helpMenu->addAction (a);
1604 a = new QAction( tr( "About VYM","Help action" ), this);
1605 a->setStatusTip( tr( "About VYM")+vymName);
1606 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1607 helpMenu->addAction (a);
1609 a = new QAction( tr( "About QT","Help action" ), this);
1610 a->setStatusTip( tr( "Information about QT toolkit" ));
1611 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1612 helpMenu->addAction (a);
1616 void Main::setupContextMenus()
1620 // Context Menu for branch or mapcenter
1621 branchContextMenu =new QMenu (this);
1622 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1623 branchContextMenu->addSeparator();
1626 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1627 branchAddContextMenu->addAction (actionPaste );
1628 branchAddContextMenu->addAction ( actionAddMapCenter );
1629 branchAddContextMenu->addAction ( actionAddBranch );
1630 branchAddContextMenu->addAction ( actionAddBranchBefore );
1631 branchAddContextMenu->addAction ( actionAddBranchAbove);
1632 branchAddContextMenu->addAction ( actionAddBranchBelow );
1633 branchAddContextMenu->addSeparator();
1634 branchAddContextMenu->addAction ( actionImportAdd );
1635 branchAddContextMenu->addAction ( actionImportReplace );
1638 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1639 branchRemoveContextMenu->addAction (actionCut);
1640 branchRemoveContextMenu->addAction ( actionDelete );
1641 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1642 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1645 actionSaveBranch->addTo( branchContextMenu );
1646 actionFileNewCopy->addTo (branchContextMenu );
1647 actionDetach->addTo (branchContextMenu );
1649 branchContextMenu->addSeparator();
1650 branchContextMenu->addAction ( actionLoadImage);
1651 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1652 branchContextMenu->addAction ( actionAddAttribute);
1654 // Submenu for Links (URLs, vymLinks)
1655 branchLinksContextMenu =new QMenu (this);
1657 branchContextMenu->addSeparator();
1658 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1659 branchLinksContextMenu->addAction ( actionOpenURL );
1660 branchLinksContextMenu->addAction ( actionOpenURLTab );
1661 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1662 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1663 branchLinksContextMenu->addAction ( actionURL );
1664 branchLinksContextMenu->addAction ( actionLocalURL );
1665 branchLinksContextMenu->addAction ( actionHeading2URL );
1666 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1667 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1669 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1670 branchLinksContextMenu->addAction ( actionFATE2URL );
1672 branchLinksContextMenu->addSeparator();
1673 branchLinksContextMenu->addAction ( actionOpenVymLink );
1674 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1675 branchLinksContextMenu->addAction ( actionVymLink );
1676 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1679 // Context Menu for XLinks in a branch menu
1680 // This will be populated "on demand" in MapEditor::updateActions
1681 branchContextMenu->addSeparator();
1682 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1683 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1686 // Context menu for floatimage
1687 floatimageContextMenu =new QMenu (this);
1688 a= new QAction (tr ("Save image","Context action"),this);
1689 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1690 floatimageContextMenu->addAction (a);
1692 floatimageContextMenu->addSeparator();
1693 actionCopy->addTo( floatimageContextMenu );
1694 actionCut->addTo( floatimageContextMenu );
1696 floatimageContextMenu->addSeparator();
1697 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1700 // Context menu for canvas
1701 canvasContextMenu =new QMenu (this);
1702 actionAddMapCenter->addTo( canvasContextMenu );
1703 actionMapInfo->addTo( canvasContextMenu );
1704 canvasContextMenu->insertSeparator();
1705 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1706 canvasContextMenu->insertSeparator();
1707 actionFormatLinkColorHint->addTo( canvasContextMenu );
1708 actionFormatLinkColor->addTo( canvasContextMenu );
1709 actionFormatSelectionColor->addTo( canvasContextMenu );
1710 actionFormatBackColor->addTo( canvasContextMenu );
1711 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1713 // Menu for last opened files
1715 for (int i = 0; i < MaxRecentFiles; ++i)
1717 recentFileActions[i] = new QAction(this);
1718 recentFileActions[i]->setVisible(false);
1719 fileLastMapsMenu->addAction(recentFileActions[i]);
1720 connect(recentFileActions[i], SIGNAL(triggered()),
1721 this, SLOT(fileLoadRecent()));
1723 setupRecentMapsMenu();
1726 void Main::setupRecentMapsMenu()
1728 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1730 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1732 for (int i = 0; i < numRecentFiles; ++i) {
1733 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1734 recentFileActions[i]->setText(text);
1735 recentFileActions[i]->setData(files[i]);
1736 recentFileActions[i]->setVisible(true);
1738 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1739 recentFileActions[j]->setVisible(false);
1742 void Main::setupMacros()
1744 for (int i = 0; i <= 11; i++)
1746 macroActions[i] = new QAction(this);
1747 macroActions[i]->setData(i);
1748 addAction (macroActions[i]);
1749 connect(macroActions[i], SIGNAL(triggered()),
1750 this, SLOT(callMacro()));
1752 macroActions[0]->setShortcut ( Qt::Key_F1 );
1753 macroActions[1]->setShortcut ( Qt::Key_F2 );
1754 macroActions[2]->setShortcut ( Qt::Key_F3 );
1755 macroActions[3]->setShortcut ( Qt::Key_F4 );
1756 macroActions[4]->setShortcut ( Qt::Key_F5 );
1757 macroActions[5]->setShortcut ( Qt::Key_F6 );
1758 macroActions[6]->setShortcut ( Qt::Key_F7 );
1759 macroActions[7]->setShortcut ( Qt::Key_F8 );
1760 macroActions[8]->setShortcut ( Qt::Key_F9 );
1761 macroActions[9]->setShortcut ( Qt::Key_F10 );
1762 macroActions[10]->setShortcut ( Qt::Key_F11 );
1763 macroActions[11]->setShortcut ( Qt::Key_F12 );
1766 void Main::hideEvent (QHideEvent * )
1768 if (!textEditor->isMinimized() ) textEditor->hide();
1771 void Main::showEvent (QShowEvent * )
1773 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1777 MapEditor* Main::currentMapEditor() const
1779 if ( tabWidget->currentPage())
1780 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1784 VymModel* Main::currentModel() const
1786 if ( tabWidget->currentPage())
1787 return vymViews.at(tabWidget->currentIndex())->getModel();
1792 void Main::editorChanged(QWidget *)
1794 // Unselect all possibly selected objects
1795 // (Important to update note editor)
1797 for (int i=0;i<=tabWidget->count() -1;i++)
1799 m= vymViews.at(i)->getModel();
1800 if (m) m->unselect();
1803 if (m) m->reselect();
1805 // Update actions to in menus and toolbars according to editor
1809 void Main::fileNew()
1811 VymModel *vm=new VymModel;
1813 /////////////////////////////////////
1814 // new ModelTest(vm, this); //FIXME-3
1815 /////////////////////////////////////
1817 VymView *vv=new VymView (vm);
1818 vymViews.append (vv);
1819 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1820 tabWidget->setCurrentIndex (vymViews.count() );
1823 // Create MapCenter for empty map
1827 // For the very first map we do not have flagrows yet...
1831 void Main::fileNewCopy()
1833 QString fn="unnamed";
1834 VymModel *srcModel=currentModel();
1839 VymModel *dstModel=vymViews.last()->getModel();
1840 dstModel->select("mc:");
1841 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1845 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1847 ErrorCode err=success;
1849 // fn is usually the archive, mapfile the file after uncompressing
1852 // Make fn absolute (needed for unzip)
1853 fn=QDir (fn).absPath();
1859 // Check, if map is already loaded
1861 while (i<=tabWidget->count() -1)
1863 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1865 // Already there, ask for confirmation
1866 QMessageBox mb( vymName,
1867 tr("The map %1\nis already opened."
1868 "Opening the same map in multiple editors may lead \n"
1869 "to confusion when finishing working with vym."
1870 "Do you want to").arg(fn),
1871 QMessageBox::Warning,
1872 QMessageBox::Yes | QMessageBox::Default,
1873 QMessageBox::Cancel | QMessageBox::Escape,
1874 QMessageBox::NoButton);
1875 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1876 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1879 case QMessageBox::Yes:
1880 // end loop and load anyway
1881 i=tabWidget->count();
1883 case QMessageBox::Cancel:
1893 int tabIndex=tabWidget->currentPageIndex();
1896 if ( !fn.isEmpty() )
1898 vm = currentModel();
1899 // Check first, if mapeditor exists
1900 // If it is not default AND we want a new map,
1901 // create a new mapeditor in a new tab
1902 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1905 VymView *vv=new VymView (vm);
1906 vymViews.append (vv);
1907 tabWidget->addTab (vv,fn);
1908 tabIndex=tabWidget->count()-1;
1909 tabWidget->setCurrentPage (tabIndex);
1913 // Check, if file exists (important for creating new files
1914 // from command line
1915 if (!QFile(fn).exists() )
1917 QMessageBox mb( vymName,
1918 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1919 QMessageBox::Question,
1921 QMessageBox::Cancel | QMessageBox::Default,
1922 QMessageBox::NoButton );
1924 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1925 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1928 case QMessageBox::Yes:
1930 currentMapEditor()->getModel()->setFilePath(fn);
1931 tabWidget->setTabText (tabIndex,
1932 currentMapEditor()->getModel()->getFileName() );
1933 statusBar()->message( "Created " + fn , statusbarTime );
1936 case QMessageBox::Cancel:
1937 // don't create new map
1938 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1945 //tabWidget->currentPage() won't be NULL here, because of above...
1946 tabWidget->setCurrentIndex (tabIndex);
1947 //FIXME-3 no me anymore... me->viewport()->setFocus();
1951 // Save existing filename in case we import
1952 QString fn_org=vm->getFilePath();
1954 // Finally load map into mapEditor
1955 vm->setFilePath (fn);
1956 err=vm->load(fn,lmode,ftype);
1958 // Restore old (maybe empty) filepath, if this is an import
1960 vm->setFilePath (fn_org);
1963 // Finally check for errors and go home
1966 if (lmode==NewMap) fileCloseMap();
1967 statusBar()->message( "Could not load " + fn, statusbarTime );
1972 vm->setFilePath (fn);
1973 tabWidget->setTabText (tabIndex, vm->getFileName());
1974 if (!isInTmpDir (fn))
1976 // Only append to lastMaps if not loaded from a tmpDir
1977 // e.g. imported bookmarks are in a tmpDir
1978 addRecentMap(vm->getFilePath() );
1980 actionFilePrint->setEnabled (true);
1982 statusBar()->message( "Loaded " + fn, statusbarTime );
1989 void Main::fileLoad(const LoadMode &lmode)
1991 QStringList filters;
1992 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1993 QFileDialog *fd=new QFileDialog( this);
1994 fd->setDir (lastFileDir);
1995 fd->setFileMode (QFileDialog::ExistingFiles);
1996 fd->setFilters (filters);
2000 fd->setCaption(vymName+ " - " +tr("Load vym map"));
2003 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
2006 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2012 if ( fd->exec() == QDialog::Accepted )
2014 lastFileDir=fd->directory().path();
2015 QStringList flist = fd->selectedFiles();
2016 QStringList::Iterator it = flist.begin();
2018 progressCounter=flist.count();
2019 progressCounterTotal=flist.count();
2020 while( it != flist.end() )
2023 fileLoad(*it, lmode);
2030 void Main::fileLoad()
2035 void Main::fileLoadRecent()
2037 QAction *action = qobject_cast<QAction *>(sender());
2039 fileLoad (action->data().toString(), NewMap);
2042 void Main::addRecentMap (const QString &fileName)
2045 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2046 files.removeAll(fileName);
2047 files.prepend(fileName);
2048 while (files.size() > MaxRecentFiles)
2051 settings.setValue("/mainwindow/recentFileList", files);
2053 setupRecentMapsMenu();
2056 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2060 if ( m->getFilePath().isEmpty() )
2062 // We have no filepath yet,
2063 // call fileSaveAs() now, this will call fileSave()
2065 // First switch to editor
2066 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2067 fileSaveAs(savemode);
2070 if (m->save (savemode)==success)
2072 statusBar()->message(
2073 tr("Saved %1").arg(m->getFilePath()),
2075 addRecentMap (m->getFilePath() );
2077 statusBar()->message(
2078 tr("Couldn't save ").arg(m->getFilePath()),
2082 void Main::fileSave()
2084 fileSave (currentModel(), CompleteMap);
2087 void Main::fileSave(VymModel *m)
2089 fileSave (m,CompleteMap);
2092 void Main::fileSaveAs(const SaveMode& savemode)
2096 if (currentMapEditor())
2098 if (savemode==CompleteMap)
2099 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2101 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2102 if ( !fn.isEmpty() )
2104 // Check for existing file
2105 if (QFile (fn).exists())
2107 QMessageBox mb( vymName,
2108 tr("The file %1\nexists already. Do you want to").arg(fn),
2109 QMessageBox::Warning,
2110 QMessageBox::Yes | QMessageBox::Default,
2111 QMessageBox::Cancel | QMessageBox::Escape,
2112 QMessageBox::NoButton);
2113 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2114 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2117 case QMessageBox::Yes:
2120 case QMessageBox::Cancel:
2127 // New file, add extension to filename, if missing
2128 // This is always .vym or .vyp, depending on savemode
2129 if (savemode==CompleteMap)
2131 if (!fn.contains (".vym") && !fn.contains (".xml"))
2135 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2144 VymModel *m=currentModel();
2146 fileSave(m, savemode);
2148 // Set name of tab, assuming current tab is the one we just saved
2149 if (savemode==CompleteMap)
2150 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2156 void Main::fileSaveAs()
2158 fileSaveAs (CompleteMap);
2161 void Main::fileImportKDE3Bookmarks()
2163 ImportKDE3Bookmarks im;
2165 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2166 currentMapEditor()->getModel()->setFilePath ("");
2169 void Main::fileImportKDE4Bookmarks()
2171 ImportKDE4Bookmarks im;
2173 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2174 currentMapEditor()->getModel()->setFilePath ("");
2177 void Main::fileImportFirefoxBookmarks()
2179 Q3FileDialog *fd=new Q3FileDialog( this);
2180 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2181 fd->setMode (Q3FileDialog::ExistingFiles);
2182 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2183 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2186 if ( fd->exec() == QDialog::Accepted )
2188 ImportFirefoxBookmarks im;
2189 QStringList flist = fd->selectedFiles();
2190 QStringList::Iterator it = flist.begin();
2191 while( it != flist.end() )
2194 if (im.transform() &&
2195 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2196 currentMapEditor() )
2197 currentMapEditor()->getModel()->setFilePath ("");
2204 void Main::fileImportFreemind()
2206 QStringList filters;
2207 filters <<"Freemind map (*.mm)"<<"All files (*)";
2208 QFileDialog *fd=new QFileDialog( this);
2209 fd->setDir (lastFileDir);
2210 fd->setFileMode (QFileDialog::ExistingFiles);
2211 fd->setFilters (filters);
2212 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2216 if ( fd->exec() == QDialog::Accepted )
2218 lastFileDir=fd->directory().path();
2219 QStringList flist = fd->selectedFiles();
2220 QStringList::Iterator it = flist.begin();
2221 while( it != flist.end() )
2224 if ( fileLoad (fn,NewMap, FreemindMap) )
2226 currentMapEditor()->getModel()->setFilePath ("");
2235 void Main::fileImportMM()
2239 Q3FileDialog *fd=new Q3FileDialog( this);
2240 fd->setDir (lastFileDir);
2241 fd->setMode (Q3FileDialog::ExistingFiles);
2242 fd->addFilter ("Mind Manager (*.mmap)");
2243 fd->setCaption(tr("Import")+" "+"Mind Manager");
2246 if ( fd->exec() == QDialog::Accepted )
2248 lastFileDir=fd->dirPath();
2249 QStringList flist = fd->selectedFiles();
2250 QStringList::Iterator it = flist.begin();
2251 while( it != flist.end() )
2254 if (im.transform() &&
2255 success==fileLoad (im.getTransformedFile(),NewMap) &&
2256 currentMapEditor() )
2257 currentMapEditor()->getModel()->setFilePath ("");
2264 void Main::fileImportDir()
2266 VymModel *m=currentModel();
2267 if (m) m->importDir();
2270 void Main::fileExportXML()
2272 VymModel *m=currentModel();
2273 if (m) m->exportXML();
2276 void Main::fileExportHTML()
2278 VymModel *m=currentModel();
2279 if (m) m->exportHTML();
2283 void Main::fileExportXHTML()
2285 VymModel *m=currentModel();
2286 if (m) m->exportXHTML();
2289 void Main::fileExportImage()
2291 VymModel *m=currentModel();
2292 if (m) m->exportImage();
2295 void Main::fileExportAO()
2297 VymModel *m=currentModel();
2298 if (m) m->exportAO();
2301 void Main::fileExportASCII()
2303 VymModel *m=currentModel();
2304 if (m) m->exportASCII();
2307 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2309 VymModel *m=currentModel();
2314 ex.addFilter ("CSV (*.csv)");
2315 ex.setDir(lastImageDir);
2316 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2317 if (ex.execDialog() )
2319 m->setExportMode(true);
2321 m->setExportMode(false);
2326 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2328 VymModel *m=currentModel();
2333 ex.addFilter ("Tex (*.tex)");
2334 ex.setDir(lastImageDir);
2335 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2336 if (ex.execDialog() )
2338 m->setExportMode(true);
2340 m->setExportMode(false);
2345 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2347 ExportKDE3Bookmarks ex;
2348 VymModel *m=currentModel();
2356 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2358 ExportKDE4Bookmarks ex;
2359 VymModel *m=currentModel();
2367 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2369 ExportTaskjuggler ex;
2370 VymModel *m=currentModel();
2374 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2375 ex.setDir(lastImageDir);
2376 ex.addFilter ("Taskjuggler (*.tjp)");
2377 if (ex.execDialog() )
2379 m->setExportMode(true);
2381 m->setExportMode(false);
2386 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2388 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2389 // TODO add preview in dialog
2390 //ImagePreview *p =new ImagePreview (fd);
2391 //fd->setContentsPreviewEnabled( TRUE );
2392 //fd->setContentsPreview( p, p );
2393 //fd->setPreviewMode( QFileDialog::Contents );
2394 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2395 fd->setDir (QDir().current());
2396 if (fd->foundConfig())
2400 if ( fd->exec() == QDialog::Accepted )
2402 QString fn=fd->selectedFile();
2403 if (!fn.contains (".odp"))
2406 //lastImageDir=fn.left(fn.findRev ("/"));
2407 VymModel *m=currentModel();
2408 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2412 QMessageBox::warning(0,
2414 tr("Couldn't find configuration for export to Open Office\n"));
2418 void Main::fileCloseMap()
2420 VymModel *m=currentModel();
2423 if (m->hasChanged())
2425 QMessageBox mb( vymName,
2426 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2427 QMessageBox::Warning,
2428 QMessageBox::Yes | QMessageBox::Default,
2430 QMessageBox::Cancel | QMessageBox::Escape );
2431 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2432 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2435 case QMessageBox::Yes:
2437 fileSave(m, CompleteMap);
2439 case QMessageBox::No:
2440 // close without saving
2442 case QMessageBox::Cancel:
2447 // And here comes the segfault, because removeTab triggers
2448 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2449 vymViews.removeAt (tabWidget->currentIndex() );
2450 tabWidget->removeTab (tabWidget->currentIndex() );
2452 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2453 // Better would be delete (me), but then we could have a Qt error:
2454 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2455 // So we only remove data now and call deconstructor when vym closes later
2456 // this needs to be moved to vymview... me->clear();
2457 // some model->clear is needed to free up memory ...
2459 delete (m->getMapEditor());
2466 void Main::filePrint()
2468 if (currentMapEditor())
2469 currentMapEditor()->print();
2472 void Main::fileExitVYM()
2474 // Check if one or more editors have changed
2476 for (i=0;i<=vymViews.count() -1;i++)
2478 // If something changed, ask what to do
2479 if (vymViews.at(i)->getModel()->hasChanged())
2481 tabWidget->setCurrentPage(i);
2482 QMessageBox mb( vymName,
2483 tr("This map is not saved yet. Do you want to"),
2484 QMessageBox::Warning,
2485 QMessageBox::Yes | QMessageBox::Default,
2487 QMessageBox::Cancel | QMessageBox::Escape );
2488 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2489 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2492 mb.setActiveWindow();
2493 switch( mb.exec() ) {
2494 case QMessageBox::Yes:
2495 // save (the changed editors) and exit
2496 fileSave(currentModel(), CompleteMap);
2498 case QMessageBox::No:
2499 // exit without saving
2501 case QMessageBox::Cancel:
2502 // don't save and don't exit
2506 } // loop over all MEs
2510 void Main::editUndo()
2512 VymModel *m=currentModel();
2516 void Main::editRedo()
2518 VymModel *m=currentModel();
2522 void Main::gotoHistoryStep (int i)
2524 VymModel *m=currentModel();
2525 if (m) m->gotoHistoryStep(i);
2528 void Main::editCopy()
2530 VymModel *m=currentModel();
2534 void Main::editPaste()
2536 VymModel *m=currentModel();
2540 void Main::editCut()
2542 VymModel *m=currentModel();
2546 void Main::editOpenFindWidget()
2548 VymModel *m=currentModel();
2549 if (m) m->emitShowFindWidget();
2552 void Main::editFindDuplicateURLs()
2554 VymModel *m=currentModel();
2555 if (m) m->findDuplicateURLs();
2558 void Main::openTabs(QStringList urls)
2560 if (!urls.isEmpty())
2564 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2565 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2566 if (*browserPID==0 ||
2567 (browser.contains("konqueror") &&
2568 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2571 // Start a new browser, if there is not one running already or
2572 // if a previously started konqueror is gone.
2573 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2574 QString u=urls.takeFirst();
2576 QString workDir=QDir::currentDirPath();
2577 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2579 // try to set path to browser
2580 QMessageBox::warning(0,
2582 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2583 tr("Please use Settings->")+tr("Set application to open an URL"));
2586 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2587 #if defined(Q_OS_WIN32)
2588 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2589 this->thread()->wait(3000);
2591 sleep (3); //FIXME-3 needed?
2595 if (browser.contains("konqueror"))
2597 for (int i=0; i<urls.size(); i++)
2600 // Try to open new tab in existing konqueror started previously by vym
2604 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2605 "konqueror-mainwindow#1"<<
2609 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2610 "/konqueror/MainWindow_1"<<
2614 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2615 if (!QProcess::startDetached ("qdbus",args))
2619 QMessageBox::warning(0,
2621 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2623 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2625 for (int i=0; i<urls.size(); i++)
2627 // Try to open new tab in firefox
2628 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2629 if (!QProcess::startDetached (browser,args))
2633 QMessageBox::warning(0,
2635 tr("Couldn't start %1 to open a new tab").arg(browser));
2638 QMessageBox::warning(0,
2640 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2644 void Main::editOpenURL()
2647 VymModel *m=currentModel();
2650 QString url=m->getURL();
2652 if (url=="") return;
2653 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2655 QString workDir=QDir::currentDirPath();
2656 if (!procBrowser->startDetached(browser,args))
2658 // try to set path to browser
2659 QMessageBox::warning(0,
2661 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2662 tr("Please use Settings->")+tr("Set application to open an URL"));
2667 void Main::editOpenURLTab()
2669 VymModel *m=currentModel();
2673 urls.append(m->getURL());
2678 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2680 VymModel *m=currentModel();
2684 urls=m->getURLs(ignoreScrolled);
2689 void Main::editOpenMultipleURLTabs()
2691 editOpenMultipleVisURLTabs (false);
2695 void Main::editURL()
2697 VymModel *m=currentModel();
2698 if (m) m->editURL();
2701 void Main::editLocalURL()
2703 VymModel *m=currentModel();
2704 if (m) m->editLocalURL();
2707 void Main::editHeading2URL()
2709 VymModel *m=currentModel();
2710 if (m) m->editHeading2URL();
2713 void Main::editBugzilla2URL()
2715 VymModel *m=currentModel();
2716 if (m) m->editBugzilla2URL();
2719 void Main::getBugzillaData()
2721 VymModel *m=currentModel();
2723 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2724 progress.setWindowModality(Qt::WindowModal);
2725 //progress.setCancelButton (NULL);
2727 progress.setMinimumDuration (0);
2728 progress.setValue (1);
2729 progress.setValue (5);
2733 QProgressBar *pb=new QProgressBar;
2739 if (m) m->getBugzillaData();
2742 void Main::editFATE2URL()
2744 VymModel *m=currentModel();
2745 if (m) m->editFATE2URL();
2748 void Main::editHeadingFinished(VymModel *m)
2752 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2753 !prevSelection.isEmpty())
2754 m->select(prevSelection);
2759 void Main::openVymLinks(const QStringList &vl)
2761 for (int j=0; j<vl.size(); j++)
2763 // compare path with already loaded maps
2766 for (i=0;i<=vymViews.count() -1;i++)
2768 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2777 if (!QFile(vl.at(j)).exists() )
2778 QMessageBox::critical( 0, tr( "Critical Error" ),
2779 tr("Couldn't open map %1").arg(vl.at(j)));
2782 fileLoad (vl.at(j), NewMap);
2783 tabWidget->setCurrentIndex (tabWidget->count()-1);
2786 // Go to tab containing the map
2787 tabWidget->setCurrentIndex (index);
2791 void Main::editOpenVymLink()
2793 VymModel *m=currentModel();
2797 vl.append(m->getVymLink());
2802 void Main::editOpenMultipleVymLinks()
2804 QString currentVymLink;
2805 VymModel *m=currentModel();
2808 QStringList vl=m->getVymLinks();
2813 void Main::editVymLink()
2815 VymModel *m=currentModel();
2820 void Main::editDeleteVymLink()
2822 VymModel *m=currentModel();
2823 if (m) m->deleteVymLink();
2826 void Main::editToggleHideExport()
2828 VymModel *m=currentModel();
2829 if (m) m->toggleHideExport();
2832 void Main::editAddTimestamp()
2834 VymModel *m=currentModel();
2835 if (m) m->addTimestamp();
2838 void Main::editMapInfo()
2840 VymModel *m=currentModel();
2843 ExtraInfoDialog dia;
2844 dia.setMapName (m->getFileName() );
2845 dia.setAuthor (m->getAuthor() );
2846 dia.setComment(m->getComment() );
2850 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2856 BranchItem *cur=NULL;
2857 BranchItem *prev=NULL;
2858 m->nextBranch(cur,prev);
2861 if (!cur->getNote().isEmpty() ) n++;
2862 f+= cur->imageCount();
2864 xl+=cur->xlinkCount();
2865 m->nextBranch(cur,prev);
2868 stats+=QString ("%1 xLinks \n").arg (xl,6);
2869 stats+=QString ("%1 notes\n").arg (n,6);
2870 stats+=QString ("%1 images\n").arg (f,6);
2871 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2872 dia.setStats (stats);
2874 // Finally show dialog
2875 if (dia.exec() == QDialog::Accepted)
2877 m->setAuthor (dia.getAuthor() );
2878 m->setComment (dia.getComment() );
2882 void Main::editMoveUp()
2884 VymModel *m=currentModel();
2888 void Main::editMoveDown()
2890 VymModel *m=currentModel();
2891 if (m) m->moveDown();
2894 void Main::editDetach()
2896 VymModel *m=currentModel();
2900 void Main::editSortChildren()
2902 VymModel *m=currentModel();
2903 if (m) m->sortChildren(false);
2906 void Main::editSortBackChildren()
2908 VymModel *m=currentModel();
2909 if (m) m->sortChildren(true);
2912 void Main::editToggleScroll()
2914 VymModel *m=currentModel();
2915 if (m) m->toggleScroll();
2918 void Main::editExpandAll()
2920 VymModel *m=currentModel();
2921 if (m) m->emitExpandAll();
2924 void Main::editExpandOneLevel()
2926 VymModel *m=currentModel();
2927 if (m) m->emitExpandOneLevel();
2930 void Main::editCollapseOneLevel()
2932 VymModel *m=currentModel();
2933 if (m) m->emitCollapseOneLevel();
2936 void Main::editUnscrollChildren()
2938 VymModel *m=currentModel();
2939 if (m) m->unscrollChildren();
2942 void Main::editAddAttribute()
2944 VymModel *m=currentModel();
2952 void Main::editAddMapCenter()
2954 VymModel *m=currentModel();
2955 if (m) m->addMapCenter ();
2958 void Main::editNewBranch()
2960 VymModel *m=currentModel();
2963 BranchItem *bi=m->addNewBranch();
2966 if (actionSettingsAutoEditNewBranch->isOn()
2967 && !actionSettingsAutoSelectNewBranch->isOn() )
2968 prevSelection=m->getSelectString();
2970 prevSelection=QString();
2972 if (actionSettingsAutoSelectNewBranch->isOn()
2973 || actionSettingsAutoEditNewBranch->isOn())
2976 if (actionSettingsAutoEditNewBranch->isOn())
2977 currentMapEditor()->editHeading();
2982 void Main::editNewBranchBefore()
2984 VymModel *m=currentModel();
2987 BranchItem *bi=m->addNewBranchBefore();
2994 if (actionSettingsAutoEditNewBranch->isOn())
2996 if (!actionSettingsAutoSelectNewBranch->isOn())
2997 prevSelection=m->getSelectString(bi);
2998 currentMapEditor()->editHeading();
3003 void Main::editNewBranchAbove()
3005 VymModel *m=currentModel();
3008 BranchItem *bi=m->addNewBranch (-1);
3016 if (actionSettingsAutoEditNewBranch->isOn())
3018 if (!actionSettingsAutoSelectNewBranch->isOn())
3019 prevSelection=m->getSelectString (bi);
3020 currentMapEditor()->editHeading();
3025 void Main::editNewBranchBelow()
3027 VymModel *m=currentModel();
3030 BranchItem *bi=m->addNewBranch (1);
3037 if (actionSettingsAutoEditNewBranch->isOn())
3039 if (!actionSettingsAutoSelectNewBranch->isOn())
3040 prevSelection=m->getSelectString(bi);
3041 currentMapEditor()->editHeading();
3046 void Main::editImportAdd()
3048 fileLoad (ImportAdd);
3051 void Main::editImportReplace()
3053 fileLoad (ImportReplace);
3056 void Main::editSaveBranch()
3058 fileSaveAs (PartOfMap);
3061 void Main::editDeleteKeepChildren()
3063 VymModel *m=currentModel();
3064 if (m) m->deleteKeepChildren();
3067 void Main::editDeleteChildren()
3069 VymModel *m=currentModel();
3070 if (m) m->deleteChildren();
3073 void Main::editDeleteSelection()
3075 VymModel *m=currentModel();
3076 if (m && actionSettingsUseDelKey->isOn())
3077 m->deleteSelection();
3080 void Main::editLoadImage()
3082 VymModel *m=currentModel();
3083 if (m) m->loadFloatImage();
3086 void Main::editSaveImage()
3088 VymModel *m=currentModel();
3089 if (m) m->saveFloatImage();
3092 void Main::editEditXLink(QAction *a)
3094 VymModel *m=currentModel();
3096 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3099 void Main::formatSelectColor()
3101 QColor col = QColorDialog::getColor((currentColor ), this );
3102 if ( !col.isValid() ) return;
3103 colorChanged( col );
3106 void Main::formatPickColor()
3108 VymModel *m=currentModel();
3110 colorChanged( m->getCurrentHeadingColor() );
3113 void Main::colorChanged(QColor c)
3115 QPixmap pix( 16, 16 );
3117 actionFormatColor->setIconSet( pix );
3121 void Main::formatColorBranch()
3123 VymModel *m=currentModel();
3124 if (m) m->colorBranch(currentColor);
3127 void Main::formatColorSubtree()
3129 VymModel *m=currentModel();
3130 if (m) m->colorSubtree (currentColor);
3133 void Main::formatLinkStyleLine()
3135 VymModel *m=currentModel();
3138 m->setMapLinkStyle("StyleLine");
3139 actionFormatLinkStyleLine->setChecked(true);
3143 void Main::formatLinkStyleParabel()
3145 VymModel *m=currentModel();
3148 m->setMapLinkStyle("StyleParabel");
3149 actionFormatLinkStyleParabel->setChecked(true);
3153 void Main::formatLinkStylePolyLine()
3155 VymModel *m=currentModel();
3158 m->setMapLinkStyle("StylePolyLine");
3159 actionFormatLinkStylePolyLine->setChecked(true);
3163 void Main::formatLinkStylePolyParabel()
3165 VymModel *m=currentModel();
3168 m->setMapLinkStyle("StylePolyParabel");
3169 actionFormatLinkStylePolyParabel->setChecked(true);
3173 void Main::formatSelectBackColor()
3175 VymModel *m=currentModel();
3176 if (m) m->selectMapBackgroundColor();
3179 void Main::formatSelectBackImage()
3181 VymModel *m=currentModel();
3183 m->selectMapBackgroundImage();
3186 void Main::formatSelectLinkColor()
3188 VymModel *m=currentModel();
3191 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3192 m->setMapDefLinkColor( col );
3196 void Main::formatSelectSelectionColor()
3198 VymModel *m=currentModel();
3201 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3202 m->setSelectionColor (col);
3207 void Main::formatToggleLinkColorHint()
3209 VymModel *m=currentModel();
3210 if (m) m->toggleMapLinkColorHint();
3214 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3216 VymModel *m=currentModel();
3218 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3221 void Main::viewZoomReset()
3223 MapEditor *me=currentMapEditor();
3224 if (me) me->setZoomFactorTarget (1);
3227 void Main::viewZoomIn()
3229 MapEditor *me=currentMapEditor();
3230 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3233 void Main::viewZoomOut()
3235 MapEditor *me=currentMapEditor();
3236 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3239 void Main::viewCenter()
3241 VymModel *m=currentModel();
3242 if (m) m->emitShowSelection();
3245 void Main::networkStartServer()
3247 VymModel *m=currentModel();
3248 if (m) m->newServer();
3251 void Main::networkConnect()
3253 VymModel *m=currentModel();
3254 if (m) m->connectToServer();
3257 bool Main::settingsPDF()
3259 // Default browser is set in constructor
3261 QString text = QInputDialog::getText(
3262 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3263 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3265 settings.setValue ("/mainwindow/readerPDF",text);
3270 bool Main::settingsURL()
3272 // Default browser is set in constructor
3274 QString text = QInputDialog::getText(
3275 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3276 settings.value("/mainwindow/readerURL").toString()
3279 settings.setValue ("/mainwindow/readerURL",text);
3283 void Main::settingsMacroDir()
3285 QDir defdir(vymBaseDir.path() + "/macros");
3286 if (!defdir.exists())
3288 QDir dir=QFileDialog::getExistingDirectory (
3290 tr ("Directory with vym macros:"),
3291 settings.value ("/macros/macroDir",defdir.path()).toString()
3294 settings.setValue ("/macros/macroDir",dir.absolutePath());
3297 void Main::settingsUndoLevels()
3300 int i = QInputDialog::getInteger(
3302 tr("QInputDialog::getInteger()"),
3303 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3306 settings.setValue ("/mapeditor/stepsTotal",i);
3307 QMessageBox::information( this, tr( "VYM -Information:" ),
3308 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3312 void Main::settingsAutosaveToggle()
3314 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3317 void Main::settingsAutosaveTime()
3320 int i = QInputDialog::getInteger(
3322 tr("QInputDialog::getInteger()"),
3323 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3325 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3328 void Main::settingsWriteBackupFileToggle()
3330 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3333 void Main::settingsToggleAnimation()
3335 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3338 void Main::settingsToggleDelKey()
3340 if (actionSettingsUseDelKey->isOn())
3342 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3345 actionDelete->setAccel (QKeySequence (""));
3349 void Main::windowToggleNoteEditor()
3351 if (textEditor->isVisible() )
3352 windowHideNoteEditor();
3354 windowShowNoteEditor();
3357 void Main::windowToggleHistory()
3359 if (historyWindow->isVisible())
3360 historyWindow->hide();
3362 historyWindow->show();
3366 void Main::windowToggleProperty()
3368 if (branchPropertyWindow->isVisible())
3369 branchPropertyWindow->hide();
3371 branchPropertyWindow->show();
3372 branchPropertyWindow->setModel (currentModel() );
3375 void Main::windowToggleAntiAlias()
3377 bool b=actionViewToggleAntiAlias->isOn();
3379 for (int i=0;i<vymViews.count();i++)
3381 me=vymViews.at(i)->getMapEditor();
3382 if (me) me->setAntiAlias(b);
3387 bool Main::isAliased()
3389 return actionViewToggleAntiAlias->isOn();
3392 bool Main::hasSmoothPixmapTransform()
3394 return actionViewToggleSmoothPixmapTransform->isOn();
3397 void Main::windowToggleSmoothPixmap()
3399 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3401 for (int i=0;i<vymViews.count();i++)
3404 me=vymViews.at(i)->getMapEditor();
3405 if (me) me->setSmoothPixmap(b);
3409 void Main::updateHistory(SimpleSettings &undoSet)
3411 historyWindow->update (undoSet);
3414 void Main::updateNoteFlag()
3416 // this slot is connected to TextEditor::textHasChanged()
3417 VymModel *m=currentModel();
3418 if (m) m->updateNoteFlag();
3421 void Main::updateNoteEditor(QModelIndex index )
3423 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3425 cout << "Main::updateNoteEditor model="<<sender();
3426 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3428 textEditor->setNote (ti->getNoteObj() );
3431 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3433 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3435 if (model && model==currentModel() )
3439 if (!oldsel.indexes().isEmpty() )
3441 ti=model->getItem(oldsel.indexes().first());
3443 // Don't update note if both treeItem and textEditor are empty
3444 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3445 // ti->setNoteObj (textEditor->getNoteObj(),false );
3447 if (!newsel.indexes().isEmpty() )
3449 ti=model->getItem(newsel.indexes().first());
3450 if (!ti->hasEmptyNote() )
3451 textEditor->setNote(ti->getNoteObj() );
3453 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3455 // Show URL and link in statusbar
3457 QString s=ti->getURL();
3458 if (!s.isEmpty() ) status+="URL: "+s+" ";
3460 if (!s.isEmpty() ) status+="Link: "+s;
3461 if (!status.isEmpty() ) statusMessage (status);
3464 textEditor->setInactive();
3470 void Main::updateActions()
3472 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3473 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3474 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3475 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3477 VymModel *m =currentModel();
3481 actionFilePrint->setEnabled (true);
3483 // Link style in context menu
3484 switch (m->getMapLinkStyle())
3486 case LinkableMapObj::Line:
3487 actionFormatLinkStyleLine->setChecked(true);
3489 case LinkableMapObj::Parabel:
3490 actionFormatLinkStyleParabel->setChecked(true);
3492 case LinkableMapObj::PolyLine:
3493 actionFormatLinkStylePolyLine->setChecked(true);
3495 case LinkableMapObj::PolyParabel:
3496 actionFormatLinkStylePolyParabel->setChecked(true);
3503 QPixmap pix( 16, 16 );
3504 pix.fill( m->getMapBackgroundColor() );
3505 actionFormatBackColor->setIconSet( pix );
3506 pix.fill( m->getSelectionColor() );
3507 actionFormatSelectionColor->setIconSet( pix );
3508 pix.fill( m->getMapDefLinkColor() );
3509 actionFormatLinkColor->setIconSet( pix );
3512 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3515 // Expanding/collapsing
3516 actionExpandAll->setEnabled (true);
3517 actionExpandOneLevel->setEnabled (true);
3518 actionCollapseOneLevel->setEnabled (true);
3522 actionFilePrint->setEnabled (false);
3524 // Expanding/collapsing
3525 actionExpandAll->setEnabled (false);
3526 actionExpandOneLevel->setEnabled (false);
3527 actionCollapseOneLevel->setEnabled (false);
3530 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3531 actionFormatLinkColorHint->setChecked(true);
3533 actionFormatLinkColorHint->setChecked(false);
3536 if (m && m->hasChanged() )
3537 actionFileSave->setEnabled( true);
3539 actionFileSave->setEnabled( false);
3540 if (m && m->isUndoAvailable())
3541 actionUndo->setEnabled( true);
3543 actionUndo->setEnabled( false);
3545 if (m && m->isRedoAvailable())
3546 actionRedo->setEnabled( true);
3548 actionRedo->setEnabled( false);
3552 TreeItem *selti=m->getSelectedItem();
3553 BranchItem *selbi=m->getSelectedBranch();
3556 if (selbi || selti->getType()==TreeItem::Image)
3558 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3559 actionFormatHideLinkUnselected->setEnabled (true);
3564 // Take care of xlinks
3565 branchXLinksContextMenuEdit->clear();
3566 if (selbi->xlinkCount()>0)
3570 for (int i=0; i<selbi->xlinkCount();++i)
3572 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3576 if (s.length()>xLinkMenuWidth)
3577 s=s.left(xLinkMenuWidth)+"...";
3578 branchXLinksContextMenuEdit->addAction (s);
3583 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3586 actionToggleScroll->setEnabled (true);
3587 if ( selbi->isScrolled() )
3588 actionToggleScroll->setChecked(true);
3590 actionToggleScroll->setChecked(false);
3592 if ( selti->getURL().isEmpty() )
3594 actionOpenURL->setEnabled (false);
3595 actionOpenURLTab->setEnabled (false);
3599 actionOpenURL->setEnabled (true);
3600 actionOpenURLTab->setEnabled (true);
3602 if ( selti->getVymLink().isEmpty() )
3604 actionOpenVymLink->setEnabled (false);
3605 actionDeleteVymLink->setEnabled (false);
3608 actionOpenVymLink->setEnabled (true);
3609 actionDeleteVymLink->setEnabled (true);
3612 if (selbi->canMoveUp())
3613 actionMoveUp->setEnabled (true);
3615 actionMoveUp->setEnabled (false);
3616 if (selbi->canMoveDown())
3617 actionMoveDown->setEnabled (true);
3619 actionMoveDown->setEnabled (false);
3621 actionSortChildren->setEnabled (true);
3622 actionSortBackChildren->setEnabled (true);
3624 actionToggleHideExport->setEnabled (true);
3625 actionToggleHideExport->setChecked (selbi->hideInExport() );
3627 actionCopy->setEnabled (true);
3628 actionCut->setEnabled (true);
3629 if (!clipboardEmpty)
3630 actionPaste->setEnabled (true);
3632 actionPaste->setEnabled (false);
3633 for (int i=0; i<actionListBranches.size(); ++i)
3634 actionListBranches.at(i)->setEnabled(true);
3635 actionDelete->setEnabled (true);
3637 if ( selti->getType()==TreeItem::Image)
3639 actionOpenURL->setEnabled (false);
3640 actionOpenVymLink->setEnabled (false);
3641 actionDeleteVymLink->setEnabled (false);
3642 actionToggleHideExport->setEnabled (true);
3643 actionToggleHideExport->setChecked (selti->hideInExport() );
3646 actionCopy->setEnabled (true);
3647 actionCut->setEnabled (true);
3648 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3649 for (int i=0; i<actionListBranches.size(); ++i)
3650 actionListBranches.at(i)->setEnabled(false);
3651 actionDelete->setEnabled (true);
3652 actionMoveUp->setEnabled (false);
3653 actionMoveDown->setEnabled (false);
3658 actionCopy->setEnabled (false);
3659 actionCut->setEnabled (false);
3660 actionPaste->setEnabled (false);
3661 for (int i=0; i<actionListBranches.size(); ++i)
3662 actionListBranches.at(i)->setEnabled(false);
3664 actionToggleScroll->setEnabled (false);
3665 actionOpenURL->setEnabled (false);
3666 actionOpenVymLink->setEnabled (false);
3667 actionDeleteVymLink->setEnabled (false);
3668 actionHeading2URL->setEnabled (false);
3669 actionDelete->setEnabled (false);
3670 actionMoveUp->setEnabled (false);
3671 actionMoveDown->setEnabled (false);
3672 actionFormatHideLinkUnselected->setEnabled (false);
3673 actionSortChildren->setEnabled (false);
3674 actionSortBackChildren->setEnabled (false);
3675 actionToggleHideExport->setEnabled (false);
3680 Main::ModMode Main::getModMode()
3682 if (actionModModeColor->isOn()) return ModModeColor;
3683 if (actionModModeCopy->isOn()) return ModModeCopy;
3684 if (actionModModeXLink->isOn()) return ModModeXLink;
3688 bool Main::autoEditNewBranch()
3690 return actionSettingsAutoEditNewBranch->isOn();
3693 bool Main::autoSelectNewBranch()
3695 return actionSettingsAutoSelectNewBranch->isOn();
3698 void Main::windowShowNoteEditor()
3700 textEditor->setShowWithMain(true);
3702 actionViewToggleNoteEditor->setChecked (true);
3705 void Main::windowHideNoteEditor()
3707 textEditor->setShowWithMain(false);
3709 actionViewToggleNoteEditor->setChecked (false);
3712 void Main::setScript (const QString &script)
3714 scriptEditor->setScript (script);
3717 void Main::runScript (const QString &script)
3719 VymModel *m=currentModel();
3720 if (m) m->runScript (script);
3723 void Main::runScriptEverywhere (const QString &script)
3726 for (int i=0;i<=tabWidget->count() -1;i++)
3728 me=(MapEditor*)tabWidget->page(i);
3729 if (me) me->getModel()->runScript (script);
3733 void Main::windowNextEditor()
3735 if (tabWidget->currentIndex() < tabWidget->count())
3736 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3739 void Main::windowPreviousEditor()
3741 if (tabWidget->currentIndex() >0)
3742 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3745 void Main::standardFlagChanged()
3749 if ( actionSettingsUseFlagGroups->isOn() )
3750 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3752 currentModel()->toggleStandardFlag(sender()->name());
3757 void Main::testFunction1()
3761 QString script="test/sleep.sh";
3763 if (!p.waitForStarted())
3765 cout <<"VM::getBugzillaData couldn't start "<<script.toStdString()<<endl;
3768 if (!p.waitForFinished())
3770 cout <<"VM::getBugzillaData couldn't finish "<<script.toStdString()<<endl;
3773 //QByteArray result=p.readAll();
3774 QString result=p.getStdout();
3775 while (result.endsWith("\n")) result.chop(1);
3776 //cout << QString(result).toStdString()<<endl;
3777 QString err=p.getErrout();
3780 cout << "VM::getBugzillaData Error:\n";
3781 cout <<err.toStdString()<<endl;
3783 else if (!result.isEmpty())
3789 QProgressDialog p ("testprogress","cancel",0,max,this);
3790 p.setWindowModality (Qt::WindowModal);
3791 p.setAutoReset (false);
3792 p.setAutoClose (false);
3794 for (int i=0;i<max;i++)
3797 if (p.wasCanceled()) break;
3800 cout << "Doing it again...\n";
3807 for (int i=0;i<max;i++)
3810 if (p.wasCanceled()) break;
3817 if (!currentMapEditor()) return;
3818 currentMapEditor()->testFunction1();
3822 VymModel *m=currentModel();
3826 QString text = QInputDialog::getText(
3827 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3828 m->getSortFilter(), &ok, NULL);
3830 // user entered something and pressed OK
3831 m->setSortFilter (text);
3835 void Main::testFunction2()
3837 if (!currentMapEditor()) return;
3838 currentMapEditor()->testFunction2();
3841 void Main::testCommand()
3843 if (!currentMapEditor()) return;
3844 scriptEditor->show();
3847 QString com = QInputDialog::getText(
3848 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3849 if (ok) currentMapEditor()->parseAtom(com);
3853 void Main::helpDoc()
3855 QString locale = QLocale::system().name();
3857 if (locale.left(2)=="es")
3858 docname="vym_es.pdf";
3862 QStringList searchList;
3864 #if defined(Q_OS_MACX)
3865 searchList << "./vym.app/Contents/Resources/doc";
3866 #elif defined(Q_OS_WIN32)
3867 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3869 #if defined(VYM_DOCDIR)
3870 searchList << VYM_DOCDIR;
3872 // default path in SUSE LINUX
3873 searchList << "/usr/share/doc/packages/vym";
3876 searchList << "doc"; // relative path for easy testing in tarball
3877 searchList << "doc/tex"; // Easy testing working on vym.tex
3878 searchList << "/usr/share/doc/vym"; // Debian
3879 searchList << "/usr/share/doc/packages";// Knoppix
3883 for (int i=0; i<searchList.count(); ++i)
3885 docfile.setFileName(searchList.at(i)+"/"+docname);
3886 if (docfile.exists())
3895 QMessageBox::critical(0,
3896 tr("Critcal error"),
3897 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3902 Process *pdfProc = new Process();
3903 args << QDir::toNativeSeparators(docfile.fileName());
3905 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3908 QMessageBox::warning(0,
3910 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3911 tr("Please use Settings->")+tr("Set application to open PDF files"));
3918 void Main::helpDemo()
3920 QStringList filters;
3921 filters <<"VYM example map (*.vym)";
3922 QFileDialog *fd=new QFileDialog( this);
3923 #if defined(Q_OS_MACX)
3924 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3926 // default path in SUSE LINUX
3927 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3930 fd->setFileMode (QFileDialog::ExistingFiles);
3931 fd->setFilters (filters);
3932 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3936 if ( fd->exec() == QDialog::Accepted )
3938 lastFileDir=fd->directory().path();
3939 QStringList flist = fd->selectedFiles();
3940 QStringList::Iterator it = flist.begin();
3941 while( it != flist.end() )
3944 fileLoad(*it, NewMap);
3952 void Main::helpAbout()
3955 ad.setName ("aboutwindow");
3956 ad.setMinimumSize(500,500);
3957 ad.resize (QSize (500,500));
3961 void Main::helpAboutQT()
3963 QMessageBox::aboutQt( this, "Qt Application Example" );
3966 void Main::callMacro ()
3968 QAction *action = qobject_cast<QAction *>(sender());
3972 i=action->data().toInt();
3973 QString mDir (settings.value ("macros/macroDir").toString() );
3975 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3977 if ( !f.open( QIODevice::ReadOnly ) )
3979 QMessageBox::warning(0,
3981 tr("Couldn't find a macro at %1.\n").arg(fn)+
3982 tr("Please use Settings->")+tr("Set directory for vym macros"));
3986 QTextStream ts( &f );
3987 QString macro= ts.read();
3989 if (! macro.isEmpty())
3991 VymModel *m=currentModel();
3992 if (m) m->runScript(macro);