fix: lazy list view spacing + debounce relayout
This commit is contained in:
parent
20983ffa6e
commit
ea776c20e0
2 changed files with 14 additions and 5 deletions
|
|
@ -422,13 +422,15 @@ void LazyListView::relayout() {
|
|||
qreal y = 0;
|
||||
bool hasLayoutItem = false;
|
||||
for (auto& record : m_layout) {
|
||||
record.targetY = y;
|
||||
const qreal layoutH = record.heightKnown ? record.height : effectiveEstimatedHeight();
|
||||
if (layoutH > 0) {
|
||||
if (hasLayoutItem)
|
||||
y += m_spacing;
|
||||
hasLayoutItem = true;
|
||||
record.targetY = y;
|
||||
y += layoutH;
|
||||
} else {
|
||||
record.targetY = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -653,10 +655,16 @@ LazyListView::DelegateEntry LazyListView::createDelegate(int modelIndex) {
|
|||
if (wasKnown)
|
||||
untrackHeight(oldH);
|
||||
trackHeight(h);
|
||||
// Relayout immediately so layoutHeight/contentHeight update
|
||||
// synchronously for parent bindings, then polish for delegate sync.
|
||||
relayout();
|
||||
polish();
|
||||
// Batch relayout: multiple height changes in the same event loop
|
||||
// iteration are coalesced into a single relayout + polish.
|
||||
if (!m_relayoutPending) {
|
||||
m_relayoutPending = true;
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
m_relayoutPending = false;
|
||||
relayout();
|
||||
polish();
|
||||
});
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ private:
|
|||
|
||||
int m_activeAnimations = 0;
|
||||
bool m_componentComplete = false;
|
||||
bool m_relayoutPending = false;
|
||||
QSet<int> m_pendingAddAnimations;
|
||||
|
||||
QList<QMetaObject::Connection> m_modelConnections;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue