ProjectExplorer etc: More FilePath usage

Mostly for project files.

Change-Id: Icb6059f80758865e42cc9f9c092ec6782770dfd7
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-06-26 17:09:35 +02:00
parent f878486fcb
commit e7c6169d70
33 changed files with 107 additions and 94 deletions

View File

@@ -59,13 +59,13 @@ using namespace Utils;
namespace QbsProjectManager {
namespace Internal {
static FilePath defaultBuildDirectory(const QString &projectFilePath, const Kit *k,
static FilePath defaultBuildDirectory(const FilePath &projectFilePath, const Kit *k,
const QString &bcName,
BuildConfiguration::BuildType buildType)
{
const QString projectName = QFileInfo(projectFilePath).completeBaseName();
const QString projectName = projectFilePath.toFileInfo().completeBaseName();
ProjectMacroExpander expander(projectFilePath, projectName, k, bcName, buildType);
QString projectDir = Project::projectDirectory(FilePath::fromString(projectFilePath)).toString();
QString projectDir = Project::projectDirectory(projectFilePath).toString();
QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate());
return FilePath::fromString(FileUtils::resolvePath(projectDir, buildPath));
}
@@ -102,7 +102,7 @@ void QbsBuildConfiguration::initialize(const BuildInfo &info)
Utils::FilePath buildDir = info.buildDirectory;
if (buildDir.isEmpty())
buildDir = defaultBuildDirectory(target()->project()->projectFilePath().toString(),
buildDir = defaultBuildDirectory(target()->project()->projectFilePath(),
target()->kit(), info.displayName, info.buildType);
setBuildDirectory(buildDir);
@@ -387,7 +387,8 @@ QList<BuildInfo> QbsBuildConfigurationFactory::availableBuilds(const Target *par
return {createBuildInfo(parent->kit(), BuildConfiguration::Debug)};
}
QList<BuildInfo> QbsBuildConfigurationFactory::availableSetups(const Kit *k, const QString &projectPath) const
QList<BuildInfo>
QbsBuildConfigurationFactory::availableSetups(const Kit *k, const FilePath &projectPath) const
{
QList<BuildInfo> result;

View File

@@ -94,7 +94,7 @@ public:
QList<ProjectExplorer::BuildInfo> availableBuilds(const ProjectExplorer::Target *parent) const override;
QList<ProjectExplorer::BuildInfo> availableSetups(const ProjectExplorer::Kit *k,
const QString &projectPath) const override;
const Utils::FilePath &projectPath) const override;
private:
ProjectExplorer::BuildInfo createBuildInfo(const ProjectExplorer::Kit *k,

View File

@@ -725,8 +725,8 @@ void QbsProject::configureAsExampleProject(const QSet<Id> &platforms)
= QtSupport::QtKitAspect::qtVersion(k);
if (!qtVersion || !qtVersionMatchesPlatform(qtVersion))
continue;
if (auto factory = BuildConfigurationFactory::find(k, projectFilePath().toString()))
infoList << factory->allAvailableSetups(k, projectFilePath().toString());
if (auto factory = BuildConfigurationFactory::find(k, projectFilePath()))
infoList << factory->allAvailableSetups(k, projectFilePath());
}
setup(infoList);
prepareForParsing();

View File

@@ -87,13 +87,12 @@ QbsProjectImporter::QbsProjectImporter(const FilePath &path) : QtProjectImporter
{
}
static QString buildDir(const QString &projectFilePath, const Kit *k)
static QString buildDir(const FilePath &projectFilePath, const Kit *k)
{
const QString projectName = QFileInfo(projectFilePath).completeBaseName();
const QString projectName = projectFilePath.toFileInfo().completeBaseName();
ProjectMacroExpander expander(projectFilePath, projectName, k, QString(),
BuildConfiguration::Unknown);
const QString projectDir
= Project::projectDirectory(FilePath::fromString(projectFilePath)).toString();
const QString projectDir = Project::projectDirectory(projectFilePath).toString();
const QString buildPath = expander.expand(ProjectExplorerPlugin::buildDirectoryTemplate());
return FileUtils::resolvePath(projectDir, buildPath);
}
@@ -125,7 +124,7 @@ QStringList QbsProjectImporter::importCandidates()
seenCandidates.insert(projectDir);
const auto &kits = KitManager::kits();
for (Kit * const k : kits) {
QFileInfo fi(buildDir(projectFilePath().toString(), k));
QFileInfo fi(buildDir(projectFilePath(), k));
const QString candidate = fi.absolutePath();
if (!seenCandidates.contains(candidate)) {
seenCandidates.insert(candidate);
@@ -224,7 +223,7 @@ const QList<BuildInfo> QbsProjectImporter::buildInfoListForKit(const Kit *k, voi
{
qCDebug(qbsPmLog) << "creating build info for kit" << k->displayName();
const auto factory = qobject_cast<QbsBuildConfigurationFactory *>(
BuildConfigurationFactory::find(k, projectFilePath().toString()));
BuildConfigurationFactory::find(k, projectFilePath()));
if (!factory) {
qCDebug(qbsPmLog) << "no build config factory found";
return {};