]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix Bug 319119 - Dolphin doesn't notice when renaming failed
authorEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Mon, 10 Jun 2013 09:16:21 +0000 (11:16 +0200)
committerEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Mon, 10 Jun 2013 09:16:21 +0000 (11:16 +0200)
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
src/views/dolphinview.h

index 9a4b8633efc0ff03e097357facd0eff75179ae45..53d3277085c46c1e1063e6c230eac8b19d24dbe9 100644 (file)
@@ -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<QByteArray, QVariant> 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)));
+            }
         }
     }
 }
index 5a70c550224196fa772e32cea591153f83e5d666..0cd6ff2f476f09854b934f2be959402af23f8bbf 100644 (file)
@@ -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().