From 897404e34dbf5e0ba3b61e5c889f906a2dfb3fce Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 17 Nov 2010 17:25:22 +0000 Subject: [PATCH] Simplify more of the tooltips. There will be some speed improvements here, but not very noticeable, I think, as these ones aren't called by the addToToc stuff. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36347 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetBranch.cpp | 8 +++----- src/insets/InsetCollapsable.cpp | 2 +- src/insets/InsetFloat.cpp | 4 ++-- src/insets/InsetFoot.cpp | 8 ++++---- src/insets/InsetIndex.cpp | 2 +- src/insets/InsetPhantom.cpp | 7 ++----- src/insets/InsetWrap.cpp | 9 +++++---- 7 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 82b5ad8dac..687d4727ab 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -62,17 +62,15 @@ void InsetBranch::read(Lexer & lex) } -docstring InsetBranch::toolTip(BufferView const & bv, int x, int y) const +docstring InsetBranch::toolTip(BufferView const & bv, int, int) const { docstring const status = isBranchSelected() ? _("active") : _("non-active"); docstring const heading = support::bformat(_("Branch (%1$s): %2$s"), status, params_.branch); - docstring const contents = InsetCollapsable::toolTip(bv, x, y); - if (isOpen(bv) || contents.empty()) + if (isOpen(bv)) return heading; - else - return heading + from_ascii("\n") + contents; + return toolTipText(heading + from_ascii("\n")); } diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 8f233f761b..949bab70dc 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -130,7 +130,7 @@ InsetCollapsable::Geometry InsetCollapsable::geometry() const docstring InsetCollapsable::toolTip(BufferView const & bv, int x, int y) const { - Dimension dim = dimensionCollapsed(bv); + Dimension const dim = dimensionCollapsed(bv); if (geometry(bv) == NoButton) return translateIfPossible(getLayout().labelstring()); if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des || isOpen(bv)) diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index 421b106a69..ccded2f3c6 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -127,8 +127,8 @@ docstring InsetFloat::name() const docstring InsetFloat::toolTip(BufferView const & bv, int x, int y) const { - if (InsetCollapsable::toolTip(bv, x, y).empty() || isOpen(bv)) - return docstring(); + if (isOpen(bv)) + return InsetCollapsable::toolTip(bv, x, y); OutputParams rp(&buffer().params().encoding()); return getCaptionText(rp); diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index fd8038f4ee..167102313e 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -75,10 +75,10 @@ void InsetFoot::addToToc(DocIterator const & cpit) docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const { - docstring default_tip = InsetCollapsable::toolTip(bv, x, y); - if (!isOpen(bv)) - return custom_label_ + "\n" + default_tip; - return default_tip; + if (isOpen(bv)) + // this will give us something useful if there is no button + return InsetCollapsable::toolTip(bv, x, y); + return toolTipText(custom_label_); } diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 194ccb8eca..a9e5f99cef 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -288,7 +288,7 @@ docstring InsetIndex::toolTip(BufferView const &, int, int) const tip += ")"; } tip += ": "; - return InsetText::toolTipText(tip); + return toolTipText(tip); } diff --git a/src/insets/InsetPhantom.cpp b/src/insets/InsetPhantom.cpp index a3c5735998..238ae14d3f 100644 --- a/src/insets/InsetPhantom.cpp +++ b/src/insets/InsetPhantom.cpp @@ -299,11 +299,8 @@ bool InsetPhantom::getStatus(Cursor & cur, FuncRequest const & cmd, docstring InsetPhantom::toolTip(BufferView const &, int, int) const { - docstring const tip = InsetText::toolTipText(); - docstring res = phantomtranslator_loc().find(params_.type); - if (!tip.empty()) - res += from_ascii(": ") + "\n" + tip; - return res; + docstring const res = phantomtranslator_loc().find(params_.type); + return toolTipText(res + from_ascii(": ")); } diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index 4ee0f7eed7..f29c06ee97 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -66,12 +66,13 @@ docstring InsetWrap::name() const docstring InsetWrap::toolTip(BufferView const & bv, int x, int y) const { + if (isOpen(bv)) + return InsetCollapsable::toolTip(bv, x, y); OutputParams rp(&buffer().params().encoding()); - docstring default_tip = InsetCollapsable::toolTip(bv, x, y); docstring caption_tip = getCaptionText(rp); - if (!isOpen(bv) && !caption_tip.empty()) - return caption_tip + '\n' + default_tip; - return default_tip; + if (!caption_tip.empty()) + caption_tip += from_ascii("\n"); + return toolTipText(caption_tip); }