ProjectExplorer: Add a ProjectConfiguration::target()

... with a suitable default implementation accessing a member
populated at construction time instead of walking the parent
chains on each access.

Change-Id: I58dae6da80ed0b023cc603fca13a5a205b123672
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-07-26 16:08:13 +02:00
parent 8493a6b044
commit d16330de6d
16 changed files with 42 additions and 79 deletions

View File

@@ -46,6 +46,7 @@ const char STEPS_PREFIX[] = "ProjectExplorer.BuildStepList.Step.";
BuildStepList::BuildStepList(QObject *parent, Core::Id id)
: ProjectConfiguration(parent, id)
{
QTC_CHECK(parent && parent->parent() && parent->parent() == target());
if (id == Constants::BUILDSTEPS_BUILD) {
//: Display name of the build build step list. Used as part of the labels in the project window.
setDefaultDisplayName(tr("Build"));
@@ -192,20 +193,3 @@ BuildStep *BuildStepList::at(int position)
{
return m_steps.at(position);
}
Target *BuildStepList::target() const
{
Q_ASSERT(parent());
auto bc = qobject_cast<BuildConfiguration *>(parent());
if (bc)
return bc->target();
auto dc = qobject_cast<DeployConfiguration *>(parent());
if (dc)
return dc->target();
return nullptr;
}
Project *BuildStepList::project() const
{
return target()->project();
}