forked from qt-creator/qt-creator
ProjectExplorer: De-duplicate code in IBuildStepFactory derived classes
This removes 900 lines of duplicated code, some duplicated checks at runtime and some (minor) quadratic behavior when gathering display names. canClone(), canRestore() and canCreate() and restore() use the same pattern. Handle that on the core side once. Leave retore() virtual to let the ios code unmodified (which is likely not needed, later...). Introduce 'Unclonable' and 'Uncreatable' flags to keep Android package installation and WinRT deployment (non-)functionality unchanged. Change-Id: I0325479aff818a4038b2f241ca733b8d8cd66f2f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -837,67 +837,27 @@ QMakeStepFactory::QMakeStepFactory(QObject *parent) :
|
||||
{
|
||||
}
|
||||
|
||||
bool QMakeStepFactory::canCreate(BuildStepList *parent, Core::Id id) const
|
||||
QList<BuildStepInfo> QMakeStepFactory::availableSteps(BuildStepList *parent) const
|
||||
{
|
||||
if (parent->id() != ProjectExplorer::Constants::BUILDSTEPS_BUILD)
|
||||
return false;
|
||||
return {};
|
||||
if (!qobject_cast<QmakeBuildConfiguration *>(parent->parent()))
|
||||
return false;
|
||||
return id == QMAKE_BS_ID;
|
||||
return {};
|
||||
|
||||
return {{ QMAKE_BS_ID, tr("qmake"), BuildStepInfo::UniqueStep }};
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStep *QMakeStepFactory::create(BuildStepList *parent, Core::Id id)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return nullptr;
|
||||
Q_UNUSED(id)
|
||||
return new QMakeStep(parent);
|
||||
}
|
||||
|
||||
bool QMakeStepFactory::canClone(BuildStepList *parent, BuildStep *source) const
|
||||
{
|
||||
return canCreate(parent, source->id());
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStep *QMakeStepFactory::clone(BuildStepList *parent, ProjectExplorer::BuildStep *source)
|
||||
{
|
||||
if (!canClone(parent, source))
|
||||
return nullptr;
|
||||
return new QMakeStep(parent, qobject_cast<QMakeStep *>(source));
|
||||
}
|
||||
|
||||
bool QMakeStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
|
||||
{
|
||||
return canCreate(parent, ProjectExplorer::idFromMap(map));
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStep *QMakeStepFactory::restore(BuildStepList *parent, const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return nullptr;
|
||||
QMakeStep *bs = new QMakeStep(parent);
|
||||
if (bs->fromMap(map))
|
||||
return bs;
|
||||
delete bs;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QList<Core::Id> QMakeStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const
|
||||
{
|
||||
if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_BUILD)
|
||||
if (QmakeBuildConfiguration *bc = qobject_cast<QmakeBuildConfiguration *>(parent->parent()))
|
||||
if (!bc->qmakeStep())
|
||||
return QList<Core::Id>() << Core::Id(QMAKE_BS_ID);
|
||||
return QList<Core::Id>();
|
||||
}
|
||||
|
||||
QString QMakeStepFactory::displayNameForId(Core::Id id) const
|
||||
{
|
||||
if (id == QMAKE_BS_ID)
|
||||
return tr("qmake");
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
QMakeStepConfig::TargetArchConfig QMakeStepConfig::targetArchFor(const Abi &targetAbi, const BaseQtVersion *version)
|
||||
{
|
||||
QMakeStepConfig::TargetArchConfig arch = QMakeStepConfig::NoArch;
|
||||
|
||||
Reference in New Issue
Block a user