diff options
author | hjk <hjk@theqtcompany.com> | 2016-05-18 12:37:29 +0200 |
---|---|---|
committer | hjk <hjk@theqtcompany.com> | 2016-06-10 10:34:51 +0000 |
commit | 519cc8ded616758cb85857e8845fdc5847339e3a (patch) | |
tree | 04069d8c648a7169008e1a35c057349b358e2f2f /src/plugins/autotoolsprojectmanager/makestep.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 <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/autotoolsprojectmanager/makestep.cpp')
-rw-r--r-- | src/plugins/autotoolsprojectmanager/makestep.cpp | 47 |
1 files changed, 5 insertions, 42 deletions
diff --git a/src/plugins/autotoolsprojectmanager/makestep.cpp b/src/plugins/autotoolsprojectmanager/makestep.cpp index ba02a2d440..bc8aacdcb0 100644 --- a/src/plugins/autotoolsprojectmanager/makestep.cpp +++ b/src/plugins/autotoolsprojectmanager/makestep.cpp @@ -62,62 +62,25 @@ const char MAKE_STEP_ADDITIONAL_ARGUMENTS_KEY[] = "AutotoolsProjectManager.MakeS MakeStepFactory::MakeStepFactory(QObject *parent) : IBuildStepFactory(parent) { setObjectName(QLatin1String("Autotools::MakeStepFactory")); } -QList<Core::Id> MakeStepFactory::availableCreationIds(BuildStepList *parent) const +QList<BuildStepInfo> MakeStepFactory::availableSteps(BuildStepList *parent) const { - if (parent->target()->project()->id() == AUTOTOOLS_PROJECT_ID) - return QList<Core::Id>() << Core::Id(MAKE_STEP_ID); - return QList<Core::Id>(); -} - -QString MakeStepFactory::displayNameForId(Core::Id id) const -{ - if (id == MAKE_STEP_ID) - return tr("Make", "Display name for AutotoolsProjectManager::MakeStep id."); - return QString(); -} + if (parent->target()->project()->id() != AUTOTOOLS_PROJECT_ID) + return {}; -bool MakeStepFactory::canCreate(BuildStepList *parent, Core::Id id) const -{ - if (parent->target()->project()->id() == AUTOTOOLS_PROJECT_ID) - return id == MAKE_STEP_ID; - return false; + return {{ MAKE_STEP_ID, tr("Make", "Display name for AutotoolsProjectManager::MakeStep id.") }}; } BuildStep *MakeStepFactory::create(BuildStepList *parent, Core::Id id) { - if (!canCreate(parent, id)) - return 0; + Q_UNUSED(id) return new MakeStep(parent); } -bool MakeStepFactory::canClone(BuildStepList *parent, BuildStep *source) const -{ - return canCreate(parent, source->id()); -} - BuildStep *MakeStepFactory::clone(BuildStepList *parent, BuildStep *source) { - if (!canClone(parent, source)) - return 0; return new MakeStep(parent, static_cast<MakeStep *>(source)); } -bool MakeStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const -{ - return canCreate(parent, idFromMap(map)); -} - -BuildStep *MakeStepFactory::restore(BuildStepList *parent, const QVariantMap &map) -{ - if (!canRestore(parent, map)) - return 0; - MakeStep *bs = new MakeStep(parent); - if (bs->fromMap(map)) - return bs; - delete bs; - return 0; -} - ///////////////////// // MakeStep class ///////////////////// |