|
|
@ -50,12 +50,13 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const
|
|
|
|
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)
|
|
|
|
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*>()))
|
|
|
|
if (dispData.canConvert<QObject*>() && qobject_cast<ComboItem*>(dispData.value<QObject*>()))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return qobject_cast<ComboItem*>(dispData.value<QObject*>())->toString();
|
|
|
|
return qobject_cast<ComboItem*>(dispData.value<QObject*>())->toString();
|
|
|
@ -68,6 +69,20 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
return dispData;
|
|
|
|
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;
|
|
|
|
return QVariant::Invalid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|