itemmodels/qitemselectionmodel.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const -
8{ -
9 return (isValid() && other.isValid() 5647
10 && parent() == other.parent() 5647
11 && model() == other.model() 5647
12 && ((top() <= other.top() && bottom() >= other.top()) 5647
13 || (top() >= other.top() && top() <= other.bottom())) 5647
14 && ((left() <= other.left() && right() >= other.left()) 5647
15 || (left() >= other.left() && left() <= other.right())));
executed: return (isValid() && other.isValid() && parent() == other.parent() && model() == other.model() && ((top() <= other.top() && bottom() >= other.top()) || (top() >= other.top() && top() <= other.bottom())) && ((left() <= other.left() && right() >= other.left()) || (left() >= other.left() && left() <= other.right())));
Execution Count:5647
5647
16} -
17QItemSelectionRange QItemSelectionRange::intersected(const QItemSelectionRange &other) const -
18{ -
19 if (model() == other.model() && parent() == other.parent()) {
partially evaluated: model() == other.model()
TRUEFALSE
yes
Evaluation Count:486
no
Evaluation Count:0
partially evaluated: parent() == other.parent()
TRUEFALSE
yes
Evaluation Count:486
no
Evaluation Count:0
0-486
20 QModelIndex topLeft = model()->index(qMax(top(), other.top()), -
21 qMax(left(), other.left()), -
22 other.parent()); -
23 QModelIndex bottomRight = model()->index(qMin(bottom(), other.bottom()), -
24 qMin(right(), other.right()), -
25 other.parent()); -
26 return QItemSelectionRange(topLeft, bottomRight);
executed: return QItemSelectionRange(topLeft, bottomRight);
Execution Count:486
486
27 } -
28 return QItemSelectionRange();
never executed: return QItemSelectionRange();
0
29} -
30static void rowLengthsFromRange(const QItemSelectionRange &range, QVector<QPair<QPersistentModelIndex, uint> > &result) -
31{ -
32 if (range.isValid() && range.model()) {
evaluated: range.isValid()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2
partially evaluated: range.model()
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
33 const QModelIndex topLeft = range.topLeft(); -
34 const int bottom = range.bottom(); -
35 const uint width = range.width(); -
36 const int column = topLeft.column(); -
37 for (int row = topLeft.row(); row <= bottom; ++row) {
evaluated: row <= bottom
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:9
9-14
38 -
39 -
40 -
41 result.push_back(qMakePair(QPersistentModelIndex(topLeft.sibling(row, column)), width)); -
42 }
executed: }
Execution Count:14
14
43 }
executed: }
Execution Count:9
9
44}
executed: }
Execution Count:11
11
45 -
46template<typename ModelIndexContainer> -
47static void indexesFromRange(const QItemSelectionRange &range, ModelIndexContainer &result) -
48{ -
49 if (range.isValid() && range.model()) {
partially evaluated: range.isValid()
TRUEFALSE
yes
Evaluation Count:639
no
Evaluation Count:0
partially evaluated: range.model()
TRUEFALSE
yes
Evaluation Count:639
no
Evaluation Count:0
0-639
50 const QModelIndex topLeft = range.topLeft(); -
51 const int bottom = range.bottom(); -
52 const int right = range.right(); -
53 for (int row = topLeft.row(); row <= bottom; ++row) {
evaluated: row <= bottom
TRUEFALSE
yes
Evaluation Count:1587
yes
Evaluation Count:639
639-1587
54 const QModelIndex columnLeader = topLeft.sibling(row, topLeft.column()); -
55 for (int column = topLeft.column(); column <= right; ++column) {
evaluated: column <= right
TRUEFALSE
yes
Evaluation Count:3740
yes
Evaluation Count:1587
1587-3740
56 QModelIndex index = columnLeader.sibling(row, column); -
57 Qt::ItemFlags flags = range.model()->flags(index); -
58 if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled))
evaluated: (flags & Qt::ItemIsSelectable)
TRUEFALSE
yes
Evaluation Count:3729
yes
Evaluation Count:11
evaluated: (flags & Qt::ItemIsEnabled)
TRUEFALSE
yes
Evaluation Count:3727
yes
Evaluation Count:2
2-3729
59 result.push_back(index);
executed: result.push_back(index);
Execution Count:3727
3727
60 }
executed: }
Execution Count:3740
3740
61 }
executed: }
Execution Count:1587
1587
62 }
executed: }
Execution Count:639
639
63}
executed: }
Execution Count:639
639
64 -
65 -
66 -
67 -
68 -
69 -
70bool QItemSelectionRange::isEmpty() const -
71{ -
72 if (!isValid() || !model())
partially evaluated: !isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:121
partially evaluated: !model()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:121
0-121
73 return true;
never executed: return true;
0
74 -
75 for (int column = left(); column <= right(); ++column) {
partially evaluated: column <= right()
TRUEFALSE
yes
Evaluation Count:121
no
Evaluation Count:0
0-121
76 for (int row = top(); row <= bottom(); ++row) {
partially evaluated: row <= bottom()
TRUEFALSE
yes
Evaluation Count:121
no
Evaluation Count:0
0-121
77 QModelIndex index = model()->index(row, column, parent()); -
78 Qt::ItemFlags flags = model()->flags(index); -
79 if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled))
partially evaluated: (flags & Qt::ItemIsSelectable)
TRUEFALSE
yes
Evaluation Count:121
no
Evaluation Count:0
partially evaluated: (flags & Qt::ItemIsEnabled)
TRUEFALSE
yes
Evaluation Count:121
no
Evaluation Count:0
0-121
80 return false;
executed: return false;
Execution Count:121
121
81 }
never executed: }
0
82 }
never executed: }
0
83 return true;
never executed: return true;
0
84} -
85 -
86 -
87 -
88 -
89 -
90QModelIndexList QItemSelectionRange::indexes() const -
91{ -
92 QModelIndexList result; -
93 indexesFromRange(*this, result); -
94 return result;
never executed: return result;
0
95} -
96QItemSelection::QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight) -
97{ -
98 select(topLeft, bottomRight); -
99}
executed: }
Execution Count:3880
3880
100void QItemSelection::select(const QModelIndex &topLeft, const QModelIndex &bottomRight) -
101{ -
102 if (!topLeft.isValid() || !bottomRight.isValid())
evaluated: !topLeft.isValid()
TRUEFALSE
yes
Evaluation Count:131
yes
Evaluation Count:4281
evaluated: !bottomRight.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4280
1-4281
103 return;
executed: return;
Execution Count:132
132
104 -
105 if ((topLeft.model() != bottomRight.model())
partially evaluated: (topLeft.model() != bottomRight.model())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4280
0-4280
106 || topLeft.parent() != bottomRight.parent()) {
evaluated: topLeft.parent() != bottomRight.parent()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4279
1-4279
107 QMessageLogger("itemmodels/qitemselectionmodel.cpp", 428, __PRETTY_FUNCTION__).warning("Can't select indexes from different model or with different parents"); -
108 return;
executed: return;
Execution Count:1
1
109 } -
110 if (topLeft.row() > bottomRight.row() || topLeft.column() > bottomRight.column()) {
partially evaluated: topLeft.row() > bottomRight.row()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4279
partially evaluated: topLeft.column() > bottomRight.column()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4279
0-4279
111 int top = qMin(topLeft.row(), bottomRight.row()); -
112 int bottom = qMax(topLeft.row(), bottomRight.row()); -
113 int left = qMin(topLeft.column(), bottomRight.column()); -
114 int right = qMax(topLeft.column(), bottomRight.column()); -
115 QModelIndex tl = topLeft.sibling(top, left); -
116 QModelIndex br = bottomRight.sibling(bottom, right); -
117 append(QItemSelectionRange(tl, br)); -
118 return;
never executed: return;
0
119 } -
120 append(QItemSelectionRange(topLeft, bottomRight)); -
121}
executed: }
Execution Count:4279
4279
122 -
123 -
124 -
125 -
126 -
127 -
128bool QItemSelection::contains(const QModelIndex &index) const -
129{ -
130 if (index.flags() & Qt::ItemIsSelectable) {
evaluated: index.flags() & Qt::ItemIsSelectable
TRUEFALSE
yes
Evaluation Count:6237
yes
Evaluation Count:7
7-6237
131 QList<QItemSelectionRange>::const_iterator it = begin(); -
132 for (; it != end(); ++it)
evaluated: it != end()
TRUEFALSE
yes
Evaluation Count:8360
yes
Evaluation Count:4961
4961-8360
133 if ((*it).contains(index))
evaluated: (*it).contains(index)
TRUEFALSE
yes
Evaluation Count:1276
yes
Evaluation Count:7084
1276-7084
134 return true;
executed: return true;
Execution Count:1276
1276
135 }
executed: }
Execution Count:4961
4961
136 return false;
executed: return false;
Execution Count:4968
4968
137} -
138 -
139 -
140 -
141 -
142 -
143QModelIndexList QItemSelection::indexes() const -
144{ -
145 QModelIndexList result; -
146 QList<QItemSelectionRange>::const_iterator it = begin(); -
147 for (; it != end(); ++it)
evaluated: it != end()
TRUEFALSE
yes
Evaluation Count:630
yes
Evaluation Count:704
630-704
148 indexesFromRange(*it, result);
executed: indexesFromRange(*it, result);
Execution Count:630
630
149 return result;
executed: return result;
Execution Count:704
704
150} -
151 -
152static QVector<QPersistentModelIndex> qSelectionPersistentindexes(const QItemSelection &sel) -
153{ -
154 QVector<QPersistentModelIndex> result; -
155 QList<QItemSelectionRange>::const_iterator it = sel.constBegin(); -
156 for (; it != sel.constEnd(); ++it)
evaluated: it != sel.constEnd()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:3906
9-3906
157 indexesFromRange(*it, result);
executed: indexesFromRange(*it, result);
Execution Count:9
9
158 return result;
executed: return result;
Execution Count:3906
3906
159} -
160 -
161static QVector<QPair<QPersistentModelIndex, uint> > qSelectionPersistentRowLengths(const QItemSelection &sel) -
162{ -
163 QVector<QPair<QPersistentModelIndex, uint> > result; -
164 for (QForeachContainer<__typeof__(sel)> _container_(sel); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QItemSelectionRange &range = *_container_.i;; __extension__ ({--_container_.brk; break;})) -
165 rowLengthsFromRange(range, result);
executed: rowLengthsFromRange(range, result);
Execution Count:11
11
166 return result;
executed: return result;
Execution Count:180
180
167} -
168void QItemSelection::merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command) -
169{ -
170 if (other.isEmpty() ||
evaluated: other.isEmpty()
TRUEFALSE
yes
Evaluation Count:208167
yes
Evaluation Count:9371
9371-208167
171 !(command & QItemSelectionModel::Select ||
evaluated: command & QItemSelectionModel::Select
TRUEFALSE
yes
Evaluation Count:8647
yes
Evaluation Count:724
724-8647
172 command & QItemSelectionModel::Deselect ||
evaluated: command & QItemSelectionModel::Deselect
TRUEFALSE
yes
Evaluation Count:612
yes
Evaluation Count:112
112-612
173 command & QItemSelectionModel::Toggle))
partially evaluated: command & QItemSelectionModel::Toggle
TRUEFALSE
yes
Evaluation Count:112
no
Evaluation Count:0
0-112
174 return;
executed: return;
Execution Count:208167
208167
175 -
176 QItemSelection newSelection = other; -
177 -
178 QItemSelection intersections; -
179 QItemSelection::iterator it = newSelection.begin(); -
180 while (it != newSelection.end()) {
evaluated: it != newSelection.end()
TRUEFALSE
yes
Evaluation Count:9461
yes
Evaluation Count:9371
9371-9461
181 if (!(*it).isValid()) {
evaluated: !(*it).isValid()
TRUEFALSE
yes
Evaluation Count:308
yes
Evaluation Count:9153
308-9153
182 it = newSelection.erase(it); -
183 continue;
executed: continue;
Execution Count:308
308
184 } -
185 for (int t = 0; t < count(); ++t) {
evaluated: t < count()
TRUEFALSE
yes
Evaluation Count:1744
yes
Evaluation Count:9153
1744-9153
186 if ((*it).intersects(at(t)))
evaluated: (*it).intersects(at(t))
TRUEFALSE
yes
Evaluation Count:331
yes
Evaluation Count:1413
331-1413
187 intersections.append(at(t).intersected(*it));
executed: intersections.append(at(t).intersected(*it));
Execution Count:331
331
188 }
executed: }
Execution Count:1744
1744
189 ++it; -
190 }
executed: }
Execution Count:9153
9153
191 -
192 -
193 for (int i = 0; i < intersections.count(); ++i) {
evaluated: i < intersections.count()
TRUEFALSE
yes
Evaluation Count:331
yes
Evaluation Count:9371
331-9371
194 for (int t = 0; t < count();) {
evaluated: t < count()
TRUEFALSE
yes
Evaluation Count:1135
yes
Evaluation Count:331
331-1135
195 if (at(t).intersects(intersections.at(i))) {
evaluated: at(t).intersects(intersections.at(i))
TRUEFALSE
yes
Evaluation Count:331
yes
Evaluation Count:804
331-804
196 split(at(t), intersections.at(i), this); -
197 removeAt(t); -
198 } else {
executed: }
Execution Count:331
331
199 ++t; -
200 }
executed: }
Execution Count:804
804
201 } -
202 -
203 for (int n = 0; (command & QItemSelectionModel::Toggle) && n < newSelection.count();) {
evaluated: (command & QItemSelectionModel::Toggle)
TRUEFALSE
yes
Evaluation Count:167
yes
Evaluation Count:252
evaluated: n < newSelection.count()
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:79
79-252
204 if (newSelection.at(n).intersects(intersections.at(i))) {
evaluated: newSelection.at(n).intersects(intersections.at(i))
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:9
9-79
205 split(newSelection.at(n), intersections.at(i), &newSelection); -
206 newSelection.removeAt(n); -
207 } else {
executed: }
Execution Count:79
79
208 ++n; -
209 }
executed: }
Execution Count:9
9
210 } -
211 }
executed: }
Execution Count:331
331
212 -
213 if (!(command & QItemSelectionModel::Deselect))
evaluated: !(command & QItemSelectionModel::Deselect)
TRUEFALSE
yes
Evaluation Count:8759
yes
Evaluation Count:612
612-8759
214 operator+=(newSelection);
executed: operator+=(newSelection);
Execution Count:8759
8759
215}
executed: }
Execution Count:9371
9371
216void QItemSelection::split(const QItemSelectionRange &range, -
217 const QItemSelectionRange &other, QItemSelection *result) -
218{ -
219 if (range.parent() != other.parent() || range.model() != other.model())
partially evaluated: range.parent() != other.parent()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:733
evaluated: range.model() != other.model()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:732
0-733
220 return;
executed: return;
Execution Count:1
1
221 -
222 QModelIndex parent = other.parent(); -
223 int top = range.top(); -
224 int left = range.left(); -
225 int bottom = range.bottom(); -
226 int right = range.right(); -
227 int other_top = other.top(); -
228 int other_left = other.left(); -
229 int other_bottom = other.bottom(); -
230 int other_right = other.right(); -
231 const QAbstractItemModel *model = range.model(); -
232 qt_noop(); -
233 if (other_top > top) {
evaluated: other_top > top
TRUEFALSE
yes
Evaluation Count:141
yes
Evaluation Count:591
141-591
234 QModelIndex tl = model->index(top, left, parent); -
235 QModelIndex br = model->index(other_top - 1, right, parent); -
236 result->append(QItemSelectionRange(tl, br)); -
237 top = other_top; -
238 }
executed: }
Execution Count:141
141
239 if (other_bottom < bottom) {
evaluated: other_bottom < bottom
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:641
91-641
240 QModelIndex tl = model->index(other_bottom + 1, left, parent); -
241 QModelIndex br = model->index(bottom, right, parent); -
242 result->append(QItemSelectionRange(tl, br)); -
243 bottom = other_bottom; -
244 }
executed: }
Execution Count:91
91
245 if (other_left > left) {
evaluated: other_left > left
TRUEFALSE
yes
Evaluation Count:146
yes
Evaluation Count:586
146-586
246 QModelIndex tl = model->index(top, left, parent); -
247 QModelIndex br = model->index(bottom, other_left - 1, parent); -
248 result->append(QItemSelectionRange(tl, br)); -
249 left = other_left; -
250 }
executed: }
Execution Count:146
146
251 if (other_right < right) {
evaluated: other_right < right
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:620
112-620
252 QModelIndex tl = model->index(top, other_right + 1, parent); -
253 QModelIndex br = model->index(bottom, right, parent); -
254 result->append(QItemSelectionRange(tl, br)); -
255 right = other_right; -
256 }
executed: }
Execution Count:112
112
257}
executed: }
Execution Count:732
732
258 -
259 -
260void QItemSelectionModelPrivate::initModel(QAbstractItemModel *model) -
261{ -
262 this->model = model; -
263 if (model) {
partially evaluated: model
TRUEFALSE
yes
Evaluation Count:3734
no
Evaluation Count:0
0-3734
264 QItemSelectionModel * const q = q_func(); -
265 QObject::connect(model, "2""rowsAboutToBeRemoved(QModelIndex,int,int)", -
266 q, "1""_q_rowsAboutToBeRemoved(QModelIndex,int,int)"); -
267 QObject::connect(model, "2""columnsAboutToBeRemoved(QModelIndex,int,int)", -
268 q, "1""_q_columnsAboutToBeRemoved(QModelIndex,int,int)"); -
269 QObject::connect(model, "2""rowsAboutToBeInserted(QModelIndex,int,int)", -
270 q, "1""_q_rowsAboutToBeInserted(QModelIndex,int,int)"); -
271 QObject::connect(model, "2""columnsAboutToBeInserted(QModelIndex,int,int)", -
272 q, "1""_q_columnsAboutToBeInserted(QModelIndex,int,int)"); -
273 QObject::connect(model, "2""rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)", -
274 q, "1""_q_layoutAboutToBeChanged()"); -
275 QObject::connect(model, "2""columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)", -
276 q, "1""_q_layoutAboutToBeChanged()"); -
277 QObject::connect(model, "2""rowsMoved(QModelIndex,int,int,QModelIndex,int)", -
278 q, "1""_q_layoutChanged()"); -
279 QObject::connect(model, "2""columnsMoved(QModelIndex,int,int,QModelIndex,int)", -
280 q, "1""_q_layoutChanged()"); -
281 QObject::connect(model, "2""layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)", -
282 q, "1""_q_layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)"); -
283 QObject::connect(model, "2""layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)", -
284 q, "1""_q_layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)"); -
285 }
executed: }
Execution Count:3734
3734
286}
executed: }
Execution Count:3734
3734
287QItemSelection QItemSelectionModelPrivate::expandSelection(const QItemSelection &selection, -
288 QItemSelectionModel::SelectionFlags command) const -
289{ -
290 if (selection.isEmpty() && !((command & QItemSelectionModel::Rows) ||
evaluated: selection.isEmpty()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:443
partially evaluated: (command & QItemSelectionModel::Rows)
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-443
291 (command & QItemSelectionModel::Columns)))
never evaluated: (command & QItemSelectionModel::Columns)
0
292 return selection;
never executed: return selection;
0
293 -
294 QItemSelection expanded; -
295 if (command & QItemSelectionModel::Rows) {
evaluated: command & QItemSelectionModel::Rows
TRUEFALSE
yes
Evaluation Count:432
yes
Evaluation Count:22
22-432
296 for (int i = 0; i < selection.count(); ++i) {
evaluated: i < selection.count()
TRUEFALSE
yes
Evaluation Count:426
yes
Evaluation Count:432
426-432
297 QModelIndex parent = selection.at(i).parent(); -
298 int colCount = model->columnCount(parent); -
299 QModelIndex tl = model->index(selection.at(i).top(), 0, parent); -
300 QModelIndex br = model->index(selection.at(i).bottom(), colCount - 1, parent); -
301 -
302 expanded.merge(QItemSelection(tl, br), QItemSelectionModel::Select); -
303 }
executed: }
Execution Count:426
426
304 }
executed: }
Execution Count:432
432
305 if (command & QItemSelectionModel::Columns) {
evaluated: command & QItemSelectionModel::Columns
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:432
22-432
306 for (int i = 0; i < selection.count(); ++i) {
evaluated: i < selection.count()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:22
22
307 QModelIndex parent = selection.at(i).parent(); -
308 int rowCount = model->rowCount(parent); -
309 QModelIndex tl = model->index(0, selection.at(i).left(), parent); -
310 QModelIndex br = model->index(rowCount - 1, selection.at(i).right(), parent); -
311 -
312 expanded.merge(QItemSelection(tl, br), QItemSelectionModel::Select); -
313 }
executed: }
Execution Count:22
22
314 }
executed: }
Execution Count:22
22
315 return expanded;
executed: return expanded;
Execution Count:454
454
316} -
317 -
318 -
319 -
320 -
321void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &parent, -
322 int start, int end) -
323{ -
324 QItemSelectionModel * const q = q_func(); -
325 finalize(); -
326 -
327 -
328 if (currentIndex.isValid() && parent == currentIndex.parent()
evaluated: currentIndex.isValid()
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:3064
evaluated: parent == currentIndex.parent()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:12
12-3064
329 && currentIndex.row() >= start && currentIndex.row() <= end) {
evaluated: currentIndex.row() >= start
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:5
evaluated: currentIndex.row() <= end
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:6
3-9
330 QModelIndex old = currentIndex; -
331 if (start > 0)
evaluated: start > 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
332 currentIndex = model->index(start - 1, old.column(), parent);
executed: currentIndex = model->index(start - 1, old.column(), parent);
Execution Count:1
1
333 else if (model && end < model->rowCount(parent) - 1)
partially evaluated: model
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: end < model->rowCount(parent) - 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
334 currentIndex = model->index(end + 1, old.column(), parent);
never executed: currentIndex = model->index(end + 1, old.column(), parent);
0
335 else -
336 currentIndex = QModelIndex();
executed: currentIndex = QModelIndex();
Execution Count:2
2
337 q->currentChanged(currentIndex, old); -
338 q->currentRowChanged(currentIndex, old); -
339 if (currentIndex.column() != old.column())
evaluated: currentIndex.column() != old.column()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
340 q->currentColumnChanged(currentIndex, old);
executed: q->currentColumnChanged(currentIndex, old);
Execution Count:2
2
341 }
executed: }
Execution Count:3
3
342 -
343 QItemSelection deselected; -
344 QItemSelection newParts; -
345 QItemSelection::iterator it = ranges.begin(); -
346 while (it != ranges.end()) {
evaluated: it != ranges.end()
TRUEFALSE
yes
Evaluation Count:131
yes
Evaluation Count:3090
131-3090
347 if (it->topLeft().parent() != parent) {
evaluated: it->topLeft().parent() != parent
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:114
17-114
348 QModelIndex itParent = it->topLeft().parent(); -
349 while (itParent.isValid() && itParent.parent() != parent)
evaluated: itParent.isValid()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:10
evaluated: itParent.parent() != parent
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:7
4-11
350 itParent = itParent.parent();
executed: itParent = itParent.parent();
Execution Count:4
4
351 -
352 if (itParent.isValid() && start <= itParent.row() && itParent.row() <= end) {
evaluated: itParent.isValid()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:10
partially evaluated: start <= itParent.row()
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
partially evaluated: itParent.row() <= end
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-10
353 deselected.append(*it); -
354 it = ranges.erase(it); -
355 } else {
executed: }
Execution Count:7
7
356 ++it; -
357 }
executed: }
Execution Count:10
10
358 } else if (start <= it->bottom() && it->bottom() <= end
evaluated: start <= it->bottom()
TRUEFALSE
yes
Evaluation Count:110
yes
Evaluation Count:4
evaluated: it->bottom() <= end
TRUEFALSE
yes
Evaluation Count:99
yes
Evaluation Count:11
4-110
359 && start <= it->top() && it->top() <= end) {
evaluated: start <= it->top()
TRUEFALSE
yes
Evaluation Count:98
yes
Evaluation Count:1
partially evaluated: it->top() <= end
TRUEFALSE
yes
Evaluation Count:98
no
Evaluation Count:0
0-98
360 deselected.append(*it); -
361 it = ranges.erase(it); -
362 } else if (start <= it->top() && it->top() <= end) {
evaluated: start <= it->top()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:7
evaluated: it->top() <= end
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:7
executed: }
Execution Count:98
2-98
363 deselected.append(QItemSelectionRange(it->topLeft(), model->index(end, it->left(), it->parent()))); -
364 *it = QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), it->bottomRight()); -
365 ++it; -
366 } else if (start <= it->bottom() && it->bottom() <= end) {
evaluated: start <= it->bottom()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:4
evaluated: it->bottom() <= end
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:9
executed: }
Execution Count:2
1-10
367 deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight())); -
368 *it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent())); -
369 ++it; -
370 } else if (it->top() < start && end < it->bottom()) {
evaluated: it->top() < start
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:7
evaluated: end < it->bottom()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
executed: }
Execution Count:1
1-7
371 -
372 -
373 -
374 -
375 const QItemSelectionRange removedRange(model->index(start, it->right(), it->parent()), -
376 model->index(end, it->left(), it->parent())); -
377 deselected.append(removedRange); -
378 QItemSelection::split(*it, removedRange, &newParts); -
379 it = ranges.erase(it); -
380 } else
executed: }
Execution Count:2
2
381 ++it;
executed: ++it;
Execution Count:11
11
382 } -
383 ranges.append(newParts); -
384 -
385 if (!deselected.isEmpty())
evaluated: !deselected.isEmpty()
TRUEFALSE
yes
Evaluation Count:106
yes
Evaluation Count:2984
106-2984
386 q->selectionChanged(QItemSelection(), deselected);
executed: q->selectionChanged(QItemSelection(), deselected);
Execution Count:106
106
387}
executed: }
Execution Count:3090
3090
388 -
389 -
390 -
391 -
392void QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &parent, -
393 int start, int end) -
394{ -
395 QItemSelectionModel * const q = q_func(); -
396 -
397 -
398 if (currentIndex.isValid() && parent == currentIndex.parent()
evaluated: currentIndex.isValid()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:265
partially evaluated: parent == currentIndex.parent()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-265
399 && currentIndex.column() >= start && currentIndex.column() <= end) {
evaluated: currentIndex.column() >= start
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:1
evaluated: currentIndex.column() <= end
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
1-7
400 QModelIndex old = currentIndex; -
401 if (start > 0)
evaluated: start > 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
402 currentIndex = model->index(old.row(), start - 1, parent);
executed: currentIndex = model->index(old.row(), start - 1, parent);
Execution Count:1
1
403 else if (model && end < model->columnCount() - 1)
partially evaluated: model
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: end < model->columnCount() - 1
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
404 currentIndex = model->index(old.row(), end + 1, parent);
executed: currentIndex = model->index(old.row(), end + 1, parent);
Execution Count:1
1
405 else -
406 currentIndex = QModelIndex();
never executed: currentIndex = QModelIndex();
0
407 q->currentChanged(currentIndex, old); -
408 if (currentIndex.row() != old.row())
partially evaluated: currentIndex.row() != old.row()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
409 q->currentRowChanged(currentIndex, old);
never executed: q->currentRowChanged(currentIndex, old);
0
410 q->currentColumnChanged(currentIndex, old); -
411 }
executed: }
Execution Count:2
2
412 -
413 -
414 QModelIndex tl = model->index(0, start, parent); -
415 QModelIndex br = model->index(model->rowCount(parent) - 1, end, parent); -
416 q->select(QItemSelection(tl, br), QItemSelectionModel::Deselect); -
417 finalize(); -
418}
executed: }
Execution Count:273
273
419 -
420 -
421 -
422 -
423 -
424 -
425void QItemSelectionModelPrivate::_q_columnsAboutToBeInserted(const QModelIndex &parent, -
426 int start, int end) -
427{ -
428 (void)end;; -
429 finalize(); -
430 QList<QItemSelectionRange> split; -
431 QList<QItemSelectionRange>::iterator it = ranges.begin(); -
432 for (; it != ranges.end(); ) {
partially evaluated: it != ranges.end()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:828
0-828
433 if ((*it).isValid() && (*it).parent() == parent
never evaluated: (*it).isValid()
never evaluated: (*it).parent() == parent
0
434 && (*it).left() < start && (*it).right() >= start) {
never evaluated: (*it).left() < start
never evaluated: (*it).right() >= start
0
435 QModelIndex bottomMiddle = model->index((*it).bottom(), start - 1, (*it).parent()); -
436 QItemSelectionRange left((*it).topLeft(), bottomMiddle); -
437 QModelIndex topMiddle = model->index((*it).top(), start, (*it).parent()); -
438 QItemSelectionRange right(topMiddle, (*it).bottomRight()); -
439 it = ranges.erase(it); -
440 split.append(left); -
441 split.append(right); -
442 } else {
never executed: }
0
443 ++it; -
444 }
never executed: }
0
445 } -
446 ranges += split; -
447}
executed: }
Execution Count:828
828
448 -
449 -
450 -
451 -
452 -
453 -
454void QItemSelectionModelPrivate::_q_rowsAboutToBeInserted(const QModelIndex &parent, -
455 int start, int end) -
456{ -
457 (void)end;; -
458 finalize(); -
459 QList<QItemSelectionRange> split; -
460 QList<QItemSelectionRange>::iterator it = ranges.begin(); -
461 for (; it != ranges.end(); ) {
evaluated: it != ranges.end()
TRUEFALSE
yes
Evaluation Count:3021
yes
Evaluation Count:194968
3021-194968
462 if ((*it).isValid() && (*it).parent() == parent
partially evaluated: (*it).isValid()
TRUEFALSE
yes
Evaluation Count:3021
no
Evaluation Count:0
evaluated: (*it).parent() == parent
TRUEFALSE
yes
Evaluation Count:314
yes
Evaluation Count:2707
0-3021
463 && (*it).top() < start && (*it).bottom() >= start) {
evaluated: (*it).top() < start
TRUEFALSE
yes
Evaluation Count:310
yes
Evaluation Count:4
evaluated: (*it).bottom() >= start
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:307
3-310
464 QModelIndex middleRight = model->index(start - 1, (*it).right(), (*it).parent()); -
465 QItemSelectionRange top((*it).topLeft(), middleRight); -
466 QModelIndex middleLeft = model->index(start, (*it).left(), (*it).parent()); -
467 QItemSelectionRange bottom(middleLeft, (*it).bottomRight()); -
468 it = ranges.erase(it); -
469 split.append(top); -
470 split.append(bottom); -
471 } else {
executed: }
Execution Count:3
3
472 ++it; -
473 }
executed: }
Execution Count:3018
3018
474 } -
475 ranges += split; -
476}
executed: }
Execution Count:194968
194968
477void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged(const QList<QPersistentModelIndex> &, QAbstractItemModel::LayoutChangeHint hint) -
478{ -
479 savedPersistentIndexes.clear(); -
480 savedPersistentCurrentIndexes.clear(); -
481 savedPersistentRowLengths.clear(); -
482 savedPersistentCurrentRowLengths.clear(); -
483 -
484 -
485 -
486 if (ranges.isEmpty() && currentSelection.count() == 1) {
evaluated: ranges.isEmpty()
TRUEFALSE
yes
Evaluation Count:2037
yes
Evaluation Count:6
evaluated: currentSelection.count() == 1
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:2027
6-2037
487 QItemSelectionRange range = currentSelection.first(); -
488 QModelIndex parent = range.parent(); -
489 tableRowCount = model->rowCount(parent); -
490 tableColCount = model->columnCount(parent); -
491 if (tableRowCount * tableColCount > 1000
partially evaluated: tableRowCount * tableColCount > 1000
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
492 && range.top() == 0
never evaluated: range.top() == 0
0
493 && range.left() == 0
never evaluated: range.left() == 0
0
494 && range.bottom() == tableRowCount - 1
never evaluated: range.bottom() == tableRowCount - 1
0
495 && range.right() == tableColCount - 1) {
never evaluated: range.right() == tableColCount - 1
0
496 tableSelected = true; -
497 tableParent = parent; -
498 return;
never executed: return;
0
499 } -
500 }
executed: }
Execution Count:10
10
501 tableSelected = false; -
502 -
503 if (hint == QAbstractItemModel::VerticalSortHint) {
evaluated: hint == QAbstractItemModel::VerticalSortHint
TRUEFALSE
yes
Evaluation Count:90
yes
Evaluation Count:1953
90-1953
504 -
505 -
506 -
507 -
508 -
509 savedPersistentRowLengths = qSelectionPersistentRowLengths(ranges); -
510 savedPersistentCurrentRowLengths = qSelectionPersistentRowLengths(currentSelection); -
511 } else {
executed: }
Execution Count:90
90
512 savedPersistentIndexes = qSelectionPersistentindexes(ranges); -
513 savedPersistentCurrentIndexes = qSelectionPersistentindexes(currentSelection); -
514 }
executed: }
Execution Count:1953
1953
515} -
516 -
517 -
518 -
519static QItemSelection mergeRowLengths(const QVector<QPair<QPersistentModelIndex, uint> > &rowLengths) -
520{ -
521 if (rowLengths.isEmpty())
evaluated: rowLengths.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
3-7
522 return QItemSelection();
executed: return QItemSelection();
Execution Count:3
3
523 -
524 QItemSelection result; -
525 int i = 0; -
526 while (i < rowLengths.count()) {
evaluated: i < rowLengths.count()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:7
7-8
527 const QPersistentModelIndex &tl = rowLengths.at(i).first; -
528 if (!tl.isValid()) {
partially evaluated: !tl.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
529 ++i; -
530 continue;
never executed: continue;
0
531 } -
532 QPersistentModelIndex br = tl; -
533 const uint length = rowLengths.at(i).second; -
534 while (++i < rowLengths.count()) {
evaluated: ++i < rowLengths.count()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
7
535 const QPersistentModelIndex &next = rowLengths.at(i).first; -
536 if (!next.isValid())
partially evaluated: !next.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
537 continue;
never executed: continue;
0
538 const uint nextLength = rowLengths.at(i).second; -
539 if ((nextLength == length)
partially evaluated: (nextLength == length)
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
540 && (next.row() == br.row() + 1)
evaluated: (next.row() == br.row() + 1)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
1-6
541 && (next.parent() == br.parent())) {
partially evaluated: (next.parent() == br.parent())
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
542 br = next; -
543 } else {
executed: }
Execution Count:6
6
544 break;
executed: break;
Execution Count:1
1
545 } -
546 } -
547 result.append(QItemSelectionRange(tl, br.sibling(br.row(), length - 1))); -
548 }
executed: }
Execution Count:8
8
549 return result;
executed: return result;
Execution Count:7
7
550} -
551 -
552 -
553 -
554 -
555 -
556 -
557 -
558static QItemSelection mergeIndexes(const QVector<QPersistentModelIndex> &indexes) -
559{ -
560 QItemSelection colSpans; -
561 -
562 int i = 0; -
563 while (i < indexes.count()) {
evaluated: i < indexes.count()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:16
16-22
564 const QPersistentModelIndex &tl = indexes.at(i); -
565 if (!tl.isValid()) {
partially evaluated: !tl.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22
0-22
566 ++i; -
567 continue;
never executed: continue;
0
568 } -
569 QPersistentModelIndex br = tl; -
570 QModelIndex brParent = br.parent(); -
571 int brRow = br.row(); -
572 int brColumn = br.column(); -
573 while (++i < indexes.count()) {
evaluated: ++i < indexes.count()
TRUEFALSE
yes
Evaluation Count:313
yes
Evaluation Count:8
8-313
574 const QPersistentModelIndex &next = indexes.at(i); -
575 if (!next.isValid())
partially evaluated: !next.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:313
0-313
576 continue;
never executed: continue;
0
577 const QModelIndex nextParent = next.parent(); -
578 const int nextRow = next.row(); -
579 const int nextColumn = next.column(); -
580 if ((nextParent == brParent)
partially evaluated: (nextParent == brParent)
TRUEFALSE
yes
Evaluation Count:313
no
Evaluation Count:0
0-313
581 && (nextRow == brRow)
evaluated: (nextRow == brRow)
TRUEFALSE
yes
Evaluation Count:299
yes
Evaluation Count:14
14-299
582 && (nextColumn == brColumn + 1)) {
partially evaluated: (nextColumn == brColumn + 1)
TRUEFALSE
yes
Evaluation Count:299
no
Evaluation Count:0
0-299
583 br = next; -
584 brParent = nextParent; -
585 brRow = nextRow; -
586 brColumn = nextColumn; -
587 } else {
executed: }
Execution Count:299
299
588 break;
executed: break;
Execution Count:14
14
589 } -
590 } -
591 colSpans.append(QItemSelectionRange(tl, br)); -
592 }
executed: }
Execution Count:22
22
593 -
594 QItemSelection rowSpans; -
595 i = 0; -
596 while (i < colSpans.count()) {
evaluated: i < colSpans.count()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:16
16-22
597 QModelIndex tl = colSpans.at(i).topLeft(); -
598 QModelIndex br = colSpans.at(i).bottomRight(); -
599 QModelIndex prevTl = tl; -
600 while (++i < colSpans.count()) {
evaluated: ++i < colSpans.count()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8
8-14
601 QModelIndex nextTl = colSpans.at(i).topLeft(); -
602 QModelIndex nextBr = colSpans.at(i).bottomRight(); -
603 -
604 if (nextTl.parent() != tl.parent())
partially evaluated: nextTl.parent() != tl.parent()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
605 break;
never executed: break;
0
606 -
607 if ((nextTl.column() == prevTl.column()) && (nextBr.column() == br.column())
partially evaluated: (nextTl.column() == prevTl.column())
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
partially evaluated: (nextBr.column() == br.column())
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
608 && (nextTl.row() == prevTl.row() + 1) && (nextBr.row() == br.row() + 1)) {
partially evaluated: (nextTl.row() == prevTl.row() + 1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
never evaluated: (nextBr.row() == br.row() + 1)
0-14
609 br = nextBr; -
610 prevTl = nextTl; -
611 } else {
never executed: }
0
612 break;
executed: break;
Execution Count:14
14
613 } -
614 } -
615 rowSpans.append(QItemSelectionRange(tl, br)); -
616 }
executed: }
Execution Count:22
22
617 return rowSpans;
executed: return rowSpans;
Execution Count:16
16
618} -
619 -
620 -
621 -
622 -
623 -
624 -
625void QItemSelectionModelPrivate::_q_layoutChanged(const QList<QPersistentModelIndex> &, QAbstractItemModel::LayoutChangeHint hint) -
626{ -
627 -
628 if (tableSelected && tableColCount == model->columnCount(tableParent)
partially evaluated: tableSelected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2044
never evaluated: tableColCount == model->columnCount(tableParent)
0-2044
629 && tableRowCount == model->rowCount(tableParent)) {
never evaluated: tableRowCount == model->rowCount(tableParent)
0
630 ranges.clear(); -
631 currentSelection.clear(); -
632 int bottom = tableRowCount - 1; -
633 int right = tableColCount - 1; -
634 QModelIndex tl = model->index(0, 0, tableParent); -
635 QModelIndex br = model->index(bottom, right, tableParent); -
636 currentSelection << QItemSelectionRange(tl, br); -
637 tableParent = QModelIndex(); -
638 tableSelected = false; -
639 return;
never executed: return;
0
640 } -
641 -
642 if ((hint != QAbstractItemModel::VerticalSortHint && savedPersistentCurrentIndexes.isEmpty() && savedPersistentIndexes.isEmpty())
evaluated: hint != QAbstractItemModel::VerticalSortHint
TRUEFALSE
yes
Evaluation Count:1954
yes
Evaluation Count:90
evaluated: savedPersistentCurrentIndexes.isEmpty()
TRUEFALSE
yes
Evaluation Count:1950
yes
Evaluation Count:4
evaluated: savedPersistentIndexes.isEmpty()
TRUEFALSE
yes
Evaluation Count:1946
yes
Evaluation Count:4
4-1954
643 || (hint == QAbstractItemModel::VerticalSortHint && savedPersistentRowLengths.isEmpty() && savedPersistentCurrentRowLengths.isEmpty())) {
evaluated: hint == QAbstractItemModel::VerticalSortHint
TRUEFALSE
yes
Evaluation Count:90
yes
Evaluation Count:8
evaluated: savedPersistentRowLengths.isEmpty()
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:2
evaluated: savedPersistentCurrentRowLengths.isEmpty()
TRUEFALSE
yes
Evaluation Count:85
yes
Evaluation Count:3
2-90
644 -
645 -
646 return;
executed: return;
Execution Count:2031
2031
647 } -
648 -
649 -
650 ranges.clear(); -
651 currentSelection.clear(); -
652 -
653 if (hint != QAbstractItemModel::VerticalSortHint) {
evaluated: hint != QAbstractItemModel::VerticalSortHint
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:5
5-8
654 -
655 std::stable_sort(savedPersistentIndexes.begin(), savedPersistentIndexes.end()); -
656 std::stable_sort(savedPersistentCurrentIndexes.begin(), savedPersistentCurrentIndexes.end()); -
657 -
658 -
659 ranges = mergeIndexes(savedPersistentIndexes); -
660 currentSelection = mergeIndexes(savedPersistentCurrentIndexes); -
661 -
662 -
663 savedPersistentIndexes.clear(); -
664 savedPersistentCurrentIndexes.clear(); -
665 } else {
executed: }
Execution Count:8
8
666 -
667 std::stable_sort(savedPersistentRowLengths.begin(), savedPersistentRowLengths.end()); -
668 std::stable_sort(savedPersistentCurrentRowLengths.begin(), savedPersistentCurrentRowLengths.end()); -
669 -
670 -
671 ranges = mergeRowLengths(savedPersistentRowLengths); -
672 currentSelection = mergeRowLengths(savedPersistentCurrentRowLengths); -
673 -
674 -
675 savedPersistentRowLengths.clear(); -
676 savedPersistentCurrentRowLengths.clear(); -
677 }
executed: }
Execution Count:5
5
678} -
679QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model) -
680 : QObject(*new QItemSelectionModelPrivate, model) -
681{ -
682 d_func()->initModel(model); -
683}
executed: }
Execution Count:32
32
684 -
685 -
686 -
687 -
688QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model, QObject *parent) -
689 : QObject(*new QItemSelectionModelPrivate, parent) -
690{ -
691 d_func()->initModel(model); -
692}
executed: }
Execution Count:3702
3702
693 -
694 -
695 -
696 -
697QItemSelectionModel::QItemSelectionModel(QItemSelectionModelPrivate &dd, QAbstractItemModel *model) -
698 : QObject(dd, model) -
699{ -
700 dd.initModel(model); -
701}
never executed: }
0
702 -
703 -
704 -
705 -
706QItemSelectionModel::~QItemSelectionModel() -
707{ -
708} -
709 -
710 -
711 -
712 -
713 -
714 -
715 -
716void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) -
717{ -
718 QItemSelection selection(index, index); -
719 select(selection, command); -
720}
executed: }
Execution Count:3034
3034
721void QItemSelectionModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) -
722{ -
723 QItemSelectionModelPrivate * const d = d_func(); -
724 if (command == NoUpdate)
evaluated: command == NoUpdate
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:5502
13-5502
725 return;
executed: return;
Execution Count:13
13
726 -
727 -
728 QItemSelection sel = selection; -
729 -
730 -
731 -
732 -
733 -
734 QItemSelection::iterator it = d->ranges.begin(); -
735 while (it != d->ranges.end()) {
evaluated: it != d->ranges.end()
TRUEFALSE
yes
Evaluation Count:688
yes
Evaluation Count:5502
688-5502
736 if (!it->isValid())
evaluated: !it->isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:686
2-686
737 it = d->ranges.erase(it);
executed: it = d->ranges.erase(it);
Execution Count:2
2
738 else -
739 ++it;
executed: ++it;
Execution Count:686
686
740 } -
741 -
742 QItemSelection old = d->ranges; -
743 old.merge(d->currentSelection, d->currentCommand); -
744 -
745 -
746 if (command & Rows || command & Columns)
evaluated: command & Rows
TRUEFALSE
yes
Evaluation Count:432
yes
Evaluation Count:5070
evaluated: command & Columns
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:5048
22-5070
747 sel = d->expandSelection(sel, command);
executed: sel = d->expandSelection(sel, command);
Execution Count:454
454
748 -
749 -
750 if (command & Clear) {
evaluated: command & Clear
TRUEFALSE
yes
Evaluation Count:4069
yes
Evaluation Count:1433
1433-4069
751 d->ranges.clear(); -
752 d->currentSelection.clear(); -
753 }
executed: }
Execution Count:4069
4069
754 -
755 -
756 if (!(command & Current))
evaluated: !(command & Current)
TRUEFALSE
yes
Evaluation Count:4861
yes
Evaluation Count:641
641-4861
757 d->finalize();
executed: d->finalize();
Execution Count:4861
4861
758 -
759 -
760 if (command & Toggle || command & Select || command & Deselect) {
evaluated: command & Toggle
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:5475
evaluated: command & Select
TRUEFALSE
yes
Evaluation Count:3922
yes
Evaluation Count:1553
evaluated: command & Deselect
TRUEFALSE
yes
Evaluation Count:327
yes
Evaluation Count:1226
27-5475
761 d->currentCommand = command; -
762 d->currentSelection = sel; -
763 }
executed: }
Execution Count:4276
4276
764 -
765 -
766 QItemSelection newSelection = d->ranges; -
767 newSelection.merge(d->currentSelection, d->currentCommand); -
768 emitSelectionChanged(newSelection, old); -
769}
executed: }
Execution Count:5502
5502
770 -
771 -
772 -
773 -
774void QItemSelectionModel::clear() -
775{ -
776 clearSelection(); -
777 clearCurrentIndex(); -
778}
executed: }
Execution Count:7755
7755
779 -
780 -
781 -
782 -
783void QItemSelectionModel::clearCurrentIndex() -
784{ -
785 QItemSelectionModelPrivate * const d = d_func(); -
786 QModelIndex previous = d->currentIndex; -
787 d->currentIndex = QModelIndex(); -
788 if (previous.isValid()) {
evaluated: previous.isValid()
TRUEFALSE
yes
Evaluation Count:776
yes
Evaluation Count:6982
776-6982
789 currentChanged(d->currentIndex, previous); -
790 currentRowChanged(d->currentIndex, previous); -
791 currentColumnChanged(d->currentIndex, previous); -
792 }
executed: }
Execution Count:776
776
793}
executed: }
Execution Count:7758
7758
794 -
795 -
796 -
797 -
798void QItemSelectionModel::reset() -
799{ -
800 bool block = blockSignals(true); -
801 clear(); -
802 blockSignals(block); -
803}
executed: }
Execution Count:5616
5616
804 -
805 -
806 -
807 -
808 -
809void QItemSelectionModel::clearSelection() -
810{ -
811 QItemSelectionModelPrivate * const d = d_func(); -
812 if (d->ranges.count() == 0 && d->currentSelection.count() == 0)
evaluated: d->ranges.count() == 0
TRUEFALSE
yes
Evaluation Count:7715
yes
Evaluation Count:53
evaluated: d->currentSelection.count() == 0
TRUEFALSE
yes
Evaluation Count:6544
yes
Evaluation Count:1171
53-7715
813 return;
executed: return;
Execution Count:6544
6544
814 -
815 select(QItemSelection(), Clear); -
816}
executed: }
Execution Count:1224
1224
817void QItemSelectionModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) -
818{ -
819 QItemSelectionModelPrivate * const d = d_func(); -
820 if (index == d->currentIndex) {
evaluated: index == d->currentIndex
TRUEFALSE
yes
Evaluation Count:98
yes
Evaluation Count:2946
98-2946
821 if (command != NoUpdate)
evaluated: command != NoUpdate
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:57
41-57
822 select(index, command);
executed: select(index, command);
Execution Count:41
41
823 return;
executed: return;
Execution Count:98
98
824 } -
825 QPersistentModelIndex previous = d->currentIndex; -
826 d->currentIndex = index; -
827 if (command != NoUpdate)
evaluated: command != NoUpdate
TRUEFALSE
yes
Evaluation Count:2539
yes
Evaluation Count:407
407-2539
828 select(d->currentIndex, command);
executed: select(d->currentIndex, command);
Execution Count:2539
2539
829 currentChanged(d->currentIndex, previous); -
830 if (d->currentIndex.row() != previous.row() ||
evaluated: d->currentIndex.row() != previous.row()
TRUEFALSE
yes
Evaluation Count:2497
yes
Evaluation Count:449
449-2497
831 d->currentIndex.parent() != previous.parent())
evaluated: d->currentIndex.parent() != previous.parent()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:439
10-439
832 currentRowChanged(d->currentIndex, previous);
executed: currentRowChanged(d->currentIndex, previous);
Execution Count:2507
2507
833 if (d->currentIndex.column() != previous.column() ||
evaluated: d->currentIndex.column() != previous.column()
TRUEFALSE
yes
Evaluation Count:1611
yes
Evaluation Count:1335
1335-1611
834 d->currentIndex.parent() != previous.parent())
evaluated: d->currentIndex.parent() != previous.parent()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:1313
22-1313
835 currentColumnChanged(d->currentIndex, previous);
executed: currentColumnChanged(d->currentIndex, previous);
Execution Count:1633
1633
836}
executed: }
Execution Count:2946
2946
837 -
838 -
839 -
840 -
841 -
842QModelIndex QItemSelectionModel::currentIndex() const -
843{ -
844 return static_cast<QModelIndex>(d_func()->currentIndex);
executed: return static_cast<QModelIndex>(d_func()->currentIndex);
Execution Count:25341
25341
845} -
846 -
847 -
848 -
849 -
850bool QItemSelectionModel::isSelected(const QModelIndex &index) const -
851{ -
852 const QItemSelectionModelPrivate * const d = d_func(); -
853 if (d->model != index.model() || !index.isValid())
evaluated: d->model != index.model()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:17954
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17954
0-17954
854 return false;
executed: return false;
Execution Count:13
13
855 -
856 bool selected = false; -
857 -
858 QList<QItemSelectionRange>::const_iterator it = d->ranges.begin(); -
859 for (; it != d->ranges.end(); ++it) {
evaluated: it != d->ranges.end()
TRUEFALSE
yes
Evaluation Count:1123
yes
Evaluation Count:17677
1123-17677
860 if ((*it).isValid() && (*it).contains(index)) {
partially evaluated: (*it).isValid()
TRUEFALSE
yes
Evaluation Count:1123
no
Evaluation Count:0
evaluated: (*it).contains(index)
TRUEFALSE
yes
Evaluation Count:277
yes
Evaluation Count:846
0-1123
861 selected = true; -
862 break;
executed: break;
Execution Count:277
277
863 } -
864 }
executed: }
Execution Count:846
846
865 -
866 -
867 if (d->currentSelection.count()) {
evaluated: d->currentSelection.count()
TRUEFALSE
yes
Evaluation Count:6237
yes
Evaluation Count:11717
6237-11717
868 if ((d->currentCommand & Deselect) && selected)
evaluated: (d->currentCommand & Deselect)
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:6103
evaluated: selected
TRUEFALSE
yes
Evaluation Count:125
yes
Evaluation Count:9
9-6103
869 selected = !d->currentSelection.contains(index);
executed: selected = !d->currentSelection.contains(index);
Execution Count:125
125
870 else if (d->currentCommand & Toggle)
evaluated: d->currentCommand & Toggle
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:6047
65-6047
871 selected ^= d->currentSelection.contains(index);
executed: selected ^= d->currentSelection.contains(index);
Execution Count:65
65
872 else if ((d->currentCommand & Select) && !selected)
evaluated: (d->currentCommand & Select)
TRUEFALSE
yes
Evaluation Count:6038
yes
Evaluation Count:9
evaluated: !selected
TRUEFALSE
yes
Evaluation Count:5988
yes
Evaluation Count:50
9-6038
873 selected = d->currentSelection.contains(index);
executed: selected = d->currentSelection.contains(index);
Execution Count:5988
5988
874 } -
875 -
876 if (selected) {
evaluated: selected
TRUEFALSE
yes
Evaluation Count:1250
yes
Evaluation Count:16704
1250-16704
877 Qt::ItemFlags flags = d->model->flags(index); -
878 return (flags & Qt::ItemIsSelectable);
executed: return (flags & Qt::ItemIsSelectable);
Execution Count:1250
1250
879 } -
880 -
881 return false;
executed: return false;
Execution Count:16704
16704
882} -
883bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent) const -
884{ -
885 const QItemSelectionModelPrivate * const d = d_func(); -
886 if (parent.isValid() && d->model != parent.model())
evaluated: parent.isValid()
TRUEFALSE
yes
Evaluation Count:170
yes
Evaluation Count:343
partially evaluated: d->model != parent.model()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:170
0-343
887 return false;
never executed: return false;
0
888 -
889 -
890 if (d->currentCommand & Deselect && d->currentSelection.count()) {
evaluated: d->currentCommand & Deselect
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:503
partially evaluated: d->currentSelection.count()
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-503
891 for (int i=0; i<d->currentSelection.count(); ++i) {
evaluated: i<d->currentSelection.count()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:3
3-10
892 if (d->currentSelection.at(i).parent() == parent &&
partially evaluated: d->currentSelection.at(i).parent() == parent
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
893 row >= d->currentSelection.at(i).top() &&
evaluated: row >= d->currentSelection.at(i).top()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:3
3-7
894 row <= d->currentSelection.at(i).bottom())
partially evaluated: row <= d->currentSelection.at(i).bottom()
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
895 return false;
executed: return false;
Execution Count:7
7
896 }
executed: }
Execution Count:3
3
897 }
executed: }
Execution Count:3
3
898 -
899 -
900 if (d->currentCommand & Toggle && d->currentSelection.count()) {
evaluated: d->currentCommand & Toggle
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:486
partially evaluated: d->currentSelection.count()
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
0-486
901 for (int i=0; i<d->currentSelection.count(); ++i)
evaluated: i<d->currentSelection.count()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:20
20
902 if (d->currentSelection.at(i).top() <= row &&
evaluated: d->currentSelection.at(i).top() <= row
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:10
10
903 d->currentSelection.at(i).bottom() >= row)
partially evaluated: d->currentSelection.at(i).bottom() >= row
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
904 for (int j=0; j<d->ranges.count(); ++j)
never evaluated: j<d->ranges.count()
0
905 if (d->ranges.at(j).top() <= row && d->ranges.at(j).bottom() >= row
never evaluated: d->ranges.at(j).top() <= row
never evaluated: d->ranges.at(j).bottom() >= row
0
906 && d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid())
never evaluated: d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid()
0
907 return false;
never executed: return false;
0
908 }
executed: }
Execution Count:20
20
909 -
910 QList<QItemSelectionRange>::const_iterator it; -
911 QList<QItemSelectionRange> joined = d->ranges; -
912 if (d->currentSelection.count())
evaluated: d->currentSelection.count()
TRUEFALSE
yes
Evaluation Count:505
yes
Evaluation Count:1
1-505
913 joined += d->currentSelection;
executed: joined += d->currentSelection;
Execution Count:505
505
914 int colCount = d->model->columnCount(parent); -
915 for (int column = 0; column < colCount; ++column) {
evaluated: column < colCount
TRUEFALSE
yes
Evaluation Count:509
yes
Evaluation Count:327
327-509
916 for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
evaluated: it != joined.constEnd()
TRUEFALSE
yes
Evaluation Count:824
yes
Evaluation Count:179
179-824
917 if ((*it).contains(row, column, parent)) {
evaluated: (*it).contains(row, column, parent)
TRUEFALSE
yes
Evaluation Count:340
yes
Evaluation Count:484
340-484
918 bool selectable = false; -
919 for (int i = column; !selectable && i <= (*it).right(); ++i) {
evaluated: !selectable
TRUEFALSE
yes
Evaluation Count:351
yes
Evaluation Count:330
evaluated: i <= (*it).right()
TRUEFALSE
yes
Evaluation Count:341
yes
Evaluation Count:10
10-351
920 Qt::ItemFlags flags = d->model->index(row, i, parent).flags(); -
921 selectable = flags & Qt::ItemIsSelectable; -
922 }
executed: }
Execution Count:341
341
923 if (selectable){
evaluated: selectable
TRUEFALSE
yes
Evaluation Count:330
yes
Evaluation Count:10
10-330
924 column = qMax(column, (*it).right()); -
925 break;
executed: break;
Execution Count:330
330
926 } -
927 }
executed: }
Execution Count:10
10
928 }
executed: }
Execution Count:494
494
929 if (it == joined.constEnd())
evaluated: it == joined.constEnd()
TRUEFALSE
yes
Evaluation Count:179
yes
Evaluation Count:330
179-330
930 return false;
executed: return false;
Execution Count:179
179
931 }
executed: }
Execution Count:330
330
932 return colCount > 0;
executed: return colCount > 0;
Execution Count:327
327
933} -
934bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent) const -
935{ -
936 const QItemSelectionModelPrivate * const d = d_func(); -
937 if (parent.isValid() && d->model != parent.model())
evaluated: parent.isValid()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:430
partially evaluated: d->model != parent.model()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-430
938 return false;
never executed: return false;
0
939 -
940 -
941 if (d->currentCommand & Deselect && d->currentSelection.count()) {
evaluated: d->currentCommand & Deselect
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:430
partially evaluated: d->currentSelection.count()
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-430
942 for (int i = 0; i < d->currentSelection.count(); ++i) {
evaluated: i < d->currentSelection.count()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:3
3-10
943 if (d->currentSelection.at(i).parent() == parent &&
partially evaluated: d->currentSelection.at(i).parent() == parent
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
944 column >= d->currentSelection.at(i).left() &&
evaluated: column >= d->currentSelection.at(i).left()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:3
3-7
945 column <= d->currentSelection.at(i).right())
partially evaluated: column <= d->currentSelection.at(i).right()
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
946 return false;
executed: return false;
Execution Count:7
7
947 }
executed: }
Execution Count:3
3
948 }
executed: }
Execution Count:3
3
949 -
950 -
951 if (d->currentCommand & Toggle && d->currentSelection.count()) {
partially evaluated: d->currentCommand & Toggle
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:433
never evaluated: d->currentSelection.count()
0-433
952 for (int i = 0; i < d->currentSelection.count(); ++i) {
never evaluated: i < d->currentSelection.count()
0
953 if (d->currentSelection.at(i).left() <= column &&
never evaluated: d->currentSelection.at(i).left() <= column
0
954 d->currentSelection.at(i).right() >= column) {
never evaluated: d->currentSelection.at(i).right() >= column
0
955 for (int j = 0; j < d->ranges.count(); ++j) {
never evaluated: j < d->ranges.count()
0
956 if (d->ranges.at(j).left() <= column && d->ranges.at(j).right() >= column
never evaluated: d->ranges.at(j).left() <= column
never evaluated: d->ranges.at(j).right() >= column
0
957 && d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid()) {
never evaluated: d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid()
0
958 return false;
never executed: return false;
0
959 } -
960 }
never executed: }
0
961 }
never executed: }
0
962 }
never executed: }
0
963 }
never executed: }
0
964 -
965 QList<QItemSelectionRange>::const_iterator it; -
966 QList<QItemSelectionRange> joined = d->ranges; -
967 if (d->currentSelection.count())
evaluated: d->currentSelection.count()
TRUEFALSE
yes
Evaluation Count:377
yes
Evaluation Count:56
56-377
968 joined += d->currentSelection;
executed: joined += d->currentSelection;
Execution Count:377
377
969 int rowCount = d->model->rowCount(parent); -
970 for (int row = 0; row < rowCount; ++row) {
evaluated: row < rowCount
TRUEFALSE
yes
Evaluation Count:445
yes
Evaluation Count:110
110-445
971 for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
evaluated: it != joined.constEnd()
TRUEFALSE
yes
Evaluation Count:558
yes
Evaluation Count:323
323-558
972 if ((*it).contains(row, column, parent)) {
evaluated: (*it).contains(row, column, parent)
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:436
122-436
973 Qt::ItemFlags flags = d->model->index(row, column, parent).flags(); -
974 if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) {
partially evaluated: (flags & Qt::ItemIsSelectable)
TRUEFALSE
yes
Evaluation Count:122
no
Evaluation Count:0
partially evaluated: (flags & Qt::ItemIsEnabled)
TRUEFALSE
yes
Evaluation Count:122
no
Evaluation Count:0
0-122
975 row = qMax(row, (*it).bottom()); -
976 break;
executed: break;
Execution Count:122
122
977 } -
978 }
never executed: }
0
979 }
executed: }
Execution Count:436
436
980 if (it == joined.constEnd())
evaluated: it == joined.constEnd()
TRUEFALSE
yes
Evaluation Count:323
yes
Evaluation Count:122
122-323
981 return false;
executed: return false;
Execution Count:323
323
982 }
executed: }
Execution Count:122
122
983 return rowCount > 0;
executed: return rowCount > 0;
Execution Count:110
110
984} -
985 -
986 -
987 -
988 -
989 -
990bool QItemSelectionModel::rowIntersectsSelection(int row, const QModelIndex &parent) const -
991{ -
992 const QItemSelectionModelPrivate * const d = d_func(); -
993 if (parent.isValid() && d->model != parent.model())
evaluated: parent.isValid()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:355
partially evaluated: d->model != parent.model()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-355
994 return false;
never executed: return false;
0
995 -
996 QItemSelection sel = d->ranges; -
997 sel.merge(d->currentSelection, d->currentCommand); -
998 for (int i = 0; i < sel.count(); ++i) {
evaluated: i < sel.count()
TRUEFALSE
yes
Evaluation Count:128
yes
Evaluation Count:301
128-301
999 QItemSelectionRange range = sel.at(i); -
1000 if (range.parent() != parent)
evaluated: range.parent() != parent
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:125
3-125
1001 return false;
executed: return false;
Execution Count:3
3
1002 int top = range.top(); -
1003 int bottom = range.bottom(); -
1004 int left = range.left(); -
1005 int right = range.right(); -
1006 if (top <= row && bottom >= row) {
evaluated: top <= row
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:30
evaluated: bottom >= row
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:38
30-95
1007 for (int j = left; j <= right; j++) {
evaluated: j <= right
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:3
3-59
1008 const Qt::ItemFlags flags = d->model->index(row, j, parent).flags(); -
1009 if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled))
partially evaluated: (flags & Qt::ItemIsSelectable)
TRUEFALSE
yes
Evaluation Count:59
no
Evaluation Count:0
evaluated: (flags & Qt::ItemIsEnabled)
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:5
0-59
1010 return true;
executed: return true;
Execution Count:54
54
1011 }
executed: }
Execution Count:5
5
1012 }
executed: }
Execution Count:3
3
1013 }
executed: }
Execution Count:71
71
1014 -
1015 return false;
executed: return false;
Execution Count:301
301
1016} -
1017 -
1018 -
1019 -
1020 -
1021 -
1022bool QItemSelectionModel::columnIntersectsSelection(int column, const QModelIndex &parent) const -
1023{ -
1024 const QItemSelectionModelPrivate * const d = d_func(); -
1025 if (parent.isValid() && d->model != parent.model())
partially evaluated: parent.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:222
never evaluated: d->model != parent.model()
0-222
1026 return false;
never executed: return false;
0
1027 -
1028 QItemSelection sel = d->ranges; -
1029 sel.merge(d->currentSelection, d->currentCommand); -
1030 for (int i = 0; i < sel.count(); ++i) {
evaluated: i < sel.count()
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:167
92-167
1031 int left = sel.at(i).left(); -
1032 int right = sel.at(i).right(); -
1033 int top = sel.at(i).top(); -
1034 int bottom = sel.at(i).bottom(); -
1035 if (left <= column && right >= column) {
evaluated: left <= column
TRUEFALSE
yes
Evaluation Count:83
yes
Evaluation Count:9
evaluated: right >= column
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:24
9-83
1036 for (int j = top; j <= bottom; j++) {
evaluated: j <= bottom
TRUEFALSE
yes
Evaluation Count:66
yes
Evaluation Count:4
4-66
1037 const Qt::ItemFlags flags = d->model->index(j, column, parent).flags(); -
1038 if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled))
partially evaluated: (flags & Qt::ItemIsSelectable)
TRUEFALSE
yes
Evaluation Count:66
no
Evaluation Count:0
evaluated: (flags & Qt::ItemIsEnabled)
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:11
0-66
1039 return true;
executed: return true;
Execution Count:55
55
1040 }
executed: }
Execution Count:11
11
1041 }
executed: }
Execution Count:4
4
1042 }
executed: }
Execution Count:37
37
1043 -
1044 return false;
executed: return false;
Execution Count:167
167
1045} -
1046 -
1047 -
1048 -
1049 -
1050 -
1051 -
1052 -
1053bool QItemSelectionModel::hasSelection() const -
1054{ -
1055 const QItemSelectionModelPrivate * const d = d_func(); -
1056 if (d->currentCommand & (Toggle | Deselect)) {
evaluated: d->currentCommand & (Toggle | Deselect)
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:523
38-523
1057 QItemSelection sel = d->ranges; -
1058 sel.merge(d->currentSelection, d->currentCommand); -
1059 return !sel.isEmpty();
executed: return !sel.isEmpty();
Execution Count:38
38
1060 } else { -
1061 return !(d->ranges.isEmpty() && d->currentSelection.isEmpty());
executed: return !(d->ranges.isEmpty() && d->currentSelection.isEmpty());
Execution Count:523
523
1062 } -
1063} -
1064 -
1065 -
1066 -
1067 -
1068 -
1069QModelIndexList QItemSelectionModel::selectedIndexes() const -
1070{ -
1071 const QItemSelectionModelPrivate * const d = d_func(); -
1072 QItemSelection selected = d->ranges; -
1073 selected.merge(d->currentSelection, d->currentCommand); -
1074 return selected.indexes();
executed: return selected.indexes();
Execution Count:375
375
1075} -
1076QModelIndexList QItemSelectionModel::selectedRows(int column) const -
1077{ -
1078 QModelIndexList indexes; -
1079 -
1080 -
1081 QSet< QPair<QModelIndex, int> > rowsSeen; -
1082 -
1083 const QItemSelection ranges = selection(); -
1084 for (int i = 0; i < ranges.count(); ++i) {
evaluated: i < ranges.count()
TRUEFALSE
yes
Evaluation Count:205
yes
Evaluation Count:678
205-678
1085 const QItemSelectionRange &range = ranges.at(i); -
1086 QModelIndex parent = range.parent(); -
1087 for (int row = range.top(); row <= range.bottom(); row++) {
evaluated: row <= range.bottom()
TRUEFALSE
yes
Evaluation Count:232
yes
Evaluation Count:205
205-232
1088 QPair<QModelIndex, int> rowDef = qMakePair(parent, row); -
1089 if (!rowsSeen.contains(rowDef)) {
partially evaluated: !rowsSeen.contains(rowDef)
TRUEFALSE
yes
Evaluation Count:232
no
Evaluation Count:0
0-232
1090 rowsSeen << rowDef; -
1091 if (isRowSelected(row, parent)) {
evaluated: isRowSelected(row, parent)
TRUEFALSE
yes
Evaluation Count:222
yes
Evaluation Count:10
10-222
1092 indexes.append(model()->index(row, column, parent)); -
1093 }
executed: }
Execution Count:222
222
1094 }
executed: }
Execution Count:232
232
1095 }
executed: }
Execution Count:232
232
1096 }
executed: }
Execution Count:205
205
1097 -
1098 return indexes;
executed: return indexes;
Execution Count:678
678
1099} -
1100QModelIndexList QItemSelectionModel::selectedColumns(int row) const -
1101{ -
1102 QModelIndexList indexes; -
1103 -
1104 -
1105 QSet< QPair<QModelIndex, int> > columnsSeen; -
1106 -
1107 const QItemSelection ranges = selection(); -
1108 for (int i = 0; i < ranges.count(); ++i) {
evaluated: i < ranges.count()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:10
10-22
1109 const QItemSelectionRange &range = ranges.at(i); -
1110 QModelIndex parent = range.parent(); -
1111 for (int column = range.left(); column <= range.right(); column++) {
evaluated: column <= range.right()
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:22
22-59
1112 QPair<QModelIndex, int> columnDef = qMakePair(parent, column); -
1113 if (!columnsSeen.contains(columnDef)) {
partially evaluated: !columnsSeen.contains(columnDef)
TRUEFALSE
yes
Evaluation Count:59
no
Evaluation Count:0
0-59
1114 columnsSeen << columnDef; -
1115 if (isColumnSelected(column, parent)) {
evaluated: isColumnSelected(column, parent)
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:30
29-30
1116 indexes.append(model()->index(row, column, parent)); -
1117 }
executed: }
Execution Count:29
29
1118 }
executed: }
Execution Count:59
59
1119 }
executed: }
Execution Count:59
59
1120 }
executed: }
Execution Count:22
22
1121 -
1122 return indexes;
executed: return indexes;
Execution Count:10
10
1123} -
1124 -
1125 -
1126 -
1127 -
1128const QItemSelection QItemSelectionModel::selection() const -
1129{ -
1130 const QItemSelectionModelPrivate * const d = d_func(); -
1131 QItemSelection selected = d->ranges; -
1132 selected.merge(d->currentSelection, d->currentCommand); -
1133 int i = 0; -
1134 -
1135 -
1136 while (i<selected.count()) {
evaluated: i<selected.count()
TRUEFALSE
yes
Evaluation Count:311
yes
Evaluation Count:1039
311-1039
1137 if (selected.at(i).isValid())
partially evaluated: selected.at(i).isValid()
TRUEFALSE
yes
Evaluation Count:311
no
Evaluation Count:0
0-311
1138 ++i;
executed: ++i;
Execution Count:311
311
1139 else -
1140 (selected.removeAt(i));
never executed: (selected.removeAt(i));
0
1141 } -
1142 return selected;
executed: return selected;
Execution Count:1039
1039
1143} -
1144 -
1145 -
1146 -
1147 -
1148const QAbstractItemModel *QItemSelectionModel::model() const -
1149{ -
1150 return d_func()->model;
executed: return d_func()->model;
Execution Count:5788
5788
1151} -
1152 -
1153 -
1154 -
1155 -
1156 -
1157void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelection, -
1158 const QItemSelection &oldSelection) -
1159{ -
1160 -
1161 if ((oldSelection.isEmpty() && newSelection.isEmpty()) ||
evaluated: oldSelection.isEmpty()
TRUEFALSE
yes
Evaluation Count:2238
yes
Evaluation Count:3264
evaluated: newSelection.isEmpty()
TRUEFALSE
yes
Evaluation Count:611
yes
Evaluation Count:1627
611-3264
1162 oldSelection == newSelection)
evaluated: oldSelection == newSelection
TRUEFALSE
yes
Evaluation Count:732
yes
Evaluation Count:4159
732-4159
1163 return;
executed: return;
Execution Count:1343
1343
1164 -
1165 -
1166 if (oldSelection.isEmpty() || newSelection.isEmpty()) {
evaluated: oldSelection.isEmpty()
TRUEFALSE
yes
Evaluation Count:1627
yes
Evaluation Count:2532
evaluated: newSelection.isEmpty()
TRUEFALSE
yes
Evaluation Count:933
yes
Evaluation Count:1599
933-2532
1167 selectionChanged(newSelection, oldSelection); -
1168 return;
executed: return;
Execution Count:2560
2560
1169 } -
1170 -
1171 QItemSelection deselected = oldSelection; -
1172 QItemSelection selected = newSelection; -
1173 -
1174 -
1175 bool advance; -
1176 for (int o = 0; o < deselected.count(); ++o) {
evaluated: o < deselected.count()
TRUEFALSE
yes
Evaluation Count:1638
yes
Evaluation Count:1599
1599-1638
1177 advance = true; -
1178 for (int s = 0; s < selected.count() && o < deselected.count();) {
evaluated: s < selected.count()
TRUEFALSE
yes
Evaluation Count:2199
yes
Evaluation Count:1560
evaluated: o < deselected.count()
TRUEFALSE
yes
Evaluation Count:2121
yes
Evaluation Count:78
78-2199
1179 if (deselected.at(o) == selected.at(s)) {
evaluated: deselected.at(o) == selected.at(s)
TRUEFALSE
yes
Evaluation Count:383
yes
Evaluation Count:1738
383-1738
1180 deselected.removeAt(o); -
1181 selected.removeAt(s); -
1182 advance = false; -
1183 } else {
executed: }
Execution Count:383
383
1184 ++s; -
1185 }
executed: }
Execution Count:1738
1738
1186 } -
1187 if (advance)
evaluated: advance
TRUEFALSE
yes
Evaluation Count:1526
yes
Evaluation Count:112
112-1526
1188 ++o;
executed: ++o;
Execution Count:1526
1526
1189 }
executed: }
Execution Count:1638
1638
1190 -
1191 -
1192 QItemSelection intersections; -
1193 for (int o = 0; o < deselected.count(); ++o) {
evaluated: o < deselected.count()
TRUEFALSE
yes
Evaluation Count:1578
yes
Evaluation Count:1599
1578-1599
1194 for (int s = 0; s < selected.count(); ++s) {
evaluated: s < selected.count()
TRUEFALSE
yes
Evaluation Count:1780
yes
Evaluation Count:1578
1578-1780
1195 if (deselected.at(o).intersects(selected.at(s)))
evaluated: deselected.at(o).intersects(selected.at(s))
TRUEFALSE
yes
Evaluation Count:155
yes
Evaluation Count:1625
155-1625
1196 intersections.append(deselected.at(o).intersected(selected.at(s)));
executed: intersections.append(deselected.at(o).intersected(selected.at(s)));
Execution Count:155
155
1197 }
executed: }
Execution Count:1780
1780
1198 }
executed: }
Execution Count:1578
1578
1199 -
1200 -
1201 for (int i = 0; i < intersections.count(); ++i) {
evaluated: i < intersections.count()
TRUEFALSE
yes
Evaluation Count:155
yes
Evaluation Count:1599
155-1599
1202 -
1203 for (int o = 0; o < deselected.count();) {
evaluated: o < deselected.count()
TRUEFALSE
yes
Evaluation Count:442
yes
Evaluation Count:155
155-442
1204 if (deselected.at(o).intersects(intersections.at(i))) {
evaluated: deselected.at(o).intersects(intersections.at(i))
TRUEFALSE
yes
Evaluation Count:155
yes
Evaluation Count:287
155-287
1205 QItemSelection::split(deselected.at(o), intersections.at(i), &deselected); -
1206 deselected.removeAt(o); -
1207 } else {
executed: }
Execution Count:155
155
1208 ++o; -
1209 }
executed: }
Execution Count:287
287
1210 } -
1211 -
1212 for (int s = 0; s < selected.count();) {
evaluated: s < selected.count()
TRUEFALSE
yes
Evaluation Count:456
yes
Evaluation Count:155
155-456
1213 if (selected.at(s).intersects(intersections.at(i))) {
evaluated: selected.at(s).intersects(intersections.at(i))
TRUEFALSE
yes
Evaluation Count:165
yes
Evaluation Count:291
165-291
1214 QItemSelection::split(selected.at(s), intersections.at(i), &selected); -
1215 selected.removeAt(s); -
1216 } else {
executed: }
Execution Count:165
165
1217 ++s; -
1218 }
executed: }
Execution Count:291
291
1219 } -
1220 }
executed: }
Execution Count:155
155
1221 -
1222 if (!selected.isEmpty() || !deselected.isEmpty())
evaluated: !selected.isEmpty()
TRUEFALSE
yes
Evaluation Count:1558
yes
Evaluation Count:41
evaluated: !deselected.isEmpty()
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:5
5-1558
1223 selectionChanged(selected, deselected);
executed: selectionChanged(selected, deselected);
Execution Count:1594
1594
1224}
executed: }
Execution Count:1599
1599
1225 -
1226 -
1227QDebug operator<<(QDebug dbg, const QItemSelectionRange &range) -
1228{ -
1229 dbg.nospace() << "QItemSelectionRange(" << range.topLeft() -
1230 << ',' << range.bottomRight() << ')'; -
1231 return dbg.space();
never executed: return dbg.space();
0
1232} -
1233 -
1234 -
1235 -
1236 -
1237 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial