--- a/src/qtgui/snippets_w.cpp
+++ b/src/qtgui/snippets_w.cpp
@@ -21,7 +21,12 @@
#include <string>
#include <vector>
+#include <sstream>
using namespace std;
+
+#include <QWebSettings>
+#include <QWebFrame>
+#include <QShortcut>
#include "debuglog.h"
#include "recoll.h"
@@ -50,6 +55,25 @@
if (m_source.isNull())
return;
+ searchFM->hide();
+ webView->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal,
+ Qt::ScrollBarAlwaysOff);
+
+
+ new QShortcut(QKeySequence::Find, this, SLOT(slotEditFind()));
+ new QShortcut(QKeySequence(Qt::Key_Slash), this, SLOT(slotEditFind()));
+ new QShortcut(QKeySequence::FindNext, this, SLOT(slotEditFindNext()));
+ new QShortcut(QKeySequence::FindPrevious, this,
+ SLOT(slotEditFindPrevious()));
+ connect(searchLE, SIGNAL(textChanged(const QString&)),
+ this, SLOT(slotSearchTextChanged(const QString&)));
+ connect(nextPB, SIGNAL(clicked()), this, SLOT(slotEditFindNext()));
+ new QShortcut(QKeySequence(Qt::Key_F3), this, SLOT(slotEditFindNext()));
+ connect(prevPB, SIGNAL(clicked()), this, SLOT(slotEditFindPrevious()));
+ connect(webView, SIGNAL(linkClicked(const QUrl &)),
+ this, SLOT(linkWasClicked(const QUrl &)));
+ webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+
// Make title out of file name if none yet
string titleOrFilename;
string utf8fn;
@@ -58,7 +82,6 @@
if (titleOrFilename.empty()) {
titleOrFilename = utf8fn;
}
-
setWindowTitle(QString::fromUtf8(titleOrFilename.c_str()));
vector<Rcl::Snippet> vpabs;
@@ -67,43 +90,60 @@
HighlightData hdata;
m_source->getTerms(hdata);
- QString html = QString::fromAscii(
+ ostringstream oss;
+ oss <<
"<html><head>"
"<meta http-equiv=\"content-type\" "
"content=\"text/html; charset=utf-8\"></head>"
"<body style='overflow-x: scroll; white-space: nowrap'>"
"<table>"
- );
+ ;
g_hiliter.set_inputhtml(false);
for (vector<Rcl::Snippet>::const_iterator it = vpabs.begin();
it != vpabs.end(); it++) {
- html += "<tr><td>";
+ list<string> lr;
+ if (!g_hiliter.plaintorich(it->snippet, lr, hdata)) {
+ LOGDEB1(("No match for [%s]\n", it->snippet.c_str()));
+ continue;
+ }
+ oss << "<tr><td>";
if (it->page > 0) {
- char txt[100];
- sprintf(txt, "P. %d", it->page);
- char url[100];
- sprintf(url, "P%dT%s", it->page, it->term.c_str());
- html += "<a href=\"";
- html += url;
- html += "\">";
- html += txt;
- html += "</a>";
+ oss << "<a href=\"P" << it->page << "T" << it->term << "\">"
+ << "P. " << it->page << "</a>";
}
- html += "</td><td>";
- list<string> lr;
- g_hiliter.plaintorich(it->snippet, lr, hdata);
- html.append(QString::fromUtf8(lr.front().c_str()));
- html.append("</td></tr>\n");
+ oss << "</td><td>" << lr.front().c_str() << "</td></tr>" << endl;
}
- html.append("</body></html>");
- webView->setHtml(html);
- connect(webView, SIGNAL(linkClicked(const QUrl &)),
- this, SLOT(linkWasClicked(const QUrl &)));
- webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+ oss << "</body></html>";
+
+ QWebSettings *ws = webView->page()->settings();
+ if (prefs.reslistfontfamily != "") {
+ ws->setFontFamily(QWebSettings::StandardFont, prefs.reslistfontfamily);
+ ws->setFontSize(QWebSettings::DefaultFontSize, prefs.reslistfontsize);
+ }
+
+ webView->setHtml(QString::fromUtf8(oss.str().c_str()));
}
+void SnippetsW::slotEditFind()
+{
+ searchFM->show();
+ searchLE->selectAll();
+ searchLE->setFocus();
+}
+void SnippetsW::slotEditFindNext()
+{
+ webView->findText(searchLE->text());
+}
+void SnippetsW::slotEditFindPrevious()
+{
+ webView->findText(searchLE->text(), QWebPage::FindBackward);
+}
+void SnippetsW::slotSearchTextChanged(const QString& txt)
+{
+ webView->findText(txt);
+}
void SnippetsW::linkWasClicked(const QUrl &url)
{