diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-02-23 04:05:06 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-02-23 06:33:26 (GMT) |
commit | d9d68c383b7b1438d3034cd3708cfba5fb9706ef (patch) | |
tree | 0b42a5a01b81304d770cbc16c4069a05b6430f8c /src/declarative | |
parent | f93d1245e5c36cf25cd6fd3c3418ee7e63e04ac2 (diff) | |
download | Qt-d9d68c383b7b1438d3034cd3708cfba5fb9706ef.zip Qt-d9d68c383b7b1438d3034cd3708cfba5fb9706ef.tar.gz Qt-d9d68c383b7b1438d3034cd3708cfba5fb9706ef.tar.bz2 |
DelayRemove of list delegate on section boundary duplicated section
When removing a delegate with a removal animation that fell on a
section boundary (i.e. owned the section header), the following
item would also create a section header before the previous item was
removed. Make updateSections() include the removed, but visible items
in its update. Ensure updateSections() is called when the removed
item is destroyed to ensure a new section header is created at that
point.
Change-Id: Ie831e3acf65b2989ebb030e2ab38cdbe179a9d45
Task-number: QTBUG-17606
Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 91de5a6..338cb58 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -228,6 +228,26 @@ public: return 0; } + // Returns the item before modelIndex, if created. + // May return an item marked for removal. + FxListItem *itemBefore(int modelIndex) const { + if (modelIndex < visibleIndex) + return 0; + int idx = 1; + int lastIndex = -1; + while (idx < visibleItems.count()) { + FxListItem *item = visibleItems.at(idx); + if (item->index != -1) + lastIndex = item->index; + if (item->index == modelIndex) + return visibleItems.at(idx-1); + ++idx; + } + if (lastIndex == modelIndex-1) + return visibleItems.last(); + return 0; + } + qreal position() const { Q_Q(const QDeclarativeListView); return orient == QDeclarativeListView::Vertical ? q->contentY() : q->contentX(); @@ -561,7 +581,7 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex) QString propValue = model->stringValue(modelIndex, sectionCriteria->property()); listItem->attached->m_section = sectionCriteria->sectionString(propValue); if (modelIndex > 0) { - if (FxListItem *item = visibleItem(modelIndex-1)) + if (FxListItem *item = itemBefore(modelIndex)) listItem->attached->m_prevSection = item->attached->section(); else listItem->attached->m_prevSection = sectionAt(modelIndex-1); @@ -969,18 +989,18 @@ void QDeclarativeListViewPrivate::updateSections() QDeclarativeListViewAttached *prevAtt = 0; int idx = -1; for (int i = 0; i < visibleItems.count(); ++i) { + QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached; + attached->setPrevSection(prevSection); if (visibleItems.at(i)->index != -1) { - QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached; - attached->setPrevSection(prevSection); QString propValue = model->stringValue(visibleItems.at(i)->index, sectionCriteria->property()); attached->setSection(sectionCriteria->sectionString(propValue)); - if (prevAtt) - prevAtt->setNextSection(attached->section()); - createSection(visibleItems.at(i)); - prevSection = attached->section(); - prevAtt = attached; idx = visibleItems.at(i)->index; } + createSection(visibleItems.at(i)); + if (prevAtt) + prevAtt->setNextSection(attached->section()); + prevSection = attached->section(); + prevAtt = attached; } if (prevAtt) { if (idx > 0 && idx < model->count()-1) @@ -3096,6 +3116,7 @@ void QDeclarativeListView::destroyRemoved() } // Correct the positioning of the items + d->updateSections(); d->layout(); } |