Remove redundant field Formula Value.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-03-18 15:50:27 +02:00
parent cc045b1285
commit b146b72963

View File

@ -35,27 +35,17 @@
#include "../vpatterndb/vformula.h" #include "../vpatterndb/vformula.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
enum class ChildType : char {Invalid = 0, Value = 1, Formula = 2};
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormulaProperty::VFormulaProperty(const QString &name) VFormulaProperty::VFormulaProperty(const QString &name)
: VProperty(name, static_cast<QVariant::Type>(VFormula::FormulaTypeId())) : VProperty(name, static_cast<QVariant::Type>(VFormula::FormulaTypeId()))
{ {
d_ptr->type = VPE::Property::Complex; d_ptr->type = VPE::Property::Complex;
VPE::VStringProperty* tmpValue = new VPE::VStringProperty(tr("Value"));
addChild(tmpValue);
tmpValue->setUpdateBehaviour(true, false);
tmpValue->setReadOnly(true);
tmpValue->setOsSeparator(qApp->Settings()->GetOsSeparator());
tmpValue->setTypeForParent(static_cast<int>(ChildType::Value));
VPE::VStringProperty* tmpFormula = new VPE::VStringProperty(tr("Formula")); VPE::VStringProperty* tmpFormula = new VPE::VStringProperty(tr("Formula"));
addChild(tmpFormula); addChild(tmpFormula);
tmpFormula->setClearButtonEnable(true); tmpFormula->setClearButtonEnable(true);
tmpFormula->setUpdateBehaviour(true, false); tmpFormula->setUpdateBehaviour(true, false);
tmpFormula->setOsSeparator(qApp->Settings()->GetOsSeparator()); tmpFormula->setOsSeparator(qApp->Settings()->GetOsSeparator());
tmpFormula->setTypeForParent(static_cast<int>(ChildType::Formula));
setValue(0); setValue(0);
} }
@ -187,7 +177,7 @@ VFormula VFormulaProperty::GetFormula() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VFormulaProperty::SetFormula(const VFormula &formula) void VFormulaProperty::SetFormula(const VFormula &formula)
{ {
if (d_ptr->Children.count() < 2) if (d_ptr->Children.count() < 1)
{ {
return; return;
} }
@ -197,14 +187,10 @@ void VFormulaProperty::SetFormula(const VFormula &formula)
value.convert(VFormula::FormulaTypeId()); value.convert(VFormula::FormulaTypeId());
VProperty::d_ptr->VariantValue = value; VProperty::d_ptr->VariantValue = value;
QVariant tmpValue(formula.getStringValue());
tmpValue.convert(QVariant::String);
QVariant tmpFormula(formula.GetFormula()); QVariant tmpFormula(formula.GetFormula());
tmpFormula.convert(QVariant::String); tmpFormula.convert(QVariant::String);
VProperty::d_ptr->Children.at(0)->setValue(tmpValue); VProperty::d_ptr->Children.at(0)->setValue(tmpFormula);
VProperty::d_ptr->Children.at(1)->setValue(tmpFormula);
if (VProperty::d_ptr->editor != nullptr) if (VProperty::d_ptr->editor != nullptr)
{ {
@ -214,10 +200,8 @@ void VFormulaProperty::SetFormula(const VFormula &formula)
void VFormulaProperty::ValueChildChanged(const QVariant &value, int typeForParent) void VFormulaProperty::ValueChildChanged(const QVariant &value, int typeForParent)
{ {
if (typeForParent == static_cast<int>(ChildType::Formula)) Q_UNUSED(typeForParent)
{
VFormula newFormula = GetFormula(); VFormula newFormula = GetFormula();
newFormula.SetFormula(value.toString(), FormulaType::FromUser); newFormula.SetFormula(value.toString(), FormulaType::FromUser);
SetFormula(newFormula); SetFormula(newFormula);
}
} }