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 | #include "qtreeview.h" | - |
34 | | - |
35 | #ifndef QT_NO_TREEVIEW | - |
36 | #include <qheaderview.h> | - |
37 | #include <qitemdelegate.h> | - |
38 | #include <qapplication.h> | - |
39 | #include <qscrollbar.h> | - |
40 | #include <qpainter.h> | - |
41 | #include <qstack.h> | - |
42 | #include <qstyle.h> | - |
43 | #include <qstyleoption.h> | - |
44 | #include <qevent.h> | - |
45 | #include <qpen.h> | - |
46 | #include <qdebug.h> | - |
47 | #include <QMetaMethod> | - |
48 | #ifndef QT_NO_ACCESSIBILITY | - |
49 | #include <qaccessible.h> | - |
50 | #endif | - |
51 | | - |
52 | #include <private/qtreeview_p.h> | - |
53 | #include <private/qheaderview_p.h> | - |
54 | | - |
55 | #include <algorithm> | - |
56 | | - |
57 | QT_BEGIN_NAMESPACE | - |
58 | | - |
59 | | - |
60 | | - |
61 | | - |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | | - |
67 | | - |
68 | | - |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | | - |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | | - |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
148 | | - |
149 | | - |
150 | | - |
151 | | - |
152 | | - |
153 | | - |
154 | | - |
155 | | - |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | | - |
178 | | - |
179 | | - |
180 | | - |
181 | | - |
182 | | - |
183 | | - |
184 | | - |
185 | | - |
186 | QTreeView::QTreeView(QWidget *parent) | - |
187 | : QAbstractItemView(*new QTreeViewPrivate, parent) | - |
188 | { | - |
189 | Q_D(QTreeView); | - |
190 | d->initialize(); | - |
191 | } never executed: end of block | 0 |
192 | | - |
193 | | - |
194 | | - |
195 | | - |
196 | QTreeView::QTreeView(QTreeViewPrivate &dd, QWidget *parent) | - |
197 | : QAbstractItemView(dd, parent) | - |
198 | { | - |
199 | Q_D(QTreeView); | - |
200 | d->initialize(); | - |
201 | } never executed: end of block | 0 |
202 | | - |
203 | | - |
204 | | - |
205 | | - |
206 | QTreeView::~QTreeView() | - |
207 | { | - |
208 | } | - |
209 | | - |
210 | | - |
211 | | - |
212 | | - |
213 | void QTreeView::setModel(QAbstractItemModel *model) | - |
214 | { | - |
215 | Q_D(QTreeView); | - |
216 | if (model == d->model)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
217 | return; never executed: return; | 0 |
218 | if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
219 | disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), | - |
220 | this, SLOT(rowsRemoved(QModelIndex,int,int))); | - |
221 | | - |
222 | disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_modelAboutToBeReset())); | - |
223 | } never executed: end of block | 0 |
224 | | - |
225 | if (d->selectionModel) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
226 | disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), | - |
227 | d->model, SLOT(submit())); | - |
228 | disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), | - |
229 | this, SLOT(rowsRemoved(QModelIndex,int,int))); | - |
230 | disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_modelAboutToBeReset())); | - |
231 | } never executed: end of block | 0 |
232 | d->viewItems.clear(); | - |
233 | d->expandedIndexes.clear(); | - |
234 | d->hiddenIndexes.clear(); | - |
235 | d->header->setModel(model); | - |
236 | QAbstractItemView::setModel(model); | - |
237 | | - |
238 | | - |
239 | disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), | - |
240 | this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); | - |
241 | | - |
242 | disconnect(d->model, SIGNAL(layoutChanged()), | - |
243 | d->header, SLOT(_q_layoutChanged())); | - |
244 | | - |
245 | connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), | - |
246 | this, SLOT(rowsRemoved(QModelIndex,int,int))); | - |
247 | | - |
248 | connect(d->model, SIGNAL(modelAboutToBeReset()), SLOT(_q_modelAboutToBeReset())); | - |
249 | | - |
250 | if (d->sortingEnabled)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
251 | d->_q_sortIndicatorChanged(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); never executed: d->_q_sortIndicatorChanged(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); | 0 |
252 | } never executed: end of block | 0 |
253 | | - |
254 | | - |
255 | | - |
256 | | - |
257 | void QTreeView::setRootIndex(const QModelIndex &index) | - |
258 | { | - |
259 | Q_D(QTreeView); | - |
260 | d->header->setRootIndex(index); | - |
261 | QAbstractItemView::setRootIndex(index); | - |
262 | } never executed: end of block | 0 |
263 | | - |
264 | | - |
265 | | - |
266 | | - |
267 | void QTreeView::setSelectionModel(QItemSelectionModel *selectionModel) | - |
268 | { | - |
269 | Q_D(QTreeView); | - |
270 | Q_ASSERT(selectionModel); | - |
271 | if (d->selectionModel) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
272 | | - |
273 | disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), | - |
274 | d->model, SLOT(submit())); | - |
275 | } never executed: end of block | 0 |
276 | | - |
277 | d->header->setSelectionModel(selectionModel); | - |
278 | QAbstractItemView::setSelectionModel(selectionModel); | - |
279 | | - |
280 | if (d->selectionModel) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
281 | | - |
282 | connect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), | - |
283 | d->model, SLOT(submit())); | - |
284 | } never executed: end of block | 0 |
285 | } never executed: end of block | 0 |
286 | | - |
287 | | - |
288 | | - |
289 | | - |
290 | | - |
291 | | - |
292 | QHeaderView *QTreeView::header() const | - |
293 | { | - |
294 | Q_D(const QTreeView); | - |
295 | return d->header; never executed: return d->header; | 0 |
296 | } | - |
297 | | - |
298 | | - |
299 | | - |
300 | | - |
301 | | - |
302 | | - |
303 | | - |
304 | | - |
305 | | - |
306 | void QTreeView::setHeader(QHeaderView *header) | - |
307 | { | - |
308 | Q_D(QTreeView); | - |
309 | if (header == d->header || !header)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
310 | return; never executed: return; | 0 |
311 | if (d->header && d->header->parent() == this)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
312 | delete d->header; never executed: delete d->header; | 0 |
313 | d->header = header; | - |
314 | d->header->setParent(this); | - |
315 | d->header->d_func()->setAllowUserMoveOfSection0(false); | - |
316 | | - |
317 | if (!d->header->model()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
318 | d->header->setModel(d->model); | - |
319 | if (d->selectionModel)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
320 | d->header->setSelectionModel(d->selectionModel); never executed: d->header->setSelectionModel(d->selectionModel); | 0 |
321 | } never executed: end of block | 0 |
322 | | - |
323 | connect(d->header, SIGNAL(sectionResized(int,int,int)), | - |
324 | this, SLOT(columnResized(int,int,int))); | - |
325 | connect(d->header, SIGNAL(sectionMoved(int,int,int)), | - |
326 | this, SLOT(columnMoved())); | - |
327 | connect(d->header, SIGNAL(sectionCountChanged(int,int)), | - |
328 | this, SLOT(columnCountChanged(int,int))); | - |
329 | connect(d->header, SIGNAL(sectionHandleDoubleClicked(int)), | - |
330 | this, SLOT(resizeColumnToContents(int))); | - |
331 | connect(d->header, SIGNAL(geometriesChanged()), | - |
332 | this, SLOT(updateGeometries())); | - |
333 | | - |
334 | setSortingEnabled(d->sortingEnabled); | - |
335 | d->updateGeometry(); | - |
336 | } never executed: end of block | 0 |
337 | | - |
338 | | - |
339 | | - |
340 | | - |
341 | | - |
342 | | - |
343 | | - |
344 | | - |
345 | | - |
346 | | - |
347 | | - |
348 | | - |
349 | int QTreeView::autoExpandDelay() const | - |
350 | { | - |
351 | Q_D(const QTreeView); | - |
352 | return d->autoExpandDelay; never executed: return d->autoExpandDelay; | 0 |
353 | } | - |
354 | | - |
355 | void QTreeView::setAutoExpandDelay(int delay) | - |
356 | { | - |
357 | Q_D(QTreeView); | - |
358 | d->autoExpandDelay = delay; | - |
359 | } never executed: end of block | 0 |
360 | | - |
361 | | - |
362 | | - |
363 | | - |
364 | | - |
365 | | - |
366 | | - |
367 | | - |
368 | | - |
369 | | - |
370 | | - |
371 | | - |
372 | | - |
373 | | - |
374 | int QTreeView::indentation() const | - |
375 | { | - |
376 | Q_D(const QTreeView); | - |
377 | return d->indent; never executed: return d->indent; | 0 |
378 | } | - |
379 | | - |
380 | void QTreeView::setIndentation(int i) | - |
381 | { | - |
382 | Q_D(QTreeView); | - |
383 | if (!d->customIndent || (i != d->indent)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
384 | d->indent = i; | - |
385 | d->customIndent = true; | - |
386 | d->viewport->update(); | - |
387 | } never executed: end of block | 0 |
388 | } never executed: end of block | 0 |
389 | | - |
390 | void QTreeView::resetIndentation() | - |
391 | { | - |
392 | Q_D(QTreeView); | - |
393 | if (d->customIndent) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
394 | d->updateIndentationFromStyle(); | - |
395 | d->customIndent = false; | - |
396 | } never executed: end of block | 0 |
397 | } never executed: end of block | 0 |
398 | | - |
399 | | - |
400 | | - |
401 | | - |
402 | | - |
403 | | - |
404 | | - |
405 | | - |
406 | | - |
407 | | - |
408 | | - |
409 | | - |
410 | bool QTreeView::rootIsDecorated() const | - |
411 | { | - |
412 | Q_D(const QTreeView); | - |
413 | return d->rootDecoration; never executed: return d->rootDecoration; | 0 |
414 | } | - |
415 | | - |
416 | void QTreeView::setRootIsDecorated(bool show) | - |
417 | { | - |
418 | Q_D(QTreeView); | - |
419 | if (show != d->rootDecoration) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
420 | d->rootDecoration = show; | - |
421 | d->viewport->update(); | - |
422 | } never executed: end of block | 0 |
423 | } never executed: end of block | 0 |
424 | | - |
425 | | - |
426 | | - |
427 | | - |
428 | | - |
429 | | - |
430 | | - |
431 | | - |
432 | | - |
433 | | - |
434 | | - |
435 | | - |
436 | | - |
437 | | - |
438 | | - |
439 | | - |
440 | | - |
441 | bool QTreeView::uniformRowHeights() const | - |
442 | { | - |
443 | Q_D(const QTreeView); | - |
444 | return d->uniformRowHeights; never executed: return d->uniformRowHeights; | 0 |
445 | } | - |
446 | | - |
447 | void QTreeView::setUniformRowHeights(bool uniform) | - |
448 | { | - |
449 | Q_D(QTreeView); | - |
450 | d->uniformRowHeights = uniform; | - |
451 | } never executed: end of block | 0 |
452 | | - |
453 | | - |
454 | | - |
455 | | - |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | | - |
461 | | - |
462 | | - |
463 | bool QTreeView::itemsExpandable() const | - |
464 | { | - |
465 | Q_D(const QTreeView); | - |
466 | return d->itemsExpandable; never executed: return d->itemsExpandable; | 0 |
467 | } | - |
468 | | - |
469 | void QTreeView::setItemsExpandable(bool enable) | - |
470 | { | - |
471 | Q_D(QTreeView); | - |
472 | d->itemsExpandable = enable; | - |
473 | } never executed: end of block | 0 |
474 | | - |
475 | | - |
476 | | - |
477 | | - |
478 | | - |
479 | | - |
480 | | - |
481 | | - |
482 | | - |
483 | | - |
484 | | - |
485 | bool QTreeView::expandsOnDoubleClick() const | - |
486 | { | - |
487 | Q_D(const QTreeView); | - |
488 | return d->expandsOnDoubleClick; never executed: return d->expandsOnDoubleClick; | 0 |
489 | } | - |
490 | | - |
491 | void QTreeView::setExpandsOnDoubleClick(bool enable) | - |
492 | { | - |
493 | Q_D(QTreeView); | - |
494 | d->expandsOnDoubleClick = enable; | - |
495 | } never executed: end of block | 0 |
496 | | - |
497 | | - |
498 | | - |
499 | | - |
500 | int QTreeView::columnViewportPosition(int column) const | - |
501 | { | - |
502 | Q_D(const QTreeView); | - |
503 | return d->header->sectionViewportPosition(column); never executed: return d->header->sectionViewportPosition(column); | 0 |
504 | } | - |
505 | | - |
506 | | - |
507 | | - |
508 | | - |
509 | | - |
510 | | - |
511 | int QTreeView::columnWidth(int column) const | - |
512 | { | - |
513 | Q_D(const QTreeView); | - |
514 | return d->header->sectionSize(column); never executed: return d->header->sectionSize(column); | 0 |
515 | } | - |
516 | | - |
517 | | - |
518 | | - |
519 | | - |
520 | | - |
521 | | - |
522 | | - |
523 | | - |
524 | void QTreeView::setColumnWidth(int column, int width) | - |
525 | { | - |
526 | Q_D(QTreeView); | - |
527 | d->header->resizeSection(column, width); | - |
528 | } never executed: end of block | 0 |
529 | | - |
530 | | - |
531 | | - |
532 | | - |
533 | | - |
534 | int QTreeView::columnAt(int x) const | - |
535 | { | - |
536 | Q_D(const QTreeView); | - |
537 | return d->header->logicalIndexAt(x); never executed: return d->header->logicalIndexAt(x); | 0 |
538 | } | - |
539 | | - |
540 | | - |
541 | | - |
542 | | - |
543 | | - |
544 | | - |
545 | bool QTreeView::isColumnHidden(int column) const | - |
546 | { | - |
547 | Q_D(const QTreeView); | - |
548 | return d->header->isSectionHidden(column); never executed: return d->header->isSectionHidden(column); | 0 |
549 | } | - |
550 | | - |
551 | | - |
552 | | - |
553 | | - |
554 | | - |
555 | | - |
556 | void QTreeView::setColumnHidden(int column, bool hide) | - |
557 | { | - |
558 | Q_D(QTreeView); | - |
559 | if (column < 0 || column >= d->header->count())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
560 | return; never executed: return; | 0 |
561 | d->header->setSectionHidden(column, hide); | - |
562 | } never executed: end of block | 0 |
563 | | - |
564 | | - |
565 | | - |
566 | | - |
567 | | - |
568 | | - |
569 | | - |
570 | | - |
571 | | - |
572 | | - |
573 | | - |
574 | bool QTreeView::isHeaderHidden() const | - |
575 | { | - |
576 | Q_D(const QTreeView); | - |
577 | return d->header->isHidden(); never executed: return d->header->isHidden(); | 0 |
578 | } | - |
579 | | - |
580 | void QTreeView::setHeaderHidden(bool hide) | - |
581 | { | - |
582 | Q_D(QTreeView); | - |
583 | d->header->setHidden(hide); | - |
584 | } never executed: end of block | 0 |
585 | | - |
586 | | - |
587 | | - |
588 | | - |
589 | | - |
590 | | - |
591 | | - |
592 | bool QTreeView::isRowHidden(int row, const QModelIndex &parent) const | - |
593 | { | - |
594 | Q_D(const QTreeView); | - |
595 | if (!d->model)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
596 | return false; never executed: return false; | 0 |
597 | return d->isRowHidden(d->model->index(row, 0, parent)); never executed: return d->isRowHidden(d->model->index(row, 0, parent)); | 0 |
598 | } | - |
599 | | - |
600 | | - |
601 | | - |
602 | | - |
603 | | - |
604 | | - |
605 | void QTreeView::setRowHidden(int row, const QModelIndex &parent, bool hide) | - |
606 | { | - |
607 | Q_D(QTreeView); | - |
608 | if (!d->model)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
609 | return; never executed: return; | 0 |
610 | QModelIndex index = d->model->index(row, 0, parent); | - |
611 | if (!index.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
612 | return; never executed: return; | 0 |
613 | | - |
614 | if (hide) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
615 | d->hiddenIndexes.insert(index); | - |
616 | } else if(d->isPersistent(index)) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
617 | d->hiddenIndexes.remove(index); | - |
618 | } never executed: end of block | 0 |
619 | | - |
620 | d->doDelayedItemsLayout(); | - |
621 | } never executed: end of block | 0 |
622 | | - |
623 | | - |
624 | | - |
625 | | - |
626 | | - |
627 | | - |
628 | | - |
629 | | - |
630 | | - |
631 | bool QTreeView::isFirstColumnSpanned(int row, const QModelIndex &parent) const | - |
632 | { | - |
633 | Q_D(const QTreeView); | - |
634 | if (d->spanningIndexes.isEmpty() || !d->model)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
635 | return false; never executed: return false; | 0 |
636 | QModelIndex index = d->model->index(row, 0, parent); | - |
637 | for (int i = 0; i < d->spanningIndexes.count(); ++i)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
638 | if (d->spanningIndexes.at(i) == index)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
639 | return true; never executed: return true; | 0 |
640 | return false; never executed: return false; | 0 |
641 | } | - |
642 | | - |
643 | | - |
644 | | - |
645 | | - |
646 | | - |
647 | | - |
648 | | - |
649 | | - |
650 | | - |
651 | | - |
652 | void QTreeView::setFirstColumnSpanned(int row, const QModelIndex &parent, bool span) | - |
653 | { | - |
654 | Q_D(QTreeView); | - |
655 | if (!d->model)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
656 | return; never executed: return; | 0 |
657 | QModelIndex index = d->model->index(row, 0, parent); | - |
658 | if (!index.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
659 | return; never executed: return; | 0 |
660 | | - |
661 | if (span) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
662 | QPersistentModelIndex persistent(index); | - |
663 | if (!d->spanningIndexes.contains(persistent))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
664 | d->spanningIndexes.append(persistent); never executed: d->spanningIndexes.append(persistent); | 0 |
665 | } else { never executed: end of block | 0 |
666 | QPersistentModelIndex persistent(index); | - |
667 | int i = d->spanningIndexes.indexOf(persistent); | - |
668 | if (i >= 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
669 | d->spanningIndexes.remove(i); never executed: d->spanningIndexes.remove(i); | 0 |
670 | } never executed: end of block | 0 |
671 | | - |
672 | d->executePostedLayout(); | - |
673 | int i = d->viewIndex(index); | - |
674 | if (i >= 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
675 | d->viewItems[i].spanning = span; never executed: d->viewItems[i].spanning = span; | 0 |
676 | | - |
677 | d->viewport->update(); | - |
678 | } never executed: end of block | 0 |
679 | | - |
680 | | - |
681 | | - |
682 | | - |
683 | void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) | - |
684 | { | - |
685 | Q_D(QTreeView); | - |
686 | | - |
687 | | - |
688 | if (d->delayedPendingLayout)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
689 | return; never executed: return; | 0 |
690 | | - |
691 | | - |
692 | | - |
693 | | - |
694 | bool sizeChanged = false; | - |
695 | int topViewIndex = d->viewIndex(topLeft); | - |
696 | if (topViewIndex == 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
697 | int newDefaultItemHeight = indexRowSizeHint(topLeft); | - |
698 | sizeChanged = d->defaultItemHeight != newDefaultItemHeight; | - |
699 | d->defaultItemHeight = newDefaultItemHeight; | - |
700 | } never executed: end of block | 0 |
701 | | - |
702 | if (topViewIndex != -1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
703 | if (topLeft.row() == bottomRight.row()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
704 | int oldHeight = d->itemHeight(topViewIndex); | - |
705 | d->invalidateHeightCache(topViewIndex); | - |
706 | sizeChanged |= (oldHeight != d->itemHeight(topViewIndex)); | - |
707 | if (topLeft.column() == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
708 | d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft); never executed: d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft); | 0 |
709 | } else { never executed: end of block | 0 |
710 | int bottomViewIndex = d->viewIndex(bottomRight); | - |
711 | for (int i = topViewIndex; i <= bottomViewIndex; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
712 | int oldHeight = d->itemHeight(i); | - |
713 | d->invalidateHeightCache(i); | - |
714 | sizeChanged |= (oldHeight != d->itemHeight(i)); | - |
715 | if (topLeft.column() == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
716 | d->viewItems[i].hasChildren = d->hasVisibleChildren(d->viewItems.at(i).index); never executed: d->viewItems[i].hasChildren = d->hasVisibleChildren(d->viewItems.at(i).index); | 0 |
717 | } never executed: end of block | 0 |
718 | } never executed: end of block | 0 |
719 | } | - |
720 | | - |
721 | if (sizeChanged) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
722 | d->updateScrollBars(); | - |
723 | d->viewport->update(); | - |
724 | } never executed: end of block | 0 |
725 | QAbstractItemView::dataChanged(topLeft, bottomRight, roles); | - |
726 | } never executed: end of block | 0 |
727 | | - |
728 | | - |
729 | | - |
730 | | - |
731 | | - |
732 | | - |
733 | | - |
734 | | - |
735 | | - |
736 | | - |
737 | void QTreeView::hideColumn(int column) | - |
738 | { | - |
739 | Q_D(QTreeView); | - |
740 | d->header->hideSection(column); | - |
741 | } never executed: end of block | 0 |
742 | | - |
743 | | - |
744 | | - |
745 | | - |
746 | | - |
747 | | - |
748 | void QTreeView::showColumn(int column) | - |
749 | { | - |
750 | Q_D(QTreeView); | - |
751 | d->header->showSection(column); | - |
752 | } never executed: end of block | 0 |
753 | | - |
754 | | - |
755 | | - |
756 | | - |
757 | | - |
758 | | - |
759 | | - |
760 | | - |
761 | void QTreeView::expand(const QModelIndex &index) | - |
762 | { | - |
763 | Q_D(QTreeView); | - |
764 | if (!d->isIndexValid(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
765 | return; never executed: return; | 0 |
766 | if (index.flags() & Qt::ItemNeverHasChildren)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
767 | return; never executed: return; | 0 |
768 | if (d->isIndexExpanded(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
769 | return; never executed: return; | 0 |
770 | if (d->delayedPendingLayout) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
771 | | - |
772 | if (d->storeExpanded(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
773 | emit expanded(index); never executed: expanded(index); | 0 |
774 | return; never executed: return; | 0 |
775 | } | - |
776 | | - |
777 | int i = d->viewIndex(index); | - |
778 | if (i != -1) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
779 | d->expand(i, true); | - |
780 | if (!d->isAnimating()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
781 | updateGeometries(); | - |
782 | d->viewport->update(); | - |
783 | } never executed: end of block | 0 |
784 | } else if (d->storeExpanded(index)) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
785 | emit expanded(index); | - |
786 | } never executed: end of block | 0 |
787 | } never executed: end of block | 0 |
788 | | - |
789 | | - |
790 | | - |
791 | | - |
792 | | - |
793 | | - |
794 | | - |
795 | | - |
796 | void QTreeView::collapse(const QModelIndex &index) | - |
797 | { | - |
798 | Q_D(QTreeView); | - |
799 | if (!d->isIndexValid(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
800 | return; never executed: return; | 0 |
801 | if (!d->isIndexExpanded(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
802 | return; never executed: return; | 0 |
803 | | - |
804 | d->delayedAutoScroll.stop(); | - |
805 | | - |
806 | if (d->delayedPendingLayout) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
807 | | - |
808 | if (d->isPersistent(index) && d->expandedIndexes.remove(index))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
809 | emit collapsed(index); never executed: collapsed(index); | 0 |
810 | return; never executed: return; | 0 |
811 | } | - |
812 | int i = d->viewIndex(index); | - |
813 | if (i != -1) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
814 | d->collapse(i, true); | - |
815 | if (!d->isAnimating()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
816 | updateGeometries(); | - |
817 | viewport()->update(); | - |
818 | } never executed: end of block | 0 |
819 | } else { never executed: end of block | 0 |
820 | if (d->isPersistent(index) && d->expandedIndexes.remove(index))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
821 | emit collapsed(index); never executed: collapsed(index); | 0 |
822 | } never executed: end of block | 0 |
823 | } | - |
824 | | - |
825 | | - |
826 | | - |
827 | | - |
828 | | - |
829 | | - |
830 | | - |
831 | | - |
832 | | - |
833 | bool QTreeView::isExpanded(const QModelIndex &index) const | - |
834 | { | - |
835 | Q_D(const QTreeView); | - |
836 | return d->isIndexExpanded(index); never executed: return d->isIndexExpanded(index); | 0 |
837 | } | - |
838 | | - |
839 | | - |
840 | | - |
841 | | - |
842 | | - |
843 | | - |
844 | | - |
845 | void QTreeView::setExpanded(const QModelIndex &index, bool expanded) | - |
846 | { | - |
847 | if (expanded)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
848 | this->expand(index); never executed: this->expand(index); | 0 |
849 | else | - |
850 | this->collapse(index); never executed: this->collapse(index); | 0 |
851 | } | - |
852 | | - |
853 | | - |
854 | | - |
855 | | - |
856 | | - |
857 | | - |
858 | | - |
859 | | - |
860 | | - |
861 | | - |
862 | | - |
863 | | - |
864 | | - |
865 | | - |
866 | | - |
867 | | - |
868 | | - |
869 | void QTreeView::setSortingEnabled(bool enable) | - |
870 | { | - |
871 | Q_D(QTreeView); | - |
872 | header()->setSortIndicatorShown(enable); | - |
873 | header()->setSectionsClickable(enable); | - |
874 | if (enable) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
875 | | - |
876 | | - |
877 | sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder()); | - |
878 | connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), | - |
879 | this, SLOT(_q_sortIndicatorChanged(int,Qt::SortOrder)), Qt::UniqueConnection); | - |
880 | } else { never executed: end of block | 0 |
881 | disconnect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), | - |
882 | this, SLOT(_q_sortIndicatorChanged(int,Qt::SortOrder))); | - |
883 | } never executed: end of block | 0 |
884 | d->sortingEnabled = enable; | - |
885 | } never executed: end of block | 0 |
886 | | - |
887 | bool QTreeView::isSortingEnabled() const | - |
888 | { | - |
889 | Q_D(const QTreeView); | - |
890 | return d->sortingEnabled; never executed: return d->sortingEnabled; | 0 |
891 | } | - |
892 | | - |
893 | | - |
894 | | - |
895 | | - |
896 | | - |
897 | | - |
898 | | - |
899 | | - |
900 | | - |
901 | | - |
902 | | - |
903 | | - |
904 | | - |
905 | | - |
906 | void QTreeView::setAnimated(bool animate) | - |
907 | { | - |
908 | Q_D(QTreeView); | - |
909 | d->animationsEnabled = animate; | - |
910 | } never executed: end of block | 0 |
911 | | - |
912 | bool QTreeView::isAnimated() const | - |
913 | { | - |
914 | Q_D(const QTreeView); | - |
915 | return d->animationsEnabled; never executed: return d->animationsEnabled; | 0 |
916 | } | - |
917 | | - |
918 | | - |
919 | | - |
920 | | - |
921 | | - |
922 | | - |
923 | | - |
924 | | - |
925 | | - |
926 | | - |
927 | | - |
928 | | - |
929 | void QTreeView::setAllColumnsShowFocus(bool enable) | - |
930 | { | - |
931 | Q_D(QTreeView); | - |
932 | if (d->allColumnsShowFocus == enable)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
933 | return; never executed: return; | 0 |
934 | d->allColumnsShowFocus = enable; | - |
935 | d->viewport->update(); | - |
936 | } never executed: end of block | 0 |
937 | | - |
938 | bool QTreeView::allColumnsShowFocus() const | - |
939 | { | - |
940 | Q_D(const QTreeView); | - |
941 | return d->allColumnsShowFocus; never executed: return d->allColumnsShowFocus; | 0 |
942 | } | - |
943 | | - |
944 | | - |
945 | | - |
946 | | - |
947 | | - |
948 | | - |
949 | | - |
950 | | - |
951 | | - |
952 | | - |
953 | | - |
954 | | - |
955 | | - |
956 | | - |
957 | void QTreeView::setWordWrap(bool on) | - |
958 | { | - |
959 | Q_D(QTreeView); | - |
960 | if (d->wrapItemText == on)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
961 | return; never executed: return; | 0 |
962 | d->wrapItemText = on; | - |
963 | d->doDelayedItemsLayout(); | - |
964 | } never executed: end of block | 0 |
965 | | - |
966 | bool QTreeView::wordWrap() const | - |
967 | { | - |
968 | Q_D(const QTreeView); | - |
969 | return d->wrapItemText; never executed: return d->wrapItemText; | 0 |
970 | } | - |
971 | | - |
972 | | - |
973 | | - |
974 | | - |
975 | | - |
976 | | - |
977 | | - |
978 | | - |
979 | | - |
980 | | - |
981 | void QTreeView::setTreePosition(int index) | - |
982 | { | - |
983 | Q_D(QTreeView); | - |
984 | d->treePosition = index; | - |
985 | update(); | - |
986 | } never executed: end of block | 0 |
987 | | - |
988 | | - |
989 | | - |
990 | | - |
991 | | - |
992 | | - |
993 | | - |
994 | | - |
995 | | - |
996 | | - |
997 | int QTreeView::treePosition() const | - |
998 | { | - |
999 | Q_D(const QTreeView); | - |
1000 | return d->treePosition; never executed: return d->treePosition; | 0 |
1001 | } | - |
1002 | | - |
1003 | | - |
1004 | | - |
1005 | | - |
1006 | void QTreeView::keyboardSearch(const QString &search) | - |
1007 | { | - |
1008 | Q_D(QTreeView); | - |
1009 | if (!d->model->rowCount(d->root) || !d->model->columnCount(d->root))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1010 | return; never executed: return; | 0 |
1011 | | - |
1012 | QModelIndex start; | - |
1013 | if (currentIndex().isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1014 | start = currentIndex(); never executed: start = currentIndex(); | 0 |
1015 | else | - |
1016 | start = d->model->index(0, 0, d->root); never executed: start = d->model->index(0, 0, d->root); | 0 |
1017 | | - |
1018 | bool skipRow = false; | - |
1019 | bool keyboardTimeWasValid = d->keyboardInputTime.isValid(); | - |
1020 | qint64 keyboardInputTimeElapsed; | - |
1021 | if (keyboardTimeWasValid)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1022 | keyboardInputTimeElapsed = d->keyboardInputTime.restart(); never executed: keyboardInputTimeElapsed = d->keyboardInputTime.restart(); | 0 |
1023 | else | - |
1024 | d->keyboardInputTime.start(); never executed: d->keyboardInputTime.start(); | 0 |
1025 | if (search.isEmpty() || !keyboardTimeWasValidTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1026 | || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1027 | d->keyboardInput = search; | - |
1028 | skipRow = currentIndex().isValid(); | - |
1029 | } else { never executed: end of block | 0 |
1030 | d->keyboardInput += search; | - |
1031 | } never executed: end of block | 0 |
1032 | | - |
1033 | | - |
1034 | bool sameKey = false; | - |
1035 | if (d->keyboardInput.length() > 1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1036 | int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1)); | - |
1037 | sameKey = (c == d->keyboardInput.length()); | - |
1038 | if (sameKey)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1039 | skipRow = true; never executed: skipRow = true; | 0 |
1040 | } never executed: end of block | 0 |
1041 | | - |
1042 | | - |
1043 | if (skipRow) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1044 | if (indexBelow(start).isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1045 | start = indexBelow(start); never executed: start = indexBelow(start); | 0 |
1046 | else | - |
1047 | start = d->model->index(0, start.column(), d->root); never executed: start = d->model->index(0, start.column(), d->root); | 0 |
1048 | } | - |
1049 | | - |
1050 | d->executePostedLayout(); | - |
1051 | int startIndex = d->viewIndex(start); | - |
1052 | if (startIndex <= -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1053 | return; never executed: return; | 0 |
1054 | | - |
1055 | int previousLevel = -1; | - |
1056 | int bestAbove = -1; | - |
1057 | int bestBelow = -1; | - |
1058 | QString searchString = sameKey ? QString(d->keyboardInput.at(0)) : d->keyboardInput;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1059 | for (int i = 0; i < d->viewItems.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1060 | if ((int)d->viewItems.at(i).level > previousLevel) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1061 | QModelIndex searchFrom = d->viewItems.at(i).index; | - |
1062 | if (start.column() > 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1063 | searchFrom = searchFrom.sibling(searchFrom.row(), start.column()); never executed: searchFrom = searchFrom.sibling(searchFrom.row(), start.column()); | 0 |
1064 | if (searchFrom.parent() == start.parent())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1065 | searchFrom = start; never executed: searchFrom = start; | 0 |
1066 | QModelIndexList match = d->model->match(searchFrom, Qt::DisplayRole, searchString); | - |
1067 | if (match.count()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1068 | int hitIndex = d->viewIndex(match.at(0)); | - |
1069 | if (hitIndex >= 0 && hitIndex < startIndex)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1070 | bestAbove = bestAbove == -1 ? hitIndex : qMin(hitIndex, bestAbove); never executed: bestAbove = bestAbove == -1 ? hitIndex : qMin(hitIndex, bestAbove); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1071 | else if (hitIndex >= startIndex)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1072 | bestBelow = bestBelow == -1 ? hitIndex : qMin(hitIndex, bestBelow); never executed: bestBelow = bestBelow == -1 ? hitIndex : qMin(hitIndex, bestBelow); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1073 | } never executed: end of block | 0 |
1074 | } never executed: end of block | 0 |
1075 | previousLevel = d->viewItems.at(i).level; | - |
1076 | } never executed: end of block | 0 |
1077 | | - |
1078 | QModelIndex index; | - |
1079 | if (bestBelow > -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1080 | index = d->viewItems.at(bestBelow).index; never executed: index = d->viewItems.at(bestBelow).index; | 0 |
1081 | else if (bestAbove > -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1082 | index = d->viewItems.at(bestAbove).index; never executed: index = d->viewItems.at(bestAbove).index; | 0 |
1083 | | - |
1084 | if (start.column() > 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1085 | index = index.sibling(index.row(), start.column()); never executed: index = index.sibling(index.row(), start.column()); | 0 |
1086 | | - |
1087 | if (index.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1088 | QItemSelectionModel::SelectionFlags flags = (d->selectionMode == SingleSelectionTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1089 | ? QItemSelectionModel::SelectionFlags( | - |
1090 | QItemSelectionModel::ClearAndSelect | - |
1091 | |d->selectionBehaviorFlags()) | - |
1092 | : QItemSelectionModel::SelectionFlags( | - |
1093 | QItemSelectionModel::NoUpdate)); | - |
1094 | selectionModel()->setCurrentIndex(index, flags); | - |
1095 | } never executed: end of block | 0 |
1096 | } never executed: end of block | 0 |
1097 | | - |
1098 | | - |
1099 | | - |
1100 | | - |
1101 | | - |
1102 | QRect QTreeView::visualRect(const QModelIndex &index) const | - |
1103 | { | - |
1104 | Q_D(const QTreeView); | - |
1105 | | - |
1106 | if (!d->isIndexValid(index) || isIndexHidden(index))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1107 | return QRect(); never executed: return QRect(); | 0 |
1108 | | - |
1109 | d->executePostedLayout(); | - |
1110 | | - |
1111 | int vi = d->viewIndex(index); | - |
1112 | if (vi < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1113 | return QRect(); never executed: return QRect(); | 0 |
1114 | | - |
1115 | bool spanning = d->viewItems.at(vi).spanning; | - |
1116 | | - |
1117 | | - |
1118 | int x = (spanning ? 0 : columnViewportPosition(index.column()));TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1119 | int w = (spanning ? d->header->length() : columnWidth(index.column()));TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1120 | | - |
1121 | if (d->isTreePosition(index.column())) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1122 | int i = d->indentationForItem(vi); | - |
1123 | w -= i; | - |
1124 | if (!isRightToLeft())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1125 | x += i; never executed: x += i; | 0 |
1126 | } never executed: end of block | 0 |
1127 | | - |
1128 | int y = d->coordinateForItem(vi); | - |
1129 | int h = d->itemHeight(vi); | - |
1130 | | - |
1131 | return QRect(x, y, w, h); never executed: return QRect(x, y, w, h); | 0 |
1132 | } | - |
1133 | | - |
1134 | | - |
1135 | | - |
1136 | | - |
1137 | | - |
1138 | | - |
1139 | | - |
1140 | | - |
1141 | | - |
1142 | void QTreeView::scrollTo(const QModelIndex &index, ScrollHint hint) | - |
1143 | { | - |
1144 | Q_D(QTreeView); | - |
1145 | | - |
1146 | if (!d->isIndexValid(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1147 | return; never executed: return; | 0 |
1148 | | - |
1149 | d->executePostedLayout(); | - |
1150 | d->updateScrollBars(); | - |
1151 | | - |
1152 | | - |
1153 | QModelIndex parent = index.parent(); | - |
1154 | while (parent != d->root && parent.isValid() && state() == NoState && d->itemsExpandable) {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 |
1155 | if (!isExpanded(parent))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1156 | expand(parent); never executed: expand(parent); | 0 |
1157 | parent = d->model->parent(parent); | - |
1158 | } never executed: end of block | 0 |
1159 | | - |
1160 | int item = d->viewIndex(index); | - |
1161 | if (item < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1162 | return; never executed: return; | 0 |
1163 | | - |
1164 | QRect area = d->viewport->rect(); | - |
1165 | | - |
1166 | | - |
1167 | if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1168 | int top = verticalScrollBar()->value(); | - |
1169 | int bottom = top + verticalScrollBar()->pageStep(); | - |
1170 | if (hint == EnsureVisible && item >= top && item < bottom) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1171 | | - |
1172 | } else if (hint == PositionAtTop || (hint == EnsureVisible && item < top)) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1173 | verticalScrollBar()->setValue(item); | - |
1174 | } else { never executed: end of block | 0 |
1175 | const int currentItemHeight = d->itemHeight(item); | - |
1176 | int y = (hint == PositionAtCenterTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1177 | | - |
1178 | ? area.height() / 2 + currentItemHeight - 1 | - |
1179 | | - |
1180 | : area.height()); | - |
1181 | if (y > currentItemHeight) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1182 | while (item >= 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1183 | y -= d->itemHeight(item); | - |
1184 | if (y < 0) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1185 | item++; | - |
1186 | break; never executed: break; | 0 |
1187 | } | - |
1188 | item--; | - |
1189 | } never executed: end of block | 0 |
1190 | } never executed: end of block | 0 |
1191 | verticalScrollBar()->setValue(item); | - |
1192 | } never executed: end of block | 0 |
1193 | } else { | - |
1194 | QRect rect(columnViewportPosition(index.column()), | - |
1195 | d->coordinateForItem(item), | - |
1196 | columnWidth(index.column()), | - |
1197 | d->itemHeight(item)); | - |
1198 | | - |
1199 | if (rect.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1200 | | - |
1201 | } else if (hint == EnsureVisible && area.contains(rect)) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1202 | d->viewport->update(rect); | - |
1203 | | - |
1204 | } else { never executed: end of block | 0 |
1205 | bool above = (hint == EnsureVisibleTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1206 | && (rect.top() < area.top()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1207 | || area.height() < rect.height()));TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1208 | bool below = (hint == EnsureVisibleTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1209 | && rect.bottom() > area.bottom()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1210 | && rect.height() < area.height());TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1211 | | - |
1212 | int verticalValue = verticalScrollBar()->value(); | - |
1213 | if (hint == PositionAtTop || above)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1214 | verticalValue += rect.top(); never executed: verticalValue += rect.top(); | 0 |
1215 | else if (hint == PositionAtBottom || below)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1216 | verticalValue += rect.bottom() - area.height(); never executed: verticalValue += rect.bottom() - area.height(); | 0 |
1217 | else if (hint == PositionAtCenter)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1218 | verticalValue += rect.top() - ((area.height() - rect.height()) / 2); never executed: verticalValue += rect.top() - ((area.height() - rect.height()) / 2); | 0 |
1219 | verticalScrollBar()->setValue(verticalValue); | - |
1220 | } never executed: end of block | 0 |
1221 | } | - |
1222 | | - |
1223 | int viewportWidth = d->viewport->width(); | - |
1224 | int horizontalOffset = d->header->offset(); | - |
1225 | int horizontalPosition = d->header->sectionPosition(index.column()); | - |
1226 | int cellWidth = d->header->sectionSize(index.column()); | - |
1227 | | - |
1228 | if (hint == PositionAtCenter) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1229 | horizontalScrollBar()->setValue(horizontalPosition - ((viewportWidth - cellWidth) / 2)); | - |
1230 | } else { never executed: end of block | 0 |
1231 | if (horizontalPosition - horizontalOffset < 0 || cellWidth > viewportWidth)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1232 | horizontalScrollBar()->setValue(horizontalPosition); never executed: horizontalScrollBar()->setValue(horizontalPosition); | 0 |
1233 | else if (horizontalPosition - horizontalOffset + cellWidth > viewportWidth)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1234 | horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth); never executed: horizontalScrollBar()->setValue(horizontalPosition - viewportWidth + cellWidth); | 0 |
1235 | } never executed: end of block | 0 |
1236 | } | - |
1237 | | - |
1238 | | - |
1239 | | - |
1240 | | - |
1241 | void QTreeView::timerEvent(QTimerEvent *event) | - |
1242 | { | - |
1243 | Q_D(QTreeView); | - |
1244 | if (event->timerId() == d->columnResizeTimerID) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1245 | updateGeometries(); | - |
1246 | killTimer(d->columnResizeTimerID); | - |
1247 | d->columnResizeTimerID = 0; | - |
1248 | QRect rect; | - |
1249 | int viewportHeight = d->viewport->height(); | - |
1250 | int viewportWidth = d->viewport->width(); | - |
1251 | for (int i = d->columnsToUpdate.size() - 1; i >= 0; --i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1252 | int column = d->columnsToUpdate.at(i); | - |
1253 | int x = columnViewportPosition(column); | - |
1254 | if (isRightToLeft())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1255 | rect |= QRect(0, 0, x + columnWidth(column), viewportHeight); never executed: rect |= QRect(0, 0, x + columnWidth(column), viewportHeight); | 0 |
1256 | else | - |
1257 | rect |= QRect(x, 0, viewportWidth - x, viewportHeight); never executed: rect |= QRect(x, 0, viewportWidth - x, viewportHeight); | 0 |
1258 | } | - |
1259 | d->viewport->update(rect.normalized()); | - |
1260 | d->columnsToUpdate.clear(); | - |
1261 | } else if (event->timerId() == d->openTimer.timerId()) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1262 | QPoint pos = d->viewport->mapFromGlobal(QCursor::pos()); | - |
1263 | if (state() == QAbstractItemView::DraggingStateTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1264 | && d->viewport->rect().contains(pos)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1265 | QModelIndex index = indexAt(pos); | - |
1266 | setExpanded(index, !isExpanded(index)); | - |
1267 | } never executed: end of block | 0 |
1268 | d->openTimer.stop(); | - |
1269 | } never executed: end of block | 0 |
1270 | | - |
1271 | QAbstractItemView::timerEvent(event); | - |
1272 | } never executed: end of block | 0 |
1273 | | - |
1274 | | - |
1275 | | - |
1276 | | - |
1277 | #ifndef QT_NO_DRAGANDDROP | - |
1278 | void QTreeView::dragMoveEvent(QDragMoveEvent *event) | - |
1279 | { | - |
1280 | Q_D(QTreeView); | - |
1281 | if (d->autoExpandDelay >= 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1282 | d->openTimer.start(d->autoExpandDelay, this); never executed: d->openTimer.start(d->autoExpandDelay, this); | 0 |
1283 | QAbstractItemView::dragMoveEvent(event); | - |
1284 | } never executed: end of block | 0 |
1285 | #endif | - |
1286 | | - |
1287 | | - |
1288 | | - |
1289 | | - |
1290 | bool QTreeView::viewportEvent(QEvent *event) | - |
1291 | { | - |
1292 | Q_D(QTreeView); | - |
1293 | switch (event->type()) { | - |
1294 | case QEvent::HoverEnter: never executed: case QEvent::HoverEnter: | 0 |
1295 | case QEvent::HoverLeave: never executed: case QEvent::HoverLeave: | 0 |
1296 | case QEvent::HoverMove: { never executed: case QEvent::HoverMove: | 0 |
1297 | QHoverEvent *he = static_cast<QHoverEvent*>(event); | - |
1298 | int oldBranch = d->hoverBranch; | - |
1299 | d->hoverBranch = d->itemDecorationAt(he->pos()); | - |
1300 | QModelIndex newIndex = indexAt(he->pos()); | - |
1301 | if (d->hover != newIndex || d->hoverBranch != oldBranch) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1302 | | - |
1303 | | - |
1304 | QRect rect = visualRect(newIndex); | - |
1305 | rect.setX(0); | - |
1306 | rect.setWidth(viewport()->width()); | - |
1307 | viewport()->update(rect); | - |
1308 | } never executed: end of block | 0 |
1309 | break; } never executed: break; | 0 |
1310 | default: never executed: default: | 0 |
1311 | break; never executed: break; | 0 |
1312 | } | - |
1313 | return QAbstractItemView::viewportEvent(event); never executed: return QAbstractItemView::viewportEvent(event); | 0 |
1314 | } | - |
1315 | | - |
1316 | | - |
1317 | | - |
1318 | | - |
1319 | void QTreeView::paintEvent(QPaintEvent *event) | - |
1320 | { | - |
1321 | Q_D(QTreeView); | - |
1322 | d->executePostedLayout(); | - |
1323 | QPainter painter(viewport()); | - |
1324 | #ifndef QT_NO_ANIMATION | - |
1325 | if (d->isAnimating()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1326 | drawTree(&painter, event->region() - d->animatedOperation.rect()); | - |
1327 | d->drawAnimatedOperation(&painter); | - |
1328 | } else never executed: end of block | 0 |
1329 | #endif //QT_NO_ANIMATION | - |
1330 | { | - |
1331 | drawTree(&painter, event->region()); | - |
1332 | #ifndef QT_NO_DRAGANDDROP | - |
1333 | d->paintDropIndicator(&painter); | - |
1334 | #endif | - |
1335 | } never executed: end of block | 0 |
1336 | } | - |
1337 | | - |
1338 | int QTreeViewPrivate::logicalIndexForTree() const | - |
1339 | { | - |
1340 | int index = treePosition; | - |
1341 | if (index < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1342 | index = header->logicalIndex(0); never executed: index = header->logicalIndex(0); | 0 |
1343 | return index; never executed: return index; | 0 |
1344 | } | - |
1345 | | - |
1346 | void QTreeViewPrivate::paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItem *option, int y, int bottom) const | - |
1347 | { | - |
1348 | Q_Q(const QTreeView); | - |
1349 | if (!alternatingColors || !q->style()->styleHint(QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea, option, q))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1350 | return; never executed: return; | 0 |
1351 | int rowHeight = defaultItemHeight; | - |
1352 | if (rowHeight <= 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1353 | rowHeight = itemDelegate->sizeHint(*option, QModelIndex()).height(); | - |
1354 | if (rowHeight <= 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1355 | return; never executed: return; | 0 |
1356 | } never executed: end of block | 0 |
1357 | while (y <= bottom) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1358 | option->rect.setRect(0, y, viewport->width(), rowHeight); | - |
1359 | if (current & 1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1360 | option->features |= QStyleOptionViewItem::Alternate; | - |
1361 | } else { never executed: end of block | 0 |
1362 | option->features &= ~QStyleOptionViewItem::Alternate; | - |
1363 | } never executed: end of block | 0 |
1364 | ++current; | - |
1365 | q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, option, painter, q); | - |
1366 | y += rowHeight; | - |
1367 | } never executed: end of block | 0 |
1368 | } never executed: end of block | 0 |
1369 | | - |
1370 | bool QTreeViewPrivate::expandOrCollapseItemAtPos(const QPoint &pos) | - |
1371 | { | - |
1372 | Q_Q(QTreeView); | - |
1373 | | - |
1374 | if ((state != QAbstractItemView::NoStateTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1375 | && state != QAbstractItemView::EditingState)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1376 | || !viewport->rect().contains(pos))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1377 | return true; never executed: return true; | 0 |
1378 | | - |
1379 | int i = itemDecorationAt(pos); | - |
1380 | if ((i != -1) && itemsExpandable && hasVisibleChildren(viewItems.at(i).index)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1381 | if (viewItems.at(i).expanded)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1382 | collapse(i, true); never executed: collapse(i, true); | 0 |
1383 | else | - |
1384 | expand(i, true); never executed: expand(i, true); | 0 |
1385 | if (!isAnimating()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1386 | q->updateGeometries(); | - |
1387 | viewport->update(); | - |
1388 | } never executed: end of block | 0 |
1389 | return true; never executed: return true; | 0 |
1390 | } | - |
1391 | return false; never executed: return false; | 0 |
1392 | } | - |
1393 | | - |
1394 | void QTreeViewPrivate::_q_modelDestroyed() | - |
1395 | { | - |
1396 | | - |
1397 | | - |
1398 | viewItems.clear(); | - |
1399 | QAbstractItemViewPrivate::_q_modelDestroyed(); | - |
1400 | } never executed: end of block | 0 |
1401 | | - |
1402 | | - |
1403 | | - |
1404 | | - |
1405 | | - |
1406 | | - |
1407 | QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const | - |
1408 | { | - |
1409 | Q_ASSERT(r); | - |
1410 | Q_Q(const QTreeView); | - |
1411 | if (spanningIndexes.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1412 | return QAbstractItemViewPrivate::draggablePaintPairs(indexes, r); never executed: return QAbstractItemViewPrivate::draggablePaintPairs(indexes, r); | 0 |
1413 | QModelIndexList list; | - |
1414 | foreach (const QModelIndex &idx, indexes) { | - |
1415 | if (idx.column() > 0 && q->isFirstColumnSpanned(idx.row(), idx.parent()))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1416 | continue; never executed: continue; | 0 |
1417 | list << idx; | - |
1418 | } never executed: end of block | 0 |
1419 | return QAbstractItemViewPrivate::draggablePaintPairs(list, r); never executed: return QAbstractItemViewPrivate::draggablePaintPairs(list, r); | 0 |
1420 | } | - |
1421 | | - |
1422 | void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItem *option, const QModelIndex ¤t) const | - |
1423 | { | - |
1424 | const int row = viewIndex(current); | - |
1425 | option->state = option->state | (viewItems.at(row).expanded ? QStyle::State_Open : QStyle::State_None) | - |
1426 | | (viewItems.at(row).hasChildren ? QStyle::State_Children : QStyle::State_None) | - |
1427 | | (viewItems.at(row).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None); | - |
1428 | | - |
1429 | option->showDecorationSelected = (selectionBehavior & QTreeView::SelectRows)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1430 | || option->showDecorationSelected;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1431 | | - |
1432 | QVector<int> logicalIndices; | - |
1433 | QVector<QStyleOptionViewItem::ViewItemPosition> viewItemPosList; | - |
1434 | const bool spanning = viewItems.at(row).spanning; | - |
1435 | const int left = (spanning ? header->visualIndex(0) : 0);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1436 | const int right = (spanning ? header->visualIndex(0) : header->count() - 1 );TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1437 | calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right); | - |
1438 | | - |
1439 | const int visualIndex = logicalIndices.indexOf(current.column()); | - |
1440 | option->viewItemPosition = viewItemPosList.at(visualIndex); | - |
1441 | } never executed: end of block | 0 |
1442 | | - |
1443 | | - |
1444 | | - |
1445 | | - |
1446 | | - |
1447 | | - |
1448 | | - |
1449 | | - |
1450 | | - |
1451 | void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const | - |
1452 | { | - |
1453 | Q_D(const QTreeView); | - |
1454 | const QVector<QTreeViewItem> viewItems = d->viewItems; | - |
1455 | | - |
1456 | QStyleOptionViewItem option = d->viewOptionsV1(); | - |
1457 | const QStyle::State state = option.state; | - |
1458 | d->current = 0; | - |
1459 | | - |
1460 | if (viewItems.count() == 0 || d->header->count() == 0 || !d->itemDelegate) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1461 | d->paintAlternatingRowColors(painter, &option, 0, region.boundingRect().bottom()+1); | - |
1462 | return; never executed: return; | 0 |
1463 | } | - |
1464 | | - |
1465 | int firstVisibleItemOffset = 0; | - |
1466 | const int firstVisibleItem = d->firstVisibleItem(&firstVisibleItemOffset); | - |
1467 | if (firstVisibleItem < 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1468 | d->paintAlternatingRowColors(painter, &option, 0, region.boundingRect().bottom()+1); | - |
1469 | return; never executed: return; | 0 |
1470 | } | - |
1471 | | - |
1472 | const int viewportWidth = d->viewport->width(); | - |
1473 | | - |
1474 | QPoint hoverPos = d->viewport->mapFromGlobal(QCursor::pos()); | - |
1475 | d->hoverBranch = d->itemDecorationAt(hoverPos); | - |
1476 | | - |
1477 | QVector<QRect> rects = region.rects(); | - |
1478 | QVector<int> drawn; | - |
1479 | bool multipleRects = (rects.size() > 1); | - |
1480 | for (int a = 0; a < rects.size(); ++a) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1481 | const QRect area = (multipleRectsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1482 | ? QRect(0, rects.at(a).y(), viewportWidth, rects.at(a).height()) | - |
1483 | : rects.at(a)); | - |
1484 | d->leftAndRight = d->startAndEndColumns(area); | - |
1485 | | - |
1486 | int i = firstVisibleItem; | - |
1487 | int y = firstVisibleItemOffset; | - |
1488 | | - |
1489 | | - |
1490 | for (; i < viewItems.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1491 | const int itemHeight = d->itemHeight(i); | - |
1492 | if (y + itemHeight > area.top())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1493 | break; never executed: break; | 0 |
1494 | y += itemHeight; | - |
1495 | } never executed: end of block | 0 |
1496 | | - |
1497 | | - |
1498 | for (; i < viewItems.count() && y <= area.bottom(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1499 | const int itemHeight = d->itemHeight(i); | - |
1500 | option.rect.setRect(0, y, viewportWidth, itemHeight); | - |
1501 | option.state = state | (viewItems.at(i).expanded ? QStyle::State_Open : QStyle::State_None) | - |
1502 | | (viewItems.at(i).hasChildren ? QStyle::State_Children : QStyle::State_None) | - |
1503 | | (viewItems.at(i).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None); | - |
1504 | d->current = i; | - |
1505 | d->spanning = viewItems.at(i).spanning; | - |
1506 | if (!multipleRects || !drawn.contains(i)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1507 | drawRow(painter, option, viewItems.at(i).index); | - |
1508 | if (multipleRects) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1509 | drawn.append(i); never executed: drawn.append(i); | 0 |
1510 | } never executed: end of block | 0 |
1511 | y += itemHeight; | - |
1512 | } never executed: end of block | 0 |
1513 | | - |
1514 | if (y <= area.bottom()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1515 | d->current = i; | - |
1516 | d->paintAlternatingRowColors(painter, &option, y, area.bottom()); | - |
1517 | } never executed: end of block | 0 |
1518 | } never executed: end of block | 0 |
1519 | } never executed: end of block | 0 |
1520 | | - |
1521 | | - |
1522 | static inline bool ancestorOf(QObject *widget, QObject *other) | - |
1523 | { | - |
1524 | for (QObject *parent = other; parent != 0; parent = parent->parent()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1525 | if (parent == widget)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1526 | return true; never executed: return true; | 0 |
1527 | } never executed: end of block | 0 |
1528 | return false; never executed: return false; | 0 |
1529 | } | - |
1530 | | - |
1531 | void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItem::ViewItemPosition> *itemPositions, int left, int right) const | - |
1532 | { | - |
1533 | const int columnCount = header->count(); | - |
1534 | | - |
1535 | | - |
1536 | | - |
1537 | int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1; | - |
1538 | for (int visualIndex = left - 1; visualIndex >= 0; --visualIndex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1539 | int logicalIndex = header->logicalIndex(visualIndex); | - |
1540 | if (!header->isSectionHidden(logicalIndex)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1541 | logicalIndexBeforeLeft = logicalIndex; | - |
1542 | break; never executed: break; | 0 |
1543 | } | - |
1544 | } never executed: end of block | 0 |
1545 | | - |
1546 | for (int visualIndex = left; visualIndex < columnCount; ++visualIndex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1547 | int logicalIndex = header->logicalIndex(visualIndex); | - |
1548 | if (!header->isSectionHidden(logicalIndex)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1549 | if (visualIndex > right) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1550 | logicalIndexAfterRight = logicalIndex; | - |
1551 | break; never executed: break; | 0 |
1552 | } | - |
1553 | logicalIndices->append(logicalIndex); | - |
1554 | } never executed: end of block | 0 |
1555 | } never executed: end of block | 0 |
1556 | | - |
1557 | itemPositions->resize(logicalIndices->count()); | - |
1558 | for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices->count(); ++currentLogicalSection) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1559 | const int headerSection = logicalIndices->at(currentLogicalSection); | - |
1560 | | - |
1561 | int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices->count()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1562 | ? logicalIndexAfterRight | - |
1563 | : logicalIndices->at(currentLogicalSection + 1); | - |
1564 | int prevLogicalSection = currentLogicalSection - 1 < 0TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1565 | ? logicalIndexBeforeLeft | - |
1566 | : logicalIndices->at(currentLogicalSection - 1); | - |
1567 | QStyleOptionViewItem::ViewItemPosition pos; | - |
1568 | if (columnCount == 1 || (nextLogicalSection == 0 && prevLogicalSection == -1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1569 | || (headerSection == 0 && nextLogicalSection == -1) || spanning)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1570 | pos = QStyleOptionViewItem::OnlyOne; never executed: pos = QStyleOptionViewItem::OnlyOne; | 0 |
1571 | else if (isTreePosition(headerSection) || (nextLogicalSection != 0 && prevLogicalSection == -1))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1572 | pos = QStyleOptionViewItem::Beginning; never executed: pos = QStyleOptionViewItem::Beginning; | 0 |
1573 | else if (nextLogicalSection == 0 || nextLogicalSection == -1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1574 | pos = QStyleOptionViewItem::End; never executed: pos = QStyleOptionViewItem::End; | 0 |
1575 | else | - |
1576 | pos = QStyleOptionViewItem::Middle; never executed: pos = QStyleOptionViewItem::Middle; | 0 |
1577 | (*itemPositions)[currentLogicalSection] = pos; | - |
1578 | } never executed: end of block | 0 |
1579 | } never executed: end of block | 0 |
1580 | | - |
1581 | | - |
1582 | | - |
1583 | | - |
1584 | | - |
1585 | int QTreeViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option, int i) const | - |
1586 | { | - |
1587 | QWidget *editor = editorForIndex(index).widget.data(); | - |
1588 | if (editor && persistent.contains(editor)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1589 | hint = qMax(hint, editor->sizeHint().width()); | - |
1590 | int min = editor->minimumSize().width(); | - |
1591 | int max = editor->maximumSize().width(); | - |
1592 | hint = qBound(min, hint, max); | - |
1593 | } never executed: end of block | 0 |
1594 | int xhint = delegateForIndex(index)->sizeHint(option, index).width(); | - |
1595 | hint = qMax(hint, xhint + (isTreePosition(index.column()) ? indentationForItem(i) : 0)); | - |
1596 | return hint; never executed: return hint; | 0 |
1597 | } | - |
1598 | | - |
1599 | | - |
1600 | | - |
1601 | | - |
1602 | | - |
1603 | | - |
1604 | | - |
1605 | | - |
1606 | void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, | - |
1607 | const QModelIndex &index) const | - |
1608 | { | - |
1609 | Q_D(const QTreeView); | - |
1610 | QStyleOptionViewItem opt = option; | - |
1611 | const QPoint offset = d->scrollDelayOffset; | - |
1612 | const int y = option.rect.y() + offset.y(); | - |
1613 | const QModelIndex parent = index.parent(); | - |
1614 | const QHeaderView *header = d->header; | - |
1615 | const QModelIndex current = currentIndex(); | - |
1616 | const QModelIndex hover = d->hover; | - |
1617 | const bool reverse = isRightToLeft(); | - |
1618 | const QStyle::State state = opt.state; | - |
1619 | const bool spanning = d->spanning; | - |
1620 | const int left = (spanning ? header->visualIndex(0) : d->leftAndRight.first);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1621 | const int right = (spanning ? header->visualIndex(0) : d->leftAndRight.second);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1622 | const bool alternate = d->alternatingColors; | - |
1623 | const bool enabled = (state & QStyle::State_Enabled) != 0; | - |
1624 | const bool allColumnsShowFocus = d->allColumnsShowFocus; | - |
1625 | | - |
1626 | | - |
1627 | | - |
1628 | | - |
1629 | bool indexWidgetHasFocus = false; | - |
1630 | if ((current.row() == index.row()) && !d->editorIndexHash.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1631 | const int r = index.row(); | - |
1632 | QWidget *fw = QApplication::focusWidget(); | - |
1633 | for (int c = 0; c < header->count(); ++c) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1634 | QModelIndex idx = d->model->index(r, c, parent); | - |
1635 | if (QWidget *editor = indexWidget(idx)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1636 | if (ancestorOf(editor, fw)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1637 | indexWidgetHasFocus = true; | - |
1638 | break; never executed: break; | 0 |
1639 | } | - |
1640 | } never executed: end of block | 0 |
1641 | } never executed: end of block | 0 |
1642 | } never executed: end of block | 0 |
1643 | | - |
1644 | const bool widgetHasFocus = hasFocus(); | - |
1645 | bool currentRowHasFocus = false; | - |
1646 | if (allColumnsShowFocus && widgetHasFocus && current.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1647 | | - |
1648 | const int r = index.row(); | - |
1649 | for (int c = 0; c < left && !currentRowHasFocus; ++c) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1650 | QModelIndex idx = d->model->index(r, c, parent); | - |
1651 | currentRowHasFocus = (idx == current); | - |
1652 | } never executed: end of block | 0 |
1653 | QModelIndex parent = d->model->parent(index); | - |
1654 | for (int c = right; c < header->count() && !currentRowHasFocus; ++c) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1655 | currentRowHasFocus = (d->model->index(r, c, parent) == current); | - |
1656 | } never executed: end of block | 0 |
1657 | } never executed: end of block | 0 |
1658 | | - |
1659 | | - |
1660 | | - |
1661 | opt.showDecorationSelected = (d->selectionBehavior & SelectRows)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1662 | || option.showDecorationSelected;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1663 | | - |
1664 | int width, height = option.rect.height(); | - |
1665 | int position; | - |
1666 | QModelIndex modelIndex; | - |
1667 | const bool hoverRow = selectionBehavior() == QAbstractItemView::SelectRowsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1668 | && index.parent() == hover.parent()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1669 | && index.row() == hover.row();TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1670 | | - |
1671 | QVector<int> logicalIndices; | - |
1672 | QVector<QStyleOptionViewItem::ViewItemPosition> viewItemPosList; | - |
1673 | d->calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right); | - |
1674 | | - |
1675 | for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices.count(); ++currentLogicalSection) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1676 | int headerSection = logicalIndices.at(currentLogicalSection); | - |
1677 | position = columnViewportPosition(headerSection) + offset.x(); | - |
1678 | width = header->sectionSize(headerSection); | - |
1679 | | - |
1680 | if (spanning) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1681 | int lastSection = header->logicalIndex(header->count() - 1); | - |
1682 | if (!reverse) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1683 | width = columnViewportPosition(lastSection) + header->sectionSize(lastSection) - position; | - |
1684 | } else { never executed: end of block | 0 |
1685 | width += position - columnViewportPosition(lastSection); | - |
1686 | position = columnViewportPosition(lastSection); | - |
1687 | } never executed: end of block | 0 |
1688 | } | - |
1689 | | - |
1690 | modelIndex = d->model->index(index.row(), headerSection, parent); | - |
1691 | if (!modelIndex.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1692 | continue; never executed: continue; | 0 |
1693 | opt.state = state; | - |
1694 | | - |
1695 | opt.viewItemPosition = viewItemPosList.at(currentLogicalSection); | - |
1696 | | - |
1697 | | - |
1698 | if (indexWidgetHasFocus)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1699 | opt.state |= QStyle::State_Active; never executed: opt.state |= QStyle::State_Active; | 0 |
1700 | | - |
1701 | if (d->selectionModel->isSelected(modelIndex))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1702 | opt.state |= QStyle::State_Selected; never executed: opt.state |= QStyle::State_Selected; | 0 |
1703 | if (widgetHasFocus && (current == modelIndex)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1704 | if (allColumnsShowFocus)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1705 | currentRowHasFocus = true; never executed: currentRowHasFocus = true; | 0 |
1706 | else | - |
1707 | opt.state |= QStyle::State_HasFocus; never executed: opt.state |= QStyle::State_HasFocus; | 0 |
1708 | } | - |
1709 | if ((hoverRow || modelIndex == hover)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1710 | && (option.showDecorationSelected || (d->hoverBranch == -1)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1711 | opt.state |= QStyle::State_MouseOver; never executed: opt.state |= QStyle::State_MouseOver; | 0 |
1712 | else | - |
1713 | opt.state &= ~QStyle::State_MouseOver; never executed: opt.state &= ~QStyle::State_MouseOver; | 0 |
1714 | | - |
1715 | if (enabled) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1716 | QPalette::ColorGroup cg; | - |
1717 | if ((d->model->flags(modelIndex) & Qt::ItemIsEnabled) == 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1718 | opt.state &= ~QStyle::State_Enabled; | - |
1719 | cg = QPalette::Disabled; | - |
1720 | } else if (opt.state & QStyle::State_Active) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1721 | cg = QPalette::Active; | - |
1722 | } else { never executed: end of block | 0 |
1723 | cg = QPalette::Inactive; | - |
1724 | } never executed: end of block | 0 |
1725 | opt.palette.setCurrentColorGroup(cg); | - |
1726 | } never executed: end of block | 0 |
1727 | | - |
1728 | if (alternate) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1729 | if (d->current & 1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1730 | opt.features |= QStyleOptionViewItem::Alternate; | - |
1731 | } else { never executed: end of block | 0 |
1732 | opt.features &= ~QStyleOptionViewItem::Alternate; | - |
1733 | } never executed: end of block | 0 |
1734 | } | - |
1735 | | - |
1736 | | - |
1737 | | - |
1738 | | - |
1739 | | - |
1740 | if (d->isTreePosition(headerSection)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1741 | const int i = d->indentationForItem(d->current); | - |
1742 | QRect branches(reverse ? position + width - i : position, y, i, height); | - |
1743 | const bool setClipRect = branches.width() > width; | - |
1744 | if (setClipRect) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1745 | painter->save(); | - |
1746 | painter->setClipRect(QRect(position, y, width, height)); | - |
1747 | } never executed: end of block | 0 |
1748 | | - |
1749 | opt.rect = branches; | - |
1750 | style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this); | - |
1751 | | - |
1752 | | - |
1753 | | - |
1754 | QStyle::State oldState = opt.state; | - |
1755 | opt.state &= ~QStyle::State_Selected; | - |
1756 | opt.rect.setRect(reverse ? position : i + position, y, width - i, height); | - |
1757 | style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this); | - |
1758 | opt.state = oldState; | - |
1759 | | - |
1760 | if (d->indent != 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1761 | drawBranches(painter, branches, index); never executed: drawBranches(painter, branches, index); | 0 |
1762 | if (setClipRect)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1763 | painter->restore(); never executed: painter->restore(); | 0 |
1764 | } else { never executed: end of block | 0 |
1765 | QStyle::State oldState = opt.state; | - |
1766 | opt.state &= ~QStyle::State_Selected; | - |
1767 | opt.rect.setRect(position, y, width, height); | - |
1768 | style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this); | - |
1769 | opt.state = oldState; | - |
1770 | } never executed: end of block | 0 |
1771 | | - |
1772 | d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex); | - |
1773 | } never executed: end of block | 0 |
1774 | | - |
1775 | if (currentRowHasFocus) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1776 | QStyleOptionFocusRect o; | - |
1777 | o.QStyleOption::operator=(option); | - |
1778 | o.state |= QStyle::State_KeyboardFocusChange; | - |
1779 | QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1780 | ? QPalette::Normal : QPalette::Disabled; | - |
1781 | o.backgroundColor = option.palette.color(cg, d->selectionModel->isSelected(index) | - |
1782 | ? QPalette::Highlight : QPalette::Background); | - |
1783 | int x = 0; | - |
1784 | if (!option.showDecorationSelected)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1785 | x = header->sectionPosition(0) + d->indentationForItem(d->current); never executed: x = header->sectionPosition(0) + d->indentationForItem(d->current); | 0 |
1786 | QRect focusRect(x - header->offset(), y, header->length() - x, height); | - |
1787 | o.rect = style()->visualRect(layoutDirection(), d->viewport->rect(), focusRect); | - |
1788 | style()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter); | - |
1789 | | - |
1790 | | - |
1791 | if (allColumnsShowFocus && !option.showDecorationSelectedTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1792 | && header->sectionsMoved() && (header->visualIndex(0) != 0)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1793 | QRect sectionRect(0, y, header->sectionPosition(0), height); | - |
1794 | o.rect = style()->visualRect(layoutDirection(), d->viewport->rect(), sectionRect); | - |
1795 | style()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter); | - |
1796 | } never executed: end of block | 0 |
1797 | } never executed: end of block | 0 |
1798 | } never executed: end of block | 0 |
1799 | | - |
1800 | | - |
1801 | | - |
1802 | | - |
1803 | | - |
1804 | | - |
1805 | void QTreeView::drawBranches(QPainter *painter, const QRect &rect, | - |
1806 | const QModelIndex &index) const | - |
1807 | { | - |
1808 | Q_D(const QTreeView); | - |
1809 | const bool reverse = isRightToLeft(); | - |
1810 | const int indent = d->indent; | - |
1811 | const int outer = d->rootDecoration ? 0 : 1;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1812 | const int item = d->current; | - |
1813 | const QTreeViewItem &viewItem = d->viewItems.at(item); | - |
1814 | int level = viewItem.level; | - |
1815 | QRect primitive(reverse ? rect.left() : rect.right() + 1, rect.top(), indent, rect.height()); | - |
1816 | | - |
1817 | QModelIndex parent = index.parent(); | - |
1818 | QModelIndex current = parent; | - |
1819 | QModelIndex ancestor = current.parent(); | - |
1820 | | - |
1821 | QStyleOptionViewItem opt = viewOptions(); | - |
1822 | QStyle::State extraFlags = QStyle::State_None; | - |
1823 | if (isEnabled())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1824 | extraFlags |= QStyle::State_Enabled; never executed: extraFlags |= QStyle::State_Enabled; | 0 |
1825 | if (window()->isActiveWindow())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1826 | extraFlags |= QStyle::State_Active; never executed: extraFlags |= QStyle::State_Active; | 0 |
1827 | QPoint oldBO = painter->brushOrigin(); | - |
1828 | if (verticalScrollMode() == QAbstractItemView::ScrollPerPixel)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1829 | painter->setBrushOrigin(QPoint(0, verticalOffset())); never executed: painter->setBrushOrigin(QPoint(0, verticalOffset())); | 0 |
1830 | | - |
1831 | if (d->alternatingColors) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1832 | if (d->current & 1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1833 | opt.features |= QStyleOptionViewItem::Alternate; | - |
1834 | } else { never executed: end of block | 0 |
1835 | opt.features &= ~QStyleOptionViewItem::Alternate; | - |
1836 | } never executed: end of block | 0 |
1837 | } | - |
1838 | | - |
1839 | | - |
1840 | | - |
1841 | bool hoverRow = selectionBehavior() == QAbstractItemView::SelectRowsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1842 | && opt.showDecorationSelectedTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1843 | && index.parent() == d->hover.parent()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1844 | && index.row() == d->hover.row();TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1845 | | - |
1846 | if (d->selectionModel->isSelected(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1847 | extraFlags |= QStyle::State_Selected; never executed: extraFlags |= QStyle::State_Selected; | 0 |
1848 | | - |
1849 | if (level >= outer) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1850 | | - |
1851 | primitive.moveLeft(reverse ? primitive.left() : primitive.left() - indent); | - |
1852 | opt.rect = primitive; | - |
1853 | | - |
1854 | const bool expanded = viewItem.expanded; | - |
1855 | const bool children = viewItem.hasChildren; | - |
1856 | bool moreSiblings = viewItem.hasMoreSiblings; | - |
1857 | | - |
1858 | opt.state = QStyle::State_Item | extraFlags | - |
1859 | | (moreSiblings ? QStyle::State_Sibling : QStyle::State_None) | - |
1860 | | (children ? QStyle::State_Children : QStyle::State_None) | - |
1861 | | (expanded ? QStyle::State_Open : QStyle::State_None); | - |
1862 | if (hoverRow || item == d->hoverBranch)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1863 | opt.state |= QStyle::State_MouseOver; never executed: opt.state |= QStyle::State_MouseOver; | 0 |
1864 | else | - |
1865 | opt.state &= ~QStyle::State_MouseOver; never executed: opt.state &= ~QStyle::State_MouseOver; | 0 |
1866 | style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this); | - |
1867 | } never executed: end of block | 0 |
1868 | | - |
1869 | for (--level; level >= outer; --level) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1870 | primitive.moveLeft(reverse ? primitive.left() + indent : primitive.left() - indent); | - |
1871 | opt.rect = primitive; | - |
1872 | opt.state = extraFlags; | - |
1873 | bool moreSiblings = false; | - |
1874 | if (d->hiddenIndexes.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1875 | moreSiblings = (d->model->rowCount(ancestor) - 1 > current.row()); | - |
1876 | } else { never executed: end of block | 0 |
1877 | int successor = item + viewItem.total + 1; | - |
1878 | while (successor < d->viewItems.size()TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1879 | && d->viewItems.at(successor).level >= uint(level)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1880 | const QTreeViewItem &successorItem = d->viewItems.at(successor); | - |
1881 | if (successorItem.level == uint(level)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1882 | moreSiblings = true; | - |
1883 | break; never executed: break; | 0 |
1884 | } | - |
1885 | successor += successorItem.total + 1; | - |
1886 | } never executed: end of block | 0 |
1887 | } never executed: end of block | 0 |
1888 | if (moreSiblings)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1889 | opt.state |= QStyle::State_Sibling; never executed: opt.state |= QStyle::State_Sibling; | 0 |
1890 | if (hoverRow || item == d->hoverBranch)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1891 | opt.state |= QStyle::State_MouseOver; never executed: opt.state |= QStyle::State_MouseOver; | 0 |
1892 | else | - |
1893 | opt.state &= ~QStyle::State_MouseOver; never executed: opt.state &= ~QStyle::State_MouseOver; | 0 |
1894 | style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this); | - |
1895 | current = ancestor; | - |
1896 | ancestor = current.parent(); | - |
1897 | } never executed: end of block | 0 |
1898 | painter->setBrushOrigin(oldBO); | - |
1899 | } never executed: end of block | 0 |
1900 | | - |
1901 | | - |
1902 | | - |
1903 | | - |
1904 | void QTreeView::mousePressEvent(QMouseEvent *event) | - |
1905 | { | - |
1906 | Q_D(QTreeView); | - |
1907 | bool handled = false; | - |
1908 | if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonPress)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1909 | handled = d->expandOrCollapseItemAtPos(event->pos()); never executed: handled = d->expandOrCollapseItemAtPos(event->pos()); | 0 |
1910 | if (!handled && d->itemDecorationAt(event->pos()) == -1)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1911 | QAbstractItemView::mousePressEvent(event); never executed: QAbstractItemView::mousePressEvent(event); | 0 |
1912 | } never executed: end of block | 0 |
1913 | | - |
1914 | | - |
1915 | | - |
1916 | | - |
1917 | void QTreeView::mouseReleaseEvent(QMouseEvent *event) | - |
1918 | { | - |
1919 | Q_D(QTreeView); | - |
1920 | if (d->itemDecorationAt(event->pos()) == -1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1921 | QAbstractItemView::mouseReleaseEvent(event); | - |
1922 | } else { never executed: end of block | 0 |
1923 | if (state() == QAbstractItemView::DragSelectingState || state() == QAbstractItemView::DraggingState)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1924 | setState(QAbstractItemView::NoState); never executed: setState(QAbstractItemView::NoState); | 0 |
1925 | if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonRelease)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1926 | d->expandOrCollapseItemAtPos(event->pos()); never executed: d->expandOrCollapseItemAtPos(event->pos()); | 0 |
1927 | } never executed: end of block | 0 |
1928 | } | - |
1929 | | - |
1930 | | - |
1931 | | - |
1932 | | - |
1933 | void QTreeView::mouseDoubleClickEvent(QMouseEvent *event) | - |
1934 | { | - |
1935 | Q_D(QTreeView); | - |
1936 | if (state() != NoState || !d->viewport->rect().contains(event->pos()))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1937 | return; never executed: return; | 0 |
1938 | | - |
1939 | int i = d->itemDecorationAt(event->pos()); | - |
1940 | if (i == -1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1941 | i = d->itemAtCoordinate(event->y()); | - |
1942 | if (i == -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1943 | return; never executed: return; | 0 |
1944 | | - |
1945 | const QPersistentModelIndex firstColumnIndex = d->viewItems.at(i).index; | - |
1946 | const QPersistentModelIndex persistent = indexAt(event->pos()); | - |
1947 | | - |
1948 | if (d->pressedIndex != persistent) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1949 | mousePressEvent(event); | - |
1950 | return; never executed: return; | 0 |
1951 | } | - |
1952 | | - |
1953 | | - |
1954 | emit doubleClicked(persistent); | - |
1955 | | - |
1956 | if (!persistent.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1957 | return; never executed: return; | 0 |
1958 | | - |
1959 | if (edit(persistent, DoubleClicked, event) || state() != NoState)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1960 | return; never executed: return; | 0 |
1961 | | - |
1962 | if (!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1963 | emit activated(persistent); never executed: activated(persistent); | 0 |
1964 | | - |
1965 | d->executePostedLayout(); | - |
1966 | if (d->itemsExpandableTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1967 | && d->expandsOnDoubleClickTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1968 | && d->hasVisibleChildren(persistent)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1969 | if (!((i < d->viewItems.count()) && (d->viewItems.at(i).index == firstColumnIndex))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1970 | | - |
1971 | for (i = 0; i < d->viewItems.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1972 | if (d->viewItems.at(i).index == firstColumnIndex)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1973 | break; never executed: break; | 0 |
1974 | } never executed: end of block | 0 |
1975 | if (i == d->viewItems.count())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1976 | return; never executed: return; | 0 |
1977 | } never executed: end of block | 0 |
1978 | if (d->viewItems.at(i).expanded)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1979 | d->collapse(i, true); never executed: d->collapse(i, true); | 0 |
1980 | else | - |
1981 | d->expand(i, true); never executed: d->expand(i, true); | 0 |
1982 | updateGeometries(); | - |
1983 | viewport()->update(); | - |
1984 | } never executed: end of block | 0 |
1985 | } never executed: end of block | 0 |
1986 | } never executed: end of block | 0 |
1987 | | - |
1988 | | - |
1989 | | - |
1990 | | - |
1991 | void QTreeView::mouseMoveEvent(QMouseEvent *event) | - |
1992 | { | - |
1993 | Q_D(QTreeView); | - |
1994 | if (d->itemDecorationAt(event->pos()) == -1) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1995 | QAbstractItemView::mouseMoveEvent(event); never executed: QAbstractItemView::mouseMoveEvent(event); | 0 |
1996 | } never executed: end of block | 0 |
1997 | | - |
1998 | | - |
1999 | | - |
2000 | | - |
2001 | void QTreeView::keyPressEvent(QKeyEvent *event) | - |
2002 | { | - |
2003 | Q_D(QTreeView); | - |
2004 | QModelIndex current = currentIndex(); | - |
2005 | | - |
2006 | if (d->isIndexValid(current) && d->model && d->itemsExpandable) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2007 | switch (event->key()) { | - |
2008 | case Qt::Key_Asterisk: { never executed: case Qt::Key_Asterisk: | 0 |
2009 | QStack<QModelIndex> parents; | - |
2010 | parents.push(current); | - |
2011 | while (!parents.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2012 | QModelIndex parent = parents.pop(); | - |
2013 | for (int row = 0; row < d->model->rowCount(parent); ++row) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2014 | QModelIndex child = d->model->index(row, 0, parent); | - |
2015 | if (!d->isIndexValid(child))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2016 | break; never executed: break; | 0 |
2017 | parents.push(child); | - |
2018 | expand(child); | - |
2019 | } never executed: end of block | 0 |
2020 | } never executed: end of block | 0 |
2021 | expand(current); | - |
2022 | break; } never executed: break; | 0 |
2023 | case Qt::Key_Plus: never executed: case Qt::Key_Plus: | 0 |
2024 | expand(current); | - |
2025 | break; never executed: break; | 0 |
2026 | case Qt::Key_Minus: never executed: case Qt::Key_Minus: | 0 |
2027 | collapse(current); | - |
2028 | break; never executed: break; | 0 |
2029 | } | - |
2030 | } never executed: end of block | 0 |
2031 | | - |
2032 | QAbstractItemView::keyPressEvent(event); | - |
2033 | } never executed: end of block | 0 |
2034 | | - |
2035 | | - |
2036 | | - |
2037 | | - |
2038 | QModelIndex QTreeView::indexAt(const QPoint &point) const | - |
2039 | { | - |
2040 | Q_D(const QTreeView); | - |
2041 | d->executePostedLayout(); | - |
2042 | | - |
2043 | int visualIndex = d->itemAtCoordinate(point.y()); | - |
2044 | QModelIndex idx = d->modelIndex(visualIndex); | - |
2045 | if (!idx.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2046 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
2047 | | - |
2048 | if (d->viewItems.at(visualIndex).spanning)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2049 | return idx; never executed: return idx; | 0 |
2050 | | - |
2051 | int column = d->columnAt(point.x()); | - |
2052 | if (column == idx.column())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2053 | return idx; never executed: return idx; | 0 |
2054 | if (column < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2055 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
2056 | return idx.sibling(idx.row(), column); never executed: return idx.sibling(idx.row(), column); | 0 |
2057 | } | - |
2058 | | - |
2059 | | - |
2060 | | - |
2061 | | - |
2062 | QModelIndex QTreeView::indexAbove(const QModelIndex &index) const | - |
2063 | { | - |
2064 | Q_D(const QTreeView); | - |
2065 | if (!d->isIndexValid(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2066 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
2067 | d->executePostedLayout(); | - |
2068 | int i = d->viewIndex(index); | - |
2069 | if (--i < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2070 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
2071 | const QModelIndex firstColumnIndex = d->viewItems.at(i).index; | - |
2072 | return firstColumnIndex.sibling(firstColumnIndex.row(), index.column()); never executed: return firstColumnIndex.sibling(firstColumnIndex.row(), index.column()); | 0 |
2073 | } | - |
2074 | | - |
2075 | | - |
2076 | | - |
2077 | | - |
2078 | QModelIndex QTreeView::indexBelow(const QModelIndex &index) const | - |
2079 | { | - |
2080 | Q_D(const QTreeView); | - |
2081 | if (!d->isIndexValid(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2082 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
2083 | d->executePostedLayout(); | - |
2084 | int i = d->viewIndex(index); | - |
2085 | if (++i >= d->viewItems.count())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2086 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
2087 | const QModelIndex firstColumnIndex = d->viewItems.at(i).index; | - |
2088 | return firstColumnIndex.sibling(firstColumnIndex.row(), index.column()); never executed: return firstColumnIndex.sibling(firstColumnIndex.row(), index.column()); | 0 |
2089 | } | - |
2090 | | - |
2091 | | - |
2092 | | - |
2093 | | - |
2094 | | - |
2095 | | - |
2096 | void QTreeView::doItemsLayout() | - |
2097 | { | - |
2098 | Q_D(QTreeView); | - |
2099 | if (!d->customIndent) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2100 | | - |
2101 | | - |
2102 | | - |
2103 | d->updateIndentationFromStyle(); | - |
2104 | } never executed: end of block | 0 |
2105 | if (d->hasRemovedItems) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2106 | | - |
2107 | d->hasRemovedItems = false; | - |
2108 | QSet<QPersistentModelIndex>::iterator it = d->expandedIndexes.begin(); | - |
2109 | while (it != d->expandedIndexes.end()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2110 | if (!it->isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2111 | it = d->expandedIndexes.erase(it); never executed: it = d->expandedIndexes.erase(it); | 0 |
2112 | else | - |
2113 | ++it; never executed: ++it; | 0 |
2114 | } | - |
2115 | it = d->hiddenIndexes.begin(); | - |
2116 | while (it != d->hiddenIndexes.end()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2117 | if (!it->isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2118 | it = d->hiddenIndexes.erase(it); never executed: it = d->hiddenIndexes.erase(it); | 0 |
2119 | else | - |
2120 | ++it; never executed: ++it; | 0 |
2121 | } | - |
2122 | } never executed: end of block | 0 |
2123 | d->viewItems.clear(); | - |
2124 | QModelIndex parent = d->root; | - |
2125 | if (d->model->hasChildren(parent)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2126 | d->layout(-1); | - |
2127 | } never executed: end of block | 0 |
2128 | QAbstractItemView::doItemsLayout(); | - |
2129 | d->header->doItemsLayout(); | - |
2130 | } never executed: end of block | 0 |
2131 | | - |
2132 | | - |
2133 | | - |
2134 | | - |
2135 | void QTreeView::reset() | - |
2136 | { | - |
2137 | Q_D(QTreeView); | - |
2138 | d->expandedIndexes.clear(); | - |
2139 | d->hiddenIndexes.clear(); | - |
2140 | d->spanningIndexes.clear(); | - |
2141 | d->viewItems.clear(); | - |
2142 | QAbstractItemView::reset(); | - |
2143 | } never executed: end of block | 0 |
2144 | | - |
2145 | | - |
2146 | | - |
2147 | | - |
2148 | | - |
2149 | | - |
2150 | | - |
2151 | | - |
2152 | | - |
2153 | int QTreeView::horizontalOffset() const | - |
2154 | { | - |
2155 | Q_D(const QTreeView); | - |
2156 | return d->header->offset(); never executed: return d->header->offset(); | 0 |
2157 | } | - |
2158 | | - |
2159 | | - |
2160 | | - |
2161 | | - |
2162 | | - |
2163 | | - |
2164 | int QTreeView::verticalOffset() const | - |
2165 | { | - |
2166 | Q_D(const QTreeView); | - |
2167 | if (d->verticalScrollMode == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2168 | if (d->uniformRowHeights)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2169 | return verticalScrollBar()->value() * d->defaultItemHeight; never executed: return verticalScrollBar()->value() * d->defaultItemHeight; | 0 |
2170 | | - |
2171 | | - |
2172 | | - |
2173 | d->executePostedLayout(); | - |
2174 | int offset = 0; | - |
2175 | for (int i = 0; i < d->viewItems.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2176 | if (i == verticalScrollBar()->value())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2177 | return offset; never executed: return offset; | 0 |
2178 | offset += d->itemHeight(i); | - |
2179 | } never executed: end of block | 0 |
2180 | return 0; never executed: return 0; | 0 |
2181 | } | - |
2182 | | - |
2183 | return verticalScrollBar()->value(); never executed: return verticalScrollBar()->value(); | 0 |
2184 | } | - |
2185 | | - |
2186 | | - |
2187 | | - |
2188 | | - |
2189 | | - |
2190 | QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) | - |
2191 | { | - |
2192 | Q_D(QTreeView); | - |
2193 | Q_UNUSED(modifiers); | - |
2194 | | - |
2195 | d->executePostedLayout(); | - |
2196 | | - |
2197 | QModelIndex current = currentIndex(); | - |
2198 | if (!current.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2199 | int i = d->below(-1); | - |
2200 | int c = 0; | - |
2201 | while (c < d->header->count() && d->header->isSectionHidden(d->header->logicalIndex(c)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2202 | ++c; never executed: ++c; | 0 |
2203 | if (i < d->viewItems.count() && c < d->header->count()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2204 | return d->modelIndex(i, d->header->logicalIndex(c)); never executed: return d->modelIndex(i, d->header->logicalIndex(c)); | 0 |
2205 | } | - |
2206 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
2207 | } | - |
2208 | int vi = -1; | - |
2209 | #if defined(Q_DEAD_CODE_FROM_QT4_MAC) && !defined(QT_NO_STYLE_MAC) | - |
2210 | | - |
2211 | if (d->selectionMode == QAbstractItemView::ExtendedSelection | - |
2212 | && d->selectionModel | - |
2213 | && d->selectionModel->hasSelection()) { | - |
2214 | | - |
2215 | const bool moveUpDown = (cursorAction == MoveUp || cursorAction == MoveDown); | - |
2216 | const bool moveNextPrev = (cursorAction == MoveNext || cursorAction == MovePrevious); | - |
2217 | const bool contiguousSelection = moveUpDown && (modifiers & Qt::ShiftModifier); | - |
2218 | | - |
2219 | | - |
2220 | if (!contiguousSelection && (moveUpDown || moveNextPrev)) { | - |
2221 | | - |
2222 | | - |
2223 | const bool useTopIndex = (cursorAction == MoveUp || cursorAction == MovePrevious); | - |
2224 | int index = useTopIndex ? INT_MAX : INT_MIN; | - |
2225 | const QItemSelection selection = d->selectionModel->selection(); | - |
2226 | for (int i = 0; i < selection.count(); ++i) { | - |
2227 | const QItemSelectionRange &range = selection.at(i); | - |
2228 | int candidate = d->viewIndex(useTopIndex ? range.topLeft() : range.bottomRight()); | - |
2229 | if (candidate >= 0) | - |
2230 | index = useTopIndex ? qMin(index, candidate) : qMax(index, candidate); | - |
2231 | } | - |
2232 | | - |
2233 | if (index >= 0 && index < INT_MAX) | - |
2234 | vi = index; | - |
2235 | } | - |
2236 | } | - |
2237 | #endif | - |
2238 | if (vi < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2239 | vi = qMax(0, d->viewIndex(current)); never executed: vi = qMax(0, d->viewIndex(current)); | 0 |
2240 | | - |
2241 | if (isRightToLeft()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2242 | if (cursorAction == MoveRight)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2243 | cursorAction = MoveLeft; never executed: cursorAction = MoveLeft; | 0 |
2244 | else if (cursorAction == MoveLeft)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2245 | cursorAction = MoveRight; never executed: cursorAction = MoveRight; | 0 |
2246 | } never executed: end of block | 0 |
2247 | switch (cursorAction) { | - |
2248 | case MoveNext: never executed: case MoveNext: | 0 |
2249 | case MoveDown: never executed: case MoveDown: | 0 |
2250 | #ifdef QT_KEYPAD_NAVIGATION | - |
2251 | if (vi == d->viewItems.count()-1 && QApplication::keypadNavigationEnabled()) | - |
2252 | return d->model->index(0, current.column(), d->root); | - |
2253 | #endif | - |
2254 | return d->modelIndex(d->below(vi), current.column()); never executed: return d->modelIndex(d->below(vi), current.column()); | 0 |
2255 | case MovePrevious: never executed: case MovePrevious: | 0 |
2256 | case MoveUp: never executed: case MoveUp: | 0 |
2257 | #ifdef QT_KEYPAD_NAVIGATION | - |
2258 | if (vi == 0 && QApplication::keypadNavigationEnabled()) | - |
2259 | return d->modelIndex(d->viewItems.count() - 1, current.column()); | - |
2260 | #endif | - |
2261 | return d->modelIndex(d->above(vi), current.column()); never executed: return d->modelIndex(d->above(vi), current.column()); | 0 |
2262 | case MoveLeft: { never executed: case MoveLeft: | 0 |
2263 | QScrollBar *sb = horizontalScrollBar(); | - |
2264 | if (vi < d->viewItems.count() && d->viewItems.at(vi).expanded && d->itemsExpandable && sb->value() == sb->minimum()) {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 |
2265 | d->collapse(vi, true); | - |
2266 | d->moveCursorUpdatedView = true; | - |
2267 | } else { never executed: end of block | 0 |
2268 | bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this); | - |
2269 | if (descend) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2270 | QModelIndex par = current.parent(); | - |
2271 | if (par.isValid() && par != rootIndex())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2272 | return par; never executed: return par; | 0 |
2273 | else | - |
2274 | descend = false; never executed: descend = false; | 0 |
2275 | } | - |
2276 | if (!descend) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2277 | if (d->selectionBehavior == SelectItems || d->selectionBehavior == SelectColumns) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2278 | int visualColumn = d->header->visualIndex(current.column()) - 1; | - |
2279 | while (visualColumn >= 0 && isColumnHidden(d->header->logicalIndex(visualColumn)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2280 | visualColumn--; never executed: visualColumn--; | 0 |
2281 | int newColumn = d->header->logicalIndex(visualColumn); | - |
2282 | QModelIndex next = current.sibling(current.row(), newColumn); | - |
2283 | if (next.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2284 | return next; never executed: return next; | 0 |
2285 | } never executed: end of block | 0 |
2286 | | - |
2287 | int oldValue = sb->value(); | - |
2288 | sb->setValue(sb->value() - sb->singleStep()); | - |
2289 | if (oldValue != sb->value())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2290 | d->moveCursorUpdatedView = true; never executed: d->moveCursorUpdatedView = true; | 0 |
2291 | } never executed: end of block | 0 |
2292 | | - |
2293 | } never executed: end of block | 0 |
2294 | updateGeometries(); | - |
2295 | viewport()->update(); | - |
2296 | break; never executed: break; | 0 |
2297 | } | - |
2298 | case MoveRight: never executed: case MoveRight: | 0 |
2299 | if (vi < d->viewItems.count() && !d->viewItems.at(vi).expanded && d->itemsExpandableTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2300 | && d->hasVisibleChildren(d->viewItems.at(vi).index)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2301 | d->expand(vi, true); | - |
2302 | d->moveCursorUpdatedView = true; | - |
2303 | } else { never executed: end of block | 0 |
2304 | bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this); | - |
2305 | if (descend) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2306 | QModelIndex idx = d->modelIndex(d->below(vi)); | - |
2307 | if (idx.parent() == current)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2308 | return idx; never executed: return idx; | 0 |
2309 | else | - |
2310 | descend = false; never executed: descend = false; | 0 |
2311 | } | - |
2312 | if (!descend) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2313 | if (d->selectionBehavior == SelectItems || d->selectionBehavior == SelectColumns) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2314 | int visualColumn = d->header->visualIndex(current.column()) + 1; | - |
2315 | while (visualColumn < d->model->columnCount(current.parent()) && isColumnHidden(d->header->logicalIndex(visualColumn)))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2316 | visualColumn++; never executed: visualColumn++; | 0 |
2317 | const int newColumn = d->header->logicalIndex(visualColumn); | - |
2318 | const QModelIndex next = current.sibling(current.row(), newColumn); | - |
2319 | if (next.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2320 | return next; never executed: return next; | 0 |
2321 | } never executed: end of block | 0 |
2322 | | - |
2323 | | - |
2324 | QScrollBar *sb = horizontalScrollBar(); | - |
2325 | int oldValue = sb->value(); | - |
2326 | sb->setValue(sb->value() + sb->singleStep()); | - |
2327 | if (oldValue != sb->value())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2328 | d->moveCursorUpdatedView = true; never executed: d->moveCursorUpdatedView = true; | 0 |
2329 | } never executed: end of block | 0 |
2330 | } never executed: end of block | 0 |
2331 | updateGeometries(); | - |
2332 | viewport()->update(); | - |
2333 | break; never executed: break; | 0 |
2334 | case MovePageUp: never executed: case MovePageUp: | 0 |
2335 | return d->modelIndex(d->pageUp(vi), current.column()); never executed: return d->modelIndex(d->pageUp(vi), current.column()); | 0 |
2336 | case MovePageDown: never executed: case MovePageDown: | 0 |
2337 | return d->modelIndex(d->pageDown(vi), current.column()); never executed: return d->modelIndex(d->pageDown(vi), current.column()); | 0 |
2338 | case MoveHome: never executed: case MoveHome: | 0 |
2339 | return d->model->index(0, current.column(), d->root); never executed: return d->model->index(0, current.column(), d->root); | 0 |
2340 | case MoveEnd: never executed: case MoveEnd: | 0 |
2341 | return d->modelIndex(d->viewItems.count() - 1, current.column()); never executed: return d->modelIndex(d->viewItems.count() - 1, current.column()); | 0 |
2342 | } | - |
2343 | return current; never executed: return current; | 0 |
2344 | } | - |
2345 | | - |
2346 | | - |
2347 | | - |
2348 | | - |
2349 | | - |
2350 | | - |
2351 | | - |
2352 | void QTreeView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) | - |
2353 | { | - |
2354 | Q_D(QTreeView); | - |
2355 | if (!selectionModel() || rect.isNull())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2356 | return; never executed: return; | 0 |
2357 | | - |
2358 | d->executePostedLayout(); | - |
2359 | QPoint tl(isRightToLeft() ? qMax(rect.left(), rect.right()) | - |
2360 | : qMin(rect.left(), rect.right()), qMin(rect.top(), rect.bottom())); | - |
2361 | QPoint br(isRightToLeft() ? qMin(rect.left(), rect.right()) : | - |
2362 | qMax(rect.left(), rect.right()), qMax(rect.top(), rect.bottom())); | - |
2363 | QModelIndex topLeft = indexAt(tl); | - |
2364 | QModelIndex bottomRight = indexAt(br); | - |
2365 | if (!topLeft.isValid() && !bottomRight.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2366 | if (command & QItemSelectionModel::Clear)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2367 | selectionModel()->clear(); never executed: selectionModel()->clear(); | 0 |
2368 | return; never executed: return; | 0 |
2369 | } | - |
2370 | if (!topLeft.isValid() && !d->viewItems.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2371 | topLeft = d->viewItems.first().index; never executed: topLeft = d->viewItems.first().index; | 0 |
2372 | if (!bottomRight.isValid() && !d->viewItems.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2373 | const int column = d->header->logicalIndex(d->header->count() - 1); | - |
2374 | const QModelIndex index = d->viewItems.last().index; | - |
2375 | bottomRight = index.sibling(index.row(), column); | - |
2376 | } never executed: end of block | 0 |
2377 | | - |
2378 | if (!d->isIndexEnabled(topLeft) || !d->isIndexEnabled(bottomRight))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2379 | return; never executed: return; | 0 |
2380 | | - |
2381 | d->select(topLeft, bottomRight, command); | - |
2382 | } never executed: end of block | 0 |
2383 | | - |
2384 | | - |
2385 | | - |
2386 | | - |
2387 | | - |
2388 | | - |
2389 | | - |
2390 | | - |
2391 | QRegion QTreeView::visualRegionForSelection(const QItemSelection &selection) const | - |
2392 | { | - |
2393 | Q_D(const QTreeView); | - |
2394 | if (selection.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2395 | return QRegion(); never executed: return QRegion(); | 0 |
2396 | | - |
2397 | QRegion selectionRegion; | - |
2398 | const QRect &viewportRect = d->viewport->rect(); | - |
2399 | for (int i = 0; i < selection.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2400 | QItemSelectionRange range = selection.at(i); | - |
2401 | if (!range.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2402 | continue; never executed: continue; | 0 |
2403 | QModelIndex parent = range.parent(); | - |
2404 | QModelIndex leftIndex = range.topLeft(); | - |
2405 | int columnCount = d->model->columnCount(parent); | - |
2406 | while (leftIndex.isValid() && isIndexHidden(leftIndex)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2407 | if (leftIndex.column() + 1 < columnCount)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2408 | leftIndex = d->model->index(leftIndex.row(), leftIndex.column() + 1, parent); never executed: leftIndex = d->model->index(leftIndex.row(), leftIndex.column() + 1, parent); | 0 |
2409 | else | - |
2410 | leftIndex = QModelIndex(); never executed: leftIndex = QModelIndex(); | 0 |
2411 | } | - |
2412 | if (!leftIndex.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2413 | continue; never executed: continue; | 0 |
2414 | const QRect leftRect = visualRect(leftIndex); | - |
2415 | int top = leftRect.top(); | - |
2416 | QModelIndex rightIndex = range.bottomRight(); | - |
2417 | while (rightIndex.isValid() && isIndexHidden(rightIndex)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2418 | if (rightIndex.column() - 1 >= 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2419 | rightIndex = d->model->index(rightIndex.row(), rightIndex.column() - 1, parent); never executed: rightIndex = d->model->index(rightIndex.row(), rightIndex.column() - 1, parent); | 0 |
2420 | else | - |
2421 | rightIndex = QModelIndex(); never executed: rightIndex = QModelIndex(); | 0 |
2422 | } | - |
2423 | if (!rightIndex.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2424 | continue; never executed: continue; | 0 |
2425 | const QRect rightRect = visualRect(rightIndex); | - |
2426 | int bottom = rightRect.bottom(); | - |
2427 | if (top > bottom)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2428 | qSwap<int>(top, bottom); never executed: qSwap<int>(top, bottom); | 0 |
2429 | int height = bottom - top + 1; | - |
2430 | if (d->header->sectionsMoved()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2431 | for (int c = range.left(); c <= range.right(); ++c) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2432 | const QRect rangeRect(columnViewportPosition(c), top, columnWidth(c), height); | - |
2433 | if (viewportRect.intersects(rangeRect))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2434 | selectionRegion += rangeRect; never executed: selectionRegion += rangeRect; | 0 |
2435 | } never executed: end of block | 0 |
2436 | } else { never executed: end of block | 0 |
2437 | QRect combined = leftRect|rightRect; | - |
2438 | combined.setX(columnViewportPosition(isRightToLeft() ? range.right() : range.left())); | - |
2439 | if (viewportRect.intersects(combined))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2440 | selectionRegion += combined; never executed: selectionRegion += combined; | 0 |
2441 | } never executed: end of block | 0 |
2442 | } | - |
2443 | return selectionRegion; never executed: return selectionRegion; | 0 |
2444 | } | - |
2445 | | - |
2446 | | - |
2447 | | - |
2448 | | - |
2449 | QModelIndexList QTreeView::selectedIndexes() const | - |
2450 | { | - |
2451 | QModelIndexList viewSelected; | - |
2452 | QModelIndexList modelSelected; | - |
2453 | if (selectionModel())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2454 | modelSelected = selectionModel()->selectedIndexes(); never executed: modelSelected = selectionModel()->selectedIndexes(); | 0 |
2455 | for (int i = 0; i < modelSelected.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2456 | | - |
2457 | QModelIndex index = modelSelected.at(i); | - |
2458 | while (index.isValid() && !isIndexHidden(index))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2459 | index = index.parent(); never executed: index = index.parent(); | 0 |
2460 | if (index.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2461 | continue; never executed: continue; | 0 |
2462 | viewSelected.append(modelSelected.at(i)); | - |
2463 | } never executed: end of block | 0 |
2464 | return viewSelected; never executed: return viewSelected; | 0 |
2465 | } | - |
2466 | | - |
2467 | | - |
2468 | | - |
2469 | | - |
2470 | void QTreeView::scrollContentsBy(int dx, int dy) | - |
2471 | { | - |
2472 | Q_D(QTreeView); | - |
2473 | | - |
2474 | d->delayedAutoScroll.stop(); | - |
2475 | | - |
2476 | dx = isRightToLeft() ? -dx : dx;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2477 | if (dx) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2478 | int oldOffset = d->header->offset(); | - |
2479 | d->header->d_func()->setScrollOffset(horizontalScrollBar(), horizontalScrollMode()); | - |
2480 | if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2481 | int newOffset = d->header->offset(); | - |
2482 | dx = isRightToLeft() ? newOffset - oldOffset : oldOffset - newOffset;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2483 | } never executed: end of block | 0 |
2484 | } never executed: end of block | 0 |
2485 | | - |
2486 | const int itemHeight = d->defaultItemHeight <= 0 ? sizeHintForRow(0) : d->defaultItemHeight;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2487 | if (d->viewItems.isEmpty() || itemHeight == 0)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2488 | return; never executed: return; | 0 |
2489 | | - |
2490 | | - |
2491 | int viewCount = d->viewport->height() / itemHeight; | - |
2492 | int maxDeltaY = qMin(d->viewItems.count(), viewCount); | - |
2493 | | - |
2494 | if (qAbs(dy) > qAbs(maxDeltaY) && d->editorIndexHash.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2495 | verticalScrollBar()->update(); | - |
2496 | d->viewport->update(); | - |
2497 | return; never executed: return; | 0 |
2498 | } | - |
2499 | | - |
2500 | if (dy && verticalScrollMode() == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2501 | int currentScrollbarValue = verticalScrollBar()->value(); | - |
2502 | int previousScrollbarValue = currentScrollbarValue + dy; | - |
2503 | int currentViewIndex = currentScrollbarValue; | - |
2504 | int previousViewIndex = previousScrollbarValue; | - |
2505 | const QVector<QTreeViewItem> viewItems = d->viewItems; | - |
2506 | dy = 0; | - |
2507 | if (previousViewIndex < currentViewIndex) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2508 | for (int i = previousViewIndex; i < currentViewIndex; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2509 | if (i < d->viewItems.count())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2510 | dy -= d->itemHeight(i); never executed: dy -= d->itemHeight(i); | 0 |
2511 | } never executed: end of block | 0 |
2512 | } else if (previousViewIndex > currentViewIndex) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2513 | for (int i = previousViewIndex - 1; i >= currentViewIndex; --i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2514 | if (i < d->viewItems.count())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2515 | dy += d->itemHeight(i); never executed: dy += d->itemHeight(i); | 0 |
2516 | } never executed: end of block | 0 |
2517 | } never executed: end of block | 0 |
2518 | } never executed: end of block | 0 |
2519 | | - |
2520 | d->scrollContentsBy(dx, dy); | - |
2521 | } never executed: end of block | 0 |
2522 | | - |
2523 | | - |
2524 | | - |
2525 | | - |
2526 | void QTreeView::columnMoved() | - |
2527 | { | - |
2528 | Q_D(QTreeView); | - |
2529 | updateEditorGeometries(); | - |
2530 | d->viewport->update(); | - |
2531 | } never executed: end of block | 0 |
2532 | | - |
2533 | | - |
2534 | | - |
2535 | | - |
2536 | void QTreeView::reexpand() | - |
2537 | { | - |
2538 | | - |
2539 | } | - |
2540 | | - |
2541 | | - |
2542 | | - |
2543 | | - |
2544 | | - |
2545 | void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) | - |
2546 | { | - |
2547 | Q_D(QTreeView); | - |
2548 | | - |
2549 | if (d->delayedPendingLayout) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2550 | QAbstractItemView::rowsInserted(parent, start, end); | - |
2551 | return; never executed: return; | 0 |
2552 | } | - |
2553 | | - |
2554 | | - |
2555 | if (parent.column() != 0 && parent.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2556 | QAbstractItemView::rowsInserted(parent, start, end); | - |
2557 | return; never executed: return; | 0 |
2558 | } | - |
2559 | | - |
2560 | const int parentRowCount = d->model->rowCount(parent); | - |
2561 | const int delta = end - start + 1; | - |
2562 | if (parent != d->root && !d->isIndexExpanded(parent) && parentRowCount > delta) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2563 | QAbstractItemView::rowsInserted(parent, start, end); | - |
2564 | return; never executed: return; | 0 |
2565 | } | - |
2566 | | - |
2567 | const int parentItem = d->viewIndex(parent); | - |
2568 | if (((parentItem != -1) && d->viewItems.at(parentItem).expanded)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2569 | || (parent == d->root)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2570 | d->doDelayedItemsLayout(); | - |
2571 | } else if (parentItem != -1 && parentRowCount == delta) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2572 | | - |
2573 | d->viewItems[parentItem].hasChildren = true; | - |
2574 | viewport()->update(); | - |
2575 | } never executed: end of block | 0 |
2576 | QAbstractItemView::rowsInserted(parent, start, end); | - |
2577 | } never executed: end of block | 0 |
2578 | | - |
2579 | | - |
2580 | | - |
2581 | | - |
2582 | | - |
2583 | void QTreeView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) | - |
2584 | { | - |
2585 | Q_D(QTreeView); | - |
2586 | QAbstractItemView::rowsAboutToBeRemoved(parent, start, end); | - |
2587 | d->viewItems.clear(); | - |
2588 | } never executed: end of block | 0 |
2589 | | - |
2590 | | - |
2591 | | - |
2592 | | - |
2593 | | - |
2594 | | - |
2595 | | - |
2596 | void QTreeView::rowsRemoved(const QModelIndex &parent, int start, int end) | - |
2597 | { | - |
2598 | Q_D(QTreeView); | - |
2599 | d->viewItems.clear(); | - |
2600 | d->doDelayedItemsLayout(); | - |
2601 | d->hasRemovedItems = true; | - |
2602 | d->_q_rowsRemoved(parent, start, end); | - |
2603 | } never executed: end of block | 0 |
2604 | | - |
2605 | | - |
2606 | | - |
2607 | | - |
2608 | | - |
2609 | void QTreeView::columnCountChanged(int oldCount, int newCount) | - |
2610 | { | - |
2611 | Q_D(QTreeView); | - |
2612 | if (oldCount == 0 && newCount > 0) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2613 | | - |
2614 | d->doDelayedItemsLayout(); | - |
2615 | } never executed: end of block | 0 |
2616 | | - |
2617 | if (isVisible())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2618 | updateGeometries(); never executed: updateGeometries(); | 0 |
2619 | viewport()->update(); | - |
2620 | } never executed: end of block | 0 |
2621 | | - |
2622 | | - |
2623 | | - |
2624 | | - |
2625 | | - |
2626 | | - |
2627 | void QTreeView::resizeColumnToContents(int column) | - |
2628 | { | - |
2629 | Q_D(QTreeView); | - |
2630 | d->executePostedLayout(); | - |
2631 | if (column < 0 || column >= d->header->count())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2632 | return; never executed: return; | 0 |
2633 | int contents = sizeHintForColumn(column); | - |
2634 | int header = d->header->isHidden() ? 0 : d->header->sectionSizeHint(column);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2635 | d->header->resizeSection(column, qMax(contents, header)); | - |
2636 | } never executed: end of block | 0 |
2637 | | - |
2638 | | - |
2639 | | - |
2640 | | - |
2641 | | - |
2642 | | - |
2643 | | - |
2644 | void QTreeView::sortByColumn(int column) | - |
2645 | { | - |
2646 | Q_D(QTreeView); | - |
2647 | sortByColumn(column, d->header->sortIndicatorOrder()); | - |
2648 | } never executed: end of block | 0 |
2649 | | - |
2650 | | - |
2651 | | - |
2652 | | - |
2653 | | - |
2654 | | - |
2655 | | - |
2656 | | - |
2657 | | - |
2658 | | - |
2659 | | - |
2660 | | - |
2661 | void QTreeView::sortByColumn(int column, Qt::SortOrder order) | - |
2662 | { | - |
2663 | Q_D(QTreeView); | - |
2664 | | - |
2665 | | - |
2666 | d->header->setSortIndicator(column, order); | - |
2667 | | - |
2668 | if (!d->sortingEnabled)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2669 | d->model->sort(column, order); never executed: d->model->sort(column, order); | 0 |
2670 | } never executed: end of block | 0 |
2671 | | - |
2672 | | - |
2673 | | - |
2674 | | - |
2675 | void QTreeView::selectAll() | - |
2676 | { | - |
2677 | Q_D(QTreeView); | - |
2678 | if (!selectionModel())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2679 | return; never executed: return; | 0 |
2680 | SelectionMode mode = d->selectionMode; | - |
2681 | d->executePostedLayout(); | - |
2682 | if (mode != SingleSelection && mode != NoSelection && !d->viewItems.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2683 | const QModelIndex &idx = d->viewItems.last().index; | - |
2684 | QModelIndex lastItemIndex = idx.sibling(idx.row(), d->model->columnCount(idx.parent()) - 1); | - |
2685 | d->select(d->viewItems.first().index, lastItemIndex, | - |
2686 | QItemSelectionModel::ClearAndSelect | - |
2687 | |QItemSelectionModel::Rows); | - |
2688 | } never executed: end of block | 0 |
2689 | } never executed: end of block | 0 |
2690 | | - |
2691 | | - |
2692 | | - |
2693 | | - |
2694 | QSize QTreeView::viewportSizeHint() const | - |
2695 | { | - |
2696 | Q_D(const QTreeView); | - |
2697 | d->executePostedLayout(); | - |
2698 | | - |
2699 | if (d->viewItems.size() == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2700 | return QAbstractItemView::viewportSizeHint(); never executed: return QAbstractItemView::viewportSizeHint(); | 0 |
2701 | | - |
2702 | | - |
2703 | const QRect deepestRect = visualRect(d->viewItems.last().index); | - |
2704 | | - |
2705 | if (!deepestRect.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2706 | return QAbstractItemView::viewportSizeHint(); never executed: return QAbstractItemView::viewportSizeHint(); | 0 |
2707 | | - |
2708 | QSize result = QSize(d->header->length(), deepestRect.bottom() + 1); | - |
2709 | | - |
2710 | | - |
2711 | result += QSize(0, d->header->isVisible() ? d->header->height() : 0); | - |
2712 | | - |
2713 | | - |
2714 | result += QSize(verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0, | - |
2715 | horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0); | - |
2716 | | - |
2717 | return result; never executed: return result; | 0 |
2718 | } | - |
2719 | | - |
2720 | | - |
2721 | | - |
2722 | | - |
2723 | | - |
2724 | | - |
2725 | | - |
2726 | | - |
2727 | | - |
2728 | | - |
2729 | void QTreeView::expandAll() | - |
2730 | { | - |
2731 | Q_D(QTreeView); | - |
2732 | d->viewItems.clear(); | - |
2733 | d->interruptDelayedItemsLayout(); | - |
2734 | d->layout(-1, true); | - |
2735 | updateGeometries(); | - |
2736 | d->viewport->update(); | - |
2737 | } never executed: end of block | 0 |
2738 | | - |
2739 | | - |
2740 | | - |
2741 | | - |
2742 | | - |
2743 | | - |
2744 | | - |
2745 | | - |
2746 | void QTreeView::collapseAll() | - |
2747 | { | - |
2748 | Q_D(QTreeView); | - |
2749 | QSet<QPersistentModelIndex> old_expandedIndexes; | - |
2750 | old_expandedIndexes = d->expandedIndexes; | - |
2751 | d->expandedIndexes.clear(); | - |
2752 | if (!signalsBlocked() && isSignalConnected(QMetaMethod::fromSignal(&QTreeView::collapsed))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2753 | QSet<QPersistentModelIndex>::const_iterator i = old_expandedIndexes.constBegin(); | - |
2754 | for (; i != old_expandedIndexes.constEnd(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2755 | const QPersistentModelIndex &mi = (*i); | - |
2756 | if (mi.isValid() && !(mi.flags() & Qt::ItemNeverHasChildren))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2757 | emit collapsed(mi); never executed: collapsed(mi); | 0 |
2758 | } never executed: end of block | 0 |
2759 | } never executed: end of block | 0 |
2760 | doItemsLayout(); | - |
2761 | } never executed: end of block | 0 |
2762 | | - |
2763 | | - |
2764 | | - |
2765 | | - |
2766 | | - |
2767 | | - |
2768 | | - |
2769 | void QTreeView::expandToDepth(int depth) | - |
2770 | { | - |
2771 | Q_D(QTreeView); | - |
2772 | d->viewItems.clear(); | - |
2773 | QSet<QPersistentModelIndex> old_expandedIndexes; | - |
2774 | old_expandedIndexes = d->expandedIndexes; | - |
2775 | d->expandedIndexes.clear(); | - |
2776 | d->interruptDelayedItemsLayout(); | - |
2777 | d->layout(-1); | - |
2778 | for (int i = 0; i < d->viewItems.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2779 | if (d->viewItems.at(i).level <= (uint)depth) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2780 | d->viewItems[i].expanded = true; | - |
2781 | d->layout(i); | - |
2782 | d->storeExpanded(d->viewItems.at(i).index); | - |
2783 | } never executed: end of block | 0 |
2784 | } never executed: end of block | 0 |
2785 | | - |
2786 | bool someSignalEnabled = isSignalConnected(QMetaMethod::fromSignal(&QTreeView::collapsed)); | - |
2787 | someSignalEnabled |= isSignalConnected(QMetaMethod::fromSignal(&QTreeView::expanded)); | - |
2788 | | - |
2789 | if (!signalsBlocked() && someSignalEnabled) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2790 | | - |
2791 | QSet<QPersistentModelIndex> collapsedIndexes = old_expandedIndexes - d->expandedIndexes; | - |
2792 | QSet<QPersistentModelIndex>::const_iterator i = collapsedIndexes.constBegin(); | - |
2793 | for (; i != collapsedIndexes.constEnd(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2794 | const QPersistentModelIndex &mi = (*i); | - |
2795 | if (mi.isValid() && !(mi.flags() & Qt::ItemNeverHasChildren))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2796 | emit collapsed(mi); never executed: collapsed(mi); | 0 |
2797 | } never executed: end of block | 0 |
2798 | | - |
2799 | QSet<QPersistentModelIndex> expandedIndexs = d->expandedIndexes - old_expandedIndexes; | - |
2800 | i = expandedIndexs.constBegin(); | - |
2801 | for (; i != expandedIndexs.constEnd(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2802 | const QPersistentModelIndex &mi = (*i); | - |
2803 | if (mi.isValid() && !(mi.flags() & Qt::ItemNeverHasChildren))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2804 | emit expanded(mi); never executed: expanded(mi); | 0 |
2805 | } never executed: end of block | 0 |
2806 | } never executed: end of block | 0 |
2807 | | - |
2808 | updateGeometries(); | - |
2809 | d->viewport->update(); | - |
2810 | } never executed: end of block | 0 |
2811 | | - |
2812 | | - |
2813 | | - |
2814 | | - |
2815 | | - |
2816 | | - |
2817 | | - |
2818 | | - |
2819 | void QTreeView::columnResized(int column, int , int ) | - |
2820 | { | - |
2821 | Q_D(QTreeView); | - |
2822 | d->columnsToUpdate.append(column); | - |
2823 | if (d->columnResizeTimerID == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2824 | d->columnResizeTimerID = startTimer(0); never executed: d->columnResizeTimerID = startTimer(0); | 0 |
2825 | } never executed: end of block | 0 |
2826 | | - |
2827 | | - |
2828 | | - |
2829 | | - |
2830 | void QTreeView::updateGeometries() | - |
2831 | { | - |
2832 | Q_D(QTreeView); | - |
2833 | if (d->header) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2834 | if (d->geometryRecursionBlock)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2835 | return; never executed: return; | 0 |
2836 | d->geometryRecursionBlock = true; | - |
2837 | int height = 0; | - |
2838 | if (!d->header->isHidden()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2839 | height = qMax(d->header->minimumHeight(), d->header->sizeHint().height()); | - |
2840 | height = qMin(height, d->header->maximumHeight()); | - |
2841 | } never executed: end of block | 0 |
2842 | setViewportMargins(0, height, 0, 0); | - |
2843 | QRect vg = d->viewport->geometry(); | - |
2844 | QRect geometryRect(vg.left(), vg.top() - height, vg.width(), height); | - |
2845 | d->header->setGeometry(geometryRect); | - |
2846 | QMetaObject::invokeMethod(d->header, "updateGeometries"); | - |
2847 | d->updateScrollBars(); | - |
2848 | d->geometryRecursionBlock = false; | - |
2849 | } never executed: end of block | 0 |
2850 | QAbstractItemView::updateGeometries(); | - |
2851 | } never executed: end of block | 0 |
2852 | | - |
2853 | | - |
2854 | | - |
2855 | | - |
2856 | | - |
2857 | | - |
2858 | | - |
2859 | | - |
2860 | | - |
2861 | | - |
2862 | | - |
2863 | | - |
2864 | | - |
2865 | | - |
2866 | | - |
2867 | int QTreeView::sizeHintForColumn(int column) const | - |
2868 | { | - |
2869 | Q_D(const QTreeView); | - |
2870 | d->executePostedLayout(); | - |
2871 | if (d->viewItems.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2872 | return -1; never executed: return -1; | 0 |
2873 | ensurePolished(); | - |
2874 | int w = 0; | - |
2875 | QStyleOptionViewItem option = d->viewOptionsV1(); | - |
2876 | const QVector<QTreeViewItem> viewItems = d->viewItems; | - |
2877 | | - |
2878 | const int maximumProcessRows = d->header->resizeContentsPrecision(); | - |
2879 | | - |
2880 | int offset = 0; | - |
2881 | int start = d->firstVisibleItem(&offset); | - |
2882 | int end = d->lastVisibleItem(start, offset); | - |
2883 | if (start < 0 || end < 0 || end == viewItems.size() - 1) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2884 | end = viewItems.size() - 1; | - |
2885 | if (maximumProcessRows < 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2886 | start = 0; | - |
2887 | } else if (maximumProcessRows == 0) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2888 | start = qMax(0, end - 1); | - |
2889 | int remainingHeight = viewport()->height(); | - |
2890 | while (start > 0 && remainingHeight > 0) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2891 | remainingHeight -= d->itemHeight(start); | - |
2892 | --start; | - |
2893 | } never executed: end of block | 0 |
2894 | } else { never executed: end of block | 0 |
2895 | start = qMax(0, end - maximumProcessRows); | - |
2896 | } never executed: end of block | 0 |
2897 | } | - |
2898 | | - |
2899 | int rowsProcessed = 0; | - |
2900 | | - |
2901 | for (int i = start; i <= end; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2902 | if (viewItems.at(i).spanning)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2903 | continue; never executed: continue; | 0 |
2904 | QModelIndex index = viewItems.at(i).index; | - |
2905 | index = index.sibling(index.row(), column); | - |
2906 | w = d->widthHintForIndex(index, w, option, i); | - |
2907 | ++rowsProcessed; | - |
2908 | if (rowsProcessed == maximumProcessRows)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2909 | break; never executed: break; | 0 |
2910 | } never executed: end of block | 0 |
2911 | | - |
2912 | --end; | - |
2913 | int actualBottom = viewItems.size() - 1; | - |
2914 | | - |
2915 | if (maximumProcessRows == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2916 | rowsProcessed = 0; never executed: rowsProcessed = 0; | 0 |
2917 | | - |
2918 | while (rowsProcessed != maximumProcessRows && (start > 0 || end < actualBottom)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2919 | int idx = -1; | - |
2920 | | - |
2921 | if ((rowsProcessed % 2 && start > 0) || end == actualBottom) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2922 | while (start > 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2923 | --start; | - |
2924 | if (viewItems.at(start).spanning)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2925 | continue; never executed: continue; | 0 |
2926 | idx = start; | - |
2927 | break; never executed: break; | 0 |
2928 | } | - |
2929 | } else { never executed: end of block | 0 |
2930 | while (end < actualBottom) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2931 | ++end; | - |
2932 | if (viewItems.at(end).spanning)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2933 | continue; never executed: continue; | 0 |
2934 | idx = end; | - |
2935 | break; never executed: break; | 0 |
2936 | } | - |
2937 | } never executed: end of block | 0 |
2938 | if (idx < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2939 | continue; never executed: continue; | 0 |
2940 | | - |
2941 | QModelIndex index = viewItems.at(idx).index; | - |
2942 | index = index.sibling(index.row(), column); | - |
2943 | w = d->widthHintForIndex(index, w, option, idx); | - |
2944 | ++rowsProcessed; | - |
2945 | } never executed: end of block | 0 |
2946 | return w; never executed: return w; | 0 |
2947 | } | - |
2948 | | - |
2949 | | - |
2950 | | - |
2951 | | - |
2952 | | - |
2953 | | - |
2954 | int QTreeView::indexRowSizeHint(const QModelIndex &index) const | - |
2955 | { | - |
2956 | Q_D(const QTreeView); | - |
2957 | if (!d->isIndexValid(index) || !d->itemDelegate)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2958 | return 0; never executed: return 0; | 0 |
2959 | | - |
2960 | int start = -1; | - |
2961 | int end = -1; | - |
2962 | int indexRow = index.row(); | - |
2963 | int count = d->header->count(); | - |
2964 | bool emptyHeader = (count == 0); | - |
2965 | QModelIndex parent = index.parent(); | - |
2966 | | - |
2967 | if (count && isVisible()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2968 | | - |
2969 | start = d->header->visualIndexAt(0); | - |
2970 | } else { never executed: end of block | 0 |
2971 | | - |
2972 | count = d->model->columnCount(parent); | - |
2973 | } never executed: end of block | 0 |
2974 | | - |
2975 | if (isRightToLeft()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2976 | start = (start == -1 ? count - 1 : start);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2977 | end = 0; | - |
2978 | } else { never executed: end of block | 0 |
2979 | start = (start == -1 ? 0 : start);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2980 | end = count - 1; | - |
2981 | } never executed: end of block | 0 |
2982 | | - |
2983 | if (end < start)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2984 | qSwap(end, start); never executed: qSwap(end, start); | 0 |
2985 | | - |
2986 | int height = -1; | - |
2987 | QStyleOptionViewItem option = d->viewOptionsV1(); | - |
2988 | | - |
2989 | | - |
2990 | | - |
2991 | | - |
2992 | | - |
2993 | option.rect.setWidth(-1); | - |
2994 | | - |
2995 | for (int column = start; column <= end; ++column) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2996 | int logicalColumn = emptyHeader ? column : d->header->logicalIndex(column);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2997 | if (d->header->isSectionHidden(logicalColumn))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2998 | continue; never executed: continue; | 0 |
2999 | QModelIndex idx = d->model->index(indexRow, logicalColumn, parent); | - |
3000 | if (idx.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3001 | QWidget *editor = d->editorForIndex(idx).widget.data(); | - |
3002 | if (editor && d->persistent.contains(editor)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3003 | height = qMax(height, editor->sizeHint().height()); | - |
3004 | int min = editor->minimumSize().height(); | - |
3005 | int max = editor->maximumSize().height(); | - |
3006 | height = qBound(min, height, max); | - |
3007 | } never executed: end of block | 0 |
3008 | int hint = d->delegateForIndex(idx)->sizeHint(option, idx).height(); | - |
3009 | height = qMax(height, hint); | - |
3010 | } never executed: end of block | 0 |
3011 | } never executed: end of block | 0 |
3012 | | - |
3013 | return height; never executed: return height; | 0 |
3014 | } | - |
3015 | | - |
3016 | | - |
3017 | | - |
3018 | | - |
3019 | | - |
3020 | | - |
3021 | int QTreeView::rowHeight(const QModelIndex &index) const | - |
3022 | { | - |
3023 | Q_D(const QTreeView); | - |
3024 | d->executePostedLayout(); | - |
3025 | int i = d->viewIndex(index); | - |
3026 | if (i == -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3027 | return 0; never executed: return 0; | 0 |
3028 | return d->itemHeight(i); never executed: return d->itemHeight(i); | 0 |
3029 | } | - |
3030 | | - |
3031 | | - |
3032 | | - |
3033 | | - |
3034 | void QTreeView::horizontalScrollbarAction(int action) | - |
3035 | { | - |
3036 | QAbstractItemView::horizontalScrollbarAction(action); | - |
3037 | } never executed: end of block | 0 |
3038 | | - |
3039 | | - |
3040 | | - |
3041 | | - |
3042 | bool QTreeView::isIndexHidden(const QModelIndex &index) const | - |
3043 | { | - |
3044 | return (isColumnHidden(index.column()) || isRowHidden(index.row(), index.parent())); never executed: return (isColumnHidden(index.column()) || isRowHidden(index.row(), index.parent())); TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3045 | } | - |
3046 | | - |
3047 | | - |
3048 | | - |
3049 | | - |
3050 | void QTreeViewPrivate::initialize() | - |
3051 | { | - |
3052 | Q_Q(QTreeView); | - |
3053 | | - |
3054 | updateIndentationFromStyle(); | - |
3055 | updateStyledFrameWidths(); | - |
3056 | q->setSelectionBehavior(QAbstractItemView::SelectRows); | - |
3057 | q->setSelectionMode(QAbstractItemView::SingleSelection); | - |
3058 | q->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); | - |
3059 | q->setAttribute(Qt::WA_MacShowFocusRect); | - |
3060 | | - |
3061 | QHeaderView *header = new QHeaderView(Qt::Horizontal, q); | - |
3062 | header->setSectionsMovable(true); | - |
3063 | header->setStretchLastSection(true); | - |
3064 | header->setDefaultAlignment(Qt::AlignLeft|Qt::AlignVCenter); | - |
3065 | q->setHeader(header); | - |
3066 | #ifndef QT_NO_ANIMATION | - |
3067 | animationsEnabled = q->style()->styleHint(QStyle::SH_Widget_Animate, 0, q); | - |
3068 | QObject::connect(&animatedOperation, SIGNAL(finished()), q, SLOT(_q_endAnimatedOperation())); | - |
3069 | #endif //QT_NO_ANIMATION | - |
3070 | } never executed: end of block | 0 |
3071 | | - |
3072 | void QTreeViewPrivate::expand(int item, bool emitSignal) | - |
3073 | { | - |
3074 | Q_Q(QTreeView); | - |
3075 | | - |
3076 | if (item == -1 || viewItems.at(item).expanded)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3077 | return; never executed: return; | 0 |
3078 | const QModelIndex index = viewItems.at(item).index; | - |
3079 | if (index.flags() & Qt::ItemNeverHasChildren)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3080 | return; never executed: return; | 0 |
3081 | | - |
3082 | #ifndef QT_NO_ANIMATION | - |
3083 | if (emitSignal && animationsEnabled)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3084 | prepareAnimatedOperation(item, QVariantAnimation::Forward); never executed: prepareAnimatedOperation(item, QVariantAnimation::Forward); | 0 |
3085 | #endif //QT_NO_ANIMATION | - |
3086 | | - |
3087 | if (state != QAbstractItemView::AnimatingState)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3088 | stateBeforeAnimation = state; never executed: stateBeforeAnimation = state; | 0 |
3089 | q->setState(QAbstractItemView::ExpandingState); | - |
3090 | storeExpanded(index); | - |
3091 | viewItems[item].expanded = true; | - |
3092 | layout(item); | - |
3093 | q->setState(stateBeforeAnimation); | - |
3094 | | - |
3095 | if (model->canFetchMore(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3096 | model->fetchMore(index); never executed: model->fetchMore(index); | 0 |
3097 | if (emitSignal) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3098 | emit q->expanded(index); | - |
3099 | #ifndef QT_NO_ANIMATION | - |
3100 | if (animationsEnabled)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3101 | beginAnimatedOperation(); never executed: beginAnimatedOperation(); | 0 |
3102 | #endif //QT_NO_ANIMATION | - |
3103 | } never executed: end of block | 0 |
3104 | } never executed: end of block | 0 |
3105 | | - |
3106 | void QTreeViewPrivate::insertViewItems(int pos, int count, const QTreeViewItem &viewItem) | - |
3107 | { | - |
3108 | viewItems.insert(pos, count, viewItem); | - |
3109 | QTreeViewItem *items = viewItems.data(); | - |
3110 | for (int i = pos + count; i < viewItems.count(); i++)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3111 | if (items[i].parentItem >= pos)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3112 | items[i].parentItem += count; never executed: items[i].parentItem += count; | 0 |
3113 | } never executed: end of block | 0 |
3114 | | - |
3115 | void QTreeViewPrivate::removeViewItems(int pos, int count) | - |
3116 | { | - |
3117 | viewItems.remove(pos, count); | - |
3118 | QTreeViewItem *items = viewItems.data(); | - |
3119 | for (int i = pos; i < viewItems.count(); i++)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3120 | if (items[i].parentItem >= pos)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3121 | items[i].parentItem -= count; never executed: items[i].parentItem -= count; | 0 |
3122 | } never executed: end of block | 0 |
3123 | | - |
3124 | #if 0 | - |
3125 | bool QTreeViewPrivate::checkViewItems() const | - |
3126 | { | - |
3127 | for (int i = 0; i < viewItems.count(); ++i) { | - |
3128 | const QTreeViewItem &vi = viewItems.at(i); | - |
3129 | if (vi.parentItem == -1) { | - |
3130 | Q_ASSERT(!vi.index.parent().isValid() || vi.index.parent() == root); | - |
3131 | } else { | - |
3132 | Q_ASSERT(vi.index.parent() == viewItems.at(vi.parentItem).index); | - |
3133 | } | - |
3134 | } | - |
3135 | return true; | - |
3136 | } | - |
3137 | #endif | - |
3138 | | - |
3139 | void QTreeViewPrivate::collapse(int item, bool emitSignal) | - |
3140 | { | - |
3141 | Q_Q(QTreeView); | - |
3142 | | - |
3143 | if (item == -1 || expandedIndexes.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3144 | return; never executed: return; | 0 |
3145 | | - |
3146 | | - |
3147 | delayedAutoScroll.stop(); | - |
3148 | | - |
3149 | int total = viewItems.at(item).total; | - |
3150 | const QModelIndex &modelIndex = viewItems.at(item).index; | - |
3151 | if (!isPersistent(modelIndex))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3152 | return; never executed: return; | 0 |
3153 | QSet<QPersistentModelIndex>::iterator it = expandedIndexes.find(modelIndex); | - |
3154 | if (it == expandedIndexes.end() || viewItems.at(item).expanded == false)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3155 | return; never executed: return; | 0 |
3156 | | - |
3157 | #ifndef QT_NO_ANIMATION | - |
3158 | if (emitSignal && animationsEnabled)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3159 | prepareAnimatedOperation(item, QVariantAnimation::Backward); never executed: prepareAnimatedOperation(item, QVariantAnimation::Backward); | 0 |
3160 | #endif //QT_NO_ANIMATION | - |
3161 | | - |
3162 | | - |
3163 | if (state != QAbstractItemView::AnimatingState)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3164 | stateBeforeAnimation = state; never executed: stateBeforeAnimation = state; | 0 |
3165 | q->setState(QAbstractItemView::CollapsingState); | - |
3166 | expandedIndexes.erase(it); | - |
3167 | viewItems[item].expanded = false; | - |
3168 | int index = item; | - |
3169 | while (index > -1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3170 | viewItems[index].total -= total; | - |
3171 | index = viewItems[index].parentItem; | - |
3172 | } never executed: end of block | 0 |
3173 | removeViewItems(item + 1, total); | - |
3174 | q->setState(stateBeforeAnimation); | - |
3175 | | - |
3176 | if (emitSignal) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3177 | emit q->collapsed(modelIndex); | - |
3178 | #ifndef QT_NO_ANIMATION | - |
3179 | if (animationsEnabled)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3180 | beginAnimatedOperation(); never executed: beginAnimatedOperation(); | 0 |
3181 | #endif //QT_NO_ANIMATION | - |
3182 | } never executed: end of block | 0 |
3183 | } never executed: end of block | 0 |
3184 | | - |
3185 | #ifndef QT_NO_ANIMATION | - |
3186 | void QTreeViewPrivate::prepareAnimatedOperation(int item, QVariantAnimation::Direction direction) | - |
3187 | { | - |
3188 | animatedOperation.item = item; | - |
3189 | animatedOperation.viewport = viewport; | - |
3190 | animatedOperation.setDirection(direction); | - |
3191 | | - |
3192 | int top = coordinateForItem(item) + itemHeight(item); | - |
3193 | QRect rect = viewport->rect(); | - |
3194 | rect.setTop(top); | - |
3195 | if (direction == QVariantAnimation::Backward) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3196 | const int limit = rect.height() * 2; | - |
3197 | int h = 0; | - |
3198 | int c = item + viewItems.at(item).total + 1; | - |
3199 | for (int i = item + 1; i < c && h < limit; ++i)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3200 | h += itemHeight(i); never executed: h += itemHeight(i); | 0 |
3201 | rect.setHeight(h); | - |
3202 | animatedOperation.setEndValue(top + h); | - |
3203 | } never executed: end of block | 0 |
3204 | animatedOperation.setStartValue(top); | - |
3205 | animatedOperation.before = renderTreeToPixmapForAnimation(rect); | - |
3206 | } never executed: end of block | 0 |
3207 | | - |
3208 | void QTreeViewPrivate::beginAnimatedOperation() | - |
3209 | { | - |
3210 | Q_Q(QTreeView); | - |
3211 | | - |
3212 | QRect rect = viewport->rect(); | - |
3213 | rect.setTop(animatedOperation.top()); | - |
3214 | if (animatedOperation.direction() == QVariantAnimation::Forward) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3215 | const int limit = rect.height() * 2; | - |
3216 | int h = 0; | - |
3217 | int c = animatedOperation.item + viewItems.at(animatedOperation.item).total + 1; | - |
3218 | for (int i = animatedOperation.item + 1; i < c && h < limit; ++i)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3219 | h += itemHeight(i); never executed: h += itemHeight(i); | 0 |
3220 | rect.setHeight(h); | - |
3221 | animatedOperation.setEndValue(animatedOperation.top() + h); | - |
3222 | } never executed: end of block | 0 |
3223 | | - |
3224 | if (!rect.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3225 | animatedOperation.after = renderTreeToPixmapForAnimation(rect); | - |
3226 | | - |
3227 | q->setState(QAbstractItemView::AnimatingState); | - |
3228 | animatedOperation.start(); | - |
3229 | } never executed: end of block | 0 |
3230 | } never executed: end of block | 0 |
3231 | | - |
3232 | void QTreeViewPrivate::drawAnimatedOperation(QPainter *painter) const | - |
3233 | { | - |
3234 | const int start = animatedOperation.startValue().toInt(), | - |
3235 | end = animatedOperation.endValue().toInt(), | - |
3236 | current = animatedOperation.currentValue().toInt(); | - |
3237 | bool collapsing = animatedOperation.direction() == QVariantAnimation::Backward; | - |
3238 | const QPixmap top = collapsing ? animatedOperation.before : animatedOperation.after;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3239 | painter->drawPixmap(0, start, top, 0, end - current - 1, top.width(), top.height()); | - |
3240 | const QPixmap bottom = collapsing ? animatedOperation.after : animatedOperation.before;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3241 | painter->drawPixmap(0, current, bottom); | - |
3242 | } never executed: end of block | 0 |
3243 | | - |
3244 | QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) const | - |
3245 | { | - |
3246 | Q_Q(const QTreeView); | - |
3247 | QPixmap pixmap(rect.size() * q->devicePixelRatio()); | - |
3248 | pixmap.setDevicePixelRatio(q->devicePixelRatio()); | - |
3249 | if (rect.size().isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3250 | return pixmap; never executed: return pixmap; | 0 |
3251 | pixmap.fill(Qt::transparent); | - |
3252 | QPainter painter(&pixmap); | - |
3253 | painter.fillRect(QRect(QPoint(0,0), rect.size()), q->palette().base()); | - |
3254 | painter.translate(0, -rect.top()); | - |
3255 | q->drawTree(&painter, QRegion(rect)); | - |
3256 | painter.end(); | - |
3257 | | - |
3258 | | - |
3259 | QStyleOptionViewItem option = viewOptionsV1(); | - |
3260 | for (QEditorIndexHash::const_iterator it = editorIndexHash.constBegin(); it != editorIndexHash.constEnd(); ++it) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3261 | QWidget *editor = it.key(); | - |
3262 | const QModelIndex &index = it.value(); | - |
3263 | option.rect = q->visualRect(index); | - |
3264 | if (option.rect.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3265 | | - |
3266 | if (QAbstractItemDelegate *delegate = delegateForIndex(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3267 | delegate->updateEditorGeometry(editor, option, index); never executed: delegate->updateEditorGeometry(editor, option, index); | 0 |
3268 | | - |
3269 | const QPoint pos = editor->pos(); | - |
3270 | if (rect.contains(pos)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3271 | editor->render(&pixmap, pos - rect.topLeft()); | - |
3272 | | - |
3273 | | - |
3274 | editor->hide(); | - |
3275 | } never executed: end of block | 0 |
3276 | } never executed: end of block | 0 |
3277 | } never executed: end of block | 0 |
3278 | | - |
3279 | | - |
3280 | return pixmap; never executed: return pixmap; | 0 |
3281 | } | - |
3282 | | - |
3283 | void QTreeViewPrivate::_q_endAnimatedOperation() | - |
3284 | { | - |
3285 | Q_Q(QTreeView); | - |
3286 | q->setState(stateBeforeAnimation); | - |
3287 | q->updateGeometries(); | - |
3288 | viewport->update(); | - |
3289 | } never executed: end of block | 0 |
3290 | #endif //QT_NO_ANIMATION | - |
3291 | | - |
3292 | void QTreeViewPrivate::_q_modelAboutToBeReset() | - |
3293 | { | - |
3294 | viewItems.clear(); | - |
3295 | } never executed: end of block | 0 |
3296 | | - |
3297 | void QTreeViewPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end) | - |
3298 | { | - |
3299 | if (start <= 0 && 0 <= end)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3300 | viewItems.clear(); never executed: viewItems.clear(); | 0 |
3301 | QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(parent, start, end); | - |
3302 | } never executed: end of block | 0 |
3303 | | - |
3304 | void QTreeViewPrivate::_q_columnsRemoved(const QModelIndex &parent, int start, int end) | - |
3305 | { | - |
3306 | if (start <= 0 && 0 <= end)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3307 | doDelayedItemsLayout(); never executed: doDelayedItemsLayout(); | 0 |
3308 | QAbstractItemViewPrivate::_q_columnsRemoved(parent, start, end); | - |
3309 | } never executed: end of block | 0 |
3310 | | - |
3311 | | - |
3312 | | - |
3313 | | - |
3314 | | - |
3315 | | - |
3316 | | - |
3317 | | - |
3318 | void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninitialized) | - |
3319 | { | - |
3320 | Q_Q(QTreeView); | - |
3321 | QModelIndex current; | - |
3322 | QModelIndex parent = (i < 0) ? (QModelIndex)root : modelIndex(i);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3323 | | - |
3324 | if (i>=0 && !parent.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3325 | | - |
3326 | | - |
3327 | | - |
3328 | return; never executed: return; | 0 |
3329 | } | - |
3330 | | - |
3331 | int count = 0; | - |
3332 | if (model->hasChildren(parent)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3333 | if (model->canFetchMore(parent))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3334 | model->fetchMore(parent); never executed: model->fetchMore(parent); | 0 |
3335 | count = model->rowCount(parent); | - |
3336 | } never executed: end of block | 0 |
3337 | | - |
3338 | bool expanding = true; | - |
3339 | if (i == -1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3340 | if (uniformRowHeights) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3341 | QModelIndex index = model->index(0, 0, parent); | - |
3342 | defaultItemHeight = q->indexRowSizeHint(index); | - |
3343 | } never executed: end of block | 0 |
3344 | viewItems.resize(count); | - |
3345 | afterIsUninitialized = true; | - |
3346 | } else if (viewItems[i].total != (uint)count) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3347 | if (!afterIsUninitialized)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3348 | insertViewItems(i + 1, count, QTreeViewItem()); never executed: insertViewItems(i + 1, count, QTreeViewItem()); | 0 |
3349 | else if (count > 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3350 | viewItems.resize(viewItems.count() + count); never executed: viewItems.resize(viewItems.count() + count); | 0 |
3351 | } else { never executed: end of block | 0 |
3352 | expanding = false; | - |
3353 | } never executed: end of block | 0 |
3354 | | - |
3355 | int first = i + 1; | - |
3356 | int level = (i >= 0 ? viewItems.at(i).level + 1 : 0);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3357 | int hidden = 0; | - |
3358 | int last = 0; | - |
3359 | int children = 0; | - |
3360 | QTreeViewItem *item = 0; | - |
3361 | for (int j = first; j < first + count; ++j) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3362 | current = model->index(j - first, 0, parent); | - |
3363 | if (isRowHidden(current)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3364 | ++hidden; | - |
3365 | last = j - hidden + children; | - |
3366 | } else { never executed: end of block | 0 |
3367 | last = j - hidden + children; | - |
3368 | if (item)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3369 | item->hasMoreSiblings = true; never executed: item->hasMoreSiblings = true; | 0 |
3370 | item = &viewItems[last]; | - |
3371 | item->index = current; | - |
3372 | item->parentItem = i; | - |
3373 | item->level = level; | - |
3374 | item->height = 0; | - |
3375 | item->spanning = q->isFirstColumnSpanned(current.row(), parent); | - |
3376 | item->expanded = false; | - |
3377 | item->total = 0; | - |
3378 | item->hasMoreSiblings = false; | - |
3379 | if ((recursiveExpanding && !(current.flags() & Qt::ItemNeverHasChildren)) || isIndexExpanded(current)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3380 | if (recursiveExpanding && storeExpanded(current) && !q->signalsBlocked())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3381 | emit q->expanded(current); never executed: q->expanded(current); | 0 |
3382 | item->expanded = true; | - |
3383 | layout(last, recursiveExpanding, afterIsUninitialized); | - |
3384 | item = &viewItems[last]; | - |
3385 | children += item->total; | - |
3386 | item->hasChildren = item->total > 0; | - |
3387 | last = j - hidden + children; | - |
3388 | } else { never executed: end of block | 0 |
3389 | item->hasChildren = hasVisibleChildren(current); | - |
3390 | } never executed: end of block | 0 |
3391 | } | - |
3392 | } | - |
3393 | | - |
3394 | | - |
3395 | if (hidden > 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3396 | if (!afterIsUninitialized)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3397 | removeViewItems(last + 1, hidden); never executed: removeViewItems(last + 1, hidden); | 0 |
3398 | else | - |
3399 | viewItems.resize(viewItems.size() - hidden); never executed: viewItems.resize(viewItems.size() - hidden); | 0 |
3400 | } | - |
3401 | | - |
3402 | if (!expanding)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3403 | return; never executed: return; | 0 |
3404 | | - |
3405 | while (i > -1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3406 | viewItems[i].total += count - hidden; | - |
3407 | i = viewItems[i].parentItem; | - |
3408 | } never executed: end of block | 0 |
3409 | } never executed: end of block | 0 |
3410 | | - |
3411 | int QTreeViewPrivate::pageUp(int i) const | - |
3412 | { | - |
3413 | int index = itemAtCoordinate(coordinateForItem(i) - viewport->height()); | - |
3414 | while (isItemHiddenOrDisabled(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3415 | index--; never executed: index--; | 0 |
3416 | return index == -1 ? 0 : index; never executed: return index == -1 ? 0 : index; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3417 | } | - |
3418 | | - |
3419 | int QTreeViewPrivate::pageDown(int i) const | - |
3420 | { | - |
3421 | int index = itemAtCoordinate(coordinateForItem(i) + viewport->height()); | - |
3422 | while (isItemHiddenOrDisabled(index))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3423 | index++; never executed: index++; | 0 |
3424 | return index == -1 ? viewItems.count() - 1 : index; never executed: return index == -1 ? viewItems.count() - 1 : index; TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3425 | } | - |
3426 | | - |
3427 | int QTreeViewPrivate::indentationForItem(int item) const | - |
3428 | { | - |
3429 | if (item < 0 || item >= viewItems.count())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3430 | return 0; never executed: return 0; | 0 |
3431 | int level = viewItems.at(item).level; | - |
3432 | if (rootDecoration)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3433 | ++level; never executed: ++level; | 0 |
3434 | return level * indent; never executed: return level * indent; | 0 |
3435 | } | - |
3436 | | - |
3437 | int QTreeViewPrivate::itemHeight(int item) const | - |
3438 | { | - |
3439 | if (uniformRowHeights)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3440 | return defaultItemHeight; never executed: return defaultItemHeight; | 0 |
3441 | if (viewItems.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3442 | return 0; never executed: return 0; | 0 |
3443 | const QModelIndex &index = viewItems.at(item).index; | - |
3444 | if (!index.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3445 | return 0; never executed: return 0; | 0 |
3446 | int height = viewItems.at(item).height; | - |
3447 | if (height <= 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3448 | height = q_func()->indexRowSizeHint(index); | - |
3449 | viewItems[item].height = height; | - |
3450 | } never executed: end of block | 0 |
3451 | return qMax(height, 0); never executed: return qMax(height, 0); | 0 |
3452 | } | - |
3453 | | - |
3454 | | - |
3455 | | - |
3456 | | - |
3457 | | - |
3458 | | - |
3459 | int QTreeViewPrivate::coordinateForItem(int item) const | - |
3460 | { | - |
3461 | if (verticalScrollMode == QAbstractItemView::ScrollPerPixel) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3462 | if (uniformRowHeights)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3463 | return (item * defaultItemHeight) - vbar->value(); never executed: return (item * defaultItemHeight) - vbar->value(); | 0 |
3464 | | - |
3465 | int y = 0; | - |
3466 | for (int i = 0; i < viewItems.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3467 | if (i == item)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3468 | return y - vbar->value(); never executed: return y - vbar->value(); | 0 |
3469 | y += itemHeight(i); | - |
3470 | } never executed: end of block | 0 |
3471 | } else { never executed: end of block | 0 |
3472 | int topViewItemIndex = vbar->value(); | - |
3473 | if (uniformRowHeights)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3474 | return defaultItemHeight * (item - topViewItemIndex); never executed: return defaultItemHeight * (item - topViewItemIndex); | 0 |
3475 | if (item >= topViewItemIndex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3476 | | - |
3477 | | - |
3478 | int viewItemCoordinate = 0; | - |
3479 | int viewItemIndex = topViewItemIndex; | - |
3480 | while (viewItemIndex < viewItems.count()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3481 | if (viewItemIndex == item)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3482 | return viewItemCoordinate; never executed: return viewItemCoordinate; | 0 |
3483 | viewItemCoordinate += itemHeight(viewItemIndex); | - |
3484 | ++viewItemIndex; | - |
3485 | } never executed: end of block | 0 |
3486 | | - |
3487 | Q_ASSERT(false); | - |
3488 | return viewItemCoordinate; never executed: return viewItemCoordinate; | 0 |
3489 | } else { | - |
3490 | | - |
3491 | int viewItemCoordinate = 0; | - |
3492 | for (int viewItemIndex = topViewItemIndex; viewItemIndex > 0; --viewItemIndex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3493 | if (viewItemIndex == item)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3494 | return viewItemCoordinate; never executed: return viewItemCoordinate; | 0 |
3495 | viewItemCoordinate -= itemHeight(viewItemIndex - 1); | - |
3496 | } never executed: end of block | 0 |
3497 | return viewItemCoordinate; never executed: return viewItemCoordinate; | 0 |
3498 | } | - |
3499 | } | - |
3500 | return 0; never executed: return 0; | 0 |
3501 | } | - |
3502 | | - |
3503 | | - |
3504 | | - |
3505 | | - |
3506 | | - |
3507 | | - |
3508 | | - |
3509 | | - |
3510 | int QTreeViewPrivate::itemAtCoordinate(int coordinate) const | - |
3511 | { | - |
3512 | const int itemCount = viewItems.count(); | - |
3513 | if (itemCount == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3514 | return -1; never executed: return -1; | 0 |
3515 | if (uniformRowHeights && defaultItemHeight <= 0)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3516 | return -1; never executed: return -1; | 0 |
3517 | if (verticalScrollMode == QAbstractItemView::ScrollPerPixel) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3518 | if (uniformRowHeights) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3519 | const int viewItemIndex = (coordinate + vbar->value()) / defaultItemHeight; | - |
3520 | return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex); never executed: return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex); TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3521 | } | - |
3522 | | - |
3523 | int viewItemCoordinate = 0; | - |
3524 | const int contentsCoordinate = coordinate + vbar->value(); | - |
3525 | for (int viewItemIndex = 0; viewItemIndex < viewItems.count(); ++viewItemIndex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3526 | viewItemCoordinate += itemHeight(viewItemIndex); | - |
3527 | if (viewItemCoordinate >= contentsCoordinate)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3528 | return (viewItemIndex >= itemCount ? -1 : viewItemIndex); never executed: return (viewItemIndex >= itemCount ? -1 : viewItemIndex); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3529 | } never executed: end of block | 0 |
3530 | } else { never executed: end of block | 0 |
3531 | int topViewItemIndex = vbar->value(); | - |
3532 | if (uniformRowHeights) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3533 | if (coordinate < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3534 | coordinate -= defaultItemHeight - 1; never executed: coordinate -= defaultItemHeight - 1; | 0 |
3535 | const int viewItemIndex = topViewItemIndex + (coordinate / defaultItemHeight); | - |
3536 | return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex); never executed: return ((viewItemIndex >= itemCount || viewItemIndex < 0) ? -1 : viewItemIndex); TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3537 | } | - |
3538 | if (coordinate >= 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3539 | | - |
3540 | int viewItemCoordinate = 0; | - |
3541 | for (int viewItemIndex = topViewItemIndex; viewItemIndex < viewItems.count(); ++viewItemIndex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3542 | viewItemCoordinate += itemHeight(viewItemIndex); | - |
3543 | if (viewItemCoordinate > coordinate)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3544 | return (viewItemIndex >= itemCount ? -1 : viewItemIndex); never executed: return (viewItemIndex >= itemCount ? -1 : viewItemIndex); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3545 | } never executed: end of block | 0 |
3546 | } else { never executed: end of block | 0 |
3547 | | - |
3548 | int viewItemCoordinate = 0; | - |
3549 | for (int viewItemIndex = topViewItemIndex; viewItemIndex >= 0; --viewItemIndex) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3550 | if (viewItemCoordinate <= coordinate)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3551 | return (viewItemIndex >= itemCount ? -1 : viewItemIndex); never executed: return (viewItemIndex >= itemCount ? -1 : viewItemIndex); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3552 | viewItemCoordinate -= itemHeight(viewItemIndex); | - |
3553 | } never executed: end of block | 0 |
3554 | } never executed: end of block | 0 |
3555 | } | - |
3556 | return -1; never executed: return -1; | 0 |
3557 | } | - |
3558 | | - |
3559 | int QTreeViewPrivate::viewIndex(const QModelIndex &_index) const | - |
3560 | { | - |
3561 | if (!_index.isValid() || viewItems.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3562 | return -1; never executed: return -1; | 0 |
3563 | | - |
3564 | const int totalCount = viewItems.count(); | - |
3565 | const QModelIndex index = _index.sibling(_index.row(), 0); | - |
3566 | const int row = index.row(); | - |
3567 | const quintptr internalId = index.internalId(); | - |
3568 | | - |
3569 | | - |
3570 | int localCount = qMin(lastViewedItem - 1, totalCount - lastViewedItem); | - |
3571 | for (int i = 0; i < localCount; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3572 | const QModelIndex &idx1 = viewItems.at(lastViewedItem + i).index; | - |
3573 | if (idx1.row() == row && idx1.internalId() == internalId) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3574 | lastViewedItem = lastViewedItem + i; | - |
3575 | return lastViewedItem; never executed: return lastViewedItem; | 0 |
3576 | } | - |
3577 | const QModelIndex &idx2 = viewItems.at(lastViewedItem - i - 1).index; | - |
3578 | if (idx2.row() == row && idx2.internalId() == internalId) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3579 | lastViewedItem = lastViewedItem - i - 1; | - |
3580 | return lastViewedItem; never executed: return lastViewedItem; | 0 |
3581 | } | - |
3582 | } never executed: end of block | 0 |
3583 | | - |
3584 | for (int j = qMax(0, lastViewedItem + localCount); j < totalCount; ++j) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3585 | const QModelIndex &idx = viewItems.at(j).index; | - |
3586 | if (idx.row() == row && idx.internalId() == internalId) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3587 | lastViewedItem = j; | - |
3588 | return j; never executed: return j; | 0 |
3589 | } | - |
3590 | } never executed: end of block | 0 |
3591 | for (int j = qMin(totalCount, lastViewedItem - localCount) - 1; j >= 0; --j) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3592 | const QModelIndex &idx = viewItems.at(j).index; | - |
3593 | if (idx.row() == row && idx.internalId() == internalId) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3594 | lastViewedItem = j; | - |
3595 | return j; never executed: return j; | 0 |
3596 | } | - |
3597 | } never executed: end of block | 0 |
3598 | | - |
3599 | | - |
3600 | return -1; never executed: return -1; | 0 |
3601 | } | - |
3602 | | - |
3603 | QModelIndex QTreeViewPrivate::modelIndex(int i, int column) const | - |
3604 | { | - |
3605 | if (i < 0 || i >= viewItems.count())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3606 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
3607 | | - |
3608 | QModelIndex ret = viewItems.at(i).index; | - |
3609 | if (column)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3610 | ret = ret.sibling(ret.row(), column); never executed: ret = ret.sibling(ret.row(), column); | 0 |
3611 | return ret; never executed: return ret; | 0 |
3612 | } | - |
3613 | | - |
3614 | int QTreeViewPrivate::firstVisibleItem(int *offset) const | - |
3615 | { | - |
3616 | const int value = vbar->value(); | - |
3617 | if (verticalScrollMode == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3618 | if (offset)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3619 | *offset = 0; never executed: *offset = 0; | 0 |
3620 | return (value < 0 || value >= viewItems.count()) ? -1 : value; never executed: return (value < 0 || value >= viewItems.count()) ? -1 : value; TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3621 | } | - |
3622 | | - |
3623 | if (uniformRowHeights) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3624 | if (!defaultItemHeight)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3625 | return -1; never executed: return -1; | 0 |
3626 | | - |
3627 | if (offset)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3628 | *offset = -(value % defaultItemHeight); never executed: *offset = -(value % defaultItemHeight); | 0 |
3629 | return value / defaultItemHeight; never executed: return value / defaultItemHeight; | 0 |
3630 | } | - |
3631 | int y = 0; | - |
3632 | for (int i = 0; i < viewItems.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3633 | y += itemHeight(i); | - |
3634 | if (y > value) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3635 | if (offset)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3636 | *offset = y - value - itemHeight(i); never executed: *offset = y - value - itemHeight(i); | 0 |
3637 | return i; never executed: return i; | 0 |
3638 | } | - |
3639 | } never executed: end of block | 0 |
3640 | return -1; never executed: return -1; | 0 |
3641 | } | - |
3642 | | - |
3643 | int QTreeViewPrivate::lastVisibleItem(int firstVisual, int offset) const | - |
3644 | { | - |
3645 | if (firstVisual < 0 || offset < 0) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3646 | firstVisual = firstVisibleItem(&offset); | - |
3647 | if (firstVisual < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3648 | return -1; never executed: return -1; | 0 |
3649 | } never executed: end of block | 0 |
3650 | int y = - offset; | - |
3651 | int value = viewport->height(); | - |
3652 | | - |
3653 | for (int i = firstVisual; i < viewItems.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3654 | y += itemHeight(i); | - |
3655 | if (y > value)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3656 | return i; never executed: return i; | 0 |
3657 | } never executed: end of block | 0 |
3658 | return viewItems.size() - 1; never executed: return viewItems.size() - 1; | 0 |
3659 | } | - |
3660 | | - |
3661 | int QTreeViewPrivate::columnAt(int x) const | - |
3662 | { | - |
3663 | return header->logicalIndexAt(x); never executed: return header->logicalIndexAt(x); | 0 |
3664 | } | - |
3665 | | - |
3666 | void QTreeViewPrivate::updateScrollBars() | - |
3667 | { | - |
3668 | Q_Q(QTreeView); | - |
3669 | QSize viewportSize = viewport->size(); | - |
3670 | if (!viewportSize.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3671 | viewportSize = QSize(0, 0); never executed: viewportSize = QSize(0, 0); | 0 |
3672 | | - |
3673 | executePostedLayout(); | - |
3674 | if (viewItems.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3675 | q->doItemsLayout(); | - |
3676 | } never executed: end of block | 0 |
3677 | | - |
3678 | int itemsInViewport = 0; | - |
3679 | if (uniformRowHeights) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3680 | if (defaultItemHeight <= 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3681 | itemsInViewport = viewItems.count(); never executed: itemsInViewport = viewItems.count(); | 0 |
3682 | else | - |
3683 | itemsInViewport = viewportSize.height() / defaultItemHeight; never executed: itemsInViewport = viewportSize.height() / defaultItemHeight; | 0 |
3684 | } else { | - |
3685 | const int itemsCount = viewItems.count(); | - |
3686 | const int viewportHeight = viewportSize.height(); | - |
3687 | for (int height = 0, item = itemsCount - 1; item >= 0; --item) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3688 | height += itemHeight(item); | - |
3689 | if (height > viewportHeight)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3690 | break; never executed: break; | 0 |
3691 | ++itemsInViewport; | - |
3692 | } never executed: end of block | 0 |
3693 | } never executed: end of block | 0 |
3694 | if (verticalScrollMode == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3695 | if (!viewItems.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3696 | itemsInViewport = qMax(1, itemsInViewport); never executed: itemsInViewport = qMax(1, itemsInViewport); | 0 |
3697 | vbar->setRange(0, viewItems.count() - itemsInViewport); | - |
3698 | vbar->setPageStep(itemsInViewport); | - |
3699 | vbar->setSingleStep(1); | - |
3700 | } else { never executed: end of block | 0 |
3701 | int contentsHeight = 0; | - |
3702 | if (uniformRowHeights) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3703 | contentsHeight = defaultItemHeight * viewItems.count(); | - |
3704 | } else { never executed: end of block | 0 |
3705 | for (int i = 0; i < viewItems.count(); ++i)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3706 | contentsHeight += itemHeight(i); never executed: contentsHeight += itemHeight(i); | 0 |
3707 | } never executed: end of block | 0 |
3708 | vbar->setRange(0, contentsHeight - viewportSize.height()); | - |
3709 | vbar->setPageStep(viewportSize.height()); | - |
3710 | vbar->setSingleStep(qMax(viewportSize.height() / (itemsInViewport + 1), 2)); | - |
3711 | } never executed: end of block | 0 |
3712 | | - |
3713 | const int columnCount = header->count(); | - |
3714 | const int viewportWidth = viewportSize.width(); | - |
3715 | int columnsInViewport = 0; | - |
3716 | for (int width = 0, column = columnCount - 1; column >= 0; --column) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3717 | int logical = header->logicalIndex(column); | - |
3718 | width += header->sectionSize(logical); | - |
3719 | if (width > viewportWidth)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3720 | break; never executed: break; | 0 |
3721 | ++columnsInViewport; | - |
3722 | } never executed: end of block | 0 |
3723 | if (columnCount > 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3724 | columnsInViewport = qMax(1, columnsInViewport); never executed: columnsInViewport = qMax(1, columnsInViewport); | 0 |
3725 | if (horizontalScrollMode == QAbstractItemView::ScrollPerItem) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3726 | hbar->setRange(0, columnCount - columnsInViewport); | - |
3727 | hbar->setPageStep(columnsInViewport); | - |
3728 | hbar->setSingleStep(1); | - |
3729 | } else { never executed: end of block | 0 |
3730 | const int horizontalLength = header->length(); | - |
3731 | const QSize maxSize = q->maximumViewportSize(); | - |
3732 | if (maxSize.width() >= horizontalLength && vbar->maximum() <= 0)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3733 | viewportSize = maxSize; never executed: viewportSize = maxSize; | 0 |
3734 | hbar->setPageStep(viewportSize.width()); | - |
3735 | hbar->setRange(0, qMax(horizontalLength - viewportSize.width(), 0)); | - |
3736 | hbar->setSingleStep(qMax(viewportSize.width() / (columnsInViewport + 1), 2)); | - |
3737 | } never executed: end of block | 0 |
3738 | } | - |
3739 | | - |
3740 | int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const | - |
3741 | { | - |
3742 | executePostedLayout(); | - |
3743 | int x = pos.x(); | - |
3744 | int column = header->logicalIndexAt(x); | - |
3745 | if (!isTreePosition(column))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3746 | return -1; never executed: return -1; | 0 |
3747 | | - |
3748 | int viewItemIndex = itemAtCoordinate(pos.y()); | - |
3749 | QRect returning = itemDecorationRect(modelIndex(viewItemIndex)); | - |
3750 | if (!returning.contains(pos))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3751 | return -1; never executed: return -1; | 0 |
3752 | | - |
3753 | return viewItemIndex; never executed: return viewItemIndex; | 0 |
3754 | } | - |
3755 | | - |
3756 | QRect QTreeViewPrivate::itemDecorationRect(const QModelIndex &index) const | - |
3757 | { | - |
3758 | Q_Q(const QTreeView); | - |
3759 | if (!rootDecoration && index.parent() == root)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3760 | return QRect(); never executed: return QRect(); | 0 |
3761 | | - |
3762 | int viewItemIndex = viewIndex(index); | - |
3763 | if (viewItemIndex < 0 || !hasVisibleChildren(viewItems.at(viewItemIndex).index))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3764 | return QRect(); never executed: return QRect(); | 0 |
3765 | | - |
3766 | int itemIndentation = indentationForItem(viewItemIndex); | - |
3767 | int position = header->sectionViewportPosition(logicalIndexForTree()); | - |
3768 | int size = header->sectionSize(logicalIndexForTree()); | - |
3769 | | - |
3770 | QRect rect; | - |
3771 | if (q->isRightToLeft())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3772 | rect = QRect(position + size - itemIndentation, coordinateForItem(viewItemIndex), never executed: rect = QRect(position + size - itemIndentation, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex)); | 0 |
3773 | indent, itemHeight(viewItemIndex)); never executed: rect = QRect(position + size - itemIndentation, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex)); | 0 |
3774 | else | - |
3775 | rect = QRect(position + itemIndentation - indent, coordinateForItem(viewItemIndex), never executed: rect = QRect(position + itemIndentation - indent, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex)); | 0 |
3776 | indent, itemHeight(viewItemIndex)); never executed: rect = QRect(position + itemIndentation - indent, coordinateForItem(viewItemIndex), indent, itemHeight(viewItemIndex)); | 0 |
3777 | QStyleOption opt; | - |
3778 | opt.initFrom(q); | - |
3779 | opt.rect = rect; | - |
3780 | return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q); never executed: return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q); | 0 |
3781 | } | - |
3782 | | - |
3783 | QList<QPair<int, int> > QTreeViewPrivate::columnRanges(const QModelIndex &topIndex, | - |
3784 | const QModelIndex &bottomIndex) const | - |
3785 | { | - |
3786 | const int topVisual = header->visualIndex(topIndex.column()), | - |
3787 | bottomVisual = header->visualIndex(bottomIndex.column()); | - |
3788 | | - |
3789 | const int start = qMin(topVisual, bottomVisual); | - |
3790 | const int end = qMax(topVisual, bottomVisual); | - |
3791 | | - |
3792 | QList<int> logicalIndexes; | - |
3793 | | - |
3794 | | - |
3795 | for (int c = start; c <= end; c++) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3796 | const int logical = header->logicalIndex(c); | - |
3797 | if (!header->isSectionHidden(logical)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3798 | logicalIndexes << logical; | - |
3799 | } never executed: end of block | 0 |
3800 | } never executed: end of block | 0 |
3801 | | - |
3802 | std::sort(logicalIndexes.begin(), logicalIndexes.end()); | - |
3803 | | - |
3804 | QList<QPair<int, int> > ret; | - |
3805 | QPair<int, int> current; | - |
3806 | current.first = -2; | - |
3807 | current.second = -2; | - |
3808 | for(int i = 0; i < logicalIndexes.count(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3809 | const int logicalColumn = logicalIndexes.at(i); | - |
3810 | if (current.second + 1 != logicalColumn) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3811 | if (current.first != -2) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3812 | | - |
3813 | ret += current; | - |
3814 | } never executed: end of block | 0 |
3815 | | - |
3816 | current.first = current.second = logicalColumn; | - |
3817 | } else { never executed: end of block | 0 |
3818 | current.second++; | - |
3819 | } never executed: end of block | 0 |
3820 | } | - |
3821 | | - |
3822 | | - |
3823 | if (current.first != -2) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3824 | ret += current; | - |
3825 | } never executed: end of block | 0 |
3826 | | - |
3827 | return ret; never executed: return ret; | 0 |
3828 | } | - |
3829 | | - |
3830 | void QTreeViewPrivate::select(const QModelIndex &topIndex, const QModelIndex &bottomIndex, | - |
3831 | QItemSelectionModel::SelectionFlags command) | - |
3832 | { | - |
3833 | Q_Q(QTreeView); | - |
3834 | QItemSelection selection; | - |
3835 | const int top = viewIndex(topIndex), | - |
3836 | bottom = viewIndex(bottomIndex); | - |
3837 | | - |
3838 | const QList< QPair<int, int> > colRanges = columnRanges(topIndex, bottomIndex); | - |
3839 | QList< QPair<int, int> >::const_iterator it; | - |
3840 | for (it = colRanges.begin(); it != colRanges.end(); ++it) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3841 | const int left = (*it).first, | - |
3842 | right = (*it).second; | - |
3843 | | - |
3844 | QModelIndex previous; | - |
3845 | QItemSelectionRange currentRange; | - |
3846 | QStack<QItemSelectionRange> rangeStack; | - |
3847 | for (int i = top; i <= bottom; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3848 | QModelIndex index = modelIndex(i); | - |
3849 | QModelIndex parent = index.parent(); | - |
3850 | QModelIndex previousParent = previous.parent(); | - |
3851 | if (previous.isValid() && parent == previousParent) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3852 | | - |
3853 | if (qAbs(previous.row() - index.row()) > 1) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3854 | | - |
3855 | if (currentRange.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3856 | selection.append(currentRange); | - |
3857 | } never executed: end of block | 0 |
3858 | | - |
3859 | currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right)); | - |
3860 | } else { never executed: end of block | 0 |
3861 | QModelIndex tl = model->index(currentRange.top(), currentRange.left(), | - |
3862 | currentRange.parent()); | - |
3863 | currentRange = QItemSelectionRange(tl, index.sibling(index.row(), right)); | - |
3864 | } never executed: end of block | 0 |
3865 | } else if (previous.isValid() && parent == model->index(previous.row(), 0, previousParent)) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3866 | | - |
3867 | rangeStack.push(currentRange); | - |
3868 | currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right)); | - |
3869 | } else { never executed: end of block | 0 |
3870 | if (currentRange.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3871 | selection.append(currentRange); never executed: selection.append(currentRange); | 0 |
3872 | if (rangeStack.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3873 | currentRange = QItemSelectionRange(index.sibling(index.row(), left), index.sibling(index.row(), right)); | - |
3874 | } else { never executed: end of block | 0 |
3875 | currentRange = rangeStack.pop(); | - |
3876 | index = currentRange.bottomRight(); | - |
3877 | --i; | - |
3878 | } never executed: end of block | 0 |
3879 | } | - |
3880 | previous = index; | - |
3881 | } never executed: end of block | 0 |
3882 | if (currentRange.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3883 | selection.append(currentRange); never executed: selection.append(currentRange); | 0 |
3884 | for (int i = 0; i < rangeStack.count(); ++i)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3885 | selection.append(rangeStack.at(i)); never executed: selection.append(rangeStack.at(i)); | 0 |
3886 | } never executed: end of block | 0 |
3887 | q->selectionModel()->select(selection, command); | - |
3888 | } never executed: end of block | 0 |
3889 | | - |
3890 | QPair<int,int> QTreeViewPrivate::startAndEndColumns(const QRect &rect) const | - |
3891 | { | - |
3892 | Q_Q(const QTreeView); | - |
3893 | int start = header->visualIndexAt(rect.left()); | - |
3894 | int end = header->visualIndexAt(rect.right()); | - |
3895 | if (q->isRightToLeft()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3896 | start = (start == -1 ? header->count() - 1 : start);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3897 | end = (end == -1 ? 0 : end);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3898 | } else { never executed: end of block | 0 |
3899 | start = (start == -1 ? 0 : start);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3900 | end = (end == -1 ? header->count() - 1 : end);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3901 | } never executed: end of block | 0 |
3902 | return qMakePair<int,int>(qMin(start, end), qMax(start, end)); never executed: return qMakePair<int,int>(qMin(start, end), qMax(start, end)); | 0 |
3903 | } | - |
3904 | | - |
3905 | bool QTreeViewPrivate::hasVisibleChildren(const QModelIndex& parent) const | - |
3906 | { | - |
3907 | Q_Q(const QTreeView); | - |
3908 | if (parent.flags() & Qt::ItemNeverHasChildren)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3909 | return false; never executed: return false; | 0 |
3910 | if (model->hasChildren(parent)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3911 | if (hiddenIndexes.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3912 | return true; never executed: return true; | 0 |
3913 | if (q->isIndexHidden(parent))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3914 | return false; never executed: return false; | 0 |
3915 | int rowCount = model->rowCount(parent); | - |
3916 | for (int i = 0; i < rowCount; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3917 | if (!q->isRowHidden(i, parent))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3918 | return true; never executed: return true; | 0 |
3919 | } never executed: end of block | 0 |
3920 | if (rowCount == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3921 | return true; never executed: return true; | 0 |
3922 | } never executed: end of block | 0 |
3923 | return false; never executed: return false; | 0 |
3924 | } | - |
3925 | | - |
3926 | void QTreeViewPrivate::_q_sortIndicatorChanged(int column, Qt::SortOrder order) | - |
3927 | { | - |
3928 | model->sort(column, order); | - |
3929 | } never executed: end of block | 0 |
3930 | | - |
3931 | int QTreeViewPrivate::accessibleTree2Index(const QModelIndex &index) const | - |
3932 | { | - |
3933 | Q_Q(const QTreeView); | - |
3934 | | - |
3935 | | - |
3936 | return (q->visualIndex(index) + (q->header() ? 1 : 0)) * index.model()->columnCount() + index.column(); never executed: return (q->visualIndex(index) + (q->header() ? 1 : 0)) * index.model()->columnCount() + index.column(); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3937 | } | - |
3938 | | - |
3939 | void QTreeViewPrivate::updateIndentationFromStyle() | - |
3940 | { | - |
3941 | Q_Q(const QTreeView); | - |
3942 | indent = q->style()->pixelMetric(QStyle::PM_TreeViewIndentation, 0, q); | - |
3943 | } never executed: end of block | 0 |
3944 | | - |
3945 | | - |
3946 | | - |
3947 | | - |
3948 | void QTreeView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) | - |
3949 | { | - |
3950 | QAbstractItemView::currentChanged(current, previous); | - |
3951 | | - |
3952 | if (allColumnsShowFocus()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3953 | if (previous.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3954 | QRect previousRect = visualRect(previous); | - |
3955 | previousRect.setX(0); | - |
3956 | previousRect.setWidth(viewport()->width()); | - |
3957 | viewport()->update(previousRect); | - |
3958 | } never executed: end of block | 0 |
3959 | if (current.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3960 | QRect currentRect = visualRect(current); | - |
3961 | currentRect.setX(0); | - |
3962 | currentRect.setWidth(viewport()->width()); | - |
3963 | viewport()->update(currentRect); | - |
3964 | } never executed: end of block | 0 |
3965 | } never executed: end of block | 0 |
3966 | #ifndef QT_NO_ACCESSIBILITY | - |
3967 | if (QAccessible::isActive() && current.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3968 | Q_D(QTreeView); | - |
3969 | | - |
3970 | QAccessibleEvent event(this, QAccessible::Focus); | - |
3971 | event.setChild(d->accessibleTree2Index(current)); | - |
3972 | QAccessible::updateAccessibility(&event); | - |
3973 | } never executed: end of block | 0 |
3974 | #endif | - |
3975 | } never executed: end of block | 0 |
3976 | | - |
3977 | | - |
3978 | | - |
3979 | | - |
3980 | void QTreeView::selectionChanged(const QItemSelection &selected, | - |
3981 | const QItemSelection &deselected) | - |
3982 | { | - |
3983 | QAbstractItemView::selectionChanged(selected, deselected); | - |
3984 | #ifndef QT_NO_ACCESSIBILITY | - |
3985 | if (QAccessible::isActive()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3986 | Q_D(QTreeView); | - |
3987 | | - |
3988 | | - |
3989 | QModelIndex sel = selected.indexes().value(0); | - |
3990 | if (sel.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3991 | int entry = d->accessibleTree2Index(sel); | - |
3992 | Q_ASSERT(entry >= 0); | - |
3993 | QAccessibleEvent event(this, QAccessible::SelectionAdd); | - |
3994 | event.setChild(entry); | - |
3995 | QAccessible::updateAccessibility(&event); | - |
3996 | } never executed: end of block | 0 |
3997 | QModelIndex desel = deselected.indexes().value(0); | - |
3998 | if (desel.isValid()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3999 | int entry = d->accessibleTree2Index(desel); | - |
4000 | Q_ASSERT(entry >= 0); | - |
4001 | QAccessibleEvent event(this, QAccessible::SelectionRemove); | - |
4002 | event.setChild(entry); | - |
4003 | QAccessible::updateAccessibility(&event); | - |
4004 | } never executed: end of block | 0 |
4005 | } never executed: end of block | 0 |
4006 | #endif | - |
4007 | } never executed: end of block | 0 |
4008 | | - |
4009 | int QTreeView::visualIndex(const QModelIndex &index) const | - |
4010 | { | - |
4011 | Q_D(const QTreeView); | - |
4012 | d->executePostedLayout(); | - |
4013 | return d->viewIndex(index); never executed: return d->viewIndex(index); | 0 |
4014 | } | - |
4015 | | - |
4016 | QT_END_NAMESPACE | - |
4017 | | - |
4018 | #include "moc_qtreeview.cpp" | - |
4019 | | - |
4020 | #endif // QT_NO_TREEVIEW | - |
| | |