From b38b88124a1baedddacc5017336985d89b8ba0d8 Mon Sep 17 00:00:00 2001 From: dockes Date: Wed, 11 Jan 2006 15:08:22 +0000 Subject: [PATCH] translation of result list title. Show query details when clicking on header --- src/doc/user/usermanual.sgml | 9 ++++++++- src/index/Makefile | 2 +- src/qtgui/recoll_fr.ts | 22 +++++++++++++++++++++- src/qtgui/recollmain.ui | 10 ++-------- src/qtgui/recollmain.ui.h | 32 ++++++++++++++++++++------------ src/query/docseq.h | 17 ++++++++++------- src/query/sortseq.cpp | 7 ++++--- src/query/sortseq.h | 5 +++-- src/rcldb/rcldb.cpp | 32 ++++++++++++++++++++------------ src/rcldb/rcldb.h | 6 ++++-- 10 files changed, 93 insertions(+), 49 deletions(-) diff --git a/src/doc/user/usermanual.sgml b/src/doc/user/usermanual.sgml index 3632fc9b..21220a1a 100644 --- a/src/doc/user/usermanual.sgml +++ b/src/doc/user/usermanual.sgml @@ -24,7 +24,7 @@ Dockes - $Id: usermanual.sgml,v 1.2 2006-01-10 11:07:21 dockes Exp $ + $Id: usermanual.sgml,v 1.3 2006-01-11 15:08:21 dockes Exp $ This document introduces full text search notions @@ -369,6 +369,7 @@ character case should make a difference for a &RCL; search. + Phrases A phrase can be looked for by enclosing it in double quotes. Example: "user manual" will look @@ -378,6 +379,12 @@ search dialog to the same effect. + Query explanation + You can get an exact description of what the query + looked for, including stem expansion, and boolean operators + used, by clicking on the result list header. + + Quitting Entering ^Q almost anywhere will close the application. diff --git a/src/index/Makefile b/src/index/Makefile index 3f890495..73c9334a 100644 --- a/src/index/Makefile +++ b/src/index/Makefile @@ -3,7 +3,7 @@ include ../mk/sysconf PROGS = recollindex csguess mimetype SRCS = recollindex.cpp -all: $(PROGS) +all: depend $(PROGS) RECOLLINDEX_OBJS= recollindex.o $(BIGLIB) $(MIMELIB) recollindex : $(RECOLLINDEX_OBJS) diff --git a/src/qtgui/recoll_fr.ts b/src/qtgui/recoll_fr.ts index 639d07d8..cd00f107 100644 --- a/src/qtgui/recoll_fr.ts +++ b/src/qtgui/recoll_fr.ts @@ -238,7 +238,7 @@ Click Cancel if you want to edit the configuration file before indexation starts Toolbar_2 - Toolbar_2 + Toolbar_2 Start &Indexing @@ -310,6 +310,26 @@ Click Cancel if you want to edit the configuration file before indexation starts &User manual &Manuel + + Query results + Résultats de la recherche + + + Query results (sorted) + Résultats de la recherche (triés) + + + Document history + Historique des documents consultés + + + Document history (sorted) + Historique des documents consultés (trié) + + + Query details + Détail de la recherche + SortForm diff --git a/src/qtgui/recollmain.ui b/src/qtgui/recollmain.ui index e1842d31..95a70db9 100644 --- a/src/qtgui/recollmain.ui +++ b/src/qtgui/recollmain.ui @@ -199,14 +199,6 @@ - - - HelpToolbar - - - Toolbar_2 - - @@ -455,6 +447,7 @@ advsearch.h sort.h uiprefs.h + rcldb.h recollmain.ui.h @@ -467,6 +460,7 @@ bool reslist_dblclck; Preview *curPreview; advsearch *asearchform; + Rcl::AdvSearchData currentQueryData; SortForm *sortform; UIPrefsDialog *uiprefs; int sortwidth; diff --git a/src/qtgui/recollmain.ui.h b/src/qtgui/recollmain.ui.h index 5fe910ac..746be831 100644 --- a/src/qtgui/recollmain.ui.h +++ b/src/qtgui/recollmain.ui.h @@ -343,10 +343,16 @@ void RecollMain::reslistTE_delayedclick() // Document number int reldocnum = reldocnumfromparnum(par); - // Bad number or already displayed. Forget it - if (reldocnum < 0) + + if (reldocnum < 0) { + // Bad number: must have clicked on header. Show details of query + QString desc = tr("Query details") + ": " + + currentQueryData.description.c_str(); + QMessageBox::information(this, tr("Query details"), desc); return; - startPreview(reslist_winfirst + reldocnum); + } else { + startPreview(reslist_winfirst + reldocnum); + } } // User asked to start query. Send it to the db aand call @@ -389,12 +395,13 @@ void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata) delete docsource; if (sortwidth > 0) { - DocSequenceDb myseq(rcldb); - docsource = new DocSeqSorted(myseq, sortwidth, sortspecs); + DocSequenceDb myseq(rcldb, tr("Query results")); + docsource = new DocSeqSorted(myseq, sortwidth, sortspecs, + tr("Query results (sorted)")); } else { - docsource = new DocSequenceDb(rcldb); + docsource = new DocSequenceDb(rcldb, tr("Query results")); } - + currentQueryData = sdata; showResultPage(); } @@ -781,22 +788,23 @@ void RecollMain::startManual() startHelpBrowser(); } - void RecollMain::showDocHistory() { LOGDEB(("RecollMain::showDocHistory\n")); reslist_winfirst = -1; curPreview = 0; - if (docsource) delete docsource; if (sortwidth > 0) { - DocSequenceHistory myseq(rcldb, history); - docsource = new DocSeqSorted(myseq, sortwidth, sortspecs); + DocSequenceHistory myseq(rcldb, history, tr("Document history")); + docsource = new DocSeqSorted(myseq, sortwidth, sortspecs, + tr("Document history (sorted)")); } else { - docsource = new DocSequenceHistory(rcldb, history); + docsource = new DocSequenceHistory(rcldb, history, + tr("Document history")); } + currentQueryData.erase(); showResultPage(); } diff --git a/src/query/docseq.h b/src/query/docseq.h index 28554956..f5c2273c 100644 --- a/src/query/docseq.h +++ b/src/query/docseq.h @@ -1,6 +1,6 @@ #ifndef _DOCSEQ_H_INCLUDED_ #define _DOCSEQ_H_INCLUDED_ -/* @(#$Id: docseq.h,v 1.3 2005-12-05 16:13:12 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: docseq.h,v 1.4 2006-01-11 15:08:22 dockes Exp $ (C) 2004 J.F.Dockes */ #include "rcldb.h" #include "history.h" @@ -11,11 +11,14 @@ history or Db query). We have an interface to make things cleaner. */ class DocSequence { + std::string m_title; public: + DocSequence(const std::string &t) : m_title(t) {} + virtual ~DocSequence() {} virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0) = 0; virtual int getResCnt() = 0; - virtual std::string title() = 0; + virtual std::string title() {return m_title;} }; @@ -23,11 +26,12 @@ class DocSequence { to make sense */ class DocSequenceDb : public DocSequence { public: - DocSequenceDb(Rcl::Db *d) : m_db(d), m_rescnt(-1) {} + DocSequenceDb(Rcl::Db *d, const std::string &t) : + DocSequence(t), m_db(d), m_rescnt(-1) + {} virtual ~DocSequenceDb() {} virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string * = 0); virtual int getResCnt(); - virtual std::string title() {return string("Query results");} private: Rcl::Db *m_db; int m_rescnt; @@ -36,13 +40,12 @@ class DocSequenceDb : public DocSequence { /** A DocSequence coming from the history file */ class DocSequenceHistory : public DocSequence { public: - DocSequenceHistory(Rcl::Db *d, RclDHistory *h) - : m_db(d), m_hist(h), m_prevnum(-1), m_prevtime(-1) {} + DocSequenceHistory(Rcl::Db *d, RclDHistory *h, const std::string &t) + : DocSequence(t), m_db(d), m_hist(h), m_prevnum(-1), m_prevtime(-1) {} virtual ~DocSequenceHistory() {} virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0); virtual int getResCnt(); - virtual std::string title() {return string("Document history");} private: Rcl::Db *m_db; RclDHistory *m_hist; diff --git a/src/query/sortseq.cpp b/src/query/sortseq.cpp index 005d6f45..ada351e1 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.4 2005-12-05 12:02:01 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.5 2006-01-11 15:08:22 dockes Exp $ (C) 2005 J.F.Dockes"; #endif #include @@ -66,7 +66,9 @@ public: } }; -DocSeqSorted::DocSeqSorted(DocSequence &iseq, int cnt, RclSortSpec &sortspec) +DocSeqSorted::DocSeqSorted(DocSequence &iseq, int cnt, RclSortSpec &sortspec, + const std::string &t) + : DocSequence(t) { LOGDEB(("DocSeqSorted:: count %d\n", cnt)); @@ -87,7 +89,6 @@ DocSeqSorted::DocSeqSorted(DocSequence &iseq, int cnt, RclSortSpec &sortspec) for (i = 0; i < m_count; i++) m_docsp[i] = &m_docs[i]; - m_title = iseq.title() + " (sorted)"; CompareDocs cmp(sortspec); sort(m_docsp.begin(), m_docsp.end(), cmp); } diff --git a/src/query/sortseq.h b/src/query/sortseq.h index ad839a97..a6535e4e 100644 --- a/src/query/sortseq.h +++ b/src/query/sortseq.h @@ -1,6 +1,6 @@ #ifndef _SORTSEQ_H_INCLUDED_ #define _SORTSEQ_H_INCLUDED_ -/* @(#$Id: sortseq.h,v 1.2 2005-12-02 16:18:20 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: sortseq.h,v 1.3 2006-01-11 15:08:22 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -24,7 +24,8 @@ class RclSortSpec { */ class DocSeqSorted : public DocSequence { public: - DocSeqSorted(DocSequence &iseq, int cnt, RclSortSpec &sortspec); + DocSeqSorted(DocSequence &iseq, int cnt, RclSortSpec &sortspec, + const std::string &t); virtual ~DocSeqSorted() {} virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0); virtual int getResCnt() {return m_count;} diff --git a/src/rcldb/rcldb.cpp b/src/rcldb/rcldb.cpp index 86764b55..45a472a0 100644 --- a/src/rcldb/rcldb.cpp +++ b/src/rcldb/rcldb.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.50 2006-01-10 12:55:51 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.51 2006-01-11 15:08:21 dockes Exp $ (C) 2004 J.F.Dockes"; #endif #include #include @@ -136,7 +136,7 @@ bool Rcl::Db::open(const string& dir, OpenMode mode) } catch (...) { ermsg = "Caught unknown exception"; } - LOGERR(("Rcl::Db::open: exception while opening '%s': %s\n", + LOGERR(("Rcl::Db::open: exception while opening [%s]: %s\n", dir.c_str(), ermsg)); return false; } @@ -578,7 +578,7 @@ bool Rcl::Db::createStemDb(const string& lang) string::iterator sit = (*it).begin(), eit = sit + (*it).length(); if ((sit = find_if(sit, eit, p_notlowerorutf)) != eit) { ++nostem; - // LOGDEB(("stemskipped: '%s', because of 0x%x\n", + // LOGDEB(("stemskipped: [%s], because of 0x%x\n", // (*it).c_str(), *sit)); continue; } @@ -631,7 +631,7 @@ bool Rcl::Db::createStemDb(const string& lang) ermsg = "Caught unknown exception"; } if (ermsg != "NOERROR") { - LOGERR(("Rcl::Db::createstemdb: exception while opening '%s': %s\n", + LOGERR(("Rcl::Db::createstemdb: exception while opening [%s]: %s\n", stemdbdir.c_str(), ermsg)); return false; } @@ -754,7 +754,7 @@ static list stemexpand(Native *ndb, string term, const string& lang) try { Xapian::Stem stemmer(lang); string stem = stemmer.stem_word(term); - LOGDEB(("stemexpand: '%s' stem-> '%s'\n", term.c_str(), stem.c_str())); + LOGDEB(("stemexpand: [%s] stem-> [%s]\n", term.c_str(), stem.c_str())); // Try to fetch the doc from the stem db string stemdbdir = stemdbname(ndb->basedir, lang); Xapian::Database sdb(stemdbdir); @@ -824,9 +824,12 @@ class wsQData : public TextSplitCB { // Turn string into list of xapian queries. There is little // interpretation done on the string (no +term -term or filename:term // stuff). We just separate words and phrases, and interpret -// capitalized terms as wanting no stem expansion. Elements of the -// list corresponding to a stem-expanded part are an OR query of the -// expanded elements +// capitalized terms as wanting no stem expansion. +// The final list contains one query for each term or phrase +// - Elements corresponding to a stem-expanded part are an OP_OR +// composition of the stem-expanded terms (or a single term query). +// - Elements corresponding to a phrase are an OP_PHRASE composition of the +// phrase terms (no stem expansion in this case) static void stringToXapianQueries(const string &iq, const string& stemlang, Native *ndb, @@ -848,7 +851,7 @@ static void stringToXapianQueries(const string &iq, wsQData splitData; TextSplit splitter(&splitData, true); splitter.text_to_words(*it); - LOGDEB(("strToXapianQ: splitter term count: %d\n", + LOGDEB1(("strToXapianQ: splitter term count: %d\n", splitData.terms.size())); switch(splitData.terms.size()) { case 0: continue;// ?? @@ -869,7 +872,7 @@ static void stringToXapianQueries(const string &iq, nostemexp = true; } } - LOGDEB(("Term: %s stem expansion: %s\n", + LOGDEB1(("Term: %s stem expansion: %s\n", term.c_str(), nostemexp?"no":"yes")); list exp; @@ -903,7 +906,7 @@ static void stringToXapianQueries(const string &iq, bool Rcl::Db::setQuery(const std::string &iqstring, QueryOpts opts, const string& stemlang) { - LOGDEB(("Rcl::Db::setQuery: q: '%s', opts 0x%x, stemlang %s\n", + LOGDEB(("Rcl::Db::setQuery: q: [%s], opts 0x%x, stemlang %s\n", iqstring.c_str(), (unsigned int)opts, stemlang.c_str())); Native *ndb = (Native *)pdata; if (!ndb) @@ -1011,6 +1014,11 @@ bool Rcl::Db::setQuery(AdvSearchData &sdata, QueryOpts opts, ndb->enquire = new Xapian::Enquire(ndb->db); ndb->enquire->set_query(ndb->query); ndb->mset = Xapian::MSet(); + // Get the query description and trim the "Xapian::Query" + sdata.description = ndb->query.get_description(); + if (sdata.description.find("Xapian::Query") == 0) + sdata.description = sdata.description.substr(strlen("Xapian::Query")); + LOGDEB(("Rcl::Db::SetQuery: Q: %s\n", sdata.description.c_str())); return true; } @@ -1169,7 +1177,7 @@ bool Rcl::Db::getDoc(int exti, Doc &doc, int *percent) last = first + ndb->mset.size() -1; } - LOGDEB1(("Rcl::Db::getDoc: Qry '%s' win [%d-%d] Estimated results: %d", + LOGDEB1(("Rcl::Db::getDoc: Qry [%s] win [%d-%d] Estimated results: %d", ndb->query.get_description().c_str(), first, last, ndb->mset.get_matches_lower_bound())); diff --git a/src/rcldb/rcldb.h b/src/rcldb/rcldb.h index 6cce5c4b..eb04ae7b 100644 --- a/src/rcldb/rcldb.h +++ b/src/rcldb/rcldb.h @@ -1,6 +1,6 @@ #ifndef _DB_H_INCLUDED_ #define _DB_H_INCLUDED_ -/* @(#$Id: rcldb.h,v 1.21 2006-01-09 16:53:31 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: rcldb.h,v 1.22 2006-01-11 15:08:21 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -76,10 +76,12 @@ class AdvSearchData { string nowords; list filetypes; // restrict to types. Empty if inactive string topdir; // restrict to subtree. Empty if inactive - + string description; // Printable expanded version of the complete query + // returned after setQuery. void erase() { allwords.erase();phrase.erase();orwords.erase();nowords.erase(); filetypes.clear(); topdir.erase(); + description.clear(); } };