aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/genericprojectmanager/genericmakestep.cpp
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2016-05-18 12:37:29 +0200
committerhjk <hjk@theqtcompany.com>2016-06-10 10:34:51 +0000
commit519cc8ded616758cb85857e8845fdc5847339e3a (patch)
tree04069d8c648a7169008e1a35c057349b358e2f2f /src/plugins/genericprojectmanager/genericmakestep.cpp
parent4ce0494284dfc3bf832e54f9315b9bf6d02a4d28 (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/genericprojectmanager/genericmakestep.cpp')
-rw-r--r--src/plugins/genericprojectmanager/genericmakestep.cpp52
1 files changed, 8 insertions, 44 deletions
diff --git a/src/plugins/genericprojectmanager/genericmakestep.cpp b/src/plugins/genericprojectmanager/genericmakestep.cpp
index f696359bf0..0e581fa155 100644
--- a/src/plugins/genericprojectmanager/genericmakestep.cpp
+++ b/src/plugins/genericprojectmanager/genericmakestep.cpp
@@ -320,17 +320,19 @@ GenericMakeStepFactory::GenericMakeStepFactory(QObject *parent) :
{
}
-bool GenericMakeStepFactory::canCreate(BuildStepList *parent, const Id id) const
+QList<BuildStepInfo> GenericMakeStepFactory::availableSteps(BuildStepList *parent) const
{
- if (parent->target()->project()->id() == Constants::GENERICPROJECT_ID)
- return id == GENERIC_MS_ID;
- return false;
+ if (parent->target()->project()->id() != Constants::GENERICPROJECT_ID)
+ return {};
+
+ return {{ GENERIC_MS_ID,
+ QCoreApplication::translate("GenericProjectManager::Internal::GenericMakeStep",
+ GENERIC_MS_DISPLAY_NAME) }};
}
BuildStep *GenericMakeStepFactory::create(BuildStepList *parent, const Id id)
{
- if (!canCreate(parent, id))
- return 0;
+ Q_UNUSED(id)
GenericMakeStep *step = new GenericMakeStep(parent);
if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) {
step->setClean(true);
@@ -341,50 +343,12 @@ BuildStep *GenericMakeStepFactory::create(BuildStepList *parent, const Id id)
return step;
}
-bool GenericMakeStepFactory::canClone(BuildStepList *parent, BuildStep *source) const
-{
- return canCreate(parent, source->id());
-}
-
BuildStep *GenericMakeStepFactory::clone(BuildStepList *parent, BuildStep *source)
{
- if (!canClone(parent, source))
- return 0;
GenericMakeStep *old(qobject_cast<GenericMakeStep *>(source));
Q_ASSERT(old);
return new GenericMakeStep(parent, old);
}
-bool GenericMakeStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
-{
- return canCreate(parent, idFromMap(map));
-}
-
-BuildStep *GenericMakeStepFactory::restore(BuildStepList *parent, const QVariantMap &map)
-{
- if (!canRestore(parent, map))
- return 0;
- GenericMakeStep *bs(new GenericMakeStep(parent));
- if (bs->fromMap(map))
- return bs;
- delete bs;
- return 0;
-}
-
-QList<Id> GenericMakeStepFactory::availableCreationIds(BuildStepList *parent) const
-{
- if (parent->target()->project()->id() == Constants::GENERICPROJECT_ID)
- return QList<Id>() << Id(GENERIC_MS_ID);
- return QList<Id>();
-}
-
-QString GenericMakeStepFactory::displayNameForId(const Id id) const
-{
- if (id == GENERIC_MS_ID)
- return QCoreApplication::translate("GenericProjectManager::Internal::GenericMakeStep",
- GENERIC_MS_DISPLAY_NAME);
- return QString();
-}
-
} // namespace Internal
} // namespace GenericProjectManager