Add possibility to display a list of sub-documents for a given result
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "filtseq.h"
|
||||
#include "sortseq.h"
|
||||
#include "debuglog.h"
|
||||
#include "internfile.h"
|
||||
|
||||
string DocSequence::o_sort_trans;
|
||||
string DocSequence::o_filt_trans;
|
||||
@@ -35,6 +36,19 @@ int DocSequence::getSeqSlice(int offs, int cnt, vector<ResListEntry>& result)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DocSequence::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
|
||||
{
|
||||
// Note: no need for setQuery here, we're just passing through a
|
||||
// query-independant request
|
||||
|
||||
string udi;
|
||||
if (!FileInterner::getEnclosing(doc.url, doc.ipath, pdoc.url, pdoc.ipath,
|
||||
udi))
|
||||
return false;
|
||||
bool dbret = getDb()->getDoc(udi, pdoc);
|
||||
return dbret && pdoc.pc != -1;
|
||||
}
|
||||
|
||||
// Remove stacked modifying sources (sort, filter) until we get to a real one
|
||||
void DocSource::stripStack()
|
||||
{
|
||||
@@ -107,3 +121,4 @@ bool DocSource::setSortSpec(const DocSeqSortSpec &s)
|
||||
buildStack();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+23
-3
@@ -114,7 +114,7 @@ class DocSequence {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool getEnclosing(Rcl::Doc&, Rcl::Doc&) = 0;
|
||||
virtual bool getEnclosing(Rcl::Doc&, Rcl::Doc&);
|
||||
|
||||
/** Get estimated total count in results */
|
||||
virtual int getResCnt() = 0;
|
||||
@@ -159,10 +159,15 @@ class DocSequence {
|
||||
o_sort_trans = sort;
|
||||
o_filt_trans = filt;
|
||||
}
|
||||
|
||||
virtual Rcl::Db *getDb() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
static std::string o_sort_trans;
|
||||
static std::string o_filt_trans;
|
||||
std::string m_reason;
|
||||
|
||||
private:
|
||||
std::string m_title;
|
||||
};
|
||||
@@ -228,14 +233,29 @@ public:
|
||||
return string();
|
||||
return m_seq->getReason();
|
||||
}
|
||||
virtual std::string title() {return m_seq->title();}
|
||||
virtual RefCntr<DocSequence> getSourceSeq() {return m_seq;}
|
||||
virtual std::string title()
|
||||
{
|
||||
return m_seq->title();
|
||||
}
|
||||
virtual RefCntr<DocSequence> getSourceSeq()
|
||||
{
|
||||
return m_seq;
|
||||
}
|
||||
|
||||
virtual Rcl::Db *getDb()
|
||||
{
|
||||
if (m_seq.isNull())
|
||||
return 0;
|
||||
return m_seq->getDb();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
RefCntr<DocSequence> m_seq;
|
||||
};
|
||||
|
||||
class RclConfig;
|
||||
|
||||
// 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 {
|
||||
|
||||
+2
-11
@@ -23,7 +23,6 @@ using std::list;
|
||||
#include "docseqdb.h"
|
||||
#include "rcldb.h"
|
||||
#include "debuglog.h"
|
||||
#include "internfile.h"
|
||||
#include "wasatorcl.h"
|
||||
|
||||
DocSequenceDb::DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
|
||||
@@ -129,17 +128,9 @@ int DocSequenceDb::getFirstMatchPage(Rcl::Doc &doc, string& term)
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool DocSequenceDb::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
|
||||
Rcl::Db *DocSequenceDb::getDb()
|
||||
{
|
||||
// Note: no need for setQuery here, we're just passing through a
|
||||
// query-independant request
|
||||
|
||||
string udi;
|
||||
if (!FileInterner::getEnclosing(doc.url, doc.ipath, pdoc.url, pdoc.ipath,
|
||||
udi))
|
||||
return false;
|
||||
bool dbret = m_q->whatDb()->getDoc(udi, pdoc);
|
||||
return dbret && pdoc.pc != -1;
|
||||
return m_q.isNotNull() ? m_q->whatDb() : 0;
|
||||
}
|
||||
|
||||
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
|
||||
|
||||
@@ -38,7 +38,7 @@ class DocSequenceDb : public DocSequence {
|
||||
|
||||
virtual bool getAbstract(Rcl::Doc &doc, vector<string>&);
|
||||
virtual int getFirstMatchPage(Rcl::Doc&, std::string& term);
|
||||
virtual bool getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc);
|
||||
virtual Rcl::Db *getDb();
|
||||
virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups);
|
||||
virtual string getDescription();
|
||||
virtual list<string> expand(Rcl::Doc &doc);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* Copyright (C) 2004-2013 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.
|
||||
*/
|
||||
#ifndef _DOCSEQDOCS_H_INCLUDED_
|
||||
#define _DOCSEQDOCS_H_INCLUDED_
|
||||
|
||||
#include "docseq.h"
|
||||
#include "rcldoc.h"
|
||||
|
||||
namespace Rcl {
|
||||
class Db;
|
||||
}
|
||||
|
||||
/** A DocSequence that's just built from a bunch of docs */
|
||||
class DocSequenceDocs : public DocSequence {
|
||||
public:
|
||||
DocSequenceDocs(Rcl::Db *d, const std::vector<Rcl::Doc> docs,
|
||||
const string &t)
|
||||
: DocSequence(t), m_db(d), m_docs(docs)
|
||||
{
|
||||
}
|
||||
virtual ~DocSequenceDocs()
|
||||
{
|
||||
}
|
||||
virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0)
|
||||
{
|
||||
if (sh)
|
||||
*sh = string();
|
||||
if (num < 0 || num >= int(m_docs.size()))
|
||||
return false;
|
||||
doc = m_docs[num];
|
||||
return true;
|
||||
}
|
||||
virtual Rcl::Db *getDb()
|
||||
{
|
||||
return m_db;
|
||||
}
|
||||
virtual int getResCnt()
|
||||
{
|
||||
return m_docs.size();
|
||||
}
|
||||
virtual string getDescription()
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
void setDescription(const string& desc)
|
||||
{
|
||||
m_description = desc;
|
||||
}
|
||||
private:
|
||||
Rcl::Db *m_db;
|
||||
string m_description;
|
||||
std::vector<Rcl::Doc> m_docs;
|
||||
};
|
||||
|
||||
#endif /* _DOCSEQ_H_INCLUDED_ */
|
||||
@@ -25,7 +25,6 @@ using std::list;
|
||||
#include "docseqhist.h"
|
||||
#include "rcldb.h"
|
||||
#include "fileudi.h"
|
||||
#include "internfile.h"
|
||||
#include "base64.h"
|
||||
#include "debuglog.h"
|
||||
#include "smallut.h"
|
||||
@@ -145,14 +144,9 @@ bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, string *sh)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DocSequenceHistory::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
|
||||
Rcl::Db *DocSequenceHistory::getDb()
|
||||
{
|
||||
string udi;
|
||||
if (!FileInterner::getEnclosing(doc.url, doc.ipath, pdoc.url, pdoc.ipath,
|
||||
udi))
|
||||
return false;
|
||||
bool dbret = m_db->getDoc(udi, pdoc);
|
||||
return dbret && pdoc.pc != -1;
|
||||
return m_db;
|
||||
}
|
||||
|
||||
int DocSequenceHistory::getResCnt()
|
||||
|
||||
@@ -48,7 +48,7 @@ class DocSequenceHistory : public DocSequence {
|
||||
virtual ~DocSequenceHistory() {}
|
||||
|
||||
virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0);
|
||||
virtual bool getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc);
|
||||
virtual Rcl::Db *getDb();
|
||||
virtual int getResCnt();
|
||||
virtual string getDescription() {return m_description;}
|
||||
void setDescription(const string& desc) {m_description = desc;}
|
||||
|
||||
Reference in New Issue
Block a user