diff options
| author | Méven Car <[email protected]> | 2026-03-18 12:49:50 +0100 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-03-19 09:23:37 +0000 |
| commit | 01bfa0e868a0696b8382deb4dd3c0ef12b584835 (patch) | |
| tree | 4a8ebcedf53c445316b142c8a8786fb1696e03f0 /src/kitemviews/kitemlistview.cpp | |
| parent | 2d7b8530e2cbf30d2ff7ee8a3ff66dd4aa6a632d (diff) | |
kitemlistview: cancel editing when animation starts
For this widget.
If a file is being moved due due to external events, an animation may
start, in which case we better cancel the edit.
If we hook this at the animation start instead of checks spread out, we
can't miss this cancellation anymore.
KStandardItemListWidget gets a cancelRoleEditing slot to cleanly cancel
editing and clean up its internal state.
Diffstat (limited to 'src/kitemviews/kitemlistview.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistview.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index b780e3ff4..e828b6967 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -117,6 +117,7 @@ KItemListView::KItemListView(QGraphicsWidget *parent) m_animation = new KItemListViewAnimation(this); connect(m_animation, &KItemListViewAnimation::finished, this, &KItemListView::slotAnimationFinished); + connect(m_animation, &KItemListViewAnimation::start, this, &KItemListView::slotAnimationStarted); m_rubberBand = new KItemListRubberBand(this); connect(m_rubberBand, &KItemListRubberBand::activationChanged, this, &KItemListView::slotRubberBandActivationChanged); @@ -758,8 +759,7 @@ void KItemListView::editRole(int index, const QByteArray &role) if (!widget) { return; } - if (m_editingRole || m_animation->isStarted(widget)) { - Q_EMIT widget->roleEditingCanceled(index, role, QVariant()); + if (widget->editedRole() == role) { return; } @@ -1577,6 +1577,13 @@ void KItemListView::slotSelectionChanged(const KItemSet ¤t, const KItemSet #endif } +void KItemListView::slotAnimationStarted(QGraphicsWidget *widget, KItemListViewAnimation::AnimationType /* type */, const QVariant & /* endValue */) +{ + KStandardItemListWidget *listWidget = qobject_cast<KStandardItemListWidget *>(widget); + Q_ASSERT(widget); + listWidget->cancelRoleEditing(); +} + void KItemListView::slotAnimationFinished(QGraphicsWidget *widget, KItemListViewAnimation::AnimationType type) { KItemListWidget *itemListWidget = qobject_cast<KItemListWidget *>(widget); @@ -1926,9 +1933,6 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha if (animate) { if (m_animation->isStarted(widget, KItemListViewAnimation::MovingAnimation)) { - if (m_editingRole) { - Q_EMIT widget->roleEditingCanceled(widget->index(), QByteArray(), QVariant()); - } m_animation->start(widget, KItemListViewAnimation::MovingAnimation, newPos); applyNewPos = false; } @@ -2804,7 +2808,7 @@ bool KItemListView::hasSiblingSuccessor(int index) const void KItemListView::disconnectRoleEditingSignals(int index) { - KStandardItemListWidget *widget = qobject_cast<KStandardItemListWidget *>(m_visibleItems.value(index)); + KItemListWidget *widget = m_visibleItems.value(index); if (!widget) { return; } |
