diff options
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativelistview.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 60 |
1 files changed, 23 insertions, 37 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 94b1cb3..6be49ba 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -124,8 +124,8 @@ public: } qreal endPosition() const { return (view->orientation() == QDeclarativeListView::Vertical - ? item->y() + (item->height() > 0 ? item->height() : 1) - : item->x() + (item->width() > 0 ? item->width() : 1)) - 1; + ? item->y() + (item->height() >= 1.0 ? item->height() : 1) + : item->x() + (item->width() >= 1.0 ? item->width() : 1)) - 1; } void setPosition(qreal pos) { if (view->orientation() == QDeclarativeListView::Vertical) { @@ -736,7 +736,7 @@ void QDeclarativeListViewPrivate::layout() } if (!visibleItems.isEmpty()) { qreal oldEnd = visibleItems.last()->endPosition(); - qreal pos = visibleItems.first()->endPosition() + spacing + 1; + qreal pos = visibleItems.first()->position() + visibleItems.first()->size() + spacing; for (int i=1; i < visibleItems.count(); ++i) { FxListItem *item = visibleItems.at(i); item->setPosition(pos); @@ -1161,30 +1161,35 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m int oldDuration = fixupDuration; fixupDuration = moveReason == Mouse ? fixupDuration : 0; - if (snapMode != QDeclarativeListView::NoSnap) { + if (currentItem && haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) { + updateHighlight(); + qreal pos = currentItem->itemPosition(); + qreal viewPos = position(); + if (viewPos < pos + currentItem->itemSize() - highlightRangeEnd) + viewPos = pos + currentItem->itemSize() - highlightRangeEnd; + if (viewPos > pos - highlightRangeStart) + viewPos = pos - highlightRangeStart; + + timeline.reset(data.move); + if (viewPos != position()) { + if (fixupDuration) + timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); + else + timeline.set(data.move, -viewPos); + } + vTime = timeline.time(); + } else if (snapMode != QDeclarativeListView::NoSnap) { FxListItem *topItem = snapItemAt(position()+highlightRangeStart); FxListItem *bottomItem = snapItemAt(position()+highlightRangeEnd); qreal pos; - if (topItem && bottomItem && haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) { - qreal topPos = qMin(topItem->position() - highlightRangeStart, -maxExtent); - qreal bottomPos = qMax(bottomItem->position() - highlightRangeEnd, -minExtent); - pos = qAbs(data.move + topPos) < qAbs(data.move + bottomPos) ? topPos : bottomPos; - } else if (topItem) { + if (topItem) { pos = qMax(qMin(topItem->position() - highlightRangeStart, -maxExtent), -minExtent); } else if (bottomItem) { - pos = qMax(qMin(bottomItem->position() - highlightRangeStart, -maxExtent), -minExtent); + pos = qMax(qMin(bottomItem->position() - highlightRangeStart, -maxExtent), -minExtent); } else { fixupDuration = oldDuration; return; } - if (currentItem && haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) { - updateHighlight(); - qreal currPos = currentItem->itemPosition(); - if (pos < currPos + currentItem->itemSize() - highlightRangeEnd) - pos = currPos + currentItem->itemSize() - highlightRangeEnd; - if (pos > currPos - highlightRangeStart) - pos = currPos - highlightRangeStart; - } qreal dist = qAbs(data.move + pos); if (dist > 0) { @@ -1195,25 +1200,6 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m timeline.set(data.move, -pos); vTime = timeline.time(); } - } else if (haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) { - if (currentItem) { - updateHighlight(); - qreal pos = currentItem->itemPosition(); - qreal viewPos = position(); - if (viewPos < pos + currentItem->itemSize() - highlightRangeEnd) - viewPos = pos + currentItem->itemSize() - highlightRangeEnd; - if (viewPos > pos - highlightRangeStart) - viewPos = pos - highlightRangeStart; - - timeline.reset(data.move); - if (viewPos != position()) { - if (fixupDuration) - timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - else - timeline.set(data.move, -viewPos); - } - vTime = timeline.time(); - } } else { QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent); } |