]> git.lyx.org Git - features.git/commitdiff
Make counter items translatable and sort properly
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 3 May 2020 07:44:55 +0000 (09:44 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 3 May 2020 07:44:55 +0000 (09:44 +0200)
src/frontends/qt/GuiCounter.cpp

index 9b8fbb666da59ef031e96f08cbc68d6dc7ecce5d..5ab3bbfcec5e372811789dd3925a87d699f0deed 100644 (file)
@@ -25,6 +25,8 @@
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
+#include "qt_helpers.h"
+
 #include <map>
 //#include <vector>
 
@@ -88,10 +90,15 @@ void GuiCounter::fillCombos()
        Counters const & cntrs =
                bv->buffer().params().documentClass().counters();
        std::vector<docstring> counts = cntrs.listOfCounters();
+       // We use an intermediate map in order to sort at translated GUI strings.
+       QMap<QString, QString> items;
        for (auto const & c : counts) {
                docstring const & guiname = cntrs.guiName(c);
-               counterCB->addItem(toqstr(guiname), toqstr(c));
+               items.insert(qt_(toqstr(guiname)), toqstr(c));
        }
+       for (QMap<QString, QString>::const_iterator it = items.constBegin();
+            it != items.constEnd(); ++it)
+               counterCB->addItem(it.key(), it.value());
 }