Added support for binding QDecimal values.

This commit is contained in:
2016-02-19 15:34:52 +01:00
parent 046c64b312
commit 8e999c7818
12 changed files with 70 additions and 17 deletions
+20 -2
View File
@@ -10,6 +10,9 @@
#include <QVariant>
#include <QMessageBox>
#include <QComboBox>
#include <QDebug>
#include "../qdecimal/src/QDecDouble.hh"
#include "iform.h"
#include "service.h"
@@ -77,7 +80,15 @@ private:
registerCombos();
foreach (QWidget *widget, m_bindWidgets) {
const char* prop = widget->metaObject()->userProperty().name();
widget->setProperty(prop, ((QObject*)m_entity.data())->property(widget->objectName().toStdString().c_str()));
QVariant value = ((QObject*)m_entity.data())->property(widget->objectName().toStdString().c_str());
if (value.canConvert<QDecDouble>())
{
widget->setProperty(prop, value.value<QDecDouble>().toString());
}
else
{
widget->setProperty(prop, value);
}
}
foreach (QComboBox *combo, m_bindCombos.keys()) {
@@ -117,7 +128,14 @@ private:
foreach (QWidget *widget, m_bindWidgets) {
const char* prop = widget->metaObject()->userProperty().name();
((QObject*)m_entity.data())->setProperty(widget->objectName().toStdString().c_str(), widget->property(prop));
QVariant val = widget->property(prop);
if (((QObject*)m_entity.data())->property(widget->objectName().toStdString().c_str()).canConvert<QDecDouble>())
{
QDecDouble dec(val.toDouble());
val = QVariant::fromValue(dec);
}
((QObject*)m_entity.data())->setProperty(widget->objectName().toStdString().c_str(), val);
}
foreach (QComboBox *combo, m_bindCombos.keys()) {