Commit cdd156b029141196ce0b4b96a76c2c56e53f9e9e
1 parent
7d2c5ba7
generalized RemoveTemplatesTransform
Showing
1 changed file
with
4 additions
and
2 deletions
openbr/plugins/misc.cpp
| @@ -424,19 +424,21 @@ BR_REGISTER(Transform, SubjectTransform) | @@ -424,19 +424,21 @@ BR_REGISTER(Transform, SubjectTransform) | ||
| 424 | 424 | ||
| 425 | /*! | 425 | /*! |
| 426 | * \ingroup transforms | 426 | * \ingroup transforms |
| 427 | - * \brief Remove templates with the specified file extension. | 427 | + * \brief Remove templates with the specified file extension or metadata value. |
| 428 | * \author Josh Klontz \cite jklontz | 428 | * \author Josh Klontz \cite jklontz |
| 429 | */ | 429 | */ |
| 430 | class RemoveTemplatesTransform : public UntrainableMetaTransform | 430 | class RemoveTemplatesTransform : public UntrainableMetaTransform |
| 431 | { | 431 | { |
| 432 | Q_OBJECT | 432 | Q_OBJECT |
| 433 | Q_PROPERTY(QString regexp READ get_regexp WRITE set_regexp RESET reset_regexp STORED false) | 433 | Q_PROPERTY(QString regexp READ get_regexp WRITE set_regexp RESET reset_regexp STORED false) |
| 434 | + Q_PROPERTY(QString key READ get_key WRITE set_key RESET reset_key STORED false) | ||
| 434 | BR_PROPERTY(QString, regexp, "") | 435 | BR_PROPERTY(QString, regexp, "") |
| 436 | + BR_PROPERTY(QString, key, "") | ||
| 435 | 437 | ||
| 436 | void project(const Template &src, Template &dst) const | 438 | void project(const Template &src, Template &dst) const |
| 437 | { | 439 | { |
| 438 | const QRegularExpression re(regexp); | 440 | const QRegularExpression re(regexp); |
| 439 | - const QRegularExpressionMatch match = re.match(src.file.suffix()); | 441 | + const QRegularExpressionMatch match = re.match(key.isEmpty() ? src.file.suffix() : src.file.get<QString>(key)); |
| 440 | if (match.hasMatch()) dst = Template(); | 442 | if (match.hasMatch()) dst = Template(); |
| 441 | else dst = src; | 443 | else dst = src; |
| 442 | } | 444 | } |