Parent: [0667b2] (diff)

Child: [658ffb] (diff)

Download this file

docseq.cpp    66 lines (57 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef lint
static char rcsid[] = "@(#$Id: docseq.cpp,v 1.2 2005-11-28 15:31:01 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <math.h>
#include "docseq.h"
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, int *percent, string *sh)
{
if (sh) sh->erase();
return db ? db->getDoc(num, doc, percent) : false;
}
int DocSequenceDb::getResCnt()
{
if (!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();
}
bool DocSequenceHistory::getDoc(int num, Rcl::Doc &doc, int *percent,
string *sh) {
// Retrieve history list
if (!hist)
return false;
if (hlist.empty())
hlist = hist->getDocHistory();
if (num < 0 || num >= (int)hlist.size())
return false;
int skip;
if (prevnum >= 0 && num >= prevnum) {
skip = num - prevnum;
} else {
skip = num;
it = hlist.begin();
}
prevnum = num;
while (skip--)
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);
*sh = string(ctime(&t));
} else
sh->erase();
}
return db->getDoc((*it).fn, (*it).ipath, doc);
}
int DocSequenceHistory::getResCnt()
{
if (hlist.empty())
hlist = hist->getDocHistory();
return hlist.size();
}