on xenial help sign in
Fix some culling to make it more accurate
8d8d033Albert Astals
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+5−2
@@ -701,7 +701,7 @@ void ListViewWithPageHeader::updatePolish()
701 return;
701 return;
702
702
703 if (!m_visibleItems.isEmpty()) {
703 if (!m_visibleItems.isEmpty()) {
704− const qreal visibleFrom = contentY() - m_clipItem->y();
704+ const qreal visibleFrom = contentY() - m_clipItem->y() + m_headerItemShownHeight;
705 const qreal visibleTo = contentY() + height() - m_clipItem->y();
705 const qreal visibleTo = contentY() + height() - m_clipItem->y();
706
706
707 qreal pos = m_visibleItems.first()->y();
707 qreal pos = m_visibleItems.first()->y();
@@ -720,7 +720,6 @@ void ListViewWithPageHeader::updatePolish()
720 const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
720 const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
721 QQmlContext *context = QQmlEngine::contextForObject(m_topSectionItem)->parentContext();
721 QQmlContext *context = QQmlEngine::contextForObject(m_topSectionItem)->parentContext();
722 context->setContextProperty(QLatin1String("section"), section);
722 context->setContextProperty(QLatin1String("section"), section);
723−
724
723
725 // Positing the top section sticky item is a two step process
724 // Positing the top section sticky item is a two step process
726 // First we set it either we cull it (because it doesn't need to be sticked to the top)
725 // First we set it either we cull it (because it doesn't need to be sticked to the top)
@@ -730,9 +729,13 @@ void ListViewWithPageHeader::updatePolish()
730 const qreal topSectionStickPos = m_headerItemShownHeight + contentY() - m_clipItem->y();
729 const qreal topSectionStickPos = m_headerItemShownHeight + contentY() - m_clipItem->y();
731 if (topSectionStickPos <= pos) {
730 if (topSectionStickPos <= pos) {
732 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
731 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
732+ QQuickItemPrivate::get(item->m_sectionItem)->setCulled(false);
733 } else {
733 } else {
734 QQuickItemPrivate::get(m_topSectionItem)->setCulled(false);
734 QQuickItemPrivate::get(m_topSectionItem)->setCulled(false);
735 m_topSectionItem->setY(topSectionStickPos);
735 m_topSectionItem->setY(topSectionStickPos);
736+ if (item->m_sectionItem) {
737+ QQuickItemPrivate::get(item->m_sectionItem)->setCulled(true);
738+ }
736 }
739 }
737 }
740 }
738 }
741 }
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+1−4
@@ -1226,10 +1226,7 @@ private Q_SLOTS:
1226 verifyItem(0, -308., 75., true);
1226 verifyItem(0, -308., 75., true);
1227 verifyItem(1, -233., 75., true);
1227 verifyItem(1, -233., 75., true);
1228 verifyItem(2, -158., 75., true);
1228 verifyItem(2, -158., 75., true);
1229− // TODO This is not visible culled should be true, but at the moment
1230− // we do not cull taking the clip/m_headerItemShownHeight into account
1231− // not a big thing but may be nice to fix in the future
1232− verifyItem(3, -83., 75., false);
1229+ verifyItem(3, -83., 75., true);
1233 verifyItem(4, -8., 75., false);
1230 verifyItem(4, -8., 75., false);
1234 verifyItem(5, 67., 75., false);
1231 verifyItem(5, 67., 75., false);
1235 verifyItem(6, 142., 75., false);
1232 verifyItem(6, 142., 75., false);