ProjectExplorer: Expose less direct use of activeTarget etc

The decision should be made closer to the UI triggering it.

Change-Id: Iaed8154dd7daffaae128ec825c6ed1ae7c4c32f5
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2024-10-18 12:13:33 +02:00
parent eccd569562
commit 99a4184761
3 changed files with 2 additions and 23 deletions

View File

@@ -1084,15 +1084,6 @@ void Project::configureAsExampleProject(Kit * /*kit*/)
{ {
} }
void Project::buildTarget(const QString &target)
{
if (!activeTarget() || !activeTarget()->activeBuildConfiguration()
|| !activeTarget()->activeBuildConfiguration()->buildSystem()) {
return;
}
activeTarget()->activeBuildConfiguration()->buildSystem()->buildNamedTarget(target);
}
bool Project::hasMakeInstallEquivalent() const bool Project::hasMakeInstallEquivalent() const
{ {
return d->m_hasMakeInstallEquivalent; return d->m_hasMakeInstallEquivalent;

View File

@@ -131,8 +131,6 @@ public:
bool needsBuildConfigurations() const; bool needsBuildConfigurations() const;
virtual void configureAsExampleProject(ProjectExplorer::Kit *kit); virtual void configureAsExampleProject(ProjectExplorer::Kit *kit);
void buildTarget(const QString &target);
virtual ProjectImporter *projectImporter() const; virtual ProjectImporter *projectImporter() const;
virtual DeploymentKnowledge deploymentKnowledge() const { return DeploymentKnowledge::Bad; } virtual DeploymentKnowledge deploymentKnowledge() const { return DeploymentKnowledge::Bad; }

View File

@@ -113,30 +113,20 @@ void QmlTaskManager::updateMessages()
m_updateDelay.start(); m_updateDelay.start();
} }
static void triggerQmllintCMakeTarget()
{
if (ProjectManager::startupProject())
ProjectManager::startupProject()->buildTarget(Constants::QMLLINT_BUILD_TARGET);
}
void QmlTaskManager::updateSemanticMessagesNow() void QmlTaskManager::updateSemanticMessagesNow()
{ {
// note: this can only be called for the startup project // note: this can only be called for the startup project
Project *project = ProjectManager::startupProject();
if (!project)
return;
BuildSystem *buildSystem = ProjectManager::startupBuildSystem(); BuildSystem *buildSystem = ProjectManager::startupBuildSystem();
if (!buildSystem) if (!buildSystem)
return; return;
const bool isCMake = buildSystem->name() == "cmake"; const bool isCMake = buildSystem->name() == "cmake";
// heuristic: qmllint will output meaningful warnings if qmlls is enabled // heuristic: qmllint will output meaningful warnings if qmlls is enabled
if (isCMake && QmllsSettingsManager::instance()->useQmlls(project)) { if (isCMake && QmllsSettingsManager::instance()->useQmlls(buildSystem->project())) {
// abort any update that's going on already, and remove old codemodel warnings // abort any update that's going on already, and remove old codemodel warnings
m_messageCollector.cancel(); m_messageCollector.cancel();
removeAllTasks(true); removeAllTasks(true);
triggerQmllintCMakeTarget(); buildSystem->buildTarget(Constants::QMLLINT_BUILD_TARGET);
return; return;
} }