]> git.lyx.org Git - features.git/commitdiff
Sort external templates locale-aware
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 9 Aug 2017 14:09:50 +0000 (16:09 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 9 Aug 2017 14:09:50 +0000 (16:09 +0200)
Fixes: #10738
src/frontends/qt4/GuiExternal.cpp
src/frontends/qt4/qt_helpers.cpp
src/frontends/qt4/qt_helpers.h

index 07eb8fce2d50d11ba440516a61aec41380fd3f71..f994aafaefc9b359c2e4b449602833d974786abb 100644 (file)
@@ -202,10 +202,16 @@ GuiExternal::GuiExternal(GuiView & lv)
        external::TemplateManager::Templates::const_iterator i1, i2;
        i1 = external::TemplateManager::get().getTemplates().begin();
        i2 = external::TemplateManager::get().getTemplates().end();
+       QMap<QString, QString> localizedTemplates;
        for (; i1 != i2; ++i1)
-               externalCO->addItem(qt_(i1->second.guiName), toqstr(i1->second.lyxName));
-       // Sort alphabetically by(localized) GUI name
-       externalCO->model()->sort(0);
+               localizedTemplates.insert(qt_(i1->second.guiName), toqstr(i1->second.lyxName));
+       // Sort alphabetically by (localized) GUI name
+       QStringList keys = localizedTemplates.keys();
+       qSort(keys.begin(), keys.end(), SortLocaleAware);
+       for (QString & key : keys) {
+               QString const value = localizedTemplates[key];
+               externalCO->addItem(key, value);
+       }
 
        // Fill the origins combo
        for (size_t i = 0; i != sizeof(origins) / sizeof(origins[0]); ++i)
index 63125d8c5c277ace085b4f9052e6aabe06a8d5a7..d2285101195527d6b4b189fb617d7f13b1ef32a1 100644 (file)
@@ -214,6 +214,12 @@ QString formatLocFPNumber(double d)
 }
 
 
+bool SortLocaleAware(QString const & lhs, QString const & rhs)
+{
+       return QString::localeAwareCompare(lhs, rhs) < 0;
+}
+
+
 bool ColorSorter(ColorCode lhs, ColorCode rhs)
 {
        return compare_no_case(lcolor.getGUIName(lhs), lcolor.getGUIName(rhs)) < 0;
index 023e86afcf4121295cead798d7d393b3fa635fb7..52057fc494af2f7d38ec65a90a7fcaf8e87771b5 100644 (file)
@@ -76,6 +76,9 @@ void doubleToWidget(QLineEdit * input, std::string const & value,
  */
 QString formatLocFPNumber(double d);
 
+/// Method to sort QStrings locale-aware (e.g. in combo widgets)
+bool SortLocaleAware(QString const & lhs, QString const & rhs);
+
 /// Method to sort colors by GUI name in combo widgets
 bool ColorSorter(ColorCode lhs, ColorCode rhs);