diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index 9c7f5ee2a59db83becbbde2f79497fdce44b09a3..395a126ec95c1d382f87445d211e97a321b9a427 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -251,6 +251,11 @@ void Project::addTarget(Target *t) connect(t, &Target::buildConfigurationEnabledChanged, this, &Project::changeBuildConfigurationEnabled); connect(t, &Target::buildDirectoryChanged, this, &Project::onBuildDirectoryChanged); + connect(t, &Target::addedProjectConfiguration, this, &Project::addedProjectConfiguration); + connect(t, &Target::aboutToRemoveProjectConfiguration, this, &Project::aboutToRemoveProjectConfiguration); + connect(t, &Target::removedProjectConfiguration, this, &Project::removedProjectConfiguration); + connect(t, &Target::activeProjectConfigurationChanged, this, &Project::activeProjectConfigurationChanged); + emit addedProjectConfiguration(t); emit addedTarget(t); // check activeTarget: @@ -274,9 +279,11 @@ bool Project::removeTarget(Target *target) SessionManager::setActiveTarget(this, d->m_targets.at(0), SetActive::Cascade); } + emit aboutToRemoveProjectConfiguration(target); emit aboutToRemoveTarget(target); d->m_targets.removeOne(target); emit removedTarget(target); + emit removedProjectConfiguration(target); delete target; return true; @@ -297,6 +304,7 @@ void Project::setActiveTarget(Target *target) if ((!target && !d->m_targets.isEmpty()) || (target && d->m_targets.contains(target) && d->m_activeTarget != target)) { d->m_activeTarget = target; + emit activeProjectConfigurationChanged(); emit activeTargetChanged(d->m_activeTarget); emit environmentChanged(); emit buildConfigurationEnabledChanged(); diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index 4a11a1b32bdc5d47e46d17809065a132a9bb21cf..71bc92042a7e9d7bbcde9ddce06c63aa3aae91de 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -49,6 +49,7 @@ class ContainerNode; class EditorConfiguration; class NamedWidget; class Node; +class ProjectConfiguration; class ProjectImporter; class ProjectNode; class ProjectPrivate; @@ -174,6 +175,15 @@ signals: // Note: activeTarget can be 0 (if no targets are defined). void activeTargetChanged(ProjectExplorer::Target *target); + void aboutToRemoveProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc); + void removedProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc); + void addedProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc); + + // *ANY* active project configuration changed somewhere in the tree. This might not be + // the one that would get started right now, since some part of the tree in between might + // not be active. + void activeProjectConfigurationChanged(); + void aboutToRemoveTarget(ProjectExplorer::Target *target); void removedTarget(ProjectExplorer::Target *target); void addedTarget(ProjectExplorer::Target *target); diff --git a/src/plugins/projectexplorer/target.cpp b/src/plugins/projectexplorer/target.cpp index 3b480e8266ea3448f5b1061ce59eb8a17658858f..fc5d330d2ec5adf91176e85550b9c2b6df47e16c 100644 --- a/src/plugins/projectexplorer/target.cpp +++ b/src/plugins/projectexplorer/target.cpp @@ -238,6 +238,7 @@ void Target::addBuildConfiguration(BuildConfiguration *bc) // add it d->m_buildConfigurations.push_back(bc); + emit addedProjectConfiguration(bc); emit addedBuildConfiguration(bc); connect(bc, &BuildConfiguration::environmentChanged, @@ -261,8 +262,9 @@ bool Target::removeBuildConfiguration(BuildConfiguration *bc) return false; d->m_buildConfigurations.removeOne(bc); + emit aboutToRemoveProjectConfiguration(bc); + d->m_buildConfigurations.removeOne(bc); - emit removedBuildConfiguration(bc); if (activeBuildConfiguration() == bc) { if (d->m_buildConfigurations.isEmpty()) @@ -271,6 +273,9 @@ bool Target::removeBuildConfiguration(BuildConfiguration *bc) SessionManager::setActiveBuildConfiguration(this, d->m_buildConfigurations.at(0), SetActive::Cascade); } + emit removedBuildConfiguration(bc); + emit removedProjectConfiguration(bc); + delete bc; return true; } @@ -285,12 +290,13 @@ BuildConfiguration *Target::activeBuildConfiguration() const return d->m_activeBuildConfiguration; } -void Target::setActiveBuildConfiguration(BuildConfiguration *configuration) +void Target::setActiveBuildConfiguration(BuildConfiguration *bc) { - if ((!configuration && d->m_buildConfigurations.isEmpty()) || - (configuration && d->m_buildConfigurations.contains(configuration) && - configuration != d->m_activeBuildConfiguration)) { - d->m_activeBuildConfiguration = configuration; + if ((!bc && d->m_buildConfigurations.isEmpty()) || + (bc && d->m_buildConfigurations.contains(bc) && + bc != d->m_activeBuildConfiguration)) { + d->m_activeBuildConfiguration = bc; + emit activeProjectConfigurationChanged(); emit activeBuildConfigurationChanged(d->m_activeBuildConfiguration); emit environmentChanged(); emit buildConfigurationEnabledChanged(); @@ -318,6 +324,7 @@ void Target::addDeployConfiguration(DeployConfiguration *dc) connect(dc, &DeployConfiguration::enabledChanged, this, &Target::changeDeployConfigurationEnabled); + emit addedProjectConfiguration(dc); emit addedDeployConfiguration(dc); if (!d->m_activeDeployConfiguration) @@ -334,10 +341,9 @@ bool Target::removeDeployConfiguration(DeployConfiguration *dc) if (BuildManager::isBuilding(dc)) return false; + emit aboutToRemoveProjectConfiguration(dc); d->m_deployConfigurations.removeOne(dc); - emit removedDeployConfiguration(dc); - if (activeDeployConfiguration() == dc) { if (d->m_deployConfigurations.isEmpty()) SessionManager::setActiveDeployConfiguration(this, nullptr, SetActive::Cascade); @@ -346,6 +352,9 @@ bool Target::removeDeployConfiguration(DeployConfiguration *dc) SetActive::Cascade); } + emit removedProjectConfiguration(dc); + emit removedDeployConfiguration(dc); + delete dc; return true; } @@ -366,6 +375,7 @@ void Target::setActiveDeployConfiguration(DeployConfiguration *dc) (dc && d->m_deployConfigurations.contains(dc) && dc != d->m_activeDeployConfiguration)) { d->m_activeDeployConfiguration = dc; + emit activeProjectConfigurationChanged(); emit activeDeployConfigurationChanged(d->m_activeDeployConfiguration); emit deployConfigurationEnabledChanged(); } @@ -419,6 +429,7 @@ void Target::addRunConfiguration(RunConfiguration *rc) connect(rc, &RunConfiguration::enabledChanged, this, &Target::changeRunConfigurationEnabled); + emit addedProjectConfiguration(rc); emit addedRunConfiguration(rc); if (!activeRunConfiguration()) @@ -429,6 +440,7 @@ void Target::removeRunConfiguration(RunConfiguration *rc) { QTC_ASSERT(rc && d->m_runConfigurations.contains(rc), return); + emit aboutToRemoveProjectConfiguration(rc); d->m_runConfigurations.removeOne(rc); if (activeRunConfiguration() == rc) { @@ -439,6 +451,8 @@ void Target::removeRunConfiguration(RunConfiguration *rc) } emit removedRunConfiguration(rc); + emit removedProjectConfiguration(rc); + delete rc; } @@ -453,6 +467,7 @@ void Target::setActiveRunConfiguration(RunConfiguration *rc) (rc && d->m_runConfigurations.contains(rc) && rc != d->m_activeRunConfiguration)) { d->m_activeRunConfiguration = rc; + emit activeProjectConfigurationChanged(); emit activeRunConfigurationChanged(d->m_activeRunConfiguration); emit runConfigurationEnabledChanged(); } diff --git a/src/plugins/projectexplorer/target.h b/src/plugins/projectexplorer/target.h index e74b29793d5c027a1649ea28516234427d227740..0725390d3033f9005ddb621e3c604b43eec9e06b 100644 --- a/src/plugins/projectexplorer/target.h +++ b/src/plugins/projectexplorer/target.h @@ -61,8 +61,8 @@ public: Kit *kit() const; // Build configuration - void addBuildConfiguration(BuildConfiguration *configuration); - bool removeBuildConfiguration(BuildConfiguration *configuration); + void addBuildConfiguration(BuildConfiguration *bc); + bool removeBuildConfiguration(BuildConfiguration *bc); QList<BuildConfiguration *> buildConfigurations() const; BuildConfiguration *activeBuildConfiguration() const; @@ -82,11 +82,11 @@ public: // Running QList<RunConfiguration *> runConfigurations() const; - void addRunConfiguration(RunConfiguration *runConfiguration); - void removeRunConfiguration(RunConfiguration *runConfiguration); + void addRunConfiguration(RunConfiguration *rc); + void removeRunConfiguration(RunConfiguration *rc); RunConfiguration *activeRunConfiguration() const; - void setActiveRunConfiguration(RunConfiguration *runConfiguration); + void setActiveRunConfiguration(RunConfiguration *rc); // Returns whether this target is actually available at he time // of the call. A target may become unavailable e.g. when a Qt version @@ -115,6 +115,12 @@ signals: void kitChanged(); + void aboutToRemoveProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc); + void removedProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc); + void addedProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc); + + void activeProjectConfigurationChanged(); + // TODO clean up signal names // might be better to also have aboutToRemove signals void removedRunConfiguration(ProjectExplorer::RunConfiguration *rc);