@@ -141,8 +141,6 @@ void ListViewWithPageHeader::ListItem::setCulled(bool culled)
141void ListViewWithPageHeader::ListItem::setSectionItem(QQuickItem *sectionItem)
141void ListViewWithPageHeader::ListItem::setSectionItem(QQuickItem *sectionItem)
143 m_sectionItem = sectionItem;
143 m_sectionItem = sectionItem;
144− QQmlContext *context = QQmlEngine::contextForObject(m_item)->parentContext();
145− context->setContextProperty(QLatin1String("hasSectionHeader"), QVariant::fromValue<bool>(sectionItem != nullptr));
148ListViewWithPageHeader::ListViewWithPageHeader()
146ListViewWithPageHeader::ListViewWithPageHeader()
@@ -685,8 +683,6 @@ QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, bool alreadyI
685 return nullptr;
683 return nullptr;
687 const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
685 const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
688− if (section.isEmpty())
691 if (modelIndex > 0) {
687 if (modelIndex > 0) {
692 const QString prevSection = m_delegateModel->stringValue(modelIndex - 1, m_sectionProperty);
688 const QString prevSection = m_delegateModel->stringValue(modelIndex - 1, m_sectionProperty);
@@ -877,7 +873,6 @@ void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
877 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
873 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
878 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
874 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
879 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
875 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
880− context->setContextProperty(QLatin1String("hasSectionHeader"), QVariant::fromValue<bool>(false));
881 if (modelIndex == m_asyncRequestedIndex) {
876 if (modelIndex == m_asyncRequestedIndex) {
882 createItem(modelIndex, false);
877 createItem(modelIndex, false);
883 refill();
878 refill();
@@ -931,17 +926,12 @@ void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool
931 const int visibleIndex = remove.index + i - m_firstVisibleIndex;
926 const int visibleIndex = remove.index + i - m_firstVisibleIndex;
932 if (visibleIndex >= 0 && visibleIndex < m_visibleItems.count()) {
927 if (visibleIndex >= 0 && visibleIndex < m_visibleItems.count()) {
933 ListItem *item = m_visibleItems[visibleIndex];
928 ListItem *item = m_visibleItems[visibleIndex];
934− // Pass the section item down if needed i.e. has no sectionItem because
929+ // Pass the section item down if needed
935− // had same section string (and not because it has no section at all)
936 if (item->sectionItem() && visibleIndex + 1 < m_visibleItems.count()) {
930 if (item->sectionItem() && visibleIndex + 1 < m_visibleItems.count()) {
937 ListItem *nextItem = m_visibleItems[visibleIndex + 1];
931 ListItem *nextItem = m_visibleItems[visibleIndex + 1];
938 if (!nextItem->sectionItem()) {
932 if (!nextItem->sectionItem()) {
939− const int modelIndex = remove.index + i;
940− const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
941− if (!section.isEmpty()) {
942− nextItem->setSectionItem(item->sectionItem());
933+ nextItem->setSectionItem(item->sectionItem());
943− item->setSectionItem(nullptr);
934+ item->setSectionItem(nullptr);
947 releaseItem(item);
937 releaseItem(item);
@@ -1189,17 +1179,12 @@ void ListViewWithPageHeader::layout()
1189 // viewport is bigger than the start of the position of the first visible item
1179 // viewport is bigger than the start of the position of the first visible item
1190 // i.e. the first visible item starts before the viewport, or when the first
1180 // i.e. the first visible item starts before the viewport, or when the first
1191 // visible item starts just at the viewport start and it does not have its own section item
1181 // visible item starts just at the viewport start and it does not have its own section item
1192− const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
1182+ if (topSectionStickPos > pos) {
1193− if (section.isEmpty()) {
1183+ showStickySectionItem = true;
1194− showStickySectionItem = false;
1184+ } else if (topSectionStickPos == pos) {
1185+ showStickySectionItem = !item->sectionItem();
1195 } else {
1186 } else {
1196− if (topSectionStickPos > pos) {
1197− showStickySectionItem = true;
1198− } else if (topSectionStickPos == pos) {
1199− showStickySectionItem = !item->sectionItem();
1201− showStickySectionItem = false;
1187+ showStickySectionItem = false;
1204 if (!showStickySectionItem) {
1189 if (!showStickySectionItem) {
1205 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
1190 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
@@ -1212,6 +1197,7 @@ void ListViewWithPageHeader::layout()
1213 } else {
1198 } else {
1214 // Update the top sticky section header
1199 // Update the top sticky section header
1200+ const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
1215 QQmlContext *context = QQmlEngine::contextForObject(m_topSectionItem)->parentContext();
1201 QQmlContext *context = QQmlEngine::contextForObject(m_topSectionItem)->parentContext();
1216 context->setContextProperty(QLatin1String("section"), section);
1202 context->setContextProperty(QLatin1String("section"), section);
@@ -1255,18 +1241,6 @@ void ListViewWithPageHeader::layout()
1255 m_topSectionItem->setY(item->y() - m_topSectionItem->height());
1241 m_topSectionItem->setY(item->y() - m_topSectionItem->height());
1259− // Is there no header because it's same section name or because has no section?
1260− // Because it is because we have no section (header) we still have to push it up
1261− const QString section = m_delegateModel->stringValue(firstReallyVisibleItem + 1, m_sectionProperty);
1262− if (section.isEmpty()) {
1263− if (m_topSectionItem->y() + m_topSectionItem->height() > item->y()) {
1264− m_topSectionItem->setY(item->y() - m_topSectionItem->height());
1265− QQmlContext *context = QQmlEngine::contextForObject(item->m_item)->parentContext();
1266− context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));