summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
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 /src/gui/itemviews
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 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qtableview.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp
index 13ce309..63036b2 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/gui/itemviews/qtableview.cpp
@@ -1108,10 +1108,15 @@ void QTableView::doItemsLayout()
{
Q_D(QTableView);
QAbstractItemView::doItemsLayout();
- if (verticalScrollMode() == QAbstractItemView::ScrollPerItem)
- d->verticalHeader->setOffsetToSectionPosition(verticalScrollBar()->value());
- else
+ if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
+ const int max = verticalScrollBar()->maximum();
+ if (max > 0 && verticalScrollBar()->value() == max)
+ d->verticalHeader->setOffsetToLastSection();
+ else
+ d->verticalHeader->setOffsetToSectionPosition(verticalScrollBar()->value());
+ } else {
d->verticalHeader->setOffset(verticalScrollBar()->value());
+ }
if (!d->verticalHeader->updatesEnabled())
d->verticalHeader->setUpdatesEnabled(true);
}