From cba59b8cfa941548392ddc52e8e9ff2ec5b9e82e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 2 Jan 2018 16:03:20 +0100 Subject: Removed unused synclistresult --- common/synclistresult.h | 65 ------------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 common/synclistresult.h (limited to 'common/synclistresult.h') diff --git a/common/synclistresult.h b/common/synclistresult.h deleted file mode 100644 index 344c0ef..0000000 --- a/common/synclistresult.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include "resultprovider.h" - -namespace async { - -/* -* A result set specialization that provides a syncronous list. -* -* Only for testing purposes. -* -* WARNING: The nested eventloop can cause all sorts of trouble. Use only in testing code. -*/ -template -class SyncListResult : public QList -{ -public: - SyncListResult(const QSharedPointer> &emitter) : QList(), mEmitter(emitter) - { - emitter->onAdded([this](const T &value) { this->append(value); }); - emitter->onModified([this](const T &value) { - for (auto it = this->begin(); it != this->end(); it++) { - if (**it == *value) { - it = this->erase(it); - this->insert(it, value); - break; - } - } - }); - emitter->onRemoved([this](const T &value) { - for (auto it = this->begin(); it != this->end(); it++) { - if (**it == *value) { - this->erase(it); - break; - } - } - }); - emitter->onInitialResultSetComplete([this]() { - if (eventLoopAborter) { - eventLoopAborter(); - // Be safe in case of a second invocation of the complete handler - eventLoopAborter = std::function(); - } - }); - emitter->onComplete([this]() { mEmitter.clear(); }); - emitter->onClear([this]() { this->clear(); }); - } - - void exec() - { - QEventLoop eventLoop; - eventLoopAborter = [&eventLoop]() { eventLoop.quit(); }; - eventLoop.exec(); - } - -private: - QSharedPointer> mEmitter; - std::function eventLoopAborter; -}; -} -- cgit v1.2.3