mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-23 00:11:49 +00:00
Amend 3615a6a75b
Natbib provides separation of abbreviated and full author list also beyond BibTeX
This commit is contained in:
parent
c6754ed548
commit
8ee2ffaa52
@ -36,6 +36,8 @@ GuiBibitem::GuiBibitem(QWidget * parent) : InsetParamsWidget(parent)
|
|||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
connect(labelED, SIGNAL(textChanged(QString)),
|
connect(labelED, SIGNAL(textChanged(QString)),
|
||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
|
connect(allAuthorsED, SIGNAL(textChanged(QString)),
|
||||||
|
this, SIGNAL(changed()));
|
||||||
connect(yearED, SIGNAL(textChanged(QString)),
|
connect(yearED, SIGNAL(textChanged(QString)),
|
||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
connect(literalCB, SIGNAL(clicked()),
|
connect(literalCB, SIGNAL(clicked()),
|
||||||
@ -54,21 +56,28 @@ void GuiBibitem::paramsToDialog(Inset const * inset)
|
|||||||
if (bp.citeEngine() == "natbib" && bp.citeEngineType() == ENGINE_TYPE_AUTHORYEAR) {
|
if (bp.citeEngine() == "natbib" && bp.citeEngineType() == ENGINE_TYPE_AUTHORYEAR) {
|
||||||
yearED->setHidden(false);
|
yearED->setHidden(false);
|
||||||
yearLA->setHidden(false);
|
yearLA->setHidden(false);
|
||||||
labelLA->setText(qt_("Author &Name:"));
|
allAuthorsED->setHidden(false);
|
||||||
labelED->setToolTip(qt_("Insert the author name(s) here. The year goes to the separate field."));
|
allAuthorsLA->setHidden(false);
|
||||||
|
labelLA->setText(qt_("Author &Names:"));
|
||||||
|
labelED->setToolTip(qt_("Insert the author name(s) for the author-year reference here. "
|
||||||
|
"If you use an abbreviated list (with 'et al.'), the full list can go below."));
|
||||||
int const i = label.lastIndexOf("(");
|
int const i = label.lastIndexOf("(");
|
||||||
int const j = label.lastIndexOf(")");
|
int const j = label.lastIndexOf(")");
|
||||||
if (i != -1 && j != -1 && i < j) {
|
if (i != -1 && j != -1 && i < j) {
|
||||||
// Split Author(Year) to Author and Year
|
// Split Author(Year) to Author and Year
|
||||||
QString const year = label.left(j).mid(i + 1);
|
QString const year = label.left(j).mid(i + 1);
|
||||||
QString const author = label.left(i);
|
QString const author = label.left(i);
|
||||||
|
QString const allauthors = label.mid(j + 1);
|
||||||
labelED->setText(author);
|
labelED->setText(author);
|
||||||
yearED->setText(year);
|
yearED->setText(year);
|
||||||
|
allAuthorsED->setText(allauthors);
|
||||||
} else
|
} else
|
||||||
labelED->setText(label);
|
labelED->setText(label);
|
||||||
} else {
|
} else {
|
||||||
yearED->setHidden(true);
|
yearED->setHidden(true);
|
||||||
yearLA->setHidden(true);
|
yearLA->setHidden(true);
|
||||||
|
allAuthorsED->setHidden(true);
|
||||||
|
allAuthorsLA->setHidden(true);
|
||||||
labelLA->setText(qt_("&Label:"));
|
labelLA->setText(qt_("&Label:"));
|
||||||
labelED->setToolTip(qt_("The label as it appears in the document"));
|
labelED->setToolTip(qt_("The label as it appears in the document"));
|
||||||
labelED->setText(label);
|
labelED->setText(label);
|
||||||
@ -81,7 +90,7 @@ docstring GuiBibitem::dialogToParams() const
|
|||||||
InsetCommandParams params(insetCode());
|
InsetCommandParams params(insetCode());
|
||||||
QString label = labelED->text();
|
QString label = labelED->text();
|
||||||
if (!yearED->isHidden())
|
if (!yearED->isHidden())
|
||||||
label += "(" + yearED->text() + ")";
|
label += "(" + yearED->text() + ")" + allAuthorsED->text();
|
||||||
params["key"] = qstring_to_ucs4(keyED->text());
|
params["key"] = qstring_to_ucs4(keyED->text());
|
||||||
params["label"] = qstring_to_ucs4(label);
|
params["label"] = qstring_to_ucs4(label);
|
||||||
params["literal"] = literalCB->isChecked()
|
params["literal"] = literalCB->isChecked()
|
||||||
|
@ -6,22 +6,22 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>467</width>
|
||||||
<height>123</height>
|
<height>170</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0" rowspan="2" colspan="2">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="keyLA">
|
<widget class="QLabel" name="keyLA">
|
||||||
@ -36,7 +36,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1" colspan="2">
|
||||||
<widget class="QLineEdit" name="keyED">
|
<widget class="QLineEdit" name="keyED">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
@ -62,7 +62,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@ -102,9 +102,26 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="allAuthorsLA">
|
||||||
|
<property name="text">
|
||||||
|
<string>A&ll Author Names:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>allAuthorsED</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QLineEdit" name="allAuthorsED">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>If you want to use an abbreviated author list (with 'et al.') as well as a full list for author-year citation, you can put the full list here and the abbreviated list above.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QCheckBox" name="literalCB">
|
<widget class="QCheckBox" name="literalCB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Pass content of the `Label' field literally to LaTeX. Check this if you want to enter LaTeX code.</string>
|
<string>Pass content of the `Label' field literally to LaTeX. Check this if you want to enter LaTeX code.</string>
|
||||||
|
@ -188,9 +188,15 @@ docstring InsetBibitem::bibLabel() const
|
|||||||
if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL)
|
if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL)
|
||||||
return autolabel_;
|
return autolabel_;
|
||||||
docstring label = getParam("label");
|
docstring label = getParam("label");
|
||||||
if (!label.empty() && bp.citeEngine() == "natbib")
|
if (!label.empty() && bp.citeEngine() == "natbib") {
|
||||||
// Add a space before opening paren
|
// Add a space before opening paren
|
||||||
label = subst(label, from_ascii("("), from_ascii(" ("));
|
label = subst(label, from_ascii("("), from_ascii(" ("));
|
||||||
|
// and strip off long author list
|
||||||
|
docstring striplabel;
|
||||||
|
label = rsplit(label, striplabel, ')');
|
||||||
|
if (!striplabel.empty())
|
||||||
|
label = striplabel + ")";
|
||||||
|
}
|
||||||
return label.empty() ? autolabel_ : label;
|
return label.empty() ? autolabel_ : label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user