summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/clientapi.cpp20
-rw-r--r--common/genericresource.cpp2
-rw-r--r--common/queryrunner.cpp18
3 files changed, 4 insertions, 36 deletions
diff --git a/common/clientapi.cpp b/common/clientapi.cpp
index 29b7e68..b732205 100644
--- a/common/clientapi.cpp
+++ b/common/clientapi.cpp
@@ -37,26 +37,6 @@
37#include "modelresult.h" 37#include "modelresult.h"
38#include "log.h" 38#include "log.h"
39 39
40#define ASYNCINTHREAD
41
42namespace async
43{
44 static void run(const std::function<void()> &runner) {
45 auto timer = new QTimer();
46 timer->setSingleShot(true);
47 QObject::connect(timer, &QTimer::timeout, [runner, timer]() {
48 delete timer;
49#ifndef ASYNCINTHREAD
50 runner();
51#else
52 QtConcurrent::run(runner);
53#endif
54 });
55 timer->start(0);
56 };
57} // namespace async
58
59
60namespace Akonadi2 40namespace Akonadi2
61{ 41{
62 42
diff --git a/common/genericresource.cpp b/common/genericresource.cpp
index 652154d..66f5dcf 100644
--- a/common/genericresource.cpp
+++ b/common/genericresource.cpp
@@ -85,8 +85,8 @@ public Q_SLOTS:
85 } 85 }
86 86
87private: 87private:
88 Akonadi2::Storage mChangeReplayStore;
89 Akonadi2::Storage mStorage; 88 Akonadi2::Storage mStorage;
89 Akonadi2::Storage mChangeReplayStore;
90 ReplayFunction mReplayFunction; 90 ReplayFunction mReplayFunction;
91}; 91};
92 92
diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp
index e365cfc..9f6d23f 100644
--- a/common/queryrunner.cpp
+++ b/common/queryrunner.cpp
@@ -53,27 +53,17 @@ static inline ResultSet fullScan(const Akonadi2::Storage::Transaction &transacti
53template<class DomainType> 53template<class DomainType>
54QueryRunner<DomainType>::QueryRunner(const Akonadi2::Query &query, const Akonadi2::ResourceAccessInterface::Ptr &resourceAccess, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &factory, const QByteArray &bufferType) 54QueryRunner<DomainType>::QueryRunner(const Akonadi2::Query &query, const Akonadi2::ResourceAccessInterface::Ptr &resourceAccess, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &factory, const QByteArray &bufferType)
55 : QueryRunnerBase(), 55 : QueryRunnerBase(),
56 mResourceAccess(resourceAccess),
57 mResultProvider(new ResultProvider<typename DomainType::Ptr>), 56 mResultProvider(new ResultProvider<typename DomainType::Ptr>),
57 mResourceAccess(resourceAccess),
58 mDomainTypeAdaptorFactory(factory), 58 mDomainTypeAdaptorFactory(factory),
59 mQuery(query),
60 mResourceInstanceIdentifier(instanceIdentifier), 59 mResourceInstanceIdentifier(instanceIdentifier),
61 mBufferType(bufferType) 60 mBufferType(bufferType),
61 mQuery(query)
62{ 62{
63 Trace() << "Starting query"; 63 Trace() << "Starting query";
64 //We delegate loading of initial data to the result provider, os it can decide for itself what it needs to load. 64 //We delegate loading of initial data to the result provider, os it can decide for itself what it needs to load.
65 mResultProvider->setFetcher([this, query](const typename DomainType::Ptr &parent) { 65 mResultProvider->setFetcher([this, query](const typename DomainType::Ptr &parent) {
66 Trace() << "Running fetcher"; 66 Trace() << "Running fetcher";
67
68 // auto watcher = new QFutureWatcher<qint64>;
69 // QObject::connect(watcher, &QFutureWatcher::finished, [](qint64 newRevision) {
70 // mResourceAccess->sendRevisionReplayedCommand(newRevision);
71 // });
72 // auto future = QtConcurrent::run([&resultProvider]() -> qint64 {
73 // const qint64 newRevision = executeInitialQuery(query, parent, resultProvider);
74 // return newRevision;
75 // });
76 // watcher->setFuture(future);
77 const qint64 newRevision = executeInitialQuery(query, parent, *mResultProvider); 67 const qint64 newRevision = executeInitialQuery(query, parent, *mResultProvider);
78 mResourceAccess->sendRevisionReplayedCommand(newRevision); 68 mResourceAccess->sendRevisionReplayedCommand(newRevision);
79 }); 69 });
@@ -109,11 +99,9 @@ typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr QueryRunner<Doma
109 return mResultProvider->emitter(); 99 return mResultProvider->emitter();
110} 100}
111 101
112//TODO move into result provider?
113template<class DomainType> 102template<class DomainType>
114void QueryRunner<DomainType>::replaySet(ResultSet &resultSet, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider) 103void QueryRunner<DomainType>::replaySet(ResultSet &resultSet, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider)
115{ 104{
116 // Trace() << "Replay set";
117 int counter = 0; 105 int counter = 0;
118 while (resultSet.next([&resultProvider, &counter](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &value, Akonadi2::Operation operation) -> bool { 106 while (resultSet.next([&resultProvider, &counter](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &value, Akonadi2::Operation operation) -> bool {
119 counter++; 107 counter++;