From: Richard Heck Date: Wed, 22 Dec 2010 01:29:17 +0000 (+0000) Subject: Mini-optimization: We do not need really long tooltips for the TOC. X-Git-Tag: 2.0.0~1277 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1f44b8a5c05be4fdb681fe3c26cd31b12298508a;p=features.git Mini-optimization: We do not need really long tooltips for the TOC. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36989 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 17191cf6b2..62fb7c4442 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -302,7 +302,7 @@ void InsetBranch::addToToc(DocIterator const & cpit) Toc & toc = buffer().tocBackend().toc("branch"); docstring str = params_.branch + ": "; text().forToc(str, TOC_ENTRY_LENGTH); - toc.push_back(TocItem(pit, 0, str, toolTipText())); + toc.push_back(TocItem(pit, 0, str, toolTipText(docstring(), 3, 60))); // Proceed with the rest of the inset. InsetCollapsable::addToToc(cpit); } diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index 96392d5d83..a2a0099fa9 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -69,7 +69,7 @@ void InsetFoot::addToToc(DocIterator const & cpit) Toc & toc = buffer().tocBackend().toc("footnote"); docstring str = custom_label_ + ": "; text().forToc(str, TOC_ENTRY_LENGTH); - toc.push_back(TocItem(pit, 0, str, toolTipText())); + toc.push_back(TocItem(pit, 0, str, toolTipText(docstring(), 3, 60))); // Proceed with the rest of the inset. InsetFootlike::addToToc(cpit); } diff --git a/src/insets/InsetMarginal.cpp b/src/insets/InsetMarginal.cpp index f40e164d03..0250d32370 100644 --- a/src/insets/InsetMarginal.cpp +++ b/src/insets/InsetMarginal.cpp @@ -59,7 +59,7 @@ void InsetMarginal::addToToc(DocIterator const & cpit) Toc & toc = buffer().tocBackend().toc("marginalnote"); docstring str; text().forToc(str, TOC_ENTRY_LENGTH); - toc.push_back(TocItem(pit, 0, str, toolTipText())); + toc.push_back(TocItem(pit, 0, str, toolTipText(docstring(), 3, 60))); // Proceed with the rest of the inset. InsetFootlike::addToToc(cpit); } diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index ed47e40e22..988fab0411 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -204,7 +204,7 @@ void InsetNote::addToToc(DocIterator const & cpit) InsetLayout const & il = getLayout(); docstring str = translateIfPossible(il.labelstring()) + from_ascii(": "); text().forToc(str, TOC_ENTRY_LENGTH); - toc.push_back(TocItem(pit, 0, str, toolTipText())); + toc.push_back(TocItem(pit, 0, str, toolTipText(docstring(), 3, 60))); // Proceed with the rest of the inset. InsetCollapsable::addToToc(cpit); } diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index f8bcef2f67..05abde1d22 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -824,9 +824,10 @@ docstring InsetText::contextMenuName() const } -docstring InsetText::toolTipText(docstring prefix) const +docstring InsetText::toolTipText(docstring prefix, + size_t numlines, size_t len) const { - static unsigned int max_length = 400; // five 80 column lines + size_t const max_length = numlines * len; OutputParams rp(&buffer().params().encoding()); odocstringstream oss; oss << prefix; @@ -845,7 +846,7 @@ docstring InsetText::toolTipText(docstring prefix) const if (str.length() > max_length) break; } - return support::wrapParas(str, 4, 80, 5); + return support::wrapParas(str, 4, len, numlines); } diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 16962ae12a..9c30cb9015 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -195,7 +195,10 @@ public: /// returns the text to be used as tooltip /// \param prefix: a string that will preced the tooltip, /// e.g., "Index: ". - docstring toolTipText(docstring prefix = empty_docstring()) const; + /// \param numlines: the number of lines in the tooltip + /// \param len: length of those lines + docstring toolTipText(docstring prefix = empty_docstring(), + size_t numlines = 5, size_t len = 80) const; /// docstring contextMenu(BufferView const &, int, int) const;