]> git.lyx.org Git - features.git/commitdiff
Keep sort order of counter actions
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 4 May 2020 07:22:35 +0000 (09:22 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 4 May 2020 07:22:35 +0000 (09:22 +0200)
src/frontends/qt/GuiCounter.cpp
src/insets/InsetCounter.cpp
src/insets/InsetCounter.h

index 5ab3bbfcec5e372811789dd3925a87d699f0deed..db081a46c52201312cf6e39e41df6e5b45664a66 100644 (file)
@@ -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) {
index d0aa10877a064daa888d28b3ba82105c76abf837..5706f2619b93889bdee0bd21cea3846546984776 100644 (file)
@@ -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") {
index 92c547e432c649cc2e96158b55a9bd77592ba76a..a050532e092a0a90681796cf66c0f1a3b9242866 100644 (file)
@@ -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: