From a02b371eb2f34bf198c95cf0caa1fbad639f96bb Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 17 Dec 2017 19:56:35 +0100 Subject: QHeaderView: properly connect rows/columnsMoved QHeaderViewPrivate reimplemented _q_layoutChanged() to handle changes of rows/columns via layoutChanged/layoutAboutToBeChanged. This worked fine for Qt4 but since Qt5 only the special signals rowsAboutToBeMoved/ rowsMoved are used for this (8021e2d5e7ccd09146896f788441c116f2ca6159). With this change, QAbstractItemViewPrivate::_q_rows/columnsMoved() is calling the virtual function _q_layoutChanged(). This resulted in a wrong call of QHP::_q_layoutChanged() for a horizontal header when a row changed and for a vertical header during a column change. In the end this can lead to an unhide of hidden sections. Task-number: QTBUG-54610 Change-Id: Ide4bfc5b24a97746fd1e5af82d3ba08257149157 Reviewed-by: David Faure Reviewed-by: Olivier Goffart (Woboq GmbH) --- .../widgets/itemviews/qtreeview/tst_qtreeview.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp') diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index f870605d7d..5293ba487a 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -312,6 +312,12 @@ public: return QVariant(); } + void simulateMoveRows() + { + beginMoveRows(QModelIndex(), 0, 0, QModelIndex(), 2); + endMoveRows(); + } + void removeLastRow() { beginRemoveRows(QModelIndex(), rows - 1, rows - 1); @@ -1327,6 +1333,17 @@ void tst_QTreeView::columnHidden() for (int c = 0; c < model.columnCount(); ++c) QCOMPARE(view.isColumnHidden(c), true); view.update(); + + // QTBUG 54610 + // QAbstractItemViewPrivate::_q_layoutChanged() is called on + // rows/columnMoved and because this function is virtual, + // QHeaderViewPrivate::_q_layoutChanged() was called and unhided + // all sections because QHeaderViewPrivate::_q_layoutAboutToBeChanged() + // could not fill persistentHiddenSections (and is not needed) + view.hideColumn(model.cols - 1); + QCOMPARE(view.isColumnHidden(model.cols - 1), true); + model.simulateMoveRows(); + QCOMPARE(view.isColumnHidden(model.cols - 1), true); } void tst_QTreeView::rowHidden() @@ -4601,7 +4618,7 @@ void tst_QTreeView::fetchMoreOnScroll() tw.setModel(&im); tw.show(); tw.expandAll(); - QTest::qWaitForWindowActive(&tw); + QVERIFY(QTest::qWaitForWindowActive(&tw)); // Now we can allow the fetch to happen im.canFetchReady = true; tw.verticalScrollBar()->setValue(tw.verticalScrollBar()->maximum()); -- cgit v1.2.3