Use the much faster forOutliner also to get the tooltip text.

This commit is contained in:
Richard Heck 2015-11-26 15:21:21 -05:00
parent a5ea77410e
commit cf64064db7
7 changed files with 37 additions and 18 deletions

View File

@ -3269,8 +3269,6 @@ void Paragraph::forOutliner(docstring & os, size_t const maxlen,
char_type const c = d->text_[i]; char_type const c = d->text_[i];
if (isPrintable(c)) if (isPrintable(c))
os += c; os += c;
else if (c == '\t' || c == '\n')
os += ' ';
else if (c == META_INSET) else if (c == META_INSET)
getInset(i)->forOutliner(os, tmplen, false); getInset(i)->forOutliner(os, tmplen, false);
} }

View File

@ -74,7 +74,7 @@ std::string insetName(InsetCode);
/// Eg, insetDisplayName(BRANCH_CODE) == _("Branch") /// Eg, insetDisplayName(BRANCH_CODE) == _("Branch")
docstring insetDisplayName(InsetCode); docstring insetDisplayName(InsetCode);
/// ///
static int const TOC_ENTRY_LENGTH = 128; static int const TOC_ENTRY_LENGTH = 120;
/// Common base class to all insets /// Common base class to all insets

View File

@ -357,10 +357,14 @@ void InsetBranch::addToToc(DocIterator const & cpit, bool output_active,
DocIterator pit = cpit; DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this))); 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"); shared_ptr<Toc> toc = buffer().tocBackend().toc("branch");
docstring str = params_.branch + ": "; toc->push_back(TocItem(pit, 0, str, output_active, tooltip));
text().forOutliner(str, TOC_ENTRY_LENGTH);
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
// Proceed with the rest of the inset. // Proceed with the rest of the inset.
bool const doing_output = output_active && isBranchSelected(); bool const doing_output = output_active && isBranchSelected();
InsetCollapsable::addToToc(cpit, doing_output, utype); InsetCollapsable::addToToc(cpit, doing_output, utype);

View File

@ -26,6 +26,7 @@
#include "support/debug.h" #include "support/debug.h"
#include "support/docstream.h" #include "support/docstream.h"
#include "support/gettext.h" #include "support/gettext.h"
#include "support/lstrings.h"
using namespace std; using namespace std;
@ -80,10 +81,14 @@ void InsetFoot::addToToc(DocIterator const & cpit, bool output_active,
DocIterator pit = cpit; DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this))); 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"); shared_ptr<Toc> toc = buffer().tocBackend().toc("footnote");
docstring str = custom_label_ + ": "; toc->push_back(TocItem(pit, 0, str, output_active, tooltip));
text().forOutliner(str, TOC_ENTRY_LENGTH);
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
// Proceed with the rest of the inset. // Proceed with the rest of the inset.
InsetFootlike::addToToc(cpit, output_active, utype); InsetFootlike::addToToc(cpit, output_active, utype);
} }

View File

@ -20,6 +20,7 @@
#include "support/docstream.h" #include "support/docstream.h"
#include "support/gettext.h" #include "support/gettext.h"
#include "support/lstrings.h"
namespace lyx { namespace lyx {
@ -57,10 +58,14 @@ void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active,
DocIterator pit = cpit; DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetMarginal &>(*this))); 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"); shared_ptr<Toc> toc = buffer().tocBackend().toc("marginalnote");
docstring str; toc->push_back(TocItem(pit, 0, str, output_active, tooltip));
text().forOutliner(str, TOC_ENTRY_LENGTH);
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
// Proceed with the rest of the inset. // Proceed with the rest of the inset.
InsetFootlike::addToToc(cpit, output_active, utype); InsetFootlike::addToToc(cpit, output_active, utype);
} }

View File

@ -37,6 +37,7 @@
#include "support/debug.h" #include "support/debug.h"
#include "support/docstream.h" #include "support/docstream.h"
#include "support/gettext.h" #include "support/gettext.h"
#include "support/lstrings.h"
#include "support/Translator.h" #include "support/Translator.h"
#include "frontends/Application.h" #include "frontends/Application.h"
@ -213,11 +214,14 @@ void InsetNote::addToToc(DocIterator const & cpit, bool output_active,
DocIterator pit = cpit; DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetNote &>(*this))); pit.push_back(CursorSlice(const_cast<InsetNote &>(*this)));
shared_ptr<Toc> toc = buffer().tocBackend().toc("note");
InsetLayout const & il = getLayout(); InsetLayout const & il = getLayout();
docstring str = translateIfPossible(il.labelstring()) + from_ascii(": "); docstring tooltip;
text().forOutliner(str, TOC_ENTRY_LENGTH); text().forOutliner(tooltip, TOC_ENTRY_LENGTH);
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60))); 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. // Proceed with the rest of the inset.
bool doing_output = output_active && producesOutput(); bool doing_output = output_active && producesOutput();

View File

@ -201,6 +201,9 @@ public:
/// e.g., "Index: ". /// e.g., "Index: ".
/// \param numlines: the number of lines in the tooltip /// \param numlines: the number of lines in the tooltip
/// \param len: length of those lines /// \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(), docstring toolTipText(docstring prefix = empty_docstring(),
size_t numlines = 5, size_t len = 80) const; size_t numlines = 5, size_t len = 80) const;