diff options
author | hjk <[email protected]> | 2016-05-18 12:37:29 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2016-06-10 10:34:51 +0000 |
commit | 519cc8ded616758cb85857e8845fdc5847339e3a (patch) | |
tree | 04069d8c648a7169008e1a35c057349b358e2f2f /src/plugins/autotoolsprojectmanager/configurestep.cpp | |
parent | 4ce0494284dfc3bf832e54f9315b9bf6d02a4d28 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/plugins/autotoolsprojectmanager/configurestep.cpp')
-rw-r--r-- | src/plugins/autotoolsprojectmanager/configurestep.cpp | 53 |
1 files changed, 7 insertions, 46 deletions
diff --git a/src/plugins/autotoolsprojectmanager/configurestep.cpp b/src/plugins/autotoolsprojectmanager/configurestep.cpp index 530fba28501..f226ecdaf61 100644 --- a/src/plugins/autotoolsprojectmanager/configurestep.cpp +++ b/src/plugins/autotoolsprojectmanager/configurestep.cpp @@ -70,66 +70,27 @@ static QString projectDirRelativeToBuildDir(BuildConfiguration *bc) { ConfigureStepFactory::ConfigureStepFactory(QObject *parent) : IBuildStepFactory(parent) { } -QList<Core::Id> ConfigureStepFactory::availableCreationIds(BuildStepList *parent) const +QList<BuildStepInfo> ConfigureStepFactory::availableSteps(BuildStepList *parent) const { - if (!canHandle(parent)) - return QList<Core::Id>(); - return QList<Core::Id>() << Core::Id(CONFIGURE_STEP_ID); -} + if (parent->target()->project()->id() != Constants::AUTOTOOLS_PROJECT_ID + || parent->id() != ProjectExplorer::Constants::BUILDSTEPS_BUILD) + return {}; -QString ConfigureStepFactory::displayNameForId(Core::Id id) const -{ - if (id == CONFIGURE_STEP_ID) - return tr("Configure", "Display name for AutotoolsProjectManager::ConfigureStep id."); - return QString(); -} - -bool ConfigureStepFactory::canCreate(BuildStepList *parent, Core::Id id) const -{ - return canHandle(parent) && id == CONFIGURE_STEP_ID; + QString display = tr("Configure", "Display name for AutotoolsProjectManager::ConfigureStep id."); + return {{ CONFIGURE_STEP_ID, display }}; } BuildStep *ConfigureStepFactory::create(BuildStepList *parent, Core::Id id) { - if (!canCreate(parent, id)) - return 0; + Q_UNUSED(id) return new ConfigureStep(parent); } -bool ConfigureStepFactory::canClone(BuildStepList *parent, BuildStep *source) const -{ - return canCreate(parent, source->id()); -} - BuildStep *ConfigureStepFactory::clone(BuildStepList *parent, BuildStep *source) { - if (!canClone(parent, source)) - return 0; return new ConfigureStep(parent, static_cast<ConfigureStep *>(source)); } -bool ConfigureStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const -{ - return canCreate(parent, idFromMap(map)); -} - -BuildStep *ConfigureStepFactory::restore(BuildStepList *parent, const QVariantMap &map) -{ - if (!canRestore(parent, map)) - return 0; - ConfigureStep *bs = new ConfigureStep(parent); - if (bs->fromMap(map)) - return bs; - delete bs; - return 0; -} - -bool ConfigureStepFactory::canHandle(BuildStepList *parent) const -{ - if (parent->target()->project()->id() == Constants::AUTOTOOLS_PROJECT_ID) - return parent->id() == ProjectExplorer::Constants::BUILDSTEPS_BUILD; - return false; -} //////////////////////// // ConfigureStep class |