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/ios/iosdeploystepfactory.cpp | |
parent | 4ce0494284dfc3bf832e54f9315b9bf6d02a4d28 (diff) | |
download | qt-creator-519cc8ded616758cb85857e8845fdc5847339e3a.tar.gz |
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/ios/iosdeploystepfactory.cpp')
-rw-r--r-- | src/plugins/ios/iosdeploystepfactory.cpp | 49 |
1 files changed, 6 insertions, 43 deletions
diff --git a/src/plugins/ios/iosdeploystepfactory.cpp b/src/plugins/ios/iosdeploystepfactory.cpp index 7f61b5fecd..b2bc8b4a83 100644 --- a/src/plugins/ios/iosdeploystepfactory.cpp +++ b/src/plugins/ios/iosdeploystepfactory.cpp @@ -46,60 +46,23 @@ IosDeployStepFactory::IosDeployStepFactory(QObject *parent) { } -QList<Core::Id> IosDeployStepFactory::availableCreationIds(BuildStepList *parent) const +QList<BuildStepInfo> IosDeployStepFactory::availableSteps(BuildStepList *parent) const { - if (parent->id() != ProjectExplorer::Constants::BUILDSTEPS_DEPLOY) - return QList<Core::Id>(); - if (!IosManager::supportsIos(parent->target())) - return QList<Core::Id>(); - if (parent->contains(IosDeployStep::Id)) - return QList<Core::Id>(); - return QList<Core::Id>() << IosDeployStep::Id; -} - -QString IosDeployStepFactory::displayNameForId(Core::Id id) const -{ - if (id == IosDeployStep::Id) - return tr("Deploy to iOS device or emulator"); - return QString(); -} - -bool IosDeployStepFactory::canCreate(BuildStepList *parent, Core::Id id) const -{ - return availableCreationIds(parent).contains(id); + if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_DEPLOY + && IosManager::supportsIos(parent->target()) + && !parent->contains(IosDeployStep::Id)) + return {{ IosDeployStep::Id, tr("Deploy to iOS device or emulator") }}; + return {}; } BuildStep *IosDeployStepFactory::create(BuildStepList *parent, Core::Id id) { - Q_ASSERT(canCreate(parent, id)); Q_UNUSED(id); return new IosDeployStep(parent); } -bool IosDeployStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const -{ - return canCreate(parent, idFromMap(map)); -} - -BuildStep *IosDeployStepFactory::restore(BuildStepList *parent, const QVariantMap &map) -{ - Q_ASSERT(canRestore(parent, map)); - IosDeployStep * const step = new IosDeployStep(parent); - if (!step->fromMap(map)) { - delete step; - return 0; - } - return step; -} - -bool IosDeployStepFactory::canClone(BuildStepList *parent, BuildStep *product) const -{ - return canCreate(parent, product->id()); -} - BuildStep *IosDeployStepFactory::clone(BuildStepList *parent, BuildStep *product) { - Q_ASSERT(canClone(parent, product)); return new IosDeployStep(parent, static_cast<IosDeployStep *>(product)); } |