Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qsortfilterproxymodel.h" | - |
43 | | - |
44 | #ifndef QT_NO_SORTFILTERPROXYMODEL | - |
45 | | - |
46 | #include "qitemselectionmodel.h" | - |
47 | #include <qsize.h> | - |
48 | #include <qdebug.h> | - |
49 | #include <qdatetime.h> | - |
50 | #include <qpair.h> | - |
51 | #include <qstringlist.h> | - |
52 | #include <private/qabstractitemmodel_p.h> | - |
53 | #include <private/qabstractproxymodel_p.h> | - |
54 | | - |
55 | #include <algorithm> | - |
56 | | - |
57 | QT_BEGIN_NAMESPACE | - |
58 | | - |
59 | typedef QList<QPair<QModelIndex, QPersistentModelIndex> > QModelIndexPairList; | - |
60 | | - |
61 | static inline QSet<int> qVectorToSet(const QVector<int> &vector) | - |
62 | { | - |
63 | QSet<int> set; executed (the execution status of this line is deduced): QSet<int> set; | - |
64 | set.reserve(vector.size()); executed (the execution status of this line is deduced): set.reserve(vector.size()); | - |
65 | for(int i=0; i < vector.size(); ++i) evaluated: i < vector.size() yes Evaluation Count:83 | yes Evaluation Count:753 |
| 83-753 |
66 | set << vector.at(i); executed: set << vector.at(i); Execution Count:83 | 83 |
67 | return set; executed: return set; Execution Count:753 | 753 |
68 | } | - |
69 | | - |
70 | class QSortFilterProxyModelLessThan | - |
71 | { | - |
72 | public: | - |
73 | inline QSortFilterProxyModelLessThan(int column, const QModelIndex &parent, | - |
74 | const QAbstractItemModel *source, | - |
75 | const QSortFilterProxyModel *proxy) | - |
76 | : sort_column(column), source_parent(parent), source_model(source), proxy_model(proxy) {} executed: } Execution Count:234 | 234 |
77 | | - |
78 | inline bool operator()(int r1, int r2) const | - |
79 | { | - |
80 | QModelIndex i1 = source_model->index(r1, sort_column, source_parent); executed (the execution status of this line is deduced): QModelIndex i1 = source_model->index(r1, sort_column, source_parent); | - |
81 | QModelIndex i2 = source_model->index(r2, sort_column, source_parent); executed (the execution status of this line is deduced): QModelIndex i2 = source_model->index(r2, sort_column, source_parent); | - |
82 | return proxy_model->lessThan(i1, i2); executed: return proxy_model->lessThan(i1, i2); Execution Count:87096 | 87096 |
83 | } | - |
84 | | - |
85 | private: | - |
86 | int sort_column; | - |
87 | QModelIndex source_parent; | - |
88 | const QAbstractItemModel *source_model; | - |
89 | const QSortFilterProxyModel *proxy_model; | - |
90 | }; | - |
91 | | - |
92 | class QSortFilterProxyModelGreaterThan | - |
93 | { | - |
94 | public: | - |
95 | inline QSortFilterProxyModelGreaterThan(int column, const QModelIndex &parent, | - |
96 | const QAbstractItemModel *source, | - |
97 | const QSortFilterProxyModel *proxy) | - |
98 | : sort_column(column), source_parent(parent), | - |
99 | source_model(source), proxy_model(proxy) {} executed: } Execution Count:19 | 19 |
100 | | - |
101 | inline bool operator()(int r1, int r2) const | - |
102 | { | - |
103 | QModelIndex i1 = source_model->index(r1, sort_column, source_parent); executed (the execution status of this line is deduced): QModelIndex i1 = source_model->index(r1, sort_column, source_parent); | - |
104 | QModelIndex i2 = source_model->index(r2, sort_column, source_parent); executed (the execution status of this line is deduced): QModelIndex i2 = source_model->index(r2, sort_column, source_parent); | - |
105 | return proxy_model->lessThan(i2, i1); executed: return proxy_model->lessThan(i2, i1); Execution Count:171 | 171 |
106 | } | - |
107 | | - |
108 | private: | - |
109 | int sort_column; | - |
110 | QModelIndex source_parent; | - |
111 | const QAbstractItemModel *source_model; | - |
112 | const QSortFilterProxyModel *proxy_model; | - |
113 | }; | - |
114 | | - |
115 | | - |
116 | //this struct is used to store what are the rows that are removed | - |
117 | //between a call to rowsAboutToBeRemoved and rowsRemoved | - |
118 | //it avoids readding rows to the mapping that are currently being removed | - |
119 | struct QRowsRemoval | - |
120 | { | - |
121 | QRowsRemoval(const QModelIndex &parent_source, int start, int end) : parent_source(parent_source), start(start), end(end) | - |
122 | { | - |
123 | } executed: } Execution Count:45 | 45 |
124 | | - |
125 | QRowsRemoval() : start(-1), end(-1) | - |
126 | { | - |
127 | } executed: } Execution Count:309 | 309 |
128 | | - |
129 | bool contains(QModelIndex parent, int row) | - |
130 | { | - |
131 | do { | - |
132 | if (parent == parent_source) partially evaluated: parent == parent_source yes Evaluation Count:304 | no Evaluation Count:0 |
| 0-304 |
133 | return row >= start && row <= end; executed: return row >= start && row <= end; Execution Count:304 | 304 |
134 | row = parent.row(); never executed (the execution status of this line is deduced): row = parent.row(); | - |
135 | parent = parent.parent(); never executed (the execution status of this line is deduced): parent = parent.parent(); | - |
136 | } while (row >= 0); never executed: } never evaluated: row >= 0 | 0 |
137 | return false; never executed: return false; | 0 |
138 | } | - |
139 | private: | - |
140 | QModelIndex parent_source; | - |
141 | int start; | - |
142 | int end; | - |
143 | }; | - |
144 | | - |
145 | class QSortFilterProxyModelPrivate : public QAbstractProxyModelPrivate | - |
146 | { | - |
147 | Q_DECLARE_PUBLIC(QSortFilterProxyModel) | - |
148 | | - |
149 | public: | - |
150 | struct Mapping { | - |
151 | QVector<int> source_rows; | - |
152 | QVector<int> source_columns; | - |
153 | QVector<int> proxy_rows; | - |
154 | QVector<int> proxy_columns; | - |
155 | QVector<QModelIndex> mapped_children; | - |
156 | QHash<QModelIndex, Mapping *>::const_iterator map_iter; | - |
157 | }; | - |
158 | | - |
159 | mutable QHash<QModelIndex, Mapping*> source_index_mapping; | - |
160 | | - |
161 | int source_sort_column; | - |
162 | int proxy_sort_column; | - |
163 | Qt::SortOrder sort_order; | - |
164 | Qt::CaseSensitivity sort_casesensitivity; | - |
165 | int sort_role; | - |
166 | bool sort_localeaware; | - |
167 | | - |
168 | int filter_column; | - |
169 | QRegExp filter_regexp; | - |
170 | int filter_role; | - |
171 | | - |
172 | bool dynamic_sortfilter; | - |
173 | QRowsRemoval itemsBeingRemoved; | - |
174 | | - |
175 | QModelIndexPairList saved_persistent_indexes; | - |
176 | | - |
177 | QHash<QModelIndex, Mapping *>::const_iterator create_mapping( | - |
178 | const QModelIndex &source_parent) const; | - |
179 | QModelIndex proxy_to_source(const QModelIndex &proxyIndex) const; | - |
180 | QModelIndex source_to_proxy(const QModelIndex &sourceIndex) const; | - |
181 | bool can_create_mapping(const QModelIndex &source_parent) const; | - |
182 | | - |
183 | void remove_from_mapping(const QModelIndex &source_parent); | - |
184 | | - |
185 | inline QHash<QModelIndex, Mapping *>::const_iterator index_to_iterator( | - |
186 | const QModelIndex &proxy_index) const | - |
187 | { | - |
188 | Q_ASSERT(proxy_index.isValid()); executed (the execution status of this line is deduced): qt_noop(); | - |
189 | Q_ASSERT(proxy_index.model() == q_func()); executed (the execution status of this line is deduced): qt_noop(); | - |
190 | const void *p = proxy_index.internalPointer(); executed (the execution status of this line is deduced): const void *p = proxy_index.internalPointer(); | - |
191 | Q_ASSERT(p); executed (the execution status of this line is deduced): qt_noop(); | - |
192 | QHash<QModelIndex, Mapping *>::const_iterator it = executed (the execution status of this line is deduced): QHash<QModelIndex, Mapping *>::const_iterator it = | - |
193 | static_cast<const Mapping*>(p)->map_iter; executed (the execution status of this line is deduced): static_cast<const Mapping*>(p)->map_iter; | - |
194 | Q_ASSERT(it != source_index_mapping.constEnd()); executed (the execution status of this line is deduced): qt_noop(); | - |
195 | Q_ASSERT(it.value()); executed (the execution status of this line is deduced): qt_noop(); | - |
196 | return it; executed: return it; Execution Count:131324 | 131324 |
197 | } | - |
198 | | - |
199 | inline QModelIndex create_index(int row, int column, | - |
200 | QHash<QModelIndex, Mapping*>::const_iterator it) const | - |
201 | { | - |
202 | return q_func()->createIndex(row, column, *it); executed: return q_func()->createIndex(row, column, *it); Execution Count:114988 | 114988 |
203 | } | - |
204 | | - |
205 | void _q_sourceDataChanged(const QModelIndex &source_top_left, | - |
206 | const QModelIndex &source_bottom_right); | - |
207 | void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end); | - |
208 | | - |
209 | void _q_sourceAboutToBeReset(); | - |
210 | void _q_sourceReset(); | - |
211 | | - |
212 | void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint); | - |
213 | void _q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint); | - |
214 | | - |
215 | void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent, | - |
216 | int start, int end); | - |
217 | void _q_sourceRowsInserted(const QModelIndex &source_parent, | - |
218 | int start, int end); | - |
219 | void _q_sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, | - |
220 | int start, int end); | - |
221 | void _q_sourceRowsRemoved(const QModelIndex &source_parent, | - |
222 | int start, int end); | - |
223 | void _q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, | - |
224 | int sourceStart, int sourceEnd, | - |
225 | const QModelIndex &destParent, int dest); | - |
226 | void _q_sourceRowsMoved(const QModelIndex &sourceParent, | - |
227 | int sourceStart, int sourceEnd, | - |
228 | const QModelIndex &destParent, int dest); | - |
229 | void _q_sourceColumnsAboutToBeInserted(const QModelIndex &source_parent, | - |
230 | int start, int end); | - |
231 | void _q_sourceColumnsInserted(const QModelIndex &source_parent, | - |
232 | int start, int end); | - |
233 | void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &source_parent, | - |
234 | int start, int end); | - |
235 | void _q_sourceColumnsRemoved(const QModelIndex &source_parent, | - |
236 | int start, int end); | - |
237 | void _q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, | - |
238 | int sourceStart, int sourceEnd, | - |
239 | const QModelIndex &destParent, int dest); | - |
240 | void _q_sourceColumnsMoved(const QModelIndex &sourceParent, | - |
241 | int sourceStart, int sourceEnd, | - |
242 | const QModelIndex &destParent, int dest); | - |
243 | | - |
244 | void _q_clearMapping(); | - |
245 | | - |
246 | void sort(); | - |
247 | bool update_source_sort_column(); | - |
248 | void sort_source_rows(QVector<int> &source_rows, | - |
249 | const QModelIndex &source_parent) const; | - |
250 | QVector<QPair<int, QVector<int > > > proxy_intervals_for_source_items_to_add( | - |
251 | const QVector<int> &proxy_to_source, const QVector<int> &source_items, | - |
252 | const QModelIndex &source_parent, Qt::Orientation orient) const; | - |
253 | QVector<QPair<int, int > > proxy_intervals_for_source_items( | - |
254 | const QVector<int> &source_to_proxy, const QVector<int> &source_items) const; | - |
255 | void insert_source_items( | - |
256 | QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, | - |
257 | const QVector<int> &source_items, const QModelIndex &source_parent, | - |
258 | Qt::Orientation orient, bool emit_signal = true); | - |
259 | void remove_source_items( | - |
260 | QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, | - |
261 | const QVector<int> &source_items, const QModelIndex &source_parent, | - |
262 | Qt::Orientation orient, bool emit_signal = true); | - |
263 | void remove_proxy_interval( | - |
264 | QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, | - |
265 | int proxy_start, int proxy_end, const QModelIndex &proxy_parent, | - |
266 | Qt::Orientation orient, bool emit_signal = true); | - |
267 | void build_source_to_proxy_mapping( | - |
268 | const QVector<int> &proxy_to_source, QVector<int> &source_to_proxy) const; | - |
269 | void source_items_inserted(const QModelIndex &source_parent, | - |
270 | int start, int end, Qt::Orientation orient); | - |
271 | void source_items_about_to_be_removed(const QModelIndex &source_parent, | - |
272 | int start, int end, Qt::Orientation orient); | - |
273 | void source_items_removed(const QModelIndex &source_parent, | - |
274 | int start, int end, Qt::Orientation orient); | - |
275 | void proxy_item_range( | - |
276 | const QVector<int> &source_to_proxy, const QVector<int> &source_items, | - |
277 | int &proxy_low, int &proxy_high) const; | - |
278 | | - |
279 | QModelIndexPairList store_persistent_indexes(); | - |
280 | void update_persistent_indexes(const QModelIndexPairList &source_indexes); | - |
281 | | - |
282 | void filter_changed(const QModelIndex &source_parent = QModelIndex()); | - |
283 | QSet<int> handle_filter_changed( | - |
284 | QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, | - |
285 | const QModelIndex &source_parent, Qt::Orientation orient); | - |
286 | | - |
287 | void updateChildrenMapping(const QModelIndex &source_parent, Mapping *parent_mapping, | - |
288 | Qt::Orientation orient, int start, int end, int delta_item_count, bool remove); | - |
289 | | - |
290 | virtual void _q_sourceModelDestroyed(); | - |
291 | }; | - |
292 | | - |
293 | typedef QHash<QModelIndex, QSortFilterProxyModelPrivate::Mapping *> IndexMap; | - |
294 | | - |
295 | void QSortFilterProxyModelPrivate::_q_sourceModelDestroyed() | - |
296 | { | - |
297 | QAbstractProxyModelPrivate::_q_sourceModelDestroyed(); executed (the execution status of this line is deduced): QAbstractProxyModelPrivate::_q_sourceModelDestroyed(); | - |
298 | _q_clearMapping(); executed (the execution status of this line is deduced): _q_clearMapping(); | - |
299 | } executed: } Execution Count:12 | 12 |
300 | | - |
301 | void QSortFilterProxyModelPrivate::remove_from_mapping(const QModelIndex &source_parent) | - |
302 | { | - |
303 | if (Mapping *m = source_index_mapping.take(source_parent)) { partially evaluated: Mapping *m = source_index_mapping.take(source_parent) yes Evaluation Count:38 | no Evaluation Count:0 |
| 0-38 |
304 | for (int i = 0; i < m->mapped_children.size(); ++i) evaluated: i < m->mapped_children.size() yes Evaluation Count:20 | yes Evaluation Count:38 |
| 20-38 |
305 | remove_from_mapping(m->mapped_children.at(i)); executed: remove_from_mapping(m->mapped_children.at(i)); Execution Count:20 | 20 |
306 | delete m; executed (the execution status of this line is deduced): delete m; | - |
307 | } executed: } Execution Count:38 | 38 |
308 | } executed: } Execution Count:38 | 38 |
309 | | - |
310 | void QSortFilterProxyModelPrivate::_q_clearMapping() | - |
311 | { | - |
312 | // store the persistent indexes | - |
313 | QModelIndexPairList source_indexes = store_persistent_indexes(); executed (the execution status of this line is deduced): QModelIndexPairList source_indexes = store_persistent_indexes(); | - |
314 | | - |
315 | qDeleteAll(source_index_mapping); executed (the execution status of this line is deduced): qDeleteAll(source_index_mapping); | - |
316 | source_index_mapping.clear(); executed (the execution status of this line is deduced): source_index_mapping.clear(); | - |
317 | if (dynamic_sortfilter && update_source_sort_column()) { evaluated: dynamic_sortfilter yes Evaluation Count:776 | yes Evaluation Count:6 |
evaluated: update_source_sort_column() yes Evaluation Count:12 | yes Evaluation Count:764 |
| 6-776 |
318 | //update_source_sort_column might have created wrong mapping so we have to clear it again | - |
319 | qDeleteAll(source_index_mapping); executed (the execution status of this line is deduced): qDeleteAll(source_index_mapping); | - |
320 | source_index_mapping.clear(); executed (the execution status of this line is deduced): source_index_mapping.clear(); | - |
321 | } executed: } Execution Count:12 | 12 |
322 | | - |
323 | // update the persistent indexes | - |
324 | update_persistent_indexes(source_indexes); executed (the execution status of this line is deduced): update_persistent_indexes(source_indexes); | - |
325 | } executed: } Execution Count:782 | 782 |
326 | | - |
327 | IndexMap::const_iterator QSortFilterProxyModelPrivate::create_mapping( | - |
328 | const QModelIndex &source_parent) const | - |
329 | { | - |
330 | Q_Q(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModel * const q = q_func(); | - |
331 | | - |
332 | IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); | - |
333 | if (it != source_index_mapping.constEnd()) // was mapped already evaluated: it != source_index_mapping.constEnd() yes Evaluation Count:146436 | yes Evaluation Count:1173 |
| 1173-146436 |
334 | return it; executed: return it; Execution Count:146436 | 146436 |
335 | | - |
336 | Mapping *m = new Mapping; executed (the execution status of this line is deduced): Mapping *m = new Mapping; | - |
337 | | - |
338 | int source_rows = model->rowCount(source_parent); executed (the execution status of this line is deduced): int source_rows = model->rowCount(source_parent); | - |
339 | m->source_rows.reserve(source_rows); executed (the execution status of this line is deduced): m->source_rows.reserve(source_rows); | - |
340 | for (int i = 0; i < source_rows; ++i) { evaluated: i < source_rows yes Evaluation Count:11362 | yes Evaluation Count:1173 |
| 1173-11362 |
341 | if (q->filterAcceptsRow(i, source_parent)) evaluated: q->filterAcceptsRow(i, source_parent) yes Evaluation Count:4731 | yes Evaluation Count:6631 |
| 4731-6631 |
342 | m->source_rows.append(i); executed: m->source_rows.append(i); Execution Count:4731 | 4731 |
343 | } executed: } Execution Count:11362 | 11362 |
344 | int source_cols = model->columnCount(source_parent); executed (the execution status of this line is deduced): int source_cols = model->columnCount(source_parent); | - |
345 | m->source_columns.reserve(source_cols); executed (the execution status of this line is deduced): m->source_columns.reserve(source_cols); | - |
346 | for (int i = 0; i < source_cols; ++i) { evaluated: i < source_cols yes Evaluation Count:235 | yes Evaluation Count:1173 |
| 235-1173 |
347 | if (q->filterAcceptsColumn(i, source_parent)) partially evaluated: q->filterAcceptsColumn(i, source_parent) yes Evaluation Count:235 | no Evaluation Count:0 |
| 0-235 |
348 | m->source_columns.append(i); executed: m->source_columns.append(i); Execution Count:235 | 235 |
349 | } executed: } Execution Count:235 | 235 |
350 | | - |
351 | sort_source_rows(m->source_rows, source_parent); executed (the execution status of this line is deduced): sort_source_rows(m->source_rows, source_parent); | - |
352 | m->proxy_rows.resize(source_rows); executed (the execution status of this line is deduced): m->proxy_rows.resize(source_rows); | - |
353 | build_source_to_proxy_mapping(m->source_rows, m->proxy_rows); executed (the execution status of this line is deduced): build_source_to_proxy_mapping(m->source_rows, m->proxy_rows); | - |
354 | m->proxy_columns.resize(source_cols); executed (the execution status of this line is deduced): m->proxy_columns.resize(source_cols); | - |
355 | build_source_to_proxy_mapping(m->source_columns, m->proxy_columns); executed (the execution status of this line is deduced): build_source_to_proxy_mapping(m->source_columns, m->proxy_columns); | - |
356 | | - |
357 | it = IndexMap::const_iterator(source_index_mapping.insert(source_parent, m)); executed (the execution status of this line is deduced): it = IndexMap::const_iterator(source_index_mapping.insert(source_parent, m)); | - |
358 | m->map_iter = it; executed (the execution status of this line is deduced): m->map_iter = it; | - |
359 | | - |
360 | if (source_parent.isValid()) { evaluated: source_parent.isValid() yes Evaluation Count:763 | yes Evaluation Count:410 |
| 410-763 |
361 | QModelIndex source_grand_parent = source_parent.parent(); executed (the execution status of this line is deduced): QModelIndex source_grand_parent = source_parent.parent(); | - |
362 | IndexMap::const_iterator it2 = create_mapping(source_grand_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it2 = create_mapping(source_grand_parent); | - |
363 | Q_ASSERT(it2 != source_index_mapping.constEnd()); executed (the execution status of this line is deduced): qt_noop(); | - |
364 | it2.value()->mapped_children.append(source_parent); executed (the execution status of this line is deduced): it2.value()->mapped_children.append(source_parent); | - |
365 | } executed: } Execution Count:763 | 763 |
366 | | - |
367 | Q_ASSERT(it != source_index_mapping.constEnd()); executed (the execution status of this line is deduced): qt_noop(); | - |
368 | Q_ASSERT(it.value()); executed (the execution status of this line is deduced): qt_noop(); | - |
369 | | - |
370 | return it; executed: return it; Execution Count:1173 | 1173 |
371 | } | - |
372 | | - |
373 | QModelIndex QSortFilterProxyModelPrivate::proxy_to_source(const QModelIndex &proxy_index) const | - |
374 | { | - |
375 | if (!proxy_index.isValid()) evaluated: !proxy_index.isValid() yes Evaluation Count:99785 | yes Evaluation Count:98443 |
| 98443-99785 |
376 | return QModelIndex(); // for now; we may want to be able to set a root index later executed: return QModelIndex(); Execution Count:99785 | 99785 |
377 | if (proxy_index.model() != q_func()) { evaluated: proxy_index.model() != q_func() yes Evaluation Count:1 | yes Evaluation Count:98442 |
| 1-98442 |
378 | qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapToSource"; executed (the execution status of this line is deduced): QMessageLogger("itemmodels/qsortfilterproxymodel.cpp", 378, __PRETTY_FUNCTION__).warning() << "QSortFilterProxyModel: index from wrong model passed to mapToSource"; | - |
379 | Q_ASSERT(!"QSortFilterProxyModel: index from wrong model passed to mapToSource"); executed (the execution status of this line is deduced): qt_noop(); | - |
380 | return QModelIndex(); executed: return QModelIndex(); Execution Count:1 | 1 |
381 | } | - |
382 | IndexMap::const_iterator it = index_to_iterator(proxy_index); executed (the execution status of this line is deduced): IndexMap::const_iterator it = index_to_iterator(proxy_index); | - |
383 | Mapping *m = it.value(); executed (the execution status of this line is deduced): Mapping *m = it.value(); | - |
384 | if ((proxy_index.row() >= m->source_rows.size()) || (proxy_index.column() >= m->source_columns.size())) partially evaluated: (proxy_index.row() >= m->source_rows.size()) no Evaluation Count:0 | yes Evaluation Count:98442 |
partially evaluated: (proxy_index.column() >= m->source_columns.size()) no Evaluation Count:0 | yes Evaluation Count:98442 |
| 0-98442 |
385 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
386 | int source_row = m->source_rows.at(proxy_index.row()); executed (the execution status of this line is deduced): int source_row = m->source_rows.at(proxy_index.row()); | - |
387 | int source_col = m->source_columns.at(proxy_index.column()); executed (the execution status of this line is deduced): int source_col = m->source_columns.at(proxy_index.column()); | - |
388 | return model->index(source_row, source_col, it.key()); executed: return model->index(source_row, source_col, it.key()); Execution Count:98442 | 98442 |
389 | } | - |
390 | | - |
391 | QModelIndex QSortFilterProxyModelPrivate::source_to_proxy(const QModelIndex &source_index) const | - |
392 | { | - |
393 | if (!source_index.isValid()) evaluated: !source_index.isValid() yes Evaluation Count:11762 | yes Evaluation Count:7279 |
| 7279-11762 |
394 | return QModelIndex(); // for now; we may want to be able to set a root index later executed: return QModelIndex(); Execution Count:11762 | 11762 |
395 | if (source_index.model() != model) { evaluated: source_index.model() != model yes Evaluation Count:1 | yes Evaluation Count:7278 |
| 1-7278 |
396 | qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapFromSource"; executed (the execution status of this line is deduced): QMessageLogger("itemmodels/qsortfilterproxymodel.cpp", 396, __PRETTY_FUNCTION__).warning() << "QSortFilterProxyModel: index from wrong model passed to mapFromSource"; | - |
397 | Q_ASSERT(!"QSortFilterProxyModel: index from wrong model passed to mapFromSource"); executed (the execution status of this line is deduced): qt_noop(); | - |
398 | return QModelIndex(); executed: return QModelIndex(); Execution Count:1 | 1 |
399 | } | - |
400 | QModelIndex source_parent = source_index.parent(); executed (the execution status of this line is deduced): QModelIndex source_parent = source_index.parent(); | - |
401 | IndexMap::const_iterator it = create_mapping(source_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it = create_mapping(source_parent); | - |
402 | Mapping *m = it.value(); executed (the execution status of this line is deduced): Mapping *m = it.value(); | - |
403 | if ((source_index.row() >= m->proxy_rows.size()) || (source_index.column() >= m->proxy_columns.size())) partially evaluated: (source_index.row() >= m->proxy_rows.size()) no Evaluation Count:0 | yes Evaluation Count:7278 |
partially evaluated: (source_index.column() >= m->proxy_columns.size()) no Evaluation Count:0 | yes Evaluation Count:7278 |
| 0-7278 |
404 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
405 | int proxy_row = m->proxy_rows.at(source_index.row()); executed (the execution status of this line is deduced): int proxy_row = m->proxy_rows.at(source_index.row()); | - |
406 | int proxy_column = m->proxy_columns.at(source_index.column()); executed (the execution status of this line is deduced): int proxy_column = m->proxy_columns.at(source_index.column()); | - |
407 | if (proxy_row == -1 || proxy_column == -1) evaluated: proxy_row == -1 yes Evaluation Count:8 | yes Evaluation Count:7270 |
partially evaluated: proxy_column == -1 no Evaluation Count:0 | yes Evaluation Count:7270 |
| 0-7270 |
408 | return QModelIndex(); executed: return QModelIndex(); Execution Count:8 | 8 |
409 | return create_index(proxy_row, proxy_column, it); executed: return create_index(proxy_row, proxy_column, it); Execution Count:7270 | 7270 |
410 | } | - |
411 | | - |
412 | bool QSortFilterProxyModelPrivate::can_create_mapping(const QModelIndex &source_parent) const | - |
413 | { | - |
414 | if (source_parent.isValid()) { evaluated: source_parent.isValid() yes Evaluation Count:1672 | yes Evaluation Count:590 |
| 590-1672 |
415 | QModelIndex source_grand_parent = source_parent.parent(); executed (the execution status of this line is deduced): QModelIndex source_grand_parent = source_parent.parent(); | - |
416 | IndexMap::const_iterator it = source_index_mapping.constFind(source_grand_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it = source_index_mapping.constFind(source_grand_parent); | - |
417 | if (it == source_index_mapping.constEnd()) { partially evaluated: it == source_index_mapping.constEnd() no Evaluation Count:0 | yes Evaluation Count:1672 |
| 0-1672 |
418 | // Don't care, since we don't have mapping for the grand parent | - |
419 | return false; never executed: return false; | 0 |
420 | } | - |
421 | Mapping *gm = it.value(); executed (the execution status of this line is deduced): Mapping *gm = it.value(); | - |
422 | if (gm->proxy_rows.at(source_parent.row()) == -1 || evaluated: gm->proxy_rows.at(source_parent.row()) == -1 yes Evaluation Count:4 | yes Evaluation Count:1668 |
| 4-1668 |
423 | gm->proxy_columns.at(source_parent.column()) == -1) { partially evaluated: gm->proxy_columns.at(source_parent.column()) == -1 no Evaluation Count:0 | yes Evaluation Count:1668 |
| 0-1668 |
424 | // Don't care, since parent is filtered | - |
425 | return false; executed: return false; Execution Count:4 | 4 |
426 | } | - |
427 | } executed: } Execution Count:1668 | 1668 |
428 | return true; executed: return true; Execution Count:2258 | 2258 |
429 | } | - |
430 | | - |
431 | /*! | - |
432 | \internal | - |
433 | | - |
434 | Sorts the existing mappings. | - |
435 | */ | - |
436 | void QSortFilterProxyModelPrivate::sort() | - |
437 | { | - |
438 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
439 | emit q->layoutAboutToBeChanged(QList<QPersistentModelIndex>(), QAbstractItemModel::VerticalSortHint); executed (the execution status of this line is deduced): q->layoutAboutToBeChanged(QList<QPersistentModelIndex>(), QAbstractItemModel::VerticalSortHint); | - |
440 | QModelIndexPairList source_indexes = store_persistent_indexes(); executed (the execution status of this line is deduced): QModelIndexPairList source_indexes = store_persistent_indexes(); | - |
441 | IndexMap::const_iterator it = source_index_mapping.constBegin(); executed (the execution status of this line is deduced): IndexMap::const_iterator it = source_index_mapping.constBegin(); | - |
442 | for (; it != source_index_mapping.constEnd(); ++it) { evaluated: it != source_index_mapping.constEnd() yes Evaluation Count:255 | yes Evaluation Count:230 |
| 230-255 |
443 | QModelIndex source_parent = it.key(); executed (the execution status of this line is deduced): QModelIndex source_parent = it.key(); | - |
444 | Mapping *m = it.value(); executed (the execution status of this line is deduced): Mapping *m = it.value(); | - |
445 | sort_source_rows(m->source_rows, source_parent); executed (the execution status of this line is deduced): sort_source_rows(m->source_rows, source_parent); | - |
446 | build_source_to_proxy_mapping(m->source_rows, m->proxy_rows); executed (the execution status of this line is deduced): build_source_to_proxy_mapping(m->source_rows, m->proxy_rows); | - |
447 | } executed: } Execution Count:255 | 255 |
448 | update_persistent_indexes(source_indexes); executed (the execution status of this line is deduced): update_persistent_indexes(source_indexes); | - |
449 | emit q->layoutChanged(QList<QPersistentModelIndex>(), QAbstractItemModel::VerticalSortHint); executed (the execution status of this line is deduced): q->layoutChanged(QList<QPersistentModelIndex>(), QAbstractItemModel::VerticalSortHint); | - |
450 | } executed: } Execution Count:230 | 230 |
451 | | - |
452 | /*! | - |
453 | \internal | - |
454 | | - |
455 | update the source_sort_column according to the proxy_sort_column | - |
456 | return true if the column was changed | - |
457 | */ | - |
458 | bool QSortFilterProxyModelPrivate::update_source_sort_column() | - |
459 | { | - |
460 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
461 | QModelIndex proxy_index = q->index(0, proxy_sort_column, QModelIndex()); executed (the execution status of this line is deduced): QModelIndex proxy_index = q->index(0, proxy_sort_column, QModelIndex()); | - |
462 | int old_source_sort_column = source_sort_column; executed (the execution status of this line is deduced): int old_source_sort_column = source_sort_column; | - |
463 | source_sort_column = q->mapToSource(proxy_index).column(); executed (the execution status of this line is deduced): source_sort_column = q->mapToSource(proxy_index).column(); | - |
464 | return old_source_sort_column != source_sort_column; executed: return old_source_sort_column != source_sort_column; Execution Count:2689 | 2689 |
465 | } | - |
466 | | - |
467 | | - |
468 | /*! | - |
469 | \internal | - |
470 | | - |
471 | Sorts the given \a source_rows according to current sort column and order. | - |
472 | */ | - |
473 | void QSortFilterProxyModelPrivate::sort_source_rows( | - |
474 | QVector<int> &source_rows, const QModelIndex &source_parent) const | - |
475 | { | - |
476 | Q_Q(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModel * const q = q_func(); | - |
477 | if (source_sort_column >= 0) { evaluated: source_sort_column >= 0 yes Evaluation Count:253 | yes Evaluation Count:2354 |
| 253-2354 |
478 | if (sort_order == Qt::AscendingOrder) { evaluated: sort_order == Qt::AscendingOrder yes Evaluation Count:234 | yes Evaluation Count:19 |
| 19-234 |
479 | QSortFilterProxyModelLessThan lt(source_sort_column, source_parent, model, q); executed (the execution status of this line is deduced): QSortFilterProxyModelLessThan lt(source_sort_column, source_parent, model, q); | - |
480 | std::stable_sort(source_rows.begin(), source_rows.end(), lt); executed (the execution status of this line is deduced): std::stable_sort(source_rows.begin(), source_rows.end(), lt); | - |
481 | } else { executed: } Execution Count:234 | 234 |
482 | QSortFilterProxyModelGreaterThan gt(source_sort_column, source_parent, model, q); executed (the execution status of this line is deduced): QSortFilterProxyModelGreaterThan gt(source_sort_column, source_parent, model, q); | - |
483 | std::stable_sort(source_rows.begin(), source_rows.end(), gt); executed (the execution status of this line is deduced): std::stable_sort(source_rows.begin(), source_rows.end(), gt); | - |
484 | } executed: } Execution Count:19 | 19 |
485 | } else { // restore the source model order | - |
486 | std::stable_sort(source_rows.begin(), source_rows.end()); executed (the execution status of this line is deduced): std::stable_sort(source_rows.begin(), source_rows.end()); | - |
487 | } executed: } Execution Count:2354 | 2354 |
488 | } | - |
489 | | - |
490 | /*! | - |
491 | \internal | - |
492 | | - |
493 | Given source-to-proxy mapping \a source_to_proxy and the set of | - |
494 | source items \a source_items (which are part of that mapping), | - |
495 | determines the corresponding proxy item intervals that should | - |
496 | be removed from the proxy model. | - |
497 | | - |
498 | The result is a vector of pairs, where each pair represents a | - |
499 | (start, end) tuple, sorted in ascending order. | - |
500 | */ | - |
501 | QVector<QPair<int, int > > QSortFilterProxyModelPrivate::proxy_intervals_for_source_items( | - |
502 | const QVector<int> &source_to_proxy, const QVector<int> &source_items) const | - |
503 | { | - |
504 | QVector<QPair<int, int> > proxy_intervals; executed (the execution status of this line is deduced): QVector<QPair<int, int> > proxy_intervals; | - |
505 | if (source_items.isEmpty()) evaluated: source_items.isEmpty() yes Evaluation Count:10 | yes Evaluation Count:119 |
| 10-119 |
506 | return proxy_intervals; executed: return proxy_intervals; Execution Count:10 | 10 |
507 | | - |
508 | int source_items_index = 0; executed (the execution status of this line is deduced): int source_items_index = 0; | - |
509 | while (source_items_index < source_items.size()) { evaluated: source_items_index < source_items.size() yes Evaluation Count:139 | yes Evaluation Count:119 |
| 119-139 |
510 | int first_proxy_item = source_to_proxy.at(source_items.at(source_items_index)); executed (the execution status of this line is deduced): int first_proxy_item = source_to_proxy.at(source_items.at(source_items_index)); | - |
511 | Q_ASSERT(first_proxy_item != -1); executed (the execution status of this line is deduced): qt_noop(); | - |
512 | int last_proxy_item = first_proxy_item; executed (the execution status of this line is deduced): int last_proxy_item = first_proxy_item; | - |
513 | ++source_items_index; executed (the execution status of this line is deduced): ++source_items_index; | - |
514 | // Find end of interval | - |
515 | while ((source_items_index < source_items.size()) evaluated: (source_items_index < source_items.size()) yes Evaluation Count:484 | yes Evaluation Count:119 |
| 119-484 |
516 | && (source_to_proxy.at(source_items.at(source_items_index)) == last_proxy_item + 1)) { evaluated: (source_to_proxy.at(source_items.at(source_items_index)) == last_proxy_item + 1) yes Evaluation Count:464 | yes Evaluation Count:20 |
| 20-464 |
517 | ++last_proxy_item; executed (the execution status of this line is deduced): ++last_proxy_item; | - |
518 | ++source_items_index; executed (the execution status of this line is deduced): ++source_items_index; | - |
519 | } executed: } Execution Count:464 | 464 |
520 | // Add interval to result | - |
521 | proxy_intervals.append(QPair<int, int>(first_proxy_item, last_proxy_item)); executed (the execution status of this line is deduced): proxy_intervals.append(QPair<int, int>(first_proxy_item, last_proxy_item)); | - |
522 | } executed: } Execution Count:139 | 139 |
523 | std::stable_sort(proxy_intervals.begin(), proxy_intervals.end()); executed (the execution status of this line is deduced): std::stable_sort(proxy_intervals.begin(), proxy_intervals.end()); | - |
524 | return proxy_intervals; executed: return proxy_intervals; Execution Count:119 | 119 |
525 | } | - |
526 | | - |
527 | /*! | - |
528 | \internal | - |
529 | | - |
530 | Given source-to-proxy mapping \a src_to_proxy and proxy-to-source mapping | - |
531 | \a proxy_to_source, removes \a source_items from this proxy model. | - |
532 | The corresponding proxy items are removed in intervals, so that the proper | - |
533 | rows/columnsRemoved(start, end) signals will be generated. | - |
534 | */ | - |
535 | void QSortFilterProxyModelPrivate::remove_source_items( | - |
536 | QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, | - |
537 | const QVector<int> &source_items, const QModelIndex &source_parent, | - |
538 | Qt::Orientation orient, bool emit_signal) | - |
539 | { | - |
540 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
541 | QModelIndex proxy_parent = q->mapFromSource(source_parent); executed (the execution status of this line is deduced): QModelIndex proxy_parent = q->mapFromSource(source_parent); | - |
542 | if (!proxy_parent.isValid() && source_parent.isValid()) evaluated: !proxy_parent.isValid() yes Evaluation Count:71 | yes Evaluation Count:58 |
partially evaluated: source_parent.isValid() no Evaluation Count:0 | yes Evaluation Count:71 |
| 0-71 |
543 | return; // nothing to do (already removed) | 0 |
544 | | - |
545 | QVector<QPair<int, int> > proxy_intervals; executed (the execution status of this line is deduced): QVector<QPair<int, int> > proxy_intervals; | - |
546 | proxy_intervals = proxy_intervals_for_source_items(source_to_proxy, source_items); executed (the execution status of this line is deduced): proxy_intervals = proxy_intervals_for_source_items(source_to_proxy, source_items); | - |
547 | | - |
548 | for (int i = proxy_intervals.size()-1; i >= 0; --i) { evaluated: i >= 0 yes Evaluation Count:139 | yes Evaluation Count:129 |
| 129-139 |
549 | QPair<int, int> interval = proxy_intervals.at(i); executed (the execution status of this line is deduced): QPair<int, int> interval = proxy_intervals.at(i); | - |
550 | int proxy_start = interval.first; executed (the execution status of this line is deduced): int proxy_start = interval.first; | - |
551 | int proxy_end = interval.second; executed (the execution status of this line is deduced): int proxy_end = interval.second; | - |
552 | remove_proxy_interval(source_to_proxy, proxy_to_source, proxy_start, proxy_end, executed (the execution status of this line is deduced): remove_proxy_interval(source_to_proxy, proxy_to_source, proxy_start, proxy_end, | - |
553 | proxy_parent, orient, emit_signal); executed (the execution status of this line is deduced): proxy_parent, orient, emit_signal); | - |
554 | } executed: } Execution Count:139 | 139 |
555 | } executed: } Execution Count:129 | 129 |
556 | | - |
557 | /*! | - |
558 | \internal | - |
559 | | - |
560 | Given source-to-proxy mapping \a source_to_proxy and proxy-to-source mapping | - |
561 | \a proxy_to_source, removes items from \a proxy_start to \a proxy_end | - |
562 | (inclusive) from this proxy model. | - |
563 | */ | - |
564 | void QSortFilterProxyModelPrivate::remove_proxy_interval( | - |
565 | QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, int proxy_start, int proxy_end, | - |
566 | const QModelIndex &proxy_parent, Qt::Orientation orient, bool emit_signal) | - |
567 | { | - |
568 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
569 | if (emit_signal) { evaluated: emit_signal yes Evaluation Count:134 | yes Evaluation Count:5 |
| 5-134 |
570 | if (orient == Qt::Vertical) evaluated: orient == Qt::Vertical yes Evaluation Count:99 | yes Evaluation Count:35 |
| 35-99 |
571 | q->beginRemoveRows(proxy_parent, proxy_start, proxy_end); executed: q->beginRemoveRows(proxy_parent, proxy_start, proxy_end); Execution Count:99 | 99 |
572 | else | - |
573 | q->beginRemoveColumns(proxy_parent, proxy_start, proxy_end); executed: q->beginRemoveColumns(proxy_parent, proxy_start, proxy_end); Execution Count:35 | 35 |
574 | } | - |
575 | | - |
576 | // Remove items from proxy-to-source mapping | - |
577 | proxy_to_source.remove(proxy_start, proxy_end - proxy_start + 1); executed (the execution status of this line is deduced): proxy_to_source.remove(proxy_start, proxy_end - proxy_start + 1); | - |
578 | | - |
579 | build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); executed (the execution status of this line is deduced): build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); | - |
580 | | - |
581 | if (emit_signal) { evaluated: emit_signal yes Evaluation Count:134 | yes Evaluation Count:5 |
| 5-134 |
582 | if (orient == Qt::Vertical) evaluated: orient == Qt::Vertical yes Evaluation Count:99 | yes Evaluation Count:35 |
| 35-99 |
583 | q->endRemoveRows(); executed: q->endRemoveRows(); Execution Count:99 | 99 |
584 | else | - |
585 | q->endRemoveColumns(); executed: q->endRemoveColumns(); Execution Count:35 | 35 |
586 | } | - |
587 | } executed: } Execution Count:139 | 139 |
588 | | - |
589 | /*! | - |
590 | \internal | - |
591 | | - |
592 | Given proxy-to-source mapping \a proxy_to_source and a set of | - |
593 | unmapped source items \a source_items, determines the proxy item | - |
594 | intervals at which the subsets of source items should be inserted | - |
595 | (but does not actually add them to the mapping). | - |
596 | | - |
597 | The result is a vector of pairs, each pair representing a tuple (start, | - |
598 | items), where items is a vector containing the (sorted) source items that | - |
599 | should be inserted at that proxy model location. | - |
600 | */ | - |
601 | QVector<QPair<int, QVector<int > > > QSortFilterProxyModelPrivate::proxy_intervals_for_source_items_to_add( | - |
602 | const QVector<int> &proxy_to_source, const QVector<int> &source_items, | - |
603 | const QModelIndex &source_parent, Qt::Orientation orient) const | - |
604 | { | - |
605 | Q_Q(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModel * const q = q_func(); | - |
606 | QVector<QPair<int, QVector<int> > > proxy_intervals; executed (the execution status of this line is deduced): QVector<QPair<int, QVector<int> > > proxy_intervals; | - |
607 | if (source_items.isEmpty()) evaluated: source_items.isEmpty() yes Evaluation Count:35 | yes Evaluation Count:2276 |
| 35-2276 |
608 | return proxy_intervals; executed: return proxy_intervals; Execution Count:35 | 35 |
609 | | - |
610 | int proxy_low = 0; executed (the execution status of this line is deduced): int proxy_low = 0; | - |
611 | int proxy_item = 0; executed (the execution status of this line is deduced): int proxy_item = 0; | - |
612 | int source_items_index = 0; executed (the execution status of this line is deduced): int source_items_index = 0; | - |
613 | QVector<int> source_items_in_interval; executed (the execution status of this line is deduced): QVector<int> source_items_in_interval; | - |
614 | bool compare = (orient == Qt::Vertical && source_sort_column >= 0 && dynamic_sortfilter); evaluated: orient == Qt::Vertical yes Evaluation Count:1144 | yes Evaluation Count:1132 |
evaluated: source_sort_column >= 0 yes Evaluation Count:12 | yes Evaluation Count:1132 |
evaluated: dynamic_sortfilter yes Evaluation Count:11 | yes Evaluation Count:1 |
| 1-1144 |
615 | while (source_items_index < source_items.size()) { evaluated: source_items_index < source_items.size() yes Evaluation Count:2286 | yes Evaluation Count:2276 |
| 2276-2286 |
616 | source_items_in_interval.clear(); executed (the execution status of this line is deduced): source_items_in_interval.clear(); | - |
617 | int first_new_source_item = source_items.at(source_items_index); executed (the execution status of this line is deduced): int first_new_source_item = source_items.at(source_items_index); | - |
618 | source_items_in_interval.append(first_new_source_item); executed (the execution status of this line is deduced): source_items_in_interval.append(first_new_source_item); | - |
619 | ++source_items_index; executed (the execution status of this line is deduced): ++source_items_index; | - |
620 | | - |
621 | // Find proxy item at which insertion should be started | - |
622 | int proxy_high = proxy_to_source.size() - 1; executed (the execution status of this line is deduced): int proxy_high = proxy_to_source.size() - 1; | - |
623 | QModelIndex i1 = compare ? model->index(first_new_source_item, source_sort_column, source_parent) : QModelIndex(); evaluated: compare yes Evaluation Count:13 | yes Evaluation Count:2273 |
| 13-2273 |
624 | while (proxy_low <= proxy_high) { evaluated: proxy_low <= proxy_high yes Evaluation Count:1152 | yes Evaluation Count:2286 |
| 1152-2286 |
625 | proxy_item = (proxy_low + proxy_high) / 2; executed (the execution status of this line is deduced): proxy_item = (proxy_low + proxy_high) / 2; | - |
626 | if (compare) { evaluated: compare yes Evaluation Count:19 | yes Evaluation Count:1133 |
| 19-1133 |
627 | QModelIndex i2 = model->index(proxy_to_source.at(proxy_item), source_sort_column, source_parent); executed (the execution status of this line is deduced): QModelIndex i2 = model->index(proxy_to_source.at(proxy_item), source_sort_column, source_parent); | - |
628 | if ((sort_order == Qt::AscendingOrder) ? q->lessThan(i1, i2) : q->lessThan(i2, i1)) evaluated: (sort_order == Qt::AscendingOrder) yes Evaluation Count:13 | yes Evaluation Count:6 |
| 6-13 |
629 | proxy_high = proxy_item - 1; executed: proxy_high = proxy_item - 1; Execution Count:4 | 4 |
630 | else | - |
631 | proxy_low = proxy_item + 1; executed: proxy_low = proxy_item + 1; Execution Count:15 | 15 |
632 | } else { | - |
633 | if (first_new_source_item < proxy_to_source.at(proxy_item)) evaluated: first_new_source_item < proxy_to_source.at(proxy_item) yes Evaluation Count:882 | yes Evaluation Count:251 |
| 251-882 |
634 | proxy_high = proxy_item - 1; executed: proxy_high = proxy_item - 1; Execution Count:882 | 882 |
635 | else | - |
636 | proxy_low = proxy_item + 1; executed: proxy_low = proxy_item + 1; Execution Count:251 | 251 |
637 | } | - |
638 | } | - |
639 | proxy_item = proxy_low; executed (the execution status of this line is deduced): proxy_item = proxy_low; | - |
640 | | - |
641 | // Find the sequence of new source items that should be inserted here | - |
642 | if (proxy_item >= proxy_to_source.size()) { evaluated: proxy_item >= proxy_to_source.size() yes Evaluation Count:2042 | yes Evaluation Count:244 |
| 244-2042 |
643 | for ( ; source_items_index < source_items.size(); ++source_items_index) evaluated: source_items_index < source_items.size() yes Evaluation Count:55105 | yes Evaluation Count:2042 |
| 2042-55105 |
644 | source_items_in_interval.append(source_items.at(source_items_index)); executed: source_items_in_interval.append(source_items.at(source_items_index)); Execution Count:55105 | 55105 |
645 | } else { executed: } Execution Count:2042 | 2042 |
646 | i1 = compare ? model->index(proxy_to_source.at(proxy_item), source_sort_column, source_parent) : QModelIndex(); evaluated: compare yes Evaluation Count:4 | yes Evaluation Count:240 |
| 4-240 |
647 | for ( ; source_items_index < source_items.size(); ++source_items_index) { evaluated: source_items_index < source_items.size() yes Evaluation Count:4828 | yes Evaluation Count:234 |
| 234-4828 |
648 | int new_source_item = source_items.at(source_items_index); executed (the execution status of this line is deduced): int new_source_item = source_items.at(source_items_index); | - |
649 | if (compare) { evaluated: compare yes Evaluation Count:2 | yes Evaluation Count:4826 |
| 2-4826 |
650 | QModelIndex i2 = model->index(new_source_item, source_sort_column, source_parent); executed (the execution status of this line is deduced): QModelIndex i2 = model->index(new_source_item, source_sort_column, source_parent); | - |
651 | if ((sort_order == Qt::AscendingOrder) ? q->lessThan(i1, i2) : q->lessThan(i2, i1)) partially evaluated: (sort_order == Qt::AscendingOrder) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
652 | break; executed: break; Execution Count:2 | 2 |
653 | } else { | 0 |
654 | if (proxy_to_source.at(proxy_item) < new_source_item) evaluated: proxy_to_source.at(proxy_item) < new_source_item yes Evaluation Count:8 | yes Evaluation Count:4818 |
| 8-4818 |
655 | break; executed: break; Execution Count:8 | 8 |
656 | } executed: } Execution Count:4818 | 4818 |
657 | source_items_in_interval.append(new_source_item); executed (the execution status of this line is deduced): source_items_in_interval.append(new_source_item); | - |
658 | } executed: } Execution Count:4818 | 4818 |
659 | } executed: } Execution Count:244 | 244 |
660 | | - |
661 | // Add interval to result | - |
662 | proxy_intervals.append(QPair<int, QVector<int> >(proxy_item, source_items_in_interval)); executed (the execution status of this line is deduced): proxy_intervals.append(QPair<int, QVector<int> >(proxy_item, source_items_in_interval)); | - |
663 | } executed: } Execution Count:2286 | 2286 |
664 | return proxy_intervals; executed: return proxy_intervals; Execution Count:2276 | 2276 |
665 | } | - |
666 | | - |
667 | /*! | - |
668 | \internal | - |
669 | | - |
670 | Given source-to-proxy mapping \a source_to_proxy and proxy-to-source mapping | - |
671 | \a proxy_to_source, inserts the given \a source_items into this proxy model. | - |
672 | The source items are inserted in intervals (based on some sorted order), so | - |
673 | that the proper rows/columnsInserted(start, end) signals will be generated. | - |
674 | */ | - |
675 | void QSortFilterProxyModelPrivate::insert_source_items( | - |
676 | QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, | - |
677 | const QVector<int> &source_items, const QModelIndex &source_parent, | - |
678 | Qt::Orientation orient, bool emit_signal) | - |
679 | { | - |
680 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
681 | QModelIndex proxy_parent = q->mapFromSource(source_parent); executed (the execution status of this line is deduced): QModelIndex proxy_parent = q->mapFromSource(source_parent); | - |
682 | if (!proxy_parent.isValid() && source_parent.isValid()) evaluated: !proxy_parent.isValid() yes Evaluation Count:631 | yes Evaluation Count:1680 |
partially evaluated: source_parent.isValid() no Evaluation Count:0 | yes Evaluation Count:631 |
| 0-1680 |
683 | return; // nothing to do (source_parent is not mapped) | 0 |
684 | | - |
685 | QVector<QPair<int, QVector<int> > > proxy_intervals; executed (the execution status of this line is deduced): QVector<QPair<int, QVector<int> > > proxy_intervals; | - |
686 | proxy_intervals = proxy_intervals_for_source_items_to_add( executed (the execution status of this line is deduced): proxy_intervals = proxy_intervals_for_source_items_to_add( | - |
687 | proxy_to_source, source_items, source_parent, orient); executed (the execution status of this line is deduced): proxy_to_source, source_items, source_parent, orient); | - |
688 | | - |
689 | for (int i = proxy_intervals.size()-1; i >= 0; --i) { evaluated: i >= 0 yes Evaluation Count:2286 | yes Evaluation Count:2311 |
| 2286-2311 |
690 | QPair<int, QVector<int> > interval = proxy_intervals.at(i); executed (the execution status of this line is deduced): QPair<int, QVector<int> > interval = proxy_intervals.at(i); | - |
691 | int proxy_start = interval.first; executed (the execution status of this line is deduced): int proxy_start = interval.first; | - |
692 | QVector<int> source_items = interval.second; executed (the execution status of this line is deduced): QVector<int> source_items = interval.second; | - |
693 | int proxy_end = proxy_start + source_items.size() - 1; executed (the execution status of this line is deduced): int proxy_end = proxy_start + source_items.size() - 1; | - |
694 | | - |
695 | if (emit_signal) { evaluated: emit_signal yes Evaluation Count:2281 | yes Evaluation Count:5 |
| 5-2281 |
696 | if (orient == Qt::Vertical) evaluated: orient == Qt::Vertical yes Evaluation Count:1149 | yes Evaluation Count:1132 |
| 1132-1149 |
697 | q->beginInsertRows(proxy_parent, proxy_start, proxy_end); executed: q->beginInsertRows(proxy_parent, proxy_start, proxy_end); Execution Count:1149 | 1149 |
698 | else | - |
699 | q->beginInsertColumns(proxy_parent, proxy_start, proxy_end); executed: q->beginInsertColumns(proxy_parent, proxy_start, proxy_end); Execution Count:1132 | 1132 |
700 | } | - |
701 | | - |
702 | for (int i = 0; i < source_items.size(); ++i) evaluated: i < source_items.size() yes Evaluation Count:62209 | yes Evaluation Count:2286 |
| 2286-62209 |
703 | proxy_to_source.insert(proxy_start + i, source_items.at(i)); executed: proxy_to_source.insert(proxy_start + i, source_items.at(i)); Execution Count:62209 | 62209 |
704 | | - |
705 | build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); executed (the execution status of this line is deduced): build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); | - |
706 | | - |
707 | if (emit_signal) { evaluated: emit_signal yes Evaluation Count:2281 | yes Evaluation Count:5 |
| 5-2281 |
708 | if (orient == Qt::Vertical) evaluated: orient == Qt::Vertical yes Evaluation Count:1149 | yes Evaluation Count:1132 |
| 1132-1149 |
709 | q->endInsertRows(); executed: q->endInsertRows(); Execution Count:1149 | 1149 |
710 | else | - |
711 | q->endInsertColumns(); executed: q->endInsertColumns(); Execution Count:1132 | 1132 |
712 | } | - |
713 | } executed: } Execution Count:2286 | 2286 |
714 | } executed: } Execution Count:2311 | 2311 |
715 | | - |
716 | /*! | - |
717 | \internal | - |
718 | | - |
719 | Handles source model items insertion (columnsInserted(), rowsInserted()). | - |
720 | Determines | - |
721 | 1) which of the inserted items to also insert into proxy model (filtering), | - |
722 | 2) where to insert the items into the proxy model (sorting), | - |
723 | then inserts those items. | - |
724 | The items are inserted into the proxy model in intervals (based on | - |
725 | sorted order), so that the proper rows/columnsInserted(start, end) | - |
726 | signals will be generated. | - |
727 | */ | - |
728 | void QSortFilterProxyModelPrivate::source_items_inserted( | - |
729 | const QModelIndex &source_parent, int start, int end, Qt::Orientation orient) | - |
730 | { | - |
731 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
732 | if ((start < 0) || (end < 0)) partially evaluated: (start < 0) no Evaluation Count:0 | yes Evaluation Count:2260 |
partially evaluated: (end < 0) no Evaluation Count:0 | yes Evaluation Count:2260 |
| 0-2260 |
733 | return; | 0 |
734 | IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); | - |
735 | if (it == source_index_mapping.constEnd()) { evaluated: it == source_index_mapping.constEnd() yes Evaluation Count:2 | yes Evaluation Count:2258 |
| 2-2258 |
736 | if (!can_create_mapping(source_parent)) partially evaluated: !can_create_mapping(source_parent) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
737 | return; executed: return; Execution Count:2 | 2 |
738 | it = create_mapping(source_parent); never executed (the execution status of this line is deduced): it = create_mapping(source_parent); | - |
739 | Mapping *m = it.value(); never executed (the execution status of this line is deduced): Mapping *m = it.value(); | - |
740 | QModelIndex proxy_parent = q->mapFromSource(source_parent); never executed (the execution status of this line is deduced): QModelIndex proxy_parent = q->mapFromSource(source_parent); | - |
741 | if (m->source_rows.count() > 0) { never evaluated: m->source_rows.count() > 0 | 0 |
742 | q->beginInsertRows(proxy_parent, 0, m->source_rows.count() - 1); never executed (the execution status of this line is deduced): q->beginInsertRows(proxy_parent, 0, m->source_rows.count() - 1); | - |
743 | q->endInsertRows(); never executed (the execution status of this line is deduced): q->endInsertRows(); | - |
744 | } | 0 |
745 | if (m->source_columns.count() > 0) { never evaluated: m->source_columns.count() > 0 | 0 |
746 | q->beginInsertColumns(proxy_parent, 0, m->source_columns.count() - 1); never executed (the execution status of this line is deduced): q->beginInsertColumns(proxy_parent, 0, m->source_columns.count() - 1); | - |
747 | q->endInsertColumns(); never executed (the execution status of this line is deduced): q->endInsertColumns(); | - |
748 | } | 0 |
749 | return; | 0 |
750 | } | - |
751 | | - |
752 | Mapping *m = it.value(); executed (the execution status of this line is deduced): Mapping *m = it.value(); | - |
753 | QVector<int> &source_to_proxy = (orient == Qt::Vertical) ? m->proxy_rows : m->proxy_columns; evaluated: (orient == Qt::Vertical) yes Evaluation Count:1126 | yes Evaluation Count:1132 |
| 1126-1132 |
754 | QVector<int> &proxy_to_source = (orient == Qt::Vertical) ? m->source_rows : m->source_columns; evaluated: (orient == Qt::Vertical) yes Evaluation Count:1126 | yes Evaluation Count:1132 |
| 1126-1132 |
755 | | - |
756 | int delta_item_count = end - start + 1; executed (the execution status of this line is deduced): int delta_item_count = end - start + 1; | - |
757 | int old_item_count = source_to_proxy.size(); executed (the execution status of this line is deduced): int old_item_count = source_to_proxy.size(); | - |
758 | | - |
759 | updateChildrenMapping(source_parent, m, orient, start, end, delta_item_count, false); executed (the execution status of this line is deduced): updateChildrenMapping(source_parent, m, orient, start, end, delta_item_count, false); | - |
760 | | - |
761 | // Expand source-to-proxy mapping to account for new items | - |
762 | if (start < 0 || start > source_to_proxy.size()) { partially evaluated: start < 0 no Evaluation Count:0 | yes Evaluation Count:2258 |
partially evaluated: start > source_to_proxy.size() no Evaluation Count:0 | yes Evaluation Count:2258 |
| 0-2258 |
763 | qWarning("QSortFilterProxyModel: invalid inserted rows reported by source model"); never executed (the execution status of this line is deduced): QMessageLogger("itemmodels/qsortfilterproxymodel.cpp", 763, __PRETTY_FUNCTION__).warning("QSortFilterProxyModel: invalid inserted rows reported by source model"); | - |
764 | remove_from_mapping(source_parent); never executed (the execution status of this line is deduced): remove_from_mapping(source_parent); | - |
765 | return; | 0 |
766 | } | - |
767 | source_to_proxy.insert(start, delta_item_count, -1); executed (the execution status of this line is deduced): source_to_proxy.insert(start, delta_item_count, -1); | - |
768 | | - |
769 | if (start < old_item_count) { evaluated: start < old_item_count yes Evaluation Count:231 | yes Evaluation Count:2027 |
| 231-2027 |
770 | // Adjust existing "stale" indexes in proxy-to-source mapping | - |
771 | int proxy_count = proxy_to_source.size(); executed (the execution status of this line is deduced): int proxy_count = proxy_to_source.size(); | - |
772 | for (int proxy_item = 0; proxy_item < proxy_count; ++proxy_item) { evaluated: proxy_item < proxy_count yes Evaluation Count:6691 | yes Evaluation Count:231 |
| 231-6691 |
773 | int source_item = proxy_to_source.at(proxy_item); executed (the execution status of this line is deduced): int source_item = proxy_to_source.at(proxy_item); | - |
774 | if (source_item >= start) evaluated: source_item >= start yes Evaluation Count:6124 | yes Evaluation Count:567 |
| 567-6124 |
775 | proxy_to_source.replace(proxy_item, source_item + delta_item_count); executed: proxy_to_source.replace(proxy_item, source_item + delta_item_count); Execution Count:6124 | 6124 |
776 | } executed: } Execution Count:6691 | 6691 |
777 | build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); executed (the execution status of this line is deduced): build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); | - |
778 | } executed: } Execution Count:231 | 231 |
779 | | - |
780 | // Figure out which items to add to mapping based on filter | - |
781 | QVector<int> source_items; executed (the execution status of this line is deduced): QVector<int> source_items; | - |
782 | for (int i = start; i <= end; ++i) { evaluated: i <= end yes Evaluation Count:62177 | yes Evaluation Count:2258 |
| 2258-62177 |
783 | if ((orient == Qt::Vertical) evaluated: (orient == Qt::Vertical) yes Evaluation Count:36285 | yes Evaluation Count:25892 |
| 25892-36285 |
784 | ? q->filterAcceptsRow(i, source_parent) executed (the execution status of this line is deduced): ? q->filterAcceptsRow(i, source_parent) | - |
785 | : q->filterAcceptsColumn(i, source_parent)) { executed (the execution status of this line is deduced): : q->filterAcceptsColumn(i, source_parent)) { | - |
786 | source_items.append(i); executed (the execution status of this line is deduced): source_items.append(i); | - |
787 | } executed: } Execution Count:62167 | 62167 |
788 | } executed: } Execution Count:62177 | 62177 |
789 | | - |
790 | if (model->rowCount(source_parent) == delta_item_count) { evaluated: model->rowCount(source_parent) == delta_item_count yes Evaluation Count:1765 | yes Evaluation Count:493 |
| 493-1765 |
791 | // Items were inserted where there were none before. | - |
792 | // If it was new rows make sure to create mappings for columns so that a | - |
793 | // valid mapping can be retrieved later and vice-versa. | - |
794 | | - |
795 | QVector<int> &orthogonal_proxy_to_source = (orient == Qt::Horizontal) ? m->source_rows : m->source_columns; evaluated: (orient == Qt::Horizontal) yes Evaluation Count:836 | yes Evaluation Count:929 |
| 836-929 |
796 | QVector<int> &orthogonal_source_to_proxy = (orient == Qt::Horizontal) ? m->proxy_rows : m->proxy_columns; evaluated: (orient == Qt::Horizontal) yes Evaluation Count:836 | yes Evaluation Count:929 |
| 836-929 |
797 | | - |
798 | if (orthogonal_source_to_proxy.isEmpty()) { evaluated: orthogonal_source_to_proxy.isEmpty() yes Evaluation Count:843 | yes Evaluation Count:922 |
| 843-922 |
799 | const int ortho_end = (orient == Qt::Horizontal) ? model->rowCount(source_parent) : model->columnCount(source_parent); partially evaluated: (orient == Qt::Horizontal) no Evaluation Count:0 | yes Evaluation Count:843 |
| 0-843 |
800 | | - |
801 | orthogonal_source_to_proxy.resize(ortho_end); executed (the execution status of this line is deduced): orthogonal_source_to_proxy.resize(ortho_end); | - |
802 | | - |
803 | for (int ortho_item = 0; ortho_item < ortho_end; ++ortho_item) { evaluated: ortho_item < ortho_end yes Evaluation Count:12 | yes Evaluation Count:843 |
| 12-843 |
804 | if ((orient == Qt::Horizontal) ? q->filterAcceptsRow(ortho_item, source_parent) partially evaluated: (orient == Qt::Horizontal) no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
805 | : q->filterAcceptsColumn(ortho_item, source_parent)) { executed (the execution status of this line is deduced): : q->filterAcceptsColumn(ortho_item, source_parent)) { | - |
806 | orthogonal_proxy_to_source.append(ortho_item); executed (the execution status of this line is deduced): orthogonal_proxy_to_source.append(ortho_item); | - |
807 | } executed: } Execution Count:11 | 11 |
808 | } executed: } Execution Count:12 | 12 |
809 | if (orient == Qt::Horizontal) { partially evaluated: orient == Qt::Horizontal no Evaluation Count:0 | yes Evaluation Count:843 |
| 0-843 |
810 | // We're reacting to columnsInserted, but we've just inserted new rows. Sort them. | - |
811 | sort_source_rows(orthogonal_proxy_to_source, source_parent); never executed (the execution status of this line is deduced): sort_source_rows(orthogonal_proxy_to_source, source_parent); | - |
812 | } | 0 |
813 | build_source_to_proxy_mapping(orthogonal_proxy_to_source, orthogonal_source_to_proxy); executed (the execution status of this line is deduced): build_source_to_proxy_mapping(orthogonal_proxy_to_source, orthogonal_source_to_proxy); | - |
814 | } executed: } Execution Count:843 | 843 |
815 | } executed: } Execution Count:1765 | 1765 |
816 | | - |
817 | // Sort and insert the items | - |
818 | if (orient == Qt::Vertical) // Only sort rows evaluated: orient == Qt::Vertical yes Evaluation Count:1126 | yes Evaluation Count:1132 |
| 1126-1132 |
819 | sort_source_rows(source_items, source_parent); executed: sort_source_rows(source_items, source_parent); Execution Count:1126 | 1126 |
820 | insert_source_items(source_to_proxy, proxy_to_source, source_items, source_parent, orient); executed (the execution status of this line is deduced): insert_source_items(source_to_proxy, proxy_to_source, source_items, source_parent, orient); | - |
821 | } executed: } Execution Count:2258 | 2258 |
822 | | - |
823 | /*! | - |
824 | \internal | - |
825 | | - |
826 | Handles source model items removal | - |
827 | (columnsAboutToBeRemoved(), rowsAboutToBeRemoved()). | - |
828 | */ | - |
829 | void QSortFilterProxyModelPrivate::source_items_about_to_be_removed( | - |
830 | const QModelIndex &source_parent, int start, int end, Qt::Orientation orient) | - |
831 | { | - |
832 | if ((start < 0) || (end < 0)) partially evaluated: (start < 0) no Evaluation Count:0 | yes Evaluation Count:80 |
partially evaluated: (end < 0) no Evaluation Count:0 | yes Evaluation Count:80 |
| 0-80 |
833 | return; | 0 |
834 | IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); | - |
835 | if (it == source_index_mapping.constEnd()) { evaluated: it == source_index_mapping.constEnd() yes Evaluation Count:2 | yes Evaluation Count:78 |
| 2-78 |
836 | // Don't care, since we don't have mapping for this index | - |
837 | return; executed: return; Execution Count:2 | 2 |
838 | } | - |
839 | | - |
840 | Mapping *m = it.value(); executed (the execution status of this line is deduced): Mapping *m = it.value(); | - |
841 | QVector<int> &source_to_proxy = (orient == Qt::Vertical) ? m->proxy_rows : m->proxy_columns; evaluated: (orient == Qt::Vertical) yes Evaluation Count:43 | yes Evaluation Count:35 |
| 35-43 |
842 | QVector<int> &proxy_to_source = (orient == Qt::Vertical) ? m->source_rows : m->source_columns; evaluated: (orient == Qt::Vertical) yes Evaluation Count:43 | yes Evaluation Count:35 |
| 35-43 |
843 | | - |
844 | // figure out which items to remove | - |
845 | QVector<int> source_items_to_remove; executed (the execution status of this line is deduced): QVector<int> source_items_to_remove; | - |
846 | int proxy_count = proxy_to_source.size(); executed (the execution status of this line is deduced): int proxy_count = proxy_to_source.size(); | - |
847 | for (int proxy_item = 0; proxy_item < proxy_count; ++proxy_item) { evaluated: proxy_item < proxy_count yes Evaluation Count:2053 | yes Evaluation Count:78 |
| 78-2053 |
848 | int source_item = proxy_to_source.at(proxy_item); executed (the execution status of this line is deduced): int source_item = proxy_to_source.at(proxy_item); | - |
849 | if ((source_item >= start) && (source_item <= end)) evaluated: (source_item >= start) yes Evaluation Count:1446 | yes Evaluation Count:607 |
evaluated: (source_item <= end) yes Evaluation Count:515 | yes Evaluation Count:931 |
| 515-1446 |
850 | source_items_to_remove.append(source_item); executed: source_items_to_remove.append(source_item); Execution Count:515 | 515 |
851 | } executed: } Execution Count:2053 | 2053 |
852 | | - |
853 | remove_source_items(source_to_proxy, proxy_to_source, source_items_to_remove, executed (the execution status of this line is deduced): remove_source_items(source_to_proxy, proxy_to_source, source_items_to_remove, | - |
854 | source_parent, orient); executed (the execution status of this line is deduced): source_parent, orient); | - |
855 | } executed: } Execution Count:78 | 78 |
856 | | - |
857 | /*! | - |
858 | \internal | - |
859 | | - |
860 | Handles source model items removal (columnsRemoved(), rowsRemoved()). | - |
861 | */ | - |
862 | void QSortFilterProxyModelPrivate::source_items_removed( | - |
863 | const QModelIndex &source_parent, int start, int end, Qt::Orientation orient) | - |
864 | { | - |
865 | if ((start < 0) || (end < 0)) partially evaluated: (start < 0) no Evaluation Count:0 | yes Evaluation Count:80 |
partially evaluated: (end < 0) no Evaluation Count:0 | yes Evaluation Count:80 |
| 0-80 |
866 | return; | 0 |
867 | IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); | - |
868 | if (it == source_index_mapping.constEnd()) { evaluated: it == source_index_mapping.constEnd() yes Evaluation Count:2 | yes Evaluation Count:78 |
| 2-78 |
869 | // Don't care, since we don't have mapping for this index | - |
870 | return; executed: return; Execution Count:2 | 2 |
871 | } | - |
872 | | - |
873 | Mapping *m = it.value(); executed (the execution status of this line is deduced): Mapping *m = it.value(); | - |
874 | QVector<int> &source_to_proxy = (orient == Qt::Vertical) ? m->proxy_rows : m->proxy_columns; evaluated: (orient == Qt::Vertical) yes Evaluation Count:43 | yes Evaluation Count:35 |
| 35-43 |
875 | QVector<int> &proxy_to_source = (orient == Qt::Vertical) ? m->source_rows : m->source_columns; evaluated: (orient == Qt::Vertical) yes Evaluation Count:43 | yes Evaluation Count:35 |
| 35-43 |
876 | | - |
877 | if (end >= source_to_proxy.size()) partially evaluated: end >= source_to_proxy.size() no Evaluation Count:0 | yes Evaluation Count:78 |
| 0-78 |
878 | end = source_to_proxy.size() - 1; never executed: end = source_to_proxy.size() - 1; | 0 |
879 | | - |
880 | // Shrink the source-to-proxy mapping to reflect the new item count | - |
881 | int delta_item_count = end - start + 1; executed (the execution status of this line is deduced): int delta_item_count = end - start + 1; | - |
882 | source_to_proxy.remove(start, delta_item_count); executed (the execution status of this line is deduced): source_to_proxy.remove(start, delta_item_count); | - |
883 | | - |
884 | int proxy_count = proxy_to_source.size(); executed (the execution status of this line is deduced): int proxy_count = proxy_to_source.size(); | - |
885 | if (proxy_count > source_to_proxy.size()) { partially evaluated: proxy_count > source_to_proxy.size() no Evaluation Count:0 | yes Evaluation Count:78 |
| 0-78 |
886 | // mapping is in an inconsistent state -- redo the whole mapping | - |
887 | qWarning("QSortFilterProxyModel: inconsistent changes reported by source model"); never executed (the execution status of this line is deduced): QMessageLogger("itemmodels/qsortfilterproxymodel.cpp", 887, __PRETTY_FUNCTION__).warning("QSortFilterProxyModel: inconsistent changes reported by source model"); | - |
888 | Q_Q(QSortFilterProxyModel); never executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
889 | q->beginResetModel(); never executed (the execution status of this line is deduced): q->beginResetModel(); | - |
890 | remove_from_mapping(source_parent); never executed (the execution status of this line is deduced): remove_from_mapping(source_parent); | - |
891 | q->endResetModel(); never executed (the execution status of this line is deduced): q->endResetModel(); | - |
892 | return; | 0 |
893 | } | - |
894 | | - |
895 | // Adjust "stale" indexes in proxy-to-source mapping | - |
896 | for (int proxy_item = 0; proxy_item < proxy_count; ++proxy_item) { evaluated: proxy_item < proxy_count yes Evaluation Count:1538 | yes Evaluation Count:78 |
| 78-1538 |
897 | int source_item = proxy_to_source.at(proxy_item); executed (the execution status of this line is deduced): int source_item = proxy_to_source.at(proxy_item); | - |
898 | if (source_item >= start) { evaluated: source_item >= start yes Evaluation Count:931 | yes Evaluation Count:607 |
| 607-931 |
899 | Q_ASSERT(source_item - delta_item_count >= 0); executed (the execution status of this line is deduced): qt_noop(); | - |
900 | proxy_to_source.replace(proxy_item, source_item - delta_item_count); executed (the execution status of this line is deduced): proxy_to_source.replace(proxy_item, source_item - delta_item_count); | - |
901 | } executed: } Execution Count:931 | 931 |
902 | } executed: } Execution Count:1538 | 1538 |
903 | build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); executed (the execution status of this line is deduced): build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); | - |
904 | | - |
905 | updateChildrenMapping(source_parent, m, orient, start, end, delta_item_count, true); executed (the execution status of this line is deduced): updateChildrenMapping(source_parent, m, orient, start, end, delta_item_count, true); | - |
906 | | - |
907 | } executed: } Execution Count:78 | 78 |
908 | | - |
909 | | - |
910 | /*! | - |
911 | \internal | - |
912 | updates the mapping of the children when inserting or removing items | - |
913 | */ | - |
914 | void QSortFilterProxyModelPrivate::updateChildrenMapping(const QModelIndex &source_parent, Mapping *parent_mapping, | - |
915 | Qt::Orientation orient, int start, int end, int delta_item_count, bool remove) | - |
916 | { | - |
917 | // see if any mapped children should be (re)moved | - |
918 | QVector<QPair<QModelIndex, Mapping*> > moved_source_index_mappings; executed (the execution status of this line is deduced): QVector<QPair<QModelIndex, Mapping*> > moved_source_index_mappings; | - |
919 | QVector<QModelIndex>::iterator it2 = parent_mapping->mapped_children.begin(); executed (the execution status of this line is deduced): QVector<QModelIndex>::iterator it2 = parent_mapping->mapped_children.begin(); | - |
920 | for ( ; it2 != parent_mapping->mapped_children.end();) { evaluated: it2 != parent_mapping->mapped_children.end() yes Evaluation Count:330 | yes Evaluation Count:2336 |
| 330-2336 |
921 | const QModelIndex source_child_index = *it2; executed (the execution status of this line is deduced): const QModelIndex source_child_index = *it2; | - |
922 | const int pos = (orient == Qt::Vertical) evaluated: (orient == Qt::Vertical) yes Evaluation Count:179 | yes Evaluation Count:151 |
| 151-179 |
923 | ? source_child_index.row() executed (the execution status of this line is deduced): ? source_child_index.row() | - |
924 | : source_child_index.column(); executed (the execution status of this line is deduced): : source_child_index.column(); | - |
925 | if (pos < start) { evaluated: pos < start yes Evaluation Count:80 | yes Evaluation Count:250 |
| 80-250 |
926 | // not affected | - |
927 | ++it2; executed (the execution status of this line is deduced): ++it2; | - |
928 | } else if (remove && pos <= end) { executed: } Execution Count:80 evaluated: remove yes Evaluation Count:30 | yes Evaluation Count:220 |
evaluated: pos <= end yes Evaluation Count:14 | yes Evaluation Count:16 |
| 14-220 |
929 | // in the removed interval | - |
930 | it2 = parent_mapping->mapped_children.erase(it2); executed (the execution status of this line is deduced): it2 = parent_mapping->mapped_children.erase(it2); | - |
931 | remove_from_mapping(source_child_index); executed (the execution status of this line is deduced): remove_from_mapping(source_child_index); | - |
932 | } else { executed: } Execution Count:14 | 14 |
933 | // below the removed items -- recompute the index | - |
934 | QModelIndex new_index; executed (the execution status of this line is deduced): QModelIndex new_index; | - |
935 | const int newpos = remove ? pos - delta_item_count : pos + delta_item_count; evaluated: remove yes Evaluation Count:16 | yes Evaluation Count:220 |
| 16-220 |
936 | if (orient == Qt::Vertical) { evaluated: orient == Qt::Vertical yes Evaluation Count:121 | yes Evaluation Count:115 |
| 115-121 |
937 | new_index = model->index(newpos, executed (the execution status of this line is deduced): new_index = model->index(newpos, | - |
938 | source_child_index.column(), executed (the execution status of this line is deduced): source_child_index.column(), | - |
939 | source_parent); executed (the execution status of this line is deduced): source_parent); | - |
940 | } else { executed: } Execution Count:121 | 121 |
941 | new_index = model->index(source_child_index.row(), executed (the execution status of this line is deduced): new_index = model->index(source_child_index.row(), | - |
942 | newpos, executed (the execution status of this line is deduced): newpos, | - |
943 | source_parent); executed (the execution status of this line is deduced): source_parent); | - |
944 | } executed: } Execution Count:115 | 115 |
945 | *it2 = new_index; executed (the execution status of this line is deduced): *it2 = new_index; | - |
946 | ++it2; executed (the execution status of this line is deduced): ++it2; | - |
947 | | - |
948 | // update mapping | - |
949 | Mapping *cm = source_index_mapping.take(source_child_index); executed (the execution status of this line is deduced): Mapping *cm = source_index_mapping.take(source_child_index); | - |
950 | Q_ASSERT(cm); executed (the execution status of this line is deduced): qt_noop(); | - |
951 | // we do not reinsert right away, because the new index might be identical with another, old index | - |
952 | moved_source_index_mappings.append(QPair<QModelIndex, Mapping*>(new_index, cm)); executed (the execution status of this line is deduced): moved_source_index_mappings.append(QPair<QModelIndex, Mapping*>(new_index, cm)); | - |
953 | } executed: } Execution Count:236 | 236 |
954 | } | - |
955 | | - |
956 | // reinsert moved, mapped indexes | - |
957 | QVector<QPair<QModelIndex, Mapping*> >::iterator it = moved_source_index_mappings.begin(); executed (the execution status of this line is deduced): QVector<QPair<QModelIndex, Mapping*> >::iterator it = moved_source_index_mappings.begin(); | - |
958 | for (; it != moved_source_index_mappings.end(); ++it) { evaluated: it != moved_source_index_mappings.end() yes Evaluation Count:236 | yes Evaluation Count:2336 |
| 236-2336 |
959 | #ifdef QT_STRICT_ITERATORS | - |
960 | source_index_mapping.insert((*it).first, (*it).second); | - |
961 | (*it).second->map_iter = source_index_mapping.constFind((*it).first); | - |
962 | #else | - |
963 | (*it).second->map_iter = source_index_mapping.insert((*it).first, (*it).second); executed (the execution status of this line is deduced): (*it).second->map_iter = source_index_mapping.insert((*it).first, (*it).second); | - |
964 | #endif | - |
965 | } executed: } Execution Count:236 | 236 |
966 | } executed: } Execution Count:2336 | 2336 |
967 | | - |
968 | /*! | - |
969 | \internal | - |
970 | */ | - |
971 | void QSortFilterProxyModelPrivate::proxy_item_range( | - |
972 | const QVector<int> &source_to_proxy, const QVector<int> &source_items, | - |
973 | int &proxy_low, int &proxy_high) const | - |
974 | { | - |
975 | proxy_low = INT_MAX; executed (the execution status of this line is deduced): proxy_low = 2147483647; | - |
976 | proxy_high = INT_MIN; executed (the execution status of this line is deduced): proxy_high = (-2147483647 - 1); | - |
977 | for (int i = 0; i < source_items.count(); ++i) { evaluated: i < source_items.count() yes Evaluation Count:6544 | yes Evaluation Count:6544 |
| 6544 |
978 | int proxy_item = source_to_proxy.at(source_items.at(i)); executed (the execution status of this line is deduced): int proxy_item = source_to_proxy.at(source_items.at(i)); | - |
979 | Q_ASSERT(proxy_item != -1); executed (the execution status of this line is deduced): qt_noop(); | - |
980 | if (proxy_item < proxy_low) partially evaluated: proxy_item < proxy_low yes Evaluation Count:6544 | no Evaluation Count:0 |
| 0-6544 |
981 | proxy_low = proxy_item; executed: proxy_low = proxy_item; Execution Count:6544 | 6544 |
982 | if (proxy_item > proxy_high) partially evaluated: proxy_item > proxy_high yes Evaluation Count:6544 | no Evaluation Count:0 |
| 0-6544 |
983 | proxy_high = proxy_item; executed: proxy_high = proxy_item; Execution Count:6544 | 6544 |
984 | } executed: } Execution Count:6544 | 6544 |
985 | } executed: } Execution Count:6544 | 6544 |
986 | | - |
987 | /*! | - |
988 | \internal | - |
989 | */ | - |
990 | void QSortFilterProxyModelPrivate::build_source_to_proxy_mapping( | - |
991 | const QVector<int> &proxy_to_source, QVector<int> &source_to_proxy) const | - |
992 | { | - |
993 | source_to_proxy.fill(-1); executed (the execution status of this line is deduced): source_to_proxy.fill(-1); | - |
994 | int proxy_count = proxy_to_source.size(); executed (the execution status of this line is deduced): int proxy_count = proxy_to_source.size(); | - |
995 | for (int i = 0; i < proxy_count; ++i) evaluated: i < proxy_count yes Evaluation Count:109994 | yes Evaluation Count:6178 |
| 6178-109994 |
996 | source_to_proxy[proxy_to_source.at(i)] = i; executed: source_to_proxy[proxy_to_source.at(i)] = i; Execution Count:109994 | 109994 |
997 | } executed: } Execution Count:6178 | 6178 |
998 | | - |
999 | /*! | - |
1000 | \internal | - |
1001 | | - |
1002 | Maps the persistent proxy indexes to source indexes and | - |
1003 | returns the list of source indexes. | - |
1004 | */ | - |
1005 | QModelIndexPairList QSortFilterProxyModelPrivate::store_persistent_indexes() | - |
1006 | { | - |
1007 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1008 | QModelIndexPairList source_indexes; executed (the execution status of this line is deduced): QModelIndexPairList source_indexes; | - |
1009 | foreach (QPersistentModelIndexData *data, persistent.indexes) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(persistent.indexes)> _container_(persistent.indexes); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QPersistentModelIndexData *data = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
1010 | QModelIndex proxy_index = data->index; executed (the execution status of this line is deduced): QModelIndex proxy_index = data->index; | - |
1011 | QModelIndex source_index = q->mapToSource(proxy_index); executed (the execution status of this line is deduced): QModelIndex source_index = q->mapToSource(proxy_index); | - |
1012 | source_indexes.append(qMakePair(proxy_index, QPersistentModelIndex(source_index))); executed (the execution status of this line is deduced): source_indexes.append(qMakePair(proxy_index, QPersistentModelIndex(source_index))); | - |
1013 | } executed: } Execution Count:373 | 373 |
1014 | return source_indexes; executed: return source_indexes; Execution Count:1024 | 1024 |
1015 | } | - |
1016 | | - |
1017 | /*! | - |
1018 | \internal | - |
1019 | | - |
1020 | Maps \a source_indexes to proxy indexes and stores those | - |
1021 | as persistent indexes. | - |
1022 | */ | - |
1023 | void QSortFilterProxyModelPrivate::update_persistent_indexes( | - |
1024 | const QModelIndexPairList &source_indexes) | - |
1025 | { | - |
1026 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1027 | QModelIndexList from, to; executed (the execution status of this line is deduced): QModelIndexList from, to; | - |
1028 | for (int i = 0; i < source_indexes.count(); ++i) { evaluated: i < source_indexes.count() yes Evaluation Count:373 | yes Evaluation Count:1026 |
| 373-1026 |
1029 | QModelIndex source_index = source_indexes.at(i).second; executed (the execution status of this line is deduced): QModelIndex source_index = source_indexes.at(i).second; | - |
1030 | QModelIndex old_proxy_index = source_indexes.at(i).first; executed (the execution status of this line is deduced): QModelIndex old_proxy_index = source_indexes.at(i).first; | - |
1031 | create_mapping(source_index.parent()); executed (the execution status of this line is deduced): create_mapping(source_index.parent()); | - |
1032 | QModelIndex proxy_index = q->mapFromSource(source_index); executed (the execution status of this line is deduced): QModelIndex proxy_index = q->mapFromSource(source_index); | - |
1033 | from << old_proxy_index; executed (the execution status of this line is deduced): from << old_proxy_index; | - |
1034 | to << proxy_index; executed (the execution status of this line is deduced): to << proxy_index; | - |
1035 | } executed: } Execution Count:373 | 373 |
1036 | q->changePersistentIndexList(from, to); executed (the execution status of this line is deduced): q->changePersistentIndexList(from, to); | - |
1037 | } executed: } Execution Count:1026 | 1026 |
1038 | | - |
1039 | | - |
1040 | /*! | - |
1041 | \internal | - |
1042 | | - |
1043 | Updates the proxy model (adds/removes rows) based on the | - |
1044 | new filter. | - |
1045 | */ | - |
1046 | void QSortFilterProxyModelPrivate::filter_changed(const QModelIndex &source_parent) | - |
1047 | { | - |
1048 | IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); | - |
1049 | if (it == source_index_mapping.constEnd()) evaluated: it == source_index_mapping.constEnd() yes Evaluation Count:11 | yes Evaluation Count:376 |
| 11-376 |
1050 | return; executed: return; Execution Count:11 | 11 |
1051 | Mapping *m = it.value(); executed (the execution status of this line is deduced): Mapping *m = it.value(); | - |
1052 | QSet<int> rows_removed = handle_filter_changed(m->proxy_rows, m->source_rows, source_parent, Qt::Vertical); executed (the execution status of this line is deduced): QSet<int> rows_removed = handle_filter_changed(m->proxy_rows, m->source_rows, source_parent, Qt::Vertical); | - |
1053 | QSet<int> columns_removed = handle_filter_changed(m->proxy_columns, m->source_columns, source_parent, Qt::Horizontal); executed (the execution status of this line is deduced): QSet<int> columns_removed = handle_filter_changed(m->proxy_columns, m->source_columns, source_parent, Qt::Horizontal); | - |
1054 | | - |
1055 | // We need to iterate over a copy of m->mapped_children because otherwise it may be changed by other code, invalidating | - |
1056 | // the iterator it2. | - |
1057 | // The m->mapped_children vector can be appended to with indexes which are no longer filtered | - |
1058 | // out (in create_mapping) when this function recurses for child indexes. | - |
1059 | const QVector<QModelIndex> mappedChildren = m->mapped_children; executed (the execution status of this line is deduced): const QVector<QModelIndex> mappedChildren = m->mapped_children; | - |
1060 | QVector<int> indexesToRemove; executed (the execution status of this line is deduced): QVector<int> indexesToRemove; | - |
1061 | for (int i = 0; i < mappedChildren.size(); ++i) { evaluated: i < mappedChildren.size() yes Evaluation Count:178 | yes Evaluation Count:376 |
| 178-376 |
1062 | const QModelIndex source_child_index = mappedChildren.at(i); executed (the execution status of this line is deduced): const QModelIndex source_child_index = mappedChildren.at(i); | - |
1063 | if (rows_removed.contains(source_child_index.row()) || columns_removed.contains(source_child_index.column())) { evaluated: rows_removed.contains(source_child_index.row()) yes Evaluation Count:3 | yes Evaluation Count:175 |
partially evaluated: columns_removed.contains(source_child_index.column()) no Evaluation Count:0 | yes Evaluation Count:175 |
| 0-175 |
1064 | indexesToRemove.push_back(i); executed (the execution status of this line is deduced): indexesToRemove.push_back(i); | - |
1065 | remove_from_mapping(source_child_index); executed (the execution status of this line is deduced): remove_from_mapping(source_child_index); | - |
1066 | } else { executed: } Execution Count:3 | 3 |
1067 | filter_changed(source_child_index); executed (the execution status of this line is deduced): filter_changed(source_child_index); | - |
1068 | } executed: } Execution Count:175 | 175 |
1069 | } | - |
1070 | QVector<int>::const_iterator removeIt = indexesToRemove.constEnd(); executed (the execution status of this line is deduced): QVector<int>::const_iterator removeIt = indexesToRemove.constEnd(); | - |
1071 | const QVector<int>::const_iterator removeBegin = indexesToRemove.constBegin(); executed (the execution status of this line is deduced): const QVector<int>::const_iterator removeBegin = indexesToRemove.constBegin(); | - |
1072 | | - |
1073 | // We can't just remove these items from mappedChildren while iterating above and then | - |
1074 | // do something like m->mapped_children = mappedChildren, because mapped_children might | - |
1075 | // be appended to in create_mapping, and we would lose those new items. | - |
1076 | // Because they are always appended in create_mapping, we can still remove them by | - |
1077 | // position here. | - |
1078 | while (removeIt != removeBegin) { evaluated: removeIt != removeBegin yes Evaluation Count:3 | yes Evaluation Count:376 |
| 3-376 |
1079 | --removeIt; executed (the execution status of this line is deduced): --removeIt; | - |
1080 | m->mapped_children.remove(*removeIt); executed (the execution status of this line is deduced): m->mapped_children.remove(*removeIt); | - |
1081 | } executed: } Execution Count:3 | 3 |
1082 | } executed: } Execution Count:376 | 376 |
1083 | | - |
1084 | /*! | - |
1085 | \internal | - |
1086 | returns the removed items indexes | - |
1087 | */ | - |
1088 | QSet<int> QSortFilterProxyModelPrivate::handle_filter_changed( | - |
1089 | QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, | - |
1090 | const QModelIndex &source_parent, Qt::Orientation orient) | - |
1091 | { | - |
1092 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1093 | // Figure out which mapped items to remove | - |
1094 | QVector<int> source_items_remove; executed (the execution status of this line is deduced): QVector<int> source_items_remove; | - |
1095 | for (int i = 0; i < proxy_to_source.count(); ++i) { evaluated: i < proxy_to_source.count() yes Evaluation Count:21712 | yes Evaluation Count:752 |
| 752-21712 |
1096 | const int source_item = proxy_to_source.at(i); executed (the execution status of this line is deduced): const int source_item = proxy_to_source.at(i); | - |
1097 | if ((orient == Qt::Vertical) evaluated: (orient == Qt::Vertical) yes Evaluation Count:15904 | yes Evaluation Count:5808 |
| 5808-15904 |
1098 | ? !q->filterAcceptsRow(source_item, source_parent) executed (the execution status of this line is deduced): ? !q->filterAcceptsRow(source_item, source_parent) | - |
1099 | : !q->filterAcceptsColumn(source_item, source_parent)) { executed (the execution status of this line is deduced): : !q->filterAcceptsColumn(source_item, source_parent)) { | - |
1100 | // This source item does not satisfy the filter, so it must be removed | - |
1101 | source_items_remove.append(source_item); executed (the execution status of this line is deduced): source_items_remove.append(source_item); | - |
1102 | } executed: } Execution Count:82 | 82 |
1103 | } executed: } Execution Count:21712 | 21712 |
1104 | // Figure out which non-mapped items to insert | - |
1105 | QVector<int> source_items_insert; executed (the execution status of this line is deduced): QVector<int> source_items_insert; | - |
1106 | int source_count = source_to_proxy.size(); executed (the execution status of this line is deduced): int source_count = source_to_proxy.size(); | - |
1107 | for (int source_item = 0; source_item < source_count; ++source_item) { evaluated: source_item < source_count yes Evaluation Count:21761 | yes Evaluation Count:752 |
| 752-21761 |
1108 | if (source_to_proxy.at(source_item) == -1) { evaluated: source_to_proxy.at(source_item) == -1 yes Evaluation Count:49 | yes Evaluation Count:21712 |
| 49-21712 |
1109 | if ((orient == Qt::Vertical) partially evaluated: (orient == Qt::Vertical) yes Evaluation Count:49 | no Evaluation Count:0 |
| 0-49 |
1110 | ? q->filterAcceptsRow(source_item, source_parent) executed (the execution status of this line is deduced): ? q->filterAcceptsRow(source_item, source_parent) | - |
1111 | : q->filterAcceptsColumn(source_item, source_parent)) { executed (the execution status of this line is deduced): : q->filterAcceptsColumn(source_item, source_parent)) { | - |
1112 | // This source item satisfies the filter, so it must be added | - |
1113 | source_items_insert.append(source_item); executed (the execution status of this line is deduced): source_items_insert.append(source_item); | - |
1114 | } executed: } Execution Count:34 | 34 |
1115 | } executed: } Execution Count:49 | 49 |
1116 | } executed: } Execution Count:21761 | 21761 |
1117 | if (!source_items_remove.isEmpty() || !source_items_insert.isEmpty()) { evaluated: !source_items_remove.isEmpty() yes Evaluation Count:35 | yes Evaluation Count:717 |
evaluated: !source_items_insert.isEmpty() yes Evaluation Count:10 | yes Evaluation Count:707 |
| 10-717 |
1118 | // Do item removal and insertion | - |
1119 | remove_source_items(source_to_proxy, proxy_to_source, executed (the execution status of this line is deduced): remove_source_items(source_to_proxy, proxy_to_source, | - |
1120 | source_items_remove, source_parent, orient); executed (the execution status of this line is deduced): source_items_remove, source_parent, orient); | - |
1121 | if (orient == Qt::Vertical) partially evaluated: orient == Qt::Vertical yes Evaluation Count:45 | no Evaluation Count:0 |
| 0-45 |
1122 | sort_source_rows(source_items_insert, source_parent); executed: sort_source_rows(source_items_insert, source_parent); Execution Count:45 | 45 |
1123 | insert_source_items(source_to_proxy, proxy_to_source, executed (the execution status of this line is deduced): insert_source_items(source_to_proxy, proxy_to_source, | - |
1124 | source_items_insert, source_parent, orient); executed (the execution status of this line is deduced): source_items_insert, source_parent, orient); | - |
1125 | } executed: } Execution Count:45 | 45 |
1126 | return qVectorToSet(source_items_remove); executed: return qVectorToSet(source_items_remove); Execution Count:752 | 752 |
1127 | } | - |
1128 | | - |
1129 | void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &source_top_left, | - |
1130 | const QModelIndex &source_bottom_right) | - |
1131 | { | - |
1132 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1133 | if (!source_top_left.isValid() || !source_bottom_right.isValid()) partially evaluated: !source_top_left.isValid() no Evaluation Count:0 | yes Evaluation Count:6854 |
partially evaluated: !source_bottom_right.isValid() no Evaluation Count:0 | yes Evaluation Count:6854 |
| 0-6854 |
1134 | return; | 0 |
1135 | QModelIndex source_parent = source_top_left.parent(); executed (the execution status of this line is deduced): QModelIndex source_parent = source_top_left.parent(); | - |
1136 | IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); | - |
1137 | if (it == source_index_mapping.constEnd()) { evaluated: it == source_index_mapping.constEnd() yes Evaluation Count:5 | yes Evaluation Count:6849 |
| 5-6849 |
1138 | // Don't care, since we don't have mapping for this index | - |
1139 | return; executed: return; Execution Count:5 | 5 |
1140 | } | - |
1141 | Mapping *m = it.value(); executed (the execution status of this line is deduced): Mapping *m = it.value(); | - |
1142 | | - |
1143 | // Figure out how the source changes affect us | - |
1144 | QVector<int> source_rows_remove; executed (the execution status of this line is deduced): QVector<int> source_rows_remove; | - |
1145 | QVector<int> source_rows_insert; executed (the execution status of this line is deduced): QVector<int> source_rows_insert; | - |
1146 | QVector<int> source_rows_change; executed (the execution status of this line is deduced): QVector<int> source_rows_change; | - |
1147 | QVector<int> source_rows_resort; executed (the execution status of this line is deduced): QVector<int> source_rows_resort; | - |
1148 | int end = qMin(source_bottom_right.row(), m->proxy_rows.count() - 1); executed (the execution status of this line is deduced): int end = qMin(source_bottom_right.row(), m->proxy_rows.count() - 1); | - |
1149 | for (int source_row = source_top_left.row(); source_row <= end; ++source_row) { evaluated: source_row <= end yes Evaluation Count:6849 | yes Evaluation Count:6849 |
| 6849 |
1150 | if (dynamic_sortfilter) { evaluated: dynamic_sortfilter yes Evaluation Count:6842 | yes Evaluation Count:7 |
| 7-6842 |
1151 | if (m->proxy_rows.at(source_row) != -1) { evaluated: m->proxy_rows.at(source_row) != -1 yes Evaluation Count:6538 | yes Evaluation Count:304 |
| 304-6538 |
1152 | if (!q->filterAcceptsRow(source_row, source_parent)) { evaluated: !q->filterAcceptsRow(source_row, source_parent) yes Evaluation Count:1 | yes Evaluation Count:6537 |
| 1-6537 |
1153 | // This source row no longer satisfies the filter, so it must be removed | - |
1154 | source_rows_remove.append(source_row); executed (the execution status of this line is deduced): source_rows_remove.append(source_row); | - |
1155 | } else if (source_sort_column >= source_top_left.column() && source_sort_column <= source_bottom_right.column()) { executed: } Execution Count:1 evaluated: source_sort_column >= source_top_left.column() yes Evaluation Count:5 | yes Evaluation Count:6532 |
partially evaluated: source_sort_column <= source_bottom_right.column() yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-6532 |
1156 | // This source row has changed in a way that may affect sorted order | - |
1157 | source_rows_resort.append(source_row); executed (the execution status of this line is deduced): source_rows_resort.append(source_row); | - |
1158 | } else { executed: } Execution Count:5 | 5 |
1159 | // This row has simply changed, without affecting filtering nor sorting | - |
1160 | source_rows_change.append(source_row); executed (the execution status of this line is deduced): source_rows_change.append(source_row); | - |
1161 | } executed: } Execution Count:6532 | 6532 |
1162 | } else { | - |
1163 | if (!itemsBeingRemoved.contains(source_parent, source_row) && q->filterAcceptsRow(source_row, source_parent)) { partially evaluated: !itemsBeingRemoved.contains(source_parent, source_row) yes Evaluation Count:304 | no Evaluation Count:0 |
evaluated: q->filterAcceptsRow(source_row, source_parent) yes Evaluation Count:3 | yes Evaluation Count:301 |
| 0-304 |
1164 | // This source row now satisfies the filter, so it must be added | - |
1165 | source_rows_insert.append(source_row); executed (the execution status of this line is deduced): source_rows_insert.append(source_row); | - |
1166 | } executed: } Execution Count:3 | 3 |
1167 | } executed: } Execution Count:304 | 304 |
1168 | } else { | - |
1169 | if (m->proxy_rows.at(source_row) != -1) partially evaluated: m->proxy_rows.at(source_row) != -1 yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
1170 | source_rows_change.append(source_row); executed: source_rows_change.append(source_row); Execution Count:7 | 7 |
1171 | } executed: } Execution Count:7 | 7 |
1172 | } | - |
1173 | | - |
1174 | if (!source_rows_remove.isEmpty()) { evaluated: !source_rows_remove.isEmpty() yes Evaluation Count:1 | yes Evaluation Count:6848 |
| 1-6848 |
1175 | remove_source_items(m->proxy_rows, m->source_rows, executed (the execution status of this line is deduced): remove_source_items(m->proxy_rows, m->source_rows, | - |
1176 | source_rows_remove, source_parent, Qt::Vertical); executed (the execution status of this line is deduced): source_rows_remove, source_parent, Qt::Vertical); | - |
1177 | QSet<int> source_rows_remove_set = qVectorToSet(source_rows_remove); executed (the execution status of this line is deduced): QSet<int> source_rows_remove_set = qVectorToSet(source_rows_remove); | - |
1178 | QVector<QModelIndex>::iterator childIt = m->mapped_children.end(); executed (the execution status of this line is deduced): QVector<QModelIndex>::iterator childIt = m->mapped_children.end(); | - |
1179 | while (childIt != m->mapped_children.begin()) { evaluated: childIt != m->mapped_children.begin() yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1180 | --childIt; executed (the execution status of this line is deduced): --childIt; | - |
1181 | const QModelIndex source_child_index = *childIt; executed (the execution status of this line is deduced): const QModelIndex source_child_index = *childIt; | - |
1182 | if (source_rows_remove_set.contains(source_child_index.row())) { partially evaluated: source_rows_remove_set.contains(source_child_index.row()) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1183 | childIt = m->mapped_children.erase(childIt); executed (the execution status of this line is deduced): childIt = m->mapped_children.erase(childIt); | - |
1184 | remove_from_mapping(source_child_index); executed (the execution status of this line is deduced): remove_from_mapping(source_child_index); | - |
1185 | } executed: } Execution Count:1 | 1 |
1186 | } executed: } Execution Count:1 | 1 |
1187 | } executed: } Execution Count:1 | 1 |
1188 | | - |
1189 | if (!source_rows_resort.isEmpty()) { evaluated: !source_rows_resort.isEmpty() yes Evaluation Count:5 | yes Evaluation Count:6844 |
| 5-6844 |
1190 | // Re-sort the rows of this level | - |
1191 | QList<QPersistentModelIndex> parents; executed (the execution status of this line is deduced): QList<QPersistentModelIndex> parents; | - |
1192 | parents << q->mapFromSource(source_parent); executed (the execution status of this line is deduced): parents << q->mapFromSource(source_parent); | - |
1193 | emit q->layoutAboutToBeChanged(parents, QAbstractItemModel::VerticalSortHint); executed (the execution status of this line is deduced): q->layoutAboutToBeChanged(parents, QAbstractItemModel::VerticalSortHint); | - |
1194 | QModelIndexPairList source_indexes = store_persistent_indexes(); executed (the execution status of this line is deduced): QModelIndexPairList source_indexes = store_persistent_indexes(); | - |
1195 | remove_source_items(m->proxy_rows, m->source_rows, source_rows_resort, executed (the execution status of this line is deduced): remove_source_items(m->proxy_rows, m->source_rows, source_rows_resort, | - |
1196 | source_parent, Qt::Vertical, false); executed (the execution status of this line is deduced): source_parent, Qt::Vertical, false); | - |
1197 | sort_source_rows(source_rows_resort, source_parent); executed (the execution status of this line is deduced): sort_source_rows(source_rows_resort, source_parent); | - |
1198 | insert_source_items(m->proxy_rows, m->source_rows, source_rows_resort, executed (the execution status of this line is deduced): insert_source_items(m->proxy_rows, m->source_rows, source_rows_resort, | - |
1199 | source_parent, Qt::Vertical, false); executed (the execution status of this line is deduced): source_parent, Qt::Vertical, false); | - |
1200 | update_persistent_indexes(source_indexes); executed (the execution status of this line is deduced): update_persistent_indexes(source_indexes); | - |
1201 | emit q->layoutChanged(parents, QAbstractItemModel::VerticalSortHint); executed (the execution status of this line is deduced): q->layoutChanged(parents, QAbstractItemModel::VerticalSortHint); | - |
1202 | // Make sure we also emit dataChanged for the rows | - |
1203 | source_rows_change += source_rows_resort; executed (the execution status of this line is deduced): source_rows_change += source_rows_resort; | - |
1204 | } executed: } Execution Count:5 | 5 |
1205 | | - |
1206 | if (!source_rows_change.isEmpty()) { evaluated: !source_rows_change.isEmpty() yes Evaluation Count:6544 | yes Evaluation Count:305 |
| 305-6544 |
1207 | // Find the proxy row range | - |
1208 | int proxy_start_row; executed (the execution status of this line is deduced): int proxy_start_row; | - |
1209 | int proxy_end_row; executed (the execution status of this line is deduced): int proxy_end_row; | - |
1210 | proxy_item_range(m->proxy_rows, source_rows_change, executed (the execution status of this line is deduced): proxy_item_range(m->proxy_rows, source_rows_change, | - |
1211 | proxy_start_row, proxy_end_row); executed (the execution status of this line is deduced): proxy_start_row, proxy_end_row); | - |
1212 | // ### Find the proxy column range also | - |
1213 | if (proxy_end_row >= 0) { partially evaluated: proxy_end_row >= 0 yes Evaluation Count:6544 | no Evaluation Count:0 |
| 0-6544 |
1214 | // the row was accepted, but some columns might still be filtered out | - |
1215 | int source_left_column = source_top_left.column(); executed (the execution status of this line is deduced): int source_left_column = source_top_left.column(); | - |
1216 | while (source_left_column < source_bottom_right.column() partially evaluated: source_left_column < source_bottom_right.column() no Evaluation Count:0 | yes Evaluation Count:6544 |
| 0-6544 |
1217 | && m->proxy_columns.at(source_left_column) == -1) never evaluated: m->proxy_columns.at(source_left_column) == -1 | 0 |
1218 | ++source_left_column; never executed: ++source_left_column; | 0 |
1219 | const QModelIndex proxy_top_left = create_index( executed (the execution status of this line is deduced): const QModelIndex proxy_top_left = create_index( | - |
1220 | proxy_start_row, m->proxy_columns.at(source_left_column), it); executed (the execution status of this line is deduced): proxy_start_row, m->proxy_columns.at(source_left_column), it); | - |
1221 | int source_right_column = source_bottom_right.column(); executed (the execution status of this line is deduced): int source_right_column = source_bottom_right.column(); | - |
1222 | while (source_right_column > source_top_left.column() partially evaluated: source_right_column > source_top_left.column() no Evaluation Count:0 | yes Evaluation Count:6544 |
| 0-6544 |
1223 | && m->proxy_columns.at(source_right_column) == -1) never evaluated: m->proxy_columns.at(source_right_column) == -1 | 0 |
1224 | --source_right_column; never executed: --source_right_column; | 0 |
1225 | const QModelIndex proxy_bottom_right = create_index( executed (the execution status of this line is deduced): const QModelIndex proxy_bottom_right = create_index( | - |
1226 | proxy_end_row, m->proxy_columns.at(source_right_column), it); executed (the execution status of this line is deduced): proxy_end_row, m->proxy_columns.at(source_right_column), it); | - |
1227 | emit q->dataChanged(proxy_top_left, proxy_bottom_right); executed (the execution status of this line is deduced): q->dataChanged(proxy_top_left, proxy_bottom_right); | - |
1228 | } executed: } Execution Count:6544 | 6544 |
1229 | } executed: } Execution Count:6544 | 6544 |
1230 | | - |
1231 | if (!source_rows_insert.isEmpty()) { evaluated: !source_rows_insert.isEmpty() yes Evaluation Count:3 | yes Evaluation Count:6846 |
| 3-6846 |
1232 | sort_source_rows(source_rows_insert, source_parent); executed (the execution status of this line is deduced): sort_source_rows(source_rows_insert, source_parent); | - |
1233 | insert_source_items(m->proxy_rows, m->source_rows, executed (the execution status of this line is deduced): insert_source_items(m->proxy_rows, m->source_rows, | - |
1234 | source_rows_insert, source_parent, Qt::Vertical); executed (the execution status of this line is deduced): source_rows_insert, source_parent, Qt::Vertical); | - |
1235 | } executed: } Execution Count:3 | 3 |
1236 | } executed: } Execution Count:6849 | 6849 |
1237 | | - |
1238 | void QSortFilterProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation orientation, | - |
1239 | int start, int end) | - |
1240 | { | - |
1241 | Q_ASSERT(start <= end); executed (the execution status of this line is deduced): qt_noop(); | - |
1242 | | - |
1243 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1244 | Mapping *m = create_mapping(QModelIndex()).value(); executed (the execution status of this line is deduced): Mapping *m = create_mapping(QModelIndex()).value(); | - |
1245 | | - |
1246 | const QVector<int> &source_to_proxy = (orientation == Qt::Vertical) ? m->proxy_rows : m->proxy_columns; evaluated: (orientation == Qt::Vertical) yes Evaluation Count:9 | yes Evaluation Count:120 |
| 9-120 |
1247 | | - |
1248 | QVector<int> proxy_positions; executed (the execution status of this line is deduced): QVector<int> proxy_positions; | - |
1249 | proxy_positions.reserve(end - start + 1); executed (the execution status of this line is deduced): proxy_positions.reserve(end - start + 1); | - |
1250 | { | - |
1251 | Q_ASSERT(source_to_proxy.size() > end); executed (the execution status of this line is deduced): qt_noop(); | - |
1252 | QVector<int>::const_iterator it = source_to_proxy.constBegin() + start; executed (the execution status of this line is deduced): QVector<int>::const_iterator it = source_to_proxy.constBegin() + start; | - |
1253 | const QVector<int>::const_iterator endIt = source_to_proxy.constBegin() + end + 1; executed (the execution status of this line is deduced): const QVector<int>::const_iterator endIt = source_to_proxy.constBegin() + end + 1; | - |
1254 | for ( ; it != endIt; ++it) { evaluated: it != endIt yes Evaluation Count:138 | yes Evaluation Count:129 |
| 129-138 |
1255 | if (*it != -1) evaluated: *it != -1 yes Evaluation Count:122 | yes Evaluation Count:16 |
| 16-122 |
1256 | proxy_positions.push_back(*it); executed: proxy_positions.push_back(*it); Execution Count:122 | 122 |
1257 | } executed: } Execution Count:138 | 138 |
1258 | } | - |
1259 | | - |
1260 | std::sort(proxy_positions.begin(), proxy_positions.end()); executed (the execution status of this line is deduced): std::sort(proxy_positions.begin(), proxy_positions.end()); | - |
1261 | | - |
1262 | int last_index = 0; executed (the execution status of this line is deduced): int last_index = 0; | - |
1263 | const int numItems = proxy_positions.size(); executed (the execution status of this line is deduced): const int numItems = proxy_positions.size(); | - |
1264 | while (last_index < numItems) { evaluated: last_index < numItems yes Evaluation Count:113 | yes Evaluation Count:129 |
| 113-129 |
1265 | const int proxyStart = proxy_positions.at(last_index); executed (the execution status of this line is deduced): const int proxyStart = proxy_positions.at(last_index); | - |
1266 | int proxyEnd = proxyStart; executed (the execution status of this line is deduced): int proxyEnd = proxyStart; | - |
1267 | ++last_index; executed (the execution status of this line is deduced): ++last_index; | - |
1268 | for (int i = last_index; i < numItems; ++i) { evaluated: i < numItems yes Evaluation Count:9 | yes Evaluation Count:113 |
| 9-113 |
1269 | if (proxy_positions.at(i) == proxyEnd + 1) { partially evaluated: proxy_positions.at(i) == proxyEnd + 1 yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
1270 | ++last_index; executed (the execution status of this line is deduced): ++last_index; | - |
1271 | ++proxyEnd; executed (the execution status of this line is deduced): ++proxyEnd; | - |
1272 | } else { executed: } Execution Count:9 | 9 |
1273 | break; | 0 |
1274 | } | - |
1275 | } | - |
1276 | emit q->headerDataChanged(orientation, proxyStart, proxyEnd); executed (the execution status of this line is deduced): q->headerDataChanged(orientation, proxyStart, proxyEnd); | - |
1277 | } executed: } Execution Count:113 | 113 |
1278 | } executed: } Execution Count:129 | 129 |
1279 | | - |
1280 | void QSortFilterProxyModelPrivate::_q_sourceAboutToBeReset() | - |
1281 | { | - |
1282 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1283 | q->beginResetModel(); executed (the execution status of this line is deduced): q->beginResetModel(); | - |
1284 | } executed: } Execution Count:112 | 112 |
1285 | | - |
1286 | void QSortFilterProxyModelPrivate::_q_sourceReset() | - |
1287 | { | - |
1288 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1289 | invalidatePersistentIndexes(); executed (the execution status of this line is deduced): invalidatePersistentIndexes(); | - |
1290 | _q_clearMapping(); executed (the execution status of this line is deduced): _q_clearMapping(); | - |
1291 | // All internal structures are deleted in clear() | - |
1292 | q->endResetModel(); executed (the execution status of this line is deduced): q->endResetModel(); | - |
1293 | update_source_sort_column(); executed (the execution status of this line is deduced): update_source_sort_column(); | - |
1294 | if (dynamic_sortfilter) partially evaluated: dynamic_sortfilter yes Evaluation Count:112 | no Evaluation Count:0 |
| 0-112 |
1295 | sort(); executed: sort(); Execution Count:112 | 112 |
1296 | } executed: } Execution Count:112 | 112 |
1297 | | - |
1298 | void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint) | - |
1299 | { | - |
1300 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1301 | saved_persistent_indexes.clear(); executed (the execution status of this line is deduced): saved_persistent_indexes.clear(); | - |
1302 | | - |
1303 | QList<QPersistentModelIndex> parents; executed (the execution status of this line is deduced): QList<QPersistentModelIndex> parents; | - |
1304 | foreach (const QPersistentModelIndex &parent, sourceParents) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sourceParents)> _container_(sourceParents); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QPersistentModelIndex &parent = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
1305 | if (!parent.isValid()) { evaluated: !parent.isValid() yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
1306 | parents << QPersistentModelIndex(); executed (the execution status of this line is deduced): parents << QPersistentModelIndex(); | - |
1307 | continue; executed: continue; Execution Count:1 | 1 |
1308 | } | - |
1309 | const QModelIndex mappedParent = q->mapFromSource(parent); executed (the execution status of this line is deduced): const QModelIndex mappedParent = q->mapFromSource(parent); | - |
1310 | // Might be filtered out. | - |
1311 | if (mappedParent.isValid()) evaluated: mappedParent.isValid() yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
1312 | parents << mappedParent; executed: parents << mappedParent; Execution Count:2 | 2 |
1313 | } executed: } Execution Count:5 | 5 |
1314 | | - |
1315 | // All parents filtered out. | - |
1316 | if (!sourceParents.isEmpty() && parents.isEmpty()) evaluated: !sourceParents.isEmpty() yes Evaluation Count:4 | yes Evaluation Count:1 |
evaluated: parents.isEmpty() yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-4 |
1317 | return; executed: return; Execution Count:1 | 1 |
1318 | | - |
1319 | emit q->layoutAboutToBeChanged(parents, hint); executed (the execution status of this line is deduced): q->layoutAboutToBeChanged(parents, hint); | - |
1320 | if (persistent.indexes.isEmpty()) evaluated: persistent.indexes.isEmpty() yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
1321 | return; executed: return; Execution Count:1 | 1 |
1322 | | - |
1323 | saved_persistent_indexes = store_persistent_indexes(); executed (the execution status of this line is deduced): saved_persistent_indexes = store_persistent_indexes(); | - |
1324 | } executed: } Execution Count:3 | 3 |
1325 | | - |
1326 | void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint) | - |
1327 | { | - |
1328 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1329 | | - |
1330 | // Optimize: We only actually have to clear the mapping related to the contents of | - |
1331 | // sourceParents, not everything. | - |
1332 | qDeleteAll(source_index_mapping); executed (the execution status of this line is deduced): qDeleteAll(source_index_mapping); | - |
1333 | source_index_mapping.clear(); executed (the execution status of this line is deduced): source_index_mapping.clear(); | - |
1334 | | - |
1335 | update_persistent_indexes(saved_persistent_indexes); executed (the execution status of this line is deduced): update_persistent_indexes(saved_persistent_indexes); | - |
1336 | saved_persistent_indexes.clear(); executed (the execution status of this line is deduced): saved_persistent_indexes.clear(); | - |
1337 | | - |
1338 | if (dynamic_sortfilter && update_source_sort_column()) { partially evaluated: dynamic_sortfilter yes Evaluation Count:5 | no Evaluation Count:0 |
evaluated: update_source_sort_column() yes Evaluation Count:1 | yes Evaluation Count:4 |
| 0-5 |
1339 | //update_source_sort_column might have created wrong mapping so we have to clear it again | - |
1340 | qDeleteAll(source_index_mapping); executed (the execution status of this line is deduced): qDeleteAll(source_index_mapping); | - |
1341 | source_index_mapping.clear(); executed (the execution status of this line is deduced): source_index_mapping.clear(); | - |
1342 | } executed: } Execution Count:1 | 1 |
1343 | | - |
1344 | QList<QPersistentModelIndex> parents; executed (the execution status of this line is deduced): QList<QPersistentModelIndex> parents; | - |
1345 | foreach (const QPersistentModelIndex &parent, sourceParents) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sourceParents)> _container_(sourceParents); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QPersistentModelIndex &parent = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
1346 | if (!parent.isValid()) { evaluated: !parent.isValid() yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
1347 | parents << QPersistentModelIndex(); executed (the execution status of this line is deduced): parents << QPersistentModelIndex(); | - |
1348 | continue; executed: continue; Execution Count:1 | 1 |
1349 | } | - |
1350 | const QModelIndex mappedParent = q->mapFromSource(parent); executed (the execution status of this line is deduced): const QModelIndex mappedParent = q->mapFromSource(parent); | - |
1351 | if (mappedParent.isValid()) evaluated: mappedParent.isValid() yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
1352 | parents << mappedParent; executed: parents << mappedParent; Execution Count:2 | 2 |
1353 | } executed: } Execution Count:5 | 5 |
1354 | | - |
1355 | if (!sourceParents.isEmpty() && parents.isEmpty()) evaluated: !sourceParents.isEmpty() yes Evaluation Count:4 | yes Evaluation Count:1 |
evaluated: parents.isEmpty() yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-4 |
1356 | return; executed: return; Execution Count:1 | 1 |
1357 | | - |
1358 | emit q->layoutChanged(parents, hint); executed (the execution status of this line is deduced): q->layoutChanged(parents, hint); | - |
1359 | } executed: } Execution Count:4 | 4 |
1360 | | - |
1361 | void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeInserted( | - |
1362 | const QModelIndex &source_parent, int start, int end) | - |
1363 | { | - |
1364 | Q_UNUSED(start); executed (the execution status of this line is deduced): (void)start;; | - |
1365 | Q_UNUSED(end); executed (the execution status of this line is deduced): (void)end;; | - |
1366 | //Force the creation of a mapping now, even if its empty. | - |
1367 | //We need it because the proxy can be acessed at the moment it emits rowsAboutToBeInserted in insert_source_items | - |
1368 | if (can_create_mapping(source_parent)) evaluated: can_create_mapping(source_parent) yes Evaluation Count:1126 | yes Evaluation Count:1 |
| 1-1126 |
1369 | create_mapping(source_parent); executed: create_mapping(source_parent); Execution Count:1126 | 1126 |
1370 | } executed: } Execution Count:1127 | 1127 |
1371 | | - |
1372 | void QSortFilterProxyModelPrivate::_q_sourceRowsInserted( | - |
1373 | const QModelIndex &source_parent, int start, int end) | - |
1374 | { | - |
1375 | source_items_inserted(source_parent, start, end, Qt::Vertical); executed (the execution status of this line is deduced): source_items_inserted(source_parent, start, end, Qt::Vertical); | - |
1376 | if (update_source_sort_column() && dynamic_sortfilter) //previous call to update_source_sort_column may fail if the model has no column. partially evaluated: update_source_sort_column() no Evaluation Count:0 | yes Evaluation Count:1127 |
never evaluated: dynamic_sortfilter | 0-1127 |
1377 | sort(); // now it should succeed so we need to make sure to sort again | 0 |
1378 | } executed: } Execution Count:1127 | 1127 |
1379 | | - |
1380 | void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeRemoved( | - |
1381 | const QModelIndex &source_parent, int start, int end) | - |
1382 | { | - |
1383 | itemsBeingRemoved = QRowsRemoval(source_parent, start, end); executed (the execution status of this line is deduced): itemsBeingRemoved = QRowsRemoval(source_parent, start, end); | - |
1384 | source_items_about_to_be_removed(source_parent, start, end, executed (the execution status of this line is deduced): source_items_about_to_be_removed(source_parent, start, end, | - |
1385 | Qt::Vertical); executed (the execution status of this line is deduced): Qt::Vertical); | - |
1386 | } executed: } Execution Count:45 | 45 |
1387 | | - |
1388 | void QSortFilterProxyModelPrivate::_q_sourceRowsRemoved( | - |
1389 | const QModelIndex &source_parent, int start, int end) | - |
1390 | { | - |
1391 | itemsBeingRemoved = QRowsRemoval(); executed (the execution status of this line is deduced): itemsBeingRemoved = QRowsRemoval(); | - |
1392 | source_items_removed(source_parent, start, end, Qt::Vertical); executed (the execution status of this line is deduced): source_items_removed(source_parent, start, end, Qt::Vertical); | - |
1393 | } executed: } Execution Count:45 | 45 |
1394 | | - |
1395 | void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeMoved( | - |
1396 | const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) | - |
1397 | { | - |
1398 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1399 | // Because rows which are contiguous in the source model might not be contiguous | - |
1400 | // in the proxy due to sorting, the best thing we can do here is be specific about what | - |
1401 | // parents are having their children changed. | - |
1402 | // Optimize: Emit move signals if the proxy is not sorted. Will need to account for rows | - |
1403 | // being filtered out though. | - |
1404 | | - |
1405 | saved_persistent_indexes.clear(); executed (the execution status of this line is deduced): saved_persistent_indexes.clear(); | - |
1406 | | - |
1407 | QList<QPersistentModelIndex> parents; executed (the execution status of this line is deduced): QList<QPersistentModelIndex> parents; | - |
1408 | parents << q->mapFromSource(sourceParent); executed (the execution status of this line is deduced): parents << q->mapFromSource(sourceParent); | - |
1409 | if (sourceParent != destParent) partially evaluated: sourceParent != destParent yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1410 | parents << q->mapFromSource(destParent); executed: parents << q->mapFromSource(destParent); Execution Count:4 | 4 |
1411 | emit q->layoutAboutToBeChanged(parents); executed (the execution status of this line is deduced): q->layoutAboutToBeChanged(parents); | - |
1412 | if (persistent.indexes.isEmpty()) partially evaluated: persistent.indexes.isEmpty() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1413 | return; | 0 |
1414 | saved_persistent_indexes = store_persistent_indexes(); executed (the execution status of this line is deduced): saved_persistent_indexes = store_persistent_indexes(); | - |
1415 | } executed: } Execution Count:4 | 4 |
1416 | | - |
1417 | void QSortFilterProxyModelPrivate::_q_sourceRowsMoved( | - |
1418 | const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) | - |
1419 | { | - |
1420 | Q_Q(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1421 | | - |
1422 | // Optimize: We only need to clear and update the persistent indexes which are children of | - |
1423 | // sourceParent or destParent | - |
1424 | qDeleteAll(source_index_mapping); executed (the execution status of this line is deduced): qDeleteAll(source_index_mapping); | - |
1425 | source_index_mapping.clear(); executed (the execution status of this line is deduced): source_index_mapping.clear(); | - |
1426 | | - |
1427 | update_persistent_indexes(saved_persistent_indexes); executed (the execution status of this line is deduced): update_persistent_indexes(saved_persistent_indexes); | - |
1428 | saved_persistent_indexes.clear(); executed (the execution status of this line is deduced): saved_persistent_indexes.clear(); | - |
1429 | | - |
1430 | if (dynamic_sortfilter && update_source_sort_column()) { partially evaluated: dynamic_sortfilter yes Evaluation Count:4 | no Evaluation Count:0 |
partially evaluated: update_source_sort_column() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1431 | //update_source_sort_column might have created wrong mapping so we have to clear it again | - |
1432 | qDeleteAll(source_index_mapping); never executed (the execution status of this line is deduced): qDeleteAll(source_index_mapping); | - |
1433 | source_index_mapping.clear(); never executed (the execution status of this line is deduced): source_index_mapping.clear(); | - |
1434 | } | 0 |
1435 | | - |
1436 | QList<QPersistentModelIndex> parents; executed (the execution status of this line is deduced): QList<QPersistentModelIndex> parents; | - |
1437 | parents << q->mapFromSource(sourceParent); executed (the execution status of this line is deduced): parents << q->mapFromSource(sourceParent); | - |
1438 | if (sourceParent != destParent) partially evaluated: sourceParent != destParent yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1439 | parents << q->mapFromSource(destParent); executed: parents << q->mapFromSource(destParent); Execution Count:4 | 4 |
1440 | emit q->layoutChanged(parents); executed (the execution status of this line is deduced): q->layoutChanged(parents); | - |
1441 | } executed: } Execution Count:4 | 4 |
1442 | | - |
1443 | void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeInserted( | - |
1444 | const QModelIndex &source_parent, int start, int end) | - |
1445 | { | - |
1446 | Q_UNUSED(start); executed (the execution status of this line is deduced): (void)start;; | - |
1447 | Q_UNUSED(end); executed (the execution status of this line is deduced): (void)end;; | - |
1448 | //Force the creation of a mapping now, even if its empty. | - |
1449 | //We need it because the proxy can be acessed at the moment it emits columnsAboutToBeInserted in insert_source_items | - |
1450 | if (can_create_mapping(source_parent)) evaluated: can_create_mapping(source_parent) yes Evaluation Count:1132 | yes Evaluation Count:1 |
| 1-1132 |
1451 | create_mapping(source_parent); executed: create_mapping(source_parent); Execution Count:1132 | 1132 |
1452 | } executed: } Execution Count:1133 | 1133 |
1453 | | - |
1454 | void QSortFilterProxyModelPrivate::_q_sourceColumnsInserted( | - |
1455 | const QModelIndex &source_parent, int start, int end) | - |
1456 | { | - |
1457 | Q_Q(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModel * const q = q_func(); | - |
1458 | source_items_inserted(source_parent, start, end, Qt::Horizontal); executed (the execution status of this line is deduced): source_items_inserted(source_parent, start, end, Qt::Horizontal); | - |
1459 | | - |
1460 | if (source_parent.isValid()) evaluated: source_parent.isValid() yes Evaluation Count:826 | yes Evaluation Count:307 |
| 307-826 |
1461 | return; //we sort according to the root column only executed: return; Execution Count:826 | 826 |
1462 | if (source_sort_column == -1) { evaluated: source_sort_column == -1 yes Evaluation Count:304 | yes Evaluation Count:3 |
| 3-304 |
1463 | //we update the source_sort_column depending on the proxy_sort_column | - |
1464 | if (update_source_sort_column() && dynamic_sortfilter) evaluated: update_source_sort_column() yes Evaluation Count:1 | yes Evaluation Count:303 |
partially evaluated: dynamic_sortfilter yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-303 |
1465 | sort(); executed: sort(); Execution Count:1 | 1 |
1466 | } else { executed: } Execution Count:304 | 304 |
1467 | if (start <= source_sort_column) evaluated: start <= source_sort_column yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
1468 | source_sort_column += end - start + 1; executed: source_sort_column += end - start + 1; Execution Count:1 | 1 |
1469 | | - |
1470 | proxy_sort_column = q->mapFromSource(model->index(0,source_sort_column, source_parent)).column(); executed (the execution status of this line is deduced): proxy_sort_column = q->mapFromSource(model->index(0,source_sort_column, source_parent)).column(); | - |
1471 | } executed: } Execution Count:3 | 3 |
1472 | } | - |
1473 | | - |
1474 | void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeRemoved( | - |
1475 | const QModelIndex &source_parent, int start, int end) | - |
1476 | { | - |
1477 | source_items_about_to_be_removed(source_parent, start, end, executed (the execution status of this line is deduced): source_items_about_to_be_removed(source_parent, start, end, | - |
1478 | Qt::Horizontal); executed (the execution status of this line is deduced): Qt::Horizontal); | - |
1479 | } executed: } Execution Count:35 | 35 |
1480 | | - |
1481 | void QSortFilterProxyModelPrivate::_q_sourceColumnsRemoved( | - |
1482 | const QModelIndex &source_parent, int start, int end) | - |
1483 | { | - |
1484 | Q_Q(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModel * const q = q_func(); | - |
1485 | source_items_removed(source_parent, start, end, Qt::Horizontal); executed (the execution status of this line is deduced): source_items_removed(source_parent, start, end, Qt::Horizontal); | - |
1486 | | - |
1487 | if (source_parent.isValid()) evaluated: source_parent.isValid() yes Evaluation Count:22 | yes Evaluation Count:13 |
| 13-22 |
1488 | return; //we sort according to the root column only executed: return; Execution Count:22 | 22 |
1489 | if (start <= source_sort_column) { evaluated: start <= source_sort_column yes Evaluation Count:2 | yes Evaluation Count:11 |
| 2-11 |
1490 | if (end < source_sort_column) evaluated: end < source_sort_column yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1491 | source_sort_column -= end - start + 1; executed: source_sort_column -= end - start + 1; Execution Count:1 | 1 |
1492 | else | - |
1493 | source_sort_column = -1; executed: source_sort_column = -1; Execution Count:1 | 1 |
1494 | } | - |
1495 | | - |
1496 | proxy_sort_column = q->mapFromSource(model->index(0,source_sort_column, source_parent)).column(); executed (the execution status of this line is deduced): proxy_sort_column = q->mapFromSource(model->index(0,source_sort_column, source_parent)).column(); | - |
1497 | } executed: } Execution Count:13 | 13 |
1498 | | - |
1499 | void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeMoved( | - |
1500 | const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) | - |
1501 | { | - |
1502 | Q_Q(QSortFilterProxyModel); never executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1503 | | - |
1504 | saved_persistent_indexes.clear(); never executed (the execution status of this line is deduced): saved_persistent_indexes.clear(); | - |
1505 | | - |
1506 | QList<QPersistentModelIndex> parents; never executed (the execution status of this line is deduced): QList<QPersistentModelIndex> parents; | - |
1507 | parents << q->mapFromSource(sourceParent); never executed (the execution status of this line is deduced): parents << q->mapFromSource(sourceParent); | - |
1508 | if (sourceParent != destParent) never evaluated: sourceParent != destParent | 0 |
1509 | parents << q->mapFromSource(destParent); never executed: parents << q->mapFromSource(destParent); | 0 |
1510 | emit q->layoutAboutToBeChanged(parents); never executed (the execution status of this line is deduced): q->layoutAboutToBeChanged(parents); | - |
1511 | | - |
1512 | if (persistent.indexes.isEmpty()) never evaluated: persistent.indexes.isEmpty() | 0 |
1513 | return; | 0 |
1514 | saved_persistent_indexes = store_persistent_indexes(); never executed (the execution status of this line is deduced): saved_persistent_indexes = store_persistent_indexes(); | - |
1515 | } | 0 |
1516 | | - |
1517 | void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved( | - |
1518 | const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */) | - |
1519 | { | - |
1520 | Q_Q(QSortFilterProxyModel); never executed (the execution status of this line is deduced): QSortFilterProxyModel * const q = q_func(); | - |
1521 | | - |
1522 | qDeleteAll(source_index_mapping); never executed (the execution status of this line is deduced): qDeleteAll(source_index_mapping); | - |
1523 | source_index_mapping.clear(); never executed (the execution status of this line is deduced): source_index_mapping.clear(); | - |
1524 | | - |
1525 | update_persistent_indexes(saved_persistent_indexes); never executed (the execution status of this line is deduced): update_persistent_indexes(saved_persistent_indexes); | - |
1526 | saved_persistent_indexes.clear(); never executed (the execution status of this line is deduced): saved_persistent_indexes.clear(); | - |
1527 | | - |
1528 | if (dynamic_sortfilter && update_source_sort_column()) { never evaluated: dynamic_sortfilter never evaluated: update_source_sort_column() | 0 |
1529 | qDeleteAll(source_index_mapping); never executed (the execution status of this line is deduced): qDeleteAll(source_index_mapping); | - |
1530 | source_index_mapping.clear(); never executed (the execution status of this line is deduced): source_index_mapping.clear(); | - |
1531 | } | 0 |
1532 | | - |
1533 | QList<QPersistentModelIndex> parents; never executed (the execution status of this line is deduced): QList<QPersistentModelIndex> parents; | - |
1534 | parents << q->mapFromSource(sourceParent); never executed (the execution status of this line is deduced): parents << q->mapFromSource(sourceParent); | - |
1535 | if (sourceParent != destParent) never evaluated: sourceParent != destParent | 0 |
1536 | parents << q->mapFromSource(destParent); never executed: parents << q->mapFromSource(destParent); | 0 |
1537 | emit q->layoutChanged(parents); never executed (the execution status of this line is deduced): q->layoutChanged(parents); | - |
1538 | } | 0 |
1539 | | - |
1540 | /*! | - |
1541 | \since 4.1 | - |
1542 | \class QSortFilterProxyModel | - |
1543 | \inmodule QtCore | - |
1544 | \brief The QSortFilterProxyModel class provides support for sorting and | - |
1545 | filtering data passed between another model and a view. | - |
1546 | | - |
1547 | \ingroup model-view | - |
1548 | | - |
1549 | QSortFilterProxyModel can be used for sorting items, filtering out items, | - |
1550 | or both. The model transforms the structure of a source model by mapping | - |
1551 | the model indexes it supplies to new indexes, corresponding to different | - |
1552 | locations, for views to use. This approach allows a given source model to | - |
1553 | be restructured as far as views are concerned without requiring any | - |
1554 | transformations on the underlying data, and without duplicating the data in | - |
1555 | memory. | - |
1556 | | - |
1557 | Let's assume that we want to sort and filter the items provided by a custom | - |
1558 | model. The code to set up the model and the view, \e without sorting and | - |
1559 | filtering, would look like this: | - |
1560 | | - |
1561 | \snippet qsortfilterproxymodel-details/main.cpp 1 | - |
1562 | | - |
1563 | To add sorting and filtering support to \c MyItemModel, we need to create | - |
1564 | a QSortFilterProxyModel, call setSourceModel() with the \c MyItemModel as | - |
1565 | argument, and install the QSortFilterProxyModel on the view: | - |
1566 | | - |
1567 | \snippet qsortfilterproxymodel-details/main.cpp 0 | - |
1568 | \snippet qsortfilterproxymodel-details/main.cpp 2 | - |
1569 | | - |
1570 | At this point, neither sorting nor filtering is enabled; the original data | - |
1571 | is displayed in the view. Any changes made through the | - |
1572 | QSortFilterProxyModel are applied to the original model. | - |
1573 | | - |
1574 | The QSortFilterProxyModel acts as a wrapper for the original model. If you | - |
1575 | need to convert source \l{QModelIndex}es to sorted/filtered model indexes | - |
1576 | or vice versa, use mapToSource(), mapFromSource(), mapSelectionToSource(), | - |
1577 | and mapSelectionFromSource(). | - |
1578 | | - |
1579 | \note By default, the model dynamically re-sorts and re-filters data | - |
1580 | whenever the original model changes. This behavior can be changed by | - |
1581 | setting the \l{QSortFilterProxyModel::dynamicSortFilter}{dynamicSortFilter} | - |
1582 | property. | - |
1583 | | - |
1584 | The \l{itemviews/basicsortfiltermodel}{Basic Sort/Filter Model} and | - |
1585 | \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model} examples | - |
1586 | illustrate how to use QSortFilterProxyModel to perform basic sorting and | - |
1587 | filtering and how to subclass it to implement custom behavior. | - |
1588 | | - |
1589 | \section1 Sorting | - |
1590 | | - |
1591 | QTableView and QTreeView have a | - |
1592 | \l{QTreeView::sortingEnabled}{sortingEnabled} property that controls | - |
1593 | whether the user can sort the view by clicking the view's horizontal | - |
1594 | header. For example: | - |
1595 | | - |
1596 | \snippet qsortfilterproxymodel-details/main.cpp 3 | - |
1597 | | - |
1598 | When this feature is on (the default is off), clicking on a header section | - |
1599 | sorts the items according to that column. By clicking repeatedly, the user | - |
1600 | can alternate between ascending and descending order. | - |
1601 | | - |
1602 | \image qsortfilterproxymodel-sorting.png A sorted QTreeView | - |
1603 | | - |
1604 | Behind the scene, the view calls the sort() virtual function on the model | - |
1605 | to reorder the data in the model. To make your data sortable, you can | - |
1606 | either implement sort() in your model, or use a QSortFilterProxyModel to | - |
1607 | wrap your model -- QSortFilterProxyModel provides a generic sort() | - |
1608 | reimplementation that operates on the sortRole() (Qt::DisplayRole by | - |
1609 | default) of the items and that understands several data types, including | - |
1610 | \c int, QString, and QDateTime. For hierarchical models, sorting is applied | - |
1611 | recursively to all child items. String comparisons are case sensitive by | - |
1612 | default; this can be changed by setting the \l{QSortFilterProxyModel::} | - |
1613 | {sortCaseSensitivity} property. | - |
1614 | | - |
1615 | Custom sorting behavior is achieved by subclassing | - |
1616 | QSortFilterProxyModel and reimplementing lessThan(), which is | - |
1617 | used to compare items. For example: | - |
1618 | | - |
1619 | \snippet ../widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 5 | - |
1620 | | - |
1621 | (This code snippet comes from the | - |
1622 | \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model} | - |
1623 | example.) | - |
1624 | | - |
1625 | An alternative approach to sorting is to disable sorting on the view and to | - |
1626 | impose a certain order to the user. This is done by explicitly calling | - |
1627 | sort() with the desired column and order as arguments on the | - |
1628 | QSortFilterProxyModel (or on the original model if it implements sort()). | - |
1629 | For example: | - |
1630 | | - |
1631 | \snippet qsortfilterproxymodel-details/main.cpp 4 | - |
1632 | | - |
1633 | QSortFilterProxyModel can be sorted by column -1, in which case it returns | - |
1634 | to the sort order of the underlying source model. | - |
1635 | | - |
1636 | \section1 Filtering | - |
1637 | | - |
1638 | In addition to sorting, QSortFilterProxyModel can be used to hide items | - |
1639 | that do not match a certain filter. The filter is specified using a QRegExp | - |
1640 | object and is applied to the filterRole() (Qt::DisplayRole by default) of | - |
1641 | each item, for a given column. The QRegExp object can be used to match a | - |
1642 | regular expression, a wildcard pattern, or a fixed string. For example: | - |
1643 | | - |
1644 | \snippet qsortfilterproxymodel-details/main.cpp 5 | - |
1645 | | - |
1646 | For hierarchical models, the filter is applied recursively to all children. | - |
1647 | If a parent item doesn't match the filter, none of its children will be | - |
1648 | shown. | - |
1649 | | - |
1650 | A common use case is to let the user specify the filter regexp, wildcard | - |
1651 | pattern, or fixed string in a QLineEdit and to connect the | - |
1652 | \l{QLineEdit::textChanged()}{textChanged()} signal to setFilterRegExp(), | - |
1653 | setFilterWildcard(), or setFilterFixedString() to reapply the filter. | - |
1654 | | - |
1655 | Custom filtering behavior can be achieved by reimplementing the | - |
1656 | filterAcceptsRow() and filterAcceptsColumn() functions. For | - |
1657 | example (from the \l{itemviews/customsortfiltermodel} | - |
1658 | {Custom Sort/Filter Model} example), the following implementation ignores | - |
1659 | the \l{QSortFilterProxyModel::filterKeyColumn}{filterKeyColumn} property | - |
1660 | and performs filtering on columns 0, 1, and 2: | - |
1661 | | - |
1662 | \snippet ../widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 3 | - |
1663 | | - |
1664 | (This code snippet comes from the | - |
1665 | \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model} | - |
1666 | example.) | - |
1667 | | - |
1668 | If you are working with large amounts of filtering and have to invoke | - |
1669 | invalidateFilter() repeatedly, using reset() may be more efficient, | - |
1670 | depending on the implementation of your model. However, reset() returns the | - |
1671 | proxy model to its original state, losing selection information, and will | - |
1672 | cause the proxy model to be repopulated. | - |
1673 | | - |
1674 | \section1 Subclassing | - |
1675 | | - |
1676 | Since QAbstractProxyModel and its subclasses are derived from | - |
1677 | QAbstractItemModel, much of the same advice about subclassing normal models | - |
1678 | also applies to proxy models. In addition, it is worth noting that many of | - |
1679 | the default implementations of functions in this class are written so that | - |
1680 | they call the equivalent functions in the relevant source model. This | - |
1681 | simple proxying mechanism may need to be overridden for source models with | - |
1682 | more complex behavior; for example, if the source model provides a custom | - |
1683 | hasChildren() implementation, you should also provide one in the proxy | - |
1684 | model. | - |
1685 | | - |
1686 | \note Some general guidelines for subclassing models are available in the | - |
1687 | \l{Model Subclassing Reference}. | - |
1688 | | - |
1689 | \sa QAbstractProxyModel, QAbstractItemModel, {Model/View Programming}, | - |
1690 | {Basic Sort/Filter Model Example}, {Custom Sort/Filter Model Example}, QIdentityProxyModel | - |
1691 | */ | - |
1692 | | - |
1693 | /*! | - |
1694 | Constructs a sorting filter model with the given \a parent. | - |
1695 | */ | - |
1696 | | - |
1697 | QSortFilterProxyModel::QSortFilterProxyModel(QObject *parent) | - |
1698 | : QAbstractProxyModel(*new QSortFilterProxyModelPrivate, parent) | - |
1699 | { | - |
1700 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
1701 | d->proxy_sort_column = d->source_sort_column = -1; executed (the execution status of this line is deduced): d->proxy_sort_column = d->source_sort_column = -1; | - |
1702 | d->sort_order = Qt::AscendingOrder; executed (the execution status of this line is deduced): d->sort_order = Qt::AscendingOrder; | - |
1703 | d->sort_casesensitivity = Qt::CaseSensitive; executed (the execution status of this line is deduced): d->sort_casesensitivity = Qt::CaseSensitive; | - |
1704 | d->sort_role = Qt::DisplayRole; executed (the execution status of this line is deduced): d->sort_role = Qt::DisplayRole; | - |
1705 | d->sort_localeaware = false; executed (the execution status of this line is deduced): d->sort_localeaware = false; | - |
1706 | d->filter_column = 0; executed (the execution status of this line is deduced): d->filter_column = 0; | - |
1707 | d->filter_role = Qt::DisplayRole; executed (the execution status of this line is deduced): d->filter_role = Qt::DisplayRole; | - |
1708 | d->dynamic_sortfilter = true; executed (the execution status of this line is deduced): d->dynamic_sortfilter = true; | - |
1709 | connect(this, SIGNAL(modelReset()), this, SLOT(_q_clearMapping())); executed (the execution status of this line is deduced): connect(this, "2""modelReset()", this, "1""_q_clearMapping()"); | - |
1710 | } executed: } Execution Count:264 | 264 |
1711 | | - |
1712 | /*! | - |
1713 | Destroys this sorting filter model. | - |
1714 | */ | - |
1715 | QSortFilterProxyModel::~QSortFilterProxyModel() | - |
1716 | { | - |
1717 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
1718 | qDeleteAll(d->source_index_mapping); executed (the execution status of this line is deduced): qDeleteAll(d->source_index_mapping); | - |
1719 | d->source_index_mapping.clear(); executed (the execution status of this line is deduced): d->source_index_mapping.clear(); | - |
1720 | } executed: } Execution Count:261 | 261 |
1721 | | - |
1722 | /*! | - |
1723 | \reimp | - |
1724 | */ | - |
1725 | void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) | - |
1726 | { | - |
1727 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
1728 | | - |
1729 | beginResetModel(); executed (the execution status of this line is deduced): beginResetModel(); | - |
1730 | | - |
1731 | disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), executed (the execution status of this line is deduced): disconnect(d->model, "2""dataChanged(QModelIndex,QModelIndex)", | - |
1732 | this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); executed (the execution status of this line is deduced): this, "1""_q_sourceDataChanged(QModelIndex,QModelIndex)"); | - |
1733 | | - |
1734 | disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""headerDataChanged(Qt::Orientation,int,int)", | - |
1735 | this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceHeaderDataChanged(Qt::Orientation,int,int)"); | - |
1736 | | - |
1737 | disconnect(d->model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsAboutToBeInserted(QModelIndex,int,int)", | - |
1738 | this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)"); | - |
1739 | | - |
1740 | disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsInserted(QModelIndex,int,int)", | - |
1741 | this, SLOT(_q_sourceRowsInserted(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsInserted(QModelIndex,int,int)"); | - |
1742 | | - |
1743 | disconnect(d->model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""columnsAboutToBeInserted(QModelIndex,int,int)", | - |
1744 | this, SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)"); | - |
1745 | | - |
1746 | disconnect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""columnsInserted(QModelIndex,int,int)", | - |
1747 | this, SLOT(_q_sourceColumnsInserted(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsInserted(QModelIndex,int,int)"); | - |
1748 | | - |
1749 | disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsAboutToBeRemoved(QModelIndex,int,int)", | - |
1750 | this, SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)"); | - |
1751 | | - |
1752 | disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsRemoved(QModelIndex,int,int)", | - |
1753 | this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsRemoved(QModelIndex,int,int)"); | - |
1754 | | - |
1755 | disconnect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""columnsAboutToBeRemoved(QModelIndex,int,int)", | - |
1756 | this, SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)"); | - |
1757 | | - |
1758 | disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""columnsRemoved(QModelIndex,int,int)", | - |
1759 | this, SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsRemoved(QModelIndex,int,int)"); | - |
1760 | | - |
1761 | disconnect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)", | - |
1762 | this, SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)"); | - |
1763 | | - |
1764 | disconnect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""rowsMoved(QModelIndex,int,int,QModelIndex,int)", | - |
1765 | this, SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)"); | - |
1766 | | - |
1767 | disconnect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)", | - |
1768 | this, SLOT(_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)"); | - |
1769 | | - |
1770 | disconnect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), executed (the execution status of this line is deduced): disconnect(d->model, "2""columnsMoved(QModelIndex,int,int,QModelIndex,int)", | - |
1771 | this, SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)"); | - |
1772 | | - |
1773 | disconnect(d->model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), executed (the execution status of this line is deduced): disconnect(d->model, "2""layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)", | - |
1774 | this, SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint))); executed (the execution status of this line is deduced): this, "1""_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)"); | - |
1775 | | - |
1776 | disconnect(d->model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), executed (the execution status of this line is deduced): disconnect(d->model, "2""layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)", | - |
1777 | this, SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint))); executed (the execution status of this line is deduced): this, "1""_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)"); | - |
1778 | | - |
1779 | disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset())); executed (the execution status of this line is deduced): disconnect(d->model, "2""modelAboutToBeReset()", this, "1""_q_sourceAboutToBeReset()"); | - |
1780 | disconnect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); executed (the execution status of this line is deduced): disconnect(d->model, "2""modelReset()", this, "1""_q_sourceReset()"); | - |
1781 | | - |
1782 | QAbstractProxyModel::setSourceModel(sourceModel); executed (the execution status of this line is deduced): QAbstractProxyModel::setSourceModel(sourceModel); | - |
1783 | | - |
1784 | connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), executed (the execution status of this line is deduced): connect(d->model, "2""dataChanged(QModelIndex,QModelIndex)", | - |
1785 | this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); executed (the execution status of this line is deduced): this, "1""_q_sourceDataChanged(QModelIndex,QModelIndex)"); | - |
1786 | | - |
1787 | connect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), executed (the execution status of this line is deduced): connect(d->model, "2""headerDataChanged(Qt::Orientation,int,int)", | - |
1788 | this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceHeaderDataChanged(Qt::Orientation,int,int)"); | - |
1789 | | - |
1790 | connect(d->model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(d->model, "2""rowsAboutToBeInserted(QModelIndex,int,int)", | - |
1791 | this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)"); | - |
1792 | | - |
1793 | connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(d->model, "2""rowsInserted(QModelIndex,int,int)", | - |
1794 | this, SLOT(_q_sourceRowsInserted(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsInserted(QModelIndex,int,int)"); | - |
1795 | | - |
1796 | connect(d->model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(d->model, "2""columnsAboutToBeInserted(QModelIndex,int,int)", | - |
1797 | this, SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)"); | - |
1798 | | - |
1799 | connect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(d->model, "2""columnsInserted(QModelIndex,int,int)", | - |
1800 | this, SLOT(_q_sourceColumnsInserted(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsInserted(QModelIndex,int,int)"); | - |
1801 | | - |
1802 | connect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(d->model, "2""rowsAboutToBeRemoved(QModelIndex,int,int)", | - |
1803 | this, SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)"); | - |
1804 | | - |
1805 | connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(d->model, "2""rowsRemoved(QModelIndex,int,int)", | - |
1806 | this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsRemoved(QModelIndex,int,int)"); | - |
1807 | | - |
1808 | connect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(d->model, "2""columnsAboutToBeRemoved(QModelIndex,int,int)", | - |
1809 | this, SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)"); | - |
1810 | | - |
1811 | connect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), executed (the execution status of this line is deduced): connect(d->model, "2""columnsRemoved(QModelIndex,int,int)", | - |
1812 | this, SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsRemoved(QModelIndex,int,int)"); | - |
1813 | | - |
1814 | connect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), executed (the execution status of this line is deduced): connect(d->model, "2""rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)", | - |
1815 | this, SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)"); | - |
1816 | | - |
1817 | connect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), executed (the execution status of this line is deduced): connect(d->model, "2""rowsMoved(QModelIndex,int,int,QModelIndex,int)", | - |
1818 | this, SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)"); | - |
1819 | | - |
1820 | connect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), executed (the execution status of this line is deduced): connect(d->model, "2""columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)", | - |
1821 | this, SLOT(_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)"); | - |
1822 | | - |
1823 | connect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), executed (the execution status of this line is deduced): connect(d->model, "2""columnsMoved(QModelIndex,int,int,QModelIndex,int)", | - |
1824 | this, SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))); executed (the execution status of this line is deduced): this, "1""_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)"); | - |
1825 | | - |
1826 | connect(d->model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), executed (the execution status of this line is deduced): connect(d->model, "2""layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)", | - |
1827 | this, SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint))); executed (the execution status of this line is deduced): this, "1""_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)"); | - |
1828 | | - |
1829 | connect(d->model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)), executed (the execution status of this line is deduced): connect(d->model, "2""layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)", | - |
1830 | this, SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint))); executed (the execution status of this line is deduced): this, "1""_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)"); | - |
1831 | | - |
1832 | connect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset())); executed (the execution status of this line is deduced): connect(d->model, "2""modelAboutToBeReset()", this, "1""_q_sourceAboutToBeReset()"); | - |
1833 | connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); executed (the execution status of this line is deduced): connect(d->model, "2""modelReset()", this, "1""_q_sourceReset()"); | - |
1834 | | - |
1835 | d->_q_clearMapping(); executed (the execution status of this line is deduced): d->_q_clearMapping(); | - |
1836 | endResetModel(); executed (the execution status of this line is deduced): endResetModel(); | - |
1837 | if (d->update_source_sort_column() && d->dynamic_sortfilter) evaluated: d->update_source_sort_column() yes Evaluation Count:1 | yes Evaluation Count:269 |
partially evaluated: d->dynamic_sortfilter no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-269 |
1838 | d->sort(); never executed: d->sort(); | 0 |
1839 | } executed: } Execution Count:270 | 270 |
1840 | | - |
1841 | /*! | - |
1842 | \reimp | - |
1843 | */ | - |
1844 | QModelIndex QSortFilterProxyModel::index(int row, int column, const QModelIndex &parent) const | - |
1845 | { | - |
1846 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
1847 | if (row < 0 || column < 0) evaluated: row < 0 yes Evaluation Count:145 | yes Evaluation Count:81098 |
evaluated: column < 0 yes Evaluation Count:2944 | yes Evaluation Count:78154 |
| 145-81098 |
1848 | return QModelIndex(); executed: return QModelIndex(); Execution Count:3089 | 3089 |
1849 | | - |
1850 | QModelIndex source_parent = mapToSource(parent); // parent is already mapped at this point executed (the execution status of this line is deduced): QModelIndex source_parent = mapToSource(parent); | - |
1851 | IndexMap::const_iterator it = d->create_mapping(source_parent); // but make sure that the children are mapped executed (the execution status of this line is deduced): IndexMap::const_iterator it = d->create_mapping(source_parent); | - |
1852 | if (it.value()->source_rows.count() <= row || it.value()->source_columns.count() <= column) evaluated: it.value()->source_rows.count() <= row yes Evaluation Count:211 | yes Evaluation Count:77943 |
evaluated: it.value()->source_columns.count() <= column yes Evaluation Count:49 | yes Evaluation Count:77894 |
| 49-77943 |
1853 | return QModelIndex(); executed: return QModelIndex(); Execution Count:260 | 260 |
1854 | | - |
1855 | return d->create_index(row, column, it); executed: return d->create_index(row, column, it); Execution Count:77894 | 77894 |
1856 | } | - |
1857 | | - |
1858 | /*! | - |
1859 | \reimp | - |
1860 | */ | - |
1861 | QModelIndex QSortFilterProxyModel::parent(const QModelIndex &child) const | - |
1862 | { | - |
1863 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
1864 | if (!d->indexValid(child)) evaluated: !d->indexValid(child) yes Evaluation Count:123 | yes Evaluation Count:16146 |
| 123-16146 |
1865 | return QModelIndex(); executed: return QModelIndex(); Execution Count:123 | 123 |
1866 | IndexMap::const_iterator it = d->index_to_iterator(child); executed (the execution status of this line is deduced): IndexMap::const_iterator it = d->index_to_iterator(child); | - |
1867 | Q_ASSERT(it != d->source_index_mapping.constEnd()); executed (the execution status of this line is deduced): qt_noop(); | - |
1868 | QModelIndex source_parent = it.key(); executed (the execution status of this line is deduced): QModelIndex source_parent = it.key(); | - |
1869 | QModelIndex proxy_parent = mapFromSource(source_parent); executed (the execution status of this line is deduced): QModelIndex proxy_parent = mapFromSource(source_parent); | - |
1870 | return proxy_parent; executed: return proxy_parent; Execution Count:16146 | 16146 |
1871 | } | - |
1872 | | - |
1873 | /*! | - |
1874 | \reimp | - |
1875 | */ | - |
1876 | QModelIndex QSortFilterProxyModel::sibling(int row, int column, const QModelIndex &idx) const | - |
1877 | { | - |
1878 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
1879 | if (!d->indexValid(idx)) evaluated: !d->indexValid(idx) yes Evaluation Count:41 | yes Evaluation Count:16736 |
| 41-16736 |
1880 | return QModelIndex(); executed: return QModelIndex(); Execution Count:41 | 41 |
1881 | | - |
1882 | const IndexMap::const_iterator it = d->index_to_iterator(idx); executed (the execution status of this line is deduced): const IndexMap::const_iterator it = d->index_to_iterator(idx); | - |
1883 | if (it.value()->source_rows.count() <= row || it.value()->source_columns.count() <= column) partially evaluated: it.value()->source_rows.count() <= row no Evaluation Count:0 | yes Evaluation Count:16736 |
partially evaluated: it.value()->source_columns.count() <= column no Evaluation Count:0 | yes Evaluation Count:16736 |
| 0-16736 |
1884 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
1885 | | - |
1886 | return d->create_index(row, column, it); executed: return d->create_index(row, column, it); Execution Count:16736 | 16736 |
1887 | } | - |
1888 | | - |
1889 | /*! | - |
1890 | \reimp | - |
1891 | */ | - |
1892 | int QSortFilterProxyModel::rowCount(const QModelIndex &parent) const | - |
1893 | { | - |
1894 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
1895 | QModelIndex source_parent = mapToSource(parent); executed (the execution status of this line is deduced): QModelIndex source_parent = mapToSource(parent); | - |
1896 | if (parent.isValid() && !source_parent.isValid()) evaluated: parent.isValid() yes Evaluation Count:6589 | yes Evaluation Count:38485 |
partially evaluated: !source_parent.isValid() no Evaluation Count:0 | yes Evaluation Count:6589 |
| 0-38485 |
1897 | return 0; never executed: return 0; | 0 |
1898 | IndexMap::const_iterator it = d->create_mapping(source_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it = d->create_mapping(source_parent); | - |
1899 | return it.value()->source_rows.count(); executed: return it.value()->source_rows.count(); Execution Count:45074 | 45074 |
1900 | } | - |
1901 | | - |
1902 | /*! | - |
1903 | \reimp | - |
1904 | */ | - |
1905 | int QSortFilterProxyModel::columnCount(const QModelIndex &parent) const | - |
1906 | { | - |
1907 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
1908 | QModelIndex source_parent = mapToSource(parent); executed (the execution status of this line is deduced): QModelIndex source_parent = mapToSource(parent); | - |
1909 | if (parent.isValid() && !source_parent.isValid()) evaluated: parent.isValid() yes Evaluation Count:6362 | yes Evaluation Count:4337 |
partially evaluated: !source_parent.isValid() no Evaluation Count:0 | yes Evaluation Count:6362 |
| 0-6362 |
1910 | return 0; never executed: return 0; | 0 |
1911 | IndexMap::const_iterator it = d->create_mapping(source_parent); executed (the execution status of this line is deduced): IndexMap::const_iterator it = d->create_mapping(source_parent); | - |
1912 | return it.value()->source_columns.count(); executed: return it.value()->source_columns.count(); Execution Count:10699 | 10699 |
1913 | } | - |
1914 | | - |
1915 | /*! | - |
1916 | \reimp | - |
1917 | */ | - |
1918 | bool QSortFilterProxyModel::hasChildren(const QModelIndex &parent) const | - |
1919 | { | - |
1920 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
1921 | QModelIndex source_parent = mapToSource(parent); executed (the execution status of this line is deduced): QModelIndex source_parent = mapToSource(parent); | - |
1922 | if (parent.isValid() && !source_parent.isValid()) evaluated: parent.isValid() yes Evaluation Count:8516 | yes Evaluation Count:302 |
partially evaluated: !source_parent.isValid() no Evaluation Count:0 | yes Evaluation Count:8516 |
| 0-8516 |
1923 | return false; never executed: return false; | 0 |
1924 | if (!d->model->hasChildren(source_parent)) evaluated: !d->model->hasChildren(source_parent) yes Evaluation Count:8305 | yes Evaluation Count:513 |
| 513-8305 |
1925 | return false; executed: return false; Execution Count:8305 | 8305 |
1926 | | - |
1927 | if (d->model->canFetchMore(source_parent)) evaluated: d->model->canFetchMore(source_parent) yes Evaluation Count:2 | yes Evaluation Count:511 |
| 2-511 |
1928 | return true; //we assume we might have children that can be fetched executed: return true; Execution Count:2 | 2 |
1929 | | - |
1930 | QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); | - |
1931 | return m->source_rows.count() != 0 && m->source_columns.count() != 0; executed: return m->source_rows.count() != 0 && m->source_columns.count() != 0; Execution Count:511 | 511 |
1932 | } | - |
1933 | | - |
1934 | /*! | - |
1935 | \reimp | - |
1936 | */ | - |
1937 | QVariant QSortFilterProxyModel::data(const QModelIndex &index, int role) const | - |
1938 | { | - |
1939 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
1940 | QModelIndex source_index = mapToSource(index); executed (the execution status of this line is deduced): QModelIndex source_index = mapToSource(index); | - |
1941 | if (index.isValid() && !source_index.isValid()) evaluated: index.isValid() yes Evaluation Count:41856 | yes Evaluation Count:102 |
partially evaluated: !source_index.isValid() no Evaluation Count:0 | yes Evaluation Count:41856 |
| 0-41856 |
1942 | return QVariant(); never executed: return QVariant(); | 0 |
1943 | return d->model->data(source_index, role); executed: return d->model->data(source_index, role); Execution Count:41958 | 41958 |
1944 | } | - |
1945 | | - |
1946 | /*! | - |
1947 | \reimp | - |
1948 | */ | - |
1949 | bool QSortFilterProxyModel::setData(const QModelIndex &index, const QVariant &value, int role) | - |
1950 | { | - |
1951 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
1952 | QModelIndex source_index = mapToSource(index); executed (the execution status of this line is deduced): QModelIndex source_index = mapToSource(index); | - |
1953 | if (index.isValid() && !source_index.isValid()) evaluated: index.isValid() yes Evaluation Count:6065 | yes Evaluation Count:77 |
partially evaluated: !source_index.isValid() no Evaluation Count:0 | yes Evaluation Count:6065 |
| 0-6065 |
1954 | return false; never executed: return false; | 0 |
1955 | return d->model->setData(source_index, value, role); executed: return d->model->setData(source_index, value, role); Execution Count:6142 | 6142 |
1956 | } | - |
1957 | | - |
1958 | /*! | - |
1959 | \reimp | - |
1960 | */ | - |
1961 | QVariant QSortFilterProxyModel::headerData(int section, Qt::Orientation orientation, int role) const | - |
1962 | { | - |
1963 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
1964 | IndexMap::const_iterator it = d->create_mapping(QModelIndex()); executed (the execution status of this line is deduced): IndexMap::const_iterator it = d->create_mapping(QModelIndex()); | - |
1965 | if (it.value()->source_rows.count() * it.value()->source_columns.count() > 0) evaluated: it.value()->source_rows.count() * it.value()->source_columns.count() > 0 yes Evaluation Count:2068 | yes Evaluation Count:53 |
| 53-2068 |
1966 | return QAbstractProxyModel::headerData(section, orientation, role); executed: return QAbstractProxyModel::headerData(section, orientation, role); Execution Count:2068 | 2068 |
1967 | int source_section; executed (the execution status of this line is deduced): int source_section; | - |
1968 | if (orientation == Qt::Vertical) { partially evaluated: orientation == Qt::Vertical no Evaluation Count:0 | yes Evaluation Count:53 |
| 0-53 |
1969 | if (section < 0 || section >= it.value()->source_rows.count()) never evaluated: section < 0 never evaluated: section >= it.value()->source_rows.count() | 0 |
1970 | return QVariant(); never executed: return QVariant(); | 0 |
1971 | source_section = it.value()->source_rows.at(section); never executed (the execution status of this line is deduced): source_section = it.value()->source_rows.at(section); | - |
1972 | } else { | 0 |
1973 | if (section < 0 || section >= it.value()->source_columns.count()) partially evaluated: section < 0 no Evaluation Count:0 | yes Evaluation Count:53 |
evaluated: section >= it.value()->source_columns.count() yes Evaluation Count:5 | yes Evaluation Count:48 |
| 0-53 |
1974 | return QVariant(); executed: return QVariant(); Execution Count:5 | 5 |
1975 | source_section = it.value()->source_columns.at(section); executed (the execution status of this line is deduced): source_section = it.value()->source_columns.at(section); | - |
1976 | } executed: } Execution Count:48 | 48 |
1977 | return d->model->headerData(source_section, orientation, role); executed: return d->model->headerData(source_section, orientation, role); Execution Count:48 | 48 |
1978 | } | - |
1979 | | - |
1980 | /*! | - |
1981 | \reimp | - |
1982 | */ | - |
1983 | bool QSortFilterProxyModel::setHeaderData(int section, Qt::Orientation orientation, | - |
1984 | const QVariant &value, int role) | - |
1985 | { | - |
1986 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
1987 | IndexMap::const_iterator it = d->create_mapping(QModelIndex()); executed (the execution status of this line is deduced): IndexMap::const_iterator it = d->create_mapping(QModelIndex()); | - |
1988 | if (it.value()->source_rows.count() * it.value()->source_columns.count() > 0) evaluated: it.value()->source_rows.count() * it.value()->source_columns.count() > 0 yes Evaluation Count:88 | yes Evaluation Count:19 |
| 19-88 |
1989 | return QAbstractProxyModel::setHeaderData(section, orientation, value, role); executed: return QAbstractProxyModel::setHeaderData(section, orientation, value, role); Execution Count:88 | 88 |
1990 | int source_section; executed (the execution status of this line is deduced): int source_section; | - |
1991 | if (orientation == Qt::Vertical) { evaluated: orientation == Qt::Vertical yes Evaluation Count:1 | yes Evaluation Count:18 |
| 1-18 |
1992 | if (section < 0 || section >= it.value()->source_rows.count()) partially evaluated: section < 0 yes Evaluation Count:1 | no Evaluation Count:0 |
never evaluated: section >= it.value()->source_rows.count() | 0-1 |
1993 | return false; executed: return false; Execution Count:1 | 1 |
1994 | source_section = it.value()->source_rows.at(section); never executed (the execution status of this line is deduced): source_section = it.value()->source_rows.at(section); | - |
1995 | } else { | 0 |
1996 | if (section < 0 || section >= it.value()->source_columns.count()) evaluated: section < 0 yes Evaluation Count:9 | yes Evaluation Count:9 |
partially evaluated: section >= it.value()->source_columns.count() yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
1997 | return false; executed: return false; Execution Count:18 | 18 |
1998 | source_section = it.value()->source_columns.at(section); never executed (the execution status of this line is deduced): source_section = it.value()->source_columns.at(section); | - |
1999 | } | 0 |
2000 | return d->model->setHeaderData(source_section, orientation, value, role); never executed: return d->model->setHeaderData(source_section, orientation, value, role); | 0 |
2001 | } | - |
2002 | | - |
2003 | /*! | - |
2004 | \reimp | - |
2005 | */ | - |
2006 | QMimeData *QSortFilterProxyModel::mimeData(const QModelIndexList &indexes) const | - |
2007 | { | - |
2008 | Q_D(const QSortFilterProxyModel); never executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2009 | QModelIndexList source_indexes; never executed (the execution status of this line is deduced): QModelIndexList source_indexes; | - |
2010 | for (int i = 0; i < indexes.count(); ++i) never evaluated: i < indexes.count() | 0 |
2011 | source_indexes << mapToSource(indexes.at(i)); never executed: source_indexes << mapToSource(indexes.at(i)); | 0 |
2012 | return d->model->mimeData(source_indexes); never executed: return d->model->mimeData(source_indexes); | 0 |
2013 | } | - |
2014 | | - |
2015 | /*! | - |
2016 | \reimp | - |
2017 | */ | - |
2018 | QStringList QSortFilterProxyModel::mimeTypes() const | - |
2019 | { | - |
2020 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2021 | return d->model->mimeTypes(); executed: return d->model->mimeTypes(); Execution Count:41 | 41 |
2022 | } | - |
2023 | | - |
2024 | /*! | - |
2025 | \reimp | - |
2026 | */ | - |
2027 | Qt::DropActions QSortFilterProxyModel::supportedDropActions() const | - |
2028 | { | - |
2029 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2030 | return d->model->supportedDropActions(); executed: return d->model->supportedDropActions(); Execution Count:41 | 41 |
2031 | } | - |
2032 | | - |
2033 | /*! | - |
2034 | \reimp | - |
2035 | */ | - |
2036 | bool QSortFilterProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, | - |
2037 | int row, int column, const QModelIndex &parent) | - |
2038 | { | - |
2039 | Q_D(QSortFilterProxyModel); never executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2040 | if ((row == -1) && (column == -1)) never evaluated: (row == -1) never evaluated: (column == -1) | 0 |
2041 | return d->model->dropMimeData(data, action, -1, -1, mapToSource(parent)); never executed: return d->model->dropMimeData(data, action, -1, -1, mapToSource(parent)); | 0 |
2042 | int source_destination_row = -1; never executed (the execution status of this line is deduced): int source_destination_row = -1; | - |
2043 | int source_destination_column = -1; never executed (the execution status of this line is deduced): int source_destination_column = -1; | - |
2044 | QModelIndex source_parent; never executed (the execution status of this line is deduced): QModelIndex source_parent; | - |
2045 | if (row == rowCount(parent)) { never evaluated: row == rowCount(parent) | 0 |
2046 | source_parent = mapToSource(parent); never executed (the execution status of this line is deduced): source_parent = mapToSource(parent); | - |
2047 | source_destination_row = d->model->rowCount(source_parent); never executed (the execution status of this line is deduced): source_destination_row = d->model->rowCount(source_parent); | - |
2048 | } else { | 0 |
2049 | QModelIndex proxy_index = index(row, column, parent); never executed (the execution status of this line is deduced): QModelIndex proxy_index = index(row, column, parent); | - |
2050 | QModelIndex source_index = mapToSource(proxy_index); never executed (the execution status of this line is deduced): QModelIndex source_index = mapToSource(proxy_index); | - |
2051 | source_destination_row = source_index.row(); never executed (the execution status of this line is deduced): source_destination_row = source_index.row(); | - |
2052 | source_destination_column = source_index.column(); never executed (the execution status of this line is deduced): source_destination_column = source_index.column(); | - |
2053 | source_parent = source_index.parent(); never executed (the execution status of this line is deduced): source_parent = source_index.parent(); | - |
2054 | } | 0 |
2055 | return d->model->dropMimeData(data, action, source_destination_row, never executed: return d->model->dropMimeData(data, action, source_destination_row, source_destination_column, source_parent); | 0 |
2056 | source_destination_column, source_parent); never executed: return d->model->dropMimeData(data, action, source_destination_row, source_destination_column, source_parent); | 0 |
2057 | } | - |
2058 | | - |
2059 | /*! | - |
2060 | \reimp | - |
2061 | */ | - |
2062 | bool QSortFilterProxyModel::insertRows(int row, int count, const QModelIndex &parent) | - |
2063 | { | - |
2064 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2065 | if (row < 0 || count <= 0) evaluated: row < 0 yes Evaluation Count:9 | yes Evaluation Count:51 |
evaluated: count <= 0 yes Evaluation Count:21 | yes Evaluation Count:30 |
| 9-51 |
2066 | return false; executed: return false; Execution Count:30 | 30 |
2067 | QModelIndex source_parent = mapToSource(parent); executed (the execution status of this line is deduced): QModelIndex source_parent = mapToSource(parent); | - |
2068 | if (parent.isValid() && !source_parent.isValid()) evaluated: parent.isValid() yes Evaluation Count:27 | yes Evaluation Count:3 |
partially evaluated: !source_parent.isValid() no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
2069 | return false; never executed: return false; | 0 |
2070 | QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); | - |
2071 | if (row > m->source_rows.count()) evaluated: row > m->source_rows.count() yes Evaluation Count:6 | yes Evaluation Count:24 |
| 6-24 |
2072 | return false; executed: return false; Execution Count:6 | 6 |
2073 | int source_row = (row >= m->source_rows.count() evaluated: row >= m->source_rows.count() yes Evaluation Count:1 | yes Evaluation Count:23 |
| 1-23 |
2074 | ? m->source_rows.count() executed (the execution status of this line is deduced): ? m->source_rows.count() | - |
2075 | : m->source_rows.at(row)); executed (the execution status of this line is deduced): : m->source_rows.at(row)); | - |
2076 | return d->model->insertRows(source_row, count, source_parent); executed: return d->model->insertRows(source_row, count, source_parent); Execution Count:24 | 24 |
2077 | } | - |
2078 | | - |
2079 | /*! | - |
2080 | \reimp | - |
2081 | */ | - |
2082 | bool QSortFilterProxyModel::insertColumns(int column, int count, const QModelIndex &parent) | - |
2083 | { | - |
2084 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2085 | if (column < 0|| count <= 0) evaluated: column < 0 yes Evaluation Count:9 | yes Evaluation Count:48 |
evaluated: count <= 0 yes Evaluation Count:21 | yes Evaluation Count:27 |
| 9-48 |
2086 | return false; executed: return false; Execution Count:30 | 30 |
2087 | QModelIndex source_parent = mapToSource(parent); executed (the execution status of this line is deduced): QModelIndex source_parent = mapToSource(parent); | - |
2088 | if (parent.isValid() && !source_parent.isValid()) partially evaluated: parent.isValid() yes Evaluation Count:27 | no Evaluation Count:0 |
partially evaluated: !source_parent.isValid() no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
2089 | return false; never executed: return false; | 0 |
2090 | QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); | - |
2091 | if (column > m->source_columns.count()) evaluated: column > m->source_columns.count() yes Evaluation Count:6 | yes Evaluation Count:21 |
| 6-21 |
2092 | return false; executed: return false; Execution Count:6 | 6 |
2093 | int source_column = (column >= m->source_columns.count() partially evaluated: column >= m->source_columns.count() no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
2094 | ? m->source_columns.count() executed (the execution status of this line is deduced): ? m->source_columns.count() | - |
2095 | : m->source_columns.at(column)); executed (the execution status of this line is deduced): : m->source_columns.at(column)); | - |
2096 | return d->model->insertColumns(source_column, count, source_parent); executed: return d->model->insertColumns(source_column, count, source_parent); Execution Count:21 | 21 |
2097 | } | - |
2098 | | - |
2099 | /*! | - |
2100 | \reimp | - |
2101 | */ | - |
2102 | bool QSortFilterProxyModel::removeRows(int row, int count, const QModelIndex &parent) | - |
2103 | { | - |
2104 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2105 | if (row < 0 || count <= 0) evaluated: row < 0 yes Evaluation Count:13 | yes Evaluation Count:65 |
evaluated: count <= 0 yes Evaluation Count:21 | yes Evaluation Count:44 |
| 13-65 |
2106 | return false; executed: return false; Execution Count:34 | 34 |
2107 | QModelIndex source_parent = mapToSource(parent); executed (the execution status of this line is deduced): QModelIndex source_parent = mapToSource(parent); | - |
2108 | if (parent.isValid() && !source_parent.isValid()) evaluated: parent.isValid() yes Evaluation Count:33 | yes Evaluation Count:11 |
partially evaluated: !source_parent.isValid() no Evaluation Count:0 | yes Evaluation Count:33 |
| 0-33 |
2109 | return false; never executed: return false; | 0 |
2110 | QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); | - |
2111 | if (row + count > m->source_rows.count()) evaluated: row + count > m->source_rows.count() yes Evaluation Count:13 | yes Evaluation Count:31 |
| 13-31 |
2112 | return false; executed: return false; Execution Count:13 | 13 |
2113 | if ((count == 1) evaluated: (count == 1) yes Evaluation Count:14 | yes Evaluation Count:17 |
| 14-17 |
2114 | || ((d->source_sort_column < 0) && (m->proxy_rows.count() == m->source_rows.count()))) { evaluated: (d->source_sort_column < 0) yes Evaluation Count:14 | yes Evaluation Count:3 |
partially evaluated: (m->proxy_rows.count() == m->source_rows.count()) yes Evaluation Count:14 | no Evaluation Count:0 |
| 0-14 |
2115 | int source_row = m->source_rows.at(row); executed (the execution status of this line is deduced): int source_row = m->source_rows.at(row); | - |
2116 | return d->model->removeRows(source_row, count, source_parent); executed: return d->model->removeRows(source_row, count, source_parent); Execution Count:28 | 28 |
2117 | } | - |
2118 | // remove corresponding source intervals | - |
2119 | // ### if this proves to be slow, we can switch to single-row removal | - |
2120 | QVector<int> rows; executed (the execution status of this line is deduced): QVector<int> rows; | - |
2121 | for (int i = row; i < row + count; ++i) evaluated: i < row + count yes Evaluation Count:9 | yes Evaluation Count:3 |
| 3-9 |
2122 | rows.append(m->source_rows.at(i)); executed: rows.append(m->source_rows.at(i)); Execution Count:9 | 9 |
2123 | std::sort(rows.begin(), rows.end()); executed (the execution status of this line is deduced): std::sort(rows.begin(), rows.end()); | - |
2124 | | - |
2125 | int pos = rows.count() - 1; executed (the execution status of this line is deduced): int pos = rows.count() - 1; | - |
2126 | bool ok = true; executed (the execution status of this line is deduced): bool ok = true; | - |
2127 | while (pos >= 0) { evaluated: pos >= 0 yes Evaluation Count:4 | yes Evaluation Count:3 |
| 3-4 |
2128 | const int source_end = rows.at(pos--); executed (the execution status of this line is deduced): const int source_end = rows.at(pos--); | - |
2129 | int source_start = source_end; executed (the execution status of this line is deduced): int source_start = source_end; | - |
2130 | while ((pos >= 0) && (rows.at(pos) == (source_start - 1))) { evaluated: (pos >= 0) yes Evaluation Count:6 | yes Evaluation Count:3 |
evaluated: (rows.at(pos) == (source_start - 1)) yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-6 |
2131 | --source_start; executed (the execution status of this line is deduced): --source_start; | - |
2132 | --pos; executed (the execution status of this line is deduced): --pos; | - |
2133 | } executed: } Execution Count:5 | 5 |
2134 | ok = ok && d->model->removeRows(source_start, source_end - source_start + 1, partially evaluated: ok yes Evaluation Count:4 | no Evaluation Count:0 |
partially evaluated: d->model->removeRows(source_start, source_end - source_start + 1, source_parent) yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
2135 | source_parent); partially evaluated: d->model->removeRows(source_start, source_end - source_start + 1, source_parent) yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
2136 | } executed: } Execution Count:4 | 4 |
2137 | return ok; executed: return ok; Execution Count:3 | 3 |
2138 | } | - |
2139 | | - |
2140 | /*! | - |
2141 | \reimp | - |
2142 | */ | - |
2143 | bool QSortFilterProxyModel::removeColumns(int column, int count, const QModelIndex &parent) | - |
2144 | { | - |
2145 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2146 | if (column < 0 || count <= 0) evaluated: column < 0 yes Evaluation Count:13 | yes Evaluation Count:62 |
evaluated: count <= 0 yes Evaluation Count:21 | yes Evaluation Count:41 |
| 13-62 |
2147 | return false; executed: return false; Execution Count:34 | 34 |
2148 | QModelIndex source_parent = mapToSource(parent); executed (the execution status of this line is deduced): QModelIndex source_parent = mapToSource(parent); | - |
2149 | if (parent.isValid() && !source_parent.isValid()) evaluated: parent.isValid() yes Evaluation Count:33 | yes Evaluation Count:8 |
partially evaluated: !source_parent.isValid() no Evaluation Count:0 | yes Evaluation Count:33 |
| 0-33 |
2150 | return false; never executed: return false; | 0 |
2151 | QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); | - |
2152 | if (column + count > m->source_columns.count()) evaluated: column + count > m->source_columns.count() yes Evaluation Count:14 | yes Evaluation Count:27 |
| 14-27 |
2153 | return false; executed: return false; Execution Count:14 | 14 |
2154 | if ((count == 1) || (m->proxy_columns.count() == m->source_columns.count())) { evaluated: (count == 1) yes Evaluation Count:13 | yes Evaluation Count:14 |
evaluated: (m->proxy_columns.count() == m->source_columns.count()) yes Evaluation Count:13 | yes Evaluation Count:1 |
| 1-14 |
2155 | int source_column = m->source_columns.at(column); executed (the execution status of this line is deduced): int source_column = m->source_columns.at(column); | - |
2156 | return d->model->removeColumns(source_column, count, source_parent); executed: return d->model->removeColumns(source_column, count, source_parent); Execution Count:26 | 26 |
2157 | } | - |
2158 | // remove corresponding source intervals | - |
2159 | QVector<int> columns; executed (the execution status of this line is deduced): QVector<int> columns; | - |
2160 | for (int i = column; i < column + count; ++i) evaluated: i < column + count yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
2161 | columns.append(m->source_columns.at(i)); executed: columns.append(m->source_columns.at(i)); Execution Count:3 | 3 |
2162 | | - |
2163 | int pos = columns.count() - 1; executed (the execution status of this line is deduced): int pos = columns.count() - 1; | - |
2164 | bool ok = true; executed (the execution status of this line is deduced): bool ok = true; | - |
2165 | while (pos >= 0) { evaluated: pos >= 0 yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
2166 | const int source_end = columns.at(pos--); executed (the execution status of this line is deduced): const int source_end = columns.at(pos--); | - |
2167 | int source_start = source_end; executed (the execution status of this line is deduced): int source_start = source_end; | - |
2168 | while ((pos >= 0) && (columns.at(pos) == (source_start - 1))) { evaluated: (pos >= 0) yes Evaluation Count:2 | yes Evaluation Count:1 |
partially evaluated: (columns.at(pos) == (source_start - 1)) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2169 | --source_start; never executed (the execution status of this line is deduced): --source_start; | - |
2170 | --pos; never executed (the execution status of this line is deduced): --pos; | - |
2171 | } | 0 |
2172 | ok = ok && d->model->removeColumns(source_start, source_end - source_start + 1, partially evaluated: ok yes Evaluation Count:3 | no Evaluation Count:0 |
partially evaluated: d->model->removeColumns(source_start, source_end - source_start + 1, source_parent) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2173 | source_parent); partially evaluated: d->model->removeColumns(source_start, source_end - source_start + 1, source_parent) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2174 | } executed: } Execution Count:3 | 3 |
2175 | return ok; executed: return ok; Execution Count:1 | 1 |
2176 | } | - |
2177 | | - |
2178 | /*! | - |
2179 | \reimp | - |
2180 | */ | - |
2181 | void QSortFilterProxyModel::fetchMore(const QModelIndex &parent) | - |
2182 | { | - |
2183 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2184 | QModelIndex source_parent; executed (the execution status of this line is deduced): QModelIndex source_parent; | - |
2185 | if (d->indexValid(parent)) evaluated: d->indexValid(parent) yes Evaluation Count:1 | yes Evaluation Count:43 |
| 1-43 |
2186 | source_parent = mapToSource(parent); executed: source_parent = mapToSource(parent); Execution Count:1 | 1 |
2187 | d->model->fetchMore(source_parent); executed (the execution status of this line is deduced): d->model->fetchMore(source_parent); | - |
2188 | } executed: } Execution Count:44 | 44 |
2189 | | - |
2190 | /*! | - |
2191 | \reimp | - |
2192 | */ | - |
2193 | bool QSortFilterProxyModel::canFetchMore(const QModelIndex &parent) const | - |
2194 | { | - |
2195 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2196 | QModelIndex source_parent; executed (the execution status of this line is deduced): QModelIndex source_parent; | - |
2197 | if (d->indexValid(parent)) evaluated: d->indexValid(parent) yes Evaluation Count:214 | yes Evaluation Count:403 |
| 214-403 |
2198 | source_parent = mapToSource(parent); executed: source_parent = mapToSource(parent); Execution Count:214 | 214 |
2199 | return d->model->canFetchMore(source_parent); executed: return d->model->canFetchMore(source_parent); Execution Count:617 | 617 |
2200 | } | - |
2201 | | - |
2202 | /*! | - |
2203 | \reimp | - |
2204 | */ | - |
2205 | Qt::ItemFlags QSortFilterProxyModel::flags(const QModelIndex &index) const | - |
2206 | { | - |
2207 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2208 | QModelIndex source_index; executed (the execution status of this line is deduced): QModelIndex source_index; | - |
2209 | if (d->indexValid(index)) evaluated: d->indexValid(index) yes Evaluation Count:1663 | yes Evaluation Count:41 |
| 41-1663 |
2210 | source_index = mapToSource(index); executed: source_index = mapToSource(index); Execution Count:1663 | 1663 |
2211 | return d->model->flags(source_index); executed: return d->model->flags(source_index); Execution Count:1704 | 1704 |
2212 | } | - |
2213 | | - |
2214 | /*! | - |
2215 | \reimp | - |
2216 | */ | - |
2217 | QModelIndex QSortFilterProxyModel::buddy(const QModelIndex &index) const | - |
2218 | { | - |
2219 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2220 | if (!d->indexValid(index)) evaluated: !d->indexValid(index) yes Evaluation Count:41 | yes Evaluation Count:31 |
| 31-41 |
2221 | return QModelIndex(); executed: return QModelIndex(); Execution Count:41 | 41 |
2222 | QModelIndex source_index = mapToSource(index); executed (the execution status of this line is deduced): QModelIndex source_index = mapToSource(index); | - |
2223 | QModelIndex source_buddy = d->model->buddy(source_index); executed (the execution status of this line is deduced): QModelIndex source_buddy = d->model->buddy(source_index); | - |
2224 | if (source_index == source_buddy) partially evaluated: source_index == source_buddy yes Evaluation Count:31 | no Evaluation Count:0 |
| 0-31 |
2225 | return index; executed: return index; Execution Count:31 | 31 |
2226 | return mapFromSource(source_buddy); never executed: return mapFromSource(source_buddy); | 0 |
2227 | } | - |
2228 | | - |
2229 | /*! | - |
2230 | \reimp | - |
2231 | */ | - |
2232 | QModelIndexList QSortFilterProxyModel::match(const QModelIndex &start, int role, | - |
2233 | const QVariant &value, int hits, | - |
2234 | Qt::MatchFlags flags) const | - |
2235 | { | - |
2236 | return QAbstractProxyModel::match(start, role, value, hits, flags); executed: return QAbstractProxyModel::match(start, role, value, hits, flags); Execution Count:47 | 47 |
2237 | } | - |
2238 | | - |
2239 | /*! | - |
2240 | \reimp | - |
2241 | */ | - |
2242 | QSize QSortFilterProxyModel::span(const QModelIndex &index) const | - |
2243 | { | - |
2244 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2245 | QModelIndex source_index = mapToSource(index); executed (the execution status of this line is deduced): QModelIndex source_index = mapToSource(index); | - |
2246 | if (index.isValid() && !source_index.isValid()) partially evaluated: index.isValid() no Evaluation Count:0 | yes Evaluation Count:41 |
never evaluated: !source_index.isValid() | 0-41 |
2247 | return QSize(); never executed: return QSize(); | 0 |
2248 | return d->model->span(source_index); executed: return d->model->span(source_index); Execution Count:41 | 41 |
2249 | } | - |
2250 | | - |
2251 | /*! | - |
2252 | \reimp | - |
2253 | */ | - |
2254 | void QSortFilterProxyModel::sort(int column, Qt::SortOrder order) | - |
2255 | { | - |
2256 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2257 | if (d->dynamic_sortfilter && d->proxy_sort_column == column && d->sort_order == order) evaluated: d->dynamic_sortfilter yes Evaluation Count:192 | yes Evaluation Count:5 |
evaluated: d->proxy_sort_column == column yes Evaluation Count:108 | yes Evaluation Count:84 |
evaluated: d->sort_order == order yes Evaluation Count:106 | yes Evaluation Count:2 |
| 2-192 |
2258 | return; executed: return; Execution Count:106 | 106 |
2259 | d->sort_order = order; executed (the execution status of this line is deduced): d->sort_order = order; | - |
2260 | d->proxy_sort_column = column; executed (the execution status of this line is deduced): d->proxy_sort_column = column; | - |
2261 | d->update_source_sort_column(); executed (the execution status of this line is deduced): d->update_source_sort_column(); | - |
2262 | d->sort(); executed (the execution status of this line is deduced): d->sort(); | - |
2263 | } executed: } Execution Count:91 | 91 |
2264 | | - |
2265 | /*! | - |
2266 | \since 4.5 | - |
2267 | \brief the column currently used for sorting | - |
2268 | | - |
2269 | This returns the most recently used sort column. | - |
2270 | */ | - |
2271 | int QSortFilterProxyModel::sortColumn() const | - |
2272 | { | - |
2273 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2274 | return d->proxy_sort_column; executed: return d->proxy_sort_column; Execution Count:13 | 13 |
2275 | } | - |
2276 | | - |
2277 | /*! | - |
2278 | \since 4.5 | - |
2279 | \brief the order currently used for sorting | - |
2280 | | - |
2281 | This returns the most recently used sort order. | - |
2282 | */ | - |
2283 | Qt::SortOrder QSortFilterProxyModel::sortOrder() const | - |
2284 | { | - |
2285 | Q_D(const QSortFilterProxyModel); never executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2286 | return d->sort_order; never executed: return d->sort_order; | 0 |
2287 | } | - |
2288 | | - |
2289 | /*! | - |
2290 | \property QSortFilterProxyModel::filterRegExp | - |
2291 | \brief the QRegExp used to filter the contents of the source model | - |
2292 | | - |
2293 | Setting this property overwrites the current | - |
2294 | \l{QSortFilterProxyModel::filterCaseSensitivity}{filterCaseSensitivity}. | - |
2295 | By default, the QRegExp is an empty string matching all contents. | - |
2296 | | - |
2297 | If no QRegExp or an empty string is set, everything in the source model | - |
2298 | will be accepted. | - |
2299 | | - |
2300 | \sa filterCaseSensitivity, setFilterWildcard(), setFilterFixedString() | - |
2301 | */ | - |
2302 | QRegExp QSortFilterProxyModel::filterRegExp() const | - |
2303 | { | - |
2304 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2305 | return d->filter_regexp; executed: return d->filter_regexp; Execution Count:45 | 45 |
2306 | } | - |
2307 | | - |
2308 | void QSortFilterProxyModel::setFilterRegExp(const QRegExp ®Exp) | - |
2309 | { | - |
2310 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2311 | d->filter_regexp = regExp; executed (the execution status of this line is deduced): d->filter_regexp = regExp; | - |
2312 | d->filter_changed(); executed (the execution status of this line is deduced): d->filter_changed(); | - |
2313 | } executed: } Execution Count:164 | 164 |
2314 | | - |
2315 | /*! | - |
2316 | \property QSortFilterProxyModel::filterKeyColumn | - |
2317 | \brief the column where the key used to filter the contents of the | - |
2318 | source model is read from. | - |
2319 | | - |
2320 | The default value is 0. If the value is -1, the keys will be read | - |
2321 | from all columns. | - |
2322 | */ | - |
2323 | int QSortFilterProxyModel::filterKeyColumn() const | - |
2324 | { | - |
2325 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2326 | return d->filter_column; executed: return d->filter_column; Execution Count:3 | 3 |
2327 | } | - |
2328 | | - |
2329 | void QSortFilterProxyModel::setFilterKeyColumn(int column) | - |
2330 | { | - |
2331 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2332 | d->filter_column = column; executed (the execution status of this line is deduced): d->filter_column = column; | - |
2333 | d->filter_changed(); executed (the execution status of this line is deduced): d->filter_changed(); | - |
2334 | } executed: } Execution Count:6 | 6 |
2335 | | - |
2336 | /*! | - |
2337 | \property QSortFilterProxyModel::filterCaseSensitivity | - |
2338 | | - |
2339 | \brief the case sensitivity of the QRegExp pattern used to filter the | - |
2340 | contents of the source model | - |
2341 | | - |
2342 | By default, the filter is case sensitive. | - |
2343 | | - |
2344 | \sa filterRegExp, sortCaseSensitivity | - |
2345 | */ | - |
2346 | Qt::CaseSensitivity QSortFilterProxyModel::filterCaseSensitivity() const | - |
2347 | { | - |
2348 | Q_D(const QSortFilterProxyModel); never executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2349 | return d->filter_regexp.caseSensitivity(); never executed: return d->filter_regexp.caseSensitivity(); | 0 |
2350 | } | - |
2351 | | - |
2352 | void QSortFilterProxyModel::setFilterCaseSensitivity(Qt::CaseSensitivity cs) | - |
2353 | { | - |
2354 | Q_D(QSortFilterProxyModel); never executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2355 | if (cs == d->filter_regexp.caseSensitivity()) never evaluated: cs == d->filter_regexp.caseSensitivity() | 0 |
2356 | return; | 0 |
2357 | d->filter_regexp.setCaseSensitivity(cs); never executed (the execution status of this line is deduced): d->filter_regexp.setCaseSensitivity(cs); | - |
2358 | d->filter_changed(); never executed (the execution status of this line is deduced): d->filter_changed(); | - |
2359 | } | 0 |
2360 | | - |
2361 | /*! | - |
2362 | \since 4.2 | - |
2363 | \property QSortFilterProxyModel::sortCaseSensitivity | - |
2364 | \brief the case sensitivity setting used for comparing strings when sorting | - |
2365 | | - |
2366 | By default, sorting is case sensitive. | - |
2367 | | - |
2368 | \sa filterCaseSensitivity, lessThan() | - |
2369 | */ | - |
2370 | Qt::CaseSensitivity QSortFilterProxyModel::sortCaseSensitivity() const | - |
2371 | { | - |
2372 | Q_D(const QSortFilterProxyModel); never executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2373 | return d->sort_casesensitivity; never executed: return d->sort_casesensitivity; | 0 |
2374 | } | - |
2375 | | - |
2376 | void QSortFilterProxyModel::setSortCaseSensitivity(Qt::CaseSensitivity cs) | - |
2377 | { | - |
2378 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2379 | if (d->sort_casesensitivity == cs) evaluated: d->sort_casesensitivity == cs yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
2380 | return; executed: return; Execution Count:3 | 3 |
2381 | | - |
2382 | d->sort_casesensitivity = cs; executed (the execution status of this line is deduced): d->sort_casesensitivity = cs; | - |
2383 | d->sort(); executed (the execution status of this line is deduced): d->sort(); | - |
2384 | } executed: } Execution Count:3 | 3 |
2385 | | - |
2386 | /*! | - |
2387 | \since 4.3 | - |
2388 | \property QSortFilterProxyModel::isSortLocaleAware | - |
2389 | \brief the local aware setting used for comparing strings when sorting | - |
2390 | | - |
2391 | By default, sorting is not local aware. | - |
2392 | | - |
2393 | \sa sortCaseSensitivity, lessThan() | - |
2394 | */ | - |
2395 | bool QSortFilterProxyModel::isSortLocaleAware() const | - |
2396 | { | - |
2397 | Q_D(const QSortFilterProxyModel); never executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2398 | return d->sort_localeaware; never executed: return d->sort_localeaware; | 0 |
2399 | } | - |
2400 | | - |
2401 | void QSortFilterProxyModel::setSortLocaleAware(bool on) | - |
2402 | { | - |
2403 | Q_D(QSortFilterProxyModel); never executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2404 | if (d->sort_localeaware == on) never evaluated: d->sort_localeaware == on | 0 |
2405 | return; | 0 |
2406 | | - |
2407 | d->sort_localeaware = on; never executed (the execution status of this line is deduced): d->sort_localeaware = on; | - |
2408 | d->sort(); never executed (the execution status of this line is deduced): d->sort(); | - |
2409 | } | 0 |
2410 | | - |
2411 | /*! | - |
2412 | \overload | - |
2413 | | - |
2414 | Sets the regular expression used to filter the contents | - |
2415 | of the source model to \a pattern. | - |
2416 | | - |
2417 | \sa setFilterCaseSensitivity(), setFilterWildcard(), setFilterFixedString(), filterRegExp() | - |
2418 | */ | - |
2419 | void QSortFilterProxyModel::setFilterRegExp(const QString &pattern) | - |
2420 | { | - |
2421 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2422 | d->filter_regexp.setPatternSyntax(QRegExp::RegExp); executed (the execution status of this line is deduced): d->filter_regexp.setPatternSyntax(QRegExp::RegExp); | - |
2423 | d->filter_regexp.setPattern(pattern); executed (the execution status of this line is deduced): d->filter_regexp.setPattern(pattern); | - |
2424 | d->filter_changed(); executed (the execution status of this line is deduced): d->filter_changed(); | - |
2425 | } executed: } Execution Count:35 | 35 |
2426 | | - |
2427 | /*! | - |
2428 | Sets the wildcard expression used to filter the contents | - |
2429 | of the source model to the given \a pattern. | - |
2430 | | - |
2431 | \sa setFilterCaseSensitivity(), setFilterRegExp(), setFilterFixedString(), filterRegExp() | - |
2432 | */ | - |
2433 | void QSortFilterProxyModel::setFilterWildcard(const QString &pattern) | - |
2434 | { | - |
2435 | Q_D(QSortFilterProxyModel); never executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2436 | d->filter_regexp.setPatternSyntax(QRegExp::Wildcard); never executed (the execution status of this line is deduced): d->filter_regexp.setPatternSyntax(QRegExp::Wildcard); | - |
2437 | d->filter_regexp.setPattern(pattern); never executed (the execution status of this line is deduced): d->filter_regexp.setPattern(pattern); | - |
2438 | d->filter_changed(); never executed (the execution status of this line is deduced): d->filter_changed(); | - |
2439 | } | 0 |
2440 | | - |
2441 | /*! | - |
2442 | Sets the fixed string used to filter the contents | - |
2443 | of the source model to the given \a pattern. | - |
2444 | | - |
2445 | \sa setFilterCaseSensitivity(), setFilterRegExp(), setFilterWildcard(), filterRegExp() | - |
2446 | */ | - |
2447 | void QSortFilterProxyModel::setFilterFixedString(const QString &pattern) | - |
2448 | { | - |
2449 | Q_D(QSortFilterProxyModel); never executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2450 | d->filter_regexp.setPatternSyntax(QRegExp::FixedString); never executed (the execution status of this line is deduced): d->filter_regexp.setPatternSyntax(QRegExp::FixedString); | - |
2451 | d->filter_regexp.setPattern(pattern); never executed (the execution status of this line is deduced): d->filter_regexp.setPattern(pattern); | - |
2452 | d->filter_changed(); never executed (the execution status of this line is deduced): d->filter_changed(); | - |
2453 | } | 0 |
2454 | | - |
2455 | /*! | - |
2456 | \since 4.2 | - |
2457 | \property QSortFilterProxyModel::dynamicSortFilter | - |
2458 | \brief whether the proxy model is dynamically sorted and filtered | - |
2459 | whenever the contents of the source model change | - |
2460 | | - |
2461 | Note that you should not update the source model through the proxy | - |
2462 | model when dynamicSortFilter is true. For instance, if you set the | - |
2463 | proxy model on a QComboBox, then using functions that update the | - |
2464 | model, e.g., \l{QComboBox::}{addItem()}, will not work as | - |
2465 | expected. An alternative is to set dynamicSortFilter to false and | - |
2466 | call \l{QSortFilterProxyModel::}{sort()} after adding items to the | - |
2467 | QComboBox. | - |
2468 | | - |
2469 | The default value is true. | - |
2470 | */ | - |
2471 | bool QSortFilterProxyModel::dynamicSortFilter() const | - |
2472 | { | - |
2473 | Q_D(const QSortFilterProxyModel); never executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2474 | return d->dynamic_sortfilter; never executed: return d->dynamic_sortfilter; | 0 |
2475 | } | - |
2476 | | - |
2477 | void QSortFilterProxyModel::setDynamicSortFilter(bool enable) | - |
2478 | { | - |
2479 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2480 | d->dynamic_sortfilter = enable; executed (the execution status of this line is deduced): d->dynamic_sortfilter = enable; | - |
2481 | if (enable) evaluated: enable yes Evaluation Count:22 | yes Evaluation Count:4 |
| 4-22 |
2482 | d->sort(); executed: d->sort(); Execution Count:22 | 22 |
2483 | } executed: } Execution Count:26 | 26 |
2484 | | - |
2485 | /*! | - |
2486 | \since 4.2 | - |
2487 | \property QSortFilterProxyModel::sortRole | - |
2488 | \brief the item role that is used to query the source model's data when sorting items | - |
2489 | | - |
2490 | The default value is Qt::DisplayRole. | - |
2491 | | - |
2492 | \sa lessThan() | - |
2493 | */ | - |
2494 | int QSortFilterProxyModel::sortRole() const | - |
2495 | { | - |
2496 | Q_D(const QSortFilterProxyModel); never executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2497 | return d->sort_role; never executed: return d->sort_role; | 0 |
2498 | } | - |
2499 | | - |
2500 | void QSortFilterProxyModel::setSortRole(int role) | - |
2501 | { | - |
2502 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2503 | if (d->sort_role == role) partially evaluated: d->sort_role == role no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
2504 | return; | 0 |
2505 | d->sort_role = role; executed (the execution status of this line is deduced): d->sort_role = role; | - |
2506 | d->sort(); executed (the execution status of this line is deduced): d->sort(); | - |
2507 | } executed: } Execution Count:1 | 1 |
2508 | | - |
2509 | /*! | - |
2510 | \since 4.2 | - |
2511 | \property QSortFilterProxyModel::filterRole | - |
2512 | \brief the item role that is used to query the source model's data when filtering items | - |
2513 | | - |
2514 | The default value is Qt::DisplayRole. | - |
2515 | | - |
2516 | \sa filterAcceptsRow() | - |
2517 | */ | - |
2518 | int QSortFilterProxyModel::filterRole() const | - |
2519 | { | - |
2520 | Q_D(const QSortFilterProxyModel); never executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2521 | return d->filter_role; never executed: return d->filter_role; | 0 |
2522 | } | - |
2523 | | - |
2524 | void QSortFilterProxyModel::setFilterRole(int role) | - |
2525 | { | - |
2526 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2527 | if (d->filter_role == role) partially evaluated: d->filter_role == role no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
2528 | return; | 0 |
2529 | d->filter_role = role; executed (the execution status of this line is deduced): d->filter_role = role; | - |
2530 | d->filter_changed(); executed (the execution status of this line is deduced): d->filter_changed(); | - |
2531 | } executed: } Execution Count:4 | 4 |
2532 | | - |
2533 | /*! | - |
2534 | \obsolete | - |
2535 | | - |
2536 | This function is obsolete. Use invalidate() instead. | - |
2537 | */ | - |
2538 | void QSortFilterProxyModel::clear() | - |
2539 | { | - |
2540 | Q_D(QSortFilterProxyModel); never executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2541 | emit layoutAboutToBeChanged(); never executed (the execution status of this line is deduced): layoutAboutToBeChanged(); | - |
2542 | d->_q_clearMapping(); never executed (the execution status of this line is deduced): d->_q_clearMapping(); | - |
2543 | emit layoutChanged(); never executed (the execution status of this line is deduced): layoutChanged(); | - |
2544 | } | 0 |
2545 | | - |
2546 | /*! | - |
2547 | \since 4.3 | - |
2548 | | - |
2549 | Invalidates the current sorting and filtering. | - |
2550 | | - |
2551 | \sa invalidateFilter() | - |
2552 | */ | - |
2553 | void QSortFilterProxyModel::invalidate() | - |
2554 | { | - |
2555 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2556 | emit layoutAboutToBeChanged(); executed (the execution status of this line is deduced): layoutAboutToBeChanged(); | - |
2557 | d->_q_clearMapping(); executed (the execution status of this line is deduced): d->_q_clearMapping(); | - |
2558 | emit layoutChanged(); executed (the execution status of this line is deduced): layoutChanged(); | - |
2559 | } executed: } Execution Count:5 | 5 |
2560 | | - |
2561 | /*! | - |
2562 | \obsolete | - |
2563 | | - |
2564 | This function is obsolete. Use invalidateFilter() instead. | - |
2565 | */ | - |
2566 | void QSortFilterProxyModel::filterChanged() | - |
2567 | { | - |
2568 | Q_D(QSortFilterProxyModel); never executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2569 | d->filter_changed(); never executed (the execution status of this line is deduced): d->filter_changed(); | - |
2570 | } | 0 |
2571 | | - |
2572 | /*! | - |
2573 | \since 4.3 | - |
2574 | | - |
2575 | Invalidates the current filtering. | - |
2576 | | - |
2577 | This function should be called if you are implementing custom filtering | - |
2578 | (e.g. filterAcceptsRow()), and your filter parameters have changed. | - |
2579 | | - |
2580 | \sa invalidate() | - |
2581 | */ | - |
2582 | void QSortFilterProxyModel::invalidateFilter() | - |
2583 | { | - |
2584 | Q_D(QSortFilterProxyModel); executed (the execution status of this line is deduced): QSortFilterProxyModelPrivate * const d = d_func(); | - |
2585 | d->filter_changed(); executed (the execution status of this line is deduced): d->filter_changed(); | - |
2586 | } executed: } Execution Count:3 | 3 |
2587 | | - |
2588 | /*! | - |
2589 | Returns true if the value of the item referred to by the given | - |
2590 | index \a left is less than the value of the item referred to by | - |
2591 | the given index \a right, otherwise returns false. | - |
2592 | | - |
2593 | This function is used as the < operator when sorting, and handles | - |
2594 | the following QVariant types: | - |
2595 | | - |
2596 | \list | - |
2597 | \li QVariant::Int | - |
2598 | \li QVariant::UInt | - |
2599 | \li QVariant::LongLong | - |
2600 | \li QVariant::ULongLong | - |
2601 | \li QVariant::Double | - |
2602 | \li QVariant::Char | - |
2603 | \li QVariant::Date | - |
2604 | \li QVariant::Time | - |
2605 | \li QVariant::DateTime | - |
2606 | \li QVariant::String | - |
2607 | \endlist | - |
2608 | | - |
2609 | Any other type will be converted to a QString using | - |
2610 | QVariant::toString(). | - |
2611 | | - |
2612 | Comparison of \l{QString}s is case sensitive by default; this can | - |
2613 | be changed using the \l {QSortFilterProxyModel::sortCaseSensitivity} | - |
2614 | {sortCaseSensitivity} property. | - |
2615 | | - |
2616 | By default, the Qt::DisplayRole associated with the | - |
2617 | \l{QModelIndex}es is used for comparisons. This can be changed by | - |
2618 | setting the \l {QSortFilterProxyModel::sortRole} {sortRole} property. | - |
2619 | | - |
2620 | \note The indices passed in correspond to the source model. | - |
2621 | | - |
2622 | \sa sortRole, sortCaseSensitivity, dynamicSortFilter | - |
2623 | */ | - |
2624 | bool QSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const | - |
2625 | { | - |
2626 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2627 | QVariant l = (left.model() ? left.model()->data(left, d->sort_role) : QVariant()); evaluated: left.model() yes Evaluation Count:87285 | yes Evaluation Count:3 |
| 3-87285 |
2628 | QVariant r = (right.model() ? right.model()->data(right, d->sort_role) : QVariant()); evaluated: right.model() yes Evaluation Count:87285 | yes Evaluation Count:3 |
| 3-87285 |
2629 | switch (l.userType()) { | - |
2630 | case QVariant::Invalid: | - |
2631 | return (r.type() != QVariant::Invalid); executed: return (r.type() != QVariant::Invalid); Execution Count:12986 | 12986 |
2632 | case QVariant::Int: | - |
2633 | return l.toInt() < r.toInt(); executed: return l.toInt() < r.toInt(); Execution Count:8 | 8 |
2634 | case QVariant::UInt: | - |
2635 | return l.toUInt() < r.toUInt(); never executed: return l.toUInt() < r.toUInt(); | 0 |
2636 | case QVariant::LongLong: | - |
2637 | return l.toLongLong() < r.toLongLong(); never executed: return l.toLongLong() < r.toLongLong(); | 0 |
2638 | case QVariant::ULongLong: | - |
2639 | return l.toULongLong() < r.toULongLong(); never executed: return l.toULongLong() < r.toULongLong(); | 0 |
2640 | case QMetaType::Float: | - |
2641 | return l.toFloat() < r.toFloat(); never executed: return l.toFloat() < r.toFloat(); | 0 |
2642 | case QVariant::Double: | - |
2643 | return l.toDouble() < r.toDouble(); never executed: return l.toDouble() < r.toDouble(); | 0 |
2644 | case QVariant::Char: | - |
2645 | return l.toChar() < r.toChar(); never executed: return l.toChar() < r.toChar(); | 0 |
2646 | case QVariant::Date: | - |
2647 | return l.toDate() < r.toDate(); never executed: return l.toDate() < r.toDate(); | 0 |
2648 | case QVariant::Time: | - |
2649 | return l.toTime() < r.toTime(); never executed: return l.toTime() < r.toTime(); | 0 |
2650 | case QVariant::DateTime: | - |
2651 | return l.toDateTime() < r.toDateTime(); never executed: return l.toDateTime() < r.toDateTime(); | 0 |
2652 | case QVariant::String: | - |
2653 | default: | - |
2654 | if (d->sort_localeaware) partially evaluated: d->sort_localeaware no Evaluation Count:0 | yes Evaluation Count:74294 |
| 0-74294 |
2655 | return l.toString().localeAwareCompare(r.toString()) < 0; never executed: return l.toString().localeAwareCompare(r.toString()) < 0; | 0 |
2656 | else | - |
2657 | return l.toString().compare(r.toString(), d->sort_casesensitivity) < 0; executed: return l.toString().compare(r.toString(), d->sort_casesensitivity) < 0; Execution Count:74294 | 74294 |
2658 | } | - |
2659 | return false; never executed: return false; | 0 |
2660 | } | - |
2661 | | - |
2662 | /*! | - |
2663 | Returns true if the item in the row indicated by the given \a source_row | - |
2664 | and \a source_parent should be included in the model; otherwise returns | - |
2665 | false. | - |
2666 | | - |
2667 | The default implementation returns true if the value held by the relevant item | - |
2668 | matches the filter string, wildcard string or regular expression. | - |
2669 | | - |
2670 | \note By default, the Qt::DisplayRole is used to determine if the row | - |
2671 | should be accepted or not. This can be changed by setting the | - |
2672 | \l{QSortFilterProxyModel::filterRole}{filterRole} property. | - |
2673 | | - |
2674 | \sa filterAcceptsColumn(), setFilterFixedString(), setFilterRegExp(), setFilterWildcard() | - |
2675 | */ | - |
2676 | bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const | - |
2677 | { | - |
2678 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2679 | if (d->filter_regexp.isEmpty()) evaluated: d->filter_regexp.isEmpty() yes Evaluation Count:45921 | yes Evaluation Count:23744 |
| 23744-45921 |
2680 | return true; executed: return true; Execution Count:45921 | 45921 |
2681 | if (d->filter_column == -1) { evaluated: d->filter_column == -1 yes Evaluation Count:5 | yes Evaluation Count:23739 |
| 5-23739 |
2682 | int column_count = d->model->columnCount(source_parent); executed (the execution status of this line is deduced): int column_count = d->model->columnCount(source_parent); | - |
2683 | for (int column = 0; column < column_count; ++column) { evaluated: column < column_count yes Evaluation Count:11 | yes Evaluation Count:2 |
| 2-11 |
2684 | QModelIndex source_index = d->model->index(source_row, column, source_parent); executed (the execution status of this line is deduced): QModelIndex source_index = d->model->index(source_row, column, source_parent); | - |
2685 | QString key = d->model->data(source_index, d->filter_role).toString(); executed (the execution status of this line is deduced): QString key = d->model->data(source_index, d->filter_role).toString(); | - |
2686 | if (key.contains(d->filter_regexp)) evaluated: key.contains(d->filter_regexp) yes Evaluation Count:3 | yes Evaluation Count:8 |
| 3-8 |
2687 | return true; executed: return true; Execution Count:3 | 3 |
2688 | } executed: } Execution Count:8 | 8 |
2689 | return false; executed: return false; Execution Count:2 | 2 |
2690 | } | - |
2691 | QModelIndex source_index = d->model->index(source_row, d->filter_column, source_parent); executed (the execution status of this line is deduced): QModelIndex source_index = d->model->index(source_row, d->filter_column, source_parent); | - |
2692 | if (!source_index.isValid()) // the column may not exist evaluated: !source_index.isValid() yes Evaluation Count:3696 | yes Evaluation Count:20043 |
| 3696-20043 |
2693 | return true; executed: return true; Execution Count:3696 | 3696 |
2694 | QString key = d->model->data(source_index, d->filter_role).toString(); executed (the execution status of this line is deduced): QString key = d->model->data(source_index, d->filter_role).toString(); | - |
2695 | return key.contains(d->filter_regexp); executed: return key.contains(d->filter_regexp); Execution Count:20043 | 20043 |
2696 | } | - |
2697 | | - |
2698 | /*! | - |
2699 | Returns true if the item in the column indicated by the given \a source_column | - |
2700 | and \a source_parent should be included in the model; otherwise returns false. | - |
2701 | | - |
2702 | The default implementation returns true if the value held by the relevant item | - |
2703 | matches the filter string, wildcard string or regular expression. | - |
2704 | | - |
2705 | \note By default, the Qt::DisplayRole is used to determine if the row | - |
2706 | should be accepted or not. This can be changed by setting the \l | - |
2707 | filterRole property. | - |
2708 | | - |
2709 | \sa filterAcceptsRow(), setFilterFixedString(), setFilterRegExp(), setFilterWildcard() | - |
2710 | */ | - |
2711 | bool QSortFilterProxyModel::filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const | - |
2712 | { | - |
2713 | Q_UNUSED(source_column); executed (the execution status of this line is deduced): (void)source_column;; | - |
2714 | Q_UNUSED(source_parent); executed (the execution status of this line is deduced): (void)source_parent;; | - |
2715 | return true; executed: return true; Execution Count:31900 | 31900 |
2716 | } | - |
2717 | | - |
2718 | /*! | - |
2719 | Returns the source model index corresponding to the given \a | - |
2720 | proxyIndex from the sorting filter model. | - |
2721 | | - |
2722 | \sa mapFromSource() | - |
2723 | */ | - |
2724 | QModelIndex QSortFilterProxyModel::mapToSource(const QModelIndex &proxyIndex) const | - |
2725 | { | - |
2726 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2727 | return d->proxy_to_source(proxyIndex); executed: return d->proxy_to_source(proxyIndex); Execution Count:198228 | 198228 |
2728 | } | - |
2729 | | - |
2730 | /*! | - |
2731 | Returns the model index in the QSortFilterProxyModel given the \a | - |
2732 | sourceIndex from the source model. | - |
2733 | | - |
2734 | \sa mapToSource() | - |
2735 | */ | - |
2736 | QModelIndex QSortFilterProxyModel::mapFromSource(const QModelIndex &sourceIndex) const | - |
2737 | { | - |
2738 | Q_D(const QSortFilterProxyModel); executed (the execution status of this line is deduced): const QSortFilterProxyModelPrivate * const d = d_func(); | - |
2739 | return d->source_to_proxy(sourceIndex); executed: return d->source_to_proxy(sourceIndex); Execution Count:19041 | 19041 |
2740 | } | - |
2741 | | - |
2742 | /*! | - |
2743 | \reimp | - |
2744 | */ | - |
2745 | QItemSelection QSortFilterProxyModel::mapSelectionToSource(const QItemSelection &proxySelection) const | - |
2746 | { | - |
2747 | return QAbstractProxyModel::mapSelectionToSource(proxySelection); never executed: return QAbstractProxyModel::mapSelectionToSource(proxySelection); | 0 |
2748 | } | - |
2749 | | - |
2750 | /*! | - |
2751 | \reimp | - |
2752 | */ | - |
2753 | QItemSelection QSortFilterProxyModel::mapSelectionFromSource(const QItemSelection &sourceSelection) const | - |
2754 | { | - |
2755 | return QAbstractProxyModel::mapSelectionFromSource(sourceSelection); executed: return QAbstractProxyModel::mapSelectionFromSource(sourceSelection); Execution Count:1 | 1 |
2756 | } | - |
2757 | | - |
2758 | /*! | - |
2759 | \fn QObject *QSortFilterProxyModel::parent() const | - |
2760 | \internal | - |
2761 | */ | - |
2762 | | - |
2763 | QT_END_NAMESPACE | - |
2764 | | - |
2765 | #include "moc_qsortfilterproxymodel.cpp" | - |
2766 | | - |
2767 | #endif // QT_NO_SORTFILTERPROXYMODEL | - |
2768 | | - |
| | |