┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2012-10-31 23:06:39 +0100
committerFrank Reininghaus <[email protected]>2012-10-31 23:06:39 +0100
commit9d6feb556dbdca54ad9c0a5edc32f53840a88a0f (patch)
treee751adfe60ac6aba841b3b489f61de04fd2b9702 /src
parentbc72aeeb8f47b94f30e6226169d2d5602433ac57 (diff)
Do not show an incorrect file name after a failed rename operation
BUG: 303742 FIXED-IN: 4.9.3
Diffstat (limited to 'src')
-rw-r--r--src/views/dolphinview.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 624aa185d..8e1a19108 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -1348,9 +1348,18 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
if (!newName.isEmpty() && newName != oldItem.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) {
const KUrl oldUrl = oldItem.url();
- QHash<QByteArray, QVariant> data;
- data.insert(role, value);
- m_model->setData(index, data);
+ const KUrl newUrl(url().path(KUrl::AddTrailingSlash) + newName);
+ const bool newNameExistsAlready = (m_model->index(newUrl) >= 0);
+ if (!newNameExistsAlready) {
+ // Only change the data in the model if no item with the new name
+ // is in the model yet. If there is an item with the new name
+ // already, calling KonqOperations::rename() will open a dialog
+ // asking for a new name, and KFileItemModel will update the
+ // data when the dir lister signals that the file name has changed.
+ QHash<QByteArray, QVariant> data;
+ data.insert(role, value);
+ m_model->setData(index, data);
+ }
KonqOperations::rename(this, oldUrl, newName);
}