aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicklistview.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-06-29 11:57:02 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-04 03:02:49 +0200
commitbaee77ef475056e045e2fa41f448a2703e2def07 (patch)
tree5ec91f0ed4d389ea1af0ef437a7fc3c7976fdc83 /src/quick/items/qquicklistview.cpp
parent9bf96613c1be7d4df7132a9c3c9ac1a8740f698f (diff)
Section headers ignore list delegate size changes when "colliding"
Make section header updates part of the layout process. Task-number: QTBUG-23298 Change-Id: I4586bc58bc195fcc47f6db79346727eb6e3d3845 Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'src/quick/items/qquicklistview.cpp')
-rw-r--r--src/quick/items/qquicklistview.cpp48
1 files changed, 22 insertions, 26 deletions
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index f12da439b5..80b4cb59df 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -110,6 +110,7 @@ public:
virtual bool applyInsertionChange(const QQuickChangeSet::Insert &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView);
virtual void translateAndTransitionItemsAfter(int afterIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult);
+ virtual void updateSectionCriteria();
virtual void updateSections();
QQuickItem *getSectionItem(const QString &section);
void releaseSectionItem(QQuickItem *item);
@@ -194,7 +195,8 @@ void QQuickViewSection::setProperty(const QString &property)
if (property != m_property) {
m_property = property;
emit propertyChanged();
- m_view->updateSections();
+ // notify view that the contents of the sections must be recalculated
+ m_view->updateSectionCriteria();
}
}
@@ -203,7 +205,8 @@ void QQuickViewSection::setCriteria(QQuickViewSection::SectionCriteria criteria)
if (criteria != m_criteria) {
m_criteria = criteria;
emit criteriaChanged();
- m_view->updateSections();
+ // notify view that the contents of the sections must be recalculated
+ m_view->updateSectionCriteria();
}
}
@@ -214,7 +217,7 @@ void QQuickViewSection::setDelegate(QQmlComponent *delegate)
m_view->releaseSectionItems();
m_delegate = delegate;
emit delegateChanged();
- m_view->updateSections();
+ m_view->forceLayoutPolish();
}
}
@@ -231,7 +234,7 @@ void QQuickViewSection::setLabelPositioning(int l)
if (m_labelPositioning != l) {
m_labelPositioning = l;
emit labelPositioningChanged();
- m_view->updateSections();
+ m_view->forceLayoutPolish();
}
}
@@ -805,6 +808,9 @@ void QQuickListViewPrivate::layoutVisibleItems(int fromModelIndex)
// move current item if it is not a visible item.
if (currentIndex >= 0 && currentItem && !fixedCurrent)
static_cast<FxListItemSG*>(currentItem)->setPosition(positionAt(currentIndex));
+
+ updateCurrentSection();
+ updateStickySections();
}
}
@@ -1163,10 +1169,6 @@ void QQuickListViewPrivate::updateSections()
}
lastVisibleSection = QString();
- updateCurrentSection();
- updateStickySections();
- forceLayout = true;
- q->polish();
}
void QQuickListViewPrivate::updateCurrentSection()
@@ -1378,8 +1380,7 @@ void QQuickListViewPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &
listItem->setPosition(listItem->position() + diff, true);
}
}
- forceLayout = true;
- q->polish();
+ forceLayoutPolish();
}
}
}
@@ -1993,8 +1994,7 @@ void QQuickListView::setSpacing(qreal spacing)
Q_D(QQuickListView);
if (spacing != d->spacing) {
d->spacing = spacing;
- d->forceLayout = true;
- polish();
+ d->forceLayoutPolish();
emit spacingChanged();
}
}
@@ -2199,10 +2199,8 @@ void QQuickListView::setOrientation(QQuickListView::Orientation orientation)
QQuickViewSection *QQuickListView::sectionCriteria()
{
Q_D(QQuickListView);
- if (!d->sectionCriteria) {
+ if (!d->sectionCriteria)
d->sectionCriteria = new QQuickViewSection(this);
- connect(d->sectionCriteria, SIGNAL(propertyChanged()), this, SLOT(updateSections()));
- }
return d->sectionCriteria;
}
@@ -2853,19 +2851,17 @@ void QQuickListView::decrementCurrentIndex()
}
}
-void QQuickListView::updateSections()
+void QQuickListViewPrivate::updateSectionCriteria()
{
- Q_D(QQuickListView);
- if (isComponentComplete() && d->model) {
+ Q_Q(QQuickListView);
+ if (q->isComponentComplete() && model) {
QList<QByteArray> roles;
- if (d->sectionCriteria && !d->sectionCriteria->property().isEmpty())
- roles << d->sectionCriteria->property().toUtf8();
- d->model->setWatchedRoles(roles);
- d->updateSections();
- if (d->itemCount) {
- d->forceLayout = true;
- polish();
- }
+ if (sectionCriteria && !sectionCriteria->property().isEmpty())
+ roles << sectionCriteria->property().toUtf8();
+ model->setWatchedRoles(roles);
+ updateSections();
+ if (itemCount)
+ forceLayoutPolish();
}
}