From 9c7502b0e5056da021ace0195e53d5b7b410120b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 18 Mar 2019 16:49:41 +0100 Subject: Assistant: Rewrite the search result list formatting to use QTextStream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-74353 Change-Id: Ia1a08949d26bbfa288b83a2553f181c587296d3b Reviewed-by: Topi Reiniƶ Reviewed-by: Kai Koehne --- src/assistant/help/qhelpsearchresultwidget.cpp | 47 +++++++++++++------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/assistant/help/qhelpsearchresultwidget.cpp b/src/assistant/help/qhelpsearchresultwidget.cpp index 887916aca..22b0bb4b2 100644 --- a/src/assistant/help/qhelpsearchresultwidget.cpp +++ b/src/assistant/help/qhelpsearchresultwidget.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -71,39 +72,39 @@ public: void showResultPage(const QVector results, bool isIndexing) { - QString htmlFile = QString(QLatin1String("%1" - "")).arg(tr("Search Results")); + QString htmlFile; + QTextStream str(&htmlFile); + str << "" << tr("Search Results") << ""; const int count = results.count(); if (count != 0) { - if (isIndexing) - htmlFile += QString(QLatin1String("
" - "%1 " - "%2

")).arg(tr("Note:")) - .arg(tr("The search results may not be complete since the " - "documentation is still being indexed.")); + if (isIndexing) { + str << "
" << tr("Note:") + << " " + << tr("The search results may not be complete since the " + "documentation is still being indexed.") + << "

"; + } for (const QHelpSearchResult &result : results) { - htmlFile += QString(QLatin1String("
%2" + str << "

")) - .arg(result.url().toString(), result.title(), - result.snippet()); + " margin:5px\">" << result.snippet() << "

"; } } else { - htmlFile += QLatin1String("


") - + tr("Your search did not match any documents.") - + QLatin1String("

"); - if (isIndexing) - htmlFile += QLatin1String("

") - + tr("(The reason for this might be that the documentation " - "is still being indexed.)") - + QLatin1String("

"); + str << "


" + << tr("Your search did not match any documents.") + << "

"; + if (isIndexing) { + str << "

" + << tr("(The reason for this might be that the documentation " + "is still being indexed.)") << "

"; + } } - htmlFile += QLatin1String(""); + str << ""; setHtml(htmlFile); } -- cgit v1.2.3