summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-01-21 19:55:40 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-01-29 10:34:31 +0000
commit3adfcbf1ed9b63c3ce41d7417658db3836fd3530 (patch)
tree9dfe3e9f91032f373ace1cab45a92131400fad25 /tests
parent5a05348fb6c3940449a9c2950bb65bdea2112a15 (diff)
QHeaderView: properly restore section data after layoutChanged()
QHeaderView is doing a complete rebuild of the sections when the layout changed because everything could have happened. But since layoutChanged is also called during e.g. sorting, the old data must be restored when possible. Task-number: QTBUG-65478 Change-Id: I088d4d843cad362b97df6dc5e0dcb9819b13547f Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 90019a1798..6dae2cf8e4 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -2251,10 +2251,6 @@ void tst_QHeaderView::QTBUG6058_reset()
void tst_QHeaderView::QTBUG7833_sectionClicked()
{
-
-
-
-
QTableView tv;
QStandardItemModel *sim = new QStandardItemModel(&tv);
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(&tv);
@@ -2278,11 +2274,20 @@ void tst_QHeaderView::QTBUG7833_sectionClicked()
tv.horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
tv.setModel(proxyModel);
+ const int section4Size = tv.horizontalHeader()->sectionSize(4) + 1;
+ tv.horizontalHeader()->resizeSection(4, section4Size);
tv.setColumnHidden(5, true);
tv.setColumnHidden(6, true);
tv.horizontalHeader()->swapSections(8, 10);
tv.sortByColumn(1, Qt::AscendingOrder);
+ QCOMPARE(tv.isColumnHidden(5), true);
+ QCOMPARE(tv.isColumnHidden(6), true);
+ QCOMPARE(tv.horizontalHeader()->sectionsMoved(), true);
+ QCOMPARE(tv.horizontalHeader()->logicalIndex(8), 10);
+ QCOMPARE(tv.horizontalHeader()->logicalIndex(10), 8);
+ QCOMPARE(tv.horizontalHeader()->sectionSize(4), section4Size);
+
QSignalSpy clickedSpy(tv.horizontalHeader(), SIGNAL(sectionClicked(int)));
QSignalSpy pressedSpy(tv.horizontalHeader(), SIGNAL(sectionPressed(int)));