From: Martin Jones Date: Tue, 27 Mar 2012 23:17:02 +0000 (+1000) Subject: Section comparison should be case insensitive. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=4f08f48017bf4fe17b23bd5d7399bce4bd37d806;p=konrad%2Fqtdeclarative.git 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 --- diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 6f33545..1cc2637 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(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 1218d3c..1ef895d 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"));