Commit bae07b16 authored by dogmaphobic's avatar dogmaphobic

Type checking in Fact::setValue()

FactTextField, when setting the value from its "text" field, was converting the value to string. This was causing (QML JavaScript) code that uses the value for computation to stop working once the user changed the value.
parent 72a7acc5
......@@ -39,7 +39,27 @@ Fact::Fact(QString name, FactMetaData::ValueType_t type, QObject* parent) :
void Fact::setValue(const QVariant& value)
{
_value = value;
switch (type()) {
case FactMetaData::valueTypeInt8:
case FactMetaData::valueTypeInt16:
case FactMetaData::valueTypeInt32:
_value.setValue(QVariant(value.toInt()));
break;
case FactMetaData::valueTypeUint8:
case FactMetaData::valueTypeUint16:
case FactMetaData::valueTypeUint32:
_value.setValue(value.toUInt());
break;
case FactMetaData::valueTypeFloat:
_value.setValue(value.toFloat());
break;
case FactMetaData::valueTypeDouble:
_value.setValue(value.toDouble());
break;
}
emit valueChanged(_value);
emit _containerValueChanged(_value);
}
......
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