diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-08-24 08:24:27 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-27 09:52:13 (GMT) |
commit | 7982f6ad2703e13edbf80d55e537871bf1cd548d (patch) | |
tree | ad23b8bbbe93704d01702948f8abd10bba748004 /src/gui | |
parent | 99e6ea17e257664467d49f4803952b7dd92f72da (diff) | |
download | Qt-7982f6ad2703e13edbf80d55e537871bf1cd548d.zip Qt-7982f6ad2703e13edbf80d55e537871bf1cd548d.tar.gz Qt-7982f6ad2703e13edbf80d55e537871bf1cd548d.tar.bz2 |
Take account of hidden items in QListView when using scrollTo.
This is a backport of 799ceebad8a2dbe1ca0e60a11c7d6ca0c2c8b7a9 from
qtbase.
Task-number: QTBUG-21804
Change-Id: I757b9598f354cdfa62c08d0c2613ded93fe88804
Reviewed-by: Jani Honkonen <jani.honkonen@digia.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/itemviews/qlistview.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 3a8cedb..2632807 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -2133,10 +2133,16 @@ int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hi { if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) { int value; - if (scrollValueMap.isEmpty()) + if (scrollValueMap.isEmpty()) { value = 0; - else - value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()), flowPositions.count() - 1); + } else { + int scrollBarValue = verticalScrollBar()->value(); + int numHidden = 0; + for (int i = 0; i < flowPositions.count() - 1 && i <= scrollBarValue; ++i) + if (isHidden(i)) + ++numHidden; + value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()) - numHidden, flowPositions.count() - 1); + } if (above) hint = QListView::PositionAtTop; else if (below) |