From 4bb345d2081a64adccd1b6352b724b9086931249 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Thu, 14 Nov 2013 14:57:28 -0500 Subject: [PATCH] changed TemplateList::relabel behavior to preserve integer labels --- openbr/openbr_plugin.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 9322f5d..8860734 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -476,13 +476,18 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) // indexes some property, assigns an integer id to each unique value of propName // stores the index values in "Label" of the output template list -TemplateList TemplateList::relabel(const TemplateList &tl, const QString & propName) +TemplateList TemplateList::relabel(const TemplateList &tl, const QString &propName) { const QList originalLabels = File::get(tl, propName); QHash labelTable; - foreach (const QString & label, originalLabels) - if (!labelTable.contains(label)) - labelTable.insert(label, labelTable.size()); + foreach (const QString &label, originalLabels) + if (!labelTable.contains(label)) { + int value; bool ok; + value = label.toInt(&ok); + // If the label is already an integer value we don't want to change it. + if (ok) labelTable.insert(label, value); + else labelTable.insert(label, labelTable.size()); + } TemplateList result = tl; for (int i=0; i