Commit cd460a36 authored by hjk's avatar hjk

RunConfigurationAspect: Streamline data serialization

Change-Id: I6f49dd9eeff53eafc51bd5238ca655437df12111
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent e3ae9e80
......@@ -71,11 +71,10 @@ void AnalyzerRunConfigurationAspect::fromMap(const QVariantMap &map)
m_useGlobalSettings = map.value(QLatin1String(useGlobalC), true).toBool();
}
QVariantMap AnalyzerRunConfigurationAspect::toMap() const
void AnalyzerRunConfigurationAspect::toMap(QVariantMap &map) const
{
QVariantMap map = m_customConfiguration->toMap();
m_customConfiguration->toMap(map);
map.insert(QLatin1String(useGlobalC), m_useGlobalSettings);
return map;
}
AnalyzerRunConfigurationAspect *AnalyzerRunConfigurationAspect::clone(
......@@ -97,7 +96,9 @@ void AnalyzerRunConfigurationAspect::resetCustomToGlobalSettings()
{
AbstractAnalyzerSubConfig *global = globalSubConfig();
QTC_ASSERT(global, return);
m_customConfiguration->fromMap(global->toMap());
QVariantMap map;
global->toMap(map);
m_customConfiguration->fromMap(map);
}
ProjectExplorer::RunConfigWidget *AnalyzerRunConfigurationAspect::createConfigurationWidget()
......
......@@ -53,7 +53,7 @@ public:
AbstractAnalyzerSubConfig() {}
/// convert current configuration into map for storage
virtual QVariantMap toMap() const = 0;
virtual void toMap(QVariantMap &map) const = 0;
/// read configuration from @p map
virtual void fromMap(const QVariantMap &map) = 0;
......@@ -84,7 +84,6 @@ public:
~AnalyzerRunConfigurationAspect();
virtual QVariantMap toMap() const;
AnalyzerRunConfigurationAspect *clone(ProjectExplorer::RunConfiguration *parent) const;
bool isUsingGlobalSettings() const { return m_useGlobalSettings; }
......@@ -97,7 +96,8 @@ public:
ProjectExplorer::RunConfigWidget *createConfigurationWidget();
protected:
virtual void fromMap(const QVariantMap &map);
void fromMap(const QVariantMap &map);
void toMap(QVariantMap &map) const;
private:
bool m_useGlobalSettings;
......
......@@ -277,16 +277,14 @@ bool DebuggerRunConfigurationAspect::isQmlDebuggingSpinboxSuppressed() const
return dev->canAutoDetectPorts();
}
QVariantMap DebuggerRunConfigurationAspect::toMap() const
void DebuggerRunConfigurationAspect::toMap(QVariantMap &map) const
{
QVariantMap map;
map.insert(QLatin1String(USE_CPP_DEBUGGER_KEY), m_useCppDebugger == EnabledLanguage);
map.insert(QLatin1String(USE_CPP_DEBUGGER_AUTO_KEY), m_useCppDebugger == AutoEnabledLanguage);
map.insert(QLatin1String(USE_QML_DEBUGGER_KEY), m_useQmlDebugger == EnabledLanguage);
map.insert(QLatin1String(USE_QML_DEBUGGER_AUTO_KEY), m_useQmlDebugger == AutoEnabledLanguage);
map.insert(QLatin1String(QML_DEBUG_SERVER_PORT_KEY), m_qmlDebugServerPort);
map.insert(QLatin1String(USE_MULTIPROCESS_KEY), m_useMultiProcess);
return map;
}
void DebuggerRunConfigurationAspect::fromMap(const QVariantMap &map)
......
......@@ -54,8 +54,8 @@ public:
AutoEnabledLanguage
};
QVariantMap toMap() const;
void fromMap(const QVariantMap &map);
void toMap(QVariantMap &map) const;
DebuggerRunConfigurationAspect *clone(ProjectExplorer::RunConfiguration *parent) const;
ProjectExplorer::RunConfigWidget *createConfigurationWidget();
......
......@@ -58,14 +58,6 @@ EnvironmentAspect::EnvironmentAspect(const EnvironmentAspect *other, RunConfigur
m_runConfiguration(parent)
{ }
QVariantMap EnvironmentAspect::toMap() const
{
QVariantMap data;
data.insert(QLatin1String(BASE_KEY), m_base);
data.insert(QLatin1String(CHANGES_KEY), Utils::EnvironmentItem::toStringList(m_changes));
return data;
}
RunConfigWidget *EnvironmentAspect::createConfigurationWidget()
{
return new EnvironmentAspectWidget(this);
......@@ -116,4 +108,10 @@ void EnvironmentAspect::fromMap(const QVariantMap &map)
m_changes = Utils::EnvironmentItem::fromStringList(map.value(QLatin1String(CHANGES_KEY)).toStringList());
}
void EnvironmentAspect::toMap(QVariantMap &data) const
{
data.insert(QLatin1String(BASE_KEY), m_base);
data.insert(QLatin1String(CHANGES_KEY), Utils::EnvironmentItem::toStringList(m_changes));
}
} // namespace ProjectExplorer
......@@ -47,7 +47,6 @@ class PROJECTEXPLORER_EXPORT EnvironmentAspect : public IRunConfigurationAspect
public:
// IRunConfigurationAspect:
QVariantMap toMap() const;
RunConfigWidget *createConfigurationWidget();
virtual RunConfiguration *runConfiguration() const { return m_runConfiguration; }
......@@ -73,6 +72,7 @@ protected:
EnvironmentAspect(const EnvironmentAspect *other, RunConfiguration *parent);
EnvironmentAspect(RunConfiguration *rc);
void fromMap(const QVariantMap &map);
void toMap(QVariantMap &map) const;
private:
mutable int m_base;
......
......@@ -224,7 +224,7 @@ QVariantMap RunConfiguration::toMap() const
QVariantMap map = ProjectConfiguration::toMap();
foreach (IRunConfigurationAspect *aspect, m_aspects)
map.unite(aspect->toMap());
aspect->toMap(map);
return map;
}
......
......@@ -78,7 +78,6 @@ class PROJECTEXPLORER_EXPORT IRunConfigurationAspect : public QObject
public:
virtual ~IRunConfigurationAspect() {}
virtual QVariantMap toMap() const = 0;
virtual IRunConfigurationAspect *clone(RunConfiguration *parent) const = 0;
virtual RunConfigWidget *createConfigurationWidget();
......@@ -91,6 +90,7 @@ public:
protected:
friend class RunConfiguration;
virtual void fromMap(const QVariantMap &map) = 0;
virtual void toMap(QVariantMap &data) const = 0;
private:
QString m_displayName;
......
......@@ -113,10 +113,8 @@ void ValgrindBaseSettings::fromMap(const QVariantMap &map)
emit changed();
}
QVariantMap ValgrindBaseSettings::toMap() const
void ValgrindBaseSettings::toMap(QVariantMap &map) const
{
QVariantMap map;
// General
map.insert(QLatin1String(valgrindExeC), m_valgrindExecutable);
......@@ -138,7 +136,6 @@ QVariantMap ValgrindBaseSettings::toMap() const
map.insert(QLatin1String(callgrindMinimumCostRatioC), m_minimumInclusiveCostRatio);
map.insert(QLatin1String(callgrindVisualisationMinimumCostRatioC),
m_visualisationMinimumInclusiveCostRatio);
return map;
}
void ValgrindBaseSettings::setValgrindExecutable(const QString &valgrindExecutable)
......@@ -288,13 +285,15 @@ void ValgrindGlobalSettings::fromMap(const QVariantMap &map)
AbstractAnalyzerSubConfig *ValgrindGlobalSettings::clone()
{
ValgrindGlobalSettings *other = new ValgrindGlobalSettings;
other->fromMap(toMap());
QVariantMap data;
toMap(data);
other->fromMap(data);
return other;
}
QVariantMap ValgrindGlobalSettings::toMap() const
void ValgrindGlobalSettings::toMap(QVariantMap &map) const
{
QVariantMap map = ValgrindBaseSettings::toMap();
ValgrindBaseSettings::toMap(map);
// Memcheck
map.insert(QLatin1String(suppressionFilesC), m_suppressionFiles);
......@@ -305,8 +304,6 @@ QVariantMap ValgrindGlobalSettings::toMap() const
map.insert(QLatin1String(callgrindCostFormatC), m_costFormat);
map.insert(QLatin1String(callgrindCycleDetectionC), m_detectCycles);
map.insert(QLatin1String(callgrindShortenTemplates), m_shortenTemplates);
return map;
}
//
......@@ -400,7 +397,8 @@ void ValgrindGlobalSettings::writeSettings() const
{
QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String(groupC));
const QVariantMap map = toMap();
QVariantMap map;
toMap(map);
for (QVariantMap::ConstIterator it = map.begin(); it != map.end(); ++it)
settings->setValue(it.key(), it.value());
settings->endGroup();
......@@ -466,19 +464,19 @@ void ValgrindProjectSettings::fromMap(const QVariantMap &map)
AbstractAnalyzerSubConfig *ValgrindProjectSettings::clone()
{
ValgrindProjectSettings *other = new ValgrindProjectSettings;
other->fromMap(toMap());
QVariantMap data;
toMap(data);
other->fromMap(data);
return other;
}
QVariantMap ValgrindProjectSettings::toMap() const
void ValgrindProjectSettings::toMap(QVariantMap &map) const
{
QVariantMap map = ValgrindBaseSettings::toMap();
ValgrindBaseSettings::toMap(map);
// Memcheck
map.insert(QLatin1String(addedSuppressionFilesC), m_addedSuppressionFiles);
map.insert(QLatin1String(removedSuppressionFilesC), m_disabledGlobalSuppressionFiles);
return map;
}
//
......
......@@ -53,8 +53,8 @@ class ValgrindBaseSettings : public Analyzer::AbstractAnalyzerSubConfig
public:
ValgrindBaseSettings() {}
virtual QVariantMap toMap() const;
virtual void fromMap(const QVariantMap &map);
void toMap(QVariantMap &map) const;
void fromMap(const QVariantMap &map);
signals:
void changed(); // sent when multiple values have changed simulatenously (e.g. fromMap)
......@@ -168,7 +168,7 @@ public:
ValgrindGlobalSettings();
QWidget *createConfigWidget(QWidget *parent);
QVariantMap toMap() const;
void toMap(QVariantMap &map) const;
void fromMap(const QVariantMap &map);
virtual AbstractAnalyzerSubConfig *clone();
......@@ -228,7 +228,7 @@ public:
ValgrindProjectSettings() {}
QWidget *createConfigWidget(QWidget *parent);
QVariantMap toMap() const;
void toMap(QVariantMap &map) const;
void fromMap(const QVariantMap &map);
virtual AbstractAnalyzerSubConfig *clone();
......
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