Commit dbf6dbd753a948d35341abd547769b0a456019ef

Authored by Josh Klontz
1 parent a0513c84

added RemoveTemplates transform

openbr/plugins/gallery.cpp
@@ -117,6 +117,8 @@ class galGallery : public Gallery @@ -117,6 +117,8 @@ class galGallery : public Gallery
117 117
118 void write(const Template &t) 118 void write(const Template &t)
119 { 119 {
  120 + if (t.isEmpty() && t.file.isNull())
  121 + return;
120 stream << t; 122 stream << t;
121 } 123 }
122 }; 124 };
openbr/plugins/meta.cpp
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <QFutureSynchronizer> 17 #include <QFutureSynchronizer>
  18 +#include <QRegularExpression>
18 #include <QtConcurrentRun> 19 #include <QtConcurrentRun>
19 #include "openbr_internal.h" 20 #include "openbr_internal.h"
20 #include "openbr/core/common.h" 21 #include "openbr/core/common.h"
openbr/plugins/misc.cpp
@@ -423,6 +423,28 @@ class RelabelTransform : public UntrainableMetaTransform @@ -423,6 +423,28 @@ class RelabelTransform : public UntrainableMetaTransform
423 423
424 BR_REGISTER(Transform, RelabelTransform) 424 BR_REGISTER(Transform, RelabelTransform)
425 425
  426 +/*!
  427 + * \ingroup transforms
  428 + * \brief Remove templates with the specified file extension.
  429 + * \author Josh Klontz \cite jklontz
  430 + */
  431 +class RemoveTemplatesTransform : public UntrainableMetaTransform
  432 +{
  433 + Q_OBJECT
  434 + Q_PROPERTY(QString regexp READ get_regexp WRITE set_regexp RESET reset_regexp STORED false)
  435 + BR_PROPERTY(QString, regexp, "")
  436 +
  437 + void project(const Template &src, Template &dst) const
  438 + {
  439 + const QRegularExpression re(regexp);
  440 + const QRegularExpressionMatch match = re.match(src.file.suffix());
  441 + if (match.hasMatch()) dst = Template();
  442 + else dst = src;
  443 + }
  444 +};
  445 +
  446 +BR_REGISTER(Transform, RemoveTemplatesTransform)
  447 +
426 } 448 }
427 449
428 #include "misc.moc" 450 #include "misc.moc"