summaryrefslogtreecommitdiffstats
path: root/common/synclistresult.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-03 09:01:05 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-03 09:01:05 +0100
commit4d9746c828558c9f872e0aed52442863affb25d5 (patch)
tree507d7c2ba67f47d3cbbcf01a722236ff1b48426b /common/synclistresult.h
parent9cea920b7dd51867a0be0fed2f461b6be73c103e (diff)
downloadsink-4d9746c828558c9f872e0aed52442863affb25d5.tar.gz
sink-4d9746c828558c9f872e0aed52442863affb25d5.zip
Fromatted the whole codebase with clang-format.
clang-format -i */**{.cpp,.h}
Diffstat (limited to 'common/synclistresult.h')
-rw-r--r--common/synclistresult.h26
1 files changed, 9 insertions, 17 deletions
diff --git a/common/synclistresult.h b/common/synclistresult.h
index 055714f..344c0ef 100644
--- a/common/synclistresult.h
+++ b/common/synclistresult.h
@@ -16,16 +16,13 @@ namespace async {
16* 16*
17* WARNING: The nested eventloop can cause all sorts of trouble. Use only in testing code. 17* WARNING: The nested eventloop can cause all sorts of trouble. Use only in testing code.
18*/ 18*/
19template<class T> 19template <class T>
20class SyncListResult : public QList<T> { 20class SyncListResult : public QList<T>
21{
21public: 22public:
22 SyncListResult(const QSharedPointer<Sink::ResultEmitter<T> > &emitter) 23 SyncListResult(const QSharedPointer<Sink::ResultEmitter<T>> &emitter) : QList<T>(), mEmitter(emitter)
23 :QList<T>(),
24 mEmitter(emitter)
25 { 24 {
26 emitter->onAdded([this](const T &value) { 25 emitter->onAdded([this](const T &value) { this->append(value); });
27 this->append(value);
28 });
29 emitter->onModified([this](const T &value) { 26 emitter->onModified([this](const T &value) {
30 for (auto it = this->begin(); it != this->end(); it++) { 27 for (auto it = this->begin(); it != this->end(); it++) {
31 if (**it == *value) { 28 if (**it == *value) {
@@ -46,16 +43,12 @@ public:
46 emitter->onInitialResultSetComplete([this]() { 43 emitter->onInitialResultSetComplete([this]() {
47 if (eventLoopAborter) { 44 if (eventLoopAborter) {
48 eventLoopAborter(); 45 eventLoopAborter();
49 //Be safe in case of a second invocation of the complete handler 46 // Be safe in case of a second invocation of the complete handler
50 eventLoopAborter = std::function<void()>(); 47 eventLoopAborter = std::function<void()>();
51 } 48 }
52 }); 49 });
53 emitter->onComplete([this]() { 50 emitter->onComplete([this]() { mEmitter.clear(); });
54 mEmitter.clear(); 51 emitter->onClear([this]() { this->clear(); });
55 });
56 emitter->onClear([this]() {
57 this->clear();
58 });
59 } 52 }
60 53
61 void exec() 54 void exec()
@@ -66,8 +59,7 @@ public:
66 } 59 }
67 60
68private: 61private:
69 QSharedPointer<Sink::ResultEmitter<T> > mEmitter; 62 QSharedPointer<Sink::ResultEmitter<T>> mEmitter;
70 std::function<void()> eventLoopAborter; 63 std::function<void()> eventLoopAborter;
71}; 64};
72
73} 65}