GH-1223 fix override settings

They now work more like passthrough settings, except not passing through set and reset
This commit is contained in:
Petr Mrázek
2015-09-04 02:10:29 +02:00
parent 151a0ca11e
commit cd108fd029
8 changed files with 88 additions and 37 deletions

View File

@ -15,16 +15,40 @@
#include "OverrideSetting.h"
OverrideSetting::OverrideSetting(std::shared_ptr<Setting> other)
OverrideSetting::OverrideSetting(std::shared_ptr<Setting> other, std::shared_ptr<Setting> gate)
: Setting(other->configKeys(), QVariant())
{
Q_ASSERT(other);
Q_ASSERT(gate);
m_other = other;
m_gate = gate;
}
bool OverrideSetting::isOverriding() const
{
return m_gate->get().toBool();
}
QVariant OverrideSetting::defValue() const
{
if (m_other)
return m_other->get();
else
return QVariant();
return m_other->get();
}
QVariant OverrideSetting::get() const
{
if(isOverriding())
{
return Setting::get();
}
return m_other->get();
}
void OverrideSetting::reset()
{
Setting::reset();
}
void OverrideSetting::set(QVariant value)
{
Setting::set(value);
}