|
|
|
@ -95,6 +95,30 @@ public:
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
QList<QSharedPointer<T> > m_list;
|
|
|
|
|
|
|
|
|
|
// QAbstractItemModel interface
|
|
|
|
|
public:
|
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const
|
|
|
|
|
{
|
|
|
|
|
if (role != Qt::DisplayRole) {
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (orientation == Qt::Horizontal) {
|
|
|
|
|
QObject *entity = (QObject*)new T();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < entity->metaObject()->propertyCount(); i++) {
|
|
|
|
|
if (i == section) {
|
|
|
|
|
QString colName(entity->metaObject()->property(i + 1).name());
|
|
|
|
|
return tr(colName.toStdString().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete entity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QVariant(section + 1);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // ODBTABLEMODEL_H
|
|
|
|
|