summaryrefslogtreecommitdiffstats
path: root/common/modelresult.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-20 20:49:17 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-20 20:49:17 +0100
commited42bdd74d70c7bcb9e1fb8f071ccb92b1515406 (patch)
treefc068b2f678d3d38d5ad398e6c85474306a0aa02 /common/modelresult.cpp
parentbc06643cd0c16140f6013be35b64732c1676e794 (diff)
downloadsink-ed42bdd74d70c7bcb9e1fb8f071ccb92b1515406.tar.gz
sink-ed42bdd74d70c7bcb9e1fb8f071ccb92b1515406.zip
Fetch more data on demand
We skip values we've already seen and only retrieve the new ones. This currently only properly works in a non-live query and we don't give the model any feedback when we can't fetch more data anymore. However, it generally works and we get the desired effect.
Diffstat (limited to 'common/modelresult.cpp')
-rw-r--r--common/modelresult.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/common/modelresult.cpp b/common/modelresult.cpp
index 5b5a473..ceefa76 100644
--- a/common/modelresult.cpp
+++ b/common/modelresult.cpp
@@ -155,7 +155,8 @@ bool ModelResult<T, Ptr>::hasChildren(const QModelIndex &parent) const
155template<class T, class Ptr> 155template<class T, class Ptr>
156bool ModelResult<T, Ptr>::canFetchMore(const QModelIndex &parent) const 156bool ModelResult<T, Ptr>::canFetchMore(const QModelIndex &parent) const
157{ 157{
158 return !mEntityChildrenFetched.contains(parent.internalId()); 158 const auto id = parent.internalId();
159 return !mEntityChildrenFetched.contains(id) || mEntityChildrenFetchComplete.contains(id);
159} 160}
160 161
161template<class T, class Ptr> 162template<class T, class Ptr>
@@ -218,6 +219,7 @@ template<class T, class Ptr>
218void ModelResult<T, Ptr>::fetchEntities(const QModelIndex &parent) 219void ModelResult<T, Ptr>::fetchEntities(const QModelIndex &parent)
219{ 220{
220 const auto id = getIdentifier(parent); 221 const auto id = getIdentifier(parent);
222 mEntityChildrenFetchComplete.remove(id);
221 mEntityChildrenFetched.insert(id); 223 mEntityChildrenFetched.insert(id);
222 Trace() << "Loading child entities of parent " << id; 224 Trace() << "Loading child entities of parent " << id;
223 if (loadEntities) { 225 if (loadEntities) {