diff options
Diffstat (limited to 'common/modelresult.cpp')
-rw-r--r-- | common/modelresult.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/common/modelresult.cpp b/common/modelresult.cpp index 26d4f82..b12216b 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp | |||
@@ -69,7 +69,7 @@ ModelResult<T, Ptr>::ModelResult(const Sink::Query &query, const QList<QByteArra | |||
69 | //We're not interested | 69 | //We're not interested |
70 | return; | 70 | return; |
71 | }; | 71 | }; |
72 | if (notification.resource.isEmpty()|| notification.entities.isEmpty()) { | 72 | if (notification.resource.isEmpty() || notification.entities.isEmpty()) { |
73 | return; | 73 | return; |
74 | } | 74 | } |
75 | 75 | ||
@@ -112,6 +112,7 @@ ModelResult<T, Ptr>::ModelResult(const Sink::Query &query, const QList<QByteArra | |||
112 | const auto oldStatus = mEntityStatus.value(id); | 112 | const auto oldStatus = mEntityStatus.value(id); |
113 | QVector<int> changedRoles; | 113 | QVector<int> changedRoles; |
114 | if (oldStatus != newStatus) { | 114 | if (oldStatus != newStatus) { |
115 | SinkTraceCtx(mLogCtx) << "Status changed for entity:" << newStatus << ", id: " << id; | ||
115 | mEntityStatus.insert(id, newStatus); | 116 | mEntityStatus.insert(id, newStatus); |
116 | changedRoles << StatusRole; | 117 | changedRoles << StatusRole; |
117 | } | 118 | } |
@@ -124,7 +125,9 @@ ModelResult<T, Ptr>::ModelResult(const Sink::Query &query, const QList<QByteArra | |||
124 | 125 | ||
125 | if (!changedRoles.isEmpty()) { | 126 | if (!changedRoles.isEmpty()) { |
126 | const auto idx = createIndexFromId(id); | 127 | const auto idx = createIndexFromId(id); |
127 | emit dataChanged(idx, idx, changedRoles); | 128 | SinkTraceCtx(mLogCtx) << "Index changed:" << idx << changedRoles; |
129 | //We don't emit the changedRoles because the consuming model likely remaps the role anyways and would then need to translate dataChanged signals as well. | ||
130 | emit dataChanged(idx, idx); | ||
128 | } | 131 | } |
129 | } | 132 | } |
130 | }); | 133 | }); |
@@ -192,7 +195,11 @@ QVariant ModelResult<T, Ptr>::data(const QModelIndex &index, int role) const | |||
192 | return childrenFetched(index); | 195 | return childrenFetched(index); |
193 | } | 196 | } |
194 | if (role == StatusRole) { | 197 | if (role == StatusRole) { |
195 | return mEntityStatus.value(index.internalId()); | 198 | auto it = mEntityStatus.constFind(index.internalId()); |
199 | if (it != mEntityStatus.constEnd()) { | ||
200 | return *it; | ||
201 | } | ||
202 | return {}; | ||
196 | } | 203 | } |
197 | if (role == Qt::DisplayRole && index.isValid()) { | 204 | if (role == Qt::DisplayRole && index.isValid()) { |
198 | if (index.column() < mPropertyColumns.size()) { | 205 | if (index.column() < mPropertyColumns.size()) { |