From: Richard Heck Date: Thu, 26 Nov 2015 20:21:21 +0000 (-0500) Subject: Use the much faster forOutliner also to get the tooltip text. X-Git-Tag: 2.2.0beta1~395 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=cf64064db71ddedb4deb888e63325cea8619a9cd;p=features.git Use the much faster forOutliner also to get the tooltip text. --- diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index ae2e6def1f..0c5feb0cf2 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3269,8 +3269,6 @@ void Paragraph::forOutliner(docstring & os, size_t const maxlen, char_type const c = d->text_[i]; if (isPrintable(c)) os += c; - else if (c == '\t' || c == '\n') - os += ' '; else if (c == META_INSET) getInset(i)->forOutliner(os, tmplen, false); } diff --git a/src/insets/Inset.h b/src/insets/Inset.h index f92883037b..96071faf7d 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -74,7 +74,7 @@ std::string insetName(InsetCode); /// Eg, insetDisplayName(BRANCH_CODE) == _("Branch") docstring insetDisplayName(InsetCode); /// -static int const TOC_ENTRY_LENGTH = 128; +static int const TOC_ENTRY_LENGTH = 120; /// Common base class to all insets diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 6c78d443c0..7d2d4d51cb 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -356,11 +356,15 @@ void InsetBranch::addToToc(DocIterator const & cpit, bool output_active, { DocIterator pit = cpit; pit.push_back(CursorSlice(const_cast(*this))); - + + docstring tooltip; + text().forOutliner(tooltip, TOC_ENTRY_LENGTH); + docstring str = params_.branch + ": " + tooltip; + tooltip = support::wrapParas(tooltip, 0, 60, 2); + shared_ptr toc = buffer().tocBackend().toc("branch"); - docstring str = params_.branch + ": "; - text().forOutliner(str, TOC_ENTRY_LENGTH); - toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60))); + toc->push_back(TocItem(pit, 0, str, output_active, tooltip)); + // Proceed with the rest of the inset. bool const doing_output = output_active && isBranchSelected(); InsetCollapsable::addToToc(cpit, doing_output, utype); diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index d1b753d52f..7008fda976 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -26,6 +26,7 @@ #include "support/debug.h" #include "support/docstream.h" #include "support/gettext.h" +#include "support/lstrings.h" using namespace std; @@ -79,11 +80,15 @@ void InsetFoot::addToToc(DocIterator const & cpit, bool output_active, { DocIterator pit = cpit; pit.push_back(CursorSlice(const_cast(*this))); - + + docstring tooltip; + text().forOutliner(tooltip, TOC_ENTRY_LENGTH); + docstring str = custom_label_ + ": " + tooltip; + tooltip = support::wrapParas(tooltip, 0, 60, 2); + shared_ptr toc = buffer().tocBackend().toc("footnote"); - docstring str = custom_label_ + ": "; - text().forOutliner(str, TOC_ENTRY_LENGTH); - toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60))); + toc->push_back(TocItem(pit, 0, str, output_active, tooltip)); + // Proceed with the rest of the inset. InsetFootlike::addToToc(cpit, output_active, utype); } diff --git a/src/insets/InsetMarginal.cpp b/src/insets/InsetMarginal.cpp index 40ff30aaba..cb85ab3c20 100644 --- a/src/insets/InsetMarginal.cpp +++ b/src/insets/InsetMarginal.cpp @@ -20,6 +20,7 @@ #include "support/docstream.h" #include "support/gettext.h" +#include "support/lstrings.h" namespace lyx { @@ -57,10 +58,14 @@ void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active, DocIterator pit = cpit; pit.push_back(CursorSlice(const_cast(*this))); + docstring tooltip; + text().forOutliner(tooltip, TOC_ENTRY_LENGTH); + docstring const str = tooltip; + tooltip = support::wrapParas(tooltip, 0, 60, 2); + shared_ptr toc = buffer().tocBackend().toc("marginalnote"); - docstring str; - text().forOutliner(str, TOC_ENTRY_LENGTH); - toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60))); + toc->push_back(TocItem(pit, 0, str, output_active, tooltip)); + // Proceed with the rest of the inset. InsetFootlike::addToToc(cpit, output_active, utype); } diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 6fcf2794bb..e483cf2e10 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -37,6 +37,7 @@ #include "support/debug.h" #include "support/docstream.h" #include "support/gettext.h" +#include "support/lstrings.h" #include "support/Translator.h" #include "frontends/Application.h" @@ -213,11 +214,14 @@ void InsetNote::addToToc(DocIterator const & cpit, bool output_active, DocIterator pit = cpit; pit.push_back(CursorSlice(const_cast(*this))); - shared_ptr toc = buffer().tocBackend().toc("note"); InsetLayout const & il = getLayout(); - docstring str = translateIfPossible(il.labelstring()) + from_ascii(": "); - text().forOutliner(str, TOC_ENTRY_LENGTH); - toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60))); + docstring tooltip; + text().forOutliner(tooltip, TOC_ENTRY_LENGTH); + docstring str = translateIfPossible(il.labelstring()) + ": " + tooltip; + tooltip = support::wrapParas(tooltip, 0, 60, 2); + + shared_ptr toc = buffer().tocBackend().toc("note"); + toc->push_back(TocItem(pit, 0, str, output_active, tooltip)); // Proceed with the rest of the inset. bool doing_output = output_active && producesOutput(); diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index c0640a1115..52ea7afc7f 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -201,6 +201,9 @@ public: /// e.g., "Index: ". /// \param numlines: the number of lines in the tooltip /// \param len: length of those lines + /// NOTE This routine is kind of slow. It's fine to use it within the + /// GUI, but definitely do not try to use it in updateBuffer or anything + /// of that sort. docstring toolTipText(docstring prefix = empty_docstring(), size_t numlines = 5, size_t len = 80) const;