From 04ae926e8d49e66571e966cd828e75ae97a01489 Mon Sep 17 00:00:00 2001 From: Austin Blanton Date: Thu, 25 Sep 2014 11:44:30 -0400 Subject: [PATCH] Add transform to filter templates based on a metadata ID --- openbr/plugins/template.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+), 0 deletions(-) diff --git a/openbr/plugins/template.cpp b/openbr/plugins/template.cpp index 7ef2846..b771c4f 100644 --- a/openbr/plugins/template.cpp +++ b/openbr/plugins/template.cpp @@ -176,6 +176,37 @@ class SelectPointsTransform : public UntrainableMetadataTransform BR_REGISTER(Transform, SelectPointsTransform) +/*! + * \ingroup transforms + * \brief Removes duplicate templates based on a unique metadata key + * \author Austin Blanton \cite imaus10 + */ +class FilterDupeMetadataTransform : public TimeVaryingTransform +{ + Q_OBJECT + + Q_PROPERTY(QString key READ get_key WRITE set_key RESET reset_key STORED false) + BR_PROPERTY(QString, key, "TemplateID") + + QSet excluded; + + void projectUpdate(const TemplateList &src, TemplateList &dst) + { + foreach (const Template &t, src) { + QString id = t.file.get(key); + if (!excluded.contains(id)) { + dst.append(t); + excluded.insert(id); + } + } + } + +public: + FilterDupeMetadataTransform() : TimeVaryingTransform(false,false) {} +}; + +BR_REGISTER(Transform, FilterDupeMetadataTransform) + } // namespace br #include "template.moc" -- libgit2 0.21.4