@@ -104,8 +104,6 @@
104#pragma GCC diagnostic pop
104#pragma GCC diagnostic pop
105// #include <private/qquickrectangle_p.h>
105// #include <private/qquickrectangle_p.h>
107−static const qreal bufferRatio = 0.5;
109qreal ListViewWithPageHeader::ListItem::height() const
107qreal ListViewWithPageHeader::ListItem::height() const
111 return m_item->height() + (m_sectionItem ? m_sectionItem->height() : 0);
109 return m_item->height() + (m_sectionItem ? m_sectionItem->height() : 0);
@@ -158,6 +156,7 @@ ListViewWithPageHeader::ListViewWithPageHeader()
158 , m_forceNoClip(false)
156 , m_forceNoClip(false)
159 , m_inLayout(false)
157 , m_inLayout(false)
160 , m_inContentHeightKeepHeaderShown(false)
158 , m_inContentHeightKeepHeaderShown(false)
162 m_clipItem = new QQuickItem(contentItem());
161 m_clipItem = new QQuickItem(contentItem());
163// m_clipItem = new QQuickRectangle(contentItem());
162// m_clipItem = new QQuickRectangle(contentItem());
@@ -335,6 +334,20 @@ qreal ListViewWithPageHeader::headerItemShownHeight() const
335 return m_headerItemShownHeight;
334 return m_headerItemShownHeight;
337+qreal ListViewWithPageHeader::cacheBuffer() const
339+ return m_cacheBuffer;
342+void ListViewWithPageHeader::setCacheBuffer(qreal cacheBuffer)
344+ if (cacheBuffer != m_cacheBuffer) {
345+ m_cacheBuffer = cacheBuffer;
346+ Q_EMIT cacheBufferChanged();
338void ListViewWithPageHeader::positionAtBeginning()
351void ListViewWithPageHeader::positionAtBeginning()
340 if (m_delegateModel->count() <= 0)
353 if (m_delegateModel->count() <= 0)
@@ -356,8 +369,7 @@ void ListViewWithPageHeader::positionAtBeginning()
356 // Create the subsequent items
369 // Create the subsequent items
357 int modelIndex = 1;
370 int modelIndex = 1;
358 qreal pos = item->y() + item->height();
371 qreal pos = item->y() + item->height();
359− const qreal buffer = height() * bufferRatio;
360− const qreal bufferTo = height() + buffer;
372+ const qreal bufferTo = height() + m_cacheBuffer;
361 while (modelIndex < m_delegateModel->count() && pos <= bufferTo) {
373 while (modelIndex < m_delegateModel->count() && pos <= bufferTo) {
362 if (!(item = createItem(modelIndex, false)))
374 if (!(item = createItem(modelIndex, false)))
@@ -593,11 +605,11 @@ void ListViewWithPageHeader::refill()
596− const qreal buffer = height() * bufferRatio;
597 const qreal from = contentY();
608 const qreal from = contentY();
598 const qreal to = from + height();
609 const qreal to = from + height();
599− const qreal bufferFrom = from - buffer;
610+ const qreal bufferFrom = from - m_cacheBuffer;
600− const qreal bufferTo = to + buffer;
611+ const qreal bufferTo = to + m_cacheBuffer;
612+// qDebug() << from << to << bufferFrom << bufferTo << m_cacheBuffer;
602 bool added = addVisibleItems(from, to, false);
614 bool added = addVisibleItems(from, to, false);
603 bool removed = removeNonVisibleItems(bufferFrom, bufferTo);
615 bool removed = removeNonVisibleItems(bufferFrom, bufferTo);