From f0538b15f20090ba53a602ae9f8e7616e8d005e7 Mon Sep 17 00:00:00 2001 From: dockes Date: Mon, 29 Sep 2008 11:33:55 +0000 Subject: [PATCH] move stemlang from RclQuery to SearchData. Allow DocSequences to do the sorting/filtering themselves --- src/kde/kioslave/recoll/kio_recoll.cpp | 4 +-- src/python/recoll/pyrecoll.cpp | 9 +++-- src/qtgui/rclmain_w.cpp | 13 ++++--- src/qtgui/reslist.cpp | 28 +++++++++------ src/query/docseq.h | 47 +++++++++++++++++++++++++- src/query/docseqdb.cpp | 45 +++++++++++++++++++++--- src/query/docseqdb.h | 9 ++++- src/query/filtseq.cpp | 8 ++++- src/query/filtseq.h | 17 ++-------- src/query/recollq.cpp | 5 +-- src/query/sortseq.cpp | 24 +++++-------- src/query/sortseq.h | 19 ++--------- src/rcldb/rclquery.cpp | 9 ++--- src/rcldb/rclquery.h | 8 ++--- src/rcldb/searchdata.cpp | 11 +++--- src/rcldb/searchdata.h | 7 ++-- 16 files changed, 166 insertions(+), 97 deletions(-) diff --git a/src/kde/kioslave/recoll/kio_recoll.cpp b/src/kde/kioslave/recoll/kio_recoll.cpp index d6a951b2..b960dbc7 100644 --- a/src/kde/kioslave/recoll/kio_recoll.cpp +++ b/src/kde/kioslave/recoll/kio_recoll.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: kio_recoll.cpp,v 1.9 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: kio_recoll.cpp,v 1.10 2008-09-29 11:33:55 dockes Exp $ (C) 2005 J.F.Dockes"; #endif #include @@ -110,7 +110,7 @@ void RecollProtocol::get(const KURL & url) sdata->addClause(new Rcl::SearchDataClauseSimple(Rcl::SCLT_AND, (const char *)u8)); Rcl::Query *query = new Rcl::Query(m_rcldb); - if (!query->setQuery(sdata, Rcl::Db::QO_STEM, "english")) { + if (!query->setQuery(sdata)) { m_reason = "Internal Error: setQuery failed"; outputError(m_reason.c_str()); finished(); diff --git a/src/python/recoll/pyrecoll.cpp b/src/python/recoll/pyrecoll.cpp index 18cb58ad..4199627f 100644 --- a/src/python/recoll/pyrecoll.cpp +++ b/src/python/recoll/pyrecoll.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: pyrecoll.cpp,v 1.15 2008-09-29 08:59:20 dockes Exp $ (C) 2007 J.F.Dockes"; +static char rcsid[] = "@(#$Id: pyrecoll.cpp,v 1.16 2008-09-29 11:33:55 dockes Exp $ (C) 2007 J.F.Dockes"; #endif @@ -617,9 +617,14 @@ Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) PyErr_SetString(PyExc_ValueError, reason.c_str()); return 0; } + + // SearchData defaults to stemming in english + // Use default for now but need to add way to specify language + if (!dostem) + sd->setStemlang(""); RefCntr rq(sd); self->query->setSortBy(self->sortfield, self->ascending); - self->query->setQuery(rq, dostem?Rcl::Query::QO_STEM:Rcl::Query::QO_NONE); + self->query->setQuery(rq); int cnt = self->query->getResCnt(); self->next = 0; return Py_BuildValue("i", cnt); diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index e5ad55ff..9197b836 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.53 2008-09-28 14:20:50 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.54 2008-09-29 11:33:55 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -99,7 +99,8 @@ void RclMain::init() static const char* catg_strings[] = { QT_TR_NOOP("All"), QT_TR_NOOP("media"), QT_TR_NOOP("message"), QT_TR_NOOP("other"), QT_TR_NOOP("presentation"), - QT_TR_NOOP("spreadsheet"), QT_TR_NOOP("text") + QT_TR_NOOP("spreadsheet"), QT_TR_NOOP("text"), + QT_TR_NOOP("sorted"), QT_TR_NOOP("filtered") }; curPreview = 0; @@ -457,19 +458,17 @@ void RclMain::startSearch(RefCntr sdata) } resList->resetList(); - - int qopts = 0; - if (!prefs.queryStemLang.length() == 0) - qopts |= Rcl::Query::QO_STEM; QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); string stemLang = (const char *)prefs.queryStemLang.ascii(); if (stemLang == "ALL") { rclconfig->getConfParam("indexstemminglanguages", stemLang); } + sdata->setStemlang(stemLang); + Rcl::Query *query = new Rcl::Query(rcldb); - if (!query || !query->setQuery(sdata, qopts, stemLang)) { + if (!query || !query->setQuery(sdata)) { QMessageBox::warning(0, "Recoll", tr("Can't start query: ") + QString::fromAscii(query->getReason().c_str())); QApplication::restoreOverrideCursor(); diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index c5d83fe9..af2b791c 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: reslist.cpp,v 1.46 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: reslist.cpp,v 1.47 2008-09-29 11:33:55 dockes Exp $ (C) 2005 J.F.Dockes"; #endif #include @@ -113,16 +113,24 @@ void ResList::setDocSource() // Filtering must be done before sorting, (which usually // truncates the original list) - if (m_filtspecs.isNotNull()) { - m_docSource = - RefCntr(new DocSeqFiltered(m_docSource, - m_filtspecs, "")); + if (m_baseDocSource->canFilter()) { + m_baseDocSource->setFiltSpec(m_filtspecs); + } else { + if (m_filtspecs.isNotNull()) { + string title = m_baseDocSource->title() + " (" + + string((const char*)tr("filtered").utf8()) + ")"; + m_docSource = + RefCntr(new DocSeqFiltered(m_docSource,m_filtspecs, + title)); + } } if (m_sortspecs.isNotNull()) { + string title = m_baseDocSource->title() + " (" + + string((const char *)tr("sorted").utf8()) + ")"; m_docSource = RefCntr(new DocSeqSorted(m_docSource, m_sortspecs, - string(tr("Query results (sorted)").utf8()))); + title)); } resultPageNext(); } @@ -162,10 +170,10 @@ void ResList::resetList() bool ResList::displayingHistory() { - // We want to reset the displayed history if it is currently shown. Using - // the title value is an ugly hack - return m_docSource->title() == - string((const char *)tr("Document history").utf8()); + // 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").utf8()); + return m_docSource->title().find(htstring) == 0; } void ResList::languageChange() diff --git a/src/query/docseq.h b/src/query/docseq.h index a7eb4037..4d2c52b0 100644 --- a/src/query/docseq.h +++ b/src/query/docseq.h @@ -16,7 +16,7 @@ */ #ifndef _DOCSEQ_H_INCLUDED_ #define _DOCSEQ_H_INCLUDED_ -/* @(#$Id: docseq.h,v 1.16 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: docseq.h,v 1.17 2008-09-29 11:33:55 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include #include @@ -34,10 +34,48 @@ struct ResListEntry { string subHeader; }; +/** Sort specification. Will be made closer to the db interface one day */ +class DocSeqSortSpec { + public: + DocSeqSortSpec() : sortdepth(0) {} + enum Field {RCLFLD_MIMETYPE, RCLFLD_MTIME}; + void addCrit(Field fld, bool desc = false) { + crits.push_back(fld); + dirs.push_back(desc); + } + bool isNotNull() {return sortdepth > 0;} + + int sortdepth; // We only re-sort the first sortdepth most relevant docs + std::vector crits; + std::vector dirs; +}; + +/** Filtering spec. This is only used to filter by doc category for now, hence + the rather specialized interface */ +class DocSeqFiltSpec { + public: + DocSeqFiltSpec() {} + enum Crit {DSFS_MIMETYPE}; + void orCrit(Crit crit, const string& value) { + crits.push_back(crit); + values.push_back(value); + } + std::vector crits; + std::vector values; + void reset() {crits.clear(); values.clear();} + bool isNotNull() {return crits.size() != 0;} +}; + /** Interface for a list of documents coming from some source. The result list display data may come from different sources (ie: history or Db query), and be post-processed (DocSeqSorted). + Additional functionality like filtering/sorting can either be + obtained by stacking DocSequence objects (ie: sorting history), or + by native capability (ex: docseqdb can sort and filter). The + implementation might be nicer by using more sophisticated c++ with + multiple inheritance of sort and filter virtual interfaces, but + the current one will have to do for now... */ class DocSequence { public: @@ -83,6 +121,13 @@ class DocSequence { terms.clear(); groups.clear(); gslks.clear(); return true; } virtual list expand(Rcl::Doc &) {list e; return e;} + + /** Optional functionality. Yeah, not nice */ + virtual bool canFilter() {return false;} + virtual bool setFiltSpec(DocSeqFiltSpec &) {return false;} + virtual bool canSort() {return false;} + virtual bool setSortSpec(DocSeqSortSpec &) {return false;} + private: string m_title; }; diff --git a/src/query/docseqdb.cpp b/src/query/docseqdb.cpp index 001ca67e..d2e2d612 100644 --- a/src/query/docseqdb.cpp +++ b/src/query/docseqdb.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.7 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.8 2008-09-29 11:33:55 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -22,10 +22,11 @@ static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.7 2008-09-29 08:59:20 dockes Exp #include "docseqdb.h" #include "rcldb.h" +#include "debuglog.h" DocSequenceDb::DocSequenceDb(RefCntr q, const string &t, RefCntr sdata) - : DocSequence(t), m_q(q), m_sdata(sdata), m_rescnt(-1) + : DocSequence(t), m_q(q), m_sdata(sdata), m_rescnt(-1), m_filt(false) { } @@ -37,12 +38,12 @@ bool DocSequenceDb::getTerms(vector& terms, vector >& groups, vector& gslks) { - return m_sdata->getTerms(terms, groups, gslks); + return m_fsdata->getTerms(terms, groups, gslks); } string DocSequenceDb::getDescription() { - return m_sdata->getDescription(); + return m_fsdata->getDescription(); } bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh) @@ -73,3 +74,39 @@ list DocSequenceDb::expand(Rcl::Doc &doc) return m_q->expand(doc); } +bool DocSequenceDb::setFiltSpec(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); + + for (unsigned int i = 0; i < fs.crits.size(); i++) { + switch (fs.crits[i]) { + case DocSeqFiltSpec::DSFS_MIMETYPE: + m_fsdata->addFiletype(fs.values[i]); + } + } + 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(); +} + +// TBDone +bool DocSequenceDb::setSortSpec(DocSeqSortSpec &sortspec) +{ + return true; +} diff --git a/src/query/docseqdb.h b/src/query/docseqdb.h index 86f6b56e..981a2ac9 100644 --- a/src/query/docseqdb.h +++ b/src/query/docseqdb.h @@ -16,7 +16,7 @@ */ #ifndef _DOCSEQDB_H_INCLUDED_ #define _DOCSEQDB_H_INCLUDED_ -/* @(#$Id: docseqdb.h,v 1.5 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: docseqdb.h,v 1.6 2008-09-29 11:33:55 dockes Exp $ (C) 2004 J.F.Dockes */ #include "docseq.h" #include "refcntr.h" @@ -38,10 +38,17 @@ class DocSequenceDb : public DocSequence { virtual string getAbstract(Rcl::Doc &doc); virtual string getDescription(); virtual list expand(Rcl::Doc &doc); + virtual bool canFilter() {return true;} + virtual bool setFiltSpec(DocSeqFiltSpec &filtspec); + virtual bool canSort() {return false;} + virtual bool setSortSpec(DocSeqSortSpec &sortspec); + virtual string title(); private: RefCntr m_q; RefCntr m_sdata; + RefCntr m_fsdata; // Filtered int m_rescnt; + bool m_filt; }; #endif /* _DOCSEQDB_H_INCLUDED_ */ diff --git a/src/query/filtseq.cpp b/src/query/filtseq.cpp index 30406cf3..ba54bece 100644 --- a/src/query/filtseq.cpp +++ b/src/query/filtseq.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: filtseq.cpp,v 1.2 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: filtseq.cpp,v 1.3 2008-09-29 11:33:55 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -47,6 +47,12 @@ DocSeqFiltered::DocSeqFiltered(RefCntr iseq, { } +bool DocSeqFiltered::setFiltSpec(DocSeqFiltSpec &filtspec) +{ + m_spec = filtspec; + m_dbindices.clear(); +} + bool DocSeqFiltered::getDoc(int idx, Rcl::Doc &doc, string *) { LOGDEB1(("DocSeqFiltered: fetching %d\n", idx)); diff --git a/src/query/filtseq.h b/src/query/filtseq.h index 7e9abab7..ae07eb30 100644 --- a/src/query/filtseq.h +++ b/src/query/filtseq.h @@ -16,7 +16,7 @@ */ #ifndef _FILTSEQ_H_INCLUDED_ #define _FILTSEQ_H_INCLUDED_ -/* @(#$Id: filtseq.h,v 1.3 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: filtseq.h,v 1.4 2008-09-29 11:33:55 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -24,19 +24,6 @@ #include "refcntr.h" #include "docseq.h" -class DocSeqFiltSpec { - public: - DocSeqFiltSpec() {} - enum Crit {DSFS_MIMETYPE}; - void orCrit(Crit crit, const string& value) { - crits.push_back(crit); - values.push_back(value); - } - std::vector crits; - std::vector values; - void reset() {crits.clear(); values.clear();} - bool isNotNull() {return crits.size() != 0;} -}; /** * A filtered sequence is created from another one by selecting entries @@ -47,6 +34,8 @@ class DocSeqFiltered : public DocSequence { DocSeqFiltered(RefCntr iseq, DocSeqFiltSpec &filtspec, const std::string &t); virtual ~DocSeqFiltered() {} + virtual bool canFilter() {return true;} + virtual bool setFiltSpec(DocSeqFiltSpec &filtspec); virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0); virtual int getResCnt() {return m_seq->getResCnt();} virtual string getAbstract(Rcl::Doc& doc) { diff --git a/src/query/recollq.cpp b/src/query/recollq.cpp index 91b19178..960dc9d8 100644 --- a/src/query/recollq.cpp +++ b/src/query/recollq.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: recollq.cpp,v 1.18 2008-09-29 08:59:20 dockes Exp $ (C) 2006 J.F.Dockes"; +static char rcsid[] = "@(#$Id: recollq.cpp,v 1.19 2008-09-29 11:33:55 dockes Exp $ (C) 2006 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -221,13 +221,14 @@ int recollq(RclConfig **cfp, int argc, char **argv) cerr << "Query string interpretation failed: " << reason << endl; return 1; } + sd->setStemlang("english"); RefCntr rq(sd); Rcl::Query query(&rcldb); if (op_flags & OPT_S) { query.setSortBy(sortfield, (op_flags & OPT_D) ? false : true); } - query.setQuery(rq, Rcl::Query::QO_STEM); + query.setQuery(rq); int cnt = query.getResCnt(); if (!(op_flags & OPT_b)) { cout << "Recoll query: " << rq->getDescription() << endl; diff --git a/src/query/sortseq.cpp b/src/query/sortseq.cpp index ff537e66..9bd6eeb6 100644 --- a/src/query/sortseq.cpp +++ b/src/query/sortseq.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.13 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.14 2008-09-29 11:33:55 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -53,20 +53,6 @@ public: return 0; } break; - case DocSeqSortSpec::RCLFLD_URL: - LOGDEB1((" URL\n")); - if (ss.dirs[i] ? x->url > y->url : x->url < y->url) - return 1; - else if (x->url != y->url) - return 0; - break; - case DocSeqSortSpec::RCLFLD_IPATH: - LOGDEB1((" IPATH\n")); - if (ss.dirs[i] ? x->ipath > y->ipath : x->ipath < y->ipath) - return 1; - else if (x->ipath != y->ipath) - return 0; - break; case DocSeqSortSpec::RCLFLD_MIMETYPE: LOGDEB1((" MIMETYPE\n")); if (ss.dirs[i] ? x->mimetype > y->mimetype : @@ -85,13 +71,18 @@ public: DocSeqSorted::DocSeqSorted(RefCntr iseq, DocSeqSortSpec &sortspec, const std::string &t) : DocSequence(t), m_seq(iseq) +{ + setSortSpec(sortspec); +} + +bool DocSeqSorted::setSortSpec(DocSeqSortSpec &sortspec) { m_spec = sortspec; LOGDEB(("DocSeqSorted:: count %d\n", m_spec.sortdepth)); m_docs.resize(m_spec.sortdepth); int i; for (i = 0; i < m_spec.sortdepth; i++) { - if (!iseq->getDoc(i, m_docs[i])) { + if (!m_seq->getDoc(i, m_docs[i])) { LOGERR(("DocSeqSorted: getDoc failed for doc %d\n", i)); break; } @@ -105,6 +96,7 @@ DocSeqSorted::DocSeqSorted(RefCntr iseq, DocSeqSortSpec &sortspec, CompareDocs cmp(sortspec); sort(m_docsp.begin(), m_docsp.end(), cmp); + return true; } bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, string *) diff --git a/src/query/sortseq.h b/src/query/sortseq.h index b2a4fb64..8c9a98e6 100644 --- a/src/query/sortseq.h +++ b/src/query/sortseq.h @@ -16,7 +16,7 @@ */ #ifndef _SORTSEQ_H_INCLUDED_ #define _SORTSEQ_H_INCLUDED_ -/* @(#$Id: sortseq.h,v 1.12 2008-09-29 08:59:20 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: sortseq.h,v 1.13 2008-09-29 11:33:55 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -24,21 +24,6 @@ #include "refcntr.h" #include "docseq.h" -class DocSeqSortSpec { - public: - DocSeqSortSpec() : sortdepth(0) {} - enum Field {RCLFLD_URL, RCLFLD_IPATH, RCLFLD_MIMETYPE, RCLFLD_MTIME}; - void addCrit(Field fld, bool desc = false) { - crits.push_back(fld); - dirs.push_back(desc); - } - bool isNotNull() {return sortdepth > 0;} - - int sortdepth; // We only re-sort the first sortdepth most relevant docs - std::vector crits; - std::vector dirs; -}; - /** * A sorted sequence is created from the first N documents of another one, * and sorts them according to the given criteria. @@ -48,6 +33,8 @@ class DocSeqSorted : public DocSequence { DocSeqSorted(RefCntr iseq, DocSeqSortSpec &sortspec, const std::string &t); virtual ~DocSeqSorted() {} + virtual bool canSort() {return true;} + virtual bool setSortSpec(DocSeqSortSpec &sortspec); virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0); virtual int getResCnt() {return m_spec.sortdepth;} virtual string getAbstract(Rcl::Doc& doc) { diff --git a/src/rcldb/rclquery.cpp b/src/rcldb/rclquery.cpp index ec548104..71951aa8 100644 --- a/src/rcldb/rclquery.cpp +++ b/src/rcldb/rclquery.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.8 2008-09-29 08:59:20 dockes Exp $ (C) 2008 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.9 2008-09-29 11:33:55 dockes Exp $ (C) 2008 J.F.Dockes"; #endif #include @@ -124,8 +124,7 @@ void Query::setSortBy(const string& fld, bool ascending) { #define ISNULL(X) !(X) // Prepare query out of user search data -bool Query::setQuery(RefCntr sdata, int opts, - const string& stemlang) +bool Query::setQuery(RefCntr sdata) { LOGDEB(("Query::setQuery:\n")); @@ -136,7 +135,6 @@ bool Query::setQuery(RefCntr sdata, int opts, m_reason.erase(); m_filterTopDir = sdata->getTopdir(); - m_qOpts = opts; m_nq->clear(); if (!m_filterTopDir.empty()) { @@ -149,8 +147,7 @@ bool Query::setQuery(RefCntr sdata, int opts, } Xapian::Query xq; - if (!sdata->toNativeQuery(*m_db, &xq, (opts & QO_STEM) ? - stemlang : string())) { + if (!sdata->toNativeQuery(*m_db, &xq)) { m_reason += sdata->getReason(); return false; } diff --git a/src/rcldb/rclquery.h b/src/rcldb/rclquery.h index 0966868b..bae86a54 100644 --- a/src/rcldb/rclquery.h +++ b/src/rcldb/rclquery.h @@ -1,6 +1,6 @@ #ifndef _rclquery_h_included_ #define _rclquery_h_included_ -/* @(#$Id: rclquery.h,v 1.5 2008-09-29 08:59:20 dockes Exp $ (C) 2008 J.F.Dockes */ +/* @(#$Id: rclquery.h,v 1.6 2008-09-29 11:33:55 dockes Exp $ (C) 2008 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 @@ -45,8 +45,6 @@ class Doc; */ class Query { public: - enum QueryOpts {QO_NONE=0, QO_STEM = 1}; - /** The constructor only allocates memory */ Query(Db *db); ~Query(); @@ -63,8 +61,7 @@ class Query { * be called repeatedly on the same object which gets reinitialized each * time. */ - bool setQuery(RefCntr q, int opts = QO_NONE, - const string& stemlang = "english"); + bool setQuery(RefCntr q); /** Get results count for current query */ int getResCnt(); @@ -93,7 +90,6 @@ private: string m_reason; // Error explanation Db *m_db; void *m_sorter; - unsigned int m_qOpts; string m_sortField; bool m_sortAscending; /* Copyconst and assignement private and forbidden */ diff --git a/src/rcldb/searchdata.cpp b/src/rcldb/searchdata.cpp index 6c2c81b8..2cd646c3 100644 --- a/src/rcldb/searchdata.cpp +++ b/src/rcldb/searchdata.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: searchdata.cpp,v 1.24 2008-09-29 06:58:25 dockes Exp $ (C) 2006 J.F.Dockes"; +static char rcsid[] = "@(#$Id: searchdata.cpp,v 1.25 2008-09-29 11:33:55 dockes Exp $ (C) 2006 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -43,7 +43,7 @@ namespace Rcl { typedef vector::iterator qlist_it_t; typedef vector::const_iterator qlist_cit_t; -bool SearchData::toNativeQuery(Rcl::Db &db, void *d, const string& stemlang) +bool SearchData::toNativeQuery(Rcl::Db &db, void *d) { Xapian::Query xq; m_reason.erase(); @@ -74,7 +74,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d, const string& stemlang) // Xapian query tree for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++) { Xapian::Query nq; - if (!(*it)->toNativeQuery(db, &nq, stemlang)) { + if (!(*it)->toNativeQuery(db, &nq, m_stemlang)) { LOGERR(("SearchData::toNativeQuery: failed\n")); m_reason = (*it)->getReason(); return false; @@ -631,10 +631,9 @@ bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p, } // Translate subquery -bool SearchDataClauseSub::toNativeQuery(Rcl::Db &db, void *p, - const string& stemlang) +bool SearchDataClauseSub::toNativeQuery(Rcl::Db &db, void *p, const string&) { - return m_sub->toNativeQuery(db, p, stemlang); + return m_sub->toNativeQuery(db, p); } } // Namespace Rcl diff --git a/src/rcldb/searchdata.h b/src/rcldb/searchdata.h index 7d896a85..27e6ce15 100644 --- a/src/rcldb/searchdata.h +++ b/src/rcldb/searchdata.h @@ -16,7 +16,7 @@ */ #ifndef _SEARCHDATA_H_INCLUDED_ #define _SEARCHDATA_H_INCLUDED_ -/* @(#$Id: searchdata.h,v 1.19 2008-09-29 06:58:25 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: searchdata.h,v 1.20 2008-09-29 11:33:55 dockes Exp $ (C) 2004 J.F.Dockes */ /** * Structures to hold data coming almost directly from the gui @@ -83,7 +83,7 @@ public: bool haveWildCards() {return m_haveWildCards;} /** Translate to Xapian query. rcldb knows about the void* */ - bool toNativeQuery(Rcl::Db &db, void *, const string& stemlang); + bool toNativeQuery(Rcl::Db &db, void *); /** We become the owner of cl and will delete it */ bool addClause(SearchDataClause *cl); @@ -109,7 +109,7 @@ public: void setTopdir(const string& t) {m_topdir = t;} /** Add file type for filtering results */ void addFiletype(const string& ft) {m_filetypes.push_back(ft);} - + void setStemlang(const string& lang = "english") {m_stemlang = lang;} private: SClType m_tp; // Only SCLT_AND or SCLT_OR here vector m_query; @@ -120,6 +120,7 @@ private: string m_description; string m_reason; bool m_haveWildCards; + string m_stemlang; /* Copyconst and assignment private and forbidden */ SearchData(const SearchData &) {} SearchData& operator=(const SearchData&) {return *this;};