Parent: [3e3114] (diff)

Child: [fb2994] (diff)

Download this file

reslistpager.h    100 lines (88 with data), 2.5 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef _reslistpager_h_included_
#define _reslistpager_h_included_
/* @(#$Id: reslistpager.h,v 1.4 2008-12-16 14:20:10 dockes Exp $ (C) 2007 J.F.Dockes */
#include <vector>
using std::vector;
#include "refcntr.h"
#include "docseq.h"
class PlainToRich;
/**
* Manage a paged HTML result list.
*/
class ResListPager {
public:
ResListPager(int pagesize=10) : m_pagesize(pagesize) {initall();}
ResListPager(RefCntr<DocSequence> src, int pagesize)
: m_pagesize(pagesize)
{
initall();
m_docSource = src;
}
virtual ~ResListPager() {}
void setHighLighter(PlainToRich *ptr) {m_hiliter = ptr;}
void setDocSource(RefCntr<DocSequence> src)
{
m_winfirst = -1;
m_hasNext = false;
m_respage.clear();
m_docSource = src;
}
int pageNumber()
{
if (m_winfirst < 0 || m_pagesize <= 0)
return -1;
return m_winfirst / m_pagesize;
}
virtual int pageSize() const {return m_pagesize;}
void pageNext();
bool hasNext() {return m_hasNext;}
bool hasPrev() {return m_winfirst > 0;}
bool atBot() {return m_winfirst <= 0;}
void resultPageBack() {
if (m_winfirst <= 0) return;
m_winfirst -= 2 * m_pagesize;
resultPageNext();
}
void resultPageFirst() {
m_winfirst = -1;
resultPageNext();
}
void resultPageNext();
void displayPage();
bool pageEmpty() {return m_respage.size() == 0;}
string queryDescription() {return m_docSource.isNull() ? "" :
m_docSource->getDescription();}
// Things that need to be reimplemented in the subclass:
virtual bool append(const string& data);
virtual bool append(const string& data, int, const Rcl::Doc&)
{
return append(data);
}
virtual string trans(const string& in);
virtual string detailsLink();
virtual const string &parFormat();
virtual string nextUrl();
virtual string prevUrl();
virtual string pageTop() {return string();}
virtual string iconPath(const string& mtype);
private:
void initall()
{
m_winfirst = -1;
m_hasNext = false;
m_respage.clear();
m_queryBuildAbstract = true;
m_queryReplaceAbstract = false;
m_hiliter = 0;
}
// First docnum (from docseq) in current page
int m_winfirst;
RefCntr<DocSequence> m_docSource;
const int m_pagesize;
bool m_hasNext;
vector<ResListEntry> m_respage;
bool m_queryBuildAbstract;
bool m_queryReplaceAbstract;
PlainToRich *m_hiliter;
};
#endif /* _reslistpager_h_included_ */