Commit 0306db6724660f3773f38aca561aebeec2337f7f
1 parent
0978a74d
Added Retain Transform, which retains on listed key/value pairs in a File's local metadata
Showing
3 changed files
with
32 additions
and
3 deletions
openbr/openbr_plugin.cpp
| ... | ... | @@ -410,7 +410,6 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) |
| 410 | 410 | } else if (newTemplates[i].file.getBool("allPartitions")) { |
| 411 | 411 | // The allPartitions flag is used to add an extended set |
| 412 | 412 | // of target images to every partition |
| 413 | - | |
| 414 | 413 | newTemplates[i].file.set("Partition", -1); |
| 415 | 414 | } else { |
| 416 | 415 | const QByteArray md5 = QCryptographicHash::hash(newTemplates[i].file.get<QString>("Subject").toLatin1(), QCryptographicHash::Md5); | ... | ... |
openbr/plugins/template.cpp
0 → 100644
| 1 | +#include "openbr_internal.h" | |
| 2 | + | |
| 3 | +namespace br | |
| 4 | +{ | |
| 5 | + | |
| 6 | +/*! | |
| 7 | + * \ingroup transforms | |
| 8 | + * \brief Retains only the values for the keys listed, to reduce template size | |
| 9 | + * \author Scott Klum \cite sklum | |
| 10 | + */ | |
| 11 | +class RetainTransform : public UntrainableTransform | |
| 12 | +{ | |
| 13 | + Q_OBJECT | |
| 14 | + Q_PROPERTY(QStringList keys READ get_keys WRITE set_keys RESET reset_keys STORED false) | |
| 15 | + BR_PROPERTY(QStringList, keys, QStringList()) | |
| 16 | + | |
| 17 | + void project(const Template &src, Template &dst) const | |
| 18 | + { | |
| 19 | + dst = src; | |
| 20 | + foreach(const QString& localKey, dst.file.localKeys()) { | |
| 21 | + if (!keys.contains(localKey)) dst.file.remove(localKey); | |
| 22 | + } | |
| 23 | + } | |
| 24 | +}; | |
| 25 | + | |
| 26 | +BR_REGISTER(Transform, RetainTransform) | |
| 27 | + | |
| 28 | +} // namespace br | |
| 29 | + | |
| 30 | +#include "template.moc" | ... | ... |
openbr/plugins/validate.cpp
| ... | ... | @@ -157,11 +157,11 @@ class MetadataDistance : public Distance |
| 157 | 157 | if (aValue[0] == '(') /* Range */ { |
| 158 | 158 | QStringList values = aValue.split(','); |
| 159 | 159 | |
| 160 | - int age = values[0].mid(1).toInt(); | |
| 160 | + int value = values[0].mid(1).toInt(); | |
| 161 | 161 | values[1].chop(1); |
| 162 | 162 | int upperBound = values[1].toInt(); |
| 163 | 163 | |
| 164 | - while (age <= upperBound) { | |
| 164 | + while (value <= upperBound) { | |
| 165 | 165 | if (aValue == bValue) { |
| 166 | 166 | keep = true; |
| 167 | 167 | break; | ... | ... |