summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppmodelmanager.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2021-06-11 14:34:34 +0200
committerDavid Schulz <david.schulz@qt.io>2021-06-17 11:13:51 +0000
commitf66df921d74c323d899f996d9ca520c224355a90 (patch)
tree42ef20fe9de0b55b756d9ba56b731d1a474c9c08 /src/plugins/cpptools/cppmodelmanager.cpp
parent55b91a76172a3235b4879daf0b675519d5b02db7 (diff)
downloadqt-creator-f66df921d74c323d899f996d9ca520c224355a90.tar.gz
Core: filepathify file renaming
Change-Id: I3d4f39e34e65cde3df7b7c19570e3a54d0625d53 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cppmodelmanager.cpp')
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index c9324b1f35..aafa51a906 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -1450,30 +1450,29 @@ QSet<QString> CppModelManager::internalTargets(const Utils::FilePath &filePath)
return targets;
}
-void CppModelManager::renameIncludes(const QString &oldFileName, const QString &newFileName)
+void CppModelManager::renameIncludes(const Utils::FilePath &oldFilePath,
+ const Utils::FilePath &newFilePath)
{
- if (oldFileName.isEmpty() || newFileName.isEmpty())
+ if (oldFilePath.isEmpty() || newFilePath.isEmpty())
return;
- const QFileInfo oldFileInfo(oldFileName);
- const QFileInfo newFileInfo(newFileName);
-
// We just want to handle renamings so return when the file was actually moved.
- if (oldFileInfo.absoluteDir() != newFileInfo.absoluteDir())
+ if (oldFilePath.absolutePath() != newFilePath.absolutePath())
return;
const TextEditor::RefactoringChanges changes;
- foreach (Snapshot::IncludeLocation loc, snapshot().includeLocationsOfDocument(oldFileName)) {
+ foreach (Snapshot::IncludeLocation loc,
+ snapshot().includeLocationsOfDocument(oldFilePath.toString())) {
TextEditor::RefactoringFilePtr file = changes.file(
Utils::FilePath::fromString(loc.first->fileName()));
const QTextBlock &block = file->document()->findBlockByNumber(loc.second - 1);
- const int replaceStart = block.text().indexOf(oldFileInfo.fileName());
+ const int replaceStart = block.text().indexOf(oldFilePath.fileName());
if (replaceStart > -1) {
Utils::ChangeSet changeSet;
changeSet.replace(block.position() + replaceStart,
- block.position() + replaceStart + oldFileInfo.fileName().length(),
- newFileInfo.fileName());
+ block.position() + replaceStart + oldFilePath.fileName().length(),
+ newFilePath.fileName());
file->setChangeSet(changeSet);
file->apply();
}