forked from qt-creator/qt-creator
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:
@@ -757,7 +757,7 @@ static BuildInfo createBuildInfo(const Kit *k, const FilePath &projectPath,
|
|||||||
// Leave info.buildDirectory unset;
|
// Leave info.buildDirectory unset;
|
||||||
|
|
||||||
// check if this project is in the source directory:
|
// check if this project is in the source directory:
|
||||||
if (version && version->isInSourceDirectory(projectPath)) {
|
if (version && version->isInQtSourceDirectory(projectPath)) {
|
||||||
// assemble build directory
|
// assemble build directory
|
||||||
QString projectDirectory = projectPath.toFileInfo().absolutePath();
|
QString projectDirectory = projectPath.toFileInfo().absolutePath();
|
||||||
QDir qtSourceDir = QDir(version->sourcePath().toString());
|
QDir qtSourceDir = QDir(version->sourcePath().toString());
|
||||||
|
@@ -746,7 +746,7 @@ Tasks QmakeProject::projectIssues(const Kit *k) const
|
|||||||
// that is not the one from the current kit.
|
// that is not the one from the current kit.
|
||||||
const QList<BaseQtVersion *> qtsContainingThisProject
|
const QList<BaseQtVersion *> qtsContainingThisProject
|
||||||
= QtVersionManager::versions([filePath = projectFilePath()](const BaseQtVersion *qt) {
|
= QtVersionManager::versions([filePath = projectFilePath()](const BaseQtVersion *qt) {
|
||||||
return qt->isValid() && qt->isSubProject(filePath);
|
return qt->isValid() && qt->isQtSubProject(filePath);
|
||||||
});
|
});
|
||||||
if (!qtsContainingThisProject.isEmpty()
|
if (!qtsContainingThisProject.isEmpty()
|
||||||
&& !qtsContainingThisProject.contains(const_cast<BaseQtVersion *>(qtFromKit))) {
|
&& !qtsContainingThisProject.contains(const_cast<BaseQtVersion *>(qtFromKit))) {
|
||||||
|
@@ -1961,35 +1961,32 @@ FilePath BaseQtVersionPrivate::sourcePath(const QHash<ProKey, ProString> &versio
|
|||||||
return FilePath::fromUserInput(QFileInfo(sourcePath).canonicalFilePath());
|
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())
|
if (source.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
QDir dir = QDir(source.toString());
|
if (source.fileName() == "qtbase")
|
||||||
if (dir.dirName() == "qtbase")
|
source = source.parentDir();
|
||||||
dir.cdUp();
|
return filePath.isChildOf(source);
|
||||||
return filePath.isChildOf(dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseQtVersion::isSubProject(const FilePath &filePath) const
|
bool BaseQtVersion::isQtSubProject(const FilePath &filePath) const
|
||||||
{
|
{
|
||||||
const FilePath &source = sourcePath();
|
FilePath source = sourcePath();
|
||||||
if (!source.isEmpty()) {
|
if (!source.isEmpty()) {
|
||||||
QDir dir = QDir(source.toString());
|
if (source.fileName() == "qtbase")
|
||||||
if (dir.dirName() == "qtbase")
|
source = source.parentDir();
|
||||||
dir.cdUp();
|
if (filePath.isChildOf(source))
|
||||||
|
|
||||||
if (filePath.isChildOf(dir))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString examples = examplesPath().toString();
|
const FilePath examples = examplesPath();
|
||||||
if (!examples.isEmpty() && filePath.isChildOf(QDir(examples)))
|
if (!examples.isEmpty() && filePath.isChildOf(examples))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const QString demos = demosPath().toString();
|
const FilePath demos = demosPath();
|
||||||
if (!demos.isEmpty() && filePath.isChildOf(QDir(demos)))
|
if (!demos.isEmpty() && filePath.isChildOf(demos))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@@ -128,8 +128,8 @@ public:
|
|||||||
Utils::FilePath sourcePath() const;
|
Utils::FilePath sourcePath() const;
|
||||||
// returns source path for installed qt packages and empty string for self build qt
|
// returns source path for installed qt packages and empty string for self build qt
|
||||||
Utils::FilePath qtPackageSourcePath() const;
|
Utils::FilePath qtPackageSourcePath() const;
|
||||||
bool isInSourceDirectory(const Utils::FilePath &filePath);
|
bool isInQtSourceDirectory(const Utils::FilePath &filePath) const;
|
||||||
bool isSubProject(const Utils::FilePath &filePath) const;
|
bool isQtSubProject(const Utils::FilePath &filePath) const;
|
||||||
|
|
||||||
Utils::FilePath rccCommand() const;
|
Utils::FilePath rccCommand() const;
|
||||||
// used by UiCodeModelSupport
|
// used by UiCodeModelSupport
|
||||||
|
Reference in New Issue
Block a user