diff options
author | Liang Qi <liang.qi@qt.io> | 2017-03-13 09:50:43 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2017-03-13 15:55:44 +0100 |
commit | d51c3ecf8ef6e28557c66745f50a223cc5b1ce54 (patch) | |
tree | 023a1ecaa944152e08ba11291ec7aadc12f59dad /src/corelib/thread/qresultstore.h | |
parent | f06f1adb6cc3835793a15eafa2d5a3affad712a2 (diff) | |
parent | 3a1f4b186d8ce79717da37f808ff9a4b3e949d9c (diff) |
Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
examples/network/network.pro
mkspecs/features/mac/default_post.prf
src/corelib/io/qfilesystemengine_win.cpp
src/corelib/io/qprocess.cpp
src/corelib/io/qprocess.h
src/corelib/io/qprocess_p.h
src/corelib/io/qprocess_unix.cpp
src/corelib/io/qprocess_win.cpp
src/corelib/thread/qmutex.cpp
src/platformsupport/fontdatabases/windows/windows.pri
src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
tests/auto/corelib/io/io.pro
Change-Id: I8a27e0e141454818bba9c433200a4e84a88d147e
Diffstat (limited to 'src/corelib/thread/qresultstore.h')
-rw-r--r-- | src/corelib/thread/qresultstore.h | 64 |
1 files changed, 16 insertions, 48 deletions
diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h index 56cfcb6ed6..be9f632557 100644 --- a/src/corelib/thread/qresultstore.h +++ b/src/corelib/thread/qresultstore.h @@ -93,20 +93,14 @@ public: protected: QMap<int, ResultItem>::const_iterator mapIterator; int m_vectorIndex; -}; - -template <typename T> -class ResultIterator : public ResultIteratorBase -{ public: - ResultIterator(const ResultIteratorBase &base) - : ResultIteratorBase(base) { } - + template <typename T> const T &value() const { - return *pointer(); + return *pointer<T>(); } + template <typename T> const T *pointer() const { if (mapIterator.value().isVector()) @@ -130,7 +124,7 @@ public: ResultIteratorBase resultAt(int index) const; bool contains(int index) const; int count() const; - virtual ~ResultStoreBase() { } + virtual ~ResultStoreBase(); protected: int insertResultItem(int index, ResultItem &resultItem); @@ -147,64 +141,44 @@ protected: QMap<int, ResultItem> pendingResults; int filteredResults; -}; - -template <typename T> -class ResultStore : public ResultStoreBase -{ public: - ResultStore() { } - - ResultStore(const ResultStoreBase &base) - : ResultStoreBase(base) { } - - int addResult(int index, const T *result) + template <typename T> + int addResult(int index, const T *result) { if (result == 0) - return ResultStoreBase::addResult(index, result); + return addResult(index, static_cast<void *>(nullptr)); else - return ResultStoreBase::addResult(index, new T(*result)); + return addResult(index, static_cast<void *>(new T(*result))); } + template <typename T> int addResults(int index, const QVector<T> *results) { - return ResultStoreBase::addResults(index, new QVector<T>(*results), results->count(), results->count()); + return addResults(index, new QVector<T>(*results), results->count(), results->count()); } + template <typename T> int addResults(int index, const QVector<T> *results, int totalCount) { if (m_filterMode == true && results->count() != totalCount && 0 == results->count()) - return ResultStoreBase::addResults(index, 0, 0, totalCount); + return addResults(index, 0, 0, totalCount); else - return ResultStoreBase::addResults(index, new QVector<T>(*results), results->count(), totalCount); + return addResults(index, new QVector<T>(*results), results->count(), totalCount); } int addCanceledResult(int index) { - return addResult(index, 0); + return addResult(index, static_cast<void *>(nullptr)); } + template <typename T> int addCanceledResults(int index, int _count) { QVector<T> empty; return addResults(index, &empty, _count); } - ResultIterator<T> begin() const - { - return static_cast<ResultIterator<T> >(ResultStoreBase::begin()); - } - - ResultIterator<T> end() const - { - return static_cast<ResultIterator<T> >(ResultStoreBase::end()); - } - - ResultIterator<T> resultAt(int index) const - { - return static_cast<ResultIterator<T> >(ResultStoreBase::resultAt(index)); - } - + template <typename T> void clear() { QMap<int, ResultItem>::const_iterator mapIterator = m_results.constBegin(); @@ -218,12 +192,6 @@ public: resultCount = 0; m_results.clear(); } - - ~ResultStore() - { - clear(); - } - }; } // namespace QtPrivate |