diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-27 17:30:04 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-27 17:30:04 +0100 |
commit | 5b41b26a349967acf2197f9f9228526193fd826e (patch) | |
tree | 166452bcc0757564deefe233bf031d2ccb0564d2 /common/modelresult.cpp | |
parent | 13af56e436f49df32d3b2f6f223cf1dec2eabaac (diff) | |
download | sink-5b41b26a349967acf2197f9f9228526193fd826e.tar.gz sink-5b41b26a349967acf2197f9f9228526193fd826e.zip |
Introduced a QueryRunner object
The QueryRunner object lives for the duration of the query (so just
for the initial query for non-live queries, and for the lifetime of the
result model for live queries).
It's supposed to handle all the threading internally and decouple the
lifetime of the facade.
Diffstat (limited to 'common/modelresult.cpp')
-rw-r--r-- | common/modelresult.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/common/modelresult.cpp b/common/modelresult.cpp index 935e2e8..65eaba9 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp | |||
@@ -183,6 +183,28 @@ void ModelResult<T, Ptr>::setFetcher(const std::function<void(const Ptr &parent) | |||
183 | } | 183 | } |
184 | 184 | ||
185 | template<class T, class Ptr> | 185 | template<class T, class Ptr> |
186 | void ModelResult<T, Ptr>::setEmitter(const typename Akonadi2::ResultEmitter<Ptr>::Ptr &emitter) | ||
187 | { | ||
188 | setFetcher(emitter->mFetcher); | ||
189 | emitter->onAdded([this](const Ptr &value) { | ||
190 | this->add(value); | ||
191 | }); | ||
192 | emitter->onModified([this](const Ptr &value) { | ||
193 | this->modify(value); | ||
194 | }); | ||
195 | emitter->onRemoved([this](const Ptr &value) { | ||
196 | this->remove(value); | ||
197 | }); | ||
198 | emitter->onInitialResultSetComplete([this]() { | ||
199 | }); | ||
200 | emitter->onComplete([this]() { | ||
201 | }); | ||
202 | emitter->onClear([this]() { | ||
203 | }); | ||
204 | mEmitter = emitter; | ||
205 | } | ||
206 | |||
207 | template<class T, class Ptr> | ||
186 | void ModelResult<T, Ptr>::modify(const Ptr &value) | 208 | void ModelResult<T, Ptr>::modify(const Ptr &value) |
187 | { | 209 | { |
188 | auto childId = qHash(value->identifier()); | 210 | auto childId = qHash(value->identifier()); |