Hi, I have a minor usability issue with the tag template comboboxes. If translations are enabled their content stays in the order of the English tag names. This makes the combobox appear like a large unsorted list, especially for 'amenity'. It's very hard to find a certain item, even if you know what you're looking for. See the attached screenshot.
I've tried to sort the items by label; see the attached patch. This works well for amenities. But then also the 'highway' and 'place' items are sorted by label which should probably stay in their hierarchical order. Maybe an optional attribute like order="strict" could be added to the template file schema. What do you think? Kind regards, Hermann
<<inline: tag-dropdown.png>>
diff --git a/src/TagTemplate/TagTemplate.cpp b/src/TagTemplate/TagTemplate.cpp
index 64f9934..a509f1e 100644
--- a/src/TagTemplate/TagTemplate.cpp
+++ b/src/TagTemplate/TagTemplate.cpp
@@ -24,6 +24,7 @@
#include <QGroupBox>
#include <QLineEdit>
#include <QRegExp>
+#include <QMultiMap>
/** TagTemplateWidget **/
@@ -193,19 +194,23 @@ QWidget* TagTemplateWidgetCombo::getWidget(const MapFeature* F)
aCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
aLayout->addWidget(aCombo);
- aCombo->addItem(tr("Undefined"), qVariantFromValue(new TagTemplateWidgetValue("__NULL__")));
- QString val = F->tagValue(theTag, "__NULL__");
- int idx = -1;
+ QMultiMap<QString, TagTemplateWidgetValue*>* comboItems = new QMultiMap<QString, TagTemplateWidgetValue*>();
for (int i=0; i<theValues.size(); ++i) {
if (theValues[i]->theDescriptions.count(lang))
- aCombo->addItem(theValues[i]->theDescriptions[lang], qVariantFromValue(theValues[i]));
+ comboItems->insert(theValues[i]->theDescriptions[lang], theValues[i]);
else
if (theValues[i]->theDescriptions.count(defLang))
- aCombo->addItem(theValues[i]->theDescriptions[defLang], qVariantFromValue(theValues[i]));
+ comboItems->insert(theValues[i]->theDescriptions[defLang], theValues[i]);
else
- aCombo->addItem(theValues[i]->theTagValue, qVariantFromValue(theValues[i]));
+ comboItems->insert(theValues[i]->theTagValue, theValues[i]);
+ }
- if (theValues[i]->theTagValue == val)
+ aCombo->addItem(tr("Undefined"), qVariantFromValue(new TagTemplateWidgetValue("__NULL__")));
+ QString val = F->tagValue(theTag, "__NULL__");
+ int idx = -1;
+ for (QMap<QString, TagTemplateWidgetValue*>::const_iterator el = comboItems->constBegin(); el != comboItems->constEnd(); ++el) {
+ aCombo->addItem(el.key(), qVariantFromValue(el.value()));
+ if (el.value()->theTagValue == val)
idx = aCombo->count() - 1;
}
@@ -229,6 +234,7 @@ QWidget* TagTemplateWidgetCombo::getWidget(const MapFeature* F)
connect(aCombo,SIGNAL(activated(int)), this, SLOT(on_combo_activated(int)));
theMainWidget = aCombo;
theLabelWidget = aLabel;
+ delete comboItems;
return theWidget;
}
_______________________________________________ Merkaartor mailing list [email protected] http://lists.openstreetmap.org/listinfo/merkaartor
