]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt/GuiCounter.cpp
Fix readability
[lyx.git] / src / frontends / qt / GuiCounter.cpp
index 9b8fbb666da59ef031e96f08cbc68d6dc7ecce5d..04fab3a664baccb166f763d3ec82f6bde42f00da 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "GuiCounter.h"
 
+#include "GuiView.h"
 #include "qt_helpers.h"
 
 #include "Buffer.h"
@@ -22,6 +23,7 @@
 #include "insets/InsetCommandParams.h"
 
 #include "support/convert.h"
+#include "support/debug.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
@@ -46,7 +48,7 @@ GuiCounter::GuiCounter(GuiView & lv, QWidget * parent) :
                this, SIGNAL(changed()));
 
        // These are hardcoded and do not change
-       std::map<std::string, std::string> const & ct =
+       std::vector<std::pair<std::string, std::string>> const & ct =
                        InsetCounter::counterTable;
        actionCB->clear();
        for (auto const & c : ct) {
@@ -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());
 }
 
 
@@ -136,10 +143,8 @@ bool GuiCounter::checkWidgets(bool readonly) const
        counterCB->setEnabled(!readonly);
        actionCB->setEnabled(!readonly);
        valueSB->setEnabled(!readonly && (cmdIsSet || cmdIsAddTo));
-       if (cmdIsAddTo)
-               valueSB->setRange(-10000, 10000);
-       else
-               valueSB->setRange(0, 10000);
+       // enumi, for example, can be negative.
+       valueSB->setRange(-10000, 10000);
 
        return InsetParamsWidget::checkWidgets() && !readonly &&
                        !counterCB->currentText().isEmpty() &&