diff options
author | Frank Reininghaus <frank78ac@googlemail.com> | 2010-09-22 08:19:59 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-09-22 08:19:59 (GMT) |
commit | 6da6b7099d4e0b49329793e4b90703ec3d868048 (patch) | |
tree | 2236200f0d2d1222865053480d45379e1b2ea749 /tests/auto/qtreeview/tst_qtreeview.cpp | |
parent | 80c2e1211065f606c6f39e708a74afad1c624663 (diff) | |
download | Qt-6da6b7099d4e0b49329793e4b90703ec3d868048.zip Qt-6da6b7099d4e0b49329793e4b90703ec3d868048.tar.gz Qt-6da6b7099d4e0b49329793e4b90703ec3d868048.tar.bz2 |
QTreeView: do not scroll to top if last item is removed
When the last item is the current item and is removed,
QTreeViewPrivate::updateScrollBars() is called after QTreeViewPrivate's
viewItems member is cleared. This commit makes sure that viewItems is
restored by calling QTreeView::doItemsLayout() in this case, preventing
that the scroll bar range is set to zero temporarily and the view is
scrolled to the top unexpectedly (this was a regression in 4.7.0:
QTBUG-13567).
Merge-request: 2481
Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
Diffstat (limited to 'tests/auto/qtreeview/tst_qtreeview.cpp')
-rw-r--r-- | tests/auto/qtreeview/tst_qtreeview.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 7e2e800..c7b53e9 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -240,6 +240,7 @@ private slots: void taskQTBUG_6450_selectAllWith1stColumnHidden(); void taskQTBUG_9216_setSizeAndUniformRowHeightsWrongRepaint(); void taskQTBUG_11466_keyboardNavigationRegression(); + void taskQTBUG_13567_removeLastItemRegression(); }; class QtTestModel: public QAbstractItemModel @@ -3910,5 +3911,26 @@ void tst_QTreeView::taskQTBUG_11466_keyboardNavigationRegression() QTRY_COMPARE(treeView.currentIndex(), treeView.selectionModel()->selection().indexes().first()); } +void tst_QTreeView::taskQTBUG_13567_removeLastItemRegression() +{ + QtTestModel model(200, 1); + + QTreeView view; + view.setSelectionMode(QAbstractItemView::ExtendedSelection); + view.setModel(&model); + view.show(); + QTest::qWaitForWindowShown(&view); + + view.scrollToBottom(); + QTest::qWait(10); + CHECK_VISIBLE(199, 0); + + view.setCurrentIndex(model.index(199, 0)); + model.removeLastRow(); + QTest::qWait(10); + QCOMPARE(view.currentIndex(), model.index(198, 0)); + CHECK_VISIBLE(198, 0); +} + QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" |