File renaming: Show a warning message if a project could not be changed

Except if we expect the changing to do nothing, e.g. if the file is
added via a folder deployment.

Change-Id: Ic6a8caa27e6ce3e779ac9cd13a43a6898360bfea
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@nokia.com>
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
Daniel Teske
2012-04-18 11:50:32 +02:00
parent dc327294d6
commit c976024c26
2 changed files with 11 additions and 4 deletions

View File

@@ -2844,8 +2844,13 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &to)
Core::DocumentManager::renamedFile(orgFilePath, newFilePath); Core::DocumentManager::renamedFile(orgFilePath, newFilePath);
// Tell the project plugin about it // Tell the project plugin about it
ProjectNode *projectNode = fileNode->projectNode(); ProjectNode *projectNode = fileNode->projectNode();
projectNode->renameFile(fileNode->fileType(), orgFilePath, newFilePath); if (!projectNode->renameFile(fileNode->fileType(), orgFilePath, newFilePath)) {
// TODO emit a signal? QMessageBox::warning(Core::ICore::mainWindow(), tr("Project Editing Failed"),
tr("The file %1 was renamed to %2, but the project file %3 could not be automatically changed.")
.arg(orgFilePath)
.arg(newFilePath)
.arg(projectNode->displayName()));
}
} }
} }

View File

@@ -992,12 +992,14 @@ bool Qt4PriFileNode::renameFile(const FileType fileType, const QString &filePath
if (newFilePath.isEmpty()) if (newFilePath.isEmpty())
return false; return false;
bool changeProFileOptional = deploysFolder(QFileInfo(filePath).absolutePath());
QStringList dummy; QStringList dummy;
changeFiles(fileType, QStringList() << filePath, &dummy, RemoveFromProFile); changeFiles(fileType, QStringList() << filePath, &dummy, RemoveFromProFile);
if (!dummy.isEmpty()) if (!dummy.isEmpty() && !changeProFileOptional)
return false; return false;
changeFiles(fileType, QStringList() << newFilePath, &dummy, AddToProFile); changeFiles(fileType, QStringList() << newFilePath, &dummy, AddToProFile);
if (!dummy.isEmpty()) if (!dummy.isEmpty() && !changeProFileOptional)
return false; return false;
return true; return true;
} }