source: trunk/tools/assistant/lib/fulltextsearch/qhits.cpp@ 966

Last change on this file since 966 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 2.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team.
4** All rights reserved.
5**
6** Portion Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
7** All rights reserved.
8**
9** This file may be used under the terms of the GNU Lesser General Public
10** License version 2.1 as published by the Free Software Foundation and
11** appearing in the file LICENSE.LGPL included in the packaging of this file.
12** Please review the following information to ensure the GNU Lesser General
13** Public License version 2.1 requirements will be met:
14** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
15**
16****************************************************************************/
17
18#include "qhits_p.h"
19#include "qsearchable_p.h"
20
21#include <CLucene.h>
22#include <CLucene/search/SearchHeader.h>
23
24QT_BEGIN_NAMESPACE
25
26QCLuceneHitsPrivate::QCLuceneHitsPrivate()
27 : QSharedData()
28{
29 hits = 0;
30 deleteCLuceneHits = true;
31}
32
33QCLuceneHitsPrivate::QCLuceneHitsPrivate(const QCLuceneHitsPrivate &other)
34 : QSharedData()
35{
36 hits = _CL_POINTER(other.hits);
37 deleteCLuceneHits = other.deleteCLuceneHits;
38}
39
40QCLuceneHitsPrivate::~QCLuceneHitsPrivate()
41{
42 if (deleteCLuceneHits)
43 _CLDECDELETE(hits);
44}
45
46
47QCLuceneHits::QCLuceneHits(const QCLuceneSearcher &searcher,
48 const QCLuceneQuery &query, const QCLuceneFilter &filter)
49 : d(new QCLuceneHitsPrivate())
50{
51 d->hits = new lucene::search::Hits(searcher.d->searchable, query.d->query,
52 filter.d->filter);
53}
54
55QCLuceneHits::QCLuceneHits(const QCLuceneSearcher &searcher, const QCLuceneQuery &query,
56 const QCLuceneFilter &filter, const QCLuceneSort &sort)
57 : d(new QCLuceneHitsPrivate())
58{
59 d->hits = new lucene::search::Hits(searcher.d->searchable, query.d->query,
60 filter.d->filter, sort.d->sort);
61}
62
63QCLuceneHits::~QCLuceneHits()
64{
65 // nothing todo
66}
67
68QCLuceneDocument QCLuceneHits::document(const qint32 index)
69{
70 // TODO: check this
71 QCLuceneDocument document;
72 document.d->deleteCLuceneDocument = false;
73 lucene::document::Document &doc = d->hits->doc(int32_t(index));
74 document.d->document = &doc;
75
76 return document;
77}
78
79qint32 QCLuceneHits::length() const
80{
81 return qint32(d->hits->length());
82}
83
84qint32 QCLuceneHits::id(const qint32 index)
85{
86 return qint32(d->hits->id(int32_t(index)));
87}
88
89qreal QCLuceneHits::score(const qint32 index)
90{
91 return qreal(d->hits->score(int32_t(index)));
92}
93
94QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.