]> git.lyx.org Git - features.git/commitdiff
Use the much faster forOutliner also to get the tooltip text.
authorRichard Heck <rgheck@lyx.org>
Thu, 26 Nov 2015 20:21:21 +0000 (15:21 -0500)
committerRichard Heck <rgheck@lyx.org>
Sat, 12 Dec 2015 22:19:33 +0000 (17:19 -0500)
src/Paragraph.cpp
src/insets/Inset.h
src/insets/InsetBranch.cpp
src/insets/InsetFoot.cpp
src/insets/InsetMarginal.cpp
src/insets/InsetNote.cpp
src/insets/InsetText.h

index ae2e6def1ff6ebda935983c446d775ee5f96d796..0c5feb0cf23a93082cfc2cc066bb3c37fd05ec1d 100644 (file)
@@ -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);
        }
index f92883037b67624c5a42918c98131acdcbd2f405..96071faf7dd7e716bef8622c7440f9a9654c865c 100644 (file)
@@ -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
 
index 6c78d443c05a0a682fb85519ff06974e8fcf99f4..7d2d4d51cb36adb9529326219c0d75bbad96c9c4 100644 (file)
@@ -356,11 +356,15 @@ void InsetBranch::addToToc(DocIterator const & cpit, bool output_active,
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this)));
-
+       
+       docstring tooltip;
+       text().forOutliner(tooltip, TOC_ENTRY_LENGTH);
+       docstring str = params_.branch + ": " + tooltip;
+       tooltip = support::wrapParas(tooltip, 0, 60, 2);
+       
        shared_ptr<Toc> 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);
index d1b753d52fc661ef923e322427425b4a358b45f3..7008fda976c7db3f753581e18797b978ca634d67 100644 (file)
@@ -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<InsetFoot &>(*this)));
-
+       
+       docstring tooltip;
+       text().forOutliner(tooltip, TOC_ENTRY_LENGTH);
+       docstring str = custom_label_ + ": " + tooltip;
+       tooltip = support::wrapParas(tooltip, 0, 60, 2);
+       
        shared_ptr<Toc> 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);
 }
index 40ff30aaba21028a56c7fc2ecd0242e3183bd531..cb85ab3c2045bf2028a2890f3569165ea9c5cb98 100644 (file)
@@ -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<InsetMarginal &>(*this)));
 
+       docstring tooltip;
+       text().forOutliner(tooltip, TOC_ENTRY_LENGTH);
+       docstring const str = tooltip;
+       tooltip = support::wrapParas(tooltip, 0, 60, 2);
+       
        shared_ptr<Toc> 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);
 }
index 6fcf2794bb649d81f1dee8622df22dcc9cab769a..e483cf2e104a6ab9db38d223e843d362b3b97b03 100644 (file)
@@ -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<InsetNote &>(*this)));
        
-       shared_ptr<Toc> 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> 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();
index c0640a1115d6a03eb5223f545784a5edea80555c..52ea7afc7f82f76729f59a4b057fedfcddb7bb58 100644 (file)
@@ -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;