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/projectexplorer/buildstep.h | |
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/projectexplorer/buildstep.h')
-rw-r--r-- | src/plugins/projectexplorer/buildstep.h | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index dfa3c05f2f..dc243a3bcb 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -94,6 +94,25 @@ private: bool m_enabled; }; +class PROJECTEXPLORER_EXPORT BuildStepInfo +{ +public: + enum Flags { + Uncreatable = 1 << 0, + Unclonable = 1 << 1, + UniqueStep = 1 << 8 // Can't be used twice in a BuildStepList + }; + + BuildStepInfo() {} + BuildStepInfo(Core::Id id, const QString &displayName, Flags flags = Flags()) + : id(id), displayName(displayName), flags(flags) + {} + + Core::Id id; + QString displayName; + Flags flags = Flags(); +}; + class PROJECTEXPLORER_EXPORT IBuildStepFactory : public QObject { Q_OBJECT @@ -101,17 +120,9 @@ class PROJECTEXPLORER_EXPORT IBuildStepFactory : public QObject public: explicit IBuildStepFactory(QObject *parent = nullptr); - // used to show the list of possible additons to a target, returns a list of types - virtual QList<Core::Id> availableCreationIds(BuildStepList *parent) const = 0; - // used to translate the types to names to display to the user - virtual QString displayNameForId(Core::Id id) const = 0; - - virtual bool canCreate(BuildStepList *parent, Core::Id id) const = 0; + virtual QList<BuildStepInfo> availableSteps(BuildStepList *parent) const = 0; virtual BuildStep *create(BuildStepList *parent, Core::Id id) = 0; - // used to recreate the runConfigurations when restoring settings - virtual bool canRestore(BuildStepList *parent, const QVariantMap &map) const = 0; - virtual BuildStep *restore(BuildStepList *parent, const QVariantMap &map) = 0; - virtual bool canClone(BuildStepList *parent, BuildStep *product) const = 0; + virtual BuildStep *restore(BuildStepList *parent, const QVariantMap &map); virtual BuildStep *clone(BuildStepList *parent, BuildStep *product) = 0; }; |