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@804: #include "shortcuts.h" insilmaril@205: #include "texteditor.h" insilmaril@442: #include "warningdialog.h" insilmaril@790: #include "xlinkitem.h" insilmaril@0: insilmaril@816: //#include // FIXME-3 insilmaril@791: 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@808: long hProcess; insilmaril@808: long hThread; insilmaril@808: long dwProcessId; insilmaril@808: 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* 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@807: QMainWindow(parent,name,f) insilmaril@0: { insilmaril@808: mainWindow=this; insilmaril@808: insilmaril@808: setCaption ("VYM - View Your Mind"); insilmaril@808: insilmaril@808: // Load window settings insilmaril@808: #if defined(Q_OS_WIN32) insilmaril@808: if (settings.value("/mainwindow/geometry/maximized", false).toBool()) insilmaril@808: { insilmaril@808: setWindowState(Qt::WindowMaximized); insilmaril@808: } insilmaril@808: else insilmaril@808: #endif insilmaril@808: { insilmaril@808: resize (settings.value("/mainwindow/geometry/size", QSize (800,600)).toSize()); insilmaril@808: move (settings.value("/mainwindow/geometry/pos", QPoint(300,100)).toPoint()); insilmaril@808: } insilmaril@808: insilmaril@808: // Sometimes we may need to remember old selections insilmaril@808: prevSelection=""; insilmaril@808: insilmaril@808: // Default color insilmaril@808: currentColor=Qt::black; insilmaril@808: insilmaril@808: // Create unique temporary directory insilmaril@808: bool ok; insilmaril@808: tmpVymDir=makeTmpDir (ok,"vym"); insilmaril@808: if (!ok) insilmaril@808: { insilmaril@808: qWarning ("Mainwindow: Could not create temporary directory, failed to start vym"); insilmaril@808: exit (1); insilmaril@808: } insilmaril@808: if (debug) qDebug (QString("vym tmpDir=%1").arg(tmpVymDir) ); insilmaril@808: insilmaril@808: // Create direcctory for clipboard insilmaril@808: clipboardDir=tmpVymDir+"/clipboard"; insilmaril@808: clipboardFile="map.xml"; insilmaril@808: QDir d(clipboardDir); insilmaril@808: d.mkdir (clipboardDir,true); insilmaril@808: makeSubDirs (clipboardDir); insilmaril@808: clipboardEmpty=true; insilmaril@808: insilmaril@808: browserPID=new qint64; insilmaril@808: *browserPID=0; insilmaril@808: insilmaril@808: // Satellite windows ////////////////////////////////////////// insilmaril@808: // history window insilmaril@808: historyWindow=new HistoryWindow(); insilmaril@808: connect (historyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@808: insilmaril@808: // properties window insilmaril@808: branchPropertyWindow = new BranchPropertyWindow(); insilmaril@808: connect (branchPropertyWindow, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@808: insilmaril@808: // Connect TextEditor, so that we can update flags if text changes insilmaril@808: connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag())); insilmaril@808: connect (textEditor, SIGNAL (windowClosed() ), this, SLOT (updateActions())); insilmaril@808: insilmaril@808: // Initialize script editor insilmaril@808: scriptEditor = new SimpleScriptEditor(); insilmaril@808: scriptEditor->move (50,50); insilmaril@808: insilmaril@808: connect( scriptEditor, SIGNAL( runScript ( QString ) ), insilmaril@808: this, SLOT( runScript( QString ) ) ); insilmaril@808: insilmaril@808: // Initialize some settings, which are platform dependant insilmaril@808: QString p,s; insilmaril@808: insilmaril@808: // application to open URLs insilmaril@808: p="/mainwindow/readerURL"; insilmaril@808: #if defined(Q_OS_LINUX) insilmaril@808: s=settings.value (p,"xdg-open").toString(); insilmaril@0: #else insilmaril@808: #if defined(Q_OS_MACX) insilmaril@808: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@808: insilmaril@807: #else insilmaril@808: #if defined(Q_OS_WIN32) insilmaril@808: // Assume that system has been set up so that insilmaril@808: // Explorer automagically opens up the URL insilmaril@808: // in the user's preferred browser. insilmaril@808: s=settings.value (p,"explorer").toString(); insilmaril@808: #else insilmaril@808: s=settings.value (p,"mozilla").toString(); insilmaril@808: #endif insilmaril@0: #endif insilmaril@0: #endif insilmaril@808: settings.setValue( p,s); insilmaril@808: insilmaril@808: // application to open PDFs insilmaril@808: p="/mainwindow/readerPDF"; insilmaril@808: #if defined(Q_OS_LINUX) insilmaril@808: s=settings.value (p,"xdg-open").toString(); insilmaril@0: #else insilmaril@808: #if defined(Q_OS_MACX) insilmaril@808: s=settings.value (p,"/usr/bin/open").toString(); insilmaril@808: #elif defined(Q_OS_WIN32) insilmaril@808: s=settings.value (p,"acrord32").toString(); insilmaril@808: #else insilmaril@808: s=settings.value (p,"acroread").toString(); insilmaril@808: #endif insilmaril@0: #endif insilmaril@808: settings.setValue( p,s); insilmaril@808: insilmaril@808: // width of xLinksMenu insilmaril@808: xLinkMenuWidth=60; insilmaril@808: insilmaril@808: // Create tab widget which holds the maps insilmaril@808: tabWidget= new QTabWidget (this); insilmaril@808: connect( tabWidget, SIGNAL( currentChanged( QWidget * ) ), insilmaril@808: this, SLOT( editorChanged( QWidget * ) ) ); insilmaril@808: insilmaril@808: setCentralWidget(tabWidget); insilmaril@808: insilmaril@808: setupFileActions(); insilmaril@808: setupEditActions(); insilmaril@808: setupFormatActions(); insilmaril@808: setupViewActions(); insilmaril@808: setupModeActions(); insilmaril@808: setupFlagActions(); insilmaril@808: setupNetworkActions(); insilmaril@808: setupSettingsActions(); insilmaril@808: setupContextMenus(); insilmaril@808: setupMacros(); insilmaril@808: if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions(); insilmaril@808: setupHelpActions(); insilmaril@808: insilmaril@808: // Status bar and progress bar there insilmaril@808: statusBar(); insilmaril@808: progressMax=0; insilmaril@821: progressCounter=0; insilmaril@821: progressCounterTotal=0; insilmaril@821: insilmaril@821: progressDialog.setLabelText (tr("Loading maps","Mainwindow")); insilmaril@821: progressDialog.setAutoReset(false); insilmaril@821: progressDialog.setAutoClose(false); insilmaril@821: //progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down insilmaril@821: //progressDialog.setCancelButton (NULL); insilmaril@808: insilmaril@808: restoreState (settings.value("/mainwindow/state",0).toByteArray()); insilmaril@808: insilmaril@808: updateGeometry(); insilmaril@0: } insilmaril@0: insilmaril@0: Main::~Main() insilmaril@0: { insilmaril@808: // Save Settings insilmaril@808: #if defined(Q_OS_WIN32) insilmaril@808: settings.setValue ("/mainwindow/geometry/maximized", isMaximized()); insilmaril@808: #endif insilmaril@808: settings.setValue ("/mainwindow/geometry/size", size()); insilmaril@808: settings.setValue ("/mainwindow/geometry/pos", pos()); insilmaril@808: settings.setValue ("/mainwindow/state",saveState(0)); insilmaril@808: insilmaril@808: settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn()); insilmaril@808: settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn()); insilmaril@808: settings.setValue( "/version/version", vymVersion ); insilmaril@808: settings.setValue( "/version/builddate", vymBuildDate ); insilmaril@808: insilmaril@808: settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() ); insilmaril@808: settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() ); insilmaril@808: settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() ); insilmaril@808: settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() ); insilmaril@808: settings.setValue( "/mapeditor/editmode/autoEditNewBranch",actionSettingsAutoEditNewBranch->isOn() ); insilmaril@808: settings.setValue( "/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() ); insilmaril@808: settings.setValue( "/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() ); insilmaril@808: settings.setValue( "/export/useHideExport",actionSettingsUseHideExport->isOn() ); insilmaril@808: insilmaril@808: //TODO save scriptEditor settings insilmaril@808: insilmaril@808: // call the destructors insilmaril@808: delete textEditor; insilmaril@808: delete historyWindow; insilmaril@808: delete branchPropertyWindow; insilmaril@808: insilmaril@808: // Remove temporary directory insilmaril@808: removeDir (QDir(tmpVymDir)); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::loadCmdLine() insilmaril@0: { insilmaril@808: /* TODO draw some kind of splashscreen while loading... insilmaril@808: if (qApp->argc()>1) insilmaril@808: { insilmaril@808: } insilmaril@808: */ insilmaril@808: insilmaril@808: QStringList flist=options.getFileList(); insilmaril@808: QStringList::Iterator it=flist.begin(); insilmaril@808: insilmaril@821: progressCounter=flist.count(); insilmaril@821: progressCounterTotal=flist.count(); insilmaril@808: while (it !=flist.end() ) insilmaril@808: { insilmaril@808: fileLoad (*it, NewMap); insilmaril@808: *it++; insilmaril@808: } insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: void Main::statusMessage(const QString &s) insilmaril@0: { insilmaril@821: // Surpress messages while progressdialog during insilmaril@808: // load is active insilmaril@821: if (progressMax==0) insilmaril@808: statusBar()->message( s); insilmaril@742: } insilmaril@742: insilmaril@821: void Main::setProgressMaximum (int max) insilmaril@742: { insilmaril@821: if (progressCounterTotal!=0) insilmaril@821: insilmaril@821: progressDialog.setRange (0,progressCounterTotal*1000); insilmaril@821: else insilmaril@821: progressDialog.setRange (0,max+10); insilmaril@821: insilmaril@821: progressDialog.setValue (0); insilmaril@821: progressMax=max*1000; insilmaril@821: //cout << "Main max="<addMenu ( tr ("&Map") ); insilmaril@808: QToolBar *tb = addToolBar( tr ("&Map") ); insilmaril@808: tb->setObjectName ("mapTB"); insilmaril@808: insilmaril@808: QAction *a; insilmaril@808: a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New map","File menu" ),this); insilmaril@808: a->setStatusTip ( tr( "New map","Status tip File menu" ) ); insilmaril@808: a->setShortcut ( Qt::CTRL + Qt::Key_N ); //New map insilmaril@808: a->addTo( tb ); insilmaril@808: fileMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileNew() ) ); insilmaril@808: insilmaril@808: a = new QAction(QPixmap( iconPath+"filenewcopy.png"), tr( "&Copy to new map","File menu" ),this); insilmaril@808: a->setStatusTip ( tr( "Copy selection to mapcenter of a new map","Status tip File menu" ) ); insilmaril@808: a->setShortcut ( Qt::CTRL +Qt::SHIFT + Qt::Key_N ); //New map insilmaril@808: fileMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileNewCopy() ) ); insilmaril@808: actionFileNewCopy=a; insilmaril@808: insilmaril@808: a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ,"File menu"),this); insilmaril@808: a->setStatusTip (tr( "Open","Status tip File menu" ) ); insilmaril@808: a->setShortcut ( Qt::CTRL + Qt::Key_O ); //Open map insilmaril@808: a->addTo( tb ); insilmaril@808: fileMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileLoad() ) ); insilmaril@808: insilmaril@808: fileLastMapsMenu = fileMenu->addMenu (tr("Open Recent","File menu")); insilmaril@808: fileMenu->addSeparator(); insilmaril@808: insilmaril@808: a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save...","File menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Save","Status tip file menu" )); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_S ); //Save map insilmaril@808: a->addTo( tb ); insilmaril@808: fileMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileSave() ) ); insilmaril@808: actionFileSave=a; insilmaril@808: insilmaril@808: a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As...","File menu" ), this); insilmaril@808: a->setStatusTip (tr( "Save &As","Status tip file menu" ) ); insilmaril@808: fileMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileSaveAs() ) ); insilmaril@808: insilmaril@808: fileMenu->addSeparator(); insilmaril@808: insilmaril@808: fileImportMenu = fileMenu->addMenu (tr("Import","File menu")); insilmaril@808: insilmaril@808: a = new QAction(tr("KDE 3 Bookmarks"), this); insilmaril@808: a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks"))); insilmaril@366: a->addTo (fileImportMenu); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) ); insilmaril@808: insilmaril@808: a = new QAction(tr("KDE 4 Bookmarks"), this); insilmaril@808: a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks"))); insilmaril@808: a->addTo (fileImportMenu); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) ); insilmaril@808: insilmaril@808: if (settings.value( "/mainwindow/showTestMenu",false).toBool()) insilmaril@808: { insilmaril@808: a = new QAction( QPixmap(), tr("Firefox Bookmarks","File menu"),this); insilmaril@808: a->setStatusTip (tr( "Import %1","Status tip file menu").arg(tr("Firefox Bookmarks" ) )); insilmaril@808: a->addTo (fileImportMenu); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFirefoxBookmarks() ) ); insilmaril@808: } insilmaril@808: insilmaril@808: a = new QAction("Freemind...",this); insilmaril@808: a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Freemind") ); insilmaril@808: fileImportMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportFreemind() ) ); insilmaril@808: insilmaril@808: a = new QAction("Mind Manager...",this); insilmaril@808: a->setStatusTip ( tr( "Import %1","status tip file menu").arg(" Mind Manager") ); insilmaril@808: fileImportMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportMM() ) ); insilmaril@808: insilmaril@808: a = new QAction( tr( "Import Dir%1","File menu").arg("..."), this); insilmaril@808: a->setStatusTip (tr( "Import directory structure (experimental)","status tip file menu" ) ); insilmaril@808: fileImportMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileImportDir() ) ); insilmaril@808: insilmaril@808: fileExportMenu = fileMenu->addMenu (tr("Export","File menu")); insilmaril@808: insilmaril@808: a = new QAction( tr("Image%1","File export menu").arg("..."), this); insilmaril@808: a->setStatusTip( tr( "Export map as image","status tip file menu" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportImage() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( "Open Office...", this); insilmaril@808: a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office ","status tip file menu" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@819: a = new QAction( "Webpage (HTML)...",this ); insilmaril@819: a->setShortcut (Qt::ALT + Qt::Key_X); //Export HTML insilmaril@808: a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu"))); insilmaril@819: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) ); insilmaril@819: fileExportMenu->addAction (a); insilmaril@819: insilmaril@819: a = new QAction( "Webpage (XHTML)...",this ); //Export XHTML insilmaril@819: insilmaril@819: //a->setShortcut (Qt::ALT + Qt::SHIFT + Qt::Key_X); a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu"))); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( "Text (A&O report)...", this); insilmaril@808: a->setStatusTip ( tr( "Export as %1").arg("A&O report "+tr("(still experimental)" ))); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportAO() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( "Text (ASCII)...", this); insilmaril@808: a->setStatusTip ( tr( "Export as %1").arg("ASCII "+tr("(still experimental)" ))); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportASCII() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( "Spreadsheet (CSV)...", this); insilmaril@808: a->setStatusTip ( tr( "Export as %1").arg("CSV "+tr("(still experimental)" ))); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( tr("KDE 3 Bookmarks","File menu"), this); insilmaril@808: a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" ))); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( tr("KDE 4 Bookmarks","File menu"), this); insilmaril@808: a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" ))); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( "Taskjuggler...", this ); insilmaril@808: a->setStatusTip( tr( "Export as %1").arg("Taskjuggler "+tr("(still experimental)" ))); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportTaskjuggler() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( "LaTeX...", this); insilmaril@808: a->setStatusTip( tr( "Export as %1").arg("LaTeX "+tr("(still experimental)" ))); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportLaTeX() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( "XML..." , this ); insilmaril@808: a->setStatusTip (tr( "Export as %1").arg("XML")); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXML() ) ); insilmaril@808: fileExportMenu->addAction (a); insilmaril@808: insilmaril@808: fileMenu->addSeparator(); insilmaril@808: insilmaril@808: a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this); insilmaril@808: a->setStatusTip ( tr( "Print" ,"File menu") ); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_P ); //Print map insilmaril@808: a->addTo( tb ); insilmaril@808: fileMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( filePrint() ) ); insilmaril@808: actionFilePrint=a; insilmaril@808: insilmaril@808: a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map","File menu" ), this); insilmaril@808: a->setStatusTip (tr( "Close Map" ) ); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_W ); //Close map insilmaril@808: fileMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( fileCloseMap() ) ); insilmaril@808: insilmaril@808: a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit","File menu")+" "+vymName, this); insilmaril@808: a->setStatusTip ( tr( "Exit")+" "+vymName ); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_Q ); //Quit vym insilmaril@808: fileMenu->addAction (a); insilmaril@808: 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@808: QToolBar *tb = addToolBar( tr ("&Actions toolbar","Toolbar name") ); insilmaril@808: tb->setLabel( "Edit Actions" ); insilmaril@808: tb->setObjectName ("actionsTB"); insilmaril@808: QMenu *editMenu = menuBar()->addMenu( tr("&Edit","Edit menu") ); insilmaril@808: insilmaril@808: QAction *a; insilmaril@808: QAction *alt; insilmaril@808: a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo","Edit menu" ),this); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editUndo() ) ); insilmaril@808: a->setStatusTip (tr( "Undo" ) ); insilmaril@808: a->setShortcut ( Qt::CTRL + Qt::Key_Z ); //Undo last action insilmaril@808: a->setEnabled (false); insilmaril@808: tb->addAction (a); insilmaril@808: editMenu->addAction (a); insilmaril@808: actionUndo=a; insilmaril@808: insilmaril@808: a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo","Edit menu" ), this); insilmaril@808: a->setStatusTip (tr( "Redo" )); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_Y ); //Redo last action insilmaril@808: tb->addAction (a); insilmaril@808: editMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editRedo() ) ); insilmaril@808: actionRedo=a; insilmaril@808: insilmaril@808: editMenu->addSeparator(); insilmaril@808: a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Copy" ) ); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_C ); //Copy insilmaril@808: a->setEnabled (false); insilmaril@808: tb->addAction (a); insilmaril@808: editMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editCopy() ) ); insilmaril@808: actionCopy=a; insilmaril@808: insilmaril@808: a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Cut" ) ); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_X ); //Cut insilmaril@808: a->setEnabled (false); insilmaril@808: tb->addAction (a); insilmaril@808: editMenu->addAction (a); insilmaril@808: actionCut=a; insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editCut() ) ); insilmaril@808: insilmaril@808: a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste","Edit menu" ),this); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editPaste() ) ); insilmaril@808: a->setStatusTip ( tr( "Paste" ) ); insilmaril@808: a->setShortcut ( Qt::CTRL + Qt::Key_V ); //Paste insilmaril@808: a->setEnabled (false); insilmaril@808: tb->addAction (a); insilmaril@808: editMenu->addAction (a); insilmaril@808: actionPaste=a; insilmaril@808: insilmaril@808: // Shortcut to delete selection insilmaril@808: a = new QAction( tr( "Delete Selection","Edit menu" ),this); insilmaril@808: a->setStatusTip (tr( "Delete Selection" )); insilmaril@808: a->setShortcut ( Qt::Key_Delete); //Delete selection insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteSelection() ) ); insilmaril@808: actionDelete=a; insilmaril@808: insilmaril@808: // Shortcut to add attribute insilmaril@808: a= new QAction(tr( "Add attribute" ), this); insilmaril@808: a->setShortcut ( Qt::Key_Q); insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) ); insilmaril@808: actionAddAttribute= a; insilmaril@808: insilmaril@808: insilmaril@808: // Shortcut to add mapcenter insilmaril@808: a= new QAction(QPixmap(iconPath+"newmapcenter.png"),tr( "Add mapcenter","Canvas context menu" ), this); insilmaril@808: a->setShortcut ( Qt::Key_M); insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editAddMapCenter() ) ); insilmaril@808: //actionListBranches.append(a); insilmaril@808: tb->addAction (a); insilmaril@808: actionAddMapCenter = a; insilmaril@808: insilmaril@808: insilmaril@808: // Shortcut to add branch insilmaril@808: alt = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this); insilmaril@808: alt->setStatusTip ( tr( "Add a branch as child of selection" )); insilmaril@808: alt->setShortcut (Qt::Key_A); //Add branch insilmaril@808: alt->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction (alt); insilmaril@808: connect( alt, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); insilmaril@808: a = new QAction(QPixmap(iconPath+"newbranch.png"), tr( "Add branch as child","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Add a branch as child of selection" )); insilmaril@808: a->setShortcut (Qt::Key_Insert); //Add branch insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranch() ) ); insilmaril@808: actionListBranches.append(a); insilmaril@808: #if defined (Q_OS_MACX) insilmaril@808: // In OSX show different shortcut in menues, the keys work indepently always insilmaril@808: actionAddBranch=alt; insilmaril@808: #else insilmaril@808: actionAddBranch=a; insilmaril@808: #endif insilmaril@808: editMenu->addAction (actionAddBranch); insilmaril@808: tb->addAction (actionAddBranch); insilmaril@808: insilmaril@808: insilmaril@808: // Add branch by inserting it at selection insilmaril@808: a = new QAction(tr( "Add branch (insert)","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); insilmaril@808: a->setShortcut (Qt::ALT + Qt::Key_Insert ); //Insert branch insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionAddBranchBefore=a; insilmaril@808: a = new QAction(tr( "Add branch (insert)","Edit menu" ),this); insilmaril@808: a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" )); insilmaril@808: a->setShortcut ( Qt::ALT + Qt::Key_A ); //Insert branch insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBefore() ) ); insilmaril@808: actionListBranches.append(a); insilmaril@808: insilmaril@808: // Add branch above insilmaril@808: a = new QAction(tr( "Add branch above","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Add a branch above selection" )); insilmaril@808: a->setShortcut (Qt::SHIFT+Qt::Key_Insert ); //Add branch above insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionAddBranchAbove=a; insilmaril@808: a = new QAction(tr( "Add branch above","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Add a branch above selection" )); insilmaril@808: a->setShortcut (Qt::SHIFT+Qt::Key_A ); //Add branch above insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchAbove() ) ); insilmaril@808: actionListBranches.append(a); insilmaril@808: insilmaril@808: // Add branch below insilmaril@808: a = new QAction(tr( "Add branch below","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Add a branch below selection" )); insilmaril@808: a->setShortcut (Qt::CTRL +Qt::Key_Insert ); //Add branch below insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionAddBranchBelow=a; insilmaril@808: a = new QAction(tr( "Add branch below","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Add a branch below selection" )); insilmaril@808: a->setShortcut (Qt::CTRL +Qt::Key_A ); // Add branch below insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editNewBranchBelow() ) ); insilmaril@808: actionListBranches.append(a); insilmaril@808: insilmaril@808: a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Move branch up" ) ); insilmaril@808: a->setShortcut (Qt::Key_PageUp ); // Move branch up insilmaril@808: a->setEnabled (false); insilmaril@808: tb->addAction (a); insilmaril@808: editMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editMoveUp() ) ); insilmaril@808: actionMoveUp=a; insilmaril@808: insilmaril@808: a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down","Edit menu" ),this); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editMoveDown() ) ); insilmaril@808: a->setStatusTip (tr( "Move branch down" ) ); insilmaril@808: a->setShortcut ( Qt::Key_PageDown ); // Move branch down insilmaril@808: a->setEnabled (false); insilmaril@808: tb->addAction (a); insilmaril@808: editMenu->addAction (a); insilmaril@808: actionMoveDown=a; insilmaril@808: insilmaril@808: a = new QAction(QPixmap(), tr( "&Detach","Context menu" ),this); insilmaril@808: a->setStatusTip ( tr( "Detach branch and use as mapcenter","Context menu" ) ); insilmaril@808: a->setShortcut ( Qt::Key_D ); // Detach branch insilmaril@808: editMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editDetach() ) ); insilmaril@808: actionDetach=a; insilmaril@808: insilmaril@808: a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this ); insilmaril@808: connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) ); insilmaril@808: a->setEnabled (true); insilmaril@808: a->addTo( tb ); insilmaril@808: editMenu->addAction (a); insilmaril@808: actionSortChildren=a; insilmaril@808: insilmaril@822: a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this ); insilmaril@822: connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) ); insilmaril@822: a->setEnabled (true); insilmaril@822: a->addTo( tb ); insilmaril@822: editMenu->addAction (a); insilmaril@822: actionSortBackChildren=a; insilmaril@822: insilmaril@808: alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this); insilmaril@808: alt->setShortcut ( Qt::Key_S ); // Scroll branch insilmaril@808: alt->setStatusTip (tr( "Scroll branch" )); insilmaril@808: connect( alt, SIGNAL( triggered() ), this, SLOT( editToggleScroll() ) ); insilmaril@808: #if defined(Q_OS_MACX) insilmaril@808: actionToggleScroll=alt; insilmaril@808: #else insilmaril@808: actionToggleScroll=a; insilmaril@808: #endif insilmaril@808: actionToggleScroll->setEnabled (false); insilmaril@808: actionToggleScroll->setToggleAction(true); insilmaril@808: tb->addAction (actionToggleScroll); insilmaril@808: editMenu->addAction ( actionToggleScroll); insilmaril@808: editMenu->addAction (actionToggleScroll); insilmaril@808: addAction (a); insilmaril@808: addAction (alt); insilmaril@808: actionListBranches.append(actionToggleScroll); insilmaril@808: insilmaril@808: a = new QAction( QPixmap(), tr( "Expand all branches","Edit menu" ), this); insilmaril@808: a->setShortcut ( Qt::SHIFT + Qt::Key_X ); // Expand all branches insilmaril@808: a->setStatusTip (tr( "Expand all branches" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editExpandAll() ) ); insilmaril@808: actionExpandAll=a; insilmaril@808: actionExpandAll->setEnabled (false); insilmaril@808: actionExpandAll->setToggleAction(false); insilmaril@808: //tb->addAction (actionExpandAll); insilmaril@808: editMenu->addAction ( actionExpandAll); insilmaril@808: addAction (a); insilmaril@808: actionListBranches.append(actionExpandAll); insilmaril@808: insilmaril@808: a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this); insilmaril@808: a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor insilmaril@808: a->setStatusTip (tr( "Expand one level in tree editor" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: a->setToggleAction(false); insilmaril@808: actionExpandOneLevel=a; insilmaril@808: //tb->addAction (a); insilmaril@808: editMenu->addAction ( a); insilmaril@808: addAction (a); insilmaril@808: actionListBranches.append(a); insilmaril@808: insilmaril@808: a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this); insilmaril@808: a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor insilmaril@808: a->setStatusTip (tr( "Collapse one level in tree editor" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: a->setToggleAction(false); insilmaril@808: actionCollapseOneLevel=a; insilmaril@808: //tb->addAction (a); insilmaril@808: editMenu->addAction ( a); insilmaril@808: addAction (a); insilmaril@808: actionListBranches.append(a); insilmaril@808: insilmaril@808: a = new QAction( tr( "Unscroll children","Edit menu" ), this); insilmaril@808: a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" )); insilmaril@808: editMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editUnscrollChildren() ) ); insilmaril@808: insilmaril@808: editMenu->addSeparator(); insilmaril@808: insilmaril@808: a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find...","Edit menu"), this); insilmaril@808: a->setStatusTip (tr( "Find" ) ); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_F ); //Find insilmaril@808: editMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) ); insilmaril@808: insilmaril@821: a = new QAction( tr( "Find duplicate URLs","Edit menu"), this); insilmaril@821: //a->setStatusTip (tr( "Find" ) ); insilmaril@821: a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs insilmaril@821: if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@821: editMenu->addAction (a); insilmaril@821: connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) ); insilmaril@821: insilmaril@808: editMenu->addSeparator(); insilmaril@808: insilmaril@808: a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this); insilmaril@808: a->setShortcut (Qt::SHIFT + Qt::Key_U ); insilmaril@808: a->setShortcut (tr( "Open URL" )); insilmaril@808: tb->addAction (a); insilmaril@808: addAction(a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURL() ) ); insilmaril@808: actionOpenURL=a; insilmaril@808: insilmaril@808: a = new QAction( tr( "Open URL in new tab","Edit menu" ), this); insilmaril@808: a->setStatusTip (tr( "Open URL in new tab" )); insilmaril@808: //a->setShortcut (Qt::CTRL+Qt::Key_U ); insilmaril@808: addAction(a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) ); insilmaril@808: actionOpenURLTab=a; insilmaril@808: insilmaril@821: a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this); insilmaril@821: a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" )); insilmaril@821: a->setShortcut ( Qt::CTRL + Qt::Key_U ); insilmaril@821: addAction(a); insilmaril@821: actionListBranches.append(a); insilmaril@821: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) ); insilmaril@821: actionOpenMultipleVisURLTabs=a; insilmaril@821: insilmaril@808: a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this); insilmaril@808: a->setStatusTip (tr( "Open all URLs in subtree" )); insilmaril@808: addAction(a); insilmaril@808: actionListBranches.append(a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) ); insilmaril@808: actionOpenMultipleURLTabs=a; insilmaril@808: insilmaril@808: a = new QAction(QPixmap(), tr( "Edit URL...","Edit menu"), this); insilmaril@808: a->setStatusTip ( tr( "Edit URL" ) ); insilmaril@808: a->setShortcut ( Qt::Key_U ); insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: actionListBranches.append(a); insilmaril@808: addAction(a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editURL() ) ); insilmaril@808: actionURL=a; insilmaril@808: insilmaril@808: a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this); insilmaril@808: a->setStatusTip ( tr( "Edit local URL" ) ); insilmaril@808: //a->setShortcut (Qt::SHIFT + Qt::Key_U ); insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: actionListBranches.append(a); insilmaril@808: addAction(a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editLocalURL() ) ); insilmaril@808: actionLocalURL=a; insilmaril@808: insilmaril@808: a = new QAction( tr( "Use heading for URL","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Use heading of selected branch as URL" )); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editHeading2URL() ) ); insilmaril@808: actionHeading2URL=a; insilmaril@808: insilmaril@808: a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Create URL to Novell Bugzilla" )); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: a->setShortcut ( Qt::Key_B ); insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction(a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) ); insilmaril@808: actionBugzilla2URL=a; insilmaril@808: insilmaril@821: a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this); insilmaril@820: a->setStatusTip ( tr( "Get data from Novell Bugzilla" )); insilmaril@820: a->setEnabled (false); insilmaril@820: actionListBranches.append(a); insilmaril@820: a->setShortcut ( Qt::Key_B + Qt::SHIFT); insilmaril@820: a->setShortcutContext (Qt::WindowShortcut); insilmaril@820: addAction(a); insilmaril@820: connect( a, SIGNAL( triggered() ), this, SLOT( getBugzillaData() ) ); insilmaril@820: actionGetBugzillaData=a; insilmaril@820: insilmaril@808: a = new QAction(tr( "Create URL to Novell FATE","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Create URL to Novell FATE" )); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editFATE2URL() ) ); insilmaril@808: actionFATE2URL=a; insilmaril@808: insilmaril@808: a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Open linked map","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" )); insilmaril@808: tb->addAction (a); insilmaril@808: a->setEnabled (false); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenVymLink() ) ); insilmaril@808: actionOpenVymLink=a; insilmaril@808: insilmaril@808: a = new QAction(QPixmap(), tr( "Open all vym links in subtree","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Open all vym links in subtree" )); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVymLinks() ) ); insilmaril@808: actionOpenMultipleVymLinks=a; insilmaril@808: insilmaril@808: insilmaril@808: a = new QAction(tr( "Edit vym link...","Edit menu" ), this); insilmaril@808: a->setEnabled (false); insilmaril@808: a->setStatusTip ( tr( "Edit link to another vym map" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editVymLink() ) ); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionVymLink=a; insilmaril@808: insilmaril@808: a = new QAction(tr( "Delete vym link","Edit menu" ),this); insilmaril@808: a->setStatusTip ( tr( "Delete link to another vym map" )); insilmaril@808: a->setEnabled (false); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteVymLink() ) ); insilmaril@808: actionDeleteVymLink=a; insilmaril@808: insilmaril@808: a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Hide object in exports" ) ); insilmaril@808: a->setShortcut (Qt::Key_H ); insilmaril@808: a->setToggleAction(true); insilmaril@808: tb->addAction (a); insilmaril@808: a->setEnabled (false); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) ); insilmaril@808: actionToggleHideExport=a; insilmaril@808: insilmaril@808: a = new QAction(tr( "Add timestamp","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Add timestamp" )); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: a->setShortcut ( Qt::Key_T ); // Add timestamp insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: addAction(a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) ); insilmaril@808: actionAddTimestamp=a; insilmaril@808: insilmaril@808: a = new QAction(tr( "Edit Map Info...","Edit menu" ),this); insilmaril@808: a->setStatusTip ( tr( "Edit Map Info" )); insilmaril@808: a->setEnabled (true); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editMapInfo() ) ); insilmaril@808: actionMapInfo=a; insilmaril@808: insilmaril@808: // Import at selection (adding to selection) insilmaril@808: a = new QAction( tr( "Add map (insert)","Edit menu" ),this); insilmaril@808: a->setStatusTip (tr( "Add map at selection" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editImportAdd() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionImportAdd=a; insilmaril@808: insilmaril@808: // Import at selection (replacing selection) insilmaril@808: a = new QAction( tr( "Add map (replace)","Edit menu" ), this); insilmaril@808: a->setStatusTip (tr( "Replace selection with map" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editImportReplace() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionImportReplace=a; insilmaril@808: insilmaril@808: // Save selection insilmaril@808: a = new QAction( tr( "Save selection","Edit menu" ), this); insilmaril@808: a->setStatusTip (tr( "Save selection" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editSaveBranch() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionSaveBranch=a; insilmaril@808: insilmaril@808: // Only remove branch, not its children insilmaril@808: a = new QAction(tr( "Remove only branch ","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Remove only branch and keep its children" )); insilmaril@808: a->setShortcut (Qt::ALT + Qt::Key_Delete ); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteKeepChildren() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: addAction (a); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionDeleteKeepChildren=a; insilmaril@808: insilmaril@808: // Only remove children of a branch insilmaril@808: a = new QAction( tr( "Remove children","Edit menu" ), this); insilmaril@808: a->setStatusTip (tr( "Remove children of branch" )); insilmaril@808: a->setShortcut (Qt::SHIFT + Qt::Key_Delete ); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editDeleteChildren() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionDeleteChildren=a; insilmaril@808: insilmaril@808: a = new QAction( tr( "Add Image...","Edit menu" ), this); insilmaril@808: a->setStatusTip (tr( "Add Image" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( editLoadImage() ) ); insilmaril@808: actionLoadImage=a; insilmaril@808: insilmaril@808: a = new QAction( tr( "Property window","Dialog to edit properties of selection" )+QString ("..."), this); insilmaril@808: a->setStatusTip (tr( "Set properties for selection" )); insilmaril@808: a->setShortcut ( Qt::CTRL + Qt::Key_I ); //Property window insilmaril@808: a->setShortcutContext (Qt::WindowShortcut); insilmaril@808: a->setToggleAction (true); insilmaril@808: addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( windowToggleProperty() ) ); insilmaril@808: actionViewTogglePropertyWindow=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Format Actions insilmaril@0: void Main::setupFormatActions() insilmaril@0: { insilmaril@808: QMenu *formatMenu = menuBar()->addMenu (tr ("F&ormat","Format menu")); insilmaril@808: insilmaril@808: QToolBar *tb = addToolBar( tr("Format Actions","Format Toolbar name")); insilmaril@808: tb->setObjectName ("formatTB"); insilmaril@808: QAction *a; insilmaril@808: QPixmap pix( 16,16); insilmaril@808: pix.fill (Qt::black); insilmaril@808: a= new QAction(pix, tr( "Set &Color" )+QString("..."), this); insilmaril@808: a->setStatusTip ( tr( "Set Color" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectColor() ) ); insilmaril@808: a->addTo( tb ); insilmaril@808: formatMenu->addAction (a); insilmaril@808: actionFormatColor=a; insilmaril@808: a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color","Edit menu" ), this); insilmaril@808: a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) ); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_K ); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatPickColor() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: a->addTo( tb ); insilmaril@808: formatMenu->addAction (a); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionFormatPickColor=a; insilmaril@808: insilmaril@808: a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color &branch","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Color branch" ) ); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_B); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatColorBranch() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: a->addTo( tb ); insilmaril@808: formatMenu->addAction (a); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionFormatColorSubtree=a; insilmaril@808: insilmaril@808: a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this); insilmaril@808: a->setStatusTip ( tr( "Color Subtree" )); insilmaril@808: //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) ); insilmaril@808: a->setEnabled (false); insilmaril@808: formatMenu->addAction (a); insilmaril@808: a->addTo( tb ); insilmaril@808: actionListBranches.append(a); insilmaril@808: actionFormatColorSubtree=a; insilmaril@808: insilmaril@808: formatMenu->addSeparator(); insilmaril@808: actionGroupFormatLinkStyles=new QActionGroup ( this); insilmaril@808: actionGroupFormatLinkStyles->setExclusive (true); insilmaril@808: a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles); insilmaril@808: a->setStatusTip (tr( "Line" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleLine() ) ); insilmaril@808: formatMenu->addAction (a); insilmaril@808: actionFormatLinkStyleLine=a; insilmaril@808: a= new QAction( tr( "Linkstyle Curve" ), actionGroupFormatLinkStyles); insilmaril@808: a->setStatusTip (tr( "Line" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStyleParabel() ) ); insilmaril@808: formatMenu->addAction (a); insilmaril@808: actionFormatLinkStyleParabel=a; insilmaril@808: a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles ); insilmaril@808: a->setStatusTip (tr( "PolyLine" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyLine() ) ); insilmaril@808: formatMenu->addAction (a); insilmaril@808: actionFormatLinkStylePolyLine=a; insilmaril@808: a= new QAction( tr( "Linkstyle Thick Curve" ), actionGroupFormatLinkStyles); insilmaril@808: a->setStatusTip (tr( "PolyParabel" ) ); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked (true); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatLinkStylePolyParabel() ) ); insilmaril@808: formatMenu->addAction (a); insilmaril@808: actionFormatLinkStylePolyParabel=a; insilmaril@808: insilmaril@808: a = new QAction( tr( "Hide link if object is not selected","Branch attribute" ), this); insilmaril@808: a->setStatusTip (tr( "Hide link" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatHideLinkUnselected() ) ); insilmaril@808: actionFormatHideLinkUnselected=a; insilmaril@808: insilmaril@808: formatMenu->addSeparator(); insilmaril@808: a= new QAction( tr( "&Use color of heading for link","Branch attribute" ), this); insilmaril@808: a->setStatusTip (tr( "Use same color for links and headings" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatToggleLinkColorHint() ) ); insilmaril@808: formatMenu->addAction (a); insilmaril@808: actionFormatLinkColorHint=a; insilmaril@808: insilmaril@808: pix.fill (Qt::white); insilmaril@808: a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this ); insilmaril@808: a->setStatusTip (tr( "Set Link Color" )); insilmaril@808: formatMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectLinkColor() ) ); insilmaril@808: actionFormatLinkColor=a; insilmaril@808: insilmaril@808: a= new QAction( pix, tr( "Set &Selection Color"+QString("...") ), this ); insilmaril@808: a->setStatusTip (tr( "Set Selection Color" )); insilmaril@808: formatMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectSelectionColor() ) ); insilmaril@808: actionFormatSelectionColor=a; insilmaril@808: insilmaril@808: a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this ); insilmaril@808: a->setStatusTip (tr( "Set Background Color" )); insilmaril@808: formatMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) ); insilmaril@808: actionFormatBackColor=a; insilmaril@808: insilmaril@808: a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this ); insilmaril@808: a->setStatusTip (tr( "Set Background image" )); insilmaril@808: formatMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) ); insilmaril@808: actionFormatBackImage=a; insilmaril@0: } insilmaril@0: insilmaril@0: // View Actions insilmaril@0: void Main::setupViewActions() insilmaril@0: { insilmaril@808: QToolBar *tb = addToolBar( tr("View Actions","View Toolbar name") ); insilmaril@808: tb->setLabel( "View Actions" ); insilmaril@808: tb->setObjectName ("viewTB"); insilmaril@808: QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" )); insilmaril@808: insilmaril@819: Switchboard switchboard; //FIXME-2 testing... insilmaril@808: insilmaril@808: QAction *a; insilmaril@808: a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this); insilmaril@808: a->setStatusTip ( tr( "Zoom reset" ) ); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom insilmaril@808: switchboard.addConnection(a,"CTRL+0"); insilmaril@808: a->addTo( tb ); insilmaril@808: viewMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) ); insilmaril@808: insilmaril@808: a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this); insilmaril@808: a->setStatusTip (tr( "Zoom in" )); insilmaril@808: switchboard.addConnection(a,"CTRL++"); insilmaril@808: a->addTo( tb ); insilmaril@808: viewMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) ); insilmaril@808: insilmaril@808: a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this); insilmaril@808: a->setStatusTip (tr( "Zoom out" )); insilmaril@808: switchboard.addConnection(a,"CTRL+-"); insilmaril@808: a->addTo( tb ); insilmaril@808: viewMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) ); insilmaril@808: insilmaril@808: a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this); insilmaril@808: a->setStatusTip (tr( "Show selection" )); insilmaril@808: switchboard.addConnection(a,"."); insilmaril@808: a->addTo( tb ); insilmaril@808: viewMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) ); insilmaril@808: insilmaril@808: viewMenu->addSeparator(); insilmaril@808: insilmaril@808: a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this); insilmaril@808: a->setStatusTip ( tr( "Show Note Editor" )); insilmaril@808: a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor insilmaril@808: a->setToggleAction(true); insilmaril@808: a->addTo( tb ); insilmaril@808: viewMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) ); insilmaril@808: actionViewToggleNoteEditor=a; insilmaril@808: insilmaril@808: a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this ); insilmaril@808: a->setStatusTip ( tr( "Show History Window" )); insilmaril@808: a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window insilmaril@808: a->setToggleAction(true); insilmaril@808: a->addTo( tb ); insilmaril@808: viewMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); insilmaril@808: actionViewToggleHistoryWindow=a; insilmaril@808: insilmaril@808: viewMenu->addAction (actionViewTogglePropertyWindow); insilmaril@808: insilmaril@808: viewMenu->addSeparator(); insilmaril@808: insilmaril@808: a = new QAction(tr( "Antialiasing","View action" ),this ); insilmaril@808: a->setStatusTip ( tr( "Antialiasing" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked (settings.value("/mainwindow/view/AntiAlias",true).toBool()); insilmaril@808: viewMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) ); insilmaril@808: actionViewToggleAntiAlias=a; insilmaril@808: insilmaril@808: a = new QAction(tr( "Smooth pixmap transformations","View action" ),this ); insilmaril@808: a->setStatusTip (a->text()); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool()); insilmaril@808: viewMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) ); insilmaril@808: actionViewToggleSmoothPixmapTransform=a; insilmaril@808: insilmaril@808: a = new QAction(tr( "Next Map","View action" ), this); insilmaril@808: a->setStatusTip (a->text()); insilmaril@808: a->setShortcut (Qt::ALT + Qt::Key_N ); insilmaril@808: viewMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) ); insilmaril@808: insilmaril@808: a = new QAction (tr( "Previous Map","View action" ), this ); insilmaril@808: a->setStatusTip (a->text()); insilmaril@808: a->setShortcut (Qt::ALT + Qt::Key_P ); insilmaril@808: viewMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) ); insilmaril@808: insilmaril@813: if (debug) switchboard.print(); insilmaril@0: } insilmaril@0: insilmaril@89: // Mode Actions insilmaril@89: void Main::setupModeActions() insilmaril@89: { insilmaril@808: //QPopupMenu *menu = new QPopupMenu( this ); insilmaril@808: //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu ); insilmaril@808: insilmaril@808: QToolBar *tb = addToolBar( tr ("Modes when using modifiers","Modifier Toolbar name") ); insilmaril@808: tb->setObjectName ("modesTB"); insilmaril@808: QAction *a; insilmaril@808: actionGroupModModes=new QActionGroup ( this); insilmaril@808: actionGroupModModes->setExclusive (true); insilmaril@808: a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches","Mode modifier" ), actionGroupModModes); insilmaril@808: a->setShortcut (Qt::Key_J); insilmaril@808: a->setStatusTip ( tr( "Use modifier to color branches" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->addTo (tb); insilmaril@808: a->setChecked(true); insilmaril@808: actionModModeColor=a; insilmaril@808: insilmaril@808: a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy","Mode modifier" ), actionGroupModModes ); insilmaril@808: a->setShortcut( Qt::Key_K); insilmaril@808: a->setStatusTip( tr( "Use modifier to copy" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->addTo (tb); insilmaril@808: actionModModeCopy=a; insilmaril@808: insilmaril@808: a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks","Mode modifier" ), actionGroupModModes ); insilmaril@808: a->setShortcut (Qt::Key_L); insilmaril@808: a->setStatusTip( tr( "Use modifier to draw xLinks" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->addTo (tb); insilmaril@808: actionModModeXLink=a; insilmaril@89: } insilmaril@89: insilmaril@0: // Flag Actions insilmaril@0: void Main::setupFlagActions() insilmaril@0: { insilmaril@808: // Create System Flags insilmaril@808: QToolBar *tb=NULL; insilmaril@808: insilmaril@808: Flag *flag=new Flag;; insilmaril@808: flag->setVisible(true); insilmaril@808: insilmaril@808: flag->load(QPixmap(flagsPath+"flag-note.png")); insilmaril@808: setupFlag (flag,tb,"system-note",tr("Note","SystemFlag")); insilmaril@808: insilmaril@808: flag->load(QPixmap(flagsPath+"flag-url.png")); insilmaril@808: setupFlag (flag,tb,"system-url",tr("URL to Document ","SystemFlag")); insilmaril@808: insilmaril@808: flag->load(QPixmap(flagsPath+"flag-vymlink.png")); insilmaril@808: setupFlag (flag,tb,"system-vymLink",tr("Link to another vym map","SystemFlag")); insilmaril@808: insilmaril@808: flag->load(QPixmap(flagsPath+"flag-scrolled-right.png")); insilmaril@808: setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag")); insilmaril@808: insilmaril@808: flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png")); insilmaril@808: setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag")); insilmaril@808: insilmaril@808: flag->load(QPixmap(flagsPath+"flag-hideexport.png")); insilmaril@808: setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag")); insilmaril@808: insilmaril@808: // Create Standard Flags insilmaril@808: tb=addToolBar (tr ("Standard Flags","Standard Flag Toolbar")); insilmaril@808: tb->setObjectName ("standardFlagTB"); insilmaril@808: standardFlagsMaster->setToolBar (tb); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-exclamationmark.png"); insilmaril@808: flag->setGroup("standard-mark"); insilmaril@808: setupFlag (flag,tb,"exclamationmark",tr("Take care!","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-questionmark.png"); insilmaril@808: flag->setGroup("standard-mark"); insilmaril@808: setupFlag (flag,tb,"questionmark",tr("Really?","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-hook-green.png"); insilmaril@815: flag->setGroup("standard-status"); insilmaril@815: setupFlag (flag,tb,"hook-green",tr("Status - ok,done","Standardflag")); insilmaril@815: insilmaril@815: flag->load(flagsPath+"flag-wip.png"); insilmaril@815: flag->setGroup("standard-status"); insilmaril@815: setupFlag (flag,tb,"wip",tr("Status - work in progress","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-cross-red.png"); insilmaril@815: flag->setGroup("standard-status"); insilmaril@815: setupFlag (flag,tb,"cross-red",tr("Status - missing, not started","Standardflag")); insilmaril@808: flag->unsetGroup(); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-stopsign.png"); insilmaril@808: setupFlag (flag,tb,"stopsign",tr("This won't work!","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-smiley-good.png"); insilmaril@808: flag->setGroup("standard-smiley"); insilmaril@808: setupFlag (flag,tb,"smiley-good",tr("Good","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-smiley-sad.png"); insilmaril@808: flag->setGroup("standard-smiley"); insilmaril@808: setupFlag (flag,tb,"smiley-sad",tr("Bad","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-smiley-omg.png"); insilmaril@808: flag->setGroup("standard-smiley"); insilmaril@808: setupFlag (flag,tb,"smiley-omb",tr("Oh no!","Standardflag")); insilmaril@808: // Original omg.png (in KDE emoticons) insilmaril@808: flag->unsetGroup(); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-kalarm.png"); insilmaril@808: setupFlag (flag,tb,"clock",tr("Time critical","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-phone.png"); insilmaril@808: setupFlag (flag,tb,"phone",tr("Call...","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-lamp.png"); insilmaril@808: setupFlag (flag,tb,"lamp",tr("Idea!","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-arrow-up.png"); insilmaril@808: flag->setGroup("standard-arrow"); insilmaril@808: setupFlag (flag,tb,"arrow-up",tr("Important","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-arrow-down.png"); insilmaril@808: flag->setGroup("standard-arrow"); insilmaril@808: setupFlag (flag,tb,"arrow-down",tr("Unimportant","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-arrow-2up.png"); insilmaril@808: flag->setGroup("standard-arrow"); insilmaril@808: setupFlag (flag,tb,"2arrow-up",tr("Very important!","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-arrow-2down.png"); insilmaril@808: flag->setGroup("standard-arrow"); insilmaril@808: setupFlag (flag,tb,"2arrow-down",tr("Very unimportant!","Standardflag")); insilmaril@808: flag->unsetGroup(); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-thumb-up.png"); insilmaril@808: flag->setGroup("standard-thumb"); insilmaril@808: setupFlag (flag,tb,"thumb-up",tr("I like this","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-thumb-down.png"); insilmaril@808: flag->setGroup("standard-thumb"); insilmaril@808: setupFlag (flag,tb,"thumb-down",tr("I do not like this","Standardflag")); insilmaril@808: flag->unsetGroup(); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-rose.png"); insilmaril@808: setupFlag (flag,tb,"rose",tr("Rose","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-heart.png"); insilmaril@808: setupFlag (flag,tb,"heart",tr("I just love...","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-present.png"); insilmaril@808: setupFlag (flag,tb,"present",tr("Surprise!","Standardflag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"flag-flash.png"); insilmaril@808: setupFlag (flag,tb,"flash",tr("Dangerous","Standardflag")); insilmaril@808: insilmaril@808: // Original: xsldbg_output.png insilmaril@808: flag->load(flagsPath+"flag-info.png"); insilmaril@808: setupFlag (flag,tb,"info",tr("Info","Standardflag")); insilmaril@808: insilmaril@808: // Original khelpcenter.png insilmaril@808: flag->load(flagsPath+"flag-lifebelt.png"); insilmaril@808: setupFlag (flag,tb,"lifebelt",tr("This will help","Standardflag")); insilmaril@808: insilmaril@808: // Freemind flags insilmaril@808: flag->setVisible(false); insilmaril@808: flag->load(flagsPath+"freemind/warning.png"); insilmaril@808: setupFlag (flag,tb, "freemind-warning",tr("Important","Freemind-Flag")); insilmaril@808: insilmaril@808: for (int i=1; i<8; i++) insilmaril@808: { insilmaril@808: flag->load(flagsPath+QString("freemind/priority-%1.png").arg(i)); insilmaril@808: setupFlag (flag,tb, QString("freemind-priority-%1").arg(i),tr("Priority","Freemind-Flag")); insilmaril@808: } insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/back.png"); insilmaril@808: setupFlag (flag,tb,"freemind-back",tr("Back","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/forward.png"); insilmaril@808: setupFlag (flag,tb,"freemind-forward",tr("forward","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/attach.png"); insilmaril@808: setupFlag (flag,tb,"freemind-attach",tr("Look here","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/clanbomber.png"); insilmaril@808: setupFlag (flag,tb,"freemind-clanbomber",tr("Dangerous","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/desktopnew.png"); insilmaril@808: setupFlag (flag,tb,"freemind-desktopnew",tr("Don't flagrget","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/flag.png"); insilmaril@808: setupFlag (flag,tb,"freemind-flag",tr("Flag","Freemind-Flag")); insilmaril@808: insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/gohome.png"); insilmaril@808: setupFlag (flag,tb,"freemind-gohome",tr("Home","Freemind-Flag")); insilmaril@808: insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/kaddressbook.png"); insilmaril@808: setupFlag (flag,tb,"freemind-kaddressbook",tr("Telephone","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/knotify.png"); insilmaril@808: setupFlag (flag,tb,"freemind-knotify",tr("Music","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/korn.png"); insilmaril@808: setupFlag (flag,tb,"freemind-korn",tr("Mailbox","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/mail.png"); insilmaril@808: setupFlag (flag,tb,"freemind-mail",tr("Maix","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/password.png"); insilmaril@808: setupFlag (flag,tb,"freemind-password",tr("Password","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/pencil.png"); insilmaril@808: setupFlag (flag,tb,"freemind-pencil",tr("To be improved","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/stop.png"); insilmaril@808: setupFlag (flag,tb,"freemind-stop",tr("Stop","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/wizard.png"); insilmaril@808: setupFlag (flag,tb,"freemind-wizard",tr("Magic","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/xmag.png"); insilmaril@808: setupFlag (flag,tb,"freemind-xmag",tr("To be discussed","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/bell.png"); insilmaril@808: setupFlag (flag,tb,"freemind-bell",tr("Reminder","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/bookmark.png"); insilmaril@808: setupFlag (flag,tb,"freemind-bookmark",tr("Excellent","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/penguin.png"); insilmaril@808: setupFlag (flag,tb,"freemind-penguin",tr("Linux","Freemind-Flag")); insilmaril@808: insilmaril@808: flag->load(flagsPath+"freemind/licq.png"); insilmaril@808: 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@808: flag->setName(name); insilmaril@808: flag->setToolTip (tooltip); insilmaril@808: QAction *a; insilmaril@808: if (tb) insilmaril@808: { insilmaril@808: a=new QAction (flag->getPixmap(),name,this); insilmaril@808: // StandardFlag insilmaril@808: tb->addAction (a); insilmaril@808: flag->setAction (a); insilmaril@808: a->setVisible (flag->isVisible()); insilmaril@808: a->setCheckable(true); insilmaril@808: a->setObjectName(name); insilmaril@808: a->setToolTip(tooltip); insilmaril@808: connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); insilmaril@808: standardFlagsMaster->addFlag (flag); insilmaril@808: } else insilmaril@808: { insilmaril@808: // SystemFlag insilmaril@808: systemFlagsMaster->addFlag (flag); insilmaril@808: } insilmaril@0: } insilmaril@767: insilmaril@528: // Network Actions insilmaril@528: void Main::setupNetworkActions() insilmaril@528: { insilmaril@808: if (!settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@808: return; insilmaril@808: QMenu *netMenu = menuBar()->addMenu( "Network" ); insilmaril@808: insilmaril@808: QAction *a; insilmaril@808: insilmaril@808: a = new QAction( "Start TCPserver for MapEditor",this); insilmaril@808: //a->setStatusTip ( "Set application to open pdf files")); insilmaril@808: //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) ); insilmaril@808: netMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( "Connect MapEditor to server",this); insilmaril@808: //a->setStatusTip ( "Set application to open pdf files")); insilmaril@808: a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) ); insilmaril@808: netMenu->addAction (a); insilmaril@528: } insilmaril@807: insilmaril@0: // Settings Actions insilmaril@0: void Main::setupSettingsActions() insilmaril@0: { insilmaril@808: QMenu *settingsMenu = menuBar()->addMenu( tr( "&Settings" )); insilmaril@808: insilmaril@808: QAction *a; insilmaril@808: insilmaril@808: a = new QAction( tr( "Set application to open pdf files","Settings action"), this); insilmaril@808: a->setStatusTip ( tr( "Set application to open pdf files")); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( settingsPDF() ) ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( tr( "Set application to open external links","Settings action"), this); insilmaril@808: a->setStatusTip( tr( "Set application to open external links")); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( settingsURL() ) ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( tr( "Set path for macros","Settings action")+"...", this); insilmaril@808: a->setStatusTip( tr( "Set path for macros")); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( settingsMacroDir() ) ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( tr( "Set number of undo levels","Settings action")+"...", this); insilmaril@808: a->setStatusTip( tr( "Set number of undo levels")); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( settingsUndoLevels() ) ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: insilmaril@808: settingsMenu->addSeparator(); insilmaril@808: insilmaril@808: a = new QAction( tr( "Autosave","Settings action"), this); insilmaril@808: a->setStatusTip( tr( "Autosave")); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked ( settings.value ("/mainwindow/autosave/use",false).toBool()); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: actionSettingsAutosaveToggle=a; insilmaril@808: insilmaril@808: a = new QAction( tr( "Autosave time","Settings action")+"...", this); insilmaril@808: a->setStatusTip( tr( "Autosave time")); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveTime() ) ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: actionSettingsAutosaveTime=a; insilmaril@808: insilmaril@808: a = new QAction( tr( "Write backup file on save","Settings action"), this); insilmaril@808: a->setStatusTip( tr( "Write backup file on save")); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked ( settings.value ("/mainwindow/writeBackupFile",false).toBool()); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( settingsWriteBackupFileToggle() ) ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: actionSettingsWriteBackupFile=a; insilmaril@808: insilmaril@808: settingsMenu->addSeparator(); insilmaril@808: insilmaril@808: a = new QAction( tr( "Edit branch after adding it","Settings action" ), this ); insilmaril@808: a->setStatusTip( tr( "Edit branch after adding it" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked ( settings.value ("/mapeditor/editmode/autoEditNewBranch",true).toBool()); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: actionSettingsAutoEditNewBranch=a; insilmaril@808: insilmaril@808: a= new QAction( tr( "Select branch after adding it","Settings action" ), this ); insilmaril@808: a->setStatusTip( tr( "Select branch after adding it" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectNewBranch",false).toBool() ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: actionSettingsAutoSelectNewBranch=a; insilmaril@808: insilmaril@808: a= new QAction(tr( "Select existing heading","Settings action" ), this); insilmaril@808: a->setStatusTip( tr( "Select heading before editing" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked ( settings.value ("/mapeditor/editmode/autoSelectText",true).toBool() ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: actionSettingsAutoSelectText=a; insilmaril@808: insilmaril@808: a= new QAction( tr( "Delete key","Settings action" ), this); insilmaril@808: a->setStatusTip( tr( "Delete key for deleting branches" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked ( settings.value ("/mapeditor/editmode/useDelKey",true).toBool() ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleDelKey() ) ); insilmaril@808: actionSettingsUseDelKey=a; insilmaril@808: insilmaril@808: a= new QAction( tr( "Exclusive flags","Settings action" ), this); insilmaril@808: a->setStatusTip( tr( "Use exclusive flags in flag toolbars" )); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked ( settings.value ("/mapeditor/editmode/useFlagGroups",true).toBool() ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: actionSettingsUseFlagGroups=a; insilmaril@808: insilmaril@808: a= new QAction( tr( "Use hide flags","Settings action" ), this); insilmaril@808: a->setStatusTip( tr( "Use hide flag during exports " )); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked ( settings.value ("/export/useHideExport",true).toBool() ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: actionSettingsUseHideExport=a; insilmaril@808: insilmaril@808: a = new QAction( tr( "Animation","Settings action"), this); insilmaril@808: a->setStatusTip( tr( "Animation")); insilmaril@808: a->setToggleAction(true); insilmaril@808: a->setChecked (settings.value("/animation/use",true).toBool() ); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( settingsToggleAnimation() ) ); insilmaril@808: settingsMenu->addAction (a); insilmaril@808: actionSettingsUseAnimation=a; insilmaril@0: } insilmaril@0: insilmaril@0: // Test Actions insilmaril@0: void Main::setupTestActions() insilmaril@0: { insilmaril@808: QMenu *testMenu = menuBar()->addMenu( tr( "&Test" )); insilmaril@808: insilmaril@808: QAction *a; insilmaril@808: a = new QAction( "Test function 1" , this); insilmaril@808: a->setStatusTip( "Call test function 1" ); insilmaril@808: a->setShortcut (Qt::CTRL + Qt::Key_T); // Test function 1 //FIXME-2 originally: color subtree insilmaril@808: testMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) ); insilmaril@808: insilmaril@808: a = new QAction( "Test function 2" , this); insilmaril@808: a->setStatusTip( "Call test function 2" ); insilmaril@808: a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 2 insilmaril@808: testMenu->addAction (a); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) ); insilmaril@808: insilmaril@808: a = new QAction( "Command" , this); insilmaril@808: a->setStatusTip( "Enter command to call in editor" ); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) ); insilmaril@808: testMenu->addAction (a); insilmaril@0: } insilmaril@0: insilmaril@0: // Help Actions insilmaril@0: void Main::setupHelpActions() insilmaril@0: { insilmaril@808: QMenu *helpMenu = menuBar()->addMenu ( tr( "&Help","Help menubar entry" )); insilmaril@808: insilmaril@808: QAction *a; insilmaril@808: a = new QAction( tr( "Open VYM Documentation (pdf) ","Help action" ), this ); insilmaril@808: a->setStatusTip( tr( "Open VYM Documentation (pdf)" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( helpDoc() ) ); insilmaril@808: helpMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( tr( "Open VYM example maps ","Help action" ), this ); insilmaril@808: a->setStatusTip( tr( "Open VYM example maps " )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( helpDemo() ) ); insilmaril@808: helpMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( tr( "About VYM","Help action" ), this); insilmaril@808: a->setStatusTip( tr( "About VYM")+vymName); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( helpAbout() ) ); insilmaril@808: helpMenu->addAction (a); insilmaril@808: insilmaril@808: a = new QAction( tr( "About QT","Help action" ), this); insilmaril@808: a->setStatusTip( tr( "Information about QT toolkit" )); insilmaril@808: connect( a, SIGNAL( triggered() ), this, SLOT( helpAboutQT() ) ); insilmaril@808: helpMenu->addAction (a); insilmaril@0: } insilmaril@0: insilmaril@0: // Context Menus insilmaril@0: void Main::setupContextMenus() insilmaril@0: { insilmaril@808: QAction*a; insilmaril@808: insilmaril@808: // Context Menu for branch or mapcenter insilmaril@808: branchContextMenu =new QMenu (this); insilmaril@808: branchContextMenu->addAction (actionViewTogglePropertyWindow); insilmaril@421: branchContextMenu->addSeparator(); insilmaril@808: insilmaril@808: // Submenu "Add" insilmaril@808: branchAddContextMenu =branchContextMenu->addMenu (tr("Add")); insilmaril@808: branchAddContextMenu->addAction (actionPaste ); insilmaril@808: branchAddContextMenu->addAction ( actionAddMapCenter ); insilmaril@808: branchAddContextMenu->addAction ( actionAddBranch ); insilmaril@808: branchAddContextMenu->addAction ( actionAddBranchBefore ); insilmaril@808: branchAddContextMenu->addAction ( actionAddBranchAbove); insilmaril@808: branchAddContextMenu->addAction ( actionAddBranchBelow ); insilmaril@808: branchAddContextMenu->addSeparator(); insilmaril@808: branchAddContextMenu->addAction ( actionImportAdd ); insilmaril@808: branchAddContextMenu->addAction ( actionImportReplace ); insilmaril@808: insilmaril@808: // Submenu "Remove" insilmaril@808: branchRemoveContextMenu =branchContextMenu->addMenu (tr ("Remove","Context menu name")); insilmaril@808: branchRemoveContextMenu->addAction (actionCut); insilmaril@808: branchRemoveContextMenu->addAction ( actionDelete ); insilmaril@808: branchRemoveContextMenu->addAction ( actionDeleteKeepChildren ); insilmaril@808: branchRemoveContextMenu->addAction ( actionDeleteChildren ); insilmaril@808: insilmaril@808: insilmaril@808: actionSaveBranch->addTo( branchContextMenu ); insilmaril@808: actionFileNewCopy->addTo (branchContextMenu ); insilmaril@808: actionDetach->addTo (branchContextMenu ); insilmaril@808: insilmaril@808: branchContextMenu->addSeparator(); insilmaril@808: branchContextMenu->addAction ( actionLoadImage); insilmaril@818: if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@818: branchContextMenu->addAction ( actionAddAttribute); insilmaril@808: insilmaril@808: // Submenu for Links (URLs, vymLinks) insilmaril@808: branchLinksContextMenu =new QMenu (this); insilmaril@808: insilmaril@808: branchContextMenu->addSeparator(); insilmaril@808: branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name")); insilmaril@808: branchLinksContextMenu->addAction ( actionOpenURL ); insilmaril@808: branchLinksContextMenu->addAction ( actionOpenURLTab ); insilmaril@821: branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs ); insilmaril@808: branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs ); insilmaril@808: branchLinksContextMenu->addAction ( actionURL ); insilmaril@808: branchLinksContextMenu->addAction ( actionLocalURL ); insilmaril@808: branchLinksContextMenu->addAction ( actionHeading2URL ); insilmaril@808: branchLinksContextMenu->addAction ( actionBugzilla2URL ); insilmaril@808: if (settings.value( "/mainwindow/showTestMenu",false).toBool() ) insilmaril@808: { insilmaril@820: branchLinksContextMenu->addAction ( actionGetBugzillaData ); insilmaril@808: branchLinksContextMenu->addAction ( actionFATE2URL ); insilmaril@808: } insilmaril@808: branchLinksContextMenu->addSeparator(); insilmaril@808: branchLinksContextMenu->addAction ( actionOpenVymLink ); insilmaril@808: branchLinksContextMenu->addAction ( actionOpenMultipleVymLinks ); insilmaril@808: branchLinksContextMenu->addAction ( actionVymLink ); insilmaril@808: branchLinksContextMenu->addAction ( actionDeleteVymLink ); insilmaril@808: insilmaril@808: insilmaril@808: // Context Menu for XLinks in a branch menu insilmaril@808: // This will be populated "on demand" in MapEditor::updateActions insilmaril@808: branchContextMenu->addSeparator(); insilmaril@808: branchXLinksContextMenuEdit =branchContextMenu->addMenu (tr ("Edit XLink","Context menu name")); insilmaril@808: connect( branchXLinksContextMenuEdit, SIGNAL( triggered(QAction *) ), this, SLOT( editEditXLink(QAction * ) ) ); insilmaril@808: insilmaril@808: insilmaril@808: // Context menu for floatimage insilmaril@808: floatimageContextMenu =new QMenu (this); insilmaril@808: a= new QAction (tr ("Save image","Context action"),this); insilmaril@808: connect (a, SIGNAL (triggered()), this, SLOT (editSaveImage())); insilmaril@808: floatimageContextMenu->addAction (a); insilmaril@808: insilmaril@808: floatimageContextMenu->addSeparator(); insilmaril@808: actionCopy->addTo( floatimageContextMenu ); insilmaril@808: actionCut->addTo( floatimageContextMenu ); insilmaril@808: insilmaril@808: floatimageContextMenu->addSeparator(); insilmaril@808: floatimageContextMenu->addAction ( actionFormatHideLinkUnselected ); insilmaril@808: insilmaril@808: insilmaril@808: // Context menu for canvas insilmaril@808: canvasContextMenu =new QMenu (this); insilmaril@808: actionAddMapCenter->addTo( canvasContextMenu ); insilmaril@808: actionMapInfo->addTo( canvasContextMenu ); insilmaril@808: canvasContextMenu->insertSeparator(); insilmaril@808: actionGroupFormatLinkStyles->addTo( canvasContextMenu ); insilmaril@808: canvasContextMenu->insertSeparator(); insilmaril@808: actionFormatLinkColorHint->addTo( canvasContextMenu ); insilmaril@808: actionFormatLinkColor->addTo( canvasContextMenu ); insilmaril@808: actionFormatSelectionColor->addTo( canvasContextMenu ); insilmaril@808: actionFormatBackColor->addTo( canvasContextMenu ); insilmaril@808: // actionFormatBackImage->addTo( canvasContextMenu ); //FIXME-4 makes vym too slow: postponed for later version insilmaril@808: insilmaril@808: // Menu for last opened files insilmaril@808: // Create actions insilmaril@808: for (int i = 0; i < MaxRecentFiles; ++i) insilmaril@807: { insilmaril@808: recentFileActions[i] = new QAction(this); insilmaril@808: recentFileActions[i]->setVisible(false); insilmaril@808: fileLastMapsMenu->addAction(recentFileActions[i]); insilmaril@808: connect(recentFileActions[i], SIGNAL(triggered()), insilmaril@808: this, SLOT(fileLoadRecent())); insilmaril@808: } insilmaril@808: setupRecentMapsMenu(); insilmaril@0: } insilmaril@0: insilmaril@401: void Main::setupRecentMapsMenu() insilmaril@0: { insilmaril@808: QStringList files = settings.value("/mainwindow/recentFileList").toStringList(); insilmaril@808: insilmaril@808: int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); insilmaril@808: insilmaril@808: for (int i = 0; i < numRecentFiles; ++i) { insilmaril@808: QString text = tr("&%1 %2").arg(i + 1).arg(files[i]); insilmaril@808: recentFileActions[i]->setText(text); insilmaril@808: recentFileActions[i]->setData(files[i]); insilmaril@808: recentFileActions[i]->setVisible(true); insilmaril@808: } insilmaril@808: for (int j = numRecentFiles; j < MaxRecentFiles; ++j) insilmaril@808: recentFileActions[j]->setVisible(false); insilmaril@445: } insilmaril@445: insilmaril@445: void Main::setupMacros() insilmaril@445: { insilmaril@808: for (int i = 0; i <= 11; i++) insilmaril@808: { insilmaril@808: macroActions[i] = new QAction(this); insilmaril@808: macroActions[i]->setData(i); insilmaril@808: addAction (macroActions[i]); insilmaril@808: connect(macroActions[i], SIGNAL(triggered()), insilmaril@808: this, SLOT(callMacro())); insilmaril@808: } insilmaril@808: macroActions[0]->setShortcut ( Qt::Key_F1 ); insilmaril@808: macroActions[1]->setShortcut ( Qt::Key_F2 ); insilmaril@808: macroActions[2]->setShortcut ( Qt::Key_F3 ); insilmaril@808: macroActions[3]->setShortcut ( Qt::Key_F4 ); insilmaril@808: macroActions[4]->setShortcut ( Qt::Key_F5 ); insilmaril@808: macroActions[5]->setShortcut ( Qt::Key_F6 ); insilmaril@808: macroActions[6]->setShortcut ( Qt::Key_F7 ); insilmaril@808: macroActions[7]->setShortcut ( Qt::Key_F8 ); insilmaril@808: macroActions[8]->setShortcut ( Qt::Key_F9 ); insilmaril@808: macroActions[9]->setShortcut ( Qt::Key_F10 ); insilmaril@808: macroActions[10]->setShortcut ( Qt::Key_F11 ); insilmaril@808: macroActions[11]->setShortcut ( Qt::Key_F12 ); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::hideEvent (QHideEvent * ) insilmaril@0: { insilmaril@808: if (!textEditor->isMinimized() ) textEditor->hide(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::showEvent (QShowEvent * ) insilmaril@0: { insilmaril@808: if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal(); insilmaril@0: } insilmaril@0: insilmaril@0: insilmaril@0: MapEditor* Main::currentMapEditor() const insilmaril@0: { insilmaril@808: if ( tabWidget->currentPage()) insilmaril@808: return vymViews.at(tabWidget->currentIndex())->getMapEditor(); insilmaril@808: return NULL; insilmaril@0: } insilmaril@0: insilmaril@721: VymModel* Main::currentModel() const insilmaril@721: { insilmaril@808: if ( tabWidget->currentPage()) insilmaril@808: return vymViews.at(tabWidget->currentIndex())->getModel(); insilmaril@808: return NULL; insilmaril@721: } insilmaril@721: insilmaril@0: insilmaril@0: void Main::editorChanged(QWidget *) insilmaril@0: { insilmaril@808: // Unselect all possibly selected objects insilmaril@808: // (Important to update note editor) insilmaril@808: VymModel *m; insilmaril@808: for (int i=0;i<=tabWidget->count() -1;i++) insilmaril@808: { insilmaril@808: m= vymViews.at(i)->getModel(); insilmaril@808: if (m) m->unselect(); insilmaril@808: } insilmaril@808: m=currentModel(); insilmaril@808: if (m) m->reselect(); insilmaril@808: insilmaril@808: // Update actions to in menus and toolbars according to editor insilmaril@808: updateActions(); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::fileNew() insilmaril@0: { insilmaril@808: VymModel *vm=new VymModel; insilmaril@808: insilmaril@808: ///////////////////////////////////// insilmaril@816: // new ModelTest(vm, this); //FIXME-3 insilmaril@808: ///////////////////////////////////// insilmaril@808: insilmaril@808: VymView *vv=new VymView (vm); insilmaril@808: vymViews.append (vv); insilmaril@808: tabWidget->addTab (vv,tr("unnamed","MainWindow: name for new and empty file")); insilmaril@808: tabWidget->setCurrentIndex (vymViews.count() ); insilmaril@808: vv->initFocus(); insilmaril@808: insilmaril@808: // Create MapCenter for empty map insilmaril@808: vm->addMapCenter(); insilmaril@808: vm->makeDefault(); insilmaril@808: insilmaril@808: // For the very first map we do not have flagrows yet... insilmaril@808: vm->select("mc:"); insilmaril@0: } insilmaril@0: insilmaril@491: void Main::fileNewCopy() insilmaril@491: { insilmaril@808: QString fn="unnamed"; insilmaril@808: VymModel *srcModel=currentModel(); insilmaril@808: if (srcModel) insilmaril@808: { insilmaril@808: srcModel->copy(); insilmaril@808: fileNew(); insilmaril@808: VymModel *dstModel=vymViews.last()->getModel(); insilmaril@808: dstModel->select("mc:"); insilmaril@808: dstModel->load (clipboardDir+"/"+clipboardFile,ImportReplace, VymMap); insilmaril@808: } insilmaril@807: } insilmaril@807: insilmaril@807: ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode, const FileType &ftype) insilmaril@807: { insilmaril@808: ErrorCode err=success; insilmaril@808: insilmaril@808: // fn is usually the archive, mapfile the file after uncompressing insilmaril@808: QString mapfile; insilmaril@808: insilmaril@808: // Make fn absolute (needed for unzip) insilmaril@808: fn=QDir (fn).absPath(); insilmaril@808: insilmaril@808: VymModel *vm; insilmaril@808: insilmaril@808: if (lmode==NewMap) insilmaril@491: { insilmaril@808: // Check, if map is already loaded insilmaril@808: int i=0; insilmaril@808: while (i<=tabWidget->count() -1) insilmaril@807: { insilmaril@808: if (vymViews.at(i)->getModel()->getFilePath() == fn) insilmaril@807: { insilmaril@808: // Already there, ask for confirmation insilmaril@808: QMessageBox mb( vymName, insilmaril@808: tr("The map %1\nis already opened." insilmaril@808: "Opening the same map in multiple editors may lead \n" insilmaril@808: "to confusion when finishing working with vym." insilmaril@808: "Do you want to").arg(fn), insilmaril@808: QMessageBox::Warning, insilmaril@808: QMessageBox::Yes | QMessageBox::Default, insilmaril@808: QMessageBox::Cancel | QMessageBox::Escape, insilmaril@808: QMessageBox::NoButton); insilmaril@808: mb.setButtonText( QMessageBox::Yes, tr("Open anyway") ); insilmaril@808: mb.setButtonText( QMessageBox::Cancel, tr("Cancel")); insilmaril@808: switch( mb.exec() ) insilmaril@808: { insilmaril@808: case QMessageBox::Yes: insilmaril@808: // end loop and load anyway insilmaril@808: i=tabWidget->count(); insilmaril@808: break; insilmaril@808: case QMessageBox::Cancel: insilmaril@808: // do nothing insilmaril@808: return aborted; insilmaril@808: break; insilmaril@808: } insilmaril@807: } insilmaril@808: i++; insilmaril@807: } insilmaril@491: } insilmaril@808: insilmaril@808: 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@821: insilmaril@821: progressCounter=flist.count(); insilmaril@821: progressCounterTotal=flist.count(); 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@819: void Main::fileExportHTML() insilmaril@819: { insilmaril@819: VymModel *m=currentModel(); insilmaril@819: if (m) m->exportHTML(); insilmaril@819: } insilmaril@819: 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@807: void Main::fileExportAO() insilmaril@807: { insilmaril@807: VymModel *m=currentModel(); insilmaril@807: if (m) m->exportAO(); insilmaril@807: } insilmaril@807: 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@804: // FIXME-3 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@807: // Remove mapEditor/model FIXME-3 Huh? seems to work now... 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@807: delete (m->getMapEditor()); insilmaril@807: delete (m); insilmaril@807: 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@808: void Main::editOpenFindWidget() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@808: if (m) m->emitShowFindWidget(); insilmaril@0: } insilmaril@0: insilmaril@821: void Main::editFindDuplicateURLs() insilmaril@821: { insilmaril@821: VymModel *m=currentModel(); insilmaril@821: if (m) m->findDuplicateURLs(); insilmaril@821: } insilmaril@821: 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@821: //qDebug ()<<"Services: "<registeredServiceNames().value(); insilmaril@821: if (*browserPID==0 || insilmaril@821: (browser.contains("konqueror") && insilmaril@821: !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID))) insilmaril@821: ) insilmaril@366: { insilmaril@821: // Start a new browser, if there is not one running already or insilmaril@821: // if a previously started konqueror is gone. insilmaril@821: if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n"; insilmaril@366: QString u=urls.takeFirst(); insilmaril@366: args<")+tr("Set application to open an URL")); insilmaril@366: return; insilmaril@366: } insilmaril@804: if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<thread()->wait(3000); insilmaril@608: #else insilmaril@804: sleep (3); //FIXME-3 needed? insilmaril@608: #endif insilmaril@366: } insilmaril@804: insilmaril@366: if (browser.contains("konqueror")) insilmaril@366: { insilmaril@366: for (int i=0; ipid())<< insilmaril@608: "konqueror-mainwindow#1"<< insilmaril@608: "newTab" << insilmaril@608: urls.at(i); insilmaril@804: */ insilmaril@804: args<< QString("org.kde.konqueror-%1").arg(*browserPID)<< insilmaril@804: "/konqueror/MainWindow_1"<< insilmaril@804: "newTab" << insilmaril@804: urls.at(i)<< insilmaril@804: "false"; insilmaril@804: if (debug) cout << "MainWindow::openURLs args="<getURL(); insilmaril@366: QStringList args; insilmaril@266: if (url=="") return; insilmaril@366: QString browser=settings.value("/mainwindow/readerURL" ).toString(); insilmaril@366: args<startDetached(browser,args)) 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@821: insilmaril@821: void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled) insilmaril@366: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) insilmaril@366: { insilmaril@366: QStringList urls; insilmaril@821: urls=m->getURLs(ignoreScrolled); insilmaril@366: openTabs (urls); insilmaril@366: } insilmaril@366: } insilmaril@366: insilmaril@821: void Main::editOpenMultipleURLTabs() insilmaril@821: { insilmaril@821: editOpenMultipleVisURLTabs (false); insilmaril@821: } insilmaril@821: 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@820: void Main::getBugzillaData() insilmaril@820: { insilmaril@820: VymModel *m=currentModel(); insilmaril@821: /* insilmaril@821: QProgressDialog progress ("Doing stuff","cancl",0,10,this); insilmaril@821: progress.setWindowModality(Qt::WindowModal); insilmaril@821: //progress.setCancelButton (NULL); insilmaril@821: progress.show(); insilmaril@821: progress.setMinimumDuration (0); insilmaril@821: progress.setValue (1); insilmaril@821: progress.setValue (5); insilmaril@821: progress.update(); insilmaril@821: */ insilmaril@821: /* insilmaril@821: QProgressBar *pb=new QProgressBar; insilmaril@821: pb->setMinimum (0); insilmaril@821: pb->setMaximum (0); insilmaril@821: pb->show(); insilmaril@821: pb->repaint(); insilmaril@821: */ insilmaril@820: if (m) m->getBugzillaData(); insilmaril@820: } insilmaril@820: 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@804: void Main::editAddTimestamp() insilmaril@804: { insilmaril@804: VymModel *m=currentModel(); insilmaril@804: if (m) m->addTimestamp(); insilmaril@804: } insilmaril@804: insilmaril@0: void Main::editMapInfo() insilmaril@0: { insilmaril@721: VymModel *m=currentModel(); insilmaril@795: if (!m) return; 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@795: stats+=tr("%1 items on map\n","Info about map").arg (m->getScene()->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@795: BranchItem *cur=NULL; insilmaril@795: BranchItem *prev=NULL; insilmaril@804: m->nextBranch(cur,prev); insilmaril@795: while (cur) insilmaril@721: { insilmaril@795: if (!cur->getNote().isEmpty() ) n++; insilmaril@795: f+= cur->imageCount(); insilmaril@721: b++; insilmaril@795: xl+=cur->xlinkCount(); insilmaril@804: m->nextBranch(cur,prev); insilmaril@721: } insilmaril@795: 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@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@795: void Main::editDetach() insilmaril@795: { insilmaril@795: VymModel *m=currentModel(); insilmaril@795: if (m) m->detach(); insilmaril@795: } insilmaril@795: insilmaril@608: void Main::editSortChildren() insilmaril@608: { insilmaril@721: VymModel *m=currentModel(); insilmaril@822: if (m) m->sortChildren(false); insilmaril@822: } insilmaril@822: insilmaril@822: void Main::editSortBackChildren() insilmaril@822: { insilmaril@822: VymModel *m=currentModel(); insilmaril@822: if (m) m->sortChildren(true); 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@804: void Main::editExpandOneLevel() insilmaril@804: { insilmaril@804: VymModel *m=currentModel(); insilmaril@804: if (m) m->emitExpandOneLevel(); insilmaril@804: } insilmaril@804: insilmaril@804: void Main::editCollapseOneLevel() insilmaril@804: { insilmaril@804: VymModel *m=currentModel(); insilmaril@804: if (m) m->emitCollapseOneLevel(); insilmaril@804: } insilmaril@804: insilmaril@721: void Main::editUnscrollChildren() insilmaril@721: { insilmaril@721: VymModel *m=currentModel(); insilmaril@721: if (m) m->unscrollChildren(); insilmaril@721: } insilmaril@721: insilmaril@786: void Main::editAddAttribute() insilmaril@786: { insilmaril@786: VymModel *m=currentModel(); insilmaril@819: if (m) insilmaril@819: { insilmaril@819: insilmaril@819: m->addAttribute(); insilmaril@819: } insilmaril@786: } insilmaril@786: 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@813: 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::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@802: actionFormatLinkStyleLine->setChecked(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@802: actionFormatLinkStyleParabel->setChecked(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@802: actionFormatLinkStylePolyLine->setChecked(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@802: actionFormatLinkStylePolyParabel->setChecked(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: VymModel *m=currentModel(); insilmaril@721: if (m) m->updateNoteFlag(); insilmaril@160: } insilmaril@160: insilmaril@753: void Main::updateNoteEditor(QModelIndex index ) insilmaril@746: { insilmaril@821: TreeItem *ti=((VymModel*) QObject::sender())->getItem(index); insilmaril@821: /* insilmaril@821: 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@785: branchPropertyWindow->setModel (model ); //FIXME-3 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@802: // updateActions is also called when satellites are closed //FIXME-2 doesn't update immediatly, e.g. historyWindow is still visible, when "close" is pressed insilmaril@802: actionViewToggleNoteEditor->setChecked (textEditor->isVisible()); insilmaril@802: actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible()); insilmaril@802: actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible()); insilmaril@802: 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@802: actionFormatLinkStyleLine->setChecked(true); insilmaril@724: break; insilmaril@724: case LinkableMapObj::Parabel: insilmaril@802: actionFormatLinkStyleParabel->setChecked(true); insilmaril@724: break; insilmaril@724: case LinkableMapObj::PolyLine: insilmaril@802: actionFormatLinkStylePolyLine->setChecked(true); insilmaril@724: break; insilmaril@724: case LinkableMapObj::PolyParabel: insilmaril@802: actionFormatLinkStylePolyParabel->setChecked(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@804: insilmaril@804: // Expanding/collapsing insilmaril@804: actionExpandAll->setEnabled (true); insilmaril@804: actionExpandOneLevel->setEnabled (true); insilmaril@804: actionCollapseOneLevel->setEnabled (true); insilmaril@724: } else insilmaril@724: { insilmaril@724: // Printing insilmaril@724: actionFilePrint->setEnabled (false); insilmaril@804: insilmaril@804: // Expanding/collapsing insilmaril@804: actionExpandAll->setEnabled (false); insilmaril@804: actionExpandOneLevel->setEnabled (false); insilmaril@804: actionCollapseOneLevel->setEnabled (false); insilmaril@724: } insilmaril@407: insilmaril@724: if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) insilmaril@802: actionFormatLinkColorHint->setChecked(true); insilmaril@390: else insilmaril@802: actionFormatLinkColorHint->setChecked(false); insilmaril@390: insilmaril@724: insilmaril@724: if (m && m->hasChanged() ) insilmaril@724: actionFileSave->setEnabled( true); insilmaril@724: else insilmaril@788: actionFileSave->setEnabled( false); 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@787: BranchItem *selbi=m->getSelectedBranch(); insilmaril@772: if (selti) insilmaril@390: { insilmaril@788: if (selbi || selti->getType()==TreeItem::Image) insilmaril@788: { insilmaril@802: actionFormatHideLinkUnselected->setChecked (((MapItem*)selti)->getHideLinkUnselected()); insilmaril@788: actionFormatHideLinkUnselected->setEnabled (true); insilmaril@788: } insilmaril@788: insilmaril@790: if (selbi) insilmaril@390: { insilmaril@790: // Take care of xlinks insilmaril@790: branchXLinksContextMenuEdit->clear(); insilmaril@790: if (selbi->xlinkCount()>0) insilmaril@772: { insilmaril@790: BranchItem *bi; insilmaril@772: QString s; insilmaril@790: for (int i=0; ixlinkCount();++i) insilmaril@772: { insilmaril@790: bi=selbi->getXLinkNum(i)->getPartnerBranch(); insilmaril@790: if (bi) insilmaril@772: { insilmaril@790: s=bi->getHeading(); insilmaril@772: if (s.length()>xLinkMenuWidth) insilmaril@772: s=s.left(xLinkMenuWidth)+"..."; insilmaril@772: branchXLinksContextMenuEdit->addAction (s); 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@802: actionToggleScroll->setChecked(true); insilmaril@772: else insilmaril@802: actionToggleScroll->setChecked(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@822: actionSortBackChildren->setEnabled (true); insilmaril@772: insilmaril@772: actionToggleHideExport->setEnabled (true); insilmaril@802: actionToggleHideExport->setChecked (selbi->hideInExport() ); insilmaril@772: 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@788: } // Branch 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@802: actionToggleHideExport->setChecked (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@723: actionMoveUp->setEnabled (false); insilmaril@723: actionMoveDown->setEnabled (false); insilmaril@788: } // Image insilmaril@772: insilmaril@772: } else insilmaril@772: { // !selti 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@788: actionFormatHideLinkUnselected->setEnabled (false); insilmaril@772: actionSortChildren->setEnabled (false); insilmaril@822: actionSortBackChildren->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@802: actionViewToggleNoteEditor->setChecked (true); insilmaril@0: } insilmaril@0: insilmaril@0: void Main::windowHideNoteEditor() insilmaril@0: { insilmaril@497: textEditor->setShowWithMain(false); insilmaril@0: textEditor->hide(); insilmaril@802: actionViewToggleNoteEditor->setChecked (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@822: insilmaril@822: Process p; insilmaril@822: QString script="test/sleep.sh"; insilmaril@822: p.start (script); insilmaril@822: if (!p.waitForStarted()) insilmaril@822: { insilmaril@822: cout <<"VM::getBugzillaData couldn't start "<testFunction1(); insilmaril@822: */ insilmaril@804: /* insilmaril@804: insilmaril@795: VymModel *m=currentModel(); insilmaril@795: if (!m) return; insilmaril@800: insilmaril@800: bool ok; insilmaril@800: QString text = QInputDialog::getText( insilmaril@800: "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet insilmaril@800: m->getSortFilter(), &ok, NULL); insilmaril@800: if ( ok) insilmaril@800: // user entered something and pressed OK insilmaril@800: m->setSortFilter (text); insilmaril@805: */ insilmaril@527: } insilmaril@527: insilmaril@527: void Main::testFunction2() insilmaril@527: { insilmaril@527: if (!currentMapEditor()) return; insilmaril@792: currentMapEditor()->testFunction2(); 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; istartDetached( settings.value("/mainwindow/readerPDF").toString(),args) ) 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: