CT_LABELSTRING_APPENDIX,
CT_PRETTYFORMAT,
CT_INITIALVALUE,
+ CT_GUINAME,
CT_END
};
LexerKeyword counterTags[] = {
{ "end", CT_END },
- { "initialvalue", CT_INITIALVALUE},
+ { "guiname", CT_GUINAME },
+ { "initialvalue", CT_INITIALVALUE},
{ "labelstring", CT_LABELSTRING },
{ "labelstringappendix", CT_LABELSTRING_APPENDIX },
{ "prettyformat", CT_PRETTYFORMAT },
lex.next();
labelstringappendix_ = lex.getDocString();
break;
+ case CT_GUINAME:
+ lex.next();
+ guiname_ = lex.getDocString();
+ break;
case CT_END:
getout = true;
break;
}
+docstring const & Counters::guiName(docstring const & cntr) const
+{
+ CounterList::const_iterator it = counterList_.find(cntr);
+ if (it == counterList_.end()) {
+ lyxerr << "step: Counter does not exist: "
+ << to_utf8(cntr) << endl;
+ return empty_docstring();
+ }
+
+ docstring const & guiname = it->second.guiName();
+ if (guiname.empty())
+ return cntr;
+ return guiname;
+}
+
+
void Counters::reset()
{
appendix_ = false;
/// Similar, but used for formatted references in XHTML output.
/// E.g., for a section counter it might be "section \thesection"
docstring const & prettyFormat() const { return prettyformat_; }
+ ///
+ docstring const & guiName() const { return guiname_; }
/// Returns a map of LaTeX-like strings to format the counter.
/** For each language, the string is similar to what one gets
docstring labelstringappendix_;
/// Similar, but used for formatted references in XHTML output
docstring prettyformat_;
+ ///
+ docstring guiname_;
/// Cache of the labelstring with \\the<counter> expressions expanded,
/// indexed by language
mutable StringMap flatlabelstring_;
/// format given by Counter::prettyFormat().
docstring prettyCounter(docstring const & cntr,
std::string const & lang) const;
+ ///
+ docstring const & guiName(docstring const & cntr) const;
/// Are we in appendix?
bool appendix() const { return appendix_; }
/// Set the state variable indicating whether we are in appendix.
void GuiCounter::processParams(InsetCommandParams const & params)
{
QString const & counter = toqstr(params["counter"]);
- int c = counterCB->findText(counter);
+ int c = counterCB->findData(counter);
counterCB->setCurrentIndex(c);
QString cmd = toqstr(params.getCmdName());
if (!bv)
return;
- std::vector<docstring> counts =
- bv->buffer().params().documentClass().counters().listOfCounters();
- for (auto const & c : counts)
- counterCB->addItem(toqstr(c));
+ Counters const & cntrs =
+ bv->buffer().params().documentClass().counters();
+ std::vector<docstring> counts = cntrs.listOfCounters();
+ for (auto const & c : counts) {
+ docstring const & guiname = cntrs.guiName(c);
+ counterCB->addItem(toqstr(guiname), toqstr(c));
+ }
}
{
InsetCommandParams params(insetCode());
- params["counter"] = qstring_to_ucs4(counterCB->currentText());
+ params["counter"] = qstring_to_ucs4(counterCB->itemData(counterCB->currentIndex()).toString());
params["value"] = convert<docstring>(valueSB->value());
params.setCmdName(fromqstr(actionCB->itemData(actionCB->currentIndex()).toString()));
params["lyxonly"] = from_ascii(lyxonlyXB->isChecked() ? "true" : "false");