aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmljstools
diff options
context:
space:
mode:
authorChristian Kandeler <[email protected]>2025-01-20 14:21:46 +0100
committerChristian Kandeler <[email protected]>2025-01-20 16:55:10 +0000
commit30dc2e66dcd7ac092a04432aa92c39e8be025924 (patch)
tree082762f2e63e1680d0bba84dcbab3e96aef6ff73 /src/plugins/qmljstools
parentd38f7f74d4e38ba9bfe082fe89ad80da80b37a62 (diff)
ProjectExplorer: Add and make use of forwarding accessors in Project
Most accesses to activeTarget() are for getting to the active kit or build/deploy/run configuration. Simplify client code by adding convenience functions for that. No functional changes intended. Change-Id: Ide266712d19f960e4512672eb3bd00fc4d21b47b Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins/qmljstools')
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index 4b97b3eaab2..4bda87f9c49 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -57,10 +57,7 @@ namespace Internal {
static void setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &projectInfo)
{
- Target *activeTarget = nullptr;
- if (projectInfo.project)
- activeTarget = projectInfo.project->activeTarget();
- Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit();
+ Kit *activeKit = projectInfo.project ? projectInfo.project->activeKit() : KitManager::defaultKit();
const QHash<QString, QString> replacements = {{QLatin1String("$(QT_INSTALL_QML)"), projectInfo.qtQmlPath.toUrlishString()}};
for (IBundleProvider *bp : IBundleProvider::allBundleProviders())
@@ -115,7 +112,6 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
ModelManagerInterface::ProjectInfo projectInfo;
projectInfo.project = project;
projectInfo.qmlDumpEnvironment = Utils::Environment::systemEnvironment();
- Target *activeTarget = nullptr;
if (project) {
using namespace Utils::Constants;
const QSet<QString> qmlTypeNames = { QML_MIMETYPE ,
@@ -131,14 +127,14 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
&& qmlTypeNames.contains(Utils::mimeTypeForFile(fn->filePath(),
MimeMatchMode::MatchExtension).name());
});
- activeTarget = project->activeTarget();
}
- Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit();
- QtSupport::QtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(activeKit);
+ Kit *activeKit = project ? project->activeKit() : nullptr;
+ Kit *kit = activeKit ? activeKit : KitManager::defaultKit();
+ QtSupport::QtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit);
projectInfo.tryQmlDump = false;
- if (activeTarget) {
+ if (activeKit) {
FilePath baseDir;
auto addAppDir = [&baseDir, &projectInfo](const FilePath &mdir) {
auto dir = mdir.cleanPath();
@@ -154,7 +150,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
projectInfo.applicationDirectories.append(dir);
};
- if (BuildConfiguration *bc = activeTarget->activeBuildConfiguration()) {
+ if (BuildConfiguration *bc = project->activeBuildConfiguration()) {
// Append QML2_IMPORT_PATH if it is defined in build configuration.
// It enables qmlplugindump to correctly dump custom plugins or other dependent
// plugins that are not installed in default Qt qml installation directory.
@@ -174,7 +170,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
// For an IDE things are a bit more complicated because source files might be edited,
// and the directory of the executable might be outdated.
// Here we try to get the directory of the executable, adding all targets
- auto *bs = activeTarget->buildSystem();
+ auto *bs = project->activeBuildSystem();
const auto appTargets = bs ? bs->applicationTargets() : QList<BuildTargetInfo>{};
for (const auto &target : appTargets) {
if (target.targetFilePath.isEmpty())
@@ -205,7 +201,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
auto v = qtVersion->qtVersion();
projectInfo.qmllsPath = ModelManagerInterface::qmllsForBinPath(qtVersion->hostBinPath(), v);
projectInfo.qtVersionString = qtVersion->qtVersionString();
- } else if (!activeKit || !activeKit->value(QtSupport::Constants::FLAGS_SUPPLIES_QTQUICK_IMPORT_PATH, false).toBool()) {
+ } else if (!kit || !kit->value(QtSupport::Constants::FLAGS_SUPPLIES_QTQUICK_IMPORT_PATH, false).toBool()) {
projectInfo.qtQmlPath = FilePath::fromUserInput(QLibraryInfo::path(QLibraryInfo::Qml2ImportsPath));
projectInfo.qmllsPath = ModelManagerInterface::qmllsForBinPath(
FilePath::fromUserInput(QLibraryInfo::path(QLibraryInfo::BinariesPath)), QLibraryInfo::version());
@@ -213,7 +209,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
}
projectInfo.qmlDumpPath.clear();
- const QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(activeKit);
+ const QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(kit);
if (version && projectInfo.tryQmlDump) {
projectInfo.qmlDumpPath = version->qmlplugindumpFilePath();
projectInfo.qmlDumpHasRelocatableFlag = version->hasQmlDumpWithRelocatableFlag();