From 5171b7ea6cdf6cc4c73605d54e036624074a9ff3 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 4 May 2020 09:22:35 +0200 Subject: [PATCH] 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 5ab3bbfcec..db081a46c5 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 const & ct = + std::vector> const & ct = InsetCounter::counterTable; actionCB->clear(); for (auto const & c : ct) { diff --git a/src/insets/InsetCounter.cpp b/src/insets/InsetCounter.cpp index d0aa10877a..5706f2619b 100644 --- a/src/insets/InsetCounter.cpp +++ b/src/insets/InsetCounter.cpp @@ -58,7 +58,7 @@ InsetCounter::InsetCounter(InsetCounter const & ir) {} -const map InsetCounter::counterTable = +const vector> InsetCounter::counterTable = { {"set", N_("Set counter to ...")}, {"addto", N_("Increase counter by ...")}, @@ -68,8 +68,13 @@ const map 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::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 92c547e432..a050532e09 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 counterTable; + static const std::vector> counterTable; static const std::map valueTable; protected: