]> git.lyx.org Git - features.git/commitdiff
More polishing of counter dialog. Thanks to Jürgen for help.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 3 May 2020 00:33:03 +0000 (20:33 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 3 May 2020 00:33:03 +0000 (20:33 -0400)
Also, remove the 'display value' option. We will move this to InsetInfo
at some point.

lib/lyx2lyx/lyx_2_4.py
src/frontends/qt/GuiCounter.cpp
src/frontends/qt/ui/CounterUi.ui
src/insets/InsetCounter.cpp
src/insets/InsetCounter.h

index 98173dfaa6cb123d7d8c293af6fbf3f6fa5ceedc..d32ff7903d10d59d2f530e90894bbfae10d25699 100644 (file)
@@ -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
index 6deed4b8d2644fe1442a704288fb277394ec26b6..c3e3265d3e1853efa020a8e84c547040075a83d9 100644 (file)
@@ -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();
 }
 
 
index 16300a89ae5d628d08a4e57e36cbc33020120bd4..72370d2a435e5ea8bbdd58aef05352a82181c3af 100644 (file)
   <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&amp;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">
        </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>&amp;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">
         </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>&amp;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>&amp;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>
index 32f7c6428c85dffc4590985279b4d42a06236750..a6e4d0d56da7c4d98e83653de68a5ee36ee9360d 100644 (file)
@@ -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);
        }
-       
 }
 
 
index 44d909c38460bac0f95e49358d39cd16b78e30ce..92c547e432c649cc2e96158b55a9bd77592ba76a 100644 (file)
@@ -82,8 +82,6 @@ private:
        docstring screenLabel() const { return screen_label_; }
        //@}
        ///
-       docstring value() const;
-       ///
        docstring lyxSaveCounter() const;
        ///
        void trackCounters(std::string const & cmd) const;