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:
@@ -55,67 +55,27 @@ const char AUTORECONF_ADDITIONAL_ARGUMENTS_KEY[] = "AutotoolsProjectManager.Auto
|
||||
AutoreconfStepFactory::AutoreconfStepFactory(QObject *parent) : IBuildStepFactory(parent)
|
||||
{ }
|
||||
|
||||
QList<Core::Id> AutoreconfStepFactory::availableCreationIds(BuildStepList *parent) const
|
||||
QList<BuildStepInfo> AutoreconfStepFactory::availableSteps(BuildStepList *parent) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
return QList<Core::Id>();
|
||||
return QList<Core::Id>() << Core::Id(AUTORECONF_STEP_ID);
|
||||
}
|
||||
if (parent->target()->project()->id() != Constants::AUTOTOOLS_PROJECT_ID
|
||||
|| parent->id() != ProjectExplorer::Constants::BUILDSTEPS_BUILD)
|
||||
return {};
|
||||
|
||||
QString AutoreconfStepFactory::displayNameForId(Core::Id id) const
|
||||
{
|
||||
if (id == AUTORECONF_STEP_ID)
|
||||
return tr("Autoreconf", "Display name for AutotoolsProjectManager::AutoreconfStep id.");
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool AutoreconfStepFactory::canCreate(BuildStepList *parent, Core::Id id) const
|
||||
{
|
||||
return canHandle(parent) && Core::Id(AUTORECONF_STEP_ID) == id;
|
||||
QString display = tr("Autoreconf", "Display name for AutotoolsProjectManager::AutoreconfStep id.");
|
||||
return {{ AUTORECONF_STEP_ID, display }};
|
||||
}
|
||||
|
||||
BuildStep *AutoreconfStepFactory::create(BuildStepList *parent, Core::Id id)
|
||||
{
|
||||
if (!canCreate(parent, id))
|
||||
return 0;
|
||||
Q_UNUSED(id);
|
||||
return new AutoreconfStep(parent);
|
||||
}
|
||||
|
||||
bool AutoreconfStepFactory::canClone(BuildStepList *parent, BuildStep *source) const
|
||||
{
|
||||
return canCreate(parent, source->id());
|
||||
}
|
||||
|
||||
BuildStep *AutoreconfStepFactory::clone(BuildStepList *parent, BuildStep *source)
|
||||
{
|
||||
if (!canClone(parent, source))
|
||||
return 0;
|
||||
return new AutoreconfStep(parent, static_cast<AutoreconfStep *>(source));
|
||||
}
|
||||
|
||||
bool AutoreconfStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
|
||||
{
|
||||
return canCreate(parent, idFromMap(map));
|
||||
}
|
||||
|
||||
BuildStep *AutoreconfStepFactory::restore(BuildStepList *parent, const QVariantMap &map)
|
||||
{
|
||||
if (!canRestore(parent, map))
|
||||
return 0;
|
||||
AutoreconfStep *bs = new AutoreconfStep(parent);
|
||||
if (bs->fromMap(map))
|
||||
return bs;
|
||||
delete bs;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AutoreconfStepFactory::canHandle(BuildStepList *parent) const
|
||||
{
|
||||
if (parent->target()->project()->id() == Constants::AUTOTOOLS_PROJECT_ID)
|
||||
return parent->id() == ProjectExplorer::Constants::BUILDSTEPS_BUILD;
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// AutoreconfStep class
|
||||
/////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user