Respect "literal" setting when entering citation via LyX server.

This requires moving the bool that tracks this somewhere that it
is visible from BufferView. It seemed to make sense to put it as
a static member of InsetCitation.
This commit is contained in:
Richard Heck 2018-02-22 15:24:28 -05:00
parent ee5f05bd1c
commit f8e8877f83
5 changed files with 17 additions and 8 deletions

View File

@ -2049,6 +2049,8 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
icp["key"] = from_utf8(arg); icp["key"] = from_utf8(arg);
if (!opt1.empty()) if (!opt1.empty())
icp["before"] = from_utf8(opt1); icp["before"] = from_utf8(opt1);
icp["literal"] =
from_ascii(InsetCitation::last_literal ? "true" : "false");
string icstr = InsetCommand::params2string(icp); string icstr = InsetCommand::params2string(icp);
FuncRequest fr(LFUN_INSET_INSERT, icstr); FuncRequest fr(LFUN_INSET_INSERT, icstr);
lyx::dispatch(fr); lyx::dispatch(fr);

View File

@ -27,6 +27,7 @@
#include "TextClass.h" #include "TextClass.h"
#include "FuncRequest.h" #include "FuncRequest.h"
#include "insets/InsetCitation.h"
#include "insets/InsetCommand.h" #include "insets/InsetCommand.h"
#include "support/debug.h" #include "support/debug.h"
@ -92,7 +93,7 @@ static vector<lyx::docstring> to_docstring_vector(QStringList const & qlist)
GuiCitation::GuiCitation(GuiView & lv) GuiCitation::GuiCitation(GuiView & lv)
: DialogView(lv, "citation", qt_("Citation")), : DialogView(lv, "citation", qt_("Citation")),
style_(QString()), literal_(false), params_(insetCode("citation")) style_(QString()), params_(insetCode("citation"))
{ {
setupUi(this); setupUi(this);
@ -237,7 +238,7 @@ void GuiCitation::on_restorePB_clicked()
void GuiCitation::on_literalCB_clicked() void GuiCitation::on_literalCB_clicked()
{ {
literal_ = literalCB->isChecked(); InsetCitation::last_literal = literalCB->isChecked();
changed(); changed();
} }
@ -768,7 +769,7 @@ void GuiCitation::init()
// if this is a new citation, we set the literal checkbox // if this is a new citation, we set the literal checkbox
// to its last set value. // to its last set value.
if (cited_keys_.isEmpty()) if (cited_keys_.isEmpty())
literalCB->setChecked(literal_); literalCB->setChecked(InsetCitation::last_literal);
else else
literalCB->setChecked(params_["literal"] == "true"); literalCB->setChecked(params_["literal"] == "true");
@ -1061,7 +1062,7 @@ void GuiCitation::saveSession(QSettings & settings) const
settings.setValue( settings.setValue(
sessionKey() + "/citestyle", style_); sessionKey() + "/citestyle", style_);
settings.setValue( settings.setValue(
sessionKey() + "/literal", literal_); sessionKey() + "/literal", InsetCitation::last_literal);
} }
@ -1073,7 +1074,8 @@ void GuiCitation::restoreSession()
casesense_->setChecked(settings.value(sessionKey() + "/casesensitive").toBool()); casesense_->setChecked(settings.value(sessionKey() + "/casesensitive").toBool());
instant_->setChecked(settings.value(sessionKey() + "/autofind", true).toBool()); instant_->setChecked(settings.value(sessionKey() + "/autofind", true).toBool());
style_ = settings.value(sessionKey() + "/citestyle").toString(); style_ = settings.value(sessionKey() + "/citestyle").toString();
literal_ = settings.value(sessionKey() + "/literal", false).toBool(); InsetCitation::last_literal =
settings.value(sessionKey() + "/literal", false).toBool();
updateFilterHint(); updateFilterHint();
} }

View File

@ -183,9 +183,6 @@ private:
/// last used citation style /// last used citation style
QString style_; QString style_;
/// last set value for literal
/// this is used only for new citations
bool literal_;
/// ///
GuiSelectionManager * selectionManager; GuiSelectionManager * selectionManager;
/// available keys. /// available keys.

View File

@ -59,6 +59,12 @@ InsetCitation::~InsetCitation()
} }
// May well be over-ridden when session settings are loaded
// in GuiCitation. Unfortunately, that will not happen until
// such a dialog is created.
bool InsetCitation::last_literal = true;
ParamInfo const & InsetCitation::findInfo(string const & /* cmdName */) ParamInfo const & InsetCitation::findInfo(string const & /* cmdName */)
{ {
static ParamInfo param_info_; static ParamInfo param_info_;

View File

@ -88,6 +88,8 @@ public:
std::vector<CitationStyle> const & valid_styles) const; std::vector<CitationStyle> const & valid_styles) const;
/// ///
std::map<docstring, docstring> getQualifiedLists(docstring const p) const; std::map<docstring, docstring> getQualifiedLists(docstring const p) const;
///
static bool last_literal;
private: private:
/// tries to make a pretty label and makes a basic one if not /// tries to make a pretty label and makes a basic one if not