IWizardFactory: Add a feature for all running plugins

Get rid of IFeatureProviders that are only telling the wizard factory
that a plugin was loaded.

Change-Id: Id12c669974a6ab98036f070e1adcae35b34ca376
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Tobias Hunger
2014-07-16 12:26:36 +02:00
parent c571ecbd51
commit 8f1ca2216a
8 changed files with 23 additions and 29 deletions

View File

@@ -30,7 +30,7 @@
****************************************************************************/
-->
<wizard version="1" kind="project" firstpage="10" id="S.Plain C (CMake)" category="I.Projects"
platformIndependent="true" featuresRequired="CMake.CMakeSupport">
platformIndependent="true" featuresRequired="Plugin.CMakeProjectManager">
<icon>../common/console.png</icon>
<description>Creates a plain C project using CMake, not using the Qt library.</description>
<displayname>Plain C Project (CMake Build)</displayname>;

View File

@@ -30,7 +30,7 @@
****************************************************************************/
-->
<wizard version="1" kind="project" firstpage="10" id="S.Plain C (Qbs)" category="I.Projects"
platformIndependent="true" featuresRequired="Qbs.QbsSupport">
platformIndependent="true" featuresRequired="Plugin.QbsProjectManager">
<icon>../common/console.png</icon>
<description>Creates a plain C project using qbs.</description>
<displayname>Plain C Project (Qbs Build)</displayname>;

View File

@@ -30,7 +30,7 @@
****************************************************************************/
-->
<wizard version="1" kind="project" firstpage="10" id="S.Plain C++ (CMake)" category="I.Projects"
platformIndependent="true" featuresRequired="CMake.CMakeSupport">
platformIndependent="true" featuresRequired="Plugin.CMakeProjectManager">
<icon>../common/console.png</icon>
<description>Creates a plain C++ project using CMake, not using the Qt library.</description>
<displayname>Plain C++ Project (CMake Build)</displayname>;

View File

@@ -30,7 +30,7 @@
****************************************************************************/
-->
<wizard version="1" kind="project" firstpage="10" id="S.Plain C++ (Qbs)" category="I.Projects"
platformIndependent="true" featuresRequired="Qbs.QbsSupport">
platformIndependent="true" featuresRequired="Plugin.QbsProjectManager">
<icon>../common/console.png</icon>
<description>Creates a plain (non-Qt) C++ project using qbs.</description>
<displayname>Plain C++ Project (Qbs Build)</displayname>;

View File

@@ -41,7 +41,6 @@ const char CMAKE_EDITOR_DISPLAY_NAME[] = "CMake Editor";
const char C_CMAKEEDITOR[] = "CMakeProject.Context.CMakeEditor";
const char RUNCMAKE[] = "CMakeProject.RunCMake";
const char RUNCMAKECONTEXTMENU[] = "CMakeProject.RunCMakeContextMenu";
const char CMAKE_SUPPORT_FEATURE[] = "CMake.CMakeSupport";
// Project
const char CMAKEPROJECT_ID[] = "CMakeProjectManager.CMakeProject";

View File

@@ -49,16 +49,6 @@
using namespace CMakeProjectManager::Internal;
class CMakeFeatureProvider : public Core::IFeatureProvider
{
Core::FeatureSet availableFeatures(const QString & /* platform */) const {
return Core::FeatureSet(Core::Id(CMakeProjectManager::Constants::CMAKE_SUPPORT_FEATURE));
}
QStringList availablePlatforms() const { return QStringList(); }
QString displayNameForPlatform(const QString & /* platform */) const { return QString(); }
};
CMakeProjectPlugin::CMakeProjectPlugin()
{
}
@@ -82,7 +72,6 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
addAutoReleasedObject(new CMakeEditorFactory(manager));
addAutoReleasedObject(new CMakeLocatorFilter);
addAutoReleasedObject(new CMakeFileCompletionAssistProvider(cmp));
addAutoReleasedObject(new CMakeFeatureProvider);
auto hf = new TextEditor::HighlighterFactory;
hf->setProductType<CMakeHighlighter>();

View File

@@ -31,8 +31,11 @@
#include <coreplugin/icore.h>
#include <coreplugin/featureprovider.h>
#include <extensionsystem/pluginspec.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/algorithm.h>
#include <QStringList>
/*!
@@ -184,7 +187,22 @@ bool IWizardFactory::isAvailable(const QString &platformName) const
{
FeatureSet availableFeatures;
const QList<Core::IFeatureProvider*> featureManagers = ExtensionSystem::PluginManager::getObjects<Core::IFeatureProvider>();
// 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));
const QList<Core::IFeatureProvider *> featureManagers
= ExtensionSystem::PluginManager::getObjects<Core::IFeatureProvider>();
foreach (const Core::IFeatureProvider *featureManager, featureManagers)
availableFeatures |= featureManager->availableFeatures(platformName);

View File

@@ -77,17 +77,6 @@ static QbsProject *currentEditorProject()
return doc ? qobject_cast<QbsProject *>(SessionManager::projectForFile(doc->filePath())) : 0;
}
class QbsFeatureProvider : public Core::IFeatureProvider
{
Core::FeatureSet availableFeatures(const QString & /* platform */) const {
return Core::FeatureSet("Qbs.QbsSupport");
}
QStringList availablePlatforms() const { return QStringList(); }
QString displayNameForPlatform(const QString & /* platform */) const { return QString(); }
};
QbsProjectManagerPlugin::QbsProjectManagerPlugin() :
m_selectedProject(0),
m_selectedNode(0),
@@ -114,7 +103,6 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString *
addAutoReleasedObject(new QbsInstallStepFactory);
addAutoReleasedObject(new QbsDeployConfigurationFactory);
addAutoReleasedObject(new QbsRunConfigurationFactory);
addAutoReleasedObject(new QbsFeatureProvider);
//menus
// Build Menu: