Numeric datatypes auto aligned to right in AutoTableModel based grids.
Swithced QLineEdit to QDoubleSpinBox for better number formating in commodityform.ui and accserviceform.ui. Fixed build order.
This commit is contained in:
+19
-4
@@ -50,12 +50,13 @@ public:
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const
|
||||
{
|
||||
QSharedPointer<T> entity = m_list.at(index.row());
|
||||
QObject *rawEntity = (QObject*)entity.data();
|
||||
|
||||
QVariant dispData = rawEntity->property(rawEntity->metaObject()->property(index.column() + 1).name());
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
QSharedPointer<T> entity = m_list.at(index.row());
|
||||
QObject *rawEntity = (QObject*)entity.data();
|
||||
|
||||
QVariant dispData = rawEntity->property(rawEntity->metaObject()->property(index.column() + 1).name());
|
||||
if (dispData.canConvert<QObject*>() && qobject_cast<ComboItem*>(dispData.value<QObject*>()))
|
||||
{
|
||||
return qobject_cast<ComboItem*>(dispData.value<QObject*>())->toString();
|
||||
@@ -68,6 +69,20 @@ public:
|
||||
|
||||
return dispData;
|
||||
}
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
{
|
||||
if (dispData.canConvert<QDecDouble>()
|
||||
|| dispData.type() == QVariant::Date
|
||||
|| dispData.type() == QVariant::Time
|
||||
|| dispData.type() == QVariant::DateTime
|
||||
|| dispData.type() == QVariant::Int
|
||||
|| dispData.type() == QVariant::Double)
|
||||
{
|
||||
return Qt::AlignRight;
|
||||
}
|
||||
|
||||
return Qt::AlignLeft;
|
||||
}
|
||||
|
||||
return QVariant::Invalid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user