chore: format

This commit is contained in:
2 * r + 2 * t 2026-04-03 16:09:00 +11:00
parent 916b702562
commit faaae7be44

View file

@ -213,8 +213,7 @@ qreal LazyListView::delegateHeight(QQuickItem* item) {
if (!item) if (!item)
return 0; return 0;
auto* attached = qobject_cast<LazyListViewAttached*>( auto* attached = qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(item, false));
qmlAttachedPropertiesObject<LazyListView>(item, false));
if (attached && attached->preferredHeight() >= 0) if (attached && attached->preferredHeight() >= 0)
return attached->preferredHeight(); return attached->preferredHeight();
@ -225,8 +224,7 @@ qreal LazyListView::delegateVisibleHeight(QQuickItem* item) {
if (!item) if (!item)
return 0; return 0;
auto* attached = qobject_cast<LazyListViewAttached*>( auto* attached = qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(item, false));
qmlAttachedPropertiesObject<LazyListView>(item, false));
if (attached) { if (attached) {
if (attached->visibleHeight() >= 0) if (attached->visibleHeight() >= 0)
return attached->visibleHeight(); return attached->visibleHeight();
@ -435,7 +433,7 @@ void LazyListView::relayout() {
qreal maxBottom = m_layout.isEmpty() ? 0 : visY - m_spacing; qreal maxBottom = m_layout.isEmpty() ? 0 : visY - m_spacing;
// Account for dying delegates still visually present // Account for dying delegates still visually present
for (const auto& dying : m_dyingDelegates) { for (const auto& dying : std::as_const(m_dyingDelegates)) {
if (dying.item) if (dying.item)
maxBottom = std::max(maxBottom, dying.item->y() + delegateVisibleHeight(dying.item)); maxBottom = std::max(maxBottom, dying.item->y() + delegateVisibleHeight(dying.item));
} }
@ -600,8 +598,8 @@ LazyListView::DelegateEntry LazyListView::createDelegate(int modelIndex) {
// Set adding = true before completeCreate so bindings see it during initial evaluation. // Set adding = true before completeCreate so bindings see it during initial evaluation.
// Cleared after creation so the transition from true→false triggers QML Behaviors. // Cleared after creation so the transition from true→false triggers QML Behaviors.
auto* addingAttached = qobject_cast<LazyListViewAttached*>( auto* addingAttached =
qmlAttachedPropertiesObject<LazyListView>(entry.item, true)); qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(entry.item, true));
if (addingAttached) if (addingAttached)
addingAttached->setAdding(true); addingAttached->setAdding(true);
@ -637,13 +635,13 @@ LazyListView::DelegateEntry LazyListView::createDelegate(int modelIndex) {
connect(entry.item, &QQuickItem::implicitHeightChanged, this, onHeightChanged); connect(entry.item, &QQuickItem::implicitHeightChanged, this, onHeightChanged);
// Watch attached properties if the delegate uses them // Watch attached properties if the delegate uses them
auto* attached = qobject_cast<LazyListViewAttached*>( auto* attached = qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(entry.item, false));
qmlAttachedPropertiesObject<LazyListView>(entry.item, false));
if (attached) { if (attached) {
entry.attachedConnection = connect(attached, &LazyListViewAttached::preferredHeightChanged, entry.attachedConnection =
this, onHeightChanged); connect(attached, &LazyListViewAttached::preferredHeightChanged, this, onHeightChanged);
connect(attached, &LazyListViewAttached::visibleHeightChanged, connect(attached, &LazyListViewAttached::visibleHeightChanged, this, [this] {
this, [this] { polish(); }); polish();
});
} }
return entry; return entry;
@ -652,8 +650,7 @@ LazyListView::DelegateEntry LazyListView::createDelegate(int modelIndex) {
void LazyListView::destroyDelegate(DelegateEntry& entry) { void LazyListView::destroyDelegate(DelegateEntry& entry) {
if (entry.animation) { if (entry.animation) {
// Disconnect before stopping to prevent re-entrant onAnimationFinished // Disconnect before stopping to prevent re-entrant onAnimationFinished
disconnect(entry.animation, &QAbstractAnimation::finished, disconnect(entry.animation, &QAbstractAnimation::finished, this, &LazyListView::onAnimationFinished);
this, &LazyListView::onAnimationFinished);
entry.animation->stop(); entry.animation->stop();
entry.animation = nullptr; entry.animation = nullptr;
--m_activeAnimations; --m_activeAnimations;
@ -721,11 +718,12 @@ void LazyListView::connectModel() {
connect(m_model, &QAbstractItemModel::rowsMoved, this, &LazyListView::onRowsMoved), connect(m_model, &QAbstractItemModel::rowsMoved, this, &LazyListView::onRowsMoved),
connect(m_model, &QAbstractItemModel::dataChanged, this, &LazyListView::onDataChanged), connect(m_model, &QAbstractItemModel::dataChanged, this, &LazyListView::onDataChanged),
connect(m_model, &QAbstractItemModel::modelReset, this, &LazyListView::onModelReset), connect(m_model, &QAbstractItemModel::modelReset, this, &LazyListView::onModelReset),
connect(m_model, &QAbstractItemModel::layoutChanged, this, [this] { connect(m_model, &QAbstractItemModel::layoutChanged, this,
for (auto& entry : m_delegates) [this] {
updateDelegateData(entry); for (auto& entry : m_delegates)
polish(); updateDelegateData(entry);
}), polish();
}),
connect(m_model, &QObject::destroyed, this, connect(m_model, &QObject::destroyed, this,
[this] { [this] {
m_model = nullptr; m_model = nullptr;
@ -818,8 +816,8 @@ void LazyListView::onRowsAboutToBeRemoved(const QModelIndex& parent, int first,
if (m_removeDuration > 0 && entry.item) { if (m_removeDuration > 0 && entry.item) {
// Signal the delegate via attached property — QML handles the visual transition // Signal the delegate via attached property — QML handles the visual transition
auto* attached = qobject_cast<LazyListViewAttached*>( auto* attached =
qmlAttachedPropertiesObject<LazyListView>(entry.item, false)); qobject_cast<LazyListViewAttached*>(qmlAttachedPropertiesObject<LazyListView>(entry.item, false));
if (attached) if (attached)
attached->setRemoving(true); attached->setRemoving(true);
@ -868,13 +866,11 @@ void LazyListView::onRowsRemoved(const QModelIndex& parent, int first, int last)
} }
m_delegates = std::move(shifted); m_delegates = std::move(shifted);
emit countChanged(); emit countChanged();
polish(); polish();
} }
void LazyListView::onRowsMoved(const QModelIndex& parent, int start, int end, void LazyListView::onRowsMoved(const QModelIndex& parent, int start, int end, const QModelIndex& destination, int row) {
const QModelIndex& destination, int row) {
if (parent.isValid() || destination.isValid()) if (parent.isValid() || destination.isValid())
return; return;