From ef205affdb73bfdbef5830996e6336e583660fbc Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 19 Nov 2015 09:37:42 +0100 Subject: Use the new modelresult in the dummyclient --- common/clientapi.h | 4 ++++ common/modelresult.h | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/clientapi.h b/common/clientapi.h index 707e81d..179bb5c 100644 --- a/common/clientapi.h +++ b/common/clientapi.h @@ -100,6 +100,10 @@ public: return resultSet->emitter(); } + enum Roles { + DomainObjectRole = Qt::UserRole + 1 //Must be the same as in ModelResult + }; + /** * Asynchronusly load a dataset with tree structure information */ diff --git a/common/modelresult.h b/common/modelresult.h index 8ca6daa..3b45955 100644 --- a/common/modelresult.h +++ b/common/modelresult.h @@ -63,11 +63,18 @@ public: virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { if (role == DomainObjectRole) { - qWarning() << "trying to get entity " << index.internalId(); Q_ASSERT(mEntities.contains(index.internalId())); return QVariant::fromValue(mEntities.value(index.internalId())); } - qDebug() << "Invalid role"; + if (role == Qt::DisplayRole) { + if (index.column() < mPropertyColumns.size()) { + Q_ASSERT(mEntities.contains(index.internalId())); + auto entity = mEntities.value(index.internalId()); + return entity->getProperty(mPropertyColumns.at(index.column())).toString(); + } else { + return "No data available"; + } + } return QVariant(); } -- cgit v1.2.3