Commit 8b767b4e603b8386a6447c775e3cb3893d32673e

Authored by Scott Klum
1 parent 1e61fbe1

Added some functionality to removetemplates

openbr/plugins/metadata/removetemplates.cpp
@@ -31,15 +31,22 @@ class RemoveTemplatesTransform : public UntrainableMetaTransform @@ -31,15 +31,22 @@ class RemoveTemplatesTransform : public UntrainableMetaTransform
31 Q_OBJECT 31 Q_OBJECT
32 Q_PROPERTY(QString regexp READ get_regexp WRITE set_regexp RESET reset_regexp STORED false) 32 Q_PROPERTY(QString regexp READ get_regexp WRITE set_regexp RESET reset_regexp STORED false)
33 Q_PROPERTY(QString key READ get_key WRITE set_key RESET reset_key STORED false) 33 Q_PROPERTY(QString key READ get_key WRITE set_key RESET reset_key STORED false)
  34 + Q_PROPERTY(bool keep READ get_keep WRITE set_keep RESET reset_keep STORED false)
34 BR_PROPERTY(QString, regexp, "") 35 BR_PROPERTY(QString, regexp, "")
35 BR_PROPERTY(QString, key, "") 36 BR_PROPERTY(QString, key, "")
  37 + BR_PROPERTY(bool, keep, false)
36 38
37 void project(const Template &src, Template &dst) const 39 void project(const Template &src, Template &dst) const
38 { 40 {
39 - const QRegularExpression re(regexp);  
40 - const QRegularExpressionMatch match = re.match(key.isEmpty() ? src.file.suffix() : src.file.get<QString>(key));  
41 - if (match.hasMatch()) dst = Template();  
42 - else dst = src; 41 + dst = src;
  42 + QRegExp re(regexp);
  43 + re.setPatternSyntax(QRegExp::Wildcard);
  44 + bool match = re.exactMatch(key.isEmpty() ? src.file.suffix() : src.file.get<QString>(key));
  45 +
  46 + if (keep && !match)
  47 + dst.file.fte = true;
  48 + else if (!keep && match)
  49 + dst.file.fte = true;
43 } 50 }
44 }; 51 };
45 52