insilmaril@0: #include "mainwindow.h" insilmaril@0: insilmaril@366: #include insilmaril@390: insilmaril@0: #include insilmaril@611: #include insilmaril@0: insilmaril@205: #include "aboutdialog.h" insilmaril@421: #include "branchpropwindow.h" insilmaril@749: #include "branchitem.h" insilmaril@205: #include "exportoofiledialog.h" insilmaril@228: #include "exports.h" insilmaril@205: #include "file.h" insilmaril@767: #include "flagrow.h" insilmaril@377: #include "historywindow.h" insilmaril@205: #include "imports.h" insilmaril@0: #include "mapeditor.h" insilmaril@205: #include "misc.h" insilmaril@205: #include "options.h" insilmaril@0: #include "process.h" insilmaril@0: #include "settings.h" insilmaril@205: #include "texteditor.h" insilmaril@442: #include "warningdialog.h" insilmaril@0: insilmaril@608: #if defined(Q_OS_WIN32) insilmaril@608: // Define only this structure as opposed to insilmaril@608: // including full 'windows.h'. FindWindow insilmaril@608: // clashes with the one in Win32 API. insilmaril@608: typedef struct _PROCESS_INFORMATION insilmaril@608: { insilmaril@608: long hProcess; insilmaril@608: long hThread; insilmaril@608: long dwProcessId; insilmaril@608: long dwThreadId; insilmaril@608: } PROCESS_INFORMATION, *LPPROCESS_INFORMATION; insilmaril@608: #endif insilmaril@608: insilmaril@0: extern TextEditor *textEditor; insilmaril@0: extern Main *mainWindow; insilmaril@164: extern QString tmpVymDir; insilmaril@166: extern QString clipboardDir; insilmaril@491: extern QString clipboardFile; insilmaril@166: extern bool clipboardEmpty; insilmaril@0: extern int statusbarTime; insilmaril@767: extern FlagRow *standardFlagsMaster; insilmaril@767: extern FlagRow *systemFlagsMaster; insilmaril@404: extern QString vymName; insilmaril@404: extern QString vymVersion; insilmaril@404: extern QString vymBuildDate; insilmaril@502: extern bool debug; insilmaril@0: insilmaril@390: QMenu* branchContextMenu; insilmaril@390: QMenu* branchAddContextMenu; insilmaril@390: QMenu* branchRemoveContextMenu; insilmaril@390: QMenu* branchLinksContextMenu; insilmaril@390: QMenu* branchXLinksContextMenuEdit; insilmaril@390: QMenu* branchXLinksContextMenuFollow; insilmaril@390: QMenu* floatimageContextMenu; insilmaril@390: QMenu* canvasContextMenu; insilmaril@390: QMenu* fileLastMapsMenu; insilmaril@390: QMenu* fileImportMenu; insilmaril@390: QMenu* fileExportMenu; insilmaril@0: insilmaril@0: insilmaril@0: extern Settings settings; insilmaril@0: extern Options options; insilmaril@366: extern ImageIO imageIO; insilmaril@366: insilmaril@269: extern QDir vymBaseDir; insilmaril@366: extern QDir lastImageDir; insilmaril@366: extern QDir lastFileDir; insilmaril@625: #if defined(Q_OS_WIN32) insilmaril@625: extern QDir vymInstallDir; insilmaril@625: #endif insilmaril@269: extern QString iconPath; insilmaril@269: extern QString flagsPath; insilmaril@0: insilmaril@725: insilmaril@366: Main::Main(QWidget* parent, const char* name, Qt::WFlags f) : insilmaril@0: QMainWindow(parent,name,f) insilmaril@0: { insilmaril@0: mainWindow=this; insilmaril@0: insilmaril@0: setCaption ("VYM - View Your Mind"); insilmaril@0: insilmaril@0: // Load window settings insilmaril@625: #if defined(Q_OS_WIN32) insilmaril@625: if (settings.value("/mainwindow/geometry/maximized", false).toBool()) insilmaril@625: { anng888@632: setWindowState(Qt::WindowMaximized); insilmaril@625: } insilmaril@625: else insilmaril@625: #endif insilmaril@625: { insilmaril@625: resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize()); insilmaril@625: move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint()); insilmaril@625: } insilmaril@0: insilmaril@394: // Sometimes we may need to remember old selections insilmaril@394: prevSelection=""; insilmaril@394: insilmaril@395: // Default color insilmaril@395: currentColor=Qt::black; insilmaril@395: insilmaril@164: // Create unique temporary directory insilmaril@366: bool ok; insilmaril@608: tmpVymDir=makeTmpDir (ok,"vym"); insilmaril@366: if (!ok) insilmaril@366: { insilmaril@366: qWarning ("Mainwindow: Could not create temporary directory, failed to start vym"); insilmaril@366: exit (1); insilmaril@366: } insilmaril@502: if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) ); insilmaril@164: insilmaril@166: // Create direcctory for clipboard insilmaril@166: clipboardDir=tmpVymDir+"/clipboard"; insilmaril@502: clipboardFile="map.xml"; insilmaril@166: QDir d(clipboardDir); insilmaril@166: d.mkdir (clipboardDir,true); insilmaril@166: makeSubDirs (clipboardDir); insilmaril@166: clipboardEmpty=true; insilmaril@164: insilmaril@266: procBrowser=NULL; insilmaril@266: insilmaril@486: // Satellite windows ////////////////////////////////////////// insilmaril@486: // history window insilmaril@404: historyWindow=new HistoryWindow(); insilmaril@486: connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@486: insilmaril@486: // properties window insilmaril@421: branchPropertyWindow = new BranchPropertyWindow(); insilmaril@486: connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@486: insilmaril@486: // Connect TextEditor, so that we can update flags if text changes insilmaril@486: connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); insilmaril@486: connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@486: insilmaril@486: // Connect HistoryWindow, so that we can update flags insilmaril@486: connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@473: insilmaril@421: insilmaril@432: // Initialize script editor insilmaril@432: scriptEditor = new SimpleScriptEditor(); insilmaril@432: scriptEditor->move (50,50); insilmaril@432: insilmaril@432: connect( scriptEditor, SIGNAL( runScript ( QString ) ), insilmaril@432: this, SLOT( runScript( QString ) ) ); insilmaril@432: insilmaril@486: insilmaril@486: // Initialize Find window insilmaril@486: findWindow=new FindWindow(NULL); insilmaril@486: findWindow->move (x(),y()+70); insilmaril@486: connect (findWindow, SIGNAL( findButton(QString) ), insilmaril@486: this, SLOT(editFind(QString) ) ); insilmaril@486: connect (findWindow, SIGNAL( somethingChanged() ), insilmaril@486: this, SLOT(editFindChanged() ) ); insilmaril@486: insilmaril@0: // Initialize some settings, which are platform dependant insilmaril@0: QString p,s; insilmaril@0: insilmaril@0: // application to open URLs insilmaril@366: p="/mainwindow/readerURL"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@608: s=settings.value (p,"xdg-open").toString(); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@366: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@608: insilmaril@608: #else insilmaril@608: #if defined(Q_OS_WIN32) insilmaril@608: // Assume that system has been set up so that insilmaril@608: // Explorer automagically opens up the URL insilmaril@608: // in the user's preferred browser. insilmaril@608: s=settings.value (p,"explorer").toString(); insilmaril@608: #else insilmaril@608: s=settings.value (p,"mozilla").toString(); insilmaril@608: #endif insilmaril@0: #endif insilmaril@0: #endif insilmaril@366: settings.setValue( p,s); insilmaril@0: insilmaril@0: // application to open PDFs insilmaril@366: p="/mainwindow/readerPDF"; insilmaril@0: #if defined(Q_OS_LINUX) insilmaril@608: s=settings.value (p,"xdg-open").toString(); insilmaril@0: #else insilmaril@0: #if defined(Q_OS_MACX) insilmaril@366: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@625: #elif defined(Q_OS_WIN32) insilmaril@625: s=settings.value (p,"acrord32").toString(); insilmaril@0: #else insilmaril@366: s=settings.value (p,"acroread").toString(); insilmaril@0: #endif insilmaril@0: #endif insilmaril@366: settings.setValue( p,s); insilmaril@0: insilmaril@600: // width of xLinksMenu insilmaril@600: xLinkMenuWidth=60; insilmaril@0: insilmaril@0: // Create tab widget which holds the maps insilmaril@0: tabWidget= new QTabWidget (this); insilmaril@0: connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), insilmaril@0: this, SLOT( editorChanged( QWidget * ) ) ); insilmaril@0: insilmaril@0: setCentralWidget(tabWidget); insilmaril@0: insilmaril@0: setupFileActions(); insilmaril@0: setupEditActions(); insilmaril@0: setupFormatActions(); insilmaril@0: setupViewActions(); insilmaril@89: setupModeActions(); insilmaril@0: setupFlagActions(); insilmaril@528: setupNetworkActions(); insilmaril@0: setupSettingsActions(); insilmaril@0: setupContextMenus(); insilmaril@445: setupMacros(); insilmaril@366: if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions(); insilmaril@0: setupHelpActions(); insilmaril@0: insilmaril@742: // Status bar and progress bar there insilmaril@0: statusBar(); insilmaril@742: progressMax=0; insilmaril@742: progressBar=new QProgressBar; insilmaril@742: progressBar->hide(); insilmaril@742: statusBar()->addPermanentWidget(progressBar); insilmaril@0: insilmaril@366: restoreState (settings.value("/mainwindow/state",0).toByteArray()); insilmaril@0: insilmaril@0: updateGeometry(); insilmaril@0: } insilmaril@0: insilmaril@0: Main::~Main() insilmaril@0: { insilmaril@0: // Save Settings insilmaril@625: #if defined(Q_OS_WIN32) insilmaril@625: settings.setValue ("/mainwindow/geometry/maximized", isMaximized()); insilmaril@625: #endif insilmaril@625: settings.setValue ("/mainwindow/geometry/size", size()); insilmaril@625: settings.setValue ("/mainwindow/geometry/pos", pos()); insilmaril@366: settings.setValue ("/mainwindow/state",saveState(0)); insilmaril@366: insilmaril@408: settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn()); insilmaril@408: settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn()); insilmaril@404: settings.setValue( "/version/version", vymVersion ); insilmaril@404: settings.setValue( "/version/builddate", vymBuildDate ); insilmaril@366: insilmaril@742: settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() ); insilmaril@537: settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() ); insilmaril@625: settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() ); insilmaril@390: settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() ); insilmaril@537: settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() ); insilmaril@366: settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() ); insilmaril@366: settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); insilmaril@366: settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() ); insilmaril@0: insilmaril@473: //TODO save scriptEditor settings insilmaril@432: insilmaril@404: // call the destructors insilmaril@442: delete textEditor; insilmaril@404: delete historyWindow; insilmaril@473: delete branchPropertyWindow; insilmaril@742: delete progressBar; insilmaril@164: insilmaril@164: // Remove temporary directory insilmaril@164: removeDir (QDir(tmpVymDir)); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::loadCmdLine() insilmaril@0: { insilmaril@0: /* TODO draw some kind of splashscreen while loading... insilmaril@0: if (qApp->argc()>1) insilmaril@0: { insilmaril@0: } insilmaril@0: */ insilmaril@0: insilmaril@0: QStringList flist=options.getFileList(); insilmaril@0: QStringList::Iterator it=flist.begin(); insilmaril@0: insilmaril@0: while (it !=flist.end() ) insilmaril@0: { insilmaril@0: fileLoad (*it, NewMap); insilmaril@0: *it++; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::statusMessage(const QString &s) insilmaril@0: { insilmaril@742: // Surpress messages while progressbar during insilmaril@742: // load is active insilmaril@742: if (progressMin==progressMax) insilmaril@742: statusBar()->message( s); insilmaril@742: } insilmaril@742: insilmaril@742: void Main::setProgressMinimum (int min) insilmaril@742: { insilmaril@742: progressBar->setMinimum(min); insilmaril@742: progressMin=min; insilmaril@742: } insilmaril@742: insilmaril@742: void Main::setProgressMaximum (int max) insilmaril@742: { insilmaril@742: progressBar->setMaximum(max); insilmaril@742: progressMax=max; insilmaril@742: if (max>0) insilmaril@742: { insilmaril@742: statusBar()->addPermanentWidget(progressBar); insilmaril@742: progressBar->show(); insilmaril@742: } insilmaril@742: } insilmaril@742: insilmaril@742: void Main::setProgressValue (int v) insilmaril@742: { insilmaril@742: progressBar->setValue (v); insilmaril@742: } insilmaril@742: insilmaril@742: void Main::removeProgressBar() insilmaril@742: { insilmaril@742: if (progressMax>0) insilmaril@742: statusBar()->removeWidget(progressBar); insilmaril@742: progressMax=progressMin=0; insilmaril@0: } insilmaril@0: insilmaril@0: void Main::closeEvent (QCloseEvent* ) insilmaril@0: { insilmaril@0: fileExitVYM(); insilmaril@0: } insilmaril@0: insilmaril@0: // File Actions insilmaril@0: void Main::setupFileActions() insilmaril@0: { insilmaril@366: QMenu *fileMenu = menuBar()->addMenu ( tr ("&Map") ); insilmaril@366: QToolBar *tb = addToolBar( tr ("&Map") ); insilmaril@366: tb->setObjectName ("mapTB"); insilmaril@0: insilmaril@0: QAction *a; insilmaril@491: a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this); insilmaril@395: a->setStatusTip ( tr( "New map","Status tip File menu" ) ); insilmaril@442: a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map insilmaril@0: a->addTo( tb ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) ); insilmaril@0: insilmaril@494: a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this); insilmaril@491: a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) ); insilmaril@491: a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map insilmaril@491: fileMenu->addAction (a); insilmaril@491: connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) ); insilmaril@689: actionFileNewCopy=a; insilmaril@491: insilmaril@395: a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this); insilmaril@395: a->setStatusTip (tr( "Open","Status tip File menu" ) ); insilmaril@442: a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map insilmaril@0: a->addTo( tb ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) ); insilmaril@0: insilmaril@395: fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu")); insilmaril@366: fileMenu->addSeparator(); insilmaril@0: insilmaril@395: a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this); insilmaril@395: a->setStatusTip ( tr( "Save","Status tip file menu" )); insilmaril@442: a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map insilmaril@0: a->addTo( tb ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) ); insilmaril@0: actionFileSave=a; insilmaril@0: insilmaril@395: a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this); insilmaril@395: a->setStatusTip (tr( "Save &As","Status tip file menu" ) ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) ); insilmaril@366: insilmaril@366: fileMenu->addSeparator(); insilmaril@366: insilmaril@395: fileImportMenu = fileMenu->addMenu (tr("Import","File menu")); insilmaril@366: insilmaril@742: a = new QAction(tr("KDE 3 Bookmarks"), this); insilmaril@742: a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks"))); insilmaril@366: a->addTo (fileImportMenu); insilmaril@742: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) ); insilmaril@742: insilmaril@742: a = new QAction(tr("KDE 4 Bookmarks"), this); insilmaril@742: a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks"))); insilmaril@742: a->addTo (fileImportMenu); insilmaril@742: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) ); insilmaril@366: insilmaril@366: if (settings.value( "/mainwindow/showTestMenu",false).toBool()) insilmaril@331: { insilmaril@395: a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this); insilmaril@395: a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) )); insilmaril@366: a->addTo (fileImportMenu); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) ); insilmaril@331: } insilmaril@314: insilmaril@571: a = new QAction("Freemind...",this); insilmaril@571: a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") ); insilmaril@571: fileImportMenu->addAction (a); insilmaril@571: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) ); insilmaril@571: insilmaril@366: a = new QAction("Mind Manager...",this); insilmaril@395: a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") ); insilmaril@366: fileImportMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) ); insilmaril@366: insilmaril@395: a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this); insilmaril@395: a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) ); insilmaril@366: fileImportMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) ); insilmaril@366: insilmaril@395: fileExportMenu = fileMenu->addMenu (tr("Export","File menu")); insilmaril@395: insilmaril@395: a = new QAction( tr("Image%1","File export menu").arg("..."), this); insilmaril@395: a->setStatusTip( tr( "Export map as image","status tip file menu" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@395: a = new QAction( "Open Office...", this); insilmaril@395: a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: a = new QAction( "Webpage (XHTML)...",this ); insilmaril@442: a->setShortcut (Qt::ALT + Qt::Key_X); //Export XHTML insilmaril@395: a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu"))); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: a = new QAction( "Text (ASCII)...", this); insilmaril@395: a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" ))); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@497: a = new QAction( "Spreadsheet (CSV)...", this); insilmaril@497: a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" ))); insilmaril@497: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) ); insilmaril@497: fileExportMenu->addAction (a); insilmaril@497: insilmaril@742: a = new QAction( tr("KDE 3 Bookmarks","File menu"), this); insilmaril@742: a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" ))); insilmaril@742: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) ); insilmaril@742: fileExportMenu->addAction (a); insilmaril@742: insilmaril@742: a = new QAction( tr("KDE 4 Bookmarks","File menu"), this); insilmaril@742: a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" ))); insilmaril@742: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: a = new QAction( "Taskjuggler...", this ); insilmaril@395: a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" ))); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: a = new QAction( "LaTeX...", this); insilmaril@395: a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" ))); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: a = new QAction( "XML..." , this ); insilmaril@395: a->setStatusTip (tr( "Export as %1").arg("XML")); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) ); insilmaril@366: fileExportMenu->addAction (a); insilmaril@366: insilmaril@366: fileMenu->addSeparator(); insilmaril@366: insilmaril@366: a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this); insilmaril@395: a->setStatusTip ( tr( "Print" ,"File menu") ); insilmaril@442: a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map insilmaril@0: a->addTo( tb ); insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) ); insilmaril@0: actionFilePrint=a; insilmaril@0: insilmaril@395: a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this); insilmaril@366: a->setStatusTip (tr( "Close Map" ) ); insilmaril@473: a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) ); insilmaril@366: insilmaril@404: a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this); insilmaril@404: a->setStatusTip ( tr( "Exit")+" "+vymName ); insilmaril@442: a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym insilmaril@366: fileMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( fileExitVYM() ) ); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: //Edit Actions insilmaril@0: void Main::setupEditActions() insilmaril@0: { insilmaril@395: QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") ); insilmaril@0: tb->setLabel( "Edit Actions" ); insilmaril@366: tb->setObjectName ("actionsTB"); insilmaril@395: QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") ); insilmaril@0: insilmaril@0: QAction *a; insilmaril@102: QAction *alt; insilmaril@395: a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) ); insilmaril@366: a->setStatusTip (tr( "Undo" ) ); insilmaril@442: a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@723: actionUndo=a; insilmaril@163: insilmaril@395: a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Redo" )); insilmaril@442: a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); insilmaril@723: actionRedo=a; insilmaril@163: insilmaril@366: editMenu->addSeparator(); insilmaril@395: a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Copy" ) ); insilmaril@442: a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) ); insilmaril@723: actionCopy=a; insilmaril@366: insilmaril@395: a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Cut" ) ); insilmaril@442: a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@723: actionCut=a; insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) ); insilmaril@366: insilmaril@395: a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) ); insilmaril@366: a->setStatusTip ( tr( "Paste" ) ); insilmaril@442: a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@723: actionPaste=a; insilmaril@98: insilmaril@351: // Shortcut to delete selection insilmaril@395: a = new QAction( tr( "Delete Selection","Edit menu" ),this); insilmaril@366: a->setStatusTip (tr( "Delete Selection" )); insilmaril@442: a->setShortcut ( Qt::Key_Delete); //Delete selection insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) ); insilmaril@723: actionDelete=a; insilmaril@351: insilmaril@684: // Shortcut to add mapcenter insilmaril@753: a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this); insilmaril@753: a->setShortcut ( Qt::Key_M); insilmaril@753: a->setShortcutContext (Qt::WindowShortcut); insilmaril@684: connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) ); insilmaril@753: //actionListBranches.append(a); insilmaril@753: tb->addAction (a); insilmaril@723: actionAddMapCenter = a; insilmaril@684: insilmaril@684: insilmaril@351: // Shortcut to add branch insilmaril@395: alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this); insilmaril@366: alt->setStatusTip ( tr( "Add a branch as child of selection" )); insilmaril@442: alt->setShortcut (Qt::Key_A); //Add branch insilmaril@366: alt->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (alt); insilmaril@366: connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); insilmaril@395: a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch as child of selection" )); insilmaril@442: a->setShortcut (Qt::Key_Insert); //Add branch insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@351: #if defined (Q_OS_MACX) insilmaril@366: // In OSX show different shortcut in menues, the keys work indepently always insilmaril@723: actionAddBranch=alt; insilmaril@351: #else insilmaril@723: actionAddBranch=a; insilmaril@351: #endif insilmaril@723: editMenu->addAction (actionAddBranch); insilmaril@723: tb->addAction (actionAddBranch); insilmaril@366: insilmaril@351: insilmaril@351: // Add branch by inserting it at selection insilmaril@395: a = new QAction(tr( "Add branch (insert)","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); insilmaril@442: a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@394: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) ); insilmaril@351: a->setEnabled (false); insilmaril@351: actionListBranches.append(a); insilmaril@723: actionAddBranchBefore=a; insilmaril@395: a = new QAction(tr( "Add branch (insert)","Edit menu" ),this); insilmaril@366: a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); insilmaril@442: a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@394: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@351: insilmaril@351: // Add branch above insilmaril@395: a = new QAction(tr( "Add branch above","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch above selection" )); insilmaril@442: a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@351: a->setEnabled (false); insilmaril@351: actionListBranches.append(a); insilmaril@723: actionAddBranchAbove=a; insilmaril@395: a = new QAction(tr( "Add branch above","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch above selection" )); insilmaril@442: a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@351: insilmaril@351: // Add branch below insilmaril@395: a = new QAction(tr( "Add branch below","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch below selection" )); insilmaril@442: a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@351: a->setEnabled (false); insilmaril@351: actionListBranches.append(a); insilmaril@723: actionAddBranchBelow=a; insilmaril@395: a = new QAction(tr( "Add branch below","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Add a branch below selection" )); insilmaril@442: a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@351: actionListBranches.append(a); insilmaril@351: insilmaril@395: a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Move branch up" ) ); insilmaril@442: a->setShortcut (Qt::Key_PageUp ); // Move branch up insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) ); insilmaril@723: actionMoveUp=a; insilmaril@98: insilmaril@395: a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) ); insilmaril@366: a->setStatusTip (tr( "Move branch down" ) ); insilmaril@442: a->setShortcut ( Qt::Key_PageDown ); // Move branch down insilmaril@0: a->setEnabled (false); insilmaril@366: tb->addAction (a); insilmaril@366: editMenu->addAction (a); insilmaril@723: actionMoveDown=a; insilmaril@98: insilmaril@608: a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this ); insilmaril@608: connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) ); insilmaril@608: a->setEnabled (true); insilmaril@608: a->addTo( tb ); insilmaril@613: editMenu->addAction (a); insilmaril@723: actionSortChildren=a; insilmaril@0: insilmaril@395: alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this); insilmaril@442: alt->setShortcut ( Qt::Key_S ); // Scroll branch insilmaril@366: alt->setStatusTip (tr( "Scroll branch" )); insilmaril@366: connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); insilmaril@102: #if defined(Q_OS_MACX) insilmaril@723: actionToggleScroll=alt; insilmaril@102: #else insilmaril@723: actionToggleScroll=a; insilmaril@102: #endif insilmaril@723: actionToggleScroll->setEnabled (false); insilmaril@723: actionToggleScroll->setToggleAction(true); insilmaril@723: tb->addAction (actionToggleScroll); insilmaril@723: editMenu->addAction ( actionToggleScroll); insilmaril@723: editMenu->addAction (actionToggleScroll); insilmaril@375: addAction (a); insilmaril@375: addAction (alt); insilmaril@723: actionListBranches.append(actionToggleScroll); insilmaril@0: insilmaril@763: a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this); insilmaril@763: a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches insilmaril@763: a->setStatusTip (tr( "Expand all branches" )); insilmaril@763: connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) ); insilmaril@763: actionExpandAll=a; insilmaril@763: actionExpandAll->setEnabled (false); insilmaril@763: actionExpandAll->setToggleAction(false); insilmaril@763: //tb->addAction (actionExpandAll); insilmaril@763: editMenu->addAction ( actionExpandAll); insilmaril@763: addAction (a); insilmaril@763: actionListBranches.append(actionExpandAll); insilmaril@763: insilmaril@763: insilmaril@721: a = new QAction( tr( "Unscroll children","Edit menu" ), this); insilmaril@473: a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" )); insilmaril@366: editMenu->addAction (a); insilmaril@721: connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) ); insilmaril@0: insilmaril@366: editMenu->addSeparator(); insilmaril@366: insilmaril@395: a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this); insilmaril@366: a->setStatusTip (tr( "Find" ) ); insilmaril@442: a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find insilmaril@366: editMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWindow() ) ); insilmaril@0: insilmaril@366: editMenu->addSeparator(); insilmaril@366: insilmaril@395: a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_U ); insilmaril@366: a->setShortcut (tr( "Open URL" )); insilmaril@366: tb->addAction (a); insilmaril@366: addAction(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) ); insilmaril@723: actionOpenURL=a; insilmaril@0: insilmaril@395: a = new QAction( tr( "Open URL in new tab","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Open URL in new tab" )); insilmaril@528: //a->setShortcut (Qt::CTRL+Qt::Key_U ); insilmaril@366: addAction(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) ); insilmaril@723: actionOpenURLTab=a; insilmaril@266: insilmaril@395: a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Open all URLs in subtree" )); insilmaril@366: addAction(a); insilmaril@366: actionListBranches.append(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) ); insilmaril@723: actionOpenMultipleURLTabs=a; insilmaril@366: insilmaril@395: a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this); insilmaril@366: a->setStatusTip ( tr( "Edit URL" ) ); insilmaril@528: a->setShortcut ( Qt::Key_U ); insilmaril@366: a->setShortcutContext (Qt::WindowShortcut); insilmaril@366: actionListBranches.append(a); insilmaril@366: addAction(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) ); insilmaril@723: actionURL=a; insilmaril@366: insilmaril@528: a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this); insilmaril@528: a->setStatusTip ( tr( "Edit local URL" ) ); insilmaril@528: a->setShortcut (Qt::SHIFT + Qt::Key_U ); insilmaril@528: a->setShortcutContext (Qt::WindowShortcut); insilmaril@528: actionListBranches.append(a); insilmaril@528: addAction(a); insilmaril@528: connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) ); insilmaril@723: actionLocalURL=a; insilmaril@528: insilmaril@395: a = new QAction( tr( "Use heading for URL","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Use heading of selected branch as URL" )); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) ); insilmaril@723: actionHeading2URL=a; insilmaril@366: insilmaril@486: a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this); insilmaril@486: a->setStatusTip ( tr( "Create URL to Novell Bugzilla" )); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) ); insilmaril@723: actionBugzilla2URL=a; insilmaril@0: insilmaril@486: a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this); insilmaril@486: a->setStatusTip ( tr( "Create URL to Novell FATE" )); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) ); insilmaril@723: actionFATE2URL=a; insilmaril@366: insilmaril@395: a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" )); insilmaril@366: tb->addAction (a); insilmaril@366: a->setEnabled (false); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) ); insilmaril@723: actionOpenVymLink=a; insilmaril@366: insilmaril@395: a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Open all vym links in subtree" )); insilmaril@175: a->setEnabled (false); insilmaril@175: actionListBranches.append(a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) ); insilmaril@723: actionOpenMultipleVymLinks=a; insilmaril@0: insilmaril@366: insilmaril@395: a = new QAction(tr( "Edit vym link...","Edit menu" ), this); insilmaril@0: a->setEnabled (false); insilmaril@366: a->setStatusTip ( tr( "Edit link to another vym map" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) ); insilmaril@98: actionListBranches.append(a); insilmaril@723: actionVymLink=a; insilmaril@0: insilmaril@395: a = new QAction(tr( "Delete vym link","Edit menu" ),this); insilmaril@366: a->setStatusTip ( tr( "Delete link to another vym map" )); insilmaril@0: a->setEnabled (false); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) ); insilmaril@723: actionDeleteVymLink=a; insilmaril@0: insilmaril@395: a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Hide object in exports" ) ); insilmaril@366: a->setShortcut (Qt::Key_H ); insilmaril@243: a->setToggleAction(true); insilmaril@366: tb->addAction (a); insilmaril@243: a->setEnabled (false); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) ); insilmaril@723: actionToggleHideExport=a; insilmaril@243: insilmaril@395: a = new QAction(tr( "Edit Map Info...","Edit menu" ),this); insilmaril@366: a->setStatusTip ( tr( "Edit Map Info" )); insilmaril@0: a->setEnabled (true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) ); insilmaril@723: actionMapInfo=a; insilmaril@0: insilmaril@0: // Import at selection (adding to selection) insilmaril@395: a = new QAction( tr( "Add map (insert)","Edit menu" ),this); insilmaril@366: a->setStatusTip (tr( "Add map at selection" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@723: actionImportAdd=a; insilmaril@0: insilmaril@0: // Import at selection (replacing selection) insilmaril@395: a = new QAction( tr( "Add map (replace)","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Replace selection with map" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@723: actionImportReplace=a; insilmaril@0: insilmaril@0: // Save selection insilmaril@395: a = new QAction( tr( "Save selection","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Save selection" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@723: actionSaveBranch=a; insilmaril@0: insilmaril@721: // Only remove branch, not its children insilmaril@395: a = new QAction(tr( "Remove only branch ","Edit menu" ), this); insilmaril@721: a->setStatusTip ( tr( "Remove only branch and keep its children" )); insilmaril@366: a->setShortcut (Qt::ALT + Qt::Key_Delete ); insilmaril@721: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) ); insilmaril@98: a->setEnabled (false); insilmaril@375: addAction (a); insilmaril@98: actionListBranches.append(a); insilmaril@723: actionDeleteKeepChildren=a; insilmaril@721: insilmaril@721: // Only remove children of a branch insilmaril@721: a = new QAction( tr( "Remove children","Edit menu" ), this); insilmaril@721: a->setStatusTip (tr( "Remove children of branch" )); insilmaril@366: a->setShortcut (Qt::SHIFT + Qt::Key_Delete ); insilmaril@721: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) ); insilmaril@98: a->setEnabled (false); insilmaril@98: actionListBranches.append(a); insilmaril@723: actionDeleteChildren=a; insilmaril@98: insilmaril@395: a = new QAction( tr( "Add Image...","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Add Image" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); insilmaril@723: actionLoadImage=a; insilmaril@89: insilmaril@473: a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this); insilmaril@442: a->setStatusTip (tr( "Set properties for selection" )); insilmaril@442: a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window insilmaril@442: a->setShortcutContext (Qt::WindowShortcut); insilmaril@486: a->setToggleAction (true); insilmaril@442: addAction (a); insilmaril@473: connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) ); insilmaril@486: actionViewTogglePropertyWindow=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Format Actions insilmaril@0: void Main::setupFormatActions() insilmaril@0: { insilmaril@395: QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu")); insilmaril@395: insilmaril@395: QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name")); insilmaril@366: tb->setObjectName ("formatTB"); insilmaril@0: QAction *a; insilmaril@0: QPixmap pix( 16,16); insilmaril@366: pix.fill (Qt::black); insilmaril@366: a= new QAction(pix, tr( "Set &Color" )+QString("..."), this); insilmaril@366: a->setStatusTip ( tr( "Set Color" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) ); insilmaril@366: a->addTo( tb ); insilmaril@366: formatMenu->addAction (a); insilmaril@366: actionFormatColor=a; insilmaril@395: a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this); insilmaril@366: a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) ); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_K ); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@366: formatMenu->addAction (a); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionFormatPickColor=a; insilmaril@366: insilmaril@417: a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Color branch" ) ); insilmaril@442: a->setShortcut (Qt::CTRL + Qt::Key_B); insilmaril@417: connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) ); insilmaril@0: a->setEnabled (false); insilmaril@0: a->addTo( tb ); insilmaril@366: formatMenu->addAction (a); insilmaril@98: actionListBranches.append(a); insilmaril@417: actionFormatColorSubtree=a; insilmaril@417: insilmaril@417: a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this); insilmaril@366: a->setStatusTip ( tr( "Color Subtree" )); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_T); insilmaril@417: connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) ); insilmaril@0: a->setEnabled (false); insilmaril@366: formatMenu->addAction (a); insilmaril@0: a->addTo( tb ); insilmaril@98: actionListBranches.append(a); insilmaril@0: actionFormatColorSubtree=a; insilmaril@0: insilmaril@366: formatMenu->addSeparator(); insilmaril@366: actionGroupFormatLinkStyles=new QActionGroup ( this); insilmaril@0: actionGroupFormatLinkStyles->setExclusive (true); insilmaril@366: a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles); insilmaril@366: a->setStatusTip (tr( "Line" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) ); insilmaril@366: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStyleLine=a; insilmaril@505: a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles); insilmaril@366: a->setStatusTip (tr( "Line" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) ); insilmaril@366: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStyleParabel=a; insilmaril@366: a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles ); insilmaril@366: a->setStatusTip (tr( "PolyLine" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) ); insilmaril@366: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStylePolyLine=a; insilmaril@505: a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles); insilmaril@366: a->setStatusTip (tr( "PolyParabel" ) ); insilmaril@0: a->setToggleAction(true); insilmaril@366: a->setChecked (true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) ); insilmaril@366: formatMenu->addAction (a); insilmaril@0: actionFormatLinkStylePolyParabel=a; insilmaril@0: insilmaril@395: a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this); insilmaril@366: a->setStatusTip (tr( "Hide link" )); insilmaril@160: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) ); insilmaril@160: actionFormatHideLinkUnselected=a; insilmaril@160: insilmaril@366: formatMenu->addSeparator(); insilmaril@395: a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this); insilmaril@366: a->setStatusTip (tr( "Use same color for links and headings" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) ); insilmaril@366: formatMenu->addAction (a); insilmaril@0: actionFormatLinkColorHint=a; insilmaril@366: insilmaril@366: pix.fill (Qt::white); insilmaril@366: a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this ); insilmaril@366: a->setStatusTip (tr( "Set Link Color" )); insilmaril@366: formatMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) ); insilmaril@366: actionFormatLinkColor=a; insilmaril@366: insilmaril@442: a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this ); insilmaril@442: a->setStatusTip (tr( "Set Selection Color" )); insilmaril@442: formatMenu->addAction (a); insilmaril@442: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) ); insilmaril@442: actionFormatSelectionColor=a; insilmaril@442: insilmaril@366: a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this ); insilmaril@366: a->setStatusTip (tr( "Set Background Color" )); insilmaril@366: formatMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) ); insilmaril@366: actionFormatBackColor=a; insilmaril@408: insilmaril@408: a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this ); insilmaril@408: a->setStatusTip (tr( "Set Background image" )); insilmaril@408: formatMenu->addAction (a); insilmaril@408: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) ); insilmaril@408: actionFormatBackImage=a; insilmaril@0: } insilmaril@0: insilmaril@0: // View Actions insilmaril@0: void Main::setupViewActions() insilmaril@0: { insilmaril@395: QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") ); insilmaril@0: tb->setLabel( "View Actions" ); insilmaril@366: tb->setObjectName ("viewTB"); insilmaril@366: QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@395: a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this); insilmaril@366: a->setStatusTip ( tr( "Zoom reset" ) ); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_0 ); insilmaril@0: a->addTo( tb ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) ); insilmaril@366: insilmaril@395: a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this); insilmaril@366: a->setStatusTip (tr( "Zoom in" )); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_Plus); insilmaril@0: a->addTo( tb ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) ); insilmaril@366: insilmaril@395: a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this); insilmaril@366: a->setStatusTip (tr( "Zoom out" )); insilmaril@366: a->setShortcut (Qt::CTRL + Qt::Key_Minus ); insilmaril@0: a->addTo( tb ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) ); insilmaril@366: insilmaril@526: a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this); insilmaril@526: a->setStatusTip (tr( "Show selection" )); insilmaril@526: a->setShortcut (Qt::Key_Period); insilmaril@526: a->addTo( tb ); insilmaril@526: viewMenu->addAction (a); insilmaril@526: connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) ); insilmaril@526: insilmaril@486: viewMenu->addSeparator(); insilmaril@366: insilmaril@395: a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this); insilmaril@366: a->setStatusTip ( tr( "Show Note Editor" )); insilmaril@366: a->setShortcut ( Qt::CTRL + Qt::Key_E ); insilmaril@0: a->setToggleAction(true); insilmaril@0: a->addTo( tb ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) ); insilmaril@0: actionViewToggleNoteEditor=a; insilmaril@294: insilmaril@442: a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this ); insilmaril@442: a->setStatusTip ( tr( "Show History Window" )); insilmaril@366: a->setShortcut ( Qt::CTRL + Qt::Key_H ); insilmaril@407: a->setToggleAction(true); insilmaril@404: a->addTo( tb ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); insilmaril@294: actionViewToggleHistoryWindow=a; insilmaril@294: insilmaril@486: viewMenu->addAction (actionViewTogglePropertyWindow); insilmaril@486: insilmaril@486: viewMenu->addSeparator(); insilmaril@442: insilmaril@408: a = new QAction(tr( "Antialiasing","View action" ),this ); insilmaril@408: a->setStatusTip ( tr( "Antialiasing" )); insilmaril@408: a->setToggleAction(true); insilmaril@408: a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool()); insilmaril@408: viewMenu->addAction (a); insilmaril@408: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) ); insilmaril@408: actionViewToggleAntiAlias=a; insilmaril@408: insilmaril@408: a = new QAction(tr( "Smooth pixmap transformations","View action" ),this ); insilmaril@408: a->setStatusTip (a->text()); insilmaril@408: a->setToggleAction(true); insilmaril@408: a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool()); insilmaril@408: viewMenu->addAction (a); insilmaril@408: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) ); insilmaril@408: actionViewToggleSmoothPixmapTransform=a; insilmaril@408: insilmaril@473: a = new QAction(tr( "Next Map","View action" ), this); insilmaril@408: a->setStatusTip (a->text()); insilmaril@366: a->setShortcut (Qt::ALT + Qt::Key_N ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) ); insilmaril@366: insilmaril@473: a = new QAction (tr( "Previous Map","View action" ), this ); insilmaril@408: a->setStatusTip (a->text()); insilmaril@366: a->setShortcut (Qt::ALT + Qt::Key_P ); insilmaril@366: viewMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) ); insilmaril@0: } insilmaril@0: insilmaril@89: // Mode Actions insilmaril@89: void Main::setupModeActions() insilmaril@89: { insilmaril@89: //QPopupMenu *menu = new QPopupMenu( this ); insilmaril@89: //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu ); insilmaril@89: insilmaril@395: QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") ); insilmaril@366: tb->setObjectName ("modesTB"); insilmaril@89: QAction *a; insilmaril@366: actionGroupModModes=new QActionGroup ( this); insilmaril@89: actionGroupModModes->setExclusive (true); insilmaril@395: a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes); insilmaril@366: a->setShortcut (Qt::Key_J); insilmaril@366: a->setStatusTip ( tr( "Use modifier to color branches" )); insilmaril@89: a->setToggleAction(true); insilmaril@89: a->addTo (tb); insilmaril@89: a->setOn(true); insilmaril@89: actionModModeColor=a; insilmaril@104: insilmaril@395: a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes ); insilmaril@366: a->setShortcut( Qt::Key_K); insilmaril@366: a->setStatusTip( tr( "Use modifier to copy" )); insilmaril@104: a->setToggleAction(true); insilmaril@104: a->addTo (tb); insilmaril@104: actionModModeCopy=a; insilmaril@104: insilmaril@395: a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes ); insilmaril@366: a->setShortcut (Qt::Key_L); insilmaril@366: a->setStatusTip( tr( "Use modifier to draw xLinks" )); insilmaril@89: a->setToggleAction(true); insilmaril@89: a->addTo (tb); insilmaril@390: actionModModeXLink=a; insilmaril@89: } insilmaril@89: insilmaril@0: // Flag Actions insilmaril@0: void Main::setupFlagActions() insilmaril@0: { insilmaril@166: // Create System Flags insilmaril@582: QToolBar *tb=NULL; insilmaril@767: insilmaril@767: Flag *flag=new Flag;; insilmaril@772: flag->setVisible(true); insilmaril@767: insilmaril@767: flag->load(QPixmap(flagsPath+"flag-note.png")); insilmaril@767: setupFlag (flag,tb,"system-note",tr("Note","SystemFlag")); insilmaril@767: insilmaril@767: flag->load(QPixmap(flagsPath+"flag-url.png")); insilmaril@767: setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag")); insilmaril@166: insilmaril@767: flag->load(QPixmap(flagsPath+"flag-vymlink.png")); insilmaril@767: setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag")); insilmaril@767: insilmaril@767: flag->load(QPixmap(flagsPath+"flag-scrolled-right.png")); insilmaril@767: setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag")); insilmaril@166: insilmaril@767: flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png")); insilmaril@775: setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag")); insilmaril@767: insilmaril@767: flag->load(QPixmap(flagsPath+"flag-hideexport.png")); insilmaril@767: setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag")); insilmaril@243: insilmaril@166: // Create Standard Flags insilmaril@582: tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar")); insilmaril@366: tb->setObjectName ("standardFlagTB"); insilmaril@770: standardFlagsMaster->setToolBar (tb); insilmaril@166: insilmaril@767: flag->load(flagsPath+"flag-exclamationmark.png"); insilmaril@767: flag->setGroup("standard-mark"); insilmaril@767: setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-questionmark.png"); insilmaril@767: flag->setGroup("standard-mark"); insilmaril@767: setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-hook-green.png"); insilmaril@767: flag->setGroup("standard-hook"); insilmaril@767: setupFlag (flag,tb,"hook-green",tr("ok!","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-cross-red.png"); insilmaril@767: flag->setGroup("standard-hook"); insilmaril@767: setupFlag (flag,tb,"cross-red",tr("Not ok!","Standardflag")); insilmaril@767: flag->unsetGroup(); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-stopsign.png"); insilmaril@767: setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-smiley-good.png"); insilmaril@767: flag->setGroup("standard-smiley"); insilmaril@767: setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-smiley-sad.png"); insilmaril@767: flag->setGroup("standard-smiley"); insilmaril@767: setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-smiley-omg.png"); insilmaril@767: flag->setGroup("standard-smiley"); insilmaril@767: setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag")); insilmaril@269: // Original omg.png (in KDE emoticons) insilmaril@767: flag->unsetGroup(); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-kalarm.png"); insilmaril@767: setupFlag (flag,tb,"clock",tr("Time critical","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-phone.png"); insilmaril@767: setupFlag (flag,tb,"phone",tr("Call...","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-lamp.png"); insilmaril@767: setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-arrow-up.png"); insilmaril@767: flag->setGroup("standard-arrow"); insilmaril@767: setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-arrow-down.png"); insilmaril@767: flag->setGroup("standard-arrow"); insilmaril@767: setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-arrow-2up.png"); insilmaril@767: flag->setGroup("standard-arrow"); insilmaril@767: setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-arrow-2down.png"); insilmaril@767: flag->setGroup("standard-arrow"); insilmaril@767: setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag")); insilmaril@767: flag->unsetGroup(); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-thumb-up.png"); insilmaril@767: flag->setGroup("standard-thumb"); insilmaril@767: setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-thumb-down.png"); insilmaril@767: flag->setGroup("standard-thumb"); insilmaril@767: setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag")); insilmaril@767: flag->unsetGroup(); insilmaril@166: insilmaril@767: flag->load(flagsPath+"flag-rose.png"); insilmaril@767: setupFlag (flag,tb,"rose",tr("Rose","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-heart.png"); insilmaril@767: setupFlag (flag,tb,"heart",tr("I just love...","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-present.png"); insilmaril@767: setupFlag (flag,tb,"present",tr("Surprise!","Standardflag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"flag-flash.png"); insilmaril@767: setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag")); insilmaril@564: insilmaril@564: // Original: xsldbg_output.png insilmaril@767: flag->load(flagsPath+"flag-info.png"); insilmaril@767: setupFlag (flag,tb,"inflag",tr("Info","Standardflag")); insilmaril@564: insilmaril@564: // Original khelpcenter.png insilmaril@767: flag->load(flagsPath+"flag-lifebelt.png"); insilmaril@767: setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag")); insilmaril@564: insilmaril@564: // Freemind flags insilmaril@772: flag->setVisible(false); insilmaril@767: flag->load(flagsPath+"freemind/warning.png"); insilmaril@767: setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag")); insilmaril@564: insilmaril@564: for (int i=1; i<8; i++) insilmaril@564: { insilmaril@767: flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i)); insilmaril@767: setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag")); insilmaril@564: } insilmaril@564: insilmaril@767: flag->load(flagsPath+"freemind/back.png"); insilmaril@767: setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/forward.png"); insilmaril@767: setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/attach.png"); insilmaril@767: setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/clanbomber.png"); insilmaril@767: setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/desktopnew.png"); insilmaril@767: setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/flag.png"); insilmaril@767: setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag")); insilmaril@767: insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/gohome.png"); insilmaril@767: setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag")); insilmaril@767: insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/kaddressbook.png"); insilmaril@767: setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/knotify.png"); insilmaril@767: setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/korn.png"); insilmaril@767: setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/mail.png"); insilmaril@767: setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/password.png"); insilmaril@767: setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/pencil.png"); insilmaril@767: setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/stop.png"); insilmaril@767: setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/wizard.png"); insilmaril@767: setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/xmag.png"); insilmaril@767: setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/bell.png"); insilmaril@767: setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/bookmark.png"); insilmaril@767: setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/penguin.png"); insilmaril@767: setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag")); insilmaril@767: insilmaril@767: flag->load(flagsPath+"freemind/licq.png"); insilmaril@767: setupFlag (flag,tb,"freemind-licq",tr("Sweet","Freemind-Flag")); insilmaril@564: } insilmaril@564: insilmaril@767: void Main::setupFlag (Flag *flag, QToolBar *tb, const QString &name, const QString &tooltip) insilmaril@564: { insilmaril@767: flag->setName(name); insilmaril@767: flag->setToolTip (tooltip); insilmaril@767: QAction *a; insilmaril@582: if (tb) insilmaril@582: { insilmaril@767: a=new QAction (flag->getPixmap(),name,this); insilmaril@582: // StandardFlag insilmaril@582: tb->addAction (a); insilmaril@770: flag->setAction (a); insilmaril@772: a->setVisible (flag->isVisible()); insilmaril@582: a->setCheckable(true); insilmaril@767: a->setObjectName(name); insilmaril@582: a->setToolTip(tooltip); insilmaril@582: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@767: standardFlagsMaster->addFlag (flag); insilmaril@582: } else insilmaril@582: { insilmaril@582: // SystemFlag insilmaril@767: systemFlagsMaster->addFlag (flag); insilmaril@582: } insilmaril@0: } insilmaril@767: insilmaril@528: // Network Actions insilmaril@528: void Main::setupNetworkActions() insilmaril@528: { insilmaril@528: if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@528: return; insilmaril@635: QMenu *netMenu = menuBar()->addMenu( "Network" ); insilmaril@528: insilmaril@528: QAction *a; insilmaril@528: insilmaril@528: a = new QAction( "Start TCPserver for MapEditor",this); insilmaril@528: //a->setStatusTip ( "Set application to open pdf files")); insilmaril@528: a->setShortcut ( Qt::Key_T ); //New TCP server insilmaril@528: connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) ); insilmaril@528: netMenu->addAction (a); insilmaril@528: insilmaril@528: a = new QAction( "Connect MapEditor to server",this); insilmaril@528: //a->setStatusTip ( "Set application to open pdf files")); insilmaril@528: a->setShortcut ( Qt::Key_C ); // Connect to server insilmaril@528: connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) ); insilmaril@528: netMenu->addAction (a); insilmaril@528: } insilmaril@528: insilmaril@0: // Settings Actions insilmaril@0: void Main::setupSettingsActions() insilmaril@0: { insilmaril@366: QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@0: insilmaril@395: a = new QAction( tr( "Set application to open pdf files","Settings action"), this); insilmaril@366: a->setStatusTip ( tr( "Set application to open pdf files")); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) ); insilmaril@366: settingsMenu->addAction (a); insilmaril@366: insilmaril@395: a = new QAction( tr( "Set application to open external links","Settings action"), this); insilmaril@366: a->setStatusTip( tr( "Set application to open external links")); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) ); insilmaril@366: settingsMenu->addAction (a); insilmaril@366: insilmaril@473: a = new QAction( tr( "Set path for macros","Settings action")+"...", this); insilmaril@450: a->setStatusTip( tr( "Set path for macros")); insilmaril@450: connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) ); insilmaril@450: settingsMenu->addAction (a); insilmaril@450: insilmaril@473: a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this); insilmaril@473: a->setStatusTip( tr( "Set number of undo levels")); insilmaril@473: connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) ); insilmaril@473: settingsMenu->addAction (a); insilmaril@473: insilmaril@366: settingsMenu->addSeparator(); insilmaril@473: insilmaril@473: a = new QAction( tr( "Autosave","Settings action"), this); insilmaril@473: a->setStatusTip( tr( "Autosave")); insilmaril@473: a->setToggleAction(true); insilmaril@742: a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool()); insilmaril@473: connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) ); insilmaril@473: settingsMenu->addAction (a); insilmaril@473: actionSettingsAutosaveToggle=a; insilmaril@473: insilmaril@473: a = new QAction( tr( "Autosave time","Settings action")+"...", this); insilmaril@473: a->setStatusTip( tr( "Autosave time")); insilmaril@473: connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) ); insilmaril@473: settingsMenu->addAction (a); insilmaril@473: actionSettingsAutosaveTime=a; insilmaril@473: insilmaril@628: a = new QAction( tr( "Write backup file on save","Settings action"), this); insilmaril@628: a->setStatusTip( tr( "Write backup file on save")); insilmaril@625: a->setToggleAction(true); insilmaril@625: a->setOn ( settings.value ("/mainwindow/writeBackupFile",false).toBool()); insilmaril@625: connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) ); insilmaril@625: settingsMenu->addAction (a); insilmaril@625: actionSettingsWriteBackupFile=a; insilmaril@625: insilmaril@473: settingsMenu->addSeparator(); insilmaril@473: insilmaril@395: a = new QAction( tr( "Edit branch after adding it","Settings action" ), this ); insilmaril@366: a->setStatusTip( tr( "Edit branch after adding it" )); insilmaril@0: a->setToggleAction(true); insilmaril@537: a->setOn ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool()); insilmaril@366: settingsMenu->addAction (a); insilmaril@537: actionSettingsAutoEditNewBranch=a; insilmaril@0: insilmaril@395: a= new QAction( tr( "Select branch after adding it","Settings action" ), this ); insilmaril@366: a->setStatusTip( tr( "Select branch after adding it" )); insilmaril@0: a->setToggleAction(true); insilmaril@537: a->setOn ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@537: actionSettingsAutoSelectNewBranch=a; insilmaril@0: insilmaril@395: a= new QAction(tr( "Select existing heading","Settings action" ), this); insilmaril@366: a->setStatusTip( tr( "Select heading before editing" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: a->setOn ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@390: actionSettingsAutoSelectText=a; insilmaril@0: insilmaril@395: a= new QAction( tr( "Delete key","Settings action" ), this); insilmaril@366: a->setStatusTip( tr( "Delete key for deleting branches" )); insilmaril@0: a->setToggleAction(true); insilmaril@505: a->setOn ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) ); insilmaril@366: actionSettingsUseDelKey=a; insilmaril@366: insilmaril@395: a= new QAction( tr( "Exclusive flags","Settings action" ), this); insilmaril@366: a->setStatusTip( tr( "Use exclusive flags in flag toolbars" )); insilmaril@0: a->setToggleAction(true); insilmaril@366: a->setOn ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@103: actionSettingsUseFlagGroups=a; insilmaril@260: insilmaril@395: a= new QAction( tr( "Use hide flags","Settings action" ), this); insilmaril@366: a->setStatusTip( tr( "Use hide flag during exports " )); insilmaril@260: a->setToggleAction(true); insilmaril@366: a->setOn ( settings.value ("/export/useHideExport",true).toBool() ); insilmaril@366: settingsMenu->addAction (a); insilmaril@260: actionSettingsUseHideExport=a; insilmaril@689: insilmaril@689: a = new QAction( tr( "Animation","Settings action"), this); insilmaril@689: a->setStatusTip( tr( "Animation")); insilmaril@689: a->setToggleAction(true); insilmaril@689: a->setOn (settings.value("/animation/use",false).toBool() ); insilmaril@689: connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) ); insilmaril@773: settingsMenu->addAction (a); insilmaril@689: actionSettingsUseAnimation=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Test Actions insilmaril@0: void Main::setupTestActions() insilmaril@0: { insilmaril@366: QMenu *testMenu = menuBar()->addMenu( tr( "&Test" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@527: a = new QAction( "Test function 1" , this); insilmaril@527: a->setStatusTip( "Call test function 1" ); insilmaril@527: testMenu->addAction (a); insilmaril@527: connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) ); insilmaril@527: insilmaril@527: a = new QAction( "Test function 2" , this); insilmaril@527: a->setStatusTip( "Call test function 2" ); insilmaril@366: testMenu->addAction (a); insilmaril@527: connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) ); insilmaril@527: insilmaril@395: a = new QAction( "Command" , this); insilmaril@395: a->setStatusTip( "Enter command to call in editor" ); insilmaril@393: connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) ); insilmaril@393: testMenu->addAction (a); insilmaril@0: } insilmaril@0: insilmaril@0: // Help Actions insilmaril@0: void Main::setupHelpActions() insilmaril@0: { insilmaril@395: QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" )); insilmaril@0: insilmaril@0: QAction *a; insilmaril@395: a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this ); insilmaril@366: a->setStatusTip( tr( "Open VYM Documentation (pdf)" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) ); insilmaril@366: helpMenu->addAction (a); insilmaril@366: insilmaril@505: a = new QAction( tr( "Open VYM example maps ","Help action" ), this ); insilmaril@505: a->setStatusTip( tr( "Open VYM example maps " )); insilmaril@505: connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) ); insilmaril@505: helpMenu->addAction (a); insilmaril@505: insilmaril@395: a = new QAction( tr( "About VYM","Help action" ), this); insilmaril@404: a->setStatusTip( tr( "About VYM")+vymName); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) ); insilmaril@366: helpMenu->addAction (a); insilmaril@366: insilmaril@395: a = new QAction( tr( "About QT","Help action" ), this); insilmaril@366: a->setStatusTip( tr( "Information about QT toolkit" )); insilmaril@366: connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) ); insilmaril@366: helpMenu->addAction (a); insilmaril@0: } insilmaril@0: insilmaril@0: // Context Menus insilmaril@0: void Main::setupContextMenus() insilmaril@0: { insilmaril@0: QAction*a; insilmaril@0: insilmaril@0: // Context Menu for branch or mapcenter insilmaril@366: branchContextMenu =new QMenu (this); insilmaril@486: branchContextMenu->addAction (actionViewTogglePropertyWindow); insilmaril@421: branchContextMenu->addSeparator(); insilmaril@421: insilmaril@98: // Submenu "Add" insilmaril@366: branchAddContextMenu =branchContextMenu->addMenu (tr("Add")); insilmaril@723: branchAddContextMenu->addAction (actionPaste ); insilmaril@753: branchAddContextMenu->addAction ( actionAddMapCenter ); insilmaril@723: branchAddContextMenu->addAction ( actionAddBranch ); insilmaril@723: branchAddContextMenu->addAction ( actionAddBranchBefore ); insilmaril@723: branchAddContextMenu->addAction ( actionAddBranchAbove); insilmaril@723: branchAddContextMenu->addAction ( actionAddBranchBelow ); insilmaril@366: branchAddContextMenu->addSeparator(); insilmaril@723: branchAddContextMenu->addAction ( actionImportAdd ); insilmaril@723: branchAddContextMenu->addAction ( actionImportReplace ); insilmaril@98: insilmaril@98: // Submenu "Remove" insilmaril@395: branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name")); insilmaril@723: branchRemoveContextMenu->addAction (actionCut); insilmaril@723: branchRemoveContextMenu->addAction ( actionDelete ); insilmaril@723: branchRemoveContextMenu->addAction ( actionDeleteKeepChildren ); insilmaril@723: branchRemoveContextMenu->addAction ( actionDeleteChildren ); insilmaril@98: insilmaril@98: insilmaril@723: actionSaveBranch->addTo( branchContextMenu ); insilmaril@689: actionFileNewCopy->addTo (branchContextMenu ); insilmaril@98: insilmaril@366: branchContextMenu->addSeparator(); insilmaril@723: branchContextMenu->addAction ( actionLoadImage); insilmaril@366: insilmaril@366: // Submenu for Links (URLs, vymLinks) insilmaril@366: branchLinksContextMenu =new QMenu (this); insilmaril@366: insilmaril@366: branchContextMenu->addSeparator(); insilmaril@473: branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name")); insilmaril@723: branchLinksContextMenu->addAction ( actionOpenURL ); insilmaril@723: branchLinksContextMenu->addAction ( actionOpenURLTab ); insilmaril@723: branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs ); insilmaril@723: branchLinksContextMenu->addAction ( actionURL ); insilmaril@723: branchLinksContextMenu->addAction ( actionLocalURL ); insilmaril@723: branchLinksContextMenu->addAction ( actionHeading2URL ); insilmaril@723: branchLinksContextMenu->addAction ( actionBugzilla2URL ); insilmaril@528: if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@366: { insilmaril@723: branchLinksContextMenu->addAction ( actionFATE2URL ); insilmaril@366: } insilmaril@366: branchLinksContextMenu->addSeparator(); insilmaril@723: branchLinksContextMenu->addAction ( actionOpenVymLink ); insilmaril@723: branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks ); insilmaril@723: branchLinksContextMenu->addAction ( actionVymLink ); insilmaril@723: branchLinksContextMenu->addAction ( actionDeleteVymLink ); insilmaril@366: insilmaril@366: insilmaril@366: // Context Menu for XLinks in a branch menu insilmaril@89: // This will be populated "on demand" in MapEditor::updateActions insilmaril@366: branchContextMenu->addSeparator(); insilmaril@395: branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name")); insilmaril@395: branchXLinksContextMenuFollow =branchContextMenu->addMenu (tr ("Follow XLink","Context menu name")); insilmaril@366: connect( branchXLinksContextMenuFollow, SIGNAL( triggered(QAction *) ), this, SLOT( editFollowXLink(QAction * ) ) ); insilmaril@366: connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) ); insilmaril@366: insilmaril@105: insilmaril@0: // Context menu for floatimage insilmaril@366: floatimageContextMenu =new QMenu (this); insilmaril@395: a= new QAction (tr ("Save image","Context action"),this); insilmaril@366: connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage())); insilmaril@366: floatimageContextMenu->addAction (a); insilmaril@366: insilmaril@366: floatimageContextMenu->addSeparator(); insilmaril@723: actionCopy->addTo( floatimageContextMenu ); insilmaril@723: actionCut->addTo( floatimageContextMenu ); insilmaril@0: insilmaril@366: floatimageContextMenu->addSeparator(); insilmaril@366: floatimageContextMenu->addAction ( actionFormatHideLinkUnselected ); insilmaril@366: insilmaril@0: insilmaril@0: // Context menu for canvas insilmaril@366: canvasContextMenu =new QMenu (this); insilmaril@753: actionAddMapCenter->addTo( canvasContextMenu ); insilmaril@723: actionMapInfo->addTo( canvasContextMenu ); insilmaril@0: canvasContextMenu->insertSeparator(); insilmaril@0: actionGroupFormatLinkStyles->addTo( canvasContextMenu ); insilmaril@0: canvasContextMenu->insertSeparator(); insilmaril@0: actionFormatLinkColorHint->addTo( canvasContextMenu ); insilmaril@0: actionFormatLinkColor->addTo( canvasContextMenu ); insilmaril@442: actionFormatSelectionColor->addTo( canvasContextMenu ); insilmaril@0: actionFormatBackColor->addTo( canvasContextMenu ); insilmaril@746: // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version insilmaril@0: insilmaril@0: // Menu for last opened files insilmaril@401: // Create actions insilmaril@401: for (int i = 0; i < MaxRecentFiles; ++i) insilmaril@0: { insilmaril@445: recentFileActions[i] = new QAction(this); insilmaril@445: recentFileActions[i]->setVisible(false); insilmaril@445: fileLastMapsMenu->addAction(recentFileActions[i]); insilmaril@445: connect(recentFileActions[i], SIGNAL(triggered()), insilmaril@401: this, SLOT(fileLoadRecent())); insilmaril@401: } insilmaril@401: setupRecentMapsMenu(); insilmaril@0: } insilmaril@0: insilmaril@401: void Main::setupRecentMapsMenu() insilmaril@0: { insilmaril@401: QStringList files = settings.value("/mainwindow/recentFileList").toStringList(); insilmaril@401: insilmaril@401: int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); insilmaril@401: insilmaril@401: for (int i = 0; i < numRecentFiles; ++i) { insilmaril@401: QString text = tr("&%1 %2").arg(i + 1).arg(files[i]); insilmaril@445: recentFileActions[i]->setText(text); insilmaril@445: recentFileActions[i]->setData(files[i]); insilmaril@445: recentFileActions[i]->setVisible(true); insilmaril@401: } insilmaril@401: for (int j = numRecentFiles; j < MaxRecentFiles; ++j) insilmaril@445: recentFileActions[j]->setVisible(false); insilmaril@445: } insilmaril@445: insilmaril@445: void Main::setupMacros() insilmaril@445: { insilmaril@445: for (int i = 0; i <= 11; i++) insilmaril@445: { insilmaril@445: macroActions[i] = new QAction(this); insilmaril@445: macroActions[i]->setData(i); insilmaril@445: addAction (macroActions[i]); insilmaril@445: connect(macroActions[i], SIGNAL(triggered()), insilmaril@445: this, SLOT(callMacro())); insilmaril@445: } insilmaril@445: macroActions[0]->setShortcut ( Qt::Key_F1 ); insilmaril@445: macroActions[1]->setShortcut ( Qt::Key_F2 ); insilmaril@445: macroActions[2]->setShortcut ( Qt::Key_F3 ); insilmaril@445: macroActions[3]->setShortcut ( Qt::Key_F4 ); insilmaril@445: macroActions[4]->setShortcut ( Qt::Key_F5 ); insilmaril@445: macroActions[5]->setShortcut ( Qt::Key_F6 ); insilmaril@445: macroActions[6]->setShortcut ( Qt::Key_F7 ); insilmaril@445: macroActions[7]->setShortcut ( Qt::Key_F8 ); insilmaril@445: macroActions[8]->setShortcut ( Qt::Key_F9 ); insilmaril@445: macroActions[9]->setShortcut ( Qt::Key_F10 ); insilmaril@445: macroActions[10]->setShortcut ( Qt::Key_F11 ); insilmaril@445: macroActions[11]->setShortcut ( Qt::Key_F12 ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::hideEvent (QHideEvent * ) insilmaril@0: { insilmaril@0: if (!textEditor->isMinimized() ) textEditor->hide(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::showEvent (QShowEvent * ) insilmaril@0: { insilmaril@491: if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal(); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: MapEditor* Main::currentMapEditor() const insilmaril@0: { insilmaril@725: if ( tabWidget->currentPage()) insilmaril@772: return vymViews.at(tabWidget->currentIndex())->getMapEditor(); insilmaril@0: return NULL; insilmaril@0: } insilmaril@0: insilmaril@721: VymModel* Main::currentModel() const insilmaril@721: { insilmaril@725: if ( tabWidget->currentPage()) insilmaril@772: return vymViews.at(tabWidget->currentIndex())->getModel(); insilmaril@725: return NULL; insilmaril@721: } insilmaril@721: insilmaril@0: insilmaril@0: void Main::editorChanged(QWidget *) insilmaril@0: { insilmaril@0: // Unselect all possibly selected objects insilmaril@0: // (Important to update note editor) insilmaril@772: VymModel *m; insilmaril@473: for (int i=0;i<=tabWidget->count() -1;i++) insilmaril@0: { insilmaril@772: m= vymViews.at(tabWidget->currentIndex())->getModel(); insilmaril@772: if (m) m->unselect(); insilmaril@772: } insilmaril@772: m=currentModel(); insilmaril@724: if (m) m->reselect(); insilmaril@0: insilmaril@0: // Update actions to in menus and toolbars according to editor insilmaril@407: updateActions(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileNew() insilmaril@0: { insilmaril@769: VymModel *vm=new VymModel; insilmaril@769: insilmaril@769: VymView *vv=new VymView (vm); insilmaril@772: vymViews.append (vv); insilmaril@769: tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file")); insilmaril@772: tabWidget->setCurrentIndex (vymViews.count() ); insilmaril@769: vv->initFocus(); insilmaril@769: insilmaril@408: insilmaril@366: // For the very first map we do not have flagrows yet... insilmaril@769: vm->select("mc:"); insilmaril@0: } insilmaril@0: insilmaril@491: void Main::fileNewCopy() insilmaril@491: { insilmaril@491: QString fn="unnamed"; insilmaril@725: VymModel *srcModel=currentModel(); insilmaril@725: if (srcModel) insilmaril@491: { insilmaril@725: srcModel->copy(); insilmaril@725: fileNew(); insilmaril@772: VymModel *dstModel=vymViews.last()->getModel(); insilmaril@725: dstModel->select("mc:"); insilmaril@725: dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap); insilmaril@491: } insilmaril@491: } insilmaril@491: insilmaril@571: ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype) insilmaril@0: { insilmaril@205: ErrorCode err=success; insilmaril@0: insilmaril@0: // fn is usually the archive, mapfile the file after uncompressing insilmaril@0: QString mapfile; insilmaril@0: insilmaril@0: // Make fn absolute (needed for unzip) insilmaril@0: fn=QDir (fn).absPath(); insilmaril@0: insilmaril@727: VymModel *vm; insilmaril@0: insilmaril@0: if (lmode==NewMap) insilmaril@0: { insilmaril@0: // Check, if map is already loaded insilmaril@0: int i=0; insilmaril@0: while (i<=tabWidget->count() -1) insilmaril@0: { insilmaril@772: if (vymViews.at(i)->getModel()->getFilePath() == fn) insilmaril@0: { insilmaril@0: // Already there, ask for confirmation insilmaril@404: QMessageBox mb( vymName, insilmaril@159: tr("The map %1\nis already opened." insilmaril@0: "Opening the same map in multiple editors may lead \n" insilmaril@0: "to confusion when finishing working with vym." insilmaril@159: "Do you want to").arg(fn), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape, insilmaril@366: QMessageBox::NoButton); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Open anyway") ); insilmaril@0: mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@725: // end loop and load anyway insilmaril@0: i=tabWidget->count(); insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@205: return aborted; insilmaril@0: break; insilmaril@0: } insilmaril@0: } insilmaril@0: i++; insilmaril@0: } insilmaril@0: } insilmaril@725: insilmaril@725: int tabIndex=tabWidget->currentPageIndex(); insilmaril@0: insilmaril@0: // Try to load map insilmaril@0: if ( !fn.isEmpty() ) insilmaril@0: { insilmaril@727: vm = currentModel(); insilmaril@0: // Check first, if mapeditor exists insilmaril@0: // If it is not default AND we want a new map, insilmaril@0: // create a new mapeditor in a new tab insilmaril@727: if ( lmode==NewMap && (!vm || !vm->isDefault() ) ) insilmaril@0: { insilmaril@727: vm=new VymModel; insilmaril@769: VymView *vv=new VymView (vm); insilmaril@772: vymViews.append (vv); insilmaril@769: tabWidget->addTab (vv,fn); insilmaril@725: tabIndex=tabWidget->count()-1; insilmaril@0: tabWidget->setCurrentPage (tabIndex); insilmaril@769: vv->initFocus(); insilmaril@0: } insilmaril@0: insilmaril@0: // Check, if file exists (important for creating new files insilmaril@0: // from command line insilmaril@0: if (!QFile(fn).exists() ) insilmaril@0: { insilmaril@404: QMessageBox mb( vymName, insilmaril@159: tr("This map does not exist:\n %1\nDo you want to create a new one?").arg(fn), insilmaril@0: QMessageBox::Question, insilmaril@0: QMessageBox::Yes , insilmaril@0: QMessageBox::Cancel | QMessageBox::Default, insilmaril@366: QMessageBox::NoButton ); insilmaril@0: insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Create")); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // Create new map insilmaril@721: currentMapEditor()->getModel()->setFilePath(fn); insilmaril@725: tabWidget->setTabText (tabIndex, insilmaril@721: currentMapEditor()->getModel()->getFileName() ); insilmaril@0: statusBar()->message( "Created " + fn , statusbarTime ); insilmaril@205: return success; insilmaril@0: insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // don't create new map insilmaril@0: statusBar()->message( "Loading " + fn + " failed!", statusbarTime ); insilmaril@0: fileCloseMap(); insilmaril@205: return aborted; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@721: insilmaril@0: //tabWidget->currentPage() won't be NULL here, because of above... insilmaril@725: tabWidget->setCurrentIndex (tabIndex); insilmaril@746: //FIXME-3 no me anymore... me->viewport()->setFocus(); insilmaril@0: insilmaril@185: if (err!=aborted) insilmaril@185: { insilmaril@185: // Save existing filename in case we import insilmaril@727: QString fn_org=vm->getFilePath(); insilmaril@106: insilmaril@185: // Finally load map into mapEditor insilmaril@727: vm->setFilePath (fn); insilmaril@727: err=vm->load(fn,lmode,ftype); insilmaril@106: insilmaril@185: // Restore old (maybe empty) filepath, if this is an import insilmaril@185: if (lmode!=NewMap) insilmaril@727: vm->setFilePath (fn_org); insilmaril@185: } insilmaril@0: insilmaril@185: // Finally check for errors and go home insilmaril@185: if (err==aborted) insilmaril@185: { insilmaril@185: if (lmode==NewMap) fileCloseMap(); insilmaril@185: statusBar()->message( "Could not load " + fn, statusbarTime ); insilmaril@185: } else insilmaril@0: { insilmaril@0: if (lmode==NewMap) insilmaril@0: { insilmaril@727: vm->setFilePath (fn); insilmaril@727: tabWidget->setTabText (tabIndex, vm->getFileName()); insilmaril@608: if (!isInTmpDir (fn)) insilmaril@205: { insilmaril@205: // Only append to lastMaps if not loaded from a tmpDir insilmaril@205: // e.g. imported bookmarks are in a tmpDir insilmaril@727: addRecentMap(vm->getFilePath() ); insilmaril@205: } insilmaril@0: actionFilePrint->setEnabled (true); insilmaril@0: } insilmaril@0: statusBar()->message( "Loaded " + fn, statusbarTime ); insilmaril@0: } insilmaril@0: } insilmaril@205: return err; insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::fileLoad(const LoadMode &lmode) insilmaril@0: { insilmaril@377: QStringList filters; insilmaril@389: filters <<"VYM map (*.vym *.vyp)"<<"XML (*.xml)"; insilmaril@377: QFileDialog *fd=new QFileDialog( this); insilmaril@366: fd->setDir (lastFileDir); insilmaril@377: fd->setFileMode (QFileDialog::ExistingFiles); insilmaril@377: fd->setFilters (filters); insilmaril@0: switch (lmode) insilmaril@0: { insilmaril@0: case NewMap: insilmaril@404: fd->setCaption(vymName+ " - " +tr("Load vym map")); insilmaril@0: break; insilmaril@0: case ImportAdd: insilmaril@404: fd->setCaption(vymName+ " - " +tr("Import: Add vym map to selection")); insilmaril@0: break; insilmaril@0: case ImportReplace: insilmaril@404: fd->setCaption(vymName+ " - " +tr("Import: Replace selection with vym map")); insilmaril@0: break; insilmaril@0: } insilmaril@0: fd->show(); insilmaril@0: insilmaril@0: QString fn; insilmaril@0: if ( fd->exec() == QDialog::Accepted ) insilmaril@0: { insilmaril@377: lastFileDir=fd->directory().path(); insilmaril@185: QStringList flist = fd->selectedFiles(); insilmaril@185: QStringList::Iterator it = flist.begin(); insilmaril@185: while( it != flist.end() ) insilmaril@185: { insilmaril@185: fn = *it; insilmaril@185: fileLoad(*it, lmode); insilmaril@185: ++it; insilmaril@185: } insilmaril@0: } insilmaril@185: delete (fd); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileLoad() insilmaril@0: { insilmaril@0: fileLoad (NewMap); insilmaril@0: } insilmaril@0: insilmaril@401: void Main::fileLoadRecent() insilmaril@0: { insilmaril@401: QAction *action = qobject_cast(sender()); insilmaril@401: if (action) insilmaril@401: fileLoad (action->data().toString(), NewMap); insilmaril@401: } insilmaril@401: insilmaril@401: void Main::addRecentMap (const QString &fileName) insilmaril@401: { insilmaril@401: insilmaril@401: QStringList files = settings.value("/mainwindow/recentFileList").toStringList(); insilmaril@401: files.removeAll(fileName); insilmaril@401: files.prepend(fileName); insilmaril@401: while (files.size() > MaxRecentFiles) insilmaril@401: files.removeLast(); insilmaril@401: insilmaril@401: settings.setValue("/mainwindow/recentFileList", files); insilmaril@401: insilmaril@401: setupRecentMapsMenu(); insilmaril@0: } insilmaril@0: insilmaril@721: void Main::fileSave(VymModel *m, const SaveMode &savemode) insilmaril@0: { insilmaril@721: if (!m) return; insilmaril@721: insilmaril@721: if ( m->getFilePath().isEmpty() ) insilmaril@676: { insilmaril@676: // We have no filepath yet, insilmaril@676: // call fileSaveAs() now, this will call fileSave() insilmaril@676: // again. insilmaril@676: // First switch to editor insilmaril@746: //FIXME-3 needed??? tabWidget->setCurrentWidget (m->getMapEditor()); insilmaril@676: fileSaveAs(savemode); insilmaril@676: } insilmaril@676: insilmaril@721: if (m->save (savemode)==success) insilmaril@151: { insilmaril@0: statusBar()->message( insilmaril@721: tr("Saved %1").arg(m->getFilePath()), insilmaril@0: statusbarTime ); insilmaril@721: addRecentMap (m->getFilePath() ); insilmaril@151: } else insilmaril@0: statusBar()->message( insilmaril@721: tr("Couldn't save ").arg(m->getFilePath()), insilmaril@0: statusbarTime ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSave() insilmaril@0: { insilmaril@721: fileSave (currentModel(), CompleteMap); insilmaril@473: } insilmaril@473: insilmaril@721: void Main::fileSave(VymModel *m) insilmaril@473: { insilmaril@721: fileSave (m,CompleteMap); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSaveAs(const SaveMode& savemode) insilmaril@0: { insilmaril@0: QString fn; insilmaril@0: insilmaril@0: if (currentMapEditor()) insilmaril@0: { insilmaril@0: if (savemode==CompleteMap) insilmaril@366: fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this ); insilmaril@0: else insilmaril@366: fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this ); insilmaril@0: if ( !fn.isEmpty() ) insilmaril@0: { insilmaril@0: // Check for existing file insilmaril@0: if (QFile (fn).exists()) insilmaril@0: { insilmaril@404: QMessageBox mb( vymName, insilmaril@159: tr("The file %1\nexists already. Do you want to").arg(fn), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape, insilmaril@366: QMessageBox::NoButton); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Overwrite") ); insilmaril@0: mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@0: return; insilmaril@0: break; insilmaril@0: } insilmaril@0: } else insilmaril@0: { insilmaril@0: // New file, add extension to filename, if missing insilmaril@0: // This is always .vym or .vyp, depending on savemode insilmaril@0: if (savemode==CompleteMap) insilmaril@0: { insilmaril@0: if (!fn.contains (".vym") && !fn.contains (".xml")) insilmaril@0: fn +=".vym"; insilmaril@0: } else insilmaril@0: { insilmaril@0: if (!fn.contains (".vyp") && !fn.contains (".xml")) insilmaril@0: fn +=".vyp"; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: insilmaril@0: insilmaril@0: // Save now insilmaril@725: VymModel *m=currentModel(); insilmaril@725: m->setFilePath(fn); insilmaril@725: fileSave(m, savemode); insilmaril@725: insilmaril@725: // Set name of tab, assuming current tab is the one we just saved insilmaril@94: if (savemode==CompleteMap) insilmaril@725: tabWidget->setTabText (tabWidget->currentIndex(), m->getFileName() ); insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileSaveAs() insilmaril@0: { insilmaril@0: fileSaveAs (CompleteMap); insilmaril@0: } insilmaril@0: insilmaril@742: void Main::fileImportKDE3Bookmarks() insilmaril@205: { insilmaril@742: ImportKDE3Bookmarks im; insilmaril@205: im.transform(); insilmaril@742: if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) insilmaril@742: currentMapEditor()->getModel()->setFilePath (""); insilmaril@742: } insilmaril@742: insilmaril@742: void Main::fileImportKDE4Bookmarks() insilmaril@742: { insilmaril@742: ImportKDE4Bookmarks im; insilmaril@742: im.transform(); insilmaril@742: if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() ) insilmaril@721: currentMapEditor()->getModel()->setFilePath (""); insilmaril@205: } insilmaril@205: insilmaril@314: void Main::fileImportFirefoxBookmarks() insilmaril@314: { insilmaril@366: Q3FileDialog *fd=new Q3FileDialog( this); insilmaril@327: fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox"); insilmaril@366: fd->setMode (Q3FileDialog::ExistingFiles); insilmaril@327: fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)"); insilmaril@327: fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks")); insilmaril@327: fd->show(); insilmaril@327: insilmaril@327: if ( fd->exec() == QDialog::Accepted ) insilmaril@327: { insilmaril@327: ImportFirefoxBookmarks im; insilmaril@327: QStringList flist = fd->selectedFiles(); insilmaril@327: QStringList::Iterator it = flist.begin(); insilmaril@327: while( it != flist.end() ) insilmaril@327: { insilmaril@327: im.setFile (*it); insilmaril@327: if (im.transform() && insilmaril@742: aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && insilmaril@327: currentMapEditor() ) insilmaril@721: currentMapEditor()->getModel()->setFilePath (""); insilmaril@327: ++it; insilmaril@327: } insilmaril@327: } insilmaril@327: delete (fd); insilmaril@314: } insilmaril@314: insilmaril@571: void Main::fileImportFreemind() insilmaril@571: { insilmaril@571: QStringList filters; insilmaril@571: filters <<"Freemind map (*.mm)"<<"All files (*)"; insilmaril@571: QFileDialog *fd=new QFileDialog( this); insilmaril@571: fd->setDir (lastFileDir); insilmaril@571: fd->setFileMode (QFileDialog::ExistingFiles); insilmaril@571: fd->setFilters (filters); insilmaril@571: fd->setCaption(vymName+ " - " +tr("Load Freemind map")); insilmaril@571: fd->show(); insilmaril@571: insilmaril@571: QString fn; insilmaril@571: if ( fd->exec() == QDialog::Accepted ) insilmaril@571: { insilmaril@571: lastFileDir=fd->directory().path(); insilmaril@571: QStringList flist = fd->selectedFiles(); insilmaril@571: QStringList::Iterator it = flist.begin(); insilmaril@571: while( it != flist.end() ) insilmaril@571: { insilmaril@571: fn = *it; insilmaril@571: if ( fileLoad (fn,NewMap, FreemindMap) ) insilmaril@571: { insilmaril@721: currentMapEditor()->getModel()->setFilePath (""); insilmaril@571: } insilmaril@571: ++it; insilmaril@571: } insilmaril@571: } insilmaril@571: delete (fd); insilmaril@571: } insilmaril@571: insilmaril@571: insilmaril@215: void Main::fileImportMM() insilmaril@215: { insilmaril@215: ImportMM im; insilmaril@215: insilmaril@366: Q3FileDialog *fd=new Q3FileDialog( this); insilmaril@366: fd->setDir (lastFileDir); insilmaril@366: fd->setMode (Q3FileDialog::ExistingFiles); insilmaril@215: fd->addFilter ("Mind Manager (*.mmap)"); insilmaril@215: fd->setCaption(tr("Import")+" "+"Mind Manager"); insilmaril@215: fd->show(); insilmaril@215: insilmaril@215: if ( fd->exec() == QDialog::Accepted ) insilmaril@215: { insilmaril@215: lastFileDir=fd->dirPath(); insilmaril@215: QStringList flist = fd->selectedFiles(); insilmaril@215: QStringList::Iterator it = flist.begin(); insilmaril@215: while( it != flist.end() ) insilmaril@215: { insilmaril@215: im.setFile (*it); insilmaril@215: if (im.transform() && insilmaril@215: success==fileLoad (im.getTransformedFile(),NewMap) && insilmaril@215: currentMapEditor() ) insilmaril@721: currentMapEditor()->getModel()->setFilePath (""); insilmaril@215: ++it; insilmaril@215: } insilmaril@215: } insilmaril@215: delete (fd); insilmaril@215: } insilmaril@215: insilmaril@215: void Main::fileImportDir() insilmaril@215: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->importDir(); insilmaril@215: } insilmaril@215: insilmaril@526: void Main::fileExportXML() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->exportXML(); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@517: void Main::fileExportXHTML() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->exportXHTML(); insilmaril@0: } insilmaril@0: insilmaril@517: void Main::fileExportImage() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->exportImage(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileExportASCII() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->exportASCII(); insilmaril@0: } insilmaril@0: insilmaril@756: void Main::fileExportCSV() //FIXME-3 not scriptable yet insilmaril@497: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@497: { insilmaril@497: ExportCSV ex; insilmaril@721: ex.setModel (m); insilmaril@497: ex.addFilter ("CSV (*.csv)"); insilmaril@497: ex.setDir(lastImageDir); insilmaril@497: ex.setCaption(vymName+ " -" +tr("Export as CSV")+" "+tr("(still experimental)")); insilmaril@497: if (ex.execDialog() ) insilmaril@497: { insilmaril@721: m->setExportMode(true); insilmaril@497: ex.doExport(); insilmaril@721: m->setExportMode(false); insilmaril@497: } insilmaril@497: } insilmaril@497: } insilmaril@497: insilmaril@756: void Main::fileExportLaTeX() //FIXME-3 not scriptable yet insilmaril@163: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@228: { insilmaril@228: ExportLaTeX ex; insilmaril@721: ex.setModel (m); insilmaril@228: ex.addFilter ("Tex (*.tex)"); insilmaril@424: ex.setDir(lastImageDir); insilmaril@404: ex.setCaption(vymName+ " -" +tr("Export as LaTeX")+" "+tr("(still experimental)")); insilmaril@260: if (ex.execDialog() ) insilmaril@260: { insilmaril@721: m->setExportMode(true); insilmaril@260: ex.doExport(); insilmaril@721: m->setExportMode(false); insilmaril@260: } insilmaril@228: } insilmaril@228: } insilmaril@228: insilmaril@756: void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet insilmaril@243: { insilmaril@742: ExportKDE3Bookmarks ex; insilmaril@742: VymModel *m=currentModel(); insilmaril@742: if (m) insilmaril@742: { insilmaril@742: ex.setModel (m); insilmaril@742: ex.doExport(); insilmaril@742: } insilmaril@742: } insilmaril@742: insilmaril@756: void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet insilmaril@742: { insilmaril@742: ExportKDE4Bookmarks ex; insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@243: { insilmaril@721: ex.setModel (m); insilmaril@243: ex.doExport(); insilmaril@243: } insilmaril@243: } insilmaril@243: insilmaril@756: void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet insilmaril@228: { insilmaril@228: ExportTaskjuggler ex; insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@228: { insilmaril@721: ex.setModel (m); insilmaril@404: ex.setCaption ( vymName+" - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)")); insilmaril@424: ex.setDir(lastImageDir); insilmaril@243: ex.addFilter ("Taskjuggler (*.tjp)"); insilmaril@260: if (ex.execDialog() ) insilmaril@260: { insilmaril@721: m->setExportMode(true); insilmaril@260: ex.doExport(); insilmaril@721: m->setExportMode(false); insilmaril@260: } insilmaril@228: } insilmaril@163: } insilmaril@163: insilmaril@756: void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet insilmaril@163: { insilmaril@404: ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office"); insilmaril@366: // TODO add preview in dialog insilmaril@185: //ImagePreview *p =new ImagePreview (fd); insilmaril@185: //fd->setContentsPreviewEnabled( TRUE ); insilmaril@185: //fd->setContentsPreview( p, p ); insilmaril@185: //fd->setPreviewMode( QFileDialog::Contents ); insilmaril@404: fd->setCaption(vymName+" - " +tr("Export to")+" Open Office"); insilmaril@366: fd->setDir (QDir().current()); insilmaril@357: if (fd->foundConfig()) insilmaril@357: { insilmaril@357: fd->show(); insilmaril@185: insilmaril@357: if ( fd->exec() == QDialog::Accepted ) insilmaril@357: { insilmaril@357: QString fn=fd->selectedFile(); insilmaril@366: if (!fn.contains (".odp")) insilmaril@366: fn +=".odp"; insilmaril@366: insilmaril@357: //lastImageDir=fn.left(fn.findRev ("/")); insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->exportOOPresentation(fn,fd->selectedConfig()); insilmaril@357: } insilmaril@357: } else insilmaril@185: { insilmaril@357: QMessageBox::warning(0, insilmaril@366: tr("Warning"), insilmaril@366: tr("Couldn't find configuration for export to Open Office\n")); insilmaril@185: } insilmaril@163: } insilmaril@163: insilmaril@772: void Main::fileCloseMap() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@0: { insilmaril@721: if (m->hasChanged()) insilmaril@0: { insilmaril@404: QMessageBox mb( vymName, insilmaril@772: tr("The map %1 has been modified but not saved yet. Do you want to").arg(m->getFileName()), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::No, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape ); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Save modified map before closing it") ); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("Discard changes")); insilmaril@0: switch( mb.exec() ) insilmaril@0: { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save and close insilmaril@721: fileSave(m, CompleteMap); insilmaril@0: break; insilmaril@0: case QMessageBox::No: insilmaril@0: // close without saving insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // do nothing insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@772: // And here comes the segfault, because removeTab triggers insilmaril@772: // currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet... insilmaril@772: vymViews.removeAt (tabWidget->currentIndex() ); insilmaril@725: tabWidget->removeTab (tabWidget->currentIndex() ); insilmaril@742: insilmaril@772: // Remove mapEditor/model FIXME-5 insilmaril@742: // Better would be delete (me), but then we could have a Qt error: insilmaril@742: // "QObject: Do not delete object, 'MapEditor', during its event handler!" insilmaril@742: // So we only remove data now and call deconstructor when vym closes later insilmaril@772: // this needs to be moved to vymview... me->clear(); insilmaril@742: // some model->clear is needed to free up memory ... insilmaril@742: insilmaril@724: updateActions(); insilmaril@625: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::filePrint() insilmaril@0: { insilmaril@0: if (currentMapEditor()) insilmaril@0: currentMapEditor()->print(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileExitVYM() insilmaril@0: { insilmaril@0: // Check if one or more editors have changed insilmaril@0: int i; insilmaril@772: for (i=0;i<=vymViews.count() -1;i++) insilmaril@0: { insilmaril@0: // If something changed, ask what to do insilmaril@772: if (vymViews.at(i)->getModel()->hasChanged()) insilmaril@0: { insilmaril@0: tabWidget->setCurrentPage(i); insilmaril@404: QMessageBox mb( vymName, insilmaril@0: tr("This map is not saved yet. Do you want to"), insilmaril@0: QMessageBox::Warning, insilmaril@0: QMessageBox::Yes | QMessageBox::Default, insilmaril@0: QMessageBox::No, insilmaril@0: QMessageBox::Cancel | QMessageBox::Escape ); insilmaril@0: mb.setButtonText( QMessageBox::Yes, tr("Save map") ); insilmaril@0: mb.setButtonText( QMessageBox::No, tr("Discard changes") ); insilmaril@366: mb.setModal (true); insilmaril@0: mb.show(); insilmaril@0: mb.setActiveWindow(); insilmaril@0: switch( mb.exec() ) { insilmaril@0: case QMessageBox::Yes: insilmaril@0: // save (the changed editors) and exit insilmaril@721: fileSave(currentModel(), CompleteMap); insilmaril@0: break; insilmaril@0: case QMessageBox::No: insilmaril@0: // exit without saving insilmaril@0: break; insilmaril@0: case QMessageBox::Cancel: insilmaril@0: // don't save and don't exit insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: } // loop over all MEs insilmaril@0: qApp->quit(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editUndo() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->undo(); insilmaril@0: } insilmaril@0: insilmaril@163: void Main::editRedo() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->redo(); insilmaril@0: } insilmaril@0: insilmaril@404: void Main::gotoHistoryStep (int i) insilmaril@404: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->gotoHistoryStep(i); insilmaril@404: } insilmaril@404: insilmaril@0: void Main::editCopy() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->copy(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editPaste() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->paste(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editCut() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->cut(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editOpenFindWindow() insilmaril@0: { insilmaril@0: findWindow->popup(); insilmaril@0: findWindow->raise(); insilmaril@0: findWindow->setActiveWindow(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editFind(QString s) insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@0: { insilmaril@721: bool cs=false; insilmaril@753: BranchItem *bi=m->findText(s, cs); insilmaril@753: if (bi) insilmaril@721: { insilmaril@753: statusBar()->message( "Found: " + bi->getHeading(), statusbarTime ); insilmaril@721: } else insilmaril@721: { insilmaril@721: QMessageBox::information( findWindow, tr( "VYM -Information:" ), insilmaril@721: tr("No matches found for \"%1\"").arg(s)); insilmaril@721: } insilmaril@721: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editFindChanged() insilmaril@0: { // Notify editor, to abort the current find process insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->findReset(); insilmaril@0: } insilmaril@0: insilmaril@366: void Main::openTabs(QStringList urls) insilmaril@366: { insilmaril@366: if (!urls.isEmpty()) insilmaril@366: { insilmaril@366: bool success=true; insilmaril@366: QStringList args; insilmaril@366: QString browser=settings.value("/mainwindow/readerURL" ).toString(); insilmaril@366: QProcess *p; insilmaril@366: if (!procBrowser || procBrowser->state()!=QProcess::Running) insilmaril@366: { insilmaril@366: QString u=urls.takeFirst(); insilmaril@366: procBrowser = new QProcess( this ); insilmaril@366: args<start(browser,args); insilmaril@366: if ( !procBrowser->waitForStarted()) insilmaril@366: { insilmaril@366: // try to set path to browser insilmaril@366: QMessageBox::warning(0, insilmaril@366: tr("Warning"), insilmaril@366: tr("Couldn't find a viewer to open %1.\n").arg(u)+ insilmaril@366: tr("Please use Settings->")+tr("Set application to open an URL")); insilmaril@366: return; insilmaril@366: } insilmaril@608: #if defined(Q_OS_WIN32) insilmaril@608: // There's no sleep in VCEE, replace it with Qt's QThread::wait(). insilmaril@608: this->thread()->wait(3000); insilmaril@608: #else insilmaril@366: sleep (3); insilmaril@608: #endif insilmaril@366: } insilmaril@366: if (browser.contains("konqueror")) insilmaril@366: { insilmaril@366: for (int i=0; ipid()->dwProcessId)<< insilmaril@608: "konqueror-mainwindow#1"<< insilmaril@608: "newTab" << insilmaril@366: urls.at(i); insilmaril@608: #else insilmaril@608: args<< QString("konqueror-%1").arg(procBrowser->pid())<< insilmaril@608: "konqueror-mainwindow#1"<< insilmaril@608: "newTab" << insilmaril@608: urls.at(i); insilmaril@608: #endif insilmaril@366: p->start ("dcop",args); insilmaril@748: if (debug) cout << "MainWindo::openURLs args="<waitForStarted() ) success=false; insilmaril@366: } insilmaril@366: if (!success) insilmaril@366: QMessageBox::warning(0, insilmaril@366: tr("Warning"), insilmaril@366: tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror")); insilmaril@366: return; insilmaril@366: } else if (browser.contains ("firefox") || browser.contains ("mozilla") ) insilmaril@366: { insilmaril@366: for (int i=0; istart (browser,args); insilmaril@366: if ( !p->waitForStarted() ) success=false; insilmaril@366: } insilmaril@366: if (!success) insilmaril@366: QMessageBox::warning(0, insilmaril@366: tr("Warning"), insilmaril@366: tr("Couldn't start %1 to open a new tab").arg(browser)); insilmaril@366: return; insilmaril@366: } insilmaril@366: QMessageBox::warning(0, insilmaril@366: tr("Warning"), insilmaril@366: tr("Sorry, currently only Konqueror and Mozilla support tabbed browsing.")); insilmaril@366: } insilmaril@366: } insilmaril@366: insilmaril@0: void Main::editOpenURL() insilmaril@0: { insilmaril@266: // Open new browser insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@266: { insilmaril@721: QString url=m->getURL(); insilmaril@366: QStringList args; insilmaril@266: if (url=="") return; insilmaril@366: QString browser=settings.value("/mainwindow/readerURL" ).toString(); insilmaril@266: procBrowser = new QProcess( this ); insilmaril@366: args<start(browser,args); insilmaril@366: if ( !procBrowser->waitForStarted()) insilmaril@266: { insilmaril@266: // try to set path to browser insilmaril@266: QMessageBox::warning(0, insilmaril@266: tr("Warning"), insilmaril@266: tr("Couldn't find a viewer to open %1.\n").arg(url)+ insilmaril@266: tr("Please use Settings->")+tr("Set application to open an URL")); insilmaril@266: settingsURL() ; insilmaril@266: } insilmaril@266: } insilmaril@266: } insilmaril@266: void Main::editOpenURLTab() insilmaril@266: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@266: { insilmaril@366: QStringList urls; insilmaril@721: urls.append(m->getURL()); insilmaril@366: openTabs (urls); insilmaril@266: } insilmaril@0: } insilmaril@366: void Main::editOpenMultipleURLTabs() insilmaril@366: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@366: { insilmaril@366: QStringList urls; insilmaril@721: urls=m->getURLs(); insilmaril@366: openTabs (urls); insilmaril@366: } insilmaril@366: } insilmaril@366: insilmaril@0: insilmaril@0: void Main::editURL() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->editURL(); insilmaril@0: } insilmaril@0: insilmaril@528: void Main::editLocalURL() insilmaril@528: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->editLocalURL(); insilmaril@528: } insilmaril@528: insilmaril@0: void Main::editHeading2URL() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->editHeading2URL(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editBugzilla2URL() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->editBugzilla2URL(); insilmaril@0: } insilmaril@0: insilmaril@175: void Main::editFATE2URL() insilmaril@175: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->editFATE2URL(); insilmaril@175: } insilmaril@175: insilmaril@721: void Main::editHeadingFinished(VymModel *m) insilmaril@394: { insilmaril@721: if (m) insilmaril@721: { insilmaril@721: if (!actionSettingsAutoSelectNewBranch->isOn() && insilmaril@721: !prevSelection.isEmpty()) insilmaril@721: m->select(prevSelection); insilmaril@721: prevSelection=""; insilmaril@721: } insilmaril@394: } insilmaril@394: insilmaril@366: void Main::openVymLinks(const QStringList &vl) insilmaril@366: { insilmaril@366: for (int j=0; jgetModel()->getFilePath() ) insilmaril@0: { insilmaril@0: index=i; insilmaril@0: break; insilmaril@0: } insilmaril@0: } insilmaril@0: if (index<0) insilmaril@0: // Load map insilmaril@0: { insilmaril@366: if (!QFile(vl.at(j)).exists() ) insilmaril@0: QMessageBox::critical( 0, tr( "Critical Error" ), insilmaril@366: tr("Couldn't open map %1").arg(vl.at(j))); insilmaril@0: else insilmaril@0: { insilmaril@366: fileLoad (vl.at(j), NewMap); insilmaril@725: tabWidget->setCurrentIndex (tabWidget->count()-1); insilmaril@0: } insilmaril@0: } else insilmaril@0: // Go to tab containing the map insilmaril@725: tabWidget->setCurrentIndex (index); insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@366: void Main::editOpenVymLink() insilmaril@366: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@366: { insilmaril@366: QStringList vl; insilmaril@721: vl.append(m->getVymLink()); insilmaril@366: openVymLinks (vl); insilmaril@366: } insilmaril@366: } insilmaril@366: insilmaril@366: void Main::editOpenMultipleVymLinks() insilmaril@366: { insilmaril@366: QString currentVymLink; insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@366: { insilmaril@721: QStringList vl=m->getVymLinks(); insilmaril@366: openVymLinks (vl); insilmaril@366: } insilmaril@366: } insilmaril@366: insilmaril@0: void Main::editVymLink() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@721: m->editVymLink(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editDeleteVymLink() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->deleteVymLink(); insilmaril@0: } insilmaril@0: insilmaril@243: void Main::editToggleHideExport() insilmaril@243: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->toggleHideExport(); insilmaril@243: } insilmaril@243: insilmaril@0: void Main::editMapInfo() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: insilmaril@721: ExtraInfoDialog dia; insilmaril@721: dia.setMapName (m->getFileName() ); insilmaril@721: dia.setAuthor (m->getAuthor() ); insilmaril@721: dia.setComment(m->getComment() ); insilmaril@721: insilmaril@721: // Calc some stats insilmaril@721: QString stats; insilmaril@746: /* FIXME-2 no stats at the moment (view dependent...) insilmaril@721: stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6); insilmaril@721: insilmaril@721: uint b=0; insilmaril@721: uint f=0; insilmaril@721: uint n=0; insilmaril@721: uint xl=0; insilmaril@721: BranchObj *bo; insilmaril@721: bo=m->first(); insilmaril@721: while (bo) insilmaril@721: { insilmaril@721: if (!bo->getNote().isEmpty() ) n++; insilmaril@721: f+= bo->countFloatImages(); insilmaril@721: b++; insilmaril@721: xl+=bo->countXLinks(); insilmaril@721: bo=m->next(bo); insilmaril@721: } insilmaril@721: stats+=QString ("%1 xLinks \n").arg (xl,6); insilmaril@721: stats+=QString ("%1 notes\n").arg (n,6); insilmaril@721: stats+=QString ("%1 images\n").arg (f,6); insilmaril@742: */ insilmaril@749: stats+=QString ("%1 branches\n").arg (m->branchCount(),6); insilmaril@721: dia.setStats (stats); insilmaril@721: insilmaril@721: // Finally show dialog insilmaril@721: if (dia.exec() == QDialog::Accepted) insilmaril@721: { insilmaril@721: m->setAuthor (dia.getAuthor() ); insilmaril@721: m->setComment (dia.getComment() ); insilmaril@721: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editMoveUp() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@767: if (m) m->moveUp(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editMoveDown() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@767: if (m) m->moveDown(); insilmaril@0: } insilmaril@0: insilmaril@608: void Main::editSortChildren() insilmaril@608: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->sortChildren(); insilmaril@608: } insilmaril@608: insilmaril@0: void Main::editToggleScroll() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->toggleScroll(); insilmaril@721: } insilmaril@721: insilmaril@763: void Main::editExpandAll() insilmaril@763: { insilmaril@763: VymModel *m=currentModel(); insilmaril@763: if (m) m->emitExpandAll(); insilmaril@763: } insilmaril@763: insilmaril@721: void Main::editUnscrollChildren() insilmaril@721: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->unscrollChildren(); insilmaril@721: } insilmaril@721: insilmaril@721: void Main::editAddMapCenter() insilmaril@721: { insilmaril@721: VymModel *m=currentModel(); insilmaril@772: if (m) m->addMapCenter (); insilmaril@0: } insilmaril@0: insilmaril@394: void Main::editNewBranch() insilmaril@394: { insilmaril@721: VymModel *m=currentModel(); insilmaril@725: if (m) insilmaril@0: { insilmaril@775: BranchItem *bi=m->addNewBranch(); insilmaril@775: if (!bi) return; insilmaril@775: insilmaril@775: if (actionSettingsAutoEditNewBranch->isOn() insilmaril@775: && !actionSettingsAutoSelectNewBranch->isOn() ) insilmaril@775: prevSelection=m->getSelectString(); insilmaril@775: else insilmaril@775: prevSelection=QString(); insilmaril@775: insilmaril@775: if (actionSettingsAutoSelectNewBranch->isOn() insilmaril@775: || actionSettingsAutoEditNewBranch->isOn()) insilmaril@775: { insilmaril@753: m->select (bi); insilmaril@775: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@775: currentMapEditor()->editHeading(); insilmaril@394: } insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@394: void Main::editNewBranchBefore() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@725: if (m) insilmaril@394: { insilmaril@771: BranchItem *bi=m->addNewBranchBefore(); insilmaril@753: insilmaril@753: if (bi) insilmaril@753: m->select (bi); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@537: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@394: { insilmaril@537: if (!actionSettingsAutoSelectNewBranch->isOn()) insilmaril@753: prevSelection=m->getSelectString(bi); insilmaril@721: currentMapEditor()->editHeading(); insilmaril@394: } insilmaril@394: } insilmaril@98: } insilmaril@98: insilmaril@0: void Main::editNewBranchAbove() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@725: if ( m) insilmaril@394: { insilmaril@763: BranchItem *bi=m->addNewBranch (-1); insilmaril@753: insilmaril@753: insilmaril@753: if (bi) insilmaril@753: m->select (bi); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@537: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@394: { insilmaril@537: if (!actionSettingsAutoSelectNewBranch->isOn()) insilmaril@753: prevSelection=m->getSelectString (bi); insilmaril@721: currentMapEditor()->editHeading(); insilmaril@394: } insilmaril@394: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editNewBranchBelow() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@725: if (m) insilmaril@394: { insilmaril@763: BranchItem *bi=m->addNewBranch (1); insilmaril@753: insilmaril@753: if (bi) insilmaril@753: m->select (bi); insilmaril@394: else insilmaril@394: return; insilmaril@394: insilmaril@537: if (actionSettingsAutoEditNewBranch->isOn()) insilmaril@394: { insilmaril@537: if (!actionSettingsAutoSelectNewBranch->isOn()) insilmaril@753: prevSelection=m->getSelectString(bi); insilmaril@721: currentMapEditor()->editHeading(); insilmaril@394: } insilmaril@394: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editImportAdd() insilmaril@0: { insilmaril@0: fileLoad (ImportAdd); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editImportReplace() insilmaril@0: { insilmaril@0: fileLoad (ImportReplace); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editSaveBranch() insilmaril@0: { insilmaril@0: fileSaveAs (PartOfMap); insilmaril@0: } insilmaril@0: insilmaril@721: void Main::editDeleteKeepChildren() insilmaril@98: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->deleteKeepChildren(); insilmaril@98: } insilmaril@98: insilmaril@721: void Main::editDeleteChildren() insilmaril@98: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->deleteChildren(); insilmaril@98: } insilmaril@98: insilmaril@0: void Main::editDeleteSelection() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m && actionSettingsUseDelKey->isOn()) insilmaril@721: m->deleteSelection(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::editLoadImage() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->loadFloatImage(); insilmaril@0: } insilmaril@0: insilmaril@366: void Main::editSaveImage() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->saveFloatImage(); insilmaril@0: } insilmaril@0: insilmaril@366: void Main::editFollowXLink(QAction *a) insilmaril@366: { insilmaril@366: insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@721: m->followXLink(branchXLinksContextMenuFollow->actions().indexOf(a)); insilmaril@366: } insilmaril@366: insilmaril@366: void Main::editEditXLink(QAction *a) insilmaril@89: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@721: m->editXLink(branchXLinksContextMenuEdit->actions().indexOf(a)); insilmaril@94: } insilmaril@94: insilmaril@0: void Main::formatSelectColor() insilmaril@0: { insilmaril@721: QColor col = QColorDialog::getColor((currentColor ), this ); insilmaril@721: if ( !col.isValid() ) return; insilmaril@721: colorChanged( col ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatPickColor() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@721: colorChanged( m->getCurrentHeadingColor() ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::colorChanged(QColor c) insilmaril@0: { insilmaril@0: QPixmap pix( 16, 16 ); insilmaril@0: pix.fill( c ); insilmaril@0: actionFormatColor->setIconSet( pix ); insilmaril@395: currentColor=c; insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatColorBranch() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->colorBranch(currentColor); insilmaril@0: } insilmaril@0: insilmaril@417: void Main::formatColorSubtree() insilmaril@417: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->colorSubtree (currentColor); insilmaril@417: } insilmaril@417: insilmaril@0: void Main::formatLinkStyleLine() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@625: { insilmaril@721: m->setMapLinkStyle("StyleLine"); insilmaril@625: actionFormatLinkStyleLine->setOn(true); insilmaril@625: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStyleParabel() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@625: { insilmaril@721: m->setMapLinkStyle("StyleParabel"); insilmaril@625: actionFormatLinkStyleParabel->setOn(true); insilmaril@625: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStylePolyLine() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@625: { insilmaril@721: m->setMapLinkStyle("StylePolyLine"); insilmaril@625: actionFormatLinkStylePolyLine->setOn(true); insilmaril@625: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatLinkStylePolyParabel() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@625: { insilmaril@721: m->setMapLinkStyle("StylePolyParabel"); insilmaril@625: actionFormatLinkStylePolyParabel->setOn(true); insilmaril@625: } insilmaril@0: } insilmaril@0: insilmaril@0: void Main::formatSelectBackColor() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->selectMapBackgroundColor(); insilmaril@0: } insilmaril@0: insilmaril@408: void Main::formatSelectBackImage() insilmaril@408: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@721: m->selectMapBackgroundImage(); insilmaril@408: } insilmaril@408: insilmaril@0: void Main::formatSelectLinkColor() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@721: { insilmaril@721: QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this ); insilmaril@721: m->setMapDefLinkColor( col ); insilmaril@721: } insilmaril@0: } insilmaril@0: insilmaril@442: void Main::formatSelectSelectionColor() insilmaril@442: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@721: { insilmaril@721: QColor col = QColorDialog::getColor( m->getMapDefLinkColor(), this ); insilmaril@721: m->setSelectionColor (col); insilmaril@721: } insilmaril@721: insilmaril@442: } insilmaril@442: insilmaril@0: void Main::formatToggleLinkColorHint() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->toggleMapLinkColorHint(); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@746: void Main::formatHideLinkUnselected() //FIXME-3 get rid of this with imagepropertydialog insilmaril@160: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@721: m->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn()); insilmaril@160: } insilmaril@160: insilmaril@0: void Main::viewZoomReset() insilmaril@0: { insilmaril@767: MapEditor *me=currentMapEditor(); insilmaril@767: if (me) me->setZoomFactorTarget (1); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::viewZoomIn() insilmaril@0: { insilmaril@767: MapEditor *me=currentMapEditor(); insilmaril@767: if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*1.25); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::viewZoomOut() insilmaril@0: { insilmaril@767: MapEditor *me=currentMapEditor(); insilmaril@767: if (me) me->setZoomFactorTarget (me->getZoomFactorTarget()*0.75); insilmaril@0: } insilmaril@89: insilmaril@526: void Main::viewCenter() insilmaril@526: { insilmaril@721: VymModel *m=currentModel(); insilmaril@763: if (m) m->emitShowSelection(); insilmaril@526: } insilmaril@526: insilmaril@528: void Main::networkStartServer() insilmaril@528: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->newServer(); insilmaril@528: } insilmaril@528: insilmaril@528: void Main::networkConnect() insilmaril@528: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->connectToServer(); insilmaril@528: } insilmaril@528: insilmaril@0: bool Main::settingsPDF() insilmaril@0: { insilmaril@0: // Default browser is set in constructor insilmaril@0: bool ok; insilmaril@0: QString text = QInputDialog::getText( insilmaril@266: "VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal, insilmaril@366: settings.value("/mainwindow/readerPDF").toString(), &ok, this ); insilmaril@0: if (ok) insilmaril@366: settings.setValue ("/mainwindow/readerPDF",text); insilmaril@0: return ok; insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: bool Main::settingsURL() insilmaril@0: { insilmaril@0: // Default browser is set in constructor insilmaril@0: bool ok; insilmaril@0: QString text = QInputDialog::getText( insilmaril@266: "VYM", tr("Set application to open an URL")+":", QLineEdit::Normal, insilmaril@366: settings.value("/mainwindow/readerURL").toString() insilmaril@0: , &ok, this ); insilmaril@0: if (ok) insilmaril@366: settings.setValue ("/mainwindow/readerURL",text); insilmaril@0: return ok; insilmaril@0: } insilmaril@0: insilmaril@450: void Main::settingsMacroDir() insilmaril@450: { insilmaril@625: QDir defdir(vymBaseDir.path() + "/macros"); insilmaril@450: if (!defdir.exists()) insilmaril@450: defdir=vymBaseDir; insilmaril@450: QDir dir=QFileDialog::getExistingDirectory ( insilmaril@450: this, insilmaril@450: tr ("Directory with vym macros:"), insilmaril@450: settings.value ("/macros/macroDir",defdir.path()).toString() insilmaril@450: ); insilmaril@450: if (dir.exists()) insilmaril@625: settings.setValue ("/macros/macroDir",dir.absolutePath()); insilmaril@450: } insilmaril@450: insilmaril@473: void Main::settingsUndoLevels() insilmaril@473: { insilmaril@473: bool ok; insilmaril@473: int i = QInputDialog::getInteger( insilmaril@473: this, insilmaril@473: tr("QInputDialog::getInteger()"), insilmaril@473: tr("Number of undo/redo levels:"), settings.value("/mapeditor/stepsTotal").toInt(), 0, 1000, 1, &ok); insilmaril@473: if (ok) insilmaril@473: { insilmaril@473: settings.setValue ("/mapeditor/stepsTotal",i); insilmaril@473: QMessageBox::information( this, tr( "VYM -Information:" ), insilmaril@473: tr("Settings have been changed. The next map opened will have \"%1\" undo/redo levels").arg(i)); insilmaril@473: } insilmaril@473: } insilmaril@473: insilmaril@473: void Main::settingsAutosaveToggle() insilmaril@473: { insilmaril@742: settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() ); insilmaril@473: } insilmaril@473: insilmaril@473: void Main::settingsAutosaveTime() insilmaril@473: { insilmaril@473: bool ok; insilmaril@473: int i = QInputDialog::getInteger( insilmaril@473: this, insilmaril@473: tr("QInputDialog::getInteger()"), insilmaril@742: tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok); insilmaril@473: if (ok) insilmaril@742: settings.setValue ("/mainwindow/autosave/ms",i * 1000); insilmaril@473: } insilmaril@473: insilmaril@625: void Main::settingsWriteBackupFileToggle() insilmaril@625: { insilmaril@742: settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() ); insilmaril@625: } insilmaril@625: insilmaril@689: void Main::settingsToggleAnimation() insilmaril@689: { insilmaril@689: settings.setValue ("/animation/use",actionSettingsUseAnimation->isOn() ); insilmaril@689: } insilmaril@689: insilmaril@327: void Main::settingsToggleDelKey() insilmaril@327: { insilmaril@327: if (actionSettingsUseDelKey->isOn()) insilmaril@327: { insilmaril@723: actionDelete->setAccel (QKeySequence (Qt::Key_Delete)); insilmaril@327: } else insilmaril@327: { insilmaril@723: actionDelete->setAccel (QKeySequence ("")); insilmaril@327: } insilmaril@327: } insilmaril@327: insilmaril@0: void Main::windowToggleNoteEditor() insilmaril@0: { insilmaril@502: if (textEditor->isVisible() ) insilmaril@497: windowHideNoteEditor(); insilmaril@497: else insilmaril@497: windowShowNoteEditor(); insilmaril@0: } insilmaril@0: insilmaril@294: void Main::windowToggleHistory() insilmaril@294: { insilmaril@404: if (historyWindow->isVisible()) insilmaril@404: historyWindow->hide(); insilmaril@404: else insilmaril@404: historyWindow->show(); insilmaril@404: insilmaril@404: } insilmaril@404: insilmaril@473: void Main::windowToggleProperty() insilmaril@473: { insilmaril@473: if (branchPropertyWindow->isVisible()) insilmaril@473: branchPropertyWindow->hide(); insilmaril@473: else insilmaril@473: branchPropertyWindow->show(); insilmaril@721: branchPropertyWindow->setModel (currentModel() ); insilmaril@473: } insilmaril@473: insilmaril@408: void Main::windowToggleAntiAlias() insilmaril@408: { insilmaril@408: bool b=actionViewToggleAntiAlias->isOn(); insilmaril@408: MapEditor *me; insilmaril@772: for (int i=0;igetMapEditor(); insilmaril@725: if (me) me->setAntiAlias(b); insilmaril@408: } insilmaril@408: insilmaril@408: } insilmaril@408: insilmaril@732: bool Main::isAliased() insilmaril@732: { insilmaril@732: return actionViewToggleAntiAlias->isOn(); insilmaril@732: } insilmaril@732: insilmaril@732: bool Main::hasSmoothPixmapTransform() insilmaril@732: { insilmaril@732: return actionViewToggleSmoothPixmapTransform->isOn(); insilmaril@732: } insilmaril@732: insilmaril@408: void Main::windowToggleSmoothPixmap() insilmaril@408: { insilmaril@408: bool b=actionViewToggleSmoothPixmapTransform->isOn(); insilmaril@408: MapEditor *me; insilmaril@772: for (int i=0;igetMapEditor(); insilmaril@725: if (me) me->setSmoothPixmap(b); insilmaril@408: } insilmaril@408: } insilmaril@408: insilmaril@404: void Main::updateHistory(SimpleSettings &undoSet) insilmaril@404: { insilmaril@404: historyWindow->update (undoSet); insilmaril@294: } insilmaril@294: insilmaril@746: void Main::updateNoteFlag() insilmaril@160: { insilmaril@721: // this slot is connected to TextEditor::textHasChanged() insilmaril@721: insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->updateNoteFlag(); insilmaril@160: } insilmaril@160: insilmaril@753: void Main::updateNoteEditor(QModelIndex index ) insilmaril@746: { insilmaril@782: cout << QObject::sender(); insilmaril@782: QObject *obj=QObject::sender(); insilmaril@782: TreeItem *ti=((TreeModel*)obj)->getItem (index); insilmaril@782: //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index); insilmaril@782: //cout << "Main::updateNoteEditor model="<setNote (ti->getNoteObj() ); insilmaril@746: } insilmaril@746: insilmaril@746: void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel) insilmaril@746: { insilmaril@777: branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select(). Maybe use signal now... insilmaril@748: insilmaril@746: if (model && model==currentModel() ) insilmaril@746: { insilmaril@746: // NoteEditor insilmaril@746: TreeItem *ti; insilmaril@746: if (!oldsel.indexes().isEmpty() ) insilmaril@746: { insilmaril@746: ti=model->getItem(oldsel.indexes().first()); insilmaril@768: insilmaril@768: // Don't update note if both treeItem and textEditor are empty insilmaril@768: //if (! (ti->hasEmptyNote() && textEditor->isEmpty() )) insilmaril@768: // ti->setNoteObj (textEditor->getNoteObj(),false ); insilmaril@746: } insilmaril@746: if (!newsel.indexes().isEmpty() ) insilmaril@746: { insilmaril@746: ti=model->getItem(newsel.indexes().first()); insilmaril@768: if (!ti->hasEmptyNote() ) insilmaril@746: textEditor->setNote(ti->getNoteObj() ); insilmaril@768: else insilmaril@768: textEditor->setNote(NoteObj() ); //FIXME-4 maybe add a clear() to TE insilmaril@770: insilmaril@770: // Show URL and link in statusbar insilmaril@770: QString status; insilmaril@770: QString s=ti->getURL(); insilmaril@770: if (!s.isEmpty() ) status+="URL: "+s+" "; insilmaril@770: s=ti->getVymLink(); insilmaril@770: if (!s.isEmpty() ) status+="Link: "+s; insilmaril@770: if (!status.isEmpty() ) statusMessage (status); insilmaril@770: insilmaril@746: } else insilmaril@746: textEditor->setInactive(); insilmaril@746: insilmaril@746: updateActions(); insilmaril@746: } insilmaril@442: } insilmaril@442: insilmaril@390: void Main::updateActions() insilmaril@390: { insilmaril@721: VymModel *m =currentModel(); insilmaril@724: if (m) insilmaril@724: { insilmaril@724: // Printing insilmaril@724: actionFilePrint->setEnabled (true); insilmaril@724: insilmaril@724: // Link style in context menu insilmaril@724: switch (m->getMapLinkStyle()) insilmaril@724: { insilmaril@724: case LinkableMapObj::Line: insilmaril@724: actionFormatLinkStyleLine->setOn(true); insilmaril@724: break; insilmaril@724: case LinkableMapObj::Parabel: insilmaril@724: actionFormatLinkStyleParabel->setOn(true); insilmaril@724: break; insilmaril@724: case LinkableMapObj::PolyLine: insilmaril@724: actionFormatLinkStylePolyLine->setOn(true); insilmaril@724: break; insilmaril@724: case LinkableMapObj::PolyParabel: insilmaril@724: actionFormatLinkStylePolyParabel->setOn(true); insilmaril@724: break; insilmaril@724: default: insilmaril@724: break; insilmaril@724: } insilmaril@724: insilmaril@724: // Update colors insilmaril@724: QPixmap pix( 16, 16 ); insilmaril@724: pix.fill( m->getMapBackgroundColor() ); insilmaril@724: actionFormatBackColor->setIconSet( pix ); insilmaril@724: pix.fill( m->getSelectionColor() ); insilmaril@724: actionFormatSelectionColor->setIconSet( pix ); insilmaril@724: pix.fill( m->getMapDefLinkColor() ); insilmaril@724: actionFormatLinkColor->setIconSet( pix ); insilmaril@724: insilmaril@724: // History window insilmaril@724: historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName())); insilmaril@724: insilmaril@724: } else insilmaril@724: { insilmaril@724: // Printing insilmaril@724: actionFilePrint->setEnabled (false); insilmaril@724: } insilmaril@407: insilmaril@390: // updateActions is also called when NoteEditor is closed insilmaril@486: actionViewToggleNoteEditor->setOn (textEditor->isVisible()); insilmaril@486: actionViewToggleHistoryWindow->setOn (historyWindow->isVisible()); insilmaril@486: actionViewTogglePropertyWindow->setOn (branchPropertyWindow->isVisible()); insilmaril@390: insilmaril@724: if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) insilmaril@390: actionFormatLinkColorHint->setOn(true); insilmaril@390: else insilmaril@390: actionFormatLinkColorHint->setOn(false); insilmaril@390: insilmaril@724: insilmaril@724: if (m && m->hasChanged() ) insilmaril@724: actionFileSave->setEnabled( true); insilmaril@724: else insilmaril@724: actionFileSave->setEnabled( true); insilmaril@724: if (m && m->isUndoAvailable()) insilmaril@723: actionUndo->setEnabled( true); insilmaril@390: else insilmaril@723: actionUndo->setEnabled( false); insilmaril@390: insilmaril@724: if (m && m->isRedoAvailable()) insilmaril@723: actionRedo->setEnabled( true); insilmaril@390: else insilmaril@723: actionRedo->setEnabled( false); insilmaril@390: insilmaril@772: if (m) insilmaril@390: { insilmaril@772: TreeItem *selti=m->getSelectedItem(); insilmaril@772: BranchItem *selbi=m->getSelectedBranchItem(); insilmaril@772: if (selti) insilmaril@390: { insilmaril@772: if (selbi) insilmaril@390: { insilmaril@772: // Take care of links // FIXME-1 insilmaril@772: /* insilmaril@772: if (bo->countXLinks()==0) insilmaril@772: { insilmaril@772: branchXLinksContextMenuEdit->clear(); insilmaril@772: branchXLinksContextMenuFollow->clear(); insilmaril@772: } else insilmaril@772: { insilmaril@772: BranchObj *bot; insilmaril@772: QString s; insilmaril@772: branchXLinksContextMenuEdit->clear(); insilmaril@772: branchXLinksContextMenuFollow->clear(); insilmaril@772: for (int i=0; i<=bo->countXLinks();i++) insilmaril@772: { insilmaril@772: bot=bo->XLinkTargetAt(i); insilmaril@772: if (bot) insilmaril@772: { insilmaril@772: s=bot->getHeading(); insilmaril@772: if (s.length()>xLinkMenuWidth) insilmaril@772: s=s.left(xLinkMenuWidth)+"..."; insilmaril@772: branchXLinksContextMenuFollow->addAction (s); insilmaril@772: branchXLinksContextMenuEdit->addAction (s); insilmaril@772: } insilmaril@772: } insilmaril@772: } insilmaril@772: */ insilmaril@772: //Standard Flags insilmaril@772: standardFlagsMaster->updateToolBar (selbi->activeStandardFlagNames() ); insilmaril@772: insilmaril@772: // System Flags insilmaril@772: actionToggleScroll->setEnabled (true); insilmaril@772: if ( selbi->isScrolled() ) insilmaril@772: actionToggleScroll->setOn(true); insilmaril@772: else insilmaril@772: actionToggleScroll->setOn(false); insilmaril@772: insilmaril@772: if ( selti->getURL().isEmpty() ) insilmaril@772: { insilmaril@772: actionOpenURL->setEnabled (false); insilmaril@772: actionOpenURLTab->setEnabled (false); insilmaril@772: } insilmaril@772: else insilmaril@772: { insilmaril@772: actionOpenURL->setEnabled (true); insilmaril@772: actionOpenURLTab->setEnabled (true); insilmaril@772: } insilmaril@772: if ( selti->getVymLink().isEmpty() ) insilmaril@772: { insilmaril@772: actionOpenVymLink->setEnabled (false); insilmaril@772: actionDeleteVymLink->setEnabled (false); insilmaril@772: } else insilmaril@772: { insilmaril@772: actionOpenVymLink->setEnabled (true); insilmaril@772: actionDeleteVymLink->setEnabled (true); insilmaril@772: } insilmaril@772: insilmaril@772: if (selbi->canMoveUp()) insilmaril@772: actionMoveUp->setEnabled (true); insilmaril@772: else insilmaril@772: actionMoveUp->setEnabled (false); insilmaril@772: if (selbi->canMoveDown()) insilmaril@772: actionMoveDown->setEnabled (true); insilmaril@772: else insilmaril@772: actionMoveDown->setEnabled (false); insilmaril@772: insilmaril@772: actionSortChildren->setEnabled (true); insilmaril@772: insilmaril@772: actionToggleHideExport->setEnabled (true); insilmaril@772: actionToggleHideExport->setOn (selbi->hideInExport() ); insilmaril@772: insilmaril@772: actionFileSave->setEnabled (true); insilmaril@772: actionCopy->setEnabled (true); insilmaril@772: actionCut->setEnabled (true); insilmaril@772: if (!clipboardEmpty) insilmaril@772: actionPaste->setEnabled (true); insilmaril@772: else insilmaril@772: actionPaste->setEnabled (false); insilmaril@772: for (int i=0; isetEnabled(true); insilmaril@772: actionDelete->setEnabled (true); insilmaril@772: //FIXME-2 actionFormatHideLinkUnselected->setOn (selection->getHideLinkUnselected()); insilmaril@772: } insilmaril@772: if ( selti->getType()==TreeItem::Image) insilmaril@390: { insilmaril@723: actionOpenURL->setEnabled (false); insilmaril@723: actionOpenVymLink->setEnabled (false); insilmaril@772: actionDeleteVymLink->setEnabled (false); insilmaril@772: actionToggleHideExport->setEnabled (true); insilmaril@776: actionToggleHideExport->setOn (selti->hideInExport() ); insilmaril@772: insilmaril@772: insilmaril@772: actionCopy->setEnabled (true); insilmaril@772: actionCut->setEnabled (true); insilmaril@772: actionPaste->setEnabled (false); //FIXME-4 why not allowing copy of images? insilmaril@772: for (int i=0; isetEnabled(false); insilmaril@772: actionDelete->setEnabled (true); insilmaril@776: // FIXME-2 actionFormatHideLinkUnselected->setOn insilmaril@776: // ( selection->getHideLinkUnselected()); insilmaril@723: actionMoveUp->setEnabled (false); insilmaril@723: actionMoveDown->setEnabled (false); insilmaril@772: } //image insilmaril@772: insilmaril@772: } else insilmaril@772: { // !selti insilmaril@772: actionFileSave->setEnabled (false); insilmaril@772: actionCopy->setEnabled (false); insilmaril@772: actionCut->setEnabled (false); insilmaril@772: actionPaste->setEnabled (false); insilmaril@406: for (int i=0; isetEnabled(false); insilmaril@772: insilmaril@772: actionToggleScroll->setEnabled (false); insilmaril@723: actionOpenURL->setEnabled (false); insilmaril@723: actionOpenVymLink->setEnabled (false); insilmaril@723: actionDeleteVymLink->setEnabled (false); insilmaril@772: actionHeading2URL->setEnabled (false); insilmaril@772: actionDelete->setEnabled (false); insilmaril@723: actionMoveUp->setEnabled (false); insilmaril@723: actionMoveDown->setEnabled (false); insilmaril@772: actionSortChildren->setEnabled (false); insilmaril@772: actionToggleHideExport->setEnabled (false); insilmaril@772: } insilmaril@772: } // m insilmaril@390: } insilmaril@390: insilmaril@473: Main::ModMode Main::getModMode() insilmaril@390: { insilmaril@390: if (actionModModeColor->isOn()) return ModModeColor; insilmaril@390: if (actionModModeCopy->isOn()) return ModModeCopy; insilmaril@390: if (actionModModeXLink->isOn()) return ModModeXLink; insilmaril@390: return ModModeNone; insilmaril@390: } insilmaril@390: insilmaril@537: bool Main::autoEditNewBranch() insilmaril@390: { insilmaril@537: return actionSettingsAutoEditNewBranch->isOn(); insilmaril@390: } insilmaril@390: insilmaril@537: bool Main::autoSelectNewBranch() insilmaril@390: { insilmaril@537: return actionSettingsAutoSelectNewBranch->isOn(); insilmaril@390: } insilmaril@390: insilmaril@0: void Main::windowShowNoteEditor() insilmaril@0: { insilmaril@497: textEditor->setShowWithMain(true); insilmaril@0: textEditor->show(); insilmaril@0: actionViewToggleNoteEditor->setOn (true); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::windowHideNoteEditor() insilmaril@0: { insilmaril@497: textEditor->setShowWithMain(false); insilmaril@0: textEditor->hide(); insilmaril@0: actionViewToggleNoteEditor->setOn (false); insilmaril@0: } insilmaril@0: insilmaril@434: void Main::setScript (const QString &script) insilmaril@434: { insilmaril@434: scriptEditor->setScript (script); insilmaril@434: } insilmaril@434: insilmaril@434: void Main::runScript (const QString &script) insilmaril@432: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->runScript (script); insilmaril@432: } insilmaril@432: insilmaril@514: void Main::runScriptEverywhere (const QString &script) insilmaril@514: { insilmaril@514: MapEditor *me; insilmaril@514: for (int i=0;i<=tabWidget->count() -1;i++) insilmaril@514: { insilmaril@514: me=(MapEditor*)tabWidget->page(i); insilmaril@721: if (me) me->getModel()->runScript (script); insilmaril@514: } insilmaril@514: } insilmaril@514: insilmaril@0: void Main::windowNextEditor() insilmaril@0: { insilmaril@725: if (tabWidget->currentIndex() < tabWidget->count()) insilmaril@725: tabWidget->setCurrentIndex (tabWidget->currentIndex() +1); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::windowPreviousEditor() insilmaril@0: { insilmaril@725: if (tabWidget->currentIndex() >0) insilmaril@725: tabWidget->setCurrentIndex (tabWidget->currentIndex() -1); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::standardFlagChanged() insilmaril@0: { insilmaril@766: if (currentModel()) insilmaril@767: { insilmaril@767: if ( actionSettingsUseFlagGroups->isOn() ) insilmaril@767: currentModel()->toggleStandardFlag(sender()->name(),standardFlagsMaster); insilmaril@767: else insilmaril@767: currentModel()->toggleStandardFlag(sender()->name()); insilmaril@770: updateActions(); insilmaril@767: } insilmaril@0: } insilmaril@0: insilmaril@527: void Main::testFunction1() insilmaril@0: { insilmaril@767: if (!currentMapEditor()) return; insilmaril@769: currentMapEditor()->testFunction1(); insilmaril@527: } insilmaril@527: insilmaril@527: void Main::testFunction2() insilmaril@527: { insilmaril@527: if (!currentMapEditor()) return; insilmaril@769: currentMapEditor()->setFocus(); insilmaril@0: } insilmaril@0: insilmaril@393: void Main::testCommand() insilmaril@393: { insilmaril@393: if (!currentMapEditor()) return; insilmaril@432: scriptEditor->show(); insilmaril@432: /* insilmaril@393: bool ok; insilmaril@393: QString com = QInputDialog::getText( insilmaril@404: vymName, "Enter Command:", QLineEdit::Normal,"command", &ok, this ); insilmaril@393: if (ok) currentMapEditor()->parseAtom(com); insilmaril@432: */ insilmaril@393: } insilmaril@393: insilmaril@0: void Main::helpDoc() insilmaril@0: { insilmaril@395: QString locale = QLocale::system().name(); insilmaril@395: QString docname; insilmaril@395: if (locale.left(2)=="es") insilmaril@395: docname="vym_es.pdf"; insilmaril@395: else insilmaril@395: docname="vym.pdf"; insilmaril@420: insilmaril@420: QStringList searchList; insilmaril@395: QDir docdir; insilmaril@103: #if defined(Q_OS_MACX) insilmaril@537: searchList << "./vym.app/Contents/Resources/doc"; insilmaril@625: #elif defined(Q_OS_WIN32) insilmaril@625: searchList << vymInstallDir.path() + "/share/doc/packages/vym"; insilmaril@103: #else insilmaril@608: #if defined(VYM_DOCDIR) insilmaril@608: searchList << VYM_DOCDIR; insilmaril@608: #endif insilmaril@103: // default path in SUSE LINUX insilmaril@625: searchList << "/usr/share/doc/packages/vym"; insilmaril@103: #endif insilmaril@0: insilmaril@420: searchList << "doc"; // relative path for easy testing in tarball insilmaril@420: searchList << "doc/tex"; // Easy testing working on vym.tex insilmaril@420: searchList << "/usr/share/doc/vym"; // Debian insilmaril@420: searchList << "/usr/share/doc/packages";// Knoppix insilmaril@420: insilmaril@420: bool found=false; insilmaril@420: QFile docfile; insilmaril@420: for (int i=0; istart( settings.value("/mainwindow/readerPDF").toString(),args); insilmaril@408: if ( !pdfProc->waitForStarted() ) insilmaril@0: { insilmaril@0: // error handling insilmaril@266: QMessageBox::warning(0, insilmaril@266: tr("Warning"), insilmaril@420: tr("Couldn't find a viewer to open %1.\n").arg(docfile.fileName())+ insilmaril@266: tr("Please use Settings->")+tr("Set application to open PDF files")); insilmaril@266: settingsPDF(); insilmaril@0: return; insilmaril@0: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@505: void Main::helpDemo() insilmaril@505: { insilmaril@505: QStringList filters; insilmaril@505: filters <<"VYM example map (*.vym)"; insilmaril@505: QFileDialog *fd=new QFileDialog( this); insilmaril@595: #if defined(Q_OS_MACX) insilmaril@595: fd->setDir (QDir("./vym.app/Contents/Resources/demos")); insilmaril@595: #else insilmaril@595: // default path in SUSE LINUX insilmaril@595: fd->setDir (QDir(vymBaseDir.path()+"/demos")); insilmaril@595: #endif insilmaril@595: insilmaril@505: fd->setFileMode (QFileDialog::ExistingFiles); insilmaril@505: fd->setFilters (filters); insilmaril@505: fd->setCaption(vymName+ " - " +tr("Load vym example map")); insilmaril@505: fd->show(); insilmaril@505: insilmaril@505: QString fn; insilmaril@505: if ( fd->exec() == QDialog::Accepted ) insilmaril@505: { insilmaril@505: lastFileDir=fd->directory().path(); insilmaril@505: QStringList flist = fd->selectedFiles(); insilmaril@505: QStringList::Iterator it = flist.begin(); insilmaril@505: while( it != flist.end() ) insilmaril@505: { insilmaril@505: fn = *it; insilmaril@505: fileLoad(*it, NewMap); insilmaril@505: ++it; insilmaril@505: } insilmaril@505: } insilmaril@505: delete (fd); insilmaril@505: } insilmaril@505: insilmaril@505: insilmaril@0: void Main::helpAbout() insilmaril@0: { insilmaril@148: AboutDialog ad; insilmaril@150: ad.setName ("aboutwindow"); insilmaril@148: ad.setMinimumSize(500,500); insilmaril@148: ad.resize (QSize (500,500)); insilmaril@148: ad.exec(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::helpAboutQT() insilmaril@0: { insilmaril@0: QMessageBox::aboutQt( this, "Qt Application Example" ); insilmaril@0: } insilmaril@0: insilmaril@445: void Main::callMacro () insilmaril@445: { insilmaril@445: QAction *action = qobject_cast(sender()); insilmaril@445: int i=-1; insilmaril@445: if (action) insilmaril@445: { insilmaril@445: i=action->data().toInt(); insilmaril@447: QString mDir (settings.value ("macros/macroDir").toString() ); insilmaril@447: insilmaril@447: QString fn=mDir + QString("/macro-%1.vys").arg(i+1); insilmaril@447: QFile f (fn); insilmaril@447: if ( !f.open( QIODevice::ReadOnly ) ) insilmaril@447: { insilmaril@447: QMessageBox::warning(0, insilmaril@447: tr("Warning"), insilmaril@447: tr("Couldn't find a macro at %1.\n").arg(fn)+ insilmaril@447: tr("Please use Settings->")+tr("Set directory for vym macros")); insilmaril@447: return; insilmaril@447: } insilmaril@447: insilmaril@447: QTextStream ts( &f ); insilmaril@721: QString macro= ts.read(); insilmaril@721: insilmaril@721: if (! macro.isEmpty()) insilmaril@445: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->runScript(macro); insilmaril@445: } insilmaril@445: } insilmaril@445: } insilmaril@445: