QString tooltip = toqstr(bformat(_("%1$s [Class '%2$s']"), guiname, from_utf8(tc.latexname())));
if (!available) {
docstring const output_type = (tc.outputType() == lyx::DOCBOOK) ? _("DocBook") : _("LaTeX");
- tooltip += '\n' + toqstr(wrap(bformat(_("Class not found by LyX. "
+ tooltip += '\n' + toqstr(bformat(_("Class not found by LyX. "
"Please check if you have the matching %1$s class "
"and all required packages (%2$s) installed."),
- output_type, from_utf8(tc.prerequisites(", ")))));
+ output_type, from_utf8(tc.prerequisites(", "))));
}
latexModule->classCO->addItemSort(toqstr(tc.name()),
toqstr(guiname),
QPoint pos = helpEvent->pos();
if (pos.x() < viewport()->width()) {
QString s = toqstr(d->buffer_view_->toolTip(pos.x(), pos.y()));
- QToolTip::showText(helpEvent->globalPos(), s);
+ QToolTip::showText(helpEvent->globalPos(), formatToolTip(s,35));
}
else
QToolTip::hideText();
virtual bool producesOutput() const { return true; }
/// \return Tool tip for this inset.
- /// This default implementation returns an empty string.
+ /// This default implementation returns an empty string. This can be
+ /// either plain text or Qt html, and formatToolTip will be called
+ /// on it before display in both cases.
virtual docstring toolTip(BufferView const & bv, int x, int y) const;
/// \return Context menu identifier. This function determines
docstring InsetBibtex::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*/) const
{
- docstring item = from_ascii("* ");
- docstring tip = _("Databases:") + "\n";
+ docstring tip = _("Databases:");
vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
- if (bibfilelist.empty()) {
- tip += item;
- tip += _("none");
- } else {
- vector<docstring>::const_iterator it = bibfilelist.begin();
- vector<docstring>::const_iterator en = bibfilelist.end();
- for (; it != en; ++it) {
- tip += item;
- tip += *it + "\n";
- }
- }
+ tip += "<ul>";
+ if (bibfilelist.empty())
+ tip += "<li>" + _("none") + "</li>";
+ else
+ for (docstring const & bibfile : bibfilelist)
+ tip += "<li>" + bibfile + "</li>";
+ tip += "</ul>";
// Style-Options
bool toc = false;
style = split(style, bibtotoc, char_type(','));
}
- tip += _("Style File:") +"\n";
- tip += item;
- if (!style.empty())
- tip += style;
- else
- tip += _("none");
+ tip += _("Style File:");
+ tip += "<ul><li>" + (style.empty() ? _("none") : style) + "</li></ul>";
- tip += "\n" + _("Lists:") + " ";
+ tip += _("Lists:") + " ";
docstring btprint = getParam("btprint");
if (btprint == "btPrintAll")
tip += _("all references");
return _("No citations selected!");
vector<docstring> keys = getVectorFromString(key);
- vector<docstring>::const_iterator it = keys.begin();
- vector<docstring>::const_iterator en = keys.end();
+ if (keys.size() == 1)
+ return bi.getInfo(keys[0], buffer(), true);
+
docstring tip;
- for (; it != en; ++it) {
- docstring const key_info = bi.getInfo(*it, buffer());
+ tip += "<ol>";
+ for (docstring const & key : keys) {
+ docstring const key_info = bi.getInfo(key, buffer(), true);
if (key_info.empty())
continue;
- if (!tip.empty())
- tip += "\n";
- tip += wrap(key_info, -4);
+ tip += "<li>" + key_info + "</li>";
}
+ tip += "</ol>";
return tip;
}
}
-docstring InsetText::toolTipText(docstring prefix,
- size_t numlines, size_t len) const
+docstring InsetText::toolTipText(docstring prefix, size_t const len) const
{
- size_t const max_length = numlines * len;
OutputParams rp(&buffer().params().encoding());
rp.for_tooltip = true;
odocstringstream oss;
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, max_length);
- str = oss.str();
- if (str.length() >= max_length)
+ writePlaintextParagraph(buffer(), *it, oss, rp, ref_printed, len);
+ if (oss.tellp() >= 0 && size_t(oss.tellp()) > len)
break;
}
- return support::wrapParas(str, 4, len, numlines);
+ docstring str = oss.str();
+ support::truncateWithEllipsis(str, len);
+ return str;
}
/// returns the text to be used as tooltip
/// \param prefix: a string that will preced the tooltip,
/// e.g., "Index: ".
- /// \param numlines: the number of lines in the tooltip
- /// \param len: length of those lines
+ /// \param len: length of the resulting string
/// 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.
+ /// of that sort. (Note: unnecessary internal copies have been removed
+ /// since the previous note. The efficiency would have to be assessed
+ /// again by profiling.)
docstring toolTipText(docstring prefix = empty_docstring(),
- size_t numlines = 5, size_t len = 80) const;
+ size_t len = 400) const;
///
std::string contextMenu(BufferView const &, int, int) const;