diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-02-23 16:10:57 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-02-23 16:10:57 (GMT) |
commit | 373d8a06c21fb3d237d1f2c7be604e1bcf7e42fa (patch) | |
tree | 468443eb03537624ed2ca56bdf07026da49745ad /src/declarative | |
parent | 5a2f7b97d564e4b8a9619cd7aa1519b4dd084ae8 (diff) | |
parent | bf2f68704ca62fa5ac21c0559dc896f02cf4775d (diff) | |
download | Qt-373d8a06c21fb3d237d1f2c7be604e1bcf7e42fa.zip Qt-373d8a06c21fb3d237d1f2c7be604e1bcf7e42fa.tar.gz Qt-373d8a06c21fb3d237d1f2c7be604e1bcf7e42fa.tar.bz2 |
Merge branch 4.7 into qt-master-from-4.7
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(); } |