mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Optimize InsetText::toolTipText() a bit. The old version was doing
plaintext() on the entire inset, even though the tooltip is only going to show the first few lines. This could make things slow when you had a lot of branches, because this is called by InsetBranch::addToToc(). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36345 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a7629d2bfc
commit
7d0b98a858
@ -822,13 +822,25 @@ docstring InsetText::contextMenu(BufferView const &, int, int) const
|
||||
|
||||
docstring InsetText::toolTipText() const
|
||||
{
|
||||
static unsigned int max_length = 400; // five 80 column lines
|
||||
OutputParams rp(&buffer().params().encoding());
|
||||
odocstringstream ods;
|
||||
// do not remove InsetText::, otherwise there
|
||||
// will be no tooltip text for InsetNotes
|
||||
InsetText::plaintext(ods, rp);
|
||||
docstring const content_tip = ods.str();
|
||||
return support::wrapParas(content_tip, 4);
|
||||
odocstringstream oss;
|
||||
|
||||
ParagraphList::const_iterator beg = paragraphs().begin();
|
||||
ParagraphList::const_iterator end = paragraphs().end();
|
||||
ParagraphList::const_iterator it = beg;
|
||||
bool ref_printed = false;
|
||||
docstring str;
|
||||
|
||||
for (; it != end; ++it) {
|
||||
if (it != beg)
|
||||
oss << '\n';
|
||||
writePlaintextParagraph(buffer(), *it, oss, rp, ref_printed);
|
||||
str = oss.str();
|
||||
if (str.length() > max_length)
|
||||
break;
|
||||
}
|
||||
return support::wrapParas(str, 4, 80, 5);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user