diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index d8123608cd8..d52bcdf9d42 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -966,7 +966,7 @@ FilePath FilePath::relativeChildPath(const FilePath &parent) const return res; } -/// \returns the relativePath of FilePath to given \a anchor. +/// \returns the relativePath of FilePath from a given \a anchor. /// Both, FilePath and anchor may be files or directories. /// Example usage: /// @@ -978,7 +978,7 @@ FilePath FilePath::relativeChildPath(const FilePath &parent) const /// /// The debug output will be "../b/ar/file.txt". /// -FilePath FilePath::relativePath(const FilePath &anchor) const +FilePath FilePath::relativePathFrom(const FilePath &anchor) const { QTC_ASSERT(isSameDevice(anchor), return *this); diff --git a/src/libs/utils/filepath.h b/src/libs/utils/filepath.h index 9bb65be2935..f7ba8631bcb 100644 --- a/src/libs/utils/filepath.h +++ b/src/libs/utils/filepath.h @@ -153,7 +153,7 @@ public: [[nodiscard]] FilePath resolveSymlinks() const; [[nodiscard]] FilePath withExecutableSuffix() const; [[nodiscard]] FilePath relativeChildPath(const FilePath &parent) const; - [[nodiscard]] FilePath relativePath(const FilePath &anchor) const; + [[nodiscard]] FilePath relativePathFrom(const FilePath &anchor) const; [[nodiscard]] FilePath searchInDirectories(const FilePaths &dirs) const; [[nodiscard]] Environment deviceEnvironment() const; [[nodiscard]] FilePath onDevice(const FilePath &deviceTemplate) const; diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index 7c3db2c7403..0cf89fd241a 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -67,7 +67,7 @@ static void copySourcePathsToClipboard(const FilePaths &srcPaths, const ProjectN QClipboard *clip = QGuiApplication::clipboard(); QString data = Utils::transform(srcPaths, [projDir = node->filePath()](const FilePath &path) { - return path.relativePath(projDir).cleanPath().toString(); + return path.relativePathFrom(projDir).cleanPath().toString(); }).join(" "); clip->setText(data); } @@ -301,7 +301,7 @@ FilePaths CMakeBuildSystem::filesGeneratedFrom(const FilePath &sourceFile) const baseDirectory = baseDirectory.parentDir(); } - const FilePath relativePath = baseDirectory.relativePath(project); + const FilePath relativePath = baseDirectory.relativePathFrom(project); FilePath generatedFilePath = buildConfiguration()->buildDirectory().resolvePath(relativePath); if (sourceFile.suffix() == "ui") { diff --git a/src/plugins/gitlab/gitlabclonedialog.cpp b/src/plugins/gitlab/gitlabclonedialog.cpp index 669a587c14e..7616e53fb47 100644 --- a/src/plugins/gitlab/gitlabclonedialog.cpp +++ b/src/plugins/gitlab/gitlabclonedialog.cpp @@ -221,7 +221,7 @@ void GitLabCloneDialog::cloneFinished(bool success) accept(); } else { const QStringList pFiles = Utils::transform(filesWeMayOpen, [base](const FilePath &f) { - return f.relativePath(base).toUserOutput(); + return f.relativePathFrom(base).toUserOutput(); }); bool ok = false; const QString fileToOpen diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp index d0bf834fea4..2370e068783 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp @@ -77,7 +77,7 @@ Core::GeneratedFiles JsonWizardScannerGenerator::fileList(Utils::MacroExpander * [](const Utils::FilePath &filePath) { return int(filePath.path().count('/')); }; int minDepth = std::numeric_limits::max(); for (auto it = result.begin(); it != result.end(); ++it) { - const Utils::FilePath relPath = it->filePath().relativePath(projectDir); + const Utils::FilePath relPath = it->filePath().relativePathFrom(projectDir); it->setBinary(binaryPattern.match(relPath.toString()).hasMatch()); bool found = ProjectManager::canOpenProjectForMimeType(Utils::mimeTypeForFile(relPath)); if (found) { @@ -119,7 +119,7 @@ Core::GeneratedFiles JsonWizardScannerGenerator::scan(const Utils::FilePath &dir const Utils::FilePaths entries = dir.dirEntries({{}, QDir::AllEntries | QDir::NoDotAndDotDot}, QDir::DirsLast | QDir::Name); for (const Utils::FilePath &fi : entries) { - const Utils::FilePath relativePath = fi.relativePath(base); + const Utils::FilePath relativePath = fi.relativePathFrom(base); if (fi.isDir() && matchesSubdirectoryPattern(relativePath)) { result += scan(fi, base); } else { diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index be62ce4684c..37015295a05 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -515,7 +515,7 @@ void PropertyEditorValue::commitDrop(const QString &path) Utils::FilePath imagePath = Utils::FilePath::fromString(path); Utils::FilePath currFilePath = QmlDesigner::DocumentManager::currentFilePath(); QmlDesigner::VariantProperty srcProp = texture.variantProperty("source"); - srcProp.setValue(imagePath.relativePath(currFilePath).toUrl()); + srcProp.setValue(imagePath.relativePathFrom(currFilePath).toUrl()); // assign the texture to the property setExpressionWithEmit(texture.id()); diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index 19fc3aa4a67..bbed26eb41a 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -113,7 +113,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( auto addAppDir = [&baseDir, &projectInfo](const FilePath &mdir) { auto dir = mdir.cleanPath(); if (!baseDir.path().isEmpty()) { - auto rDir = dir.relativePath(baseDir); + auto rDir = dir.relativePathFrom(baseDir); // do not add directories outside the build directory // this might happen for example when we think an executable path belongs to // a bundle, and we need to remove extra directories, but that was not the case diff --git a/src/plugins/qmlprojectmanager/cmakegen/cmakegeneratordialog.cpp b/src/plugins/qmlprojectmanager/cmakegen/cmakegeneratordialog.cpp index 2b1b3382974..306133445f6 100644 --- a/src/plugins/qmlprojectmanager/cmakegen/cmakegeneratordialog.cpp +++ b/src/plugins/qmlprojectmanager/cmakegen/cmakegeneratordialog.cpp @@ -142,7 +142,7 @@ void CmakeGeneratorDialog::refreshNotificationText() continue; if (node->toFilePath().exists() && node->isChecked()) { - QString relativePath = node->toFilePath().relativePath(m_rootDir).toString(); + QString relativePath = node->toFilePath().relativePathFrom(m_rootDir).toString(); cursor.insertImage(iformat); cursor.insertText(QString(FILE_OVERWRITE_NOTIFICATION).arg(relativePath)); } diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index 689de58428e..426ad149bda 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -372,7 +372,7 @@ FilePath VcsBasePluginState::currentFileDirectory() const QString VcsBasePluginState::relativeCurrentFile() const { QTC_ASSERT(hasFile(), return {}); - return data->m_state.currentFile.relativePath(data->m_state.currentFileTopLevel).toString(); + return data->m_state.currentFile.relativePathFrom(data->m_state.currentFileTopLevel).toString(); } QString VcsBasePluginState::currentPatchFile() const @@ -405,7 +405,7 @@ QString VcsBasePluginState::relativeCurrentProject() const QTC_ASSERT(hasProject(), return QString()); if (data->m_state.currentProjectTopLevel == data->m_state.currentProjectPath) return {}; - return data->m_state.currentProjectPath.relativePath(data->m_state.currentProjectTopLevel).toString(); + return data->m_state.currentProjectPath.relativePathFrom(data->m_state.currentProjectTopLevel).toString(); } bool VcsBasePluginState::hasTopLevel() const diff --git a/tests/auto/utils/fileutils/tst_fileutils.cpp b/tests/auto/utils/fileutils/tst_fileutils.cpp index 4d600a68c2f..d4cd46965cf 100644 --- a/tests/auto/utils/fileutils/tst_fileutils.cpp +++ b/tests/auto/utils/fileutils/tst_fileutils.cpp @@ -294,7 +294,7 @@ void tst_fileutils::calcRelativePath() void tst_fileutils::relativePath_specials() { - QString path = FilePath("").relativePath("").toString(); + QString path = FilePath("").relativePathFrom("").toString(); QCOMPARE(path, ""); } @@ -320,7 +320,7 @@ void tst_fileutils::relativePath() QFETCH(QString, anchor); QFETCH(QString, result); FilePath actualPath = FilePath::fromString(rootPath + "/" + relative) - .relativePath(FilePath::fromString(rootPath + "/" + anchor)); + .relativePathFrom(FilePath::fromString(rootPath + "/" + anchor)); QCOMPARE(actualPath.toString(), result); }