Changeset View
Changeset View
Standalone View
Standalone View
src/akonadi/akonadilivequeryhelpers.cpp
Show All 21 Lines | |||||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | 24 | | |||
25 | #include "akonadilivequeryhelpers.h" | 25 | #include "akonadilivequeryhelpers.h" | ||
26 | 26 | | |||
27 | #include "akonadi/akonadicollectionfetchjobinterface.h" | 27 | #include "akonadi/akonadicollectionfetchjobinterface.h" | ||
28 | #include "akonadi/akonadiitemfetchjobinterface.h" | 28 | #include "akonadi/akonadiitemfetchjobinterface.h" | ||
29 | #include "akonadi/akonaditagfetchjobinterface.h" | 29 | #include "akonadi/akonaditagfetchjobinterface.h" | ||
30 | #include "akonadi/akonadistorageinterface.h" | ||||
30 | 31 | | |||
31 | #include "utils/jobhandler.h" | 32 | #include "utils/jobhandler.h" | ||
32 | 33 | | |||
33 | using namespace Akonadi; | 34 | using namespace Akonadi; | ||
34 | 35 | | |||
35 | LiveQueryHelpers::LiveQueryHelpers(const SerializerInterface::Ptr &serializer, | 36 | LiveQueryHelpers::LiveQueryHelpers(const SerializerInterface::Ptr &serializer, | ||
36 | const StorageInterface::Ptr &storage) | 37 | const StorageInterface::Ptr &storage) | ||
37 | : m_serializer(serializer), | 38 | : m_serializer(serializer), | ||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Line(s) | 182 | while (!parentUid.isEmpty()) { | |||
188 | } | 189 | } | ||
189 | add(*parent); | 190 | add(*parent); | ||
190 | parentUid = serializer->relatedUidFromItem(*parent); | 191 | parentUid = serializer->relatedUidFromItem(*parent); | ||
191 | } | 192 | } | ||
192 | }); | 193 | }); | ||
193 | }; | 194 | }; | ||
194 | } | 195 | } | ||
195 | 196 | | |||
197 | LiveQueryHelpers::CollectionFetchFunction LiveQueryHelpers::fetchItemCollection(const Item& item) const | ||||
198 | { | ||||
199 | auto storage = m_storage; | ||||
200 | return [storage, item] (const Domain::LiveQueryInput<Collection>::AddFunction &add) { | ||||
201 | auto job = storage->fetchCollections(item.parentCollection(), StorageInterface::Base, StorageInterface::AllContent); | ||||
202 | Utils::JobHandler::install(job->kjob(), [storage, job, add] { | ||||
203 | if (job->kjob()->error() != KJob::NoError) | ||||
204 | return; | ||||
205 | auto collection = job->collections().at(0); | ||||
206 | add(collection); | ||||
207 | }); | ||||
208 | }; | ||||
209 | } | ||||
210 | | ||||
211 | | ||||
196 | LiveQueryHelpers::ItemFetchFunction LiveQueryHelpers::fetchSiblings(const Item &item) const | 212 | LiveQueryHelpers::ItemFetchFunction LiveQueryHelpers::fetchSiblings(const Item &item) const | ||
197 | { | 213 | { | ||
198 | auto storage = m_storage; | 214 | auto storage = m_storage; | ||
199 | return [storage, item] (const Domain::LiveQueryInput<Item>::AddFunction &add) { | 215 | return [storage, item] (const Domain::LiveQueryInput<Item>::AddFunction &add) { | ||
200 | auto job = storage->fetchItem(item); | 216 | auto job = storage->fetchItem(item); | ||
201 | Utils::JobHandler::install(job->kjob(), [storage, job, add] { | 217 | Utils::JobHandler::install(job->kjob(), [storage, job, add] { | ||
202 | if (job->kjob()->error() != KJob::NoError) | 218 | if (job->kjob()->error() != KJob::NoError) | ||
203 | return; | 219 | return; | ||
Show All 27 Lines |