2
This file is part of the Nepomuk KDE project.
3
Copyright (C) 2010 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 Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) version 3, or any
9
later version accepted by the membership of KDE e.V. (or its
10
successor approved by the membership of KDE e.V.), which shall
11
act as a proxy defined in Section 6 of version 3 of the license.
13
This library is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Lesser General Public License for more details.
18
You should have received a copy of the GNU Lesser General Public
19
License along with this library. If not, see <http://www.gnu.org/licenses/>.
22
#ifndef _NEPOMUK_QUERY_PROXY_FACET_H_
23
#define _NEPOMUK_QUERY_PROXY_FACET_H_
26
#include "nepomukutils_export.h"
31
* \class ProxyFacet proxyfacet.h Nepomuk/Utils/ProxyFacet
33
* \ingroup nepomuk_facets
35
* \brief A facet forwarding the filtered choices from another facet.
37
* The ProxyFacet allows to perform filter operations on another facet.
38
* Most noticable one can set a general condition which needs to be fulfilled
39
* in the client query in order for the facet to show any choices.
41
* \sa \ref nepomuk_facet_examples
43
* \author Sebastian Trueg <trueg@kde.org>
47
class NEPOMUKUTILS_EXPORT ProxyFacet : public Facet
53
* Create a new proxy facet without a source.
55
ProxyFacet( QObject* parent = 0 );
60
virtual ~ProxyFacet();
63
* Set the source facet. The proxy will forward all calls to
66
void setSourceFacet( Facet* source );
69
* The source facet which this proxy facet is forwarding.
70
* \sa setSourceFacet()
72
Facet* sourceFacet() const;
75
* The selection mode forwarded from the sourceFacet().
77
SelectionMode selectionMode() const;
80
* The query term forwarded and optionally filtered from the sourceModel().
82
virtual Nepomuk::Query::Term queryTerm() const;
85
* \return The number of terms forwarded from the sourceFacet().
90
* The gui item forwarded from the sourceFacet().
92
KGuiItem guiItem( int index ) const;
95
* \return \p true if the term at \p index has been selected via
98
bool isSelected( int index ) const;
101
* The facet condition set via setFacetCondition()
103
Nepomuk::Query::Term facetCondition() const;
107
* Allows to set a condition for the entire facet. Unless it is not met in the
108
* client query set via setClientQuery() the facet does not provide any choices.
110
* \param term The condition term. If valid this facet will only show any choices
111
* if the client query contains \p term in a non-optional way.
113
* A typical example is a facet which filters images by size. In that case the
116
* Query::ResourceTypeTerm( Vocabulary::NFO::RasterImage() );
118
* since filtering by image size does only make sense if only images are selected.
120
void setFacetCondition( const Nepomuk::Query::Term& queryTerm );
123
* Clear the selection. If selectionMode() is MatchOne the first
124
* choice should be selected.
126
void clearSelection();
129
* Selects or deselects the term at \p index. Depending on the selectionMode()
130
* this will also affect the selection of other terms.
132
void setSelected( int index, bool selected = true );
135
* The \p term is analyzed depending on the selectionMode().
137
* \sa Facet::selectFromTerm()
139
bool selectFromTerm( const Nepomuk::Query::Term& queryTerm );
143
* Used internally to determine if the facet condition is met. Can be
144
* reimplemented for customized filtering.
146
* \return \p true if the facet condition is met and all choices from the
147
* source facet should be forwarded.
149
virtual bool facetConditionMet() const;
151
void handleClientQueryChange();