diff --git a/src/configure b/src/configure index 046e8705..754e8716 100755 --- a/src/configure +++ b/src/configure @@ -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\\" diff --git a/src/configure.ac b/src/configure.ac index fed02539..b4d49ad3 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -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) diff --git a/src/qtgui/editdialog.h b/src/qtgui/editdialog.h new file mode 100644 index 00000000..cac93651 --- /dev/null +++ b/src/qtgui/editdialog.h @@ -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 + +#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 diff --git a/src/qtgui/editdialog.ui b/src/qtgui/editdialog.ui new file mode 100644 index 00000000..edf2e143 --- /dev/null +++ b/src/qtgui/editdialog.ui @@ -0,0 +1,67 @@ + + + EditDialog + + + + 0 + 0 + 614 + 509 + + + + Dialog + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index e9651ba9..b9d6d272 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -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"); diff --git a/src/qtgui/guiutils.h b/src/qtgui/guiutils.h index 93c7f9e7..c1e6df77 100644 --- a/src/qtgui/guiutils.h +++ b/src/qtgui/guiutils.h @@ -48,6 +48,7 @@ class PrefsPack { // Result list format string QString reslistformat; string creslistformat; + QString reslistheadertext; // Abstract snippet separator QString abssep; // Date strftime format diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 6a882584..e3e3e83e 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -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) diff --git a/src/qtgui/recoll.pro.in b/src/qtgui/recoll.pro.in index e2114a05..ca31e854 100644 --- a/src/qtgui/recoll.pro.in +++ b/src/qtgui/recoll.pro.in @@ -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 \ diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index 047dc3f2..b346a173 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -62,6 +62,12 @@ #define MIN(A,B) ((A) < (B) ? (A) : (B)) #endif +#ifndef RESLIST_TEXTBROWSER +#include +#include +#include +#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 vectoruterms, map >& 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("
").arg(docnum); + m_parent->append(sdoc); + m_parent->append(QString::fromUtf8(data.c_str())); + m_parent->append("
"); +#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 vectoruterms, map >& sugg) { @@ -233,7 +245,7 @@ class PlainToRichQtReslist : public PlainToRich { public: virtual ~PlainToRichQtReslist() {} virtual string startMatch() { - return string(""); } virtual string endMatch() {return string("");} @@ -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(""); +#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 ResList::parnumfromdocnum(int docnum) { LOGDEB(("parnumfromdocnum: docnum %d\n", docnum)); @@ -422,6 +470,7 @@ pair ResList::parnumfromdocnum(int docnum) LOGDEB(("parnumfromdocnum: not found return -1,-1\n")); return pair(-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 blockrange; if (m_curPvDoc != -1) { - blockrange = parnumfromdocnum(m_curPvDoc); +#ifdef RESLIST_TEXTBROWSER + pair 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 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; diff --git a/src/qtgui/reslist.h b/src/qtgui/reslist.h index 31f7346f..cb22e681 100644 --- a/src/qtgui/reslist.h +++ b/src/qtgui/reslist.h @@ -26,8 +26,13 @@ using std::list; using std::pair; #endif -#include -#include +#ifdef RESLIST_TEXTBROWSER +#include +#define RESLIST_PARENTCLASS QTextBrowser +#else +#include +#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 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 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 m_pageParaToReldocnums; - - int m_popDoc; // Docnum for the popup menu. - int m_curPvDoc;// Docnum for current preview - int m_lstClckMod; // Last click modifier. - list m_selDocs; - int m_listId; // query Id for matching with preview windows - virtual int docnumfromparnum(int); virtual pair 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(); }; diff --git a/src/qtgui/uiprefs.ui b/src/qtgui/uiprefs.ui index 6fdebd29..137867bb 100644 --- a/src/qtgui/uiprefs.ui +++ b/src/qtgui/uiprefs.ui @@ -7,7 +7,7 @@ 0 0 531 - 446 + 422 @@ -296,48 +296,21 @@ - - - - 0 - 0 - - - - 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. - + - Result paragraph<br>format string - - - false - - - - - - - - 1 - 0 - - - - - 0 - 0 - - - - true - - - + Edit result paragraph format string + + + + Edit result page html header text insert + + + @@ -388,6 +361,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp index ad55f3d1..47d5256b 100644 --- a/src/qtgui/uiprefs_w.cpp +++ b/src/qtgui/uiprefs_w.cpp @@ -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())); } } } diff --git a/src/qtgui/uiprefs_w.h b/src/qtgui/uiprefs_w.h index 3bc8a468..8c17d059 100644 --- a/src/qtgui/uiprefs_w.h +++ b/src/qtgui/uiprefs_w.h @@ -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; diff --git a/src/query/reslistpager.cpp b/src/query/reslistpager.cpp index 06544fac..01f1d3d2 100644 --- a/src/query/reslistpager.cpp +++ b/src/query/reslistpager.cpp @@ -279,6 +279,7 @@ void ResListPager::displayPage(RclConfig *config) chunk << "" << endl << "" << endl + << headerContent() << "" << endl << pageTop() << "

" diff --git a/src/query/reslistpager.h b/src/query/reslistpager.h index 746109d4..48570a40 100644 --- a/src/query/reslistpager.h +++ b/src/query/reslistpager.h @@ -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, map >& sugg) { diff --git a/src/sampleconf/recoll.qss b/src/sampleconf/recoll.qss index b43551c2..31e07bb0 100644 --- a/src/sampleconf/recoll.qss +++ b/src/sampleconf/recoll.qss @@ -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; }