From 8d9445fe5da1dbc399ca53c7f826dfa0cc80902e Mon Sep 17 00:00:00 2001 From: sklum Date: Wed, 7 Aug 2013 10:24:44 -0700 Subject: [PATCH] Fixed bugs with MetadataDistance --- openbr/plugins/validate.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/openbr/plugins/validate.cpp b/openbr/plugins/validate.cpp index 8b3a174..f2f7b96 100644 --- a/openbr/plugins/validate.cpp +++ b/openbr/plugins/validate.cpp @@ -147,26 +147,29 @@ class MetadataDistance : public Distance float compare(const Template &a, const Template &b) const { foreach (const QString &key, filters) { + QString aValue = a.file.get(key, QString()); + QString bValue = b.file.get(key, QString()); - const QString aValue = a.file.get(key, ""); - const QString bValue = b.file.get(key, ""); + // The query value may be a range. Let's check. + if (bValue.isEmpty()) bValue = QtUtils::toString(b.file.get(key, QPointF())); if (aValue.isEmpty() || bValue.isEmpty()) continue; bool keep = false; + bool ok; - if (aValue[0] == '(') /* Range */ { - QStringList values = aValue.split(','); + QPointF range = QtUtils::toPoint(bValue,&ok); - int value = values[0].mid(1).toInt(); - values[1].chop(1); - int upperBound = values[1].toInt(); + if (ok) /* Range */ { + int value = range.x(); + int upperBound = range.y(); while (value <= upperBound) { - if (aValue == bValue) { + if (aValue == QString::number(value)) { keep = true; break; } + value++; } } else if (aValue == bValue) keep = true; -- libgit2 0.21.4