diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-23 01:35:13 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-23 01:35:13 +0200 |
commit | 52ad48c8bd755a2fde249296d6017853538f478f (patch) | |
tree | d3adbee13e49d2525720069cb7d9ca6b5876dbd8 /common/modelresult.cpp | |
parent | 6fc76bc690e5a2e7748936fa835338d820c7e7de (diff) | |
download | sink-52ad48c8bd755a2fde249296d6017853538f478f.tar.gz sink-52ad48c8bd755a2fde249296d6017853538f478f.zip |
A new query system
Diffstat (limited to 'common/modelresult.cpp')
-rw-r--r-- | common/modelresult.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/common/modelresult.cpp b/common/modelresult.cpp index 56a39ee..d13bba9 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp | |||
@@ -188,7 +188,7 @@ void ModelResult<T, Ptr>::add(const Ptr &value) | |||
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | auto parent = createIndexFromId(id); | 190 | auto parent = createIndexFromId(id); |
191 | // qDebug() << "Added entity " << childId << value->identifier() << id; | 191 | SinkTrace() << "Added entity " << childId << value->identifier() << id; |
192 | const auto keys = mTree[id]; | 192 | const auto keys = mTree[id]; |
193 | int index = 0; | 193 | int index = 0; |
194 | for (; index < keys.size(); index++) { | 194 | for (; index < keys.size(); index++) { |
@@ -200,13 +200,13 @@ void ModelResult<T, Ptr>::add(const Ptr &value) | |||
200 | SinkWarning() << "Entity already in model " << value->identifier(); | 200 | SinkWarning() << "Entity already in model " << value->identifier(); |
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | // qDebug() << "Inserting rows " << index << parent; | 203 | // SinkTrace() << "Inserting rows " << index << parent; |
204 | beginInsertRows(parent, index, index); | 204 | beginInsertRows(parent, index, index); |
205 | mEntities.insert(childId, value); | 205 | mEntities.insert(childId, value); |
206 | mTree[id].insert(index, childId); | 206 | mTree[id].insert(index, childId); |
207 | mParents.insert(childId, id); | 207 | mParents.insert(childId, id); |
208 | endInsertRows(); | 208 | endInsertRows(); |
209 | // qDebug() << "Inserted rows " << mTree[id].size(); | 209 | // SinkTrace() << "Inserted rows " << mTree[id].size(); |
210 | } | 210 | } |
211 | 211 | ||
212 | 212 | ||
@@ -216,7 +216,7 @@ void ModelResult<T, Ptr>::remove(const Ptr &value) | |||
216 | auto childId = qHash(*value); | 216 | auto childId = qHash(*value); |
217 | auto id = parentId(value); | 217 | auto id = parentId(value); |
218 | auto parent = createIndexFromId(id); | 218 | auto parent = createIndexFromId(id); |
219 | // qDebug() << "Removed entity" << childId; | 219 | SinkTrace() << "Removed entity" << childId; |
220 | auto index = mTree[id].indexOf(childId); | 220 | auto index = mTree[id].indexOf(childId); |
221 | beginRemoveRows(parent, index, index); | 221 | beginRemoveRows(parent, index, index); |
222 | mEntities.remove(childId); | 222 | mEntities.remove(childId); |
@@ -259,6 +259,7 @@ void ModelResult<T, Ptr>::setEmitter(const typename Sink::ResultEmitter<Ptr>::Pt | |||
259 | }); | 259 | }); |
260 | }); | 260 | }); |
261 | emitter->onModified([this](const Ptr &value) { | 261 | emitter->onModified([this](const Ptr &value) { |
262 | SinkTrace() << "Received modification: " << value->identifier(); | ||
262 | threadBoundary.callInMainThread([this, value]() { | 263 | threadBoundary.callInMainThread([this, value]() { |
263 | modify(value); | 264 | modify(value); |
264 | }); | 265 | }); |
@@ -294,8 +295,9 @@ void ModelResult<T, Ptr>::modify(const Ptr &value) | |||
294 | return; | 295 | return; |
295 | } | 296 | } |
296 | auto parent = createIndexFromId(id); | 297 | auto parent = createIndexFromId(id); |
297 | // qDebug() << "Modified entity" << childId; | 298 | SinkTrace() << "Modified entity" << childId; |
298 | auto i = mTree[id].indexOf(childId); | 299 | auto i = mTree[id].indexOf(childId); |
300 | Q_ASSERT(i >= 0); | ||
299 | mEntities.remove(childId); | 301 | mEntities.remove(childId); |
300 | mEntities.insert(childId, value); | 302 | mEntities.insert(childId, value); |
301 | // TODO check for change of parents | 303 | // TODO check for change of parents |