Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | #include "qheaderview.h" | - |
41 | | - |
42 | #ifndef QT_NO_ITEMVIEWS | - |
43 | #include <qbitarray.h> | - |
44 | #include <qbrush.h> | - |
45 | #include <qdebug.h> | - |
46 | #include <qevent.h> | - |
47 | #include <qpainter.h> | - |
48 | #include <qscrollbar.h> | - |
49 | #include <qtooltip.h> | - |
50 | #include <qwhatsthis.h> | - |
51 | #include <qstyle.h> | - |
52 | #include <qstyleoption.h> | - |
53 | #include <qvector.h> | - |
54 | #include <qapplication.h> | - |
55 | #include <qvarlengtharray.h> | - |
56 | #include <qabstractitemdelegate.h> | - |
57 | #include <qvariant.h> | - |
58 | #include <private/qheaderview_p.h> | - |
59 | #include <private/qabstractitemmodel_p.h> | - |
60 | | - |
61 | #ifndef QT_NO_DATASTREAM | - |
62 | #include <qdatastream.h> | - |
63 | #endif | - |
64 | | - |
65 | QT_BEGIN_NAMESPACE | - |
66 | | - |
67 | #ifndef QT_NO_DATASTREAM | - |
68 | QDataStream &operator<<(QDataStream &out, const QHeaderViewPrivate::SectionItem §ion) | - |
69 | { | - |
70 | section.write(out); | - |
71 | return out; | - |
72 | } | - |
73 | | - |
74 | QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionItem §ion) | - |
75 | { | - |
76 | section.read(in); | - |
77 | return in; | - |
78 | } | - |
79 | #endif // QT_NO_DATASTREAM | - |
80 | | - |
81 | static const int maxSizeSection = 1048575; | - |
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 | | - |
187 | | - |
188 | | - |
189 | | - |
190 | | - |
191 | | - |
192 | | - |
193 | | - |
194 | | - |
195 | | - |
196 | | - |
197 | | - |
198 | | - |
199 | | - |
200 | | - |
201 | | - |
202 | | - |
203 | | - |
204 | | - |
205 | | - |
206 | | - |
207 | | - |
208 | | - |
209 | | - |
210 | | - |
211 | | - |
212 | | - |
213 | | - |
214 | | - |
215 | | - |
216 | | - |
217 | | - |
218 | | - |
219 | | - |
220 | | - |
221 | | - |
222 | | - |
223 | | - |
224 | | - |
225 | | - |
226 | | - |
227 | | - |
228 | | - |
229 | | - |
230 | | - |
231 | | - |
232 | | - |
233 | | - |
234 | | - |
235 | | - |
236 | | - |
237 | | - |
238 | | - |
239 | | - |
240 | | - |
241 | | - |
242 | | - |
243 | | - |
244 | | - |
245 | | - |
246 | | - |
247 | | - |
248 | | - |
249 | | - |
250 | | - |
251 | | - |
252 | | - |
253 | | - |
254 | | - |
255 | | - |
256 | | - |
257 | | - |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
262 | | - |
263 | | - |
264 | | - |
265 | | - |
266 | | - |
267 | | - |
268 | | - |
269 | | - |
270 | | - |
271 | | - |
272 | | - |
273 | | - |
274 | | - |
275 | | - |
276 | | - |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | | - |
282 | | - |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | | - |
288 | | - |
289 | | - |
290 | | - |
291 | | - |
292 | | - |
293 | | - |
294 | | - |
295 | | - |
296 | | - |
297 | | - |
298 | | - |
299 | | - |
300 | | - |
301 | QHeaderView::QHeaderView(Qt::Orientation orientation, QWidget *parent) | - |
302 | : QAbstractItemView(*new QHeaderViewPrivate, parent) | - |
303 | { | - |
304 | Q_D(QHeaderView); | - |
305 | d->setDefaultValues(orientation); | - |
306 | initialize(); | - |
307 | } | - |
308 | | - |
309 | | - |
310 | | - |
311 | | - |
312 | QHeaderView::QHeaderView(QHeaderViewPrivate &dd, | - |
313 | Qt::Orientation orientation, QWidget *parent) | - |
314 | : QAbstractItemView(dd, parent) | - |
315 | { | - |
316 | Q_D(QHeaderView); | - |
317 | d->setDefaultValues(orientation); | - |
318 | initialize(); | - |
319 | } | - |
320 | | - |
321 | | - |
322 | | - |
323 | | - |
324 | | - |
325 | QHeaderView::~QHeaderView() | - |
326 | { | - |
327 | } | - |
328 | | - |
329 | | - |
330 | | - |
331 | | - |
332 | void QHeaderView::initialize() | - |
333 | { | - |
334 | Q_D(QHeaderView); | - |
335 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - |
336 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - |
337 | setFrameStyle(NoFrame); | - |
338 | setFocusPolicy(Qt::NoFocus); | - |
339 | d->viewport->setMouseTracking(true); | - |
340 | d->viewport->setBackgroundRole(QPalette::Button); | - |
341 | d->textElideMode = Qt::ElideNone; | - |
342 | delete d->itemDelegate; | - |
343 | } | - |
344 | | - |
345 | | - |
346 | | - |
347 | | - |
348 | void QHeaderView::setModel(QAbstractItemModel *model) | - |
349 | { | - |
350 | if (model == this->model()) | - |
351 | return; | - |
352 | Q_D(QHeaderView); | - |
353 | d->persistentHiddenSections.clear(); | - |
354 | if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) { | - |
355 | if (d->orientation == Qt::Horizontal) { | - |
356 | QObject::disconnect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)), | - |
357 | this, SLOT(sectionsInserted(QModelIndex,int,int))); | - |
358 | QObject::disconnect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), | - |
359 | this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); | - |
360 | QObject::disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), | - |
361 | this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); | - |
362 | QObject::disconnect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), | - |
363 | this, SLOT(_q_layoutAboutToBeChanged())); | - |
364 | } else { | - |
365 | QObject::disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), | - |
366 | this, SLOT(sectionsInserted(QModelIndex,int,int))); | - |
367 | QObject::disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), | - |
368 | this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); | - |
369 | QObject::disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), | - |
370 | this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); | - |
371 | QObject::disconnect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), | - |
372 | this, SLOT(_q_layoutAboutToBeChanged())); | - |
373 | } | - |
374 | QObject::disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), | - |
375 | this, SLOT(headerDataChanged(Qt::Orientation,int,int))); | - |
376 | QObject::disconnect(d->model, SIGNAL(layoutAboutToBeChanged()), | - |
377 | this, SLOT(_q_layoutAboutToBeChanged())); | - |
378 | } | - |
379 | | - |
380 | if (model && model != QAbstractItemModelPrivate::staticEmptyModel()) { | - |
381 | if (d->orientation == Qt::Horizontal) { | - |
382 | QObject::connect(model, SIGNAL(columnsInserted(QModelIndex,int,int)), | - |
383 | this, SLOT(sectionsInserted(QModelIndex,int,int))); | - |
384 | QObject::connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), | - |
385 | this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); | - |
386 | QObject::connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), | - |
387 | this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); | - |
388 | QObject::connect(model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), | - |
389 | this, SLOT(_q_layoutAboutToBeChanged())); | - |
390 | } else { | - |
391 | QObject::connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), | - |
392 | this, SLOT(sectionsInserted(QModelIndex,int,int))); | - |
393 | QObject::connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), | - |
394 | this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); | - |
395 | QObject::connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), | - |
396 | this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); | - |
397 | QObject::connect(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), | - |
398 | this, SLOT(_q_layoutAboutToBeChanged())); | - |
399 | } | - |
400 | QObject::connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), | - |
401 | this, SLOT(headerDataChanged(Qt::Orientation,int,int))); | - |
402 | QObject::connect(model, SIGNAL(layoutAboutToBeChanged()), | - |
403 | this, SLOT(_q_layoutAboutToBeChanged())); | - |
404 | } | - |
405 | | - |
406 | d->state = QHeaderViewPrivate::NoClear; | - |
407 | QAbstractItemView::setModel(model); | - |
408 | d->state = QHeaderViewPrivate::NoState; | - |
409 | | - |
410 | | - |
411 | | - |
412 | | - |
413 | initializeSections(); | - |
414 | } | - |
415 | | - |
416 | | - |
417 | | - |
418 | | - |
419 | | - |
420 | | - |
421 | | - |
422 | Qt::Orientation QHeaderView::orientation() const | - |
423 | { | - |
424 | Q_D(const QHeaderView); | - |
425 | return d->orientation; | - |
426 | } | - |
427 | | - |
428 | | - |
429 | | - |
430 | | - |
431 | | - |
432 | | - |
433 | | - |
434 | | - |
435 | int QHeaderView::offset() const | - |
436 | { | - |
437 | Q_D(const QHeaderView); | - |
438 | return d->offset; | - |
439 | } | - |
440 | | - |
441 | | - |
442 | | - |
443 | | - |
444 | | - |
445 | | - |
446 | | - |
447 | | - |
448 | | - |
449 | void QHeaderView::setOffset(int newOffset) | - |
450 | { | - |
451 | Q_D(QHeaderView); | - |
452 | if (d->offset == (int)newOffset) | - |
453 | return; | - |
454 | int ndelta = d->offset - newOffset; | - |
455 | d->offset = newOffset; | - |
456 | if (d->orientation == Qt::Horizontal) | - |
457 | d->viewport->scroll(isRightToLeft() ? -ndelta : ndelta, 0); | - |
458 | else | - |
459 | d->viewport->scroll(0, ndelta); | - |
460 | if (d->state == QHeaderViewPrivate::ResizeSection && !d->preventCursorChangeInSetOffset) { | - |
461 | QPoint cursorPos = QCursor::pos(); | - |
462 | if (d->orientation == Qt::Horizontal) | - |
463 | QCursor::setPos(cursorPos.x() + ndelta, cursorPos.y()); | - |
464 | else | - |
465 | QCursor::setPos(cursorPos.x(), cursorPos.y() + ndelta); | - |
466 | d->firstPos += ndelta; | - |
467 | d->lastPos += ndelta; | - |
468 | } | - |
469 | } | - |
470 | | - |
471 | | - |
472 | | - |
473 | | - |
474 | | - |
475 | | - |
476 | | - |
477 | | - |
478 | | - |
479 | void QHeaderView::setOffsetToSectionPosition(int visualSectionNumber) | - |
480 | { | - |
481 | Q_D(QHeaderView); | - |
482 | if (visualSectionNumber > -1 && visualSectionNumber < d->sectionCount()) { | - |
483 | int position = d->headerSectionPosition(d->adjustedVisualIndex(visualSectionNumber)); | - |
484 | setOffset(position); | - |
485 | } | - |
486 | } | - |
487 | | - |
488 | | - |
489 | | - |
490 | | - |
491 | | - |
492 | | - |
493 | | - |
494 | void QHeaderView::setOffsetToLastSection() | - |
495 | { | - |
496 | Q_D(const QHeaderView); | - |
497 | int size = (d->orientation == Qt::Horizontal ? viewport()->width() : viewport()->height()); | - |
498 | int position = length() - size; | - |
499 | setOffset(position); | - |
500 | } | - |
501 | | - |
502 | | - |
503 | | - |
504 | | - |
505 | | - |
506 | | - |
507 | | - |
508 | int QHeaderView::length() const | - |
509 | { | - |
510 | Q_D(const QHeaderView); | - |
511 | d->executePostedLayout(); | - |
512 | d->executePostedResize(); | - |
513 | | - |
514 | return d->length; | - |
515 | } | - |
516 | | - |
517 | | - |
518 | | - |
519 | | - |
520 | | - |
521 | | - |
522 | | - |
523 | QSize QHeaderView::sizeHint() const | - |
524 | { | - |
525 | Q_D(const QHeaderView); | - |
526 | if (d->cachedSizeHint.isValid()) | - |
527 | return d->cachedSizeHint; | - |
528 | d->cachedSizeHint = QSize(0, 0); | - |
529 | const int sectionCount = count(); | - |
530 | | - |
531 | | - |
532 | int i = 0; | - |
533 | for (int checked = 0; checked < 100 && i < sectionCount; ++i) { | - |
534 | if (isSectionHidden(i)) | - |
535 | continue; | - |
536 | checked++; | - |
537 | QSize hint = sectionSizeFromContents(i); | - |
538 | d->cachedSizeHint = d->cachedSizeHint.expandedTo(hint); | - |
539 | } | - |
540 | | - |
541 | i = qMax(i, sectionCount - 100 ); | - |
542 | for (int j = sectionCount - 1, checked = 0; j >= i && checked < 100; --j) { | - |
543 | if (isSectionHidden(j)) | - |
544 | continue; | - |
545 | checked++; | - |
546 | QSize hint = sectionSizeFromContents(j); | - |
547 | d->cachedSizeHint = d->cachedSizeHint.expandedTo(hint); | - |
548 | } | - |
549 | return d->cachedSizeHint; | - |
550 | } | - |
551 | | - |
552 | | - |
553 | | - |
554 | | - |
555 | | - |
556 | void QHeaderView::setVisible(bool v) | - |
557 | { | - |
558 | bool actualChange = (v != isVisible()); | - |
559 | QAbstractItemView::setVisible(v); | - |
560 | if (actualChange) { | - |
561 | QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea*>(parentWidget()); | - |
562 | if (parent) | - |
563 | parent->updateGeometry(); | - |
564 | } | - |
565 | } | - |
566 | | - |
567 | | - |
568 | | - |
569 | | - |
570 | | - |
571 | | - |
572 | | - |
573 | | - |
574 | | - |
575 | int QHeaderView::sectionSizeHint(int logicalIndex) const | - |
576 | { | - |
577 | Q_D(const QHeaderView); | - |
578 | if (isSectionHidden(logicalIndex)) | - |
579 | return 0; | - |
580 | if (logicalIndex < 0 || logicalIndex >= count()) | - |
581 | return -1; | - |
582 | QSize size; | - |
583 | QVariant value = d->model->headerData(logicalIndex, d->orientation, Qt::SizeHintRole); | - |
584 | if (value.isValid()) | - |
585 | size = qvariant_cast<QSize>(value); | - |
586 | else | - |
587 | size = sectionSizeFromContents(logicalIndex); | - |
588 | int hint = d->orientation == Qt::Horizontal ? size.width() : size.height(); | - |
589 | return qBound(minimumSectionSize(), hint, maximumSectionSize()); | - |
590 | } | - |
591 | | - |
592 | | - |
593 | | - |
594 | | - |
595 | | - |
596 | | - |
597 | | - |
598 | | - |
599 | int QHeaderView::visualIndexAt(int position) const | - |
600 | { | - |
601 | Q_D(const QHeaderView); | - |
602 | int vposition = position; | - |
603 | d->executePostedLayout(); | - |
604 | d->executePostedResize(); | - |
605 | const int count = d->sectionCount(); | - |
606 | if (count < 1) | - |
607 | return -1; | - |
608 | | - |
609 | if (d->reverse()) | - |
610 | vposition = d->viewport->width() - vposition; | - |
611 | vposition += d->offset; | - |
612 | | - |
613 | if (vposition > d->length) | - |
614 | return -1; | - |
615 | int visual = d->headerVisualIndexAt(vposition); | - |
616 | if (visual < 0) | - |
617 | return -1; | - |
618 | | - |
619 | while (d->isVisualIndexHidden(visual)){ | - |
620 | ++visual; | - |
621 | if (visual >= count) | - |
622 | return -1; | - |
623 | } | - |
624 | return visual; | - |
625 | } | - |
626 | | - |
627 | | - |
628 | | - |
629 | | - |
630 | | - |
631 | | - |
632 | | - |
633 | int QHeaderView::logicalIndexAt(int position) const | - |
634 | { | - |
635 | const int visual = visualIndexAt(position); | - |
636 | if (visual > -1) | - |
637 | return logicalIndex(visual); | - |
638 | return -1; | - |
639 | } | - |
640 | | - |
641 | | - |
642 | | - |
643 | | - |
644 | | - |
645 | | - |
646 | | - |
647 | | - |
648 | int QHeaderView::sectionSize(int logicalIndex) const | - |
649 | { | - |
650 | Q_D(const QHeaderView); | - |
651 | if (isSectionHidden(logicalIndex)) | - |
652 | return 0; | - |
653 | if (logicalIndex < 0 || logicalIndex >= count()) | - |
654 | return 0; | - |
655 | int visual = visualIndex(logicalIndex); | - |
656 | if (visual == -1) | - |
657 | return 0; | - |
658 | d->executePostedResize(); | - |
659 | return d->headerSectionSize(visual); | - |
660 | } | - |
661 | | - |
662 | | - |
663 | | - |
664 | | - |
665 | | - |
666 | | - |
667 | | - |
668 | | - |
669 | | - |
670 | | - |
671 | | - |
672 | | - |
673 | int QHeaderView::sectionPosition(int logicalIndex) const | - |
674 | { | - |
675 | Q_D(const QHeaderView); | - |
676 | int visual = visualIndex(logicalIndex); | - |
677 | | - |
678 | | - |
679 | if (visual == -1) | - |
680 | return -1; | - |
681 | d->executePostedResize(); | - |
682 | return d->headerSectionPosition(visual); | - |
683 | } | - |
684 | | - |
685 | | - |
686 | | - |
687 | | - |
688 | | - |
689 | | - |
690 | | - |
691 | | - |
692 | | - |
693 | int QHeaderView::sectionViewportPosition(int logicalIndex) const | - |
694 | { | - |
695 | Q_D(const QHeaderView); | - |
696 | if (logicalIndex >= count()) | - |
697 | return -1; | - |
698 | int position = sectionPosition(logicalIndex); | - |
699 | if (position < 0) | - |
700 | return position; | - |
701 | int offsetPosition = position - d->offset; | - |
702 | if (d->reverse()) | - |
703 | return d->viewport->width() - (offsetPosition + sectionSize(logicalIndex)); | - |
704 | return offsetPosition; | - |
705 | } | - |
706 | | - |
707 | | - |
708 | | - |
709 | | - |
710 | | - |
711 | | - |
712 | | - |
713 | | - |
714 | | - |
715 | | - |
716 | | - |
717 | | - |
718 | | - |
719 | | - |
720 | | - |
721 | | - |
722 | | - |
723 | | - |
724 | | - |
725 | template<typename Container> | - |
726 | static void qMoveRange(Container& c, | - |
727 | typename Container::size_type rangeStart, | - |
728 | typename Container::size_type rangeEnd, | - |
729 | typename Container::size_type targetPosition) | - |
730 | { | - |
731 | Q_ASSERT(targetPosition <= c.size()); | - |
732 | Q_ASSERT(targetPosition < rangeStart || targetPosition >= rangeEnd); | - |
733 | | - |
734 | const bool forwardMove = targetPosition > rangeStart; | - |
735 | typename Container::size_type first = std::min(rangeStart, targetPosition); | - |
736 | typename Container::size_type mid = forwardMove ? rangeEnd : rangeStart; | - |
737 | typename Container::size_type last = forwardMove ? targetPosition + 1 : rangeEnd; | - |
738 | std::rotate(c.begin() + first, c.begin() + mid, c.begin() + last); | - |
739 | } | - |
740 | | - |
741 | | - |
742 | | - |
743 | | - |
744 | | - |
745 | | - |
746 | | - |
747 | void QHeaderView::moveSection(int from, int to) | - |
748 | { | - |
749 | Q_D(QHeaderView); | - |
750 | | - |
751 | d->executePostedLayout(); | - |
752 | if (from < 0 || from >= d->sectionCount() || to < 0 || to >= d->sectionCount())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 |
753 | return; never executed: return; | 0 |
754 | | - |
755 | if (from == to) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
756 | int logical = logicalIndex(from); | - |
757 | Q_ASSERT(logical != -1); | - |
758 | updateSection(logical); | - |
759 | return; never executed: return; | 0 |
760 | } | - |
761 | | - |
762 | if (stretchLastSection() && to == d->lastVisibleVisualIndex()) | - |
| d->lastSectionSize = sectionSize(from);d->initializeIndexMapping(); | |
763 | | - |
764 | int *visualIndices = d->visualIndices.data(); | - |
765 | int *logicalIndices = d->logicalIndices.data(); | - |
766 | int logical = logicalIndices[from]; | - |
767 | int visual = from; | - |
768 | | - |
769 | if (to > from) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
770 | while (visual < to) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
771 | visualIndices[logicalIndices[visual + 1]] = visual; | - |
772 | logicalIndices[visual] = logicalIndices[visual + 1]; | - |
773 | ++visual; | - |
774 | } never executed: end of block | 0 |
775 | } else { never executed: end of block | 0 |
776 | while (visual > to) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
777 | visualIndices[logicalIndices[visual - 1]] = visual; | - |
778 | logicalIndices[visual] = logicalIndices[visual - 1]; | - |
779 | --visual; | - |
780 | } never executed: end of block | 0 |
781 | } never executed: end of block | 0 |
782 | visualIndices[logical] = to; | - |
783 | logicalIndices[to] = logical; | - |
784 | | - |
785 | qMoveRange(d->sectionItems, from, from + 1, to); | - |
786 | | - |
787 | d->sectionStartposRecalc = true; | - |
788 | | - |
789 | if (d->hasAutoResizeSections())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
790 | d->doDelayedResizeSections(); never executed: d->doDelayedResizeSections(); | 0 |
791 | d->viewport->update(); | - |
792 | | - |
793 | emit sectionMoved(logical, from, to); | - |
794 | | - |
795 | if (stretchLastSection()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
796 | const int lastSectionVisualIdx = visualIndex(d->lastSectionLogicalIdx); | - |
797 | if (from >= lastSectionVisualIdx || to >= lastSectionVisualIdx)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
798 | d->maybeRestorePrevLastSectionAndStretchLast(); never executed: d->maybeRestorePrevLastSectionAndStretchLast(); | 0 |
799 | } never executed: end of block | 0 |
800 | } never executed: end of block | 0 |
801 | | - |
802 | | - |
803 | | - |
804 | | - |
805 | | - |
806 | | - |
807 | | - |
808 | | - |
809 | void QHeaderView::swapSections(int first, int second) | - |
810 | { | - |
811 | Q_D(QHeaderView); | - |
812 | | - |
813 | if (first == second)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
814 | return; never executed: return; | 0 |
815 | d->executePostedLayout(); | - |
816 | if (first < 0 || first >= d->sectionCount() || second < 0 || second >= d->sectionCount())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 |
817 | return; never executed: return; | 0 |
818 | | - |
819 | int firstSize = d->headerSectionSize(first); | - |
820 | ResizeMode firstMode = d->headerSectionResizeMode(first); | - |
821 | int firstLogical = d->logicalIndex(first); | - |
822 | | - |
823 | int secondSize = d->headerSectionSize(second); | - |
824 | ResizeMode secondMode = d->headerSectionResizeMode(second); | - |
825 | int secondLogical = d->logicalIndex(second); | - |
826 | | - |
827 | if (d->state == QHeaderViewPrivate::ResizeSection)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
828 | d->preventCursorChangeInSetOffset = true; never executed: d->preventCursorChangeInSetOffset = true; | 0 |
829 | | - |
830 | d->createSectionItems(second, second, firstSize, firstMode); | - |
831 | d->createSectionItems(first, first, secondSize, secondMode); | - |
832 | | - |
833 | d->initializeIndexMapping(); | - |
834 | | - |
835 | d->visualIndices[firstLogical] = second; | - |
836 | d->logicalIndices[second] = firstLogical; | - |
837 | | - |
838 | d->visualIndices[secondLogical] = first; | - |
839 | d->logicalIndices[first] = secondLogical; | - |
840 | | - |
841 | if (!d->hiddenSectionSize.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
842 | bool firstHidden = d->isVisualIndexHidden(first); | - |
843 | bool secondHidden = d->isVisualIndexHidden(second); | - |
844 | d->setVisualIndexHidden(first, secondHidden); | - |
845 | d->setVisualIndexHidden(second, firstHidden); | - |
846 | } never executed: end of block | 0 |
847 | | - |
848 | d->viewport->update(); | - |
849 | emit sectionMoved(firstLogical, first, second); | - |
850 | emit sectionMoved(secondLogical, second, first); | - |
851 | | - |
852 | if (stretchLastSection()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
853 | const int lastSectionVisualIdx = visualIndex(d->lastSectionLogicalIdx); | - |
854 | if (first >= lastSectionVisualIdx || second >= lastSectionVisualIdx)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
855 | d->maybeRestorePrevLastSectionAndStretchLast(); never executed: d->maybeRestorePrevLastSectionAndStretchLast(); | 0 |
856 | } never executed: end of block | 0 |
857 | } never executed: end of block | 0 |
858 | | - |
859 | | - |
860 | | - |
861 | | - |
862 | | - |
863 | | - |
864 | | - |
865 | | - |
866 | | - |
867 | | - |
868 | | - |
869 | | - |
870 | void QHeaderView::resizeSection(int logical, int size) | - |
871 | { | - |
872 | Q_D(QHeaderView); | - |
873 | if (logical < 0 || logical >= count() || size < 0 || size > maxSizeSection)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 |
874 | return; never executed: return; | 0 |
875 | | - |
876 | if (isSectionHidden(logical)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
877 | d->hiddenSectionSize.insert(logical, size); | - |
878 | return; never executed: return; | 0 |
879 | } | - |
880 | | - |
881 | int visual = visualIndex(logical); | - |
882 | if (visual == -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
883 | return; never executed: return; | 0 |
884 | | - |
885 | if (d->state == QHeaderViewPrivate::ResizeSection && !d->cascadingResizing && logical != d->section)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
886 | d->preventCursorChangeInSetOffset = true; never executed: d->preventCursorChangeInSetOffset = true; | 0 |
887 | | - |
888 | int oldSize = d->headerSectionSize(visual); | - |
889 | if (oldSize == size)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
890 | return; never executed: return; | 0 |
891 | | - |
892 | d->executePostedLayout(); | - |
893 | d->invalidateCachedSizeHint(); | - |
894 | | - |
895 | if (stretchLastSection() && visuallogical == d->lastVisibleVisualIndex())lastSectionLogicalIdx)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
896 | d->lastSectionSize = size; never executed: d->lastSectionSize = size; | 0 |
897 | | - |
898 | d->createSectionItems(visual, visual, size, d->headerSectionResizeMode(visual)); | - |
899 | | - |
900 | if (!updatesEnabled()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
901 | if (d->hasAutoResizeSections())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
902 | d->doDelayedResizeSections(); never executed: d->doDelayedResizeSections(); | 0 |
903 | emit sectionResized(logical, oldSize, size); | - |
904 | return; never executed: return; | 0 |
905 | } | - |
906 | | - |
907 | int w = d->viewport->width(); | - |
908 | int h = d->viewport->height(); | - |
909 | int pos = sectionViewportPosition(logical); | - |
910 | QRect r; | - |
911 | if (d->orientation == Qt::Horizontal)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
912 | if (isRightToLeft())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
913 | r.setRect(0, 0, pos + size, h); never executed: r.setRect(0, 0, pos + size, h); | 0 |
914 | else | - |
915 | r.setRect(pos, 0, w - pos, h); never executed: r.setRect(pos, 0, w - pos, h); | 0 |
916 | else | - |
917 | r.setRect(0, pos, w, h - pos); never executed: r.setRect(0, pos, w, h - pos); | 0 |
918 | | - |
919 | if (d->hasAutoResizeSections()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
920 | d->doDelayedResizeSections(); | - |
921 | r = d->viewport->rect(); | - |
922 | } never executed: end of block | 0 |
923 | | - |
924 | | - |
925 | | - |
926 | | - |
927 | | - |
928 | | - |
929 | | - |
930 | | - |
931 | QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea *>(parentWidget()); | - |
932 | if (parent && parent->sizeAdjustPolicy() == QAbstractScrollArea::AdjustToContents)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
933 | parent->updateGeometry(); never executed: parent->updateGeometry(); | 0 |
934 | | - |
935 | d->viewport->update(r.normalized()); | - |
936 | emit sectionResized(logical, oldSize, size); | - |
937 | } never executed: end of block | 0 |
938 | | - |
939 | | - |
940 | | - |
941 | | - |
942 | | - |
943 | | - |
944 | | - |
945 | | - |
946 | void QHeaderView::resizeSections(QHeaderView::ResizeMode mode) | - |
947 | { | - |
948 | Q_D(QHeaderView); | - |
949 | d->resizeSections(mode, true); | - |
950 | } | - |
951 | | - |
952 | | - |
953 | | - |
954 | | - |
955 | | - |
956 | | - |
957 | | - |
958 | | - |
959 | | - |
960 | | - |
961 | | - |
962 | | - |
963 | | - |
964 | | - |
965 | | - |
966 | | - |
967 | | - |
968 | | - |
969 | | - |
970 | | - |
971 | | - |
972 | | - |
973 | | - |
974 | | - |
975 | bool QHeaderView::isSectionHidden(int logicalIndex) const | - |
976 | { | - |
977 | Q_D(const QHeaderView); | - |
978 | d->executePostedLayout(); | - |
979 | if (d->hiddenSectionSize.isEmpty() || logicalIndex < 0 || logicalIndex >= d->sectionCount()) | - |
980 | return false; | - |
981 | int visual = visualIndex(logicalIndex); | - |
982 | Q_ASSERT(visual != -1); | - |
983 | return d->isVisualIndexHidden(visual); | - |
984 | } | - |
985 | | - |
986 | | - |
987 | | - |
988 | | - |
989 | | - |
990 | | - |
991 | | - |
992 | | - |
993 | int QHeaderView::hiddenSectionCount() const | - |
994 | { | - |
995 | Q_D(const QHeaderView); | - |
996 | return d->hiddenSectionSize.count(); | - |
997 | } | - |
998 | | - |
999 | | - |
1000 | | - |
1001 | | - |
1002 | | - |
1003 | | - |
1004 | | - |
1005 | | - |
1006 | void QHeaderView::setSectionHidden(int logicalIndex, bool hide) | - |
1007 | { | - |
1008 | Q_D(QHeaderView); | - |
1009 | if (logicalIndex < 0 || logicalIndex >= count())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1010 | return; never executed: return; | 0 |
1011 | | - |
1012 | d->executePostedLayout(); | - |
1013 | int visual = visualIndex(logicalIndex); | - |
1014 | Q_ASSERT(visual != -1); | - |
1015 | if (hide == d->isVisualIndexHidden(visual))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1016 | return; never executed: return; | 0 |
1017 | if (hide) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1018 | const bool isHidingLastSection = (stretchLastSection() && logicalIndex == d->lastSectionLogicalIdx);TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1019 | if (isHidingLastSection)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1020 | d->restoreSizeOnPrevLastSection(); never executed: d->restoreSizeOnPrevLastSection(); never executed: d->restoreSizeOnPrevLastSection(); | 0 |
1021 | int size = d->headerSectionSize(visual); | - |
1022 | if (!d->hasAutoResizeSections())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1023 | resizeSection(logicalIndex, 0); never executed: resizeSection(logicalIndex, 0); | 0 |
1024 | d->hiddenSectionSize.insert(logicalIndex, size); | - |
1025 | d->setVisualIndexHidden(visual, true); | - |
1026 | if (isHidingLastSection)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1027 | d->setNewLastSection(d->lastVisibleVisualIndex()); never executed: d->setNewLastSection(d->lastVisibleVisualIndex()); | 0 |
1028 | if (d->hasAutoResizeSections())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1029 | d->doDelayedResizeSections(); never executed: d->doDelayedResizeSections(); | 0 |
1030 | } else { never executed: end of block | 0 |
1031 | int size = d->hiddenSectionSize.value(logicalIndex, d->defaultSectionSize); | - |
1032 | d->hiddenSectionSize.remove(logicalIndex); | - |
1033 | d->setVisualIndexHidden(visual, false); | - |
1034 | resizeSection(logicalIndex, size); | - |
1035 | | - |
1036 | const bool newLastSection = (stretchLastSection() && visual > visualIndex(d->lastSectionLogicalIdx));TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1037 | if (newLastSection) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1038 | d->restoreSizeOnPrevLastSection(); | - |
1039 | d->setNewLastSection(visual); | - |
1040 | } never executed: end of block | 0 |
1041 | } never executed: end of block | 0 |
1042 | } | - |
1043 | | - |
1044 | | - |
1045 | | - |
1046 | | - |
1047 | | - |
1048 | | - |
1049 | | - |
1050 | int QHeaderView::count() const | - |
1051 | { | - |
1052 | Q_D(const QHeaderView); | - |
1053 | | - |
1054 | | - |
1055 | d->executePostedLayout(); | - |
1056 | return d->sectionCount(); | - |
1057 | } | - |
1058 | | - |
1059 | | - |
1060 | | - |
1061 | | - |
1062 | | - |
1063 | | - |
1064 | | - |
1065 | | - |
1066 | | - |
1067 | | - |
1068 | int QHeaderView::visualIndex(int logicalIndex) const | - |
1069 | { | - |
1070 | Q_D(const QHeaderView); | - |
1071 | if (logicalIndex < 0) | - |
1072 | return -1; | - |
1073 | d->executePostedLayout(); | - |
1074 | if (d->visualIndices.isEmpty()) { | - |
1075 | if (logicalIndex < d->sectionCount()) | - |
1076 | return logicalIndex; | - |
1077 | } else if (logicalIndex < d->visualIndices.count()) { | - |
1078 | int visual = d->visualIndices.at(logicalIndex); | - |
1079 | Q_ASSERT(visual < d->sectionCount()); | - |
1080 | return visual; | - |
1081 | } | - |
1082 | return -1; | - |
1083 | } | - |
1084 | | - |
1085 | | - |
1086 | | - |
1087 | | - |
1088 | | - |
1089 | | - |
1090 | | - |
1091 | | - |
1092 | | - |
1093 | | - |
1094 | int QHeaderView::logicalIndex(int visualIndex) const | - |
1095 | { | - |
1096 | Q_D(const QHeaderView); | - |
1097 | if (visualIndex < 0 || visualIndex >= d->sectionCount()) | - |
1098 | return -1; | - |
1099 | return d->logicalIndex(visualIndex); | - |
1100 | } | - |
1101 | | - |
1102 | | - |
1103 | | - |
1104 | | - |
1105 | | - |
1106 | | - |
1107 | | - |
1108 | | - |
1109 | | - |
1110 | | - |
1111 | void QHeaderView::setSectionsMovable(bool movable) | - |
1112 | { | - |
1113 | Q_D(QHeaderView); | - |
1114 | d->movableSections = movable; | - |
1115 | } | - |
1116 | | - |
1117 | | - |
1118 | | - |
1119 | | - |
1120 | | - |
1121 | | - |
1122 | | - |
1123 | | - |
1124 | | - |
1125 | | - |
1126 | | - |
1127 | | - |
1128 | | - |
1129 | | - |
1130 | | - |
1131 | | - |
1132 | | - |
1133 | | - |
1134 | | - |
1135 | | - |
1136 | bool QHeaderView::sectionsMovable() const | - |
1137 | { | - |
1138 | Q_D(const QHeaderView); | - |
1139 | return d->movableSections; | - |
1140 | } | - |
1141 | | - |
1142 | | - |
1143 | | - |
1144 | | - |
1145 | | - |
1146 | | - |
1147 | | - |
1148 | | - |
1149 | | - |
1150 | | - |
1151 | | - |
1152 | | - |
1153 | | - |
1154 | | - |
1155 | | - |
1156 | | - |
1157 | | - |
1158 | | - |
1159 | | - |
1160 | | - |
1161 | void QHeaderView::setSectionsClickable(bool clickable) | - |
1162 | { | - |
1163 | Q_D(QHeaderView); | - |
1164 | d->clickableSections = clickable; | - |
1165 | } | - |
1166 | | - |
1167 | | - |
1168 | | - |
1169 | | - |
1170 | | - |
1171 | | - |
1172 | | - |
1173 | | - |
1174 | | - |
1175 | | - |
1176 | | - |
1177 | | - |
1178 | | - |
1179 | | - |
1180 | | - |
1181 | | - |
1182 | | - |
1183 | | - |
1184 | | - |
1185 | | - |
1186 | | - |
1187 | bool QHeaderView::sectionsClickable() const | - |
1188 | { | - |
1189 | Q_D(const QHeaderView); | - |
1190 | return d->clickableSections; | - |
1191 | } | - |
1192 | | - |
1193 | | - |
1194 | | - |
1195 | | - |
1196 | | - |
1197 | | - |
1198 | | - |
1199 | | - |
1200 | | - |
1201 | | - |
1202 | | - |
1203 | void QHeaderView::setHighlightSections(bool highlight) | - |
1204 | { | - |
1205 | Q_D(QHeaderView); | - |
1206 | d->highlightSelected = highlight; | - |
1207 | } | - |
1208 | | - |
1209 | bool QHeaderView::highlightSections() const | - |
1210 | { | - |
1211 | Q_D(const QHeaderView); | - |
1212 | return d->highlightSelected; | - |
1213 | } | - |
1214 | | - |
1215 | | - |
1216 | | - |
1217 | | - |
1218 | | - |
1219 | | - |
1220 | | - |
1221 | | - |
1222 | | - |
1223 | | - |
1224 | void QHeaderView::setSectionResizeMode(ResizeMode mode) | - |
1225 | { | - |
1226 | Q_D(QHeaderView); | - |
1227 | initializeSections(); | - |
1228 | d->stretchSections = (mode == Stretch ? count() : 0); | - |
1229 | d->contentsSections = (mode == ResizeToContents ? count() : 0); | - |
1230 | d->setGlobalHeaderResizeMode(mode); | - |
1231 | if (d->hasAutoResizeSections()) | - |
1232 | d->doDelayedResizeSections(); | - |
1233 | } | - |
1234 | | - |
1235 | | - |
1236 | | - |
1237 | | - |
1238 | | - |
1239 | | - |
1240 | | - |
1241 | | - |
1242 | | - |
1243 | | - |
1244 | | - |
1245 | | - |
1246 | | - |
1247 | | - |
1248 | | - |
1249 | void QHeaderView::setSectionResizeMode(int logicalIndex, ResizeMode mode) | - |
1250 | { | - |
1251 | Q_D(QHeaderView); | - |
1252 | int visual = visualIndex(logicalIndex); | - |
1253 | Q_ASSERT(visual != -1); | - |
1254 | | - |
1255 | ResizeMode old = d->headerSectionResizeMode(visual); | - |
1256 | d->setHeaderSectionResizeMode(visual, mode); | - |
1257 | | - |
1258 | if (mode == Stretch && old != Stretch) | - |
1259 | ++d->stretchSections; | - |
1260 | else if (mode == ResizeToContents && old != ResizeToContents) | - |
1261 | ++d->contentsSections; | - |
1262 | else if (mode != Stretch && old == Stretch) | - |
1263 | --d->stretchSections; | - |
1264 | else if (mode != ResizeToContents && old == ResizeToContents) | - |
1265 | --d->contentsSections; | - |
1266 | | - |
1267 | if (d->hasAutoResizeSections() && d->state == QHeaderViewPrivate::NoState) | - |
1268 | d->doDelayedResizeSections(); | - |
1269 | } | - |
1270 | | - |
1271 | | - |
1272 | | - |
1273 | | - |
1274 | | - |
1275 | | - |
1276 | | - |
1277 | | - |
1278 | | - |
1279 | | - |
1280 | | - |
1281 | | - |
1282 | | - |
1283 | | - |
1284 | | - |
1285 | | - |
1286 | | - |
1287 | | - |
1288 | | - |
1289 | | - |
1290 | | - |
1291 | | - |
1292 | | - |
1293 | | - |
1294 | | - |
1295 | | - |
1296 | | - |
1297 | | - |
1298 | | - |
1299 | | - |
1300 | QHeaderView::ResizeMode QHeaderView::sectionResizeMode(int logicalIndex) const | - |
1301 | { | - |
1302 | Q_D(const QHeaderView); | - |
1303 | int visual = visualIndex(logicalIndex); | - |
1304 | if (visual == -1) | - |
1305 | return Fixed; | - |
1306 | return d->headerSectionResizeMode(visual); | - |
1307 | } | - |
1308 | | - |
1309 | | - |
1310 | | - |
1311 | | - |
1312 | | - |
1313 | | - |
1314 | | - |
1315 | | - |
1316 | | - |
1317 | | - |
1318 | | - |
1319 | | - |
1320 | | - |
1321 | | - |
1322 | | - |
1323 | | - |
1324 | | - |
1325 | | - |
1326 | | - |
1327 | | - |
1328 | | - |
1329 | | - |
1330 | | - |
1331 | void QHeaderView::setResizeContentsPrecision(int precision) | - |
1332 | { | - |
1333 | Q_D(QHeaderView); | - |
1334 | d->resizeContentsPrecision = precision; | - |
1335 | } | - |
1336 | | - |
1337 | | - |
1338 | | - |
1339 | | - |
1340 | | - |
1341 | | - |
1342 | | - |
1343 | | - |
1344 | | - |
1345 | int QHeaderView::resizeContentsPrecision() const | - |
1346 | { | - |
1347 | Q_D(const QHeaderView); | - |
1348 | return d->resizeContentsPrecision; | - |
1349 | } | - |
1350 | | - |
1351 | | - |
1352 | | - |
1353 | | - |
1354 | | - |
1355 | | - |
1356 | | - |
1357 | | - |
1358 | | - |
1359 | | - |
1360 | | - |
1361 | | - |
1362 | | - |
1363 | | - |
1364 | | - |
1365 | | - |
1366 | | - |
1367 | | - |
1368 | | - |
1369 | | - |
1370 | | - |
1371 | int QHeaderView::stretchSectionCount() const | - |
1372 | { | - |
1373 | Q_D(const QHeaderView); | - |
1374 | return d->stretchSections; | - |
1375 | } | - |
1376 | | - |
1377 | | - |
1378 | | - |
1379 | | - |
1380 | | - |
1381 | | - |
1382 | | - |
1383 | | - |
1384 | | - |
1385 | | - |
1386 | void QHeaderView::setSortIndicatorShown(bool show) | - |
1387 | { | - |
1388 | Q_D(QHeaderView); | - |
1389 | if (d->sortIndicatorShown == show) | - |
1390 | return; | - |
1391 | | - |
1392 | d->sortIndicatorShown = show; | - |
1393 | | - |
1394 | if (sortIndicatorSection() < 0 || sortIndicatorSection() > count()) | - |
1395 | return; | - |
1396 | | - |
1397 | if (d->headerSectionResizeMode(sortIndicatorSection()) == ResizeToContents) | - |
1398 | resizeSections(); | - |
1399 | | - |
1400 | d->viewport->update(); | - |
1401 | } | - |
1402 | | - |
1403 | bool QHeaderView::isSortIndicatorShown() const | - |
1404 | { | - |
1405 | Q_D(const QHeaderView); | - |
1406 | return d->sortIndicatorShown; | - |
1407 | } | - |
1408 | | - |
1409 | | - |
1410 | | - |
1411 | | - |
1412 | | - |
1413 | | - |
1414 | | - |
1415 | | - |
1416 | | - |
1417 | | - |
1418 | | - |
1419 | | - |
1420 | | - |
1421 | void QHeaderView::setSortIndicator(int logicalIndex, Qt::SortOrder order) | - |
1422 | { | - |
1423 | Q_D(QHeaderView); | - |
1424 | | - |
1425 | | - |
1426 | int old = d->sortIndicatorSection; | - |
1427 | if (old == logicalIndex && order == d->sortIndicatorOrder) | - |
1428 | return; | - |
1429 | d->sortIndicatorSection = logicalIndex; | - |
1430 | d->sortIndicatorOrder = order; | - |
1431 | | - |
1432 | if (logicalIndex >= d->sectionCount()) { | - |
1433 | emit sortIndicatorChanged(logicalIndex, order); | - |
1434 | return; | - |
1435 | } | - |
1436 | | - |
1437 | if (old != logicalIndex | - |
1438 | && ((logicalIndex >= 0 && sectionResizeMode(logicalIndex) == ResizeToContents) | - |
1439 | || old >= d->sectionCount() || (old >= 0 && sectionResizeMode(old) == ResizeToContents))) { | - |
1440 | resizeSections(); | - |
1441 | d->viewport->update(); | - |
1442 | } else { | - |
1443 | if (old >= 0 && old != logicalIndex) | - |
1444 | updateSection(old); | - |
1445 | if (logicalIndex >= 0) | - |
1446 | updateSection(logicalIndex); | - |
1447 | } | - |
1448 | | - |
1449 | emit sortIndicatorChanged(logicalIndex, order); | - |
1450 | } | - |
1451 | | - |
1452 | | - |
1453 | | - |
1454 | | - |
1455 | | - |
1456 | | - |
1457 | | - |
1458 | | - |
1459 | int QHeaderView::sortIndicatorSection() const | - |
1460 | { | - |
1461 | Q_D(const QHeaderView); | - |
1462 | return d->sortIndicatorSection; | - |
1463 | } | - |
1464 | | - |
1465 | | - |
1466 | | - |
1467 | | - |
1468 | | - |
1469 | | - |
1470 | | - |
1471 | | - |
1472 | Qt::SortOrder QHeaderView::sortIndicatorOrder() const | - |
1473 | { | - |
1474 | Q_D(const QHeaderView); | - |
1475 | return d->sortIndicatorOrder; | - |
1476 | } | - |
1477 | | - |
1478 | | - |
1479 | | - |
1480 | | - |
1481 | | - |
1482 | | - |
1483 | | - |
1484 | | - |
1485 | | - |
1486 | | - |
1487 | | - |
1488 | | - |
1489 | | - |
1490 | | - |
1491 | | - |
1492 | | - |
1493 | bool QHeaderView::stretchLastSection() const | - |
1494 | { | - |
1495 | Q_D(const QHeaderView); | - |
1496 | return d->stretchLastSection; | - |
1497 | } | - |
1498 | | - |
1499 | void QHeaderView::setStretchLastSection(bool stretch) | - |
1500 | { | - |
1501 | Q_D(QHeaderView); | - |
1502 | if (d->stretchLastSection == stretch)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1503 | return; never executed: return; | 0 |
1504 | d->stretchLastSection = stretch; | - |
1505 | if (d->state != QHeaderViewPrivate::NoState)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1506 | return; never executed: return; | 0 |
1507 | if (stretch) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1508 | d->setNewLastSection(d->lastVisibleVisualIndex()); | - |
1509 | resizeSections(); | - |
1510 | } else if (count()) never executed: end of block | 0 |
| resizeSection(count() - 1, never executed: end of block {never executed: end of block | |
1511 | d->defaultSectionSize);restoreSizeOnPrevLastSection(); | - |
1512 | } never executed: end of block | 0 |
1513 | } | - |
1514 | | - |
1515 | | - |
1516 | | - |
1517 | | - |
1518 | | - |
1519 | | - |
1520 | | - |
1521 | | - |
1522 | | - |
1523 | | - |
1524 | | - |
1525 | | - |
1526 | | - |
1527 | | - |
1528 | | - |
1529 | bool QHeaderView::cascadingSectionResizes() const | - |
1530 | { | - |
1531 | Q_D(const QHeaderView); | - |
1532 | return d->cascadingResizing; | - |
1533 | } | - |
1534 | | - |
1535 | void QHeaderView::setCascadingSectionResizes(bool enable) | - |
1536 | { | - |
1537 | Q_D(QHeaderView); | - |
1538 | d->cascadingResizing = enable; | - |
1539 | } | - |
1540 | | - |
1541 | | - |
1542 | | - |
1543 | | - |
1544 | | - |
1545 | | - |
1546 | | - |
1547 | | - |
1548 | | - |
1549 | | - |
1550 | | - |
1551 | | - |
1552 | | - |
1553 | | - |
1554 | | - |
1555 | int QHeaderView::defaultSectionSize() const | - |
1556 | { | - |
1557 | Q_D(const QHeaderView); | - |
1558 | return d->defaultSectionSize; | - |
1559 | } | - |
1560 | | - |
1561 | void QHeaderView::setDefaultSectionSize(int size) | - |
1562 | { | - |
1563 | Q_D(QHeaderView); | - |
1564 | if (size < 0 || size > maxSizeSection) | - |
1565 | return; | - |
1566 | d->setDefaultSectionSize(size); | - |
1567 | } | - |
1568 | | - |
1569 | void QHeaderView::resetDefaultSectionSize() | - |
1570 | { | - |
1571 | Q_D(QHeaderView); | - |
1572 | if (d->customDefaultSectionSize) { | - |
1573 | d->updateDefaultSectionSizeFromStyle(); | - |
1574 | d->customDefaultSectionSize = false; | - |
1575 | } | - |
1576 | } | - |
1577 | | - |
1578 | | - |
1579 | | - |
1580 | | - |
1581 | | - |
1582 | | - |
1583 | | - |
1584 | | - |
1585 | | - |
1586 | | - |
1587 | | - |
1588 | | - |
1589 | | - |
1590 | | - |
1591 | | - |
1592 | int QHeaderView::minimumSectionSize() const | - |
1593 | { | - |
1594 | Q_D(const QHeaderView); | - |
1595 | if (d->minimumSectionSize == -1) { | - |
1596 | QSize strut = QApplication::globalStrut(); | - |
1597 | int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); | - |
1598 | if (d->orientation == Qt::Horizontal) | - |
1599 | return qMax(strut.width(), (fontMetrics().maxWidth() + margin)); | - |
1600 | return qMax(strut.height(), (fontMetrics().height() + margin)); | - |
1601 | } | - |
1602 | return d->minimumSectionSize; | - |
1603 | } | - |
1604 | | - |
1605 | void QHeaderView::setMinimumSectionSize(int size) | - |
1606 | { | - |
1607 | Q_D(QHeaderView); | - |
1608 | if (size < -1 || size > maxSizeSection) | - |
1609 | return; | - |
1610 | d->minimumSectionSize = size; | - |
1611 | if (d->minimumSectionSize > maximumSectionSize()) | - |
1612 | d->maximumSectionSize = size; | - |
1613 | } | - |
1614 | | - |
1615 | | - |
1616 | | - |
1617 | | - |
1618 | | - |
1619 | | - |
1620 | | - |
1621 | | - |
1622 | | - |
1623 | | - |
1624 | | - |
1625 | | - |
1626 | | - |
1627 | | - |
1628 | | - |
1629 | int QHeaderView::maximumSectionSize() const | - |
1630 | { | - |
1631 | Q_D(const QHeaderView); | - |
1632 | if (d->maximumSectionSize == -1) | - |
1633 | return maxSizeSection; | - |
1634 | return d->maximumSectionSize; | - |
1635 | } | - |
1636 | | - |
1637 | void QHeaderView::setMaximumSectionSize(int size) | - |
1638 | { | - |
1639 | Q_D(QHeaderView); | - |
1640 | if (size == -1) { | - |
1641 | d->maximumSectionSize = maxSizeSection; | - |
1642 | return; | - |
1643 | } | - |
1644 | if (size < 0 || size > maxSizeSection) | - |
1645 | return; | - |
1646 | if (minimumSectionSize() > size) | - |
1647 | d->minimumSectionSize = size; | - |
1648 | | - |
1649 | d->maximumSectionSize = size; | - |
1650 | } | - |
1651 | | - |
1652 | | - |
1653 | | - |
1654 | | - |
1655 | | - |
1656 | | - |
1657 | | - |
1658 | | - |
1659 | Qt::Alignment QHeaderView::defaultAlignment() const | - |
1660 | { | - |
1661 | Q_D(const QHeaderView); | - |
1662 | return d->defaultAlignment; | - |
1663 | } | - |
1664 | | - |
1665 | void QHeaderView::setDefaultAlignment(Qt::Alignment alignment) | - |
1666 | { | - |
1667 | Q_D(QHeaderView); | - |
1668 | if (d->defaultAlignment == alignment) | - |
1669 | return; | - |
1670 | | - |
1671 | d->defaultAlignment = alignment; | - |
1672 | d->viewport->update(); | - |
1673 | } | - |
1674 | | - |
1675 | | - |
1676 | | - |
1677 | | - |
1678 | void QHeaderView::doItemsLayout() | - |
1679 | { | - |
1680 | initializeSections(); | - |
1681 | QAbstractItemView::doItemsLayout(); | - |
1682 | } | - |
1683 | | - |
1684 | | - |
1685 | | - |
1686 | | - |
1687 | | - |
1688 | | - |
1689 | | - |
1690 | bool QHeaderView::sectionsMoved() const | - |
1691 | { | - |
1692 | Q_D(const QHeaderView); | - |
1693 | return !d->visualIndices.isEmpty(); | - |
1694 | } | - |
1695 | | - |
1696 | | - |
1697 | | - |
1698 | | - |
1699 | | - |
1700 | | - |
1701 | | - |
1702 | | - |
1703 | | - |
1704 | bool QHeaderView::sectionsHidden() const | - |
1705 | { | - |
1706 | Q_D(const QHeaderView); | - |
1707 | return !d->hiddenSectionSize.isEmpty(); | - |
1708 | } | - |
1709 | | - |
1710 | #ifndef QT_NO_DATASTREAM | - |
1711 | | - |
1712 | | - |
1713 | | - |
1714 | | - |
1715 | | - |
1716 | | - |
1717 | | - |
1718 | | - |
1719 | | - |
1720 | QByteArray QHeaderView::saveState() const | - |
1721 | { | - |
1722 | Q_D(const QHeaderView); | - |
1723 | QByteArray data; | - |
1724 | QDataStream stream(&data, QIODevice::WriteOnly); | - |
1725 | stream << QHeaderViewPrivate::VersionMarker; | - |
1726 | stream << 0; | - |
1727 | d->write(stream); | - |
1728 | return data; | - |
1729 | } | - |
1730 | | - |
1731 | | - |
1732 | | - |
1733 | | - |
1734 | | - |
1735 | | - |
1736 | | - |
1737 | | - |
1738 | | - |
1739 | bool QHeaderView::restoreState(const QByteArray &state) | - |
1740 | { | - |
1741 | Q_D(QHeaderView); | - |
1742 | if (state.isEmpty()) | - |
1743 | return false; | - |
1744 | QByteArray data = state; | - |
1745 | QDataStream stream(&data, QIODevice::ReadOnly); | - |
1746 | int marker; | - |
1747 | int ver; | - |
1748 | stream >> marker; | - |
1749 | stream >> ver; | - |
1750 | if (stream.status() != QDataStream::Ok | - |
1751 | || marker != QHeaderViewPrivate::VersionMarker | - |
1752 | || ver != 0) | - |
1753 | return false; | - |
1754 | | - |
1755 | if (d->read(stream)) { | - |
1756 | emit sortIndicatorChanged(d->sortIndicatorSection, d->sortIndicatorOrder ); | - |
1757 | d->viewport->update(); | - |
1758 | return true; | - |
1759 | } | - |
1760 | return false; | - |
1761 | } | - |
1762 | #endif // QT_NO_DATASTREAM | - |
1763 | | - |
1764 | | - |
1765 | | - |
1766 | | - |
1767 | void QHeaderView::reset() | - |
1768 | { | - |
1769 | QAbstractItemView::reset(); | - |
1770 | | - |
1771 | | - |
1772 | | - |
1773 | initializeSections(); | - |
1774 | } | - |
1775 | | - |
1776 | | - |
1777 | | - |
1778 | | - |
1779 | | - |
1780 | void QHeaderView::headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast) | - |
1781 | { | - |
1782 | Q_D(QHeaderView); | - |
1783 | if (d->orientation != orientation) | - |
1784 | return; | - |
1785 | | - |
1786 | if (logicalFirst < 0 || logicalLast < 0 || logicalFirst >= count() || logicalLast >= count()) | - |
1787 | return; | - |
1788 | | - |
1789 | d->invalidateCachedSizeHint(); | - |
1790 | | - |
1791 | int firstVisualIndex = INT_MAX, lastVisualIndex = -1; | - |
1792 | | - |
1793 | for (int section = logicalFirst; section <= logicalLast; ++section) { | - |
1794 | const int visual = visualIndex(section); | - |
1795 | firstVisualIndex = qMin(firstVisualIndex, visual); | - |
1796 | lastVisualIndex = qMax(lastVisualIndex, visual); | - |
1797 | } | - |
1798 | | - |
1799 | d->executePostedResize(); | - |
1800 | const int first = d->headerSectionPosition(firstVisualIndex), | - |
1801 | last = d->headerSectionPosition(lastVisualIndex) | - |
1802 | + d->headerSectionSize(lastVisualIndex); | - |
1803 | | - |
1804 | if (orientation == Qt::Horizontal) { | - |
1805 | d->viewport->update(first, 0, last - first, d->viewport->height()); | - |
1806 | } else { | - |
1807 | d->viewport->update(0, first, d->viewport->width(), last - first); | - |
1808 | } | - |
1809 | } | - |
1810 | | - |
1811 | | - |
1812 | | - |
1813 | | - |
1814 | | - |
1815 | | - |
1816 | | - |
1817 | | - |
1818 | void QHeaderView::updateSection(int logicalIndex) | - |
1819 | { | - |
1820 | Q_D(QHeaderView); | - |
1821 | if (d->orientation == Qt::Horizontal) | - |
1822 | d->viewport->update(QRect(sectionViewportPosition(logicalIndex), | - |
1823 | 0, sectionSize(logicalIndex), d->viewport->height())); | - |
1824 | else | - |
1825 | d->viewport->update(QRect(0, sectionViewportPosition(logicalIndex), | - |
1826 | d->viewport->width(), sectionSize(logicalIndex))); | - |
1827 | } | - |
1828 | | - |
1829 | | - |
1830 | | - |
1831 | | - |
1832 | | - |
1833 | | - |
1834 | void QHeaderView::resizeSections() | - |
1835 | { | - |
1836 | Q_D(QHeaderView); | - |
1837 | if (d->hasAutoResizeSections()) | - |
1838 | d->resizeSections(Interactive, false); | - |
1839 | } | - |
1840 | | - |
1841 | | - |
1842 | | - |
1843 | | - |
1844 | | - |
1845 | | - |
1846 | | - |
1847 | | - |
1848 | | - |
1849 | | - |
1850 | void QHeaderView::sectionsInserted(const QModelIndex &parent, | - |
1851 | int logicalFirst, int logicalLast) | - |
1852 | { | - |
1853 | Q_D(QHeaderView); | - |
1854 | if (parent != d->root)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1855 | return; never executed: return; | 0 |
1856 | int oldCount = d->sectionCount(); | - |
1857 | | - |
1858 | d->invalidateCachedSizeHint(); | - |
1859 | | - |
1860 | if (d->state == QHeaderViewPrivate::ResizeSection)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1861 | d->preventCursorChangeInSetOffset = true; never executed: d->preventCursorChangeInSetOffset = true; | 0 |
1862 | | - |
1863 | | - |
1864 | int insertAt = logicalFirst; | - |
1865 | int insertCount = logicalLast - logicalFirst + 1; | - |
1866 | | - |
1867 | bool lastSectionActualChange = false; | - |
1868 | if (stretchLastSection()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1869 | | - |
1870 | int visualIndexForStretch = d->lastSectionLogicalIdx; | - |
1871 | if (d->lastSectionLogicalIdx >= 0 && d->lastSectionLogicalIdx < d->visualIndices.size())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1872 | visualIndexForStretch = d->visualIndices[d->lastSectionLogicalIdx]; never executed: visualIndexForStretch = d->visualIndices[d->lastSectionLogicalIdx]; never executed: visualIndexForStretch = d->visualIndices[d->lastSectionLogicalIdx]; | 0 |
1873 | | - |
1874 | | - |
1875 | if (d->lastSectionLogicalIdx < 0 || insertAt >= visualIndexForStretch)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1876 | lastSectionActualChange = true; never executed: lastSectionActualChange = true; | 0 |
1877 | | - |
1878 | if (d->lastSectionLogicalIdx >= logicalFirst)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1879 | d->lastSectionLogicalIdx += insertCount never executed: d->lastSectionLogicalIdx += insertCount; ; never executed: d->lastSectionLogicalIdx += insertCount; | 0 |
1880 | } never executed: end of block | 0 |
1881 | | - |
1882 | QHeaderViewPrivate::SectionItem section(d->defaultSectionSize, d->globalResizeMode); | - |
1883 | d->sectionStartposRecalc = true; | - |
1884 | | - |
1885 | if (d->sectionItems.isEmpty() || insertAt >= d->sectionItems.count()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1886 | int insertLength = d->defaultSectionSize * insertCount; | - |
1887 | d->length += insertLength; | - |
1888 | d->sectionItems.insert(d->sectionItems.count(), insertCount, section); | - |
1889 | } else { never executed: end of block | 0 |
1890 | | - |
1891 | int insertLength = d->defaultSectionSize * insertCount; | - |
1892 | d->length += insertLength; | - |
1893 | d->sectionItems.insert(insertAt, insertCount, section); | - |
1894 | } never executed: end of block | 0 |
1895 | | - |
1896 | | - |
1897 | if (d->sortIndicatorSection >= logicalFirst)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1898 | d->sortIndicatorSection += insertCount; never executed: d->sortIndicatorSection += insertCount; | 0 |
1899 | | - |
1900 | | - |
1901 | if (d->globalResizeMode == Stretch)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1902 | d->stretchSections = d->sectionCount(); never executed: d->stretchSections = d->sectionCount(); | 0 |
1903 | else if (d->globalResizeMode == ResizeToContents)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1904 | d->contentsSections = d->sectionCount(); never executed: d->contentsSections = d->sectionCount(); | 0 |
1905 | | - |
1906 | | - |
1907 | d->sectionSelected.clear(); | - |
1908 | | - |
1909 | | - |
1910 | if (!d->visualIndices.isEmpty() && !d->logicalIndices.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1911 | Q_ASSERT(d->visualIndices.count() == d->logicalIndices.count()); | - |
1912 | int mappingCount = d->visualIndices.count(); | - |
1913 | for (int i = 0; i < mappingCount; ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1914 | if (d->visualIndices.at(i) >= logicalFirst)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1915 | d->visualIndices[i] += insertCount; never executed: d->visualIndices[i] += insertCount; | 0 |
1916 | if (d->logicalIndices.at(i) >= logicalFirst)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1917 | d->logicalIndices[i] += insertCount; never executed: d->logicalIndices[i] += insertCount; | 0 |
1918 | } never executed: end of block | 0 |
1919 | for (int j = logicalFirst; j <= logicalLast; ++j) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1920 | d->visualIndices.insert(j, j); | - |
1921 | d->logicalIndices.insert(j, j); | - |
1922 | } never executed: end of block | 0 |
1923 | } never executed: end of block | 0 |
1924 | | - |
1925 | | - |
1926 | QHash<int, int> newHiddenSectionSize; | - |
1927 | for (QHash<int, int>::const_iterator it = d->hiddenSectionSize.cbegin(), | - |
1928 | end = d->hiddenSectionSize.cend(); it != end; ++it) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1929 | const int oldIndex = it.key(); | - |
1930 | const int newIndex = (oldIndex < logicalFirst) ? oldIndex : oldIndex + insertCount;TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1931 | newHiddenSectionSize[newIndex] = it.value(); | - |
1932 | } never executed: end of block | 0 |
1933 | d->hiddenSectionSize.swap(newHiddenSectionSize); | - |
1934 | | - |
1935 | d->doDelayedResizeSections(); | - |
1936 | emit sectionCountChanged(oldCount, count()); | - |
1937 | | - |
1938 | if (lastSectionActualChange)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1939 | d->maybeRestorePrevLastSectionAndStretchLast(); never executed: d->maybeRestorePrevLastSectionAndStretchLast(); | 0 |
1940 | | - |
1941 | | - |
1942 | if (!d->hasAutoResizeSections())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1943 | d->viewport->update(); never executed: d->viewport->update(); | 0 |
1944 | } never executed: end of block | 0 |
1945 | | - |
1946 | | - |
1947 | | - |
1948 | | - |
1949 | | - |
1950 | | - |
1951 | | - |
1952 | | - |
1953 | | - |
1954 | void QHeaderView::sectionsAboutToBeRemoved(const QModelIndex &parent, | - |
1955 | int logicalFirst, int logicalLast) | - |
1956 | { | - |
1957 | Q_UNUSED(parent); | - |
1958 | Q_UNUSED(logicalFirst); | - |
1959 | Q_UNUSED(logicalLast); | - |
1960 | } | - |
1961 | | - |
1962 | void QHeaderViewPrivate::updateHiddenSections(int logicalFirst, int logicalLast) | - |
1963 | { | - |
1964 | Q_Q(QHeaderView); | - |
1965 | const int changeCount = logicalLast - logicalFirst + 1; | - |
1966 | | - |
1967 | | - |
1968 | QHash<int, int> newHiddenSectionSize; | - |
1969 | for (int i = 0; i < logicalFirst; ++i) | - |
1970 | if (q->isSectionHidden(i)) | - |
1971 | newHiddenSectionSize[i] = hiddenSectionSize[i]; | - |
1972 | for (int j = logicalLast + 1; j < sectionCount(); ++j) | - |
1973 | if (q->isSectionHidden(j)) | - |
1974 | newHiddenSectionSize[j - changeCount] = hiddenSectionSize[j]; | - |
1975 | hiddenSectionSize = newHiddenSectionSize; | - |
1976 | } | - |
1977 | | - |
1978 | void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent, | - |
1979 | int logicalFirst, int logicalLast) | - |
1980 | { | - |
1981 | Q_Q(QHeaderView); | - |
1982 | if (parent != root)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1983 | return; never executed: return; | 0 |
1984 | if (qMin(logicalFirst, logicalLast) < 0TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1985 | || qMax(logicalLast, logicalFirst) >= sectionCount())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1986 | return; never executed: return; | 0 |
1987 | int oldCount = q->count(); | - |
1988 | int changeCount = logicalLast - logicalFirst + 1; | - |
1989 | | - |
1990 | if (state == QHeaderViewPrivate::ResizeSection)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1991 | preventCursorChangeInSetOffset = true; never executed: preventCursorChangeInSetOffset = true; | 0 |
1992 | | - |
1993 | updateHiddenSections(logicalFirst, logicalLast); | - |
1994 | | - |
1995 | if (visualIndices.isEmpty() && logicalIndices.isEmpty()) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1996 | | - |
1997 | removeSectionsFromSectionItems(logicalFirst, logicalLast); | - |
1998 | } else { never executed: end of block | 0 |
1999 | if (logicalFirst == logicalLast) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2000 | int l = logicalFirst; | - |
2001 | int visual = visualIndices.at(l); | - |
2002 | Q_ASSERT(sectionCount() == logicalIndices.count()); | - |
2003 | for (int v = 0; v < sectionCount(); ++v) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2004 | if (v > visual) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2005 | int logical = logicalIndices.at(v); | - |
2006 | --(visualIndices[logical]); | - |
2007 | } never executed: end of block | 0 |
2008 | if (logicalIndex(v) > l) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2009 | --(logicalIndices[v]); never executed: --(logicalIndices[v]); | 0 |
2010 | } never executed: end of block | 0 |
2011 | logicalIndices.remove(visual); | - |
2012 | visualIndices.remove(l); | - |
2013 | | - |
2014 | removeSectionsFromSectionItems(visual, visual); | - |
2015 | } else { never executed: end of block | 0 |
2016 | sectionStartposRecalc = true; | - |
2017 | for (int u = 0; u < sectionItems.count(); ++u) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2018 | sectionItems.at(u).tmpLogIdx = logicalIndices.at(u); never executed: sectionItems.at(u).tmpLogIdx = logicalIndices.at(u); | 0 |
2019 | for (int v = sectionItems.count() - 1; v >= 0; --v) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2020 | if (logicalFirst <= sectionItems.at(v).tmpLogIdx && sectionItems.at(v).tmpLogIdx <= logicalLast)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2021 | removeSectionsFromSectionItems(v, v); never executed: removeSectionsFromSectionItems(v, v); | 0 |
2022 | } never executed: end of block | 0 |
2023 | visualIndices.resize(sectionItems.count()); | - |
2024 | logicalIndices.resize(sectionItems.count()); | - |
2025 | int* visual_data = visualIndices.data(); | - |
2026 | int* logical_data = logicalIndices.data(); | - |
2027 | for (int w = 0; w < sectionItems.count(); ++w) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2028 | int logindex = sectionItems.at(w).tmpLogIdx; | - |
2029 | if (logindex > logicalFirst)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2030 | logindex -= changeCount; never executed: logindex -= changeCount; | 0 |
2031 | visual_data[logindex] = w; | - |
2032 | logical_data[w] = logindex; | - |
2033 | } never executed: end of block | 0 |
2034 | } never executed: end of block | 0 |
2035 | | - |
2036 | } | - |
2037 | | - |
2038 | | - |
2039 | if (sortIndicatorSection >= logicalFirst) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2040 | if (sortIndicatorSection <= logicalLast)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2041 | sortIndicatorSection = -1; never executed: sortIndicatorSection = -1; | 0 |
2042 | else | - |
2043 | sortIndicatorSection -= changeCount; never executed: sortIndicatorSection -= changeCount; | 0 |
2044 | } | - |
2045 | | - |
2046 | | - |
2047 | if (sectionCount() <= 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2048 | clear(); never executed: clear(); | 0 |
2049 | invalidateCachedSizeHint(); | - |
2050 | emit q->sectionCountChanged(oldCount, q->count()); | - |
2051 | | - |
2052 | if (q->stretchLastSection()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2053 | const bool lastSectionRemoved = lastSectionLogicalIdx >= logicalFirst && lastSectionLogicalIdx <= logicalLast;TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2054 | if (lastSectionRemoved)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2055 | setNewLastSection(lastVisibleVisualIndex()); never executed: setNewLastSection(lastVisibleVisualIndex()); | 0 |
2056 | else | - |
2057 | lastSectionLogicalIdx = logicalIndex(lastVisibleVisualIndex never executed: lastSectionLogicalIdx = logicalIndex(lastVisibleVisualIndex()); ()); never executed: lastSectionLogicalIdx = logicalIndex(lastVisibleVisualIndex()); | 0 |
2058 | doDelayedResizeSections(); | - |
2059 | } never executed: end of block | 0 |
2060 | | - |
2061 | viewport->update(); | - |
2062 | } never executed: end of block | 0 |
2063 | | - |
2064 | void QHeaderViewPrivate::_q_layoutAboutToBeChanged() | - |
2065 | { | - |
2066 | | - |
2067 | | - |
2068 | | - |
2069 | | - |
2070 | if ((orientation == Qt::Horizontal && model->rowCount(root) == 0) | - |
2071 | || model->columnCount(root) == 0) | - |
2072 | return; | - |
2073 | | - |
2074 | if (hiddenSectionSize.count() == 0) | - |
2075 | return; | - |
2076 | | - |
2077 | for (int i = 0; i < sectionItems.count(); ++i) | - |
2078 | if (isVisualIndexHidden(i)) | - |
2079 | persistentHiddenSections.append(orientation == Qt::Horizontal | - |
2080 | ? model->index(0, logicalIndex(i), root) | - |
2081 | : model->index(logicalIndex(i), 0, root)); | - |
2082 | } | - |
2083 | | - |
2084 | void QHeaderViewPrivate::_q_layoutChanged() | - |
2085 | { | - |
2086 | Q_Q(QHeaderView); | - |
2087 | viewport->update(); | - |
2088 | if (persistentHiddenSections.isEmpty() || modelIsEmpty()) { | - |
2089 | if (modelSectionCount() != sectionCount()) | - |
2090 | q->initializeSections(); | - |
2091 | persistentHiddenSections.clear(); | - |
2092 | return; | - |
2093 | } | - |
2094 | | - |
2095 | QBitArray oldSectionHidden = sectionsHiddenToBitVector(); | - |
2096 | oldSectionHidden.resize(sectionItems.size()); | - |
2097 | bool sectionCountChanged = false; | - |
2098 | | - |
2099 | for (int i = 0; i < persistentHiddenSections.count(); ++i) { | - |
2100 | QModelIndex index = persistentHiddenSections.at(i); | - |
2101 | if (index.isValid()) { | - |
2102 | const int logical = (orientation == Qt::Horizontal | - |
2103 | ? index.column() | - |
2104 | : index.row()); | - |
2105 | q->setSectionHidden(logical, true); | - |
2106 | oldSectionHidden.setBit(logical, false); | - |
2107 | } else if (!sectionCountChanged && (modelSectionCount() != sectionCount())) { | - |
2108 | sectionCountChanged = true; | - |
2109 | break; | - |
2110 | } | - |
2111 | } | - |
2112 | persistentHiddenSections.clear(); | - |
2113 | | - |
2114 | for (int i = 0; i < oldSectionHidden.count(); ++i) { | - |
2115 | if (oldSectionHidden.testBit(i)) | - |
2116 | q->setSectionHidden(i, false); | - |
2117 | } | - |
2118 | | - |
2119 | | - |
2120 | if (sectionCountChanged) | - |
2121 | q->initializeSections(); | - |
2122 | } | - |
2123 | | - |
2124 | | - |
2125 | | - |
2126 | | - |
2127 | | - |
2128 | void QHeaderView::initializeSections() | - |
2129 | { | - |
2130 | Q_D(QHeaderView); | - |
2131 | const int oldCount = d->sectionCount(); | - |
2132 | const int newCount = d->modelSectionCount(); | - |
2133 | if (newCount <= 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2134 | d->clear(); | - |
2135 | emit sectionCountChanged(oldCount, 0); | - |
2136 | } else if (newCount != oldCount) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2137 | const int min = qBound(0, oldCount, newCount - 1); | - |
2138 | initializeSections(min, newCount - 1); | - |
2139 | if (stretchLastSection()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2140 | d->lastSectionSize = sectionSize(logicalIndex(d->sectionCount() - 1));maybeRestorePrevLastSectionAndStretchLast(); never executed: d->maybeRestorePrevLastSectionAndStretchLast(); | 0 |
2141 | | - |
2142 | | - |
2143 | if (newCount < oldCount)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2144 | d->updateHiddenSections(0, newCount-1); never executed: d->updateHiddenSections(0, newCount-1); | 0 |
2145 | } never executed: end of block | 0 |
2146 | } never executed: end of block | 0 |
2147 | | - |
2148 | | - |
2149 | | - |
2150 | | - |
2151 | | - |
2152 | void QHeaderView::initializeSections(int start, int end) | - |
2153 | { | - |
2154 | Q_D(QHeaderView); | - |
2155 | | - |
2156 | Q_ASSERT(start >= 0); | - |
2157 | Q_ASSERT(end >= 0); | - |
2158 | | - |
2159 | d->invalidateCachedSizeHint(); | - |
2160 | int oldCount = d->sectionCount(); | - |
2161 | | - |
2162 | if (end + 1 < d->sectionCount()) { | - |
2163 | int newCount = end + 1; | - |
2164 | d->removeSectionsFromSectionItems(newCount, d->sectionCount() - 1); | - |
2165 | if (!d->hiddenSectionSize.isEmpty()) { | - |
2166 | if (oldCount - newCount > d->hiddenSectionSize.count()) { | - |
2167 | for (int i = end + 1; i < d->sectionCount(); ++i) | - |
2168 | d->hiddenSectionSize.remove(i); | - |
2169 | } else { | - |
2170 | QHash<int, int>::iterator it = d->hiddenSectionSize.begin(); | - |
2171 | while (it != d->hiddenSectionSize.end()) { | - |
2172 | if (it.key() > end) | - |
2173 | it = d->hiddenSectionSize.erase(it); | - |
2174 | else | - |
2175 | ++it; | - |
2176 | } | - |
2177 | } | - |
2178 | } | - |
2179 | } | - |
2180 | | - |
2181 | int newSectionCount = end + 1; | - |
2182 | | - |
2183 | if (!d->logicalIndices.isEmpty()) { | - |
2184 | if (oldCount <= newSectionCount) { | - |
2185 | d->logicalIndices.resize(newSectionCount); | - |
2186 | d->visualIndices.resize(newSectionCount); | - |
2187 | for (int i = oldCount; i < newSectionCount; ++i) { | - |
2188 | d->logicalIndices[i] = i; | - |
2189 | d->visualIndices[i] = i; | - |
2190 | } | - |
2191 | } else { | - |
2192 | int j = 0; | - |
2193 | for (int i = 0; i < oldCount; ++i) { | - |
2194 | int v = d->logicalIndices.at(i); | - |
2195 | if (v < newSectionCount) { | - |
2196 | d->logicalIndices[j] = v; | - |
2197 | d->visualIndices[v] = j; | - |
2198 | j++; | - |
2199 | } | - |
2200 | } | - |
2201 | d->logicalIndices.resize(newSectionCount); | - |
2202 | d->visualIndices.resize(newSectionCount); | - |
2203 | } | - |
2204 | } | - |
2205 | | - |
2206 | if (d->globalResizeMode == Stretch) | - |
2207 | d->stretchSections = newSectionCount; | - |
2208 | else if (d->globalResizeMode == ResizeToContents) | - |
2209 | d->contentsSections = newSectionCount; | - |
2210 | | - |
2211 | if (newSectionCount > oldCount) | - |
2212 | d->createSectionItems(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode); | - |
2213 | | - |
2214 | | - |
2215 | if (d->sectionCount() != oldCount) | - |
2216 | emit sectionCountChanged(oldCount, d->sectionCount()); | - |
2217 | d->viewport->update(); | - |
2218 | } | - |
2219 | | - |
2220 | | - |
2221 | | - |
2222 | | - |
2223 | | - |
2224 | void QHeaderView::currentChanged(const QModelIndex ¤t, const QModelIndex &old) | - |
2225 | { | - |
2226 | Q_D(QHeaderView); | - |
2227 | | - |
2228 | if (d->orientation == Qt::Horizontal && current.column() != old.column()) { | - |
2229 | if (old.isValid() && old.parent() == d->root) | - |
2230 | d->viewport->update(QRect(sectionViewportPosition(old.column()), 0, | - |
2231 | sectionSize(old.column()), d->viewport->height())); | - |
2232 | if (current.isValid() && current.parent() == d->root) | - |
2233 | d->viewport->update(QRect(sectionViewportPosition(current.column()), 0, | - |
2234 | sectionSize(current.column()), d->viewport->height())); | - |
2235 | } else if (d->orientation == Qt::Vertical && current.row() != old.row()) { | - |
2236 | if (old.isValid() && old.parent() == d->root) | - |
2237 | d->viewport->update(QRect(0, sectionViewportPosition(old.row()), | - |
2238 | d->viewport->width(), sectionSize(old.row()))); | - |
2239 | if (current.isValid() && current.parent() == d->root) | - |
2240 | d->viewport->update(QRect(0, sectionViewportPosition(current.row()), | - |
2241 | d->viewport->width(), sectionSize(current.row()))); | - |
2242 | } | - |
2243 | } | - |
2244 | | - |
2245 | | - |
2246 | | - |
2247 | | - |
2248 | | - |
2249 | | - |
2250 | bool QHeaderView::event(QEvent *e) | - |
2251 | { | - |
2252 | Q_D(QHeaderView); | - |
2253 | switch (e->type()) { | - |
2254 | case QEvent::HoverEnter: { | - |
2255 | QHoverEvent *he = static_cast<QHoverEvent*>(e); | - |
2256 | d->hover = logicalIndexAt(he->pos()); | - |
2257 | if (d->hover != -1) | - |
2258 | updateSection(d->hover); | - |
2259 | break; } | - |
2260 | case QEvent::Leave: | - |
2261 | case QEvent::HoverLeave: { | - |
2262 | if (d->hover != -1) | - |
2263 | updateSection(d->hover); | - |
2264 | d->hover = -1; | - |
2265 | break; } | - |
2266 | case QEvent::HoverMove: { | - |
2267 | QHoverEvent *he = static_cast<QHoverEvent*>(e); | - |
2268 | int oldHover = d->hover; | - |
2269 | d->hover = logicalIndexAt(he->pos()); | - |
2270 | if (d->hover != oldHover) { | - |
2271 | if (oldHover != -1) | - |
2272 | updateSection(oldHover); | - |
2273 | if (d->hover != -1) | - |
2274 | updateSection(d->hover); | - |
2275 | } | - |
2276 | break; } | - |
2277 | case QEvent::Timer: { | - |
2278 | QTimerEvent *te = static_cast<QTimerEvent*>(e); | - |
2279 | if (te->timerId() == d->delayedResize.timerId()) { | - |
2280 | d->delayedResize.stop(); | - |
2281 | resizeSections(); | - |
2282 | } | - |
2283 | break; } | - |
2284 | case QEvent::StyleChange: | - |
2285 | if (!d->customDefaultSectionSize) | - |
2286 | d->updateDefaultSectionSizeFromStyle(); | - |
2287 | break; | - |
2288 | default: | - |
2289 | break; | - |
2290 | } | - |
2291 | return QAbstractItemView::event(e); | - |
2292 | } | - |
2293 | | - |
2294 | | - |
2295 | | - |
2296 | | - |
2297 | | - |
2298 | void QHeaderView::paintEvent(QPaintEvent *e) | - |
2299 | { | - |
2300 | Q_D(QHeaderView); | - |
2301 | | - |
2302 | if (count() == 0) | - |
2303 | return; | - |
2304 | | - |
2305 | QPainter painter(d->viewport); | - |
2306 | const QPoint offset = d->scrollDelayOffset; | - |
2307 | QRect translatedEventRect = e->rect(); | - |
2308 | translatedEventRect.translate(offset); | - |
2309 | | - |
2310 | int start = -1; | - |
2311 | int end = -1; | - |
2312 | if (d->orientation == Qt::Horizontal) { | - |
2313 | start = visualIndexAt(translatedEventRect.left()); | - |
2314 | end = visualIndexAt(translatedEventRect.right()); | - |
2315 | } else { | - |
2316 | start = visualIndexAt(translatedEventRect.top()); | - |
2317 | end = visualIndexAt(translatedEventRect.bottom()); | - |
2318 | } | - |
2319 | | - |
2320 | if (d->reverse()) { | - |
2321 | start = (start == -1 ? count() - 1 : start); | - |
2322 | end = (end == -1 ? 0 : end); | - |
2323 | } else { | - |
2324 | start = (start == -1 ? 0 : start); | - |
2325 | end = (end == -1 ? count() - 1 : end); | - |
2326 | } | - |
2327 | | - |
2328 | int tmp = start; | - |
2329 | start = qMin(start, end); | - |
2330 | end = qMax(tmp, end); | - |
2331 | | - |
2332 | d->prepareSectionSelected(); | - |
2333 | | - |
2334 | QRect currentSectionRect; | - |
2335 | int logical; | - |
2336 | const int width = d->viewport->width(); | - |
2337 | const int height = d->viewport->height(); | - |
2338 | for (int i = start; i <= end; ++i) { | - |
2339 | if (d->isVisualIndexHidden(i)) | - |
2340 | continue; | - |
2341 | painter.save(); | - |
2342 | logical = logicalIndex(i); | - |
2343 | if (d->orientation == Qt::Horizontal) { | - |
2344 | currentSectionRect.setRect(sectionViewportPosition(logical), 0, sectionSize(logical), height); | - |
2345 | } else { | - |
2346 | currentSectionRect.setRect(0, sectionViewportPosition(logical), width, sectionSize(logical)); | - |
2347 | } | - |
2348 | currentSectionRect.translate(offset); | - |
2349 | | - |
2350 | QVariant variant = d->model->headerData(logical, d->orientation, | - |
2351 | Qt::FontRole); | - |
2352 | if (variant.isValid() && variant.canConvert<QFont>()) { | - |
2353 | QFont sectionFont = qvariant_cast<QFont>(variant); | - |
2354 | painter.setFont(sectionFont); | - |
2355 | } | - |
2356 | paintSection(&painter, currentSectionRect, logical); | - |
2357 | painter.restore(); | - |
2358 | } | - |
2359 | | - |
2360 | QStyleOption opt; | - |
2361 | opt.init(this); | - |
2362 | | - |
2363 | if (d->reverse()) { | - |
2364 | opt.state |= QStyle::State_Horizontal; | - |
2365 | if (currentSectionRect.left() > translatedEventRect.left()) { | - |
2366 | opt.rect = QRect(translatedEventRect.left(), 0, | - |
2367 | currentSectionRect.left() - translatedEventRect.left(), height); | - |
2368 | style()->drawControl(QStyle::CE_HeaderEmptyArea, &opt, &painter, this); | - |
2369 | } | - |
2370 | } else if (currentSectionRect.right() < translatedEventRect.right()) { | - |
2371 | | - |
2372 | opt.state |= QStyle::State_Horizontal; | - |
2373 | opt.rect = QRect(currentSectionRect.right() + 1, 0, | - |
2374 | translatedEventRect.right() - currentSectionRect.right(), height); | - |
2375 | style()->drawControl(QStyle::CE_HeaderEmptyArea, &opt, &painter, this); | - |
2376 | } else if (currentSectionRect.bottom() < translatedEventRect.bottom()) { | - |
2377 | | - |
2378 | opt.state &= ~QStyle::State_Horizontal; | - |
2379 | opt.rect = QRect(0, currentSectionRect.bottom() + 1, | - |
2380 | width, height - currentSectionRect.bottom() - 1); | - |
2381 | style()->drawControl(QStyle::CE_HeaderEmptyArea, &opt, &painter, this); | - |
2382 | } | - |
2383 | | - |
2384 | #if 0 | - |
2385 | | - |
2386 | for (int a = 0, i = 0; i < d->sectionItems.count(); ++i) { | - |
2387 | QColor color((i & 4 ? 255 : 0), (i & 2 ? 255 : 0), (i & 1 ? 255 : 0)); | - |
2388 | if (d->orientation == Qt::Horizontal) | - |
2389 | painter.fillRect(a - d->offset, 0, d->sectionItems.at(i).size, 4, color); | - |
2390 | else | - |
2391 | painter.fillRect(0, a - d->offset, 4, d->sectionItems.at(i).size, color); | - |
2392 | a += d->sectionItems.at(i).size; | - |
2393 | } | - |
2394 | | - |
2395 | #endif | - |
2396 | } | - |
2397 | | - |
2398 | | - |
2399 | | - |
2400 | | - |
2401 | | - |
2402 | void QHeaderView::mousePressEvent(QMouseEvent *e) | - |
2403 | { | - |
2404 | Q_D(QHeaderView); | - |
2405 | if (d->state != QHeaderViewPrivate::NoState || e->button() != Qt::LeftButton) | - |
2406 | return; | - |
2407 | int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); | - |
2408 | int handle = d->sectionHandleAt(pos); | - |
2409 | d->originalSize = -1; | - |
2410 | if (handle == -1) { | - |
2411 | d->pressed = logicalIndexAt(pos); | - |
2412 | if (d->clickableSections) | - |
2413 | emit sectionPressed(d->pressed); | - |
2414 | | - |
2415 | bool acceptMoveSection = d->movableSections; | - |
2416 | if (acceptMoveSection && d->pressed == 0 && !d->allowUserMoveOfSection0) | - |
2417 | acceptMoveSection = false; | - |
2418 | | - |
2419 | if (acceptMoveSection) { | - |
2420 | d->section = d->target = d->pressed; | - |
2421 | if (d->section == -1) | - |
2422 | return; | - |
2423 | d->state = QHeaderViewPrivate::MoveSection; | - |
2424 | d->setupSectionIndicator(d->section, pos); | - |
2425 | } else if (d->clickableSections && d->pressed != -1) { | - |
2426 | updateSection(d->pressed); | - |
2427 | d->state = QHeaderViewPrivate::SelectSections; | - |
2428 | } | - |
2429 | } else if (sectionResizeMode(handle) == Interactive) { | - |
2430 | d->originalSize = sectionSize(handle); | - |
2431 | d->state = QHeaderViewPrivate::ResizeSection; | - |
2432 | d->section = handle; | - |
2433 | d->preventCursorChangeInSetOffset = false; | - |
2434 | } | - |
2435 | | - |
2436 | d->firstPos = pos; | - |
2437 | d->lastPos = pos; | - |
2438 | | - |
2439 | d->clearCascadingSections(); | - |
2440 | } | - |
2441 | | - |
2442 | | - |
2443 | | - |
2444 | | - |
2445 | | - |
2446 | void QHeaderView::mouseMoveEvent(QMouseEvent *e) | - |
2447 | { | - |
2448 | Q_D(QHeaderView); | - |
2449 | int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); | - |
2450 | if (pos < 0 && d->state != QHeaderViewPrivate::SelectSections) | - |
2451 | return; | - |
2452 | if (e->buttons() == Qt::NoButton) { | - |
2453 | #if !defined(Q_DEAD_CODE_FROM_QT4_MAC) | - |
2454 | | - |
2455 | | - |
2456 | | - |
2457 | | - |
2458 | | - |
2459 | d->state = QHeaderViewPrivate::NoState; | - |
2460 | d->pressed = -1; | - |
2461 | #endif | - |
2462 | } | - |
2463 | switch (d->state) { | - |
2464 | case QHeaderViewPrivate::ResizeSection: { | - |
2465 | Q_ASSERT(d->originalSize != -1); | - |
2466 | if (d->cascadingResizing) { | - |
2467 | int delta = d->reverse() ? d->lastPos - pos : pos - d->lastPos; | - |
2468 | int visual = visualIndex(d->section); | - |
2469 | d->cascadingResize(visual, d->headerSectionSize(visual) + delta); | - |
2470 | } else { | - |
2471 | int delta = d->reverse() ? d->firstPos - pos : pos - d->firstPos; | - |
2472 | int newsize = qBound(minimumSectionSize(), d->originalSize + delta, maximumSectionSize()); | - |
2473 | resizeSection(d->section, newsize); | - |
2474 | } | - |
2475 | d->lastPos = pos; | - |
2476 | return; | - |
2477 | } | - |
2478 | case QHeaderViewPrivate::MoveSection: { | - |
2479 | if (d->shouldAutoScroll(e->pos())) | - |
2480 | d->startAutoScroll(); | - |
2481 | if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance() | - |
2482 | || !d->sectionIndicator->isHidden()) { | - |
2483 | int visual = visualIndexAt(pos); | - |
2484 | if (visual == -1) | - |
2485 | return; | - |
2486 | if (visual == 0 && logicalIndex(0) == 0 && !d->allowUserMoveOfSection0) | - |
2487 | return; | - |
2488 | | - |
2489 | int posThreshold = d->headerSectionPosition(visual) - d->offset + d->headerSectionSize(visual) / 2; | - |
2490 | int moving = visualIndex(d->section); | - |
2491 | if (visual < moving) { | - |
2492 | if (pos < posThreshold) | - |
2493 | d->target = d->logicalIndex(visual); | - |
2494 | else | - |
2495 | d->target = d->logicalIndex(visual + 1); | - |
2496 | } else if (visual > moving) { | - |
2497 | if (pos > posThreshold) | - |
2498 | d->target = d->logicalIndex(visual); | - |
2499 | else | - |
2500 | d->target = d->logicalIndex(visual - 1); | - |
2501 | } else { | - |
2502 | d->target = d->section; | - |
2503 | } | - |
2504 | d->updateSectionIndicator(d->section, pos); | - |
2505 | } | - |
2506 | return; | - |
2507 | } | - |
2508 | case QHeaderViewPrivate::SelectSections: { | - |
2509 | int logical = logicalIndexAt(qMax(-d->offset, pos)); | - |
2510 | if (logical == -1 && pos > 0) | - |
2511 | logical = logicalIndex(d->lastVisibleVisualIndex()); | - |
2512 | if (logical == d->pressed) | - |
2513 | return; | - |
2514 | else if (d->pressed != -1) | - |
2515 | updateSection(d->pressed); | - |
2516 | d->pressed = logical; | - |
2517 | if (d->clickableSections && logical != -1) { | - |
2518 | emit sectionEntered(d->pressed); | - |
2519 | updateSection(d->pressed); | - |
2520 | } | - |
2521 | return; | - |
2522 | } | - |
2523 | case QHeaderViewPrivate::NoState: { | - |
2524 | #ifndef QT_NO_CURSOR | - |
2525 | int handle = d->sectionHandleAt(pos); | - |
2526 | bool hasCursor = testAttribute(Qt::WA_SetCursor); | - |
2527 | if (handle != -1 && (sectionResizeMode(handle) == Interactive)) { | - |
2528 | if (!hasCursor) | - |
2529 | setCursor(d->orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor); | - |
2530 | } else if (hasCursor) { | - |
2531 | unsetCursor(); | - |
2532 | } | - |
2533 | #endif | - |
2534 | return; | - |
2535 | } | - |
2536 | default: | - |
2537 | break; | - |
2538 | } | - |
2539 | } | - |
2540 | | - |
2541 | | - |
2542 | | - |
2543 | | - |
2544 | | - |
2545 | void QHeaderView::mouseReleaseEvent(QMouseEvent *e) | - |
2546 | { | - |
2547 | Q_D(QHeaderView); | - |
2548 | int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); | - |
2549 | switch (d->state) { | - |
2550 | case QHeaderViewPrivate::MoveSection: | - |
2551 | if (!d->sectionIndicator->isHidden()) { | - |
2552 | int from = visualIndex(d->section); | - |
2553 | Q_ASSERT(from != -1); | - |
2554 | int to = visualIndex(d->target); | - |
2555 | Q_ASSERT(to != -1); | - |
2556 | moveSection(from, to); | - |
2557 | d->section = d->target = -1; | - |
2558 | d->updateSectionIndicator(d->section, pos); | - |
2559 | break; | - |
2560 | } | - |
2561 | case QHeaderViewPrivate::SelectSections: | - |
2562 | if (!d->clickableSections) { | - |
2563 | int section = logicalIndexAt(pos); | - |
2564 | updateSection(section); | - |
2565 | } | - |
2566 | | - |
2567 | case QHeaderViewPrivate::NoState: | - |
2568 | if (d->clickableSections) { | - |
2569 | int section = logicalIndexAt(pos); | - |
2570 | if (section != -1 && section == d->pressed) { | - |
2571 | d->flipSortIndicator(section); | - |
2572 | emit sectionClicked(section); | - |
2573 | } | - |
2574 | if (d->pressed != -1) | - |
2575 | updateSection(d->pressed); | - |
2576 | } | - |
2577 | break; | - |
2578 | case QHeaderViewPrivate::ResizeSection: | - |
2579 | d->originalSize = -1; | - |
2580 | d->clearCascadingSections(); | - |
2581 | break; | - |
2582 | default: | - |
2583 | break; | - |
2584 | } | - |
2585 | d->state = QHeaderViewPrivate::NoState; | - |
2586 | d->pressed = -1; | - |
2587 | } | - |
2588 | | - |
2589 | | - |
2590 | | - |
2591 | | - |
2592 | | - |
2593 | void QHeaderView::mouseDoubleClickEvent(QMouseEvent *e) | - |
2594 | { | - |
2595 | Q_D(QHeaderView); | - |
2596 | int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); | - |
2597 | int handle = d->sectionHandleAt(pos); | - |
2598 | if (handle > -1 && sectionResizeMode(handle) == Interactive) { | - |
2599 | emit sectionHandleDoubleClicked(handle); | - |
2600 | #ifndef QT_NO_CURSOR | - |
2601 | Qt::CursorShape splitCursor = (d->orientation == Qt::Horizontal) | - |
2602 | ? Qt::SplitHCursor : Qt::SplitVCursor; | - |
2603 | if (cursor().shape() == splitCursor) { | - |
2604 | | - |
2605 | handle = d->sectionHandleAt(pos); | - |
2606 | if (!(handle > -1 && sectionResizeMode(handle) == Interactive)) | - |
2607 | setCursor(Qt::ArrowCursor); | - |
2608 | } | - |
2609 | #endif | - |
2610 | } else { | - |
2611 | emit sectionDoubleClicked(logicalIndexAt(e->pos())); | - |
2612 | } | - |
2613 | } | - |
2614 | | - |
2615 | | - |
2616 | | - |
2617 | | - |
2618 | | - |
2619 | bool QHeaderView::viewportEvent(QEvent *e) | - |
2620 | { | - |
2621 | Q_D(QHeaderView); | - |
2622 | switch (e->type()) { | - |
2623 | #ifndef QT_NO_TOOLTIP | - |
2624 | case QEvent::ToolTip: { | - |
2625 | QHelpEvent *he = static_cast<QHelpEvent*>(e); | - |
2626 | int logical = logicalIndexAt(he->pos()); | - |
2627 | if (logical != -1) { | - |
2628 | QVariant variant = d->model->headerData(logical, d->orientation, Qt::ToolTipRole); | - |
2629 | if (variant.isValid()) { | - |
2630 | QToolTip::showText(he->globalPos(), variant.toString(), this); | - |
2631 | return true; | - |
2632 | } | - |
2633 | } | - |
2634 | break; } | - |
2635 | #endif | - |
2636 | #ifndef QT_NO_WHATSTHIS | - |
2637 | case QEvent::QueryWhatsThis: { | - |
2638 | QHelpEvent *he = static_cast<QHelpEvent*>(e); | - |
2639 | int logical = logicalIndexAt(he->pos()); | - |
2640 | if (logical != -1 | - |
2641 | && d->model->headerData(logical, d->orientation, Qt::WhatsThisRole).isValid()) | - |
2642 | return true; | - |
2643 | break; } | - |
2644 | case QEvent::WhatsThis: { | - |
2645 | QHelpEvent *he = static_cast<QHelpEvent*>(e); | - |
2646 | int logical = logicalIndexAt(he->pos()); | - |
2647 | if (logical != -1) { | - |
2648 | QVariant whatsthis = d->model->headerData(logical, d->orientation, | - |
2649 | Qt::WhatsThisRole); | - |
2650 | if (whatsthis.isValid()) { | - |
2651 | QWhatsThis::showText(he->globalPos(), whatsthis.toString(), this); | - |
2652 | return true; | - |
2653 | } | - |
2654 | } | - |
2655 | break; } | - |
2656 | #endif // QT_NO_WHATSTHIS | - |
2657 | #ifndef QT_NO_STATUSTIP | - |
2658 | case QEvent::StatusTip: { | - |
2659 | QHelpEvent *he = static_cast<QHelpEvent*>(e); | - |
2660 | int logical = logicalIndexAt(he->pos()); | - |
2661 | if (logical != -1) { | - |
2662 | QString statustip = d->model->headerData(logical, d->orientation, | - |
2663 | Qt::StatusTipRole).toString(); | - |
2664 | if (!statustip.isEmpty()) | - |
2665 | setStatusTip(statustip); | - |
2666 | } | - |
2667 | return true; } | - |
2668 | #endif // QT_NO_STATUSTIP | - |
2669 | case QEvent::FontChange: | - |
2670 | case QEvent::StyleChange: | - |
2671 | d->invalidateCachedSizeHint(); | - |
2672 | | - |
2673 | case QEvent::Hide: | - |
2674 | case QEvent::Show: { | - |
2675 | QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea *>(parentWidget()); | - |
2676 | if (parent && parent->isVisible()) | - |
2677 | resizeSections(); | - |
2678 | emit geometriesChanged(); | - |
2679 | break;} | - |
2680 | case QEvent::ContextMenu: { | - |
2681 | d->state = QHeaderViewPrivate::NoState; | - |
2682 | d->pressed = d->section = d->target = -1; | - |
2683 | d->updateSectionIndicator(d->section, -1); | - |
2684 | break; } | - |
2685 | case QEvent::Wheel: { | - |
2686 | QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea *>(parentWidget()); | - |
2687 | if (asa) | - |
2688 | return QApplication::sendEvent(asa->viewport(), e); | - |
2689 | break; } | - |
2690 | default: | - |
2691 | break; | - |
2692 | } | - |
2693 | return QAbstractItemView::viewportEvent(e); | - |
2694 | } | - |
2695 | | - |
2696 | | - |
2697 | | - |
2698 | | - |
2699 | | - |
2700 | | - |
2701 | | - |
2702 | | - |
2703 | void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const | - |
2704 | { | - |
2705 | Q_D(const QHeaderView); | - |
2706 | if (!rect.isValid()) | - |
2707 | return; | - |
2708 | | - |
2709 | QStyleOptionHeader opt; | - |
2710 | initStyleOption(&opt); | - |
2711 | QStyle::State state = QStyle::State_None; | - |
2712 | if (isEnabled()) | - |
2713 | state |= QStyle::State_Enabled; | - |
2714 | if (window()->isActiveWindow()) | - |
2715 | state |= QStyle::State_Active; | - |
2716 | if (d->clickableSections) { | - |
2717 | if (logicalIndex == d->hover) | - |
2718 | state |= QStyle::State_MouseOver; | - |
2719 | if (logicalIndex == d->pressed) | - |
2720 | state |= QStyle::State_Sunken; | - |
2721 | else if (d->highlightSelected) { | - |
2722 | if (d->sectionIntersectsSelection(logicalIndex)) | - |
2723 | state |= QStyle::State_On; | - |
2724 | if (d->isSectionSelected(logicalIndex)) | - |
2725 | state |= QStyle::State_Sunken; | - |
2726 | } | - |
2727 | | - |
2728 | } | - |
2729 | if (isSortIndicatorShown() && sortIndicatorSection() == logicalIndex) | - |
2730 | opt.sortIndicator = (sortIndicatorOrder() == Qt::AscendingOrder) | - |
2731 | ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp; | - |
2732 | | - |
2733 | | - |
2734 | QVariant textAlignment = d->model->headerData(logicalIndex, d->orientation, | - |
2735 | Qt::TextAlignmentRole); | - |
2736 | opt.rect = rect; | - |
2737 | opt.section = logicalIndex; | - |
2738 | opt.state |= state; | - |
2739 | opt.textAlignment = Qt::Alignment(textAlignment.isValid() | - |
2740 | ? Qt::Alignment(textAlignment.toInt()) | - |
2741 | : d->defaultAlignment); | - |
2742 | | - |
2743 | opt.iconAlignment = Qt::AlignVCenter; | - |
2744 | opt.text = d->model->headerData(logicalIndex, d->orientation, | - |
2745 | Qt::DisplayRole).toString(); | - |
2746 | | - |
2747 | int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); | - |
2748 | | - |
2749 | const Qt::Alignment headerArrowAlignment = static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_Header_ArrowAlignment, 0, this)); | - |
2750 | const bool isHeaderArrowOnTheSide = headerArrowAlignment & Qt::AlignVCenter; | - |
2751 | if (isSortIndicatorShown() && sortIndicatorSection() == logicalIndex && isHeaderArrowOnTheSide) | - |
2752 | margin += style()->pixelMetric(QStyle::PM_HeaderMarkSize, 0, this); | - |
2753 | | - |
2754 | if (d->textElideMode != Qt::ElideNone) | - |
2755 | opt.text = opt.fontMetrics.elidedText(opt.text, d->textElideMode , rect.width() - margin); | - |
2756 | | - |
2757 | QVariant variant = d->model->headerData(logicalIndex, d->orientation, | - |
2758 | Qt::DecorationRole); | - |
2759 | opt.icon = qvariant_cast<QIcon>(variant); | - |
2760 | if (opt.icon.isNull()) | - |
2761 | opt.icon = qvariant_cast<QPixmap>(variant); | - |
2762 | QVariant foregroundBrush = d->model->headerData(logicalIndex, d->orientation, | - |
2763 | Qt::ForegroundRole); | - |
2764 | if (foregroundBrush.canConvert<QBrush>()) | - |
2765 | opt.palette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(foregroundBrush)); | - |
2766 | | - |
2767 | QPointF oldBO = painter->brushOrigin(); | - |
2768 | QVariant backgroundBrush = d->model->headerData(logicalIndex, d->orientation, | - |
2769 | Qt::BackgroundRole); | - |
2770 | if (backgroundBrush.canConvert<QBrush>()) { | - |
2771 | opt.palette.setBrush(QPalette::Button, qvariant_cast<QBrush>(backgroundBrush)); | - |
2772 | opt.palette.setBrush(QPalette::Window, qvariant_cast<QBrush>(backgroundBrush)); | - |
2773 | painter->setBrushOrigin(opt.rect.topLeft()); | - |
2774 | } | - |
2775 | | - |
2776 | | - |
2777 | int visual = visualIndex(logicalIndex); | - |
2778 | Q_ASSERT(visual != -1); | - |
2779 | bool first = d->isFirstVisibleSection(visual); | - |
2780 | bool last = d->isLastVisibleSection(visual); | - |
2781 | if (first && last) | - |
2782 | opt.position = QStyleOptionHeader::OnlyOneSection; | - |
2783 | else if (first) | - |
2784 | opt.position = QStyleOptionHeader::Beginning; | - |
2785 | else if (last) | - |
2786 | opt.position = QStyleOptionHeader::End; | - |
2787 | else | - |
2788 | opt.position = QStyleOptionHeader::Middle; | - |
2789 | opt.orientation = d->orientation; | - |
2790 | | - |
2791 | bool previousSelected = d->isSectionSelected(this->logicalIndex(visual - 1)); | - |
2792 | bool nextSelected = d->isSectionSelected(this->logicalIndex(visual + 1)); | - |
2793 | if (previousSelected && nextSelected) | - |
2794 | opt.selectedPosition = QStyleOptionHeader::NextAndPreviousAreSelected; | - |
2795 | else if (previousSelected) | - |
2796 | opt.selectedPosition = QStyleOptionHeader::PreviousIsSelected; | - |
2797 | else if (nextSelected) | - |
2798 | opt.selectedPosition = QStyleOptionHeader::NextIsSelected; | - |
2799 | else | - |
2800 | opt.selectedPosition = QStyleOptionHeader::NotAdjacent; | - |
2801 | | - |
2802 | style()->drawControl(QStyle::CE_Header, &opt, painter, this); | - |
2803 | | - |
2804 | painter->setBrushOrigin(oldBO); | - |
2805 | } | - |
2806 | | - |
2807 | | - |
2808 | | - |
2809 | | - |
2810 | | - |
2811 | | - |
2812 | | - |
2813 | | - |
2814 | QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const | - |
2815 | { | - |
2816 | Q_D(const QHeaderView); | - |
2817 | Q_ASSERT(logicalIndex >= 0); | - |
2818 | | - |
2819 | ensurePolished(); | - |
2820 | | - |
2821 | | - |
2822 | QVariant variant = d->model->headerData(logicalIndex, d->orientation, Qt::SizeHintRole); | - |
2823 | if (variant.isValid()) | - |
2824 | return qvariant_cast<QSize>(variant); | - |
2825 | | - |
2826 | | - |
2827 | QStyleOptionHeader opt; | - |
2828 | initStyleOption(&opt); | - |
2829 | opt.section = logicalIndex; | - |
2830 | QVariant var = d->model->headerData(logicalIndex, d->orientation, | - |
2831 | Qt::FontRole); | - |
2832 | QFont fnt; | - |
2833 | if (var.isValid() && var.canConvert<QFont>()) | - |
2834 | fnt = qvariant_cast<QFont>(var); | - |
2835 | else | - |
2836 | fnt = font(); | - |
2837 | fnt.setBold(true); | - |
2838 | opt.fontMetrics = QFontMetrics(fnt); | - |
2839 | opt.text = d->model->headerData(logicalIndex, d->orientation, | - |
2840 | Qt::DisplayRole).toString(); | - |
2841 | variant = d->model->headerData(logicalIndex, d->orientation, Qt::DecorationRole); | - |
2842 | opt.icon = qvariant_cast<QIcon>(variant); | - |
2843 | if (opt.icon.isNull()) | - |
2844 | opt.icon = qvariant_cast<QPixmap>(variant); | - |
2845 | if (isSortIndicatorShown()) | - |
2846 | opt.sortIndicator = QStyleOptionHeader::SortDown; | - |
2847 | return style()->sizeFromContents(QStyle::CT_HeaderSection, &opt, QSize(), this); | - |
2848 | } | - |
2849 | | - |
2850 | | - |
2851 | | - |
2852 | | - |
2853 | | - |
2854 | | - |
2855 | | - |
2856 | | - |
2857 | int QHeaderView::horizontalOffset() const | - |
2858 | { | - |
2859 | Q_D(const QHeaderView); | - |
2860 | if (d->orientation == Qt::Horizontal) | - |
2861 | return d->offset; | - |
2862 | return 0; | - |
2863 | } | - |
2864 | | - |
2865 | | - |
2866 | | - |
2867 | | - |
2868 | | - |
2869 | | - |
2870 | | - |
2871 | | - |
2872 | int QHeaderView::verticalOffset() const | - |
2873 | { | - |
2874 | Q_D(const QHeaderView); | - |
2875 | if (d->orientation == Qt::Vertical) | - |
2876 | return d->offset; | - |
2877 | return 0; | - |
2878 | } | - |
2879 | | - |
2880 | | - |
2881 | | - |
2882 | | - |
2883 | | - |
2884 | | - |
2885 | void QHeaderView::updateGeometries() | - |
2886 | { | - |
2887 | Q_D(QHeaderView); | - |
2888 | d->layoutChildren(); | - |
2889 | if (d->hasAutoResizeSections()) | - |
2890 | d->doDelayedResizeSections(); | - |
2891 | } | - |
2892 | | - |
2893 | | - |
2894 | | - |
2895 | | - |
2896 | | - |
2897 | | - |
2898 | void QHeaderView::scrollContentsBy(int dx, int dy) | - |
2899 | { | - |
2900 | Q_D(QHeaderView); | - |
2901 | d->scrollDirtyRegion(dx, dy); | - |
2902 | } | - |
2903 | | - |
2904 | | - |
2905 | | - |
2906 | | - |
2907 | | - |
2908 | void QHeaderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &) | - |
2909 | { | - |
2910 | Q_D(QHeaderView); | - |
2911 | d->invalidateCachedSizeHint(); | - |
2912 | if (d->hasAutoResizeSections()) { | - |
2913 | bool resizeRequired = d->globalResizeMode == ResizeToContents; | - |
2914 | int first = orientation() == Qt::Horizontal ? topLeft.column() : topLeft.row(); | - |
2915 | int last = orientation() == Qt::Horizontal ? bottomRight.column() : bottomRight.row(); | - |
2916 | for (int i = first; i <= last && !resizeRequired; ++i) | - |
2917 | resizeRequired = (sectionResizeMode(i) == ResizeToContents); | - |
2918 | if (resizeRequired) | - |
2919 | d->doDelayedResizeSections(); | - |
2920 | } | - |
2921 | } | - |
2922 | | - |
2923 | | - |
2924 | | - |
2925 | | - |
2926 | | - |
2927 | | - |
2928 | | - |
2929 | void QHeaderView::rowsInserted(const QModelIndex &, int, int) | - |
2930 | { | - |
2931 | | - |
2932 | } | - |
2933 | | - |
2934 | | - |
2935 | | - |
2936 | | - |
2937 | | - |
2938 | | - |
2939 | | - |
2940 | | - |
2941 | QRect QHeaderView::visualRect(const QModelIndex &) const | - |
2942 | { | - |
2943 | return QRect(); | - |
2944 | } | - |
2945 | | - |
2946 | | - |
2947 | | - |
2948 | | - |
2949 | | - |
2950 | | - |
2951 | | - |
2952 | | - |
2953 | void QHeaderView::scrollTo(const QModelIndex &, ScrollHint) | - |
2954 | { | - |
2955 | | - |
2956 | } | - |
2957 | | - |
2958 | | - |
2959 | | - |
2960 | | - |
2961 | | - |
2962 | | - |
2963 | | - |
2964 | | - |
2965 | QModelIndex QHeaderView::indexAt(const QPoint &) const | - |
2966 | { | - |
2967 | return QModelIndex(); | - |
2968 | } | - |
2969 | | - |
2970 | | - |
2971 | | - |
2972 | | - |
2973 | | - |
2974 | | - |
2975 | | - |
2976 | | - |
2977 | bool QHeaderView::isIndexHidden(const QModelIndex &) const | - |
2978 | { | - |
2979 | return true; | - |
2980 | } | - |
2981 | | - |
2982 | | - |
2983 | | - |
2984 | | - |
2985 | | - |
2986 | | - |
2987 | | - |
2988 | | - |
2989 | QModelIndex QHeaderView::moveCursor(CursorAction, Qt::KeyboardModifiers) | - |
2990 | { | - |
2991 | return QModelIndex(); | - |
2992 | } | - |
2993 | | - |
2994 | | - |
2995 | | - |
2996 | | - |
2997 | | - |
2998 | | - |
2999 | | - |
3000 | | - |
3001 | | - |
3002 | | - |
3003 | void QHeaderView::setSelection(const QRect&, QItemSelectionModel::SelectionFlags) | - |
3004 | { | - |
3005 | | - |
3006 | } | - |
3007 | | - |
3008 | | - |
3009 | | - |
3010 | | - |
3011 | | - |
3012 | QRegion QHeaderView::visualRegionForSelection(const QItemSelection &selection) const | - |
3013 | { | - |
3014 | Q_D(const QHeaderView); | - |
3015 | const int max = d->modelSectionCount(); | - |
3016 | | - |
3017 | if (d->orientation == Qt::Horizontal) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3018 | int logicalLeft = max; | - |
3019 | int logicalRight = 0; | - |
3020 | | - |
3021 | if (d->visualIndices.empty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3022 | | - |
3023 | for (int i = 0; i < selection.count(); ++i) {const QItemSelectionRangeauto &r =: selection.at(i);) { | - |
3024 | if (r.parent().isValid() || !r.isValid())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3025 | continue; never executed: continue; | 0 |
3026 | if (r.left() < logicalLeft)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3027 | logicalLeft = r.left(); never executed: logicalLeft = r.left(); | 0 |
3028 | if (r.right() > logicalRight)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3029 | logicalRight = r.right(); never executed: logicalRight = r.right(); | 0 |
3030 | } never executed: end of block | 0 |
3031 | } else { never executed: end of block | 0 |
3032 | int left = max; | - |
3033 | int right = 0; | - |
3034 | for (int i = 0; i < selection.count(); ++i) {const QItemSelectionRangeauto &r =: selection.at(i);) { | - |
3035 | if (r.parent().isValid() || !r.isValid())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3036 | continue; never executed: continue; | 0 |
3037 | for (int k = r.left(); k <= r.right(); ++k) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3038 | int visual = visualIndex(k); | - |
3039 | if (visual == -1) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3040 | continue; never executed: continue; | 0 |
3041 | if (visual < left)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3042 | left = visual; never executed: left = visual; | 0 |
3043 | if (visual > right)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3044 | right = visual; never executed: right = visual; | 0 |
3045 | } never executed: end of block | 0 |
3046 | } never executed: end of block | 0 |
3047 | logicalLeft = logicalIndex(left); | - |
3048 | logicalRight = logicalIndex(right); | - |
3049 | } never executed: end of block | 0 |
3050 | | - |
3051 | if (logicalLeft < 0 || logicalLeft >= count() ||TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3052 | logicalRight < 0 || logicalRight >= count())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3053 | return QRegion(); never executed: return QRegion(); | 0 |
3054 | | - |
3055 | int leftPos = sectionViewportPosition(logicalLeft); | - |
3056 | int rightPos = sectionViewportPosition(logicalRight); | - |
3057 | rightPos += sectionSize(logicalRight); | - |
3058 | return QRect(leftPos, 0, rightPos - leftPos, height()); never executed: return QRect(leftPos, 0, rightPos - leftPos, height()); | 0 |
3059 | } | - |
3060 | | - |
3061 | int logicalTop = max; | - |
3062 | int logicalBottom = 0; | - |
3063 | | - |
3064 | if (d->visualIndices.empty()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3065 | | - |
3066 | for (int i = 0; i < selection.count(); ++i) {const QItemSelectionRangeauto &r =: selection.at(i);) { | - |
3067 | if (r.parent().isValid() || !r.isValid())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3068 | continue; never executed: continue; | 0 |
3069 | if (r.top() < logicalTop)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3070 | logicalTop = r.top(); never executed: logicalTop = r.top(); | 0 |
3071 | if (r.bottom() > logicalBottom)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3072 | logicalBottom = r.bottom(); never executed: logicalBottom = r.bottom(); | 0 |
3073 | } never executed: end of block | 0 |
3074 | } else { never executed: end of block | 0 |
3075 | int top = max; | - |
3076 | int bottom = 0; | - |
3077 | | - |
3078 | for (int i = 0; i < selection.count(); ++i) {const QItemSelectionRangeauto &r =: selection.at(i);) { | - |
3079 | if (r.parent().isValid() || !r.isValid())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3080 | continue; never executed: continue; | 0 |
3081 | for (int k = r.top(); k <= r.bottom(); ++k) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3082 | int visual = visualIndex(k); | - |
3083 | if (visual == -1) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3084 | continue; never executed: continue; | 0 |
3085 | if (visual < top)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3086 | top = visual; never executed: top = visual; | 0 |
3087 | if (visual > bottom)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3088 | bottom = visual; never executed: bottom = visual; | 0 |
3089 | } never executed: end of block | 0 |
3090 | } never executed: end of block | 0 |
3091 | | - |
3092 | logicalTop = logicalIndex(top); | - |
3093 | logicalBottom = logicalIndex(bottom); | - |
3094 | } never executed: end of block | 0 |
3095 | | - |
3096 | if (logicalTop < 0 || logicalTop >= count() ||TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3097 | logicalBottom < 0 || logicalBottom >= count())TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3098 | return QRegion(); never executed: return QRegion(); | 0 |
3099 | | - |
3100 | int topPos = sectionViewportPosition(logicalTop); | - |
3101 | int bottomPos = sectionViewportPosition(logicalBottom) + sectionSize(logicalBottom); | - |
3102 | | - |
3103 | return QRect(0, topPos, width(), bottomPos - topPos); never executed: return QRect(0, topPos, width(), bottomPos - topPos); | 0 |
3104 | } | - |
3105 | | - |
3106 | | - |
3107 | | - |
3108 | | - |
3109 | int QHeaderViewPrivate::sectionHandleAt(int position) | - |
3110 | { | - |
3111 | Q_Q(QHeaderView); | - |
3112 | int visual = q->visualIndexAt(position); | - |
3113 | if (visual == -1) | - |
3114 | return -1; | - |
3115 | int log = logicalIndex(visual); | - |
3116 | int pos = q->sectionViewportPosition(log); | - |
3117 | int grip = q->style()->pixelMetric(QStyle::PM_HeaderGripMargin, 0, q); | - |
3118 | | - |
3119 | bool atLeft = position < pos + grip; | - |
3120 | bool atRight = (position > pos + q->sectionSize(log) - grip); | - |
3121 | if (reverse()) | - |
3122 | qSwap(atLeft, atRight); | - |
3123 | | - |
3124 | if (atLeft) { | - |
3125 | | - |
3126 | while(visual > -1) { | - |
3127 | int logical = q->logicalIndex(--visual); | - |
3128 | if (!q->isSectionHidden(logical)) | - |
3129 | return logical; | - |
3130 | } | - |
3131 | } else if (atRight) { | - |
3132 | | - |
3133 | return log; | - |
3134 | } | - |
3135 | return -1; | - |
3136 | } | - |
3137 | | - |
3138 | void QHeaderViewPrivate::setupSectionIndicator(int section, int position) | - |
3139 | { | - |
3140 | Q_Q(QHeaderView); | - |
3141 | if (!sectionIndicator) { | - |
3142 | sectionIndicator = new QLabel(viewport); | - |
3143 | } | - |
3144 | | - |
3145 | int w, h; | - |
3146 | int p = q->sectionViewportPosition(section); | - |
3147 | if (orientation == Qt::Horizontal) { | - |
3148 | w = q->sectionSize(section); | - |
3149 | h = viewport->height(); | - |
3150 | } else { | - |
3151 | w = viewport->width(); | - |
3152 | h = q->sectionSize(section); | - |
3153 | } | - |
3154 | sectionIndicator->resize(w, h); | - |
3155 | | - |
3156 | QPixmap pm(w, h); | - |
3157 | pm.fill(QColor(0, 0, 0, 45)); | - |
3158 | QRect rect(0, 0, w, h); | - |
3159 | | - |
3160 | QPainter painter(&pm); | - |
3161 | painter.setOpacity(0.75); | - |
3162 | q->paintSection(&painter, rect, section); | - |
3163 | painter.end(); | - |
3164 | | - |
3165 | sectionIndicator->setPixmap(pm); | - |
3166 | sectionIndicatorOffset = position - qMax(p, 0); | - |
3167 | } | - |
3168 | | - |
3169 | void QHeaderViewPrivate::updateSectionIndicator(int section, int position) | - |
3170 | { | - |
3171 | if (!sectionIndicator) | - |
3172 | return; | - |
3173 | | - |
3174 | if (section == -1 || target == -1) { | - |
3175 | sectionIndicator->hide(); | - |
3176 | return; | - |
3177 | } | - |
3178 | | - |
3179 | if (orientation == Qt::Horizontal) | - |
3180 | sectionIndicator->move(position - sectionIndicatorOffset, 0); | - |
3181 | else | - |
3182 | sectionIndicator->move(0, position - sectionIndicatorOffset); | - |
3183 | | - |
3184 | sectionIndicator->show(); | - |
3185 | } | - |
3186 | | - |
3187 | | - |
3188 | | - |
3189 | | - |
3190 | | - |
3191 | | - |
3192 | | - |
3193 | | - |
3194 | void QHeaderView::initStyleOption(QStyleOptionHeader *option) const | - |
3195 | { | - |
3196 | Q_D(const QHeaderView); | - |
3197 | option->initFrom(this); | - |
3198 | option->state = QStyle::State_None | QStyle::State_Raised; | - |
3199 | option->orientation = d->orientation; | - |
3200 | if (d->orientation == Qt::Horizontal) | - |
3201 | option->state |= QStyle::State_Horizontal; | - |
3202 | if (isEnabled()) | - |
3203 | option->state |= QStyle::State_Enabled; | - |
3204 | option->section = 0; | - |
3205 | } | - |
3206 | | - |
3207 | bool QHeaderViewPrivate::isSectionSelected(int section) const | - |
3208 | { | - |
3209 | int i = section * 2; | - |
3210 | if (i < 0 || i >= sectionSelected.count()) | - |
3211 | return false; | - |
3212 | if (sectionSelected.testBit(i)) | - |
3213 | return sectionSelected.testBit(i + 1); | - |
3214 | bool s = false; | - |
3215 | if (orientation == Qt::Horizontal) | - |
3216 | s = isColumnSelected(section); | - |
3217 | else | - |
3218 | s = isRowSelected(section); | - |
3219 | sectionSelected.setBit(i + 1, s); | - |
3220 | sectionSelected.setBit(i, true); | - |
3221 | return s; | - |
3222 | } | - |
3223 | | - |
3224 | bool QHeaderViewPrivate::isFirstVisibleSection(int section) const | - |
3225 | { | - |
3226 | if (sectionStartposRecalc) | - |
3227 | recalcSectionStartPos(); | - |
3228 | const SectionItem &item = sectionItems.at(section); | - |
3229 | return item.size > 0 && item.calculated_startpos == 0; | - |
3230 | } | - |
3231 | | - |
3232 | bool QHeaderViewPrivate::isLastVisibleSection(int section) const | - |
3233 | { | - |
3234 | if (sectionStartposRecalc) | - |
3235 | recalcSectionStartPos(); | - |
3236 | const SectionItem &item = sectionItems.at(section); | - |
3237 | return item.size > 0 && item.calculatedEndPos() == length; | - |
3238 | } | - |
3239 | | - |
3240 | | - |
3241 | | - |
3242 | | - |
3243 | | - |
3244 | int QHeaderViewPrivate::lastVisibleVisualIndex() const | - |
3245 | { | - |
3246 | Q_Q(const QHeaderView); | - |
3247 | for (int visual = q->count()-1; visual >= 0; --visual) { | - |
3248 | if (!q->isSectionHidden(q->logicalIndex(visual))) | - |
3249 | return visual; | - |
3250 | } | - |
3251 | | - |
3252 | | - |
3253 | return -1; | - |
3254 | } | - |
3255 | | - |
3256 | void QHeaderViewPrivate::restoreSizeOnPrevLastSection() | - |
3257 | { | - |
3258 | Q_Q(QHeaderView); | - |
3259 | if (lastSectionLogicalIdx < 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3260 | return; never executed: return; | 0 |
3261 | int resizeLogIdx = lastSectionLogicalIdx; | - |
3262 | lastSectionLogicalIdx = -1; | - |
3263 | q->resizeSection(resizeLogIdx, lastSectionSize); | - |
3264 | } never executed: end of block | 0 |
3265 | | - |
3266 | void QHeaderViewPrivate::setNewLastSection(int visualIndexForLastSection) | - |
3267 | { | - |
3268 | Q_Q(QHeaderView); | - |
3269 | lastSectionSize = -1; | - |
3270 | lastSectionLogicalIdx = q->logicalIndex(visualIndexForLastSection); | - |
3271 | lastSectionSize = headerSectionSize(visualIndexForLastSection); | - |
3272 | | - |
3273 | } never executed: end of block | 0 |
3274 | | - |
3275 | void QHeaderViewPrivate::maybeRestorePrevLastSectionAndStretchLast() | - |
3276 | { | - |
3277 | Q_Q(const QHeaderView); | - |
3278 | if (!q->stretchLastSection())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3279 | return; never executed: return; | 0 |
3280 | | - |
3281 | int nowLastVisualSection = lastVisibleVisualIndex(); | - |
3282 | if (lastSectionLogicalIdx == q->logicalIndex(nowLastVisualSection))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3283 | return never executed: return; ;never executed: return; | 0 |
3284 | | - |
3285 | | - |
3286 | restoreSizeOnPrevLastSection(); | - |
3287 | setNewLastSection(nowLastVisualSection); | - |
3288 | doDelayedResizeSections(); | - |
3289 | } never executed: end of block | 0 |
3290 | | - |
3291 | | - |
3292 | | - |
3293 | | - |
3294 | | - |
3295 | | - |
3296 | | - |
3297 | | - |
3298 | | - |
3299 | | - |
3300 | | - |
3301 | | - |
3302 | | - |
3303 | | - |
3304 | | - |
3305 | void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool useGlobalMode) | - |
3306 | { | - |
3307 | Q_Q(QHeaderView); | - |
3308 | | - |
3309 | delayedResize.stop(); | - |
3310 | | - |
3311 | executePostedLayout(); | - |
3312 | if (sectionCount() == 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3313 | return; never executed: return; | 0 |
3314 | | - |
3315 | if (resizeRecursionBlock)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3316 | return; never executed: return; | 0 |
3317 | resizeRecursionBlock = true; | - |
3318 | | - |
3319 | invalidateCachedSizeHint(); | - |
3320 | const int lastVisibleSectionlastSectionVisualIdx = lastVisibleVisualIndex();q->visualIndex(lastSectionLogicalIdx); | - |
3321 | | - |
3322 | | - |
3323 | int stretchSection = -1; | - |
3324 | if (stretchLastSection && !useGlobalMode)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3325 | stretchSection = lastVisibleVisualIndex();lastSectionVisualIdx; never executed: stretchSection = lastSectionVisualIdx; | 0 |
3326 | | - |
3327 | | - |
3328 | int lengthToStretch = (orientation == Qt::Horizontal ? viewport->width() : viewport->height());TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3329 | int numberOfStretchedSections = 0; | - |
3330 | QList<int> section_sizes; | - |
3331 | for (int i = 0; i < sectionCount(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3332 | if (isVisualIndexHidden(i))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3333 | continue; never executed: continue; | 0 |
3334 | | - |
3335 | QHeaderView::ResizeMode resizeMode; | - |
3336 | if (useGlobalMode && (i != stretchSection))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3337 | resizeMode = globalMode; never executed: resizeMode = globalMode; | 0 |
3338 | else | - |
3339 | resizeMode = (i == stretchSection ? QHeaderView::Stretch : headerSectionResizeMode(i)); never executed: resizeMode = (i == stretchSection ? QHeaderView::Stretch : headerSectionResizeMode(i)); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3340 | | - |
3341 | if (resizeMode == QHeaderView::Stretch) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3342 | ++numberOfStretchedSections; | - |
3343 | section_sizes.append(headerSectionSize(i)); | - |
3344 | continue; never executed: continue; | 0 |
3345 | } | - |
3346 | | - |
3347 | | - |
3348 | int sectionSize = 0; | - |
3349 | if (resizeMode == QHeaderView::Interactive || resizeMode == QHeaderView::Fixed) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3350 | sectionSize = headerSectionSize(i); | - |
3351 | } else { never executed: end of block | 0 |
3352 | int logicalIndex = q->logicalIndex(i); | - |
3353 | sectionSize = qMax(viewSectionSizeHint(logicalIndex), | - |
3354 | q->sectionSizeHint(logicalIndex)); | - |
3355 | if (sectionSize > q->maximumSectionSize())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3356 | sectionSize = q->maximumSectionSize(); never executed: sectionSize = q->maximumSectionSize(); | 0 |
3357 | } never executed: end of block | 0 |
3358 | section_sizes.append(sectionSize); | - |
3359 | lengthToStretch -= sectionSize; | - |
3360 | } never executed: end of block | 0 |
3361 | | - |
3362 | | - |
3363 | int stretchSectionLength = -1; | - |
3364 | int pixelReminder = 0; | - |
3365 | if (numberOfStretchedSections > 0 && lengthToStretch > 0) { TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3366 | int hintLengthForEveryStretchedSection = lengthToStretch / numberOfStretchedSections; | - |
3367 | stretchSectionLength = qMax(hintLengthForEveryStretchedSection, q->minimumSectionSize()); | - |
3368 | pixelReminder = lengthToStretch % numberOfStretchedSections; | - |
3369 | } never executed: end of block | 0 |
3370 | | - |
3371 | | - |
3372 | int spanStartSection = 0; | - |
3373 | int previousSectionLength = 0; | - |
3374 | | - |
3375 | QHeaderView::ResizeMode previousSectionResizeMode = QHeaderView::Interactive; | - |
3376 | | - |
3377 | | - |
3378 | for (int i = 0; i < sectionCount(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3379 | int oldSectionLength = headerSectionSize(i); | - |
3380 | int newSectionLength = -1; | - |
3381 | QHeaderView::ResizeMode newSectionResizeMode = headerSectionResizeMode(i); | - |
3382 | | - |
3383 | if (isVisualIndexHidden(i)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3384 | newSectionLength = 0; | - |
3385 | } else { never executed: end of block | 0 |
3386 | QHeaderView::ResizeMode resizeMode; | - |
3387 | if (useGlobalMode)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3388 | resizeMode = globalMode; never executed: resizeMode = globalMode; | 0 |
3389 | else | - |
3390 | resizeMode = (i == stretchSection never executed: resizeMode = (i == stretchSection ? QHeaderView::Stretch : newSectionResizeMode); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3391 | ? QHeaderView::Stretch never executed: resizeMode = (i == stretchSection ? QHeaderView::Stretch : newSectionResizeMode); | 0 |
3392 | : newSectionResizeMode); never executed: resizeMode = (i == stretchSection ? QHeaderView::Stretch : newSectionResizeMode); | 0 |
3393 | if (resizeMode == QHeaderView::Stretch && stretchSectionLength != -1) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3394 | if (i == lastVisibleSectionlastSectionVisualIdx)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3395 | newSectionLength = qMax(stretchSectionLength, lastSectionSize); never executed: newSectionLength = qMax(stretchSectionLength, lastSectionSize); | 0 |
3396 | else | - |
3397 | newSectionLength = stretchSectionLength; never executed: newSectionLength = stretchSectionLength; | 0 |
3398 | if (pixelReminder > 0) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3399 | newSectionLength += 1; | - |
3400 | --pixelReminder; | - |
3401 | } never executed: end of block | 0 |
3402 | section_sizes.removeFirst(); | - |
3403 | } else { never executed: end of block | 0 |
3404 | newSectionLength = section_sizes.front();section_sizes.removeFirsttakeFirst(); | - |
3405 | } never executed: end of block | 0 |
3406 | } | - |
3407 | | - |
3408 | | - |
3409 | if ((previousSectionResizeMode != newSectionResizeModeTRUE | never evaluated | FALSE | never evaluated |
| 0 |
3410 | || previousSectionLength != newSectionLength) && i > 0) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3411 | int spanLength = (i - spanStartSection) * previousSectionLength; | - |
3412 | createSectionItems(spanStartSection, i - 1, spanLength, previousSectionResizeMode); | - |
3413 | | - |
3414 | spanStartSection = i; | - |
3415 | } never executed: end of block | 0 |
3416 | | - |
3417 | if (newSectionLength != oldSectionLength)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3418 | emit q->sectionResized(logicalIndex(i), oldSectionLength, newSectionLength); never executed: q->sectionResized(logicalIndex(i), oldSectionLength, newSectionLength); | 0 |
3419 | | - |
3420 | previousSectionLength = newSectionLength; | - |
3421 | previousSectionResizeMode = newSectionResizeMode; | - |
3422 | } never executed: end of block | 0 |
3423 | | - |
3424 | createSectionItems(spanStartSection, sectionCount() - 1, | - |
3425 | (sectionCount() - spanStartSection) * previousSectionLength, | - |
3426 | previousSectionResizeMode); | - |
3427 | | - |
3428 | resizeRecursionBlock = false; | - |
3429 | viewport->update(); | - |
3430 | } never executed: end of block | 0 |
3431 | | - |
3432 | void QHeaderViewPrivate::createSectionItems(int start, int end, int size, QHeaderView::ResizeMode mode) | - |
3433 | { | - |
3434 | int sizePerSection = size / (end - start + 1); | - |
3435 | if (end >= sectionItems.count()) { | - |
3436 | sectionItems.resize(end + 1); | - |
3437 | sectionStartposRecalc = true; | - |
3438 | } | - |
3439 | SectionItem *sectiondata = sectionItems.data(); | - |
3440 | for (int i = start; i <= end; ++i) { | - |
3441 | length += (sizePerSection - sectiondata[i].size); | - |
3442 | sectionStartposRecalc |= (sectiondata[i].size != sizePerSection); | - |
3443 | sectiondata[i].size = sizePerSection; | - |
3444 | sectiondata[i].resizeMode = mode; | - |
3445 | } | - |
3446 | } | - |
3447 | | - |
3448 | void QHeaderViewPrivate::removeSectionsFromSectionItems(int start, int end) | - |
3449 | { | - |
3450 | | - |
3451 | sectionStartposRecalc |= (end != sectionItems.count() - 1); | - |
3452 | int removedlength = 0; | - |
3453 | for (int u = start; u <= end; ++u) | - |
3454 | removedlength += sectionItems.at(u).size; | - |
3455 | length -= removedlength; | - |
3456 | sectionItems.remove(start, end - start + 1); | - |
3457 | } | - |
3458 | | - |
3459 | void QHeaderViewPrivate::clear() | - |
3460 | { | - |
3461 | if (state != NoClear) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3462 | length = 0; | - |
3463 | visualIndices.clear(); | - |
3464 | logicalIndices.clear(); | - |
3465 | sectionSelected.clear(); | - |
3466 | hiddenSectionSize.clear(); | - |
3467 | sectionItems.clear(); | - |
3468 | lastSectionLogicalIdx = -1; | - |
3469 | invalidateCachedSizeHint(); | - |
3470 | } never executed: end of block | 0 |
3471 | } never executed: end of block | 0 |
3472 | | - |
3473 | void QHeaderViewPrivate::flipSortIndicator(int section) | - |
3474 | { | - |
3475 | Q_Q(QHeaderView); | - |
3476 | Qt::SortOrder sortOrder; | - |
3477 | if (sortIndicatorSection == section) { | - |
3478 | sortOrder = (sortIndicatorOrder == Qt::DescendingOrder) ? Qt::AscendingOrder : Qt::DescendingOrder; | - |
3479 | } else { | - |
3480 | const QVariant value = model->headerData(section, orientation, Qt::InitialSortOrderRole); | - |
3481 | if (value.canConvert(QVariant::Int)) | - |
3482 | sortOrder = static_cast<Qt::SortOrder>(value.toInt()); | - |
3483 | else | - |
3484 | sortOrder = Qt::AscendingOrder; | - |
3485 | } | - |
3486 | q->setSortIndicator(section, sortOrder); | - |
3487 | } | - |
3488 | | - |
3489 | void QHeaderViewPrivate::cascadingResize(int visual, int newSize) | - |
3490 | { | - |
3491 | Q_Q(QHeaderView); | - |
3492 | const int minimumSize = q->minimumSectionSize(); | - |
3493 | const int oldSize = headerSectionSize(visual); | - |
3494 | int delta = newSize - oldSize; | - |
3495 | | - |
3496 | if (delta > 0) { | - |
3497 | bool sectionResized = false; | - |
3498 | | - |
3499 | | - |
3500 | for (int i = firstCascadingSection; i < visual; ++i) { | - |
3501 | if (cascadingSectionSize.contains(i)) { | - |
3502 | int currentSectionSize = headerSectionSize(i); | - |
3503 | int originalSectionSize = cascadingSectionSize.value(i); | - |
3504 | if (currentSectionSize < originalSectionSize) { | - |
3505 | int newSectionSize = currentSectionSize + delta; | - |
3506 | resizeSectionItem(i, currentSectionSize, newSectionSize); | - |
3507 | if (newSectionSize >= originalSectionSize && false) dead code: cascadingSectionSize.remove(i); | - |
3508 | cascadingSectionSize.remove(i); dead code: cascadingSectionSize.remove(i); | - |
3509 | sectionResized = true; | - |
3510 | break; | - |
3511 | } | - |
3512 | } | - |
3513 | | - |
3514 | } | - |
3515 | | - |
3516 | | - |
3517 | if (!sectionResized) { | - |
3518 | newSize = qMax(newSize, minimumSize); | - |
3519 | if (oldSize != newSize) | - |
3520 | resizeSectionItem(visual, oldSize, newSize); | - |
3521 | } | - |
3522 | | - |
3523 | | - |
3524 | for (int i = visual + 1; i < sectionCount(); ++i) { | - |
3525 | if (!sectionIsCascadable(i)) | - |
3526 | continue; | - |
3527 | int currentSectionSize = headerSectionSize(i); | - |
3528 | if (currentSectionSize <= minimumSize) | - |
3529 | continue; | - |
3530 | int newSectionSize = qMax(currentSectionSize - delta, minimumSize); | - |
3531 | | - |
3532 | resizeSectionItem(i, currentSectionSize, newSectionSize); | - |
3533 | saveCascadingSectionSize(i, currentSectionSize); | - |
3534 | delta = delta - (currentSectionSize - newSectionSize); | - |
3535 | | - |
3536 | | - |
3537 | if (delta <= 0) | - |
3538 | break; | - |
3539 | } | - |
3540 | } else { | - |
3541 | bool sectionResized = false; | - |
3542 | | - |
3543 | | - |
3544 | for (int i = lastCascadingSection; i > visual; --i) { | - |
3545 | if (!cascadingSectionSize.contains(i)) | - |
3546 | continue; | - |
3547 | int currentSectionSize = headerSectionSize(i); | - |
3548 | int originalSectionSize = cascadingSectionSize.value(i); | - |
3549 | if (currentSectionSize >= originalSectionSize) | - |
3550 | continue; | - |
3551 | int newSectionSize = currentSectionSize - delta; | - |
3552 | resizeSectionItem(i, currentSectionSize, newSectionSize); | - |
3553 | if (newSectionSize >= originalSectionSize && false) { dead code: { cascadingSectionSize.remove(i); } | - |
3554 | dead code: { cascadingSectionSize.remove(i); } | - |
3555 | cascadingSectionSize.remove(i); dead code: { cascadingSectionSize.remove(i); } | - |
3556 | } dead code: { cascadingSectionSize.remove(i); } | - |
3557 | sectionResized = true; | - |
3558 | break; | - |
3559 | } | - |
3560 | | - |
3561 | | - |
3562 | resizeSectionItem(visual, oldSize, qMax(newSize, minimumSize)); | - |
3563 | | - |
3564 | | - |
3565 | if (delta < 0 && newSize < minimumSize) { | - |
3566 | for (int i = visual - 1; i >= 0; --i) { | - |
3567 | if (!sectionIsCascadable(i)) | - |
3568 | continue; | - |
3569 | int sectionSize = headerSectionSize(i); | - |
3570 | if (sectionSize <= minimumSize) | - |
3571 | continue; | - |
3572 | resizeSectionItem(i, sectionSize, qMax(sectionSize + delta, minimumSize)); | - |
3573 | saveCascadingSectionSize(i, sectionSize); | - |
3574 | break; | - |
3575 | } | - |
3576 | } | - |
3577 | | - |
3578 | | - |
3579 | if (!sectionResized) { | - |
3580 | for (int i = visual + 1; i < sectionCount(); ++i) { | - |
3581 | if (!sectionIsCascadable(i)) | - |
3582 | continue; | - |
3583 | int currentSectionSize = headerSectionSize(i); | - |
3584 | int newSectionSize = qMax(currentSectionSize - delta, minimumSize); | - |
3585 | resizeSectionItem(i, currentSectionSize, newSectionSize); | - |
3586 | break; | - |
3587 | } | - |
3588 | } | - |
3589 | } | - |
3590 | | - |
3591 | if (hasAutoResizeSections()) | - |
3592 | doDelayedResizeSections(); | - |
3593 | | - |
3594 | viewport->update(); | - |
3595 | } | - |
3596 | | - |
3597 | void QHeaderViewPrivate::setDefaultSectionSize(int size) | - |
3598 | { | - |
3599 | Q_Q(QHeaderView); | - |
3600 | executePostedLayout(); | - |
3601 | invalidateCachedSizeHint(); | - |
3602 | defaultSectionSize = size; | - |
3603 | customDefaultSectionSize = true; | - |
3604 | if (state == QHeaderViewPrivate::ResizeSection) | - |
3605 | preventCursorChangeInSetOffset = true; | - |
3606 | for (int i = 0; i < sectionItems.count(); ++i) { | - |
3607 | QHeaderViewPrivate::SectionItem §ion = sectionItems[i]; | - |
3608 | if (hiddenSectionSize.isEmpty() || !isVisualIndexHidden(i)) { | - |
3609 | const int newSize = size; | - |
3610 | if (newSize != section.size) { | - |
3611 | length += newSize - section.size; | - |
3612 | const int oldSectionSize = section.sectionSize(); | - |
3613 | section.size = size; | - |
3614 | emit q->sectionResized(logicalIndex(i), oldSectionSize, size); | - |
3615 | } | - |
3616 | } | - |
3617 | } | - |
3618 | sectionStartposRecalc = true; | - |
3619 | if (hasAutoResizeSections()) | - |
3620 | doDelayedResizeSections(); | - |
3621 | viewport->update(); | - |
3622 | } | - |
3623 | | - |
3624 | void QHeaderViewPrivate::updateDefaultSectionSizeFromStyle() | - |
3625 | { | - |
3626 | Q_Q(QHeaderView); | - |
3627 | if (orientation == Qt::Horizontal) { | - |
3628 | defaultSectionSize = q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeHorizontal, 0, q); | - |
3629 | } else { | - |
3630 | defaultSectionSize = qMax(q->minimumSectionSize(), | - |
3631 | q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeVertical, 0, q)); | - |
3632 | } | - |
3633 | } | - |
3634 | | - |
3635 | void QHeaderViewPrivate::recalcSectionStartPos() const | - |
3636 | { | - |
3637 | int pixelpos = 0; | - |
3638 | for (QVector<SectionItem>::const_iterator i = sectionItems.constBegin(); i != sectionItems.constEnd(); ++i) { | - |
3639 | i->calculated_startpos = pixelpos; | - |
3640 | pixelpos += i->size; | - |
3641 | } | - |
3642 | sectionStartposRecalc = false; | - |
3643 | } | - |
3644 | | - |
3645 | void QHeaderViewPrivate::resizeSectionItem(int visualIndex, int oldSize, int newSize) | - |
3646 | { | - |
3647 | Q_Q(QHeaderView); | - |
3648 | QHeaderView::ResizeMode mode = headerSectionResizeMode(visualIndex); | - |
3649 | createSectionItems(visualIndex, visualIndex, newSize, mode); | - |
3650 | emit q->sectionResized(logicalIndex(visualIndex), oldSize, newSize); | - |
3651 | } | - |
3652 | | - |
3653 | int QHeaderViewPrivate::headerSectionSize(int visual) const | - |
3654 | { | - |
3655 | if (visual < sectionCount() && visual >= 0) | - |
3656 | return sectionItems.at(visual).sectionSize(); | - |
3657 | return -1; | - |
3658 | } | - |
3659 | | - |
3660 | int QHeaderViewPrivate::headerSectionPosition(int visual) const | - |
3661 | { | - |
3662 | if (visual < sectionCount() && visual >= 0) { | - |
3663 | if (sectionStartposRecalc) | - |
3664 | recalcSectionStartPos(); | - |
3665 | return sectionItems.at(visual).calculated_startpos; | - |
3666 | } | - |
3667 | return -1; | - |
3668 | } | - |
3669 | | - |
3670 | int QHeaderViewPrivate::headerVisualIndexAt(int position) const | - |
3671 | { | - |
3672 | if (sectionStartposRecalc) | - |
3673 | recalcSectionStartPos(); | - |
3674 | int startidx = 0; | - |
3675 | int endidx = sectionItems.count() - 1; | - |
3676 | while (startidx <= endidx) { | - |
3677 | int middle = (endidx + startidx) / 2; | - |
3678 | if (sectionItems.at(middle).calculated_startpos > position) { | - |
3679 | endidx = middle - 1; | - |
3680 | } else { | - |
3681 | if (sectionItems.at(middle).calculatedEndPos() <= position) | - |
3682 | startidx = middle + 1; | - |
3683 | else | - |
3684 | return middle; | - |
3685 | } | - |
3686 | } | - |
3687 | return -1; | - |
3688 | } | - |
3689 | | - |
3690 | void QHeaderViewPrivate::setHeaderSectionResizeMode(int visual, QHeaderView::ResizeMode mode) | - |
3691 | { | - |
3692 | int size = headerSectionSize(visual); | - |
3693 | createSectionItems(visual, visual, size, mode); | - |
3694 | } | - |
3695 | | - |
3696 | QHeaderView::ResizeMode QHeaderViewPrivate::headerSectionResizeMode(int visual) const | - |
3697 | { | - |
3698 | if (visual < 0 || visual >= sectionItems.count()) | - |
3699 | return globalResizeMode; | - |
3700 | return static_cast<QHeaderView::ResizeMode>(sectionItems.at(visual).resizeMode); | - |
3701 | } | - |
3702 | | - |
3703 | void QHeaderViewPrivate::setGlobalHeaderResizeMode(QHeaderView::ResizeMode mode) | - |
3704 | { | - |
3705 | globalResizeMode = mode; | - |
3706 | for (int i = 0; i < sectionItems.count(); ++i) | - |
3707 | sectionItems[i].resizeMode = mode; | - |
3708 | } | - |
3709 | | - |
3710 | int QHeaderViewPrivate::viewSectionSizeHint(int logical) const | - |
3711 | { | - |
3712 | if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(parent)) { | - |
3713 | return (orientation == Qt::Horizontal | - |
3714 | ? view->sizeHintForColumn(logical) | - |
3715 | : view->sizeHintForRow(logical)); | - |
3716 | } | - |
3717 | return 0; | - |
3718 | } | - |
3719 | | - |
3720 | int QHeaderViewPrivate::adjustedVisualIndex(int visualIndex) const | - |
3721 | { | - |
3722 | if (!hiddenSectionSize.isEmpty()) { | - |
3723 | int adjustedVisualIndex = visualIndex; | - |
3724 | int currentVisualIndex = 0; | - |
3725 | for (int i = 0; i < sectionItems.count(); ++i) { | - |
3726 | if (isVisualIndexHidden(i)) | - |
3727 | ++adjustedVisualIndex; | - |
3728 | else | - |
3729 | ++currentVisualIndex; | - |
3730 | if (currentVisualIndex >= visualIndex) | - |
3731 | break; | - |
3732 | } | - |
3733 | visualIndex = adjustedVisualIndex; | - |
3734 | } | - |
3735 | return visualIndex; | - |
3736 | } | - |
3737 | | - |
3738 | void QHeaderViewPrivate::setScrollOffset(const QScrollBar *scrollBar, QAbstractItemView::ScrollMode scrollMode) | - |
3739 | { | - |
3740 | Q_Q(QHeaderView); | - |
3741 | if (scrollMode == QAbstractItemView::ScrollPerItem) { | - |
3742 | if (scrollBar->maximum() > 0 && scrollBar->value() == scrollBar->maximum()) | - |
3743 | q->setOffsetToLastSection(); | - |
3744 | else | - |
3745 | q->setOffsetToSectionPosition(scrollBar->value()); | - |
3746 | } else { | - |
3747 | q->setOffset(scrollBar->value()); | - |
3748 | } | - |
3749 | } | - |
3750 | | - |
3751 | #ifndef QT_NO_DATASTREAM | - |
3752 | void QHeaderViewPrivate::write(QDataStream &out) const | - |
3753 | { | - |
3754 | out << int(orientation); | - |
3755 | out << int(sortIndicatorOrder); | - |
3756 | out << sortIndicatorSection; | - |
3757 | out << sortIndicatorShown; | - |
3758 | | - |
3759 | out << visualIndices; | - |
3760 | out << logicalIndices; | - |
3761 | | - |
3762 | out << sectionsHiddenToBitVector(); | - |
3763 | out << hiddenSectionSize; | - |
3764 | | - |
3765 | out << length; | - |
3766 | out << sectionCount(); | - |
3767 | out << movableSections; | - |
3768 | out << clickableSections; | - |
3769 | out << highlightSelected; | - |
3770 | out << stretchLastSection; | - |
3771 | out << cascadingResizing; | - |
3772 | out << stretchSections; | - |
3773 | out << contentsSections; | - |
3774 | out << defaultSectionSize; | - |
3775 | out << minimumSectionSize; | - |
3776 | | - |
3777 | out << int(defaultAlignment); | - |
3778 | out << int(globalResizeMode); | - |
3779 | | - |
3780 | out << sectionItems; | - |
3781 | out << resizeContentsPrecision; | - |
3782 | out << customDefaultSectionSize; | - |
3783 | out << lastSectionSize; | - |
3784 | } never executed: end of block | 0 |
3785 | | - |
3786 | bool QHeaderViewPrivate::read(QDataStream &in) | - |
3787 | { | - |
3788 | Q_Q(QHeaderView); | - |
3789 | int orient, order, align, global; | - |
3790 | int sortIndicatorSectionIn; | - |
3791 | bool sortIndicatorShownIn; | - |
3792 | int lengthIn; | - |
3793 | QVector<int> visualIndicesIn; | - |
3794 | QVector<int> logicalIndicesIn; | - |
3795 | QHash<int, int> hiddenSectionSizeIn; | - |
3796 | bool movableSectionsIn; | - |
3797 | bool clickableSectionsIn; | - |
3798 | bool highlightSelectedIn; | - |
3799 | bool stretchLastSectionIn; | - |
3800 | bool cascadingResizingIn; | - |
3801 | int stretchSectionsIn; | - |
3802 | int contentsSectionsIn; | - |
3803 | int defaultSectionSizeIn; | - |
3804 | int minimumSectionSizeIn; | - |
3805 | QVector<SectionItem> sectionItemsIn; | - |
3806 | | - |
3807 | in >> orient; | - |
3808 | in >> order; | - |
3809 | | - |
3810 | in >> sortIndicatorSectionIn; | - |
3811 | in >> sortIndicatorShownIn; | - |
3812 | | - |
3813 | in >> visualIndicesIn; | - |
3814 | in >> logicalIndicesIn; | - |
3815 | | - |
3816 | QBitArray sectionHidden; | - |
3817 | in >> sectionHidden; | - |
3818 | in >> hiddenSectionSizeIn; | - |
3819 | in >> lengthIn; | - |
3820 | | - |
3821 | int unusedSectionCount; | - |
3822 | in >> unusedSectionCount; | - |
3823 | | - |
3824 | if (in.status() != QDataStream::Ok || lengthIn < 0)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3825 | return false; never executed: return false; | 0 |
3826 | | - |
3827 | in >> movableSectionsIn; | - |
3828 | in >> clickableSectionsIn; | - |
3829 | in >> highlightSelectedIn; | - |
3830 | in >> stretchLastSectionIn; | - |
3831 | in >> cascadingResizingIn; | - |
3832 | in >> stretchSectionsIn; | - |
3833 | in >> contentsSectionsIn; | - |
3834 | in >> defaultSectionSizeIn; | - |
3835 | in >> minimumSectionSizeIn; | - |
3836 | | - |
3837 | in >> align; | - |
3838 | | - |
3839 | in >> global; | - |
3840 | | - |
3841 | in >> sectionItemsIn; | - |
3842 | | - |
3843 | | - |
3844 | | - |
3845 | QVector<SectionItem> newSectionItems; | - |
3846 | for (int u = 0; u < sectionItemsIn.count(); ++u) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3847 | int count = sectionItemsIn.at(u).tmpDataStreamSectionCount; | - |
3848 | if (count > 0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3849 | sectionItemsIn[u].size /= count; never executed: sectionItemsIn[u].size /= count; | 0 |
3850 | for (int n = 0; n < count; ++n)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3851 | newSectionItems.append(sectionItemsIn[u]); never executed: newSectionItems.append(sectionItemsIn[u]); | 0 |
3852 | } never executed: end of block | 0 |
3853 | | - |
3854 | int sectionItemsLengthTotal = 0; | - |
3855 | foreach (const SectionItem §ion, newSectionItems) | - |
3856 | sectionItemsLengthTotal += section.size; never executed: sectionItemsLengthTotal += section.size; | 0 |
3857 | if (sectionItemsLengthTotal != lengthIn)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3858 | return false; never executed: return false; | 0 |
3859 | | - |
3860 | orientation = static_cast<Qt::Orientation>(orient); | - |
3861 | sortIndicatorOrder = static_cast<Qt::SortOrder>(order); | - |
3862 | sortIndicatorSection = sortIndicatorSectionIn; | - |
3863 | sortIndicatorShown = sortIndicatorShownIn; | - |
3864 | visualIndices = visualIndicesIn; | - |
3865 | logicalIndices = logicalIndicesIn; | - |
3866 | hiddenSectionSize = hiddenSectionSizeIn; | - |
3867 | length = lengthIn; | - |
3868 | | - |
3869 | movableSections = movableSectionsIn; | - |
3870 | clickableSections = clickableSectionsIn; | - |
3871 | highlightSelected = highlightSelectedIn; | - |
3872 | stretchLastSection = stretchLastSectionIn; | - |
3873 | cascadingResizing = cascadingResizingIn; | - |
3874 | stretchSections = stretchSectionsIn; | - |
3875 | contentsSections = contentsSectionsIn; | - |
3876 | defaultSectionSize = defaultSectionSizeIn; | - |
3877 | minimumSectionSize = minimumSectionSizeIn; | - |
3878 | | - |
3879 | defaultAlignment = Qt::Alignment(align); | - |
3880 | globalResizeMode = static_cast<QHeaderView::ResizeMode>(global); | - |
3881 | | - |
3882 | sectionItems = newSectionItems; | - |
3883 | setHiddenSectionsFromBitVector(sectionHidden); | - |
3884 | recalcSectionStartPos(); | - |
3885 | | - |
3886 | int tmpint; | - |
3887 | in >> tmpint; | - |
3888 | if (in.status() == QDataStream::Ok) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3889 | resizeContentsPrecision = tmpint; never executed: resizeContentsPrecision = tmpint; | 0 |
3890 | | - |
3891 | bool tmpbool; | - |
3892 | in >> tmpbool; | - |
3893 | if (in.status() == QDataStream::Ok) { TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3894 | customDefaultSectionSize = tmpbool; | - |
3895 | if (!customDefaultSectionSize)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3896 | updateDefaultSectionSizeFromStyle(); never executed: updateDefaultSectionSizeFromStyle(); | 0 |
3897 | } never executed: end of block | 0 |
3898 | | - |
3899 | lastSectionSize = -1; | - |
3900 | int inLastSectionSize; | - |
3901 | in >> inLastSectionSize; | - |
3902 | if (in.status() == QDataStream::Ok)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3903 | lastSectionSize = inLastSectionSize; never executed: lastSectionSize = inLastSectionSize; | 0 |
3904 | | - |
3905 | lastSectionLogicalIdx = -1; | - |
3906 | if (stretchLastSection) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
3907 | lastSectionLogicalIdx = q->logicalIndex(lastVisibleVisualIndex()); | - |
3908 | doDelayedResizeSections(); | - |
3909 | } never executed: end of block | 0 |
3910 | | - |
3911 | return true; never executed: return true; | 0 |
3912 | } | - |
3913 | | - |
3914 | #endif // QT_NO_DATASTREAM | - |
3915 | | - |
3916 | QT_END_NAMESPACE | - |
3917 | | - |
3918 | #endif // QT_NO_ITEMVIEWS | - |
3919 | | - |
3920 | #include "moc_qheaderview.cpp" | - |
| | |