diff --git a/openbr/plugins/gallery.cpp b/openbr/plugins/gallery.cpp index 35b6aad..bb94e02 100644 --- a/openbr/plugins/gallery.cpp +++ b/openbr/plugins/gallery.cpp @@ -117,6 +117,8 @@ class galGallery : public Gallery void write(const Template &t) { + if (t.isEmpty() && t.file.isNull()) + return; stream << t; } }; diff --git a/openbr/plugins/meta.cpp b/openbr/plugins/meta.cpp index a018244..4d058a3 100644 --- a/openbr/plugins/meta.cpp +++ b/openbr/plugins/meta.cpp @@ -15,6 +15,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include +#include #include #include "openbr_internal.h" #include "openbr/core/common.h" diff --git a/openbr/plugins/misc.cpp b/openbr/plugins/misc.cpp index f84e7ea..80407c9 100644 --- a/openbr/plugins/misc.cpp +++ b/openbr/plugins/misc.cpp @@ -423,6 +423,28 @@ class RelabelTransform : public UntrainableMetaTransform BR_REGISTER(Transform, RelabelTransform) +/*! + * \ingroup transforms + * \brief Remove templates with the specified file extension. + * \author Josh Klontz \cite jklontz + */ +class RemoveTemplatesTransform : public UntrainableMetaTransform +{ + Q_OBJECT + Q_PROPERTY(QString regexp READ get_regexp WRITE set_regexp RESET reset_regexp STORED false) + BR_PROPERTY(QString, regexp, "") + + void project(const Template &src, Template &dst) const + { + const QRegularExpression re(regexp); + const QRegularExpressionMatch match = re.match(src.file.suffix()); + if (match.hasMatch()) dst = Template(); + else dst = src; + } +}; + +BR_REGISTER(Transform, RemoveTemplatesTransform) + } #include "misc.moc"