mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Fix scrolling during inline renaming causes rename of wrong file
Summary: Scrolling during inline renaming accepts the renaming now, like if one would hit Return for example. I chose this approach because it seems the easiest way to fix this. This also fixes the “possible” Ui glitch where the renaming KTextField doesn’t move along with the list item. Possible glitch, because I don’t know if this is intentional, but for me it looks broken. BUG: 378786 Fixes T7443 Test Plan: * Enable "Rename inline" in dolphin settings * Go to a folder where you have to scroll through items (many files, big zoom,…) * Start to rename a file (context menu, F2, …) * Scroll with mouse wheel * Rename accepted -> file is renamed Reviewers: ngraham, rkflx, #dolphin, elvisangelaccio Reviewed By: ngraham, rkflx, #dolphin, elvisangelaccio Subscribers: anthonyfieroni, elvisangelaccio, #dolphin Maniphest Tasks: T7443 Differential Revision: https://phabricator.kde.org/D8822
This commit is contained in:
parent
e60e3f07cf
commit
5bee1889e1
|
@ -27,7 +27,7 @@
|
|||
#include "kitemlistcontroller.h"
|
||||
#include "kitemlistheader.h"
|
||||
#include "kitemlistselectionmanager.h"
|
||||
#include "kitemlistwidget.h"
|
||||
#include "kstandarditemlistwidget.h"
|
||||
|
||||
#include "private/kitemlistheaderwidget.h"
|
||||
#include "private/kitemlistrubberband.h"
|
||||
|
@ -642,7 +642,7 @@ QPixmap KItemListView::createDragPixmap(const KItemSet& indexes) const
|
|||
|
||||
void KItemListView::editRole(int index, const QByteArray& role)
|
||||
{
|
||||
KItemListWidget* widget = m_visibleItems.value(index);
|
||||
KStandardItemListWidget* widget = qobject_cast<KStandardItemListWidget *>(m_visibleItems.value(index));
|
||||
if (!widget || m_editingRole) {
|
||||
return;
|
||||
}
|
||||
|
@ -654,6 +654,9 @@ void KItemListView::editRole(int index, const QByteArray& role)
|
|||
this, &KItemListView::slotRoleEditingCanceled);
|
||||
connect(widget, &KItemListWidget::roleEditingFinished,
|
||||
this, &KItemListView::slotRoleEditingFinished);
|
||||
|
||||
connect(this, &KItemListView::scrollOffsetChanged,
|
||||
widget, &KStandardItemListWidget::finishRoleEditing);
|
||||
}
|
||||
|
||||
void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
|
@ -2639,13 +2642,14 @@ bool KItemListView::hasSiblingSuccessor(int index) const
|
|||
|
||||
void KItemListView::disconnectRoleEditingSignals(int index)
|
||||
{
|
||||
KItemListWidget* widget = m_visibleItems.value(index);
|
||||
KStandardItemListWidget* widget = qobject_cast<KStandardItemListWidget *>(m_visibleItems.value(index));
|
||||
if (!widget) {
|
||||
return;
|
||||
}
|
||||
|
||||
disconnect(widget, &KItemListWidget::roleEditingCanceled, this, nullptr);
|
||||
disconnect(widget, &KItemListWidget::roleEditingFinished, this, nullptr);
|
||||
disconnect(this, &KItemListView::scrollOffsetChanged, widget, nullptr);
|
||||
}
|
||||
|
||||
int KItemListView::calculateAutoScrollingIncrement(int pos, int range, int oldInc)
|
||||
|
|
|
@ -860,6 +860,13 @@ bool KStandardItemListWidget::event(QEvent *event)
|
|||
return KItemListWidget::event(event);
|
||||
}
|
||||
|
||||
void KStandardItemListWidget::finishRoleEditing()
|
||||
{
|
||||
if (!editedRole().isEmpty() && m_roleEditor) {
|
||||
slotRoleEditingFinished(editedRole(), KIO::encodeFileName(m_roleEditor->toPlainText()));
|
||||
}
|
||||
}
|
||||
|
||||
void KStandardItemListWidget::slotCutItemsChanged()
|
||||
{
|
||||
const QUrl itemUrl = data().value("url").toUrl();
|
||||
|
|
|
@ -185,6 +185,9 @@ protected:
|
|||
virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
|
||||
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
public slots:
|
||||
void finishRoleEditing();
|
||||
|
||||
private slots:
|
||||
void slotCutItemsChanged();
|
||||
void slotRoleEditingCanceled(const QByteArray& role, const QVariant& value);
|
||||
|
|
Loading…
Reference in a new issue