Commit dbf6dbd753a948d35341abd547769b0a456019ef
1 parent
a0513c84
added RemoveTemplates transform
Showing
3 changed files
with
25 additions
and
0 deletions
openbr/plugins/gallery.cpp
openbr/plugins/meta.cpp
| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 16 | 16 | |
| 17 | 17 | #include <QFutureSynchronizer> |
| 18 | +#include <QRegularExpression> | |
| 18 | 19 | #include <QtConcurrentRun> |
| 19 | 20 | #include "openbr_internal.h" |
| 20 | 21 | #include "openbr/core/common.h" | ... | ... |
openbr/plugins/misc.cpp
| ... | ... | @@ -423,6 +423,28 @@ class RelabelTransform : public UntrainableMetaTransform |
| 423 | 423 | |
| 424 | 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 | 450 | #include "misc.moc" | ... | ... |