forked from qt-creator/qt-creator
ProjectExplorer: Rename local variable and add some consts
Change-Id: If9cadcbb196a8b6350a654aca01b4a7ee59612b3 Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -3232,32 +3232,32 @@ void ProjectExplorerPluginPrivate::handleRenameFile()
|
|||||||
|
|
||||||
void ProjectExplorerPlugin::renameFile(Node *node, const QString &newFilePath)
|
void ProjectExplorerPlugin::renameFile(Node *node, const QString &newFilePath)
|
||||||
{
|
{
|
||||||
QString orgFilePath = node->filePath().toFileInfo().absoluteFilePath();
|
const QString oldFilePath = node->filePath().toFileInfo().absoluteFilePath();
|
||||||
FolderNode *folderNode = node->parentFolderNode();
|
FolderNode *folderNode = node->parentFolderNode();
|
||||||
QString projectFileName = folderNode->projectNode()->filePath().fileName();
|
const QString projectFileName = folderNode->projectNode()->filePath().fileName();
|
||||||
|
|
||||||
if (!folderNode->canRenameFile(orgFilePath, newFilePath)) {
|
if (!folderNode->canRenameFile(oldFilePath, newFilePath)) {
|
||||||
QTimer::singleShot(0, [orgFilePath, newFilePath, projectFileName] {
|
QTimer::singleShot(0, [oldFilePath, newFilePath, projectFileName] {
|
||||||
int res = QMessageBox::question(ICore::mainWindow(),
|
int res = QMessageBox::question(ICore::mainWindow(),
|
||||||
tr("Project Editing Failed"),
|
tr("Project Editing Failed"),
|
||||||
tr("The project file %1 cannot be automatically changed.\n\n"
|
tr("The project file %1 cannot be automatically changed.\n\n"
|
||||||
"Rename %2 to %3 anyway?")
|
"Rename %2 to %3 anyway?")
|
||||||
.arg(projectFileName)
|
.arg(projectFileName)
|
||||||
.arg(QDir::toNativeSeparators(orgFilePath))
|
.arg(QDir::toNativeSeparators(oldFilePath))
|
||||||
.arg(QDir::toNativeSeparators(newFilePath)));
|
.arg(QDir::toNativeSeparators(newFilePath)));
|
||||||
if (res == QMessageBox::Yes)
|
if (res == QMessageBox::Yes)
|
||||||
FileUtils::renameFile(orgFilePath, newFilePath);
|
FileUtils::renameFile(oldFilePath, newFilePath);
|
||||||
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileUtils::renameFile(orgFilePath, newFilePath)) {
|
if (FileUtils::renameFile(oldFilePath, newFilePath)) {
|
||||||
// Tell the project plugin about rename
|
// Tell the project plugin about rename
|
||||||
if (!folderNode->renameFile(orgFilePath, newFilePath)) {
|
if (!folderNode->renameFile(oldFilePath, newFilePath)) {
|
||||||
const QString renameFileError
|
const QString renameFileError
|
||||||
= tr("The file %1 was renamed to %2, but the project file %3 could not be automatically changed.")
|
= tr("The file %1 was renamed to %2, but the project file %3 could not be automatically changed.")
|
||||||
.arg(QDir::toNativeSeparators(orgFilePath))
|
.arg(QDir::toNativeSeparators(oldFilePath))
|
||||||
.arg(QDir::toNativeSeparators(newFilePath))
|
.arg(QDir::toNativeSeparators(newFilePath))
|
||||||
.arg(projectFileName);
|
.arg(projectFileName);
|
||||||
|
|
||||||
@@ -3269,7 +3269,7 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &newFilePath)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const QString renameFileError = tr("The file %1 could not be renamed %2.")
|
const QString renameFileError = tr("The file %1 could not be renamed %2.")
|
||||||
.arg(QDir::toNativeSeparators(orgFilePath))
|
.arg(QDir::toNativeSeparators(oldFilePath))
|
||||||
.arg(QDir::toNativeSeparators(newFilePath));
|
.arg(QDir::toNativeSeparators(newFilePath));
|
||||||
|
|
||||||
QTimer::singleShot(0, [renameFileError]() {
|
QTimer::singleShot(0, [renameFileError]() {
|
||||||
|
Reference in New Issue
Block a user