Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qresultstore.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qresultstore.h"
5
7
8namespace QtPrivate {
9
10/*!
11 \internal
12
13 Finds result in \a store by \a index
14 */
15static ResultIteratorBase findResult(const QMap<int, ResultItem> &store, int index)
16{
17 if (store.isEmpty())
18 return ResultIteratorBase(store.end());
19 QMap<int, ResultItem>::const_iterator it = store.lowerBound(index);
20
21 // lowerBound returns either an iterator to the result or an iterator
22 // to the nearest greater index. If the latter happens it might be
23 // that the result is stored in a vector at the previous index.
24 if (it == store.end()) {
25 --it;
26 if (it.value().isVector() == false) {
27 return ResultIteratorBase(store.end());
28 }
29 } else {
30 if (it.key() > index) {
31 if (it == store.begin())
32 return ResultIteratorBase(store.end());
33 --it;
34 }
35 }
36
37 const int vectorIndex = index - it.key();
38
39 if (vectorIndex >= it.value().count())
40 return ResultIteratorBase(store.end());
41 else if (it.value().isVector() == false && vectorIndex != 0)
42 return ResultIteratorBase(store.end());
43 return ResultIteratorBase(it, vectorIndex);
44}
45
46/*!
47 \class QtPrivate::ResultItem
48 \internal
49 */
50
51/*!
52 \class QtPrivate::ResultIteratorBase
53 \internal
54 */
55
56/*!
57 \class QtPrivate::ResultStoreBase
58 \internal
59 */
60
65
68
70{
73 } else {
75 m_vectorIndex = 0;
76 }
77 return *this;
78}
79
81{
82 return mapIterator.value().count();
83}
84
90
92{
93 return mapIterator.value().isVector();
94}
95
100
102{
103 return mapIterator.value().isValid();
104}
105
108
110{
111 // QFutureInterface's dtor must delete the contents of m_results.
113}
114
119
121{
122 return m_filterMode;
123}
124
126{
128 while (it != end()) {
131 }
132}
133
143
157
159{
160 // index might refer to either visible or pending result
161 const bool inPending = m_filterMode && index != -1 && index > insertIndex;
162 const auto &store = inPending ? pendingResults : m_results;
163 auto it = findResult(store, index);
164 return it != ResultIteratorBase(store.end()) && it.isValid();
165}
166
168{
169 // check if we can insert any of the pending results:
171 while (it != pendingResults.end()) {
172 int index = it.key();
174 break;
175
180 }
181}
182
183int ResultStoreBase::addResult(int index, const void *result)
184{
185 ResultItem resultItem(result, 0); // 0 means "not a vector"
187}
188
204
209
214
216{
217 return begin() != end();
218}
219
224
226{
227 return (resultAt(index) != end());
228}
229
231{
232 return resultCount;
233}
234
235// returns the insert index, calling this function with
236// index equal to -1 returns the next available index.
238{
239 if (index == -1) {
242 } else {
244 }
245 return index;
246}
247
248} // namespace QtPrivate
249
250QT_END_NAMESPACE
Combined button and popup list for selecting options.
\macro QT_NO_KEYWORDS >
Definition qcompare.h:24
static ResultIteratorBase findResult(const QMap< int, ResultItem > &store, int index)