--- a/src/query/docseq.cpp
+++ b/src/query/docseq.cpp
@@ -1,5 +1,5 @@
#ifndef lint
-static char rcsid[] = "@(#$Id: docseq.cpp,v 1.3 2005-12-05 12:02:01 dockes Exp $ (C) 2005 J.F.Dockes";
+static char rcsid[] = "@(#$Id: docseq.cpp,v 1.4 2005-12-05 16:13:12 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <math.h>
@@ -8,61 +8,64 @@
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, int *percent, string *sh)
{
if (sh) sh->erase();
- return db ? db->getDoc(num, doc, percent) : false;
+ return m_db ? m_db->getDoc(num, doc, percent) : false;
}
int DocSequenceDb::getResCnt()
{
- if (!db)
+ if (!m_db)
return -1;
// Need to fetch one document before we can get the result count
- Rcl::Doc doc;
- int percent;
- db->getDoc(0, doc, &percent);
- return db->getResCnt();
+ if (m_rescnt < 0) {
+ Rcl::Doc doc;
+ int percent;
+ m_db->getDoc(0, doc, &percent);
+ m_rescnt= m_db->getResCnt();
+ }
+ return m_rescnt;
}
bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, int *percent,
string *sh) {
// Retrieve history list
- if (!hist)
+ if (!m_hist)
return false;
- if (hlist.empty())
- hlist = hist->getDocHistory();
+ if (m_hlist.empty())
+ m_hlist = m_hist->getDocHistory();
- if (num < 0 || num >= (int)hlist.size())
+ if (num < 0 || num >= (int)m_hlist.size())
return false;
int skip;
- if (prevnum >= 0 && num >= prevnum) {
- skip = num - prevnum;
+ if (m_prevnum >= 0 && num >= m_prevnum) {
+ skip = num - m_prevnum;
} else {
skip = num;
- it = hlist.begin();
- prevtime = -1;
+ m_it = m_hlist.begin();
+ m_prevtime = -1;
}
- prevnum = num;
+ m_prevnum = num;
while (skip--)
- it++;
+ m_it++;
if (percent)
*percent = 100;
if (sh) {
- if (prevtime < 0 || abs(prevtime - (*it).unixtime) > 86400) {
- prevtime = it->unixtime;
- time_t t = (time_t)(it->unixtime);
+ if (m_prevtime < 0 || abs(m_prevtime - m_it->unixtime) > 86400) {
+ m_prevtime = m_it->unixtime;
+ time_t t = (time_t)(m_it->unixtime);
*sh = string(ctime(&t));
// Get rid of the final \n in ctime
sh->erase(sh->length()-1);
} else
sh->erase();
}
- return db->getDoc((*it).fn, (*it).ipath, doc);
+ return m_db->getDoc(m_it->fn, m_it->ipath, doc);
}
int DocSequenceHistory::getResCnt()
{
- if (hlist.empty())
- hlist = hist->getDocHistory();
- return hlist.size();
+ if (m_hlist.empty())
+ m_hlist = m_hist->getDocHistory();
+ return m_hlist.size();
}