GUI: enable using QWebView WebKit browser instead of Qt native QTextBrowser to display the result list. On by default, can be disabled with configure --disable-webkit

This commit is contained in:
Jean-Francois Dockes 2012-02-23 14:16:47 +01:00
parent 7fefaf540f
commit ea0f4725cb
16 changed files with 387 additions and 108 deletions

45
src/configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for Recoll 1.16.2. # Generated by GNU Autoconf 2.68 for Recoll 1.17.0.
# #
# #
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@ -557,8 +557,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='Recoll' PACKAGE_NAME='Recoll'
PACKAGE_TARNAME='recoll' PACKAGE_TARNAME='recoll'
PACKAGE_VERSION='1.16.2' PACKAGE_VERSION='1.17.0'
PACKAGE_STRING='Recoll 1.16.2' PACKAGE_STRING='Recoll 1.17.0'
PACKAGE_BUGREPORT='' PACKAGE_BUGREPORT=''
PACKAGE_URL='' PACKAGE_URL=''
@ -603,6 +603,8 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS LIBOBJS
RCLVERSION RCLVERSION
NOPIC NOPIC
QMAKE_DISABLE_WEBKIT
QMAKE_ENABLE_WEBKIT
NOCMDLINE NOCMDLINE
NOQTMAKE NOQTMAKE
HAVE_MKDTEMP HAVE_MKDTEMP
@ -689,6 +691,7 @@ enable_xattr
enable_camelcase enable_camelcase
enable_pic enable_pic
enable_qtgui enable_qtgui
enable_webkit
enable_x11mon enable_x11mon
with_x with_x
' '
@ -1248,7 +1251,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures Recoll 1.16.2 to adapt to many kinds of systems. \`configure' configures Recoll 1.17.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1313,7 +1316,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of Recoll 1.16.2:";; short | recursive ) echo "Configuration of Recoll 1.17.0:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1338,6 +1341,7 @@ Optional Features:
code. This is necessary for building the php code. This is necessary for building the php
extension. extension.
--disable-qtgui Disable the QT-based graphical user interface. --disable-qtgui Disable the QT-based graphical user interface.
--disable-webkit Disable use of qt-webkit.
--disable-x11mon Disable recollindex support for X11 session --disable-x11mon Disable recollindex support for X11 session
monitoring. monitoring.
@ -1436,7 +1440,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
Recoll configure 1.16.2 Recoll configure 1.17.0
generated by GNU Autoconf 2.68 generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc. Copyright (C) 2010 Free Software Foundation, Inc.
@ -1989,7 +1993,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by Recoll $as_me 1.16.2, which was It was created by Recoll $as_me 1.17.0, which was
generated by GNU Autoconf 2.68. Invocation command line was generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@ $ $0 $@
@ -4709,8 +4713,27 @@ $as_echo "$as_me: using qt version 4 user interface" >&6;}
fi fi
cd .. cd ..
##### Using Qt webkit for reslist display? Else Qt textbrowser
# Check whether --enable-webkit was given.
if test "${enable_webkit+set}" = set; then :
enableval=$enable_webkit; enableWebkit=$enableval
else
enableWebkit="yes"
fi
if test "$enableWebkit" = "yes" ; then
QMAKE_ENABLE_WEBKIT=""
QMAKE_DISABLE_WEBKIT="#"
else
QMAKE_ENABLE_WEBKIT="#"
QMAKE_DISABLE_WEBKIT=""
fi
ac_config_files="$ac_config_files $QTGUI/recoll.pro" ac_config_files="$ac_config_files $QTGUI/recoll.pro"
##################### End QT detection ##################### End QT detection
fi fi
@ -5566,7 +5589,9 @@ test "X$m_prefix" = "XNONE" && m_prefix=/usr/local
m_datadir=${m_prefix}/share m_datadir=${m_prefix}/share
QTRECOLL_DATADIR=${m_datadir}/recoll QTRECOLL_DATADIR=${m_datadir}/recoll
RCLVERSION='1.16.2' RCLVERSION='1.17.0'
@ -6127,7 +6152,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by Recoll $as_me 1.16.2, which was This file was extended by Recoll $as_me 1.17.0, which was
generated by GNU Autoconf 2.68. Invocation command line was generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -6189,7 +6214,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
Recoll config.status 1.16.2 Recoll config.status 1.17.0
configured by $0, generated by GNU Autoconf 2.68, configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -404,6 +404,21 @@ else
fi fi
cd .. cd ..
##### Using Qt webkit for reslist display? Else Qt textbrowser
AC_ARG_ENABLE(webkit,
AC_HELP_STRING([--disable-webkit],
[Disable use of qt-webkit.]),
enableWebkit=$enableval, enableWebkit="yes")
if test "$enableWebkit" = "yes" ; then
QMAKE_ENABLE_WEBKIT=""
QMAKE_DISABLE_WEBKIT="#"
else
QMAKE_ENABLE_WEBKIT="#"
QMAKE_DISABLE_WEBKIT=""
fi
AC_CONFIG_FILES($QTGUI/recoll.pro) AC_CONFIG_FILES($QTGUI/recoll.pro)
##################### End QT detection ##################### End QT detection
fi fi
@ -458,6 +473,8 @@ AC_SUBST(XAPIANCXXFLAGS)
AC_SUBST(HAVE_MKDTEMP) AC_SUBST(HAVE_MKDTEMP)
AC_SUBST(NOQTMAKE) AC_SUBST(NOQTMAKE)
AC_SUBST(NOCMDLINE) AC_SUBST(NOCMDLINE)
AC_SUBST(QMAKE_ENABLE_WEBKIT)
AC_SUBST(QMAKE_DISABLE_WEBKIT)
AC_SUBST(NOPIC) AC_SUBST(NOPIC)
AC_SUBST(RCLVERSION) AC_SUBST(RCLVERSION)

35
src/qtgui/editdialog.h Normal file
View File

@ -0,0 +1,35 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef EDITDIALOG_H
#define EDITDIALOG_H
#include <QDialog>
#include "ui_editdialog.h"
class EditDialog : public QDialog, public Ui::EditDialog {
Q_OBJECT
public:
EditDialog(QWidget * parent = 0)
: QDialog(parent)
{
setupUi(this);
}
};
#endif // EDITDIALOG_H

67
src/qtgui/editdialog.ui Normal file
View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditDialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>614</width>
<height>509</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPlainTextEdit" name="plainTextEdit"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -157,6 +157,7 @@ void rwSettings(bool writing)
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8(); prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
} }
} }
SETTING_RW(prefs.reslistheadertext, "/Recoll/prefs/reslist/headertext", String, "");
SETTING_RW(prefs.stylesheetFile, "/Recoll/prefs/stylesheet", String, ""); SETTING_RW(prefs.stylesheetFile, "/Recoll/prefs/stylesheet", String, "");
SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String, SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String,
"english"); "english");

View File

@ -48,6 +48,7 @@ class PrefsPack {
// Result list format string // Result list format string
QString reslistformat; QString reslistformat;
string creslistformat; string creslistformat;
QString reslistheadertext;
// Abstract snippet separator // Abstract snippet separator
QString abssep; QString abssep;
// Date strftime format // Date strftime format

View File

@ -1726,12 +1726,7 @@ void RclMain::setUIPrefs()
if (!uiprefs) if (!uiprefs)
return; return;
LOGDEB(("Recollmain::setUIPrefs\n")); LOGDEB(("Recollmain::setUIPrefs\n"));
if (prefs.reslistfontfamily.length()) { reslist->setFont();
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
reslist->setFont(nfont);
} else {
reslist->setFont(this->font());
}
} }
void RclMain::enableNextPage(bool yesno) void RclMain::enableNextPage(bool yesno)

View File

@ -1,6 +1,9 @@
TEMPLATE = app TEMPLATE = app
LANGUAGE = C++ LANGUAGE = C++
@QMAKE_ENABLE_WEBKIT@QT += webkit
@QMAKE_DISABLE_WEBKIT@QMAKE_CXXFLAGS += -DRESLIST_TEXTBROWSER
CONFIG += qt warn_on thread release CONFIG += qt warn_on thread release
HEADERS += \ HEADERS += \
@ -8,6 +11,7 @@ HEADERS += \
confgui/confgui.h \ confgui/confgui.h \
confgui/confguiindex.h \ confgui/confguiindex.h \
crontool.h \ crontool.h \
editdialog.h \
firstidx.h \ firstidx.h \
idxsched.h \ idxsched.h \
listdialog.h \ listdialog.h \
@ -48,6 +52,7 @@ SOURCES += \
FORMS = \ FORMS = \
advsearch.ui \ advsearch.ui \
crontool.ui \ crontool.ui \
editdialog.ui \
firstidx.ui \ firstidx.ui \
idxsched.ui \ idxsched.ui \
listdialog.ui \ listdialog.ui \

View File

@ -62,6 +62,12 @@
#define MIN(A,B) ((A) < (B) ? (A) : (B)) #define MIN(A,B) ((A) < (B) ? (A) : (B))
#endif #endif
#ifndef RESLIST_TEXTBROWSER
#include <QWebFrame>
#include <QWebElement>
#include <QWebSettings>
#endif
class QtGuiResListPager : public ResListPager { class QtGuiResListPager : public ResListPager {
public: public:
QtGuiResListPager(ResList *p, int ps) QtGuiResListPager(ResList *p, int ps)
@ -75,7 +81,7 @@ public:
virtual const string &dateFormat(); virtual const string &dateFormat();
virtual string nextUrl(); virtual string nextUrl();
virtual string prevUrl(); virtual string prevUrl();
virtual string pageTop(); virtual string headerContent();
virtual void suggest(const vector<string>uterms, virtual void suggest(const vector<string>uterms,
map<string, vector<string> >& sugg); map<string, vector<string> >& sugg);
virtual string absSep() {return (const char *)(prefs.abssep.toUtf8());} virtual string absSep() {return (const char *)(prefs.abssep.toUtf8());}
@ -113,6 +119,7 @@ bool QtGuiResListPager::append(const string& data, int docnum,
LOGDEB2(("QtGuiReslistPager::appendDoc: blockCount %d, %s\n", LOGDEB2(("QtGuiReslistPager::appendDoc: blockCount %d, %s\n",
m_parent->document()->blockCount(), data.c_str())); m_parent->document()->blockCount(), data.c_str()));
logdata(data.c_str()); logdata(data.c_str());
#ifdef RESLIST_TEXTBROWSER
int blkcnt0 = m_parent->document()->blockCount(); int blkcnt0 = m_parent->document()->blockCount();
m_parent->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); m_parent->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
m_parent->textCursor().insertBlock(); m_parent->textCursor().insertBlock();
@ -123,6 +130,12 @@ bool QtGuiResListPager::append(const string& data, int docnum,
for (int block = blkcnt0; block < blkcnt1; block++) { for (int block = blkcnt0; block < blkcnt1; block++) {
m_parent->m_pageParaToReldocnums[block] = docnum; m_parent->m_pageParaToReldocnums[block] = docnum;
} }
#else
QString sdoc = QString("<div rcldocnum=\"%1\">").arg(docnum);
m_parent->append(sdoc);
m_parent->append(QString::fromUtf8(data.c_str()));
m_parent->append("</div>");
#endif
return true; return true;
} }
@ -158,12 +171,11 @@ string QtGuiResListPager::prevUrl()
return "p-1"; return "p-1";
} }
string QtGuiResListPager::pageTop() string QtGuiResListPager::headerContent()
{ {
return string(); return (const char *)prefs.reslistheadertext.toUtf8();
} }
void QtGuiResListPager::suggest(const vector<string>uterms, void QtGuiResListPager::suggest(const vector<string>uterms,
map<string, vector<string> >& sugg) map<string, vector<string> >& sugg)
{ {
@ -233,7 +245,7 @@ class PlainToRichQtReslist : public PlainToRich {
public: public:
virtual ~PlainToRichQtReslist() {} virtual ~PlainToRichQtReslist() {}
virtual string startMatch() { virtual string startMatch() {
return string("<span style='color: ") return string("<span class='rclmatch' style='color: ")
+ string((const char *)prefs.qtermcolor.toAscii()) + string("'>"); + string((const char *)prefs.qtermcolor.toAscii()) + string("'>");
} }
virtual string endMatch() {return string("</span>");} virtual string endMatch() {return string("</span>");}
@ -243,26 +255,35 @@ static PlainToRichQtReslist g_hiliter;
///////////////////////////////////// /////////////////////////////////////
ResList::ResList(QWidget* parent, const char* name) ResList::ResList(QWidget* parent, const char* name)
: QTextBrowser(parent) : RESLIST_PARENTCLASS(parent)
{ {
if (!name) if (!name)
setObjectName("resList"); setObjectName("resList");
else else
setObjectName(name); setObjectName(name);
#ifdef RESLIST_TEXTBROWSER
LOGDEB(("Reslist: using QTextBrowser\n"));
setReadOnly(TRUE); setReadOnly(TRUE);
setUndoRedoEnabled(FALSE); setUndoRedoEnabled(FALSE);
setOpenLinks(FALSE); setOpenLinks(FALSE);
languageChange();
setTabChangesFocus(true); 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);
#endif
setFont();
languageChange();
(void)new HelpClient(this); (void)new HelpClient(this);
HelpClient::installMap((const char *)this->objectName().toAscii(), HelpClient::installMap((const char *)this->objectName().toAscii(),
"RCL.SEARCH.RESLIST"); "RCL.SEARCH.RESLIST");
// signals and slots connections
connect(this, SIGNAL(anchorClicked(const QUrl &)),
this, SLOT(linkWasClicked(const QUrl &)));
#if 0 #if 0
// See comments in "highlighted // See comments in "highlighted
connect(this, SIGNAL(highlighted(const QString &)), connect(this, SIGNAL(highlighted(const QString &)),
@ -277,10 +298,6 @@ ResList::ResList(QWidget* parent, const char* name)
m_listId = 0; m_listId = 0;
m_pager = new QtGuiResListPager(this, prefs.respagesize); m_pager = new QtGuiResListPager(this, prefs.respagesize);
m_pager->setHighLighter(&g_hiliter); m_pager->setHighLighter(&g_hiliter);
if (prefs.reslistfontfamily.length()) {
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
setFont(nfont);
}
} }
ResList::~ResList() ResList::~ResList()
@ -304,6 +321,29 @@ ResList::~ResList()
}; };
} }
void ResList::setFont()
{
#ifdef RESLIST_TEXTBROWSER
if (prefs.reslistfontfamily.length()) {
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
QTextBrowser::setFont(nfont);
} else {
QTextBrowser::setFont(QFont());
}
#else
QWebSettings *websettings = settings();
if (prefs.reslistfontfamily.length()) {
websettings->setFontSize(QWebSettings::DefaultFontSize,
prefs.reslistfontsize);
websettings->setFontFamily(QWebSettings::StandardFont,
prefs.reslistfontfamily);
} else {
websettings->resetFontSize(QWebSettings::DefaultFontSize);
websettings->resetFontFamily(QWebSettings::StandardFont);
}
#endif
}
int ResList::newListId() int ResList::newListId()
{ {
static int id; static int id;
@ -350,12 +390,19 @@ 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
m_pageParaToReldocnums.clear();
clear(); clear();
QTextBrowser::append("."); QTextBrowser::append(".");
clear(); clear();
#ifndef __APPLE__ #ifndef __APPLE__
XFlush(QX11Info::display()); XFlush(QX11Info::display());
#endif #endif
#else
m_text = "";
setHtml("<html><body></body></html>");
#endif
} }
bool ResList::displayingHistory() bool ResList::displayingHistory()
@ -373,6 +420,7 @@ void ResList::languageChange()
setWindowTitle(tr("Result list")); setWindowTitle(tr("Result list"));
} }
#ifdef RESLIST_TEXTBROWSER
// Get document number from text block number // Get document number from text block number
int ResList::docnumfromparnum(int block) int ResList::docnumfromparnum(int block)
{ {
@ -390,7 +438,7 @@ int ResList::docnumfromparnum(int block)
return -1; return -1;
} }
// Get paragraph number from document number // Get range of paragraph numbers which make up the result for document number
pair<int,int> ResList::parnumfromdocnum(int docnum) pair<int,int> ResList::parnumfromdocnum(int docnum)
{ {
LOGDEB(("parnumfromdocnum: docnum %d\n", docnum)); LOGDEB(("parnumfromdocnum: docnum %d\n", docnum));
@ -422,6 +470,7 @@ pair<int,int> ResList::parnumfromdocnum(int docnum)
LOGDEB(("parnumfromdocnum: not found return -1,-1\n")); LOGDEB(("parnumfromdocnum: not found return -1,-1\n"));
return pair<int,int>(-1,-1); return pair<int,int>(-1,-1);
} }
#endif // TEXTBROWSER
// Return doc from current or adjacent result pages. We can get called // Return doc from current or adjacent result pages. We can get called
// for a document not in the current page if the user browses through // for a document not in the current page if the user browses through
@ -464,7 +513,7 @@ void ResList::keyPressEvent(QKeyEvent * e)
resPageDownOrNext(); resPageDownOrNext();
return; return;
} }
QTextBrowser::keyPressEvent(e); RESLIST_PARENTCLASS::keyPressEvent(e);
} }
void ResList::mouseReleaseEvent(QMouseEvent *e) void ResList::mouseReleaseEvent(QMouseEvent *e)
@ -476,7 +525,7 @@ void ResList::mouseReleaseEvent(QMouseEvent *e)
if (e->modifiers() & Qt::ShiftModifier) { if (e->modifiers() & Qt::ShiftModifier) {
m_lstClckMod |= Qt::ShiftModifier; m_lstClckMod |= Qt::ShiftModifier;
} }
QTextBrowser::mouseReleaseEvent(e); RESLIST_PARENTCLASS::mouseReleaseEvent(e);
} }
void ResList::highlighted(const QString& ) void ResList::highlighted(const QString& )
@ -491,20 +540,38 @@ 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
int vpos = verticalScrollBar()->value(); int vpos = verticalScrollBar()->value();
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub); verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
if (vpos == verticalScrollBar()->value()) if (vpos == verticalScrollBar()->value())
resultPageBack(); resultPageBack();
#else
QWebFrame *frame = page()->mainFrame();
int vpos = frame->scrollBarValue(Qt::Vertical);
if (vpos != frame->scrollBarMinimum(Qt::Vertical))
frame->scroll(0, -int(0.9*geometry().height()));
else
resultPageBack();
#endif
} }
void ResList::resPageDownOrNext() void ResList::resPageDownOrNext()
{ {
#ifdef RESLIST_TEXTBROWSER
int vpos = verticalScrollBar()->value(); int vpos = verticalScrollBar()->value();
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd); verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
LOGDEB(("ResList::resPageDownOrNext: vpos before %d, after %d\n", LOGDEB(("ResList::resPageDownOrNext: vpos before %d, after %d\n",
vpos, verticalScrollBar()->value())); vpos, verticalScrollBar()->value()));
if (vpos == verticalScrollBar()->value()) if (vpos == verticalScrollBar()->value())
resultPageNext(); resultPageNext();
#else
QWebFrame *frame = page()->mainFrame();
int vpos = frame->scrollBarValue(Qt::Vertical);
if (vpos != frame->scrollBarMaximum(Qt::Vertical))
frame->scroll(0, int(0.9*geometry().height()));
else
resultPageNext();
#endif
} }
// Show previous page of results. We just set the current number back // Show previous page of results. We just set the current number back
@ -528,7 +595,11 @@ void ResList::append(const QString &text)
{ {
LOGDEB2(("QtGuiReslistPager::appendQString : %s\n", LOGDEB2(("QtGuiReslistPager::appendQString : %s\n",
(const char*)text.toUtf8())); (const char*)text.toUtf8()));
#ifdef RESLIST_TEXTBROWSER
QTextBrowser::append(text); QTextBrowser::append(text);
#else
m_text += text;
#endif
} }
// Fill up result list window with next screen of hits // Fill up result list window with next screen of hits
@ -546,16 +617,22 @@ void ResList::resultPageFor(int docnum)
void ResList::displayPage() void ResList::displayPage()
{ {
m_pageParaToReldocnums.clear(); resetView();
clear();
m_pager->displayPage(theconfig); m_pager->displayPage(theconfig);
#ifndef RESLIST_TEXTBROWSER
setHtml(m_text);
#endif
LOGDEB0(("ResList::resultPageNext: hasNext %d hasPrev %d\n", LOGDEB0(("ResList::resultPageNext: hasNext %d hasPrev %d\n",
m_pager->hasPrev(), m_pager->hasNext())); m_pager->hasPrev(), m_pager->hasNext()));
emit prevPageAvailable(m_pager->hasPrev()); emit prevPageAvailable(m_pager->hasPrev());
emit nextPageAvailable(m_pager->hasNext()); emit nextPageAvailable(m_pager->hasNext());
// Possibly color paragraph of current preview if any // Possibly color paragraph of current preview if any
previewExposed(m_curPvDoc); previewExposed(m_curPvDoc);
ensureCursorVisible();
} }
// Color paragraph (if any) of currently visible preview // Color paragraph (if any) of currently visible preview
@ -564,9 +641,9 @@ void ResList::previewExposed(int docnum)
LOGDEB(("ResList::previewExposed: doc %d\n", docnum)); LOGDEB(("ResList::previewExposed: doc %d\n", docnum));
// Possibly erase old one to white // Possibly erase old one to white
pair<int,int> blockrange;
if (m_curPvDoc != -1) { if (m_curPvDoc != -1) {
blockrange = parnumfromdocnum(m_curPvDoc); #ifdef RESLIST_TEXTBROWSER
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;
blockn < blockrange.second; blockn++) { blockn < blockrange.second; blockn++) {
@ -577,17 +654,31 @@ 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: [%s]\n",
(const char *)sel.toAscii()));
QWebElement elt = page()->mainFrame()->findFirstElement(sel);
if (!elt.isNull()) {
LOGDEB2(("Found\n"));
elt.removeAttribute("style");
} else {
LOGDEB2(("Not Found\n"));
}
#endif
m_curPvDoc = -1; m_curPvDoc = -1;
} }
// Set background for active preview's doc entry // Set background for active preview's doc entry
m_curPvDoc = docnum; m_curPvDoc = docnum;
blockrange = parnumfromdocnum(docnum);
#ifdef RESLIST_TEXTBROWSER
pair<int,int> blockrange = parnumfromdocnum(docnum);
// Maybe docnum is -1 or not in this window, // Maybe docnum is -1 or not in this window,
if (blockrange.first < 0) if (blockrange.first < 0)
return; return;
// Color the new active paragraph // Color the new active paragraph
QColor color("LightBlue"); QColor color("LightBlue");
for (int blockn = blockrange.first+1; for (int blockn = blockrange.first+1;
@ -600,14 +691,31 @@ 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: [%s]\n",
(const char *)sel.toAscii()));
QWebElement elt = page()->mainFrame()->findFirstElement(sel);
if (!elt.isNull()) {
LOGDEB2(("Found\n"));
elt.setAttribute("style", "background: LightBlue;}");
} else {
LOGDEB2(("Not Found\n"));
}
#endif
} }
// Double click in res list: add selection to simple search // Double click in res list: add selection to simple search
void ResList::mouseDoubleClickEvent(QMouseEvent *event) void ResList::mouseDoubleClickEvent(QMouseEvent *event)
{ {
QTextBrowser::mouseDoubleClickEvent(event); RESLIST_PARENTCLASS::mouseDoubleClickEvent(event);
#ifdef RESLIST_TEXTBROWSER
if (textCursor().hasSelection()) if (textCursor().hasSelection())
emit(wordSelect(textCursor().selectedText())); emit(wordSelect(textCursor().selectedText()));
#else
emit(wordSelect(selectedText()));
#endif
} }
void ResList::linkWasClicked(const QUrl &url) void ResList::linkWasClicked(const QUrl &url)
@ -663,10 +771,23 @@ void ResList::linkWasClicked(const QUrl &url)
void ResList::createPopupMenu(const QPoint& pos) void ResList::createPopupMenu(const QPoint& pos)
{ {
LOGDEB(("ResList::createPopupMenu(%d, %d)\n", pos.x(), pos.y())); LOGDEB(("ResList::createPopupMenu(%d, %d)\n", pos.x(), pos.y()));
#ifdef RESLIST_TEXTBROWSER
QTextCursor cursor = cursorForPosition(pos); QTextCursor cursor = cursorForPosition(pos);
int blocknum = cursor.blockNumber(); int blocknum = cursor.blockNumber();
LOGDEB(("ResList::createPopupMenu(): block %d\n", blocknum)); LOGDEB(("ResList::createPopupMenu(): block %d\n", blocknum));
m_popDoc = docnumfromparnum(blocknum); 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) if (m_popDoc < 0)
return; return;

View File

@ -26,8 +26,13 @@ using std::list;
using std::pair; using std::pair;
#endif #endif
#include <qtextbrowser.h> #ifdef RESLIST_TEXTBROWSER
#include <QTextCursor> #include <QTextBrowser>
#define RESLIST_PARENTCLASS QTextBrowser
#else
#include <QtWebKit/QWebView>
#define RESLIST_PARENTCLASS QWebView
#endif
#include "docseq.h" #include "docseq.h"
#include "sortseq.h" #include "sortseq.h"
@ -36,20 +41,13 @@ using std::pair;
#include "rcldoc.h" #include "rcldoc.h"
#include "reslistpager.h" #include "reslistpager.h"
class ResList;
class QtGuiResListPager; class QtGuiResListPager;
class QMenu;
/** /**
* 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
* manager or from an index query, both abstracted as a DocSequence. * manager or from an index query, both abstracted as a DocSequence.
* Sorting and filtering are applied by stacking Sort/Filter DocSequences.
* This is nice because history and index result are handled the same, but
* not nice because we can't use the sort/filter capabilities in the index
* engine, and do it instead on the index output, which duplicates code and
* may be sometimes slower.
*/ */
class ResList : public QTextBrowser class ResList : public RESLIST_PARENTCLASS
{ {
Q_OBJECT; Q_OBJECT;
@ -67,6 +65,7 @@ class ResList : public QTextBrowser
bool displayingHistory(); bool displayingHistory();
int listId() const {return m_listId;} int listId() const {return m_listId;}
int pageFirstDocNum(); int pageFirstDocNum();
void setFont();
public slots: public slots:
virtual void setDocSource(RefCntr<DocSequence> nsource); virtual void setDocSource(RefCntr<DocSequence> nsource);
@ -77,7 +76,6 @@ class ResList : public QTextBrowser
virtual void resultPageFirst(); // First page of results virtual void resultPageFirst(); // First page of results
virtual void resultPageNext(); // Next (or first) page of results virtual void resultPageNext(); // Next (or first) page of results
virtual void resultPageFor(int docnum); // Page containing docnum virtual void resultPageFor(int docnum); // Page containing docnum
virtual void displayPage(); // Display current page
virtual void menuPreview(); virtual void menuPreview();
virtual void menuSaveToFile(); virtual void menuSaveToFile();
virtual void menuEdit(); virtual void menuEdit();
@ -104,7 +102,6 @@ class ResList : public QTextBrowser
void docExpand(Rcl::Doc); void docExpand(Rcl::Doc);
void wordSelect(QString); void wordSelect(QString);
void wordReplace(const QString&, const QString&); void wordReplace(const QString&, const QString&);
void linkClicked(const QString&, int); // See emitLinkClicked()
void hasResults(int); void hasResults(int);
protected: protected:
@ -119,24 +116,22 @@ class ResList : public QTextBrowser
private: private:
QtGuiResListPager *m_pager; QtGuiResListPager *m_pager;
RefCntr<DocSequence> m_source; RefCntr<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
#ifdef RESLIST_TEXTBROWSER
// 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;
int m_popDoc; // Docnum for the popup menu.
int m_curPvDoc;// Docnum for current preview
int m_lstClckMod; // Last click modifier.
list<int> m_selDocs;
int m_listId; // query Id for matching with preview windows
virtual int docnumfromparnum(int); virtual int docnumfromparnum(int);
virtual pair<int,int> parnumfromdocnum(int); virtual pair<int,int> parnumfromdocnum(int);
#else
QString m_text; // webview doesn't take text incrementally, store it.
#endif
// Don't know why this is necessary but it is virtual void displayPage(); // Display current page
void emitLinkClicked(const QString &s) {
emit linkClicked(s, m_lstClckMod);
};
static int newListId(); static int newListId();
void resetView(); void resetView();
}; };

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>531</width> <width>531</width>
<height>446</height> <height>422</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -296,48 +296,21 @@
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<item> <item>
<widget class="QLabel" name="textLabel1_4"> <widget class="QCommandLinkButton" name="CLEditPara">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Defines the format for each result list paragraph. Use qt html format and printf-like replacements:&lt;br&gt;%A Abstract&lt;br&gt; %D Date&lt;br&gt; %I Icon image name&lt;br&gt; %K Keywords (if any)&lt;br&gt; %L Preview and Edit links&lt;br&gt; %M Mime type&lt;br&gt; %N Result number&lt;br&gt; %R Relevance percentage&lt;br&gt; %S Size information&lt;br&gt; %T Title&lt;br&gt; %U Url&lt;br&gt; Go to http://www.recoll.org/custom.html for examples.</string>
</property>
<property name="text"> <property name="text">
<string>Result paragraph&lt;br&gt;format string</string> <string>Edit result paragraph format string</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="rlfTE">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
<property name="text" stdset="0">
<string/>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCommandLinkButton" name="CLEditHeader">
<property name="text">
<string>Edit result page html header text insert</string>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<item> <item>
@ -388,6 +361,19 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab1"> <widget class="QWidget" name="tab1">

View File

@ -49,6 +49,7 @@
#include "uiprefs_w.h" #include "uiprefs_w.h"
#include "viewaction_w.h" #include "viewaction_w.h"
#include "debuglog.h" #include "debuglog.h"
#include "editdialog.h"
void UIPrefsDialog::init() void UIPrefsDialog::init()
{ {
@ -70,7 +71,8 @@ void UIPrefsDialog::init()
this, SLOT(actAllExtraDbPB_clicked())); this, SLOT(actAllExtraDbPB_clicked()));
connect(unacAllExtraDbPB, SIGNAL(clicked()), connect(unacAllExtraDbPB, SIGNAL(clicked()),
this, SLOT(unacAllExtraDbPB_clicked())); this, SLOT(unacAllExtraDbPB_clicked()));
connect(CLEditPara, SIGNAL(clicked()), this, SLOT(editParaFormat()));
connect(CLEditHeader, SIGNAL(clicked()), this, SLOT(editHeaderText()));
connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(buildAbsCB, SIGNAL(toggled(bool)), connect(buildAbsCB, SIGNAL(toggled(bool)),
@ -129,7 +131,8 @@ void UIPrefsDialog::setFromPrefs()
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str())); stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
} }
rlfTE->setPlainText(prefs.reslistformat); paraFormat = prefs.reslistformat;
headerText = prefs.reslistheadertext;
// Stemming language combobox // Stemming language combobox
stemLangCMB->clear(); stemLangCMB->clear();
@ -201,10 +204,11 @@ void UIPrefsDialog::accept()
prefs.reslistfontfamily = reslistFontFamily; prefs.reslistfontfamily = reslistFontFamily;
prefs.reslistfontsize = reslistFontSize; prefs.reslistfontsize = reslistFontSize;
prefs.stylesheetFile = stylesheetFile; prefs.stylesheetFile = stylesheetFile;
prefs.reslistformat = rlfTE->toPlainText(); prefs.reslistformat = paraFormat;
prefs.reslistheadertext = headerText;
if (prefs.reslistformat.trimmed().isEmpty()) { if (prefs.reslistformat.trimmed().isEmpty()) {
prefs.reslistformat = prefs.dfltResListFormat; prefs.reslistformat = prefs.dfltResListFormat;
rlfTE->setPlainText(prefs.reslistformat); paraFormat = prefs.reslistformat;
} }
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8(); prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
@ -255,6 +259,23 @@ void UIPrefsDialog::accept()
QDialog::accept(); QDialog::accept();
} }
void UIPrefsDialog::editParaFormat()
{
EditDialog dialog(this);
dialog.plainTextEdit->setPlainText(paraFormat);
int result = dialog.exec();
if (result == QDialog::Accepted)
paraFormat = dialog.plainTextEdit->toPlainText();
}
void UIPrefsDialog::editHeaderText()
{
EditDialog dialog(this);
dialog.plainTextEdit->setPlainText(headerText);
int result = dialog.exec();
if (result == QDialog::Accepted)
headerText = dialog.plainTextEdit->toPlainText();
}
void UIPrefsDialog::reject() void UIPrefsDialog::reject()
{ {
setFromPrefs(); setFromPrefs();
@ -292,16 +313,18 @@ void UIPrefsDialog::showFontDialog()
if (ok) { if (ok) {
// Check if the default font was set, in which case we // Check if the default font was set, in which case we
// erase the preference // erase the preference
QString s;
if (font.family().compare(this->font().family()) || if (font.family().compare(this->font().family()) ||
font.pointSize() != this->font().pointSize()) { font.pointSize() != this->font().pointSize()) {
reslistFontFamily = font.family(); reslistFontFamily = font.family();
reslistFontSize = font.pointSize(); reslistFontSize = font.pointSize();
QString s;
reslistFontPB->setText(reslistFontFamily + "-" + reslistFontPB->setText(reslistFontFamily + "-" +
s.setNum(reslistFontSize)); s.setNum(reslistFontSize));
} else { } else {
reslistFontFamily = ""; reslistFontFamily = "";
reslistFontSize = 0; reslistFontSize = 0;
reslistFontPB->setText(this->font().family() + "-" +
s.setNum(this->font().pointSize()));
} }
} }
} }

View File

@ -56,6 +56,8 @@ public slots:
virtual void actAllExtraDbPB_clicked(); virtual void actAllExtraDbPB_clicked();
virtual void unacAllExtraDbPB_clicked(); virtual void unacAllExtraDbPB_clicked();
virtual void setStemLang(const QString& lang); virtual void setStemLang(const QString& lang);
virtual void editParaFormat();
virtual void editHeaderText();
signals: signals:
void uiprefsDone(); void uiprefsDone();
@ -64,6 +66,9 @@ protected slots:
virtual void accept(); virtual void accept();
virtual void reject(); virtual void reject();
private: private:
// Locally stored data (pending ok/cancel)
QString paraFormat;
QString headerText;
void setFromPrefs(); void setFromPrefs();
ViewAction *m_viewAction; ViewAction *m_viewAction;

View File

@ -279,6 +279,7 @@ void ResListPager::displayPage(RclConfig *config)
chunk << "<html><head>" << endl chunk << "<html><head>" << endl
<< "<meta http-equiv=\"content-type\"" << "<meta http-equiv=\"content-type\""
<< " content=\"text/html; charset=utf-8\">" << endl << " content=\"text/html; charset=utf-8\">" << endl
<< headerContent()
<< "</head><body>" << endl << "</head><body>" << endl
<< pageTop() << pageTop()
<< "<p><font size=+1><b>" << "<p><font size=+1><b>"

View File

@ -110,6 +110,7 @@ public:
virtual string nextUrl(); virtual string nextUrl();
virtual string prevUrl(); virtual string prevUrl();
virtual string pageTop() {return string();} virtual string pageTop() {return string();}
virtual string headerContent() {return string();}
virtual string iconUrl(RclConfig *, Rcl::Doc& doc); virtual string iconUrl(RclConfig *, Rcl::Doc& doc);
virtual void suggest(const vector<string>, virtual void suggest(const vector<string>,
map<string, vector<string> >& sugg) { map<string, vector<string> >& sugg) {

View File

@ -40,7 +40,8 @@
/* Use a light yellow background for all text display areas: */ /* Use a light yellow background for all text display areas: */
QComboBox[editable="true"], QTextEdit, QLineEdit, QTextBrowser, QTableView { QComboBox[editable="true"], QTextEdit, QLineEdit, QTextBrowser, QTableView,
QWebView, QPlainTextEdit {
background: #ffffee; background: #ffffee;
} }