diff --git a/src/python/recoll/pyrecoll.cpp b/src/python/recoll/pyrecoll.cpp index a245cb0b..0317cf45 100644 --- a/src/python/recoll/pyrecoll.cpp +++ b/src/python/recoll/pyrecoll.cpp @@ -732,8 +732,6 @@ Query_fetchone(recoll_QueryObject* self, PyObject *, PyObject *) printableUrl(rclconfig->getDefCharset(), doc->url, doc->meta[Rcl::Doc::keyurl]); doc->meta[Rcl::Doc::keytp] = doc->mimetype; - doc->meta[Rcl::Doc::keymt] = doc->dmtime.empty() ? - doc->fmtime : doc->dmtime; doc->meta[Rcl::Doc::keyipt] = doc->ipath; doc->meta[Rcl::Doc::keyfs] = doc->fbytes; doc->meta[Rcl::Doc::keyds] = doc->dbytes; diff --git a/src/python/samples/recollq.py b/src/python/samples/recollq.py index c1eaffdd..c1b66a22 100755 --- a/src/python/samples/recollq.py +++ b/src/python/samples/recollq.py @@ -27,7 +27,7 @@ def doquery(db, q): while query.next >= 0 and query.next < nres: doc = query.fetchone() print query.next, ":", - for k in ("title", "url"): + for k in ("title", "url", "mtime"): print k, ":", getattr(doc, k).encode('utf-8') abs = db.makeDocAbstract(doc, query).encode('utf-8') print abs diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 63803610..32080a10 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -88,7 +88,8 @@ void RclMain::init() QT_TR_NOOP("spreadsheet"), QT_TR_NOOP("text"), QT_TR_NOOP("sorted"), QT_TR_NOOP("filtered") }; - + DocSource::set_translations((const char *)tr("sorted").toUtf8(), + (const char *)tr("filtered").toUtf8()); curPreview = 0; asearchform = 0; uiprefs = 0; @@ -258,7 +259,7 @@ void RclMain::init() connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)), resList, SLOT(setSortParams(DocSeqSortSpec))); connect(resList, SIGNAL(hasResults(int)), this, SLOT(resultCount(int))); - connect(this, SIGNAL(applySortData()), resList, SLOT(setDocSource())); + connect(this, SIGNAL(applySortData()), resList, SLOT(readDocSource())); if (prefs.keepSort && prefs.sortActive) { if (prefs.sortDesc) actionSortByDateDesc->setChecked(true); @@ -542,13 +543,13 @@ void RclMain::startSearch(RefCntr sdata) Rcl::Query *query = new Rcl::Query(rcldb); query->setCollapseDuplicates(prefs.collapseDuplicates); - if (!query || !query->setQuery(sdata)) { QMessageBox::warning(0, "Recoll", tr("Can't start query: ") + QString::fromAscii(query->getReason().c_str())); QApplication::restoreOverrideCursor(); return; } + curPreview = 0; DocSequenceDb *src = new DocSequenceDb(RefCntr(query), @@ -557,6 +558,9 @@ void RclMain::startSearch(RefCntr sdata) prefs.queryReplaceAbstract); resList->setDocSource(RefCntr(src)); + resList->setSortParams(m_sortspec); + resList->setFilterParams(m_filtspec); + resList->readDocSource(); QApplication::restoreOverrideCursor(); } @@ -795,21 +799,21 @@ void RclMain::previewExposed(Preview *, int sid, int docnum) void RclMain::onSortDataChanged() { LOGDEB(("RclMain::onSortDataChanged()\n")); - DocSeqSortSpec spec; + m_sortspec.reset(); if (actionSortByDateAsc->isChecked()) { - spec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, false); - spec.sortdepth = 1000000; + m_sortspec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, false); + m_sortspec.sortdepth = 1000000; prefs.sortActive = true; prefs.sortDesc = false; } else if (actionSortByDateDesc->isChecked()) { - spec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, true); - spec.sortdepth = 1000000; + m_sortspec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, true); + m_sortspec.sortdepth = 1000000; prefs.sortActive = true; prefs.sortDesc = true; } else { prefs.sortActive = prefs.sortDesc = false; } - emit sortDataChanged(spec); + emit sortDataChanged(m_sortspec); emit applySortData(); } @@ -1158,6 +1162,9 @@ void RclMain::showDocHistory() string(tr("Document history").toUtf8())); src->setDescription((const char *)tr("History data").toUtf8()); resList->setDocSource(RefCntr(src)); + resList->setSortParams(m_sortspec); + resList->setFilterParams(m_filtspec); + resList->readDocSource(); } // Erase all memory of documents viewed @@ -1204,7 +1211,7 @@ void RclMain::catgFilter(int id) if (id < 0 || id >= int(m_catgbutvec.size())) return; - DocSeqFiltSpec spec; + m_filtspec.reset(); if (id != 0) { string catg = m_catgbutvec[id]; @@ -1212,11 +1219,11 @@ void RclMain::catgFilter(int id) rclconfig->getMimeCatTypes(catg, tps); for (list::const_iterator it = tps.begin(); it != tps.end(); it++) - spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it); + m_filtspec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it); } - resList->setFilterParams(spec); - resList->setDocSource(); + resList->setFilterParams(m_filtspec); + resList->readDocSource(); } void RclMain::toggleFullScreen() diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index f2e818cf..8cdfffe0 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -120,6 +120,8 @@ private: QAction * m_idNoStem; QAction * m_idAllStem; bool m_idxStatusAck; // Did we act on last status? + DocSeqFiltSpec m_filtspec; + DocSeqSortSpec m_sortspec; virtual void init(); virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum, diff --git a/src/qtgui/recoll.pro.in b/src/qtgui/recoll.pro.in index ae889862..9a310fa9 100644 --- a/src/qtgui/recoll.pro.in +++ b/src/qtgui/recoll.pro.in @@ -40,6 +40,7 @@ SOURCES += \ FORMS = \ advsearch.ui \ rclmain.ui \ + restable.ui \ spell.ui \ ssearchb.ui \ uiprefs.ui \ diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index 08f45f64..f44d7112 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -268,65 +268,34 @@ int ResList::newListId() extern "C" int XFlush(void *); -void ResList::setDocSource(RefCntr ndocsource) +void ResList::setDocSource(RefCntr nsource) { - m_baseDocSource = ndocsource; - setDocSource(); + m_source = RefCntr(new DocSource(nsource)); } // Reapply parameters. Sort params probably changed -void ResList::setDocSource() +void ResList::readDocSource() { - LOGDEB(("ResList::setDocSource\n")); - if (m_baseDocSource.isNull()) + if (m_source.isNull()) return; resetList(); m_listId = newListId(); - m_docSource = m_baseDocSource; - // Filtering must be done before sorting, (which usually - // truncates the original list) - if (m_baseDocSource->canFilter()) { - m_baseDocSource->setFiltSpec(m_filtspecs); - } else { - if (m_filtspecs.isNotNull()) { - string title = m_baseDocSource->title() + " (" + - string((const char*)tr("filtered").toUtf8()) + ")"; - m_docSource = - RefCntr(new DocSeqFiltered(m_docSource,m_filtspecs, - title)); - } - } - - if (m_docSource->canSort()) { - m_docSource->setSortSpec(m_sortspecs); - } else { - if (m_sortspecs.isNotNull()) { - LOGDEB(("Reslist: sortspecs not Null\n")); - string title = m_baseDocSource->title() + " (" + - string((const char *)tr("sorted").toUtf8()) + ")"; - m_docSource = RefCntr(new DocSeqSorted(m_docSource, - m_sortspecs, - title)); - } - } // Reset the page size in case the preference was changed m_pager->setPageSize(prefs.respagesize); - m_pager->setDocSource(m_docSource); + m_pager->setDocSource(m_source); resultPageNext(); emit hasResults(getResCnt()); } void ResList::setSortParams(DocSeqSortSpec spec) { - LOGDEB(("ResList::setSortParams: %s\n", spec.isNotNull() ? "notnull":"null")); - m_sortspecs = spec; + m_source->setSortSpec(spec); } void ResList::setFilterParams(const DocSeqFiltSpec& spec) { - LOGDEB(("ResList::setFilterParams\n")); - m_filtspecs = spec; + m_source->setFiltSpec(spec); } void ResList::resetList() @@ -350,9 +319,9 @@ bool ResList::displayingHistory() // We want to reset the displayed history if it is currently // shown. Using the title value is an ugly hack string htstring = string((const char *)tr("Document history").toUtf8()); - if (m_docSource.isNull() || m_docSource->title().empty()) + if (m_source.isNull() || m_source->title().empty()) return false; - return m_docSource->title().find(htstring) == 0; + return m_source->title().find(htstring) == 0; } void ResList::languageChange() @@ -363,14 +332,14 @@ void ResList::languageChange() bool ResList::getTerms(vector& terms, vector >& groups, vector& gslks) { - return m_baseDocSource->getTerms(terms, groups, gslks); + return m_source->getTerms(terms, groups, gslks); } list ResList::expand(Rcl::Doc& doc) { - if (m_baseDocSource.isNull()) + if (m_source.isNull()) return list(); - return m_baseDocSource->expand(doc); + return m_source->expand(doc); } // Get document number from paragraph number @@ -492,9 +461,9 @@ void ResList::mouseReleaseEvent(QMouseEvent *e) // Return total result list count int ResList::getResCnt() { - if (m_docSource.isNull()) + if (m_source.isNull()) return -1; - return m_docSource->getResCnt(); + return m_source->getResCnt(); } void ResList::highlighted(const QString& ) @@ -706,10 +675,10 @@ void ResList::menuSaveToFile() void ResList::menuPreviewParent() { Rcl::Doc doc; - if (!getDoc(m_popDoc, doc) || m_baseDocSource.isNull()) + if (!getDoc(m_popDoc, doc) || m_source.isNull()) return; Rcl::Doc pdoc; - if (m_baseDocSource->getEnclosing(doc, pdoc)) { + if (m_source->getEnclosing(doc, pdoc)) { emit previewRequested(pdoc); } else { // No parent doc: show enclosing folder with app configured for @@ -723,10 +692,10 @@ void ResList::menuPreviewParent() void ResList::menuOpenParent() { Rcl::Doc doc; - if (!getDoc(m_popDoc, doc) || m_baseDocSource.isNull()) + if (!getDoc(m_popDoc, doc) || m_source.isNull()) return; Rcl::Doc pdoc; - if (m_baseDocSource->getEnclosing(doc, pdoc)) { + if (m_source->getEnclosing(doc, pdoc)) { emit editRequested(pdoc); } else { // No parent doc: show enclosing folder with app configured for @@ -783,13 +752,13 @@ void ResList::menuExpand() QString ResList::getDescription() { - return QString::fromUtf8(m_docSource->getDescription().c_str()); + return QString::fromUtf8(m_source->getDescription().c_str()); } /** Show detailed expansion of a query */ void ResList::showQueryDetails() { - string oq = breakIntoLines(m_docSource->getDescription(), 100, 50); + string oq = breakIntoLines(m_source->getDescription(), 100, 50); QString desc = tr("Query details") + ": " + QString::fromUtf8(oq.c_str()); QMessageBox::information(this, tr("Query details"), desc); } diff --git a/src/qtgui/reslist.h b/src/qtgui/reslist.h index ec6e4863..88a7c173 100644 --- a/src/qtgui/reslist.h +++ b/src/qtgui/reslist.h @@ -48,7 +48,7 @@ class ResList : public QTextBrowser QString getDescription(); // Printable actual query performed on db int getResCnt(); // Return total result list size - void setDocSource(RefCntr ndocsource); + void setDocSource(RefCntr nsource); bool displayingHistory(); bool getTerms(vector& terms, vector >& groups, vector& gslks); @@ -73,7 +73,7 @@ class ResList : public QTextBrowser virtual void menuOpenParent(); virtual void previewExposed(int); virtual void append(const QString &text); - virtual void setDocSource(); + virtual void readDocSource(); virtual void setSortParams(DocSeqSortSpec spec); virtual void setFilterParams(const DocSeqFiltSpec &spec); virtual void highlighted(const QString& link); @@ -104,16 +104,9 @@ class ResList : public QTextBrowser virtual void showQueryDetails(); private: - QtGuiResListPager *m_pager; - // Raw doc source - RefCntr m_baseDocSource; - // Possibly filtered/sorted docsource (the one displayed) - RefCntr m_docSource; - // Current sort and filtering parameters - DocSeqSortSpec m_sortspecs; - DocSeqFiltSpec m_filtspecs; - // Docs for current page - std::vector m_curDocs; + QtGuiResListPager *m_pager; + RefCntr m_source; + std::vector m_curDocs; // Docs for current page // Translate from textedit paragraph number to relative // docnum. Built while we insert text into the qtextedit @@ -122,8 +115,7 @@ class ResList : public QTextBrowser int m_curPvDoc;// Docnum for current preview int m_lstClckMod; // Last click modifier. list m_selDocs; - int m_listId; - + int m_listId; // query Id for matching with preview windows virtual int docnumfromparnum(int); virtual pair parnumfromdocnum(int); diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp new file mode 100644 index 00000000..496fdf96 --- /dev/null +++ b/src/qtgui/restable.cpp @@ -0,0 +1,28 @@ +#ifndef lint +static char rcsid[] = "@(#$Id: reslist.cpp,v 1.52 2008-12-17 15:12:08 dockes Exp $ (C) 2005 J.F.Dockes"; +#endif + +#include "autoconfig.h" + +#include + +#include "restable.h" + +class RecollModel : public QAbstractTableModel { + Q_OBJECT + +public: + RecollModel(QObject *parent = 0) + : QAbstractTableModel(parent) + { + } + +private: + +}; + +void ResTable::init() +{ + +// Set up the columns according to the list of fields we are displaying +} diff --git a/src/qtgui/restable.h b/src/qtgui/restable.h new file mode 100644 index 00000000..6b1a3b74 --- /dev/null +++ b/src/qtgui/restable.h @@ -0,0 +1,45 @@ +#ifndef _RESTABLE_H_INCLUDED_ +#define _RESTABLE_H_INCLUDED_ +/* @(#$Id: spell_w.h,v 1.7 2006-12-22 11:01:28 dockes Exp $ (C) 2006 J.F.Dockes */ +/* + * 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. + */ + +#include "ui_restable.h" + +class ResTable : public Ui::ResTable +{ + Q_OBJECT +public: + ResTable(QWidget* parent = 0) + : QWidget(parent) + { + setupUi(this); + init(); + } + + ~ResTable(){} + +public slots: + +signals: + +private: + void init(); +}; + + +#endif /* _RESTABLE_H_INCLUDED_ */ diff --git a/src/qtgui/restable.ui b/src/qtgui/restable.ui new file mode 100644 index 00000000..1b26f6ae --- /dev/null +++ b/src/qtgui/restable.ui @@ -0,0 +1,59 @@ + + + ResTable + + + + 0 + 0 + 520 + 291 + + + + Form + + + + + + Qt::Vertical + + + + + 0 + 10 + + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + false + + + false + + + + + + 0 + 1 + + + + + + + + + + diff --git a/src/query/docseq.cpp b/src/query/docseq.cpp index e3159813..970a5334 100644 --- a/src/query/docseq.cpp +++ b/src/query/docseq.cpp @@ -17,10 +17,10 @@ static char rcsid[] = "@(#$Id: docseq.cpp,v 1.11 2008-09-29 08:59:20 dockes Exp * Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include - #include "docseq.h" +#include "filtseq.h" +#include "sortseq.h" +#include "debuglog.h" int DocSequence::getSeqSlice(int offs, int cnt, vector& result) { @@ -35,3 +35,75 @@ int DocSequence::getSeqSlice(int offs, int cnt, vector& result) return ret; } +void DocSource::unwind() +{ + RefCntr base = m_seq; + while (!m_seq.isNull() && !(m_seq->getSourceSeq()).isNull()) { + base = m_seq->getSourceSeq(); + } + m_seq = base; +} + +bool DocSource::buildStack() +{ + LOGDEB2(("DocSource::buildStack()\n")); + unwind(); + + if (m_seq.isNull()) + return false; + + // Filtering must be done before sorting, (which may + // truncates the original list) + if (m_seq->canFilter()) { + if (!m_seq->setFiltSpec(m_fspec)) { + LOGERR(("DocSource::buildStack: setfiltspec failed\n")); + } + } else { + if (m_fspec.isNotNull()) { + m_seq = + RefCntr(new DocSeqFiltered(m_seq, m_fspec)); + } + } + + if (m_seq->canSort()) { + if (!m_seq->setSortSpec(m_sspec)) { + LOGERR(("DocSource::buildStack: setsortspec failed\n")); + } + } else { + if (m_sspec.isNotNull()) { + m_seq = RefCntr(new DocSeqSorted(m_seq, m_sspec)); + } + } + return true; +} + +string DocSource::o_sort_trans; +string DocSource::o_filt_trans; + +string DocSource::title() +{ + string qual; + if (m_fspec.isNotNull() && !m_sspec.isNotNull()) + qual = string(" (") + o_filt_trans + string(")"); + else if (!m_fspec.isNotNull() && m_sspec.isNotNull()) + qual = string(" (") + o_sort_trans + string(")"); + else if (m_fspec.isNotNull() && m_sspec.isNotNull()) + qual = string(" (") + o_sort_trans + string(",") + o_filt_trans + string(")"); + return m_seq->title() + qual; +} + +bool DocSource::setFiltSpec(const DocSeqFiltSpec &f) +{ + LOGDEB2(("DocSource::setFiltSpec\n")); + m_fspec = f; + buildStack(); + return true; +} + +bool DocSource::setSortSpec(const DocSeqSortSpec &s) +{ + LOGDEB2(("DocSource::setSortSpec\n")); + m_sspec = s; + buildStack(); + return true; +} diff --git a/src/query/docseq.h b/src/query/docseq.h index 30ee61cb..b385962f 100644 --- a/src/query/docseq.h +++ b/src/query/docseq.h @@ -44,8 +44,8 @@ class DocSeqSortSpec { crits.push_back(fld); dirs.push_back(desc); } - bool isNotNull() {return sortdepth > 0;} - + bool isNotNull() const {return sortdepth > 0;} + void reset() {crits.clear(); dirs.clear();sortdepth = 0;} int sortdepth; // We only re-sort the first sortdepth most relevant docs std::vector crits; std::vector dirs; @@ -64,7 +64,7 @@ class DocSeqFiltSpec { std::vector crits; std::vector values; void reset() {crits.clear(); values.clear();} - bool isNotNull() {return crits.size() != 0;} + bool isNotNull() const {return crits.size() != 0;} }; /** Interface for a list of documents coming from some source. @@ -94,7 +94,7 @@ class DocSequence { virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0) = 0; /** Get next page of documents. This accumulates entries into the result - * list (doesn't reset it). */ + * list parameter (doesn't reset it). */ virtual int getSeqSlice(int offs, int cnt, vector& result); /** Get abstract for document. This is special because it may take time. @@ -130,14 +130,15 @@ class DocSequence { } virtual list expand(Rcl::Doc &) {return list();} - /** Optional functionality. Yeah, not nice */ + /** Optional functionality. */ virtual bool canFilter() {return false;} - virtual bool setFiltSpec(DocSeqFiltSpec &) {return false;} virtual bool canSort() {return false;} - virtual bool setSortSpec(DocSeqSortSpec &) {return false;} + virtual bool setFiltSpec(const DocSeqFiltSpec &) {return false;} + virtual bool setSortSpec(const DocSeqSortSpec &) {return false;} + virtual RefCntr getSourceSeq() {return RefCntr();} private: - string m_title; + string m_title; }; /** A modifier has a child sequence which does the real work and does @@ -145,8 +146,8 @@ class DocSequence { */ class DocSeqModifier : public DocSequence { public: - DocSeqModifier(const string &t, RefCntr iseq) - : DocSequence(t), m_seq(iseq) + DocSeqModifier(RefCntr iseq) + : DocSequence(""), m_seq(iseq) {} virtual ~DocSeqModifier() {} @@ -168,10 +169,45 @@ public: { m_seq->getUTerms(terms); } + virtual string title() {return m_seq->title();} + virtual RefCntr getSourceSeq() {return m_seq;} protected: RefCntr m_seq; }; +// A DocSource can juggle docseqs of different kinds to implement +// sorting and filtering in ways depending on the base seqs capabilities +class DocSource : public DocSeqModifier { +public: + DocSource(RefCntr iseq) + : DocSeqModifier(iseq) + {} + virtual bool canFilter() {return true;} + virtual bool canSort() {return true;} + virtual bool setFiltSpec(const DocSeqFiltSpec &); + virtual bool setSortSpec(const DocSeqSortSpec &); + virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0) + { + return m_seq->getDoc(num, doc, sh); + } + virtual int getResCnt() + { + return m_seq->getResCnt(); + } + static void set_translations(const string& sort, const string& filt) + { + o_sort_trans = sort; + o_filt_trans = filt; + } + virtual string title(); +private: + bool buildStack(); + void unwind(); + DocSeqFiltSpec m_fspec; + DocSeqSortSpec m_sspec; + static string o_sort_trans; + static string o_filt_trans; +}; #endif /* _DOCSEQ_H_INCLUDED_ */ diff --git a/src/query/docseqdb.cpp b/src/query/docseqdb.cpp index b6c78479..be0737d8 100644 --- a/src/query/docseqdb.cpp +++ b/src/query/docseqdb.cpp @@ -28,7 +28,7 @@ static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.9 2008-11-13 10:57:46 dockes Exp DocSequenceDb::DocSequenceDb(RefCntr q, const string &t, RefCntr sdata) : DocSequence(t), m_q(q), m_sdata(sdata), m_fsdata(sdata), - m_rescnt(-1), m_filt(false), + m_rescnt(-1), m_queryBuildAbstract(true), m_queryReplaceAbstract(false) { @@ -98,39 +98,31 @@ list DocSequenceDb::expand(Rcl::Doc &doc) return m_q->expand(doc); } -bool DocSequenceDb::setFiltSpec(DocSeqFiltSpec &fs) +bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs) { - if (!fs.isNotNull()) { - m_fsdata = m_sdata; - m_filt = false; - return m_q->setQuery(m_sdata); - } - - // We build a search spec by adding a filtering layer to the base one. - m_fsdata = RefCntr(new Rcl::SearchData(Rcl::SCLT_AND)); - Rcl::SearchDataClauseSub *cl = - new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB, m_sdata); - m_fsdata->addClause(cl); + LOGDEB(("DocSequenceDb::setFiltSpec\n")); + if (fs.isNotNull()) { + // We build a search spec by adding a filtering layer to the base one. + m_fsdata = RefCntr(new Rcl::SearchData(Rcl::SCLT_AND)); + Rcl::SearchDataClauseSub *cl = + new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB, m_sdata); + m_fsdata->addClause(cl); - for (unsigned int i = 0; i < fs.crits.size(); i++) { - switch (fs.crits[i]) { - case DocSeqFiltSpec::DSFS_MIMETYPE: - m_fsdata->addFiletype(fs.values[i]); + for (unsigned int i = 0; i < fs.crits.size(); i++) { + switch (fs.crits[i]) { + case DocSeqFiltSpec::DSFS_MIMETYPE: + m_fsdata->addFiletype(fs.values[i]); + } } + } else { + m_fsdata = m_sdata; } - m_filt = true; return m_q->setQuery(m_fsdata); } -// Need a way to access the translations for filtered ... -string DocSequenceDb::title() -{ - LOGDEB(("DOcSequenceDb::title()\n")); - return m_filt ? DocSequence::title() + " (filtered)" : DocSequence::title(); -} - -bool DocSequenceDb::setSortSpec(DocSeqSortSpec &sortspec) +bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &sortspec) { + LOGDEB(("DocSequenceDb::setSortSpec\n")); if (sortspec.isNotNull()) { bool ascending = false; for (unsigned int i = 0; i < sortspec.crits.size(); i++) { @@ -149,3 +141,7 @@ bool DocSequenceDb::setSortSpec(DocSeqSortSpec &sortspec) return m_q->setQuery(m_fsdata); } +bool DocSequenceDb::setQuery() +{ + return m_q->setQuery(m_fsdata); +} diff --git a/src/query/docseqdb.h b/src/query/docseqdb.h index d7846a0f..0008a758 100644 --- a/src/query/docseqdb.h +++ b/src/query/docseqdb.h @@ -41,10 +41,10 @@ class DocSequenceDb : public DocSequence { virtual string getDescription(); virtual list expand(Rcl::Doc &doc); virtual bool canFilter() {return true;} - virtual bool setFiltSpec(DocSeqFiltSpec &filtspec); + virtual bool setFiltSpec(const DocSeqFiltSpec &filtspec); virtual bool canSort() {return true;} - virtual bool setSortSpec(DocSeqSortSpec &sortspec); - virtual string title(); + virtual bool setSortSpec(const DocSeqSortSpec &sortspec); + virtual bool setQuery(); virtual void setAbstractParams(bool qba, bool qra) { m_queryBuildAbstract = qba; @@ -56,7 +56,6 @@ class DocSequenceDb : public DocSequence { RefCntr m_sdata; RefCntr m_fsdata; // Filtered int m_rescnt; - bool m_filt; bool m_queryBuildAbstract; bool m_queryReplaceAbstract; }; diff --git a/src/query/filtseq.cpp b/src/query/filtseq.cpp index e346bea5..ccd5940c 100644 --- a/src/query/filtseq.cpp +++ b/src/query/filtseq.cpp @@ -40,13 +40,6 @@ static bool filter(const DocSeqFiltSpec& fs, const Rcl::Doc *x) return 0; } -DocSeqFiltered::DocSeqFiltered(RefCntr iseq, - DocSeqFiltSpec &filtspec, - const std::string &t) - : DocSeqModifier(t, iseq), m_spec(filtspec) -{ -} - bool DocSeqFiltered::setFiltSpec(DocSeqFiltSpec &filtspec) { m_spec = filtspec; @@ -59,7 +52,7 @@ bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, string *) LOGDEB1(("DocSeqFiltered: fetching %d\n", idx)); if (idx >= (int)m_dbindices.size()) { - // Have to fetch xapian docs and filter until we get enough or + // Have to fetch docs and filter until we get enough or // fail m_dbindices.reserve(idx+1); diff --git a/src/query/filtseq.h b/src/query/filtseq.h index 5845e3f3..fc1200d5 100644 --- a/src/query/filtseq.h +++ b/src/query/filtseq.h @@ -30,9 +30,10 @@ * according to the given criteria. */ class DocSeqFiltered : public DocSeqModifier { - public: - DocSeqFiltered(RefCntr iseq, DocSeqFiltSpec &filtspec, - const std::string &t); +public: + DocSeqFiltered(RefCntr iseq, DocSeqFiltSpec &filtspec) + : DocSeqModifier(iseq), m_spec(filtspec) + {} virtual ~DocSeqFiltered() {} virtual bool canFilter() {return true;} virtual bool setFiltSpec(DocSeqFiltSpec &filtspec); diff --git a/src/query/sortseq.cpp b/src/query/sortseq.cpp index 217a34d1..6a9d605a 100644 --- a/src/query/sortseq.cpp +++ b/src/query/sortseq.cpp @@ -68,13 +68,6 @@ public: } }; -DocSeqSorted::DocSeqSorted(RefCntr iseq, DocSeqSortSpec &sortspec, - const std::string &t) - : DocSeqModifier(t, iseq) -{ - setSortSpec(sortspec); -} - bool DocSeqSorted::setSortSpec(DocSeqSortSpec &sortspec) { m_spec = sortspec; diff --git a/src/query/sortseq.h b/src/query/sortseq.h index b067d5cc..e5c32d3b 100644 --- a/src/query/sortseq.h +++ b/src/query/sortseq.h @@ -30,8 +30,11 @@ */ class DocSeqSorted : public DocSeqModifier { public: - DocSeqSorted(RefCntr iseq, DocSeqSortSpec &sortspec, - const std::string &t); + DocSeqSorted(RefCntr iseq, DocSeqSortSpec &sortspec) + : DocSeqModifier(iseq) + { + setSortSpec(sortspec); + } virtual ~DocSeqSorted() {} virtual bool canSort() {return true;} virtual bool setSortSpec(DocSeqSortSpec &sortspec); diff --git a/src/rcldb/rcldb.cpp b/src/rcldb/rcldb.cpp index 29141732..1a6b277b 100644 --- a/src/rcldb/rcldb.cpp +++ b/src/rcldb/rcldb.cpp @@ -253,7 +253,7 @@ string Db::Native::makeAbstract(Xapian::docid docid, Query *query) for (list::const_iterator qit = qterms.begin(); qit != qterms.end(); qit++) { query->m_nq->termfreqs[*qit] = xrdb.get_termfreq(*qit) / doccnt; - LOGDEB(("makeAbstract: [%s] db freq %.1e\n", qit->c_str(), + LOGABS(("makeAbstract: [%s] db freq %.1e\n", qit->c_str(), query->m_nq->termfreqs[*qit])); } LOGABS(("makeAbstract:%d: got termfreqs\n", chron.ms()));