QtSupport: Use FilePaths in BaseQtVersion::isInSourceDirectory

... and isSubProject.

Take the opportunity to rename them into isInQtSourceDirectory and
a isQtSubProject to make its limited scope clearer.

An open question is why this is only used for qmake projects.

Change-Id: If36f9457583eac17e149624ec46e5de10dd4a5a5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-06-30 11:33:33 +02:00
parent 18b98a85eb
commit 1db9dd058e
4 changed files with 18 additions and 21 deletions

View File

@@ -757,7 +757,7 @@ static BuildInfo createBuildInfo(const Kit *k, const FilePath &projectPath,
// Leave info.buildDirectory unset;
// check if this project is in the source directory:
if (version && version->isInSourceDirectory(projectPath)) {
if (version && version->isInQtSourceDirectory(projectPath)) {
// assemble build directory
QString projectDirectory = projectPath.toFileInfo().absolutePath();
QDir qtSourceDir = QDir(version->sourcePath().toString());

View File

@@ -746,7 +746,7 @@ Tasks QmakeProject::projectIssues(const Kit *k) const
// that is not the one from the current kit.
const QList<BaseQtVersion *> qtsContainingThisProject
= QtVersionManager::versions([filePath = projectFilePath()](const BaseQtVersion *qt) {
return qt->isValid() && qt->isSubProject(filePath);
return qt->isValid() && qt->isQtSubProject(filePath);
});
if (!qtsContainingThisProject.isEmpty()
&& !qtsContainingThisProject.contains(const_cast<BaseQtVersion *>(qtFromKit))) {

View File

@@ -1961,35 +1961,32 @@ FilePath BaseQtVersionPrivate::sourcePath(const QHash<ProKey, ProString> &versio
return FilePath::fromUserInput(QFileInfo(sourcePath).canonicalFilePath());
}
bool BaseQtVersion::isInSourceDirectory(const FilePath &filePath)
bool BaseQtVersion::isInQtSourceDirectory(const FilePath &filePath) const
{
const FilePath &source = sourcePath();
FilePath source = sourcePath();
if (source.isEmpty())
return false;
QDir dir = QDir(source.toString());
if (dir.dirName() == "qtbase")
dir.cdUp();
return filePath.isChildOf(dir);
if (source.fileName() == "qtbase")
source = source.parentDir();
return filePath.isChildOf(source);
}
bool BaseQtVersion::isSubProject(const FilePath &filePath) const
bool BaseQtVersion::isQtSubProject(const FilePath &filePath) const
{
const FilePath &source = sourcePath();
FilePath source = sourcePath();
if (!source.isEmpty()) {
QDir dir = QDir(source.toString());
if (dir.dirName() == "qtbase")
dir.cdUp();
if (filePath.isChildOf(dir))
if (source.fileName() == "qtbase")
source = source.parentDir();
if (filePath.isChildOf(source))
return true;
}
const QString examples = examplesPath().toString();
if (!examples.isEmpty() && filePath.isChildOf(QDir(examples)))
const FilePath examples = examplesPath();
if (!examples.isEmpty() && filePath.isChildOf(examples))
return true;
const QString demos = demosPath().toString();
if (!demos.isEmpty() && filePath.isChildOf(QDir(demos)))
const FilePath demos = demosPath();
if (!demos.isEmpty() && filePath.isChildOf(demos))
return true;
return false;

View File

@@ -128,8 +128,8 @@ public:
Utils::FilePath sourcePath() const;
// returns source path for installed qt packages and empty string for self build qt
Utils::FilePath qtPackageSourcePath() const;
bool isInSourceDirectory(const Utils::FilePath &filePath);
bool isSubProject(const Utils::FilePath &filePath) const;
bool isInQtSourceDirectory(const Utils::FilePath &filePath) const;
bool isQtSubProject(const Utils::FilePath &filePath) const;
Utils::FilePath rccCommand() const;
// used by UiCodeModelSupport