From 8b767b4e603b8386a6447c775e3cb3893d32673e Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Tue, 6 Oct 2015 16:27:55 -0400 Subject: [PATCH] Added some functionality to removetemplates --- openbr/plugins/metadata/removetemplates.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/openbr/plugins/metadata/removetemplates.cpp b/openbr/plugins/metadata/removetemplates.cpp index ec8f76d..ac704f3 100644 --- a/openbr/plugins/metadata/removetemplates.cpp +++ b/openbr/plugins/metadata/removetemplates.cpp @@ -31,15 +31,22 @@ class RemoveTemplatesTransform : public UntrainableMetaTransform Q_OBJECT Q_PROPERTY(QString regexp READ get_regexp WRITE set_regexp RESET reset_regexp STORED false) Q_PROPERTY(QString key READ get_key WRITE set_key RESET reset_key STORED false) + Q_PROPERTY(bool keep READ get_keep WRITE set_keep RESET reset_keep STORED false) BR_PROPERTY(QString, regexp, "") BR_PROPERTY(QString, key, "") + BR_PROPERTY(bool, keep, false) void project(const Template &src, Template &dst) const { - const QRegularExpression re(regexp); - const QRegularExpressionMatch match = re.match(key.isEmpty() ? src.file.suffix() : src.file.get(key)); - if (match.hasMatch()) dst = Template(); - else dst = src; + dst = src; + QRegExp re(regexp); + re.setPatternSyntax(QRegExp::Wildcard); + bool match = re.exactMatch(key.isEmpty() ? src.file.suffix() : src.file.get(key)); + + if (keep && !match) + dst.file.fte = true; + else if (!keep && match) + dst.file.fte = true; } }; -- libgit2 0.21.4