forked from qt-creator/qt-creator
IWizardFactory: Factor out plugin feature set generation
Change-Id: I8e8c5ec691f7054e1c57994d3ee599a6942ddf8d Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user