|
a/src/query/docseq.cpp |
|
b/src/query/docseq.cpp |
|
... |
|
... |
15 |
* You should have received a copy of the GNU General Public License
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the
|
16 |
* along with this program; if not, write to the
|
17 |
* Free Software Foundation, Inc.,
|
17 |
* Free Software Foundation, Inc.,
|
18 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
18 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
19 |
*/
|
19 |
*/
|
20 |
#include <math.h>
|
|
|
21 |
#include <time.h>
|
|
|
22 |
|
|
|
23 |
#include "docseq.h"
|
20 |
#include "docseq.h"
|
|
|
21 |
#include "filtseq.h"
|
|
|
22 |
#include "sortseq.h"
|
|
|
23 |
#include "debuglog.h"
|
24 |
|
24 |
|
25 |
int DocSequence::getSeqSlice(int offs, int cnt, vector<ResListEntry>& result)
|
25 |
int DocSequence::getSeqSlice(int offs, int cnt, vector<ResListEntry>& result)
|
26 |
{
|
26 |
{
|
27 |
int ret = 0;
|
27 |
int ret = 0;
|
28 |
for (int num = offs; num < offs + cnt; num++, ret++) {
|
28 |
for (int num = offs; num < offs + cnt; num++, ret++) {
|
|
... |
|
... |
33 |
}
|
33 |
}
|
34 |
}
|
34 |
}
|
35 |
return ret;
|
35 |
return ret;
|
36 |
}
|
36 |
}
|
37 |
|
37 |
|
|
|
38 |
void DocSource::unwind()
|
|
|
39 |
{
|
|
|
40 |
RefCntr<DocSequence> base = m_seq;
|
|
|
41 |
while (!m_seq.isNull() && !(m_seq->getSourceSeq()).isNull()) {
|
|
|
42 |
base = m_seq->getSourceSeq();
|
|
|
43 |
}
|
|
|
44 |
m_seq = base;
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
bool DocSource::buildStack()
|
|
|
48 |
{
|
|
|
49 |
LOGDEB2(("DocSource::buildStack()\n"));
|
|
|
50 |
unwind();
|
|
|
51 |
|
|
|
52 |
if (m_seq.isNull())
|
|
|
53 |
return false;
|
|
|
54 |
|
|
|
55 |
// Filtering must be done before sorting, (which may
|
|
|
56 |
// truncates the original list)
|
|
|
57 |
if (m_seq->canFilter()) {
|
|
|
58 |
if (!m_seq->setFiltSpec(m_fspec)) {
|
|
|
59 |
LOGERR(("DocSource::buildStack: setfiltspec failed\n"));
|
|
|
60 |
}
|
|
|
61 |
} else {
|
|
|
62 |
if (m_fspec.isNotNull()) {
|
|
|
63 |
m_seq =
|
|
|
64 |
RefCntr<DocSequence>(new DocSeqFiltered(m_seq, m_fspec));
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
if (m_seq->canSort()) {
|
|
|
69 |
if (!m_seq->setSortSpec(m_sspec)) {
|
|
|
70 |
LOGERR(("DocSource::buildStack: setsortspec failed\n"));
|
|
|
71 |
}
|
|
|
72 |
} else {
|
|
|
73 |
if (m_sspec.isNotNull()) {
|
|
|
74 |
m_seq = RefCntr<DocSequence>(new DocSeqSorted(m_seq, m_sspec));
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
return true;
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
string DocSource::o_sort_trans;
|
|
|
81 |
string DocSource::o_filt_trans;
|
|
|
82 |
|
|
|
83 |
string DocSource::title()
|
|
|
84 |
{
|
|
|
85 |
string qual;
|
|
|
86 |
if (m_fspec.isNotNull() && !m_sspec.isNotNull())
|
|
|
87 |
qual = string(" (") + o_filt_trans + string(")");
|
|
|
88 |
else if (!m_fspec.isNotNull() && m_sspec.isNotNull())
|
|
|
89 |
qual = string(" (") + o_sort_trans + string(")");
|
|
|
90 |
else if (m_fspec.isNotNull() && m_sspec.isNotNull())
|
|
|
91 |
qual = string(" (") + o_sort_trans + string(",") + o_filt_trans + string(")");
|
|
|
92 |
return m_seq->title() + qual;
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
bool DocSource::setFiltSpec(const DocSeqFiltSpec &f)
|
|
|
96 |
{
|
|
|
97 |
LOGDEB2(("DocSource::setFiltSpec\n"));
|
|
|
98 |
m_fspec = f;
|
|
|
99 |
buildStack();
|
|
|
100 |
return true;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
bool DocSource::setSortSpec(const DocSeqSortSpec &s)
|
|
|
104 |
{
|
|
|
105 |
LOGDEB2(("DocSource::setSortSpec\n"));
|
|
|
106 |
m_sspec = s;
|
|
|
107 |
buildStack();
|
|
|
108 |
return true;
|
|
|
109 |
}
|