Inline editing of QDecDouble in AutoTableModel now possible.

master
Josef Rokos 8 years ago
parent 0e803c23cb
commit 50ecd60c9a

@ -6,6 +6,7 @@
#include <QMetaProperty> #include <QMetaProperty>
#include <QModelIndex> #include <QModelIndex>
#include <QDebug> #include <QDebug>
#include <QDecDouble.hh>
#include "../qdecimal/src/QDecDouble.hh" #include "../qdecimal/src/QDecDouble.hh"
@ -264,7 +265,14 @@ public:
QSharedPointer<T> entity = m_list.at(index.row()); QSharedPointer<T> entity = m_list.at(index.row());
QObject *rawEntity = (QObject*)entity.data(); QObject *rawEntity = (QObject*)entity.data();
rawEntity->setProperty(rawEntity->metaObject()->property(index.column() + 1).name(), value); QVariant val = value;
if (rawEntity->property(rawEntity->metaObject()->property(index.column() + 1).name()).canConvert<QDecDouble>())
{
QDecDouble dec(val.toDouble());
val = QVariant::fromValue(dec);
}
rawEntity->setProperty(rawEntity->metaObject()->property(index.column() + 1).name(), val);
} }
if (role == Qt::CheckStateRole) if (role == Qt::CheckStateRole)

Loading…
Cancel
Save