summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-04-16 17:40:59 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-22 18:35:52 +0200
commit00b11ccdead05d77589d4ec5ebb3b376c6ae2ca1 (patch)
treef17f223cdff64199c7fae56a833273bfdac0ab18 /tests/auto
parent241ee2ee4208eb6b338390f82b71f1b1d7c4c5b0 (diff)
Fix QTableView::doItemsLayout()
Keep the content aligned to the bottom when the view has been scrolled to the bottom and the content is relayouted (for example due to sorting). Task-number: QTBUG-30653 Change-Id: I9513e295e276d25ff2068036cd80dbf91314fe84 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 13476a7ffa..8e888f06ee 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -199,6 +199,7 @@ private slots:
void taskQTBUG_7774_RtoLVisualRegionForSelection();
void taskQTBUG_8777_scrollToSpans();
void taskQTBUG_10169_sizeHintForRow();
+ void taskQTBUG_30653_doItemsLayout();
void mouseWheel_data();
void mouseWheel();
@@ -4096,5 +4097,38 @@ void tst_QTableView::viewOptions()
QVERIFY(options.showDecorationSelected);
}
+void tst_QTableView::taskQTBUG_30653_doItemsLayout()
+{
+ QWidget topLevel;
+ QtTestTableView view(&topLevel);
+
+ QtTestTableModel model(5, 5);
+ view.setModel(&model);
+
+ QtTestItemDelegate delegate;
+ delegate.hint = QSize(50, 50);
+ view.setItemDelegate(&delegate);
+
+ view.resizeRowsToContents();
+ view.resizeColumnsToContents();
+
+ // show two and half rows/cols
+ int extraWidth = view.verticalHeader()->sizeHint().width() + view.verticalScrollBar()->sizeHint().width();
+ int extraHeight = view.horizontalHeader()->sizeHint().height() + view.horizontalScrollBar()->sizeHint().height();
+ view.resize(125 + extraWidth, 125 + extraHeight);
+
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
+ // the offset after scrollToBottom() and doItemsLayout() should not differ
+ // as the view content should stay aligned to the last section
+ view.scrollToBottom();
+ int scrollToBottomOffset = view.verticalHeader()->offset();
+ view.doItemsLayout();
+ int doItemsLayoutOffset = view.verticalHeader()->offset();
+
+ QCOMPARE(scrollToBottomOffset, doItemsLayoutOffset);
+}
+
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"