forked from qt-creator/qt-creator
Utils: Rename FilePath::relativePath() to relativePathFrom()
Hopefully less confusion about the direction. Change-Id: I61727d6c4d19e0dfe46f24ff24f5d90f9835d05c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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") {
|
||||
|
@@ -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
|
||||
|
@@ -77,7 +77,7 @@ Core::GeneratedFiles JsonWizardScannerGenerator::fileList(Utils::MacroExpander *
|
||||
[](const Utils::FilePath &filePath) { return int(filePath.path().count('/')); };
|
||||
int minDepth = std::numeric_limits<int>::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 {
|
||||
|
@@ -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());
|
||||
|
@@ -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
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user