@@ -141,8 +141,6 @@ void ListViewWithPageHeader::ListItem::setCulled(bool culled)
141141void ListViewWithPageHeader::ListItem::setSectionItem(QQuickItem *sectionItem)
142142{
143143 m_sectionItem = sectionItem;
144− QQmlContext *context = QQmlEngine::contextForObject(m_item)->parentContext();
145− context->setContextProperty(QLatin1String("hasSectionHeader"), QVariant::fromValue<bool>(sectionItem != nullptr));
146144}
147145
148146ListViewWithPageHeader::ListViewWithPageHeader()
@@ -685,8 +683,6 @@ QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, bool alreadyI
685683 return nullptr;
686684
687685 const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
688− if (section.isEmpty())
689− return nullptr;
690686
691687 if (modelIndex > 0) {
692688 const QString prevSection = m_delegateModel->stringValue(modelIndex - 1, m_sectionProperty);
@@ -877,7 +873,6 @@ void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
877873 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
878874 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
879875 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
880− context->setContextProperty(QLatin1String("hasSectionHeader"), QVariant::fromValue<bool>(false));
881876 if (modelIndex == m_asyncRequestedIndex) {
882877 createItem(modelIndex, false);
883878 refill();
@@ -931,17 +926,12 @@ void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool
931926 const int visibleIndex = remove.index + i - m_firstVisibleIndex;
932927 if (visibleIndex >= 0 && visibleIndex < m_visibleItems.count()) {
933928 ListItem *item = m_visibleItems[visibleIndex];
934− // Pass the section item down if needed i.e. has no sectionItem because
935− // had same section string (and not because it has no section at all)
929+ // Pass the section item down if needed
936930 if (item->sectionItem() && visibleIndex + 1 < m_visibleItems.count()) {
937931 ListItem *nextItem = m_visibleItems[visibleIndex + 1];
938932 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());
943− item->setSectionItem(nullptr);
944− }
933+ nextItem->setSectionItem(item->sectionItem());
934+ item->setSectionItem(nullptr);
945935 }
946936 }
947937 releaseItem(item);
@@ -1189,17 +1179,12 @@ void ListViewWithPageHeader::layout()
11891179 // viewport is bigger than the start of the position of the first visible item
11901180 // i.e. the first visible item starts before the viewport, or when the first
11911181 // 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);
1193− if (section.isEmpty()) {
1194− showStickySectionItem = false;
1182+ if (topSectionStickPos > pos) {
1183+ showStickySectionItem = true;
1184+ } else if (topSectionStickPos == pos) {
1185+ showStickySectionItem = !item->sectionItem();
11951186 } else {
1196− if (topSectionStickPos > pos) {
1197− showStickySectionItem = true;
1198− } else if (topSectionStickPos == pos) {
1199− showStickySectionItem = !item->sectionItem();
1200− } else {
1201− showStickySectionItem = false;
1202− }
1187+ showStickySectionItem = false;
12031188 }
12041189 if (!showStickySectionItem) {
12051190 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
@@ -1212,6 +1197,7 @@ void ListViewWithPageHeader::layout()
12121197 }
12131198 } else {
12141199 // Update the top sticky section header
1200+ const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
12151201 QQmlContext *context = QQmlEngine::contextForObject(m_topSectionItem)->parentContext();
12161202 context->setContextProperty(QLatin1String("section"), section);
12171203
@@ -1255,18 +1241,6 @@ void ListViewWithPageHeader::layout()
12551241 m_topSectionItem->setY(item->y() - m_topSectionItem->height());
12561242 }
12571243 break;
1258− } else {
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));
1267− }
1268− break;
1269− }
12701244 }
12711245 }
12721246 }