summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJani Honkonen <jani.honkonen@digia.com>2012-02-28 10:26:22 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-08-22 00:59:03 (GMT)
commit1de75716d6f0691cc57feb21768f250236eebfd4 (patch)
tree67e4247ab40c82e304726e7b10822e3bf3794cfa /src
parent1cc7a13c71240507a5c6aa31fdf63e2db30d4117 (diff)
downloadQt-1de75716d6f0691cc57feb21768f250236eebfd4.zip
Qt-1de75716d6f0691cc57feb21768f250236eebfd4.tar.gz
Qt-1de75716d6f0691cc57feb21768f250236eebfd4.tar.bz2
Fix QListWidget scrolling with keys when there are hidden items
If the selected item is scrolled with keyboard keys the selected item will go outside the visible area. The scrolling did not take hidden items into account when calculating the amout to be scrolled. Backported from Qt5 commit: d4385e48b8566a5587048a3c6d8b2396ba587ed5 Task-number: QTBUG-21804 Change-Id: I81a82ed56bb0e4c0229fd117784790e1234aacca Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/itemviews/qlistview.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 6db979c..e6949fd 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -2558,13 +2558,21 @@ int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int view
{
if (index < 0)
return scrollValue;
+
+ QVector<int> visibleFlowPositions;
+ visibleFlowPositions.reserve(flowPositions.count() - 1);
+ for (int i = 0; i < flowPositions.count() - 1; i++) { // flowPositions count is +1 larger than actual row count
+ if (!isHidden(i))
+ visibleFlowPositions.append(flowPositions.at(i));
+ }
+
if (!wrap) {
int topIndex = index;
const int bottomIndex = topIndex;
- const int bottomCoordinate = flowPositions.at(index);
+ const int bottomCoordinate = visibleFlowPositions.at(index);
while (topIndex > 0 &&
- (bottomCoordinate - flowPositions.at(topIndex-1) + itemExtent) <= (viewportSize)) {
+ (bottomCoordinate - visibleFlowPositions.at(topIndex - 1) + itemExtent) <= (viewportSize)) {
topIndex--;
}
@@ -2584,7 +2592,7 @@ int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int view
? Qt::Horizontal : Qt::Vertical);
if (flowOrientation == orientation) { // scrolling in the "flow" direction
// ### wrapped scrolling in the flow direction
- return flowPositions.at(index); // ### always pixel based for now
+ return visibleFlowPositions.at(index); // ### always pixel based for now
} else if (!segmentStartRows.isEmpty()) { // we are scrolling in the "segment" direction
int segment = qBinarySearch<int>(segmentStartRows, index, 0, segmentStartRows.count() - 1);
int leftSegment = segment;