try to limit the places which use Rcl:: stuff

This commit is contained in:
dockes 2007-01-19 15:22:50 +00:00
parent 6b394537b2
commit ddb1bdca07
13 changed files with 94 additions and 96 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: plaintorich.cpp,v 1.19 2006-12-11 14:56:38 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: plaintorich.cpp,v 1.20 2007-01-19 15:22:50 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -68,8 +68,9 @@ class myTextSplitCB : public TextSplitCB {
// Out: begin and end byte positions of query terms/groups in text
vector<pair<int, int> > tboffs;
myTextSplitCB(const vector<string>& its, vector<vector<string> >&groups,
vector<int>& slacks)
myTextSplitCB(const vector<string>& its,
const vector<vector<string> >&groups,
const vector<int>& slacks)
: firstTermOcc(1), m_wcount(0), m_groups(groups), m_slacks(slacks)
{
for (vector<string>::const_iterator it = its.begin();
@ -316,16 +317,14 @@ const char *firstTermBeacon = "\xe2\xa0\x91\xe2\x96\x9f\x20\x01\x9a";
// we return the first term encountered, and the caller will use the
// editor's find() function to position on it
bool plaintorich(const string& in, string& out,
RefCntr<Rcl::SearchData> sdata,
const HiliteData& hdata,
bool noHeader, bool fft)
{
Chrono chron;
out.erase();
vector<string> terms;
vector<vector<string> > groups;
vector<int> slacks;
sdata->getTerms(terms, groups, slacks);
const vector<string>& terms(hdata.terms);
const vector<vector<string> >& groups(hdata.groups);
const vector<int>& slacks(hdata.gslks);
if (DebugLog::getdbl()->getlevel() >= DEBDEB0) {
LOGDEB0(("plaintorich: terms: \n"));
@ -333,7 +332,7 @@ bool plaintorich(const string& in, string& out,
LOGDEB0((" %s\n", sterms.c_str()));
sterms = "\n";
LOGDEB0(("plaintorich: groups: \n"));
for (vector<vector<string> >::iterator vit = groups.begin();
for (vector<vector<string> >::const_iterator vit = groups.begin();
vit != groups.end(); vit++) {
sterms += vecStringToString(*vit);
sterms += "\n";

View File

@ -16,11 +16,16 @@
*/
#ifndef _PLAINTORICH_H_INCLUDED_
#define _PLAINTORICH_H_INCLUDED_
/* @(#$Id: plaintorich.h,v 1.11 2006-11-30 13:38:44 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: plaintorich.h,v 1.12 2007-01-19 15:22:50 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include "searchdata.h"
// A data struct to hold words and groups of words to be highlighted
struct HiliteData {
vector<string> terms;
vector<vector<string> > groups;
vector<int> gslks; // group slacks (number of permitted non-matched words)
};
/**
* Transform plain text into qt rich text for the preview window.
@ -31,13 +36,13 @@
*
* @param in raw text out of internfile.
* @param out rich text output
* @param terms list of query terms. These are out of Rcl::Db and dumb
* @param firstTerm out: value of the first search term in text.
* @param frsttocc out: occurrence of 1st term to look for
* @param hdata terms and groups to be highlighted. These are
* lowercase and unaccented.
* @param noHeader if true don't output header (<qt><title>...)
* @param fft If true mark the first term position in the text
*/
extern bool plaintorich(const string &in, string &out,
RefCntr<Rcl::SearchData> sdata,
const HiliteData& hdata,
bool noHeader = false,
bool fft = false);

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.13 2006-12-20 14:09:21 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.14 2007-01-19 15:22:50 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -497,12 +497,12 @@ class LoadThread : public QThread {
/* A thread to convert to rich text (mark search terms) */
class ToRichThread : public QThread {
string &in;
RefCntr<Rcl::SearchData> m_searchData;
const HiliteData &hdata;
QString &out;
int loglevel;
public:
ToRichThread(string &i, RefCntr<Rcl::SearchData> searchData, QString &o)
: in(i), m_searchData(searchData), out(o)
ToRichThread(string &i, const HiliteData& hd, QString &o)
: in(i), hdata(hd), out(o)
{
loglevel = DebugLog::getdbl()->getlevel();
}
@ -511,7 +511,7 @@ class ToRichThread : public QThread {
DebugLog::getdbl()->setloglevel(loglevel);
string rich;
try {
plaintorich(in, rich, m_searchData, false, true);
plaintorich(in, rich, hdata, false, true);
} catch (CancelExcept) {
}
out = QString::fromUtf8(rich.c_str(), rich.length());
@ -599,7 +599,7 @@ bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc,
bool highlightTerms = fdoc.text.length() < 1000 *1024;
if (highlightTerms) {
progress.setLabelText(tr("Creating preview text"));
ToRichThread rthr(fdoc.text, m_searchData, richTxt);
ToRichThread rthr(fdoc.text, m_hData, richTxt);
rthr.start();
for (;;prog++) {

View File

@ -1,6 +1,6 @@
#ifndef _PREVIEW_W_H_INCLUDED_
#define _PREVIEW_W_H_INCLUDED_
/* @(#$Id: preview_w.h,v 1.7 2006-12-04 09:56:26 dockes Exp $ (C) 2006 J.F.Dockes */
/* @(#$Id: preview_w.h,v 1.8 2007-01-19 15:22:50 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
@ -29,7 +29,7 @@
#define QTextEdit Q3TextEdit
#endif
#include "refcntr.h"
#include "searchdata.h"
#include "plaintorich.h"
// We keep a list of data associated to each tab
class TabData {
@ -69,10 +69,10 @@ public:
~Preview(){}
virtual void setSId(int sid, RefCntr<Rcl::SearchData> sdata)
virtual void setSId(int sid, const HiliteData& hdata)
{
m_searchId = sid;
m_searchData = sdata;
m_hData = hdata;
}
virtual void closeEvent( QCloseEvent *e );
virtual bool eventFilter( QObject *target, QEvent *event );
@ -111,7 +111,7 @@ private:
bool canBeep;
list<TabData> tabData;
QWidget *currentW;
RefCntr<Rcl::SearchData> m_searchData;
HiliteData m_hData;
void init();
virtual void destroy();
TabData *tabDataForCurrent(); // Return auxiliary data pointer for cur tab

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.23 2007-01-19 10:32:39 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.24 2007-01-19 15:22:50 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -380,8 +380,10 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
return;
}
curPreview = 0;
DocSequenceDb *src =
new DocSequenceDb(rcldb, string(tr("Query results").utf8()), sdata);
m_docSource = RefCntr<DocSequence>(src);
m_searchData = sdata;
m_docSource = RefCntr<DocSequence>(new DocSequenceDb(rcldb, string(tr("Query results").utf8())));
setDocSequence();
}
@ -404,7 +406,7 @@ void RclMain::setDocSequence()
docsource = m_docSource;
}
m_searchId++;
resList->setDocSource(docsource, m_searchData);
resList->setDocSource(docsource);
}
// Open advanced search dialog.
@ -531,7 +533,9 @@ void RclMain::startPreview(int docnum, int mod)
QMessageBox::NoButton);
return;
}
curPreview->setSId(m_searchId, resList->getSearchData());
HiliteData hdata;
m_searchData->getTerms(hdata.terms, hdata.groups, hdata.gslks);
curPreview->setSId(m_searchId, hdata);
curPreview->setCaption(resList->getDescription());
connect(curPreview, SIGNAL(previewClosed(QWidget *)),
this, SLOT(previewClosed(QWidget *)));
@ -582,8 +586,7 @@ void RclMain::startPreview(Rcl::Doc doc)
QMessageBox::NoButton);
return;
}
RefCntr<Rcl::SearchData> searchdata(new Rcl::SearchData(Rcl::SCLT_AND));
preview->setSId(0, searchdata);
preview->setSId(0, HiliteData());
connect(preview, SIGNAL(wordSelect(QString)),
this, SLOT(ssearchAddTerm(QString)));
g_dynconf->enterDoc(fn, doc.ipath);
@ -868,9 +871,11 @@ void RclMain::showDocHistory()
m_searchId++;
m_docSource = RefCntr<DocSequence>(new DocSequenceHistory(rcldb,
g_dynconf,
string(tr("Document history").utf8())));
DocSequenceHistory *src =
new DocSequenceHistory(rcldb, g_dynconf,
string(tr("Document history").utf8()));
src->setDescription((const char *)tr("History data").utf8());
m_docSource = RefCntr<DocSequence>(src);
setDocSequence();
}

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.20 2007-01-19 10:32:39 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.21 2007-01-19 15:22:50 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <time.h>
@ -85,12 +85,10 @@ void ResList::languageChange()
}
// Acquire new docsource
void ResList::setDocSource(RefCntr<DocSequence> docsource,
RefCntr<Rcl::SearchData> sdt)
void ResList::setDocSource(RefCntr<DocSequence> docsource)
{
m_winfirst = -1;
m_docSource = docsource;
m_searchData = sdt;
m_curPvDoc = -1;
resultPageNext();
@ -351,6 +349,9 @@ void ResList::resultPageNext()
append(chunk);
HiliteData hdata;
m_docSource->getTerms(hdata.terms, hdata.groups, hdata.gslks);
// Insert results in result list window. We have to actually send
// the text to the widget (instead of setting the whole at the
// end), because we need the paragraph number each time we add a
@ -443,7 +444,7 @@ void ResList::resultPageNext()
}
string richabst;
plaintorich(abstract, richabst, m_searchData, true);
plaintorich(abstract, richabst, hdata, true);
// Links;
string linksbuf;
@ -682,7 +683,7 @@ void ResList::menuExpand()
QString ResList::getDescription()
{
return QString::fromUtf8(m_searchData->getDescription().c_str());
return QString::fromUtf8(m_docSource->getDescription().c_str());
}
/** Show detailed expansion of a query */
@ -692,7 +693,7 @@ void ResList::showQueryDetails()
// Also limit the total number of lines.
const unsigned int ll = 100;
const unsigned int maxlines = 50;
string query = m_searchData->getDescription();
string query = m_docSource->getDescription();
string oq;
unsigned int nlines = 0;
while (query.length() > 0) {

View File

@ -1,6 +1,6 @@
#ifndef _RESLIST_H_INCLUDED_
#define _RESLIST_H_INCLUDED_
/* @(#$Id: reslist.h,v 1.8 2007-01-08 10:01:55 dockes Exp $ (C) 2005 J.F.Dockes */
/* @(#$Id: reslist.h,v 1.9 2007-01-19 15:22:50 dockes Exp $ (C) 2005 J.F.Dockes */
#include <list>
@ -20,12 +20,9 @@ class Q3PopupMenu;
#define QTEXTBROWSER Q3TextBrowser
#endif
#include "rcldb.h"
#include "docseq.h"
#include "searchdata.h"
#include "refcntr.h"
class ResList : public QTEXTBROWSER
{
Q_OBJECT;
@ -40,12 +37,10 @@ class ResList : public QTEXTBROWSER
// num is inside the current page or its immediate neighbours.
virtual bool getDoc(int docnum, Rcl::Doc &);
virtual void setDocSource(RefCntr<DocSequence> source,
RefCntr<Rcl::SearchData> qdata);
virtual void setDocSource(RefCntr<DocSequence> source);
virtual RCLPOPUP *createPopupMenu(const QPoint& pos);
virtual QString getDescription(); // Printable actual query performed on db
virtual int getResCnt(); // Return total result list size
virtual RefCntr<Rcl::SearchData> getSearchData() {return m_searchData;}
public slots:
virtual void resetSearch();
@ -86,7 +81,6 @@ class ResList : public QTEXTBROWSER
private:
std::map<int,int> m_pageParaToReldocnums;
RefCntr<Rcl::SearchData> m_searchData;
RefCntr<DocSequence> m_docSource;
std::vector<Rcl::Doc> m_curDocs;
int m_winfirst;

View File

@ -16,7 +16,7 @@
*/
#ifndef _DOCSEQ_H_INCLUDED_
#define _DOCSEQ_H_INCLUDED_
/* @(#$Id: docseq.h,v 1.10 2007-01-19 10:32:39 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: docseq.h,v 1.11 2007-01-19 15:22:50 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include <list>
#include <vector>
@ -79,9 +79,16 @@ class DocSequence {
/** Get title for result list */
virtual string title() {return m_title;}
/** Get description for underlying query */
virtual string getDescription() = 0;
/** Get search terms (for highlighting abstracts). Some sequences
* may have no associated search terms. Implement this for them. */
virtual void getTerms(list<string>& t) {t.clear();}
virtual bool getTerms(vector<string>& terms,
vector<vector<string> >& groups,
vector<int>& gslks) const {
terms.clear(); groups.clear(); gslks.clear(); return true;
}
private:
string m_title;

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.1 2007-01-19 10:32:39 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.2 2007-01-19 15:22:50 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -39,13 +39,6 @@ int DocSequenceDb::getResCnt()
return m_rescnt;
}
void DocSequenceDb::getTerms(list<string> &terms)
{
if (!m_db)
return;
m_db->getQueryTerms(terms);
}
string DocSequenceDb::getAbstract(Rcl::Doc &doc)
{
if (!m_db)

View File

@ -16,35 +16,35 @@
*/
#ifndef _DOCSEQDB_H_INCLUDED_
#define _DOCSEQDB_H_INCLUDED_
/* @(#$Id: docseqdb.h,v 1.1 2007-01-19 10:32:39 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include <list>
#ifndef NO_NAMESPACES
using std::string;
using std::list;
#endif
/* @(#$Id: docseqdb.h,v 1.2 2007-01-19 15:22:50 dockes Exp $ (C) 2004 J.F.Dockes */
#include "docseq.h"
namespace Rcl {
class Db;
}
#include "refcntr.h"
#include "searchdata.h"
/** A DocSequence from a Db query (there should be one active for this
to make sense */
to make sense) */
class DocSequenceDb : public DocSequence {
public:
DocSequenceDb(Rcl::Db *d, const string &t) :
DocSequence(t), m_db(d), m_rescnt(-1)
DocSequenceDb(Rcl::Db *d, const string &t, RefCntr<Rcl::SearchData> sdata)
: DocSequence(t), m_db(d), m_sdata(sdata), m_rescnt(-1)
{}
virtual ~DocSequenceDb() {}
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string * = 0);
virtual int getResCnt();
virtual void getTerms(list<string>&);
virtual bool getTerms(vector<string>& terms,
vector<vector<string> >& groups,
vector<int>& gslks) const {
return m_sdata.getptr()->getTerms(terms, groups, gslks);
}
virtual string getAbstract(Rcl::Doc &doc);
virtual string getDescription() {return m_sdata->getDescription();}
private:
Rcl::Db *m_db;
int m_rescnt;
Rcl::Db *m_db;
RefCntr<Rcl::SearchData> m_sdata;
int m_rescnt;
};
#endif /* _DOCSEQDB_H_INCLUDED_ */

View File

@ -16,20 +16,14 @@
*/
#ifndef _DOCSEQHIST_H_INCLUDED_
#define _DOCSEQHIST_H_INCLUDED_
/* @(#$Id: docseqhist.h,v 1.1 2007-01-19 10:32:39 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include <list>
#ifndef NO_NAMESPACES
using std::string;
using std::list;
#endif
/* @(#$Id: docseqhist.h,v 1.2 2007-01-19 15:22:50 dockes Exp $ (C) 2004 J.F.Dockes */
#include "docseq.h"
#include "history.h"
namespace Rcl {
class Db;
class Db;
}
class RclHistory;
/** A DocSequence coming from the history file.
* History is kept as a list of urls. This queries the db to fetch
@ -42,12 +36,14 @@ class DocSequenceHistory : public DocSequence {
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0);
virtual int getResCnt();
virtual string getDescription() {return m_description;}
void setDescription(const string& desc) {m_description = desc;}
private:
Rcl::Db *m_db;
RclHistory *m_hist;
int m_prevnum;
long m_prevtime;
string m_description; // This is just an nls translated 'doc history'
list<RclDHistoryEntry> m_hlist;
list<RclDHistoryEntry>::const_iterator m_it;
};

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.10 2007-01-19 10:32:39 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.11 2007-01-19 15:22:50 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -120,8 +120,3 @@ bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, int *percent, string *)
doc = *m_docsp[num];
return true;
}
string DocSeqSorted::getAbstract(Rcl::Doc& doc)
{
return m_seq->getAbstract(doc);
}

View File

@ -16,7 +16,7 @@
*/
#ifndef _SORTSEQ_H_INCLUDED_
#define _SORTSEQ_H_INCLUDED_
/* @(#$Id: sortseq.h,v 1.9 2007-01-19 10:32:39 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: sortseq.h,v 1.10 2007-01-19 15:22:50 dockes Exp $ (C) 2004 J.F.Dockes */
#include <vector>
#include <string>
@ -48,7 +48,10 @@ class DocSeqSorted : public DocSequence {
virtual ~DocSeqSorted() {}
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0);
virtual int getResCnt() {return m_spec.sortwidth;}
virtual string getAbstract(Rcl::Doc& doc);
virtual string getAbstract(Rcl::Doc& doc) {
return m_seq->getAbstract(doc);
}
virtual string getDescription() {return m_seq->getDescription();}
private:
RefCntr<DocSequence> m_seq;