diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-09-11 05:48:20 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-09-11 05:48:20 (GMT) |
commit | e4648700e7e3c84c61d6b012f7d480394b889c31 (patch) | |
tree | a29fb2181ea14a2ff6726cd468b1b2bdf7e4e967 /src/declarative/fx/qfxlistview.cpp | |
parent | 6065187899b88ce6593077eea5e93737ba31b84e (diff) | |
download | Qt-e4648700e7e3c84c61d6b012f7d480394b889c31.zip Qt-e4648700e7e3c84c61d6b012f7d480394b889c31.tar.gz Qt-e4648700e7e3c84c61d6b012f7d480394b889c31.tar.bz2 |
Fix moving an item to the first visible position.
Also fix the type of some properties/variables.
Diffstat (limited to 'src/declarative/fx/qfxlistview.cpp')
-rw-r--r-- | src/declarative/fx/qfxlistview.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 6596735..ac9b6ca 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -172,11 +172,11 @@ public: QFxListViewPrivate() : model(0), currentItem(0), tmpCurrent(0), orient(Qt::Vertical) , visiblePos(0), visibleIndex(0) - , averageSize(100), currentIndex(-1), requestedIndex(-1) + , averageSize(100.0), currentIndex(-1), requestedIndex(-1) , currItemMode(QFxListView::Free), snapPos(0), highlightComponent(0), highlight(0), trackedItem(0) - , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0), spacing(0) + , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0), spacing(0.0) , ownModel(false), wrap(false), autoHighlight(true) - , fixCurrentVisibility(false) {} + {} void init(); void clear(); @@ -205,7 +205,7 @@ public: else q->setViewportX(pos); } - int size() const { + qreal size() const { Q_Q(const QFxListView); return orient == Qt::Vertical ? q->height() : q->width(); } @@ -384,12 +384,11 @@ public: QmlEaseFollow *highlightSizeAnimator; QString sectionExpression; QString currentSection; - int spacing; + qreal spacing; - int ownModel : 1; - int wrap : 1; - int autoHighlight : 1; - int fixCurrentVisibility : 1; + bool ownModel : 1; + bool wrap : 1; + bool autoHighlight : 1; }; void QFxListViewPrivate::init() @@ -755,7 +754,6 @@ void QFxListViewPrivate::updateCurrent(int modelIndex) FxListItem *oldCurrentItem = currentItem; currentIndex = modelIndex; currentItem = createItem(modelIndex); - fixCurrentVisibility = true; if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item)) oldCurrentItem->attached->setIsCurrentItem(false); if (currentItem) { @@ -1149,13 +1147,13 @@ void QFxListView::setSnapPosition(int pos) This property holds the spacing to leave between items. */ -int QFxListView::spacing() const +qreal QFxListView::spacing() const { Q_D(const QFxListView); return d->spacing; } -void QFxListView::setSpacing(int spacing) +void QFxListView::setSpacing(qreal spacing) { Q_D(QFxListView); if (spacing != d->spacing) { @@ -1640,6 +1638,7 @@ void QFxListView::destroyRemoved() void QFxListView::itemsMoved(int from, int to, int count) { Q_D(QFxListView); + qreal firstItemPos = d->visibleItems.first()->position(); QHash<int,FxListItem*> moved; int moveBy = 0; @@ -1653,11 +1652,9 @@ void QFxListView::itemsMoved(int from, int to, int count) moveBy += item->size(); it = d->visibleItems.erase(it); } else { - if (item->index > from && item->index != -1) { - // move everything after the moved items. + // move everything after the moved items. + if (item->index > from && item->index != -1) item->index -= count; - item->setPosition(item->position()-moveBy); - } ++it; } } @@ -1698,6 +1695,9 @@ void QFxListView::itemsMoved(int from, int to, int count) while (moved.count()) d->releaseItem(moved.take(moved.begin().key())); + // Ensure we don't cause an ugly list scroll. + d->visibleItems.first()->setPosition(firstItemPos); + d->layout(); } |