diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-08 23:47:49 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-08 23:47:49 (GMT) |
commit | 139b84198b6bd0454becc9d5ae1a64a1e22f1fe2 (patch) | |
tree | 52181b059c8d73c42ffd5b120b4aa3a6e9bb2853 /src/declarative/graphicsitems/qdeclarativelistview.cpp | |
parent | cabf4f41a51599b3527cd848af14966986430566 (diff) | |
download | Qt-139b84198b6bd0454becc9d5ae1a64a1e22f1fe2.zip Qt-139b84198b6bd0454becc9d5ae1a64a1e22f1fe2.tar.gz Qt-139b84198b6bd0454becc9d5ae1a64a1e22f1fe2.tar.bz2 |
Add highlightMoveDuration to views.
Task-number: QTBUG-7568
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativelistview.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 31d97f3..b4506ef 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -156,7 +156,8 @@ public: , highlightComponent(0), highlight(0), trackedItem(0) , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0) , sectionCriteria(0), spacing(0.0) - , highlightMoveSpeed(400), highlightResizeSpeed(400), highlightRange(QDeclarativeListView::NoHighlightRange) + , highlightMoveSpeed(400), highlightMoveDuration(-1) + , highlightResizeSpeed(400), highlightResizeDuration(-1), highlightRange(QDeclarativeListView::NoHighlightRange) , snapMode(QDeclarativeListView::NoSnap), overshootDist(0.0) , footerComponent(0), footer(0), headerComponent(0), header(0) , bufferMode(NoBuffer) @@ -464,7 +465,9 @@ public: QDeclarativeItem *sectionCache[sectionCacheSize]; qreal spacing; qreal highlightMoveSpeed; + int highlightMoveDuration; qreal highlightResizeSpeed; + int highlightResizeDuration; QDeclarativeListView::HighlightRangeMode highlightRange; QDeclarativeListView::SnapMode snapMode; qreal overshootDist; @@ -835,10 +838,12 @@ void QDeclarativeListViewPrivate::createHighlight() highlightPosAnimator = new QSmoothedAnimation(q); highlightPosAnimator->target = QDeclarativeProperty(highlight->item, posProp); highlightPosAnimator->velocity = highlightMoveSpeed; + highlightPosAnimator->userDuration = highlightMoveDuration; highlightPosAnimator->restart(); const QLatin1String sizeProp(orient == QDeclarativeListView::Vertical ? "height" : "width"); highlightSizeAnimator = new QSmoothedAnimation(q); highlightSizeAnimator->velocity = highlightResizeSpeed; + highlightSizeAnimator->userDuration = highlightResizeDuration; highlightSizeAnimator->target = QDeclarativeProperty(highlight->item, sizeProp); highlightSizeAnimator->restart(); changed = true; @@ -1867,13 +1872,19 @@ QString QDeclarativeListView::currentSection() const /*! \qmlproperty real ListView::highlightMoveSpeed + \qmlproperty int ListView::highlightMoveDuration \qmlproperty real ListView::highlightResizeSpeed + \qmlproperty int ListView::highlightResizeDuration These properties hold the move and resize animation speed of the highlight delegate. highlightFollowsCurrentItem must be true for these properties to have effect. - The default value for these properties is 400 pixels/second. + The default value for the speed properties is 400 pixels/second. + The default value for the duration properties is -1, i.e. the + highlight will take as much time as necessary to move at the set speed. + + These properties have the same characteristics as a SmoothedAnimation. \sa highlightFollowsCurrentItem */ @@ -1894,6 +1905,23 @@ void QDeclarativeListView::setHighlightMoveSpeed(qreal speed) } } +int QDeclarativeListView::highlightMoveDuration() const +{ + Q_D(const QDeclarativeListView); + return d->highlightMoveDuration; +} + +void QDeclarativeListView::setHighlightMoveDuration(int duration) +{ + Q_D(QDeclarativeListView);\ + if (d->highlightMoveDuration != duration) { + d->highlightMoveDuration = duration; + if (d->highlightPosAnimator) + d->highlightPosAnimator->userDuration = d->highlightMoveDuration; + emit highlightMoveDurationChanged(); + } +} + qreal QDeclarativeListView::highlightResizeSpeed() const { Q_D(const QDeclarativeListView);\ @@ -1911,6 +1939,23 @@ void QDeclarativeListView::setHighlightResizeSpeed(qreal speed) } } +int QDeclarativeListView::highlightResizeDuration() const +{ + Q_D(const QDeclarativeListView); + return d->highlightResizeDuration; +} + +void QDeclarativeListView::setHighlightResizeDuration(int duration) +{ + Q_D(QDeclarativeListView);\ + if (d->highlightResizeDuration != duration) { + d->highlightResizeDuration = duration; + if (d->highlightSizeAnimator) + d->highlightSizeAnimator->userDuration = d->highlightResizeDuration; + emit highlightResizeDurationChanged(); + } +} + /*! \qmlproperty enumeration ListView::snapMode |