diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-09-10 03:21:36 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-09-10 03:21:36 (GMT) |
commit | 2c0255521f00a1fd95988161a03c39631350eaba (patch) | |
tree | 20947c82c768b3aa785628e92ae0ee7a0ac3bfbd /src/declarative/fx/qfxlistview.cpp | |
parent | c494da05e1d3cb597990098e9713a0af5364c828 (diff) | |
download | Qt-2c0255521f00a1fd95988161a03c39631350eaba.zip Qt-2c0255521f00a1fd95988161a03c39631350eaba.tar.gz Qt-2c0255521f00a1fd95988161a03c39631350eaba.tar.bz2 |
Follow renamed to SpringFollow.
Diffstat (limited to 'src/declarative/fx/qfxlistview.cpp')
-rw-r--r-- | src/declarative/fx/qfxlistview.cpp | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 6c0a83e..49de016 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "private/qfxflickable_p.h" -#include "qmlfollow.h" +#include "qmleasefollow.h" #include "qlistmodelinterface.h" #include "qfxvisualitemmodel.h" #include "qfxlistview.h" @@ -381,8 +381,8 @@ public: enum MovementReason { Other, Key, Mouse }; MovementReason moveReason; int buffer; - QmlFollow *highlightPosAnimator; - QmlFollow *highlightSizeAnimator; + QmlEaseFollow *highlightPosAnimator; + QmlEaseFollow *highlightSizeAnimator; QString sectionExpression; QString currentSection; int spacing; @@ -660,15 +660,18 @@ void QFxListViewPrivate::createHighlight() } if (item) { highlight = new FxListItem(item, q); + if (orient == Qt::Vertical) + highlight->item->setHeight(currentItem->item->height()); + else + highlight->item->setWidth(currentItem->item->width()); const QLatin1String posProp(orient == Qt::Vertical ? "y" : "x"); - highlightPosAnimator = new QmlFollow(q); + highlightPosAnimator = new QmlEaseFollow(q); highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp)); - highlightPosAnimator->setEpsilon(0.25); - highlightPosAnimator->setSpring(2.5); - highlightPosAnimator->setDamping(0.35); + highlightPosAnimator->setVelocity(400); highlightPosAnimator->setEnabled(autoHighlight); const QLatin1String sizeProp(orient == Qt::Vertical ? "height" : "width"); - highlightSizeAnimator = new QmlFollow(q); + highlightSizeAnimator = new QmlEaseFollow(q); + highlightSizeAnimator->setVelocity(400); highlightSizeAnimator->setTarget(QmlMetaProperty(highlight->item, sizeProp)); highlightSizeAnimator->setEnabled(autoHighlight); } @@ -909,6 +912,7 @@ void QFxListView::setModel(const QVariant &model) if (d->model) { disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); + disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); disconnect(d->model, SIGNAL(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*))); disconnect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*))); } @@ -937,6 +941,7 @@ void QFxListView::setModel(const QVariant &model) d->updateCurrent(d->currentIndex); connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); + connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); connect(d->model, SIGNAL(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*))); connect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*))); refill(); @@ -1635,6 +1640,37 @@ void QFxListView::destroyRemoved() d->layout(); } +void QFxListView::itemsMoved(int from, int to, int count) +{ + qWarning() << "ListView does not support moving in models"; + + Q_D(QFxListView); + int fromCount = count; + int toCount = count; + bool fromVisible = d->mapRangeFromModel(from, fromCount); + bool toVisible = d->mapRangeFromModel(to, toCount); + + if (!fromVisible && !toVisible) { + // The items are outside the visible range. + if (d->visibleItems.count()) + d->visibleIndex = -1; + for (int i = 0; i < d->visibleItems.count(); ++i) { + FxListItem *listItem = d->visibleItems.at(i); + if (listItem->index != -1) { + listItem->index = d->model->indexOf(listItem->item, this); + if (d->visibleIndex < 0) + d->visibleIndex = listItem->index; + } + } + if (d->currentItem) { + d->currentItem->index = d->model->indexOf(d->currentItem->item, this); + d->currentIndex = d->currentItem->index; + } + return; + } + +} + void QFxListView::createdItem(int index, QFxItem *item) { Q_D(QFxListView); |