Switch to unified view

a/src/query/docseqdb.cpp b/src/query/docseqdb.cpp
...
...
36
      m_needSetQuery(false),
36
      m_needSetQuery(false),
37
      m_lastSQStatus(true)
37
      m_lastSQStatus(true)
38
{
38
{
39
}
39
}
40
40
41
DocSequenceDb::~DocSequenceDb() 
42
{
43
}
44
45
void DocSequenceDb::getTerms(HighlightData& hld)
41
void DocSequenceDb::getTerms(HighlightData& hld)
46
{
42
{
47
    m_fsdata->getTerms(hld);
43
    m_fsdata->getTerms(hld);
48
}
44
}
49
45
...
...
52
    return m_fsdata->getDescription();
48
    return m_fsdata->getDescription();
53
}
49
}
54
50
55
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
51
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
56
{
52
{
53
    PTMutexLocker locker(o_dblock);
57
    if (!setQuery())
54
    if (!setQuery())
58
    return false;
55
    return false;
59
    if (sh) sh->erase();
56
    if (sh) sh->erase();
60
    return m_q->getDoc(num, doc);
57
    return m_q->getDoc(num, doc);
61
}
58
}
62
59
63
int DocSequenceDb::getResCnt()
60
int DocSequenceDb::getResCnt()
64
{
61
{
62
    PTMutexLocker locker(o_dblock);
65
    if (!setQuery())
63
    if (!setQuery())
66
    return false;
64
    return false;
67
    if (m_rescnt < 0) {
65
    if (m_rescnt < 0) {
68
    m_rescnt= m_q->getResCnt();
66
    m_rescnt= m_q->getResCnt();
69
    }
67
    }
...
...
75
// This one only gets called to fill-up the snippets window
73
// This one only gets called to fill-up the snippets window
76
// We ignore most abstract/snippets preferences.
74
// We ignore most abstract/snippets preferences.
77
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs)
75
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs)
78
{
76
{
79
    LOGDEB(("DocSequenceDb::getAbstract/pair\n"));
77
    LOGDEB(("DocSequenceDb::getAbstract/pair\n"));
78
    PTMutexLocker locker(o_dblock);
80
    if (!setQuery())
79
    if (!setQuery())
81
    return false;
80
    return false;
82
81
83
    // Have to put the limit somewhere. 
82
    // Have to put the limit somewhere. 
84
    int maxoccs = 1000;
83
    int maxoccs = 1000;
...
...
105
    return true;
104
    return true;
106
}
105
}
107
106
108
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<string>& vabs)
107
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<string>& vabs)
109
{
108
{
109
    PTMutexLocker locker(o_dblock);
110
    if (!setQuery())
110
    if (!setQuery())
111
    return false;
111
    return false;
112
    if (m_q->whatDb() &&
112
    if (m_q->whatDb() &&
113
    m_queryBuildAbstract && (doc.syntabs || m_queryReplaceAbstract)) {
113
    m_queryBuildAbstract && (doc.syntabs || m_queryReplaceAbstract)) {
114
    m_q->makeDocAbstract(doc, vabs);
114
    m_q->makeDocAbstract(doc, vabs);
...
...
118
    return true;
118
    return true;
119
}
119
}
120
120
121
int DocSequenceDb::getFirstMatchPage(Rcl::Doc &doc, string& term)
121
int DocSequenceDb::getFirstMatchPage(Rcl::Doc &doc, string& term)
122
{
122
{
123
    PTMutexLocker locker(o_dblock);
123
    if (!setQuery())
124
    if (!setQuery())
124
    return false;
125
    return false;
125
    if (m_q->whatDb()) {
126
    if (m_q->whatDb()) {
126
    return m_q->getFirstMatchPage(doc, term);
127
    return m_q->getFirstMatchPage(doc, term);
127
    }
128
    }
...
...
133
    return m_q.isNotNull() ? m_q->whatDb() : 0;
134
    return m_q.isNotNull() ? m_q->whatDb() : 0;
134
}
135
}
135
136
136
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
137
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
137
{
138
{
139
    PTMutexLocker locker(o_dblock);
138
    if (!setQuery())
140
    if (!setQuery())
139
    return list<string>();
141
    return list<string>();
140
    vector<string> v = m_q->expand(doc);
142
    vector<string> v = m_q->expand(doc);
141
    return list<string>(v.begin(), v.end());
143
    return list<string>(v.begin(), v.end());
142
}
144
}
...
...
147
    if (m_isFiltered && !m_isSorted)
149
    if (m_isFiltered && !m_isSorted)
148
    qual = string(" (") + o_filt_trans + string(")");
150
    qual = string(" (") + o_filt_trans + string(")");
149
    else if (!m_isFiltered && m_isSorted)
151
    else if (!m_isFiltered && m_isSorted)
150
    qual = string(" (") + o_sort_trans + string(")");
152
    qual = string(" (") + o_sort_trans + string(")");
151
    else if (m_isFiltered && m_isSorted)
153
    else if (m_isFiltered && m_isSorted)
152
    qual = string(" (") + o_sort_trans + string(",") + o_filt_trans + string(")");
154
    qual = string(" (") + o_sort_trans + string(",") + o_filt_trans + 
155
            string(")");
153
    return DocSequence::title() + qual;
156
    return DocSequence::title() + qual;
154
}
157
}
155
158
156
bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs) 
159
bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs) 
157
{
160
{
158
    LOGDEB(("DocSequenceDb::setFiltSpec\n"));
161
    LOGDEB(("DocSequenceDb::setFiltSpec\n"));
162
    PTMutexLocker locker(o_dblock);
159
    if (fs.isNotNull()) {
163
    if (fs.isNotNull()) {
160
    // We build a search spec by adding a filtering layer to the base one.
164
    // We build a search spec by adding a filtering layer to the base one.
161
    m_fsdata = RefCntr<Rcl::SearchData>(
165
    m_fsdata = RefCntr<Rcl::SearchData>(
162
        new Rcl::SearchData(Rcl::SCLT_AND, m_sdata->getStemLang()));
166
        new Rcl::SearchData(Rcl::SCLT_AND, m_sdata->getStemLang()));
163
    Rcl::SearchDataClauseSub *cl = 
167
    Rcl::SearchDataClauseSub *cl = 
...
...
202
206
203
bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec) 
207
bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec) 
204
{
208
{
205
    LOGDEB(("DocSequenceDb::setSortSpec: fld [%s] %s\n", 
209
    LOGDEB(("DocSequenceDb::setSortSpec: fld [%s] %s\n", 
206
        spec.field.c_str(), spec.desc ? "desc" : "asc"));
210
        spec.field.c_str(), spec.desc ? "desc" : "asc"));
211
    PTMutexLocker locker(o_dblock);
207
    if (spec.isNotNull()) {
212
    if (spec.isNotNull()) {
208
    m_q->setSortBy(spec.field, !spec.desc);
213
    m_q->setSortBy(spec.field, !spec.desc);
209
    m_isSorted = true;
214
    m_isSorted = true;
210
    } else {
215
    } else {
211
    m_q->setSortBy(string(), true);
216
    m_q->setSortBy(string(), true);
...
...
232
}
237
}
233
238
234
bool DocSequenceDb::docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
239
bool DocSequenceDb::docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
235
{
240
{
236
    if (m_q->whatDb()) {
241
    if (m_q->whatDb()) {
242
        PTMutexLocker locker(o_dblock);
237
    return m_q->whatDb()->docDups(doc, dups);
243
    return m_q->whatDb()->docDups(doc, dups);
238
    } else {
244
    } else {
239
    return false;
245
    return false;
240
    }
246
    }
241
}
247
}