]> cloud.milkyroute.net Git - dolphin.git/blob - src/tagcloud/tagcloud.h
* changed "Click to add comment..." to simply "Add comment..." for consistency with...
[dolphin.git] / src / tagcloud / tagcloud.h
1 /*
2 This file is part of the Nepomuk KDE project.
3 Copyright (C) 2007 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 Library General Public
7 License version 2 as published by the Free Software Foundation.
8
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.
13
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.
18 */
19
20 #ifndef _NEPOMUK_TAG_CLOUD_H_
21 #define _NEPOMUK_TAG_CLOUD_H_
22
23 #include <QtGui/QFrame>
24 #include <QtCore/QList>
25
26 #include <nepomuk/tag.h>
27 #include <nepomuk/nepomuk_export.h>
28
29 #include <Soprano/Statement>
30
31 class QResizeEvent;
32 class QPaintEvent;
33 class QMouseEvent;
34 class QEvent;
35
36 namespace Nepomuk {
37 class NEPOMUK_EXPORT TagCloud : public QFrame
38 {
39 Q_OBJECT
40
41 public:
42 TagCloud( QWidget* parent = 0 );
43 ~TagCloud();
44
45 enum Sorting {
46 SortAlpabetically,
47 SortByWeight,
48 SortRandom
49 };
50
51 int heightForWidth( int w ) const;
52 QSize sizeHint() const;
53 QSize minimumSizeHint() const;
54
55 bool zoomEnabled() const;
56
57 public Q_SLOTS:
58 /**
59 * Set the maximum used font size. The default is 0
60 * which means to calculate proper values from the KDE
61 * defaults.
62 */
63 void setMaxFontSize( int size );
64
65 /**
66 * Set the minimum used font size. The default is 0
67 * which means to calculate proper values from the KDE
68 * defaults.
69 */
70 void setMinFontSize( int size );
71
72 /**
73 * Set the maximum number of displayed tags. The default is 0
74 * which means to display all tags.
75 *
76 * NOT IMPLEMENTED YET
77 */
78 void setMaxNumberDisplayedTags( int n );
79
80 /**
81 * Allow selection of tags, i.e. enabling and disabling of tags.
82 */
83 void setSelectionEnabled( bool enabled );
84
85 void setNewTagButtonEnabled( bool enabled );
86 void setContextMenuEnabled( bool enabled );
87 void setAlignment( Qt::Alignment alignment );
88
89 void setZoomEnabled( bool zoom );
90
91 /**
92 * Default: SortAlpabetically
93 */
94 void setSorting( Sorting );
95
96 /**
97 * Will reset tags set via showTags()
98 */
99 void showAllTags();
100
101 /**
102 * Set the tags to be shown in the tag cloud.
103 * If the new tag button is enabled (setEnableNewTagButton())
104 * new tags will automatically be added to the list of shown tags.
105 */
106 void showTags( const QList<Tag>& tags );
107
108 void showResourceTags( const Resource& resource );
109
110 /**
111 * Select or deselect a tag. This does only make sense
112 * if selection is enabled and \p tag is actually
113 * displayed.
114 *
115 * \sa setSelectionEnabled
116 */
117 void setTagSelected( const Tag& tag, bool selected );
118
119 void setCustomNewTagAction( QAction* action );
120
121 Q_SIGNALS:
122 void tagClicked( const Nepomuk::Tag& tag );
123 void tagAdded( const Nepomuk::Tag& tag );
124 void tagToggled( const Nepomuk::Tag& tag, bool enabled );
125
126 protected:
127 void resizeEvent( QResizeEvent* e );
128 void paintEvent( QPaintEvent* e );
129 void mousePressEvent( QMouseEvent* );
130 void mouseMoveEvent( QMouseEvent* );
131 void leaveEvent( QEvent* );
132
133 private Q_SLOTS:
134 void slotStatementAdded( const Soprano::Statement& s );
135 void slotStatementRemoved( const Soprano::Statement& s );
136
137 private:
138 class Private;
139 Private* const d;
140 };
141 }
142
143 #endif