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
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()));
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));
- }
}
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");
}
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));
}
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);
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();
}
<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>
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item>
<widget class="QComboBox" name="counterCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
</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>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item>
<widget class="QComboBox" name="actionCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
</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>
- </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>
- </property>
- <property name="buddy">
- <cstring>vtypeCB</cstring>
+ <item>
+ <widget class="QSpinBox" name="valueSB">
+ <property name="maximum">
+ <number>10000</number>
</property>
</widget>
</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>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
</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>
</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>
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")}
};
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_;
cnts.restoreValue(cntr);
os << "\\setcounter{" << cntr
<< "{\\value{" << lyxSaveCounter() << "}}";
- } else if (cmd == "value") {
- os << "\\the" << cntr << "{}";
}
}
}
-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")},
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();
}
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);
}
-
}
docstring screenLabel() const { return screen_label_; }
//@}
///
- docstring value() const;
- ///
docstring lyxSaveCounter() const;
///
void trackCounters(std::string const & cmd) const;