GUI: small cleanups in html-generating code
This commit is contained in:
parent
03f82fa115
commit
ab0aba8c36
@ -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("<div class=\"rclresult\" id=\"%1\" rcldocnum=\"%1\">").arg(docnum);
|
||||
m_reslist->append(sdoc);
|
||||
m_reslist->append(QString::fromUtf8(data.c_str()));
|
||||
m_reslist->append(QString("<div class=\"rclresult\" id=\"%1\" rcldocnum=\"%1\">").arg(docnum));
|
||||
m_reslist->append(u8s2qs(data));
|
||||
m_reslist->append("</div>");
|
||||
#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
|
||||
|
||||
|
||||
@ -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 << "</p>" << 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 << "<br style='clear:both;height:0;line-height:0;'>" << endl;
|
||||
|
||||
chunk << formatted << "</p>\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 << "<html><head>" << endl
|
||||
chunk << "<html><head>\n"
|
||||
<< "<meta http-equiv=\"content-type\""
|
||||
<< " content=\"text/html; charset=utf-8\">" << endl
|
||||
<< " content=\"text/html; charset=utf-8\">\n"
|
||||
<< headerContent()
|
||||
<< "</head><body " << bodyAttrs() << ">" << endl
|
||||
<< "</head><body " << bodyAttrs() << ">\n"
|
||||
<< pageTop()
|
||||
<< "<p><span style=\"font-size:110%;\"><b>"
|
||||
<< m_docSource->title()
|
||||
@ -373,8 +366,7 @@ void ResListPager::displayPage(RclConfig *config)
|
||||
chunk << trans("<p><b>No results found</b><br>");
|
||||
string reason = m_docSource->getReason();
|
||||
if (!reason.empty()) {
|
||||
chunk << "<blockquote>" << escapeHtml(reason) <<
|
||||
"</blockquote></p>";
|
||||
chunk << "<blockquote>" << escapeHtml(reason) << "</blockquote></p>";
|
||||
} 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("<p><i>Alternate spellings (accents suppressed): </i>")
|
||||
chunk << trans("<p><i>Alternate spellings (accents suppressed): </i>")
|
||||
<< "<br /><blockquote>";
|
||||
} else {
|
||||
chunk <<
|
||||
trans("<p><i>Alternate spellings: </i>")
|
||||
<< "<br /><blockquote>";
|
||||
chunk << trans("<p><i>Alternate spellings: </i>") << "<br /><blockquote>";
|
||||
|
||||
}
|
||||
|
||||
@ -432,7 +421,7 @@ void ResListPager::displayPage(RclConfig *config)
|
||||
<< "</b></a>";
|
||||
}
|
||||
}
|
||||
chunk << "</p>" << endl;
|
||||
chunk << "</p>\n";
|
||||
|
||||
append(chunk.rdbuf()->str());
|
||||
chunk.rdbuf()->str("");
|
||||
@ -464,15 +453,14 @@ void ResListPager::displayPage(RclConfig *config)
|
||||
<< "</b></a>";
|
||||
}
|
||||
}
|
||||
chunk << "</p>" << endl;
|
||||
chunk << "</body></html>" << endl;
|
||||
chunk << "</p>\n";
|
||||
chunk << "</body></html>\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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user