diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-08-05 13:44:38 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-05 09:23:48 +0200 |
commit | ab4cac7453c5da79f356bdac4b15d876dde97938 (patch) | |
tree | 78bbbf3b7833b8242b130a6cda41de5df8085a4a /src/qtquick1 | |
parent | 97ff5987170460172f9a808193b17af8b3abd6d3 (diff) |
ListView with StrictlyEnforceRange skips over items
When list item size varies smaller items next to larger
items may not be able to become the current item. Ensure
the snap item is found using the correct range, i.e.
half of previous item above snap pos and half of next item
below.
Change-Id: I52ae235e6b801bda48fcb636bb4150ab643715e8
Fixes: QTBUG-20745
Reviewed-on: http://codereview.qt.nokia.com/2650
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'src/qtquick1')
-rw-r--r-- | src/qtquick1/graphicsitems/qdeclarativelistview.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/qtquick1/graphicsitems/qdeclarativelistview.cpp b/src/qtquick1/graphicsitems/qdeclarativelistview.cpp index 244a2b83fc..bc06f9b2fe 100644 --- a/src/qtquick1/graphicsitems/qdeclarativelistview.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativelistview.cpp @@ -446,6 +446,7 @@ public: FxListItem1 *snapItemAt(qreal pos) { FxListItem1 *snapItem = 0; + qreal prevItemSize = 0; for (int i = 0; i < visibleItems.count(); ++i) { FxListItem1 *item = visibleItems[i]; if (item->index == -1) @@ -453,8 +454,9 @@ public: qreal itemTop = item->position(); if (highlight && itemTop >= pos && item->endPosition() <= pos + highlight->size() - 1) return item; - if (itemTop+item->size()/2 >= pos && itemTop-item->size()/2 < pos) + if (itemTop+item->size()/2 >= pos && itemTop-prevItemSize/2 < pos) snapItem = item; + prevItemSize = item->size(); } return snapItem; } |