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.
print
Josef Rokos
parent 96685d2bed
commit 7ae8c53a16

@ -72,9 +72,6 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="price"/>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="count"/>
</item>
@ -84,8 +81,27 @@
<item row="5" column="1">
<widget class="QComboBox" name="vat"/>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="price">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>name</tabstop>
<tabstop>shortName</tabstop>
<tabstop>code</tabstop>
<tabstop>type</tabstop>
<tabstop>price</tabstop>
<tabstop>vat</tabstop>
<tabstop>count</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

@ -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;
}

@ -1,4 +1,5 @@
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += \
qdecimal \

@ -31,9 +31,6 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="price"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
@ -78,12 +75,21 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="price">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<double>999999999.990000009536743</double>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>accServiceName</tabstop>
<tabstop>accServiceCode</tabstop>
<tabstop>price</tabstop>
<tabstop>serviceType</tabstop>
<tabstop>vatType</tabstop>
<tabstop>salePossible</tabstop>

Loading…
Cancel
Save