Commit 000035f7 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

IWizardFactory: Factor out plugin feature set generation



Change-Id: I8e8c5ec691f7054e1c57994d3ee599a6942ddf8d
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent b8b2568a
......@@ -190,21 +190,7 @@ QList<IWizardFactory*> IWizardFactory::wizardFactoriesOfKind(WizardKind kind)
bool IWizardFactory::isAvailable(const QString &platformName) const
{
FeatureSet availableFeatures;
// Implicitly create a feature for each plugin loaded:
QList<ExtensionSystem::PluginSpec *> activeSpecs;
foreach (ExtensionSystem::PluginSpec *s, ExtensionSystem::PluginManager::plugins()) {
if (s->state() == ExtensionSystem::PluginSpec::Running)
activeSpecs << s;
}
QStringList plugins = Utils::transform(activeSpecs,
[](ExtensionSystem::PluginSpec *s) -> QString {
return QStringLiteral("Plugin.") + s->name();
});
foreach (const QString &n, plugins)
availableFeatures |= Feature(Core::Id::fromString(n));
FeatureSet availableFeatures = pluginFeatures();
foreach (const Core::IFeatureProvider *featureManager, s_providerList)
availableFeatures |= featureManager->availableFeatures(platformName);
......@@ -255,3 +241,18 @@ void IWizardFactory::destroyFeatureProvider()
qDeleteAll(s_providerList);
s_providerList.clear();
}
FeatureSet IWizardFactory::pluginFeatures() const
{
static FeatureSet plugins;
if (plugins.isEmpty()) {
QStringList list;
// Implicitly create a feature for each plugin loaded:
foreach (ExtensionSystem::PluginSpec *s, ExtensionSystem::PluginManager::plugins()) {
if (s->state() == ExtensionSystem::PluginSpec::Running)
list.append(QString::fromLatin1("Plugin.") + s->name());
}
plugins = FeatureSet::fromStringList(list);
}
return plugins;
}
......@@ -36,6 +36,7 @@
#include <QIcon>
#include <QObject>
#include <QString>
#include <QVariantMap>
namespace Core {
......@@ -98,6 +99,9 @@ public:
static void registerFeatureProvider(IFeatureProvider *provider);
protected:
Core::FeatureSet pluginFeatures() const;
private:
static void destroyFeatureProvider();
......
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