Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const | - |
8 | { | - |
9 | return (isValid() && other.isValid() | 10580 |
10 | && parent() == other.parent() | 10580 |
11 | && model() == other.model() | 10580 |
12 | && ((top() <= other.top() && bottom() >= other.top()) | 10580 |
13 | || (top() >= other.top() && top() <= other.bottom())) | 10580 |
14 | && ((left() <= other.left() && right() >= other.left()) | 10580 |
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:10580 | 10580 |
16 | } | - |
17 | QItemSelectionRange QItemSelectionRange::intersected(const QItemSelectionRange &other) const | - |
18 | { | - |
19 | if (model() == other.model() && parent() == other.parent()) { partially evaluated: model() == other.model() yes Evaluation Count:1151 | no Evaluation Count:0 |
partially evaluated: parent() == other.parent() yes Evaluation Count:1151 | no Evaluation Count:0 |
| 0-1151 |
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:1151 | 1151 |
27 | } | - |
28 | return QItemSelectionRange(); never executed: return QItemSelectionRange(); | 0 |
29 | } | - |
30 | static void rowLengthsFromRange(const QItemSelectionRange &range, QVector<QPair<QPersistentModelIndex, uint> > &result) | - |
31 | { | - |
32 | if (range.isValid() && range.model()) { evaluated: range.isValid() yes Evaluation Count:9 | yes Evaluation Count:2 |
partially evaluated: range.model() 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 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 | | - |
46 | template<typename ModelIndexContainer> | - |
47 | static void indexesFromRange(const QItemSelectionRange &range, ModelIndexContainer &result) | - |
48 | { | - |
49 | if (range.isValid() && range.model()) { partially evaluated: range.isValid() yes Evaluation Count:704 | no Evaluation Count:0 |
partially evaluated: range.model() yes Evaluation Count:704 | no Evaluation Count:0 |
| 0-704 |
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 yes Evaluation Count:1657 | yes Evaluation Count:704 |
| 704-1657 |
54 | const QModelIndex columnLeader = topLeft.sibling(row, topLeft.column()); | - |
55 | for (int column = topLeft.column(); column <= right; ++column) { evaluated: column <= right yes Evaluation Count:3873 | yes Evaluation Count:1657 |
| 1657-3873 |
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) yes Evaluation Count:3862 | yes Evaluation Count:11 |
evaluated: (flags & Qt::ItemIsEnabled) yes Evaluation Count:3860 | yes Evaluation Count:2 |
| 2-3862 |
59 | result.push_back(index); executed: result.push_back(index); Execution Count:3860 | 3860 |
60 | } executed: } Execution Count:3873 | 3873 |
61 | } executed: } Execution Count:1657 | 1657 |
62 | } executed: } Execution Count:704 | 704 |
63 | } executed: } Execution Count:704 | 704 |
64 | | - |
65 | | - |
66 | | - |
67 | | - |
68 | | - |
69 | | - |
70 | bool QItemSelectionRange::isEmpty() const | - |
71 | { | - |
72 | if (!isValid() || !model()) partially evaluated: !isValid() no Evaluation Count:0 | yes Evaluation Count:417 |
partially evaluated: !model() no Evaluation Count:0 | yes Evaluation Count:417 |
| 0-417 |
73 | return true; never executed: return true; | 0 |
74 | | - |
75 | for (int column = left(); column <= right(); ++column) { partially evaluated: column <= right() yes Evaluation Count:417 | no Evaluation Count:0 |
| 0-417 |
76 | for (int row = top(); row <= bottom(); ++row) { partially evaluated: row <= bottom() yes Evaluation Count:417 | no Evaluation Count:0 |
| 0-417 |
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) yes Evaluation Count:417 | no Evaluation Count:0 |
partially evaluated: (flags & Qt::ItemIsEnabled) yes Evaluation Count:417 | no Evaluation Count:0 |
| 0-417 |
80 | return false; executed: return false; Execution Count:417 | 417 |
81 | } | 0 |
82 | } | 0 |
83 | return true; never executed: return true; | 0 |
84 | } | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | QModelIndexList QItemSelectionRange::indexes() const | - |
91 | { | - |
92 | QModelIndexList result; | - |
93 | indexesFromRange(*this, result); | - |
94 | return result; never executed: return result; | 0 |
95 | } | - |
96 | QItemSelection::QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight) | - |
97 | { | - |
98 | select(topLeft, bottomRight); | - |
99 | } executed: } Execution Count:4308 | 4308 |
100 | void QItemSelection::select(const QModelIndex &topLeft, const QModelIndex &bottomRight) | - |
101 | { | - |
102 | if (!topLeft.isValid() || !bottomRight.isValid()) evaluated: !topLeft.isValid() yes Evaluation Count:271 | yes Evaluation Count:4705 |
evaluated: !bottomRight.isValid() yes Evaluation Count:1 | yes Evaluation Count:4704 |
| 1-4705 |
103 | return; executed: return; Execution Count:272 | 272 |
104 | | - |
105 | if ((topLeft.model() != bottomRight.model()) partially evaluated: (topLeft.model() != bottomRight.model()) no Evaluation Count:0 | yes Evaluation Count:4704 |
| 0-4704 |
106 | || topLeft.parent() != bottomRight.parent()) { evaluated: topLeft.parent() != bottomRight.parent() yes Evaluation Count:1 | yes Evaluation Count:4703 |
| 1-4703 |
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() no Evaluation Count:0 | yes Evaluation Count:4703 |
partially evaluated: topLeft.column() > bottomRight.column() no Evaluation Count:0 | yes Evaluation Count:4703 |
| 0-4703 |
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; | 0 |
119 | } | - |
120 | append(QItemSelectionRange(topLeft, bottomRight)); | - |
121 | } executed: } Execution Count:4703 | 4703 |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | bool QItemSelection::contains(const QModelIndex &index) const | - |
129 | { | - |
130 | if (index.flags() & Qt::ItemIsSelectable) { evaluated: index.flags() & Qt::ItemIsSelectable yes Evaluation Count:8680 | yes Evaluation Count:7 |
| 7-8680 |
131 | QList<QItemSelectionRange>::const_iterator it = begin(); | - |
132 | for (; it != end(); ++it) evaluated: it != end() yes Evaluation Count:10805 | yes Evaluation Count:7047 |
| 7047-10805 |
133 | if ((*it).contains(index)) evaluated: (*it).contains(index) yes Evaluation Count:1633 | yes Evaluation Count:9172 |
| 1633-9172 |
134 | return true; executed: return true; Execution Count:1633 | 1633 |
135 | } executed: } Execution Count:7047 | 7047 |
136 | return false; executed: return false; Execution Count:7054 | 7054 |
137 | } | - |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | QModelIndexList QItemSelection::indexes() const | - |
144 | { | - |
145 | QModelIndexList result; | - |
146 | QList<QItemSelectionRange>::const_iterator it = begin(); | - |
147 | for (; it != end(); ++it) evaluated: it != end() yes Evaluation Count:693 | yes Evaluation Count:779 |
| 693-779 |
148 | indexesFromRange(*it, result); executed: indexesFromRange(*it, result); Execution Count:693 | 693 |
149 | return result; executed: return result; Execution Count:779 | 779 |
150 | } | - |
151 | | - |
152 | static 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() yes Evaluation Count:11 | yes Evaluation Count:4184 |
| 11-4184 |
157 | indexesFromRange(*it, result); executed: indexesFromRange(*it, result); Execution Count:11 | 11 |
158 | return result; executed: return result; Execution Count:4184 | 4184 |
159 | } | - |
160 | | - |
161 | static 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:222 | 222 |
167 | } | - |
168 | void QItemSelection::merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command) | - |
169 | { | - |
170 | if (other.isEmpty() || evaluated: other.isEmpty() yes Evaluation Count:210598 | yes Evaluation Count:11755 |
| 11755-210598 |
171 | !(command & QItemSelectionModel::Select || evaluated: command & QItemSelectionModel::Select yes Evaluation Count:10811 | yes Evaluation Count:944 |
| 944-10811 |
172 | command & QItemSelectionModel::Deselect || evaluated: command & QItemSelectionModel::Deselect yes Evaluation Count:830 | yes Evaluation Count:114 |
| 114-830 |
173 | command & QItemSelectionModel::Toggle)) partially evaluated: command & QItemSelectionModel::Toggle yes Evaluation Count:114 | no Evaluation Count:0 |
| 0-114 |
174 | return; executed: return; Execution Count:210598 | 210598 |
175 | | - |
176 | QItemSelection newSelection = other; | - |
177 | | - |
178 | QItemSelection intersections; | - |
179 | QItemSelection::iterator it = newSelection.begin(); | - |
180 | while (it != newSelection.end()) { evaluated: it != newSelection.end() yes Evaluation Count:12205 | yes Evaluation Count:11755 |
| 11755-12205 |
181 | if (!(*it).isValid()) { evaluated: !(*it).isValid() yes Evaluation Count:311 | yes Evaluation Count:11894 |
| 311-11894 |
182 | it = newSelection.erase(it); | - |
183 | continue; executed: continue; Execution Count:311 | 311 |
184 | } | - |
185 | for (int t = 0; t < count(); ++t) { evaluated: t < count() yes Evaluation Count:3436 | yes Evaluation Count:11894 |
| 3436-11894 |
186 | if ((*it).intersects(at(t))) evaluated: (*it).intersects(at(t)) yes Evaluation Count:846 | yes Evaluation Count:2590 |
| 846-2590 |
187 | intersections.append(at(t).intersected(*it)); executed: intersections.append(at(t).intersected(*it)); Execution Count:846 | 846 |
188 | } executed: } Execution Count:3436 | 3436 |
189 | ++it; | - |
190 | } executed: } Execution Count:11894 | 11894 |
191 | | - |
192 | | - |
193 | for (int i = 0; i < intersections.count(); ++i) { evaluated: i < intersections.count() yes Evaluation Count:846 | yes Evaluation Count:11755 |
| 846-11755 |
194 | for (int t = 0; t < count();) { evaluated: t < count() yes Evaluation Count:2939 | yes Evaluation Count:846 |
| 846-2939 |
195 | if (at(t).intersects(intersections.at(i))) { evaluated: at(t).intersects(intersections.at(i)) yes Evaluation Count:846 | yes Evaluation Count:2093 |
| 846-2093 |
196 | split(at(t), intersections.at(i), this); | - |
197 | removeAt(t); | - |
198 | } else { executed: } Execution Count:846 | 846 |
199 | ++t; | - |
200 | } executed: } Execution Count:2093 | 2093 |
201 | } | - |
202 | | - |
203 | for (int n = 0; (command & QItemSelectionModel::Toggle) && n < newSelection.count();) { evaluated: (command & QItemSelectionModel::Toggle) yes Evaluation Count:173 | yes Evaluation Count:765 |
evaluated: n < newSelection.count() yes Evaluation Count:92 | yes Evaluation Count:81 |
| 81-765 |
204 | if (newSelection.at(n).intersects(intersections.at(i))) { evaluated: newSelection.at(n).intersects(intersections.at(i)) yes Evaluation Count:81 | yes Evaluation Count:11 |
| 11-81 |
205 | split(newSelection.at(n), intersections.at(i), &newSelection); | - |
206 | newSelection.removeAt(n); | - |
207 | } else { executed: } Execution Count:81 | 81 |
208 | ++n; | - |
209 | } executed: } Execution Count:11 | 11 |
210 | } | - |
211 | } executed: } Execution Count:846 | 846 |
212 | | - |
213 | if (!(command & QItemSelectionModel::Deselect)) evaluated: !(command & QItemSelectionModel::Deselect) yes Evaluation Count:10925 | yes Evaluation Count:830 |
| 830-10925 |
214 | operator+=(newSelection); executed: operator+=(newSelection); Execution Count:10925 | 10925 |
215 | } executed: } Execution Count:11755 | 11755 |
216 | void 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() no Evaluation Count:0 | yes Evaluation Count:1550 |
evaluated: range.model() != other.model() yes Evaluation Count:1 | yes Evaluation Count:1549 |
| 0-1550 |
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 yes Evaluation Count:209 | yes Evaluation Count:1340 |
| 209-1340 |
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:209 | 209 |
239 | if (other_bottom < bottom) { evaluated: other_bottom < bottom yes Evaluation Count:258 | yes Evaluation Count:1291 |
| 258-1291 |
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:258 | 258 |
245 | if (other_left > left) { evaluated: other_left > left yes Evaluation Count:205 | yes Evaluation Count:1344 |
| 205-1344 |
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:205 | 205 |
251 | if (other_right < right) { evaluated: other_right < right yes Evaluation Count:265 | yes Evaluation Count:1284 |
| 265-1284 |
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:265 | 265 |
257 | } executed: } Execution Count:1549 | 1549 |
258 | | - |
259 | | - |
260 | void QItemSelectionModelPrivate::initModel(QAbstractItemModel *model) | - |
261 | { | - |
262 | this->model = model; | - |
263 | if (model) { partially evaluated: model yes Evaluation Count:4165 | no Evaluation Count:0 |
| 0-4165 |
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:4165 | 4165 |
286 | } executed: } Execution Count:4165 | 4165 |
287 | QItemSelection QItemSelectionModelPrivate::expandSelection(const QItemSelection &selection, | - |
288 | QItemSelectionModel::SelectionFlags command) const | - |
289 | { | - |
290 | if (selection.isEmpty() && !((command & QItemSelectionModel::Rows) || evaluated: selection.isEmpty() yes Evaluation Count:11 | yes Evaluation Count:472 |
partially evaluated: (command & QItemSelectionModel::Rows) yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-472 |
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 yes Evaluation Count:461 | yes Evaluation Count:22 |
| 22-461 |
296 | for (int i = 0; i < selection.count(); ++i) { evaluated: i < selection.count() yes Evaluation Count:455 | yes Evaluation Count:461 |
| 455-461 |
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:455 | 455 |
304 | } executed: } Execution Count:461 | 461 |
305 | if (command & QItemSelectionModel::Columns) { evaluated: command & QItemSelectionModel::Columns yes Evaluation Count:22 | yes Evaluation Count:461 |
| 22-461 |
306 | for (int i = 0; i < selection.count(); ++i) { evaluated: i < selection.count() 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:483 | 483 |
316 | } | - |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | void 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() yes Evaluation Count:28 | yes Evaluation Count:3104 |
evaluated: parent == currentIndex.parent() yes Evaluation Count:15 | yes Evaluation Count:13 |
| 13-3104 |
329 | && currentIndex.row() >= start && currentIndex.row() <= end) { evaluated: currentIndex.row() >= start yes Evaluation Count:10 | yes Evaluation Count:5 |
evaluated: currentIndex.row() <= end yes Evaluation Count:4 | yes Evaluation Count:6 |
| 4-10 |
330 | QModelIndex old = currentIndex; | - |
331 | if (start > 0) evaluated: start > 0 yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
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 yes Evaluation Count:3 | no Evaluation Count:0 |
partially evaluated: end < model->rowCount(parent) - 1 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
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:3 | 3 |
337 | q->currentChanged(currentIndex, old); | - |
338 | q->currentRowChanged(currentIndex, old); | - |
339 | if (currentIndex.column() != old.column()) evaluated: currentIndex.column() != old.column() yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
340 | q->currentColumnChanged(currentIndex, old); executed: q->currentColumnChanged(currentIndex, old); Execution Count:3 | 3 |
341 | } executed: } Execution Count:4 | 4 |
342 | | - |
343 | QItemSelection deselected; | - |
344 | QItemSelection newParts; | - |
345 | QItemSelection::iterator it = ranges.begin(); | - |
346 | while (it != ranges.end()) { evaluated: it != ranges.end() yes Evaluation Count:156 | yes Evaluation Count:3132 |
| 156-3132 |
347 | if (it->topLeft().parent() != parent) { evaluated: it->topLeft().parent() != parent yes Evaluation Count:13 | yes Evaluation Count:143 |
| 13-143 |
348 | QModelIndex itParent = it->topLeft().parent(); | - |
349 | while (itParent.isValid() && itParent.parent() != parent) evaluated: itParent.isValid() yes Evaluation Count:7 | yes Evaluation Count:11 |
evaluated: itParent.parent() != parent yes Evaluation Count:5 | yes Evaluation Count:2 |
| 2-11 |
350 | itParent = itParent.parent(); executed: itParent = itParent.parent(); Execution Count:5 | 5 |
351 | | - |
352 | if (itParent.isValid() && start <= itParent.row() && itParent.row() <= end) { evaluated: itParent.isValid() yes Evaluation Count:2 | yes Evaluation Count:11 |
partially evaluated: start <= itParent.row() yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: itParent.row() <= end yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-11 |
353 | deselected.append(*it); | - |
354 | it = ranges.erase(it); | - |
355 | } else { executed: } Execution Count:2 | 2 |
356 | ++it; | - |
357 | } executed: } Execution Count:11 | 11 |
358 | } else if (start <= it->bottom() && it->bottom() <= end evaluated: start <= it->bottom() yes Evaluation Count:131 | yes Evaluation Count:12 |
evaluated: it->bottom() <= end yes Evaluation Count:118 | yes Evaluation Count:13 |
| 12-131 |
359 | && start <= it->top() && it->top() <= end) { evaluated: start <= it->top() yes Evaluation Count:117 | yes Evaluation Count:1 |
partially evaluated: it->top() <= end yes Evaluation Count:117 | no Evaluation Count:0 |
| 0-117 |
360 | deselected.append(*it); | - |
361 | it = ranges.erase(it); | - |
362 | } else if (start <= it->top() && it->top() <= end) { evaluated: start <= it->top() yes Evaluation Count:11 | yes Evaluation Count:15 |
evaluated: it->top() <= end yes Evaluation Count:2 | yes Evaluation Count:9 |
executed: } Execution Count:117 | 2-117 |
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() yes Evaluation Count:12 | yes Evaluation Count:12 |
evaluated: it->bottom() <= end yes Evaluation Count:1 | yes Evaluation Count:11 |
executed: } Execution Count:2 | 1-12 |
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 yes Evaluation Count:14 | yes Evaluation Count:9 |
evaluated: end < it->bottom() yes Evaluation Count:2 | yes Evaluation Count:12 |
executed: } Execution Count:1 | 1-14 |
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:21 | 21 |
382 | } | - |
383 | ranges.append(newParts); | - |
384 | | - |
385 | if (!deselected.isEmpty()) evaluated: !deselected.isEmpty() yes Evaluation Count:124 | yes Evaluation Count:3008 |
| 124-3008 |
386 | q->selectionChanged(QItemSelection(), deselected); executed: q->selectionChanged(QItemSelection(), deselected); Execution Count:124 | 124 |
387 | } executed: } Execution Count:3132 | 3132 |
388 | | - |
389 | | - |
390 | | - |
391 | | - |
392 | void 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() yes Evaluation Count:8 | yes Evaluation Count:272 |
partially evaluated: parent == currentIndex.parent() yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-272 |
399 | && currentIndex.column() >= start && currentIndex.column() <= end) { evaluated: currentIndex.column() >= start yes Evaluation Count:7 | yes Evaluation Count:1 |
evaluated: currentIndex.column() <= end yes Evaluation Count:2 | yes Evaluation Count:5 |
| 1-7 |
400 | QModelIndex old = currentIndex; | - |
401 | if (start > 0) evaluated: start > 0 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 yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: end < model->columnCount() - 1 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() 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:280 | 280 |
419 | | - |
420 | | - |
421 | | - |
422 | | - |
423 | | - |
424 | | - |
425 | void 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() no Evaluation Count:0 | yes Evaluation Count:833 |
| 0-833 |
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 { | 0 |
443 | ++it; | - |
444 | } | 0 |
445 | } | - |
446 | ranges += split; | - |
447 | } executed: } Execution Count:833 | 833 |
448 | | - |
449 | | - |
450 | | - |
451 | | - |
452 | | - |
453 | | - |
454 | void 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() yes Evaluation Count:3034 | yes Evaluation Count:195772 |
| 3034-195772 |
462 | if ((*it).isValid() && (*it).parent() == parent partially evaluated: (*it).isValid() yes Evaluation Count:3034 | no Evaluation Count:0 |
evaluated: (*it).parent() == parent yes Evaluation Count:316 | yes Evaluation Count:2718 |
| 0-3034 |
463 | && (*it).top() < start && (*it).bottom() >= start) { evaluated: (*it).top() < start yes Evaluation Count:312 | yes Evaluation Count:4 |
evaluated: (*it).bottom() >= start yes Evaluation Count:3 | yes Evaluation Count:309 |
| 3-312 |
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:3031 | 3031 |
474 | } | - |
475 | ranges += split; | - |
476 | } executed: } Execution Count:195772 | 195772 |
477 | void 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() yes Evaluation Count:2196 | yes Evaluation Count:7 |
evaluated: currentSelection.count() == 1 yes Evaluation Count:11 | yes Evaluation Count:2185 |
| 7-2196 |
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 no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
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; | 0 |
499 | } | - |
500 | } executed: } Execution Count:11 | 11 |
501 | tableSelected = false; | - |
502 | | - |
503 | if (hint == QAbstractItemModel::VerticalSortHint) { evaluated: hint == QAbstractItemModel::VerticalSortHint yes Evaluation Count:111 | yes Evaluation Count:2092 |
| 111-2092 |
504 | | - |
505 | | - |
506 | | - |
507 | | - |
508 | | - |
509 | savedPersistentRowLengths = qSelectionPersistentRowLengths(ranges); | - |
510 | savedPersistentCurrentRowLengths = qSelectionPersistentRowLengths(currentSelection); | - |
511 | } else { executed: } Execution Count:111 | 111 |
512 | savedPersistentIndexes = qSelectionPersistentindexes(ranges); | - |
513 | savedPersistentCurrentIndexes = qSelectionPersistentindexes(currentSelection); | - |
514 | } executed: } Execution Count:2092 | 2092 |
515 | } | - |
516 | | - |
517 | | - |
518 | | - |
519 | static QItemSelection mergeRowLengths(const QVector<QPair<QPersistentModelIndex, uint> > &rowLengths) | - |
520 | { | - |
521 | if (rowLengths.isEmpty()) evaluated: rowLengths.isEmpty() 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() 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() 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() 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() 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) yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
540 | && (next.row() == br.row() + 1) evaluated: (next.row() == br.row() + 1) yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
541 | && (next.parent() == br.parent())) { partially evaluated: (next.parent() == br.parent()) 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 | | - |
558 | static QItemSelection mergeIndexes(const QVector<QPersistentModelIndex> &indexes) | - |
559 | { | - |
560 | QItemSelection colSpans; | - |
561 | | - |
562 | int i = 0; | - |
563 | while (i < indexes.count()) { evaluated: i < indexes.count() yes Evaluation Count:24 | yes Evaluation Count:20 |
| 20-24 |
564 | const QPersistentModelIndex &tl = indexes.at(i); | - |
565 | if (!tl.isValid()) { partially evaluated: !tl.isValid() no Evaluation Count:0 | yes Evaluation Count:24 |
| 0-24 |
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() yes Evaluation Count:319 | yes Evaluation Count:10 |
| 10-319 |
574 | const QPersistentModelIndex &next = indexes.at(i); | - |
575 | if (!next.isValid()) partially evaluated: !next.isValid() no Evaluation Count:0 | yes Evaluation Count:319 |
| 0-319 |
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) yes Evaluation Count:319 | no Evaluation Count:0 |
| 0-319 |
581 | && (nextRow == brRow) evaluated: (nextRow == brRow) yes Evaluation Count:305 | yes Evaluation Count:14 |
| 14-305 |
582 | && (nextColumn == brColumn + 1)) { partially evaluated: (nextColumn == brColumn + 1) yes Evaluation Count:305 | no Evaluation Count:0 |
| 0-305 |
583 | br = next; | - |
584 | brParent = nextParent; | - |
585 | brRow = nextRow; | - |
586 | brColumn = nextColumn; | - |
587 | } else { executed: } Execution Count:305 | 305 |
588 | break; executed: break; Execution Count:14 | 14 |
589 | } | - |
590 | } | - |
591 | colSpans.append(QItemSelectionRange(tl, br)); | - |
592 | } executed: } Execution Count:24 | 24 |
593 | | - |
594 | QItemSelection rowSpans; | - |
595 | i = 0; | - |
596 | while (i < colSpans.count()) { evaluated: i < colSpans.count() yes Evaluation Count:24 | yes Evaluation Count:20 |
| 20-24 |
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() yes Evaluation Count:14 | yes Evaluation Count:10 |
| 10-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() no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
605 | break; | 0 |
606 | | - |
607 | if ((nextTl.column() == prevTl.column()) && (nextBr.column() == br.column()) partially evaluated: (nextTl.column() == prevTl.column()) yes Evaluation Count:14 | no Evaluation Count:0 |
partially evaluated: (nextBr.column() == br.column()) 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) 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 { | 0 |
612 | break; executed: break; Execution Count:14 | 14 |
613 | } | - |
614 | } | - |
615 | rowSpans.append(QItemSelectionRange(tl, br)); | - |
616 | } executed: } Execution Count:24 | 24 |
617 | return rowSpans; executed: return rowSpans; Execution Count:20 | 20 |
618 | } | - |
619 | | - |
620 | | - |
621 | | - |
622 | | - |
623 | | - |
624 | | - |
625 | void QItemSelectionModelPrivate::_q_layoutChanged(const QList<QPersistentModelIndex> &, QAbstractItemModel::LayoutChangeHint hint) | - |
626 | { | - |
627 | | - |
628 | if (tableSelected && tableColCount == model->columnCount(tableParent) partially evaluated: tableSelected no Evaluation Count:0 | yes Evaluation Count:2204 |
never evaluated: tableColCount == model->columnCount(tableParent) | 0-2204 |
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; | 0 |
640 | } | - |
641 | | - |
642 | if ((hint != QAbstractItemModel::VerticalSortHint && savedPersistentCurrentIndexes.isEmpty() && savedPersistentIndexes.isEmpty()) evaluated: hint != QAbstractItemModel::VerticalSortHint yes Evaluation Count:2093 | yes Evaluation Count:111 |
evaluated: savedPersistentCurrentIndexes.isEmpty() yes Evaluation Count:2088 | yes Evaluation Count:5 |
evaluated: savedPersistentIndexes.isEmpty() yes Evaluation Count:2083 | yes Evaluation Count:5 |
| 5-2093 |
643 | || (hint == QAbstractItemModel::VerticalSortHint && savedPersistentRowLengths.isEmpty() && savedPersistentCurrentRowLengths.isEmpty())) { evaluated: hint == QAbstractItemModel::VerticalSortHint yes Evaluation Count:111 | yes Evaluation Count:10 |
evaluated: savedPersistentRowLengths.isEmpty() yes Evaluation Count:109 | yes Evaluation Count:2 |
evaluated: savedPersistentCurrentRowLengths.isEmpty() yes Evaluation Count:106 | yes Evaluation Count:3 |
| 2-111 |
644 | | - |
645 | | - |
646 | return; executed: return; Execution Count:2189 | 2189 |
647 | } | - |
648 | | - |
649 | | - |
650 | ranges.clear(); | - |
651 | currentSelection.clear(); | - |
652 | | - |
653 | if (hint != QAbstractItemModel::VerticalSortHint) { evaluated: hint != QAbstractItemModel::VerticalSortHint yes Evaluation Count:10 | yes Evaluation Count:5 |
| 5-10 |
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:10 | 10 |
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 | } | - |
679 | QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model) | - |
680 | : QObject(*new QItemSelectionModelPrivate, model) | - |
681 | { | - |
682 | d_func()->initModel(model); | - |
683 | } executed: } Execution Count:32 | 32 |
684 | | - |
685 | | - |
686 | | - |
687 | | - |
688 | QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model, QObject *parent) | - |
689 | : QObject(*new QItemSelectionModelPrivate, parent) | - |
690 | { | - |
691 | d_func()->initModel(model); | - |
692 | } executed: } Execution Count:4133 | 4133 |
693 | | - |
694 | | - |
695 | | - |
696 | | - |
697 | QItemSelectionModel::QItemSelectionModel(QItemSelectionModelPrivate &dd, QAbstractItemModel *model) | - |
698 | : QObject(dd, model) | - |
699 | { | - |
700 | dd.initModel(model); | - |
701 | } | 0 |
702 | | - |
703 | | - |
704 | | - |
705 | | - |
706 | QItemSelectionModel::~QItemSelectionModel() | - |
707 | { | - |
708 | } | - |
709 | | - |
710 | | - |
711 | | - |
712 | | - |
713 | | - |
714 | | - |
715 | | - |
716 | void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) | - |
717 | { | - |
718 | QItemSelection selection(index, index); | - |
719 | select(selection, command); | - |
720 | } executed: } Execution Count:3426 | 3426 |
721 | void QItemSelectionModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) | - |
722 | { | - |
723 | QItemSelectionModelPrivate * const d = d_func(); | - |
724 | if (command == NoUpdate) evaluated: command == NoUpdate yes Evaluation Count:44 | yes Evaluation Count:6493 |
| 44-6493 |
725 | return; executed: return; Execution Count:44 | 44 |
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() yes Evaluation Count:1254 | yes Evaluation Count:6493 |
| 1254-6493 |
736 | if (!it->isValid()) evaluated: !it->isValid() yes Evaluation Count:2 | yes Evaluation Count:1252 |
| 2-1252 |
737 | it = d->ranges.erase(it); executed: it = d->ranges.erase(it); Execution Count:2 | 2 |
738 | else | - |
739 | ++it; executed: ++it; Execution Count:1252 | 1252 |
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 yes Evaluation Count:461 | yes Evaluation Count:6032 |
evaluated: command & Columns yes Evaluation Count:22 | yes Evaluation Count:6010 |
| 22-6032 |
747 | sel = d->expandSelection(sel, command); executed: sel = d->expandSelection(sel, command); Execution Count:483 | 483 |
748 | | - |
749 | | - |
750 | if (command & Clear) { evaluated: command & Clear yes Evaluation Count:4742 | yes Evaluation Count:1751 |
| 1751-4742 |
751 | d->ranges.clear(); | - |
752 | d->currentSelection.clear(); | - |
753 | } executed: } Execution Count:4742 | 4742 |
754 | | - |
755 | | - |
756 | if (!(command & Current)) evaluated: !(command & Current) yes Evaluation Count:5780 | yes Evaluation Count:713 |
| 713-5780 |
757 | d->finalize(); executed: d->finalize(); Execution Count:5780 | 5780 |
758 | | - |
759 | | - |
760 | if (command & Toggle || command & Select || command & Deselect) { evaluated: command & Toggle yes Evaluation Count:28 | yes Evaluation Count:6465 |
evaluated: command & Select yes Evaluation Count:4827 | yes Evaluation Count:1638 |
evaluated: command & Deselect yes Evaluation Count:372 | yes Evaluation Count:1266 |
| 28-6465 |
761 | d->currentCommand = command; | - |
762 | d->currentSelection = sel; | - |
763 | } executed: } Execution Count:5227 | 5227 |
764 | | - |
765 | | - |
766 | QItemSelection newSelection = d->ranges; | - |
767 | newSelection.merge(d->currentSelection, d->currentCommand); | - |
768 | emitSelectionChanged(newSelection, old); | - |
769 | } executed: } Execution Count:6493 | 6493 |
770 | | - |
771 | | - |
772 | | - |
773 | | - |
774 | void QItemSelectionModel::clear() | - |
775 | { | - |
776 | clearSelection(); | - |
777 | clearCurrentIndex(); | - |
778 | } executed: } Execution Count:8326 | 8326 |
779 | | - |
780 | | - |
781 | | - |
782 | | - |
783 | void 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() yes Evaluation Count:801 | yes Evaluation Count:7528 |
| 801-7528 |
789 | currentChanged(d->currentIndex, previous); | - |
790 | currentRowChanged(d->currentIndex, previous); | - |
791 | currentColumnChanged(d->currentIndex, previous); | - |
792 | } executed: } Execution Count:801 | 801 |
793 | } executed: } Execution Count:8329 | 8329 |
794 | | - |
795 | | - |
796 | | - |
797 | | - |
798 | void QItemSelectionModel::reset() | - |
799 | { | - |
800 | bool block = blockSignals(true); | - |
801 | clear(); | - |
802 | blockSignals(block); | - |
803 | } executed: } Execution Count:6095 | 6095 |
804 | | - |
805 | | - |
806 | | - |
807 | | - |
808 | | - |
809 | void QItemSelectionModel::clearSelection() | - |
810 | { | - |
811 | QItemSelectionModelPrivate * const d = d_func(); | - |
812 | if (d->ranges.count() == 0 && d->currentSelection.count() == 0) evaluated: d->ranges.count() == 0 yes Evaluation Count:8287 | yes Evaluation Count:54 |
evaluated: d->currentSelection.count() == 0 yes Evaluation Count:7077 | yes Evaluation Count:1210 |
| 54-8287 |
813 | return; executed: return; Execution Count:7077 | 7077 |
814 | | - |
815 | select(QItemSelection(), Clear); | - |
816 | } executed: } Execution Count:1264 | 1264 |
817 | void QItemSelectionModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) | - |
818 | { | - |
819 | QItemSelectionModelPrivate * const d = d_func(); | - |
820 | if (index == d->currentIndex) { evaluated: index == d->currentIndex yes Evaluation Count:167 | yes Evaluation Count:3576 |
| 167-3576 |
821 | if (command != NoUpdate) evaluated: command != NoUpdate yes Evaluation Count:51 | yes Evaluation Count:116 |
| 51-116 |
822 | select(index, command); executed: select(index, command); Execution Count:51 | 51 |
823 | return; executed: return; Execution Count:167 | 167 |
824 | } | - |
825 | QPersistentModelIndex previous = d->currentIndex; | - |
826 | d->currentIndex = index; | - |
827 | if (command != NoUpdate) evaluated: command != NoUpdate yes Evaluation Count:2726 | yes Evaluation Count:850 |
| 850-2726 |
828 | select(d->currentIndex, command); executed: select(d->currentIndex, command); Execution Count:2726 | 2726 |
829 | currentChanged(d->currentIndex, previous); | - |
830 | if (d->currentIndex.row() != previous.row() || evaluated: d->currentIndex.row() != previous.row() yes Evaluation Count:3035 | yes Evaluation Count:541 |
| 541-3035 |
831 | d->currentIndex.parent() != previous.parent()) evaluated: d->currentIndex.parent() != previous.parent() yes Evaluation Count:14 | yes Evaluation Count:527 |
| 14-527 |
832 | currentRowChanged(d->currentIndex, previous); executed: currentRowChanged(d->currentIndex, previous); Execution Count:3049 | 3049 |
833 | if (d->currentIndex.column() != previous.column() || evaluated: d->currentIndex.column() != previous.column() yes Evaluation Count:1891 | yes Evaluation Count:1685 |
| 1685-1891 |
834 | d->currentIndex.parent() != previous.parent()) evaluated: d->currentIndex.parent() != previous.parent() yes Evaluation Count:28 | yes Evaluation Count:1657 |
| 28-1657 |
835 | currentColumnChanged(d->currentIndex, previous); executed: currentColumnChanged(d->currentIndex, previous); Execution Count:1919 | 1919 |
836 | } executed: } Execution Count:3576 | 3576 |
837 | | - |
838 | | - |
839 | | - |
840 | | - |
841 | | - |
842 | QModelIndex QItemSelectionModel::currentIndex() const | - |
843 | { | - |
844 | return static_cast<QModelIndex>(d_func()->currentIndex); executed: return static_cast<QModelIndex>(d_func()->currentIndex); Execution Count:28221 | 28221 |
845 | } | - |
846 | | - |
847 | | - |
848 | | - |
849 | | - |
850 | bool 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() yes Evaluation Count:20 | yes Evaluation Count:21974 |
partially evaluated: !index.isValid() no Evaluation Count:0 | yes Evaluation Count:21974 |
| 0-21974 |
854 | return false; executed: return false; Execution Count:20 | 20 |
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() yes Evaluation Count:2845 | yes Evaluation Count:21266 |
| 2845-21266 |
860 | if ((*it).isValid() && (*it).contains(index)) { partially evaluated: (*it).isValid() yes Evaluation Count:2845 | no Evaluation Count:0 |
evaluated: (*it).contains(index) yes Evaluation Count:708 | yes Evaluation Count:2137 |
| 0-2845 |
861 | selected = true; | - |
862 | break; executed: break; Execution Count:708 | 708 |
863 | } | - |
864 | } executed: } Execution Count:2137 | 2137 |
865 | | - |
866 | | - |
867 | if (d->currentSelection.count()) { evaluated: d->currentSelection.count() yes Evaluation Count:8944 | yes Evaluation Count:13030 |
| 8944-13030 |
868 | if ((d->currentCommand & Deselect) && selected) evaluated: (d->currentCommand & Deselect) yes Evaluation Count:265 | yes Evaluation Count:8679 |
evaluated: selected yes Evaluation Count:192 | yes Evaluation Count:73 |
| 73-8679 |
869 | selected = !d->currentSelection.contains(index); executed: selected = !d->currentSelection.contains(index); Execution Count:192 | 192 |
870 | else if (d->currentCommand & Toggle) evaluated: d->currentCommand & Toggle yes Evaluation Count:65 | yes Evaluation Count:8687 |
| 65-8687 |
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) yes Evaluation Count:8614 | yes Evaluation Count:73 |
evaluated: !selected yes Evaluation Count:8364 | yes Evaluation Count:250 |
| 73-8614 |
873 | selected = d->currentSelection.contains(index); executed: selected = d->currentSelection.contains(index); Execution Count:8364 | 8364 |
874 | } | - |
875 | | - |
876 | if (selected) { evaluated: selected yes Evaluation Count:1990 | yes Evaluation Count:19984 |
| 1990-19984 |
877 | Qt::ItemFlags flags = d->model->flags(index); | - |
878 | return (flags & Qt::ItemIsSelectable); executed: return (flags & Qt::ItemIsSelectable); Execution Count:1990 | 1990 |
879 | } | - |
880 | | - |
881 | return false; executed: return false; Execution Count:19984 | 19984 |
882 | } | - |
883 | bool 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() yes Evaluation Count:220 | yes Evaluation Count:929 |
partially evaluated: d->model != parent.model() no Evaluation Count:0 | yes Evaluation Count:220 |
| 0-929 |
887 | return false; never executed: return false; | 0 |
888 | | - |
889 | | - |
890 | if (d->currentCommand & Deselect && d->currentSelection.count()) { evaluated: d->currentCommand & Deselect yes Evaluation Count:76 | yes Evaluation Count:1073 |
partially evaluated: d->currentSelection.count() yes Evaluation Count:76 | no Evaluation Count:0 |
| 0-1073 |
891 | for (int i=0; i<d->currentSelection.count(); ++i) { evaluated: i<d->currentSelection.count() yes Evaluation Count:76 | yes Evaluation Count:55 |
| 55-76 |
892 | if (d->currentSelection.at(i).parent() == parent && partially evaluated: d->currentSelection.at(i).parent() == parent yes Evaluation Count:76 | no Evaluation Count:0 |
| 0-76 |
893 | row >= d->currentSelection.at(i).top() && evaluated: row >= d->currentSelection.at(i).top() yes Evaluation Count:62 | yes Evaluation Count:14 |
| 14-62 |
894 | row <= d->currentSelection.at(i).bottom()) evaluated: row <= d->currentSelection.at(i).bottom() yes Evaluation Count:21 | yes Evaluation Count:41 |
| 21-41 |
895 | return false; executed: return false; Execution Count:21 | 21 |
896 | } executed: } Execution Count:55 | 55 |
897 | } executed: } Execution Count:55 | 55 |
898 | | - |
899 | | - |
900 | if (d->currentCommand & Toggle && d->currentSelection.count()) { evaluated: d->currentCommand & Toggle yes Evaluation Count:20 | yes Evaluation Count:1108 |
partially evaluated: d->currentSelection.count() yes Evaluation Count:20 | no Evaluation Count:0 |
| 0-1108 |
901 | for (int i=0; i<d->currentSelection.count(); ++i) evaluated: i<d->currentSelection.count() yes Evaluation Count:20 | yes Evaluation Count:20 |
| 20 |
902 | if (d->currentSelection.at(i).top() <= row && evaluated: d->currentSelection.at(i).top() <= row yes Evaluation Count:10 | yes Evaluation Count:10 |
| 10 |
903 | d->currentSelection.at(i).bottom() >= row) partially evaluated: d->currentSelection.at(i).bottom() >= row 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() yes Evaluation Count:1011 | yes Evaluation Count:117 |
| 117-1011 |
913 | joined += d->currentSelection; executed: joined += d->currentSelection; Execution Count:1011 | 1011 |
914 | int colCount = d->model->columnCount(parent); | - |
915 | for (int column = 0; column < colCount; ++column) { evaluated: column < colCount yes Evaluation Count:1407 | yes Evaluation Count:397 |
| 397-1407 |
916 | for (it = joined.constBegin(); it != joined.constEnd(); ++it) { evaluated: it != joined.constEnd() yes Evaluation Count:2682 | yes Evaluation Count:731 |
| 731-2682 |
917 | if ((*it).contains(row, column, parent)) { evaluated: (*it).contains(row, column, parent) yes Evaluation Count:686 | yes Evaluation Count:1996 |
| 686-1996 |
918 | bool selectable = false; | - |
919 | for (int i = column; !selectable && i <= (*it).right(); ++i) { evaluated: !selectable yes Evaluation Count:697 | yes Evaluation Count:676 |
evaluated: i <= (*it).right() yes Evaluation Count:687 | yes Evaluation Count:10 |
| 10-697 |
920 | Qt::ItemFlags flags = d->model->index(row, i, parent).flags(); | - |
921 | selectable = flags & Qt::ItemIsSelectable; | - |
922 | } executed: } Execution Count:687 | 687 |
923 | if (selectable){ evaluated: selectable yes Evaluation Count:676 | yes Evaluation Count:10 |
| 10-676 |
924 | column = qMax(column, (*it).right()); | - |
925 | break; executed: break; Execution Count:676 | 676 |
926 | } | - |
927 | } executed: } Execution Count:10 | 10 |
928 | } executed: } Execution Count:2006 | 2006 |
929 | if (it == joined.constEnd()) evaluated: it == joined.constEnd() yes Evaluation Count:731 | yes Evaluation Count:676 |
| 676-731 |
930 | return false; executed: return false; Execution Count:731 | 731 |
931 | } executed: } Execution Count:676 | 676 |
932 | return colCount > 0; executed: return colCount > 0; Execution Count:397 | 397 |
933 | } | - |
934 | bool 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() yes Evaluation Count:20 | yes Evaluation Count:867 |
partially evaluated: d->model != parent.model() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-867 |
938 | return false; never executed: return false; | 0 |
939 | | - |
940 | | - |
941 | if (d->currentCommand & Deselect && d->currentSelection.count()) { evaluated: d->currentCommand & Deselect yes Evaluation Count:50 | yes Evaluation Count:837 |
partially evaluated: d->currentSelection.count() yes Evaluation Count:50 | no Evaluation Count:0 |
| 0-837 |
942 | for (int i = 0; i < d->currentSelection.count(); ++i) { evaluated: i < d->currentSelection.count() yes Evaluation Count:50 | yes Evaluation Count:29 |
| 29-50 |
943 | if (d->currentSelection.at(i).parent() == parent && partially evaluated: d->currentSelection.at(i).parent() == parent yes Evaluation Count:50 | no Evaluation Count:0 |
| 0-50 |
944 | column >= d->currentSelection.at(i).left() && evaluated: column >= d->currentSelection.at(i).left() yes Evaluation Count:41 | yes Evaluation Count:9 |
| 9-41 |
945 | column <= d->currentSelection.at(i).right()) evaluated: column <= d->currentSelection.at(i).right() yes Evaluation Count:21 | yes Evaluation Count:20 |
| 20-21 |
946 | return false; executed: return false; Execution Count:21 | 21 |
947 | } executed: } Execution Count:29 | 29 |
948 | } executed: } Execution Count:29 | 29 |
949 | | - |
950 | | - |
951 | if (d->currentCommand & Toggle && d->currentSelection.count()) { partially evaluated: d->currentCommand & Toggle no Evaluation Count:0 | yes Evaluation Count:866 |
never evaluated: d->currentSelection.count() | 0-866 |
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 | } | 0 |
961 | } | 0 |
962 | } | 0 |
963 | } | 0 |
964 | | - |
965 | QList<QItemSelectionRange>::const_iterator it; | - |
966 | QList<QItemSelectionRange> joined = d->ranges; | - |
967 | if (d->currentSelection.count()) evaluated: d->currentSelection.count() yes Evaluation Count:750 | yes Evaluation Count:116 |
| 116-750 |
968 | joined += d->currentSelection; executed: joined += d->currentSelection; Execution Count:750 | 750 |
969 | int rowCount = d->model->rowCount(parent); | - |
970 | for (int row = 0; row < rowCount; ++row) { evaluated: row < rowCount yes Evaluation Count:1069 | yes Evaluation Count:127 |
| 127-1069 |
971 | for (it = joined.constBegin(); it != joined.constEnd(); ++it) { evaluated: it != joined.constEnd() yes Evaluation Count:1712 | yes Evaluation Count:739 |
| 739-1712 |
972 | if ((*it).contains(row, column, parent)) { evaluated: (*it).contains(row, column, parent) yes Evaluation Count:334 | yes Evaluation Count:1378 |
| 334-1378 |
973 | Qt::ItemFlags flags = d->model->index(row, column, parent).flags(); | - |
974 | if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) { partially evaluated: (flags & Qt::ItemIsSelectable) yes Evaluation Count:334 | no Evaluation Count:0 |
evaluated: (flags & Qt::ItemIsEnabled) yes Evaluation Count:330 | yes Evaluation Count:4 |
| 0-334 |
975 | row = qMax(row, (*it).bottom()); | - |
976 | break; executed: break; Execution Count:330 | 330 |
977 | } | - |
978 | } executed: } Execution Count:4 | 4 |
979 | } executed: } Execution Count:1382 | 1382 |
980 | if (it == joined.constEnd()) evaluated: it == joined.constEnd() yes Evaluation Count:739 | yes Evaluation Count:330 |
| 330-739 |
981 | return false; executed: return false; Execution Count:739 | 739 |
982 | } executed: } Execution Count:330 | 330 |
983 | return rowCount > 0; executed: return rowCount > 0; Execution Count:127 | 127 |
984 | } | - |
985 | | - |
986 | | - |
987 | | - |
988 | | - |
989 | | - |
990 | bool 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() yes Evaluation Count:3 | yes Evaluation Count:926 |
partially evaluated: d->model != parent.model() no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-926 |
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() yes Evaluation Count:811 | yes Evaluation Count:651 |
| 651-811 |
999 | QItemSelectionRange range = sel.at(i); | - |
1000 | if (range.parent() != parent) evaluated: range.parent() != parent yes Evaluation Count:3 | yes Evaluation Count:808 |
| 3-808 |
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 yes Evaluation Count:554 | yes Evaluation Count:254 |
evaluated: bottom >= row yes Evaluation Count:317 | yes Evaluation Count:237 |
| 237-554 |
1007 | for (int j = left; j <= right; j++) { evaluated: j <= right yes Evaluation Count:334 | yes Evaluation Count:42 |
| 42-334 |
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) yes Evaluation Count:334 | no Evaluation Count:0 |
evaluated: (flags & Qt::ItemIsEnabled) yes Evaluation Count:275 | yes Evaluation Count:59 |
| 0-334 |
1010 | return true; executed: return true; Execution Count:275 | 275 |
1011 | } executed: } Execution Count:59 | 59 |
1012 | } executed: } Execution Count:42 | 42 |
1013 | } executed: } Execution Count:533 | 533 |
1014 | | - |
1015 | return false; executed: return false; Execution Count:651 | 651 |
1016 | } | - |
1017 | | - |
1018 | | - |
1019 | | - |
1020 | | - |
1021 | | - |
1022 | bool 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() no Evaluation Count:0 | yes Evaluation Count:495 |
never evaluated: d->model != parent.model() | 0-495 |
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() yes Evaluation Count:348 | yes Evaluation Count:284 |
| 284-348 |
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 yes Evaluation Count:301 | yes Evaluation Count:47 |
evaluated: right >= column yes Evaluation Count:219 | yes Evaluation Count:82 |
| 47-301 |
1036 | for (int j = top; j <= bottom; j++) { evaluated: j <= bottom yes Evaluation Count:229 | yes Evaluation Count:8 |
| 8-229 |
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) yes Evaluation Count:229 | no Evaluation Count:0 |
evaluated: (flags & Qt::ItemIsEnabled) yes Evaluation Count:211 | yes Evaluation Count:18 |
| 0-229 |
1039 | return true; executed: return true; Execution Count:211 | 211 |
1040 | } executed: } Execution Count:18 | 18 |
1041 | } executed: } Execution Count:8 | 8 |
1042 | } executed: } Execution Count:137 | 137 |
1043 | | - |
1044 | return false; executed: return false; Execution Count:284 | 284 |
1045 | } | - |
1046 | | - |
1047 | | - |
1048 | | - |
1049 | | - |
1050 | | - |
1051 | | - |
1052 | | - |
1053 | bool QItemSelectionModel::hasSelection() const | - |
1054 | { | - |
1055 | const QItemSelectionModelPrivate * const d = d_func(); | - |
1056 | if (d->currentCommand & (Toggle | Deselect)) { evaluated: d->currentCommand & (Toggle | Deselect) yes Evaluation Count:69 | yes Evaluation Count:865 |
| 69-865 |
1057 | QItemSelection sel = d->ranges; | - |
1058 | sel.merge(d->currentSelection, d->currentCommand); | - |
1059 | return !sel.isEmpty(); executed: return !sel.isEmpty(); Execution Count:69 | 69 |
1060 | } else { | - |
1061 | return !(d->ranges.isEmpty() && d->currentSelection.isEmpty()); executed: return !(d->ranges.isEmpty() && d->currentSelection.isEmpty()); Execution Count:865 | 865 |
1062 | } | - |
1063 | } | - |
1064 | | - |
1065 | | - |
1066 | | - |
1067 | | - |
1068 | | - |
1069 | QModelIndexList 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:408 | 408 |
1075 | } | - |
1076 | QModelIndexList 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() yes Evaluation Count:255 | yes Evaluation Count:778 |
| 255-778 |
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() yes Evaluation Count:282 | yes Evaluation Count:255 |
| 255-282 |
1088 | QPair<QModelIndex, int> rowDef = qMakePair(parent, row); | - |
1089 | if (!rowsSeen.contains(rowDef)) { partially evaluated: !rowsSeen.contains(rowDef) yes Evaluation Count:282 | no Evaluation Count:0 |
| 0-282 |
1090 | rowsSeen << rowDef; | - |
1091 | if (isRowSelected(row, parent)) { evaluated: isRowSelected(row, parent) yes Evaluation Count:272 | yes Evaluation Count:10 |
| 10-272 |
1092 | indexes.append(model()->index(row, column, parent)); | - |
1093 | } executed: } Execution Count:272 | 272 |
1094 | } executed: } Execution Count:282 | 282 |
1095 | } executed: } Execution Count:282 | 282 |
1096 | } executed: } Execution Count:255 | 255 |
1097 | | - |
1098 | return indexes; executed: return indexes; Execution Count:778 | 778 |
1099 | } | - |
1100 | QModelIndexList 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() 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() 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) yes Evaluation Count:59 | no Evaluation Count:0 |
| 0-59 |
1114 | columnsSeen << columnDef; | - |
1115 | if (isColumnSelected(column, parent)) { evaluated: isColumnSelected(column, parent) 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 | | - |
1128 | const 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() yes Evaluation Count:361 | yes Evaluation Count:1143 |
| 361-1143 |
1137 | if (selected.at(i).isValid()) partially evaluated: selected.at(i).isValid() yes Evaluation Count:361 | no Evaluation Count:0 |
| 0-361 |
1138 | ++i; executed: ++i; Execution Count:361 | 361 |
1139 | else | - |
1140 | (selected.removeAt(i)); never executed: (selected.removeAt(i)); | 0 |
1141 | } | - |
1142 | return selected; executed: return selected; Execution Count:1143 | 1143 |
1143 | } | - |
1144 | | - |
1145 | | - |
1146 | | - |
1147 | | - |
1148 | const QAbstractItemModel *QItemSelectionModel::model() const | - |
1149 | { | - |
1150 | return d_func()->model; executed: return d_func()->model; Execution Count:6492 | 6492 |
1151 | } | - |
1152 | | - |
1153 | | - |
1154 | | - |
1155 | | - |
1156 | | - |
1157 | void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelection, | - |
1158 | const QItemSelection &oldSelection) | - |
1159 | { | - |
1160 | | - |
1161 | if ((oldSelection.isEmpty() && newSelection.isEmpty()) || evaluated: oldSelection.isEmpty() yes Evaluation Count:2374 | yes Evaluation Count:4119 |
evaluated: newSelection.isEmpty() yes Evaluation Count:622 | yes Evaluation Count:1752 |
| 622-4119 |
1162 | oldSelection == newSelection) evaluated: oldSelection == newSelection yes Evaluation Count:974 | yes Evaluation Count:4897 |
| 974-4897 |
1163 | return; executed: return; Execution Count:1596 | 1596 |
1164 | | - |
1165 | | - |
1166 | if (oldSelection.isEmpty() || newSelection.isEmpty()) { evaluated: oldSelection.isEmpty() yes Evaluation Count:1752 | yes Evaluation Count:3145 |
evaluated: newSelection.isEmpty() yes Evaluation Count:970 | yes Evaluation Count:2175 |
| 970-3145 |
1167 | selectionChanged(newSelection, oldSelection); | - |
1168 | return; executed: return; Execution Count:2722 | 2722 |
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() yes Evaluation Count:2348 | yes Evaluation Count:2175 |
| 2175-2348 |
1177 | advance = true; | - |
1178 | for (int s = 0; s < selected.count() && o < deselected.count();) { evaluated: s < selected.count() yes Evaluation Count:3376 | yes Evaluation Count:2186 |
evaluated: o < deselected.count() yes Evaluation Count:3214 | yes Evaluation Count:162 |
| 162-3376 |
1179 | if (deselected.at(o) == selected.at(s)) { evaluated: deselected.at(o) == selected.at(s) yes Evaluation Count:632 | yes Evaluation Count:2582 |
| 632-2582 |
1180 | deselected.removeAt(o); | - |
1181 | selected.removeAt(s); | - |
1182 | advance = false; | - |
1183 | } else { executed: } Execution Count:632 | 632 |
1184 | ++s; | - |
1185 | } executed: } Execution Count:2582 | 2582 |
1186 | } | - |
1187 | if (advance) evaluated: advance yes Evaluation Count:2107 | yes Evaluation Count:241 |
| 241-2107 |
1188 | ++o; executed: ++o; Execution Count:2107 | 2107 |
1189 | } executed: } Execution Count:2348 | 2348 |
1190 | | - |
1191 | | - |
1192 | QItemSelection intersections; | - |
1193 | for (int o = 0; o < deselected.count(); ++o) { evaluated: o < deselected.count() yes Evaluation Count:2315 | yes Evaluation Count:2175 |
| 2175-2315 |
1194 | for (int s = 0; s < selected.count(); ++s) { evaluated: s < selected.count() yes Evaluation Count:2608 | yes Evaluation Count:2315 |
| 2315-2608 |
1195 | if (deselected.at(o).intersects(selected.at(s))) evaluated: deselected.at(o).intersects(selected.at(s)) yes Evaluation Count:305 | yes Evaluation Count:2303 |
| 305-2303 |
1196 | intersections.append(deselected.at(o).intersected(selected.at(s))); executed: intersections.append(deselected.at(o).intersected(selected.at(s))); Execution Count:305 | 305 |
1197 | } executed: } Execution Count:2608 | 2608 |
1198 | } executed: } Execution Count:2315 | 2315 |
1199 | | - |
1200 | | - |
1201 | for (int i = 0; i < intersections.count(); ++i) { evaluated: i < intersections.count() yes Evaluation Count:305 | yes Evaluation Count:2175 |
| 305-2175 |
1202 | | - |
1203 | for (int o = 0; o < deselected.count();) { evaluated: o < deselected.count() yes Evaluation Count:755 | yes Evaluation Count:305 |
| 305-755 |
1204 | if (deselected.at(o).intersects(intersections.at(i))) { evaluated: deselected.at(o).intersects(intersections.at(i)) yes Evaluation Count:305 | yes Evaluation Count:450 |
| 305-450 |
1205 | QItemSelection::split(deselected.at(o), intersections.at(i), &deselected); | - |
1206 | deselected.removeAt(o); | - |
1207 | } else { executed: } Execution Count:305 | 305 |
1208 | ++o; | - |
1209 | } executed: } Execution Count:450 | 450 |
1210 | } | - |
1211 | | - |
1212 | for (int s = 0; s < selected.count();) { evaluated: s < selected.count() yes Evaluation Count:748 | yes Evaluation Count:305 |
| 305-748 |
1213 | if (selected.at(s).intersects(intersections.at(i))) { evaluated: selected.at(s).intersects(intersections.at(i)) yes Evaluation Count:315 | yes Evaluation Count:433 |
| 315-433 |
1214 | QItemSelection::split(selected.at(s), intersections.at(i), &selected); | - |
1215 | selected.removeAt(s); | - |
1216 | } else { executed: } Execution Count:315 | 315 |
1217 | ++s; | - |
1218 | } executed: } Execution Count:433 | 433 |
1219 | } | - |
1220 | } executed: } Execution Count:305 | 305 |
1221 | | - |
1222 | if (!selected.isEmpty() || !deselected.isEmpty()) evaluated: !selected.isEmpty() yes Evaluation Count:2065 | yes Evaluation Count:110 |
evaluated: !deselected.isEmpty() yes Evaluation Count:84 | yes Evaluation Count:26 |
| 26-2065 |
1223 | selectionChanged(selected, deselected); executed: selectionChanged(selected, deselected); Execution Count:2149 | 2149 |
1224 | } executed: } Execution Count:2175 | 2175 |
1225 | | - |
1226 | | - |
1227 | QDebug 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 | | - |
| | |