forked from qt-creator/qt-creator
IFeatureProvider: Add register method for IFeatureProviders to IWizardFactory
and avoid putting those objects into the object pool. Change-Id: I46c5ed93a9e80532b3cbd7dba2e52b28b1595aa3 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include "mimedatabase.h"
|
#include "mimedatabase.h"
|
||||||
#include "modemanager.h"
|
#include "modemanager.h"
|
||||||
#include "infobar.h"
|
#include "infobar.h"
|
||||||
|
#include "iwizardfactory.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
@@ -60,6 +61,8 @@ CorePlugin::CorePlugin() : m_editMode(0), m_designMode(0)
|
|||||||
|
|
||||||
CorePlugin::~CorePlugin()
|
CorePlugin::~CorePlugin()
|
||||||
{
|
{
|
||||||
|
IWizardFactory::destroyFeatureProvider();
|
||||||
|
|
||||||
delete m_findPlugin;
|
delete m_findPlugin;
|
||||||
delete m_locator;
|
delete m_locator;
|
||||||
|
|
||||||
|
|||||||
@@ -42,10 +42,8 @@ namespace Core {
|
|||||||
|
|
||||||
class CORE_EXPORT FeatureSet;
|
class CORE_EXPORT FeatureSet;
|
||||||
|
|
||||||
class CORE_EXPORT IFeatureProvider : public QObject
|
class CORE_EXPORT IFeatureProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IFeatureProvider() {}
|
IFeatureProvider() {}
|
||||||
virtual ~IFeatureProvider() {}
|
virtual ~IFeatureProvider() {}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
@@ -145,6 +146,10 @@
|
|||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
static QList<IFeatureProvider *> s_providerList;
|
||||||
|
}
|
||||||
|
|
||||||
/* A utility to find all wizards supporting a view mode and matching a predicate */
|
/* A utility to find all wizards supporting a view mode and matching a predicate */
|
||||||
template <class Predicate>
|
template <class Predicate>
|
||||||
QList<IWizardFactory*> findWizardFactories(Predicate predicate)
|
QList<IWizardFactory*> findWizardFactories(Predicate predicate)
|
||||||
@@ -201,10 +206,7 @@ bool IWizardFactory::isAvailable(const QString &platformName) const
|
|||||||
foreach (const QString &n, plugins)
|
foreach (const QString &n, plugins)
|
||||||
availableFeatures |= Feature(Core::Id::fromString(n));
|
availableFeatures |= Feature(Core::Id::fromString(n));
|
||||||
|
|
||||||
const QList<Core::IFeatureProvider *> featureManagers
|
foreach (const Core::IFeatureProvider *featureManager, s_providerList)
|
||||||
= ExtensionSystem::PluginManager::getObjects<Core::IFeatureProvider>();
|
|
||||||
|
|
||||||
foreach (const Core::IFeatureProvider *featureManager, featureManagers)
|
|
||||||
availableFeatures |= featureManager->availableFeatures(platformName);
|
availableFeatures |= featureManager->availableFeatures(platformName);
|
||||||
|
|
||||||
return availableFeatures.contains(requiredFeatures());
|
return availableFeatures.contains(requiredFeatures());
|
||||||
@@ -226,10 +228,7 @@ QStringList IWizardFactory::allAvailablePlatforms()
|
|||||||
{
|
{
|
||||||
QStringList platforms;
|
QStringList platforms;
|
||||||
|
|
||||||
const QList<Core::IFeatureProvider*> featureManagers =
|
foreach (const Core::IFeatureProvider *featureManager, s_providerList)
|
||||||
ExtensionSystem::PluginManager::getObjects<Core::IFeatureProvider>();
|
|
||||||
|
|
||||||
foreach (const Core::IFeatureProvider *featureManager, featureManagers)
|
|
||||||
platforms.append(featureManager->availablePlatforms());
|
platforms.append(featureManager->availablePlatforms());
|
||||||
|
|
||||||
return platforms;
|
return platforms;
|
||||||
@@ -237,13 +236,22 @@ QStringList IWizardFactory::allAvailablePlatforms()
|
|||||||
|
|
||||||
QString IWizardFactory::displayNameForPlatform(const QString &string)
|
QString IWizardFactory::displayNameForPlatform(const QString &string)
|
||||||
{
|
{
|
||||||
const QList<Core::IFeatureProvider*> featureManagers =
|
foreach (const Core::IFeatureProvider *featureManager, s_providerList) {
|
||||||
ExtensionSystem::PluginManager::getObjects<Core::IFeatureProvider>();
|
|
||||||
|
|
||||||
foreach (const Core::IFeatureProvider *featureManager, featureManagers) {
|
|
||||||
QString displayName = featureManager->displayNameForPlatform(string);
|
QString displayName = featureManager->displayNameForPlatform(string);
|
||||||
if (!displayName.isEmpty())
|
if (!displayName.isEmpty())
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IWizardFactory::registerFeatureProvider(IFeatureProvider *provider)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(!s_providerList.contains(provider), return);
|
||||||
|
s_providerList.append(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IWizardFactory::destroyFeatureProvider()
|
||||||
|
{
|
||||||
|
qDeleteAll(s_providerList);
|
||||||
|
s_providerList.clear();
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,6 +40,8 @@
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
namespace Internal { class CorePlugin; }
|
||||||
|
|
||||||
class CORE_EXPORT IWizardFactory
|
class CORE_EXPORT IWizardFactory
|
||||||
: public QObject
|
: public QObject
|
||||||
{
|
{
|
||||||
@@ -94,7 +96,11 @@ public:
|
|||||||
static QStringList allAvailablePlatforms();
|
static QStringList allAvailablePlatforms();
|
||||||
static QString displayNameForPlatform(const QString &string);
|
static QString displayNameForPlatform(const QString &string);
|
||||||
|
|
||||||
|
static void registerFeatureProvider(IFeatureProvider *provider);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void destroyFeatureProvider();
|
||||||
|
|
||||||
IWizardFactory::WizardKind m_kind;
|
IWizardFactory::WizardKind m_kind;
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
QString m_description;
|
QString m_description;
|
||||||
@@ -105,6 +111,8 @@ private:
|
|||||||
FeatureSet m_requiredFeatures;
|
FeatureSet m_requiredFeatures;
|
||||||
WizardFlags m_flags;
|
WizardFlags m_flags;
|
||||||
QString m_descriptionImage;
|
QString m_descriptionImage;
|
||||||
|
|
||||||
|
friend class Internal::CorePlugin;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -38,11 +38,6 @@ namespace Internal {
|
|||||||
|
|
||||||
class KitFeatureProvider : public Core::IFeatureProvider
|
class KitFeatureProvider : public Core::IFeatureProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// IFeatureProvider interface
|
|
||||||
public:
|
public:
|
||||||
Core::FeatureSet availableFeatures(const QString &platform) const;
|
Core::FeatureSet availableFeatures(const QString &platform) const;
|
||||||
QStringList availablePlatforms() const;
|
QStringList availablePlatforms() const;
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ 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);
|
Core::IWizardFactory::registerFeatureProvider(new Internal::KitFeatureProvider);
|
||||||
|
|
||||||
// Register KitInformation:
|
// Register KitInformation:
|
||||||
KitManager::registerKitInformation(new DeviceTypeKitInformation);
|
KitManager::registerKitInformation(new DeviceTypeKitInformation);
|
||||||
|
|||||||
Reference in New Issue
Block a user