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=""
|
||||
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
|
||||
AC_ARG_WITH(qzeitgeist,
|
||||
AC_HELP_STRING([--with-qzeitgeist],
|
||||
@ -504,6 +520,8 @@ AC_SUBST(QTGUI)
|
||||
AC_SUBST(XAPIANCXXFLAGS)
|
||||
AC_SUBST(QMAKE_ENABLE_WEBKIT)
|
||||
AC_SUBST(QMAKE_DISABLE_WEBKIT)
|
||||
AC_SUBST(QMAKE_ENABLE_WEBENGINE)
|
||||
AC_SUBST(QMAKE_DISABLE_WEBENGINE)
|
||||
AC_SUBST(QMAKE_ENABLE_ZEITGEIST)
|
||||
AC_SUBST(QMAKE_DISABLE_ZEITGEIST)
|
||||
AC_SUBST(LIBQZEITGEIST)
|
||||
|
||||
@ -5,9 +5,11 @@ VPATH = @srcdir@
|
||||
DEFINES += BUILDING_RECOLL
|
||||
|
||||
@QMAKE_ENABLE_WEBKIT@ QT += webkit
|
||||
@QMAKE_DISABLE_WEBKIT@ QMAKE_CXXFLAGS += -DRESLIST_TEXTBROWSER -DSNIPPETS_TEXTBROWSER
|
||||
@QMAKE_DISABLE_WEBKIT@ DEFINES += RESLIST_TEXTBROWSER
|
||||
@QMAKE_DISABLE_WEBKIT@ DEFINES += SNIPPETS_TEXTBROWSER
|
||||
@QMAKE_ENABLE_WEBKIT@ DEFINES += USING_WEBKIT
|
||||
|
||||
@QMAKE_ENABLE_WEBENGINE@ QT += webengine
|
||||
@QMAKE_ENABLE_WEBENGINE@ DEFINES += USING_WEBENGINE
|
||||
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
|
||||
@QMAKE_ENABLE_ZEITGEIST@ QT += dbus
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qvariant.h>
|
||||
#include <qevent.h>
|
||||
@ -34,9 +36,6 @@
|
||||
#include <qscrollbar.h>
|
||||
#include <QTextBlock>
|
||||
#include <QShortcut>
|
||||
#ifndef __APPLE__
|
||||
//#include <qx11info_x11.h>
|
||||
#endif
|
||||
|
||||
#include "log.h"
|
||||
#include "smallut.h"
|
||||
@ -47,7 +46,6 @@
|
||||
#include "pathut.h"
|
||||
#include "mimehandler.h"
|
||||
#include "plaintorich.h"
|
||||
#include <memory>
|
||||
#include "internfile.h"
|
||||
#include "indexer.h"
|
||||
#include "snippets_w.h"
|
||||
@ -57,11 +55,12 @@
|
||||
#include "rclhelp.h"
|
||||
#include "appformime.h"
|
||||
#include "respopup.h"
|
||||
#include "reslistpager.h"
|
||||
|
||||
static const QKeySequence quitKeySeq("Ctrl+q");
|
||||
static const QKeySequence closeKeySeq("Ctrl+w");
|
||||
|
||||
#ifndef RESLIST_TEXTBROWSER
|
||||
#if defined(USING_WEBKIT)
|
||||
#include <QWebFrame>
|
||||
#include <QWebElement>
|
||||
#include <QWebSettings>
|
||||
@ -125,7 +124,12 @@ bool QtGuiResListPager::append(const string& data, int docnum,
|
||||
LOGDEB2("QtGuiReslistPager::appendDoc: blockCount " <<
|
||||
m_reslist->document()->blockCount() << ", " << data << "\n");
|
||||
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();
|
||||
m_reslist->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
|
||||
m_reslist->textCursor().insertBlock();
|
||||
@ -136,11 +140,6 @@ bool QtGuiResListPager::append(const string& data, int docnum,
|
||||
for (int block = blkcnt0; block < blkcnt1; block++) {
|
||||
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
|
||||
return true;
|
||||
}
|
||||
@ -281,14 +280,20 @@ static PlainToRichQtReslist g_hiliter;
|
||||
/////////////////////////////////////
|
||||
|
||||
ResList::ResList(QWidget* parent, const char* name)
|
||||
: RESLIST_PARENTCLASS(parent), m_curPvDoc(-1), m_lstClckMod(0),
|
||||
m_listId(0), m_rclmain(0), m_ismainres(true)
|
||||
: RESLIST_PARENTCLASS(parent)
|
||||
{
|
||||
if (!name)
|
||||
setObjectName("resList");
|
||||
else
|
||||
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");
|
||||
setReadOnly(true);
|
||||
setUndoRedoEnabled(false);
|
||||
@ -297,13 +302,6 @@ ResList::ResList(QWidget* parent, const char* name)
|
||||
// signals and slots connections
|
||||
connect(this, SIGNAL(anchorClicked(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
|
||||
|
||||
setFont();
|
||||
@ -370,14 +368,7 @@ void ResList::setRclMain(RclMain *m, bool ismain)
|
||||
|
||||
void ResList::setFont()
|
||||
{
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
if (prefs.reslistfontfamily.length()) {
|
||||
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||
QTextBrowser::setFont(nfont);
|
||||
} else {
|
||||
QTextBrowser::setFont(QFont());
|
||||
}
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
#ifndef SETFONT_WITH_HEADSTYLE
|
||||
QWebSettings *websettings = settings();
|
||||
if (prefs.reslistfontfamily.length()) {
|
||||
@ -392,6 +383,13 @@ void ResList::setFont()
|
||||
websettings->resetFontFamily(QWebSettings::StandardFont);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
if (prefs.reslistfontfamily.length()) {
|
||||
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||
QTextBrowser::setFont(nfont);
|
||||
} else {
|
||||
QTextBrowser::setFont(QFont());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -443,17 +441,14 @@ void ResList::resetView()
|
||||
// slow search, the user will wonder if anything happened. The
|
||||
// following helps making sure that the textedit is really
|
||||
// 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();
|
||||
clear();
|
||||
QTextBrowser::append(".");
|
||||
clear();
|
||||
#ifndef __APPLE__
|
||||
// XFlush(QX11Info::display());
|
||||
#endif
|
||||
#else
|
||||
m_text = "";
|
||||
setHtml("<html><body></body></html>");
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -473,7 +468,7 @@ void ResList::languageChange()
|
||||
setWindowTitle(tr("Result list"));
|
||||
}
|
||||
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
#if !defined(USING_WEBKIT) && !defined(USING_WEBENGINE)
|
||||
// Get document number from text block number
|
||||
int ResList::docnumfromparnum(int block)
|
||||
{
|
||||
@ -601,12 +596,7 @@ void ResList::highlighted(const QString& )
|
||||
// fair enough, else we go to next/previous result page.
|
||||
void ResList::resPageUpOrBack()
|
||||
{
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
int vpos = verticalScrollBar()->value();
|
||||
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
|
||||
if (vpos == verticalScrollBar()->value())
|
||||
resultPageBack();
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
if (scrollIsAtTop()) {
|
||||
resultPageBack();
|
||||
} else {
|
||||
@ -614,19 +604,17 @@ void ResList::resPageUpOrBack()
|
||||
frame->scroll(0, -int(0.9*geometry().height()));
|
||||
}
|
||||
setupArrows();
|
||||
#else
|
||||
int vpos = verticalScrollBar()->value();
|
||||
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
|
||||
if (vpos == verticalScrollBar()->value())
|
||||
resultPageBack();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ResList::resPageDownOrNext()
|
||||
{
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
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 defined(USING_WEBKIT)
|
||||
if (scrollIsAtBottom()) {
|
||||
resultPageNext();
|
||||
} else {
|
||||
@ -634,6 +622,13 @@ void ResList::resPageDownOrNext()
|
||||
frame->scroll(0, int(0.9*geometry().height()));
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@ -645,9 +640,7 @@ void ResList::setupArrows()
|
||||
|
||||
bool ResList::scrollIsAtBottom()
|
||||
{
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
return false;
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
QWebFrame *frame = page()->mainFrame();
|
||||
bool ret;
|
||||
if (!frame || frame->scrollBarGeometry(Qt::Vertical).isEmpty()) {
|
||||
@ -660,14 +653,14 @@ bool ResList::scrollIsAtBottom()
|
||||
}
|
||||
LOGDEB2("scrollIsAtBottom: returning " << ret << "\n");
|
||||
return ret;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ResList::scrollIsAtTop()
|
||||
{
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
return false;
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
QWebFrame *frame = page()->mainFrame();
|
||||
bool ret;
|
||||
if (!frame || frame->scrollBarGeometry(Qt::Vertical).isEmpty()) {
|
||||
@ -680,6 +673,8 @@ bool ResList::scrollIsAtTop()
|
||||
}
|
||||
LOGDEB2("scrollIsAtTop: returning " << ret << "\n");
|
||||
return ret;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -720,10 +715,10 @@ void ResList::resultPageFor(int docnum)
|
||||
void ResList::append(const QString &text)
|
||||
{
|
||||
LOGDEB2("QtGuiReslistPager::appendQString : " << qs2utf8s(text) << "\n");
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
QTextBrowser::append(text);
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
m_text += text;
|
||||
#else
|
||||
QTextBrowser::append(text);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -733,7 +728,7 @@ void ResList::displayPage()
|
||||
|
||||
m_pager->displayPage(theconfig);
|
||||
|
||||
#ifndef RESLIST_TEXTBROWSER
|
||||
#if defined(USING_WEBENGINE) || defined(USING_WEBKIT)
|
||||
setHtml(m_text);
|
||||
#endif
|
||||
|
||||
@ -753,7 +748,18 @@ void ResList::previewExposed(int docnum)
|
||||
|
||||
// Possibly erase old one to white
|
||||
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);
|
||||
if (blockrange.first != -1) {
|
||||
for (int blockn = blockrange.first;
|
||||
@ -765,17 +771,6 @@ void ResList::previewExposed(int docnum)
|
||||
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
|
||||
m_curPvDoc = -1;
|
||||
}
|
||||
@ -783,7 +778,18 @@ void ResList::previewExposed(int docnum)
|
||||
// Set background for active preview's doc entry
|
||||
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);
|
||||
|
||||
// Maybe docnum is -1 or not in this window,
|
||||
@ -801,17 +807,6 @@ void ResList::previewExposed(int docnum)
|
||||
setTextCursor(cursor);
|
||||
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
|
||||
}
|
||||
|
||||
@ -819,11 +814,11 @@ void ResList::previewExposed(int docnum)
|
||||
void ResList::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
RESLIST_PARENTCLASS::mouseDoubleClickEvent(event);
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
#if defined(USING_WEBKIT)
|
||||
emit(wordSelect(selectedText()));
|
||||
#else
|
||||
if (textCursor().hasSelection())
|
||||
emit(wordSelect(textCursor().selectedText()));
|
||||
#else
|
||||
emit(wordSelect(selectedText()));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -981,12 +976,7 @@ void ResList::linkWasClicked(const QUrl &url)
|
||||
void ResList::createPopupMenu(const QPoint& pos)
|
||||
{
|
||||
LOGDEB("ResList::createPopupMenu(" << pos.x() << ", " << pos.y() << ")\n");
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
QTextCursor cursor = cursorForPosition(pos);
|
||||
int blocknum = cursor.blockNumber();
|
||||
LOGDEB("ResList::createPopupMenu(): block " << blocknum << "\n");
|
||||
m_popDoc = docnumfromparnum(blocknum);
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
QWebHitTestResult htr = page()->mainFrame()->hitTestContent(pos);
|
||||
if (htr.isNull())
|
||||
return;
|
||||
@ -997,6 +987,11 @@ void ResList::createPopupMenu(const QPoint& pos)
|
||||
return;
|
||||
QString snum = el.attribute("rcldocnum");
|
||||
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
|
||||
|
||||
if (m_popDoc < 0)
|
||||
@ -1101,8 +1096,8 @@ void ResList::menuExpand()
|
||||
if (getDoc(m_popDoc, doc))
|
||||
emit docExpand(doc);
|
||||
}
|
||||
|
||||
int ResList::pageFirstDocNum()
|
||||
{
|
||||
return m_pager->pageFirstDocNum();
|
||||
}
|
||||
|
||||
|
||||
@ -19,26 +19,24 @@
|
||||
#define _RESLIST_H_INCLUDED_
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <map>
|
||||
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
#include <QTextBrowser>
|
||||
#define RESLIST_PARENTCLASS QTextBrowser
|
||||
#else
|
||||
#if defined(USING_WEBENGINE)
|
||||
# include <QWebEngineView>
|
||||
# define RESLIST_PARENTCLASS QWebEngineView
|
||||
#elif defined(USING_WEBKIT)
|
||||
# include <QWebView>
|
||||
# define RESLIST_PARENTCLASS QWebView
|
||||
#else
|
||||
# include <QTextBrowser>
|
||||
# define RESLIST_PARENTCLASS QTextBrowser
|
||||
#endif
|
||||
|
||||
#include "docseq.h"
|
||||
#include "sortseq.h"
|
||||
#include "filtseq.h"
|
||||
#include <memory>
|
||||
#include "rcldoc.h"
|
||||
#include "reslistpager.h"
|
||||
|
||||
class RclMain;
|
||||
class QtGuiResListPager;
|
||||
namespace Rcl {
|
||||
class Doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a list of document records. The data can be out of the history
|
||||
@ -117,26 +115,26 @@ class ResList : public RESLIST_PARENTCLASS
|
||||
virtual void linkWasClicked(const QUrl &);
|
||||
|
||||
private:
|
||||
QtGuiResListPager *m_pager;
|
||||
QtGuiResListPager *m_pager{0};
|
||||
std::shared_ptr<DocSequence> m_source;
|
||||
int m_popDoc; // Docnum for the popup menu.
|
||||
int m_curPvDoc;// Docnum for current preview
|
||||
int m_lstClckMod; // Last click modifier.
|
||||
int m_listId; // query Id for matching with preview windows
|
||||
int m_popDoc{-1}; // Docnum for the popup menu.
|
||||
int m_curPvDoc{-1};// Docnum for current preview
|
||||
int m_lstClckMod{0}; // Last click modifier.
|
||||
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
|
||||
// docnum. Built while we insert text into the qtextedit
|
||||
std::map<int,int> m_pageParaToReldocnums;
|
||||
virtual int docnumfromparnum(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
|
||||
RclMain *m_rclmain;
|
||||
bool m_ismainres;
|
||||
RclMain *m_rclmain{0};
|
||||
bool m_ismainres{true};
|
||||
|
||||
virtual void displayPage(); // Display current page
|
||||
static int newListId();
|
||||
|
||||
@ -23,12 +23,12 @@
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
#ifdef SNIPPETS_TEXTBROWSER
|
||||
#include <QTextBrowser>
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
#include <QWebSettings>
|
||||
#include <QWebFrame>
|
||||
#include <QUrl>
|
||||
#else
|
||||
#include <QTextBrowser>
|
||||
#endif
|
||||
#include <QShortcut>
|
||||
|
||||
@ -42,10 +42,10 @@ using namespace std;
|
||||
|
||||
// Note: the internal search currently does not work with QTextBrowser. To be
|
||||
// fixed by looking at the preview code if someone asks for it...
|
||||
#ifdef SNIPPETS_TEXTBROWSER
|
||||
#define browser ((QTextBrowser*)browserw)
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
#define browser ((QWebView*)browserw)
|
||||
#else
|
||||
#define browser ((QTextBrowser*)browserw)
|
||||
#endif
|
||||
|
||||
class PlainToRichQtSnippets : public PlainToRich {
|
||||
@ -92,22 +92,7 @@ void SnippetsW::init()
|
||||
connect(nextPB, SIGNAL(clicked()), this, SLOT(slotEditFindNext()));
|
||||
connect(prevPB, SIGNAL(clicked()), this, SLOT(slotEditFindPrevious()));
|
||||
|
||||
#ifdef SNIPPETS_TEXTBROWSER
|
||||
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
|
||||
#if defined(USING_WEBKIT)
|
||||
browserw = new QWebView(this);
|
||||
verticalLayout->insertWidget(0, browserw);
|
||||
browser->setUrl(QUrl(QString::fromUtf8("about:blank")));
|
||||
@ -123,6 +108,21 @@ void SnippetsW::init()
|
||||
}
|
||||
if (!prefs.snipCssFile.isEmpty())
|
||||
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
|
||||
|
||||
// Make title out of file name if none yet
|
||||
@ -193,10 +193,10 @@ void SnippetsW::init()
|
||||
"generator got lost in a maze...</p>"));
|
||||
}
|
||||
oss << "\n</body></html>";
|
||||
#ifdef SNIPPETS_TEXTBROWSER
|
||||
browser->insertHtml(QString::fromUtf8(oss.str().c_str()));
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
browser->setHtml(QString::fromUtf8(oss.str().c_str()));
|
||||
#else
|
||||
browser->insertHtml(QString::fromUtf8(oss.str().c_str()));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -212,10 +212,10 @@ void SnippetsW::slotEditFindNext()
|
||||
if (!searchFM->isVisible())
|
||||
slotEditFind();
|
||||
|
||||
#ifdef SNIPPETS_TEXTBROWSER
|
||||
browser->find(searchLE->text(), 0);
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
browser->findText(searchLE->text());
|
||||
#else
|
||||
browser->find(searchLE->text(), 0);
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -224,18 +224,19 @@ void SnippetsW::slotEditFindPrevious()
|
||||
if (!searchFM->isVisible())
|
||||
slotEditFind();
|
||||
|
||||
#ifdef SNIPPETS_TEXTBROWSER
|
||||
browser->find(searchLE->text(), QTextDocument::FindBackward);
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
browser->findText(searchLE->text(), QWebPage::FindBackward);
|
||||
#else
|
||||
browser->find(searchLE->text(), QTextDocument::FindBackward);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SnippetsW::slotSearchTextChanged(const QString& txt)
|
||||
{
|
||||
#ifdef SNIPPETS_TEXTBROWSER
|
||||
browser->find(txt, 0);
|
||||
#else
|
||||
#if defined(USING_WEBKIT)
|
||||
browser->findText(txt);
|
||||
#else
|
||||
browser->find(txt, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user