mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
More polishing of counter dialog. Thanks to Jürgen for help.
Also, remove the 'display value' option. We will move this to InsetInfo at some point.
This commit is contained in:
parent
b55f735afe
commit
c37500050d
@ -3730,12 +3730,6 @@ def revert_counter_inset(document):
|
||||
ert = put_cmd_in_ert("\\addtocounter{%s}{%s}" % (cnt, val))
|
||||
elif cmd == "reset":
|
||||
ert = put_cmd_in_ert("\\setcounter{%s}{0}" % (cnt))
|
||||
elif cmd == "value":
|
||||
vty = get_quoted_value(document.body, "vtype", i, j)
|
||||
if not vty:
|
||||
document.warning("Can't convert counter inset at line %d!" % i)
|
||||
else:
|
||||
ert = put_cmd_in_ert("\\%s{%s}" % (vty, cnt))
|
||||
elif cmd == "save":
|
||||
needed_counters[cnt] = 1
|
||||
savecnt = "LyXSave" + cnt
|
||||
|
@ -42,8 +42,6 @@ GuiCounter::GuiCounter(GuiView & lv, QWidget * parent) :
|
||||
this, SIGNAL(changed()));
|
||||
connect(valueSB, SIGNAL(valueChanged(int)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(vtypeCB, SIGNAL(currentIndexChanged(int)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(lyxonlyXB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
@ -55,15 +53,6 @@ GuiCounter::GuiCounter(GuiView & lv, QWidget * parent) :
|
||||
docstring guistring = translateIfPossible(from_ascii(c.second));
|
||||
actionCB->addItem(toqstr(guistring), toqstr(c.first));
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> const & vt =
|
||||
InsetCounter::valueTable;
|
||||
vtypeCB->clear();
|
||||
vtypeCB->addItem("", "");
|
||||
for (auto const & v : vt) {
|
||||
docstring guistring = translateIfPossible(from_ascii(v.second));
|
||||
vtypeCB->addItem(toqstr(guistring), toqstr(v.first));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -84,13 +73,6 @@ void GuiCounter::processParams(InsetCommandParams const & params)
|
||||
int val = convert<int>(params["value"]);
|
||||
valueSB->setValue(val);
|
||||
|
||||
cmd = toqstr(params["vtype"]);
|
||||
c = cmd.isEmpty() ? 0 : vtypeCB->findData(cmd);
|
||||
if (c < 0) {
|
||||
c = 0;
|
||||
LYXERR0("Unable to find " << cmd << " in GuiCounter!");
|
||||
}
|
||||
vtypeCB->setCurrentIndex(c);
|
||||
lyxonlyXB->setChecked(support::lowercase(params["lyxonly"]) == "true");
|
||||
}
|
||||
|
||||
@ -139,7 +121,6 @@ docstring GuiCounter::dialogToParams() const
|
||||
params["counter"] = qstring_to_ucs4(counterCB->currentText());
|
||||
params["value"] = convert<docstring>(valueSB->value());
|
||||
params.setCmdName(fromqstr(actionCB->itemData(actionCB->currentIndex()).toString()));
|
||||
params["vtype"] = qstring_to_ucs4(vtypeCB->itemData(vtypeCB->currentIndex()).toString());
|
||||
params["lyxonly"] = from_ascii(lyxonlyXB->isChecked() ? "true" : "false");
|
||||
return from_utf8(InsetCounter::params2string(params));
|
||||
}
|
||||
@ -147,7 +128,6 @@ docstring GuiCounter::dialogToParams() const
|
||||
|
||||
bool GuiCounter::checkWidgets(bool readonly) const
|
||||
{
|
||||
bool const cmdIsValue = actionCB->itemData(actionCB->currentIndex()).toString() == "value";
|
||||
bool const cmdIsSet = actionCB->itemData(actionCB->currentIndex()).toString() == "set";
|
||||
bool const cmdIsAddTo = actionCB->itemData(actionCB->currentIndex()).toString() == "addto";
|
||||
counterCB->setEnabled(!readonly);
|
||||
@ -157,13 +137,10 @@ bool GuiCounter::checkWidgets(bool readonly) const
|
||||
valueSB->setRange(-10000, 10000);
|
||||
else
|
||||
valueSB->setRange(0, 10000);
|
||||
vtypeLA->setEnabled(!readonly && cmdIsValue);
|
||||
vtypeCB->setEnabled(!readonly && cmdIsValue);
|
||||
|
||||
return InsetParamsWidget::checkWidgets() && !readonly &&
|
||||
!counterCB->currentText().isEmpty() &&
|
||||
!actionCB->currentText().isEmpty() &&
|
||||
!(cmdIsValue && vtypeCB->currentText().isEmpty());
|
||||
!actionCB->currentText().isEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,10 +13,10 @@
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="counterLA">
|
||||
<property name="text">
|
||||
<string>C&ounter:</string>
|
||||
@ -26,7 +26,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item>
|
||||
<widget class="QComboBox" name="counterCB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
@ -39,7 +39,11 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="actionLA">
|
||||
<property name="text">
|
||||
<string>&Action:</string>
|
||||
@ -49,7 +53,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item>
|
||||
<widget class="QComboBox" name="actionCB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
@ -58,71 +62,41 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>SET counter value; ADD TO (or subtract from) counter value; RESET counter to zero; SAVE counter value; RESTORE previously saved counter value; DISPLAY counter value</string>
|
||||
<string>SET counter to specified value; ADD TO (or subtract from) counter value; RESET counter to zero; SAVE counter value for later restoring; RESTORE previously saved counter value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="valueLA">
|
||||
<property name="text">
|
||||
<string>&Value:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>valueSB</cstring>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="valueSB">
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="valueSB">
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>13</width>
|
||||
<height>39</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="vtypeLA">
|
||||
<property name="text">
|
||||
<string>Display Format</string>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>vtypeCB</cstring>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="vtypeCB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="lyxonlyXB">
|
||||
<property name="toolTip">
|
||||
<string>Affect counters only in LyX, not in output</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&LyX Only</string>
|
||||
@ -131,6 +105,19 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<includes>
|
||||
|
@ -60,12 +60,11 @@ InsetCounter::InsetCounter(InsetCounter const & ir)
|
||||
|
||||
const map<string, string> InsetCounter::counterTable =
|
||||
{
|
||||
{"set", N_("Set Counter")},
|
||||
{"addto", N_("Add To Counter")},
|
||||
{"reset", N_("Reset To 0")},
|
||||
{"set", N_("Set Counter To")},
|
||||
{"addto", N_("Increase Counter By")},
|
||||
{"reset", N_("Reset Counter To 0")},
|
||||
{"save", N_("Save Value of Counter")},
|
||||
{"restore", N_("Restore Value of Counter")},
|
||||
{"value", N_("Display Value of Counter")}
|
||||
};
|
||||
|
||||
|
||||
@ -80,7 +79,6 @@ ParamInfo const & InsetCounter::findInfo(string const & /* cmdName */)
|
||||
if (param_info_.empty()) {
|
||||
param_info_.add("counter", ParamInfo::LYX_INTERNAL);
|
||||
param_info_.add("value", ParamInfo::LYX_INTERNAL);
|
||||
param_info_.add("vtype", ParamInfo::LYX_INTERNAL);
|
||||
param_info_.add("lyxonly", ParamInfo::LYX_INTERNAL);
|
||||
}
|
||||
return param_info_;
|
||||
@ -112,8 +110,6 @@ void InsetCounter::latex(otexstream & os, OutputParams const &) const
|
||||
cnts.restoreValue(cntr);
|
||||
os << "\\setcounter{" << cntr
|
||||
<< "{\\value{" << lyxSaveCounter() << "}}";
|
||||
} else if (cmd == "value") {
|
||||
os << "\\the" << cntr << "{}";
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,26 +129,8 @@ int InsetCounter::plaintext(odocstringstream & os,
|
||||
}
|
||||
|
||||
|
||||
void InsetCounter::trackCounters(string const & cmd) const
|
||||
{
|
||||
Counters & cnts = buffer().params().documentClass().counters();
|
||||
docstring cntr = getParam("counter");
|
||||
if (cmd == "set") {
|
||||
docstring const & val = getParam("value");
|
||||
cnts.set(cntr, convert<int>(val));
|
||||
} else if (cmd == "addto") {
|
||||
docstring const & val = getParam("value");
|
||||
cnts.addto(cntr, convert<int>(val));
|
||||
} else if (cmd == "reset") {
|
||||
cnts.reset(cntr);
|
||||
} else if (cmd == "save") {
|
||||
cnts.saveValue(cntr);
|
||||
} else if (cmd == "restore") {
|
||||
cnts.restoreValue(cntr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
// save this code until we get it working in InsetInfo
|
||||
const map<string, string> InsetCounter::valueTable =
|
||||
{
|
||||
{"Roman", N_("Roman Uppercase")},
|
||||
@ -180,40 +158,43 @@ docstring InsetCounter::value() const {
|
||||
LATTEST(false);
|
||||
return empty_docstring();
|
||||
}
|
||||
#endif
|
||||
|
||||
void InsetCounter::trackCounters(string const & cmd) const
|
||||
{
|
||||
Counters & cnts = buffer().params().documentClass().counters();
|
||||
docstring cntr = getParam("counter");
|
||||
if (cmd == "set") {
|
||||
docstring const & val = getParam("value");
|
||||
cnts.set(cntr, convert<int>(val));
|
||||
} else if (cmd == "addto") {
|
||||
docstring const & val = getParam("value");
|
||||
cnts.addto(cntr, convert<int>(val));
|
||||
} else if (cmd == "reset") {
|
||||
cnts.reset(cntr);
|
||||
} else if (cmd == "save") {
|
||||
cnts.saveValue(cntr);
|
||||
} else if (cmd == "restore") {
|
||||
cnts.restoreValue(cntr);
|
||||
}
|
||||
}
|
||||
|
||||
int InsetCounter::docbook(odocstream & os, OutputParams const &) const
|
||||
int InsetCounter::docbook(odocstream &, OutputParams const &) const
|
||||
{
|
||||
// Here, we need to track counter values ourselves,
|
||||
// since unlike in the LaTeX case, there is no external
|
||||
// mechanism for doing that.
|
||||
string const cmd = getCmdName();
|
||||
if (cmd == "value") {
|
||||
docstring cntr = getParam("counter");
|
||||
Counters & cnts = buffer().params().documentClass().counters();
|
||||
if (cnts.hasCounter(cntr))
|
||||
os << cnts.value(cntr);
|
||||
} else
|
||||
trackCounters(cmd);
|
||||
|
||||
trackCounters(getCmdName());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
docstring InsetCounter::xhtml(XHTMLStream & xs, OutputParams const &) const
|
||||
docstring InsetCounter::xhtml(XHTMLStream &, OutputParams const &) const
|
||||
{
|
||||
// Here, we need to track counter values ourselves,
|
||||
// since unlike in the LaTeX case, there is no external
|
||||
// mechanism for doing that.
|
||||
string const cmd = getCmdName();
|
||||
if (cmd == "value") {
|
||||
docstring cntr = getParam("counter");
|
||||
Counters & cnts = buffer().params().documentClass().counters();
|
||||
if (cnts.hasCounter(cntr))
|
||||
xs << cnts.value(cntr);
|
||||
} else
|
||||
trackCounters(cmd);
|
||||
|
||||
trackCounters(getCmdName());
|
||||
return docstring();
|
||||
}
|
||||
|
||||
@ -250,11 +231,7 @@ void InsetCounter::updateBuffer(ParIterator const &, UpdateType, bool const)
|
||||
cnts.restoreValue(cntr);
|
||||
screen_label_ = bformat(_("Counter: Restore %1$s"), cntr);
|
||||
tooltip_ = bformat(_("Restore value of counter %1$s"), cntr);
|
||||
} else if (cmd == "value") {
|
||||
screen_label_ = bformat(_("Counter: Value %1$s"), cntr);
|
||||
tooltip_ = bformat(_("Display value of counter %1$s"), cntr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,8 +82,6 @@ private:
|
||||
docstring screenLabel() const { return screen_label_; }
|
||||
//@}
|
||||
///
|
||||
docstring value() const;
|
||||
///
|
||||
docstring lyxSaveCounter() const;
|
||||
///
|
||||
void trackCounters(std::string const & cmd) const;
|
||||
|
Loading…
Reference in New Issue
Block a user