Prepare for webengine integration. defines and indents, no real changes
This commit is contained in:
parent
bc24792a2c
commit
504705879b
@ -427,6 +427,22 @@ if test X$enableQT = Xyes ; then
|
|||||||
QMAKE_DISABLE_WEBKIT=""
|
QMAKE_DISABLE_WEBKIT=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(webengine,
|
||||||
|
AC_HELP_STRING([--enable-webengine],
|
||||||
|
[Enable use of qt-webengine (only meaningful if qtgui is enabled), in
|
||||||
|
place or qt-webkit.]),
|
||||||
|
enableWebengine=$enableval, enableWebengine="no")
|
||||||
|
|
||||||
|
if test "$enableWebengine" = "yes" ; then
|
||||||
|
QMAKE_ENABLE_WEBENGINE=""
|
||||||
|
QMAKE_DISABLE_WEBENGINE="#"
|
||||||
|
QMAKE_ENABLE_WEBKIT="#"
|
||||||
|
QMAKE_DISABLE_WEBKIT=""
|
||||||
|
else
|
||||||
|
QMAKE_ENABLE_WEBENGINE="#"
|
||||||
|
QMAKE_DISABLE_WEBENGINE=""
|
||||||
|
fi
|
||||||
|
|
||||||
##### Using QZeitGeist lib ? Default no for now
|
##### Using QZeitGeist lib ? Default no for now
|
||||||
AC_ARG_WITH(qzeitgeist,
|
AC_ARG_WITH(qzeitgeist,
|
||||||
AC_HELP_STRING([--with-qzeitgeist],
|
AC_HELP_STRING([--with-qzeitgeist],
|
||||||
@ -504,6 +520,8 @@ AC_SUBST(QTGUI)
|
|||||||
AC_SUBST(XAPIANCXXFLAGS)
|
AC_SUBST(XAPIANCXXFLAGS)
|
||||||
AC_SUBST(QMAKE_ENABLE_WEBKIT)
|
AC_SUBST(QMAKE_ENABLE_WEBKIT)
|
||||||
AC_SUBST(QMAKE_DISABLE_WEBKIT)
|
AC_SUBST(QMAKE_DISABLE_WEBKIT)
|
||||||
|
AC_SUBST(QMAKE_ENABLE_WEBENGINE)
|
||||||
|
AC_SUBST(QMAKE_DISABLE_WEBENGINE)
|
||||||
AC_SUBST(QMAKE_ENABLE_ZEITGEIST)
|
AC_SUBST(QMAKE_ENABLE_ZEITGEIST)
|
||||||
AC_SUBST(QMAKE_DISABLE_ZEITGEIST)
|
AC_SUBST(QMAKE_DISABLE_ZEITGEIST)
|
||||||
AC_SUBST(LIBQZEITGEIST)
|
AC_SUBST(LIBQZEITGEIST)
|
||||||
|
|||||||
@ -5,9 +5,11 @@ VPATH = @srcdir@
|
|||||||
DEFINES += BUILDING_RECOLL
|
DEFINES += BUILDING_RECOLL
|
||||||
|
|
||||||
@QMAKE_ENABLE_WEBKIT@ QT += webkit
|
@QMAKE_ENABLE_WEBKIT@ QT += webkit
|
||||||
@QMAKE_DISABLE_WEBKIT@ QMAKE_CXXFLAGS += -DRESLIST_TEXTBROWSER -DSNIPPETS_TEXTBROWSER
|
@QMAKE_ENABLE_WEBKIT@ DEFINES += USING_WEBKIT
|
||||||
@QMAKE_DISABLE_WEBKIT@ DEFINES += RESLIST_TEXTBROWSER
|
|
||||||
@QMAKE_DISABLE_WEBKIT@ DEFINES += SNIPPETS_TEXTBROWSER
|
@QMAKE_ENABLE_WEBENGINE@ QT += webengine
|
||||||
|
@QMAKE_ENABLE_WEBENGINE@ DEFINES += USING_WEBENGINE
|
||||||
|
|
||||||
QMAKE_CXXFLAGS += -std=c++11
|
QMAKE_CXXFLAGS += -std=c++11
|
||||||
|
|
||||||
@QMAKE_ENABLE_ZEITGEIST@ QT += dbus
|
@QMAKE_ENABLE_ZEITGEIST@ QT += dbus
|
||||||
|
|||||||
@ -20,6 +20,8 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qvariant.h>
|
#include <qvariant.h>
|
||||||
#include <qevent.h>
|
#include <qevent.h>
|
||||||
@ -34,9 +36,6 @@
|
|||||||
#include <qscrollbar.h>
|
#include <qscrollbar.h>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#ifndef __APPLE__
|
|
||||||
//#include <qx11info_x11.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
@ -47,7 +46,6 @@
|
|||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
#include "mimehandler.h"
|
#include "mimehandler.h"
|
||||||
#include "plaintorich.h"
|
#include "plaintorich.h"
|
||||||
#include <memory>
|
|
||||||
#include "internfile.h"
|
#include "internfile.h"
|
||||||
#include "indexer.h"
|
#include "indexer.h"
|
||||||
#include "snippets_w.h"
|
#include "snippets_w.h"
|
||||||
@ -57,11 +55,12 @@
|
|||||||
#include "rclhelp.h"
|
#include "rclhelp.h"
|
||||||
#include "appformime.h"
|
#include "appformime.h"
|
||||||
#include "respopup.h"
|
#include "respopup.h"
|
||||||
|
#include "reslistpager.h"
|
||||||
|
|
||||||
static const QKeySequence quitKeySeq("Ctrl+q");
|
static const QKeySequence quitKeySeq("Ctrl+q");
|
||||||
static const QKeySequence closeKeySeq("Ctrl+w");
|
static const QKeySequence closeKeySeq("Ctrl+w");
|
||||||
|
|
||||||
#ifndef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
#include <QWebElement>
|
#include <QWebElement>
|
||||||
#include <QWebSettings>
|
#include <QWebSettings>
|
||||||
@ -125,7 +124,12 @@ bool QtGuiResListPager::append(const string& data, int docnum,
|
|||||||
LOGDEB2("QtGuiReslistPager::appendDoc: blockCount " <<
|
LOGDEB2("QtGuiReslistPager::appendDoc: blockCount " <<
|
||||||
m_reslist->document()->blockCount() << ", " << data << "\n");
|
m_reslist->document()->blockCount() << ", " << data << "\n");
|
||||||
logdata(data.c_str());
|
logdata(data.c_str());
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
|
QString sdoc = QString("<div class=\"rclresult\" rcldocnum=\"%1\">").arg(docnum);
|
||||||
|
m_reslist->append(sdoc);
|
||||||
|
m_reslist->append(QString::fromUtf8(data.c_str()));
|
||||||
|
m_reslist->append("</div>");
|
||||||
|
#else
|
||||||
int blkcnt0 = m_reslist->document()->blockCount();
|
int blkcnt0 = m_reslist->document()->blockCount();
|
||||||
m_reslist->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
|
m_reslist->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
|
||||||
m_reslist->textCursor().insertBlock();
|
m_reslist->textCursor().insertBlock();
|
||||||
@ -136,11 +140,6 @@ bool QtGuiResListPager::append(const string& data, int docnum,
|
|||||||
for (int block = blkcnt0; block < blkcnt1; block++) {
|
for (int block = blkcnt0; block < blkcnt1; block++) {
|
||||||
m_reslist->m_pageParaToReldocnums[block] = docnum;
|
m_reslist->m_pageParaToReldocnums[block] = docnum;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
QString sdoc = QString("<div class=\"rclresult\" rcldocnum=\"%1\">").arg(docnum);
|
|
||||||
m_reslist->append(sdoc);
|
|
||||||
m_reslist->append(QString::fromUtf8(data.c_str()));
|
|
||||||
m_reslist->append("</div>");
|
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -281,14 +280,20 @@ static PlainToRichQtReslist g_hiliter;
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
ResList::ResList(QWidget* parent, const char* name)
|
ResList::ResList(QWidget* parent, const char* name)
|
||||||
: RESLIST_PARENTCLASS(parent), m_curPvDoc(-1), m_lstClckMod(0),
|
: RESLIST_PARENTCLASS(parent)
|
||||||
m_listId(0), m_rclmain(0), m_ismainres(true)
|
|
||||||
{
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
setObjectName("resList");
|
setObjectName("resList");
|
||||||
else
|
else
|
||||||
setObjectName(name);
|
setObjectName(name);
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
|
LOGDEB("Reslist: using Webkit\n");
|
||||||
|
// signals and slots connections
|
||||||
|
connect(this, SIGNAL(linkClicked(const QUrl &)),
|
||||||
|
this, SLOT(linkWasClicked(const QUrl &)));
|
||||||
|
page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
||||||
|
settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
|
||||||
|
#else
|
||||||
LOGDEB("Reslist: using QTextBrowser\n");
|
LOGDEB("Reslist: using QTextBrowser\n");
|
||||||
setReadOnly(true);
|
setReadOnly(true);
|
||||||
setUndoRedoEnabled(false);
|
setUndoRedoEnabled(false);
|
||||||
@ -297,13 +302,6 @@ ResList::ResList(QWidget* parent, const char* name)
|
|||||||
// signals and slots connections
|
// signals and slots connections
|
||||||
connect(this, SIGNAL(anchorClicked(const QUrl &)),
|
connect(this, SIGNAL(anchorClicked(const QUrl &)),
|
||||||
this, SLOT(linkWasClicked(const QUrl &)));
|
this, SLOT(linkWasClicked(const QUrl &)));
|
||||||
#else
|
|
||||||
LOGDEB("Reslist: using QWebView\n");
|
|
||||||
// signals and slots connections
|
|
||||||
connect(this, SIGNAL(linkClicked(const QUrl &)),
|
|
||||||
this, SLOT(linkWasClicked(const QUrl &)));
|
|
||||||
page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
|
||||||
settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setFont();
|
setFont();
|
||||||
@ -370,14 +368,7 @@ void ResList::setRclMain(RclMain *m, bool ismain)
|
|||||||
|
|
||||||
void ResList::setFont()
|
void ResList::setFont()
|
||||||
{
|
{
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
if (prefs.reslistfontfamily.length()) {
|
|
||||||
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
|
||||||
QTextBrowser::setFont(nfont);
|
|
||||||
} else {
|
|
||||||
QTextBrowser::setFont(QFont());
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#ifndef SETFONT_WITH_HEADSTYLE
|
#ifndef SETFONT_WITH_HEADSTYLE
|
||||||
QWebSettings *websettings = settings();
|
QWebSettings *websettings = settings();
|
||||||
if (prefs.reslistfontfamily.length()) {
|
if (prefs.reslistfontfamily.length()) {
|
||||||
@ -392,6 +383,13 @@ void ResList::setFont()
|
|||||||
websettings->resetFontFamily(QWebSettings::StandardFont);
|
websettings->resetFontFamily(QWebSettings::StandardFont);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
if (prefs.reslistfontfamily.length()) {
|
||||||
|
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||||
|
QTextBrowser::setFont(nfont);
|
||||||
|
} else {
|
||||||
|
QTextBrowser::setFont(QFont());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,17 +441,14 @@ void ResList::resetView()
|
|||||||
// slow search, the user will wonder if anything happened. The
|
// slow search, the user will wonder if anything happened. The
|
||||||
// following helps making sure that the textedit is really
|
// following helps making sure that the textedit is really
|
||||||
// blank. Else, there are often icons or text left around
|
// blank. Else, there are often icons or text left around
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
|
m_text = "";
|
||||||
|
setHtml("<html><body></body></html>");
|
||||||
|
#else
|
||||||
m_pageParaToReldocnums.clear();
|
m_pageParaToReldocnums.clear();
|
||||||
clear();
|
clear();
|
||||||
QTextBrowser::append(".");
|
QTextBrowser::append(".");
|
||||||
clear();
|
clear();
|
||||||
#ifndef __APPLE__
|
|
||||||
// XFlush(QX11Info::display());
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
m_text = "";
|
|
||||||
setHtml("<html><body></body></html>");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -473,7 +468,7 @@ void ResList::languageChange()
|
|||||||
setWindowTitle(tr("Result list"));
|
setWindowTitle(tr("Result list"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if !defined(USING_WEBKIT) && !defined(USING_WEBENGINE)
|
||||||
// Get document number from text block number
|
// Get document number from text block number
|
||||||
int ResList::docnumfromparnum(int block)
|
int ResList::docnumfromparnum(int block)
|
||||||
{
|
{
|
||||||
@ -601,12 +596,7 @@ void ResList::highlighted(const QString& )
|
|||||||
// fair enough, else we go to next/previous result page.
|
// fair enough, else we go to next/previous result page.
|
||||||
void ResList::resPageUpOrBack()
|
void ResList::resPageUpOrBack()
|
||||||
{
|
{
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
int vpos = verticalScrollBar()->value();
|
|
||||||
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
|
|
||||||
if (vpos == verticalScrollBar()->value())
|
|
||||||
resultPageBack();
|
|
||||||
#else
|
|
||||||
if (scrollIsAtTop()) {
|
if (scrollIsAtTop()) {
|
||||||
resultPageBack();
|
resultPageBack();
|
||||||
} else {
|
} else {
|
||||||
@ -614,19 +604,17 @@ void ResList::resPageUpOrBack()
|
|||||||
frame->scroll(0, -int(0.9*geometry().height()));
|
frame->scroll(0, -int(0.9*geometry().height()));
|
||||||
}
|
}
|
||||||
setupArrows();
|
setupArrows();
|
||||||
|
#else
|
||||||
|
int vpos = verticalScrollBar()->value();
|
||||||
|
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
|
||||||
|
if (vpos == verticalScrollBar()->value())
|
||||||
|
resultPageBack();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResList::resPageDownOrNext()
|
void ResList::resPageDownOrNext()
|
||||||
{
|
{
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
int vpos = verticalScrollBar()->value();
|
|
||||||
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
|
|
||||||
LOGDEB("ResList::resPageDownOrNext: vpos before " << vpos << ", after "
|
|
||||||
<< verticalScrollBar()->value() << "\n");
|
|
||||||
if (vpos == verticalScrollBar()->value())
|
|
||||||
resultPageNext();
|
|
||||||
#else
|
|
||||||
if (scrollIsAtBottom()) {
|
if (scrollIsAtBottom()) {
|
||||||
resultPageNext();
|
resultPageNext();
|
||||||
} else {
|
} else {
|
||||||
@ -634,6 +622,13 @@ void ResList::resPageDownOrNext()
|
|||||||
frame->scroll(0, int(0.9*geometry().height()));
|
frame->scroll(0, int(0.9*geometry().height()));
|
||||||
}
|
}
|
||||||
setupArrows();
|
setupArrows();
|
||||||
|
#else
|
||||||
|
int vpos = verticalScrollBar()->value();
|
||||||
|
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
|
||||||
|
LOGDEB("ResList::resPageDownOrNext: vpos before " << vpos << ", after "
|
||||||
|
<< verticalScrollBar()->value() << "\n");
|
||||||
|
if (vpos == verticalScrollBar()->value())
|
||||||
|
resultPageNext();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,9 +640,7 @@ void ResList::setupArrows()
|
|||||||
|
|
||||||
bool ResList::scrollIsAtBottom()
|
bool ResList::scrollIsAtBottom()
|
||||||
{
|
{
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
QWebFrame *frame = page()->mainFrame();
|
QWebFrame *frame = page()->mainFrame();
|
||||||
bool ret;
|
bool ret;
|
||||||
if (!frame || frame->scrollBarGeometry(Qt::Vertical).isEmpty()) {
|
if (!frame || frame->scrollBarGeometry(Qt::Vertical).isEmpty()) {
|
||||||
@ -660,14 +653,14 @@ bool ResList::scrollIsAtBottom()
|
|||||||
}
|
}
|
||||||
LOGDEB2("scrollIsAtBottom: returning " << ret << "\n");
|
LOGDEB2("scrollIsAtBottom: returning " << ret << "\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResList::scrollIsAtTop()
|
bool ResList::scrollIsAtTop()
|
||||||
{
|
{
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
QWebFrame *frame = page()->mainFrame();
|
QWebFrame *frame = page()->mainFrame();
|
||||||
bool ret;
|
bool ret;
|
||||||
if (!frame || frame->scrollBarGeometry(Qt::Vertical).isEmpty()) {
|
if (!frame || frame->scrollBarGeometry(Qt::Vertical).isEmpty()) {
|
||||||
@ -680,6 +673,8 @@ bool ResList::scrollIsAtTop()
|
|||||||
}
|
}
|
||||||
LOGDEB2("scrollIsAtTop: returning " << ret << "\n");
|
LOGDEB2("scrollIsAtTop: returning " << ret << "\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,10 +715,10 @@ void ResList::resultPageFor(int docnum)
|
|||||||
void ResList::append(const QString &text)
|
void ResList::append(const QString &text)
|
||||||
{
|
{
|
||||||
LOGDEB2("QtGuiReslistPager::appendQString : " << qs2utf8s(text) << "\n");
|
LOGDEB2("QtGuiReslistPager::appendQString : " << qs2utf8s(text) << "\n");
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
QTextBrowser::append(text);
|
|
||||||
#else
|
|
||||||
m_text += text;
|
m_text += text;
|
||||||
|
#else
|
||||||
|
QTextBrowser::append(text);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,7 +728,7 @@ void ResList::displayPage()
|
|||||||
|
|
||||||
m_pager->displayPage(theconfig);
|
m_pager->displayPage(theconfig);
|
||||||
|
|
||||||
#ifndef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBENGINE) || defined(USING_WEBKIT)
|
||||||
setHtml(m_text);
|
setHtml(m_text);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -753,7 +748,18 @@ void ResList::previewExposed(int docnum)
|
|||||||
|
|
||||||
// Possibly erase old one to white
|
// Possibly erase old one to white
|
||||||
if (m_curPvDoc != -1) {
|
if (m_curPvDoc != -1) {
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
|
QString sel =
|
||||||
|
QString("div[rcldocnum=\"%1\"]").arg(m_curPvDoc - pageFirstDocNum());
|
||||||
|
LOGDEB2("Searching for element, selector: [" << qs2utf8s(sel) << "]\n");
|
||||||
|
QWebElement elt = page()->mainFrame()->findFirstElement(sel);
|
||||||
|
if (!elt.isNull()) {
|
||||||
|
LOGDEB2("Found\n");
|
||||||
|
elt.removeAttribute("style");
|
||||||
|
} else {
|
||||||
|
LOGDEB2("Not Found\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
pair<int,int> blockrange = parnumfromdocnum(m_curPvDoc);
|
pair<int,int> blockrange = parnumfromdocnum(m_curPvDoc);
|
||||||
if (blockrange.first != -1) {
|
if (blockrange.first != -1) {
|
||||||
for (int blockn = blockrange.first;
|
for (int blockn = blockrange.first;
|
||||||
@ -765,17 +771,6 @@ void ResList::previewExposed(int docnum)
|
|||||||
cursor.setBlockFormat(format);
|
cursor.setBlockFormat(format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
QString sel =
|
|
||||||
QString("div[rcldocnum=\"%1\"]").arg(m_curPvDoc - pageFirstDocNum());
|
|
||||||
LOGDEB2("Searching for element, selector: [" << qs2utf8s(sel) << "]\n");
|
|
||||||
QWebElement elt = page()->mainFrame()->findFirstElement(sel);
|
|
||||||
if (!elt.isNull()) {
|
|
||||||
LOGDEB2("Found\n");
|
|
||||||
elt.removeAttribute("style");
|
|
||||||
} else {
|
|
||||||
LOGDEB2("Not Found\n");
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
m_curPvDoc = -1;
|
m_curPvDoc = -1;
|
||||||
}
|
}
|
||||||
@ -783,7 +778,18 @@ void ResList::previewExposed(int docnum)
|
|||||||
// Set background for active preview's doc entry
|
// Set background for active preview's doc entry
|
||||||
m_curPvDoc = docnum;
|
m_curPvDoc = docnum;
|
||||||
|
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
|
QString sel =
|
||||||
|
QString("div[rcldocnum=\"%1\"]").arg(docnum - pageFirstDocNum());
|
||||||
|
LOGDEB2("Searching for element, selector: [" << qs2utf8s(sel) << "]\n");
|
||||||
|
QWebElement elt = page()->mainFrame()->findFirstElement(sel);
|
||||||
|
if (!elt.isNull()) {
|
||||||
|
LOGDEB2("Found\n");
|
||||||
|
elt.setAttribute("style", "background: LightBlue;}");
|
||||||
|
} else {
|
||||||
|
LOGDEB2("Not Found\n");
|
||||||
|
}
|
||||||
|
#else
|
||||||
pair<int,int> blockrange = parnumfromdocnum(docnum);
|
pair<int,int> blockrange = parnumfromdocnum(docnum);
|
||||||
|
|
||||||
// Maybe docnum is -1 or not in this window,
|
// Maybe docnum is -1 or not in this window,
|
||||||
@ -801,17 +807,6 @@ void ResList::previewExposed(int docnum)
|
|||||||
setTextCursor(cursor);
|
setTextCursor(cursor);
|
||||||
ensureCursorVisible();
|
ensureCursorVisible();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
QString sel =
|
|
||||||
QString("div[rcldocnum=\"%1\"]").arg(docnum - pageFirstDocNum());
|
|
||||||
LOGDEB2("Searching for element, selector: [" << qs2utf8s(sel) << "]\n");
|
|
||||||
QWebElement elt = page()->mainFrame()->findFirstElement(sel);
|
|
||||||
if (!elt.isNull()) {
|
|
||||||
LOGDEB2("Found\n");
|
|
||||||
elt.setAttribute("style", "background: LightBlue;}");
|
|
||||||
} else {
|
|
||||||
LOGDEB2("Not Found\n");
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -819,11 +814,11 @@ void ResList::previewExposed(int docnum)
|
|||||||
void ResList::mouseDoubleClickEvent(QMouseEvent *event)
|
void ResList::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
RESLIST_PARENTCLASS::mouseDoubleClickEvent(event);
|
RESLIST_PARENTCLASS::mouseDoubleClickEvent(event);
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
|
emit(wordSelect(selectedText()));
|
||||||
|
#else
|
||||||
if (textCursor().hasSelection())
|
if (textCursor().hasSelection())
|
||||||
emit(wordSelect(textCursor().selectedText()));
|
emit(wordSelect(textCursor().selectedText()));
|
||||||
#else
|
|
||||||
emit(wordSelect(selectedText()));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,12 +976,7 @@ void ResList::linkWasClicked(const QUrl &url)
|
|||||||
void ResList::createPopupMenu(const QPoint& pos)
|
void ResList::createPopupMenu(const QPoint& pos)
|
||||||
{
|
{
|
||||||
LOGDEB("ResList::createPopupMenu(" << pos.x() << ", " << pos.y() << ")\n");
|
LOGDEB("ResList::createPopupMenu(" << pos.x() << ", " << pos.y() << ")\n");
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
QTextCursor cursor = cursorForPosition(pos);
|
|
||||||
int blocknum = cursor.blockNumber();
|
|
||||||
LOGDEB("ResList::createPopupMenu(): block " << blocknum << "\n");
|
|
||||||
m_popDoc = docnumfromparnum(blocknum);
|
|
||||||
#else
|
|
||||||
QWebHitTestResult htr = page()->mainFrame()->hitTestContent(pos);
|
QWebHitTestResult htr = page()->mainFrame()->hitTestContent(pos);
|
||||||
if (htr.isNull())
|
if (htr.isNull())
|
||||||
return;
|
return;
|
||||||
@ -997,6 +987,11 @@ void ResList::createPopupMenu(const QPoint& pos)
|
|||||||
return;
|
return;
|
||||||
QString snum = el.attribute("rcldocnum");
|
QString snum = el.attribute("rcldocnum");
|
||||||
m_popDoc = pageFirstDocNum() + snum.toInt();
|
m_popDoc = pageFirstDocNum() + snum.toInt();
|
||||||
|
#else
|
||||||
|
QTextCursor cursor = cursorForPosition(pos);
|
||||||
|
int blocknum = cursor.blockNumber();
|
||||||
|
LOGDEB("ResList::createPopupMenu(): block " << blocknum << "\n");
|
||||||
|
m_popDoc = docnumfromparnum(blocknum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_popDoc < 0)
|
if (m_popDoc < 0)
|
||||||
@ -1101,8 +1096,8 @@ void ResList::menuExpand()
|
|||||||
if (getDoc(m_popDoc, doc))
|
if (getDoc(m_popDoc, doc))
|
||||||
emit docExpand(doc);
|
emit docExpand(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ResList::pageFirstDocNum()
|
int ResList::pageFirstDocNum()
|
||||||
{
|
{
|
||||||
return m_pager->pageFirstDocNum();
|
return m_pager->pageFirstDocNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,26 +19,24 @@
|
|||||||
#define _RESLIST_H_INCLUDED_
|
#define _RESLIST_H_INCLUDED_
|
||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
|
|
||||||
#include <list>
|
#include <map>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBENGINE)
|
||||||
#include <QTextBrowser>
|
# include <QWebEngineView>
|
||||||
#define RESLIST_PARENTCLASS QTextBrowser
|
# define RESLIST_PARENTCLASS QWebEngineView
|
||||||
|
#elif defined(USING_WEBKIT)
|
||||||
|
# include <QWebView>
|
||||||
|
# define RESLIST_PARENTCLASS QWebView
|
||||||
#else
|
#else
|
||||||
#include <QWebView>
|
# include <QTextBrowser>
|
||||||
#define RESLIST_PARENTCLASS QWebView
|
# define RESLIST_PARENTCLASS QTextBrowser
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "docseq.h"
|
|
||||||
#include "sortseq.h"
|
|
||||||
#include "filtseq.h"
|
|
||||||
#include <memory>
|
|
||||||
#include "rcldoc.h"
|
|
||||||
#include "reslistpager.h"
|
|
||||||
|
|
||||||
class RclMain;
|
class RclMain;
|
||||||
class QtGuiResListPager;
|
class QtGuiResListPager;
|
||||||
|
namespace Rcl {
|
||||||
|
class Doc;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a list of document records. The data can be out of the history
|
* Display a list of document records. The data can be out of the history
|
||||||
@ -49,7 +47,7 @@ class ResList : public RESLIST_PARENTCLASS
|
|||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
|
||||||
friend class QtGuiResListPager;
|
friend class QtGuiResListPager;
|
||||||
public:
|
public:
|
||||||
ResList(QWidget* parent = 0, const char* name = 0);
|
ResList(QWidget* parent = 0, const char* name = 0);
|
||||||
virtual ~ResList();
|
virtual ~ResList();
|
||||||
|
|
||||||
@ -65,7 +63,7 @@ class ResList : public RESLIST_PARENTCLASS
|
|||||||
void setFont();
|
void setFont();
|
||||||
void setRclMain(RclMain *m, bool ismain);
|
void setRclMain(RclMain *m, bool ismain);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setDocSource(std::shared_ptr<DocSequence> nsource);
|
virtual void setDocSource(std::shared_ptr<DocSequence> nsource);
|
||||||
virtual void resetList(); // Erase current list
|
virtual void resetList(); // Erase current list
|
||||||
virtual void resPageUpOrBack(); // Page up pressed
|
virtual void resPageUpOrBack(); // Page up pressed
|
||||||
@ -92,7 +90,7 @@ class ResList : public RESLIST_PARENTCLASS
|
|||||||
virtual void createPopupMenu(const QPoint& pos);
|
virtual void createPopupMenu(const QPoint& pos);
|
||||||
virtual void showQueryDetails();
|
virtual void showQueryDetails();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nextPageAvailable(bool);
|
void nextPageAvailable(bool);
|
||||||
void prevPageAvailable(bool);
|
void prevPageAvailable(bool);
|
||||||
void docPreviewClicked(int, Rcl::Doc, int);
|
void docPreviewClicked(int, Rcl::Doc, int);
|
||||||
@ -107,36 +105,36 @@ class ResList : public RESLIST_PARENTCLASS
|
|||||||
void wordReplace(const QString&, const QString&);
|
void wordReplace(const QString&, const QString&);
|
||||||
void hasResults(int);
|
void hasResults(int);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *e);
|
void keyPressEvent(QKeyEvent *e);
|
||||||
void mouseReleaseEvent(QMouseEvent *e);
|
void mouseReleaseEvent(QMouseEvent *e);
|
||||||
void mouseDoubleClickEvent(QMouseEvent*);
|
void mouseDoubleClickEvent(QMouseEvent*);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void languageChange();
|
virtual void languageChange();
|
||||||
virtual void linkWasClicked(const QUrl &);
|
virtual void linkWasClicked(const QUrl &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QtGuiResListPager *m_pager;
|
QtGuiResListPager *m_pager{0};
|
||||||
std::shared_ptr<DocSequence> m_source;
|
std::shared_ptr<DocSequence> m_source;
|
||||||
int m_popDoc; // Docnum for the popup menu.
|
int m_popDoc{-1}; // Docnum for the popup menu.
|
||||||
int m_curPvDoc;// Docnum for current preview
|
int m_curPvDoc{-1};// Docnum for current preview
|
||||||
int m_lstClckMod; // Last click modifier.
|
int m_lstClckMod{0}; // Last click modifier.
|
||||||
int m_listId; // query Id for matching with preview windows
|
int m_listId{0}; // query Id for matching with preview windows
|
||||||
|
|
||||||
#ifdef RESLIST_TEXTBROWSER
|
#if defined(USING_WEBKIT) || defined(USING_WEBENGINE)
|
||||||
|
// Webview makes it more difficult to append text incrementally,
|
||||||
|
// so we store the page and display it when done.
|
||||||
|
QString m_text;
|
||||||
|
#else
|
||||||
// Translate from textedit paragraph number to relative
|
// Translate from textedit paragraph number to relative
|
||||||
// docnum. Built while we insert text into the qtextedit
|
// docnum. Built while we insert text into the qtextedit
|
||||||
std::map<int,int> m_pageParaToReldocnums;
|
std::map<int,int> m_pageParaToReldocnums;
|
||||||
virtual int docnumfromparnum(int);
|
virtual int docnumfromparnum(int);
|
||||||
virtual std::pair<int,int> parnumfromdocnum(int);
|
virtual std::pair<int,int> parnumfromdocnum(int);
|
||||||
#else
|
|
||||||
// Webview makes it more difficult to append text incrementally,
|
|
||||||
// so we store the page and display it when done.
|
|
||||||
QString m_text;
|
|
||||||
#endif
|
#endif
|
||||||
RclMain *m_rclmain;
|
RclMain *m_rclmain{0};
|
||||||
bool m_ismainres;
|
bool m_ismainres{true};
|
||||||
|
|
||||||
virtual void displayPage(); // Display current page
|
virtual void displayPage(); // Display current page
|
||||||
static int newListId();
|
static int newListId();
|
||||||
@ -144,7 +142,7 @@ class ResList : public RESLIST_PARENTCLASS
|
|||||||
bool scrollIsAtTop();
|
bool scrollIsAtTop();
|
||||||
bool scrollIsAtBottom();
|
bool scrollIsAtBottom();
|
||||||
void setupArrows();
|
void setupArrows();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* _RESLIST_H_INCLUDED_ */
|
#endif /* _RESLIST_H_INCLUDED_ */
|
||||||
|
|||||||
@ -23,12 +23,12 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#ifdef SNIPPETS_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
#include <QTextBrowser>
|
|
||||||
#else
|
|
||||||
#include <QWebSettings>
|
#include <QWebSettings>
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#else
|
||||||
|
#include <QTextBrowser>
|
||||||
#endif
|
#endif
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
@ -42,10 +42,10 @@ using namespace std;
|
|||||||
|
|
||||||
// Note: the internal search currently does not work with QTextBrowser. To be
|
// Note: the internal search currently does not work with QTextBrowser. To be
|
||||||
// fixed by looking at the preview code if someone asks for it...
|
// fixed by looking at the preview code if someone asks for it...
|
||||||
#ifdef SNIPPETS_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
#define browser ((QTextBrowser*)browserw)
|
|
||||||
#else
|
|
||||||
#define browser ((QWebView*)browserw)
|
#define browser ((QWebView*)browserw)
|
||||||
|
#else
|
||||||
|
#define browser ((QTextBrowser*)browserw)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class PlainToRichQtSnippets : public PlainToRich {
|
class PlainToRichQtSnippets : public PlainToRich {
|
||||||
@ -92,22 +92,7 @@ void SnippetsW::init()
|
|||||||
connect(nextPB, SIGNAL(clicked()), this, SLOT(slotEditFindNext()));
|
connect(nextPB, SIGNAL(clicked()), this, SLOT(slotEditFindNext()));
|
||||||
connect(prevPB, SIGNAL(clicked()), this, SLOT(slotEditFindPrevious()));
|
connect(prevPB, SIGNAL(clicked()), this, SLOT(slotEditFindPrevious()));
|
||||||
|
|
||||||
#ifdef SNIPPETS_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
browserw = new QTextBrowser(this);
|
|
||||||
verticalLayout->insertWidget(0, browserw);
|
|
||||||
connect(browser, SIGNAL(anchorClicked(const QUrl &)),
|
|
||||||
this, SLOT(linkWasClicked(const QUrl &)));
|
|
||||||
browser->setReadOnly(true);
|
|
||||||
browser->setUndoRedoEnabled(false);
|
|
||||||
browser->setOpenLinks(false);
|
|
||||||
browser->setTabChangesFocus(true);
|
|
||||||
if (prefs.reslistfontfamily.length()) {
|
|
||||||
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
|
||||||
browser->setFont(nfont);
|
|
||||||
} else {
|
|
||||||
browser->setFont(QFont());
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
browserw = new QWebView(this);
|
browserw = new QWebView(this);
|
||||||
verticalLayout->insertWidget(0, browserw);
|
verticalLayout->insertWidget(0, browserw);
|
||||||
browser->setUrl(QUrl(QString::fromUtf8("about:blank")));
|
browser->setUrl(QUrl(QString::fromUtf8("about:blank")));
|
||||||
@ -123,6 +108,21 @@ void SnippetsW::init()
|
|||||||
}
|
}
|
||||||
if (!prefs.snipCssFile.isEmpty())
|
if (!prefs.snipCssFile.isEmpty())
|
||||||
ws->setUserStyleSheetUrl(QUrl::fromLocalFile(prefs.snipCssFile));
|
ws->setUserStyleSheetUrl(QUrl::fromLocalFile(prefs.snipCssFile));
|
||||||
|
#else
|
||||||
|
browserw = new QTextBrowser(this);
|
||||||
|
verticalLayout->insertWidget(0, browserw);
|
||||||
|
connect(browser, SIGNAL(anchorClicked(const QUrl &)),
|
||||||
|
this, SLOT(linkWasClicked(const QUrl &)));
|
||||||
|
browser->setReadOnly(true);
|
||||||
|
browser->setUndoRedoEnabled(false);
|
||||||
|
browser->setOpenLinks(false);
|
||||||
|
browser->setTabChangesFocus(true);
|
||||||
|
if (prefs.reslistfontfamily.length()) {
|
||||||
|
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||||
|
browser->setFont(nfont);
|
||||||
|
} else {
|
||||||
|
browser->setFont(QFont());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Make title out of file name if none yet
|
// Make title out of file name if none yet
|
||||||
@ -193,10 +193,10 @@ void SnippetsW::init()
|
|||||||
"generator got lost in a maze...</p>"));
|
"generator got lost in a maze...</p>"));
|
||||||
}
|
}
|
||||||
oss << "\n</body></html>";
|
oss << "\n</body></html>";
|
||||||
#ifdef SNIPPETS_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
browser->insertHtml(QString::fromUtf8(oss.str().c_str()));
|
|
||||||
#else
|
|
||||||
browser->setHtml(QString::fromUtf8(oss.str().c_str()));
|
browser->setHtml(QString::fromUtf8(oss.str().c_str()));
|
||||||
|
#else
|
||||||
|
browser->insertHtml(QString::fromUtf8(oss.str().c_str()));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,10 +212,10 @@ void SnippetsW::slotEditFindNext()
|
|||||||
if (!searchFM->isVisible())
|
if (!searchFM->isVisible())
|
||||||
slotEditFind();
|
slotEditFind();
|
||||||
|
|
||||||
#ifdef SNIPPETS_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
browser->find(searchLE->text(), 0);
|
|
||||||
#else
|
|
||||||
browser->findText(searchLE->text());
|
browser->findText(searchLE->text());
|
||||||
|
#else
|
||||||
|
browser->find(searchLE->text(), 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -224,18 +224,19 @@ void SnippetsW::slotEditFindPrevious()
|
|||||||
if (!searchFM->isVisible())
|
if (!searchFM->isVisible())
|
||||||
slotEditFind();
|
slotEditFind();
|
||||||
|
|
||||||
#ifdef SNIPPETS_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
browser->find(searchLE->text(), QTextDocument::FindBackward);
|
|
||||||
#else
|
|
||||||
browser->findText(searchLE->text(), QWebPage::FindBackward);
|
browser->findText(searchLE->text(), QWebPage::FindBackward);
|
||||||
|
#else
|
||||||
|
browser->find(searchLE->text(), QTextDocument::FindBackward);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnippetsW::slotSearchTextChanged(const QString& txt)
|
void SnippetsW::slotSearchTextChanged(const QString& txt)
|
||||||
{
|
{
|
||||||
#ifdef SNIPPETS_TEXTBROWSER
|
#if defined(USING_WEBKIT)
|
||||||
browser->find(txt, 0);
|
|
||||||
#else
|
|
||||||
browser->findText(txt);
|
browser->findText(txt);
|
||||||
|
#else
|
||||||
|
browser->find(txt, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user