GUI: small cleanups in html-generating code
This commit is contained in:
parent
03f82fa115
commit
ab0aba8c36
@ -164,16 +164,15 @@ private:
|
|||||||
// /// QtGuiResListPager methods:
|
// /// QtGuiResListPager methods:
|
||||||
bool QtGuiResListPager::append(const string& data)
|
bool QtGuiResListPager::append(const string& data)
|
||||||
{
|
{
|
||||||
m_reslist->append(QString::fromUtf8(data.c_str()));
|
m_reslist->append(u8s2qs(data));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtGuiResListPager::append(const string& data, int docnum, const Rcl::Doc&)
|
bool QtGuiResListPager::append(const string& data, int docnum, const Rcl::Doc&)
|
||||||
{
|
{
|
||||||
#if defined(USING_WEBKIT) || defined(USING_WEBENGINE)
|
#if defined(USING_WEBKIT) || defined(USING_WEBENGINE)
|
||||||
QString sdoc = QString("<div class=\"rclresult\" id=\"%1\" rcldocnum=\"%1\">").arg(docnum);
|
m_reslist->append(QString("<div class=\"rclresult\" id=\"%1\" rcldocnum=\"%1\">").arg(docnum));
|
||||||
m_reslist->append(sdoc);
|
m_reslist->append(u8s2qs(data));
|
||||||
m_reslist->append(QString::fromUtf8(data.c_str()));
|
|
||||||
m_reslist->append("</div>");
|
m_reslist->append("</div>");
|
||||||
#else
|
#else
|
||||||
int blkcnt0 = m_reslist->document()->blockCount();
|
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)
|
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()
|
string QtGuiResListPager::detailsLink()
|
||||||
@ -810,6 +809,14 @@ void ResList::displayPage()
|
|||||||
m_progress = nullptr;
|
m_progress = nullptr;
|
||||||
}
|
}
|
||||||
const static QUrl baseUrl("file:///");
|
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);
|
setHtml(m_text, baseUrl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -198,8 +198,7 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
|
|||||||
// Document date: either doc or file modification times
|
// Document date: either doc or file modification times
|
||||||
string datebuf;
|
string datebuf;
|
||||||
if (!doc.dmtime.empty() || !doc.fmtime.empty()) {
|
if (!doc.dmtime.empty() || !doc.fmtime.empty()) {
|
||||||
time_t mtime = doc.dmtime.empty() ?
|
time_t mtime = doc.dmtime.empty() ? atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str());
|
||||||
atoll(doc.fmtime.c_str()) : atoll(doc.dmtime.c_str());
|
|
||||||
struct tm *tm = localtime(&mtime);
|
struct tm *tm = localtime(&mtime);
|
||||||
datebuf = utf8datestring(dateFormat(), tm);
|
datebuf = utf8datestring(dateFormat(), tm);
|
||||||
}
|
}
|
||||||
@ -315,13 +314,7 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
|
|||||||
|
|
||||||
string formatted;
|
string formatted;
|
||||||
pcSubst(parFormat(), formatted, subs);
|
pcSubst(parFormat(), formatted, subs);
|
||||||
chunk << formatted;
|
chunk << formatted << "</p>\n";
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
LOGDEB2("Chunk: [" << chunk.rdbuf()->str() << "]\n");
|
LOGDEB2("Chunk: [" << chunk.rdbuf()->str() << "]\n");
|
||||||
append(chunk.rdbuf()->str(), i, doc);
|
append(chunk.rdbuf()->str(), i, doc);
|
||||||
@ -359,11 +352,11 @@ void ResListPager::displayPage(RclConfig *config)
|
|||||||
// gets confused. Hence the use of the 'chunk' text
|
// gets confused. Hence the use of the 'chunk' text
|
||||||
// accumulator
|
// accumulator
|
||||||
// Also note that there can be results beyond the estimated resCnt.
|
// Also note that there can be results beyond the estimated resCnt.
|
||||||
chunk << "<html><head>" << endl
|
chunk << "<html><head>\n"
|
||||||
<< "<meta http-equiv=\"content-type\""
|
<< "<meta http-equiv=\"content-type\""
|
||||||
<< " content=\"text/html; charset=utf-8\">" << endl
|
<< " content=\"text/html; charset=utf-8\">\n"
|
||||||
<< headerContent()
|
<< headerContent()
|
||||||
<< "</head><body " << bodyAttrs() << ">" << endl
|
<< "</head><body " << bodyAttrs() << ">\n"
|
||||||
<< pageTop()
|
<< pageTop()
|
||||||
<< "<p><span style=\"font-size:110%;\"><b>"
|
<< "<p><span style=\"font-size:110%;\"><b>"
|
||||||
<< m_docSource->title()
|
<< m_docSource->title()
|
||||||
@ -373,8 +366,7 @@ void ResListPager::displayPage(RclConfig *config)
|
|||||||
chunk << trans("<p><b>No results found</b><br>");
|
chunk << trans("<p><b>No results found</b><br>");
|
||||||
string reason = m_docSource->getReason();
|
string reason = m_docSource->getReason();
|
||||||
if (!reason.empty()) {
|
if (!reason.empty()) {
|
||||||
chunk << "<blockquote>" << escapeHtml(reason) <<
|
chunk << "<blockquote>" << escapeHtml(reason) << "</blockquote></p>";
|
||||||
"</blockquote></p>";
|
|
||||||
} else {
|
} else {
|
||||||
HighlightData hldata;
|
HighlightData hldata;
|
||||||
m_docSource->getTerms(hldata);
|
m_docSource->getTerms(hldata);
|
||||||
@ -384,13 +376,10 @@ void ResListPager::displayPage(RclConfig *config)
|
|||||||
suggest(uterms, spellings);
|
suggest(uterms, spellings);
|
||||||
if (!spellings.empty()) {
|
if (!spellings.empty()) {
|
||||||
if (o_index_stripchars) {
|
if (o_index_stripchars) {
|
||||||
chunk <<
|
chunk << trans("<p><i>Alternate spellings (accents suppressed): </i>")
|
||||||
trans("<p><i>Alternate spellings (accents suppressed): </i>")
|
|
||||||
<< "<br /><blockquote>";
|
<< "<br /><blockquote>";
|
||||||
} else {
|
} else {
|
||||||
chunk <<
|
chunk << trans("<p><i>Alternate spellings: </i>") << "<br /><blockquote>";
|
||||||
trans("<p><i>Alternate spellings: </i>")
|
|
||||||
<< "<br /><blockquote>";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +421,7 @@ void ResListPager::displayPage(RclConfig *config)
|
|||||||
<< "</b></a>";
|
<< "</b></a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chunk << "</p>" << endl;
|
chunk << "</p>\n";
|
||||||
|
|
||||||
append(chunk.rdbuf()->str());
|
append(chunk.rdbuf()->str());
|
||||||
chunk.rdbuf()->str("");
|
chunk.rdbuf()->str("");
|
||||||
@ -464,15 +453,14 @@ void ResListPager::displayPage(RclConfig *config)
|
|||||||
<< "</b></a>";
|
<< "</b></a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chunk << "</p>" << endl;
|
chunk << "</p>\n";
|
||||||
chunk << "</body></html>" << endl;
|
chunk << "</body></html>\n";
|
||||||
append(chunk.rdbuf()->str());
|
append(chunk.rdbuf()->str());
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResListPager::displaySingleDoc(RclConfig *config, int idx,
|
void ResListPager::displaySingleDoc(
|
||||||
Rcl::Doc& doc,
|
RclConfig *config, int idx, Rcl::Doc& doc, const HighlightData& hdata)
|
||||||
const HighlightData& hdata)
|
|
||||||
{
|
{
|
||||||
ostringstream chunk;
|
ostringstream chunk;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user