diff options
author | Thorbjørn Lund Martsum <tmartsum@gmail.com> | 2012-10-28 05:55:55 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-31 00:03:22 (GMT) |
commit | da113c065991f2e1d25fd507daf79f5aeb691522 (patch) | |
tree | 203784284ad21cae94de8952081c54b8ae687693 | |
parent | 4ccc7ff70918f1fdbe37637aa72e02d5a90a6550 (diff) | |
download | Qt-da113c065991f2e1d25fd507daf79f5aeb691522.zip Qt-da113c065991f2e1d25fd507daf79f5aeb691522.tar.gz Qt-da113c065991f2e1d25fd507daf79f5aeb691522.tar.bz2 |
QHeaderView - fix minor bug in visualIndexAt
This fixes a minor bug in VisualIndex triggered when calling
resizeSection with size 0 (but not hideSection).
It is mostly cosmetics - but it is still a bug.
This is a backport of SHA 73a5bc2aac7638438dfde260a4246359a06e89ae
Change-Id: Ic3e1ce584d8befa501c670c085435248ebaa681b
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
-rw-r--r-- | src/gui/itemviews/qheaderview.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qheaderview/tst_qheaderview.cpp | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 4fa155a..65a8858 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -3488,8 +3488,8 @@ int QHeaderViewPrivate::headerVisualIndexAt(int position) const const QHeaderViewPrivate::SectionSpan ¤tSection = sectionSpans.at(i); int next_span_start_section = span_start_section + currentSection.count; int next_span_position = span_position + currentSection.size; - if (position == span_position) - return span_start_section; // spans with no size + if (position == span_position && currentSection.size > 0) + return span_start_section; if (position > span_position && position < next_span_position) { int position_in_span = position - span_position; return span_start_section + (position_in_span / currentSection.sectionSize()); diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp index 6e68564..2588f5e 100644 --- a/tests/auto/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/qheaderview/tst_qheaderview.cpp @@ -197,6 +197,7 @@ private slots: void QTBUG14242_hideSectionAutoSize(); void initialSortOrderRole(); + void ensureNoIndexAtLength(); protected: QWidget *topLevel; @@ -2162,5 +2163,17 @@ void tst_QHeaderView::initialSortOrderRole() QCOMPARE(view.horizontalHeader()->sortIndicatorOrder(), Qt::AscendingOrder); } +void tst_QHeaderView::ensureNoIndexAtLength() +{ + QTableView qtv; + QStandardItemModel amodel(4, 4); + qtv.setModel(&amodel); + QHeaderView *hv = qtv.verticalHeader(); + QVERIFY(hv->visualIndexAt(hv->length()) == -1); + hv->resizeSection(hv->count() - 1, 0); + QVERIFY(hv->visualIndexAt(hv->length()) == -1); +} + + QTEST_MAIN(tst_QHeaderView) #include "tst_qheaderview.moc" |