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:
parent
7fefaf540f
commit
ea0f4725cb
45
src/configure
vendored
45
src/configure
vendored
@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# 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,
|
||||
@ -557,8 +557,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='Recoll'
|
||||
PACKAGE_TARNAME='recoll'
|
||||
PACKAGE_VERSION='1.16.2'
|
||||
PACKAGE_STRING='Recoll 1.16.2'
|
||||
PACKAGE_VERSION='1.17.0'
|
||||
PACKAGE_STRING='Recoll 1.17.0'
|
||||
PACKAGE_BUGREPORT=''
|
||||
PACKAGE_URL=''
|
||||
|
||||
@ -603,6 +603,8 @@ ac_subst_vars='LTLIBOBJS
|
||||
LIBOBJS
|
||||
RCLVERSION
|
||||
NOPIC
|
||||
QMAKE_DISABLE_WEBKIT
|
||||
QMAKE_ENABLE_WEBKIT
|
||||
NOCMDLINE
|
||||
NOQTMAKE
|
||||
HAVE_MKDTEMP
|
||||
@ -689,6 +691,7 @@ enable_xattr
|
||||
enable_camelcase
|
||||
enable_pic
|
||||
enable_qtgui
|
||||
enable_webkit
|
||||
enable_x11mon
|
||||
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.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
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]...
|
||||
|
||||
@ -1313,7 +1316,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of Recoll 1.16.2:";;
|
||||
short | recursive ) echo "Configuration of Recoll 1.17.0:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@ -1338,6 +1341,7 @@ Optional Features:
|
||||
code. This is necessary for building the php
|
||||
extension.
|
||||
--disable-qtgui Disable the QT-based graphical user interface.
|
||||
--disable-webkit Disable use of qt-webkit.
|
||||
--disable-x11mon Disable recollindex support for X11 session
|
||||
monitoring.
|
||||
|
||||
@ -1436,7 +1440,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
Recoll configure 1.16.2
|
||||
Recoll configure 1.17.0
|
||||
generated by GNU Autoconf 2.68
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
@ -1989,7 +1993,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
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
|
||||
|
||||
$ $0 $@
|
||||
@ -4709,8 +4713,27 @@ $as_echo "$as_me: using qt version 4 user interface" >&6;}
|
||||
fi
|
||||
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"
|
||||
|
||||
|
||||
##################### End QT detection
|
||||
fi
|
||||
|
||||
@ -5566,7 +5589,9 @@ test "X$m_prefix" = "XNONE" && m_prefix=/usr/local
|
||||
m_datadir=${m_prefix}/share
|
||||
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
|
||||
# values after options handling.
|
||||
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
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@ -6189,7 +6214,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
Recoll config.status 1.16.2
|
||||
Recoll config.status 1.17.0
|
||||
configured by $0, generated by GNU Autoconf 2.68,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
||||
@ -404,6 +404,21 @@ else
|
||||
fi
|
||||
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)
|
||||
##################### End QT detection
|
||||
fi
|
||||
@ -458,6 +473,8 @@ AC_SUBST(XAPIANCXXFLAGS)
|
||||
AC_SUBST(HAVE_MKDTEMP)
|
||||
AC_SUBST(NOQTMAKE)
|
||||
AC_SUBST(NOCMDLINE)
|
||||
AC_SUBST(QMAKE_ENABLE_WEBKIT)
|
||||
AC_SUBST(QMAKE_DISABLE_WEBKIT)
|
||||
AC_SUBST(NOPIC)
|
||||
AC_SUBST(RCLVERSION)
|
||||
|
||||
|
||||
35
src/qtgui/editdialog.h
Normal file
35
src/qtgui/editdialog.h
Normal 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
67
src/qtgui/editdialog.ui
Normal 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>
|
||||
@ -157,6 +157,7 @@ void rwSettings(bool writing)
|
||||
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.queryStemLang, "/Recoll/prefs/query/stemLang", String,
|
||||
"english");
|
||||
|
||||
@ -48,6 +48,7 @@ class PrefsPack {
|
||||
// Result list format string
|
||||
QString reslistformat;
|
||||
string creslistformat;
|
||||
QString reslistheadertext;
|
||||
// Abstract snippet separator
|
||||
QString abssep;
|
||||
// Date strftime format
|
||||
|
||||
@ -1726,12 +1726,7 @@ void RclMain::setUIPrefs()
|
||||
if (!uiprefs)
|
||||
return;
|
||||
LOGDEB(("Recollmain::setUIPrefs\n"));
|
||||
if (prefs.reslistfontfamily.length()) {
|
||||
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||
reslist->setFont(nfont);
|
||||
} else {
|
||||
reslist->setFont(this->font());
|
||||
}
|
||||
reslist->setFont();
|
||||
}
|
||||
|
||||
void RclMain::enableNextPage(bool yesno)
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
TEMPLATE = app
|
||||
LANGUAGE = C++
|
||||
|
||||
@QMAKE_ENABLE_WEBKIT@QT += webkit
|
||||
@QMAKE_DISABLE_WEBKIT@QMAKE_CXXFLAGS += -DRESLIST_TEXTBROWSER
|
||||
|
||||
CONFIG += qt warn_on thread release
|
||||
|
||||
HEADERS += \
|
||||
@ -8,6 +11,7 @@ HEADERS += \
|
||||
confgui/confgui.h \
|
||||
confgui/confguiindex.h \
|
||||
crontool.h \
|
||||
editdialog.h \
|
||||
firstidx.h \
|
||||
idxsched.h \
|
||||
listdialog.h \
|
||||
@ -48,6 +52,7 @@ SOURCES += \
|
||||
FORMS = \
|
||||
advsearch.ui \
|
||||
crontool.ui \
|
||||
editdialog.ui \
|
||||
firstidx.ui \
|
||||
idxsched.ui \
|
||||
listdialog.ui \
|
||||
|
||||
@ -62,6 +62,12 @@
|
||||
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
||||
#endif
|
||||
|
||||
#ifndef RESLIST_TEXTBROWSER
|
||||
#include <QWebFrame>
|
||||
#include <QWebElement>
|
||||
#include <QWebSettings>
|
||||
#endif
|
||||
|
||||
class QtGuiResListPager : public ResListPager {
|
||||
public:
|
||||
QtGuiResListPager(ResList *p, int ps)
|
||||
@ -75,7 +81,7 @@ public:
|
||||
virtual const string &dateFormat();
|
||||
virtual string nextUrl();
|
||||
virtual string prevUrl();
|
||||
virtual string pageTop();
|
||||
virtual string headerContent();
|
||||
virtual void suggest(const vector<string>uterms,
|
||||
map<string, vector<string> >& sugg);
|
||||
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",
|
||||
m_parent->document()->blockCount(), data.c_str()));
|
||||
logdata(data.c_str());
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
int blkcnt0 = m_parent->document()->blockCount();
|
||||
m_parent->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
|
||||
m_parent->textCursor().insertBlock();
|
||||
@ -123,6 +130,12 @@ bool QtGuiResListPager::append(const string& data, int docnum,
|
||||
for (int block = blkcnt0; block < blkcnt1; block++) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -158,12 +171,11 @@ string QtGuiResListPager::prevUrl()
|
||||
return "p-1";
|
||||
}
|
||||
|
||||
string QtGuiResListPager::pageTop()
|
||||
string QtGuiResListPager::headerContent()
|
||||
{
|
||||
return string();
|
||||
return (const char *)prefs.reslistheadertext.toUtf8();
|
||||
}
|
||||
|
||||
|
||||
void QtGuiResListPager::suggest(const vector<string>uterms,
|
||||
map<string, vector<string> >& sugg)
|
||||
{
|
||||
@ -233,7 +245,7 @@ class PlainToRichQtReslist : public PlainToRich {
|
||||
public:
|
||||
virtual ~PlainToRichQtReslist() {}
|
||||
virtual string startMatch() {
|
||||
return string("<span style='color: ")
|
||||
return string("<span class='rclmatch' style='color: ")
|
||||
+ string((const char *)prefs.qtermcolor.toAscii()) + string("'>");
|
||||
}
|
||||
virtual string endMatch() {return string("</span>");}
|
||||
@ -243,26 +255,35 @@ static PlainToRichQtReslist g_hiliter;
|
||||
/////////////////////////////////////
|
||||
|
||||
ResList::ResList(QWidget* parent, const char* name)
|
||||
: QTextBrowser(parent)
|
||||
: RESLIST_PARENTCLASS(parent)
|
||||
{
|
||||
if (!name)
|
||||
setObjectName("resList");
|
||||
else
|
||||
setObjectName(name);
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
LOGDEB(("Reslist: using QTextBrowser\n"));
|
||||
setReadOnly(TRUE);
|
||||
setUndoRedoEnabled(FALSE);
|
||||
setOpenLinks(FALSE);
|
||||
languageChange();
|
||||
|
||||
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);
|
||||
HelpClient::installMap((const char *)this->objectName().toAscii(),
|
||||
"RCL.SEARCH.RESLIST");
|
||||
|
||||
// signals and slots connections
|
||||
connect(this, SIGNAL(anchorClicked(const QUrl &)),
|
||||
this, SLOT(linkWasClicked(const QUrl &)));
|
||||
#if 0
|
||||
// See comments in "highlighted
|
||||
connect(this, SIGNAL(highlighted(const QString &)),
|
||||
@ -277,10 +298,6 @@ ResList::ResList(QWidget* parent, const char* name)
|
||||
m_listId = 0;
|
||||
m_pager = new QtGuiResListPager(this, prefs.respagesize);
|
||||
m_pager->setHighLighter(&g_hiliter);
|
||||
if (prefs.reslistfontfamily.length()) {
|
||||
QFont nfont(prefs.reslistfontfamily, prefs.reslistfontsize);
|
||||
setFont(nfont);
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
static int id;
|
||||
@ -350,12 +390,19 @@ 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
|
||||
m_pageParaToReldocnums.clear();
|
||||
clear();
|
||||
QTextBrowser::append(".");
|
||||
clear();
|
||||
#ifndef __APPLE__
|
||||
XFlush(QX11Info::display());
|
||||
#endif
|
||||
#else
|
||||
m_text = "";
|
||||
setHtml("<html><body></body></html>");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
bool ResList::displayingHistory()
|
||||
@ -373,6 +420,7 @@ void ResList::languageChange()
|
||||
setWindowTitle(tr("Result list"));
|
||||
}
|
||||
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
// Get document number from text block number
|
||||
int ResList::docnumfromparnum(int block)
|
||||
{
|
||||
@ -390,7 +438,7 @@ int ResList::docnumfromparnum(int block)
|
||||
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)
|
||||
{
|
||||
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"));
|
||||
return pair<int,int>(-1,-1);
|
||||
}
|
||||
#endif // TEXTBROWSER
|
||||
|
||||
// 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
|
||||
@ -464,7 +513,7 @@ void ResList::keyPressEvent(QKeyEvent * e)
|
||||
resPageDownOrNext();
|
||||
return;
|
||||
}
|
||||
QTextBrowser::keyPressEvent(e);
|
||||
RESLIST_PARENTCLASS::keyPressEvent(e);
|
||||
}
|
||||
|
||||
void ResList::mouseReleaseEvent(QMouseEvent *e)
|
||||
@ -476,7 +525,7 @@ void ResList::mouseReleaseEvent(QMouseEvent *e)
|
||||
if (e->modifiers() & Qt::ShiftModifier) {
|
||||
m_lstClckMod |= Qt::ShiftModifier;
|
||||
}
|
||||
QTextBrowser::mouseReleaseEvent(e);
|
||||
RESLIST_PARENTCLASS::mouseReleaseEvent(e);
|
||||
}
|
||||
|
||||
void ResList::highlighted(const QString& )
|
||||
@ -491,20 +540,38 @@ 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
|
||||
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()
|
||||
{
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
int vpos = verticalScrollBar()->value();
|
||||
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
|
||||
LOGDEB(("ResList::resPageDownOrNext: vpos before %d, after %d\n",
|
||||
vpos, verticalScrollBar()->value()));
|
||||
if (vpos == verticalScrollBar()->value())
|
||||
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
|
||||
@ -528,7 +595,11 @@ void ResList::append(const QString &text)
|
||||
{
|
||||
LOGDEB2(("QtGuiReslistPager::appendQString : %s\n",
|
||||
(const char*)text.toUtf8()));
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
QTextBrowser::append(text);
|
||||
#else
|
||||
m_text += text;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Fill up result list window with next screen of hits
|
||||
@ -546,16 +617,22 @@ void ResList::resultPageFor(int docnum)
|
||||
|
||||
void ResList::displayPage()
|
||||
{
|
||||
m_pageParaToReldocnums.clear();
|
||||
clear();
|
||||
resetView();
|
||||
|
||||
m_pager->displayPage(theconfig);
|
||||
|
||||
#ifndef RESLIST_TEXTBROWSER
|
||||
setHtml(m_text);
|
||||
#endif
|
||||
|
||||
LOGDEB0(("ResList::resultPageNext: hasNext %d hasPrev %d\n",
|
||||
m_pager->hasPrev(), m_pager->hasNext()));
|
||||
emit prevPageAvailable(m_pager->hasPrev());
|
||||
emit nextPageAvailable(m_pager->hasNext());
|
||||
|
||||
// Possibly color paragraph of current preview if any
|
||||
previewExposed(m_curPvDoc);
|
||||
ensureCursorVisible();
|
||||
|
||||
}
|
||||
|
||||
// Color paragraph (if any) of currently visible preview
|
||||
@ -564,9 +641,9 @@ void ResList::previewExposed(int docnum)
|
||||
LOGDEB(("ResList::previewExposed: doc %d\n", docnum));
|
||||
|
||||
// Possibly erase old one to white
|
||||
pair<int,int> blockrange;
|
||||
if (m_curPvDoc != -1) {
|
||||
blockrange = parnumfromdocnum(m_curPvDoc);
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
pair<int,int> blockrange = parnumfromdocnum(m_curPvDoc);
|
||||
if (blockrange.first != -1) {
|
||||
for (int blockn = blockrange.first;
|
||||
blockn < blockrange.second; blockn++) {
|
||||
@ -577,17 +654,31 @@ void ResList::previewExposed(int docnum)
|
||||
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;
|
||||
}
|
||||
|
||||
// Set background for active preview's doc entry
|
||||
m_curPvDoc = docnum;
|
||||
blockrange = parnumfromdocnum(docnum);
|
||||
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
pair<int,int> blockrange = parnumfromdocnum(docnum);
|
||||
|
||||
// Maybe docnum is -1 or not in this window,
|
||||
if (blockrange.first < 0)
|
||||
return;
|
||||
|
||||
// Color the new active paragraph
|
||||
QColor color("LightBlue");
|
||||
for (int blockn = blockrange.first+1;
|
||||
@ -600,14 +691,31 @@ void ResList::previewExposed(int docnum)
|
||||
setTextCursor(cursor);
|
||||
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
|
||||
void ResList::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
QTextBrowser::mouseDoubleClickEvent(event);
|
||||
RESLIST_PARENTCLASS::mouseDoubleClickEvent(event);
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
if (textCursor().hasSelection())
|
||||
emit(wordSelect(textCursor().selectedText()));
|
||||
#else
|
||||
emit(wordSelect(selectedText()));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ResList::linkWasClicked(const QUrl &url)
|
||||
@ -663,10 +771,23 @@ void ResList::linkWasClicked(const QUrl &url)
|
||||
void ResList::createPopupMenu(const QPoint& pos)
|
||||
{
|
||||
LOGDEB(("ResList::createPopupMenu(%d, %d)\n", pos.x(), pos.y()));
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
QTextCursor cursor = cursorForPosition(pos);
|
||||
int blocknum = cursor.blockNumber();
|
||||
LOGDEB(("ResList::createPopupMenu(): block %d\n", 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)
|
||||
return;
|
||||
|
||||
@ -26,8 +26,13 @@ using std::list;
|
||||
using std::pair;
|
||||
#endif
|
||||
|
||||
#include <qtextbrowser.h>
|
||||
#include <QTextCursor>
|
||||
#ifdef RESLIST_TEXTBROWSER
|
||||
#include <QTextBrowser>
|
||||
#define RESLIST_PARENTCLASS QTextBrowser
|
||||
#else
|
||||
#include <QtWebKit/QWebView>
|
||||
#define RESLIST_PARENTCLASS QWebView
|
||||
#endif
|
||||
|
||||
#include "docseq.h"
|
||||
#include "sortseq.h"
|
||||
@ -36,20 +41,13 @@ using std::pair;
|
||||
#include "rcldoc.h"
|
||||
#include "reslistpager.h"
|
||||
|
||||
class ResList;
|
||||
class QtGuiResListPager;
|
||||
class QMenu;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
|
||||
@ -67,6 +65,7 @@ class ResList : public QTextBrowser
|
||||
bool displayingHistory();
|
||||
int listId() const {return m_listId;}
|
||||
int pageFirstDocNum();
|
||||
void setFont();
|
||||
|
||||
public slots:
|
||||
virtual void setDocSource(RefCntr<DocSequence> nsource);
|
||||
@ -77,7 +76,6 @@ class ResList : public QTextBrowser
|
||||
virtual void resultPageFirst(); // First page of results
|
||||
virtual void resultPageNext(); // Next (or first) page of results
|
||||
virtual void resultPageFor(int docnum); // Page containing docnum
|
||||
virtual void displayPage(); // Display current page
|
||||
virtual void menuPreview();
|
||||
virtual void menuSaveToFile();
|
||||
virtual void menuEdit();
|
||||
@ -104,7 +102,6 @@ class ResList : public QTextBrowser
|
||||
void docExpand(Rcl::Doc);
|
||||
void wordSelect(QString);
|
||||
void wordReplace(const QString&, const QString&);
|
||||
void linkClicked(const QString&, int); // See emitLinkClicked()
|
||||
void hasResults(int);
|
||||
|
||||
protected:
|
||||
@ -119,24 +116,22 @@ class ResList : public QTextBrowser
|
||||
private:
|
||||
QtGuiResListPager *m_pager;
|
||||
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
|
||||
// docnum. Built while we insert text into the qtextedit
|
||||
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 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
|
||||
void emitLinkClicked(const QString &s) {
|
||||
emit linkClicked(s, m_lstClckMod);
|
||||
};
|
||||
virtual void displayPage(); // Display current page
|
||||
static int newListId();
|
||||
void resetView();
|
||||
};
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>531</width>
|
||||
<height>446</height>
|
||||
<height>422</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -296,48 +296,21 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel1_4">
|
||||
<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:<br>%A Abstract<br> %D Date<br> %I Icon image name<br> %K Keywords (if any)<br> %L Preview and Edit links<br> %M Mime type<br> %N Result number<br> %R Relevance percentage<br> %S Size information<br> %T Title<br> %U Url<br> Go to http://www.recoll.org/custom.html for examples.</string>
|
||||
</property>
|
||||
<widget class="QCommandLinkButton" name="CLEditPara">
|
||||
<property name="text">
|
||||
<string>Result paragraph<br>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/>
|
||||
<string>Edit result paragraph format string</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCommandLinkButton" name="CLEditHeader">
|
||||
<property name="text">
|
||||
<string>Edit result page html header text insert</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
@ -388,6 +361,19 @@
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab1">
|
||||
|
||||
@ -49,6 +49,7 @@
|
||||
#include "uiprefs_w.h"
|
||||
#include "viewaction_w.h"
|
||||
#include "debuglog.h"
|
||||
#include "editdialog.h"
|
||||
|
||||
void UIPrefsDialog::init()
|
||||
{
|
||||
@ -70,7 +71,8 @@ void UIPrefsDialog::init()
|
||||
this, SLOT(actAllExtraDbPB_clicked()));
|
||||
connect(unacAllExtraDbPB, SIGNAL(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(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
connect(buildAbsCB, SIGNAL(toggled(bool)),
|
||||
@ -129,7 +131,8 @@ void UIPrefsDialog::setFromPrefs()
|
||||
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
||||
}
|
||||
|
||||
rlfTE->setPlainText(prefs.reslistformat);
|
||||
paraFormat = prefs.reslistformat;
|
||||
headerText = prefs.reslistheadertext;
|
||||
|
||||
// Stemming language combobox
|
||||
stemLangCMB->clear();
|
||||
@ -201,10 +204,11 @@ void UIPrefsDialog::accept()
|
||||
prefs.reslistfontfamily = reslistFontFamily;
|
||||
prefs.reslistfontsize = reslistFontSize;
|
||||
prefs.stylesheetFile = stylesheetFile;
|
||||
prefs.reslistformat = rlfTE->toPlainText();
|
||||
prefs.reslistformat = paraFormat;
|
||||
prefs.reslistheadertext = headerText;
|
||||
if (prefs.reslistformat.trimmed().isEmpty()) {
|
||||
prefs.reslistformat = prefs.dfltResListFormat;
|
||||
rlfTE->setPlainText(prefs.reslistformat);
|
||||
paraFormat = prefs.reslistformat;
|
||||
}
|
||||
|
||||
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
|
||||
@ -255,6 +259,23 @@ void UIPrefsDialog::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()
|
||||
{
|
||||
setFromPrefs();
|
||||
@ -292,16 +313,18 @@ void UIPrefsDialog::showFontDialog()
|
||||
if (ok) {
|
||||
// Check if the default font was set, in which case we
|
||||
// erase the preference
|
||||
QString s;
|
||||
if (font.family().compare(this->font().family()) ||
|
||||
font.pointSize() != this->font().pointSize()) {
|
||||
reslistFontFamily = font.family();
|
||||
reslistFontSize = font.pointSize();
|
||||
QString s;
|
||||
reslistFontPB->setText(reslistFontFamily + "-" +
|
||||
s.setNum(reslistFontSize));
|
||||
} else {
|
||||
reslistFontFamily = "";
|
||||
reslistFontSize = 0;
|
||||
reslistFontPB->setText(this->font().family() + "-" +
|
||||
s.setNum(this->font().pointSize()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,6 +56,8 @@ public slots:
|
||||
virtual void actAllExtraDbPB_clicked();
|
||||
virtual void unacAllExtraDbPB_clicked();
|
||||
virtual void setStemLang(const QString& lang);
|
||||
virtual void editParaFormat();
|
||||
virtual void editHeaderText();
|
||||
|
||||
signals:
|
||||
void uiprefsDone();
|
||||
@ -64,6 +66,9 @@ protected slots:
|
||||
virtual void accept();
|
||||
virtual void reject();
|
||||
private:
|
||||
// Locally stored data (pending ok/cancel)
|
||||
QString paraFormat;
|
||||
QString headerText;
|
||||
void setFromPrefs();
|
||||
ViewAction *m_viewAction;
|
||||
|
||||
|
||||
@ -279,6 +279,7 @@ void ResListPager::displayPage(RclConfig *config)
|
||||
chunk << "<html><head>" << endl
|
||||
<< "<meta http-equiv=\"content-type\""
|
||||
<< " content=\"text/html; charset=utf-8\">" << endl
|
||||
<< headerContent()
|
||||
<< "</head><body>" << endl
|
||||
<< pageTop()
|
||||
<< "<p><font size=+1><b>"
|
||||
|
||||
@ -110,6 +110,7 @@ public:
|
||||
virtual string nextUrl();
|
||||
virtual string prevUrl();
|
||||
virtual string pageTop() {return string();}
|
||||
virtual string headerContent() {return string();}
|
||||
virtual string iconUrl(RclConfig *, Rcl::Doc& doc);
|
||||
virtual void suggest(const vector<string>,
|
||||
map<string, vector<string> >& sugg) {
|
||||
|
||||
@ -40,7 +40,8 @@
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user