diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 09:01:05 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 09:01:05 +0100 |
commit | 4d9746c828558c9f872e0aed52442863affb25d5 (patch) | |
tree | 507d7c2ba67f47d3cbbcf01a722236ff1b48426b /common/synclistresult.h | |
parent | 9cea920b7dd51867a0be0fed2f461b6be73c103e (diff) | |
download | sink-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.h | 26 |
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 | */ |
19 | template<class T> | 19 | template <class T> |
20 | class SyncListResult : public QList<T> { | 20 | class SyncListResult : public QList<T> |
21 | { | ||
21 | public: | 22 | public: |
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 | ||
68 | private: | 61 | private: |
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 | } |