Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | #include "qtableview.h" | - |
41 | | - |
42 | #ifndef QT_NO_TABLEVIEW | - |
43 | #include <qheaderview.h> | - |
44 | #include <qitemdelegate.h> | - |
45 | #include <qapplication.h> | - |
46 | #include <qpainter.h> | - |
47 | #include <qstyle.h> | - |
48 | #include <qsize.h> | - |
49 | #include <qevent.h> | - |
50 | #include <qbitarray.h> | - |
51 | #include <qscrollbar.h> | - |
52 | #include <qabstractbutton.h> | - |
53 | #include <private/qtableview_p.h> | - |
54 | #include <private/qheaderview_p.h> | - |
55 | #include <private/qscrollbar_p.h> | - |
56 | #ifndef QT_NO_ACCESSIBILITY | - |
57 | #include <qaccessible.h> | - |
58 | #endif | - |
59 | | - |
60 | QT_BEGIN_NAMESPACE | - |
61 | | - |
62 | | - |
63 | | - |
64 | | - |
65 | void QSpanCollection::addSpan(QSpanCollection::Span *span) | - |
66 | { | - |
67 | spans.append(span); | - |
68 | Index::iterator it_y = index.lowerBound(-span->top()); | - |
69 | if (it_y == index.end() || it_y.key() != -span->top()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
70 | | - |
71 | SubIndex sub_index; | - |
72 | if (it_y != index.end()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
73 | | - |
74 | | - |
75 | const SubIndex previousList = it_y.value(); | - |
76 | foreach(Span *s, previousList) { | - |
77 | | - |
78 | if(s->bottom() >= span->top())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
79 | sub_index.insert(-s->left(), s); never executed: sub_index.insert(-s->left(), s); | 0 |
80 | } never executed: end of block | 0 |
81 | } never executed: end of block | 0 |
82 | it_y = index.insert(-span->top(), sub_index); | - |
83 | | - |
84 | } never executed: end of block | 0 |
85 | | - |
86 | | - |
87 | while(-it_y.key() <= span->bottom()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
88 | (*it_y).insert(-span->left(), span); | - |
89 | if(it_y == index.begin())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
90 | break; never executed: break; | 0 |
91 | --it_y; | - |
92 | } never executed: end of block | 0 |
93 | } never executed: end of block | 0 |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height) | - |
104 | { | - |
105 | if (old_height < span->height()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
106 | | - |
107 | Index::iterator it_y = index.lowerBound(-(span->top() + old_height - 1)); | - |
108 | Q_ASSERT(it_y != index.end()); | - |
109 | while (-it_y.key() <= span->bottom()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
110 | (*it_y).insert(-span->left(), span); | - |
111 | if(it_y == index.begin())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
112 | break; never executed: break; | 0 |
113 | --it_y; | - |
114 | } never executed: end of block | 0 |
115 | } else if (old_height > span->height()) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
116 | | - |
117 | Index::iterator it_y = index.lowerBound(-qMax(span->bottom(), span->top())); | - |
118 | Q_ASSERT(it_y != index.end()); | - |
119 | while (-it_y.key() <= span->top() + old_height -1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
120 | if (-it_y.key() > span->bottom()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
121 | int removed = (*it_y).remove(-span->left()); | - |
122 | Q_ASSERT(removed == 1); Q_UNUSED(removed); | - |
123 | if (it_y->isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
124 | it_y = index.erase(it_y); | - |
125 | } never executed: end of block | 0 |
126 | } never executed: end of block | 0 |
127 | if(it_y == index.begin())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
128 | break; never executed: break; | 0 |
129 | --it_y; | - |
130 | } never executed: end of block | 0 |
131 | } never executed: end of block | 0 |
132 | | - |
133 | if (span->width() == 0 && span->height() == 0) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
134 | spans.removeOne(span); | - |
135 | delete span; | - |
136 | } never executed: end of block | 0 |
137 | } never executed: end of block | 0 |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | QSpanCollection::Span *QSpanCollection::spanAt(int x, int y) const | - |
143 | { | - |
144 | Index::const_iterator it_y = index.lowerBound(-y); | - |
145 | if (it_y == index.end())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
146 | return 0; never executed: return 0; | 0 |
147 | SubIndex::const_iterator it_x = (*it_y).lowerBound(-x); | - |
148 | if (it_x == (*it_y).end())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
149 | return 0; never executed: return 0; | 0 |
150 | Span *span = *it_x; | - |
151 | if (span->right() >= x && span->bottom() >= y)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
152 | return span; never executed: return span; | 0 |
153 | return 0; never executed: return 0; | 0 |
154 | } | - |
155 | | - |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | void QSpanCollection::clear() | - |
161 | { | - |
162 | qDeleteAll(spans); | - |
163 | index.clear(); | - |
164 | spans.clear(); | - |
165 | } never executed: end of block | 0 |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | QList<QSpanCollection::Span *> QSpanCollection::spansInRect(int x, int y, int w, int h) const | - |
171 | { | - |
172 | QSet<Span *> list; | - |
173 | Index::const_iterator it_y = index.lowerBound(-y); | - |
174 | if(it_y == index.end())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
175 | --it_y; never executed: --it_y; | 0 |
176 | while(-it_y.key() <= y + h) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
177 | SubIndex::const_iterator it_x = (*it_y).lowerBound(-x); | - |
178 | if (it_x == (*it_y).end())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
179 | --it_x; never executed: --it_x; | 0 |
180 | while(-it_x.key() <= x + w) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
181 | Span *s = *it_x; | - |
182 | if (s->bottom() >= y && s->right() >= x)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
183 | list << s; never executed: list << s; | 0 |
184 | if (it_x == (*it_y).begin())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
185 | break; never executed: break; | 0 |
186 | --it_x; | - |
187 | } never executed: end of block | 0 |
188 | if(it_y == index.begin())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
189 | break; never executed: break; | 0 |
190 | --it_y; | - |
191 | } never executed: end of block | 0 |
192 | return list.toList(); never executed: return list.toList(); | 0 |
193 | } | - |
194 | | - |
195 | #undef DEBUG_SPAN_UPDATE | - |
196 | | - |
197 | #ifdef DEBUG_SPAN_UPDATE | - |
198 | QDebug operator<<(QDebug str, const QSpanCollection::Span &span) | - |
199 | { | - |
200 | str << '(' << span.top() << ',' << span.left() << ',' << span.bottom() << ',' << span.right() << ')'; | - |
201 | return str; | - |
202 | } | - |
203 | #endif | - |
204 | | - |
205 | | - |
206 | | - |
207 | | - |
208 | void QSpanCollection::updateInsertedRows(int start, int end) | - |
209 | { | - |
210 | #ifdef DEBUG_SPAN_UPDATE | - |
211 | qDebug() << start << end << endl << index; | - |
212 | #endif | - |
213 | if (spans.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
214 | return; never executed: return; | 0 |
215 | | - |
216 | int delta = end - start + 1; | - |
217 | #ifdef DEBUG_SPAN_UPDATE | - |
218 | qDebug("Before"); | - |
219 | #endif | - |
220 | for (SpanList::iterator it = spans.begin(); it != spans.end(); ++it) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
221 | Span *span = *it; | - |
222 | #ifdef DEBUG_SPAN_UPDATE | - |
223 | qDebug() << span << *span; | - |
224 | #endif | - |
225 | if (span->m_bottom < start)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
226 | continue; never executed: continue; | 0 |
227 | if (span->m_top >= start)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
228 | span->m_top += delta; never executed: span->m_top += delta; | 0 |
229 | span->m_bottom += delta; | - |
230 | } never executed: end of block | 0 |
231 | | - |
232 | #ifdef DEBUG_SPAN_UPDATE | - |
233 | qDebug("After"); | - |
234 | foreach (QSpanCollection::Span *span, spans) | - |
235 | qDebug() << span << *span; | - |
236 | #endif | - |
237 | | - |
238 | for (Index::iterator it_y = index.begin(); it_y != index.end(); ) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
239 | int y = -it_y.key(); | - |
240 | if (y < start) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
241 | ++it_y; | - |
242 | continue; never executed: continue; | 0 |
243 | } | - |
244 | | - |
245 | index.insert(-y - delta, it_y.value()); | - |
246 | it_y = index.erase(it_y); | - |
247 | } never executed: end of block | 0 |
248 | #ifdef DEBUG_SPAN_UPDATE | - |
249 | qDebug() << index; | - |
250 | #endif | - |
251 | } never executed: end of block | 0 |
252 | | - |
253 | | - |
254 | | - |
255 | | - |
256 | void QSpanCollection::updateInsertedColumns(int start, int end) | - |
257 | { | - |
258 | #ifdef DEBUG_SPAN_UPDATE | - |
259 | qDebug() << start << end << endl << index; | - |
260 | #endif | - |
261 | if (spans.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
262 | return; never executed: return; | 0 |
263 | | - |
264 | int delta = end - start + 1; | - |
265 | #ifdef DEBUG_SPAN_UPDATE | - |
266 | qDebug("Before"); | - |
267 | #endif | - |
268 | for (SpanList::iterator it = spans.begin(); it != spans.end(); ++it) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
269 | Span *span = *it; | - |
270 | #ifdef DEBUG_SPAN_UPDATE | - |
271 | qDebug() << span << *span; | - |
272 | #endif | - |
273 | if (span->m_right < start)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
274 | continue; never executed: continue; | 0 |
275 | if (span->m_left >= start)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
276 | span->m_left += delta; never executed: span->m_left += delta; | 0 |
277 | span->m_right += delta; | - |
278 | } never executed: end of block | 0 |
279 | | - |
280 | #ifdef DEBUG_SPAN_UPDATE | - |
281 | qDebug("After"); | - |
282 | foreach (QSpanCollection::Span *span, spans) | - |
283 | qDebug() << span << *span; | - |
284 | #endif | - |
285 | | - |
286 | for (Index::iterator it_y = index.begin(); it_y != index.end(); ++it_y) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
287 | SubIndex &subindex = it_y.value(); | - |
288 | for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
289 | int x = -it.key(); | - |
290 | if (x < start) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
291 | ++it; | - |
292 | continue; never executed: continue; | 0 |
293 | } | - |
294 | subindex.insert(-x - delta, it.value()); | - |
295 | it = subindex.erase(it); | - |
296 | } never executed: end of block | 0 |
297 | } never executed: end of block | 0 |
298 | #ifdef DEBUG_SPAN_UPDATE | - |
299 | qDebug() << index; | - |
300 | #endif | - |
301 | } never executed: end of block | 0 |
302 | | - |
303 | | - |
304 | | - |
305 | | - |
306 | | - |
307 | | - |
308 | bool QSpanCollection::cleanSpanSubIndex(QSpanCollection::SubIndex &subindex, int y, bool update) | - |
309 | { | - |
310 | if (subindex.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
311 | return true; never executed: return true; | 0 |
312 | | - |
313 | bool should_be_deleted = true; | - |
314 | SubIndex::iterator it = subindex.end(); | - |
315 | do { | - |
316 | --it; | - |
317 | int x = -it.key(); | - |
318 | Span *span = it.value(); | - |
319 | if (span->will_be_deleted) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
320 | it = subindex.erase(it); | - |
321 | continue; never executed: continue; | 0 |
322 | } | - |
323 | if (update && span->m_left != x) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
324 | subindex.insert(-span->m_left, span); | - |
325 | it = subindex.erase(it); | - |
326 | } never executed: end of block | 0 |
327 | if (should_be_deleted && span->m_top == y)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
328 | should_be_deleted = false; never executed: should_be_deleted = false; | 0 |
329 | } while (it != subindex.begin()); never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
330 | | - |
331 | return should_be_deleted; never executed: return should_be_deleted; | 0 |
332 | } | - |
333 | | - |
334 | | - |
335 | | - |
336 | | - |
337 | void QSpanCollection::updateRemovedRows(int start, int end) | - |
338 | { | - |
339 | #ifdef DEBUG_SPAN_UPDATE | - |
340 | qDebug() << start << end << endl << index; | - |
341 | #endif | - |
342 | if (spans.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
343 | return; never executed: return; | 0 |
344 | | - |
345 | SpanList spansToBeDeleted; | - |
346 | int delta = end - start + 1; | - |
347 | #ifdef DEBUG_SPAN_UPDATE | - |
348 | qDebug("Before"); | - |
349 | #endif | - |
350 | for (SpanList::iterator it = spans.begin(); it != spans.end(); ) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
351 | Span *span = *it; | - |
352 | #ifdef DEBUG_SPAN_UPDATE | - |
353 | qDebug() << span << *span; | - |
354 | #endif | - |
355 | if (span->m_bottom < start) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
356 | ++it; | - |
357 | continue; never executed: continue; | 0 |
358 | } | - |
359 | if (span->m_top < start) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
360 | if (span->m_bottom <= end)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
361 | span->m_bottom = start - 1; never executed: span->m_bottom = start - 1; | 0 |
362 | else | - |
363 | span->m_bottom -= delta; never executed: span->m_bottom -= delta; | 0 |
364 | } else { | - |
365 | if (span->m_bottom > end) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
366 | if (span->m_top <= end)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
367 | span->m_top = start; never executed: span->m_top = start; | 0 |
368 | else | - |
369 | span->m_top -= delta; never executed: span->m_top -= delta; | 0 |
370 | span->m_bottom -= delta; | - |
371 | } else { never executed: end of block | 0 |
372 | span->will_be_deleted = true; | - |
373 | } never executed: end of block | 0 |
374 | } | - |
375 | if (span->m_top == span->m_bottom && span->m_left == span->m_right)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
376 | span->will_be_deleted = true; never executed: span->will_be_deleted = true; | 0 |
377 | if (span->will_be_deleted) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
378 | spansToBeDeleted.append(span); | - |
379 | it = spans.erase(it); | - |
380 | } else { never executed: end of block | 0 |
381 | ++it; | - |
382 | } never executed: end of block | 0 |
383 | } | - |
384 | | - |
385 | #ifdef DEBUG_SPAN_UPDATE | - |
386 | qDebug("After"); | - |
387 | foreach (QSpanCollection::Span *span, spans) | - |
388 | qDebug() << span << *span; | - |
389 | #endif | - |
390 | if (spans.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
391 | qDeleteAll(spansToBeDeleted); | - |
392 | index.clear(); | - |
393 | return; never executed: return; | 0 |
394 | } | - |
395 | | - |
396 | Index::iterator it_y = index.end(); | - |
397 | do { | - |
398 | --it_y; | - |
399 | int y = -it_y.key(); | - |
400 | SubIndex &subindex = it_y.value(); | - |
401 | if (y < start) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
402 | if (cleanSpanSubIndex(subindex, y))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
403 | it_y = index.erase(it_y); never executed: it_y = index.erase(it_y); | 0 |
404 | } else if (y >= start && y <= end) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
405 | bool span_at_start = false; | - |
406 | SubIndex spansToBeMoved; | - |
407 | for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ++it) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
408 | Span *span = it.value(); | - |
409 | if (span->will_be_deleted)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
410 | continue; never executed: continue; | 0 |
411 | if (!span_at_start && span->m_top == start)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
412 | span_at_start = true; never executed: span_at_start = true; | 0 |
413 | spansToBeMoved.insert(it.key(), span); | - |
414 | } never executed: end of block | 0 |
415 | | - |
416 | if (y == start && span_at_start)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
417 | subindex.clear(); never executed: subindex.clear(); | 0 |
418 | else | - |
419 | it_y = index.erase(it_y); never executed: it_y = index.erase(it_y); | 0 |
420 | | - |
421 | if (span_at_start) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
422 | Index::iterator it_start; | - |
423 | if (y == start)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
424 | it_start = it_y; never executed: it_start = it_y; | 0 |
425 | else { | - |
426 | it_start = index.find(-start); | - |
427 | if (it_start == index.end())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
428 | it_start = index.insert(-start, SubIndex()); never executed: it_start = index.insert(-start, SubIndex()); | 0 |
429 | } never executed: end of block | 0 |
430 | SubIndex &start_subindex = it_start.value(); | - |
431 | for (SubIndex::iterator it = spansToBeMoved.begin(); it != spansToBeMoved.end(); ++it)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
432 | start_subindex.insert(it.key(), it.value()); never executed: start_subindex.insert(it.key(), it.value()); | 0 |
433 | } never executed: end of block | 0 |
434 | } else { never executed: end of block | 0 |
435 | if (y == end + 1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
436 | Index::iterator it_top = index.find(-y + delta); | - |
437 | if (it_top == index.end())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
438 | it_top = index.insert(-y + delta, SubIndex()); never executed: it_top = index.insert(-y + delta, SubIndex()); | 0 |
439 | for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
440 | Span *span = it.value(); | - |
441 | if (!span->will_be_deleted)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
442 | it_top.value().insert(it.key(), span); never executed: it_top.value().insert(it.key(), span); | 0 |
443 | ++it; | - |
444 | } never executed: end of block | 0 |
445 | } else { never executed: end of block | 0 |
446 | index.insert(-y + delta, subindex); | - |
447 | } never executed: end of block | 0 |
448 | it_y = index.erase(it_y); | - |
449 | } never executed: end of block | 0 |
450 | } while (it_y != index.begin());TRUE | never evaluated | FALSE | never evaluated |
| 0 |
451 | | - |
452 | #ifdef DEBUG_SPAN_UPDATE | - |
453 | qDebug() << index; | - |
454 | qDebug("Deleted"); | - |
455 | foreach (QSpanCollection::Span *span, spansToBeDeleted) | - |
456 | qDebug() << span << *span; | - |
457 | #endif | - |
458 | qDeleteAll(spansToBeDeleted); | - |
459 | } never executed: end of block | 0 |
460 | | - |
461 | | - |
462 | | - |
463 | | - |
464 | void QSpanCollection::updateRemovedColumns(int start, int end) | - |
465 | { | - |
466 | #ifdef DEBUG_SPAN_UPDATE | - |
467 | qDebug() << start << end << endl << index; | - |
468 | #endif | - |
469 | if (spans.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
470 | return; never executed: return; | 0 |
471 | | - |
472 | SpanList toBeDeleted; | - |
473 | int delta = end - start + 1; | - |
474 | #ifdef DEBUG_SPAN_UPDATE | - |
475 | qDebug("Before"); | - |
476 | #endif | - |
477 | for (SpanList::iterator it = spans.begin(); it != spans.end(); ) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
478 | Span *span = *it; | - |
479 | #ifdef DEBUG_SPAN_UPDATE | - |
480 | qDebug() << span << *span; | - |
481 | #endif | - |
482 | if (span->m_right < start) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
483 | ++it; | - |
484 | continue; never executed: continue; | 0 |
485 | } | - |
486 | if (span->m_left < start) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
487 | if (span->m_right <= end)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
488 | span->m_right = start - 1; never executed: span->m_right = start - 1; | 0 |
489 | else | - |
490 | span->m_right -= delta; never executed: span->m_right -= delta; | 0 |
491 | } else { | - |
492 | if (span->m_right > end) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
493 | if (span->m_left <= end)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
494 | span->m_left = start; never executed: span->m_left = start; | 0 |
495 | else | - |
496 | span->m_left -= delta; never executed: span->m_left -= delta; | 0 |
497 | span->m_right -= delta; | - |
498 | } else { never executed: end of block | 0 |
499 | span->will_be_deleted = true; | - |
500 | } never executed: end of block | 0 |
501 | } | - |
502 | if (span->m_top == span->m_bottom && span->m_left == span->m_right)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
503 | span->will_be_deleted = true; never executed: span->will_be_deleted = true; | 0 |
504 | if (span->will_be_deleted) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
505 | toBeDeleted.append(span); | - |
506 | it = spans.erase(it); | - |
507 | } else { never executed: end of block | 0 |
508 | ++it; | - |
509 | } never executed: end of block | 0 |
510 | } | - |
511 | | - |
512 | #ifdef DEBUG_SPAN_UPDATE | - |
513 | qDebug("After"); | - |
514 | foreach (QSpanCollection::Span *span, spans) | - |
515 | qDebug() << span << *span; | - |
516 | #endif | - |
517 | if (spans.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
518 | qDeleteAll(toBeDeleted); | - |
519 | index.clear(); | - |
520 | return; never executed: return; | 0 |
521 | } | - |
522 | | - |
523 | for (Index::iterator it_y = index.begin(); it_y != index.end(); ) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
524 | int y = -it_y.key(); | - |
525 | if (cleanSpanSubIndex(it_y.value(), y, true))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
526 | it_y = index.erase(it_y); never executed: it_y = index.erase(it_y); | 0 |
527 | else | - |
528 | ++it_y; never executed: ++it_y; | 0 |
529 | } | - |
530 | | - |
531 | #ifdef DEBUG_SPAN_UPDATE | - |
532 | qDebug() << index; | - |
533 | qDebug("Deleted"); | - |
534 | foreach (QSpanCollection::Span *span, toBeDeleted) | - |
535 | qDebug() << span << *span; | - |
536 | #endif | - |
537 | qDeleteAll(toBeDeleted); | - |
538 | } never executed: end of block | 0 |
539 | | - |
540 | #ifdef QT_BUILD_INTERNAL | - |
541 | | - |
542 | | - |
543 | | - |
544 | | - |
545 | bool QSpanCollection::checkConsistency() const | - |
546 | { | - |
547 | for (Index::const_iterator it_y = index.begin(); it_y != index.end(); ++it_y) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
548 | int y = -it_y.key(); | - |
549 | const SubIndex &subIndex = it_y.value(); | - |
550 | for (SubIndex::const_iterator it = subIndex.begin(); it != subIndex.end(); ++it) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
551 | int x = -it.key(); | - |
552 | Span *span = it.value(); | - |
553 | if (!spans.contains(span) || span->left() != xTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
554 | || y < span->top() || y > span->bottom())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
555 | return false; never executed: return false; | 0 |
556 | } never executed: end of block | 0 |
557 | } never executed: end of block | 0 |
558 | | - |
559 | foreach (const Span *span, spans) { | - |
560 | if (span->width() < 1 || span->height() < 1TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
561 | || (span->width() == 1 && span->height() == 1))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
562 | return false; never executed: return false; | 0 |
563 | for (int y = span->top(); y <= span->bottom(); ++y) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
564 | Index::const_iterator it_y = index.find(-y); | - |
565 | if (it_y == index.end()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
566 | if (y == span->top())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
567 | return false; never executed: return false; | 0 |
568 | else | - |
569 | continue; never executed: continue; | 0 |
570 | } | - |
571 | const SubIndex &subIndex = it_y.value(); | - |
572 | SubIndex::const_iterator it = subIndex.find(-span->left()); | - |
573 | if (it == subIndex.end() || it.value() != span)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
574 | return false; never executed: return false; | 0 |
575 | } never executed: end of block | 0 |
576 | } never executed: end of block | 0 |
577 | return true; never executed: return true; | 0 |
578 | } | - |
579 | #endif | - |
580 | | - |
581 | class QTableCornerButton : public QAbstractButton | - |
582 | { | - |
583 | Q_OBJECT | - |
584 | public: | - |
585 | QTableCornerButton(QWidget *parent) : QAbstractButton(parent) {} never executed: end of block | 0 |
586 | void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE { | - |
587 | QStyleOptionHeader opt; | - |
588 | opt.init(this); | - |
589 | QStyle::State state = QStyle::State_None; | - |
590 | if (isEnabled())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
591 | state |= QStyle::State_Enabled; never executed: state |= QStyle::State_Enabled; | 0 |
592 | if (isActiveWindow())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
593 | state |= QStyle::State_Active; never executed: state |= QStyle::State_Active; | 0 |
594 | if (isDown())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
595 | state |= QStyle::State_Sunken; never executed: state |= QStyle::State_Sunken; | 0 |
596 | opt.state = state; | - |
597 | opt.rect = rect(); | - |
598 | opt.position = QStyleOptionHeader::OnlyOneSection; | - |
599 | QPainter painter(this); | - |
600 | style()->drawControl(QStyle::CE_Header, &opt, &painter, this); | - |
601 | } never executed: end of block | 0 |
602 | }; | - |
603 | | - |
604 | void QTableViewPrivate::init() | - |
605 | { | - |
606 | Q_Q(QTableView); | - |
607 | | - |
608 | q->setEditTriggers(editTriggers|QAbstractItemView::AnyKeyPressed); | - |
609 | | - |
610 | QHeaderView *vertical = new QHeaderView(Qt::Vertical, q); | - |
611 | vertical->setSectionsClickable(true); | - |
612 | vertical->setHighlightSections(true); | - |
613 | q->setVerticalHeader(vertical); | - |
614 | | - |
615 | QHeaderView *horizontal = new QHeaderView(Qt::Horizontal, q); | - |
616 | horizontal->setSectionsClickable(true); | - |
617 | horizontal->setHighlightSections(true); | - |
618 | q->setHorizontalHeader(horizontal); | - |
619 | | - |
620 | tabKeyNavigation = true; | - |
621 | | - |
622 | cornerWidget = new QTableCornerButton(q); | - |
623 | cornerWidget->setFocusPolicy(Qt::NoFocus); | - |
624 | QObject::connect(cornerWidget, SIGNAL(clicked()), q, SLOT(selectAll())); | - |
625 | } never executed: end of block | 0 |
626 | | - |
627 | | - |
628 | | - |
629 | | - |
630 | | - |
631 | void QTableViewPrivate::trimHiddenSelections(QItemSelectionRange *range) const | - |
632 | { | - |
633 | Q_ASSERT(range && range->isValid()); | - |
634 | | - |
635 | int top = range->top(); | - |
636 | int left = range->left(); | - |
637 | int bottom = range->bottom(); | - |
638 | int right = range->right(); | - |
639 | | - |
640 | while (bottom >= top && verticalHeader->isSectionHidden(bottom))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
641 | --bottom; never executed: --bottom; | 0 |
642 | while (right >= left && horizontalHeader->isSectionHidden(right))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
643 | --right; never executed: --right; | 0 |
644 | | - |
645 | if (top > bottom || left > right) { TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
646 | *range = QItemSelectionRange(); | - |
647 | return; never executed: return; | 0 |
648 | } | - |
649 | | - |
650 | while (verticalHeader->isSectionHidden(top) && top <= bottom)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
651 | ++top; never executed: ++top; | 0 |
652 | while (horizontalHeader->isSectionHidden(left) && left <= right)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
653 | ++left; never executed: ++left; | 0 |
654 | | - |
655 | if (top > bottom || left > right) { TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
656 | *range = QItemSelectionRange(); | - |
657 | return; never executed: return; | 0 |
658 | } | - |
659 | | - |
660 | QModelIndex bottomRight = model->index(bottom, right, range->parent()); | - |
661 | QModelIndex topLeft = model->index(top, left, range->parent()); | - |
662 | *range = QItemSelectionRange(topLeft, bottomRight); | - |
663 | } never executed: end of block | 0 |
664 | | - |
665 | | - |
666 | | - |
667 | | - |
668 | | - |
669 | void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan) | - |
670 | { | - |
671 | if (Q_UNLIKELY(row < 0 || column < 0 || rowSpan <= 0 || columnSpan <= 0)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
672 | qWarning("QTableView::setSpan: invalid span given: (%d, %d, %d, %d)", | - |
673 | row, column, rowSpan, columnSpan); | - |
674 | return; never executed: return; | 0 |
675 | } | - |
676 | QSpanCollection::Span *sp = spans.spanAt(column, row); | - |
677 | if (sp) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
678 | if (sp->top() != row || sp->left() != column) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
679 | qWarning("QTableView::setSpan: span cannot overlap"); | - |
680 | return; never executed: return; | 0 |
681 | } | - |
682 | if (rowSpan == 1 && columnSpan == 1) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
683 | rowSpan = columnSpan = 0; | - |
684 | } never executed: end of block | 0 |
685 | const int old_height = sp->height(); | - |
686 | sp->m_bottom = row + rowSpan - 1; | - |
687 | sp->m_right = column + columnSpan - 1; | - |
688 | spans.updateSpan(sp, old_height); | - |
689 | return; never executed: return; | 0 |
690 | } else if (Q_UNLIKELY(rowSpan == 1 && columnSpan == 1)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
691 | qWarning("QTableView::setSpan: single cell span won't be added"); | - |
692 | return; never executed: return; | 0 |
693 | } | - |
694 | sp = new QSpanCollection::Span(row, column, rowSpan, columnSpan); | - |
695 | spans.addSpan(sp); | - |
696 | } never executed: end of block | 0 |
697 | | - |
698 | | - |
699 | | - |
700 | | - |
701 | | - |
702 | QSpanCollection::Span QTableViewPrivate::span(int row, int column) const | - |
703 | { | - |
704 | QSpanCollection::Span *sp = spans.spanAt(column, row); | - |
705 | if (sp)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
706 | return *sp; never executed: return *sp; | 0 |
707 | | - |
708 | return QSpanCollection::Span(row, column, 1, 1); never executed: return QSpanCollection::Span(row, column, 1, 1); | 0 |
709 | } | - |
710 | | - |
711 | | - |
712 | | - |
713 | | - |
714 | | - |
715 | int QTableViewPrivate::sectionSpanEndLogical(const QHeaderView *header, int logical, int span) const | - |
716 | { | - |
717 | int visual = header->visualIndex(logical); | - |
718 | for (int i = 1; i < span; ) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
719 | if (++visual >= header->count())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
720 | break; never executed: break; | 0 |
721 | logical = header->logicalIndex(visual); | - |
722 | ++i; | - |
723 | } never executed: end of block | 0 |
724 | return logical; never executed: return logical; | 0 |
725 | } | - |
726 | | - |
727 | | - |
728 | | - |
729 | | - |
730 | | - |
731 | | - |
732 | int QTableViewPrivate::sectionSpanSize(const QHeaderView *header, int logical, int span) const | - |
733 | { | - |
734 | int endLogical = sectionSpanEndLogical(header, logical, span); | - |
735 | return header->sectionPosition(endLogical) never executed: return header->sectionPosition(endLogical) - header->sectionPosition(logical) + header->sectionSize(endLogical); | 0 |
736 | - header->sectionPosition(logical) never executed: return header->sectionPosition(endLogical) - header->sectionPosition(logical) + header->sectionSize(endLogical); | 0 |
737 | + header->sectionSize(endLogical); never executed: return header->sectionPosition(endLogical) - header->sectionPosition(logical) + header->sectionSize(endLogical); | 0 |
738 | } | - |
739 | | - |
740 | | - |
741 | | - |
742 | | - |
743 | | - |
744 | | - |
745 | | - |
746 | bool QTableViewPrivate::spanContainsSection(const QHeaderView *header, int logical, int spanLogical, int span) const | - |
747 | { | - |
748 | if (logical == spanLogical)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
749 | return true; never executed: return true; | 0 |
750 | int visual = header->visualIndex(spanLogical); | - |
751 | for (int i = 1; i < span; ) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
752 | if (++visual >= header->count())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
753 | break; never executed: break; | 0 |
754 | spanLogical = header->logicalIndex(visual); | - |
755 | if (logical == spanLogical)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
756 | return true; never executed: return true; | 0 |
757 | ++i; | - |
758 | } never executed: end of block | 0 |
759 | return false; never executed: return false; | 0 |
760 | } | - |
761 | | - |
762 | | - |
763 | | - |
764 | | - |
765 | | - |
766 | QRect QTableViewPrivate::visualSpanRect(const QSpanCollection::Span &span) const | - |
767 | { | - |
768 | Q_Q(const QTableView); | - |
769 | | - |
770 | int row = span.top(); | - |
771 | int rowp = verticalHeader->sectionViewportPosition(row); | - |
772 | int rowh = rowSpanHeight(row, span.height()); | - |
773 | | - |
774 | int column = span.left(); | - |
775 | int colw = columnSpanWidth(column, span.width()); | - |
776 | if (q->isRightToLeft())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
777 | column = span.right(); never executed: column = span.right(); | 0 |
778 | int colp = horizontalHeader->sectionViewportPosition(column); | - |
779 | | - |
780 | const int i = showGrid ? 1 : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
781 | if (q->isRightToLeft())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
782 | return QRect(colp + i, rowp, colw - i, rowh - i); never executed: return QRect(colp + i, rowp, colw - i, rowh - i); | 0 |
783 | return QRect(colp, rowp, colw - i, rowh - i); never executed: return QRect(colp, rowp, colw - i, rowh - i); | 0 |
784 | } | - |
785 | | - |
786 | | - |
787 | | - |
788 | | - |
789 | | - |
790 | | - |
791 | | - |
792 | void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter, | - |
793 | const QStyleOptionViewItem &option, QBitArray *drawn, | - |
794 | int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn) | - |
795 | { | - |
796 | bool alternateBase = false; | - |
797 | QRegion region = viewport->rect(); | - |
798 | | - |
799 | QList<QSpanCollection::Span *> visibleSpans; | - |
800 | bool sectionMoved = verticalHeader->sectionsMoved() || horizontalHeader->sectionsMoved();TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
801 | | - |
802 | if (!sectionMoved) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
803 | visibleSpans = spans.spansInRect(logicalColumn(firstVisualColumn), logicalRow(firstVisualRow), | - |
804 | lastVisualColumn - firstVisualColumn + 1, lastVisualRow - firstVisualRow + 1); | - |
805 | } else { never executed: end of block | 0 |
806 | QSet<QSpanCollection::Span *> set; | - |
807 | for(int x = firstVisualColumn; x <= lastVisualColumn; x++)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
808 | for(int y = firstVisualRow; y <= lastVisualRow; y++)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
809 | set.insert(spans.spanAt(x,y)); never executed: set.insert(spans.spanAt(x,y)); | 0 |
810 | set.remove(0); | - |
811 | visibleSpans = set.toList(); | - |
812 | } never executed: end of block | 0 |
813 | | - |
814 | foreach (QSpanCollection::Span *span, visibleSpans) { | - |
815 | int row = span->top(); | - |
816 | int col = span->left(); | - |
817 | QModelIndex index = model->index(row, col, root); | - |
818 | if (!index.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
819 | continue; never executed: continue; | 0 |
820 | QRect rect = visualSpanRect(*span); | - |
821 | rect.translate(scrollDelayOffset); | - |
822 | if (!area.intersects(rect))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
823 | continue; never executed: continue; | 0 |
824 | QStyleOptionViewItem opt = option; | - |
825 | opt.rect = rect; | - |
826 | alternateBase = alternatingColors && (span->top() & 1);TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
827 | opt.features.setFlag(QStyleOptionViewItem::Alternate, alternateBase); | - |
828 | drawCell(painter, opt, index); | - |
829 | region -= rect; | - |
830 | for (int r = span->top(); r <= span->bottom(); ++r) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
831 | const int vr = visualRow(r); | - |
832 | if (vr < firstVisualRow || vr > lastVisualRow)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
833 | continue; never executed: continue; | 0 |
834 | for (int c = span->left(); c <= span->right(); ++c) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
835 | const int vc = visualColumn(c); | - |
836 | if (vc < firstVisualColumn || vc > lastVisualColumn)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
837 | continue; never executed: continue; | 0 |
838 | drawn->setBit((vr - firstVisualRow) * (lastVisualColumn - firstVisualColumn + 1) | - |
839 | + vc - firstVisualColumn); | - |
840 | } never executed: end of block | 0 |
841 | } never executed: end of block | 0 |
842 | | - |
843 | } never executed: end of block | 0 |
844 | painter->setClipRegion(region); | - |
845 | } never executed: end of block | 0 |
846 | | - |
847 | | - |
848 | | - |
849 | | - |
850 | | - |
851 | void QTableViewPrivate::_q_updateSpanInsertedRows(const QModelIndex &parent, int start, int end) | - |
852 | { | - |
853 | Q_UNUSED(parent) | - |
854 | spans.updateInsertedRows(start, end); | - |
855 | } never executed: end of block | 0 |
856 | | - |
857 | | - |
858 | | - |
859 | | - |
860 | | - |
861 | void QTableViewPrivate::_q_updateSpanInsertedColumns(const QModelIndex &parent, int start, int end) | - |
862 | { | - |
863 | Q_UNUSED(parent) | - |
864 | spans.updateInsertedColumns(start, end); | - |
865 | } never executed: end of block | 0 |
866 | | - |
867 | | - |
868 | | - |
869 | | - |
870 | | - |
871 | void QTableViewPrivate::_q_updateSpanRemovedRows(const QModelIndex &parent, int start, int end) | - |
872 | { | - |
873 | Q_UNUSED(parent) | - |
874 | spans.updateRemovedRows(start, end); | - |
875 | } never executed: end of block | 0 |
876 | | - |
877 | | - |
878 | | - |
879 | | - |
880 | | - |
881 | void QTableViewPrivate::_q_updateSpanRemovedColumns(const QModelIndex &parent, int start, int end) | - |
882 | { | - |
883 | Q_UNUSED(parent) | - |
884 | spans.updateRemovedColumns(start, end); | - |
885 | } never executed: end of block | 0 |
886 | | - |
887 | | - |
888 | | - |
889 | | - |
890 | | - |
891 | void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) | - |
892 | { | - |
893 | Q_Q(QTableView); | - |
894 | QStyleOptionViewItem opt = option; | - |
895 | | - |
896 | if (selectionModel && selectionModel->isSelected(index))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
897 | opt.state |= QStyle::State_Selected; never executed: opt.state |= QStyle::State_Selected; | 0 |
898 | if (index == hover)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
899 | opt.state |= QStyle::State_MouseOver; never executed: opt.state |= QStyle::State_MouseOver; | 0 |
900 | if (option.state & QStyle::State_Enabled) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
901 | QPalette::ColorGroup cg; | - |
902 | if ((model->flags(index) & Qt::ItemIsEnabled) == 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
903 | opt.state &= ~QStyle::State_Enabled; | - |
904 | cg = QPalette::Disabled; | - |
905 | } else { never executed: end of block | 0 |
906 | cg = QPalette::Normal; | - |
907 | } never executed: end of block | 0 |
908 | opt.palette.setCurrentColorGroup(cg); | - |
909 | } never executed: end of block | 0 |
910 | | - |
911 | if (index == q->currentIndex()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
912 | const bool focus = (q->hasFocus() || viewport->hasFocus()) && q->currentIndex().isValid();TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
913 | if (focus)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
914 | opt.state |= QStyle::State_HasFocus; never executed: opt.state |= QStyle::State_HasFocus; | 0 |
915 | } never executed: end of block | 0 |
916 | | - |
917 | q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, q); | - |
918 | | - |
919 | q->itemDelegate(index)->paint(painter, opt, index); | - |
920 | } never executed: end of block | 0 |
921 | | - |
922 | | - |
923 | | - |
924 | | - |
925 | | - |
926 | int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const | - |
927 | { | - |
928 | Q_Q(const QTableView); | - |
929 | QWidget *editor = editorForIndex(index).widget.data(); | - |
930 | if (editor && persistent.contains(editor)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
931 | hint = qMax(hint, editor->sizeHint().width()); | - |
932 | int min = editor->minimumSize().width(); | - |
933 | int max = editor->maximumSize().width(); | - |
934 | hint = qBound(min, hint, max); | - |
935 | } never executed: end of block | 0 |
936 | hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width()); | - |
937 | return hint; never executed: return hint; | 0 |
938 | } | - |
939 | | - |
940 | | - |
941 | | - |
942 | | - |
943 | | - |
944 | int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QStyleOptionViewItem &option) const | - |
945 | { | - |
946 | Q_Q(const QTableView); | - |
947 | QWidget *editor = editorForIndex(index).widget.data(); | - |
948 | if (editor && persistent.contains(editor)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
949 | hint = qMax(hint, editor->sizeHint().height()); | - |
950 | int min = editor->minimumSize().height(); | - |
951 | int max = editor->maximumSize().height(); | - |
952 | hint = qBound(min, hint, max); | - |
953 | } never executed: end of block | 0 |
954 | | - |
955 | if (wrapItemText) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
956 | option.rect.setY(q->rowViewportPosition(index.row())); | - |
957 | int height = q->rowHeight(index.row()); | - |
958 | | - |
959 | | - |
960 | | - |
961 | | - |
962 | | - |
963 | | - |
964 | if (height == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
965 | height = 1; never executed: height = 1; | 0 |
966 | option.rect.setHeight(height); | - |
967 | option.rect.setX(q->columnViewportPosition(index.column())); | - |
968 | option.rect.setWidth(q->columnWidth(index.column())); | - |
969 | } never executed: end of block | 0 |
970 | hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).height()); | - |
971 | return hint; never executed: return hint; | 0 |
972 | } | - |
973 | | - |
974 | | - |
975 | | - |
976 | | - |
977 | | - |
978 | | - |
979 | | - |
980 | | - |
981 | | - |
982 | | - |
983 | | - |
984 | | - |
985 | | - |
986 | | - |
987 | | - |
988 | | - |
989 | | - |
990 | | - |
991 | | - |
992 | | - |
993 | | - |
994 | | - |
995 | | - |
996 | | - |
997 | | - |
998 | | - |
999 | | - |
1000 | | - |
1001 | | - |
1002 | | - |
1003 | | - |
1004 | | - |
1005 | | - |
1006 | | - |
1007 | | - |
1008 | | - |
1009 | | - |
1010 | | - |
1011 | | - |
1012 | | - |
1013 | | - |
1014 | | - |
1015 | | - |
1016 | | - |
1017 | | - |
1018 | | - |
1019 | | - |
1020 | | - |
1021 | | - |
1022 | | - |
1023 | | - |
1024 | | - |
1025 | | - |
1026 | | - |
1027 | | - |
1028 | | - |
1029 | | - |
1030 | | - |
1031 | | - |
1032 | | - |
1033 | | - |
1034 | | - |
1035 | | - |
1036 | | - |
1037 | | - |
1038 | | - |
1039 | | - |
1040 | | - |
1041 | | - |
1042 | | - |
1043 | | - |
1044 | | - |
1045 | | - |
1046 | | - |
1047 | | - |
1048 | | - |
1049 | | - |
1050 | | - |
1051 | | - |
1052 | | - |
1053 | | - |
1054 | | - |
1055 | | - |
1056 | | - |
1057 | | - |
1058 | | - |
1059 | | - |
1060 | | - |
1061 | | - |
1062 | | - |
1063 | | - |
1064 | | - |
1065 | | - |
1066 | | - |
1067 | | - |
1068 | | - |
1069 | | - |
1070 | | - |
1071 | | - |
1072 | | - |
1073 | | - |
1074 | QTableView::QTableView(QWidget *parent) | - |
1075 | : QAbstractItemView(*new QTableViewPrivate, parent) | - |
1076 | { | - |
1077 | Q_D(QTableView); | - |
1078 | d->init(); | - |
1079 | } never executed: end of block | 0 |
1080 | | - |
1081 | | - |
1082 | | - |
1083 | | - |
1084 | QTableView::QTableView(QTableViewPrivate &dd, QWidget *parent) | - |
1085 | : QAbstractItemView(dd, parent) | - |
1086 | { | - |
1087 | Q_D(QTableView); | - |
1088 | d->init(); | - |
1089 | } never executed: end of block | 0 |
1090 | | - |
1091 | | - |
1092 | | - |
1093 | | - |
1094 | QTableView::~QTableView() | - |
1095 | { | - |
1096 | } | - |
1097 | | - |
1098 | | - |
1099 | | - |
1100 | | - |
1101 | QSize QTableView::viewportSizeHint() const | - |
1102 | { | - |
1103 | Q_D(const QTableView); | - |
1104 | QSize result( (d->verticalHeader->isHidden() ? 0 : d->verticalHeader->width()) + d->horizontalHeader->length(), | - |
1105 | (d->horizontalHeader->isHidden() ? 0 : d->horizontalHeader->height()) + d->verticalHeader->length()); | - |
1106 | result += QSize(verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0, | - |
1107 | horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0); | - |
1108 | return result; never executed: return result; | 0 |
1109 | } | - |
1110 | | - |
1111 | | - |
1112 | | - |
1113 | | - |
1114 | void QTableView::setModel(QAbstractItemModel *model) | - |
1115 | { | - |
1116 | Q_D(QTableView); | - |
1117 | if (model == d->model)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1118 | return; never executed: return; | 0 |
1119 | | - |
1120 | if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1121 | disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), | - |
1122 | this, SLOT(_q_updateSpanInsertedRows(QModelIndex,int,int))); | - |
1123 | disconnect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)), | - |
1124 | this, SLOT(_q_updateSpanInsertedColumns(QModelIndex,int,int))); | - |
1125 | disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), | - |
1126 | this, SLOT(_q_updateSpanRemovedRows(QModelIndex,int,int))); | - |
1127 | disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), | - |
1128 | this, SLOT(_q_updateSpanRemovedColumns(QModelIndex,int,int))); | - |
1129 | } never executed: end of block | 0 |
1130 | if (d->selectionModel) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1131 | disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), | - |
1132 | d->model, SLOT(submit())); | - |
1133 | } never executed: end of block | 0 |
1134 | if (model) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1135 | connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), | - |
1136 | this, SLOT(_q_updateSpanInsertedRows(QModelIndex,int,int))); | - |
1137 | connect(model, SIGNAL(columnsInserted(QModelIndex,int,int)), | - |
1138 | this, SLOT(_q_updateSpanInsertedColumns(QModelIndex,int,int))); | - |
1139 | connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), | - |
1140 | this, SLOT(_q_updateSpanRemovedRows(QModelIndex,int,int))); | - |
1141 | connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), | - |
1142 | this, SLOT(_q_updateSpanRemovedColumns(QModelIndex,int,int))); | - |
1143 | } never executed: end of block | 0 |
1144 | d->verticalHeader->setModel(model); | - |
1145 | d->horizontalHeader->setModel(model); | - |
1146 | QAbstractItemView::setModel(model); | - |
1147 | } never executed: end of block | 0 |
1148 | | - |
1149 | | - |
1150 | | - |
1151 | | - |
1152 | void QTableView::setRootIndex(const QModelIndex &index) | - |
1153 | { | - |
1154 | Q_D(QTableView); | - |
1155 | if (index == d->root) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1156 | viewport()->update(); | - |
1157 | return; never executed: return; | 0 |
1158 | } | - |
1159 | d->verticalHeader->setRootIndex(index); | - |
1160 | d->horizontalHeader->setRootIndex(index); | - |
1161 | QAbstractItemView::setRootIndex(index); | - |
1162 | } never executed: end of block | 0 |
1163 | | - |
1164 | | - |
1165 | | - |
1166 | | - |
1167 | void QTableView::doItemsLayout() | - |
1168 | { | - |
1169 | Q_D(QTableView); | - |
1170 | QAbstractItemView::doItemsLayout(); | - |
1171 | d->verticalHeader->d_func()->setScrollOffset(verticalScrollBar(), verticalScrollMode()); | - |
1172 | if (!d->verticalHeader->updatesEnabled())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1173 | d->verticalHeader->setUpdatesEnabled(true); never executed: d->verticalHeader->setUpdatesEnabled(true); | 0 |
1174 | } never executed: end of block | 0 |
1175 | | - |
1176 | | - |
1177 | | - |
1178 | | - |
1179 | void QTableView::setSelectionModel(QItemSelectionModel *selectionModel) | - |
1180 | { | - |
1181 | Q_D(QTableView); | - |
1182 | Q_ASSERT(selectionModel); | - |
1183 | if (d->selectionModel) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1184 | | - |
1185 | disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), | - |
1186 | d->model, SLOT(submit())); | - |
1187 | } never executed: end of block | 0 |
1188 | | - |
1189 | d->verticalHeader->setSelectionModel(selectionModel); | - |
1190 | d->horizontalHeader->setSelectionModel(selectionModel); | - |
1191 | QAbstractItemView::setSelectionModel(selectionModel); | - |
1192 | | - |
1193 | if (d->selectionModel) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1194 | | - |
1195 | connect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), | - |
1196 | d->model, SLOT(submit())); | - |
1197 | } never executed: end of block | 0 |
1198 | } never executed: end of block | 0 |
1199 | | - |
1200 | | - |
1201 | | - |
1202 | | - |
1203 | | - |
1204 | | - |
1205 | QHeaderView *QTableView::horizontalHeader() const | - |
1206 | { | - |
1207 | Q_D(const QTableView); | - |
1208 | return d->horizontalHeader; never executed: return d->horizontalHeader; | 0 |
1209 | } | - |
1210 | | - |
1211 | | - |
1212 | | - |
1213 | | - |
1214 | | - |
1215 | | - |
1216 | QHeaderView *QTableView::verticalHeader() const | - |
1217 | { | - |
1218 | Q_D(const QTableView); | - |
1219 | return d->verticalHeader; never executed: return d->verticalHeader; | 0 |
1220 | } | - |
1221 | | - |
1222 | | - |
1223 | | - |
1224 | | - |
1225 | | - |
1226 | | - |
1227 | void QTableView::setHorizontalHeader(QHeaderView *header) | - |
1228 | { | - |
1229 | Q_D(QTableView); | - |
1230 | | - |
1231 | if (!header || header == d->horizontalHeader)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1232 | return; never executed: return; | 0 |
1233 | if (d->horizontalHeader && d->horizontalHeader->parent() == this)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1234 | delete d->horizontalHeader; never executed: delete d->horizontalHeader; | 0 |
1235 | d->horizontalHeader = header; | - |
1236 | d->horizontalHeader->setParent(this); | - |
1237 | d->horizontalHeader->d_func()->setAllowUserMoveOfSection0(true); | - |
1238 | if (!d->horizontalHeader->model()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1239 | d->horizontalHeader->setModel(d->model); | - |
1240 | if (d->selectionModel)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1241 | d->horizontalHeader->setSelectionModel(d->selectionModel); never executed: d->horizontalHeader->setSelectionModel(d->selectionModel); | 0 |
1242 | } never executed: end of block | 0 |
1243 | | - |
1244 | connect(d->horizontalHeader,SIGNAL(sectionResized(int,int,int)), | - |
1245 | this, SLOT(columnResized(int,int,int))); | - |
1246 | connect(d->horizontalHeader, SIGNAL(sectionMoved(int,int,int)), | - |
1247 | this, SLOT(columnMoved(int,int,int))); | - |
1248 | connect(d->horizontalHeader, SIGNAL(sectionCountChanged(int,int)), | - |
1249 | this, SLOT(columnCountChanged(int,int))); | - |
1250 | connect(d->horizontalHeader, SIGNAL(sectionPressed(int)), this, SLOT(selectColumn(int))); | - |
1251 | connect(d->horizontalHeader, SIGNAL(sectionEntered(int)), this, SLOT(_q_selectColumn(int))); | - |
1252 | connect(d->horizontalHeader, SIGNAL(sectionHandleDoubleClicked(int)), | - |
1253 | this, SLOT(resizeColumnToContents(int))); | - |
1254 | connect(d->horizontalHeader, SIGNAL(geometriesChanged()), this, SLOT(updateGeometries())); | - |
1255 | | - |
1256 | | - |
1257 | setSortingEnabled(d->sortingEnabled); | - |
1258 | } never executed: end of block | 0 |
1259 | | - |
1260 | | - |
1261 | | - |
1262 | | - |
1263 | | - |
1264 | | - |
1265 | void QTableView::setVerticalHeader(QHeaderView *header) | - |
1266 | { | - |
1267 | Q_D(QTableView); | - |
1268 | | - |
1269 | if (!header || header == d->verticalHeader)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1270 | return; never executed: return; | 0 |
1271 | if (d->verticalHeader && d->verticalHeader->parent() == this)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1272 | delete d->verticalHeader; never executed: delete d->verticalHeader; | 0 |
1273 | d->verticalHeader = header; | - |
1274 | d->verticalHeader->setParent(this); | - |
1275 | d->verticalHeader->d_func()->setAllowUserMoveOfSection0(true); | - |
1276 | if (!d->verticalHeader->model()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1277 | d->verticalHeader->setModel(d->model); | - |
1278 | if (d->selectionModel)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1279 | d->verticalHeader->setSelectionModel(d->selectionModel); never executed: d->verticalHeader->setSelectionModel(d->selectionModel); | 0 |
1280 | } never executed: end of block | 0 |
1281 | | - |
1282 | connect(d->verticalHeader, SIGNAL(sectionResized(int,int,int)), | - |
1283 | this, SLOT(rowResized(int,int,int))); | - |
1284 | connect(d->verticalHeader, SIGNAL(sectionMoved(int,int,int)), | - |
1285 | this, SLOT(rowMoved(int,int,int))); | - |
1286 | connect(d->verticalHeader, SIGNAL(sectionCountChanged(int,int)), | - |
1287 | this, SLOT(rowCountChanged(int,int))); | - |
1288 | connect(d->verticalHeader, SIGNAL(sectionPressed(int)), this, SLOT(selectRow(int))); | - |
1289 | connect(d->verticalHeader, SIGNAL(sectionEntered(int)), this, SLOT(_q_selectRow(int))); | - |
1290 | connect(d->verticalHeader, SIGNAL(sectionHandleDoubleClicked(int)), | - |
1291 | this, SLOT(resizeRowToContents(int))); | - |
1292 | connect(d->verticalHeader, SIGNAL(geometriesChanged()), this, SLOT(updateGeometries())); | - |
1293 | } never executed: end of block | 0 |
1294 | | - |
1295 | | - |
1296 | | - |
1297 | | - |
1298 | | - |
1299 | | - |
1300 | void QTableView::scrollContentsBy(int dx, int dy) | - |
1301 | { | - |
1302 | Q_D(QTableView); | - |
1303 | | - |
1304 | d->delayedAutoScroll.stop(); | - |
1305 | | - |
1306 | dx = isRightToLeft() ? -dx : dx;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1307 | if (dx) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1308 | int oldOffset = d->horizontalHeader->offset(); | - |
1309 | d->horizontalHeader->d_func()->setScrollOffset(horizontalScrollBar(), horizontalScrollMode()); | - |
1310 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1311 | int newOffset = d->horizontalHeader->offset(); | - |
1312 | dx = isRightToLeft() ? newOffset - oldOffset : oldOffset - newOffset;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1313 | } never executed: end of block | 0 |
1314 | } never executed: end of block | 0 |
1315 | if (dy) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1316 | int oldOffset = d->verticalHeader->offset(); | - |
1317 | d->verticalHeader->d_func()->setScrollOffset(verticalScrollBar(), verticalScrollMode()); | - |
1318 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1319 | int newOffset = d->verticalHeader->offset(); | - |
1320 | dy = oldOffset - newOffset; | - |
1321 | } never executed: end of block | 0 |
1322 | } never executed: end of block | 0 |
1323 | d->scrollContentsBy(dx, dy); | - |
1324 | | - |
1325 | if (d->showGrid) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1326 | | - |
1327 | | - |
1328 | | - |
1329 | if (dy > 0 && d->horizontalHeader->isHidden() && d->verticalScrollMode == ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1330 | d->viewport->update(0, dy, d->viewport->width(), dy); | - |
1331 | } never executed: end of block | 0 |
1332 | if (dx > 0 && d->verticalHeader->isHidden() && d->horizontalScrollMode == ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1333 | d->viewport->update(dx, 0, dx, d->viewport->height()); | - |
1334 | } never executed: end of block | 0 |
1335 | } never executed: end of block | 0 |
1336 | } never executed: end of block | 0 |
1337 | | - |
1338 | | - |
1339 | | - |
1340 | | - |
1341 | QStyleOptionViewItem QTableView::viewOptions() const | - |
1342 | { | - |
1343 | QStyleOptionViewItem option = QAbstractItemView::viewOptions(); | - |
1344 | option.showDecorationSelected = true; | - |
1345 | return option; never executed: return option; | 0 |
1346 | } | - |
1347 | | - |
1348 | | - |
1349 | | - |
1350 | | - |
1351 | void QTableView::paintEvent(QPaintEvent *event) | - |
1352 | { | - |
1353 | Q_D(QTableView); | - |
1354 | | - |
1355 | QStyleOptionViewItem option = d->viewOptionsV1(); | - |
1356 | const QPoint offset = d->scrollDelayOffset; | - |
1357 | const bool showGrid = d->showGrid; | - |
1358 | const int gridSize = showGrid ? 1 : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1359 | const int gridHint = style()->styleHint(QStyle::SH_Table_GridLineColor, &option, this); | - |
1360 | const QColor gridColor = static_cast<QRgb>(gridHint); | - |
1361 | const QPen gridPen = QPen(gridColor, 0, d->gridStyle); | - |
1362 | const QHeaderView *verticalHeader = d->verticalHeader; | - |
1363 | const QHeaderView *horizontalHeader = d->horizontalHeader; | - |
1364 | const bool alternate = d->alternatingColors; | - |
1365 | const bool rightToLeft = isRightToLeft(); | - |
1366 | | - |
1367 | QPainter painter(d->viewport); | - |
1368 | | - |
1369 | | - |
1370 | if (horizontalHeader->count() == 0 || verticalHeader->count() == 0 || !d->itemDelegate)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1371 | return; never executed: return; | 0 |
1372 | | - |
1373 | uint x = horizontalHeader->length() - horizontalHeader->offset() - (rightToLeft ? 0 : 1);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1374 | uint y = verticalHeader->length() - verticalHeader->offset() - 1; | - |
1375 | | - |
1376 | | - |
1377 | | - |
1378 | int firstVisualRow = qMax(verticalHeader->visualIndexAt(0),0); | - |
1379 | int lastVisualRow = verticalHeader->visualIndexAt(verticalHeader->viewport()->height()); | - |
1380 | if (lastVisualRow == -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1381 | lastVisualRow = d->model->rowCount(d->root) - 1; never executed: lastVisualRow = d->model->rowCount(d->root) - 1; | 0 |
1382 | | - |
1383 | int firstVisualColumn = horizontalHeader->visualIndexAt(0); | - |
1384 | int lastVisualColumn = horizontalHeader->visualIndexAt(horizontalHeader->viewport()->width()); | - |
1385 | if (rightToLeft)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1386 | qSwap(firstVisualColumn, lastVisualColumn); never executed: qSwap(firstVisualColumn, lastVisualColumn); | 0 |
1387 | if (firstVisualColumn == -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1388 | firstVisualColumn = 0; never executed: firstVisualColumn = 0; | 0 |
1389 | if (lastVisualColumn == -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1390 | lastVisualColumn = horizontalHeader->count() - 1; never executed: lastVisualColumn = horizontalHeader->count() - 1; | 0 |
1391 | | - |
1392 | QBitArray drawn((lastVisualRow - firstVisualRow + 1) * (lastVisualColumn - firstVisualColumn + 1)); | - |
1393 | | - |
1394 | const QRegion region = event->region().translated(offset); | - |
1395 | | - |
1396 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1397 | d->drawAndClipSpans(region, &painter, option, &drawn, | - |
1398 | firstVisualRow, lastVisualRow, firstVisualColumn, lastVisualColumn); | - |
1399 | } never executed: end of block | 0 |
1400 | | - |
1401 | const QVector<QRect> rects = region.rects(); | - |
1402 | for (auto dirtyArea : rects) { | - |
1403 | dirtyArea.setBottom(qMin(dirtyArea.bottom(), int(y))); | - |
1404 | if (rightToLeft) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1405 | dirtyArea.setLeft(qMax(dirtyArea.left(), d->viewport->width() - int(x))); | - |
1406 | } else { never executed: end of block | 0 |
1407 | dirtyArea.setRight(qMin(dirtyArea.right(), int(x))); | - |
1408 | } never executed: end of block | 0 |
1409 | | - |
1410 | | - |
1411 | int left = horizontalHeader->visualIndexAt(dirtyArea.left()); | - |
1412 | int right = horizontalHeader->visualIndexAt(dirtyArea.right()); | - |
1413 | if (rightToLeft)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1414 | qSwap(left, right); never executed: qSwap(left, right); | 0 |
1415 | if (left == -1) left = 0; never executed: left = 0; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1416 | if (right == -1) right = horizontalHeader->count() - 1; never executed: right = horizontalHeader->count() - 1; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1417 | | - |
1418 | | - |
1419 | int bottom = verticalHeader->visualIndexAt(dirtyArea.bottom()); | - |
1420 | if (bottom == -1) bottom = verticalHeader->count() - 1; never executed: bottom = verticalHeader->count() - 1; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1421 | int top = 0; | - |
1422 | bool alternateBase = false; | - |
1423 | if (alternate && verticalHeader->sectionsHidden()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1424 | uint verticalOffset = verticalHeader->offset(); | - |
1425 | int row = verticalHeader->logicalIndex(top); | - |
1426 | for (int y = 0; | - |
1427 | ((uint)(y += verticalHeader->sectionSize(top)) <= verticalOffset) && (top < bottom);TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1428 | ++top) { | - |
1429 | row = verticalHeader->logicalIndex(top); | - |
1430 | if (alternate && !verticalHeader->isSectionHidden(row))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1431 | alternateBase = !alternateBase; never executed: alternateBase = !alternateBase; | 0 |
1432 | } never executed: end of block | 0 |
1433 | } else { never executed: end of block | 0 |
1434 | top = verticalHeader->visualIndexAt(dirtyArea.top()); | - |
1435 | alternateBase = (top & 1) && alternate;TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1436 | } never executed: end of block | 0 |
1437 | if (top == -1 || top > bottom)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1438 | continue; never executed: continue; | 0 |
1439 | | - |
1440 | | - |
1441 | for (int visualRowIndex = top; visualRowIndex <= bottom; ++visualRowIndex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1442 | int row = verticalHeader->logicalIndex(visualRowIndex); | - |
1443 | if (verticalHeader->isSectionHidden(row))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1444 | continue; never executed: continue; | 0 |
1445 | int rowY = rowViewportPosition(row); | - |
1446 | rowY += offset.y(); | - |
1447 | int rowh = rowHeight(row) - gridSize; | - |
1448 | | - |
1449 | | - |
1450 | for (int visualColumnIndex = left; visualColumnIndex <= right; ++visualColumnIndex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1451 | int currentBit = (visualRowIndex - firstVisualRow) * (lastVisualColumn - firstVisualColumn + 1) | - |
1452 | + visualColumnIndex - firstVisualColumn; | - |
1453 | | - |
1454 | if (currentBit < 0 || currentBit >= drawn.size() || drawn.testBit(currentBit))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1455 | continue; never executed: continue; | 0 |
1456 | drawn.setBit(currentBit); | - |
1457 | | - |
1458 | int col = horizontalHeader->logicalIndex(visualColumnIndex); | - |
1459 | if (horizontalHeader->isSectionHidden(col))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1460 | continue; never executed: continue; | 0 |
1461 | int colp = columnViewportPosition(col); | - |
1462 | colp += offset.x(); | - |
1463 | int colw = columnWidth(col) - gridSize; | - |
1464 | | - |
1465 | const QModelIndex index = d->model->index(row, col, d->root); | - |
1466 | if (index.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1467 | option.rect = QRect(colp + (showGrid && rightToLeft ? 1 : 0), rowY, colw, rowh); | - |
1468 | if (alternate) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1469 | if (alternateBase)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1470 | option.features |= QStyleOptionViewItem::Alternate; never executed: option.features |= QStyleOptionViewItem::Alternate; | 0 |
1471 | else | - |
1472 | option.features &= ~QStyleOptionViewItem::Alternate; never executed: option.features &= ~QStyleOptionViewItem::Alternate; | 0 |
1473 | } | - |
1474 | d->drawCell(&painter, option, index); | - |
1475 | } never executed: end of block | 0 |
1476 | } never executed: end of block | 0 |
1477 | alternateBase = !alternateBase && alternate;TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1478 | } never executed: end of block | 0 |
1479 | | - |
1480 | if (showGrid) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1481 | | - |
1482 | while (verticalHeader->isSectionHidden(verticalHeader->logicalIndex(bottom))) --bottom; never executed: --bottom; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1483 | QPen old = painter.pen(); | - |
1484 | painter.setPen(gridPen); | - |
1485 | | - |
1486 | for (int visualIndex = top; visualIndex <= bottom; ++visualIndex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1487 | int row = verticalHeader->logicalIndex(visualIndex); | - |
1488 | if (verticalHeader->isSectionHidden(row))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1489 | continue; never executed: continue; | 0 |
1490 | int rowY = rowViewportPosition(row); | - |
1491 | rowY += offset.y(); | - |
1492 | int rowh = rowHeight(row) - gridSize; | - |
1493 | painter.drawLine(dirtyArea.left(), rowY + rowh, dirtyArea.right(), rowY + rowh); | - |
1494 | } never executed: end of block | 0 |
1495 | | - |
1496 | | - |
1497 | for (int h = left; h <= right; ++h) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1498 | int col = horizontalHeader->logicalIndex(h); | - |
1499 | if (horizontalHeader->isSectionHidden(col))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1500 | continue; never executed: continue; | 0 |
1501 | int colp = columnViewportPosition(col); | - |
1502 | colp += offset.x(); | - |
1503 | if (!rightToLeft)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1504 | colp += columnWidth(col) - gridSize; never executed: colp += columnWidth(col) - gridSize; | 0 |
1505 | painter.drawLine(colp, dirtyArea.top(), colp, dirtyArea.bottom()); | - |
1506 | } never executed: end of block | 0 |
1507 | | - |
1508 | | - |
1509 | | - |
1510 | if (horizontalHeader->isHidden() && verticalScrollMode() == ScrollPerItem)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1511 | painter.drawLine(dirtyArea.left(), 0, dirtyArea.right(), 0); never executed: painter.drawLine(dirtyArea.left(), 0, dirtyArea.right(), 0); | 0 |
1512 | if (verticalHeader->isHidden() && horizontalScrollMode() == ScrollPerItem)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1513 | painter.drawLine(0, dirtyArea.top(), 0, dirtyArea.bottom()); never executed: painter.drawLine(0, dirtyArea.top(), 0, dirtyArea.bottom()); | 0 |
1514 | painter.setPen(old); | - |
1515 | } never executed: end of block | 0 |
1516 | } never executed: end of block | 0 |
1517 | | - |
1518 | #ifndef QT_NO_DRAGANDDROP | - |
1519 | | - |
1520 | d->paintDropIndicator(&painter); | - |
1521 | #endif | - |
1522 | } never executed: end of block | 0 |
1523 | | - |
1524 | | - |
1525 | | - |
1526 | | - |
1527 | | - |
1528 | QModelIndex QTableView::indexAt(const QPoint &pos) const | - |
1529 | { | - |
1530 | Q_D(const QTableView); | - |
1531 | d->executePostedLayout(); | - |
1532 | int r = rowAt(pos.y()); | - |
1533 | int c = columnAt(pos.x()); | - |
1534 | if (r >= 0 && c >= 0) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1535 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1536 | QSpanCollection::Span span = d->span(r, c); | - |
1537 | r = span.top(); | - |
1538 | c = span.left(); | - |
1539 | } never executed: end of block | 0 |
1540 | return d->model->index(r, c, d->root); never executed: return d->model->index(r, c, d->root); | 0 |
1541 | } | - |
1542 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
1543 | } | - |
1544 | | - |
1545 | | - |
1546 | | - |
1547 | | - |
1548 | | - |
1549 | | - |
1550 | | - |
1551 | | - |
1552 | | - |
1553 | int QTableView::horizontalOffset() const | - |
1554 | { | - |
1555 | Q_D(const QTableView); | - |
1556 | return d->horizontalHeader->offset(); never executed: return d->horizontalHeader->offset(); | 0 |
1557 | } | - |
1558 | | - |
1559 | | - |
1560 | | - |
1561 | | - |
1562 | | - |
1563 | | - |
1564 | | - |
1565 | | - |
1566 | | - |
1567 | int QTableView::verticalOffset() const | - |
1568 | { | - |
1569 | Q_D(const QTableView); | - |
1570 | return d->verticalHeader->offset(); never executed: return d->verticalHeader->offset(); | 0 |
1571 | } | - |
1572 | | - |
1573 | | - |
1574 | | - |
1575 | | - |
1576 | | - |
1577 | | - |
1578 | | - |
1579 | | - |
1580 | | - |
1581 | QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) | - |
1582 | { | - |
1583 | Q_D(QTableView); | - |
1584 | Q_UNUSED(modifiers); | - |
1585 | | - |
1586 | int bottom = d->model->rowCount(d->root) - 1; | - |
1587 | | - |
1588 | while (bottom >= 0 && isRowHidden(d->logicalRow(bottom)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1589 | --bottom; never executed: --bottom; | 0 |
1590 | | - |
1591 | int right = d->model->columnCount(d->root) - 1; | - |
1592 | | - |
1593 | while (right >= 0 && isColumnHidden(d->logicalColumn(right)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1594 | --right; never executed: --right; | 0 |
1595 | | - |
1596 | if (bottom == -1 || right == -1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1597 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
1598 | | - |
1599 | QModelIndex current = currentIndex(); | - |
1600 | | - |
1601 | if (!current.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1602 | int row = 0; | - |
1603 | int column = 0; | - |
1604 | while (column < right && isColumnHidden(d->logicalColumn(column)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1605 | ++column; never executed: ++column; | 0 |
1606 | while (isRowHidden(d->logicalRow(row)) && row < bottom)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1607 | ++row; never executed: ++row; | 0 |
1608 | d->visualCursor = QPoint(column, row); | - |
1609 | return d->model->index(d->logicalRow(row), d->logicalColumn(column), d->root); never executed: return d->model->index(d->logicalRow(row), d->logicalColumn(column), d->root); | 0 |
1610 | } | - |
1611 | | - |
1612 | | - |
1613 | QPoint visualCurrent(d->visualColumn(current.column()), d->visualRow(current.row())); | - |
1614 | if (visualCurrent != d->visualCursor) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1615 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1616 | QSpanCollection::Span span = d->span(current.row(), current.column()); | - |
1617 | if (span.top() > d->visualCursor.y() || d->visualCursor.y() > span.bottom()TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1618 | || span.left() > d->visualCursor.x() || d->visualCursor.x() > span.right())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1619 | d->visualCursor = visualCurrent; never executed: d->visualCursor = visualCurrent; | 0 |
1620 | } else { never executed: end of block | 0 |
1621 | d->visualCursor = visualCurrent; | - |
1622 | } never executed: end of block | 0 |
1623 | } | - |
1624 | | - |
1625 | int visualRow = d->visualCursor.y(); | - |
1626 | if (visualRow > bottom)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1627 | visualRow = bottom; never executed: visualRow = bottom; | 0 |
1628 | Q_ASSERT(visualRow != -1); | - |
1629 | int visualColumn = d->visualCursor.x(); | - |
1630 | if (visualColumn > right)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1631 | visualColumn = right; never executed: visualColumn = right; | 0 |
1632 | Q_ASSERT(visualColumn != -1); | - |
1633 | | - |
1634 | if (isRightToLeft()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1635 | if (cursorAction == MoveLeft)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1636 | cursorAction = MoveRight; never executed: cursorAction = MoveRight; | 0 |
1637 | else if (cursorAction == MoveRight)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1638 | cursorAction = MoveLeft; never executed: cursorAction = MoveLeft; | 0 |
1639 | } never executed: end of block | 0 |
1640 | | - |
1641 | switch (cursorAction) { | - |
1642 | case MoveUp: { never executed: case MoveUp: | 0 |
1643 | int originalRow = visualRow; | - |
1644 | #ifdef QT_KEYPAD_NAVIGATION | - |
1645 | if (QApplication::keypadNavigationEnabled() && visualRow == 0) | - |
1646 | visualRow = d->visualRow(model()->rowCount() - 1) + 1; | - |
1647 | | - |
1648 | #endif | - |
1649 | int r = d->logicalRow(visualRow); | - |
1650 | int c = d->logicalColumn(visualColumn); | - |
1651 | if (r != -1 && d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1652 | QSpanCollection::Span span = d->span(r, c); | - |
1653 | if (span.width() > 1 || span.height() > 1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1654 | visualRow = d->visualRow(span.top()); never executed: visualRow = d->visualRow(span.top()); | 0 |
1655 | } never executed: end of block | 0 |
1656 | while (visualRow >= 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1657 | --visualRow; | - |
1658 | r = d->logicalRow(visualRow); | - |
1659 | c = d->logicalColumn(visualColumn); | - |
1660 | if (r == -1 || (!isRowHidden(r) && d->isCellEnabled(r, c)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1661 | break; never executed: break; | 0 |
1662 | } never executed: end of block | 0 |
1663 | if (visualRow < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1664 | visualRow = originalRow; never executed: visualRow = originalRow; | 0 |
1665 | break; never executed: break; | 0 |
1666 | } | - |
1667 | case MoveDown: { never executed: case MoveDown: | 0 |
1668 | int originalRow = visualRow; | - |
1669 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1670 | QSpanCollection::Span span = d->span(current.row(), current.column()); | - |
1671 | visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); | - |
1672 | } never executed: end of block | 0 |
1673 | #ifdef QT_KEYPAD_NAVIGATION | - |
1674 | if (QApplication::keypadNavigationEnabled() && visualRow >= bottom) | - |
1675 | visualRow = -1; | - |
1676 | #endif | - |
1677 | int r = d->logicalRow(visualRow); | - |
1678 | int c = d->logicalColumn(visualColumn); | - |
1679 | if (r != -1 && d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1680 | QSpanCollection::Span span = d->span(r, c); | - |
1681 | if (span.width() > 1 || span.height() > 1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1682 | visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); never executed: visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); | 0 |
1683 | } never executed: end of block | 0 |
1684 | while (visualRow <= bottom) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1685 | ++visualRow; | - |
1686 | r = d->logicalRow(visualRow); | - |
1687 | c = d->logicalColumn(visualColumn); | - |
1688 | if (r == -1 || (!isRowHidden(r) && d->isCellEnabled(r, c)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1689 | break; never executed: break; | 0 |
1690 | } never executed: end of block | 0 |
1691 | if (visualRow > bottom)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1692 | visualRow = originalRow; never executed: visualRow = originalRow; | 0 |
1693 | break; never executed: break; | 0 |
1694 | } | - |
1695 | case MovePrevious: never executed: case MovePrevious: | 0 |
1696 | case MoveLeft: { never executed: case MoveLeft: | 0 |
1697 | int originalRow = visualRow; | - |
1698 | int originalColumn = visualColumn; | - |
1699 | bool firstTime = true; | - |
1700 | bool looped = false; | - |
1701 | bool wrapped = false; | - |
1702 | do { | - |
1703 | int r = d->logicalRow(visualRow); | - |
1704 | int c = d->logicalColumn(visualColumn); | - |
1705 | if (firstTime && c != -1 && d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1706 | firstTime = false; | - |
1707 | QSpanCollection::Span span = d->span(r, c); | - |
1708 | if (span.width() > 1 || span.height() > 1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1709 | visualColumn = d->visualColumn(span.left()); never executed: visualColumn = d->visualColumn(span.left()); | 0 |
1710 | } never executed: end of block | 0 |
1711 | while (visualColumn >= 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1712 | --visualColumn; | - |
1713 | r = d->logicalRow(visualRow); | - |
1714 | c = d->logicalColumn(visualColumn); | - |
1715 | if (r == -1 || c == -1 || (!isRowHidden(r) && !isColumnHidden(c) && d->isCellEnabled(r, c)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1716 | break; never executed: break; | 0 |
1717 | if (wrapped && (originalRow < visualRow || (originalRow == visualRow && originalColumn <= visualColumn))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1718 | looped = true; | - |
1719 | break; never executed: break; | 0 |
1720 | } | - |
1721 | } never executed: end of block | 0 |
1722 | if (cursorAction == MoveLeft || visualColumn >= 0)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1723 | break; never executed: break; | 0 |
1724 | visualColumn = right + 1; | - |
1725 | if (visualRow == 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1726 | wrapped = true; | - |
1727 | visualRow = bottom; | - |
1728 | } else { never executed: end of block | 0 |
1729 | --visualRow; | - |
1730 | } never executed: end of block | 0 |
1731 | } while (!looped);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1732 | if (visualColumn < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1733 | visualColumn = originalColumn; never executed: visualColumn = originalColumn; | 0 |
1734 | break; never executed: break; | 0 |
1735 | } | - |
1736 | case MoveNext: never executed: case MoveNext: | 0 |
1737 | case MoveRight: { never executed: case MoveRight: | 0 |
1738 | int originalRow = visualRow; | - |
1739 | int originalColumn = visualColumn; | - |
1740 | bool firstTime = true; | - |
1741 | bool looped = false; | - |
1742 | bool wrapped = false; | - |
1743 | do { | - |
1744 | int r = d->logicalRow(visualRow); | - |
1745 | int c = d->logicalColumn(visualColumn); | - |
1746 | if (firstTime && c != -1 && d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1747 | firstTime = false; | - |
1748 | QSpanCollection::Span span = d->span(r, c); | - |
1749 | if (span.width() > 1 || span.height() > 1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1750 | visualColumn = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width())); never executed: visualColumn = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width())); | 0 |
1751 | } never executed: end of block | 0 |
1752 | while (visualColumn <= right) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1753 | ++visualColumn; | - |
1754 | r = d->logicalRow(visualRow); | - |
1755 | c = d->logicalColumn(visualColumn); | - |
1756 | if (r == -1 || c == -1 || (!isRowHidden(r) && !isColumnHidden(c) && d->isCellEnabled(r, c)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1757 | break; never executed: break; | 0 |
1758 | if (wrapped && (originalRow > visualRow || (originalRow == visualRow && originalColumn >= visualColumn))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1759 | looped = true; | - |
1760 | break; never executed: break; | 0 |
1761 | } | - |
1762 | } never executed: end of block | 0 |
1763 | if (cursorAction == MoveRight || visualColumn <= right)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1764 | break; never executed: break; | 0 |
1765 | visualColumn = -1; | - |
1766 | if (visualRow == bottom) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1767 | wrapped = true; | - |
1768 | visualRow = 0; | - |
1769 | } else { never executed: end of block | 0 |
1770 | ++visualRow; | - |
1771 | } never executed: end of block | 0 |
1772 | } while (!looped);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1773 | if (visualColumn > right)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1774 | visualColumn = originalColumn; never executed: visualColumn = originalColumn; | 0 |
1775 | break; never executed: break; | 0 |
1776 | } | - |
1777 | case MoveHome: never executed: case MoveHome: | 0 |
1778 | visualColumn = 0; | - |
1779 | while (visualColumn < right && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1780 | ++visualColumn; never executed: ++visualColumn; | 0 |
1781 | if (modifiers & Qt::ControlModifier) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1782 | visualRow = 0; | - |
1783 | while (visualRow < bottom && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1784 | ++visualRow; never executed: ++visualRow; | 0 |
1785 | } never executed: end of block | 0 |
1786 | break; never executed: break; | 0 |
1787 | case MoveEnd: never executed: case MoveEnd: | 0 |
1788 | visualColumn = right; | - |
1789 | if (modifiers & Qt::ControlModifier)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1790 | visualRow = bottom; never executed: visualRow = bottom; | 0 |
1791 | break; never executed: break; | 0 |
1792 | case MovePageUp: { never executed: case MovePageUp: | 0 |
1793 | int newRow = rowAt(visualRect(current).bottom() - d->viewport->height()); | - |
1794 | if (newRow == -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1795 | newRow = d->logicalRow(0); never executed: newRow = d->logicalRow(0); | 0 |
1796 | return d->model->index(newRow, current.column(), d->root); never executed: return d->model->index(newRow, current.column(), d->root); | 0 |
1797 | } | - |
1798 | case MovePageDown: { never executed: case MovePageDown: | 0 |
1799 | int newRow = rowAt(visualRect(current).top() + d->viewport->height()); | - |
1800 | if (newRow == -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1801 | newRow = d->logicalRow(bottom); never executed: newRow = d->logicalRow(bottom); | 0 |
1802 | return d->model->index(newRow, current.column(), d->root); never executed: return d->model->index(newRow, current.column(), d->root); | 0 |
1803 | }} | - |
1804 | | - |
1805 | d->visualCursor = QPoint(visualColumn, visualRow); | - |
1806 | int logicalRow = d->logicalRow(visualRow); | - |
1807 | int logicalColumn = d->logicalColumn(visualColumn); | - |
1808 | if (!d->model->hasIndex(logicalRow, logicalColumn, d->root))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1809 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
1810 | | - |
1811 | QModelIndex result = d->model->index(logicalRow, logicalColumn, d->root); | - |
1812 | if (!d->isRowHidden(logicalRow) && !d->isColumnHidden(logicalColumn) && d->isIndexEnabled(result)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1813 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1814 | QSpanCollection::Span span = d->span(result.row(), result.column()); | - |
1815 | if (span.width() > 1 || span.height() > 1) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1816 | result = d->model->sibling(span.top(), span.left(), result); | - |
1817 | } never executed: end of block | 0 |
1818 | } never executed: end of block | 0 |
1819 | return result; never executed: return result; | 0 |
1820 | } | - |
1821 | | - |
1822 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
1823 | } | - |
1824 | | - |
1825 | | - |
1826 | | - |
1827 | | - |
1828 | | - |
1829 | | - |
1830 | | - |
1831 | | - |
1832 | void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) | - |
1833 | { | - |
1834 | Q_D(QTableView); | - |
1835 | QModelIndex tl = indexAt(QPoint(isRightToLeft() ? qMax(rect.left(), rect.right()) | - |
1836 | : qMin(rect.left(), rect.right()), qMin(rect.top(), rect.bottom()))); | - |
1837 | QModelIndex br = indexAt(QPoint(isRightToLeft() ? qMin(rect.left(), rect.right()) : | - |
1838 | qMax(rect.left(), rect.right()), qMax(rect.top(), rect.bottom()))); | - |
1839 | if (!d->selectionModel || !tl.isValid() || !br.isValid() || !d->isIndexEnabled(tl) || !d->isIndexEnabled(br))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1840 | return; never executed: return; | 0 |
1841 | | - |
1842 | bool verticalMoved = verticalHeader()->sectionsMoved(); | - |
1843 | bool horizontalMoved = horizontalHeader()->sectionsMoved(); | - |
1844 | | - |
1845 | QItemSelection selection; | - |
1846 | | - |
1847 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1848 | bool expanded; | - |
1849 | int top = qMin(d->visualRow(tl.row()), d->visualRow(br.row())); | - |
1850 | int left = qMin(d->visualColumn(tl.column()), d->visualColumn(br.column())); | - |
1851 | int bottom = qMax(d->visualRow(tl.row()), d->visualRow(br.row())); | - |
1852 | int right = qMax(d->visualColumn(tl.column()), d->visualColumn(br.column())); | - |
1853 | do { | - |
1854 | expanded = false; | - |
1855 | foreach (QSpanCollection::Span *it, d->spans.spans) { | - |
1856 | const QSpanCollection::Span &span = *it; | - |
1857 | int t = d->visualRow(span.top()); | - |
1858 | int l = d->visualColumn(span.left()); | - |
1859 | int b = d->visualRow(d->rowSpanEndLogical(span.top(), span.height())); | - |
1860 | int r = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width())); | - |
1861 | if ((t > bottom) || (l > right) || (top > b) || (left > r))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1862 | continue; never executed: continue; | 0 |
1863 | if (t < top) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1864 | top = t; | - |
1865 | expanded = true; | - |
1866 | } never executed: end of block | 0 |
1867 | if (l < left) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1868 | left = l; | - |
1869 | expanded = true; | - |
1870 | } never executed: end of block | 0 |
1871 | if (b > bottom) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1872 | bottom = b; | - |
1873 | expanded = true; | - |
1874 | } never executed: end of block | 0 |
1875 | if (r > right) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1876 | right = r; | - |
1877 | expanded = true; | - |
1878 | } never executed: end of block | 0 |
1879 | if (expanded)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1880 | break; never executed: break; | 0 |
1881 | } never executed: end of block | 0 |
1882 | } while (expanded); never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1883 | selection.reserve((right - left + 1) * (bottom - top + 1)); | - |
1884 | for (int horizontal = left; horizontal <= right; ++horizontal) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1885 | int column = d->logicalColumn(horizontal); | - |
1886 | for (int vertical = top; vertical <= bottom; ++vertical) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1887 | int row = d->logicalRow(vertical); | - |
1888 | QModelIndex index = d->model->index(row, column, d->root); | - |
1889 | selection.append(QItemSelectionRange(index)); | - |
1890 | } never executed: end of block | 0 |
1891 | } never executed: end of block | 0 |
1892 | } else if (verticalMoved && horizontalMoved) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1893 | int top = d->visualRow(tl.row()); | - |
1894 | int left = d->visualColumn(tl.column()); | - |
1895 | int bottom = d->visualRow(br.row()); | - |
1896 | int right = d->visualColumn(br.column()); | - |
1897 | selection.reserve((right - left + 1) * (bottom - top + 1)); | - |
1898 | for (int horizontal = left; horizontal <= right; ++horizontal) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1899 | int column = d->logicalColumn(horizontal); | - |
1900 | for (int vertical = top; vertical <= bottom; ++vertical) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1901 | int row = d->logicalRow(vertical); | - |
1902 | QModelIndex index = d->model->index(row, column, d->root); | - |
1903 | selection.append(QItemSelectionRange(index)); | - |
1904 | } never executed: end of block | 0 |
1905 | } never executed: end of block | 0 |
1906 | } else if (horizontalMoved) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1907 | int left = d->visualColumn(tl.column()); | - |
1908 | int right = d->visualColumn(br.column()); | - |
1909 | selection.reserve(right - left + 1); | - |
1910 | for (int visual = left; visual <= right; ++visual) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1911 | int column = d->logicalColumn(visual); | - |
1912 | QModelIndex topLeft = d->model->index(tl.row(), column, d->root); | - |
1913 | QModelIndex bottomRight = d->model->index(br.row(), column, d->root); | - |
1914 | selection.append(QItemSelectionRange(topLeft, bottomRight)); | - |
1915 | } never executed: end of block | 0 |
1916 | } else if (verticalMoved) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1917 | int top = d->visualRow(tl.row()); | - |
1918 | int bottom = d->visualRow(br.row()); | - |
1919 | selection.reserve(bottom - top + 1); | - |
1920 | for (int visual = top; visual <= bottom; ++visual) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1921 | int row = d->logicalRow(visual); | - |
1922 | QModelIndex topLeft = d->model->index(row, tl.column(), d->root); | - |
1923 | QModelIndex bottomRight = d->model->index(row, br.column(), d->root); | - |
1924 | selection.append(QItemSelectionRange(topLeft, bottomRight)); | - |
1925 | } never executed: end of block | 0 |
1926 | } else { never executed: end of block | 0 |
1927 | QItemSelectionRange range(tl, br); | - |
1928 | if (!range.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1929 | selection.append(range); never executed: selection.append(range); | 0 |
1930 | } never executed: end of block | 0 |
1931 | | - |
1932 | d->selectionModel->select(selection, command); | - |
1933 | } never executed: end of block | 0 |
1934 | | - |
1935 | | - |
1936 | | - |
1937 | | - |
1938 | | - |
1939 | | - |
1940 | | - |
1941 | | - |
1942 | | - |
1943 | | - |
1944 | QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) const | - |
1945 | { | - |
1946 | Q_D(const QTableView); | - |
1947 | | - |
1948 | if (selection.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1949 | return QRegion(); never executed: return QRegion(); | 0 |
1950 | | - |
1951 | QRegion selectionRegion; | - |
1952 | const QRect &viewportRect = d->viewport->rect(); | - |
1953 | bool verticalMoved = verticalHeader()->sectionsMoved(); | - |
1954 | bool horizontalMoved = horizontalHeader()->sectionsMoved(); | - |
1955 | | - |
1956 | if ((verticalMoved && horizontalMoved) || (d->hasSpans() && (verticalMoved || horizontalMoved))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1957 | for (const auto &range : selection) { | - |
1958 | if (range.parent() != d->root || !range.isValid())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1959 | continue; never executed: continue; | 0 |
1960 | for (int r = range.top(); r <= range.bottom(); ++r)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1961 | for (int c = range.left(); c <= range.right(); ++c) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1962 | const QRect &rangeRect = visualRect(d->model->index(r, c, d->root)); | - |
1963 | if (viewportRect.intersects(rangeRect))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1964 | selectionRegion += rangeRect; never executed: selectionRegion += rangeRect; | 0 |
1965 | } never executed: end of block | 0 |
1966 | } never executed: end of block | 0 |
1967 | } else if (horizontalMoved) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1968 | for (const auto &range : selection) { | - |
1969 | if (range.parent() != d->root || !range.isValid())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1970 | continue; never executed: continue; | 0 |
1971 | int top = rowViewportPosition(range.top()); | - |
1972 | int bottom = rowViewportPosition(range.bottom()) + rowHeight(range.bottom()); | - |
1973 | if (top > bottom)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1974 | qSwap<int>(top, bottom); never executed: qSwap<int>(top, bottom); | 0 |
1975 | int height = bottom - top; | - |
1976 | for (int c = range.left(); c <= range.right(); ++c) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1977 | const QRect rangeRect(columnViewportPosition(c), top, columnWidth(c), height); | - |
1978 | if (viewportRect.intersects(rangeRect))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1979 | selectionRegion += rangeRect; never executed: selectionRegion += rangeRect; | 0 |
1980 | } never executed: end of block | 0 |
1981 | } never executed: end of block | 0 |
1982 | } else if (verticalMoved) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1983 | for (const auto &range : selection) { | - |
1984 | if (range.parent() != d->root || !range.isValid())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1985 | continue; never executed: continue; | 0 |
1986 | int left = columnViewportPosition(range.left()); | - |
1987 | int right = columnViewportPosition(range.right()) + columnWidth(range.right()); | - |
1988 | if (left > right)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1989 | qSwap<int>(left, right); never executed: qSwap<int>(left, right); | 0 |
1990 | int width = right - left; | - |
1991 | for (int r = range.top(); r <= range.bottom(); ++r) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1992 | const QRect rangeRect(left, rowViewportPosition(r), width, rowHeight(r)); | - |
1993 | if (viewportRect.intersects(rangeRect))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1994 | selectionRegion += rangeRect; never executed: selectionRegion += rangeRect; | 0 |
1995 | } never executed: end of block | 0 |
1996 | } never executed: end of block | 0 |
1997 | } else { never executed: end of block | 0 |
1998 | const int gridAdjust = showGrid() ? 1 : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1999 | for (auto range : selection) { | - |
2000 | if (range.parent() != d->root || !range.isValid())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2001 | continue; never executed: continue; | 0 |
2002 | d->trimHiddenSelections(&range); | - |
2003 | | - |
2004 | const int rtop = rowViewportPosition(range.top()); | - |
2005 | const int rbottom = rowViewportPosition(range.bottom()) + rowHeight(range.bottom()); | - |
2006 | int rleft; | - |
2007 | int rright; | - |
2008 | if (isLeftToRight()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2009 | rleft = columnViewportPosition(range.left()); | - |
2010 | rright = columnViewportPosition(range.right()) + columnWidth(range.right()); | - |
2011 | } else { never executed: end of block | 0 |
2012 | rleft = columnViewportPosition(range.right()); | - |
2013 | rright = columnViewportPosition(range.left()) + columnWidth(range.left()); | - |
2014 | } never executed: end of block | 0 |
2015 | const QRect rangeRect(QPoint(rleft, rtop), QPoint(rright - 1 - gridAdjust, rbottom - 1 - gridAdjust)); | - |
2016 | if (viewportRect.intersects(rangeRect))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2017 | selectionRegion += rangeRect; never executed: selectionRegion += rangeRect; | 0 |
2018 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2019 | const auto spansInRect = d->spans.spansInRect(range.left(), range.top(), range.width(), range.height()); | - |
2020 | for (QSpanCollection::Span *s : spansInRect) { | - |
2021 | if (range.contains(s->top(), s->left(), range.parent())) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2022 | const QRect &visualSpanRect = d->visualSpanRect(*s); | - |
2023 | if (viewportRect.intersects(visualSpanRect))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2024 | selectionRegion += visualSpanRect; never executed: selectionRegion += visualSpanRect; | 0 |
2025 | } never executed: end of block | 0 |
2026 | } never executed: end of block | 0 |
2027 | } never executed: end of block | 0 |
2028 | } never executed: end of block | 0 |
2029 | } never executed: end of block | 0 |
2030 | | - |
2031 | return selectionRegion; never executed: return selectionRegion; | 0 |
2032 | } | - |
2033 | | - |
2034 | | - |
2035 | | - |
2036 | | - |
2037 | | - |
2038 | QModelIndexList QTableView::selectedIndexes() const | - |
2039 | { | - |
2040 | Q_D(const QTableView); | - |
2041 | QModelIndexList viewSelected; | - |
2042 | QModelIndexList modelSelected; | - |
2043 | if (d->selectionModel)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2044 | modelSelected = d->selectionModel->selectedIndexes(); never executed: modelSelected = d->selectionModel->selectedIndexes(); | 0 |
2045 | for (int i = 0; i < modelSelected.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2046 | QModelIndex index = modelSelected.at(i); | - |
2047 | if (!isIndexHidden(index) && index.parent() == d->root)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2048 | viewSelected.append(index); never executed: viewSelected.append(index); | 0 |
2049 | } never executed: end of block | 0 |
2050 | return viewSelected; never executed: return viewSelected; | 0 |
2051 | } | - |
2052 | | - |
2053 | | - |
2054 | | - |
2055 | | - |
2056 | | - |
2057 | | - |
2058 | | - |
2059 | void QTableView::rowCountChanged(int oldCount, int newCount ) | - |
2060 | { | - |
2061 | Q_D(QTableView); | - |
2062 | | - |
2063 | | - |
2064 | if (newCount < oldCount)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2065 | d->verticalHeader->setUpdatesEnabled(false); never executed: d->verticalHeader->setUpdatesEnabled(false); | 0 |
2066 | d->doDelayedItemsLayout(); | - |
2067 | } never executed: end of block | 0 |
2068 | | - |
2069 | | - |
2070 | | - |
2071 | | - |
2072 | | - |
2073 | | - |
2074 | void QTableView::columnCountChanged(int, int) | - |
2075 | { | - |
2076 | Q_D(QTableView); | - |
2077 | updateGeometries(); | - |
2078 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2079 | d->horizontalHeader->setOffsetToSectionPosition(horizontalScrollBar()->value()); never executed: d->horizontalHeader->setOffsetToSectionPosition(horizontalScrollBar()->value()); | 0 |
2080 | else | - |
2081 | d->horizontalHeader->setOffset(horizontalScrollBar()->value()); never executed: d->horizontalHeader->setOffset(horizontalScrollBar()->value()); | 0 |
2082 | d->viewport->update(); | - |
2083 | } never executed: end of block | 0 |
2084 | | - |
2085 | | - |
2086 | | - |
2087 | | - |
2088 | void QTableView::updateGeometries() | - |
2089 | { | - |
2090 | Q_D(QTableView); | - |
2091 | if (d->geometryRecursionBlock)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2092 | return; never executed: return; | 0 |
2093 | d->geometryRecursionBlock = true; | - |
2094 | | - |
2095 | int width = 0; | - |
2096 | if (!d->verticalHeader->isHidden()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2097 | width = qMax(d->verticalHeader->minimumWidth(), d->verticalHeader->sizeHint().width()); | - |
2098 | width = qMin(width, d->verticalHeader->maximumWidth()); | - |
2099 | } never executed: end of block | 0 |
2100 | int height = 0; | - |
2101 | if (!d->horizontalHeader->isHidden()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2102 | height = qMax(d->horizontalHeader->minimumHeight(), d->horizontalHeader->sizeHint().height()); | - |
2103 | height = qMin(height, d->horizontalHeader->maximumHeight()); | - |
2104 | } never executed: end of block | 0 |
2105 | bool reverse = isRightToLeft(); | - |
2106 | if (reverse)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2107 | setViewportMargins(0, height, width, 0); never executed: setViewportMargins(0, height, width, 0); | 0 |
2108 | else | - |
2109 | setViewportMargins(width, height, 0, 0); never executed: setViewportMargins(width, height, 0, 0); | 0 |
2110 | | - |
2111 | | - |
2112 | | - |
2113 | QRect vg = d->viewport->geometry(); | - |
2114 | | - |
2115 | int verticalLeft = reverse ? vg.right() + 1 : (vg.left() - width);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2116 | d->verticalHeader->setGeometry(verticalLeft, vg.top(), width, vg.height()); | - |
2117 | if (d->verticalHeader->isHidden())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2118 | QMetaObject::invokeMethod(d->verticalHeader, "updateGeometries"); never executed: QMetaObject::invokeMethod(d->verticalHeader, "updateGeometries"); | 0 |
2119 | | - |
2120 | int horizontalTop = vg.top() - height; | - |
2121 | d->horizontalHeader->setGeometry(vg.left(), horizontalTop, vg.width(), height); | - |
2122 | if (d->horizontalHeader->isHidden())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2123 | QMetaObject::invokeMethod(d->horizontalHeader, "updateGeometries"); never executed: QMetaObject::invokeMethod(d->horizontalHeader, "updateGeometries"); | 0 |
2124 | | - |
2125 | | - |
2126 | if (d->horizontalHeader->isHidden() || d->verticalHeader->isHidden()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2127 | d->cornerWidget->setHidden(true); | - |
2128 | } else { never executed: end of block | 0 |
2129 | d->cornerWidget->setHidden(false); | - |
2130 | d->cornerWidget->setGeometry(verticalLeft, horizontalTop, width, height); | - |
2131 | } never executed: end of block | 0 |
2132 | | - |
2133 | | - |
2134 | | - |
2135 | | - |
2136 | QSize vsize = d->viewport->size(); | - |
2137 | QSize max = maximumViewportSize(); | - |
2138 | uint horizontalLength = d->horizontalHeader->length(); | - |
2139 | uint verticalLength = d->verticalHeader->length(); | - |
2140 | if ((uint)max.width() >= horizontalLength && (uint)max.height() >= verticalLength)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2141 | vsize = max; never executed: vsize = max; | 0 |
2142 | | - |
2143 | | - |
2144 | const int columnCount = d->horizontalHeader->count(); | - |
2145 | const int viewportWidth = vsize.width(); | - |
2146 | int columnsInViewport = 0; | - |
2147 | for (int width = 0, column = columnCount - 1; column >= 0; --column) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2148 | int logical = d->horizontalHeader->logicalIndex(column); | - |
2149 | if (!d->horizontalHeader->isSectionHidden(logical)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2150 | width += d->horizontalHeader->sectionSize(logical); | - |
2151 | if (width > viewportWidth)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2152 | break; never executed: break; | 0 |
2153 | ++columnsInViewport; | - |
2154 | } never executed: end of block | 0 |
2155 | } never executed: end of block | 0 |
2156 | columnsInViewport = qMax(columnsInViewport, 1); | - |
2157 | | - |
2158 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2159 | const int visibleColumns = columnCount - d->horizontalHeader->hiddenSectionCount(); | - |
2160 | horizontalScrollBar()->setRange(0, visibleColumns - columnsInViewport); | - |
2161 | horizontalScrollBar()->setPageStep(columnsInViewport); | - |
2162 | if (columnsInViewport >= visibleColumns)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2163 | d->horizontalHeader->setOffset(0); never executed: d->horizontalHeader->setOffset(0); | 0 |
2164 | horizontalScrollBar()->setSingleStep(1); | - |
2165 | } else { never executed: end of block | 0 |
2166 | horizontalScrollBar()->setPageStep(vsize.width()); | - |
2167 | horizontalScrollBar()->setRange(0, horizontalLength - vsize.width()); | - |
2168 | horizontalScrollBar()->d_func()->itemviewChangeSingleStep(qMax(vsize.width() / (columnsInViewport + 1), 2)); | - |
2169 | } never executed: end of block | 0 |
2170 | | - |
2171 | | - |
2172 | const int rowCount = d->verticalHeader->count(); | - |
2173 | const int viewportHeight = vsize.height(); | - |
2174 | int rowsInViewport = 0; | - |
2175 | for (int height = 0, row = rowCount - 1; row >= 0; --row) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2176 | int logical = d->verticalHeader->logicalIndex(row); | - |
2177 | if (!d->verticalHeader->isSectionHidden(logical)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2178 | height += d->verticalHeader->sectionSize(logical); | - |
2179 | if (height > viewportHeight)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2180 | break; never executed: break; | 0 |
2181 | ++rowsInViewport; | - |
2182 | } never executed: end of block | 0 |
2183 | } never executed: end of block | 0 |
2184 | rowsInViewport = qMax(rowsInViewport, 1); | - |
2185 | | - |
2186 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2187 | const int visibleRows = rowCount - d->verticalHeader->hiddenSectionCount(); | - |
2188 | verticalScrollBar()->setRange(0, visibleRows - rowsInViewport); | - |
2189 | verticalScrollBar()->setPageStep(rowsInViewport); | - |
2190 | if (rowsInViewport >= visibleRows)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2191 | d->verticalHeader->setOffset(0); never executed: d->verticalHeader->setOffset(0); | 0 |
2192 | verticalScrollBar()->setSingleStep(1); | - |
2193 | } else { never executed: end of block | 0 |
2194 | verticalScrollBar()->setPageStep(vsize.height()); | - |
2195 | verticalScrollBar()->setRange(0, verticalLength - vsize.height()); | - |
2196 | verticalScrollBar()->d_func()->itemviewChangeSingleStep(qMax(vsize.height() / (rowsInViewport + 1), 2)); | - |
2197 | } never executed: end of block | 0 |
2198 | | - |
2199 | d->geometryRecursionBlock = false; | - |
2200 | QAbstractItemView::updateGeometries(); | - |
2201 | } never executed: end of block | 0 |
2202 | | - |
2203 | | - |
2204 | | - |
2205 | | - |
2206 | | - |
2207 | | - |
2208 | | - |
2209 | | - |
2210 | | - |
2211 | | - |
2212 | | - |
2213 | | - |
2214 | | - |
2215 | | - |
2216 | | - |
2217 | int QTableView::sizeHintForRow(int row) const | - |
2218 | { | - |
2219 | Q_D(const QTableView); | - |
2220 | | - |
2221 | if (!model())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2222 | return -1; never executed: return -1; | 0 |
2223 | | - |
2224 | ensurePolished(); | - |
2225 | const int maximumProcessCols = d->verticalHeader->resizeContentsPrecision(); | - |
2226 | | - |
2227 | | - |
2228 | int left = qMax(0, d->horizontalHeader->visualIndexAt(0)); | - |
2229 | int right = d->horizontalHeader->visualIndexAt(d->viewport->width()); | - |
2230 | if (right == -1) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2231 | right = d->model->columnCount(d->root) - 1; never executed: right = d->model->columnCount(d->root) - 1; | 0 |
2232 | | - |
2233 | QStyleOptionViewItem option = d->viewOptionsV1(); | - |
2234 | | - |
2235 | int hint = 0; | - |
2236 | QModelIndex index; | - |
2237 | int columnsProcessed = 0; | - |
2238 | int column = left; | - |
2239 | for (; column <= right; ++column) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2240 | int logicalColumn = d->horizontalHeader->logicalIndex(column); | - |
2241 | if (d->horizontalHeader->isSectionHidden(logicalColumn))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2242 | continue; never executed: continue; | 0 |
2243 | index = d->model->index(row, logicalColumn, d->root); | - |
2244 | hint = d->heightHintForIndex(index, hint, option); | - |
2245 | | - |
2246 | ++columnsProcessed; | - |
2247 | if (columnsProcessed == maximumProcessCols)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2248 | break; never executed: break; | 0 |
2249 | } never executed: end of block | 0 |
2250 | | - |
2251 | int actualRight = d->model->columnCount(d->root) - 1; | - |
2252 | int idxLeft = left; | - |
2253 | int idxRight = column - 1; | - |
2254 | | - |
2255 | if (maximumProcessCols == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2256 | columnsProcessed = 0; never executed: columnsProcessed = 0; | 0 |
2257 | | - |
2258 | while (columnsProcessed != maximumProcessCols && (idxLeft > 0 || idxRight < actualRight)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2259 | int logicalIdx = -1; | - |
2260 | | - |
2261 | if ((columnsProcessed % 2 && idxLeft > 0) || idxRight == actualRight) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2262 | while (idxLeft > 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2263 | --idxLeft; | - |
2264 | int logcol = d->horizontalHeader->logicalIndex(idxLeft); | - |
2265 | if (d->horizontalHeader->isSectionHidden(logcol))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2266 | continue; never executed: continue; | 0 |
2267 | logicalIdx = logcol; | - |
2268 | break; never executed: break; | 0 |
2269 | } | - |
2270 | } else { never executed: end of block | 0 |
2271 | while (idxRight < actualRight) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2272 | ++idxRight; | - |
2273 | int logcol = d->horizontalHeader->logicalIndex(idxRight); | - |
2274 | if (d->horizontalHeader->isSectionHidden(logcol))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2275 | continue; never executed: continue; | 0 |
2276 | logicalIdx = logcol; | - |
2277 | break; never executed: break; | 0 |
2278 | } | - |
2279 | } never executed: end of block | 0 |
2280 | if (logicalIdx < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2281 | continue; never executed: continue; | 0 |
2282 | | - |
2283 | index = d->model->index(row, logicalIdx, d->root); | - |
2284 | hint = d->heightHintForIndex(index, hint, option); | - |
2285 | ++columnsProcessed; | - |
2286 | } never executed: end of block | 0 |
2287 | | - |
2288 | return d->showGrid ? hint + 1 : hint; never executed: return d->showGrid ? hint + 1 : hint; | 0 |
2289 | } | - |
2290 | | - |
2291 | | - |
2292 | | - |
2293 | | - |
2294 | | - |
2295 | | - |
2296 | | - |
2297 | | - |
2298 | | - |
2299 | | - |
2300 | | - |
2301 | | - |
2302 | | - |
2303 | | - |
2304 | | - |
2305 | | - |
2306 | int QTableView::sizeHintForColumn(int column) const | - |
2307 | { | - |
2308 | Q_D(const QTableView); | - |
2309 | | - |
2310 | if (!model())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2311 | return -1; never executed: return -1; | 0 |
2312 | | - |
2313 | ensurePolished(); | - |
2314 | const int maximumProcessRows = d->horizontalHeader->resizeContentsPrecision(); | - |
2315 | | - |
2316 | int top = qMax(0, d->verticalHeader->visualIndexAt(0)); | - |
2317 | int bottom = d->verticalHeader->visualIndexAt(d->viewport->height()); | - |
2318 | if (!isVisible() || bottom == -1) TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2319 | bottom = d->model->rowCount(d->root) - 1; never executed: bottom = d->model->rowCount(d->root) - 1; | 0 |
2320 | | - |
2321 | QStyleOptionViewItem option = d->viewOptionsV1(); | - |
2322 | | - |
2323 | int hint = 0; | - |
2324 | int rowsProcessed = 0; | - |
2325 | QModelIndex index; | - |
2326 | int row = top; | - |
2327 | for (; row <= bottom; ++row) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2328 | int logicalRow = d->verticalHeader->logicalIndex(row); | - |
2329 | if (d->verticalHeader->isSectionHidden(logicalRow))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2330 | continue; never executed: continue; | 0 |
2331 | index = d->model->index(logicalRow, column, d->root); | - |
2332 | | - |
2333 | hint = d->widthHintForIndex(index, hint, option); | - |
2334 | ++rowsProcessed; | - |
2335 | if (rowsProcessed == maximumProcessRows)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2336 | break; never executed: break; | 0 |
2337 | } never executed: end of block | 0 |
2338 | | - |
2339 | int actualBottom = d->model->rowCount(d->root) - 1; | - |
2340 | int idxTop = top; | - |
2341 | int idxBottom = row - 1; | - |
2342 | | - |
2343 | if (maximumProcessRows == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2344 | rowsProcessed = 0; never executed: rowsProcessed = 0; | 0 |
2345 | | - |
2346 | while (rowsProcessed != maximumProcessRows && (idxTop > 0 || idxBottom < actualBottom)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2347 | int logicalIdx = -1; | - |
2348 | | - |
2349 | if ((rowsProcessed % 2 && idxTop > 0) || idxBottom == actualBottom) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2350 | while (idxTop > 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2351 | --idxTop; | - |
2352 | int logrow = d->verticalHeader->logicalIndex(idxTop); | - |
2353 | if (d->verticalHeader->isSectionHidden(logrow))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2354 | continue; never executed: continue; | 0 |
2355 | logicalIdx = logrow; | - |
2356 | break; never executed: break; | 0 |
2357 | } | - |
2358 | } else { never executed: end of block | 0 |
2359 | while (idxBottom < actualBottom) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2360 | ++idxBottom; | - |
2361 | int logrow = d->verticalHeader->logicalIndex(idxBottom); | - |
2362 | if (d->verticalHeader->isSectionHidden(logrow))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2363 | continue; never executed: continue; | 0 |
2364 | logicalIdx = logrow; | - |
2365 | break; never executed: break; | 0 |
2366 | } | - |
2367 | } never executed: end of block | 0 |
2368 | if (logicalIdx < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2369 | continue; never executed: continue; | 0 |
2370 | | - |
2371 | index = d->model->index(logicalIdx, column, d->root); | - |
2372 | hint = d->widthHintForIndex(index, hint, option); | - |
2373 | ++rowsProcessed; | - |
2374 | } never executed: end of block | 0 |
2375 | | - |
2376 | return d->showGrid ? hint + 1 : hint; never executed: return d->showGrid ? hint + 1 : hint; | 0 |
2377 | } | - |
2378 | | - |
2379 | | - |
2380 | | - |
2381 | | - |
2382 | | - |
2383 | int QTableView::rowViewportPosition(int row) const | - |
2384 | { | - |
2385 | Q_D(const QTableView); | - |
2386 | return d->verticalHeader->sectionViewportPosition(row); never executed: return d->verticalHeader->sectionViewportPosition(row); | 0 |
2387 | } | - |
2388 | | - |
2389 | | - |
2390 | | - |
2391 | | - |
2392 | | - |
2393 | | - |
2394 | | - |
2395 | | - |
2396 | | - |
2397 | | - |
2398 | int QTableView::rowAt(int y) const | - |
2399 | { | - |
2400 | Q_D(const QTableView); | - |
2401 | return d->verticalHeader->logicalIndexAt(y); never executed: return d->verticalHeader->logicalIndexAt(y); | 0 |
2402 | } | - |
2403 | | - |
2404 | | - |
2405 | | - |
2406 | | - |
2407 | | - |
2408 | | - |
2409 | void QTableView::setRowHeight(int row, int height) | - |
2410 | { | - |
2411 | Q_D(const QTableView); | - |
2412 | d->verticalHeader->resizeSection(row, height); | - |
2413 | } never executed: end of block | 0 |
2414 | | - |
2415 | | - |
2416 | | - |
2417 | | - |
2418 | | - |
2419 | | - |
2420 | int QTableView::rowHeight(int row) const | - |
2421 | { | - |
2422 | Q_D(const QTableView); | - |
2423 | return d->verticalHeader->sectionSize(row); never executed: return d->verticalHeader->sectionSize(row); | 0 |
2424 | } | - |
2425 | | - |
2426 | | - |
2427 | | - |
2428 | | - |
2429 | | - |
2430 | int QTableView::columnViewportPosition(int column) const | - |
2431 | { | - |
2432 | Q_D(const QTableView); | - |
2433 | return d->horizontalHeader->sectionViewportPosition(column); never executed: return d->horizontalHeader->sectionViewportPosition(column); | 0 |
2434 | } | - |
2435 | | - |
2436 | | - |
2437 | | - |
2438 | | - |
2439 | | - |
2440 | | - |
2441 | | - |
2442 | | - |
2443 | | - |
2444 | | - |
2445 | int QTableView::columnAt(int x) const | - |
2446 | { | - |
2447 | Q_D(const QTableView); | - |
2448 | return d->horizontalHeader->logicalIndexAt(x); never executed: return d->horizontalHeader->logicalIndexAt(x); | 0 |
2449 | } | - |
2450 | | - |
2451 | | - |
2452 | | - |
2453 | | - |
2454 | | - |
2455 | | - |
2456 | void QTableView::setColumnWidth(int column, int width) | - |
2457 | { | - |
2458 | Q_D(const QTableView); | - |
2459 | d->horizontalHeader->resizeSection(column, width); | - |
2460 | } never executed: end of block | 0 |
2461 | | - |
2462 | | - |
2463 | | - |
2464 | | - |
2465 | | - |
2466 | | - |
2467 | int QTableView::columnWidth(int column) const | - |
2468 | { | - |
2469 | Q_D(const QTableView); | - |
2470 | return d->horizontalHeader->sectionSize(column); never executed: return d->horizontalHeader->sectionSize(column); | 0 |
2471 | } | - |
2472 | | - |
2473 | | - |
2474 | | - |
2475 | | - |
2476 | | - |
2477 | | - |
2478 | bool QTableView::isRowHidden(int row) const | - |
2479 | { | - |
2480 | Q_D(const QTableView); | - |
2481 | return d->verticalHeader->isSectionHidden(row); never executed: return d->verticalHeader->isSectionHidden(row); | 0 |
2482 | } | - |
2483 | | - |
2484 | | - |
2485 | | - |
2486 | | - |
2487 | | - |
2488 | | - |
2489 | void QTableView::setRowHidden(int row, bool hide) | - |
2490 | { | - |
2491 | Q_D(QTableView); | - |
2492 | if (row < 0 || row >= d->verticalHeader->count())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2493 | return; never executed: return; | 0 |
2494 | d->verticalHeader->setSectionHidden(row, hide); | - |
2495 | } never executed: end of block | 0 |
2496 | | - |
2497 | | - |
2498 | | - |
2499 | | - |
2500 | | - |
2501 | | - |
2502 | bool QTableView::isColumnHidden(int column) const | - |
2503 | { | - |
2504 | Q_D(const QTableView); | - |
2505 | return d->horizontalHeader->isSectionHidden(column); never executed: return d->horizontalHeader->isSectionHidden(column); | 0 |
2506 | } | - |
2507 | | - |
2508 | | - |
2509 | | - |
2510 | | - |
2511 | | - |
2512 | | - |
2513 | | - |
2514 | void QTableView::setColumnHidden(int column, bool hide) | - |
2515 | { | - |
2516 | Q_D(QTableView); | - |
2517 | if (column < 0 || column >= d->horizontalHeader->count())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2518 | return; never executed: return; | 0 |
2519 | d->horizontalHeader->setSectionHidden(column, hide); | - |
2520 | } never executed: end of block | 0 |
2521 | | - |
2522 | | - |
2523 | | - |
2524 | | - |
2525 | | - |
2526 | | - |
2527 | | - |
2528 | | - |
2529 | | - |
2530 | | - |
2531 | | - |
2532 | | - |
2533 | | - |
2534 | | - |
2535 | | - |
2536 | | - |
2537 | | - |
2538 | | - |
2539 | | - |
2540 | | - |
2541 | | - |
2542 | | - |
2543 | void QTableView::setSortingEnabled(bool enable) | - |
2544 | { | - |
2545 | Q_D(QTableView); | - |
2546 | d->sortingEnabled = enable; | - |
2547 | horizontalHeader()->setSortIndicatorShown(enable); | - |
2548 | if (enable) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2549 | disconnect(d->horizontalHeader, SIGNAL(sectionEntered(int)), | - |
2550 | this, SLOT(_q_selectColumn(int))); | - |
2551 | disconnect(horizontalHeader(), SIGNAL(sectionPressed(int)), | - |
2552 | this, SLOT(selectColumn(int))); | - |
2553 | connect(horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), | - |
2554 | this, SLOT(sortByColumn(int)), Qt::UniqueConnection); | - |
2555 | sortByColumn(horizontalHeader()->sortIndicatorSection(), | - |
2556 | horizontalHeader()->sortIndicatorOrder()); | - |
2557 | } else { never executed: end of block | 0 |
2558 | connect(d->horizontalHeader, SIGNAL(sectionEntered(int)), | - |
2559 | this, SLOT(_q_selectColumn(int)), Qt::UniqueConnection); | - |
2560 | connect(horizontalHeader(), SIGNAL(sectionPressed(int)), | - |
2561 | this, SLOT(selectColumn(int)), Qt::UniqueConnection); | - |
2562 | disconnect(horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), | - |
2563 | this, SLOT(sortByColumn(int))); | - |
2564 | } never executed: end of block | 0 |
2565 | } | - |
2566 | | - |
2567 | bool QTableView::isSortingEnabled() const | - |
2568 | { | - |
2569 | Q_D(const QTableView); | - |
2570 | return d->sortingEnabled; never executed: return d->sortingEnabled; | 0 |
2571 | } | - |
2572 | | - |
2573 | | - |
2574 | | - |
2575 | | - |
2576 | | - |
2577 | | - |
2578 | | - |
2579 | | - |
2580 | bool QTableView::showGrid() const | - |
2581 | { | - |
2582 | Q_D(const QTableView); | - |
2583 | return d->showGrid; never executed: return d->showGrid; | 0 |
2584 | } | - |
2585 | | - |
2586 | void QTableView::setShowGrid(bool show) | - |
2587 | { | - |
2588 | Q_D(QTableView); | - |
2589 | if (d->showGrid != show) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2590 | d->showGrid = show; | - |
2591 | d->viewport->update(); | - |
2592 | } never executed: end of block | 0 |
2593 | } never executed: end of block | 0 |
2594 | | - |
2595 | | - |
2596 | | - |
2597 | | - |
2598 | | - |
2599 | | - |
2600 | | - |
2601 | Qt::PenStyle QTableView::gridStyle() const | - |
2602 | { | - |
2603 | Q_D(const QTableView); | - |
2604 | return d->gridStyle; never executed: return d->gridStyle; | 0 |
2605 | } | - |
2606 | | - |
2607 | void QTableView::setGridStyle(Qt::PenStyle style) | - |
2608 | { | - |
2609 | Q_D(QTableView); | - |
2610 | if (d->gridStyle != style) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2611 | d->gridStyle = style; | - |
2612 | d->viewport->update(); | - |
2613 | } never executed: end of block | 0 |
2614 | } never executed: end of block | 0 |
2615 | | - |
2616 | | - |
2617 | | - |
2618 | | - |
2619 | | - |
2620 | | - |
2621 | | - |
2622 | | - |
2623 | | - |
2624 | | - |
2625 | | - |
2626 | | - |
2627 | | - |
2628 | | - |
2629 | | - |
2630 | void QTableView::setWordWrap(bool on) | - |
2631 | { | - |
2632 | Q_D(QTableView); | - |
2633 | if (d->wrapItemText == on)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2634 | return; never executed: return; | 0 |
2635 | d->wrapItemText = on; | - |
2636 | QMetaObject::invokeMethod(d->verticalHeader, "resizeSections"); | - |
2637 | QMetaObject::invokeMethod(d->horizontalHeader, "resizeSections"); | - |
2638 | } never executed: end of block | 0 |
2639 | | - |
2640 | bool QTableView::wordWrap() const | - |
2641 | { | - |
2642 | Q_D(const QTableView); | - |
2643 | return d->wrapItemText; never executed: return d->wrapItemText; | 0 |
2644 | } | - |
2645 | | - |
2646 | | - |
2647 | | - |
2648 | | - |
2649 | | - |
2650 | | - |
2651 | | - |
2652 | | - |
2653 | | - |
2654 | | - |
2655 | | - |
2656 | | - |
2657 | void QTableView::setCornerButtonEnabled(bool enable) | - |
2658 | { | - |
2659 | Q_D(QTableView); | - |
2660 | d->cornerWidget->setEnabled(enable); | - |
2661 | } never executed: end of block | 0 |
2662 | | - |
2663 | bool QTableView::isCornerButtonEnabled() const | - |
2664 | { | - |
2665 | Q_D(const QTableView); | - |
2666 | return d->cornerWidget->isEnabled(); never executed: return d->cornerWidget->isEnabled(); | 0 |
2667 | } | - |
2668 | | - |
2669 | | - |
2670 | | - |
2671 | | - |
2672 | | - |
2673 | | - |
2674 | | - |
2675 | | - |
2676 | QRect QTableView::visualRect(const QModelIndex &index) const | - |
2677 | { | - |
2678 | Q_D(const QTableView); | - |
2679 | if (!d->isIndexValid(index) || index.parent() != d->rootTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2680 | || (!d->hasSpans() && isIndexHidden(index)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2681 | return QRect(); never executed: return QRect(); | 0 |
2682 | | - |
2683 | d->executePostedLayout(); | - |
2684 | | - |
2685 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2686 | QSpanCollection::Span span = d->span(index.row(), index.column()); | - |
2687 | return d->visualSpanRect(span); never executed: return d->visualSpanRect(span); | 0 |
2688 | } | - |
2689 | | - |
2690 | int rowp = rowViewportPosition(index.row()); | - |
2691 | int rowh = rowHeight(index.row()); | - |
2692 | int colp = columnViewportPosition(index.column()); | - |
2693 | int colw = columnWidth(index.column()); | - |
2694 | | - |
2695 | const int i = showGrid() ? 1 : 0;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2696 | return QRect(colp, rowp, colw - i, rowh - i); never executed: return QRect(colp, rowp, colw - i, rowh - i); | 0 |
2697 | } | - |
2698 | | - |
2699 | | - |
2700 | | - |
2701 | | - |
2702 | | - |
2703 | | - |
2704 | | - |
2705 | void QTableView::scrollTo(const QModelIndex &index, ScrollHint hint) | - |
2706 | { | - |
2707 | Q_D(QTableView); | - |
2708 | | - |
2709 | | - |
2710 | if (!d->isIndexValid(index)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2711 | || (d->model->parent(index) != d->root)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2712 | || isRowHidden(index.row()) || isColumnHidden(index.column()))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2713 | return; never executed: return; | 0 |
2714 | | - |
2715 | QSpanCollection::Span span; | - |
2716 | if (d->hasSpans())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2717 | span = d->span(index.row(), index.column()); never executed: span = d->span(index.row(), index.column()); | 0 |
2718 | | - |
2719 | | - |
2720 | | - |
2721 | int viewportWidth = d->viewport->width(); | - |
2722 | int horizontalOffset = d->horizontalHeader->offset(); | - |
2723 | int horizontalPosition = d->horizontalHeader->sectionPosition(index.column()); | - |
2724 | int horizontalIndex = d->horizontalHeader->visualIndex(index.column()); | - |
2725 | int cellWidth = d->hasSpans()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2726 | ? d->columnSpanWidth(index.column(), span.width()) | - |
2727 | : d->horizontalHeader->sectionSize(index.column()); | - |
2728 | | - |
2729 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2730 | | - |
2731 | bool positionAtLeft = (horizontalPosition - horizontalOffset < 0); | - |
2732 | bool positionAtRight = (horizontalPosition - horizontalOffset + cellWidth > viewportWidth); | - |
2733 | | - |
2734 | if (hint == PositionAtCenter || positionAtRight) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2735 | int w = (hint == PositionAtCenter ? viewportWidth / 2 : viewportWidth);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2736 | int x = cellWidth; | - |
2737 | while (horizontalIndex > 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2738 | x += columnWidth(d->horizontalHeader->logicalIndex(horizontalIndex-1)); | - |
2739 | if (x > w)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2740 | break; never executed: break; | 0 |
2741 | --horizontalIndex; | - |
2742 | } never executed: end of block | 0 |
2743 | } never executed: end of block | 0 |
2744 | | - |
2745 | if (positionAtRight || hint == PositionAtCenter || positionAtLeft) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2746 | int hiddenSections = 0; | - |
2747 | if (d->horizontalHeader->sectionsHidden()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2748 | for (int s = horizontalIndex - 1; s >= 0; --s) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2749 | int column = d->horizontalHeader->logicalIndex(s); | - |
2750 | if (d->horizontalHeader->isSectionHidden(column))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2751 | ++hiddenSections; never executed: ++hiddenSections; | 0 |
2752 | } never executed: end of block | 0 |
2753 | } never executed: end of block | 0 |
2754 | horizontalScrollBar()->setValue(horizontalIndex - hiddenSections); | - |
2755 | } never executed: end of block | 0 |
2756 | | - |
2757 | } else { never executed: end of block | 0 |
2758 | if (hint == PositionAtCenter) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2759 | horizontalScrollBar()->setValue(horizontalPosition - ((viewportWidth - cellWidth) / 2)); | - |
2760 | } else { never executed: end of block | 0 |
2761 | if (horizontalPosition - horizontalOffset < 0 || cellWidth > viewportWidth)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2762 | horizontalScrollBar()->setValue(horizontalPosition); never executed: horizontalScrollBar()->setValue(horizontalPosition); | 0 |
2763 | else if (horizontalPosition - horizontalOffset + cellWidth > viewportWidth)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2764 | horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth); never executed: horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth); | 0 |
2765 | } never executed: end of block | 0 |
2766 | } | - |
2767 | | - |
2768 | | - |
2769 | | - |
2770 | int viewportHeight = d->viewport->height(); | - |
2771 | int verticalOffset = d->verticalHeader->offset(); | - |
2772 | int verticalPosition = d->verticalHeader->sectionPosition(index.row()); | - |
2773 | int verticalIndex = d->verticalHeader->visualIndex(index.row()); | - |
2774 | int cellHeight = d->hasSpans()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2775 | ? d->rowSpanHeight(index.row(), span.height()) | - |
2776 | : d->verticalHeader->sectionSize(index.row()); | - |
2777 | | - |
2778 | if (verticalPosition - verticalOffset < 0 || cellHeight > viewportHeight) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2779 | if (hint == EnsureVisible)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2780 | hint = PositionAtTop; never executed: hint = PositionAtTop; | 0 |
2781 | } else if (verticalPosition - verticalOffset + cellHeight > viewportHeight) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2782 | if (hint == EnsureVisible)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2783 | hint = PositionAtBottom; never executed: hint = PositionAtBottom; | 0 |
2784 | } never executed: end of block | 0 |
2785 | | - |
2786 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2787 | | - |
2788 | if (hint == PositionAtBottom || hint == PositionAtCenter) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2789 | int h = (hint == PositionAtCenter ? viewportHeight / 2 : viewportHeight);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2790 | int y = cellHeight; | - |
2791 | while (verticalIndex > 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2792 | int row = d->verticalHeader->logicalIndex(verticalIndex - 1); | - |
2793 | y += d->verticalHeader->sectionSize(row); | - |
2794 | if (y > h)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2795 | break; never executed: break; | 0 |
2796 | --verticalIndex; | - |
2797 | } never executed: end of block | 0 |
2798 | } never executed: end of block | 0 |
2799 | | - |
2800 | if (hint == PositionAtBottom || hint == PositionAtCenter || hint == PositionAtTop) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2801 | int hiddenSections = 0; | - |
2802 | if (d->verticalHeader->sectionsHidden()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2803 | for (int s = verticalIndex - 1; s >= 0; --s) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2804 | int row = d->verticalHeader->logicalIndex(s); | - |
2805 | if (d->verticalHeader->isSectionHidden(row))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2806 | ++hiddenSections; never executed: ++hiddenSections; | 0 |
2807 | } never executed: end of block | 0 |
2808 | } never executed: end of block | 0 |
2809 | verticalScrollBar()->setValue(verticalIndex - hiddenSections); | - |
2810 | } never executed: end of block | 0 |
2811 | | - |
2812 | } else { never executed: end of block | 0 |
2813 | if (hint == PositionAtTop) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2814 | verticalScrollBar()->setValue(verticalPosition); | - |
2815 | } else if (hint == PositionAtBottom) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2816 | verticalScrollBar()->setValue(verticalPosition - viewportHeight + cellHeight); | - |
2817 | } else if (hint == PositionAtCenter) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2818 | verticalScrollBar()->setValue(verticalPosition - ((viewportHeight - cellHeight) / 2)); | - |
2819 | } never executed: end of block | 0 |
2820 | } never executed: end of block | 0 |
2821 | | - |
2822 | update(index); | - |
2823 | } never executed: end of block | 0 |
2824 | | - |
2825 | | - |
2826 | | - |
2827 | | - |
2828 | | - |
2829 | | - |
2830 | | - |
2831 | | - |
2832 | void QTableView::rowResized(int row, int, int) | - |
2833 | { | - |
2834 | Q_D(QTableView); | - |
2835 | d->rowsToUpdate.append(row); | - |
2836 | if (d->rowResizeTimerID == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2837 | d->rowResizeTimerID = startTimer(0); never executed: d->rowResizeTimerID = startTimer(0); | 0 |
2838 | } never executed: end of block | 0 |
2839 | | - |
2840 | | - |
2841 | | - |
2842 | | - |
2843 | | - |
2844 | | - |
2845 | | - |
2846 | | - |
2847 | void QTableView::columnResized(int column, int, int) | - |
2848 | { | - |
2849 | Q_D(QTableView); | - |
2850 | d->columnsToUpdate.append(column); | - |
2851 | if (d->columnResizeTimerID == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2852 | d->columnResizeTimerID = startTimer(0); never executed: d->columnResizeTimerID = startTimer(0); | 0 |
2853 | } never executed: end of block | 0 |
2854 | | - |
2855 | | - |
2856 | | - |
2857 | | - |
2858 | void QTableView::timerEvent(QTimerEvent *event) | - |
2859 | { | - |
2860 | Q_D(QTableView); | - |
2861 | | - |
2862 | if (event->timerId() == d->columnResizeTimerID) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2863 | updateGeometries(); | - |
2864 | killTimer(d->columnResizeTimerID); | - |
2865 | d->columnResizeTimerID = 0; | - |
2866 | | - |
2867 | QRect rect; | - |
2868 | int viewportHeight = d->viewport->height(); | - |
2869 | int viewportWidth = d->viewport->width(); | - |
2870 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2871 | rect = QRect(0, 0, viewportWidth, viewportHeight); | - |
2872 | } else { never executed: end of block | 0 |
2873 | for (int i = d->columnsToUpdate.size()-1; i >= 0; --i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2874 | int column = d->columnsToUpdate.at(i); | - |
2875 | int x = columnViewportPosition(column); | - |
2876 | if (isRightToLeft())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2877 | rect |= QRect(0, 0, x + columnWidth(column), viewportHeight); never executed: rect |= QRect(0, 0, x + columnWidth(column), viewportHeight); | 0 |
2878 | else | - |
2879 | rect |= QRect(x, 0, viewportWidth - x, viewportHeight); never executed: rect |= QRect(x, 0, viewportWidth - x, viewportHeight); | 0 |
2880 | } | - |
2881 | } never executed: end of block | 0 |
2882 | | - |
2883 | d->viewport->update(rect.normalized()); | - |
2884 | d->columnsToUpdate.clear(); | - |
2885 | } never executed: end of block | 0 |
2886 | | - |
2887 | if (event->timerId() == d->rowResizeTimerID) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2888 | updateGeometries(); | - |
2889 | killTimer(d->rowResizeTimerID); | - |
2890 | d->rowResizeTimerID = 0; | - |
2891 | | - |
2892 | int viewportHeight = d->viewport->height(); | - |
2893 | int viewportWidth = d->viewport->width(); | - |
2894 | int top; | - |
2895 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2896 | top = 0; | - |
2897 | } else { never executed: end of block | 0 |
2898 | top = viewportHeight; | - |
2899 | for (int i = d->rowsToUpdate.size()-1; i >= 0; --i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2900 | int y = rowViewportPosition(d->rowsToUpdate.at(i)); | - |
2901 | top = qMin(top, y); | - |
2902 | } never executed: end of block | 0 |
2903 | } never executed: end of block | 0 |
2904 | | - |
2905 | d->viewport->update(QRect(0, top, viewportWidth, viewportHeight - top)); | - |
2906 | d->rowsToUpdate.clear(); | - |
2907 | } never executed: end of block | 0 |
2908 | | - |
2909 | QAbstractItemView::timerEvent(event); | - |
2910 | } never executed: end of block | 0 |
2911 | | - |
2912 | | - |
2913 | | - |
2914 | | - |
2915 | | - |
2916 | | - |
2917 | | - |
2918 | | - |
2919 | void QTableView::rowMoved(int, int oldIndex, int newIndex) | - |
2920 | { | - |
2921 | Q_D(QTableView); | - |
2922 | | - |
2923 | updateGeometries(); | - |
2924 | int logicalOldIndex = d->verticalHeader->logicalIndex(oldIndex); | - |
2925 | int logicalNewIndex = d->verticalHeader->logicalIndex(newIndex); | - |
2926 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2927 | d->viewport->update(); | - |
2928 | } else { never executed: end of block | 0 |
2929 | int oldTop = rowViewportPosition(logicalOldIndex); | - |
2930 | int newTop = rowViewportPosition(logicalNewIndex); | - |
2931 | int oldBottom = oldTop + rowHeight(logicalOldIndex); | - |
2932 | int newBottom = newTop + rowHeight(logicalNewIndex); | - |
2933 | int top = qMin(oldTop, newTop); | - |
2934 | int bottom = qMax(oldBottom, newBottom); | - |
2935 | int height = bottom - top; | - |
2936 | d->viewport->update(0, top, d->viewport->width(), height); | - |
2937 | } never executed: end of block | 0 |
2938 | } | - |
2939 | | - |
2940 | | - |
2941 | | - |
2942 | | - |
2943 | | - |
2944 | | - |
2945 | | - |
2946 | | - |
2947 | void QTableView::columnMoved(int, int oldIndex, int newIndex) | - |
2948 | { | - |
2949 | Q_D(QTableView); | - |
2950 | | - |
2951 | updateGeometries(); | - |
2952 | int logicalOldIndex = d->horizontalHeader->logicalIndex(oldIndex); | - |
2953 | int logicalNewIndex = d->horizontalHeader->logicalIndex(newIndex); | - |
2954 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2955 | d->viewport->update(); | - |
2956 | } else { never executed: end of block | 0 |
2957 | int oldLeft = columnViewportPosition(logicalOldIndex); | - |
2958 | int newLeft = columnViewportPosition(logicalNewIndex); | - |
2959 | int oldRight = oldLeft + columnWidth(logicalOldIndex); | - |
2960 | int newRight = newLeft + columnWidth(logicalNewIndex); | - |
2961 | int left = qMin(oldLeft, newLeft); | - |
2962 | int right = qMax(oldRight, newRight); | - |
2963 | int width = right - left; | - |
2964 | d->viewport->update(left, 0, width, d->viewport->height()); | - |
2965 | } never executed: end of block | 0 |
2966 | } | - |
2967 | | - |
2968 | | - |
2969 | | - |
2970 | | - |
2971 | | - |
2972 | | - |
2973 | | - |
2974 | void QTableView::selectRow(int row) | - |
2975 | { | - |
2976 | Q_D(QTableView); | - |
2977 | d->selectRow(row, true); | - |
2978 | } never executed: end of block | 0 |
2979 | | - |
2980 | | - |
2981 | | - |
2982 | | - |
2983 | | - |
2984 | | - |
2985 | | - |
2986 | void QTableView::selectColumn(int column) | - |
2987 | { | - |
2988 | Q_D(QTableView); | - |
2989 | d->selectColumn(column, true); | - |
2990 | } never executed: end of block | 0 |
2991 | | - |
2992 | | - |
2993 | | - |
2994 | | - |
2995 | | - |
2996 | | - |
2997 | void QTableView::hideRow(int row) | - |
2998 | { | - |
2999 | Q_D(QTableView); | - |
3000 | d->verticalHeader->hideSection(row); | - |
3001 | } never executed: end of block | 0 |
3002 | | - |
3003 | | - |
3004 | | - |
3005 | | - |
3006 | | - |
3007 | | - |
3008 | void QTableView::hideColumn(int column) | - |
3009 | { | - |
3010 | Q_D(QTableView); | - |
3011 | d->horizontalHeader->hideSection(column); | - |
3012 | } never executed: end of block | 0 |
3013 | | - |
3014 | | - |
3015 | | - |
3016 | | - |
3017 | | - |
3018 | | - |
3019 | void QTableView::showRow(int row) | - |
3020 | { | - |
3021 | Q_D(QTableView); | - |
3022 | d->verticalHeader->showSection(row); | - |
3023 | } never executed: end of block | 0 |
3024 | | - |
3025 | | - |
3026 | | - |
3027 | | - |
3028 | | - |
3029 | | - |
3030 | void QTableView::showColumn(int column) | - |
3031 | { | - |
3032 | Q_D(QTableView); | - |
3033 | d->horizontalHeader->showSection(column); | - |
3034 | } never executed: end of block | 0 |
3035 | | - |
3036 | | - |
3037 | | - |
3038 | | - |
3039 | | - |
3040 | | - |
3041 | | - |
3042 | void QTableView::resizeRowToContents(int row) | - |
3043 | { | - |
3044 | Q_D(QTableView); | - |
3045 | int content = sizeHintForRow(row); | - |
3046 | int header = d->verticalHeader->sectionSizeHint(row); | - |
3047 | d->verticalHeader->resizeSection(row, qMax(content, header)); | - |
3048 | } never executed: end of block | 0 |
3049 | | - |
3050 | | - |
3051 | | - |
3052 | | - |
3053 | | - |
3054 | | - |
3055 | | - |
3056 | void QTableView::resizeRowsToContents() | - |
3057 | { | - |
3058 | Q_D(QTableView); | - |
3059 | d->verticalHeader->resizeSections(QHeaderView::ResizeToContents); | - |
3060 | } never executed: end of block | 0 |
3061 | | - |
3062 | | - |
3063 | | - |
3064 | | - |
3065 | | - |
3066 | | - |
3067 | | - |
3068 | | - |
3069 | | - |
3070 | | - |
3071 | void QTableView::resizeColumnToContents(int column) | - |
3072 | { | - |
3073 | Q_D(QTableView); | - |
3074 | int content = sizeHintForColumn(column); | - |
3075 | int header = d->horizontalHeader->sectionSizeHint(column); | - |
3076 | d->horizontalHeader->resizeSection(column, qMax(content, header)); | - |
3077 | } never executed: end of block | 0 |
3078 | | - |
3079 | | - |
3080 | | - |
3081 | | - |
3082 | | - |
3083 | | - |
3084 | | - |
3085 | void QTableView::resizeColumnsToContents() | - |
3086 | { | - |
3087 | Q_D(QTableView); | - |
3088 | d->horizontalHeader->resizeSections(QHeaderView::ResizeToContents); | - |
3089 | } never executed: end of block | 0 |
3090 | | - |
3091 | | - |
3092 | | - |
3093 | | - |
3094 | | - |
3095 | | - |
3096 | | - |
3097 | void QTableView::sortByColumn(int column) | - |
3098 | { | - |
3099 | Q_D(QTableView); | - |
3100 | if (column == -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3101 | return; never executed: return; | 0 |
3102 | d->model->sort(column, d->horizontalHeader->sortIndicatorOrder()); | - |
3103 | } never executed: end of block | 0 |
3104 | | - |
3105 | | - |
3106 | | - |
3107 | | - |
3108 | | - |
3109 | | - |
3110 | | - |
3111 | | - |
3112 | void QTableView::sortByColumn(int column, Qt::SortOrder order) | - |
3113 | { | - |
3114 | Q_D(QTableView); | - |
3115 | d->horizontalHeader->setSortIndicator(column, order); | - |
3116 | sortByColumn(column); | - |
3117 | } never executed: end of block | 0 |
3118 | | - |
3119 | | - |
3120 | | - |
3121 | | - |
3122 | void QTableView::verticalScrollbarAction(int action) | - |
3123 | { | - |
3124 | QAbstractItemView::verticalScrollbarAction(action); | - |
3125 | } never executed: end of block | 0 |
3126 | | - |
3127 | | - |
3128 | | - |
3129 | | - |
3130 | void QTableView::horizontalScrollbarAction(int action) | - |
3131 | { | - |
3132 | QAbstractItemView::horizontalScrollbarAction(action); | - |
3133 | } never executed: end of block | 0 |
3134 | | - |
3135 | | - |
3136 | | - |
3137 | | - |
3138 | bool QTableView::isIndexHidden(const QModelIndex &index) const | - |
3139 | { | - |
3140 | Q_D(const QTableView); | - |
3141 | Q_ASSERT(d->isIndexValid(index)); | - |
3142 | if (isRowHidden(index.row()) || isColumnHidden(index.column()))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3143 | return true; never executed: return true; | 0 |
3144 | if (d->hasSpans()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3145 | QSpanCollection::Span span = d->span(index.row(), index.column()); | - |
3146 | return !((span.top() == index.row()) && (span.left() == index.column())); never executed: return !((span.top() == index.row()) && (span.left() == index.column())); | 0 |
3147 | } | - |
3148 | return false; never executed: return false; | 0 |
3149 | } | - |
3150 | | - |
3151 | | - |
3152 | | - |
3153 | | - |
3154 | | - |
3155 | | - |
3156 | | - |
3157 | | - |
3158 | | - |
3159 | | - |
3160 | void QTableView::setSpan(int row, int column, int rowSpan, int columnSpan) | - |
3161 | { | - |
3162 | Q_D(QTableView); | - |
3163 | if (row < 0 || column < 0 || rowSpan < 0 || columnSpan < 0)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3164 | return; never executed: return; | 0 |
3165 | d->setSpan(row, column, rowSpan, columnSpan); | - |
3166 | d->viewport->update(); | - |
3167 | } never executed: end of block | 0 |
3168 | | - |
3169 | | - |
3170 | | - |
3171 | | - |
3172 | | - |
3173 | | - |
3174 | | - |
3175 | | - |
3176 | | - |
3177 | int QTableView::rowSpan(int row, int column) const | - |
3178 | { | - |
3179 | Q_D(const QTableView); | - |
3180 | return d->rowSpan(row, column); never executed: return d->rowSpan(row, column); | 0 |
3181 | } | - |
3182 | | - |
3183 | | - |
3184 | | - |
3185 | | - |
3186 | | - |
3187 | | - |
3188 | | - |
3189 | | - |
3190 | | - |
3191 | int QTableView::columnSpan(int row, int column) const | - |
3192 | { | - |
3193 | Q_D(const QTableView); | - |
3194 | return d->columnSpan(row, column); never executed: return d->columnSpan(row, column); | 0 |
3195 | } | - |
3196 | | - |
3197 | | - |
3198 | | - |
3199 | | - |
3200 | | - |
3201 | | - |
3202 | | - |
3203 | | - |
3204 | | - |
3205 | void QTableView::clearSpans() | - |
3206 | { | - |
3207 | Q_D(QTableView); | - |
3208 | d->spans.clear(); | - |
3209 | d->viewport->update(); | - |
3210 | } never executed: end of block | 0 |
3211 | | - |
3212 | void QTableViewPrivate::_q_selectRow(int row) | - |
3213 | { | - |
3214 | selectRow(row, false); | - |
3215 | } never executed: end of block | 0 |
3216 | | - |
3217 | void QTableViewPrivate::_q_selectColumn(int column) | - |
3218 | { | - |
3219 | selectColumn(column, false); | - |
3220 | } never executed: end of block | 0 |
3221 | | - |
3222 | void QTableViewPrivate::selectRow(int row, bool anchor) | - |
3223 | { | - |
3224 | Q_Q(QTableView); | - |
3225 | | - |
3226 | if (q->selectionBehavior() == QTableView::SelectColumnsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
3227 | || (q->selectionMode() == QTableView::SingleSelectionTRUE | never evaluated | FALSE | never evaluated |
| 0 |
3228 | && q->selectionBehavior() == QTableView::SelectItems))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3229 | return; never executed: return; | 0 |
3230 | | - |
3231 | if (row >= 0 && row < model->rowCount(root)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3232 | int column = horizontalHeader->logicalIndexAt(q->isRightToLeft() ? viewport->width() : 0); | - |
3233 | QModelIndex index = model->index(row, column, root); | - |
3234 | QItemSelectionModel::SelectionFlags command = q->selectionCommand(index); | - |
3235 | selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate); | - |
3236 | if ((anchor && !(command & QItemSelectionModel::Current))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3237 | || (q->selectionMode() == QTableView::SingleSelection))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3238 | rowSectionAnchor = row; never executed: rowSectionAnchor = row; | 0 |
3239 | | - |
3240 | if (q->selectionMode() != QTableView::SingleSelectionTRUE | never evaluated | FALSE | never evaluated |
| 0 |
3241 | && command.testFlag(QItemSelectionModel::Toggle)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3242 | if (anchor)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3243 | ctrlDragSelectionFlag = verticalHeader->selectionModel()->selectedRows().contains(index) never executed: ctrlDragSelectionFlag = verticalHeader->selectionModel()->selectedRows().contains(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3244 | ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; never executed: ctrlDragSelectionFlag = verticalHeader->selectionModel()->selectedRows().contains(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; | 0 |
3245 | command &= ~QItemSelectionModel::Toggle; | - |
3246 | command |= ctrlDragSelectionFlag; | - |
3247 | if (!anchor)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3248 | command |= QItemSelectionModel::Current; never executed: command |= QItemSelectionModel::Current; | 0 |
3249 | } never executed: end of block | 0 |
3250 | | - |
3251 | QModelIndex upper = model->index(qMin(rowSectionAnchor, row), column, root); | - |
3252 | QModelIndex lower = model->index(qMax(rowSectionAnchor, row), column, root); | - |
3253 | if ((verticalHeader->sectionsMoved() && upper.row() != lower.row())) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3254 | q->setSelection(q->visualRect(upper) | q->visualRect(lower), command | QItemSelectionModel::Rows); | - |
3255 | } else { never executed: end of block | 0 |
3256 | selectionModel->select(QItemSelection(upper, lower), command | QItemSelectionModel::Rows); | - |
3257 | } never executed: end of block | 0 |
3258 | } | - |
3259 | } never executed: end of block | 0 |
3260 | | - |
3261 | void QTableViewPrivate::selectColumn(int column, bool anchor) | - |
3262 | { | - |
3263 | Q_Q(QTableView); | - |
3264 | | - |
3265 | if (q->selectionBehavior() == QTableView::SelectRowsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
3266 | || (q->selectionMode() == QTableView::SingleSelectionTRUE | never evaluated | FALSE | never evaluated |
| 0 |
3267 | && q->selectionBehavior() == QTableView::SelectItems))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3268 | return; never executed: return; | 0 |
3269 | | - |
3270 | if (column >= 0 && column < model->columnCount(root)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3271 | int row = verticalHeader->logicalIndexAt(0); | - |
3272 | QModelIndex index = model->index(row, column, root); | - |
3273 | QItemSelectionModel::SelectionFlags command = q->selectionCommand(index); | - |
3274 | selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate); | - |
3275 | if ((anchor && !(command & QItemSelectionModel::Current))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3276 | || (q->selectionMode() == QTableView::SingleSelection))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3277 | columnSectionAnchor = column; never executed: columnSectionAnchor = column; | 0 |
3278 | | - |
3279 | if (q->selectionMode() != QTableView::SingleSelectionTRUE | never evaluated | FALSE | never evaluated |
| 0 |
3280 | && command.testFlag(QItemSelectionModel::Toggle)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3281 | if (anchor)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3282 | ctrlDragSelectionFlag = horizontalHeader->selectionModel()->selectedColumns().contains(index) never executed: ctrlDragSelectionFlag = horizontalHeader->selectionModel()->selectedColumns().contains(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3283 | ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; never executed: ctrlDragSelectionFlag = horizontalHeader->selectionModel()->selectedColumns().contains(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; | 0 |
3284 | command &= ~QItemSelectionModel::Toggle; | - |
3285 | command |= ctrlDragSelectionFlag; | - |
3286 | if (!anchor)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3287 | command |= QItemSelectionModel::Current; never executed: command |= QItemSelectionModel::Current; | 0 |
3288 | } never executed: end of block | 0 |
3289 | | - |
3290 | QModelIndex left = model->index(row, qMin(columnSectionAnchor, column), root); | - |
3291 | QModelIndex right = model->index(row, qMax(columnSectionAnchor, column), root); | - |
3292 | if ((horizontalHeader->sectionsMoved() && left.column() != right.column())) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3293 | q->setSelection(q->visualRect(left) | q->visualRect(right), command | QItemSelectionModel::Columns); | - |
3294 | } else { never executed: end of block | 0 |
3295 | selectionModel->select(QItemSelection(left, right), command | QItemSelectionModel::Columns); | - |
3296 | } never executed: end of block | 0 |
3297 | } | - |
3298 | } never executed: end of block | 0 |
3299 | | - |
3300 | | - |
3301 | | - |
3302 | | - |
3303 | void QTableView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) | - |
3304 | { | - |
3305 | #ifndef QT_NO_ACCESSIBILITY | - |
3306 | if (QAccessible::isActive()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3307 | if (current.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3308 | Q_D(QTableView); | - |
3309 | int entry = d->accessibleTable2Index(current); | - |
3310 | QAccessibleEvent event(this, QAccessible::Focus); | - |
3311 | event.setChild(entry); | - |
3312 | QAccessible::updateAccessibility(&event); | - |
3313 | } never executed: end of block | 0 |
3314 | } never executed: end of block | 0 |
3315 | #endif | - |
3316 | QAbstractItemView::currentChanged(current, previous); | - |
3317 | } never executed: end of block | 0 |
3318 | | - |
3319 | | - |
3320 | | - |
3321 | | - |
3322 | void QTableView::selectionChanged(const QItemSelection &selected, | - |
3323 | const QItemSelection &deselected) | - |
3324 | { | - |
3325 | Q_D(QTableView); | - |
3326 | Q_UNUSED(d) | - |
3327 | #ifndef QT_NO_ACCESSIBILITY | - |
3328 | if (QAccessible::isActive()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3329 | | - |
3330 | QModelIndex sel = selected.indexes().value(0); | - |
3331 | if (sel.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3332 | int entry = d->accessibleTable2Index(sel); | - |
3333 | QAccessibleEvent event(this, QAccessible::SelectionAdd); | - |
3334 | event.setChild(entry); | - |
3335 | QAccessible::updateAccessibility(&event); | - |
3336 | } never executed: end of block | 0 |
3337 | QModelIndex desel = deselected.indexes().value(0); | - |
3338 | if (desel.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3339 | int entry = d->accessibleTable2Index(desel); | - |
3340 | QAccessibleEvent event(this, QAccessible::SelectionRemove); | - |
3341 | event.setChild(entry); | - |
3342 | QAccessible::updateAccessibility(&event); | - |
3343 | } never executed: end of block | 0 |
3344 | } never executed: end of block | 0 |
3345 | #endif | - |
3346 | QAbstractItemView::selectionChanged(selected, deselected); | - |
3347 | } never executed: end of block | 0 |
3348 | | - |
3349 | int QTableView::visualIndex(const QModelIndex &index) const | - |
3350 | { | - |
3351 | return index.row(); never executed: return index.row(); | 0 |
3352 | } | - |
3353 | | - |
3354 | QT_END_NAMESPACE | - |
3355 | | - |
3356 | #include "qtableview.moc" | - |
3357 | | - |
3358 | #include "moc_qtableview.cpp" | - |
3359 | | - |
3360 | #endif // QT_NO_TABLEVIEW | - |
| | |