diff options
Diffstat (limited to 'pokescripting/Config.cpp')
| -rw-r--r-- | pokescripting/Config.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/pokescripting/Config.cpp b/pokescripting/Config.cpp index 3e2e3adc..a0739591 100644 --- a/pokescripting/Config.cpp +++ b/pokescripting/Config.cpp @@ -23,20 +23,34 @@ Pokescripting::Config::Config(QObject* parent) : { } -void Pokescripting::Config::addValue(const QString& name, const QVariant& value) +void Pokescripting::Config::addValue(const QString& name, const QVariant& value, const bool temporary) { if (!m_values.contains(name)) - m_values[name] = value; + { + setValue(name, value, temporary); + emit(valueAdded(name, value)); + } } -void Pokescripting::Config::setValue(const QString& name, const QVariant& value) +void Pokescripting::Config::setValue(const QString& name, const QVariant& value, const bool temporary) { + const QVariant& oldValue = m_values[name]; m_values[name] = value; + if (temporary) + { + if (m_temporaries.contains(name)) + m_temporaries.append(name); + } + else + m_temporaries.removeAll(name); + emit(valueChanged(name, oldValue, value)); } void Pokescripting::Config::removeValue(const QString& name) { m_values.remove(name); + m_temporaries.removeAll(name); + emit(valueRemoved(name)); } QVariant Pokescripting::Config::value(const QString& name, const bool recursive) const @@ -65,6 +79,12 @@ bool Pokescripting::Config::hasValue(const QString& name, const bool recursive) return false; } +void Pokescripting::Config::clearTemporary() +{ + while (m_temporaries.size()) + removeValue(m_temporaries[0]); +} + void Pokescripting::Config::writeBack() { } |
