Commit b2ea6e1b authored by Tobias Hunger's avatar Tobias Hunger
Browse files

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: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 281161c2
...@@ -582,6 +582,45 @@ bool Kit::isMutable(Id id) const ...@@ -582,6 +582,45 @@ bool Kit::isMutable(Id id) const
return d->m_mutable.contains(id); 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() void Kit::kitUpdated()
{ {
if (d->m_nestedBlockingLevel > 0 && !d->m_mustNotifyAboutDisplayName) { if (d->m_nestedBlockingLevel > 0 && !d->m_mustNotifyAboutDisplayName) {
......
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
#include "projectexplorer_export.h" #include "projectexplorer_export.h"
#include "task.h" #include "task.h"
#include <coreplugin/featureprovider.h>
#include <QSet>
#include <QVariant> #include <QVariant>
namespace Utils { class Environment; } namespace Utils { class Environment; }
...@@ -113,6 +116,12 @@ public: ...@@ -113,6 +116,12 @@ public:
void setMutable(Core::Id id, bool b); void setMutable(Core::Id id, bool b);
bool isMutable(Core::Id id) const; 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: private:
void setSdkProvided(bool sdkProvided); void setSdkProvided(bool sdkProvided);
......
...@@ -27,26 +27,29 @@ ...@@ -27,26 +27,29 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef QTFEATUREPROVIDER_H #ifndef KITFEATUREPROVIDER_H
#define QTFEATUREPROVIDER_H #define KITFEATUREPROVIDER_H
#include <coreplugin/id.h>
#include <coreplugin/featureprovider.h> #include <coreplugin/featureprovider.h>
namespace QtSupport { namespace ProjectExplorer {
namespace Internal { namespace Internal {
class QtFeatureProvider : public Core::IFeatureProvider class KitFeatureProvider : public Core::IFeatureProvider
{ {
Q_OBJECT Q_OBJECT
public: public:
QtFeatureProvider() {}
Core::FeatureSet availableFeatures(const QString &platformName) const; // IFeatureProvider interface
public:
Core::FeatureSet availableFeatures(const QString &platform) const;
QStringList availablePlatforms() const; QStringList availablePlatforms() const;
QString displayNameForPlatform(const QString &string) const; QString displayNameForPlatform(const QString &string) const;
}; };
} // namespace Internal } // namespace Internal
} // namespace QtSupport } // namespace ProjectExplorer
#endif // QTFEATUREPROVIDER_H #endif // KITFEATUREPROVIDER_H
...@@ -326,6 +326,15 @@ KitMatcher DeviceTypeKitInformation::deviceTypeMatcher(Core::Id type) ...@@ -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: // DeviceInformation:
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -129,6 +129,8 @@ public: ...@@ -129,6 +129,8 @@ public:
static void setDeviceTypeId(Kit *k, Core::Id type); static void setDeviceTypeId(Kit *k, Core::Id type);
static KitMatcher deviceTypeMatcher(Core::Id type); static KitMatcher deviceTypeMatcher(Core::Id type);
Core::FeatureSet availableFeatures(const Kit *k) const;
}; };
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -30,9 +30,10 @@ ...@@ -30,9 +30,10 @@
#include "kitmanager.h" #include "kitmanager.h"
#include "kit.h" #include "kit.h"
#include "task.h" #include "kitfeatureprovider.h"
#include "kitmanagerconfigwidget.h" #include "kitmanagerconfigwidget.h"
#include "project.h" #include "project.h"
#include "task.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
...@@ -341,6 +342,35 @@ void KitManager::deregisterKitInformation(KitInformation *ki) ...@@ -341,6 +342,35 @@ void KitManager::deregisterKitInformation(KitInformation *ki)
delete 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) KitManager::KitList KitManager::restoreKits(const Utils::FileName &fileName)
{ {
KitList result; KitList result;
...@@ -586,9 +616,47 @@ QString KitInformation::displayNamePostfix(const Kit *k) const ...@@ -586,9 +616,47 @@ QString KitInformation::displayNamePostfix(const Kit *k) const
return QString(); 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) void KitInformation::notifyAboutUpdate(Kit *k)
{ {
KitManager::notifyAboutUpdate(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 } // namespace ProjectExplorer
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "projectexplorer_export.h" #include "projectexplorer_export.h"
#include <coreplugin/id.h> #include <coreplugin/id.h>
#include <coreplugin/featureprovider.h>
#include <QObject> #include <QObject>
#include <QPair> #include <QPair>
...@@ -92,6 +93,10 @@ public: ...@@ -92,6 +93,10 @@ public:
virtual QString displayNamePostfix(const Kit *k) const; 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: protected:
void setId(Core::Id id) { m_id = id; } void setId(Core::Id id) { m_id = id; }
void setPriority(int priority) { m_priority = priority; } void setPriority(int priority) { m_priority = priority; }
...@@ -144,6 +149,10 @@ public: ...@@ -144,6 +149,10 @@ public:
static void registerKitInformation(ProjectExplorer::KitInformation *ki); static void registerKitInformation(ProjectExplorer::KitInformation *ki);
static void deregisterKitInformation(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: public slots:
void saveKits(); void saveKits();
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "projectmacroexpander.h" #include "projectmacroexpander.h"
#include "removetaskhandler.h" #include "removetaskhandler.h"
#include "unconfiguredprojectpanel.h" #include "unconfiguredprojectpanel.h"
#include "kitfeatureprovider.h"
#include "kitmanager.h" #include "kitmanager.h"
#include "kitoptionspage.h" #include "kitoptionspage.h"
#include "target.h" #include "target.h"
...@@ -388,6 +389,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er ...@@ -388,6 +389,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
d->m_kitManager = new KitManager; // register before ToolChainManager d->m_kitManager = new KitManager; // register before ToolChainManager
d->m_toolChainManager = new ToolChainManager; d->m_toolChainManager = new ToolChainManager;
addAutoReleasedObject(new Internal::KitFeatureProvider);
// Register KitInformation: // Register KitInformation:
KitManager::registerKitInformation(new DeviceTypeKitInformation); KitManager::registerKitInformation(new DeviceTypeKitInformation);
KitManager::registerKitInformation(new DeviceKitInformation); KitManager::registerKitInformation(new DeviceKitInformation);
......
...@@ -28,6 +28,7 @@ HEADERS += projectexplorer.h \ ...@@ -28,6 +28,7 @@ HEADERS += projectexplorer.h \
kitconfigwidget.h \ kitconfigwidget.h \
kitinformation.h \ kitinformation.h \
kitinformationconfigwidget.h \ kitinformationconfigwidget.h \
kitfeatureprovider.h \
kitmanager.h \ kitmanager.h \
kitmanagerconfigwidget.h \ kitmanagerconfigwidget.h \
kitmodel.h \ kitmodel.h \
......
...@@ -89,6 +89,7 @@ QtcPlugin { ...@@ -89,6 +89,7 @@ QtcPlugin {
"kit.cpp", "kit.h", "kit.cpp", "kit.h",
"kitchooser.cpp", "kitchooser.h", "kitchooser.cpp", "kitchooser.h",
"kitconfigwidget.cpp", "kitconfigwidget.h", "kitconfigwidget.cpp", "kitconfigwidget.h",
"kitfeatureprovider.h",
"kitinformation.cpp", "kitinformation.h", "kitinformation.cpp", "kitinformation.h",
"kitinformationconfigwidget.cpp", "kitinformationconfigwidget.h", "kitinformationconfigwidget.cpp", "kitinformationconfigwidget.h",
"kitmanager.cpp", "kitmanager.h", "kitmanager.cpp", "kitmanager.h",
......
...@@ -221,4 +221,27 @@ KitMatcher QtKitInformation::qtVersionMatcher(const Core::FeatureSet &required, ...@@ -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 } // namespace QtSupport
...@@ -66,11 +66,15 @@ public: ...@@ -66,11 +66,15 @@ public:
static BaseQtVersion *qtVersion(const ProjectExplorer::Kit *k); static BaseQtVersion *qtVersion(const ProjectExplorer::Kit *k);
static void setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion *v); 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(), static ProjectExplorer::KitMatcher qtVersionMatcher(const Core::FeatureSet &required = Core::FeatureSet(),
const QtVersionNumber &min = QtVersionNumber(0, 0, 0), const QtVersionNumber &min = QtVersionNumber(0, 0, 0),
const QtVersionNumber &max = QtVersionNumber(INT_MAX, INT_MAX, INT_MAX)); 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: private slots:
void qtVersionsChanged(const QList<int> &addedIds, void qtVersionsChanged(const QList<int> &addedIds,
const QList<int> &removedIds, const QList<int> &removedIds,
......
...@@ -29,7 +29,6 @@ HEADERS += \ ...@@ -29,7 +29,6 @@ HEADERS += \
exampleslistmodel.h \ exampleslistmodel.h \
screenshotcropper.h \ screenshotcropper.h \
qtconfigwidget.h \ qtconfigwidget.h \
qtfeatureprovider.h \
desktopqtversionfactory.h \ desktopqtversionfactory.h \
simulatorqtversionfactory.h \ simulatorqtversionfactory.h \
desktopqtversion.h \ desktopqtversion.h \
......
...@@ -101,7 +101,6 @@ QtcPlugin { ...@@ -101,7 +101,6 @@ QtcPlugin {
"qtversionmanager.cpp", "qtversionmanager.cpp",
"qtversionmanager.h", "qtversionmanager.h",
"qtversionmanager.ui", "qtversionmanager.ui",
"qtfeatureprovider.h",
"screenshotcropper.cpp", "screenshotcropper.cpp",
"screenshotcropper.h", "screenshotcropper.h",
"showbuildlog.ui", "showbuildlog.ui",
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "codegensettingspage.h" #include "codegensettingspage.h"
#include "customexecutablerunconfiguration.h" #include "customexecutablerunconfiguration.h"
#include "desktopqtversionfactory.h" #include "desktopqtversionfactory.h"
#include "qtfeatureprovider.h"
#include "qtkitinformation.h" #include "qtkitinformation.h"
#include "qtoptionspage.h" #include "qtoptionspage.h"
#include "qtversionmanager.h" #include "qtversionmanager.h"
...@@ -79,9 +78,6 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes ...@@ -79,9 +78,6 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes
addAutoReleasedObject(new WinCeQtVersionFactory); addAutoReleasedObject(new WinCeQtVersionFactory);
addAutoReleasedObject(new UiCodeModelManager); addAutoReleasedObject(new UiCodeModelManager);
QtFeatureProvider *featureMgr = new QtFeatureProvider;
addAutoReleasedObject(featureMgr);
addAutoReleasedObject(new CodeGenSettingsPage); addAutoReleasedObject(new CodeGenSettingsPage);
addAutoReleasedObject(new QtOptionsPage); addAutoReleasedObject(new QtOptionsPage);
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "qtkitinformation.h" #include "qtkitinformation.h"
#include "qtversionfactory.h" #include "qtversionfactory.h"
#include "baseqtversion.h" #include "baseqtversion.h"
#include "qtfeatureprovider.h"
#include "qtsupportconstants.h" #include "qtsupportconstants.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
...@@ -813,35 +812,4 @@ static BaseQtVersion::QmakeBuildConfigs qmakeBuildConfigFromCmdArgs(QList<QMakeA ...@@ -813,35 +812,4 @@ static BaseQtVersion::QmakeBuildConfigs qmakeBuildConfigFromCmdArgs(QList<QMakeA
return result; 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 } // namespace QtVersion
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment