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::removeProgressValue(int v)
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 alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
695 alt->setShortcut ( Qt::Key_S ); // Scroll branch
696 alt->setStatusTip (tr( "Scroll branch" ));
697 connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) );
698 #if defined(Q_OS_MACX)
699 actionToggleScroll=alt;
701 actionToggleScroll=a;
703 actionToggleScroll->setEnabled (false);
704 actionToggleScroll->setToggleAction(true);
705 tb->addAction (actionToggleScroll);
706 editMenu->addAction ( actionToggleScroll);
707 editMenu->addAction (actionToggleScroll);
710 actionListBranches.append(actionToggleScroll);
712 a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this);
713 a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches
714 a->setStatusTip (tr( "Expand all branches" ));
715 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) );
717 actionExpandAll->setEnabled (false);
718 actionExpandAll->setToggleAction(false);
719 //tb->addAction (actionExpandAll);
720 editMenu->addAction ( actionExpandAll);
722 actionListBranches.append(actionExpandAll);
724 a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this);
725 a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor
726 a->setStatusTip (tr( "Expand one level in tree editor" ));
727 connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) );
728 a->setEnabled (false);
729 a->setToggleAction(false);
730 actionExpandOneLevel=a;
732 editMenu->addAction ( a);
734 actionListBranches.append(a);
736 a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this);
737 a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor
738 a->setStatusTip (tr( "Collapse one level in tree editor" ));
739 connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) );
740 a->setEnabled (false);
741 a->setToggleAction(false);
742 actionCollapseOneLevel=a;
744 editMenu->addAction ( a);
746 actionListBranches.append(a);
748 a = new QAction( tr( "Unscroll children","Edit menu" ), this);
749 a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" ));
750 editMenu->addAction (a);
751 connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) );
753 editMenu->addSeparator();
755 a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this);
756 a->setStatusTip (tr( "Find" ) );
757 a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find
758 editMenu->addAction (a);
759 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
761 a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
762 //a->setStatusTip (tr( "Find" ) );
763 a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
764 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
765 editMenu->addAction (a);
766 connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
768 editMenu->addSeparator();
770 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
771 a->setShortcut (Qt::SHIFT + Qt::Key_U );
772 a->setShortcut (tr( "Open URL" ));
775 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) );
778 a = new QAction( tr( "Open URL in new tab","Edit menu" ), this);
779 a->setStatusTip (tr( "Open URL in new tab" ));
780 //a->setShortcut (Qt::CTRL+Qt::Key_U );
782 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
785 a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
786 a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
787 a->setShortcut ( Qt::CTRL + Qt::Key_U );
789 actionListBranches.append(a);
790 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
791 actionOpenMultipleVisURLTabs=a;
793 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
794 a->setStatusTip (tr( "Open all URLs in subtree" ));
796 actionListBranches.append(a);
797 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
798 actionOpenMultipleURLTabs=a;
800 a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this);
801 a->setStatusTip ( tr( "Edit URL" ) );
802 a->setShortcut ( Qt::Key_U );
803 a->setShortcutContext (Qt::WindowShortcut);
804 actionListBranches.append(a);
806 connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) );
809 a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this);
810 a->setStatusTip ( tr( "Edit local URL" ) );
811 //a->setShortcut (Qt::SHIFT + Qt::Key_U );
812 a->setShortcutContext (Qt::WindowShortcut);
813 actionListBranches.append(a);
815 connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) );
818 a = new QAction( tr( "Use heading for URL","Edit menu" ), this);
819 a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
820 a->setEnabled (false);
821 actionListBranches.append(a);
822 connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) );
825 a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
826 a->setStatusTip ( tr( "Create URL to Novell Bugzilla" ));
827 a->setEnabled (false);
828 actionListBranches.append(a);
829 a->setShortcut ( Qt::Key_B );
830 a->setShortcutContext (Qt::WindowShortcut);
832 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
833 actionBugzilla2URL=a;
835 a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
836 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
837 a->setEnabled (false);
838 actionListBranches.append(a);
839 a->setShortcut ( Qt::Key_B + Qt::SHIFT);
840 a->setShortcutContext (Qt::WindowShortcut);
842 connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) );
843 actionGetBugzillaData=a;
845 a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this);
846 a->setStatusTip ( tr( "Create URL to Novell FATE" ));
847 a->setEnabled (false);
848 actionListBranches.append(a);
849 connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) );
852 a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this);
853 a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
855 a->setEnabled (false);
856 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) );
859 a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this);
860 a->setStatusTip ( tr( "Open all vym links in subtree" ));
861 a->setEnabled (false);
862 actionListBranches.append(a);
863 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) );
864 actionOpenMultipleVymLinks=a;
867 a = new QAction(tr( "Edit vym link...","Edit menu" ), this);
868 a->setEnabled (false);
869 a->setStatusTip ( tr( "Edit link to another vym map" ));
870 connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) );
871 actionListBranches.append(a);
874 a = new QAction(tr( "Delete vym link","Edit menu" ),this);
875 a->setStatusTip ( tr( "Delete link to another vym map" ));
876 a->setEnabled (false);
877 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) );
878 actionDeleteVymLink=a;
880 a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this);
881 a->setStatusTip ( tr( "Hide object in exports" ) );
882 a->setShortcut (Qt::Key_H );
883 a->setToggleAction(true);
885 a->setEnabled (false);
886 connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) );
887 actionToggleHideExport=a;
889 a = new QAction(tr( "Add timestamp","Edit menu" ), this);
890 a->setStatusTip ( tr( "Add timestamp" ));
891 a->setEnabled (false);
892 actionListBranches.append(a);
893 a->setShortcut ( Qt::Key_T ); // Add timestamp
894 a->setShortcutContext (Qt::WindowShortcut);
896 connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) );
897 actionAddTimestamp=a;
899 a = new QAction(tr( "Edit Map Info...","Edit menu" ),this);
900 a->setStatusTip ( tr( "Edit Map Info" ));
901 a->setEnabled (true);
902 connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) );
905 // Import at selection (adding to selection)
906 a = new QAction( tr( "Add map (insert)","Edit menu" ),this);
907 a->setStatusTip (tr( "Add map at selection" ));
908 connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) );
909 a->setEnabled (false);
910 actionListBranches.append(a);
913 // Import at selection (replacing selection)
914 a = new QAction( tr( "Add map (replace)","Edit menu" ), this);
915 a->setStatusTip (tr( "Replace selection with map" ));
916 connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) );
917 a->setEnabled (false);
918 actionListBranches.append(a);
919 actionImportReplace=a;
922 a = new QAction( tr( "Save selection","Edit menu" ), this);
923 a->setStatusTip (tr( "Save selection" ));
924 connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) );
925 a->setEnabled (false);
926 actionListBranches.append(a);
929 // Only remove branch, not its children
930 a = new QAction(tr( "Remove only branch ","Edit menu" ), this);
931 a->setStatusTip ( tr( "Remove only branch and keep its children" ));
932 a->setShortcut (Qt::ALT + Qt::Key_Delete );
933 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) );
934 a->setEnabled (false);
936 actionListBranches.append(a);
937 actionDeleteKeepChildren=a;
939 // Only remove children of a branch
940 a = new QAction( tr( "Remove children","Edit menu" ), this);
941 a->setStatusTip (tr( "Remove children of branch" ));
942 a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
943 connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) );
944 a->setEnabled (false);
945 actionListBranches.append(a);
946 actionDeleteChildren=a;
948 a = new QAction( tr( "Add Image...","Edit menu" ), this);
949 a->setStatusTip (tr( "Add Image" ));
950 connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) );
953 a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this);
954 a->setStatusTip (tr( "Set properties for selection" ));
955 a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window
956 a->setShortcutContext (Qt::WindowShortcut);
957 a->setToggleAction (true);
959 connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) );
960 actionViewTogglePropertyWindow=a;
964 void Main::setupFormatActions()
966 QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu"));
968 QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name"));
969 tb->setObjectName ("formatTB");
972 pix.fill (Qt::black);
973 a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
974 a->setStatusTip ( tr( "Set Color" ));
975 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) );
977 formatMenu->addAction (a);
979 a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this);
980 a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
981 a->setShortcut (Qt::CTRL + Qt::Key_K );
982 connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) );
983 a->setEnabled (false);
985 formatMenu->addAction (a);
986 actionListBranches.append(a);
987 actionFormatPickColor=a;
989 a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this);
990 a->setStatusTip ( tr( "Color branch" ) );
991 a->setShortcut (Qt::CTRL + Qt::Key_B);
992 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) );
993 a->setEnabled (false);
995 formatMenu->addAction (a);
996 actionListBranches.append(a);
997 actionFormatColorSubtree=a;
999 a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this);
1000 a->setStatusTip ( tr( "Color Subtree" ));
1001 //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree
1002 connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) );
1003 a->setEnabled (false);
1004 formatMenu->addAction (a);
1006 actionListBranches.append(a);
1007 actionFormatColorSubtree=a;
1009 formatMenu->addSeparator();
1010 actionGroupFormatLinkStyles=new QActionGroup ( this);
1011 actionGroupFormatLinkStyles->setExclusive (true);
1012 a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
1013 a->setStatusTip (tr( "Line" ));
1014 a->setToggleAction(true);
1015 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) );
1016 formatMenu->addAction (a);
1017 actionFormatLinkStyleLine=a;
1018 a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles);
1019 a->setStatusTip (tr( "Line" ));
1020 a->setToggleAction(true);
1021 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) );
1022 formatMenu->addAction (a);
1023 actionFormatLinkStyleParabel=a;
1024 a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
1025 a->setStatusTip (tr( "PolyLine" ));
1026 a->setToggleAction(true);
1027 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) );
1028 formatMenu->addAction (a);
1029 actionFormatLinkStylePolyLine=a;
1030 a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles);
1031 a->setStatusTip (tr( "PolyParabel" ) );
1032 a->setToggleAction(true);
1033 a->setChecked (true);
1034 connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) );
1035 formatMenu->addAction (a);
1036 actionFormatLinkStylePolyParabel=a;
1038 a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this);
1039 a->setStatusTip (tr( "Hide link" ));
1040 a->setToggleAction(true);
1041 connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) );
1042 actionFormatHideLinkUnselected=a;
1044 formatMenu->addSeparator();
1045 a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this);
1046 a->setStatusTip (tr( "Use same color for links and headings" ));
1047 a->setToggleAction(true);
1048 connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) );
1049 formatMenu->addAction (a);
1050 actionFormatLinkColorHint=a;
1052 pix.fill (Qt::white);
1053 a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this );
1054 a->setStatusTip (tr( "Set Link Color" ));
1055 formatMenu->addAction (a);
1056 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) );
1057 actionFormatLinkColor=a;
1059 a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this );
1060 a->setStatusTip (tr( "Set Selection Color" ));
1061 formatMenu->addAction (a);
1062 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) );
1063 actionFormatSelectionColor=a;
1065 a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
1066 a->setStatusTip (tr( "Set Background Color" ));
1067 formatMenu->addAction (a);
1068 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
1069 actionFormatBackColor=a;
1071 a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
1072 a->setStatusTip (tr( "Set Background image" ));
1073 formatMenu->addAction (a);
1074 connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
1075 actionFormatBackImage=a;
1079 void Main::setupViewActions()
1081 QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") );
1082 tb->setLabel( "View Actions" );
1083 tb->setObjectName ("viewTB");
1084 QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
1086 Switchboard switchboard; //FIXME-2 testing...
1089 a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
1090 a->setStatusTip ( tr( "Zoom reset" ) );
1091 a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom
1092 switchboard.addConnection(a,"CTRL+0");
1094 viewMenu->addAction (a);
1095 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) );
1097 a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this);
1098 a->setStatusTip (tr( "Zoom in" ));
1099 switchboard.addConnection(a,"CTRL++");
1101 viewMenu->addAction (a);
1102 connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) );
1104 a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this);
1105 a->setStatusTip (tr( "Zoom out" ));
1106 switchboard.addConnection(a,"CTRL+-");
1108 viewMenu->addAction (a);
1109 connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
1111 a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
1112 a->setStatusTip (tr( "Show selection" ));
1113 switchboard.addConnection(a,".");
1115 viewMenu->addAction (a);
1116 connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
1118 viewMenu->addSeparator();
1120 a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
1121 a->setStatusTip ( tr( "Show Note Editor" ));
1122 a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor
1123 a->setToggleAction(true);
1125 viewMenu->addAction (a);
1126 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
1127 actionViewToggleNoteEditor=a;
1129 a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this );
1130 a->setStatusTip ( tr( "Show History Window" ));
1131 a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window
1132 a->setToggleAction(true);
1134 viewMenu->addAction (a);
1135 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
1136 actionViewToggleHistoryWindow=a;
1138 viewMenu->addAction (actionViewTogglePropertyWindow);
1140 viewMenu->addSeparator();
1142 a = new QAction(tr( "Antialiasing","View action" ),this );
1143 a->setStatusTip ( tr( "Antialiasing" ));
1144 a->setToggleAction(true);
1145 a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool());
1146 viewMenu->addAction (a);
1147 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
1148 actionViewToggleAntiAlias=a;
1150 a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
1151 a->setStatusTip (a->text());
1152 a->setToggleAction(true);
1153 a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
1154 viewMenu->addAction (a);
1155 connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
1156 actionViewToggleSmoothPixmapTransform=a;
1158 a = new QAction(tr( "Next Map","View action" ), this);
1159 a->setStatusTip (a->text());
1160 a->setShortcut (Qt::ALT + Qt::Key_N );
1161 viewMenu->addAction (a);
1162 connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
1164 a = new QAction (tr( "Previous Map","View action" ), this );
1165 a->setStatusTip (a->text());
1166 a->setShortcut (Qt::ALT + Qt::Key_P );
1167 viewMenu->addAction (a);
1168 connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
1170 if (debug) switchboard.print();
1174 void Main::setupModeActions()
1176 //QPopupMenu *menu = new QPopupMenu( this );
1177 //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
1179 QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") );
1180 tb->setObjectName ("modesTB");
1182 actionGroupModModes=new QActionGroup ( this);
1183 actionGroupModModes->setExclusive (true);
1184 a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes);
1185 a->setShortcut (Qt::Key_J);
1186 a->setStatusTip ( tr( "Use modifier to color branches" ));
1187 a->setToggleAction(true);
1189 a->setChecked(true);
1190 actionModModeColor=a;
1192 a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes );
1193 a->setShortcut( Qt::Key_K);
1194 a->setStatusTip( tr( "Use modifier to copy" ));
1195 a->setToggleAction(true);
1197 actionModModeCopy=a;
1199 a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes );
1200 a->setShortcut (Qt::Key_L);
1201 a->setStatusTip( tr( "Use modifier to draw xLinks" ));
1202 a->setToggleAction(true);
1204 actionModModeXLink=a;
1208 void Main::setupFlagActions()
1210 // Create System Flags
1213 Flag *flag=new Flag;;
1214 flag->setVisible(true);
1216 flag->load(QPixmap(flagsPath+"flag-note.png"));
1217 setupFlag (flag,tb,"system-note",tr("Note","SystemFlag"));
1219 flag->load(QPixmap(flagsPath+"flag-url.png"));
1220 setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag"));
1222 flag->load(QPixmap(flagsPath+"flag-vymlink.png"));
1223 setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag"));
1225 flag->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
1226 setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag"));
1228 flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
1229 setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag"));
1231 flag->load(QPixmap(flagsPath+"flag-hideexport.png"));
1232 setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag"));
1234 // Create Standard Flags
1235 tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar"));
1236 tb->setObjectName ("standardFlagTB");
1237 standardFlagsMaster->setToolBar (tb);
1239 flag->load(flagsPath+"flag-exclamationmark.png");
1240 flag->setGroup("standard-mark");
1241 setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag"));
1243 flag->load(flagsPath+"flag-questionmark.png");
1244 flag->setGroup("standard-mark");
1245 setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag"));
1247 flag->load(flagsPath+"flag-hook-green.png");
1248 flag->setGroup("standard-status");
1249 setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag"));
1251 flag->load(flagsPath+"flag-wip.png");
1252 flag->setGroup("standard-status");
1253 setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag"));
1255 flag->load(flagsPath+"flag-cross-red.png");
1256 flag->setGroup("standard-status");
1257 setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag"));
1260 flag->load(flagsPath+"flag-stopsign.png");
1261 setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag"));
1263 flag->load(flagsPath+"flag-smiley-good.png");
1264 flag->setGroup("standard-smiley");
1265 setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag"));
1267 flag->load(flagsPath+"flag-smiley-sad.png");
1268 flag->setGroup("standard-smiley");
1269 setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag"));
1271 flag->load(flagsPath+"flag-smiley-omg.png");
1272 flag->setGroup("standard-smiley");
1273 setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag"));
1274 // Original omg.png (in KDE emoticons)
1277 flag->load(flagsPath+"flag-kalarm.png");
1278 setupFlag (flag,tb,"clock",tr("Time critical","Standardflag"));
1280 flag->load(flagsPath+"flag-phone.png");
1281 setupFlag (flag,tb,"phone",tr("Call...","Standardflag"));
1283 flag->load(flagsPath+"flag-lamp.png");
1284 setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag"));
1286 flag->load(flagsPath+"flag-arrow-up.png");
1287 flag->setGroup("standard-arrow");
1288 setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag"));
1290 flag->load(flagsPath+"flag-arrow-down.png");
1291 flag->setGroup("standard-arrow");
1292 setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag"));
1294 flag->load(flagsPath+"flag-arrow-2up.png");
1295 flag->setGroup("standard-arrow");
1296 setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag"));
1298 flag->load(flagsPath+"flag-arrow-2down.png");
1299 flag->setGroup("standard-arrow");
1300 setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag"));
1303 flag->load(flagsPath+"flag-thumb-up.png");
1304 flag->setGroup("standard-thumb");
1305 setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag"));
1307 flag->load(flagsPath+"flag-thumb-down.png");
1308 flag->setGroup("standard-thumb");
1309 setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag"));
1312 flag->load(flagsPath+"flag-rose.png");
1313 setupFlag (flag,tb,"rose",tr("Rose","Standardflag"));
1315 flag->load(flagsPath+"flag-heart.png");
1316 setupFlag (flag,tb,"heart",tr("I just love...","Standardflag"));
1318 flag->load(flagsPath+"flag-present.png");
1319 setupFlag (flag,tb,"present",tr("Surprise!","Standardflag"));
1321 flag->load(flagsPath+"flag-flash.png");
1322 setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag"));
1324 // Original: xsldbg_output.png
1325 flag->load(flagsPath+"flag-info.png");
1326 setupFlag (flag,tb,"info",tr("Info","Standardflag"));
1328 // Original khelpcenter.png
1329 flag->load(flagsPath+"flag-lifebelt.png");
1330 setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag"));
1333 flag->setVisible(false);
1334 flag->load(flagsPath+"freemind/warning.png");
1335 setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag"));
1337 for (int i=1; i<8; i++)
1339 flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i));
1340 setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag"));
1343 flag->load(flagsPath+"freemind/back.png");
1344 setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag"));
1346 flag->load(flagsPath+"freemind/forward.png");
1347 setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag"));
1349 flag->load(flagsPath+"freemind/attach.png");
1350 setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag"));
1352 flag->load(flagsPath+"freemind/clanbomber.png");
1353 setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag"));
1355 flag->load(flagsPath+"freemind/desktopnew.png");
1356 setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag"));
1358 flag->load(flagsPath+"freemind/flag.png");
1359 setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag"));
1362 flag->load(flagsPath+"freemind/gohome.png");
1363 setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag"));
1366 flag->load(flagsPath+"freemind/kaddressbook.png");
1367 setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag"));
1369 flag->load(flagsPath+"freemind/knotify.png");
1370 setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag"));
1372 flag->load(flagsPath+"freemind/korn.png");
1373 setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag"));
1375 flag->load(flagsPath+"freemind/mail.png");
1376 setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag"));
1378 flag->load(flagsPath+"freemind/password.png");
1379 setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag"));
1381 flag->load(flagsPath+"freemind/pencil.png");
1382 setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag"));
1384 flag->load(flagsPath+"freemind/stop.png");
1385 setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag"));
1387 flag->load(flagsPath+"freemind/wizard.png");
1388 setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag"));
1390 flag->load(flagsPath+"freemind/xmag.png");
1391 setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag"));
1393 flag->load(flagsPath+"freemind/bell.png");
1394 setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag"));
1396 flag->load(flagsPath+"freemind/bookmark.png");
1397 setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag"));
1399 flag->load(flagsPath+"freemind/penguin.png");
1400 setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag"));
1402 flag->load(flagsPath+"freemind/licq.png");
1403 setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag"));
1406 void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip)
1408 flag->setName(name);
1409 flag->setToolTip (tooltip);
1413 a=new QAction (flag->getPixmap(),name,this);
1416 flag->setAction (a);
1417 a->setVisible (flag->isVisible());
1418 a->setCheckable(true);
1419 a->setObjectName(name);
1420 a->setToolTip(tooltip);
1421 connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
1422 standardFlagsMaster->addFlag (flag);
1426 systemFlagsMaster->addFlag (flag);
1431 void Main::setupNetworkActions()
1433 if (!settings.value( "/mainwindow/showTestMenu",false).toBool() )
1435 QMenu *netMenu = menuBar()->addMenu( "Network" );
1439 a = new QAction( "Start TCPserver for MapEditor",this);
1440 //a->setStatusTip ( "Set application to open pdf files"));
1441 //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server
1442 connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) );
1443 netMenu->addAction (a);
1445 a = new QAction( "Connect MapEditor to server",this);
1446 //a->setStatusTip ( "Set application to open pdf files"));
1447 a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server
1448 connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) );
1449 netMenu->addAction (a);
1453 void Main::setupSettingsActions()
1455 QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" ));
1459 a = new QAction( tr( "Set application to open pdf files","Settings action"), this);
1460 a->setStatusTip ( tr( "Set application to open pdf files"));
1461 connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) );
1462 settingsMenu->addAction (a);
1464 a = new QAction( tr( "Set application to open external links","Settings action"), this);
1465 a->setStatusTip( tr( "Set application to open external links"));
1466 connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) );
1467 settingsMenu->addAction (a);
1469 a = new QAction( tr( "Set path for macros","Settings action")+"...", this);
1470 a->setStatusTip( tr( "Set path for macros"));
1471 connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) );
1472 settingsMenu->addAction (a);
1474 a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this);
1475 a->setStatusTip( tr( "Set number of undo levels"));
1476 connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) );
1477 settingsMenu->addAction (a);
1479 settingsMenu->addSeparator();
1481 a = new QAction( tr( "Autosave","Settings action"), this);
1482 a->setStatusTip( tr( "Autosave"));
1483 a->setToggleAction(true);
1484 a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool());
1485 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
1486 settingsMenu->addAction (a);
1487 actionSettingsAutosaveToggle=a;
1489 a = new QAction( tr( "Autosave time","Settings action")+"...", this);
1490 a->setStatusTip( tr( "Autosave time"));
1491 connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) );
1492 settingsMenu->addAction (a);
1493 actionSettingsAutosaveTime=a;
1495 a = new QAction( tr( "Write backup file on save","Settings action"), this);
1496 a->setStatusTip( tr( "Write backup file on save"));
1497 a->setToggleAction(true);
1498 a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool());
1499 connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) );
1500 settingsMenu->addAction (a);
1501 actionSettingsWriteBackupFile=a;
1503 settingsMenu->addSeparator();
1505 a = new QAction( tr( "Edit branch after adding it","Settings action" ), this );
1506 a->setStatusTip( tr( "Edit branch after adding it" ));
1507 a->setToggleAction(true);
1508 a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool());
1509 settingsMenu->addAction (a);
1510 actionSettingsAutoEditNewBranch=a;
1512 a= new QAction( tr( "Select branch after adding it","Settings action" ), this );
1513 a->setStatusTip( tr( "Select branch after adding it" ));
1514 a->setToggleAction(true);
1515 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() );
1516 settingsMenu->addAction (a);
1517 actionSettingsAutoSelectNewBranch=a;
1519 a= new QAction(tr( "Select existing heading","Settings action" ), this);
1520 a->setStatusTip( tr( "Select heading before editing" ));
1521 a->setToggleAction(true);
1522 a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() );
1523 settingsMenu->addAction (a);
1524 actionSettingsAutoSelectText=a;
1526 a= new QAction( tr( "Delete key","Settings action" ), this);
1527 a->setStatusTip( tr( "Delete key for deleting branches" ));
1528 a->setToggleAction(true);
1529 a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() );
1530 settingsMenu->addAction (a);
1531 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) );
1532 actionSettingsUseDelKey=a;
1534 a= new QAction( tr( "Exclusive flags","Settings action" ), this);
1535 a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
1536 a->setToggleAction(true);
1537 a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() );
1538 settingsMenu->addAction (a);
1539 actionSettingsUseFlagGroups=a;
1541 a= new QAction( tr( "Use hide flags","Settings action" ), this);
1542 a->setStatusTip( tr( "Use hide flag during exports " ));
1543 a->setToggleAction(true);
1544 a->setChecked ( settings.value ("/export/useHideExport",true).toBool() );
1545 settingsMenu->addAction (a);
1546 actionSettingsUseHideExport=a;
1548 a = new QAction( tr( "Animation","Settings action"), this);
1549 a->setStatusTip( tr( "Animation"));
1550 a->setToggleAction(true);
1551 a->setChecked (settings.value("/animation/use",true).toBool() );
1552 connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) );
1553 settingsMenu->addAction (a);
1554 actionSettingsUseAnimation=a;
1558 void Main::setupTestActions()
1560 QMenu *testMenu = menuBar()->addMenu( tr( "&Test" ));
1563 a = new QAction( "Test function 1" , this);
1564 a->setStatusTip( "Call test function 1" );
1565 a->setShortcut (Qt::CTRL + Qt::Key_T); // Test function 1 //FIXME-2 originally: color subtree
1566 testMenu->addAction (a);
1567 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
1569 a = new QAction( "Test function 2" , this);
1570 a->setStatusTip( "Call test function 2" );
1571 a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 2
1572 testMenu->addAction (a);
1573 connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
1575 a = new QAction( "Command" , this);
1576 a->setStatusTip( "Enter command to call in editor" );
1577 connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
1578 testMenu->addAction (a);
1582 void Main::setupHelpActions()
1584 QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" ));
1587 a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this );
1588 a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
1589 connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) );
1590 helpMenu->addAction (a);
1592 a = new QAction( tr( "Open VYM example maps ","Help action" ), this );
1593 a->setStatusTip( tr( "Open VYM example maps " ));
1594 connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) );
1595 helpMenu->addAction (a);
1597 a = new QAction( tr( "About VYM","Help action" ), this);
1598 a->setStatusTip( tr( "About VYM")+vymName);
1599 connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
1600 helpMenu->addAction (a);
1602 a = new QAction( tr( "About QT","Help action" ), this);
1603 a->setStatusTip( tr( "Information about QT toolkit" ));
1604 connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) );
1605 helpMenu->addAction (a);
1609 void Main::setupContextMenus()
1613 // Context Menu for branch or mapcenter
1614 branchContextMenu =new QMenu (this);
1615 branchContextMenu->addAction (actionViewTogglePropertyWindow);
1616 branchContextMenu->addSeparator();
1619 branchAddContextMenu =branchContextMenu->addMenu (tr("Add"));
1620 branchAddContextMenu->addAction (actionPaste );
1621 branchAddContextMenu->addAction ( actionAddMapCenter );
1622 branchAddContextMenu->addAction ( actionAddBranch );
1623 branchAddContextMenu->addAction ( actionAddBranchBefore );
1624 branchAddContextMenu->addAction ( actionAddBranchAbove);
1625 branchAddContextMenu->addAction ( actionAddBranchBelow );
1626 branchAddContextMenu->addSeparator();
1627 branchAddContextMenu->addAction ( actionImportAdd );
1628 branchAddContextMenu->addAction ( actionImportReplace );
1631 branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name"));
1632 branchRemoveContextMenu->addAction (actionCut);
1633 branchRemoveContextMenu->addAction ( actionDelete );
1634 branchRemoveContextMenu->addAction ( actionDeleteKeepChildren );
1635 branchRemoveContextMenu->addAction ( actionDeleteChildren );
1638 actionSaveBranch->addTo( branchContextMenu );
1639 actionFileNewCopy->addTo (branchContextMenu );
1640 actionDetach->addTo (branchContextMenu );
1642 branchContextMenu->addSeparator();
1643 branchContextMenu->addAction ( actionLoadImage);
1644 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1645 branchContextMenu->addAction ( actionAddAttribute);
1647 // Submenu for Links (URLs, vymLinks)
1648 branchLinksContextMenu =new QMenu (this);
1650 branchContextMenu->addSeparator();
1651 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1652 branchLinksContextMenu->addAction ( actionOpenURL );
1653 branchLinksContextMenu->addAction ( actionOpenURLTab );
1654 branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1655 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1656 branchLinksContextMenu->addAction ( actionURL );
1657 branchLinksContextMenu->addAction ( actionLocalURL );
1658 branchLinksContextMenu->addAction ( actionHeading2URL );
1659 branchLinksContextMenu->addAction ( actionBugzilla2URL );
1660 if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1662 branchLinksContextMenu->addAction ( actionGetBugzillaData );
1663 branchLinksContextMenu->addAction ( actionFATE2URL );
1665 branchLinksContextMenu->addSeparator();
1666 branchLinksContextMenu->addAction ( actionOpenVymLink );
1667 branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks );
1668 branchLinksContextMenu->addAction ( actionVymLink );
1669 branchLinksContextMenu->addAction ( actionDeleteVymLink );
1672 // Context Menu for XLinks in a branch menu
1673 // This will be populated "on demand" in MapEditor::updateActions
1674 branchContextMenu->addSeparator();
1675 branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name"));
1676 connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) );
1679 // Context menu for floatimage
1680 floatimageContextMenu =new QMenu (this);
1681 a= new QAction (tr ("Save image","Context action"),this);
1682 connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage()));
1683 floatimageContextMenu->addAction (a);
1685 floatimageContextMenu->addSeparator();
1686 actionCopy->addTo( floatimageContextMenu );
1687 actionCut->addTo( floatimageContextMenu );
1689 floatimageContextMenu->addSeparator();
1690 floatimageContextMenu->addAction ( actionFormatHideLinkUnselected );
1693 // Context menu for canvas
1694 canvasContextMenu =new QMenu (this);
1695 actionAddMapCenter->addTo( canvasContextMenu );
1696 actionMapInfo->addTo( canvasContextMenu );
1697 canvasContextMenu->insertSeparator();
1698 actionGroupFormatLinkStyles->addTo( canvasContextMenu );
1699 canvasContextMenu->insertSeparator();
1700 actionFormatLinkColorHint->addTo( canvasContextMenu );
1701 actionFormatLinkColor->addTo( canvasContextMenu );
1702 actionFormatSelectionColor->addTo( canvasContextMenu );
1703 actionFormatBackColor->addTo( canvasContextMenu );
1704 // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version
1706 // Menu for last opened files
1708 for (int i = 0; i < MaxRecentFiles; ++i)
1710 recentFileActions[i] = new QAction(this);
1711 recentFileActions[i]->setVisible(false);
1712 fileLastMapsMenu->addAction(recentFileActions[i]);
1713 connect(recentFileActions[i], SIGNAL(triggered()),
1714 this, SLOT(fileLoadRecent()));
1716 setupRecentMapsMenu();
1719 void Main::setupRecentMapsMenu()
1721 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
1723 int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
1725 for (int i = 0; i < numRecentFiles; ++i) {
1726 QString text = tr("&%1 %2").arg(i + 1).arg(files[i]);
1727 recentFileActions[i]->setText(text);
1728 recentFileActions[i]->setData(files[i]);
1729 recentFileActions[i]->setVisible(true);
1731 for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
1732 recentFileActions[j]->setVisible(false);
1735 void Main::setupMacros()
1737 for (int i = 0; i <= 11; i++)
1739 macroActions[i] = new QAction(this);
1740 macroActions[i]->setData(i);
1741 addAction (macroActions[i]);
1742 connect(macroActions[i], SIGNAL(triggered()),
1743 this, SLOT(callMacro()));
1745 macroActions[0]->setShortcut ( Qt::Key_F1 );
1746 macroActions[1]->setShortcut ( Qt::Key_F2 );
1747 macroActions[2]->setShortcut ( Qt::Key_F3 );
1748 macroActions[3]->setShortcut ( Qt::Key_F4 );
1749 macroActions[4]->setShortcut ( Qt::Key_F5 );
1750 macroActions[5]->setShortcut ( Qt::Key_F6 );
1751 macroActions[6]->setShortcut ( Qt::Key_F7 );
1752 macroActions[7]->setShortcut ( Qt::Key_F8 );
1753 macroActions[8]->setShortcut ( Qt::Key_F9 );
1754 macroActions[9]->setShortcut ( Qt::Key_F10 );
1755 macroActions[10]->setShortcut ( Qt::Key_F11 );
1756 macroActions[11]->setShortcut ( Qt::Key_F12 );
1759 void Main::hideEvent (QHideEvent * )
1761 if (!textEditor->isMinimized() ) textEditor->hide();
1764 void Main::showEvent (QShowEvent * )
1766 if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
1770 MapEditor* Main::currentMapEditor() const
1772 if ( tabWidget->currentPage())
1773 return vymViews.at(tabWidget->currentIndex())->getMapEditor();
1777 VymModel* Main::currentModel() const
1779 if ( tabWidget->currentPage())
1780 return vymViews.at(tabWidget->currentIndex())->getModel();
1785 void Main::editorChanged(QWidget *)
1787 // Unselect all possibly selected objects
1788 // (Important to update note editor)
1790 for (int i=0;i<=tabWidget->count() -1;i++)
1792 m= vymViews.at(i)->getModel();
1793 if (m) m->unselect();
1796 if (m) m->reselect();
1798 // Update actions to in menus and toolbars according to editor
1802 void Main::fileNew()
1804 VymModel *vm=new VymModel;
1806 /////////////////////////////////////
1807 // new ModelTest(vm, this); //FIXME-3
1808 /////////////////////////////////////
1810 VymView *vv=new VymView (vm);
1811 vymViews.append (vv);
1812 tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file"));
1813 tabWidget->setCurrentIndex (vymViews.count() );
1816 // Create MapCenter for empty map
1820 // For the very first map we do not have flagrows yet...
1824 void Main::fileNewCopy()
1826 QString fn="unnamed";
1827 VymModel *srcModel=currentModel();
1832 VymModel *dstModel=vymViews.last()->getModel();
1833 dstModel->select("mc:");
1834 dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap);
1838 ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype)
1840 ErrorCode err=success;
1842 // fn is usually the archive, mapfile the file after uncompressing
1845 // Make fn absolute (needed for unzip)
1846 fn=QDir (fn).absPath();
1852 // Check, if map is already loaded
1854 while (i<=tabWidget->count() -1)
1856 if (vymViews.at(i)->getModel()->getFilePath() == fn)
1858 // Already there, ask for confirmation
1859 QMessageBox mb( vymName,
1860 tr("The map %1\nis already opened."
1861 "Opening the same map in multiple editors may lead \n"
1862 "to confusion when finishing working with vym."
1863 "Do you want to").arg(fn),
1864 QMessageBox::Warning,
1865 QMessageBox::Yes | QMessageBox::Default,
1866 QMessageBox::Cancel | QMessageBox::Escape,
1867 QMessageBox::NoButton);
1868 mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
1869 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
1872 case QMessageBox::Yes:
1873 // end loop and load anyway
1874 i=tabWidget->count();
1876 case QMessageBox::Cancel:
1886 int tabIndex=tabWidget->currentPageIndex();
1889 if ( !fn.isEmpty() )
1891 vm = currentModel();
1892 // Check first, if mapeditor exists
1893 // If it is not default AND we want a new map,
1894 // create a new mapeditor in a new tab
1895 if ( lmode==NewMap && (!vm || !vm->isDefault() ) )
1898 VymView *vv=new VymView (vm);
1899 vymViews.append (vv);
1900 tabWidget->addTab (vv,fn);
1901 tabIndex=tabWidget->count()-1;
1902 tabWidget->setCurrentPage (tabIndex);
1906 // Check, if file exists (important for creating new files
1907 // from command line
1908 if (!QFile(fn).exists() )
1910 QMessageBox mb( vymName,
1911 tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn),
1912 QMessageBox::Question,
1914 QMessageBox::Cancel | QMessageBox::Default,
1915 QMessageBox::NoButton );
1917 mb.setButtonText( QMessageBox::Yes, tr("Create"));
1918 mb.setButtonText( QMessageBox::No, tr("Cancel"));
1921 case QMessageBox::Yes:
1923 currentMapEditor()->getModel()->setFilePath(fn);
1924 tabWidget->setTabText (tabIndex,
1925 currentMapEditor()->getModel()->getFileName() );
1926 statusBar()->message( "Created " + fn , statusbarTime );
1929 case QMessageBox::Cancel:
1930 // don't create new map
1931 statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
1938 //tabWidget->currentPage() won't be NULL here, because of above...
1939 tabWidget->setCurrentIndex (tabIndex);
1940 //FIXME-3 no me anymore... me->viewport()->setFocus();
1944 // Save existing filename in case we import
1945 QString fn_org=vm->getFilePath();
1947 // Finally load map into mapEditor
1948 vm->setFilePath (fn);
1949 err=vm->load(fn,lmode,ftype);
1951 // Restore old (maybe empty) filepath, if this is an import
1953 vm->setFilePath (fn_org);
1956 // Finally check for errors and go home
1959 if (lmode==NewMap) fileCloseMap();
1960 statusBar()->message( "Could not load " + fn, statusbarTime );
1965 vm->setFilePath (fn);
1966 tabWidget->setTabText (tabIndex, vm->getFileName());
1967 if (!isInTmpDir (fn))
1969 // Only append to lastMaps if not loaded from a tmpDir
1970 // e.g. imported bookmarks are in a tmpDir
1971 addRecentMap(vm->getFilePath() );
1973 actionFilePrint->setEnabled (true);
1975 statusBar()->message( "Loaded " + fn, statusbarTime );
1982 void Main::fileLoad(const LoadMode &lmode)
1984 QStringList filters;
1985 filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)";
1986 QFileDialog *fd=new QFileDialog( this);
1987 fd->setDir (lastFileDir);
1988 fd->setFileMode (QFileDialog::ExistingFiles);
1989 fd->setFilters (filters);
1993 fd->setCaption(vymName+ " - " +tr("Load vym map"));
1996 fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection"));
1999 fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map"));
2005 if ( fd->exec() == QDialog::Accepted )
2007 lastFileDir=fd->directory().path();
2008 QStringList flist = fd->selectedFiles();
2009 QStringList::Iterator it = flist.begin();
2011 progressCounter=flist.count();
2012 progressCounterTotal=flist.count();
2013 while( it != flist.end() )
2016 fileLoad(*it, lmode);
2023 void Main::fileLoad()
2028 void Main::fileLoadRecent()
2030 QAction *action = qobject_cast<QAction *>(sender());
2032 fileLoad (action->data().toString(), NewMap);
2035 void Main::addRecentMap (const QString &fileName)
2038 QStringList files = settings.value("/mainwindow/recentFileList").toStringList();
2039 files.removeAll(fileName);
2040 files.prepend(fileName);
2041 while (files.size() > MaxRecentFiles)
2044 settings.setValue("/mainwindow/recentFileList", files);
2046 setupRecentMapsMenu();
2049 void Main::fileSave(VymModel *m, const SaveMode &savemode)
2053 if ( m->getFilePath().isEmpty() )
2055 // We have no filepath yet,
2056 // call fileSaveAs() now, this will call fileSave()
2058 // First switch to editor
2059 //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor());
2060 fileSaveAs(savemode);
2063 if (m->save (savemode)==success)
2065 statusBar()->message(
2066 tr("Saved %1").arg(m->getFilePath()),
2068 addRecentMap (m->getFilePath() );
2070 statusBar()->message(
2071 tr("Couldn't save ").arg(m->getFilePath()),
2075 void Main::fileSave()
2077 fileSave (currentModel(), CompleteMap);
2080 void Main::fileSave(VymModel *m)
2082 fileSave (m,CompleteMap);
2085 void Main::fileSaveAs(const SaveMode& savemode)
2089 if (currentMapEditor())
2091 if (savemode==CompleteMap)
2092 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
2094 fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
2095 if ( !fn.isEmpty() )
2097 // Check for existing file
2098 if (QFile (fn).exists())
2100 QMessageBox mb( vymName,
2101 tr("The file %1\nexists already. Do you want to").arg(fn),
2102 QMessageBox::Warning,
2103 QMessageBox::Yes | QMessageBox::Default,
2104 QMessageBox::Cancel | QMessageBox::Escape,
2105 QMessageBox::NoButton);
2106 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
2107 mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
2110 case QMessageBox::Yes:
2113 case QMessageBox::Cancel:
2120 // New file, add extension to filename, if missing
2121 // This is always .vym or .vyp, depending on savemode
2122 if (savemode==CompleteMap)
2124 if (!fn.contains (".vym") && !fn.contains (".xml"))
2128 if (!fn.contains (".vyp") && !fn.contains (".xml"))
2137 VymModel *m=currentModel();
2139 fileSave(m, savemode);
2141 // Set name of tab, assuming current tab is the one we just saved
2142 if (savemode==CompleteMap)
2143 tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() );
2149 void Main::fileSaveAs()
2151 fileSaveAs (CompleteMap);
2154 void Main::fileImportKDE3Bookmarks()
2156 ImportKDE3Bookmarks im;
2158 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2159 currentMapEditor()->getModel()->setFilePath ("");
2162 void Main::fileImportKDE4Bookmarks()
2164 ImportKDE4Bookmarks im;
2166 if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
2167 currentMapEditor()->getModel()->setFilePath ("");
2170 void Main::fileImportFirefoxBookmarks()
2172 Q3FileDialog *fd=new Q3FileDialog( this);
2173 fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
2174 fd->setMode (Q3FileDialog::ExistingFiles);
2175 fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
2176 fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
2179 if ( fd->exec() == QDialog::Accepted )
2181 ImportFirefoxBookmarks im;
2182 QStringList flist = fd->selectedFiles();
2183 QStringList::Iterator it = flist.begin();
2184 while( it != flist.end() )
2187 if (im.transform() &&
2188 aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) &&
2189 currentMapEditor() )
2190 currentMapEditor()->getModel()->setFilePath ("");
2197 void Main::fileImportFreemind()
2199 QStringList filters;
2200 filters <<"Freemind map (*.mm)"<<"All files (*)";
2201 QFileDialog *fd=new QFileDialog( this);
2202 fd->setDir (lastFileDir);
2203 fd->setFileMode (QFileDialog::ExistingFiles);
2204 fd->setFilters (filters);
2205 fd->setCaption(vymName+ " - " +tr("Load Freemind map"));
2209 if ( fd->exec() == QDialog::Accepted )
2211 lastFileDir=fd->directory().path();
2212 QStringList flist = fd->selectedFiles();
2213 QStringList::Iterator it = flist.begin();
2214 while( it != flist.end() )
2217 if ( fileLoad (fn,NewMap, FreemindMap) )
2219 currentMapEditor()->getModel()->setFilePath ("");
2228 void Main::fileImportMM()
2232 Q3FileDialog *fd=new Q3FileDialog( this);
2233 fd->setDir (lastFileDir);
2234 fd->setMode (Q3FileDialog::ExistingFiles);
2235 fd->addFilter ("Mind Manager (*.mmap)");
2236 fd->setCaption(tr("Import")+" "+"Mind Manager");
2239 if ( fd->exec() == QDialog::Accepted )
2241 lastFileDir=fd->dirPath();
2242 QStringList flist = fd->selectedFiles();
2243 QStringList::Iterator it = flist.begin();
2244 while( it != flist.end() )
2247 if (im.transform() &&
2248 success==fileLoad (im.getTransformedFile(),NewMap) &&
2249 currentMapEditor() )
2250 currentMapEditor()->getModel()->setFilePath ("");
2257 void Main::fileImportDir()
2259 VymModel *m=currentModel();
2260 if (m) m->importDir();
2263 void Main::fileExportXML()
2265 VymModel *m=currentModel();
2266 if (m) m->exportXML();
2269 void Main::fileExportHTML()
2271 VymModel *m=currentModel();
2272 if (m) m->exportHTML();
2276 void Main::fileExportXHTML()
2278 VymModel *m=currentModel();
2279 if (m) m->exportXHTML();
2282 void Main::fileExportImage()
2284 VymModel *m=currentModel();
2285 if (m) m->exportImage();
2288 void Main::fileExportAO()
2290 VymModel *m=currentModel();
2291 if (m) m->exportAO();
2294 void Main::fileExportASCII()
2296 VymModel *m=currentModel();
2297 if (m) m->exportASCII();
2300 void Main::fileExportCSV() //FIXME-3 not scriptable yet
2302 VymModel *m=currentModel();
2307 ex.addFilter ("CSV (*.csv)");
2308 ex.setDir(lastImageDir);
2309 ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)"));
2310 if (ex.execDialog() )
2312 m->setExportMode(true);
2314 m->setExportMode(false);
2319 void Main::fileExportLaTeX() //FIXME-3 not scriptable yet
2321 VymModel *m=currentModel();
2326 ex.addFilter ("Tex (*.tex)");
2327 ex.setDir(lastImageDir);
2328 ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
2329 if (ex.execDialog() )
2331 m->setExportMode(true);
2333 m->setExportMode(false);
2338 void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet
2340 ExportKDE3Bookmarks ex;
2341 VymModel *m=currentModel();
2349 void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet
2351 ExportKDE4Bookmarks ex;
2352 VymModel *m=currentModel();
2360 void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet
2362 ExportTaskjuggler ex;
2363 VymModel *m=currentModel();
2367 ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
2368 ex.setDir(lastImageDir);
2369 ex.addFilter ("Taskjuggler (*.tjp)");
2370 if (ex.execDialog() )
2372 m->setExportMode(true);
2374 m->setExportMode(false);
2379 void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet
2381 ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
2382 // TODO add preview in dialog
2383 //ImagePreview *p =new ImagePreview (fd);
2384 //fd->setContentsPreviewEnabled( TRUE );
2385 //fd->setContentsPreview( p, p );
2386 //fd->setPreviewMode( QFileDialog::Contents );
2387 fd->setCaption(vymName+" - " +tr("Export to")+" Open Office");
2388 fd->setDir (QDir().current());
2389 if (fd->foundConfig())
2393 if ( fd->exec() == QDialog::Accepted )
2395 QString fn=fd->selectedFile();
2396 if (!fn.contains (".odp"))
2399 //lastImageDir=fn.left(fn.findRev ("/"));
2400 VymModel *m=currentModel();
2401 if (m) m->exportOOPresentation(fn,fd->selectedConfig());
2405 QMessageBox::warning(0,
2407 tr("Couldn't find configuration for export to Open Office\n"));
2411 void Main::fileCloseMap()
2413 VymModel *m=currentModel();
2416 if (m->hasChanged())
2418 QMessageBox mb( vymName,
2419 tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()),
2420 QMessageBox::Warning,
2421 QMessageBox::Yes | QMessageBox::Default,
2423 QMessageBox::Cancel | QMessageBox::Escape );
2424 mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") );
2425 mb.setButtonText( QMessageBox::No, tr("Discard changes"));
2428 case QMessageBox::Yes:
2430 fileSave(m, CompleteMap);
2432 case QMessageBox::No:
2433 // close without saving
2435 case QMessageBox::Cancel:
2440 // And here comes the segfault, because removeTab triggers
2441 // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet...
2442 vymViews.removeAt (tabWidget->currentIndex() );
2443 tabWidget->removeTab (tabWidget->currentIndex() );
2445 // Remove mapEditor/model FIXME-3 Huh? seems to work now...
2446 // Better would be delete (me), but then we could have a Qt error:
2447 // "QObject: Do not delete object, 'MapEditor', during its event handler!"
2448 // So we only remove data now and call deconstructor when vym closes later
2449 // this needs to be moved to vymview... me->clear();
2450 // some model->clear is needed to free up memory ...
2452 delete (m->getMapEditor());
2459 void Main::filePrint()
2461 if (currentMapEditor())
2462 currentMapEditor()->print();
2465 void Main::fileExitVYM()
2467 // Check if one or more editors have changed
2469 for (i=0;i<=vymViews.count() -1;i++)
2471 // If something changed, ask what to do
2472 if (vymViews.at(i)->getModel()->hasChanged())
2474 tabWidget->setCurrentPage(i);
2475 QMessageBox mb( vymName,
2476 tr("This map is not saved yet. Do you want to"),
2477 QMessageBox::Warning,
2478 QMessageBox::Yes | QMessageBox::Default,
2480 QMessageBox::Cancel | QMessageBox::Escape );
2481 mb.setButtonText( QMessageBox::Yes, tr("Save map") );
2482 mb.setButtonText( QMessageBox::No, tr("Discard changes") );
2485 mb.setActiveWindow();
2486 switch( mb.exec() ) {
2487 case QMessageBox::Yes:
2488 // save (the changed editors) and exit
2489 fileSave(currentModel(), CompleteMap);
2491 case QMessageBox::No:
2492 // exit without saving
2494 case QMessageBox::Cancel:
2495 // don't save and don't exit
2499 } // loop over all MEs
2503 void Main::editUndo()
2505 VymModel *m=currentModel();
2509 void Main::editRedo()
2511 VymModel *m=currentModel();
2515 void Main::gotoHistoryStep (int i)
2517 VymModel *m=currentModel();
2518 if (m) m->gotoHistoryStep(i);
2521 void Main::editCopy()
2523 VymModel *m=currentModel();
2527 void Main::editPaste()
2529 VymModel *m=currentModel();
2533 void Main::editCut()
2535 VymModel *m=currentModel();
2539 void Main::editOpenFindWidget()
2541 VymModel *m=currentModel();
2542 if (m) m->emitShowFindWidget();
2545 void Main::editFindDuplicateURLs()
2547 VymModel *m=currentModel();
2548 if (m) m->findDuplicateURLs();
2551 void Main::openTabs(QStringList urls)
2553 if (!urls.isEmpty())
2557 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2558 //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
2559 if (*browserPID==0 ||
2560 (browser.contains("konqueror") &&
2561 !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
2564 // Start a new browser, if there is not one running already or
2565 // if a previously started konqueror is gone.
2566 if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
2567 QString u=urls.takeFirst();
2569 QString workDir=QDir::currentDirPath();
2570 if (!QProcess::startDetached(browser,args,workDir,browserPID))
2572 // try to set path to browser
2573 QMessageBox::warning(0,
2575 tr("Couldn't find a viewer to open %1.\n").arg(u)+
2576 tr("Please use Settings->")+tr("Set application to open an URL"));
2579 if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<<endl;
2580 #if defined(Q_OS_WIN32)
2581 // There's no sleep in VCEE, replace it with Qt's QThread::wait().
2582 this->thread()->wait(3000);
2584 sleep (3); //FIXME-3 needed?
2588 if (browser.contains("konqueror"))
2590 for (int i=0; i<urls.size(); i++)
2593 // Try to open new tab in existing konqueror started previously by vym
2597 args<< QString("konqueror-%1").arg(procBrowser->pid())<<
2598 "konqueror-mainwindow#1"<<
2602 args<< QString("org.kde.konqueror-%1").arg(*browserPID)<<
2603 "/konqueror/MainWindow_1"<<
2607 if (debug) cout << "MainWindow::openURLs args="<<args.join(" ").toStdString()<<endl;
2608 if (!QProcess::startDetached ("qdbus",args))
2612 QMessageBox::warning(0,
2614 tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
2616 } else if (browser.contains ("firefox") || browser.contains ("mozilla") )
2618 for (int i=0; i<urls.size(); i++)
2620 // Try to open new tab in firefox
2621 args<< "-remote"<< QString("openurl(%1,new-tab)").arg(urls.at(i));
2622 if (!QProcess::startDetached (browser,args))
2626 QMessageBox::warning(0,
2628 tr("Couldn't start %1 to open a new tab").arg(browser));
2631 QMessageBox::warning(0,
2633 tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing."));
2637 void Main::editOpenURL()
2640 VymModel *m=currentModel();
2643 QString url=m->getURL();
2645 if (url=="") return;
2646 QString browser=settings.value("/mainwindow/readerURL" ).toString();
2648 QString workDir=QDir::currentDirPath();
2649 if (!procBrowser->startDetached(browser,args))
2651 // try to set path to browser
2652 QMessageBox::warning(0,
2654 tr("Couldn't find a viewer to open %1.\n").arg(url)+
2655 tr("Please use Settings->")+tr("Set application to open an URL"));
2660 void Main::editOpenURLTab()
2662 VymModel *m=currentModel();
2666 urls.append(m->getURL());
2671 void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
2673 VymModel *m=currentModel();
2677 urls=m->getURLs(ignoreScrolled);
2682 void Main::editOpenMultipleURLTabs()
2684 editOpenMultipleVisURLTabs (false);
2688 void Main::editURL()
2690 VymModel *m=currentModel();
2691 if (m) m->editURL();
2694 void Main::editLocalURL()
2696 VymModel *m=currentModel();
2697 if (m) m->editLocalURL();
2700 void Main::editHeading2URL()
2702 VymModel *m=currentModel();
2703 if (m) m->editHeading2URL();
2706 void Main::editBugzilla2URL()
2708 VymModel *m=currentModel();
2709 if (m) m->editBugzilla2URL();
2712 void Main::getBugzillaData()
2714 VymModel *m=currentModel();
2716 QProgressDialog progress ("Doing stuff","cancl",0,10,this);
2717 progress.setWindowModality(Qt::WindowModal);
2718 //progress.setCancelButton (NULL);
2720 progress.setMinimumDuration (0);
2721 progress.setValue (1);
2722 progress.setValue (5);
2726 QProgressBar *pb=new QProgressBar;
2732 if (m) m->getBugzillaData();
2735 void Main::editFATE2URL()
2737 VymModel *m=currentModel();
2738 if (m) m->editFATE2URL();
2741 void Main::editHeadingFinished(VymModel *m)
2745 if (!actionSettingsAutoSelectNewBranch->isOn() &&
2746 !prevSelection.isEmpty())
2747 m->select(prevSelection);
2752 void Main::openVymLinks(const QStringList &vl)
2754 for (int j=0; j<vl.size(); j++)
2756 // compare path with already loaded maps
2759 for (i=0;i<=vymViews.count() -1;i++)
2761 if (vl.at(j)==vymViews.at(i)->getModel()->getFilePath() )
2770 if (!QFile(vl.at(j)).exists() )
2771 QMessageBox::critical( 0, tr( "Critical Error" ),
2772 tr("Couldn't open map %1").arg(vl.at(j)));
2775 fileLoad (vl.at(j), NewMap);
2776 tabWidget->setCurrentIndex (tabWidget->count()-1);
2779 // Go to tab containing the map
2780 tabWidget->setCurrentIndex (index);
2784 void Main::editOpenVymLink()
2786 VymModel *m=currentModel();
2790 vl.append(m->getVymLink());
2795 void Main::editOpenMultipleVymLinks()
2797 QString currentVymLink;
2798 VymModel *m=currentModel();
2801 QStringList vl=m->getVymLinks();
2806 void Main::editVymLink()
2808 VymModel *m=currentModel();
2813 void Main::editDeleteVymLink()
2815 VymModel *m=currentModel();
2816 if (m) m->deleteVymLink();
2819 void Main::editToggleHideExport()
2821 VymModel *m=currentModel();
2822 if (m) m->toggleHideExport();
2825 void Main::editAddTimestamp()
2827 VymModel *m=currentModel();
2828 if (m) m->addTimestamp();
2831 void Main::editMapInfo()
2833 VymModel *m=currentModel();
2836 ExtraInfoDialog dia;
2837 dia.setMapName (m->getFileName() );
2838 dia.setAuthor (m->getAuthor() );
2839 dia.setComment(m->getComment() );
2843 stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->items().size(),6);
2849 BranchItem *cur=NULL;
2850 BranchItem *prev=NULL;
2851 m->nextBranch(cur,prev);
2854 if (!cur->getNote().isEmpty() ) n++;
2855 f+= cur->imageCount();
2857 xl+=cur->xlinkCount();
2858 m->nextBranch(cur,prev);
2861 stats+=QString ("%1 xLinks \n").arg (xl,6);
2862 stats+=QString ("%1 notes\n").arg (n,6);
2863 stats+=QString ("%1 images\n").arg (f,6);
2864 stats+=QString ("%1 branches\n").arg (m->branchCount(),6);
2865 dia.setStats (stats);
2867 // Finally show dialog
2868 if (dia.exec() == QDialog::Accepted)
2870 m->setAuthor (dia.getAuthor() );
2871 m->setComment (dia.getComment() );
2875 void Main::editMoveUp()
2877 VymModel *m=currentModel();
2881 void Main::editMoveDown()
2883 VymModel *m=currentModel();
2884 if (m) m->moveDown();
2887 void Main::editDetach()
2889 VymModel *m=currentModel();
2893 void Main::editSortChildren()
2895 VymModel *m=currentModel();
2896 if (m) m->sortChildren();
2899 void Main::editToggleScroll()
2901 VymModel *m=currentModel();
2902 if (m) m->toggleScroll();
2905 void Main::editExpandAll()
2907 VymModel *m=currentModel();
2908 if (m) m->emitExpandAll();
2911 void Main::editExpandOneLevel()
2913 VymModel *m=currentModel();
2914 if (m) m->emitExpandOneLevel();
2917 void Main::editCollapseOneLevel()
2919 VymModel *m=currentModel();
2920 if (m) m->emitCollapseOneLevel();
2923 void Main::editUnscrollChildren()
2925 VymModel *m=currentModel();
2926 if (m) m->unscrollChildren();
2929 void Main::editAddAttribute()
2931 VymModel *m=currentModel();
2939 void Main::editAddMapCenter()
2941 VymModel *m=currentModel();
2942 if (m) m->addMapCenter ();
2945 void Main::editNewBranch()
2947 VymModel *m=currentModel();
2950 BranchItem *bi=m->addNewBranch();
2953 if (actionSettingsAutoEditNewBranch->isOn()
2954 && !actionSettingsAutoSelectNewBranch->isOn() )
2955 prevSelection=m->getSelectString();
2957 prevSelection=QString();
2959 if (actionSettingsAutoSelectNewBranch->isOn()
2960 || actionSettingsAutoEditNewBranch->isOn())
2963 if (actionSettingsAutoEditNewBranch->isOn())
2964 currentMapEditor()->editHeading();
2969 void Main::editNewBranchBefore()
2971 VymModel *m=currentModel();
2974 BranchItem *bi=m->addNewBranchBefore();
2981 if (actionSettingsAutoEditNewBranch->isOn())
2983 if (!actionSettingsAutoSelectNewBranch->isOn())
2984 prevSelection=m->getSelectString(bi);
2985 currentMapEditor()->editHeading();
2990 void Main::editNewBranchAbove()
2992 VymModel *m=currentModel();
2995 BranchItem *bi=m->addNewBranch (-1);
3003 if (actionSettingsAutoEditNewBranch->isOn())
3005 if (!actionSettingsAutoSelectNewBranch->isOn())
3006 prevSelection=m->getSelectString (bi);
3007 currentMapEditor()->editHeading();
3012 void Main::editNewBranchBelow()
3014 VymModel *m=currentModel();
3017 BranchItem *bi=m->addNewBranch (1);
3024 if (actionSettingsAutoEditNewBranch->isOn())
3026 if (!actionSettingsAutoSelectNewBranch->isOn())
3027 prevSelection=m->getSelectString(bi);
3028 currentMapEditor()->editHeading();
3033 void Main::editImportAdd()
3035 fileLoad (ImportAdd);
3038 void Main::editImportReplace()
3040 fileLoad (ImportReplace);
3043 void Main::editSaveBranch()
3045 fileSaveAs (PartOfMap);
3048 void Main::editDeleteKeepChildren()
3050 VymModel *m=currentModel();
3051 if (m) m->deleteKeepChildren();
3054 void Main::editDeleteChildren()
3056 VymModel *m=currentModel();
3057 if (m) m->deleteChildren();
3060 void Main::editDeleteSelection()
3062 VymModel *m=currentModel();
3063 if (m && actionSettingsUseDelKey->isOn())
3064 m->deleteSelection();
3067 void Main::editLoadImage()
3069 VymModel *m=currentModel();
3070 if (m) m->loadFloatImage();
3073 void Main::editSaveImage()
3075 VymModel *m=currentModel();
3076 if (m) m->saveFloatImage();
3079 void Main::editEditXLink(QAction *a)
3081 VymModel *m=currentModel();
3083 m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a));
3086 void Main::formatSelectColor()
3088 QColor col = QColorDialog::getColor((currentColor ), this );
3089 if ( !col.isValid() ) return;
3090 colorChanged( col );
3093 void Main::formatPickColor()
3095 VymModel *m=currentModel();
3097 colorChanged( m->getCurrentHeadingColor() );
3100 void Main::colorChanged(QColor c)
3102 QPixmap pix( 16, 16 );
3104 actionFormatColor->setIconSet( pix );
3108 void Main::formatColorBranch()
3110 VymModel *m=currentModel();
3111 if (m) m->colorBranch(currentColor);
3114 void Main::formatColorSubtree()
3116 VymModel *m=currentModel();
3117 if (m) m->colorSubtree (currentColor);
3120 void Main::formatLinkStyleLine()
3122 VymModel *m=currentModel();
3125 m->setMapLinkStyle("StyleLine");
3126 actionFormatLinkStyleLine->setChecked(true);
3130 void Main::formatLinkStyleParabel()
3132 VymModel *m=currentModel();
3135 m->setMapLinkStyle("StyleParabel");
3136 actionFormatLinkStyleParabel->setChecked(true);
3140 void Main::formatLinkStylePolyLine()
3142 VymModel *m=currentModel();
3145 m->setMapLinkStyle("StylePolyLine");
3146 actionFormatLinkStylePolyLine->setChecked(true);
3150 void Main::formatLinkStylePolyParabel()
3152 VymModel *m=currentModel();
3155 m->setMapLinkStyle("StylePolyParabel");
3156 actionFormatLinkStylePolyParabel->setChecked(true);
3160 void Main::formatSelectBackColor()
3162 VymModel *m=currentModel();
3163 if (m) m->selectMapBackgroundColor();
3166 void Main::formatSelectBackImage()
3168 VymModel *m=currentModel();
3170 m->selectMapBackgroundImage();
3173 void Main::formatSelectLinkColor()
3175 VymModel *m=currentModel();
3178 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3179 m->setMapDefLinkColor( col );
3183 void Main::formatSelectSelectionColor()
3185 VymModel *m=currentModel();
3188 QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this );
3189 m->setSelectionColor (col);
3194 void Main::formatToggleLinkColorHint()
3196 VymModel *m=currentModel();
3197 if (m) m->toggleMapLinkColorHint();
3201 void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog
3203 VymModel *m=currentModel();
3205 m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
3208 void Main::viewZoomReset()
3210 MapEditor *me=currentMapEditor();
3211 if (me) me->setZoomFactorTarget (1);
3214 void Main::viewZoomIn()
3216 MapEditor *me=currentMapEditor();
3217 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25);
3220 void Main::viewZoomOut()
3222 MapEditor *me=currentMapEditor();
3223 if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75);
3226 void Main::viewCenter()
3228 VymModel *m=currentModel();
3229 if (m) m->emitShowSelection();
3232 void Main::networkStartServer()
3234 VymModel *m=currentModel();
3235 if (m) m->newServer();
3238 void Main::networkConnect()
3240 VymModel *m=currentModel();
3241 if (m) m->connectToServer();
3244 bool Main::settingsPDF()
3246 // Default browser is set in constructor
3248 QString text = QInputDialog::getText(
3249 "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
3250 settings.value("/mainwindow/readerPDF").toString(), &ok, this );
3252 settings.setValue ("/mainwindow/readerPDF",text);
3257 bool Main::settingsURL()
3259 // Default browser is set in constructor
3261 QString text = QInputDialog::getText(
3262 "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
3263 settings.value("/mainwindow/readerURL").toString()
3266 settings.setValue ("/mainwindow/readerURL",text);
3270 void Main::settingsMacroDir()
3272 QDir defdir(vymBaseDir.path() + "/macros");
3273 if (!defdir.exists())
3275 QDir dir=QFileDialog::getExistingDirectory (
3277 tr ("Directory with vym macros:"),
3278 settings.value ("/macros/macroDir",defdir.path()).toString()
3281 settings.setValue ("/macros/macroDir",dir.absolutePath());
3284 void Main::settingsUndoLevels()
3287 int i = QInputDialog::getInteger(
3289 tr("QInputDialog::getInteger()"),
3290 tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok);
3293 settings.setValue ("/mapeditor/stepsTotal",i);
3294 QMessageBox::information( this, tr( "VYM -Information:" ),
3295 tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i));
3299 void Main::settingsAutosaveToggle()
3301 settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
3304 void Main::settingsAutosaveTime()
3307 int i = QInputDialog::getInteger(
3309 tr("QInputDialog::getInteger()"),
3310 tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
3312 settings.setValue ("/mainwindow/autosave/ms",i * 1000);
3315 void Main::settingsWriteBackupFileToggle()
3317 settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
3320 void Main::settingsToggleAnimation()
3322 settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() );
3325 void Main::settingsToggleDelKey()
3327 if (actionSettingsUseDelKey->isOn())
3329 actionDelete->setAccel (QKeySequence (Qt::Key_Delete));
3332 actionDelete->setAccel (QKeySequence (""));
3336 void Main::windowToggleNoteEditor()
3338 if (textEditor->isVisible() )
3339 windowHideNoteEditor();
3341 windowShowNoteEditor();
3344 void Main::windowToggleHistory()
3346 if (historyWindow->isVisible())
3347 historyWindow->hide();
3349 historyWindow->show();
3353 void Main::windowToggleProperty()
3355 if (branchPropertyWindow->isVisible())
3356 branchPropertyWindow->hide();
3358 branchPropertyWindow->show();
3359 branchPropertyWindow->setModel (currentModel() );
3362 void Main::windowToggleAntiAlias()
3364 bool b=actionViewToggleAntiAlias->isOn();
3366 for (int i=0;i<vymViews.count();i++)
3368 me=vymViews.at(i)->getMapEditor();
3369 if (me) me->setAntiAlias(b);
3374 bool Main::isAliased()
3376 return actionViewToggleAntiAlias->isOn();
3379 bool Main::hasSmoothPixmapTransform()
3381 return actionViewToggleSmoothPixmapTransform->isOn();
3384 void Main::windowToggleSmoothPixmap()
3386 bool b=actionViewToggleSmoothPixmapTransform->isOn();
3388 for (int i=0;i<vymViews.count();i++)
3391 me=vymViews.at(i)->getMapEditor();
3392 if (me) me->setSmoothPixmap(b);
3396 void Main::updateHistory(SimpleSettings &undoSet)
3398 historyWindow->update (undoSet);
3401 void Main::updateNoteFlag()
3403 // this slot is connected to TextEditor::textHasChanged()
3404 VymModel *m=currentModel();
3405 if (m) m->updateNoteFlag();
3408 void Main::updateNoteEditor(QModelIndex index )
3410 TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
3412 cout << "Main::updateNoteEditor model="<<sender();
3413 cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
3415 textEditor->setNote (ti->getNoteObj() );
3418 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
3420 branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
3422 if (model && model==currentModel() )
3426 if (!oldsel.indexes().isEmpty() )
3428 ti=model->getItem(oldsel.indexes().first());
3430 // Don't update note if both treeItem and textEditor are empty
3431 //if (! (ti->hasEmptyNote() && textEditor->isEmpty() ))
3432 // ti->setNoteObj (textEditor->getNoteObj(),false );
3434 if (!newsel.indexes().isEmpty() )
3436 ti=model->getItem(newsel.indexes().first());
3437 if (!ti->hasEmptyNote() )
3438 textEditor->setNote(ti->getNoteObj() );
3440 textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE
3442 // Show URL and link in statusbar
3444 QString s=ti->getURL();
3445 if (!s.isEmpty() ) status+="URL: "+s+" ";
3447 if (!s.isEmpty() ) status+="Link: "+s;
3448 if (!status.isEmpty() ) statusMessage (status);
3451 textEditor->setInactive();
3457 void Main::updateActions()
3459 // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed
3460 actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
3461 actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
3462 actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
3464 VymModel *m =currentModel();
3468 actionFilePrint->setEnabled (true);
3470 // Link style in context menu
3471 switch (m->getMapLinkStyle())
3473 case LinkableMapObj::Line:
3474 actionFormatLinkStyleLine->setChecked(true);
3476 case LinkableMapObj::Parabel:
3477 actionFormatLinkStyleParabel->setChecked(true);
3479 case LinkableMapObj::PolyLine:
3480 actionFormatLinkStylePolyLine->setChecked(true);
3482 case LinkableMapObj::PolyParabel:
3483 actionFormatLinkStylePolyParabel->setChecked(true);
3490 QPixmap pix( 16, 16 );
3491 pix.fill( m->getMapBackgroundColor() );
3492 actionFormatBackColor->setIconSet( pix );
3493 pix.fill( m->getSelectionColor() );
3494 actionFormatSelectionColor->setIconSet( pix );
3495 pix.fill( m->getMapDefLinkColor() );
3496 actionFormatLinkColor->setIconSet( pix );
3499 historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName()));
3502 // Expanding/collapsing
3503 actionExpandAll->setEnabled (true);
3504 actionExpandOneLevel->setEnabled (true);
3505 actionCollapseOneLevel->setEnabled (true);
3509 actionFilePrint->setEnabled (false);
3511 // Expanding/collapsing
3512 actionExpandAll->setEnabled (false);
3513 actionExpandOneLevel->setEnabled (false);
3514 actionCollapseOneLevel->setEnabled (false);
3517 if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor)
3518 actionFormatLinkColorHint->setChecked(true);
3520 actionFormatLinkColorHint->setChecked(false);
3523 if (m && m->hasChanged() )
3524 actionFileSave->setEnabled( true);
3526 actionFileSave->setEnabled( false);
3527 if (m && m->isUndoAvailable())
3528 actionUndo->setEnabled( true);
3530 actionUndo->setEnabled( false);
3532 if (m && m->isRedoAvailable())
3533 actionRedo->setEnabled( true);
3535 actionRedo->setEnabled( false);
3539 TreeItem *selti=m->getSelectedItem();
3540 BranchItem *selbi=m->getSelectedBranch();
3543 if (selbi || selti->getType()==TreeItem::Image)
3545 actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected());
3546 actionFormatHideLinkUnselected->setEnabled (true);
3551 // Take care of xlinks
3552 branchXLinksContextMenuEdit->clear();
3553 if (selbi->xlinkCount()>0)
3557 for (int i=0; i<selbi->xlinkCount();++i)
3559 bi=selbi->getXLinkNum(i)->getPartnerBranch();
3563 if (s.length()>xLinkMenuWidth)
3564 s=s.left(xLinkMenuWidth)+"...";
3565 branchXLinksContextMenuEdit->addAction (s);
3570 standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() );
3573 actionToggleScroll->setEnabled (true);
3574 if ( selbi->isScrolled() )
3575 actionToggleScroll->setChecked(true);
3577 actionToggleScroll->setChecked(false);
3579 if ( selti->getURL().isEmpty() )
3581 actionOpenURL->setEnabled (false);
3582 actionOpenURLTab->setEnabled (false);
3586 actionOpenURL->setEnabled (true);
3587 actionOpenURLTab->setEnabled (true);
3589 if ( selti->getVymLink().isEmpty() )
3591 actionOpenVymLink->setEnabled (false);
3592 actionDeleteVymLink->setEnabled (false);
3595 actionOpenVymLink->setEnabled (true);
3596 actionDeleteVymLink->setEnabled (true);
3599 if (selbi->canMoveUp())
3600 actionMoveUp->setEnabled (true);
3602 actionMoveUp->setEnabled (false);
3603 if (selbi->canMoveDown())
3604 actionMoveDown->setEnabled (true);
3606 actionMoveDown->setEnabled (false);
3608 actionSortChildren->setEnabled (true);
3610 actionToggleHideExport->setEnabled (true);
3611 actionToggleHideExport->setChecked (selbi->hideInExport() );
3613 actionCopy->setEnabled (true);
3614 actionCut->setEnabled (true);
3615 if (!clipboardEmpty)
3616 actionPaste->setEnabled (true);
3618 actionPaste->setEnabled (false);
3619 for (int i=0; i<actionListBranches.size(); ++i)
3620 actionListBranches.at(i)->setEnabled(true);
3621 actionDelete->setEnabled (true);
3623 if ( selti->getType()==TreeItem::Image)
3625 actionOpenURL->setEnabled (false);
3626 actionOpenVymLink->setEnabled (false);
3627 actionDeleteVymLink->setEnabled (false);
3628 actionToggleHideExport->setEnabled (true);
3629 actionToggleHideExport->setChecked (selti->hideInExport() );
3632 actionCopy->setEnabled (true);
3633 actionCut->setEnabled (true);
3634 actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images?
3635 for (int i=0; i<actionListBranches.size(); ++i)
3636 actionListBranches.at(i)->setEnabled(false);
3637 actionDelete->setEnabled (true);
3638 actionMoveUp->setEnabled (false);
3639 actionMoveDown->setEnabled (false);
3644 actionCopy->setEnabled (false);
3645 actionCut->setEnabled (false);
3646 actionPaste->setEnabled (false);
3647 for (int i=0; i<actionListBranches.size(); ++i)
3648 actionListBranches.at(i)->setEnabled(false);
3650 actionToggleScroll->setEnabled (false);
3651 actionOpenURL->setEnabled (false);
3652 actionOpenVymLink->setEnabled (false);
3653 actionDeleteVymLink->setEnabled (false);
3654 actionHeading2URL->setEnabled (false);
3655 actionDelete->setEnabled (false);
3656 actionMoveUp->setEnabled (false);
3657 actionMoveDown->setEnabled (false);
3658 actionFormatHideLinkUnselected->setEnabled (false);
3659 actionSortChildren->setEnabled (false);
3660 actionToggleHideExport->setEnabled (false);
3665 Main::ModMode Main::getModMode()
3667 if (actionModModeColor->isOn()) return ModModeColor;
3668 if (actionModModeCopy->isOn()) return ModModeCopy;
3669 if (actionModModeXLink->isOn()) return ModModeXLink;
3673 bool Main::autoEditNewBranch()
3675 return actionSettingsAutoEditNewBranch->isOn();
3678 bool Main::autoSelectNewBranch()
3680 return actionSettingsAutoSelectNewBranch->isOn();
3683 void Main::windowShowNoteEditor()
3685 textEditor->setShowWithMain(true);
3687 actionViewToggleNoteEditor->setChecked (true);
3690 void Main::windowHideNoteEditor()
3692 textEditor->setShowWithMain(false);
3694 actionViewToggleNoteEditor->setChecked (false);
3697 void Main::setScript (const QString &script)
3699 scriptEditor->setScript (script);
3702 void Main::runScript (const QString &script)
3704 VymModel *m=currentModel();
3705 if (m) m->runScript (script);
3708 void Main::runScriptEverywhere (const QString &script)
3711 for (int i=0;i<=tabWidget->count() -1;i++)
3713 me=(MapEditor*)tabWidget->page(i);
3714 if (me) me->getModel()->runScript (script);
3718 void Main::windowNextEditor()
3720 if (tabWidget->currentIndex() < tabWidget->count())
3721 tabWidget->setCurrentIndex (tabWidget->currentIndex() +1);
3724 void Main::windowPreviousEditor()
3726 if (tabWidget->currentIndex() >0)
3727 tabWidget->setCurrentIndex (tabWidget->currentIndex() -1);
3730 void Main::standardFlagChanged()
3734 if ( actionSettingsUseFlagGroups->isOn() )
3735 currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster);
3737 currentModel()->toggleStandardFlag(sender()->name());
3742 void Main::testFunction1()
3745 QProgressDialog p ("testprogress","cancel",0,max,this);
3746 p.setWindowModality (Qt::WindowModal);
3747 p.setAutoReset (false);
3748 p.setAutoClose (false);
3750 for (int i=0;i<max;i++)
3753 if (p.wasCanceled()) break;
3756 cout << "Doing it again...\n";
3763 for (int i=0;i<max;i++)
3766 if (p.wasCanceled()) break;
3772 if (!currentMapEditor()) return;
3773 currentMapEditor()->testFunction1();
3776 VymModel *m=currentModel();
3780 QString text = QInputDialog::getText(
3781 "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet
3782 m->getSortFilter(), &ok, NULL);
3784 // user entered something and pressed OK
3785 m->setSortFilter (text);
3789 void Main::testFunction2()
3791 if (!currentMapEditor()) return;
3792 currentMapEditor()->testFunction2();
3795 void Main::testCommand()
3797 if (!currentMapEditor()) return;
3798 scriptEditor->show();
3801 QString com = QInputDialog::getText(
3802 vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this );
3803 if (ok) currentMapEditor()->parseAtom(com);
3807 void Main::helpDoc()
3809 QString locale = QLocale::system().name();
3811 if (locale.left(2)=="es")
3812 docname="vym_es.pdf";
3816 QStringList searchList;
3818 #if defined(Q_OS_MACX)
3819 searchList << "./vym.app/Contents/Resources/doc";
3820 #elif defined(Q_OS_WIN32)
3821 searchList << vymInstallDir.path() + "/share/doc/packages/vym";
3823 #if defined(VYM_DOCDIR)
3824 searchList << VYM_DOCDIR;
3826 // default path in SUSE LINUX
3827 searchList << "/usr/share/doc/packages/vym";
3830 searchList << "doc"; // relative path for easy testing in tarball
3831 searchList << "doc/tex"; // Easy testing working on vym.tex
3832 searchList << "/usr/share/doc/vym"; // Debian
3833 searchList << "/usr/share/doc/packages";// Knoppix
3837 for (int i=0; i<searchList.count(); ++i)
3839 docfile.setFileName(searchList.at(i)+"/"+docname);
3840 if (docfile.exists())
3849 QMessageBox::critical(0,
3850 tr("Critcal error"),
3851 tr("Couldn't find the documentation %1 in:\n%2").arg(searchList.join("\n")));
3856 Process *pdfProc = new Process();
3857 args << QDir::toNativeSeparators(docfile.fileName());
3859 if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) )
3862 QMessageBox::warning(0,
3864 tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+
3865 tr("Please use Settings->")+tr("Set application to open PDF files"));
3872 void Main::helpDemo()
3874 QStringList filters;
3875 filters <<"VYM example map (*.vym)";
3876 QFileDialog *fd=new QFileDialog( this);
3877 #if defined(Q_OS_MACX)
3878 fd->setDir (QDir("./vym.app/Contents/Resources/demos"));
3880 // default path in SUSE LINUX
3881 fd->setDir (QDir(vymBaseDir.path()+"/demos"));
3884 fd->setFileMode (QFileDialog::ExistingFiles);
3885 fd->setFilters (filters);
3886 fd->setCaption(vymName+ " - " +tr("Load vym example map"));
3890 if ( fd->exec() == QDialog::Accepted )
3892 lastFileDir=fd->directory().path();
3893 QStringList flist = fd->selectedFiles();
3894 QStringList::Iterator it = flist.begin();
3895 while( it != flist.end() )
3898 fileLoad(*it, NewMap);
3906 void Main::helpAbout()
3909 ad.setName ("aboutwindow");
3910 ad.setMinimumSize(500,500);
3911 ad.resize (QSize (500,500));
3915 void Main::helpAboutQT()
3917 QMessageBox::aboutQt( this, "Qt Application Example" );
3920 void Main::callMacro ()
3922 QAction *action = qobject_cast<QAction *>(sender());
3926 i=action->data().toInt();
3927 QString mDir (settings.value ("macros/macroDir").toString() );
3929 QString fn=mDir + QString("/macro-%1.vys").arg(i+1);
3931 if ( !f.open( QIODevice::ReadOnly ) )
3933 QMessageBox::warning(0,
3935 tr("Couldn't find a macro at %1.\n").arg(fn)+
3936 tr("Please use Settings->")+tr("Set directory for vym macros"));
3940 QTextStream ts( &f );
3941 QString macro= ts.read();
3943 if (! macro.isEmpty())
3945 VymModel *m=currentModel();
3946 if (m) m->runScript(macro);