ProjectExplorer: Add some more functions to buildsteplist

Use those functions instead of repeating code all over the place.

Change-Id: I03161663b4d5c538fb2ea667353ab7846373ad81
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2016-04-19 12:36:11 +02:00
parent 385237dbbd
commit f32a1b1e4c
10 changed files with 45 additions and 60 deletions

View File

@@ -84,29 +84,20 @@ QList<Core::LocatorFilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<
void CMakeLocatorFilter::accept(Core::LocatorFilterEntry selection) const
{
// Get the project containing the target selected
CMakeProject *cmakeProject = 0;
CMakeProject *cmakeProject = nullptr;
foreach (Project *p, SessionManager::projects()) {
cmakeProject = qobject_cast<CMakeProject *>(p);
if (cmakeProject && cmakeProject->projectFilePath().toString() == selection.internalData.toString())
break;
cmakeProject = 0;
}
if (!cmakeProject)
return;
if (!cmakeProject->activeTarget())
return;
if (!cmakeProject->activeTarget()->activeBuildConfiguration())
if (!cmakeProject || !cmakeProject->activeTarget() || !cmakeProject->activeTarget()->activeBuildConfiguration())
return;
// Find the make step
ProjectExplorer::BuildStepList *buildStepList = cmakeProject->activeTarget()->activeBuildConfiguration()
->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
auto buildStep
= qobject_cast<CMakeBuildStep *>(findOrDefault(buildStepList->steps(),
[](BuildStep *s) -> bool { return qobject_cast<CMakeBuildStep *>(s); }));
auto buildStep = buildStepList->firstOfType<CMakeBuildStep>();
if (!buildStep)
return;