diff --git a/src/configure.ac b/src/configure.ac index 148679a6..b59add44 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -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) diff --git a/src/qtgui/recoll.pro.in b/src/qtgui/recoll.pro.in index b6448dbf..d3f6ecce 100644 --- a/src/qtgui/recoll.pro.in +++ b/src/qtgui/recoll.pro.in @@ -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 diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index 4b059cc4..9882125c 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include #include #include @@ -34,9 +36,6 @@ #include #include #include -#ifndef __APPLE__ -//#include -#endif #include "log.h" #include "smallut.h" @@ -47,7 +46,6 @@ #include "pathut.h" #include "mimehandler.h" #include "plaintorich.h" -#include #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 #include #include @@ -77,8 +76,8 @@ static const QKeySequence closeKeySeq("Ctrl+w"); class QtGuiResListPager : public ResListPager { public: QtGuiResListPager(ResList *p, int ps) - : ResListPager(ps), m_reslist(p) - {} + : ResListPager(ps), m_reslist(p) + {} virtual bool append(const string& data); virtual bool append(const string& data, int idx, const Rcl::Doc& doc); virtual string trans(const string& in); @@ -89,7 +88,7 @@ public: virtual string prevUrl(); virtual string headerContent(); virtual void suggest(const vectoruterms, - map >& sugg); + map >& sugg); virtual string absSep() {return (const char *)(prefs.abssep.toUtf8());} virtual string iconUrl(RclConfig *, Rcl::Doc& doc); private: @@ -101,9 +100,9 @@ FILE *fp; void logdata(const char *data) { if (fp == 0) - fp = fopen("/tmp/recolltoto.html", "a"); + fp = fopen("/tmp/recolltoto.html", "a"); if (fp) - fprintf(fp, "%s", data); + fprintf(fp, "%s", data); } #else #define logdata(X) @@ -120,12 +119,17 @@ bool QtGuiResListPager::append(const string& data) } bool QtGuiResListPager::append(const string& data, int docnum, - const Rcl::Doc&) + const Rcl::Doc&) { LOGDEB2("QtGuiReslistPager::appendDoc: blockCount " << m_reslist->document()->blockCount() << ", " << data << "\n"); logdata(data.c_str()); -#ifdef RESLIST_TEXTBROWSER +#if defined(USING_WEBKIT) + QString sdoc = QString("
").arg(docnum); + m_reslist->append(sdoc); + m_reslist->append(QString::fromUtf8(data.c_str())); + m_reslist->append("
"); +#else int blkcnt0 = m_reslist->document()->blockCount(); m_reslist->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); m_reslist->textCursor().insertBlock(); @@ -134,13 +138,8 @@ bool QtGuiResListPager::append(const string& data, int docnum, m_reslist->ensureCursorVisible(); int blkcnt1 = m_reslist->document()->blockCount(); for (int block = blkcnt0; block < blkcnt1; block++) { - m_reslist->m_pageParaToReldocnums[block] = docnum; + m_reslist->m_pageParaToReldocnums[block] = docnum; } -#else - QString sdoc = QString("
").arg(docnum); - m_reslist->append(sdoc); - m_reslist->append(QString::fromUtf8(data.c_str())); - m_reslist->append("
"); #endif return true; } @@ -196,37 +195,37 @@ string QtGuiResListPager::headerContent() } void QtGuiResListPager::suggest(const vectoruterms, - map >& sugg) + map >& sugg) { sugg.clear(); bool issimple = m_reslist && m_reslist->m_rclmain && - m_reslist->m_rclmain->lastSearchSimple(); + m_reslist->m_rclmain->lastSearchSimple(); for (const auto& uit : uterms) { vector tsuggs; - // If the term is in the dictionary, Aspell::suggest won't - // list alternatives. In fact we may want to check the - // frequencies and propose something anyway if a possible - // variation is much more common (as google does) ? + // If the term is in the dictionary, Aspell::suggest won't + // list alternatives. In fact we may want to check the + // frequencies and propose something anyway if a possible + // variation is much more common (as google does) ? if (!rcldb->getSpellingSuggestions(uit, tsuggs)) { continue; } - // We should check that the term stems differently from the - // base word (else it's not useful to expand the search). Or - // is it ? This should depend if stemming is turned on or not + // We should check that the term stems differently from the + // base word (else it's not useful to expand the search). Or + // is it ? This should depend if stemming is turned on or not if (!tsuggs.empty()) { sugg[uit] = vector(tsuggs.begin(), tsuggs.end()); - if (sugg[uit].size() > 5) - sugg[uit].resize(5); - // Set up the links as a . - for (auto& it : sugg[uit]) { - if (issimple) { - it = string("" + - it + ""; - } - } + if (sugg[uit].size() > 5) + sugg[uit].resize(5); + // Set up the links as a . + for (auto& it : sugg[uit]) { + if (issimple) { + it = string("" + + it + ""; + } + } } } } @@ -234,22 +233,22 @@ void QtGuiResListPager::suggest(const vectoruterms, string QtGuiResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc) { if (doc.ipath.empty()) { - vector docs; - docs.push_back(doc); - vector paths; - Rcl::docsToPaths(docs, paths); - if (!paths.empty()) { - string path; - LOGDEB2("ResList::iconUrl: source path [" << paths[0] << "]\n"); - if (thumbPathForUrl(cstr_fileu + paths[0], 128, path)) { - LOGDEB2("ResList::iconUrl: icon path [" << path << "]\n"); - return cstr_fileu + path; - } else { - LOGDEB2("ResList::iconUrl: no icon: path [" << path << "]\n"); - } - } else { - LOGDEB("ResList::iconUrl: docsToPaths failed\n"); - } + vector docs; + docs.push_back(doc); + vector paths; + Rcl::docsToPaths(docs, paths); + if (!paths.empty()) { + string path; + LOGDEB2("ResList::iconUrl: source path [" << paths[0] << "]\n"); + if (thumbPathForUrl(cstr_fileu + paths[0], 128, path)) { + LOGDEB2("ResList::iconUrl: icon path [" << path << "]\n"); + return cstr_fileu + path; + } else { + LOGDEB2("ResList::iconUrl: no icon: path [" << path << "]\n"); + } + } else { + LOGDEB("ResList::iconUrl: docsToPaths failed\n"); + } } return ResListPager::iconUrl(config, doc); } @@ -259,36 +258,42 @@ string QtGuiResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc) class PlainToRichQtReslist : public PlainToRich { public: virtual string startMatch(unsigned int idx) - { - if (0 && m_hdata) { - string s1, s2; - stringsToString >(m_hdata->groups[idx], s1); - stringsToString >(m_hdata->ugroups[m_hdata->grpsugidx[idx]], s2); - LOGDEB2("Reslist startmatch: group " << s1 << " user group " << - s2 << "\n"); - } - - return string(""); - } + { + if (0 && m_hdata) { + string s1, s2; + stringsToString >(m_hdata->groups[idx], s1); + stringsToString >(m_hdata->ugroups[m_hdata->grpsugidx[idx]], s2); + LOGDEB2("Reslist startmatch: group " << s1 << " user group " << + s2 << "\n"); + } + + return string(""); + } virtual string endMatch() - { - return string(""); - } + { + return string(""); + } }; 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"); + setObjectName("resList"); else - setObjectName(name); -#ifdef RESLIST_TEXTBROWSER + setObjectName(name); +#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); @@ -296,14 +301,7 @@ ResList::ResList(QWidget* parent, const char* name) setTabChangesFocus(true); // 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); + this, SLOT(linkWasClicked(const QUrl &))); #endif setFont(); @@ -316,12 +314,12 @@ ResList::ResList(QWidget* parent, const char* name) #if 0 // See comments in "highlighted connect(this, SIGNAL(highlighted(const QString &)), - this, SLOT(highlighted(const QString &))); + this, SLOT(highlighted(const QString &))); #endif setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), - this, SLOT(createPopupMenu(const QPoint&))); + this, SLOT(createPopupMenu(const QPoint&))); m_pager = new QtGuiResListPager(this, prefs.respagesize); m_pager->setHighLighter(&g_hiliter); @@ -333,18 +331,18 @@ ResList::~ResList() #ifdef __GNUC__ __attribute__((unused)) #endif - static const char* strings[] = { - QT_TR_NOOP("

No results found
"), - QT_TR_NOOP("Documents"), - QT_TR_NOOP("out of at least"), - QT_TR_NOOP("for"), - QT_TR_NOOP("Previous"), - QT_TR_NOOP("Next"), - QT_TR_NOOP("Unavailable document"), - QT_TR_NOOP("Preview"), - QT_TR_NOOP("Open"), - QT_TR_NOOP("Snippets"), - QT_TR_NOOP("(show query)"), + static const char* strings[] = { + QT_TR_NOOP("

No results found
"), + QT_TR_NOOP("Documents"), + QT_TR_NOOP("out of at least"), + QT_TR_NOOP("for"), + QT_TR_NOOP("Previous"), + QT_TR_NOOP("Next"), + QT_TR_NOOP("Unavailable document"), + QT_TR_NOOP("Preview"), + QT_TR_NOOP("Open"), + QT_TR_NOOP("Snippets"), + QT_TR_NOOP("(show query)"), QT_TR_NOOP("

Alternate spellings (accents suppressed): "), QT_TR_NOOP("

Alternate spellings: "), }; @@ -355,43 +353,43 @@ void ResList::setRclMain(RclMain *m, bool ismain) m_rclmain = m; m_ismainres = ismain; if (!m_ismainres) { - connect(new QShortcut(closeKeySeq, this), SIGNAL (activated()), - this, SLOT (close())); - connect(new QShortcut(quitKeySeq, this), SIGNAL (activated()), - m_rclmain, SLOT (fileExit())); - connect(this, SIGNAL(previewRequested(Rcl::Doc)), - m_rclmain, SLOT(startPreview(Rcl::Doc))); - connect(this, SIGNAL(docSaveToFileClicked(Rcl::Doc)), - m_rclmain, SLOT(saveDocToFile(Rcl::Doc))); - connect(this, SIGNAL(editRequested(Rcl::Doc)), - m_rclmain, SLOT(startNativeViewer(Rcl::Doc))); + connect(new QShortcut(closeKeySeq, this), SIGNAL (activated()), + this, SLOT (close())); + connect(new QShortcut(quitKeySeq, this), SIGNAL (activated()), + m_rclmain, SLOT (fileExit())); + connect(this, SIGNAL(previewRequested(Rcl::Doc)), + m_rclmain, SLOT(startPreview(Rcl::Doc))); + connect(this, SIGNAL(docSaveToFileClicked(Rcl::Doc)), + m_rclmain, SLOT(saveDocToFile(Rcl::Doc))); + connect(this, SIGNAL(editRequested(Rcl::Doc)), + m_rclmain, SLOT(startNativeViewer(Rcl::Doc))); } } 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()) { // For some reason there is (12-2014) an offset of 3 between what // we request from webkit and what we get. - websettings->setFontSize(QWebSettings::DefaultFontSize, - prefs.reslistfontsize + 3); - websettings->setFontFamily(QWebSettings::StandardFont, - prefs.reslistfontfamily); + websettings->setFontSize(QWebSettings::DefaultFontSize, + prefs.reslistfontsize + 3); + websettings->setFontFamily(QWebSettings::StandardFont, + prefs.reslistfontfamily); } else { - websettings->resetFontSize(QWebSettings::DefaultFontSize); - websettings->resetFontFamily(QWebSettings::StandardFont); + websettings->resetFontSize(QWebSettings::DefaultFontSize); + websettings->resetFontFamily(QWebSettings::StandardFont); } #endif +#else + if (prefs.reslistfontfamily.length()) { + QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize); + QTextBrowser::setFont(nfont); + } else { + QTextBrowser::setFont(QFont()); + } #endif } @@ -418,7 +416,7 @@ void ResList::readDocSource() LOGDEB("ResList::readDocSource()\n"); resetView(); if (!m_source) - return; + return; m_listId = newListId(); // Reset the page size in case the preference was changed @@ -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(""); +#else m_pageParaToReldocnums.clear(); clear(); QTextBrowser::append("."); clear(); -#ifndef __APPLE__ -// XFlush(QX11Info::display()); -#endif -#else - m_text = ""; - setHtml(""); #endif } @@ -464,7 +459,7 @@ bool ResList::displayingHistory() // shown. Using the title value is an ugly hack string htstring = string((const char *)tr("Document history").toUtf8()); if (!m_source || m_source->title().empty()) - return false; + return false; return m_source->title().find(htstring) == 0; } @@ -473,20 +468,20 @@ 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) { if (m_pager->pageNumber() < 0) - return -1; + return -1; // Try to find the first number < input and actually in the map // (result blocks can be made of several text blocks) std::map::iterator it; do { - it = m_pageParaToReldocnums.find(block); - if (it != m_pageParaToReldocnums.end()) - return pageFirstDocNum() + it->second; + it = m_pageParaToReldocnums.find(block); + if (it != m_pageParaToReldocnums.end()) + return pageFirstDocNum() + it->second; } while (--block >= 0); return -1; } @@ -496,29 +491,29 @@ pair ResList::parnumfromdocnum(int docnum) { LOGDEB("parnumfromdocnum: docnum " << docnum << "\n"); if (m_pager->pageNumber() < 0) { - LOGDEB("parnumfromdocnum: no page return -1,-1\n"); - return pair(-1,-1); + LOGDEB("parnumfromdocnum: no page return -1,-1\n"); + return pair(-1,-1); } int winfirst = pageFirstDocNum(); if (docnum - winfirst < 0) { - LOGDEB("parnumfromdocnum: docnum " << docnum << " < winfirst " << + LOGDEB("parnumfromdocnum: docnum " << docnum << " < winfirst " << winfirst << " return -1,-1\n"); - return pair(-1,-1); + return pair(-1,-1); } docnum -= winfirst; for (std::map::iterator it = m_pageParaToReldocnums.begin(); - it != m_pageParaToReldocnums.end(); it++) { - if (docnum == it->second) { - int first = it->first; - int last = first+1; - std::map::iterator it1; - while ((it1 = m_pageParaToReldocnums.find(last)) != - m_pageParaToReldocnums.end() && it1->second == docnum) { - last++; - } - LOGDEB("parnumfromdocnum: return " << first << "," << last << "\n"); - return pair(first, last); - } + it != m_pageParaToReldocnums.end(); it++) { + if (docnum == it->second) { + int first = it->first; + int last = first+1; + std::map::iterator it1; + while ((it1 = m_pageParaToReldocnums.find(last)) != + m_pageParaToReldocnums.end() && it1->second == docnum) { + last++; + } + LOGDEB("parnumfromdocnum: return " << first << "," << last << "\n"); + return pair(first, last); + } } LOGDEB("parnumfromdocnum: not found return -1,-1\n"); return pair(-1,-1); @@ -536,23 +531,23 @@ bool ResList::getDoc(int docnum, Rcl::Doc &doc) int winfirst = pageFirstDocNum(); int winlast = m_pager->pageLastDocNum(); if (docnum < 0 || winfirst < 0 || winlast < 0) - return false; + return false; // Is docnum in current page ? Then all Ok if (docnum >= winfirst && docnum <= winlast) { - return m_pager->getDoc(docnum, doc); + return m_pager->getDoc(docnum, doc); } // Else we accept to page down or up but not further if (docnum < winfirst && docnum >= winfirst - prefs.respagesize) { - resultPageBack(); + resultPageBack(); } else if (docnum < winlast + 1 + prefs.respagesize) { - resultPageNext(); + resultPageNext(); } winfirst = pageFirstDocNum(); winlast = m_pager->pageLastDocNum(); if (docnum >= winfirst && docnum <= winlast) { - return m_pager->getDoc(docnum, doc); + return m_pager->getDoc(docnum, doc); } return false; } @@ -560,19 +555,19 @@ bool ResList::getDoc(int docnum, Rcl::Doc &doc) void ResList::keyPressEvent(QKeyEvent * e) { if ((e->modifiers() & Qt::ShiftModifier)) { - if (e->key() == Qt::Key_PageUp) { - // Shift-PageUp -> first page of results - resultPageFirst(); - return; - } + if (e->key() == Qt::Key_PageUp) { + // Shift-PageUp -> first page of results + resultPageFirst(); + return; + } } else { - if (e->key() == Qt::Key_PageUp || e->key() == Qt::Key_Backspace) { - resPageUpOrBack(); - return; - } else if (e->key() == Qt::Key_PageDown || e->key() == Qt::Key_Space) { - resPageDownOrNext(); - return; - } + if (e->key() == Qt::Key_PageUp || e->key() == Qt::Key_Backspace) { + resPageUpOrBack(); + return; + } else if (e->key() == Qt::Key_PageDown || e->key() == Qt::Key_Space) { + resPageDownOrNext(); + return; + } } RESLIST_PARENTCLASS::keyPressEvent(e); } @@ -581,10 +576,10 @@ void ResList::mouseReleaseEvent(QMouseEvent *e) { m_lstClckMod = 0; if (e->modifiers() & Qt::ControlModifier) { - m_lstClckMod |= Qt::ControlModifier; + m_lstClckMod |= Qt::ControlModifier; } if (e->modifiers() & Qt::ShiftModifier) { - m_lstClckMod |= Qt::ShiftModifier; + m_lstClckMod |= Qt::ShiftModifier; } RESLIST_PARENTCLASS::mouseReleaseEvent(e); } @@ -601,39 +596,39 @@ void ResList::highlighted(const QString& ) // fair enough, else we go to next/previous result page. void ResList::resPageUpOrBack() { -#ifdef RESLIST_TEXTBROWSER +#if defined(USING_WEBKIT) + if (scrollIsAtTop()) { + resultPageBack(); + } else { + QWebFrame *frame = page()->mainFrame(); + frame->scroll(0, -int(0.9*geometry().height())); + } + setupArrows(); +#else int vpos = verticalScrollBar()->value(); verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub); if (vpos == verticalScrollBar()->value()) - resultPageBack(); -#else - if (scrollIsAtTop()) { - resultPageBack(); - } else { - QWebFrame *frame = page()->mainFrame(); - frame->scroll(0, -int(0.9*geometry().height())); - } - setupArrows(); + resultPageBack(); #endif } void ResList::resPageDownOrNext() { -#ifdef RESLIST_TEXTBROWSER +#if defined(USING_WEBKIT) + if (scrollIsAtBottom()) { + resultPageNext(); + } else { + QWebFrame *frame = page()->mainFrame(); + 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(); -#else - if (scrollIsAtBottom()) { - resultPageNext(); - } else { - QWebFrame *frame = page()->mainFrame(); - frame->scroll(0, int(0.9*geometry().height())); - } - setupArrows(); + resultPageNext(); #endif } @@ -645,41 +640,41 @@ 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()) { - ret = true; + ret = true; } else { - int max = frame->scrollBarMaximum(Qt::Vertical); - int cur = frame->scrollBarValue(Qt::Vertical); - ret = (max != 0) && (cur == max); - LOGDEB2("Scrollatbottom: cur " << cur << " max " << max << "\n"); + int max = frame->scrollBarMaximum(Qt::Vertical); + int cur = frame->scrollBarValue(Qt::Vertical); + ret = (max != 0) && (cur == max); + LOGDEB2("Scrollatbottom: cur " << cur << " max " << max << "\n"); } 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()) { - ret = true; + ret = true; } else { - int cur = frame->scrollBarValue(Qt::Vertical); - int min = frame->scrollBarMinimum(Qt::Vertical); - LOGDEB("Scrollattop: cur " << cur << " min " << min << "\n"); - ret = (cur == min); + int cur = frame->scrollBarValue(Qt::Vertical); + int min = frame->scrollBarMinimum(Qt::Vertical); + LOGDEB("Scrollattop: cur " << cur << " min " << min << "\n"); + ret = (cur == min); } LOGDEB2("scrollIsAtTop: returning " << ret << "\n"); return ret; +#else + return false; #endif } @@ -688,8 +683,8 @@ bool ResList::scrollIsAtTop() void ResList::resultPageBack() { if (m_pager->hasPrev()) { - m_pager->resultPageBack(); - displayPage(); + m_pager->resultPageBack(); + displayPage(); } } @@ -706,8 +701,8 @@ void ResList::resultPageFirst() void ResList::resultPageNext() { if (m_pager->hasNext()) { - m_pager->resultPageNext(); - displayPage(); + m_pager->resultPageNext(); + displayPage(); } } @@ -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,64 +748,64 @@ void ResList::previewExposed(int docnum) // Possibly erase old one to white if (m_curPvDoc != -1) { -#ifdef RESLIST_TEXTBROWSER - pair blockrange = parnumfromdocnum(m_curPvDoc); - if (blockrange.first != -1) { - for (int blockn = blockrange.first; - blockn < blockrange.second; blockn++) { - QTextBlock block = document()->findBlockByNumber(blockn); - QTextCursor cursor(block); - QTextBlockFormat format = cursor.blockFormat(); - format.clearBackground(); - cursor.setBlockFormat(format); - } - } +#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 - 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"); - } + pair blockrange = parnumfromdocnum(m_curPvDoc); + if (blockrange.first != -1) { + for (int blockn = blockrange.first; + blockn < blockrange.second; blockn++) { + QTextBlock block = document()->findBlockByNumber(blockn); + QTextCursor cursor(block); + QTextBlockFormat format = cursor.blockFormat(); + format.clearBackground(); + cursor.setBlockFormat(format); + } + } #endif - m_curPvDoc = -1; + m_curPvDoc = -1; } // 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 blockrange = parnumfromdocnum(docnum); // Maybe docnum is -1 or not in this window, if (blockrange.first < 0) - return; + return; // Color the new active paragraph QColor color("LightBlue"); for (int blockn = blockrange.first+1; - blockn < blockrange.second; blockn++) { - QTextBlock block = document()->findBlockByNumber(blockn); - QTextCursor cursor(block); - QTextBlockFormat format; - format.setBackground(QBrush(color)); - cursor.mergeBlockFormat(format); - 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"); + blockn < blockrange.second; blockn++) { + QTextBlock block = document()->findBlockByNumber(blockn); + QTextCursor cursor(block); + QTextBlockFormat format; + format.setBackground(QBrush(color)); + cursor.mergeBlockFormat(format); + setTextCursor(cursor); + ensureCursorVisible(); } #endif } @@ -819,22 +814,22 @@ void ResList::previewExposed(int docnum) void ResList::mouseDoubleClickEvent(QMouseEvent *event) { RESLIST_PARENTCLASS::mouseDoubleClickEvent(event); -#ifdef RESLIST_TEXTBROWSER - if (textCursor().hasSelection()) - emit(wordSelect(textCursor().selectedText())); -#else +#if defined(USING_WEBKIT) emit(wordSelect(selectedText())); +#else + if (textCursor().hasSelection()) + emit(wordSelect(textCursor().selectedText())); #endif } void ResList::showQueryDetails() { if (!m_source) - return; + return; string oq = breakIntoLines(m_source->getDescription(), 100, 50); QString str; QString desc = tr("Result count (est.)") + ": " + - str.setNum(m_source->getResCnt()) + "
"; + str.setNum(m_source->getResCnt()) + "
"; desc += tr("Query details") + ": " + QString::fromUtf8(oq.c_str()); QMessageBox::information(this, tr("Query details"), desc); } @@ -851,48 +846,48 @@ void ResList::linkWasClicked(const QUrl &url) int what = strurl[0]; switch (what) { - // Open abstract/snippets window + // Open abstract/snippets window case 'A': { - if (!m_source) - return; - int i = atoi(strurl.c_str()+1) - 1; - Rcl::Doc doc; - if (!getDoc(i, doc)) { - LOGERR("ResList::linkWasClicked: can't get doc for " << i << "\n"); - return; - } - emit(showSnippets(doc)); + if (!m_source) + return; + int i = atoi(strurl.c_str()+1) - 1; + Rcl::Doc doc; + if (!getDoc(i, doc)) { + LOGERR("ResList::linkWasClicked: can't get doc for " << i << "\n"); + return; + } + emit(showSnippets(doc)); } break; // Show duplicates case 'D': { - if (!m_source) - return; - int i = atoi(strurl.c_str()+1) - 1; - Rcl::Doc doc; - if (!getDoc(i, doc)) { - LOGERR("ResList::linkWasClicked: can't get doc for " << i << "\n"); - return; - } - vector dups; - if (m_source->docDups(doc, dups) && m_rclmain) { - m_rclmain->newDupsW(doc, dups); - } + if (!m_source) + return; + int i = atoi(strurl.c_str()+1) - 1; + Rcl::Doc doc; + if (!getDoc(i, doc)) { + LOGERR("ResList::linkWasClicked: can't get doc for " << i << "\n"); + return; + } + vector dups; + if (m_source->docDups(doc, dups) && m_rclmain) { + m_rclmain->newDupsW(doc, dups); + } } break; // Open parent folder case 'F': { - int i = atoi(strurl.c_str()+1) - 1; - Rcl::Doc doc; - if (!getDoc(i, doc)) { - LOGERR("ResList::linkWasClicked: can't get doc for " << i << "\n"); - return; - } + int i = atoi(strurl.c_str()+1) - 1; + Rcl::Doc doc; + if (!getDoc(i, doc)) { + LOGERR("ResList::linkWasClicked: can't get doc for " << i << "\n"); + return; + } emit editRequested(ResultPopup::getParent(std::shared_ptr(), doc)); } @@ -901,47 +896,47 @@ void ResList::linkWasClicked(const QUrl &url) // Show query details case 'H': { - showQueryDetails(); - break; + showQueryDetails(); + break; } // Preview and edit case 'P': case 'E': { - int i = atoi(strurl.c_str()+1) - 1; - Rcl::Doc doc; - if (!getDoc(i, doc)) { - LOGERR("ResList::linkWasClicked: can't get doc for " << i << "\n"); - return; - } - if (what == 'P') { - if (m_ismainres) { - emit docPreviewClicked(i, doc, m_lstClckMod); - } else { - emit previewRequested(doc); - } - } else { - emit editRequested(doc); - } + int i = atoi(strurl.c_str()+1) - 1; + Rcl::Doc doc; + if (!getDoc(i, doc)) { + LOGERR("ResList::linkWasClicked: can't get doc for " << i << "\n"); + return; + } + if (what == 'P') { + if (m_ismainres) { + emit docPreviewClicked(i, doc, m_lstClckMod); + } else { + emit previewRequested(doc); + } + } else { + emit editRequested(doc); + } } break; // Next/prev page case 'n': - resultPageNext(); - break; + resultPageNext(); + break; case 'p': - resultPageBack(); - break; + resultPageBack(); + break; - // Run script. Link format Rnn|Script Name + // Run script. Link format Rnn|Script Name case 'R': { - int i = atoi(strurl.c_str() + 1) - 1; - QString s = url.toString(); - int bar = s.indexOf("|"); - if (bar == -1 || bar >= s.size()-1) + int i = atoi(strurl.c_str() + 1) - 1; + QString s = url.toString(); + int bar = s.indexOf("|"); + if (bar == -1 || bar >= s.size()-1) break; string cmdname = qs2utf8s(s.right(s.size() - (bar + 1))); DesktopDb ddb(path_cat(theconfig->getConfDir(), "scripts")); @@ -956,58 +951,58 @@ void ResList::linkWasClicked(const QUrl &url) } break; - // Spelling: replacement suggestion clicked + // Spelling: replacement suggestion clicked case 'S': { string s; - if (!strurl.empty()) - s = strurl.substr(1); + if (!strurl.empty()) + s = strurl.substr(1); string::size_type bar = s.find_first_of("|"); - if (bar != string::npos && bar < s.size() - 1) { - string o = s.substr(0, bar); - string n = s.substr(bar+1); + if (bar != string::npos && bar < s.size() - 1) { + string o = s.substr(0, bar); + string n = s.substr(bar+1); LOGDEB2("Emitting wordreplace " << o << " -> " << n << std::endl); - emit wordReplace(u8s2qs(o), u8s2qs(n)); - } + emit wordReplace(u8s2qs(o), u8s2qs(n)); + } } break; default: - LOGERR("ResList::linkWasClicked: bad link [" << strurl << "]\n"); - break;// ?? + LOGERR("ResList::linkWasClicked: bad link [" << strurl << "]\n"); + break;// ?? } } void ResList::createPopupMenu(const QPoint& pos) { LOGDEB("ResList::createPopupMenu(" << pos.x() << ", " << pos.y() << ")\n"); -#ifdef RESLIST_TEXTBROWSER +#if defined(USING_WEBKIT) + QWebHitTestResult htr = page()->mainFrame()->hitTestContent(pos); + if (htr.isNull()) + return; + QWebElement el = htr.enclosingBlockElement(); + while (!el.isNull() && !el.hasAttribute("rcldocnum")) + el = el.parent(); + if (el.isNull()) + 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); -#else - QWebHitTestResult htr = page()->mainFrame()->hitTestContent(pos); - if (htr.isNull()) - return; - QWebElement el = htr.enclosingBlockElement(); - while (!el.isNull() && !el.hasAttribute("rcldocnum")) - el = el.parent(); - if (el.isNull()) - return; - QString snum = el.attribute("rcldocnum"); - m_popDoc = pageFirstDocNum() + snum.toInt(); #endif if (m_popDoc < 0) - return; + return; Rcl::Doc doc; if (!getDoc(m_popDoc, doc)) - return; + return; int options = ResultPopup::showSaveOne; if (m_ismainres) - options |= ResultPopup::isMain; + options |= ResultPopup::isMain; QMenu *popup = ResultPopup::create(this, options, m_source, doc); popup->popup(mapToGlobal(pos)); } @@ -1016,11 +1011,11 @@ void ResList::menuPreview() { Rcl::Doc doc; if (getDoc(m_popDoc, doc)) { - if (m_ismainres) { - emit docPreviewClicked(m_popDoc, doc, 0); - } else { - emit previewRequested(doc); - } + if (m_ismainres) { + emit docPreviewClicked(m_popDoc, doc, 0); + } else { + emit previewRequested(doc); + } } } @@ -1028,19 +1023,19 @@ void ResList::menuSaveToFile() { Rcl::Doc doc; if (getDoc(m_popDoc, doc)) - emit docSaveToFileClicked(doc); + emit docSaveToFileClicked(doc); } void ResList::menuPreviewParent() { Rcl::Doc doc; if (getDoc(m_popDoc, doc) && m_source) { - Rcl::Doc pdoc = ResultPopup::getParent(m_source, doc); - if (pdoc.mimetype == "inode/directory") { - emit editRequested(pdoc); - } else { - emit previewRequested(pdoc); - } + Rcl::Doc pdoc = ResultPopup::getParent(m_source, doc); + if (pdoc.mimetype == "inode/directory") { + emit editRequested(pdoc); + } else { + emit previewRequested(pdoc); + } } } @@ -1048,28 +1043,28 @@ void ResList::menuOpenParent() { Rcl::Doc doc; if (getDoc(m_popDoc, doc) && m_source) - emit editRequested(ResultPopup::getParent(m_source, doc)); + emit editRequested(ResultPopup::getParent(m_source, doc)); } void ResList::menuShowSnippets() { Rcl::Doc doc; if (getDoc(m_popDoc, doc)) - emit showSnippets(doc); + emit showSnippets(doc); } void ResList::menuShowSubDocs() { Rcl::Doc doc; if (getDoc(m_popDoc, doc)) - emit showSubDocs(doc); + emit showSubDocs(doc); } void ResList::menuEdit() { Rcl::Doc doc; if (getDoc(m_popDoc, doc)) - emit editRequested(doc); + emit editRequested(doc); } void ResList::menuOpenWith(QAction *act) { @@ -1078,31 +1073,31 @@ void ResList::menuOpenWith(QAction *act) string cmd = qs2utf8s(act->data().toString()); Rcl::Doc doc; if (getDoc(m_popDoc, doc)) - emit openWithRequested(doc, cmd); + emit openWithRequested(doc, cmd); } void ResList::menuCopyFN() { Rcl::Doc doc; if (getDoc(m_popDoc, doc)) - ResultPopup::copyFN(doc); + ResultPopup::copyFN(doc); } void ResList::menuCopyURL() { Rcl::Doc doc; if (getDoc(m_popDoc, doc)) - ResultPopup::copyURL(doc); + ResultPopup::copyURL(doc); } void ResList::menuExpand() { Rcl::Doc doc; if (getDoc(m_popDoc, doc)) - emit docExpand(doc); + emit docExpand(doc); } + int ResList::pageFirstDocNum() { return m_pager->pageFirstDocNum(); } - diff --git a/src/qtgui/reslist.h b/src/qtgui/reslist.h index f8254d03..8495fd28 100644 --- a/src/qtgui/reslist.h +++ b/src/qtgui/reslist.h @@ -19,26 +19,24 @@ #define _RESLIST_H_INCLUDED_ #include "autoconfig.h" -#include -#include +#include -#ifdef RESLIST_TEXTBROWSER -#include -#define RESLIST_PARENTCLASS QTextBrowser +#if defined(USING_WEBENGINE) +# include +# define RESLIST_PARENTCLASS QWebEngineView +#elif defined(USING_WEBKIT) +# include +# define RESLIST_PARENTCLASS QWebView #else -#include -#define RESLIST_PARENTCLASS QWebView +# include +# define RESLIST_PARENTCLASS QTextBrowser #endif -#include "docseq.h" -#include "sortseq.h" -#include "filtseq.h" -#include -#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 @@ -49,7 +47,7 @@ class ResList : public RESLIST_PARENTCLASS Q_OBJECT; friend class QtGuiResListPager; - public: +public: ResList(QWidget* parent = 0, const char* name = 0); virtual ~ResList(); @@ -65,7 +63,7 @@ class ResList : public RESLIST_PARENTCLASS void setFont(); void setRclMain(RclMain *m, bool ismain); - public slots: +public slots: virtual void setDocSource(std::shared_ptr nsource); virtual void resetList(); // Erase current list virtual void resPageUpOrBack(); // Page up pressed @@ -91,8 +89,8 @@ class ResList : public RESLIST_PARENTCLASS virtual void highlighted(const QString& link); virtual void createPopupMenu(const QPoint& pos); virtual void showQueryDetails(); - - signals: + +signals: void nextPageAvailable(bool); void prevPageAvailable(bool); void docPreviewClicked(int, Rcl::Doc, int); @@ -107,36 +105,36 @@ class ResList : public RESLIST_PARENTCLASS void wordReplace(const QString&, const QString&); void hasResults(int); - protected: +protected: void keyPressEvent(QKeyEvent *e); void mouseReleaseEvent(QMouseEvent *e); void mouseDoubleClickEvent(QMouseEvent*); - protected slots: +protected slots: virtual void languageChange(); virtual void linkWasClicked(const QUrl &); - private: - QtGuiResListPager *m_pager; +private: + QtGuiResListPager *m_pager{0}; std::shared_ptr 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 m_pageParaToReldocnums; virtual int docnumfromparnum(int); virtual std::pair 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(); @@ -144,7 +142,7 @@ class ResList : public RESLIST_PARENTCLASS bool scrollIsAtTop(); bool scrollIsAtBottom(); void setupArrows(); - }; +}; #endif /* _RESLIST_H_INCLUDED_ */ diff --git a/src/qtgui/snippets_w.cpp b/src/qtgui/snippets_w.cpp index 2c4e3d7c..83541500 100644 --- a/src/qtgui/snippets_w.cpp +++ b/src/qtgui/snippets_w.cpp @@ -23,12 +23,12 @@ #include using namespace std; -#ifdef SNIPPETS_TEXTBROWSER -#include -#else +#if defined(USING_WEBKIT) #include #include #include +#else +#include #endif #include @@ -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...

")); } oss << "\n"; -#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 }