┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/dolphinview.cpp
diff options
context:
space:
mode:
authorJin Liu <[email protected]>2024-10-11 16:21:14 +0800
committerJin Liu <[email protected]>2024-10-12 21:23:46 +0800
commit1ba5168e39b270744a8e5c033ec24900b337f908 (patch)
tree2d26b3ab377ff162b3d1120b4ba8604cb233d38a /src/views/dolphinview.cpp
parenta340362524b5979474bb55705e37f40ba89f6f5b (diff)
dolphinview: when rename dialog finishes, immediately update the model and the selection
On sucessful return of the rename dialog, we update the model and the selection immediately to reflect the new name. This is to avoid the short duration after the rename during which the selection is lost. Currently, after the rename dialog finishes, the selection is briefly lost for about 1 second until the view automatically refreshes. This patch updates the model and selection immediately after the dialog finishes, so the renamed file is still selected. BUG: 481717
Diffstat (limited to 'src/views/dolphinview.cpp')
-rw-r--r--src/views/dolphinview.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index ab39173da..f9f32d35c 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -757,7 +757,20 @@ void DolphinView::renameSelectedItems()
} else {
KIO::RenameFileDialog *dialog = new KIO::RenameFileDialog(items, this);
- connect(dialog, &KIO::RenameFileDialog::renamingFinished, this, &DolphinView::slotRenameDialogRenamingFinished);
+ connect(dialog, &KIO::RenameFileDialog::renamingFinished, this, [this, items](const QList<QUrl> &urls) {
+ // The model may have already been updated, so it's possible that we don't find the old items.
+ for (int i = 0; i < items.count(); ++i) {
+ const int index = m_model->index(items[i]);
+ if (index >= 0) {
+ QHash<QByteArray, QVariant> data;
+ data.insert("text", urls[i].fileName());
+ m_model->setData(index, data);
+ }
+ }
+
+ forceUrlsSelection(urls.first(), urls);
+ updateSelectionState();
+ });
connect(dialog, &KIO::RenameFileDialog::error, this, [this](KJob *job) {
KMessageBox::error(this, job->errorString());
});
@@ -2276,11 +2289,6 @@ QUrl DolphinView::viewPropertiesUrl() const
return url;
}
-void DolphinView::slotRenameDialogRenamingFinished(const QList<QUrl> &urls)
-{
- forceUrlsSelection(urls.first(), urls);
-}
-
void DolphinView::forceUrlsSelection(const QUrl &current, const QList<QUrl> &selected)
{
clearSelection();