Commit 15caea1d authored by hjk's avatar hjk

Analyzer: Handle createProjectSettings outside IAnalyzerTool

Less indirection.

Change-Id: If702a0a44c1fc96510fd1c5411fda51660dde10b
Reviewed-by: default avatarAurindam Jana <aurindam.jana@digia.com>
parent 2e0434dd
......@@ -684,11 +684,6 @@ QDockWidget *AnalyzerManager::createDockWidget(IAnalyzerTool *tool, const QStrin
return dockWidget;
}
QList<IAnalyzerTool *> AnalyzerManager::tools()
{
return d->m_tools;
}
void AnalyzerManager::selectTool(IAnalyzerTool *tool, StartMode mode)
{
d->selectTool(d->actionFromToolAndMode(tool, mode));
......
......@@ -75,7 +75,6 @@ public:
static Utils::FancyMainWindow *mainWindow();
static void showMode();
static QList<IAnalyzerTool *> tools();
static void selectTool(IAnalyzerTool *tool, StartMode mode);
static void startTool();
static void stopTool();
......
......@@ -46,7 +46,6 @@ class DetailsWidget;
namespace Analyzer {
class AnalyzerSettings;
class AbstractAnalyzerSubConfig;
namespace Internal {
......
......@@ -151,16 +151,18 @@ void AnalyzerGlobalSettings::registerConfig(AbstractAnalyzerSubConfig *config)
}
static QList<AnalyzerSubConfigFactory *> theAnalyzerSubConfigFactories()
{
static QList<AnalyzerSubConfigFactory *> theFactories;
return theFactories;
}
AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect()
: AnalyzerSettings((QObject *)0), m_useGlobalSettings(true)
{
QList<IAnalyzerTool*> tools = AnalyzerManager::tools();
// add sub configs
foreach (IAnalyzerTool *tool, tools) {
AbstractAnalyzerSubConfig *config = tool->createProjectSettings();
if (config)
m_customConfigurations.append(config);
}
foreach (AnalyzerSubConfigFactory *factory, theAnalyzerSubConfigFactories())
m_customConfigurations.append(factory->createProjectSettings());
m_subConfigs = AnalyzerGlobalSettings::instance()->subConfigs();
resetCustomToGlobalSettings();
......@@ -184,6 +186,11 @@ AnalyzerRunConfigurationAspect::~AnalyzerRunConfigurationAspect()
qDeleteAll(m_customConfigurations);
}
void AnalyzerRunConfigurationAspect::registerConfigFactory(AnalyzerSubConfigFactory *factory)
{
theAnalyzerSubConfigFactories().append(factory);
}
QString AnalyzerRunConfigurationAspect::displayName() const
{
return tr("Analyzer Settings");
......
......@@ -81,6 +81,17 @@ public:
virtual AbstractAnalyzerSubConfig *clone() = 0;
};
class ANALYZER_EXPORT AnalyzerSubConfigFactory : public QObject
{
Q_OBJECT
public:
AnalyzerSubConfigFactory() {}
/// Factory method to create the project tool setting
virtual AbstractAnalyzerSubConfig *createProjectSettings() = 0;
};
/**
* Shared interface for the global and per-project settings.
*
......@@ -168,6 +179,8 @@ public:
AnalyzerRunConfigurationAspect(const AnalyzerRunConfigurationAspect *other);
~AnalyzerRunConfigurationAspect();
static void registerConfigFactory(AnalyzerSubConfigFactory *factory);
QString displayName() const;
virtual QVariantMap toMap() const;
AnalyzerRunConfigurationAspect *clone(ProjectExplorer::RunConfiguration *parent) const;
......
......@@ -60,11 +60,6 @@ IAnalyzerTool::IAnalyzerTool(QObject *parent)
: QObject(parent)
{}
AbstractAnalyzerSubConfig *IAnalyzerTool::createProjectSettings()
{
return 0;
}
static bool buildTypeAccepted(IAnalyzerTool::ToolMode toolMode,
BuildConfiguration::BuildType buildType)
{
......
......@@ -113,9 +113,6 @@ public:
/// Called when tools gets deselected.
virtual void toolDeselected() const {}
/// Factory method to create the project tool setting
virtual AbstractAnalyzerSubConfig *createProjectSettings();
};
} // namespace Analyzer
......
......@@ -297,11 +297,6 @@ QString MemcheckTool::description() const
"memory leaks");
}
AbstractAnalyzerSubConfig *MemcheckTool::createProjectSettings()
{
return new ValgrindProjectSettings();
}
IAnalyzerTool::ToolMode MemcheckTool::toolMode() const
{
return DebugMode;
......
......@@ -89,9 +89,6 @@ public:
QString displayName() const;
QString description() const;
// Create the valgrind settings (for all valgrind tools)
Analyzer::AbstractAnalyzerSubConfig *createProjectSettings();
private slots:
void settingsDestroyed(QObject *settings);
void maybeActiveRunConfigurationChanged();
......
......@@ -48,9 +48,18 @@ using namespace Analyzer;
namespace Valgrind {
namespace Internal {
class ProjectSettingsFactory : public AnalyzerSubConfigFactory
{
AbstractAnalyzerSubConfig *createProjectSettings()
{
return new ValgrindProjectSettings();
}
};
bool ValgrindPlugin::initialize(const QStringList &, QString *)
{
AnalyzerGlobalSettings::registerConfig(new ValgrindGlobalSettings());
AnalyzerRunConfigurationAspect::registerConfigFactory(new ProjectSettingsFactory());
IAnalyzerTool *memcheckTool = new MemcheckTool(this);
IAnalyzerTool *callgrindTool = new CallgrindTool(this);
......
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