~ubuntu-branches/ubuntu/natty/kde4libs/natty-proposed

« back to all changes in this revision

Viewing changes to nepomuk/utils/proxyfacet.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell, Scott Kitterman, Jonathan Riddell
  • Date: 2010-11-22 17:59:02 UTC
  • mfrom: (1.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122175902-yubxubd0pg6hn11z
Tags: 4:4.5.80a-0ubuntu1
[ Scott Kitterman ]
* New upstream beta release
  - Refreshed all patches
  - Updated debian/patches/10_make_libkdeinit4_private.diff to use Qfile
    instead of Qstring in kdecore/kernel/kstandarddirs_unix.cpp
  - Updated debian/patches/kubuntu_01_kubuntu_useragent.diff to provide
    Kubuntu in the Konqueror user agen string with the changes in
    kio/kio/kprotocolmanager.cpp
  - Partially updated debian/patches/kubuntu_05_langpack_desktop_files.diff
    and left the balance in kdecore/localization/klocale.cpp.rej for later
    revision
  - Update debian/patches/kubuntu_06_user_disk_mounting.diff for changes in
    solid/solid/backends/hal/halstorageaccess.cpp
  - Remove debian/patches/kubuntu_71_backport_plasma_webview_changes.diff
    (backported from upstream, so already present now)
  - Add minimum version for libattica-dev of 0.1.90 to build-depends
  - Bump minimum version for libsoprano-dev build-depend to 2.5.60
  - Add minimum version for shared-desktop-ontologies of 0.5 in build-dep

[ Jonathan Riddell ]
* Add build-depends on grantlee, libudev-dev, hupnp (FIXME needs packaging fixes)
* Update kubuntu_04_add_langpack_path.diff 28_find_old_kde4_html_documentation.diff
  22_hack_in_etc_kde4_in_kstandarddirs.diff for QT_NO_CAST_FROM_ASCII
* Update kubuntu_05_langpack_desktop_files.diff for new upstream code
* Add kubuntu_78_solid_trunk.diff to fix solid linking
* Add libnepomukutils4 package for new library
* Don't install kcm_ssl for now, e-mailed upstream to suggest moving to kdebase
* Add kubuntu_79_knewstuff_fix.diff to fix compile broken by non-trunk commit
  http://websvn.kde.org/?view=revision&revision=1199825
* kdelibs5-data replaces old kdebase-runtime-data due to moved file
* Add kubuntu_80_find_hupnp.diff to find hupnp include files, committed upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   This file is part of the Nepomuk KDE project.
 
3
   Copyright (C) 2010 Sebastian Trueg <trueg@kde.org>
 
4
 
 
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.
 
12
 
 
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.
 
17
 
 
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/>.
 
20
*/
 
21
 
 
22
#ifndef _NEPOMUK_QUERY_PROXY_FACET_H_
 
23
#define _NEPOMUK_QUERY_PROXY_FACET_H_
 
24
 
 
25
#include "facet.h"
 
26
#include "nepomukutils_export.h"
 
27
 
 
28
namespace Nepomuk {
 
29
    namespace Utils {
 
30
        /**
 
31
         * \class ProxyFacet proxyfacet.h Nepomuk/Utils/ProxyFacet
 
32
         *
 
33
         * \ingroup nepomuk_facets
 
34
         *
 
35
         * \brief A facet forwarding the filtered choices from another facet.
 
36
         *
 
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.
 
40
         *
 
41
         * \sa \ref nepomuk_facet_examples
 
42
         *
 
43
         * \author Sebastian Trueg <trueg@kde.org>
 
44
         *
 
45
         * \since 4.6
 
46
         */
 
47
        class NEPOMUKUTILS_EXPORT ProxyFacet : public Facet
 
48
        {
 
49
            Q_OBJECT
 
50
 
 
51
        public:
 
52
            /**
 
53
             * Create a new proxy facet without a source.
 
54
             */
 
55
            ProxyFacet( QObject* parent = 0 );
 
56
 
 
57
            /**
 
58
             * Destructor.
 
59
             */
 
60
            virtual ~ProxyFacet();
 
61
 
 
62
            /**
 
63
             * Set the source facet. The proxy will forward all calls to
 
64
             * \p source.
 
65
             */
 
66
            void setSourceFacet( Facet* source );
 
67
 
 
68
            /**
 
69
             * The source facet which this proxy facet is forwarding.
 
70
             * \sa setSourceFacet()
 
71
             */
 
72
            Facet* sourceFacet() const;
 
73
 
 
74
            /**
 
75
             * The selection mode forwarded from the sourceFacet().
 
76
             */
 
77
            SelectionMode selectionMode() const;
 
78
 
 
79
            /**
 
80
             * The query term forwarded and optionally filtered from the sourceModel().
 
81
             */
 
82
            virtual Nepomuk::Query::Term queryTerm() const;
 
83
 
 
84
            /**
 
85
             * \return The number of terms forwarded from the sourceFacet().
 
86
             */
 
87
            int count() const;
 
88
 
 
89
            /**
 
90
             * The gui item forwarded from the sourceFacet().
 
91
             */
 
92
            KGuiItem guiItem( int index ) const;
 
93
 
 
94
            /**
 
95
             * \return \p true if the term at \p index has been selected via
 
96
             * setSelected().
 
97
             */
 
98
            bool isSelected( int index ) const;
 
99
 
 
100
            /**
 
101
             * The facet condition set via setFacetCondition()
 
102
             */
 
103
            Nepomuk::Query::Term facetCondition() const;
 
104
 
 
105
        public Q_SLOTS:
 
106
            /**
 
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.
 
109
             *
 
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.
 
112
             *
 
113
             * A typical example is a facet which filters images by size. In that case the
 
114
             * condition would be
 
115
             * \code
 
116
             * Query::ResourceTypeTerm( Vocabulary::NFO::RasterImage() );
 
117
             * \endcode
 
118
             * since filtering by image size does only make sense if only images are selected.
 
119
             */
 
120
            void setFacetCondition( const Nepomuk::Query::Term& queryTerm );
 
121
 
 
122
            /**
 
123
             * Clear the selection. If selectionMode() is MatchOne the first
 
124
             * choice should be selected.
 
125
             */
 
126
            void clearSelection();
 
127
 
 
128
            /**
 
129
             * Selects or deselects the term at \p index. Depending on the selectionMode()
 
130
             * this will also affect the selection of other terms.
 
131
             */
 
132
            void setSelected( int index, bool selected = true );
 
133
 
 
134
            /**
 
135
             * The \p term is analyzed depending on the selectionMode().
 
136
             *
 
137
             * \sa Facet::selectFromTerm()
 
138
             */
 
139
            bool selectFromTerm( const Nepomuk::Query::Term& queryTerm );
 
140
 
 
141
        protected:
 
142
            /**
 
143
             * Used internally to determine if the facet condition is met. Can be
 
144
             * reimplemented for customized filtering.
 
145
             *
 
146
             * \return \p true if the facet condition is met and all choices from the
 
147
             * source facet should be forwarded.
 
148
             */
 
149
            virtual bool facetConditionMet() const;
 
150
 
 
151
            void handleClientQueryChange();
 
152
 
 
153
        private:
 
154
            class Private;
 
155
            Private* const d;
 
156
        };
 
157
    }
 
158
}
 
159
 
 
160
#endif