forked from qt-creator/qt-creator
ProjectExplorer: Add a RunConfigurationFactory::canHandle(Target *)
All RunConfiguration factories had some kind of canHandle(Target *) implementation. Centralize this notion. Change-Id: Ie24a355e857bddfd76b866859b8c7a42ffc83840 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "kitinformation.h"
|
||||
#include "runnables.h"
|
||||
#include "session.h"
|
||||
#include "kitinformation.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
@@ -449,6 +450,33 @@ IRunConfigurationFactory::IRunConfigurationFactory(QObject *parent) :
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Specifies a list of device types for which this RunConfigurationFactory
|
||||
can create RunConfiguration.
|
||||
|
||||
Not calling this function or using an empty list means no restriction.
|
||||
*/
|
||||
void IRunConfigurationFactory::setSupportedTargetDeviceTypes(const QList<Core::Id> &ids)
|
||||
{
|
||||
m_supportedTargetDeviceTypes = ids;
|
||||
}
|
||||
|
||||
bool IRunConfigurationFactory::canHandle(Target *target) const
|
||||
{
|
||||
if (m_projectTypeChecker && !m_projectTypeChecker(target->project()))
|
||||
return false;
|
||||
|
||||
if (!target->project()->supportsKit(target->kit()))
|
||||
return false;
|
||||
|
||||
if (!m_supportedTargetDeviceTypes.isEmpty())
|
||||
if (!m_supportedTargetDeviceTypes.contains(
|
||||
DeviceTypeKitInformation::deviceTypeId(target->kit())))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
RunConfiguration *IRunConfigurationFactory::create(Target *parent, Core::Id id)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
|
||||
Reference in New Issue
Block a user