Commit 4bb345d2081a64adccd1b6352b724b9086931249
1 parent
b29a6349
changed TemplateList::relabel behavior to preserve integer labels
Showing
1 changed file
with
9 additions
and
4 deletions
openbr/openbr_plugin.cpp
| @@ -476,13 +476,18 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) | @@ -476,13 +476,18 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) | ||
| 476 | 476 | ||
| 477 | // indexes some property, assigns an integer id to each unique value of propName | 477 | // indexes some property, assigns an integer id to each unique value of propName |
| 478 | // stores the index values in "Label" of the output template list | 478 | // stores the index values in "Label" of the output template list |
| 479 | -TemplateList TemplateList::relabel(const TemplateList &tl, const QString & propName) | 479 | +TemplateList TemplateList::relabel(const TemplateList &tl, const QString &propName) |
| 480 | { | 480 | { |
| 481 | const QList<QString> originalLabels = File::get<QString>(tl, propName); | 481 | const QList<QString> originalLabels = File::get<QString>(tl, propName); |
| 482 | QHash<QString,int> labelTable; | 482 | QHash<QString,int> labelTable; |
| 483 | - foreach (const QString & label, originalLabels) | ||
| 484 | - if (!labelTable.contains(label)) | ||
| 485 | - labelTable.insert(label, labelTable.size()); | 483 | + foreach (const QString &label, originalLabels) |
| 484 | + if (!labelTable.contains(label)) { | ||
| 485 | + int value; bool ok; | ||
| 486 | + value = label.toInt(&ok); | ||
| 487 | + // If the label is already an integer value we don't want to change it. | ||
| 488 | + if (ok) labelTable.insert(label, value); | ||
| 489 | + else labelTable.insert(label, labelTable.size()); | ||
| 490 | + } | ||
| 486 | 491 | ||
| 487 | TemplateList result = tl; | 492 | TemplateList result = tl; |
| 488 | for (int i=0; i<result.size(); i++) | 493 | for (int i=0; i<result.size(); i++) |