qsortfilterproxymodel.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9