Commit 3c14ceeb authored by hjk's avatar hjk
Browse files

Analyzer: Rename AbstractAnalyzerSubConfig to ISettingsAspect



More in line with IRunConfigurationAspect

Change-Id: I50a038de004733b6b19d345b30a63cc2db02875a
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent cd460a36
...@@ -46,7 +46,7 @@ namespace Internal { ...@@ -46,7 +46,7 @@ namespace Internal {
AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(AnalyzerRunConfigurationAspect *aspect) AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(AnalyzerRunConfigurationAspect *aspect)
{ {
m_aspect = aspect; m_aspect = aspect;
m_config = aspect->customSubConfig(); m_config = aspect->projectSettings();
QWidget *globalSetting = new QWidget; QWidget *globalSetting = new QWidget;
QHBoxLayout *globalSettingLayout = new QHBoxLayout(globalSetting); QHBoxLayout *globalSettingLayout = new QHBoxLayout(globalSetting);
......
...@@ -59,7 +59,7 @@ private slots: ...@@ -59,7 +59,7 @@ private slots:
private: private:
QWidget *m_configWidget; QWidget *m_configWidget;
AnalyzerRunConfigurationAspect *m_aspect; AnalyzerRunConfigurationAspect *m_aspect;
AbstractAnalyzerSubConfig *m_config; ISettingsAspect *m_config;
QComboBox *m_settingsCombo; QComboBox *m_settingsCombo;
QPushButton *m_restoreButton; QPushButton *m_restoreButton;
Utils::DetailsWidget *m_details; Utils::DetailsWidget *m_details;
......
...@@ -46,34 +46,33 @@ static const char useGlobalC[] = "Analyzer.Project.UseGlobal"; ...@@ -46,34 +46,33 @@ static const char useGlobalC[] = "Analyzer.Project.UseGlobal";
namespace Analyzer { namespace Analyzer {
AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect( AnalyzerRunConfigurationAspect::AnalyzerRunConfigurationAspect(ISettingsAspect *projectSettings,
AbstractAnalyzerSubConfig *customConfiguration, ISettingsAspect *globalSettings)
AbstractAnalyzerSubConfig *globalConfiguration)
{ {
m_useGlobalSettings = true; m_useGlobalSettings = true;
m_customConfiguration = customConfiguration; m_projectSettings = projectSettings;
m_globalConfiguration = globalConfiguration; m_globalSettings = globalSettings;
} }
AbstractAnalyzerSubConfig *AnalyzerRunConfigurationAspect::currentConfig() const ISettingsAspect *AnalyzerRunConfigurationAspect::currentSettings() const
{ {
return m_useGlobalSettings ? m_globalConfiguration : m_customConfiguration; return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
} }
AnalyzerRunConfigurationAspect::~AnalyzerRunConfigurationAspect() AnalyzerRunConfigurationAspect::~AnalyzerRunConfigurationAspect()
{ {
delete m_customConfiguration; delete m_projectSettings;
} }
void AnalyzerRunConfigurationAspect::fromMap(const QVariantMap &map) void AnalyzerRunConfigurationAspect::fromMap(const QVariantMap &map)
{ {
m_customConfiguration->fromMap(map); m_projectSettings->fromMap(map);
m_useGlobalSettings = map.value(QLatin1String(useGlobalC), true).toBool(); m_useGlobalSettings = map.value(QLatin1String(useGlobalC), true).toBool();
} }
void AnalyzerRunConfigurationAspect::toMap(QVariantMap &map) const void AnalyzerRunConfigurationAspect::toMap(QVariantMap &map) const
{ {
m_customConfiguration->toMap(map); m_projectSettings->toMap(map);
map.insert(QLatin1String(useGlobalC), m_useGlobalSettings); map.insert(QLatin1String(useGlobalC), m_useGlobalSettings);
} }
...@@ -82,7 +81,7 @@ AnalyzerRunConfigurationAspect *AnalyzerRunConfigurationAspect::clone( ...@@ -82,7 +81,7 @@ AnalyzerRunConfigurationAspect *AnalyzerRunConfigurationAspect::clone(
{ {
Q_UNUSED(parent) Q_UNUSED(parent)
AnalyzerRunConfigurationAspect *other AnalyzerRunConfigurationAspect *other
= new AnalyzerRunConfigurationAspect(m_customConfiguration->clone(), m_globalConfiguration); = new AnalyzerRunConfigurationAspect(m_projectSettings->clone(), m_globalSettings);
other->m_useGlobalSettings = m_useGlobalSettings; other->m_useGlobalSettings = m_useGlobalSettings;
return other; return other;
} }
...@@ -94,11 +93,11 @@ void AnalyzerRunConfigurationAspect::setUsingGlobalSettings(bool value) ...@@ -94,11 +93,11 @@ void AnalyzerRunConfigurationAspect::setUsingGlobalSettings(bool value)
void AnalyzerRunConfigurationAspect::resetCustomToGlobalSettings() void AnalyzerRunConfigurationAspect::resetCustomToGlobalSettings()
{ {
AbstractAnalyzerSubConfig *global = globalSubConfig(); ISettingsAspect *global = globalSettings();
QTC_ASSERT(global, return); QTC_ASSERT(global, return);
QVariantMap map; QVariantMap map;
global->toMap(map); global->toMap(map);
m_customConfiguration->fromMap(map); m_projectSettings->fromMap(map);
} }
ProjectExplorer::RunConfigWidget *AnalyzerRunConfigurationAspect::createConfigurationWidget() ProjectExplorer::RunConfigWidget *AnalyzerRunConfigurationAspect::createConfigurationWidget()
......
...@@ -45,33 +45,28 @@ namespace Analyzer { ...@@ -45,33 +45,28 @@ namespace Analyzer {
* If global and project-specific settings differ for your tool, * If global and project-specific settings differ for your tool,
* create one subclass for each. * create one subclass for each.
*/ */
class ANALYZER_EXPORT AbstractAnalyzerSubConfig : public QObject class ANALYZER_EXPORT ISettingsAspect : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
AbstractAnalyzerSubConfig() {} ISettingsAspect() {}
/// convert current configuration into map for storage /// Converts current object into map for storage.
virtual void toMap(QVariantMap &map) const = 0; virtual void toMap(QVariantMap &map) const = 0;
/// read configuration from @p map /// Read object state from @p map.
virtual void fromMap(const QVariantMap &map) = 0; virtual void fromMap(const QVariantMap &map) = 0;
/// create a configuration widget for this configuration /// Create a configuration widget for this settings aspect.
virtual QWidget *createConfigWidget(QWidget *parent) = 0; virtual QWidget *createConfigWidget(QWidget *parent) = 0;
/// clones s AbstractAnalyzerSubConfig /// Clones the object.
virtual AbstractAnalyzerSubConfig *clone() = 0; virtual ISettingsAspect *clone() = 0;
}; };
/** /**
* Settings associated with a single project/run configuration * Settings associated with a single project/run configuration
* *
* To access your custom configuration use:
* @code
* ProjectExplorer::RunConfiguration *rc = ...;
* rc->extraAspect<AnalyzerRunConfigurationAspect>()->subConfig<YourProjectConfig>()->...
* @endcode
*/ */
class ANALYZER_EXPORT AnalyzerRunConfigurationAspect class ANALYZER_EXPORT AnalyzerRunConfigurationAspect
: public ProjectExplorer::IRunConfigurationAspect : public ProjectExplorer::IRunConfigurationAspect
...@@ -79,8 +74,8 @@ class ANALYZER_EXPORT AnalyzerRunConfigurationAspect ...@@ -79,8 +74,8 @@ class ANALYZER_EXPORT AnalyzerRunConfigurationAspect
Q_OBJECT Q_OBJECT
public: public:
AnalyzerRunConfigurationAspect(AbstractAnalyzerSubConfig *customConfiguration, AnalyzerRunConfigurationAspect(ISettingsAspect *projectSettings,
AbstractAnalyzerSubConfig *globalConfiguration); ISettingsAspect *globalSettings);
~AnalyzerRunConfigurationAspect(); ~AnalyzerRunConfigurationAspect();
...@@ -90,9 +85,9 @@ public: ...@@ -90,9 +85,9 @@ public:
void setUsingGlobalSettings(bool value); void setUsingGlobalSettings(bool value);
void resetCustomToGlobalSettings(); void resetCustomToGlobalSettings();
AbstractAnalyzerSubConfig *customSubConfig() const { return m_customConfiguration; } ISettingsAspect *projectSettings() const { return m_projectSettings; }
AbstractAnalyzerSubConfig *globalSubConfig() const { return m_globalConfiguration; } ISettingsAspect *globalSettings() const { return m_globalSettings; }
AbstractAnalyzerSubConfig *currentConfig() const; ISettingsAspect *currentSettings() const;
ProjectExplorer::RunConfigWidget *createConfigurationWidget(); ProjectExplorer::RunConfigWidget *createConfigurationWidget();
protected: protected:
...@@ -101,8 +96,8 @@ protected: ...@@ -101,8 +96,8 @@ protected:
private: private:
bool m_useGlobalSettings; bool m_useGlobalSettings;
AbstractAnalyzerSubConfig *m_customConfiguration; ISettingsAspect *m_projectSettings;
AbstractAnalyzerSubConfig *m_globalConfiguration; ISettingsAspect *m_globalSettings;
}; };
} // namespace Analyzer } // namespace Analyzer
......
...@@ -548,7 +548,7 @@ AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartPa ...@@ -548,7 +548,7 @@ AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartPa
if (runConfiguration) { if (runConfiguration) {
if (AnalyzerRunConfigurationAspect *analyzerAspect if (AnalyzerRunConfigurationAspect *analyzerAspect
= runConfiguration->extraAspect<AnalyzerRunConfigurationAspect>(ANALYZER_VALGRIND_SETTINGS)) { = runConfiguration->extraAspect<AnalyzerRunConfigurationAspect>(ANALYZER_VALGRIND_SETTINGS)) {
if (const ValgrindBaseSettings *settings = qobject_cast<ValgrindBaseSettings *>(analyzerAspect->currentConfig())) { if (const ValgrindBaseSettings *settings = qobject_cast<ValgrindBaseSettings *>(analyzerAspect->currentSettings())) {
m_visualisation->setMinimumInclusiveCostRatio(settings->visualisationMinimumInclusiveCostRatio() / 100.0); m_visualisation->setMinimumInclusiveCostRatio(settings->visualisationMinimumInclusiveCostRatio() / 100.0);
m_proxyModel->setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio() / 100.0); m_proxyModel->setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio() / 100.0);
m_dataModel->setVerboseToolTipsEnabled(settings->enableEventToolTips()); m_dataModel->setVerboseToolTipsEnabled(settings->enableEventToolTips());
......
...@@ -232,7 +232,7 @@ void MemcheckTool::maybeActiveRunConfigurationChanged() ...@@ -232,7 +232,7 @@ void MemcheckTool::maybeActiveRunConfigurationChanged()
if (Target *target = project->activeTarget()) if (Target *target = project->activeTarget())
if (RunConfiguration *rc = target->activeRunConfiguration()) if (RunConfiguration *rc = target->activeRunConfiguration())
if (AnalyzerRunConfigurationAspect *aspect = rc->extraAspect<AnalyzerRunConfigurationAspect>(ANALYZER_VALGRIND_SETTINGS)) if (AnalyzerRunConfigurationAspect *aspect = rc->extraAspect<AnalyzerRunConfigurationAspect>(ANALYZER_VALGRIND_SETTINGS))
settings = qobject_cast<ValgrindBaseSettings *>(aspect->customSubConfig()); settings = qobject_cast<ValgrindBaseSettings *>(aspect->projectSettings());
if (!settings) // fallback to global settings if (!settings) // fallback to global settings
settings = ValgrindPlugin::globalSettings(); settings = ValgrindPlugin::globalSettings();
......
...@@ -65,7 +65,7 @@ ValgrindRunControl::ValgrindRunControl(const AnalyzerStartParameters &sp, ...@@ -65,7 +65,7 @@ ValgrindRunControl::ValgrindRunControl(const AnalyzerStartParameters &sp,
{ {
if (runConfiguration) if (runConfiguration)
if (AnalyzerRunConfigurationAspect *aspect = runConfiguration->extraAspect<AnalyzerRunConfigurationAspect>(ANALYZER_VALGRIND_SETTINGS)) if (AnalyzerRunConfigurationAspect *aspect = runConfiguration->extraAspect<AnalyzerRunConfigurationAspect>(ANALYZER_VALGRIND_SETTINGS))
m_settings = qobject_cast<ValgrindBaseSettings *>(aspect->customSubConfig()); m_settings = qobject_cast<ValgrindBaseSettings *>(aspect->projectSettings());
if (!m_settings) if (!m_settings)
m_settings = ValgrindPlugin::globalSettings(); m_settings = ValgrindPlugin::globalSettings();
......
...@@ -282,7 +282,7 @@ void ValgrindGlobalSettings::fromMap(const QVariantMap &map) ...@@ -282,7 +282,7 @@ void ValgrindGlobalSettings::fromMap(const QVariantMap &map)
setIfPresent(map, QLatin1String(callgrindShortenTemplates), &m_shortenTemplates); setIfPresent(map, QLatin1String(callgrindShortenTemplates), &m_shortenTemplates);
} }
AbstractAnalyzerSubConfig *ValgrindGlobalSettings::clone() ISettingsAspect *ValgrindGlobalSettings::clone()
{ {
ValgrindGlobalSettings *other = new ValgrindGlobalSettings; ValgrindGlobalSettings *other = new ValgrindGlobalSettings;
QVariantMap data; QVariantMap data;
...@@ -461,7 +461,7 @@ void ValgrindProjectSettings::fromMap(const QVariantMap &map) ...@@ -461,7 +461,7 @@ void ValgrindProjectSettings::fromMap(const QVariantMap &map)
setIfPresent(map, QLatin1String(removedSuppressionFilesC), &m_disabledGlobalSuppressionFiles); setIfPresent(map, QLatin1String(removedSuppressionFilesC), &m_disabledGlobalSuppressionFiles);
} }
AbstractAnalyzerSubConfig *ValgrindProjectSettings::clone() ISettingsAspect *ValgrindProjectSettings::clone()
{ {
ValgrindProjectSettings *other = new ValgrindProjectSettings; ValgrindProjectSettings *other = new ValgrindProjectSettings;
QVariantMap data; QVariantMap data;
......
...@@ -46,7 +46,7 @@ const char ANALYZER_VALGRIND_SETTINGS[] = "Analyzer.Valgrind.Settings"; ...@@ -46,7 +46,7 @@ const char ANALYZER_VALGRIND_SETTINGS[] = "Analyzer.Valgrind.Settings";
/** /**
* Valgrind settings shared for global and per-project. * Valgrind settings shared for global and per-project.
*/ */
class ValgrindBaseSettings : public Analyzer::AbstractAnalyzerSubConfig class ValgrindBaseSettings : public Analyzer::ISettingsAspect
{ {
Q_OBJECT Q_OBJECT
...@@ -170,7 +170,7 @@ public: ...@@ -170,7 +170,7 @@ public:
QWidget *createConfigWidget(QWidget *parent); QWidget *createConfigWidget(QWidget *parent);
void toMap(QVariantMap &map) const; void toMap(QVariantMap &map) const;
void fromMap(const QVariantMap &map); void fromMap(const QVariantMap &map);
virtual AbstractAnalyzerSubConfig *clone(); virtual ISettingsAspect *clone();
/* /*
* Global memcheck settings * Global memcheck settings
...@@ -230,7 +230,7 @@ public: ...@@ -230,7 +230,7 @@ public:
QWidget *createConfigWidget(QWidget *parent); QWidget *createConfigWidget(QWidget *parent);
void toMap(QVariantMap &map) const; void toMap(QVariantMap &map) const;
void fromMap(const QVariantMap &map); void fromMap(const QVariantMap &map);
virtual AbstractAnalyzerSubConfig *clone(); virtual ISettingsAspect *clone();
/** /**
* Per-project memcheck settings, saves a diff to the global suppression files list * Per-project memcheck settings, saves a diff to the global suppression files list
......
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