Tooltips: Avoid showing too much content.

Reviewed-by: Tobias Hunger
This commit is contained in:
Leandro Melo
2010-09-30 17:43:43 +02:00
parent 4c185a9ac4
commit 4537a7eb38

View File

@@ -180,28 +180,32 @@ void HtmlDocExtractor::processOutput(QString *html) const
return; return;
if (m_mode == FirstParagraph) { if (m_mode == FirstParagraph) {
int index = html->indexOf(QLatin1String("</p>")); // Try to get the entire first paragraph, but if one is not found or if its opening
if (index > 0) { // tag is not in the very beginning (using an empirical value as the limit) the html
if (html->at(index - 1) == QLatin1Char('.')) { // is cleared to avoid too much content.
index += 4; int index = html->indexOf(QLatin1String("<p>"));
html->truncate(index); if (index != -1 && index < 400) {
} else { index = html->indexOf(QLatin1String("</p>"), index + 2);
// <p>Paragraphs similar to this. Example:</p> if (index != -1) {
index = html->lastIndexOf(QLatin1Char('.'), index); if (html->at(index - 1) == QLatin1Char('.')) {
if (index > 0) { html->truncate(index + 4);
html->truncate(index); } else {
html->append(QLatin1String(".</p>")); // <p>Paragraphs similar to this. Example:</p>
index = html->lastIndexOf(QLatin1Char('.'), index);
if (index != -1) {
html->truncate(index);
html->append(QLatin1String(".</p>"));
}
} }
} else {
html->clear();
} }
} else { } else {
// Some enumerations don't have paragraphs and just a table with the items. In such
// cases the the html is cleared to avoid showing more that desired.
html->clear(); html->clear();
return;
} }
} }
if (m_formatContents) { if (!html->isEmpty() && m_formatContents) {
stripBold(html); stripBold(html);
replaceNonStyledHeadingsForBold(html); replaceNonStyledHeadingsForBold(html);
replaceTablesForSimpleLines(html); replaceTablesForSimpleLines(html);