aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-03-28 09:17:02 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-28 03:10:14 +0200
commit4f08f48017bf4fe17b23bd5d7399bce4bd37d806 (patch)
treeb3b2b9f5118da8a0612808f128fe5f33be62ab0c
parent7d1996c1f44c75159b7dc3040dd458ba533cc665 (diff)
Section comparison should be case insensitive.
Allows use of mixed case model data without having to add a special role just for sectioning. Change-Id: I0a747e51542b5bf0f9db8fc2732882928a6cc676 Reviewed-by: Bea Lam <bea.lam@nokia.com>
-rw-r--r--src/quick/items/qquicklistview.cpp11
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp10
2 files changed, 12 insertions, 9 deletions
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 6f33545185..1cc2637fe6 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -577,7 +577,7 @@ void QQuickListViewPrivate::initializeViewItem(FxViewItem *item)
itemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry);
if (sectionCriteria && sectionCriteria->delegate()) {
- if (item->attached->m_prevSection != item->attached->m_section)
+ if (QString::compare(item->attached->m_prevSection, item->attached->m_section, Qt::CaseInsensitive))
updateInlineSection(static_cast<FxListItemSG*>(item));
}
}
@@ -962,7 +962,7 @@ void QQuickListViewPrivate::updateInlineSection(FxListItemSG *listItem)
{
if (!sectionCriteria || !sectionCriteria->delegate())
return;
- if (listItem->attached->m_prevSection != listItem->attached->m_section
+ if (QString::compare(listItem->attached->m_prevSection, listItem->attached->m_section, Qt::CaseInsensitive)
&& (sectionCriteria->labelPositioning() & QQuickViewSection::InlineLabels
|| (listItem->index == 0 && sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart))) {
if (!listItem->section()) {
@@ -1022,7 +1022,7 @@ void QQuickListViewPrivate::updateStickySections()
if (sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart && isValid() && visibleItems.count()) {
if (!currentSectionItem) {
currentSectionItem = getSectionItem(currentSection);
- } else if (currentStickySection != currentSection) {
+ } else if (QString::compare(currentStickySection, currentSection, Qt::CaseInsensitive)) {
QQmlContext *context = QQmlEngine::contextForObject(currentSectionItem)->parentContext();
context->setContextProperty(QLatin1String("section"), currentSection);
}
@@ -1055,7 +1055,7 @@ void QQuickListViewPrivate::updateStickySections()
if (sectionCriteria->labelPositioning() & QQuickViewSection::NextLabelAtEnd && isValid() && visibleItems.count()) {
if (!nextSectionItem) {
nextSectionItem = getSectionItem(nextSection);
- } else if (nextStickySection != nextSection) {
+ } else if (QString::compare(nextStickySection, nextSection, Qt::CaseInsensitive)) {
QQmlContext *context = QQmlEngine::contextForObject(nextSectionItem)->parentContext();
context->setContextProperty(QLatin1String("section"), nextSection);
}
@@ -2040,6 +2040,9 @@ void QQuickListView::setOrientation(QQuickListView::Orientation orientation)
sections, etc. for an address book)
\endlist
+ A case insensitive comparison is used when determining section
+ boundaries.
+
\c section.delegate holds the delegate component for each section.
\c section.labelPositioning determines whether the current and/or
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 1218d3cfcb..1ef895d111 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -2120,13 +2120,13 @@ void tst_QQuickListView::sectionsPositioning()
QVERIFY(bottomItem);
QCOMPARE(bottomItem->y(), 380.);
- // Change current section
+ // Change current section, and verify case insensitive comparison
listview->setContentY(10);
model.modifyItem(0, "One", "aaa");
- model.modifyItem(1, "Two", "aaa");
- model.modifyItem(2, "Three", "aaa");
- model.modifyItem(3, "Four", "aaa");
- model.modifyItem(4, "Five", "aaa");
+ model.modifyItem(1, "Two", "AAA");
+ model.modifyItem(2, "Three", "aAa");
+ model.modifyItem(3, "Four", "aaA");
+ model.modifyItem(4, "Five", "Aaa");
QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
QTRY_COMPARE(listview->currentSection(), QString("aaa"));