diff options
author | Tobias Hunger <tobias.hunger@digia.com> | 2014-07-29 15:15:27 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@digia.com> | 2014-07-30 13:49:59 +0200 |
commit | b2ea6e1b9e4cd15e3ac1255b9a67ed033eb70f7c (patch) | |
tree | 6a57783b449188f85d713e6df4be46d6919d8417 | |
parent | 281161c24276a52a4e120f2d43ad578895a1a04a (diff) | |
download | qt-creator-b2ea6e1b9e4cd15e3ac1255b9a67ed033eb70f7c.tar.gz |
FeatureProvider: Move features into Kits
Make available features and platforms methods on kits (implemented
via the KitInformation). Add convenience methods to KitManager to
collect all that.
Remove QtFeatureProvider and implement KitFeatureProvider instead.
The idea of this patch is to make it easier to find which kits are
applicable to which wizard: I should now be able to match the
wizard features against a kit and have a good set of kits to choose
from.
Change-Id: Ie5be0213f142cfdf4417ac55bd6cbb056265a531
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
-rw-r--r-- | src/plugins/projectexplorer/kit.cpp | 39 | ||||
-rw-r--r-- | src/plugins/projectexplorer/kit.h | 9 | ||||
-rw-r--r-- | src/plugins/projectexplorer/kitfeatureprovider.h (renamed from src/plugins/qtsupport/qtfeatureprovider.h) | 19 | ||||
-rw-r--r-- | src/plugins/projectexplorer/kitinformation.cpp | 9 | ||||
-rw-r--r-- | src/plugins/projectexplorer/kitinformation.h | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/kitmanager.cpp | 70 | ||||
-rw-r--r-- | src/plugins/projectexplorer/kitmanager.h | 9 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.cpp | 3 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.pro | 1 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.qbs | 1 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtkitinformation.cpp | 23 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtkitinformation.h | 6 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtsupport.pro | 1 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtsupport.qbs | 1 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtsupportplugin.cpp | 4 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtversionmanager.cpp | 32 |
16 files changed, 181 insertions, 48 deletions
diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp index 763f81aa9c..aa52ea586d 100644 --- a/src/plugins/projectexplorer/kit.cpp +++ b/src/plugins/projectexplorer/kit.cpp @@ -582,6 +582,45 @@ bool Kit::isMutable(Id id) const return d->m_mutable.contains(id); } +QSet<QString> Kit::availablePlatforms() const +{ + QSet<QString> platforms; + foreach (const KitInformation *ki, KitManager::kitInformation()) + platforms.unite(ki->availablePlatforms(this)); + return platforms; +} + +bool Kit::hasPlatform(const QString &platform) const +{ + if (platform.isEmpty()) + return true; + return availablePlatforms().contains(platform); +} + +QString Kit::displayNameForPlatform(const QString &platform) const +{ + foreach (const KitInformation *ki, KitManager::kitInformation()) { + const QString displayName = ki->displayNameForPlatform(this, platform); + if (!displayName.isEmpty()) + return displayName; + } + return QString(); + +} + +FeatureSet Kit::availableFeatures() const +{ + Core::FeatureSet features; + foreach (const KitInformation *ki, KitManager::kitInformation()) + features |= ki->availableFeatures(this); + return features; +} + +bool Kit::hasFeatures(const FeatureSet &features) const +{ + return availableFeatures().contains(features); +} + void Kit::kitUpdated() { if (d->m_nestedBlockingLevel > 0 && !d->m_mustNotifyAboutDisplayName) { diff --git a/src/plugins/projectexplorer/kit.h b/src/plugins/projectexplorer/kit.h index 8092f445e6..7ee9609749 100644 --- a/src/plugins/projectexplorer/kit.h +++ b/src/plugins/projectexplorer/kit.h @@ -33,6 +33,9 @@ #include "projectexplorer_export.h" #include "task.h" +#include <coreplugin/featureprovider.h> + +#include <QSet> #include <QVariant> namespace Utils { class Environment; } @@ -113,6 +116,12 @@ public: void setMutable(Core::Id id, bool b); bool isMutable(Core::Id id) const; + QSet<QString> availablePlatforms() const; + bool hasPlatform(const QString &platform) const; + QString displayNameForPlatform(const QString &platform) const; + Core::FeatureSet availableFeatures() const; + bool hasFeatures(const Core::FeatureSet &features) const; + private: void setSdkProvided(bool sdkProvided); diff --git a/src/plugins/qtsupport/qtfeatureprovider.h b/src/plugins/projectexplorer/kitfeatureprovider.h index 818292f835..4bb3adadcc 100644 --- a/src/plugins/qtsupport/qtfeatureprovider.h +++ b/src/plugins/projectexplorer/kitfeatureprovider.h @@ -27,26 +27,29 @@ ** ****************************************************************************/ -#ifndef QTFEATUREPROVIDER_H -#define QTFEATUREPROVIDER_H +#ifndef KITFEATUREPROVIDER_H +#define KITFEATUREPROVIDER_H +#include <coreplugin/id.h> #include <coreplugin/featureprovider.h> -namespace QtSupport { +namespace ProjectExplorer { namespace Internal { -class QtFeatureProvider : public Core::IFeatureProvider +class KitFeatureProvider : public Core::IFeatureProvider { Q_OBJECT public: - QtFeatureProvider() {} - Core::FeatureSet availableFeatures(const QString &platformName) const; + + // IFeatureProvider interface +public: + Core::FeatureSet availableFeatures(const QString &platform) const; QStringList availablePlatforms() const; QString displayNameForPlatform(const QString &string) const; }; } // namespace Internal -} // namespace QtSupport +} // namespace ProjectExplorer -#endif // QTFEATUREPROVIDER_H +#endif // KITFEATUREPROVIDER_H diff --git a/src/plugins/projectexplorer/kitinformation.cpp b/src/plugins/projectexplorer/kitinformation.cpp index 6437ec9114..44c38eaabc 100644 --- a/src/plugins/projectexplorer/kitinformation.cpp +++ b/src/plugins/projectexplorer/kitinformation.cpp @@ -326,6 +326,15 @@ KitMatcher DeviceTypeKitInformation::deviceTypeMatcher(Core::Id type) }); } +Core::FeatureSet DeviceTypeKitInformation::availableFeatures(const Kit *k) const +{ + Core::Id id = DeviceTypeKitInformation::deviceTypeId(k); + Core::FeatureSet result; + if (id.isValid()) + result |= Core::Feature(Core::Id::fromString(QString::fromLatin1("DeviceType.") + id.toString())); + return result; +} + // -------------------------------------------------------------------------- // DeviceInformation: // -------------------------------------------------------------------------- diff --git a/src/plugins/projectexplorer/kitinformation.h b/src/plugins/projectexplorer/kitinformation.h index 2d17fce8d7..79c09484d0 100644 --- a/src/plugins/projectexplorer/kitinformation.h +++ b/src/plugins/projectexplorer/kitinformation.h @@ -129,6 +129,8 @@ public: static void setDeviceTypeId(Kit *k, Core::Id type); static KitMatcher deviceTypeMatcher(Core::Id type); + + Core::FeatureSet availableFeatures(const Kit *k) const; }; // -------------------------------------------------------------------------- diff --git a/src/plugins/projectexplorer/kitmanager.cpp b/src/plugins/projectexplorer/kitmanager.cpp index a1b66a9a6c..891ed458c1 100644 --- a/src/plugins/projectexplorer/kitmanager.cpp +++ b/src/plugins/projectexplorer/kitmanager.cpp @@ -30,9 +30,10 @@ #include "kitmanager.h" #include "kit.h" -#include "task.h" +#include "kitfeatureprovider.h" #include "kitmanagerconfigwidget.h" #include "project.h" +#include "task.h" #include <coreplugin/icore.h> @@ -341,6 +342,35 @@ void KitManager::deregisterKitInformation(KitInformation *ki) delete ki; } +QSet<QString> KitManager::availablePlatforms() +{ + QSet<QString> platforms; + foreach (const Kit *k, kits()) + platforms.unite(k->availablePlatforms()); + return platforms; +} + +QString KitManager::displayNameForPlatform(const QString &platform) +{ + foreach (const Kit *k, kits()) { + const QString displayName = k->displayNameForPlatform(platform); + if (!displayName.isEmpty()) + return displayName; + } + return QString(); +} + +Core::FeatureSet KitManager::availableFeatures(const QString &platform) +{ + Core::FeatureSet features; + foreach (const Kit *k, kits()) { + QSet<QString> kitPlatforms = k->availablePlatforms(); + if (kitPlatforms.isEmpty() || kitPlatforms.contains(platform)) + features |= k->availableFeatures(); + } + return features; +} + KitManager::KitList KitManager::restoreKits(const Utils::FileName &fileName) { KitList result; @@ -586,9 +616,47 @@ QString KitInformation::displayNamePostfix(const Kit *k) const return QString(); } +QSet<QString> KitInformation::availablePlatforms(const Kit *k) const +{ + Q_UNUSED(k); + return QSet<QString>(); +} + +QString KitInformation::displayNameForPlatform(const Kit *k, const QString &platform) const +{ + Q_UNUSED(k); + Q_UNUSED(platform); + return QString(); +} + +Core::FeatureSet KitInformation::availableFeatures(const Kit *k) const +{ + Q_UNUSED(k); + return Core::FeatureSet(); +} + void KitInformation::notifyAboutUpdate(Kit *k) { KitManager::notifyAboutUpdate(k); } +// -------------------------------------------------------------------- +// KitFeatureProvider: +// -------------------------------------------------------------------- + +Core::FeatureSet Internal::KitFeatureProvider::availableFeatures(const QString &platform) const +{ + return KitManager::availableFeatures(platform); +} + +QStringList Internal::KitFeatureProvider::availablePlatforms() const +{ + return KitManager::availablePlatforms().toList(); +} + +QString Internal::KitFeatureProvider::displayNameForPlatform(const QString &string) const +{ + return KitManager::displayNameForPlatform(string); +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/kitmanager.h b/src/plugins/projectexplorer/kitmanager.h index b5ac4f8c49..fa163472ec 100644 --- a/src/plugins/projectexplorer/kitmanager.h +++ b/src/plugins/projectexplorer/kitmanager.h @@ -33,6 +33,7 @@ #include "projectexplorer_export.h" #include <coreplugin/id.h> +#include <coreplugin/featureprovider.h> #include <QObject> #include <QPair> @@ -92,6 +93,10 @@ public: virtual QString displayNamePostfix(const Kit *k) const; + virtual QSet<QString> availablePlatforms(const Kit *k) const; + virtual QString displayNameForPlatform(const ProjectExplorer::Kit *k, const QString &platform) const; + virtual Core::FeatureSet availableFeatures(const Kit *k) const; + protected: void setId(Core::Id id) { m_id = id; } void setPriority(int priority) { m_priority = priority; } @@ -144,6 +149,10 @@ public: static void registerKitInformation(ProjectExplorer::KitInformation *ki); static void deregisterKitInformation(ProjectExplorer::KitInformation *ki); + static QSet<QString> availablePlatforms(); + static QString displayNameForPlatform(const QString &platform); + static Core::FeatureSet availableFeatures(const QString &platform); + public slots: void saveKits(); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index e303c2d3b5..fd11f88598 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -40,6 +40,7 @@ #include "projectmacroexpander.h" #include "removetaskhandler.h" #include "unconfiguredprojectpanel.h" +#include "kitfeatureprovider.h" #include "kitmanager.h" #include "kitoptionspage.h" #include "target.h" @@ -388,6 +389,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er d->m_kitManager = new KitManager; // register before ToolChainManager d->m_toolChainManager = new ToolChainManager; + addAutoReleasedObject(new Internal::KitFeatureProvider); + // Register KitInformation: KitManager::registerKitInformation(new DeviceTypeKitInformation); KitManager::registerKitInformation(new DeviceKitInformation); diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index ca9be7b40a..7319546449 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -28,6 +28,7 @@ HEADERS += projectexplorer.h \ kitconfigwidget.h \ kitinformation.h \ kitinformationconfigwidget.h \ + kitfeatureprovider.h \ kitmanager.h \ kitmanagerconfigwidget.h \ kitmodel.h \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 841d9e7890..93030dc0c1 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -89,6 +89,7 @@ QtcPlugin { "kit.cpp", "kit.h", "kitchooser.cpp", "kitchooser.h", "kitconfigwidget.cpp", "kitconfigwidget.h", + "kitfeatureprovider.h", "kitinformation.cpp", "kitinformation.h", "kitinformationconfigwidget.cpp", "kitinformationconfigwidget.h", "kitmanager.cpp", "kitmanager.h", diff --git a/src/plugins/qtsupport/qtkitinformation.cpp b/src/plugins/qtsupport/qtkitinformation.cpp index 48df8097e2..1cb6b20abe 100644 --- a/src/plugins/qtsupport/qtkitinformation.cpp +++ b/src/plugins/qtsupport/qtkitinformation.cpp @@ -221,4 +221,27 @@ KitMatcher QtKitInformation::qtVersionMatcher(const Core::FeatureSet &required, }); } +QSet<QString> QtKitInformation::availablePlatforms(const Kit *k) const +{ + QSet<QString> result; + BaseQtVersion *version = QtKitInformation::qtVersion(k); + if (version) + result.insert(version->platformName()); + return result; +} + +QString QtKitInformation::displayNameForPlatform(const Kit *k, const QString &platform) const +{ + BaseQtVersion *version = QtKitInformation::qtVersion(k); + if (version && version->platformName() == platform) + return version->platformDisplayName(); + return QString(); +} + +Core::FeatureSet QtKitInformation::availableFeatures(const Kit *k) const +{ + BaseQtVersion *version = QtKitInformation::qtVersion(k); + return version ? version->availableFeatures() : Core::FeatureSet(); +} + } // namespace QtSupport diff --git a/src/plugins/qtsupport/qtkitinformation.h b/src/plugins/qtsupport/qtkitinformation.h index c9db7fedf1..9b52c3459e 100644 --- a/src/plugins/qtsupport/qtkitinformation.h +++ b/src/plugins/qtsupport/qtkitinformation.h @@ -66,11 +66,15 @@ public: static BaseQtVersion *qtVersion(const ProjectExplorer::Kit *k); static void setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion *v); - static ProjectExplorer::KitMatcher platformMatcher(const QString &platform); + static ProjectExplorer::KitMatcher platformMatcher(const QString &availablePlatforms); static ProjectExplorer::KitMatcher qtVersionMatcher(const Core::FeatureSet &required = Core::FeatureSet(), const QtVersionNumber &min = QtVersionNumber(0, 0, 0), const QtVersionNumber &max = QtVersionNumber(INT_MAX, INT_MAX, INT_MAX)); + QSet<QString> availablePlatforms(const ProjectExplorer::Kit *k) const; + QString displayNameForPlatform(const ProjectExplorer::Kit *k, const QString &platform) const; + Core::FeatureSet availableFeatures(const ProjectExplorer::Kit *k) const; + private slots: void qtVersionsChanged(const QList<int> &addedIds, const QList<int> &removedIds, diff --git a/src/plugins/qtsupport/qtsupport.pro b/src/plugins/qtsupport/qtsupport.pro index 4e6ee53152..f1e794c4ff 100644 --- a/src/plugins/qtsupport/qtsupport.pro +++ b/src/plugins/qtsupport/qtsupport.pro @@ -29,7 +29,6 @@ HEADERS += \ exampleslistmodel.h \ screenshotcropper.h \ qtconfigwidget.h \ - qtfeatureprovider.h \ desktopqtversionfactory.h \ simulatorqtversionfactory.h \ desktopqtversion.h \ diff --git a/src/plugins/qtsupport/qtsupport.qbs b/src/plugins/qtsupport/qtsupport.qbs index 0454f431f7..0a2229a61a 100644 --- a/src/plugins/qtsupport/qtsupport.qbs +++ b/src/plugins/qtsupport/qtsupport.qbs @@ -101,7 +101,6 @@ QtcPlugin { "qtversionmanager.cpp", "qtversionmanager.h", "qtversionmanager.ui", - "qtfeatureprovider.h", "screenshotcropper.cpp", "screenshotcropper.h", "showbuildlog.ui", diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp index f3cd82edb1..d275985c09 100644 --- a/src/plugins/qtsupport/qtsupportplugin.cpp +++ b/src/plugins/qtsupport/qtsupportplugin.cpp @@ -32,7 +32,6 @@ #include "codegensettingspage.h" #include "customexecutablerunconfiguration.h" #include "desktopqtversionfactory.h" -#include "qtfeatureprovider.h" #include "qtkitinformation.h" #include "qtoptionspage.h" #include "qtversionmanager.h" @@ -79,9 +78,6 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes addAutoReleasedObject(new WinCeQtVersionFactory); addAutoReleasedObject(new UiCodeModelManager); - QtFeatureProvider *featureMgr = new QtFeatureProvider; - addAutoReleasedObject(featureMgr); - addAutoReleasedObject(new CodeGenSettingsPage); addAutoReleasedObject(new QtOptionsPage); diff --git a/src/plugins/qtsupport/qtversionmanager.cpp b/src/plugins/qtsupport/qtversionmanager.cpp index 5ac557efe3..03d8d719e0 100644 --- a/src/plugins/qtsupport/qtversionmanager.cpp +++ b/src/plugins/qtsupport/qtversionmanager.cpp @@ -32,7 +32,6 @@ #include "qtkitinformation.h" #include "qtversionfactory.h" #include "baseqtversion.h" -#include "qtfeatureprovider.h" #include "qtsupportconstants.h" #include <coreplugin/icore.h> @@ -813,35 +812,4 @@ static BaseQtVersion::QmakeBuildConfigs qmakeBuildConfigFromCmdArgs(QList<QMakeA return result; } -Core::FeatureSet QtFeatureProvider::availableFeatures(const QString &platformName) const -{ - Core::FeatureSet features; - foreach (BaseQtVersion *const qtVersion, QtVersionManager::validVersions()) { - if (qtVersion->platformName() == platformName || platformName.isEmpty()) - features |= qtVersion->availableFeatures(); - } - - return features; -} - -QStringList QtFeatureProvider::availablePlatforms() const -{ - QStringList platforms; - foreach (BaseQtVersion *const qtVersion, QtVersionManager::validVersions()) { - if (!qtVersion->platformName().isEmpty()) - platforms.append(qtVersion->platformName()); - } - platforms.removeDuplicates(); - return platforms; -} - -QString QtFeatureProvider::displayNameForPlatform(const QString &string) const -{ - foreach (BaseQtVersion *const qtVersion, QtVersionManager::validVersions()) { - if (qtVersion->platformName() == string) - return qtVersion->platformDisplayName(); - } - return QString(); -} - } // namespace QtVersion |