From e73aa3b84d06b5d6c5661096e8226b3d859682f0 Mon Sep 17 00:00:00 2001 From: Achim Date: Tue, 31 Dec 2024 08:40:03 +0100 Subject: [PATCH] ComboBox change sorting alphabetical sorting in the ComboBox changed according to the order in the elementInfoKeys list --- sources/editor/ui/dynamictextfieldeditor.cpp | 11 +++-------- sources/ui/compositetexteditdialog.cpp | 12 +++--------- sources/ui/dynamicelementtextmodel.cpp | 13 ++++--------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/sources/editor/ui/dynamictextfieldeditor.cpp b/sources/editor/ui/dynamictextfieldeditor.cpp index 15c3872e3..629a8f9dd 100644 --- a/sources/editor/ui/dynamictextfieldeditor.cpp +++ b/sources/editor/ui/dynamictextfieldeditor.cpp @@ -226,15 +226,10 @@ void DynamicTextFieldEditor::fillInfoComboBox() else { strl = QETInformation::elementInfoKeys(); } - //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 info_map; - for(const QString& str : strl) - info_map.insert(QETInformation::translatedInfoKey(str), str); - - for (const QString& key : info_map.keys()) - ui -> m_elmt_info_cb -> addItem(key, info_map.value(key)); + for (int i=0; i m_elmt_info_cb -> addItem(QETInformation::translatedInfoKey(strl[i]), strl[i]); + } } void DynamicTextFieldEditor::on_m_x_sb_editingFinished() diff --git a/sources/ui/compositetexteditdialog.cpp b/sources/ui/compositetexteditdialog.cpp index 045615e3d..1b81924a7 100644 --- a/sources/ui/compositetexteditdialog.cpp +++ b/sources/ui/compositetexteditdialog.cpp @@ -68,15 +68,9 @@ 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 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 m_info_cb -> addItem(QETInformation::translatedInfoKey(qstrl[i]), + is_report ? QETInformation::folioReportInfoToVar(qstrl[i]) : QETInformation::elementInfoToVar(qstrl[i])); } } diff --git a/sources/ui/dynamicelementtextmodel.cpp b/sources/ui/dynamicelementtextmodel.cpp index 95b224446..8b837ad33 100644 --- a/sources/ui/dynamicelementtextmodel.cpp +++ b/sources/ui/dynamicelementtextmodel.cpp @@ -1623,17 +1623,12 @@ QWidget *DynamicTextItemDelegate::createEditor( 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 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 addItem(QETInformation::translatedInfoKey(strl[i]), strl[i]); } return qcb; }