2 This file is part of the Nepomuk KDE project.
3 Copyright (C) 2008 Sebastian Trueg <trueg@kde.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
23 #include <QtCore/QSharedData>
24 #include <QtCore/QHash>
27 class Nepomuk::Search::Result::Private
: public QSharedData
32 QHash
<QUrl
, Soprano::Node
> requestProperties
;
36 Nepomuk::Search::Result::Result()
42 Nepomuk::Search::Result::Result( const QUrl
& uri
, double score
)
50 Nepomuk::Search::Result::Result( const Result
& other
)
56 Nepomuk::Search::Result::~Result()
61 Nepomuk::Search::Result
& Nepomuk::Search::Result::operator=( const Result
& other
)
68 double Nepomuk::Search::Result::score() const
74 QUrl
Nepomuk::Search::Result::resourceUri() const
80 void Nepomuk::Search::Result::setScore( double score
)
86 void Nepomuk::Search::Result::addRequestProperty( const QUrl
& property
, const Soprano::Node
& value
)
88 d
->requestProperties
[property
] = value
;
92 Soprano::Node
Nepomuk::Search::Result::operator[]( const QUrl
& property
) const
94 return requestProperty( property
);
98 Soprano::Node
Nepomuk::Search::Result::requestProperty( const QUrl
& property
) const
100 QHash
<QUrl
, Soprano::Node
>::const_iterator it
= d
->requestProperties
.find( property
);
101 if ( it
!= d
->requestProperties
.end() ) {
105 return Soprano::Node();
110 QHash
<QUrl
, Soprano::Node
> Nepomuk::Search::Result::requestProperties() const
112 return d
->requestProperties
;
116 bool Nepomuk::Search::Result::operator==( const Result
& other
) const
118 if ( d
->resource
!= other
.d
->resource
||
119 d
->score
!= other
.d
->score
) {
122 for ( QHash
<QUrl
, Soprano::Node
>::const_iterator it
= d
->requestProperties
.constBegin();
123 it
!= d
->requestProperties
.constEnd(); ++it
) {
124 QHash
<QUrl
, Soprano::Node
>::const_iterator it2
= other
.d
->requestProperties
.constFind( it
.key() );
125 if ( it2
== other
.d
->requestProperties
.constEnd() ||
126 it2
.value() != it
.value() ) {
130 for ( QHash
<QUrl
, Soprano::Node
>::const_iterator it
= other
.d
->requestProperties
.constBegin();
131 it
!= other
.d
->requestProperties
.constEnd(); ++it
) {
132 QHash
<QUrl
, Soprano::Node
>::const_iterator it2
= d
->requestProperties
.constFind( it
.key() );
133 if ( it2
== d
->requestProperties
.constEnd() ||
134 it2
.value() != it
.value() ) {