summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-11-19 09:37:42 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-11-19 09:37:42 +0100
commitef205affdb73bfdbef5830996e6336e583660fbc (patch)
treeaba43d38e6ea9a2b48a6818978bad123fbb5bcc0 /common
parentb42047ad90470ecab329375fdacff03564c80074 (diff)
downloadsink-ef205affdb73bfdbef5830996e6336e583660fbc.tar.gz
sink-ef205affdb73bfdbef5830996e6336e583660fbc.zip
Use the new modelresult in the dummyclient
Diffstat (limited to 'common')
-rw-r--r--common/clientapi.h4
-rw-r--r--common/modelresult.h11
2 files changed, 13 insertions, 2 deletions
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:
100 return resultSet->emitter(); 100 return resultSet->emitter();
101 } 101 }
102 102
103 enum Roles {
104 DomainObjectRole = Qt::UserRole + 1 //Must be the same as in ModelResult
105 };
106
103 /** 107 /**
104 * Asynchronusly load a dataset with tree structure information 108 * Asynchronusly load a dataset with tree structure information
105 */ 109 */
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:
63 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const 63 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
64 { 64 {
65 if (role == DomainObjectRole) { 65 if (role == DomainObjectRole) {
66 qWarning() << "trying to get entity " << index.internalId();
67 Q_ASSERT(mEntities.contains(index.internalId())); 66 Q_ASSERT(mEntities.contains(index.internalId()));
68 return QVariant::fromValue(mEntities.value(index.internalId())); 67 return QVariant::fromValue(mEntities.value(index.internalId()));
69 } 68 }
70 qDebug() << "Invalid role"; 69 if (role == Qt::DisplayRole) {
70 if (index.column() < mPropertyColumns.size()) {
71 Q_ASSERT(mEntities.contains(index.internalId()));
72 auto entity = mEntities.value(index.internalId());
73 return entity->getProperty(mPropertyColumns.at(index.column())).toString();
74 } else {
75 return "No data available";
76 }
77 }
71 return QVariant(); 78 return QVariant();
72 } 79 }
73 80