diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index e4a42c53..6ab49395 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -164,16 +164,15 @@ private: // /// QtGuiResListPager methods: bool QtGuiResListPager::append(const string& data) { - m_reslist->append(QString::fromUtf8(data.c_str())); + m_reslist->append(u8s2qs(data)); return true; } bool QtGuiResListPager::append(const string& data, int docnum, const Rcl::Doc&) { #if defined(USING_WEBKIT) || defined(USING_WEBENGINE) - QString sdoc = QString("
").arg(docnum); - m_reslist->append(sdoc); - m_reslist->append(QString::fromUtf8(data.c_str())); + m_reslist->append(QString("
").arg(docnum)); + m_reslist->append(u8s2qs(data)); m_reslist->append("
"); #else int blkcnt0 = m_reslist->document()->blockCount(); @@ -192,7 +191,7 @@ bool QtGuiResListPager::append(const string& data, int docnum, const Rcl::Doc&) string QtGuiResListPager::trans(const string& in) { - return string((const char*)ResList::tr(in.c_str()).toUtf8()); + return qs2utf8s(ResList::tr(in.c_str())); } string QtGuiResListPager::detailsLink() @@ -810,6 +809,14 @@ void ResList::displayPage() m_progress = nullptr; } const static QUrl baseUrl("file:///"); +#if 0 + auto fp = fopen("/tmp/recoll-reslist.html", "w"); + if (fp) { + auto s = qs2utf8s(m_text); + fwrite(s.c_str(), 1, s.size(), fp); + fclose(fp); + } +#endif setHtml(m_text, baseUrl); #endif diff --git a/src/query/reslistpager.cpp b/src/query/reslistpager.cpp index c5c42e2a..fd943532 100644 --- a/src/query/reslistpager.cpp +++ b/src/query/reslistpager.cpp @@ -198,8 +198,7 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc, // Document date: either doc or file modification times string datebuf; if (!doc.dmtime.empty() || !doc.fmtime.empty()) { - time_t mtime = doc.dmtime.empty() ? - atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str()); + time_t mtime = doc.dmtime.empty() ? atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str()); struct tm *tm = localtime(&mtime); datebuf = utf8datestring(dateFormat(), tm); } @@ -315,14 +314,8 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc, string formatted; pcSubst(parFormat(), formatted, subs); - chunk << formatted; - - chunk << "

" << endl; - // This was to force qt 4.x to clear the margins (which it should do - // anyway because of the paragraph's style), but we finally took - // the table approach for 1.15 for now (in guiutils.cpp) -// chunk << "
" << endl; - + chunk << formatted << "

\n"; + LOGDEB2("Chunk: [" << chunk.rdbuf()->str() << "]\n"); append(chunk.rdbuf()->str(), i, doc); } @@ -359,11 +352,11 @@ void ResListPager::displayPage(RclConfig *config) // gets confused. Hence the use of the 'chunk' text // accumulator // Also note that there can be results beyond the estimated resCnt. - chunk << "" << endl + chunk << "\n" << "" << endl + << " content=\"text/html; charset=utf-8\">\n" << headerContent() - << "" << endl + << "\n" << pageTop() << "

" << m_docSource->title() @@ -373,8 +366,7 @@ void ResListPager::displayPage(RclConfig *config) chunk << trans("

No results found
"); string reason = m_docSource->getReason(); if (!reason.empty()) { - chunk << "

" << escapeHtml(reason) << - "

"; + chunk << "
" << escapeHtml(reason) << "

"; } else { HighlightData hldata; m_docSource->getTerms(hldata); @@ -384,13 +376,10 @@ void ResListPager::displayPage(RclConfig *config) suggest(uterms, spellings); if (!spellings.empty()) { if (o_index_stripchars) { - chunk << - trans("

Alternate spellings (accents suppressed): ") + chunk << trans("

Alternate spellings (accents suppressed): ") << "

"; } else { - chunk << - trans("

Alternate spellings: ") - << "

"; + chunk << trans("

Alternate spellings: ") << "

"; } @@ -432,7 +421,7 @@ void ResListPager::displayPage(RclConfig *config) << ""; } } - chunk << "

" << endl; + chunk << "

\n"; append(chunk.rdbuf()->str()); chunk.rdbuf()->str(""); @@ -464,15 +453,14 @@ void ResListPager::displayPage(RclConfig *config) << ""; } } - chunk << "

" << endl; - chunk << "" << endl; + chunk << "

\n"; + chunk << "\n"; append(chunk.rdbuf()->str()); flush(); } -void ResListPager::displaySingleDoc(RclConfig *config, int idx, - Rcl::Doc& doc, - const HighlightData& hdata) +void ResListPager::displaySingleDoc( + RclConfig *config, int idx, Rcl::Doc& doc, const HighlightData& hdata) { ostringstream chunk;