From bbbc44c45d9a6b7381b775413fcfcc1a72c14317 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 23 Feb 2012 11:51:31 +1000 Subject: Clean up some of the view transition docs Fix some of the wording in the docs. Change-Id: I07892bec06c78b73bdd93926719d609405e263b3 Reviewed-by: Bea Lam --- src/quick/items/qquicklistview.cpp | 69 ++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 33 deletions(-) (limited to 'src/quick/items/qquicklistview.cpp') diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 906b9b3781..6324c7d2ff 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -2245,10 +2245,11 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::populate - This property holds the transition to apply to items that are initially created for a - view. - This transition is applied to all the items that are created when: + This property holds the transition to apply to the items that are initially created + for a view. + + It is applied to all items that are created when: \list \o The view is first created @@ -2278,10 +2279,10 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::add - This property holds the transition to apply to items that are added within the view. - The transition is applied to items that have been added to the visible area of the view. For - example, here is a view that specifies such a transition: + This property holds the transition to apply to items that are added to the view. + + For example, here is a view that specifies such a transition: \code ListView { @@ -2310,11 +2311,11 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::addDisplaced - This property holds the transition to apply to items in the view that are displaced by other - items that have been added to the view. - The transition is applied to items that are currently visible and have been displaced by newly - added items. For example, here is a view that specifies such a transition: + This property holds the transition to apply to items within the view that are displaced by + the addition of other items to the view. + + For example, here is a view that specifies such a transition: \code ListView { @@ -2344,11 +2345,11 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::move - This property holds the transition to apply to items in the view that are moved by a move - operation. - The transition is applied to items that are moving within the view or are moving - into the view as a result of a move operation in the view's model. For example: + This property holds the transition to apply to items in the view that are being moved due + to a move operation in the view's \l model. + + For example, here is a view that specifies such a transition: \code ListView { @@ -2359,10 +2360,11 @@ void QQuickListView::setSnapMode(SnapMode mode) } \endcode - Whenever an item is moved within the above view, the item will be animated to its new position in - the view over one second. The transition only applies to the items that are the subject of the - move operation in the model; it does not apply to the items below them that are displaced by - the move operation. To animate the displaced items, set the \l moveDisplaced property. + Whenever the \l model performs a move operation to move a particular set of indexes, the + respective items in the view will be animated to their new positions in the view over one + second. The transition only applies to the items that are the subject of the move operation + in the model; it does not apply to items below them that are displaced by the move operation. + To animate the displaced items, set the \l moveDisplaced property. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2372,11 +2374,11 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::moveDisplaced - This property holds the transition to apply to items in the view that are displaced by a - move operation in the view. - The transition is applied to items that are currently visible and have been displaced following - a move operation in the view's model. For example, here is a view that specifies such a transition: + This property holds the transition to apply to items that are displaced by a move operation in + the view's \l model. + + For example, here is a view that specifies such a transition: \code ListView { @@ -2387,12 +2389,13 @@ void QQuickListView::setSnapMode(SnapMode mode) } \endcode - Whenever an item moves within (or moves into) the above view, all items beneath it are - displaced, causing them to move upwards (or sideways, if horizontally orientated) within the - view. As this displacement occurs, the items' movement to their new x,y positions within the - view will be animated by a NumberAnimation over one second, as specified. This transition is - not applied to the item that are actually the subject of the move operation; to animate the - moved items, set the \l move property. + Whenever the \l model performs a move operation to move a particular set of indexes, the items + between the source and destination indexes of the move operation are displaced, causing them + to move upwards or downwards (or sideways, if horizontally orientated) within the view. As this + displacement occurs, the items' movement to their new x,y positions within the view will be + animated by a NumberAnimation over one second, as specified. This transition is not applied to + the items that are the actual subjects of the move operation; to animate the moved items, set + the \l move property. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2402,10 +2405,10 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::remove + This property holds the transition to apply to items that are removed from the view. - The transition is applied to items that have been removed from the visible area of the view. For - example: + For example, here is a view that specifies such a transition: \code ListView { @@ -2422,7 +2425,7 @@ void QQuickListView::setSnapMode(SnapMode mode) Whenever an item is removed from the above view, the item will be animated to the position (100,100) over one second, and in parallel will also change its opacity to 0. The transition only applies to the items that are removed from the view; it does not apply to the items below - them that are displaced by the removal of the items. To animate the displaced items, set the \l + them that are displaced by the removal of the items. To animate the displaced items, set the \l removeDisplaced property. Note that by the time the transition is applied, the item has already been removed from the @@ -2439,11 +2442,11 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::removeDisplaced + This property holds the transition to apply to items in the view that are displaced by the removal of other items in the view. - The transition is applied to items that are currently visible and have been displaced by - the removal of items. For example, here is a view that specifies such a transition: + For example, here is a view that specifies such a transition: \code ListView { -- cgit v1.2.3 From 15dac112df4f44ba8b15047720e1570fd4096f26 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 23 Feb 2012 16:57:06 +1000 Subject: Don't create a separate section header for currentItem The currentItem FxViewItem contained it's own section item, which when created would cause the current item delegate to be repositioned. This change associates the section item with the delegate item, via the attached object. Change-Id: Ie675d545539b56d0f1cf5a9b4ea26668978a5e72 Reviewed-by: Bea Lam --- src/quick/items/qquicklistview.cpp | 112 ++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 52 deletions(-) (limited to 'src/quick/items/qquicklistview.cpp') diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 6324c7d2ff..0e643a13e3 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -93,7 +93,7 @@ public: virtual FxViewItem *newViewItem(int index, QQuickItem *item); virtual void initializeViewItem(FxViewItem *item); - virtual void releaseItem(FxViewItem *item); + virtual bool releaseItem(FxViewItem *item); virtual void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer); virtual void repositionPackageItemAt(QQuickItem *item, int index); virtual void resetFirstItemPosition(qreal pos = 0.0); @@ -236,7 +236,7 @@ void QQuickViewSection::setLabelPositioning(int l) class FxListItemSG : public FxViewItem { public: - FxListItemSG(QQuickItem *i, QQuickListView *v, bool own) : FxViewItem(i, own), section(0), view(v) { + FxListItemSG(QQuickItem *i, QQuickListView *v, bool own) : FxViewItem(i, own), view(v) { attached = static_cast(qmlAttachedPropertiesObject(item)); if (attached) static_cast(attached)->setView(view); @@ -244,12 +244,21 @@ public: ~FxListItemSG() {} + inline QQuickItem *section() const { + return attached ? static_cast(attached)->m_sectionItem : 0; + } + void setSection(QQuickItem *s) { + if (!attached) + attached = static_cast(qmlAttachedPropertiesObject(item)); + static_cast(attached)->m_sectionItem = s; + } + qreal position() const { - if (section) { + if (section()) { if (view->orientation() == QQuickListView::Vertical) - return section->y(); + return section()->y(); else - return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -section->width()-section->x() : section->x()); + return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -section()->width()-section()->x() : section()->x()); } else { return itemPosition(); } @@ -261,8 +270,8 @@ public: return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -item->width()-itemX() : itemX()); } qreal size() const { - if (section) - return (view->orientation() == QQuickListView::Vertical ? item->height()+section->height() : item->width()+section->width()); + if (section()) + return (view->orientation() == QQuickListView::Vertical ? item->height()+section()->height() : item->width()+section()->width()); else return (view->orientation() == QQuickListView::Vertical ? item->height() : item->width()); } @@ -270,8 +279,8 @@ public: return (view->orientation() == QQuickListView::Vertical ? item->height() : item->width()); } qreal sectionSize() const { - if (section) - return (view->orientation() == QQuickListView::Vertical ? section->height() : section->width()); + if (section()) + return (view->orientation() == QQuickListView::Vertical ? section()->height() : section()->width()); return 0.0; } qreal endPosition() const { @@ -285,14 +294,14 @@ public: } void setPosition(qreal pos) { // position the section immediately even if there is a transition - if (section) { + if (section()) { if (view->orientation() == QQuickListView::Vertical) { - section->setY(pos); + section()->setY(pos); } else { if (view->effectiveLayoutDirection() == Qt::RightToLeft) - section->setX(-section->width()-pos); + section()->setX(-section()->width()-pos); else - section->setX(pos); + section()->setX(pos); } } moveTo(pointForPosition(pos)); @@ -311,23 +320,22 @@ public: return view; } - QQuickItem *section; QQuickListView *view; private: QPointF pointForPosition(qreal pos) const { if (view->orientation() == QQuickListView::Vertical) { - if (section) - pos += section->height(); + if (section()) + pos += section()->height(); return QPointF(itemX(), pos); } else { if (view->effectiveLayoutDirection() == Qt::RightToLeft) { - if (section) - pos += section->width(); + if (section()) + pos += section()->width(); return QPointF(-item->width() - pos, itemY()); } else { - if (section) - pos += section->width(); + if (section()) + pos += section()->width(); return QPointF(pos, itemY()); } } @@ -566,25 +574,31 @@ void QQuickListViewPrivate::initializeViewItem(FxViewItem *item) } } -void QQuickListViewPrivate::releaseItem(FxViewItem *item) +bool QQuickListViewPrivate::releaseItem(FxViewItem *item) { - if (item) { - FxListItemSG* listItem = static_cast(item); - if (listItem->section) { - int i = 0; - do { - if (!sectionCache[i]) { - sectionCache[i] = listItem->section; - sectionCache[i]->setVisible(false); - listItem->section = 0; - break; - } - ++i; - } while (i < sectionCacheSize); - delete listItem->section; - } + if (!item || !model) + return true; + + QQuickListViewAttached *att = static_cast(item->attached); + + bool released = QQuickItemViewPrivate::releaseItem(item); + if (released && att && att->m_sectionItem) { + // We hold no more references to this item + int i = 0; + do { + if (!sectionCache[i]) { + sectionCache[i] = att->m_sectionItem; + sectionCache[i]->setVisible(false); + att->m_sectionItem = 0; + break; + } + ++i; + } while (i < sectionCacheSize); + delete att->m_sectionItem; + att->m_sectionItem = 0; } - QQuickItemViewPrivate::releaseItem(item); + + return released; } bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool doBuffer) @@ -944,18 +958,18 @@ void QQuickListViewPrivate::updateInlineSection(FxListItemSG *listItem) if (listItem->attached->m_prevSection != listItem->attached->m_section && (sectionCriteria->labelPositioning() & QQuickViewSection::InlineLabels || (listItem->index == 0 && sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart))) { - if (!listItem->section) { + if (!listItem->section()) { qreal pos = listItem->position(); - listItem->section = getSectionItem(listItem->attached->m_section); + listItem->setSection(getSectionItem(listItem->attached->m_section)); listItem->setPosition(pos); } else { - QDeclarativeContext *context = QDeclarativeEngine::contextForObject(listItem->section)->parentContext(); + QDeclarativeContext *context = QDeclarativeEngine::contextForObject(listItem->section())->parentContext(); context->setContextProperty(QLatin1String("section"), listItem->attached->m_section); } - } else if (listItem->section) { + } else if (listItem->section()) { qreal pos = listItem->position(); - releaseSectionItem(listItem->section); - listItem->section = 0; + releaseSectionItem(listItem->section()); + listItem->setSection(0); listItem->setPosition(pos); } } @@ -972,7 +986,7 @@ void QQuickListViewPrivate::updateStickySections() QQuickItem *lastSectionItem = 0; int index = 0; while (index < visibleItems.count()) { - if (QQuickItem *section = static_cast(visibleItems.at(index))->section) { + if (QQuickItem *section = static_cast(visibleItems.at(index))->section()) { // Find the current section header and last visible section header // and hide them if they will overlap a static section header. qreal sectionPos = orient == QQuickListView::Vertical ? section->y() : section->x(); @@ -1173,9 +1187,9 @@ void QQuickListViewPrivate::initializeCurrentItem() if (currentItem) { FxListItemSG *listItem = static_cast(currentItem); - // don't reposition the item if it's about to be transitioned to another position + // don't reposition the item if it is already in the visibleItems list FxViewItem *actualItem = visibleItem(currentIndex); - if ((!actualItem || !actualItem->transitionScheduledOrRunning())) { + if (!actualItem) { if (currentIndex == visibleIndex - 1 && visibleItems.count()) { // We can calculate exact postion in this case listItem->setPosition(visibleItems.first()->position() - currentItem->size() - spacing); @@ -1186,12 +1200,6 @@ void QQuickListViewPrivate::initializeCurrentItem() } } - // Avoid showing section delegate twice. We still need the section heading so that - // currentItem positioning works correctly. - // This is slightly sub-optimal, but section heading caching minimizes the impact. - if (listItem->section) - listItem->section->setVisible(false); - if (visibleItems.isEmpty()) averageSize = listItem->size(); } -- cgit v1.2.3 From 328c100ab3fc4d5ddccb0d19af9d7e87bd849f0b Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 21 Feb 2012 14:44:21 +1000 Subject: Separate view transition functionality into new file Move most of the view transition functionality from qquickitemview* into qquickitemviewtransition*. - Move QQuickViewTransitionAttached - Move QQuickItemViewTransitionManager, rename to QQuickItemViewTransitionJob - Move FxViewItem transition-specific features into new QQuickViewItem - Move transition-specific functions like transitionNextReposition() and canTransition() into QQuickItemViewTransitioner which holds all the transition objects now Also mention in docs that there's no defined order for choosing between multiple matching displaced transitions. Change-Id: I8701c0d40d2af152c5d432a4c8de646854c76ea2 Reviewed-by: Martin Jones --- src/quick/items/qquicklistview.cpp | 42 ++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'src/quick/items/qquicklistview.cpp') diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 0e643a13e3..2190952c69 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -316,9 +316,6 @@ public: return (x >= itemX() && x < itemX() + item->width() && y >= itemY() && y < itemY() + item->height()); } - QQuickItemView *itemView() const { - return view; - } QQuickListView *view; @@ -643,7 +640,7 @@ bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool d #endif if (!(item = static_cast(createItem(modelIndex, doBuffer)))) break; - if (!canTransition(FxViewItemTransitionManager::PopulateTransition, true)) // pos will be set by layoutVisibleItems() + if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems() item->setPosition(pos); item->item->setVisible(!doBuffer); pos += item->size() + spacing; @@ -663,7 +660,7 @@ bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool d break; --visibleIndex; visiblePos -= item->size() + spacing; - if (!canTransition(FxViewItemTransitionManager::PopulateTransition, true)) // pos will be set by layoutVisibleItems() + if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems() item->setPosition(visiblePos); item->item->setVisible(!doBuffer); visibleItems.prepend(item); @@ -2341,6 +2338,10 @@ void QQuickListView::setSnapMode(SnapMode mode) the new item that has been added to the view; to animate the added items, set the \l add property. + If an item is displaced by multiple types of operations at the same time, it is not + defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition + will be applied. + For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2405,6 +2406,10 @@ void QQuickListView::setSnapMode(SnapMode mode) the items that are the actual subjects of the move operation; to animate the moved items, set the \l move property. + If an item is displaced by multiple types of operations at the same time, it is not + defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition + will be applied. + For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2472,6 +2477,10 @@ void QQuickListView::setSnapMode(SnapMode mode) the item that has actually been removed from the view; to animate the removed items, set the \l remove property. + If an item is displaced by multiple types of operations at the same time, it is not + defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition + will be applied. + For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2740,7 +2749,8 @@ bool QQuickListViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In insertResult->changedFirstItem = true; if (!change.isMove()) { addedItems->append(item); - transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, true); + if (transitioner) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, true); } insertResult->sizeChangesBeforeVisiblePos += item->size() + spacing; pos -= item->size() + spacing; @@ -2766,11 +2776,12 @@ bool QQuickListViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In if (change.isMove()) { // we know this is a move target, since move displaced items that are // shuffled into view due to a move would be added in refill() - if (canTransition(FxViewItemTransitionManager::MoveTransition, true) && newItem) + if (newItem && transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true)) movingIntoView->append(MovedItem(item, change.moveKey(item->index))); } else { addedItems->append(item); - transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, true); + if (transitioner) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, true); } insertResult->sizeChangesAfterVisiblePos += item->size() + spacing; pos += item->size() + spacing; @@ -2782,10 +2793,12 @@ bool QQuickListViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In FxViewItem *item = visibleItems.at(index); if (item->index != -1) item->index += count; - if (change.isMove()) - transitionNextReposition(item, FxViewItemTransitionManager::MoveTransition, false); - else - transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, false); + if (transitioner) { + if (change.isMove()) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::MoveTransition, false); + else + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, false); + } } updateVisibleIndex(); @@ -2797,6 +2810,9 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex { Q_UNUSED(insertionResult); + if (!transitioner) + return; + int markerItemIndex = -1; for (int i=0; iindex == afterModelIndex) { @@ -2816,7 +2832,7 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex if (!listItem->transitionScheduledOrRunning()) { qreal pos = listItem->position(); listItem->setPosition(pos - sizeRemoved); - transitionNextReposition(listItem, FxViewItemTransitionManager::RemoveTransition, false); + transitioner->transitionNextReposition(listItem, QQuickItemViewTransitioner::RemoveTransition, false); listItem->setPosition(pos); } } -- cgit v1.2.3 From ba3ac328ca721712c56f28a1fc6ae8e64b6ad7f2 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 22 Feb 2012 17:23:47 +1000 Subject: Add generic "displaced" transition property This is the default displaced transition that will be applied if addDisplaced, removeDisplaced or moveDisplaced are not specified (or are disabled). Change-Id: I9356036dc93bd9cb26e64e0b1769228113b74273 Reviewed-by: Martin Jones --- src/quick/items/qquicklistview.cpp | 72 +++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 17 deletions(-) (limited to 'src/quick/items/qquicklistview.cpp') diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 2190952c69..876859eeb1 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -2301,8 +2301,8 @@ void QQuickListView::setSnapMode(SnapMode mode) Whenever an item is added to the above view, the item will be animated from the position (100,100) to its final x,y position within the view, over one second. The transition only applies to the new items that are added to the view; it does not apply to the items below that are - displaced by the addition of the new items. To animate the displaced items, set the \l - addDisplaced property. + displaced by the addition of the new items. To animate the displaced items, set the \l displaced + or \l addDisplaced properties. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2338,9 +2338,10 @@ void QQuickListView::setSnapMode(SnapMode mode) the new item that has been added to the view; to animate the added items, set the \l add property. - If an item is displaced by multiple types of operations at the same time, it is not - defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition - will be applied. + If an item is displaced by multiple types of operations at the same time, it is not defined as to + whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, + if it is not necessary to specify different transitions depending on whether an item is displaced + by an add, move or remove operation, consider setting the \l displaced property instead. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2349,7 +2350,7 @@ void QQuickListView::setSnapMode(SnapMode mode) populated, or when the view's \l model changes. In those cases, the \l populate transition is applied instead. - \sa add, populate, ViewTransition + \sa displaced, add, populate, ViewTransition */ /*! @@ -2373,7 +2374,7 @@ void QQuickListView::setSnapMode(SnapMode mode) respective items in the view will be animated to their new positions in the view over one second. The transition only applies to the items that are the subject of the move operation in the model; it does not apply to items below them that are displaced by the move operation. - To animate the displaced items, set the \l moveDisplaced property. + To animate the displaced items, set the \l displaced or \l moveDisplaced properties. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2406,14 +2407,15 @@ void QQuickListView::setSnapMode(SnapMode mode) the items that are the actual subjects of the move operation; to animate the moved items, set the \l move property. - If an item is displaced by multiple types of operations at the same time, it is not - defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition - will be applied. + If an item is displaced by multiple types of operations at the same time, it is not defined as to + whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, + if it is not necessary to specify different transitions depending on whether an item is displaced + by an add, move or remove operation, consider setting the \l displaced property instead. For more details and examples on how to use view transitions, see the ViewTransition documentation. - \sa move, ViewTransition + \sa displaced, move, ViewTransition */ /*! @@ -2438,8 +2440,8 @@ void QQuickListView::setSnapMode(SnapMode mode) Whenever an item is removed from the above view, the item will be animated to the position (100,100) over one second, and in parallel will also change its opacity to 0. The transition only applies to the items that are removed from the view; it does not apply to the items below - them that are displaced by the removal of the items. To animate the displaced items, set the \l - removeDisplaced property. + them that are displaced by the removal of the items. To animate the displaced items, set the + \l displaced or \l removeDisplaced properties. Note that by the time the transition is applied, the item has already been removed from the model; any references to the model data for the removed index will not be valid. @@ -2477,16 +2479,52 @@ void QQuickListView::setSnapMode(SnapMode mode) the item that has actually been removed from the view; to animate the removed items, set the \l remove property. - If an item is displaced by multiple types of operations at the same time, it is not - defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition - will be applied. + If an item is displaced by multiple types of operations at the same time, it is not defined as to + whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, + if it is not necessary to specify different transitions depending on whether an item is displaced + by an add, move or remove operation, consider setting the \l displaced property instead. For more details and examples on how to use view transitions, see the ViewTransition documentation. - \sa remove, ViewTransition + \sa displaced, remove, ViewTransition */ +/*! + \qmlproperty Transition QtQuick2::ListView::displaced + This property holds the generic transition to apply to items that have been displaced by + any model operation that affects the view. + + This is a convenience for specifying the generic transition to be applied to any items + that are displaced by an add, move or remove operation, without having to specify the + individual addDisplaced, moveDisplaced and removeDisplaced properties. For example, here + is a view that specifies a displaced transition: + + \code + ListView { + ... + displaced: Transition { + NumberAnimation { properties: "x,y"; duration: 1000 } + } + } + \endcode + + When any item is added, moved or removed within the above view, the items below it are + displaced, causing them to move down (or sideways, if horizontally orientated) within the + view. As this displacement occurs, the items' movement to their new x,y positions within + the view will be animated by a NumberAnimation over one second, as specified. + + If a view specifies this generic displaced transition as well as a specific addDisplaced, + moveDisplaced or removeDisplaced transition, the more specific transition will be used + instead of the generic displaced transition when the relevant operation occurs, providing that + the more specific transition has not been disabled (by setting \l {Transition::enabled}{enabled} + to false). If it has indeed been disabled, the generic displaced transition is applied instead. + + For more details and examples on how to use view transitions, see the ViewTransition + documentation. + + \sa addDisplaced, moveDisplaced, removeDisplaced, ViewTransition +*/ void QQuickListView::viewportMoved() { -- cgit v1.2.3