forked from qt-creator/qt-creator
ProjectExplorer: Keep RunConfiguration in ISettingsAspect
Any SettingsAspect that doesn't refer to the global settings has a specific RunConfiguration it is about. This can be very handy to know when constructing the actual settings. Right now there is no way to find out about it. Drop the clone() and create() methods. They weren't used anywhere and a proper implementation should take care of the runConfiguration member. Change-Id: Ie505a9b19707f8a1b6bf9cae73513cd3c30d0bca Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -78,13 +78,14 @@ namespace ProjectExplorer {
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
ISettingsAspect *ISettingsAspect::clone() const
|
||||
ISettingsAspect::ISettingsAspect(RunConfiguration *runConfiguration) :
|
||||
m_runConfiguration(runConfiguration)
|
||||
{
|
||||
ISettingsAspect *other = create();
|
||||
QVariantMap data;
|
||||
toMap(data);
|
||||
other->fromMap(data);
|
||||
return other;
|
||||
}
|
||||
|
||||
RunConfiguration *ISettingsAspect::runConfiguration() const
|
||||
{
|
||||
return m_runConfiguration;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
@@ -77,14 +77,12 @@ class PROJECTEXPLORER_EXPORT ISettingsAspect : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ISettingsAspect() { }
|
||||
ISettingsAspect(RunConfiguration *runConfiguration);
|
||||
|
||||
/// Create a configuration widget for this settings aspect.
|
||||
virtual QWidget *createConfigWidget(QWidget *parent) = 0;
|
||||
/// "Virtual default constructor"
|
||||
virtual ISettingsAspect *create() const = 0;
|
||||
/// "Virtual copy constructor"
|
||||
ISettingsAspect *clone() const;
|
||||
|
||||
RunConfiguration *runConfiguration() const;
|
||||
|
||||
protected:
|
||||
///
|
||||
@@ -93,6 +91,9 @@ protected:
|
||||
virtual void toMap(QVariantMap &map) const = 0;
|
||||
/// Read object state from @p map.
|
||||
virtual void fromMap(const QVariantMap &map) = 0;
|
||||
|
||||
private:
|
||||
RunConfiguration *m_runConfiguration;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -37,7 +37,7 @@ QmlProfilerRunConfigurationAspect::QmlProfilerRunConfigurationAspect(
|
||||
ProjectExplorer::RunConfiguration *parent) :
|
||||
ProjectExplorer::IRunConfigurationAspect(parent)
|
||||
{
|
||||
setProjectSettings(new QmlProfilerSettings());
|
||||
setProjectSettings(new QmlProfilerSettings(parent));
|
||||
setGlobalSettings(QmlProfilerPlugin::globalSettings());
|
||||
setId(Constants::SETTINGS);
|
||||
setDisplayName(QCoreApplication::translate("QmlProfilerRunConfiguration", "QML Profiler Settings"));
|
||||
|
@@ -34,7 +34,8 @@
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
QmlProfilerSettings::QmlProfilerSettings()
|
||||
QmlProfilerSettings::QmlProfilerSettings(ProjectExplorer::RunConfiguration *runConfiguration) :
|
||||
ProjectExplorer::ISettingsAspect(runConfiguration)
|
||||
{
|
||||
QVariantMap defaults;
|
||||
defaults.insert(QLatin1String(Constants::FLUSH_INTERVAL), 1000);
|
||||
@@ -58,11 +59,6 @@ QWidget *QmlProfilerSettings::createConfigWidget(QWidget *parent)
|
||||
return new Internal::QmlProfilerConfigWidget(this, parent);
|
||||
}
|
||||
|
||||
ProjectExplorer::ISettingsAspect *QmlProfilerSettings::create() const
|
||||
{
|
||||
return new QmlProfilerSettings;
|
||||
}
|
||||
|
||||
bool QmlProfilerSettings::flushEnabled() const
|
||||
{
|
||||
return m_flushEnabled;
|
||||
|
@@ -34,9 +34,8 @@ class QmlProfilerSettings : public ProjectExplorer::ISettingsAspect
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QmlProfilerSettings();
|
||||
QmlProfilerSettings(ProjectExplorer::RunConfiguration *runConfiguration = nullptr);
|
||||
QWidget *createConfigWidget(QWidget *parent);
|
||||
ProjectExplorer::ISettingsAspect *create() const;
|
||||
|
||||
bool flushEnabled() const;
|
||||
void setFlushEnabled(bool flushEnabled);
|
||||
|
@@ -95,7 +95,7 @@ public:
|
||||
ValgrindRunConfigurationAspect(RunConfiguration *parent)
|
||||
: IRunConfigurationAspect(parent)
|
||||
{
|
||||
setProjectSettings(new ValgrindProjectSettings());
|
||||
setProjectSettings(new ValgrindProjectSettings(parent));
|
||||
setGlobalSettings(ValgrindPlugin::globalSettings());
|
||||
setId(ANALYZER_VALGRIND_SETTINGS);
|
||||
setDisplayName(QCoreApplication::translate("Valgrind::Internal::ValgrindRunConfigurationAspect",
|
||||
|
@@ -113,6 +113,10 @@ void ValgrindBaseSettings::fromMap(const QVariantMap &map)
|
||||
emit changed();
|
||||
}
|
||||
|
||||
ValgrindBaseSettings::ValgrindBaseSettings(ProjectExplorer::RunConfiguration *runConfiguration) :
|
||||
ProjectExplorer::ISettingsAspect(runConfiguration)
|
||||
{}
|
||||
|
||||
void ValgrindBaseSettings::toMap(QVariantMap &map) const
|
||||
{
|
||||
// General
|
||||
@@ -471,6 +475,11 @@ void ValgrindGlobalSettings::setShortenTemplates(bool on)
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
ValgrindProjectSettings::ValgrindProjectSettings(
|
||||
ProjectExplorer::RunConfiguration *runConfiguration) :
|
||||
ValgrindBaseSettings(runConfiguration)
|
||||
{}
|
||||
|
||||
QWidget *ValgrindProjectSettings::createConfigWidget(QWidget *parent)
|
||||
{
|
||||
return new ValgrindConfigWidget(this, parent, false);
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
LeakCheckOnFinishYes
|
||||
};
|
||||
|
||||
ValgrindBaseSettings() {}
|
||||
ValgrindBaseSettings(ProjectExplorer::RunConfiguration *runConfiguration = nullptr);
|
||||
|
||||
void toMap(QVariantMap &map) const;
|
||||
void fromMap(const QVariantMap &map);
|
||||
@@ -186,8 +186,6 @@ public:
|
||||
QWidget *createConfigWidget(QWidget *parent) override;
|
||||
void toMap(QVariantMap &map) const;
|
||||
void fromMap(const QVariantMap &map);
|
||||
ISettingsAspect *create() const { return new ValgrindGlobalSettings; }
|
||||
|
||||
|
||||
/*
|
||||
* Global memcheck settings
|
||||
@@ -241,12 +239,11 @@ class ValgrindProjectSettings : public ValgrindBaseSettings
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ValgrindProjectSettings() {}
|
||||
ValgrindProjectSettings(ProjectExplorer::RunConfiguration *runConfiguration);
|
||||
|
||||
QWidget *createConfigWidget(QWidget *parent) override;
|
||||
void toMap(QVariantMap &map) const;
|
||||
void fromMap(const QVariantMap &map);
|
||||
ISettingsAspect *create() const { return new ValgrindProjectSettings; }
|
||||
|
||||
/**
|
||||
* Per-project memcheck settings, saves a diff to the global suppression files list
|
||||
|
Reference in New Issue
Block a user