diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-20 16:02:38 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-20 16:02:38 +0100 |
commit | 1864024012213dc0a17c76e9755bf50a19944ec7 (patch) | |
tree | 06690c35c05c29deec30a3dd412d4043e2c956a3 /common/modelresult.cpp | |
parent | 6625bb5a2145008ad47ae963e1546714b7342bf0 (diff) | |
download | sink-1864024012213dc0a17c76e9755bf50a19944ec7.tar.gz sink-1864024012213dc0a17c76e9755bf50a19944ec7.zip |
Report when we don't have any more to fetch.
... so we can use that information in fetchMore.
Diffstat (limited to 'common/modelresult.cpp')
-rw-r--r-- | common/modelresult.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/common/modelresult.cpp b/common/modelresult.cpp index 34e6dfc..8e92365 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp | |||
@@ -167,7 +167,10 @@ template <class T, class Ptr> | |||
167 | bool ModelResult<T, Ptr>::canFetchMore(const QModelIndex &parent) const | 167 | bool ModelResult<T, Ptr>::canFetchMore(const QModelIndex &parent) const |
168 | { | 168 | { |
169 | const auto id = parent.internalId(); | 169 | const auto id = parent.internalId(); |
170 | return !mEntityChildrenFetched.contains(id) || !mEntityChildrenFetchComplete.contains(id); | 170 | if (mEntityAllChildrenFetched.contains(id)) { |
171 | return false; | ||
172 | } | ||
173 | return true; | ||
171 | } | 174 | } |
172 | 175 | ||
173 | template <class T, class Ptr> | 176 | template <class T, class Ptr> |
@@ -269,11 +272,14 @@ void ModelResult<T, Ptr>::setEmitter(const typename Sink::ResultEmitter<Ptr>::Pt | |||
269 | remove(value); | 272 | remove(value); |
270 | }); | 273 | }); |
271 | }); | 274 | }); |
272 | emitter->onInitialResultSetComplete([this](const Ptr &parent) { | 275 | emitter->onInitialResultSetComplete([this](const Ptr &parent, bool fetchedAll) { |
273 | SinkTrace() << "Initial result set complete"; | 276 | SinkTrace() << "Initial result set complete"; |
274 | const qint64 parentId = parent ? qHash(*parent) : 0; | 277 | const qint64 parentId = parent ? qHash(*parent) : 0; |
275 | const auto parentIndex = createIndexFromId(parentId); | 278 | const auto parentIndex = createIndexFromId(parentId); |
276 | mEntityChildrenFetchComplete.insert(parentId); | 279 | mEntityChildrenFetchComplete.insert(parentId); |
280 | if (fetchedAll) { | ||
281 | mEntityAllChildrenFetched.insert(parentId); | ||
282 | } | ||
277 | emit dataChanged(parentIndex, parentIndex, QVector<int>() << ChildrenFetchedRole); | 283 | emit dataChanged(parentIndex, parentIndex, QVector<int>() << ChildrenFetchedRole); |
278 | }); | 284 | }); |
279 | mEmitter = emitter; | 285 | mEmitter = emitter; |