From 7c4d91c465d3e7383e8d0f7583018118efef40ef Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Mon, 10 Jun 2013 11:16:21 +0200 Subject: [PATCH] Fix Bug 319119 - Dolphin doesn't notice when renaming failed Change the data in the model before the real renaming is done by KonqOperations::rename(), but when the rename operation fails, revert the data changes in the model. BUG: 319119 REVIEW: 110922 --- src/views/dolphinview.cpp | 15 ++++++++++++++- src/views/dolphinview.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 9a4b8633e..53d327708 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1363,6 +1363,16 @@ void DolphinView::slotDeleteFileFinished(KJob* job) } } +void DolphinView::slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl) +{ + const int index = m_model->index(newUrl); + if (index >= 0) { + QHash data; + data.insert("text", oldUrl.fileName()); + m_model->setData(index, data); + } +} + void DolphinView::slotDirectoryLoadingStarted() { // Disable the writestate temporary until it can be determined in a fast way @@ -1454,7 +1464,10 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con m_model->setData(index, data); } - KonqOperations::rename(this, oldUrl, newName); + KonqOperations* op = KonqOperations::renameV2(this, oldUrl, newName); + if (op) { + connect(op, SIGNAL(renamingFailed(KUrl,KUrl)), SLOT(slotRenamingFailed(KUrl,KUrl))); + } } } } diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 5a70c5502..0cd6ff2f4 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -632,6 +632,8 @@ private slots: */ void slotDeleteFileFinished(KJob* job); + void slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl); + /** * Invoked when the file item model has started the loading * of the directory specified by DolphinView::url(). -- 2.47.3