]> git.lyx.org Git - features.git/commitdiff
Display subinsets in inset button and outliner
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 31 Oct 2022 05:04:13 +0000 (06:04 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 31 Oct 2022 05:04:13 +0000 (06:04 +0100)
src/insets/InsetIndex.cpp
src/insets/InsetIndex.h

index 25dfb4649ba57dc410b86a5e4d1ec19a0a946b0e..5f4cb7e93fc49ab81d4738118603d9dfb15d46cb 100644 (file)
@@ -687,7 +687,8 @@ void InsetIndex::getSubentries(otexstream & os, OutputParams const & runparams)
 }
 
 
-std::vector<docstring> InsetIndex::getSubentriesAsText(OutputParams const & runparams) const
+std::vector<docstring> InsetIndex::getSubentriesAsText(OutputParams const & runparams,
+                                                      bool const asLabel) const
 {
        std::vector<docstring> subentries;
 
@@ -703,10 +704,15 @@ std::vector<docstring> InsetIndex::getSubentriesAsText(OutputParams const & runp
                                ++i;
                                if (i > 2)
                                        break;
-
-                               otexstringstream os;
-                               iim.getLatex(os, runparams);
-                               subentries.emplace_back(os.str());
+                               if (asLabel) {
+                                       docstring const l;
+                                       docstring const sl = iim.getNewLabel(l);
+                                       subentries.emplace_back(sl);
+                               } else {
+                                       otexstringstream os;
+                                       iim.getLatex(os, runparams);
+                                       subentries.emplace_back(os.str());
+                               }
                        }
                }
        }
@@ -926,8 +932,15 @@ docstring const InsetIndex::buttonLabel(BufferView const & bv) const
        docstring res;
        if (!il.contentaslabel() || geometry(bv) != ButtonOnly)
                res = label;
-       else
+       else {
                res = getNewLabel(label);
+               OutputParams const rp(0);
+               vector<docstring> sublbls = getSubentriesAsText(rp, true);
+               for (auto const & sublbl : sublbls) {
+                       res += " " + docstring(1, char_type(0x2023));// TRIANGULAR BULLET
+                       res += " " + sublbl;
+               }
+       }
        if (!insetindexpagerangetranslator_latex().find(params_.range).empty())
                res += " " + from_ascii(insetindexpagerangetranslator_latex().find(params_.range));
        return res;
@@ -979,11 +992,22 @@ void InsetIndex::addToToc(DocIterator const & cpit, bool output_active,
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetIndex &>(*this)));
        docstring str;
+       InsetLayout const & il = getLayout();
+       docstring label = translateIfPossible(il.labelstring());
+       if (!il.contentaslabel())
+               str = label;
+       else {
+               str = getNewLabel(label);
+               OutputParams const rp(0);
+               vector<docstring> sublbls = getSubentriesAsText(rp, true);
+               for (auto const & sublbl : sublbls) {
+                       str += " " + docstring(1, char_type(0x2023));// TRIANGULAR BULLET
+                       str += " " + sublbl;
+               }
+       }
        string type = "index";
        if (buffer().masterBuffer()->params().use_indices)
                type += ":" + to_utf8(params_.index);
-       // this is unlikely to be terribly long
-       text().forOutliner(str, INT_MAX);
        TocBuilder & b = backend.builder(type);
        b.pushItem(pit, str, output_active);
        // Proceed with the rest of the inset.
index 5ecf6befdcd9123da2c70e6bc87de5d303331f2e..1aaf2d79f321c4a9e0d11b3d2063923431cb8c8e 100644 (file)
@@ -104,7 +104,8 @@ private:
        ///
        void getSubentries(otexstream &, OutputParams const &) const;
        ///
-       std::vector<docstring> getSubentriesAsText(OutputParams const &) const;
+       std::vector<docstring> getSubentriesAsText(OutputParams const &,
+                                                  bool const asLabel = false) const;
        ///
        docstring getMainSubentryAsText(OutputParams const & runparams) const;
        ///