FuncRequest(LFUN_NOACTION)));
return;
}
- InsetCommand const * citinset =
- static_cast<InsetCommand const *>(inset);
+ InsetCitation const * citinset =
+ static_cast<InsetCitation const *>(inset);
Buffer const * buf = &bv->buffer();
+ BufferParams const & bp = buf->params();
string const cmd = citinset->params().getCmdName();
docstring const & key = citinset->getParam("key");
return;
}
- docstring const & before = citinset->getParam("before");
- docstring const & after = citinset->getParam("after");
-
size_t const n = cmd.size();
- bool const force = cmd[0] == 'C';
- bool const full = cmd[n] == '*';
+ bool const force = isUpperCase(cmd[0]);
+ bool const star = cmd[n] == '*';
vector<docstring> const keys = getVectorFromString(key);
vector<CitationStyle> const citeStyleList = buf->params().citeStyles();
- static const size_t max_length = 40;
+ CiteItem ci;
+ ci.textBefore = citinset->getParam("before");
+ ci.textAfter = citinset->getParam("after");
+ ci.forceUpperCase = force;
+ ci.Starred = star;
+ ci.context = CiteItem::Dialog;
+ ci.max_size = 40;
vector<docstring> citeStrings =
- buf->masterBibInfo().getCiteStrings(keys, citeStyleList, bv->buffer(),
- before, after, from_utf8("dialog"), max_length);
+ buf->masterBibInfo().getCiteStrings(keys, citeStyleList, bv->buffer(), ci);
vector<docstring>::const_iterator cit = citeStrings.begin();
vector<docstring>::const_iterator end = citeStrings.end();
docstring label = *cit;
CitationStyle cs = citeStyleList[ii - 1];
cs.forceUpperCase &= force;
- cs.fullAuthorList &= full;
+ cs.hasStarredVersion &= star;
addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(label),
FuncRequest(LFUN_INSET_MODIFY,
"changetype " + from_utf8(citationStyleToString(cs)))));
}
+
+ // Extra features of the citation styles
+ CitationStyle cs = citinset->getCitationStyle(bp, cmd, citeStyleList);
+
+ if (cs.hasStarredVersion) {
+ docstring starred = _("All authors|h");
+ // Check if we have a custom string/tooltip for the starred version
+ if (!cs.stardesc.empty()) {
+ string val =
+ bp.documentClass().getCiteMacro(buf->params().citeEngineType(), cs.stardesc);
+ if (!val.empty())
+ starred = translateIfPossible(from_utf8(val));
+ // Transform qt-style accelerators to menu-style
+ int const amps = count_char(starred, '&');
+ if (amps > 0) {
+ if (amps > 1)
+ starred = subst(starred, from_ascii("&&"), from_ascii("<:amp:>"));
+ size_t n = starred.find('&');
+ char_type accel = char_type();
+ if (n != docstring::npos && n < starred.size() - 1)
+ accel = starred[n + 1];
+ starred = subst(starred, from_ascii("&"), from_ascii(""));
+ if (amps > 1)
+ starred = subst(starred, from_ascii("<:amp:>"), from_ascii("&&"));
+ if (accel != char_type())
+ starred = starred + '|' + accel;
+ }
+ }
+ add(MenuItem(MenuItem::Separator));
+ addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(starred),
+ FuncRequest(LFUN_INSET_MODIFY, "toggleparam star")));
+ }
+
+ if (cs.forceUpperCase) {
+ if (!cs.hasStarredVersion)
+ add(MenuItem(MenuItem::Separator));
+ addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(_("Force upper case|u")),
+ FuncRequest(LFUN_INSET_MODIFY, "toggleparam casing")));
+ }
}