Commit 414d1286 authored by dt_'s avatar dt_ Committed by Daniel Teske
Browse files

Renaming files: fix case-change only renames

Change-Id: Ie95133d22de33a0acca7756b8a41b3812e7dd9e7
Task-Nr: QTCREATORBUG-2434
Reviewed-on: http://codereview.qt.nokia.com/435

Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@nokia.com>
parent e463874c
......@@ -119,6 +119,7 @@
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
#include <QtCore/QSettings>
#include <QtCore/QAbstractFileEngine>
#include <QtGui/QAction>
#include <QtGui/QApplication>
......@@ -2582,13 +2583,26 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &to)
QString orgFilePath = QFileInfo(node->path()).absoluteFilePath();
QString dir = QFileInfo(orgFilePath).absolutePath();
QString newFilePath = dir + QLatin1Char('/') + to;
if (orgFilePath == newFilePath)
return;
Core::ICore *core = Core::ICore::instance();
Core::IVersionControl *vc = core->vcsManager()->findVersionControlForDirectory(dir);
bool result = false;
if (vc && vc->supportsOperation(Core::IVersionControl::MoveOperation))
result = vc->vcsMove(orgFilePath, newFilePath);
if (!result) // The moving via vcs failed or the vcs does not support moving, fall back
result = QFile::rename(orgFilePath, newFilePath);
if (!result) { // The moving via vcs failed or the vcs does not support moving, fall back
QFile f(orgFilePath);
if (!f.fileEngine()->caseSensitive()
&& orgFilePath.compare(newFilePath, Qt::CaseInsensitive) == 0) {
// Due to QTBUG-3570
result = f.fileEngine()->rename(newFilePath);
} else {
result = QFile::rename(orgFilePath, newFilePath);
}
}
if (result) {
// yeah we moved, tell the filemanager about it
Core::ICore::instance()->fileManager()->renamedFile(orgFilePath, newFilePath);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment