ComboBox change sorting

alphabetical sorting in the ComboBox changed according to the order in
the elementInfoKeys list
This commit is contained in:
Achim
2024-12-16 15:55:16 +01:00
parent 0a658d5d61
commit 3b32daf15d
2 changed files with 6 additions and 18 deletions

View File

@@ -68,15 +68,8 @@ void CompositeTextEditDialog::setUpComboBox()
qstrl.removeAll("formula");
}
//We use a QMap because the keys of the map are sorted, then no matter the current local,
//the value of the combo box are always alphabetically sorted
QMap <QString, QString> info_map;
for(const QString& str : qstrl) {
info_map.insert(QETInformation::translatedInfoKey(str),
is_report ? QETInformation::folioReportInfoToVar(str) : QETInformation::elementInfoToVar(str));
}
for(const QString& key : info_map.keys()) {
ui->m_info_cb->addItem(key, info_map.value(key));
for (int i=0; i<qstrl.size();++i) {
ui -> m_info_cb -> addItem(qstrl[i], QETInformation::translatedInfoKey(qstrl[i]));
}
}

View File

@@ -1622,18 +1622,13 @@ QWidget *DynamicTextItemDelegate::createEditor(
DynamicElementTextItem *deti = detm->textFromIndex(index);
if(!deti)
break;
//We use a QMap because the keys of the map are sorted, then no matter the current local,
//the value of the combo box are always alphabetically sorted
QMap <QString, QString> info_map;
for(const QString& str : availableInfo(deti)) {
info_map.insert(QETInformation::translatedInfoKey(str), str);
}
QComboBox *qcb = new QComboBox(parent);
qcb->setObjectName("info_text");
for (const QString& key : info_map.keys()) {
qcb->addItem(key, info_map.value(key));
QStringList strl = availableInfo(deti);
for (int i=0; i<strl.size();++i) {
qcb -> addItem(strl[i], QETInformation::translatedInfoKey(strl[i]));
}
return qcb;
}