ProjectExplorer: Add subscribeSignal method to targets and projects

Add a subscribeSignal method to targets and projects that will make
sure all signals of all project configurations added during the lifetime
of the project/target will get connected (if the type matches).

Use this to connect to some signal in all BuildConfigurations of
a project and get rid of code that keeps connecting to the current
build configuration.

Use Project::buildEnvironmentChanged as an example and convert its
usages.

Change-Id: I689bcebac4b191bf3f8a18765bf18eaac371c5fe
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tobias Hunger
2017-07-29 23:34:56 +02:00
parent 34456aa906
commit e52ebbf217
17 changed files with 291 additions and 46 deletions

View File

@@ -223,13 +223,6 @@ QString Project::makeUnique(const QString &preferredName, const QStringList &use
return tryName;
}
void Project::changeEnvironment()
{
auto t = qobject_cast<Target *>(sender());
if (t == activeTarget())
emit environmentChanged();
}
void Project::changeBuildConfigurationEnabled()
{
auto t = qobject_cast<Target *>(sender());
@@ -247,7 +240,6 @@ void Project::addTarget(Target *t)
// add it
d->m_targets.push_back(t);
connect(t, &Target::environmentChanged, this, &Project::changeEnvironment);
connect(t, &Target::buildConfigurationEnabledChanged,
this, &Project::changeBuildConfigurationEnabled);
connect(t, &Target::buildDirectoryChanged, this, &Project::onBuildDirectoryChanged);
@@ -306,7 +298,6 @@ void Project::setActiveTarget(Target *target)
d->m_activeTarget = target;
emit activeProjectConfigurationChanged(d->m_activeTarget);
emit activeTargetChanged(d->m_activeTarget);
emit environmentChanged();
emit buildConfigurationEnabledChanged();
}
}