mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
parent
7b313ec452
commit
3615a6a75b
@ -4,6 +4,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \¸author Jürgen Spitzmüller
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -12,6 +13,9 @@
|
||||
|
||||
#include "GuiBibitem.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "insets/InsetCommand.h"
|
||||
@ -32,6 +36,8 @@ GuiBibitem::GuiBibitem(QWidget * parent) : InsetParamsWidget(parent)
|
||||
this, SIGNAL(changed()));
|
||||
connect(labelED, SIGNAL(textChanged(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(yearED, SIGNAL(textChanged(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(literalCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
}
|
||||
@ -42,16 +48,42 @@ void GuiBibitem::paramsToDialog(Inset const * inset)
|
||||
InsetCommand const * ic = static_cast<InsetCommand const *>(inset);
|
||||
InsetCommandParams const & params = ic->params();
|
||||
keyED->setText(toqstr(params["key"]));
|
||||
labelED->setText(toqstr(params["label"]));
|
||||
literalCB->setChecked(params["literal"] == "true");
|
||||
QString const label = toqstr(params["label"]);
|
||||
BufferParams const bp = inset->buffer().masterParams();
|
||||
if (bp.citeEngine() == "natbib" && bp.citeEngineType() == ENGINE_TYPE_AUTHORYEAR) {
|
||||
yearED->setHidden(false);
|
||||
yearLA->setHidden(false);
|
||||
labelLA->setText(qt_("Author &Name:"));
|
||||
labelED->setToolTip(qt_("Insert the author name(s) here. The year goes to the separate field."));
|
||||
int const i = label.lastIndexOf("(");
|
||||
int const j = label.lastIndexOf(")");
|
||||
if (i != -1 && j != -1 && i < j) {
|
||||
// Split Author(Year) to Author and Year
|
||||
QString const year = label.left(j).mid(i + 1);
|
||||
QString const author = label.left(i);
|
||||
labelED->setText(author);
|
||||
yearED->setText(year);
|
||||
} else
|
||||
labelED->setText(label);
|
||||
} else {
|
||||
yearED->setHidden(true);
|
||||
yearLA->setHidden(true);
|
||||
labelLA->setText(qt_("&Label:"));
|
||||
labelED->setToolTip(qt_("The label as it appears in the document"));
|
||||
labelED->setText(label);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
docstring GuiBibitem::dialogToParams() const
|
||||
{
|
||||
InsetCommandParams params(insetCode());
|
||||
QString label = labelED->text();
|
||||
if (!yearED->isHidden())
|
||||
label += "(" + yearED->text() + ")";
|
||||
params["key"] = qstring_to_ucs4(keyED->text());
|
||||
params["label"] = qstring_to_ucs4(labelED->text());
|
||||
params["label"] = qstring_to_ucs4(label);
|
||||
params["literal"] = literalCB->isChecked()
|
||||
? from_ascii("true") : from_ascii("false");
|
||||
return from_utf8(InsetCommand::params2string(params));
|
||||
@ -64,7 +96,8 @@ bool GuiBibitem::checkWidgets(bool readonly) const
|
||||
labelED->setReadOnly(readonly);
|
||||
if (!InsetParamsWidget::checkWidgets())
|
||||
return false;
|
||||
return !keyED->text().isEmpty();
|
||||
return !keyED->text().isEmpty()
|
||||
&& (yearED->isHidden() || !yearED->text().isEmpty());
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -6,17 +6,24 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>218</width>
|
||||
<height>121</height>
|
||||
<width>400</width>
|
||||
<height>123</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="keyLA">
|
||||
<property name="toolTip">
|
||||
<string>The bibliography key</string>
|
||||
@ -29,31 +36,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelLA">
|
||||
<property name="toolTip">
|
||||
<string>The label as it appears in the document</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Label:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>labelED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="keyED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
@ -66,31 +49,71 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="labelED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelLA">
|
||||
<property name="toolTip">
|
||||
<string>The label as it appears in the document</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Label:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>labelED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="literalCB">
|
||||
<property name="toolTip">
|
||||
<string>Pass content of the `Label' field literally to LaTeX. Check this if you want to enter LaTeX code.</string>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Li&teral</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="labelED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The label as it appears in the document</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="yearLA">
|
||||
<property name="text">
|
||||
<string>&Year:</string>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>yearED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="yearED">
|
||||
<property name="toolTip">
|
||||
<string>The year with "Author (Year)" citations (without parentheses).</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="literalCB">
|
||||
<property name="toolTip">
|
||||
<string>Pass content of the `Label' field literally to LaTeX. Check this if you want to enter LaTeX code.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Li&teral</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<includes>
|
||||
|
@ -187,7 +187,10 @@ docstring InsetBibitem::bibLabel() const
|
||||
BufferParams const & bp = buffer().masterBuffer()->params();
|
||||
if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL)
|
||||
return autolabel_;
|
||||
docstring const & label = getParam("label");
|
||||
docstring label = getParam("label");
|
||||
if (!label.empty() && bp.citeEngine() == "natbib")
|
||||
// Add a space before opening paren
|
||||
label = subst(label, from_ascii("("), from_ascii(" ("));
|
||||
return label.empty() ? autolabel_ : label;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user