]> git.lyx.org Git - features.git/commitdiff
Mini-optimization: We do not need really long tooltips for the TOC.
authorRichard Heck <rgheck@comcast.net>
Wed, 22 Dec 2010 01:29:17 +0000 (01:29 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 22 Dec 2010 01:29:17 +0000 (01:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36989 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetBranch.cpp
src/insets/InsetFoot.cpp
src/insets/InsetMarginal.cpp
src/insets/InsetNote.cpp
src/insets/InsetText.cpp
src/insets/InsetText.h

index 17191cf6b2bd626c818d03f9ac91e9d4bc6ab5dc..62fb7c4442b3d5cc2351734534788de524762d78 100644 (file)
@@ -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);
 }
index 96392d5d83f75f175194ac1b2351169b7528c63c..a2a0099fa9d0f828788976240fce81389b85f1a3 100644 (file)
@@ -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);
 }
index f40e164d03e359b6477399f406a953d5c1aa0082..0250d32370386674ca5bdeee3e7fb6832898f1f3 100644 (file)
@@ -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);
 }
index ed47e40e2271fe463fcd15e6b0a33f6228d7b862..988fab041146d421f7ffe3b467ea2c093dca4450 100644 (file)
@@ -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);
 }
index f8bcef2f670088082b6ee89a8f5d3246ebd4031b..05abde1d225f15ae49c38461517b7c17a13429ca 100644 (file)
@@ -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);
 }
 
 
index 16962ae12aae13e22317da96eae4cae3775591e7..9c30cb90156efe1cd3ede30295c84eda04a6914b 100644 (file)
@@ -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;