summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-04-16 15:53:46 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-23 12:03:07 (GMT)
commite36e83b5e65a703058ec5a4e4418fe6a49d73e2c (patch)
tree1dc62cdb9be3b05fcc47dfd884d78c72127f394f /tests/auto
parentdc5db85ca4f95a0cfe682d90693d05a74af63f55 (diff)
downloadQt-e36e83b5e65a703058ec5a4e4418fe6a49d73e2c.zip
Qt-e36e83b5e65a703058ec5a4e4418fe6a49d73e2c.tar.gz
Qt-e36e83b5e65a703058ec5a4e4418fe6a49d73e2c.tar.bz2
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 (cherry-picked from qtbase commit 00b11ccdead05d77589d4ec5ebb3b376c6ae2ca1) Change-Id: I183145fbd84339e82d2d1d0bc39cea33d9cc9734 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 73cb379..1939b61 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -203,6 +203,7 @@ private slots:
void taskQTBUG_7774_RtoLVisualRegionForSelection();
void taskQTBUG_8777_scrollToSpans();
void taskQTBUG_10169_sizeHintForRow();
+ void taskQTBUG_30653_doItemsLayout();
void mouseWheel_data();
void mouseWheel();
@@ -4069,5 +4070,38 @@ void tst_QTableView::taskQTBUG_10169_sizeHintForRow()
QCOMPARE(orderedHeight, reorderedHeight);
}
+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::qWaitForWindowShown(&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"