commit 5171b7ea6cdf6cc4c73605d54e036624074a9ff3
Author: Juergen Spitzmueller <[email protected]>
Date:   Mon May 4 09:22:35 2020 +0200

    Keep sort order of counter actions
---
 src/frontends/qt/GuiCounter.cpp |    2 +-
 src/insets/InsetCounter.cpp     |   20 ++++++++++++++------
 src/insets/InsetCounter.h       |    2 +-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/frontends/qt/GuiCounter.cpp b/src/frontends/qt/GuiCounter.cpp
index 5ab3bbf..db081a4 100644
--- a/src/frontends/qt/GuiCounter.cpp
+++ b/src/frontends/qt/GuiCounter.cpp
@@ -48,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) {
diff --git a/src/insets/InsetCounter.cpp b/src/insets/InsetCounter.cpp
index d0aa108..5706f26 100644
--- a/src/insets/InsetCounter.cpp
+++ b/src/insets/InsetCounter.cpp
@@ -58,7 +58,7 @@ InsetCounter::InsetCounter(InsetCounter const & ir)
 {}
 
 
-const map<string, string> InsetCounter::counterTable =
+const vector<pair<string, string>> InsetCounter::counterTable =
 {
        {"set", N_("Set counter to ...")},
        {"addto", N_("Increase counter by ...")},
@@ -68,8 +68,13 @@ const map<string, string> InsetCounter::counterTable =
 };
 
 
-bool InsetCounter::isCompatibleCommand(string const & s) {
-       return counterTable.count(s);
+bool InsetCounter::isCompatibleCommand(string const & s)
+{
+       for (auto & i : counterTable) {
+               if (i.first == s)
+                       return true;
+       }
+       return false;
 }
 
 
@@ -204,9 +209,12 @@ void InsetCounter::updateBuffer(ParIterator const &, 
UpdateType, bool const)
        string const cmd = getCmdName();
        docstring cntr = getParam("counter");
        Counters & cnts = buffer().params().documentClass().counters();
-       map<string, string>::const_iterator cit = counterTable.find(cmd);
-       LASSERT(cit != counterTable.end(), return);
-       string const label = cit->second;
+       string label;
+       for (auto & i : counterTable) {
+               if (i.first == cmd)
+                       label = i.second;
+       }
+       LASSERT(!label.empty(), return);
        docstring const tlabel = translateIfPossible(from_ascii(label));
 
        if (cmd == "set") {
diff --git a/src/insets/InsetCounter.h b/src/insets/InsetCounter.h
index 92c547e..a050532 100644
--- a/src/insets/InsetCounter.h
+++ b/src/insets/InsetCounter.h
@@ -62,7 +62,7 @@ public:
        static bool isCompatibleCommand(std::string const & s);
        //@}
        /// keys are commands, values are GUI strings
-       static const std::map<std::string, std::string> counterTable;
+       static const std::vector<std::pair<std::string, std::string>> 
counterTable;
        static const std::map<std::string, std::string> valueTable;
 
 protected:
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to