Keep sort order of counter actions

This commit is contained in:
Juergen Spitzmueller 2020-05-04 09:22:35 +02:00
parent 5f5cb7eea7
commit 5171b7ea6c
3 changed files with 16 additions and 8 deletions

View File

@ -48,7 +48,7 @@ GuiCounter::GuiCounter(GuiView & lv, QWidget * parent) :
this, SIGNAL(changed())); this, SIGNAL(changed()));
// These are hardcoded and do not change // 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; InsetCounter::counterTable;
actionCB->clear(); actionCB->clear();
for (auto const & c : ct) { for (auto const & c : ct) {

View 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 ...")}, {"set", N_("Set counter to ...")},
{"addto", N_("Increase counter by ...")}, {"addto", N_("Increase counter by ...")},
@ -68,8 +68,13 @@ const map<string, string> InsetCounter::counterTable =
}; };
bool InsetCounter::isCompatibleCommand(string const & s) { bool InsetCounter::isCompatibleCommand(string const & s)
return counterTable.count(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(); string const cmd = getCmdName();
docstring cntr = getParam("counter"); docstring cntr = getParam("counter");
Counters & cnts = buffer().params().documentClass().counters(); Counters & cnts = buffer().params().documentClass().counters();
map<string, string>::const_iterator cit = counterTable.find(cmd); string label;
LASSERT(cit != counterTable.end(), return); for (auto & i : counterTable) {
string const label = cit->second; if (i.first == cmd)
label = i.second;
}
LASSERT(!label.empty(), return);
docstring const tlabel = translateIfPossible(from_ascii(label)); docstring const tlabel = translateIfPossible(from_ascii(label));
if (cmd == "set") { if (cmd == "set") {

View File

@ -62,7 +62,7 @@ public:
static bool isCompatibleCommand(std::string const & s); static bool isCompatibleCommand(std::string const & s);
//@} //@}
/// keys are commands, values are GUI strings /// 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; static const std::map<std::string, std::string> valueTable;
protected: protected: