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
This commit is contained in:
Emmanuel Pescosta 2013-06-10 11:16:21 +02:00
parent ca6e6a342e
commit 7c4d91c465
2 changed files with 16 additions and 1 deletions

View 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)));
}
}
}
}

View 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().