diff --git a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp index 7ecf320fa2bd65dfb74e01f68681bc0c1cb5ee30..ed0f9e40c562285d9945301042e7355c2abdb7e1 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp @@ -31,11 +31,16 @@ #include "s60devices.h" #include "s60devicespreferencepane.h" +#include "qtversionmanager.h" #include <extensionsystem/pluginmanager.h> using namespace Qt4ProjectManager::Internal; +namespace { +static const char *S60_AUTODETECTION_SOURCE = "QTS60"; +} + S60Manager::S60Manager(QObject *parent) : QObject(parent), m_devices(new S60Devices(this)), @@ -44,6 +49,7 @@ S60Manager::S60Manager(QObject *parent) m_devices->detectQtForDevices(); ExtensionSystem::PluginManager::instance() ->addObject(m_devicesPreferencePane); + updateQtVersions(); } S60Manager::~S60Manager() @@ -51,3 +57,49 @@ S60Manager::~S60Manager() ExtensionSystem::PluginManager::instance() ->removeObject(m_devicesPreferencePane); } + +void S60Manager::updateQtVersions() +{ + // This assumes that the QtVersionManager has already read + // the Qt versions from the settings + QtVersionManager *versionManager = QtVersionManager::instance(); + QList<QtVersion *> versions = versionManager->versions(); + QList<QtVersion *> handledVersions; + QList<QtVersion *> versionsToAdd; + foreach (const S60Devices::Device &device, m_devices->devices()) { + if (device.qt.isEmpty()) // no Qt version found for this sdk + continue; + QtVersion *deviceVersion = 0; + // look if we have a respective Qt version already + foreach (QtVersion *version, versions) { + if (version->isAutodetected() + && version->autodetectionSource().startsWith(S60_AUTODETECTION_SOURCE) + && version->autodetectionSource().mid(QString(S60_AUTODETECTION_SOURCE).length()+1) == device.id) { + deviceVersion = version; + break; + } + } + if (deviceVersion) { + deviceVersion->setName(QString("%1 (Qt %2)").arg(device.id, deviceVersion->qtVersionString())); + deviceVersion->setPath(device.qt); + handledVersions.append(deviceVersion); + } else { + deviceVersion = new QtVersion(QString("%1 (Qt %2)").arg(device.id), device.qt, + true, QString("%1.%2").arg(S60_AUTODETECTION_SOURCE, device.id)); + deviceVersion->setName(deviceVersion->name().arg(deviceVersion->qtVersionString())); + versionsToAdd.append(deviceVersion); + } + } + // remove old autodetected versions + foreach (QtVersion *version, versions) { + if (version->isAutodetected() + && version->autodetectionSource().startsWith(S60_AUTODETECTION_SOURCE) + && !handledVersions.contains(version)) { + versionManager->removeVersion(version); + } + } + // add new versions + foreach (QtVersion *version, versionsToAdd) { + versionManager->addVersion(version); + } +} diff --git a/src/plugins/qt4projectmanager/qt-s60/s60manager.h b/src/plugins/qt4projectmanager/qt-s60/s60manager.h index 265d57f034e8b89554f55b9db8d0e31ca08a312f..2b34c0446590ee9c4b2012a68449e404af88af1b 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60manager.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60manager.h @@ -46,8 +46,7 @@ class S60Manager : public QObject public: S60Manager(QObject *parent = 0); ~S60Manager(); - - S60Devices *devices() const { return m_devices; } + void updateQtVersions(); private: S60Devices *m_devices; diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 64310b1b82c42ba0c1eb7a20d65efc1fe920add9..75199be531a4f9ddfe44fbba4bc76d4f5effa839 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -143,6 +143,14 @@ void QtVersionManager::addVersion(QtVersion *version) writeVersionsIntoSettings(); } +void QtVersionManager::removeVersion(QtVersion *version) +{ + m_versions.removeAll(version); + emit qtVersionsChanged(); + writeVersionsIntoSettings(); + delete version; +} + void QtVersionManager::updateDocumentation() { Help::HelpManager *helpManager @@ -387,9 +395,11 @@ QtVersion::QtVersion(const QString &name, const QString &path, int id, setPath(path); } -QtVersion::QtVersion(const QString &name, const QString &path) +QtVersion::QtVersion(const QString &name, const QString &path, + bool isAutodetected, const QString &autodetectionSource) : m_name(name), - m_isAutodetected(false), + m_isAutodetected(isAutodetected), + m_autodetectionSource(autodetectionSource), m_hasDebuggingHelper(false), m_mkspecUpToDate(false), m_versionInfoUpToDate(false), diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index debaf9b4eb5651ba80c62df175c480f3b2b51fc0..b9a1b051eb8033a714df0ed42d3f91dc110f39ed 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -46,10 +46,10 @@ class Qt4ProjectManagerPlugin; class QtVersion { - friend class Internal::QtOptionsPageWidget; //for changing name and path friend class QtVersionManager; public: - QtVersion(const QString &name, const QString &path); + QtVersion(const QString &name, const QString &path, + bool isAutodetected = false, const QString &autodetectionSource = QString()); QtVersion(const QString &name, const QString &path, int id, bool isAutodetected = false, const QString &autodetectionSource = QString()); QtVersion() @@ -74,6 +74,9 @@ public: QString qmakeCXX() const; ProjectExplorer::ToolChain *toolChain() const; + void setName(const QString &name); + void setPath(const QString &path); + QString qtVersionString() const; // Returns the PREFIX, BINPREFIX, DOCPREFIX and similar information QHash<QString,QString> versionInfo() const; @@ -117,8 +120,6 @@ public: private: static int getUniqueId(); // Also used by QtOptionsPageWidget - void setName(const QString &name); - void setPath(const QString &path); void updateSourcePath(); void updateMkSpec() const; void updateVersionInfo() const; @@ -180,6 +181,7 @@ public: QtVersion *qtVersionForDirectory(const QString &directory); // Used by the projectloadwizard void addVersion(QtVersion *version); + void removeVersion(QtVersion *version); // Static Methods static QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig);