commit 1f380191195926258c6f312a696017cef415ce0b
Author: Juergen Spitzmueller <[email protected]>
Date: Fri Mar 27 12:57:13 2026 +0100
Display hierarchical index entries in outliner as tree
(cherry picked from commit 900cce27da0273206f4b40905f2c225debd7c4d6)
---
src/insets/InsetIndex.cpp | 38 +++++++++++++++++++++-----------------
src/insets/InsetIndex.h | 3 ++-
status.25x | 4 ++++
3 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index b62e79a564..a03d4fae97 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -815,7 +815,8 @@ void InsetIndex::getSubentries(otexstream & os,
OutputParams const & runparams,
std::vector<docstring> InsetIndex::getSubentriesAsText(OutputParams const &
runparams,
- bool const asLabel) const
+ bool const asLabel,
+ pos_type const
max_length) const
{
std::vector<docstring> subentries;
@@ -833,7 +834,7 @@ std::vector<docstring>
InsetIndex::getSubentriesAsText(OutputParams const & runp
break;
if (asLabel) {
docstring const l;
- docstring const sl = iim.getNewLabel(l);
+ docstring const sl = iim.getNewLabel(l,
max_length);
subentries.emplace_back(sl);
} else {
otexstringstream os;
@@ -1140,32 +1141,35 @@ void InsetIndex::addToToc(DocIterator const & cpit,
bool output_active,
docstring str;
InsetLayout const & il = getLayout();
docstring label = translateIfPossible(il.labelstring());
+ string type = "index";
+ if (buffer().masterBuffer()->params().use_indices)
+ type += ":" + to_utf8(params_.index);
+ shared_ptr<Toc> toc = backend.toc(type);
if (!il.contentaslabel())
- str = label;
+ toc->push_back(TocItem(cpit, 0, label, output_active));
else {
+ str = getNewLabel(label, TOC_ENTRY_LENGTH);
OutputParams const rp(0);
- vector<docstring> sublbls = getSubentriesAsText(rp, true);
- docstring sublabel;
- for (auto const & sublbl : sublbls) {
- sublabel += " " + docstring(1, char_type(0x2023));//
TRIANGULAR BULLET
- sublabel += " " + sublbl;
- }
docstring see = getSeeAsText(rp, true);
if (see.empty() && !getSeeAlsoesAsText(rp, true).empty())
see = getSeeAlsoesAsText(rp, true).front();
if (!see.empty())
see = " " + docstring(1, char_type(0x261e)) + see;//
WHITE RIGHT POINTING INDEX
- int const maxlen = TOC_ENTRY_LENGTH - sublabel.size() -
see.size();
- str = getNewLabel(label, maxlen) + sublabel + see;
+ vector<docstring> sublbls = getSubentriesAsText(rp, true,
TOC_ENTRY_LENGTH);
+ if (sublbls.empty() && !see.empty())
+ str += see;
+ toc->push_back(TocItem(cpit, 0, str, output_active));
+ int item_depth = 1;
+ for (auto const & sublbl : sublbls) {
+ if (item_depth == int(sublbls.size()))
+ toc->push_back(TocItem(cpit, item_depth, sublbl
+ see, output_active));
+ else
+ toc->push_back(TocItem(cpit, item_depth,
sublbl, output_active));
+ ++item_depth;
+ }
}
- string type = "index";
- if (buffer().masterBuffer()->params().use_indices)
- type += ":" + to_utf8(params_.index);
- TocBuilder & b = backend.builder(type);
- b.pushItem(pit, str, output_active);
// Proceed with the rest of the inset.
InsetCollapsible::addToToc(cpit, output_active, utype, backend);
- b.pop();
}
diff --git a/src/insets/InsetIndex.h b/src/insets/InsetIndex.h
index c415c1acd6..82b1eebe75 100644
--- a/src/insets/InsetIndex.h
+++ b/src/insets/InsetIndex.h
@@ -110,7 +110,8 @@ private:
void getSubentries(otexstream &, OutputParams const &, docstring const
&) const;
///
std::vector<docstring> getSubentriesAsText(OutputParams const &,
- bool const asLabel = false)
const;
+ bool const asLabel = false,
+ pos_type const max_length =
15) const;
///
docstring getMainSubentryAsText(OutputParams const & runparams) const;
///
diff --git a/status.25x b/status.25x
index cb99752c09..3c9b6cc8ff 100644
--- a/status.25x
+++ b/status.25x
@@ -25,6 +25,10 @@ What's new
- Improve keyboard navigation in Cross-References dialog.
+- Improve the display of index entries in the outliner (bug 13289):
+ 1. Abbreviate long entries
+ 2. Display hierarchical entries as tree
+
- Use cached citation labels for statistics and plaintext to
improve performance (bug 13322).
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs