|
|
|
@ -49,13 +49,14 @@ public:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const
|
|
|
|
|
{
|
|
|
|
|
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 (role == Qt::DisplayRole)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|