Commit b2ea6e1b authored by Tobias Hunger's avatar Tobias Hunger

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
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) {
......
......@@ -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);
......
......@@ -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
......@@ -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:
// --------------------------------------------------------------------------
......
......@@ -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;
};
// --------------------------------------------------------------------------
......
......@@ -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
......@@ -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();
......
......@@ -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);
......
......@@ -28,6 +28,7 @@ HEADERS += projectexplorer.h \
kitconfigwidget.h \
kitinformation.h \
kitinformationconfigwidget.h \
kitfeatureprovider.h \
kitmanager.h \
kitmanagerconfigwidget.h \
kitmodel.h \
......
......@@ -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",
......
......@@ -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
......@@ -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,
......
......@@ -29,7 +29,6 @@ HEADERS += \
exampleslistmodel.h \
screenshotcropper.h \
qtconfigwidget.h \
qtfeatureprovider.h \
desktopqtversionfactory.h \
simulatorqtversionfactory.h \
desktopqtversion.h \
......
......@@ -101,7 +101,6 @@ QtcPlugin {
"qtversionmanager.cpp",
"qtversionmanager.h",
"qtversionmanager.ui",
"qtfeatureprovider.h",
"screenshotcropper.cpp",
"screenshotcropper.h",
"showbuildlog.ui",
......
......@@ -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);
......
......@@ -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
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